@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
 
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -140,13 +141,46 @@ If `paths` section is absent, use these defaults:
140
141
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
142
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
144
+ - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -217,6 +251,26 @@ If the file does not exist → skip silently.
217
251
 
218
252
  ---
219
253
 
254
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
255
+
256
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
257
+
258
+ ```
259
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
260
+ ```
261
+
262
+ | `platform_type` | Modules |
263
+ |---|---|
264
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
265
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
266
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
267
+
268
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
269
+
270
+ 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).
271
+
272
+ ---
273
+
220
274
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
275
 
222
276
  After loading all context, synthesize and output a compact summary block.
@@ -227,10 +281,12 @@ Output exactly this block:
227
281
  ```
228
282
  [CTX LOADED]
229
283
  Stack : {language} / {framework} / {database}
284
+ Platform : {active_module} ({platform_type})
230
285
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
286
  Ticket : {ticket_prefix}-
232
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
233
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
234
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
235
291
  ```
236
292
 
@@ -252,27 +308,88 @@ After completing all steps, you have loaded:
252
308
  Proceed to the next step of the calling command.
253
309
 
254
310
 
311
+ ---
312
+
313
+ ## Scope Lock
314
+
315
+ This command is strictly scoped to the **single feature file** passed as `$ARGUMENTS`:
316
+
317
+ - Feature file: `{exact path from $ARGUMENTS}`
318
+ - UC: `{UC-ID}` (read from `@trace.id` in that file's header)
319
+
320
+ **Do NOT read or implement scenarios from any other `.feature` file** in the same domain folder, even if they share the same entity, domain concept, or service name.
321
+
322
+ ---
323
+
324
+ ## Context Load (additional)
325
+
326
+ Read:
327
+ 1. The scoped `.feature` file only
328
+ 2. Tech-doc at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` (if exists)
329
+ 3. CLAUDE.md §architecture + §coding_standards
330
+
331
+ ---
332
+
333
+ ## Read Trace State
334
+
335
+ Read `{paths.trace_dir}/{UC-ID}.tsv` if it exists. For each scenario row, note its current `status`:
336
+
337
+ | Status | Meaning | Action in this run |
338
+ |--------|---------|-------------------|
339
+ | `UNTRACKED` | `implemented_by == —` | Generate — scenario has no code yet |
340
+ | `DRIFT` | `spec_ver != gen_ver` | Regenerate — scenario updated since last codegen |
341
+ | `OK` | implemented + tested | Skip unless explicitly re-generating |
342
+ | `GAP` | implemented, no tests | Skip codegen — already coded; run `/generate-tests` instead |
343
+
344
+ Use these statuses to populate the **Scenarios** count in the CHECKPOINT plan (`{X} new, {Y} drifted, {Z} synced-skip`).
345
+ If `.tsv` does not exist → treat all scenarios as `UNTRACKED`.
346
+
347
+ ---
348
+
349
+ ## File Scan
350
+
351
+ Before generating, determine which files will be needed for this UC's scenarios. Check whether each file already exists on disk.
352
+
353
+ Classify each file:
354
+
355
+ | Status | Meaning | Action |
356
+ |--------|---------|--------|
357
+ | `CREATE` | File does not exist | Generate full new file |
358
+ | `EXTEND` | File exists, new methods needed | Add new methods only — do NOT rewrite existing code |
359
+ | `SKIP` | File exists and already covers all UC scenarios | Leave untouched |
360
+
361
+ > **EXTEND rule:** Read the existing file fully. Locate the correct class/interface. Add only the methods required by `{UC-ID}` scenarios. Preserve all existing methods, fields, and annotations exactly as-is. Attach `@trace.implements={UC-ID}-SC{N}` on each new method.
362
+
255
363
  ---
256
364
 
257
365
  ## CHECKPOINT — Code Generation Plan
258
366
 
259
367
  Before generating any code, show:
368
+
260
369
  ```
261
- I understand:
262
- - Feature: {name} | Ticket: {ID if known}
263
- - UC: {UC-ID} | Domain: {domain}
264
- - Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
265
- - Layer order: {from CLAUDE.md §2 architecture}
266
- - Tech stack: {language} / {framework}
267
- - Files to create: [list]
370
+ Code Generation Plan — {UC-ID}
371
+ ──────────────────────────────────────────────────────
372
+ Feature : {name}
373
+ Ticket : {TICKET_ID if known}
374
+ Domain : {domain}
375
+ UC : {UC-ID} only ← other feature files in this folder are NOT read
376
+ Tech : {language} / {framework}
377
+ Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
378
+ Layer : {from CLAUDE.md §2}
379
+
380
+ Files:
381
+ CREATE {N} new files
382
+ + {path/FileName.ext}
383
+ EXTEND {M} existing files (add methods only)
384
+ ~ {path/FileName.ext} — adding: {methodA}, {methodB}
385
+ SKIP {K} files (no change needed)
386
+ = {path/FileName.ext}
387
+ ──────────────────────────────────────────────────────
268
388
  Proceed? (Y/N)
269
389
  ```
270
390
 
271
391
  Wait for explicit "Y" before generating.
272
392
 
273
- ## Context Load (additional)
274
- Read: `.feature` file, tech-doc (if exists at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`), CLAUDE.md §architecture + §coding_standards, existing entity files.
275
-
276
393
  ## Branch
277
394
  ```bash
278
395
  git checkout -b feature/{TICKET_ID}-{slug}
@@ -283,13 +400,17 @@ git checkout -b feature/{TICKET_ID}-{slug}
283
400
  Default order (override from CLAUDE.md if different):
284
401
  DTOs → Entity/Model → Repository → Service interface → Service impl → Facade (if applicable) → Controller
285
402
 
286
- **Controller must have traceability tags (adapt to your language's comment syntax):**
403
+ **For `CREATE` files:** generate the full file.
404
+
405
+ **For `EXTEND` files:** open the existing file → add only the new methods for `{UC-ID}` → do not touch anything else.
406
+
407
+ **Traceability tags on controller/handler (adapt to your language's comment syntax):**
287
408
  ```
288
409
  @trace.implements={UC-ID}-SC{N}
289
410
  @trace.prd_version={read @trace.prd_version from the .feature file header}
290
411
  @trace.bdd_version={read @trace.bdd_version from the .feature file header}
291
412
  @trace.tech_doc_revision={read @trace.revision from tech-doc header, or omit if no tech-doc}
292
- @trace.source={paths.specs_dir}/{domain}/{UC-ID}.feature
413
+ @trace.source={paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
293
414
  ```
294
415
 
295
416
  `@trace.prd_version` records which PRD version this code was written against.
@@ -297,6 +418,8 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
297
418
  `@trace.tech_doc_revision` records which tech-design revision this code follows.
298
419
  `/validate-traces` will flag drift if any upstream artifact is updated to a newer version.
299
420
 
421
+ > **Entry-point rule:** `@trace.implements` must appear on the **entry-point layer** as defined in `CLAUDE.md §2`. For REST APIs → Controller. For event-driven modules → event handler / consumer class. For context-engineering → the prompt orchestration function. Never put it only on an inner layer.
422
+
300
423
  ## Self-Review (3 rounds)
301
424
  - [ ] Every scenario has a corresponding endpoint
302
425
  - [ ] @trace.implements on every endpoint
@@ -360,21 +483,23 @@ Suggest the logical next command based on workflow phase:
360
483
 
361
484
  | Current command | Suggest next |
362
485
  |-------------------------|-----------------------------------------------|
486
+ | /setup-ai-first | `/define-product` to start your first feature |
363
487
  | /define-product | `/generate-prd {product-definition-file}` |
364
488
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
365
489
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
366
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
490
+ | /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 |
491
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
367
492
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
368
493
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
369
494
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
370
495
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
371
- | /generate-code | `/generate-tests {UC-ID}` |
496
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
372
497
  | /generate-tests | `/run-tests {UC-ID}` |
373
498
  | /run-tests (passing) | `/review-code {UC-ID}` |
374
499
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
375
500
  | /review-code | `/smoke-test {UC-ID}` or create PR |
376
501
  | /smoke-test | Create PR and link to ticket |
377
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
502
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
378
503
  | /fix-bug | Create PR and link to ticket |
379
504
  | /debug | `/fix-bug {ticket-id}` if fix needed |
380
505
 
@@ -389,7 +514,9 @@ Next : {suggested command with example arguments}
389
514
 
390
515
  ```
391
516
  /generate-code Complete — {UC-ID}
392
- Files: created={N}, updated={M} | Build: SUCCESS
517
+ Files: created={N}, extended={M}, skipped={K} | Build: SUCCESS
393
518
  Branch: feature/{TICKET_ID}-{slug}
394
- Next: /review-code OR /generate-tests {UC-ID}
519
+ Next:
520
+ First generation for this UC → /review-code {UC-ID} ← code review required before tests
521
+ Re-generation (already reviewed) → /generate-tests {UC-ID}
395
522
  ```