@anhth2/spec-driven-dev-plugin 0.6.0 → 0.8.0

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 (86) hide show
  1. package/bin/index.js +285 -11
  2. package/commands/debug.md +233 -11
  3. package/commands/debug.tmpl +170 -6
  4. package/commands/define-product.md +68 -6
  5. package/commands/define-product.tmpl +5 -1
  6. package/commands/fix-bug.md +111 -11
  7. package/commands/fix-bug.tmpl +48 -6
  8. package/commands/generate-bdd.md +86 -9
  9. package/commands/generate-bdd.tmpl +23 -4
  10. package/commands/generate-code.md +146 -19
  11. package/commands/generate-code.tmpl +83 -14
  12. package/commands/generate-design-spec.md +754 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +91 -7
  15. package/commands/generate-prd.tmpl +28 -2
  16. package/commands/generate-spec-manifest.md +519 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +122 -9
  19. package/commands/generate-tech-docs.tmpl +59 -4
  20. package/commands/generate-tests.md +491 -37
  21. package/commands/generate-tests.tmpl +428 -32
  22. package/commands/refine-prd.md +76 -8
  23. package/commands/refine-prd.tmpl +13 -3
  24. package/commands/review-code.md +94 -6
  25. package/commands/review-code.tmpl +31 -1
  26. package/commands/review-context.md +118 -12
  27. package/commands/review-context.tmpl +55 -7
  28. package/commands/review-tech-docs.md +76 -9
  29. package/commands/review-tech-docs.tmpl +13 -4
  30. package/commands/run-tests.md +196 -18
  31. package/commands/run-tests.tmpl +133 -13
  32. package/commands/setup-ai-first.md +192 -6
  33. package/commands/setup-ai-first.tmpl +136 -5
  34. package/commands/smoke-test.md +228 -22
  35. package/commands/smoke-test.tmpl +165 -17
  36. package/commands/validate-traces.md +77 -8
  37. package/commands/validate-traces.tmpl +14 -3
  38. package/core/FRAMEWORK_VERSION +1 -1
  39. package/core/commands/debug.md +233 -11
  40. package/core/commands/define-product.md +68 -6
  41. package/core/commands/fix-bug.md +111 -11
  42. package/core/commands/generate-bdd.md +86 -9
  43. package/core/commands/generate-code.md +146 -19
  44. package/core/commands/generate-design-spec.md +754 -0
  45. package/core/commands/generate-prd.md +91 -7
  46. package/core/commands/generate-spec-manifest.md +519 -0
  47. package/core/commands/generate-tech-docs.md +122 -9
  48. package/core/commands/generate-tests.md +491 -37
  49. package/core/commands/refine-prd.md +76 -8
  50. package/core/commands/review-code.md +94 -6
  51. package/core/commands/review-context.md +118 -12
  52. package/core/commands/review-tech-docs.md +76 -9
  53. package/core/commands/run-tests.md +196 -18
  54. package/core/commands/setup-ai-first.md +192 -6
  55. package/core/commands/smoke-test.md +228 -22
  56. package/core/commands/validate-traces.md +77 -8
  57. package/core/skills/code/SKILL.md +68 -8
  58. package/core/skills/debug/SKILL.md +72 -10
  59. package/core/skills/design-spec/SKILL.md +450 -0
  60. package/core/skills/discovery/SKILL.md +62 -4
  61. package/core/skills/prd/SKILL.md +12 -8
  62. package/core/skills/setup-ai-first/SKILL.md +5 -3
  63. package/core/skills/spec/SKILL.md +11 -7
  64. package/core/skills/test/SKILL.md +130 -12
  65. package/core/steps/context-loader.md +57 -1
  66. package/core/steps/gate.md +1 -1
  67. package/core/steps/report-footer.md +5 -3
  68. package/core/steps/spawn-agent.md +3 -1
  69. package/core/templates/design-spec.template.md +209 -0
  70. package/core/templates/project-context.yaml +29 -0
  71. package/package.json +1 -1
  72. package/skills/code/SKILL.md +68 -8
  73. package/skills/debug/SKILL.md +72 -10
  74. package/skills/design-spec/SKILL.md +450 -0
  75. package/skills/design-spec/SKILL.tmpl +95 -0
  76. package/skills/discovery/SKILL.md +62 -4
  77. package/skills/prd/SKILL.md +12 -8
  78. package/skills/setup-ai-first/SKILL.md +5 -3
  79. package/skills/spec/SKILL.md +11 -7
  80. package/skills/test/SKILL.md +130 -12
  81. package/steps/context-loader.md +57 -1
  82. package/steps/gate.md +1 -1
  83. package/steps/report-footer.md +5 -3
  84. package/steps/spawn-agent.md +3 -1
  85. package/templates/design-spec.template.md +209 -0
  86. package/templates/project-context.yaml +29 -0
