@niracler/encore 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,118 +1,118 @@
1
- # Encore
1
+ <p align="center">
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
+ </p>
2
4
 
3
- **Bring your AI agent sessions back on stage.**
4
- *Like [`asciinema`](https://asciinema.org), but for AI Agent sessions (`Codex`, `Claude Code`, `Claude.ai`).*
5
+ <p align="center">
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
+ <a href="./README.md"><strong>English</strong></a> ·
9
+ <a href="./README.zh-CN.md">简体中文</a>
10
+ </p>
5
11
 
6
- [English](./README.md) · [简体中文](./README.zh-CN.md)
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>
7
18
 
8
- ![Encore Preview](./docs/preview-en.webp)
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
+ ![Encore Player showing the Step timeline on the left and the live Context Snapshot inspector on the right](./docs/preview-en.webp)
9
22
 
10
23
  ---
11
24
 
12
- ## Why Encore?
25
+ ## Quick Start
26
+
27
+ Requires **Node.js >= 20.10**. No global install needed.
13
28
 
14
- Screen recordings of AI coding or design sessions are blurry, bulky, and unsearchable. Plain Markdown chat exports strip away everything that actually matters in an agentic workflow: **what was inside the context window, which tools and sub-agents ran, how visual artifacts evolved step by step, and when context compaction fired.**
29
+ ```bash
30
+ npx @niracler/encore@latest
31
+ ```
15
32
 
16
- **Encore** turns raw session logs from **OpenAI Codex**, **Claude Code**, and **Claude.ai** into an interactive, self-contained web stage:
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.
17
34
 
18
- | Stage Area | What It Shows |
19
- | :--- | :--- |
20
- | **Left · Conversation & Artifact Stage** | Typewriter prompt composer, soft-breathing Markdown reply streaming, live tool call shimmer (`1.0×` / `12×` / `0.8×`), sub-agent dispatches & reports, inline `.webp` visual outputs, intermediate Markdown drafts, and audio/video deliverables. |
21
- | **Right · Live Context Window Inspector** | Real-time token gauge (`200k` / `1.0M`), 7-color stacked bar (`System Prompt`, `Tool Schemas & MCP`, `User Messages`, `Memory & Rules`, `Skills`, `Assistant`, `Tool Outputs`), auto-compaction headroom markers, and drill-down payload inspection for every step. |
22
- | **Bottom · Segmented Milestone Timeline** | Interactive step segments with pinned visual frames (`🖼`), draft documents (`📄`), context compactions (`🗜`), and user turns (`💬`). |
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.
23
36
 
24
37
  ---
25
38
 
26
- ## Architecture (Inspired by `asciinema`)
39
+ ## How It Works
27
40
 
28
- Encore separates data, player, and CLI into three clean layers:
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>
29
48
 
30
- 1. **Data Format (`session.json` + `.webp`)**: A self-contained, human-editable JSON file (analogous to `.cast` in `asciinema`) holding metadata (`title`, `description`, `deliverables`), visual milestone `frames`, initial context mounts, and normalized conversation `items`.
31
- 2. **Standalone Player (`encore-player.js` + `encore-player.css`)**: Zero-dependency drop-in browser player. Any HTML page can embed a replay with a single tag:
32
- ```html
33
- <link rel="stylesheet" href="./encore-player.css">
34
- <div data-encore-player src="./session.json" data-lang="en"></div>
35
- <script src="./encore-player.js" defer></script>
36
- ```
37
- 3. **CLI (`encore`)**: Auto-detects `Codex`, `Claude Code`, and `Claude.ai` logs, extracts embedded images into `.webp`, redacts local paths & secrets, writes the static replay folder, and serves a live local preview.
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.
38
52
 
39
53
  ---
40
54
 
41
- ## 30-Second Quick Start (Raw Cut)
55
+ ## Curating Before Publishing (Optional)
42
56
 
43
- ### 1. Pick from your recent local sessions
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.
44
58
 
45
- Run `encore` with no arguments to scan `~/.codex/sessions` and `~/.claude/projects` and pick a recent session with `↑` / `↓`:
59
+ **What the CLI handles automatically**
46
60
 
47
- ```bash
48
- npx @niracler/encore
49
- ```
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
50
64
 
51
- ### 2. Convert a specific log file directly
65
+ **What the `encore` skill adds during curation**
52
66
 
53
- Pass any `.jsonl` (or `.jsonl.zst` / Claude `.json` export) and Encore will auto-detect the format, extract embedded screenshots to `.webp`, mask sensitive strings, and launch a local preview:
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):
54
73
 
55
74
  ```bash
56
- npx @niracler/encore /path/to/rollout.jsonl -o ./replays/my-session
75
+ npx skills add niracler/encore -g
57
76
  ```
58
77
 
59
- ### 3. Edit `session.json` & refresh
60
-
61
- Because `index.html` loads `./session.json` dynamically, **any edit you make to `session.json` (changing `title`, adding `description`, renaming or deleting `frames`) appears immediately when you refresh the browser.**
78
+ Then ask your Agent from any workspace:
62
79
 
63
- You can also re-run `encore` on an existing replay directory to sync `<title>` in `index.html` and re-run the privacy leak check:
64
-
65
- ```bash
66
- npx @niracler/encore ./replays/my-session
80
+ ```text
81
+ Use the encore skill to export my latest session and curate it for publishing.
67
82
  ```
68
83
 
69
- ---
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.
70
85
 
71
- ## Agent Curation Workflow (Director's Cut)
86
+ ---
72
87
 
73
- Raw agent logs often contain 20+ repetitive screenshots, long first prompts instead of a clear title, or internal project names that regex redaction cannot catch.
88
+ ## Embedding on Any Site
74
89
 
75
- Encore ships with an all-in-one Agent Skill at [`skills/encore/SKILL.md`](./skills/encore/SKILL.md). Install or link it into `.agents/skills/encore` (or `~/.codex/skills/encore` / `~/.claude/skills/encore`) and ask your agent:
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:
76
91
 
77
- > *"Use the `encore` skill to export my latest session and curate `session.json` for publishing."*
92
+ ```html
93
+ <link rel="stylesheet" href="./encore-player.css">
94
+ <div data-encore-player src="./session.json" data-lang="en"></div>
95
+ <script src="./encore-player.js" defer></script>
96
+ ```
78
97
 
79
- The skill guides the agent through four curation steps:
80
- 1. **Visual Frame Pruning & Naming**: Visually inspects every extracted `.webp` image, deletes broken or redundant screenshots from `frames[]`, and writes concise narrative labels (e.g. `"V1 wireframe"`, `"Final dark-mode layout"`).
81
- 2. **Title & Opening Story Intro**: Writes a punchy `title` and a 1–3 sentence `description` explaining the problem, mid-session pivot, and outcome without fluff.
82
- 3. **Semantic Privacy Cleanup**: Scans `items[]` for internal codenames, colleague names, or sensitive business logic and replaces them with `(Internal context redacted)`.
83
- 4. **Time-Window Trimming**: Cuts unrelated off-topic turns at the start or end of a session.
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.
84
99
 
85
- ---
100
+ <details>
101
+ <summary><strong><code>session.json</code> Schema</strong></summary>
86
102
 
87
- ## `session.json` Schema Reference
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)
88
104
 
89
105
  ```json
