Documentation
¶
Overview ¶
Package source loads and normalises Claude and Opencode sessions; detects active sessions via PID/lsof.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveResult ¶ added in v0.3.1
type ActiveResult struct {
Confirmed map[string]bool // session IDs matched by cache
Guessed map[string]bool // session IDs matched by CWD fallback
}
ActiveResult holds the outcome of DetectActive split by confidence level. Confirmed: session identified via pid+lstart cache — certain. Guessed: session identified via CWD+mtime fallback — probable but not certain.
func DetectActive ¶ added in v0.3.1
func DetectActive(sessions []Session, procs []ProcInfo, cache *PIDCache) ActiveResult
DetectActive returns session IDs that are currently active, split by confidence.
For each running claude/opencode process:
- If the cache has a pid+lstart → sessionID mapping, use it directly (Confirmed).
- Otherwise fall back: session CWD must match process CWD AND last-activity timestamp must be today (>= local midnight) (Guessed).
procs must be pre-collected by the caller (avoids duplicate CollectProcs calls). Errors from CollectProcs are silently ignored — callers get empty maps on failure.
type MetaCache ¶ added in v0.3.6
type MetaCache struct {
// contains filtered or unexported fields
}
MetaCache is an in-process cache backed by a gob file on disk. The backing file lives at ~/.cache/aps/session-meta.gob.
func LoadMetaCache ¶ added in v0.3.6
func LoadMetaCache() *MetaCache
LoadMetaCache reads ~/.cache/aps/session-meta.gob. Returns an empty cache (never nil, never error) if file is missing or corrupt.
func (*MetaCache) Lookup ¶ added in v0.3.6
Lookup returns the cached entry for path if mtime AND size both match. Returns (entry, true) on hit, (zero, false) on miss.
type PIDCache ¶ added in v0.3.1
type PIDCache struct {
// contains filtered or unexported fields
}
PIDCache persists pid→sessionID mappings across aps invocations. The backing file lives at ~/.cache/aps/pid-session.txt. Format: one entry per line: "pid|lstart|sessionID"
func LoadPIDCache ¶ added in v0.3.1
func LoadPIDCache() *PIDCache
LoadPIDCache reads the cache from disk. Missing file is not an error.
func (*PIDCache) GC ¶ added in v0.3.1
GC removes entries whose process is no longer running, then persists. Intended to run in a goroutine; call wg.Done when finished.
type ProcInfo ¶ added in v0.3.1
type ProcInfo struct {
PID string // numeric process ID
LStart string // process create time as Unix ms string (opaque, used only for equality)
CWD string // working directory
}
ProcInfo identifies a specific process instance by pid and start time. Using both fields prevents pid-reuse collisions: the same pid with a different lstart is a different process.
func CollectProcs ¶ added in v0.3.1
func CollectProcs() []ProcInfo
CollectProcs returns running claude/opencode processes with pid, lstart, and CWD. Uses gopsutil for pure-Go process inspection (no ps/lsof subprocess overhead).
type Session ¶
type Session struct {
Client Client
ID string // UUID (Claude) or Opencode session ID
Title string
CWD string // Absolute working directory
CWDDisplay string // ~ abbreviated
ProjectPath string // Claude only: full path to project dir
Time time.Time // Used for sorting (newest first)
MsgCount int
// contains filtered or unexported fields
}
func LoadClaude ¶
LoadClaude returns all Claude Code sessions, optionally filtered by path.
func LoadOpencode ¶
LoadOpencode returns all Opencode sessions, optionally filtered by path. It auto-detects storage format: SQLite takes precedence over JSON.