collect

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package collect reads the agent network off this machine, read-only:

  • leases ~/.claude/agentsync/locks/*.lease
  • tells ~/.claude/agentsync/locks/<target>.messages
  • session recs ~/.claude/agentsync/sessions/<uuid>.json
  • transcripts ~/.claude/projects/<project>/<session>.jsonl, and the sub-agents under <project>/<session>/subagents/

and folds them into one model.Snapshot. It never writes to any of them, it reads transcripts incrementally and bounded, and it extracts metadata only (see transcript.go for what is and is not decoded).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentWindows added in v0.10.4

func AgentWindows(claudeDir string) map[string]int64

AgentWindows are the compaction windows the agent definitions of claudeDir/agents/<type>.md name in their frontmatter (autoCompactWindow), by agent type. A type whose file names none, or a bad one, is left out: it runs under the session's window.

func CompactWindow added in v0.9.0

func CompactWindow(claudeDir string, getenv func(string) string) int64

CompactWindow is the context size, in tokens, at which Claude Code compacts: autoCompactWindow of claudeDir/settings.json, else the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable, else one million. A value that is not a positive integer is not a window and falls through to the next source. getenv is os.Getenv, or a test's.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector holds what is remembered between snapshots: the offset reached in each transcript and the parsed form of each small file that has not changed.

func New

func New(o Options) *Collector

New returns a Collector.

func (*Collector) Snapshot

func (c *Collector) Snapshot() model.Snapshot

Snapshot collects the picture now.

type Options

type Options struct {
	ClaudeDir     string        // ~/.claude
	LocalhostRoot string        // ~/Documents/VCS/GIT/localhost
	GithubRoot    string        // ~/Documents/VCS/GIT/github.com
	Active        time.Duration // a session is active when written within this
	Horizon       time.Duration // sessions and expired leases older than this are not listed
	TellWindow    time.Duration // tells older than this are not listed
	TailBytes     int64         // first read of a transcript covers its last TailBytes
	MaxLine       int           // a transcript line longer than this is skipped
	MaxTellText   int           // runes of a tell text kept
	MaxAgents     int           // sub-agents listed per session (newest first)
	Now           func() time.Time
}

Options configures a Collector. The zero value is not useful; use DefaultOptions.

func DefaultOptions

func DefaultOptions() (Options, error)

DefaultOptions are the settings of `agentscope serve` without flags.

type Resolver

type Resolver struct {
	LocalhostRoot string // <org>-<repo>[-topic] clones
	GithubRoot    string // <org>/<repo> clones
	TTL           time.Duration
	Now           func() time.Time
	// contains filtered or unexported fields
}

Resolver turns what a lease calls its resource into a repository, when it is one. A lease key is whatever a session typed: "go-tex/engine", "github.com/go-ansible/.github", and also a task note used as the key, or a flag ("--note"). The first two are repositories; the rest are anomalies the UI must show, not drop.

func (*Resolver) RepoOfCwd

func (r *Resolver) RepoOfCwd(cwd string) string

RepoOfCwd names the repository a working directory is inside, or "".

func (*Resolver) Resolve

func (r *Resolver) Resolve(resource string) (key string, kind model.RepoKind, path string)

Resolve classifies a lease resource. The answer is cached until the index of clones is rebuilt: a snapshot resolves every lease, hundreds of them, and the same keys come back every tick.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL