@brunosps00/dev-workflow 1.5.0 → 1.7.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 (34) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +2 -2
  3. package/lib/constants.js +6 -4
  4. package/lib/install-deps.js +22 -1
  5. package/lib/install-open-design.js +89 -0
  6. package/package.json +4 -2
  7. package/scaffold/en/commands/dw-adr.md +49 -11
  8. package/scaffold/en/commands/dw-analyze-project.md +5 -0
  9. package/scaffold/en/commands/dw-brainstorm.md +103 -32
  10. package/scaffold/en/commands/dw-claude-run.md +8 -5
  11. package/scaffold/en/commands/dw-help.md +3 -1
  12. package/scaffold/en/commands/dw-open-design.md +324 -0
  13. package/scaffold/en/commands/dw-plan.md +34 -5
  14. package/scaffold/en/templates/adr-template.md +8 -4
  15. package/scaffold/en/templates/idea-onepager.md +44 -2
  16. package/scaffold/pt-br/commands/dw-adr.md +49 -11
  17. package/scaffold/pt-br/commands/dw-analyze-project.md +5 -0
  18. package/scaffold/pt-br/commands/dw-brainstorm.md +105 -32
  19. package/scaffold/pt-br/commands/dw-claude-run.md +8 -5
  20. package/scaffold/pt-br/commands/dw-help.md +3 -1
  21. package/scaffold/pt-br/commands/dw-open-design.md +323 -0
  22. package/scaffold/pt-br/commands/dw-plan.md +34 -5
  23. package/scaffold/pt-br/templates/adr-template.md +8 -4
  24. package/scaffold/pt-br/templates/idea-onepager.md +44 -2
  25. package/scaffold/scripts/open-design/capture-current.mjs +170 -0
  26. package/scaffold/scripts/open-design/gate-prototype.mjs +223 -0
  27. package/scaffold/skill-registry.json +25 -1
  28. package/scaffold/skills/dw-cli-run/SKILL.md +10 -8
  29. package/scaffold/skills/dw-domain-modeling/SKILL.md +84 -0
  30. package/scaffold/skills/dw-domain-modeling/references/adr-policy.md +48 -0
  31. package/scaffold/skills/dw-domain-modeling/references/glossary-format.md +66 -0
  32. package/scaffold/skills/dw-grilling/SKILL.md +98 -0
  33. package/scaffold/skills/dw-grilling/references/decision-tree.md +56 -0
  34. package/scaffold/skills/dw-grilling/references/interview-loop.md +52 -0
@@ -11,18 +11,19 @@ session**, score the delivery 0–10, escalate on failure, and **STOP for the ga
11
11
 
12
12
  | Slot | Claude value |
13
13
  |---|---|
14
- | `DISPATCH` | `UUID=$(cat /proc/sys/kernel/random/uuid); cd <WORKTREE> && claude -p --session-id "$UUID" --model <MODEL> --output-format stream-json --include-partial-messages --verbose --dangerously-skip-permissions "$(cat <PROMPT>)" </dev/null > <AUDIT>/<slug>.log 2>&1` |
14
+ | `DISPATCH` | `UUID=$(cat /proc/sys/kernel/random/uuid); cd <WORKTREE> && claude -p --session-id "$UUID" --model <MODEL> --effort <EFFORT> --output-format stream-json --include-partial-messages --verbose --dangerously-skip-permissions "$(cat <PROMPT>)" </dev/null > <AUDIT>/<slug>.log 2>&1` |
15
15
  | `STREAM` | `--output-format stream-json --include-partial-messages --verbose` (`--verbose` is **required** with `stream-json` in `-p` mode) |
16
16
  | `AUTO` | `--dangerously-skip-permissions` (headless auto-approve; justified because the worktree is isolated). Read-only/analysis: drop it and pass `--permission-mode plan` (or restrict `--allowedTools`). |
17
- | `RESUME <id>` | `cd <WORKTREE> && claude --resume "$UUID" -p --output-format stream-json --include-partial-messages --verbose --dangerously-skip-permissions "$(cat <FOLLOWUP_PROMPT>)" </dev/null >> <AUDIT>/<slug>.log 2>&1` |
17
+ | `RESUME <id>` | `cd <WORKTREE> && claude --resume "$UUID" -p --effort <EFFORT> --output-format stream-json --include-partial-messages --verbose --dangerously-skip-permissions "$(cat <FOLLOWUP_PROMPT>)" </dev/null >> <AUDIT>/<slug>.log 2>&1` |
18
18
  | `RESUME_LAST` | `claude -c -p …` (continue the most recent conversation in this cwd) |
19
19
  | `SESSION_ID` | **FIXED by you** — you pass `--session-id "$UUID"` on the first run, so the id is known up front. Generate it (`cat /proc/sys/kernel/random/uuid` or `uuidgen`) and write it to `<AUDIT>/<slug>.session` BEFORE/at dispatch. No stream-scraping needed — Claude is the easy case. |
20
20
  | `DONE_SIGNAL` | the final `{"type":"result"}` message in the stream (carries `subtype`, `usage`, `total_cost_usd`, `num_turns`) |
21
21
  | `USAGE` | the `result` message `usage` → `input_tokens` / `cache_read_input_tokens` / `cache_creation_input_tokens` / `output_tokens`, plus `total_cost_usd`. Extract: `grep -oE '"usage":\{[^}]*\}' <AUDIT>/<slug>.log \| tail -1` |
22
22
 
23
- **Model + effort:** `--model` selects the tier (`opus` · `sonnet` · `haiku`, or a full id). Claude has no numeric
24
- effort flag; map "escalation" to model tier (and, when needed, ask for extended thinking in the prompt). Start one
25
- tier below the ceiling; escalate per `dw-cli-run`.
23
+ **Model + effort:** `--model` selects the tier (`opus` · `sonnet` · `haiku`, or a full id). `--effort` selects the
24
+ reasoning budget: `low` · `medium` · `high` · `xhigh` · `max` (supported by the Claude CLI ≥ 2.1.206). Escalate per
25
+ `dw-cli-run`: raise `--effort` first (low→medium→high→xhigh→max), then bump `--model` one tier and reset effort.
26
+ Start one notch below the ceiling.
26
27
 
27
28
  ## Session resume (the heart)
28
29
  Because you pass `--session-id "$UUID"`, the id is **fixed and known** at dispatch — write it to
@@ -38,6 +39,8 @@ Because you pass `--session-id "$UUID"`, the id is **fixed and known** at dispat
38
39
  | `<PROMPT>` | prepared prompt/spec path | `.dw/spec/prd-billing-integrador/codex-prompt.md` |
39
40
  | `<slug>` | task key for audit/session files | `prd-billing-integrador` |
40
41
  | `<AUDIT>` | durable audit dir OUTSIDE the worktree | `~/code/vizzita/.dw/cli-run` |
42
+ | `<MODEL>` | Claude tier or full model id | `opus` / `sonnet` / `haiku` |
43
+ | `<EFFORT>` | reasoning budget (Claude CLI ≥ 2.1.206) | `low` / `medium` / `high` / `xhigh` / `max` |
41
44
 
42
45
  Return via the `dw-cli-run` **Structured Return** (Status/Score/Scope/Evidence/Artifacts/Decisions/Risks/Telemetry/
43
46
  Next Step), including the fixed `session-id` (UUID), its sidecar path, and the exact `RESUME` command to continue.
@@ -38,12 +38,13 @@ Use `/dw-autopilot "wish"` as the gateway for most feature work. The granular co
38
38
  | `/dw-commit` | Atomic Conventional Commits for pending work. |
39
39
  | `/dw-generate-pr [target]` | Push branch, draft PR body, open browser. |
40
40
 
41
- ## Tier 3 — Specialty (11)
41
+ ## Tier 3 — Specialty (12)
42
42
 
43
43
  | Command | What |
44
44
  |---------|------|
45
45
  | `/dw-analyze-project` | Scan the repo, write `.dw/rules/`, offer `.dw/constitution.md`, generate `.dw/rules/concerns.md`, and synthesize frontend `DESIGN.md` when tokens exist. |
46
46
  | `/dw-redesign-ui "target"` | Audit, propose 2-3 design directions, ship. Enforces UI grounding + WCAG; can run the deterministic impeccable slop detector. |
47
+ | `/dw-open-design --brief <file>` | Generate, iterate, or `--refactor` headless Open Design HTML prototypes via `od`; refines briefs first, can capture current screenshots with `--url --viewports` or `--screenshot`, then verifies file + visual gate. |
47
48
  | `/dw-refactor "target"` | Audit code-health and tech debt with Fowler smells, deep-modules analysis, and behavior-preserving test gates. |
48
49
  | `/dw-functional-doc` | Map screens + flows into a functional doc validated with Playwright; uses WSL-resilient browser resolution. |
49
50
  | `/dw-context-budget` | Audit context overhead from commands, skills, agents, instructions, and MCPs. |
@@ -112,6 +113,7 @@ Match the keyword and suggest:
112
113
  | `research`, `compare`, `state of the art` | `/dw-brainstorm --research` |
113
114
  | `refactor`, `smell`, `code health`, `tech debt` | `/dw-refactor` |
114
115
  | `ui`, `design`, `redesign` | `/dw-redesign-ui` |
116
+ | `open design`, `prototype`, `prototipo`, `od cli`, `html prototype` | `/dw-open-design --brief <file>`, `/dw-open-design --brief-glob "<glob>" --agent claude`, or `/dw-open-design --refactor --url <url> --viewports "1440x900,375x812"` |
115
117
  | `intel`, `where is`, `what uses` | `/dw-intel` (or `--build` to (re)create the index) |
116
118
  | `context`, `tokens`, `slow agent` | `/dw-context-budget` |
117
119
  | `harness`, `install`, `wrappers`, `agents` | `/dw-harness-audit` |
@@ -0,0 +1,324 @@
1
+ <system_instructions>
2
+ You are the **headless Open Design (`od`) runner** for generating and iterating HTML prototypes in a project
3
+ folder, without Electron and without depending on the user's GUI state. Start the `nexu-io/open-design` daemon in
4
+ `--headless`, import the target folder once, run single briefs or serial batches, verify the output file, run the
5
+ Playwright/Firefox visual gate, and **STOP for the owner's gate** before any commit.
6
+
7
+ <critical>NEVER use the user's GUI state. Always run with an isolated per-project `OD_DATA_DIR`, for example `.dw/.open-design/data/`.</critical>
8
+ <critical>NEVER commit a rejected prototype. The gate is dual >=9: automated gate + your own visual score >=9, then owner gate.</critical>
9
+ <critical>The agent (`codex` or `claude`) must always be explicit in `od run start --agent <agent>`. If the user does not pass one, resolve from project config/state; fallback `codex`.</critical>
10
+ <critical>NEVER dispatch the user's raw request to `od`. This command's value is refining the prompt first: ground it in real code, structure the brief, qualify states/themes/a11y/deep-link, persist the reviewable brief, and only then append the headless appendix.</critical>
11
+
12
+ ## Inputs
13
+
14
+ | Flag/argument | Default | Description |
15
+ |---|---:|---|
16
+ | `--target <dir>` | `open-design/` | Folder imported as the external project and where HTML files are written. |
17
+ | `--brief <file>` | none | One markdown brief for a single run. |
18
+ | `--brief-glob <glob>` | none | Serial batch. Expand to a stable list and run one prompt at a time. |
19
+ | `--output <file>` | required in the brief/appendix | Expected HTML file; verify it on disk after the run. |
20
+ | `--agent <codex|claude>` | state/config -> `codex` | Agent forwarded to `od run start --agent`. |
21
+ | `--platform <text>` | `Responsive web, desktop-first and mobile-safe` | Pre-filled discovery answer for the `web-prototype` skill. |
22
+ | `--deep-link-id <id>` | none | Value used by the behavioral gate for `?aberto=<id>` + Esc. |
23
+ | `--refactor` | false | Existing-screen redesign/refactor mode; captures current screenshots and grounds the brief in visible state + real code. |
24
+ | `--url <url>` | none | Running app URL for current screenshot capture via Playwright Firefox. |
25
+ | `--viewports <list>` | `1440x900,375x812` | Comma-separated viewports for `--refactor --url`; expand as the pain requires (for example `1920x1080` for a wide table). |
26
+ | `--screenshot <path>` | repeatable | Already-captured current screenshot when there is no `--url`; copy it into `_refs/<slug>/`. |
27
+
28
+ ## 0. Refine The Brief
29
+
30
+ Before any daemon pre-flight or `od` call, turn the user's intent into a qualified brief. Do not send the user's raw
31
+ sentence to the runner.
32
+
33
+ Required contract:
34
+
35
+ | Step | Requirement |
36
+ |---|---|
37
+ | Ground in reality | If the screen exists, read its real code: columns, enums, actions, states, permissions, contracts, and domain. Also read the project's design system, sibling prototypes, and design guides. Inventing a field, status, or action is forbidden. |
38
+ | Structure | Rewrite the request into the standard skeleton below, filling real paths and the exact output file. |
39
+ | Qualify | Cover loading/skeleton, empty, error/failure, light + dark, a11y, local design-system limits (for example <=6 cards/filters), responsiveness, and deep-link. |
40
+ | Persist | Save the refined brief inside the project, for example `<target>/PROMPT-<slug>.md`. It is a reviewable owner deliverable, not a disposable scratch file. |
41
+ | Review if already ready | If the user already provides a qualified brief, do a quick checklist review, patch only gaps, and persist the final version. |
42
+
43
+ Standard refined brief skeleton:
44
+
45
+ ```markdown
46
+ # <screen/prototype title>
47
+
48
+ Paste this brief into Open Design. Exact output file: `<OUTPUT_FILE>`.
49
+
50
+ ## 1. Why
51
+ <real user/product pain; observable problem this prototype must solve>
52
+
53
+ ## 2. Interaction Decision
54
+ <navigation, opening, selection, filters, sorting, editing, and confirmation pattern>
55
+
56
+ ## 3. Layout/List
57
+ Table/list based only on REAL columns:
58
+
59
+ | Real column | Source/contract | Presentation | State/limit |
60
+ |---|---|---|---|
61
+ | <name> | <file/API/schema> | <text, badge, action> | <truncate, empty, error> |
62
+
63
+ ## 4. Detail/Actions
64
+ <drawer/modal/detail page; contextual actions allowed by real state/permission>
65
+
66
+ ## 5. Domain Fidelity
67
+ So the mock does not lie: use real enums/statuses, realistic sample data in the project's language, and include rare/broken states that exist in the domain.
68
+
69
+ ## 6. Visual Direction
70
+ <tokens, components, density, inherited references, sibling prototypes, and design-system limits>
71
+
72
+ ## Deliver
73
+ - `<OUTPUT_FILE>`
74
+ - `<OUTPUT_FILE>.artifact.json` when there is a sidecar
75
+ ```
76
+
77
+ Only after persisting this file should you append the headless appendix under `.dw/.open-design/runs/` and dispatch
78
+ the run.
79
+
80
+ ### 0R. Refactor/Redesign Mode
81
+
82
+ When `--refactor` is present, phase 0 remains mandatory. Screenshots complement grounding in code; they do not
83
+ replace reading contracts, enums, permissions, states, the design system, and sibling prototypes.
84
+
85
+ Capture or copy current screenshots into the imported folder, under `_refs/<slug>/`, before persisting the brief:
86
+
87
+ ```bash
88
+ node .dw/scripts/open-design/capture-current.mjs \
89
+ --target "$TARGET_DIR" \
90
+ --slug "<slug>" \
91
+ --url "<url>" \
92
+ --viewports "1440x900,375x812"
93
+ ```
94
+
95
+ Without a running app URL, accept existing screenshots by repeating `--screenshot`:
96
+
97
+ ```bash
98
+ node .dw/scripts/open-design/capture-current.mjs \
99
+ --target "$TARGET_DIR" \
100
+ --slug "<slug>" \
101
+ --screenshot "./before-1440-light.png" \
102
+ --screenshot "./before-375-dark.png"
103
+ ```
104
+
105
+ Capture rules:
106
+
107
+ | Case | Requirement |
108
+ |---|---|
109
+ | Viewports | Sensible default: desktop `1440x900` + mobile `375x812`. The agent chooses/expands as the pain requires: mobile bug includes `375x812`; wide table includes `1920x1080`; tablet/console includes `768x1024`. |
110
+ | Themes | Capture light and dark when applicable. The helper uses `light,dark` by default and writes names like `_refs/<slug>/atual-1440-light.png` and `_refs/<slug>/atual-375-dark.png`. |
111
+ | Robust path | The `od` agent reads images from the project filesystem. Reference relative paths inside the target; do not depend on an image flag in `run start`. |
112
+ | Hygiene | `_refs/` and reference material must not become prototypes. If the target project tracks final prototypes, document cleanup or add `<target>/_refs/` to `.gitignore` according to local convention. |
113
+
114
+ The refined refactor brief must add this block:
115
+
116
+ ```markdown
117
+ ## Current Screen References
118
+ Open and ANALYZE the screenshots before writing:
119
+ - `_refs/<slug>/atual-1440-light.png`
120
+ - `_refs/<slug>/atual-375-dark.png`
121
+
122
+ ## What Is Wrong Today
123
+ <pain pointing to visible elements in the screenshots: density, hierarchy, table, filters, states, contrast, mobile, etc.>
124
+
125
+ ## The Change Idea
126
+ <what changes and why; interaction/visual decision proposed by the user or by the agent after reading code and screenshots>
127
+
128
+ ## Preserve
129
+ <flows, fields, permissions, states, copy, affordances, and integrations that must not change>
130
+ ```
131
+
132
+ ## Pre-flight
133
+
134
+ | Check | Action |
135
+ |---|---|
136
+ | Resolve `od` | `OD_CLI_DIR` wins. Otherwise use `~/.dw/vendor/open-design`. If `apps/daemon/bin/od.mjs` is missing, stop and tell the user to run `dev-workflow install-deps`. |
137
+ | Prerequisites | The Open Design checkout requires Node `~24` and pnpm `>=10.33`. If missing, stop with concrete instructions. |
138
+ | Isolated state | Create `.dw/.open-design/`, `.dw/.open-design/data/`, `.dw/.open-design/runs/`, and `.dw/.open-design/state.json`. |
139
+ | Port | Pick a free port on `127.0.0.1`; persist `daemonUrl` and `port` in state. |
140
+ | Live daemon | If `od daemon status --daemon-url <url> --json` returns `ok: true`, reuse it. Otherwise start a new daemon. |
141
+
142
+ Daemon command shape:
143
+
144
+ ```bash
145
+ OD_DATA_DIR="$PWD/.dw/.open-design/data" \
146
+ OD_CHAT_RUN_INACTIVITY_TIMEOUT_MS=1800000 \
147
+ node "$OD_DIR/apps/daemon/bin/od.mjs" daemon start \
148
+ --headless \
149
+ --host 127.0.0.1 \
150
+ --port "$PORT"
151
+ ```
152
+
153
+ Known noise: `codex_core::shell_snapshot` may log a syntax `ERROR`. Treat it as benign when the run continues and
154
+ the target file is created.
155
+
156
+ ## Idempotent Import
157
+
158
+ Use `project import-folder` on the resolved absolute target folder. Default: `<repo>/open-design/`.
159
+
160
+ Persist in `.dw/.open-design/state.json`:
161
+
162
+ ```json
163
+ {
164
+ "schema_version": "1.0",
165
+ "targetDir": "/abs/repo/open-design",
166
+ "projectId": "<project.id>",
167
+ "conversationId": "<conversationId>",
168
+ "daemonUrl": "http://127.0.0.1:<port>",
169
+ "port": 17556,
170
+ "agent": "codex"
171
+ }
172
+ ```
173
+
174
+ If `projectId` exists in state and `od project info <id> --daemon-url <url> --json` works for the same `targetDir`,
175
+ reuse it. Otherwise, reimport:
176
+
177
+ ```bash
178
+ node "$OD_DIR/apps/daemon/bin/od.mjs" project import-folder "$TARGET_DIR" \
179
+ --daemon-url "$OD_URL" \
180
+ --name "$(basename "$TARGET_DIR")" \
181
+ --skill web-prototype \
182
+ --design-system default \
183
+ --json
184
+ ```
185
+
186
+ Capture `project.id` and `conversationId`; do not depend on global app state.
187
+
188
+ ## Required Headless Appendix
189
+
190
+ Append this block to every brief in a temporary file under `.dw/.open-design/runs/`.
191
+ Fill `<PLATFORM>`, `<OUTPUT_FILE>`, and sibling references when applicable.
192
+
193
+ ```markdown
194
+ ---
195
+
196
+ ## Headless appendix for Open Design
197
+
198
+ Target platform: <PLATFORM>.
199
+
200
+ Do not run discovery and do not ask questions. Do not emit `<question-form>`. Follow this brief with the answers
201
+ above and deliver file-first.
202
+
203
+ Required output file: `<OUTPUT_FILE>`.
204
+
205
+ File-first contract:
206
+ - Write the HTML directly to the project filesystem, exactly at `<OUTPUT_FILE>`.
207
+ - Do not alter existing files, except when this prompt is explicitly a surgical iteration on a target file.
208
+ - If you need to create a sidecar, keep `<OUTPUT_FILE>.artifact.json` coherent.
209
+ - Do not answer only with a textual `<artifact>` block; run `succeeded` without the file is a failure.
210
+
211
+ To avoid headless timeout:
212
+ - Write large files in parts, with edits of about 150 lines per call.
213
+ - Keep visible progress until the HTML is complete.
214
+
215
+ Consistency context:
216
+ - Read sibling prototypes in `prototipos/` or the folder named by the brief before defining visual patterns.
217
+ - Preserve the local visual system when a nearby reference exists.
218
+
219
+ Required deep link:
220
+ - Implement `?aberto=<id>` to open the correct item's drawer/modal.
221
+ - On Esc or close action, clear the parameter with `history.replaceState`.
222
+ - The drawer/modal must use `role="dialog"` and appropriate ARIA attributes.
223
+ - Include skeleton/loading, empty, and error states.
224
+ ```
225
+
226
+ ## Single Run
227
+
228
+ Always pass `--agent` explicitly:
229
+
230
+ ```bash
231
+ node "$OD_DIR/apps/daemon/bin/od.mjs" run start \
232
+ --daemon-url "$OD_URL" \
233
+ --project "$PROJECT_ID" \
234
+ --conversation "$CONVERSATION_ID" \
235
+ --agent "$AGENT" \
236
+ --skill web-prototype \
237
+ --design-system default \
238
+ --prompt-file "$PROMPT_WITH_APPENDIX" \
239
+ --follow \
240
+ --json | tee ".dw/.open-design/runs/<slug>.jsonl"
241
+ ```
242
+
243
+ After the run, check the file. **Do not accept only `succeeded`:**
244
+
245
+ ```bash
246
+ test -s "$TARGET_DIR/<OUTPUT_FILE>"
247
+ ```
248
+
249
+ Record in JSONL or an audit sidecar: brief, prompt with appendix, agent, daemonUrl, projectId, conversationId,
250
+ expected output, final status, and file verification result.
251
+
252
+ ## Batch
253
+
254
+ For `--brief-glob`, expand the briefs, sort by name, and run serially. Stop at the first case where:
255
+
256
+ | Condition | Result |
257
+ |---|---|
258
+ | run fails | `BLOCKED` with JSONL log |
259
+ | run says success but file is missing or empty | `FINDINGS` and surgical follow-up or `BLOCKED` |
260
+ | visual gate <9 | `FINDINGS`; iterate before continuing |
261
+
262
+ Do not run prompts in parallel in the same `od` project; preserve auditability and context.
263
+
264
+ ## Surgical Iteration
265
+
266
+ Use a follow-up run on the same `projectId`/`conversationId`, with a short prompt and explicit target file:
267
+
268
+ ```bash
269
+ node "$OD_DIR/apps/daemon/bin/od.mjs" run start \
270
+ --daemon-url "$OD_URL" \
271
+ --project "$PROJECT_ID" \
272
+ --conversation "$CONVERSATION_ID" \
273
+ --agent "$AGENT" \
274
+ --skill web-prototype \
275
+ --design-system default \
276
+ --prompt-file ".dw/.open-design/runs/<slug>.followup.md" \
277
+ --follow \
278
+ --json | tee -a ".dw/.open-design/runs/<slug>.jsonl"
279
+ ```
280
+
281
+ The follow-up must say: single file, exact change, do not touch sibling prototypes, preserve deep-link and states.
282
+
283
+ ## Required Visual Gate
284
+
285
+ Run the automated gate:
286
+
287
+ ```bash
288
+ node .dw/scripts/open-design/gate-prototype.mjs \
289
+ --file "$TARGET_DIR/<OUTPUT_FILE>" \
290
+ --deep-link-id "<real-id>" \
291
+ --expected-text "<item-text>" \
292
+ --out ".dw/.open-design/gate/<slug>"
293
+ ```
294
+
295
+ The gate covers:
296
+
297
+ | Layer | Requirement |
298
+ |---|---|
299
+ | Structural | `<title>`, `aberto`, `replaceState`, `role=dialog`/ARIA, skeleton/loading, empty, error. |
300
+ | Screenshot | Headless Firefox in light and dark, with `colorScheme` and `data-theme`. |
301
+ | Behavioral | `?aberto=<id>` opens the correct item; Esc closes and clears the parameter. |
302
+ | Evaluation | Automated PASS + your visual score >=9. If below 9, run a surgical follow-up. |
303
+
304
+ After it passes, **stop for the owner's gate**. Do not commit until the owner approves.
305
+
306
+ ## Validated Pitfalls
307
+
308
+ | Pitfall | Symptom | Required workaround |
309
+ |---|---|---|
310
+ | `web-prototype` discovery | Opens with `<question-form>` and ends the turn; headless does not create GenUI (`od ui list` empty). | Append the headless appendix answering platform and forbidding questions/discovery. |
311
+ | Inactivity timeout | Large HTML goes silent and the run dies near 10 minutes. | `OD_CHAT_RUN_INACTIVITY_TIMEOUT_MS=1800000` on the daemon + instruct ~150-line chunked writes. |
312
+ | `codex_core::shell_snapshot` | Logs a syntax `ERROR` in the stream. | Treat as noise if the run continues and the final file exists. |
313
+ | GUI state | App config/agent/projects leak from the user's GUI. | Isolated `OD_DATA_DIR` always; explicit `--agent`, `--skill`, and `--design-system`. |
314
+
315
+ ## Structured Return
316
+
317
+ **Status:** `PASS` | `FINDINGS` | `BLOCKED` | `NOT_APPLICABLE`
318
+ **Scope:** target folder, briefs run, agent used, projectId/conversationId.
319
+ **Evidence:** JSONL logs, verified HTML file(s), gate JSON, light/dark screenshots.
320
+ **Artifacts:** prototype and sidecar paths.
321
+ **Decisions:** defaults/overrides applied (`agent`, `target`, platform, port).
322
+ **Risks:** any gate below 9, missing file despite run succeeded, missing dependency.
323
+ **Next Step:** owner gate, required surgical follow-up, or exact resume command.
324
+ </system_instructions>
@@ -55,7 +55,36 @@ Claude Code and OpenCode can use native project agents. Codex and Copilot use `.
55
55
 
56
56
  <critical>When a structured interview/user-input tool is available, `/dw-plan` MUST use it for PRD and TechSpec clarification questions. Do not downgrade to plain chat merely for convenience. If no such tool exists in the runtime, ask the same questions in chat and explicitly record: `Structured interview tool unavailable; using chat fallback.`</critical>
57
57
 
58
- The tool is mandatory for planning because it preserves explicit user choices and prevents the agent from answering its own questions. Each stage keeps its own quota: PRD requires 7+ product questions; TechSpec requires 7+ technical questions.
58
+ The tool is mandatory for planning because it preserves explicit user choices and prevents the agent from answering its own questions.
59
+
60
+ ## Coverage-driven interview (no fixed question quotas)
61
+
62
+ <critical>`/dw-plan` does NOT ask a fixed number of questions. Each stage builds a **coverage matrix** over its required dimensions, discovers facts from the repo/rules/intel/domain artifacts, **credits evidence already resolved in an aligned Grill handoff**, and then asks — one decision at a time — ONLY the dimensions that remain uncovered. Never re-ask a product decision the user already resolved during Grill.</critical>
63
+
64
+ ### Aligned handoff (from `/dw-brainstorm` grill)
65
+
66
+ Before Stage 1, check for an idea one-pager at `.dw/spec/ideas/<slug>.md` and the canonical vocabulary in `.dw/domain/**`.
67
+
68
+ <critical>Validate the handoff and FAIL CLOSED. Credit an aligned handoff — i.e. suppress the product questions its decisions cover — ONLY when EVERY one of these holds:
69
+ - `schema_version: "1.1"`;
70
+ - `status: aligned`;
71
+ - `alignment.confirmed_by_user: true`;
72
+ - every dependency branch is resolved (no open decision node);
73
+ - glossary/code contradictions are closed;
74
+ - no **blocking** entry remains under Remaining Decisions.
75
+ If ANY check fails — or the file is malformed, internally inconsistent, `draft`, or `paused` — the one-pager is **input, not a trusted handoff**: read it for context, but treat all its decisions as **uncovered** and ask them normally. Never suppress a product question on the strength of `status: aligned` alone; `alignment.confirmed_by_user: true` and a resolved, non-blocking, contradiction-free tree are required too.</critical>
76
+
77
+ When (and only when) the handoff is fully valid:
78
+ - Load its **Resolved Decisions**, **Evidence**, and **Canonical Vocabulary** links.
79
+ - Mark every PRD dimension those decisions cover as **already covered** (cite the one-pager as the evidence) — do NOT re-ask them.
80
+ - Only uncovered dimensions become questions, asked one at a time.
81
+
82
+ ### Coverage matrices
83
+
84
+ - **PRD dimensions:** goals, target users, scope boundaries, success metrics, rollout strategy, integration points, edge cases.
85
+ - **TechSpec dimensions:** domain placement, data flow, dependencies, core interfaces, test strategy, reuse-vs-build, multi-project integration (when applicable).
86
+
87
+ For each stage: build the matrix, mark each dimension `covered` (fact discovered or aligned evidence credited) or `uncovered`, then ask only the `uncovered` ones — one decision per turn, each with a recommended answer. **Technical decisions a product Grill did not cover may still be asked during TechSpec** — Grill aligns product vocabulary and product decisions, not the full technical design.
59
88
 
60
89
  ## Constitution Gate
61
90
 
@@ -78,11 +107,11 @@ Runs when default mode OR `plan prd`.
78
107
 
79
108
  ### Prerequisites for this stage
80
109
  - Idea or topic from the user.
81
- - (Optional) brainstorm one-pager from `/dw-brainstorm --onepager` at `.dw/spec/ideas/<slug>.md`.
110
+ - (Optional) an idea one-pager from `/dw-brainstorm` at `.dw/spec/ideas/<slug>.md`. If it is `status: aligned` (schema `1.1`, from a Grill session), consume it as a handoff — its Resolved Decisions are credited, not re-asked (see Coverage-driven interview).
82
111
 
83
112
  ### Required behavior
84
113
 
85
- 1. **Clarification questions (MINIMUM 7).** Before writing anything, use the structured interview tool when available to ask 7+ focused questions covering: goals, target users, scope boundaries, success metrics, rollout strategy, integration points, edge cases. If the tool is unavailable, use chat fallback and record that fallback.
114
+ 1. **Coverage matrix over the PRD dimensions** (goals, target users, scope boundaries, success metrics, rollout strategy, integration points, edge cases). Build the matrix, credit any aligned-handoff evidence and facts discovered from the repo, then ask ONLY the uncovered dimensions — one decision at a time, each with a recommended answer — using the structured interview tool when available (record the chat fallback otherwise). No fixed question count; never re-ask a decision resolved in an aligned one-pager.
86
115
  2. **Web search MINIMUM 3 queries** for market patterns, regulatory context, competitor approaches when relevant.
87
116
  3. **Constitution alignment.** Each functional requirement (FR-N.M) includes a `Constitution Alignment: respects P-NNN, P-MMM` line OR `no applicable principle: <reason>`.
88
117
  4. **Multi-project awareness.** If the feature spans multiple projects in the workspace, consult `.dw/rules/integrations.md` and document scope in the PRD's "Impacted Projects" section.
@@ -106,7 +135,7 @@ Runs when default mode (after PRD approval) OR `plan techspec` OR `plan --from t
106
135
  ### Required behavior
107
136
 
108
137
  1. **Hard gate: PRD open questions.** If `.dw/spec/prd-<feature>/prd.md` has an "Open Questions" section with unresolved items, STOP and ask the user to resolve them first.
109
- 2. **Clarification questions (MINIMUM 7).** Use the structured interview tool when available to ask technical questions covering: domain placement, data flow, dependencies, core interfaces, test strategy, reuse-vs-build, multi-project integration if applicable. If the tool is unavailable, use chat fallback and record that fallback.
138
+ 2. **Coverage matrix over the TechSpec dimensions** (domain placement, data flow, dependencies, core interfaces, test strategy, reuse-vs-build, multi-project integration when applicable). Credit aligned-handoff evidence and discovered facts, then ask ONLY uncovered dimensions — one decision at a time — using the structured interview tool when available (record the chat fallback otherwise). Technical decisions not covered by a product Grill may still be asked here. No fixed question count.
110
139
  3. **Web search MINIMUM 3 queries** for technical patterns + Context7 MCP for framework/library specifics.
111
140
  4. **Source grounding (`dw-source-grounding`).** Every framework/library decision ships with `[source: <url>, version: X.Y, retrieved: YYYY-MM-DD]`.
112
141
  5. **Constitution gate.** Each architectural decision lists `Respects: P-NNN` or `Deviates: P-NNN — justification: <ADR slug or rationale>`. Deviations from `severity: high/critical` principles without ADR → STOP.
@@ -187,7 +216,7 @@ After full plan run, the PRD directory contains:
187
216
 
188
217
  ## Final Guidelines
189
218
 
190
- - Each stage has its own clarification question quota — don't recycle. Different stages need different framing. Use the structured interview tool whenever available.
219
+ - Each stage runs a coverage matrix over its own dimensions — no fixed question quota. Credit aligned-handoff evidence and discovered facts; ask only uncovered decisions, one at a time. Different stages need different framing. Use the structured interview tool whenever available.
191
220
  - Web search is mandatory; Context7 MCP for libraries. No skipping for "I think I know the latest version."
192
221
  - Constitution gate runs at every stage entry; defaults are auto-installed when missing (never blocks).
193
222
  - All three stages produce committed Markdown — these are the canonical planning artifacts. They evolve with the feature.
@@ -3,8 +3,9 @@ id: NNN
3
3
  status: Proposed
4
4
  title: [Short imperative title of the decision]
5
5
  date: YYYY-MM-DD
6
- prd: [PRD slug, e.g. prd-user-auth]
7
- schema_version: "1.0"
6
+ scope: repo | prd
7
+ prd: [PRD slug for scope=prd, e.g. prd-user-auth; "n/a" for scope=repo]
8
+ schema_version: "1.1"
8
9
  supersedes: null
9
10
  superseded_by: null
10
11
  ---
@@ -46,8 +47,11 @@ Proposed | Accepted | Deprecated | Superseded by ADR-XXX
46
47
 
47
48
  ## Related
48
49
 
49
- - PRD: `.dw/spec/[prd-slug]/prd.md`
50
- - TechSpec: `.dw/spec/[prd-slug]/techspec.md` (if applicable)
50
+ <!-- scope=prd: link the owning PRD/TechSpec. scope=repo: no owning PRD — omit the PRD/TechSpec lines
51
+ (or write "n/a") and link `.dw/constitution.md` / `.dw/rules/` only when they genuinely apply. -->
52
+
53
+ - PRD: `.dw/spec/[prd-slug]/prd.md` (scope=prd only; "n/a" for scope=repo)
54
+ - TechSpec: `.dw/spec/[prd-slug]/techspec.md` (if applicable; scope=prd only)
51
55
  - Affected tasks: [task list, if applicable]
52
56
  - Related ADRs: [list, if applicable]
53
57
 
@@ -1,11 +1,19 @@
1
1
  ---
2
2
  type: idea-onepager
3
- schema_version: "1.0"
4
- status: draft
3
+ schema_version: "1.1"
4
+ status: draft | paused | aligned
5
5
  date: YYYY-MM-DD
6
6
  classification: improves | consolidates | new
7
+ alignment:
8
+ confirmed_by_user: false # set true ONLY when the user explicitly confirms shared understanding
9
+ confirmed_on: null # ISO date of that confirmation
7
10
  ---
8
11
 
12
+ > **Schema 1.1.** The `## Grill Alignment` block below is populated by a `/dw-brainstorm` grill session. Without a
13
+ > Grill, leave that block empty and keep `status: draft`. `status: aligned` is allowed ONLY when every dependency
14
+ > branch is resolved, glossary/code contradictions are closed, no blocking decision remains, and the user has
15
+ > explicitly confirmed shared understanding — otherwise use `draft` or `paused`.
16
+
9
17
  # Idea: [Short, imperative title]
10
18
 
11
19
  ## Problem Statement
@@ -81,6 +89,40 @@ Ideally 2-4 stories. If it's more than 5, it's probably not MVP.]
81
89
  - [Question 1 affecting scope]
82
90
  - [Question 2 affecting priority]
83
91
 
92
+ ## Grill Alignment
93
+
94
+ _(schema 1.1 — filled by a `/dw-brainstorm` grill session; consumed by `/dw-plan`, which does NOT re-ask resolved decisions. Leave empty for a non-grilled one-pager.)_
95
+
96
+ ### Resolved Decisions
97
+
98
+ | Decision | Recommended | Chosen | Alternative rejected | Evidence |
99
+ |----------|-------------|--------|----------------------|----------|
100
+ | [the decision] | [what Grill recommended] | [what the user chose] | [the rejected option + its trade-off] | [one-pager/repo source] |
101
+
102
+ ### Evidence
103
+
104
+ [Facts discovered during Grill from the repo/rules/intel/docs — each with its source (`path:line`, doc, or intel query) — that were used instead of asking the user.]
105
+
106
+ - **[fact]** — source: `[path:line or doc]`
107
+
108
+ ### Canonical Vocabulary
109
+
110
+ [Links into `.dw/domain/**` for the terms this idea depends on. Do not restate definitions here — point to the glossary.]
111
+
112
+ - **[Term]** → `.dw/domain/glossary.md#term` (or `.dw/domain/contexts/<slug>.md#term` for a multi-context project)
113
+
114
+ ### Remaining Decisions
115
+
116
+ [Non-blocking decisions still open after alignment, with their owner. A blocking decision means the one-pager is NOT `aligned`.]
117
+
118
+ - **[open decision]** — owner: [who] — blocking? [no]
119
+
120
+ ### Alignment State
121
+
122
+ - **State:** `draft` | `paused` | `aligned`
123
+ - **Shared understanding confirmed by user:** [yes/no — `aligned` requires an explicit yes]
124
+ - **Why not aligned (if draft/paused):** [the blocking node or unclosed contradiction that stopped alignment]
125
+
84
126
  ## Next Step
85
127
 
86
128
  Pick ONE: