Skip to content

docs(v2): §0.5 文体硬约束 + C01 最小 diff 重做 + C-1~C-4 CI 脚本 - #17

Merged
luyao618 merged 8 commits into
mainfrom
agent/cc-dev/v2-style-guard-c01-redo
May 21, 2026
Merged

docs(v2): §0.5 文体硬约束 + C01 最小 diff 重做 + C-1~C-4 CI 脚本#17
luyao618 merged 8 commits into
mainfrom
agent/cc-dev/v2-style-guard-c01-redo

Conversation

@luyao618

Copy link
Copy Markdown
Owner

落地动作(对应 issue YAO-60 §0.5.8)

按 OC-PM 的 §0.5 文体硬约束补丁与 PR #15 翻车点清单一次性落地:

  1. close PR docs(c01): 项目全景与四种入口形态 (V2 第一棒) #15 — 已 close(不在本 PR 提交范围内,链接:https://github.com/luyao618/Claude-Code-Source-Study/pull/15)
  2. §0.5.1–§0.5.7 合入 docs/V2-REVISION-SPEC.md — §0 四公约 → 五公约;引言补一句 "v2 是用更强模型重新解析同一套源码以校正准确性,不是用更新颖的写法重写既有文章";§3 CI 校验 单元由 3 项扩为 7 项;§7.2 仓库布局补 4 个新脚本路径
  3. C01 最小 diff 重做docs/01-项目全景.md:仅在 §3.2 目录结构后加一段 250 字散文,提示 v1 未入图的 12 个一级目录及它们对应的 v2 新增章节;v1 标题 / 段落 / 表格全部保留;无章节骨架重排
  4. C-1~C-4 CI 脚本scripts/check-prose-diff-ratio.ts / check-heading-preservation.ts / check-code-ratio.ts / lint-section-titles.ts,由 .github/workflows/v2-style-guard.yml 在 PR 触发

风格双亲(§0.5.1)

本 PR 修订对象是 docs/01-项目全景.md(即 C01 v1 原稿)。最小修改原则下不需要"模仿"风格——保留 v1-01 自身的全部叙事;新增的一段散文以 v1-01 §3.2 既有文风("目录结构与职责"散文 + 缩进 ASCII 树)为基线,并参照 v1-25(架构模式总结)的"罗列式但保持口语化"写法。

风格双亲:v1-01(项目全景)+ v1-25(架构模式总结)

本次修改量化对照(§0.5 R-2)

docs/01-项目全景.md

  • 保留 v1 段落:全部(包括标题、技术栈散文、启动链路五层小节、目录树、关键数据流、架构决策、可迁移设计模式、下一篇预告)
  • 改写 v1 段落:0 段
  • 新增段落:1 段(§3.2 末尾的 250 字 v2 补记,未在小标题之间另开层级)

CI 自检(base = origin/main):

  • C-1 中文段落留存率:100.0%(≥ 50%)
  • C-2 v1 一/二级标题:8/8 全部保留
  • C-3 代码块占比:non-new chapter, skip
  • C-4 工程化小标题禁词:27 个标题全部合规

C-3 范围说明

§0.5.4 #3 把"代码块占比 ≤ 25%"写在新章规则下;为了不阻塞 v1 老章节的 minimal-diff 修订(v1-01 自身因 mermaid 图与 ts 片段而天然偏高),脚本仅对 C04/C13/C17/C24/C25/C28/C29/C30 这 8 个 v2 新增章节文件名生效,或对 frontmatter 含 新增章节: yes 的文件生效。其他章节走 C-1/C-2/C-4。

反例对照(§0.5.5)

PR #15 的六条翻车点已全部规避:

# PR #15 反例 本 PR 对应做法
1 标题被换皮为 # C01 · ... 完全保留 v1 标题 # 第 1 篇:项目全景 — 一个 AI CLI 产品的技术蓝图
2 开篇被替换为 ## 源码锚点 列表 保留 v1 "为什么要从全景开始?" 叙事破题,未引入源码锚点前言
3 散文章节被表格化 "一、技术栈选型" 整节散文 + 总结表保持原样
4 25+ 行快速路径分发表挤压叙述 v1 §2.1 的快速路径表(6 行)维持原状
5 小标题工程化("X 是 Y,不是 Z") 全章小标题不变
6 "12 个新模块" 被过度展开 收敛为 §3.2 末尾 1 段 250 字散文,不另开层级

验证

$ bun scripts/check-prose-diff-ratio.ts --base origin/main
[C-1] OK   docs/01-项目全景.md: 中文段落留存率 100.0%

$ bun scripts/check-heading-preservation.ts --base origin/main
[C-2] OK   docs/01-项目全景.md: 全部 8 个 v1 标题保留

$ bun scripts/check-code-ratio.ts --base origin/main
[C-3] skip docs/01-项目全景.md: 非 v2 新增章节,C-3 不适用

$ bun scripts/lint-section-titles.ts --base origin/main
[C-4] OK   docs/01-项目全景.md: 27 个标题全部合规

Refs: YAO-60 (mention://issue/7ca361f1-1a45-474a-92f4-f58bb1dd559c)

Yao Lu and others added 8 commits May 22, 2026 00:15
- spec: §0 four-rules → five-rules; insert §0.5.1–§0.5.7 (style baseline,
  iteration rules for v1 chapters, new-chapter rules, PR #15 reverse-examples,
  CI/human review acceptance, and the narrowed migration-matrix semantics)
- spec §1 intro: add the 'v2 是更准确,不是更新颖' clause
- spec §3 / §7.2: bump CI count and list four new scripts
- 01-项目全景.md: minimum-diff redo of PR #15. Restore v1 narrative,
  add a single 250-word paragraph in §3.2 noting the 12 first-class dirs
  that v2 will cover (bridge/remote/coordinator/server/upstreamproxy/
  migrations/buddy/screens/outputStyles/keybindings,vim,voice/native-ts/
  schemas), no other section reshuffles.
- scripts/check-prose-diff-ratio.ts (C-1): 8-CJK-char window retention check
- scripts/check-heading-preservation.ts (C-2): v1 H1/H2 set ⊆ v2 set
- scripts/check-code-ratio.ts (C-3): source-lang fenced ratio, applies to
  v2 new chapters only (per §0.5.4 #3)
- scripts/lint-section-titles.ts (C-4): 5 forbidden patterns
- .github/workflows/v2-style-guard.yml: wire C-1..C-4 to PR checks

Co-authored-by: multica-agent <github@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
- C-1/C-2: when a protected v1 doc exists in base but is missing in
  worktree (delete or rename), fail loudly instead of warn/skip — prior
  branches let `docs/01-...` be removed silently.
- C-3: drop the stale `C04|C13|...` filename whitelist (actual files use
  `NN-标题.md` and never carry book-spine IDs in the filename); the
  frontmatter `新增章节: yes` declaration is now the sole gate, and
  V2-REVISION-SPEC §0.5.4 + §9.3 mandate it for the 8 new chapters.

Co-authored-by: multica-agent <github@multica.ai>
OC-R flagged that new chapters could skip C-3 by simply omitting
`新增章节: yes`. Now any docs/*.md file not in the v1 published
manifest is treated as a planned-new-chapter path and must declare
the frontmatter, otherwise C-3 fails (no longer skip+exit 0).

V1 published files keep the prior skip behavior (C-3 doesn't apply
to v1 chapters by spec §0.5.4 / §9.3).

Co-authored-by: multica-agent <github@multica.ai>
按 issue YAO-60 范围确认,C01 正文修订留作后续子 issue 处理。

Co-authored-by: multica-agent <github@multica.ai>
OC-R reported that the prior C-3 candidate filter (docs/*.md minus
V2-REVISION-SPEC.md) treated planned docs/appendix/{A..F}.md auto-
generated appendices as new-chapter candidates and would FAIL them
for missing '新增章节: yes' frontmatter.

Restrict candidates to top-level chapter files matching
^docs/\d{2}-[^/]+\.md$, aligned with V2-REVISION-SPEC.md §9.3
(NN-标题.md naming). Appendices, the spec itself, and any other
non-chapter pages are now skipped.

Co-authored-by: multica-agent <github@multica.ai>
OC-R PR #17 二次反馈:旧实现把"不在 V1_DOC_FILES 内"等价为"新增章节",
会误伤 v2 改名后的非新增章节(例如 v1-04 → docs/06-System-Prompt-与-
Output-Style-注入.md 对应 C06,仍是非新增)。

改为基于 V2-REVISION-SPEC §5/§9.3 维护 NEW_CHAPTER_NN 集合
{04,13,17,24,25,28,29,30},按 NN 前缀显式判定 v2 新章。V1_DOC_FILES
保留并优先匹配,使 v1 文件被重命名/移除前不被新 NN 槽位误判为新章。

Co-authored-by: multica-agent <github@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
@luyao618
luyao618 merged commit f0327e2 into main May 21, 2026
1 check passed
@luyao618
luyao618 deleted the agent/cc-dev/v2-style-guard-c01-redo branch May 21, 2026 17:16
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.

1 participant