maestro-flow 0.3.28 → 0.3.30

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.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: maestro-init
3
3
  description: Initialize project with auto state detection (empty/code/existing)
4
- argument-hint: "[--auto] [--from-brainstorm SESSION-ID]"
4
+ argument-hint: "[-y] [--from-brainstorm SESSION-ID]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Write
@@ -24,7 +24,7 @@ Initialize a new project through auto state detection and unified flow. Invoked
24
24
 
25
25
  <context>
26
26
  **Flags:**
27
- - `--auto` -- Automatic mode. After config questions, runs research without further interaction. Expects idea document via @ reference.
27
+ - `-y` -- Automatic mode. After config questions, runs research without further interaction. Expects idea document via @ reference.
28
28
  - `--from-brainstorm SESSION-ID` -- Import from a brainstorm session. Reads guidance-specification.md to pre-fill project vision, goals, constraints, and terminology. Skips interactive questioning.
29
29
 
30
30
  **Load project state if exists:**
@@ -61,7 +61,7 @@ Other commands:
61
61
  <error_codes>
62
62
  | Code | Severity | Condition | Recovery |
63
63
  |------|----------|-----------|----------|
64
- | E001 | error | No arguments provided when --auto requires @ reference | Check arguments format, re-run with correct input |
64
+ | E001 | error | No arguments provided when -y requires @ reference | Check arguments format, re-run with correct input |
65
65
  | E002 | error | .workflow/ already exists for greenfield init | Check .workflow/ directory state, resolve conflicts |
66
66
  | E003 | error | Brainstorm session not found (--from-brainstorm) | Check arguments format, re-run with correct input |
67
67
  | W001 | warning | Research agent failed, continuing with partial results | Retry research or proceed with partial results |
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: maestro-plan
3
3
  description: Explore, clarify, plan, check, and confirm a phase execution plan
4
- argument-hint: "[phase] [--collab] [--spec SPEC-xxx] [--auto] [--gaps] [--dir <path>] [--revise [instructions]] [--check <plan-dir>]"
4
+ argument-hint: "[phase] [--collab] [--spec SPEC-xxx] [-y] [--gaps] [--dir <path>] [--revise [instructions]] [--check <plan-dir>]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Write
@@ -36,7 +36,7 @@ All plan output goes to `.workflow/scratch/{YYYYMMDD}-plan-[P{N}-|M{N}-]{slug}/`
36
36
  <context>
37
37
  $ARGUMENTS — phase number, or no args for milestone-wide planning, with optional flags.
38
38
 
39
- Scope routing, base flags (`--collab`, `--spec`, `--auto`, `--gaps`, `--dir`), output directory format, and artifact registration are defined in workflow plan.md.
39
+ Scope routing, base flags (`--collab`, `--spec`, `-y`, `--gaps`, `--dir`), output directory format, and artifact registration are defined in workflow plan.md.
40
40
 
41
41
  **Command-level flags** (extensions beyond workflow base):
42
42
  - `--revise [instructions]` -- See workflow plan.md § Revise Mode
