@anhth2/spec-driven-dev-plugin 0.9.1 → 0.10.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 (124) hide show
  1. package/ARCHITECTURE.md +20 -9
  2. package/bin/index.js +1 -2
  3. package/commands/debug.md +13 -12
  4. package/commands/define-product.md +12 -11
  5. package/commands/{generate-tests.md → dev-gen-test.md} +48 -15
  6. package/commands/{generate-tests.tmpl → dev-gen-test.tmpl} +18 -4
  7. package/{core/commands/run-tests.md → commands/dev-run-test.md} +62 -13
  8. package/commands/{run-tests.tmpl → dev-run-test.tmpl} +32 -2
  9. package/{core/commands/smoke-test.md → commands/dev-smoke-test.md} +17 -16
  10. package/commands/{smoke-test.tmpl → dev-smoke-test.tmpl} +5 -5
  11. package/commands/fix-bug.md +13 -12
  12. package/commands/generate-bdd.md +39 -13
  13. package/commands/generate-bdd.tmpl +9 -2
  14. package/commands/generate-code.md +86 -15
  15. package/commands/generate-code.tmpl +56 -4
  16. package/commands/generate-design-spec.md +105 -39
  17. package/commands/generate-design-spec.tmpl +93 -28
  18. package/commands/generate-prd.md +12 -11
  19. package/commands/generate-spec-manifest.md +12 -11
  20. package/commands/generate-tech-docs.md +63 -22
  21. package/commands/generate-tech-docs.tmpl +51 -11
  22. package/commands/learn.md +13 -12
  23. package/commands/propose-scenario.md +13 -12
  24. package/commands/propose-scenario.tmpl +1 -1
  25. package/commands/refine-prd.md +166 -16
  26. package/commands/refine-prd.tmpl +16 -5
  27. package/commands/report-bug.md +12 -11
  28. package/commands/review-code.md +14 -13
  29. package/commands/review-code.tmpl +1 -1
  30. package/commands/review-context.md +161 -12
  31. package/commands/review-context.tmpl +11 -1
  32. package/commands/review-tech-docs.md +13 -11
  33. package/commands/review-tech-docs.tmpl +1 -0
  34. package/commands/setup-ai-first.md +7 -7
  35. package/commands/sync.md +23 -20
  36. package/commands/sync.tmpl +16 -13
  37. package/commands/update-framework.md +7 -7
  38. package/commands/validate-traces.md +57 -37
  39. package/commands/validate-traces.tmpl +45 -26
  40. package/core/FRAMEWORK_VERSION +1 -1
  41. package/core/commands/debug.md +13 -12
  42. package/core/commands/define-product.md +12 -11
  43. package/core/commands/{generate-tests.md → dev-gen-test.md} +48 -15
  44. package/{commands/run-tests.md → core/commands/dev-run-test.md} +62 -13
  45. package/{commands/smoke-test.md → core/commands/dev-smoke-test.md} +17 -16
  46. package/core/commands/fix-bug.md +13 -12
  47. package/core/commands/generate-bdd.md +39 -13
  48. package/core/commands/generate-code.md +86 -15
  49. package/core/commands/generate-design-spec.md +105 -39
  50. package/core/commands/generate-prd.md +12 -11
  51. package/core/commands/generate-spec-manifest.md +12 -11
  52. package/core/commands/generate-tech-docs.md +63 -22
  53. package/core/commands/learn.md +13 -12
  54. package/core/commands/propose-scenario.md +13 -12
  55. package/core/commands/refine-prd.md +166 -16
  56. package/core/commands/report-bug.md +12 -11
  57. package/core/commands/review-code.md +14 -13
  58. package/core/commands/review-context.md +161 -12
  59. package/core/commands/review-tech-docs.md +13 -11
  60. package/core/commands/setup-ai-first.md +7 -7
  61. package/core/commands/sync.md +23 -20
  62. package/core/commands/update-framework.md +7 -7
  63. package/core/commands/validate-traces.md +57 -37
  64. package/core/modules/android-compose/module.yaml +13 -0
  65. package/core/modules/android-compose/stack-profile.yaml +57 -0
  66. package/core/modules/flutter/module.yaml +14 -0
  67. package/core/modules/flutter/stack-profile.yaml +59 -0
  68. package/core/modules/ios-swiftui/module.yaml +13 -0
  69. package/core/modules/ios-swiftui/stack-profile.yaml +55 -0
  70. package/core/modules/nuxt/module.yaml +14 -0
  71. package/core/modules/nuxt/stack-profile.yaml +58 -0
  72. package/core/modules/react-native/module.yaml +14 -0
  73. package/core/modules/react-native/stack-profile.yaml +56 -0
  74. package/core/modules/vue/module.yaml +14 -0
  75. package/core/modules/vue/stack-profile.yaml +65 -0
  76. package/core/skills/code/SKILL.md +19 -18
  77. package/core/skills/debug/SKILL.md +27 -26
  78. package/core/skills/design-spec/SKILL.md +12 -11
  79. package/core/skills/discovery/SKILL.md +12 -11
  80. package/core/skills/prd/SKILL.md +14 -14
  81. package/core/skills/setup-ai-first/SKILL.md +7 -7
  82. package/core/skills/spec/SKILL.md +14 -14
  83. package/core/skills/test/SKILL.md +40 -38
  84. package/core/steps/capture-lesson.md +1 -1
  85. package/core/steps/context-loader.md +5 -4
  86. package/core/steps/report-footer.md +7 -7
  87. package/core/steps/review-fanout.md +138 -0
  88. package/core/steps/spawn-agent.md +1 -1
  89. package/core/steps/trace-mirror.md +18 -0
  90. package/core/templates/design-spec.template.md +16 -8
  91. package/core/templates/product-definition.template.md +3 -3
  92. package/core/templates/project-context.yaml +4 -1
  93. package/modules/android-compose/module.yaml +13 -0
  94. package/modules/android-compose/stack-profile.yaml +57 -0
  95. package/modules/flutter/module.yaml +14 -0
  96. package/modules/flutter/stack-profile.yaml +59 -0
  97. package/modules/ios-swiftui/module.yaml +13 -0
  98. package/modules/ios-swiftui/stack-profile.yaml +55 -0
  99. package/modules/nuxt/module.yaml +14 -0
  100. package/modules/nuxt/stack-profile.yaml +58 -0
  101. package/modules/react-native/module.yaml +14 -0
  102. package/modules/react-native/stack-profile.yaml +56 -0
  103. package/modules/vue/module.yaml +14 -0
  104. package/modules/vue/stack-profile.yaml +65 -0
  105. package/package.json +1 -1
  106. package/skills/code/SKILL.md +19 -18
  107. package/skills/debug/SKILL.md +27 -26
  108. package/skills/debug/SKILL.tmpl +1 -1
  109. package/skills/design-spec/SKILL.md +12 -11
  110. package/skills/discovery/SKILL.md +12 -11
  111. package/skills/prd/SKILL.md +14 -14
  112. package/skills/setup-ai-first/SKILL.md +7 -7
  113. package/skills/spec/SKILL.md +14 -14
  114. package/skills/test/SKILL.md +40 -38
  115. package/skills/test/SKILL.tmpl +9 -9
  116. package/steps/capture-lesson.md +1 -1
  117. package/steps/context-loader.md +5 -4
  118. package/steps/report-footer.md +7 -7
  119. package/steps/review-fanout.md +138 -0
  120. package/steps/spawn-agent.md +1 -1
  121. package/steps/trace-mirror.md +18 -0
  122. package/templates/design-spec.template.md +16 -8
  123. package/templates/product-definition.template.md +3 -3
  124. package/templates/project-context.yaml +4 -1
