maestro-flow 0.3.48 → 0.4.1

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 (93) hide show
  1. package/.claude/agents/impeccable-agent.md +99 -0
  2. package/.claude/commands/maestro-analyze.md +2 -2
  3. package/.claude/commands/maestro-brainstorm.md +116 -112
  4. package/.claude/commands/maestro-composer.md +5 -0
  5. package/.claude/commands/maestro-impeccable.md +231 -74
  6. package/.claude/commands/maestro-merge.md +3 -0
  7. package/.claude/commands/maestro-roadmap.md +5 -1
  8. package/.claude/commands/maestro.md +3 -3
  9. package/.claude/commands/manage-issue-discover.md +4 -0
  10. package/.claude/commands/quality-refactor.md +3 -0
  11. package/.claude/skills/maestro-help/index/catalog.json +1 -1
  12. package/.claude/skills/maestro-help/phases/01-parse-intent.md +1 -1
  13. package/.codex/skills/maestro/SKILL.md +70 -28
  14. package/.codex/skills/maestro-brainstorm/SKILL.md +19 -2
  15. package/.codex/skills/maestro-composer/SKILL.md +5 -0
  16. package/.codex/skills/maestro-help/catalog.json +1 -1
  17. package/.codex/skills/maestro-impeccable/SKILL.md +230 -97
  18. package/.codex/skills/maestro-merge/SKILL.md +3 -0
  19. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -7
  20. package/.codex/skills/maestro-quick/SKILL.md +1 -1
  21. package/.codex/skills/maestro-roadmap/SKILL.md +1 -1
  22. package/.codex/skills/maestro-tools-execute/SKILL.md +1 -1
  23. package/.codex/skills/maestro-tools-register/SKILL.md +1 -1
  24. package/.codex/skills/quality-refactor/SKILL.md +114 -22
  25. package/chains/_intent-map.json +1 -1
  26. package/chains/singles/ui-design.json +4 -4
  27. package/chains/{ui-design-driven.json → ui-craft-build.json} +8 -8
  28. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js +3 -3
  29. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js.map +1 -1
  30. package/dist/src/commands/delegate.d.ts.map +1 -1
  31. package/dist/src/commands/delegate.js +12 -7
  32. package/dist/src/commands/delegate.js.map +1 -1
  33. package/dist/src/commands/impeccable.d.ts +2 -1
  34. package/dist/src/commands/impeccable.d.ts.map +1 -1
  35. package/dist/src/commands/impeccable.js +80 -1
  36. package/dist/src/commands/impeccable.js.map +1 -1
  37. package/package.json +1 -1
  38. package/templates/planning-roles/ui-designer.md +86 -99
  39. package/templates/workflows/specs/node-catalog.md +1 -1
  40. package/workflows/brainstorm.md +26 -0
  41. package/workflows/cli-tools-usage.md +9 -26
  42. package/workflows/delegate-usage.md +301 -343
  43. package/workflows/impeccable/design.md +462 -0
  44. package/workflows/impeccable/explore.md +157 -0
  45. package/workflows/impeccable/shape.md +4 -0
  46. package/workflows/impeccable/ui-search/__pycache__/core.cpython-313.pyc +0 -0
  47. package/workflows/impeccable/ui-search/__pycache__/design_system.cpython-313.pyc +0 -0
  48. package/workflows/impeccable/ui-search/core.py +262 -0
  49. package/workflows/impeccable/ui-search/data/app-interface.csv +31 -0
  50. package/workflows/impeccable/ui-search/data/charts.csv +26 -0
  51. package/workflows/impeccable/ui-search/data/colors.csv +162 -0
  52. package/workflows/impeccable/ui-search/data/design.csv +1776 -0
  53. package/workflows/impeccable/ui-search/data/draft.csv +1779 -0
  54. package/workflows/impeccable/ui-search/data/google-fonts.csv +1924 -0
  55. package/workflows/impeccable/ui-search/data/icons.csv +106 -0
  56. package/workflows/impeccable/ui-search/data/landing.csv +35 -0
  57. package/workflows/impeccable/ui-search/data/products.csv +162 -0
  58. package/workflows/impeccable/ui-search/data/react-performance.csv +45 -0
  59. package/workflows/impeccable/ui-search/data/stacks/angular.csv +51 -0
  60. package/workflows/impeccable/ui-search/data/stacks/astro.csv +54 -0
  61. package/workflows/impeccable/ui-search/data/stacks/flutter.csv +53 -0
  62. package/workflows/impeccable/ui-search/data/stacks/html-tailwind.csv +56 -0
  63. package/workflows/impeccable/ui-search/data/stacks/jetpack-compose.csv +53 -0
  64. package/workflows/impeccable/ui-search/data/stacks/laravel.csv +51 -0
  65. package/workflows/impeccable/ui-search/data/stacks/nextjs.csv +53 -0
  66. package/workflows/impeccable/ui-search/data/stacks/nuxt-ui.csv +51 -0
  67. package/workflows/impeccable/ui-search/data/stacks/nuxtjs.csv +59 -0
  68. package/workflows/impeccable/ui-search/data/stacks/react-native.csv +52 -0
  69. package/workflows/impeccable/ui-search/data/stacks/react.csv +54 -0
  70. package/workflows/impeccable/ui-search/data/stacks/shadcn.csv +61 -0
  71. package/workflows/impeccable/ui-search/data/stacks/svelte.csv +54 -0
  72. package/workflows/impeccable/ui-search/data/stacks/swiftui.csv +51 -0
  73. package/workflows/impeccable/ui-search/data/stacks/threejs.csv +54 -0
  74. package/workflows/impeccable/ui-search/data/stacks/vue.csv +50 -0
  75. package/workflows/impeccable/ui-search/data/styles.csv +85 -0
  76. package/workflows/impeccable/ui-search/data/typography.csv +74 -0
  77. package/workflows/impeccable/ui-search/data/ui-reasoning.csv +162 -0
  78. package/workflows/impeccable/ui-search/data/ux-guidelines.csv +100 -0
  79. package/workflows/impeccable/ui-search/design_system.py +1148 -0
  80. package/workflows/impeccable/ui-search/prototype-template.html +511 -0
  81. package/workflows/impeccable/ui-search/render-prototype.js +208 -0
  82. package/workflows/impeccable/ui-search/search.py +114 -0
  83. package/workflows/maestro-chain-execute.md +2 -2
  84. package/workflows/maestro.codex.md +3 -3
  85. package/workflows/maestro.md +107 -117
  86. package/workflows/plan.md +1 -1
  87. package/workflows/ui-design.md +1 -1
  88. package/workflows/ui-style.md +1 -1
  89. package/.claude/commands/maestro-ui-craft.md +0 -364
  90. package/.claude/commands/maestro-ui-design.md +0 -104
  91. package/.claude/skills/maestro-impeccable/SKILL.md +0 -169
  92. package/.codex/skills/maestro-ui-craft/SKILL.md +0 -341
  93. package/.codex/skills/maestro-ui-design/SKILL.md +0 -242
@@ -1,343 +1,301 @@
1
- # Delegate Execution Specification
2
-
3
- <purpose>
4
- Unified reference for `maestro delegate` — synchronous task delegation with broker-managed lifecycle, message injection, and MCP notifications.
5
- </purpose>
6
-
7
- **References**: `~/.maestro/cli-tools.json` (tool config), `~/.maestro/templates/cli/` (protocol + prompt templates)
8
-
9
- ---
10
-
11
- ## 1. Quick Reference
12
-
13
- <context>
14
-
15
- ### Command Syntax
16
-
17
- ```bash
18
- maestro delegate "<PROMPT>" [options]
19
- ```
20
-
21
- ### Options
22
-
23
- | Option | Description | Default |
24
- |--------|-------------|---------|
25
- | `--to <tool>` | Explicit tool: gemini, qwen, codex, claude, opencode | First enabled in config |
26
- | `--role <role>` | Capability role: analyze, explore, review, implement, plan, brainstorm, research | — (resolves via config) |
27
- | `--mode <mode>` | `analysis` (read-only) or `write` (create/modify/delete) | `analysis` |
28
- | `--model <model>` | Model override | Tool's `primaryModel` |
29
- | `--cd <dir>` | Working directory | Current directory |
30
- | `--rule <template>` | Load protocol + prompt template | — (optional) |
31
- | `--id <id>` | Execution ID | Auto: `{prefix}-{HHmmss}-{rand4}` |
32
- | `--resume [id]` | Resume previous session (last if no id) | — |
33
- | `--includeDirs <dirs>` | Additional directories (comma-separated) | — |
34
- | `--backend <type>` | Adapter backend: `direct` or `terminal` (tmux/wezterm) | `direct` |
35
-
36
- ### Tool Resolution Priority
37
-
38
- 1. `--to <tool>` — explicit tool selection (backward compat, highest priority)
39
- 2. `--role <role>` — capability-based auto-selection via config
40
- 3. No flag — first enabled tool in config
41
-
42
- ### Role-Based Tool Selection
43
-
44
- Roles map to tools via `cli-tools.json` configuration:
45
- - User-defined roles in `roles` section override built-in defaults
46
- - Workspace `.maestro/cli-tools.json` overrides global `~/.maestro/cli-tools.json`
47
- - Built-in roles: `analyze`, `explore`, `review`, `implement`, `plan`, `brainstorm`, `research`
48
-
49
- ### Mode Definition (Authoritative)
50
-
51
- | Mode | Permission | Auto-Invoke Safe | Use For |
52
- |------|-----------|------------------|---------|
53
- | `analysis` | Read-only | Yes | Review, exploration, diagnosis, architecture analysis |
54
- | `write` | Create/Modify/Delete | No — requires explicit intent | Implementation, bug fixes, refactoring |
55
-
56
- > `--mode` is the **authoritative** permission control. The `MODE:` field inside prompt text is a hint for the agent — both should be consistent, but `--mode` governs actual behavior.
57
- </context>
58
-
59
- ---
60
-
61
- ## 2. Configuration
62
-
63
- <context>
64
-
65
- ### Config File: `~/.maestro/cli-tools.json`
66
-
67
- | Field | Description |
68
- |-------|-------------|
69
- | `enabled` | Tool availability |
70
- | `primaryModel` | Default model |
71
- | `secondaryModel` | Fallback model |
72
- | `tags` | Capability tags (for caller-side routing) |
73
- | `type` | `builtin` / `cli-wrapper` / `api-endpoint` |
74
-
75
- > `api-endpoint` tools support **analysis only** — no file write capability.
76
-
77
- ### Tool Selection
78
-
79
- 1. Explicit `--to` specified → use it (validate enabled)
80
- 2. No `--to` → first enabled tool in config order
81
-
82
- ### Fallback Chain
83
-
84
- Primary model fails → `secondaryModel` → next enabled tool → first enabled (default).
85
-
86
- ### MCP Server Startup
87
-
88
- ```bash
89
- # Claude Code — load Maestro as development MCP server
90
- claude --dangerously-load-development-channels server:maestro --dangerously-skip-permissions
91
- ```
92
-
93
- With MCP connected, all delegate tools are available programmatically.
94
- </context>
95
-
96
- ---
97
-
98
- ## 3. Prompt Construction
99
-
100
- <context>
101
-
102
- ### Assembly Order
103
-
104
- `maestro delegate` builds the final prompt as:
105
-
106
- 1. **Mode protocol** — `~/.maestro/templates/cli/protocols/{mode}-protocol.md`
107
- 2. **User prompt** — the positional `"<PROMPT>"` value
108
- 3. **Rule template** — `~/.maestro/templates/cli/prompts/{rule}.txt` (if `--rule` specified)
109
-
110
- ### Prompt Template (6 Fields)
111
-
112
- ```
113
- PURPOSE: [goal] + [why] + [success criteria]
114
- TASK: [step 1] | [step 2] | [step 3]
115
- MODE: analysis|write
116
- CONTEXT: @[file patterns] | Memory: [prior work context]
117
- EXPECTED: [output format] + [quality criteria]
118
- CONSTRAINTS: [scope limits] | [special requirements]
119
- ```
120
-
121
- - **PURPOSE**: What + Why + Success. Not "Analyze code" but "Identify auth vulnerabilities; success = OWASP Top 10 covered"
122
- - **TASK**: Specific verbs. Not "Review code" but "Scan for SQL injection | Check XSS | Verify CSRF"
123
- - **MODE**: Must match `--mode` flag
124
- - **CONTEXT**: File scope + memory from prior work
125
- - **EXPECTED**: Deliverable format, not just "Report"
126
- - **CONSTRAINTS**: Task-specific limits (vs `--rule` which loads generic templates)
127
-
128
- ### CONTEXT: File Patterns + Directory
129
-
130
- - `@**/*` — all files in working directory (default)
131
- - `@src/**/*.ts` — scoped pattern
132
- - `@../shared/**/*` — sibling directory (**requires `--includeDirs`**)
133
-
134
- **Rule**: If CONTEXT uses `@../dir/**/*`, must add `--includeDirs ../dir`.
135
-
136
- ```bash
137
- maestro delegate "CONTEXT: @**/* @../shared/**/*" --to gemini --mode analysis \
138
- --cd "src/auth" --includeDirs "../shared"
139
- ```
140
-
141
- ### CONTEXT: Memory
142
-
143
- Include when building on previous work:
144
-
145
- ```
146
- Memory: Building on auth refactoring (commit abc123), implementing refresh tokens
147
- Memory: Integration with auth module, using shared error patterns
148
- ```
149
-
150
- ### --rule Templates
151
-
152
- **Universal**: `universal-rigorous-style`, `universal-creative-style`
153
-
154
- **Analysis**: `analysis-trace-code-execution`, `analysis-diagnose-bug-root-cause`, `analysis-analyze-code-patterns`, `analysis-analyze-technical-document`, `analysis-review-architecture`, `analysis-review-code-quality`, `analysis-analyze-performance`, `analysis-assess-security-risks`
155
-
156
- **Planning**: `planning-plan-architecture-design`, `planning-breakdown-task-steps`, `planning-design-component-spec`, `planning-plan-migration-strategy`
157
-
158
- **Development**: `development-implement-feature`, `development-refactor-codebase`, `development-generate-tests`, `development-implement-component-ui`, `development-debug-runtime-issues`
159
-
160
- ### Complete Example
161
-
162
- ```bash
163
- maestro delegate "PURPOSE: Identify OWASP Top 10 vulnerabilities in auth module; success = all critical/high documented with remediation
164
- TASK: Scan for injection flaws | Check auth bypass vectors | Evaluate session management | Assess data exposure
165
- MODE: analysis
166
- CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt + JWT
167
- EXPECTED: Severity matrix, file:line references, remediation snippets, priority ranking
168
- CONSTRAINTS: Focus on authentication | Ignore test files
169
- " --to gemini --mode analysis --rule analysis-assess-security-risks --cd "src/auth"
170
- ```
171
- </context>
172
-
173
- ---
174
-
175
- ## 4. Execution
176
-
177
- <execution>
178
-
179
- ### Calling Convention
180
-
181
- `maestro delegate` runs synchronously — it blocks until the delegate completes. To avoid blocking the conversation, **always** use `run_in_background: true` on the Bash tool call, then stop output immediately and wait for the background completion callback.
182
-
183
- ```
184
- Bash({
185
- command: "maestro delegate \"<PROMPT>\" --to gemini --mode analysis",
186
- run_in_background: true
187
- })
188
- // STOP — do not output anything further
189
- // Wait for Bash background completion callback to receive results
190
- ```
191
-
192
- **Rules:**
193
- - **Never** use foreground Bash for delegate calls — it blocks the conversation for the entire execution duration
194
- - After the `Bash(run_in_background: true)` call, **stop immediately** — no follow-up text, no polling, no `delegate status` checks
195
- - When the background callback arrives, retrieve output with `maestro delegate output <id>`
196
-
197
- ### Execution ID
198
-
199
- ID prefix: gemini→`gem`, qwen→`qwn`, codex→`cdx`, claude→`cld`, opencode→`opc`
200
-
201
- Format: `{prefix}-{HHmmss}-{rand4}` (e.g. `gem-143022-a7f2`)
202
-
203
- Output to stderr: `[MAESTRO_EXEC_ID=<id>]`
204
-
205
- ```bash
206
- maestro delegate "analyze code" --to gemini # auto-ID: gem-143022-a7f2
207
- maestro delegate "fix bug" --to gemini --mode write --id my-task-1 # custom ID
208
- ```
209
-
210
- ### Session Resume
211
-
212
- ```bash
213
- maestro delegate "continue" --to gemini --resume # last session
214
- maestro delegate "continue" --to gemini --resume <id> # specific session
215
- ```
216
-
217
- Resume auto-assembles previous conversation context. Warning emitted when context exceeds 32KB.
218
-
219
- ### Subcommands
220
-
221
- ```bash
222
- # List executions
223
- maestro delegate show # recent 20
224
- maestro delegate show --all # up to 100
225
-
226
- # Inspect state
227
- maestro delegate status <id> # broker + history + snapshot preview
228
- maestro delegate status <id> --events 10 # with more broker events
229
- maestro delegate tail <id> # recent events + history
230
- maestro delegate tail <id> --events 20 --history 20
231
-
232
- # Get result
233
- maestro delegate output <id> # last reply only (after last tool call)
234
- maestro delegate output <id> --full # full output (all turns)
235
- maestro delegate output <id> --verbose # include start/end timestamps
236
-
237
- # Lifecycle control
238
- maestro delegate cancel <id> # request cancellation
239
-
240
- # Message delivery
241
- maestro delegate message <id> "text" # inject into running worker
242
- maestro delegate message <id> "text" --delivery after_complete # chain after done
243
- maestro delegate messages <id> # list queued messages
244
- ```
245
-
246
- ### MCP Tools
247
-
248
- All subcommands are also available as MCP tools for programmatic access:
249
-
250
- | CLI Subcommand | MCP Tool | Extra Params |
251
- |---------------|----------|-------------|
252
- | `message <id> "text"` | `delegate_message` | `delivery` (inject/after_complete) |
253
- | `messages <id>` | `delegate_messages` | — |
254
- | `status <id>` | `delegate_status` | `eventLimit` |
255
- | `output <id>` | `delegate_output` | — |
256
- | `tail <id>` | `delegate_tail` | `limit` |
257
- | `cancel <id>` | `delegate_cancel` | — |
258
-
259
- ### Snapshot & Preview
260
-
261
- `delegate status` includes a `Preview:` field showing the agent's latest output — built from `assistant_message`, `tool_use` completions, and `file_change` events.
262
-
263
- ### Job Lifecycle
264
-
265
- ```
266
- queued → running → completed
267
- failed
268
- → cancelled
269
-
270
- input_required
271
- ```
272
-
273
- ### Message Delivery
274
-
275
- | Mode | Behavior | Use For |
276
- |------|----------|---------|
277
- | `inject` | Routes to running worker stdin; non-interactive adapters auto cancel + relaunch | Supplementary context, course correction |
278
- | `after_complete` | Queues message; relaunches delegate with queued message on completion | Chained tasks, post-processing |
279
-
280
- </execution>
281
-
282
- ---
283
-
284
- ## 5. Auto-Invoke Triggers
285
-
286
- <execution>
287
-
288
- Proactively invoke `maestro delegate` when these conditions are met — no user confirmation needed for `analysis` mode:
289
-
290
- | Trigger | Suggested Rule |
291
- |---------|---------------|
292
- | Self-repair fails (1+ attempts) | `analysis-diagnose-bug-root-cause` |
293
- | Ambiguous requirements | `planning-breakdown-task-steps` |
294
- | Architecture decisions needed | `planning-plan-architecture-design` |
295
- | Pattern uncertainty | `analysis-analyze-code-patterns` |
296
- | Critical/security code paths | `analysis-assess-security-risks` |
297
-
298
- ### Principles
299
-
300
- - Default `--mode analysis` (safe, read-only)
301
- - Always `Bash(run_in_background: true)` — stop immediately, wait for callback
302
- - Use `--role` for capability-based tool selection; fallback chain is config-driven
303
- - Rule suggestions are guidelines — choose the best fit
304
- - Use `inject` for supplementary context mid-execution; `after_complete` for chained multi-step tasks
305
- </execution>
306
-
307
- ---
308
-
309
- ## 6. Workflows
310
-
311
- <execution>
312
-
313
- ### Basic Usage
314
-
315
- ```
316
- Bash({
317
- command: 'maestro delegate "analyze auth module" --to gemini',
318
- run_in_background: true
319
- })
320
- // → STOP, wait for callback
321
- // → on callback: maestro delegate output <id>
322
- ```
323
-
324
- ### Inject Supplementary Context
325
-
326
- ```bash
327
- maestro delegate message gem-143022-a7f2 "Also check src/utils/sanitize.ts"
328
- # → accepted: true, delivery: inject
329
- ```
330
-
331
- ### Chain: Analyze → Fix
332
-
333
- ```
334
- Bash({
335
- command: 'maestro delegate "find SQL injection vulnerabilities" --to gemini',
336
- run_in_background: true
337
- })
338
- // → STOP, wait for callback
339
- // → on callback: chain next step
340
- maestro delegate message gem-143022-a7f2 "Fix all critical vulnerabilities" --delivery after_complete
341
- // → queued, relaunches after analysis completes
342
- ```
343
- </execution>
1
+ # Delegate Execution Specification
2
+
3
+ <purpose>
4
+ Unified reference for `maestro delegate` — synchronous task delegation with broker-managed lifecycle, message injection, and MCP notifications.
5
+ </purpose>
6
+
7
+ **References**: `~/.maestro/cli-tools.json` (tool config), `~/.maestro/templates/cli/` (protocol + prompt templates)
8
+
9
+ ---
10
+
11
+ ## 1. Quick Reference
12
+
13
+ <context>
14
+
15
+ ### Command Syntax
16
+
17
+ ```bash
18
+ maestro delegate "<PROMPT>" [options]
19
+ ```
20
+
21
+ ### Options
22
+
23
+ | Option | Description | Default |
24
+ |--------|-------------|---------|
25
+ | `--to <tool>` | Explicit tool: gemini, qwen, codex, claude, opencode | First enabled in config |
26
+ | `--role <role>` | Capability role: analyze, explore, review, implement, plan, brainstorm, research | — (resolves via config) |
27
+ | `--mode <mode>` | `analysis` (read-only) or `write` (create/modify/delete) | `analysis` |
28
+ | `--model <model>` | Model override | Tool's `primaryModel` |
29
+ | `--cd <dir>` | Working directory | Current directory |
30
+ | `--rule <template>` | Load protocol + prompt template | — (optional) |
31
+ | `--id <id>` | Execution ID | Auto: `{prefix}-{HHmmss}-{rand4}` |
32
+ | `--resume [id]` | Resume previous session (last if no id) | — |
33
+ | `--includeDirs <dirs>` | Additional directories (comma-separated) | — |
34
+ | `--backend <type>` | Adapter backend: `direct` or `terminal` (tmux/wezterm) | `direct` |
35
+
36
+ ### Tool Resolution Priority
37
+
38
+ 1. `--to <tool>` — explicit tool selection (backward compat, highest priority)
39
+ 2. `--role <role>` — capability-based auto-selection via config
40
+ 3. No flag — first enabled tool in config
41
+
42
+ ### Role-Based Tool Selection
43
+
44
+ Roles map to tools via `cli-tools.json` configuration:
45
+ - User-defined roles in `roles` section override built-in defaults
46
+ - Workspace `.maestro/cli-tools.json` overrides global `~/.maestro/cli-tools.json`
47
+ - Built-in roles: `analyze`, `explore`, `review`, `implement`, `plan`, `brainstorm`, `research`
48
+
49
+ ### Mode Definition (Authoritative)
50
+
51
+ | Mode | Permission | Auto-Invoke Safe | Use For |
52
+ |------|-----------|------------------|---------|
53
+ | `analysis` | Read-only | Yes | Review, exploration, diagnosis, architecture analysis |
54
+ | `write` | Create/Modify/Delete | No — requires explicit intent | Implementation, bug fixes, refactoring |
55
+
56
+ > `--mode` is the **authoritative** permission control. The `MODE:` field inside prompt text is a hint for the agent — both should be consistent, but `--mode` governs actual behavior.
57
+ </context>
58
+
59
+ ---
60
+
61
+ ## 2. Configuration
62
+
63
+ <context>
64
+
65
+ ### Config File: `~/.maestro/cli-tools.json`
66
+
67
+ | Field | Description |
68
+ |-------|-------------|
69
+ | `enabled` | Tool availability |
70
+ | `primaryModel` | Default model |
71
+ | `secondaryModel` | Fallback model |
72
+ | `tags` | Capability tags (for caller-side routing) |
73
+ | `type` | `builtin` / `cli-wrapper` / `api-endpoint` |
74
+
75
+ > `api-endpoint` tools support **analysis only** — no file write capability.
76
+
77
+ ### Tool Selection
78
+
79
+ 1. Explicit `--to` specified → use it (validate enabled)
80
+ 2. No `--to` → first enabled tool in config order
81
+
82
+ ### Fallback Chain
83
+
84
+ Primary model fails → `secondaryModel` → next enabled tool → first enabled (default).
85
+
86
+ ### MCP Server Startup
87
+
88
+ ```bash
89
+ # Claude Code — load Maestro as development MCP server
90
+ claude --dangerously-load-development-channels server:maestro --dangerously-skip-permissions
91
+ ```
92
+
93
+ With MCP connected, all delegate tools are available programmatically.
94
+ </context>
95
+
96
+ ---
97
+
98
+ ## 3. Prompt Construction
99
+
100
+ <context>
101
+
102
+ ### Assembly Order
103
+
104
+ `maestro delegate` builds the final prompt as:
105
+
106
+ 1. **Mode protocol** — `~/.maestro/templates/cli/protocols/{mode}-protocol.md`
107
+ 2. **User prompt** — the positional `"<PROMPT>"` value
108
+ 3. **Rule template** — `~/.maestro/templates/cli/prompts/{rule}.txt` (if `--rule` specified)
109
+
110
+ ### Prompt Template (6 Fields)
111
+
112
+ ```
113
+ PURPOSE: [goal] + [why] + [success criteria]
114
+ TASK: [step 1] | [step 2] | [step 3]
115
+ MODE: analysis|write
116
+ CONTEXT: @[file patterns] | Memory: [prior work context]
117
+ EXPECTED: [output format] + [quality criteria]
118
+ CONSTRAINTS: [scope limits] | [special requirements]
119
+ ```
120
+
121
+ - **PURPOSE**: What + Why + Success. Not "Analyze code" but "Identify auth vulnerabilities; success = OWASP Top 10 covered"
122
+ - **TASK**: Specific verbs. Not "Review code" but "Scan for SQL injection | Check XSS | Verify CSRF"
123
+ - **MODE**: Must match `--mode` flag
124
+ - **CONTEXT**: File scope + memory from prior work
125
+ - **EXPECTED**: Deliverable format, not just "Report"
126
+ - **CONSTRAINTS**: Task-specific limits (vs `--rule` which loads generic templates)
127
+
128
+ ### CONTEXT: File Patterns + Directory
129
+
130
+ - `@**/*` — all files in working directory (default)
131
+ - `@src/**/*.ts` — scoped pattern
132
+ - `@../shared/**/*` — sibling directory (**requires `--includeDirs`**)
133
+
134
+ **Rule**: If CONTEXT uses `@../dir/**/*`, must add `--includeDirs ../dir`.
135
+
136
+ ```bash
137
+ maestro delegate "CONTEXT: @**/* @../shared/**/*" --to gemini --mode analysis \
138
+ --cd "src/auth" --includeDirs "../shared"
139
+ ```
140
+
141
+ ### CONTEXT: Memory
142
+
143
+ Include when building on previous work:
144
+
145
+ ```
146
+ Memory: Building on auth refactoring (commit abc123), implementing refresh tokens
147
+ Memory: Integration with auth module, using shared error patterns
148
+ ```
149
+
150
+ ### --rule Templates
151
+
152
+ **Universal**: `universal-rigorous-style`, `universal-creative-style`
153
+
154
+ **Analysis**: `analysis-trace-code-execution`, `analysis-diagnose-bug-root-cause`, `analysis-analyze-code-patterns`, `analysis-analyze-technical-document`, `analysis-review-architecture`, `analysis-review-code-quality`, `analysis-analyze-performance`, `analysis-assess-security-risks`
155
+
156
+ **Planning**: `planning-plan-architecture-design`, `planning-breakdown-task-steps`, `planning-design-component-spec`, `planning-plan-migration-strategy`
157
+
158
+ **Development**: `development-implement-feature`, `development-refactor-codebase`, `development-generate-tests`, `development-implement-component-ui`, `development-debug-runtime-issues`
159
+
160
+ ### Complete Example
161
+
162
+ ```bash
163
+ maestro delegate "PURPOSE: Identify OWASP Top 10 vulnerabilities in auth module; success = all critical/high documented with remediation
164
+ TASK: Scan for injection flaws | Check auth bypass vectors | Evaluate session management | Assess data exposure
165
+ MODE: analysis
166
+ CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt + JWT
167
+ EXPECTED: Severity matrix, file:line references, remediation snippets, priority ranking
168
+ CONSTRAINTS: Focus on authentication | Ignore test files
169
+ " --to gemini --mode analysis --rule analysis-assess-security-risks --cd "src/auth"
170
+ ```
171
+ </context>
172
+
173
+ ---
174
+
175
+ ## 4. Execution
176
+
177
+ <execution>
178
+
179
+ ### Calling Convention
180
+
181
+ `maestro delegate` runs synchronously. Status summary and output are **auto-appended** on completion no manual `output` or `status` commands needed.
182
+
183
+ **Always** use `run_in_background: true` and **end your response immediately**:
184
+
185
+ ```
186
+ Bash({ command: "maestro delegate \"...\" --to gemini --mode analysis", run_in_background: true })
187
+ ```
188
+
189
+ When the background callback arrives, the result is already included:
190
+ ```
191
+ [MAESTRO_EXEC_ID=gem-143022-a7f2] ← at start
192
+ [DELEGATE COMPLETED] gem-143022-a7f2 gemini/analysis ← status, on completion
193
+ --- Output ---
194
+ <actual output content> ← output, on completion
195
+ ```
196
+
197
+ **Rules:**
198
+ - NEVER use foreground Bash for delegate calls
199
+ - NEVER output text or tool calls after the `run_in_background` Bash call
200
+ - When the callback arrives, output is already included — directly use it
201
+
202
+ ### Execution ID
203
+
204
+ ID prefix: gemini→`gem`, qwen→`qwn`, codex→`cdx`, claude→`cld`, opencode→`opc`
205
+
206
+ ```bash
207
+ maestro delegate "<PROMPT>" --to gemini --mode analysis # auto-ID: gem-143022-a7f2
208
+ maestro delegate "<PROMPT>" --to gemini --mode write --id my-task-1 # custom ID
209
+ ```
210
+
211
+ ### Session Resume
212
+
213
+ ```bash
214
+ maestro delegate "<PROMPT>" --to gemini --resume # last session
215
+ maestro delegate "<PROMPT>" --to gemini --mode write --resume <id> # specific
216
+ maestro delegate "<PROMPT>" --to gemini --resume <id1>,<id2> # merge multiple
217
+ ```
218
+
219
+ Resume auto-assembles previous conversation context. Warning emitted when context exceeds 32KB.
220
+
221
+ ### Job Lifecycle
222
+
223
+ ```
224
+ queued running completed
225
+ → failed
226
+ cancelled
227
+
228
+ input_required
229
+ ```
230
+
231
+ ### Message Delivery
232
+
233
+ | Mode | Behavior | Use For |
234
+ |------|----------|---------|
235
+ | `inject` | Routes to running worker stdin; non-interactive adapters auto cancel + relaunch | Supplementary context, course correction |
236
+ | `after_complete` | Queues message; relaunches delegate with queued message on completion | Chained tasks, post-processing |
237
+
238
+ </execution>
239
+
240
+ ---
241
+
242
+ ## 5. Auto-Invoke Triggers
243
+
244
+ <execution>
245
+
246
+ Proactively invoke `maestro delegate` when these conditions are met — no user confirmation needed for `analysis` mode:
247
+
248
+ | Trigger | Suggested Rule |
249
+ |---------|---------------|
250
+ | Self-repair fails (1+ attempts) | `analysis-diagnose-bug-root-cause` |
251
+ | Ambiguous requirements | `planning-breakdown-task-steps` |
252
+ | Architecture decisions needed | `planning-plan-architecture-design` |
253
+ | Pattern uncertainty | `analysis-analyze-code-patterns` |
254
+ | Critical/security code paths | `analysis-assess-security-risks` |
255
+
256
+ ### Principles
257
+
258
+ - Default `--mode analysis` (safe, read-only)
259
+ - Always `Bash(run_in_background: true)` — stop immediately, wait for callback
260
+ - Use `--role` for capability-based tool selection; fallback chain is config-driven
261
+ - Rule suggestions are guidelines choose the best fit
262
+ - Use `inject` for supplementary context mid-execution; `after_complete` for chained multi-step tasks
263
+ </execution>
264
+
265
+ ---
266
+
267
+ ## 6. Workflows
268
+
269
+ <execution>
270
+
271
+ ### Basic Usage
272
+
273
+ ```
274
+ Bash({
275
+ command: 'maestro delegate "analyze auth module" --to gemini',
276
+ run_in_background: true
277
+ })
278
+ // STOP, wait for callback
279
+ // → callback includes status + output automatically
280
+ ```
281
+
282
+ ### Inject Supplementary Context
283
+
284
+ ```bash
285
+ maestro delegate message gem-143022-a7f2 "Also check src/utils/sanitize.ts"
286
+ # → accepted: true, delivery: inject
287
+ ```
288
+
289
+ ### Chain: Analyze → Fix
290
+
291
+ ```
292
+ Bash({
293
+ command: 'maestro delegate "find SQL injection vulnerabilities" --to gemini',
294
+ run_in_background: true
295
+ })
296
+ // STOP, wait for callback
297
+ // → on callback: chain next step
298
+ maestro delegate message gem-143022-a7f2 "Fix all critical vulnerabilities" --delivery after_complete
299
+ // → queued, relaunches after analysis completes
300
+ ```
301
+ </execution>