@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
@@ -47,9 +47,18 @@ Read `@trace.platform` from the feature file header.
47
47
  - If `web` or `app` → continue with phase logic below.
48
48
 
49
49
  **If `--phase=ui`:**
50
- Load System BDD for this UC: find `{specs_dir}/{domain}/system/{TICKET-ID}*.feature`.
51
- Extract all `Then` clauses collect implied response shapes and error states.
52
- If System BDD not found warn: "System BDD not found mock layer will use placeholder fixtures." Continue.
50
+ Resolve the **mock shape source** (hybrid prefer the real contract, fall back to System BDD):
51
+ - **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.
52
+ - **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:
53
+ ```
54
+ ⚠ BE contract not found — mock shape inferred from System BDD only.
55
+ System BDD describes behavior, not full request/response shape — the mock
56
+ may differ from the real API; expect adjustment at --phase=integration.
57
+ (Recommended: have BE publish {UC-ID}-tech-design.md first for an accurate mock.)
58
+ ```
59
+ - If System BDD is also missing → warn "System BDD not found — mock layer will use placeholder fixtures." Continue.
60
+
61
+ Store `mock_source` (`contract` | `system-bdd`) for the mock tags below.
53
62
 
54
63
  **Then run the Figma Dev Mode MCP Check below** before generating any UI — the Design
55
64
  Spec's frame links are the visual contract, and the local MCP reads them with far more
@@ -97,13 +106,18 @@ Code Connect mappings. Prefer Code-Connect-mapped components over inventing mark
97
106
  real token names, not hardcoded values.
98
107
 
99
108
  **If `--phase=integration`:**
100
- Read tech-doc `@trace.status` from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`.
109
+ Resolve the design that drives the adapter (two layers):
110
+ - **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).
111
+ - **BE API contract** (endpoint/shape source): `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`.
112
+
113
+ Read `@trace.status` of whichever drives the adapter (the FE doc if present, else the BE contract).
101
114
  If `draft` or `in-review` → warn:
102
115
  ```
103
- ⚠ Tech docs for {UC-ID} are {status}.
104
- BE may not have a stable API contract yet.
105
- Proceeding — ensure BE endpoint is deployed or confirm contract manually.
116
+ ⚠ Tech design for {UC-ID} ({platform}) is {status}.
117
+ Contract / adapter mapping may still change.
118
+ Proceeding — ensure BE endpoint is deployed or confirm the mapping manually.
106
119
  ```
120
+ 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."
107
121
  Locate existing mock adapter from `--phase=ui` run (search for `{UC-ID}MockApiAdapter` in `{paths.src_dir}/{domain}/`).
108
122
  If not found → warn: "Mock adapter not found — generating real API adapter from scratch using tech-doc contract."
109
123
 
@@ -200,30 +214,50 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
200
214
 
201
215
  > **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.
202
216
 
217
+ ### Test Selectors — emit stable element IDs *(FE/App UI only)*
218
+
219
+ *Applies when `platform` is `web`/`app` and generating UI (`--phase=ui`, or default FE/App mode). Skip for BE.*
220
+
221
+ Every **actionable** element (button, input, link, select, toggle, form-submit) MUST carry a **stable test-id** so QC locates it directly (no runtime scan):
222
+
223
+ 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.
224
+ 2. **Emit via the platform attribute** (from `@trace.testid_attr`, or by module):
225
+ - web (`react`/`nextjs`/`vue`/`angular`) → `data-testid="..."`
226
+ - React Native → `testID="..."`
227
+ - Flutter → `Key('...')` (+ `Semantics(identifier: '...')` where the action needs it)
228
+ - native iOS → `accessibilityIdentifier = "..."`
229
+ 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.
230
+ 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.
231
+
203
232
  ## Mock API Layer (`--phase=ui` only)
204
233
 
205
234
  *Skip this section entirely if `--phase` is not `ui`.*
206
235
 
207
- Using the System BDD `Then` clauses loaded in Phase Detection:
236
+ 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:
208
237
 
209
- 1. **Extract fixture data** per scenario success responses + error responses.
210
- 2. **Generate mock adapter** at `{paths.src_dir}/{domain}/{UC-ID}MockApiAdapter.{ext}`:
238
+ 1. **Define the port shape** `{UC-ID}ApiPort` (request/response DTOs + error codes):
239
+ - `mock_source = contract` → field names / types / error codes taken **verbatim from the BE contract** §2 (API Endpoints) / §3 (Data Model) — the real shape.
240
+ - `mock_source = system-bdd` → shape **inferred** from System BDD `Then` clauses (provisional — see warning above).
241
+ 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).
242
+ 3. **Generate mock adapter** at `{paths.src_dir}/{domain}/{UC-ID}MockApiAdapter.{ext}`:
211
243
  - Implements interface `{UC-ID}ApiPort` (same interface the real adapter will implement)
212
- - Each method returns fixture data matching the BDD `Then` clause
244
+ - Each method returns fixture data matching the BDD `Then` clause, in the port shape
213
245
  - Include both success and error states (map to error scenarios in BDD)
214
246
  - Traceability tags:
215
247
  ```
