maestro-flow 0.1.0 → 0.1.2

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 (92) hide show
  1. package/.codex/skills/manage-codebase-rebuild/SKILL.md +405 -405
  2. package/.codex/skills/manage-codebase-refresh/SKILL.md +82 -82
  3. package/.codex/skills/manage-issue/SKILL.md +65 -65
  4. package/.codex/skills/manage-status/SKILL.md +89 -89
  5. package/.codex/skills/quality-debug/SKILL.md +413 -413
  6. package/.codex/skills/quality-refactor/SKILL.md +191 -191
  7. package/.codex/skills/quality-sync/SKILL.md +89 -89
  8. package/.codex/skills/quality-test/SKILL.md +198 -198
  9. package/.codex/skills/spec-add/SKILL.md +79 -79
  10. package/.codex/skills/spec-load/SKILL.md +75 -75
  11. package/.codex/skills/spec-map/SKILL.md +182 -182
  12. package/.codex/skills/spec-setup/SKILL.md +76 -76
  13. package/.codex/skills/team-coordinate/SKILL.md +7 -7
  14. package/.codex/skills/team-coordinate/roles/coordinator/role.md +1 -1
  15. package/.codex/skills/team-lifecycle-v4/SKILL.md +2 -2
  16. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +2 -2
  17. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +2 -2
  18. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +2 -2
  19. package/.codex/skills/team-lifecycle-v4/roles/executor/commands/implement.md +1 -1
  20. package/.codex/skills/team-lifecycle-v4/roles/planner/role.md +2 -2
  21. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  22. package/.codex/skills/team-lifecycle-v4/schemas/tasks-schema.md +1 -1
  23. package/.codex/skills/team-quality-assurance/SKILL.md +2 -2
  24. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +2 -2
  25. package/.codex/skills/team-quality-assurance/roles/executor/role.md +1 -1
  26. package/.codex/skills/team-quality-assurance/roles/scout/role.md +2 -2
  27. package/.codex/skills/team-review/SKILL.md +2 -2
  28. package/.codex/skills/team-review/roles/coordinator/role.md +2 -2
  29. package/.codex/skills/team-review/roles/reviewer/role.md +2 -2
  30. package/.codex/skills/team-review/roles/scanner/role.md +1 -1
  31. package/.codex/skills/team-tech-debt/SKILL.md +2 -2
  32. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +1 -1
  33. package/.codex/skills/team-tech-debt/roles/executor/role.md +1 -1
  34. package/.codex/skills/team-tech-debt/roles/scanner/role.md +2 -2
  35. package/.codex/skills/team-tech-debt/roles/validator/role.md +1 -1
  36. package/.codex/skills/team-testing/SKILL.md +2 -2
  37. package/.codex/skills/team-testing/roles/coordinator/role.md +2 -2
  38. package/.codex/skills/team-testing/roles/executor/role.md +2 -2
  39. package/.codex/skills/team-testing/roles/generator/role.md +2 -2
  40. package/README.md +43 -4
  41. package/dist/agents/dashboard-bridge.d.ts +5 -0
  42. package/dist/agents/dashboard-bridge.d.ts.map +1 -1
  43. package/dist/agents/dashboard-bridge.js +13 -0
  44. package/dist/agents/dashboard-bridge.js.map +1 -1
  45. package/dist/agents/parallel-cli-runner.d.ts +42 -0
  46. package/dist/agents/parallel-cli-runner.d.ts.map +1 -0
  47. package/dist/agents/parallel-cli-runner.js +200 -0
  48. package/dist/agents/parallel-cli-runner.js.map +1 -0
  49. package/dist/agents/terminal-adapter.d.ts +94 -0
  50. package/dist/agents/terminal-adapter.d.ts.map +1 -0
  51. package/dist/agents/terminal-adapter.js +132 -0
  52. package/dist/agents/terminal-adapter.js.map +1 -0
  53. package/dist/agents/terminal-backend.d.ts +53 -0
  54. package/dist/agents/terminal-backend.d.ts.map +1 -0
  55. package/dist/agents/terminal-backend.js +286 -0
  56. package/dist/agents/terminal-backend.js.map +1 -0
  57. package/dist/cli.js +5 -1
  58. package/dist/cli.js.map +1 -1
  59. package/dist/commands/coordinate.d.ts.map +1 -1
  60. package/dist/commands/coordinate.js +14 -5
  61. package/dist/commands/coordinate.js.map +1 -1
  62. package/dist/commands/delegate.d.ts +3 -0
  63. package/dist/commands/delegate.d.ts.map +1 -0
  64. package/dist/commands/delegate.js +142 -0
  65. package/dist/commands/delegate.js.map +1 -0
  66. package/dist/commands/msg.d.ts +3 -0
  67. package/dist/commands/msg.d.ts.map +1 -0
  68. package/dist/commands/msg.js +110 -0
  69. package/dist/commands/msg.js.map +1 -0
  70. package/dist/coordinator/graph-types.d.ts +17 -0
  71. package/dist/coordinator/graph-types.d.ts.map +1 -1
  72. package/dist/coordinator/graph-walker.d.ts +3 -1
  73. package/dist/coordinator/graph-walker.d.ts.map +1 -1
  74. package/dist/coordinator/graph-walker.js +147 -8
  75. package/dist/coordinator/graph-walker.js.map +1 -1
  76. package/dist/coordinator/index.d.ts +2 -0
  77. package/dist/coordinator/index.d.ts.map +1 -1
  78. package/dist/coordinator/index.js +1 -0
  79. package/dist/coordinator/index.js.map +1 -1
  80. package/dist/coordinator/parallel-executor.d.ts +24 -0
  81. package/dist/coordinator/parallel-executor.d.ts.map +1 -0
  82. package/dist/coordinator/parallel-executor.js +43 -0
  83. package/dist/coordinator/parallel-executor.js.map +1 -0
  84. package/package.json +3 -1
  85. package/templates/cli/prompts/rules-tech-rules-agent-prompt.txt +89 -89
  86. package/templates/cli/prompts/workflow-codex-feasibility-validation.txt +176 -176
  87. package/templates/cli/prompts/workflow-gemini-solution-design.txt +131 -131
  88. package/templates/cli/prompts/workflow-skill-index.txt +224 -224
  89. package/templates/cli/protocols/analysis-protocol.md +2 -2
  90. package/templates/cli/protocols/write-protocol.md +2 -2
  91. package/workflows/memory.md +2 -2
  92. package/.codex/skills/team-lifecycle-v4/MIGRATION-PLAN.md +0 -512
