Skip to content

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

Merged
ecalifornica merged 1 commit into
mainfrom
ecalifornica/claude-write-jsonl
Aug 24, 2026
Merged

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

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

The trailing newline constraint on Claude session files belongs in the crate that owns the format, not in cmd_export. This adds a ConversationWriter::write_conversation to toolpath-claude 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 (comment)

toolpath-claude bumps to 0.12.3


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

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://99c904de.toolpath.pages.dev

`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).
@ecalifornica
ecalifornica force-pushed the ecalifornica/claude-write-jsonl branch from eaf60f5 to 4ee2b8e Compare August 22, 2026 18:10
@ecalifornica
ecalifornica marked this pull request as ready for review August 22, 2026 18:20
@ecalifornica
ecalifornica requested a review from akesling August 22, 2026 18:20

@akesling akesling left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akesling akesling assigned ecalifornica and unassigned akesling Aug 24, 2026
@ecalifornica
ecalifornica merged commit b1da30a into main Aug 24, 2026
3 checks passed
@ecalifornica
ecalifornica deleted the ecalifornica/claude-write-jsonl branch August 24, 2026 15:31
@ecalifornica ecalifornica removed their assignment Aug 24, 2026
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