@@ -31,7 +31,7 @@ Display and wait for response:
31
31
  ```
32
32
  ⚙️ MODEL CHECK
33
33
  ──────────────────────────────────────────────────────────────────
34
- Recommended : claude-opus-4-5 (or claude-opus-4)
34
+ Recommended : claude-opus-4 (or latest Opus model)
35
35
  Why needed : Spec analysis, architecture review, code generation
36
36
  require deep reasoning. Smaller models miss edge cases.
37
37
 
@@ -84,7 +84,28 @@ Wait for explicit "Y" or "N" from the user before continuing.
84
84
  - "N" → stop and ask what the user wants to change.
85
85
 
86
86
 
87
- *Note: For this command, the target in Step 1 is a `.feature` file or UC-ID under `{paths.specs_dir}/`. If quality < 80% (missing BDD rules compliance), halt with feedback.*
87
+ *Note: For this command, the target in Step 1 is a `.feature` file or UC-ID under `{paths.specs_dir}/`.*
88
+
89
+ **Quality Gate**: Before generating, check the BDD findings file:
90
+
91
+ 1. Look for `{paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml`.
92
+ 2. **If file does not exist** → warn and ask:
93
+ ```
94
+ ⚠️ /review-context has not been run for this feature file.
95
+ Recommended: run /review-context {feature-file} first to verify BDD quality.
96
+ Continue without review? (Y/N)
97
+ ```
98
+ - Y → proceed (accept risk)
99
+ - N → stop; run `/review-context {feature-file}` first
100
+ 3. **If file exists** → check for unresolved `status: "pending"` critical findings.
101
+ If any found → **HALT** and print:
102
+ ```
103
+ ❌ Quality Gate Failed — {feature-file}
104
+ Unresolved critical BDD findings detected.
105
+ Run: /review-context --fix {feature-file} ← auto-fix what's possible
106
+ Then: /review-context --resume {feature-file} ← apply remaining accepted findings
107
+ Then re-run: /generate-tech-docs {feature-file}
108
+ ```
88
109
 
89
110
  ## Context
90
111
  # Context Loader — Load All Project Context
@@ -131,6 +152,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
152
  - `paths.core_entities` → path to core-entities.md
132
153
  - `paths.tech_docs_dir` → technical documentation root
133
154
  - `paths.trace_dir` → trace state directory
155
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
156
 
135
157
  If `paths` section is absent, use these defaults:
136
158
  - `specs_dir` = `specs/bdd`
@@ -140,13 +162,46 @@ If `paths` section is absent, use these defaults:
140
162
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
163
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
164
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
165
+ - `tech_docs_dir` = `specs/tech-docs`
144
166
  - `trace_dir` = `.trace`
167
+ - `design_spec_dir` = `specs/design-spec`
145
168
 
146
169
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
170
 
148
171
  ---
149
172
 
173
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
174
+
175
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
176
+
177
+ If `services` section is present:
178
+
179
+ **1. Detect active domain** (in priority order):
180
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
181
+ - Extract from target file path: segment immediately after `prd_dir` base path
182
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
183
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
184
+
185
+ **2. Route to service** — if active domain matches a key in `services`:
186
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
187
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
188
+ - Store `active_service` = `services.{domain}.path`
189
+ - Store `active_service_module` = `services.{domain}.module`
190
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
191
+
192
+ **3. Fallback** — if domain not detected or no matching service key:
193
+ - Keep default paths from Step 1
194
+ - Set `active_service = unresolved`
195
+
196
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
197
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
198
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
199
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
200
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
201
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
202
+
203
+ ---
204
+
150
205
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
206
 
152
207
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -217,6 +272,26 @@ If the file does not exist → skip silently.
217
272
 
218
273
  ---
219
274
 
275
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
276
+
277
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
278
+
279
+ ```
280
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
281
+ ```
282
+
283
+ | `platform_type` | Modules |
284
+ |---|---|
285
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
286
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
287
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
288
+
289
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
290
+
291
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (generate-tests, debug, fix-bug, smoke-test).
292
+
293
+ ---
294
+
220
295
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
296
 
222
297
  After loading all context, synthesize and output a compact summary block.
@@ -227,10 +302,12 @@ Output exactly this block:
227
302
  ```
228
303
  [CTX LOADED]
229
304
  Stack : {language} / {framework} / {database}
305
+ Platform : {active_module} ({platform_type})
230
306
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
307
  Ticket : {ticket_prefix}-
232
308
  Dict : {loaded — N canonical terms, M banned terms | missing}
233
309
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
310
+ Service : {active_service} ({active_service_module}) | single-service
234
311
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
235
312
  ```
236
313
 
@@ -252,6 +329,38 @@ After completing all steps, you have loaded:
252
329
  Proceed to the next step of the calling command.
253
330
 
254
331
 
332
+ ---
333
+
334
+ ## CHECKPOINT — Tech Design Plan
335
+
336
+ Before generating, scan the feature file for scenario count, referenced BRs, and entities. Display and wait for Y:
337
+
338
+ ```
339
+ Tech Design Plan — {UC-ID}
340
+ ──────────────────────────────────────────────────────
341
+ UC : {UC-ID} — {feature title}
342
+ Service : {trace.service}
343
+ Module : {trace.module}
344
+ Scenarios: {N} scenarios
345
+ BDD ver : {trace.bdd_version}
346
+ Output : {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
347
+
348
+ Sections to generate:
349
+ §1 Overview
350
+ §2 API Endpoints ({N} endpoints inferred from scenarios)
351
+ §3 Data Model ({entities from core-entities.md relevant to this UC})
352
+ §4 Service Flow
353
+ §5 Business Rules ({N} BRs from feature header)
354
+ §6 Error Handling
355
+ §7 Database Changes
356
+ §8 Caching Strategy
357
+ §9 Cross-Service Dependencies
358
+ ──────────────────────────────────────────────────────
359
+ Proceed? (Y/N)
360
+ ```
361
+
362
+ Wait for explicit "Y" before generating.
363
+
255
364
  ---
256
365
 
257
366
  ## Generate
@@ -264,6 +373,8 @@ Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
264
373
  ---
265
374
  @trace.id: {UC-ID}
266
375
  @trace.domain: {domain}
376
+ @trace.service: {read @trace.service from the .feature file header}
377
+ @trace.module: {read @trace.module from the .feature file header}
267
378
  @trace.prd: {TICKET-ID}
268
379
  @trace.bdd_version: {read @trace.bdd_version from the .feature file header}
269
380
  @trace.revision: 1
@@ -296,8 +407,6 @@ Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
296
407
  | 1 | {YYYY-MM-DD} | Initial generation from {UC-ID}.feature (BDD v{bdd_version}) |
297
408
  ```
298
409
 
299
- SA/Lead should review and approve before running `/generate-code`.
300
-
301
410
  ## Output
302
411
 
303
412
  # Report Footer — Standard Command Output Format
@@ -328,21 +437,23 @@ Suggest the logical next command based on workflow phase:
328
437
 
329
438
  | Current command | Suggest next |
330
439
  |-------------------------|-----------------------------------------------|
440
+ | /setup-ai-first | `/define-product` to start your first feature |
331
441
  | /define-product | `/generate-prd {product-definition-file}` |
332
442
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
333
443
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
334
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
444
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
445
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
335
446
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
336
447
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
337
448
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
338
449
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
339
- | /generate-code | `/generate-tests {UC-ID}` |
450
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
340
451
  | /generate-tests | `/run-tests {UC-ID}` |
341
452
  | /run-tests (passing) | `/review-code {UC-ID}` |
342
453
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
343
454
  | /review-code | `/smoke-test {UC-ID}` or create PR |
344
455
  | /smoke-test | Create PR and link to ticket |
345
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
456
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
346
457
  | /fix-bug | Create PR and link to ticket |
347
458
  | /debug | `/fix-bug {ticket-id}` if fix needed |
348
459
 
@@ -358,5 +469,7 @@ Next : {suggested command with example arguments}
358
469
  ```
359
470
  /generate-tech-docs Complete — {UC-ID}
360
471
  File: {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
361
- Next: /generate-code {UC-ID}
472
+ Next: /review-tech-docs {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
473
+ ← SA/Lead review required before code generation
474
+ → after approved: /generate-code {paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
362
475
  ```
@@ -3,13 +3,66 @@
3
3
  ## Gate
4
4
  {{include:steps/gate.md}}
5
5
 
6
- *Note: For this command, the target in Step 1 is a `.feature` file or UC-ID under `{paths.specs_dir}/`. If quality < 80% (missing BDD rules compliance), halt with feedback.*
6
+ *Note: For this command, the target in Step 1 is a `.feature` file or UC-ID under `{paths.specs_dir}/`.*
7
+
8
+ **Quality Gate**: Before generating, check the BDD findings file:
9
+
10
+ 1. Look for `{paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml`.
11
+ 2. **If file does not exist** → warn and ask:
12
+ ```
13
+ ⚠️ /review-context has not been run for this feature file.
14
+ Recommended: run /review-context {feature-file} first to verify BDD quality.
15
+ Continue without review? (Y/N)
16
+ ```
17
+ - Y → proceed (accept risk)
18
+ - N → stop; run `/review-context {feature-file}` first
19
+ 3. **If file exists** → check for unresolved `status: "pending"` critical findings.
20
+ If any found → **HALT** and print:
21
+ ```
22
+ ❌ Quality Gate Failed — {feature-file}
23
+ Unresolved critical BDD findings detected.
24
+ Run: /review-context --fix {feature-file} ← auto-fix what's possible
25
+ Then: /review-context --resume {feature-file} ← apply remaining accepted findings
26
+ Then re-run: /generate-tech-docs {feature-file}
27
+ ```
7
28
 
8
29
  ## Context
9
30
  {{include:steps/context-loader.md}}
10
31
 
11
32
  ---
12
33
 
34
+ ## CHECKPOINT — Tech Design Plan
35
+
36
+ Before generating, scan the feature file for scenario count, referenced BRs, and entities. Display and wait for Y:
37
+
38
+ ```
39
+ Tech Design Plan — {UC-ID}
40
+ ──────────────────────────────────────────────────────
41
+ UC : {UC-ID} — {feature title}
42
+ Service : {trace.service}
43
+ Module : {trace.module}
44
+ Scenarios: {N} scenarios
45
+ BDD ver : {trace.bdd_version}
46
+ Output : {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
47
+
48
+ Sections to generate:
49
+ §1 Overview
50
+ §2 API Endpoints ({N} endpoints inferred from scenarios)
51
+ §3 Data Model ({entities from core-entities.md relevant to this UC})
52
+ §4 Service Flow
53
+ §5 Business Rules ({N} BRs from feature header)
54
+ §6 Error Handling
55
+ §7 Database Changes
56
+ §8 Caching Strategy
57
+ §9 Cross-Service Dependencies
58
+ ──────────────────────────────────────────────────────
59
+ Proceed? (Y/N)
60
+ ```
61
+
62
+ Wait for explicit "Y" before generating.
63
+
64
+ ---
65
+
13
66
  ## Generate
14
67
 
15
68
  Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
@@ -20,6 +73,8 @@ Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
20
73
  ---
21
74
  @trace.id: {UC-ID}
22
75
  @trace.domain: {domain}
76
+ @trace.service: {read @trace.service from the .feature file header}
77
+ @trace.module: {read @trace.module from the .feature file header}
23
78
  @trace.prd: {TICKET-ID}
24
79
  @trace.bdd_version: {read @trace.bdd_version from the .feature file header}
25
80
  @trace.revision: 1
@@ -52,8 +107,6 @@ Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
52
107
  | 1 | {YYYY-MM-DD} | Initial generation from {UC-ID}.feature (BDD v{bdd_version}) |
53
108
  ```
54
109
 
55
- SA/Lead should review and approve before running `/generate-code`.
56
-
57
110
  ## Output
58
111
 
59
112
  {{include:steps/report-footer.md}}
@@ -61,5 +114,7 @@ SA/Lead should review and approve before running `/generate-code`.
61
114
  ```
62
115
  /generate-tech-docs Complete — {UC-ID}
63
116
  File: {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
64
- Next: /generate-code {UC-ID}
117
+ Next: /review-tech-docs {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
118
+ ← SA/Lead review required before code generation
119
+ → after approved: /generate-code {paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
65
120
  ```