@dorywoof/agentreplay 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  <h1 align="center">agentreplay</h1>
2
2
 
3
3
  <p align="center">
4
- <b>Turn any Claude Code or Codex session into a shareable, video-like replay.</b><br>
4
+ <b>Turn any AI coding agent session into a shareable, video-like replay.</b><br>
5
+ Claude Code · Codex · Gemini CLI · OpenCode · Cline · Roo · Kilo · Copilot CLI · Qwen · Amp · Aider · any chat log<br>
5
6
  One command. One self-contained HTML file. Secrets stripped before you share.
6
7
  </p>
7
8
 
@@ -26,10 +27,10 @@ You just watched an AI agent build a feature in 6 minutes. Now you want to show
26
27
  ## Features
27
28
 
28
29
  - ▶️ **Plays like a video.** Events appear in order with condensed timing; scrub, skip, pause, or change speed. Edits, errors and prompts are marked on the timeline.
29
- - 🤝 **Claude Code *and* Codex.** Auto-detects the format. More agents are on the roadmap.
30
- - 💸 **Cost and token panel.** Input, output and cache tokens, plus an estimated API cost at list prices.
30
+ - 🤝 **Works with (almost) every agent.** Built-in support for 11 coding agents, plus a universal parser that understands Anthropic, OpenAI and Gemini message formats. Point it at any JSON or JSONL chat log and it will try to replay it.
31
+ - 💸 **Cost and token panel.** Input, output and cache tokens. Shows the real cost when the agent records it (Cline, Roo, OpenCode), otherwise an estimate at list prices.
31
32
  - 🔒 **Safe to share by default.** API keys, tokens, JWTs, private keys, passwords in env assignments, e-mail addresses and your home directory are redacted *before* the HTML is written. The footer says what was removed.
32
- - 📝 **Real diffs.** `Edit`, `Write`, `MultiEdit` and Codex `apply_patch` are shown as red and green diffs, with a per-file `+/-` summary.
33
+ - 📝 **Real diffs.** Edits are shown as red and green diffs with a per-file `+/-` summary: Claude's `Edit`/`Write`, Codex `apply_patch`, Cline/Roo/Aider SEARCH/REPLACE blocks, OpenCode and Gemini edit tools.
33
34
  - 📦 **One file, zero dependencies.** The output is one HTML file that works offline. Host it anywhere: GitHub Pages, a gist, Slack, e-mail.
34
35
  - 🌗 Light and dark themes, works on phones, and keyboard shortcuts (`space`, `←` `→`, `Home`, `End`).
35
36
 
@@ -40,27 +41,42 @@ npx @dorywoof/agentreplay # replays your most recent session and open
40
41
  ```
41
42
 
42
43
  ```bash
43
- npx @dorywoof/agentreplay --list # pick from recent Claude Code / Codex sessions
44
+ npx @dorywoof/agentreplay --list # pick from recent sessions of every agent
44
45
  npx @dorywoof/agentreplay --pick 3
45
46
  npx @dorywoof/agentreplay path/to/session.jsonl -o my-replay.html
47
+ npx @dorywoof/agentreplay --agents # which agents were found on this machine
46
48
  ```
47
49
 
48
50
  Requires Node 18+. Nothing is uploaded anywhere: everything happens on your machine.
49
51
 
50
52
  ### Where sessions live
51
53
 
52
- | Agent | Location |
53
- |---|---|
54
- | Claude Code | `~/.claude/projects/<project>/<session>.jsonl` |
55
- | Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` |
54
+ Sessions are found automatically. You can also pass any file directly.
56
55
 
