@gordon.gan/specflow 1.8.0-beta → 1.8.2-beta

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 (181) hide show
  1. package/README.md +7 -5
  2. package/dist/cli/commands/document-run.d.ts +98 -0
  3. package/dist/cli/commands/document-run.js +1064 -0
  4. package/dist/cli/index.js +2 -2
  5. package/dist/core/artifact-language.js +11 -1
  6. package/dist/core/document/asset-paths.d.ts +15 -0
  7. package/dist/core/document/asset-paths.js +38 -0
  8. package/dist/core/document/chapters.d.ts +6 -0
  9. package/dist/core/document/chapters.js +38 -0
  10. package/dist/core/document/coverage.d.ts +25 -0
  11. package/dist/core/document/coverage.js +49 -0
  12. package/dist/core/document/digests.d.ts +40 -0
  13. package/dist/core/document/digests.js +144 -0
  14. package/dist/core/document/engine.d.ts +101 -0
  15. package/dist/core/document/engine.js +722 -0
  16. package/dist/core/document/extract.d.ts +61 -0
  17. package/dist/core/document/extract.js +437 -0
  18. package/dist/core/{approval → document}/forbidden-patterns.d.ts +4 -2
  19. package/dist/core/document/forbidden-patterns.js +36 -0
  20. package/dist/core/document/gates.d.ts +39 -0
  21. package/dist/core/document/gates.js +75 -0
  22. package/dist/core/document/input-digest.d.ts +63 -0
  23. package/dist/core/document/input-digest.js +200 -0
  24. package/dist/core/document/input-features.d.ts +43 -0
  25. package/dist/core/document/input-features.js +161 -0
  26. package/dist/core/document/lint.d.ts +39 -0
  27. package/dist/core/document/lint.js +147 -0
  28. package/dist/core/document/llm.d.ts +28 -0
  29. package/dist/core/document/llm.js +22 -0
  30. package/dist/core/document/map.d.ts +52 -0
  31. package/dist/core/document/map.js +296 -0
  32. package/dist/core/document/outline.d.ts +29 -0
  33. package/dist/core/document/outline.js +171 -0
  34. package/dist/core/document/paths.d.ts +23 -0
  35. package/dist/core/document/paths.js +36 -0
  36. package/dist/core/document/profile-validator.d.ts +23 -0
  37. package/dist/core/document/profile-validator.js +155 -0
  38. package/dist/core/document/profiles.d.ts +23 -0
  39. package/dist/core/document/profiles.js +76 -0
  40. package/dist/core/document/render.d.ts +61 -0
  41. package/dist/core/document/render.js +243 -0
  42. package/dist/core/document/review.d.ts +57 -0
  43. package/dist/core/document/review.js +202 -0
  44. package/dist/core/document/scene-detect.d.ts +32 -0
  45. package/dist/core/document/scene-detect.js +237 -0
  46. package/dist/core/document/schemas.d.ts +1111 -0
  47. package/dist/core/document/schemas.js +191 -0
  48. package/dist/integrations/shared/capability-evidence.js +4 -9
  49. package/dist/integrations/shared/command-catalog.js +2 -1
  50. package/dist/integrations/shared/parity-manifest.js +4 -9
  51. package/package.json +2 -1
  52. package/prompts/apply/phase-a-plan.md +1 -1
  53. package/prompts/document/map/acceptance.md +9 -0
  54. package/prompts/document/map/anti-ai.md +29 -0
  55. package/prompts/document/map/api-design.md +26 -0
  56. package/prompts/document/map/architecture.md +27 -0
  57. package/prompts/document/map/benchmark.md +26 -0
  58. package/prompts/document/map/closed-loop.md +9 -0
  59. package/prompts/document/map/compat-migration.md +31 -0
  60. package/prompts/document/map/component-design.md +30 -0
  61. package/prompts/document/map/config-runtime.md +9 -0
  62. package/prompts/document/map/core-flow.md +62 -0
  63. package/prompts/document/map/core-logic.md +9 -0
  64. package/prompts/document/map/data-model.md +18 -0
  65. package/prompts/document/map/deploy.md +26 -0
  66. package/prompts/document/map/fix.md +8 -0
  67. package/prompts/document/map/frontend-architecture.md +35 -0
  68. package/prompts/document/map/goal.md +8 -0
  69. package/prompts/document/map/impact.md +8 -0
  70. package/prompts/document/map/implementability.md +9 -0
  71. package/prompts/document/map/migration-guide.md +36 -0
  72. package/prompts/document/map/mvp-boundary.md +8 -0
  73. package/prompts/document/map/non-goals.md +8 -0
  74. package/prompts/document/map/ops.md +33 -0
  75. package/prompts/document/map/performance.md +32 -0
  76. package/prompts/document/map/poc-demo.md +25 -0
  77. package/prompts/document/map/regression.md +8 -0
  78. package/prompts/document/map/reproduce.md +8 -0
  79. package/prompts/document/map/requirement.md +8 -0
  80. package/prompts/document/map/research.md +25 -0
  81. package/prompts/document/map/root-cause.md +8 -0
  82. package/prompts/document/map/signoff.md +9 -0
  83. package/prompts/document/map/state-management.md +23 -0
  84. package/prompts/document/map/tech-selection.md +29 -0
  85. package/prompts/document/map/test-strategy.md +24 -0
  86. package/prompts/document/map/ui-design.md +21 -0
  87. package/prompts/document/outline/general.md +46 -0
  88. package/prompts/document/review/ai-review.md +57 -0
  89. package/prompts/document/shared/grounding.md +84 -0
  90. package/prompts/explore/explore-session.md +1 -1
  91. package/prompts/propose/design-draft.md +1 -1
  92. package/prompts/propose/proposal.md +1 -1
  93. package/prompts/propose/specs.md +1 -1
  94. package/prompts/propose/tasks-draft.md +1 -1
  95. package/prompts/refine/design-output.md +1 -1
  96. package/prompts/refine/update-artifacts.md +2 -0
  97. package/prompts/shared/artifact-language.md +13 -0
  98. package/skills/specflow-techdoc/SKILL.md +143 -0
  99. package/skills/specflow-techdoc-synth/SKILL.md +115 -0
  100. package/templates/document/chapters/acceptance.yaml +16 -0
  101. package/templates/document/chapters/api-design.yaml +29 -0
  102. package/templates/document/chapters/architecture.yaml +21 -0
  103. package/templates/document/chapters/benchmark.yaml +20 -0
  104. package/templates/document/chapters/closed-loop.yaml +22 -0
  105. package/templates/document/chapters/compat-migration.yaml +21 -0
  106. package/templates/document/chapters/component-design.yaml +22 -0
  107. package/templates/document/chapters/config-runtime.yaml +16 -0
  108. package/templates/document/chapters/core-flow.yaml +27 -0
  109. package/templates/document/chapters/core-logic.yaml +16 -0
  110. package/templates/document/chapters/data-model.yaml +25 -0
  111. package/templates/document/chapters/deploy.yaml +22 -0
  112. package/templates/document/chapters/fix.yaml +18 -0
  113. package/templates/document/chapters/frontend-architecture.yaml +22 -0
  114. package/templates/document/chapters/goal.yaml +17 -0
  115. package/templates/document/chapters/impact.yaml +16 -0
  116. package/templates/document/chapters/implementability.yaml +22 -0
  117. package/templates/document/chapters/migration-guide.yaml +21 -0
  118. package/templates/document/chapters/mvp-boundary.yaml +20 -0
  119. package/templates/document/chapters/non-goals.yaml +17 -0
  120. package/templates/document/chapters/ops.yaml +25 -0
  121. package/templates/document/chapters/performance.yaml +21 -0
  122. package/templates/document/chapters/poc-demo.yaml +22 -0
  123. package/templates/document/chapters/regression.yaml +16 -0
  124. package/templates/document/chapters/reproduce.yaml +16 -0
  125. package/templates/document/chapters/requirement.yaml +18 -0
  126. package/templates/document/chapters/research.yaml +22 -0
  127. package/templates/document/chapters/root-cause.yaml +18 -0
  128. package/templates/document/chapters/signoff.yaml +15 -0
  129. package/templates/document/chapters/state-management.yaml +22 -0
  130. package/templates/document/chapters/tech-selection.yaml +23 -0
  131. package/templates/document/chapters/test-strategy.yaml +23 -0
  132. package/templates/document/chapters/ui-design.yaml +28 -0
  133. package/templates/document/profiles/0to1.yaml +44 -0
  134. package/templates/document/profiles/approve.yaml +22 -0
  135. package/templates/document/profiles/bugfix.yaml +15 -0
  136. package/templates/document/profiles/feature.yaml +23 -0
  137. package/templates/document/profiles/frontend-0to1.yaml +47 -0
  138. package/templates/document/profiles/migration.yaml +42 -0
  139. package/templates/document/profiles/poc.yaml +46 -0
  140. package/dist/cli/commands/approval-assemble.d.ts +0 -64
  141. package/dist/cli/commands/approval-assemble.js +0 -408
  142. package/dist/core/approval/assemble.d.ts +0 -10
  143. package/dist/core/approval/assemble.js +0 -384
  144. package/dist/core/approval/bundle.d.ts +0 -9
  145. package/dist/core/approval/bundle.js +0 -172
  146. package/dist/core/approval/forbidden-patterns.js +0 -40
  147. package/dist/core/approval/index-schema.d.ts +0 -676
  148. package/dist/core/approval/index-schema.js +0 -193
  149. package/dist/core/approval/index.d.ts +0 -12
  150. package/dist/core/approval/index.js +0 -9
  151. package/dist/core/approval/lint.d.ts +0 -10
  152. package/dist/core/approval/lint.js +0 -302
  153. package/dist/core/approval/paths.d.ts +0 -13
  154. package/dist/core/approval/paths.js +0 -43
  155. package/dist/core/approval/pipeline.d.ts +0 -28
  156. package/dist/core/approval/pipeline.js +0 -146
  157. package/dist/core/approval/playbook-schema.d.ts +0 -182
  158. package/dist/core/approval/playbook-schema.js +0 -51
  159. package/dist/core/approval/render.d.ts +0 -20
  160. package/dist/core/approval/render.js +0 -210
  161. package/dist/core/approval/review-pack.d.ts +0 -26
  162. package/dist/core/approval/review-pack.js +0 -205
  163. package/dist/core/approval/types.d.ts +0 -223
  164. package/dist/core/approval/types.js +0 -1
  165. package/prompts/approval/acp-pipeline.md +0 -106
  166. package/prompts/approval/ai-review.md +0 -145
  167. package/prompts/approval/api-guidance.md +0 -179
  168. package/prompts/approval/database-guidance.md +0 -105
  169. package/prompts/approval/frontend-guidance.md +0 -249
  170. package/prompts/approval/generate.md +0 -1596
  171. package/prompts/approval/multi-repo-guidance.md +0 -263
  172. package/prompts/approval/multi-repo-spoke-subagent.md +0 -94
  173. package/prompts/approval/project-conventions-guidance.md +0 -171
  174. package/prompts/approval/runtime-guidance.md +0 -64
  175. package/prompts/approval/segmented-generation.md +0 -157
  176. package/skills/specflow-approval/SKILL.md +0 -778
  177. package/templates/approval-index.yaml +0 -93
  178. package/templates/approval-part.md +0 -15
  179. package/templates/approval-playbook-talos-scenario-job-compile.yaml +0 -29
  180. package/templates/approval-playbook.yaml +0 -28
  181. package/templates/approval.md +0 -261
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Document Engine — zod schemas (data model)
3
+ *
4
+ * Source of truth for the Generic LongDoc Engine (design doc
5
+ * docs/GENERIC_LONGDOC_ENGINE_DESIGN.md §6.2, decisions 1–9).
6
+ *
7
+ * Layered source of truth:
8
+ * - Contract entities (interfaces/tables/decisions) → structured, zod-validated
9
+ * - Narrative content → controlled Markdown fragments
10
+ * - Outline is the two-pass core IR (replaces ACP index.yaml/parts_order)
11
+ */
12
+ import { z } from 'zod';
13
+ // ============= 通用归一化(P2) =============
14
+ /** 把显式 null 归一为 undefined,使 `.default([])` 对 null 与缺键行为一致(zod v3 默认不处理 null)。 */
15
+ const nullish = (schema) => z.preprocess((v) => (v === null ? undefined : v), schema);
16
+ // ============= Field-level contract primitives =============
17
+ export const FieldSchema = z.object({
18
+ name: z.string().min(1),
19
+ type: z.string().min(1),
20
+ required: z.boolean().default(false),
21
+ desc: z.string().optional(),
22
+ default: z.string().optional(),
23
+ });
24
+ export const ErrorSpecSchema = z.object({
25
+ condition: z.string().min(1),
26
+ status: z.string().min(1),
27
+ note: z.string().optional(),
28
+ });
29
+ // ============= Contract entities =============
30
+ export const InterfaceEntitySchema = z.object({
31
+ id: z.string().trim().min(1), // stable id, e.g. "I1"
32
+ name: z.string().min(1), // e.g. "SubmitStepResult"
33
+ method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
34
+ path: z.string().min(1),
35
+ request_fields: z.array(FieldSchema).optional(),
36
+ response_fields: z.array(FieldSchema).optional(),
37
+ errors: z.array(ErrorSpecSchema).min(1), // G2: errors required
38
+ failure_examples: z.array(z.string()).min(1), // G2 hard gate
39
+ });
40
+ export const TableEntitySchema = z.object({
41
+ id: z.string().trim().min(1), // stable id, e.g. "T1"
42
+ name: z.string().min(1),
43
+ ddl: z.string().min(1),
44
+ fields: z.array(FieldSchema).optional(),
45
+ migration: z.string().optional(), // G3: fill strategy
46
+ rollback: z.string().optional(), // G4: rollback compat
47
+ });
48
+ export const DecisionEntitySchema = z.object({
49
+ id: z.string().trim().min(1), // e.g. "D1"
50
+ text: z.string().min(1),
51
+ });
52
+ export const EntitiesSchema = z.object({
53
+ interfaces: nullish(z.array(InterfaceEntitySchema).default([])),
54
+ tables: nullish(z.array(TableEntitySchema).default([])),
55
+ decisions: nullish(z.array(DecisionEntitySchema).default([])),
56
+ });
57
+ // ============= Outline (two-pass core IR, decision 6/8/9) =============
58
+ export const OutlinePointKindSchema = z.enum(['entity', 'narrative', 'mixed']);
59
+ export const OutlinePointSchema = z.object({
60
+ id: z.string().trim().min(1),
61
+ text: z.string().min(1),
62
+ required: z.boolean().default(true),
63
+ kind: OutlinePointKindSchema.default('mixed'), // decision 9: coverage channel
64
+ references: nullish(z.array(z.string()).default([])), // decision 8: entity ids (full contract injection)
65
+ source_segments: nullish(z.array(z.string()).default([])), // decision 9: original input segment ids
66
+ });
67
+ export const OutlineChapterSchema = z.object({
68
+ // 白名单字符集与 paths.ts CHAPTER_ID_RE 一致:拒绝路径分隔符/`..`/空串(防路径穿越)
69
+ id: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/, 'chapter id must be a safe identifier'),
70
+ title: z.string().min(1),
71
+ points: z.array(OutlinePointSchema).min(1),
72
+ optional: z.boolean().default(false),
73
+ });
74
+ export const OutlineEntitySchema = z.object({
75
+ id: z.string().trim().min(1),
76
+ frozen: z.string().min(1), // frozen name, must not drift
77
+ standalone: z.boolean().default(false), // decision 9: referenced by decisions only, no contract injection
78
+ });
79
+ export const FillOnceSchema = z.object({
80
+ enabled: z.boolean().default(false),
81
+ input_budget_tokens: z.number().int().positive().default(8000), // decision 9: exceed → fallback per-chapter
82
+ });
83
+ export const OutlineSchema = z.object({
84
+ profile: z.string().min(1),
85
+ chapters: z.array(OutlineChapterSchema).min(1), // order = render order
86
+ entities: nullish(z.array(OutlineEntitySchema).default([])),
87
+ decisions: nullish(z.array(z.string()).default([])),
88
+ fill_once: FillOnceSchema.optional(),
89
+ });
90
+ // ============= Constraint list (decision 8 · P1-D) =============
91
+ export const ConstraintItemKindSchema = z.enum(['entity', 'decision', 'point']);
92
+ export const ConstraintItemSchema = z.object({
93
+ kind: ConstraintItemKindSchema,
94
+ id: z.string().trim().min(1),
95
+ label: z.string().min(1), // one-line label for digest prompt
96
+ });
97
+ // ============= Chapter component (reusable) =============
98
+ export const ChapterComponentSchema = z.object({
99
+ id: z.string().trim().min(1),
100
+ title: z.string().min(1),
101
+ when: z.preprocess((v) => (typeof v === 'string' ? (v.trim() === '' ? undefined : v.trim()) : v === null ? undefined : v), z.string().optional()), // condition DSL: input.<feature> && / || / !
102
+ depends_on: nullish(z.array(z.string()).default([])),
103
+ outline_points: nullish(z.array(OutlinePointSchema).default([])), // candidate points (Pass 1 reference)
104
+ entities: z.record(z.any()).optional(), // chapter entity schema description
105
+ narratives: z.record(z.any()).optional(),
106
+ gates: nullish(z.array(z.string()).default([])),
107
+ map_prompt: z.string().optional(),
108
+ output_budget_tokens: z.number().int().positive().optional(), // per-chapter output cap
109
+ });
110
+ // ============= Scenario profile (three-way classification, decision 8 · P1-J) =============
111
+ export const ScenarioProfileSchema = z.object({
112
+ id: z.string().trim().min(1),
113
+ name: z.string().min(1),
114
+ required: z.array(z.string()).min(1), // must be included by outline
115
+ optional_candidates: nullish(z.array(z.string()).default([])), // LLM may choose (subject to when)
116
+ forbidden: nullish(z.array(z.string()).default([])), // never appear in this scenario
117
+ shared: nullish(z.array(z.string()).default([])), // global chapters allowed in dependency closure
118
+ appendices: nullish(z.array(z.enum(['anti-ai', 'handoff'])).default([])), // §7.2: rendered 附录 B/C
119
+ });
120
+ // ============= Review (decision 9 · target + max_rounds) =============
121
+ export const ReviewTargetSchema = z.enum(['entity', 'narrative', 'mixed']);
122
+ export const ReviewFindingSchema = z.object({
123
+ id: z.string().trim().min(1),
124
+ severity: z.enum(['critical', 'important', 'minor']),
125
+ category: z.string().min(1),
126
+ message: z.string().min(1),
127
+ target: ReviewTargetSchema.default('narrative'), // decision 9: what to fix
128
+ chapter: z.string().optional(),
129
+ status: z.enum(['open', 'fixed', 'waived']).default('open'),
130
+ waiver_reason: z.string().optional(),
131
+ });
132
+ export const ReviewResultSchema = z.object({
133
+ schema: z.literal('specflow.document.review/v1'),
134
+ change: z.string().min(1),
135
+ reviewed_at: z.string().min(1),
136
+ reviewer: z.enum(['ai', 'human']).default('ai'),
137
+ verdict: z.enum(['pass', 'fail', 'pass_with_waivers']),
138
+ summary: z.string().optional(),
139
+ findings: nullish(z.array(ReviewFindingSchema).default([])),
140
+ part_hashes: nullish(z.array(z.object({ id: z.string().trim().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/i, 'sha256 must be 64 hex chars') })).default([])),
141
+ /** decision 9 · tamper semantics: chapters the ENGINE legitimately changed after the review
142
+ * snapshot (entity refill / narrative fix notes). The tamper check exempts these from the
143
+ * post-review "stale" verdict — every other chapter must still match the reviewer-time
144
+ * `part_hashes` snapshot. */
145
+ post_review_repairs: nullish(z.array(z.object({ chapter: z.string().min(1), at: z.string().min(1) })).default([])),
146
+ });
147
+ export function parseReviewResult(raw) {
148
+ return ReviewResultSchema.parse(raw);
149
+ }
150
+ // ============= Parsers =============
151
+ export function parseInterfaceEntity(raw) {
152
+ return InterfaceEntitySchema.parse(raw);
153
+ }
154
+ export function parseTableEntity(raw) {
155
+ return TableEntitySchema.parse(raw);
156
+ }
157
+ export function parseDecisionEntity(raw) {
158
+ return DecisionEntitySchema.parse(raw);
159
+ }
160
+ export function parseEntities(raw) {
161
+ return EntitiesSchema.parse(raw);
162
+ }
163
+ /**
164
+ * 兼容两种章节 JSON 块格式的实体解析:
165
+ * - 未包装:`{"interfaces": [...], "tables": [...], "decisions": [...]}`(引擎推荐,validate 期望)
166
+ * - 包装:`{"entities": {"interfaces": [...]}}`(部分 map 提示词曾要求,Agent 可能照此写)
167
+ * zod 默认 strip 未知 key,若顶层只有 `entities` 会被剥成空实体——这里显式解包后再解析,
168
+ * 避免「提示词包装格式 → 实体被剥空 → validate 报缺失 → Agent 反复返工」。
169
+ */
170
+ export function parseEntitiesLenient(raw) {
171
+ if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
172
+ const obj = raw;
173
+ if (obj.entities && typeof obj.entities === 'object' && !Array.isArray(obj.entities)) {
174
+ const inner = obj.entities;
175
+ // 仅当解包后含实体字段才解包;否则保持原样(可能是非实体叙述块)。
176
+ if ('interfaces' in inner || 'tables' in inner || 'decisions' in inner) {
177
+ return parseEntities(inner);
178
+ }
179
+ }
180
+ }
181
+ return parseEntities(raw);
182
+ }
183
+ export function parseOutline(raw) {
184
+ return OutlineSchema.parse(raw);
185
+ }
186
+ export function parseChapterComponent(raw) {
187
+ return ChapterComponentSchema.parse(raw);
188
+ }
189
+ export function parseScenarioProfile(raw) {
190
+ return ScenarioProfileSchema.parse(raw);
191
+ }
@@ -7,14 +7,10 @@ const MARKER_RULES = [
7
7
  { id: 'sub.propose.first_iteration', skill: 'propose', includes: ['first-iteration deep-analysis pass'] },
8
8
  { id: 'sub.refine.multi_round', skill: 'refine', includes: ['auto-multi-round loop', '## LOOP (Stages 2-4)'] },
9
9
  { id: 'sub.refine.challenge_scope', skill: 'refine', includes: ['Challenge Behaviors #3 and #4', 'question scope'] },
10
- { id: 'sub.approval.closed_loop', skill: 'approval', includes: ['Closed-Loop Verification', 'Pass 1'] },
11
- { id: 'sub.approval.implementability', skill: 'approval', includes: ['Implementability Assessment', 'Completeness'] },
12
- { id: 'sub.approval.no_phase_change', skill: 'approval', includes: ['does NOT advance phase', 'phase stays `refined`'] },
13
- { id: 'sub.approval.code_grounding', skill: 'approval', includes: ['Code Grounding', 'Pass 6'] },
14
- { id: 'sub.approval.design_quality', skill: 'approval', includes: ['Design Quality Assessment', 'Over-Engineering'] },
15
- { id: 'sub.approval.acp_finalize', skill: 'approval', includes: ['specflow approval finalize', 'Stage 12f'] },
16
- { id: 'sub.approval.ai_review', skill: 'approval', includes: ['12e AI Review', 'part_hashes'] },
17
- { id: 'sub.approval.multi_repo_subagent', skill: 'approval', includes: ['Stage 1c', 'multi-repo-spoke-subagent'] },
10
+ { id: 'sub.techdoc.two_pass_outline', skill: 'techdoc', includes: ['outline', 'Pass 1'] },
11
+ { id: 'sub.techdoc.fill_in_by_points', skill: 'techdoc', includes: ['填空', '要点'] },
12
+ { id: 'sub.techdoc.contract_injection', skill: 'techdoc', includes: ['契约注入', 'references'] },
13
+ { id: 'sub.techdoc.coverage_check', skill: 'techdoc', includes: ['覆盖', 'coverage'] },
18
14
  { id: 'sub.apply.phase_a', skill: 'apply', includes: ['## Phase A: Task Rewrite'] },
19
15
  { id: 'sub.apply.phase_b', skill: 'apply', includes: ['## Phase B: Subagent TDD Execution'] },
20
16
  { id: 'sub.apply.gap_detection', skill: 'apply', includes: ['Gap Detection'] },
@@ -27,7 +23,6 @@ const MARKER_RULES = [
27
23
  { id: 'failure.explore.proposal_exists_redirect', skill: 'explore', includes: ['explore is too late', 'refine'] },
28
24
  { id: 'failure.propose.explore_draft_gate', skill: 'propose', includes: ['Status: draft', 'REFUSE to proceed'] },
29
25
  { id: 'failure.apply.phase_gate', skill: 'apply', includes: ['HARD GATE (prerequisite)', 'phase is not `refined`, REFUSE'] },
30
- { id: 'failure.approval.phase_gate', skill: 'approval', includes: ['phase must be `refined`', 'REFUSE to proceed'] },
31
26
  { id: 'failure.verify.explicit_skip_marker', skill: 'verify', includes: ['Pass 2: skipped (no baseline'] },
32
27
  ];
33
28
  /**
@@ -2,7 +2,8 @@ export const COMMAND_CATALOG = [
2
2
  { id: 'explore', description: 'Think-before-propose exploration when requirements are fuzzy' },
3
3
  { id: 'propose', description: 'Create proposal and spec artifacts for a change' },
4
4
  { id: 'refine', description: 'Refine and iterate on spec artifacts' },
5
- { id: 'approval', description: 'Post-refine technical approval document with AI closed-loop check' },
5
+ { id: 'techdoc', description: 'Generate scenario-based solution documents via the Generic LongDoc Engine' },
6
+ { id: 'techdoc-synth', description: 'Synthesize multi-repo four artifacts into ONE cross-repo document (document + synthesize; scene auto-detect when --profile omitted)' },
6
7
  { id: 'apply', description: 'Implement tasks from a change spec' },
7
8
  { id: 'review', description: 'Review code changes against spec' },
8
9
  { id: 'test', description: 'Run tests and verify coverage' },
@@ -13,14 +13,10 @@ export const CAPABILITY_MANIFEST = [
13
13
  { id: 'sub.propose.first_iteration', commandId: 'propose', level: 'sub-capability', required: true },
14
14
  { id: 'sub.refine.multi_round', commandId: 'refine', level: 'sub-capability', required: true },
15
15
  { id: 'sub.refine.challenge_scope', commandId: 'refine', level: 'sub-capability', required: true },
16
- { id: 'sub.approval.closed_loop', commandId: 'approval', level: 'sub-capability', required: true },
17
- { id: 'sub.approval.implementability', commandId: 'approval', level: 'sub-capability', required: true },
18
- { id: 'sub.approval.no_phase_change', commandId: 'approval', level: 'sub-capability', required: true },
19
- { id: 'sub.approval.code_grounding', commandId: 'approval', level: 'sub-capability', required: true },
20
- { id: 'sub.approval.design_quality', commandId: 'approval', level: 'sub-capability', required: true },
21
- { id: 'sub.approval.acp_finalize', commandId: 'approval', level: 'sub-capability', required: true },
22
- { id: 'sub.approval.ai_review', commandId: 'approval', level: 'sub-capability', required: true },
23
- { id: 'sub.approval.multi_repo_subagent', commandId: 'approval', level: 'sub-capability', required: true },
16
+ { id: 'sub.techdoc.two_pass_outline', commandId: 'techdoc', level: 'sub-capability', required: true },
17
+ { id: 'sub.techdoc.fill_in_by_points', commandId: 'techdoc', level: 'sub-capability', required: true },
18
+ { id: 'sub.techdoc.contract_injection', commandId: 'techdoc', level: 'sub-capability', required: true },
19
+ { id: 'sub.techdoc.coverage_check', commandId: 'techdoc', level: 'sub-capability', required: true },
24
20
  { id: 'sub.apply.phase_a', commandId: 'apply', level: 'sub-capability', required: true },
25
21
  { id: 'sub.apply.phase_b', commandId: 'apply', level: 'sub-capability', required: true },
26
22
  { id: 'sub.apply.gap_detection', commandId: 'apply', level: 'sub-capability', required: true },
@@ -33,7 +29,6 @@ export const CAPABILITY_MANIFEST = [
33
29
  { id: 'failure.explore.proposal_exists_redirect', commandId: 'explore', level: 'failure-path', required: true },
34
30
  { id: 'failure.propose.explore_draft_gate', commandId: 'propose', level: 'failure-path', required: true },
35
31
  { id: 'failure.apply.phase_gate', commandId: 'apply', level: 'failure-path', required: true },
36
- { id: 'failure.approval.phase_gate', commandId: 'approval', level: 'failure-path', required: true },
37
32
  { id: 'failure.verify.explicit_skip_marker', commandId: 'verify', level: 'failure-path', required: true },
38
33
  ];
39
34
  export const IDE_ASSET_MANIFEST = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gordon.gan/specflow",
3
- "version": "1.8.0-beta",
3
+ "version": "1.8.2-beta",
4
4
  "type": "module",
5
5
  "description": "SpecFlow — unified spec-driven development: OpenSpec planning + Superpowers execution in one CLI and cross-IDE workflow",
6
6
  "keywords": [
@@ -55,6 +55,7 @@
55
55
  "release:major": "npm version major && git push && git push --tags"
56
56
  },
57
57
  "dependencies": {
58
+ "@gordon.gan/specflow": "^1.8.0-alpha",
58
59
  "chalk": "^5.4.1",
59
60
  "commander": "^13.1.0",
60
61
  "js-yaml": "^4.1.0",
@@ -18,7 +18,7 @@
18
18
 
19
19
  ## Artifact Language
20
20
 
21
- Before rewriting, resolve `artifacts.language` from the active planning root's `specflow/config.yaml` (see shared `artifact-language.md`). Rewrite **group titles and task description prose** in that language (`zh-CN` → Simplified Chinese; `en` → English). Keep file paths, commands, code blocks, symbols, and Verify command text unchanged. Do not switch business narrative to English when `zh-CN` is configured.
21
+ Before rewriting, resolve `artifacts.language` from the active planning root's `specflow/config.yaml` (see shared `artifact-language.md`). Rewrite **group titles and task description prose** in that language (`zh-CN` → Simplified Chinese; `en` → English). Keep file paths, commands, code blocks, symbols, and Verify command text unchanged. Do not switch business narrative to English when `zh-CN` is configured. zh-CN: 叙述简要;怎么做用 1. 2. 3.。
22
22
 
23
23
  ## Input Order
24
24
 
@@ -0,0 +1,9 @@
1
+ # 章节填充:acceptance
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
@@ -0,0 +1,29 @@
1
+ # 附录填充:anti-ai(去AI味自检 · 附录 B)
2
+
3
+ 你是方案文档撰写员。为整份方案写「去AI味自检」条目,写入 `appendices/anti-ai.md`。
4
+
5
+ ## 硬规则(frontend-dev-guide §十一 → README §1.6)
6
+
7
+ 1. **至少 3 条**:每条自检对应五维中的一维,格式 `- 维度名:自检陈述`(如 `- 不做决策:明确写了本期不做什么(…),不是只列功能清单`)。
8
+ 2. **对着五维写**:
9
+ | 维度 | 自检问题 | AI 味反例 |
10
+ |------|---------|----------|
11
+ | 不做决策 | 明确说了「不做什么」? | 只列功能清单 |
12
+ | 数字具体 | 指标/约束具体到数字? | 「提升体验」 |
13
+ | 竞品立场 | 与竞品差异有一句话立场? | 「借鉴头部最佳实践」 |
14
+ | 此刻合理性 | 为什么现在做?不做会怎样? | 不解释时机 |
15
+ | 优先级倾斜 | P0/P1 有倾斜逻辑? | 全功能同等权重 |
16
+ 3. **必须引用本文档的实际内容**:每条自检要能指到正文里的具体段落/数字(如「正文 §Benchmark 给了原始测量值 82ms/320ms,不是只说『更快』」)。禁止写与本文档无关的通用自检。
17
+ 4. **诚实**:自检条目是「我确实做到了」的声明,不是愿望清单。没做到的维度不要硬凑,写「本迭代不适用」并说明理由。
18
+ 5. **禁止 stub**(TODO/待补充/此处省略);每条不少于 15 字。
19
+
20
+ ## 输出示例
21
+
22
+ ```markdown
23
+ - 不做决策:明确写了预研不做架构/接口/UI 实现设计(§6.3 分界),不是只列候选功能。
24
+ - 数字具体:benchmark 给出同条件同设备原始测量值(冷启动 82ms vs 320ms),不是「性能大幅提升」。
25
+ - 竞品立场:一句话立场写明「本项目不选 Bun」及原因,不是「借鉴头部最佳实践」。
26
+ - 此刻合理性:说明了本次预研触发点(生态缺口风险),不做会怎样已写(§research)。
27
+ ```
28
+
29
+ > 优先级:项目约定 > SpecFlow guidance > LLM。
@@ -0,0 +1,26 @@
1
+ # 章节填充:api-design(接口设计 · 契约 + 前端对接)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+
10
+ ## 接口章节硬规则(借鉴 approval api-guidance + F1/F2 前端对接合并)
11
+
12
+ 1. **分层契约,禁止混层**:每个契约面对应一个独立 `In`(L2 Worker HTTP / L3 RPC+HTTP / L4 客户端 RPC),禁止「内部经 I7 一行代替 L4 详设」。
13
+ 2. **RPC / 服务名冻结**:禁止「暂定 / 如 Xxx / 实现时命名」;给出冻结的 RPC 名 + proto 字段号 + http_path。
14
+ 3. **proto 最小集**:新接口尽量给出可生成的 Proto 草案(rpc 名 / message / field 编号 / google.api.http)。
15
+ 4. **G2 失败示例(强制)**:清单中每个接口(含「不变」)除成功示例外,必须 ≥1 组失败示例(参数校验失败/租约过期/未认证),附完整 HTTP 或等价示例。只有错误码表不合格。
16
+ 5. **固定顺序**:元信息 → 请求体字段(或路径/Query/CLI flags)→ 请求示例 → 成功响应字段 → 响应示例(成功) → 响应示例(失败)(G2) → 错误表 →(可选)处理顺序。
17
+ 6. **接口清单稳定编号**:`In` 稳定,供页面引用与跨章交叉引用。
18
+
19
+ ## 前端对接维度(O5–O7,F1 §2.2 合并「契约+对接」)
20
+
21
+ 7. **前端请求封装**:统一请求层(拦截器:token 注入/统一错误处理/超时/重试策略/缓存),DTO → VO 映射层。禁止「每个页面自己 fetch + 自己处理错误」。
22
+ 8. **前端错误处理统一**:后端错误码 → 前端统一错误态映射(Loading-Empty-Error),禁止前后端各写一套错误码约定。
23
+ 9. **接口 Mock 与契约先行**:前端并行开发用 Mock,Mock 的数据结构必须与冻结契约一致(R5);联调时切换真实接口不改变前端代码结构。
24
+ 10. **优先级**:项目约定 + 现网 OpenAPI/proto > SpecFlow 骨架 > LLM。
25
+
26
+ > 前后端契约一致性是本章最高门禁:字段名、错误码、DTO 结构前后端必须对齐,禁止各写各的。
@@ -0,0 +1,27 @@
1
+ # 章节填充:architecture(架构设计 · C4 分层 + ADR)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+
10
+ ## 架构章节硬规则(G1 + README §1.7 + C4/ADR,见 f1-0to1.md §2.7.4)
11
+
12
+ 1. **架构图必须有图 + 文字(README §1.7 门禁)**:
13
+ - Mermaid 组件图/容器图(```mermaid block)。
14
+ - 图后逐节点说明职责/边界/「不放什么」,禁止只复述节点名,也禁止只有图无文字。
15
+ - 超 5 行流程必须 Mermaid(G1)。
16
+
17
+ 2. **每个组件必须写「不做什么」边界**(反AI决策 #1 在架构层):组件职责一句话 + 明确不放什么(如「网关不做业务逻辑」「缓存层不做持久化」)。
18
+
19
+ 3. **C4 分层(AR4)**:按需给 Context(系统上下文,外部系统/用户)/ Container(可部署单元:Web/API/DB/消息)/ Component(模块组件)分层;每层给依赖方向。与 core-flow 的组件层交互时序对接(R5,交叉引用冻结 id)。
20
+
21
+ 4. **ADR 决策记录(AR5)**:把 tech-selection 的关键决策沉淀为 ADR——背景 / 决策 / 后果 / 备选(为什么不用备选)。引用 tech-selection 的 decisions 实体 id,不另起名。
22
+
23
+ 5. **架构一致性自检(AR3)**:对照目标(可扩展/可维护/性能),检查架构是否满足,给出自检结论。
24
+
25
+ 6. **功能场景(F2)特殊**:architecture = 功能架构(不是项目架构)——只画本次功能涉及的模块/组件边界/与现有系统的集成点,不重画整个项目架构。
26
+
27
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目禁令不得被通用规则覆盖。
@@ -0,0 +1,26 @@
1
+ # 章节填充:benchmark(Benchmark 数据)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown(含测量数据表)
5
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
6
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
7
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
8
+
9
+ ## Benchmark 章节硬规则(F5 预研/选型 · 数据说话的严谨性)
10
+
11
+ 1. **同条件同设备(铁律)**:所有候选必须在**同一台设备/同一环境/同一数据规模**下测量,并写明条件(硬件型号 / OS / 版本 / 数据集 / 压测工具 / 次数)。**禁止**拿别人文档里的数字和自己实测比,也禁止不同环境互相硬比。
12
+
13
+ 2. **必须给原始测量值**:每个指标给**原始数据**(如 `P95 延迟 = 23ms`、`冷启动 = 1.8s`、`bundle gzip = 186KB`、`QPS = 1200`),再谈相对提升。**禁止**只写「提升 50%」「性能大幅提升」这类无原始数据的结论(反AI决策 #2 数字门禁)。
14
+
15
+ 3. **双维度覆盖(全栈)**:按预研对象取舍——
16
+ - **前端维度**:渲染速度(首屏/交互)、内存占用、bundle 体积(raw/gzip)、加载时间、Lighthouse。
17
+ - **后端维度**:吞吐(QPS/RPS)、延迟(P50/P95/P99)、内存/CPU 占用、连接数、DB 查询耗时。
18
+ - 只评估前端的预研可以只测前端维度,但**要说清为什么后端维度不适用**(如「纯前端库,无服务端运行时」)。
19
+
20
+ 4. **DX 对比也量化**:HMR 速度、调试工具链(DevTools 集成/断点)、类型体验(TS 支持等级)、文档质量、迁移成本。DX 可以主观,但要有「为什么」;能数字化的给数字。
21
+
22
+ 5. **注明数据可信度**:每个结论标注「可复现(附复现步骤)/ 单次测量(未复现)/ 样本数 N」。数据可信度决定选型结论的权重——不可复现的数据不能支撑硬结论。
23
+
24
+ 6. **结论承接选型**:benchmark 结论(哪个候选在哪些维度占优)要能被 tech-selection 评估矩阵引用,作为「得分」的事实依据。
25
+
26
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目红线(如「性能目标是 LCP<2.5s」)优先于通用规则。
@@ -0,0 +1,9 @@
1
+ # 章节填充:closed-loop
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
@@ -0,0 +1,31 @@
1
+ # 章节填充:compat-migration(兼容性与迁移 · 新旧 API 对照)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
10
+
11
+ ## 兼容迁移章节硬规则(G3/G4 + F4 迁移扩展)
12
+
13
+ 1. **接口/数据兼容结论(CM1)**:本次变更是否破坏兼容——接口签名、数据结构、字段增减、行为变化。给明确结论(兼容/不兼容 + 影响面)。
14
+
15
+ 2. **存量填充策略(CM2 · G3)**:新数据/新字段对存量数据的填充策略(回填默认值/延迟填充/首次访问计算),写明触发时机与可回滚性。
16
+
17
+ 3. **回滚数据兼容(CM3 · G4)**:回滚后旧版本能否安全跳过/忽略新数据,必须写明。禁止「回滚就完事」。
18
+
19
+ 4. **新旧 API 变化对照(CM4)**:有 Breaking Change 时逐项对照:
20
+ ```
21
+ | 旧 API/字段 | 新 API/字段 | 变更类型(重命名/删除/改类型/新增必填) | 迁移动作 |
22
+ ```
23
+ 禁止只写「不兼容」。
24
+
25
+ 5. **浏览器/依赖兼容(CM5)**:目标版本 + 降级手段(README §1.4),禁「支持最新浏览器」空话。
26
+
27
+ 6. **渐进式迁移(CM6)**:分阶段迁移计划、新旧代码共存(双构建/双运行/特性开关)、每阶段结束可运行。
28
+
29
+ 7. **零变更**:显式「无新旧互读问题」。
30
+
31
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目禁令不得被通用规则覆盖。
@@ -0,0 +1,30 @@
1
+ # 章节填充:component-design(组件设计)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown(含组件树)
5
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
6
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
7
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
8
+
9
+ ## 组件设计章节硬规则(frontend-dev-guide 组件方法论 + README §1.1/§1.2)
10
+
11
+ 1. **组件树必须标注流向(禁只列组件名)**:
12
+ ```
13
+ 页面 PageX
14
+ └─ 容器 ContainerX(数据获取 + 状态)──Props 向下──
15
+ └─ 展示组件 PresenterX(只渲染)──Events 向上──
16
+ └─ 基础组件 BaseX(default/loading/empty/error 四态)
17
+ ```
18
+ 每条连线标注「props 流向」或「event 名 + 参数」。
19
+
20
+ 2. **单一职责 + 组合优先**:一个组件只做一件事;优先组合而非继承。给出每个组件的「职责一句话」和「不做什么」。
21
+
22
+ 3. **四态必须逐组件覆盖(README §1.2 结构模板)**:default / loading / empty / error(含重试),禁止只写成功态。每态给出 UI 表现(骨架屏/空文案+引导/错误重试)。
23
+
24
+ 4. **容器/展示分离**:容器组件负责数据获取与状态管理,展示组件只负责渲染。必须写明每个组件属于哪一类,数据从哪来。
25
+
26
+ 5. **复用与拆分边界(反AI决策 #1)**:至少给 1 条「本迭代不拆/不复用」的边界(如「两个页面暂共享此组件,但差异超过 30% 时拆开」)。禁止为抽象而抽象。
27
+
28
+ 6. **禁臆造组件树(README §1.1)**:组件树必须能追溯到页面/路由清单与设计输入;不存在于输入或推断来源的页面树禁止臆造。
29
+
30
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目禁令不得被通用规则覆盖。
@@ -0,0 +1,9 @@
1
+ # 章节填充:config-runtime
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
@@ -0,0 +1,62 @@
1
+ # 章节填充:core-flow(主业务流程时序)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown(含 Mermaid 时序图)
5
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
6
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
7
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
8
+
9
+ ## 时序图硬规则(README §1.7 架构图规范 + seqdiagram 精神)
10
+
11
+ 1. **必须有图**:主链路时序图用 Mermaid `sequenceDiagram` 源码块(diagram as code,可进 git/diff)。禁止用文字描述代替图,也禁止贴图片。
12
+
13
+ 2. **必须有文字说明图(图 + 文成对)**:
14
+ - 图前写一段「本图说明」:这条链路在讲什么、参与者(lifeline)分别是谁。
15
+ - 图后逐条解释关键消息/分支:每条消息为什么这么走、谁负责什么、失败时怎么办。
16
+ - **禁止只有图没有文字**,也禁止只有文字没有图。
17
+
18
+ 3. **覆盖关键分支**(禁止只画 happy path):
19
+ - 成功路径:正常完成整条链路。
20
+ - 异常/失败路径:错误码 → 降级 → 重试 → 回滚(`alt`/`opt` 块)。
21
+ - 写操作链路:幂等(重复请求/重复提交如何保证只生效一次)+ 并发(并发写/乐观锁)。
22
+ - 异步/消息链路:回调/补偿/死信/超时(`par`/`Note` 标注)。
23
+ - 第三方交互:webhook/回调/超时降级/隔离(防雪崩)。
24
+
25
+ 4. **标注易错决策点**(seqdiagram-examples 精神):每条主链路至少标 1 处「第一次容易做错的决策」——如幂等键怎么生成、超时设多少、回调如何防重、降级策略是什么。用 `Note right of` 或紧随图的文字说明。
26
+
27
+ 5. **交叉引用一致(R5)**:时序图里用到的接口/表,引用上游冻结契约 id(如 `I1`/`T1`),不要另起新名;与 api-design/data-model 保持一致。
28
+
29
+ 6. **粒度**:一图一事——一条主链路一张图,不要把所有流程塞进一张巨型图;图多时按业务主链路拆开,每图配文字。
30
+
31
+ ## Mermaid sequenceDiagram 模板(可填空)
32
+
33
+ ```mermaid
34
+ sequenceDiagram
35
+ autonumber
36
+ participant U as 用户
37
+ participant FE as 前端
38
+ participant BE as 后端
39
+ participant DB as 数据库
40
+ participant TP as 第三方
41
+ participant WK as 异步任务
42
+ U->>FE: 触发主操作({页面/按钮})
43
+ FE->>BE: {API 调用 + 参数}
44
+ BE->>BE: 校验/幂等键({幂等方案})
45
+ BE->>DB: {读写 + 事务/锁}
46
+ alt 成功
47
+ BE-->>FE: 200 + {返回结构}
48
+ FE-->>U: 成功态({UI 表现})
49
+ else 失败
50
+ BE-->>FE: {错误码 + 降级}
51
+ FE-->>U: 错误态({重试/回退})
52
+ end
53
+ opt 异步
54
+ BE->>WK: 投递任务({队列/补偿})
55
+ end
56
+ opt 第三方
57
+ BE->>TP: {调用 + 超时/重试}
58
+ TP-->>BE: {回调/webhook}
59
+ end
60
+ ```
61
+
62
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目禁令(如「禁止引入消息队列」)不得被通用规则覆盖。
@@ -0,0 +1,9 @@
1
+ # 章节填充:core-logic
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
@@ -0,0 +1,18 @@
1
+ # 章节填充:data-model(数据结构/数据模型变更)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=entity|mixed 的要点 → 产出结构化契约实体(JSON 块 ```json {"interfaces": [...], "tables": [...], "decisions": [...]} ```)
5
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
6
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
7
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
8
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
9
+
10
+ ## 数据章节硬规则(借鉴 approval database-guidance)
11
+
12
+ 1. **先探测项目 DB 栈**:读项目规约 `conventions.database` + 现网 DDL/迁移文件,判断 MySQL/PostgreSQL/SQLite/Redis/ES 等。命中本地 guidance 则遵循,未命中 LLM fallback。
13
+ 2. **总则必须写明**:数据库迁移、新建表、增删列、新增索引、DDL 来源、项目约定(路径或「未发现」)。
14
+ 3. **每张表必须**:完整 CREATE TABLE(含 ENGINE/CHARSET/索引)+ 字段说明(类型/本迭代用法)。
15
+ 4. **G3 存量填充**:JSON 形状变更或新增列时必须写存量默认值填充策略(回填 SQL/读时默认值/禁止空读/上线顺序)。
16
+ 5. **G4 回滚兼容**:回滚后旧版本能否安全跳过/忽略新数据?写明机制(omitempty/忽略未知键/version 分派)。禁止只写「回滚应用」。
17
+ 6. **零 DDL 迭代**:仍须展示现网 DDL,禁止假装「不涉及数据库」。
18
+ 7. **优先级**:项目约定 > SpecFlow guidance > LLM。项目禁令(如「本迭代禁止迁移」)不得被通用规则覆盖。
@@ -0,0 +1,26 @@
1
+ # 章节填充:deploy(部署交付方案 · 12-Factor)
2
+
3
+ 你是方案文档撰写员。按大纲要点"填空题"式展开本章,逐要点填充,不自由发挥。
4
+ - kind=narrative|mixed 的要点 → 产出叙述 Markdown
5
+ - 遵循 prompts/shared/artifact-language.md 的中文叙述规范(简要;怎么做用 1. 2. 3.)
6
+ - 禁止 stub(TODO/待补充/此处省略);禁止含糊词
7
+ - **事实从工程数据源提取,意图向用户询问,推理由你完成**(见 `prompts/document/shared/grounding.md`):本章涉及的接口字段/表列/组件名/依赖版本必须来自工程,缺失的关键信息列入缺口清单一次性询问用户,禁止编造
8
+ - 涉及项目规约/DB/API/前端约束时,遵循「项目约定 > SpecFlow guidance > LLM」优先级
9
+
10
+ ## 部署交付章节硬规则(F1 §2.6.2 + Twelve-Factor App)
11
+
12
+ 1. **环境拆分(DP1)**:dev/staging/prod 各自用途、谁访问、数据隔离。禁止「部署到服务器」这种空话。
13
+
14
+ 2. **CI/CD 流水线(DP2)**:代码检查 → 测试 → 构建 → 部署 各环节的工具与触发方式。**构建产物与运行分离(不可变制品)**:一次构建的镜像/产物用于所有环境,禁止「环境不同产物不同」。
15
+
16
+ 3. **部署拓扑(DP3)**:后端(容器/K8s/Serverless/虚拟机)+ 前端(静态托管/CDN/**SPA 路由回退**——history 模式必须配 fallback 到 index.html,否则刷新 404)。写明部署方式与理由。
17
+
18
+ 4. **发布策略(DP4)**:蓝绿 / 金丝雀 / 滚动 选择并给理由(按风险与回滚速度取舍)。
19
+
20
+ 5. **回滚(DP5)**:触发条件(什么指标/谁决策)、方式(切流量/重部署旧版本)、**数据一致性结论(G4 语义)**——回滚后新数据如何处理、旧版本能否安全读取,必须写明。禁止「出问题就回滚」一句话。
21
+
22
+ 6. **配置管理(DP6 · 12-Factor)**:配置来自环境变量;密钥(DB 密码/API key)不进代码仓库、不进制品;写明密钥管理方式(Secrets Manager/.env 注入)与生效时机(重启/热更新)。
23
+
24
+ 7. **纯库/CLI 项目**:可写「不涉及运行时部署」,并说明交付形态(npm 包/二进制/构建产物)。
25
+
26
+ > 优先级:项目约定 > SpecFlow guidance > LLM。项目禁令不得被通用规则覆盖。