maestro-flow 0.3.42 → 0.3.44
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/.claude/commands/learn-decompose.md +10 -15
- package/.claude/commands/learn-follow.md +11 -16
- package/.claude/commands/learn-investigate.md +18 -22
- package/.claude/commands/learn-retro.md +23 -26
- package/.claude/commands/learn-second-opinion.md +11 -16
- package/.claude/commands/maestro-analyze.md +8 -0
- package/.claude/commands/maestro-brainstorm.md +8 -0
- package/.claude/commands/maestro-execute.md +11 -3
- package/.claude/commands/maestro-learn.md +4 -4
- package/.claude/commands/maestro-milestone-complete.md +6 -6
- package/.claude/commands/maestro-plan.md +8 -0
- package/.claude/commands/maestro-ralph-execute.md +52 -80
- package/.claude/commands/maestro-ralph.md +2 -2
- package/.claude/commands/maestro-tools-execute.md +117 -0
- package/.claude/commands/maestro-tools-register.md +137 -0
- package/.claude/commands/maestro-ui-codify.md +67 -0
- package/.claude/commands/manage-harvest.md +1 -1
- package/.claude/commands/manage-learn.md +5 -7
- package/.claude/commands/manage-wiki.md +1 -1
- package/.claude/commands/quality-auto-test.md +1 -1
- package/.claude/commands/quality-debug.md +8 -0
- package/.claude/commands/quality-retrospective.md +4 -5
- package/.claude/commands/quality-review.md +8 -0
- package/.claude/commands/spec-add.md +25 -4
- package/.claude/commands/spec-load.md +26 -6
- package/.claude/commands/spec-setup.md +2 -2
- package/.claude/commands/wiki-connect.md +1 -1
- package/.claude/commands/wiki-digest.md +5 -6
- package/.claude/skills/codify-to-knowhow/SKILL.md +167 -0
- package/.claude/skills/codify-to-knowhow/phases/01-load-manifest.md +101 -0
- package/.claude/skills/codify-to-knowhow/phases/02-generate-knowhow.md +97 -0
- package/.claude/skills/codify-to-knowhow/phases/03-generate-specs.md +92 -0
- package/.claude/skills/codify-to-knowhow/phases/04-index-verify.md +119 -0
- package/.codex/skills/codify-to-knowhow/SKILL.md +427 -0
- package/.codex/skills/learn-decompose/SKILL.md +8 -8
- package/.codex/skills/learn-follow/SKILL.md +6 -6
- package/.codex/skills/learn-investigate/SKILL.md +4 -4
- package/.codex/skills/learn-retro/SKILL.md +7 -7
- package/.codex/skills/learn-second-opinion/SKILL.md +6 -6
- package/.codex/skills/maestro-analyze/SKILL.md +491 -491
- package/.codex/skills/maestro-collab/SKILL.md +1 -1
- package/.codex/skills/maestro-learn/SKILL.md +1 -1
- package/.codex/skills/maestro-milestone-complete/SKILL.md +122 -122
- package/.codex/skills/maestro-plan/SKILL.md +485 -485
- package/.codex/skills/maestro-tools-execute/SKILL.md +105 -0
- package/.codex/skills/maestro-tools-register/SKILL.md +144 -0
- package/.codex/skills/maestro-ui-codify/SKILL.md +398 -0
- package/.codex/skills/maestro-verify/SKILL.md +486 -486
- package/.codex/skills/manage-harvest/SKILL.md +3 -3
- package/.codex/skills/manage-issue-discover/SKILL.md +431 -431
- package/.codex/skills/manage-learn/SKILL.md +13 -13
- package/.codex/skills/manage-wiki/SKILL.md +1 -1
- package/.codex/skills/quality-auto-test/SKILL.md +553 -553
- package/.codex/skills/quality-refactor/SKILL.md +151 -151
- package/.codex/skills/quality-retrospective/SKILL.md +6 -6
- package/.codex/skills/spec-add/SKILL.md +17 -4
- package/.codex/skills/spec-load/SKILL.md +24 -28
- package/.codex/skills/team-quality-assurance/roles/executor/role.md +1 -1
- package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
- package/.codex/skills/team-tech-debt/roles/scanner/role.md +1 -1
- package/.codex/skills/team-testing/roles/executor/role.md +1 -1
- package/.codex/skills/team-testing/roles/generator/role.md +1 -1
- package/.codex/skills/wiki-connect/SKILL.md +5 -5
- package/.codex/skills/wiki-digest/SKILL.md +8 -8
- package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -2
- package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/routes/specs.js +1 -1
- package/dashboard/dist-server/dashboard/src/server/routes/specs.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/routes/wiki.js +2 -1
- package/dashboard/dist-server/dashboard/src/server/routes/wiki.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js +2 -2
- package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.d.ts +1 -1
- package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js +1 -1
- package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/search.js +2 -2
- package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.d.ts +7 -3
- package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js +47 -15
- package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +1 -2
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +3 -52
- package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +67 -21
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-types.d.ts +6 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js +1 -11
- package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/writer.d.ts +7 -4
- package/dashboard/dist-server/dashboard/src/server/wiki/writer.js +27 -12
- package/dashboard/dist-server/dashboard/src/server/wiki/writer.js.map +1 -1
- package/dashboard/dist-server/src/tools/spec-entry-parser.d.ts +10 -2
- package/dashboard/dist-server/src/tools/spec-entry-parser.js +46 -12
- package/dashboard/dist-server/src/tools/spec-entry-parser.js.map +1 -1
- package/dashboard/dist-server/src/tools/spec-loader.d.ts +6 -2
- package/dashboard/dist-server/src/tools/spec-loader.js +119 -23
- package/dashboard/dist-server/src/tools/spec-loader.js.map +1 -1
- package/dist/src/commands/knowhow.d.ts.map +1 -1
- package/dist/src/commands/knowhow.js +21 -2
- package/dist/src/commands/knowhow.js.map +1 -1
- package/dist/src/commands/spec.d.ts +1 -1
- package/dist/src/commands/spec.d.ts.map +1 -1
- package/dist/src/commands/spec.js +78 -4
- package/dist/src/commands/spec.js.map +1 -1
- package/dist/src/commands/wiki.d.ts.map +1 -1
- package/dist/src/commands/wiki.js +51 -3
- package/dist/src/commands/wiki.js.map +1 -1
- package/dist/src/hooks/keyword-spec-injector.js +1 -1
- package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
- package/dist/src/hooks/plugins/spec-injection-plugin.js +11 -11
- package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
- package/dist/src/hooks/spec-injector.d.ts +1 -0
- package/dist/src/hooks/spec-injector.d.ts.map +1 -1
- package/dist/src/hooks/spec-injector.js +55 -22
- package/dist/src/hooks/spec-injector.js.map +1 -1
- package/dist/src/hooks/wiki-role-loader.d.ts +18 -0
- package/dist/src/hooks/wiki-role-loader.d.ts.map +1 -0
- package/dist/src/hooks/wiki-role-loader.js +43 -0
- package/dist/src/hooks/wiki-role-loader.js.map +1 -0
- package/dist/src/tools/spec-entry-parser.d.ts +10 -2
- package/dist/src/tools/spec-entry-parser.d.ts.map +1 -1
- package/dist/src/tools/spec-entry-parser.js +46 -12
- package/dist/src/tools/spec-entry-parser.js.map +1 -1
- package/dist/src/tools/spec-init.d.ts.map +1 -1
- package/dist/src/tools/spec-init.js +19 -0
- package/dist/src/tools/spec-init.js.map +1 -1
- package/dist/src/tools/spec-loader.d.ts +6 -2
- package/dist/src/tools/spec-loader.d.ts.map +1 -1
- package/dist/src/tools/spec-loader.js +119 -23
- package/dist/src/tools/spec-loader.js.map +1 -1
- package/dist/src/tools/spec-writer.d.ts +6 -1
- package/dist/src/tools/spec-writer.d.ts.map +1 -1
- package/dist/src/tools/spec-writer.js +29 -2
- package/dist/src/tools/spec-writer.js.map +1 -1
- package/dist/src/tools/store-knowhow.d.ts.map +1 -1
- package/dist/src/tools/store-knowhow.js +56 -27
- package/dist/src/tools/store-knowhow.js.map +1 -1
- package/package.json +1 -1
- package/workflows/analyze.md +2 -2
- package/workflows/auto-test.md +2 -2
- package/workflows/brainstorm.md +1 -1
- package/workflows/codebase-rebuild.md +1 -1
- package/workflows/codebase-refresh.md +1 -1
- package/workflows/debug.md +1 -1
- package/workflows/execute.md +3 -3
- package/workflows/harvest.md +13 -13
- package/workflows/integration-test.md +2 -2
- package/workflows/issue-discover.md +1 -1
- package/workflows/knowhow.md +72 -11
- package/workflows/learn.md +70 -58
- package/workflows/map.md +1 -1
- package/workflows/milestone-complete.md +2 -2
- package/workflows/plan.md +1 -1
- package/workflows/quick.md +1 -1
- package/workflows/refactor.md +1 -1
- package/workflows/retrospective.md +51 -57
- package/workflows/review.md +1 -1
- package/workflows/roadmap-common.md +1 -1
- package/workflows/specs-add.md +11 -2
- package/workflows/specs-load.md +17 -15
- package/workflows/test-gen.md +1 -1
- package/workflows/tools-spec.md +98 -0
- package/workflows/ui-codify-extract.md +373 -0
- package/workflows/ui-codify-knowhow.md +258 -0
- package/workflows/ui-codify-package.md +161 -0
- package/workflows/ui-codify.md +225 -0
- package/workflows/verify.md +1 -1
- package/workflows/wiki-connect.md +7 -7
- package/workflows/wiki-digest.md +13 -13
- package/workflows/wiki-manage.md +1 -1
|
@@ -1,485 +1,485 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: maestro-plan
|
|
3
|
-
description: Plan phase execution with exploration and verification
|
|
4
|
-
argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--dir <path>] [--gaps] [--spec SPEC-xxx] [--collab]\""
|
|
5
|
-
allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<purpose>
|
|
9
|
-
Wave-based planning using `spawn_agents_on_csv`. Wave 1 explores codebase context in parallel across multiple angles, Wave 2 consumes all exploration findings to generate a verified execution plan.
|
|
10
|
-
|
|
11
|
-
**Core workflow**: Resolve Phase -> Determine Explorations -> Parallel Exploration -> Sequential Planning -> Check + Confirm
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
+---------------------------------------------------------------------------+
|
|
15
|
-
| PLAN CSV WAVE WORKFLOW |
|
|
16
|
-
+---------------------------------------------------------------------------+
|
|
17
|
-
| |
|
|
18
|
-
| Phase 1: Phase Resolution -> CSV |
|
|
19
|
-
| +-- Resolve phase directory from arguments (or --dir) |
|
|
20
|
-
| +-- Load context.md, index.json, spec-ref, codebase docs |
|
|
21
|
-
| +-- Check for upstream analysis (conclusions.json) |
|
|
22
|
-
| +-- If --gaps: load gaps from issues/verification/uat |
|
|
23
|
-
| +-- Determine exploration angles (architecture, implementation, etc.) |
|
|
24
|
-
| +-- Generate tasks.csv with one row per exploration + planning row |
|
|
25
|
-
| +-- User validates exploration breakdown (skip if -y) |
|
|
26
|
-
| |
|
|
27
|
-
| Phase 2: Wave Execution Engine |
|
|
28
|
-
| +-- Wave 1: Codebase Exploration (parallel) |
|
|
29
|
-
| | +-- Each agent explores one angle of the codebase |
|
|
30
|
-
| | +-- Agent reads files, discovers patterns, maps dependencies |
|
|
31
|
-
| | +-- Discoveries shared via board (patterns, conventions, risks) |
|
|
32
|
-
| | +-- Results: findings per exploration angle |
|
|
33
|
-
| +-- Wave 2: Plan Generation (sequential) |
|
|
34
|
-
| | +-- Single planning agent consumes all exploration findings |
|
|
35
|
-
| | +-- Generates plan.json with waves, dependencies, estimates |
|
|
36
|
-
| | +-- Generates .task/TASK-*.json for each task |
|
|
37
|
-
| | +-- Applies Deep Work Rules (read_first, convergence.criteria) |
|
|
38
|
-
| | +-- Results: plan.json path + task count |
|
|
39
|
-
| +-- discoveries.ndjson shared across all waves (append-only) |
|
|
40
|
-
| |
|
|
41
|
-
| Phase 3: Plan Checking + Confirmation |
|
|
42
|
-
| +-- Validate plan quality (coverage, feasibility, deps, criteria) |
|
|
43
|
-
| +-- Revision loop (max 3 rounds) if critical issues found |
|
|
44
|
-
| +-- Update index.json with plan metadata |
|
|
45
|
-
| +-- Display plan summary + options (execute/modify/view) |
|
|
46
|
-
| |
|
|
47
|
-
+---------------------------------------------------------------------------+
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
</purpose>
|
|
51
|
-
|
|
52
|
-
<context>
|
|
53
|
-
```bash
|
|
54
|
-
$maestro-plan "3"
|
|
55
|
-
$maestro-plan -y "3"
|
|
56
|
-
$maestro-plan -c 4 "3 --spec SPEC-001"
|
|
57
|
-
$maestro-plan "3 --gaps"
|
|
58
|
-
$maestro-plan "3 --dir .workflow/scratch/quick-nav-fix"
|
|
59
|
-
$maestro-plan --continue "20260318-plan-P3-auth"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Flags**:
|
|
63
|
-
- `-y, --yes`: Skip all confirmations (auto mode)
|
|
64
|
-
- `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
|
|
65
|
-
- `--continue`: Resume existing session
|
|
66
|
-
|
|
67
|
-
When `--yes` or `-y`: Auto-confirm exploration angles, skip interactive clarification (P2), use defaults for complexity detection.
|
|
68
|
-
|
|
69
|
-
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
70
|
-
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `plan.json` + `.task/TASK-*.json`
|
|
71
|
-
</context>
|
|
72
|
-
|
|
73
|
-
<csv_schema>
|
|
74
|
-
|
|
75
|
-
### tasks.csv (Master State)
|
|
76
|
-
|
|
77
|
-
```csv
|
|
78
|
-
id,title,description,exploration_focus,deps,context_from,wave,status,findings,error
|
|
79
|
-
"E1","Architecture Exploration","Explore how the target feature fits into existing architecture. Map module boundaries, dependency graph, and integration points. Identify existing patterns that should be followed.","architecture","","","1","","",""
|
|
80
|
-
"E2","Implementation Exploration","Explore implementation patterns: libraries in use, coding conventions, error handling patterns, type definitions. Find 3+ similar features as reference.","implementation","","","1","","",""
|
|
81
|
-
"E3","Integration Exploration","Explore integration points: what existing code needs modification, API contracts, shared state, event flows. Map all touch points.","integration","","","1","","",""
|
|
82
|
-
"E4","Risk Exploration","Explore risks: what could go wrong, backward compatibility concerns, performance implications, security surface changes, test coverage gaps.","risk","","","1","","",""
|
|
83
|
-
"P1","Plan Generation","Consume all exploration findings. Decompose phase goal into concrete tasks with waves, dependencies, convergence criteria. Generate plan.json + TASK-*.json files following Deep Work Rules.","planning","E1;E2;E3;E4","E1;E2;E3;E4","2","","",""
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**Columns**:
|
|
87
|
-
|
|
88
|
-
| Column | Phase | Description |
|
|
89
|
-
|--------|-------|-------------|
|
|
90
|
-
| `id` | Input | Unique task identifier: `E{N}` for explorations (wave 1), `P1` for planning (wave 2) |
|
|
91
|
-
| `title` | Input | Short exploration or planning title |
|
|
92
|
-
| `description` | Input | Detailed exploration/planning instructions |
|
|
93
|
-
| `exploration_focus` | Input | Focus area: architecture/implementation/integration/risk/planning |
|
|
94
|
-
| `deps` | Input | Semicolon-separated dependency task IDs |
|
|
95
|
-
| `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
|
|
96
|
-
| `wave` | Computed | Wave number (1 = exploration, 2 = plan generation) |
|
|
97
|
-
| `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
|
|
98
|
-
| `findings` | Output | Key findings summary (max 500 chars) |
|
|
99
|
-
| `error` | Output | Error message if failed |
|
|
100
|
-
|
|
101
|
-
### Per-Wave CSV (Temporary)
|
|
102
|
-
|
|
103
|
-
Each wave generates `wave-{N}.csv` with extra `prev_context` column.
|
|
104
|
-
|
|
105
|
-
### Output Artifacts
|
|
106
|
-
|
|
107
|
-
| File | Purpose | Lifecycle |
|
|
108
|
-
|------|---------|-----------|
|
|
109
|
-
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
|
|
110
|
-
| `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
|
|
111
|
-
| `results.csv` | Final export of all task results | Created in Phase 3 |
|
|
112
|
-
| `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
|
|
113
|
-
| `context.md` | Human-readable planning report | Created in Phase 3 |
|
|
114
|
-
| `plan.json` | Execution plan (in phase directory) | Created by wave 2 agent |
|
|
115
|
-
| `.task/TASK-*.json` | Individual task definitions (in phase directory) | Created by wave 2 agent |
|
|
116
|
-
|
|
117
|
-
### Session Structure
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
.workflow/.csv-wave/{YYYYMMDD}-plan-P{N}-{slug}/
|
|
121
|
-
+-- tasks.csv
|
|
122
|
-
+-- results.csv
|
|
123
|
-
+-- discoveries.ndjson
|
|
124
|
-
+-- context.md
|
|
125
|
-
+-- wave-{N}.csv (temporary)
|
|
126
|
-
```
|
|
127
|
-
</csv_schema>
|
|
128
|
-
|
|
129
|
-
<invariants>
|
|
130
|
-
1. **Start Immediately**: First action is session initialization, then Phase 1
|
|
131
|
-
2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
|
|
132
|
-
3. **CSV is Source of Truth**: Master tasks.csv holds all state
|
|
133
|
-
4. **Context Propagation**: prev_context built from master CSV, not from memory
|
|
134
|
-
5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
|
|
135
|
-
6. **Skip on Failure**: If all exploration agents failed, planning agent proceeds with available context
|
|
136
|
-
7. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
|
|
137
|
-
8. **DO NOT STOP**: Continuous execution until all waves complete
|
|
138
|
-
</invariants>
|
|
139
|
-
|
|
140
|
-
<execution>
|
|
141
|
-
|
|
142
|
-
### Session Initialization
|
|
143
|
-
|
|
144
|
-
```javascript
|
|
145
|
-
// Parse from $ARGUMENTS:
|
|
146
|
-
// AUTO_YES <- --yes | -y
|
|
147
|
-
// continueMode <- --continue
|
|
148
|
-
// maxConcurrency <- --concurrency N | -c N (default: 4)
|
|
149
|
-
// autoMode <- --auto
|
|
150
|
-
// gapsMode <- --gaps
|
|
151
|
-
// dirMatch <- --dir <path>
|
|
152
|
-
// specMatch <- --spec SPEC-xxx
|
|
153
|
-
// collabMode <- --collab
|
|
154
|
-
// phaseArg <- remaining text after stripping all flags
|
|
155
|
-
|
|
156
|
-
// Auto-bootstrap .workflow/state.json if missing
|
|
157
|
-
|
|
158
|
-
// Scope determination from state.json (priority order):
|
|
159
|
-
// --dir given → scope from parent artifact or 'standalone'
|
|
160
|
-
// phaseArg empty → 'milestone' (requires current_milestone + roadmap.md) or ERROR E001
|
|
161
|
-
// phaseArg is digit → 'phase', resolve slug from roadmap, find latest completed analyze artifact
|
|
162
|
-
// phaseArg is text → 'adhoc' (if milestone active) or 'standalone', slugify phaseArg
|
|
163
|
-
|
|
164
|
-
// Session IDs (UTC+8):
|
|
165
|
-
// sessionId = {YYYYMMDD}-plan-P{phaseArg}-{phaseSlug}
|
|
166
|
-
// sessionFolder = .workflow/.csv-wave/{sessionId}
|
|
167
|
-
// scratchDir = .workflow/scratch/{sessionId}
|
|
168
|
-
|
|
169
|
-
// Create: sessionFolder, scratchDir/.task/
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Session Resume (`--continue`)
|
|
173
|
-
|
|
174
|
-
When `continueMode` is true:
|
|
175
|
-
1. Scan `.workflow/.csv-wave/` for directories matching `*-plan-*`
|
|
176
|
-
2. If `$ARGUMENTS` contains a session ID suffix, match it; otherwise use the most recent session
|
|
177
|
-
3. Read the session's `tasks.csv` to determine resume point:
|
|
178
|
-
- If all wave 1 tasks completed → skip to wave 2
|
|
179
|
-
- If wave 2 completed → skip to Phase 3 (plan checking)
|
|
180
|
-
- If Phase 3 incomplete → re-run plan checking
|
|
181
|
-
4. Re-use existing `sessionFolder` and `scratchDir` (do not create new ones)
|
|
182
|
-
5. Log: "Resuming session {sessionId} — skipping {N} completed tasks"
|
|
183
|
-
|
|
184
|
-
If no matching session found, list available sessions and abort.
|
|
185
|
-
|
|
186
|
-
### Phase 1: Phase Resolution -> CSV
|
|
187
|
-
|
|
188
|
-
**Objective**: Resolve phase, load context, determine exploration angles, generate tasks.csv.
|
|
189
|
-
|
|
190
|
-
**Decomposition Rules**:
|
|
191
|
-
|
|
192
|
-
1. **Scope resolution**: Already determined in Session Initialization (milestone/phase/adhoc/standalone)
|
|
193
|
-
|
|
194
|
-
2. **Context loading** (from upstream analyze artifact or --dir):
|
|
195
|
-
- Read `{contextDir}/context.md` (user decisions from analyze) — if contextDir resolved
|
|
196
|
-
- Read `.workflow/project.md` — project vision and constraints
|
|
197
|
-
- Read `.workflow/roadmap.md` — phase structure and dependencies
|
|
198
|
-
- Read spec-ref if `--spec` flag
|
|
199
|
-
- Read `.workflow/codebase/doc-index.json` if exists
|
|
200
|
-
- Find design artifacts from `state.json.artifacts[]` (type=brainstorm with ui-designer) for MASTER.md
|
|
201
|
-
- Load project specs via `maestro spec load --
|
|
202
|
-
|
|
203
|
-
3. **Upstream analysis check**:
|
|
204
|
-
- If `{contextDir}/conclusions.json` exists and has content: reuse as exploration context, skip wave 1
|
|
205
|
-
- If `{contextDir}/explorations.json` exists: load as additional context
|
|
206
|
-
|
|
207
|
-
4. **Gap mode** (if `--gaps`):
|
|
208
|
-
- Load gaps from `.workflow/issues/issues.jsonl` (primary), `verification.json` (fallback), `uat.md` (additional)
|
|
209
|
-
- Enrich with debug diagnosis from `{PHASE_DIR}/.debug/*/understanding.md`
|
|
210
|
-
- Skip wave 1 exploration, generate gap-fix tasks directly in wave 2
|
|
211
|
-
|
|
212
|
-
5. **Exploration angle determination** (skip if --gaps or upstream analysis loaded):
|
|
213
|
-
|
|
214
|
-
| Angle | Focus | When Included |
|
|
215
|
-
|-------|-------|---------------|
|
|
216
|
-
| architecture | Module boundaries, dependency graph, integration points | Always |
|
|
217
|
-
| implementation | Coding patterns, libraries, conventions, similar features | Always |
|
|
218
|
-
| integration | Existing code modifications, API contracts, shared state | When phase touches existing modules |
|
|
219
|
-
| risk | Backward compatibility, performance, security, test gaps | When phase is complex or critical |
|
|
220
|
-
|
|
221
|
-
6. **CSV generation**: Exploration rows (wave 1) + one planning row (wave 2).
|
|
222
|
-
|
|
223
|
-
**Wave computation**: Simple 2-wave -- all exploration tasks = wave 1, planning task = wave 2.
|
|
224
|
-
|
|
225
|
-
**User validation**: Display exploration breakdown (skip if AUTO_YES or `--auto`).
|
|
226
|
-
|
|
227
|
-
### Pre-flight: Team Conflict Check
|
|
228
|
-
|
|
229
|
-
Before starting the plan pipeline:
|
|
230
|
-
```
|
|
231
|
-
Bash("maestro collab preflight --phase <phase-number>")
|
|
232
|
-
```
|
|
233
|
-
If exit code is 1, present warnings and ask whether to proceed.
|
|
234
|
-
|
|
235
|
-
### Wiki Knowledge Search
|
|
236
|
-
|
|
237
|
-
During context collection, after loading files and before exploration (Wave 1):
|
|
238
|
-
```
|
|
239
|
-
phase_keywords = extract key terms from goal/title (2-5 terms)
|
|
240
|
-
wiki_result = Bash("maestro wiki search ${phase_keywords} --json 2>/dev/null")
|
|
241
|
-
|
|
242
|
-
IF wiki_result exit code != 0 OR empty:
|
|
243
|
-
W003: Wiki search unavailable, continue without prior knowledge
|
|
244
|
-
ELSE:
|
|
245
|
-
entries = JSON.parse(wiki_result).entries (limit to first 10)
|
|
246
|
-
Pass wiki_context to Wave 2 planning agent
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Mode Routing
|
|
250
|
-
|
|
251
|
-
| Mode | Trigger | Behavior |
|
|
252
|
-
|------|---------|----------|
|
|
253
|
-
| Create | Default (no --revise/--check) | Full pipeline: Phase 1 → Wave 1 → Wave 2 → Phase 3 |
|
|
254
|
-
| Revise | `--revise [instructions]` | Load existing plan, apply incremental edits, re-check |
|
|
255
|
-
| Check | `--check <plan-dir>` | Skip exploration/planning, run plan-checker only on existing plan |
|
|
256
|
-
|
|
257
|
-
**Revise mode**: Load plan.json from target dir, apply user instructions (add/remove/edit tasks, adjust waves), re-run plan-checker, update index.json.
|
|
258
|
-
|
|
259
|
-
**Check mode**: Read plan.json + .task/TASK-*.json from `--check` path, validate quality, report issues. No exploration, no generation.
|
|
260
|
-
|
|
261
|
-
### Phase 2: Wave Execution Engine
|
|
262
|
-
|
|
263
|
-
**Objective**: Explore codebase then generate plan via spawn_agents_on_csv.
|
|
264
|
-
|
|
265
|
-
#### Wave 1: Codebase Exploration (Parallel)
|
|
266
|
-
|
|
267
|
-
1. Read master `tasks.csv`
|
|
268
|
-
2. Filter rows where `wave == 1` AND `status == pending`
|
|
269
|
-
3. No prev_context needed (wave 1 has no predecessors)
|
|
270
|
-
4. Write `wave-1.csv`
|
|
271
|
-
5. Execute:
|
|
272
|
-
|
|
273
|
-
```javascript
|
|
274
|
-
spawn_agents_on_csv({
|
|
275
|
-
csv_path: `${sessionFolder}/wave-1.csv`,
|
|
276
|
-
id_column: "id",
|
|
277
|
-
instruction: buildExplorationInstruction(sessionFolder, phaseDir), // agent: ~/.codex/agents/cli-explore-agent.toml
|
|
278
|
-
max_concurrency: maxConcurrency,
|
|
279
|
-
max_runtime_seconds: 3600,
|
|
280
|
-
output_csv_path: `${sessionFolder}/wave-1-results.csv`,
|
|
281
|
-
output_schema: { // required: id, status, findings
|
|
282
|
-
id: "string", status: "completed|failed", findings: "string", error: "string"
|
|
283
|
-
}
|
|
284
|
-
})
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
6. Merge `wave-1-results.csv` into master `tasks.csv`, delete `wave-1.csv`
|
|
288
|
-
|
|
289
|
-
#### Task Count Guard (before Wave 2)
|
|
290
|
-
|
|
291
|
-
Before generating the planning instruction, assess scope complexity and embed expected task count ceiling:
|
|
292
|
-
- Single feature / simple change → expect **1-2 tasks** max
|
|
293
|
-
- Medium feature (multiple files, one module) → expect **2-4 tasks** max
|
|
294
|
-
- Large feature (cross-module) → expect **4-8 tasks** max
|
|
295
|
-
|
|
296
|
-
Include this ceiling in `buildPlanningInstruction`. If the planning agent outputs more tasks than the threshold, re-prompt with explicit instruction to merge.
|
|
297
|
-
|
|
298
|
-
#### Wave 2: Plan Generation (Sequential)
|
|
299
|
-
|
|
300
|
-
1. Read master `tasks.csv`
|
|
301
|
-
2. Filter rows where `wave == 2` AND `status == pending`
|
|
302
|
-
3. Build `prev_context` from wave 1 findings:
|
|
303
|
-
```
|
|
304
|
-
[E1: Architecture Exploration] Module boundaries: auth/ is self-contained, shared/ has...
|
|
305
|
-
[E2: Implementation Exploration] Patterns found: Result type for errors, zod for validation...
|
|
306
|
-
[E3: Integration Exploration] Touch points: routes/index.ts needs new route, middleware/auth.ts...
|
|
307
|
-
[E4: Risk Exploration] Risks: No test coverage for auth refresh flow, potential breaking change...
|
|
308
|
-
```
|
|
309
|
-
4. Write `wave-2.csv` with `prev_context` column
|
|
310
|
-
5. Execute:
|
|
311
|
-
|
|
312
|
-
```javascript
|
|
313
|
-
spawn_agents_on_csv({
|
|
314
|
-
csv_path: `${sessionFolder}/wave-2.csv`,
|
|
315
|
-
id_column: "id",
|
|
316
|
-
instruction: buildPlanningInstruction(sessionFolder, phaseDir, { // agent: ~/.codex/agents/workflow-planner.toml
|
|
317
|
-
contextMd, indexJson, specRef, docIndex, designRef, gapsContext
|
|
318
|
-
}),
|
|
319
|
-
max_concurrency: 1, // Single planning agent
|
|
320
|
-
max_runtime_seconds: 3600,
|
|
321
|
-
output_csv_path: `${sessionFolder}/wave-2-results.csv`,
|
|
322
|
-
output_schema: { // required: id, status, findings
|
|
323
|
-
id: "string", status: "completed|failed", findings: "string", error: "string"
|
|
324
|
-
}
|
|
325
|
-
})
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
6. Merge `wave-2-results.csv` into master `tasks.csv`, delete `wave-2.csv`
|
|
329
|
-
|
|
330
|
-
**Planning agent responsibilities** (embedded in instruction):
|
|
331
|
-
- Group work into feature-level tasks. One feature = one task (even if it touches 3-5 files). Do NOT split a single feature into multiple file-level tasks.
|
|
332
|
-
- Apply Deep Work Rules: `read_first[]` includes modified file + source of truth; `convergence.criteria[]` are grep-verifiable; all actions/steps have concrete values
|
|
333
|
-
- Write `plan.json` to `{PHASE_DIR}/plan.json` and `.task/TASK-{NNN}.json` to `{PHASE_DIR}/.task/`
|
|
334
|
-
- `--gaps`: create fix tasks from gap context, link to issues; `--collab`: pre-allocate ID ranges
|
|
335
|
-
|
|
336
|
-
**Task Grouping Rules (MANDATORY)** — pass to planning agent, re-prompt if violated:
|
|
337
|
-
|
|
338
|
-
1. **Group by feature** — All changes for one feature = one task (even if 3-5 files). Never create separate tasks per file.
|
|
339
|
-
2. **Group by context** — Related functional changes belong together. Don't split just because changes touch different files.
|
|
340
|
-
3. **Minimize agent count** — Group simple unrelated changes into a single "batch" task to reduce overhead. Each agent spawn costs significant tokens.
|
|
341
|
-
4. **Substantial tasks only** — Each task should represent 15-60 minutes of real work. If a task takes <5 minutes, merge it into another.
|
|
342
|
-
5. **True dependencies only** — `depends_on` only when Task B genuinely needs Task A's output (e.g., "Task A defines the interface that Task B implements"). Sequential execution wastes time.
|
|
343
|
-
6. **Prefer parallel** — Most tasks should be independent (no depends_on). Default to parallel waves.
|
|
344
|
-
7. **Complexity-based sizing**:
|
|
345
|
-
- **Low** (single file, single concern, zero cross-module): **1 task**
|
|
346
|
-
- **Medium** (multiple files OR integration point): **1-4 tasks**
|
|
347
|
-
- **High** (cross-module, architectural, new subsystem): **4-10 tasks**
|
|
348
|
-
|
|
349
|
-
**Anti-splitting rules** (re-prompt if violated):
|
|
350
|
-
- One feature = one task (even if 3-5 files); never split a feature into per-file tasks
|
|
351
|
-
- Group simple unrelated changes into a batch task to minimize agent spawns
|
|
352
|
-
- `depends_on` only for genuine output dependencies; most tasks should be parallel
|
|
353
|
-
- Each task must be substantial (15-60 min); sub-5-min changes must be merged
|
|
354
|
-
|
|
355
|
-
### Phase 3: Plan Checking + Confirmation
|
|
356
|
-
|
|
357
|
-
**Objective**: Validate plan quality, revise if needed, present to user.
|
|
358
|
-
|
|
359
|
-
1. **Plan checking** (inline, not a separate wave):
|
|
360
|
-
Read `plan.json` + all `.task/TASK-*.json`. Validate: requirements coverage, file feasibility, dependency correctness (no cycles, valid wave order), grep-verifiable convergence criteria, read_first completeness, action concreteness, no parallel file conflicts, **task count within complexity threshold** (reject over-split plans), **no per-file splitting** (each task must be feature-level).
|
|
361
|
-
|
|
362
|
-
1b. **Plan confidence scoring**:
|
|
363
|
-
|
|
364
|
-
Dimensions (5): requirements_coverage, task_quality, dependency_correctness, estimation_accuracy, collision_safety. Factors (weights): completeness(.30), specificity(.25), structural_validity(.20), user_validation(.15), consistency(.10). Add `confidence` section to `plan.json`.
|
|
365
|
-
|
|
366
|
-
**Readiness gate**: Block if requirements_coverage < 40% or any task missing read_first/convergence.criteria.
|
|
367
|
-
|
|
368
|
-
2. **Revision loop** (max 3 rounds): If critical issues found, regenerate affected tasks.
|
|
369
|
-
|
|
370
|
-
2b. **Spec Enrichment**: Persist cross-task reusable design decisions:
|
|
371
|
-
- `maestro spec add coding|arch "<decision.title>" "<rationale>" --keywords ... --source plan:{sessionId}`
|
|
372
|
-
- Test strategy decisions → `maestro spec add test ...`
|
|
373
|
-
- Typical: 0-3 entries per plan session
|
|
374
|
-
|
|
375
|
-
3. **Export results**:
|
|
376
|
-
- Export `results.csv` from master `tasks.csv`
|
|
377
|
-
- Generate `context.md`: summary (phase, task count, wave count, complexity, exploration count), exploration findings per angle, plan overview (approach, task IDs, waves), next steps
|
|
378
|
-
|
|
379
|
-
4. **Collision detection**: Scan same-milestone plans for overlapping file targets:
|
|
380
|
-
```
|
|
381
|
-
other_plans = state.json.artifacts.filter(a => a.milestone == current && a.type == "plan" && a.id != this)
|
|
382
|
-
For each other_plan: read .task/TASK-*.json, collect files[].path
|
|
383
|
-
collisions = intersection(this_plan_files, other_plan_files)
|
|
384
|
-
If collisions.length > 0: emit W004, display collision table (non-blocking)
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
5. **Update index.json**: set `status: "planning"`, `plan: { task_ids, task_count, complexity, waves }`, `updated_at`
|
|
388
|
-
|
|
389
|
-
6. **Register PLN artifact** in state.json:
|
|
390
|
-
```json
|
|
391
|
-
{ "id": "PLN-NNN", "type": "plan", "milestone": "current", "phase": "target_phase",
|
|
392
|
-
"scope": "phase", "path": "scratch/{YYYYMMDD}-plan-P{N}-{slug}",
|
|
393
|
-
"status": "completed", "depends_on": "anl_art.id || exec_art.id" }
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
7. **Issue linking** (if --gaps):
|
|
397
|
-
For each TASK with `issue_id`: update issue in `issues.jsonl` (`task_refs` += TASK-NNN, `task_plan_dir`, `status: "planned"`, `updated_at`) + append history entry. Ensures bidirectional issue-TASK traceability.
|
|
398
|
-
|
|
399
|
-
8. **Display summary + options** (skip options if AUTO_YES):
|
|
400
|
-
```
|
|
401
|
-
=== PLAN READY ===
|
|
402
|
-
Phase: {phase_name}
|
|
403
|
-
Tasks: {task_count} tasks in {wave_count} waves
|
|
404
|
-
Check: {checker_status} (iteration {check_count}/{max_checks})
|
|
405
|
-
Collision: {collision_status}
|
|
406
|
-
Confidence: {overall}% (weakest: {dim})
|
|
407
|
-
|
|
408
|
-
Next steps:
|
|
409
|
-
$maestro-execute "{phase}" -- Execute the plan
|
|
410
|
-
$maestro-plan "{phase}" -- Re-plan with modifications
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
### Shared Discovery Board Protocol
|
|
414
|
-
|
|
415
|
-
#### Standard Discovery Types
|
|
416
|
-
|
|
417
|
-
| Type | Dedup Key | Data Schema | Description |
|
|
418
|
-
|------|-----------|-------------|-------------|
|
|
419
|
-
| `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
|
|
420
|
-
| `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
|
|
421
|
-
| `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
|
|
422
|
-
| `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
|
|
423
|
-
| `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
|
|
424
|
-
|
|
425
|
-
#### Domain Discovery Types
|
|
426
|
-
|
|
427
|
-
| Type | Dedup Key | Data Schema | Description |
|
|
428
|
-
|------|-----------|-------------|-------------|
|
|
429
|
-
| `existing_pattern` | `data.name` | `{name, file, description, usage}` | Existing feature pattern to follow |
|
|
430
|
-
| `dependency_map` | `data.module` | `{module, imports[], exports[], dependents[]}` | Module dependency mapping |
|
|
431
|
-
| `risk_factor` | `data.risk` | `{risk, severity, mitigation, affected_files[]}` | Identified risk |
|
|
432
|
-
| `test_command` | `data.command` | `{command, scope, framework}` | Test execution command |
|
|
433
|
-
|
|
434
|
-
#### Protocol
|
|
435
|
-
|
|
436
|
-
1. **Read** `{session_folder}/discoveries.ndjson` before own exploration
|
|
437
|
-
2. **Skip covered**: If discovery of same type + dedup key exists, skip
|
|
438
|
-
3. **Write immediately**: Append findings as found
|
|
439
|
-
4. **Append-only**: Never modify or delete
|
|
440
|
-
5. **Deduplicate**: Check before writing
|
|
441
|
-
|
|
442
|
-
```bash
|
|
443
|
-
echo '{"ts":"<ISO>","worker":"{id}","type":"existing_pattern","data":{"name":"Result error handling","file":"src/utils/result.ts","description":"All functions return Result<T,E> instead of throwing","usage":"Used in auth, payments, validation modules"}}' >> {session_folder}/discoveries.ndjson
|
|
444
|
-
```
|
|
445
|
-
</execution>
|
|
446
|
-
|
|
447
|
-
<error_codes>
|
|
448
|
-
|
|
449
|
-
| Error | Resolution |
|
|
450
|
-
|-------|------------|
|
|
451
|
-
| Phase argument required | Abort with error: "Phase argument required" |
|
|
452
|
-
| Phase directory not found | Abort with error: "Phase {N} not found. Run init first." |
|
|
453
|
-
| --gaps requires gaps source | Abort with error: "--gaps requires issues.jsonl, verification.json, or uat.md" |
|
|
454
|
-
| No plan found to revise (--revise) | Use --dir to specify plan, or create plan first |
|
|
455
|
-
| Plan directory not found (--check) | Check path, use --dir |
|
|
456
|
-
| No context.md found | Warn, proceed with exploration only |
|
|
457
|
-
| Wiki search unavailable (W003) | Continue without prior knowledge context |
|
|
458
|
-
| Collision detected (W004) | Review colliding files, confirm or adjust scope |
|
|
459
|
-
| Exploration agent timeout | Mark as failed, continue with available explorations |
|
|
460
|
-
| Planning agent fails | Retry once with simplified context, then abort |
|
|
461
|
-
| Plan produces invalid JSON | Retry once, then abort with error details |
|
|
462
|
-
| Plan-checker exceeds 3 rounds | Accept plan with warnings, note in index.json |
|
|
463
|
-
| CSV parse error | Validate format, show line number |
|
|
464
|
-
| discoveries.ndjson corrupt | Ignore malformed lines |
|
|
465
|
-
| Continue mode: no session found | List available sessions |
|
|
466
|
-
</error_codes>
|
|
467
|
-
|
|
468
|
-
<success_criteria>
|
|
469
|
-
- [ ] Session folder created with valid tasks.csv
|
|
470
|
-
- [ ] All waves executed in order
|
|
471
|
-
- [ ] plan.json produced in phase directory
|
|
472
|
-
- [ ] .task/TASK-*.json files produced for all tasks
|
|
473
|
-
- [ ] Plan passes quality checks (coverage, deps, criteria)
|
|
474
|
-
- [ ] Plan confidence scored with 5-dimension factor model
|
|
475
|
-
- [ ] Readiness gate checked before confirmation
|
|
476
|
-
- [ ] plan.json includes confidence section
|
|
477
|
-
- [ ] Collision detection executed against same-milestone plans
|
|
478
|
-
- [ ] PLN artifact registered in state.json
|
|
479
|
-
- [ ] context.md produced with exploration findings + plan overview
|
|
480
|
-
- [ ] index.json updated with plan metadata
|
|
481
|
-
- [ ] Issues linked bidirectionally (if --gaps mode)
|
|
482
|
-
- [ ] Wiki knowledge integrated (if available)
|
|
483
|
-
- [ ] Team conflict preflight checked
|
|
484
|
-
- [ ] discoveries.ndjson append-only throughout
|
|
485
|
-
</success_criteria>
|
|
1
|
+
---
|
|
2
|
+
name: maestro-plan
|
|
3
|
+
description: Plan phase execution with exploration and verification
|
|
4
|
+
argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--dir <path>] [--gaps] [--spec SPEC-xxx] [--collab]\""
|
|
5
|
+
allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<purpose>
|
|
9
|
+
Wave-based planning using `spawn_agents_on_csv`. Wave 1 explores codebase context in parallel across multiple angles, Wave 2 consumes all exploration findings to generate a verified execution plan.
|
|
10
|
+
|
|
11
|
+
**Core workflow**: Resolve Phase -> Determine Explorations -> Parallel Exploration -> Sequential Planning -> Check + Confirm
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
+---------------------------------------------------------------------------+
|
|
15
|
+
| PLAN CSV WAVE WORKFLOW |
|
|
16
|
+
+---------------------------------------------------------------------------+
|
|
17
|
+
| |
|
|
18
|
+
| Phase 1: Phase Resolution -> CSV |
|
|
19
|
+
| +-- Resolve phase directory from arguments (or --dir) |
|
|
20
|
+
| +-- Load context.md, index.json, spec-ref, codebase docs |
|
|
21
|
+
| +-- Check for upstream analysis (conclusions.json) |
|
|
22
|
+
| +-- If --gaps: load gaps from issues/verification/uat |
|
|
23
|
+
| +-- Determine exploration angles (architecture, implementation, etc.) |
|
|
24
|
+
| +-- Generate tasks.csv with one row per exploration + planning row |
|
|
25
|
+
| +-- User validates exploration breakdown (skip if -y) |
|
|
26
|
+
| |
|
|
27
|
+
| Phase 2: Wave Execution Engine |
|
|
28
|
+
| +-- Wave 1: Codebase Exploration (parallel) |
|
|
29
|
+
| | +-- Each agent explores one angle of the codebase |
|
|
30
|
+
| | +-- Agent reads files, discovers patterns, maps dependencies |
|
|
31
|
+
| | +-- Discoveries shared via board (patterns, conventions, risks) |
|
|
32
|
+
| | +-- Results: findings per exploration angle |
|
|
33
|
+
| +-- Wave 2: Plan Generation (sequential) |
|
|
34
|
+
| | +-- Single planning agent consumes all exploration findings |
|
|
35
|
+
| | +-- Generates plan.json with waves, dependencies, estimates |
|
|
36
|
+
| | +-- Generates .task/TASK-*.json for each task |
|
|
37
|
+
| | +-- Applies Deep Work Rules (read_first, convergence.criteria) |
|
|
38
|
+
| | +-- Results: plan.json path + task count |
|
|
39
|
+
| +-- discoveries.ndjson shared across all waves (append-only) |
|
|
40
|
+
| |
|
|
41
|
+
| Phase 3: Plan Checking + Confirmation |
|
|
42
|
+
| +-- Validate plan quality (coverage, feasibility, deps, criteria) |
|
|
43
|
+
| +-- Revision loop (max 3 rounds) if critical issues found |
|
|
44
|
+
| +-- Update index.json with plan metadata |
|
|
45
|
+
| +-- Display plan summary + options (execute/modify/view) |
|
|
46
|
+
| |
|
|
47
|
+
+---------------------------------------------------------------------------+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
</purpose>
|
|
51
|
+
|
|
52
|
+
<context>
|
|
53
|
+
```bash
|
|
54
|
+
$maestro-plan "3"
|
|
55
|
+
$maestro-plan -y "3"
|
|
56
|
+
$maestro-plan -c 4 "3 --spec SPEC-001"
|
|
57
|
+
$maestro-plan "3 --gaps"
|
|
58
|
+
$maestro-plan "3 --dir .workflow/scratch/quick-nav-fix"
|
|
59
|
+
$maestro-plan --continue "20260318-plan-P3-auth"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Flags**:
|
|
63
|
+
- `-y, --yes`: Skip all confirmations (auto mode)
|
|
64
|
+
- `-c, --concurrency N`: Max concurrent agents within each wave (default: 4)
|
|
65
|
+
- `--continue`: Resume existing session
|
|
66
|
+
|
|
67
|
+
When `--yes` or `-y`: Auto-confirm exploration angles, skip interactive clarification (P2), use defaults for complexity detection.
|
|
68
|
+
|
|
69
|
+
**Output Directory**: `.workflow/.csv-wave/{session-id}/`
|
|
70
|
+
**Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `plan.json` + `.task/TASK-*.json`
|
|
71
|
+
</context>
|
|
72
|
+
|
|
73
|
+
<csv_schema>
|
|
74
|
+
|
|
75
|
+
### tasks.csv (Master State)
|
|
76
|
+
|
|
77
|
+
```csv
|
|
78
|
+
id,title,description,exploration_focus,deps,context_from,wave,status,findings,error
|
|
79
|
+
"E1","Architecture Exploration","Explore how the target feature fits into existing architecture. Map module boundaries, dependency graph, and integration points. Identify existing patterns that should be followed.","architecture","","","1","","",""
|
|
80
|
+
"E2","Implementation Exploration","Explore implementation patterns: libraries in use, coding conventions, error handling patterns, type definitions. Find 3+ similar features as reference.","implementation","","","1","","",""
|
|
81
|
+
"E3","Integration Exploration","Explore integration points: what existing code needs modification, API contracts, shared state, event flows. Map all touch points.","integration","","","1","","",""
|
|
82
|
+
"E4","Risk Exploration","Explore risks: what could go wrong, backward compatibility concerns, performance implications, security surface changes, test coverage gaps.","risk","","","1","","",""
|
|
83
|
+
"P1","Plan Generation","Consume all exploration findings. Decompose phase goal into concrete tasks with waves, dependencies, convergence criteria. Generate plan.json + TASK-*.json files following Deep Work Rules.","planning","E1;E2;E3;E4","E1;E2;E3;E4","2","","",""
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Columns**:
|
|
87
|
+
|
|
88
|
+
| Column | Phase | Description |
|
|
89
|
+
|--------|-------|-------------|
|
|
90
|
+
| `id` | Input | Unique task identifier: `E{N}` for explorations (wave 1), `P1` for planning (wave 2) |
|
|
91
|
+
| `title` | Input | Short exploration or planning title |
|
|
92
|
+
| `description` | Input | Detailed exploration/planning instructions |
|
|
93
|
+
| `exploration_focus` | Input | Focus area: architecture/implementation/integration/risk/planning |
|
|
94
|
+
| `deps` | Input | Semicolon-separated dependency task IDs |
|
|
95
|
+
| `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
|
|
96
|
+
| `wave` | Computed | Wave number (1 = exploration, 2 = plan generation) |
|
|
97
|
+
| `status` | Output | `pending` -> `completed` / `failed` / `skipped` |
|
|
98
|
+
| `findings` | Output | Key findings summary (max 500 chars) |
|
|
99
|
+
| `error` | Output | Error message if failed |
|
|
100
|
+
|
|
101
|
+
### Per-Wave CSV (Temporary)
|
|
102
|
+
|
|
103
|
+
Each wave generates `wave-{N}.csv` with extra `prev_context` column.
|
|
104
|
+
|
|
105
|
+
### Output Artifacts
|
|
106
|
+
|
|
107
|
+
| File | Purpose | Lifecycle |
|
|
108
|
+
|------|---------|-----------|
|
|
109
|
+
| `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
|
|
110
|
+
| `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
|
|
111
|
+
| `results.csv` | Final export of all task results | Created in Phase 3 |
|
|
112
|
+
| `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
|
|
113
|
+
| `context.md` | Human-readable planning report | Created in Phase 3 |
|
|
114
|
+
| `plan.json` | Execution plan (in phase directory) | Created by wave 2 agent |
|
|
115
|
+
| `.task/TASK-*.json` | Individual task definitions (in phase directory) | Created by wave 2 agent |
|
|
116
|
+
|
|
117
|
+
### Session Structure
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
.workflow/.csv-wave/{YYYYMMDD}-plan-P{N}-{slug}/
|
|
121
|
+
+-- tasks.csv
|
|
122
|
+
+-- results.csv
|
|
123
|
+
+-- discoveries.ndjson
|
|
124
|
+
+-- context.md
|
|
125
|
+
+-- wave-{N}.csv (temporary)
|
|
126
|
+
```
|
|
127
|
+
</csv_schema>
|
|
128
|
+
|
|
129
|
+
<invariants>
|
|
130
|
+
1. **Start Immediately**: First action is session initialization, then Phase 1
|
|
131
|
+
2. **Wave Order is Sacred**: Never execute wave 2 before wave 1 completes and results are merged
|
|
132
|
+
3. **CSV is Source of Truth**: Master tasks.csv holds all state
|
|
133
|
+
4. **Context Propagation**: prev_context built from master CSV, not from memory
|
|
134
|
+
5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
|
|
135
|
+
6. **Skip on Failure**: If all exploration agents failed, planning agent proceeds with available context
|
|
136
|
+
7. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
|
|
137
|
+
8. **DO NOT STOP**: Continuous execution until all waves complete
|
|
138
|
+
</invariants>
|
|
139
|
+
|
|
140
|
+
<execution>
|
|
141
|
+
|
|
142
|
+
### Session Initialization
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
// Parse from $ARGUMENTS:
|
|
146
|
+
// AUTO_YES <- --yes | -y
|
|
147
|
+
// continueMode <- --continue
|
|
148
|
+
// maxConcurrency <- --concurrency N | -c N (default: 4)
|
|
149
|
+
// autoMode <- --auto
|
|
150
|
+
// gapsMode <- --gaps
|
|
151
|
+
// dirMatch <- --dir <path>
|
|
152
|
+
// specMatch <- --spec SPEC-xxx
|
|
153
|
+
// collabMode <- --collab
|
|
154
|
+
// phaseArg <- remaining text after stripping all flags
|
|
155
|
+
|
|
156
|
+
// Auto-bootstrap .workflow/state.json if missing
|
|
157
|
+
|
|
158
|
+
// Scope determination from state.json (priority order):
|
|
159
|
+
// --dir given → scope from parent artifact or 'standalone'
|
|
160
|
+
// phaseArg empty → 'milestone' (requires current_milestone + roadmap.md) or ERROR E001
|
|
161
|
+
// phaseArg is digit → 'phase', resolve slug from roadmap, find latest completed analyze artifact
|
|
162
|
+
// phaseArg is text → 'adhoc' (if milestone active) or 'standalone', slugify phaseArg
|
|
163
|
+
|
|
164
|
+
// Session IDs (UTC+8):
|
|
165
|
+
// sessionId = {YYYYMMDD}-plan-P{phaseArg}-{phaseSlug}
|
|
166
|
+
// sessionFolder = .workflow/.csv-wave/{sessionId}
|
|
167
|
+
// scratchDir = .workflow/scratch/{sessionId}
|
|
168
|
+
|
|
169
|
+
// Create: sessionFolder, scratchDir/.task/
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Session Resume (`--continue`)
|
|
173
|
+
|
|
174
|
+
When `continueMode` is true:
|
|
175
|
+
1. Scan `.workflow/.csv-wave/` for directories matching `*-plan-*`
|
|
176
|
+
2. If `$ARGUMENTS` contains a session ID suffix, match it; otherwise use the most recent session
|
|
177
|
+
3. Read the session's `tasks.csv` to determine resume point:
|
|
178
|
+
- If all wave 1 tasks completed → skip to wave 2
|
|
179
|
+
- If wave 2 completed → skip to Phase 3 (plan checking)
|
|
180
|
+
- If Phase 3 incomplete → re-run plan checking
|
|
181
|
+
4. Re-use existing `sessionFolder` and `scratchDir` (do not create new ones)
|
|
182
|
+
5. Log: "Resuming session {sessionId} — skipping {N} completed tasks"
|
|
183
|
+
|
|
184
|
+
If no matching session found, list available sessions and abort.
|
|
185
|
+
|
|
186
|
+
### Phase 1: Phase Resolution -> CSV
|
|
187
|
+
|
|
188
|
+
**Objective**: Resolve phase, load context, determine exploration angles, generate tasks.csv.
|
|
189
|
+
|
|
190
|
+
**Decomposition Rules**:
|
|
191
|
+
|
|
192
|
+
1. **Scope resolution**: Already determined in Session Initialization (milestone/phase/adhoc/standalone)
|
|
193
|
+
|
|
194
|
+
2. **Context loading** (from upstream analyze artifact or --dir):
|
|
195
|
+
- Read `{contextDir}/context.md` (user decisions from analyze) — if contextDir resolved
|
|
196
|
+
- Read `.workflow/project.md` — project vision and constraints
|
|
197
|
+
- Read `.workflow/roadmap.md` — phase structure and dependencies
|
|
198
|
+
- Read spec-ref if `--spec` flag
|
|
199
|
+
- Read `.workflow/codebase/doc-index.json` if exists
|
|
200
|
+
- Find design artifacts from `state.json.artifacts[]` (type=brainstorm with ui-designer) for MASTER.md
|
|
201
|
+
- Load project specs via `maestro spec load --role plan`
|
|
202
|
+
|
|
203
|
+
3. **Upstream analysis check**:
|
|
204
|
+
- If `{contextDir}/conclusions.json` exists and has content: reuse as exploration context, skip wave 1
|
|
205
|
+
- If `{contextDir}/explorations.json` exists: load as additional context
|
|
206
|
+
|
|
207
|
+
4. **Gap mode** (if `--gaps`):
|
|
208
|
+
- Load gaps from `.workflow/issues/issues.jsonl` (primary), `verification.json` (fallback), `uat.md` (additional)
|
|
209
|
+
- Enrich with debug diagnosis from `{PHASE_DIR}/.debug/*/understanding.md`
|
|
210
|
+
- Skip wave 1 exploration, generate gap-fix tasks directly in wave 2
|
|
211
|
+
|
|
212
|
+
5. **Exploration angle determination** (skip if --gaps or upstream analysis loaded):
|
|
213
|
+
|
|
214
|
+
| Angle | Focus | When Included |
|
|
215
|
+
|-------|-------|---------------|
|
|
216
|
+
| architecture | Module boundaries, dependency graph, integration points | Always |
|
|
217
|
+
| implementation | Coding patterns, libraries, conventions, similar features | Always |
|
|
218
|
+
| integration | Existing code modifications, API contracts, shared state | When phase touches existing modules |
|
|
219
|
+
| risk | Backward compatibility, performance, security, test gaps | When phase is complex or critical |
|
|
220
|
+
|
|
221
|
+
6. **CSV generation**: Exploration rows (wave 1) + one planning row (wave 2).
|
|
222
|
+
|
|
223
|
+
**Wave computation**: Simple 2-wave -- all exploration tasks = wave 1, planning task = wave 2.
|
|
224
|
+
|
|
225
|
+
**User validation**: Display exploration breakdown (skip if AUTO_YES or `--auto`).
|
|
226
|
+
|
|
227
|
+
### Pre-flight: Team Conflict Check
|
|
228
|
+
|
|
229
|
+
Before starting the plan pipeline:
|
|
230
|
+
```
|
|
231
|
+
Bash("maestro collab preflight --phase <phase-number>")
|
|
232
|
+
```
|
|
233
|
+
If exit code is 1, present warnings and ask whether to proceed.
|
|
234
|
+
|
|
235
|
+
### Wiki Knowledge Search
|
|
236
|
+
|
|
237
|
+
During context collection, after loading files and before exploration (Wave 1):
|
|
238
|
+
```
|
|
239
|
+
phase_keywords = extract key terms from goal/title (2-5 terms)
|
|
240
|
+
wiki_result = Bash("maestro wiki search ${phase_keywords} --json 2>/dev/null")
|
|
241
|
+
|
|
242
|
+
IF wiki_result exit code != 0 OR empty:
|
|
243
|
+
W003: Wiki search unavailable, continue without prior knowledge
|
|
244
|
+
ELSE:
|
|
245
|
+
entries = JSON.parse(wiki_result).entries (limit to first 10)
|
|
246
|
+
Pass wiki_context to Wave 2 planning agent
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Mode Routing
|
|
250
|
+
|
|
251
|
+
| Mode | Trigger | Behavior |
|
|
252
|
+
|------|---------|----------|
|
|
253
|
+
| Create | Default (no --revise/--check) | Full pipeline: Phase 1 → Wave 1 → Wave 2 → Phase 3 |
|
|
254
|
+
| Revise | `--revise [instructions]` | Load existing plan, apply incremental edits, re-check |
|
|
255
|
+
| Check | `--check <plan-dir>` | Skip exploration/planning, run plan-checker only on existing plan |
|
|
256
|
+
|
|
257
|
+
**Revise mode**: Load plan.json from target dir, apply user instructions (add/remove/edit tasks, adjust waves), re-run plan-checker, update index.json.
|
|
258
|
+
|
|
259
|
+
**Check mode**: Read plan.json + .task/TASK-*.json from `--check` path, validate quality, report issues. No exploration, no generation.
|
|
260
|
+
|
|
261
|
+
### Phase 2: Wave Execution Engine
|
|
262
|
+
|
|
263
|
+
**Objective**: Explore codebase then generate plan via spawn_agents_on_csv.
|
|
264
|
+
|
|
265
|
+
#### Wave 1: Codebase Exploration (Parallel)
|
|
266
|
+
|
|
267
|
+
1. Read master `tasks.csv`
|
|
268
|
+
2. Filter rows where `wave == 1` AND `status == pending`
|
|
269
|
+
3. No prev_context needed (wave 1 has no predecessors)
|
|
270
|
+
4. Write `wave-1.csv`
|
|
271
|
+
5. Execute:
|
|
272
|
+
|
|
273
|
+
```javascript
|
|
274
|
+
spawn_agents_on_csv({
|
|
275
|
+
csv_path: `${sessionFolder}/wave-1.csv`,
|
|
276
|
+
id_column: "id",
|
|
277
|
+
instruction: buildExplorationInstruction(sessionFolder, phaseDir), // agent: ~/.codex/agents/cli-explore-agent.toml
|
|
278
|
+
max_concurrency: maxConcurrency,
|
|
279
|
+
max_runtime_seconds: 3600,
|
|
280
|
+
output_csv_path: `${sessionFolder}/wave-1-results.csv`,
|
|
281
|
+
output_schema: { // required: id, status, findings
|
|
282
|
+
id: "string", status: "completed|failed", findings: "string", error: "string"
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
6. Merge `wave-1-results.csv` into master `tasks.csv`, delete `wave-1.csv`
|
|
288
|
+
|
|
289
|
+
#### Task Count Guard (before Wave 2)
|
|
290
|
+
|
|
291
|
+
Before generating the planning instruction, assess scope complexity and embed expected task count ceiling:
|
|
292
|
+
- Single feature / simple change → expect **1-2 tasks** max
|
|
293
|
+
- Medium feature (multiple files, one module) → expect **2-4 tasks** max
|
|
294
|
+
- Large feature (cross-module) → expect **4-8 tasks** max
|
|
295
|
+
|
|
296
|
+
Include this ceiling in `buildPlanningInstruction`. If the planning agent outputs more tasks than the threshold, re-prompt with explicit instruction to merge.
|
|
297
|
+
|
|
298
|
+
#### Wave 2: Plan Generation (Sequential)
|
|
299
|
+
|
|
300
|
+
1. Read master `tasks.csv`
|
|
301
|
+
2. Filter rows where `wave == 2` AND `status == pending`
|
|
302
|
+
3. Build `prev_context` from wave 1 findings:
|
|
303
|
+
```
|
|
304
|
+
[E1: Architecture Exploration] Module boundaries: auth/ is self-contained, shared/ has...
|
|
305
|
+
[E2: Implementation Exploration] Patterns found: Result type for errors, zod for validation...
|
|
306
|
+
[E3: Integration Exploration] Touch points: routes/index.ts needs new route, middleware/auth.ts...
|
|
307
|
+
[E4: Risk Exploration] Risks: No test coverage for auth refresh flow, potential breaking change...
|
|
308
|
+
```
|
|
309
|
+
4. Write `wave-2.csv` with `prev_context` column
|
|
310
|
+
5. Execute:
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
spawn_agents_on_csv({
|
|
314
|
+
csv_path: `${sessionFolder}/wave-2.csv`,
|
|
315
|
+
id_column: "id",
|
|
316
|
+
instruction: buildPlanningInstruction(sessionFolder, phaseDir, { // agent: ~/.codex/agents/workflow-planner.toml
|
|
317
|
+
contextMd, indexJson, specRef, docIndex, designRef, gapsContext
|
|
318
|
+
}),
|
|
319
|
+
max_concurrency: 1, // Single planning agent
|
|
320
|
+
max_runtime_seconds: 3600,
|
|
321
|
+
output_csv_path: `${sessionFolder}/wave-2-results.csv`,
|
|
322
|
+
output_schema: { // required: id, status, findings
|
|
323
|
+
id: "string", status: "completed|failed", findings: "string", error: "string"
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
6. Merge `wave-2-results.csv` into master `tasks.csv`, delete `wave-2.csv`
|
|
329
|
+
|
|
330
|
+
**Planning agent responsibilities** (embedded in instruction):
|
|
331
|
+
- Group work into feature-level tasks. One feature = one task (even if it touches 3-5 files). Do NOT split a single feature into multiple file-level tasks.
|
|
332
|
+
- Apply Deep Work Rules: `read_first[]` includes modified file + source of truth; `convergence.criteria[]` are grep-verifiable; all actions/steps have concrete values
|
|
333
|
+
- Write `plan.json` to `{PHASE_DIR}/plan.json` and `.task/TASK-{NNN}.json` to `{PHASE_DIR}/.task/`
|
|
334
|
+
- `--gaps`: create fix tasks from gap context, link to issues; `--collab`: pre-allocate ID ranges
|
|
335
|
+
|
|
336
|
+
**Task Grouping Rules (MANDATORY)** — pass to planning agent, re-prompt if violated:
|
|
337
|
+
|
|
338
|
+
1. **Group by feature** — All changes for one feature = one task (even if 3-5 files). Never create separate tasks per file.
|
|
339
|
+
2. **Group by context** — Related functional changes belong together. Don't split just because changes touch different files.
|
|
340
|
+
3. **Minimize agent count** — Group simple unrelated changes into a single "batch" task to reduce overhead. Each agent spawn costs significant tokens.
|
|
341
|
+
4. **Substantial tasks only** — Each task should represent 15-60 minutes of real work. If a task takes <5 minutes, merge it into another.
|
|
342
|
+
5. **True dependencies only** — `depends_on` only when Task B genuinely needs Task A's output (e.g., "Task A defines the interface that Task B implements"). Sequential execution wastes time.
|
|
343
|
+
6. **Prefer parallel** — Most tasks should be independent (no depends_on). Default to parallel waves.
|
|
344
|
+
7. **Complexity-based sizing**:
|
|
345
|
+
- **Low** (single file, single concern, zero cross-module): **1 task**
|
|
346
|
+
- **Medium** (multiple files OR integration point): **1-4 tasks**
|
|
347
|
+
- **High** (cross-module, architectural, new subsystem): **4-10 tasks**
|
|
348
|
+
|
|
349
|
+
**Anti-splitting rules** (re-prompt if violated):
|
|
350
|
+
- One feature = one task (even if 3-5 files); never split a feature into per-file tasks
|
|
351
|
+
- Group simple unrelated changes into a batch task to minimize agent spawns
|
|
352
|
+
- `depends_on` only for genuine output dependencies; most tasks should be parallel
|
|
353
|
+
- Each task must be substantial (15-60 min); sub-5-min changes must be merged
|
|
354
|
+
|
|
355
|
+
### Phase 3: Plan Checking + Confirmation
|
|
356
|
+
|
|
357
|
+
**Objective**: Validate plan quality, revise if needed, present to user.
|
|
358
|
+
|
|
359
|
+
1. **Plan checking** (inline, not a separate wave):
|
|
360
|
+
Read `plan.json` + all `.task/TASK-*.json`. Validate: requirements coverage, file feasibility, dependency correctness (no cycles, valid wave order), grep-verifiable convergence criteria, read_first completeness, action concreteness, no parallel file conflicts, **task count within complexity threshold** (reject over-split plans), **no per-file splitting** (each task must be feature-level).
|
|
361
|
+
|
|
362
|
+
1b. **Plan confidence scoring**:
|
|
363
|
+
|
|
364
|
+
Dimensions (5): requirements_coverage, task_quality, dependency_correctness, estimation_accuracy, collision_safety. Factors (weights): completeness(.30), specificity(.25), structural_validity(.20), user_validation(.15), consistency(.10). Add `confidence` section to `plan.json`.
|
|
365
|
+
|
|
366
|
+
**Readiness gate**: Block if requirements_coverage < 40% or any task missing read_first/convergence.criteria.
|
|
367
|
+
|
|
368
|
+
2. **Revision loop** (max 3 rounds): If critical issues found, regenerate affected tasks.
|
|
369
|
+
|
|
370
|
+
2b. **Spec Enrichment**: Persist cross-task reusable design decisions:
|
|
371
|
+
- `maestro spec add coding|arch "<decision.title>" "<rationale>" --keywords ... --source plan:{sessionId}`
|
|
372
|
+
- Test strategy decisions → `maestro spec add test ...`
|
|
373
|
+
- Typical: 0-3 entries per plan session
|
|
374
|
+
|
|
375
|
+
3. **Export results**:
|
|
376
|
+
- Export `results.csv` from master `tasks.csv`
|
|
377
|
+
- Generate `context.md`: summary (phase, task count, wave count, complexity, exploration count), exploration findings per angle, plan overview (approach, task IDs, waves), next steps
|
|
378
|
+
|
|
379
|
+
4. **Collision detection**: Scan same-milestone plans for overlapping file targets:
|
|
380
|
+
```
|
|
381
|
+
other_plans = state.json.artifacts.filter(a => a.milestone == current && a.type == "plan" && a.id != this)
|
|
382
|
+
For each other_plan: read .task/TASK-*.json, collect files[].path
|
|
383
|
+
collisions = intersection(this_plan_files, other_plan_files)
|
|
384
|
+
If collisions.length > 0: emit W004, display collision table (non-blocking)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
5. **Update index.json**: set `status: "planning"`, `plan: { task_ids, task_count, complexity, waves }`, `updated_at`
|
|
388
|
+
|
|
389
|
+
6. **Register PLN artifact** in state.json:
|
|
390
|
+
```json
|
|
391
|
+
{ "id": "PLN-NNN", "type": "plan", "milestone": "current", "phase": "target_phase",
|
|
392
|
+
"scope": "phase", "path": "scratch/{YYYYMMDD}-plan-P{N}-{slug}",
|
|
393
|
+
"status": "completed", "depends_on": "anl_art.id || exec_art.id" }
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
7. **Issue linking** (if --gaps):
|
|
397
|
+
For each TASK with `issue_id`: update issue in `issues.jsonl` (`task_refs` += TASK-NNN, `task_plan_dir`, `status: "planned"`, `updated_at`) + append history entry. Ensures bidirectional issue-TASK traceability.
|
|
398
|
+
|
|
399
|
+
8. **Display summary + options** (skip options if AUTO_YES):
|
|
400
|
+
```
|
|
401
|
+
=== PLAN READY ===
|
|
402
|
+
Phase: {phase_name}
|
|
403
|
+
Tasks: {task_count} tasks in {wave_count} waves
|
|
404
|
+
Check: {checker_status} (iteration {check_count}/{max_checks})
|
|
405
|
+
Collision: {collision_status}
|
|
406
|
+
Confidence: {overall}% (weakest: {dim})
|
|
407
|
+
|
|
408
|
+
Next steps:
|
|
409
|
+
$maestro-execute "{phase}" -- Execute the plan
|
|
410
|
+
$maestro-plan "{phase}" -- Re-plan with modifications
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Shared Discovery Board Protocol
|
|
414
|
+
|
|
415
|
+
#### Standard Discovery Types
|
|
416
|
+
|
|
417
|
+
| Type | Dedup Key | Data Schema | Description |
|
|
418
|
+
|------|-----------|-------------|-------------|
|
|
419
|
+
| `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
|
|
420
|
+
| `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
|
|
421
|
+
| `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
|
|
422
|
+
| `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
|
|
423
|
+
| `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
|
|
424
|
+
|
|
425
|
+
#### Domain Discovery Types
|
|
426
|
+
|
|
427
|
+
| Type | Dedup Key | Data Schema | Description |
|
|
428
|
+
|------|-----------|-------------|-------------|
|
|
429
|
+
| `existing_pattern` | `data.name` | `{name, file, description, usage}` | Existing feature pattern to follow |
|
|
430
|
+
| `dependency_map` | `data.module` | `{module, imports[], exports[], dependents[]}` | Module dependency mapping |
|
|
431
|
+
| `risk_factor` | `data.risk` | `{risk, severity, mitigation, affected_files[]}` | Identified risk |
|
|
432
|
+
| `test_command` | `data.command` | `{command, scope, framework}` | Test execution command |
|
|
433
|
+
|
|
434
|
+
#### Protocol
|
|
435
|
+
|
|
436
|
+
1. **Read** `{session_folder}/discoveries.ndjson` before own exploration
|
|
437
|
+
2. **Skip covered**: If discovery of same type + dedup key exists, skip
|
|
438
|
+
3. **Write immediately**: Append findings as found
|
|
439
|
+
4. **Append-only**: Never modify or delete
|
|
440
|
+
5. **Deduplicate**: Check before writing
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
echo '{"ts":"<ISO>","worker":"{id}","type":"existing_pattern","data":{"name":"Result error handling","file":"src/utils/result.ts","description":"All functions return Result<T,E> instead of throwing","usage":"Used in auth, payments, validation modules"}}' >> {session_folder}/discoveries.ndjson
|
|
444
|
+
```
|
|
445
|
+
</execution>
|
|
446
|
+
|
|
447
|
+
<error_codes>
|
|
448
|
+
|
|
449
|
+
| Error | Resolution |
|
|
450
|
+
|-------|------------|
|
|
451
|
+
| Phase argument required | Abort with error: "Phase argument required" |
|
|
452
|
+
| Phase directory not found | Abort with error: "Phase {N} not found. Run init first." |
|
|
453
|
+
| --gaps requires gaps source | Abort with error: "--gaps requires issues.jsonl, verification.json, or uat.md" |
|
|
454
|
+
| No plan found to revise (--revise) | Use --dir to specify plan, or create plan first |
|
|
455
|
+
| Plan directory not found (--check) | Check path, use --dir |
|
|
456
|
+
| No context.md found | Warn, proceed with exploration only |
|
|
457
|
+
| Wiki search unavailable (W003) | Continue without prior knowledge context |
|
|
458
|
+
| Collision detected (W004) | Review colliding files, confirm or adjust scope |
|
|
459
|
+
| Exploration agent timeout | Mark as failed, continue with available explorations |
|
|
460
|
+
| Planning agent fails | Retry once with simplified context, then abort |
|
|
461
|
+
| Plan produces invalid JSON | Retry once, then abort with error details |
|
|
462
|
+
| Plan-checker exceeds 3 rounds | Accept plan with warnings, note in index.json |
|
|
463
|
+
| CSV parse error | Validate format, show line number |
|
|
464
|
+
| discoveries.ndjson corrupt | Ignore malformed lines |
|
|
465
|
+
| Continue mode: no session found | List available sessions |
|
|
466
|
+
</error_codes>
|
|
467
|
+
|
|
468
|
+
<success_criteria>
|
|
469
|
+
- [ ] Session folder created with valid tasks.csv
|
|
470
|
+
- [ ] All waves executed in order
|
|
471
|
+
- [ ] plan.json produced in phase directory
|
|
472
|
+
- [ ] .task/TASK-*.json files produced for all tasks
|
|
473
|
+
- [ ] Plan passes quality checks (coverage, deps, criteria)
|
|
474
|
+
- [ ] Plan confidence scored with 5-dimension factor model
|
|
475
|
+
- [ ] Readiness gate checked before confirmation
|
|
476
|
+
- [ ] plan.json includes confidence section
|
|
477
|
+
- [ ] Collision detection executed against same-milestone plans
|
|
478
|
+
- [ ] PLN artifact registered in state.json
|
|
479
|
+
- [ ] context.md produced with exploration findings + plan overview
|
|
480
|
+
- [ ] index.json updated with plan metadata
|
|
481
|
+
- [ ] Issues linked bidirectionally (if --gaps mode)
|
|
482
|
+
- [ ] Wiki knowledge integrated (if available)
|
|
483
|
+
- [ ] Team conflict preflight checked
|
|
484
|
+
- [ ] discoveries.ndjson append-only throughout
|
|
485
|
+
</success_criteria>
|