Skip to content

Add principles doc and a delivery gate (npm run verify) - #3

Merged
runanshao merged 1 commit into
mainfrom
claude/exciting-johnson-64owsd
Oct 5, 2026
Merged

runanshao merged 1 commit into
mainfrom
claude/exciting-johnson-64owsd

Conversation

@runanshao

Copy link
Copy Markdown
Owner

为什么

「往原理去理解,随后一通百通;可交付、可重复、稳定输出,才是 AI 赋能的前提。」这句话之前没有落到具体的东西上,这个 PR 用一份文档和一道检查把它落地。

改了什么

docs/principles.md:原理文档

  • 一条主线:旁白 → 逐词时间戳 → 帧号 → 画面。
  • 六条原理,每条都写了「所以能做到什么」和「怎么验证」:
    1. 时间只有一个来源:旁白
    2. 每一帧是帧号的纯函数
    3. 动 = 进场 + 停留时的呼吸 + 退场
    4. 风格是外面那层衣服,核心不认识风格
    5. 只在一张画布上设计,画幅交给外壳
    6. 能由源文件推出来的,都不手改
  • 「可交付 / 可重复 / 稳定输出」三个词在这个项目里分别指什么、靠什么保证。
  • 一张「新需求怎么从原理推出做法」的对照表。

tools/verify.mjs(npm run verify):交付前的检查

依次检查四项,任何一项不通过就停下:

  1. 类型检查
  2. 源文件一致(pytest)
  3. 每一场在横屏、9x16、1x1 三种画幅下,开头、中间、结尾三帧都能渲染
  4. 同一批帧渲染两次,结果逐字节一致

--quick 只跑前两项,不渲染。tools/publish.mjs 在渲染前会自动跑一遍,不通过就停,不会白渲染几十分钟;需要跳过时用 --no-verify。

tests/test_sync.py

检查 tts/script.json、src/timings.json、音频文件、src/scenes/index.ts 场景登记表四者一致:场景、顺序、章节标题、cue 都要对上,每场都要登记。CI 里会跑。

文档

  • CLAUDE.md 写入了这条原则,规定 verify 不过就不算完成。
  • README 开头加了「先读原理」的入口,工作流里加了 verify 这一步。
  • 四个 skill(new-scene、review、new-style-pack、publish)都改成以 verify 为准。

验证

  • 在沙箱里跑了完整的 npm run verify:四项全部通过,用时约 40 秒。--quick 也跑通了。
  • 检查第 4 项真能抓到问题:故意往 s02 里塞一个 Math.random(),第 4 项报错;之后已恢复,s02 不在这次的改动里。
  • npx tsc --noEmit 和 15 项 pytest 都通过。

场景代码、风格包和渲染结果都没有改动。

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hf6CivwFE1rx9Hf8pbNvaS


Generated by Claude Code

- docs/principles.md: the six principles behind the template (one time
  source, frames as pure functions, enter/breathe/exit, looks as
  clothing, one canvas for every format, nothing derived is hand-edited)
  and how deliverable / repeatable / stable maps onto this repo
- tools/verify.mjs: types -> source consistency -> every scene renders
  at start/mid/end in every format -> two renders are byte-identical;
  --quick skips rendering. publish runs it before rendering
  (--no-verify to skip)
- tests/test_sync.py: script.json <-> timings.json <-> audio <-> scene
  registry stay in step
- CLAUDE.md, README and skills point at the principles and the gate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hf6CivwFE1rx9Hf8pbNvaS
@runanshao
runanshao merged commit 3dc25fe into main Oct 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants