Feature
Every Claude Code hook payload includes transcript_path: "/absolute/path/to/session.jsonl" — the exact path to the current session file. Cozempic currently ignores this and runs find_current_session() which uses 4 heuristic detection strategies (lsof, text-snippet, CWD slug, mtime fallback).
Why
- Hook-provided path is always authoritative — no detection needed
find_current_session() can fail in edge cases (multiple Claude processes, non-standard installs, race conditions)
- Simplifies guard startup:
cozempic guard --transcript-path <path> instead of --session <id> + detection
Hook payload (from Claude Code source)
{
"session_id": "uuid",
"transcript_path": "/Users/name/.claude/projects/-Users-name-project/uuid.jsonl",
"cwd": "/Users/name/project",
"permission_mode": "default",
"agent_id": "..."
}
All events: SessionStart, PreCompact, PostCompact, Stop, SubagentStop, PostToolUse — all include transcript_path.
Implementation
- Update
hooks.json to pass transcript_path from stdin JSON to the cozempic commands
- Add
--transcript-path flag to cozempic guard and cozempic checkpoint
- When
--transcript-path is provided, skip find_current_session() entirely
- Keep detection as fallback for CLI use (when running
cozempic treat manually)
Impact
More reliable hook operation. Eliminates the entire class of "could not detect current session" failures in hook contexts.
Feature
Every Claude Code hook payload includes
transcript_path: "/absolute/path/to/session.jsonl"— the exact path to the current session file. Cozempic currently ignores this and runsfind_current_session()which uses 4 heuristic detection strategies (lsof, text-snippet, CWD slug, mtime fallback).Why
find_current_session()can fail in edge cases (multiple Claude processes, non-standard installs, race conditions)cozempic guard --transcript-path <path>instead of--session <id>+ detectionHook payload (from Claude Code source)
{ "session_id": "uuid", "transcript_path": "/Users/name/.claude/projects/-Users-name-project/uuid.jsonl", "cwd": "/Users/name/project", "permission_mode": "default", "agent_id": "..." }All events:
SessionStart,PreCompact,PostCompact,Stop,SubagentStop,PostToolUse— all includetranscript_path.Implementation
hooks.jsonto passtranscript_pathfrom stdin JSON to the cozempic commands--transcript-pathflag tocozempic guardandcozempic checkpoint--transcript-pathis provided, skipfind_current_session()entirelycozempic treatmanually)Impact
More reliable hook operation. Eliminates the entire class of "could not detect current session" failures in hook contexts.