explanatory-animation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseexplanatory-animation
解释性动画
One file says what is being explained; the tool draws it, and then
checks that the picture says what the file claims. The writer's job is the
scene and the captions. The tool's job is layout, motion, and telling the
writer where the picture lies.
json
{ "format": "vlmkit-anim/scene@1", "kind": "sort", "algorithm": "bubble", "values": [5, 3, 8, 1] }Two layers: a Scene ( + intent — ,
, , never x / y)
compiles to a Timeline (nodes, keyframe tracks, captioned steps). Write
the scene; read the timeline only through the verbs below.
kind"algorithm": "bubble""trace": ["connect", "SYN+ACK"]"deps": [["web", "api"]]When the task is to answer a question with a figure — "how does this
work", "how is this structured", "what does this PR change" —
decides what to draw, from what, and how the prose follows it; this skill is
how the scene itself is written and checked.
explain-with-animThe one page to read before writing is — shipped in the package
(; in this repository
)
— every kind, its ops, the annotation ops every kind shares, and one JSON
example per kind that passes. prints
one kind's section. Do not learn the format from the compiler source.
docs/anim-ir.mdnode_modules/@mizchi/vlmkit-anim/docs/anim-ir.mdpackages/vlmkit-anim/docs/anim-ir.mdcheckvlmkit-anim schema --kind <k>一个文件说明要解释的内容;工具负责绘制,然后检查图片是否表达了文件中的声明。编写者负责场景和字幕,工具负责布局、动效,并告诉编写者图片在哪些地方与声明不符。
json
{ "format": "vlmkit-anim/scene@1", "kind": "sort", "algorithm": "bubble", "values": [5, 3, 8, 1] }这里分为两层:Scene( + 意图——例如 、、,绝不使用 x / y)会编译为 Timeline(节点、关键帧轨道、带字幕的步骤)。编写场景;只能通过以下命令读取 Timeline。
kind"algorithm": "bubble""trace": ["connect", "SYN+ACK"]"deps": [["web", "api"]]当任务需要用图回答问题——例如“它如何工作”“它如何组织”“这个 PR 改了什么”—— 会决定画什么、依据什么来画,以及后续文字如何配合;本 skill 负责场景本身的编写与检查。
explain-with-anim动手编写前必读的一页是 ——该文件随包发布(;在当前仓库中位于 )——其中包含每一种 kind、每种 kind 的操作、所有 kind 共用的标注操作,以及每种 kind 都有一个能通过 的 JSON 示例。 会打印指定 kind 的章节。不要通过阅读编译器源码来学习格式。
docs/anim-ir.mdnode_modules/@mizchi/vlmkit-anim/docs/anim-ir.mdpackages/vlmkit-anim/docs/anim-ir.mdcheckvlmkit-anim schema --kind <k>Invocation
调用方式
vlmkit-animvlmkitbash
undefinedvlmkit-animvlmkitbash
undefinedmizchi/explainer, where the package lives
mizchi/explainer, where the package lives
node --experimental-strip-types packages/vlmkit-anim/src/cli.ts check scene.json # from source, no build
node --experimental-strip-types packages/vlmkit-anim/src/cli.ts check scene.json # from source, no build
any other repository
any other repository
npx -p @mizchi/vlmkit-anim vlmkit-anim check scene.json # or add @mizchi/vlmkit-anim as a dev dependency
Nothing below needs a browser or an API key except: `.png` output, `sheet`,
`video`, `eval` (Playwright), and `review --model` (a vision model through
`@mizchi/vlmkit-ai`). Writing and checking a scene is browser-free.npx -p @mizchi/vlmkit-anim vlmkit-anim check scene.json # or add @mizchi/vlmkit-anim as a dev dependency
除以下功能外,下面的操作都不需要浏览器或 API 密钥:`.png` 输出、`sheet`、`video`(Playwright)以及 `review --model`(通过 `@mizchi/vlmkit-ai` 调用视觉模型)。编写和检查场景无需浏览器。Route by task
按任务选择路线
| Task shape | Do this |
|---|---|
| "Animate / show step by step how X works" (a sort, search, BST, heap, DP table, graph walk, state machine, message exchange, flowchart, gantt) | Pick the |
| "Explain a concept" that no kind names | Choose the kind whose things the concept has (nodes exchanging messages → |
| "Draw a module / dependency / architecture map" | |
| "Draw this repository" | |
| "What does this branch change?" | |
| "Show what changed between two maps" | |
| "We already have a mermaid diagram" | |
| "Put it in the docs" | |
"As D2 text" / "show it in the terminal" / an existing | Not this tool: |
| 任务形式 | 操作 |
|---|---|
| “制作动画/逐步展示 X 的工作方式”(排序、搜索、BST、堆、DP 表、图遍历、状态机、消息交换、流程图、甘特图) | 在指南中选择明确提到 X 的 kind;编写场景;然后运行下面的循环。共有十九种 kind:sort、array、stack、queue、list、tree、state-machine、heap、distributed、matrix、graph、chart、flowchart、gantt、sequence、diagram、modules、vector、compose。 |
| “解释某种概念”,但没有对应的 kind | 选择其对象与该概念最相近的 kind(交换消息的节点 → |
| “绘制模块/依赖关系/架构图” | 使用 |
| “绘制当前仓库” | |
| “这个分支改了什么?” | |
| “展示两张图之间发生了什么变化” | |
| “已经有 mermaid 图” | |
| “放入文档中” | |
“输出为 D2 文本”/“在终端中展示”/处理现有 | 不使用此工具: |
The loop
循环
1. write scene.json one kind; ids ASCII, language in `label`
2. vlmkit-anim check scene.json [--expect facts.json] validate → compile → semantic checks → stats; exit 1 on ✗
3. vlmkit-anim explain scene.json the narration as a numbered list — is this the story?
4. vlmkit-anim layout scene.json texts on texts, under boxes, past the edge, lines through
labels, containers crossing — per step; exit 1 when any
5. vlmkit-anim why scene.json [--about id] (modules / diagram) what set each canvas axis, rows vs bands
and their share, what put each box on its layer, which box
a bent edge went round — read this BEFORE relabelling
6. vlmkit-anim still scene.json --out fig.svg the figure | html --out page.html | video --out demo.gif
7. vlmkit-anim review scene.json --out dir optional: a contact sheet + brief for a vision reader;
--answers scores its JSON against the geometry / the factsEach ✗ line names a path, what is wrong, and a hint with the fix. Fix
the first ✗, re-run; ⚠ lines are advice you act on only when they touch
what the picture is for. Budget five rounds; if the fifth is not green,
stop and report the lines, not a guess.
→1. write scene.json one kind; ids ASCII, language in `label`
2. vlmkit-anim check scene.json [--expect facts.json] validate → compile → semantic checks → stats; exit 1 on ✗
3. vlmkit-anim explain scene.json the narration as a numbered list — is this the story?
4. vlmkit-anim layout scene.json texts on texts, under boxes, past the edge, lines through
labels, containers crossing — per step; exit 1 when any
5. vlmkit-anim why scene.json [--about id] (modules / diagram) what set each canvas axis, rows vs bands
and their share, what put each box on its layer, which box
a bent edge went round — read this BEFORE relabelling
6. vlmkit-anim still scene.json --out fig.svg the figure | html --out page.html | video --out demo.gif
7. vlmkit-anim review scene.json --out dir optional: a contact sheet + brief for a vision reader;
--answers scores its JSON against the geometry / the facts每个 ✗ 行都会指出路径、问题所在,以及带有修复建议的 提示。先修复第一个 ✗,然后重新运行;⚠ 行只是建议,只有当它影响图片的用途时才需要处理。最多安排五轮;如果第五轮仍未通过,请停止并报告相关行,而不是猜测。
→Done condition
完成条件
- exits 0 with no ✗ (and, when a fact sheet exists,
checktoo).--expect - reports no issue on any step.
layout - reads as the explanation you meant — every beat has a caption that says why, not only what moved.
explain - For a still: both canvas sides under 2000px (the canvas ⚠ in ), and you looked at the SVG once.
check
- 退出码为 0,且没有 ✗(存在事实表时,
check也必须通过)。--expect - 报告任何步骤都没有问题。
layout - 读起来就是你想表达的讲解——每个节拍都有说明为什么的字幕,而不只是说明什么发生了移动。
explain - 对于静态图:画布两侧都小于 2000px(中的画布 ⚠),并且你已经亲自查看过一次 SVG。
check
Reading the kickbacks
读取检查反馈
- The canvas warning names its cause. "labels stop being legible — A
(206px, in G1) and B (53px, in G2) need 142px between their centres … and
the layout put them 10% of the width apart", then "N containers sit side by
side across the picture (a 40%, b 10%, …), each as wide as its fullest
layer's boxes". The lever is the named pair or the banding — flatten or
re-nest the containers, break the named label — not the longest label you
can see. has every layer, band and detour; two writers who read it before their first edit brought an 8882px graph under 2000px.
why - A crossing names the edge by its ends () and the box it runs through. Move one end to another layer (reorder the list, regroup) or shorten that label.
edge-24: diff → capture - "no sequence" on a means the picture, not the motion, is the point: switch to
diagram. The switch changes layering (a diagram layers one past what points into a box; a module map layers from its leaves), so re-runkind: modulesand read the new canvas line.check - lines are the facts the picture got wrong: a dependency drawn that the sheet does not list, one listed and not drawn, the wrong edge highlighted. A green
--expecton a wrong picture is the failure this exists for — the sheet wins over the picture.check import mermaidnames what the IR has no place for (styles, classDefs, clicks,dropped / changed:inside a subgraph, composite states). Colour withdirection; everything else you put back as captions.tone
- 画布警告会指出原因。 “标签无法清晰辨认——A (206px, in G1) 与 B (53px, in G2) 的中心之间需要 142px……而布局只把二者放在画布宽度的 10% 处”,接着还有“N 个容器在图中并排分布(a 占 40%,b 占 10%……),每个容器都与其最宽一层的方框一样宽”。调整的切入点是被点名的标签对或分层方式——扁平化或重新嵌套容器,或者拆开被点名的标签——而不是去改你能看到的最长标签。会列出每一层、每个 band 和每次绕行;两位编写者在第一次修改前先读了它,把一张 8882px 的图缩小到了 2000px 以内。
why - 交叉线会按两端点名称标识边(),并指出它穿过了哪个方框。将其中一端移到另一层(重排列表、重新分组),或者缩短那个标签。
edge-24: diff → capture - 在 上出现“no sequence” 意味着重点是图片本身,而不是动效:切换到
diagram。切换会改变分层方式(diagram 的分层会依据指向某个方框的对象向后推一层;模块图则从叶子节点开始分层),因此需要重新运行kind: modules并阅读新的画布提示行。check - 行表示图片画错的事实:图中存在事实表未列出的依赖、事实表列出的依赖没有画出,或者高亮了错误的边。即使
--expect通过,图片仍然是错的,这种失败正是该工具要发现的问题——事实表优先于图片。check - 的
import mermaid会指出 IR 无法表达的内容(样式、classDefs、点击事件、子图内部的dropped / changed:、复合状态)。使用direction设置颜色;其余内容通过字幕补回。tone
Rules the checks enforce (do not fight them)
检查所强制执行的规则(不要与之对抗)
- No coordinates in a scene that has a kind for its things. and hand-written positions are the fallback and are counted as such.
kind: vector - Every annotation names an anchor the kind owns (an index, a cell, a node,
an edge), and asks for a ; the compiler grows the canvas on that side and routes the pointer round labelled boxes. Record asked vs landed if it matters.
side - Labels may be any script; boxes are sized per glyph (CJK is one em). Ids stay ASCII.
- A dependency cycle in is a warning, drawn — name the cut in a caption or mark one edge
modules."style": "forbidden" - A scene in a fence is checked the same way; a fence that does not compile renders as a visible
```vlm-animwith the check's lines.<pre>
- 对于已有对应 kind 来表达对象的场景,不允许使用坐标。和手工位置是兜底方案,并且会被计分。
kind: vector - 每个标注都必须指定该 kind 所拥有的锚点(索引、单元格、节点或边),并要求一个 ;编译器会在该侧扩展画布,并让指示线绕过带标签的方框。如果有必要,请记录请求的 side 与实际落点。
side - 标签可以使用任意文字系统;方框大小按字形计算(CJK 占一个 em)。ID 保持为 ASCII。
- 中存在依赖环时会给出警告,但仍会绘制——请在字幕中说明切断点,或将某条边标记为
modules。"style": "forbidden" - 位于 围栏中的场景也会接受相同检查;无法编译的围栏会显示为可见的
```vlm-anim,并附带检查结果行。<pre>
Outputs at a glance
输出一览
| File | Verb | Consumer |
|---|---|---|
| you | the repo — this is what is edited later |
| | docs, a README, a slide |
| | a browser; |
| | a README or PR comment |
| | |
| | a vision model or a second agent, and its score |
| 文件 | 命令 | 使用方 |
|---|---|---|
| 你 | 仓库——这是后续要编辑的内容 |
| | 文档、README、幻灯片 |
| | 浏览器; |
| | README 或 PR 评论 |
| | |
| | 视觉模型或另一位 agent,以及它给出的评分 |
Failure modes
失败模式
- ,
.png,sheet,video --out x.mp4fail with a browser error → Playwright is missing;eval,.svgand.gifneed no browser.sheet --out sheet.html - In mizchi/explainer the CLI shows old behaviour after editing →
packages/vlmkit-anim/src/innpm run build(never piped topackages/vlmkit-anim), or run from source.head - Every round shortens a label and the canvas does not move → the label was
not the binding one; read the canvas line and .
why - A map has a dependency the code does not → the sheet from
modulescatches it; a map drawn from memory is checked against the code, not the other way round.facts - is green, the figure is wrong → write the fact sheet. That is the whole reason
checkexists.--expect
- 、
.png、sheet、video --out x.mp4因浏览器错误而失败 → 缺少 Playwright;eval、.svg和.gif不需要浏览器。sheet --out sheet.html - 在 mizchi/explainer 中,编辑 后 CLI 仍显示旧行为 → 在
packages/vlmkit-anim/src/中运行packages/vlmkit-anim(绝不要管道给npm run build),或者直接从源码运行。head - 每轮都在缩短标签,但画布毫无变化 → 该标签并不是决定画布尺寸的标签;请阅读画布提示行和 。
why - 图中包含代码里不存在的依赖 → 由
modules生成的事实表会捕获这个问题;凭记忆绘制的图应与代码进行核对,而不是反过来。facts - 已通过,但图片仍然是错的 → 编写事实表。这正是
check存在的全部意义。--expect