@brunosps00/dev-workflow 1.0.5 → 1.1.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 (55) hide show
  1. package/README.md +17 -13
  2. package/bin/dev-workflow.js +5 -0
  3. package/lib/constants.js +6 -4
  4. package/lib/install-deps.js +88 -3
  5. package/lib/setup-wsl-browser.js +149 -0
  6. package/package.json +1 -1
  7. package/scaffold/en/agent-instructions.md +7 -5
  8. package/scaffold/en/commands/dw-analyze-project.md +22 -0
  9. package/scaffold/en/commands/dw-autopilot.md +158 -275
  10. package/scaffold/en/commands/dw-bugfix.md +3 -2
  11. package/scaffold/en/commands/dw-functional-doc.md +11 -3
  12. package/scaffold/en/commands/dw-generate-pr.md +2 -2
  13. package/scaffold/en/commands/dw-goal.md +136 -0
  14. package/scaffold/en/commands/dw-help.md +9 -7
  15. package/scaffold/en/commands/dw-plan.md +9 -3
  16. package/scaffold/en/commands/dw-qa.md +1 -1
  17. package/scaffold/en/commands/dw-redesign-ui.md +2 -2
  18. package/scaffold/en/commands/dw-review.md +7 -5
  19. package/scaffold/en/commands/dw-secure-audit.md +72 -15
  20. package/scaffold/en/templates/constitution-template.md +8 -3
  21. package/scaffold/en/templates/functional-doc/playwright.flow.mjs.tpl +17 -0
  22. package/scaffold/pt-br/agent-instructions.md +7 -5
  23. package/scaffold/pt-br/commands/dw-analyze-project.md +22 -0
  24. package/scaffold/pt-br/commands/dw-autopilot.md +161 -278
  25. package/scaffold/pt-br/commands/dw-bugfix.md +3 -2
  26. package/scaffold/pt-br/commands/dw-functional-doc.md +11 -3
  27. package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
  28. package/scaffold/pt-br/commands/dw-goal.md +136 -0
  29. package/scaffold/pt-br/commands/dw-help.md +9 -7
  30. package/scaffold/pt-br/commands/dw-plan.md +9 -3
  31. package/scaffold/pt-br/commands/dw-qa.md +1 -1
  32. package/scaffold/pt-br/commands/dw-redesign-ui.md +2 -2
  33. package/scaffold/pt-br/commands/dw-review.md +7 -5
  34. package/scaffold/pt-br/commands/dw-secure-audit.md +72 -15
  35. package/scaffold/pt-br/templates/constitution-template.md +8 -3
  36. package/scaffold/pt-br/templates/functional-doc/playwright.flow.mjs.tpl +17 -0
  37. package/scaffold/scripts/cdp-relay/Cargo.toml +16 -0
  38. package/scaffold/scripts/cdp-relay/src/main.rs +49 -0
  39. package/scaffold/scripts/functional-doc/generate-dossier.mjs +7 -9
  40. package/scaffold/scripts/functional-doc/run-playwright-flow.mjs +192 -183
  41. package/scaffold/scripts/lib/capture-screenshots.mjs +133 -0
  42. package/scaffold/scripts/lib/resolve-browser.mjs +405 -0
  43. package/scaffold/scripts/lib/ui-slop-detect.mjs +102 -0
  44. package/scaffold/skills/dw-testing-discipline/references/playwright-recipes.md +50 -0
  45. package/scaffold/skills/dw-ui-discipline/SKILL.md +5 -0
  46. package/scaffold/skills/dw-ui-discipline/references/color-oklch.md +60 -0
  47. package/scaffold/skills/dw-ui-discipline/references/motion.md +52 -0
  48. package/scaffold/skills/dw-ui-discipline/references/responsive.md +52 -0
  49. package/scaffold/skills/dw-ui-discipline/references/type-scale.md +48 -0
  50. package/scaffold/skills/dw-ui-discipline/references/ux-writing.md +52 -0
  51. package/scaffold/skills/security-review/SKILL.md +19 -0
  52. package/scaffold/skills/security-review/references/sast.md +67 -0
  53. package/scaffold/skills/security-review/references/secrets.md +46 -0
  54. package/scaffold/en/templates/functional-doc/playwright.spec.ts.tpl +0 -19
  55. package/scaffold/pt-br/templates/functional-doc/playwright.spec.ts.tpl +0 -19
@@ -0,0 +1,136 @@
1
+ <system_instructions>
2
+ You are the dev-workflow durable goal orchestrator. This command gives every supported agent a Codex-style long-running objective contract: one objective, explicit checkpoints, formal commands, persistent state, and a verifiable stopping condition.
3
+
4
+ ## When to Use
5
+ - Use when a workflow is larger than one normal turn but has a clear finish line.
6
+ - Use after `/dw-plan` when implementation, review, QA, and post-QA review should run as one durable loop.
7
+ - Use from `/dw-autopilot` after the first invocation has completed PRD → TechSpec → Tasks.
8
+ - Do NOT use for loose backlogs, unrelated task lists, or exploratory brainstorming.
9
+
10
+ ## Position in Pipeline
11
+ **Predecessor:** `/dw-plan` or `/dw-autopilot` plan phase | **Successor:** `/dw-commit` + `/dw-generate-pr`
12
+
13
+ ## Modes
14
+
15
+ | Invocation | Behavior |
16
+ |------------|----------|
17
+ | `/dw-goal "<objective>"` | Create and execute a manual durable goal. |
18
+ | `/dw-goal --from-autopilot <prd-slug>` | Create and execute the standard autopilot execution-quality goal for an existing PRD. |
19
+ | `/dw-goal status` | Show the active goal, checkpoint, last verification, and blockers. |
20
+ | `/dw-goal pause` | Mark the active goal paused without deleting state. |
21
+ | `/dw-goal resume` | Resume the paused or interrupted goal from `status.json`. |
22
+ | `/dw-goal clear` | Clear the active goal only after it is complete, cancelled, or explicitly replaced. |
23
+
24
+ ## Native Codex Bridge
25
+
26
+ <critical>`/dw-goal` is portable. The canonical state lives in `.dw/goals/` even when Codex native `/goal` is available.</critical>
27
+
28
+ Official Codex guidance treats `/goal` as an experimental durable objective for long-running work with a verifiable stopping condition. In Codex CLI it requires `features.goals`; it can be set with `/goal <objective>`, inspected with `/goal`, and controlled with `/goal pause`, `/goal resume`, or `/goal clear`.
29
+
30
+ When running in Codex:
31
+ - If a native goal tool is available, create/update it with a short objective pointing to `.dw/goals/<slug>/goal.md`.
32
+ - If the interactive `/goal` slash command is available and `features.goals` is enabled, use `/goal <objective>` with an objective under 4,000 characters.
33
+ - If native goals are unavailable, continue with the portable `.dw/goals/` loop. Do not block.
34
+
35
+ Native Codex objective format:
36
+
37
+ ```text
38
+ Execute the durable goal defined in .dw/goals/<goal-slug>/goal.md until its verifiable stopping condition is met. Update .dw/goals/<goal-slug>/progress.md after every checkpoint.
39
+ ```
40
+
41
+ ## Persistent State
42
+
43
+ Create `.dw/goals/<goal-slug>/` with:
44
+
45
+ ```
46
+ .dw/goals/<goal-slug>/
47
+ ├── goal.md
48
+ ├── status.json
49
+ └── progress.md
50
+ ```
51
+
52
+ `goal.md` MUST include:
53
+ - One objective.
54
+ - In scope / out of scope.
55
+ - Input artifacts to read first.
56
+ - Checkpoints in order.
57
+ - Formal `/dw-*` commands to invoke.
58
+ - Required artifacts per checkpoint.
59
+ - Verifiable stopping condition.
60
+ - Block conditions.
61
+ - Resume policy.
62
+
63
+ `status.json` MUST use this shape:
64
+
65
+ ```json
66
+ {
67
+ "schema_version": "1.0",
68
+ "slug": "goal-prd-example",
69
+ "source": "manual",
70
+ "prd_path": null,
71
+ "status": "active",
72
+ "current_checkpoint": "start",
73
+ "completed_checkpoints": [],
74
+ "required_artifacts": [],
75
+ "last_verification": null,
76
+ "created_at": "2026-05-20T00:00:00Z",
77
+ "updated_at": "2026-05-20T00:00:00Z"
78
+ }
79
+ ```
80
+
81
+ `progress.md` is append-only. Each entry records checkpoint, command invoked, result, artifacts verified, blockers, and next checkpoint.
82
+
83
+ ## Autopilot Goal
84
+
85
+ When invoked as `/dw-goal --from-autopilot <prd-slug>`:
86
+
87
+ 1. Resolve `<prd-slug>` to `.dw/spec/<prd-slug>/`.
88
+ 2. Verify `prd.md`, `techspec.md`, `tasks.md`, per-task files, and `tasks-validation.md` exist.
89
+ 3. Create goal slug `autopilot-<prd-slug>`.
90
+ 4. Write `goal.md` with this objective:
91
+
92
+ ```text
93
+ Complete implementation and quality validation for .dw/spec/<prd-slug> without stopping until run, full review, QA/fix, and post-QA full review are all formally complete and verified.
94
+ ```
95
+
96
+ Checkpoints:
97
+
98
+ | Checkpoint | Formal command | Completion evidence |
99
+ |------------|----------------|---------------------|
100
+ | `run` | `/dw-run <prd-path>` | Tasks done, task commits present, run log or task status updated. |
101
+ | `review-before-qa` | `/dw-review <prd-path>` | `<prd-path>/QA/review-consolidated.md` exists and overall verdict is approved or approved with explicit non-blocking caveats. |
102
+ | `qa` | `/dw-qa <prd-path>` | Required QA artifacts exist. |
103
+ | `qa-fix` | `/dw-qa --fix <prd-path>` when `bugs.md` has Open bugs | Bugs are Fixed/Closed or explicitly deferred by user. |
104
+ | `review-after-qa` | `/dw-review <prd-path>` | Consolidated review exists after QA fixes and is approved or approved with explicit non-blocking caveats. |
105
+
106
+ The goal is complete only when:
107
+ - All checkpoints above are complete or explicitly skipped with a documented reason.
108
+ - No Open QA bug remains unless the user explicitly accepted deferral.
109
+ - The final `/dw-review` ran after the last QA fix.
110
+ - `status.json` has `"status": "complete"`.
111
+
112
+ ## Execution Rules
113
+
114
+ <critical>Every checkpoint that invokes a `/dw-*` command MUST invoke the formal command and follow its complete `.dw/commands/` instructions. Manual equivalents do not count.</critical>
115
+
116
+ - Before each checkpoint, append a `progress.md` entry and update `status.json.current_checkpoint`.
117
+ - After each checkpoint, verify required artifacts with `ls` or equivalent inspection before marking complete.
118
+ - If a command fails, fix according to that command's own loop, then re-run it.
119
+ - If the same blocker repeats for 3 consecutive goal turns and no meaningful progress is possible, mark `status: "blocked"` and surface the blocker.
120
+ - Keep progress updates compact: current checkpoint, verification result, remaining checkpoints, blocker if any.
121
+
122
+ ## Status Commands
123
+
124
+ - `status`: read `status.json` and last 10 entries of `progress.md`; report current checkpoint, completed checkpoints, last verification, and blockers.
125
+ - `pause`: set `status: "paused"` and append why.
126
+ - `resume`: set `status: "active"` and continue from `current_checkpoint`; do not repeat completed checkpoints unless artifacts are missing.
127
+ - `clear`: if complete/cancelled/replaced, mark `status: "cancelled"` or archive according to project convention. Do not delete evidence by default.
128
+
129
+ ## Anti-patterns
130
+
131
+ - Do not create a goal with multiple unrelated objectives.
132
+ - Do not use `/dw-goal` to bypass `/dw-plan`; goals execute a defined plan, they do not invent scope.
133
+ - Do not mark a checkpoint complete without checking artifacts.
134
+ - Do not use native Codex `/goal` as the only state; `.dw/goals/` remains the cross-agent contract.
135
+
136
+ </system_instructions>
@@ -19,7 +19,7 @@ Use `/dw-autopilot "wish"` as the gateway for most feature work. The granular co
19
19
 
20
20
  | Command | When |
21
21
  |---------|------|
22
- | `/dw-autopilot "wish"` | Default entry point. PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR. Three approval gates. |
22
+ | `/dw-autopilot "wish"` | Default entry point in two invocations. First run plans and stops; second run resumes through `/dw-goal`, commit, and PR. |
23
23
  | `/dw-bugfix "description"` | A bug or error report. Surgical fix or PRD route. |
24
24
  | `/dw-help [keyword]` | This screen. Pass a keyword for shortcuts. `--advanced` reveals internal commands. |
25
25
 
@@ -50,15 +50,15 @@ Use `/dw-autopilot "wish"` as the gateway for most feature work. The granular co
50
50
 
51
51
  ## Workflow at a glance
52
52
 
53
- `/dw-autopilot "wish"` runs the full pipeline (PRD → ... → PR) with 3 gates. Step-by-step:
53
+ `/dw-autopilot "wish"` runs planning first and stops. Reinvoke it to resume through `/dw-goal`, commit, and PR. Step-by-step:
54
54
 
55
55
  ```
56
- /dw-brainstorm → /dw-plan → /dw-run → /dw-qa → /dw-review → /dw-commit → /dw-generate-pr
56
+ /dw-brainstorm → /dw-plan → /dw-goal → /dw-commit → /dw-generate-pr
57
57
  ```
58
58
 
59
59
  ## Advanced / internal commands
60
60
 
