@anhth2/spec-driven-dev-plugin 0.11.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 (173) hide show
  1. package/commands/debug.md +47 -7
  2. package/commands/define-product.md +47 -7
  3. package/commands/dev-gen-test.md +65 -17
  4. package/commands/dev-run-test.md +66 -18
  5. package/commands/dev-run-test.tmpl +1 -1
  6. package/commands/dev-smoke-test.md +47 -7
  7. package/commands/fix-bug.md +83 -13
  8. package/commands/fix-bug.tmpl +36 -6
  9. package/commands/generate-bdd.md +74 -21
  10. package/commands/generate-bdd.tmpl +9 -4
  11. package/commands/generate-code.md +118 -35
  12. package/commands/generate-code.tmpl +53 -18
  13. package/commands/generate-design-spec.md +47 -7
  14. package/commands/generate-prd.md +47 -7
  15. package/commands/generate-spec-manifest.md +47 -7
  16. package/commands/generate-tech-docs.md +234 -20
  17. package/commands/generate-tech-docs.tmpl +187 -13
  18. package/commands/learn.md +47 -7
  19. package/commands/map-testids.md +564 -0
  20. package/commands/map-testids.tmpl +81 -0
  21. package/commands/propose-scenario.md +78 -18
  22. package/commands/propose-scenario.tmpl +31 -11
  23. package/commands/qc-analyze.md +67 -12
  24. package/commands/qc-analyze.tmpl +20 -5
  25. package/commands/qc-design-test.md +51 -10
  26. package/commands/qc-design-test.tmpl +4 -3
  27. package/commands/qc-plan.md +50 -10
  28. package/commands/qc-plan.tmpl +3 -3
  29. package/commands/qc-report.md +60 -8
  30. package/commands/qc-report.tmpl +13 -1
  31. package/commands/qc-review.md +49 -9
  32. package/commands/qc-review.tmpl +2 -2
  33. package/commands/qc-run-test.md +75 -20
  34. package/commands/qc-run-test.tmpl +10 -3
  35. package/commands/refine-prd.md +47 -7
  36. package/commands/report-bug.md +63 -9
  37. package/commands/report-bug.tmpl +16 -2
  38. package/commands/review-code.md +47 -7
  39. package/commands/review-context.md +47 -7
  40. package/commands/review-tech-docs.md +50 -9
  41. package/commands/review-tech-docs.tmpl +3 -2
  42. package/commands/setup-ai-first.md +37 -4
  43. package/commands/setup-ai-first.tmpl +2 -2
  44. package/commands/sync.md +47 -11
  45. package/commands/sync.tmpl +12 -9
  46. package/commands/update-framework.md +35 -2
  47. package/commands/validate-traces.md +98 -40
  48. package/commands/validate-traces.tmpl +51 -33
  49. package/core/FRAMEWORK_VERSION +1 -1
  50. package/core/commands/debug.md +47 -7
  51. package/core/commands/define-product.md +47 -7
  52. package/core/commands/dev-gen-test.md +65 -17
  53. package/core/commands/dev-run-test.md +66 -18
  54. package/core/commands/dev-smoke-test.md +47 -7
  55. package/core/commands/fix-bug.md +83 -13
  56. package/core/commands/generate-bdd.md +74 -21
  57. package/core/commands/generate-code.md +118 -35
  58. package/core/commands/generate-design-spec.md +47 -7
  59. package/core/commands/generate-prd.md +47 -7
  60. package/core/commands/generate-spec-manifest.md +47 -7
  61. package/core/commands/generate-tech-docs.md +234 -20
  62. package/core/commands/learn.md +47 -7
  63. package/core/commands/map-testids.md +564 -0
  64. package/core/commands/propose-scenario.md +78 -18
  65. package/core/commands/qc-analyze.md +67 -12
  66. package/core/commands/qc-design-test.md +51 -10
  67. package/core/commands/qc-plan.md +50 -10
  68. package/core/commands/qc-report.md +60 -8
  69. package/core/commands/qc-review.md +49 -9
  70. package/core/commands/qc-run-test.md +75 -20
  71. package/core/commands/refine-prd.md +47 -7
  72. package/core/commands/report-bug.md +63 -9
  73. package/core/commands/review-code.md +47 -7
  74. package/core/commands/review-context.md +47 -7
  75. package/core/commands/review-tech-docs.md +50 -9
  76. package/core/commands/setup-ai-first.md +37 -4
  77. package/core/commands/sync.md +47 -11
  78. package/core/commands/update-framework.md +35 -2
  79. package/core/commands/validate-traces.md +98 -40
  80. package/core/modules/qc-playwright/stack-profile.yaml +4 -3
  81. package/core/skills/code/SKILL.md +82 -9
  82. package/core/skills/debug/SKILL.md +117 -11
  83. package/core/skills/design-spec/SKILL.md +47 -7
  84. package/core/skills/discovery/SKILL.md +47 -7
  85. package/core/skills/prd/SKILL.md +70 -4
  86. package/core/skills/qc/qa-analyst/acceptance-criteria.md +5 -1
  87. package/core/skills/qc/qa-analyst/business-rules.md +6 -2
  88. package/core/skills/qc/qa-analyst/data-flow.md +6 -2
  89. package/core/skills/qc/qa-analyst/spec-breakdown.md +7 -3
  90. package/core/skills/qc/qa-designer/e2e/journey.md +1 -1
  91. package/core/skills/qc/qa-designer/exploratory/charter.md +2 -2
  92. package/core/skills/qc/qa-designer/exploratory/explore-to-functional.md +1 -1
  93. package/core/skills/qc/qa-designer/functional/api.md +1 -1
  94. package/core/skills/qc/qa-designer/functional/gui-feature.md +1 -1
  95. package/core/skills/qc/qa-designer/functional/gui-screen.md +1 -1
  96. package/core/skills/qc/qa-designer/integration/api.md +1 -1
  97. package/core/skills/qc/qa-designer/integration/db.md +1 -1
  98. package/core/skills/qc/qa-designer/integration/gui.md +1 -1
  99. package/core/skills/qc/qa-designer/integration/kafka.md +1 -1
  100. package/core/skills/qc/qa-designer/non-functional.md +1 -1
  101. package/core/skills/qc/qa-planner/test-plan.md +4 -4
  102. package/core/skills/qc/qa-runner/exploratory/session.md +2 -2
  103. package/core/skills/setup-ai-first/SKILL.md +35 -2
  104. package/core/skills/spec/SKILL.md +70 -4
  105. package/core/skills/test/SKILL.md +129 -16
  106. package/core/steps/context-loader.md +12 -5
  107. package/core/steps/report-footer.md +35 -2
  108. package/core/steps/trace-mirror.md +18 -10
  109. package/core/templates/project-context.yaml +27 -6
  110. package/docs/01-getting-started/core-concepts.md +7 -7
  111. package/docs/01-getting-started/installation.md +4 -2
  112. package/docs/01-getting-started/quickstart.md +1 -1
  113. package/docs/02-guides/README.md +1 -2
  114. package/docs/02-guides/developer/README.md +1 -1
  115. package/docs/02-guides/developer/bdd-and-trace.md +10 -8
  116. package/docs/02-guides/developer/commands.md +4 -4
  117. package/docs/02-guides/developer/scenarios.md +26 -14
  118. package/docs/02-guides/developer/workflow.md +81 -19
  119. package/docs/02-guides/product-owner/README.md +6 -4
  120. package/docs/02-guides/product-owner/commands.md +1 -1
  121. package/docs/02-guides/product-owner/scenarios.md +80 -1
  122. package/docs/02-guides/tester/README.md +13 -10
  123. package/docs/02-guides/tester/bug-reporting.md +2 -2
  124. package/docs/02-guides/tester/qc-automation.md +165 -0
  125. package/docs/02-guides/tester/reading-specs.md +4 -4
  126. package/docs/02-guides/tester/scenarios.md +5 -5
  127. package/docs/02-guides/tester/spec-manifest.md +17 -12
  128. package/docs/02-guides/tester/test-checklist.md +3 -3
  129. package/docs/02-guides/tester/workflow.md +12 -14
  130. package/docs/03-concepts/architecture.md +7 -4
  131. package/docs/03-concepts/pipeline.md +37 -12
  132. package/docs/03-concepts/traceability.md +19 -18
  133. package/docs/04-operations/README.md +1 -1
  134. package/docs/04-operations/bug-flow.md +46 -5
  135. package/docs/04-operations/sync-and-update.md +186 -24
  136. package/docs/05-reference/README.md +3 -0
  137. package/docs/05-reference/command-cheatsheet.md +147 -0
  138. package/docs/05-reference/commands.md +73 -70
  139. package/docs/05-reference/modules.md +4 -4
  140. package/docs/05-reference/trace-schema.md +23 -16
  141. package/docs/README.md +3 -5
  142. package/modules/qc-playwright/stack-profile.yaml +4 -3
  143. package/package.json +1 -1
  144. package/skills/code/SKILL.md +82 -9
  145. package/skills/debug/SKILL.md +117 -11
  146. package/skills/design-spec/SKILL.md +47 -7
  147. package/skills/discovery/SKILL.md +47 -7
  148. package/skills/prd/SKILL.md +70 -4
  149. package/skills/qc/qa-analyst/acceptance-criteria.md +5 -1
  150. package/skills/qc/qa-analyst/business-rules.md +6 -2
  151. package/skills/qc/qa-analyst/data-flow.md +6 -2
  152. package/skills/qc/qa-analyst/spec-breakdown.md +7 -3
  153. package/skills/qc/qa-designer/e2e/journey.md +1 -1
  154. package/skills/qc/qa-designer/exploratory/charter.md +2 -2
  155. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +1 -1
  156. package/skills/qc/qa-designer/functional/api.md +1 -1
  157. package/skills/qc/qa-designer/functional/gui-feature.md +1 -1
  158. package/skills/qc/qa-designer/functional/gui-screen.md +1 -1
  159. package/skills/qc/qa-designer/integration/api.md +1 -1
  160. package/skills/qc/qa-designer/integration/db.md +1 -1
  161. package/skills/qc/qa-designer/integration/gui.md +1 -1
  162. package/skills/qc/qa-designer/integration/kafka.md +1 -1
  163. package/skills/qc/qa-designer/non-functional.md +1 -1
  164. package/skills/qc/qa-planner/test-plan.md +4 -4
  165. package/skills/qc/qa-runner/exploratory/session.md +2 -2
  166. package/skills/setup-ai-first/SKILL.md +35 -2
  167. package/skills/spec/SKILL.md +70 -4
  168. package/skills/test/SKILL.md +129 -16
  169. package/steps/context-loader.md +12 -5
  170. package/steps/report-footer.md +35 -2
  171. package/steps/trace-mirror.md +18 -10
  172. package/templates/project-context.yaml +27 -6
  173. package/docs/02-guides/qc-automation.md +0 -92
@@ -125,6 +125,8 @@ Read `.agent/project-context.yaml`. Extract and store:
125
125
  - `paths.specs_dir` → BDD specs root
126
126
  - `paths.prd_dir` → PRD documents root
127
127
  - `paths.refinement_dir` → findings/review output dir
128
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
129
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
128
130
  - `paths.product_definitions_dir` → product definitions root
129
131
  - `paths.domain_knowledge_dir` → domain knowledge root
130
132
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -137,6 +139,8 @@ If `paths` section is absent, use these defaults:
137
139
  - `specs_dir` = `specs/bdd`
138
140
  - `prd_dir` = `specs/prd`
139
141
  - `refinement_dir` = `.agent/review`
142
+ - `qc_dir` = `docs`
143
+ - `qc_skills_dir` = `.agent/skills/qc`
140
144
  - `product_definitions_dir` = `specs/product-definition`
141
145
  - `domain_knowledge_dir` = `specs/domain-knowledge`
142
146
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -162,7 +166,7 @@ If `services` section is present:
162
166
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
167
 
164
168
  **2. Route to service** — if active domain matches a key in `services`:
165
- - 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.
166
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.
167
171
  - Store `active_service` = `services.{domain}.path`
168
172
  - Store `active_service_module` = `services.{domain}.module`
@@ -173,6 +177,7 @@ If `services` section is present:
173
177
  - Set `active_service = unresolved`
174
178
 
175
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`.)*
176
181
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
182
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
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.)*
@@ -181,8 +186,10 @@ If `services` section is present:
181
186
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
182
187
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
183
188
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
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`.)*
184
191
 
185
- > **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.
186
193
 
187
194
  ---
188
195
 
@@ -202,12 +209,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
202
209
  |----------|--------|
203
210
  | `conventions.test_command` | service's `conventions.test_command` |
204
211
  | `conventions.build_command` | service's `conventions.build_command` |
205
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
206
- | `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. |
207
214
 
208
215
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
209
216
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
210
- - 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/`).
211
218
 
212
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).
213
220
 
@@ -423,9 +430,18 @@ Read `@trace.platform` from the feature file header.
423
430
  - If `web` or `app` → continue with phase logic below.
424
431
 
425
432
  **If `--phase=ui`:**
426
- Load System BDD for this UC: find `{specs_dir}/{domain}/system/{TICKET-ID}*.feature`.
427
- Extract all `Then` clauses collect implied response shapes and error states.
428
- If System BDD not found warn: "System BDD not found mock layer will use placeholder fixtures." Continue.
433
+ Resolve the **mock shape source** (hybrid prefer the real contract, fall back to System BDD):
434
+ - **BE contract** `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` if it exists, the mock adapter's port/DTO **shape** (request/response fields, types, error codes) comes from here → `mock_source = contract`. Most accurate; no shape rework at integration.
435
+ - **System BDD** `{specs_dir}/{domain}/system/{TICKET-ID}*.feature` always load `Then` clauses for **behavior + fixture values**. If no BE contract, the shape is inferred from these too → `mock_source = system-bdd`, and WARN:
436
+ ```
437
+ ⚠ BE contract not found — mock shape inferred from System BDD only.
438
+ System BDD describes behavior, not full request/response shape — the mock
439
+ may differ from the real API; expect adjustment at --phase=integration.
440
+ (Recommended: have BE publish {UC-ID}-tech-design.md first for an accurate mock.)
441
+ ```
442
+ - If System BDD is also missing → warn "System BDD not found — mock layer will use placeholder fixtures." Continue.
443
+
444
+ Store `mock_source` (`contract` | `system-bdd`) for the mock tags below.
429
445
 
