@anhth2/spec-driven-dev-plugin 0.7.0 → 0.9.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 (96) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/bin/index.js +105 -0
  3. package/commands/debug.md +189 -1
  4. package/commands/debug.tmpl +16 -0
  5. package/commands/define-product.md +94 -1
  6. package/commands/fix-bug.md +190 -1
  7. package/commands/fix-bug.tmpl +17 -0
  8. package/commands/generate-bdd.md +314 -14
  9. package/commands/generate-bdd.tmpl +220 -13
  10. package/commands/generate-code.md +191 -3
  11. package/commands/generate-code.tmpl +97 -2
  12. package/commands/generate-design-spec.md +811 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +133 -1
  15. package/commands/generate-prd.tmpl +39 -0
  16. package/commands/generate-spec-manifest.md +576 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +116 -2
  19. package/commands/generate-tech-docs.tmpl +22 -1
  20. package/commands/generate-tests.md +94 -1
  21. package/commands/learn.md +554 -0
  22. package/commands/learn.tmpl +63 -0
  23. package/commands/propose-scenario.md +521 -0
  24. package/commands/propose-scenario.tmpl +109 -0
  25. package/commands/refine-prd.md +94 -1
  26. package/commands/report-bug.md +543 -0
  27. package/commands/report-bug.tmpl +131 -0
  28. package/commands/review-code.md +190 -1
  29. package/commands/review-code.tmpl +17 -0
  30. package/commands/review-context.md +134 -1
  31. package/commands/review-context.tmpl +40 -0
  32. package/commands/review-tech-docs.md +176 -5
  33. package/commands/review-tech-docs.tmpl +82 -4
  34. package/commands/run-tests.md +119 -1
  35. package/commands/run-tests.tmpl +25 -0
  36. package/commands/setup-ai-first.md +142 -4
  37. package/commands/setup-ai-first.tmpl +135 -3
  38. package/commands/smoke-test.md +94 -1
  39. package/commands/sync.md +405 -0
  40. package/commands/sync.tmpl +345 -0
  41. package/commands/update-framework.md +211 -0
  42. package/commands/update-framework.tmpl +151 -0
  43. package/commands/validate-traces.md +152 -3
  44. package/commands/validate-traces.tmpl +58 -2
  45. package/core/FRAMEWORK_VERSION +1 -1
  46. package/core/commands/debug.md +189 -1
  47. package/core/commands/define-product.md +94 -1
  48. package/core/commands/fix-bug.md +190 -1
  49. package/core/commands/generate-bdd.md +314 -14
  50. package/core/commands/generate-code.md +191 -3
  51. package/core/commands/generate-design-spec.md +811 -0
  52. package/core/commands/generate-prd.md +133 -1
  53. package/core/commands/generate-spec-manifest.md +576 -0
  54. package/core/commands/generate-tech-docs.md +116 -2
  55. package/core/commands/generate-tests.md +94 -1
  56. package/core/commands/learn.md +554 -0
  57. package/core/commands/propose-scenario.md +521 -0
  58. package/core/commands/refine-prd.md +94 -1
  59. package/core/commands/report-bug.md +543 -0
  60. package/core/commands/review-code.md +190 -1
  61. package/core/commands/review-context.md +134 -1
  62. package/core/commands/review-tech-docs.md +176 -5
  63. package/core/commands/run-tests.md +119 -1
  64. package/core/commands/setup-ai-first.md +142 -4
  65. package/core/commands/smoke-test.md +94 -1
  66. package/core/commands/sync.md +405 -0
  67. package/core/commands/update-framework.md +211 -0
  68. package/core/commands/validate-traces.md +152 -3
  69. package/core/skills/code/SKILL.md +101 -2
  70. package/core/skills/debug/SKILL.md +108 -3
  71. package/core/skills/design-spec/SKILL.md +507 -0
  72. package/core/skills/discovery/SKILL.md +94 -1
  73. package/core/skills/prd/SKILL.md +14 -2
  74. package/core/skills/setup-ai-first/SKILL.md +7 -1
  75. package/core/skills/spec/SKILL.md +14 -2
  76. package/core/skills/test/SKILL.md +195 -3
  77. package/core/steps/capture-lesson.md +79 -0
  78. package/core/steps/context-loader.md +87 -0
  79. package/core/steps/report-footer.md +7 -1
  80. package/core/templates/design-spec.template.md +209 -0
  81. package/core/templates/project-context.yaml +40 -0
  82. package/package.json +1 -1
  83. package/skills/code/SKILL.md +101 -2
  84. package/skills/debug/SKILL.md +108 -3
  85. package/skills/design-spec/SKILL.md +507 -0
  86. package/skills/design-spec/SKILL.tmpl +95 -0
  87. package/skills/discovery/SKILL.md +94 -1
  88. package/skills/prd/SKILL.md +14 -2
  89. package/skills/setup-ai-first/SKILL.md +7 -1
  90. package/skills/spec/SKILL.md +14 -2
  91. package/skills/test/SKILL.md +195 -3
  92. package/steps/capture-lesson.md +79 -0
  93. package/steps/context-loader.md +87 -0
  94. package/steps/report-footer.md +7 -1
  95. package/templates/design-spec.template.md +209 -0
  96. package/templates/project-context.yaml +40 -0
@@ -0,0 +1,211 @@
1
+ # /update-framework — Update the Spec-Driven Dev Framework
2
+
3
+ Upgrades the **framework tooling** (`.agent/commands/`, `steps/`, `modules/`, `hooks/`, `rules/`, `templates/`, `skills/`) to the latest published version from npm.
4
+
5
+ > **Not the same as `/sync`.**
6
+ > - `/sync` → pulls **project content** (submodule code/specs) + refreshes Living Docs. Run daily.
7
+ > - `/update-framework` → upgrades the **framework command files themselves**. Run occasionally, when a new framework version ships.
8
+
9
+ This command wraps `npx @anhth2/spec-driven-dev-plugin@latest --init`. It requires network + npm access.
10
+
11
+ ---
12
+
13
+ ## Step 0 — Detect Current State
14
+
15
+ 1. Read `.agent/FRAMEWORK_VERSION` → current installed version.
16
+ - If missing → this project was not installed via `--init`. Stop:
17
+ ```
18
+ ❌ .agent/FRAMEWORK_VERSION not found.
19
+ This project was not set up with the framework installer.
20
+ Run: npx @anhth2/spec-driven-dev-plugin --init
21
+ ```
22
+
23
+ 2. Read `.agent/project-context.yaml` → extract `setup.mode` (`umbrella` / absent = single) and `services`.
24
+
25
+ 3. List `.agent/modules/` → record installed module names (these must be re-passed on upgrade so they update too).
26
+
27
+ Print:
28
+ ```
29
+ Current framework : v{current}
30
+ Mode : {umbrella | single-service}
31
+ Installed modules : {list or "none"}
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Step 1 — Check Latest Version
37
+
38
+ Run:
39
+ ```bash
40
+ npm view @anhth2/spec-driven-dev-plugin version
41
+ ```
42
+
43
+ Compare `current` vs `latest`:
44
+
45
+ | Result | Action |
46
+ |--------|--------|
47
+ | Network/registry unreachable | Warn `⚠️ Could not reach npm registry — check connection.` and stop |
48
+ | `current == latest` | Print `✅ Already up to date (v{current}). Nothing to do.` and stop |
49
+ | `latest > current` | Print `Update available: v{current} → v{latest}` and continue |
50
+
51
+ Ask: `Proceed with upgrade? (Y/N)` — wait for `Y`.
52
+
53
+ ---
54
+
55
+ ## Step 2 — Umbrella Awareness *(umbrella mode only)*
56
+
57
+ If `setup.mode == umbrella`, print this note before upgrading:
58
+
59
+ ```
60
+ ℹ️ Umbrella mode — framework tooling lives ONLY at this umbrella root.
61
+ Service submodules contain just .agent/project-context.yaml (config), not
62
+ command files — they read commands from the umbrella root. No per-service
63
+ framework update is needed here.
64
+
65
+ Exception: if a teammate opens Claude Code directly INSIDE a service repo
66
+ (outside the umbrella), that repo has its own .agent/ — its owning team runs
67
+ /update-framework there independently.
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Step 3 — Pre-flight Git Check
73
+
74
+ Run `git status --short .agent/ .claude/commands/`.
75
+
76
+ If there are uncommitted changes in those paths:
77
+ ```
78
+ ⚠️ Uncommitted changes in .agent/ or .claude/commands/.
79
+ The upgrade overwrites framework files. Commit or stash first so you can
80
+ cleanly review the upgrade diff:
81
+ git add .agent/ .claude/commands/ && git commit -m "wip" (or git stash)
82
+ ```
83
+ Ask whether to continue anyway `(Y/N)`. Default to stopping.
84
+
85
+ ---
86
+
87
+ ## Step 4 — Run the Upgrade
88
+
89
+ Build the module flags from Step 0 (one `--module {name}` per installed module), then run:
90
+
91
+ ```bash
92
+ npx -y @anhth2/spec-driven-dev-plugin@latest --init {--module X ...}
93
+ ```
94
+
95
+ This **overwrites** (refreshes to the new version):
96
+ - `.agent/commands/`, `.agent/steps/`, `.agent/hooks/`, `.agent/rules/`, `.agent/templates/`, `.agent/skills/`, `.agent/modules/{installed}/`
97
+ - `.agent/FRAMEWORK_VERSION`
98
+ - `.claude/commands/` shortcuts
99
+
100
+ This **does NOT touch** (your content is safe):
101
+ - `.agent/project-context.yaml`
102
+ - `CLAUDE.md`
103
+ - `specs/domain-knowledge/` (business-dictionary, core-entities)
104
+ - `.trace/`
105
+
106
+ If the npx command exits non-zero → print the error and stop with `❌`.
107
+
108
+ ---
109
+
110
+ ## Step 5 — Review Changes
111
+
112
+ Run:
113
+ ```bash
114
+ git diff --stat .agent/ .claude/commands/
115
+ ```
116
+
117
+ Summarize for the user:
118
+ - **New commands** — `.md` files present now but not before
119
+ - **Updated commands** — files with changed content
120
+ - **Removed commands** — files deleted in the new version
121
+
122
+ If a new command appeared (e.g. a new slash command), call it out explicitly so the user knows it is now available.
123
+
124
+ ---
125
+
126
+ ## Output
127
+
128
+ # Report Footer — Standard Command Output Format
129
+
130
+ Every command report must end with this standard footer section.
131
+
132
+ ## Status Badge
133
+
134
+ Choose one based on outcome:
135
+ - `✅ Complete` — all steps succeeded, no issues found
136
+ - `❌ Failed` — command could not complete due to a blocking error
137
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
138
+
139
+ ## Output Artifacts
140
+
141
+ List every file created or modified by this command:
142
+ ```
143
+ Output Artifacts:
144
+ {created|updated} {file-path} ({brief description})
145
+ {created|updated} {file-path} ({brief description})
146
+ ```
147
+
148
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
149
+
150
+ ## Next Command Suggestion
151
+
152
+ Suggest the logical next command based on workflow phase:
153
+
154
+ | Current command | Suggest next |
155
+ |-------------------------|-----------------------------------------------|
156
+ | /setup-ai-first | `/define-product` to start your first feature |
157
+ | /define-product | `/generate-prd {product-definition-file}` |
158
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
159
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
160
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
161
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
162
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
163
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
164
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
165
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
166
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
167
+ | /generate-tests | `/run-tests {UC-ID}` |
168
+ | /run-tests (passing) | `/review-code {UC-ID}` |
169
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
170
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
171
+ | /smoke-test | Create PR and link to ticket |
172
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
173
+ | /fix-bug | Create PR and link to ticket |
174
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
175
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
176
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
177
+ | /learn | Continue working — lesson applies on next command |
178
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
179
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
180
+
181
+ Format the footer as:
182
+ ```
183
+ ---
184
+ Status : {badge}
185
+ {Output Artifacts block}
186
+ Next : {suggested command with example arguments}
187
+ ```
188
+
189
+
190
+ ```
191
+ /update-framework — v{current} → v{latest}
192
+
193
+ ✅ Framework upgraded
194
+ Updated : {N} command files, {M} step files
195
+ New : {list any new commands, e.g. /some-new-command}
196
+ Removed : {list any removed commands, or "none"}
197
+
198
+ Your content was preserved:
199
+ project-context.yaml, CLAUDE.md, domain-knowledge/, .trace/ — untouched
200
+
201
+ Review & commit:
202
+ git diff .agent/
203
+ git add .agent/ .claude/commands/
204
+ git commit -m "chore: upgrade spec-driven-dev v{current} → v{latest}"
205
+ {umbrella mode: this is the umbrella root — service submodules need no framework update}
206
+
207
+ ---
208
+ Status : ✅ Complete | ⚠️ Warnings
209
+ Output Artifacts: refreshed .agent/ framework files, .claude/commands/ shortcuts
210
+ Next : review git diff, then commit | /sync to refresh project content
211
+ ```
@@ -133,6 +133,7 @@ Read `.agent/project-context.yaml`. Extract and store:
133
133
  - `paths.core_entities` → path to core-entities.md
134
134
  - `paths.tech_docs_dir` → technical documentation root
135
135
  - `paths.trace_dir` → trace state directory
136
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
136
137
 
137
138
  If `paths` section is absent, use these defaults:
138
139
  - `specs_dir` = `specs/bdd`
@@ -144,11 +145,75 @@ If `paths` section is absent, use these defaults:
144
145
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
145
146
  - `tech_docs_dir` = `specs/tech-docs`
146
147
  - `trace_dir` = `.trace`
148
+ - `design_spec_dir` = `specs/design-spec`
147
149
 
148
150
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
149
151
 
150
152
  ---
151
153
 
154
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
155
+
156
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
157
+
158
+ If `services` section is present:
159
+
160
+ **1. Detect active domain** (in priority order):
161
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
162
+ - Extract from target file path: segment immediately after `prd_dir` base path
163
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
164
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
165
+
166
+ **2. Route to service** — if active domain matches a key in `services`:
167
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
168
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
169
+ - Store `active_service` = `services.{domain}.path`
170
+ - Store `active_service_module` = `services.{domain}.module`
171
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
172
+
173
+ **3. Fallback** — if domain not detected or no matching service key:
174
+ - Keep default paths from Step 1
175
+ - Set `active_service = unresolved`
176
+
177
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
178
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
179
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
180
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
181
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
182
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
183
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
184
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
185
+
186
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
187
+
188
+ ---
189
+
190
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
191
+
192
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
193
+
194
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
195
+
196
+ **1. Locate service config** — try in priority order:
197
+ - `{active_service}/.agent/project-context.yaml`
198
+ - `{active_service}/project-context.yaml`
199
+
200
+ **2. If found, override with service-specific values:**
201
+
202
+ | Variable | Source |
203
+ |----------|--------|
204
+ | `conventions.test_command` | service's `conventions.test_command` |
205
+ | `conventions.build_command` | service's `conventions.build_command` |
206
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
207
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
208
+
209
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
210
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
211
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
212
+
213
+ **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).
214
+
215
+ ---
216
+
152
217
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
153
218
 
