Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ temp/
docs/maestro/
docs/superpowers/
hooks/permissions.json
.worktrees
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ This preamble maps generic step references to Gemini CLI tool syntax.
| Load template/reference/protocol | `get_skill_content(resources: ["<name>"])` |
| Delegate to agent | Call agent tool by name: `coder(query: "...")`, `tester(query: "...")`, `design_system_engineer(query: "...")` |
| MCP tools | `mcp_maestro_<tool_name>` (Gemini CLI also accepts bare names like `resolve_settings`) |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then Request Restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Exit Plan Mode | `exit_plan_mode` with `plan_filename` |
| User prompt (choose) | `ask_user` with `type: 'choice'` |
| User prompt (approve) | `ask_user` with `type: 'yesno'` |
| Define Agent Models | `ask_user` for valid mode (`quality`, `balanced`, `economic`, `skip`) and call `setup_models` with the selected mode. Then Request Restart. |
| Request Restart | STOP here and wait for the user to restart and signal to continue. Do NOT proceed. |

## Execute

Expand Down
78 changes: 40 additions & 38 deletions claude/src/references/orchestration-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ STARTUP (Turn 1 — tool calls only, no text output)
6. STOP. Turn 1 is ONLY steps 1-5. No text, no design questions, no file reads.

CLASSIFICATION (Turn 2)
7. Load the architecture reference: ["architecture"]. Do NOT load templates yet — they are loaded at their consumption points (steps 13, 15, 20).
7. Load the architecture reference: ["architecture"]. Do NOT load templates yet — they are loaded at their consumption points (steps 14, 16, 21).
8. Classify task as simple/medium/complex. Present classification with rationale.
9. Route: simple → Express (step 31). Medium/complex → continue to step 10.
9. Route: simple → Express (step 32). Medium/complex → continue to step 10.

DESIGN (Phase 1)
10. Enter Plan Mode. If unavailable, follow the runtime preamble's Plan Mode fallback instructions.
11. Call `get_skill_content` with resources: ["design-dialogue"]. Follow the loaded protocol for:
11. Define Agent Models.
12. Call `get_skill_content` with resources: ["design-dialogue"]. Follow the loaded protocol for:
- Design depth selector (first design question)
- Repository grounding (for existing codebases, skip for greenfield)
- One question at a time via user prompt
Expand All @@ -31,51 +32,51 @@ DESIGN (Phase 1)
WRONG: user requests "fan site" → options include React, Next.js, Astro
CORRECT: user requests "fan site" → recommended option is vanilla HTML/CSS/JS
</ANTI-PATTERN>
12. Present design sections one at a time, per the design-dialogue skill's convergence protocol.
13. Present design sections one at a time, per the design-dialogue skill's convergence protocol.
<HARD-GATE>
Each section must be presented individually and approved via user prompt before
proceeding to the next. Do NOT present the full design as a single block.
Quick depth may combine sections. Standard/Deep MUST validate individually.
</HARD-GATE>
13. Call `get_skill_content` with resources: ["design-document"]. Write approved design document to <state_dir>/plans/ (or Plan Mode tmp path).
14. If Plan Mode is active, exit Plan Mode with the plan path. Copy approved document to <state_dir>/plans/.
14. Call `get_skill_content` with resources: ["design-document"]. Write approved design document to <state_dir>/plans/ (or Plan Mode tmp path).
15. If Plan Mode is active, exit Plan Mode with the plan path. Copy approved document to <state_dir>/plans/.

PLANNING (Phase 2)
15. Call `get_skill_content` with resources: ["implementation-planning", "implementation-plan"]. Follow the loaded skill protocol.
16. Call validate_plan with the generated plan and task_complexity.
16. Call `get_skill_content` with resources: ["implementation-planning", "implementation-plan"]. Follow the loaded skill protocol.
17. Call validate_plan with the generated plan and task_complexity.
<HARD-GATE>
You MUST call validate_plan BEFORE presenting the plan for approval. Do NOT
present the plan, write it to state_dir, or proceed to step 17 without first
present the plan, write it to state_dir, or proceed to step 18 without first
calling validate_plan and resolving any error-severity violations.
validate_plan enforces server-side: phase count limits, dependency cycles,
unknown agents, file ownership conflicts, and agent-deliverable compatibility
(read-only agents cannot be assigned to file-creating phases). If it returns
violations with severity "error", fix them in the plan and re-validate.
</HARD-GATE>
17. Present plan for user approval (Approve / Revise / Abort via user prompt).
18. Write approved implementation plan to <state_dir>/plans/.
18. Present plan for user approval (Approve / Revise / Abort via user prompt).
19. Write approved implementation plan to <state_dir>/plans/.

