@brunosps00/dev-workflow 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +16 -12
  2. package/bin/dev-workflow.js +1 -1
  3. package/lib/constants.js +8 -2
  4. package/lib/init.js +6 -0
  5. package/lib/install-deps.js +0 -5
  6. package/lib/migrate-gsd.js +164 -0
  7. package/lib/uninstall.js +2 -2
  8. package/package.json +1 -1
  9. package/scaffold/en/commands/dw-analyze-project.md +6 -11
  10. package/scaffold/en/commands/dw-autopilot.md +6 -13
  11. package/scaffold/en/commands/dw-brainstorm.md +1 -1
  12. package/scaffold/en/commands/dw-code-review.md +6 -5
  13. package/scaffold/en/commands/dw-create-prd.md +5 -4
  14. package/scaffold/en/commands/dw-create-techspec.md +5 -4
  15. package/scaffold/en/commands/dw-execute-phase.md +149 -0
  16. package/scaffold/en/commands/dw-help.md +5 -2
  17. package/scaffold/en/commands/dw-intel.md +98 -29
  18. package/scaffold/en/commands/dw-map-codebase.md +125 -0
  19. package/scaffold/en/commands/dw-new-project.md +1 -1
  20. package/scaffold/en/commands/dw-plan-checker.md +144 -0
  21. package/scaffold/en/commands/dw-quick.md +30 -12
  22. package/scaffold/en/commands/dw-redesign-ui.md +5 -9
  23. package/scaffold/en/commands/dw-refactoring-analysis.md +6 -5
  24. package/scaffold/en/commands/dw-resume.md +10 -8
  25. package/scaffold/en/commands/dw-run-plan.md +14 -20
  26. package/scaffold/en/commands/dw-run-task.md +5 -4
  27. package/scaffold/en/commands/dw-update.md +3 -1
  28. package/scaffold/en/templates/idea-onepager.md +1 -1
  29. package/scaffold/pt-br/commands/dw-analyze-project.md +6 -11
  30. package/scaffold/pt-br/commands/dw-autopilot.md +6 -13
  31. package/scaffold/pt-br/commands/dw-brainstorm.md +1 -1
  32. package/scaffold/pt-br/commands/dw-code-review.md +6 -5
  33. package/scaffold/pt-br/commands/dw-create-prd.md +5 -4
  34. package/scaffold/pt-br/commands/dw-create-techspec.md +5 -4
  35. package/scaffold/pt-br/commands/dw-execute-phase.md +149 -0
  36. package/scaffold/pt-br/commands/dw-help.md +5 -2
  37. package/scaffold/pt-br/commands/dw-intel.md +98 -29
  38. package/scaffold/pt-br/commands/dw-map-codebase.md +125 -0
  39. package/scaffold/pt-br/commands/dw-new-project.md +1 -1
  40. package/scaffold/pt-br/commands/dw-plan-checker.md +144 -0
  41. package/scaffold/pt-br/commands/dw-quick.md +30 -12
  42. package/scaffold/pt-br/commands/dw-redesign-ui.md +5 -9
  43. package/scaffold/pt-br/commands/dw-refactoring-analysis.md +6 -5
  44. package/scaffold/pt-br/commands/dw-resume.md +10 -8
  45. package/scaffold/pt-br/commands/dw-run-plan.md +16 -22
  46. package/scaffold/pt-br/commands/dw-run-task.md +5 -4
  47. package/scaffold/pt-br/commands/dw-update.md +3 -1
  48. package/scaffold/pt-br/templates/idea-onepager.md +1 -1
  49. package/scaffold/skills/dw-codebase-intel/SKILL.md +101 -0
  50. package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +318 -0
  51. package/scaffold/skills/dw-codebase-intel/references/incremental-update.md +79 -0
  52. package/scaffold/skills/dw-codebase-intel/references/intel-format.md +208 -0
  53. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +148 -0
  54. package/scaffold/skills/dw-execute-phase/SKILL.md +133 -0
  55. package/scaffold/skills/dw-execute-phase/agents/executor.md +264 -0
  56. package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +215 -0
  57. package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +143 -0
  58. package/scaffold/skills/dw-execute-phase/references/plan-verification.md +156 -0
  59. package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +102 -0
@@ -25,15 +25,16 @@ Quando disponíveis no projeto em `./.agents/skills/`, use estas skills como sup
25
25
 
26
26
  ## Inteligência do Codebase
27
27
 