90
106
  {
107
+ "$schema": "https://encore.niracler.com/schema/session.schema.json",
91
108
  "tool": "codex",
92
109
  "model": "gpt-5.4",
93
110
  "title": "Redesigning the 7-Stage Architecture Diagram",
94
111
  "description": "Started with a cluttered layout, pivoted to a two-column grid after visual review, and exported the final SVG.",
95
112
  "lang": "en",
96
- "started": "2026-11-17T10:00:00.000Z",
97
- "ended": "2026-11-17T10:18:30.000Z",
98
113
  "contextWindow": 258400,
99
- "deliverables": [
100
- {
101
- "title": "Final Architecture Diagram",
102
- "href": "./final-diagram.webp",
103
- "meta": "SVG / WebP · 1920×1080"
104
- }
105
- ],
106
- "frames": [
107
- {
108
- "time": "2026-11-17T10:04:12.000Z",
109
- "img": "a1b2c3d4e5f6.webp",
110
- "who": "ai",
111
- "label": "Draft 1: Overcrowded labels",
112
- "w": 960,
113
- "h": 540
114
- }
115
- ],
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
116
  "items": [
117
117
  { "type": "user", "text": "...", "time": "..." },
118
118
  { "type": "tool", "name": "exec_command", "summary": "...", "stats": { "command": 1 }, "time": "..." },
@@ -122,37 +122,45 @@ The skill guides the agent through four curation steps:
122
122
  }
123
123
  ```
124
124
 
125
+ </details>
126
+
125
127
  ---
126
128
 
127
- ## CLI Options
129
+ ## FAQ
128
130
 
129
- ```text
130
- Usage:
131
- encore Scan recent Codex & Claude Code sessions and pick one interactively
132
- encore <log.jsonl | dir> [options] Build a standalone replay directory from a log or re-render an edited session.json
133
- encore play <dir> [--port 4180] Start local preview server for an existing replay directory
134
-
135
- Options:
136
- -o, --out <dir> Output directory (default: ./replays/<session-slug>)
137
- -l, --lang <zh|en|auto> Player UI language (default: auto; also toggleable in the topbar)
138
- --title <text> Override session title
139
- --desc <text> Set opening description shown before playback starts
140
- --from <iso-time> Start time window filter (e.g. 2026-11-10T09:00)
141
- --to <iso-time> End time window filter
142
- --no-images Skip extracting embedded images to .webp
143
- --image-width <px> Max width for extracted WebP frames (default: 960)
144
- --clip <chars> Max chars per tool input/output (default: 1500/2000)
145
- --conversation <id> Conversation UUID for multi-chat Claude.ai exports
146
- --include-memory Include full cross-session MEMORY_SUMMARY / User CLAUDE.md text
147
- --list List recent local sessions without interactive prompt
148
- --serve Start local HTTP preview server after building
149
- --no-serve Do not start local HTTP preview server
150
- --no-open Do not automatically open browser when serving
151
- -p, --port <number> Preview server port (default: 4180)
152
- -v, --version Show version number
153
- -h, --help Show help message
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>
154
144
  ```
155
145
 
156
- ## License
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.
157
165
 
158
166
  [MIT](./LICENSE)
package/README.zh-CN.md CHANGED
@@ -1,115 +1,166 @@
1
- # Encore
1
+ <p align="center">
2
+ <img src="./docs/hero-zh.svg" alt="Encore · 回看一次 AI Agent 会话,看它怎么完成任务,交付了什么。" width="100%">
3
+ </p>
2
4
 
3
- **Bring your AI agent sessions back on stage.**
4
- *把 AI Agent 的工作现场搬回舞台再演一场 —— AI Agent 时代的 [`asciinema`](https://asciinema.org)(支持 `Codex`、`Claude Code`、`Claude.ai`)。*
5
+ <p align="center">
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
+ <a href="./README.md">English</a> ·
9
+ <a href="./README.zh-CN.md"><strong>简体中文</strong></a>
10
+ </p>
5
11
 
6
- [English](./README.md) · [简体中文](./README.zh-CN.md)
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>
7
18
 
8
- ![Encore 界面预览](./docs/preview-zh.webp)
19
+ **Encore** 是面向 AI Agent 会话的 [`asciinema`](https://asciinema.org)。它在本地将 **Codex**、**Claude Code**、**Claude.ai** 或 **WorkBuddy** 的原始日志转换为可独立托管的网页回放。打开回放后,读者可以按步骤查看对话轮次、工具调用、子 Agent 协作、画面帧与交付物,并在右侧同步查看上下文快照的增长与压缩。
20
+
21
+ ![Encore 播放器预览:左侧为会话步骤时间轴,右侧为实时上下文快照面板](./docs/preview-zh.webp)
9
22
 
10
23
  ---
11
24
 
12
- ## 它是干什么的?
25
+ ## 快速开始
26
+
27
+ 需要 **Node.js >= 20.10**,无需全局安装。
13
28
 
14
- 把 AI 编程或设计过程录成视频又糊又大,而导出成普通 Markdown 聊天记录又会丢掉 Agent 工作流里最精彩的部分:**每一轮上下文窗口(Context Window)里到底塞了什么、调用了哪些工具与子代理、中间视觉稿是怎么一版版演进出来的,以及什么时候触发了上下文压缩(Compaction)。**
29
+ ```bash
30
+ npx @niracler/encore@latest
31
+ ```
15
32
 
16
- **Encore** 将 **OpenAI Codex**、**Claude Code** 和 **Claude.ai** 的原始会话日志一键转换为可交互的独立网页剧场:
33
+ 命令会扫描本机最近的 **Codex**、**Claude Code** 与 **WorkBuddy** 会话,选中后在浏览器中打开回放;也可以直接传入 `.jsonl`、`.jsonl.zst` 或 Claude.ai 导出的 `conversations.json`。
17
34
 
18
- | 舞台区域 | 还原内容 |
19
- | :--- | :--- |
20
- | **左屏 · 对话流与作品演进** | 底部输入框打字上屏、Agent 回复呼吸感流式输出、工具调用流光快切(`1.0×` / `12×` / `0.8×`)、子任务派发与报告弹窗、内嵌 `.webp` 过程效果图、Markdown 中间草稿与音视频交付物。 |
21
- | **右屏 · Context 实时透视面板** | 实时显示上下文窗口水位(`200k` / `1.0M`)、7 色分段进度条(系统提示词、工具定义、用户消息、注入规则、技能、助手回复、工具输出)、自动压缩警戒线,点击任意消息或色块即可定格查看当时的原文载荷。 |
22
- | **底部 · 关键帧章节时间轴** | 按步骤切分的时间轴,自动钉出过程效果图(`🖼`)、中间文稿(`📄`)、上下文压缩(`🗜`)与提问轮次(`💬`)。 |
35
+ 未传 `-o` 时,回放默认写入系统临时目录;需要保存可移植副本或部署时,传入 `-o <目录>`。完整子命令与选项见 `npx @niracler/encore@latest --help`。
23
36
 
24
37
  ---
25
38
 
26
- ## 三层解耦架构(致敬 `asciinema`)
39
+ ## 工作原理
27
40
 
28
- 1. **标准数据格式(`session.json` + `.webp`)**:全量自包含、可直接手改的 JSON 文件(类比 `asciinema` 的 `.cast`),内含标题(`title`)、开场导读(`description`)、最终交付物(`deliverables`)、过程图片关键帧(`frames`)与对话记录(`items`)。
29
- 2. **独立播放器(`encore-player.js` + `encore-player.css`)**:零外部依赖的纯前端组件。生成的 `index.html` 极其干净,要在个人博客或文档站嵌入回放,只需一行标签:
30
- ```html
31
- <link rel="stylesheet" href="./encore-player.css">
32
- <div data-encore-player src="./session.json" data-lang="zh"></div>
33
- <script src="./encore-player.js" defer></script>
34
- ```
35
- 3. **CLI 转换与预览工具(`encore`)**:自动识别日志来源、默认导出 `.webp` 图片、自动脱敏本机路径与密钥(非阻塞告警)、生成静态目录并启动本地预览服务。
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 与表格的页内预览,并在原消息下标注「已核对版本」「导出时的副本」或「原文件缺失」。
36
52
 
37
53
  ---
38
54
 
39
- ## 30 秒上手(生肉直出)
55
+ ## 发布前整理(可选)
40
56
 
41
- ### 1. 免找文件:直接扫描本机最近对话
57
+ 个人复盘或内部留档时,CLI 导出的回放已经可以直接观看,不需要安装技能。准备公开发布到博客、课程或展示页时,可以配合 `encore` 技能在导出结果上做一轮语义整理。
42
58
 
43
- 在终端直接运行 `npx @niracler/encore`(不带参数),工具会自动扫描 `~/.codex/sessions` 和 `~/.claude/projects` 下最近的对话,显示时间与首句提问,按 `↑` / `↓` 挑一条回车即可导出并打开预览:
59
+ **CLI 自动导出已完成**
44
60
 
45
- ```bash
46
- npx @niracler/encore
47
- ```
61
+ - 转换原始日志,提取去重 `.webp` 画面帧,收集资产根目录内引用的附件与交付物并生成页内预览
62
+ - 对常见密钥、私钥、JWT、数据库连接串、邮箱、内网 IP 与本机路径自动脱敏,默认省略 `MEMORY_SUMMARY` 与用户级 `CLAUDE.md` 正文,并输出非阻塞泄露检查预警
63
+ - 打包独立的回放目录与零依赖播放器
64
+
65
+ **`encore` 技能负责发布前整理**
48
66
 
49
- ### 2. 指定日志文件一步直出
67
+ - **筛选与标注画面帧**:逐张查看 `.webp` 画面帧,剔除报错与冗余中间态,只保留里程碑画面并写清变化标签
68
+ - **撰写导读与裁剪轮次**:结合上下文撰写标题(`title`)与开场说明(`description`),删去首尾无关轮次
69
+ - **人工脱敏与附件复核**:处理泄露检查预警,清理正则识别不出的内部代号、人名与业务数据,并核对 `attachments/` 中的原件
70
+ - **无损重建同步**:整理完成后运行 `npx @niracler/encore@latest <回放目录>`,刷新播放器与预览、同步页面 `<title>`、清理已删画面帧引用并重跑泄露检查(保留整理修改与补充媒体)
50
71
 
51
- 无需手动指定是哪家工具的日志,`encore` 会自动识别文件内容:
72
+ 全局安装该技能(或手动复制 [`skills/encore/SKILL.md`](./skills/encore/SKILL.md)):
52
73
 
53
74
  ```bash
54
- npx @niracler/encore /path/to/rollout.jsonl -o ./replays/my-session
75
+ npx skills add niracler/encore -g
55
76
  ```
56
77
 
57
- ### 3. 改 `session.json` 实时生效
78
+ 之后在任意工作区直接告诉 Agent:
58
79
 
59
- 由于 `index.html` 动态读取同目录的 `./session.json`,**你在编辑器里修改 `session.json` 的标题、开场导读或删减图片后,直接刷新浏览器就能看到最新效果,无需重新编译。**
60
-
61
- 如果需要同步更新 `index.html` 的 `<title>` 标签或重新运行隐私脱敏检查,对目录再跑一次命令即可:
62
-
63
- ```bash
64
- npx @niracler/encore ./replays/my-session
80
+ ```text
81
+ 用 encore 技能把我刚才那段对话导出并整理一下。
65
82
  ```
66
83
 
84
+ > **公开分享前请复核**:自动脱敏只改写 `session.json`,不会修改 `attachments/` 中复制进来的 PDF、工作簿、图片或视频原件。发布前请检查 `session.json`、保留的 `.webp` 画面帧以及所有打包的附件和交付物。
85
+
67
86
  ---
68
87
 
69
- ## Agent 精修工作流(熟肉策展)
88
+ ## 嵌入网页
70
89
 
71
- 脚本一步直出的「生肉」回放里,往往夹杂着二三十张重复微调或报错的截图,标题也只是第一句长提问。
90
+ 使用 `-o ./replays/<会话短名>` 导出后,将整个回放目录部署到 GitHub Pages、Cloudflare Pages、Vercel 或任意静态托管服务即可直接访问,也可通过 3 行代码嵌入已有 HTML 页面:
72
91
 
73
- 仓库内置了配套的精修 Skill:[`skills/encore/SKILL.md`](./skills/encore/SKILL.md)。将它放入 `.agents/skills/encore`(或全局 `~/.codex/skills/encore` / `~/.claude/skills/encore`)后,直接对 Agent 说:
92
+ ```html
93
+ <link rel="stylesheet" href="./encore-player.css">
94
+ <div data-encore-player src="./session.json" data-lang="zh"></div>
95
+ <script src="./encore-player.js" defer></script>
96
+ ```
74
97
 
75
- > 「用 `encore` 技能把我刚才那段对话导出并精修一下。」
98
+ 省略 `data-lang` 时,界面语言自动跟随 `session.json` 的设置。播放器同时原生支持在 `session.json` 中手动挂载步骤音频(`item.audio`)、横竖屏视频切换与 PDF / 表格修订对照。
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
+ ```
76
124
 
77
- Agent 会自动完成 4 件事:
78
- 1. **逐张看图筛废片与起名**:用多模态看图检查导出目录里的 `.webp`,删掉报错图与重复图,只留关键演进节点,并补写清晰的 `label`(如 `"第一张草图:信息过载"`、`"终稿:定版海报"`)。
79
- 2. **提炼短标题与故事导读**:去掉空洞套话,在 `session.json` 顶层写出直奔主题的 `title` 与几十宇的 `description` 开场脉络。
80
- 3. **语义级隐私与噪音清理**:识别正则抓不到的业务代号、同事姓名或内部地址,替换为 `(涉及内部业务细节,已略去)`。
81
- 4. **掐头去尾(时间切片)**:切掉会话首尾顺手聊的无关话题,只保留完整讲好一件事的片段。
125
+ </details>
82
126
 
83
127
  ---
84
128
 
85
- ## `session.json` 字段速查与 CLI 参数
129
+ ## 常见问题
86
130
 
87
- - `title`:页面顶部标题与浏览器标签名(自动取日志标题或首句提问摘要,可直接手改)。
88
- - `description`:点击播放前在空白舞台中央展示的开场导读。
89
- - `lang`:界面默认语言(`"zh"` 或 `"en"`,也可点击网页右上角按钮随时切换中英文)。
90
- - `frames`:过程图片数组 `[{ time, img, who, label, w, h }]`,删掉不需要的项即可从时间轴和对话流中移除该图。
91
- - `deliverables`:会话结束时展示的最终成果列表 `[{ title, href, meta, cover }]`。
131
+ ### 日志会上传吗?隐私怎么处理?
92
132
 
93
- ```text
94
- 用法:
95
- encore 扫描本机最近的 Codex 与 Claude Code 会话,上下键选择导出
96
- encore <log.jsonl | dir> [options] 从原始日志一步生成回放目录,或对已修改的目录重新同步
97
- encore play <dir> [--port 4180] 启动本地预览服务
98
-
99
- 常用参数:
100
- -o, --out <dir> 输出目录(默认:./replays/<会话短名>)
101
- -l, --lang <zh|en|auto> 界面语言(默认:auto,网页右上角也可一键切换)
102
- --title <text> 自定义回放标题
103
- --desc <text> 自定义开场导读说明
104
- --from <iso-time> 起始时间切片(如 2026-11-10T09:00)
105
- --to <iso-time> 结束时间切片
106
- --no-images 不提取内嵌图片
107
- --include-memory 保留完整的跨会话 MEMORY_SUMMARY / 用户级 CLAUDE.md 原文(默认自动折叠脱敏)
108
- --list 仅列出本机最近会话,不进入交互菜单
109
- --no-serve 生成文件后直接退出,不启动本地预览服务
110
- -v, --version 显示版本号
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/<会话短名>
111
144
  ```
112
145
 
113
- ## 开源协议
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。
114
165
 
115
166
  [MIT](./LICENSE)