maestro-flow-one 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/maestro-flow.js +730 -0
  4. package/claude/maestro-flow/SKILL.md +239 -0
  5. package/claude/maestro-flow/chains/templates.json +256 -0
  6. package/claude/maestro-flow/commands/learn/decompose.md +176 -0
  7. package/claude/maestro-flow/commands/learn/follow.md +167 -0
  8. package/claude/maestro-flow/commands/learn/investigate.md +221 -0
  9. package/claude/maestro-flow/commands/learn/retro.md +303 -0
  10. package/claude/maestro-flow/commands/learn/second-opinion.md +167 -0
  11. package/claude/maestro-flow/commands/lifecycle/amend.md +300 -0
  12. package/claude/maestro-flow/commands/lifecycle/analyze.md +126 -0
  13. package/claude/maestro-flow/commands/lifecycle/brainstorm.md +100 -0
  14. package/claude/maestro-flow/commands/lifecycle/composer.md +354 -0
  15. package/claude/maestro-flow/commands/lifecycle/execute.md +114 -0
  16. package/claude/maestro-flow/commands/lifecycle/fork.md +86 -0
  17. package/claude/maestro-flow/commands/lifecycle/init.md +78 -0
  18. package/claude/maestro-flow/commands/lifecycle/learn.md +140 -0
  19. package/claude/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  20. package/claude/maestro-flow/commands/lifecycle/merge.md +61 -0
  21. package/claude/maestro-flow/commands/lifecycle/overlay.md +178 -0
  22. package/claude/maestro-flow/commands/lifecycle/plan.md +138 -0
  23. package/claude/maestro-flow/commands/lifecycle/player.md +404 -0
  24. package/claude/maestro-flow/commands/lifecycle/quick.md +56 -0
  25. package/claude/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  26. package/claude/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  27. package/claude/maestro-flow/commands/lifecycle/update.md +176 -0
  28. package/claude/maestro-flow/commands/lifecycle/verify.md +90 -0
  29. package/claude/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  30. package/claude/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  31. package/claude/maestro-flow/commands/manage/harvest.md +94 -0
  32. package/claude/maestro-flow/commands/manage/issue-discover.md +77 -0
  33. package/claude/maestro-flow/commands/manage/issue.md +73 -0
  34. package/claude/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  35. package/claude/maestro-flow/commands/manage/knowhow.md +77 -0
  36. package/claude/maestro-flow/commands/manage/learn.md +67 -0
  37. package/claude/maestro-flow/commands/manage/status.md +51 -0
  38. package/claude/maestro-flow/commands/manage/wiki.md +62 -0
  39. package/claude/maestro-flow/commands/milestone/audit.md +68 -0
  40. package/claude/maestro-flow/commands/milestone/complete.md +75 -0
  41. package/claude/maestro-flow/commands/milestone/release.md +96 -0
  42. package/claude/maestro-flow/commands/quality/auto-test.md +124 -0
  43. package/claude/maestro-flow/commands/quality/debug.md +115 -0
  44. package/claude/maestro-flow/commands/quality/refactor.md +55 -0
  45. package/claude/maestro-flow/commands/quality/retrospective.md +78 -0
  46. package/claude/maestro-flow/commands/quality/review.md +108 -0
  47. package/claude/maestro-flow/commands/quality/sync.md +51 -0
  48. package/claude/maestro-flow/commands/quality/test.md +103 -0
  49. package/claude/maestro-flow/commands/spec/add.md +49 -0
  50. package/claude/maestro-flow/commands/spec/load.md +51 -0
  51. package/claude/maestro-flow/commands/spec/remove.md +51 -0
  52. package/claude/maestro-flow/commands/spec/setup.md +51 -0
  53. package/claude/maestro-flow/commands/wiki/connect.md +62 -0
  54. package/claude/maestro-flow/commands/wiki/digest.md +69 -0
  55. package/codex/maestro-flow/SKILL.md +505 -0
  56. package/codex/maestro-flow/chains/templates.json +256 -0
  57. package/codex/maestro-flow/commands/learn/decompose.md +113 -0
  58. package/codex/maestro-flow/commands/learn/follow.md +83 -0
  59. package/codex/maestro-flow/commands/learn/investigate.md +83 -0
  60. package/codex/maestro-flow/commands/learn/retro.md +83 -0
  61. package/codex/maestro-flow/commands/learn/second-opinion.md +86 -0
  62. package/codex/maestro-flow/commands/lifecycle/amend.md +300 -0
  63. package/codex/maestro-flow/commands/lifecycle/analyze.md +483 -0
  64. package/codex/maestro-flow/commands/lifecycle/brainstorm.md +397 -0
  65. package/codex/maestro-flow/commands/lifecycle/composer.md +213 -0
  66. package/codex/maestro-flow/commands/lifecycle/execute.md +318 -0
  67. package/codex/maestro-flow/commands/lifecycle/fork.md +98 -0
  68. package/codex/maestro-flow/commands/lifecycle/init.md +134 -0
  69. package/codex/maestro-flow/commands/lifecycle/learn.md +80 -0
  70. package/codex/maestro-flow/commands/lifecycle/link-coordinate.md +257 -0
  71. package/codex/maestro-flow/commands/lifecycle/merge.md +69 -0
  72. package/codex/maestro-flow/commands/lifecycle/overlay.md +119 -0
  73. package/codex/maestro-flow/commands/lifecycle/plan.md +460 -0
  74. package/codex/maestro-flow/commands/lifecycle/player.md +323 -0
  75. package/codex/maestro-flow/commands/lifecycle/quick.md +124 -0
  76. package/codex/maestro-flow/commands/lifecycle/roadmap.md +468 -0
  77. package/codex/maestro-flow/commands/lifecycle/ui-design.md +135 -0
  78. package/codex/maestro-flow/commands/lifecycle/update.md +176 -0
  79. package/codex/maestro-flow/commands/lifecycle/verify.md +468 -0
  80. package/codex/maestro-flow/commands/manage/codebase-rebuild.md +347 -0
  81. package/codex/maestro-flow/commands/manage/codebase-refresh.md +66 -0
  82. package/codex/maestro-flow/commands/manage/harvest.md +91 -0
  83. package/codex/maestro-flow/commands/manage/issue-discover.md +431 -0
  84. package/codex/maestro-flow/commands/manage/issue.md +75 -0
  85. package/codex/maestro-flow/commands/manage/knowhow-capture.md +110 -0
  86. package/codex/maestro-flow/commands/manage/knowhow.md +95 -0
  87. package/codex/maestro-flow/commands/manage/learn.md +137 -0
  88. package/codex/maestro-flow/commands/manage/status.md +76 -0
  89. package/codex/maestro-flow/commands/manage/wiki.md +55 -0
  90. package/codex/maestro-flow/commands/milestone/audit.md +87 -0
  91. package/codex/maestro-flow/commands/milestone/complete.md +91 -0
  92. package/codex/maestro-flow/commands/milestone/release.md +70 -0
  93. package/codex/maestro-flow/commands/quality/auto-test.md +547 -0
  94. package/codex/maestro-flow/commands/quality/debug.md +334 -0
  95. package/codex/maestro-flow/commands/quality/refactor.md +151 -0
  96. package/codex/maestro-flow/commands/quality/retrospective.md +292 -0
  97. package/codex/maestro-flow/commands/quality/review.md +364 -0
  98. package/codex/maestro-flow/commands/quality/sync.md +111 -0
  99. package/codex/maestro-flow/commands/quality/test.md +498 -0
  100. package/codex/maestro-flow/commands/spec/add.md +101 -0
  101. package/codex/maestro-flow/commands/spec/load.md +77 -0
  102. package/codex/maestro-flow/commands/spec/remove.md +69 -0
  103. package/codex/maestro-flow/commands/spec/setup.md +75 -0
  104. package/codex/maestro-flow/commands/wiki/connect.md +73 -0
  105. package/codex/maestro-flow/commands/wiki/digest.md +87 -0
  106. package/package.json +24 -0
