maestro-flow 0.3.33 → 0.3.35

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