EXECUTION SETUP (Phase 3 — pre-delegation)
19. Call `get_skill_content` with resources: ["execution"]. Follow its Execution Mode Gate.
20. Call `get_skill_content` with resources: ["execution"]. Follow its Execution Mode Gate.
<HARD-GATE>
Present ONLY "Parallel" and "Sequential" as execution mode options.
Do NOT present "Ask" as a user-facing choice — "ask" is a setting value
that means "prompt the user", not an execution mode the user selects.
</HARD-GATE>
20. Call `get_skill_content` with resources: ["session-management", "session-state"].
21. Create session via create_session with resolved execution_mode. Do NOT create before mode is resolved.
22. Call `get_skill_content` with resources: ["delegation", "validation", "agent-base-protocol", "filesystem-safety-protocol"].
21. Call `get_skill_content` with resources: ["session-management", "session-state"].
22. Create session via create_session with resolved execution_mode. Do NOT create before mode is resolved.
23. Call `get_skill_content` with resources: ["delegation", "validation", "agent-base-protocol", "filesystem-safety-protocol"].

EXECUTION (Phase 3 — delegation loop)
23. For each phase (or parallel batch): call `get_agent` for the assigned agent, then delegate using the returned methodology and tool restrictions.
24. For each phase (or parallel batch): call `get_agent` for the assigned agent, then delegate using the returned methodology and tool restrictions.
<HARD-GATE>
Dispatch by calling the agent's registered tool directly.
Do NOT use the built-in generalist tool or invoke agents by bare name.
Each Maestro agent carries specialized methodology, tool restrictions, temperature,
and turn limits from its frontmatter that the generalist ignores.
</HARD-GATE>
24. After each agent returns, parse Task Report + Downstream Context from response.
25. Call transition_phase to persist results.
25. After each agent returns, parse Task Report + Downstream Context from response.
26. Call transition_phase to persist results.
<HARD-GATE>
For parallel batches: call transition_phase INDIVIDUALLY for EVERY completed
phase in the batch. The MCP tool writes files_created, files_modified,
Expand All @@ -85,73 +86,74 @@ EXECUTION (Phase 3 — delegation loop)
merge all agents' files into one call — the archive attributes files per
phase, so empty payloads mean lost traceability.
</HARD-GATE>
26. Repeat steps 23-25 until all phases complete.
27. Repeat steps 24-26 until all phases complete.

COMPLETION (Phase 4)
27. Call `get_skill_content` with resources: ["code-review"].
28. If execution changed non-documentation files, delegate to the code reviewer agent. Block on Critical/Major findings.
28. Call `get_skill_content` with resources: ["code-review"].
29. If execution changed non-documentation files, delegate to the code reviewer agent. Block on Critical/Major findings.
<HARD-GATE>
If Critical/Major findings: re-delegate to the implementing agent to fix.
The orchestrator MUST NOT write code directly.
</HARD-GATE>
29. If MAESTRO_AUTO_ARCHIVE is true (or unset), call archive_session. If false, inform user session is complete but not archived.
30. Present final summary with files changed, phase outcomes, and next steps.
30. If MAESTRO_AUTO_ARCHIVE is true (or unset), call archive_session. If false, inform user session is complete but not archived.
31. Present final summary with files changed, phase outcomes, and next steps.

RECOVERY (referenced from any step on user request)
If the user says the flow moved too fast: return to the most recent unanswered approval gate.
If the user asks for implementation before approval: remind them Maestro requires approval first.
If the user asks to skip execution-mode: remind them parallel/sequential is required unless MAESTRO_EXECUTION_MODE pins it.
If an answer invalidates a prior choice: restate the updated assumption and re-run the relevant gate.
If delegation collapses to parent session without fallback approval: return to step 19 or re-scope the child-agent work packages.
If delegation collapses to parent session without fallback approval: return to step 20 or re-scope the child-agent work packages.

EXPRESS WORKFLOW (simple tasks only — jumped to from step 9)

EXPRESS MODE GATE BYPASS: Express bypasses the execution-mode gate entirely. Express always dispatches sequentially. Do NOT prompt for parallel/sequential.

EXPRESS MCP FALLBACK: If MCP state tools (create_session, transition_phase, archive_session) are unavailable, fall back to direct file writes on <state_dir>/state/active-session.md.

31. Verify classification is simple. If task requires multiple phases or agents, override to medium → step 10.
32. Verify classification is simple. If task requires multiple phases or agents, override to medium → step 10.
<HARD-GATE>
Express sessions MUST have exactly one implementation phase with exactly one agent.
</HARD-GATE>
32. Ask 1-2 clarifying questions from Area 1 only.
33. Define Agent Models.
34. Ask 1-2 clarifying questions from Area 1 only.
<HARD-GATE>
Each question MUST use the user prompt tool (not plain text). Use the choose
variant with 2-4 options where possible. Do NOT ask questions as plain text
in the model response — the user prompt tool is the only input mechanism.
</HARD-GATE>
33. Present structured Express brief as plain text, then ask for approval.
35. Present structured Express brief as plain text, then ask for approval.
<HARD-GATE>
The brief MUST be plain text output in the model response.
The approval MUST be a SEPARATE user prompt tool call — not embedded in the
brief text. The prompt contains only: "Approve this Express brief to proceed?"
These are two distinct actions: first emit the brief as text, then call the
user prompt tool for approval. Do NOT combine them into one text block.
</HARD-GATE>
34. On approval, create session with workflow_mode: "express", exactly 1 phase.
36. On approval, create session with workflow_mode: "express", exactly 1 phase.
On rejection, revise. On second rejection, escalate to Standard → step 10.
35. Call `get_skill_content` with resources: ["agent-base-protocol", "filesystem-safety-protocol"] and prepend them to the delegation prompt.
36. Delegate to the assigned agent.
37. Call `get_skill_content` with resources: ["agent-base-protocol", "filesystem-safety-protocol"] and prepend them to the delegation prompt.
38. Delegate to the assigned agent.
<HARD-GATE>
Same dispatch rule as step 23: call agent by registered tool name, not generalist.
Same dispatch rule as step 24: call agent by registered tool name, not generalist.
</HARD-GATE>
37. Parse Task Report from the agent's response. Call transition_phase to persist results.
39. Parse Task Report from the agent's response. Call transition_phase to persist results.
<HARD-GATE>
You MUST call transition_phase after the implementing agent returns. Extract
files_created, files_modified, files_deleted, and downstream_context from the
Task Report and pass them to transition_phase. Without this call, the session
state has no record of what was delivered. Do NOT skip to code review or archive
without calling transition_phase first.
</HARD-GATE>
38. Delegate to the code reviewer agent.
40. Delegate to the code reviewer agent.
<HARD-GATE>
If Critical/Major findings: re-delegate to implementing agent (1 retry).
Orchestrator MUST NOT write code directly. If retry fails, escalate to user.
</HARD-GATE>
39. Call archive_session.
40. Present summary.
41. Call archive_session.
42. Present summary.

EXPRESS RESUME (when resuming an Express session from get_session_status)
If phase is pending: re-generate and present brief (step 33). On approval, proceed to delegation (step 36).
If phase is in_progress: re-delegate with same scope (step 36).
If phase is completed but session is in_progress: run code review (step 38), then archive (step 39).
If phase is pending: re-generate and present brief (step 35). On approval, proceed to delegation (step 38).
If phase is in_progress: re-delegate with same scope (step 38).
If phase is completed but session is in_progress: run code review (step 40), then archive (step 41).
4 changes: 3 additions & 1 deletion commands/maestro/orchestrate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ This preamble maps generic step references to Gemini CLI tool syntax.
| Load template/reference/protocol | `get_skill_content(resources: ["<name>"])` |
| Delegate to agent | Call agent tool by name: `coder(query: "...")`, `tester(query: "...")`, `design_system_engineer(query: "...")` |
| MCP tools | `mcp_maestro_<tool_name>` (Gemini CLI also accepts bare names like `resolve_settings`) |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then Request Restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Exit Plan Mode | `exit_plan_mode` with `plan_filename` |
| User prompt (choose) | `ask_user` with `type: 'choice'` |
| User prompt (approve) | `ask_user` with `type: 'yesno'` |
| Define Agent Models | `ask_user` for valid mode (`quality`, `balanced`, `economic`, `skip`) and call `setup_models` with the selected mode. Then Request Restart. |
| Request Restart | STOP here and wait for the user to restart and signal to continue. Do NOT proceed. |

## Execute

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ This preamble maps generic step references to Gemini CLI tool syntax.
| Load template/reference/protocol | `get_skill_content(resources: ["<name>"])` |
| Delegate to agent | Call agent tool by name: `coder(query: "...")`, `tester(query: "...")`, `design_system_engineer(query: "...")` |
| MCP tools | `mcp_maestro_<tool_name>` (Gemini CLI also accepts bare names like `resolve_settings`) |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Enter Plan Mode | `enter_plan_mode` — if unavailable, tell user: "Run `gemini --settings` and set `experimental.plan` to `true`, then Request Restart." Offer to continue without Plan Mode using `ask_user` for approvals. |
| Exit Plan Mode | `exit_plan_mode` with `plan_filename` |
| User prompt (choose) | `ask_user` with `type: 'choice'` |
| User prompt (approve) | `ask_user` with `type: 'yesno'` |
| Define Agent Models | `ask_user` for valid mode (`quality`, `balanced`, `economic`, `skip`) and call `setup_models` with the selected mode. Then Request Restart. |
| Request Restart | STOP here and wait for the user to restart and signal to continue. Do NOT proceed. |

## Execute

Expand Down
Loading