216
248
  @trace.mock_for={UC-ID}
249
+ @trace.mock_source={contract | system-bdd}
217
250
  @trace.system_bdd={paths.specs_dir}/{domain}/system/{UC-ID}*.feature
251
+ {@trace.be_contract={UC-ID}-tech-design.md # only when mock_source=contract}
218
252
  ```
219
- 3. **Wire into service/hook layer** via environment flag or DI:
253
+ 4. **Wire into service/hook layer** via environment flag or DI:
220
254
  ```
221
255
  const adapter = IS_MOCK ? new {UC-ID}MockApiAdapter() : new {UC-ID}ApiAdapter()
222
256
  ```
223
257
  - `IS_MOCK` defaults to `true` in development/test env until real adapter is generated.
224
258
 
225
- > Tester uses the mock adapter to test all FE scenarios without waiting for BE.
226
- > Mock fixture data is derived directly from System BDD — BDD is the source of truth.
259
+ > Tester uses the mock adapter to test all FE scenarios without waiting for BE to **deploy**.
260
+ > 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.
227
261
 
228
262
  ---
229
263
 
@@ -231,7 +265,7 @@ Using the System BDD `Then` clauses loaded in Phase Detection:
231
265
 
232
266
  *Skip this section entirely if `--phase` is not `integration`.*
233
267
 
234
- 1. **Read tech-doc API contract** from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` extract endpoints, request/response shapes, error codes.
268
+ 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.
235
269
  2. **Read existing mock adapter** interface (`{UC-ID}ApiPort`) from the `--phase=ui` output.
236
270
  3. **Generate real API adapter** at `{paths.src_dir}/{domain}/{UC-ID}ApiAdapter.{ext}`:
237
271
  - Implements the same `{UC-ID}ApiPort` interface as mock adapter
@@ -261,18 +295,19 @@ Using the System BDD `Then` clauses loaded in Phase Detection:
261
295
 
262
296
  ## Write Trace State
263
297
 
264
- Update `{paths.trace_dir}/{UC-ID}.tsv` — for each implemented scenario, find the existing row by `sc_id` and update only these columns:
298
+ 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.)*
265
299
 
266
300
  | Column | Value |
267
301
  |--------|-------|
268
302
  | `gen_ver` | copy `spec_ver` from the current `.tsv` row (= scenario version at time of codegen) |
269
303
  | `implemented_by` | `{ControllerClass}.{methodName}` |
270
304
  | `bdd_version` | `@trace.bdd_version` from `.feature` header |
