discover

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package discover enumerates agent session files from each agent's known roots. It only locates files; reading their headers and resolving them to a project is the resolve package's job.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Matches

func Matches(agent, name string) bool

Matches reports whether a filename is a session file for the given agent. Codex files are named rollout-*.jsonl; Claude and pi use any *.jsonl. This is only a suffix gate: every agent's files are further validated by a positive session-header signature at resolve time (see resolve.sessionSignature), which is what keeps unrelated *.jsonl under a custom extra_root from being ingested.

Types

type Excluder

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

Excluder skips discovered paths that match any of a set of glob patterns, backing the config's `excludes` knob (config.Client.Excludes) so a user can keep a sensitive or noisy session directory from being discovered, watched, and uploaded. Patterns match against the full path with forward slashes, and `*` (or `**`) spans separators, so `**/tmp/**` excludes any path with a `tmp` segment and `*.private.jsonl` excludes by suffix anywhere. A zero Excluder (no patterns) excludes nothing, so callers that do not filter pass the zero value.

func NewExcluder

func NewExcluder(globs []string) Excluder

NewExcluder compiles a set of exclude globs. Blank patterns are dropped and every pattern is normalized to forward slashes so a config written on one OS matches paths discovered on another.

func (Excluder) Excluded

func (e Excluder) Excluded(path string) bool

Excluded reports whether path matches any exclude pattern. The path is normalized to forward slashes before matching so the patterns are OS-agnostic.

func (Excluder) ExcludedDir

func (e Excluder) ExcludedDir(path string) bool

ExcludedDir reports whether a directory should be pruned. A directory is matched both bare and with a trailing slash so either pattern style prunes it: the bare form catches an exact pattern like `**/private`, and the trailing-slash form catches a subtree pattern like `**/tmp/**` (whose trailing `**` needs the slash to match the directory node itself, not just files under it).

type File

type File struct {
	Agent string // claude | codex | pi
	Root  string
	Path  string
}

File is one discovered session file. Root is the discovery directory the file was found under: it is what lets resolution compute a stable, unique id from the file's location relative to the root, which is how Claude's subagent and workflow files (which all carry their parent's sessionId inside) avoid colliding on a single source id.

func Discover

func Discover(roots []Root, ex Excluder) ([]File, error)

Discover walks every root and returns the session files it finds, de-duplicated by path and sorted for stable output. A missing root is not an error: agents a user does not run simply contribute nothing. ex drops paths the user configured to exclude (pass the zero Excluder to keep everything): an excluded directory is pruned from the walk, and an excluded file is skipped, so an ignored location is never discovered, watched, or uploaded.

type Root

type Root struct {
	Agent string
	Dir   string
}

Root is a directory to scan for one agent's sessions.

func Roots

func Roots(cfg config.Client, env func(string) string, home string) []Root

Roots builds the directories to scan for each agent. It honors each agent's own documented environment override (akari defines none of its own) via the env lookup, falls back to the standard location under home, and appends any extra roots from the config.

Jump to

Keyboard shortcuts

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