maestro-flow 0.5.34 → 0.5.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 (95) hide show
  1. package/.agents/agents/workflow-collab-planner.md +1 -0
  2. package/.agents/agents/workflow-planner.md +2 -0
  3. package/.agents/skills/maestro-help/SKILL.md +1 -1
  4. package/.agents/skills/maestro-help/index/catalog.json +0 -1
  5. package/.agents/skills/maestro-help/phases/01-parse-intent.md +1 -1
  6. package/.agents/skills/maestro-plan/SKILL.md +3 -1
  7. package/.agents/skills/maestro-ralph/SKILL.md +46 -17
  8. package/.agents/skills/maestro-ralph-execute/SKILL.md +51 -10
  9. package/.agents/skills/quality-test/SKILL.md +27 -1
  10. package/.agy/agents/workflow-collab-planner.md +1 -0
  11. package/.agy/agents/workflow-planner.md +2 -0
  12. package/.agy/skills/maestro-help/SKILL.md +1 -1
  13. package/.agy/skills/maestro-help/index/catalog.json +0 -1
  14. package/.agy/skills/maestro-help/phases/01-parse-intent.md +1 -1
  15. package/.agy/skills/maestro-plan/SKILL.md +3 -1
  16. package/.agy/skills/maestro-ralph/SKILL.md +46 -17
  17. package/.agy/skills/maestro-ralph-execute/SKILL.md +51 -10
  18. package/.agy/skills/quality-test/SKILL.md +27 -1
  19. package/.claude/agents/workflow-collab-planner.md +1 -0
  20. package/.claude/agents/workflow-planner.md +2 -0
  21. package/.claude/commands/maestro-plan.md +3 -1
  22. package/.claude/commands/maestro-ralph-execute.md +51 -10
  23. package/.claude/commands/maestro-ralph.md +46 -17
  24. package/.claude/commands/quality-test.md +27 -1
  25. package/.claude/skills/maestro-help/SKILL.md +1 -1
  26. package/.claude/skills/maestro-help/index/catalog.json +0 -1
  27. package/.claude/skills/maestro-help/phases/01-parse-intent.md +1 -1
  28. package/.codex/skills/maestro/SKILL.md +17 -2
  29. package/.codex/skills/maestro-analyze/SKILL.md +20 -3
  30. package/.codex/skills/maestro-brainstorm/SKILL.md +30 -4
  31. package/.codex/skills/maestro-execute/SKILL.md +25 -3
  32. package/.codex/skills/maestro-grill/SKILL.md +9 -0
  33. package/.codex/skills/maestro-plan/SKILL.md +26 -3
  34. package/.codex/skills/maestro-ralph/SKILL.md +6 -0
  35. package/.codex/skills/maestro-ralph-execute/SKILL.md +51 -10
  36. package/.codex/skills/maestro-roadmap/SKILL.md +30 -1
  37. package/.codex/skills/quality-review/SKILL.md +9 -0
  38. package/README.md +28 -5
  39. package/README.zh-CN.md +28 -5
  40. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +82 -0
  41. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +444 -0
  42. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -0
  43. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +46 -0
  44. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +413 -19
  45. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  46. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js +16 -0
  47. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js.map +1 -1
  48. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +13 -0
  49. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +102 -7
  50. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  51. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +42 -0
  52. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  53. package/dashboard/dist-server/src/commands/hooks.d.ts +3 -0
  54. package/dashboard/dist-server/src/commands/hooks.js +11 -8
  55. package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
  56. package/dashboard/dist-server/src/graph/kg/extraction/code/code-extractor.js +1 -1
  57. package/dashboard/dist-server/src/graph/kg/extraction/code/code-extractor.js.map +1 -1
  58. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -6
  59. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  60. package/dist/src/cli.js +1 -0
  61. package/dist/src/cli.js.map +1 -1
  62. package/dist/src/commands/hooks.d.ts +3 -0
  63. package/dist/src/commands/hooks.d.ts.map +1 -1
  64. package/dist/src/commands/hooks.js +11 -8
  65. package/dist/src/commands/hooks.js.map +1 -1
  66. package/dist/src/commands/install.d.ts.map +1 -1
  67. package/dist/src/commands/install.js +42 -9
  68. package/dist/src/commands/install.js.map +1 -1
  69. package/dist/src/commands/search.d.ts +5 -0
  70. package/dist/src/commands/search.d.ts.map +1 -1
  71. package/dist/src/commands/search.js +81 -11
  72. package/dist/src/commands/search.js.map +1 -1
  73. package/dist/src/commands/update.d.ts.map +1 -1
  74. package/dist/src/commands/update.js +37 -21
  75. package/dist/src/commands/update.js.map +1 -1
  76. package/dist/src/core/install-executor.d.ts.map +1 -1
  77. package/dist/src/core/install-executor.js +6 -3
  78. package/dist/src/core/install-executor.js.map +1 -1
  79. package/dist/src/graph/kg/extraction/code/code-extractor.js +1 -1
  80. package/dist/src/graph/kg/extraction/code/code-extractor.js.map +1 -1
  81. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  82. package/dist/src/graph/kg/extraction/orchestrator.js +2 -6
  83. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  84. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  85. package/dist/src/ralph/cmd-next.js +2 -3
  86. package/dist/src/ralph/cmd-next.js.map +1 -1
  87. package/package.json +4 -2
  88. package/workflows/claude-instructions.md +17 -2
  89. package/workflows/codex-instructions.md +85 -14
  90. package/workflows/command-authoring.md +1 -1
  91. package/workflows/plan.md +2 -1
  92. package/.agents/skills/maestro-ralph-beta/SKILL.md +0 -882
  93. package/.agy/skills/maestro-ralph-beta/SKILL.md +0 -878
  94. package/.claude/commands/maestro-ralph-beta.md +0 -880
  95. package/.codex/skills/maestro-ralph-beta/SKILL.md +0 -883
