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.2
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.2
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 ps/lsof calls). Errors from ps/lsof are silently ignored — callers get empty maps on failure.
type PIDCache ¶ added in v0.3.2
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.2
func LoadPIDCache() *PIDCache
LoadPIDCache reads the cache from disk. Missing file is not an error.
func (*PIDCache) GC ¶ added in v0.3.2
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.2
type ProcInfo struct {
PID string // numeric string from ps
LStart string // raw lstart string from ps (opaque, used only for equality)
CWD string // working directory from lsof
}
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.2
func CollectProcs() []ProcInfo
CollectProcs returns running claude/opencode processes with pid, lstart, and CWD.
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.