57
- `CLAUDE_CONFIG_DIR` and `CODEX_HOME` are respected.
56
+ | Agent | `--agent` | Where it looks |
57
+ |---|---|---|
58
+ | Claude Code | `claude` | `~/.claude/projects/*/*.jsonl` |
59
+ | Codex | `codex` | `~/.codex/sessions/**/rollout-*.jsonl` |
60
+ | Gemini CLI | `gemini` | `~/.gemini/tmp/*/chats/*.json(l)` |
61
+ | Qwen Code | `qwen` | `~/.qwen/projects/*/chats/*.jsonl` |
62
+ | OpenCode | `opencode` | `~/.local/share/opencode/`: `storage/` JSON, `opencode.db`, or an `opencode export` file |
63
+ | Cline | `cline` | VS Code / Cursor / Windsurf globalStorage `saoudrizwan.claude-dev/tasks/*`, `~/.cline/data/tasks/*` |
64
+ | Roo Code | `roo` | globalStorage `rooveterinaryinc.roo-cline/tasks/*` |
65
+ | Kilo Code | `kilo` | globalStorage `kilocode.kilo-code/tasks/*` |
66
+ | GitHub Copilot CLI | `copilot` | `~/.copilot/session-state/**/*.jsonl` |
67
+ | Amp | `amp` | `~/.local/share/amp/threads/*.json` |
68
+ | Aider | `aider` | `.aider.chat.history.md` in the current folder |
69
+ | Anything else | `generic` | Pass the file: Anthropic / OpenAI / Gemini-style messages in JSON or JSONL |
70
+
71
+ `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `GEMINI_DIR`, `QWEN_DATA_DIR`, `AMP_DATA_DIR`, `COPILOT_HOME` and `XDG_DATA_HOME` are respected. Reading `opencode.db` needs Node 22.5+ (built-in SQLite).
72
+
73
+ > Only Claude Code and Codex have been tested against real logs so far. The others are built from their documented formats and tested with fixtures. If a session from your agent doesn't replay correctly, please [open an issue](https://github.com/dorywoof/agentreplay/issues) with a redacted sample.
58
74
 
59
75
  ## Options
60
76
 
61
77
  ```
62
78
  -o, --out <file> output HTML path (default: ./replay-<id>.html)
63
- -a, --agent <name> only look at "claude" or "codex" sessions
79
+ -a, --agent <name> only one agent (see the table above)
64
80
  -t, --title <text> override the replay title
65
81
  --no-thinking hide thinking / reasoning blocks
66
82
  --no-redact keep secrets, e-mails and home paths (not for sharing!)
@@ -84,7 +100,7 @@ The output is a static file, so any of these work:
84
100
 
85
101
  ## About the cost estimate
86
102
 
87
- Cost uses public per-token API list prices (including cache reads and writes) for the Claude models it knows about. If you're on a subscription plan, it shows what the session *would* cost on the API. For models it has no price for (for example Codex models), only token counts are shown. You can supply your own prices:
103
+ When the agent records what a session cost (Cline, Roo, Kilo, OpenCode), that number is shown. Otherwise cost is estimated from public per-token API list prices (including cache reads and writes) for the Claude models it knows about. If you're on a subscription plan, it shows what the session *would* cost on the API. For models it has no price for, only token counts are shown. You can supply your own prices:
88
104
 