@@ -1,883 +0,0 @@
1
- ---
2
- name: maestro-ralph-beta
3
- description: "Self-running loop controller for adaptive maestro workflow — build, tick, decide in one skill"
4
- argument-hint: "<intent> [-y] | continue | status"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - Bash
10
- - Glob
11
- - Grep
12
- - Skill
13
- - request_user_input
14
- ---
15
- <purpose>
16
- Closed-loop runner for the maestro workflow lifecycle.
17
- Single skill — every invocation routes by session state, executes one tick, and self-invokes `$maestro-ralph-beta` until all `completion_confirmed` or paused.
18
-
19
- Entry points:
20
- - **`$maestro-ralph-beta "intent"`** — New session: infer → decompose → build → tick
21
- - **`$maestro-ralph-beta continue`** — Resume: locate session → tick
22
- - **`$maestro-ralph-beta status`** — Display session progress
23
-
24
- Tick kinds:
25
- - **执行 step** (`step.decision == null`): `maestro ralph next` → inline → `maestro ralph complete` → self-invoke
26
- - **decision step** (`step.decision != null`): inline evaluate → apply verdict → self-invoke
27
-
28
- Session: `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`
29
- </purpose>
30
-
31
- <context>
32
- $ARGUMENTS — intent text, flags, or keywords.
33
-
34
- **Parse:**
35
- ```
36
- -y flag → auto_confirm = true
37
- .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
38
- "status" → status mode
39
- "continue" → resume mode
40
- Remaining → intent (new session)
41
- ```
42
-
43
- **State files:**
44
- - `.workflow/state.json` — artifact registry, milestones, phases
45
- - `.workflow/roadmap.md` — milestone/phase structure
46
- - `.workflow/.maestro/ralph-*/status.json` — ralph session state
47
- </context>
48
-
49
- <invariants>
50
- 1. **Self-invocation = `$maestro-ralph-beta`** — 每次 tick 末尾强制自调用;除非 router 命中终止条件
51
- 2. **status.json 是唯一真源;写入权限分层**:
52
- - **Step 级字段**(`step.completion_*`, `step.status` 执行 step running↔completed, `step.load.*`, `step.retried`,以及执行 step 的 `active_step_index` 占用/释放)→ 由 `maestro ralph next/complete/retry` CLI 写入
53
- - **会话级结构**(`session.status`, `passed_gates`, `steps[]` 增删/reindex, `task_decomposition[*]`, `boundary_contract`, `context.*`, `scope_verdict`, `consec_exit2_count`, decision step 的 `status`/`retry_count`/`active_step_index` 占用与释放)→ 由 maestro-ralph-beta 写入
54
- 3. **执行 step 通过 `maestro ralph next` 加载** — CLI 解析 frontmatter + `<required_reading>` + `<deferred_reading>`、读 required 全文、拼 prompt、写 `step.load.*` + `active_step_index` + `step.status="running"`
55
- 4. **decision step 内联评估** — 不 handoff、不调 ralph next;按 `step.decision` 分派 A_DECISION_*
56
- 5. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入;STATUS 仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`
57
- 6. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform codex --json --quiet` 预校验(project 覆盖 global,只扫描 `.codex/skills/`);未命中标 `command_scope = "missing"`
58
- 7. **required reading 由 CLI 加载** — 缺失 → 退出码 1(E007)→ pause session;ralph build 阶段不读 .md 内容
59
- 8. **active_step_index 一致性由 CLI 维护** — 同一 session 同时最多一个 step 持有;E008/E009 直接退出
60
- 9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 由用户输入
61
- 10. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
62
- 11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段累加,既有字段不删不改
63
- </invariants>
64
-
65
- <router>
66
-
67
- 每次进入 skill 先执行 router,按顺序匹配,先命中先用。术语:
68
- - **active session** = `.workflow/.maestro/ralph-*/status.json` 中 `status ∈ {running, paused}` 的最新会话
69
- - **live session** = active session 且 `status == "running"`
70
- - **active_step** = `session.steps[session.active_step_index]`
71
-
72
- ```
73
- 1. intent == "status" → S_STATUS → END
74
- 2. intent == "continue" AND active session exists → A_RESUME_SESSION → S_TICK_LOCATE
75
- 3. intent non-empty AND intent ∉ {"continue","status"} AND active session exists
76
- → S_FALLBACK → END
77
- display "已有 active session {id};先 $maestro-ralph-beta continue 续跑或显式 abandon"
78
- 4. live session AND active_step.status == "running" AND active_step.decision != null
79
- → S_TICK_LOCATE → S_TICK_DECISION
80
- 5. live session AND has pending step → S_TICK_LOCATE
81
- 6. live session AND all completion_confirmed → S_COMPLETE → END
82
- 7. active session AND session.status == "paused" AND no intent → S_FALLBACK → END
83
- display "Session {id} paused;输入 $maestro-ralph-beta continue 显式恢复"
84
- 8. no active session AND intent non-empty → S_BUILD_PHASE
85
- 9. no active session AND no intent → S_FALLBACK → END
86
- ```
87
-
88
- </router>
89
-
90
- <state_machine>
91
-
92
- <states>
93
- # Build phase (one-time per session)
94
- S_RESOLVE_PHASE — 解析 phase + phase_is_new + D-007 milestone PERSIST: session.phase, session.phase_is_new, session.milestone
95
- S_INFER — 推断 lifecycle_position PERSIST: session.lifecycle_position
96
- S_RESOLVE_SCOPE — 读 macro analyze conclusions.scope_verdict PERSIST: session.scope_verdict, session.analyze_macro_id
97
- S_QUALITY_MODE — 决定质量管线模式 PERSIST: session.quality_mode
98
- S_PLANNING_MODE — 决定统一/独立规划模式 PERSIST: session.planning_mode
99
- S_DECOMPOSE — 边界澄清、写执行准则+子目标清单 PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
100
- S_BUILD_CHAIN — 构建步骤链 PERSIST: session.steps[]
101
- S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
102
- S_CONFIRM — 用户确认 PERSIST: —
103
-
104
- # Tick phase (per step)
105
- S_TICK_LOCATE — 定位 session + 找 active step PERSIST: —
106
- S_TICK — 分派执行 step 或 decision step PERSIST: step.status, active_step_index
107
- S_TICK_EXEC — 执行 step:ralph next → inline → ralph complete PERSIST: via CLI
108
- S_TICK_DECISION — decision step:内联评估 + 应用裁决 PERSIST: session.steps[], passed_gates, decisions.ndjson
109
- S_HANDLE_FAIL — 处理执行失败 PERSIST: step.status, session.status
110
-
111
- # Terminal
112
- S_STATUS — 显示 session 进度 PERSIST: —
113
- S_COMPLETE — 收尾 PERSIST: session.status = "completed"
114
- S_FALLBACK — 引导用户输入或退出 PERSIST: —
115
- </states>
116
-
117
- <transitions>
118
-
119
- # === Build phase ===
120
-
121
- S_BUILD_PHASE (entry):
122
- → S_RESOLVE_PHASE
123
-
124
- S_RESOLVE_PHASE:
125
- → S_INFER WHEN: phase resolved or null DO: A_RESOLVE_PHASE
126
- → S_FALLBACK WHEN: ambiguous
127
- GUARD: auto_confirm does NOT skip phase ambiguity
128
-
129
- S_INFER:
130
- → S_RESOLVE_SCOPE WHEN: position resolved DO: A_INFER_POSITION
131
- → S_FALLBACK WHEN: cannot infer
132
-
133
- S_RESOLVE_SCOPE:
134
- → S_QUALITY_MODE DO: A_RESOLVE_SCOPE_VERDICT
135
- GUARD: position ∈ {brainstorm, blueprint, init} → skip (scope_verdict = null)
136
-
137
- S_QUALITY_MODE:
138
- → S_PLANNING_MODE DO: A_DETERMINE_QUALITY_MODE
139
-
140
- S_PLANNING_MODE:
141
- → S_DECOMPOSE DO: A_DETERMINE_PLANNING_MODE
142
- GUARD: lifecycle_position ∈ {brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
143
-
144
- S_DECOMPOSE:
145
- → S_BUILD_CHAIN DO: A_DECOMPOSE_TASKS
146
- GUARD: broad intent → MUST clarify boundary even if auto_confirm
147
- GUARD: narrow intent → auto-derive, skip questions
148
- GUARD: position ∈ {brainstorm, blueprint, init} → skip decomposition
149
-
150
- S_BUILD_CHAIN:
151
- → S_CREATE_SESSION DO: A_BUILD_STEPS
152
-
153
- S_CREATE_SESSION:
154
- → S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
155
- → S_TICK_LOCATE WHEN: auto_confirm DO: A_CREATE_SESSION + $maestro-ralph-beta
156
-
157
- S_CONFIRM:
158
- → S_TICK_LOCATE WHEN: user selects "Proceed" DO: $maestro-ralph-beta
159
- → S_BUILD_CHAIN WHEN: user selects "Edit"
160
- → END WHEN: user selects "Cancel"
161
-
162
- # === Tick phase ===
163
-
164
- S_TICK_LOCATE: Entry: A_LOCATE_SESSION
165
- → S_TICK WHEN: next_pending_step != null
166
- → S_COMPLETE WHEN: next_pending_step == null
167
- → S_FALLBACK WHEN: no active session
168
-
169
- S_TICK:
170
- → S_TICK_DECISION WHEN: next_pending_step.decision != null DO: A_CLAIM_DECISION
171
- → S_TICK_EXEC WHEN: next_pending_step.decision == null DO: A_RESOLVE_ARGS
172
-
173
- S_TICK_EXEC: Entry: A_EXEC_STEP
174
- → S_TICK_LOCATE WHEN: ralph complete with DONE|DONE_WITH_CONCERNS DO: $maestro-ralph-beta
175
- → S_TICK_LOCATE WHEN: ralph next exit == 2 DO: $maestro-ralph-beta
176
- → S_HANDLE_FAIL WHEN: ralph next exit == 1 OR exit >= 3
177
- → S_HANDLE_FAIL WHEN: ralph complete with NEEDS_RETRY|BLOCKED
178
-
179
- S_TICK_DECISION: (gate 名取自 `step.decision`)
180
- → S_TICK_APPLY WHEN: quality-gate (post-execute, post-business-test, post-review, post-test)
181
- DO: A_DELEGATE_EVALUATE
182
- → S_TICK_APPLY WHEN: goal-gate (post-goal-audit)
183
- DO: A_GOAL_AUDIT_EVALUATE
184
- → S_TICK_APPLY WHEN: scope-gate (post-analyze-scope)
185
- DO: A_SCOPE_EVALUATE
186
- → S_TICK_APPLY WHEN: structural (post-milestone, post-debug-escalate)
187
- DO: A_STRUCTURAL_EVALUATE
188
-
189
- S_TICK_APPLY:
190
- → S_TICK_LOCATE WHEN: verdict == "proceed" DO: A_APPLY_PROCEED + $maestro-ralph-beta
191
- → S_TICK_LOCATE WHEN: post-goal-audit + unmet sub-goals DO: A_APPLY_GOAL_FIX + $maestro-ralph-beta
192
- → S_TICK_LOCATE WHEN: post-goal-audit + all sub-goals met DO: A_APPLY_GOAL_DONE + $maestro-ralph-beta
193
- → S_TICK_LOCATE WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT + $maestro-ralph-beta
194
- → S_TICK_LOCATE WHEN: verdict == "fix" DO: A_APPLY_FIX + $maestro-ralph-beta
195
- → S_TICK_LOCATE WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE + $maestro-ralph-beta
196
- → S_TICK_LOCATE WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE + $maestro-ralph-beta
197
- → END WHEN: post-milestone + standard + no next milestone DO: mark completed
198
- → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
199
- → END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
200
- GUARD: retry_count >= max_retries → force escalate
201
- GUARD: confidence_score < 60 AND proceed → override to fix
202
- GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
203
- GUARD: auto_confirm → skip user prompt, apply adjusted verdict
204
- GUARD: not auto_confirm → request_user_input with override options
205
-
206
- S_HANDLE_FAIL:
207
- → S_TICK_LOCATE WHEN: auto + not retried DO: A_RETRY + $maestro-ralph-beta
208
- → END WHEN: auto + retried DO: A_PAUSE_SESSION
209
- → S_TICK_LOCATE WHEN: interactive + user selects retry DO: A_RETRY + $maestro-ralph-beta
210
- → S_TICK_LOCATE WHEN: interactive + user selects skip DO: A_SKIP_STEP + $maestro-ralph-beta
211
- → END WHEN: interactive + user selects abort DO: A_PAUSE_SESSION
212
-
213
- # === Terminal ===
214
-
215
- S_STATUS:
216
- → END DO: A_SHOW_STATUS
217
-
218
- S_COMPLETE:
219
- → END DO: A_COMPLETE_SESSION
220
-
221
- S_FALLBACK:
222
- → S_BUILD_PHASE WHEN: user provides intent (no active session) DO: request_user_input
223
- → S_TICK_LOCATE WHEN: user selects "continue active session" DO: A_RESUME_SESSION + $maestro-ralph-beta
224
- → END WHEN: user cancels OR no active session for resume
225
-
226
- </transitions>
227
-
228
- <actions>
229
-
230
- ### A_SHOW_STATUS
231
-
232
- 1. Find latest ralph session (by created_at)
233
- 2. Display: Session, Status, Position, Progress, Current step
234
- 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
235
- 4. If `task_decomposition` present (absent → skip):
236
- ```
237
- Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
238
- [x] G1 done_when={done_when} evidence={evidence} confirmed={completion_confirmed}
239
- [ ] G2 done_when={done_when} evidence={evidence} confirmed=false ◀ unmet
240
- ```
241
-
242
- ### A_RESOLVE_PHASE
243
-
244
- 产出 `phase` + `phase_is_new` + `milestone`(D-007 反查)。
245
-
246
- **Priority:**
247
-
248
- | Step | 行为 | phase_is_new |
249
- |------|------|--------------|
250
- | 1 | intent 匹配 `phase\s*(\d+)` → 取 state.json 对应 phase | false |
251
- | 2 | intent 派生短语 → 在 `state.json.milestones[*].phase_slugs` / `artifacts[*].path` 查找 | false (匹配) / true (无匹配) |
252
- | 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
253
- | 4 | 仍无 → state.json 首个 incomplete phase | false |
254
- | 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
255
- | 6 | 仍模糊 → `request_user_input` | 由用户回答确定 |
256
-
257
- **D-007 Phase→Milestone 反查**(数字 phase 已解析时):
258
- ```
259
- resolve_milestone(phase_number):
260
- for ms in state.json.milestones:
261
- if str(phase_number) in ms.phase_slugs: return ms.id
262
- return state.json.current_milestone # fallback
263
- ```
264
- 写入 `session.milestone`。
265
-
266
- **写入 session**: `phase`, `phase_is_new`, `milestone`。
267
-
268
- **新派生 phase 时 milestone 处理**:
269
- - state.json 当前 milestone 仍 active → 沿用,新增 phase
270
- - intent 派生新 milestone 名 → 写入 session 仅作标签;`state.json.milestones` 由 `maestro-roadmap` / `maestro-milestone-release` 创建
271
-
272
- ### A_INFER_POSITION
273
-
274
- **Intent-based overrides** (按顺序匹配,先命中先用):
275
-
276
- | Pattern | Position |
277
- |---------|----------|
278
- | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
279
- | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
280
- | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
281
-
282
- **Bootstrap detection:**
283
-
284
- | Condition | Position |
285
- |-----------|----------|
286
- | No `.workflow/` + no source files | `brainstorm` |
287
- | No `.workflow/` + has source files | `init` |
288
- | Has `.workflow/` but no state.json | `init` |
289
- | Has state.json | → phase-aware artifact inference |
290
-
291
- **Phase-aware artifact inference**(基于 `session.phase` + `session.phase_is_new`,artifact 按 `session.phase` 过滤):
292
-
293
- | Condition | Position |
294
- |-----------|----------|
295
- | `phase_is_new == true` | `analyze` |
296
- | no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` |
297
- | no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
298
- | `phase == null` | n/a |
299
- | phase 已存在 + 无任何 artifact | `analyze` |
300
- | phase 已存在 + 最新 artifact = analyze | `plan` |
301
- | phase 已存在 + 最新 artifact = plan | `execute` |
302
- | phase 已存在 + 最新 artifact = execute | `review` |
303
-
304
- **Refine from review results:**
305
-
306
- | Condition | Position |
307
- |-----------|----------|
308
- | review.json: verdict=="BLOCK" | `review-failed` |
309
- | review.json: verdict!="BLOCK" | `test` |
310
- | uat.md: all passed | `milestone-audit` |
311
- | uat.md: has failures | `test-failed` |
312
-
313
- ### A_RESOLVE_SCOPE_VERDICT
314
-
315
- 仅当 `lifecycle_position ∈ {analyze-macro, roadmap, plan}` 且存在最新 analyze artifact 时执行。
316
-
317
- 1. 定位最新 macro analyze artifact(`type=="analyze"` 且 `scope=="macro"`,按 created_at DESC)→ `session.analyze_macro_id = ANL-xxx`
318
- 2. 读 `{artifact_path}/conclusions.json` 的 `scope_verdict` 字段(`large | medium | small`)
319
- 3. 写入 `session.scope_verdict`;缺失 → `unknown`
320
- 4. 路由建议:
321
-
322
- | scope_verdict | 链路 |
323
- |---------------|------|
324
- | `large` | analyze-macro → roadmap → analyze → plan → execute → ... |
325
- | `medium` / `small` | analyze-macro → plan --from analyze:{ANL_ID} → execute → ... |
326
- | `unknown` | 默认 large;post-analyze-scope 节点再纠正 |
327
-
328
- ### A_DETERMINE_QUALITY_MODE
329
-
330
- 读 `session.quality_mode_override`(CLI `--quality`),无则按规则推断:
331
-
332
- | Condition | Mode | Pipeline (execute 之后) |
333
- |-----------|------|-------------------------|
334
- | Has `specs/REQ-*.md` + 当前 phase 业务范围明确 | `full` | business-test → review → test-gen → test |
335
- | Default | `standard` | review → test-gen (当 coverage<80%) → test |
336
- | `--quality quick` | `quick` | review --tier quick |
337
-
338
- 写入 `session.quality_mode`。
339
-
340
- ### A_DETERMINE_PLANNING_MODE
341
-
342
- **Auto-resolve rules (按优先级):**
343
-
344
- | Condition | Mode |
345
- |-----------|------|
346
- | lifecycle_position ∈ {brainstorm, init, roadmap} | `independent` |
347
- | `phase_is_new == true` | `independent` |
348
- | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` |
349
- | milestone 仅含 1 个 phase | `independent` |
350
- | milestone 含多个 phase + `auto_confirm` | `unified` |
351
- | milestone 含多个 phase + 非 `auto_confirm` | → request_user_input |
352
-
353
- **request_user_input** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
354
-
355
- ```
356
- question: "当前里程碑含 {N} 个 phase,选择规划模式?"
357
- options:
358
- - label: "统一规划 (Recommended)"
359
- description: "一次性分析+规划整个里程碑所有 phase,analyze/plan 走里程碑级,适合 phase 间关联紧密"
360
- - label: "独立规划"
361
- description: "逐个 phase 走完整生命周期(analyze→plan→execute→verify→...),适合 phase 间独立性高"
362
- ```
363
-
364
- 写入 `session.planning_mode`(`"unified"` 或 `"independent"`)。
365
-
366
- ### A_DECOMPOSE_TASKS
367
-
368
- **1. Classify intent breadth:**
369
-
370
- | Pattern | Breadth | Clarify? |
371
- |---------|---------|----------|
372
- | 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp | broad | MUST (ignores auto_confirm) |
373
- | named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
374
- | otherwise | medium | clarify unless auto_confirm |
375
-
376
- **2. Clarify boundary** (broad/medium) — `request_user_input`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
377
-
378
- | Round | Question | Drives |
379
- |-------|----------|--------|
380
- | Scope | 哪些目录/文件/层在范围内?明确排除什么? | boundary_contract.in_scope / out_of_scope |
381
- | Constraints | 必须向后兼容?公共 API 冻结?行为/性能预算?测试门槛? | boundary_contract.constraints + execution_criteria |
382
- | Done | 什么可观测结果算"完成"?(如:测试全绿 + 行为零变更 + X 指标) | boundary_contract.definition_of_done |
383
-
384
- narrow → derive defaults from intent + codebase, skip questions.
385
-
386
- **3. Derive `execution_criteria`**: backward-compat、scope-freeze、test/coverage bar、fix-don't-hide、incremental commit。
387
-
388
- **4. Derive `task_decomposition`** (子目标清单 — outcome-oriented, NOT lifecycle stages). Each entry:
389
- ```json
390
- { "id": "G1", "goal": "<deliverable>", "boundary": "<in/out note>",
391
- "done_when": "<objectively checkable condition>",
392
- "evidence": "verification.json|review.json|uat.md|<test path>",
393
- "lifecycle": ["analyze","execute","verify"], "status": "pending" }
394
- ```
395
- `done_when` 必须客观可验证,且引用 ralph 已产出的 artifact;`lifecycle` 字段映射到产出 evidence 的生命周期 stage。
396
-
397
- **5. Persist**: `boundary_contract`, `execution_criteria`, `task_decomposition`。每个 sub-goal 初始化 `status: "pending"` + `completion_confirmed: false`。
398
-
399
- **6. Stage** the Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
400
-
401
- ### A_BUILD_STEPS
402
-
403
- 从 `session.lifecycle_position` 生成 steps 到 `milestone-complete`。
404
-
405
- | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
406
- |-------|---------------------|-----------------|----------------|--------------|
407
- | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
408
- | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
409
- | init | `maestro-init` | *(same)* | — | all |
410
- | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
411
- | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
412
- | analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
413
- | plan | `maestro-plan {phase}` *(scope=phase)* / `maestro-plan --from analyze:{analyze_macro_id}` *(scope=standalone)* / `maestro-plan --from blueprint:{blueprint_id}` *(scope=standalone)* | `maestro-plan` | — | all |
414
- | execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
415
- | business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
416
- | review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
417
- | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
418
- | test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
419
- | milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
420
- | goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
421
- | milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
422
-
423
- **Build rules (按顺序应用):**
424
-
425
- 0. **planning_mode 选列**:`unified` → Skill (unified) 列;`independent` → Skill (independent) 列
426
- 1. **起点**:从 `session.lifecycle_position` 开始
427
- 2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
428
- 3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
429
- 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
430
- 5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
431
- 6. **终点硬约束**:chain 以 `milestone-complete` 结尾
432
- 7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
433
- 8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
434
- 9. **command_path 解析**(执行 step):
435
- - skill 名 = args 前的第一个 token
436
- - `Bash("maestro ralph skills --platform codex --json --quiet")` 拉取 global + project(project 覆盖 global),匹配 skill 名:
437
- - 命中 → `command_scope = "global" | "project"`,`command_path = <绝对路径>`
438
- - 未命中 → `command_scope = "missing"`, `command_path = null` → A_CREATE_SESSION raise E006
439
- 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `deferred_reads: []`, `load: null`
440
- 11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
441
- - `scope_verdict ∈ {medium, small}` → 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
442
- - `scope_verdict == large` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
443
- - `scope_verdict == unknown` → 默认 large 路径;由 `post-analyze-scope` 决策节点在 macro analyze 完成后纠正(A_APPLY_SCOPE_VERDICT)
444
- 12. **--from 自动注入**:
445
- - `analyze_macro_id` 存在且当前 step 是 `roadmap` → args 改为 `--from analyze:{analyze_macro_id}`
446
- - `analyze_macro_id` 存在且 `scope_verdict ∈ {medium, small}` 且当前 step 是 `plan` → args 改为 `--from analyze:{analyze_macro_id}`
447
- - `blueprint_id` 存在 → 当前 step 是 `plan` → args 改为 `--from blueprint:{blueprint_id}`(优先级低于 phase 数字参数)
448
- - 写入 `step.source_artifact_ref` 以便审计
449
- 13. **Milestone-ref**:含 `{phase}` 占位符的 step → `step.milestone_id = session.milestone`
450
- 14. **动态插入步骤**(A_APPLY_*)同样应用规则 7-13
451
-
452
- ### A_CREATE_SESSION
453
-
454
- 1. 校验所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
455
- 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`
456
- 3. Display chain overview:每步显示 `{index}. {skill} [{command_scope}]`
457
- 4. `task_decomposition` 存在 → display Goal Prompt block,继续进入 tick
458
-
459
- ### A_LOCATE_SESSION
460
-
461
- 1. If session_id provided → load `.workflow/.maestro/{session_id}/status.json`
462
- 2. Else: scan `.workflow/.maestro/*/status.json`, filter `status ∈ {"running","paused"}`, sort DESC by created_at, take first
463
- 3. Extract: session_id, source, steps[], phase, milestone, intent, auto_mode, context, cli_tool, active_step_index, status
464
- 4. 预探测 `next_pending_step`(瞬态,不持久化):
465
- - 若 `active_step_index != null` 且 `steps[active_step_index].status == "running"` → `steps[active_step_index]`
466
- - 否则 `steps[]` 中 `status == "pending"` 的最小 index
467
- - 都无 → `null`
468
-
469
- ### A_RESUME_SESSION
470
-
471
- 1. A_LOCATE_SESSION 加载 active session
472
- 2. 清理 active_step_index:若 `active_step_index != null` 且 `steps[active_step_index].status ∈ {"completed","skipped","failed"}` → `active_step_index = null`;其余保留
473
- 3. If `session.status == "paused"` → `session.status = "running"`
474
- 4. `session.consec_exit2_count = 0`
475
- 5. Display: `↻ Resume {session_id}`
476
-
477
- ### A_CLAIM_DECISION
478
-
479
- 1. 校验 `session.active_step_index ∈ {null, next_pending_step.index}`,否则 raise E008
480
- 2. `session.active_step_index = next_pending_step.index`
481
- 3. `steps[next_pending_step.index].status = "running"`
482
- 4. Display: `[{index}/{total}] ◆ {step.decision} Retry: {retry}/{max}`
483
-
484
- ### A_RESOLVE_ARGS
485
-
486
- **Placeholder substitution:**
487
-
488
- | Placeholder | Source |
489
- |-------------|--------|
490
- | `{phase}` | session.phase |
491
- | `{milestone}` | session.milestone |
492
- | `{intent}` | session.intent |
493
- | `{description}` | session.intent (alias) |
494
- | `{scratch_dir}` | session.context.scratch_dir or latest artifact path |
495
- | `{plan_dir}` | session.context.plan_dir |
496
- | `{analysis_dir}` | session.context.analysis_dir |
497
- | `{issue_id}` | session.context.issue_id |
498
- | `{milestone_num}` | session.context.milestone_num |
499
-
500
- **Per-skill enrichment** (when args empty or minimal):
501
-
502
- | Skill | Required context | Source |
503
- |-------|-----------------|--------|
504
- | maestro-brainstorm | topic | `"{intent}"` |
505
- | maestro-roadmap | description | `"{intent}"` |
506
- | maestro-analyze | phase or topic | `{phase}` or `"{intent}"` |
507
- | maestro-plan | phase or --dir | `{phase}`, or `--dir {scratch_dir}` |
508
- | maestro-execute | phase or --dir | `{phase}`, or `--dir {scratch_dir}` |
509
- | quality-debug | gap context | Read previous step's error/gap |
510
- | quality-* | phase | `{phase}` |
511
-
512
- **Artifact dir resolution for --dir:**
513
- ```
514
- Read state.json → filter artifacts by milestone + phase
515
- plan commands: latest type=="analyze" → --dir .workflow/scratch/{path}
516
- execute commands: latest type=="plan" → --dir .workflow/scratch/{path}
517
- ```
518
-
519
- Write enriched args back to status.json.
520
-
521
- ### A_EXEC_STEP
522
-
523
- 1. **Load** — `Bash("maestro ralph next")`
524
- - exit 0 → `session.consec_exit2_count = 0`,按 stdout 内联执行(进入步骤 2)
525
- - exit 2 → `session.consec_exit2_count += 1`;≥ 2 时抛 E010 → S_HANDLE_FAIL;否则 → S_TICK_LOCATE
526
- - exit 1 → E007 → S_HANDLE_FAIL
527
- - exit ≥ 3 → E008 → S_HANDLE_FAIL
528
- 2. **Inline execution** — 按 stdout 执行;deferred_reading 按需 Read
529
- 3. **Complete**:
530
- - `Bash("maestro ralph complete N --status DONE [--evidence <path>]")`
531
- - `Bash("maestro ralph complete N --status DONE_WITH_CONCERNS --concerns \"...\"")`
532
- - `Bash("maestro ralph retry N")`
533
- - `Bash("maestro ralph complete N --status BLOCKED --reason \"...\"")`
534
- 4. **Propagate context signals** — `PHASE: N` / `scratch_dir: path` / `BLP-xxx` 写入 `status.json.context`
535
-
536
- ### A_DELEGATE_EVALUATE
537
-
538
- 1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
539
- 2. Parse decision metadata: `{ decision, retry_count, max_retries }`
540
- 3. Map result files:
541
- | Decision | Files |
542
- |----------|-------|
543
- | post-execute | verification.json |
544
- | post-business-test | .tests/auto-test/report.json |
545
- | post-review | review.json |
546
- | post-test | uat.md, .tests/test-results.json |
547
- 4. Check artifact for confidence section → include as signal
548
- 5. Execute delegate (run_in_background, STOP, wait for callback):
549
- ```
550
- maestro delegate "PURPOSE: 评估 {decision} 质量门结果
551
- TASK: 读取结果 | 分析状态 | 评估严重性 | 给出建议
552
- EXPECTED: ---VERDICT--- STATUS/REASON/GAP_SUMMARY/CONFIDENCE(high|medium|low)/CONFIDENCE_SCORE(0-100)/WEAKEST_DIMENSION ---END---
553
- CONSTRAINTS: 只评估 | 置信度<60% 倾向 fix | retry {n}/{max} 达上限必须 escalate"
554
- --role analyze --mode analysis
555
- ```
556
- 6. On callback: parse verdict; if parse fails → fallback STATUS="fix"
557
- 7. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
558
- 8. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
559
- ```json
560
- { "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph",
561
- "node_id": "{step.decision}", "type": "quality-gate",
562
- "verdict": "{adjusted_verdict}", "confidence_score": {N},
563
- "close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
564
- ```
565
-
566
- ### A_STRUCTURAL_EVALUATE
567
-
568
- **post-milestone:**
569
- 1. Read state.json → 取已完成 milestone 对象
570
- 2. `milestone_obj.type` (default `"standard"`)
571
- 3. `type == "standard"`:next milestone 存在 → insert lifecycle steps;否则 → END
572
- 4. `type == "adhoc"`:END,`current_milestone = null`
573
-
574
- **post-debug-escalate:** STOP → paused,display "请人工介入"
575
-
576
- ### A_SCOPE_EVALUATE
577
-
578
- 由 `post-analyze-scope` 触发。
579
-
580
- 1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path = {artifact_path}/conclusions.json`
581
- 2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
582
- 3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
583
- 4. Append `{session_dir}/decisions.ndjson`:
584
- ```json
585
- { "id": "DEC-{timestamp}", "type": "scope-gate",
586
- "source": "ralph", "node_id": "post-analyze-scope",
587
- "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }
588
- ```
589
- 5. → A_APPLY_SCOPE_VERDICT
590
-
591
- ### A_GOAL_AUDIT_EVALUATE
592
-
593
- 仅当 `task_decomposition` 存在。
594
-
595
- 1. Read `session.task_decomposition`
596
- 2. For each sub-goal `status != "done"`:resolve `evidence` artifact
597
- 3. Delegate read-only audit (run_in_background, STOP, wait):
598
- ```
599
- maestro delegate "PURPOSE: 审计未完成子目标,判定 met / unmet
600
- TASK:
601
- 1. 读取 status.json.task_decomposition 中 status!=done 的子目标
602
- 2. 打开 evidence 产物,对照 done_when 严格判定
603
- 3. 输出 met / unmet,unmet 给出 gap + target_phase
604
- CONTEXT:
605
- status.json = {session_dir}/status.json
606
- evidence = {evidence artifacts}
607
- execution_criteria = {execution_criteria}
608
- boundary_contract = {boundary_contract}
609
- EXPECTED:
610
- ---VERDICT---
611
- STATUS=all_met|has_unmet
612
- UNMET=[{id:G2,gap:'...',target_phase:execute}, ...]
613
- CONFIDENCE_SCORE=0-100
614
- ---END---
615
- CONSTRAINTS:
616
- - 只评估,不修改文件
617
- - 严格按 done_when 判定;evidence 缺失 → unmet
618
- - 不得建议超出 boundary_contract 的修改
619
- "
620
- --role analyze --mode analysis
621
- ```
622
- 4. On callback: 对每个 met 子目标,set `task_decomposition[i].status="done"` + `completion_confirmed=true` + `completed_at=now`
623
- 5. Append `{session_dir}/decisions.ndjson` with `"type": "goal-gate"`, `unmet_count`, `unmet_ids`
624
- 6. Verdict: `all_met` → A_APPLY_GOAL_DONE; `has_unmet` → A_APPLY_GOAL_FIX
625
- GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
626
-
627
- > **A_APPLY_\* release 协议**(所有 A_APPLY_* 末尾统一应用):
628
- > - 完成分支(proceed / goal-done / scope applied / structural advanced):`step.status = "completed"`, `step.completion_confirmed = true`, `session.active_step_index = null`
629
- > - 重评分支(fix / escalate / goal-fix):`step.status = "pending"`, `step.completion_confirmed = false`, `session.active_step_index = null`, `step.retry_count += 1`
630
-
631
- ### A_APPLY_PROCEED
632
-
633
- 1. release 协议 — 完成分支
634
- 2. Append decisions.ndjson with verdict
635
- 3. Display: ◆ Decision: {type} → proceed ({reason})
636
-
637
- ### A_APPLY_FIX
638
-
639
- 1. Insert fix-loop commands after current step (Appendix: Fix-Loop Templates)
640
- 2. release 协议 — 重评分支;reindex steps
641
- 3. Display: ◆ Decision: {type} → fix, +{N} commands inserted
642
-
643
- ### A_APPLY_ESCALATE
644
-
645
- 1. Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]`
646
- 2. release 协议 — 重评分支;reindex
647
-
648
- ### A_APPLY_SCOPE_VERDICT
649
-
650
- 由 `post-analyze-scope` 触发。
651
-
652
- 1. 读 `session.scope_verdict`
653
- 2. `large`:为后续 `roadmap` step 注入 `--from analyze:{analyze_macro_id}`;后续 `plan` step 选 phase 列
654
- 3. `medium` / `small`:
655
- - 删除 `goal-audit` 之前未完成的 `roadmap` + `analyze` (phase) step
656
- - 下一个未完成的 `plan` step → `maestro-plan --from analyze:{analyze_macro_id}`,去掉 `{phase}`,`source_artifact_ref = analyze:{analyze_macro_id}`
657
- - 后续 `execute` / `verify` 同 standalone scope
658
- 4. `unknown`:非 auto_confirm → request_user_input 二选一(large / medium-small);auto_confirm → 默认 large
659
- 5. release 协议 — 完成分支;reindex
660
- 6. Display: ◆ Scope verdict: {verdict} → {kept|collapsed to standalone via analyze:{ANL_ID}}
661
-
662
- ### A_APPLY_GOAL_FIX
663
-
664
- 1. 对每个 unmet 子目标 `G{n}`(按 `target_phase` 分组去重):在 `goal-audit` 节点前插入 scoped mini-loop(Appendix: post-goal-audit),每条 step `goal_ref: "G{n}"`
665
- 2. 追加 `decision:post-goal-audit {retry+1}`
666
- 3. release 协议 — 重评分支;reindex
667
- 4. Display: ◆ Goal audit: {k} unmet → +{N} steps inserted (G{ids}), retry {r}/{max}
668
-
669
- ### A_APPLY_GOAL_DONE
670
-
671
- 1. 每个 `task_decomposition[*]` → `status="done"`, `completion_confirmed=true`, `completed_at=now`;顶层 `task_decomposition_all_done=true`
672
- 2. release 协议 — 完成分支;proceed to `milestone-complete`
673
- 3. Display: ◆ Goal audit: all met ✓
674
-
675
- ### A_ADVANCE_MILESTONE
676
-
677
- 1. Update session: milestone, phase, reset passed_gates
678
- 2. Insert full lifecycle steps for next milestone
679
- 3. release 协议 — 完成分支;reindex
680
-
681
- ### A_RETRY
682
-
683
- 1. `Bash("maestro ralph retry N")`
684
- 2. Display: `[{index}/{total}] ↻ {step.skill} retry`
685
-
686
- ### A_SKIP_STEP
687
-
688
- 手动编辑 status.json:`step.status = "skipped"`, `step.completion_confirmed = false`,若 `active_step_index == step.index` 则置 null。
689
-
690
- ### A_PAUSE_SESSION
691
-
692
- `session.status = "paused"` (CLI 通过 `ralph complete N --status BLOCKED` 自动写;手动场景直接编辑)
693
- Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。$maestro-ralph-beta continue 恢复。`
694
-
695
- ### A_PAUSE_ESCALATE
696
-
697
- 1. `session.status = "paused"`
698
- 2. Display: ◆ 已达最大重试次数,debug 已执行。请人工介入。
699
- 3. Display: $maestro-ralph-beta continue 恢复
700
-
701
- ### A_COMPLETE_SESSION
702
-
703
- 1. 校验:所有 step `completion_confirmed == true`(除 skipped);task_decomposition 存在时校验 `task_decomposition_all_done == true`
704
- 2. 任一校验失败 → 不标 completed,回 S_TICK_LOCATE 或 pause
705
- 3. `session.status = "completed"`, write status.json
706
- 4. Display completion report:
707
- ```
708
- ============================================================
709
- SESSION COMPLETE
710
- ============================================================
711
- Session: {session_id} [{source}]
712
- Steps: {completed}/{total} confirmed: {confirmed}/{completed}
713
-
714
- [✓] 0. maestro-plan 1 [global]
715
- [✓] 1. maestro-execute 1 [project]
716
- [✓] 2. quality-review 1 [global]
717
- [✓] 3. ◆ post-review [decision]
718
- ...
719
- ============================================================
720
- ```
721
- Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision
722
-
723
- </actions>
724
-
725
- </state_machine>
726
-
727
- <appendix>
728
-
729
- ### Session Schema
730
-
731
- ```json
732
- {
733
- "session_id": "ralph-{YYYYMMDD-HHmmss}",
734
- "source": "ralph", "status": "running",
735
- "ralph_protocol_version": "2",
736
- "active_step_index": null,
737
- "intent": "", "lifecycle_position": "",
738
- "phase": null, "phase_is_new": false,
739
- "milestone": "", // D-007 反查结果
740
- "auto_mode": false,
741
- "quality_mode": "standard", // "full" | "standard" | "quick"
742
- "planning_mode": "independent", // "unified" | "independent"
743
- "scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
744
- "analyze_macro_id": null, // "ANL-xxx"
745
- "blueprint_id": null, // "BLP-xxx"
746
- "cli_tool": "claude", "passed_gates": [],
747
- "consec_exit2_count": 0,
748
-
749
- "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
750
- "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
751
- "steps": [{
752
- "index": 0,
753
- "skill": "", // 执行 step 有值;decision 节点为空字符串/null
754
- "args": "",
755
- "stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|...
756
- "scope": null, // "phase"|"standalone"|"milestone"|null(plan 等需要)
757
- "decision": null, // null = 执行 step;非 null = decision step (值为 gate 名)
758
- "retry_count": 0, // decision step
759
- "max_retries": 2, // decision step
760
- "command_scope": "global|project|missing|null",
761
- "command_path": "<absolute path> | null",
762
- "milestone_id": null, // 仅含 {phase} 占位符的 step
763
- "source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
764
- "status": "pending|running|completed|skipped|failed",
765
- "goal_ref": null,
766
- "completion_confirmed": false,
767
- "completion_status": null,
768
- "completion_evidence": null,
769
- "completed_at": null,
770
- "deferred_reads": [],
771
- "load": null // { loaded_at, required_files[], deferred_files[], resolve_version }
772
- }],
773
- "current_step": 0,
774
-
775
- "boundary_contract": {
776
- "in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
777
- },
778
- "execution_criteria": [],
779
- "task_decomposition": [
780
- { "id": "G1", "goal": "", "boundary": "", "done_when": "",
781
- "evidence": "", "lifecycle": [], "status": "pending|done",
782
- "completion_confirmed": false, "completed_at": null }
783
- ],
784
- "task_decomposition_all_done": false
785
- }
786
- ```
787
-
788
- ### Fix-Loop Templates
789
-
790
- 插入的执行 step 按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点。
791
-
792
- **post-execute:**
793
- ```
794
- quality-debug "{gap_summary}"
795
- maestro-plan --gaps {phase}
796
- maestro-execute {phase}
797
- decision:post-execute {retry+1}
798
- ```
799
-
800
- **post-business-test:**
801
- ```
802
- quality-debug --from-business-test "{gap_summary}"
803
- maestro-plan --gaps {phase}
804
- maestro-execute {phase}
805
- decision:post-execute {retry: 0}
806
- quality-auto-test {phase}
807
- decision:post-business-test {retry+1}
808
- ```
809
-
810
- **post-review:**
811
- ```
812
- quality-debug "{gap_summary}"
813
- maestro-plan --gaps {phase}
814
- maestro-execute {phase}
815
- quality-review {phase}
816
- decision:post-review {retry+1}
817
- ```
818
-
819
- **post-test:**
820
- ```
821
- quality-debug --from-uat "{gap_summary}"
822
- maestro-plan --gaps {phase}
823
- maestro-execute {phase}
824
- decision:post-execute {retry: 0}
825
- quality-auto-test {phase}
826
- decision:post-business-test {retry: 0}
827
- quality-review {phase}
828
- decision:post-review {retry: 0}
829
- quality-auto-test {phase}
830
- quality-test {phase}
831
- decision:post-test {retry+1}
832
- ```
833
-
834
- **post-goal-audit:** (per unmet sub-goal group)
835
- ```
836
- # for each unmet sub-goal G{n}, scoped to target_phase:
837
- maestro-plan --gaps {target_phase} "G{n}: {gap}" [goal_ref: G{n}]
838
- maestro-execute {target_phase} [goal_ref: G{n}]
839
- # after all unmet groups inserted:
840
- decision:post-goal-audit {retry+1}
841
- ```
842
-
843
- ### Goal Prompt Template
844
-
845
- decomposition 产出后,链路概览之后逐字显示:
846
-
847
- ```
848
- 📋 任务分解完成。可随时复制以下 /goal 设定终止条件:
849
-
850
- /goal 直到 {session_dir}/status.json 的 task_decomposition[*] 与 steps[*] 全部 completion_confirmed=true 才停。每轮以 status.json 为唯一行动手册,通过 $maestro-ralph-beta 推进 tick;decision 节点由 ralph 内联评估。禁止手动执行 skill 或修改 boundary_contract.out_of_scope。
851
- ```
852
-
853
- ### Error Codes
854
-
855
- | Code | Severity | Description | Recovery |
856
- |------|----------|-------------|----------|
857
- | E001 | error | No intent and no running session | Prompt for intent |
858
- | E002 | error | Cannot infer lifecycle position | Show raw state, ask |
859
- | E003 | error | Artifact dir not found for decision | Show glob, ask |
860
- | E004 | error | Delegate verdict parse failed | Fallback: "fix" |
861
- | E005 | error | Delegate execution failed | Fallback: "fix" |
862
- | E006 | error | command_scope == "missing" for one or more steps | List missing skills, abort build |
863
- | E007 | error | required_reading 引用文件缺失 | `ralph next` 拒绝;CLI stderr 列出缺失路径 |
864
- | E008 | error | `ralph complete` idx ≠ active_step_index | 编辑 status.json 修正一致性 |
865
- | E009 | error | `ralph complete` step.status ≠ running | 重复 complete 或非法跳跃;编辑 status.json |
866
- | E010 | error | status.json schema 损坏 OR A_EXEC_STEP exit=2 熔断(连续 ≥2 次空转) | `ralph check` 显示损坏字段;熔断需人工核对 next_pending_step 与 router 路由是否一致 |
867
- | W001 | warning | Decision expanded chain | Auto-handled |
868
- | W002 | warning | Max retries, escalating | Auto-handled |
869
- | W003 | warning | Multiple running sessions | Use latest, warn |
870
- | W004 | warning | Low delegate confidence | Show warning |
871
- | W005 | warning | active_step_index 指向已 completed step | `ralph next` 自动清理后继续 |
872
- | W007 | warning | step.skill ≠ command .md frontmatter.name | 提示但不阻塞 |
873
-
874
- ### Success Criteria
875
-
876
- - [ ] Tick 末尾自调用 `$maestro-ralph-beta`,直到全部 `completion_confirmed` 或 paused
877
- - [ ] 同一 session 同时仅一个 step 持 `active_step_index`;切换前必经 release
878
- - [ ] Decision step 全程不调 `maestro ralph next` / `complete`,由 maestro-ralph-beta 内联评估并 release
879
- - [ ] `task_decomposition` 存在时,chain 含 `decision:post-goal-audit`,且最终 `task_decomposition_all_done == true` 才允许 S_COMPLETE
880
- - [ ] Chain 以 `milestone-complete` 结尾;A_APPLY_* 修改 steps[] 后均 reindex
881
- - [ ] 连续 2 次 `ralph next` exit=2 → E010 pause(防 router 错路由空转)
882
-
883
- </appendix>