@niracler/encore 0.2.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 +104 -75
- package/README.zh-CN.md +105 -69
- package/bin/encore.mjs +53 -22
- package/package.json +4 -2
- package/player/encore-player.css +83 -1
- package/player/encore-player.js +422 -90
- package/schema/session.schema.json +63 -1
- package/skills/encore/SKILL.md +39 -35
- package/src/attachment-previews.mjs +169 -0
- package/src/attachment-reader.mjs +169 -0
- package/src/claude-ai.mjs +3 -1
- package/src/claude-code.mjs +11 -7
- package/src/codex.mjs +10 -3
- package/src/common.mjs +25 -5
- package/src/external-files.mjs +176 -0
- package/src/i18n.mjs +107 -25
- package/src/index.d.ts +18 -2
- package/src/index.mjs +59 -41
- package/src/markdown.mjs +14 -11
- package/src/player-assets.mjs +4 -1
- package/src/player-runtime.mjs +53 -11
- package/src/render.mjs +48 -13
- package/src/server.mjs +2 -0
- package/src/timeline.mjs +32 -30
- package/src/workbuddy.mjs +6 -5
package/README.md
CHANGED
|
@@ -1,72 +1,93 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="./docs/hero-en.svg" alt="Encore
|
|
2
|
+
<img src="./docs/hero-en.svg" alt="Encore · Replay an AI Agent session to see how it worked and what it delivered." width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://encore.niracler.com"><strong>Live
|
|
7
|
-
<a href="https://www.npmjs.com/package/@niracler/encore"><strong>npm
|
|
6
|
+
<a href="https://encore.niracler.com/?lang=en"><strong>Live Demos (encore.niracler.com)</strong></a> ·
|
|
7
|
+
<a href="https://www.npmjs.com/package/@niracler/encore"><strong>npm</strong></a> ·
|
|
8
8
|
<a href="./README.md"><strong>English</strong></a> ·
|
|
9
9
|
<a href="./README.zh-CN.md">简体中文</a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</tr>
|
|
23
|
-
</thead>
|
|
24
|
-
<tbody>
|
|
25
|
-
<tr>
|
|
26
|
-
<td valign="top">Typewriter prompt input, streaming Markdown replies, <code>12×</code> tool call shimmer, sub-agent dispatches, and inline <code>.webp</code> visual outputs.</td>
|
|
27
|
-
<td valign="top">Live <code>200k</code> / <code>1.0M</code> token gauge, 7-color bucket bar, auto-compaction headroom markers, and click-to-inspect raw payloads at any step.</td>
|
|
28
|
-
<td valign="top">Step-by-step scrubber pinned with visual keyframes (<code>🖼</code>), draft docs (<code>📄</code>), context compactions (<code>🗜</code>), and user turns (<code>💬</code>).</td>
|
|
29
|
-
</tr>
|
|
30
|
-
</tbody>
|
|
31
|
-
</table>
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/@niracler/encore"><img src="https://img.shields.io/npm/v/@niracler/encore?style=flat-square&color=c2410c" alt="npm version"></a>
|
|
14
|
+
<a href="https://github.com/niracler/encore/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/niracler/encore/ci.yml?branch=main&style=flat-square&label=CI" alt="CI status"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20.10-334155?style=flat-square" alt="Node.js >= 20.10">
|
|
16
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-2563eb?style=flat-square" alt="MIT License"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
**Encore** is like [`asciinema`](https://asciinema.org) for AI Agent sessions. Locally, it turns a raw log from **Codex**, **Claude Code**, **Claude.ai**, or **WorkBuddy** into a portable web replay. Readers can step through turns, tool calls, sub-agents, frames, and deliverables while watching the context snapshot grow and compact in real time.
|
|
20
|
+
|
|
21
|
+

|
|
32
22
|
|
|
33
23
|
---
|
|
34
24
|
|
|
35
|
-
##
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
Requires **Node.js >= 20.10**. No global install needed.
|
|
36
28
|
|
|
37
29
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
npx @niracler/encore
|
|
30
|
+
npx @niracler/encore@latest
|
|
31
|
+
```
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
npx @niracler/encore /path/to/rollout.jsonl -o ./replays/my-session
|
|
33
|
+
The interactive picker scans recent local **Codex**, **Claude Code**, and **WorkBuddy** sessions and opens the selected replay in your browser. You can also pass a `.jsonl` or `.jsonl.zst` raw log, or a Claude.ai `conversations.json` export directly.
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
# or re-run on the folder to sync <title> and privacy checks:
|
|
47
|
-
npx @niracler/encore ./replays/my-session
|
|
48
|
-
```
|
|
35
|
+
Without `-o`, replays write to a temporary directory. Pass `-o <dir>` to keep a portable copy for publishing; see `npx @niracler/encore@latest --help` for all commands and options.
|
|
49
36
|
|
|
50
37
|
---
|
|
51
38
|
|
|
52
|
-
##
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<picture>
|
|
43
|
+
<source media="(prefers-color-scheme: dark)" srcset="./docs/architecture-en-dark.webp">
|
|
44
|
+
<source media="(prefers-color-scheme: light)" srcset="./docs/architecture-en-light.webp">
|
|
45
|
+
<img src="./docs/architecture-en-light.webp" alt="Encore architecture: from raw Agent logs and referenced local files in Asset Roots, through automatic CLI export and optional pre-publish Curation, to a portable Replay and standalone Player" width="100%">
|
|
46
|
+
</picture>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
- **Local-only processing**: Adapters, `.webp` frame extraction, automatic redaction, and leak checks all run locally in Node.js. Nothing is uploaded.
|
|
50
|
+
- **Decoupled Session and Player**: `session.json`, extracted `.webp` frames, and collected files live beside the zero-dependency player, so edits to `session.json` appear on browser reload.
|
|
51
|
+
- **Explicit file collection boundaries**: Encore collects locally referenced attachments and deliverables within allowed asset roots (defaulting to the current directory and native session workspace; override with `--asset-root`), builds in-place PDF and workbook previews, and labels each file as verified (matching SHA-256), an export-time copy, or missing.
|
|
52
|
+
|
|
53
|
+
---
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
## Curating Before Publishing (Optional)
|
|
56
|
+
|
|
57
|
+
For personal review or internal archiving, the CLI export is ready to watch as-is—no skill needed. When preparing a replay for a blog, course, or public showcase, pair the export with the companion `encore` skill for a semantic curation pass.
|
|
58
|
+
|
|
59
|
+
**What the CLI handles automatically**
|
|
60
|
+
|
|
61
|
+
- Adapts the raw log, extracts deduplicated `.webp` frames, collects referenced attachments and deliverables from asset roots, and builds in-place previews
|
|
62
|
+
- Redacts common API keys, private keys, JWTs, database URLs, emails, private IPs, and home paths, omits cross-session `MEMORY_SUMMARY` and user-level `CLAUDE.md` bodies by default, and runs a non-blocking leak check
|
|
63
|
+
- Packages a standalone replay directory with the zero-dependency player
|
|
64
|
+
|
|
65
|
+
**What the `encore` skill adds during curation**
|
|
66
|
+
|
|
67
|
+
- **Curate & label frames**: Inspects `.webp` frames, drops noisy intermediate states, keeps key milestones, and replaces fallback labels with concrete descriptions
|
|
68
|
+
- **Write intro & trim turns**: Drafts a concise `title` and opening `description` from full context, and trims off-topic opening or closing turns
|
|
69
|
+
- **Manual redaction & file review**: Reviews leak check warnings, removes internal codenames, people's names, and business figures regex cannot detect, and audits raw files in `attachments/`
|
|
70
|
+
- **Lossless rebuild**: Runs `npx @niracler/encore@latest <replay-dir>` to refresh player assets and previews, sync `<title>`, drop deleted frame references, and re-run the leak check without overwriting curation edits or added media
|
|
71
|
+
|
|
72
|
+
Install the skill globally (or copy [`skills/encore/SKILL.md`](./skills/encore/SKILL.md) manually):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx skills add niracler/encore -g
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then ask your Agent from any workspace:
|
|
55
79
|
|
|
56
80
|
```text
|
|
57
|
-
Use the encore skill to export my latest session and curate
|
|
81
|
+
Use the encore skill to export my latest session and curate it for publishing.
|
|
58
82
|
```
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
- **Title & Playbill Intro**: Writes a sharp `title` and a 1–3 sentence `description` summarizing the problem, pivot, and outcome.
|
|
62
|
-
- **Semantic Privacy Redaction**: Replaces internal codenames, colleague names, or private URLs with `(Internal context redacted)`.
|
|
63
|
-
- **Time-Window Trimming**: Cuts off-topic turns at the start or end of a session.
|
|
84
|
+
> **Review before sharing**: Automatic redaction only rewrites `session.json`; it never modifies copied PDFs, workbooks, images, or videos in `attachments/`. Review `session.json`, every kept `.webp` frame, and all packaged attachments and deliverables before publishing.
|
|
64
85
|
|
|
65
86
|
---
|
|
66
87
|
|
|
67
|
-
##
|
|
88
|
+
## Embedding on Any Site
|
|
68
89
|
|
|
69
|
-
|
|
90
|
+
Export with `-o ./replays/<slug>` and deploy the entire replay directory to GitHub Pages, Cloudflare Pages, Vercel, or any static host—or embed the player in an existing HTML page with three lines:
|
|
70
91
|
|
|
71
92
|
```html
|
|
72
93
|
<link rel="stylesheet" href="./encore-player.css">
|
|
@@ -74,39 +95,10 @@ Encore separates data (`session.json` + `.webp`), standalone player (`encore-pla
|
|
|
74
95
|
<script src="./encore-player.js" defer></script>
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
|
|
78
|
-
<summary><strong>CLI Options & <code>session.json</code> Reference</strong></summary>
|
|
79
|
-
|
|
80
|
-
### CLI Options
|
|
98
|
+
Omit `data-lang` to follow the language set in `session.json`. The player also natively renders optional curated extensions in `session.json`, including per-step audio (`item.audio`), landscape/portrait video switching, and PDF/workbook revision diffs.
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
encore Scan recent Codex, Claude Code & WorkBuddy sessions and pick one interactively
|
|
85
|
-
encore <log.jsonl | dir> [options] Build a standalone replay directory from a log or re-render an edited session.json
|
|
86
|
-
encore play <dir> [--port 4180] Start local preview server for an existing replay directory
|
|
87
|
-
|
|
88
|
-
Options:
|
|
89
|
-
-o, --out <dir> Output directory (default: ./replays/<session-slug>)
|
|
90
|
-
-l, --lang <zh|en|auto> Player UI language (default: auto; also toggleable in the topbar)
|
|
91
|
-
--title <text> Override session title
|
|
92
|
-
--desc <text> Set opening description shown before playback starts
|
|
93
|
-
--from <iso-time> Start time window filter (e.g. 2026-11-10T09:00)
|
|
94
|
-
--to <iso-time> End time window filter
|
|
95
|
-
--no-images Skip extracting embedded images to .webp
|
|
96
|
-
--image-width <px> Max width for extracted WebP frames (default: 960)
|
|
97
|
-
--clip <chars> Max chars per tool input/output (default: 1500/2000)
|
|
98
|
-
--conversation <id> Conversation UUID for multi-chat Claude.ai exports
|
|
99
|
-
--include-memory Include full cross-session MEMORY_SUMMARY / User CLAUDE.md text
|
|
100
|
-
--list List recent local sessions without interactive prompt
|
|
101
|
-
--serve Start local HTTP preview server after building
|
|
102
|
-
--no-serve Do not start local HTTP preview server
|
|
103
|
-
--no-open Do not automatically open browser when serving
|
|
104
|
-
-p, --port <number> Preview server port (default: 4180)
|
|
105
|
-
-v, --version Show version number
|
|
106
|
-
-h, --help Show help message
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### `session.json` Schema
|
|
100
|
+
<details>
|
|
101
|
+
<summary><strong><code>session.json</code> Schema</strong></summary>
|
|
110
102
|
|
|
111
103
|
Formal JSON Schema: [`schema/session.schema.json`](./schema/session.schema.json) (`https://encore.niracler.com/schema/session.schema.json`) · TypeScript Definitions: [`src/index.d.ts`](./src/index.d.ts)
|
|
112
104
|
|
|
@@ -132,6 +124,43 @@ Formal JSON Schema: [`schema/session.schema.json`](./schema/session.schema.json)
|
|
|
132
124
|
|
|
133
125
|
</details>
|
|
134
126
|
|
|
135
|
-
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## FAQ
|
|
130
|
+
|
|
131
|
+
### Does Encore upload my logs? How does redaction work?
|
|
132
|
+
|
|
133
|
+
**No—everything runs locally.**
|
|
134
|
+
|
|
135
|
+
- **Automatic redaction**: Hides common API keys, private keys, JWTs, database URLs, emails, private IPs, and home directory paths (replaced with `~`), omits cross-session `MEMORY_SUMMARY` and user-level `CLAUDE.md` bodies by default, and runs a non-blocking leak check.
|
|
136
|
+
- **Manual review still needed**: Project codenames, business figures, and raw files copied into `attachments/` (PDFs, workbooks, images, videos) are never rewritten automatically.
|
|
137
|
+
|
|
138
|
+
### Why doesn't double-clicking `index.html` work?
|
|
139
|
+
|
|
140
|
+
Browser security rules block `fetch('./session.json')` on `file://` URLs. Open the replay through the local preview server, or deploy the folder to any static host:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npx @niracler/encore@latest play ./replays/<slug>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Will deleting the raw log or source files break a replay?
|
|
147
|
+
|
|
148
|
+
**No.** A replay directory is a self-contained static bundle (`session.json`, `.webp` frames, `attachments/`, and player assets). Keep the directory intact; only external URLs still depend on their hosts.
|
|
149
|
+
|
|
150
|
+
### Why is an attachment labeled as an export-time copy or missing?
|
|
151
|
+
|
|
152
|
+
- **Verified**: Found inside an allowed asset root with a SHA-256 matching the digest recorded in the session.
|
|
153
|
+
- **Export-time copy**: Found at export time, but no matching session digest exists or the file changed afterward.
|
|
154
|
+
- **Missing / Outside asset roots**: Referenced in the log, but absent on disk or outside the allowed asset roots (pass `--asset-root` to include another directory; the filename stays visible under the message).
|
|
155
|
+
|
|
156
|
+
### Are token counts in the Context Snapshot exact billing figures?
|
|
157
|
+
|
|
158
|
+
**No.** They visualize context structure and growth: when a raw log includes real token counts (including `preTokens` / `postTokens` around compactions), Encore displays them directly; when per-step totals or category breakdowns are missing, it estimates from content length.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Contributing & License
|
|
163
|
+
|
|
164
|
+
Architecture notes and development commands live in [`AGENTS.md`](./AGENTS.md), and shared domain terminology lives in [`GLOSSARY.md`](./GLOSSARY.md). Run `pnpm test` before opening a pull request to verify adapters, redaction rules, and player build sync. To request support for another Agent format, open an issue.
|
|
136
165
|
|
|
137
166
|
[MIT](./LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,72 +1,93 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="./docs/hero-zh.svg" alt="Encore
|
|
2
|
+
<img src="./docs/hero-zh.svg" alt="Encore · 回看一次 AI Agent 会话,看它怎么完成任务,交付了什么。" width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://encore.niracler.com"><strong
|
|
7
|
-
<a href="https://www.npmjs.com/package/@niracler/encore"><strong>npm
|
|
6
|
+
<a href="https://encore.niracler.com/?lang=zh"><strong>在线演示(encore.niracler.com)</strong></a> ·
|
|
7
|
+
<a href="https://www.npmjs.com/package/@niracler/encore"><strong>npm</strong></a> ·
|
|
8
8
|
<a href="./README.md">English</a> ·
|
|
9
9
|
<a href="./README.zh-CN.md"><strong>简体中文</strong></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</tr>
|
|
23
|
-
</thead>
|
|
24
|
-
<tbody>
|
|
25
|
-
<tr>
|
|
26
|
-
<td valign="top">输入框打字上屏、Markdown 呼吸流式回复、<code>12×</code> 工具调用流光快切、子代理派发报告与 <code>.webp</code> 过程效果图演进。</td>
|
|
27
|
-
<td valign="top">实时显示 <code>200k</code> / <code>1.0M</code> 上下文水位、7 色分段进度条与压缩警戒线,点击任意色块或消息即可定格查看当时的原文载荷。</td>
|
|
28
|
-
<td valign="top">按步切分的进度条,自动钉出过程效果图(<code>🖼</code>)、中间文稿(<code>📄</code>)、上下文压缩(<code>🗜</code>)与提问节点(<code>💬</code>)。</td>
|
|
29
|
-
</tr>
|
|
30
|
-
</tbody>
|
|
31
|
-
</table>
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/@niracler/encore"><img src="https://img.shields.io/npm/v/@niracler/encore?style=flat-square&color=c2410c" alt="npm 版本"></a>
|
|
14
|
+
<a href="https://github.com/niracler/encore/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/niracler/encore/ci.yml?branch=main&style=flat-square&label=CI" alt="CI 状态"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20.10-334155?style=flat-square" alt="Node.js >= 20.10">
|
|
16
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-2563eb?style=flat-square" alt="MIT 协议"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
**Encore** 是面向 AI Agent 会话的 [`asciinema`](https://asciinema.org)。它在本地将 **Codex**、**Claude Code**、**Claude.ai** 或 **WorkBuddy** 的原始日志转换为可独立托管的网页回放。打开回放后,读者可以按步骤查看对话轮次、工具调用、子 Agent 协作、画面帧与交付物,并在右侧同步查看上下文快照的增长与压缩。
|
|
20
|
+
|
|
21
|
+

|
|
32
22
|
|
|
33
23
|
---
|
|
34
24
|
|
|
35
|
-
##
|
|
25
|
+
## 快速开始
|
|
26
|
+
|
|
27
|
+
需要 **Node.js >= 20.10**,无需全局安装。
|
|
36
28
|
|
|
37
29
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
npx @niracler/encore
|
|
30
|
+
npx @niracler/encore@latest
|
|
31
|
+
```
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
npx @niracler/encore /path/to/rollout.jsonl -o ./replays/my-session
|
|
33
|
+
命令会扫描本机最近的 **Codex**、**Claude Code** 与 **WorkBuddy** 会话,选中后在浏览器中打开回放;也可以直接传入 `.jsonl`、`.jsonl.zst` 或 Claude.ai 导出的 `conversations.json`。
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
# 对目录重跑命令可同步更新 <title> 并重新执行隐私检查:
|
|
47
|
-
npx @niracler/encore ./replays/my-session
|
|
48
|
-
```
|
|
35
|
+
未传 `-o` 时,回放默认写入系统临时目录;需要保存可移植副本或部署时,传入 `-o <目录>`。完整子命令与选项见 `npx @niracler/encore@latest --help`。
|
|
49
36
|
|
|
50
37
|
---
|
|
51
38
|
|
|
52
|
-
##
|
|
39
|
+
## 工作原理
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<picture>
|
|
43
|
+
<source media="(prefers-color-scheme: dark)" srcset="./docs/architecture-zh-dark.webp">
|
|
44
|
+
<source media="(prefers-color-scheme: light)" srcset="./docs/architecture-zh-light.webp">
|
|
45
|
+
<img src="./docs/architecture-zh-light.webp" alt="Encore 处理架构:从原始 Agent 日志与资产根目录内的本地文件,经 CLI 自动导出与可选的发布前整理,生成可独立托管的回放目录与零依赖播放器" width="100%">
|
|
46
|
+
</picture>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
- **全本地离线运行**:日志适配、`.webp` 画面帧转码、自动脱敏与泄露检查都在本地 Node.js 环境中完成,不上传任何数据。
|
|
50
|
+
- **会话数据与播放器分离**:`session.json`、提取出的 `.webp` 画面帧与收录文件都与零依赖播放器同目录存放,编辑 `session.json` 后刷新页面即可生效。
|
|
51
|
+
- **明确的文件收集边界**:自动收集允许的资产根目录(默认为当前工作目录与原始会话工作区,可用 `--asset-root` 覆盖)内日志明确引用的附件与交付物,生成 PDF 与表格的页内预览,并在原消息下标注「已核对版本」「导出时的副本」或「原文件缺失」。
|
|
52
|
+
|
|
53
|
+
---
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
## 发布前整理(可选)
|
|
56
|
+
|
|
57
|
+
个人复盘或内部留档时,CLI 导出的回放已经可以直接观看,不需要安装技能。准备公开发布到博客、课程或展示页时,可以配合 `encore` 技能在导出结果上做一轮语义整理。
|
|
58
|
+
|
|
59
|
+
**CLI 自动导出已完成**
|
|
60
|
+
|
|
61
|
+
- 转换原始日志,提取去重 `.webp` 画面帧,收集资产根目录内引用的附件与交付物并生成页内预览
|
|
62
|
+
- 对常见密钥、私钥、JWT、数据库连接串、邮箱、内网 IP 与本机路径自动脱敏,默认省略 `MEMORY_SUMMARY` 与用户级 `CLAUDE.md` 正文,并输出非阻塞泄露检查预警
|
|
63
|
+
- 打包独立的回放目录与零依赖播放器
|
|
64
|
+
|
|
65
|
+
**`encore` 技能负责发布前整理**
|
|
66
|
+
|
|
67
|
+
- **筛选与标注画面帧**:逐张查看 `.webp` 画面帧,剔除报错与冗余中间态,只保留里程碑画面并写清变化标签
|
|
68
|
+
- **撰写导读与裁剪轮次**:结合上下文撰写标题(`title`)与开场说明(`description`),删去首尾无关轮次
|
|
69
|
+
- **人工脱敏与附件复核**:处理泄露检查预警,清理正则识别不出的内部代号、人名与业务数据,并核对 `attachments/` 中的原件
|
|
70
|
+
- **无损重建同步**:整理完成后运行 `npx @niracler/encore@latest <回放目录>`,刷新播放器与预览、同步页面 `<title>`、清理已删画面帧引用并重跑泄露检查(保留整理修改与补充媒体)
|
|
71
|
+
|
|
72
|
+
全局安装该技能(或手动复制 [`skills/encore/SKILL.md`](./skills/encore/SKILL.md)):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx skills add niracler/encore -g
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
之后在任意工作区直接告诉 Agent:
|
|
55
79
|
|
|
56
80
|
```text
|
|
57
|
-
用 encore
|
|
81
|
+
用 encore 技能把我刚才那段对话导出并整理一下。
|
|
58
82
|
```
|
|
59
83
|
|
|
60
|
-
|
|
61
|
-
- **提炼标题与报幕导读**:在 `session.json` 顶层写出直奔主题的 `title` 与几十字的 `description` 开场脉络。
|
|
62
|
-
- **语义级隐私清理**:识别正则抓不到的内部代号、同事姓名或内网地址,替换为 `(涉及内部业务细节,已略去)`。
|
|
63
|
-
- **时间窗口切片**:掐掉会话首尾顺手聊的无关话题,只留完整讲好一件事的片段。
|
|
84
|
+
> **公开分享前请复核**:自动脱敏只改写 `session.json`,不会修改 `attachments/` 中复制进来的 PDF、工作簿、图片或视频原件。发布前请检查 `session.json`、保留的 `.webp` 画面帧以及所有打包的附件和交付物。
|
|
64
85
|
|
|
65
86
|
---
|
|
66
87
|
|
|
67
|
-
##
|
|
88
|
+
## 嵌入网页
|
|
68
89
|
|
|
69
|
-
|
|
90
|
+
使用 `-o ./replays/<会话短名>` 导出后,将整个回放目录部署到 GitHub Pages、Cloudflare Pages、Vercel 或任意静态托管服务即可直接访问,也可通过 3 行代码嵌入已有 HTML 页面:
|
|
70
91
|
|
|
71
92
|
```html
|
|
72
93
|
<link rel="stylesheet" href="./encore-player.css">
|
|
@@ -74,34 +95,12 @@ Encore 将数据(`session.json` + `.webp`)、纯前端播放器(`encore-pl
|
|
|
74
95
|
<script src="./encore-player.js" defer></script>
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
|
|
78
|
-
<summary><strong>CLI 参数与 <code>session.json</code> 结构速查</strong></summary>
|
|
79
|
-
|
|
80
|
-
### CLI 参数
|
|
98
|
+
省略 `data-lang` 时,界面语言自动跟随 `session.json` 的设置。播放器同时原生支持在 `session.json` 中手动挂载步骤音频(`item.audio`)、横竖屏视频切换与 PDF / 表格修订对照。
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
encore 扫描本机最近的 Codex、Claude Code 与 WorkBuddy 会话,上下键选择导出
|
|
85
|
-
encore <log.jsonl | dir> [options] 从原始日志一步生成回放目录,或对已修改的目录重新同步
|
|
86
|
-
encore play <dir> [--port 4180] 启动本地预览服务
|
|
87
|
-
|
|
88
|
-
常用参数:
|
|
89
|
-
-o, --out <dir> 输出目录(默认:./replays/<会话短名>)
|
|
90
|
-
-l, --lang <zh|en|auto> 界面语言(默认:auto,网页右上角也可一键切换)
|
|
91
|
-
--title <text> 自定义回放标题
|
|
92
|
-
--desc <text> 自定义开场导读说明
|
|
93
|
-
--from <iso-time> 起始时间切片(如 2026-11-10T09:00)
|
|
94
|
-
--to <iso-time> 结束时间切片
|
|
95
|
-
--no-images 不提取内嵌图片
|
|
96
|
-
--include-memory 保留完整的跨会话 MEMORY_SUMMARY / 用户级 CLAUDE.md 原文(默认自动折叠脱敏)
|
|
97
|
-
--list 仅列出本机最近会话,不进入交互菜单
|
|
98
|
-
--no-serve 生成文件后直接退出,不启动本地预览服务
|
|
99
|
-
-v, --version 显示版本号
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### `session.json` 核心字段
|
|
100
|
+
<details>
|
|
101
|
+
<summary><strong><code>session.json</code> 核心结构</strong></summary>
|
|
103
102
|
|
|
104
|
-
JSON Schema 规范:[`schema/session.schema.json`](./schema/session.schema.json)(`https://encore.niracler.com/schema/session.schema.json
|
|
103
|
+
JSON Schema 规范:[`schema/session.schema.json`](./schema/session.schema.json)(`https://encore.niracler.com/schema/session.schema.json`);TypeScript 类型声明:[`src/index.d.ts`](./src/index.d.ts)。
|
|
105
104
|
|
|
106
105
|
```json
|
|
107
106
|
{
|
|
@@ -125,6 +124,43 @@ JSON Schema 规范:[`schema/session.schema.json`](./schema/session.schema.json
|
|
|
125
124
|
|
|
126
125
|
</details>
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 常见问题
|
|
130
|
+
|
|
131
|
+
### 日志会上传吗?隐私怎么处理?
|
|
132
|
+
|
|
133
|
+
**不会,全部在本地运行。**
|
|
134
|
+
|
|
135
|
+
- **自动脱敏**:隐藏常见密钥、私钥、JWT、数据库连接串、邮箱、内网 IP 与本机用户目录(替换为 `~`),默认省略 `MEMORY_SUMMARY` 与用户级 `CLAUDE.md` 正文,并输出非阻塞泄露检查预警。
|
|
136
|
+
- **需人工复核**:项目代号、业务数据,以及 `attachments/` 里复制进来的原件(PDF、工作簿、图片、视频)不会被自动改写。
|
|
137
|
+
|
|
138
|
+
### 为什么双击 `index.html` 无法播放?
|
|
139
|
+
|
|
140
|
+
浏览器安全策略会拦截 `file://` 协议下的 `fetch('./session.json')` 请求。用本地预览服务打开,或部署到任意静态托管即可:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npx @niracler/encore@latest play ./replays/<会话短名>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 导出后删掉原始日志或原文件,回放会坏吗?
|
|
147
|
+
|
|
148
|
+
**不会。** 回放目录是自包含的静态包(`session.json`、`.webp` 画面帧、`attachments/` 与播放器文件),保持整个目录完整即可;只有外链 URL 仍依赖原地址。
|
|
149
|
+
|
|
150
|
+
### 为什么附件会标为「导出时的副本」或「原文件缺失」?
|
|
151
|
+
|
|
152
|
+
- **已核对版本**:文件在允许的资产根目录内找到,且 SHA-256 与日志记录一致。
|
|
153
|
+
- **导出时的副本**:文件在导出时找到了,但日志里没有可比对的摘要或内容已变化。
|
|
154
|
+
- **原文件缺失 / 未收录**:日志引用了该文件,但导出时在磁盘上已找不到,或位于资产根目录之外(可用 `--asset-root` 补充目录;原消息下会保留文件名)。
|
|
155
|
+
|
|
156
|
+
### 上下文快照里的 Token 数值是实际账单吗?
|
|
157
|
+
|
|
158
|
+
**不是。** 它用于观察上下文结构与增长趋势:原始日志带真实统计(含压缩前后 `preTokens` / `postTokens`)时直接显示,缺失步级或分类明细时按内容长度估算。
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 参与贡献与开源协议
|
|
163
|
+
|
|
164
|
+
架构说明与开发命令见 [`AGENTS.md`](./AGENTS.md),统一领域术语见 [`GLOSSARY.md`](./GLOSSARY.md)。提交改动前运行 `pnpm test` 验证适配器、脱敏规则与播放器构建产物一致性;如需支持其他 AI Agent 日志格式,欢迎提交 Issue。
|
|
129
165
|
|
|
130
166
|
[MIT](./LICENSE)
|
package/bin/encore.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from 'node:fs'
|
|
3
3
|
import { on } from 'node:events'
|
|
4
|
-
import { dirname, join, relative, resolve } from 'node:path'
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
6
|
import { parseArgs } from 'node:util'
|
|
7
7
|
import readline from 'node:readline'
|
|
@@ -16,15 +16,16 @@ import {
|
|
|
16
16
|
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json')
|
|
17
17
|
|
|
18
18
|
const HELP = `
|
|
19
|
-
encore (@niracler/encore) —
|
|
19
|
+
encore (@niracler/encore) — Replay an AI Agent session to see how it worked and what it delivered.
|
|
20
20
|
|
|
21
21
|
Usage:
|
|
22
22
|
encore Scan recent Codex, Claude Code & WorkBuddy sessions and pick one interactively
|
|
23
|
-
encore <log.jsonl | dir> [options] Build a
|
|
23
|
+
encore <log.jsonl | dir> [options] Build a replay from a raw log, or rebuild an existing replay directory
|
|
24
24
|
encore play <dir> [--port 4180] Start local preview server for an existing replay directory
|
|
25
25
|
|
|
26
26
|
Options:
|
|
27
|
-
-o, --out <dir> Output directory (default:
|
|
27
|
+
-o, --out <dir> Output directory (default: temporary directory)
|
|
28
|
+
--asset-root <dir> Set allowed asset roots for attachments and deliverables (repeatable; defaults to cwd and native session workspace)
|
|
28
29
|
-l, --lang <zh|en|auto> Player UI language (default: auto)
|
|
29
30
|
--title <text> Override session title
|
|
30
31
|
--desc <text> Set opening description shown before playback starts
|
|
@@ -44,25 +45,46 @@ Options:
|
|
|
44
45
|
-h, --help Show this help message
|
|
45
46
|
`.trim()
|
|
46
47
|
|
|
47
|
-
function
|
|
48
|
+
async function withBuildProgress(build) {
|
|
49
|
+
const output = process.stderr
|
|
50
|
+
if (!output.isTTY) return build()
|
|
51
|
+
|
|
52
|
+
const frames = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
|
|
53
|
+
let index = 0
|
|
54
|
+
const draw = () => output.write(`\r${frames[index++ % frames.length]} Building replay…`)
|
|
55
|
+
draw()
|
|
56
|
+
const timer = setInterval(draw, 100)
|
|
57
|
+
try {
|
|
58
|
+
return await build()
|
|
59
|
+
} finally {
|
|
60
|
+
clearInterval(timer)
|
|
61
|
+
readline.cursorTo(output, 0)
|
|
62
|
+
readline.clearLine(output, 0)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function printBuildReport(result, { isTempDefault = false } = {}) {
|
|
48
67
|
const { mode, toolLabel, dir, sessionFile, session, leaks } = result
|
|
49
|
-
const
|
|
50
|
-
const
|
|
68
|
+
const shownDir = displayPath(dir)
|
|
69
|
+
const shownSession = displayPath(sessionFile)
|
|
51
70
|
const count = type => (session.items || []).filter(item => item.type === type).length
|
|
52
71
|
const framesCount = (session.frames || []).length
|
|
53
|
-
const action = mode === 'rebuild' ? '
|
|
72
|
+
const action = mode === 'rebuild' ? 'Rebuilt' : 'Built'
|
|
54
73
|
|
|
55
|
-
console.log(`\n✨ ${action} replay in ${
|
|
74
|
+
console.log(`\n✨ ${action} replay in ${shownDir.endsWith(sep) ? shownDir : `${shownDir}${sep}`}`)
|
|
56
75
|
console.log(` Title : ${session.title}`)
|
|
57
76
|
console.log(` Agent : ${toolLabel}${session.model ? ` · ${session.model}` : ''}`)
|
|
58
|
-
console.log(`
|
|
77
|
+
console.log(` Events : ${count('user')} user messages · ${count('assistant')} replies · ${count('tool')} tool calls${count('compact') ? ` · ${count('compact')} compactions` : ''}`)
|
|
59
78
|
if (framesCount) {
|
|
60
|
-
console.log(` Frames : ${framesCount} WebP
|
|
79
|
+
console.log(` Frames : ${framesCount} WebP frame(s) in frames[] (edit ${shownSession} to curate or relabel)`)
|
|
61
80
|
}
|
|
62
81
|
console.log(` Files : index.html, session.json, encore-player.js, encore-player.css`)
|
|
82
|
+
if (mode === 'import' && isTempDefault) {
|
|
83
|
+
console.log(` Note : Saved to a temporary directory. Pass -o <dir> to keep a portable copy.`)
|
|
84
|
+
}
|
|
63
85
|
|
|
64
86
|
if (leaks.length) {
|
|
65
|
-
console.log(`\n⚠️
|
|
87
|
+
console.log(`\n⚠️ Leak check found ${leaks.length} potential sensitive snippet(s) (non-blocking — review in ${shownSession}):`)
|
|
66
88
|
for (const leak of leaks.slice(0, 12)) {
|
|
67
89
|
console.log(` - ${leak.path} · ${leak.rule} · ${leak.match}`)
|
|
68
90
|
}
|
|
@@ -72,6 +94,12 @@ function printBuildReport(result) {
|
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
96
|
|
|
97
|
+
function displayPath(targetPath) {
|
|
98
|
+
const rel = relative(process.cwd(), targetPath)
|
|
99
|
+
if (!rel) return '.'
|
|
100
|
+
return rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel) ? rel : targetPath
|
|
101
|
+
}
|
|
102
|
+
|
|
75
103
|
function truncateToColumns(str, maxCols) {
|
|
76
104
|
let width = 0
|
|
77
105
|
let out = ''
|
|
@@ -98,7 +126,7 @@ async function pickRecentSessionInteractive() {
|
|
|
98
126
|
console.log(` [${idx + 1}] ${s.timeLabel} · ${s.toolLabel.padEnd(11)} · ${s.preview}`)
|
|
99
127
|
console.log(` ${s.file} (${s.sizeKB} KB)`)
|
|
100
128
|
})
|
|
101
|
-
console.log('\nRun: encore <file-path> -o ./
|
|
129
|
+
console.log('\nRun: encore <file-path> -o ./my-replay')
|
|
102
130
|
return null
|
|
103
131
|
}
|
|
104
132
|
|
|
@@ -197,6 +225,7 @@ async function main() {
|
|
|
197
225
|
allowPositionals: true,
|
|
198
226
|
options: {
|
|
199
227
|
out: { type: 'string', short: 'o' },
|
|
228
|
+
'asset-root': { type: 'string', multiple: true },
|
|
200
229
|
lang: { type: 'string', short: 'l' },
|
|
201
230
|
title: { type: 'string' },
|
|
202
231
|
desc: { type: 'string' },
|
|
@@ -229,15 +258,16 @@ async function main() {
|
|
|
229
258
|
// Subcommand: `encore play <dir>` or `encore preview <dir>`
|
|
230
259
|
if (positionals[0] === 'play' || positionals[0] === 'preview') {
|
|
231
260
|
const targetDir = resolve(positionals[1] || '.')
|
|
232
|
-
const rebuilt = await rebuildReplayDir(targetDir, {
|
|
261
|
+
const rebuilt = await withBuildProgress(() => rebuildReplayDir(targetDir, {
|
|
262
|
+
assetRoots: values['asset-root'],
|
|
233
263
|
lang: values.lang,
|
|
234
264
|
title: values.title,
|
|
235
265
|
description: values.desc,
|
|
236
|
-
})
|
|
266
|
+
}))
|
|
237
267
|
printBuildReport(rebuilt)
|
|
238
268
|
const { url } = await serveReplayDir(rebuilt.dir, { port, open: !hasNoOpen })
|
|
239
|
-
console.log(`\n🎬
|
|
240
|
-
console.log(` Tip: Edit ${
|
|
269
|
+
console.log(`\n🎬 Replay live at ${url} (Ctrl+C to stop)`)
|
|
270
|
+
console.log(` Tip: Edit ${displayPath(rebuilt.sessionFile)} and refresh the browser to see changes immediately.`)
|
|
241
271
|
return
|
|
242
272
|
}
|
|
243
273
|
|
|
@@ -272,7 +302,8 @@ async function main() {
|
|
|
272
302
|
explicitTool = picked.tool
|
|
273
303
|
}
|
|
274
304
|
|
|
275
|
-
const result = await buildReplay(targets, {
|
|
305
|
+
const result = await withBuildProgress(() => buildReplay(targets, {
|
|
306
|
+
assetRoots: values['asset-root'],
|
|
276
307
|
tool: explicitTool,
|
|
277
308
|
outDir: values.out,
|
|
278
309
|
lang: values.lang || 'auto',
|
|
@@ -285,15 +316,15 @@ async function main() {
|
|
|
285
316
|
clip: values.clip ? Number(values.clip) : undefined,
|
|
286
317
|
conversation: values.conversation,
|
|
287
318
|
includeMemory: hasIncludeMemory,
|
|
288
|
-
})
|
|
319
|
+
}))
|
|
289
320
|
|
|
290
|
-
printBuildReport(result)
|
|
321
|
+
printBuildReport(result, { isTempDefault: !values.out })
|
|
291
322
|
|
|
292
323
|
const shouldServe = hasServe || (!hasNoServe && Boolean(process.stdin.isTTY && process.stdout.isTTY))
|
|
293
324
|
if (shouldServe) {
|
|
294
325
|
const { url } = await serveReplayDir(result.dir, { port, open: !hasNoOpen })
|
|
295
|
-
console.log(`\n🎬
|
|
296
|
-
console.log(` Tip: Edit ${
|
|
326
|
+
console.log(`\n🎬 Replay live at ${url} (Ctrl+C to stop)`)
|
|
327
|
+
console.log(` Tip: Edit ${displayPath(result.sessionFile)} and refresh the browser to see changes immediately.`)
|
|
297
328
|
}
|
|
298
329
|
}
|
|
299
330
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niracler/encore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A curtain call for your AI agent runs. Replay Codex, Claude Code, Claude.ai, and WorkBuddy sessions as an interactive web stage with a live context-window inspector.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
"node": ">=20.10.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@hyzyla/pdfium": "2.1.13",
|
|
59
|
+
"node-xlsx": "0.25.0",
|
|
58
60
|
"sharp": "^0.35.5"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
"scripts": {
|
|
64
66
|
"build:player": "node -e \"import('./src/player-assets.mjs').then(m => m.buildStandalonePlayerJs())\"",
|
|
65
67
|
"build:site": "node scripts/build-site.mjs",
|
|
66
|
-
"pretest": "
|
|
68
|
+
"pretest": "node -e \"import('./src/player-assets.mjs').then(m => m.buildStandalonePlayerJs())\"",
|
|
67
69
|
"release": "pnpm publish && git push origin main --follow-tags && gh release create \"v$(node -p \"require('./package.json').version\")\" --generate-notes",
|
|
68
70
|
"test": "node --test test/*.test.mjs"
|
|
69
71
|
}
|