@brunosps00/dev-workflow 1.0.6 → 1.1.1

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 +51 -29
  2. package/bin/dev-workflow.js +6 -0
  3. package/lib/constants.js +2 -2
  4. package/lib/init.js +13 -3
  5. package/lib/install-deps.js +88 -3
  6. package/lib/migrate-gsd.js +1 -1
  7. package/lib/post-update.js +153 -0
  8. package/lib/setup-wsl-browser.js +149 -0
  9. package/lib/uninstall.js +1 -1
  10. package/package.json +1 -1
  11. package/scaffold/en/agent-instructions.md +1 -1
  12. package/scaffold/en/commands/dw-analyze-project.md +22 -0
  13. package/scaffold/en/commands/dw-autopilot.md +3 -1
  14. package/scaffold/en/commands/dw-functional-doc.md +11 -3
  15. package/scaffold/en/commands/dw-generate-pr.md +2 -2
  16. package/scaffold/en/commands/dw-help.md +29 -14
  17. package/scaffold/en/commands/dw-qa.md +1 -1
  18. package/scaffold/en/commands/dw-redesign-ui.md +2 -2
  19. package/scaffold/en/commands/dw-review.md +7 -5
  20. package/scaffold/en/commands/dw-secure-audit.md +72 -15
  21. package/scaffold/en/commands/dw-update.md +16 -1
  22. package/scaffold/en/templates/constitution-template.md +8 -3
  23. package/scaffold/en/templates/functional-doc/playwright.flow.mjs.tpl +17 -0
  24. package/scaffold/pt-br/agent-instructions.md +1 -1
  25. package/scaffold/pt-br/commands/dw-analyze-project.md +22 -0
  26. package/scaffold/pt-br/commands/dw-autopilot.md +3 -1
  27. package/scaffold/pt-br/commands/dw-functional-doc.md +11 -3
  28. package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
  29. package/scaffold/pt-br/commands/dw-help.md +29 -14
  30. package/scaffold/pt-br/commands/dw-qa.md +1 -1
  31. package/scaffold/pt-br/commands/dw-redesign-ui.md +2 -2
  32. package/scaffold/pt-br/commands/dw-review.md +7 -5
  33. package/scaffold/pt-br/commands/dw-secure-audit.md +72 -15
  34. package/scaffold/pt-br/commands/dw-update.md +16 -1
  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
@@ -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
@@ -79,6 +79,7 @@ The `update` command overwrites managed files and PRESERVES:
79
79
  - `.dw/rules/` (user rules)
80
80
  - `.dw/spec/` (in-progress PRDs and tasks)
81
81
  - `.dw/intel/` (codebase index from `/dw-intel --build`)
82
+ - project-derived docs such as `.dw/constitution.md`, `.dw/rules/concerns.md`, and frontend `DESIGN.md`
82
83
 
83
84
  The `update` command also runs the GSD migration step automatically — if a project has legacy `.planning/` (from prior GSD usage), the contents are migrated to `.dw/intel/`, `.dw/spec/active-session.md`, `.dw/spec/quick/`, etc., and `.planning/` is renamed to `.planning.gsd-archive-<DATE>/` for inspection. The `.claude/commands/gsd/`, `.claude/agents/gsd-*.md`, `.claude/hooks/gsd-*.js`, and `.claude/gsd-file-manifest.json` files are removed during the migration.
84
85
 
@@ -96,9 +97,23 @@ Present to the user:
96
97
  - Detected language (`DETECTED_LANG`)
97
98
  - Previous version → new version
98
99
  - Summary of what the `update` output showed (files copied, wrappers generated, MCPs configured)
100
+ - The `Post-update agent actions` printed by the CLI
99
101
  - Any warnings or errors
100
102
 
101
- ### 6. Suggest Next Step
103
+ ### 6. Run Post-Update Agent Actions (Required)
104
+
105
+ <critical>The CLI cannot execute slash commands or inspect product-specific design authority by itself. When the update output prints `Post-update agent actions`, treat that list as work for this agent to run now, unless the user explicitly asked for "update files only".</critical>
106
+
107
+ Run listed commands in this order:
108
+
109
+ 1. `/dw-analyze-project` when listed — refreshes project-derived docs. This is the command that creates or refreshes `.dw/rules/`, offers `.dw/constitution.md`, writes `.dw/rules/concerns.md`, and for frontend projects synthesizes `DESIGN.md` from existing design tokens when no design authority exists.
110
+ 2. `/dw-intel --build` when listed — rebuilds the queryable codebase index after rules/docs refresh.
111
+ 3. `/dw-harness-audit` — validates commands, wrappers, agents, MCPs, and gates after managed files changed.
112
+ 4. `/dw-skill-health` — audits refreshed bundled skills and agents for bloat, overlap, and stale references.
113
+
114
+ If `/dw-analyze-project` asks clarification or approval questions, ask them and continue. Do not fabricate `DESIGN.md`, `concerns.md`, or constitution content directly inside `/dw-update`; delegate to the command that owns those artifacts.
115
+
116
+ ### 7. Suggest Next Step
102
117
 
103
118
  If commands/skills were updated, remind the user:
104
119
  - Restart the agent session (or reload skills) so the new instructions take effect — skills are usually loaded at session start
@@ -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
+ }
@@ -72,7 +72,7 @@ Antes de escolher um comando da Trigger Map, dimensione o escopo real da mudanç
72
72
  - **`.dw/constitution.md`**: princípios com `severity: high` ou `critical` bloqueiam PRs / techspecs sem um ADR justificando o desvio. Constitution ausente? Os comandos auto-instalam defaults em `severity: info` (não-bloqueante) e seguem — ausência nunca bloqueia.
73
73
  - **`.dw/spec/<prd>/tasks-validation.md`**: auto-gerado no fim do `/dw-plan tasks`. Qualquer dimensão FAIL bloqueia approval do usuário até resolver ou override explícito.
74
74
  - **Verification**: `/dw-generate-pr` exige `dw-verify` PASS fresco (testes + lint + build) depois do último edit.
75
- - **Segurança**: projetos TS / Python / C# / Rust precisam passar `/dw-secure-audit` (Trivy + OWASP + lockfile audit) antes do PR abrir.
75
+ - **Segurança**: projetos TS / Python / C# / Rust precisam passar `/dw-secure-audit` (OWASP + Semgrep + gitleaks + Trivy + lockfile audit) antes do PR abrir.
76
76
 
77
77
  ## Escape Hatches — NÃO auto-trigger
78
78
 
@@ -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
@@ -152,10 +152,11 @@ Quando `autopilot-state.json status=plan_complete`, invoque formalmente:
152
152
  O goal e dono desta sequencia:
153
153
 
154
154
  1. `/dw-run <prd-path>`
155
- 2. `/dw-review <prd-path>` (review completo: cobertura, qualidade, convencoes, seguranca, constitution, verify)
155
+ 2. `/dw-review <prd-path>` (review completo: cobertura, qualidade, convencoes, constitution, verify)
156
156
  3. `/dw-qa <prd-path>`
157
157
  4. `/dw-qa --fix <prd-path>` se QA encontrou bugs Open
158
158
  5. `/dw-review <prd-path>` novamente apos QA/fixes
159
+ 6. **Security Gate** — o `/dw-review` pós-QA (passo 5) aciona o `/dw-secure-audit`, produzindo um `.dw/secure-audit/audit-summary.md` fresco. Este passo **garante** que o verdict é APROVADO: se ausente/desatualizado/REPROVADO, rode `/dw-secure-audit <prd-path>` standalone, depois volte pro `/dw-bugfix` por finding e re-cheque. Findings SECRET sempre bloqueiam (sem escape de ADR). Não force um segundo scan completo quando já existe um summary APROVADO fresco.
159
160
 
160
161
  <critical>Nao substitua os reviews do goal por `/dw-review --coverage-only`. O goal de qualidade do autopilot exige `/dw-review` completo antes do QA e depois dos fixes de QA.</critical>
161
162
 
@@ -175,6 +176,7 @@ Antes de `/dw-commit`, verifique:
175
176
  - `.dw/goals/autopilot-<prd-slug>/status.json` esta completo.
176
177
  - `<prd-path>/QA/review-consolidated.md` existe a partir do review final pos-QA.
177
178
  - `<prd-path>/QA/qa-report.md` e `<prd-path>/QA/bugs.md` existem.
179
+ - **Security Gate passou:** `.dw/secure-audit/audit-summary.md` existe, esta fresco (pos-ultima-edicao) e status APROVADO. Se ausente/desatualizado/REPROVADO → PARE (nao commite).
178
180
  - `autopilot-state.json` registra artefatos de planejamento e o goal completo.
179
181
 
180
182
  Se algo estiver faltando, PARE e re-execute o comando formal ausente. Nao faca commit parcial.
@@ -114,7 +114,7 @@ Arquivos mínimos:
114
114
  - `case-matrix.md`