61
- Pass `--advanced` to `/dw-help` to see internal commands (`dw-adr`, `dw-intel`, `dw-secure-audit`, `dw-find-skills`, `dw-update`, `dw-subtask-start`, `dw-subtask-complete`, `dw-subtask-resume`) that are usually invoked by other commands.
61
+ Pass `--advanced` to `/dw-help` to see internal commands (`dw-adr`, `dw-intel`, `dw-secure-audit`, `dw-goal`, `dw-find-skills`, `dw-update`, `dw-subtask-start`, `dw-subtask-complete`, `dw-subtask-resume`) that are usually invoked by other commands.
62
62
  ```
63
63
 
64
64
  ## Advanced mode — `--advanced` flag
@@ -70,13 +70,14 @@ When invoked with `--advanced`, ALSO show:
70
70
 
71
71
  These are auto-invoked by primary commands but available standalone.
72
72
 
73
- ## Tier 4 — Hidden (8)
73
+ ## Tier 4 — Hidden (9)
74
74
 
75
75
  | Command | What | Invoked by |
76
76
  |---------|------|------------|
77
77
  | `/dw-adr "decision"` | Record an Architecture Decision Record at `.dw/spec/<prd>/adrs/`. | `/dw-plan techspec --council`, deviations from constitution |
78
78
  | `/dw-intel "question"` | Query codebase intelligence; `--build` (re)indexes `.dw/intel/`. | `/dw-plan`, `/dw-review`, `/dw-bugfix` |
79
79
  | `/dw-secure-audit` | OWASP + Trivy + lockfile + supply-chain scan. Hard gate. Flags: `--scan-only`, `--plan`, `--execute`. | `/dw-review`, `/dw-generate-pr` |
80
+ | `/dw-goal "<objective>"` | Durable objective contract with `.dw/goals/`; bridges to Codex native `/goal` when available. | `/dw-autopilot` after planning |
80
81
  | `/dw-find-skills "query"` | Search npx skills ecosystem, vet, install. | manual when extending the bundle |
81
82
  | `/dw-update` | Update dev-workflow to latest npm release with rollback snapshot. | manual maintenance |
82
83
  | `/dw-subtask-start "goal"` | Create a minimal input packet for a subagent. | parent agent before delegation |
@@ -93,6 +94,7 @@ Match the keyword and suggest:
93
94
  | `prd`, `spec`, `plan`, `architecture`, `techspec`, `tasks` | `/dw-plan` (with appropriate stage flag) |
94
95
  | `bug`, `error`, `broken`, `fix` | `/dw-bugfix` |
95
96
  | `run`, `execute`, `implement` | `/dw-run` |
97
+ | `goal`, `objective`, `long-running`, `resume autopilot` | `/dw-goal` or `/dw-autopilot` if `autopilot-state.json` exists |
96
98
  | `review`, `quality`, `audit code` | `/dw-review` |
97
99
  | `qa`, `test plan`, `e2e` | `/dw-qa` |
98
100
  | `commit`, `git` | `/dw-commit` |
@@ -121,10 +123,10 @@ If no keyword matches, show the default surface and a note: "Keyword `<word>` no
121
123
  ## FAQ
122
124
 
123
125
  **Q: I'm not sure where to start with a new feature.**
124
- - Use `/dw-autopilot "what you want"`. It runs PRD → TechSpec → Tasks → Run → Review → PR with three approval gates.
126
+ - Use `/dw-autopilot "what you want"`. First invocation runs PRD → TechSpec → Tasks and stops; second invocation resumes through `/dw-goal`, commit, and PR.
125
127
 
126
128
  **Q: Do I have to use `/dw-autopilot`?**
127
- - No. The granular pipeline (`/dw-brainstorm` → `/dw-plan` → `/dw-run` → `/dw-qa` → `/dw-review` → `/dw-commit` → `/dw-generate-pr`) gives you control at each step.
129
+ - No. The granular pipeline (`/dw-brainstorm` → `/dw-plan` → `/dw-goal` or `/dw-run`/`/dw-qa`/`/dw-review` → `/dw-commit` → `/dw-generate-pr`) gives you control at each step.
128
130
 
129
131
  **Q: I just want to fix a bug.**
130
132
  - `/dw-bugfix "<bug description>"`. It triages (bug vs feature vs scope), asks 3 questions, then fixes or routes to a PRD if scope is large.
@@ -50,6 +50,12 @@ When project agents are installed, use:
50
50
 
51
51
  Claude Code and OpenCode can use native project agents. Codex and Copilot use `.agents/agents/` plus these instructions as the fallback dispatch contract.
52
52
 
53
+ ## Structured Interview Tool
54
+
55
+ <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>
56
+
57
+ 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
+
53
59
  ## Constitution Gate
54
60
 
55
61
  <critical>BEFORE any stage, check `.dw/constitution.md`. If MISSING, copy `templates/constitution-template.md` to `.dw/constitution.md` (severity=info defaults), notify the user in chat, and continue. If PRESENT, every FR (PRD), every architectural decision (TechSpec), and every task (Tasks) carries Constitution Alignment metadata mapping to relevant principles or declaring deviation.</critical>
@@ -73,7 +79,7 @@ Runs when default mode OR `plan prd`.
73
79
 
74
80
  ### Required behavior
75
81
 
76
- 1. **Clarification questions (MINIMUM 7).** Before writing anything, ask 7+ focused questions covering: goals, target users, scope boundaries, success metrics, rollout strategy, integration points, edge cases.
82
+ 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.
77
83
  2. **Web search MINIMUM 3 queries** for market patterns, regulatory context, competitor approaches when relevant.
78
84
  3. **Constitution alignment.** Each functional requirement (FR-N.M) includes a `Constitution Alignment: respects P-NNN, P-MMM` line OR `no applicable principle: <reason>`.
79
85
  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.
@@ -97,7 +103,7 @@ Runs when default mode (after PRD approval) OR `plan techspec` OR `plan --from t
97
103
  ### Required behavior
98
104
 
99
105
  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.
100
- 2. **Clarification questions (MINIMUM 7).** Technical questions covering: domain placement, data flow, dependencies, core interfaces, test strategy, reuse-vs-build, multi-project integration if applicable.
106
+ 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.
101
107
  3. **Web search MINIMUM 3 queries** for technical patterns + Context7 MCP for framework/library specifics.
102
108
  4. **Source grounding (`dw-source-grounding`).** Every framework/library decision ships with `[source: <url>, version: X.Y, retrieved: YYYY-MM-DD]`.
103
109
  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.
@@ -178,7 +184,7 @@ After full plan run, the PRD directory contains:
178
184
 
179
185
  ## Final Guidelines
180
186
 
181
- - Each stage has its own clarification question quota — don't recycle. Different stages need different framing.
187
+ - Each stage has its own clarification question quota — don't recycle. Different stages need different framing. Use the structured interview tool whenever available.
182
188
  - Web search is mandatory; Context7 MCP for libraries. No skipping for "I think I know the latest version."
183
189
  - Constitution gate runs at every stage entry; defaults are auto-installed when missing (never blocks).
184
190
  - All three stages produce committed Markdown — these are the canonical planning artifacts. They evolve with the feature.
