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.
- package/.claude/commands/maestro-init.md +3 -3
- package/.claude/commands/maestro-plan.md +2 -2
- package/.claude/commands/maestro-ralph-execute.md +332 -0
- package/.claude/commands/maestro-ralph.md +526 -0
- package/.claude/commands/maestro.md +13 -11
- package/.claude/commands/quality-business-test.md +3 -3
- package/.claude/commands/quality-retrospective.md +2 -2
- package/.codex/skills/maestro/SKILL.md +4 -4
- package/.codex/skills/maestro-init/SKILL.md +9 -9
- package/.codex/skills/maestro-link-coordinate/SKILL.md +4 -4
- package/.codex/skills/maestro-milestone-complete/SKILL.md +3 -2
- package/.codex/skills/maestro-plan/SKILL.md +2 -2
- package/.codex/skills/maestro-ralph/SKILL.md +662 -0
- package/.codex/skills/maestro-ralph-execute/SKILL.md +193 -0
- package/.codex/skills/quality-business-test/SKILL.md +6 -6
- package/.codex/skills/quality-retrospective/SKILL.md +5 -5
- package/.codex/skills/quality-test/SKILL.md +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-ralph
|
|
3
|
+
description: Closed-loop lifecycle decision engine — read state, infer position, build adaptive chain, execute via CSV waves, STOP at decision nodes for re-evaluation
|
|
4
|
+
argument-hint: "\"intent\" [-y] | status | continue | execute"
|
|
5
|
+
allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<purpose>
|
|
9
|
+
Closed-loop decision engine for the maestro workflow lifecycle.
|
|
10
|
+
Two entry points with distinct roles:
|
|
11
|
+
|
|
12
|
+
- **`$maestro-ralph "intent"`** — Decision mode: read state → infer position → build/expand chain → write status.json → execute first wave(s) until a decision node → STOP
|
|
13
|
+
- **`$maestro-ralph execute`** — Execute mode: resume from status.json → run next wave(s) until a decision node → STOP
|
|
14
|
+
- **`$maestro-ralph status`** — Display session progress
|
|
15
|
+
- **`$maestro-ralph continue`** — Alias for `execute` (resume after decision)
|
|
16
|
+
|
|
17
|
+
Key difference from maestro coordinator:
|
|
18
|
+
- maestro: static chain → run all waves to completion
|
|
19
|
+
- ralph: living chain → decision nodes pause execution → ralph re-evaluates → chain grows/shrinks dynamically
|
|
20
|
+
|
|
21
|
+
Three node types in the chain:
|
|
22
|
+
- **decision**: Barrier that STOPS execution. Ralph re-reads result files, decides whether to expand chain.
|
|
23
|
+
- **skill**: Executed via `spawn_agents_on_csv`. Barrier skills (analyze, plan, execute, brainstorm) run solo. Non-barriers can parallel.
|
|
24
|
+
- **cli**: Executed via `maestro delegate` (轻量替代,如 quick 模式的 review)。单步执行,不进 CSV wave。
|
|
25
|
+
|
|
26
|
+
Session at `.workflow/.ralph/ralph-{YYYYMMDD-HHmmss}/status.json`.
|
|
27
|
+
</purpose>
|
|
28
|
+
|
|
29
|
+
<context>
|
|
30
|
+
$ARGUMENTS — intent text, or keywords.
|
|
31
|
+
|
|
32
|
+
**Routing:**
|
|
33
|
+
```
|
|
34
|
+
"status" → handleStatus(). End.
|
|
35
|
+
"execute" | "continue"→ handleExecute(). Jump to Phase 2.
|
|
36
|
+
otherwise → handleNew(). Start from Phase 1.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Flags:**
|
|
40
|
+
- `-y` / `--yes` — Auto mode: skip confirmation, decision nodes auto-evaluate并继续(不 STOP),错误自动重试一次后跳过。`-y` 存入 `session.auto`,传播到 ralph-execute 及下游 skill。
|
|
41
|
+
|
|
42
|
+
**`-y` 传播链:**
|
|
43
|
+
```
|
|
44
|
+
ralph -y → session.auto = true
|
|
45
|
+
→ wave CSV skill_call 附加 -y: $maestro-ralph-execute -y "$skill_call"
|
|
46
|
+
→ ralph-execute 解析 -y,附加到目标 skill: $maestro-plan -y 1
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**`-y` 下游传播表:**
|
|
50
|
+
|
|
51
|
+
| Skill | 附加 Flag | 效果 |
|
|
52
|
+
|-------|-----------|------|
|
|
53
|
+
| maestro-init | `-y` | 跳过交互提问 |
|
|
54
|
+
| maestro-analyze | `-y` | 跳过交互 scoping |
|
|
55
|
+
| maestro-brainstorm | `-y` | 跳过交互提问 |
|
|
56
|
+
| maestro-roadmap | `-y` | 跳过交互选择 |
|
|
57
|
+
| maestro-plan | `-y` | 跳过确认和澄清 |
|
|
58
|
+
| maestro-execute | `-y` | 跳过确认,blocked 自动继续 |
|
|
59
|
+
| maestro-verify | *(none)* | 无交互,正常执行 |
|
|
60
|
+
| quality-business-test | `-y` | 跳过计划确认 |
|
|
61
|
+
| quality-review | *(none)* | 无交互确认,自动检测级别 |
|
|
62
|
+
| quality-test | `-y --auto-fix` | 自动触发 gap-fix loop |
|
|
63
|
+
| quality-test-gen | *(none)* | 无交互,正常生成 |
|
|
64
|
+
| quality-debug | *(none)* | 无交互确认,正常诊断 |
|
|
65
|
+
| maestro-milestone-audit | *(none)* | 无交互,正常执行 |
|
|
66
|
+
| maestro-milestone-complete | `-y` | 跳过 knowledge promotion 交互 |
|
|
67
|
+
|
|
68
|
+
未列出的命令无 auto flag,原样执行。
|
|
69
|
+
|
|
70
|
+
**Decision-node detection (for execute mode):**
|
|
71
|
+
If status.json has a pending decision node as next step → Phase 2b (evaluate), not Phase 2a (spawn).
|
|
72
|
+
</context>
|
|
73
|
+
|
|
74
|
+
<invariants>
|
|
75
|
+
1. **Skills via spawn_agents_on_csv, CLI via delegate**: Coordinator NEVER executes skills directly. CLI steps use `maestro delegate`.
|
|
76
|
+
2. **Decision nodes STOP execution**: After processing a decision node, coordinator writes status.json and STOPS. User must call `$maestro-ralph execute` to resume. **例外:`-y` 模式下 decision 自动评估后继续,不 STOP(post-debug-escalate 除外)。**
|
|
77
|
+
3. **Barrier = solo wave**: barrier skills (analyze, plan, execute, brainstorm, roadmap) always run alone.
|
|
78
|
+
4. **Non-barriers can parallel**: consecutive non-barrier + non-decision steps grouped into one wave.
|
|
79
|
+
5. **Decision = barrier + conditional stop**: decision node is always solo. 默认 STOP;`-y` 模式自动继续。
|
|
80
|
+
6. **Wave-by-wave**: never start wave N+1 before wave N results are read.
|
|
81
|
+
7. **Coordinator owns context**: sub-agents never read prior results.
|
|
82
|
+
8. **Abort on failure**: failed step → `-y` 模式重试一次后跳过并继续;非 `-y` 模式 mark remaining skipped → pause session.
|
|
83
|
+
9. **Quality mode governs steps**: quality_mode (full/standard/quick) 决定哪些质量步骤被包含。
|
|
84
|
+
10. **passed_gates skip**: 重试循环中已通过的质量门不重复执行(除非代码变更影响了其检查范围)。
|
|
85
|
+
</invariants>
|
|
86
|
+
|
|
87
|
+
<execution>
|
|
88
|
+
|
|
89
|
+
## Phase 1: Resolve Intent and Build Chain (handleNew)
|
|
90
|
+
|
|
91
|
+
### 1a: Read project state
|
|
92
|
+
|
|
93
|
+
Read `.workflow/state.json`. Actual schema:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"current_milestone": "MVP",
|
|
98
|
+
"milestones": [{ "id": "M1", "name": "MVP", "status": "active", "phases": [1, 2] }],
|
|
99
|
+
"artifacts": [
|
|
100
|
+
{
|
|
101
|
+
"id": "ANL-001",
|
|
102
|
+
"type": "analyze", // analyze | plan | execute | verify
|
|
103
|
+
"milestone": "MVP",
|
|
104
|
+
"phase": 1,
|
|
105
|
+
"scope": "phase", // phase | milestone | adhoc | standalone
|
|
106
|
+
"path": "phases/01-auth-multi-tenant", // relative to .workflow/scratch/
|
|
107
|
+
"status": "completed",
|
|
108
|
+
"depends_on": "PLN-001",
|
|
109
|
+
"harvested": true
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"accumulated_context": {
|
|
113
|
+
"key_decisions": [...],
|
|
114
|
+
"deferred": [...]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Bootstrap state detection:**
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
Case A — No .workflow/ at all:
|
|
123
|
+
A1: No source files (empty project, 0→1)
|
|
124
|
+
→ position = "brainstorm", chain starts: brainstorm → init → roadmap → analyze → ...
|
|
125
|
+
A2: Has source files (existing code, first time using maestro)
|
|
126
|
+
→ position = "init", chain starts: init → roadmap → analyze → ...
|
|
127
|
+
|
|
128
|
+
Case B — Has .workflow/, no state.json or empty milestones:
|
|
129
|
+
→ position = "init" or "roadmap"
|
|
130
|
+
|
|
131
|
+
Case C — Has state.json with artifacts:
|
|
132
|
+
→ artifact-based inference (see below)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 1b: Artifact-based position inference (Case C)
|
|
136
|
+
|
|
137
|
+
Filter artifacts by `milestone == current_milestone`. Group by phase. For the target phase, find the **latest completed artifact type**:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
state.json exists, no milestones[] → "roadmap"
|
|
141
|
+
Has milestones, no roadmap.md → "roadmap"
|
|
142
|
+
Has roadmap, no artifacts for target phase → "analyze"
|
|
143
|
+
Latest artifact type == "analyze" → "plan"
|
|
144
|
+
Latest artifact type == "plan" → "execute"
|
|
145
|
+
Latest artifact type == "execute" → "verify"
|
|
146
|
+
Latest artifact type == "verify" → check result files (see below)
|
|
147
|
+
|
|
148
|
+
When latest is "verify", read result files to refine position:
|
|
149
|
+
resolve_artifact_dir(latest_verify_artifact)
|
|
150
|
+
Read verification.json from that dir:
|
|
151
|
+
gaps[] non-empty or passed == false → "verify-failed" (needs fix loop)
|
|
152
|
+
passed == true, no review.json → "post-verify" (chain builder 按 quality_mode 决定下一步)
|
|
153
|
+
has review.json with verdict == "BLOCK" → "review-failed"
|
|
154
|
+
has review.json with verdict != "BLOCK" → "test"
|
|
155
|
+
has uat.md with status == "complete", all passed → "milestone-audit"
|
|
156
|
+
has uat.md with failures → "test-failed"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**resolve_artifact_dir(artifact):**
|
|
160
|
+
```
|
|
161
|
+
artifact.path is relative path (e.g. "phases/01-auth-multi-tenant")
|
|
162
|
+
Full path = .workflow/scratch/{artifact.path}/
|
|
163
|
+
If path starts with "phases/": also try .workflow/scratch/{YYYYMMDD}-*-P{phase}-*/
|
|
164
|
+
Fallback: glob .workflow/scratch/*-P{phase}-*/ sorted by date DESC, take first
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 1c: Build command sequence
|
|
168
|
+
|
|
169
|
+
**Quality pipeline modes** (`quality_mode` in session):
|
|
170
|
+
|
|
171
|
+
| Mode | 含义 | 质量步骤 |
|
|
172
|
+
|------|------|----------|
|
|
173
|
+
| `full` | 全量质量管线 | verify → business-test → review → test-gen → test |
|
|
174
|
+
| `standard` | 标准管线(默认) | verify → review → test(跳过 business-test、test-gen 按条件) |
|
|
175
|
+
| `quick` | 轻量验证 | verify → CLI-review(跳过 business-test、test-gen、test) |
|
|
176
|
+
|
|
177
|
+
Mode 选择逻辑(Phase 1a 后自动推断,可被用户覆盖):
|
|
178
|
+
```
|
|
179
|
+
有 requirements/REQ-*.md 且 phase scope == "phase" → full
|
|
180
|
+
其他场景 → standard
|
|
181
|
+
用户显式指定 → 覆盖自动推断
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Lifecycle stages** (带条件的完整管线):
|
|
185
|
+
```
|
|
186
|
+
Stage Skill Barrier Decision After Condition
|
|
187
|
+
───────────────────────────────────────────────────────────────────────────────────────────────
|
|
188
|
+
brainstorm maestro-brainstorm "{intent}" yes — 0→1 only
|
|
189
|
+
init maestro-init no — always
|
|
190
|
+
roadmap maestro-roadmap "{intent}" yes — always
|
|
191
|
+
analyze maestro-analyze {phase} yes — always
|
|
192
|
+
plan maestro-plan {phase} yes — always
|
|
193
|
+
execute maestro-execute {phase} yes — always
|
|
194
|
+
verify maestro-verify {phase} no decision:post-verify always
|
|
195
|
+
business-test quality-business-test {phase} no decision:post-biz-test full only ①
|
|
196
|
+
review quality-review {phase} no decision:post-review full/standard ②
|
|
197
|
+
└─ CLI alt delegate --role review — decision:post-review quick ②
|
|
198
|
+
test-gen quality-test-gen {phase} no — full; standard 按条件 ③
|
|
199
|
+
test quality-test {phase} no decision:post-test full/standard ④
|
|
200
|
+
milestone-audit maestro-milestone-audit no — always
|
|
201
|
+
milestone-complete maestro-milestone-complete no decision:post-milestone always
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**条件说明:**
|
|
205
|
+
- ① `business-test`: 仅 full 模式。与 `quality-test` 有 40% 重叠(PRD 正向 vs 代码反向),full 模式两者互补覆盖,standard/quick 模式省略
|
|
206
|
+
- ② `review`: full/standard 用完整 skill spawn(6 维度并行);quick 模式改用 CLI delegate(轻量代码审查)
|
|
207
|
+
- ③ `test-gen`: full 模式始终执行;standard 模式仅在 `validation.json` 覆盖率 < 80% 或不存在时执行
|
|
208
|
+
- ④ `test`: full/standard 执行;quick 模式跳过(依赖 verify + CLI-review 即可)
|
|
209
|
+
|
|
210
|
+
**CLI review 替代(quick 模式):**
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"type": "cli",
|
|
214
|
+
"skill": "maestro delegate",
|
|
215
|
+
"args": "\"review changed files in phase {phase}\" --role review --mode analysis --rule analysis-review-code-quality",
|
|
216
|
+
"output_file": "{artifact_dir}/review.json"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
CLI review 输出需符合 review.json schema(verdict + issues[]),供 post-review 决策节点消费。
|
|
220
|
+
|
|
221
|
+
**条件步骤的链构建:**
|
|
222
|
+
```
|
|
223
|
+
buildSteps(position, target, quality_mode):
|
|
224
|
+
steps = lifecycle_stages[position..target]
|
|
225
|
+
|
|
226
|
+
# 按 quality_mode 过滤
|
|
227
|
+
if quality_mode != "full":
|
|
228
|
+
remove business-test + decision:post-biz-test
|
|
229
|
+
if quality_mode == "quick":
|
|
230
|
+
replace review skill → CLI review
|
|
231
|
+
remove test-gen
|
|
232
|
+
remove test + decision:post-test
|
|
233
|
+
if quality_mode == "standard":
|
|
234
|
+
# test-gen 延迟决定:在 post-verify 决策后检查覆盖率
|
|
235
|
+
mark test-gen as conditional: "check_coverage"
|
|
236
|
+
|
|
237
|
+
return steps
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Generate `steps[]` from current position to target. Decision nodes use:
|
|
241
|
+
```json
|
|
242
|
+
{ "type": "decision", "skill": "maestro-ralph", "args": "{\"decision\":\"post-verify\",\"retry_count\":0,\"max_retries\":2}" }
|
|
243
|
+
```
|
|
244
|
+
Conditional steps use:
|
|
245
|
+
```json
|
|
246
|
+
{ "type": "skill", "skill": "quality-test-gen {phase}", "condition": "check_coverage", "threshold": 80 }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 1d: Create session
|
|
250
|
+
|
|
251
|
+
Write `.workflow/.ralph/ralph-{YYYYMMDD-HHmmss}/status.json`:
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"id": "ralph-{YYYYMMDD-HHmmss}",
|
|
255
|
+
"created_at": "ISO",
|
|
256
|
+
"intent": "{user_intent}",
|
|
257
|
+
"status": "running",
|
|
258
|
+
"lifecycle_position": "{position}",
|
|
259
|
+
"target": "milestone-complete",
|
|
260
|
+
"phase": null,
|
|
261
|
+
"milestone": null,
|
|
262
|
+
"auto": false,
|
|
263
|
+
"quality_mode": "standard",
|
|
264
|
+
"passed_gates": [],
|
|
265
|
+
"context": { "plan_dir": null, "analysis_dir": null, "brainstorm_dir": null },
|
|
266
|
+
"steps": [...],
|
|
267
|
+
"waves": [],
|
|
268
|
+
"current_step": 0,
|
|
269
|
+
"updated_at": "ISO"
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### 1e: Display plan + confirm
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
============================================================
|
|
277
|
+
RALPH DECISION ENGINE
|
|
278
|
+
============================================================
|
|
279
|
+
Position: {position} (Phase {N}, {milestone})
|
|
280
|
+
Target: milestone-complete
|
|
281
|
+
Quality: {quality_mode} (full|standard|quick)
|
|
282
|
+
Steps: {total} ({decision_count} decision points)
|
|
283
|
+
|
|
284
|
+
[ ] 0. maestro-plan {phase} [skill/barrier]
|
|
285
|
+
[ ] 1. maestro-execute {phase} [skill/barrier]
|
|
286
|
+
[ ] 2. maestro-verify {phase} [skill]
|
|
287
|
+
[ ] 3. ◆ post-verify [decision] ← STOP
|
|
288
|
+
[ ] 4. quality-review {phase} [skill] ← standard
|
|
289
|
+
[ ] 4. quality-review {phase} [cli/delegate] ← quick
|
|
290
|
+
[ ] 5. ◆ post-review [decision] ← STOP
|
|
291
|
+
...
|
|
292
|
+
── skipped (standard mode) ──────────────────────────────
|
|
293
|
+
[~] _. quality-business-test {phase} [skip: standard]
|
|
294
|
+
[?] _. quality-test-gen {phase} [conditional: coverage < 80%]
|
|
295
|
+
============================================================
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
If not auto: AskUserQuestion → Proceed / Cancel / Change quality mode
|
|
299
|
+
If auto (`-y`): skip confirmation, proceed directly
|
|
300
|
+
|
|
301
|
+
### 1f: Fall through to Phase 2
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Phase 2: Wave Execution Loop (handleExecute)
|
|
306
|
+
|
|
307
|
+
### 2a: Load session
|
|
308
|
+
|
|
309
|
+
Read status.json. Find first pending step.
|
|
310
|
+
|
|
311
|
+
If first pending step is a decision node → go to Phase 2b.
|
|
312
|
+
Otherwise → go to Phase 2c.
|
|
313
|
+
|
|
314
|
+
### 2b: Decision Evaluation (when next pending is decision)
|
|
315
|
+
|
|
316
|
+
Read decision metadata from step.args: `{ decision, retry_count, max_retries }`
|
|
317
|
+
|
|
318
|
+
**Locate result files** — find the artifact dir for current phase:
|
|
319
|
+
```
|
|
320
|
+
Read .workflow/state.json
|
|
321
|
+
Filter artifacts: milestone == session.milestone, phase == session.phase
|
|
322
|
+
Sort by created_at DESC
|
|
323
|
+
|
|
324
|
+
For the decision type, find the relevant artifact:
|
|
325
|
+
post-verify → latest type=="verify" artifact
|
|
326
|
+
post-biz-test → same dir as verify (business-test writes to same artifact dir)
|
|
327
|
+
post-review → latest artifact dir → review.json
|
|
328
|
+
post-test → latest artifact dir → uat.md + .tests/test-results.json
|
|
329
|
+
|
|
330
|
+
artifact_dir = resolve_artifact_dir(artifact)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Evaluate by decision type:**
|
|
334
|
+
|
|
335
|
+
> **passed_gates 机制**:session.passed_gates[] 记录已通过的质量门。重试循环中跳过已通过的门,避免重复执行。
|
|
336
|
+
> 当代码被修改(debug+plan+execute)后,清除 passed_gates 中被影响的门(verify 始终重新执行)。
|
|
337
|
+
|
|
338
|
+
**post-verify:**
|
|
339
|
+
```
|
|
340
|
+
Read {artifact_dir}/verification.json
|
|
341
|
+
Check: gaps[] array and passed field
|
|
342
|
+
|
|
343
|
+
If gaps found (passed == false or gaps[].length > 0):
|
|
344
|
+
If meta.retry_count >= meta.max_retries:
|
|
345
|
+
→ Insert: [quality-debug "{gap_summary}", decision:post-debug-escalate]
|
|
346
|
+
→ Display: ◆ post-verify: max retries reached, escalating to debug
|
|
347
|
+
Else:
|
|
348
|
+
→ Insert: [quality-debug "{gap_summary}", maestro-plan --gaps {phase},
|
|
349
|
+
maestro-execute {phase}, maestro-verify {phase},
|
|
350
|
+
decision:post-verify(retry+1)]
|
|
351
|
+
→ Display: ◆ post-verify: gaps detected, inserting debug+fix loop (retry {N}/{max})
|
|
352
|
+
|
|
353
|
+
If no gaps (passed == true):
|
|
354
|
+
→ Add "verify" to passed_gates
|
|
355
|
+
→ 条件检查 test-gen(standard 模式):
|
|
356
|
+
Read {artifact_dir}/validation.json
|
|
357
|
+
If coverage < 80% or validation.json not found:
|
|
358
|
+
activate conditional test-gen step (set condition = "met")
|
|
359
|
+
Else:
|
|
360
|
+
skip test-gen step (set status = "skipped")
|
|
361
|
+
→ No insertion, proceed
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**post-biz-test (仅 full 模式):**
|
|
365
|
+
```
|
|
366
|
+
Read {artifact_dir}/business-test-results.json or scan for business test output
|
|
367
|
+
Check: failures[] or passed field
|
|
368
|
+
|
|
369
|
+
If failures found:
|
|
370
|
+
If meta.retry_count >= meta.max_retries:
|
|
371
|
+
→ Insert: [quality-debug --from-business-test {phase}, decision:post-debug-escalate]
|
|
372
|
+
Else:
|
|
373
|
+
→ Clear passed_gates (code will change)
|
|
374
|
+
→ Insert: [quality-debug --from-business-test {phase},
|
|
375
|
+
maestro-plan --gaps {phase}, maestro-execute {phase},
|
|
376
|
+
maestro-verify {phase}, decision:post-verify(retry:0),
|
|
377
|
+
quality-business-test {phase}, decision:post-biz-test(retry+1)]
|
|
378
|
+
|
|
379
|
+
If all pass:
|
|
380
|
+
→ Add "business-test" to passed_gates
|
|
381
|
+
→ No insertion, proceed
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**post-review:**
|
|
385
|
+
```
|
|
386
|
+
Read {artifact_dir}/review.json
|
|
387
|
+
Check: verdict field and issues[].severity
|
|
388
|
+
|
|
389
|
+
If verdict == "BLOCK" or any issue.severity == "critical":
|
|
390
|
+
If meta.retry_count >= meta.max_retries:
|
|
391
|
+
→ Insert: [quality-debug "{block_summary}", decision:post-debug-escalate]
|
|
392
|
+
Else:
|
|
393
|
+
→ Clear passed_gates (code will change)
|
|
394
|
+
→ Insert: [quality-debug "{block_issues}",
|
|
395
|
+
maestro-plan --gaps {phase}, maestro-execute {phase},
|
|
396
|
+
quality-review {phase}, decision:post-review(retry+1)]
|
|
397
|
+
注:review 失败只重跑 review,不回滚到 verify(verify 已通过且代码仅修复 review 问题)
|
|
398
|
+
|
|
399
|
+
If verdict == "PASS" or "WARN":
|
|
400
|
+
→ Add "review" to passed_gates
|
|
401
|
+
→ No insertion, proceed
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**post-test (仅 full/standard 模式):**
|
|
405
|
+
```
|
|
406
|
+
Read {artifact_dir}/uat.md (parse frontmatter + gap sections)
|
|
407
|
+
Read {artifact_dir}/.tests/test-results.json if exists
|
|
408
|
+
|
|
409
|
+
If failures found (any test result != pass, or gaps with severity >= high):
|
|
410
|
+
If meta.retry_count >= meta.max_retries:
|
|
411
|
+
→ Insert: [quality-debug --from-uat {phase}, decision:post-debug-escalate]
|
|
412
|
+
Else:
|
|
413
|
+
→ Clear passed_gates (code will change)
|
|
414
|
+
→ 轻量重试:仅重新执行 verify + 未通过的质量门
|
|
415
|
+
→ Insert: [quality-debug --from-uat {phase},
|
|
416
|
+
maestro-plan --gaps {phase}, maestro-execute {phase},
|
|
417
|
+
maestro-verify {phase}, decision:post-verify(retry:0),
|
|
418
|
+
// 对 passed_gates 中的每个门:对比修改文件列表与该门的检查范围
|
|
419
|
+
// 有交集 → 重新插入该门 + 对应 decision
|
|
420
|
+
// 无交集 → 跳过(不插入)
|
|
421
|
+
quality-test {phase}, decision:post-test(retry+1)]
|
|
422
|
+
注:不再重新插入整条管线。verify 始终重跑(代码已变),其余门按影响范围判断。
|
|
423
|
+
|
|
424
|
+
If all pass:
|
|
425
|
+
→ Add "test" to passed_gates
|
|
426
|
+
→ No insertion, proceed
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**post-milestone:**
|
|
430
|
+
```
|
|
431
|
+
Re-read .workflow/state.json (milestone-complete will have updated it).
|
|
432
|
+
Check: state.milestones[] for next milestone with status == "pending" or "active"
|
|
433
|
+
|
|
434
|
+
If next milestone found:
|
|
435
|
+
next_m = next milestone
|
|
436
|
+
first_phase = next_m.phases[0]
|
|
437
|
+
Update ralph session: milestone = next_m.name, phase = first_phase
|
|
438
|
+
|
|
439
|
+
→ Reset passed_gates = []
|
|
440
|
+
→ Re-infer quality_mode for next milestone (check REQ-*.md existence)
|
|
441
|
+
→ Insert lifecycle for next milestone (按 quality_mode 过滤):
|
|
442
|
+
[maestro-analyze {first_phase} [barrier],
|
|
443
|
+
maestro-plan {first_phase} [barrier],
|
|
444
|
+
maestro-execute {first_phase} [barrier],
|
|
445
|
+
maestro-verify {first_phase},
|
|
446
|
+
decision:post-verify(retry:0),
|
|
447
|
+
...quality steps per quality_mode (see 1c buildSteps)...,
|
|
448
|
+
maestro-milestone-audit,
|
|
449
|
+
maestro-milestone-complete,
|
|
450
|
+
decision:post-milestone]
|
|
451
|
+
注:使用 buildSteps() 按当前 quality_mode 生成质量步骤,不硬编码完整管线
|
|
452
|
+
|
|
453
|
+
→ Display: ◆ post-milestone: {completed_m.name} done → advancing to {next_m.name} Phase {first_phase}
|
|
454
|
+
|
|
455
|
+
If no next milestone:
|
|
456
|
+
→ No insertion — session will complete naturally
|
|
457
|
+
→ Display: ◆ post-milestone: all milestones complete!
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**post-debug-escalate:**
|
|
461
|
+
```
|
|
462
|
+
This is a terminal escalation — debug was run but we exceeded max retries.
|
|
463
|
+
→ Set session status = "paused"
|
|
464
|
+
→ Display: ◆ 已达最大重试次数,debug 已执行。请人工介入检查结果。
|
|
465
|
+
→ Display: 使用 $maestro-ralph execute 在处理后恢复
|
|
466
|
+
→ STOP
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
After evaluation:
|
|
470
|
+
1. Mark decision step as "completed"
|
|
471
|
+
2. Reindex steps if inserted
|
|
472
|
+
3. Write status.json
|
|
473
|
+
4. Display: `◆ Decision: {type} → {outcome}`
|
|
474
|
+
5. **STOP 判定:**
|
|
475
|
+
- `post-debug-escalate` → 始终 STOP(无论 `-y` 与否)
|
|
476
|
+
- `auto == true` (`-y`) → 不 STOP,直接 fall through to Phase 2c
|
|
477
|
+
- `auto == false` → STOP。Display: `⏸ 到达决策节点。使用 $maestro-ralph execute 继续。`
|
|
478
|
+
|
|
479
|
+
### 2c: Build and Execute Next Wave
|
|
480
|
+
|
|
481
|
+
**While pending non-decision steps remain:**
|
|
482
|
+
|
|
483
|
+
1. **buildNextWave**: Take first pending step.
|
|
484
|
+
- If conditional step with condition not met → mark "skipped", advance to next
|
|
485
|
+
- If barrier → solo wave
|
|
486
|
+
- If non-barrier → collect consecutive non-barrier, non-decision steps
|
|
487
|
+
- Stop at first decision node (it will be processed in next `execute` call)
|
|
488
|
+
|
|
489
|
+
2. **Assemble args** (placeholder resolution):
|
|
490
|
+
```
|
|
491
|
+
{phase} → status.phase
|
|
492
|
+
{intent} → status.intent
|
|
493
|
+
{scratch_dir} → from latest artifact path
|
|
494
|
+
{plan_dir} → status.context.plan_dir
|
|
495
|
+
{analysis_dir}→ status.context.analysis_dir
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
3. **Route by step type:**
|
|
499
|
+
|
|
500
|
+
**type == "skill"** → Write wave CSV: `{sessionDir}/wave-{N}.csv`
|
|
501
|
+
Each row spawns a `$maestro-ralph-execute` agent with the target skill_call as argument:
|
|
502
|
+
```csv
|
|
503
|
+
id,skill_call,topic
|
|
504
|
+
"3","$maestro-ralph-execute \"$maestro-verify 1\"","Ralph step 3/14: verify phase 1"
|
|
505
|
+
```
|
|
506
|
+
当 `session.auto == true` 时,skill_call 附加 `-y`:
|
|
507
|
+
```csv
|
|
508
|
+
"3","$maestro-ralph-execute -y \"$maestro-verify 1\"","Ralph step 3/14: verify phase 1"
|
|
509
|
+
```
|
|
510
|
+
ralph-execute 解析 `-y` 后,按传播表对目标 skill 附加对应 auto flag。
|
|
511
|
+
The inner `$maestro-verify 1` is the actual skill; `$maestro-ralph-execute` is the worker wrapper.
|
|
512
|
+
|
|
513
|
+
**type == "cli"** → CLI delegate 执行(quick 模式 review 等):
|
|
514
|
+
```
|
|
515
|
+
Bash({
|
|
516
|
+
command: 'maestro delegate "{step.args}" --mode analysis',
|
|
517
|
+
run_in_background: true
|
|
518
|
+
})
|
|
519
|
+
```
|
|
520
|
+
等待回调 → `maestro delegate output <id>` → 解析输出写入 `{artifact_dir}/{output_file}`
|
|
521
|
+
CLI 步骤始终单步执行,不进 CSV wave。
|
|
522
|
+
|
|
523
|
+
4. **Spawn** (仅 skill 类型):
|
|
524
|
+
```
|
|
525
|
+
spawn_agents_on_csv({
|
|
526
|
+
csv_path: "{sessionDir}/wave-{N}.csv",
|
|
527
|
+
id_column: "id",
|
|
528
|
+
instruction: WAVE_INSTRUCTION,
|
|
529
|
+
max_workers: <wave_size>,
|
|
530
|
+
max_runtime_seconds: 3600,
|
|
531
|
+
output_csv_path: "{sessionDir}/wave-{N}-results.csv",
|
|
532
|
+
output_schema: RESULT_SCHEMA
|
|
533
|
+
})
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
5. **Read results**: Update step status from results CSV (skill) or delegate output (cli)
|
|
537
|
+
|
|
538
|
+
6. **Barrier check**: If wave was a barrier skill, read artifacts, update context:
|
|
539
|
+
| Barrier | Read | Update |
|
|
540
|
+
|---------|------|--------|
|
|
541
|
+
| maestro-analyze | context.md, state.json | context.analysis_dir, context.gaps |
|
|
542
|
+
| maestro-plan | plan.json | context.plan_dir, context.task_count |
|
|
543
|
+
| maestro-execute | results.csv | context.exec_status |
|
|
544
|
+
| maestro-brainstorm | .brainstorming/ | context.brainstorm_dir |
|
|
545
|
+
| maestro-roadmap | specs/ | context.spec_session_id |
|
|
546
|
+
|
|
547
|
+
7. **Persist**: Write status.json with updated steps, waves, context
|
|
548
|
+
|
|
549
|
+
8. **Failure check**: Any step failed → mark remaining skipped, pause session, STOP
|
|
550
|
+
|
|
551
|
+
9. **Decision check**: If next pending step is a decision node:
|
|
552
|
+
- `auto == true` → 不 STOP,直接进入 Phase 2b 评估该决策节点,然后继续循环
|
|
553
|
+
- `auto == false` → STOP。Display: `⏸ 到达决策节点: {decision_type}。使用 $maestro-ralph execute 继续。`
|
|
554
|
+
|
|
555
|
+
10. **Continue**: If next pending is not decision, loop back to step 1
|
|
556
|
+
|
|
557
|
+
### Sub-Agent Instruction Template
|
|
558
|
+
|
|
559
|
+
```
|
|
560
|
+
你是 Ralph 执行器子 agent。
|
|
561
|
+
|
|
562
|
+
skill_call 列包含 $maestro-ralph-execute 调用,它会解析内部的目标 skill 并执行。
|
|
563
|
+
直接运行 skill_call 中的命令即可。
|
|
564
|
+
|
|
565
|
+
限制:
|
|
566
|
+
- 不要修改 .workflow/.ralph/ 下的文件
|
|
567
|
+
- ralph-execute 内部处理 skill 路由和执行
|
|
568
|
+
|
|
569
|
+
完成后调用 report_agent_job_result,返回:
|
|
570
|
+
{"status":"completed|failed","skill_call":"{skill_call}","summary":"一句话结果","artifacts":"产物路径或空","error":"失败原因或空"}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Result Schema
|
|
574
|
+
|
|
575
|
+
`{ status, skill_call, summary, artifacts, error }` — all string, status = "completed"|"failed"
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## Phase 3: Completion (when no pending steps remain)
|
|
580
|
+
|
|
581
|
+
```
|
|
582
|
+
status.status = "completed"
|
|
583
|
+
status.updated_at = now
|
|
584
|
+
Write status.json
|
|
585
|
+
|
|
586
|
+
============================================================
|
|
587
|
+
RALPH COMPLETE
|
|
588
|
+
============================================================
|
|
589
|
+
Session: {id}
|
|
590
|
+
Quality: {quality_mode}
|
|
591
|
+
Phase: {phase} → {milestone}
|
|
592
|
+
Waves: {wave_count} executed
|
|
593
|
+
Steps: {completed}/{total} ({skipped} skipped)
|
|
594
|
+
|
|
595
|
+
[✓] 0. maestro-plan 1 [W1]
|
|
596
|
+
[✓] 1. maestro-execute 1 [W2]
|
|
597
|
+
[✓] 2. maestro-verify 1 [W3]
|
|
598
|
+
[✓] 3. ◆ post-verify [decision: no gaps]
|
|
599
|
+
[~] 4. quality-business-test 1 [skipped: standard mode]
|
|
600
|
+
[✓] 5. quality-review 1 [W4]
|
|
601
|
+
...
|
|
602
|
+
|
|
603
|
+
Resume: $maestro-ralph execute
|
|
604
|
+
============================================================
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
</execution>
|
|
608
|
+
|
|
609
|
+
<csv_schema>
|
|
610
|
+
### wave-{N}.csv
|
|
611
|
+
|
|
612
|
+
All skill execution goes through `$maestro-ralph-execute` as the worker wrapper:
|
|
613
|
+
|
|
614
|
+
```csv
|
|
615
|
+
id,skill_call,topic
|
|
616
|
+
"3","$maestro-ralph-execute \"$maestro-verify 1\"","Ralph step 3/14: verify phase 1"
|
|
617
|
+
"4","$maestro-ralph-execute \"$quality-business-test 1\"","Ralph step 4/14: business test phase 1"
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
- `skill_call` column: `$maestro-ralph-execute [-y] "<inner_skill_call>"`(`session.auto` 时附加 `-y`)
|
|
621
|
+
- `topic` column: human-readable step description
|
|
622
|
+
- Non-barrier + non-decision steps can be grouped in one wave CSV with multiple rows
|
|
623
|
+
- Barrier steps always solo (one row per CSV)
|
|
624
|
+
- Decision steps are NEVER in CSV — processed by ralph directly
|
|
625
|
+
- CLI steps (type=="cli") are NEVER in CSV — processed by ralph via maestro delegate
|
|
626
|
+
</csv_schema>
|
|
627
|
+
|
|
628
|
+
<error_codes>
|
|
629
|
+
| Code | Severity | Description | Recovery |
|
|
630
|
+
|------|----------|-------------|----------|
|
|
631
|
+
| E001 | error | No intent and no running session | Prompt for intent |
|
|
632
|
+
| E002 | error | Cannot infer lifecycle position | Show raw state, ask user |
|
|
633
|
+
| E003 | error | Artifact dir not found for decision evaluation | Show glob results, ask user |
|
|
634
|
+
| E004 | error | Result file (verification.json etc) missing in artifact dir | Warn, treat as failure |
|
|
635
|
+
| E005 | error | Wave timeout (max_runtime_seconds) | Mark step failed, pause session |
|
|
636
|
+
| E006 | error | No session found for execute/continue | Suggest $maestro-ralph "intent" |
|
|
637
|
+
| W001 | warning | Decision node expanded chain (gap/failure detected) | Auto-handled, log expansion |
|
|
638
|
+
| W002 | warning | Max retries reached, escalating to debug | Auto-handled |
|
|
639
|
+
| W003 | warning | Multiple running sessions found | Use latest, warn user |
|
|
640
|
+
</error_codes>
|
|
641
|
+
|
|
642
|
+
<success_criteria>
|
|
643
|
+
- [ ] state.json artifacts correctly read with actual schema (type, path, scope, milestone, depends_on)
|
|
644
|
+
- [ ] Lifecycle position inferred from artifacts + result files (verification.json, review.json, uat.md)
|
|
645
|
+
- [ ] Artifact dir resolved via resolve_artifact_dir() with fallback globs
|
|
646
|
+
- [ ] Quality mode (full/standard/quick) 正确推断并影响步骤生成
|
|
647
|
+
- [ ] Conditional steps: business-test 仅 full 模式,test-gen 按覆盖率条件
|
|
648
|
+
- [ ] CLI 替代: quick 模式 review 走 delegate 而非 skill spawn
|
|
649
|
+
- [ ] Decision nodes at: post-verify, post-biz-test (full only), post-review, post-test (full/standard), post-milestone
|
|
650
|
+
- [ ] Every decision failure path starts with quality-debug before plan --gaps
|
|
651
|
+
- [ ] passed_gates[] 正确追踪,重试时跳过已通过的质量门
|
|
652
|
+
- [ ] 重试循环轻量化:post-test 失败不重跑整条管线,仅重跑未通过的门
|
|
653
|
+
- [ ] retry_count tracked per decision node, max_retries enforced
|
|
654
|
+
- [ ] Max retries → post-debug-escalate → session paused for human intervention
|
|
655
|
+
- [ ] Skills via spawn_agents_on_csv, CLI via delegate — coordinator never executes directly
|
|
656
|
+
- [ ] Decision nodes STOP execution — user must call `execute` to resume
|
|
657
|
+
- [ ] Barrier skills run solo, non-barriers grouped in parallel waves
|
|
658
|
+
- [ ] Placeholder args resolved before CSV assembly ({phase}, {intent}, {scratch_dir})
|
|
659
|
+
- [ ] post-milestone 用 buildSteps() 生成下一个 milestone 的步骤(按 quality_mode)
|
|
660
|
+
- [ ] status.json persisted after every wave
|
|
661
|
+
- [ ] Command insertion + reindex works correctly after decision expansion
|
|
662
|
+
</success_criteria>
|