430
446
  **Then run the Figma Dev Mode MCP Check below** before generating any UI — the Design
431
447
  Spec's frame links are the visual contract, and the local MCP reads them with far more
@@ -473,13 +489,18 @@ Code Connect mappings. Prefer Code-Connect-mapped components over inventing mark
473
489
  real token names, not hardcoded values.
474
490
 
475
491
  **If `--phase=integration`:**
476
- Read tech-doc `@trace.status` from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`.
492
+ Resolve the design that drives the adapter (two layers):
493
+ - **FE tech-design** (preferred — the port→endpoint→DTO mapping): `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` §4, produced by `/generate-tech-docs` (FE path).
494
+ - **BE API contract** (endpoint/shape source): `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`.
495
+
496
+ Read `@trace.status` of whichever drives the adapter (the FE doc if present, else the BE contract).
477
497
  If `draft` or `in-review` → warn:
478
498
  ```
479
- ⚠ Tech docs for {UC-ID} are {status}.
480
- BE may not have a stable API contract yet.
481
- Proceeding — ensure BE endpoint is deployed or confirm contract manually.
499
+ ⚠ Tech design for {UC-ID} ({platform}) is {status}.
500
+ Contract / adapter mapping may still change.
501
+ Proceeding — ensure BE endpoint is deployed or confirm the mapping manually.
482
502
  ```
503
+ If the FE tech-design is **missing** → warn: "No FE tech-design found — falling back to the BE contract directly (adapter mapping inferred). Recommended: run `/generate-tech-docs {web|app .feature}` first."
483
504
  Locate existing mock adapter from `--phase=ui` run (search for `{UC-ID}MockApiAdapter` in `{paths.src_dir}/{domain}/`).
484
505
  If not found → warn: "Mock adapter not found — generating real API adapter from scratch using tech-doc contract."
485
506
 
@@ -576,30 +597,50 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
576
597
 
577
598
  > **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.
578
599
 
600
+ ### Test Selectors — emit stable element IDs *(FE/App UI only)*
601
+
602
+ *Applies when `platform` is `web`/`app` and generating UI (`--phase=ui`, or default FE/App mode). Skip for BE.*
603
+
604
+ Every **actionable** element (button, input, link, select, toggle, form-submit) MUST carry a **stable test-id** so QC locates it directly (no runtime scan):
605
+
606
+ 1. **Source the id.** If the FE tech-design `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` exists, take ids **verbatim** from its §2b Test Selectors table (the contract). If it does not exist yet (e.g. `--phase=ui` before the FE tech-design), **generate ids by the convention** `{uc-lower}-{screen}-{element}-{type}` (e.g. `ft001-login-submit-btn`) so QC still has stable handles — they will be reconciled to the tech-design's §2b at integration.
607
+ 2. **Emit via the platform attribute** (from `@trace.testid_attr`, or by module):
608
+ - web (`react`/`nextjs`/`vue`/`angular`) → `data-testid="..."`
609
+ - React Native → `testID="..."`
610
+ - Flutter → `Key('...')` (+ `Semantics(identifier: '...')` where the action needs it)
611
+ - native iOS → `accessibilityIdentifier = "..."`
612
+ 3. Only actionable elements; do not spam ids on static text. Keep ids identical to the tech-design map so QC Page Objects match on the first try.
613
+ 4. **Reused catalog component?** Pass the id via its **forwarding prop** (see the catalog `## Test-ID Forwarding` section — e.g. `<Button testId="ft001-login-submit-btn">`), not a raw attribute. If the component does not forward a test-id, or you are backfilling **existing/brownfield** screens (not freshly generated here), that is `/map-testids {UC-ID}`'s job — run it instead of editing shared components inline.
614
+
579
615
  ## Mock API Layer (`--phase=ui` only)