@@ -0,0 +1,332 @@
1
+ ---
2
+ name: maestro-ralph-execute
3
+ description: Single-step executor — find next pending command in ralph session, execute by type (decision/skill/cli), hand off to next iteration
4
+ argument-hint: "[-y] [session-id]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Skill
13
+ ---
14
+ <purpose>
15
+ Single-step executor for ralph command chains. Each invocation:
16
+ 1. Finds the next pending command in the ralph session JSON
17
+ 2. Executes it based on node type (decision → ralph, skill → Skill(), cli → delegate)
18
+ 3. Updates status.json
19
+ 4. Hands off to next iteration via self-invocation or ralph callback
20
+
21
+ Three node types drive different execution + handoff patterns:
22
+ - **decision**: `Skill("maestro-ralph")` — ralph re-evaluates state, may expand chain
23
+ - **skill**: `Skill({ skill, args })` — synchronous in-session → `Skill("maestro-ralph-execute")`
24
+ - **cli**: `maestro delegate` background → STOP → callback → `Skill("maestro-ralph-execute")`
25
+
26
+ Mutual invocation with `/maestro-ralph` forms a persistent self-perpetuating work loop.
27
+ </purpose>
28
+
29
+ <context>
30
+ $ARGUMENTS — optional `-y` flag + optional session ID. If session ID omitted, finds latest running ralph session.
31
+
32
+ **Flag parsing:**
33
+ ```
34
+ Parse $ARGUMENTS:
35
+ Contains "-y" or "--yes" → auto = true, remove flag from remaining args
36
+ Remaining → session_id (if matches ralph-* pattern)
37
+ ```
38
+
39
+ **Session discovery:**
40
+ Scan `.workflow/.ralph/ralph-*/status.json` for `status == "running"`, sorted by `created_at` descending.
41
+ If remaining args match a session ID pattern, use that specific session.
42
+ Also read `session.auto` from status.json — if `true`, treat as `-y` even if flag not passed(ralph 已写入)。
43
+ </context>
44
+
45
+ <execution>
46
+
47
+ ## Step 1: Locate Session
48
+
49
+ ```
50
+ If $ARGUMENTS matches ralph-* pattern:
51
+ session_path = .workflow/.ralph/{$ARGUMENTS}/status.json
52
+ Else:
53
+ Scan .workflow/.ralph/ralph-*/status.json
54
+ Filter: status == "running"
55
+ Sort: created_at DESC
56
+ Take first
57
+
58
+ If no session found:
59
+ Output: "无运行中的 ralph 会话。使用 /maestro-ralph 创建新会话。"
60
+ End.
61
+ ```
62
+
63
+ Read status.json → extract: `id`, `steps[]`, `current_step`, `status`, `phase`.
64
+
65
+ ## Step 2: Find Next Pending Command
66
+
67
+ ```
68
+ next = steps.find(step => step.status == "pending")
69
+
70
+ If no pending command:
71
+ → Step 5 (Complete)
72
+ ```
73
+
74
+ ## Step 2.5: Assemble Args (context propagation)
75
+
76
+ Before execution, enrich `next.args` with context from session and prior outputs.
77
+
78
+ **Context sources (priority order):**
79
+ 1. `status.json.intent` — user's original input text
80
+ 2. `status.json.phase` — current phase number
81
+ 3. `status.json.milestone` — current milestone name
82
+ 4. `.workflow/state.json.artifacts[]` — latest artifacts for path resolution
83
+ 5. Previous completed command outputs — scratch dirs, session IDs
84
+
85
+ **Placeholder substitution in args:**
86
+ ```
87
+ {phase} → status.phase
88
+ {milestone} → status.milestone
89
+ {intent} → status.intent
90
+ {scratch_dir} → latest artifact path for current phase from state.json
91
+ ```
92
+
93
+ **Per-command enrichment** (when args is empty or only has phase number):
94
+
95
+ | Command | Required context | Source |
96
+ |---------|-----------------|--------|
97
+ | maestro-brainstorm | topic description | `status.intent` — pass as `"{intent}"` |
98
+ | maestro-roadmap | description + context | `status.intent` — pass as `"{intent}"` |
99
+ | maestro-analyze | phase or topic | `{phase}` or `"{intent}"` if no phase |
100
+ | maestro-plan | phase or --dir | `{phase}`, or `--dir {scratch_dir}` if standalone |
101
+ | maestro-execute | phase or --dir | `{phase}`, or `--dir {scratch_dir}` if standalone |
102
+ | maestro-verify | phase | `{phase}` |
103
+ | quality-debug | gap context | Read previous step's error or gap summary from artifact dir |
104
+ | quality-* | phase | `{phase}` |
105
+
106
+ **Artifact dir resolution for --dir args:**
107
+ ```
108
+ Read .workflow/state.json
109
+ Filter artifacts: milestone == session.milestone, phase == session.phase
110
+ For plan commands: find latest type=="analyze" artifact → --dir .workflow/scratch/{path}
111
+ For execute commands: find latest type=="plan" artifact → --dir .workflow/scratch/{path}
112
+ ```
113
+
114
+ **Write enriched args back to status.json** so resume preserves them:
115
+ ```
116
+ next.args = enriched_args
117
+ Write status.json
118
+ ```
119
+
120
+ ## Step 3: Mark Running + Update JSON
121
+
122
+ ```
123
+ next.status = "running"
124
+ next.started_at = new Date().toISOString()
125
+ status.current = next.index
126
+ status.updated_at = new Date().toISOString()
127
+
128
+ Write status.json
129
+ ```
130
+
131
+ Display step banner:
132
+ ```
133
+ ------------------------------------------------------------
134
+ [{next.index}/{steps.length - 1}] {next.skill} [{next.type}]
135
+ ------------------------------------------------------------
136
+ Args: {next.args}
137
+ {next.type == "decision" ? "Retry: " + JSON.parse(next.args).retry_count + "/" + JSON.parse(next.args).max_retries : ""}
138
+ ```
139
+
140
+ **Context weight hint** (after 4+ completed steps):
141
+ ```
142
+ If completed_count >= 4:
143
+ Display: ⚡ 已执行 {completed_count} 步,上下文较重。可 /maestro-ralph continue 在新上下文恢复。
144
+ ```
145
+
146
+ ## Step 4: Execute by Type
147
+
148
+ ### 4a. decision node
149
+
150
+ Decision nodes hand control back to ralph for re-evaluation.
151
+
152
+ ```
153
+ Skill({ skill: "maestro-ralph" })
154
+ ```
155
+
156
+ Ralph will:
157
+ 1. Detect the running decision node in status.json
158
+ 2. Evaluate execution results (verify gaps, test failures, etc.)
159
+ 3. Optionally expand steps[] with fix loops
160
+ 4. Mark the decision node completed
161
+ 5. Call `Skill("maestro-ralph-execute")` to resume
162
+
163
+ **After Skill("maestro-ralph") returns, this execution ends.** Ralph handles the handoff.
164
+
165
+ ### 4b. skill node
166
+
167
+ Synchronous in-session execution.
168
+
169
+ **`-y` auto flag 传播:** 当 `auto == true` 时,按传播表对目标 skill 附加 auto flag:
170
+ ```
171
+ auto_flag_map = {
172
+ "maestro-init": "-y",
173
+ "maestro-analyze": "-y",
174
+ "maestro-brainstorm": "-y",
175
+ "maestro-roadmap": "-y",
176
+ "maestro-plan": "-y",
177
+ "maestro-execute": "-y",
178
+ "quality-business-test": "-y",
179
+ "quality-test": "-y --auto-fix",
180
+ "maestro-milestone-complete": "-y"
181
+ }
182
+ flag = auto_flag_map[next.skill] || ""
183
+ effective_args = flag ? `${next.args} ${flag}` : next.args
184
+ ```
185
+
186
+ ```
187
+ Skill({ skill: next.skill, args: effective_args })
188
+ ```
189
+
190
+ On success:
191
+ ```
192
+ next.status = "completed"
193
+ next.completed_at = new Date().toISOString()
194
+ Write status.json
195
+
196
+ Display: [N/total] ✓ {next.skill} completed
197
+ ```
198
+
199
+ On failure (Skill throws or produces error):
200
+ ```
201
+ next.status = "failed"
202
+ next.error = "{error message}"
203
+ next.completed_at = new Date().toISOString()
204
+ Write status.json
205
+
206
+ Display: [N/total] ✗ {next.skill} failed: {error}
207
+
208
+ If auto:
209
+ If not next.retried:
210
+ next.retried = true, next.status = "pending", next.error = null → retry once
211
+ Else:
212
+ next.status = "skipped" → continue (auto-skip)
213
+ Display: [N/total] ⏭ {next.skill} auto-skipped after retry
214
+ Else:
215
+ AskUserQuestion: "retry / skip / abort"
216
+ retry → reset next.status = "pending", next.error = null → Skill("maestro-ralph-execute")
217
+ skip → next.status = "skipped" → Skill("maestro-ralph-execute")
218
+ abort → status.status = "paused" → Write status.json → End.
219
+ ```
220
+
221
+ Then hand off:
222
+ ```
223
+ Skill({ skill: "maestro-ralph-execute" })
224
+ ```
225
+
226
+ ### 4c. cli node
227
+
228
+ Background delegate execution with stop-and-wait pattern.
229
+
230
+ Resolve CLI tool from session or default config:
231
+ ```
232
+ cli_tool = session.cli_tool || "gemini" // from ralph status.json or fallback
233
+ ```
234
+
235
+ ```
236
+ Bash({
237
+ command: `maestro delegate "PURPOSE: 执行 /${next.skill} ${next.args}; success = 命令正常完成并产出 artifact
238
+ TASK: 运行 /${next.skill} ${next.args}
239
+ MODE: write
240
+ CONTEXT: @**/*
241
+ EXPECTED: 产出写入 .workflow/scratch/,artifact 注册到 state.json
242
+ CONSTRAINTS: 严格按照 /${next.skill} 的正常流程执行" --to ${cli_tool} --mode write`,
243
+ run_in_background: true,
244
+ timeout: 600000
245
+ })
246
+
247
+ STOP — wait for background callback.
248
+ ```
249
+
250
+ **On callback:**
251
+
252
+ ```
253
+ Retrieve output: maestro delegate output <exec_id>
254
+
255
+ next.status = "completed"
256
+ next.completed_at = new Date().toISOString()
257
+ Write status.json
258
+
259
+ Display: [N/total] ✓ {next.skill} completed [cli]
260
+ ```
261
+
262
+ On failure:
263
+ ```
264
+ next.status = "failed"
265
+ next.error = "{error details}"
266
+ Write status.json
267
+
268
+ (same as 4b failure handling: auto → retry once then skip; else → AskUserQuestion)
269
+ ```
270
+
271
+ Then hand off:
272
+ ```
273
+ Skill({ skill: "maestro-ralph-execute" })
274
+ ```
275
+
276
+ ## Step 5: Complete Session
277
+
278
+ When no pending steps remain:
279
+
280
+ ```
281
+ status.status = "completed"
282
+ status.updated_at = new Date().toISOString()
283
+ Write status.json
284
+ ```
285
+
286
+ Display completion report:
287
+ ```
288
+ ============================================================
289
+ RALPH COMPLETE
290
+ ============================================================
291
+ Session: {id}
292
+ Phase: {phase}
293
+ Steps: {completed}/{total}
294
+
295
+ {steps.map(cmd => {
296
+ icon = cmd.status == "completed" ? "✓" :
297
+ cmd.status == "skipped" ? "—" :
298
+ cmd.status == "failed" ? "✗" : " "
299
+ type_badge = cmd.type == "decision" ? "◆" :
300
+ cmd.type == "cli" ? "⚡" : " "
301
+ return ` [${icon}] ${cmd.index}. ${type_badge} ${cmd.skill} ${cmd.args} [${cmd.type}]`
302
+ })}
303
+ ============================================================
304
+ ```
305
+
306
+ **End.**
307
+
308
+ </execution>
309
+
310
+ <error_codes>
311
+ | Code | Severity | Description | Recovery |
312
+ |------|----------|-------------|----------|
313
+ | E001 | error | No running ralph session found | Suggest /maestro-ralph to create |
314
+ | E002 | error | Session status.json corrupt or unreadable | Show path, suggest manual check |
315
+ | E003 | error | CLI delegate failed + user chose abort | Mark paused, suggest /maestro-ralph continue |
316
+ | W001 | warning | Step completed with warnings | Log and continue |
317
+ | W002 | warning | Context getting heavy (step >= 4) | Hint: /maestro-ralph continue for fresh context |
318
+ </error_codes>
319
+
320
+ <success_criteria>
321
+ - [ ] Session discovery finds latest running ralph session
322
+ - [ ] `-y` flag parsed from args OR inherited from session.auto
323
+ - [ ] Pending step correctly identified from steps[]
324
+ - [ ] decision nodes hand off to maestro-ralph via Skill()
325
+ - [ ] skill nodes execute synchronously via Skill() and self-invoke next
326
+ - [ ] `-y` auto flag 按传播表附加到目标 skill args
327
+ - [ ] cli nodes use maestro delegate with run_in_background + stop pattern
328
+ - [ ] status.json updated after every status change (resume-safe)
329
+ - [ ] auto 模式:失败重试一次后 auto-skip;非 auto:AskUserQuestion retry/skip/abort
330
+ - [ ] Completion report shows all steps with status icons
331
+ - [ ] Self-invocation chain continues until all steps complete
332
+ </success_criteria>