@brunosps00/dev-workflow 0.7.0 → 0.8.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.
- package/README.md +20 -4
- package/lib/constants.js +8 -0
- package/lib/install-deps.js +13 -0
- package/package.json +1 -1
- package/scaffold/en/commands/dw-deps-audit.md +326 -0
- package/scaffold/en/commands/dw-dockerize.md +321 -0
- package/scaffold/en/commands/dw-find-skills.md +158 -0
- package/scaffold/en/commands/dw-fix-qa.md +34 -13
- package/scaffold/en/commands/dw-help.md +4 -0
- package/scaffold/en/commands/dw-new-project.md +350 -0
- package/scaffold/en/commands/dw-run-qa.md +124 -23
- package/scaffold/en/templates/project-onepager.md +129 -0
- package/scaffold/pt-br/commands/dw-deps-audit.md +326 -0
- package/scaffold/pt-br/commands/dw-dockerize.md +321 -0
- package/scaffold/pt-br/commands/dw-find-skills.md +158 -0
- package/scaffold/pt-br/commands/dw-fix-qa.md +34 -13
- package/scaffold/pt-br/commands/dw-help.md +4 -0
- package/scaffold/pt-br/commands/dw-new-project.md +350 -0
- package/scaffold/pt-br/commands/dw-run-qa.md +124 -23
- package/scaffold/pt-br/templates/project-onepager.md +129 -0
- package/scaffold/skills/api-testing-recipes/SKILL.md +104 -0
- package/scaffold/skills/api-testing-recipes/recipes/dotnet-webapp-factory.md +168 -0
- package/scaffold/skills/api-testing-recipes/recipes/http-rest-client.md +130 -0
- package/scaffold/skills/api-testing-recipes/recipes/pytest-httpx.md +157 -0
- package/scaffold/skills/api-testing-recipes/recipes/rust-reqwest.md +173 -0
- package/scaffold/skills/api-testing-recipes/recipes/supertest-node.md +153 -0
- package/scaffold/skills/api-testing-recipes/references/auth-patterns.md +138 -0
- package/scaffold/skills/api-testing-recipes/references/log-conventions.md +117 -0
- package/scaffold/skills/api-testing-recipes/references/matrix-conventions.md +68 -0
- package/scaffold/skills/api-testing-recipes/references/openapi-driven.md +97 -0
- package/scaffold/skills/docker-compose-recipes/SKILL.md +84 -0
- package/scaffold/skills/docker-compose-recipes/references/compose-composition.md +91 -0
- package/scaffold/skills/docker-compose-recipes/references/env-conventions.md +51 -0
- package/scaffold/skills/docker-compose-recipes/references/healthcheck-patterns.md +54 -0
- package/scaffold/skills/docker-compose-recipes/references/prod-vs-dev.md +85 -0
- package/scaffold/skills/docker-compose-recipes/services/elasticsearch.yml +34 -0
- package/scaffold/skills/docker-compose-recipes/services/jaeger.yml +24 -0
- package/scaffold/skills/docker-compose-recipes/services/localstack.yml +30 -0
- package/scaffold/skills/docker-compose-recipes/services/mailhog.yml +23 -0
- package/scaffold/skills/docker-compose-recipes/services/mailpit.yml +27 -0
- package/scaffold/skills/docker-compose-recipes/services/meilisearch.yml +28 -0
- package/scaffold/skills/docker-compose-recipes/services/memcached.yml +19 -0
- package/scaffold/skills/docker-compose-recipes/services/minio.yml +30 -0
- package/scaffold/skills/docker-compose-recipes/services/mysql.yml +30 -0
- package/scaffold/skills/docker-compose-recipes/services/postgres.yml +30 -0
- package/scaffold/skills/docker-compose-recipes/services/rabbitmq.yml +29 -0
- package/scaffold/skills/docker-compose-recipes/services/redis.yml +25 -0
- package/scaffold/skills/docker-compose-recipes/services/smtp4dev.yml +27 -0
- package/scaffold/skills/docker-compose-recipes/services/traefik.yml +42 -0
- package/scaffold/skills/docker-compose-recipes/services/typesense.yml +25 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npx @brunosps00/dev-workflow init
|
|
|
10
10
|
|
|
11
11
|
This will:
|
|
12
12
|
1. Ask you to select a language (English or Portuguese)
|
|
13
|
-
2. Create `.dw/commands/` with
|
|
13
|
+
2. Create `.dw/commands/` with 31 workflow commands
|
|
14
14
|
3. Create `.dw/templates/` with document templates (PRD, TechSpec, Tasks, ADR, etc.)
|
|
15
15
|
4. Create `.dw/rules/` (populated by `/dw-analyze-project`)
|
|
16
16
|
5. Install bundled skills (`dw-verify`, `dw-memory`, `dw-review-rigor`, `ui-ux-pro-max`, `security-review`, etc.) to `.agents/skills/`
|
|
@@ -63,10 +63,10 @@ Executes a one-off change with workflow guarantees (validation, atomic commit) w
|
|
|
63
63
|
### Quality
|
|
64
64
|
|
|
65
65
|
#### `/dw-run-qa`
|
|
66
|
-
Validates the implementation against PRD, TechSpec, and Tasks
|
|
66
|
+
Validates the implementation against PRD, TechSpec, and Tasks. **Mode-aware**: in UI mode, drives Playwright MCP for E2E browser tests with happy paths, edge cases, negative flows, regressions, WCAG 2.2 accessibility, and screenshot evidence. In API mode (auto-detected when no UI deps are in the manifest, or forced via `--api`), composes per-RF `.http` / pytest+httpx / supertest / WebApplicationFactory / reqwest scripts from the bundled `api-testing-recipes` skill, executes them, and writes JSONL request/response logs to `QA/logs/api/` as evidence. The matrix expands to {200 happy / 4xx validation/auth/authz/not-found/conflict / 5xx / contract drift / cross-tenant denial}. Optional `--from-openapi` adds a baseline derived from the project's OpenAPI spec. Generates a QA report, documents bugs with mode-aware evidence, and detects stub/placeholder pages (UI) or unmapped spec endpoints (API).
|
|
67
67
|
|
|
68
68
|
#### `/dw-fix-qa`
|
|
69
|
-
Fixes bugs found during QA testing with evidence-driven retesting via Playwright MCP. Runs iterative cycles of identify, fix, retest, updating `QA/bugs.md` and `QA/qa-report.md` with status and
|
|
69
|
+
Fixes bugs found during QA testing with evidence-driven retesting. **Mode-aware**: in UI mode replays the failing flow via Playwright MCP and saves a retest screenshot; in API mode replays the failing `.http`/recipe and appends a `verdict: PASS|FAIL` JSONL line to `QA/logs/api/BUG-NN-retest.log`. Runs iterative cycles of identify, fix, retest, updating `QA/bugs.md` and `QA/qa-report.md` with status and mode-correct evidence.
|
|
70
70
|
|
|
71
71
|
#### `/dw-review-implementation`
|
|
72
72
|
Compares documented requirements (PRD + TechSpec + Tasks) against actual code as a Level 2 review. Maps each requirement to endpoints and tasks with evidence, identifies gaps, partial implementations, and extra undocumented code. Does not execute fixes — waits for user instruction.
|
|
@@ -80,6 +80,9 @@ Audits the codebase for code smells and refactoring opportunities using Martin F
|
|
|
80
80
|
#### `/dw-security-check`
|
|
81
81
|
Rigid multi-layer security check for **TypeScript, Python, C#, and Rust** projects. Combines OWASP static review (language-aware, via the bundled `security-review` skill), Trivy SCA/secret/IaC scanning (`trivy fs` + `trivy config`), and native lockfile audit (`npm audit` / `pip-audit` / `dotnet list package --vulnerable` / `cargo audit`). Consults Context7 MCP for framework-version-specific best practices (Next.js, Django, ASP.NET Core, Actix/Axum/Rocket, etc.). Hard gates: any CRITICAL or HIGH finding produces REJECTED status, blocking `/dw-code-review`, `/dw-review-implementation`, and `/dw-generate-pr`. No bypass flag. Requires Trivy (install via `install-deps`).
|
|
82
82
|
|
|
83
|
+
#### `/dw-deps-audit`
|
|
84
|
+
Supply-chain remediation orchestrator for **TypeScript, Python, C#, and Rust** projects. Runs three detection signals — `npm/pnpm/pip-audit/dotnet/cargo audit` for known CVEs, the `outdated` companions for stale versions, and an OSV.dev + GitHub Advisories cross-check (with a hardcoded fallback list of historical malicious-package incidents like `event-stream`, `ua-parser-js`, `node-ipc`) for supply-chain attacks. Classifies findings into COMPROMISED / CRITICAL / HIGH / OUTDATED-MAJOR / OUTDATED-MINOR tiers, maps each affected package to the files that import it and the tests that cover those files, then drafts a per-package update plan with three options (Conservative / Balanced / Bold) and trade-offs. Modes: `--scan-only` (CI), `--plan` (default — no file writes), `--execute` (applies updates with scoped tests, one `/dw-fix-qa` retry, atomic commits, and `/dw-run-qa` as final gate; reverts and marks BLOCKED if recovery fails). Complementary to `/dw-security-check`: that one is the single-shot gate, this one is the planner-and-remediator.
|
|
85
|
+
|
|
83
86
|
### Git & PR
|
|
84
87
|
|
|
85
88
|
#### `/dw-commit`
|
|
@@ -91,6 +94,16 @@ Pushes the branch to remote and creates a Pull Request on GitHub with a structur
|
|
|
91
94
|
#### `/dw-revert-task`
|
|
92
95
|
Safely reverts the commits of a specific task created by `/dw-run-task`, with dependency-aware checks (blocks if subsequent tasks already executed depend on it) and explicit user confirmation. Updates `tasks.md` to re-mark the task as pending.
|
|
93
96
|
|
|
97
|
+
### Project Bootstrap
|
|
98
|
+
|
|
99
|
+
#### `/dw-new-project`
|
|
100
|
+
Bootstraps a new project from an empty directory. Runs a wide stack interview (frontend/backend/fullstack, language, framework, db, cache, queue, email, storage, search, auth, observability, reverse proxy, scheduler, CI, linter), then wraps the right official `create-*` tools (`pnpm create next-app`, `pnpm create vite`, `pnpm dlx create-t3-app`, `dotnet new webapi`, `cargo new`, etc.) to scaffold the apps. Composes a `docker-compose.dev.yml` from the bundled `docker-compose-recipes` skill (postgres, redis, mailhog by default for email-in-dev, minio, meilisearch, jaeger, traefik, etc.), seeds `.env.example`, root scripts (`dev:up`/`down`/`logs`/`reset`), `.gitignore`/`.dockerignore`, GitHub Action, README with port table, and a minimal `.dw/rules/index.md`. Hard gate: presents a one-pager + plan and waits for explicit approval before touching disk.
|
|
101
|
+
|
|
102
|
+
### Containerization
|
|
103
|
+
|
|
104
|
+
#### `/dw-dockerize`
|
|
105
|
+
Reads an existing project, detects language / framework / package manager / runtime infra deps (postgres, redis, queue, email, storage, search, OTel) by parsing manifests and import statements, then proposes Docker artifacts. Modes: `--dev` (default if no Dockerfile exists) generates `docker-compose.dev.yml` + `Dockerfile.dev` from the bundled `docker-compose-recipes` skill; `--prod` generates a multi-stage `Dockerfile` (Conservative slim / Balanced alpine / Bold distroless — brainstormed with trade-offs) + optional `docker-compose.prod.yml` with non-root user, healthcheck, no secrets baked in; `--both` ships both; `--audit` (default if Docker artifacts already exist) reports findings against `security-review/infrastructure/docker.md` without overwriting. Hard gate: presents the file tree and waits for approval before any write. Sister command to `/dw-new-project` — they share the `docker-compose-recipes` bundled skill.
|
|
106
|
+
|
|
94
107
|
### Architectural Decisions
|
|
95
108
|
|
|
96
109
|
#### `/dw-adr`
|
|
@@ -116,6 +129,9 @@ Generates a functional documentation dossier with screen mapping, E2E flows, and
|
|
|
116
129
|
#### `/dw-help`
|
|
117
130
|
Displays the complete guide of available commands, integration flows, and when to use each one. Can be invoked without arguments for the full guide or with a specific command name for a detailed section.
|
|
118
131
|
|
|
132
|
+
#### `/dw-find-skills`
|
|
133
|
+
Discovers skills from the open agent skills ecosystem (`npx skills` / [skills.sh](https://skills.sh/)) when no `dw-*` already covers the request. Checks the leaderboard first, then runs `npx skills find <query>` if needed, vets each candidate (install count, source reputation, GitHub stars), and presents 1–3 options with the install commands. Asks whether to install globally (`-g`, lands in `~/.agents/skills/`) or locally (this repo) before running `npx skills add`. Falls back to `/dw-brainstorm` or `/dw-quick` when no skill matches. Ports the `find-skills` Claude superpowers skill into a `dw-*` command so every supported platform gets the same discovery on-ramp.
|
|
134
|
+
|
|
119
135
|
## Workflow
|
|
120
136
|
|
|
121
137
|
```
|
|
@@ -167,7 +183,7 @@ All wrappers point to `.dw/commands/` as the single source of truth.
|
|
|
167
183
|
```
|
|
168
184
|
your-project/
|
|
169
185
|
├── .dw/
|
|
170
|
-
│ ├── commands/ #
|
|
186
|
+
│ ├── commands/ # 31 workflow command files
|
|
171
187
|
│ ├── templates/ # Document templates (PRD, TechSpec, etc.)
|
|
172
188
|
│ ├── rules/ # Project-specific rules (run /dw-analyze-project)
|
|
173
189
|
│ ├── references/ # Reference documentation
|
package/lib/constants.js
CHANGED
|
@@ -11,11 +11,15 @@ const COMMANDS = {
|
|
|
11
11
|
{ name: 'dw-create-tasks', description: 'Breaks the PRD and techspec into tasks small enough to ship one at a time.' },
|
|
12
12
|
{ name: 'dw-create-techspec', description: 'Translates a finished PRD into a techspec the team can actually build from.' },
|
|
13
13
|
{ name: 'dw-deep-research', description: 'Researches a topic across sources, tracks citations, and flags claims that don\'t check out.' },
|
|
14
|
+
{ name: 'dw-deps-audit', description: 'Finds outdated and supply-chain-compromised packages, drafts a per-package update plan, and runs scoped QA after each upgrade.' },
|
|
15
|
+
{ name: 'dw-dockerize', description: 'Reads a project, detects the stack and runtime deps, then proposes Dockerfile and docker-compose for dev and prod with explicit trade-offs.' },
|
|
16
|
+
{ name: 'dw-find-skills', description: 'Searches the npx skills ecosystem for a skill matching what you need, vets it, and installs it where you choose.' },
|
|
14
17
|
{ name: 'dw-fix-qa', description: 'Fixes bugs found in QA and retests them with screenshot evidence until they stay fixed.' },
|
|
15
18
|
{ name: 'dw-functional-doc', description: 'Maps screens and user flows into a functional doc, validated end-to-end with Playwright.' },
|
|
16
19
|
{ name: 'dw-generate-pr', description: 'Pushes the branch and opens a PR with a body that explains what changed and how to test it.' },
|
|
17
20
|
{ name: 'dw-help', description: 'Lists every command and the flows that connect them. Pass a keyword for a contextual shortcut.' },
|
|
18
21
|
{ name: 'dw-intel', description: 'Answers questions about the codebase using its own rules and intel as the source of truth.' },
|
|
22
|
+
{ name: 'dw-new-project', description: 'Interviews you about stack and infra, then scaffolds a working monorepo with docker-compose for dev, .env, scripts, CI, and seeded rules.' },
|
|
19
23
|
{ name: 'dw-quick', description: 'Runs a small, well-defined change with workflow guarantees, no PRD needed.' },
|
|
20
24
|
{ name: 'dw-redesign-ui', description: 'Audits a frontend page, proposes design directions you choose from, then ships the redesign.' },
|
|
21
25
|
{ name: 'dw-refactoring-analysis', description: 'Catalogs code smells in Fowler\'s vocabulary and ranks them by impact, P0 to P3.' },
|
|
@@ -40,11 +44,15 @@ const COMMANDS = {
|
|
|
40
44
|
{ name: 'dw-create-tasks', description: 'Quebra PRD e techspec em tasks pequenas o suficiente para entregar uma de cada vez.' },
|
|
41
45
|
{ name: 'dw-create-techspec', description: 'Traduz um PRD pronto em um techspec que o time consegue construir de fato.' },
|
|
42
46
|
{ name: 'dw-deep-research', description: 'Pesquisa um topico em varias fontes, rastreia citacoes e marca o que nao confere.' },
|
|
47
|
+
{ name: 'dw-deps-audit', description: 'Encontra pacotes desatualizados e comprometidos por supply-chain, monta plano de update por pacote e roda QA do que foi afetado.' },
|
|
48
|
+
{ name: 'dw-dockerize', description: 'Le um projeto, detecta stack e deps de runtime, e propoe Dockerfile e docker-compose para dev e prod com trade-offs explicitos.' },
|
|
49
|
+
{ name: 'dw-find-skills', description: 'Busca no ecossistema npx skills uma skill que resolva o que voce precisa, valida e instala onde voce escolher.' },
|
|
43
50
|
{ name: 'dw-fix-qa', description: 'Corrige bugs do QA e retesta com evidencia em screenshot ate ficarem estaveis.' },
|
|
44
51
|
{ name: 'dw-functional-doc', description: 'Mapeia telas e fluxos em um dossie funcional, validado E2E com Playwright.' },
|
|
45
52
|
{ name: 'dw-generate-pr', description: 'Faz push da branch e abre um PR com corpo explicando o que mudou e como testar.' },
|
|
46
53
|
{ name: 'dw-help', description: 'Lista todos os commands e os fluxos que os conectam. Passe uma keyword para atalho contextual.' },
|
|
47
54
|
{ name: 'dw-intel', description: 'Responde perguntas sobre o codebase usando suas proprias rules e intel como fonte.' },
|
|
55
|
+
{ name: 'dw-new-project', description: 'Entrevista voce sobre stack e infra, depois faz scaffold de um monorepo com docker-compose para dev, .env, scripts, CI e rules seed.' },
|
|
48
56
|
{ name: 'dw-quick', description: 'Roda uma mudanca pequena e bem definida com garantias do workflow, sem precisar de PRD.' },
|
|
49
57
|
{ name: 'dw-redesign-ui', description: 'Audita uma pagina frontend, propoe direcoes de design que voce escolhe, e entrega o redesign.' },
|
|
50
58
|
{ name: 'dw-refactoring-analysis', description: 'Cataloga code smells no vocabulario de Fowler e ranqueia por impacto, P0 a P3.' },
|
package/lib/install-deps.js
CHANGED
|
@@ -39,6 +39,19 @@ function run() {
|
|
|
39
39
|
'Once installed, /dw-security-check will use it for CVE, secret, and IaC scanning.',
|
|
40
40
|
],
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Docker + Docker Compose',
|
|
44
|
+
check: 'docker --version && (docker compose version || docker-compose --version)',
|
|
45
|
+
install: null,
|
|
46
|
+
instructions: [
|
|
47
|
+
'Docker is required by /dw-new-project and /dw-dockerize for dev dependency seeding and image generation.',
|
|
48
|
+
' macOS: https://docs.docker.com/desktop/install/mac-install/',
|
|
49
|
+
' Windows: https://docs.docker.com/desktop/install/windows-install/',
|
|
50
|
+
' Linux: https://docs.docker.com/engine/install/ (then enable the Compose plugin: https://docs.docker.com/compose/install/linux/)',
|
|
51
|
+
'',
|
|
52
|
+
'Verify after install: docker --version && docker compose version',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
42
55
|
];
|
|
43
56
|
|
|
44
57
|
let installed = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brunosps00/dev-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "AI-driven development workflow commands for any project. Scaffolds a complete PRD-to-PR pipeline with multi-platform AI assistant support.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dev-workflow": "./bin/dev-workflow.js"
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<system_instructions>
|
|
2
|
+
You are a dependency-supply-chain remediation lead. Your job is to **find** outdated and supply-chain-compromised packages, **plan** a per-package update strategy with explicit trade-offs, and (when authorized) **execute** updates safely with scoped QA so the upgrade does not regress where the package is actually used.
|
|
3
|
+
|
|
4
|
+
This command is **distinct** from `/dw-security-check`:
|
|
5
|
+
- `/dw-security-check` is a single-shot SAST + SCA verdict (CRITICAL/HIGH = REJECTED, no remediation).
|
|
6
|
+
- `/dw-deps-audit` is a multi-phase planner-and-remediator: detect → classify → brainstorm update plan → human gate → execute with scoped QA → report.
|
|
7
|
+
|
|
8
|
+
<critical>This command is rigid about safety: in `--execute` mode, NO file may be modified before the user explicitly approves the plan presented at the end of Phase 3. No bypass flag.</critical>
|
|
9
|
+
<critical>Supported languages: TypeScript/JavaScript, Python, C#, Rust. Abort with a clear message if none is detected in scope.</critical>
|
|
10
|
+
<critical>If the package upgrade fails its scoped tests AND one `dw-fix-qa` cycle does not recover, REVERT the change (lockfile + manifest) and mark the package BLOCKED. Do not leave dirty state.</critical>
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- After `/dw-security-check` flags vulnerable dependencies and you need a remediation plan
|
|
15
|
+
- When the team wants to clear up technical debt around outdated packages with a controlled rollout
|
|
16
|
+
- When monitoring catches a public supply-chain incident (e.g., a malicious package published) and you need to confirm exposure + plan removal/pin
|
|
17
|
+
- Before a major release, to reduce the surface of known CVEs in shipped dependencies
|
|
18
|
+
- NOT for runtime DAST or for application code review (use `/dw-run-qa` and `/dw-code-review`)
|
|
19
|
+
- NOT a replacement for `/dw-security-check` — they are complementary; this one focuses on SCA and remediation, not OWASP static review
|
|
20
|
+
|
|
21
|
+
## Pipeline Position
|
|
22
|
+
|
|
23
|
+
**Predecessor:** `/dw-security-check` (optional — its findings can prefill this command's inventory) | **Successor:** `/dw-code-review` and `/dw-generate-pr` (the report is evidence the deps surface is clean for the PR)
|
|
24
|
+
|
|
25
|
+
## Complementary Skills
|
|
26
|
+
|
|
27
|
+
| Skill | Trigger |
|
|
28
|
+
|-------|---------|
|
|
29
|
+
| `dw-verify` | **ALWAYS** — every phase emits a VERIFICATION REPORT (commands run, exit codes, artifacts) before the next phase starts |
|
|
30
|
+
| `dw-review-rigor` | **ALWAYS** — applies de-duplication (same advisory across N packages = 1 finding with affected list), severity ordering, and signal-over-volume on the OUTDATED-MINOR list |
|
|
31
|
+
| `security-review` (`references/supply-chain.md`) | **ALWAYS** when classifying findings — gives OWASP A06 (Vulnerable & Outdated Components) framing for the brainstorm trade-offs |
|
|
32
|
+
| `dw-council` | Auto opt-in when ≥3 packages land in tier COMPROMISED — multi-advisor stress-test on remediation order and scope |
|
|
33
|
+
| `webapp-testing` | Optional — when the project is frontend and the scoped test phase needs Playwright-aware test selection |
|
|
34
|
+
|
|
35
|
+
## Input Variables
|
|
36
|
+
|
|
37
|
+
| Variable | Description | Example |
|
|
38
|
+
|----------|-------------|---------|
|
|
39
|
+
| `{{SCOPE}}` | PRD path OR source path. Optional — defaults to `.dw/spec/prd-<slug>` inferred from the active `feat/prd-<slug>` git branch | `.dw/spec/prd-checkout-v2` or `.` |
|
|
40
|
+
| `{{MODE}}` | One of `--scan-only`, `--plan` (default), `--execute` | `--execute` |
|
|
41
|
+
|
|
42
|
+
If `{{SCOPE}}` is not provided and no PRD is active, scope falls back to the repo root (`.`) and the report goes to `.dw/audit/`.
|
|
43
|
+
|
|
44
|
+
## File Locations
|
|
45
|
+
|
|
46
|
+
- Report (PRD scope): `{{SCOPE}}/deps-audit.md`
|
|
47
|
+
- Report (no PRD scope): `.dw/audit/deps-audit-<YYYY-MM-DD>.md`
|
|
48
|
+
- Inventory raw artifacts (always): `/tmp/dw-deps-audit-<run-id>/{npm-audit.json, npm-outdated.json, pip-audit.json, ...}`
|
|
49
|
+
- Skill references: `.agents/skills/security-review/references/supply-chain.md`
|
|
50
|
+
|
|
51
|
+
## Required Behavior — Pipeline
|
|
52
|
+
|
|
53
|
+
Execute phases in order. Phase 4 only runs when `{{MODE}} == --execute` AND the user approved the plan in Phase 3.5.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Phase 0 — Language Detection
|
|
58
|
+
|
|
59
|
+
Enumerate files in scope and detect languages:
|
|
60
|
+
|
|
61
|
+
| Language | Indicators |
|
|
62
|
+
|----------|------------|
|
|
63
|
+
| TypeScript / JavaScript | `package.json`, `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `*.ts`, `*.tsx`, `*.js`, `*.jsx`, `*.mjs` |
|
|
64
|
+
| Python | `pyproject.toml`, `requirements*.txt`, `Pipfile`, `poetry.lock`, `setup.py`, `*.py` |
|
|
65
|
+
| C# / .NET | `*.csproj`, `*.sln`, `packages.config`, `*.cs` |
|
|
66
|
+
| Rust | `Cargo.toml`, `Cargo.lock`, `*.rs` |
|
|
67
|
+
|
|
68
|
+
If none of the four is detected → **abort** with:
|
|
69
|
+
`"dw-deps-audit currently supports TypeScript, Python, C#, and Rust. No files in supported languages were detected in <scope>. Aborting."`
|
|
70
|
+
|
|
71
|
+
Polyglot repos run every applicable language layer; the report has a section per language.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Phase 1 — Inventory (three signals)
|
|
76
|
+
|
|
77
|
+
Build the candidate set from three independent signals so nothing slips through.
|
|
78
|
+
|
|
79
|
+
#### Signal A — Known vulnerabilities (SCA)
|
|
80
|
+
|
|
81
|
+
| Language | Primary command | Notes |
|
|
82
|
+
|----------|-----------------|-------|
|
|
83
|
+
| TS/JS (npm) | `npm audit --json` | Detect package manager via lockfile |
|
|
84
|
+
| TS/JS (pnpm) | `pnpm audit --json` | |
|
|
85
|
+
| TS/JS (yarn) | `yarn npm audit --recursive --json` | Yarn Berry; for v1 use `yarn audit --json` |
|
|
86
|
+
| Python | `pip-audit --strict --format json` | Skip with note if `pip-audit` not installed |
|
|
87
|
+
| C# / .NET | `dotnet list package --vulnerable --include-transitive` | Output is human-readable; parse table |
|
|
88
|
+
| Rust | `cargo audit --json` | Skip with note if `cargo-audit` not installed; suggest `cargo install cargo-audit` |
|
|
89
|
+
|
|
90
|
+
#### Signal B — Outdated packages
|
|
91
|
+
|
|
92
|
+
| Language | Primary command | Notes |
|
|
93
|
+
|----------|-----------------|-------|
|
|
94
|
+
| TS/JS (npm) | `npm outdated --json` | Returns 1 when outdated exist; this is expected |
|
|
95
|
+
| TS/JS (pnpm) | `pnpm outdated --format json` | |
|
|
96
|
+
| TS/JS (yarn) | `yarn outdated --json` | |
|
|
97
|
+
| Python | `pip list --outdated --format json` | |
|
|
98
|
+
| C# / .NET | `dotnet list package --outdated` | |
|
|
99
|
+
| Rust | `cargo outdated --format json` | Skip with note if `cargo-outdated` not installed |
|
|
100
|
+
|
|
101
|
+
#### Signal C — Supply-chain attacks (the differentiator)
|
|
102
|
+
|
|
103
|
+
This signal looks for **maliciously published** packages, not just CVE-flagged ones.
|
|
104
|
+
|
|
105
|
+
1. **OSV.dev cross-check** — for every direct dependency, query the OSV API for `OSV-MAL-*` advisories (malicious-package category):
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
POST https://api.osv.dev/v1/query
|
|
109
|
+
Body: {"package": {"name": "<name>", "ecosystem": "<npm|PyPI|NuGet|crates.io>"}}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Fetch via WebFetch. Filter results where `id` starts with `MAL-` or `aliases` includes a `MAL-` advisory.
|
|
113
|
+
2. **GitHub Security Advisories cross-check** — query for advisories in the matching ecosystem that are `severity:critical` or `published_in_last_90_days`. WebFetch from `https://api.github.com/advisories?ecosystem=<eco>&severity=critical&per_page=100` (no auth needed for public advisories).
|
|
114
|
+
3. **Hardcoded fallback list** — a known set of historic malicious-package incidents to catch even when offline. Include at minimum:
|
|
115
|
+
- `event-stream` (any version after compromise)
|
|
116
|
+
- `ua-parser-js@0.7.29 || 0.7.30 || 0.7.31 || 1.0.0`
|
|
117
|
+
- `node-ipc@>=10.1.1`
|
|
118
|
+
- `coa@2.0.3`
|
|
119
|
+
- `colors@1.4.1`
|
|
120
|
+
- `flatmap-stream` (any version)
|
|
121
|
+
- `ctx@*` (PyPI typosquat incident)
|
|
122
|
+
- `phpass@*` (PyPI typosquat incident)
|
|
123
|
+
- `xrpl@4.2.1 || 4.2.2 || 4.2.3 || 4.2.4`
|
|
124
|
+
|
|
125
|
+
<critical>The hardcoded list is a SECONDARY signal. It will go stale. The OSV consult is the source of truth — note in the report when OSV was unreachable and the run fell back to the hardcoded list only.</critical>
|
|
126
|
+
|
|
127
|
+
Write a VERIFICATION REPORT for Phase 1 (commands + exit codes + finding counts) before moving on.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Phase 2 — Classification
|
|
132
|
+
|
|
133
|
+
Bucket every candidate from Phase 1 into one tier. Apply `dw-review-rigor` rules:
|
|
134
|
+
- De-duplicate: the same advisory affecting N packages is one finding with the affected list.
|
|
135
|
+
- Severity ordering: COMPROMISED → CRITICAL CVE → HIGH CVE → OUTDATED-MAJOR → OUTDATED-MINOR.
|
|
136
|
+
- Signal over volume: in the report, list every COMPROMISED/CRITICAL/HIGH; collapse OUTDATED-MINOR to a count plus the top 5 by usage.
|
|
137
|
+
|
|
138
|
+
| Tier | Criterion | Default action |
|
|
139
|
+
|------|-----------|----------------|
|
|
140
|
+
| **COMPROMISED** | Match against OSV-MAL-*, GitHub critical advisory, or hardcoded list | Always in plan; cannot be unchecked by the user (warning if attempted) |
|
|
141
|
+
| **CRITICAL CVE** | CVSS ≥ 9.0 OR advisory marked exploited | Always in plan; user can defer with explicit reason captured in report |
|
|
142
|
+
| **HIGH CVE** | CVSS 7.0 – 8.9 | Always in plan; user can defer with explicit reason |
|
|
143
|
+
| **OUTDATED-MAJOR** | Current version is at least one major behind latest stable | Goes through brainstorm; user picks per package |
|
|
144
|
+
| **OUTDATED-MINOR** | Outdated minor/patch with no CVE | Summarized only; not in the per-package plan |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### Phase 3 — Impact Mapping + Brainstorm
|
|
149
|
+
|
|
150
|
+
For every package in tiers **COMPROMISED / CRITICAL CVE / HIGH CVE / OUTDATED-MAJOR**:
|
|
151
|
+
|
|
152
|
+
#### 3.1 Usage mapping
|
|
153
|
+
|
|
154
|
+
Find every file that imports the package:
|
|
155
|
+
|
|
156
|
+
- TS/JS: `from '<pkg>'` / `from "<pkg>/..."` / `require('<pkg>')` / `import('<pkg>')`
|
|
157
|
+
- Python: `import <pkg>` / `from <pkg> import` / `from <pkg>.* import`
|
|
158
|
+
- C#: `using <pkg>;` (root namespace) / `<PackageReference Include="<pkg>" .../>` for transitive verification
|
|
159
|
+
- Rust: `use <pkg>::` / `extern crate <pkg>` / `<pkg>::` qualified paths
|
|
160
|
+
|
|
161
|
+
Use `Grep` and `Glob`. Capture the file list per package.
|
|
162
|
+
|
|
163
|
+
#### 3.2 Test mapping
|
|
164
|
+
|
|
165
|
+
For each file in 3.1, find the tests that exercise it. Heuristics (apply in order):
|
|
166
|
+
|
|
167
|
+
1. Same-name pair: `src/foo.ts` ↔ `src/foo.test.ts` / `src/foo.spec.ts`.
|
|
168
|
+
2. Sibling test directory: `__tests__/foo.test.ts`, `tests/test_foo.py`, `Foo.Tests/FooTests.cs`, `tests/foo.rs`.
|
|
169
|
+
3. Symbol search: grep tests for the exported symbol used by the application file.
|
|
170
|
+
4. Build a concrete test command per language:
|
|
171
|
+
- npm: `npm test -- <files>` or the project's documented unit-test script (`test:unit`).
|
|
172
|
+
- pnpm: `pnpm test -- <files>`. yarn: `yarn test <files>`.
|
|
173
|
+
- Python: `pytest <files>`.
|
|
174
|
+
- .NET: `dotnet test --filter "FullyQualifiedName~<Class>"`.
|
|
175
|
+
- Rust: `cargo test <module>` or `cargo test --package <pkg-using-it>`.
|
|
176
|
+
|
|
177
|
+
If a file has zero discoverable tests, mark it `UNCOVERED` and surface in the report — the user must accept the risk before the upgrade proceeds in `--execute` mode.
|
|
178
|
+
|
|
179
|
+
#### 3.3 Brainstorm (3 options per package)
|
|
180
|
+
|
|
181
|
+
For each package, present three update strategies in `dw-brainstorm` style:
|
|
182
|
+
|
|
183
|
+
| Option | Definition | Effort | Breaking risk | Security upside |
|
|
184
|
+
|--------|------------|--------|---------------|-----------------|
|
|
185
|
+
| **Conservative** | Pin to the closest fixed version on the current major (or remove the package entirely if COMPROMISED and it has a drop-in alternative) | S | Low | High (closes the advisory) |
|
|
186
|
+
| **Balanced** | Upgrade to the highest minor/patch within the current major | S–M | Low–Medium | High |
|
|
187
|
+
| **Bold** | Upgrade to the latest major | M–L | Medium–High (may need refactor) | Highest (latest patches + new features) |
|
|
188
|
+
|
|
189
|
+
For each option, list:
|
|
190
|
+
- Target version
|
|
191
|
+
- Breaking-change notes (skim CHANGELOG / GitHub releases if reachable; cite source)
|
|
192
|
+
- Refactor scope estimate (file count from 3.1)
|
|
193
|
+
|
|
194
|
+
#### 3.4 Recommendation
|
|
195
|
+
|
|
196
|
+
One line per package: **recommended option** + the next-action command (e.g., `npm install lodash@4.17.21 && npm test`).
|
|
197
|
+
|
|
198
|
+
#### 3.5 Human approval gate
|
|
199
|
+
|
|
200
|
+
Present the full plan and ask the user, via `AskUserQuestion` if available, otherwise via a numbered prompt:
|
|
201
|
+
|
|
202
|
+
1. Which packages to apply
|
|
203
|
+
2. Which option (Conservative / Balanced / Bold) per package
|
|
204
|
+
3. For COMPROMISED packages: confirmation they understand removal cannot be deferred
|
|
205
|
+
|
|
206
|
+
Without explicit approval, the command terminates here with status **PLANNED** and writes the report.
|
|
207
|
+
|
|
208
|
+
If `{{MODE}} == --plan` (default), STOP after writing the report. Do not enter Phase 4.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### Phase 4 — Guided Execution (`--execute` only)
|
|
213
|
+
|
|
214
|
+
For each approved package, in the order COMPROMISED → CRITICAL → HIGH → OUTDATED-MAJOR:
|
|
215
|
+
|
|
216
|
+
1. **Apply the update**:
|
|
217
|
+
- npm/pnpm/yarn: detect manager from lockfile, then run the matching command:
|
|
218
|
+
- `npm install <pkg>@<v> --save-exact`
|
|
219
|
+
- `pnpm add <pkg>@<v>`
|
|
220
|
+
- `yarn add <pkg>@<v>` (Berry) or `yarn upgrade <pkg>@<v>` (v1)
|
|
221
|
+
- Python: `pip install -U "<pkg>==<v>"` OR `poetry add <pkg>@<v>` if `poetry.lock` exists OR edit `pyproject.toml` and `pip install -e .`
|
|
222
|
+
- C#: `dotnet add package <pkg> --version <v>`
|
|
223
|
+
- Rust: edit `Cargo.toml` and run `cargo update -p <pkg> --precise <v>`
|
|
224
|
+
2. **Run scoped tests** from Phase 3.2 — only the tests that touch this package, not the full suite. Capture stdout, stderr, exit code.
|
|
225
|
+
3. **If tests fail**:
|
|
226
|
+
- Run one cycle of `dw-fix-qa` automatically (same fix-retest pattern as `/dw-fix-qa`).
|
|
227
|
+
- If still failing after that one cycle: **revert the update**:
|
|
228
|
+
- Restore the lockfile + manifest from git (`git checkout -- <lockfile> <manifest>`)
|
|
229
|
+
- Run the install command again to reconcile installed deps with the restored lockfile
|
|
230
|
+
- Mark the package **BLOCKED** in the report with the failing test names and stderr excerpt
|
|
231
|
+
- Move to the next package
|
|
232
|
+
4. **If tests pass**: create an atomic commit per package:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
chore(deps): update <pkg> from <old> to <new> [supply-chain] (<tier>)
|
|
236
|
+
|
|
237
|
+
- Closes <CVE-ID> | <OSV-ID> | <advisory>
|
|
238
|
+
- Scoped tests passed: <test-count>
|
|
239
|
+
- Files importing <pkg>: <count>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
5. After all approved packages are processed, run `/dw-run-qa` (PRD scope if available, otherwise the e2e suite) as a final gate.
|
|
243
|
+
- PASS → status **EXECUTED-CLEAN**
|
|
244
|
+
- FAIL → status **EXECUTED-PARTIAL** (committed packages stay; final QA failure is documented)
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
### Phase 5 — Report
|
|
249
|
+
|
|
250
|
+
Write the report to:
|
|
251
|
+
- `.dw/spec/prd-<slug>/deps-audit.md` if PRD scope
|
|
252
|
+
- `.dw/audit/deps-audit-<YYYY-MM-DD>.md` otherwise (create the directory if missing)
|
|
253
|
+
|
|
254
|
+
Frontmatter:
|
|
255
|
+
|
|
256
|
+
```markdown
|
|
257
|
+
---
|
|
258
|
+
type: deps-audit
|
|
259
|
+
schema_version: "1.0"
|
|
260
|
+
status: <SCANNED | PLANNED | EXECUTED-CLEAN | EXECUTED-PARTIAL | BLOCKED>
|
|
261
|
+
date: YYYY-MM-DD
|
|
262
|
+
languages: [typescript, python, csharp, rust]
|
|
263
|
+
mode: <scan|plan|execute>
|
|
264
|
+
osv_consulted: <true|false>
|
|
265
|
+
github_advisories_consulted: <true|false>
|
|
266
|
+
---
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Sections:
|
|
270
|
+
|
|
271
|
+
1. **VERIFICATION REPORT** (per phase: command, exit code, artifact path)
|
|
272
|
+
2. **Inventory** — per-language tables of Signal A / B / C results
|
|
273
|
+
3. **Classification** — packages grouped by tier
|
|
274
|
+
4. **Impact Mapping** — per package: usage files, test files, UNCOVERED warning if any
|
|
275
|
+
5. **Brainstorm & Recommendations** — 3 options per package + the recommended one
|
|
276
|
+
6. **Human Approvals** — only in `--execute`: which packages were approved with which option, and reasons for any deferral
|
|
277
|
+
7. **Execution Log** — only in `--execute`: per package, install command, test command, result, commit SHA (or BLOCKED reason)
|
|
278
|
+
8. **Final QA** — only in `--execute`: `/dw-run-qa` outcome
|
|
279
|
+
9. **Next Steps** — packages still BLOCKED, packages deferred to a future run, link to `/dw-security-check` for the next gate
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Flags
|
|
284
|
+
|
|
285
|
+
| Flag | Phases | Use |
|
|
286
|
+
|------|--------|-----|
|
|
287
|
+
| (default) `--plan` | 0 → 3 → 5 | Detect, classify, brainstorm, write the plan. No file mutations. Good default. |
|
|
288
|
+
| `--scan-only` | 0 → 2 → 5 | Detect and classify. Skip brainstorm and execution. Designed for CI dashboards. |
|
|
289
|
+
| `--execute` | 0 → 5 | Full pipeline including updates, scoped QA, commits. Requires explicit human approval at Phase 3.5. |
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Critical Rules
|
|
294
|
+
|
|
295
|
+
- <critical>Phase 4 NEVER runs without explicit approval captured in Phase 3.5. If the agent executing this command has no interactive channel and `--execute` is passed, abort with: `"--execute requires interactive approval; rerun with --plan and apply approved changes manually."`</critical>
|
|
296
|
+
- <critical>COMPROMISED packages are ALWAYS in the plan. The user can decline, but the report records the declined COMPROMISED entries with a visible warning section.</critical>
|
|
297
|
+
- <critical>If scoped tests fail and `dw-fix-qa` cannot recover in one cycle, the update is REVERTED. No partial commit.</critical>
|
|
298
|
+
- <critical>OSV consult is the source of truth for COMPROMISED. The hardcoded list is a fallback only; flag in the report when OSV was unreachable.</critical>
|
|
299
|
+
- Do NOT bump packages outside the approved list, even if they appear in `npm outdated`.
|
|
300
|
+
- Do NOT modify lockfiles directly — let the package manager regenerate them.
|
|
301
|
+
- Do NOT run `npm audit fix --force` or any auto-fix flag; it bypasses the brainstorm and the human gate.
|
|
302
|
+
- Do NOT skip the Phase 5 report, even on early abort — write what was collected so the next run has context.
|
|
303
|
+
|
|
304
|
+
## Error Handling
|
|
305
|
+
|
|
306
|
+
- Tool missing (`pip-audit`, `cargo-audit`, `cargo-outdated`) → skip that signal with a visible note in the report; do not fail.
|
|
307
|
+
- OSV API unreachable → use the hardcoded list as fallback, mark `osv_consulted: false` in the frontmatter, add a visible warning in the report.
|
|
308
|
+
- GitHub Advisories API rate-limited → fall back to hardcoded list for the rest of the run, mark `github_advisories_consulted: false`.
|
|
309
|
+
- Lockfile missing for a detected language (e.g., `package.json` but no `package-lock.json`) → skip Signal A/B for that language, note it; the user must commit a lockfile first.
|
|
310
|
+
- `--execute` requested but the working tree is dirty → abort with `"Working tree must be clean before --execute (uncommitted changes detected). Commit or stash, then retry."`
|
|
311
|
+
- `dw-fix-qa` not available in the environment → in `--execute`, fall back to a direct revert (no fix attempt) and mark BLOCKED.
|
|
312
|
+
|
|
313
|
+
## Integration With Other dw-* Commands
|
|
314
|
+
|
|
315
|
+
- **`/dw-security-check`** — its findings can prefill Phase 1 Signal A. After `EXECUTED-CLEAN` from this command, rerun `/dw-security-check` to confirm the verdict flips.
|
|
316
|
+
- **`/dw-run-qa`** — invoked as the final gate in Phase 4 step 5.
|
|
317
|
+
- **`/dw-fix-qa`** — invoked once per failing package in Phase 4 step 3 (recover or revert).
|
|
318
|
+
- **`/dw-brainstorm`** — Phase 3.3 reuses its three-option (Conservative/Balanced/Bold) discipline, but applies it per package, not per feature.
|
|
319
|
+
- **`/dw-commit`** — not invoked directly; this command writes its own commit messages with the supply-chain trailer.
|
|
320
|
+
- **`/dw-generate-pr`** — the report is evidence of remediation in the PR body.
|
|
321
|
+
|
|
322
|
+
## Inspired by
|
|
323
|
+
|
|
324
|
+
`dw-deps-audit` is dev-workflow-native. The detection layer reuses the SCA pipeline already declared in `/dw-security-check` (npm/pnpm/pip-audit/dotnet/cargo). The brainstorm layer borrows the three-option (Conservative/Balanced/Bold) discipline from `/dw-brainstorm`. The fix-retest loop borrows from `/dw-run-qa` and `/dw-fix-qa`. OWASP A06 (Vulnerable & Outdated Components) framing comes from the `security-review` skill (`references/supply-chain.md`). The OSV.dev consult and the malicious-package incident list are first-class signals here — neither `/dw-security-check` nor any of the open-source skills surfaced via `/dw-find-skills` integrate them as a remediation orchestrator.
|
|
325
|
+
|
|
326
|
+
</system_instructions>
|