Skip to content

feat(cli): p export claude takes --derive-session-id - #241

Draft
ecalifornica wants to merge 3 commits into
ecalifornica/export-claude-cwdfrom
ecalifornica/export-claude-derive-session-id
Draft

feat(cli): p export claude takes --derive-session-id#241
ecalifornica wants to merge 3 commits into
ecalifornica/export-claude-cwdfrom
ecalifornica/export-claude-derive-session-id

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

The remote session file must be named by the document, so a re-run of the same session finds the same file. p export claude --derive-session-id renames the session to a v4-shaped UUID from the first 128 bits of the SHA-256 of the key-sorted compact JSON of the input document. The same document yields the same ID on every run, so a second export of it into the same project is refused instead of duplicated. --cwd does not change the ID, because the hash is over the input text.

The rename is Conversation::rename_session(id), a new toolpath-claude method that sets the session ID everywhere the format carries it, nested sessionId keys in preamble lines included.

The --output message names the session ID, so a caller learns the derived ID without parsing the file. The script exports with --cwd <remote-dir> --derive-session-id and reads the ID back from the JSONL with jq.

Three commits: the library method, the flag, the script.

toolpath-claude 0.13.2, path-cli 0.20.0, toolpath-cli 0.20.0. Stacked on #247.

@ecalifornica ecalifornica self-assigned this Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://3cda967f.toolpath.pages.dev

@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-derive-session-id branch from 88c6a01 to 9c1db5a Compare August 25, 2026 21:34
@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-derive-session-id branch from 9c1db5a to 4fea279 Compare August 26, 2026 15:42
@ecalifornica
ecalifornica requested a review from akesling August 26, 2026 15:50
@ecalifornica
ecalifornica marked this pull request as ready for review August 26, 2026 15:50
@ecalifornica
ecalifornica marked this pull request as draft August 27, 2026 16:31
`rename_session(id)` sets the session ID everywhere the format carries
it: `session_id`, every entry's `sessionId`, and every `sessionId` key
in preamble lines at any depth. Claude Code copies the ID into
`worktreeSession.sessionId` on `worktree-state` lines. Message content
and tool results are not touched.

toolpath-claude 0.13.2.
`--derive-session-id` renames the session to an ID derived from the
input document: a v4-shaped UUID from the first 128 bits of the SHA-256
of the key-sorted compact JSON. Key order and whitespace in the input
do not change the ID, and neither does `--cwd`: the ID hashes the input
document, not the projection. The same document yields the same ID on
every run, so a second export of it into the same project is refused
instead of duplicated. The rename is `Conversation::rename_session`:
the conversation's session ID, every entry's `sessionId`, and every
`sessionId` key in every preamble line, nested keys included.

The `--output` message names the session ID, so a caller learns the
derived ID without parsing the file.

The flag joins `--cwd` in `RemoteSessionArgs` behind the
`resume-remote` feature. `load_path_doc` splits into `read_doc_json`
and `parse_path_doc`; the derivation hashes the document text, not a
type round-trip.

path-cli 0.20.0; toolpath-cli 0.20.0 (lockstep bump of the shim).
Step 5 exports with `--cwd <remote-dir> --derive-session-id` and reads
the remote session ID back from the JSONL: `jq -r '.sessionId'` over
every line, then `sort -u`, which yields one line only when every line
agrees. The tmux session name is keyed on that ID. The shell
`mint_uuid`, the `sha256sum` precondition, and the sed rewrite of
`sessionId` are removed.
@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-derive-session-id branch from 4fea279 to c369afa Compare August 27, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants