@niracler/encore 0.3.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 +41 -109
- package/README.zh-CN.md +41 -109
- package/bin/encore.mjs +9 -100
- package/package.json +2 -2
- package/player/encore-player.css +42 -43
- package/player/encore-player.js +145 -201
- package/schema/session.schema.json +1 -1
- package/skills/encore/SKILL.md +2 -2
- package/src/antigravity.mjs +162 -0
- package/src/common.mjs +5 -2
- package/src/detect.mjs +96 -51
- package/src/external-files.mjs +22 -5
- package/src/i18n.mjs +1 -3
- package/src/index.d.ts +5 -2
- package/src/index.mjs +17 -6
- package/src/player-runtime.mjs +95 -121
- package/src/render.mjs +35 -70
- package/src/session-picker.mjs +162 -0
- package/src/timeline.mjs +12 -5
package/README.md
CHANGED
|
@@ -3,40 +3,25 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://encore.niracler.com/?lang=en"><strong>
|
|
7
|
-
<a href="https://www.npmjs.com/package/@niracler/encore"><strong>npm</strong></a> ·
|
|
8
|
-
<a href="./README.md"><strong>English</strong></a> ·
|
|
6
|
+
<a href="https://encore.niracler.com/?demo=poster-redesign&lang=en"><strong>Watch Codex redesign a course poster</strong></a> ·
|
|
9
7
|
<a href="./README.zh-CN.md">简体中文</a>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
12
|
-
|
|
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
|
-

