ax-narrate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseax:narrate - write the session's story as a structured narration
ax:narrate - 编写会话的结构化叙事
You were there. This skill turns YOUR OWN memory of the session into a
reviewable artifact: 3-7 stops in reading-flow order, each anchored to
real evidence - code hunks, turn numbers, user quotes, failures. The
point is to capture what a PR diff never shows: the corrections, the
dead ends, the recoveries.
The artifact validates against in
and renders in ax studio.
SessionNarrationapps/studio/src/routes/narration-types.ts你全程参与了会话。此技能将你对会话的记忆转化为一份可审阅的工件:按照阅读顺序排列的3-7个节点,每个节点都锚定在真实证据上——代码片段、轮次编号、用户引用、失败记录。核心是捕获PR差异永远无法展示的内容:修正过程、死胡同、恢复步骤。
该工件需符合中的校验规则,并可在ax studio中渲染。
apps/studio/src/routes/narration-types.tsSessionNarrationStep 1 - identify the session
步骤1 - 识别会话
- Preferred: and pick the current session's id (the one matching this conversation). Use the short id.
ax sessions here --days=1 --json - If is unavailable or the session isn't ingested yet, derive a slug:
ax. Note in<repo>-<YYYYMMDD-HHmm>that turn seqs are best-effort ordinals in that case.meta - If available, gives you the real turn seqs to anchor against. Prefer real seqs over guesses.
ax sessions show <id> --json
- 首选方式:执行并选择当前会话的ID(与本次对话匹配的ID),使用短ID。
ax sessions here --days=1 --json - 若不可用或会话尚未被收录,则生成一个slug:
ax。在此情况下,需在<repo>-<YYYYMMDD-HHmm>中注明轮次序号为最佳预估的序数。meta - 若可用,可提供真实的轮次序号用于锚定。优先使用真实序号而非预估序号。
ax sessions show <id> --json
Step 2 - reconstruct the story from your own context
步骤2 - 从自身语境重构叙事
Re-read the conversation in your head before writing anything:
- What did the user originally ask for? (intent)
- What existed before, what exists now? (before/after)
- Where did the user redirect or correct you? EVERY one of these
becomes a anchor. No exceptions.
correction - Which tool failures actually mattered (changed your approach, cost
real time, forced a workaround)? Each becomes a anchor. Skip trivial retries that changed nothing.
tool_failure - Which attempts were abandoned? They get a stop or at least a
anchor - abandonment is part of the story.
turn
在开始编写前,先在脑中重读对话内容:
- 用户最初的需求是什么?(意图)
- 变更前后的状态分别是什么?(前后对比)
- 用户在哪些地方进行了引导或修正?每一处都要成为锚点,无一例外。
correction - 哪些工具失败产生了实际影响(改变了你的方法、耗费了时间、迫使你寻找替代方案)?每一处都要成为锚点。忽略无影响的重试操作。
tool_failure - 哪些尝试被废弃了?它们需要对应一个节点,或至少一个锚点——废弃过程也是叙事的一部分。
turn
Step 3 - choose 3-7 stops, in reading-flow order
步骤3 - 选择3-7个节点,按阅读顺序排列
A stop is a LOGICAL unit of change, not a file. If three files changed
for one reason, that is ONE stop with several anchors. Order rules
(stolen from the code-tour playbook because they work):
- Entry point first: the change that, understood alone, unlocks the rest.
- Cause before effect: the correction comes before the code it caused.
- Definitions before consumers: types/schema stops before usage stops.
- Verification last: tests, typecheck, and the failures hit on the way.
- Combine trivial housekeeping into one final stop, or omit it.
节点是一个逻辑变更单元,而非单个文件。如果三个文件因同一原因发生变更,那这是一个包含多个锚点的节点。排序规则(借鉴自代码漫游手册,因其行之有效):
- 入口点优先:单独理解该变更即可掌握后续所有内容。
- 先因后果:修正操作放在其引发的代码变更之前。
- 先定义后使用:类型/架构节点放在使用节点之前。
- 验证环节最后:测试、类型检查,以及过程中遇到的失败。
- 将琐碎的整理操作合并为最后一个节点,或直接省略。
Step 4 - write each stop
步骤4 - 编写每个节点
- title: short and friendly. "Call counts become a char diffstat", not "Changes to files-touched.ts".
- gist: ONE sentence. Not two. A reader who reads nothing else must get the stop from the gist. Conversational, the way you'd say it to a colleague.
- detail: 2-4 sentences of markdown (paragraphs, , bold). Say WHY the change looks the way it does; "we did X instead of Y because Z" is exactly what the reader wants.
inline code - transition: a short connective phrase to the next stop; empty
string for the last stop.
"" - anchors: MUST be non-empty. An unanchored stop is an unsupported claim. Anchor kinds:
| kind | required fields | use for |
|---|---|---|
| | a real code change |
| | the evolving architecture snapshot |
| | a plain moment in the transcript |
| | user steering (not correcting) |
| | user correcting course |
| | consequential failure |
| | a domain term the story leans on |
- title:简短友好。例如“调用次数转为字符差异统计”,而非“修改files-touched.ts文件”。
- gist:一句话描述。不能是两句。只读这一句话的读者也能理解该节点的核心内容。用和同事交流的口语化风格表述。
- detail:2-4句Markdown格式的内容(段落、、加粗)。说明变更为何是当前的样子;“我们选择X而非Y是因为Z”正是读者需要的信息。
行内代码 - transition:连接到下一个节点的简短短语;最后一个节点留空字符串。
"" - anchors:必须非空。无锚点的节点属于无依据的表述。锚点类型如下:
| 类型 | 必填字段 | 适用场景 |
|---|---|---|
| | 真实的代码变更 |
| | 演进中的架构快照 |
| | 对话中的某个普通时刻 |
| | 用户的引导(非修正) |
| | 用户的路线修正 |
| | 产生影响的失败 |
| | 叙事中涉及的领域术语 |
Hard anchor rules
锚点严格规则
- carries VERBATIM old/new fragments from the actual edits you made - copy the real text, never paraphrase code. Keep hunks short (5-15 lines per side); pick the most telling fragment, not the whole edit.
file_hunkfor pure insertions,old_text: nullfor pure deletions. Never both null.new_text: null - Every user correction/redirect in the session gets a anchor with a verbatim (trimmed)
correctionand a concretequote- what actually changed because of it.outcome - Every consequential tool failure gets a anchor with a real
tool_failureand how you recovered (orerror_excerpt)."abandoned" - Never fabricate turn seqs. Use seqs when you have them; otherwise count user turns from the start of the conversation and say so in the detail.
ax sessions show - is the architecture spine of the narration: pick ONE stable
code_stateid (e.g.artifact) and restate the FULL snapshot at each stop where the design moved - pseudo-code of types/interfaces, how they compose, and the call stack (plan-style:"review-architecture"). Consecutive snapshots of the same artifact animate token-by-token in studio, so KEEP shared lines byte-identical between stops and let only the real delta differ - a new method, a renamed shape, an added edge case. UseCaller -> Callee // notefor the evolving design; usecode_statefor one-off code jumps (those render as static before/after diffs, not motion).file_hunk
- 必须包含你所做编辑的原文片段——复制真实文本,绝不要改写代码。保持片段简短(每侧5-15行);选择最具代表性的片段,而非完整编辑内容。纯插入时
file_hunk,纯删除时old_text: null。不可两者都为null。new_text: null - 会话中每一处用户修正/引导都要对应一个锚点,包含原文(精简后)
correction和具体的quote——即该修正实际带来的变化。outcome - 每一处产生影响的工具失败都要对应一个锚点,包含真实的
tool_failure以及你的恢复方式(或error_excerpt)。"abandoned" - 绝不要编造轮次序号。有提供的序号时优先使用;否则从对话开始计数用户轮次,并在detail中说明。
ax sessions show - 是叙事的架构核心:选择一个稳定的
code_stateID(例如artifact),并在每个设计发生变化的节点处重述完整快照——类型/接口的伪代码、它们的组合方式、调用栈(计划风格:"review-architecture")。同一工件的连续快照在studio中会逐 token 动画展示,因此要保持节点间的共享内容完全一致,仅修改真实差异部分——新增方法、重命名结构、添加边缘案例。Caller -> Callee // 备注用于展示演进中的设计;code_state用于展示一次性代码跳转(后者会渲染为静态的前后差异,而非动态效果)。file_hunk
Step 5 - emit the artifact
步骤5 - 生成工件
Write (create the directory if
needed) with exactly this top-level shape:
.ax/narrations/<session-id>.jsonjson
{
"schema_version": 1,
"kind": "narration",
"meta": {
"session_id": "<id>",
"generated_at": "<ISO-8601 now>",
"generator": "skill",
"model": "<your model id>"
},
"title": "...",
"intent": "...",
"before": "...",
"after": "...",
"stops": [ { "title": "...", "gist": "...", "detail": "...", "transition": "...", "anchors": [ ... ] } ]
}Before finishing, self-check against the validator's rules:
- non-empty (3-7), every stop's
stopsnon-empty.anchors - Every gist is one sentence; every has an
correction; everyoutcomehas atool_failure; norecoverywith both sides null or empty.file_hunk - Strings are plain JSON strings (escape newlines in hunks as ).
\n
Then tell the user where the file landed and give a 2-line summary of
the story you wrote. Do not paste the whole JSON into chat.
编写文件(若目录不存在则创建),必须遵循以下顶层结构:
.ax/narrations/<session-id>.jsonjson
{
"schema_version": 1,
"kind": "narration",
"meta": {
"session_id": "<id>",
"generated_at": "<ISO-8601 now>",
"generator": "skill",
"model": "<your model id>"
},
"title": "...",
"intent": "...",
"before": "...",
"after": "...",
"stops": [ { "title": "...", "gist": "...", "detail": "...", "transition": "...", "anchors": [ ... ] } ]
}完成前,对照校验规则进行自检:
- 非空(3-7个),每个节点的
stops非空。anchors - 每个gist都是一句话;每个都有
correction;每个outcome都有tool_failure;没有两侧都为null或空的recovery。file_hunk - 字符串为标准JSON字符串(片段中的换行需转义为)。
\
然后告知用户文件的保存位置,并给出你所编写叙事的2行摘要。不要将完整JSON粘贴到聊天中。",