@anhth2/spec-driven-dev-plugin 0.12.0 → 0.14.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 (130) hide show
  1. package/commands/debug.md +42 -7
  2. package/commands/define-product.md +42 -7
  3. package/commands/dev-gen-test.md +60 -17
  4. package/commands/dev-run-test.md +61 -18
  5. package/commands/dev-run-test.tmpl +1 -1
  6. package/commands/dev-smoke-test.md +42 -7
  7. package/commands/fix-bug.md +42 -7
  8. package/commands/generate-bdd.md +67 -21
  9. package/commands/generate-bdd.tmpl +7 -4
  10. package/commands/generate-code.md +113 -35
  11. package/commands/generate-code.tmpl +53 -18
  12. package/commands/generate-design-spec.md +42 -7
  13. package/commands/generate-prd.md +42 -7
  14. package/commands/generate-spec-manifest.md +42 -7
  15. package/commands/generate-tech-docs.md +229 -20
  16. package/commands/generate-tech-docs.tmpl +187 -13
  17. package/commands/learn.md +42 -7
  18. package/commands/map-testids.md +564 -0
  19. package/commands/map-testids.tmpl +81 -0
  20. package/commands/propose-scenario.md +42 -7
  21. package/commands/qc-analyze.md +42 -7
  22. package/commands/qc-design-test.md +44 -8
  23. package/commands/qc-design-test.tmpl +2 -1
  24. package/commands/qc-plan.md +42 -7
  25. package/commands/qc-report.md +42 -7
  26. package/commands/qc-review.md +42 -7
  27. package/commands/qc-run-test.md +62 -18
  28. package/commands/qc-run-test.tmpl +2 -1
  29. package/commands/refine-prd.md +42 -7
  30. package/commands/report-bug.md +42 -7
  31. package/commands/review-code.md +42 -7
  32. package/commands/review-context.md +42 -7
  33. package/commands/review-tech-docs.md +45 -9
  34. package/commands/review-tech-docs.tmpl +3 -2
  35. package/commands/setup-ai-first.md +37 -4
  36. package/commands/setup-ai-first.tmpl +2 -2
  37. package/commands/sync.md +35 -2
  38. package/commands/update-framework.md +35 -2
  39. package/commands/validate-traces.md +85 -40
  40. package/commands/validate-traces.tmpl +43 -33
  41. package/core/FRAMEWORK_VERSION +1 -1
  42. package/core/commands/debug.md +42 -7
  43. package/core/commands/define-product.md +42 -7
  44. package/core/commands/dev-gen-test.md +60 -17
  45. package/core/commands/dev-run-test.md +61 -18
  46. package/core/commands/dev-smoke-test.md +42 -7
  47. package/core/commands/fix-bug.md +42 -7
  48. package/core/commands/generate-bdd.md +67 -21
  49. package/core/commands/generate-code.md +113 -35
  50. package/core/commands/generate-design-spec.md +42 -7
  51. package/core/commands/generate-prd.md +42 -7
  52. package/core/commands/generate-spec-manifest.md +42 -7
  53. package/core/commands/generate-tech-docs.md +229 -20
  54. package/core/commands/learn.md +42 -7
  55. package/core/commands/map-testids.md +564 -0
  56. package/core/commands/propose-scenario.md +42 -7
  57. package/core/commands/qc-analyze.md +42 -7
  58. package/core/commands/qc-design-test.md +44 -8
  59. package/core/commands/qc-plan.md +42 -7
  60. package/core/commands/qc-report.md +42 -7
  61. package/core/commands/qc-review.md +42 -7
  62. package/core/commands/qc-run-test.md +62 -18
  63. package/core/commands/refine-prd.md +42 -7
  64. package/core/commands/report-bug.md +42 -7
  65. package/core/commands/review-code.md +42 -7
  66. package/core/commands/review-context.md +42 -7
  67. package/core/commands/review-tech-docs.md +45 -9
  68. package/core/commands/setup-ai-first.md +37 -4
  69. package/core/commands/sync.md +35 -2
  70. package/core/commands/update-framework.md +35 -2
  71. package/core/commands/validate-traces.md +85 -40
  72. package/core/modules/qc-playwright/stack-profile.yaml +1 -0
  73. package/core/skills/code/SKILL.md +77 -9
  74. package/core/skills/debug/SKILL.md +112 -11
  75. package/core/skills/design-spec/SKILL.md +42 -7
  76. package/core/skills/discovery/SKILL.md +42 -7
  77. package/core/skills/prd/SKILL.md +70 -4
  78. package/core/skills/setup-ai-first/SKILL.md +35 -2
  79. package/core/skills/spec/SKILL.md +70 -4
  80. package/core/skills/test/SKILL.md +119 -16
  81. package/core/steps/context-loader.md +7 -5
  82. package/core/steps/report-footer.md +35 -2
  83. package/core/steps/trace-mirror.md +18 -10
  84. package/core/templates/project-context.yaml +8 -5
  85. package/docs/01-getting-started/core-concepts.md +7 -7
  86. package/docs/01-getting-started/installation.md +2 -2
  87. package/docs/01-getting-started/quickstart.md +1 -1
  88. package/docs/02-guides/README.md +1 -2
  89. package/docs/02-guides/developer/README.md +1 -1
  90. package/docs/02-guides/developer/bdd-and-trace.md +10 -8
  91. package/docs/02-guides/developer/commands.md +3 -3
  92. package/docs/02-guides/developer/scenarios.md +26 -14
  93. package/docs/02-guides/developer/workflow.md +80 -20
  94. package/docs/02-guides/product-owner/README.md +6 -4
  95. package/docs/02-guides/product-owner/commands.md +1 -1
  96. package/docs/02-guides/product-owner/scenarios.md +80 -1
  97. package/docs/02-guides/tester/README.md +12 -11
  98. package/docs/02-guides/tester/bug-reporting.md +1 -1
  99. package/docs/02-guides/{qc-automation.md → tester/qc-automation.md} +14 -6
  100. package/docs/02-guides/tester/reading-specs.md +4 -4
  101. package/docs/02-guides/tester/scenarios.md +5 -5
  102. package/docs/02-guides/tester/spec-manifest.md +17 -12
  103. package/docs/02-guides/tester/test-checklist.md +3 -3
  104. package/docs/02-guides/tester/workflow.md +8 -11
  105. package/docs/03-concepts/architecture.md +5 -4
  106. package/docs/03-concepts/pipeline.md +18 -6
  107. package/docs/03-concepts/traceability.md +17 -17
  108. package/docs/04-operations/README.md +1 -1
  109. package/docs/04-operations/bug-flow.md +4 -4
  110. package/docs/04-operations/sync-and-update.md +163 -38
  111. package/docs/05-reference/README.md +3 -0
  112. package/docs/05-reference/command-cheatsheet.md +147 -0
  113. package/docs/05-reference/commands.md +72 -69
  114. package/docs/05-reference/modules.md +2 -2
  115. package/docs/05-reference/trace-schema.md +15 -14
  116. package/docs/README.md +3 -5
  117. package/modules/qc-playwright/stack-profile.yaml +1 -0
  118. package/package.json +1 -1
  119. package/skills/code/SKILL.md +77 -9
  120. package/skills/debug/SKILL.md +112 -11
  121. package/skills/design-spec/SKILL.md +42 -7
  122. package/skills/discovery/SKILL.md +42 -7
  123. package/skills/prd/SKILL.md +70 -4
  124. package/skills/setup-ai-first/SKILL.md +35 -2
  125. package/skills/spec/SKILL.md +70 -4
  126. package/skills/test/SKILL.md +119 -16
  127. package/steps/context-loader.md +7 -5
  128. package/steps/report-footer.md +35 -2
  129. package/steps/trace-mirror.md +18 -10
  130. package/templates/project-context.yaml +8 -5
