Skip to content

Prince2412k2/session_translator-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agent-translator

A CLI tool to translate session files between AI coding agent formats.

Supported 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/

Installation

# From the project directory
npm install
npm link   # makes 'translate' available globally
# or just run directly:
node translate.js ...

Usage

translate <file> [--opencode | --pi | --codex | --claudecode] [-o output]

If no target format flag is given, an interactive picker will appear.

Examples

# 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

Options

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

Format Detection

The tool auto-detects the source format based on file structure:

  • OpenCode: root JSON object with info + messages keys
  • Pi: JSONL with {"type":"session","version":...} header
  • Codex: JSONL with {"type":"response_item","payload":...} entries
  • Claude Code: JSONL with {"type":"user"|"assistant",...,"uuid":...} entries

Sample Files

See the samples/ directory for example files in each format.

Notes on Translation Fidelity

  • 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)

Releases

No releases published

Packages

 
 
 

Contributors