Baton

tech.kasabeh由 kasabeh.tech 发布v0.3.0更新于 Oct 27, 2026

Pass the baton between coding agents: convert sessions across Claude Code, OpenCode, Codex & more.

已验证STDIO仅桌面文件与存储开发者工具

概览

AI 生成的概览

Baton 在 Claude Code、OpenCode、Codex 等编码代理之间转换会话,让助手列出、转换并导入对话记录。

可以做什么
  • 列出所有受支持编码代理的会话及其文件路径
  • 把会话从一种代理格式转换为另一种格式
  • 转换并执行目标代理的导入命令
  • 识别某个会话文件或目录由哪个代理生成
适用场景
适合在遇到用量上限或想中途更换代理时使用,保留完整对话记录而不必重新解释计划。也适合对疑难问题征求第二种意见,或把会话统一归档为一种格式。
运行要求
以本地 stdio 进程运行,通常通过 npx 调用 npm 包并下载预编译二进制;也可用 npm、Homebrew、Cargo 或 shell 安装脚本安装。仅限桌面环境,未声明认证、环境变量或请求头。会话文件从本地代理目录读取,例如 Claude Code 与 Codex CLI 的文件夹。
安装前请注意
它会读取本地代理对话记录,其中可能包含代码、提示词和密钥,并写出转换后的文件、执行目标代理的导入命令,因此会话会被复制到另一个代理的存储中。npx 与 shell 安装方式会从网络下载并执行预编译二进制。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Baton,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[baton]

Pass the baton between coding agents.

Convert any coding-agent session to any other. One command. Keep going where you left off.

[crates.io] [npm] [CI] [agents] [license]

[baton converting a Claude Code session to opencode]

A passed transcript kept 14/17 concrete facts. A hand-written handoff summary kept 3/17. Benchmark ↓


The 4 p.m. problem

It's 4 p.m. Claude Code says "usage limit reached — resets at 10 p.m." You're three hours into a session: architecture decided, edge cases mapped, half the diff written.

❌ Without baton — open another agent and start from zero. Re-explain the plan. Re-read the files. Re-litigate every decision you already made.

✅ With baton — pass the session and keep going:

sh
baton convert --from claude-code --to opencode --latest --import# using latest claude-code session: 2026-07-09 15:58  Refactor the auth middleware to…# passed baton: claude-code → opencode (1388 messages) → handoff.json# Imported session: ses_8c4c973a521549e2
opencode -s ses_8c4c973a521549e2   # same conversation, different runner

Works in every direction: switch agents mid-task, try a second opinion on a hard bug, move a session from your editor agent to a terminal agent, or archive everything in one format.

Quick start

sh
# zero-install run (downloads prebuilt binary)npx @kasabeh/baton-mcp --help
# convert your most recent session + auto-import into the target agentbaton convert --from claude-code --to opencode --latest --import
# or omit the path to pick interactively — newest first,# each session previewed by its first user messagebaton convert --from claude-code --to opencode --import
# or pass an explicit session filebaton convert --from claude-code --to opencode <session.jsonl> --import
# see every session on your machine, across all agentsbaton list

Where do session files live?

You never have to hunt these down (--latest and the interactive picker find them for you), but for reference — each agent stores its transcripts on disk:

AgentLocation
Claude Code~/.claude/projects/<encoded-cwd>/<session-uuid>.jsonl
Codex CLI~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-*.jsonl

baton list prints the path of every session it can find, across all agents.

Supported formats

AgentReadWriteAuto-import
Claude Code✅✅—
OpenCode✅✅✅ opencode import
Codex CLI✅✅—
Gemini CLI✅✅—
Zed✅✅—
Aider✅✅—
Cursor✅¹—²—
Continue✅——
Cline / Roo✅—²—

¹ Cursor reads from exported JSON (sqlite3 state.vscdb "SELECT value FROM ItemTable WHERE key='aiService:chats'")

² Not planned: Cursor and Cline keep session state inside editor databases (SQLite / VS Code globalState) with no file-level import path.

Benchmark

Does carrying the full transcript beat writing a handoff summary for the next agent? We measured both on a real 3.4 MB Claude Code session (same model both arms, only the context differs):

session sizebaton transcripthandoff summary
sm (93 KB)3/3 details recalled1/3
md (198 KB)6/61/6
lg (599 KB)5/81/8
total14/173/17

The summary lost concrete facts (versions, line counts, MSRV) even on the smallest slice — the receiving agent had to re-read files and re-run commands to rediscover them. Mechanical fidelity: all 896 messages are written to every target; round-trip loss reflects each target format's expressiveness (claude-code 896/896, codex 736, gemini-cli 723, aider 111 — it stores chat text only).

We also measured task continuation: cut the session at three mid-task points, ask a fresh agent to state the task, state, and next steps. Result: parity (baton 10/12, handoff 10/12) — a good summary is enough for what to do next; the transcript is what answers the specific factual questions the summary's author didn't anticipate. And the summary only exists if an agent spends a full transcript read writing it — baton makes the transfer free.

Full methodology, caveats, and reproduction steps: benchmark/RESULTS.md.

MCP server

baton is also an MCP server — your agent can pass the baton itself, mid-conversation:

ToolDescription
list_sessionsScan all agents, return a unified list
convert_sessionConvert a session from one format to another
import_to_targetConvert + run the target agent's import command
detect_formatSniff a file/dir and report which agent produced it
sh
baton install     # registers baton in every detected agent's MCP configbaton doctor      # verifybaton uninstall   # remove from all agents

How it works

Claude Code session (.jsonl)      │      ▼  baton read ──► canonical Session { messages: [Text, Reasoning, ToolCall, ToolResult] }      │      ▼  baton write ──► OpenCode import JSON (SessionV1 schema)

Every agent format is read into a canonical intermediate representation, then written out in the target format. Adding a new format is O(1), not O(N×M) per-pair converters.

Install

sh
# npm (prebuilt binary, no Rust needed)npm install -g @kasabeh/baton-mcp
# Homebrewbrew install kaseban/tap/baton-mcp
# Cargo binstall (prebuilt binary)cargo binstall baton-mcp
# Cargo (from source)cargo install baton-mcp
# Shell installer (prebuilt binary)curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Kaseban/baton/releases/latest/download/baton-mcp-installer.sh | sh

Or grab a binary from GitHub Releases.

Building

sh
git clone https://github.com/Kaseban/baton.gitcd batoncargo build --release./target/release/baton --help

Contributing

Each format lives in src/formats/<name>.rs and implements the Format trait (read + write). See src/formats/claude_code.rs for a complete reference implementation.

All nine formats have readers; Claude Code, OpenCode, Codex, Zed, Aider, and Gemini CLI also have writers. The most impactful contribution now is a writer for Continue.

Regenerating the demo

The README GIF is scripted with VHS: vhs assets/demo.tape. It records against a sandboxed $HOME (/tmp/demo) populated with fabricated sessions, so no real session data ends up in the GIF.

Don't drop the baton.

License

Dual-licensed under MIT OR Apache-2.0.

来源:README.md,提交 4526159

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分