@@ -168,7 +168,7 @@ If `services` section is present:
168
168
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
169
169
 
170
170
  **2. Route to service** — if active domain matches a key in `services`:
171
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
171
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
172
172
  - 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.
173
173
  - Store `active_service` = `services.{domain}.path`
174
174
  - Store `active_service_module` = `services.{domain}.module`
@@ -179,6 +179,7 @@ If `services` section is present:
179
179
  - Set `active_service = unresolved`
180
180
 
181
181
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
182
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
182
183
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
183
184
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
184
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.)*
@@ -188,8 +189,9 @@ If `services` section is present:
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
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
192
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
191
193
 
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.
194
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
193
195
 
194
196
  ---
195
197
 
@@ -209,12 +211,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
209
211
  |----------|--------|
210
212
  | `conventions.test_command` | service's `conventions.test_command` |
211
213
  | `conventions.build_command` | service's `conventions.build_command` |
212
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
213
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
214
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
215
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
214
216
 
215
217
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
216
218
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
217
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
219
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
218
220
 
219
221
  **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).
220
222
 
@@ -400,16 +402,15 @@ Proceed to the next step of the calling command.
400
402
  Check whether `services` array exists in `project-context.yaml`.
401
403
 
402
404
  **If `services` exists (umbrella mode):**