@@ -83,7 +83,7 @@ When available under `./.agents/skills/`, these are invoked operationally:
83
83
 
84
84
  1. **Pre-flight**: confirm the project dev server can run. Confirm `.dw/spec/<prd>/` has the PRD + TechSpec + tasks.
85
85
  2. **Map FRs to test plan**: for each FR, identify the user-facing flow that exercises it.
86
- 3. **Drive Playwright MCP** (or fallback to local Playwright per `dw-testing-discipline/references/playwright-recipes.md`):
86
+ 3. **Drive Playwright MCP** (if unavailable or blocked — common on WSL — fall back to the WSL-resilient local capture `node .dw/scripts/lib/capture-screenshots.mjs`, which picks the browser via `.dw/scripts/lib/resolve-browser.mjs`; see the "Browser on WSL" section of `dw-testing-discipline/references/playwright-recipes.md`):
87
87
  - Happy paths for each FR.
88
88
  - Edge cases (boundary inputs, network failure, validation errors).
89
89
  - Negative flows (unauthorized actions, malformed input).
@@ -56,12 +56,12 @@ Use diagnostic tools based on the project's framework:
56
56
  ## Required Behavior
57
57
 
58
58
  1. Identify the target: page, component, or route to be redesigned.
59
- 2. **AUDIT**: read the current implementation, identify the CSS stack (Tailwind, CSS Modules, styled-components, etc.), capture screenshot using `dw-testing-discipline`/playwright-recipes if available, run react-doctor if React project.
59
+ 2. **AUDIT**: read the current implementation, identify the CSS stack (Tailwind, CSS Modules, styled-components, etc.), capture the before-state screenshot (Playwright MCP, or `node .dw/scripts/lib/capture-screenshots.mjs` as the WSL-resilient fallback), run react-doctor if React project.
60
60
  3. Ask 3 to 5 questions about redesign goals: style direction, brand constraints, inspirations, target audience, priority devices.
61
61
  4. **PROPOSE**: present 2 to 3 design directions after passing the `dw-ui-discipline` hard-gate (brand authorities or curated defaults selected; surface job sentence written; state matrix enumerated; scene sentence written). Each direction lists color palette, typography pairing, layout style, and rationale. Self-check each direction against the 14 anti-slop patterns. For EACH direction, explicitly describe the mobile layout (<=768px) and desktop layout (>=1024px), including how elements reorganize, stack, or hide between breakpoints.
62
62
  5. Wait for explicit user approval before implementing.
63
63
  6. **IMPLEMENT**: apply the chosen design with a mobile-first approach — implement the mobile layout first, then add media queries/breakpoints for tablet and desktop. Respect the existing stack. Use `vercel-react-best-practices` for React/Next.js. Maintain the project's CSS methodology.
64
- 7. **VALIDATE**: capture after-state in BOTH resolutions (mobile and desktop), compare before/after, verify accessibility against `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — non-negotiable: contrast, focus-visible, keyboard nav, ARIA, no traps), run react-doctor `--diff` if React. Use `dw-testing-discipline/references/playwright-recipes.md` to capture screenshots at 375px viewport (mobile) and 1440px viewport (desktop).
64
+ 7. **VALIDATE**: capture after-state in BOTH resolutions (mobile and desktop), compare before/after, verify accessibility against `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — non-negotiable: contrast, focus-visible, keyboard nav, ARIA, no traps), run react-doctor `--diff` if React. Capture screenshots at 375px (mobile) and 1440px (desktop) — `node .dw/scripts/lib/capture-screenshots.mjs --url <url> --widths 375,1440` is the WSL-resilient path; see the "Browser on WSL" section of `dw-testing-discipline/references/playwright-recipes.md`.
65
65
  8. **PERSIST CONTRACT**: if the user approved a direction, generate `design-contract.md` in the PRD directory (`.dw/spec/prd-[name]/design-contract.md`) with: approved direction, color palette, typography pairing, layout rules, accessibility rules, and component rules. This contract will be read by `dw-run-task` and `dw-run-plan` to ensure visual consistency.
66
66
 
67
67
  ## Codebase Intelligence
@@ -44,9 +44,10 @@ When available under `./.agents/skills/`, these are invoked as analytical suppor
44
44
 
45
45
  - `dw-review-rigor`: **ALWAYS** — applies de-duplication (same pattern in N files = 1 finding), severity ordering (critical → high → medium → low), verify-before-flag, skip-what-linter-catches, and signal-over-volume. The "Issues Found" table follows this discipline.
46
46
  - `dw-verify`: **ALWAYS** — invoked before emitting `APPROVED` or `APPROVED WITH CAVEATS`. Without a VERIFICATION REPORT PASS (test + lint + build), verdict cannot be APPROVED.
47
- - `dw-secure-audit`: **ALWAYS for TS/Python/C#/Rust projects** — security gate. If the project uses a supported language and a recent `secure-audit.md` is missing OR has REJECTED status, the verdict is **REJECTED** — no exception.
47
+ - `dw-secure-audit` (**Security Gate**): **ALWAYS for TS/Python/C#/Rust projects** — triggered here and the verdict is enforced. If the project's language is supported and a fresh `.dw/secure-audit/audit-summary.md` is missing OR has REJECTED status, the review verdict is **REJECTED** — no exception. The same gate is also a standalone command (`/dw-secure-audit`) and an explicit phase in `/dw-autopilot`. It now adds Semgrep SAST (diff) + gitleaks secrets on top of OWASP/Trivy/SCA.
48
+ - `security-review`: the OWASP diff-level skill the gate uses (injection, authz, secrets, SSRF, crypto — HIGH CONFIDENCE only).
48
49
  - `dw-simplification`: use when the diff touches dense or twisty code — applies Chesterton's Fence, behavior-preserving refactor protocol, complexity metrics.
49
- - `dw-ui-discipline`: use when the diff touches UI — runs the 14 visual-slop patterns + accessibility floor checks.
50
+ - `dw-ui-discipline`: use when the diff touches UI — runs the 14 visual-slop patterns + accessibility floor checks. For a deterministic gate, also run `node .dw/scripts/lib/ui-slop-detect.mjs <changed-ui-paths> --fail-on error` (a wrapper over the impeccable detector); treat blocking findings as **REJECTED** and surface warnings in the report.
50
51
  - `dw-testing-discipline`: use when the diff touches tests — applies the 25 anti-patterns catalog + 6 agent guardrails (when tests were agent-authored).
51
52
  - `dw-llm-eval`: **REQUIRED when the diff touches AI/LLM feature code paths**. Reference dataset + ≥2 oracle rungs + judge calibration (if rung 4 used) + eval run results MUST be in the PR. Missing → REJECTED.
52
53
  - `security-review`: use when the diff touches auth, authorization, external input, upload, SQL, secrets, SSRF, XSS, or sensitive surfaces.