154
219
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -239,6 +304,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
239
304
 
240
305
  ---
241
306
 
307
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
308
+
309
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
310
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
311
+
312
+ Resolve the lessons file path:
313
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
314
+ - Else default `specs/domain-knowledge/lessons-learned.md`
315
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
316
+
317
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
318
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
319
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
320
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
321
+
322
+ If the file does not exist → skip silently (no lessons captured yet).
323
+
324
+ ---
325
+
242
326
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
243
327
 
244
328
  After loading all context, synthesize and output a compact summary block.
@@ -254,6 +338,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
254
338
  Ticket : {ticket_prefix}-
255
339
  Dict : {loaded — N canonical terms, M banned terms | missing}
256
340
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
341
+ Lessons : {loaded — N guardrails | none yet}
342
+ Service : {active_service} ({active_service_module}) | single-service
343
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
257
344
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
258
345
  ```
259
346
 
@@ -279,12 +366,33 @@ Proceed to the next step of the calling command.
279
366
 
280
367
  ## Process
281
368
 
369
+ ### Step 0 — Umbrella Mode Detection
370
+
371
+ Check whether `services` array exists in `project-context.yaml`.
372
+
373
+ **If `services` exists (umbrella mode):**
374
+ - Resolve the trace dir for each service:
375
+ - Use `services[N].trace_dir` if explicitly set
376
+ - Otherwise default to `{services[N].path}/.trace`
377
+ - Set `all_trace_dirs = [ dir1, dir2, ... ]` — one per service
378
+ - Set `umbrella_root_trace = ".trace"` (at umbrella workspace root)
379
+ - Step 1 will read TSVs from ALL dirs in `all_trace_dirs`, tagged by service name
380
+
381
+ **If no `services` key (single-service mode):**
382
+ - Set `all_trace_dirs = [ {paths.trace_dir} ]`
383
+ - No umbrella sync needed
384
+
385
+ ---
386
+
282
387
  ### Step 1 — Load TSV data
283
388
 
284
- Read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
389
+ **Umbrella mode:** read all `{trace_dir}/{UC-ID}.tsv` files from every dir in `all_trace_dirs`. For each TSV, tag its rows with the originating service name.
390
+
391
+ **Single-service mode:** read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
392
+
285
393
  Each file gives the persisted trace state for that UC.
286
394
 
287
- **If no `.tsv` files found** in `{paths.trace_dir}`:
395
+ **If no `.tsv` files found** in any of the trace dirs:
288
396
  - Scan all `{paths.specs_dir}/**/*.feature` files in the target domain to build an in-memory list of all scenarios.
289
397
  - Treat all scenarios as `UNTRACKED` (no code generated yet).
290
398
  - Print: "⚠️ No trace files found. All {N} scenarios across {M} UCs are UNTRACKED."
@@ -464,6 +572,36 @@ Schema:
464
572
  - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
465
573
  - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`
466
574
 
575
+ ### Step 8b — Umbrella Living Docs Sync *(umbrella mode only)*
576
+
577
+ *Skip this step in single-service mode.*
578
+
579
+ After writing each service's `trace-report.json`, sync trace files to the umbrella root so the Living Docs VS Code panel (opened at umbrella root) can read them:
580
+
581
+ 1. Create directory `{umbrella_root_trace}/` if it does not exist (`mkdir -p .trace`).
582
+
583
+ 2. **Copy TSV files** from each service trace dir to umbrella trace dir with service namespace:
584
+ ```
585
+ {service.path}/.trace/{UC-ID}.tsv → .trace/{service-name}/{UC-ID}.tsv
586
+ ```
587
+ Overwrite if exists. Do not delete files in `.trace/` that no longer have a service source — they may be from a previous run.
588
+
589
+ 3. **Write aggregated `trace-report.json`** to `{umbrella_root_trace}/trace-report.json`:
590
+ - Merge all per-service `trace-report.json` data into one document
591
+ - Add `"service"` field to each scenario row
592
+ - Recalculate summary aggregates across all services
593
+
594
+ 4. **Print sync summary:**
595
+ ```
596
+ Umbrella sync → .trace/
597
+ user-service : {N} TSV files copied
598
+ order-service : {N} TSV files copied
599
+ trace-report.json: merged ({total} scenarios across {S} services)
600
+ Living Docs panel will reflect this data immediately.
601
+ ```
602
+
603
+ > **Note:** `.trace/` at umbrella root is a **read-only mirror** — do NOT commit it to the umbrella repo. Add `.trace/` to the umbrella's `.gitignore`. Authoritative trace state lives in each service submodule's `.trace/` dir and is committed there.
604
+
467
605
  ## Output
468
606
 
469
607
  # Report Footer — Standard Command Output Format
@@ -498,7 +636,8 @@ Suggest the logical next command based on workflow phase:
498
636
  | /define-product | `/generate-prd {product-definition-file}` |
499
637
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
500
638
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
501
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
639
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
640
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
502
641
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
503
642
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
504
643
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -512,6 +651,11 @@ Suggest the logical next command based on workflow phase:
512
651
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
513
652
  | /fix-bug | Create PR and link to ticket |
514
653
  | /debug | `/fix-bug {ticket-id}` if fix needed |
654
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
655
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
656
+ | /learn | Continue working — lesson applies on next command |
657
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
658
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
515
659
 
516
660
  Format the footer as:
517
661
  ```
@@ -559,4 +703,9 @@ Recommendations:
559
703
  - /generate-code {UC-ID} for DRIFT and UNTRACKED scenarios
560
704
  - /generate-tests {UC-ID} for GAP (missing tests)
561
705
  - /generate-bdd {prd-file} for PRD version drift
706
+
707
+ [Umbrella mode only]
708
+ Living Docs synced → .trace/ (umbrella root)
709
+ Tip: run /validate-traces after each codegen session to refresh the panel.
710
+ .trace/ at umbrella root is a mirror — do not commit it (add to .gitignore).
562
711
  ```
@@ -158,6 +158,7 @@ Read `.agent/project-context.yaml`. Extract and store:
158
158
  - `paths.core_entities` → path to core-entities.md