403
- - Resolve the trace dir for each service:
404
- - Use `services[N].trace_dir` if explicitly set
405
- - Otherwise default to `{services[N].path}/.trace`
406
- - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
407
- - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
408
- - **Resolve the Living Docs home (canonical report location):**
405
+ - Resolve the trace dir(s):
406
+ - **If `setup.spec_source` is set (consolidated trace):** `all_trace_dirs = [ {spec_source}/.trace ]` — a **single** authoritative location in the spec repo. Scenarios carry their owning service via the `@trace.service` field, so no per-service split is needed. This is the common case.
407
+ - **Else (no spec_source — legacy per-service trace):** one dir per service — `services[N].trace_dir` if set, else `{services[N].path}/.trace`; `all_trace_dirs = [ dir1, dir2, … ]`, tagged by service name on read.
408
+ - Step 1 reads TSVs from `all_trace_dirs`.
409
+ - **Resolve the Living Docs home (generated report location):**
409
410
  - If `setup.spec_source` is set → `living_docs_dir = {spec_source}/.living-docs`
410
411
  *(the shared specs module — mounted inside every service/umbrella workspace, so the panel resolves it no matter which submodule the dev is standing in)*
411
412
  - Else (umbrella without a separate spec repo) → `living_docs_dir = .living-docs` at umbrella root
412
- - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the merged report here is what makes the view non-empty when a dev opens a service submodule directly.
413
+ - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the report here is what makes the view non-empty when a dev opens a service submodule directly.
413
414
 
414
415
  **If no `services` key (single-service mode):**
415
416
  - Set `all_trace_dirs = [ {paths.trace_dir} ]`
@@ -461,11 +462,14 @@ If any layer is behind current PRD version → flag `PRD_DRIFT` and extract chan
461
462
 
462
463
  ### Step 5 — Tech-doc revision drift check
463
464
 
464
- For each UC that has a tech-doc, compare:
465
- - Current `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`
466
- - `tech_doc_revision` stored in `.tsv` (revision at time of codegen)
465
+ For each UC that has a tech-doc, compare the stored revision against the current doc — for **both** tech-doc kinds:
467
466
 
468
- If code was generated from an older revision flag `TECHDOC_DRIFT`.
467
+ - **BE contract:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` vs `tech_doc_revision` in `.tsv`.
468
+ Code generated from an older revision → flag `TECHDOC_DRIFT`.
469
+ - **FE tech-design:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` vs `fe_tech_doc_revision` in `.tsv` (per platform row).
470
+ FE code generated from an older revision → flag `FE_TECHDOC_DRIFT`.
471
+
472
+ Skip whichever kind has no doc / no stored revision (`—`).
469
473
 
470
474
  ### Step 6 — Write status back to TSV
471
475
 
@@ -572,6 +576,7 @@ Schema:
572
576
  "prd_version": "<prd version when BDD was generated>",
573
577
  "bdd_version": "<bdd version when code was generated>",
574
578
  "tech_doc_revision": 0,
579
+ "fe_tech_doc_revision": 0,
575
580
  "status": "OK | DRIFT | GAP | UNTRACKED",
576
581
  "last_updated": "<YYYY-MM-DD>"
577
582
  }
@@ -621,6 +626,15 @@ Schema:
621
626
  "current_revision": 0,
622
627
  "fix": "/generate-code <UC-ID>"
623
628
  }