271
- | `tech_doc_revision` | `@trace.revision` from tech-doc header, or `—` if no tech-doc |
305
+ | `tech_doc_revision` | `@trace.revision` from the **BE** contract `{UC-ID}-tech-design.md`, or `—` if none |
306
+ | `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 |
272
307
  | `fe_phase` | `ui` if `--phase=ui` \| `integrated` if `--phase=integration` \| `—` if no phase flag |
273
308
  | `last_updated` | today `YYYY-MM-DD` |
274
309
 
275
- 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.
310
+ 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.
276
311
  `status` is computed by `/validate-traces` — do not set here.
277
312
 
278
313
  ## Refresh Panel Mirror
@@ -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
 
@@ -841,6 +843,36 @@ Output Artifacts:
841
843
 
842
844
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
843
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
+
844
876
  ## Next Command Suggestion
845
877
 
846
878
  Suggest the logical next command based on workflow phase:
@@ -882,10 +914,13 @@ Suggest the logical next command based on workflow phase:
882
914
  Format the footer as:
883
915
  ```
884
916
  ---
885
- Status : {badge}
917
+ Status : {badge}
886
918
  {Output Artifacts block}
887
- 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}
888
922
  ```
923
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
889
924
 
890
925
 
891
926
  {If missing_frames is empty}:
@@ -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
 
@@ -644,6 +646,36 @@ Output Artifacts:
644
646
 
645
647
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
646
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
+
647
679
  ## Next Command Suggestion
648
680
 
649
681
  Suggest the logical next command based on workflow phase:
@@ -685,10 +717,13 @@ Suggest the logical next command based on workflow phase:
685
717
  Format the footer as:
686
718
  ```
687
719
  ---
688
- Status : {badge}
720
+ Status : {badge}
689
721
  {Output Artifacts block}
690
- 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}
691
725
  ```
726
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
692
727
 
693
728
 
694
729
  ```
@@ -171,7 +171,7 @@ If `services` section is present:
171
171
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
172
172
 
173
173
  **2. Route to service** — if active domain matches a key in `services`:
174
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
174
+ - 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.
175
175
  - 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.
176
176
  - Store `active_service` = `services.{domain}.path`
177
177
  - Store `active_service_module` = `services.{domain}.module`
@@ -182,6 +182,7 @@ If `services` section is present:
182
182
  - Set `active_service = unresolved`
183
183
 
184
184
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
185
+ - 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`.)*
185
186
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
186
187
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
187
188
  - 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.)*
@@ -191,8 +192,9 @@ If `services` section is present:
191
192
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
192
193
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
193
194
  - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
195
+ - 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`.)*
194
196
 
195
- > **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.
197
+ > **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.
196
198
 
197
199
  ---
198
200
 
@@ -212,12 +214,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
212
214
  |----------|--------|
213
215
  | `conventions.test_command` | service's `conventions.test_command` |
214
216
  | `conventions.build_command` | service's `conventions.build_command` |
215
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
216
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
217
+ | `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`). |
218
+ | `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. |
217
219
 
218
220
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
219
221
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
220
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
222
+ - **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/`).
221
223
 
222
224
  **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).
223
225
 
@@ -541,6 +543,36 @@ Output Artifacts:
541
543
 
542
544
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
543
545
 
546
+ ## Pipeline Position
547
+
548
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
549
+ so the user always sees where this command sits in the end-to-end flow:
550
+
551
+ ```
552
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
553
+ ```
554
+
555
+ Find the current command in this phase legend and mark **its** phase in the map above:
556
+
557
+ | Phase | Commands |
558
+ |-------|----------|
559
+ | Discovery | `/define-product` |
560
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
561
+ | Design Spec | `/generate-design-spec` |
562
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
563
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
564
+ | Code | `/generate-code` · `/review-code` |
565
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
566
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
567
+ | Trace Audit | `/validate-traces` |
568
+
569
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
570
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
571
+
572
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
573
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
574
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
575
+
544
576
  ## Next Command Suggestion
545
577
 
546
578
  Suggest the logical next command based on workflow phase:
@@ -582,10 +614,13 @@ Suggest the logical next command based on workflow phase:
582
614
  Format the footer as:
583
615
  ```
584
616
  ---
585
- Status : {badge}
617
+ Status : {badge}
586
618
  {Output Artifacts block}
587
- Next : {suggested command with example arguments}
619
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
620
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
621
+ Next : {suggested command with example arguments}
588
622
  ```
623
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
589
624
 
590
625
 
591
626
  ```