159
159
  - `paths.tech_docs_dir` → technical documentation root
160
160
  - `paths.trace_dir` → trace state directory
161
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
161
162
 
162
163
  If `paths` section is absent, use these defaults:
163
164
  - `specs_dir` = `specs/bdd`
@@ -169,11 +170,75 @@ If `paths` section is absent, use these defaults:
169
170
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
170
171
  - `tech_docs_dir` = `specs/tech-docs`
171
172
  - `trace_dir` = `.trace`
173
+ - `design_spec_dir` = `specs/design-spec`
172
174
 
173
175
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
174
176
 
175
177
  ---
176
178
 
179
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
180
+
181
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
182
+
183
+ If `services` section is present:
184
+
185
+ **1. Detect active domain** (in priority order):
186
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
187
+ - Extract from target file path: segment immediately after `prd_dir` base path
188
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
189
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
190
+
191
+ **2. Route to service** — if active domain matches a key in `services`:
192
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
193
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
194
+ - Store `active_service` = `services.{domain}.path`
195
+ - Store `active_service_module` = `services.{domain}.module`
196
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
197
+
198
+ **3. Fallback** — if domain not detected or no matching service key:
199
+ - Keep default paths from Step 1
200
+ - Set `active_service = unresolved`
201
+
202
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
203
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
204
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
205
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
206
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
207
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
208
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
209
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
210
+
211
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
212
+
213
+ ---
214
+
215
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
216
+
217
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
218
+
219
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
220
+
221
+ **1. Locate service config** — try in priority order:
222
+ - `{active_service}/.agent/project-context.yaml`
223
+ - `{active_service}/project-context.yaml`
224
+
225
+ **2. If found, override with service-specific values:**
226
+
227
+ | Variable | Source |
228
+ |----------|--------|
229
+ | `conventions.test_command` | service's `conventions.test_command` |
230
+ | `conventions.build_command` | service's `conventions.build_command` |
231
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
232
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
233
+
234
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
235
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
236
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
237
+
238
+ **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).
239
+
240
+ ---
241
+
177
242
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
178
243
 
179
244
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -264,6 +329,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
264
329
 
265
330
  ---
266
331
 
332
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
333
+
334
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
335
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
336
+
337
+ Resolve the lessons file path:
338
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
339
+ - Else default `specs/domain-knowledge/lessons-learned.md`
340
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
341
+
342
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
343
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
344
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
345
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
346
+
347
+ If the file does not exist → skip silently (no lessons captured yet).
348
+
349
+ ---
350
+
267
351
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
268
352
 
269
353
  After loading all context, synthesize and output a compact summary block.
@@ -279,6 +363,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
279
363
  Ticket : {ticket_prefix}-
280
364
  Dict : {loaded — N canonical terms, M banned terms | missing}
281
365
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
366
+ Lessons : {loaded — N guardrails | none yet}
367
+ Service : {active_service} ({active_service_module}) | single-service
368
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
282
369
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
283
370
  ```
284
371
 
@@ -412,7 +499,8 @@ Suggest the logical next command based on workflow phase:
412
499
  | /define-product | `/generate-prd {product-definition-file}` |
413
500
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
414
501
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
415
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
502
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
503
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
416
504
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
417
505
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
418
506
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -426,6 +514,11 @@ Suggest the logical next command based on workflow phase:
426
514
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
427
515
  | /fix-bug | Create PR and link to ticket |
428
516
  | /debug | `/fix-bug {ticket-id}` if fix needed |
517
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
518
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
519
+ | /learn | Continue working — lesson applies on next command |
520
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
521
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
429
522
 
430
523
  Format the footer as:
431
524
  ```
@@ -524,7 +617,8 @@ Suggest the logical next command based on workflow phase:
524
617
  | /define-product | `/generate-prd {product-definition-file}` |
525
618
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
526
619
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
527
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
620
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
621
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
528
622
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
529
623
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
530
624
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -538,6 +632,11 @@ Suggest the logical next command based on workflow phase:
538
632
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
539
633
  | /fix-bug | Create PR and link to ticket |
540
634
  | /debug | `/fix-bug {ticket-id}` if fix needed |
635
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
636
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
637
+ | /learn | Continue working — lesson applies on next command |
638
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
639
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
541
640
 
542
641
  Format the footer as:
543
642
  ```