629
+ ],
630
+ "fe_techdoc_drift": [
631
+ {
632
+ "uc_id": "<UC-ID>",
633
+ "platform": "web | app",
634
+ "code_revision": 0,
635
+ "current_revision": 0,
636
+ "fix": "/generate-code <UC-ID> --phase=integration"
637
+ }
624
638
  ]
625
639
  }
626
640
  }
@@ -630,44 +644,42 @@ Schema:
630
644
  - `implemented_by`: use `null` (not `"—"`) in JSON when no value
631
645
  - `test_count`: use integer `0` (not `"—"`) when no tests
632
646
  - `test_classes`: use `[]` (not `"—"`) when no test classes
633
- - `tech_doc_revision`: use integer; `0` if not yet generated
647
+ - `tech_doc_revision` / `fe_tech_doc_revision`: use integer; `0` if not yet generated
634
648
  - `code_coverage_pct` / `test_coverage_pct`: round to nearest integer (0–100)
635
649
  - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
636
- - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
637
- - **Backward-compat (older 19-col TSV):** if `qc_owner` / `qc_blocked_by` columns are **absent** from the header (a pre-upgrade TSV), treat them as `null` do not error. The next `/generate-bdd` re-gen upgrades the header to include them.
650
+ - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `fe_tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
651
+ - **Backward-compat:** older TSVs may be missing newer columns from the header — treat any absent column as its empty value (do not error): `qc_owner`/`qc_blocked_by` (pre-19-col) `null`; `fe_tech_doc_revision` (pre-22-col) `0`. The next `/generate-bdd` re-gen upgrades the header to the current 22-column layout.
638
652
 
639
653
  ### Step 8b — Living Docs Sync *(umbrella mode only)*
640
654
 
641
655
  *Skip this step in single-service mode.*
642
656
 
643
- Authoritative trace state stays in each service submodule's `.trace/` (committed there).
644
- This step publishes the merged report to the **canonical Living Docs home** (the specs
645
- module) and drops a local mirror so the panel is never empty.
657
+ **With `spec_source` set,** the authoritative trace TSVs already live in **one** place —
658
+ `{spec_source}/.trace/` (committed in the spec repo). There is **no per-service merge**:
659
+ each scenario row carries its owning service via `@trace.service`. This step just
660
+ (re)generates the report and refreshes the local panel.
646
661
 
647
- 1. **Write canonical merged report** to `{living_docs_dir}/` (`mkdir -p` it first):
648
- - `{living_docs_dir}/trace-report.json` merge every per-service `trace-report.json`
649
- into one document, add a `"service"` field per scenario row, recalc summary aggregates.
650
- - `{living_docs_dir}/{service-name}/{UC-ID}.tsv` copy each service's TSVs, namespaced
651
- by service. Overwrite; don't delete TSVs whose service source is gone (prior runs).
662
+ 1. **Write the report** to `{living_docs_dir}/trace-report.json` (`mkdir -p` first) — built
663
+ directly from `{spec_source}/.trace/*.tsv`, with a `"service"` field per scenario row and
664
+ the summary aggregates. *(Legacy no-`spec_source` umbrellas still merge every per-service
665
+ `trace-report.json` into one document, namespaced by service.)*
652
666
 
653
667
  2. **Mirror to the panel location** `{panel_mirror}` (`./.trace` at the current workspace
654
- root) so a dev who opened *this* repo (umbrella **or** a single service submodule) sees
655
- data immediately: copy `{living_docs_dir}/trace-report.json` → `{panel_mirror}/trace-report.json`
656
- (and the namespaced TSVs). If `panel_mirror` already resolves to `living_docs_dir`, skip.
668
+ root) so a dev who opened *this* repo sees data immediately: copy
669
+ `{living_docs_dir}/trace-report.json` (+ the `{UC-ID}.tsv` files) → `{panel_mirror}/`.
670
+ If `panel_mirror` already resolves to `{spec_source}/.trace`, skip.
657
671
 
658
672
  3. **Print sync summary:**
659
673
  ```
660
- Living Docs → {living_docs_dir}/ (canonical, in specs module)
661
- user-service : {N} TSV files
662
- order-service : {N} TSV files
663
- trace-report.json: merged ({total} scenarios across {S} services)
674
+ Living Docs → {living_docs_dir}/trace-report.json ({total} scenarios across {S} services)
675
+ Trace (authoritative) → {spec_source}/.trace/ (committed in spec repo)
664
676
  Panel mirror → {panel_mirror}/trace-report.json (current workspace)
665
677
  ```
666
678
 
667
- > **Note both locations are generated, gitignored mirrors.** Add `.living-docs/` to the
668
- > **specs module's** `.gitignore` and `.trace/` to the current repo's `.gitignore`. The only
669
- > committed, authoritative trace state is each service submodule's own `.trace/`. The report
670
- > is regenerated by `/validate-traces` or `/sync` — never commit it.
679
+ > **Note:** the committed, authoritative trace state is `{spec_source}/.trace/*.tsv` (in the
680
+ > spec repo one place for the PM). The report (`.living-docs/`) and the panel mirror
681
+ > (`./.trace` at a workspace that is not the spec repo) are **generated** — gitignore them;
682
+ > they are regenerated by `/validate-traces` or `/sync`.
671
683
 
672
684
  ## Output
673
685
 
@@ -693,6 +705,36 @@ Output Artifacts:
693
705
 
694
706
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
695
707
 
708
+ ## Pipeline Position
709
+
710
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
711
+ so the user always sees where this command sits in the end-to-end flow:
712
+
713
+ ```
714
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
715
+ ```
716
+
717
+ Find the current command in this phase legend and mark **its** phase in the map above:
718
+
719
+ | Phase | Commands |
720
+ |-------|----------|
721
+ | Discovery | `/define-product` |
722
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
723
+ | Design Spec | `/generate-design-spec` |
724
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
725
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
726
+ | Code | `/generate-code` · `/review-code` |
727
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
728
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
729
+ | Trace Audit | `/validate-traces` |
730
+
731
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
732
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
733
+
734
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
735
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
736
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
737
+
696
738
  ## Next Command Suggestion
697
739
 
698
740
  Suggest the logical next command based on workflow phase:
@@ -734,10 +776,13 @@ Suggest the logical next command based on workflow phase:
734
776
  Format the footer as:
735
777
  ```
736
778
  ---
737
- Status : {badge}
779
+ Status : {badge}
738
780
  {Output Artifacts block}
739
- Next : {suggested command with example arguments}
781
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
782
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
783
+ Next : {suggested command with example arguments}
740
784
  ```
785
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
741
786
 
742
787
 
743
788
  ```
@@ -19,16 +19,15 @@ Read-only check of coverage between specs, code, and tests — including PRD ver
19
19
  Check whether `services` array exists in `project-context.yaml`.
20
20
 
21
21
  **If `services` exists (umbrella mode):**
22
- - Resolve the trace dir for each service:
23
- - Use `services[N].trace_dir` if explicitly set
24
- - Otherwise default to `{services[N].path}/.trace`
25
- - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
26
- - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
27
- - **Resolve the Living Docs home (canonical report location):**
22
+ - Resolve the trace dir(s):
23
+ - **If `setup.spec_source` is set (consolidated trace):** `all_trace_dirs = [ {spec_source}/.trace ]` — a **single** authoritative location in the spec repo. Scenarios carry their owning service via the `@trace.service` field, so no per-service split is needed. This is the common case.
24
+ - **Else (no spec_source — legacy per-service trace):** one dir per service — `services[N].trace_dir` if set, else `{services[N].path}/.trace`; `all_trace_dirs = [ dir1, dir2, … ]`, tagged by service name on read.
25
+ - Step 1 reads TSVs from `all_trace_dirs`.
26
+ - **Resolve the Living Docs home (generated report location):**
28
27
  - If `setup.spec_source` is set → `living_docs_dir = {spec_source}/.living-docs`
29
28
  *(the shared specs module — mounted inside every service/umbrella workspace, so the panel resolves it no matter which submodule the dev is standing in)*
30
29
  - Else (umbrella without a separate spec repo) → `living_docs_dir = .living-docs` at umbrella root
31
- - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the merged report here is what makes the view non-empty when a dev opens a service submodule directly.
30
+ - **Resolve the panel mirror:** `panel_mirror = ./.trace` at the **current workspace root** (wherever this command runs). The VS Code panel reads `.trace/trace-report.json` from the open workspace — writing the report here is what makes the view non-empty when a dev opens a service submodule directly.
32
31
 
33
32
  **If no `services` key (single-service mode):**
34
33
  - Set `all_trace_dirs = [ {paths.trace_dir} ]`
@@ -80,11 +79,14 @@ If any layer is behind current PRD version → flag `PRD_DRIFT` and extract chan
80
79
 
81
80
  ### Step 5 — Tech-doc revision drift check
82
81
 
83
- For each UC that has a tech-doc, compare:
84
- - Current `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`
85
- - `tech_doc_revision` stored in `.tsv` (revision at time of codegen)
82
+ For each UC that has a tech-doc, compare the stored revision against the current doc — for **both** tech-doc kinds:
86
83
 
87
- If code was generated from an older revision flag `TECHDOC_DRIFT`.
84
+ - **BE contract:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` vs `tech_doc_revision` in `.tsv`.
85
+ Code generated from an older revision → flag `TECHDOC_DRIFT`.
86
+ - **FE tech-design:** `@trace.revision` in `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` vs `fe_tech_doc_revision` in `.tsv` (per platform row).
87
+ FE code generated from an older revision → flag `FE_TECHDOC_DRIFT`.
88
+
89
+ Skip whichever kind has no doc / no stored revision (`—`).
88
90
 
89
91
  ### Step 6 — Write status back to TSV
90
92
 
@@ -191,6 +193,7 @@ Schema:
191
193
  "prd_version": "<prd version when BDD was generated>",
192
194
  "bdd_version": "<bdd version when code was generated>",
193
195
  "tech_doc_revision": 0,
196
+ "fe_tech_doc_revision": 0,
194
197
  "status": "OK | DRIFT | GAP | UNTRACKED",
195
198
  "last_updated": "<YYYY-MM-DD>"
196
199
  }
@@ -240,6 +243,15 @@ Schema:
240
243
  "current_revision": 0,
241
244
  "fix": "/generate-code <UC-ID>"
242
245
  }
246
+ ],
247
+ "fe_techdoc_drift": [
248
+ {
249
+ "uc_id": "<UC-ID>",
250
+ "platform": "web | app",
251
+ "code_revision": 0,
252
+ "current_revision": 0,
253
+ "fix": "/generate-code <UC-ID> --phase=integration"
254
+ }
243
255
  ]
244
256
  }
245
257
  }
@@ -249,44 +261,42 @@ Schema:
249
261
  - `implemented_by`: use `null` (not `"—"`) in JSON when no value
250
262
  - `test_count`: use integer `0` (not `"—"`) when no tests
251
263
  - `test_classes`: use `[]` (not `"—"`) when no test classes
252
- - `tech_doc_revision`: use integer; `0` if not yet generated
264
+ - `tech_doc_revision` / `fe_tech_doc_revision`: use integer; `0` if not yet generated
253
265
  - `code_coverage_pct` / `test_coverage_pct`: round to nearest integer (0–100)
254
266
  - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
255
- - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
256
- - **Backward-compat (older 19-col TSV):** if `qc_owner` / `qc_blocked_by` columns are **absent** from the header (a pre-upgrade TSV), treat them as `null` do not error. The next `/generate-bdd` re-gen upgrades the header to include them.
267
+ - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`; `fe_tech_doc_revision: "—"` → `0`; `dev_selftest: "—"` → `"not_run"`; `dev_selftest_at: "—"` → `null`; `qc_status: "—"` → `"not_run"`; `qc_run_at: "—"` → `null`; `qc_owner: "—"` → `null`; `qc_blocked_by: "—"` → `null`
268
+ - **Backward-compat:** older TSVs may be missing newer columns from the header — treat any absent column as its empty value (do not error): `qc_owner`/`qc_blocked_by` (pre-19-col) `null`; `fe_tech_doc_revision` (pre-22-col) `0`. The next `/generate-bdd` re-gen upgrades the header to the current 22-column layout.
257
269
 
258
270
  ### Step 8b — Living Docs Sync *(umbrella mode only)*
259
271
 
260
272
  *Skip this step in single-service mode.*
261
273
 
262
- Authoritative trace state stays in each service submodule's `.trace/` (committed there).
263
- This step publishes the merged report to the **canonical Living Docs home** (the specs
264
- module) and drops a local mirror so the panel is never empty.
274
+ **With `spec_source` set,** the authoritative trace TSVs already live in **one** place —
275
+ `{spec_source}/.trace/` (committed in the spec repo). There is **no per-service merge**:
276
+ each scenario row carries its owning service via `@trace.service`. This step just
277
+ (re)generates the report and refreshes the local panel.
265
278
 
266
- 1. **Write canonical merged report** to `{living_docs_dir}/` (`mkdir -p` it first):
267
- - `{living_docs_dir}/trace-report.json` merge every per-service `trace-report.json`
268
- into one document, add a `"service"` field per scenario row, recalc summary aggregates.
269
- - `{living_docs_dir}/{service-name}/{UC-ID}.tsv` copy each service's TSVs, namespaced
270
- by service. Overwrite; don't delete TSVs whose service source is gone (prior runs).
279
+ 1. **Write the report** to `{living_docs_dir}/trace-report.json` (`mkdir -p` first) — built
280
+ directly from `{spec_source}/.trace/*.tsv`, with a `"service"` field per scenario row and
281
+ the summary aggregates. *(Legacy no-`spec_source` umbrellas still merge every per-service
282
+ `trace-report.json` into one document, namespaced by service.)*
271
283
 
272
284
  2. **Mirror to the panel location** `{panel_mirror}` (`./.trace` at the current workspace
273
- root) so a dev who opened *this* repo (umbrella **or** a single service submodule) sees
274
- data immediately: copy `{living_docs_dir}/trace-report.json` → `{panel_mirror}/trace-report.json`
275
- (and the namespaced TSVs). If `panel_mirror` already resolves to `living_docs_dir`, skip.
285
+ root) so a dev who opened *this* repo sees data immediately: copy
286
+ `{living_docs_dir}/trace-report.json` (+ the `{UC-ID}.tsv` files) → `{panel_mirror}/`.
287
+ If `panel_mirror` already resolves to `{spec_source}/.trace`, skip.
276
288
 
277
289
  3. **Print sync summary:**
278
290
  ```
279
- Living Docs → {living_docs_dir}/ (canonical, in specs module)
280
- user-service : {N} TSV files
281
- order-service : {N} TSV files
282
- trace-report.json: merged ({total} scenarios across {S} services)
291
+ Living Docs → {living_docs_dir}/trace-report.json ({total} scenarios across {S} services)
292
+ Trace (authoritative) → {spec_source}/.trace/ (committed in spec repo)
283
293
  Panel mirror → {panel_mirror}/trace-report.json (current workspace)
284
294
  ```
285
295
 
286
- > **Note both locations are generated, gitignored mirrors.** Add `.living-docs/` to the
287
- > **specs module's** `.gitignore` and `.trace/` to the current repo's `.gitignore`. The only
288
- > committed, authoritative trace state is each service submodule's own `.trace/`. The report
289
- > is regenerated by `/validate-traces` or `/sync` — never commit it.
296
+ > **Note:** the committed, authoritative trace state is `{spec_source}/.trace/*.tsv` (in the
297
+ > spec repo one place for the PM). The report (`.living-docs/`) and the panel mirror
298
+ > (`./.trace` at a workspace that is not the spec repo) are **generated** — gitignore them;
299
+ > they are regenerated by `/validate-traces` or `/sync`.
290
300
 
291
301
  ## Output
292
302
 
@@ -1 +1 @@
1
- 0.12.0
1
+ 0.14.0
@@ -169,7 +169,7 @@ If `services` section is present:
169
169
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
170
170
 
171
171
  **2. Route to service** — if active domain matches a key in `services`:
172
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
172
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
173
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`
@@ -180,6 +180,7 @@ If `services` section is present:
180
180
  - Set `active_service = unresolved`
181
181
 
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
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
183
184
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
184
185
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
185
186
  - 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.)*
@@ -189,8 +190,9 @@ If `services` section is present:
189
190
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
190
191
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
191
192
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
193
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
192
194
 
193
- > **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.
195
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
194
196
 
195
197
  ---
196
198
 
@@ -210,12 +212,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
210
212
  |----------|--------|
211
213
  | `conventions.test_command` | service's `conventions.test_command` |
212
214
  | `conventions.build_command` | service's `conventions.build_command` |
213
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
214
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
215
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
216
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
215
217
 
216
218
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
217
219
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
218
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
220
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
219
221
 
220
222
  **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).
221
223
 
@@ -618,6 +620,36 @@ Output Artifacts:
618
620
 
619
621
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
620
622
 
623
+ ## Pipeline Position
624
+
625
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
626
+ so the user always sees where this command sits in the end-to-end flow:
627
+
628
+ ```
629
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
630
+ ```
631
+
632
+ Find the current command in this phase legend and mark **its** phase in the map above:
633
+
634
+ | Phase | Commands |
635
+ |-------|----------|
636
+ | Discovery | `/define-product` |
637
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
638
+ | Design Spec | `/generate-design-spec` |
639
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
640
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
641
+ | Code | `/generate-code` · `/review-code` |
642
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
643
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
644
+ | Trace Audit | `/validate-traces` |
645
+
646
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
647
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
648
+
649
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
650
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
651
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
652
+
621
653
  ## Next Command Suggestion
622
654
 
623
655
  Suggest the logical next command based on workflow phase:
@@ -659,10 +691,13 @@ Suggest the logical next command based on workflow phase:
659
691
  Format the footer as:
660
692
  ```
661
693
  ---
662
- Status : {badge}
694
+ Status : {badge}
663
695
  {Output Artifacts block}
664
- Next : {suggested command with example arguments}
696
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
697
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
698
+ Next : {suggested command with example arguments}
665
699
  ```
700
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
666
701
 
667
702
 
668
703
  ```
@@ -166,7 +166,7 @@ If `services` section is present:
166
166
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
167
167
 
168
168
  **2. Route to service** — if active domain matches a key in `services`:
169
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
169
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
170
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`
@@ -177,6 +177,7 @@ If `services` section is present:
177
177
  - Set `active_service = unresolved`
178
178
 
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
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
180
181
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
181
182
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
182
183
  - 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.)*
@@ -186,8 +187,9 @@ If `services` section is present:
186
187
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
187
188
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
188
189
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
190
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
189
191
 
190
- > **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
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
191
193
 
192
194
  ---
193
195
 
@@ -207,12 +209,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
207
209
  |----------|--------|
208
210
  | `conventions.test_command` | service's `conventions.test_command` |
209
211
  | `conventions.build_command` | service's `conventions.build_command` |
210
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
211
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
212
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
213
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
212
214
 
213
215
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
214
216
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
215
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
217
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
216
218
 
217
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).
218
220
 
@@ -552,6 +554,36 @@ Output Artifacts:
552
554
 
553
555
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
554
556
 
557
+ ## Pipeline Position
558
+
559
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
560
+ so the user always sees where this command sits in the end-to-end flow:
561
+
562
+ ```
563
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
564
+ ```
565
+
566
+ Find the current command in this phase legend and mark **its** phase in the map above:
567
+
568
+ | Phase | Commands |
569
+ |-------|----------|
570
+ | Discovery | `/define-product` |
571
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
572
+ | Design Spec | `/generate-design-spec` |
573
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
574
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
575
+ | Code | `/generate-code` · `/review-code` |
576
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
577
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
578
+ | Trace Audit | `/validate-traces` |
579
+
580
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
581
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
582
+
583
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
584
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
585
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
586
+
555
587
  ## Next Command Suggestion
556
588
 
557
589
  Suggest the logical next command based on workflow phase:
@@ -593,10 +625,13 @@ Suggest the logical next command based on workflow phase:
593
625
  Format the footer as:
594
626
  ```
595
627
  ---
596
- Status : {badge}
628
+ Status : {badge}
597
629
  {Output Artifacts block}
598
- Next : {suggested command with example arguments}
630
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
631
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
632
+ Next : {suggested command with example arguments}
599
633
  ```
634
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
600
635
 
601
636
 
602
637
  ```