maestro-flow-one 0.2.15 → 0.2.17

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.
@@ -138,6 +138,55 @@ If chain selected: -> Step 4
138
138
 
139
139
  ---
140
140
 
141
+ ## Step 3.5: Task Decomposition (broad lifecycle intents)
142
+
143
+ Shares the decomposition contract with maestro-ralph `A_DECOMPOSE_TASKS` — reference that spec; do not duplicate.
144
+
145
+ ```
146
+ Classify intent breadth:
147
+ broad = 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp
148
+ narrow = single file/function/bug, "fix X", "add Y to Z"
149
+ other = medium
150
+
151
+ Skip decomposition (-> Step 4 directly) WHEN:
152
+ narrow intent OR single-command chain OR chain ∈ {status, init, quick}
153
+
154
+ Else (broad MUST clarify even if auto_confirm; medium clarify unless auto_confirm):
155
+ AskUserQuestion ≤3 rounds (options pre-filled from intent + quick Glob/Grep of target module):
156
+ 1. Scope -> in_scope / out_of_scope
157
+ 2. Constraints -> constraints + execution_criteria (compat/API/perf/test bar)
158
+ 3. Done -> definition_of_done
159
+
160
+ Derive:
161
+ execution_criteria = 3-6 imperative rules every step obeys
162
+ task_decomposition = outcome sub-goals; each:
163
+ { id:"G1", goal, boundary, done_when, evidence, lifecycle:[...], status:"pending" }
164
+ RULE: done_when objectively verifiable, mapped to a ralph evidence artifact
165
+ (verification.json | review.json | uat.md | <test path>)
166
+
167
+ Write {session_dir}/goal-checklist.md (template below) with ALL_GOALS_DONE sentinel.
168
+ Stage additive block + goal_checklist_path for Step 4.
169
+ Emit the /goal bind prompt:
170
+ 📋 任务分解完成。复制下面一行设定目标(推荐):
171
+ /goal 当 {session_dir}/goal-checklist.md 子目标全 [x] 且含 ALL_GOALS_DONE 时达成;
172
+ 否则按执行准则继续推进且不越边界契约
173
+ ```
174
+
175
+ **goal-checklist.md template:**
176
+ ```markdown
177
+ # Flow Goal Checklist — {session_id}
178
+ > Intent: {intent}
179
+ ## 执行准则 / Execution Criteria
180
+ - {criterion}
181
+ ## 边界契约 / Boundary Contract
182
+ - In scope / Out of scope / Constraints / Definition of Done
183
+ ## 子目标 / Sub-goals
184
+ - [ ] G1: {goal} — done when: {done_when} (evidence: {evidence})
185
+ <!-- executor flips [ ]→[x] when evidence confirms; appends ALL_GOALS_DONE when all [x] -->
186
+ ```
187
+
188
+ ---
189
+
141
190
  ## Step 4: Build Session
142
191
 
143
192
  ### 4.1: Create session from template
@@ -147,8 +196,21 @@ session_id = "flow-{YYYYMMDD-HHmmss}"
147
196
  session_dir = .workflow/.maestro/{session_id}/
148
197
 
149
198
  Build steps[] from selected chain template.
199
+
200
+ If Step 3.5 produced a decomposition:
201
+ - Add additive block to status.json (OPTIONAL keys; absent = old behavior;
202
+ never remove/rename existing fields — status JSON is schema-additive + step-dynamic):
203
+ boundary_contract, execution_criteria, task_decomposition, goal_checklist_path
204
+ - Each step gains optional "goal_ref": null
205
+ - Append a decision step
206
+ { "cmd":"decision:post-goal-audit", "type":"decision",
207
+ "decision":"post-goal-audit", "retry_count":0, "max_retries":2 }
208
+ as the FINAL node — after the last evidence-producing step (verify/review/test),
209
+ before a milestone-complete/close-out step if the chain ends with one
210
+ (audit needs evidence artifacts to exist)
211
+
150
212
  Write status.json.
151
- Display chain steps, confirm (or auto if -y).
213
+ Display chain steps (+ Sub-goals: {n} if decomposed), confirm (or auto if -y).
152
214
  ```
153
215
 
154
216
  Fall through to Phase 2.
@@ -25,6 +25,12 @@
25
25
  "evaluates": "state.json",
26
26
  "verdict_prompt": "检查是否有下一个 milestone",
27
27
  "structural": true
28
+ },
29
+ "post-goal-audit": {
30
+ "evaluates": "goal-checklist.md + per-subgoal evidence (verification.json|review.json|uat.md|test path)",
31
+ "verdict_prompt": "审计子目标: 逐个对照 done_when 判定 met/unmet, 输出 STATUS(all_met|has_unmet) 与 UNMET=[{id,gap,target_phase}]",
32
+ "fix_loop": ["maestro-plan --gaps", "maestro-execute", "maestro-verify", "decision:post-goal-audit"],
33
+ "goal_gate": true
28
34
  }
29
35
  },
30
36
  "templates": {
@@ -72,7 +72,13 @@ artifact_dir = .workflow/scratch/{artifact.path}/
72
72
  Fallback: glob .workflow/scratch/*-P{phase}-*/ sorted by date DESC
73
73
  ```
74
74
 
75
- #### 3.3: Structural vs Quality-gate
75
+ #### 3.3: Route by decision class
76
+
77
+ ```
78
+ decision_type == "post-milestone" -> Structural (evaluate directly)
79
+ decision_type == "post-goal-audit" -> Goal-gate (audit sub-goals, grow steps)
80
+ otherwise -> Quality-gate (delegate analyzer)
81
+ ```
76
82
 
77
83
  **Structural decisions (post-milestone)** -- evaluate directly:
78
84
 
@@ -90,6 +96,42 @@ post-milestone:
90
96
  -> proceed (mark done, continue)
91
97
  ```
92
98
 
99
+ **Goal-gate decision (post-goal-audit)** -- shares contract with maestro-ralph `A_GOAL_AUDIT_EVALUATE`:
100
+
101
+ ```
102
+ Read session.task_decomposition + session.goal_checklist_path
103
+ For each sub-goal status != "done": resolve its evidence artifact under {artifact_dir}
104
+
105
+ Bash({
106
+ command: `maestro delegate "PURPOSE: 审计子目标达成, 决定是否补充执行步骤
107
+ TASK: 逐个读取未完成子目标 evidence | 对照 done_when 判定 met/unmet | 给出 unmet 差距与 target_phase
108
+ MODE: analysis
109
+ CONTEXT: @{goal_checklist_path} @{evidence files} | 执行准则: {execution_criteria} | 边界: {boundary_contract}
110
+ EXPECTED: ---VERDICT--- STATUS: all_met | has_unmet / UNMET: [{id,gap,target_phase}] ---END---
111
+ CONSTRAINTS: 只评估不修改 | 严格按 done_when | 不越 boundary_contract" --role analyze --mode analysis`,
112
+ run_in_background: true
113
+ })
114
+ STOP -- wait for callback.
115
+
116
+ On callback:
117
+ For each met sub-goal -> set task_decomposition[i].status="done" + flip [ ]→[x] in goal-checklist.md
118
+ STATUS == all_met:
119
+ Append line `ALL_GOALS_DONE` to goal-checklist.md
120
+ Mark decision completed, write status.json
121
+ -> Step 3.8 (continue; satisfies user /goal Stop hook)
122
+ STATUS == has_unmet:
123
+ For each unmet sub-goal G{n} (grouped by target_phase), insert before this decision node:
124
+ maestro-plan {target_phase} --gaps "G{n}: {gap}" [internal] [goal_ref: G{n}]
125
+ maestro-execute {target_phase} [external] [goal_ref: G{n}]
126
+ maestro-verify {target_phase} [internal] [goal_ref: G{n}]
127
+ Re-append: decision:post-goal-audit {retry+1} [decision]
128
+ Reindex steps, increment retry_count, write status.json
129
+ Display: Decision: post-goal-audit -> {k} unmet, +{N} steps inserted (G{ids})
130
+ -> Step 3.8 (continue)
131
+ GUARD: retry_count >= max_retries AND still unmet ->
132
+ insert quality-debug "{unmet gaps}" [internal]; set session.status="paused"; End.
133
+ ```
134
+
93
135
  **Quality-gate decisions** -- delegate to external analyzer:
94
136
 
95
137
  Result file mapping:
@@ -1,19 +1,20 @@
1
1
  ---
2
2
  name: maestro-flow
3
- description: Unified workflow command collection — intent routing, minimal closed-loop chain selection, wave-based CSV execution. All 49 maestro commands in one skill.
3
+ description: Unified workflow command collection — intent routing, minimal closed-loop chain selection, sequential direct step execution. All 49 maestro commands in one skill.
4
4
  argument-hint: "\"intent\" [-y] [--chain <name>] [--cmd <name> <args>] | list | status | continue | execute"
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
6
  ---
7
7
 
8
8
  <purpose>
9
- Single-entry skill packaging all 49 Maestro workflow commands.
9
+ Single-entry skill packaging all 49 Maestro workflow commands (Codex variant).
10
10
 
11
11
  Two execution modes:
12
- 1. **Router** (default): Analyze intent -> match chain template -> create session -> wave execution
12
+ 1. **Router** (default): Analyze intent -> decompose (broad intents) -> match chain -> create session -> sequential step execution
13
13
  2. **Direct** (`--cmd <name> <args>`): Load and execute a specific command inline
14
14
 
15
- Execution uses `spawn_agents_on_csv` for wave-based parallel/sequential step dispatch.
16
- Commands loaded via `maestro-flow resolve` CLI for path resolution.
15
+ Execution invokes each step DIRECTLY in coordinator context (no agent spawning).
16
+ Step lifecycle managed by `maestro-flow next/done` CLI. Commands loaded via `maestro-flow resolve`.
17
+ Goal tracking via built-in `create_goal` / `update_plan` / `update_goal`.
17
18
 
18
19
  Session path: `.workflow/.maestro/flow-{YYYYMMDD-HHmmss}/status.json`
19
20
  </purpose>
@@ -24,7 +25,7 @@ $ARGUMENTS -- intent text, flags, or special keywords.
24
25
  **Skill directory structure** (relative to this SKILL.md):
25
26
  ```
26
27
  maestro-flow/
27
- SKILL.md <- this file (router + wave executor)
28
+ SKILL.md <- this file (router + sequential executor)
28
29
  commands/
29
30
  lifecycle/ <- 17 commands: init, analyze, plan, execute, verify, ...
30
31
  quality/ <- 7 commands: debug, review, test, auto-test, ...
@@ -45,13 +46,13 @@ maestro-flow/
45
46
  </context>
46
47
 
47
48
  <invariants>
48
- 1. **ALL steps via spawn_agents_on_csv** -- coordinator NEVER executes skill logic directly
49
- 2. **Coordinator = prompt assembler** -- classify -> enrich args -> build CSV -> spawn -> read results -> next wave
50
- 3. **Decision nodes handled by coordinator** -- delegate-evaluate for quality gates, direct for structural
51
- 4. **Barrier = solo wave** -- analyze, plan, execute, brainstorm, roadmap always run alone
52
- 5. **Non-barriers can parallel** -- consecutive non-barrier, non-decision steps grouped into one wave
53
- 6. **Wave-by-wave** -- never start wave N+1 before wave N results are read
54
- 7. **Decision nodes NEVER appear in CSV** -- processed by coordinator between waves
49
+ 1. **Steps invoked DIRECTLY in-context** -- coordinator runs `$maestro-flow --cmd <skill> <args>` itself, sequentially. NO spawn_agents_on_csv, NO wave, NO CSV.
50
+ 2. **Coordinator owns the loop** -- classify -> decompose -> build -> for each step: resolve args -> invoke -> read result -> persist -> next.
51
+ 3. **Decision nodes evaluate, never execute** -- quality-gate via `maestro delegate --role analyze`; goal-gate audits sub-goals; structural evaluated directly.
52
+ 4. **Goal is tool-created** -- broad intents call `create_goal` with sub-goal success criteria; `update_goal` on convergence.
53
+ 5. **task_decomposition drives DYNAMIC step growth** -- sub-goals are the convergence spec; `steps[]` is a living array. `post-goal-audit` re-checks the checklist and inserts scoped steps for unmet sub-goals.
54
+ 6. **Status JSON: schema-additive + step-dynamic** -- decomposition fields OPTIONAL (absent -> old behavior); `steps[]` grown at runtime; `goal_ref` traces dynamically-added steps. Never remove/rename existing fields.
55
+ 7. **Sequential execution** -- one step at a time in index order; each step's result read before the next starts.
55
56
  </invariants>
56
57
 
57
58
  <execution>
@@ -65,22 +66,12 @@ Parse $ARGUMENTS:
65
66
  -> Step 1a: Direct Command Execution
66
67
  -> End.
67
68
 
68
- list
69
- -> Bash: maestro-flow list
70
- -> End.
71
-
72
- status [session-id]
73
- -> Bash: maestro-flow status [session-id]
74
- -> End.
75
-
76
- chains
77
- -> Bash: maestro-flow chains
78
- -> End.
69
+ list -> Bash: maestro-flow list. End.
70
+ status [session-id] -> Bash: maestro-flow status [session-id]. End.
71
+ chains -> Bash: maestro-flow chains. End.
79
72
 
80
73
  execute | continue
81
- -> Find latest running flow session
82
- -> If not found: "No running flow session." End.
83
- -> Phase 2 (Wave Execution Loop)
74
+ -> Phase 2 (Sequential Execution Loop)
84
75
 
85
76
  --chain <name> [-y] <remaining>
86
77
  -> Force chain selection (skip intent analysis), go to Step 4
@@ -94,20 +85,14 @@ Parse $ARGUMENTS:
94
85
 
95
86
  ### Step 1a: Direct Command Execution (--cmd)
96
87
 
97
- Entry point for delegate sessions and single-command execution.
88
+ Entry point for single-command execution.
98
89
 
99
90
  ```
100
- 1. Bash: maestro-flow resolve <name>
101
- -> Returns absolute path to command .md file
102
-
91
+ 1. Bash: maestro-flow resolve <name> -> absolute path to command .md
103
92
  2. If NOT_FOUND -> Error. End.
104
-
105
93
  3. Read() the command .md file
106
-
107
94
  4. Set $ARGUMENTS = <remaining-args>
108
-
109
95
  5. Follow the command's <execution> section completely
110
-
111
96
  End.
112
97
  ```
113
98
 
@@ -124,15 +109,62 @@ If not: state_summary = "Project not initialized"
124
109
  ## Step 3: Intent Analysis & Chain Matching
125
110
 
126
111
  ```
127
- Bash: maestro-flow suggest "{intent}"
128
- -> Parse output for suggested chains
129
-
130
- Display top 3 chain options to user
112
+ Bash: maestro-flow suggest "{intent}" -> parse suggested chains
113
+ Display top 3 chain options
131
114
  AskUserQuestion: select chain / single command / Cancel
132
115
 
133
116
  If auto_confirm: pick highest scoring chain
134
117
  If single command: --cmd -> Step 1a
135
- If chain selected: -> Step 4
118
+ If chain selected: -> Step 3.5
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Step 3.5: Task Decomposition (broad lifecycle intents)
124
+
125
+ Shares the decomposition contract with maestro-ralph `A_DECOMPOSE_TASKS` — reference that spec; do not duplicate.
126
+
127
+ ```
128
+ Classify intent breadth:
129
+ broad = 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp
130
+ narrow = single file/function/bug, "fix X", "add Y to Z"
131
+ other = medium
132
+
133
+ Skip decomposition (-> Step 4 directly) WHEN:
134
+ narrow intent OR single-command chain OR chain ∈ {status, init, quick}
135
+
136
+ Else (broad MUST clarify even if auto_confirm; medium clarify unless auto_confirm):
137
+ AskUserQuestion ≤3 rounds (options pre-filled from intent + quick Glob/Grep of target module):
138
+ 1. Scope -> in_scope / out_of_scope
139
+ 2. Constraints -> constraints + execution_criteria (compat/API/perf/test bar)
140
+ 3. Done -> definition_of_done
141
+
142
+ Derive:
143
+ execution_criteria = 3-6 imperative rules every step obeys
144
+ task_decomposition = outcome sub-goals; each:
145
+ { id:"G1", goal, boundary, done_when, evidence, lifecycle:[...], status:"pending" }
146
+ RULE: done_when objectively verifiable, mapped to a ralph evidence artifact
147
+ (verification.json | review.json | uat.md | <test path>)
148
+
149
+ Write {session_dir}/goal-checklist.md (template below) with ALL_GOALS_DONE sentinel.
150
+ Register goal via built-in tool:
151
+ create_goal({ objective: "Flow {chain}: {intent} — converge {N} sub-goals within boundary",
152
+ success_criteria: task_decomposition.map(g => `${g.id}: ${g.done_when}`),
153
+ constraints: [...execution_criteria, "stay within boundary_contract"] })
154
+ Stage additive block + goal_checklist_path for Step 4.
155
+ ```
156
+
157
+ **goal-checklist.md template:**
158
+ ```markdown
159
+ # Flow Goal Checklist — {session_id}
160
+ > Intent: {intent}
161
+ ## 执行准则 / Execution Criteria
162
+ - {criterion}
163
+ ## 边界契约 / Boundary Contract
164
+ - In scope / Out of scope / Constraints / Definition of Done
165
+ ## 子目标 / Sub-goals
166
+ - [ ] G1: {goal} — done when: {done_when} (evidence: {evidence})
167
+ <!-- executor flips [ ]→[x] when evidence confirms; appends ALL_GOALS_DONE when all [x] -->
136
168
  ```
137
169
 
138
170
  ---
@@ -142,11 +174,9 @@ If chain selected: -> Step 4
142
174
  ### 4.1: Load template & build steps
143
175
 
144
176
  ```
