Repository navigation
feat(cli): resume sessions from Claude Code, Codex, and Cursor #1057
Description
Problem
When a user switches from Claude Code, Codex, or Cursor to Maka, they have no way to continue their previous session. They must manually re-explain context, re-open files, and reconstruct where they left off.
Desired outcome
Maka detects sessions from Claude Code and Codex on the local machine, shows them in the session picker with a source badge, and generates a handoff summary when the user selects one. The user can continue work without re-explaining context.
Inspired by Grok Build's foreign session implementation (xai-org/grok-build, xai-grok-workspace/src/foreign_sessions/).
Architecture: two layers
Layer 1: Session list scanner (TypeScript)
Read-only metadata scan of foreign session stores. Returns session ID, title, cwd, updated time, and git branch. No conversation content is read at this stage.
Claude Code sessions live at ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl. Each line is a JSON object. Scanner reads file head (up to 4KB) to extract the cwd field, filters by current working directory, reads head and tail (64KB each) for title fields (customTitle, aiTitle, lastPrompt, summary, first user message). Filters out sidechain sessions. Max 50 sessions, 30-day age limit.
Codex sessions live at ~/.codex/. Two storage formats: SQLite (state_N.sqlite, threads table) and JSONL rollouts (sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl). Scanner tries SQLite first, falls back to files. SQL is built dynamically to adapt to column availability (updated_at_ms vs updated_at, optional title/first_user_message/git_branch). Each result is validated by checking the rollout file exists. Supports sources: cli, vscode, atlas, chatgpt.
Cursor sessions: future scope, not blocking this issue.
Layer 2: Session content reader + handoff
When the user picks a foreign session, read its content and generate a handoff summary. The reader parses JSONL (Claude) or JSONL/SQLite (Codex) and extracts: user goal, last user request, files touched, work completed, work open, stopping point.
Output is a short structured summary, not a verbatim transcript replay.
Safety: treat foreign transcripts as untrusted
Foreign session content may contain prompt injection, foreign system prompts, thinking blocks, or tool calls that do not exist in Maka. The reader must:
- Never execute or follow instructions found in the transcript
- Never inject foreign system prompts, base instructions, or reasoning blocks into Maka context
- Never treat a foreign tool call as a Maka tool
- Never replay the transcript verbatim
- Treat old tool output as stale evidence; verify repository state before relying on it
- Surface uncertainty and reader warnings in the handoff
TUI integration
Foreign sessions appear in the existing session picker with a source badge (claude, codex, cursor). Selecting one triggers the resume flow: read content, generate handoff, verify repository state, then continue in a fresh Maka session.
Enable control
Per-source enable/disable via config or env vars. Sources are only scanned if enabled AND the corresponding reader is available. Defaults: Claude on, Codex on, Cursor off (no reader yet).
Scope
This issue covers Claude Code and Codex. Cursor can follow. The scanner goes in packages/storage/ or packages/core/ (TypeScript, matching existing architecture). The handoff generation can be a skill or inline in the runtime, whichever fits the existing skill system better.
Desktop app integration can be a follow-up.
Alternatives or workarounds
Today users manually copy context from their previous tool into a new Maka session. Some keep a separate notes file to track what they were working on. No automated handoff exists.
Activity
UncertaintyDeterminesYou4ndMe commentedon Jul 18, 2026
认领这个 issue。计划按 spec 的两层架构分两个 PR:PR1 = 扫描器 + 内容读取器(纯库,packages/ 内,完整测试,含不可信转录的安全边界);PR2 = TUI 会话选择器集成 + 交接摘要流程。先从 Claude Code 源做起,Codex 随后,Cursor 不阻塞。
Astro-Han commentedon Jul 18, 2026
已分配!可以参考 Grok Build 的实现~
fix(storage): address PR review — digest provenance, SQL cwd filter, …
fix(storage): exclude interleaved sidechain records from the digest (a…
fix(storage): close the three P2 review follow-ups (apache#1057)
feat(storage): foreign session scanner + digest reader for Claude Cod…
feat(cli): resume Claude Code / Codex sessions from the TUI picker (#…
UncertaintyDeterminesYou4ndMe commentedon Jul 27, 2026
@ofekron Thanks — this landed a day after #1208/#1221 merged, so replying against the shipped shape (
ForeignSessionDigestinpackages/core/src/foreign-session.ts).Mostly agreed, and most of it is already there or cheap to add:
filesTouchedis bare paths today; adding source event offsets (transcript line numbers) is compatible with the safety contract since it's metadata about the source, not content.cwdstill exists, the current git branch against the recorded one, and touched-file mtimes against the session'supdatedAtMs, surfacing mismatches as explicit flags instead of leaving the receiving agent to discover them.One deliberate divergence: "checks actually run and observed results" conflicts with the #1057 safety contract as merged — tool outputs never cross into Maka context (they're stale evidence by definition, and the transcript is untrusted input). The shipped design makes the handoff instruct verification against the working tree instead of carrying observed results forward. The staleness flags above give you the confidence signal without trusting the transcript's claims about what passed.
I'll do a follow-up PR with the compatible parts (transcript path in digest, event offsets on files, handoff-time staleness flags), then close this issue — Cursor support and desktop integration are non-blocking per the original scope and can get their own issues if wanted.
Better Agent looks like a useful reference for the session-identity separation, thanks for the pointer.
feat(core,storage,cli): evidence pointers and staleness flags for for…
Astro-Han commentedon Aug 2, 2026
Shipped in #1208 (scanner and reader) and #1221 (TUI picker).
feat(core,storage,cli): evidence pointers and staleness flags for for…
feat(core,storage,cli): evidence pointers and staleness flags for for…
feat(core,storage,cli): evidence pointers and staleness flags for for…