@@ -161,9 +162,10 @@ If MISSING > 0, the verdict suggests revisiting `/dw-plan tasks` to scope or `/d
161
162
  - Run dw-verify to produce a VERIFICATION REPORT (test + lint + build all GREEN).
162
163
  - Without PASS, verdict cannot be APPROVED.
163
164
 
164
- 8. **Security Layer (`dw-secure-audit` for TS/Python/C#/Rust):**
165
- - Run `/dw-secure-audit` against the PR. Latest scan must be present and not REJECTED.
166
- - If language is supported and audit is missing OR REJECTED → verdict **REJECTED**.
165
+ 8. **Security Gate (`dw-secure-audit` for TS/Python/C#/Rust):**
166
+ - Trigger `/dw-secure-audit` against the diff (OWASP + Semgrep SAST + gitleaks + Trivy/SCA + supply-chain). It produces/refreshes `.dw/secure-audit/audit-summary.md`.
167
+ - Latest scan must be present, fresh (post-last-edit), and not REJECTED. If language is supported and the audit is missing OR REJECTED → review verdict **REJECTED**. SECRET findings always block (no ADR escape).
168
+ - The same gate is also runnable standalone (`/dw-secure-audit`) and is an explicit phase in `/dw-autopilot`; `/dw-generate-pr` re-enforces the verdict before the PR.
167
169
 
168
170
  ### Output
169
171
 
@@ -1,7 +1,13 @@
1
1
  <system_instructions>
2
- You are the security audit orchestrator. Runs OWASP static review + supply-chain CVE/secret/IaC scanning + dependency outdated check + supply-chain compromise detection in one pass. Hard-gates downstream commands when CRITICAL or HIGH findings exist.
2
+ You are the security audit orchestrator — the **Security Gate**. Runs OWASP static review + SAST
3
+ (Semgrep, diff-focused on the generated code) + dedicated secret scanning (gitleaks) + supply-chain
4
+ CVE/secret/IaC scanning (Trivy + native lockfile audit) + supply-chain compromise detection + outdated
5
+ check, in one pass. Hard-gates downstream commands when any blocking finding exists.
3
6
 
4
- Auto-invoked by `/dw-review` and `/dw-generate-pr` for TS/Python/C#/Rust projects. Standalone invocation available for manual audit.
7
+ It is **auto-invoked by `/dw-review` and `/dw-generate-pr`** (for TS/Python/C#/Rust), runs as an **explicit,
8
+ named phase in `/dw-autopilot`** (after review + QA, before commit/PR), and is **runnable standalone** any
9
+ time. `/dw-generate-pr` re-enforces the verdict as a final hard gate. All three keep gating on security —
10
+ the standalone command and the named phase are additive, not a replacement.
5
11
 
6
12
  ## When to Use
7
13
  - Auto-invoked: `/dw-review` and `/dw-generate-pr` for supported languages.
@@ -10,7 +16,7 @@ Auto-invoked by `/dw-review` and `/dw-generate-pr` for TS/Python/C#/Rust project
10
16
  - Do NOT use as a substitute for human security review on high-stakes auth/payment code (use `security-review` skill PLUS this).
11
17
 
12
18
  ## Pipeline Position
13
- **Predecessor:** any time; auto-invoked by `/dw-review`, `/dw-generate-pr` | **Successor:** `/dw-bugfix` to address findings, or `/dw-commit` if APPROVED
19
+ **Predecessor:** `/dw-review` + `/dw-qa` (the Security Gate runs after they pass) | **Successor:** `/dw-commit` / `/dw-generate-pr` if APPROVED, or `/dw-bugfix` to address findings. Can also run standalone any time.
14
20
 
15
21
  ## Modes
16
22
 
@@ -33,10 +39,20 @@ Auto-invoked by `/dw-review` and `/dw-generate-pr` for TS/Python/C#/Rust project
33
39
 
34
40
  ## Required Dependencies
35
41
 
36
- - **Trivy** — must be installed (via `npx @brunosps00/dev-workflow install-deps`).
42
+ - **Trivy** — SCA / secrets / IaC (via `npx @brunosps00/dev-workflow install-deps`).
43
+ - **Semgrep** — SAST layer (optional but recommended). If absent, the SAST layer is skipped and noted.
44
+ - **gitleaks** — dedicated secret scan (optional but recommended). If absent, falls back to Trivy secrets.
37
45
  - **Context7 MCP** — for framework-version-specific security best practices.
38
46
 
39
- ## Three Detection Layers
47
+ All scanners are optional individually: a missing tool degrades that layer and is **reported** in the
48
+ summary (the gate never crashes for a missing scanner), but the missing coverage is visible. Install via
49
+ `npx @brunosps00/dev-workflow install-deps`.
50
+
51
+ ## Detection Layers
52
+
53
+ **Diff focus (the generated code):** layers that support it scope to the diff against the PR base
54
+ (`git merge-base HEAD origin/main`) so the gate concentrates on the code just written, without noise from
55
+ pre-existing code. A `--full` periodic pass scans the whole tree.
40
56
 
41
57
  ### Layer 1: OWASP Static Review (via `security-review` skill)
42
58
 
@@ -72,6 +88,23 @@ Cross-references the dependency tree against:
72
88
 
73
89
  Output: `.dw/secure-audit/compromise-findings.md` per affected package: COMPROMISED / suspicious / clean.
74
90
 
91
+ ### Layer 4: SAST — Semgrep (semantic analysis of generated code)
92
+
93
+ Deterministic, semantic static analysis of the **diff** (`--baseline-commit`), complementing the human-style
94
+ Layer 1. Pinned rulesets: `p/security-audit`, `p/owasp-top-ten`, `p/secrets` (+ language packs as detected).
95
+ Map Semgrep `ERROR`→HIGH (or CRITICAL for RCE/authn-bypass/SQLi CWEs), `WARNING`→MEDIUM, `INFO`→LOW. Apply
96
+ the **fp-check** reachability discipline before a finding blocks (see `security-review/references/sast.md`).
97
+
98
+ Output: `.dw/secure-audit/sast-findings.md`. If `semgrep` is absent: skipped + noted in the summary.
99
+
100
+ ### Layer 5: Dedicated secret scan — gitleaks
101
+
102
+ `gitleaks protect --staged` (uncommitted) or `gitleaks detect --log-opts <base>..HEAD` (branch), `--redact`.
103
+ Authoritative for the diff; complements Trivy secrets (dedupe by `file:line`). **Any hit = REJECTED, no ADR
104
+ exception** — secrets are removed and rotated, not justified. See `security-review/references/secrets.md`.
105
+
106
+ Output: `.dw/secure-audit/secret-findings.md`. If `gitleaks` is absent: falls back to Trivy secrets + noted.
107
+
75
108
  ### Plus: outdated check
76
109
 
77
110
  `npm outdated` / `pip list --outdated` / `dotnet list outdated` / `cargo outdated` to identify packages behind by minor or major versions.
@@ -84,9 +117,11 @@ All findings are classified into one of these tiers in `.dw/secure-audit/audit-s
84
117
 
85
118
  | Tier | Criteria | Block | Suggested Action |
86
119
  |------|----------|-------|------------------|
120
+ | **SECRET** | Hardcoded credential/key/token (gitleaks or Trivy), survives allowlist | YES — **no ADR exception** | Remove from code + history, rotate, move to a secret store |
87
121
  | **COMPROMISED** | Package known to be malicious in this version range | YES | Immediate remove / pin to safe version |
88
- | **CRITICAL** | CVE CVSS ≥9.0 OR exploits in the wild OR auth bypass | YES | Update or replace within 24h |
89
- | **HIGH** | CVE CVSS 7.0–8.9 OR exploitable in current context | YES | Update or replace within 1 week |
122
+ | **CRITICAL** | CVE CVSS ≥9.0 OR exploits in the wild OR auth bypass; OR SAST high-impact CWE (SQLi/RCE/authn-bypass/SSRF/deserialization) reachable | YES | Update/replace or fix within 24h |
123
+ | **HIGH** | CVE CVSS 7.0–8.9 OR exploitable in context; OR Semgrep `ERROR` reachable (fp-check passed) | YES | Update/replace or fix within 1 week |
124
+ | **MEDIUM / LOW** | CVE CVSS <7.0; OR Semgrep `WARNING`/`INFO`; OR unreachable finding downgraded by fp-check | NO (advisory) | Track and fix routinely |
90
125
  | **OUTDATED-MAJOR** | ≥1 major version behind (e.g., React 17 → 19) | NO | Plan migration in next quarter |
91
126
  | **OUTDATED-MINOR** | Minor/patch behind | NO | Update routinely |
92
127
  | **CLEAN** | No findings | NO | — |
@@ -94,19 +129,26 @@ All findings are classified into one of these tiers in `.dw/secure-audit/audit-s
94
129
  ## Hard Gates
95
130
 
96
131
  The verdict is one of:
97
- - **APPROVED** — no CRITICAL or HIGH or COMPROMISED findings. Verdict file `.dw/secure-audit/audit-summary.md` status: APPROVED.
98
- - **REJECTED** — ≥1 CRITICAL, HIGH, or COMPROMISED finding without explicit ADR or remediation in flight. Verdict file status: REJECTED.
132
+ - **APPROVED** — no SECRET, COMPROMISED, CRITICAL, or HIGH findings. Verdict file `.dw/secure-audit/audit-summary.md` status: APPROVED. (MEDIUM/LOW/outdated may be present as advisory.)
133
+ - **REJECTED** — ≥1 SECRET (always), or ≥1 COMPROMISED/CRITICAL/HIGH without explicit ADR or remediation in flight. Verdict file status: REJECTED.
134
+
135
+ **Rigoroso threshold:** SECRET and COMPROMISED always block. CRITICAL/HIGH (CVE or reachable SAST) block unless an ADR justifies acceptance. MEDIUM/LOW and outdated are advisory. A SECRET is the one tier with **no ADR escape** — rotate, don't justify.
99
136
 
100
137
  **`/dw-review` and `/dw-generate-pr` enforce:** if the project's language is supported AND the most recent `.dw/secure-audit/audit-summary.md` is missing OR REJECTED, those commands themselves return REJECTED. No exception. No bypass flag.
101
138
 
102
139
  ## Mode 1: Default (`/dw-secure-audit`)
103
140
 
104
141
  1. **Detect stack**: check for package.json / requirements.txt / *.csproj / Cargo.toml.
105
- 2. **Run all three layers in parallel** (where possible):
106
- - OWASP static (via `security-review` skill).
142
+ 2. **Run all detection layers in parallel** (where possible):
143
+ - OWASP static (via `security-review` skill) — diff-focused.
144
+ - SAST — Semgrep on the diff (`--baseline-commit`).
145
+ - Dedicated secret scan — gitleaks on the diff.
107
146
  - Trivy + lockfile audit.
108
147
  - Supply-chain compromise check.
109
148
  3. **Run outdated check.**
149
+ **fp-check:** before finalizing, run reachability validation on each blocking SAST/OWASP finding
150
+ (see `security-review` SKILL.md); downgrade provably-unreachable ones to advisory with a logged reason.
151
+ Secrets are exempt from downgrade.
110
152
  4. **Aggregate findings** per classification tier.
111
153
  5. **Write summary** at `.dw/secure-audit/audit-summary.md`:
112
154
 
@@ -118,14 +160,26 @@ The verdict is one of:
118
160
  ## Tier Summary
119
161
  | Tier | Count | Detail |
120
162
  |------|-------|--------|
163
+ | SECRET | N | <list> |
121
164
  | COMPROMISED | N | <list> |
122
165
  | CRITICAL | N | <list> |
123
166
  | HIGH | N | <list> |
167
+ | MEDIUM/LOW (advisory) | N | <list> |
124
168
  | OUTDATED-MAJOR | N | <list> |
125
169
  | OUTDATED-MINOR | N | <list> |
126
170
 
171
+ ## Scanners
172
+ | Layer | Tool | Status |
173
+ |-------|------|--------|
174
+ | OWASP | security-review | run |
175
+ | SAST | semgrep | run / skipped (not installed) |
176
+ | Secrets | gitleaks | run / fallback to trivy (not installed) |
177
+ | SCA/IaC | trivy | run |
178
+
127
179
  ## Layer reports
128
180
  - OWASP findings: `owasp-findings.md`
181
+ - SAST findings: `sast-findings.md`
182
+ - Secret findings: `secret-findings.md`
129
183
  - Trivy findings: `trivy-findings.md`
130
184
  - Lockfile findings: `lockfile-findings.md`
131
185
  - Compromise findings: `compromise-findings.md`
@@ -164,7 +218,7 @@ For each user-approved remediation:
164
218
  ## Mode 4: CI mode (`/dw-secure-audit --scan-only`)
165
219
 
166
220
  Minimal output:
167
- - Runs all three layers.
221
+ - Runs all detection layers.
168
222
  - Writes findings to disk.
169
223
  - Exits with code 0 if APPROVED, 1 if REJECTED.
170
224
  - No remediation planning.
@@ -182,8 +236,9 @@ For pre-merge CI gates.
182
236
  ## Constitution Gate
183
237
 
184
238
  <critical>
185
- - A CRITICAL or COMPROMISED finding without an ADR justifying explicit acceptance → verdict cannot be APPROVED.
186
- - Constitution principle violations (security-related principles like P-009 server-side auth, P-010 secrets-in-repo) escalate findings — a `severity: info` principle violation surfaced here becomes a HIGH classification.
239
+ - A SECRET finding → verdict cannot be APPROVED, EVER (no ADR escape). Rotate and remove.
240
+ - A CRITICAL/HIGH/COMPROMISED finding (CVE or reachable SAST) without an ADR justifying explicit acceptance → verdict cannot be APPROVED.
241
+ - Constitution principle violations (security principles like P-009 server-side auth, P-010 secrets-in-repo, P-011 no high-severity SAST) escalate findings — a `severity: info` principle violation surfaced here becomes a HIGH classification.
187
242
  </critical>
188
243
 
189
244
  ## Anti-patterns
@@ -198,8 +253,10 @@ For pre-merge CI gates.
198
253
 
199
254
  ```
200
255
  .dw/secure-audit/
201
- ├── audit-summary.md # verdict + tier summary
256
+ ├── audit-summary.md # verdict + tier summary + scanner status
202
257
  ├── owasp-findings.md # Layer 1
258
+ ├── sast-findings.md # Layer 4 (Semgrep)
259
+ ├── secret-findings.md # Layer 5 (gitleaks, redacted)
203
260
  ├── trivy-findings.md # Layer 2 (SCA + secrets + IaC)
204
261
  ├── lockfile-findings.md # Layer 2 (native auditor)
205
262
  ├── compromise-findings.md # Layer 3
@@ -80,12 +80,17 @@ mode: defaults | custom
80
80
  **P-009 — Server-side authorization on every state-changing endpoint** (severity: info)
81
81
  **Rule:** Any endpoint that creates, updates, or deletes data must verify caller authorization on the server. UI-level gating (hidden buttons, disabled forms) is not security.
82
82
  **Why:** Browsers are untrusted (see `dw-testing-discipline/references/security-boundary.md`). UI gating is convenience; only server checks protect data.
83
- **Enforcement:** `dw-code-review` and `dw-security-check` require an explicit auth check (decorator, middleware, or in-handler assertion) on POST/PUT/PATCH/DELETE routes.
83
+ **Enforcement:** `dw-review` and the `dw-secure-audit` Security Gate require an explicit auth check (decorator, middleware, or in-handler assertion) on POST/PUT/PATCH/DELETE routes.
84
84
 
85
- **P-010 — Secrets never enter the repository** (severity: info)
85
+ **P-010 — Secrets never enter the repository** (severity: high)
86
86
  **Rule:** No API keys, passwords, signing keys, tokens, or production endpoints checked into source. `.env.example` documents shape only.
87
87
  **Why:** Repository history is permanent. A secret committed once is leaked even if reverted next commit.
88
- **Enforcement:** `dw-security-check` runs Trivy + secret scanners on the diff.
88
+ **Enforcement:** the `dw-secure-audit` Security Gate runs gitleaks + Trivy secret scanners on the diff. Any hit blocks — with **no ADR exception** (rotate, don't justify).
89
+
90
+ **P-011 — No high-severity SAST finding ships unreviewed** (severity: high)
91
+ **Rule:** Generated/changed code must pass the SAST layer (Semgrep) of the Security Gate. A reachable high-severity finding (SQLi, command/code injection, SSRF, insecure deserialization, authn bypass) blocks unless an ADR justifies acceptance.
92
+ **Why:** AI-generated code reproduces insecure patterns at scale; deterministic SAST on the diff catches what review by reading misses.
93
+ **Enforcement:** `dw-secure-audit` runs Semgrep on the diff (`--baseline-commit`); findings survive an fp-check reachability validation before blocking.
89
94
 
90
95
  ---
91
96
 
@@ -0,0 +1,17 @@
1
+ // Functional-doc flow module. Driven by .dw/scripts/functional-doc/run-playwright-flow.mjs
2
+ // through the Playwright Node API, so video is captured with page.screencast (works both
3
+ // for a launched browser and over connectOverCDP). No imports are needed here — the runner
4
+ // injects page, context, expect, baseURL and the step()/shot() helpers.
5
+
6
+ export default async function flow({ page, expect, baseURL, step, shot }) {
7
+ await step("Open target route", async () => {
8
+ await page.goto(`${baseURL}{{routePath}}`);
9
+ await expect(page).toHaveURL(new RegExp("{{routeRegex}}"));
10
+ });
11
+
12
+ {{testSteps}}
13
+
14
+ await step("Record final context", async () => {
15
+ await expect(page.locator("body")).toBeVisible();
16
+ });
17
+ }
@@ -13,7 +13,7 @@ Antes de escolher um comando da Trigger Map, dimensione o escopo real da mudanç
13
13
  |---------|----------------|-------------|
14
14
  | **Pequeno** | ≤3 arquivos, sem migration, sem novo endpoint, descritível em uma frase. Exemplos: typo, log message, config de uma linha, bump de dependência, version pin. | Faça inline. Nenhum comando `dw-*`. |
15
15
  | **Médio** | Feature ou bug claro, <10 tasks numeradas esperadas, único componente ou serviço, sem decisões arquiteturais. Exemplos: adicionar campo de form com validação, corrigir regressão em módulo conhecido, ligar novo endpoint num handler existente. | `/dw-bugfix` (bugs) ou `/dw-plan` (features) — direto, não via `/dw-autopilot`. |
16
- | **Grande** | Feature multi-componente, ≥10 tasks esperadas, toca múltiplos módulos, tem superfície UX user-visible E backend. Exemplos: adicionar nova entidade end-to-end (model + migration + API + UI), introduzir integração de terceiro, redesenhar fluxo. | `/dw-autopilot "<wish>"` — pipeline completo PRD → TechSpec → Tasks → Run → QA → Review → Commit → PR com três gates. |
16
+ | **Grande** | Feature multi-componente, ≥10 tasks esperadas, toca múltiplos módulos, tem superfície UX user-visible E backend. Exemplos: adicionar nova entidade end-to-end (model + migration + API + UI), introduzir integração de terceiro, redesenhar fluxo. | `/dw-autopilot "<wish>"` — primeira invocação planeja e para; segunda invocação retoma via `/dw-goal` para Run → Review → QA/Fix → Review, depois Commit → PR. |
17
17
  | **Complexo** | Domínio novo, requisitos ambíguos, decisão arquitetural exigida, superfície regulatória ou de compliance, ou escopo que cruza múltiplos PRDs. Exemplos: introduzir event sourcing, reconstruir auth, multi-tenancy, nova linha de produto. | `/dw-brainstorm "<ideia>"` primeiro (auto-dispatch de modos research/council), depois `/dw-plan --council` para a etapa de techspec rodar o debate multi-advisor. |
18
18
 
19
19
  **Safety valve:** se você começou em Pequeno ou Médio mas o trabalho revela que é Grande de fato (a listagem inline passa de 5 passos, ou `/dw-bugfix` dispara seu `Step 5.0`), PARE e escale. Não existe flag para bypass. Escalar é o desfecho correto.
@@ -26,6 +26,7 @@ Antes de escolher um comando da Trigger Map, dimensione o escopo real da mudanç
26
26
  |------------------------------------------------|--------------|
27
27
  | "Implementa X" / "Cria Y" / "Adiciona feature Z" / "Preciso de..." | `/dw-autopilot "X"` |
28
28
  | "Autopilota esse PRD" / "Leva esse PRD pra PR" / continua escalação de bugfix autonomamente | `/dw-autopilot --from-prd <slug>` (PRD existente em `.dw/spec/<slug>/`) |
29
+ | "Retoma autopilot" / "continua depois do plan" / `autopilot-state.json` tem `status: plan_complete` | `/dw-autopilot` (ou `/dw-goal --from-autopilot <slug>` se o usuário pedir especificamente a etapa de goal) |
29
30
  | Erro colado / "X está quebrado" / "Bug em Y" / screenshot de teste falhando | `/dw-bugfix "X"` |
30
31
  | "Planeja essa feature" / "Escreve PRD + techspec + tasks" | `/dw-plan "X"` |
31
32
  | "Escreve PRD pra X" / "Especifica Y" | `/dw-plan prd "X"` |
@@ -33,6 +34,7 @@ Antes de escolher um comando da Trigger Map, dimensione o escopo real da mudanç
33
34
  | "Quebra em tasks" | `/dw-plan tasks` |
34
35
  | "Roda essa task" (com ID da task) | `/dw-run <ID>` |
35
36
  | "Roda todas as tasks pendentes" / "Executa o plano" | `/dw-run` |
37
+ | "Roda isso como goal" / "objetivo durável" / "long-running objective" | `/dw-goal "<objetivo>"` |
36
38
  | "Continue de onde parei" | `/dw-run --resume` |
37
39
  | "Pausa o trabalho" / "Encerra a sessão" / "Salva onde paramos" | `/dw-pause` |
38
40
  | "Retoma" / "Onde paramos?" / "Volta de onde parei" | `/dw-resume` |
@@ -63,7 +65,7 @@ Antes de escolher um comando da Trigger Map, dimensione o escopo real da mudanç
63
65
  | "Instala skills Azure" / "Configura MCP do Microsoft docs" / "Adiciona expertise Azure" / "Vou trabalhar com Azure" | `/dw-install-azure-skills` |
64
66
  | "Instala skills AWS" / "Configura MCP da AWS" / "Adiciona expertise AWS" / "Vou trabalhar com AWS" | `/dw-install-aws-skills` |
65
67
 
66
- **Prioridade:** na dúvida entre dois comandos, `/dw-autopilot` é o default mais seguro pra qualquer pedido de feature não-trivial — ele compõe os demais.
68
+ **Prioridade:** na dúvida entre dois comandos, `/dw-autopilot` é o default mais seguro pra qualquer pedido de feature não-trivial. Se um autopilot planejado já parou com `status: plan_complete`, retome em vez de iniciar novo plano; a fase de execução pertence ao `/dw-goal`.
67
69
 
68
70
  ## Hard Gates (os comandos enforçam — não burle)
69
71
 
@@ -131,12 +133,12 @@ Skills são protocolos compactos primeiro. Leia o `SKILL.md` de entrada e carreg
131
133
  ## Referência de Workflow
132
134
 
133
135
  ```
134
- /dw-autopilot "wish" ────► Roda pipeline completo automaticamente
135
- (3 gates: PRD approval, Tasks approval, PR confirmação)
136
+ /dw-autopilot "wish" ────► Primeira invocação planeja: PRD → TechSpec → Tasks → STOP
137
+ /dw-autopilot ────► Segunda invocação retoma: /dw-goal → Commit → PR
136
138
 
137
139
  --- OU passo a passo ---
138
140
 
139
- /dw-brainstorm ─► /dw-plan ─► /dw-run ─► /dw-qa ─► /dw-review ─► /dw-commit ─► /dw-generate-pr
141
+ /dw-brainstorm ─► /dw-plan ─► /dw-goal ─► /dw-commit ─► /dw-generate-pr
140
142
  ```
141
143
 
142
144
  Lista completa e ajuda contextual: `/dw-help`.
@@ -767,6 +767,27 @@ Se após as heurísticas nada cruzar a barra (codebase pequeno, churn baixo, sem
767
767
 
768
768
  **Cadência de refresh:** usuários re-rodam `/dw-analyze-project` quando rules ficam desatualizadas. O Passo 9 atualiza seções auto mantendo entradas preservadas. Não existe comando separado só de refresh.
769
769
 
770
+ ### Passo 10: Autoridade de design (DESIGN.md) — só projetos frontend
771
+
772
+ Rode quando um frontend for detectado (React/Vue/Angular/Svelte/Tailwind/CSS), para que a grounding
773
+ question 1 do `dw-ui-discipline` ("de onde vêm as decisões de design?") tenha uma autoridade do projeto
774
+ para seguir. Isso fecha o loop que hoje a grounding apenas *lê*.
775
+
776
+ 1. **Cheque uma autoridade existente primeiro.** Se `DESIGN.md`, `BRAND.md` ou `STYLE_GUIDE.md` já existe
777
+ na raiz do projeto (ou do módulo frontend), NÃO sobrescreva — registre a localização e pare.
778
+ 2. **Detecte design tokens** em ordem de prioridade: `theme`/`@theme` do Tailwind (cores, fontFamily,
779
+ spacing, radius), CSS custom properties em `globals.css`/`theme.css`/`tokens.css`, theme exports de
780
+ MUI/Chakra, `components.json` do shadcn, theme do Storybook. Leia os valores reais — não invente.
781
+ 3. **Se houver tokens:** sintetize `DESIGN.md` na raiz do frontend capturando o que o projeto JÁ usa —
782
+ paleta (com os valores hex/oklch reais e nomes dos tokens), tipografia (famílias, escala, pesos),
783
+ escala de spacing/radius e convenções de componente observadas. Inicie com:
784
+ `> Gerado por /dw-analyze-project a partir de tokens existentes em <data>. Cure antes de tratar como canon.`
785
+ 4. **Se não houver tokens:** NÃO fabrique paleta. Recomende bootstrap a partir de
786
+ `dw-ui-discipline/references/curated-defaults.md` e registre essa recomendação no índice de rules.
787
+ 5. Referencie o novo `DESIGN.md` a partir de `.dw/rules/<módulo-frontend>.md` para os comandos downstream acharem.
788
+
789
+ Este passo é aditivo e reversível; nunca edita código de componente, só documenta o que existe.
790
+
770
791
  ## Checklist de Qualidade
771
792
 
772
793
  - [ ] Estrutura do repositório escaneada
@@ -797,6 +818,7 @@ Se após as heurísticas nada cruzar a barra (codebase pequeno, churn baixo, sem
797
818
  - [ ] Convenções de teste documentadas (framework, padrões, cobertura)
798
819
  - [ ] Step 8 (constitution) oferecido e resolvido (A/B/C)
799
820
  - [ ] Step 9 (mapa de concerns) apresentou candidatos, aguardou aprovação, escreveu `.dw/rules/concerns.md` (ou anotou que não há sinais)
821
+ - [ ] Passo 10 (autoridade de design) rodou para projetos frontend: autoridade existente respeitada, ou `DESIGN.md` gerado a partir de tokens reais, ou bootstrap via curated-defaults recomendado
800
822
  - [ ] Blocos com marker preserved em concerns.md mantidos verbatim no refresh
801
823
 
802
824
  ## Exemplo de Uso