580
616
 
581
617
  *Skip this section entirely if `--phase` is not `ui`.*
582
618
 
583
- Using the System BDD `Then` clauses loaded in Phase Detection:
619
+ Build the mock from the `mock_source` resolved in Phase Detection — **shape** from the BE contract when present, **fixture values + behavior** always from System BDD `Then` clauses:
584
620
 
585
- 1. **Extract fixture data** per scenario success responses + error responses.
586
- 2. **Generate mock adapter** at `{paths.src_dir}/{domain}/{UC-ID}MockApiAdapter.{ext}`:
621
+ 1. **Define the port shape** `{UC-ID}ApiPort` (request/response DTOs + error codes):
622
+ - `mock_source = contract` → field names / types / error codes taken **verbatim from the BE contract** §2 (API Endpoints) / §3 (Data Model) — the real shape.
623
+ - `mock_source = system-bdd` → shape **inferred** from System BDD `Then` clauses (provisional — see warning above).
624
+ 2. **Extract fixture data** per scenario from System BDD `Then` clauses — success + error responses (BDD is the source of truth for *values / behavior*, regardless of shape source).
625
+ 3. **Generate mock adapter** at `{paths.src_dir}/{domain}/{UC-ID}MockApiAdapter.{ext}`:
587
626
  - Implements interface `{UC-ID}ApiPort` (same interface the real adapter will implement)
588
- - Each method returns fixture data matching the BDD `Then` clause
627
+ - Each method returns fixture data matching the BDD `Then` clause, in the port shape
589
628
  - Include both success and error states (map to error scenarios in BDD)
590
629
  - Traceability tags:
591
630
  ```
592
631
  @trace.mock_for={UC-ID}
632
+ @trace.mock_source={contract | system-bdd}
593
633
  @trace.system_bdd={paths.specs_dir}/{domain}/system/{UC-ID}*.feature
634
+ {@trace.be_contract={UC-ID}-tech-design.md # only when mock_source=contract}
594
635
  ```
595
- 3. **Wire into service/hook layer** via environment flag or DI:
636
+ 4. **Wire into service/hook layer** via environment flag or DI:
596
637
  ```
597
638
  const adapter = IS_MOCK ? new {UC-ID}MockApiAdapter() : new {UC-ID}ApiAdapter()
598
639
  ```
599
640
  - `IS_MOCK` defaults to `true` in development/test env until real adapter is generated.
600
641
 
601
- > Tester uses the mock adapter to test all FE scenarios without waiting for BE.
602
- > Mock fixture data is derived directly from System BDD — BDD is the source of truth.
642
+ > Tester uses the mock adapter to test all FE scenarios without waiting for BE to **deploy**.
643
+ > Shape comes from the BE contract when available (accurate, no integration rework); else from System BDD (provisional adjust at `--phase=integration`). Fixture *values* always come from System BDD — BDD is the source of truth for behavior.
603
644
 
604
645
  ---
605
646
 
@@ -607,7 +648,7 @@ Using the System BDD `Then` clauses loaded in Phase Detection:
607
648
 
608
649
  *Skip this section entirely if `--phase` is not `integration`.*
609
650
 
610
- 1. **Read tech-doc API contract** from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` extract endpoints, request/response shapes, error codes.
651
+ 1. **Read the integration design.** Prefer the FE tech-design §4 (port→endpoint→DTO→error mapping) at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md`, using the BE API contract `{UC-ID}-tech-design.md` as the endpoint / request-response / error-code source. If no FE tech-design exists, extract endpoints + shapes + error codes directly from the BE contract.
611
652
  2. **Read existing mock adapter** interface (`{UC-ID}ApiPort`) from the `--phase=ui` output.
612
653
  3. **Generate real API adapter** at `{paths.src_dir}/{domain}/{UC-ID}ApiAdapter.{ext}`:
613
654
  - Implements the same `{UC-ID}ApiPort` interface as mock adapter
@@ -637,39 +678,48 @@ Using the System BDD `Then` clauses loaded in Phase Detection:
637
678
 
638
679
  ## Write Trace State
639
680
 
640
- Update `{paths.trace_dir}/{UC-ID}.tsv` — for each implemented scenario, find the existing row by `sc_id` and update only these columns:
681
+ Update `{paths.trace_dir}/{UC-ID}.tsv` — for each implemented scenario, find the existing row by `sc_id` and update only these columns. *(Umbrella + `spec_source`: `trace_dir` resolves to `{spec_source}/.trace` — this command runs from `service_root` but writes the trace row into the **spec repo** (cross-repo); commit/push the spec submodule for the trace update, alongside the 2-tier code push.)*
641
682
 
642
683
  | Column | Value |
643
684
  |--------|-------|
644
685
  | `gen_ver` | copy `spec_ver` from the current `.tsv` row (= scenario version at time of codegen) |
645
686
  | `implemented_by` | `{ControllerClass}.{methodName}` |
646
687
  | `bdd_version` | `@trace.bdd_version` from `.feature` header |
647
- | `tech_doc_revision` | `@trace.revision` from tech-doc header, or `—` if no tech-doc |
688
+ | `tech_doc_revision` | `@trace.revision` from the **BE** contract `{UC-ID}-tech-design.md`, or `—` if none |
689
+ | `fe_tech_doc_revision` | `@trace.revision` from the **FE** tech-design `{UC-ID}-tech-design-{platform}.md` when generating FE with `--phase=integration` (the doc whose §4 drove this adapter); `—` for BE, or for FE `--phase=ui` / no FE tech-design |
648
690
  | `fe_phase` | `ui` if `--phase=ui` \| `integrated` if `--phase=integration` \| `—` if no phase flag |
649
691
  | `last_updated` | today `YYYY-MM-DD` |
650
692
 
651
- Leave all other columns (`sc_title`, `spec_ver`, `prd_version`, `prd_status`, `uc_status`, `test_count`, `test_classes`, `dev_selftest`, `dev_selftest_at`, `qc_status`, `qc_run_at`) unchanged.
693
+ Leave all other columns (`sc_title`, `spec_ver`, `prd_version`, `prd_status`, `uc_status`, `test_count`, `test_classes`, `dev_selftest`, `dev_selftest_at`, `qc_status`, `qc_run_at`, `qc_owner`, `qc_blocked_by`) unchanged.
652
694
  `status` is computed by `/validate-traces` — do not set here.
653
695
 
654
696
  ## Refresh Panel Mirror
655
697
  # Refresh Living Docs panel mirror *(local, umbrella mode)*
656
698
 
657
699
  *Skip entirely in single-service mode (no `services` and no `setup.spec_source`) — there
658
- the service `.trace/` IS the panel location, so nothing to mirror.*
700
+ the repo's own `.trace/` IS the panel location, so nothing to mirror.*
659
701
 
660
- After updating the authoritative service TSV(s) at `{paths.trace_dir}`:
702
+ After updating the authoritative TSV(s) at `{paths.trace_dir}`:
661
703
 
662
- 1. Resolve `panel_mirror = ./.trace` at the **current workspace root** (where this command runs).
704
+ **When `setup.spec_source` is set (consolidated trace the common case):**
705
+ `{paths.trace_dir}` resolves to `{spec_source}/.trace` — the single authoritative location.
706
+ This command runs from `service_root`, so the write is **cross-repo into the spec submodule**;
707
+ commit/push the spec submodule for the trace update (same as `feedback/`).
708
+ 1. Resolve `panel_mirror = ./.trace` at the **current workspace root**.
663
709
  2. If `panel_mirror` resolves to a different path than `{paths.trace_dir}`, copy each
664
- just-updated `{UC-ID}.tsv` → `{panel_mirror}/{service-name}/{UC-ID}.tsv`
665
- (create the dir; overwrite). Use `active_service` for `{service-name}`.
710
+ just-updated `{UC-ID}.tsv` → `{panel_mirror}/{UC-ID}.tsv` (create the dir; overwrite).
711
+ No per-service namespacing — there is one trace set; the owning service is carried in each
712
+ row's `@trace.service`.
713
+
714
+ **Legacy (no `spec_source` — per-service trace):**
715
+ Copy each just-updated `{UC-ID}.tsv` → `{panel_mirror}/{service-name}/{UC-ID}.tsv`
716
+ (namespaced by `active_service`).
666
717
 
667
718
  This keeps the open workspace's Living Docs panel current **between syncs** — it is a