115
115
  - `e2e-runbook.md`
116
116
  - `manifest.json`
117
- - `scripts/*.spec.ts`
117
+ - `scripts/*.flow.mjs`
118
118
  - `captions/*.srt`
119
119
 
120
120
  Se houver execução:
@@ -291,8 +291,16 @@ Se já existir no workspace um script de shell funcional (ex: `record-human-tour
291
291
  ## Scripts utilitários
292
292
 
293
293
  Use os utilitários do workspace quando fizer sentido:
294
- - `node .dw/scripts/dw-functional-doc/generate-dossier.mjs --target <URL> [--lang en|pt-br] [--project <nome>] [--base-url <url>]`
295
- - `node .dw/scripts/dw-functional-doc/run-playwright-flow.mjs --flow-dir <caminho> [--browser-name chromium|firefox] [--video-resolution fullhd|1920x1080]`
294
+ - `node .dw/scripts/functional-doc/generate-dossier.mjs --target <URL> [--lang en|pt-br] [--project <nome>] [--base-url <url>]`
295
+ - `node .dw/scripts/functional-doc/run-playwright-flow.mjs --flow-dir <caminho> [--video-resolution fullhd|1920x1080] [--list-only]`
296
+
297
+ O runner dirige o Playwright pela API Node e grava vídeo com `page.screencast` (único mecanismo que
298
+ funciona via CDP). Ele gera `scripts/<slug>.flow.mjs` — um módulo ESM simples que exporta
299
+ `async function flow({ page, context, expect, baseURL, step, shot })`, não um spec `@playwright/test`,
300
+ então dispensa o `playwright.config.*` do projeto. O browser é escolhido por `.dw/scripts/lib/resolve-browser.mjs`
301
+ (resiliente no WSL: Chromium headless full por padrão; defina `BROWSER_TEST` com o caminho do exe do browser do Windows para dirigi-lo via CDP — em NAT rode `npx @brunosps00/dev-workflow setup-wsl-browser` uma vez para o cdp-relay.exe + regra Hyper-V, em mirrored funciona direto);
302
+ veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`. Só Chromium —
303
+ `screencast`/CDP não suportam Firefox/WebKit.
296
304
 
297
305
  ## Critérios de completude
298
306
 
@@ -15,11 +15,11 @@
15
15
  |-------|---------|
16
16
  | `dw-verify` | **SEMPRE** — invocada antes do `git push`. Sem VERIFICATION REPORT PASS na sessão após a última edição de código, o PR **NÃO** pode ser criado. |
17
17
  | `dw-git-discipline` | **SEMPRE** — valida naming de branch (`<tipo>/<escopo>` kebab-case), histórico atomic-commit (cada commit single-intent, mensagem conventional), tempo de vida da branch (flag se >7 dias) e escopo da PR (sugere split se diff > ~400 linhas). Descrição da PR segue summary + test plan, não dump de `git log`. |
18
- | `/dw-secure-audit` | **SEMPRE para projetos TS/Python/C#/Rust** — `security-check.md` com status ≠ REJECTED é obrigatório para projetos em linguagem suportada. |
18
+ | `/dw-secure-audit` | **SEMPRE para projetos TS/Python/C#/Rust** — um `.dw/secure-audit/audit-summary.md` fresco com status ≠ REJECTED é obrigatório para projetos em linguagem suportada. |
19
19
 
20
20
  <critical>Hard gate 1 (verify): se a sessão atual não tem um VERIFICATION REPORT PASS de `dw-verify` produzido APÓS a última edição/commit, PARAR e invocar `dw-verify` antes de prosseguir. PR é um artefato permanente — exige o maior rigor de verificação.</critical>
21
21
 
22
- <critical>Hard gate 2 (security): para projetos TS/Python/C#/Rust, se `{{PRD_PATH}}/security-check.md` não existir OU tiver status REJECTED, PARAR e invocar `/dw-secure-audit` antes de prosseguir. Vulnerabilidades HIGH/CRITICAL NÃO podem chegar ao PR. Para outras linguagens (Go, Java, etc.), este gate é pulado com nota.</critical>
22
+ <critical>Hard gate 2 (security): para projetos TS/Python/C#/Rust, se `.dw/secure-audit/audit-summary.md` não existir, estiver desatualizado (anterior à última edição) OU tiver status REJECTED, PARAR e invocar `/dw-secure-audit` antes de prosseguir. Findings SECRET e vulnerabilidades HIGH/CRITICAL NÃO podem chegar ao PR. Para outras linguagens (Go, Java, etc.), este gate é pulado com nota.</critical>
23
23
 
24
24
  ## Uso
25
25
 
@@ -17,41 +17,45 @@ Use `/dw-autopilot "desejo"` como gateway pra maior parte do trabalho. Comandos
17
17
 
18
18
  | Comando | Quando |
19
19
  |---------|--------|
20
- | `/dw-autopilot "desejo"` | Entry point padrão em duas invocações. Primeira roda plan e para; segunda retoma via `/dw-goal`, commit e PR. |
20
+ | `/dw-autopilot "desejo"` | Entry point padrão em duas invocações. Primeira roda plan e para; segunda retoma via `/dw-goal`, Security Gate, commit e PR. |
21
21
  | `/dw-bugfix "descrição"` | Bug ou error report. Fix cirúrgico ou rota pra PRD. |
22
22
  | `/dw-help [palavra-chave]` | Esta tela. Passe palavra-chave pra atalhos. `--advanced` revela comandos internos. |
23
23
 
24
- ## Tier 2 — Pipeline granular (7)
24
+ ## Tier 2 — Pipeline granular (9)
25
25
 
26
26
  | Comando | O que |
27
27
  |---------|-------|
28
28
  | `/dw-brainstorm "ideia"` | Refina ideia antes do PRD. Flags: `--onepager`, `--council`, `--research`, `--refactor`. |
29
29
  | `/dw-plan "feature"` | PRD → TechSpec → Tasks sequencial com checkpoints. Stages: `prd`, `techspec`, `tasks`. |
30
30
  | `/dw-run [task-id]` | Executa todas tasks pendentes ou uma específica. Flag `--resume`. |
31
- | `/dw-review` | Level 2 (cobertura PRD) + Level 3 (qualidade). Flags: `--coverage-only`, `--code-only`. |
32
- | `/dw-qa` | QA mode-aware (UI / API auto-detect). Flags: `--fix`, `--api`, `--ai`. |
31
+ | `/dw-review` | Level 2 (cobertura PRD) + Level 3 (qualidade/segurança). Flags: `--coverage-only`, `--code-only`, `--bugfix <slug>`. |
32
+ | `/dw-qa` | QA mode-aware (UI / API auto-detect). Flags: `--fix`, `--api`, `--ai`, `--uat`, `--bugfix <slug>`. |
33
+ | `/dw-pause` | Salva estado da sessão, decisões, bloqueios, todos e open loops em `.dw/STATE.md`. |
34
+ | `/dw-resume` | Lê `.dw/STATE.md`, mostra um TLDR e sugere o próximo comando `dw-*`. |
33
35
  | `/dw-commit` | Commits atômicos Conventional pra trabalho pendente. |
34
36
  | `/dw-generate-pr [target]` | Push branch, draft do PR body, abre browser. |
35
37
 
36
- ## Tier 3 — Especialidade (8)
38
+ ## Tier 3 — Especialidade (10)
37
39
 
38
40
  | Comando | O que |
39
41
  |---------|-------|
40
- | `/dw-analyze-project` | Scan do repo, escreve `.dw/rules/` + oferece gerar `.dw/constitution.md`. |
41
- | `/dw-redesign-ui "target"` | Audit, propõe 2-3 direções, entrega. Enforça UI grounding + WCAG. |
42
- | `/dw-functional-doc` | Mapeia screens + flows em doc funcional validado com Playwright. |
42
+ | `/dw-analyze-project` | Scan do repo, escreve `.dw/rules/`, oferece `.dw/constitution.md`, gera `.dw/rules/concerns.md` e sintetiza `DESIGN.md` em frontend quando há tokens. |
43
+ | `/dw-redesign-ui "target"` | Audit, propõe 2-3 direções, entrega. Enforça UI grounding + WCAG; pode rodar o detector determinístico do impeccable. |
44
+ | `/dw-functional-doc` | Mapeia screens + flows em doc funcional validado com Playwright; usa resolução de browser resiliente no WSL. |
43
45
  | `/dw-context-budget` | Audita contexto de commands, skills, agentes, instrucoes e MCPs. |
44
46
  | `/dw-harness-audit` | Pontua saude da instalacao: wrappers, agentes, MCPs e gates. |
45
47
  | `/dw-skill-health` | Audita skills e agentes por bloat, duplicacao e referencias quebradas. |
46
48
  | `/dw-new-project` | Bootstrap por entrevista (stack + infra + docker-compose + CI). |
47
49
  | `/dw-dockerize` | Detecta stack, propõe Dockerfile + docker-compose pra dev/prod. |
50
+ | `/dw-install-azure-skills` | Opt-in: skills Azure + Microsoft Learn MCP. Seleção interativa de categorias. |
51
+ | `/dw-install-aws-skills` | Opt-in: skills AWS + AWS MCP Server. Requer `uv`, AWS CLI e credenciais. |
48
52
 
49
53
  ## Workflow em resumo
50
54
 
51
- `/dw-autopilot "desejo"` roda planejamento primeiro e para. Reinvoque para retomar via `/dw-goal`, commit e PR. Passo a passo:
55
+ `/dw-autopilot "desejo"` roda planejamento primeiro e para. Reinvoque para retomar via `/dw-goal`, Security Gate, commit e PR. Passo a passo:
52
56
 
53
57
  ```
54
- /dw-brainstorm → /dw-plan → /dw-goal → /dw-commit → /dw-generate-pr
58
+ /dw-brainstorm → /dw-plan → /dw-goal → /dw-secure-audit → /dw-commit → /dw-generate-pr
55
59
  ```
56
60
 
57
61
  ## Comandos avançados / internos
@@ -74,10 +78,10 @@ Auto-invocados por comandos primários mas disponíveis standalone.
74
78
  |---------|-------|--------------|
75
79
  | `/dw-adr "decisão"` | Registra um ADR em `.dw/spec/<prd>/adrs/`. | `/dw-plan techspec --council`, desvios de constitution |
76
80
  | `/dw-intel "pergunta"` | Query de codebase intel; `--build` (re)indexa `.dw/intel/`. | `/dw-plan`, `/dw-review`, `/dw-bugfix` |
77
- | `/dw-secure-audit` | OWASP + Trivy + lockfile + supply-chain scan. Hard gate. Flags: `--scan-only`, `--plan`, `--execute`. | `/dw-review`, `/dw-generate-pr` |
81
+ | `/dw-secure-audit` | OWASP + Semgrep SAST + gitleaks secrets + Trivy SCA/IaC + lockfile + supply-chain scan. Hard gate. Flags: `--scan-only`, `--plan`, `--execute`. | `/dw-review`, `/dw-autopilot`, `/dw-generate-pr` |
78
82
  | `/dw-goal "<objetivo>"` | Contrato de objetivo duravel com `.dw/goals/`; faz ponte com `/goal` nativo do Codex quando disponivel. | `/dw-autopilot` apos planejamento |
79
83
  | `/dw-find-skills "query"` | Busca npx skills ecosystem, valida, instala. | manual ao estender bundle |
80
- | `/dw-update` | Atualiza dev-workflow pro último release npm com snapshot rollback. | manutenção manual |
84
+ | `/dw-update` | Atualiza dev-workflow pro último release npm com snapshot rollback, depois roda ações pós-update listadas (`/dw-analyze-project`, `/dw-intel --build`, `/dw-harness-audit`, `/dw-skill-health`) quando aplicável. | manutenção manual |
81
85
  | `/dw-subtask-start "goal"` | Cria um input packet minimo para subagente. | parent antes de delegar |
82
86
  | `/dw-subtask-complete <slug>` | Registra handoff estruturado da sessao child. | subagente / sessao child |
83
87
  | `/dw-subtask-resume` | Consome e arquiva handoffs pendentes para sintese do parent. | parent apos delegacao |
@@ -91,6 +95,8 @@ Auto-invocados por comandos primários mas disponíveis standalone.
91
95
  | `bug`, `erro`, `quebrado`, `fix` | `/dw-bugfix` |
92
96
  | `run`, `executa`, `implementa` | `/dw-run` |
93
97
  | `goal`, `objetivo`, `long-running`, `retomar autopilot` | `/dw-goal` ou `/dw-autopilot` se `autopilot-state.json` existir |
98
+ | `pausa`, `salvar estado`, `encerrar sessão` | `/dw-pause` |
99
+ | `retomar`, `continuar`, `onde paramos` | `/dw-resume` |
94
100
  | `review`, `qualidade`, `audit code` | `/dw-review` |
95
101
  | `qa`, `test plan`, `e2e` | `/dw-qa` |
96
102
  | `commit`, `git` | `/dw-commit` |
@@ -102,15 +108,21 @@ Auto-invocados por comandos primários mas disponíveis standalone.
102
108
  | `intel`, `onde está`, `o que usa` | `/dw-intel` (ou `--build`) |
103
109
  | `contexto`, `tokens`, `agente lento` | `/dw-context-budget` |
104
110
  | `harness`, `install`, `wrappers`, `agentes` | `/dw-harness-audit` |
111
+ | `update`, `upgrade`, `latest`, `pós-update` | `/dw-update` |
112
+ | `design.md`, `autoridade de design`, `mapa de concerns` | `/dw-analyze-project` (também listado como ação pós-update quando ausente) |
105
113
  | `subagent`, `subtask`, `handoff`, `delegate`, `delegar` | `/dw-subtask-start` ou `/dw-subtask-resume` |
106
114
  | `skills`, `skill health`, `bloat` | `/dw-skill-health` |
107
115
  | `analyze`, `rules`, `convenções` | `/dw-analyze-project` |
108
116
  | `constitution`, `princípios` | `/dw-analyze-project` (Step 8) |
109
117
  | `security`, `vulnerabilidades`, `cve`, `deps` | `/dw-secure-audit` |
118
+ | `secret`, `sast`, `semgrep`, `gitleaks`, `trivy` | `/dw-secure-audit` |
110
119
  | `adr`, `decisão` | `/dw-adr` |
111
120
  | `docker`, `compose`, `container` | `/dw-dockerize` |
112
121
  | `new project`, `bootstrap`, `scaffold` | `/dw-new-project` |
113
122
  | `functional doc`, `screen map` | `/dw-functional-doc` |
123
+ | `wsl`, `browser`, `playwright browser`, `cdp` | `npx @brunosps00/dev-workflow setup-wsl-browser` quando WSL NAT precisa dirigir o browser real do Windows |
124
+ | `azure`, `microsoft learn`, `azure skills` | `/dw-install-azure-skills` |
125
+ | `aws`, `aws mcp`, `aws skills` | `/dw-install-aws-skills` |
114
126
  | `incident`, `outage`, `postmortem`, `sev-1` | (Skill `dw-incident-response` auto-invocada de `/dw-bugfix`) |
115
127
  | `eval`, `llm`, `ai feature`, `rag` | (Skill `dw-llm-eval` invocada de `/dw-plan`, `/dw-review`, `/dw-qa --ai`) |
116
128
 
@@ -119,10 +131,10 @@ Sem match: surface padrão + nota.
119
131
  ## FAQ
120
132
 
121
133
  **P: Onde começo com uma nova feature?**
122
- - `/dw-autopilot "o que voce quer"`. Primeira invocacao roda PRD → TechSpec → Tasks e para; segunda invocacao retoma via `/dw-goal`, commit e PR.
134
+ - `/dw-autopilot "o que voce quer"`. Primeira invocacao roda PRD → TechSpec → Tasks e para; segunda invocacao retoma via `/dw-goal`, Security Gate, commit e PR.
123
135
 
124
136
  **P: Tenho que usar `/dw-autopilot`?**
125
- - Não. Pipeline granular dá controle a cada step, com `/dw-goal` quando quiser executar run/review/QA/review como objetivo duravel.
137
+ - Não. Pipeline granular dá controle a cada step, com `/dw-goal` quando quiser executar run/review/QA/review como objetivo duravel, seguido por `/dw-secure-audit`, `/dw-commit` e `/dw-generate-pr`.
126
138
 
127
139
  **P: Só quero corrigir um bug.**
128
140
  - `/dw-bugfix "<descrição>"`. Tria, 3 perguntas, fixa ou roteia.
@@ -133,6 +145,9 @@ Sem match: surface padrão + nota.
133
145
  **P: Onde features AI são avaliadas?**
134
146
  - Skill `dw-llm-eval` auto-invocada de `/dw-plan tasks`, `/dw-review`, `/dw-qa --ai`.
135
147
 
148
+ **P: Onde entra segurança?**
149
+ - `/dw-review` auto-invoca `/dw-secure-audit` para stacks suportadas; `/dw-autopilot` trata como gate nomeado antes de commit/PR; `/dw-generate-pr` reforça o summary aprovado mais recente.
150
+
136
151
  **P: O que aconteceu com outros comandos?**
137
152
  - v1.0.0 consolidou a surface antiga de comandos. Mergers: create-prd/techspec/tasks → `/dw-plan`; run-task/run-plan → `/dw-run`; code-review/review-implementation → `/dw-review`; run-qa/fix-qa → `/dw-qa`; security-check/deps-audit → `/dw-secure-audit`; map-codebase → `/dw-intel --build`; deep-research e refactoring-analysis → `/dw-brainstorm --research/--refactor`. Removidos: revert-task (use `git revert` direto).
138
153
 
@@ -83,7 +83,7 @@ Quando disponíveis em `./.agents/skills/`, invocadas operacionalmente:
83
83
 
84
84
  1. **Pre-flight**: confirmar que dev server do projeto pode rodar. Confirmar `.dw/spec/<prd>/` tem PRD + TechSpec + tasks.
85
85
  2. **Mapear FRs para test plan**: pra cada FR, identificar fluxo user-facing que exercita.
86
- 3. **Dirigir Playwright MCP** (ou fallback pra Playwright local per `dw-testing-discipline/references/playwright-recipes.md`):
86
+ 3. **Dirigir Playwright MCP** (se indisponível ou bloqueado — comum no WSL — use o fallback local resiliente `node .dw/scripts/lib/capture-screenshots.mjs`, que escolhe o browser via `.dw/scripts/lib/resolve-browser.mjs`; veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`):
87
87
  - Happy paths pra cada FR.
88
88
  - Edge cases (boundary inputs, falha de rede, erros de validação).
89
89
  - Fluxos negativos (ações não autorizadas, input malformado).
@@ -56,12 +56,12 @@ Utilize ferramentas de diagnóstico conforme o framework do projeto:
56
56
  ## Comportamento Obrigatório
57
57
 
58
58
  1. Identifique o alvo: página, componente ou rota que será redesenhada.
59
- 2. **AUDITAR**: leia a implementação atual, identifique stack CSS (Tailwind, CSS Modules, styled-components, etc.), capture screenshot usando `dw-testing-discipline`/playwright-recipes se disponível, rode react-doctor se projeto React.
59
+ 2. **AUDITAR**: leia a implementação atual, identifique stack CSS (Tailwind, CSS Modules, styled-components, etc.), capture o screenshot do estado-antes (Playwright MCP, ou `node .dw/scripts/lib/capture-screenshots.mjs` como fallback resiliente no WSL), rode react-doctor se projeto React.
60
60
  3. Faça 3 a 5 perguntas sobre objetivos do redesign: direção de estilo, constraints de marca, inspirações, público-alvo, dispositivos prioritários.
61
61
  4. **PROPOR**: apresente 2 a 3 direções de design depois de passar pelo hard-gate de `dw-ui-discipline` (brand authorities ou curated defaults; surface job sentence; state matrix enumerada; scene sentence). Cada direção lista paleta de cores, par tipográfico, estilo de layout e racional. Self-check de cada direção contra os 14 anti-slop patterns. Para CADA direção, descreva explicitamente o layout mobile (<=768px) e o layout desktop (>=1024px), incluindo como os elementos se reorganizam, empilham ou escondem entre breakpoints.
62
62
  5. Espere aprovação explícita do usuário antes de implementar.
63
63
  6. **IMPLEMENTAR**: aplique o design escolhido com abordagem mobile-first — implemente primeiro o layout mobile e depois adicione media queries/breakpoints para tablet e desktop. Respeite a stack existente. Use `vercel-react-best-practices` para React/Next.js. Mantenha a metodologia CSS do projeto.
64
- 7. **VALIDAR**: capture estado depois em AMBAS as resoluções (mobile e desktop), compare antes/depois, verifique acessibilidade contra `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — não-negociável: contraste, focus-visible, keyboard nav, ARIA, sem traps), rode react-doctor `--diff` se React. Use `dw-testing-discipline/references/playwright-recipes.md` para capturar screenshots em viewport 375px (mobile) e 1440px (desktop).
64
+ 7. **VALIDAR**: capture estado depois em AMBAS as resoluções (mobile e desktop), compare antes/depois, verifique acessibilidade contra `dw-ui-discipline/references/accessibility-floor.md` (WCAG 2.2 AA — não-negociável: contraste, focus-visible, keyboard nav, ARIA, sem traps), rode react-doctor `--diff` se React. Capture screenshots em 375px (mobile) e 1440px (desktop) — `node .dw/scripts/lib/capture-screenshots.mjs --url <url> --widths 375,1440` é o caminho resiliente no WSL; veja a seção "Browser on WSL" de `dw-testing-discipline/references/playwright-recipes.md`.
65
65
  8. **PERSISTIR CONTRATO**: se o usuário aprovou uma direção, gere `design-contract.md` no diretório do PRD (`.dw/spec/prd-[nome]/design-contract.md`) com: direção aprovada, paleta de cores, par tipográfico, regras de layout, regras de acessibilidade e regras de componentes. Este contrato será lido por `dw-run-task` e `dw-run-plan` para garantir consistência visual.
66
66
 
67
67
  ## Inteligência do Codebase
@@ -44,9 +44,10 @@ Quando disponíveis em `./.agents/skills/`, são invocadas como apoio analítico
44
44
 
45
45
  - `dw-review-rigor`: **SEMPRE** — aplica de-duplication (mesmo pattern em N arquivos = 1 finding), severity ordering (critical → high → medium → low), verify-before-flag, skip-what-linter-catches, signal-over-volume. A tabela "Problemas Encontrados" segue essa disciplina.
46
46
  - `dw-verify`: **SEMPRE** — invocada antes de emitir `APROVADO` ou `APROVADO COM RESSALVAS`. Sem VERIFICATION REPORT PASS (test + lint + build), verdict não pode ser APROVADO.
47
- - `dw-secure-audit`: **SEMPRE para projetos TS/Python/C#/Rust** — security gate. Se projeto usa linguagem suportada e `secure-audit.md` recente está ausente OU REJECTED, verdict é **REPROVADO** — sem exceção.
47
+ - `dw-secure-audit` (**Security Gate**): **SEMPRE para projetos TS/Python/C#/Rust** — acionado aqui e o verdict é enforced. Se a linguagem é suportada e `.dw/secure-audit/audit-summary.md` fresco está ausente OU REPROVADO, o verdict do review é **REPROVADO** — sem exceção. O mesmo gate também é comando standalone (`/dw-secure-audit`) e fase explícita no `/dw-autopilot`. Agora soma Semgrep SAST (diff) + gitleaks secrets sobre OWASP/Trivy/SCA.
48
+ - `security-review`: a skill OWASP nível-diff que o gate usa (injection, authz, secrets, SSRF, crypto — só HIGH CONFIDENCE).
48
49
  - `dw-simplification`: use quando diff toca código denso — aplica Chesterton's Fence, protocolo de refactor preservando comportamento, métricas de complexidade.
49
- - `dw-ui-discipline`: use quando diff toca UI — roda os 14 visual-slop patterns + accessibility floor.
50
+ - `dw-ui-discipline`: use quando diff toca UI — roda os 14 visual-slop patterns + accessibility floor. Para um gate determinístico, rode também `node .dw/scripts/lib/ui-slop-detect.mjs <paths-ui-alterados> --fail-on error` (wrapper sobre o detector do impeccable); trate findings bloqueantes como **REJECTED** e reporte os warnings.
50
51
  - `dw-testing-discipline`: use quando diff toca testes — aplica catálogo de 25 anti-patterns + 6 agent guardrails (quando testes foram agent-authored).
51
52
  - `dw-llm-eval`: **OBRIGATÓRIO quando diff toca código de feature AI/LLM**. Reference dataset + ≥2 oracle rungs + judge calibration (se rung 4 usado) + eval run results DEVEM estar no PR. Faltando → REPROVADO.
52
53
  - `security-review`: use quando diff toca auth, autorização, input externo, upload, SQL, secrets, SSRF, XSS ou superfícies sensíveis.
@@ -161,9 +162,10 @@ Se FALTANDO > 0, o veredicto sugere revisitar `/dw-plan tasks` pra escopar ou `/
161
162
  - Rodar dw-verify pra produzir VERIFICATION REPORT (test + lint + build GREEN).
162
163
  - Sem PASS, verdict não pode ser APROVADO.
163
164
 
164
- 8. **Security Layer (`dw-secure-audit` para TS/Python/C#/Rust):**
165
- - Rodar `/dw-secure-audit` contra o PR. Scan mais recente deve estar presente e não REPROVADO.
166
- - Se linguagem suportada e audit faltando OU REPROVADO → verdict **REPROVADO**.
165
+ 8. **Security Gate (`dw-secure-audit` para TS/Python/C#/Rust):**
166
+ - Acione `/dw-secure-audit` contra o diff (OWASP + Semgrep SAST + gitleaks + Trivy/SCA + supply-chain). Ele produz/atualiza `.dw/secure-audit/audit-summary.md`.
167
+ - Scan mais recente deve estar presente, fresco (pós-última-edição) e não REPROVADO. Se linguagem suportada e audit ausente OU REPROVADO → verdict do review **REPROVADO**. Findings SECRET sempre bloqueiam (sem escape de ADR).
168
+ - O mesmo gate também roda standalone (`/dw-secure-audit`) e é fase explícita no `/dw-autopilot`; `/dw-generate-pr` re-enforça o verdict antes do PR.
167
169
 
168
170
  ### Output
169
171