Skip to content

feat(session): import a Claude Code session transcript as a resumable tole session - #501

Merged
ajianaz merged 2 commits into
developfrom
feat/cc-resume
Nov 3, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/cc-resume

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Claude Code session import (#381, import half): tole import-claude <transcript.jsonl> turns a Claude Code session into a NEW resumable tole session cc-<claude-session-id>.

  • Accepts both the ~/.claude/projects JSONL and claude -p --output-format stream-json output; continue with tole resume cc-<id> "<prompt>".
  • Mapping: user prompts / assistant text -> message; tool_use -> intent (cc_<tool_use_id>, replay: never, batch: true when several in one response); tool_result -> result (or error when is_error), parented under its intent. Claude Code tool names are kept as history only, never executed.
  • Metadata: model, version, branch, first/last timestamps -> fact/cc_import register; header takes the transcript's cwd; entry timestamps from the transcript.
  • Skipped: thinking blocks, sidechain/subagent lines, non-conversation types, image blocks (with warnings naming line numbers). Cut point: the last completed assistant answer, so the session rests at Final; a dangling prompt or open tool call is dropped and reported.
  • Double import: derived from the Claude session id, so re-importing fails with "already imported" and changes nothing; existing sessions are never touched.
  • Deferred (documented in docs/epics.md): attaching to a running claude process + double-attach guard (separate slice), live provider round trip.

Why (the problem you're solving)

Closes #381 — Claude Code sessions were dead ends; there was no way to carry their history into tole's durable, resumable sessions.

Testing (how you verified this works)

  • RED first: cargo test -p tole-core --test cc_import failed to compile (no ccimport module / cwd()). GREEN after implementation.
  • cc_import 8/8 (mapping, cut point, double-import refusal, malformed-line skip, fixture re-import + new turn via MockProvider with imported entries untouched); import_claude_e2e 1/1.
  • Gates (all run, counts exact): cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets -- -D warnings clean; cargo test --workspace --no-fail-fast 992 passed / 0 failed (61 binaries); cargo test --workspace --no-fail-fast --no-default-features 861 passed / 0 failed (59 binaries); cargo build -p tole-cli --no-default-features OK. No feature gates needed — the new code compiles in both profiles.
  • Honest notes: the pre-commit cora hook timed out at 300 s with no verdict (CI Cora Review is the check); the fixture is hand-written in the shape of a real transcript (a real one was not used — it holds private content); live E2E against a real provider NOT exercised.

… tole session (#381)

Adds tole import-claude and tole_core::ccimport: a Claude Code transcript (JSONL or claude -p stream-json) becomes a new cc-<id> session; existing sessions are untouched and a repeat import is refused. Attaching to a running claude process is deferred.
/// checked when a new prompt starts and at end of input.
fn mark_if_settled(&mut self) {
let last_is_answer = self.entries.last().is_some_and(|e| {
e.kind.as_str() == EntryType::MESSAGE && e.payload["role"] == "assistant"
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 07f5dd3 into develop Nov 3, 2026
23 of 24 checks passed
@ajianaz
ajianaz deleted the feat/cc-resume branch November 3, 2026 22:37
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.

feat(sessions): resume Claude Code (claude -p stream-json) sessions inside tole

2 participants