@@ -170,7 +170,7 @@ If `services` section is present:
170
170
 
171
171
  **2. Route to service** — if active domain matches a key in `services`:
172
172
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
173
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
173
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
174
174
  - Store `active_service` = `services.{domain}.path`
175
175
  - Store `active_service_module` = `services.{domain}.module`
176
176
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -182,13 +182,14 @@ If `services` section is present:
182
182
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
183
183
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
184
184
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
185
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
185
186
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
186
187
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
187
188
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
188
189
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
189
190
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
190
191
 
191
- > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
192
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
192
193
 
193
194
  ---
194
195
 
@@ -212,7 +213,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
212
213
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
213
214
 
214
215
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
215
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
216
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
216
217
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
217
218
 
218
219
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -305,7 +306,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
305
306
 
306
307
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
307
308
 
308
- 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).
309
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
309
310
 
310
311
  ---
311
312
 
@@ -386,6 +387,154 @@ Derive the output findings filename:
386
387
 
387
388
  ---
388
389
 
390
+ ## Review Procedure
391
+ # Exhaustive Review Fan-Out + Completeness Convergence
392
+
393
+ **Why this exists:** A single-pass review never lists every issue at once — the model
394
+ stops at "enough" findings, so each later review round surfaces *new* problems
395
+ (whack-a-mole). This procedure forces the review to **converge in one command run**:
396
+ fan out across review dimensions in parallel, then loop a completeness critic until a
397
+ round produces nothing new, *before* writing the findings file.
398
+
399
+ The calling command supplies two things:
400
+ - **DIMENSIONS** — the list of review dimensions to fan out over
401
+ (`/refine-prd` → the 4 lenses; `/review-context` → the P-checks or B-checks).
402
+ - **FINDINGS SCHEMA** — the YAML shape each finding must follow (defined in the command).
403
+
404
+ > **Sub-agent mode bypass:** If Gate Step 0 set `_agent_mode: true`, this whole
405
+ > procedure is **skipped** — the orchestrator is already running one dimension/UC per
406
+ > sub-agent. Run the command's checks directly on the scoped section and return findings.
407
+
408
+ ---
409
+
410
+ ## Phase 1 — Parallel dimension scan
411
+
412
+ **How many sub-agents:** the agent *count* is not the completeness lever — breadth is
413
+ fixed by the DIMENSION taxonomy (adding agents to the same dimension just re-finds the
414
+ same issues), and *depth* is owned by the Phase 2 critic loop. Pick the **fan-out
415
+ granularity** by target size, reusing the `steps/spawn-agent.md` thresholds:
416
+
417
+ | Target size | Granularity | Agent count |
418
+ |-------------|-------------|-------------|
419
+ | ≤ 3 UCs **and** ≤ 300 lines | one agent per DIMENSION over the whole file | = number of dimensions |
420
+ | > 3 UCs **or** > 300 lines | one agent per **DIMENSION × UC-scope** (UCs + a PRD-global scope), batched to fit the agent cap | `dimensions × (UCs + 1)`, capped (see below) |
421
+
422
+ The larger granularity keeps each sub-agent's context small and its scan exhaustive on a
423
+ single UC — which is what prevents misses on big PRDs.
424
+
425
+ > **Global (non-UC) sections — required in `DIMENSION × UC` mode.** Per-UC agents only
426
+ > see one UC each, so PRD-wide sections that belong to no UC (scope, success metrics,
427
+ > problem statement, terminology, glossary, changelog) would go unscanned. Whenever you
428
+ > fan out per UC, also include a **"PRD-global"** scope (the non-UC sections, findings get
429
+ > `uc_id: ""`) alongside the UC list. So the natural agent count is `dimensions × (UCs + 1)`.
430
+ > (Not needed in the whole-file mode — there each agent already sees the global sections.)
431
+
432
+ ### Agent cap — batch UCs when the fan-out gets too wide
433
+
434
+ `dimensions × (UCs + 1)` can explode on large PRDs (e.g. 6 checks × (8 UCs + 1) = 54
435
+ agents). Cap the wave at **`AGENT_CAP = 12`** agents and batch UC scopes to fit:
436
+
437
+ 1. Build the scope list = `[UC1, UC2, …, UCn, PRD-global]` (length `UCs + 1`).
438
+ 2. Compute scopes-per-agent-bucket: `groups = max(1, floor(AGENT_CAP / dimensions))`.
439
+ - If `groups ≥ UCs + 1` → no batching needed, run one agent per `DIMENSION × scope`.
440
+ - Else split the scope list into `groups` contiguous buckets of roughly equal size
441
+ (keep `PRD-global` in its own bucket if it fits; otherwise append it to the last
442
+ bucket). Each agent then handles **one DIMENSION over one bucket of UCs**.
443
+ 3. Resulting wave size = `dimensions × groups ≤ AGENT_CAP`.
444
+
445
+ A batched agent reviews several UCs at once — still scoped far tighter than the whole
446
+ file, so coverage stays high. `AGENT_CAP` is the only knob; raise it if the host allows
447
+ more concurrency, lower it to save tokens. Whole-file mode (≤ 3 UCs) never hits the cap.
448
+
449
+ Spawn the chosen sub-agents using the Agent tool (send them in a single message so they
450
+ run concurrently). Each sub-agent gets a **fresh context window** and scans its scope
451
+ through its **one** dimension only — deeper coverage than one session juggling every
452
+ dimension at once (avoids lost-in-the-middle).
453
+
454
+ Sub-agent prompt template (fill the braces):
455
+
456
+ ```
457
+ You are a {DIMENSION_NAME} reviewer. Read the full target file at {target_file}.
458
+ Scope: review ONLY through the {DIMENSION_NAME} lens/check — {DIMENSION_DESCRIPTION}.
459
+ Be exhaustive: scan every section, every UC, every AC/BR/scenario. Do not stop early.
460
+ Project context (terminology, entities, architecture):
461
+ {slim_context — banned terms, canonical entities, layer order, domains}
462
+
463
+ Return a JSON array of findings, each:
464
+ { "dimension": "{DIMENSION_NAME}", "severity": "critical|major|minor",
465
+ "section": "...", "uc_id": "...", "quote": "<verbatim ≤120 chars>",
466
+ "finding": "...", "suggestion": "...", "auto_fixable": true|false }
467
+ Return [] if this dimension is clean. Return ONLY the JSON array.
468
+ ```
469
+
470
+ Collect every sub-agent's array into one consolidated list `ALL_FINDINGS`.
471
+
472
+ ---
473
+
474
+ ## Phase 2 — Completeness-critic convergence loop
475
+
476
+ This is the anti-whack-a-mole step. Repeat until **two consecutive rounds add zero new
477
+ findings**, or a hard cap of **3 rounds**, whichever comes first:
478
+
479
+ 1. Spawn one **completeness-critic** sub-agent with the Agent tool. Give it:
480
+ - the full target file (`{target_file}`),
481
+ - the current `ALL_FINDINGS` list (so it knows what is already captured),
482
+ - the same slim context.
483
+ Prompt it:
484
+ ```
485
+ Here is a document and a list of issues already found. Read the WHOLE document.
486
+ List ONLY real, additional issues NOT already in the list — gaps, ambiguities,
487
+ contradictions, missing edge/negative paths, coverage holes, terminology drift,
488
+ structural omissions, and any issue that a fix to an existing finding would expose.
489
+ Do NOT repeat anything already listed. Return the same finding JSON shape, or [] if
490
+ nothing new.
491
+ ```
492
+ 2. Append any genuinely new findings (not already in `ALL_FINDINGS`) to the list.
493
+ 3. If this round returned 0 new → increment the dry-round counter; else reset it to 0.
494
+ 4. Stop when dry-round counter reaches 2, or after 3 rounds total.
495
+
496
+ Record `convergence_rounds` (how many critic rounds ran) for the report.
497
+
498
+ ---
499
+
500
+ ## Phase 3 — Dedup, resolve conflicts, merge
501
+
502
+ Sub-agents run **blind to each other** (independence = diverse coverage). They never
503
+ talk or reconcile among themselves — all duplicate/conflict resolution happens **here in
504
+ the orchestrator**, where the full set is visible.
505
+
506
+ 1. **Deduplicate** `ALL_FINDINGS`: two findings are duplicates if they target the same
507
+ `section` + `uc_id` and describe the same underlying issue. Keep the one with the
508
+ richer `suggestion`; if they differ on severity, keep the **higher** severity.
509
+ 2. **Resolve conflicts** — group remaining findings by `section` + `uc_id` and check for
510
+ contradictions (two findings whose `suggestion`s cannot both be applied, or that
511
+ propose opposite fixes for the same spot):
512
+ - If the two suggestions can be **merged** into one coherent fix → merge them into a
513
+ single finding.
514
+ - If they are **mutually exclusive** → emit **one** finding that states both options
515
+ and set `auto_fixable: false` with `status: "needs_discussion"` (PRD) /
516
+ `status: "pending"` (review) so a human picks — never silently drop one side.
517
+ - If a finding is **invalidated** by another (e.g. a structural finding says a section
518
+ is missing, but another quotes content from it) → drop the invalid one.
519
+ 3. **Sort** by severity (critical → major → minor), then by `section` order in the file.
520
+ 4. **Assign stable IDs** `F001, F002, …` in that sorted order.
521
+ 5. Map each finding's `dimension` into the command's schema field
522
+ (`lens` for `/refine-prd`; `check_id` for `/review-context`).
523
+ 6. Write the **single** findings file in the FINDINGS SCHEMA the command defines.
524
+
525
+ In the command's final report, add one line:
526
+ ```
527
+ Convergence: {convergence_rounds} critic round(s) — findings file is complete; re-running should surface 0 new issues.
528
+ ```
529
+
530
+
531
+ **How the checks below map onto the procedure:**
532
+ - **DIMENSIONS** = the check groups for the detected mode — PRD: `P1, P2, P4, P5`; BDD: `B1, B2, B3, B4, B5, B6`. Fan out one sub-agent per check group, each scanning the full target file for just that group.
533
+ - **Orchestrator-run checks (not fanned out):** `P0` (umbrella routing) and `P3` (cross-PRD conflict) need config / other-PRD context — the orchestrator runs these itself **before** the fan-out and adds their results to `ALL_FINDINGS`.
534
+ - The completeness-critic loop (Phase 2) guarantees the findings file is complete in one run — re-running `/review-context` should surface **0 new** findings. Map each dimension into the `check_id` field of the schema below.
535
+
536
+ ---
537
+
389
538
  ## PRD Review Mode