@@ -1,405 +1,405 @@
1
- ---
2
- name: maestro-codebase-rebuild
3
- description: Full codebase documentation rebuild via CSV wave pipeline. Spawns 5 parallel doc generator agents to scan project and produce complete .workflow/codebase/ documentation set. Replaces manage-codebase-rebuild command.
4
- argument-hint: "[-y|--yes] [-c|--concurrency 5] [--continue] \"[--force] [--skip-commit]\""
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- ## Auto Mode
9
-
10
- When `--yes` or `-y`: Auto-confirm rebuild (implies --force), skip all prompts.
11
-
12
- # Maestro Codebase Rebuild (CSV Wave)
13
-
14
- ## Usage
15
-
16
- ```bash
17
- $maestro-codebase-rebuild ""
18
- $maestro-codebase-rebuild -y "--force"
19
- $maestro-codebase-rebuild -c 5 "--force --skip-commit"
20
- $maestro-codebase-rebuild --continue "rebuild-full-20260318"
21
- ```
22
-
23
- **Flags**:
24
- - `-y, --yes`: Skip all confirmations (auto mode, implies --force)
25
- - `-c, --concurrency N`: Max concurrent agents (default: 5)
26
- - `--continue`: Resume existing session
27
-
28
- **Inner flags** (passed inside quotes):
29
- - `--force`: Clear existing .workflow/codebase/ and rebuild from scratch
30
- - `--skip-commit`: Do not auto-commit after rebuild
31
-
32
- **Output Directory**: `.workflow/.csv-wave/{session-id}/`
33
- **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
34
- **Target**: `.workflow/codebase/` (doc-index.json, tech-registry/, feature-maps/)
35
-
36
- ---
37
-
38
- ## Overview
39
-
40
- Single-wave parallel execution -- 5 independent doc generator agents each analyze a different documentation dimension of the codebase. All agents run concurrently with no dependencies. This is a destructive operation that rebuilds the entire `.workflow/codebase/` directory from scratch.
41
-
42
- **Core workflow**: Prepare Directory -> Decompose Doc Dimensions -> Parallel Generation -> Assemble doc-index.json
43
-
44
- **Topology**: Independent Parallel (single wave)
45
-
46
- ```
47
- +---------------------------------------------------------------------------+
48
- | CODEBASE REBUILD CSV WAVE WORKFLOW |
49
- +---------------------------------------------------------------------------+
50
- | |
51
- | Phase 1: Setup -> CSV |
52
- | +-- Validate .workflow/ exists |
53
- | +-- Confirm rebuild (or --force / -y) |
54
- | +-- Clear .workflow/codebase/ directory |
55
- | +-- Detect source directories (src/, lib/, app/, packages/) |
56
- | +-- Generate tasks.csv with 5 doc generator tasks |
57
- | +-- All tasks wave 1 (no dependencies) |
58
- | |
59
- | Phase 2: Wave Execution (Single Wave) |
60
- | +-- Wave 1: All 5 generators run concurrently |
61
- | | +-- Component Scanner (TC-* entries) |
62
- | | +-- Feature Mapper (FT-* entries) |
63
- | | +-- Requirement Linker (REQ-* entries, if specs exist) |
64
- | | +-- Tech Registry Writer (tech-registry/*.md) |
65
- | | +-- Feature Map Writer (feature-maps/*.md) |
66
- | +-- discoveries.ndjson shared (append-only) |
67
- | |
68
- | Phase 3: Results -> .workflow/codebase/ |
69
- | +-- Assemble doc-index.json from agent findings |
70
- | +-- Validate all output files exist |
71
- | +-- Update state.json with rebuild timestamp |
72
- | +-- Generate context.md summary |
73
- | +-- Auto-commit (unless --skip-commit) |
74
- | +-- Display completion report |
75
- | |
76
- +---------------------------------------------------------------------------+
77
- ```
78
-
79
- ---
80
-
81
- ## CSV Schema
82
-
83
- ### tasks.csv (Master State)
84
-
85
- ```csv
86
- id,title,description,doc_dimension,output_path,deps,context_from,wave,status,findings,error
87
- "1","Component Scanner","Scan all source directories for components: models, services, controllers, utils, types, config, middleware, core modules. For each component extract exported symbols, determine type, record code locations. Output JSON array of component entries with id (TC-NNN), name, type, code_locations, symbols.","components",".workflow/codebase/doc-index.json#components","","","1","","",""
88
- "2","Feature Mapper","Group discovered components by domain/functional area using directory proximity, naming patterns, and import relationships. Map features to requirements if .workflow/task-specs/ exists. Output JSON array of feature entries with id (FT-NNN), name, status, component_ids, requirement_ids, phase.","features",".workflow/codebase/doc-index.json#features","","","1","","",""
89
- "3","Requirement Linker","If .workflow/task-specs/ exists, scan SPEC-*/requirements/REQ-*.md files. Parse requirement metadata (title, priority, acceptance_criteria). Match requirements to features by keyword analysis. Also scan for ADR-*.md architecture decisions. Output JSON arrays for requirements and architecture_decisions.","requirements",".workflow/codebase/doc-index.json#requirements","","","1","","",""
90
- "4","Tech Registry Writer","For each component discovered, generate a markdown documentation file in .workflow/codebase/tech-registry/{slug}.md with: ID, type, features, code locations, exported symbols, dependencies. Generate _index.md with component table. Output file count and paths.","tech-registry",".workflow/codebase/tech-registry/","","","1","","",""
91
- "5","Feature Map Writer","For each feature discovered, generate a markdown documentation file in .workflow/codebase/feature-maps/{slug}.md with: ID, status, phase, requirements, component table. Generate _index.md with feature table. Output file count and paths.","feature-maps",".workflow/codebase/feature-maps/","","","1","","",""
92
- ```
93
-
94
- **Columns**:
95
-
96
- | Column | Phase | Description |
97
- |--------|-------|-------------|
98
- | `id` | Input | Generator identifier |
99
- | `title` | Input | Doc generator dimension title |
100
- | `description` | Input | Detailed generation instructions |
101
- | `doc_dimension` | Input | Documentation dimension: components/features/requirements/tech-registry/feature-maps |
102
- | `output_path` | Input | Target output path in .workflow/codebase/ |
103
- | `deps` | Input | Empty (all independent) |
104
- | `context_from` | Input | Empty (no cross-task context needed) |
105
- | `wave` | Computed | Always 1 (single wave, independent parallel) |
106
- | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
107
- | `findings` | Output | Generation summary -- counts, paths, notes (max 500 chars) |
108
- | `error` | Output | Error message if failed |
109
-
110
- ### Per-Wave CSV (Temporary)
111
-
112
- Single wave generates `wave-1.csv`. No `prev_context` needed (all tasks independent).
113
-
114
- ---
115
-
116
- ## Output Artifacts
117
-
118
- | File | Purpose | Lifecycle |
119
- |------|---------|-----------|
120
- | `tasks.csv` | Master state -- all tasks with status/findings | Updated after wave |
121
- | `wave-1.csv` | Wave input (temporary) | Created before wave, deleted after |
122
- | `wave-1-results.csv` | Wave output | Created by spawn_agents_on_csv |
123
- | `results.csv` | Final export of all task results | Created in Phase 3 |
124
- | `discoveries.ndjson` | Shared exploration board | Append-only during wave |
125
- | `context.md` | Human-readable rebuild report | Created in Phase 3 |
126
-
127
- ### Target Output (in .workflow/codebase/)
128
-
129
- | File | Description |
130
- |------|-------------|
131
- | `doc-index.json` | Single source of truth: components, features, requirements, ADRs |
132
- | `tech-registry/_index.md` | Component index table |
133
- | `tech-registry/{slug}.md` | Per-component documentation |
134
- | `feature-maps/_index.md` | Feature index table |
135
- | `feature-maps/{slug}.md` | Per-feature documentation |
136
-
137
- ---
138
-
139
- ## Session Structure
140
-
141
- ```
142
- .workflow/.csv-wave/rebuild-{scope}-{date}/
143
- +-- tasks.csv
144
- +-- results.csv
145
- +-- discoveries.ndjson
146
- +-- context.md
147
- +-- config.json
148
- +-- wave-1.csv (temporary)
149
- +-- wave-1-results.csv (temporary)
150
- ```
151
-
152
- ---
153
-
154
- ## Implementation
155
-
156
- ### Session Initialization
157
-
158
- ```javascript
159
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
160
-
161
- // Parse flags
162
- const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
163
- const continueMode = $ARGUMENTS.includes('--continue')
164
- const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
165
- const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 5
166
-
167
- // Parse rebuild-specific flags
168
- const forceMode = $ARGUMENTS.includes('--force') || AUTO_YES
169
- const skipCommit = $ARGUMENTS.includes('--skip-commit')
170
-
171
- const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
172
- const sessionId = `rebuild-full-${dateStr}`
173
- const sessionFolder = `.workflow/.csv-wave/${sessionId}`
174
-
175
- Bash(`mkdir -p ${sessionFolder}`)
176
- ```
177
-
178
- ---
179
-
180
- ### Phase 1: Setup -> CSV
181
-
182
- **Objective**: Validate prerequisites, prepare directory, detect source dirs, generate tasks.csv.
183
-
184
- **Steps**:
185
-
186
- 1. **Validate .workflow/ exists**:
187
- - Check `.workflow/state.json` exists
188
- - If not: abort with "Run init first"
189
-
190
- 2. **Confirm rebuild**:
191
- - If `.workflow/codebase/` exists AND NOT forceMode:
192
- ```
193
- AskUserQuestion: "Codebase docs already exist. Rebuild will overwrite all files. Continue? [y/N]"
194
- If no: exit
195
- ```
196
- - If forceMode or confirmed: clear `.workflow/codebase/`
197
-
198
- 3. **Prepare directory structure**:
199
- ```bash
200
- mkdir -p .workflow/codebase/tech-registry
201
- mkdir -p .workflow/codebase/feature-maps
202
- mkdir -p .workflow/codebase/action-logs
203
- ```
204
-
205
- 4. **Detect source directories**:
206
- - Check for: `src/`, `lib/`, `app/`, `packages/`
207
- - Read `project-tech.json` if available for `source_dirs`
208
- - If no source directories found: abort with "No source files in project"
209
-
210
- 5. **Load project specs** (if available):
211
- - Read `.workflow/specs/` for architecture context
212
-
213
- 6. **Generate tasks.csv**: 5 rows, all wave 1, no dependencies.
214
-
215
- 7. **User validation**: Display doc generator breakdown. Skip if AUTO_YES.
216
-
217
- ---
218
-
219
- ### Phase 2: Wave Execution (Single Wave)
220
-
221
- **Objective**: Run all 5 doc generators concurrently via spawn_agents_on_csv.
222
-
223
- #### Wave 1: All Generators (Parallel)
224
-
225
- 1. Read master `tasks.csv`
226
- 2. Filter rows where `wave == 1` AND `status == pending`
227
- 3. No prev_context needed (single wave, all independent)
228
- 4. Write `wave-1.csv`
229
- 5. Execute:
230
-
231
- ```javascript
232
- spawn_agents_on_csv({
233
- csv_path: `${sessionFolder}/wave-1.csv`,
234
- id_column: "id",
235
- instruction: buildRebuildInstruction(sessionFolder, sourceDirs),
236
- max_concurrency: maxConcurrency,
237
- max_runtime_seconds: 900,
238
- output_csv_path: `${sessionFolder}/wave-1-results.csv`,
239
- output_schema: {
240
- type: "object",
241
- properties: {
242
- id: { type: "string" },
243
- status: { type: "string", enum: ["completed", "failed"] },
244
- findings: { type: "string" },
245
- error: { type: "string" }
246
- },
247
- required: ["id", "status", "findings"]
248
- }
249
- })
250
- ```
251
-
252
- 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
253
- 7. Delete `wave-1.csv`
254
-
255
- ---
256
-
257
- ### Phase 3: Results -> .workflow/codebase/
258
-
259
- **Objective**: Assemble doc-index.json from agent findings, validate, update state.
260
-
261
- 1. Read final master `tasks.csv`
262
- 2. Export as `results.csv`
263
-
264
- 3. **Assemble doc-index.json**:
265
- - Read component findings from task 1 (Component Scanner)
266
- - Read feature findings from task 2 (Feature Mapper)
267
- - Read requirement/ADR findings from task 3 (Requirement Linker)
268
- - Merge into complete doc-index.json:
269
- ```json
270
- {
271
- "version": "1.0",
272
- "schema_version": "1.0",
273
- "project": "<project name>",
274
- "last_updated": "<ISO>",
275
- "features": [],
276
- "components": [],
277
- "requirements": [],
278
- "architecture_decisions": [],
279
- "actions": []
280
- }
281
- ```
282
- - Write to `.workflow/codebase/doc-index.json`
283
-
284
- 4. **Validate output files**:
285
- - Check doc-index.json exists and is valid JSON
286
- - Check tech-registry/_index.md exists (from task 4)
287
- - Check feature-maps/_index.md exists (from task 5)
288
- - Log warnings for any missing files
289
-
290
- 5. **Update state.json**: Set `codebase.last_rebuild` timestamp.
291
-
292
- 6. **Generate context.md**:
293
-
294
- ```markdown
295
- # Codebase Rebuild Report
296
-
297
- ## Summary
298
- - Components discovered: {count}
299
- - Features mapped: {count}
300
- - Requirements linked: {count}
301
- - ADRs recorded: {count}
302
- - Files generated: {count}
303
- - Generators: {completed}/{total} succeeded
304
-
305
- ## Generator Results
306
- | Generator | Status | Output | Findings |
307
- |-----------|--------|--------|----------|
308
- | Component Scanner | {status} | {count} components | {summary} |
309
- | Feature Mapper | {status} | {count} features | {summary} |
310
- | Requirement Linker | {status} | {count} requirements | {summary} |
311
- | Tech Registry Writer | {status} | {count} files | {summary} |
312
- | Feature Map Writer | {status} | {count} files | {summary} |
313
-
314
- ## Discovery Board Summary
315
- {aggregated discovery findings}
316
-
317
- ## Next Steps
318
- - Run manage-status to review
319
- - Run manage-codebase-refresh for future incremental updates
320
- ```
321
-
322
- 7. **Auto-commit** (unless --skip-commit):
323
- - Stage `.workflow/codebase/` files
324
- - Suggest commit: "docs(codebase): full rebuild of codebase documentation"
325
-
326
- 8. **Display completion report**:
327
-
328
- ```
329
- === CODEBASE REBUILD COMPLETE ===
330
- Components: {count}
331
- Features: {count}
332
- Requirements: {count}
333
- ADRs: {count}
334
- Files: {count} generated in .workflow/codebase/
335
-
336
- Generators: {completed}/{total} succeeded
337
- {if failures: "W001: {failed_generator} failed -- partial results available"}
338
-
339
- Next steps:
340
- Skill({ skill: "manage-status" })
341
- Skill({ skill: "manage-codebase-refresh" })
342
- ```
343
-
344
- ---
345
-
346
- ## Shared Discovery Board Protocol
347
-
348
- ### Standard Discovery Types
349
-
350
- | Type | Dedup Key | Data Schema | Description |
351
- |------|-----------|-------------|-------------|
352
- | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack identified |
353
- | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
354
- | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
355
- | `convention` | singleton | `{naming, imports, formatting}` | Project coding conventions |
356
-
357
- ### Domain Discovery Types
358
-
359
- | Type | Dedup Key | Data Schema | Description |
360
- |------|-----------|-------------|-------------|
361
- | `component` | `data.id` | `{id, name, type, code_locations[]}` | Component discovered by scanner |
362
- | `feature_group` | `data.name` | `{name, component_ids[], directory}` | Feature grouping identified |
363
-
364
- ### Protocol
365
-
366
- 1. **Read** `{session_folder}/discoveries.ndjson` before own analysis
367
- 2. **Skip covered**: If discovery of same type + dedup key exists, skip
368
- 3. **Write immediately**: Append findings as discovered
369
- 4. **Append-only**: Never modify or delete
370
- 5. **Deduplicate**: Check before writing
371
-
372
- ```bash
373
- echo '{"ts":"<ISO>","worker":"1","type":"tech_stack","data":{"framework":"Express","language":"TypeScript","tools":["jest","eslint","prettier"]}}' >> {session_folder}/discoveries.ndjson
374
- ```
375
-
376
- Generators share discoveries so other generators can skip redundant scanning (e.g., Component Scanner discovers components, Feature Mapper and Tech Registry Writer can leverage those findings).
377
-
378
- ---
379
-
380
- ## Error Handling
381
-
382
- | Error | Resolution |
383
- |-------|------------|
384
- | .workflow/ not initialized | Abort: "Run init first" (E001) |
385
- | No source directories found | Abort: "No source files in project" |
386
- | .workflow/codebase/ exists without --force | Prompt user for confirmation |
387
- | Generator agent timeout | Mark as failed, continue with other generators |
388
- | Generator agent failed | Mark as failed, log W001, output partial results |
389
- | doc-index.json assembly fails | Use available generator outputs, log missing sections |
390
- | CSV parse error | Validate format, show line number |
391
- | discoveries.ndjson corrupt | Ignore malformed lines |
392
- | Continue mode: no session found | List available sessions |
393
-
394
- ---
395
-
396
- ## Core Rules
397
-
398
- 1. **Start Immediately**: First action is session initialization, then Phase 1
399
- 2. **CSV is Source of Truth**: tasks.csv holds all generator state
400
- 3. **Discovery Board is Append-Only**: Generators share findings via NDJSON
401
- 4. **Partial Results OK**: If 3/5 generators succeed, still assemble available docs
402
- 5. **Destructive by Design**: This is a full rebuild -- existing codebase/ is cleared
403
- 6. **Single Wave**: All generators are independent, no wave ordering needed
404
- 7. **Cleanup Temp Files**: Remove wave-1.csv after results are merged
405
- 8. **DO NOT STOP**: Execute until all generators complete or fail
1
+ ---
2
+ name: maestro-codebase-rebuild
3
+ description: Full codebase documentation rebuild via CSV wave pipeline. Spawns 5 parallel doc generator agents to scan project and produce complete .workflow/codebase/ documentation set. Replaces manage-codebase-rebuild command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency 5] [--continue] \"[--force] [--skip-commit]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm rebuild (implies --force), skip all prompts.
11
+
12
+ # Maestro Codebase Rebuild (CSV Wave)
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $maestro-codebase-rebuild ""
18
+ $maestro-codebase-rebuild -y "--force"
19
+ $maestro-codebase-rebuild -c 5 "--force --skip-commit"
20
+ $maestro-codebase-rebuild --continue "rebuild-full-20260318"
21
+ ```
22
+
23
+ **Flags**:
24
+ - `-y, --yes`: Skip all confirmations (auto mode, implies --force)
25
+ - `-c, --concurrency N`: Max concurrent agents (default: 5)
26
+ - `--continue`: Resume existing session
27
+
28
+ **Inner flags** (passed inside quotes):
29
+ - `--force`: Clear existing .workflow/codebase/ and rebuild from scratch
30
+ - `--skip-commit`: Do not auto-commit after rebuild
31
+
32
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
33
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
34
+ **Target**: `.workflow/codebase/` (doc-index.json, tech-registry/, feature-maps/)
35
+
36
+ ---
37
+
38
+ ## Overview
39
+
40
+ Single-wave parallel execution -- 5 independent doc generator agents each analyze a different documentation dimension of the codebase. All agents run concurrently with no dependencies. This is a destructive operation that rebuilds the entire `.workflow/codebase/` directory from scratch.
41
+
42
+ **Core workflow**: Prepare Directory -> Decompose Doc Dimensions -> Parallel Generation -> Assemble doc-index.json
43
+
44
+ **Topology**: Independent Parallel (single wave)
45
+
46
+ ```
47
+ +---------------------------------------------------------------------------+
48
+ | CODEBASE REBUILD CSV WAVE WORKFLOW |
49
+ +---------------------------------------------------------------------------+
50
+ | |
51
+ | Phase 1: Setup -> CSV |
52
+ | +-- Validate .workflow/ exists |
53
+ | +-- Confirm rebuild (or --force / -y) |
54
+ | +-- Clear .workflow/codebase/ directory |
55
+ | +-- Detect source directories (src/, lib/, app/, packages/) |
56
+ | +-- Generate tasks.csv with 5 doc generator tasks |
57
+ | +-- All tasks wave 1 (no dependencies) |
58
+ | |
59
+ | Phase 2: Wave Execution (Single Wave) |
60
+ | +-- Wave 1: All 5 generators run concurrently |
61
+ | | +-- Component Scanner (TC-* entries) |
62
+ | | +-- Feature Mapper (FT-* entries) |
63
+ | | +-- Requirement Linker (REQ-* entries, if specs exist) |
64
+ | | +-- Tech Registry Writer (tech-registry/*.md) |
65
+ | | +-- Feature Map Writer (feature-maps/*.md) |
66
+ | +-- discoveries.ndjson shared (append-only) |
67
+ | |
68
+ | Phase 3: Results -> .workflow/codebase/ |
69
+ | +-- Assemble doc-index.json from agent findings |
70
+ | +-- Validate all output files exist |
71
+ | +-- Update state.json with rebuild timestamp |
72
+ | +-- Generate context.md summary |
73
+ | +-- Auto-commit (unless --skip-commit) |
74
+ | +-- Display completion report |
75
+ | |
76
+ +---------------------------------------------------------------------------+
77
+ ```
78
+
79
+ ---
80
+
81
+ ## CSV Schema
82
+
83
+ ### tasks.csv (Master State)
84
+
85
+ ```csv
86
+ id,title,description,doc_dimension,output_path,deps,context_from,wave,status,findings,error
87
+ "1","Component Scanner","Scan all source directories for components: models, services, controllers, utils, types, config, middleware, core modules. For each component extract exported symbols, determine type, record code locations. Output JSON array of component entries with id (TC-NNN), name, type, code_locations, symbols.","components",".workflow/codebase/doc-index.json#components","","","1","","",""
88
+ "2","Feature Mapper","Group discovered components by domain/functional area using directory proximity, naming patterns, and import relationships. Map features to requirements if .workflow/task-specs/ exists. Output JSON array of feature entries with id (FT-NNN), name, status, component_ids, requirement_ids, phase.","features",".workflow/codebase/doc-index.json#features","","","1","","",""
89
+ "3","Requirement Linker","If .workflow/task-specs/ exists, scan SPEC-*/requirements/REQ-*.md files. Parse requirement metadata (title, priority, acceptance_criteria). Match requirements to features by keyword analysis. Also scan for ADR-*.md architecture decisions. Output JSON arrays for requirements and architecture_decisions.","requirements",".workflow/codebase/doc-index.json#requirements","","","1","","",""
90
+ "4","Tech Registry Writer","For each component discovered, generate a markdown documentation file in .workflow/codebase/tech-registry/{slug}.md with: ID, type, features, code locations, exported symbols, dependencies. Generate _index.md with component table. Output file count and paths.","tech-registry",".workflow/codebase/tech-registry/","","","1","","",""
91
+ "5","Feature Map Writer","For each feature discovered, generate a markdown documentation file in .workflow/codebase/feature-maps/{slug}.md with: ID, status, phase, requirements, component table. Generate _index.md with feature table. Output file count and paths.","feature-maps",".workflow/codebase/feature-maps/","","","1","","",""
92
+ ```
93
+
94
+ **Columns**:
95
+
96
+ | Column | Phase | Description |
97
+ |--------|-------|-------------|
98
+ | `id` | Input | Generator identifier |
99
+ | `title` | Input | Doc generator dimension title |
100
+ | `description` | Input | Detailed generation instructions |
101
+ | `doc_dimension` | Input | Documentation dimension: components/features/requirements/tech-registry/feature-maps |
102
+ | `output_path` | Input | Target output path in .workflow/codebase/ |
103
+ | `deps` | Input | Empty (all independent) |
104
+ | `context_from` | Input | Empty (no cross-task context needed) |
105
+ | `wave` | Computed | Always 1 (single wave, independent parallel) |
106
+ | `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
107
+ | `findings` | Output | Generation summary -- counts, paths, notes (max 500 chars) |
108
+ | `error` | Output | Error message if failed |
109
+
110
+ ### Per-Wave CSV (Temporary)
111
+
112
+ Single wave generates `wave-1.csv`. No `prev_context` needed (all tasks independent).
113
+
114
+ ---
115
+
116
+ ## Output Artifacts
117
+
118
+ | File | Purpose | Lifecycle |
119
+ |------|---------|-----------|
120
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after wave |
121
+ | `wave-1.csv` | Wave input (temporary) | Created before wave, deleted after |
122
+ | `wave-1-results.csv` | Wave output | Created by spawn_agents_on_csv |
123
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
124
+ | `discoveries.ndjson` | Shared exploration board | Append-only during wave |
125
+ | `context.md` | Human-readable rebuild report | Created in Phase 3 |
126
+
127
+ ### Target Output (in .workflow/codebase/)
128
+
129
+ | File | Description |
130
+ |------|-------------|
131
+ | `doc-index.json` | Single source of truth: components, features, requirements, ADRs |
132
+ | `tech-registry/_index.md` | Component index table |
133
+ | `tech-registry/{slug}.md` | Per-component documentation |
134
+ | `feature-maps/_index.md` | Feature index table |
135
+ | `feature-maps/{slug}.md` | Per-feature documentation |
136
+
137
+ ---
138
+
139
+ ## Session Structure
140
+
141
+ ```
142
+ .workflow/.csv-wave/rebuild-{scope}-{date}/
143
+ +-- tasks.csv
144
+ +-- results.csv
145
+ +-- discoveries.ndjson
146
+ +-- context.md
147
+ +-- config.json
148
+ +-- wave-1.csv (temporary)
149
+ +-- wave-1-results.csv (temporary)
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Implementation
155
+
156
+ ### Session Initialization
157
+
158
+ ```javascript
159
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
160
+
161
+ // Parse flags
162
+ const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
163
+ const continueMode = $ARGUMENTS.includes('--continue')
164
+ const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
165
+ const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 5
166
+
167
+ // Parse rebuild-specific flags
168
+ const forceMode = $ARGUMENTS.includes('--force') || AUTO_YES
169
+ const skipCommit = $ARGUMENTS.includes('--skip-commit')
170
+
171
+ const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
172
+ const sessionId = `rebuild-full-${dateStr}`
173
+ const sessionFolder = `.workflow/.csv-wave/${sessionId}`
174
+
175
+ Bash(`mkdir -p ${sessionFolder}`)
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Phase 1: Setup -> CSV
181
+
182
+ **Objective**: Validate prerequisites, prepare directory, detect source dirs, generate tasks.csv.
183
+
184
+ **Steps**:
185
+
186
+ 1. **Validate .workflow/ exists**:
187
+ - Check `.workflow/state.json` exists
188
+ - If not: abort with "Run init first"
189
+
190
+ 2. **Confirm rebuild**:
191
+ - If `.workflow/codebase/` exists AND NOT forceMode:
192
+ ```
193
+ AskUserQuestion: "Codebase docs already exist. Rebuild will overwrite all files. Continue? [y/N]"
194
+ If no: exit
195
+ ```
196
+ - If forceMode or confirmed: clear `.workflow/codebase/`
197
+
198
+ 3. **Prepare directory structure**:
199
+ ```bash
200
+ mkdir -p .workflow/codebase/tech-registry
201
+ mkdir -p .workflow/codebase/feature-maps
202
+ mkdir -p .workflow/codebase/action-logs
203
+ ```
204
+
205
+ 4. **Detect source directories**:
206
+ - Check for: `src/`, `lib/`, `app/`, `packages/`
207
+ - Read `project-tech.json` if available for `source_dirs`
208
+ - If no source directories found: abort with "No source files in project"
209
+
210
+ 5. **Load project specs** (if available):
211
+ - Read `.workflow/specs/` for architecture context
212
+
213
+ 6. **Generate tasks.csv**: 5 rows, all wave 1, no dependencies.
214
+
215
+ 7. **User validation**: Display doc generator breakdown. Skip if AUTO_YES.
216
+
217
+ ---
218
+
219
+ ### Phase 2: Wave Execution (Single Wave)
220
+
221
+ **Objective**: Run all 5 doc generators concurrently via spawn_agents_on_csv.
222
+
223
+ #### Wave 1: All Generators (Parallel)
224
+
225
+ 1. Read master `tasks.csv`
226
+ 2. Filter rows where `wave == 1` AND `status == pending`
227
+ 3. No prev_context needed (single wave, all independent)
228
+ 4. Write `wave-1.csv`
229
+ 5. Execute:
230
+
231
+ ```javascript
232
+ spawn_agents_on_csv({
233
+ csv_path: `${sessionFolder}/wave-1.csv`,
234
+ id_column: "id",
235
+ instruction: buildRebuildInstruction(sessionFolder, sourceDirs),
236
+ max_concurrency: maxConcurrency,
237
+ max_runtime_seconds: 900,
238
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
239
+ output_schema: {
240
+ type: "object",
241
+ properties: {
242
+ id: { type: "string" },
243
+ status: { type: "string", enum: ["completed", "failed"] },
244
+ findings: { type: "string" },
245
+ error: { type: "string" }
246
+ },
247
+ required: ["id", "status", "findings"]
248
+ }
249
+ })
250
+ ```
251
+
252
+ 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
253
+ 7. Delete `wave-1.csv`
254
+
255
+ ---
256
+
257
+ ### Phase 3: Results -> .workflow/codebase/
258
+
259
+ **Objective**: Assemble doc-index.json from agent findings, validate, update state.
260
+
261
+ 1. Read final master `tasks.csv`
262
+ 2. Export as `results.csv`
263
+
264
+ 3. **Assemble doc-index.json**:
265
+ - Read component findings from task 1 (Component Scanner)
266
+ - Read feature findings from task 2 (Feature Mapper)
267
+ - Read requirement/ADR findings from task 3 (Requirement Linker)
268
+ - Merge into complete doc-index.json:
269
+ ```json
270
+ {
271
+ "version": "1.0",
272
+ "schema_version": "1.0",
273
+ "project": "<project name>",
274
+ "last_updated": "<ISO>",
275
+ "features": [],
276
+ "components": [],
277
+ "requirements": [],
278
+ "architecture_decisions": [],
279
+ "actions": []
280
+ }
281
+ ```
282
+ - Write to `.workflow/codebase/doc-index.json`
283
+
284
+ 4. **Validate output files**:
285
+ - Check doc-index.json exists and is valid JSON
286
+ - Check tech-registry/_index.md exists (from task 4)
287
+ - Check feature-maps/_index.md exists (from task 5)
288
+ - Log warnings for any missing files
289
+
290
+ 5. **Update state.json**: Set `codebase.last_rebuild` timestamp.
291
+
292
+ 6. **Generate context.md**:
293
+
294
+ ```markdown
295
+ # Codebase Rebuild Report
296
+
297
+ ## Summary
298
+ - Components discovered: {count}
299
+ - Features mapped: {count}
300
+ - Requirements linked: {count}
301
+ - ADRs recorded: {count}
302
+ - Files generated: {count}
303
+ - Generators: {completed}/{total} succeeded
304
+
305
+ ## Generator Results
306
+ | Generator | Status | Output | Findings |
307
+ |-----------|--------|--------|----------|
308
+ | Component Scanner | {status} | {count} components | {summary} |
309
+ | Feature Mapper | {status} | {count} features | {summary} |
310
+ | Requirement Linker | {status} | {count} requirements | {summary} |
311
+ | Tech Registry Writer | {status} | {count} files | {summary} |
312
+ | Feature Map Writer | {status} | {count} files | {summary} |
313
+
314
+ ## Discovery Board Summary
315
+ {aggregated discovery findings}
316
+
317
+ ## Next Steps
318
+ - Run manage-status to review
319
+ - Run manage-codebase-refresh for future incremental updates
320
+ ```
321
+
322
+ 7. **Auto-commit** (unless --skip-commit):
323
+ - Stage `.workflow/codebase/` files
324
+ - Suggest commit: "docs(codebase): full rebuild of codebase documentation"
325
+
326
+ 8. **Display completion report**:
327
+
328
+ ```
329
+ === CODEBASE REBUILD COMPLETE ===
330
+ Components: {count}
331
+ Features: {count}
332
+ Requirements: {count}
333
+ ADRs: {count}
334
+ Files: {count} generated in .workflow/codebase/
335
+
336
+ Generators: {completed}/{total} succeeded
337
+ {if failures: "W001: {failed_generator} failed -- partial results available"}
338
+
339
+ Next steps:
340
+ Skill({ skill: "manage-status" })
341
+ Skill({ skill: "manage-codebase-refresh" })
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Shared Discovery Board Protocol
347
+
348
+ ### Standard Discovery Types
349
+
350
+ | Type | Dedup Key | Data Schema | Description |
351
+ |------|-----------|-------------|-------------|
352
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack identified |
353
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
354
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
355
+ | `convention` | singleton | `{naming, imports, formatting}` | Project coding conventions |
356
+
357
+ ### Domain Discovery Types
358
+
359
+ | Type | Dedup Key | Data Schema | Description |
360
+ |------|-----------|-------------|-------------|
361
+ | `component` | `data.id` | `{id, name, type, code_locations[]}` | Component discovered by scanner |
362
+ | `feature_group` | `data.name` | `{name, component_ids[], directory}` | Feature grouping identified |
363
+
364
+ ### Protocol
365
+
366
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own analysis
367
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
368
+ 3. **Write immediately**: Append findings as discovered
369
+ 4. **Append-only**: Never modify or delete
370
+ 5. **Deduplicate**: Check before writing
371
+
372
+ ```bash
373
+ echo '{"ts":"<ISO>","worker":"1","type":"tech_stack","data":{"framework":"Express","language":"TypeScript","tools":["jest","eslint","prettier"]}}' >> {session_folder}/discoveries.ndjson
374
+ ```
375
+
376
+ Generators share discoveries so other generators can skip redundant scanning (e.g., Component Scanner discovers components, Feature Mapper and Tech Registry Writer can leverage those findings).
377
+
378
+ ---
379
+
380
+ ## Error Handling
381
+
382
+ | Error | Resolution |
383
+ |-------|------------|
384
+ | .workflow/ not initialized | Abort: "Run init first" (E001) |
385
+ | No source directories found | Abort: "No source files in project" |
386
+ | .workflow/codebase/ exists without --force | Prompt user for confirmation |
387
+ | Generator agent timeout | Mark as failed, continue with other generators |
388
+ | Generator agent failed | Mark as failed, log W001, output partial results |
389
+ | doc-index.json assembly fails | Use available generator outputs, log missing sections |
390
+ | CSV parse error | Validate format, show line number |
391
+ | discoveries.ndjson corrupt | Ignore malformed lines |
392
+ | Continue mode: no session found | List available sessions |
393
+
394
+ ---
395
+
396
+ ## Core Rules
397
+
398
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
399
+ 2. **CSV is Source of Truth**: tasks.csv holds all generator state
400
+ 3. **Discovery Board is Append-Only**: Generators share findings via NDJSON
401
+ 4. **Partial Results OK**: If 3/5 generators succeed, still assemble available docs
402
+ 5. **Destructive by Design**: This is a full rebuild -- existing codebase/ is cleared
403
+ 6. **Single Wave**: All generators are independent, no wave ordering needed
404
+ 7. **Cleanup Temp Files**: Remove wave-1.csv after results are merged
405
+ 8. **DO NOT STOP**: Execute until all generators complete or fail