Documentation
¶
Index ¶
- Variables
- func FindSessionFile(sessionID, projectsDir string) string
- func FindSessionFileDefault(sessionID string) string
- func GetProcessCwd(pid int) (string, error)
- func MatchTmuxSession(sessions []TmuxSession, workingDir string) string
- func PsLines(psOutput string) []string
- func ScanProcesses() ([]agent.Agent, error)
- func ScanProcessesFromOutput(psOutput string) []agent.Agent
- func SessionFilesForDir(workingDir string) []string
- type AgentProvider
- type Orchestrator
- type SessionInfo
- type Snapshot
- type SnapshotProvider
- type TmuxSession
Constants ¶
This section is empty.
Variables ¶
var GetParentPID = getParentPIDImpl
GetParentPID returns the parent PID for a given process, or 0 on error. Exported for use by the correlator. Variable so tests can override it.
Functions ¶
func FindSessionFile ¶
FindSessionFile searches for a session JSONL file matching the given session ID within the projects directory.
func FindSessionFileDefault ¶
FindSessionFileDefault searches for a session file using the default ~/.claude/projects/ directory.
func GetProcessCwd ¶
GetProcessCwd returns the current working directory of a process. Uses `lsof -a -d cwd -p PID -Fn` which only queries the cwd file descriptor instead of listing all open files. Times out after 3 seconds to avoid blocking the discovery loop when lsof hangs on a process.
func MatchTmuxSession ¶
func MatchTmuxSession(sessions []TmuxSession, workingDir string) string
MatchTmuxSession finds a tmux session matching the "claude-<project>" naming convention based on the working directory's base name.
func PsLines ¶ added in v0.8.1
PsLines returns the trimmed non-empty lines from ps aux output (skipping header). Providers use this to avoid re-splitting the shared snapshot.
func ScanProcesses ¶
ScanProcesses runs `ps aux`, parses each line, and returns Instance stubs for every detected Claude process. Subagent processes (whose parent PID is also a Claude process) are automatically filtered out so that only top-level sessions appear.
func ScanProcessesFromOutput ¶ added in v0.8.1
ScanProcessesFromOutput parses pre-captured `ps aux` output for Claude processes.
func SessionFilesForDir ¶
SessionFilesForDir finds all JSONL session files associated with a working directory. Claude converts directory paths by replacing "/" with "-" to form the project directory key.
Types ¶
type AgentProvider ¶
AgentProvider is the minimal interface that the orchestrator requires from each provider. It is intentionally kept small to avoid a circular dependency between the discovery and provider packages. Any type implementing provider.Provider automatically satisfies this interface.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator coordinates multiple providers to produce a unified list of agents.
func NewOrchestrator ¶
func NewOrchestrator(providers ...AgentProvider) *Orchestrator
NewOrchestrator creates an orchestrator that iterates the given providers.
func (*Orchestrator) Discover ¶
func (o *Orchestrator) Discover() ([]agent.Agent, error)
Discover queries every registered provider and merges the results. A single process snapshot is taken first and shared with providers that implement SnapshotProvider, avoiding redundant ps/tmux calls.
func (*Orchestrator) ProviderFor ¶
func (o *Orchestrator) ProviderFor(name string) AgentProvider
ProviderFor returns the first provider whose Name() matches the given name, or nil if no provider matches.
type SessionInfo ¶
type SessionInfo struct {
SessionID string
GitBranch string
Model string
TokensIn int64
TokensOut int64
CacheReadTokens int64
CacheWriteTokens int64
MessageCount int
LastTimestamp time.Time
LastAction string // most recent tool call, e.g. "Ed main.go"
}
SessionInfo holds aggregated data parsed from a Claude JSONL session file.
func ParseSessionFile ¶
func ParseSessionFile(path string) (SessionInfo, error)
ParseSessionFile reads a JSONL session file and aggregates token usage across all messages.
type Snapshot ¶ added in v0.8.1
type Snapshot struct {
PsOutput string // raw `ps aux` output
TmuxSessions []TmuxSession // parsed tmux sessions
}
Snapshot holds shared data collected once and reused by all providers.
func TakeSnapshot ¶ added in v0.8.1
func TakeSnapshot() *Snapshot
TakeSnapshot captures a process snapshot (ps aux + tmux) once.
type SnapshotProvider ¶ added in v0.8.1
SnapshotProvider is an optional interface for providers that can accept a shared process snapshot. This avoids each provider calling `ps aux` and `tmux list-sessions` independently (~200ms each).
type TmuxSession ¶
TmuxSession represents a tmux session with its name and attachment state.
func ListTmuxSessions ¶
func ListTmuxSessions() []TmuxSession
ListTmuxSessions runs `tmux list-sessions` and returns the parsed results. Returns nil if tmux is not running or not installed.