89
105
  ```json
90
106
  { "gpt-6.1": { "input": 1.25, "output": 10, "cacheRead": 0.125 } }
@@ -96,13 +112,14 @@ npx @dorywoof/agentreplay --pricing prices.json
96
112
 
97
113
  ## Roadmap
98
114
 
99
- - [ ] opencode, Gemini CLI and Cursor agent logs
115
+ - [ ] Cursor and Windsurf built-in chat (stored in proprietary SQLite blobs)
116
+ - [ ] Goose, Crush, Droid and Kiro sessions
100
117
  - [ ] Export to GIF / MP4 for social posts
101
118
  - [ ] Subagent (sidechain) lanes
102
119
  - [ ] `agentreplay publish`: one-command upload to a gist
103
120
  - [ ] Combine several sessions into one replay
104
121
 
105
- Ideas and PRs are welcome. Adding a new agent means writing one parser in `src/parsers/` that returns the shared event shape.
122
+ Ideas and PRs are welcome. Adding a new agent usually means a few lines in `src/parsers/agents.js` that find its files and hand them to the universal parser.
106
123
 
107
124
  ## Development
108
125
 
@@ -17,10 +17,12 @@ Usage
17
17
  agentreplay <session.jsonl> replay a specific log file
18
18
  agentreplay --list list recent sessions
19
19
  agentreplay --pick 3 replay #3 from --list
20
+ agentreplay --agents show supported agents and what was found
20
21
 
21
22
  Options
22
23
  -o, --out <file> output HTML path (default: ./replay-<id>.html)
23
- -a, --agent <name> only look at "claude" or "codex" sessions
24
+ -a, --agent <name> only one agent: claude, codex, gemini, qwen, opencode,
25
+ cline, roo, kilo, copilot, amp, aider, generic
24
26
  -t, --title <text> override the replay title
25
27
  --no-thinking hide thinking / reasoning blocks
26
28
  --no-redact keep secrets, e-mails and home paths (not for sharing!)
@@ -38,6 +40,7 @@ const { values: opts, positionals } = parseArgs({
38
40
  agent: { type: 'string', short: 'a' },
39
41
  title: { type: 'string', short: 't' },
40
42
  list: { type: 'boolean', short: 'l' },
43
+ agents: { type: 'boolean' },
41
44
  pick: { type: 'string', short: 'p' },
42
45
  'no-thinking': { type: 'boolean' },
43
46
  'no-redact': { type: 'boolean' },
@@ -66,14 +69,25 @@ function ago(ms) {
66
69
 
67
70
  function main() {
68
71
  if (opts.help) return console.log(HELP);
69
- if (opts.agent && !PARSERS[opts.agent]) fail(`unknown agent "${opts.agent}" (use claude or codex)`);
72
+ if (opts.agent && !PARSERS[opts.agent]) fail(`unknown agent "${opts.agent}" (one of: ${Object.keys(PARSERS).join(', ')})`);
73
+
74
+ if (opts.agents) {
75
+ console.log(bold('Supported agents') + dim(' (sessions found on this machine)') + '\n');
76
+ for (const [key, src] of Object.entries(PARSERS)) {
77
+ if (key === 'generic') continue;
78
+ const n = listSessions({ agent: key }).length;
79
+ console.log(` ${key.padEnd(9)} ${src.label.padEnd(13)} ${n ? bold(String(n)) : dim('0')}`);
80
+ }
81
+ console.log('\n' + dim('Any other JSON / JSONL chat log works too: agentreplay path/to/log.json'));
82
+ return;
83
+ }
70
84
 
71
85
  if (opts.list) {
72
86
  const sessions = listSessions({ agent: opts.agent }).slice(0, 20);
73
- if (!sessions.length) fail('no Claude Code or Codex sessions found on this machine');
87
+ if (!sessions.length) fail('no agent sessions found on this machine. Pass a log file path instead.');
74
88
  sessions.forEach((s, i) => {
75
- const tag = s.agent === 'claude' ? 'claude' : 'codex ';
76
- console.log(`${bold(String(i + 1).padStart(2))} ${tag} ${dim(ago(s.mtime).padEnd(8))} ${preview(s.file)}`);
89
+ const tag = PARSERS[s.agent].label.padEnd(12);
90
+ console.log(`${bold(String(i + 1).padStart(2))} ${tag} ${dim(ago(s.mtime).padEnd(8))} ${preview(s.file, s.agent)}`);
77
91
  });
78
92
  console.log(dim('\nReplay one with: agentreplay --pick <n>'));
79
93
  return;
@@ -82,12 +96,12 @@ function main() {
82
96
  let file, agent;
83
97
  if (positionals[0]) {
84
98
  file = path.resolve(positionals[0]);
85
- if (!fs.existsSync(file)) fail(`file not found: ${file}`);
99
+ if (!fs.existsSync(file.split('#')[0])) fail(`file not found: ${file}`);
86
100
  agent = opts.agent || detectAgent(file);
87
- if (!agent) fail('could not recognise this log format (supported: Claude Code, Codex)');
101
+ if (!agent) fail('could not find a conversation in this file. Run agentreplay --agents to see supported formats.');
88
102
  } else {
89
103
  const sessions = listSessions({ agent: opts.agent });
90
- if (!sessions.length) fail('no Claude Code or Codex sessions found. Pass a .jsonl file path instead.');
104
+ if (!sessions.length) fail('no agent sessions found on this machine. Pass a log file path instead.');
91
105
  const idx = opts.pick ? Number(opts.pick) - 1 : 0;
92
106
  if (!sessions[idx]) fail(`no session #${opts.pick} — run with --list to see what's available`);
93
107
  ({ file, agent } = sessions[idx]);
@@ -112,7 +126,7 @@ function main() {
112
126
  return;
113
127
  }
114
128
 
115
- const out = path.resolve(opts.out || `replay-${session.id.slice(0, 8)}.html`);
129
+ const out = path.resolve(opts.out || `replay-${String(session.id).replace(/[^w-]/g, '').slice(0, 12) || 'session'}.html`);
116
130
  fs.mkdirSync(path.dirname(out), { recursive: true });
117
131
  fs.writeFileSync(out, renderHtml(session, stats, { redactions }));
118
132
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dorywoof/agentreplay",
3
- "version": "0.1.0",
4
- "description": "Turn Claude Code and Codex sessions into a shareable, video-like HTML replay — with cost stats and automatic secret redaction.",
3
+ "version": "0.2.0",
4
+ "description": "Turn any AI coding agent session (Claude Code, Codex, Gemini CLI, OpenCode, Cline, Roo, Copilot CLI, Aider, …) into a shareable, video-like HTML replay with cost stats and secret redaction.",
5
5
  "homepage": "https://github.com/dorywoof/agentreplay#readme",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,7 +35,18 @@
35
35
  "session",
36
36
  "transcript",
37
37
  "llm",
38
- "cli"
38
+ "cli",
39
+ "gemini-cli",
40
+ "opencode",
41
+ "cline",
42
+ "roo-code",
43
+ "kilo-code",
44
+ "copilot",
45
+ "qwen-code",
46
+ "amp",
47
+ "aider",
48
+ "chat-log",
49
+ "transcript-viewer"
39
50
  ],
40
51
  "license": "MIT"
41
52
  }
package/src/discover.js CHANGED
@@ -2,73 +2,108 @@ import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { readJsonl, stripHarnessTags } from './util.js';
5
- import * as claude from './parsers/claude.js';
6
- import * as codex from './parsers/codex.js';
5
+ import * as claudeParser from './parsers/claude.js';
6
+ import * as codexParser from './parsers/codex.js';
7
+ import * as agents from './parsers/agents.js';
8
+ import * as universal from './parsers/universal.js';
7
9
 
8
- export const PARSERS = { claude, codex };
10
+ const home = os.homedir();
9
11
 
10
- function claudeRoot() {
11
- return path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'projects');
12
- }
13
- function codexRoot() {
14
- return path.join(process.env.CODEX_HOME || path.join(os.homedir(), '.codex'), 'sessions');
15
- }
12
+ const claude = {
13
+ label: 'Claude Code',
14
+ // projects/<project>/<session>.jsonl — subagent logs nested deeper are skipped
15
+ find: () => agents.walk(path.join(process.env.CLAUDE_CONFIG_DIR || path.join(home, '.claude'), 'projects'), 1, (n) => n.endsWith('.jsonl')),
16
+ parse: (f) => claudeParser.parse(f),
17
+ };
18
+ const codex = {
19
+ label: 'Codex',
20
+ find: () => agents.walk(path.join(process.env.CODEX_HOME || path.join(home, '.codex'), 'sessions'), 4, (n) => n.endsWith('.jsonl')),
21
+ parse: (f) => codexParser.parse(f),
22
+ };
16
23
 
