Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToolNamesFromPatterns ¶
TitlePatternsFromConfig compiles config regex strings into TitlePatterns. agentNames is the list of known tool names used to infer the tool label from each pattern string (e.g. a pattern containing "claude" maps to tool "claude"). Pass nil to fall back to the generic "agent" label for all patterns. The list should come from config so no source-code change is required when a new tool is added.
ToolNamesFromPatterns extracts clean binary names for process detection from the same pattern list. Use it alongside TitlePatternsFromConfig so that patterns containing regex metacharacters (e.g. "^pi$") map correctly to process names (e.g. "pi").
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores classification results, invalidated on process fingerprint change.
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier classifies tmux panes as agent or non-agent.
func New ¶
func New(titles []TitlePattern, reader process.ProcessReader, capture ContentCapture, scorer ContentScorer) *Classifier
New creates a Classifier with the given dependencies. titlePatterns drives both Tier 1 (pane title) and Tier 2 (process binary name) detection, so no separate tool-name list is required.
func (*Classifier) Classify ¶
func (c *Classifier) Classify(ctx context.Context, input PaneInput) Result
Classify runs the 3-tier cascade on a single pane.
func (*Classifier) ClassifyStable ¶
func (c *Classifier) ClassifyStable(input PaneInput) Result
ClassifyStable runs only Tier 1 (title) and Tier 2 (process) classification. It skips Tier 3 content capture, which spawns external subprocesses. Use this during periodic cache refresh when Tier 3 is gated by a rate limiter.
func (*Classifier) WithReader ¶
func (c *Classifier) WithReader(r process.ProcessReader) *Classifier
WithReader returns a shallow copy of the Classifier that uses r for process identification instead of the original reader. Use this to inject a per-refresh-cycle SnapshotReader without mutating the shared Classifier.
type Confidence ¶
type Confidence string
Confidence represents classification certainty.
const ( // ConfidenceHigh indicates a strong classification signal. ConfidenceHigh Confidence = "high" // ConfidenceMedium indicates a moderate classification signal. ConfidenceMedium Confidence = "medium" )
type ContentCapture ¶
ContentCapture abstracts pane content retrieval for Tier 3.
type ContentScorer ¶
ContentScorer scores terminal content for agent-like signals.
type PaneInput ¶
type PaneInput struct {
SessionName string
PaneID string
PanePID int64
WindowIndex string
WindowName string
PaneTitle string
WorkDir string
Activity int64
HiveSession string
}
PaneInput holds the raw data for one pane from tmux list-panes.
type Result ¶
type Result struct {
IsAgent bool
Tool string
Confidence Confidence
Tier int
ClassifiedAt time.Time
}
Result holds the classification output for a single pane.
func (Result) StableForProcessCache ¶
StableForProcessCache reports whether this positive result can be reused while the pane foreground process fingerprint is unchanged.
type TitlePattern ¶
TitlePattern is a compiled regex for Tier 1 title matching.
func TitlePatternsFromConfig ¶
func TitlePatternsFromConfig(patterns []string, agentNames []string) []TitlePattern