28
- <critical>Se `.planning/intel/` existir, a consulta é OBRIGATÓRIA antes de redigir os requisitos. NÃO pule este passo.</critical>
29
- - Execute internamente: `/gsd-intel "padrões de implementação em [área alvo da task]"`
28
+ <critical>Se `.dw/intel/` existir, a consulta via `/dw-intel` é OBRIGATÓRIA antes de codar. NÃO pule este passo.</critical>
29
+ - Execute internamente: `/dw-intel "padrões de implementação em [área alvo da task]"`
30
30
  - Siga convenções encontradas para estrutura de arquivos, nomenclatura e tratamento de erros
31
31
 
32
32
  Se `design-contract.md` existir no diretório do PRD:
33
33
  - Leia o contrato e garanta que toda implementação frontend siga as regras de design aprovadas
34
34
 
35
- Se `.planning/intel/` NÃO existir:
36
- - Use `.dw/rules/` como contexto (comportamento atual)
35
+ Se `.dw/intel/` NÃO existir:
36
+ - Use `.dw/rules/` como contexto, caindo para grep direto se necessário
37
+ - Sugira rodar `/dw-map-codebase` após a task para enriquecer contexto downstream
37
38
 
38
39
  ## Localização dos Arquivos
39
40
 
@@ -79,7 +79,9 @@ npx -y @brunosps00/dev-workflow@latest update --lang=$DETECTED_LANG
79
79
  O comando `update` sobrescreve arquivos gerenciados e PRESERVA:
80
80
  - `.dw/rules/` (rules do usuário)
81
81
  - `.dw/spec/` (PRDs e tasks em andamento)
82
- - `.planning/` (dados do usuário)
82
+ - `.dw/intel/` (índice de codebase do `/dw-map-codebase`)
83
+
84
+ O comando `update` também roda o passo de migração GSD automaticamente — se o projeto tem `.planning/` legado (de uso prévio do GSD), o conteúdo é migrado para `.dw/intel/`, `.dw/spec/active-session.md`, `.dw/spec/quick/`, etc., e `.planning/` é renomeado para `.planning.gsd-archive-<DATA>/` para inspeção. Os arquivos `.claude/commands/gsd/`, `.claude/agents/gsd-*.md`, `.claude/hooks/gsd-*.js` e `.claude/gsd-file-manifest.json` são removidos durante a migração.
83
85
 
84
86
  Se o update falhar (erro de rede, permissão, pacote indisponível): reporte o erro ao usuário e PARE. NÃO tente workarounds manuais como copiar arquivos.
85
87
 
@@ -22,7 +22,7 @@ Foque no problema, não na solução. Evite entrar em "como implementar".]
22
22
  Fontes:
23
23
  - PRDs em `.dw/spec/prd-*/prd.md` (features já entregues ou em desenvolvimento)
24
24
  - `.dw/rules/index.md` (overview do produto)
25
- - `.planning/intel/` se GSD estiver instalado
25
+ - `.dw/intel/` (indice queryable construido por `/dw-map-codebase`, consultado via `/dw-intel`)
26
26
 
27
27
  Formato:]
