maestro-flow 0.5.1 → 0.5.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.
- package/.codex/skills/learn-decompose/SKILL.md +144 -144
- package/.codex/skills/learn-follow/SKILL.md +83 -83
- package/.codex/skills/learn-investigate/SKILL.md +84 -84
- package/.codex/skills/learn-retro/SKILL.md +113 -113
- package/.codex/skills/learn-second-opinion/SKILL.md +116 -116
- package/.codex/skills/maestro/SKILL.md +11 -8
- package/.codex/skills/maestro-amend/SKILL.md +4 -4
- package/.codex/skills/maestro-analyze/SKILL.md +2 -2
- package/.codex/skills/maestro-blueprint/SKILL.md +4 -4
- package/.codex/skills/maestro-companion/SKILL.md +4 -4
- package/.codex/skills/maestro-composer/SKILL.md +217 -217
- package/.codex/skills/maestro-grill/SKILL.md +1 -1
- package/.codex/skills/maestro-help/SKILL.md +30 -30
- package/.codex/skills/maestro-init/SKILL.md +1 -1
- package/.codex/skills/maestro-learn/SKILL.md +80 -80
- package/.codex/skills/maestro-merge/SKILL.md +76 -76
- package/.codex/skills/maestro-milestone-release/SKILL.md +74 -74
- package/.codex/skills/maestro-player/SKILL.md +3 -3
- package/.codex/skills/maestro-quick/SKILL.md +129 -129
- package/.codex/skills/maestro-ralph/SKILL.md +9 -9
- package/.codex/skills/maestro-ralph-beta/SKILL.md +34 -34
- package/.codex/skills/maestro-ralph-execute/SKILL.md +5 -5
- package/.codex/skills/maestro-tools-execute/SKILL.md +3 -3
- package/.codex/skills/maestro-tools-register/SKILL.md +3 -3
- package/.codex/skills/manage-codebase-rebuild/SKILL.md +412 -412
- package/.codex/skills/manage-codebase-refresh/SKILL.md +1 -1
- package/.codex/skills/manage-harvest/SKILL.md +99 -99
- package/.codex/skills/manage-issue-discover/SKILL.md +1 -1
- package/.codex/skills/manage-knowhow/SKILL.md +95 -95
- package/.codex/skills/manage-knowhow-capture/SKILL.md +137 -137
- package/.codex/skills/manage-status/SKILL.md +7 -7
- package/.codex/skills/manage-wiki/SKILL.md +55 -55
- package/.codex/skills/quality-auto-test/SKILL.md +1 -1
- package/.codex/skills/quality-debug/SKILL.md +8 -8
- package/.codex/skills/quality-refactor/SKILL.md +3 -3
- package/.codex/skills/quality-review/SKILL.md +1 -1
- package/.codex/skills/quality-sync/SKILL.md +111 -111
- package/.codex/skills/quality-test/SKILL.md +1 -1
- package/.codex/skills/spec-add/SKILL.md +2 -2
- package/.codex/skills/spec-load/SKILL.md +1 -1
- package/.codex/skills/spec-map/SKILL.md +204 -204
- package/.codex/skills/spec-remove/SKILL.md +75 -75
- package/.codex/skills/spec-setup/SKILL.md +2 -2
- package/.codex/skills/wiki-connect/SKILL.md +73 -73
- package/.codex/skills/wiki-digest/SKILL.md +87 -87
- package/dist/src/ralph/skill-scanner.d.ts.map +1 -1
- package/dist/src/ralph/skill-scanner.js +9 -3
- package/dist/src/ralph/skill-scanner.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,412 +1,412 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: manage-codebase-rebuild
|
|
3
|
-
description: Rebuild all codebase documentation from scratch
|
|
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,
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<purpose>
|
|
9
|
-
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.
|
|
10
|
-
|
|
11
|
-
**Core workflow**: Prepare Directory -> Decompose Doc Dimensions -> Parallel Generation -> Assemble doc-index.json
|
|
12
|
-
|
|
13
|
-
**Topology**: Independent Parallel (single wave)
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
+---------------------------------------------------------------------------+
|
|
17
|
-
| CODEBASE REBUILD CSV WAVE WORKFLOW |
|
|
18
|
-
+---------------------------------------------------------------------------+
|
|
19
|
-
| |
|
|
20
|
-
| Phase 1: Setup -> CSV |
|
|
21
|
-
| +-- Validate .workflow/ exists |
|
|
22
|
-
| +-- Confirm rebuild (or --force / -y) |
|
|
23
|
-
| +-- Clear .workflow/codebase/ directory |
|
|
24
|
-
| +-- Detect source directories (src/, lib/, app/, packages/) |
|
|
25
|
-
| +-- Generate tasks.csv with 5 doc generator tasks |
|
|
26
|
-
| +-- All tasks wave 1 (no dependencies) |
|
|
27
|
-
| |
|
|
28
|
-
| Phase 2: Wave Execution (Single Wave) |
|
|
29
|
-
| +-- Wave 1: All 5 generators run concurrently |
|
|
30
|
-
| | +-- Component Scanner (TC-* entries) |
|
|
31
|
-
| | +-- Feature Mapper (FT-* entries) |
|
|
32
|
-
| | +-- Requirement Linker (REQ-* entries, if specs exist) |
|
|
33
|
-
| | +-- Tech Registry Writer (tech-registry/*.md) |
|
|
34
|
-
| | +-- Feature Map Writer (feature-maps/*.md) |
|
|
35
|
-
| +-- discoveries.ndjson shared (append-only) |
|
|
36
|
-
| |
|
|
37
|
-
| Phase 3: Results -> .workflow/codebase/ |
|
|
38
|
-
| +-- Assemble doc-index.json from agent findings |
|
|
39
|
-
| +-- Validate all output files exist |
|
|
40
|
-
| +-- Update state.json with rebuild timestamp |
|
|
41
|
-
| +-- Generate context.md summary |
|
|
42
|
-
| +-- Auto-commit (unless --skip-commit) |
|
|
43
|
-
| +-- Display completion report |
|
|
44
|
-
| |
|
|
45
|
-
+---------------------------------------------------------------------------+
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
</purpose>
|
|
49
|
-
|
|
50
|
-
<context>
|
|
51
|
-
$ARGUMENTS -- optional flags for rebuild control.
|
|
52
|
-
|
|
53
|
-
**Usage**:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
$manage-codebase-rebuild ""
|
|
57
|
-
$manage-codebase-rebuild -y "--force"
|
|
58
|
-
$manage-codebase-rebuild -c 5 "--force --skip-commit"
|
|
59
|
-
$manage-codebase-rebuild --continue "20260318-rebuild-full"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Flags**:
|
|
63
|
-
- `-y, --yes`: Skip all confirmations (auto mode, implies --force)
|
|
64
|
-
- `-c, --concurrency N`: Max concurrent agents (default: 5)
|
|
65
|
-
- `--continue`: Resume existing session
|
|
66
|
-
|
|
67
|
-
**Inner flags** (passed inside quotes):
|
|
68
|
-
- `--force`: Clear existing .workflow/codebase/ and rebuild from scratch
|
|
69
|
-
- `--skip-commit`: Do not auto-commit after rebuild
|
|
70
|
-
|
|
71
|
-
When `--yes` or `-y`: Auto-confirm rebuild (implies --force), skip all prompts.
|
|
72
|
-
|
|
73
|
-
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
74
|
-
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
|
|
75
|
-
**Target**: `.workflow/codebase/` (doc-index.json, tech-registry/, feature-maps/)
|
|
76
|
-
</context>
|
|
77
|
-
|
|
78
|
-
<csv_schema>
|
|
79
|
-
|
|
80
|
-
### tasks.csv (Master State)
|
|
81
|
-
|
|
82
|
-
```csv
|
|
83
|
-
id,title,description,doc_dimension,output_path,deps,context_from,wave
|
|
84
|
-
"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. Return JSON array of component entries with id (TC-NNN), name, type, code_locations, symbols via output_schema. Do NOT write files — orchestrator assembles doc-index.json in Phase 3.","components","<ABS_WORKFLOW>/codebase/doc-index.json#components","","","1"
|
|
85
|
-
"2","Feature Mapper","Group discovered components by domain/functional area using directory proximity, naming patterns, and import relationships. Map features to requirements if <ABS_WORKFLOW>/blueprint/ exists. Return JSON array of feature entries with id (FT-NNN), name, status, component_ids, requirement_ids, phase via output_schema. Do NOT write files.","features","<ABS_WORKFLOW>/codebase/doc-index.json#features","","","1"
|
|
86
|
-
"3","Requirement Linker","If <ABS_WORKFLOW>/blueprint/ exists, scan BLP-*/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. Return JSON arrays for requirements and architecture_decisions via output_schema. Do NOT write files.","requirements","<ABS_WORKFLOW>/codebase/doc-index.json#requirements","","","1"
|
|
87
|
-
"4","Tech Registry Writer","For each component discovered, use the Write tool to create a markdown documentation file at <ABS_WORKFLOW>/codebase/tech-registry/{slug}.md with: ID, type, features, code locations, exported symbols, dependencies. Also write <ABS_WORKFLOW>/codebase/tech-registry/_index.md with the component table. After all writes, verify every intended file exists with Glob and return file count + absolute paths via output_schema. MUST use the Write tool — files on disk are the deliverable, do NOT return file content as text.","tech-registry","<ABS_WORKFLOW>/codebase/tech-registry/","","","1"
|
|
88
|
-
"5","Feature Map Writer","For each feature discovered, use the Write tool to create a markdown documentation file at <ABS_WORKFLOW>/codebase/feature-maps/{slug}.md with: ID, status, phase, requirements, component table. Also write <ABS_WORKFLOW>/codebase/feature-maps/_index.md with the feature table. After all writes, verify every intended file exists with Glob and return file count + absolute paths via output_schema. MUST use the Write tool — files on disk are the deliverable, do NOT return file content as text.","feature-maps","<ABS_WORKFLOW>/codebase/feature-maps/","","","1"
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Path resolution (orchestrator MUST do BEFORE writing tasks.csv)**: substitute `<ABS_WORKFLOW>` with the absolute path to the project's `.workflow/` directory (e.g. `D:/maestro2/.workflow`). Agent Write tool requires absolute paths — passing relative `.workflow/...` literals will fail.
|
|
92
|
-
|
|
93
|
-
**Columns**:
|
|
94
|
-
|
|
95
|
-
| Column | Phase | Description |
|
|
96
|
-
|--------|-------|-------------|
|
|
97
|
-
| `id` | Input | Generator identifier |
|
|
98
|
-
| `title` | Input | Doc generator dimension title |
|
|
99
|
-
| `description` | Input | Detailed generation instructions |
|
|
100
|
-
| `doc_dimension` | Input | Documentation dimension: components/features/requirements/tech-registry/feature-maps |
|
|
101
|
-
| `output_path` | Input | Target output path in .workflow/codebase/ |
|
|
102
|
-
| `deps` | Input | Empty (all independent) |
|
|
103
|
-
| `context_from` | Input | Empty (no cross-task context needed) |
|
|
104
|
-
| `wave` | Computed | Always 1 (single wave, independent parallel) |
|
|
105
|
-
|
|
106
|
-
**Output columns** (returned exclusively via `output_schema`, NOT in wave CSV):
|
|
107
|
-
|
|
108
|
-
| Column | Description |
|
|
109
|
-
|--------|-------------|
|
|
110
|
-
| `result_status` | `completed` / `failed` (mapped to master `status` on merge) |
|
|
111
|
-
| `result_findings` | Generation summary -- counts, paths, notes (max 500 chars) |
|
|
112
|
-
| `error` | Error message if failed |
|
|
113
|
-
|
|
114
|
-
**Column separation rule**: Input columns and Output columns MUST NOT share names. Wave CSV only contains Input columns + prev_context. Output columns are returned exclusively via output_schema.
|
|
115
|
-
|
|
116
|
-
### Per-Wave CSV (Temporary)
|
|
117
|
-
|
|
118
|
-
Single wave generates `wave-1.csv`. No `prev_context` needed (all tasks independent).
|
|
119
|
-
</csv_schema>
|
|
120
|
-
|
|
121
|
-
<invariants>
|
|
122
|
-
1. **Start Immediately**: First action is session initialization, then Phase 1
|
|
123
|
-
2. **CSV is Source of Truth**: tasks.csv holds all generator state
|
|
124
|
-
3. **Discovery Board is Append-Only**: Generators share findings via NDJSON
|
|
125
|
-
4. **Partial Results OK**: If 3/5 generators succeed, still assemble available docs
|
|
126
|
-
5. **Destructive by Design**: This is a full rebuild -- existing codebase/ is cleared
|
|
127
|
-
6. **Single Wave**: All generators are independent, no wave ordering needed
|
|
128
|
-
7. **Cleanup Temp Files**: Remove wave-1.csv after results are merged
|
|
129
|
-
8. **DO NOT STOP**: Execute until all generators complete or fail
|
|
130
|
-
9. **Absolute Paths Only**: All paths in `description` and `output_path` MUST be absolute before tasks.csv is written. Orchestrator substitutes `<ABS_WORKFLOW>` placeholder; never let it leak into a spawned agent's prompt.
|
|
131
|
-
10. **Writer vs Returner Split**: Tasks 1-3 return data via `output_schema` (no file writes). Tasks 4-5 MUST write files via Write tool + verify with Glob. Mixing the two contracts (e.g., returning markdown content as text from tasks 4-5) is a contract violation.
|
|
132
|
-
</invariants>
|
|
133
|
-
|
|
134
|
-
<execution>
|
|
135
|
-
|
|
136
|
-
### Output Artifacts
|
|
137
|
-
|
|
138
|
-
| File | Purpose | Lifecycle |
|
|
139
|
-
|------|---------|-----------|
|
|
140
|
-
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after wave |
|
|
141
|
-
| `wave-1.csv` | Wave input (temporary) | Created before wave, deleted after |
|
|
142
|
-
| `wave-1-results.csv` | Wave output | Created by spawn_agents_on_csv |
|
|
143
|
-
| `results.csv` | Final export of all task results | Created in Phase 3 |
|
|
144
|
-
| `discoveries.ndjson` | Shared exploration board | Append-only during wave |
|
|
145
|
-
| `context.md` | Human-readable rebuild report | Created in Phase 3 |
|
|
146
|
-
|
|
147
|
-
### Target Output (in .workflow/codebase/)
|
|
148
|
-
|
|
149
|
-
| File | Description |
|
|
150
|
-
|------|-------------|
|
|
151
|
-
| `doc-index.json` | Single source of truth: components, features, requirements, ADRs |
|
|
152
|
-
| `tech-registry/_index.md` | Component index table |
|
|
153
|
-
| `tech-registry/{slug}.md` | Per-component documentation |
|
|
154
|
-
| `feature-maps/_index.md` | Feature index table |
|
|
155
|
-
| `feature-maps/{slug}.md` | Per-feature documentation |
|
|
156
|
-
| `knowledge-graph.json` | Knowledge Graph: nodes, edges, layers, tour (generated by `maestro kg index`) |
|
|
157
|
-
|
|
158
|
-
**Wiki Integration**: After rebuild, KG nodes are automatically indexed as virtual wiki entries (type: knowhow, virtualKind: kg-node/kg-layer/kg-tour-step) on next `maestro wiki` access. Verify with `maestro search "kg" --type knowhow`. Use `maestro kg diff-wiki` for future change impact analysis.
|
|
159
|
-
|
|
160
|
-
### Session Structure
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
.workflow/.csv-wave/{YYYYMMDD}-rebuild-{scope}/
|
|
164
|
-
+-- tasks.csv
|
|
165
|
-
+-- results.csv
|
|
166
|
-
+-- discoveries.ndjson
|
|
167
|
-
+-- context.md
|
|
168
|
-
+-- config.json
|
|
169
|
-
+-- wave-1.csv (temporary)
|
|
170
|
-
+-- wave-1-results.csv (temporary)
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Session Initialization
|
|
174
|
-
|
|
175
|
-
Parse `$ARGUMENTS` to extract:
|
|
176
|
-
- `AUTO_YES` from `--yes` / `-y`
|
|
177
|
-
- `continueMode` from `--continue`
|
|
178
|
-
- `maxConcurrency` from `--concurrency N` / `-c N` (default: 5)
|
|
179
|
-
- `forceMode` from `--force` (or implied by AUTO_YES)
|
|
180
|
-
- `skipCommit` from `--skip-commit`
|
|
181
|
-
|
|
182
|
-
Session ID: `{YYYYMMDD}-rebuild-full`
|
|
183
|
-
Session folder: `.workflow/.csv-wave/{sessionId}/` — create via `mkdir -p`
|
|
184
|
-
|
|
185
|
-
### Phase 1: Setup -> CSV
|
|
186
|
-
|
|
187
|
-
**Objective**: Validate prerequisites, prepare directory, detect source dirs, generate tasks.csv.
|
|
188
|
-
|
|
189
|
-
**Steps**:
|
|
190
|
-
|
|
191
|
-
1. **Validate** `.workflow/state.json` exists — abort with "Run init first" if missing
|
|
192
|
-
2. **Confirm rebuild**: If `.workflow/codebase/` exists AND NOT forceMode, prompt user. If forceMode or confirmed, clear `.workflow/codebase/`
|
|
193
|
-
3. **Prepare directories**:
|
|
194
|
-
```bash
|
|
195
|
-
mkdir -p .workflow/codebase/tech-registry
|
|
196
|
-
mkdir -p .workflow/codebase/feature-maps
|
|
197
|
-
mkdir -p .workflow/codebase/action-logs
|
|
198
|
-
```
|
|
199
|
-
4. **Detect source directories**: `src/`, `lib/`, `app/`, `packages/` — abort if none found
|
|
200
|
-
5. **Load project specs** from `.workflow/specs/` if available
|
|
201
|
-
6. **Generate tasks.csv**: 5 rows, all wave 1, no dependencies
|
|
202
|
-
7. **User validation**: Display doc generator breakdown (skip if AUTO_YES)
|
|
203
|
-
|
|
204
|
-
### Phase 2: Wave Execution (Single Wave)
|
|
205
|
-
|
|
206
|
-
**Objective**: Run all 5 doc generators concurrently via spawn_agents_on_csv.
|
|
207
|
-
|
|
208
|
-
#### Wave 1: All Generators (Parallel)
|
|
209
|
-
|
|
210
|
-
Filter master `tasks.csv` for `wave == 1 AND status == pending` → write `wave-1.csv` (no prev_context needed, all independent).
|
|
211
|
-
|
|
212
|
-
```javascript
|
|
213
|
-
spawn_agents_on_csv({
|
|
214
|
-
csv_path: `${sessionFolder}/wave-1.csv`,
|
|
215
|
-
id_column: "id",
|
|
216
|
-
instruction: REBUILD_INSTRUCTION, // see "Rebuild Worker Contract" below
|
|
217
|
-
max_concurrency: maxConcurrency,
|
|
218
|
-
max_runtime_seconds: 3600,
|
|
219
|
-
output_csv_path: `${sessionFolder}/wave-1-results.csv`,
|
|
220
|
-
output_schema: {
|
|
221
|
-
type: "object",
|
|
222
|
-
properties: {
|
|
223
|
-
id: { type: "string" },
|
|
224
|
-
result_status: { type: "string", enum: ["completed", "failed"] },
|
|
225
|
-
result_findings: { type: "string", description: "For task 1-3: JSON payload to merge into doc-index.json. For task 4-5: list of files written" },
|
|
226
|
-
error: { type: "string" }
|
|
227
|
-
},
|
|
228
|
-
required: ["id", "result_status", "result_findings"]
|
|
229
|
-
}
|
|
230
|
-
})
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Merge `wave-1-results.csv` into master `tasks.csv`: map `result_status` -> master `status`, `result_findings` -> master `findings`, copy `error` as-is. After merge, delete temporary files (`wave-1.csv` and `wave-1-results.csv`).
|
|
234
|
-
|
|
235
|
-
#### Rebuild Worker Contract (REBUILD_INSTRUCTION)
|
|
236
|
-
|
|
237
|
-
```
|
|
238
|
-
You are a codebase doc generator for ONE task (Component Scanner / Feature Mapper / Requirement Linker / Tech Registry Writer / Feature Map Writer). Your contract depends on your task id — read description carefully.
|
|
239
|
-
|
|
240
|
-
DUAL CONTRACT (per task id):
|
|
241
|
-
Tasks 1-3 (Scanner/Mapper/Linker) → RETURN data via result_findings (JSON payload). Do NOT write files.
|
|
242
|
-
Tasks 4-5 (Writers) → MUST WRITE files via the Write tool. Verify each via Glob. Return file count + absolute paths via result_findings.
|
|
243
|
-
|
|
244
|
-
REQUIRED STEPS:
|
|
245
|
-
1. Scan codebase per description and focus_area
|
|
246
|
-
2. For tasks 1-3: assemble JSON payload matching the documented section schema (components / features / requirements)
|
|
247
|
-
3. For tasks 4-5: render markdown documents and write them to disk; verify every intended file exists via Glob; if any file missing → result_status=failed
|
|
248
|
-
4. Append discoveries to {sessionFolder}/discoveries.ndjson if reusable
|
|
249
|
-
5. Call report_agent_job_result EXACTLY ONCE
|
|
250
|
-
|
|
251
|
-
TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
|
|
252
|
-
- Success → result_status=completed
|
|
253
|
-
- Failure → unrecoverable error / write verification fails → result_status=failed
|
|
254
|
-
- Timeout → near max_runtime_seconds, finish current write/scan if safe, then report failed with error="timeout (partial)"
|
|
255
|
-
- NEVER skip report_agent_job_result.
|
|
256
|
-
|
|
257
|
-
CONTRACT VIOLATION GUARD:
|
|
258
|
-
- Tasks 4-5 returning markdown content in result_findings instead of writing files → MUST self-report failed (orchestrator cannot assemble docs from text).
|
|
259
|
-
- Tasks 1-3 writing files to .workflow/codebase/ → MUST self-report failed (orchestrator owns assembly).
|
|
260
|
-
|
|
261
|
-
OUTPUT (must match output_schema):
|
|
262
|
-
Tasks 1-3:
|
|
263
|
-
{
|
|
264
|
-
"id": "<your row id>",
|
|
265
|
-
"result_status": "completed" | "failed",
|
|
266
|
-
"result_findings": "<JSON payload to merge into doc-index.json section>",
|
|
267
|
-
"error": "<message if failed, else empty>"
|
|
268
|
-
}
|
|
269
|
-
Tasks 4-5:
|
|
270
|
-
{
|
|
271
|
-
"id": "<your row id>",
|
|
272
|
-
"result_status": "completed" | "failed",
|
|
273
|
-
"result_findings": "<count + semicolon-separated absolute paths of files written>",
|
|
274
|
-
"error": "<message if failed, else empty>"
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
CONSTRAINTS:
|
|
278
|
-
- Do NOT write to tasks.csv, wave-*.csv, results.csv, doc-index.json (orchestrator assembles in Phase 3).
|
|
279
|
-
- Do NOT call spawn_agents_on_csv (no recursion).
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Phase 3: Results -> .workflow/codebase/
|
|
283
|
-
|
|
284
|
-
**Objective**: Assemble doc-index.json from agent findings, validate, update state.
|
|
285
|
-
|
|
286
|
-
Export master `tasks.csv` as `results.csv`.
|
|
287
|
-
|
|
288
|
-
**Assemble doc-index.json** by merging findings from tasks 1-3 (Component Scanner, Feature Mapper, Requirement Linker):
|
|
289
|
-
```json
|
|
290
|
-
{
|
|
291
|
-
"version": "1.0",
|
|
292
|
-
"schema_version": "1.0",
|
|
293
|
-
"project": "<project name>",
|
|
294
|
-
"last_updated": "<ISO>",
|
|
295
|
-
"features": [],
|
|
296
|
-
"components": [],
|
|
297
|
-
"requirements": [],
|
|
298
|
-
"architecture_decisions": [],
|
|
299
|
-
"actions": []
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
- Write to `.workflow/codebase/doc-index.json`
|
|
303
|
-
|
|
304
|
-
**Validate output files**: doc-index.json (valid JSON), tech-registry/_index.md, feature-maps/_index.md — log warnings for missing.
|
|
305
|
-
|
|
306
|
-
**Update state.json**: Set `codebase.last_rebuild` timestamp.
|
|
307
|
-
|
|
308
|
-
**Generate context.md**:
|
|
309
|
-
|
|
310
|
-
```markdown
|
|
311
|
-
# Codebase Rebuild Report
|
|
312
|
-
|
|
313
|
-
## Summary
|
|
314
|
-
- Components discovered: {count}
|
|
315
|
-
- Features mapped: {count}
|
|
316
|
-
- Requirements linked: {count}
|
|
317
|
-
- ADRs recorded: {count}
|
|
318
|
-
- Files generated: {count}
|
|
319
|
-
- Generators: {completed}/{total} succeeded
|
|
320
|
-
|
|
321
|
-
## Generator Results
|
|
322
|
-
| Generator | Status | Output | Findings |
|
|
323
|
-
|-----------|--------|--------|----------|
|
|
324
|
-
| Component Scanner | {status} | {count} components | {summary} |
|
|
325
|
-
| Feature Mapper | {status} | {count} features | {summary} |
|
|
326
|
-
| Requirement Linker | {status} | {count} requirements | {summary} |
|
|
327
|
-
| Tech Registry Writer | {status} | {count} files | {summary} |
|
|
328
|
-
| Feature Map Writer | {status} | {count} files | {summary} |
|
|
329
|
-
|
|
330
|
-
## Discovery Board Summary
|
|
331
|
-
{aggregated discovery findings}
|
|
332
|
-
|
|
333
|
-
## Next Steps
|
|
334
|
-
- Run manage-status to review
|
|
335
|
-
- Run manage-codebase-refresh for future incremental updates
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
**Auto-commit** (unless --skip-commit): Stage `.workflow/codebase/` files, commit "docs(codebase): full rebuild of codebase documentation".
|
|
339
|
-
|
|
340
|
-
**Display completion report**:
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
=== CODEBASE REBUILD COMPLETE ===
|
|
344
|
-
Components: {count}
|
|
345
|
-
Features: {count}
|
|
346
|
-
Requirements: {count}
|
|
347
|
-
ADRs: {count}
|
|
348
|
-
Files: {count} generated in .workflow/codebase/
|
|
349
|
-
|
|
350
|
-
Generators: {completed}/{total} succeeded
|
|
351
|
-
{if failures: "W001: {failed_generator} failed -- partial results available"}
|
|
352
|
-
|
|
353
|
-
Next steps:
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
maestro kg stats # verify KG
|
|
357
|
-
maestro search "kg" --type knowhow # verify wiki integration
|
|
358
|
-
maestro kg diff-wiki # future change impact
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### Shared Discovery Board Protocol
|
|
362
|
-
|
|
363
|
-
#### Standard Discovery Types
|
|
364
|
-
|
|
365
|
-
| Type | Dedup Key | Data Schema | Description |
|
|
366
|
-
|------|-----------|-------------|-------------|
|
|
367
|
-
| `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack identified |
|
|
368
|
-
| `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
|
|
369
|
-
| `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
|
|
370
|
-
| `convention` | singleton | `{naming, imports, formatting}` | Project coding conventions |
|
|
371
|
-
|
|
372
|
-
#### Domain Discovery Types
|
|
373
|
-
|
|
374
|
-
| Type | Dedup Key | Data Schema | Description |
|
|
375
|
-
|------|-----------|-------------|-------------|
|
|
376
|
-
| `component` | `data.id` | `{id, name, type, code_locations[]}` | Component discovered by scanner |
|
|
377
|
-
| `feature_group` | `data.name` | `{name, component_ids[], directory}` | Feature grouping identified |
|
|
378
|
-
|
|
379
|
-
#### Protocol
|
|
380
|
-
|
|
381
|
-
Read `{session_folder}/discoveries.ndjson` before own analysis. Deduplicate by type + dedup key before writing. Append-only — never modify or delete. Generators share discoveries to skip redundant scanning.
|
|
382
|
-
|
|
383
|
-
```bash
|
|
384
|
-
echo '{"ts":"<ISO>","worker":"1","type":"tech_stack","data":{"framework":"Express","language":"TypeScript","tools":["jest","eslint","prettier"]}}' >> {session_folder}/discoveries.ndjson
|
|
385
|
-
```
|
|
386
|
-
</execution>
|
|
387
|
-
|
|
388
|
-
<error_codes>
|
|
389
|
-
| Error | Resolution |
|
|
390
|
-
|-------|------------|
|
|
391
|
-
| .workflow/ not initialized | Abort: "Run init first" (E001) |
|
|
392
|
-
| No source directories found | Abort: "No source files in project" |
|
|
393
|
-
| .workflow/codebase/ exists without --force | Prompt user for confirmation |
|
|
394
|
-
| Generator agent timeout | Mark as failed, continue with other generators |
|
|
395
|
-
| Generator agent failed | Mark as failed, log W001, output partial results |
|
|
396
|
-
| doc-index.json assembly fails | Use available generator outputs, log missing sections |
|
|
397
|
-
| CSV parse error | Validate format, show line number |
|
|
398
|
-
| discoveries.ndjson corrupt | Ignore malformed lines |
|
|
399
|
-
| Continue mode: no session found | List available sessions |
|
|
400
|
-
</error_codes>
|
|
401
|
-
|
|
402
|
-
<success_criteria>
|
|
403
|
-
- [ ] Session initialized with tasks.csv
|
|
404
|
-
- [ ] .workflow/codebase/ cleared (if --force or confirmed)
|
|
405
|
-
- [ ] All 5 doc generators executed via spawn_agents_on_csv
|
|
406
|
-
- [ ] doc-index.json assembled from generator findings
|
|
407
|
-
- [ ] tech-registry/ and feature-maps/ populated with markdown docs
|
|
408
|
-
- [ ] state.json updated with rebuild timestamp
|
|
409
|
-
- [ ] context.md generated with rebuild report
|
|
410
|
-
- [ ] Auto-commit performed (unless --skip-commit)
|
|
411
|
-
- [ ] Completion report displayed with counts and next steps
|
|
412
|
-
</success_criteria>
|
|
1
|
+
---
|
|
2
|
+
name: manage-codebase-rebuild
|
|
3
|
+
description: Rebuild all codebase documentation from scratch
|
|
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, request_user_input
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<purpose>
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
**Core workflow**: Prepare Directory -> Decompose Doc Dimensions -> Parallel Generation -> Assemble doc-index.json
|
|
12
|
+
|
|
13
|
+
**Topology**: Independent Parallel (single wave)
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
+---------------------------------------------------------------------------+
|
|
17
|
+
| CODEBASE REBUILD CSV WAVE WORKFLOW |
|
|
18
|
+
+---------------------------------------------------------------------------+
|
|
19
|
+
| |
|
|
20
|
+
| Phase 1: Setup -> CSV |
|
|
21
|
+
| +-- Validate .workflow/ exists |
|
|
22
|
+
| +-- Confirm rebuild (or --force / -y) |
|
|
23
|
+
| +-- Clear .workflow/codebase/ directory |
|
|
24
|
+
| +-- Detect source directories (src/, lib/, app/, packages/) |
|
|
25
|
+
| +-- Generate tasks.csv with 5 doc generator tasks |
|
|
26
|
+
| +-- All tasks wave 1 (no dependencies) |
|
|
27
|
+
| |
|
|
28
|
+
| Phase 2: Wave Execution (Single Wave) |
|
|
29
|
+
| +-- Wave 1: All 5 generators run concurrently |
|
|
30
|
+
| | +-- Component Scanner (TC-* entries) |
|
|
31
|
+
| | +-- Feature Mapper (FT-* entries) |
|
|
32
|
+
| | +-- Requirement Linker (REQ-* entries, if specs exist) |
|
|
33
|
+
| | +-- Tech Registry Writer (tech-registry/*.md) |
|
|
34
|
+
| | +-- Feature Map Writer (feature-maps/*.md) |
|
|
35
|
+
| +-- discoveries.ndjson shared (append-only) |
|
|
36
|
+
| |
|
|
37
|
+
| Phase 3: Results -> .workflow/codebase/ |
|
|
38
|
+
| +-- Assemble doc-index.json from agent findings |
|
|
39
|
+
| +-- Validate all output files exist |
|
|
40
|
+
| +-- Update state.json with rebuild timestamp |
|
|
41
|
+
| +-- Generate context.md summary |
|
|
42
|
+
| +-- Auto-commit (unless --skip-commit) |
|
|
43
|
+
| +-- Display completion report |
|
|
44
|
+
| |
|
|
45
|
+
+---------------------------------------------------------------------------+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</purpose>
|
|
49
|
+
|
|
50
|
+
<context>
|
|
51
|
+
$ARGUMENTS -- optional flags for rebuild control.
|
|
52
|
+
|
|
53
|
+
**Usage**:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
$manage-codebase-rebuild ""
|
|
57
|
+
$manage-codebase-rebuild -y "--force"
|
|
58
|
+
$manage-codebase-rebuild -c 5 "--force --skip-commit"
|
|
59
|
+
$manage-codebase-rebuild --continue "20260318-rebuild-full"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Flags**:
|
|
63
|
+
- `-y, --yes`: Skip all confirmations (auto mode, implies --force)
|
|
64
|
+
- `-c, --concurrency N`: Max concurrent agents (default: 5)
|
|
65
|
+
- `--continue`: Resume existing session
|
|
66
|
+
|
|
67
|
+
**Inner flags** (passed inside quotes):
|
|
68
|
+
- `--force`: Clear existing .workflow/codebase/ and rebuild from scratch
|
|
69
|
+
- `--skip-commit`: Do not auto-commit after rebuild
|
|
70
|
+
|
|
71
|
+
When `--yes` or `-y`: Auto-confirm rebuild (implies --force), skip all prompts.
|
|
72
|
+
|
|
73
|
+
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
74
|
+
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
|
|
75
|
+
**Target**: `.workflow/codebase/` (doc-index.json, tech-registry/, feature-maps/)
|
|
76
|
+
</context>
|
|
77
|
+
|
|
78
|
+
<csv_schema>
|
|
79
|
+
|
|
80
|
+
### tasks.csv (Master State)
|
|
81
|
+
|
|
82
|
+
```csv
|
|
83
|
+
id,title,description,doc_dimension,output_path,deps,context_from,wave
|
|
84
|
+
"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. Return JSON array of component entries with id (TC-NNN), name, type, code_locations, symbols via output_schema. Do NOT write files — orchestrator assembles doc-index.json in Phase 3.","components","<ABS_WORKFLOW>/codebase/doc-index.json#components","","","1"
|
|
85
|
+
"2","Feature Mapper","Group discovered components by domain/functional area using directory proximity, naming patterns, and import relationships. Map features to requirements if <ABS_WORKFLOW>/blueprint/ exists. Return JSON array of feature entries with id (FT-NNN), name, status, component_ids, requirement_ids, phase via output_schema. Do NOT write files.","features","<ABS_WORKFLOW>/codebase/doc-index.json#features","","","1"
|
|
86
|
+
"3","Requirement Linker","If <ABS_WORKFLOW>/blueprint/ exists, scan BLP-*/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. Return JSON arrays for requirements and architecture_decisions via output_schema. Do NOT write files.","requirements","<ABS_WORKFLOW>/codebase/doc-index.json#requirements","","","1"
|
|
87
|
+
"4","Tech Registry Writer","For each component discovered, use the Write tool to create a markdown documentation file at <ABS_WORKFLOW>/codebase/tech-registry/{slug}.md with: ID, type, features, code locations, exported symbols, dependencies. Also write <ABS_WORKFLOW>/codebase/tech-registry/_index.md with the component table. After all writes, verify every intended file exists with Glob and return file count + absolute paths via output_schema. MUST use the Write tool — files on disk are the deliverable, do NOT return file content as text.","tech-registry","<ABS_WORKFLOW>/codebase/tech-registry/","","","1"
|
|
88
|
+
"5","Feature Map Writer","For each feature discovered, use the Write tool to create a markdown documentation file at <ABS_WORKFLOW>/codebase/feature-maps/{slug}.md with: ID, status, phase, requirements, component table. Also write <ABS_WORKFLOW>/codebase/feature-maps/_index.md with the feature table. After all writes, verify every intended file exists with Glob and return file count + absolute paths via output_schema. MUST use the Write tool — files on disk are the deliverable, do NOT return file content as text.","feature-maps","<ABS_WORKFLOW>/codebase/feature-maps/","","","1"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Path resolution (orchestrator MUST do BEFORE writing tasks.csv)**: substitute `<ABS_WORKFLOW>` with the absolute path to the project's `.workflow/` directory (e.g. `D:/maestro2/.workflow`). Agent Write tool requires absolute paths — passing relative `.workflow/...` literals will fail.
|
|
92
|
+
|
|
93
|
+
**Columns**:
|
|
94
|
+
|
|
95
|
+
| Column | Phase | Description |
|
|
96
|
+
|--------|-------|-------------|
|
|
97
|
+
| `id` | Input | Generator identifier |
|
|
98
|
+
| `title` | Input | Doc generator dimension title |
|
|
99
|
+
| `description` | Input | Detailed generation instructions |
|
|
100
|
+
| `doc_dimension` | Input | Documentation dimension: components/features/requirements/tech-registry/feature-maps |
|
|
101
|
+
| `output_path` | Input | Target output path in .workflow/codebase/ |
|
|
102
|
+
| `deps` | Input | Empty (all independent) |
|
|
103
|
+
| `context_from` | Input | Empty (no cross-task context needed) |
|
|
104
|
+
| `wave` | Computed | Always 1 (single wave, independent parallel) |
|
|
105
|
+
|
|
106
|
+
**Output columns** (returned exclusively via `output_schema`, NOT in wave CSV):
|
|
107
|
+
|
|
108
|
+
| Column | Description |
|
|
109
|
+
|--------|-------------|
|
|
110
|
+
| `result_status` | `completed` / `failed` (mapped to master `status` on merge) |
|
|
111
|
+
| `result_findings` | Generation summary -- counts, paths, notes (max 500 chars) |
|
|
112
|
+
| `error` | Error message if failed |
|
|
113
|
+
|
|
114
|
+
**Column separation rule**: Input columns and Output columns MUST NOT share names. Wave CSV only contains Input columns + prev_context. Output columns are returned exclusively via output_schema.
|
|
115
|
+
|
|
116
|
+
### Per-Wave CSV (Temporary)
|
|
117
|
+
|
|
118
|
+
Single wave generates `wave-1.csv`. No `prev_context` needed (all tasks independent).
|
|
119
|
+
</csv_schema>
|
|
120
|
+
|
|
121
|
+
<invariants>
|
|
122
|
+
1. **Start Immediately**: First action is session initialization, then Phase 1
|
|
123
|
+
2. **CSV is Source of Truth**: tasks.csv holds all generator state
|
|
124
|
+
3. **Discovery Board is Append-Only**: Generators share findings via NDJSON
|
|
125
|
+
4. **Partial Results OK**: If 3/5 generators succeed, still assemble available docs
|
|
126
|
+
5. **Destructive by Design**: This is a full rebuild -- existing codebase/ is cleared
|
|
127
|
+
6. **Single Wave**: All generators are independent, no wave ordering needed
|
|
128
|
+
7. **Cleanup Temp Files**: Remove wave-1.csv after results are merged
|
|
129
|
+
8. **DO NOT STOP**: Execute until all generators complete or fail
|
|
130
|
+
9. **Absolute Paths Only**: All paths in `description` and `output_path` MUST be absolute before tasks.csv is written. Orchestrator substitutes `<ABS_WORKFLOW>` placeholder; never let it leak into a spawned agent's prompt.
|
|
131
|
+
10. **Writer vs Returner Split**: Tasks 1-3 return data via `output_schema` (no file writes). Tasks 4-5 MUST write files via Write tool + verify with Glob. Mixing the two contracts (e.g., returning markdown content as text from tasks 4-5) is a contract violation.
|
|
132
|
+
</invariants>
|
|
133
|
+
|
|
134
|
+
<execution>
|
|
135
|
+
|
|
136
|
+
### Output Artifacts
|
|
137
|
+
|
|
138
|
+
| File | Purpose | Lifecycle |
|
|
139
|
+
|------|---------|-----------|
|
|
140
|
+
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after wave |
|
|
141
|
+
| `wave-1.csv` | Wave input (temporary) | Created before wave, deleted after |
|
|
142
|
+
| `wave-1-results.csv` | Wave output | Created by spawn_agents_on_csv |
|
|
143
|
+
| `results.csv` | Final export of all task results | Created in Phase 3 |
|
|
144
|
+
| `discoveries.ndjson` | Shared exploration board | Append-only during wave |
|
|
145
|
+
| `context.md` | Human-readable rebuild report | Created in Phase 3 |
|
|
146
|
+
|
|
147
|
+
### Target Output (in .workflow/codebase/)
|
|
148
|
+
|
|
149
|
+
| File | Description |
|
|
150
|
+
|------|-------------|
|
|
151
|
+
| `doc-index.json` | Single source of truth: components, features, requirements, ADRs |
|
|
152
|
+
| `tech-registry/_index.md` | Component index table |
|
|
153
|
+
| `tech-registry/{slug}.md` | Per-component documentation |
|
|
154
|
+
| `feature-maps/_index.md` | Feature index table |
|
|
155
|
+
| `feature-maps/{slug}.md` | Per-feature documentation |
|
|
156
|
+
| `knowledge-graph.json` | Knowledge Graph: nodes, edges, layers, tour (generated by `maestro kg index`) |
|
|
157
|
+
|
|
158
|
+
**Wiki Integration**: After rebuild, KG nodes are automatically indexed as virtual wiki entries (type: knowhow, virtualKind: kg-node/kg-layer/kg-tour-step) on next `maestro wiki` access. Verify with `maestro search "kg" --type knowhow`. Use `maestro kg diff-wiki` for future change impact analysis.
|
|
159
|
+
|
|
160
|
+
### Session Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
.workflow/.csv-wave/{YYYYMMDD}-rebuild-{scope}/
|
|
164
|
+
+-- tasks.csv
|
|
165
|
+
+-- results.csv
|
|
166
|
+
+-- discoveries.ndjson
|
|
167
|
+
+-- context.md
|
|
168
|
+
+-- config.json
|
|
169
|
+
+-- wave-1.csv (temporary)
|
|
170
|
+
+-- wave-1-results.csv (temporary)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Session Initialization
|
|
174
|
+
|
|
175
|
+
Parse `$ARGUMENTS` to extract:
|
|
176
|
+
- `AUTO_YES` from `--yes` / `-y`
|
|
177
|
+
- `continueMode` from `--continue`
|
|
178
|
+
- `maxConcurrency` from `--concurrency N` / `-c N` (default: 5)
|
|
179
|
+
- `forceMode` from `--force` (or implied by AUTO_YES)
|
|
180
|
+
- `skipCommit` from `--skip-commit`
|
|
181
|
+
|
|
182
|
+
Session ID: `{YYYYMMDD}-rebuild-full`
|
|
183
|
+
Session folder: `.workflow/.csv-wave/{sessionId}/` — create via `mkdir -p`
|
|
184
|
+
|
|
185
|
+
### Phase 1: Setup -> CSV
|
|
186
|
+
|
|
187
|
+
**Objective**: Validate prerequisites, prepare directory, detect source dirs, generate tasks.csv.
|
|
188
|
+
|
|
189
|
+
**Steps**:
|
|
190
|
+
|
|
191
|
+
1. **Validate** `.workflow/state.json` exists — abort with "Run init first" if missing
|
|
192
|
+
2. **Confirm rebuild**: If `.workflow/codebase/` exists AND NOT forceMode, prompt user. If forceMode or confirmed, clear `.workflow/codebase/`
|
|
193
|
+
3. **Prepare directories**:
|
|
194
|
+
```bash
|
|
195
|
+
mkdir -p .workflow/codebase/tech-registry
|
|
196
|
+
mkdir -p .workflow/codebase/feature-maps
|
|
197
|
+
mkdir -p .workflow/codebase/action-logs
|
|
198
|
+
```
|
|
199
|
+
4. **Detect source directories**: `src/`, `lib/`, `app/`, `packages/` — abort if none found
|
|
200
|
+
5. **Load project specs** from `.workflow/specs/` if available
|
|
201
|
+
6. **Generate tasks.csv**: 5 rows, all wave 1, no dependencies
|
|
202
|
+
7. **User validation**: Display doc generator breakdown (skip if AUTO_YES)
|
|
203
|
+
|
|
204
|
+
### Phase 2: Wave Execution (Single Wave)
|
|
205
|
+
|
|
206
|
+
**Objective**: Run all 5 doc generators concurrently via spawn_agents_on_csv.
|
|
207
|
+
|
|
208
|
+
#### Wave 1: All Generators (Parallel)
|
|
209
|
+
|
|
210
|
+
Filter master `tasks.csv` for `wave == 1 AND status == pending` → write `wave-1.csv` (no prev_context needed, all independent).
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
spawn_agents_on_csv({
|
|
214
|
+
csv_path: `${sessionFolder}/wave-1.csv`,
|
|
215
|
+
id_column: "id",
|
|
216
|
+
instruction: REBUILD_INSTRUCTION, // see "Rebuild Worker Contract" below
|
|
217
|
+
max_concurrency: maxConcurrency,
|
|
218
|
+
max_runtime_seconds: 3600,
|
|
219
|
+
output_csv_path: `${sessionFolder}/wave-1-results.csv`,
|
|
220
|
+
output_schema: {
|
|
221
|
+
type: "object",
|
|
222
|
+
properties: {
|
|
223
|
+
id: { type: "string" },
|
|
224
|
+
result_status: { type: "string", enum: ["completed", "failed"] },
|
|
225
|
+
result_findings: { type: "string", description: "For task 1-3: JSON payload to merge into doc-index.json. For task 4-5: list of files written" },
|
|
226
|
+
error: { type: "string" }
|
|
227
|
+
},
|
|
228
|
+
required: ["id", "result_status", "result_findings"]
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Merge `wave-1-results.csv` into master `tasks.csv`: map `result_status` -> master `status`, `result_findings` -> master `findings`, copy `error` as-is. After merge, delete temporary files (`wave-1.csv` and `wave-1-results.csv`).
|
|
234
|
+
|
|
235
|
+
#### Rebuild Worker Contract (REBUILD_INSTRUCTION)
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
You are a codebase doc generator for ONE task (Component Scanner / Feature Mapper / Requirement Linker / Tech Registry Writer / Feature Map Writer). Your contract depends on your task id — read description carefully.
|
|
239
|
+
|
|
240
|
+
DUAL CONTRACT (per task id):
|
|
241
|
+
Tasks 1-3 (Scanner/Mapper/Linker) → RETURN data via result_findings (JSON payload). Do NOT write files.
|
|
242
|
+
Tasks 4-5 (Writers) → MUST WRITE files via the Write tool. Verify each via Glob. Return file count + absolute paths via result_findings.
|
|
243
|
+
|
|
244
|
+
REQUIRED STEPS:
|
|
245
|
+
1. Scan codebase per description and focus_area
|
|
246
|
+
2. For tasks 1-3: assemble JSON payload matching the documented section schema (components / features / requirements)
|
|
247
|
+
3. For tasks 4-5: render markdown documents and write them to disk; verify every intended file exists via Glob; if any file missing → result_status=failed
|
|
248
|
+
4. Append discoveries to {sessionFolder}/discoveries.ndjson if reusable
|
|
249
|
+
5. Call report_agent_job_result EXACTLY ONCE
|
|
250
|
+
|
|
251
|
+
TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
|
|
252
|
+
- Success → result_status=completed
|
|
253
|
+
- Failure → unrecoverable error / write verification fails → result_status=failed
|
|
254
|
+
- Timeout → near max_runtime_seconds, finish current write/scan if safe, then report failed with error="timeout (partial)"
|
|
255
|
+
- NEVER skip report_agent_job_result.
|
|
256
|
+
|
|
257
|
+
CONTRACT VIOLATION GUARD:
|
|
258
|
+
- Tasks 4-5 returning markdown content in result_findings instead of writing files → MUST self-report failed (orchestrator cannot assemble docs from text).
|
|
259
|
+
- Tasks 1-3 writing files to .workflow/codebase/ → MUST self-report failed (orchestrator owns assembly).
|
|
260
|
+
|
|
261
|
+
OUTPUT (must match output_schema):
|
|
262
|
+
Tasks 1-3:
|
|
263
|
+
{
|
|
264
|
+
"id": "<your row id>",
|
|
265
|
+
"result_status": "completed" | "failed",
|
|
266
|
+
"result_findings": "<JSON payload to merge into doc-index.json section>",
|
|
267
|
+
"error": "<message if failed, else empty>"
|
|
268
|
+
}
|
|
269
|
+
Tasks 4-5:
|
|
270
|
+
{
|
|
271
|
+
"id": "<your row id>",
|
|
272
|
+
"result_status": "completed" | "failed",
|
|
273
|
+
"result_findings": "<count + semicolon-separated absolute paths of files written>",
|
|
274
|
+
"error": "<message if failed, else empty>"
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
CONSTRAINTS:
|
|
278
|
+
- Do NOT write to tasks.csv, wave-*.csv, results.csv, doc-index.json (orchestrator assembles in Phase 3).
|
|
279
|
+
- Do NOT call spawn_agents_on_csv (no recursion).
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Phase 3: Results -> .workflow/codebase/
|
|
283
|
+
|
|
284
|
+
**Objective**: Assemble doc-index.json from agent findings, validate, update state.
|
|
285
|
+
|
|
286
|
+
Export master `tasks.csv` as `results.csv`.
|
|
287
|
+
|
|
288
|
+
**Assemble doc-index.json** by merging findings from tasks 1-3 (Component Scanner, Feature Mapper, Requirement Linker):
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"version": "1.0",
|
|
292
|
+
"schema_version": "1.0",
|
|
293
|
+
"project": "<project name>",
|
|
294
|
+
"last_updated": "<ISO>",
|
|
295
|
+
"features": [],
|
|
296
|
+
"components": [],
|
|
297
|
+
"requirements": [],
|
|
298
|
+
"architecture_decisions": [],
|
|
299
|
+
"actions": []
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
- Write to `.workflow/codebase/doc-index.json`
|
|
303
|
+
|
|
304
|
+
**Validate output files**: doc-index.json (valid JSON), tech-registry/_index.md, feature-maps/_index.md — log warnings for missing.
|
|
305
|
+
|
|
306
|
+
**Update state.json**: Set `codebase.last_rebuild` timestamp.
|
|
307
|
+
|
|
308
|
+
**Generate context.md**:
|
|
309
|
+
|
|
310
|
+
```markdown
|
|
311
|
+
# Codebase Rebuild Report
|
|
312
|
+
|
|
313
|
+
## Summary
|
|
314
|
+
- Components discovered: {count}
|
|
315
|
+
- Features mapped: {count}
|
|
316
|
+
- Requirements linked: {count}
|
|
317
|
+
- ADRs recorded: {count}
|
|
318
|
+
- Files generated: {count}
|
|
319
|
+
- Generators: {completed}/{total} succeeded
|
|
320
|
+
|
|
321
|
+
## Generator Results
|
|
322
|
+
| Generator | Status | Output | Findings |
|
|
323
|
+
|-----------|--------|--------|----------|
|
|
324
|
+
| Component Scanner | {status} | {count} components | {summary} |
|
|
325
|
+
| Feature Mapper | {status} | {count} features | {summary} |
|
|
326
|
+
| Requirement Linker | {status} | {count} requirements | {summary} |
|
|
327
|
+
| Tech Registry Writer | {status} | {count} files | {summary} |
|
|
328
|
+
| Feature Map Writer | {status} | {count} files | {summary} |
|
|
329
|
+
|
|
330
|
+
## Discovery Board Summary
|
|
331
|
+
{aggregated discovery findings}
|
|
332
|
+
|
|
333
|
+
## Next Steps
|
|
334
|
+
- Run manage-status to review
|
|
335
|
+
- Run manage-codebase-refresh for future incremental updates
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Auto-commit** (unless --skip-commit): Stage `.workflow/codebase/` files, commit "docs(codebase): full rebuild of codebase documentation".
|
|
339
|
+
|
|
340
|
+
**Display completion report**:
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
=== CODEBASE REBUILD COMPLETE ===
|
|
344
|
+
Components: {count}
|
|
345
|
+
Features: {count}
|
|
346
|
+
Requirements: {count}
|
|
347
|
+
ADRs: {count}
|
|
348
|
+
Files: {count} generated in .workflow/codebase/
|
|
349
|
+
|
|
350
|
+
Generators: {completed}/{total} succeeded
|
|
351
|
+
{if failures: "W001: {failed_generator} failed -- partial results available"}
|
|
352
|
+
|
|
353
|
+
Next steps:
|
|
354
|
+
$manage-status
|
|
355
|
+
$manage-codebase-refresh
|
|
356
|
+
maestro kg stats # verify KG
|
|
357
|
+
maestro search "kg" --type knowhow # verify wiki integration
|
|
358
|
+
maestro kg diff-wiki # future change impact
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Shared Discovery Board Protocol
|
|
362
|
+
|
|
363
|
+
#### Standard Discovery Types
|
|
364
|
+
|
|
365
|
+
| Type | Dedup Key | Data Schema | Description |
|
|
366
|
+
|------|-----------|-------------|-------------|
|
|
367
|
+
| `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack identified |
|
|
368
|
+
| `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
|
|
369
|
+
| `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
|
|
370
|
+
| `convention` | singleton | `{naming, imports, formatting}` | Project coding conventions |
|
|
371
|
+
|
|
372
|
+
#### Domain Discovery Types
|
|
373
|
+
|
|
374
|
+
| Type | Dedup Key | Data Schema | Description |
|
|
375
|
+
|------|-----------|-------------|-------------|
|
|
376
|
+
| `component` | `data.id` | `{id, name, type, code_locations[]}` | Component discovered by scanner |
|
|
377
|
+
| `feature_group` | `data.name` | `{name, component_ids[], directory}` | Feature grouping identified |
|
|
378
|
+
|
|
379
|
+
#### Protocol
|
|
380
|
+
|
|
381
|
+
Read `{session_folder}/discoveries.ndjson` before own analysis. Deduplicate by type + dedup key before writing. Append-only — never modify or delete. Generators share discoveries to skip redundant scanning.
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
echo '{"ts":"<ISO>","worker":"1","type":"tech_stack","data":{"framework":"Express","language":"TypeScript","tools":["jest","eslint","prettier"]}}' >> {session_folder}/discoveries.ndjson
|
|
385
|
+
```
|
|
386
|
+
</execution>
|
|
387
|
+
|
|
388
|
+
<error_codes>
|
|
389
|
+
| Error | Resolution |
|
|
390
|
+
|-------|------------|
|
|
391
|
+
| .workflow/ not initialized | Abort: "Run init first" (E001) |
|
|
392
|
+
| No source directories found | Abort: "No source files in project" |
|
|
393
|
+
| .workflow/codebase/ exists without --force | Prompt user for confirmation |
|
|
394
|
+
| Generator agent timeout | Mark as failed, continue with other generators |
|
|
395
|
+
| Generator agent failed | Mark as failed, log W001, output partial results |
|
|
396
|
+
| doc-index.json assembly fails | Use available generator outputs, log missing sections |
|
|
397
|
+
| CSV parse error | Validate format, show line number |
|
|
398
|
+
| discoveries.ndjson corrupt | Ignore malformed lines |
|
|
399
|
+
| Continue mode: no session found | List available sessions |
|
|
400
|
+
</error_codes>
|
|
401
|
+
|
|
402
|
+
<success_criteria>
|
|
403
|
+
- [ ] Session initialized with tasks.csv
|
|
404
|
+
- [ ] .workflow/codebase/ cleared (if --force or confirmed)
|
|
405
|
+
- [ ] All 5 doc generators executed via spawn_agents_on_csv
|
|
406
|
+
- [ ] doc-index.json assembled from generator findings
|
|
407
|
+
- [ ] tech-registry/ and feature-maps/ populated with markdown docs
|
|
408
|
+
- [ ] state.json updated with rebuild timestamp
|
|
409
|
+
- [ ] context.md generated with rebuild report
|
|
410
|
+
- [ ] Auto-commit performed (unless --skip-commit)
|
|
411
|
+
- [ ] Completion report displayed with counts and next steps
|
|
412
|
+
</success_criteria>
|