|
|
22
|
-
|
|
23
|
-
---
|
|
10
|
+
[](https://encore.niracler.com/?demo=poster-redesign&lang=en)
|
|
24
11
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
Requires **Node.js >= 20.10**. No global install needed.
|
|
12
|
+
## Replay your own session
|
|
28
13
|
|
|
29
14
|
```bash
|
|
30
15
|
npx @niracler/encore@latest
|
|
31
16
|
```
|
|
32
17
|
|
|
33
|
-
|
|
18
|
+
Requires Node.js 20.10 or later. Choose a local Codex, Claude Code, WorkBuddy or Antigravity session to open its replay in your browser. Press `Tab` to switch agents and `/` to search titles and first user messages in the current tab. Search includes identifiable archived sessions. `Esc` restores your previous position.
|
|
34
19
|
|
|
35
|
-
|
|
20
|
+
Antigravity App and CLI share a tab with the source shown on each row. The picker prefers `transcript_full.jsonl` and falls back to `transcript.jsonl`. Passing a path imports exactly that file. The picker reads the Antigravity index using Node’s built-in SQLite or a local `sqlite3` executable. If the index is unavailable, it uses transcripts and title annotations and cannot identify archives recorded only in the index. For Claude.ai, pass the path to your exported `conversations.json` to the same command.
|
|
36
21
|
|
|
37
|
-
|
|
22
|
+
Encore writes to a temporary directory by default. To keep the replay, add `-o ./my-replay` to the command.
|
|
38
23
|
|
|
39
|
-
## How
|
|
24
|
+
## How it works
|
|
40
25
|
|
|
41
26
|
<p align="center">
|
|
42
27
|
<picture>
|
|
@@ -46,121 +31,68 @@ Without `-o`, replays write to a temporary directory. Pass `-o <dir>` to keep a
|
|
|
46
31
|
</picture>
|
|
47
32
|
</p>
|
|
48
33
|
|
|
49
|
-
|
|
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
|
-
---
|
|
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
|
|
34
|
+
## FAQ
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+
<details>
|
|
37
|
+
<summary>Does Encore upload my logs? What should I check before sharing?</summary>
|
|
66
38
|
|
|
67
|
-
|
|
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
|
|
39
|
+
Export runs locally. Encore redacts common secrets, email addresses and local paths in `session.json`. Before publishing, review the conversation, screenshots and attachments for details such as internal project names or business figures. PDFs, spreadsheets and other attachments are copied as they are.
|
|
71
40
|
|
|
72
|
-
|
|
41
|
+
To pick screenshots, trim the conversation or write an introduction, install the [Encore skill](./skills/encore/SKILL.md) and ask your agent to prepare your latest session for sharing.
|
|
73
42
|
|
|
74
43
|
```bash
|
|
75
44
|
npx skills add niracler/encore -g
|
|
76
45
|
```
|
|
77
46
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
Use the encore skill to export my latest session and curate it for publishing.
|
|
82
|
-
```
|
|
83
|
-
|
|
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.
|
|
85
|
-
|
|
86
|
-
---
|
|
47
|
+
</details>
|
|
87
48
|
|
|
88
|
-
|
|
49
|
+
<details>
|
|
50
|
+
<summary>How do I reopen a saved replay?</summary>
|
|
89
51
|
|
|
90
|
-
|
|
52
|
+
If you saved it with `-o ./my-replay`, run:
|
|
91
53
|
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
<div data-encore-player src="./session.json" data-lang="en"></div>
|
|
95
|
-
<script src="./encore-player.js" defer></script>
|
|
54
|
+
```bash
|
|
55
|
+
npx @niracler/encore@latest play ./my-replay
|
|
96
56
|
```
|
|
97
57
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<details>
|
|
101
|
-
<summary><strong><code>session.json</code> Schema</strong></summary>
|
|
102
|
-
|
|
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)
|
|
104
|
-
|
|
105
|
-
```json
|
|
106
|
-
{
|
|
107
|
-
"$schema": "https://encore.niracler.com/schema/session.schema.json",
|
|
108
|
-
"tool": "codex",
|
|
109
|
-
"model": "gpt-5.4",
|
|
110
|
-
"title": "Redesigning the 7-Stage Architecture Diagram",
|
|
111
|
-
"description": "Started with a cluttered layout, pivoted to a two-column grid after visual review, and exported the final SVG.",
|
|
112
|
-
"lang": "en",
|
|
113
|
-
"contextWindow": 258400,
|
|
114
|
-
"deliverables": [{ "title": "Final Diagram", "href": "./final-diagram.webp", "meta": "SVG / WebP · 1920×1080" }],
|
|
115
|
-
"frames": [{ "time": "2026-11-17T10:04:12.000Z", "img": "a1b2c3d4e5f6.webp", "who": "ai", "label": "Draft 1", "w": 960, "h": 540 }],
|
|
116
|
-
"items": [
|
|
117
|
-
{ "type": "user", "text": "...", "time": "..." },
|
|
118
|
-
{ "type": "tool", "name": "exec_command", "summary": "...", "stats": { "command": 1 }, "time": "..." },
|
|
119
|
-
{ "type": "compact", "seq": 1, "trigger": "auto", "preTokens": 210000, "postTokens": 42000, "time": "..." },
|
|
120
|
-
{ "type": "assistant", "text": "...", "time": "..." }
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
```
|
|
58
|
+
This starts a local preview server. Opening `index.html` directly can cause the browser to block access to `session.json`.
|
|
124
59
|
|
|
125
60
|
</details>
|
|
126
61
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
## FAQ
|
|
130
|
-
|
|
131
|
-
### Does Encore upload my logs? How does redaction work?
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Can I delete the original log after exporting?</summary>
|
|
132
64
|
|
|
133
|
-
|
|
65
|
+
Yes. Keep the entire replay directory, which includes the collected attachments. External links still depend on their original hosts.
|
|
134
66
|
|
|
135
|
-
|
|
136
|
-
- **Manual review still needed**: Project codenames, business figures, and raw files copied into `attachments/` (PDFs, workbooks, images, videos) are never rewritten automatically.
|
|
67
|
+
</details>
|
|
137
68
|
|
|
138
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>How do I embed a replay on my site?</summary>
|
|
139
71
|
|
|
140
|
-
|
|
72
|
+
Upload the entire replay directory to a static host to give it its own URL. To embed it in an existing page, point these three lines at your replay directory:
|
|
141
73
|
|
|
142
|
-
```
|
|
143
|
-
|
|
74
|
+
```html
|
|
75
|
+
<link rel="stylesheet" href="./my-replay/encore-player.css">
|
|
76
|
+
<div data-encore-player src="./my-replay/session.json" data-lang="en"></div>
|
|
77
|
+
<script src="./my-replay/encore-player.js" defer></script>
|
|
144
78
|
```
|
|
145
79
|
|
|
146
|
-
|
|
80
|
+
To customize the replay data, see the [JSON Schema](./schema/session.schema.json) and [TypeScript types](./src/index.d.ts).
|
|
147
81
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### Why is an attachment labeled as an export-time copy or missing?
|
|
82
|
+
</details>
|
|
151
83
|
|
|
152
|
-
|
|
153
|
-
|
|
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).
|
|
84
|
+
<details>
|
|
85
|
+
<summary>What do the attachment labels mean?</summary>
|
|
155
86
|
|
|
156
|
-
|
|
87
|
+
A verified file matches the SHA-256 checksum recorded in the log. An export-time copy was found on disk, but its contents could not be verified against the session. A missing or excluded file could not be found or was outside the allowed directories. Use `--asset-root` to specify a directory to collect files from.
|
|
157
88
|
|
|
158
|
-
|
|
89
|
+
</details>
|
|
159
90
|
|
|
160
|
-
|
|
91
|
+
<details>
|
|
92
|
+
<summary>Can I use the context token counts to check my bill?</summary>
|
|
161
93
|
|
|
162
|
-
|
|
94
|
+
The counts show how the context changes during a session. Encore uses recorded counts where available and estimates missing step or category counts from content length.
|
|
163
95
|
|
|
164
|
-
|
|
96
|
+
</details>
|
|
165
97
|
|
|
166
|
-
[MIT](./LICENSE)
|
|
98
|
+
[Contributing](./AGENTS.md) · [Glossary](./GLOSSARY.md) · [npm](https://www.npmjs.com/package/@niracler/encore) · [MIT](./LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -3,38 +3,23 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://encore.niracler.com/?lang=zh"><strong
|
|
7
|
-
<a href="
|
|
8
|
-
<a href="./README.md">English</a> ·
|
|
9
|
-
<a href="./README.zh-CN.md"><strong>简体中文</strong></a>
|
|
6
|
+
<a href="https://encore.niracler.com/?demo=poster-redesign&lang=zh"><strong>看回放:Codex 重新设计课程海报</strong></a> ·
|
|
7
|
+
<a href="./README.md">English</a>
|
|
10
8
|
</p>
|
|
11
9
|
|
|
12
|
-
|
|
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
|
-

|
|
22
|
-
|
|
23
|
-
---
|
|
10
|
+
[](https://encore.niracler.com/?demo=poster-redesign&lang=zh)
|
|
24
11
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
需要 **Node.js >= 20.10**,无需全局安装。
|
|
12
|
+
## 回看自己的会话
|
|
28
13
|
|
|
29
14
|
```bash
|
|
30
15
|
npx @niracler/encore@latest
|
|
31
16
|
```
|
|
32
17
|
|
|
33
|
-
|
|
18
|
+
需要 Node.js 20.10 或更高版本。从「全部」或 Agent 标签中选择一段 Codex、Claude Code、WorkBuddy 或 Antigravity 会话,即可在浏览器中回看。按 `Tab` 切换标签,按 `/` 搜索当前标签下的标题和首条用户消息,按 `Esc` 返回原位置。搜索也会列出能识别的归档会话。
|
|
34
19
|
|
|
35
|
-
|
|
20
|
+
Antigravity App 和 CLI 共用一个标签,每行显示来源。选择器优先使用 `transcript_full.jsonl`,缺少时读取 `transcript.jsonl`。手动传入路径时,Encore 读取指定文件。会话选择器通过 Node.js 内置 SQLite 或本机的 `sqlite3` 读取 Antigravity 索引。索引不可用时,使用本地日志和标题文件,此时无法识别索引中的归档状态。要回看 Claude.ai 会话,把导出的 `conversations.json` 路径传给同一条命令即可。
|
|
36
21
|
|
|
37
|
-
|
|
22
|
+
回放默认写入系统临时目录。想保留下来,可以在命令末尾加上 `-o ./my-replay`。
|
|
38
23
|
|
|
39
24
|
## 工作原理
|
|
40
25
|
|
|
@@ -46,121 +31,68 @@ npx @niracler/encore@latest
|
|
|
46
31
|
</picture>
|
|
47
32
|
</p>
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
- **会话数据与播放器分离**:`session.json`、提取出的 `.webp` 画面帧与收录文件都与零依赖播放器同目录存放,编辑 `session.json` 后刷新页面即可生效。
|
|
51
|
-
- **明确的文件收集边界**:自动收集允许的资产根目录(默认为当前工作目录与原始会话工作区,可用 `--asset-root` 覆盖)内日志明确引用的附件与交付物,生成 PDF 与表格的页内预览,并在原消息下标注「已核对版本」「导出时的副本」或「原文件缺失」。
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## 发布前整理(可选)
|
|
56
|
-
|
|
57
|
-
个人复盘或内部留档时,CLI 导出的回放已经可以直接观看,不需要安装技能。准备公开发布到博客、课程或展示页时,可以配合 `encore` 技能在导出结果上做一轮语义整理。
|
|
58
|
-
|
|
59
|
-
**CLI 自动导出已完成**
|
|
60
|
-
|
|
61
|
-
- 转换原始日志,提取去重 `.webp` 画面帧,收集资产根目录内引用的附件与交付物并生成页内预览
|
|
62
|
-
- 对常见密钥、私钥、JWT、数据库连接串、邮箱、内网 IP 与本机路径自动脱敏,默认省略 `MEMORY_SUMMARY` 与用户级 `CLAUDE.md` 正文,并输出非阻塞泄露检查预警
|
|
63
|
-
- 打包独立的回放目录与零依赖播放器
|
|
34
|
+
## 常见问题
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+
<details>
|
|
37
|
+
<summary>日志会上传吗?分享前要检查什么?</summary>
|
|
66
38
|
|
|
67
|
-
|
|
68
|
-
- **撰写导读与裁剪轮次**:结合上下文撰写标题(`title`)与开场说明(`description`),删去首尾无关轮次
|
|
69
|
-
- **人工脱敏与附件复核**:处理泄露检查预警,清理正则识别不出的内部代号、人名与业务数据,并核对 `attachments/` 中的原件
|
|
70
|
-
- **无损重建同步**:整理完成后运行 `npx @niracler/encore@latest <回放目录>`,刷新播放器与预览、同步页面 `<title>`、清理已删画面帧引用并重跑泄露检查(保留整理修改与补充媒体)
|
|
39
|
+
导出在本机完成。Encore 会在 `session.json` 中隐藏常见密钥、邮箱和本机路径。公开前请检查对话、截图和附件,尤其是项目代号和业务数据。PDF、表格等附件会按原样复制。
|
|
71
40
|
|
|
72
|
-
|
|
41
|
+
需要挑选截图、裁剪对话或写导读时,可以安装 [Encore 技能](./skills/encore/SKILL.md),然后告诉 Agent:「把我刚才的会话整理成可以分享的回放。」
|
|
73
42
|
|
|
74
43
|
```bash
|
|
75
44
|
npx skills add niracler/encore -g
|
|
76
45
|
```
|
|
77
46
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
用 encore 技能把我刚才那段对话导出并整理一下。
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
> **公开分享前请复核**:自动脱敏只改写 `session.json`,不会修改 `attachments/` 中复制进来的 PDF、工作簿、图片或视频原件。发布前请检查 `session.json`、保留的 `.webp` 画面帧以及所有打包的附件和交付物。
|
|
85
|
-
|
|
86
|
-
---
|
|
47
|
+
</details>
|
|
87
48
|
|
|
88
|
-
|
|
49
|
+
<details>
|
|
50
|
+
<summary>怎样重新打开保存的回放?</summary>
|
|
89
51
|
|
|
90
|
-
|
|
52
|
+
如果用 `-o ./my-replay` 保存过回放,运行:
|
|
91
53
|
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
<div data-encore-player src="./session.json" data-lang="zh"></div>
|
|
95
|
-
<script src="./encore-player.js" defer></script>
|
|
54
|
+
```bash
|
|
55
|
+
npx @niracler/encore@latest play ./my-replay
|
|
96
56
|
```
|
|
97
57
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<details>
|
|
101
|
-
<summary><strong><code>session.json</code> 核心结构</strong></summary>
|
|
102
|
-
|
|
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)。
|
|
104
|
-
|
|
105
|
-
```json
|
|
106
|
-
{
|
|
107
|
-
"$schema": "https://encore.niracler.com/schema/session.schema.json",
|
|
108
|
-
"tool": "codex",
|
|
109
|
-
"model": "gpt-5.4",
|
|
110
|
-
"title": "定下像素风和红发主角·课程海报视觉探索",
|
|
111
|
-
"description": "从信息过载的第一版草图出发,确立三阶段路线图,最终定版像素风课程海报。",
|
|
112
|
-
"lang": "zh",
|
|
113
|
-
"contextWindow": 258400,
|
|
114
|
-
"deliverables": [{ "title": "定版课程海报", "href": "./final-poster.webp", "meta": "WebP · 1920×1080" }],
|
|
115
|
-
"frames": [{ "time": "2026-11-17T10:04:12.000Z", "img": "a1b2c3d4e5f6.webp", "who": "ai", "label": "像素风草图", "w": 960, "h": 540 }],
|
|
116
|
-
"items": [
|
|
117
|
-
{ "type": "user", "text": "...", "time": "..." },
|
|
118
|
-
{ "type": "tool", "name": "exec_command", "summary": "...", "stats": { "command": 1 }, "time": "..." },
|
|
119
|
-
{ "type": "compact", "seq": 1, "trigger": "auto", "preTokens": 210000, "postTokens": 42000, "time": "..." },
|
|
120
|
-
{ "type": "assistant", "text": "...", "time": "..." }
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
```
|
|
58
|
+
这会启动本地预览服务。直接双击 `index.html` 时,浏览器可能会拦截对 `session.json` 的读取。
|
|
124
59
|
|
|
125
60
|
</details>
|
|
126
61
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
## 常见问题
|
|
130
|
-
|
|
131
|
-
### 日志会上传吗?隐私怎么处理?
|
|
62
|
+
<details>
|
|
63
|
+
<summary>删掉原始日志后还能回放吗?</summary>
|
|
132
64
|
|
|
133
|
-
|
|
65
|
+
可以。保留整个回放目录即可,已收录的附件也在里面。外部链接仍依赖原地址。
|
|
134
66
|
|
|
135
|
-
|
|
136
|
-
- **需人工复核**:项目代号、业务数据,以及 `attachments/` 里复制进来的原件(PDF、工作簿、图片、视频)不会被自动改写。
|
|
67
|
+
</details>
|
|
137
68
|
|
|
138
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>怎样把回放嵌入自己的网页?</summary>
|
|
139
71
|
|
|
140
|
-
|
|
72
|
+
将整个回放目录上传到静态网站即可单独访问。要嵌入已有页面,引入目录中的三个文件(示例假设目录名为 `my-replay`):
|
|
141
73
|
|
|
142
|
-
```
|
|
143
|
-
|
|
74
|
+
```html
|
|
75
|
+
<link rel="stylesheet" href="./my-replay/encore-player.css">
|
|
76
|
+
<div data-encore-player src="./my-replay/session.json" data-lang="zh"></div>
|
|
77
|
+
<script src="./my-replay/encore-player.js" defer></script>
|
|
144
78
|
```
|
|
145
79
|
|
|
146
|
-
|
|
80
|
+
自定义回放数据可查阅 [JSON Schema](./schema/session.schema.json) 和 [TypeScript 类型](./src/index.d.ts)。
|
|
147
81
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### 为什么附件会标为「导出时的副本」或「原文件缺失」?
|
|
82
|
+
</details>
|
|
151
83
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
- **原文件缺失 / 未收录**:日志引用了该文件,但导出时在磁盘上已找不到,或位于资产根目录之外(可用 `--asset-root` 补充目录;原消息下会保留文件名)。
|
|
84
|
+
<details>
|
|
85
|
+
<summary>附件旁边的状态是什么意思?</summary>
|
|
155
86
|
|
|
156
|
-
|
|
87
|
+
「已核对版本」表示文件的 SHA-256 与日志记录一致。「导出时的副本」表示找到了文件,但无法确认它与会话当时的版本一致。「原文件缺失」或「未收录」表示文件找不到或在允许收集的目录之外。可以用 `--asset-root` 指定收集目录。
|
|
157
88
|
|
|
158
|
-
|
|
89
|
+
</details>
|
|
159
90
|
|
|
160
|
-
|
|
91
|
+
<details>
|
|
92
|
+
<summary>上下文里的 Token 数能用来核对账单吗?</summary>
|
|
161
93
|
|
|
162
|
-
|
|
94
|
+
这些数值用于观察会话中的上下文变化。日志提供统计时使用记录值,缺少的步骤或分类明细按内容长度估算。
|
|
163
95
|
|
|
164
|
-
|
|
96
|
+
</details>
|
|
165
97
|
|
|
166
|
-
[MIT](./LICENSE)
|
|
98
|
+
[开发与贡献](./AGENTS.md) · [术语表](./GLOSSARY.md) · [npm](https://www.npmjs.com/package/@niracler/encore) · [MIT](./LICENSE)
|
package/bin/encore.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from 'node:fs'
|
|
3
|
-
import { on } from 'node:events'
|
|
4
3
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
5
4
|
import { fileURLToPath } from 'node:url'
|
|
6
|
-
import { parseArgs } from 'node:util'
|
|
7
5
|
import readline from 'node:readline'
|
|
8
|
-
import {
|
|
6
|
+
import { parseArgs } from 'node:util'
|
|
7
|
+
import { pickSession } from '../src/session-picker.mjs'
|
|
9
8
|
import {
|
|
10
9
|
buildReplay,
|
|
11
10
|
rebuildReplayDir,
|
|
12
11
|
scanRecentSessions,
|
|
12
|
+
tools,
|
|
13
13
|
serveReplayDir,
|
|
14
14
|
} from '../src/index.mjs'
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ const HELP = `
|
|
|
19
19
|
encore (@niracler/encore) — Replay an AI Agent session to see how it worked and what it delivered.
|
|
20
20
|
|
|
21
21
|
Usage:
|
|
22
|
-
encore Scan recent Codex, Claude Code &
|
|
22
|
+
encore Scan recent Codex, Claude Code, WorkBuddy & Antigravity sessions and pick one interactively
|
|
23
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
|
|
|
@@ -100,20 +100,7 @@ function displayPath(targetPath) {
|
|
|
100
100
|
return rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel) ? rel : targetPath
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function
|
|
104
|
-
let width = 0
|
|
105
|
-
let out = ''
|
|
106
|
-
for (const ch of String(str)) {
|
|
107
|
-
const code = ch.codePointAt(0)
|
|
108
|
-
const w = code > 0x1f00 ? 2 : 1
|
|
109
|
-
if (width + w > maxCols - 1) return `${out}…`
|
|
110
|
-
out += ch
|
|
111
|
-
width += w
|
|
112
|
-
}
|
|
113
|
-
return out
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function pickRecentSessionInteractive() {
|
|
103
|
+
async function pickRecentSessionInteractive(lang) {
|
|
117
104
|
const pageSize = 10
|
|
118
105
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
119
106
|
const sessions = await scanRecentSessions({ limit: pageSize })
|
|
@@ -130,85 +117,7 @@ async function pickRecentSessionInteractive() {
|
|
|
130
117
|
return null
|
|
131
118
|
}
|
|
132
119
|
|
|
133
|
-
|
|
134
|
-
const sessions = []
|
|
135
|
-
let exhausted = false
|
|
136
|
-
let selected = 0
|
|
137
|
-
let renderedLines = 0
|
|
138
|
-
|
|
139
|
-
async function loadPage(start) {
|
|
140
|
-
while (!exhausted && sessions.length <= start + pageSize) {
|
|
141
|
-
const next = await history.next()
|
|
142
|
-
if (next.done) exhausted = true
|
|
143
|
-
else sessions.push(next.value)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
await loadPage(0)
|
|
148
|
-
if (!sessions.length) {
|
|
149
|
-
console.log(HELP)
|
|
150
|
-
return null
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function renderMenu(start) {
|
|
154
|
-
if (renderedLines) {
|
|
155
|
-
readline.moveCursor(process.stdout, 0, -renderedLines)
|
|
156
|
-
readline.clearScreenDown(process.stdout)
|
|
157
|
-
}
|
|
158
|
-
const cols = Math.max(1, (process.stdout.columns || 80) - 2)
|
|
159
|
-
const page = sessions.slice(start, start + pageSize)
|
|
160
|
-
const last = exhausted && start + pageSize >= sessions.length
|
|
161
|
-
const heading = `Page ${start / pageSize + 1}${last ? ' (last)' : ''} · ←/→ page · ↑/↓ move · Enter select · q quit`
|
|
162
|
-
process.stdout.write(`${truncateToColumns(heading, cols)}\n\n`)
|
|
163
|
-
page.forEach((session, index) => {
|
|
164
|
-
const active = start + index === selected
|
|
165
|
-
const prefix = active ? ' ❯ ' : ' '
|
|
166
|
-
const num = String(index + 1).padStart(2, ' ')
|
|
167
|
-
const badge = `[${session.toolLabel}]`.padEnd(13, ' ')
|
|
168
|
-
const line = truncateToColumns(`${prefix}${num}. ${session.timeLabel} ${badge} ${session.preview} (${session.sizeKB} KB)`, cols)
|
|
169
|
-
process.stdout.write(`${active ? `\x1b[36m\x1b[1m${line}\x1b[0m` : line}\n`)
|
|
170
|
-
})
|
|
171
|
-
process.stdout.write('\n')
|
|
172
|
-
renderedLines = page.length + 3
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
readline.emitKeypressEvents(process.stdin)
|
|
176
|
-
const wasRaw = process.stdin.isRaw
|
|
177
|
-
process.stdin.setRawMode(true)
|
|
178
|
-
try {
|
|
179
|
-
let start = 0
|
|
180
|
-
renderMenu(start)
|
|
181
|
-
for await (const [str, key] of on(process.stdin, 'keypress')) {
|
|
182
|
-
if (key.name === 'q' || key.name === 'escape' || (key.ctrl && key.name === 'c')) {
|
|
183
|
-
return null
|
|
184
|
-
}
|
|
185
|
-
if (key.name === 'return' || key.name === 'enter') return sessions[selected]
|
|
186
|
-
if (key.name === 'left' || key.name === 'pageup') {
|
|
187
|
-
if (!start) continue
|
|
188
|
-
selected = start - pageSize
|
|
189
|
-
} else if (key.name === 'right' || key.name === 'pagedown') {
|
|
190
|
-
if (start + pageSize >= sessions.length) continue
|
|
191
|
-
selected = start + pageSize
|
|
192
|
-
} else if (key.name === 'up' || key.name === 'k') {
|
|
193
|
-
selected = Math.max(0, selected - 1)
|
|
194
|
-
} else if (key.name === 'down' || key.name === 'j') {
|
|
195
|
-
selected = Math.min(sessions.length - 1, selected + 1)
|
|
196
|
-
} else if (/^\d$/.test(str)) {
|
|
197
|
-
const index = start + (Number(str) || pageSize) - 1
|
|
198
|
-
if (index >= sessions.length) continue
|
|
199
|
-
selected = index
|
|
200
|
-
} else {
|
|
201
|
-
continue
|
|
202
|
-
}
|
|
203
|
-
start = Math.floor(selected / pageSize) * pageSize
|
|
204
|
-
await loadPage(start)
|
|
205
|
-
renderMenu(start)
|
|
206
|
-
}
|
|
207
|
-
} finally {
|
|
208
|
-
process.stdin.setRawMode(Boolean(wasRaw))
|
|
209
|
-
process.stdin.pause()
|
|
210
|
-
await history.return()
|
|
211
|
-
}
|
|
120
|
+
return pickSession({ lang })
|
|
212
121
|
}
|
|
213
122
|
|
|
214
123
|
async function main() {
|
|
@@ -274,7 +183,7 @@ async function main() {
|
|
|
274
183
|
if (values.list) {
|
|
275
184
|
const recent = await scanRecentSessions({ limit: 15 })
|
|
276
185
|
if (!recent.length) {
|
|
277
|
-
console.log('No recent
|
|
186
|
+
console.log('No recent local AI Agent sessions found.')
|
|
278
187
|
return
|
|
279
188
|
}
|
|
280
189
|
console.log('Recent local AI Agent sessions:\n')
|
|
@@ -290,13 +199,13 @@ async function main() {
|
|
|
290
199
|
targets = targets.slice(1)
|
|
291
200
|
}
|
|
292
201
|
let explicitTool
|
|
293
|
-
if (
|
|
202
|
+
if (Object.hasOwn(tools, targets[0]) && targets.length > 1) {
|
|
294
203
|
explicitTool = targets[0]
|
|
295
204
|
targets = targets.slice(1)
|
|
296
205
|
}
|
|
297
206
|
|
|
298
207
|
if (!targets.length) {
|
|
299
|
-
const picked = await pickRecentSessionInteractive()
|
|
208
|
+
const picked = await pickRecentSessionInteractive(values.lang)
|
|
300
209
|
if (!picked) return
|
|
301
210
|
targets = [picked.file]
|
|
302
211
|
explicitTool = picked.tool
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niracler/encore",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A curtain call for your AI agent runs. Replay Codex, Claude Code, Claude.ai, and
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A curtain call for your AI agent runs. Replay Codex, Claude Code, Claude.ai, WorkBuddy, and Antigravity sessions as an interactive web stage with a live context-window inspector.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"repository": {
|