Skip to content

feat(claude): ConversationWriter writes Claude Code session JSONL - #230

Draft
ecalifornica wants to merge 1 commit into
mainfrom
ecalifornica/claude-write-jsonl
Draft

feat(claude): ConversationWriter writes Claude Code session JSONL#230
ecalifornica wants to merge 1 commit into
mainfrom
ecalifornica/claude-write-jsonl

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

The last step of projecting a Claude Code Conversation to JSONL is a loop in cmd_export. That loop carries a harness-specific constraint (required trailing newline). Feels like that constraint belongs in the crate that owns the harness format. This adds ConversationWriter::write_conversation and routes p export claude through it.

Alternatives considered: a method on Conversation, rejected because types.rs holds data and infallible accessors only.

Discovered this while working on a second caller: #223, #223 (comment)

toolpath-claude bumps to 0.12.3 (additive).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

`ConversationWriter::write_conversation<W: Write>(&conv, w)` writes a
conversation in Claude Code session-file layout: preamble lines, then
entries, one JSON value per line, newline-terminated. It is the
inverse of `ConversationReader::read_conversation`. Records go
straight to the sink via `serde_json::to_writer`, so no intermediate
String exists.

The trailing newline is part of the contract: Claude Code appends to
the file on resume, and without it the first appended entry lands on
the last line.

`p export claude` writes through the new writer; its private
serialization loop in cmd_export.rs becomes a three-line adapter
that collects the bytes into a String for stdout and --output.

Bumps toolpath-claude to 0.12.3 (additive).
@github-actions

Copy link
Copy Markdown

🔍 Preview deployed: https://7c3aa6f2.toolpath.pages.dev

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.

1 participant