17
- function walk(dir, depth, out) {
18
- let entries;
24
+ /** Every agent we know how to find and replay. Keys are what --agent accepts. */
25
+ export const PARSERS = {
26
+ claude,
27
+ codex,
28
+ gemini: agents.gemini,
29
+ qwen: agents.qwen,
30
+ opencode: agents.opencode,
31
+ cline: agents.cline,
32
+ roo: agents.roo,
33
+ kilo: agents.kilo,
34
+ copilot: agents.copilot,
35
+ amp: agents.amp,
36
+ aider: agents.aider,
37
+ generic: agents.generic,
38
+ };
39
+
40
+ function mtimeOf(ref) {
19
41
  try {
20
- entries = fs.readdirSync(dir, { withFileTypes: true });
42
+ return fs.statSync(ref.split('#')[0]).mtimeMs;
21
43
  } catch {
22
- return out;
23
- }
24
- for (const e of entries) {
25
- const p = path.join(dir, e.name);
26
- if (e.isDirectory() && depth > 0) walk(p, depth - 1, out);
27
- else if (e.isFile() && e.name.endsWith('.jsonl')) out.push(p);
44
+ return 0;
28
45
  }
29
- return out;
30
46
  }
31
47
 
32
- /** All known session files on this machine, newest first. */
48
+ /** All sessions found on this machine, newest first. */
33
49
  export function listSessions({ agent } = {}) {
34
50
  const found = [];
35
- if (!agent || agent === 'claude') {
36
- // projects/<project>/<session>.jsonl — skip subagent logs nested deeper
37
- for (const f of walk(claudeRoot(), 1, [])) found.push({ agent: 'claude', file: f });
38
- }
39
- if (!agent || agent === 'codex') {
40
- for (const f of walk(codexRoot(), 4, [])) found.push({ agent: 'codex', file: f });
51
+ for (const [key, src] of Object.entries(PARSERS)) {
52
+ if (agent && agent !== key) continue;
53
+ let files = [];
54
+ try {
55
+ files = src.find();
56
+ } catch {
57
+ /* a broken store for one agent shouldn't hide the others */
58
+ }
59
+ for (const file of files) found.push({ agent: key, file, mtime: mtimeOf(file) });
41
60
  }
42
- for (const s of found) s.mtime = fs.statSync(s.file).mtimeMs;
43
61
  return found.sort((a, b) => b.mtime - a.mtime);
44
62
  }
45
63
 
46
- /** Pick the parser for an arbitrary file by sniffing its first records. */
64
+ /** Pick the parser for an arbitrary file path. */
47
65
  export function detectAgent(file) {
48
- const records = readJsonl(file).slice(0, 50);
49
- if (codex.detect(records)) return 'codex';
50
- if (claude.detect(records)) return 'claude';
66
+ const base = path.basename(file);
67
+ if (base === 'api_conversation_history.json' || base === 'ui_messages.json') {
68
+ for (const k of ['roo', 'kilo', 'cline']) if (PARSERS[k].match(file)) return k;
69
+ return 'cline';
70
+ }
71
+ if (file.endsWith('.md')) return 'aider';
72
+ if (file.includes('.db#') || base === 'opencode.db') return 'opencode';
73
+ for (const k of ['gemini', 'qwen', 'amp', 'copilot', 'opencode']) if (PARSERS[k].match(file)) return k;
74
+ if (file.endsWith('.jsonl')) {
75
+ const records = readJsonl(file).slice(0, 50);
76
+ if (codexParser.detect(records)) return 'codex';
77
+ if (claudeParser.detect(records)) return 'claude';
78
+ }
79
+ if (universal.detect(file)) return 'generic';
51
80
  return null;
52
81
  }
53
82
 
54
- /** Cheap one-line preview for --list without fully parsing. */
55
- export function preview(file) {
83
+ /** Cheap one-line preview for --list. */
84
+ export function preview(file, agent) {
56
85
  try {
57
- const records = readJsonl(file);
58
- for (const r of records) if (r.type === 'ai-title' && r.aiTitle) return r.aiTitle;
59
- for (const r of records) {
60
- if (r.isMeta || r.isSidechain) continue;
61
- const isUser = r.type === 'user' || (r.payload?.type === 'message' && r.payload.role === 'user');
62
- if (!isUser) continue;
63
- const c = r.message?.content ?? r.payload.content;
64
- const blocks = typeof c === 'string' ? [c] : Array.isArray(c) ? c.map((b) => (b.type === 'tool_result' ? '' : b.text || '')) : [];
65
- for (const b of blocks) {
66
- const clean = stripHarnessTags(b);
67
- if (clean && !clean.startsWith('<')) return clean.split('\n')[0].slice(0, 70);
68
- }
69
- }
86
+ if (agent === 'claude' || agent === 'codex') return previewJsonl(file);
87
+ const s = PARSERS[agent].parse(file);
88
+ return s.title || '(no prompt)';
70
89
  } catch {
71
- /* unreadable */
90
+ return '(unreadable)';
91
+ }
92
+ }
93
+
94
+ function previewJsonl(file) {
95
+ const records = readJsonl(file);
96
+ for (const r of records) if (r.type === 'ai-title' && r.aiTitle) return r.aiTitle;
97
+ for (const r of records) {
98
+ if (r.isMeta || r.isSidechain) continue;
99
+ const isUser = r.type === 'user' || (r.payload?.type === 'message' && r.payload.role === 'user');
100
+ if (!isUser) continue;
101
+ const c = r.message?.content ?? r.payload.content;
102
+ const blocks = typeof c === 'string' ? [c] : Array.isArray(c) ? c.map((b) => (b.type === 'tool_result' ? '' : b.text || '')) : [];
103
+ for (const b of blocks) {
104
+ const clean = stripHarnessTags(b);
105
+ if (clean && !clean.startsWith('<')) return clean.split('\n')[0].slice(0, 70);
106
+ }
72
107
  }
73
108
  return '(no prompt)';
74
109
  }