28
28
 
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: dw-codebase-intel
3
+ description: Codebase intelligence for dev-workflow. The intel-updater agent maintains a queryable index in .dw/intel/ (stack.json, files.json, apis.json, deps.json, arch.md) that other commands read instead of doing expensive codebase exploration. Used by /dw-intel and /dw-map-codebase. Adapted from get-shit-done-cc (MIT).
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ ---
11
+
12
+ # dw-codebase-intel
13
+
14
+ Bundled skill that gives dev-workflow native **codebase intelligence** — a queryable knowledge base of the project's stack, file graph, API surface, dependencies, and architecture. Other commands (`/dw-create-prd`, `/dw-create-techspec`, `/dw-code-review`, `/dw-refactoring-analysis`, `/dw-brainstorm`, etc.) read from this index instead of re-exploring the codebase on every invocation.
15
+
16
+ ## Why a skill (not inline)
17
+
18
+ - Each agent is independently maintainable and reusable.
19
+ - The format of `.dw/intel/` is a contract that downstream commands depend on; codifying it in references makes drift visible.
20
+ - Other commands invoke these agents through the skill, not by duplicating the logic.
21
+
22
+ ## When to Use
23
+
24
+ Read this skill when:
25
+
26
+ - `/dw-map-codebase` is invoked (full or partial codebase analysis).
27
+ - `/dw-intel "<query>"` is invoked (query existing intel).
28
+ - `/dw-analyze-project` runs after first commit and wants to enrich `.dw/rules/` with structural facts from `.dw/intel/`.
29
+ - Any other `dw-*` command wants to look up "where is X used", "what frameworks are in this stack", "what's the architecture pattern" without re-scanning files.
30
+
31
+ Do NOT use when:
32
+
33
+ - The user is asking a runtime question (use logs / running app).
34
+ - The intel is fresh (`.dw/intel/.last-refresh.json` is current and the user did not ask for a refresh).
35
+ - The project is greenfield with no source files yet — in that case, fall back to `.dw/rules/` seeded by `/dw-new-project`.
36
+
37
+ ## Files in `.dw/intel/`
38
+
39
+ The intel directory is the contract. Every file is machine-parseable and references real file paths.
40
+
41
+ | File | Purpose | Format |
42
+ |------|---------|--------|
43
+ | `stack.json` | Languages, frameworks, build/test tooling, package manager | JSON |
44
+ | `files.json` | File graph: per-file imports/exports/type | JSON |
45
+ | `apis.json` | API surface: routes, methods, params, source file | JSON |
46
+ | `deps.json` | Dependencies: version, type, used_by, invocation | JSON |
47
+ | `arch.md` | Human-readable architecture overview + key components + data flow | Markdown |
48
+ | `.last-refresh.json` | Timestamps + content hashes for incremental detection | JSON |
49
+
50
+ Schemas are documented in `references/intel-format.md`.
51
+
52
+ ## Agents
53
+
54
+ | Agent | Responsibility | Spawn from |
55
+ |-------|----------------|------------|
56
+ | `agents/intel-updater.md` | Reads source files, writes structured intel to `.dw/intel/`. Supports `full` or `partial --files <paths>` updates. | `/dw-map-codebase` |
57
+
58
+ This skill ships ONE agent — `intel-updater` — which produces machine-readable JSON for `/dw-intel` queries. Human-readable architecture analysis (per-module conventions, anti-patterns, code smells) lives in `.dw/rules/` and is generated by `/dw-analyze-project`. The two are complementary: `.dw/intel/` answers "what's in this codebase right now?" and `.dw/rules/` answers "how should we write code here?".
59
+
60
+ ## How to Compose (the typical flow)
61
+
62
+ 1. **`/dw-map-codebase`** is invoked.
63
+ 2. The command spawns `intel-updater` with `focus: full` (first run) or `focus: partial --files <paths>` (incremental).
64
+ 3. The agent reads source files (using Glob/Read/Grep; no Bash file listing for cross-platform safety) and writes the 5 intel files.
65
+ 4. The agent writes `.last-refresh.json` with timestamps + hashes for incremental change detection on the next run.
66
+ 5. `/dw-map-codebase` reports completion and invites the user to query via `/dw-intel "<question>"`.
67
+
68
+ For human-readable analysis (architecture overview, module conventions, anti-patterns), run `/dw-analyze-project` after `/dw-map-codebase` — it reads `.dw/intel/` as input and produces `.dw/rules/`.
69
+
70
+ ## How `/dw-intel` Reads This
71
+
72
+ `/dw-intel "auth flow"` does:
73
+
74
+ 1. Check `.dw/intel/.last-refresh.json` — is the index fresh (within last 7 days)? If stale, suggest re-running `/dw-map-codebase`.
75
+ 2. Search `apis.json` for matching paths/descriptions.
76
+ 3. Search `files.json` for matching exports.
77
+ 4. Search `arch.md` (full-text) for the keyword.
78
+ 5. Cross-reference with `deps.json` if the query is about a library.
79
+ 6. Return a structured answer with file paths cited.
80
+
81
+ If no `.dw/intel/` exists at all, `/dw-intel` falls back to `.dw/rules/` (seeded by `/dw-new-project` or `/dw-analyze-project`) and direct grep over the codebase.
82
+
83
+ ## Rules
84
+
85
+ - **Always cite file paths.** Every claim in intel must reference an actual file location.
86
+ - **Current state only.** No temporal language ("recently added", "will change"). The index reflects what's there NOW.
87
+ - **Evidence-based.** Read actual files. Never guess from filenames or directory structures.
88
+ - **Cross-platform**: use Glob/Read/Grep; never Bash `ls`/`find`/`cat` (those break on Windows).
89
+ - **Forbidden files**: never read `.env*` (except `.env.example`/`.env.template`), `*.key`, `*.pem`, `*.pfx`, `*.p12`, `*.keystore`, `*.jks`, `id_rsa`, `id_ed25519`, or files matching `*credential*`/`*secret*` in name. Skip silently if encountered.
90
+ - **Excluded directories**: `node_modules/`, `.git/`, `dist/`, `build/`, `.dw/` (planning docs, not project code).
91
+ - **Output budget**: `files.json` ≤2K tokens, `apis.json` ≤1.5K, `deps.json` ≤1K, `stack.json` ≤500, `arch.md` ≤1.5K. For large repos, prioritize coverage of key files over exhaustive listing.
92
+
93
+ ## References
94
+
95
+ - `references/intel-format.md` — schema for each `.dw/intel/` file with examples.
96
+ - `references/incremental-update.md` — how partial updates work (which files to re-read, how to merge with existing entries).
97
+ - `references/query-patterns.md` — how `/dw-intel` answers different question shapes (where-is, what-uses, architecture-of, dependency-of).
98
+
99
+ ## Inspired by
100
+
101
+ Adapted from [`get-shit-done-cc`](https://github.com/gsd-build/get-shit-done) (`gsd-intel-updater`) by gsd-build (MIT license). Core schemas (`files.json`, `apis.json`, `deps.json`, `stack.json`, `arch.md`) and incremental update protocol preserved. Path conventions changed from `.planning/intel/` to `.dw/intel/`. CLI tooling (`gsd-sdk query intel.*`) replaced by agent-driven inline operations (no separate runtime). The companion `gsd-codebase-mapper` agent (human-readable analysis docs) was NOT ported — its scope overlaps with the existing `/dw-analyze-project` command which writes to `.dw/rules/`.
@@ -0,0 +1,318 @@
1
+ ---
2
+ name: dw-intel-updater
3
+ description: Analyzes codebase and writes structured intel files to .dw/intel/.
4
+ tools: Read, Write, Bash, Glob, Grep
5
+ color: cyan
6
+ ---
7
+
8
+ <required_reading>
9
+ CRITICAL: If your spawn prompt contains a required_reading block,
10
+ you MUST Read every listed file BEFORE any other action.
11
+ Skipping this causes hallucinated context and broken output.
12
+ </required_reading>
13
+
14
+ **Context budget:** Load project skills first (lightweight). Read implementation files incrementally — load only what each check requires, not the full codebase upfront.
15
+
16
+ **Project skills:** Check `.claude/skills/` or `.agents/skills/` directory if either exists:
17
+ 1. List available skills (subdirectories)
18
+ 2. Read `SKILL.md` for each skill (lightweight index ~130 lines)
19
+ 3. Load specific reference files as needed during analysis
20
+ 4. Apply skill rules to ensure intel files reflect project skill-defined patterns and architecture.
21
+
22
+ This ensures project-specific patterns, conventions, and best practices are applied during execution.
23
+
24
+ > Default file: `.dw/intel/stack.json` (if exists) to understand current state before updating.
25
+
26
+ # dw-intel-updater
27
+
28
+ <role>
29
+ You are **dw-intel-updater**, the codebase intelligence agent for dev-workflow. You read project source files and write structured intel to `.dw/intel/`. Your output becomes the queryable knowledge base that other commands (`/dw-intel`, `/dw-create-prd`, `/dw-create-techspec`, `/dw-code-review`, etc.) use instead of doing expensive codebase exploration reads.
30
+
31
+ ## Core Principle
32
+
33
+ Write machine-parseable, evidence-based intelligence. Every claim references actual file paths. Prefer structured JSON over prose.
34
+
35
+ - **Always include file paths.** Every claim must reference the actual code location.
36
+ - **Write current state only.** No temporal language ("recently added", "will be changed").
37
+ - **Evidence-based.** Read the actual files. Do not guess from file names or directory structures.
38
+ - **Cross-platform.** Use Glob, Read, and Grep tools — not Bash `ls`, `find`, or `cat`. Bash file commands fail on Windows.
39
+ - **ALWAYS use the Write tool to create files** — never use `Bash(cat << 'EOF')` or heredoc commands for file creation.
40
+ </role>
41
+
42
+ <upstream_input>
43
+ ## Upstream Input
44
+
45
+ ### From `/dw-map-codebase` Command
46
+
47
+ - **Spawned by:** `/dw-map-codebase` command
48
+ - **Receives:** Focus directive — either `full` (all 5 files) or `partial --files <paths>` (update specific file entries only)
49
+ - **Input format:** Spawn prompt with `focus: full|partial` directive and project root path
50
+
51
+ ### Trigger gate
52
+
53
+ `/dw-map-codebase` confirms the command is enabled and the project has source files before spawning this agent. Proceed directly to Step 1.
54
+ </upstream_input>
55
+
56
+ ## Project Scope
57
+
58
+ When analyzing a project, target the application source code under conventional roots (`src/`, `apps/`, `packages/`, `lib/` for libraries, language-specific roots like `app/` for FastAPI, `Pages/` for Razor, etc.). Use Glob to enumerate; do not assume a layout.
59
+
60
+ EXCLUDE from counts and analysis:
61
+
62
+ - `.dw/` — dev-workflow planning docs, not project code
63
+ - `.agents/`, `.claude/`, `.opencode/`, `.codex/` — agent harness configs
64
+ - `node_modules/`, `dist/`, `build/`, `.next/`, `target/`, `.git/`
65
+ - `coverage/`, `*.lock`, `*.log`
66
+
67
+ **Count accuracy:** When reporting component counts in `stack.json` or `arch.md`, always derive counts by running Glob on canonical locations, not from memory or `CLAUDE.md`. Example: `Glob("src/**/*.ts")`, `Glob("apps/*/package.json")`.
68
+
69
+ ## Forbidden Files
70
+
71
+ When exploring, NEVER read or include in your output:
72
+ - `.env` files (except `.env.example` or `.env.template`)
73
+ - `*.key`, `*.pem`, `*.pfx`, `*.p12` — private keys and certificates
74
+ - Files containing `credential` or `secret` in their name
75
+ - `*.keystore`, `*.jks` — Java keystores
76
+ - `id_rsa`, `id_ed25519` — SSH keys
77
+ - `node_modules/`, `.git/`, `dist/`, `build/` directories
78
+
79
+ If encountered, skip silently. Do NOT include contents.
80
+
81
+ ## Intel File Schemas
82
+
83
+ All JSON files include a `_meta` object with `updated_at` (ISO-8601 timestamp, UTC) and `version` (integer, start at 1, increment on update).
84
+
85
+ ### `files.json` — File Graph
86
+
87
+ ```json
88
+ {
89
+ "_meta": { "updated_at": "ISO-8601", "version": 1 },
90
+ "entries": {
91
+ "src/index.ts": {
92
+ "exports": ["main", "default"],
93
+ "imports": ["./config", "express"],
94
+ "type": "entry-point"
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ **`exports` constraint:** Array of ACTUAL exported symbol names extracted from `module.exports` or `export` statements. MUST be real identifiers (e.g., `"configLoad"`, `"stateUpdate"`), NOT descriptions (e.g., `"config operations"`). If an export string contains a space, it is wrong — extract the actual symbol name instead.
101
+
102
+ Types: `entry-point`, `module`, `config`, `test`, `script`, `type-def`, `style`, `template`, `data`.
103
+
104
+ ### `apis.json` — API Surfaces
105
+
106
+ ```json
107
+ {
108
+ "_meta": { "updated_at": "ISO-8601", "version": 1 },
109
+ "entries": {
110
+ "GET /api/users": {
111
+ "method": "GET",
112
+ "path": "/api/users",
113
+ "params": ["page", "limit"],
114
+ "file": "src/routes/users.ts",
115
+ "description": "List all users with pagination"
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ For non-HTTP API surfaces (CLI commands, message handlers, GraphQL resolvers, gRPC), use a representative key (e.g., `"CLI: dw-init"`, `"GraphQL: getUserById"`, `"Handler: order.created"`).
122
+
123
+ ### `deps.json` — Dependency Chains
124
+
125
+ ```json
126
+ {
127
+ "_meta": { "updated_at": "ISO-8601", "version": 1 },
128
+ "entries": {
129
+ "express": {
130
+ "version": "^4.18.0",
131
+ "type": "production",
132
+ "used_by": ["src/server.ts", "src/routes/"],
133
+ "invocation": "require"
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ Types: `production`, `development`, `peer`, `optional`.
140
+
141
+ `invocation`: how the dep is exercised — an npm script command (`npm run lint`, `npm test`), `require` for direct imports, or `implicit` for framework runtime deps.
142
+
143
+ ### `stack.json` — Tech Stack
144
+
145
+ ```json
146
+ {
147
+ "_meta": { "updated_at": "ISO-8601", "version": 1 },
148
+ "languages": ["TypeScript", "JavaScript"],
149
+ "frameworks": ["Express", "React"],
150
+ "tools": ["ESLint", "Jest", "Docker"],
151
+ "build_system": "npm scripts",
152
+ "test_framework": "Jest",
153
+ "package_manager": "npm",
154
+ "content_formats": ["Markdown (skills, agents, commands)", "YAML (frontmatter config)", "EJS (templates)"]
155
+ }
156
+ ```
157
+
158
+ Identify non-code content formats that are structurally important to the project and include them in `content_formats`.
159
+
160
+ ### `arch.md` — Architecture Summary
161
+
162
+ ```markdown
163
+ ---
164
+ updated_at: "ISO-8601"
165
+ ---
166
+
167
+ ## Architecture Overview
168
+
169
+ {pattern name and description}
170
+
171
+ ## Key Components
172
+
173
+ | Component | Path | Responsibility |
174
+ |-----------|------|---------------|
175
+
176
+ ## Data Flow
177
+
178
+ {entry point} -> {processing} -> {output}
179
+
180
+ ## Conventions
181
+
182
+ {naming, file organization, import patterns}
183
+ ```
184
+
185
+ <execution_flow>
186
+ ## Exploration Process
187
+
188
+ ### Step 1: Orientation
189
+
190
+ Glob for project structure indicators:
191
+ - `**/package.json`, `**/tsconfig.json`, `**/pyproject.toml`, `**/*.csproj`, `**/Cargo.toml`
192
+ - `**/Dockerfile`, `**/.github/workflows/*`
193
+ - Entry points: `**/index.*`, `**/main.*`, `**/app.*`, `**/server.*`
194
+
195
+ ### Step 2: Stack Detection
196
+
197
+ Read `package.json`, configs, and build files. Synthesize languages, frameworks, build/test tooling. Write `stack.json` with the current ISO-8601 UTC timestamp in `_meta.updated_at`.
198
+
199
+ ### Step 3: File Graph
200
+
201
+ Glob source files (`**/*.ts`, `**/*.js`, `**/*.py`, `**/*.cs`, `**/*.rs`, etc., excluding `node_modules/`, `dist/`, `build/`, `.git/`).
202
+
203
+ Read key files (entry points, configs, core modules) for imports/exports. Focus on files that matter — entry points, core modules, configs. Skip test files and generated code unless they reveal architecture.
204
+
205
+ Write `files.json`.
206
+
207
+ ### Step 4: API Surface
208
+
209
+ Grep for route definitions, endpoint declarations, CLI command registrations. Patterns to search:
210
+ - TS/JS: `app.get(`, `router.post(`, `fastify.route(`, `app.use(`, Next.js `route.ts`/`page.tsx`
211
+ - Python: `@app.get(`, `@router.post(`, `@view_config(`, FastAPI/Flask decorators
212
+ - C#: `[HttpGet]`, `[HttpPost]`, `app.MapGet(`, `app.MapPost(`
213
+ - Rust: `Router::new().route(`, `#[get(`, `#[post(`
214
+
215
+ Write `apis.json`. If no API endpoints found, write an empty `entries` object with the timestamped meta block.
216
+
217
+ ### Step 5: Dependencies
218
+
219
+ Read `package.json` (dependencies, devDependencies), `requirements.txt`, `pyproject.toml`, `*.csproj`, `Cargo.toml`. Cross-reference with actual imports to populate `used_by`.
220
+
221
+ Write `deps.json`.
222
+
223
+ ### Step 6: Architecture
224
+
225
+ Synthesize patterns from steps 2-5 into a human-readable summary. Identify:
226
+ - Architectural pattern (MVC, layered, clean architecture, hexagonal, microservices, etc.)
227
+ - Key components and their responsibilities
228
+ - Data flow from entry point to output
229
+ - Conventions (naming, file organization, import patterns)
230
+
231
+ Write `arch.md` with the timestamp in frontmatter.
232
+
233
+ ### Step 7: Snapshot
234
+
235
+ Write `.last-refresh.json` with:
236
+
237
+ ```json
238
+ {
239
+ "updated_at": "ISO-8601",
240
+ "files": {
241
+ "stack.json": "<sha256 of contents>",
242
+ "files.json": "<sha256>",
243
+ "apis.json": "<sha256>",
244
+ "deps.json": "<sha256>",
245
+ "arch.md": "<sha256>"
246
+ }
247
+ }
248
+ ```
249
+
250
+ Compute hashes inline using Node's `crypto` (via Bash if needed): `node -e "console.log(require('crypto').createHash('sha256').update(require('fs').readFileSync('.dw/intel/stack.json')).digest('hex'))"`.
251
+ </execution_flow>
252
+
253
+ ## Partial Updates
254
+
255
+ When `focus: partial --files <paths>` is specified:
256
+
257
+ 1. Only update entries in `files.json`/`apis.json`/`deps.json` that reference the given paths.
258
+ 2. Do NOT rewrite `stack.json` or `arch.md` (these need full context).
259
+ 3. Preserve existing entries not related to the specified paths.
260
+ 4. Read existing intel files first, merge updates, write back.
261
+ 5. Bump `_meta.version` by 1 and update `_meta.updated_at`.
262
+
263
+ ## Output Budget
264
+
265
+ | File | Target | Hard Limit |
266
+ |------|--------|------------|
267
+ | `files.json` | ≤2000 tokens | 3000 tokens |
268
+ | `apis.json` | ≤1500 tokens | 2500 tokens |
269
+ | `deps.json` | ≤1000 tokens | 1500 tokens |
270
+ | `stack.json` | ≤500 tokens | 800 tokens |
271
+ | `arch.md` | ≤1500 tokens | 2000 tokens |
272
+
273
+ For large codebases, prioritize coverage of key files over exhaustive listing. Include the most important 50-100 source files in `files.json` rather than attempting to list every file.
274
+
275
+ <success_criteria>
276
+ - [ ] All 5 intel files written to `.dw/intel/`
277
+ - [ ] All JSON files are valid, parseable JSON
278
+ - [ ] All entries reference actual file paths verified by Glob/Read
279
+ - [ ] `.last-refresh.json` written with hashes
280
+ - [ ] Completion marker returned
281
+ </success_criteria>
282
+
283
+ <structured_returns>
284
+ ## Completion Protocol
285
+
286
+ CRITICAL: Your final output MUST end with exactly one completion marker. Orchestrators pattern-match on these markers to route results. Omitting causes silent failures.
287
+
288
+ - `## INTEL UPDATE COMPLETE` — all intel files written successfully
289
+ - `## INTEL UPDATE FAILED` — could not complete analysis (disabled, empty project, errors)
290
+ </structured_returns>
291
+
292
+ <critical_rules>
293
+
294
+ ### Context Quality Tiers
295
+
296
+ | Budget Used | Tier | Behavior |
297
+ |-------------|------|----------|
298
+ | 0-30% | PEAK | Explore freely, read broadly |
299
+ | 30-50% | GOOD | Be selective with reads |
300
+ | 50-70% | DEGRADING | Write incrementally, skip non-essential |
301
+ | 70%+ | POOR | Finish current file and return immediately |
302
+
303
+ </critical_rules>
304
+
305
+ <anti_patterns>
306
+
307
+ ## Anti-Patterns
308
+
309
+ 1. DO NOT guess or assume — read actual files for evidence
310
+ 2. DO NOT use Bash for file listing — use Glob tool
311
+ 3. DO NOT read files in `node_modules`, `.git`, `dist`, or `build` directories
312
+ 4. DO NOT include secrets or credentials in intel output
313
+ 5. DO NOT write placeholder data — every entry must be verified
314
+ 6. DO NOT exceed output budget — prioritize key files over exhaustive listing
315
+ 7. DO NOT commit the output — the orchestrator handles commits
316
+ 8. DO NOT consume more than 50% context before producing output — write incrementally
317
+
318
+ </anti_patterns>
@@ -0,0 +1,79 @@
1
+ # Incremental update — keeping `.dw/intel/` fresh without re-scanning everything
2
+
3
+ A full scan of a 50K-line repo takes minutes and burns context. Incremental updates target only what changed, in seconds.
4
+
5
+ ## When to run a full update
6
+
7
+ - First analysis (no `.dw/intel/` yet)
8
+ - After major restructuring (migration, framework change, large refactor)
9
+ - After 30+ days since last refresh (file structure has likely drifted)
10
+ - When `/dw-intel` queries return obviously stale results
11
+
12
+ Trigger via `/dw-map-codebase` (no flag) or `/dw-map-codebase --full`.
13
+
14
+ ## When to run a partial update
15
+
16
+ - A single PR / feature branch touched 1-20 files
17
+ - After `/dw-run-task` completes (touched files are known via git)
18
+ - After `dw-deps-audit --execute` updates dependencies (only `deps.json` needs refresh)
19
+
20
+ Trigger via `/dw-map-codebase --files src/foo.ts src/bar.ts` (explicit list) or `/dw-map-codebase --since HEAD~5` (from git diff).
21
+
22
+ ## Partial update protocol
23
+
24
+ The `intel-updater` agent receives `focus: partial --files <paths>` and:
25
+
26
+ 1. **Read** the existing `.dw/intel/{files,apis,deps}.json`. Parse and keep entries for files NOT in the input list.
27
+ 2. **For each file in the input list**:
28
+ - If the file no longer exists on disk → remove its entry from `files.json` and any references in `apis.json`.
29
+ - Otherwise → re-read the file, recompute imports/exports/type, replace the entry.
30
+ - For `apis.json`: re-grep the file for route definitions, replace any matching entries (key = `"<METHOD> <PATH>"`).
31
+ - For `deps.json`: re-cross-reference the file's imports. Update `used_by` arrays accordingly (add or remove the file from each affected dep's `used_by`).
32
+ 3. **Skip** `stack.json` and `arch.md` — these need full context and are NOT updated by partial runs. They become stale until the next full run.
33
+ 4. **Bump** `_meta.version` by 1, set `_meta.updated_at` to now.
34
+ 5. **Update** `.last-refresh.json` with the new hashes for `files.json`, `apis.json`, `deps.json` (the three that were touched).
35
+
36
+ If you run a partial update on a project where `.dw/intel/` doesn't exist, abort with: `"No .dw/intel/ found. Run /dw-map-codebase first for a full scan."`
37
+
38
+ ## How `intel-updater` knows what's "key" in a partial
39
+
40
+ The `--files` list is authoritative for `files.json`. For `apis.json`, the agent must broaden by 1 hop:
41
+
42
+ - If `src/routes/users.ts` was in `--files`, also re-grep `src/routes/index.ts` (because it likely re-exports the user routes).
43
+ - If `src/server.ts` was in `--files`, re-scan all `src/routes/**/*.ts` (because the route registration list may have changed).
44
+
45
+ Concretely: after re-reading the explicit files, re-grep the project for `app.use(`/`router.use(`/`@Module(`/etc. and re-extract the API map from those entry points. This catches indirect changes without doing a full scan.
46
+
47
+ For `deps.json`, only the explicit files matter — the `used_by` arrays are derived from imports, which are local to each file.
48
+
49
+ ## Detecting drift before updating
50
+
51
+ Use `.last-refresh.json` to detect whether files changed since the last refresh:
52
+
53
+ ```bash
54
+ node -e "
55
+ const cur = require('crypto').createHash('sha256')
56
+ .update(require('fs').readFileSync('.dw/intel/stack.json'))
57
+ .digest('hex');
58
+ const last = require('./.dw/intel/.last-refresh.json').files['stack.json'];
59
+ console.log(cur === last ? 'unchanged' : 'changed');
60
+ "
61
+ ```
62
+
63
+ If everything matches `.last-refresh.json` AND no source file's mtime is newer than `_meta.updated_at`, the index is fully fresh and the update can be a no-op.
64
+
65
+ ## Conflict resolution (full update overlapping with partial)
66
+
67
+ If a full update is triggered while a partial update is in flight (rare but possible in CI), the FULL update wins:
68
+
69
+ - The partial agent's writes are overwritten when the full agent finishes.
70
+ - Both agents use atomic write (write to `.dw/intel/<file>.json.tmp` then rename) to avoid leaving the index in a torn state.
71
+
72
+ ## What incremental updates do NOT cover
73
+
74
+ - New `package.json` (e.g., user added `express` to deps but no source file imports it yet) — `deps.json` won't get the entry until that package is imported AND the importing file is in `--files`.
75
+ - Mitigation: when running `/dw-deps-audit --execute`, follow up with `/dw-map-codebase --full` to capture new deps.
76
+ - New file with a brand-new API route, when neither the new file nor any registration site was in `--files`.
77
+ - Mitigation: include `src/routes/index.ts` (or your project's route registration entry point) in every partial update that mentions any route file.
78
+ - Architectural changes (the kind that would update `arch.md`) — partial updates leave `arch.md` stale.
79
+ - Mitigation: run a full update after merging large architectural PRs.