390
539
 
391
540
  ### P0 — Umbrella Routing Check (umbrella mode only)
@@ -632,13 +781,13 @@ Suggest the logical next command based on workflow phase:
632
781
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
633
782
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
634
783
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
635
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
636
- | /generate-tests | `/run-tests {UC-ID}` |
637
- | /run-tests (passing) | `/review-code {UC-ID}` |
638
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
639
- | /review-code | `/smoke-test {UC-ID}` or create PR |
640
- | /smoke-test | Create PR and link to ticket |
641
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
784
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
785
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
786
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
787
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
788
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
789
+ | /dev-smoke-test | Create PR and link to ticket |
790
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
642
791
  | /fix-bug | Create PR and link to ticket |
643
792
  | /debug | `/fix-bug {ticket-id}` if fix needed |
644
793
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -689,7 +838,7 @@ to the findings file as usual and left `status: pending`.
689
838
 
690
839
  ### Phase 1 — Run analysis
691
840
 
692
- Run all checks (P1–P5 or B1–B6) exactly as in the default mode.
841
+ Run all checks via the **Review Procedure** (fan-out + completeness loop) exactly as in the default mode.
693
842
  Write the findings file with all `status: "pending"` as usual.
694
843
 
695
844
  ### Phase 2 — Apply auto-fixable findings
