@gordon.gan/specflow 1.7.0-beta → 1.8.0-alpha

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.
Files changed (151) hide show
  1. package/README.md +4 -4
  2. package/dist/cli/commands/document-run.d.ts +84 -0
  3. package/dist/cli/commands/document-run.js +539 -0
  4. package/dist/cli/index.js +2 -2
  5. package/dist/core/artifact-language.js +11 -1
  6. package/dist/core/document/chapters.d.ts +6 -0
  7. package/dist/core/document/chapters.js +21 -0
  8. package/dist/core/document/coverage.d.ts +25 -0
  9. package/dist/core/document/coverage.js +49 -0
  10. package/dist/core/document/digests.d.ts +41 -0
  11. package/dist/core/document/digests.js +136 -0
  12. package/dist/core/document/engine.d.ts +92 -0
  13. package/dist/core/document/engine.js +487 -0
  14. package/dist/core/{approval → document}/forbidden-patterns.d.ts +4 -2
  15. package/dist/core/document/forbidden-patterns.js +33 -0
  16. package/dist/core/document/gates.d.ts +27 -0
  17. package/dist/core/document/gates.js +33 -0
  18. package/dist/core/document/index.d.ts +7 -0
  19. package/dist/core/document/index.js +7 -0
  20. package/dist/core/document/input-digest.d.ts +55 -0
  21. package/dist/core/document/input-digest.js +121 -0
  22. package/dist/core/document/input-features.d.ts +24 -0
  23. package/dist/core/document/input-features.js +112 -0
  24. package/dist/core/document/lint.d.ts +22 -0
  25. package/dist/core/document/lint.js +29 -0
  26. package/dist/core/document/llm.d.ts +35 -0
  27. package/dist/core/document/llm.js +27 -0
  28. package/dist/core/document/map.d.ts +46 -0
  29. package/dist/core/document/map.js +212 -0
  30. package/dist/core/document/outline.d.ts +26 -0
  31. package/dist/core/document/outline.js +128 -0
  32. package/dist/core/document/paths.d.ts +23 -0
  33. package/dist/core/document/paths.js +31 -0
  34. package/dist/core/document/profile-validator.d.ts +23 -0
  35. package/dist/core/document/profile-validator.js +127 -0
  36. package/dist/core/document/profiles.d.ts +23 -0
  37. package/dist/core/document/profiles.js +69 -0
  38. package/dist/core/document/render.d.ts +19 -0
  39. package/dist/core/document/render.js +97 -0
  40. package/dist/core/document/review.d.ts +42 -0
  41. package/dist/core/document/review.js +157 -0
  42. package/dist/core/document/scene-detect.d.ts +25 -0
  43. package/dist/core/document/scene-detect.js +121 -0
  44. package/dist/core/document/schemas.d.ts +949 -0
  45. package/dist/core/document/schemas.js +158 -0
  46. package/dist/integrations/shared/capability-evidence.js +4 -8
  47. package/dist/integrations/shared/command-catalog.js +1 -1
  48. package/dist/integrations/shared/parity-manifest.js +4 -8
  49. package/package.json +1 -1
  50. package/prompts/apply/phase-a-plan.md +1 -1
  51. package/prompts/document/map/acceptance.md +8 -0
  52. package/prompts/document/map/api-design.md +17 -0
  53. package/prompts/document/map/architecture.md +7 -0
  54. package/prompts/document/map/closed-loop.md +8 -0
  55. package/prompts/document/map/compat-migration.md +8 -0
  56. package/prompts/document/map/config-runtime.md +8 -0
  57. package/prompts/document/map/core-logic.md +8 -0
  58. package/prompts/document/map/data-model.md +17 -0
  59. package/prompts/document/map/deploy.md +8 -0
  60. package/prompts/document/map/fix.md +7 -0
  61. package/prompts/document/map/goal.md +7 -0
  62. package/prompts/document/map/impact.md +7 -0
  63. package/prompts/document/map/implementability.md +8 -0
  64. package/prompts/document/map/mvp-boundary.md +7 -0
  65. package/prompts/document/map/non-goals.md +7 -0
  66. package/prompts/document/map/regression.md +7 -0
  67. package/prompts/document/map/reproduce.md +7 -0
  68. package/prompts/document/map/requirement.md +7 -0
  69. package/prompts/document/map/root-cause.md +7 -0
  70. package/prompts/document/map/signoff.md +8 -0
  71. package/prompts/document/map/tech-selection.md +17 -0
  72. package/prompts/document/map/test-strategy.md +7 -0
  73. package/prompts/document/map/ui-design.md +18 -0
  74. package/prompts/document/outline/general.md +37 -0
  75. package/prompts/document/review/ai-review.md +56 -0
  76. package/prompts/explore/explore-session.md +1 -1
  77. package/prompts/propose/design-draft.md +1 -1
  78. package/prompts/propose/proposal.md +1 -1
  79. package/prompts/propose/specs.md +1 -1
  80. package/prompts/propose/tasks-draft.md +1 -1
  81. package/prompts/refine/design-output.md +1 -1
  82. package/prompts/refine/update-artifacts.md +2 -0
  83. package/prompts/shared/artifact-language.md +13 -0
  84. package/skills/specflow-document/SKILL.md +124 -0
  85. package/templates/document/chapters/acceptance.yaml +16 -0
  86. package/templates/document/chapters/api-design.yaml +24 -0
  87. package/templates/document/chapters/architecture.yaml +18 -0
  88. package/templates/document/chapters/closed-loop.yaml +22 -0
  89. package/templates/document/chapters/compat-migration.yaml +17 -0
  90. package/templates/document/chapters/config-runtime.yaml +16 -0
  91. package/templates/document/chapters/core-logic.yaml +16 -0
  92. package/templates/document/chapters/data-model.yaml +25 -0
  93. package/templates/document/chapters/deploy.yaml +18 -0
  94. package/templates/document/chapters/fix.yaml +18 -0
  95. package/templates/document/chapters/goal.yaml +17 -0
  96. package/templates/document/chapters/impact.yaml +16 -0
  97. package/templates/document/chapters/implementability.yaml +22 -0
  98. package/templates/document/chapters/mvp-boundary.yaml +20 -0
  99. package/templates/document/chapters/non-goals.yaml +17 -0
  100. package/templates/document/chapters/regression.yaml +16 -0
  101. package/templates/document/chapters/reproduce.yaml +16 -0
  102. package/templates/document/chapters/requirement.yaml +18 -0
  103. package/templates/document/chapters/root-cause.yaml +18 -0
  104. package/templates/document/chapters/signoff.yaml +15 -0
  105. package/templates/document/chapters/tech-selection.yaml +20 -0
  106. package/templates/document/chapters/test-strategy.yaml +20 -0
  107. package/templates/document/chapters/ui-design.yaml +22 -0
  108. package/templates/document/profiles/0to1.yaml +12 -0
  109. package/templates/document/profiles/approve.yaml +22 -0
  110. package/templates/document/profiles/bugfix.yaml +10 -0
  111. package/templates/document/profiles/feature.yaml +11 -0
  112. package/dist/cli/commands/approval-assemble.d.ts +0 -64
  113. package/dist/cli/commands/approval-assemble.js +0 -408
  114. package/dist/core/approval/assemble.d.ts +0 -10
  115. package/dist/core/approval/assemble.js +0 -384
  116. package/dist/core/approval/bundle.d.ts +0 -9
  117. package/dist/core/approval/bundle.js +0 -172
  118. package/dist/core/approval/forbidden-patterns.js +0 -37
  119. package/dist/core/approval/index-schema.d.ts +0 -676
  120. package/dist/core/approval/index-schema.js +0 -193
  121. package/dist/core/approval/index.d.ts +0 -12
  122. package/dist/core/approval/index.js +0 -9
  123. package/dist/core/approval/lint.d.ts +0 -10
  124. package/dist/core/approval/lint.js +0 -302
  125. package/dist/core/approval/paths.d.ts +0 -13
  126. package/dist/core/approval/paths.js +0 -43
  127. package/dist/core/approval/pipeline.d.ts +0 -28
  128. package/dist/core/approval/pipeline.js +0 -146
  129. package/dist/core/approval/playbook-schema.d.ts +0 -182
  130. package/dist/core/approval/playbook-schema.js +0 -51
  131. package/dist/core/approval/render.d.ts +0 -20
  132. package/dist/core/approval/render.js +0 -210
  133. package/dist/core/approval/review-pack.d.ts +0 -26
  134. package/dist/core/approval/review-pack.js +0 -205
  135. package/dist/core/approval/types.d.ts +0 -223
  136. package/dist/core/approval/types.js +0 -1
  137. package/prompts/approval/acp-pipeline.md +0 -104
  138. package/prompts/approval/ai-review.md +0 -145
  139. package/prompts/approval/api-guidance.md +0 -179
  140. package/prompts/approval/database-guidance.md +0 -105
  141. package/prompts/approval/frontend-guidance.md +0 -249
  142. package/prompts/approval/generate.md +0 -1583
  143. package/prompts/approval/multi-repo-guidance.md +0 -238
  144. package/prompts/approval/project-conventions-guidance.md +0 -171
  145. package/prompts/approval/runtime-guidance.md +0 -64
  146. package/prompts/approval/segmented-generation.md +0 -157
  147. package/skills/specflow-approval/SKILL.md +0 -663
  148. package/templates/approval-index.yaml +0 -93
  149. package/templates/approval-part.md +0 -15
  150. package/templates/approval-playbook.yaml +0 -28
  151. package/templates/approval.md +0 -261
@@ -1,663 +0,0 @@
1
- ---
2
- name: specflow-approval
3
- description: "Post-refine technical approval document -- AI closed-loop check + code/baseline grounding + over-design guard + implementability assessment"
4
- ---
5
-
6
- # SpecFlow: Approval
7
-
8
- > **HARD GATE**: phase must be `refined`. Run `/specflow:refine` first if not.
9
- > **HARD GATE**: User must confirm before `approval.md` is written to the change directory.
10
- > Approval does NOT advance phase — it produces an optional review artifact for human sign-off.
11
-
12
- ## Purpose
13
-
14
- Approval is the **post-refine, pre-apply technical review pass**: it reads the four
15
- refined artifacts (`proposal.md`, delta `specs/`, `design.md`, `tasks.md`), **grounds them
16
- against existing project code and spec baseline**, and produces a single `approval.md`
17
- technical-approval document for human sign-off.
18
-
19
- It is **optional**. Skip it when you want to go straight from refine to apply. Use it when
20
- the change is significant enough to warrant formal technical review before implementation
21
- begins — architecture decisions, cross-team impact, regulatory exposure, or any change where
22
- "should we even build this, this way?" deserves a documented answer.
23
-
24
- Unlike `/specflow:review` (which reviews code after implementation) and `/specflow:verify`
25
- (which validates implementation against specs), approval reviews the **plan** before any
26
- code is written. It fills the gap between refine convergence and apply execution.
27
-
28
- Approval does five things a deterministic CLI cannot:
29
-
30
- 1. **Integrates** the four artifacts into a single narrative with cross-references.
31
- 2. **Checks closed-loop coherence** across requirements ↔ design ↔ specs ↔ tasks using
32
- semantic reasoning (fuzzy wording detection, coverage gaps, traceability).
33
- 3. **Grounds the plan against reality** — reads existing project code (anchor files) and
34
- the main spec baseline to verify the plan can actually land on this codebase.
35
- 4. **Guards design quality** — detects over-engineering (YAGNI violations) while confirming
36
- reasonable extensibility is preserved.
37
- 5. **Assesses implementability** — can an engineer execute this plan without getting stuck?
38
-
39
- ## Invocation
40
-
41
- ```text
42
- /specflow:approval <change-name>
43
- ```
44
-
45
- Cursor: `specflow:approval <change-name>`;Codex: `$specflow-approval <change-name>`.
46
-
47
- ## Prerequisites
48
-
49
- - An active change exists with `.specflow.yaml` and `phase: refined`.
50
- - If phase is not `refined`, REFUSE to proceed and suggest: "This change is in phase
51
- `<phase>`. Run `/specflow:refine` first to complete deep review before generating an
52
- approval document."
53
- - All four refined artifacts exist in `specflow/changes/<name>/`:
54
- - `proposal.md`
55
- - `specs/**/*.md` (at least one delta spec)
56
- - `design.md`
57
- - `tasks.md`
58
- - `specflow` CLI is available on PATH (for `specflow validate` and optional status lookup).
59
- - Optional: `explore.md` with `Status: confirmed` (enriches the approval's "why" section).
60
-
61
- ## Artifact Language Setup
62
-
63
- Read `.claude/specflow/prompts/shared/artifact-language.md` and resolve the active planning
64
- root's `specflow/config.yaml` before generating `approval.md`. Apply the policy to all
65
- human-readable narrative content (summaries, assessments, evidence). Preserve protocol
66
- markers (`### Requirement:`, `#### Scenario:`, `- **WHEN**`, `- **THEN**`), capability IDs,
67
- change names, file paths, commands, and code in their original form.
68
-
69
- ---
70
-
71
- ## Stage 1: Pre-flight Validation
72
-
73
- 1. Read `.specflow.yaml` and confirm `phase: refined`. If not, refuse and suggest `/specflow:refine`.
74
- 2. Confirm all four artifacts exist. If any is missing, stop and tell the user which are missing.
75
- 3. Read `specflow/config.yaml` and resolve `artifacts.language` (default `en`).
76
- 4. Detect project tech stack signals at the project root only (do not recurse):
77
- - `package.json` → Node/TS/JS ecosystem
78
- - `go.mod` → Go
79
- - `pyproject.toml` / `requirements.txt` → Python
80
- - `Cargo.toml` → Rust
81
- - `tsconfig.json` → TypeScript (refines Node detection)
82
- - If none match, set `techStack: unknown`
83
- 5. Set `projectMode`:
84
- - `greenfield` — no meaningful application source yet (no `src/`/`app/`/`internal/`/`lib/`
85
- with real code, or only empty scaffold); Pass 6 will be SKIPPED greenfield
86
- - `brownfield` — existing product code to ground against
87
- 6. **Detect database stack** (for §4.4 guidance). Follow
88
- `prompts/approval/database-guidance.md` §1 — set
89
- `dbStack: mysql|postgresql|oracle|redis|elasticsearch|none`. Prefer OLTP
90
- (`mysql`/`postgresql`/`oracle`) over cache/search when multiple match.
91
- 7. **Scan four artifacts for tech selection coverage** (proposal / design / tasks / specs):
92
- look for explicit choices on: 前端、后端、数据库与缓存、基础设施(含 CI/部署/云)。
93
- Set `stackCoverage: complete | partial | missing`.
94
- 8. **Detect `uiInScope`** (follow `prompts/approval/frontend-guidance.md` §1):
95
- UI/控制台/页面/组件 signals → `uiInScope=yes|no`. When yes, check FE 五元组 coverage
96
- (Framework / Styling / State / UI kit / FE testing); incomplete counts as
97
- `stackCoverage=partial` for 前端.
98
- 9. Read `specflow/specs/` baseline if it exists (for Pass 7 baseline cross-check).
99
-
100
- Announce: "Generating technical approval document for change `<name>` (phase=refined,
101
- language=<lang>, projectMode=<greenfield|brownfield>, techStack=<stack>, dbStack=<db>,
102
- uiInScope=<yes|no>, stackCoverage=<complete|partial|missing>)."
103
-
104
- ---
105
-
106
- ## Stage 1b: Multi-Repo Intake (多仓)
107
-
108
- **Trigger**: user **自然语言** specifies multiple repos (talos + talos-web + worker), workset
109
- with multiple planning roots, or cross-repo design/tasks.
110
-
111
- Read **`prompts/approval/multi-repo-guidance.md`**.
112
-
113
- 1. Resolve `multi_repo.repos[]` — `id`, `label`, `role`, **per-repo `change`**, optional `root_hint`.
114
- 2. **Read four refined artifacts from each repo** before Pass 1.
115
- 3. **User gate (hard)** — ask before writing any approval file:
116
-
117
- ```text
118
- 跨 N 个仓库,审批技术文档如何产出?
119
- A) 一份合订视图 (bundle) — 各仓 per_repo 真源 + CLI bundle 只读合订 (**推荐**)
120
- B) 多份分仓 (per_repo) — 每仓各自 approval.md(默认 Map 模式)
121
- C) 一份 LLM 合订 (legacy unified) — 仅当用户明确要求且无 bundle;不推荐
122
- ```
123
-
124
- 4. **A (recommended)**: `document_mode: per_repo` + `multi_repo.bundle.enabled: true` + primary repo for playbook output; **B**: per_repo only; **C**: legacy unified (discourage).
125
- 5. If **A or C** — ask **主仓** for playbook/bundle output path.
126
- 6. Write `approval/index.yaml` → `multi_repo` + `acp.pipeline: acp/v2`.
127
- 7. **Per_repo**: Stage 12 + ACP **per repo**; if **A**, run `specflow approval bundle` after all repos assemble.
128
-
129
- Single-repo → skip (`multi_repo.enabled=false`).
130
-
131
- ---
132
-
133
- ## Gate: Tech Stack Intake (0→1 / 四件套缺选型)
134
-
135
- **Trigger** (any):
136
-
137
- - `projectMode = greenfield`, **or**
138
- - `stackCoverage = missing | partial` for dimensions this change needs
139
- (e.g. UI change needs 前端; persistence needs 数据库与缓存; ship needs 基础设施)
140
-
141
- **Do NOT** invent a full stack. **STOP and ask the user** in chat (structured), then wait:
142
-
143
- ```text
144
- 本变更需要补全技术选型(四件套未写清 / 0→1 绿场)。请确认或补充下列方向
145
- (可写「本变更不涉及」跳过某一维):
146
-
147
- 1. 前端:Framework / Styling / State / UI kit / FE testing(五元组;或不涉及前端)
148
- 2. 后端:语言/框架、API 风格(HTTP/gRPC/…)、进程模型
149
- 3. 数据库与缓存:主存(MySQL/PG/…)、缓存(Redis/…)、搜索(若有)
150
- 4. 基础设施:运行环境(K8s/VM/Serverless)、CI/CD、对象存储/消息队列(若有)
151
- 5. 其它约束:公司强制栈、禁止项、必须复用的现网组件
152
-
153
- 若本变更含 UI 且前端仍不清,追问(可合并一次问完):
154
- - 关键页面/路由清单(或「沿用现网,本迭代只改某页」)
155
- - 验证命令(dev / test / e2e / browser)
156
- - (可选)若用 v0/Lovable 等 AI builder:导出与本地可构建计划
157
-
158
- 回复示例:
159
- 前端 Next.js+TS / Tailwind / Zustand / shadcn / Vitest+Playwright;
160
- 后端 Go+Gin;DB MySQL 8 + Redis;基础设施 K8s + GitHub Actions;
161
- 禁止自建消息队列,复用公司 Kafka。
162
- ```
163
-
164
- After the user answers:
165
-
166
- 1. Record answers for §2.2 技术选型 + fold into §2.4 决策评审表 (new D-rows).
167
- 2. Suggest (do not force) updating `design.md` via `/specflow:refine` later; approval may
168
- proceed with chat-confirmed stack for this `approval.md` only.
169
- 3. Re-run dbStack detection if the user named a DB; re-check FE 五元组 if UI in scope.
170
- 4. Continue subsequent stages.
171
-
172
- If the user refuses to choose and the change clearly needs a stack → mark
173
- `[待 refine 澄清: 技术选型]` and **do not** fabricate architecture/DDL/页面树 around a
174
- guessed stack.
175
-
176
- ---
177
-
178
- ## Stage 2: Load Execution Instructions
179
-
180
- Read these files and follow them:
181
-
182
- 1. `.claude/specflow/prompts/approval/generate.md` (or repo `prompts/approval/generate.md`)
183
- 2. `prompts/approval/database-guidance.md` — SpecFlow DB **guidance pack** router
184
- 3. `prompts/approval/frontend-guidance.md` — UI scope + FE 五元组 + §4.6 contract
185
- 4. `prompts/approval/project-conventions-guidance.md` — **project** skill/rule/docs
186
- lazy-load (architecture / api / database / frontend); cross-IDE path resolve;
187
- priority **project > SpecFlow guidance > LLM**
188
-
189
- `generate.md` + convention/DB/FE routers together specify:
190
-
191
- - The 7-dimension closed-loop verification (Passes 1–7)
192
- - Design quality, architecture, detailed design, test/deploy (optional chapters), implementability
193
- - Document order: §1 → §2 → §3 → §4 → **(optional §5)** → §6 → **(optional §7/§8)** → §9 → §10(签字栏 only)
194
- - **Quality Gates G1–G6** + **Style & Tone**(含禁止正文代码腔)
195
- - **Optional chapters** §5 / §7 / §8 — ask before write; **AI 预审** chat-only
196
- - **Project conventions** lazy-load before §3/§4.4/§4.5/§4.6; **project > SpecFlow guidance > LLM**
197
- - **DB guidance** after project DB conventions; resolve
198
- `{ide}/specflow/guidance/database/<stack>/` (or package `skills/database/`); record
199
- 项目约定 + DB 技能 + `dbStack` in §4.4.1; never fetch remote / MCP
200
- - **FE guidance** when `uiInScope=yes`: `frontend-guidance.md` §3 **must** scan
201
- IDE skills/rules + 落地文档(组件/路由/状态/表单/样式/a11y/测试) + `topic=frontend`;
202
- §4.6 cites 项目约定 + IDE skills/rules; G5/G6; Visual Loop; never invent page trees
203
- - **Tech stack intake**: greenfield or four-artifacts missing 前端/后端/数据库与缓存/基础设施
204
- → ask user before inventing stacks; FE needs 五元组; record in §2.2; never fabricate
205
-
206
- You MUST read `generate.md` before any analysis or writing `approval.md`.
207
-
208
- ---
209
-
210
- ## Stage 3: Extract Anchor Files
211
-
212
- Before running the closed-loop passes, extract the set of **anchor files** that the plan
213
- references. These are the files Pass 6 (Code Grounding) will read.
214
-
215
- **Extraction rules** (defined in detail in `generate.md` Part A → Pass 6):
216
-
217
- 1. Scan `design.md` and `tasks.md` for file path references (backtick-quoted paths, code
218
- blocks, or inline paths like `src/core/...`).
219
- 2. Collect only paths under the project root that look like source files (`.ts`, `.js`,
220
- `.py`, `.go`, `.rs`, `.kt`, `.java`, etc.) or config files (`package.json`, `tsconfig.json`,
221
- etc.).
222
- 3. Deduplicate. Do NOT read directories, only files.
223
- 4. **Depth limit: read the anchor file itself only.** Do not follow imports, do not recurse.
224
- 5. If no anchor files are found and the project has no source code (greenfield), Pass 6
225
- will emit `skipped (greenfield — no existing code)`. If the project HAS source code but
226
- the plan references no existing files, that is a `FAIL` (plan is ungrounded).
227
-
228
- Announce the extracted anchor file list to the user before Pass 1 begins.
229
-
230
- ---
231
-
232
- ## Stage 4: AI Closed-Loop Verification
233
-
234
- Perform the 7 closed-loop passes defined in `generate.md`, in order:
235
-
236
- ### Internal coherence (Passes 1–5)
237
-
238
- 1. **Pass 1 — Requirement Closure**: proposal ↔ specs coverage
239
- 2. **Pass 2 — Design Closure**: design decisions ↔ spec requirements
240
- 3. **Pass 3 — Spec Closure**: scenario completeness + testability (3-level grading) + delta integrity
241
- 4. **Pass 4 — Implementation Closure**: tasks ↔ spec requirements coverage + granularity
242
- 5. **Pass 5 — Risk Closure**: risks ↔ mitigations + BREAKING migration + unidentified risks
243
-
244
- ### External grounding (Passes 6–7)
245
-
246
- 6. **Pass 6 — Code Grounding**: design/tasks anchor files exist in the project + structure
247
- compatibility + tech-stack consistency. Reads actual project code (anchor files only).
248
- 7. **Pass 7 — Baseline Cross-Check**: delta specs vs `specflow/specs/` main baseline —
249
- conflict detection, duplicate-definition detection, MODIFIED name matching.
250
-
251
- Each Pass must produce a brief result for the conversation (verdict + one-line evidence).
252
- Do **not** dump full coverage matrices into chat unless the user asks or a Pass is
253
- `WARNING`/`FAIL`.
254
-
255
- ### Closed-Loop Overall Verdict
256
-
257
- After all 7 Passes:
258
-
259
- - `FAIL` if any Pass is `FAIL`
260
- - `PASS WITH WARNINGS` if no `FAIL` but at least one `WARNING`
261
- - `PASS` if all Passes are `PASS` (a `SKIPPED` Pass does not affect the verdict)
262
-
263
- When writing `approval.md` **§8** (only if the user opted in), use the **single compact
264
- table** only (see generate.md Part E §8). Always run Passes 1–7 for the **chat** summary
265
- even when §8 is omitted from the document. Expand evidence only for ⚠️/❌ rows
266
- (max 2–3 bullets); PASS/SKIPPED stay one line.
267
-
268
- ---
269
-
270
- ## Stage 5: Design Quality Assessment
271
-
272
- Perform the two design-quality checks defined in `generate.md` Part B:
273
-
274
- ### Over-Engineering Check
275
-
276
- Scan `design.md` and `tasks.md` for the 5 over-engineering signals:
277
-
278
- 1. Interface for unrequested requirements
279
- 2. Unnecessary abstraction layers
280
- 3. Pre-built unused infrastructure
281
- 4. Config fields beyond current needs
282
- 5. Complexity exceeding problem scale
283
-
284
- **Verdict rule**: 1 signal → `WARNING`; 3+ signals → `FAIL`; 0 signals → `PASS`.
285
-
286
- ### Extensibility Assessment
287
-
288
- Scan `design.md` for the 5 extensibility signals:
289
-
290
- 1. Namespace reservation
291
- 2. Stable interface, replaceable implementation
292
- 3. Explicit Non-Goals
293
- 4. Backward-compatibility path
294
- 5. Decision rationale mentions extensibility trade-off
295
-
296
- **Verdict rule**: 4-5 signals present → `PASS`; 2-3 → `WARNING`; 0-1 → `WARNING`.
297
-
298
- ### Combined Design Quality Verdict
299
-
300
- - `FAIL` if over-engineering is `FAIL`
301
- - `WARNING` if either check is `WARNING`
302
- - `PASS` if both are `PASS`
303
- - **Special**: if over-engineering = `WARNING`/`FAIL` AND extensibility = `WARNING` →
304
- escalate to `FAIL` (the plan is both bloated AND not extensible)
305
-
306
- ---
307
-
308
- ## Stage 6: Architecture Design
309
-
310
- **Before drafting §3**: follow `project-conventions-guidance.md` with `topic=architecture`
311
- (lazy-load ≤3 project convention files). Apply project bans to 图要点; cite path or「未发现」.
312
-
313
- Produce the **architecture design** section (approval.md **§3**) defined in
314
- `generate.md` Part E.
315
-
316
- It is complementary to Detailed Design: architecture is about **module-to-module
317
- relationships** (macro), detailed design is about **module-internal implementation**
318
- (micro). Architecture is placed **before** acceptance criteria so implementers read
319
- structure first.
320
-
321
- ### 3.1 Overall Architecture
322
-
323
- Draw Mermaid diagram(s) — module dependency / layered and optionally system interaction:
324
-
325
- Requirements:
326
-
327
- 1. **Mark changed modules** (`[新增]` / `[修改]`) so the change surface is visible.
328
- 2. Label edges with dependency direction or interaction messages.
329
- 3. Project-type mapping: CLI/library → `src/core/*`, `src/cli/*`; Web → services/components;
330
- multi-repo → repositories/services.
331
- 4. Consistent with **§2** decisions.
332
- 5. **Hard rule — 图要点说明**: every architecture diagram MUST be followed by a numbered
333
- 「设计说明 / 图要点」list (boundaries, invariants, reuse vs new) — not a restatement of
334
- node names. Align with scenario-job-compile §3 style.
335
-
336
- ### 3.2 Core Components
337
-
338
- | Component | Responsibility | Boundary (does / does NOT) | Depends on | Change type |
339
- |-----------|---------------|----------------------------|-----------|-------------|
340
-
341
- Requirements: list added+modified components;「不做什么」boundaries; 1:1 with diagram;
342
- trace to §2 decisions. Optional short「组件边界总原则」list.
343
-
344
- **If no architecture change**: write explicit `不涉及架构变更(...)` marker.
345
-
346
- ### 3.3 Architecture Consistency Self-check
347
-
348
- - Diagrams mark added/modified modules; each has 图要点说明.
349
- - Each component has a "does NOT do" boundary; diagram ↔ table 1:1.
350
- - Boundaries trace to §2 decisions.
351
-
352
- Present the architecture design to the user as part of the confirmation summary.
353
-
354
- ---
355
-
356
- ## Stage 7: Detailed Design
357
-
358
- Produce the **detailed design** section (approval.md **§4** 方案详细设计) defined in
359
- `generate.md` Part E.
360
-
361
- **Selective** categories; uninvolved ones get explicit「不涉及 X」markers.
362
-
363
- Order and hard requirements (from `generate.md` §4.1–4.9):
364
-
365
- 1. **设计要点一览** — P1…Pn invariants from design decisions (required).
366
- 2. **核心业务时序 · Happy Path** — complete Mermaid `sequenceDiagram` for the main success
367
- path + post-diagram「设计要点」(required).
368
- 3. **业务场景时序** — each scenario: purpose + diagram + **设计要点说明** (required notes;
369
- bare diagrams fail quality).
370
- 4. **数据结构** — Before §4.4: (1) `project-conventions-guidance.md` `topic=database`;
371
- (2) `database-guidance.md` + SpecFlow guidance pack / `dbStack`; (3) live DDL/anchors.
372
- Priority: **project + live DDL > SpecFlow pack > LLM**. §4.4.1 must list 项目约定 + DB 技能.
373
- **Outline**: only `4.4.1–4.4.4` + `##### table`; DDL/字段说明/JSON = `**bold**`.
374
- 5. **接口设计** — Before §4.5: (1) `project-conventions-guidance.md` `topic=api`;
375
- (2) **`api-guidance.md`** — 契约面分层(L2/L3/L4 各独立 `In`)、RPC 锁名、proto/OpenAPI 可生成包;
376
- (3) live proto/OpenAPI/anchors.
377
- Then inventory + **each surface** fields + examples + errors + **Proto 草案**(新增 RPC).
378
- **禁止** L2 HTTP 详写 + L4「内部调用」stub; **禁止**「暂定/如/实现时」RPC 名。
379
- **Outline**: only `4.5.1–4.5.3` + `##### In`; 请求体字段/示例/错误 = `**bold**`.
380
- 6. **前端 / UI** — When `uiInScope=yes`: before §4.6:
381
- (1) `project-conventions-guidance.md` `topic=frontend`;
382
- (2) **`frontend-guidance.md` §3** — 强制扫描 IDE skills/rules(`.cursor`/`.claude`/`.agents`)
383
- 与落地文档(组件命名、路由、状态、表单、API client、样式/token、a11y、测试命令、lint 禁令);
384
- 合计 ≤5 文件,禁止 `invoke` skill;
385
- (3) live UI anchors from design/tasks.
386
- Then write 五元组 + 页面/路由 + Page 详设(空/加载/错态) + 状态 + Visual Loop.
387
- §4.6.1 must list **项目约定** + **IDE skills/rules**.
388
- **Outline**: only `4.6.1–4.6.5` + `##### Page · …`. **G5/G6**. Omit chapter if no UI.
389
- 7. **核心算法 / 配置 / 兼容性** — §4.7–4.9 as applicable.
390
-
391
- **Traceability**: every element → **§5** Requirement/Scenario and **§2** decision.
392
- If not implementer-ready, mark `[待 refine 澄清: <元素>]`.
393
-
394
- Present the detailed design to the user as part of the confirmation summary.
395
-
396
- ---
397
-
398
- ## Stage 8: Acceptance Criteria (optional)
399
-
400
- **Ask the user** whether to include **§5 验收标准** in `approval.md`.
401
-
402
- - If **yes**: produce §5 only **after** §3/§4 are drafted; exhaustive Requirement +
403
- Scenario list with 3-level testability.
404
- - If **no**: omit the entire chapter (no placeholder).
405
-
406
- ---
407
-
408
- ## Stage 9: Test Strategy
409
-
410
- Produce **§6 测试策略**. If §5 is included, every criterion maps to ≥1 test layer.
411
- If §5 was omitted, map layers to named Requirement/Scenario from delta specs.
412
-
413
- ---
414
-
415
- ## Stage 10: Deployment & Release (optional)
416
-
417
- **Ask the user** whether to include **§7 部署/发布/回滚**. If yes, produce the section;
418
- if no, omit entirely.
419
-
420
- ---
421
-
422
- ## Stage 10b: Closed-Loop table (optional)
423
-
424
- Closed-loop **analysis** (Passes 1–7) always runs. **Ask the user** whether to include
425
- **§8 闭环性检查表** in the document. If no, omit §8; still report overall verdict in chat.
426
-
427
- ---
428
-
429
- ## Stage 11: Implementability Assessment
430
-
431
- Perform the 7 implementability dimensions defined in `generate.md` Part C.
432
-
433
- 1. **Completeness** — no TODOs, placeholders, vague tasks
434
- 2. **Spec Alignment** — tasks cover all spec requirements, no scope creep
435
- 3. **Task Actionability** — can an engineer execute each task without ambiguity
436
- 4. **Technical Feasibility** — design decisions are achievable in the detected tech stack
437
- 5. **Dependency Clarity** — task dependencies and external dependencies are explicit
438
- 6. **Architecture Consistency** — design choices match project's existing tech stack, directory structure, error-handling patterns, and test framework (grounded in code reading from Pass 6)
439
- 7. **Implementation Risk** — high-risk module changes, data migration, concurrency, external API breaks, team tech-stack unfamiliarity
440
-
441
- Each dimension produces a verdict (`READY` | `NEEDS REFINEMENT` | `BLOCKED`) with evidence.
442
-
443
- ### Implementability Overall Verdict
444
-
445
- - `BLOCKED` if any dimension is `BLOCKED`
446
- - `NEEDS REFINEMENT` if no `BLOCKED` but any dimension is `NEEDS REFINEMENT`
447
- - `READY` if all 7 are `READY`
448
-
449
- ---
450
-
451
- ## Stage 12: Generate approval.md (Index → Map → CLI Reduce)
452
-
453
- Follow `generate.md` Part E (structure) and Part F (segmented pipeline + anti-lazy rules).
454
- Read `prompts/approval/segmented-generation.md` when `mode=segmented`; read `prompts/approval/acp-pipeline.md` for ACP verify/finalize flow.
455
-
456
- **Output artifact**: `specflow/changes/<name>/approval.md`
457
- **Workspace** (segmented): `specflow/changes/<name>/approval/` — `index.yaml`, `analysis.json`, `parts/*.md`, `manifest.json`
458
-
459
- ### 12.0 Mode selection (before writing)
460
-
461
- | Trigger | Mode |
462
- |---------|------|
463
- | `tables > 2` OR `interfaces > 3` OR `pages > 2` OR user opted §5 | **segmented** (mandatory) |
464
- | Else | ask user: **segmented** (recommended) or **monolithic** |
465
-
466
- Copy `templates/approval-index.yaml` → `approval/index.yaml`; fill `tables[]` / `interfaces[]` / `pages[]` with stable ids and `part` paths **before** any Map batch.
467
-
468
- **Anti-lazy (hard)**: when segmented, **never** one-shot the full `approval.md`; **never** stub parts (`TODO` / `待补充` / empty); **always** finish with `specflow approval finalize` (Stage 12f).
469
-
470
- ### 12a Index + Skeleton
471
-
472
- Write **first** (Gate depends on this):
473
-
474
- 1. `approval/index.yaml` — full `parts_order`, entity inventory, `optional.s5/s7/s8`, `mode`
475
- 2. `approval/analysis.json` — Pass 1–7 + quality + implementability summaries
476
- 3. `approval/parts/` skeleton:
477
- - `01-intro.md` … `03-architecture.md`
478
- - `04-detail-core.md` (§4.1–4.3 only)
479
- - `06-test.md`, `09-implementability.md`, `10-signoff.md`
480
-
481
- Use `templates/approval-part.md` fragment header; parts use `###`/`####` only — **no** foreign `## N.` headings.
482
-
483
- ### 12b Map Append (batched §4.4 / §4.5 / §4.6 / §4.7–§4.9)
484
-
485
- Per batch, Read only: `index.yaml`, `analysis.json` digests, design/tasks/spec snippets for batch ids, lazy-loaded conventions (caps per topic), anchor files.
486
-
487
- Respect `index.batching.*_per_call`. After each part: update `approval/manifest.json` entry.
488
-
489
- Minimums (no shortcuts — see Part E hard rules 9–10, 18–20):
490
-
491
- - §4.4 batch: DDL + 字段说明 + 本迭代用法 per table; G3/G4 when applicable
492
- - §4.5 batch: **Read `api-guidance.md`**; one `In` per contract surface (L2 Worker HTTP / L3 RPC / L4 client RPC — no collapsing)
493
- - meta + fields + success examples + **failure example (G2)** + error table per interface (**含不变**)
494
- - **新增 RPC**: frozen `Service.Method` + proto field numbers + `google.api.http` + Gateway registration + Worker OpenAPI pointer
495
- - **禁止** 暂定/如/实现时 RPC; **禁止** L4 stub when L2 is fully written
496
- - §4.6 batch (when `uiInScope`): IDE skills/rules scan first; page/route + states + G6; §4.5 `In` refs
497
-
498
- ### 12c Optional chapters
499
-
500
- Only if user accepted **and** `optional.s5/s7/s8: true` in index:
501
-
502
- - Insert `05-*` / `07-deploy` / `08-closed-loop` into `parts_order`
503
- - §8: one table only (from analysis)
504
-
505
- ### 12e AI Review (ACP — in-session, mandatory for non-lightweight)
506
-
507
- Read **`prompts/approval/ai-review.md`**. This step runs **inside `/specflow-approval`** — not as separate user-facing commands.
508
-
509
- 1. Run once (or when paused): `specflow approval finalize <change>` — if `review-result.json` missing, CLI pauses and writes `review-packet.json`.
510
- 2. Read `review-packet.json` + all parts; fix **parts only**; write `approval/review-result.json` (use `specflow approval review-hashes <change> --json` for `part_hashes`).
511
- 3. Use **generic long-document checks** in `ai-review.md` (R1–R13). Load optional packs (`runtime-guidance.md`, `api-guidance.md`) **only** when the change design requires them.
512
-
513
- Set in `index.yaml`:
514
-
515
- ```yaml
516
- acp:
517
- pipeline: acp/v2
518
- review:
519
- enabled: true
520
- required_pass: true
521
- ```
522
-
523
- ### 12f Finalize (one CLI — preferred)
524
-
525
- After Map + AI Review, **one command** finishes Verify → Reduce → optional bundle:
526
-
527
- ```bash
528
- specflow approval finalize <change> [--bundle] [--workspace-root <workset-root>]
529
- ```
530
-
531
- Chains: `lint --strict` → `review-check` → `check` → `assemble --force` → `bundle` (when `multi_repo.bundle.enabled`).
532
-
533
- **Do not** ask the user to run `lint` / `review-pack` / `review-check` / `assemble` separately unless debugging a single stage.
534
-
535
- Low-level subcommands (`lint`, `review-pack`, `assemble`, …) remain for CI hooks and troubleshooting — not the default skill path.
536
-
537
- ### 12g Multi-repo bundle
538
-
539
- When `multi_repo.bundle.enabled`, `finalize --bundle` (or auto) produces readonly `approval-unified.md` from `approval-playbook.yaml`. **Apply 只用各仓 approval.md 真源。**
540
-
541
- Optional HTML: `specflow approval render <change>` or `finalize --render` → `approval.html` (browser-readable; mermaid via CDN).
542
-
543
- ### Monolithic fast path
544
-
545
- When user chose `mode: monolithic` and lightweight inventory: write `approval.md` directly **or** parts + single assemble. Same Part E quality bars apply.
546
-
547
- Document chapter order (hard for included chapters):
548
-
549
- 1. §1 绪论与边界
550
- 2. §2 技术方案评估 — **可读中文**写现状与约束(禁止代码腔堆砌)
551
- 3. §3 架构整体设计
552
- 4. §4 方案详细设计
553
- 5. §5 验收标准 — **仅用户确认要时**
554
- 6. §6 测试策略
555
- 7. §7 部署 — **仅用户确认要时**
556
- 8. §8 闭环表 — **仅用户确认要时**(分析仍必做)
557
- 9. §9 可实施性评估
558
- 10. §10 审批 — **仅人工签字栏**(无 AI 预审小节)
559
-
560
- Key rules (all modes):
561
-
562
- - §1 truthful; Journey traces to §5 if present else named specs; Non-Goals with reasons.
563
- - **§2.2 技术选型**: required for greenfield or when four artifacts lack needed stack
564
- dimensions; only after Tech Stack Intake (user confirm); never invent full stack.
565
- Frontend (when UI) needs 五元组, not「React」alone.
566
- - Decision Review includes every `design.md` decision (plus D-FE/D-BE/D-DB/D-Infra when intake ran).
567
- - §5 when included: exhaustive + after §3/§4.
568
- - §3/§4 hard bars + outline hygiene; **G1–G6**; Style & Tone including **no code-dump prose**.
569
- - §4.6 when `uiInScope`: pages/routes + G5/G6 + Visual Loop; **must Read** IDE
570
- skills/rules/落地规约 before draft; cite paths in §4.6.1; omit if no UI.
571
- - §8 when included: one compact table; always report closed-loop verdict in chat.
572
- - Test Strategy maps to §5 or specs names; Deployment only if opted in.
573
- - Sign-off blank; **never** write AI pre-approval into the file; never recommend approve if any verdict is `FAIL`.
574
-
575
- ---
576
-
577
- ## Gate: User Confirmation
578
-
579
- Present a summary to the user (**chat only** — these are not document chapters):
580
-
581
- - Closed-loop overall verdict (PASS / PASS WITH WARNINGS / FAIL)
582
- - Design quality verdict (PASS / WARNING / FAIL)
583
- - Implementability overall verdict (READY / NEEDS REFINEMENT / BLOCKED)
584
- - **AI pre-approval recommendation** (建议批准 / 有条件批准 / 退回 refine / 拒绝) + 理由
585
- - The path where `approval.md` will be written (**all paths** if `multi_repo.document_mode=per_repo`)
586
-
587
- If `multi_repo.enabled`, confirm document mode + primary repo (unified) are already in `index.yaml`.
588
-
589
- Ask explicitly about **optional chapters** (record in `approval/index.yaml` → `optional.s5/s7/s8`):
590
-
591
- ```text
592
- 是否将以下章节写入审批文档?
593
- - §5 验收标准: 要 / 不要
594
- - §7 部署/发布/回滚: 要 / 不要
595
- - §8 闭环性检查表: 要 / 不要
596
- ```
597
-
598
- If not forced segmented, ask generation mode:
599
-
600
- ```text
601
- 审批文档生成方式:
602
- - segmented (推荐): 分片写入 approval/parts/,CLI 拼接 approval.md
603
- - monolithic: 一次性写入 approval.md(仅轻量变更)
604
- ```
605
-
606
- **After Stage 12a**, show index inventory (tables / interfaces / pages) and ask:
607
-
608
- > "确认 index 与可选章节后继续 Map 生成?"
609
-
610
- Do NOT run 12b until index + optional choices are confirmed.
611
-
612
- After 12b/12c, run **Stage 12e AI Review** (fix parts, write `review-result.json` with `part_hashes`).
613
-
614
- Then ask:
615
-
616
- > "确认 finalize 并写入 `specflow/changes/<name>/approval.md`?"
617
-
618
- Do NOT finalize until the user confirms (unless they already confirmed end-to-end generation).
619
-
620
- On confirmation:
621
-
622
- 1. **Segmented**: `specflow approval finalize <change>` — do not paste assembled markdown manually; do not run lint/assemble subcommands separately unless debugging.
623
- 2. **Monolithic**: write `approval.md` directly (or parts + finalize).
624
- 3. Include only optional chapters the user accepted.
625
- 4. Do **not** include「AI 预审建议」in the file.
626
- 5. Do NOT change `phase` — it remains `refined`.
627
- 6. Report the file path (and bundle path if multi-repo) and next-step suggestions.
628
-
629
- ---
630
-
631
- ## Stage 13: Next-Step Suggestions
632
-
633
- Based on the assessment results:
634
-
635
- - **If closed-loop = PASS, design quality = PASS, and implementability = READY**:
636
- Suggest `/specflow:apply` to begin implementation.
637
-
638
- - **If any verdict is WARNING**:
639
- Suggest the user either (a) proceed to `/specflow:apply` after acknowledging the warnings
640
- in the approval document, or (b) return to `/specflow:refine` to close the gaps first.
641
-
642
- - **If any verdict is FAIL or implementability = BLOCKED**:
643
- Strongly recommend `/specflow:refine` to resolve the failures before implementation.
644
- Do NOT suggest `/specflow:apply` — the plan is not ready.
645
-
646
- In all cases, remind the user that `approval.md` is an optional artifact: it does not block
647
- `/specflow:apply` (which only requires `phase=refined`), and it does not affect
648
- `/specflow:archive` (which scans `specs/`, not `approval.md`).
649
-
650
- ---
651
-
652
- ## Not Covered by Approval
653
-
654
- - No code implementation — `/specflow:apply` owns that.
655
- - No phase transition — phase stays `refined` until `/specflow:apply` advances it.
656
- - No spec validation — `/specflow:verify` owns delta + main spec regression checks.
657
- - No code review — `/specflow:review` owns post-implementation code quality checks.
658
- - No artifact modification — approval reads the four artifacts (and project code, read-only)
659
- but never modifies them. If a Pass reveals a gap, the user returns to `/specflow:refine`
660
- to fix it; approval only documents the finding.
661
- - No full codebase scan — approval reads only the anchor files extracted in Stage 3. Full
662
- codebase investigation is `/specflow:explore`'s job.
663
- - Approval is **not** a gate for apply. It is a decision-support artifact for human review.