feat(cli): p export claude takes --derive-session-id - #241
Draft
ecalifornica wants to merge 3 commits into
Draft
Conversation
|
🔍 Preview deployed: https://3cda967f.toolpath.pages.dev |
ecalifornica
force-pushed
the
ecalifornica/export-claude-derive-session-id
branch
from
August 25, 2026 21:34
88c6a01 to
9c1db5a
Compare
ecalifornica
force-pushed
the
ecalifornica/export-claude-derive-session-id
branch
from
August 26, 2026 15:42
9c1db5a to
4fea279
Compare
ecalifornica
marked this pull request as ready for review
August 26, 2026 15:50
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
force-pushed
the
ecalifornica/export-claude-derive-session-id
branch
from
August 27, 2026 21:35
4fea279 to
c369afa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-idrenames 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.--cwddoes not change the ID, because the hash is over the input text.The rename is
Conversation::rename_session(id), a newtoolpath-claudemethod that sets the session ID everywhere the format carries it, nestedsessionIdkeys in preamble lines included.The
--outputmessage names the session ID, so a caller learns the derived ID without parsing the file. The script exports with--cwd <remote-dir> --derive-session-idand reads the ID back from the JSONL withjq.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.