145
- Bash: maestro-flow chain {template_name}
146
- -> Parse step list
147
-
148
- Build session steps[] from template.
149
- Decision steps get extra fields: decision, retry_count, max_retries
177
+ Bash: maestro-flow chain {template_name} -> parse step list
178
+ Build session steps[] from template. Each step type ∈ {internal, external, decision}.
179
+ Decision steps get extra fields: decision, retry_count, max_retries.
150
180
  ```
151
181
 
152
182
  ### 4.2: Create session
@@ -157,25 +187,31 @@ session_dir = .workflow/.maestro/{session_id}/
157
187
 
158
188
  Write {session_dir}/status.json:
159
189
  {
160
- "session_id": "{session_id}",
161
- "source": "flow",
190
+ "session_id": "{session_id}", "source": "flow",
162
191
  "created_at": "{ISO}", "updated_at": "{ISO}",
163
- "intent": "{intent}",
164
- "status": "running",
165
- "chain_name": "{template_name}",
166
- "task_type": "{category}",
167
- "phase": {phase},
168
- "milestone": "{current_milestone}",
169
- "auto_mode": {auto_confirm},
170
- "quality_mode": "standard",
171
- "passed_gates": [],
172
- "context": {
173
- "scratch_dir": null, "plan_dir": null, "analysis_dir": null
174
- },
175
- "steps": [...],
176
- "waves": [],
177
- "current_step": 0
192
+ "intent": "{intent}", "status": "running",
193
+ "chain_name": "{template_name}", "task_type": "{category}",
194
+ "phase": {phase}, "milestone": "{current_milestone}",
195
+ "auto_mode": {auto_confirm}, "quality_mode": "standard", "passed_gates": [],
196
+ "context": { "scratch_dir": null, "plan_dir": null, "analysis_dir": null },
197
+ "steps": [ { ..., "goal_ref": null } ],
198
+ "waves": [], "current_step": 0,
199
+
200
+ "_comment": "↓ OPTIONAL additive block — present only if Step 3.5 ran; absent = flat-chain behavior",
201
+ "boundary_contract": {}, "execution_criteria": [], "task_decomposition": [], "goal_checklist_path": ""
178
202
  }
203
+
204
+ If Step 3.5 produced a decomposition:
205
+ - Fill the additive block (never remove/rename existing fields)
206
+ - Append a decision step
207
+ { "cmd":"decision:post-goal-audit", "type":"decision",
208
+ "decision":"post-goal-audit", "retry_count":0, "max_retries":2 }
209
+ as the FINAL node — after the last evidence-producing step (verify/review/test),
210
+ before a milestone-complete/close-out step if the chain ends with one
211
+ - update_plan({ plan: steps.map(s => ({ step: s.cmd, status: "pending" })) })
212
+ Else:
213
+ - create_goal({ objective: "Flow {chain}: {N} steps" })
214
+ - update_plan({ plan: steps.map(s => ({ step: s.cmd, status: "pending" })) })
179
215
  ```
180
216
 
181
217
  ### 4.3: Display + confirm
@@ -185,13 +221,13 @@ Write {session_dir}/status.json:
185
221
  MAESTRO FLOW SESSION
186
222
  ============================================================
187
223
  Session: {session_id}
188
- Chain: {chain_name} ({total} steps)
224
+ Chain: {chain_name} ({total} steps) Sub-goals: {n if decomposed}
189
225
  Phase: {phase}
190
226
 
191
- [ ] 0. maestro-plan {phase} [barrier]
192
- [ ] 1. maestro-execute {phase} [barrier]
227
+ [ ] 0. maestro-plan {phase}
228
+ [ ] 1. maestro-execute {phase}
193
229
  [ ] 2. maestro-verify {phase}
194
- [ ] 3. * post-verify [decision]
230
+ [ ] 3. > post-goal-audit [decision]
195
231
  ...
196
232
  ============================================================
197
233
 
@@ -203,27 +239,46 @@ Fall through to Phase 2.
203
239
 
204
240
  ---
205
241
 
206
- ## Phase 2: Wave Execution Loop
242
+ ## Phase 2: Sequential Execution Loop
207
243
 
208
- ### 2.1: Load session + find next step
244
+ Core loop: `maestro-flow next` -> route by type -> execute directly -> `maestro-flow done` -> self-invoke.
209
245
 
210
- Read status.json. Find first pending step.
246
+ ### 2.1: Load next step
211
247
 
212
- - If decision node -> Step 2.2 (Decision Evaluation)
213
- - If non-decision -> Step 2.3 (Wave Execution)
214
- - If no pending -> Phase 3 (Completion)
248
+ ```
249
+ Bash: maestro-flow next [session-id]
250
+ Parse:
251
+ "NO_SESSION" -> "No running flow session." End.
252
+ "SESSION_COMPLETE" -> Phase 3.
253
+ Else:
254
+ STEP / TYPE / SKILL / ARGS
255
+ DECISION / RETRY (decision only)
256
+ PATH (internal/external only)
257
+ ---COMMAND--- + content (internal/external only)
215
258
 
216
- ### 2.2: Decision Evaluation
259
+ Display banner: [{idx}/{total}] {SKILL} [{TYPE}] Args: {ARGS}
217
260
 
218
- **Route by decision type:**
219
- - Quality-gate decisions (post-verify, post-business-test, post-review, post-test) -> delegate analysis
220
- - Structural decisions (post-milestone) -> direct evaluation
261
+ Route:
262
+ TYPE == "decision" -> Step 2.2
263
+ TYPE == "internal" -> Step 2.3 (direct)
264
+ TYPE == "external" -> Step 2.4 (direct)
265
+ ```
221
266
 
222
- #### 2.2a: Delegate quality-gate assessment
267
+ ### 2.2: Decision Evaluation
223
268
 
224
269
  ```
225
- Read decision metadata: { decision, retry_count, max_retries }
270
+ Route by decision class:
271
+ decision == "post-milestone" -> Structural (2.2d)
272
+ decision == "post-goal-audit" -> Goal-gate (2.2g)
273
+ otherwise -> Quality-gate (2.2a)
274
+ ```
275
+
276
+ Resolve `artifact_dir`: read state.json, filter artifacts by session.milestone+phase, latest;
277
+ fallback glob `.workflow/scratch/*-P{phase}-*/`.
226
278
 
279
+ #### 2.2a: Quality-gate delegate assessment
280
+
281
+ ```
227
282
  Result file mapping:
228
283
  post-verify -> {artifact_dir}/verification.json
229
284
  post-business-test -> {artifact_dir}/business-test-results.json
@@ -232,7 +287,7 @@ Result file mapping:
232
287
 
233
288
  Bash({
234
289
  command: `maestro delegate "PURPOSE: evaluate ${decision} quality gate
235
- TASK: read result files | analyze pass/fail | assess severity | recommend next step
290
+ TASK: read result files | analyze pass/fail | assess severity | recommend
236
291
  MODE: analysis
237
292
  CONTEXT: @${result_files}
238
293
  EXPECTED:
@@ -246,211 +301,126 @@ CONSTRAINTS: evaluate only | retry ${retry_count}/${max_retries}" --role analyze
246
301
  run_in_background: true
247
302
  })
248
303
  STOP -- wait for callback.
249
- ```
250
-
251
- #### 2.2b: Parse verdict & apply
252
-
253
- ```
254
- On callback: maestro delegate output <exec_id>
255
- Extract STATUS / REASON / GAP_SUMMARY / CONFIDENCE
256
- If parse fails -> fallback: STATUS = "fix"
257
304
 
258
- Verdict actions:
259
- proceed -> add gate to passed_gates[], mark decision completed, continue
260
- fix -> clear passed_gates[], insert fix-loop steps, continue
261
- escalate -> session status = "paused". End.
305
+ On callback: maestro delegate output <exec_id> -> extract STATUS/REASON/GAP_SUMMARY/CONFIDENCE
306
+ If parse fails -> fallback STATUS = "fix"
262
307
 
263
- Interactive (non-auto): AskUserQuestion before applying
264
- Auto (-y): follow verdict directly
308
+ Verdict:
309
+ proceed -> add gate to passed_gates[], mark decision completed
310
+ fix -> clear passed_gates[], insert fix-loop (2.2c)
311
+ escalate -> session.status = "paused". End.
312
+ Interactive (non-auto): AskUserQuestion before applying. Auto (-y): follow directly.
265
313
  ```
266
314
 
267
315
  #### 2.2c: Fix-loop templates
268
316
 
269
- When verdict == "fix", insert fix-loop after current position:
270
-
271
- **post-verify:** quality-debug -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify {retry+1}
272
- **post-review:** quality-debug -> maestro-plan --gaps -> maestro-execute -> quality-review -> decision:post-review {retry+1}
273
- **post-test:** quality-debug -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify -> quality-test -> decision:post-test {retry+1}
274
- **post-business-test:** quality-debug -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify -> quality-auto-test -> decision:post-business-test {retry+1}
317
+ When verdict == "fix", insert after current position, reindex:
275
318
 
276
- Insert, reindex, write status.json, continue to 2.3.
319
+ - **post-verify:** quality-debug -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify {retry+1}
320
+ - **post-review:** quality-debug -> maestro-plan --gaps -> maestro-execute -> quality-review -> decision:post-review {retry+1}
321
+ - **post-test:** quality-debug --from-uat -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify {0} -> quality-test -> decision:post-test {retry+1}
322
+ - **post-business-test:** quality-debug --from-business-test -> maestro-plan --gaps -> maestro-execute -> maestro-verify -> decision:post-verify {0} -> quality-auto-test -> decision:post-business-test {retry+1}
277
323
 
278
- #### 2.2d: Structural decisions
324
+ #### 2.2d: Structural (post-milestone)
279
325
 
280
- **post-milestone:**
281
326
  ```
282
- Read .workflow/state.json -> check next milestone
283
- If found: update session, insert lifecycle steps for next milestone
284
- If none: proceed, session completes naturally
327
+ Read state.json -> next milestone (pending/active)?
328
+ If found: update session (milestone, phase, reset passed_gates), insert lifecycle steps, reindex
329
+ If none: proceed (session completes naturally)
285
330
  ```
286
331
 
287
- #### 2.2e: Finalize decision
332
+ #### 2.2g: Goal-gate (post-goal-audit)
288
333
 
289
- ```
290
- Mark decision step "completed"
291
- Write status.json
334
+ Shares contract with maestro-ralph `A_GOAL_AUDIT_EVALUATE`.
292
335
 
293
- STOP behavior:
294
- auto_mode == true -> no STOP, continue to 2.3
295
- auto_mode == false -> STOP. Display: "Use $maestro-flow execute to continue"
296
336
  ```
337
+ Read session.task_decomposition + goal_checklist_path
338
+ For each sub-goal status != "done": resolve its evidence artifact under {artifact_dir}
297
339
 
298
- ### 2.3: Build and Execute Wave
299
-
300
- **Loop while pending non-decision steps exist:**
301
-
302
- #### 1. buildNextWave
340
+ Bash({
341
+ command: `maestro delegate "PURPOSE: 审计子目标达成, 决定是否补充执行步骤
342
+ TASK: 逐个读取未完成子目标 evidence | 对照 done_when 判定 met/unmet | 给出 unmet 差距与 target_phase
343
+ MODE: analysis
344
+ CONTEXT: @{goal_checklist_path} @{evidence files} | 执行准则: {execution_criteria} | 边界: {boundary_contract}
345
+ EXPECTED: ---VERDICT--- STATUS: all_met | has_unmet / UNMET: [{id,gap,target_phase}] ---END---
346
+ CONSTRAINTS: 只评估不修改 | 严格按 done_when | 不越 boundary_contract" --role analyze --mode analysis`,
347
+ run_in_background: true
348
+ })
349
+ STOP -- wait for callback.
303
350
 
351
+ On callback:
352
+ For each met sub-goal -> task_decomposition[i].status="done" + flip [ ]→[x] in goal-checklist.md
353
+ STATUS == all_met:
354
+ Append `ALL_GOALS_DONE` to goal-checklist.md
355
+ Set all task_decomposition[*].status="done"; update_goal({ status:"complete" })
356
+ Mark decision completed, write status.json -> 2.2e
357
+ STATUS == has_unmet:
358
+ For each unmet G{n} (grouped by target_phase), insert before this decision node:
359
+ maestro-plan {target_phase} --gaps "G{n}: {gap}" [internal] [goal_ref: G{n}]
360
+ maestro-execute {target_phase} [external] [goal_ref: G{n}]
361
+ maestro-verify {target_phase} [internal] [goal_ref: G{n}]
362
+ Re-append: decision:post-goal-audit {retry+1} [decision]
363
+ Reindex, increment retry_count, write status.json + update_plan -> 2.2e
364
+ GUARD: retry_count >= max_retries AND still unmet ->
365
+ insert quality-debug "{unmet gaps}" [internal]; session.status="paused"; End.
304
366
  ```
305
- Scan pending steps from current position:
306
- - Barrier step (analyze, plan, execute, brainstorm, roadmap)
307
- -> solo wave (single row CSV)
308
- - Non-barrier step
309
- -> collect consecutive non-barrier, non-decision steps (multi-row CSV)
310
- - Stop at first decision node
311
- ```
312
-
313
- **Barrier list:**
314
-
315
- | Command | Barrier |
316
- |---------|---------|
317
- | maestro-analyze | yes |
318
- | maestro-plan | yes |
319
- | maestro-execute | yes |
320
- | maestro-brainstorm | yes |
321
- | maestro-roadmap | yes |
322
- | All others | no |
323
367
 
324
- #### 2. buildSkillCall(step, session)
325
-
326
- Assemble fully-resolved command for CSV:
368
+ #### 2.2e: Finalize decision
327
369
 
328
- **Placeholder resolution:**
329
370
  ```
330
- {phase} -> session.phase
331
- {intent} -> session.intent
332
- {scratch_dir} -> session.context.scratch_dir or latest artifact path
333
- {plan_dir} -> session.context.plan_dir
334
- {analysis_dir} -> session.context.analysis_dir
371
+ Mark decision step "completed"; write status.json
372
+ Bash: maestro-flow done -> Skill({ skill: "maestro-flow", args: "execute" }) End.
373
+ (auto_mode == false on quality-gate: STOP first, display "Use $maestro-flow execute to continue")
335
374
  ```
336
375
 
337
- **Per-skill enrichment:**
338
-
339
- | Skill | Enrichment |
340
- |-------|-----------|
341
- | maestro-brainstorm | args empty -> `"{intent}"` |
342
- | maestro-roadmap | args empty -> `"{intent}"` |
343
- | maestro-analyze | args empty -> `{phase}` |
344
- | maestro-plan | resolve latest analyze artifact -> `--dir .workflow/scratch/{path}` |
345
- | maestro-execute | resolve latest plan artifact -> `--dir .workflow/scratch/{path}` |
346
- | quality-debug | append gap_summary context |
347
- | quality-* / maestro-verify / milestone-* | args empty -> `{phase}` or empty |
348
-
349
- **Auto flag propagation (if auto_mode == true):**
350
-
351
- | Skill | Flag |
352
- |-------|------|
353
- | maestro-init | -y |
354
- | maestro-analyze | -y |
355
- | maestro-brainstorm | -y |
356
- | maestro-roadmap | -y |
357
- | maestro-plan | -y |
358
- | maestro-execute | -y |
359
- | quality-auto-test | -y |
360
- | quality-test | -y --auto-fix |
361
- | maestro-milestone-complete | -y |
362
-
363
- Result: `$maestro-flow --cmd <skill-name> <enriched-args> [auto-flag]`
364
-
365
- #### 3. Write wave CSV
376
+ ### 2.3: Internal Execution (direct)
366
377
 
