@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.
- package/ARCHITECTURE.md +6 -2
- package/bin/index.js +105 -0
- package/commands/debug.md +189 -1
- package/commands/debug.tmpl +16 -0
- package/commands/define-product.md +94 -1
- package/commands/fix-bug.md +190 -1
- package/commands/fix-bug.tmpl +17 -0
- package/commands/generate-bdd.md +314 -14
- package/commands/generate-bdd.tmpl +220 -13
- package/commands/generate-code.md +191 -3
- package/commands/generate-code.tmpl +97 -2
- package/commands/generate-design-spec.md +811 -0
- package/commands/generate-design-spec.tmpl +399 -0
- package/commands/generate-prd.md +133 -1
- package/commands/generate-prd.tmpl +39 -0
- package/commands/generate-spec-manifest.md +576 -0
- package/commands/generate-spec-manifest.tmpl +164 -0
- package/commands/generate-tech-docs.md +116 -2
- package/commands/generate-tech-docs.tmpl +22 -1
- package/commands/generate-tests.md +94 -1
- package/commands/learn.md +554 -0
- package/commands/learn.tmpl +63 -0
- package/commands/propose-scenario.md +521 -0
- package/commands/propose-scenario.tmpl +109 -0
- package/commands/refine-prd.md +94 -1
- package/commands/report-bug.md +543 -0
- package/commands/report-bug.tmpl +131 -0
- package/commands/review-code.md +190 -1
- package/commands/review-code.tmpl +17 -0
- package/commands/review-context.md +134 -1
- package/commands/review-context.tmpl +40 -0
- package/commands/review-tech-docs.md +176 -5
- package/commands/review-tech-docs.tmpl +82 -4
- package/commands/run-tests.md +119 -1
- package/commands/run-tests.tmpl +25 -0
- package/commands/setup-ai-first.md +142 -4
- package/commands/setup-ai-first.tmpl +135 -3
- package/commands/smoke-test.md +94 -1
- package/commands/sync.md +405 -0
- package/commands/sync.tmpl +345 -0
- package/commands/update-framework.md +211 -0
- package/commands/update-framework.tmpl +151 -0
- package/commands/validate-traces.md +152 -3
- package/commands/validate-traces.tmpl +58 -2
- package/core/FRAMEWORK_VERSION +1 -1
- package/core/commands/debug.md +189 -1
- package/core/commands/define-product.md +94 -1
- package/core/commands/fix-bug.md +190 -1
- package/core/commands/generate-bdd.md +314 -14
- package/core/commands/generate-code.md +191 -3
- package/core/commands/generate-design-spec.md +811 -0
- package/core/commands/generate-prd.md +133 -1
- package/core/commands/generate-spec-manifest.md +576 -0
- package/core/commands/generate-tech-docs.md +116 -2
- package/core/commands/generate-tests.md +94 -1
- package/core/commands/learn.md +554 -0
- package/core/commands/propose-scenario.md +521 -0
- package/core/commands/refine-prd.md +94 -1
- package/core/commands/report-bug.md +543 -0
- package/core/commands/review-code.md +190 -1
- package/core/commands/review-context.md +134 -1
- package/core/commands/review-tech-docs.md +176 -5
- package/core/commands/run-tests.md +119 -1
- package/core/commands/setup-ai-first.md +142 -4
- package/core/commands/smoke-test.md +94 -1
- package/core/commands/sync.md +405 -0
- package/core/commands/update-framework.md +211 -0
- package/core/commands/validate-traces.md +152 -3
- package/core/skills/code/SKILL.md +101 -2
- package/core/skills/debug/SKILL.md +108 -3
- package/core/skills/design-spec/SKILL.md +507 -0
- package/core/skills/discovery/SKILL.md +94 -1
- package/core/skills/prd/SKILL.md +14 -2
- package/core/skills/setup-ai-first/SKILL.md +7 -1
- package/core/skills/spec/SKILL.md +14 -2
- package/core/skills/test/SKILL.md +195 -3
- package/core/steps/capture-lesson.md +79 -0
- package/core/steps/context-loader.md +87 -0
- package/core/steps/report-footer.md +7 -1
- package/core/templates/design-spec.template.md +209 -0
- package/core/templates/project-context.yaml +40 -0
- package/package.json +1 -1
- package/skills/code/SKILL.md +101 -2
- package/skills/debug/SKILL.md +108 -3
- package/skills/design-spec/SKILL.md +507 -0
- package/skills/design-spec/SKILL.tmpl +95 -0
- package/skills/discovery/SKILL.md +94 -1
- package/skills/prd/SKILL.md +14 -2
- package/skills/setup-ai-first/SKILL.md +7 -1
- package/skills/spec/SKILL.md +14 -2
- package/skills/test/SKILL.md +195 -3
- package/steps/capture-lesson.md +79 -0
- package/steps/context-loader.md +87 -0
- package/steps/report-footer.md +7 -1
- package/templates/design-spec.template.md +209 -0
- package/templates/project-context.yaml +40 -0
|
@@ -6,6 +6,194 @@
|
|
|
6
6
|
## Context
|
|
7
7
|
{{include:steps/context-loader.md}}
|
|
8
8
|
|
|
9
|
+
> **Tester proposals (optional input):** before generating, check `{paths.bdd_proposals_dir}/` (default `{spec_source}/feedback/bdd-proposals/`) for scenarios proposed by testers via `/propose-scenario` that map to this UC's ACs. Incorporate any the PO/Dev has accepted — then the tester's draft is removed/archived from `feedback/`. Skip if the folder is empty.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Repo Mode Detection
|
|
14
|
+
|
|
15
|
+
After loading context, determine which mode to operate in:
|
|
16
|
+
|
|
17
|
+
- **Spec repo mode**: `project-context.yaml` has NO `services` section OR `setup.mode: spec`
|
|
18
|
+
- **Umbrella mode**: `project-context.yaml` HAS `services` section AND `setup.mode: umbrella`
|
|
19
|
+
|
|
20
|
+
→ Spec repo mode → proceed to **Platform Selection** below (skip Service Detection)
|
|
21
|
+
→ Umbrella mode → proceed to **Service Detection** below (skip Platform Selection)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Platform Selection (Spec Repo Mode Only)
|
|
26
|
+
|
|
27
|
+
*Skip this section if running in umbrella mode.*
|
|
28
|
+
|
|
29
|
+
Ask the user to select the target platform:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Which platform is this BDD for?
|
|
33
|
+
1. web — FE/Web (React, Next.js, Angular, Vue, Nuxt)
|
|
34
|
+
2. app — Mobile (Flutter, React Native, iOS, Android)
|
|
35
|
+
3. system — System/BE BDD (synthesized from existing web + app BDDs)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Wait for user selection. Set `active_platform` = chosen value.
|
|
39
|
+
|
|
40
|
+
**Output path (spec repo mode):**
|
|
41
|
+
`{paths.specs_dir}/{domain}/{active_platform}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
42
|
+
|
|
43
|
+
**Platform vocabulary:**
|
|
44
|
+
|
|
45
|
+
| Platform | "user action" | "type/input" | "observe" | "navigate" |
|
|
46
|
+
|---|---|---|---|---|
|
|
47
|
+
| web | "clicks" | "types into" / "enters" | "sees" / "the page shows" | "navigates to" / "goes to" |
|
|
48
|
+
| app | "taps" | "enters" / "inputs" | "sees" / "the screen shows" | "navigates to" / "opens" |
|
|
49
|
+
| system | N/A — use business events | — | "the system returns" / "receives response" | — |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## System BDD Synthesis (active_platform = system)
|
|
54
|
+
|
|
55
|
+
*Only applies when platform = system. Skip for web and app.*
|
|
56
|
+
|
|
57
|
+
### Step S0 — Brownfield Check
|
|
58
|
+
|
|
59
|
+
Check the source PRD Metadata table for `| **API Source** | existing |`.
|
|
60
|
+
|
|
61
|
+
**Nếu `API Source: existing`:**
|
|
62
|
+
- API contract đã được PO ghi trong phần "Existing API Contract" của PRD.
|
|
63
|
+
- **Skip Steps S1–S3** — không cần scan FE/App BDD, không cần conflict resolution.
|
|
64
|
+
- Dùng bảng "Existing API Contract" trong PRD làm contract input cho Step S4.
|
|
65
|
+
- Set `# @trace.api_source: existing` trong header của file system BDD được gen.
|
|
66
|
+
|
|
67
|
+
**Nếu `API Source` không có hoặc không phải `existing`:**
|
|
68
|
+
- Tiếp tục Steps S1–S3 (normal synthesis flow).
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Step S1 — Scan available FE/App BDDs
|
|
73
|
+
|
|
74
|
+
Search for existing BDDs for this TICKET-ID:
|
|
75
|
+
- Web BDDs: `{paths.specs_dir}/{domain}/web/{TICKET-ID}-*.feature`
|
|
76
|
+
- App BDDs: `{paths.specs_dir}/{domain}/app/{TICKET-ID}-*.feature`
|
|
77
|
+
|
|
78
|
+
Classify the feature:
|
|
79
|
+
|
|
80
|
+
| Condition | Mode |
|
|
81
|
+
|---|---|
|
|
82
|
+
| Both web + app BDDs found | **Multi-platform** — synthesize from both |
|
|
83
|
+
| Only web BDD found | **Web-only** — synthesize from web |
|
|
84
|
+
| Only app BDD found | **App-only** — synthesize from app |
|
|
85
|
+
| No FE/App BDDs found | **Backend-only** — gen directly from PRD |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### Step S2 — Extract expected contracts per platform
|
|
90
|
+
|
|
91
|
+
For each found BDD file, extract:
|
|
92
|
+
- **Triggers**: what user actions call the backend? (map to logical "request" events)
|
|
93
|
+
- **Expected response data**: what fields/shape does each `Then` clause need from the system?
|
|
94
|
+
- **Error signals**: what error states must the backend signal?
|
|
95
|
+
- **Business rules**: what invariants does each platform assume the system enforces?
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### Step S3 — Cross-Platform Conflict Check (multi-platform mode only)
|
|
100
|
+
|
|
101
|
+
*Skip if web-only, app-only, or backend-only.*
|
|
102
|
+
|
|
103
|
+
Compare the extracted contracts across platforms. Flag a conflict if any of these differ:
|
|
104
|
+
|
|
105
|
+
| Conflict type | Example |
|
|
106
|
+
|---|---|
|
|
107
|
+
| **Response shape mismatch** | Web expects `{ token, redirect_url }`, App expects `{ token, user_profile }` |
|
|
108
|
+
| **Error semantics mismatch** | Web expects HTTP 423 for lock, App expects custom error code `ACC_LOCKED` |
|
|
109
|
+
| **Business rule contradiction** | Web BDD says "lock after 5 attempts", App BDD says "lock after 3 attempts" |
|
|
110
|
+
| **Data field conflict** | Web expects `expires_in: seconds`, App expects `expires_at: ISO timestamp` |
|
|
111
|
+
|
|
112
|
+
**If conflicts detected → CHECKPOINT (mandatory, cannot skip):**
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
⚠️ CROSS-PLATFORM CONTRACT CONFLICT
|
|
116
|
+
──────────────────────────────────────────────────────────────────
|
|
117
|
+
Feature : {TICKET-ID} — {UC name}
|
|
118
|
+
|
|
119
|
+
Conflict 1: Response shape mismatch
|
|
120
|
+
Web BDD (Then): user sees dashboard → implies { token, redirect_url }
|
|
121
|
+
App BDD (Then): app navigates to HomeScreen → implies { token, user_profile }
|
|
122
|
+
|
|
123
|
+
Resolution options:
|
|
124
|
+
A — Union response
|
|
125
|
+
BE returns all fields: { token, redirect_url, user_profile }
|
|
126
|
+
Clients ignore fields they don't use. Simple, slight over-fetch.
|
|
127
|
+
B — Platform hint in request
|
|
128
|
+
Client sends X-Platform: web|app in header, BE tailors response.
|
|
129
|
+
Cleaner responses, more BE logic.
|
|
130
|
+
C — Separate endpoints
|
|
131
|
+
POST /auth/login/web and POST /auth/login/app
|
|
132
|
+
Maximum flexibility, more endpoints to maintain.
|
|
133
|
+
D — Custom: describe your approach
|
|
134
|
+
──────────────────────────────────────────────────────────────────
|
|
135
|
+
Choose resolution for each conflict (A/B/C/D):
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Wait for PO's resolution per conflict. Record each decision as a `# @system.resolution:` annotation in the generated system BDD file.
|
|
139
|
+
|
|
140
|
+
**If no conflicts → proceed to Step S4 directly.**
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### Step S4 — Generate System BDD scenarios
|
|
145
|
+
|
|
146
|
+
Generate scenarios based on mode and resolved conflicts:
|
|
147
|
+
|
|
148
|
+
- **Multi-platform**: synthesize from both web + app contracts, applying resolved resolutions
|
|
149
|
+
- **Web-only / App-only**: derive from the single platform's contracts
|
|
150
|
+
- **Backend-only**: derive directly from PRD AC/BR using business event language (not HTTP)
|
|
151
|
+
|
|
152
|
+
System BDD step vocabulary (always use — regardless of FE/App vocabulary):
|
|
153
|
+
- Triggers: "the system receives {event}" / "a {actor} submits {action}"
|
|
154
|
+
- Assertions: "the system returns {data}" / "the system signals {error}" / "the system stores {state}"
|
|
155
|
+
- Do NOT use UI words (click, tap, see, navigate) in system BDD
|
|
156
|
+
|
|
157
|
+
**If multi-platform with resolution A (union):**
|
|
158
|
+
- System BDD shows the full response contract: all fields from all platforms
|
|
159
|
+
- Add comment: `# @system.resolution: union — clients receive all fields`
|
|
160
|
+
|
|
161
|
+
**If resolution B (platform hint):**
|
|
162
|
+
- Write separate `Scenario Outline` using Examples table for `web` vs `app` response variants
|
|
163
|
+
- Add comment: `# @system.resolution: platform-hint — X-Platform header determines response shape`
|
|
164
|
+
|
|
165
|
+
**If resolution C (separate endpoints):**
|
|
166
|
+
- Write separate Scenarios for each endpoint
|
|
167
|
+
- Note the endpoint split explicitly in the SCOPE section
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Service Detection (Umbrella Mode Only)
|
|
172
|
+
|
|
173
|
+
*Skip this section if running in spec repo mode.*
|
|
174
|
+
|
|
175
|
+
Read the PRD Metadata table for `| **Service** |` and `| **Module** |` rows.
|
|
176
|
+
|
|
177
|
+
| Condition | Action |
|
|
178
|
+
|---|---|
|
|
179
|
+
| PRD has `Service` row AND value is not "default" | Use it as `active_service` + `active_module`. Load catalog for that module. |
|
|
180
|
+
| PRD has no `Service` row AND `services` defined in project-context.yaml | Ask: "Which service is this BDD for?" (list services, wait for selection) |
|
|
181
|
+
| Single-service project (no `services` array) | `active_service = "default"`, `active_module = tech_stack.module` |
|
|
182
|
+
|
|
183
|
+
**Output path (umbrella mode):**
|
|
184
|
+
- `active_service = "default"` → `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
185
|
+
- `active_service ≠ "default"` → `{paths.specs_dir}/{domain}/{active_service}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
186
|
+
|
|
187
|
+
**Platform vocabulary** — adapt BDD step wording based on `active_module`:
|
|
188
|
+
|
|
189
|
+
| Platform type | Modules | "click" | "type" | "see" | "navigate" |
|
|
190
|
+
|---|---|---|---|---|---|
|
|
191
|
+
| Web | react, nextjs, vue, nuxt, angular | "clicks" | "types into" / "enters" | "sees" / "the page shows" | "navigates to" / "goes to" |
|
|
192
|
+
| Mobile | flutter, react-native, ios-swiftui, android-compose | "taps" | "enters" / "inputs" | "sees" / "the screen shows" | "navigates to" / "opens" |
|
|
193
|
+
| Backend / API | java-spring, golang, dotnet, php-laravel | *(no UI steps — use)* "submits a request" / "calls the API" | — | "receives response" / "the system returns" | — |
|
|
194
|
+
|
|
195
|
+
Apply this vocabulary silently when writing Gherkin steps. Do NOT mix web and mobile terms in the same feature file.
|
|
196
|
+
|
|
9
197
|
---
|
|
10
198
|
|
|
11
199
|
## Orchestration Check
|
|
@@ -42,7 +230,9 @@ After generating all `.feature` and `.tsv` files for the assigned UC, return the
|
|
|
42
230
|
|
|
43
231
|
Before generating, check for existing `.feature` files for this PRD:
|
|
44
232
|
|
|
45
|
-
1.
|
|
233
|
+
1. Resolve the search path based on mode:
|
|
234
|
+
- **Spec repo mode**: `{paths.specs_dir}/{domain}/{active_platform}/{TICKET-ID}-UC*.feature`
|
|
235
|
+
- **Umbrella mode**: `{paths.specs_dir}/{domain}/{TICKET-ID}-UC*.feature` (or with `{active_service}/` if multi-service)
|
|
46
236
|
2. Read current PRD `| **Version** |` from metadata (e.g., `1.2`).
|
|
47
237
|
|
|
48
238
|
**If no existing feature files** → fresh generation, proceed normally. Use PRD version as `@trace.prd_version`.
|
|
@@ -145,7 +335,12 @@ CHECKPOINT: "Does this outline look correct? Do you want to add or remove any SC
|
|
|
145
335
|
|
|
146
336
|
## Generate
|
|
147
337
|
|
|
148
|
-
|
|
338
|
+
**Output path by mode:**
|
|
339
|
+
- **Spec repo mode**: `{paths.specs_dir}/{domain}/{active_platform}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
340
|
+
- **Umbrella mode (single-service)**: `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
341
|
+
- **Umbrella mode (multi-service)**: `{paths.specs_dir}/{domain}/{active_service}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
342
|
+
|
|
343
|
+
For each UC, write to the resolved path above. Use vocabulary for the active platform (from Platform Selection or Service Detection).
|
|
149
344
|
|
|
150
345
|
```gherkin
|
|
151
346
|
# ============================================================
|
|
@@ -153,8 +348,9 @@ For each UC, write `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
|
|
|
153
348
|
# @trace.title: <Feature name>
|
|
154
349
|
# @trace.revision: 1 ← static field; use @trace.bdd_version for version tracking (incremented by /review-context --fix or --resume)
|
|
155
350
|
# @trace.domain: <domain>
|
|
156
|
-
# @trace.
|
|
157
|
-
# @trace.
|
|
351
|
+
# @trace.platform: {active_platform — web | app | system | (omit in umbrella mode)}
|
|
352
|
+
# @trace.service: {active_service — omit in spec repo mode}
|
|
353
|
+
# @trace.module: {active_module in umbrella mode; "unknown" in spec repo mode}
|
|
158
354
|
# @trace.status: draft
|
|
159
355
|
# @trace.author: AI-generated
|
|
160
356
|
# @trace.created_at: {YYYY-MM-DD}
|
|
@@ -262,7 +458,7 @@ After generating all `.feature` files, create or update `{paths.trace_dir}/{UC-I
|
|
|
262
458
|
|
|
263
459
|
**TSV columns (tab-separated, one header row + one data row per scenario):**
|
|
264
460
|
```
|
|
265
|
-
sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tprd_version\tbdd_version\ttech_doc_revision\tprd_status\tuc_status\tstatus\tlast_updated
|
|
461
|
+
sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tprd_version\tbdd_version\ttech_doc_revision\tprd_status\tuc_status\tfe_phase\tstatus\tlast_updated
|
|
266
462
|
```
|
|
267
463
|
|
|
268
464
|
**Rules:**
|
|
@@ -289,6 +485,7 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tpr
|
|
|
289
485
|
| `tech_doc_revision` | `—` |
|
|
290
486
|
| `prd_status` | read `\| **Status** \|` from PRD metadata |
|
|
291
487
|
| `uc_status` | `draft` for new UCs; keep existing value for re-gen |
|
|
488
|
+
| `fe_phase` | `—` (set by `/generate-code --phase` when FE implements) |
|
|
292
489
|
| `status` | `UNTRACKED` |
|
|
293
490
|
| `last_updated` | today `YYYY-MM-DD` |
|
|
294
491
|
|
|
@@ -298,16 +495,26 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tpr
|
|
|
298
495
|
|
|
299
496
|
```
|
|
300
497
|
/generate-bdd Complete
|
|
498
|
+
|
|
499
|
+
[Spec repo mode — platform: {active_platform}]
|
|
301
500
|
Files:
|
|
302
|
-
{paths.specs_dir}/{domain}/{TICKET-ID}-UC1-{slug}.feature ({N} scenarios)
|
|
303
|
-
{paths.specs_dir}/{domain}/{TICKET-ID}-UC2-{slug}.feature ({N} scenarios)
|
|
501
|
+
{paths.specs_dir}/{domain}/{active_platform}/{TICKET-ID}-UC1-{slug}.feature ({N} scenarios)
|
|
502
|
+
{paths.specs_dir}/{domain}/{active_platform}/{TICKET-ID}-UC2-{slug}.feature ({N} scenarios)
|
|
304
503
|
Trace:
|
|
305
504
|
{paths.trace_dir}/{TICKET-ID}-UC1.tsv ({N} rows)
|
|
306
505
|
{paths.trace_dir}/{TICKET-ID}-UC2.tsv ({N} rows)
|
|
307
|
-
Next
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
506
|
+
Next (spec repo):
|
|
507
|
+
→ Run /generate-bdd again for other platforms (web → app → system)
|
|
508
|
+
→ After all platforms generated: commit + push + notify dev team
|
|
509
|
+
→ Dev team reads BDD from spec submodule — no /generate-bdd on their side
|
|
510
|
+
|
|
511
|
+
[Umbrella mode — service: {active_service}]
|
|
512
|
+
Files:
|
|
513
|
+
{paths.specs_dir}/{domain}/{TICKET-ID}-UC1-{slug}.feature ({N} scenarios)
|
|
514
|
+
Trace:
|
|
515
|
+
{paths.trace_dir}/{TICKET-ID}-UC1.tsv ({N} rows)
|
|
516
|
+
Next (umbrella):
|
|
517
|
+
→ /review-context {feature-file} to verify coverage
|
|
518
|
+
→ /generate-tech-docs {feature-file}
|
|
519
|
+
→ /generate-code {feature-file}
|
|
313
520
|
```
|
|
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
|
|
|
131
131
|
- `paths.core_entities` → path to core-entities.md
|
|
132
132
|
- `paths.tech_docs_dir` → technical documentation root
|
|
133
133
|
- `paths.trace_dir` → trace state directory
|
|
134
|
+
- `paths.design_spec_dir` → Design Spec documents root (FE/App only)
|
|
134
135
|
|
|
135
136
|
If `paths` section is absent, use these defaults:
|
|
136
137
|
- `specs_dir` = `specs/bdd`
|
|
@@ -142,11 +143,75 @@ If `paths` section is absent, use these defaults:
|
|
|
142
143
|
- `core_entities` = `specs/domain-knowledge/core-entities.md`
|
|
143
144
|
- `tech_docs_dir` = `specs/tech-docs`
|
|
144
145
|
- `trace_dir` = `.trace`
|
|
146
|
+
- `design_spec_dir` = `specs/design-spec`
|
|
145
147
|
|
|
146
148
|
If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
|
|
147
149
|
|
|
148
150
|
---
|
|
149
151
|
|
|
152
|
+
## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
|
|
153
|
+
|
|
154
|
+
*Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
|
|
155
|
+
|
|
156
|
+
If `services` section is present:
|
|
157
|
+
|
|
158
|
+
**1. Detect active domain** (in priority order):
|
|
159
|
+
- Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
|
|
160
|
+
- Extract from target file path: segment immediately after `prd_dir` base path
|
|
161
|
+
*(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
|
|
162
|
+
- If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
|
|
163
|
+
|
|
164
|
+
**2. Route to service** — if active domain matches a key in `services`:
|
|
165
|
+
- Override `paths.specs_dir` → `services.{domain}.specs_dir`
|
|
166
|
+
- Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
|
|
167
|
+
- Store `active_service` = `services.{domain}.path`
|
|
168
|
+
- Store `active_service_module` = `services.{domain}.module`
|
|
169
|
+
- If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
|
|
170
|
+
|
|
171
|
+
**3. Fallback** — if domain not detected or no matching service key:
|
|
172
|
+
- Keep default paths from Step 1
|
|
173
|
+
- Set `active_service = unresolved`
|
|
174
|
+
|
|
175
|
+
**4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
|
|
176
|
+
- Override `paths.prd_dir` → `{spec_source}/specs/prd`
|
|
177
|
+
- Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
|
|
178
|
+
- Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
|
|
179
|
+
- Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
|
|
180
|
+
- Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
|
|
181
|
+
- Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
|
|
182
|
+
- Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
|
|
183
|
+
|
|
184
|
+
> **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.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
|
|
189
|
+
|
|
190
|
+
*Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
|
|
191
|
+
|
|
192
|
+
When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
|
|
193
|
+
|
|
194
|
+
**1. Locate service config** — try in priority order:
|
|
195
|
+
- `{active_service}/.agent/project-context.yaml`
|
|
196
|
+
- `{active_service}/project-context.yaml`
|
|
197
|
+
|
|
198
|
+
**2. If found, override with service-specific values:**
|
|
199
|
+
|
|
200
|
+
| Variable | Source |
|
|
201
|
+
|----------|--------|
|
|
202
|
+
| `conventions.test_command` | service's `conventions.test_command` |
|
|
203
|
+
| `conventions.build_command` | service's `conventions.build_command` |
|
|
204
|
+
| `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
|
|
205
|
+
| `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
|
|
206
|
+
|
|
207
|
+
**3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
|
|
208
|
+
- Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
|
|
209
|
+
- File write operations (test files, trace TSVs) use paths **relative to** `service_root`
|
|
210
|
+
|
|
211
|
+
**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).
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
150
215
|
## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
|
|
151
216
|
|
|
152
217
|
If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
|
|
@@ -237,6 +302,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
|
|
|
237
302
|
|
|
238
303
|
---
|
|
239
304
|
|
|
305
|
+
## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
|
|
306
|
+
|
|
307
|
+
*Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
|
|
308
|
+
or accepted during `/review-code`, `/fix-bug`, `/debug`.*
|
|
309
|
+
|
|
310
|
+
Resolve the lessons file path:
|
|
311
|
+
- Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
|
|
312
|
+
- Else default `specs/domain-knowledge/lessons-learned.md`
|
|
313
|
+
- In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
|
|
314
|
+
|
|
315
|
+
If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
|
|
316
|
+
- Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
|
|
317
|
+
- 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).
|
|
318
|
+
- If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
|
|
319
|
+
|
|
320
|
+
If the file does not exist → skip silently (no lessons captured yet).
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
240
324
|
## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
|
|
241
325
|
|
|
242
326
|
After loading all context, synthesize and output a compact summary block.
|
|
@@ -252,6 +336,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
|
|
|
252
336
|
Ticket : {ticket_prefix}-
|
|
253
337
|
Dict : {loaded — N canonical terms, M banned terms | missing}
|
|
254
338
|
Entities : {loaded — EntityA, EntityB, EntityC | missing}
|
|
339
|
+
Lessons : {loaded — N guardrails | none yet}
|
|
340
|
+
Service : {active_service} ({active_service_module}) | single-service
|
|
341
|
+
Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
|
|
255
342
|
Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
|
|
256
343
|
```
|
|
257
344
|
|
|
@@ -295,6 +382,39 @@ Read:
|
|
|
295
382
|
|
|
296
383
|
---
|
|
297
384
|
|
|
385
|
+
## Phase Detection
|
|
386
|
+
|
|
387
|
+
Parse `$ARGUMENTS` for a `--phase` flag:
|
|
388
|
+
|
|
389
|
+
| Flag | Meaning |
|
|
390
|
+
|---|---|
|
|
391
|
+
| `--phase=ui` | FE Phase 1 — generate UI + mock API layer from System BDD contract |
|
|
392
|
+
| `--phase=integration` | FE Phase 2 — replace mock adapter with real API calls from tech docs |
|
|
393
|
+
| *(none)* | Default — full implementation (BE or full-stack without mock split) |
|
|
394
|
+
|
|
395
|
+
**If `--phase` is set — confirm platform:**
|
|
396
|
+
Read `@trace.platform` from the feature file header.
|
|
397
|
+
- If `system` → warn: "`--phase` flag is not applicable for system BDD (BE-facing). Proceeding with default mode." Treat as no flag.
|
|
398
|
+
- If `web` or `app` → continue with phase logic below.
|
|
399
|
+
|
|
400
|
+
**If `--phase=ui`:**
|
|
401
|
+
Load System BDD for this UC: find `{specs_dir}/{domain}/system/{TICKET-ID}*.feature`.
|
|
402
|
+
Extract all `Then` clauses → collect implied response shapes and error states.
|
|
403
|
+
If System BDD not found → warn: "System BDD not found — mock layer will use placeholder fixtures." Continue.
|
|
404
|
+
|
|
405
|
+
**If `--phase=integration`:**
|
|
406
|
+
Read tech-doc `@trace.status` from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`.
|
|
407
|
+
If `draft` or `in-review` → warn:
|
|
408
|
+
```
|
|
409
|
+
⚠ Tech docs for {UC-ID} are {status}.
|
|
410
|
+
BE may not have a stable API contract yet.
|
|
411
|
+
Proceeding — ensure BE endpoint is deployed or confirm contract manually.
|
|
412
|
+
```
|
|
413
|
+
Locate existing mock adapter from `--phase=ui` run (search for `{UC-ID}MockApiAdapter` in `{paths.src_dir}/{domain}/`).
|
|
414
|
+
If not found → warn: "Mock adapter not found — generating real API adapter from scratch using tech-doc contract."
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
298
418
|
## Read Trace State
|
|
299
419
|
|
|
300
420
|
Read `{paths.trace_dir}/{UC-ID}.tsv` if it exists. For each scenario row, note its current `status`:
|
|
@@ -339,6 +459,7 @@ Ticket : {TICKET_ID if known}
|
|
|
339
459
|
Domain : {domain}
|
|
340
460
|
UC : {UC-ID} only ← other feature files in this folder are NOT read
|
|
341
461
|
Tech : {language} / {framework}
|
|
462
|
+
Phase : {UI — mock layer | Integration — real API | Default — full} ← omit if no --phase flag
|
|
342
463
|
Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
|
|
343
464
|
Layer : {from CLAUDE.md §2}
|
|
344
465
|
|
|
@@ -385,6 +506,53 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
|
|
|
385
506
|
|
|
386
507
|
> **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.
|
|
387
508
|
|
|
509
|
+
## Mock API Layer (`--phase=ui` only)
|
|
510
|
+
|
|
511
|
+
*Skip this section entirely if `--phase` is not `ui`.*
|
|
512
|
+
|
|
513
|
+
Using the System BDD `Then` clauses loaded in Phase Detection:
|
|
514
|
+
|
|
515
|
+
1. **Extract fixture data** per scenario — success responses + error responses.
|
|
516
|
+
2. **Generate mock adapter** at `{paths.src_dir}/{domain}/{UC-ID}MockApiAdapter.{ext}`:
|
|
517
|
+
- Implements interface `{UC-ID}ApiPort` (same interface the real adapter will implement)
|
|
518
|
+
- Each method returns fixture data matching the BDD `Then` clause
|
|
519
|
+
- Include both success and error states (map to error scenarios in BDD)
|
|
520
|
+
- Traceability tags:
|
|
521
|
+
```
|
|
522
|
+
@trace.mock_for={UC-ID}
|
|
523
|
+
@trace.system_bdd={paths.specs_dir}/{domain}/system/{UC-ID}*.feature
|
|
524
|
+
```
|
|
525
|
+
3. **Wire into service/hook layer** via environment flag or DI:
|
|
526
|
+
```
|
|
527
|
+
const adapter = IS_MOCK ? new {UC-ID}MockApiAdapter() : new {UC-ID}ApiAdapter()
|
|
528
|
+
```
|
|
529
|
+
- `IS_MOCK` defaults to `true` in development/test env until real adapter is generated.
|
|
530
|
+
|
|
531
|
+
> Tester uses the mock adapter to test all FE scenarios without waiting for BE.
|
|
532
|
+
> Mock fixture data is derived directly from System BDD — BDD is the source of truth.
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
## Integration Phase (`--phase=integration` only)
|
|
537
|
+
|
|
538
|
+
*Skip this section entirely if `--phase` is not `integration`.*
|
|
539
|
+
|
|
540
|
+
1. **Read tech-doc API contract** from `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` — extract endpoints, request/response shapes, error codes.
|
|
541
|
+
2. **Read existing mock adapter** interface (`{UC-ID}ApiPort`) from the `--phase=ui` output.
|
|
542
|
+
3. **Generate real API adapter** at `{paths.src_dir}/{domain}/{UC-ID}ApiAdapter.{ext}`:
|
|
543
|
+
- Implements the same `{UC-ID}ApiPort` interface as mock adapter
|
|
544
|
+
- Makes real HTTP calls to endpoints from tech-doc contract
|
|
545
|
+
- Maps response fields to the same shapes the mock adapter returned
|
|
546
|
+
- Traceability tags:
|
|
547
|
+
```
|
|
548
|
+
@trace.implements={UC-ID}-SC{N}
|
|
549
|
+
@trace.tech_doc_revision={read from tech-doc header}
|
|
550
|
+
```
|
|
551
|
+
4. **Flip wire-up**: switch DI binding / env flag so service/hook uses `{UC-ID}ApiAdapter` (real) instead of mock.
|
|
552
|
+
5. **Do NOT delete mock adapter** — keep it for unit testing.
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
388
556
|
## Self-Review (3 rounds)
|
|
389
557
|
- [ ] Every scenario has a corresponding endpoint
|
|
390
558
|
- [ ] @trace.implements on every endpoint
|
|
@@ -407,6 +575,7 @@ Update `{paths.trace_dir}/{UC-ID}.tsv` — for each implemented scenario, find t
|
|
|
407
575
|
| `implemented_by` | `{ControllerClass}.{methodName}` |
|
|
408
576
|
| `bdd_version` | `@trace.bdd_version` from `.feature` header |
|
|
409
577
|
| `tech_doc_revision` | `@trace.revision` from tech-doc header, or `—` if no tech-doc |
|
|
578
|
+
| `fe_phase` | `ui` if `--phase=ui` \| `integrated` if `--phase=integration` \| `—` if no phase flag |
|
|
410
579
|
| `last_updated` | today `YYYY-MM-DD` |
|
|
411
580
|
|
|
412
581
|
Leave all other columns (`sc_title`, `spec_ver`, `prd_version`, `prd_status`, `uc_status`, `test_count`, `test_classes`) unchanged.
|
|
@@ -452,7 +621,8 @@ Suggest the logical next command based on workflow phase:
|
|
|
452
621
|
| /define-product | `/generate-prd {product-definition-file}` |
|
|
453
622
|
| /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
|
|
454
623
|
| /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
|
|
455
|
-
| /review-context (PRD) | `/generate-
|
|
624
|
+
| /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 |
|
|
625
|
+
| /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
|
|
456
626
|
| /generate-bdd | `/review-context {feature-file}` to verify coverage |
|
|
457
627
|
| /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
|
|
458
628
|
| /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
|
|
@@ -466,6 +636,11 @@ Suggest the logical next command based on workflow phase:
|
|
|
466
636
|
| /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
|
|
467
637
|
| /fix-bug | Create PR and link to ticket |
|
|
468
638
|
| /debug | `/fix-bug {ticket-id}` if fix needed |
|
|
639
|
+
| /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
|
|
640
|
+
| /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
|
|
641
|
+
| /learn | Continue working — lesson applies on next command |
|
|
642
|
+
| /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
|
|
643
|
+
| /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
|
|
469
644
|
|
|
470
645
|
Format the footer as:
|
|
471
646
|
```
|
|
@@ -480,7 +655,20 @@ Next : {suggested command with example arguments}
|
|
|
480
655
|
/generate-code Complete — {UC-ID}
|
|
481
656
|
Files: created={N}, extended={M}, skipped={K} | Build: SUCCESS
|
|
482
657
|
Branch: feature/{TICKET_ID}-{slug}
|
|
658
|
+
Phase : {UI (mock layer) | Integration (real API) | Default (full)}
|
|
659
|
+
fe_phase : {ui | integrated | —}
|
|
660
|
+
|
|
483
661
|
Next:
|
|
484
|
-
|
|
485
|
-
|
|
662
|
+
--phase=ui done:
|
|
663
|
+
→ Notify tester: FE is testable via mock adapter
|
|
664
|
+
→ Collect BE sign-offs → /review-tech-docs {tech-design-file}
|
|
665
|
+
→ When BE ready → /generate-code {feature-file} --phase=integration
|
|
666
|
+
|
|
667
|
+
--phase=integration done:
|
|
668
|
+
→ /review-code {UC-ID} ← code review required
|
|
669
|
+
→ /generate-tests {UC-ID} ← integration test suite
|
|
670
|
+
|
|
671
|
+
Default (no phase flag):
|
|
672
|
+
→ /review-code {UC-ID} ← code review required before tests
|
|
673
|
+
→ /generate-tests {UC-ID}
|
|
486
674
|
```
|