maestro-flow 0.4.7 → 0.4.8

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 (55) hide show
  1. package/.claude/commands/maestro-ralph.md +548 -377
  2. package/.claude/commands/maestro.md +220 -191
  3. package/.codex/skills/maestro/SKILL.md +495 -462
  4. package/.codex/skills/maestro-ralph/SKILL.md +491 -339
  5. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +25 -33
  6. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  7. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.test.js +9 -3
  8. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.test.js.map +1 -1
  9. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js +5 -2
  10. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js.map +1 -1
  11. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +20 -8
  12. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  13. package/dashboard/dist-server/dashboard/src/server/agents/gemini-a2a-adapter.js +6 -3
  14. package/dashboard/dist-server/dashboard/src/server/agents/gemini-a2a-adapter.js.map +1 -1
  15. package/dashboard/dist-server/dashboard/src/server/agents/gemini-a2a-adapter.test.js +7 -1
  16. package/dashboard/dist-server/dashboard/src/server/agents/gemini-a2a-adapter.test.js.map +1 -1
  17. package/dashboard/dist-server/dashboard/src/server/agents/opencode-adapter.d.ts +2 -0
  18. package/dashboard/dist-server/dashboard/src/server/agents/opencode-adapter.js +40 -15
  19. package/dashboard/dist-server/dashboard/src/server/agents/opencode-adapter.js.map +1 -1
  20. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.d.ts +1 -0
  21. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.js +59 -0
  22. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.js.map +1 -0
  23. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.test.d.ts +1 -0
  24. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.test.js +78 -0
  25. package/dashboard/dist-server/dashboard/src/server/agents/process-tree-kill.test.js.map +1 -0
  26. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.d.ts +25 -0
  27. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.js +40 -0
  28. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.js.map +1 -0
  29. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.test.d.ts +1 -0
  30. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.test.js +89 -0
  31. package/dashboard/dist-server/dashboard/src/server/agents/stale-handler.test.js.map +1 -0
  32. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js +19 -8
  33. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js.map +1 -1
  34. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.d.ts +6 -0
  35. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.js +7 -1
  36. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.js.map +1 -1
  37. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.test.d.ts +1 -0
  38. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.test.js +46 -0
  39. package/dashboard/dist-server/dashboard/src/server/agents/stream-monitor.test.js.map +1 -0
  40. package/dashboard/dist-server/shared/agent-types.d.ts +6 -0
  41. package/dist/shared/agent-types.d.ts +6 -0
  42. package/dist/shared/agent-types.d.ts.map +1 -1
  43. package/dist/src/agents/cli-agent-runner.d.ts +3 -0
  44. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  45. package/dist/src/agents/cli-agent-runner.js +1 -0
  46. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  47. package/dist/src/commands/delegate.d.ts +2 -0
  48. package/dist/src/commands/delegate.d.ts.map +1 -1
  49. package/dist/src/commands/delegate.js +18 -0
  50. package/dist/src/commands/delegate.js.map +1 -1
  51. package/dist/src/config/cli-tools-config.d.ts +3 -0
  52. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  53. package/dist/src/config/cli-tools-config.js.map +1 -1
  54. package/package.json +1 -1
  55. package/shared/agent-types.ts +237 -231
