Skip to main content

Module state

Module state 

Source
Expand description

Scan ~/.claude/state/ for markers that tell us what’s blocked, what has an active intent, and which repos have a fresh review marker.

Marker schemes mirror ~/.claude/hooks/_lib.sh::repo_hash (first 12 chars of MD5 of the repo root path string). We deliberately re-implement the hash rather than shelling out to keep this read-only and fast.

Structs§

ClaudeStateMarkers
Snapshot of the marker files we care about.
CodexJob
One row from a codex-companion workspace’s state.json::jobs[]. The companion writes one workspace directory per repo, each with a single state.json carrying the full job history — we filter to the still- active ones so the dashboard isn’t dominated by completed tasks.

Constants§

CODEX_JOB_MAX_AGE_MS
Heuristic: how long can a job sit in non-terminal status before we stop trusting the file? Real codex tasks finish in seconds-minutes; anything past an hour is almost certainly a zombie left by a codex-companion crash that never wrote the terminal status.

Functions§

codex_jobs
Enumerate currently-active codex-companion jobs across every workspace directory. state.json is the source of truth; directory mtime is no longer trusted as a job signal.
codex_jobs_in
find_repo_root
Walk parents of path until a .git entry is found; returns that directory. None if not inside a git repo (or if I/O fails).
repo_hash
Compute the same 12-char marker hash that ~/.claude/hooks/_lib.sh writes.
scan
scan_dir
state_dir