@dorywoof/agentreplay 0.2.0 → 0.4.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 +45 -1
- package/bin/agentreplay.js +39 -3
- package/package.json +5 -2
- package/skills/replay/SKILL.md +76 -0
- package/src/install-skill.js +88 -0
- package/src/parsers/claude.js +2 -1
- package/src/parsers/codex.js +9 -2
- package/src/stats.js +2 -0
- package/src/template.html +295 -205
- package/src/util.js +13 -0
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ You just watched an AI agent build a feature in 6 minutes. Now you want to show
|
|
|
32
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.
|
|
33
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.
|
|
34
34
|
- 📦 **One file, zero dependencies.** The output is one HTML file that works offline. Host it anywhere: GitHub Pages, a gist, Slack, e-mail.
|
|
35
|
+
- 🌍 **Speaks the viewer's language.** The page follows the browser language (English, Türkçe, Español, Deutsch, Français, Português, Italiano, Русский, 日本語, 中文, 한국어). Add `?lang=xx` to force one.
|
|
36
|
+
- 🧮 **Honest token numbers.** Agents re-send the whole conversation on every request, so summed tokens balloon. The replay leads with the largest single prompt and explains the total, including how much came from cache.
|
|
35
37
|
- 🌗 Light and dark themes, works on phones, and keyboard shortcuts (`space`, `←` `→`, `Home`, `End`).
|
|
36
38
|
|
|
37
39
|
## Quick start
|
|
@@ -49,6 +51,47 @@ npx @dorywoof/agentreplay --agents # which agents were found on this machine
|
|
|
49
51
|
|
|
50
52
|
Requires Node 18+. Nothing is uploaded anywhere: everything happens on your machine.
|
|
51
53
|
|
|
54
|
+
### As a Claude Code plugin
|
|
55
|
+
|
|
56
|
+
Replay the session you're in without leaving Claude Code:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/plugin install agentreplay --marketplace dorywoof/agentreplay
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
On older Claude Code versions, use two steps instead:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
/plugin marketplace add dorywoof/agentreplay
|
|
66
|
+
/plugin install agentreplay@agentreplay
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
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`.
|
|
70
|
+
|
|
71
|
+
### As a skill in Codex, Gemini CLI, OpenCode, Copilot, Cursor…
|
|
72
|
+
|
|
73
|
+
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:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx @dorywoof/agentreplay install-skill
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
| Agent | Installed to |
|
|
80
|
+
|---|---|
|
|
81
|
+
| Shared folder several agents read | `~/.agents/skills/agentreplay/` (always) |
|
|
82
|
+
| Claude Code | `~/.claude/skills/agentreplay/` |
|
|
83
|
+
| Codex | `~/.codex/skills/agentreplay/` |
|
|
84
|
+
| Gemini CLI | `~/.gemini/skills/agentreplay/` |
|
|
85
|
+
| Qwen Code | `~/.qwen/skills/agentreplay/` |
|
|
86
|
+
| OpenCode | `~/.config/opencode/skills/agentreplay/` |
|
|
87
|
+
| GitHub Copilot | `~/.copilot/skills/agentreplay/` |
|
|
88
|
+
| Cursor | `~/.cursor/skills/agentreplay/` |
|
|
89
|
+
| Windsurf, Amp, Goose | their own `skills/` folders |
|
|
90
|
+
|
|
91
|
+
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"*.
|
|
92
|
+
|
|
93
|
+
> 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.
|
|
94
|
+
|
|
52
95
|
### Where sessions live
|
|
53
96
|
|
|
54
97
|
Sessions are found automatically. You can also pass any file directly.
|
|
@@ -77,6 +120,7 @@ Sessions are found automatically. You can also pass any file directly.
|
|
|
77
120
|
```
|
|
78
121
|
-o, --out <file> output HTML path (default: ./replay-<id>.html)
|
|
79
122
|
-a, --agent <name> only one agent (see the table above)
|
|
123
|
+
-s, --session <id> replay the session whose id / file name matches
|
|
80
124
|
-t, --title <text> override the replay title
|
|
81
125
|
--no-thinking hide thinking / reasoning blocks
|
|
82
126
|
--no-redact keep secrets, e-mails and home paths (not for sharing!)
|
|
@@ -86,7 +130,7 @@ Sessions are found automatically. You can also pass any file directly.
|
|
|
86
130
|
--no-open don't open the replay in a browser
|
|
87
131
|
```
|
|
88
132
|
|
|
89
|
-
**URL tricks:** add `#e42` to open a replay at event 42,
|
|
133
|
+
**URL tricks:** add `#e42` to open a replay at event 42, `?static` to show the whole session at once with no animation, or `?lang=de` to pick the interface language.
|
|
90
134
|
|
|
91
135
|
## Sharing a replay
|
|
92
136
|
|
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,7 +18,13 @@ 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
|
|
20
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
|
|
21
28
|
|
|
22
29
|
Options
|
|
23
30
|
-o, --out <file> output HTML path (default: ./replay-<id>.html)
|
|
@@ -42,6 +49,9 @@ const { values: opts, positionals } = parseArgs({
|
|
|
42
49
|
list: { type: 'boolean', short: 'l' },
|
|
43
50
|
agents: { type: 'boolean' },
|
|
44
51
|
pick: { type: 'string', short: 'p' },
|
|
52
|
+
session: { type: 'string', short: 's' },
|
|
53
|
+
project: { type: 'boolean' },
|
|
54
|
+
force: { type: 'boolean' },
|
|
45
55
|
'no-thinking': { type: 'boolean' },
|
|
46
56
|
'no-redact': { type: 'boolean' },
|
|
47
57
|
'keep-paths': { type: 'boolean' },
|
|
@@ -69,6 +79,22 @@ function ago(ms) {
|
|
|
69
79
|
|
|
70
80
|
function main() {
|
|
71
81
|
if (opts.help) return console.log(HELP);
|
|
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
|
+
|
|
72
98
|
if (opts.agent && !PARSERS[opts.agent]) fail(`unknown agent "${opts.agent}" (one of: ${Object.keys(PARSERS).join(', ')})`);
|
|
73
99
|
|
|
74
100
|
if (opts.agents) {
|
|
@@ -102,9 +128,19 @@ function main() {
|
|
|
102
128
|
} else {
|
|
103
129
|
const sessions = listSessions({ agent: opts.agent });
|
|
104
130
|
if (!sessions.length) fail('no agent sessions found on this machine. Pass a log file path instead.');
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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);
|
|
108
144
|
}
|
|
109
145
|
|
|
110
146
|
let session = PARSERS[agent].parse(file);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dorywoof/agentreplay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
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": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"bin",
|
|
19
19
|
"src",
|
|
20
|
+
"skills",
|
|
20
21
|
"README.md",
|
|
21
22
|
"LICENSE"
|
|
22
23
|
],
|
|
@@ -46,7 +47,9 @@
|
|
|
46
47
|
"amp",
|
|
47
48
|
"aider",
|
|
48
49
|
"chat-log",
|
|
49
|
-
"transcript-viewer"
|
|
50
|
+
"transcript-viewer",
|
|
51
|
+
"claude-code-plugin",
|
|
52
|
+
"claude-skill"
|
|
50
53
|
],
|
|
51
54
|
"license": "MIT"
|
|
52
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.
|
|
@@ -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
|
+
}
|
package/src/parsers/claude.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { readJsonl, toText, stripHarnessTags, truncate, lineDelta } from '../util.js';
|
|
2
|
+
import { readJsonl, toText, stripHarnessTags, truncate, lineDelta, trackRequest } from '../util.js';
|
|
3
3
|
|
|
4
4
|
const MAX_OUTPUT = 4000;
|
|
5
5
|
const EDIT_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
|
|
@@ -102,6 +102,7 @@ function addUsage(session, model, u) {
|
|
|
102
102
|
session.usage[k] += add[k];
|
|
103
103
|
per[k] += add[k];
|
|
104
104
|
}
|
|
105
|
+
trackRequest(session, add);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
function toolEvent(b, ts) {
|
package/src/parsers/codex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { readJsonl, toText, truncate, parsePatch } from '../util.js';
|
|
2
|
+
import { readJsonl, toText, truncate, parsePatch, trackRequest } from '../util.js';
|
|
3
3
|
|
|
4
4
|
const MAX_OUTPUT = 4000;
|
|
5
5
|
|
|
@@ -48,7 +48,14 @@ export function parse(file) {
|
|
|
48
48
|
if (currentModel) session.models.add(currentModel);
|
|
49
49
|
|
|
50
50
|
if (r.type === 'event_msg' && p.type === 'token_count' && p.info?.total_token_usage) {
|
|
51
|
-
|
|
51
|
+
const tot = p.info.total_token_usage; // cumulative across the session
|
|
52
|
+
const last = p.info.last_token_usage; // this one request
|
|
53
|
+
const changed = !lastTotals || tot.total_tokens !== lastTotals.total_tokens || tot.input_tokens !== lastTotals.input_tokens;
|
|
54
|
+
if (last && changed) {
|
|
55
|
+
const cachedLast = last.cached_input_tokens || 0;
|
|
56
|
+
trackRequest(session, { input: (last.input_tokens || 0) - cachedLast, cacheRead: cachedLast, output: last.output_tokens || 0 });
|
|
57
|
+
}
|
|
58
|
+
lastTotals = tot;
|
|
52
59
|
continue;
|
|
53
60
|
}
|
|
54
61
|
if (r.type !== 'response_item') continue;
|
package/src/stats.js
CHANGED
|
@@ -56,6 +56,8 @@ export function computeStats(session, pricing) {
|
|
|
56
56
|
cacheRead: u.cacheRead,
|
|
57
57
|
cacheWrite: u.cacheWrite + u.cacheWrite1h,
|
|
58
58
|
total: u.input + u.output + u.cacheRead + u.cacheWrite + u.cacheWrite1h,
|
|
59
|
+
peakContext: session.peakContext || 0,
|
|
60
|
+
requests: session.requests || 0,
|
|
59
61
|
},
|
|
60
62
|
cost: session.reportedCost ?? estimateCost(session.usageByModel, pricing),
|
|
61
63
|
costReported: session.reportedCost != null,
|
package/src/template.html
CHANGED
|
@@ -3,136 +3,166 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
6
7
|
<title>__TITLE__</title>
|
|
7
8
|
<style>
|
|
8
9
|
:root {
|
|
9
|
-
--bg: #
|
|
10
|
-
--accent: #
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
|
|
14
|
-
--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
|
|
10
|
+
--bg: #fbfaf7; --ink: #1b1b19; --muted: #6c6a63; --faint: #a3a198; --rule: #e6e4dd; --soft: #f2f1ec;
|
|
11
|
+
--accent: #2a50d8; --add: #1a7f37; --add-bg: #e9f6ec; --del: #c4321f; --del-bg: #fcebe8; --warn: #c4321f;
|
|
12
|
+
--sans: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
|
|
13
|
+
--mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
|
|
15
14
|
}
|
|
16
15
|
@media (prefers-color-scheme: dark) {
|
|
17
16
|
:root:not([data-theme="light"]) {
|
|
18
|
-
--bg: #
|
|
19
|
-
--
|
|
20
|
-
--add-bg: #14301e; --add: #7fdc9b; --del-bg: #3a1916; --del: #ff9a8c; --code-bg: #262522; --think: #8f8c84;
|
|
21
|
-
--shadow: none;
|
|
17
|
+
--bg: #111110; --ink: #ecebe5; --muted: #908e86; --faint: #5d5c56; --rule: #262522; --soft: #1a1a18;
|
|
18
|
+
--accent: #86a8ff; --add: #56d364; --add-bg: #12261a; --del: #ff7b72; --del-bg: #2d1514; --warn: #ff7b72;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
:root[data-theme="dark"] {
|
|
25
|
-
--bg: #
|
|
26
|
-
--
|
|
27
|
-
--add-bg: #14301e; --add: #7fdc9b; --del-bg: #3a1916; --del: #ff9a8c; --code-bg: #262522; --think: #8f8c84;
|
|
28
|
-
--shadow: none;
|
|
22
|
+
--bg: #111110; --ink: #ecebe5; --muted: #908e86; --faint: #5d5c56; --rule: #262522; --soft: #1a1a18;
|
|
23
|
+
--accent: #86a8ff; --add: #56d364; --add-bg: #12261a; --del: #ff7b72; --del-bg: #2d1514; --warn: #ff7b72;
|
|
29
24
|
}
|
|
30
25
|
* { box-sizing: border-box; }
|
|
31
|
-
html, body { margin: 0; background: var(--bg); color: var(--ink);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
html, body { margin: 0; background: var(--bg); color: var(--ink); }
|
|
27
|
+
body { font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
|
|
28
|
+
a { color: inherit; text-decoration-color: var(--faint); text-underline-offset: 3px; }
|
|
29
|
+
a:hover { text-decoration-color: currentColor; }
|
|
30
|
+
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
|
|
31
|
+
code, pre, .mono { font-family: var(--mono); }
|
|
32
|
+
.wrap { max-width: 1120px; margin: 0 auto; padding: 48px 24px 140px; }
|
|
35
33
|
|
|
36
|
-
/* ----------
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
34
|
+
/* ---------- header ---------- */
|
|
35
|
+
.meta { font: 12px/1.4 var(--mono); color: var(--muted); letter-spacing: .02em; display: flex; flex-wrap: wrap; gap: 6px 14px; }
|
|
36
|
+
.meta b { color: var(--ink); font-weight: 600; }
|
|
37
|
+
h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.12; letter-spacing: -.025em; font-weight: 650; margin: 14px 0 32px; max-width: 28ch; overflow-wrap: anywhere; }
|
|
38
|
+
.figures { display: flex; flex-wrap: wrap; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
|
|
39
|
+
.fig { padding: 14px 28px 14px 0; margin-right: 28px; border-right: 1px solid var(--rule); min-width: 92px; }
|
|
40
|
+
.fig:last-child { border-right: 0; margin-right: 0; }
|
|
41
|
+
.fig .n { font: 500 22px/1.2 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
42
|
+
.fig .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
|
43
|
+
.fig .add { color: var(--add); } .fig .del { color: var(--del); }
|
|
46
44
|
|
|
47
45
|
/* ---------- layout ---------- */
|
|
48
|
-
.
|
|
49
|
-
@media (max-width:
|
|
50
|
-
.side { position: sticky; top:
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
.
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
46
|
+
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 56px; margin-top: 40px; align-items: start; }
|
|
47
|
+
@media (max-width: 920px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 40px; } .side { order: 2; } }
|
|
48
|
+
.side { position: sticky; top: 24px; font-size: 13px; }
|
|
49
|
+
@media (max-width: 920px) { .side { position: static; } }
|
|
50
|
+
.side section { padding: 14px 0 18px; border-top: 1px solid var(--rule); }
|
|
51
|
+
.side section:first-child { border-top-color: var(--ink); }
|
|
52
|
+
.side h2 { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
|
|
53
|
+
.rows { list-style: none; margin: 0; padding: 0; }
|
|
54
|
+
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
|
|
55
|
+
.rows .k { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
56
|
+
.rows .v { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
57
|
+
.rows .file { font-family: var(--mono); font-size: 12px; color: var(--ink); }
|
|
58
|
+
.rows .file i { color: var(--faint); font-style: normal; }
|
|
59
|
+
.rows .strong .k, .rows .strong .v { color: var(--ink); font-weight: 600; }
|
|
60
|
+
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 10px 0 0; }
|
|
61
|
+
.bar { display: inline-block; height: 2px; background: var(--ink); vertical-align: middle; margin-right: 8px; opacity: .55; }
|
|
64
62
|
|
|
65
|
-
/* ----------
|
|
66
|
-
.
|
|
67
|
-
.ev {
|
|
68
|
-
|
|
69
|
-
.ev.
|
|
70
|
-
.ev.
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
.ev.
|
|
74
|
-
|
|
75
|
-
.ev.
|
|
76
|
-
|
|
77
|
-
.
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
-
.
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
.
|
|
85
|
-
.
|
|
86
|
-
|
|
87
|
-
.tool
|
|
88
|
-
.
|
|
89
|
-
.tool
|
|
90
|
-
.tool
|
|
91
|
-
.tool
|
|
92
|
-
.
|
|
93
|
-
.
|
|
63
|
+
/* ---------- transcript ---------- */
|
|
64
|
+
.log { min-width: 0; }
|
|
65
|
+
.ev { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 16px; padding: 10px 0; scroll-margin: 120px; }
|
|
66
|
+
.ev + .ev { border-top: 1px solid transparent; }
|
|
67
|
+
.ev.turn { border-top: 1px solid var(--rule); margin-top: 14px; padding-top: 22px; }
|
|
68
|
+
.ev.turn:first-child { border-top: 0; margin-top: 0; padding-top: 4px; }
|
|
69
|
+
.t { font: 11px/22px var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; text-align: right; }
|
|
70
|
+
.who { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 0 8px; }
|
|
71
|
+
.ev.new { animation: rise .28s ease-out; }
|
|
72
|
+
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
|
73
|
+
@media (prefers-reduced-motion: reduce) { .ev.new { animation: none; } }
|
|
74
|
+
|
|
75
|
+
.user .body { font-size: 17px; line-height: 1.5; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid var(--accent); padding-left: 14px; }
|
|
76
|
+
.user .who { color: var(--accent); }
|
|
77
|
+
.say .body { overflow-wrap: anywhere; max-width: 68ch; }
|
|
78
|
+
.say .body p { margin: 0 0 10px; } .say .body p:last-child { margin-bottom: 0; }
|
|
79
|
+
.say .body ul, .say .body ol { margin: 0 0 10px; padding-left: 20px; }
|
|
80
|
+
.say .body pre { background: var(--soft); padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; margin: 0 0 10px; border-left: 2px solid var(--rule); }
|
|
81
|
+
.say .body :not(pre) > code { font-size: .88em; background: var(--soft); padding: 1px 5px; }
|
|
82
|
+
.think .body { color: var(--muted); font-style: italic; font-size: 14px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
|
|
83
|
+
.think.open .body { display: block; }
|
|
84
|
+
|
|
85
|
+
.tool { padding: 3px 0; }
|
|
86
|
+
.tool .line { display: flex; align-items: baseline; gap: 10px; min-width: 0; cursor: pointer; font-size: 13.5px; padding: 3px 0; }
|
|
87
|
+
.tool .line:hover .nm { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
|
|
88
|
+
.tool .g { font: 12px var(--mono); width: 12px; flex: none; color: var(--add); }
|
|
89
|
+
.tool.err .g { color: var(--warn); }
|
|
90
|
+
.tool .nm { font: 500 13px var(--mono); flex: none; }
|
|
91
|
+
.tool .sum { color: var(--muted); font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
|
|
92
|
+
.tool .dl { font: 12px var(--mono); flex: none; }
|
|
93
|
+
.dl .a { color: var(--add); } .dl .d { color: var(--del); }
|
|
94
|
+
.tool .detail { display: none; margin: 6px 0 8px 22px; border-left: 1px solid var(--rule); padding-left: 14px; }
|
|
95
|
+
.tool.open .detail { display: block; }
|
|
96
|
+
.detail .lbl { font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 10px 0 4px; }
|
|
97
|
+
.detail .lbl:first-child { margin-top: 0; }
|
|
98
|
+
.detail .path { font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; margin-bottom: 6px; }
|
|
99
|
+
.detail pre { margin: 0; background: var(--soft); padding: 10px 12px; font-size: 12px; line-height: 1.55; overflow: auto; max-height: 340px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
100
|
+
.diff { font: 12px/1.55 var(--mono); overflow: auto; max-height: 420px; background: var(--soft); }
|
|
101
|
+
.diff div { padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
94
102
|
.diff .a { background: var(--add-bg); color: var(--add); }
|
|
95
103
|
.diff .d { background: var(--del-bg); color: var(--del); }
|
|
96
104
|
.diff .f { color: var(--muted); padding-top: 6px; }
|
|
97
|
-
|
|
105
|
+
@media (max-width: 600px) {
|
|
106
|
+
.wrap { padding: 28px 16px 140px; }
|
|
107
|
+
.ev { grid-template-columns: minmax(0, 1fr); }
|
|
108
|
+
.t { text-align: left; line-height: 1; margin-bottom: 2px; }
|
|
109
|
+
.ev:not(.turn) .t { display: none; }
|
|
110
|
+
.fig { padding-right: 18px; margin-right: 18px; min-width: 0; }
|
|
111
|
+
.fig .n { font-size: 18px; }
|
|
112
|
+
}
|
|
98
113
|
|
|
99
114
|
/* ---------- player ---------- */
|
|
100
|
-
.player { position: fixed;
|
|
101
|
-
.
|
|
102
|
-
.
|
|
103
|
-
.
|
|
104
|
-
.
|
|
105
|
-
.track
|
|
106
|
-
.track .
|
|
107
|
-
.track .
|
|
108
|
-
.
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
.player { position: fixed; inset: auto 0 0 0; background: var(--bg); border-top: 1px solid var(--rule); z-index: 10; }
|
|
116
|
+
.pin { max-width: 1120px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 18px; }
|
|
117
|
+
.play { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--ink); flex: none; }
|
|
118
|
+
.play:hover { background: var(--ink); color: var(--bg); }
|
|
119
|
+
.play svg { width: 14px; height: 14px; fill: currentColor; }
|
|
120
|
+
.track { position: relative; flex: 1; height: 26px; cursor: pointer; min-width: 80px; touch-action: none; }
|
|
121
|
+
.track .rail { position: absolute; left: 0; right: 0; top: 12px; height: 2px; background: var(--rule); }
|
|
122
|
+
.track .fill { position: absolute; left: 0; top: 12px; height: 2px; background: var(--ink); }
|
|
123
|
+
.track .head { position: absolute; top: 8px; width: 2px; height: 10px; background: var(--ink); transform: translateX(-1px); }
|
|
124
|
+
.track .mk { position: absolute; top: 18px; width: 1px; height: 5px; background: var(--faint); }
|
|
125
|
+
.mk.u { background: var(--accent); height: 7px; top: 17px; width: 2px; }
|
|
126
|
+
.mk.x { background: var(--warn); }
|
|
127
|
+
.mk.e { background: var(--add); }
|
|
128
|
+
.count { font: 12px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 64px; text-align: right; }
|
|
129
|
+
.speeds { display: flex; font: 12px var(--mono); border: 1px solid var(--rule); }
|
|
130
|
+
.speeds button { padding: 5px 8px; color: var(--muted); border-left: 1px solid var(--rule); }
|
|
131
|
+
.speeds button:first-child { border-left: 0; }
|
|
132
|
+
.speeds button[aria-pressed="true"] { color: var(--bg); background: var(--ink); }
|
|
133
|
+
.speeds button:not([aria-pressed="true"]):hover { color: var(--ink); }
|
|
134
|
+
.txt { font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
|
|
135
|
+
.txt:hover { color: var(--ink); }
|
|
136
|
+
.icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; display: block; }
|
|
137
|
+
.icon { color: var(--muted); } .icon:hover { color: var(--ink); }
|
|
138
|
+
@media (max-width: 700px) {
|
|
139
|
+
.pin { padding: 10px 16px; gap: 12px; }
|
|
140
|
+
.speeds button:not([aria-pressed="true"]) { display: none; }
|
|
141
|
+
.speeds button { border-left: 0; }
|
|
142
|
+
.count, .hide-sm { display: none; }
|
|
143
|
+
}
|
|
144
|
+
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
112
145
|
|
|
113
|
-
footer {
|
|
114
|
-
.redacted { font-size: 12px; color: var(--muted); margin-top: 12px; }
|
|
146
|
+
footer { margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--rule); font: 12px/1.6 var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
|
|
115
147
|
</style>
|
|
116
148
|
</head>
|
|
117
149
|
<body>
|
|
118
150
|
<div class="wrap">
|
|
119
|
-
<
|
|
120
|
-
<div class="
|
|
121
|
-
<main class="
|
|
151
|
+
<header id="head"></header>
|
|
152
|
+
<div class="cols">
|
|
153
|
+
<main class="log" id="log" aria-live="polite"></main>
|
|
122
154
|
<aside class="side" id="side"></aside>
|
|
123
155
|
</div>
|
|
124
156
|
<footer id="foot"></footer>
|
|
125
157
|
</div>
|
|
126
158
|
<div class="player">
|
|
127
|
-
<div class="
|
|
128
|
-
<button class="
|
|
129
|
-
<div class="track" id="track"
|
|
130
|
-
<span class="
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<button class="btn ghost hide-sm" id="all" title="Show everything (end)">Show all</button>
|
|
135
|
-
<button class="btn ghost hide-sm" id="theme" title="Toggle theme" aria-label="Toggle theme">◐</button>
|
|
159
|
+
<div class="pin">
|
|
160
|
+
<button class="play" id="play"></button>
|
|
161
|
+
<div class="track" id="track"><div class="rail"></div><div class="fill" id="fill"></div><div class="head" id="phead"></div></div>
|
|
162
|
+
<span class="count" id="count"></span>
|
|
163
|
+
<div class="speeds" id="speeds" role="group"></div>
|
|
164
|
+
<button class="txt hide-sm" id="all"></button>
|
|
165
|
+
<button class="icon" id="theme"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.5v2.2M12 19.3v2.2M4.6 4.6l1.6 1.6M17.8 17.8l1.6 1.6M2.5 12h2.2M19.3 12h2.2M4.6 19.4l1.6-1.6M17.8 6.2l1.6-1.6"/></svg></button>
|
|
136
166
|
</div>
|
|
137
167
|
</div>
|
|
138
168
|
<script id="data" type="application/json">__DATA__</script>
|
|
@@ -141,69 +171,104 @@ footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4
|
|
|
141
171
|
const D = JSON.parse(document.getElementById('data').textContent);
|
|
142
172
|
const S = D.stats;
|
|
143
173
|
const $ = (id) => document.getElementById(id);
|
|
174
|
+
|
|
175
|
+
/* ---------- language ---------- */
|
|
176
|
+
const I18N = {
|
|
177
|
+
en: { you: 'You', thinking: 'Thinking', activeTime: 'active', prompts: ['prompt', 'prompts'], toolCalls: 'tool calls', filesChanged: 'files changed', lines: 'lines', peak: 'largest prompt', cost: 'cost', estCost: 'est. API cost', files: 'Files', tools: 'Tools', tokens: 'Tokens', output: 'Output', newInput: 'New input', cacheRead: 'Read from cache', cacheWrite: 'Written to cache', requests: 'Requests', totalProcessed: 'Total processed', failed: 'Failed tool calls', tokenNote: 'Every request re-sends the whole conversation, so the total counts the same context again and again. {pct} of it came from cache. The largest single prompt was {peak}.', costNote: 'Estimate at public API list prices.', input: 'Input', error: 'Error', result: 'Output', showAll: 'Show all', play: 'Play', pause: 'Pause', replay: 'Replay from start', theme: 'Switch theme', speed: 'Speed', more: '+{n} more', madeWith: 'Made with', redacted: 'Removed before sharing: {list}', untitled: 'Untitled session', seek: 'Timeline', of: 'of', branch: 'branch' },
|
|
178
|
+
tr: { you: 'Sen', thinking: 'Düşünüyor', activeTime: 'aktif süre', prompts: ['mesaj', 'mesaj'], toolCalls: 'araç çağrısı', filesChanged: 'dosya değişti', lines: 'satır', peak: 'en büyük istem', cost: 'maliyet', estCost: 'tahmini API maliyeti', files: 'Dosyalar', tools: 'Araçlar', tokens: 'Token', output: 'Çıktı', newInput: 'Yeni girdi', cacheRead: 'Önbellekten okunan', cacheWrite: 'Önbelleğe yazılan', requests: 'API isteği', totalProcessed: 'Toplam işlenen', failed: 'Başarısız araç çağrısı', tokenNote: 'Her istekte konuşmanın tamamı yeniden gönderilir, bu yüzden toplam aynı içeriği defalarca sayar. Bunun {pct} kadarı önbellekten geldi. Tek seferdeki en büyük istem {peak} idi.', costNote: 'Herkese açık API liste fiyatlarına göre tahmin.', input: 'Girdi', error: 'Hata', result: 'Çıktı', showAll: 'Tümünü göster', play: 'Oynat', pause: 'Duraklat', replay: 'Baştan oynat', theme: 'Temayı değiştir', speed: 'Hız', more: '+{n} tane daha', madeWith: 'Şununla yapıldı:', redacted: 'Paylaşmadan önce kaldırıldı: {list}', untitled: 'Başlıksız oturum', seek: 'Zaman çizelgesi', of: '/', branch: 'dal' },
|
|
179
|
+
es: { you: 'Tú', thinking: 'Pensando', activeTime: 'activo', prompts: ['instrucción', 'instrucciones'], toolCalls: 'llamadas a herramientas', filesChanged: 'archivos cambiados', lines: 'líneas', peak: 'mayor prompt', cost: 'coste', estCost: 'coste API estimado', files: 'Archivos', tools: 'Herramientas', tokens: 'Tokens', output: 'Salida', newInput: 'Entrada nueva', cacheRead: 'Leído de caché', cacheWrite: 'Escrito en caché', requests: 'Peticiones', totalProcessed: 'Total procesado', failed: 'Llamadas fallidas', tokenNote: 'Cada petición reenvía toda la conversación, así que el total cuenta el mismo contexto una y otra vez. El {pct} vino de la caché. El prompt más grande fue de {peak}.', costNote: 'Estimación con precios de lista de la API.', input: 'Entrada', error: 'Error', result: 'Salida', showAll: 'Ver todo', play: 'Reproducir', pause: 'Pausa', replay: 'Reproducir desde el inicio', theme: 'Cambiar tema', speed: 'Velocidad', more: '+{n} más', madeWith: 'Hecho con', redacted: 'Eliminado antes de compartir: {list}', untitled: 'Sesión sin título', seek: 'Línea de tiempo', of: 'de', branch: 'rama' },
|
|
180
|
+
de: { you: 'Du', thinking: 'Denkt nach', activeTime: 'aktiv', prompts: ['Prompt', 'Prompts'], toolCalls: 'Tool-Aufrufe', filesChanged: 'Dateien geändert', lines: 'Zeilen', peak: 'größter Prompt', cost: 'Kosten', estCost: 'geschätzte API-Kosten', files: 'Dateien', tools: 'Tools', tokens: 'Tokens', output: 'Ausgabe', newInput: 'Neue Eingabe', cacheRead: 'Aus Cache gelesen', cacheWrite: 'In Cache geschrieben', requests: 'Anfragen', totalProcessed: 'Insgesamt verarbeitet', failed: 'Fehlgeschlagene Aufrufe', tokenNote: 'Jede Anfrage sendet das ganze Gespräch erneut, daher zählt die Summe denselben Kontext immer wieder. {pct} davon kamen aus dem Cache. Der größte einzelne Prompt hatte {peak}.', costNote: 'Schätzung nach öffentlichen API-Listenpreisen.', input: 'Eingabe', error: 'Fehler', result: 'Ausgabe', showAll: 'Alles zeigen', play: 'Abspielen', pause: 'Pause', replay: 'Von vorn abspielen', theme: 'Design wechseln', speed: 'Tempo', more: '+{n} weitere', madeWith: 'Erstellt mit', redacted: 'Vor dem Teilen entfernt: {list}', untitled: 'Unbenannte Sitzung', seek: 'Zeitleiste', of: 'von', branch: 'Branch' },
|
|
181
|
+
fr: { you: 'Vous', thinking: 'Réflexion', activeTime: 'actif', prompts: ['prompt', 'prompts'], toolCalls: 'appels d’outils', filesChanged: 'fichiers modifiés', lines: 'lignes', peak: 'plus grand prompt', cost: 'coût', estCost: 'coût API estimé', files: 'Fichiers', tools: 'Outils', tokens: 'Tokens', output: 'Sortie', newInput: 'Nouvelle entrée', cacheRead: 'Lu depuis le cache', cacheWrite: 'Écrit en cache', requests: 'Requêtes', totalProcessed: 'Total traité', failed: 'Appels échoués', tokenNote: 'Chaque requête renvoie toute la conversation : le total compte donc le même contexte encore et encore. {pct} provenait du cache. Le plus grand prompt faisait {peak}.', costNote: 'Estimation aux prix publics de l’API.', input: 'Entrée', error: 'Erreur', result: 'Sortie', showAll: 'Tout afficher', play: 'Lire', pause: 'Pause', replay: 'Rejouer depuis le début', theme: 'Changer de thème', speed: 'Vitesse', more: '+{n} autres', madeWith: 'Fait avec', redacted: 'Retiré avant partage : {list}', untitled: 'Session sans titre', seek: 'Chronologie', of: 'sur', branch: 'branche' },
|
|
182
|
+
pt: { you: 'Você', thinking: 'Pensando', activeTime: 'ativo', prompts: ['prompt', 'prompts'], toolCalls: 'chamadas de ferramentas', filesChanged: 'arquivos alterados', lines: 'linhas', peak: 'maior prompt', cost: 'custo', estCost: 'custo de API estimado', files: 'Arquivos', tools: 'Ferramentas', tokens: 'Tokens', output: 'Saída', newInput: 'Entrada nova', cacheRead: 'Lido do cache', cacheWrite: 'Gravado no cache', requests: 'Requisições', totalProcessed: 'Total processado', failed: 'Chamadas com falha', tokenNote: 'Cada requisição reenvia a conversa inteira, então o total conta o mesmo contexto várias vezes. {pct} veio do cache. O maior prompt teve {peak}.', costNote: 'Estimativa com preços públicos da API.', input: 'Entrada', error: 'Erro', result: 'Saída', showAll: 'Mostrar tudo', play: 'Reproduzir', pause: 'Pausar', replay: 'Reproduzir do início', theme: 'Mudar tema', speed: 'Velocidade', more: '+{n} mais', madeWith: 'Feito com', redacted: 'Removido antes de compartilhar: {list}', untitled: 'Sessão sem título', seek: 'Linha do tempo', of: 'de', branch: 'branch' },
|
|
183
|
+
it: { you: 'Tu', thinking: 'Ragionamento', activeTime: 'attivo', prompts: ['prompt', 'prompt'], toolCalls: 'chiamate a strumenti', filesChanged: 'file modificati', lines: 'righe', peak: 'prompt più grande', cost: 'costo', estCost: 'costo API stimato', files: 'File', tools: 'Strumenti', tokens: 'Token', output: 'Output', newInput: 'Input nuovo', cacheRead: 'Letto dalla cache', cacheWrite: 'Scritto in cache', requests: 'Richieste', totalProcessed: 'Totale elaborato', failed: 'Chiamate fallite', tokenNote: 'Ogni richiesta reinvia l’intera conversazione, quindi il totale conta lo stesso contesto più volte. Il {pct} proveniva dalla cache. Il prompt più grande era di {peak}.', costNote: 'Stima ai prezzi di listino dell’API.', input: 'Input', error: 'Errore', result: 'Output', showAll: 'Mostra tutto', play: 'Riproduci', pause: 'Pausa', replay: 'Riproduci dall’inizio', theme: 'Cambia tema', speed: 'Velocità', more: '+{n} altri', madeWith: 'Creato con', redacted: 'Rimosso prima della condivisione: {list}', untitled: 'Sessione senza titolo', seek: 'Timeline', of: 'di', branch: 'branch' },
|
|
184
|
+
ru: { you: 'Вы', thinking: 'Размышление', activeTime: 'активно', prompts: ['запрос', 'запросов'], toolCalls: 'вызовов инструментов', filesChanged: 'файлов изменено', lines: 'строк', peak: 'крупнейший промпт', cost: 'стоимость', estCost: 'оценка стоимости API', files: 'Файлы', tools: 'Инструменты', tokens: 'Токены', output: 'Вывод', newInput: 'Новый ввод', cacheRead: 'Из кэша', cacheWrite: 'Записано в кэш', requests: 'Запросы к API', totalProcessed: 'Всего обработано', failed: 'Неудачные вызовы', tokenNote: 'Каждый запрос заново отправляет весь диалог, поэтому сумма много раз считает один и тот же контекст. {pct} пришло из кэша. Самый большой промпт — {peak}.', costNote: 'Оценка по публичным ценам API.', input: 'Ввод', error: 'Ошибка', result: 'Вывод', showAll: 'Показать всё', play: 'Воспроизвести', pause: 'Пауза', replay: 'С начала', theme: 'Сменить тему', speed: 'Скорость', more: 'ещё {n}', madeWith: 'Сделано с помощью', redacted: 'Удалено перед публикацией: {list}', untitled: 'Сессия без названия', seek: 'Шкала времени', of: 'из', branch: 'ветка' },
|
|
185
|
+
ja: { you: 'あなた', thinking: '思考中', activeTime: '作業時間', prompts: ['プロンプト', 'プロンプト'], toolCalls: 'ツール呼び出し', filesChanged: '変更ファイル', lines: '行', peak: '最大プロンプト', cost: 'コスト', estCost: 'API 推定コスト', files: 'ファイル', tools: 'ツール', tokens: 'トークン', output: '出力', newInput: '新規入力', cacheRead: 'キャッシュ読込', cacheWrite: 'キャッシュ書込', requests: 'リクエスト数', totalProcessed: '処理合計', failed: '失敗した呼び出し', tokenNote: 'リクエストごとに会話全体が再送されるため、合計には同じ文脈が何度も含まれます。そのうち {pct} はキャッシュからでした。1 回あたりの最大プロンプトは {peak} です。', costNote: '公開 API 価格による推定です。', input: '入力', error: 'エラー', result: '出力', showAll: 'すべて表示', play: '再生', pause: '一時停止', replay: '最初から再生', theme: 'テーマ切替', speed: '速度', more: 'ほか {n} 件', madeWith: '作成:', redacted: '共有前に削除:{list}', untitled: '無題のセッション', seek: 'タイムライン', of: '/', branch: 'ブランチ' },
|
|
186
|
+
zh: { you: '你', thinking: '思考中', activeTime: '活跃时长', prompts: ['条提示', '条提示'], toolCalls: '次工具调用', filesChanged: '个文件改动', lines: '行', peak: '最大提示', cost: '费用', estCost: '估算 API 费用', files: '文件', tools: '工具', tokens: 'Token', output: '输出', newInput: '新输入', cacheRead: '缓存读取', cacheWrite: '缓存写入', requests: '请求次数', totalProcessed: '累计处理', failed: '失败的调用', tokenNote: '每次请求都会重新发送整个对话,所以累计值会反复计算同样的上下文。其中 {pct} 来自缓存。单次最大提示为 {peak}。', costNote: '按公开 API 价格估算。', input: '输入', error: '错误', result: '输出', showAll: '显示全部', play: '播放', pause: '暂停', replay: '从头播放', theme: '切换主题', speed: '速度', more: '还有 {n} 个', madeWith: '制作工具:', redacted: '分享前已移除:{list}', untitled: '未命名会话', seek: '时间轴', of: '/', branch: '分支' },
|
|
187
|
+
ko: { you: '나', thinking: '생각 중', activeTime: '작업 시간', prompts: ['프롬프트', '프롬프트'], toolCalls: '도구 호출', filesChanged: '변경된 파일', lines: '줄', peak: '가장 큰 프롬프트', cost: '비용', estCost: '예상 API 비용', files: '파일', tools: '도구', tokens: '토큰', output: '출력', newInput: '새 입력', cacheRead: '캐시 읽기', cacheWrite: '캐시 쓰기', requests: '요청 수', totalProcessed: '총 처리량', failed: '실패한 호출', tokenNote: '요청할 때마다 대화 전체를 다시 보내므로 합계에는 같은 맥락이 여러 번 포함됩니다. 그중 {pct}는 캐시에서 왔습니다. 한 번에 가장 큰 프롬프트는 {peak}였습니다.', costNote: '공개 API 가격 기준 추정치입니다.', input: '입력', error: '오류', result: '출력', showAll: '모두 보기', play: '재생', pause: '일시정지', replay: '처음부터 재생', theme: '테마 전환', speed: '속도', more: '+{n}개 더', madeWith: '제작 도구:', redacted: '공유 전 제거됨: {list}', untitled: '제목 없는 세션', seek: '타임라인', of: '/', branch: '브랜치' },
|
|
188
|
+
};
|
|
189
|
+
const qs = new URLSearchParams(location.search);
|
|
190
|
+
const wanted = [qs.get('lang'), ...(navigator.languages || [navigator.language || 'en'])].filter(Boolean);
|
|
191
|
+
const lang = wanted.map((l) => l.toLowerCase().split('-')[0]).find((l) => I18N[l]) || 'en';
|
|
192
|
+
const L = I18N[lang];
|
|
193
|
+
document.documentElement.lang = lang;
|
|
194
|
+
const tr = (k, vars = {}) => String(L[k] ?? I18N.en[k]).replace(/\{(\w+)\}/g, (_, v) => vars[v] ?? '');
|
|
195
|
+
const plural = (k, n) => { const f = L[k] || I18N.en[k]; return Array.isArray(f) ? f[n === 1 ? 0 : 1] : f; };
|
|
196
|
+
const nf = new Intl.NumberFormat(lang);
|
|
197
|
+
const cf = (() => { try { return new Intl.NumberFormat(lang, { notation: 'compact', maximumFractionDigits: 1 }); } catch { return null; } })();
|
|
198
|
+
|
|
199
|
+
/* ---------- helpers ---------- */
|
|
144
200
|
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
145
|
-
const num = (n) => n >= 1e6
|
|
146
|
-
const dur = (ms) => { const m = Math.round(ms / 60000);
|
|
201
|
+
const num = (n) => (n >= 1e6 && cf ? cf.format(n) : nf.format(n));
|
|
202
|
+
const dur = (ms) => { const m = Math.round(ms / 60000); if (m < 1) return '<1 min'; if (m < 60) return m + ' min'; return Math.floor(m / 60) + ' h ' + (m % 60) + ' min'; };
|
|
203
|
+
const clock = (ms) => { const s = Math.max(0, Math.round(ms / 1000)); const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), x = s % 60; return (h ? h + ':' + String(m).padStart(2, '0') : String(m).padStart(2, '0')) + ':' + String(x).padStart(2, '0'); };
|
|
147
204
|
const base = (p) => String(p || '').split(/[\\/]/).pop();
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
205
|
+
const shortPath = (p) => { const parts = String(p || '').split(/[\\/]/).filter(Boolean); const name = parts.pop() || ''; const dir = parts.slice(-2).join('/'); return (dir ? `<i>${parts.length > 2 ? '…/' : ''}${esc(dir)}/</i>` : '') + esc(name); };
|
|
206
|
+
const money = (c) => { try { return new Intl.NumberFormat(lang, { style: 'currency', currency: 'USD', maximumFractionDigits: c < 10 ? 2 : 0 }).format(c); } catch { return '$' + c.toFixed(2); } };
|
|
207
|
+
const ICON = {
|
|
208
|
+
play: '<svg viewBox="0 0 16 16"><path d="M4 2.5v11l9-5.5z"/></svg>',
|
|
209
|
+
pause: '<svg viewBox="0 0 16 16"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',
|
|
210
|
+
again: '<svg viewBox="0 0 16 16"><path d="M8 2.5a5.5 5.5 0 1 0 5.4 6.5h-1.6A4 4 0 1 1 8 4v2.2L11.2 3.3 8 .5z"/></svg>',
|
|
154
211
|
};
|
|
155
212
|
|
|
156
|
-
/* ----------
|
|
157
|
-
const date = S.start ? new Date(S.start).toLocaleDateString(
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
];
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
</div
|
|
173
|
-
<h1>${esc(D.title)}</h1>
|
|
174
|
-
<div class="tiles">${tiles.map(([b, s]) => `<div class="tile"><b>${b}</b><span>${s}</span></div>`).join('')}</div>`;
|
|
213
|
+
/* ---------- header ---------- */
|
|
214
|
+
const date = S.start ? new Date(S.start).toLocaleDateString(lang, { year: 'numeric', month: 'short', day: 'numeric' }) : '';
|
|
215
|
+
const meta = [`<b>${esc(D.agent)}</b>`];
|
|
216
|
+
if (D.models.length) meta.push(esc(D.models.join(', ')));
|
|
217
|
+
if (date) meta.push(esc(date));
|
|
218
|
+
if (D.branch && D.branch !== 'HEAD') meta.push(`${esc(tr('branch'))} ${esc(D.branch)}`);
|
|
219
|
+
const figs = [];
|
|
220
|
+
if (!S.timesSynthetic) figs.push([dur(S.activeMs), tr('activeTime')]);
|
|
221
|
+
figs.push([nf.format(S.prompts), plural('prompts', S.prompts)]);
|
|
222
|
+
figs.push([nf.format(S.toolCalls), tr('toolCalls')]);
|
|
223
|
+
figs.push([nf.format(S.files.length), tr('filesChanged')]);
|
|
224
|
+
if (S.linesAdded || S.linesRemoved) figs.push([`<span class="add">+${num(S.linesAdded)}</span> <span class="del">−${num(S.linesRemoved)}</span>`, tr('lines')]);
|
|
225
|
+
if (S.tokens.peakContext) figs.push([num(S.tokens.peakContext), tr('peak')]);
|
|
226
|
+
if (S.cost != null) figs.push([money(S.cost), S.costReported ? tr('cost') : tr('estCost')]);
|
|
227
|
+
$('head').innerHTML = `<div class="meta">${meta.join('<span>·</span>')}</div>
|
|
228
|
+
<h1>${esc(D.title || tr('untitled'))}</h1>
|
|
229
|
+
<div class="figures">${figs.map(([n, l]) => `<div class="fig"><div class="n">${n}</div><div class="l">${esc(l)}</div></div>`).join('')}</div>`;
|
|
175
230
|
|
|
176
231
|
/* ---------- sidebar ---------- */
|
|
232
|
+
const T = S.tokens;
|
|
177
233
|
const maxTool = S.byTool.length ? S.byTool[0][1] : 1;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
`<li><span class="
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
</
|
|
192
|
-
|
|
193
|
-
|
|
234
|
+
const totalIn = T.input + T.cacheRead + T.cacheWrite;
|
|
235
|
+
const pct = totalIn ? Math.round((T.cacheRead / totalIn) * 100) + '%' : '0%';
|
|
236
|
+
let side = '';
|
|
237
|
+
if (S.files.length) side += `<section><h2>${esc(tr('files'))}</h2><ul class="rows">${S.files.slice(0, 20).map((f) =>
|
|
238
|
+
`<li title="${esc(f.file)}"><span class="k file">${shortPath(f.file)}</span><span class="v"><span style="color:var(--add)">+${f.added}</span> <span style="color:var(--del)">−${f.removed}</span></span></li>`).join('')}
|
|
239
|
+
${S.files.length > 20 ? `<li><span class="k">${esc(tr('more', { n: S.files.length - 20 }))}</span></li>` : ''}</ul></section>`;
|
|
240
|
+
if (S.byTool.length) side += `<section><h2>${esc(tr('tools'))}</h2><ul class="rows">${S.byTool.slice(0, 10).map(([n, c]) =>
|
|
241
|
+
`<li title="${esc(n)}"><span class="k">${esc(n.split(' · ').pop())}</span><span class="v"><span class="bar" style="width:${Math.max(3, (c / maxTool) * 56)}px"></span>${c}</span></li>`).join('')}</ul></section>`;
|
|
242
|
+
if (T.total) side += `<section><h2>${esc(tr('tokens'))}</h2><ul class="rows">
|
|
243
|
+
<li><span class="k">${esc(tr('output'))}</span><span class="v">${nf.format(T.output)}</span></li>
|
|
244
|
+
<li><span class="k">${esc(tr('newInput'))}</span><span class="v">${nf.format(T.input)}</span></li>
|
|
245
|
+
${T.cacheRead ? `<li><span class="k">${esc(tr('cacheRead'))}</span><span class="v">${nf.format(T.cacheRead)}</span></li>` : ''}
|
|
246
|
+
${T.cacheWrite ? `<li><span class="k">${esc(tr('cacheWrite'))}</span><span class="v">${nf.format(T.cacheWrite)}</span></li>` : ''}
|
|
247
|
+
${T.requests ? `<li><span class="k">${esc(tr('requests'))}</span><span class="v">${nf.format(T.requests)}</span></li>` : ''}
|
|
248
|
+
<li class="strong"><span class="k">${esc(tr('totalProcessed'))}</span><span class="v">${nf.format(T.total)}</span></li>
|
|
249
|
+
${S.errors ? `<li><span class="k">${esc(tr('failed'))}</span><span class="v" style="color:var(--warn)">${S.errors}</span></li>` : ''}
|
|
250
|
+
</ul>${T.requests > 1 && T.peakContext ? `<p class="note">${esc(tr('tokenNote', { pct, peak: num(T.peakContext) }))}</p>` : ''}
|
|
251
|
+
${S.cost != null && !S.costReported ? `<p class="note">${esc(tr('costNote'))}</p>` : ''}</section>`;
|
|
252
|
+
$('side').innerHTML = side;
|
|
194
253
|
|
|
195
254
|
const red = D.redactions ? Object.entries(D.redactions) : [];
|
|
196
|
-
const
|
|
197
|
-
$('foot').innerHTML =
|
|
198
|
-
${red.length ? `<
|
|
255
|
+
const g = D.generator;
|
|
256
|
+
$('foot').innerHTML = `<span>${esc(tr('madeWith'))} ${g.url ? `<a href="${esc(g.url)}">agentreplay</a>` : 'agentreplay'} ${esc(g.version)}</span>
|
|
257
|
+
${red.length ? `<span>${esc(tr('redacted', { list: red.map(([k, v]) => `${v} × ${k}`).join(', ') }))}</span>` : ''}`;
|
|
199
258
|
|
|
200
|
-
/* ----------
|
|
259
|
+
/* ---------- markdown (small, safe) ---------- */
|
|
201
260
|
function md(src) {
|
|
202
|
-
const parts = String(src).split(/```
|
|
261
|
+
const parts = String(src).split(/```[\w+-]*\n?([\s\S]*?)```/g);
|
|
203
262
|
let html = '';
|
|
204
|
-
for (let i = 0; i < parts.length; i
|
|
205
|
-
|
|
206
|
-
|
|
263
|
+
for (let i = 0; i < parts.length; i++) {
|
|
264
|
+
if (i % 2) { html += `<pre><code>${esc(parts[i].replace(/\n$/, ''))}</code></pre>`; continue; }
|
|
265
|
+
for (const block of parts[i].split(/\n{2,}/)) {
|
|
266
|
+
if (!block.trim()) continue;
|
|
267
|
+
const lines = block.split('\n');
|
|
268
|
+
if (lines.every((l) => /^\s*[-*•] /.test(l))) html += '<ul>' + lines.map((l) => `<li>${inline(l.replace(/^\s*[-*•] /, ''))}</li>`).join('') + '</ul>';
|
|
269
|
+
else if (lines.every((l) => /^\s*\d+[.)] /.test(l))) html += '<ol>' + lines.map((l) => `<li>${inline(l.replace(/^\s*\d+[.)] /, ''))}</li>`).join('') + '</ol>';
|
|
270
|
+
else html += '<p>' + inline(block).replace(/\n/g, '<br>') + '</p>';
|
|
271
|
+
}
|
|
207
272
|
}
|
|
208
273
|
return html;
|
|
209
274
|
}
|
|
@@ -226,118 +291,143 @@ footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4
|
|
|
226
291
|
|
|
227
292
|
/* ---------- events ---------- */
|
|
228
293
|
const E = D.events;
|
|
294
|
+
const t0 = E.length && E[0].t ? E[0].t : 0;
|
|
229
295
|
function render(e, i) {
|
|
230
296
|
const el = document.createElement('div');
|
|
231
297
|
el.id = 'e' + i;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
298
|
+
const prev = E[i - 1];
|
|
299
|
+
const newTurn = e.kind === 'user' || (prev && prev.kind === 'user');
|
|
300
|
+
const time = !S.timesSynthetic && e.t && t0 ? clock(e.t - t0) : '';
|
|
301
|
+
const gutter = `<div class="t">${time}</div>`;
|
|
302
|
+
if (e.kind === 'user') {
|
|
303
|
+
el.className = 'ev user turn';
|
|
304
|
+
el.innerHTML = `${gutter}<div><div class="who">${esc(tr('you'))}</div><div class="body"></div></div>`;
|
|
305
|
+
el.querySelector('.body').textContent = e.text;
|
|
306
|
+
} else if (e.kind === 'assistant') {
|
|
307
|
+
el.className = 'ev say' + (newTurn ? ' turn' : '');
|
|
308
|
+
el.innerHTML = `${gutter}<div>${newTurn ? `<div class="who">${esc(D.agent)}</div>` : ''}<div class="body">${md(e.text)}</div></div>`;
|
|
309
|
+
} else if (e.kind === 'thinking') {
|
|
310
|
+
el.className = 'ev think' + (newTurn ? ' turn' : '');
|
|
311
|
+
el.innerHTML = `${gutter}<div>${newTurn ? `<div class="who">${esc(D.agent)}</div>` : ''}<div class="body" title="${esc(tr('thinking'))}"></div></div>`;
|
|
312
|
+
el.querySelector('.body').textContent = e.text;
|
|
313
|
+
el.querySelector('.body').onclick = () => el.classList.toggle('open');
|
|
314
|
+
} else {
|
|
315
|
+
el.className = 'ev tool' + (e.isError ? ' err' : '') + (newTurn ? ' turn' : '');
|
|
316
|
+
const lines = e.lines ? `<span class="dl"><span class="a">+${e.lines.added}</span> <span class="d">−${e.lines.removed}</span></span>` : '';
|
|
238
317
|
const sum = e.diff ? base(e.file) + (e.files && e.files.length > 1 ? ` +${e.files.length - 1}` : '') : e.summary;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
318
|
+
const name = String(e.name).split(' · ').pop();
|
|
319
|
+
el.innerHTML = `${gutter}<div>${newTurn ? `<div class="who">${esc(D.agent)}</div>` : ''}
|
|
320
|
+
<div class="line" role="button" tabindex="0" aria-expanded="false"><span class="g">${e.isError ? '✕' : '✓'}</span><span class="nm" title="${esc(e.name)}">${esc(name)}</span><span class="sum" title="${esc(e.summary)}">${esc(sum)}</span>${lines}</div>
|
|
321
|
+
<div class="detail">${e.diff ? (e.file ? `<div class="path">${esc(e.file)}</div>` : '') + diffHtml(e.diff) : ''}
|
|
322
|
+
${e.input ? `<div class="lbl">${esc(tr('input'))}</div><pre>${esc(e.input)}</pre>` : ''}
|
|
323
|
+
${e.output ? `<div class="lbl">${esc(e.isError ? tr('error') : tr('result'))}</div><pre>${esc(e.output)}</pre>` : ''}</div></div>`;
|
|
324
|
+
const line = el.querySelector('.line');
|
|
325
|
+
const toggle = () => { el.classList.toggle('open'); line.setAttribute('aria-expanded', el.classList.contains('open')); };
|
|
326
|
+
line.onclick = toggle;
|
|
327
|
+
line.onkeydown = (ev) => { if (ev.key === 'Enter' || ev.key === ' ') { ev.preventDefault(); toggle(); } };
|
|
328
|
+
if (e.isError || (e.diff && e.lines && e.lines.added + e.lines.removed <= 40)) { el.classList.add('open'); line.setAttribute('aria-expanded', 'true'); }
|
|
245
329
|
}
|
|
246
330
|
return el;
|
|
247
331
|
}
|
|
248
332
|
|
|
249
333
|
/* ---------- schedule: condensed time ---------- */
|
|
250
|
-
// Real gaps are squeezed into 0.35–2.5s so a 2-hour session plays in minutes,
|
|
251
|
-
// with a bit of extra hold for long messages so they're readable.
|
|
252
334
|
const sched = [];
|
|
253
335
|
let acc = 0;
|
|
254
336
|
for (let i = 0; i < E.length; i++) {
|
|
255
337
|
if (i > 0) {
|
|
256
|
-
const
|
|
257
|
-
const gap =
|
|
258
|
-
const read =
|
|
338
|
+
const p = E[i - 1];
|
|
339
|
+
const gap = E[i].t && p.t ? Math.max(0, E[i].t - p.t) : 800;
|
|
340
|
+
const read = p.kind === 'user' || p.kind === 'assistant' ? Math.min(3000, (p.text || '').length * 12) : 0;
|
|
259
341
|
acc += Math.min(2500, Math.max(350, gap / 4)) + read;
|
|
260
342
|
}
|
|
261
343
|
sched.push(acc);
|
|
262
344
|
}
|
|
263
345
|
const total = acc + 1200;
|
|
264
346
|
|
|
265
|
-
// Markers on the track
|
|
266
347
|
const track = $('track');
|
|
267
348
|
E.forEach((e, i) => {
|
|
268
349
|
const cls = e.kind === 'user' ? 'u' : e.isError ? 'x' : e.diff ? 'e' : null;
|
|
269
350
|
if (!cls) return;
|
|
270
351
|
const m = document.createElement('div');
|
|
271
352
|
m.className = 'mk ' + cls;
|
|
272
|
-
m.style.left = (sched[i] / total * 100
|
|
353
|
+
m.style.left = (sched[i] / total) * 100 + '%';
|
|
273
354
|
track.appendChild(m);
|
|
274
355
|
});
|
|
275
356
|
|
|
276
357
|
/* ---------- player ---------- */
|
|
277
|
-
const
|
|
278
|
-
let shown = 0,
|
|
358
|
+
const log = $('log');
|
|
359
|
+
let shown = 0, at = 0, playing = false, last = 0, speed = 1;
|
|
360
|
+
const SPEEDS = [0.5, 1, 2, 4, 10];
|
|
279
361
|
|
|
280
362
|
function showUpTo(n, animate) {
|
|
281
363
|
n = Math.max(0, Math.min(E.length, n));
|
|
282
|
-
if (n < shown) {
|
|
364
|
+
if (n < shown) { log.innerHTML = ''; shown = 0; }
|
|
283
365
|
const frag = document.createDocumentFragment();
|
|
284
366
|
let lastEl = null;
|
|
285
|
-
while (shown < n) { lastEl = render(E[shown], shown); if (
|
|
286
|
-
if (lastEl) {
|
|
287
|
-
feed.appendChild(frag);
|
|
288
|
-
if (animate) lastEl.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
|
289
|
-
}
|
|
367
|
+
while (shown < n) { lastEl = render(E[shown], shown); if (animate) lastEl.classList.add('new'); frag.appendChild(lastEl); shown++; }
|
|
368
|
+
if (lastEl) { log.appendChild(frag); if (animate) lastEl.scrollIntoView({ behavior: 'smooth', block: 'end' }); }
|
|
290
369
|
}
|
|
291
370
|
function ui() {
|
|
292
|
-
const p = Math.min(1,
|
|
293
|
-
$('fill').style.width =
|
|
294
|
-
$('
|
|
295
|
-
$('
|
|
296
|
-
|
|
371
|
+
const p = Math.min(1, at / total);
|
|
372
|
+
$('fill').style.width = p * 100 + '%';
|
|
373
|
+
$('phead').style.left = p * 100 + '%';
|
|
374
|
+
$('count').textContent = `${shown} ${tr('of')} ${E.length}`;
|
|
375
|
+
const done = shown >= E.length && !playing;
|
|
376
|
+
$('play').innerHTML = playing ? ICON.pause : done ? ICON.again : ICON.play;
|
|
377
|
+
$('play').setAttribute('aria-label', playing ? tr('pause') : done ? tr('replay') : tr('play'));
|
|
378
|
+
$('play').title = $('play').getAttribute('aria-label');
|
|
297
379
|
}
|
|
298
380
|
function tick(now) {
|
|
299
381
|
if (!playing) return;
|
|
300
|
-
|
|
382
|
+
at += (now - last) * speed; last = now;
|
|
301
383
|
let n = shown;
|
|
302
|
-
while (n < E.length && sched[n] <=
|
|
384
|
+
while (n < E.length && sched[n] <= at) n++;
|
|
303
385
|
if (n !== shown) showUpTo(n, true);
|
|
304
|
-
if (shown >= E.length &&
|
|
386
|
+
if (shown >= E.length && at >= total) playing = false;
|
|
305
387
|
ui();
|
|
306
388
|
if (playing) requestAnimationFrame(tick);
|
|
307
389
|
}
|
|
308
|
-
function play() {
|
|
309
|
-
if (shown >= E.length) { clock = 0; showUpTo(0); }
|
|
310
|
-
playing = true; last = performance.now(); requestAnimationFrame(tick); ui();
|
|
311
|
-
}
|
|
390
|
+
function play() { if (shown >= E.length) { at = 0; showUpTo(0); } playing = true; last = performance.now(); requestAnimationFrame(tick); ui(); }
|
|
312
391
|
function pause() { playing = false; ui(); }
|
|
313
392
|
function seekTo(n) {
|
|
314
393
|
pause();
|
|
315
394
|
showUpTo(n, false);
|
|
316
|
-
|
|
395
|
+
at = n > 0 ? sched[n - 1] : 0;
|
|
317
396
|
const el = $('e' + (n - 1));
|
|
318
397
|
if (el) el.scrollIntoView({ block: 'center' });
|
|
319
398
|
ui();
|
|
320
399
|
}
|
|
321
400
|
|
|
322
401
|
$('play').onclick = () => (playing ? pause() : play());
|
|
323
|
-
$('
|
|
324
|
-
$('all').onclick = () => { seekTo(E.length);
|
|
402
|
+
$('all').textContent = tr('showAll');
|
|
403
|
+
$('all').onclick = () => { seekTo(E.length); at = total; ui(); };
|
|
404
|
+
$('speeds').setAttribute('aria-label', tr('speed'));
|
|
405
|
+
$('speeds').innerHTML = SPEEDS.map((s) => `<button aria-pressed="${s === 1}" data-s="${s}">${s}×</button>`).join('');
|
|
406
|
+
$('speeds').onclick = (ev) => {
|
|
407
|
+
const b = ev.target.closest('button');
|
|
408
|
+
if (!b) return;
|
|
409
|
+
const narrow = matchMedia('(max-width: 700px)').matches;
|
|
410
|
+
speed = narrow && b.getAttribute('aria-pressed') === 'true' ? SPEEDS[(SPEEDS.indexOf(speed) + 1) % SPEEDS.length] : Number(b.dataset.s);
|
|
411
|
+
for (const x of $('speeds').children) x.setAttribute('aria-pressed', Number(x.dataset.s) === speed);
|
|
412
|
+
};
|
|
413
|
+
$('theme').setAttribute('aria-label', tr('theme'));
|
|
414
|
+
$('theme').title = tr('theme');
|
|
325
415
|
$('theme').onclick = () => {
|
|
326
416
|
const r = document.documentElement;
|
|
327
417
|
const dark = r.dataset.theme ? r.dataset.theme === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches;
|
|
328
418
|
r.dataset.theme = dark ? 'light' : 'dark';
|
|
329
419
|
try { localStorage.setItem('agentreplay-theme', r.dataset.theme); } catch {}
|
|
330
420
|
};
|
|
331
|
-
try { const
|
|
421
|
+
try { const th = localStorage.getItem('agentreplay-theme'); if (th) document.documentElement.dataset.theme = th; } catch {}
|
|
332
422
|
|
|
333
|
-
track.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
423
|
+
track.setAttribute('role', 'slider');
|
|
424
|
+
track.setAttribute('aria-label', tr('seek'));
|
|
425
|
+
track.tabIndex = 0;
|
|
426
|
+
const seekAt = (x) => { const r = track.getBoundingClientRect(); const target = ((x - r.left) / r.width) * total; let n = 0; while (n < E.length && sched[n] <= target) n++; seekTo(n); };
|
|
427
|
+
track.onpointerdown = (ev) => { seekAt(ev.clientX); track.setPointerCapture(ev.pointerId); track.onpointermove = (m) => seekAt(m.clientX); };
|
|
428
|
+
track.onpointerup = () => { track.onpointermove = null; };
|
|
339
429
|
document.addEventListener('keydown', (ev) => {
|
|
340
|
-
if (ev.target.
|
|
430
|
+
if (ev.target.closest && ev.target.closest('.line')) return;
|
|
341
431
|
if (ev.code === 'Space') { ev.preventDefault(); playing ? pause() : play(); }
|
|
342
432
|
else if (ev.key === 'ArrowRight') seekTo(shown + 1);
|
|
343
433
|
else if (ev.key === 'ArrowLeft') seekTo(shown - 1);
|
|
@@ -345,11 +435,11 @@ footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4
|
|
|
345
435
|
else if (ev.key === 'Home') seekTo(0);
|
|
346
436
|
});
|
|
347
437
|
|
|
348
|
-
//
|
|
438
|
+
// #e42 opens at event 42; ?static shows everything at once.
|
|
349
439
|
const m = location.hash.match(/^#e(\d+)$/);
|
|
350
|
-
if (m)
|
|
351
|
-
else if (
|
|
352
|
-
else { showUpTo(1, false);
|
|
440
|
+
if (m) seekTo(Number(m[1]) + 1);
|
|
441
|
+
else if (qs.has('static')) $('all').click();
|
|
442
|
+
else { showUpTo(1, false); at = sched[0]; ui(); setTimeout(play, 700); }
|
|
353
443
|
})();
|
|
354
444
|
</script>
|
|
355
445
|
</body>
|
package/src/util.js
CHANGED
|
@@ -107,6 +107,19 @@ export function addUsage(session, model, u) {
|
|
|
107
107
|
session.usage[k] += v;
|
|
108
108
|
per[k] += v;
|
|
109
109
|
}
|
|
110
|
+
trackRequest(session, u);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* One API request: count it and remember the biggest prompt. Agents re-send the
|
|
115
|
+
* whole conversation on every request, so summed tokens grow quadratically —
|
|
116
|
+
* the peak prompt is the honest "how big was this conversation" number.
|
|
117
|
+
*/
|
|
118
|
+
export function trackRequest(session, u) {
|
|
119
|
+
const ctx = (Number(u.input) || 0) + (Number(u.cacheRead) || 0) + (Number(u.cacheWrite) || 0) + (Number(u.cacheWrite1h) || 0);
|
|
120
|
+
if (!ctx && !u.output) return;
|
|
121
|
+
session.requests = (session.requests || 0) + 1;
|
|
122
|
+
session.peakContext = Math.max(session.peakContext || 0, ctx);
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
/** Codex / OpenAI apply_patch envelope → diff hunks. */
|