367
378
  ```
368
- Write {sessionDir}/wave-{N}.csv:
369
-
370
- id,skill_call,topic
371
- "0","$maestro-flow --cmd maestro-plan 1 -y","Flow step 0/8: plan phase 1"
372
- "1","$maestro-flow --cmd maestro-execute 1 -y","Flow step 1/8: execute phase 1"
379
+ Command content already in context (after ---COMMAND--- from `maestro-flow next`).
380
+ Set $ARGUMENTS = ARGS. Apply auto-flag if session.auto_mode (table below).
381
+ Follow the command's <execution> section completely (respect its required/deferred reading).
382
+ On success -> 2.5. On failure -> 2.6.
373
383
  ```
374
384
 
375
- Rules:
376
- - `skill_call`: `$maestro-flow --cmd <skill> <args>` (routes through this skill's --cmd)
377
- - `topic`: human-readable step description
378
- - Non-barrier + non-decision -> multi-row (parallel)
379
- - Barrier -> single-row (solo)
380
- - Decision nodes NEVER appear in CSV
381
-
382
- #### 4. Spawn
385
+ ### 2.4: External Execution (direct)
383
386
 
384
387
  ```
385
- spawn_agents_on_csv({
386
- csv_path: "{sessionDir}/wave-{N}.csv",
387
- id_column: "id",
388
- instruction: WAVE_INSTRUCTION,
389
- max_workers: <wave_size>,
390
- max_runtime_seconds: 3600,
391
- output_csv_path: "{sessionDir}/wave-{N}-results.csv",
392
- output_schema: RESULT_SCHEMA
393
- })
388
+ External steps run in coordinator context too (no spawn). Append -y.
389
+ Invoke directly: follow `$maestro-flow --cmd {SKILL} {ARGS} -y` — i.e., resolve the
390
+ command .md (already provided after ---COMMAND---) and follow its <execution> completely.
391
+ On success -> 2.5. On failure -> 2.6.
394
392
  ```
395
393
 
396
- **Sub-Agent Instruction:**
397
- ```
398
- You are a CSV job sub-agent in a maestro-flow pipeline.
394
+ **Auto flag propagation (session.auto_mode == true):**
399
395
 
400
- Execute the skill call: {skill_call}
401
- Task: {topic}
396
+ | Skill | Flag |
397
+ |-------|------|
398
+ | maestro-init / maestro-analyze / maestro-brainstorm / maestro-roadmap / maestro-plan / maestro-execute / quality-auto-test / maestro-milestone-complete | -y |
399
+ | quality-test | -y --auto-fix |
400
+ | (all others) | (none) |
402
401
 
403
- Rules:
404
- - Do NOT modify .workflow/.maestro/ status files
405
- - The skill has its own session management
406
- - Execute the command completely
402
+ ### 2.5: Mark Done & Advance
407
403
 
408
- Report result:
409
- {"status":"completed|failed","skill_call":"{skill_call}","summary":"one-line result","artifacts":"artifact paths","error":"failure reason"}
410
404
  ```
405
+ Bash: maestro-flow done [session-id]
406
+ Parse:
407
+ "COMPLETED: {idx} {skill}" / "NEXT: ..." -> Skill({ skill: "maestro-flow", args: "execute" }) End.
408
+ "SESSION_COMPLETE" -> Phase 3.
411
409
 
412
- **Result Schema:** `{ status, skill_call, summary, artifacts, error }` -- all string
413
-
414
- #### 5. Read results & update
415
-
416
- ```
417
- Read wave-{N}-results.csv
418
- For each result row:
419
- Match to step by id
420
- If status == "completed":
421
- step.status = "completed"
422
- step.completed_at = now
423
- If status == "failed":
424
- step.status = "failed"
425
- step.error = result.error
410
+ Context propagation (after a context-producing skill): read its artifacts, update
411
+ session.context (analyze->analysis_dir, plan->plan_dir, execute->scratch_dir,
412
+ brainstorm->brainstorm_dir, roadmap->spec_session_id); write status.json.
426
413
  ```
427
414
 
428
- #### 6. Barrier context update
429
-
430
- After barrier wave completes, read outputs and update session context:
431
-
432
- | Barrier | Read | Update |
433
- |---------|------|--------|
434
- | maestro-analyze | context.md, state.json | context.analysis_dir |
435
- | maestro-plan | plan.json | context.plan_dir |
436
- | maestro-execute | results | context.scratch_dir |
437
- | maestro-brainstorm | .brainstorming/ | context.brainstorm_dir |
438
- | maestro-roadmap | specs/ | context.spec_session_id |
439
-
440
- #### 7. Persist & continue
415
+ ### 2.6: Handle Failure
441
416
 
442
417
  ```
443
- Write status.json
444
- Record wave in session.waves[]
445
-
446
- Failure check:
447
- -y: retry once, then skip and continue
448
- non-y: mark remaining skipped, pause, STOP
449
-
450
- Next step check:
451
- Decision node -> loop to 2.2
452
- More external steps -> loop to 2.3 step 1
453
- No pending -> Phase 3
418
+ Bash: maestro-flow step {session_id} {idx} failed
419
+ Auto mode:
420
+ not retried -> step ... pending -> Skill({ skill:"maestro-flow", args:"execute" }) (retry once)
421
+ retried -> step ... skipped -> Skill({ skill:"maestro-flow", args:"execute" }) (continue)
422
+ Interactive: AskUserQuestion retry / skip / abort
423
+ abort -> session.status = "paused". End.
454
424
  ```
455
425
 
456
426
  ---
@@ -458,45 +428,28 @@ Next step check:
458
428
  ## Phase 3: Completion
459
429
 
460
430
  ```
461
- session.status = "completed"
462
- Write status.json
431
+ session.status = "completed"; write status.json
432
+ update_plan: all steps -> "completed"
433
+ update_goal({ status: "complete" }) (idempotent if released by 2.2g)
463
434
 
464
435
  Display:
465
436
  ============================================================
466
437
  FLOW COMPLETE
467
438
  ============================================================
468
439
  Session: {session_id}
469
- Chain: {chain_name}
470
- Phase: {phase}
471
- Waves: {wave_count} executed
472
- Steps: {completed}/{total} ({skipped} skipped)
473
-
474
- [+] 0. maestro-plan 1 [W1]
475
- [+] 1. maestro-execute 1 [W2]
476
- [+] 2. maestro-verify 1 [W3]
477
- [+] 3. * post-verify -> proceed [decision]
478
- [~] 4. quality-auto-test 1 [skipped]
479
- [+] 5. quality-review 1 [W4]
440
+ Chain: {chain_name} Steps: {completed}/{total} ({skipped} skipped)
441
+ Sub-goals: {done}/{total}
442
+
443
+ [+] 0. maestro-plan 1
444
+ [+] 1. maestro-execute 1
445
+ [+] 2. maestro-verify 1
446
+ [+] 3. > post-goal-audit -> all_met [decision]
480
447
  ...
481
448
  ============================================================
482
449
  ```
483
450
 
484
451
  </execution>
485
452
 
486
- <csv_schema>
487
- ### wave-{N}.csv
488
-
489
- ```csv
490
- id,skill_call,topic
491
- "0","$maestro-flow --cmd maestro-verify 1","Flow step 2/8: verify phase 1"
492
- "1","$maestro-flow --cmd quality-review 1","Flow step 3/8: review phase 1"
493
- ```
494
-
495
- ### Result Schema
496
-
497
- `{ status, skill_call, summary, artifacts, error }` -- all string
498
- </csv_schema>
499
-
500
453
  <error_codes>
501
454
  | Code | Severity | Description | Recovery |
502
455
  |------|----------|-------------|----------|
@@ -504,20 +457,21 @@ id,skill_call,topic
504
457
  | E002 | error | Command not found for --cmd | maestro-flow list |
505
458
  | E003 | error | No matching chain template | maestro-flow chains |
506
459
  | E004 | error | Delegate verdict parse failed | Fallback: treat as "fix" |
507
- | E005 | error | Wave timeout | Mark step failed, pause |
508
- | W001 | warning | Multiple chains match equally | Show top 3 |
460
+ | E005 | error | Step execution failed | auto: retry once then skip; interactive: ask |
509
461
  </error_codes>
510
462
 
511
463
  <success_criteria>
512
464
  - [ ] --cmd resolves via maestro-flow CLI, executes command inline
513
465
  - [ ] list/status/chains/suggest route to maestro-flow CLI
514
- - [ ] Intent analysis -> chain matching -> session creation
515
- - [ ] Wave execution via spawn_agents_on_csv with CSV skill_call format
516
- - [ ] Barrier steps solo wave, non-barriers parallel
517
- - [ ] Decision nodes evaluated between waves (never in CSV)
518
- - [ ] Quality-gate decisions delegate-evaluated, structural evaluated directly
519
- - [ ] Fix-loop insertion + reindex on "fix" verdict
520
- - [ ] passed_gates tracking, retry_count enforcement
521
- - [ ] Context propagation after barrier waves
466
+ - [ ] Intent analysis -> decomposition (broad) -> chain matching -> session creation
467
+ - [ ] Broad intents decomposed (≤3 boundary questions); goal registered via create_goal
468
+ - [ ] status.json schema-additive (decomposition fields optional) + step-dynamic (steps[] grows)
469
+ - [ ] post-goal-audit appended as final node; unmet sub-goals grow steps[] (goal_ref tagged)
470
+ - [ ] Steps invoked DIRECTLY in-context NO spawn_agents_on_csv, NO wave/CSV
471
+ - [ ] Sequential execution; status.json + update_plan persisted after every step/decision
472
+ - [ ] Quality-gate delegate-evaluated; goal-gate audits sub-goals; structural direct
473
+ - [ ] Fix-loop / goal-fix insertion + reindex; passed_gates + retry_count enforced
474
+ - [ ] Context propagation after context-producing skills
475
+ - [ ] update_goal released on convergence (2.2g / Phase 3); held while paused
522
476
  - [ ] Auto mode: skip confirmation, auto-follow verdicts, retry+skip on failure
523
477
  </success_criteria>
@@ -25,6 +25,12 @@
25
25
  "evaluates": "state.json",
26
26
  "verdict_prompt": "检查是否有下一个 milestone",
27
27
  "structural": true
28
+ },
29
+ "post-goal-audit": {
30
+ "evaluates": "goal-checklist.md + per-subgoal evidence (verification.json|review.json|uat.md|test path)",
31
+ "verdict_prompt": "审计子目标: 逐个对照 done_when 判定 met/unmet, 输出 STATUS(all_met|has_unmet) 与 UNMET=[{id,gap,target_phase}]",
32
+ "fix_loop": ["maestro-plan --gaps", "maestro-execute", "maestro-verify", "decision:post-goal-audit"],
33
+ "goal_gate": true
28
34
  }
29
35
  },
30
36
  "templates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maestro-flow-one",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "All Maestro workflow commands as a single Claude Code skill — intent routing, decision gates, minimal closed-loop chains",
5
5
  "bin": {
6
6
  "maestro-flow": "bin/maestro-flow.js"