A CLI tool to translate session files between AI coding agent formats.
| Format | Description | Default path |
|---|---|---|
opencode |
OpenCode agent JSON export | { info, messages } structure |
pi |
Pi coding agent JSONL | ~/.pi/agent/sessions/ |
codex |
OpenAI Codex CLI JSONL | ~/.codex/sessions/YYYY/MM/DD/ |
claudecode |
Claude Code JSONL | ~/.claude/projects/ |
# From the project directory
npm install
npm link # makes 'translate' available globally
# or just run directly:
node translate.js ...translate <file> [--opencode | --pi | --codex | --claudecode] [-o output]
If no target format flag is given, an interactive picker will appear.
# Pi → Claude Code
translate ./session.jsonl --claudecode
# OpenCode → Pi (custom output path)
translate ./export.json --pi -o ./converted.jsonl
# Codex → OpenCode
translate ./rollout.jsonl --opencode
# Interactive (pick target from list)
translate ./session.jsonl| Flag | Description |
|---|---|
--opencode |
Translate to OpenCode JSON format |
--pi |
Translate to Pi agent JSONL |
--codex |
Translate to OpenAI Codex JSONL |
--claudecode |
Translate to Claude Code JSONL |
-o, --output <path> |
Custom output file path |
--no-color |
Disable color output |
-h, --help |
Show help |
The tool auto-detects the source format based on file structure:
- OpenCode: root JSON object with
info+messageskeys - Pi: JSONL with
{"type":"session","version":...}header - Codex: JSONL with
{"type":"response_item","payload":...}entries - Claude Code: JSONL with
{"type":"user"|"assistant",...,"uuid":...}entries
See the samples/ directory for example files in each format.
- Text content is always preserved
- Tool calls and results are translated to the target format's equivalent
- Token usage is preserved where both formats support it (pi ↔ claudecode do best)
- Metadata that doesn't have an equivalent in the target format is dropped
- Branching / tree structure (pi's tree, Claude Code's parentUuid chain) is linearized when translating to flat formats (opencode, codex)