@@ -167,7 +167,7 @@ If `services` section is present:
167
167
 
168
168
  **2. Route to service** — if active domain matches a key in `services`:
169
169
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
170
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
170
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
171
171
  - Store `active_service` = `services.{domain}.path`
172
172
  - Store `active_service_module` = `services.{domain}.module`
173
173
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -179,13 +179,14 @@ If `services` section is present:
179
179
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
180
180
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
181
181
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
182
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
182
183
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
183
184
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
184
185
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
185
186
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
186
187
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
187
188
 
188
- > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
189
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
189
190
 
190
191
  ---
191
192
 
@@ -209,7 +210,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
209
210
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
210
211
 
211
212
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
212
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
213
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
213
214
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
214
215
 
215
216
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -302,7 +303,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
302
303
 
303
304
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
304
305
 
305
- 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).
306
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
306
307
 
307
308
  ---
308
309
 
@@ -615,13 +616,13 @@ Suggest the logical next command based on workflow phase:
615
616
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
616
617
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
617
618
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
618
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
619
- | /generate-tests | `/run-tests {UC-ID}` |
620
- | /run-tests (passing) | `/review-code {UC-ID}` |
621
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
622
- | /review-code | `/smoke-test {UC-ID}` or create PR |
623
- | /smoke-test | Create PR and link to ticket |
624
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
619
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
620
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
621
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
622
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
623
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
624
+ | /dev-smoke-test | Create PR and link to ticket |
625
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
625
626
  | /fix-bug | Create PR and link to ticket |
626
627
  | /debug | `/fix-bug {ticket-id}` if fix needed |
627
628
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -724,4 +725,5 @@ Sign-off : {✅ All done — status set to approved
724
725
  Re-run /review-tech-docs {file} to confirm 0 remaining critical findings.
725
726
  Next: {/generate-code {feature-file} ← only if status = approved
726
727
  | Collect pending sign-offs → update @trace.sign_off → re-run /review-tech-docs}
728
+ → if the tech-doc lives in the shared spec repo: commit + push it to the spec submodule so FE/App `/sync` the updated contract
727
729
  ```
@@ -408,13 +408,13 @@ Suggest the logical next command based on workflow phase:
408
408
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
409
409
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
410
410
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
411
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
412
- | /generate-tests | `/run-tests {UC-ID}` |
413
- | /run-tests (passing) | `/review-code {UC-ID}` |
414
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
415
- | /review-code | `/smoke-test {UC-ID}` or create PR |
416
- | /smoke-test | Create PR and link to ticket |
417
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
411
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
412
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
413
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
414
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
415
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
416
+ | /dev-smoke-test | Create PR and link to ticket |
417
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
418
418
  | /fix-bug | Create PR and link to ticket |
419
419
  | /debug | `/fix-bug {ticket-id}` if fix needed |
420
420
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -248,13 +248,15 @@ For each entry in `services[]`:
248
248
 
249
249
  ## Step 4 — Check `.gitignore`
250
250
 
251
- Check if `.trace/` appears in the umbrella root's `.gitignore` (or `.git/info/exclude`).
251
+ Check the generated Living Docs mirrors are gitignored:
252
+ - `.trace/` in the current repo's `.gitignore` (or `.git/info/exclude`)
253
+ - `.living-docs/` in the **specs module's** `.gitignore` (when `setup.spec_source` is set)
252
254
 
253
- If missing:
255
+ If either is missing:
254
256
  ```
255
- ⚠️ .trace/ is not in umbrella .gitignore
256
- Add it to prevent accidentally committing generated trace artifacts:
257
+ ⚠️ Living Docs mirrors not gitignored they are generated, never commit them:
257
258
  echo ".trace/" >> .gitignore
259
+ echo ".living-docs/" >> {spec_source}/.gitignore # specs module (if spec_source set)
258
260
  ```
259
261
 
260
262
  ---
@@ -263,20 +265,21 @@ If missing:
263
265
 
264
266
  *Skip if `services` is empty.*
265
267
 
266
- For each service in `services[]`:
267
- 1. Check if `{service.path}/.trace/` directory exists and contains `.tsv` files
268
- 2. If yes copy TSVs to `{umbrella_root}/.trace/{service-name}/` (create dir if needed)
268
+ **Resolve the Living Docs home (same rule as `/validate-traces`):**
269
+ - `living_docs_dir` = `{spec_source}/.living-docs` if `setup.spec_source` is set, else `.living-docs` at umbrella root. *(The specs module is mounted inside every service workspace, so the panel resolves it even when a dev opens a single service submodule.)*
270
+ - `panel_mirror` = `./.trace` at the current workspace root.
269
271
 
270
- After copying all services, write merged `{umbrella_root}/.trace/trace-report.json`:
271
- - Aggregate data from each service's `.trace/` TSVs
272
- - Include `"service"` field per scenario row
273
- - Recalculate summary totals
272
+ 1. For each service in `services[]`: if `{service.path}/.trace/` has `.tsv` files → copy them to `{living_docs_dir}/{service-name}/` (create dir if needed).
273
+ 2. Write merged `{living_docs_dir}/trace-report.json`:
274
+ - Aggregate each service's `.trace/` TSVs, add `"service"` field per row, recalc summary totals.
275
+ 3. **Mirror to the panel location:** copy `{living_docs_dir}/trace-report.json` (+ namespaced TSVs) → `{panel_mirror}/` so the panel in the currently-open repo is non-empty. Skip if `panel_mirror` already equals `living_docs_dir`.
274
276
 
275
277
  Print sync result:
276
278
  ```
277
- Living Docs → .trace/ synced
279
+ Living Docs → {living_docs_dir}/ synced (canonical, specs module)
278
280
  {service-name}: {N} TSVs
279
281
  trace-report.json: {total} scenarios across {S} services
282
+ Panel mirror → {panel_mirror}/ (current workspace)
280
283
  ```
281
284
 
282
285
  If no `.trace/` dirs found → `Living Docs: no trace data yet — run /generate-bdd then /generate-code first.`
@@ -334,13 +337,13 @@ Suggest the logical next command based on workflow phase:
334
337
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
335
338
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
336
339
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
337
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
338
- | /generate-tests | `/run-tests {UC-ID}` |
339
- | /run-tests (passing) | `/review-code {UC-ID}` |
340
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
341
- | /review-code | `/smoke-test {UC-ID}` or create PR |
342
- | /smoke-test | Create PR and link to ticket |
343
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
340
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
341
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
342
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
343
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
344
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
345
+ | /dev-smoke-test | Create PR and link to ticket |
346
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
344
347
  | /fix-bug | Create PR and link to ticket |
345
348
  | /debug | `/fix-bug {ticket-id}` if fix needed |
346
349
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -385,7 +388,7 @@ Service Configs
385
388
  ✅ user-service — test: mvn test | build: mvn compile
386
389
  ✅ order-service — test: mvn test | build: mvn compile
387
390
  ⚠️ payment-service — .agent/project-context.yaml missing
388
- → create it so /run-tests works correctly
391
+ → create it so /dev-run-test works correctly
389
392
 
390
393
  .gitignore
391
394
  ✅ .trace/ is gitignored
@@ -163,13 +163,13 @@ Suggest the logical next command based on workflow phase:
163
163
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
164
164
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
165
165
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
166
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
167
- | /generate-tests | `/run-tests {UC-ID}` |
168
- | /run-tests (passing) | `/review-code {UC-ID}` |
169
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
170
- | /review-code | `/smoke-test {UC-ID}` or create PR |
171
- | /smoke-test | Create PR and link to ticket |
172
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
166
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
167
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
168
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
169
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
170
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
171
+ | /dev-smoke-test | Create PR and link to ticket |
172
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
173
173
  | /fix-bug | Create PR and link to ticket |
174
174
  | /debug | `/fix-bug {ticket-id}` if fix needed |
175
175
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |