maestro-flow 0.3.46 → 0.3.47

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 (241) hide show
  1. package/.claude/agents/ui-design-agent.md +1 -0
  2. package/.claude/agents/workflow-executor.md +3 -0
  3. package/.claude/commands/learn-decompose.md +91 -146
  4. package/.claude/commands/learn-follow.md +102 -137
  5. package/.claude/commands/learn-investigate.md +102 -167
  6. package/.claude/commands/learn-retro.md +100 -243
  7. package/.claude/commands/learn-second-opinion.md +95 -135
  8. package/.claude/commands/maestro-amend.md +95 -232
  9. package/.claude/commands/maestro-analyze.md +1 -6
  10. package/.claude/commands/maestro-collab.md +104 -265
  11. package/.claude/commands/maestro-composer.md +113 -293
  12. package/.claude/commands/maestro-execute.md +10 -17
  13. package/.claude/commands/maestro-impeccable.md +89 -0
  14. package/.claude/commands/maestro-plan.md +1 -6
  15. package/.claude/commands/maestro-player.md +111 -340
  16. package/.claude/commands/maestro-quick.md +9 -0
  17. package/.claude/commands/maestro-ralph-execute.md +167 -210
  18. package/.claude/commands/maestro-ralph.md +245 -426
  19. package/.claude/commands/maestro-ui-codify.md +13 -0
  20. package/.claude/commands/maestro-ui-craft.md +364 -0
  21. package/.claude/commands/maestro-ui-design.md +12 -1
  22. package/.claude/commands/maestro-verify.md +12 -13
  23. package/.claude/commands/maestro.md +142 -72
  24. package/.claude/commands/manage-knowhow-capture.md +45 -170
  25. package/.claude/commands/quality-auto-test.md +9 -0
  26. package/.claude/commands/quality-debug.md +11 -25
  27. package/.claude/commands/quality-refactor.md +9 -0
  28. package/.claude/commands/quality-review.md +5 -14
  29. package/.claude/commands/spec-add.md +1 -1
  30. package/.claude/commands/spec-load.md +3 -2
  31. package/.claude/skills/maestro-impeccable/SKILL.md +169 -0
  32. package/.codex/skills/learn-decompose/SKILL.md +1 -1
  33. package/.codex/skills/learn-investigate/SKILL.md +2 -1
  34. package/.codex/skills/maestro/SKILL.md +278 -313
  35. package/.codex/skills/maestro-analyze/SKILL.md +126 -417
  36. package/.codex/skills/maestro-brainstorm/SKILL.md +129 -451
  37. package/.codex/skills/maestro-collab/SKILL.md +134 -547
  38. package/.codex/skills/maestro-execute/SKILL.md +3 -1
  39. package/.codex/skills/maestro-impeccable/SKILL.md +112 -0
  40. package/.codex/skills/maestro-plan/SKILL.md +88 -437
  41. package/.codex/skills/maestro-player/SKILL.md +191 -333
  42. package/.codex/skills/maestro-quick/SKILL.md +2 -0
  43. package/.codex/skills/maestro-ralph/SKILL.md +307 -710
  44. package/.codex/skills/maestro-roadmap/SKILL.md +201 -518
  45. package/.codex/skills/maestro-ui-codify/SKILL.md +1 -0
  46. package/.codex/skills/maestro-ui-craft/SKILL.md +341 -0
  47. package/.codex/skills/maestro-ui-design/SKILL.md +10 -0
  48. package/.codex/skills/maestro-verify/SKILL.md +116 -409
  49. package/.codex/skills/quality-auto-test/SKILL.md +145 -443
  50. package/.codex/skills/quality-refactor/SKILL.md +1 -1
  51. package/.codex/skills/quality-test/SKILL.md +229 -517
  52. package/.codex/skills/spec-add/SKILL.md +1 -1
  53. package/README.md +4 -1
  54. package/README.zh-CN.md +3 -1
  55. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js +3 -0
  56. package/dashboard/dist-server/dashboard/src/server/agents/codex-cli-adapter.js.map +1 -1
  57. package/dashboard/dist-server/dashboard/src/server/routes/install.js +110 -1
  58. package/dashboard/dist-server/dashboard/src/server/routes/install.js.map +1 -1
  59. package/dashboard/dist-server/dashboard/src/server/routes/settings.js +56 -0
  60. package/dashboard/dist-server/dashboard/src/server/routes/settings.js.map +1 -1
  61. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js +2 -0
  62. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js.map +1 -1
  63. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js +2 -2
  64. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js.map +1 -1
  65. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +2 -0
  66. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  67. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-types.d.ts +3 -1
  68. package/dashboard/dist-server/dashboard/src/shared/constants.d.ts +2 -0
  69. package/dashboard/dist-server/dashboard/src/shared/constants.js +2 -0
  70. package/dashboard/dist-server/dashboard/src/shared/constants.js.map +1 -1
  71. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  72. package/dist/src/agents/cli-agent-runner.js +1 -3
  73. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  74. package/dist/src/agents/cli-history-store.d.ts +5 -0
  75. package/dist/src/agents/cli-history-store.d.ts.map +1 -1
  76. package/dist/src/agents/cli-history-store.js +65 -13
  77. package/dist/src/agents/cli-history-store.js.map +1 -1
  78. package/dist/src/cli.js +13 -0
  79. package/dist/src/cli.js.map +1 -1
  80. package/dist/src/commands/command-help.d.ts +3 -0
  81. package/dist/src/commands/command-help.d.ts.map +1 -0
  82. package/dist/src/commands/command-help.js +60 -0
  83. package/dist/src/commands/command-help.js.map +1 -0
  84. package/dist/src/commands/config.d.ts.map +1 -1
  85. package/dist/src/commands/config.js +17 -0
  86. package/dist/src/commands/config.js.map +1 -1
  87. package/dist/src/commands/delegate.d.ts.map +1 -1
  88. package/dist/src/commands/delegate.js +12 -2
  89. package/dist/src/commands/delegate.js.map +1 -1
  90. package/dist/src/commands/impeccable.d.ts +10 -0
  91. package/dist/src/commands/impeccable.d.ts.map +1 -0
  92. package/dist/src/commands/impeccable.js +181 -0
  93. package/dist/src/commands/impeccable.js.map +1 -0
  94. package/dist/src/commands/spec.js +1 -1
  95. package/dist/src/commands/spec.js.map +1 -1
  96. package/dist/src/commands/wiki.d.ts.map +1 -1
  97. package/dist/src/commands/wiki.js +5 -1
  98. package/dist/src/commands/wiki.js.map +1 -1
  99. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  100. package/dist/src/config/cli-tools-config.js +10 -7
  101. package/dist/src/config/cli-tools-config.js.map +1 -1
  102. package/dist/src/core/addon-registry.d.ts +31 -0
  103. package/dist/src/core/addon-registry.d.ts.map +1 -0
  104. package/dist/src/core/addon-registry.js +28 -0
  105. package/dist/src/core/addon-registry.js.map +1 -0
  106. package/dist/src/hooks/plugins/spec-injection-plugin.js +2 -0
  107. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  108. package/dist/src/hooks/spec-injector.js +2 -2
  109. package/dist/src/hooks/spec-injector.js.map +1 -1
  110. package/dist/src/index.d.ts +2 -0
  111. package/dist/src/index.d.ts.map +1 -1
  112. package/dist/src/index.js +1 -0
  113. package/dist/src/index.js.map +1 -1
  114. package/dist/src/tools/impeccable/critique-storage.d.ts +28 -0
  115. package/dist/src/tools/impeccable/critique-storage.d.ts.map +1 -0
  116. package/dist/src/tools/impeccable/critique-storage.js +120 -0
  117. package/dist/src/tools/impeccable/critique-storage.js.map +1 -0
  118. package/dist/src/tools/impeccable/design-parser.d.ts +90 -0
  119. package/dist/src/tools/impeccable/design-parser.d.ts.map +1 -0
  120. package/dist/src/tools/impeccable/design-parser.js +696 -0
  121. package/dist/src/tools/impeccable/design-parser.js.map +1 -0
  122. package/dist/src/tools/impeccable/detect-csp.d.ts +6 -0
  123. package/dist/src/tools/impeccable/detect-csp.d.ts.map +1 -0
  124. package/dist/src/tools/impeccable/detect-csp.js +130 -0
  125. package/dist/src/tools/impeccable/detect-csp.js.map +1 -0
  126. package/dist/src/tools/impeccable/is-generated.d.ts +4 -0
  127. package/dist/src/tools/impeccable/is-generated.d.ts.map +1 -0
  128. package/dist/src/tools/impeccable/is-generated.js +56 -0
  129. package/dist/src/tools/impeccable/is-generated.js.map +1 -0
  130. package/dist/src/tools/impeccable/live/accept.d.ts +50 -0
  131. package/dist/src/tools/impeccable/live/accept.d.ts.map +1 -0
  132. package/dist/src/tools/impeccable/live/accept.js +556 -0
  133. package/dist/src/tools/impeccable/live/accept.js.map +1 -0
  134. package/dist/src/tools/impeccable/live/bootstrap.d.ts +2 -0
  135. package/dist/src/tools/impeccable/live/bootstrap.d.ts.map +1 -0
  136. package/dist/src/tools/impeccable/live/bootstrap.js +244 -0
  137. package/dist/src/tools/impeccable/live/bootstrap.js.map +1 -0
  138. package/dist/src/tools/impeccable/live/complete.d.ts +7 -0
  139. package/dist/src/tools/impeccable/live/complete.d.ts.map +1 -0
  140. package/dist/src/tools/impeccable/live/complete.js +67 -0
  141. package/dist/src/tools/impeccable/live/complete.js.map +1 -0
  142. package/dist/src/tools/impeccable/live/completion.d.ts +24 -0
  143. package/dist/src/tools/impeccable/live/completion.d.ts.map +1 -0
  144. package/dist/src/tools/impeccable/live/completion.js +26 -0
  145. package/dist/src/tools/impeccable/live/completion.js.map +1 -0
  146. package/dist/src/tools/impeccable/live/inject.d.ts +41 -0
  147. package/dist/src/tools/impeccable/live/inject.d.ts.map +1 -0
  148. package/dist/src/tools/impeccable/live/inject.js +394 -0
  149. package/dist/src/tools/impeccable/live/inject.js.map +1 -0
  150. package/dist/src/tools/impeccable/live/poll.d.ts +24 -0
  151. package/dist/src/tools/impeccable/live/poll.d.ts.map +1 -0
  152. package/dist/src/tools/impeccable/live/poll.js +180 -0
  153. package/dist/src/tools/impeccable/live/poll.js.map +1 -0
  154. package/dist/src/tools/impeccable/live/resume.d.ts +5 -0
  155. package/dist/src/tools/impeccable/live/resume.d.ts.map +1 -0
  156. package/dist/src/tools/impeccable/live/resume.js +30 -0
  157. package/dist/src/tools/impeccable/live/resume.js.map +1 -0
  158. package/dist/src/tools/impeccable/live/server.d.ts +6 -0
  159. package/dist/src/tools/impeccable/live/server.d.ts.map +1 -0
  160. package/dist/src/tools/impeccable/live/server.js +867 -0
  161. package/dist/src/tools/impeccable/live/server.js.map +1 -0
  162. package/dist/src/tools/impeccable/live/session-store.d.ts +72 -0
  163. package/dist/src/tools/impeccable/live/session-store.d.ts.map +1 -0
  164. package/dist/src/tools/impeccable/live/session-store.js +281 -0
  165. package/dist/src/tools/impeccable/live/session-store.js.map +1 -0
  166. package/dist/src/tools/impeccable/live/static/live-browser-session.js +123 -0
  167. package/dist/src/tools/impeccable/live/static/live-browser.js +4860 -0
  168. package/dist/src/tools/impeccable/live/static/modern-screenshot.umd.js +14 -0
  169. package/dist/src/tools/impeccable/live/status.d.ts +2 -0
  170. package/dist/src/tools/impeccable/live/status.d.ts.map +1 -0
  171. package/dist/src/tools/impeccable/live/status.js +52 -0
  172. package/dist/src/tools/impeccable/live/status.js.map +1 -0
  173. package/dist/src/tools/impeccable/live/wrap.d.ts +33 -0
  174. package/dist/src/tools/impeccable/live/wrap.d.ts.map +1 -0
  175. package/dist/src/tools/impeccable/live/wrap.js +572 -0
  176. package/dist/src/tools/impeccable/live/wrap.js.map +1 -0
  177. package/dist/src/tools/impeccable/load-context.d.ts +13 -0
  178. package/dist/src/tools/impeccable/load-context.d.ts.map +1 -0
  179. package/dist/src/tools/impeccable/load-context.js +79 -0
  180. package/dist/src/tools/impeccable/load-context.js.map +1 -0
  181. package/dist/src/tools/impeccable/paths.d.ts +34 -0
  182. package/dist/src/tools/impeccable/paths.d.ts.map +1 -0
  183. package/dist/src/tools/impeccable/paths.js +102 -0
  184. package/dist/src/tools/impeccable/paths.js.map +1 -0
  185. package/dist/src/tools/spec-entry-parser.d.ts +1 -1
  186. package/dist/src/tools/spec-entry-parser.d.ts.map +1 -1
  187. package/dist/src/tools/spec-entry-parser.js +1 -1
  188. package/dist/src/tools/spec-entry-parser.js.map +1 -1
  189. package/dist/src/tools/spec-init.d.ts.map +1 -1
  190. package/dist/src/tools/spec-init.js +26 -1
  191. package/dist/src/tools/spec-init.js.map +1 -1
  192. package/dist/src/tools/spec-loader.d.ts +1 -1
  193. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  194. package/dist/src/tools/spec-loader.js +2 -0
  195. package/dist/src/tools/spec-loader.js.map +1 -1
  196. package/package.json +2 -2
  197. package/workflows/claude-instructions.md +17 -5
  198. package/workflows/cli-tools-usage.md +10 -3
  199. package/workflows/delegate-usage.md +3 -2
  200. package/workflows/impeccable/adapt.md +190 -0
  201. package/workflows/impeccable/animate.md +175 -0
  202. package/workflows/impeccable/audit.md +133 -0
  203. package/workflows/impeccable/bolder.md +113 -0
  204. package/workflows/impeccable/brand.md +118 -0
  205. package/workflows/impeccable/clarify.md +174 -0
  206. package/workflows/impeccable/codex.md +105 -0
  207. package/workflows/impeccable/cognitive-load.md +106 -0
  208. package/workflows/impeccable/color-and-contrast.md +105 -0
  209. package/workflows/impeccable/colorize.md +154 -0
  210. package/workflows/impeccable/craft.md +123 -0
  211. package/workflows/impeccable/critique.md +261 -0
  212. package/workflows/impeccable/delight.md +302 -0
  213. package/workflows/impeccable/distill.md +111 -0
  214. package/workflows/impeccable/document.md +439 -0
  215. package/workflows/impeccable/extract.md +69 -0
  216. package/workflows/impeccable/harden.md +347 -0
  217. package/workflows/impeccable/heuristics-scoring.md +234 -0
  218. package/workflows/impeccable/interaction-design.md +195 -0
  219. package/workflows/impeccable/layout.md +141 -0
  220. package/workflows/impeccable/live.md +622 -0
  221. package/workflows/impeccable/motion-design.md +109 -0
  222. package/workflows/impeccable/onboard.md +234 -0
  223. package/workflows/impeccable/optimize.md +258 -0
  224. package/workflows/impeccable/overdrive.md +130 -0
  225. package/workflows/impeccable/personas.md +179 -0
  226. package/workflows/impeccable/polish.md +242 -0
  227. package/workflows/impeccable/product.md +62 -0
  228. package/workflows/impeccable/quieter.md +99 -0
  229. package/workflows/impeccable/responsive-design.md +114 -0
  230. package/workflows/impeccable/shape.md +165 -0
  231. package/workflows/impeccable/spatial-design.md +100 -0
  232. package/workflows/impeccable/teach.md +168 -0
  233. package/workflows/impeccable/typeset.md +124 -0
  234. package/workflows/impeccable/typography.md +159 -0
  235. package/workflows/impeccable/ux-writing.md +107 -0
  236. package/workflows/impeccable.md +164 -0
  237. package/workflows/maestro.md +7 -3
  238. package/workflows/skill-authoring.md +265 -0
  239. package/workflows/specs-add.md +3 -2
  240. package/workflows/specs-load.md +2 -1
  241. package/workflows/specs-setup.md +21 -1
@@ -1,710 +1,307 @@
1
- ---
2
- name: maestro-ralph
3
- description: Adaptive lifecycle engine -- infer state, build command chain
4
- argument-hint: "\"intent\" [-y] | status | continue | execute"
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
- ---
7
-
8
- <purpose>
9
- Closed-loop decision engine for the maestro workflow lifecycle.
10
- Coordinator assembles fully-resolved skill calls spawns via `spawn_agents_on_csv`
11
- delegates evaluation at decision nodes dynamically expands/shrinks chain.
12
-
13
- Entry points:
14
- - **`$maestro-ralph "intent"`** — New session: read state infer build → execute
15
- - **`$maestro-ralph execute`** / **`continue`** — Resume: run next wave(s) until decision or completion
16
- - **`$maestro-ralph status`** — Display session progress
17
-
18
- Two node types:
19
- - **external**: Executed via `spawn_agents_on_csv`. Barrier steps solo; non-barriers parallel.
20
- - **decision**: Delegate evaluation via `maestro delegate --role analyze`, then expand/proceed/escalate.
21
-
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
-
26
- Session at `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`.
27
- </purpose>
28
-
29
- <context>
30
- $ARGUMENTS intent text, flags, or keywords.
31
-
32
- **State files:**
33
- - `.workflow/state.json` artifact registry, milestones, phases
34
- - `.workflow/roadmap.md` milestone/phase structure
35
- - `.workflow/.maestro/ralph-*/status.json` ralph session state
36
-
37
- **Parse & Route:**
38
- ```
39
- Parse $ARGUMENTS:
40
- -y / --yes → auto_mode = true
41
- .md/.txt path input_doc (supplementary context for downstream commands)
42
- Remaining → intent
43
-
44
- Route:
45
- intent == "status" → handleStatus(). End.
46
- intent == "execute" | "continue" Phase 2 (Wave Execution).
47
-
48
- Check running ralph session (.workflow/.maestro/ralph-*/status.json, status=="running"):
49
- If found AND steps[current_step].type == "decision" AND steps[current_step].status == "running":
50
- Phase 2, Step 2.2 (Delegate Evaluation resume mid-decision)
51
- Else if intent is non-empty:
52
- Phase 1 (New Session)
53
- Else:
54
- → request_user_input: "请描述目标,或输入 status/continue/execute"
55
- ```
56
-
57
- HARD RULE: `input_doc` is supplementary context only. It NEVER substitutes for lifecycle stages.
58
-
59
- ### handleStatus()
60
- ```
61
- Find latest ralph session (by created_at).
62
- Display:
63
- Session: {id}
64
- Status: {status}
65
- Position: {lifecycle_position}
66
- Quality: {quality_mode}
67
- Progress: {completed}/{total} steps ({decision_count} decisions)
68
- Current: [{current_step}] {steps[current_step].skill} [{type}]
69
-
70
- Steps:
71
- [✓] 0. maestro-analyze 1 [W1, barrier]
72
- [▸] 1. maestro-plan 1 [barrier]
73
- [ ] 2. maestro-execute 1 [barrier]
74
- [ ] 3. post-verify [decision]
75
- ...
76
- End.
77
- ```
78
-
79
- **Flags:**
80
- - `-y` / `--yes` → `session.auto_mode = true`
81
- - Skip confirmation prompts
82
- - Decision nodes: auto-follow delegate verdict (no STOP), except post-debug-escalate
83
- - Failures: retry once then pause
84
-
85
- **`-y` downstream propagation** (appended to skill_call in CSV):
86
-
87
- | Skill | Flag | Effect |
88
- |-------|------|--------|
89
- | maestro-init | `-y` | 跳过交互提问 |
90
- | maestro-analyze | `-y` | 跳过 scoping 交互 |
91
- | maestro-brainstorm | `-y` | 跳过交互提问 |
92
- | maestro-roadmap | `-y` | 跳过交互选择 |
93
- | maestro-plan | `-y` | 跳过确认和澄清 |
94
- | maestro-execute | `-y` | 跳过确认,blocked 自动继续 |
95
- | quality-auto-test | `-y` | 跳过计划确认 |
96
- | quality-test | `-y --auto-fix` | 自动触发 gap-fix loop |
97
- | maestro-milestone-complete | `-y` | 跳过 knowledge promotion 交互 |
98
- | maestro-verify | `-y` | 跳过交互确认 |
99
- | quality-review | `-y` | 跳过交互确认 |
100
- | quality-debug | `-y` | 跳过交互确认 |
101
- | maestro-milestone-audit | `-y` | 跳过交互确认 |
102
-
103
- All lifecycle commands are listed. When auto_mode is true, buildSkillCall appends the corresponding flag per this table.
104
- </context>
105
-
106
- <invariants>
107
- 1. **ALL external steps via spawn_agents_on_csv** — coordinator NEVER executes skill logic directly
108
- 2. **Coordinator = prompt assembler** — classify → enrich args → build CSV → spawn → read results → assemble next
109
- 3. **Decision nodes delegate-evaluate** — use `maestro delegate --role analyze` for quality-gate assessment; structural decisions (post-milestone, post-debug-escalate) evaluated directly
110
- 4. **Decision STOP behavior** — default: STOP after evaluation; `-y` mode: auto-continue (except post-debug-escalate always STOPs)
111
- 5. **Barrier = solo wave** — analyze, plan, execute, brainstorm, roadmap always run alone
112
- 6. **Non-barriers can parallel** consecutive non-barrier, non-decision external steps grouped into one wave
113
- 7. **Wave-by-wave** never start wave N+1 before wave N results are read
114
- 8. **Coordinator owns context** — sub-agents never read prior results; coordinator assembles full skill_call
115
- 9. **Abort on failure** — `-y`: retry once then pause; non-`-y`: mark remaining skipped → pause
116
- 10. **Quality mode governs steps** — full/standard/quick determines which quality stages are included
117
- 11. **passed_gates skip** — already-passed gates not re-run in retry loops (unless code changed)
118
- </invariants>
119
-
120
- <execution>
121
-
122
- ## Phase 1: New Session
123
-
124
- ### 1.1: Read project state
125
-
126
- Read `.workflow/state.json` schema:
127
- ```json
128
- {
129
- "current_milestone": "MVP",
130
- "milestones": [{ "id": "M1", "name": "MVP", "status": "active", "phases": [1, 2] }],
131
- "artifacts": [{
132
- "id": "ANL-001", "type": "analyze|plan|execute|verify",
133
- "milestone": "MVP", "phase": 1, "scope": "phase|milestone|adhoc|standalone",
134
- "path": "phases/01-auth-multi-tenant", // relative to .workflow/scratch/
135
- "status": "completed", "depends_on": "PLN-001", "harvested": true
136
- }],
137
- "accumulated_context": { "key_decisions": [], "deferred": [] }
138
- }
139
- ```
140
-
141
- ### 1.2: Infer lifecycle position
142
-
143
- **Intent-based override:**
144
-
145
- If intent matches brainstorm pattern (contains "brainstorm", "头脑风暴", "探索", "ideate", or "设计思路"), position = `brainstorm` regardless of project state.
146
-
147
- Chain for existing project: `brainstorm → roadmap → analyze → ...` (skip init if `.workflow/state.json` exists).
148
-
149
- **Bootstrap detection:**
150
-
151
- | Condition | Position | Chain starts at |
152
- |-----------|----------|-----------------|
153
- | No `.workflow/` + no source files | `brainstorm` | brainstorm → init → roadmap → ... |
154
- | No `.workflow/` + has source files | `init` | init → roadmap → ... |
155
- | Has `.workflow/` but no state.json | `init` | init → roadmap → ... |
156
- | Has state.json | Artifact-based inference below |
157
-
158
- **Artifact-based inference:**
159
-
160
- Filter by `milestone == current_milestone`, target phase. Find latest completed artifact type:
161
-
162
- | State | Position |
163
- |-------|----------|
164
- | No milestones[] or no roadmap.md | `roadmap` |
165
- | No artifacts for target phase | `analyze` |
166
- | Latest == "analyze" | `plan` |
167
- | Latest == "plan" | `execute` |
168
- | Latest == "execute" | `verify` |
169
- | Latest == "verify" | Refine by result files |
170
-
171
- **Refine from verify results** (read `{artifact_dir}/`):
172
-
173
- | Condition | Position |
174
- |-----------|----------|
175
- | verification.json: `passed==false` or `gaps[]` non-empty | `verify-failed` |
176
- | verification.json: `passed==true`, no review.json, has `.tests/auto-test/report.json` | `review` |
177
- | verification.json: `passed==true`, no review.json, no `.tests/auto-test/report.json` | `business-test` (full) / `review` (standard/quick) |
178
- | review.json: `verdict=="BLOCK"` | `review-failed` |
179
- | review.json: `verdict!="BLOCK"` | `test` |
180
- | uat.md: all passed | `milestone-audit` |
181
- | uat.md: has failures | `test-failed` |
182
-
183
- **resolve_artifact_dir(artifact):**
184
- ```
185
- Full path = .workflow/scratch/{artifact.path}/
186
- Fallback: glob .workflow/scratch/*-P{phase}-*/ sorted by date DESC, take first
187
- ```
188
-
189
- ### 1.3: Resolve phase number
190
-
191
- Priority order:
192
- 1. Regex from intent: `phase\s*(\d+)` or bare number
193
- 2. Latest in-progress artifact's phase field
194
- 3. First incomplete phase in current milestone's `phases[]`
195
- 4. `null` if position is brainstorm/init/roadmap (deferred to post-roadmap)
196
- 5. request_user_input if ambiguous (auto_mode does NOT skip this)
197
-
198
- ### 1.4: Determine quality mode
199
-
200
- **Auto-inference (can be overridden by user to any mode):**
201
-
202
- | Condition | Mode | Pipeline |
203
- |-----------|------|----------|
204
- | Has requirements/REQ-*.md + phase scope | `full` | verify → business-test → review → test-gen → test |
205
- | Default | `standard` | verify review test (test-gen conditional on coverage < 80%) |
206
- | User explicit `--quality quick` | `quick` | verify review --tier quick |
207
-
208
- User can specify `--quality full|standard|quick` to override auto-inference.
209
-
210
- ### 1.5: Build command sequence
211
-
212
- **Lifecycle stages:**
213
-
214
- | Stage | Skill | Barrier | Decision after | Condition |
215
- |-------|-------|---------|----------------|-----------|
216
- | brainstorm | `maestro-brainstorm "{intent}"` | yes | | intent-override or 0→1 bootstrap |
217
- | init | `maestro-init` | no | | always |
218
- | roadmap | `maestro-roadmap "{intent}"` | yes | — | always |
219
- | analyze | `maestro-analyze {phase}` | yes | — | always |
220
- | plan | `maestro-plan {phase}` | yes | — | always |
221
- | execute | `maestro-execute {phase}` | yes | | always |
222
- | verify | `maestro-verify {phase}` | no | `post-verify` | always |
223
- | business-test | `quality-auto-test {phase}` | no | `post-business-test` | full only |
224
- | review | `quality-review {phase}` | no | `post-review` | always (quick: +`--tier quick`) |
225
- | test-gen | `quality-auto-test {phase}` | no | — | full; standard if coverage < 80% |
226
- | test | `quality-test {phase}` | no | `post-test` | full/standard |
227
- | milestone-audit | `maestro-milestone-audit` | no | | always |
228
- | milestone-complete | `maestro-milestone-complete` | no | `post-milestone` | always |
229
-
230
- **Build rules:**
231
- 1. Start from inferred position, skip completed stages
232
- 2. Filter by quality_mode (remove inapplicable stages)
233
- 3. After each decision-triggering stage, insert decision node: `{ decision, retry_count: 0, max_retries: 2 }`
234
- 4. Conditional steps (test-gen in standard) use: `{ "condition": "check_coverage", "threshold": 80 }`
235
- 5. Phase-independent commands (brainstorm, roadmap, init) use `"{intent}"` as args
236
- 6. Commands needing prior output (analyze→plan, plan→execute) have args resolved via artifact lookup at wave build time by coordinator (see buildSkillCall enrichment table in 2.3)
237
- 7. Args use placeholders resolved at wave build time by coordinator
238
-
239
- **Example — from "plan" position, standard quality mode:**
240
- ```json
241
- [
242
- { "index": 0, "type": "external", "skill": "maestro-plan", "args": "{phase}", "barrier": true },
243
- { "index": 1, "type": "external", "skill": "maestro-execute", "args": "{phase}", "barrier": true },
244
- { "index": 2, "type": "external", "skill": "maestro-verify", "args": "{phase}" },
245
- { "index": 3, "type": "decision", "skill": "maestro-ralph", "args": "{\"decision\":\"post-verify\",\"retry_count\":0,\"max_retries\":2}" },
246
- { "index": 4, "type": "external", "skill": "quality-review", "args": "{phase}" },
247
- { "index": 5, "type": "decision", "skill": "maestro-ralph", "args": "{\"decision\":\"post-review\",\"retry_count\":0,\"max_retries\":2}" },
248
- { "index": 6, "type": "external", "skill": "quality-auto-test", "args": "{phase}", "condition": "check_coverage" },
249
- { "index": 7, "type": "external", "skill": "quality-test", "args": "{phase}" },
250
- { "index": 8, "type": "decision", "skill": "maestro-ralph", "args": "{\"decision\":\"post-test\",\"retry_count\":0,\"max_retries\":2}" },
251
- { "index": 9, "type": "external", "skill": "maestro-milestone-audit", "args": "" },
252
- { "index": 10, "type": "external", "skill": "maestro-milestone-complete", "args": "" },
253
- { "index": 11, "type": "decision", "skill": "maestro-ralph", "args": "{\"decision\":\"post-milestone\"}" }
254
- ]
255
- ```
256
-
257
- ### 1.6: Create session
258
-
259
- Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`:
260
- ```json
261
- {
262
- "session_id": "ralph-{YYYYMMDD-HHmmss}",
263
- "source": "ralph",
264
- "created_at": "ISO", "updated_at": "ISO",
265
- "intent": "{user_intent}",
266
- "status": "running",
267
- "chain_name": "ralph-lifecycle",
268
- "task_type": "lifecycle",
269
- "lifecycle_position": "{position}",
270
- "target": "milestone-complete",
271
- "phase": null | N,
272
- "milestone": null | "{M}",
273
- "auto_mode": false,
274
- "quality_mode": "standard",
275
- "passed_gates": [],
276
- "context": {
277
- "issue_id": null, "milestone_num": null, "spec_session_id": null,
278
- "scratch_dir": null, "plan_dir": null, "analysis_dir": null, "brainstorm_dir": null
279
- },
280
- "steps": [...],
281
- "waves": [],
282
- "current_step": 0
283
- }
284
- ```
285
-
286
- ### 1.7: Initialize tracking + confirm
287
-
288
- ```
289
- // Goal = outer constraint ensures entire lifecycle chain completes
290
- functions.create_goal({
291
- objective: `Ralph lifecycle: ${lifecycle_position} → milestone-complete | ${steps.length} steps (${decision_count} decisions) | quality=${quality_mode}`
292
- })
293
-
294
- // Plan = inner tracking sub-step progress
295
- functions.update_plan({
296
- explanation: "Ralph lifecycle: {position} milestone-complete",
297
- plan: steps.map(step => ({ step: stepLabel(step), status: "pending" }))
298
- })
299
- ```
300
-
301
- Display:
302
- ```
303
- ============================================================
304
- RALPH DECISION ENGINE
305
- ============================================================
306
- Position: {position} (Phase {N}, {milestone})
307
- Target: milestone-complete
308
- Quality: {quality_mode}
309
- Steps: {total} ({decision_count} decision points)
310
-
311
- [ ] 0. maestro-plan {phase} [barrier]
312
- [ ] 1. maestro-execute {phase} [barrier]
313
- [ ] 2. maestro-verify {phase} [external]
314
- [ ] 3. ◆ post-verify [decision]
315
- ...
316
- ============================================================
317
- ```
318
-
319
- - If `-y`: proceed directly
320
- - Else: request_user_input → Proceed / Edit / Cancel / Change quality mode
321
-
322
- Fall through to Phase 2.
323
-
324
- ---
325
-
326
- ## Phase 2: Wave Execution Loop
327
-
328
- ### 2.1: Load session + find next step
329
-
330
- Read status.json. Rebuild `update_plan` from step statuses.
331
- Find first pending step.
332
-
333
- - If decision node → Step 2.2 (Delegate Evaluation)
334
- - If external node → Step 2.3 (Wave Execution)
335
- - If no pending → Phase 3 (Completion)
336
-
337
- ### 2.2: Delegate Evaluation (decision nodes)
338
-
339
- **Route by decision type:**
340
- - Quality-gate decisions (post-verify, post-business-test, post-review, post-test) → delegate analysis
341
- - Structural decisions (post-milestone, post-debug-escalate) → direct evaluation
342
-
343
- #### 2.2a: Delegate quality-gate assessment
344
-
345
- Read decision metadata: `{ decision, retry_count, max_retries }`
346
-
347
- **Result file mapping:**
348
-
349
- | Decision | Files to include |
350
- |----------|-----------------|
351
- | post-verify | `{artifact_dir}/verification.json` |
352
- | post-business-test | `{artifact_dir}/.tests/auto-test/report.json` |
353
- | post-review | `{artifact_dir}/review.json` |
354
- | post-test | `{artifact_dir}/uat.md`, `{artifact_dir}/.tests/test-results.json` |
355
-
356
- ```
357
- exec_command({
358
- cmd: `maestro delegate "PURPOSE: 评估 ${meta.decision} 质量门结果
359
- TASK: 读取结果文件 | 分析通过/失败 | 评估严重性 | 给出建议
360
- MODE: analysis
361
- CONTEXT: @${result_files}
362
- EXPECTED: 严格按格式输出:
363
- ---VERDICT---
364
- STATUS: proceed | fix | escalate
365
- REASON: 一句话解释
366
- GAP_SUMMARY: 问题描述(fix/escalate 时填写)
367
- CONFIDENCE: high | medium | low
368
- CONFIDENCE_SCORE: 0-100(从结果文件中读取置信度分数,无则估算)
369
- WEAKEST_DIMENSION: 最弱维度名称
370
- ---END---
371
- CONSTRAINTS: 只评估 | STATUS 三选一 | 置信度 < 60% 倾向 fix | retry ${meta.retry_count}/${meta.max_retries} 达上限必须 escalate" --role analyze --mode analysis`,
372
- yield_time_ms: 30000,
373
- max_output_tokens: 6000
374
- })
375
- // ⚠️ If session_id returned → poll write_stdin until completion (see @~/.maestro/workflows/delegate-protocol.codex.md)
376
- // NEVER skip — verdict is required for decision routing
377
- ```
378
-
379
- **Parse verdict** (on callback):
380
- ```
381
- Extract STATUS / REASON / GAP_SUMMARY / CONFIDENCE / CONFIDENCE_SCORE / WEAKEST_DIMENSION from output.
382
- If parse fails → fallback: STATUS = "fix", GAP_SUMMARY = generic
383
-
384
- Confidence-based verdict adjustment (after parse, before apply):
385
- If CONFIDENCE_SCORE < 60 AND STATUS == "proceed":
386
- → Override to "fix", REASON += " (置信度不足: {score}%,{weakest} 需加强)"
387
- If CONFIDENCE_SCORE > 95 AND STATUS == "fix" AND retry_count > 0:
388
- → Suggest "proceed" override, REASON += " (置信度充分: {score}%,建议通过)"
389
- ```
390
-
391
- **Confidence-aware evaluation**: Before delegating, check if artifact contains confidence section (added by downstream commands). If found, include `已有置信度评估: 整体 {overall}%, 最弱维度: {weakest} ({score}%)` in delegate prompt as additional signal.
392
-
393
- **Apply verdict:**
394
-
395
- | Mode | Behavior |
396
- |------|----------|
397
- | `-y` (auto_mode) | Follow adjusted verdict directly, no user prompt |
398
- | Interactive + confidence_score >= 80 | Display recommendation with confidence, prompt user |
399
- | Interactive + confidence_score < 80 | Display recommendation **with confidence warning**, prompt user |
400
-
401
- **If auto_mode == true**: skip prompt, apply adjusted verdict directly → jump to "Verdict → action".
402
-
403
- **If auto_mode == false** (interactive): prompt via `request_user_input`:
404
- ```json
405
- { "questions": [{ "id": "decision_override", "header": "◆ {meta.decision} 评估结果", "question": "STATUS: {verdict.status}\nREASON: {verdict.reason}\n\n选择操作:", "options": [
406
- { "label": "按建议执行 (Recommended)", "description": "执行 {verdict.status} 操作" },
407
- { "label": "覆盖 proceed", "description": "忽略问题,强制通过" },
408
- { "label": "覆盖 fix", "description": "强制进入修复循环" },
409
- { "label": "取消", "description": "暂停会话,手动处理" }
410
- ]}] }
411
- ```
412
-
413
- **Verdict → action:**
414
-
415
- | Verdict | Action |
416
- |---------|--------|
417
- | `proceed` | Add gate to passed_gates, continue |
418
- | `fix` | Clear passed_gates (code will change), insert fix-loop |
419
- | `escalate` | Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]` |
420
-
421
- #### 2.2b: Fix-loop templates
422
-
423
- The delegate's `gap_summary` is passed as context to `quality-debug`.
424
-
425
- **passed_gates reset**: Every fix-loop inserts `maestro-execute` (code changes), so `passed_gates` is cleared at insertion time (see 2.2a verdict action). Downstream decision nodes restart with `retry: 0` to re-validate against modified code. Only the triggering decision's own `retry_count` increments.
426
-
427
- **post-verify fix-loop:**
428
- Reset: `passed_gates = []` (code changed via execute)
429
- ```
430
- quality-debug "{gap_summary}"
431
- maestro-plan --gaps {phase} [barrier]
432
- maestro-execute {phase} [barrier]
433
- maestro-verify {phase}
434
- decision:post-verify {retry+1}
435
- ```
436
-
437
- **post-business-test fix-loop (full mode):**
438
- Reset: `passed_gates = []` (code changed via execute); post-verify restarts at retry: 0
439
- ```
440
- quality-debug --from-business-test "{gap_summary}"
441
- maestro-plan --gaps {phase} [barrier]
442
- maestro-execute {phase} [barrier]
443
- maestro-verify {phase}
444
- decision:post-verify {retry: 0}
445
- quality-auto-test {phase}
446
- decision:post-business-test {retry+1}
447
- ```
448
-
449
- **post-review fix-loop:**
450
- Reset: `passed_gates = []` (code changed via execute); post-verify restarts at retry: 0
451
- ```
452
- quality-debug "{gap_summary}"
453
- maestro-plan --gaps {phase} [barrier]
454
- maestro-execute {phase} [barrier]
455
- maestro-verify {phase}
456
- decision:post-verify {retry: 0}
457
- quality-review {phase}
458
- decision:post-review {retry+1}
459
- ```
460
-
461
- **post-test fix-loop:**
462
- Reset: `passed_gates = []` (code changed via execute); all downstream decisions restart at retry: 0
463
- ```
464
- quality-debug --from-uat "{gap_summary}"
465
- maestro-plan --gaps {phase} [barrier]
466
- maestro-execute {phase} [barrier]
467
- maestro-verify {phase}
468
- decision:post-verify {retry: 0}
469
- quality-auto-test {phase} # full mode only
470
- decision:post-business-test {retry: 0} # full mode only
471
- quality-review {phase}
472
- decision:post-review {retry: 0}
473
- quality-auto-test {phase} # full mode; standard if coverage < 80%
474
- quality-test {phase}
475
- decision:post-test {retry+1}
476
- ```
477
-
478
- #### 2.2c: Structural decisions (direct evaluation)
479
-
480
- **post-milestone:**
481
- ```
482
- Read .workflow/state.json — check next milestone (status "pending"/"active")
483
- If found: update session (milestone, phase, reset passed_gates), re-infer quality_mode,
484
- insert lifecycle via buildSteps() for next milestone
485
- If none: proceed — session completes naturally
486
- ```
487
-
488
- **post-debug-escalate:**
489
- ```
490
- Set session status = "paused"
491
- Display: ◆ 已达最大重试次数,debug 已执行。请人工介入检查结果。
492
- STOP (always, regardless of -y)
493
- ```
494
-
495
- #### 2.2d: Finalize decision
496
-
497
- ```
498
- Mark decision step "completed"
499
- Reindex steps if commands inserted
500
- Write status.json
501
- Sync update_plan
502
-
503
- Display: ◆ Decision: {type} → {verdict.status} ({verdict.reason})
504
-
505
- STOP behavior:
506
- post-debug-escalate → always STOP
507
- auto_mode == true → no STOP, continue to 2.3
508
- auto_mode == false → STOP. Display: ⏸ 使用 $maestro-ralph execute 继续
509
- ```
510
-
511
- ### 2.3: Build and Execute Wave
512
-
513
- **Loop while pending non-decision steps exist:**
514
-
515
- **1. buildNextWave:**
516
- - Conditional step → evaluate condition, skip if not met:
517
- - `check_coverage`: read `{artifact_dir}/validation.json`, if `coverage >= threshold` → skip test-gen; else → include
518
- - If validation.json not found → include (assume coverage insufficient)
519
- - Barrier step → solo wave (single row CSV)
520
- - Non-barrier → collect consecutive non-barrier, non-decision steps (multi-row CSV)
521
- - Stop at first decision node
522
-
523
- **2. buildSkillCall(step, session)** — assemble fully-resolved command:
524
-
525
- Placeholder resolution:
526
- ```
527
- {phase} → session.phase
528
- {intent} → session.intent
529
- {scratch_dir} → latest artifact path
530
- {plan_dir} → session.context.plan_dir
531
- {analysis_dir} → session.context.analysis_dir
532
- ```
533
-
534
- Per-skill enrichment:
535
- | Skill | Enrichment |
536
- |-------|-----------|
537
- | maestro-brainstorm | args empty → `"{intent}"` |
538
- | maestro-roadmap | args empty → `"{intent}"` |
539
- | maestro-analyze | args empty → `{phase}` |
540
- | maestro-plan | resolve latest analyze artifact → `--dir .workflow/scratch/{path}` |
541
- | maestro-execute | resolve latest plan artifact → `--dir .workflow/scratch/{path}` |
542
- | quality-debug | append gap_summary or `--from-uat`/`--from-business-test` |
543
- | quality-* / maestro-verify / milestone-* | args empty → `{phase}` or empty |
544
-
545
- Auto flag: append from propagation table if `auto_mode == true`.
546
-
547
- Result: `$<skill-name> <enriched-args> [auto-flag]`
548
-
549
- **3. Write wave CSV:** `{sessionDir}/wave-{N}.csv`
550
-
551
- **4. Update plan** (mark wave steps in_progress)
552
-
553
- **5. Spawn:**
554
- ```
555
- spawn_agents_on_csv({
556
- csv_path: "{sessionDir}/wave-{N}.csv",
557
- id_column: "id",
558
- instruction: WAVE_INSTRUCTION,
559
- max_workers: <wave_size>,
560
- max_runtime_seconds: 3600,
561
- output_csv_path: "{sessionDir}/wave-{N}-results.csv",
562
- output_schema: RESULT_SCHEMA
563
- })
564
- ```
565
-
566
- **6. Read results** — update step statuses from results CSV
567
-
568
- **7. Barrier context update:**
569
-
570
- | Barrier | Read | Update |
571
- |---------|------|--------|
572
- | maestro-analyze | context.md, state.json | context.analysis_dir |
573
- | maestro-plan | plan.json | context.plan_dir |
574
- | maestro-execute | results | context.exec_status |
575
- | maestro-brainstorm | .brainstorming/ | context.brainstorm_dir |
576
- | maestro-roadmap | specs/ | context.spec_session_id |
577
-
578
- **8. Persist** — write status.json + sync update_plan
579
-
580
- **9. Failure check:**
581
- - `-y`: retry once, then pause (await manual intervention)
582
- - Non-`-y`: mark remaining skipped → pause → STOP
583
-
584
- **10. Next step check:**
585
- - Decision node + auto_mode → loop to 2.2
586
- - Decision node + non-auto → STOP
587
- - External node → loop to step 1
588
-
589
- ---
590
-
591
- ## Phase 3: Completion
592
-
593
- ```
594
- status.status = "completed"
595
- status.updated_at = now
596
- Write status.json
597
-
598
- functions.update_plan({
599
- explanation: "Ralph lifecycle complete",
600
- plan: steps.map(step => ({ step: stepLabel(step), status: "completed" }))
601
- })
602
-
603
- // Release goal constraint — only on true completion
604
- functions.update_goal({ status: "complete" })
605
- ```
606
-
607
- **Note**: Pause/escalate paths (`post-debug-escalate` STOP, session pause) do NOT call `update_goal` — goal stays running for resume.
608
-
609
- Display:
610
- ```
611
- ============================================================
612
- RALPH COMPLETE
613
- ============================================================
614
- Session: {session_id}
615
- Quality: {quality_mode}
616
- Phase: {phase} → {milestone}
617
- Waves: {wave_count} executed
618
- Steps: {completed}/{total} ({skipped} skipped)
619
-
620
- [✓] 0. maestro-plan 1 [W1]
621
- [✓] 1. maestro-execute 1 [W2]
622
- [✓] 2. maestro-verify 1 [W3]
623
- [✓] 3. ◆ post-verify → proceed [decision]
624
- [~] 4. quality-auto-test 1 [skipped: standard mode]
625
- [✓] 5. quality-review 1 [W4]
626
- ...
627
- ============================================================
628
- ```
629
-
630
- </execution>
631
-
632
- <csv_schema>
633
- ### wave-{N}.csv
634
-
635
- Coordinator 已完成 arg 组装 + auto flag 附加:
636
-
637
- ```csv
638
- id,skill_call,topic
639
- "3","$maestro-verify 1","Ralph step 3/14: verify phase 1"
640
- "4","$quality-review 1 --tier quick","Ralph step 4/14: review phase 1"
641
- ```
642
-
643
- Rules:
644
- - `skill_call`: complete `$<skill> <args> [auto-flag]` from `buildSkillCall()`
645
- - `topic`: human-readable step description
646
- - Non-barrier external + non-decision → multi-row (parallel)
647
- - Barrier external → single-row (solo)
648
- - Decision nodes NEVER appear in CSV — processed by coordinator directly
649
-
650
- ### Sub-Agent Instruction
651
-
652
- ```
653
- 你是 CSV job 子 agent。
654
-
655
- 执行技能调用:{skill_call}
656
- 任务说明:{topic}
657
-
658
- 限制:
659
- - 不要修改 .workflow/.maestro/ 下的 status 文件
660
- - skill 内部有自己的 session 管理,按 skill SKILL.md 执行
661
-
662
- 完成后调用 `report_agent_job_result`,返回:
663
- {"status":"completed|failed","skill_call":"{skill_call}","summary":"一句话结果","artifacts":"产物路径","error":"失败原因"}
664
- ```
665
-
666
- ### Result Schema
667
-
668
- `{ status, skill_call, summary, artifacts, error }` — all string
669
- </csv_schema>
670
-
671
- <error_codes>
672
- | Code | Severity | Description | Recovery |
673
- |------|----------|-------------|----------|
674
- | E001 | error | No intent and no running session | Prompt for intent |
675
- | E002 | error | Cannot infer lifecycle position | Show raw state, ask user |
676
- | E003 | error | Artifact dir not found for decision | Show glob results, ask user |
677
- | E004 | error | Delegate verdict parse failed | Fallback: treat as "fix" |
678
- | E005 | error | Delegate execution failed | Fallback: treat as "fix" with generic summary |
679
- | E006 | error | Wave timeout (max_runtime_seconds) | Mark step failed, pause |
680
- | E007 | error | No session found for execute/continue | Suggest $maestro-ralph "intent" |
681
- | W001 | warning | Decision node expanded chain | Auto-handled, log expansion |
682
- | W002 | warning | Max retries reached, escalating | Auto-handled |
683
- | W003 | warning | Multiple running sessions found | Use latest, warn user |
684
- | W004 | warning | Delegate confidence == "low" | Show warning in interactive mode |
685
- </error_codes>
686
-
687
- <success_criteria>
688
- - [ ] state.json parsed with actual schema (type, path, scope, milestone, depends_on)
689
- - [ ] Lifecycle position inferred from bootstrap + artifact chain + result files
690
- - [ ] Artifact dir resolved via resolve_artifact_dir() with fallback glob
691
- - [ ] Quality mode (full/standard/quick) correctly inferred and governs step generation
692
- - [ ] Conditional steps evaluated at decision time (coverage threshold)
693
- - [ ] buildSkillCall() completes arg enrichment + auto flag, CSV contains full commands
694
- - [ ] Quality-gate decisions delegate-evaluated via `maestro delegate --role analyze`
695
- - [ ] Delegate verdict parsed: STATUS / REASON / GAP_SUMMARY / CONFIDENCE / CONFIDENCE_SCORE / WEAKEST_DIMENSION
696
- - [ ] Confidence-based verdict adjustment applied (< 60% bias fix, > 95% bias proceed)
697
- - [ ] Artifact confidence sections read when available as additional signal
698
- - [ ] `-y` mode: auto-follow adjusted verdict, no STOP (except post-debug-escalate)
699
- - [ ] Interactive mode: display recommendation with confidence score + request_user_input with override
700
- - [ ] Delegate failure fallback: treat as "fix" verdict
701
- - [ ] passed_gates[] tracks passed quality gates, skips re-runs in retry loops
702
- - [ ] passed_gates cleared when code changes (fix-loop inserts execute step)
703
- - [ ] Fix-loop templates correctly use gap_summary from delegate
704
- - [ ] retry_count tracked per decision, max_retries enforced → escalation
705
- - [ ] ALL external steps via spawn_agents_on_csv — coordinator never executes directly
706
- - [ ] Barrier steps solo wave, non-barriers parallel
707
- - [ ] functions.update_plan() initialized in 1.7, synced per wave, finalized in Phase 3
708
- - [ ] status.json persisted after every wave and decision
709
- - [ ] Command insertion + reindex preserves step integrity
710
- </success_criteria>
1
+ ---
2
+ name: maestro-ralph
3
+ description: Adaptive lifecycle engine -- infer state, build command chain
4
+ argument-hint: "\"intent\" [-y] | status | continue | execute"
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
+ ---
7
+
8
+ <purpose>
9
+ Closed-loop decision engine for the maestro workflow lifecycle.
10
+ Coordinator assembles fully-resolved skill calls -> spawns via `spawn_agents_on_csv` ->
11
+ delegates evaluation at decision nodes -> dynamically expands/shrinks chain.
12
+
13
+ Entry: `"intent"` (new session), `execute`/`continue` (resume), `status` (display).
14
+ Two node types: **external** (spawn_agents_on_csv) and **decision** (delegate evaluate).
15
+ Session at `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`.
16
+ </purpose>
17
+
18
+ <context>
19
+ $ARGUMENTS -- intent text, flags, or keywords.
20
+
21
+ **Parse**: `-y` -> auto_mode. `.md/.txt` path -> input_doc (supplementary, never substitutes lifecycle). Remaining -> intent.
22
+
23
+ **`-y` downstream propagation**:
24
+
25
+ | Skill | Flag | Effect |
26
+ |-------|------|--------|
27
+ | maestro-init | `-y` | skip interactive |
28
+ | maestro-analyze | `-y` | skip scoping |
29
+ | maestro-brainstorm | `-y` | skip questions |
30
+ | maestro-roadmap | `-y` | skip choices |
31
+ | maestro-plan | `-y` | skip confirmation |
32
+ | maestro-execute | `-y` | skip confirmation, auto-continue blocked |
33
+ | quality-auto-test | `-y` | skip plan confirmation |
34
+ | quality-test | `-y --auto-fix` | auto gap-fix loop |
35
+ | maestro-verify | `-y` | skip confirmation |
36
+ | quality-review | `-y` | skip confirmation |
37
+ | quality-debug | `-y` | skip confirmation |
38
+ | maestro-milestone-complete | `-y` | skip knowledge promotion |
39
+ | maestro-milestone-audit | `-y` | skip confirmation |
40
+
41
+ **State files**: `.workflow/state.json`, `.workflow/roadmap.md`, `.workflow/.maestro/ralph-*/status.json`
42
+ </context>
43
+
44
+ <invariants>
45
+ 1. **ALL external steps via spawn_agents_on_csv** -- coordinator NEVER executes skill logic directly
46
+ 2. **Coordinator = prompt assembler** -- classify -> enrich args -> build CSV -> spawn -> read results -> assemble next
47
+ 3. **Decision nodes delegate-evaluate** -- `maestro delegate --role analyze`; structural decisions evaluated directly
48
+ 4. **Barrier = solo wave** -- analyze, plan, execute, brainstorm, roadmap always run alone
49
+ 5. **Non-barriers can parallel** -- consecutive non-barrier, non-decision external steps grouped
50
+ 6. **Wave-by-wave** -- never start wave N+1 before wave N results read
51
+ 7. **Coordinator owns context** -- sub-agents never read prior results; coordinator assembles full skill_call
52
+ 8. **Quality mode governs steps** -- full/standard/quick determines quality stages
53
+ 9. **passed_gates skip** -- already-passed gates not re-run (unless code changed)
54
+ </invariants>
55
+
56
+ <state_machine>
57
+
58
+ <states>
59
+ S_PARSE_ROUTE -- 解析参数、路由入口点 PERSIST: --
60
+ S_STATUS -- 显示 session 进度后结束 PERSIST: --
61
+ S_INFER -- 推断生命周期位置 PERSIST: session.lifecycle_position
62
+ S_RESOLVE_PHASE -- 解析目标 phase PERSIST: session.phase
63
+ S_QUALITY_MODE -- 确定质量模式 full/standard/quick PERSIST: session.quality_mode
64
+ S_BUILD_CHAIN -- 构建步骤链 PERSIST: session.steps[]
65
+ S_CREATE_SESSION -- 写 status.json PERSIST: session (full)
66
+ S_CONFIRM -- 用户确认(auto_mode skip) PERSIST: --
67
+ S_LOAD_NEXT -- 找下一个 pending step PERSIST: --
68
+ S_WAVE_EXEC -- 构建并执行 wave PERSIST: session.waves[], context
69
+ S_DECISION_EVAL -- 评估质量门 PERSIST: --
70
+ S_APPLY_VERDICT -- 应用裁决 PERSIST: passed_gates[], retry_count
71
+ S_FIX_LOOP -- 插入修复步骤、重索引 PERSIST: session.steps[] (expanded)
72
+ S_COMPLETE -- 标记完成 PERSIST: session.status = "completed"
73
+ S_PAUSED -- 暂停等待人工 PERSIST: session.status = "paused"
74
+ S_FALLBACK -- 请求用户输入 PERSIST: session.status = "paused"
75
+ </states>
76
+
77
+ <transitions>
78
+
79
+ S_PARSE_ROUTE:
80
+ -> S_STATUS WHEN: intent == "status"
81
+ -> S_LOAD_NEXT WHEN: intent == "execute" | "continue"
82
+ -> S_DECISION_EVAL WHEN: running session with decision step in "running"
83
+ -> S_INFER WHEN: intent non-empty
84
+ -> S_FALLBACK WHEN: no intent AND no running session
85
+
86
+ S_STATUS -> END DO: A_SHOW_STATUS
87
+
88
+ S_INFER:
89
+ -> S_RESOLVE_PHASE WHEN: position resolved DO: A_INFER_POSITION
90
+ -> S_FALLBACK WHEN: cannot infer
91
+
92
+ S_RESOLVE_PHASE:
93
+ -> S_QUALITY_MODE DO: A_RESOLVE_PHASE
94
+
95
+ S_QUALITY_MODE:
96
+ -> S_BUILD_CHAIN DO: A_DETERMINE_QUALITY_MODE
97
+
98
+ S_BUILD_CHAIN:
99
+ -> S_CREATE_SESSION DO: A_BUILD_STEPS
100
+
101
+ S_CREATE_SESSION:
102
+ -> S_CONFIRM WHEN: not auto_mode
103
+ -> S_LOAD_NEXT WHEN: auto_mode
104
+
105
+ S_CONFIRM:
106
+ -> S_LOAD_NEXT WHEN: "Proceed"
107
+ -> S_BUILD_CHAIN WHEN: "Edit"
108
+ -> S_QUALITY_MODE WHEN: "Change quality mode"
109
+ -> S_PAUSED WHEN: "Cancel"
110
+
111
+ S_LOAD_NEXT:
112
+ -> S_DECISION_EVAL WHEN: next_step.type == "decision"
113
+ -> S_WAVE_EXEC WHEN: next_step.type == "external"
114
+ -> S_COMPLETE WHEN: no pending steps
115
+
116
+ S_WAVE_EXEC:
117
+ -> S_LOAD_NEXT WHEN: success DO: A_BUILD_AND_SPAWN_WAVE
118
+ -> S_PAUSED WHEN: failed GUARD: auto_mode retry once then pause
119
+
120
+ S_DECISION_EVAL:
121
+ -> S_APPLY_VERDICT WHEN: quality-gate DO: A_DELEGATE_EVALUATE
122
+ -> S_APPLY_VERDICT WHEN: structural DO: A_STRUCTURAL_EVALUATE
123
+
124
+ S_APPLY_VERDICT:
125
+ -> S_LOAD_NEXT WHEN: proceed DO: add gate to passed_gates
126
+ -> S_FIX_LOOP WHEN: fix DO: clear passed_gates, increment retry
127
+ -> S_PAUSED WHEN: escalate
128
+ -> S_LOAD_NEXT WHEN: post-milestone + next milestone DO: A_ADVANCE_MILESTONE
129
+ -> S_COMPLETE WHEN: post-milestone + no next
130
+ -> S_PAUSED WHEN: post-debug-escalate (always, even -y)
131
+ GUARD: retry >= max_retries -> force escalate
132
+ GUARD: confidence < 60 AND proceed -> override to fix
133
+ GUARD: confidence > 95 AND fix AND retry > 0 -> suggest proceed
134
+
135
+ S_FIX_LOOP:
136
+ -> S_LOAD_NEXT DO: A_INSERT_FIX_LOOP
137
+
138
+ S_COMPLETE -> END DO: A_FINALIZE
139
+ S_PAUSED -> END DO: A_PAUSE_SESSION
140
+ S_FALLBACK -> S_PARSE_ROUTE WHEN: user input | -> END WHEN: cancel
141
+
142
+ </transitions>
143
+
144
+ <actions>
145
+
146
+ ### A_INFER_POSITION
147
+
148
+ **Intent-based override**: brainstorm pattern -> position = brainstorm.
149
+
150
+ **Bootstrap detection**:
151
+
152
+ | Condition | Position |
153
+ |-----------|----------|
154
+ | No .workflow/ + no source | brainstorm |
155
+ | No .workflow/ + has source | init |
156
+ | Has .workflow/ but no state.json | init |
157
+ | Has state.json | artifact-based inference |
158
+
159
+ **Artifact-based**: filter by current_milestone + target phase. Latest artifact type: none->analyze, analyze->plan, plan->execute, execute->verify, verify->refine from result files:
160
+
161
+ | Condition | Position |
162
+ |-----------|----------|
163
+ | verification.json: passed==false or gaps[] non-empty | verify-failed |
164
+ | passed==true, no review.json, has auto-test report | review |
165
+ | passed==true, no review.json, no auto-test report | business-test (full) / review (standard/quick) |
166
+ | review.json: verdict=="BLOCK" | review-failed |
167
+ | review.json: verdict!="BLOCK" | test |
168
+ | uat.md: all passed | milestone-audit |
169
+ | uat.md: has failures | test-failed |
170
+
171
+ ### A_RESOLVE_PHASE
172
+
173
+ Priority: regex from intent `phase\s*(\d+)` -> latest in-progress artifact's phase -> first incomplete phase -> null (brainstorm/init/roadmap) -> request_user_input if ambiguous.
174
+
175
+ ### A_DETERMINE_QUALITY_MODE
176
+
177
+ | Condition | Mode | Pipeline |
178
+ |-----------|------|----------|
179
+ | Has REQ-*.md + phase scope | full | verify -> business-test -> review -> test-gen -> test |
180
+ | Default | standard | verify -> review -> test (test-gen if coverage < 80%) |
181
+ | User --quality quick | quick | verify -> review --tier quick |
182
+
183
+ ### A_BUILD_STEPS
184
+
185
+ Lifecycle stages (start from position, skip completed, filter by quality_mode):
186
+
187
+ | Stage | Skill | Barrier | Decision after |
188
+ |-------|-------|---------|----------------|
189
+ | brainstorm | maestro-brainstorm | yes | -- |
190
+ | init | maestro-init | no | -- |
191
+ | roadmap | maestro-roadmap | yes | -- |
192
+ | analyze | maestro-analyze | yes | -- |
193
+ | plan | maestro-plan | yes | -- |
194
+ | execute | maestro-execute | yes | -- |
195
+ | verify | maestro-verify | no | post-verify |
196
+ | business-test | quality-auto-test | no | post-business-test (full) |
197
+ | review | quality-review | no | post-review |
198
+ | test-gen | quality-auto-test | no | -- (full; standard if coverage<80%) |
199
+ | test | quality-test | no | post-test |
200
+ | milestone-audit | maestro-milestone-audit | no | -- |
201
+ | milestone-complete | maestro-milestone-complete | no | post-milestone |
202
+
203
+ ### A_BUILD_AND_SPAWN_WAVE
204
+
205
+ 1. Conditional step eval: check_coverage -> read validation.json, skip if >= threshold
206
+ 2. buildNextWave: barrier -> solo; non-barrier -> batch consecutive; stop at decision
207
+ 3. buildSkillCall: resolve {phase}/{intent}/{dirs} placeholders, enrich (plan -> --dir analyze, execute -> --dir plan), append -y if auto_mode
208
+ 4. Write wave-{N}.csv (id, skill_call, topic) -> `spawn_agents_on_csv`
209
+ 5. Read results -> update step statuses
210
+ 6. Barrier context update: analyze->context.analysis_dir, plan->context.plan_dir, execute->context.exec_status, brainstorm->context.brainstorm_dir, roadmap->context.spec_session_id
211
+ 7. Persist status.json
212
+
213
+ ### A_DELEGATE_EVALUATE
214
+
215
+ 1. Resolve result files per decision type (post-verify: verification.json, post-business-test: report.json, post-review: review.json, post-test: uat.md + test-results.json)
216
+ 2. Execute `maestro delegate` with analysis prompt -> parse verdict: STATUS (proceed/fix/escalate), REASON, GAP_SUMMARY, CONFIDENCE_SCORE, WEAKEST_DIMENSION
217
+ 3. Confidence adjustment: score < 60 + proceed -> fix; score > 95 + fix + retry > 0 -> suggest proceed
218
+
219
+ ### A_STRUCTURAL_EVALUATE
220
+
221
+ **post-milestone**: Read state.json -> next milestone -> update session (milestone, phase, reset gates), re-infer quality_mode, insert lifecycle steps. No next -> complete.
222
+ **post-debug-escalate**: Pause (always, even -y). Display: max retries reached, manual intervention needed.
223
+
224
+ ### A_INSERT_FIX_LOOP
225
+
226
+ Insert fix template by decision type after current position, reindex:
227
+ - **post-verify**: debug -> plan --gaps -> execute -> verify -> decision:post-verify
228
+ - **post-business-test**: debug --from-business-test -> plan --gaps -> execute -> verify -> decision:post-verify -> auto-test -> decision:post-business-test
229
+ - **post-review**: debug -> plan --gaps -> execute -> verify -> decision:post-verify -> review -> decision:post-review
230
+ - **post-test**: debug --from-uat -> plan --gaps -> execute -> verify -> decision:post-verify -> [auto-test + decision:post-business-test (full)] -> review -> decision:post-review -> [auto-test (full; standard if <80%)] -> test -> decision:post-test
231
+
232
+ ### A_ADVANCE_MILESTONE
233
+
234
+ Update session: milestone, phase, reset passed_gates. Re-infer quality_mode. Build + insert new lifecycle steps for next milestone.
235
+
236
+ ### A_FINALIZE
237
+
238
+ Set status = "completed". Sync update_plan. Release goal. Display completion report.
239
+
240
+ ### A_PAUSE_SESSION
241
+
242
+ Set status = "paused". Do NOT release goal. Display: use $maestro-ralph execute to continue.
243
+
244
+ </actions>
245
+
246
+ </state_machine>
247
+
248
+ <appendix>
249
+
250
+ ### Session JSON Schema
251
+
252
+ ```json
253
+ {
254
+ "session_id": "ralph-{YYYYMMDD-HHmmss}",
255
+ "source": "ralph", "intent": "", "status": "running|paused|completed",
256
+ "lifecycle_position": "", "phase": null, "milestone": null,
257
+ "auto_mode": false, "quality_mode": "standard", "passed_gates": [],
258
+ "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null, "analysis_dir": null, "brainstorm_dir": null },
259
+ "steps": [{ "index": 0, "type": "external|decision", "skill": "", "args": "", "barrier": false, "status": "pending", "wave_n": null }],
260
+ "waves": [], "current_step": 0
261
+ }
262
+ ```
263
+
264
+ ### Worker Contract
265
+
266
+ ```
267
+ Execute skill_call: {skill_call}. Topic: {topic}.
268
+ Do not modify .workflow/.maestro/ status files.
269
+ Return: { status, skill_call, summary, artifacts, error }
270
+ ```
271
+
272
+ ### Wave CSV Schema
273
+
274
+ ```csv
275
+ id,skill_call,topic
276
+ "3","$maestro-verify 1","Ralph step 3/14: verify phase 1"
277
+ ```
278
+
279
+ Rules: decision nodes NEVER in CSV; barrier -> single-row; non-barrier -> multi-row.
280
+
281
+ ### Error Codes
282
+
283
+ | Condition | Recovery |
284
+ |-----------|----------|
285
+ | No intent and no running session | Prompt for intent |
286
+ | Cannot infer lifecycle position | Show raw state, ask user |
287
+ | Artifact dir not found for decision | Show glob results, ask user |
288
+ | Delegate verdict parse failed | Fallback: treat as "fix" |
289
+ | Wave timeout | Mark step failed, pause |
290
+ | No session for execute/continue | Suggest $maestro-ralph "intent" |
291
+
292
+ ### Success Criteria
293
+
294
+ - [ ] Lifecycle position inferred from bootstrap + artifact chain + result files
295
+ - [ ] Quality mode governs step generation
296
+ - [ ] buildSkillCall() with arg enrichment + auto flag
297
+ - [ ] Quality-gate decisions delegate-evaluated via maestro delegate --role analyze
298
+ - [ ] Confidence-based verdict adjustment applied
299
+ - [ ] -y: auto-follow verdict, no STOP (except post-debug-escalate)
300
+ - [ ] passed_gates[] tracked, cleared on code changes
301
+ - [ ] Fix-loop templates with gap_summary from delegate
302
+ - [ ] retry_count per decision, max_retries enforced
303
+ - [ ] ALL external steps via spawn_agents_on_csv
304
+ - [ ] Barrier solo wave, non-barriers parallel
305
+ - [ ] status.json persisted after every wave and decision
306
+
307
+ </appendix>