Repository navigation
Description
Problem
Remember derives two things it is handed for free.
scripts/resolve-paths.sh resolves the plugin root from CLAUDE_PLUGIN_ROOT (line 105) and the project root from CLAUDE_PROJECT_DIR (line 121). pipeline/extract.py:_session_dir() then reconstructs the transcript location as <config-dir>/projects/<slug>/<session_id>.jsonl, which is why this repo carries the Windows drive-letter normalisation at resolve-paths.sh:131-181 and the four path shapes behind #263: the slug has to be rebuilt byte-for-byte or the glob silently returns nothing.
The host already tells us both. Every SessionStart and SessionEnd payload carries cwd and transcript_path on stdin, and session-start-hook.sh already reads that stdin — HOOK_STDIN at line 124, _stdin_json_string() at line 144, pulling session_id (#206) and source (#339) out of it. We consume two fields of a payload that contains four we want.
Why this is not Codex prep
Filed out of #406, but it stands on its own and should be reviewed on its own.
Reconstructing a path we were given is strictly worse than reading it, on the host we support today. Every failure mode in the slug logic — #263's four drive shapes, the twelve days of empty backups, the case-divergence library — exists only because the derivation can disagree with reality. A field handed over by the host cannot.
The portability argument is a bonus, and it is a real one. Three CLIs now ship hook systems, and they agree on this payload and on very little else:
| Claude Code | Codex | Gemini CLI | |
|---|---|---|---|
stdin session_id, cwd, transcript_path |
yes | yes | yes |
| tool event names | PreToolUse/PostToolUse |
same | BeforeTool/AfterTool |
| plugin-root env var | CLAUDE_PLUGIN_ROOT |
PLUGIN_ROOT (+ CLAUDE_* alias) |
none documented |
The env-var route is the parochial one. Codex's CLAUDE_PLUGIN_ROOT alias is a courtesy that can be withdrawn in any release, and Gemini documents no such variable at all. The stdin contract is the part three vendors arrived at independently.
Proposed change
- Extend the
_stdin_json_string()calls insession-start-hook.sh(and the equivalent insession-end-hook.sh) to also extractcwdandtranscript_path, exporting them for the sourced resolver. resolve-paths.sh: insert stdin-cwdas aPROJECT_DIRsource between theCLAUDE_PROJECT_DIRbranch (121) and the.claude/rememberlayout branch (123). Read plugin root as${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}at 105 so the vendor-neutral name wins when present.pipeline/extract.py: accept an explicit transcript path and use it when supplied; keep_session_dir()reconstruction as the fallback for every path that has no payload (consolidation, doctor, manual invocation).
Nothing is removed. Each derivation stays as the fallback it already is.
Tests
resolve-paths.sh:107— the derive-from-script-location plugin-root branch is currently reached only by local installs. If the env var is ever absent it becomes the only route, and it has no dedicated test. Pin it.- Precedence, explicitly: env var beats stdin beats derivation, and a stdin
cwddisagreeing withCLAUDE_PROJECT_DIRmust not silently win. - A supplied
transcript_pathmust be used verbatim, including a path the slug logic would have mangled — the Windows drive-letter case is the positive control here. - Absent, malformed and empty stdin must behave exactly as today.
_stdin_json_string()is documented as a heuristic and validated after extraction; two more keys must not weaken that.
Out of scope
The summarizer. pipeline/haiku.py shells claude -p, and that is the one genuinely Claude-coupled component. It is not touched here, and it should not be abstracted on the strength of a single implementation.
Activity
fdaviddpt commentedon Aug 28, 2026
Narrowing this before starting, because the plan above does not survive contact with the hook ordering.
What blocks step 2
session-start-hook.sh:75sourcesresolve-paths.sh.HOOK_STDINis not captured until line 124. The resolver therefore runs before stdin has been read, and cannot consult a field that has not arrived yet.Neither escape is free:
session_id(False "previous session was not captured" warning fires on every /clear #206) andsource(session-start-hook.sh ignores thesourcefield, re-injecting the full memory recap on everycompact#339) extraction.read -t 1then runs before theREMEMBER_NESTED_SUMMARIZERguard atresolve-paths.sh:68, so every nestedclaude -pchild pays up to a second at startup before discovering it has no project. Guardable, but it is a change to hook startup ordering, and today it buys nothing: on Claude CodeCLAUDE_PROJECT_DIRis always set, so the stdin branch would never execute.Scope now
Doing here — both pay on the host we support, neither touches ordering:
transcript_path, consumed from the payload and used bypipeline/extract.pywhen supplied, with_session_dir()reconstruction preserved as the fallback for every path that has no payload. This is the half that retires the slug-disagreement failure class behind A lowercase drive letter in CLAUDE_PROJECT_DIR makes git add match nothing, and the backup reports success #263.${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}atresolve-paths.sh:105, so the vendor-neutral name wins where it exists and nothing depends on a compatibility alias that can be withdrawn.Deferred to #406, deliberately:
cwd→PROJECT_DIR, together with the capture hoist and its nested-summarizer guard. It is unverifiable here: a test can unsetCLAUDE_PROJECT_DIRto force the branch, but the thing that justifies the ordering change is a host that genuinely omits it, and no such host is installed yet. It gets done against a real Codex install, where the failing test is a real failure rather than a simulated one.The test list above stands, minus the
cwdprecedence case, which moves with the branch it covers.fdaviddpt commentedon Aug 28, 2026
Design decision, recorded before the implementation lane picks this up: the transcript path is read through a host adapter with a registry, not by an inline environment read.
I argued against abstraction earlier in this thread and want to be explicit about why that changed. It was not a change of mind about speculative generality. It is that the seam is now measured rather than guessed: three shipped agent CLIs, and the disagreement between them is documented, narrow and stable in shape.
session_id,cwd,transcript_pathPreToolUse/PostToolUseBeforeTool/AfterToolCLAUDE_PLUGIN_ROOTPLUGIN_ROOT(+CLAUDE_*alias)What differs is the names, and that is data.
pipeline/host.py(pushed onfeat/407-transcript-path) holds it as aHostrecord per CLI plus adetect_host()factory, so a fourth host is a table entry rather than a search through the tree.Two details in it that are decisions rather than mechanics:
PLUGIN_ROOTis read beforeCLAUDE_PLUGIN_ROOT, so nothing depends on a compatibility alias outliving the release that shipped it.CLAUDE_PLUGIN_ROOTis not a detection signature. Codex sets it too. Detection usesCLAUDE_CODE_*, which Claude Code sets and nothing else does. Getting this backwards would identify every Codex session as Claude Code.Three things are deliberately excluded, and the module docstring says so at the point someone would otherwise add them:
pipeline/haiku.pyshellsclaude -p. Still one implementation; an interface derived from it would encode that CLI's auth model and output shape as though they were neutral. Extracted from two real providers or not at all.resolve-paths.shruns before starting Python is worth it, so it mirrors the variable list by hand, exactly aslib-slug.shmirrorspipeline/slug.py. That mirror needs a parity test or it will drift.State on the branch
feat/407-transcript-path, commit f9852fa. Eleven tests intests/test_transcript_path_407.py, four currently red — the four asserting a supplied path is used. The other seven pass today and are the positive controls: without them, the red four could be satisfied by a reader that simply stops reading.One hazard the tests pin, which is easy to miss:
extract_sessionderivesactual_idfrom the transcript's basename. Codex names rollout filesrollout-<date>-<uuid>.jsonl, so a basename-derived id would keyget_last_save_lineon something that never matches, and every save would re-summarize the whole transcript from line 0 — the duplicate #140 exists to prevent. When a session id is known it must win over the filename.Nothing consumes
host.pyyet. Remaining: wire it intofind_session/extract_session, exportREMEMBER_TRANSCRIPT_PATHfrom the hooks that already consume the payload, add the${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}read plus its parity test, and document it.fix: read the host-supplied transcript path instead of reconstructing…
fix: recovery no longer leaks the current session's transcript path i…
docs: update the #407 changelog fragment for the review-round fixes
fix: read the host-supplied transcript path instead of reconstructing…
fix: per-tool-call capture on Codex still forked save-session.sh into…
Add a checked-in Gemini CLI hook manifest (#456) (#531)