668
- **local convenience mirror only**. The *canonical* report in the spec module
669
- (`{spec_source}/.living-docs/`) and the merged `trace-report.json` are rebuilt by
670
- `/sync` or `/validate-traces` (those need every service's data, so a single per-UC
671
- command cannot produce them). For orchestrated commands, do this once in the orchestrator
672
- after all sub-agents return — not inside each sub-agent.
719
+ **local convenience mirror only**. The merged `trace-report.json` (canonical, in
720
+ `{spec_source}/.living-docs/`) is rebuilt by `/sync` or `/validate-traces`. For orchestrated
721
+ commands, do this once in the orchestrator after all sub-agents return — not inside each
722
+ sub-agent.
673
723
 
674
724
 
675
725
  ## Commit
@@ -702,6 +752,36 @@ Output Artifacts:
702
752
 
703
753
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
704
754
 
755
+ ## Pipeline Position
756
+
757
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
758
+ so the user always sees where this command sits in the end-to-end flow:
759
+
760
+ ```
761
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
762
+ ```
763
+
764
+ Find the current command in this phase legend and mark **its** phase in the map above:
765
+
766
+ | Phase | Commands |
767
+ |-------|----------|
768
+ | Discovery | `/define-product` |
769
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
770
+ | Design Spec | `/generate-design-spec` |
771
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
772
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
773
+ | Code | `/generate-code` · `/review-code` |
774
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
775
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
776
+ | Trace Audit | `/validate-traces` |
777
+
778
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
779
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
780
+
781
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
782
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
783
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
784
+
705
785
  ## Next Command Suggestion
706
786
 
707
787
  Suggest the logical next command based on workflow phase:
@@ -743,10 +823,13 @@ Suggest the logical next command based on workflow phase:
743
823
  Format the footer as:
744
824
  ```
745
825
  ---
746
- Status : {badge}
826
+ Status : {badge}
747
827
  {Output Artifacts block}
748
- Next : {suggested command with example arguments}
828
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
829
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
830
+ Next : {suggested command with example arguments}
749
831
  ```
832
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
750
833
 
751
834
 
752
835
  ```
@@ -125,6 +125,8 @@ Read `.agent/project-context.yaml`. Extract and store:
125
125
  - `paths.specs_dir` → BDD specs root
126
126
  - `paths.prd_dir` → PRD documents root
127
127
  - `paths.refinement_dir` → findings/review output dir
128
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
129
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
128
130
  - `paths.product_definitions_dir` → product definitions root
129
131
  - `paths.domain_knowledge_dir` → domain knowledge root
130
132
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -137,6 +139,8 @@ If `paths` section is absent, use these defaults:
137
139
  - `specs_dir` = `specs/bdd`
138
140
  - `prd_dir` = `specs/prd`
139
141
  - `refinement_dir` = `.agent/review`
142
+ - `qc_dir` = `docs`
143
+ - `qc_skills_dir` = `.agent/skills/qc`
140
144
  - `product_definitions_dir` = `specs/product-definition`
141
145
  - `domain_knowledge_dir` = `specs/domain-knowledge`
142
146
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -162,7 +166,7 @@ If `services` section is present:
162
166
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
167
 
164
168
  **2. Route to service** — if active domain matches a key in `services`:
165
- - 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.
166
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.
167
171
  - Store `active_service` = `services.{domain}.path`
168
172
  - Store `active_service_module` = `services.{domain}.module`
@@ -173,6 +177,7 @@ If `services` section is present:
173
177
  - Set `active_service = unresolved`
174
178
 
175
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`.)*
176
181
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
182
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
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.)*
@@ -181,8 +186,10 @@ If `services` section is present:
181
186
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
182
187
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
183
188
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
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`.)*
184
191
 
185
- > **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.
186
193
 
187
194
  ---
188
195
 
@@ -202,12 +209,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
202
209
  |----------|--------|
203
210
  | `conventions.test_command` | service's `conventions.test_command` |
204
211
  | `conventions.build_command` | service's `conventions.build_command` |
205
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
206
- | `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. |
207
214
 