@@ -1,462 +1,495 @@
1
- ---
2
- name: maestro
3
- description: Auto-route intent to optimal command chain
4
- argument-hint: "\"intent text\" [-y] [-c|--continue] [--dry-run] [--super]"
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- <purpose>
9
- Wave-based pipeline coordinator. Classify intent → resolve chain wave-by-wave spawn report.
10
- All skill execution via `spawn_agents_on_csv` coordinator never executes skills directly.
11
-
12
- Entry points:
13
- - **`$maestro "intent"`** — Classify → chain → execute
14
- - **`$maestro --continue`** — Resume from last incomplete wave
15
- - **`$maestro --dry-run "intent"`** — Show chain, no execution
16
- - **`$maestro --super "intent"`** — Production-ready mode (read maestro-super.md)
17
- </purpose>
18
-
19
- <deferred_reading>
20
- - [maestro-super.md](~/.maestro/workflows/maestro-super.md)read when `--super` flag is active
21
- </deferred_reading>
22
-
23
- <context>
24
- $ARGUMENTS — user intent text, or special flags.
25
-
26
- **Flags:**
27
- - `-y, --yes` — Auto mode: skip all prompts; propagate `-y` to each skill
28
- - `--continue` — Resume latest paused session from last incomplete wave
29
- - `--dry-run` Display planned chain without executing
30
- - `--super` — Read and follow `maestro-super.md` completely
31
-
32
- **Session state**: `.workflow/.maestro/{session-id}/`
33
- </context>
34
-
35
- <invariants>
36
- 1. **ALL skills via spawn_agents_on_csv** — coordinator NEVER directly executes any skill logic
37
- 2. **Coordinator = prompt assembler** — classify → build CSV → spawn → read results → assemble next
38
- 3. **Barrier = solo wave** — barrier skills always execute alone (wave size = 1)
39
- 4. **Non-barriers can parallel** — consecutive non-barrier skills grouped into one wave
40
- 5. **Wave-by-wave** — never start wave N+1 before wave N results are read
41
- 6. **Coordinator owns context** — sub-agents never read prior results; coordinator assembles full `skill_call`
42
- 7. **Abort on failure** — failed step → mark remaining skippedreport
43
- </invariants>
44
-
45
- <state_machine>
46
-
47
- <states>
48
- S_PARSE — 解析参数、检测 flags PERSIST: —
49
- S_CONTINUE — 加载已有 session,定位 resume 点 PERSIST: session (loaded)
50
- S_CLASSIFY — 意图分类、解析 chain (A_CLASSIFY) PERSIST: —
51
- S_CREATE — 创建 session + status.json PERSIST: session.status, session.steps[]
52
- S_DRY_RUN — 显示 chain 后结束 PERSIST: —
53
- S_CONFIRM 用户确认(auto_mode 跳过) PERSIST: —
54
- S_WAVE_LOOP 构建 wave spawn → 读结果 → 循环 PERSIST: session.waves[], session.current_step, session.context
55
- S_COMPLETE标记完成、释放目标 PERSIST: session.status = "completed"
56
- S_ABORTED 失败中止、标记剩余 skipped PERSIST: session.status = "aborted"
57
- S_FALLBACK 意图无法分类,请求输入 PERSIST:
58
- </states>
59
-
60
- <transitions>
61
-
62
- S_PARSE:
63
- S_CONTINUE WHEN: --continue flag
64
- S_CLASSIFY WHEN: intent text present
65
- → S_FALLBACK WHEN: no intent AND no flags
66
-
67
- S_CONTINUE:
68
- → S_WAVE_LOOP WHEN: session found, has pending steps DO: A_RESUME_SESSION
69
- → S_FALLBACK WHEN: no session found
70
-
71
- S_CLASSIFY:
72
- S_CREATE WHEN: chain resolved DO: A_CLASSIFY
73
- → S_FALLBACK WHEN: no match AND auto_mode
74
- → S_CLASSIFY WHEN: no match AND not auto_mode DO: A_CLARIFY_INTENT
75
- GUARD: max 1 clarification attempt S_FALLBACK
76
-
77
- S_CREATE:
78
- → S_DRY_RUN WHEN: --dry-run flag DO: A_CREATE_SESSION
79
- S_CONFIRM WHEN: not auto_mode DO: A_CREATE_SESSION
80
- S_WAVE_LOOP WHEN: auto_mode DO: A_CREATE_SESSION
81
-
82
- S_DRY_RUN:
83
- → END DO: display chain with [BARRIER] markers
84
-
85
- S_CONFIRM:
86
- S_WAVE_LOOP WHEN: user confirms
87
- S_ABORTED WHEN: user cancels
88
-
89
- S_WAVE_LOOP:
90
- S_WAVE_LOOP WHEN: pending steps remain DO: A_BUILD_AND_SPAWN_WAVE
91
- S_COMPLETE WHEN: no pending steps
92
- S_ABORTED WHEN: step failed
93
- GUARD: wave order is sacred — never skip ahead
94
-
95
- S_COMPLETE:
96
- → END DO: A_FINALIZE
97
-
98
- S_ABORTED:
99
- END DO: A_ABORT_REPORT
100
-
101
- S_FALLBACK:
102
- S_CLASSIFY WHEN: user provides new intent DO: AskUserQuestion
103
- END WHEN: user cancels
104
-
105
- </transitions>
106
-
107
- <actions>
108
-
109
- ### A_CREATE_SESSION
110
-
111
- 1. Read `.workflow/state.json` for project context (current phase, milestone, workflow_name)
112
- 2. Resolve chain's skill list from Chain Map (see appendix)
113
- 3. Create `.workflow/.maestro/maestro-{YYYYMMDD-HHMMSS}/status.json`:
114
- ```json
115
- { "session_id", "source": "maestro", "intent", "task_type", "chain_name",
116
- "phase", "milestone", "auto_mode", "context": { "issue_id", "scratch_dir",
117
- "plan_dir", "analysis_dir", "brainstorm_dir" },
118
- "steps": [{ "index", "skill", "args", "status": "pending", "wave_n": null }],
119
- "waves": [], "current_step": 0, "status": "running" }
120
- ```
121
- 4. Initialize tracking:
122
- - `create_goal({ objective: "Maestro {chain}: {N} steps [{skill list}]" })`
123
- - `update_plan({ plan: steps.map(step => { step, status: "pending" }) })`
124
-
125
- ### A_RESUME_SESSION
126
-
127
- 1. Glob `.workflow/.maestro/maestro-*/status.json` sorted desc, load most recent
128
- 2. Find first pending step → set as resume point
129
- 3. Rebuild `update_plan` from status.json (completed"completed", current→"in_progress", rest→"open")
130
-
131
- ### A_CLASSIFY
132
-
133
- **Layer 1: Exact-match (fast path)**
134
- - `--chain <name>` flag → validate against chainMap, use directly (E002 if not found)
135
- - `continue`/`next`/`go`/`继续`/`下一步` `state_continue`
136
- - `status`/`状态`/`dashboard` → `status`
137
-
138
- If matched, skip to chain resolution.
139
-
140
- **Layer 2: Semantic intent matching**
141
-
142
- Directly match user intent to the best `task_type` (maps to chain in Chain Map). Use LLM semantic understanding — no rigid keyword lookup.
143
-
144
- Extract:
145
- ```json
146
- {
147
- "task_type": "<from chain catalog below>",
148
- "scope": "<module/file/area or null>",
149
- "issue_id": "<ISS-XXXXXXXX-NNN if mentioned, else null>",
150
- "phase_ref": "<integer if mentioned, else null>",
151
- "urgency": "<low|normal|high>"
152
- }
153
- ```
154
-
155
- **Chain catalog select by best semantic fit:**
156
-
157
- | task_type | When user intent is about... |
158
- |-----------|---------------------------|
159
- | `quick` | Simple/small task, add a feature, quick change |
160
- | `plan` | Plan, design, architect a phase |
161
- | `execute` | Implement, develop, code a phase |
162
- | `analyze` | Understand, investigate, evaluate code |
163
- | `verify` | Check goals met, validate results |
164
- | `review` | Code quality review |
165
- | `test` | Run or create tests, UAT |
166
- | `test_gen` | Generate tests for coverage gaps |
167
- | `debug` | Diagnose, troubleshoot, fix broken behavior |
168
- | `refactor` | Restructure, clean up, reduce tech debt |
169
- | `init` | Initialize project |
170
- | `sync` | Update/sync documentation |
171
- | `retrospective` | Phase review, post-mortem, 复盘 |
172
- | `learn` | Capture insights, record learnings |
173
- | `release` | Publish, ship, tag version |
174
- | `amend` | Revise workflow commands |
175
- | `compose` | Design/compose reusable workflows |
176
- | `overlay` | Create/edit command overlays |
177
- | `update` | Update maestro itself |
178
- | `harvest` | Extract knowledge from artifacts |
179
- | `wiki` | Manage wiki graph |
180
- | `knowhow` | Manage knowhow entries |
181
- | `ui_design` | UI design, build new UI |
182
- | `issue` | Issue CRUD create, list, close, query |
183
- | `issue_discover` | Discover/find issues in codebase |
184
- | `issue_analyze` | Analyze a specific issue |
185
- | `issue_plan` | Plan fix for an issue |
186
- | `issue_execute` | Fix issue end-to-end (auto-upgrades to issue-full) |
187
- | `feature` | Standard feature: plan→execute→verify |
188
- | `full-lifecycle` | Complete phase: plan→execute→verify→review→test→audit→complete |
189
- | `brainstorm-driven` | Start from exploration/brainstorm |
190
- | `spec-driven` | From spec/requirements (heavy, with init) |
191
- | `roadmap-driven` | From requirements (light, with init) |
192
- | `analyze-plan-execute` | Fast track: analyze→plan→execute |
193
- | `execute-verify` | Resume after planning |
194
- | `review-fix` | Fix review-blocked issues |
195
- | `quality-loop` | Full quality improvement cycle |
196
- | `quality-loop-partial` | Partial quality fix |
197
- | `quality-fix` | Analyze gaps→plan→execute→verify |
198
- | `deploy` | Verify then release |
199
- | `milestone-close` | Close/transition milestone |
200
- | `milestone-release` | Release milestone with version tag |
201
- | `phase_transition` | Transition phase: audit→complete |
202
- | `next-milestone` | Advance to next milestone |
203
- | `state_continue` | Continue from current project state |
204
-
205
- **Selection priorities:**
206
- 1. `issue_id` present prefer issue chains
207
- 2. UI/design/界面/页面/原型prefer `ui_design`
208
- 3. Multiple lifecycle steps implied → prefer multi-step chains
209
- 4. Single specific action prefer single-step chains
210
- 5. "问题" describing broken behavior `debug`; tracked item with ISS-ID `issue`; ambiguous → `debug`
211
- 6. Simple task, no lifecycle context → `quick`
212
- 7. Global fallback `quick`
213
-
214
- **Clarity scoring**: 3=task_type+scope+phase, 2=task_type+scope, 1=task_type only, 0=empty.
215
- If `clarity < 2` and not `auto_mode` → transition to A_CLARIFY_INTENT.
216
-
217
- **Layer 4: State-based routing** (when `taskType === 'state_continue'`)
218
-
219
- Read `.workflow/state.json` and route by condition:
220
-
221
- | Condition | Chain |
222
- |-----------|-------|
223
- | Not initialized | `init` |
224
- | No phases, no roadmap, has accumulated_context | `next-milestone` |
225
- | No phases | `brainstorm-driven` |
226
- | pending + has context | `plan` |
227
- | pending, no context | `analyze` |
228
- | exploring/planning + has plan | `execute-verify` |
229
- | exploring/planning, no plan | `plan` |
230
- | executing, all tasks done | `verify` |
231
- | executing, tasks remain | `execute` |
232
- | verifying, passed + no review | `review` |
233
- | verifying, passed + BLOCK | `review-fix` |
234
- | verifying, passed + UAT pending | `test` |
235
- | verifying, passed + UAT passed | `milestone-close` |
236
- | verifying, passed + UAT failed | `debug` |
237
- | verifying, not passed | `quality-loop-partial` |
238
- | testing, UAT passed | `milestone-close` |
239
- | testing, UAT not passed | `debug` |
240
- | completed | `milestone-close` |
241
- | blocked | `debug` |
242
- | fallback | `status` |
243
-
244
- **Chain resolution order:**
245
- 1. `forceChain` → `chainMap[forceChain]` (E002 if not found)
246
- 2. `state_continue` → Layer 4 state routing → `{ chain, argsOverride? }`
247
- 3. `taskToChain[taskType]` → alias lookup (see Chain Aliases below)
248
- 4. `chainMap[taskType]` → direct lookup
249
-
250
- **Phase resolution**: structured extraction `phase_ref` → fallback regex (`phase N` or bare number) → `projectState.current_phase`.
251
-
252
- ### A_CLARIFY_INTENT
253
-
254
- 1. `AskUserQuestion` with available chain types
255
- 2. Re-classify with user response
256
-
257
- ### A_BUILD_AND_SPAWN_WAVE
258
-
259
- 1. **buildNextWave**: first pending step; barrier solo wave; non-barrier → collect consecutive non-barriers
260
- 2. **buildSkillCall** per step:
261
- - Replace placeholders: `{phase}`, `{plan_dir}`, `{analysis_dir}`, `{brainstorm_dir}`, `{spec_session_id}`
262
- - Append auto-yes flag if `auto_mode` (see Appendix: Auto-Yes Flag Map)
263
- 3. Write `{sessionDir}/wave-{N}.csv` (columns: id, skill_call, topic)
264
- 4. `spawn_agents_on_csv({ csv_path, id_column: "id", instruction: WAVE_INSTRUCTION, max_workers, max_runtime_seconds: 3600, output_csv_path, output_schema: RESULT_SCHEMA })`
265
- 5. Read results update step statuses in status.json
266
- 6. **Barrier analysis** (if barrier skill): read artifacts, update `session.context`
267
- | Barrier Skill | Read | Context Updates |
268
- |---------------|------|-----------------|
269
- | maestro-analyze | context.md, state.json | analysis_dir, gaps, phase |
270
- | maestro-plan | plan.json, .task/TASK-*.json | plan_dir, task_count, wave_count |
271
- | maestro-brainstorm | .brainstorming/ | brainstorm_dir, features |
272
- | maestro-roadmap | specs/ | spec_session_id |
273
- | maestro-execute | results.csv | exec_completed, exec_failed |
274
- 7. Persist: write status.json + sync update_plan
275
-
276
- ### A_FINALIZE
277
-
278
- 1. Set `session.status = "completed"`, write status.json
279
- 2. Sync update_plan: all steps → "completed"
280
- 3. `update_goal({ status: "complete" })` release goal constraint
281
- 4. Generate completion report (see Appendix: Report Format)
282
-
283
- ### A_ABORT_REPORT
284
-
285
- 1. Mark remaining steps as `skipped` in status.json
286
- 2. Set `session.status = "aborted"`, write status.json
287
- 3. Sync update_plan (skipped steps marked)
288
- 4. Do NOT call update_goal — goal stays for `--continue` resume
289
- 5. Display abort report with failure details
290
-
291
- </actions>
292
-
293
- </state_machine>
294
-
295
- <appendix>
296
-
297
- ### Chain Map (Full)
298
-
299
- **Single-step chains:**
300
-
301
- | Chain | Command + Args |
302
- |-------|---------------|
303
- | `status` | `manage-status` |
304
- | `init` | `maestro-init` |
305
- | `analyze` | `maestro-analyze {phase}` |
306
- | `ui_design` | `maestro-impeccable build "{phase}"` |
307
- | `plan` | `maestro-plan {phase}` |
308
- | `execute` | `maestro-execute {phase}` |
309
- | `verify` | `maestro-verify {phase}` |
310
- | `test_gen` | `quality-auto-test {phase}` |
311
- | `auto_test` | `quality-auto-test {phase}` |
312
- | `test` | `quality-test {phase}` |
313
- | `debug` | `quality-debug "{description}"` |
314
- | `integration_test` | `quality-auto-test {phase}` |
315
- | `refactor` | `quality-refactor "{description}"` |
316
- | `review` | `quality-review {phase}` |
317
- | `retrospective` | `quality-retrospective {phase}` |
318
- | `learn` | `maestro-learn "{description}"` |
319
- | `sync` | `quality-sync` |
320
- | `milestone_audit` | `maestro-milestone-audit` |
321
- | `milestone_complete` | `maestro-milestone-complete` |
322
- | `codebase_rebuild` | `manage-codebase-rebuild` |
323
- | `codebase_refresh` | `manage-codebase-refresh` |
324
- | `spec_setup` | `spec-setup` |
325
- | `spec_add` | `spec-add "{description}"` |
326
- | `spec_load` | `spec-load` |
327
- | `spec_map` | `manage-codebase-rebuild` |
328
- | `spec_remove` | `spec-remove "{description}"` |
329
- | `knowhow_capture` | `manage-knowhow-capture "{description}"` |
330
- | `knowhow` | `manage-knowhow "{description}"` |
331
- | `issue` | `manage-issue "{description}"` |
332
- | `issue_discover` | `manage-issue-discover "{description}"` |
333
- | `issue_analyze` | `maestro-analyze --gaps "{description}"` |
334
- | `issue_plan` | `maestro-plan --gaps` |
335
- | `issue_execute` | `maestro-execute` |
336
- | `quick` | `maestro-quick "{description}"` |
337
- | `harvest` | `manage-harvest "{description}"` |
338
- | `wiki` | `manage-wiki` |
339
- | `wiki_connect` | `wiki-connect` |
340
- | `wiki_digest` | `wiki-digest` |
341
- | `business_test` | `quality-auto-test {phase}` |
342
- | `amend` | `maestro-amend "{description}"` |
343
- | `release` | `maestro-milestone-release` |
344
- | `compose` | `maestro-composer "{description}"` |
345
- | `play` | `maestro-player "{description}"` |
346
- | `update` | `maestro-update` |
347
- | `overlay` | `maestro-overlay "{description}"` |
348
- | `link_coordinate` | `maestro-link-coordinate "{description}"` |
349
-
350
- **Multi-step chains:**
351
-
352
- | Chain | Steps (→ = sequential, [B] = barrier) |
353
- |-------|---------------------------------------|
354
- | `feature` | [B] maestro-plan → [B] maestro-execute → maestro-verify |
355
- | `quality-fix` | [B] maestro-analyze --gaps → [B] maestro-plan --gaps → [B] maestro-execute → maestro-verify |
356
- | `deploy` | maestro-verify → maestro-milestone-release |
357
- | `spec-driven` | maestro-init → [B] maestro-roadmap --mode full → [B] maestro-plan → [B] maestro-execute → maestro-verify |
358
- | `brainstorm-driven` | [B] maestro-brainstorm → [B] maestro-plan → [B] maestro-execute → maestro-verify |
359
- | `ui-craft-build` | maestro-impeccable build → [B] maestro-plan → [B] maestro-execute → maestro-verify |
360
- | `roadmap-driven` | maestro-init [B] maestro-roadmap → [B] maestro-plan → [B] maestro-execute → maestro-verify |
361
- | `next-milestone` | [B] maestro-roadmap → [B] maestro-plan [B] maestro-execute → maestro-verify |
362
- | `full-lifecycle` | [B] maestro-plan → [B] maestro-execute maestro-verify → quality-review → quality-test → maestro-milestone-audit → maestro-milestone-complete |
363
- | `execute-verify` | [B] maestro-execute maestro-verify |
364
- | `analyze-plan-execute` | [B] maestro-analyze -q → [B] maestro-plan --dir {scratch_dir} → [B] maestro-execute --dir {scratch_dir} |
365
- | `quality-loop` | maestro-verify → quality-review → quality-test quality-debug --from-uat → [B] maestro-plan --gaps → [B] maestro-execute |
366
- | `quality-loop-partial` | [B] maestro-plan --gaps → [B] maestro-execute → maestro-verify |
367
- | `review-fix` | [B] maestro-plan --gaps → [B] maestro-execute → quality-review |
368
- | `milestone-close` | maestro-milestone-audit maestro-milestone-complete |
369
- | `milestone-release` | maestro-milestone-audit maestro-milestone-release |
370
- | `phase_transition` | maestro-milestone-audit maestro-milestone-complete |
371
- | `issue-full` | [B] maestro-analyze --gaps → [B] maestro-plan --gaps → [B] maestro-execute → quality-review manage-issue close |
372
- | `issue-quick` | [B] maestro-plan --gaps → [B] maestro-execute → manage-issue close |
373
-
374
- **Chain Aliases** (taskType chain):
375
-
376
- | taskType | Chain |
377
- |----------|-------|
378
- | `spec_generate` | `spec-driven` |
379
- | `brainstorm` | `brainstorm-driven` |
380
- | `issue_execute` | `issue-full` |
381
-
382
- ### Auto-Yes Flag Map
383
-
384
- | Skill | Flag |
385
- |-------|------|
386
- | maestro-init, maestro-analyze, maestro-brainstorm, maestro-impeccable, maestro-roadmap | `-y` |
387
- | maestro-plan, maestro-execute, maestro-milestone-complete | `-y` |
388
- | quality-auto-test, quality-retrospective | `-y` |
389
- | quality-test | `-y --auto-fix` |
390
-
391
- ### Barrier Skills
392
-
393
- `maestro-analyze`, `maestro-plan`, `maestro-brainstorm`, `maestro-roadmap`, `maestro-execute`
394
-
395
- Non-barrier (groupable): `maestro-verify`, `quality-review`, `quality-test`, `quality-debug`, `quality-refactor`, `quality-sync`, `manage-*`
396
-
397
- ### Worker Contract
398
-
399
- **Instruction template:**
400
- ```
401
- 你是 CSV job agent。
402
- 先原样执行这一段技能调用:{skill_call}
403
- 然后基于结果完成这一行任务说明:{topic}
404
- 限制:不要修改 .workflow/.maestro/ 下的 status 文件
405
- 最后必须调用 `report_agent_job_result`,返回 JSON:
406
- {"status":"completed|failed","skill_call":"{skill_call}","summary":"一句话结果","artifacts":"产物路径","error":"失败原因"}
407
- ```
408
-
409
- **Result schema:** `{ status, skill_call, summary, artifacts, error }` all string, all required
410
-
411
- ### CSV Schema
412
-
413
- **wave-{N}.csv:**
414
- ```csv
415
- id,skill_call,topic
416
- "1","$maestro-analyze --gaps \"fix auth\" -y","Chain \"quality-fix\" step 1/4"
417
- ```
418
-
419
- **Session status.json:** see A_CREATE_SESSION for full schema
420
-
421
- ### Error Codes
422
-
423
- | Code | Severity | Condition | Recovery |
424
- |------|----------|-----------|----------|
425
- | E001 | error | Intent unclassifiable after clarification | Default to `feature` chain |
426
- | E002 | error | Intent unresolvable after retry | List chains, abort |
427
- | E003 | error | Wave timeout | Mark step failed, abort chain |
428
- | E004 | error | Barrier artifact not found | Retry wave once, then abort |
429
- | E005 | error | --continue: no session found | List sessions, prompt |
430
- | W001 | warning | Barrier artifact partial | Continue with available context |
431
-
432
- ### Success Criteria
433
-
434
- - [ ] Intent classified and chain resolved
435
- - [ ] Session dir initialized with status.json before first wave
436
- - [ ] Every skill goes through spawn_agents_on_csv
437
- - [ ] Barrier skills solo wave; non-barriers grouped parallel
438
- - [ ] Each wave: CSV → spawn → results → state updated
439
- - [ ] Barrier artifacts read before assembling next wave args
440
- - [ ] Failed step → remaining skipped → abort reported
441
- - [ ] --dry-run shows chain with [BARRIER], no execution
442
- - [ ] --continue resumes from last incomplete wave
443
-
444
- ### Report Format
445
-
446
- ```
447
- === COORDINATE COMPLETE ===
448
- Session: {sessionId}
449
- Chain: {chain}
450
- Waves: {N} executed
451
- Steps: {completed}/{total}
452
-
453
- WAVE RESULTS:
454
- [W1] $maestro-analyze --gaps → ✓ found 3 gaps
455
- [W2] $maestro-plan --gaps → ✓ 12 tasks in 3 waves
456
- ...
457
-
458
- State: .workflow/.maestro/{sessionId}/status.json
459
- Resume: $maestro --continue
460
- ```
461
-
462
- </appendix>
1
+ ---
2
+ name: maestro
3
+ description: Auto-route intent to optimal command chain
4
+ argument-hint: "\"intent text\" [-y] [-c|--continue] [--dry-run] [--super]"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ <purpose>
9
+ Sequential pipeline coordinator. Classify intent → decompose (broad lifecycle intents)
10
+ resolve chain **directly invoke each skill in-context, one at a time** → report.
11
+
12
+ Entry points:
13
+ - **`$maestro "intent"`** — Classify → decompose → chain → execute
14
+ - **`$maestro --continue`** — Resume from first pending step
15
+ - **`$maestro --dry-run "intent"`** — Show chain, no execution
16
+ - **`$maestro --super "intent"`** — Production-ready mode (read maestro-super.md)
17
+
18
+ Codex specifics (parity with maestro-ralph):
19
+ - **No agent spawning** — skills run directly in coordinator context, sequentially.
20
+ - **Goal created via built-in tool** `create_goal` binds the decomposed sub-goal checklist;
21
+ `update_plan` mirrors steps; `update_goal` releases on convergence.
22
+ </purpose>
23
+
24
+ <deferred_reading>
25
+ - [maestro-super.md](~/.maestro/workflows/maestro-super.md) — read when `--super` flag is active
26
+ </deferred_reading>
27
+
28
+ <context>
29
+ $ARGUMENTSuser intent text, or special flags.
30
+
31
+ **Flags:**
32
+ - `-y, --yes` — Auto mode: skip all prompts; propagate `-y` to each skill
33
+ - `--continue` — Resume latest paused session from first pending step
34
+ - `--dry-run` — Display planned chain without executing
35
+ - `--super` — Read and follow `maestro-super.md` completely
36
+
37
+ **Session state**: `.workflow/.maestro/{session-id}/`
38
+ </context>
39
+
40
+ <invariants>
41
+ 1. **Skills invoked DIRECTLY in-context** — coordinator runs `$skill {resolved_args}` itself, sequentially. NO spawn_agents_on_csv, NO wave/CSV/worker.
42
+ 2. **Coordinator owns the loop** — classify → decompose → resolve chain → for each step: resolve args invoke skill read result persist → next.
43
+ 3. **Decomposition contract shared with maestro-ralph** — broad/lifecycle intents run S_DECOMPOSE producing the SAME additive block (`boundary_contract`, `execution_criteria`, `task_decomposition`, `goal_checklist_path`) + `goal-checklist.md`. Reference maestro-ralph `A_DECOMPOSE_TASKS`; do not duplicate logic.
44
+ 4. **Goal is tool-created** — `A_DECOMPOSE_TASKS` calls `create_goal` with sub-goal success criteria. `update_goal` on convergence; held while aborted/paused.
45
+ 5. **Status JSON: schema-additive + step-dynamic** — decomposition fields OPTIONAL (absent → old flat-chain behavior); `steps[]` is a living array grown at runtime by `post-goal-audit`. `goal_ref` traces dynamically-added steps. Never remove/rename existing fields. `waves` kept as empty array for backward-compat (spawning removed).
46
+ 6. **Sequential execution** — one step at a time in index order; each step's result read before the next starts.
47
+ 7. **Abort on failure** — failed step → mark remaining skipped → report (goal stays bound for `--continue`).
48
+ </invariants>
49
+
50
+ <state_machine>
51
+
52
+ <states>
53
+ S_PARSE 解析参数、检测 flags PERSIST: —
54
+ S_CONTINUE 加载已有 session,定位 resume PERSIST: session (loaded)
55
+ S_CLASSIFY意图分类、解析 chain (A_CLASSIFY) PERSIST:
56
+ S_DECOMPOSE 边界澄清、写执行准则+子目标、建 goal PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
57
+ S_CREATE 创建 session + status.json PERSIST: session.status, session.steps[]
58
+ S_DRY_RUN — 显示 chain 后结束 PERSIST: —
59
+ S_CONFIRM — 用户确认(auto_mode 跳过) PERSIST: —
60
+ S_STEP_LOOP — 逐步直接调用 skill → 读结果 → 循环 PERSIST: session.current_step, session.steps[], session.context
61
+ S_DECISION_EVAL — 评估 post-goal-audit 决策节点 PERSIST: —
62
+ S_COMPLETE — 标记完成、释放目标 PERSIST: session.status = "completed"
63
+ S_ABORTED — 失败中止、标记剩余 skipped PERSIST: session.status = "aborted"
64
+ S_FALLBACK — 意图无法分类,请求输入 PERSIST:
65
+ </states>
66
+
67
+ <transitions>
68
+
69
+ S_PARSE:
70
+ → S_CONTINUE WHEN: --continue flag
71
+ S_CLASSIFY WHEN: intent text present
72
+ S_FALLBACK WHEN: no intent AND no flags
73
+
74
+ S_CONTINUE:
75
+ → S_STEP_LOOP WHEN: session found, has pending steps DO: A_RESUME_SESSION
76
+ → S_FALLBACK WHEN: no session found
77
+
78
+ S_CLASSIFY:
79
+ S_DECOMPOSE WHEN: chain resolved DO: A_CLASSIFY
80
+ S_FALLBACK WHEN: no match AND auto_mode
81
+ → S_CLASSIFY WHEN: no match AND not auto_mode DO: A_CLARIFY_INTENT
82
+ GUARD: max 1 clarification attempt → S_FALLBACK
83
+
84
+ S_DECOMPOSE:
85
+ → S_CREATE DO: A_DECOMPOSE_TASKS
86
+ GUARD: broad intent (重构/全面/重写/迁移/overhaul/migrate/rewrite) on multi-step lifecycle chain MUST clarify even if auto_mode
87
+ GUARD: single-step chain OR narrow intent OR chain ∈ {status,init,quick} skip decomposition (pass through)
88
+
89
+ S_CREATE:
90
+ S_DRY_RUN WHEN: --dry-run flag DO: A_CREATE_SESSION
91
+ S_CONFIRM WHEN: not auto_mode DO: A_CREATE_SESSION
92
+ S_STEP_LOOP WHEN: auto_mode DO: A_CREATE_SESSION
93
+
94
+ S_DRY_RUN:
95
+ → END DO: display chain with step types + sub-goal summary
96
+
97
+ S_CONFIRM:
98
+ → S_STEP_LOOP WHEN: user confirms
99
+ S_ABORTED WHEN: user cancels
100
+
101
+ S_STEP_LOOP:
102
+ S_DECISION_EVAL WHEN: next step.type == "decision"
103
+ S_STEP_LOOP WHEN: next step.type == "skill" DO: A_EXEC_STEP
104
+ → S_COMPLETE WHEN: no pending steps
105
+ → S_ABORTED WHEN: step failed (auto_mode: retry once then abort)
106
+
107
+ S_DECISION_EVAL: ENTRY: A_GOAL_AUDIT_EVALUATE (produces verdict)
108
+ → S_STEP_LOOP WHEN: verdict == all_met DO: A_APPLY_GOAL_DONE
109
+ S_STEP_LOOP WHEN: verdict == has_unmet DO: A_APPLY_GOAL_FIX
110
+ → S_ABORTED WHEN: retry >= max_retries AND unmet DO: escalate (insert quality-debug "{gaps}")
111
+
112
+ S_COMPLETE:
113
+ END DO: A_FINALIZE
114
+
115
+ S_ABORTED:
116
+ END DO: A_ABORT_REPORT
117
+
118
+ S_FALLBACK:
119
+ → S_CLASSIFY WHEN: user provides new intent DO: AskUserQuestion
120
+ → END WHEN: user cancels
121
+
122
+ </transitions>
123
+
124
+ <actions>
125
+
126
+ ### A_CLASSIFY
127
+
128
+ **Layer 1: Exact-match (fast path)**
129
+ - `--chain <name>` flagvalidate against chainMap, use directly (E002 if not found)
130
+ - `continue`/`next`/`go`/`继续`/`下一步` → `state_continue`
131
+ - `status`/`状态`/`dashboard` → `status`
132
+
133
+ If matched, skip to chain resolution.
134
+
135
+ **Layer 2: Semantic intent matching**
136
+
137
+ Directly match user intent to the best `task_type` (maps to chain in Chain Map). Use LLM semantic understanding — no rigid keyword lookup.
138
+
139
+ Extract:
140
+ ```json
141
+ {
142
+ "task_type": "<from chain catalog below>",
143
+ "scope": "<module/file/area or null>",
144
+ "issue_id": "<ISS-XXXXXXXX-NNN if mentioned, else null>",
145
+ "phase_ref": "<integer if mentioned, else null>",
146
+ "urgency": "<low|normal|high>"
147
+ }
148
+ ```
149
+
150
+ **Chain catalog select by best semantic fit:**
151
+
152
+ | task_type | When user intent is about... |
153
+ |-----------|---------------------------|
154
+ | `quick` | Simple/small task, add a feature, quick change |
155
+ | `plan` | Plan, design, architect a phase |
156
+ | `execute` | Implement, develop, code a phase |
157
+ | `analyze` | Understand, investigate, evaluate code |
158
+ | `verify` | Check goals met, validate results |
159
+ | `review` | Code quality review |
160
+ | `test` | Run or create tests, UAT |
161
+ | `test_gen` | Generate tests for coverage gaps |
162
+ | `debug` | Diagnose, troubleshoot, fix broken behavior |
163
+ | `refactor` | Restructure, clean up, reduce tech debt |
164
+ | `init` | Initialize project |
165
+ | `sync` | Update/sync documentation |
166
+ | `retrospective` | Phase review, post-mortem, 复盘 |
167
+ | `learn` | Capture insights, record learnings |
168
+ | `release` | Publish, ship, tag version |
169
+ | `amend` | Revise workflow commands |
170
+ | `compose` | Design/compose reusable workflows |
171
+ | `overlay` | Create/edit command overlays |
172
+ | `update` | Update maestro itself |
173
+ | `harvest` | Extract knowledge from artifacts |
174
+ | `wiki` | Manage wiki graph |
175
+ | `knowhow` | Manage knowhow entries |
176
+ | `ui_design` | UI design, build new UI |
177
+ | `issue` | Issue CRUD create, list, close, query |
178
+ | `issue_discover` | Discover/find issues in codebase |
179
+ | `issue_analyze` | Analyze a specific issue |
180
+ | `issue_plan` | Plan fix for an issue |
181
+ | `issue_execute` | Fix issue end-to-end (auto-upgrades to issue-full) |
182
+ | `feature` | Standard feature: plan→execute→verify |
183
+ | `full-lifecycle` | Complete phase: plan→execute→verify→review→test→audit→complete |
184
+ | `brainstorm-driven` | Start from exploration/brainstorm |
185
+ | `spec-driven` | From spec/requirements (heavy, with init) |
186
+ | `roadmap-driven` | From requirements (light, with init) |
187
+ | `analyze-plan-execute` | Fast track: analyze→plan→execute |
188
+ | `execute-verify` | Resume after planning |
189
+ | `review-fix` | Fix review-blocked issues |
190
+ | `quality-loop` | Full quality improvement cycle |
191
+ | `quality-loop-partial` | Partial quality fix |
192
+ | `quality-fix` | Analyze gaps→plan→execute→verify |
193
+ | `deploy` | Verify then release |
194
+ | `milestone-close` | Close/transition milestone |
195
+ | `milestone-release` | Release milestone with version tag |
196
+ | `phase_transition` | Transition phase: audit→complete |
197
+ | `next-milestone` | Advance to next milestone |
198
+ | `state_continue` | Continue from current project state |
199
+
200
+ **Selection priorities:**
201
+ 1. `issue_id` present prefer issue chains
202
+ 2. UI/design/界面/页面/原型 prefer `ui_design`
203
+ 3. Multiple lifecycle steps implied prefer multi-step chains
204
+ 4. Single specific action → prefer single-step chains
205
+ 5. "问题" describing broken behavior → `debug`; tracked item with ISS-ID → `issue`; ambiguous → `debug`
206
+ 6. Simple task, no lifecycle context → `quick`
207
+ 7. Global fallback → `quick`
208
+
209
+ **Clarity scoring**: 3=task_type+scope+phase, 2=task_type+scope, 1=task_type only, 0=empty.
210
+ If `clarity < 2` and not `auto_mode`transition to A_CLARIFY_INTENT.
211
+
212
+ **Layer 4: State-based routing** (when `taskType === 'state_continue'`)
213
+
214
+ Read `.workflow/state.json` and route by condition:
215
+
216
+ | Condition | Chain |
217
+ |-----------|-------|
218
+ | Not initialized | `init` |
219
+ | No phases, no roadmap, has accumulated_context | `next-milestone` |
220
+ | No phases | `brainstorm-driven` |
221
+ | pending + has context | `plan` |
222
+ | pending, no context | `analyze` |
223
+ | exploring/planning + has plan | `execute-verify` |
224
+ | exploring/planning, no plan | `plan` |
225
+ | executing, all tasks done | `verify` |
226
+ | executing, tasks remain | `execute` |
227
+ | verifying, passed + no review | `review` |
228
+ | verifying, passed + BLOCK | `review-fix` |
229
+ | verifying, passed + UAT pending | `test` |
230
+ | verifying, passed + UAT passed | `milestone-close` |
231
+ | verifying, passed + UAT failed | `debug` |
232
+ | verifying, not passed | `quality-loop-partial` |
233
+ | testing, UAT passed | `milestone-close` |
234
+ | testing, UAT not passed | `debug` |
235
+ | completed | `milestone-close` |
236
+ | blocked | `debug` |
237
+ | fallback | `status` |
238
+
239
+ **Chain resolution order:**
240
+ 1. `forceChain` `chainMap[forceChain]` (E002 if not found)
241
+ 2. `state_continue` Layer 4 state routing → `{ chain, argsOverride? }`
242
+ 3. `taskToChain[taskType]` → alias lookup (see Chain Aliases below)
243
+ 4. `chainMap[taskType]` → direct lookup
244
+
245
+ **Phase resolution**: structured extraction `phase_ref` → fallback regex (`phase N` or bare number) → `projectState.current_phase`.
246
+
247
+ ### A_CLARIFY_INTENT
248
+
249
+ 1. `AskUserQuestion` with available chain types
250
+ 2. Re-classify with user response
251
+
252
+ ### A_DECOMPOSE_TASKS
253
+
254
+ Shares the decomposition contract with maestro-ralph `A_DECOMPOSE_TASKS` **reference that spec; do not duplicate.** Condensed:
255
+
256
+ 1. Classify intent breadth. Skip for narrow / single-step / {status,init,quick} chains
257
+ 2. Broad/medium → `AskUserQuestion` ≤3 rounds: Scope (in/out) | Constraints (compat/API/perf/test bar) | Definition of Done
258
+ 3. Derive `execution_criteria` (3-6 imperative rules) + `task_decomposition` (outcome sub-goals; each `done_when` objectively verifiable, mapped to a ralph evidence artifact: verification.json / review.json / uat.md / test path)
259
+ 4. Write `{session_dir}/goal-checklist.md` (same template as maestro-ralph) with `ALL_GOALS_DONE` sentinel; set `goal_checklist_path`
260
+ 5. Append `{ type: "decision", decision: "post-goal-audit", retry_count: 0, max_retries: 2 }` as the FINAL node — after the last evidence-producing step (verify/review/test), before a milestone-complete/close-out step if present (audit needs evidence artifacts) → dynamic step growth for unmet sub-goals
261
+ 6. **Register goal via `create_goal`:**
262
+ ```
263
+ create_goal({ objective: "Maestro {chain}: {intent} — converge {N} sub-goals within boundary",
264
+ success_criteria: task_decomposition.map(g => `${g.id}: ${g.done_when}`),
265
+ constraints: [...execution_criteria, "stay within boundary_contract"] })
266
+ ```
267
+
268
+ ### A_CREATE_SESSION
269
+
270
+ 1. Read `.workflow/state.json` for project context (current phase, milestone, workflow_name)
271
+ 2. Resolve chain's skill list from Chain Map (see appendix)
272
+ 3. Create `.workflow/.maestro/maestro-{YYYYMMDD-HHMMSS}/status.json`:
273
+ ```json
274
+ { "session_id", "source": "maestro", "intent", "task_type", "chain_name",
275
+ "phase", "milestone", "auto_mode", "context": { "issue_id", "scratch_dir",
276
+ "plan_dir", "analysis_dir", "brainstorm_dir" },
277
+ "steps": [{ "index", "type": "skill|decision", "skill", "args", "status": "pending", "goal_ref": null }],
278
+ "waves": [], "current_step": 0, "status": "running",
279
+ "_comment": "↓ OPTIONAL additive block — present only if S_DECOMPOSE ran; absent flat-chain behavior",
280
+ "boundary_contract": {}, "execution_criteria": [], "task_decomposition": [], "goal_checklist_path": "" }
281
+ ```
282
+ Decomposition fields written ONLY if A_DECOMPOSE_TASKS produced them (additive)
283
+ 4. Initialize tracking:
284
+ - If decomposed: goal already registered by A_DECOMPOSE_TASKS. Else: `create_goal({ objective: "Maestro {chain}: {N} steps [{skill list}]" })`
285
+ - `update_plan({ plan: steps.map(step => ({ step, status: "pending" })) })`
286
+
287
+ ### A_RESUME_SESSION
288
+
289
+ 1. Glob `.workflow/.maestro/maestro-*/status.json` sorted desc, load most recent
290
+ 2. Find first pending step → set as resume point
291
+ 3. Rebuild `update_plan` from status.json (completed→"completed", current→"in_progress", rest→"open")
292
+
293
+ ### A_EXEC_STEP
294
+
295
+ Direct in-context skill invocation — **replaces the old spawn/wave/CSV mechanism**.
296
+
297
+ 1. **buildSkillCall**: replace placeholders `{phase}`/`{plan_dir}`/`{analysis_dir}`/`{brainstorm_dir}`/`{spec_session_id}`; append auto-yes flag if `auto_mode` (see Appendix: Auto-Yes Flag Map)
298
+ 2. Mark step `status="running"`, persist status.json + `update_plan` (this step → in_progress)
299
+ 3. **Invoke the skill directly**: execute `$skill {resolved_args}` in coordinator context (NO spawn). Read its produced artifacts directly
300
+ 4. On success: capture summary; mark step `status="done"`. **Barrier-context update** (when step is a context-producing skill):
301
+ | Skill | Read | Context Updates |
302
+ |-------|------|-----------------|
303
+ | maestro-analyze | context.md, state.json | analysis_dir, gaps, phase |
304
+ | maestro-plan | plan.json, .task/TASK-*.json | plan_dir, task_count |
305
+ | maestro-brainstorm | .brainstorming/ | brainstorm_dir, features |
306
+ | maestro-roadmap | specs/ | spec_session_id |
307
+ | maestro-execute | results.csv | exec_completed, exec_failed |
308
+ 5. On failure: mark `status="failed"`; auto_mode → retry once → still failed → S_ABORTED
309
+ 6. Persist status.json + `update_plan` after every step
310
+
311
+ ### A_GOAL_AUDIT_EVALUATE
312
+
313
+ Entry action of S_DECISION_EVAL — mirrors maestro-ralph `A_GOAL_AUDIT_EVALUATE` (reference that spec; do not duplicate). Condensed:
314
+
315
+ 1. Read `session.task_decomposition` + `goal_checklist_path`
316
+ 2. For each sub-goal `status != "done"`: resolve its `evidence` artifact under current phase scratch dir
317
+ 3. Delegate read-only audit (`maestro delegate --role analyze --mode analysis`): for each unmet sub-goal, read evidence, judge against `done_when`, return `STATUS(all_met|has_unmet) / UNMET=[{id,gap,target_phase}]`
318
+ 4. For each met sub-goal → set `task_decomposition[i].status="done"` + flip `[ ]→[x]` in goal-checklist.md; persist
319
+ 5. Produce verdict (`all_met` / `has_unmet`) consumed by S_DECISION_EVAL transition. GUARD: retry >= max_retries AND still unmet → escalate
320
+
321
+ ### A_APPLY_GOAL_FIX
322
+
323
+ **Dynamic step-growth core** (mirrors maestro-ralph). For each unmet sub-goal (grouped by target_phase), insert before the post-goal-audit node a scoped mini-loop `$maestro-plan --gaps {phase} "G{n}: {gap}" → $maestro-execute {phase} → $maestro-verify {phase}`, each tagged `goal_ref: "G{n}"`, type `"skill"`. Re-append `decision:post-goal-audit {retry+1}`. Reindex, increment retry, persist + `update_plan`. `steps[]` grew.
324
+
325
+ ### A_APPLY_GOAL_DONE
326
+
327
+ 1. Set all `task_decomposition[*].status="done"`, persist; append `ALL_GOALS_DONE` to goal-checklist.md
328
+ 2. `update_goal({ status: "complete" })` — release decomposition goal
329
+ 3. Proceed to chain's terminal step
330
+
331
+ ### A_FINALIZE
332
+
333
+ 1. Set `session.status = "completed"`, write status.json
334
+ 2. Sync `update_plan`: all steps "completed"
335
+ 3. `update_goal({ status: "complete" })` — release goal (idempotent if already released)
336
+ 4. Generate completion report (see Appendix: Report Format)
337
+
338
+ ### A_ABORT_REPORT
339
+
340
+ 1. Mark remaining steps `skipped` in status.json
341
+ 2. Set `session.status = "aborted"`, write status.json; sync `update_plan`
342
+ 3. Do NOT call `update_goal` goal stays for `--continue` resume
343
+ 4. Display abort report with failure details
344
+
345
+ </actions>
346
+
347
+ </state_machine>
348
+
349
+ <appendix>
350
+
351
+ ### Chain Map (Full)
352
+
353
+ **Single-step chains:**
354
+
355
+ | Chain | Command + Args |
356
+ |-------|---------------|
357
+ | `status` | `manage-status` |
358
+ | `init` | `maestro-init` |
359
+ | `analyze` | `maestro-analyze {phase}` |
360
+ | `ui_design` | `maestro-impeccable build "{phase}"` |
361
+ | `plan` | `maestro-plan {phase}` |
362
+ | `execute` | `maestro-execute {phase}` |
363
+ | `verify` | `maestro-verify {phase}` |
364
+ | `test_gen` | `quality-auto-test {phase}` |
365
+ | `auto_test` | `quality-auto-test {phase}` |
366
+ | `test` | `quality-test {phase}` |
367
+ | `debug` | `quality-debug "{description}"` |
368
+ | `integration_test` | `quality-auto-test {phase}` |
369
+ | `refactor` | `quality-refactor "{description}"` |
370
+ | `review` | `quality-review {phase}` |
371
+ | `retrospective` | `quality-retrospective {phase}` |
372
+ | `learn` | `maestro-learn "{description}"` |
373
+ | `sync` | `quality-sync` |
374
+ | `milestone_audit` | `maestro-milestone-audit` |
375
+ | `milestone_complete` | `maestro-milestone-complete` |
376
+ | `codebase_rebuild` | `manage-codebase-rebuild` |
377
+ | `codebase_refresh` | `manage-codebase-refresh` |
378
+ | `spec_setup` | `spec-setup` |
379
+ | `spec_add` | `spec-add "{description}"` |
380
+ | `spec_load` | `spec-load` |
381
+ | `spec_map` | `manage-codebase-rebuild` |
382
+ | `spec_remove` | `spec-remove "{description}"` |
383
+ | `knowhow_capture` | `manage-knowhow-capture "{description}"` |
384
+ | `knowhow` | `manage-knowhow "{description}"` |
385
+ | `issue` | `manage-issue "{description}"` |
386
+ | `issue_discover` | `manage-issue-discover "{description}"` |
387
+ | `issue_analyze` | `maestro-analyze --gaps "{description}"` |
388
+ | `issue_plan` | `maestro-plan --gaps` |
389
+ | `issue_execute` | `maestro-execute` |
390
+ | `quick` | `maestro-quick "{description}"` |
391
+ | `harvest` | `manage-harvest "{description}"` |
392
+ | `wiki` | `manage-wiki` |
393
+ | `wiki_connect` | `wiki-connect` |
394
+ | `wiki_digest` | `wiki-digest` |
395
+ | `business_test` | `quality-auto-test {phase}` |
396
+ | `amend` | `maestro-amend "{description}"` |
397
+ | `release` | `maestro-milestone-release` |
398
+ | `compose` | `maestro-composer "{description}"` |
399
+ | `play` | `maestro-player "{description}"` |
400
+ | `update` | `maestro-update` |
401
+ | `overlay` | `maestro-overlay "{description}"` |
402
+ | `link_coordinate` | `maestro-link-coordinate "{description}"` |
403
+
404
+ **Multi-step chains:**
405
+
406
+ | Chain | Steps (→ = sequential, [B] = context-producing barrier) |
407
+ |-------|---------------------------------------|
408
+ | `feature` | [B] maestro-plan → [B] maestro-execute → maestro-verify |
409
+ | `quality-fix` | [B] maestro-analyze --gaps [B] maestro-plan --gaps [B] maestro-execute → maestro-verify |
410
+ | `deploy` | maestro-verify → maestro-milestone-release |
411
+ | `spec-driven` | maestro-init → [B] maestro-roadmap --mode full → [B] maestro-plan → [B] maestro-execute → maestro-verify |
412
+ | `brainstorm-driven` | [B] maestro-brainstorm → [B] maestro-plan → [B] maestro-execute → maestro-verify |
413
+ | `ui-craft-build` | maestro-impeccable build → [B] maestro-plan → [B] maestro-execute → maestro-verify |
414
+ | `roadmap-driven` | maestro-init → [B] maestro-roadmap → [B] maestro-plan → [B] maestro-execute → maestro-verify |
415
+ | `next-milestone` | [B] maestro-roadmap → [B] maestro-plan → [B] maestro-execute → maestro-verify |
416
+ | `full-lifecycle` | [B] maestro-plan [B] maestro-execute → maestro-verify quality-review quality-test → maestro-milestone-audit → maestro-milestone-complete |
417
+ | `execute-verify` | [B] maestro-execute → maestro-verify |
418
+ | `analyze-plan-execute` | [B] maestro-analyze -q → [B] maestro-plan --dir {scratch_dir} → [B] maestro-execute --dir {scratch_dir} |
419
+ | `quality-loop` | maestro-verify quality-review → quality-test → quality-debug --from-uat → [B] maestro-plan --gaps → [B] maestro-execute |
420
+ | `quality-loop-partial` | [B] maestro-plan --gaps → [B] maestro-execute → maestro-verify |
421
+ | `review-fix` | [B] maestro-plan --gaps → [B] maestro-execute → quality-review |
422
+ | `milestone-close` | maestro-milestone-audit → maestro-milestone-complete |
423
+ | `milestone-release` | maestro-milestone-audit maestro-milestone-release |
424
+ | `phase_transition` | maestro-milestone-audit → maestro-milestone-complete |
425
+ | `issue-full` | [B] maestro-analyze --gaps [B] maestro-plan --gaps [B] maestro-execute quality-review → manage-issue close |
426
+ | `issue-quick` | [B] maestro-plan --gaps [B] maestro-execute manage-issue close |
427
+
428
+ > When S_DECOMPOSE ran, a `decision:post-goal-audit` node is appended as the final node (after the last evidence-producing step; before milestone-complete/close-out if the chain ends with one). `[B]` now denotes a context-producing skill (artifacts read into `session.context`) — execution is still sequential (no parallelism; spawning removed).
429
+
430
+ **Chain Aliases** (taskType chain):
431
+
432
+ | taskType | Chain |
433
+ |----------|-------|
434
+ | `spec_generate` | `spec-driven` |
435
+ | `brainstorm` | `brainstorm-driven` |
436
+ | `issue_execute` | `issue-full` |
437
+
438
+ ### Auto-Yes Flag Map
439
+
440
+ | Skill | Flag |
441
+ |-------|------|
442
+ | maestro-init, maestro-analyze, maestro-brainstorm, maestro-impeccable, maestro-roadmap | `-y` |
443
+ | maestro-plan, maestro-execute, maestro-milestone-complete | `-y` |
444
+ | quality-auto-test, quality-retrospective | `-y` |
445
+ | quality-test | `-y --auto-fix` |
446
+
447
+ ### Context-Producing Skills
448
+
449
+ `maestro-analyze`, `maestro-plan`, `maestro-brainstorm`, `maestro-roadmap`, `maestro-execute` — their artifacts are read into `session.context` after the step completes (see A_EXEC_STEP step 4). Other skills produce no coordinator context. No parallelism — all steps run sequentially.
450
+
451
+ ### Error Codes
452
+
453
+ | Code | Severity | Condition | Recovery |
454
+ |------|----------|-----------|----------|
455
+ | E001 | error | Intent unclassifiable after clarification | Default to `feature` chain |
456
+ | E002 | error | Intent unresolvable after retry | List chains, abort |
457
+ | E003 | error | Step skill invocation failed | auto_mode retry once, then abort chain |
458
+ | E004 | error | Context artifact not found | Retry step once, then abort |
459
+ | E005 | error | --continue: no session found | List sessions, prompt |
460
+ | W001 | warning | Context artifact partial | Continue with available context |
461
+
462
+ ### Success Criteria
463
+
464
+ - [ ] Intent classified and chain resolved
465
+ - [ ] Broad lifecycle intents decomposed (S_DECOMPOSE, ≤3 boundary questions) sharing maestro-ralph contract; narrow/single-step skip
466
+ - [ ] Goal registered via built-in `create_goal`; status.json decomposition fields additive-only
467
+ - [ ] post-goal-audit node appended as final node (after evidence-producing steps); unmet sub-goals dynamically grow steps[] (goal_ref tagged)
468
+ - [ ] Session dir initialized with status.json before first step
469
+ - [ ] Every skill invoked DIRECTLY in-context — NO spawn_agents_on_csv, NO wave/CSV/worker
470
+ - [ ] Sequential execution; status.json + update_plan persisted after every step
471
+ - [ ] Context-producing skills' artifacts read into session.context before next step's args assembled
472
+ - [ ] Failed step → remaining skipped → abort reported (goal held for --continue)
473
+ - [ ] --dry-run shows chain + sub-goal summary, no execution
474
+ - [ ] --continue resumes from first pending step
475
+ - [ ] update_goal released on convergence (A_APPLY_GOAL_DONE / A_FINALIZE); held while aborted
476
+
477
+ ### Report Format
478
+
479
+ ```
480
+ === MAESTRO COMPLETE ===
481
+ Session: {sessionId}
482
+ Chain: {chain}
483
+ Steps: {completed}/{total} Sub-goals: {done}/{total}
484
+
485
+ STEP RESULTS:
486
+ [1] $maestro-analyze --gaps → ✓ found 3 gaps
487
+ [2] $maestro-plan --gaps → ✓ 12 tasks
488
+ [◆] post-goal-audit → ✓ all sub-goals met
489
+ ...
490
+
491
+ State: .workflow/.maestro/{sessionId}/status.json
492
+ Resume: $maestro --continue
493
+ ```
494
+
495
+ </appendix>