maestro-flow 0.3.25 → 0.3.26

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.
@@ -26,11 +26,9 @@ Produces session directory at `.workflow/.maestro/{session_id}/` with status.jso
26
26
  Executes commands sequentially with artifact propagation between steps.
27
27
  </purpose>
28
28
 
29
- <required_reading>
30
- @~/.maestro/workflows/maestro.md
31
- </required_reading>
32
-
33
29
  <deferred_reading>
30
+ - [maestro.md](~/.maestro/workflows/maestro.md) — read at execution start (Steps 1-3: intent analysis, chain selection, session setup)
31
+ - [maestro-chain-execute.md](~/.maestro/workflows/maestro-chain-execute.md) — read when dispatching chain execution (Step 4b) or resume mode (Step 1b)
34
32
  - [maestro-super.md](~/.maestro/workflows/maestro-super.md) — read when `--super` flag is active
35
33
  </deferred_reading>
36
34
 
@@ -56,7 +54,9 @@ $ARGUMENTS — user intent text, or special keywords.
56
54
  </context>
57
55
 
58
56
  <execution>
59
- Follow '~/.maestro/workflows/maestro.md' completely.
57
+ **Resume mode (`-c`):** Skip selection workflow entirely — scan `.workflow/.maestro/` for latest session, then read `~/.maestro/workflows/maestro-chain-execute.md` and follow it with `$SESSION_PATH` = discovered session path. **End.**
58
+
59
+ **Normal mode:** Read `~/.maestro/workflows/maestro.md` from deferred_reading, then follow it completely.
60
60
 
61
61
  **Auto mode (`-y`) propagation:**
62
62
 
@@ -111,11 +111,10 @@ Context cleanup hints, context window reminders, and completion report format ar
111
111
  - [ ] Per-step engine selected (auto routes heavy steps to CLI, observable steps to internal)
112
112
  - [ ] Auto flags correctly propagated to supporting commands only
113
113
  - [ ] Session directory created at .workflow/.maestro/{session_id}/
114
- - [ ] status.json tracks per-step progress and execution engine
115
- - [ ] All chain steps executed via internal or CLI delegate with proper argument propagation
114
+ - [ ] status.json created with steps[], context, and tracking fields
115
+ - [ ] Low-complexity intents routed to maestro-quick
116
+ - [ ] All chains dispatched via execution workflow (maestro-chain-execute.md) with status.json tracking
116
117
  - [ ] Phase numbers auto-detected and passed to downstream commands
117
- - [ ] Error handling: retry/skip/abort per step (auto-skip in -y mode)
118
- - [ ] Session summary displayed on completion
119
118
  - [ ] (super mode) Requirements expanded and validated via Gemini before roadmap creation
120
119
  - [ ] (super mode) Each milestone scored ≥ 80% before advancing
121
120
  - [ ] (super mode) All milestones completed with no user intervention
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maestro-flow",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "description": "Workflow orchestration CLI with MCP endpoint support and extensible architecture",
5
5
  "type": "module",
6
6
  "imports": {
@@ -0,0 +1,204 @@
1
+ # Workflow: maestro-chain-execute
2
+
3
+ Upgraded version of maestro's original direct execution strategy.
4
+ Reads session status.json, loops through steps with per-step engine selection,
5
+ context propagation, post-step Gemini analysis, and error handling.
6
+ Tracks all progress via status.json (the JSON file created during selection).
7
+
8
+ **Prerequisites:**
9
+ - Session directory with valid status.json (status: "running", pending steps)
10
+ - $SESSION_PATH passed from maestro.md dispatch
11
+
12
+ ## Step 1: Load Session
13
+
14
+ Read status.json from `$SESSION_PATH`.
15
+
16
+ Extract: `session_id`, `chain_name`, `steps[]`, `context`, `auto_mode`, `exec_mode`, `cli_tool`, `gemini_session_id`.
17
+
18
+ Set `$STEP_INDEX` = `current_step` (first pending step).
19
+
20
+ Validate: `status == "running"` and at least one pending step exists.
21
+
22
+ Display banner:
23
+
24
+ ```
25
+ ============================================================
26
+ CHAIN EXECUTOR
27
+ ============================================================
28
+ Session: {session_id}
29
+ Chain: {chain_name}
30
+ Steps: {completed}/{total} done, starting from step {$STEP_INDEX}
31
+ Auto: {auto_mode}
32
+ Exec: {exec_mode}
33
+ ```
34
+
35
+ ## Step 2: Context & Argument Assembly
36
+
37
+ Initialize context object from `status.json.context`:
38
+
39
+ ```
40
+ context = {
41
+ current_phase, // from status.json.context or top-level phase
42
+ user_intent, // from status.json.context or top-level intent
43
+ issue_id,
44
+ spec_session_id,
45
+ scratch_dir,
46
+ auto_mode // from status.json.auto_mode
47
+ }
48
+ ```
49
+
50
+ ### assembleArgs(step)
51
+
52
+ ```
53
+ 1. Substitute placeholders in step.args:
54
+ {phase} → context.current_phase
55
+ {description} → context.user_intent
56
+ {issue_id} → context.issue_id
57
+ {spec_session_id} → context.spec_session_id
58
+ {scratch_dir} → context.scratch_dir
59
+
60
+ 2. In auto_mode, append per-command flag if not already present:
61
+ maestro-analyze / maestro-brainstorm / maestro-roadmap / maestro-ui-design → -y
62
+ maestro-plan → --auto
63
+ quality-test → --auto-fix
64
+ quality-retrospective → --auto-yes
65
+
66
+ 3. Shell-escape strings with single quotes for CLI delegate calls.
67
+ ```
68
+
69
+ ## Step 3: Step Loop
70
+
71
+ For each step starting at `$STEP_INDEX`:
72
+
73
+ ### 3a. Select engine & display banner
74
+
75
+ Per-step engine selection:
76
+
77
+ ```
78
+ If exec_mode is 'cli' or 'skill' → force that engine for all steps.
79
+
80
+ In 'auto' mode, select per step:
81
+ CLI steps (heavy, context-isolated):
82
+ maestro-plan, maestro-execute, maestro-analyze, maestro-brainstorm,
83
+ maestro-roadmap, maestro-ui-design, quality-refactor
84
+
85
+ Skill steps (observable, interactive, lightweight):
86
+ everything else — verify, review, test, debug, milestone-*,
87
+ manage-*, spec-*, quick, etc.
88
+ ```
89
+
90
+ Display: `[Step {N}/{total}] /{cmd} [{engine}] — {args}`
91
+
92
+ Update status.json: step `status = "running"`, `engine`, `started_at`.
93
+
94
+ Context window hint:
95
+ - Step >= 4 and not autoYes: hint user about `/maestro -c` for fresh context resume.
96
+ - autoYes and step >= 5: log warning to status.json.
97
+
98
+ ### 3b. Execute (engine-dependent)
99
+
100
+ **Skill engine** — invoke directly (synchronous, visible):
101
+
102
+ ```
103
+ Skill({ skill: step.cmd, args: assembledArgs })
104
+ ```
105
+
106
+ **CLI engine** — template-driven, async, context-isolated:
107
+
108
+ ```
109
+ 1. Load template ~/.maestro/templates/cli/prompts/coordinate-step.txt
110
+ 2. Build analysisHints from previous step's next_step_hints
111
+ (prompt_additions, cautions, context_to_carry)
112
+ 3. Substitute template placeholders:
113
+ {{COMMAND}}, {{ARGS}}, {{STEP_N}}, {{AUTO_DIRECTIVE}},
114
+ {{CHAIN_NAME}}, {{ANALYSIS_HINTS}}
115
+ 4. Run:
116
+ Bash(maestro delegate "<prompt>" --to {cli_tool} --mode write,
117
+ run_in_background: true, timeout: 600000)
118
+ 5. **STOP** — wait for background callback
119
+ ```
120
+
121
+ ### 3c. Parse output & update context
122
+
123
+ Scan step output for context propagation:
124
+
125
+ ```
126
+ PHASE: N → context.current_phase
127
+ SPEC-xxx → context.spec_session_id
128
+ scratch_dir: path → context.scratch_dir
129
+ ```
130
+
131
+ CLI: capture `exec_id` from stderr `[MAESTRO_EXEC_ID=<id>]`.
132
+
133
+ **Persist context back to status.json** after each step — write updated `context` field and `current_step`. This enables resume via `/maestro -c`.
134
+
135
+ ### 3d. Handle result
136
+
137
+ **Success:** mark step `status = "completed"`, set `completed_at` in status.json.
138
+ CLI: save output to `step-{N}-output.txt` in session directory.
139
+
140
+ **Failure:**
141
+ - `auto_mode` → retry once, then skip (mark `"skipped"`).
142
+ - Interactive → offer: Retry (max 2) / Skip / Abort.
143
+ - Abort → **Error E003** — update status.json `status = "aborted"`, display resume hint: `/maestro -c`.
144
+
145
+ ### 3e. Post-step analysis (CLI steps only)
146
+
147
+ Skip if: step failed/skipped, or `engine == 'skill'`.
148
+
149
+ Delegate to gemini (analysis mode, `--resume` if `gemini_session_id` exists) with prompt containing:
150
+ - Step command, args, chain name, intent
151
+ - Last 200 lines of step output
152
+ - Next step info (command, args) if any
153
+
154
+ Expected JSON response:
155
+
156
+ ```json
157
+ {
158
+ "quality_score": "<0-100>",
159
+ "execution_assessment": {
160
+ "success": "<bool>",
161
+ "completeness": "<full|partial|minimal>",
162
+ "key_outputs": [],
163
+ "missing_outputs": []
164
+ },
165
+ "issues": [
166
+ { "severity": "critical|high|medium|low", "description": "" }
167
+ ],
168
+ "next_step_hints": {
169
+ "prompt_additions": "<extra context for next step>",
170
+ "cautions": ["<things to watch out for>"],
171
+ "context_to_carry": "<key facts from this step>"
172
+ },
173
+ "step_summary": ""
174
+ }
175
+ ```
176
+
177
+ On callback:
178
+ 1. Capture gemini `exec_id` → store as `gemini_session_id` in status.json for session continuity.
179
+ 2. Store analysis in `step_analyses[]` and `step-{N}-analysis.json` in session directory.
180
+ 3. Advance to next step (**3a**).
181
+
182
+ ## Step 4: Completion Report
183
+
184
+ Update status.json: `status = "completed"`.
185
+
186
+ ```
187
+ ============================================================
188
+ MAESTRO SESSION COMPLETE
189
+ ============================================================
190
+ Session: {session_id}
191
+ Chain: {chain_name}
192
+ Steps: {completed}/{total} completed
193
+ Phase: {context.current_phase}
194
+
195
+ Results:
196
+ [✓] 1. maestro-plan — completed [cli] (quality: 85/100)
197
+ [✓] 2. maestro-verify — completed [skill]
198
+ [—] 3. quality-review — skipped [skill]
199
+
200
+ CLI Avg Quality: {avgScore}/100 (based on {cliStepCount} cli steps)
201
+
202
+ Next: /maestro continue | /manage-status
203
+ ============================================================
204
+ ```
@@ -20,16 +20,7 @@ Parse $ARGUMENTS → extract flags, remainder is intent text.
20
20
  intent = arguments with all flags/valued options stripped, trimmed
21
21
  ```
22
22
 
23
- ### 1b: Handle resume mode
24
-
25
- If `resumeMode`:
26
- 1. Scan `.workflow/.maestro/` for latest session (or session ID if specified)
27
- 2. Read `status.json` → find last completed step, remaining steps
28
- 3. Set `$CHAIN` from status.json, `$STEP_INDEX` = last_completed + 1
29
- 4. If no session found: **Error E004** — list available sessions
30
- 5. Jump to **Step 4** at resume point
31
-
32
- ### 1c: Read project state
23
+ ### 1b: Read project state
33
24
 
34
25
  Check `.workflow/state.json` existence.
35
26
 
@@ -54,7 +45,7 @@ Check `.workflow/state.json` existence.
54
45
 
55
46
  **If missing:** `$PROJECT_STATE = { initialized: false }`. If intent also empty → **Error E001** (suggest `maestro-init`).
56
47
 
57
- ### 1d: Display banner
48
+ ### 1c: Display banner
58
49
 
59
50
  ```
60
51
  ============================================================
@@ -267,105 +258,36 @@ Create session directory `.workflow/.maestro/maestro-{YYYYMMDD-HHMMSS}/` and wri
267
258
  "cli_tool": "{cliTool}",
268
259
  "gemini_session_id": null,
269
260
  "step_analyses": [],
261
+ "context": {
262
+ "current_phase": "{resolved_phase}",
263
+ "user_intent": "{original_intent}",
264
+ "issue_id": "{resolved_issue_id or null}",
265
+ "spec_session_id": null,
266
+ "scratch_dir": null
267
+ },
270
268
  "steps": [{ "index": 0, "skill": "{cmd}", "args": "{args}", "engine": null, "status": "pending", "started_at": null, "completed_at": null }],
271
269
  "current_step": 0,
272
270
  "status": "running"
273
271
  }
274
272
  ```
275
273
 
276
- ## Step 4: Execute Chain
277
-
278
- ### Shared: context & argument assembly
279
-
280
- ```
281
- Context object tracks: current_phase, user_intent, issue_id, spec_session_id, scratch_dir, auto_mode.
282
-
283
- assembleArgs: substitute placeholders {phase}, {description}, {issue_id}, {spec_session_id}, {scratch_dir} in step.args.
284
- In auto_mode, append per-command flag if not already present:
285
- maestro-analyze/brainstorm/roadmap/ui-design → -y
286
- maestro-plan → --auto
287
- quality-test → --auto-fix
288
- quality-retrospective → --auto-yes
289
-
290
- Shell-escape strings with single quotes for CLI delegate calls.
291
- ```
292
-
293
- ### Step loop — for each step starting at `$STEP_INDEX` (default 0):
294
-
295
- **4a. Select engine & display banner:**
296
-
297
- Select engine per step (see 3e). Display step banner with index, command name, engine, args.
298
- - Step >= 4 and not autoYes: hint user about `/maestro -c` for fresh context resume.
299
- - autoYes and step >= 5: log warning to status.json.
300
- - Update status.json: step status = `"running"`, engine, started_at.
301
-
302
- **4b. Execute (engine-dependent):**
303
-
304
- **Skill** — invoke `Skill({ skill: step.cmd, args: assembledArgs })` directly (synchronous, visible).
305
-
306
- **CLI** — template-driven, async, context-isolated:
307
- 1. Load template `~/.maestro/templates/cli/prompts/coordinate-step.txt`
308
- 2. Build `analysisHints` from previous step's `next_step_hints` (prompt_additions, cautions, context_to_carry)
309
- 3. Substitute template placeholders: `{{COMMAND}}`, `{{ARGS}}`, `{{STEP_N}}`, `{{AUTO_DIRECTIVE}}`, `{{CHAIN_NAME}}`, `{{ANALYSIS_HINTS}}`
310
- 4. Run `maestro delegate <prompt> --to {cliTool} --mode write` via `Bash(run_in_background: true, timeout: 600000)`
311
- 5. **STOP** — wait for background callback
312
-
313
- **4c. Parse output & update context:**
314
-
315
- Scan step output for context propagation: `PHASE: N` → current_phase, `SPEC-xxx` → spec_session_id, `scratch_dir: path` → scratch_dir. CLI: capture exec_id from stderr.
316
-
317
- **4d. Handle result:**
318
-
319
- Success: mark `"completed"` in status.json. CLI: save output to `step-{N}-output.txt`.
320
- Failure: autoYes → retry once then skip. Interactive → Retry (max 2) / Skip / Abort. Abort → **Error E003** with resume hint.
321
-
322
- **4e. Post-step analysis (CLI steps only, multi-step chains):**
323
-
324
- Skip if: step failed/skipped, single-step chain, or `stepEngine === 'skill'`.
325
-
326
- Delegate to gemini (analysis mode, `--resume` if prior gemini_session_id exists) with prompt containing:
327
- - Step command, args, chain name, intent
328
- - Last 200 lines of step output
329
- - Next step info (if any)
330
-
331
- Expected JSON response:
332
- ```json
333
- {
334
- "quality_score": "<0-100>",
335
- "execution_assessment": { "success": "<bool>", "completeness": "<full|partial|minimal>", "key_outputs": [], "missing_outputs": [] },
336
- "issues": [{ "severity": "critical|high|medium|low", "description": "" }],
337
- "next_step_hints": {
338
- "prompt_additions": "<extra context for next step>",
339
- "cautions": ["<things to watch out for>"],
340
- "context_to_carry": "<key facts from this step>"
341
- },
342
- "step_summary": ""
343
- }
344
- ```
345
-
346
- On callback: capture gemini exec_id for session continuity, store analysis in `state.step_analyses[]` and `step-{N}-analysis.json`, advance to next step (**4a**).
274
+ ## Step 4: Dispatch
347
275
 
348
- **4f. Completion report:**
276
+ ### 4a: Low-complexity fast path
349
277
 
350
- ```
351
- ============================================================
352
- MAESTRO SESSION COMPLETE
353
- ============================================================
354
- Session: {session_id}
355
- Chain: {chain_name}
356
- Steps: {completed}/{total} completed
357
- Phase: {current_phase}
278
+ If ALL conditions met:
279
+ - clarity >= 2
280
+ - task_type == `'quick'` or (action == `'create'` && object == `'feature'`)
281
+ - NOT `forcedChain`, NOT `state_continue`
358
282
 
359
- Results:
360
- [✓] 1. maestro-plan — completed [cli] (quality: 85/100)
361
- [✓] 2. maestro-verify — completed [skill]
362
- [—] 3. quality-review — skipped [skill]
283
+ Then: `Skill({ skill: "maestro-quick", args: '"{description}"' })`. **End.**
363
284
 
364
- CLI Avg Quality: {avgScore}/100 (based on {cliStepCount} cli steps)
285
+ ### 4b: Standard execution read and follow execution workflow
365
286
 
366
- Next: /maestro continue | /manage-status
367
- ============================================================
368
- ```
287
+ For ALL chains (regardless of step count):
288
+ 1. status.json already created in Step 3f with `steps[]` and `context`
289
+ 2. Read `~/.maestro/workflows/maestro-chain-execute.md`
290
+ 3. Follow it with `$SESSION_PATH` = session directory from Step 3f
369
291
 
370
292
  ---
371
293