208
215
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
209
216
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
210
- - 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/`).
211
218
 
212
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).
213
220
 
@@ -836,6 +843,36 @@ Output Artifacts:
836
843
 
837
844
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
838
845
 
846
+ ## Pipeline Position
847
+
848
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
849
+ so the user always sees where this command sits in the end-to-end flow:
850
+
851
+ ```
852
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
853
+ ```
854
+
855
+ Find the current command in this phase legend and mark **its** phase in the map above:
856
+
857
+ | Phase | Commands |
858
+ |-------|----------|
859
+ | Discovery | `/define-product` |
860
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
861
+ | Design Spec | `/generate-design-spec` |
862
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
863
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
864
+ | Code | `/generate-code` · `/review-code` |
865
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
866
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
867
+ | Trace Audit | `/validate-traces` |
868
+
869
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
870
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
871
+
872
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
873
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
874
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
875
+
839
876
  ## Next Command Suggestion
840
877
 
841
878
  Suggest the logical next command based on workflow phase:
@@ -877,10 +914,13 @@ Suggest the logical next command based on workflow phase:
877
914
  Format the footer as:
878
915
  ```
879
916
  ---
880
- Status : {badge}
917
+ Status : {badge}
881
918
  {Output Artifacts block}
882
- Next : {suggested command with example arguments}
919
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
920
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
921
+ Next : {suggested command with example arguments}
883
922
  ```
923
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
884
924
 
885
925
 
886
926
  {If missing_frames is empty}:
@@ -125,6 +125,8 @@ Read `.agent/project-context.yaml`. Extract and store:
125
125
  - `paths.specs_dir` → BDD specs root
126
126
  - `paths.prd_dir` → PRD documents root
127
127
  - `paths.refinement_dir` → findings/review output dir
128
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
129
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
128
130
  - `paths.product_definitions_dir` → product definitions root
129
131
  - `paths.domain_knowledge_dir` → domain knowledge root
130
132
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -137,6 +139,8 @@ If `paths` section is absent, use these defaults:
137
139
  - `specs_dir` = `specs/bdd`
138
140
  - `prd_dir` = `specs/prd`
139
141
  - `refinement_dir` = `.agent/review`
142
+ - `qc_dir` = `docs`
143
+ - `qc_skills_dir` = `.agent/skills/qc`
140
144
  - `product_definitions_dir` = `specs/product-definition`
141
145
  - `domain_knowledge_dir` = `specs/domain-knowledge`
142
146
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -162,7 +166,7 @@ If `services` section is present:
162
166
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
167
 
164
168
  **2. Route to service** — if active domain matches a key in `services`:
165
- - 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.
166
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.
167
171
  - Store `active_service` = `services.{domain}.path`
168
172
  - Store `active_service_module` = `services.{domain}.module`
@@ -173,6 +177,7 @@ If `services` section is present:
173
177
  - Set `active_service = unresolved`
174
178
 
175
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`.)*
176
181
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
182
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
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.)*
@@ -181,8 +186,10 @@ If `services` section is present:
181
186
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
182
187
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
183
188
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
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`.)*
184
191
 
185
- > **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.
186
193
 
187
194
  ---
188
195
 
@@ -202,12 +209,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
202
209
  |----------|--------|
203
210
  | `conventions.test_command` | service's `conventions.test_command` |
204
211
  | `conventions.build_command` | service's `conventions.build_command` |
205
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
206
- | `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. |
207
214
 
208
215
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
209
216
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
210
- - 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/`).
211
218
 
212
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).
213
220
 
@@ -639,6 +646,36 @@ Output Artifacts:
639
646
 
640
647
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
641
648
 
649
+ ## Pipeline Position
650
+
651
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
652
+ so the user always sees where this command sits in the end-to-end flow:
653
+
654
+ ```
655
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
656
+ ```
657
+
658
+ Find the current command in this phase legend and mark **its** phase in the map above:
659
+
660
+ | Phase | Commands |
661
+ |-------|----------|
662
+ | Discovery | `/define-product` |
663
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
664
+ | Design Spec | `/generate-design-spec` |
665
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
666
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
667
+ | Code | `/generate-code` · `/review-code` |
668
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
669
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
670
+ | Trace Audit | `/validate-traces` |
671
+
672
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
673
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
674
+
675
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
676
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
677
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
678
+
642
679
  ## Next Command Suggestion
643
680
 
644
681
  Suggest the logical next command based on workflow phase:
@@ -680,10 +717,13 @@ Suggest the logical next command based on workflow phase:
680
717
  Format the footer as:
681
718
  ```
682
719
  ---
683
- Status : {badge}
720
+ Status : {badge}
684
721
  {Output Artifacts block}
685
- Next : {suggested command with example arguments}
722
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
723
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
724
+ Next : {suggested command with example arguments}
686
725
  ```
726
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
687
727
 
688
728
 
689
729
  ```