@dorywoof/agentreplay 0.1.0 → 0.3.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 +73 -14
- package/bin/agentreplay.js +62 -12
- package/package.json +17 -3
- package/skills/replay/SKILL.md +76 -0
- package/src/discover.js +82 -47
- package/src/install-skill.js +88 -0
- package/src/parsers/agents.js +377 -0
- package/src/parsers/claude.js +1 -1
- package/src/parsers/codex.js +2 -24
- package/src/parsers/universal.js +467 -0
- package/src/stats.js +3 -1
- package/src/template.html +3 -3
- package/src/util.js +86 -0
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
|
|
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
|
-
- 🤝 **
|
|
30
|
-
- 💸 **Cost and token panel.** Input, output and cache tokens,
|
|
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.**
|
|
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,84 @@ 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
|
|
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
|
+
### As a Claude Code plugin
|
|
53
|
+
|
|
54
|
+
Replay the session you're in without leaving Claude Code:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
/plugin install agentreplay --marketplace dorywoof/agentreplay
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
On older Claude Code versions, use two steps instead:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
/plugin marketplace add dorywoof/agentreplay
|
|
64
|
+
/plugin install agentreplay@agentreplay
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then type `/agentreplay:replay`, or just ask *"make a replay of this session"*. Claude runs the CLI for you, writes the HTML next to your project and tells you what was redacted. Arguments pass through, for example `/agentreplay:replay --list`.
|
|
68
|
+
|
|
69
|
+
### As a skill in Codex, Gemini CLI, OpenCode, Copilot, Cursor…
|
|
51
70
|
|
|
52
|
-
|
|
71
|
+
Most agents now read the open [Agent Skills](https://agentskills.io) format (`SKILL.md`). One command installs the replay skill into every agent it finds on your machine:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx @dorywoof/agentreplay install-skill
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Agent | Installed to |
|
|
53
78
|
|---|---|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
79
|
+
| Shared folder several agents read | `~/.agents/skills/agentreplay/` (always) |
|
|
80
|
+
| Claude Code | `~/.claude/skills/agentreplay/` |
|
|
81
|
+
| Codex | `~/.codex/skills/agentreplay/` |
|
|
82
|
+
| Gemini CLI | `~/.gemini/skills/agentreplay/` |
|
|
83
|
+
| Qwen Code | `~/.qwen/skills/agentreplay/` |
|
|
84
|
+
| OpenCode | `~/.config/opencode/skills/agentreplay/` |
|
|
85
|
+
| GitHub Copilot | `~/.copilot/skills/agentreplay/` |
|
|
86
|
+
| Cursor | `~/.cursor/skills/agentreplay/` |
|
|
87
|
+
| Windsurf, Amp, Goose | their own `skills/` folders |
|
|
88
|
+
|
|
89
|
+
Folders are only written for agents that are installed (`--force` writes all of them). `--agent codex` limits it to one agent, `--project` installs into the current repo instead (`.agents/skills`, `.claude/skills`, …) so your whole team gets it, and `uninstall-skill` removes it again. Restart the agent afterwards, then ask it to *"make a replay of this session"*.
|
|
90
|
+
|
|
91
|
+
> Skill folder locations differ between agents and versions. If your agent doesn't pick the skill up, copy [`skills/replay/SKILL.md`](skills/replay/SKILL.md) into the folder its docs name.
|
|
92
|
+
|
|
93
|
+
### Where sessions live
|
|
94
|
+
|
|
95
|
+
Sessions are found automatically. You can also pass any file directly.
|
|
96
|
+
|
|
97
|
+
| Agent | `--agent` | Where it looks |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| Claude Code | `claude` | `~/.claude/projects/*/*.jsonl` |
|
|
100
|
+
| Codex | `codex` | `~/.codex/sessions/**/rollout-*.jsonl` |
|
|
101
|
+
| Gemini CLI | `gemini` | `~/.gemini/tmp/*/chats/*.json(l)` |
|
|
102
|
+
| Qwen Code | `qwen` | `~/.qwen/projects/*/chats/*.jsonl` |
|
|
103
|
+
| OpenCode | `opencode` | `~/.local/share/opencode/`: `storage/` JSON, `opencode.db`, or an `opencode export` file |
|
|
104
|
+
| Cline | `cline` | VS Code / Cursor / Windsurf globalStorage `saoudrizwan.claude-dev/tasks/*`, `~/.cline/data/tasks/*` |
|
|
105
|
+
| Roo Code | `roo` | globalStorage `rooveterinaryinc.roo-cline/tasks/*` |
|
|
106
|
+
| Kilo Code | `kilo` | globalStorage `kilocode.kilo-code/tasks/*` |
|
|
107
|
+
| GitHub Copilot CLI | `copilot` | `~/.copilot/session-state/**/*.jsonl` |
|
|
108
|
+
| Amp | `amp` | `~/.local/share/amp/threads/*.json` |
|
|
109
|
+
| Aider | `aider` | `.aider.chat.history.md` in the current folder |
|
|
110
|
+
| Anything else | `generic` | Pass the file: Anthropic / OpenAI / Gemini-style messages in JSON or JSONL |
|
|
111
|
+
|
|
112
|
+
`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).
|
|
56
113
|
|
|
57
|
-
|
|
114
|
+
> 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
115
|
|
|
59
116
|
## Options
|
|
60
117
|
|
|
61
118
|
```
|
|
62
119
|
-o, --out <file> output HTML path (default: ./replay-<id>.html)
|
|
63
|
-
-a, --agent <name> only
|
|
120
|
+
-a, --agent <name> only one agent (see the table above)
|
|
121
|
+
-s, --session <id> replay the session whose id / file name matches
|
|
64
122
|
-t, --title <text> override the replay title
|
|
65
123
|
--no-thinking hide thinking / reasoning blocks
|
|
66
124
|
--no-redact keep secrets, e-mails and home paths (not for sharing!)
|
|
@@ -84,7 +142,7 @@ The output is a static file, so any of these work:
|
|
|
84
142
|
|
|
85
143
|
## About the cost estimate
|
|
86
144
|
|
|
87
|
-
|
|
145
|
+
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
146
|
|
|
89
147
|
```json
|
|
90
148
|
{ "gpt-6.1": { "input": 1.25, "output": 10, "cacheRead": 0.125 } }
|
|
@@ -96,13 +154,14 @@ npx @dorywoof/agentreplay --pricing prices.json
|
|
|
96
154
|
|
|
97
155
|
## Roadmap
|
|
98
156
|
|
|
99
|
-
- [ ]
|
|
157
|
+
- [ ] Cursor and Windsurf built-in chat (stored in proprietary SQLite blobs)
|
|
158
|
+
- [ ] Goose, Crush, Droid and Kiro sessions
|
|
100
159
|
- [ ] Export to GIF / MP4 for social posts
|
|
101
160
|
- [ ] Subagent (sidechain) lanes
|
|
102
161
|
- [ ] `agentreplay publish`: one-command upload to a gist
|
|
103
162
|
- [ ] Combine several sessions into one replay
|
|
104
163
|
|
|
105
|
-
Ideas and PRs are welcome. Adding a new agent means
|
|
164
|
+
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
165
|
|
|
107
166
|
## Development
|
|
108
167
|
|
package/bin/agentreplay.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createRedactor } from '../src/redact.js';
|
|
|
8
8
|
import { computeStats } from '../src/stats.js';
|
|
9
9
|
import { loadPricing } from '../src/pricing.js';
|
|
10
10
|
import { renderHtml } from '../src/render.js';
|
|
11
|
+
import { installSkill, uninstallSkill } from '../src/install-skill.js';
|
|
11
12
|
|
|
12
13
|
const HELP = `
|
|
13
14
|
agentreplay — turn an AI coding session into a shareable replay
|
|
@@ -17,10 +18,18 @@ Usage
|
|
|
17
18
|
agentreplay <session.jsonl> replay a specific log file
|
|
18
19
|
agentreplay --list list recent sessions
|
|
19
20
|
agentreplay --pick 3 replay #3 from --list
|
|
21
|
+
agentreplay --session <id> replay the session whose id / file name matches
|
|
22
|
+
agentreplay --agents show supported agents and what was found
|
|
23
|
+
agentreplay install-skill add a "replay" skill to every agent on this machine
|
|
24
|
+
(Claude Code, Codex, Gemini CLI, OpenCode, Copilot,
|
|
25
|
+
Cursor…). --project installs into the current repo,
|
|
26
|
+
--agent <name> limits it to one agent.
|
|
27
|
+
agentreplay uninstall-skill remove it again
|
|
20
28
|
|
|
21
29
|
Options
|
|
22
30
|
-o, --out <file> output HTML path (default: ./replay-<id>.html)
|
|
23
|
-
-a, --agent <name> only
|
|
31
|
+
-a, --agent <name> only one agent: claude, codex, gemini, qwen, opencode,
|
|
32
|
+
cline, roo, kilo, copilot, amp, aider, generic
|
|
24
33
|
-t, --title <text> override the replay title
|
|
25
34
|
--no-thinking hide thinking / reasoning blocks
|
|
26
35
|
--no-redact keep secrets, e-mails and home paths (not for sharing!)
|
|
@@ -38,7 +47,11 @@ const { values: opts, positionals } = parseArgs({
|
|
|
38
47
|
agent: { type: 'string', short: 'a' },
|
|
39
48
|
title: { type: 'string', short: 't' },
|
|
40
49
|
list: { type: 'boolean', short: 'l' },
|
|
50
|
+
agents: { type: 'boolean' },
|
|
41
51
|
pick: { type: 'string', short: 'p' },
|
|
52
|
+
session: { type: 'string', short: 's' },
|
|
53
|
+
project: { type: 'boolean' },
|
|
54
|
+
force: { type: 'boolean' },
|
|
42
55
|
'no-thinking': { type: 'boolean' },
|
|
43
56
|
'no-redact': { type: 'boolean' },
|
|
44
57
|
'keep-paths': { type: 'boolean' },
|
|
@@ -66,14 +79,41 @@ function ago(ms) {
|
|
|
66
79
|
|
|
67
80
|
function main() {
|
|
68
81
|
if (opts.help) return console.log(HELP);
|
|
69
|
-
|
|
82
|
+
|
|
83
|
+
if (positionals[0] === 'install-skill' || positionals[0] === 'uninstall-skill') {
|
|
84
|
+
const project = opts.project ? process.cwd() : null;
|
|
85
|
+
const results =
|
|
86
|
+
positionals[0] === 'install-skill'
|
|
87
|
+
? installSkill({ project, only: opts.agent, force: opts.force })
|
|
88
|
+
: uninstallSkill({ project });
|
|
89
|
+
const done = results.filter((r) => r.status !== 'skipped');
|
|
90
|
+
for (const r of done) console.log(`${bold('✓')} ${r.agent.padEnd(20)} ${dim(r.status.padEnd(9))} ${r.file}`);
|
|
91
|
+
const skipped = results.filter((r) => r.status === 'skipped').map((r) => r.agent);
|
|
92
|
+
if (skipped.length) console.log(dim(` not installed (agent not found): ${skipped.join(', ')}. Use --force to install anyway.`));
|
|
93
|
+
if (!done.length) console.log(positionals[0] === 'install-skill' ? 'Nothing installed.' : 'No agentreplay skill found to remove.');
|
|
94
|
+
else if (positionals[0] === 'install-skill') console.log(`\nRestart your agent, then ask it to ${bold('"make a replay of this session"')} (in Claude Code: ${bold('/agentreplay')}).`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (opts.agent && !PARSERS[opts.agent]) fail(`unknown agent "${opts.agent}" (one of: ${Object.keys(PARSERS).join(', ')})`);
|
|
99
|
+
|
|
100
|
+
if (opts.agents) {
|
|
101
|
+
console.log(bold('Supported agents') + dim(' (sessions found on this machine)') + '\n');
|
|
102
|
+
for (const [key, src] of Object.entries(PARSERS)) {
|
|
103
|
+
if (key === 'generic') continue;
|
|
104
|
+
const n = listSessions({ agent: key }).length;
|
|
105
|
+
console.log(` ${key.padEnd(9)} ${src.label.padEnd(13)} ${n ? bold(String(n)) : dim('0')}`);
|
|
106
|
+
}
|
|
107
|
+
console.log('\n' + dim('Any other JSON / JSONL chat log works too: agentreplay path/to/log.json'));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
70
110
|
|
|
71
111
|
if (opts.list) {
|
|
72
112
|
const sessions = listSessions({ agent: opts.agent }).slice(0, 20);
|
|
73
|
-
if (!sessions.length) fail('no
|
|
113
|
+
if (!sessions.length) fail('no agent sessions found on this machine. Pass a log file path instead.');
|
|
74
114
|
sessions.forEach((s, i) => {
|
|
75
|
-
const tag = s.agent
|
|
76
|
-
console.log(`${bold(String(i + 1).padStart(2))} ${tag} ${dim(ago(s.mtime).padEnd(8))} ${preview(s.file)}`);
|
|
115
|
+
const tag = PARSERS[s.agent].label.padEnd(12);
|
|
116
|
+
console.log(`${bold(String(i + 1).padStart(2))} ${tag} ${dim(ago(s.mtime).padEnd(8))} ${preview(s.file, s.agent)}`);
|
|
77
117
|
});
|
|
78
118
|
console.log(dim('\nReplay one with: agentreplay --pick <n>'));
|
|
79
119
|
return;
|
|
@@ -82,15 +122,25 @@ function main() {
|
|
|
82
122
|
let file, agent;
|
|
83
123
|
if (positionals[0]) {
|
|
84
124
|
file = path.resolve(positionals[0]);
|
|
85
|
-
if (!fs.existsSync(file)) fail(`file not found: ${file}`);
|
|
125
|
+
if (!fs.existsSync(file.split('#')[0])) fail(`file not found: ${file}`);
|
|
86
126
|
agent = opts.agent || detectAgent(file);
|
|
87
|
-
if (!agent) fail('could not
|
|
127
|
+
if (!agent) fail('could not find a conversation in this file. Run agentreplay --agents to see supported formats.');
|
|
88
128
|
} else {
|
|
89
129
|
const sessions = listSessions({ agent: opts.agent });
|
|
90
|
-
if (!sessions.length) fail('no
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
if (!sessions.length) fail('no agent sessions found on this machine. Pass a log file path instead.');
|
|
131
|
+
let chosen = null;
|
|
132
|
+
const wanted = (opts.session || '').trim();
|
|
133
|
+
// An unexpanded "${CLAUDE_SESSION_ID}" or an unknown id falls back to the newest session.
|
|
134
|
+
if (wanted && !wanted.includes('$')) {
|
|
135
|
+
chosen = sessions.find((s) => path.basename(s.file).includes(wanted) || s.file.endsWith('#' + wanted));
|
|
136
|
+
if (!chosen) console.error(dim(`session "${wanted}" not found — using the most recent one`));
|
|
137
|
+
}
|
|
138
|
+
if (!chosen) {
|
|
139
|
+
const idx = opts.pick ? Number(opts.pick) - 1 : 0;
|
|
140
|
+
if (!sessions[idx]) fail(`no session #${opts.pick} — run with --list to see what's available`);
|
|
141
|
+
chosen = sessions[idx];
|
|
142
|
+
}
|
|
143
|
+
({ file, agent } = chosen);
|
|
94
144
|
}
|
|
95
145
|
|
|
96
146
|
let session = PARSERS[agent].parse(file);
|
|
@@ -112,7 +162,7 @@ function main() {
|
|
|
112
162
|
return;
|
|
113
163
|
}
|
|
114
164
|
|
|
115
|
-
const out = path.resolve(opts.out || `replay-${session.id.slice(0,
|
|
165
|
+
const out = path.resolve(opts.out || `replay-${String(session.id).replace(/[^w-]/g, '').slice(0, 12) || 'session'}.html`);
|
|
116
166
|
fs.mkdirSync(path.dirname(out), { recursive: true });
|
|
117
167
|
fs.writeFileSync(out, renderHtml(session, stats, { redactions }));
|
|
118
168
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dorywoof/agentreplay",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Turn Claude Code
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"bin",
|
|
19
19
|
"src",
|
|
20
|
+
"skills",
|
|
20
21
|
"README.md",
|
|
21
22
|
"LICENSE"
|
|
22
23
|
],
|
|
@@ -35,7 +36,20 @@
|
|
|
35
36
|
"session",
|
|
36
37
|
"transcript",
|
|
37
38
|
"llm",
|
|
38
|
-
"cli"
|
|
39
|
+
"cli",
|
|
40
|
+
"gemini-cli",
|
|
41
|
+
"opencode",
|
|
42
|
+
"cline",
|
|
43
|
+
"roo-code",
|
|
44
|
+
"kilo-code",
|
|
45
|
+
"copilot",
|
|
46
|
+
"qwen-code",
|
|
47
|
+
"amp",
|
|
48
|
+
"aider",
|
|
49
|
+
"chat-log",
|
|
50
|
+
"transcript-viewer",
|
|
51
|
+
"claude-code-plugin",
|
|
52
|
+
"claude-skill"
|
|
39
53
|
],
|
|
40
54
|
"license": "MIT"
|
|
41
55
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: replay
|
|
3
|
+
description: Turn the current coding-agent session into a shareable, video-like HTML replay with diffs, tool calls, token/cost stats and automatic secret redaction. Use when the user asks to replay, share, export, record or show off what was done in this session, or asks for a replay of an earlier Claude Code, Codex, Gemini CLI, OpenCode, Cline, Roo, Copilot CLI, Qwen, Amp or Aider session.
|
|
4
|
+
argument-hint: "[--list | --pick N | path/to/log] [--title \"…\"] [--no-thinking]"
|
|
5
|
+
allowed-tools: Bash(npx -y @dorywoof/agentreplay*), Bash(npx @dorywoof/agentreplay*)
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Replay this session
|
|
9
|
+
|
|
10
|
+
agentreplay is a zero-dependency CLI on npm (`@dorywoof/agentreplay`). It reads
|
|
11
|
+
agent session logs from disk and writes one self-contained HTML file that plays
|
|
12
|
+
the session back like a video. It runs locally and uploads nothing. It works the
|
|
13
|
+
same no matter which agent is running this skill.
|
|
14
|
+
|
|
15
|
+
## Default: replay the current session
|
|
16
|
+
|
|
17
|
+
Run this in the user's shell, with `<agent>` set to the agent you are:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx -y @dorywoof/agentreplay@latest --agent <agent> -o agentreplay.html
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| You are | `<agent>` |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Claude Code | `claude` (also add `--session "${CLAUDE_SESSION_ID}"`) |
|
|
26
|
+
| OpenAI Codex | `codex` |
|
|
27
|
+
| Gemini CLI | `gemini` |
|
|
28
|
+
| Qwen Code | `qwen` |
|
|
29
|
+
| OpenCode | `opencode` |
|
|
30
|
+
| GitHub Copilot CLI | `copilot` |
|
|
31
|
+
| Cline / Roo Code / Kilo Code | `cline` / `roo` / `kilo` |
|
|
32
|
+
| Amp | `amp` |
|
|
33
|
+
| Aider | `aider` |
|
|
34
|
+
| Not sure | leave `--agent` out: the newest session of any agent is used |
|
|
35
|
+
|
|
36
|
+
- The session being written right now is the newest log of that agent, so
|
|
37
|
+
this picks it up without an id. If a `--session` value is empty or not found,
|
|
38
|
+
the CLI falls back to the newest session by itself.
|
|
39
|
+
- Write the file in the current working directory unless the user names
|
|
40
|
+
another place; use a more descriptive file name when there is an obvious
|
|
41
|
+
one. The file opens in the browser; add `--no-open` if the user asked not to
|
|
42
|
+
open it or there is no desktop.
|
|
43
|
+
- Add `--title "…"` when the session has an obvious one-line summary.
|
|
44
|
+
|
|
45
|
+
## Other requests
|
|
46
|
+
|
|
47
|
+
| User wants | Add |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Choose an earlier session | run with `--list` first, then `--pick N` |
|
|
50
|
+
| See which agents have sessions on this machine | `--agents` |
|
|
51
|
+
| Replay a specific log file | the file path as the first argument |
|
|
52
|
+
| Hide reasoning | `--no-thinking` |
|
|
53
|
+
| Keep file paths but still strip secrets | `--keep-paths` |
|
|
54
|
+
| Raw data instead of HTML | `--json` |
|
|
55
|
+
|
|
56
|
+
Pass through any arguments the user gave this skill.
|
|
57
|
+
|
|
58
|
+
## Rules
|
|
59
|
+
|
|
60
|
+
- Never pass `--no-redact` unless the user explicitly asks for it, and if they
|
|
61
|
+
do, warn them that secrets, e-mails and home paths will be in the file.
|
|
62
|
+
- Redaction covers common secret formats but not everything private. Tell the
|
|
63
|
+
user to skim the replay before posting it publicly.
|
|
64
|
+
- Don't upload or publish the HTML anywhere yourself. Offer the sharing options
|
|
65
|
+
below and let the user choose.
|
|
66
|
+
|
|
67
|
+
## After it runs
|
|
68
|
+
|
|
69
|
+
Report in two or three lines: the output path, the one-line stats the CLI
|
|
70
|
+
printed (events, tool calls, files, minutes, cost), and what was redacted. Then
|
|
71
|
+
mention the ways to share it: drag the file onto Netlify Drop, attach it in Slack/Discord,
|
|
72
|
+
or commit it to a GitHub Pages branch. `#e42` at the end of the URL opens the
|
|
73
|
+
replay at event 42 and `?static` shows everything at once.
|
|
74
|
+
|
|
75
|
+
If the command fails because Node is missing, say that agentreplay needs
|
|
76
|
+
Node.js 18 or newer.
|
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
|
|
6
|
-
import * as
|
|
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
|
-
|
|
10
|
+
const home = os.homedir();
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
42
|
+
return fs.statSync(ref.split('#')[0]).mtimeMs;
|
|
21
43
|
} catch {
|
|
22
|
-
return
|
|
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
|
|
48
|
+
/** All sessions found on this machine, newest first. */
|
|
33
49
|
export function listSessions({ agent } = {}) {
|
|
34
50
|
const found = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
64
|
+
/** Pick the parser for an arbitrary file path. */
|
|
47
65
|
export function detectAgent(file) {
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
|
|
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
|
|
55
|
-
export function preview(file) {
|
|
83
|
+
/** Cheap one-line preview for --list. */
|
|
84
|
+
export function preview(file, agent) {
|
|
56
85
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the replay skill (an Agent Skills SKILL.md) into every coding agent
|
|
3
|
+
* on this machine. The format is shared; only the folder each agent reads from
|
|
4
|
+
* differs, so we copy the same file into each one.
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const SKILL_SRC = fileURLToPath(new URL('../skills/replay/SKILL.md', import.meta.url));
|
|
12
|
+
export const SKILL_NAME = 'agentreplay';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Where each agent looks for skills. `home` is the agent's own folder: we only
|
|
16
|
+
* install for agents that are present. `.agents/skills` is the shared location
|
|
17
|
+
* several agents read, so it is always written.
|
|
18
|
+
*/
|
|
19
|
+
export function targets({ home = os.homedir(), project = null } = {}) {
|
|
20
|
+
const env = process.env;
|
|
21
|
+
const xdg = env.XDG_CONFIG_HOME || path.join(home, '.config');
|
|
22
|
+
if (project) {
|
|
23
|
+
return [
|
|
24
|
+
{ agent: 'Shared (.agents)', dir: path.join(project, '.agents', 'skills'), always: true },
|
|
25
|
+
{ agent: 'Claude Code', dir: path.join(project, '.claude', 'skills'), always: true },
|
|
26
|
+
{ agent: 'Gemini CLI', dir: path.join(project, '.gemini', 'skills'), when: path.join(project, '.gemini') },
|
|
27
|
+
{ agent: 'OpenCode', dir: path.join(project, '.opencode', 'skills'), when: path.join(project, '.opencode') },
|
|
28
|
+
{ agent: 'GitHub Copilot', dir: path.join(project, '.github', 'skills'), when: path.join(project, '.github') },
|
|
29
|
+
{ agent: 'Cursor', dir: path.join(project, '.cursor', 'skills'), when: path.join(project, '.cursor') },
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
{ agent: 'Shared (~/.agents)', dir: path.join(home, '.agents', 'skills'), always: true },
|
|
34
|
+
{ agent: 'Claude Code', dir: path.join(env.CLAUDE_CONFIG_DIR || path.join(home, '.claude'), 'skills'), when: env.CLAUDE_CONFIG_DIR || path.join(home, '.claude') },
|
|
35
|
+
{ agent: 'Codex', dir: path.join(env.CODEX_HOME || path.join(home, '.codex'), 'skills'), when: env.CODEX_HOME || path.join(home, '.codex') },
|
|
36
|
+
{ agent: 'Gemini CLI', dir: path.join(home, '.gemini', 'skills'), when: path.join(home, '.gemini') },
|
|
37
|
+
{ agent: 'Qwen Code', dir: path.join(home, '.qwen', 'skills'), when: path.join(home, '.qwen') },
|
|
38
|
+
{ agent: 'OpenCode', dir: path.join(xdg, 'opencode', 'skills'), when: path.join(xdg, 'opencode') },
|
|
39
|
+
{ agent: 'GitHub Copilot', dir: path.join(env.COPILOT_HOME || path.join(home, '.copilot'), 'skills'), when: env.COPILOT_HOME || path.join(home, '.copilot') },
|
|
40
|
+
{ agent: 'Cursor', dir: path.join(home, '.cursor', 'skills'), when: path.join(home, '.cursor') },
|
|
41
|
+
{ agent: 'Windsurf', dir: path.join(home, '.codeium', 'windsurf', 'skills'), when: path.join(home, '.codeium', 'windsurf') },
|
|
42
|
+
{ agent: 'Amp', dir: path.join(xdg, 'amp', 'skills'), when: path.join(xdg, 'amp') },
|
|
43
|
+
{ agent: 'Goose', dir: path.join(xdg, 'goose', 'skills'), when: path.join(xdg, 'goose') },
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The SKILL.md with `name:` matching the folder it's installed into (the spec requires that). */
|
|
48
|
+
function skillText() {
|
|
49
|
+
return fs.readFileSync(SKILL_SRC, 'utf8').replace(/^name:\s*.+$/m, `name: ${SKILL_NAME}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @returns {{agent:string, file:string, status:'installed'|'updated'|'unchanged'|'skipped'}[]}
|
|
54
|
+
*/
|
|
55
|
+
export function installSkill({ home, project, only, force = false } = {}) {
|
|
56
|
+
const text = skillText();
|
|
57
|
+
const results = [];
|
|
58
|
+
for (const t of targets({ home, project })) {
|
|
59
|
+
if (only && !t.agent.toLowerCase().includes(only.toLowerCase())) continue;
|
|
60
|
+
const file = path.join(t.dir, SKILL_NAME, 'SKILL.md');
|
|
61
|
+
if (!t.always && !force && !(t.when && fs.existsSync(t.when))) {
|
|
62
|
+
results.push({ agent: t.agent, file, status: 'skipped' });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
let status = 'installed';
|
|
66
|
+
if (fs.existsSync(file)) status = fs.readFileSync(file, 'utf8') === text ? 'unchanged' : 'updated';
|
|
67
|
+
if (status !== 'unchanged') {
|
|
68
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
69
|
+
fs.writeFileSync(file, text);
|
|
70
|
+
}
|
|
71
|
+
results.push({ agent: t.agent, file, status });
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Remove only folders this tool created (they hold our SKILL.md). */
|
|
77
|
+
export function uninstallSkill({ home, project } = {}) {
|
|
78
|
+
const results = [];
|
|
79
|
+
for (const t of targets({ home, project })) {
|
|
80
|
+
const dir = path.join(t.dir, SKILL_NAME);
|
|
81
|
+
const file = path.join(dir, 'SKILL.md');
|
|
82
|
+
if (!fs.existsSync(file)) continue;
|
|
83
|
+
if (!fs.readFileSync(file, 'utf8').includes('@dorywoof/agentreplay')) continue; // not ours
|
|
84
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
85
|
+
results.push({ agent: t.agent, file, status: 'removed' });
|
|
86
|
+
}
|
|
87
|
+
return results;
|
|
88
|
+
}
|