Skip to main content

Module session

Module session 

Source
Expand description

Session metadata sidecar + path derivation.

csd tracks each driven session with a small JSON sidecar under the state dir so ps/state can recover the session id, cwd and transcript path without re-deriving them. tmux remains the source of truth for liveness; the sidecar is the source of truth for identity.

Structs§

Session
Persisted identity of one driven session.

Functions§

cwd_slug
Slugify a cwd the way claude names its project transcript dir: every /-.
jsonl_path
Deterministic transcript path: ~/.claude/projects/<cwd-slug>/<session-id>.jsonl.
mtime_epoch
Modification time of path as Unix epoch seconds, if available.
now_epoch
Current Unix epoch in seconds. (Clock-before-epoch is impossible in practice → 0 fallback.)
plans_dir
~/.claude/plans — where claude writes plan files in plan mode (global, not per-session).
validate_name
Reject session names that aren’t a single safe path segment. A name becomes both a tmux session name and a sidecar filename, so it must contain only [A-Za-z0-9._-], start with an alphanumeric or underscore (no leading - that tmux could read as a flag), and never contain ...