@@ -0,0 +1,318 @@
1
+ ---
2
+ name: maestro-execute
3
+ description: Wave-based parallel task execution via CSV wave pipeline. Reads plan.json to build CSV with pre-computed waves, executes tasks in parallel per wave with cross-wave context propagation. Core execution engine replacing maestro-execute command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--auto-commit] [--method agent|cli] [--dir <path>]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Wave-based parallel task execution using `spawn_agents_on_csv`. Reads plan.json to build a CSV where waves are pre-computed from the plan. Each wave runs tasks in parallel, with cross-wave context propagation via `prev_context`. This is the core execution engine of the maestro pipeline.
10
+
11
+ **Core workflow**: Load Plan -> Build CSV from Tasks -> Wave-by-Wave Parallel Execution -> Aggregate Results
12
+
13
+ **Topology**: Custom (waves inherited from plan.json -- no Kahn's algorithm needed)
14
+
15
+ ```
16
+ +---------------------------------------------------------------------------+
17
+ | TASK EXECUTION CSV WAVE WORKFLOW |
18
+ +---------------------------------------------------------------------------+
19
+ | |
20
+ | Phase 1: Plan Resolution -> CSV |
21
+ | +-- Resolve phase directory (or --dir path) |
22
+ | +-- Read plan.json + .task/TASK-*.json definitions |
23
+ | +-- Detect completed tasks (breakpoint resume) |
24
+ | +-- Build tasks.csv with one row per pending task |
25
+ | +-- Waves inherited from plan.json (pre-computed) |
26
+ | +-- Load project specs for executor context |
27
+ | +-- User validates task breakdown (skip if -y) |
28
+ | |
29
+ | Phase 2: Wave Execution Engine |
30
+ | +-- For each wave (sequential): |
31
+ | | +-- Wave N: Task Execution (parallel within wave) |
32
+ | | | +-- Each agent implements one task |
33
+ | | | +-- Agent reads task definition + convergence criteria |
34
+ | | | +-- Agent creates/modifies files per task.files |
35
+ | | | +-- Agent verifies convergence.criteria (max 3 fix attempts) |
36
+ | | | +-- Agent writes .summaries/TASK-{NNN}-summary.md |
37
+ | | | +-- Atomic commit if --auto-commit |
38
+ | | | +-- Discoveries shared via board (patterns, blockers) |
39
+ | | +-- Merge wave results into master tasks.csv |
40
+ | | +-- Build prev_context for next wave from completed findings |
41
+ | | +-- If blocked tasks: prompt user (skip if -y: auto-continue) |
42
+ | +-- discoveries.ndjson shared across all waves (append-only) |
43
+ | |
44
+ | Phase 3: Results Aggregation |
45
+ | +-- Export results.csv |
46
+ | +-- Update .task/TASK-*.json statuses |
47
+ | +-- Update index.json execution progress |
48
+ | +-- Update state.json project progress |
49
+ | +-- Generate context.md with execution report |
50
+ | +-- Auto-sync codebase docs (if configured) |
51
+ | +-- Display summary with next steps |
52
+ | |
53
+ +---------------------------------------------------------------------------+
54
+ ```
55
+ </purpose>
56
+
57
+ <context>
58
+ ```bash
59
+ $maestro-execute "3"
60
+ $maestro-execute -c 4 "3 --auto-commit"
61
+ $maestro-execute -y "3 --method cli"
62
+ $maestro-execute "3 --dir .workflow/scratch/quick-fix"
63
+ $maestro-execute --continue "20260318-execute-P3-phase3"
64
+ ```
65
+
66
+ **Flags**:
67
+ - `-y, --yes`: Skip all confirmations (auto mode)
68
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 5)
69
+ - `--continue`: Resume existing session
70
+
71
+ **Inner flags** (passed inside quotes):
72
+ - `--auto-commit`: Atomic git commit after each task completion
73
+ - `--method agent|cli`: Override execution method (default: from config.json)
74
+ - `--dir <path>`: Use arbitrary directory instead of phase resolution (scratch mode)
75
+
76
+ When `--yes` or `-y`: Auto-confirm task breakdown, skip blocked-task prompts, auto-continue through all waves.
77
+
78
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
79
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report)
80
+ </context>
81
+
82
+ <csv_schema>
83
+
84
+ ### tasks.csv (Master State)
85
+
86
+ ```csv
87
+ id,title,description,scope,convergence_criteria,hints,execution_directives,deps,context_from,wave,status,findings,files_modified,tests_passed,error
88
+ "TASK-001","Setup auth module","Create authentication module with JWT token generation and verification. Export verifyToken and generateToken functions.","src/auth/","auth.ts contains export function verifyToken(; auth.ts contains export function generateToken(","Reference existing middleware pattern in src/middleware/auth.ts","npm test -- --grep auth","","","1","","","","",""
89
+ "TASK-002","Create user model","Define User interface and database schema with email, passwordHash, role fields. Use existing Result type pattern.","src/models/","user.ts contains export interface User; user.ts contains email: string","See src/models/session.ts for existing model pattern","npm test -- --grep user","","","1","","","","",""
90
+ "TASK-003","Auth middleware","Create Express middleware that validates JWT from Authorization header. Use verifyToken from auth module. Return 401 on invalid token.","src/middleware/","auth-middleware.ts contains export function authMiddleware(; auth-middleware.ts contains verifyToken","Follows existing middleware pattern in src/middleware/logging.ts","npm test -- --grep middleware","TASK-001","TASK-001","2","","","","",""
91
+ "TASK-004","Login endpoint","Implement POST /api/login endpoint. Validate credentials against user model, return JWT on success. Use generateToken from auth module.","src/routes/","login.ts contains router.post('/api/login'; login.ts contains generateToken(","Wire into existing Express app in src/app.ts","curl -X POST localhost:3000/api/login","TASK-001;TASK-002","TASK-001;TASK-002","2","","","","",""
92
+ "TASK-005","Integration tests","Write integration tests for full auth flow: register, login, access protected route, token refresh.","tests/","tests/auth.test.ts exists; npm test exits with code 0","Use existing test setup in tests/setup.ts","npm test","TASK-003;TASK-004","TASK-003;TASK-004","3","","","","",""
93
+ ```
94
+
95
+ **Columns**:
96
+
97
+ | Column | Phase | Description |
98
+ |--------|-------|-------------|
99
+ | `id` | Input | Task ID (TASK-NNN format, from plan.json) |
100
+ | `title` | Input | Short task title from task definition |
101
+ | `description` | Input | Full task description from TASK-*.json |
102
+ | `scope` | Input | Target file/directory glob from task.files |
103
+ | `convergence_criteria` | Input | Grep-verifiable completion criteria (semicolon-separated) |
104
+ | `hints` | Input | Implementation hints + reference files from task definition |
105
+ | `execution_directives` | Input | Verification commands to run after implementation |
106
+ | `deps` | Input | Semicolon-separated dependency task IDs |
107
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs |
108
+ | `wave` | Computed | Wave number from plan.json wave assignment |
109
+ | `status` | Output | `pending` -> `completed` / `failed` / `blocked` / `skipped` |
110
+ | `findings` | Output | Implementation notes and observations (max 500 chars) |
111
+ | `files_modified` | Output | Semicolon-separated list of created/modified files |
112
+ | `tests_passed` | Output | Test pass/fail status from execution_directives |
113
+ | `error` | Output | Error message if failed or blocked |
114
+
115
+ ### Per-Wave CSV (Temporary)
116
+
117
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column populated from predecessor task findings.
118
+
119
+ ### Output Artifacts
120
+
121
+ | File | Purpose | Lifecycle |
122
+ |------|---------|-----------|
123
+ | `tasks.csv` | Master state -- all tasks with status/findings | Updated after each wave |
124
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
125
+ | `wave-{N}-results.csv` | Per-wave output | Created by spawn_agents_on_csv |
126
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
127
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across waves |
128
+ | `context.md` | Human-readable execution report | Created in Phase 3 |
129
+
130
+ ### Session Structure
131
+
132
+ ```
133
+ .workflow/.csv-wave/{YYYYMMDD}-execute-P{N}-{slug}/
134
+ +-- tasks.csv
135
+ +-- results.csv
136
+ +-- discoveries.ndjson
137
+ +-- context.md
138
+ +-- config.json
139
+ +-- wave-{N}.csv (temporary)
140
+ +-- wave-{N}-results.csv (temporary)
141
+ ```
142
+ </csv_schema>
143
+
144
+ <invariants>
145
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
146
+ 2. **Wave Order is Sacred**: Never execute wave N+1 before wave N completes and results are merged
147
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all execution state
148
+ 4. **Context Propagation**: prev_context built from master CSV findings, not from memory
149
+ 5. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
150
+ 6. **Cascading Skip on Failure**: If a task fails/blocks, all dependent tasks are skipped
151
+ 7. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
152
+ 8. **Max 3 Fix Attempts**: Per task, auto-fix convergence failures up to 3 times, then mark blocked
153
+ 9. **Breakpoint Resume**: Always detect completed tasks and skip them on re-run
154
+ 10. **DO NOT STOP**: Continuous execution until all waves complete or user explicitly stops
155
+ </invariants>
156
+
157
+ <execution>
158
+
159
+ ### Session Initialization
160
+
161
+ ```
162
+ Parse from $ARGUMENTS:
163
+ AUTO_YES ← --yes | -y
164
+ continueMode ← --continue
165
+ maxConcurrency ← --concurrency | -c N (default: 5)
166
+ autoCommit ← --auto-commit
167
+ executionMethod ← --method agent|cli (default: from config.json)
168
+ scratchDir ← --dir <path> (default: null)
169
+ phaseArg ← remaining text after flag removal
170
+
171
+ Derive:
172
+ dateStr ← UTC+8 YYYYMMDD
173
+ sessionId ← scratchDir ? "{dateStr}-execute-scratch" : "{dateStr}-execute-P{phaseArg}-{phaseSlug}"
174
+ sessionFolder ← ".workflow/.csv-wave/{sessionId}"
175
+
176
+ mkdir -p {sessionFolder}
177
+ ```
178
+
179
+ ### Phase 1: Plan Resolution -> CSV
180
+
181
+ **Objective**: Resolve phase, load plan + task definitions, detect resume point, generate tasks.csv.
182
+
183
+ **Decomposition Rules**:
184
+
185
+ 1. **Plan resolution** (per scratch-milestone-architecture):
186
+
187
+ | Input | Resolution |
188
+ |-------|------------|
189
+ | `--dir <path>` | Use path directly (scratch plan dir) |
190
+ | No args | Find all pending plans for current milestone from state.json.artifacts[] |
191
+ | Number (e.g., `3`) | Find pending plans for phase N from state.json.artifacts[] |
192
+
193
+ For multi-plan: execute sequentially. Each plan is a full CSV session.
194
+
195
+ 2. **Load plan**: Read `{PLAN_DIR}/plan.json` for wave structure and task assignments
196
+
197
+ 3. **Detect completed tasks (breakpoint resume)**: Read `.task/TASK-{NNN}.json` for each task; exclude completed ones from CSV. Log resume count.
198
+
199
+ 4. **Build tasks.csv**: For each pending task per wave, read `.task/TASK-{NNN}.json` and extract: title, description, scope (from files), convergence.criteria, hints, execution_directives. Set `deps` from task dependency, `context_from` = deps, `wave` from plan.json.
200
+
201
+ 5. **Load project specs**: Read `.workflow/specs/` for coding conventions and architecture constraints (passed to all agents)
202
+
203
+ 6. **User validation**: Display task/wave breakdown. Skip if AUTO_YES.
204
+
205
+ ### Phase 2: Wave Execution Engine
206
+
207
+ **Objective**: Execute tasks wave-by-wave via spawn_agents_on_csv with cross-wave context propagation.
208
+
209
+ #### Per-Wave Execution Loop
210
+
211
+ For each wave N in ascending order:
212
+
213
+ 1. Extract wave N pending rows from master `tasks.csv` (skip wave if none)
214
+ 2. Build `prev_context` per task from completed predecessor findings
215
+ 3. Write `wave-{N}.csv` with `prev_context` column, then execute:
216
+
217
+ ```javascript
218
+ spawn_agents_on_csv({
219
+ csv_path: `${sessionFolder}/wave-${N}.csv`,
220
+ id_column: "id",
221
+ instruction: buildExecutorInstruction(sessionFolder, phaseDir, autoCommit, specsContent),
222
+ max_concurrency: maxConcurrency, max_runtime_seconds: 3600,
223
+ output_csv_path: `${sessionFolder}/wave-${N}-results.csv`,
224
+ output_schema: { id, status: [completed|failed|blocked], findings, files_modified, tests_passed, error }
225
+ })
226
+ ```
227
+
228
+ 4. Merge results into master `tasks.csv`, delete `wave-{N}.csv`
229
+
230
+ #### Blocked Task Handling
231
+
232
+ After each wave: if blocked tasks exist, prompt user to continue or stop (AUTO_YES: auto-continue). Skip tasks whose deps are blocked/failed.
233
+
234
+ #### Cascading Skip
235
+
236
+ Blocked/failed tasks cascade: mark all downstream dependents as `skipped` with error "Dependency {dep_id} blocked/failed".
237
+
238
+ ### Phase 3: Results Aggregation
239
+
240
+ **Objective**: Update all state files and generate execution report.
241
+
242
+ 1. Export final `tasks.csv` as `results.csv`
243
+
244
+ 2. **Update task files**: Write each task's status from CSV back to `.task/{id}.json`
245
+
246
+ 3. **Issue status sync**: For tasks with `issue_id`, update `.workflow/issues/issues.jsonl`:
247
+ - All task_refs completed -> `issue.status = "resolved"`; any failed -> `"in_progress"`
248
+ - Append history entry: `{ action: "executed", at: <ISO>, by: "maestro-execute", summary: "TASK-{NNN} {status}" }`
249
+
250
+ 4. **Register EXC artifact in state.json**: Find matching plan artifact, create `{ id: "EXC-{next_id}", type: "execute", milestone, phase, scope, path, status: "completed", depends_on: plan_artifact.id, harvested: false, created_at, completed_at }`
251
+
252
+ 5. **Extract incremental specs**: Read `.summaries/`, use `maestro spec add` CLI:
253
+ - Learnings/pitfalls → `maestro spec add learning "<title>" "<content>" --keywords ... --source execute:{PLAN_DIR}`
254
+ - Design rationale → `maestro spec add coding "<title>" "<content>" --keywords ...`
255
+ - Root cause/workaround → `maestro spec add debug "<title>" "<content>" --keywords ...`
256
+ Mark artifact `harvested: true`
257
+
258
+ 6. **Post-task Knowledge Inquiry**: Prompt user to capture knowledge when:
259
+ - Execution deviation detected (plan change) -> `/spec-add arch`
260
+ - Retry success (>=2 retries) -> `/spec-add debug`
261
+ - Implicit design rationale found -> `/spec-add learning`
262
+
263
+ 7. **Generate context.md**: Execution report with summary (tasks/blocked/waves/auto-commit), per-wave result table (task, status, files, tests), blocked tasks, discovery board summary, next steps.
264
+
265
+ 8. **Auto-sync** (if config.json.codebase.auto_sync_after_execute == true): detect changed files, trigger codebase doc update.
266
+
267
+ 9. **Display completion report**: Phase, completed/blocked counts, wave progress, paths to `.summaries/` and `.task/`, next step suggestions (`maestro-verify`, `manage-status`).
268
+
269
+ ### Shared Discovery Board Protocol
270
+
271
+ #### Standard Discovery Types
272
+
273
+ | Type | Dedup Key | Data Schema | Description |
274
+ |------|-----------|-------------|-------------|
275
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found during implementation |
276
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point discovered |
277
+ | `convention` | singleton | `{naming, imports, formatting}` | Project coding conventions observed |
278
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue encountered |
279
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack detail confirmed |
280
+ | `test_command` | `data.command` | `{command, scope, result}` | Working test command discovered |
281
+
282
+ #### Protocol
283
+
284
+ Read `discoveries.ndjson` before implementation. Append-only: dedup by type+key before writing, never modify/delete.
285
+
286
+ ```bash
287
+ echo '{"ts":"<ISO>","worker":"TASK-001","type":"code_pattern","data":{"name":"Result type","file":"src/types/result.ts","description":"All functions return Result<T,E> for error handling"}}' >> {session_folder}/discoveries.ndjson
288
+ ```
289
+ </execution>
290
+
291
+ <error_codes>
292
+
293
+ | Error | Resolution |
294
+ |-------|------------|
295
+ | Phase directory not found | Abort with error: "Phase {N} not found" |
296
+ | plan.json not found | Abort with error: "No plan found -- run plan first" |
297
+ | No pending tasks (all completed) | Abort with info: "All tasks already completed" |
298
+ | Task file (.task/TASK-*.json) missing | Skip task, log error, mark as failed |
299
+ | Agent spawn fails | Retry once, then mark task as blocked with checkpoint |
300
+ | Convergence criteria not met after 3 attempts | Mark task as blocked, write checkpoint |
301
+ | Git commit fails (--auto-commit) | Log warning, continue (task still marked completed) |
302
+ | All tasks in wave blocked | Stop execution, report blocked wave |
303
+ | CSV parse error | Validate format, show line number |
304
+ | discoveries.ndjson corrupt | Ignore malformed lines, continue |
305
+ | Continue mode: no session found | List available sessions |
306
+ </error_codes>
307
+
308
+ <success_criteria>
309
+ - [ ] Session folder created with valid tasks.csv
310
+ - [ ] All waves executed in order with cross-wave context propagation
311
+ - [ ] Completed tasks have .summaries/TASK-{NNN}-summary.md
312
+ - [ ] .task/TASK-*.json statuses updated to match execution results
313
+ - [ ] state.json updated with EXC artifact
314
+ - [ ] context.md produced with execution report
315
+ - [ ] Blocked tasks have checkpoint info for resume
316
+ - [ ] Cascading skip applied for dependent tasks
317
+ - [ ] discoveries.ndjson append-only throughout
318
+ </success_criteria>
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: maestro-fork
3
+ description: Create git worktree for milestone-level parallel development, or sync existing worktree with main. Copies .workflow/ context and scratch artifacts into worktree since .workflow/ is gitignored.
4
+ argument-hint: "-m <milestone-number> [--base <branch>] [--sync]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Create a git worktree for an entire milestone, enabling inter-milestone parallel development.
10
+ The worktree scope is milestone-level — all scratch artifacts for that milestone are owned by
11
+ the worktree. Since `.workflow/` is gitignored, this command explicitly copies project context
12
+ and milestone scratch artifacts into the worktree.
13
+
14
+ Also supports `--sync` mode to pull latest main into an active worktree.
15
+ </purpose>
16
+
17
+ <required_reading>
18
+ @~/.maestro/workflows/fork.md
19
+ </required_reading>
20
+
21
+ <context>
22
+ $ARGUMENTS — milestone number and optional flags.
23
+
24
+ **Modes:**
25
+ | Mode | Trigger | Behavior |
26
+ |------|---------|----------|
27
+ | Fork | `-m 2` or `2` | Create worktree for milestone 2 |
28
+ | Sync | `-m 2 --sync` | Sync existing worktree with main |
29
+
30
+ **Flags:**
31
+ - `-m <N>` or bare `<N>`: Milestone number
32
+ - `--base <branch>`: Override base branch (default: HEAD)
33
+ - `--sync`: Pull main into existing worktree, re-copy shared artifacts
34
+
35
+ **Worktree layout:**
36
+ ```
37
+ .worktrees/m{N}-{slug}/
38
+ ├── .workflow/
39
+ │ ├── worktree-scope.json (milestone scope marker)
40
+ │ ├── state.json (scoped — this milestone's artifacts only)
41
+ │ ├── project.md, roadmap.md, config.json, specs/ (read-only copies)
42
+ │ └── scratch/ (milestone's existing + new artifacts)
43
+ └── <source code>
44
+ ```
45
+
46
+ **Artifact scoping:**
47
+ Fork copies scratch artifacts belonging to the target milestone (filtered from `state.json.artifacts[]` where `milestone == target`). New work creates scratch artifacts normally, registered in the worktree's local `state.json`.
48
+ </context>
49
+
50
+ <execution>
51
+ Follow '~/.maestro/workflows/fork.md' completely.
52
+
53
+ **Fork flow:**
54
+ 1. Validate: initialized, roadmap exists, not inside worktree, milestone not forked
55
+ 2. Resolve milestone: `state.json.milestones[N-1]`
56
+ 3. Create worktree: `git worktree add -b milestone/{slug} .worktrees/m{N}-{slug} HEAD`
57
+ 4. Copy `.workflow/`: shared files + milestone scratch artifacts
58
+ 5. Write `worktree-scope.json` with milestone scope
59
+ 6. Write scoped `state.json` (this milestone's artifacts only)
60
+ 7. Update main: `worktrees.json` registry, mark milestone `"forked"`
61
+
62
+ **Sync flow:**
63
+ 1. Find worktree from `worktrees.json`
64
+ 2. `cd worktree && git merge main`
65
+ 3. Re-copy shared files (project.md, roadmap.md, config.json, specs/)
66
+
67
+ **Next steps:**
68
+ - Fork → `cd {wt.path} && $maestro-analyze`
69
+ - Sync → resume work in worktree
70
+ </execution>
71
+
72
+ <error_codes>
73
+ | Code | Severity | Condition | Recovery |
74
+ |------|----------|-----------|----------|
75
+ | E001 | error | Project not initialized | Run maestro-init |
76
+ | E002 | error | No roadmap found | Run maestro-roadmap |
77
+ | E003 | error | Running inside a worktree | Run from main worktree |
78
+ | E004 | error | No milestone number | Provide `-m <N>` |
79
+ | E006 | error | Milestone out of range | Check available milestones |
80
+ | E008 | error | Milestone already has active worktree | Merge or cleanup first |
81
+ </error_codes>
82
+
83
+ <success_criteria>
84
+ Fork mode:
85
+ - [ ] Milestone resolved from state.json.milestones[]
86
+ - [ ] Git worktree created with branch `milestone/{slug}`
87
+ - [ ] Shared `.workflow/` files copied (project.md, roadmap.md, config.json, specs/)
88
+ - [ ] Milestone scratch artifacts copied (filtered from artifact registry)
89
+ - [ ] `worktree-scope.json` written with milestone scope
90
+ - [ ] Scoped `state.json` written (this milestone's artifacts only)
91
+ - [ ] `worktrees.json` registry updated in main worktree
92
+ - [ ] Milestone marked `"forked"` in main state.json
93
+
94
+ Sync mode:
95
+ - [ ] Git merge main into worktree branch
96
+ - [ ] Shared artifacts re-copied
97
+ - [ ] Conflicts reported if any
98
+ </success_criteria>
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: maestro-init
3
+ description: Initialize project with auto state detection — creates .workflow/ directory, project.md, state.json, config.json, and specs/
4
+ argument-hint: "[-y] [--from-brainstorm SESSION-ID]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Sequential project setup skill. Detects project state (empty/code/existing), gathers project information through deep questioning or document extraction, then creates the `.workflow/` directory structure. No parallel agents — single sequential flow.
10
+
11
+ When `-y`: After config questions, run research without further interaction. Expects idea document via @ reference.
12
+ </purpose>
13
+
14
+ <context>
15
+
16
+ ```bash
17
+ $maestro-init ""
18
+ $maestro-init "-y"
19
+ $maestro-init "--from-brainstorm 20260318-brainstorm-auth"
20
+ ```
21
+
22
+ **Flags**:
23
+ - `-y`: Skip interactive questioning; extract from provided document
24
+ - `--from-brainstorm SESSION-ID`: Import vision/goals/constraints from brainstorm guidance-specification.md
25
+
26
+ **Output**: `.workflow/` directory with project.md, state.json, config.json, specs/
27
+
28
+ </context>
29
+
30
+ <invariants>
31
+ 1. **Never create roadmap** — init only creates .workflow/ structure; roadmap is a separate step
32
+ 2. **Deep questioning over speed** — follow threads, ask clarifying questions (unless -y)
33
+ 3. **Detect, don't assume** — scan for existing files, package managers, frameworks before asking
34
+ 4. **Templates are source of truth** — always read templates before writing files
35
+ 5. **Idempotent check** — if .workflow/ exists, refuse to overwrite (E002)
36
+ </invariants>
37
+
38
+ <execution>
39
+
40
+ ### Step 1: Parse Arguments
41
+
42
+ Extract flags from arguments:
43
+ - `-y` flag presence
44
+ - `--from-brainstorm SESSION-ID` value
45
+ - Remaining text as project description
46
+
47
+ ### Step 2: Detect Project State
48
+
49
+ Check for `.workflow/state.json` and common manifests (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`).
50
+
51
+ Classify as:
52
+ - **existing**: `.workflow/state.json` found — warn and exit (E002)
53
+ - **code**: Source files present but no `.workflow/` — onboarding existing codebase
54
+ - **empty**: Greenfield project
55
+
56
+ ### Step 3: Gather Project Information
57
+
58
+ **If `--from-brainstorm`**:
59
+ - Read `.workflow/.brainstorm/{SESSION-ID}/guidance-specification.md`
60
+ - Extract: vision, goals, constraints, terminology, tech decisions
61
+ - Skip interactive questioning
62
+
63
+ **If `-y`**:
64
+ - Extract project info from provided document/@ reference
65
+ - Minimal interactive questions (confirm core value only)
66
+
67
+ **Otherwise (interactive)**:
68
+ - Deep questioning flow:
69
+ 1. What is the core value proposition?
70
+ 2. Who are the target users?
71
+ 3. What are the key requirements? (follow threads, don't rush)
72
+ 4. What are known constraints/limitations?
73
+ 5. What tech stack preferences exist?
74
+ - Follow each thread with clarifying questions until satisfied
75
+
76
+ ### Step 4: Read Templates
77
+
78
+ Read the following templates:
79
+ - `~/.maestro/templates/project.md`
80
+ - `~/.maestro/templates/state.json`
81
+ - `~/.maestro/templates/config.json`
82
+
83
+ ### Step 5: Create .workflow/ Structure
84
+
85
+ Create directories: `.workflow/specs`, `.workflow/scratch`, `.workflow/codebase`.
86
+
87
+ ### Step 6: Write project.md
88
+
89
+ Populate template with: project name, core value proposition, requirements (Validated/Active/Out of Scope), key decisions, constraints, tech stack. Write to `.workflow/project.md`.
90
+
91
+ ### Step 7: Write state.json
92
+
93
+ Initialize from template with `current_milestone: null`, `status: "initialized"`, empty `artifacts[]`. Write to `.workflow/state.json`.
94
+
95
+ ### Step 8: Write config.json
96
+
97
+ Configuration questions (or defaults for -y): granularity (fine/medium/coarse), workflow agents (enable/disable), gate preferences. Write to `.workflow/config.json`.
98
+
99
+ ### Step 9: Initialize specs/
100
+
101
+ Run `Bash("maestro spec init")` to create empty seed files in `.workflow/specs/`.
102
+
103
+ If project state is **code** (existing source files detected):
104
+ - Auto-trigger `Skill({ skill: "maestro-flow", args: "--cmd spec-setup" })` to scan codebase and populate specs with detected conventions.
105
+
106
+ If project state is **empty** (greenfield):
107
+ - Skip spec-setup. Specs are populated progressively by analyze, plan, and execute stages via `maestro spec add`.
108
+
109
+ ### Step 10: Completion Report
110
+
111
+ Display created files and next steps: `$maestro-roadmap --mode full` (full spec), `$maestro-roadmap` (light), `$manage-status`, `$maestro-brainstorm`, `$maestro-quick`.
112
+
113
+ </execution>
114
+
115
+ <error_codes>
116
+
117
+ | Code | Severity | Description | Recovery |
118
+ |------|----------|-------------|----------|
119
+ | E001 | error | No arguments when -y requires document | Ask user for document reference |
120
+ | E002 | error | .workflow/ already exists | Show status, suggest manage-status |
121
+ | E003 | error | Brainstorm session not found | List available sessions |
122
+ | W001 | warning | Could not detect tech stack | Continue with manual input |
123
+
124
+ </error_codes>
125
+
126
+ <success_criteria>
127
+ - [ ] Project state correctly detected (empty/code/existing)
128
+ - [ ] `.workflow/` directory structure created
129
+ - [ ] `project.md` populated with project information
130
+ - [ ] `state.json` initialized with correct status
131
+ - [ ] `config.json` written with configuration
132
+ - [ ] `specs/` initialized with convention files
133
+ - [ ] Completion report displayed with next steps
134
+ </success_criteria>
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: maestro-learn
3
+ description: Learning coordinator — route intent to learn commands, execute single or multi-step chains sequentially. Supports 7 chains from single-step (follow, investigate) to multi-step (deep-understand, pattern-catalog).
4
+ argument-hint: "\"intent text\" [-y] [--dry-run] [--chain <name>]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Route learning requests to the optimal learn command or multi-step chain.
10
+ Executes commands sequentially with session tracking.
11
+
12
+ ```
13
+ Intent → Route to Chain → Execute Steps → Session Summary
14
+ ```
15
+ </purpose>
16
+
17
+ <context>
18
+ $ARGUMENTS — learning intent text, or flags.
19
+
20
+ **Flags:**
21
+ - `-y, --yes` — Auto mode: skip confirmation
22
+ - `--dry-run` — Show planned chain without executing
23
+ - `--chain <name>` — Force specific chain
24
+
25
+ **Chains:**
26
+ | Chain | Steps | Use when |
27
+ |-------|-------|----------|
28
+ | `follow` | learn-follow | Read/understand code or docs |
29
+ | `investigate` | learn-investigate | Answer "how/why" questions |
30
+ | `decompose` | learn-decompose | Catalog patterns in a module |
31
+ | `second-opinion` | learn-second-opinion | Get review/challenge on code |
32
+ | `retro` | learn-retro --lens all | Full retrospective |
33
+ | `deep-understand` | follow → decompose → second-opinion | Thorough module analysis |
34
+ | `pattern-catalog` | decompose --save-spec --save-wiki → second-opinion --mode review | Full pattern extraction + review |
35
+
36
+ **Session state:** `.workflow/learning/.maestro-learn/{session_id}/status.json`
37
+ </context>
38
+
39
+ <execution>
40
+
41
+ ### Step 1: Parse & Route
42
+
43
+ **Intent routing:**
44
+ | Keywords | Route |
45
+ |----------|-------|
46
+ | File path (contains `/` or `\`) | `follow` |
47
+ | read, follow, walk through, understand | `follow` |
48
+ | why, how, what if, investigate | `investigate` |
49
+ | pattern, decompose, catalog | `decompose` |
50
+ | opinion, review, challenge, consult | `second-opinion` |
51
+ | retro, git, commit, decision | `retro` |
52
+ | thorough, deep | `deep-understand` |
53
+
54
+ No match → present menu via AskUserQuestion. Max 1 clarification.
55
+
56
+ ### Step 2: Resolve Target & Build Args
57
+ Map chain to skill invocations. Extract target and flags from arguments.
58
+
59
+ ### Step 3: Confirm & Execute
60
+ - `--dry-run`: display chain and exit
61
+ - Not `-y`: show plan, ask confirmation
62
+ - Execute each step sequentially. On failure: retry/skip/abort
63
+ - Write session `status.json`, display summary
64
+ </execution>
65
+
66
+ <error_codes>
67
+ | Code | Severity | Condition | Recovery |
68
+ |------|----------|-----------|----------|
69
+ | E001 | error | No intent provided | Provide learning goal or use --chain |
70
+ | E002 | error | Cannot determine intent | Rephrase or use --chain |
71
+ | E005 | error | Invalid --chain name | Show valid chains |
72
+ | W001 | warning | Intent ambiguous | Present options |
73
+ </error_codes>
74
+
75
+ <success_criteria>
76
+ - [ ] Intent routed to correct chain
77
+ - [ ] Session directory created with status.json
78
+ - [ ] All chain steps executed
79
+ - [ ] Session summary displayed with next-step routing
80
+ </success_criteria>