pi-maestro-flow 0.2.0

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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,976 @@
1
+ ---
2
+ name: maestro-ralph-cli
3
+ description: "[LEGACY — prefer maestro-ralph-v2] CLI-delegated lifecycle orchestrator — compose, delegate, analyze, decide in one loop Arguments: <intent> [-y] [--to <tool>] [--amend [change]] [--roadmap] | status | continue"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Skill AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ CLI-delegated lifecycle orchestrator: compose prompt → delegate to CLI (via ralph-cli-execute wrapper) → STOP → callback → analyze structured result → mark complete → decide next → loop.
9
+
10
+ Session: `.workflow/.maestro/ralph-cli-{YYYYMMDD-HHmmss}/status.json`
11
+ </purpose>
12
+
13
+ <context>
14
+ $ARGUMENTS — intent text, flags, or keywords.
15
+
16
+ **Parse:**
17
+ ```
18
+ -y flag → auto_confirm = true
19
+ --to <tool> → cli_tool (claude|codex|opencode|agy); 默认 claude
20
+ --roadmap → wants_roadmap = true
21
+ --amend / -a → amend_mode = true
22
+ .md/.txt path → input_doc
23
+ status|continue → route keyword
24
+ Remaining → intent (amend_mode 时为 change_request)
25
+ ```
26
+
27
+ **CLI tool selection:**
28
+ 1. `--to <tool>` 显式指定 → 直接使用
29
+ 2. 未指定 → 默认 `claude`
30
+ 3. 校验 `cli-tools.json` 中目标工具 `enabled: true`
31
+ 4. `enabled: false` → E012
32
+
33
+ **State files**:
34
+ - `.workflow/state.json` — artifact registry
35
+ - `.workflow/.maestro/ralph-cli-*/status.json` — session state
36
+ </context>
37
+
38
+ <invariants>
39
+ 1. **Ralph-cli never executes steps** — only creates sessions, composes delegation prompts, and evaluates decisions;执行由 delegate 端 cli-execute 完成
40
+ 2. **ralph-cli owns the loop** — compose → delegate → analyze → decide 全部在本命令内完成;ralph-cli-execute 只是被委托端的执行包装器
41
+ 3. **Delegate via cli-execute** — delegate prompt 首行为 cli-execute 调用,格式由目标工具决定(见 Invocation Notation)
42
+ 4. **Parse ---RESULT--- block** — delegate 返回后从输出中解析结构化结果块
43
+ 5. **Decision evaluation inline** — decision 节点不 handoff,直接在本循环内评估(用 `maestro delegate --to {session.cli_tool} --mode analysis` 做只读分析)
44
+ 6. **Decision delegates read-only** — `maestro delegate --to <tool> --mode analysis`
45
+ 7. **No inline skill execution** — 本命令不执行 skill 逻辑;执行由委托端 cli-execute 完成
46
+ 8. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(由 cli-execute 端完成)
47
+ 9. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
48
+ 10. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
49
+ 11. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform claude --json --quiet` 预校验
50
+ 12. **执行 step 加载契约** — 由 `maestro ralph next` CLI 在执行期完成
51
+ 13. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻
52
+ 14. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
53
+ 15. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop
54
+ 16. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作
55
+ 17. **Delegate fallback 必须标记** — A_DELEGATE_EVALUATE 解析 verdict 失败时 fallback 为 "fix",MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`
56
+ 18. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定
57
+ 19. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有
58
+ 20. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点
59
+ </invariants>
60
+
61
+ <state_machine>
62
+
63
+ Chain-building states(S_PARSE_ROUTE through S_CREATE_SESSION)+ 执行循环 states(替代 S_DISPATCH):
64
+
65
+ <states>
66
+ S_PARSE_ROUTE — 解析参数、路由入口
67
+ S_STATUS — 显示 session 进度
68
+ S_CONTINUE — 恢复执行
69
+ S_RESOLVE_PHASE — 解析 phase 三元组 PERSIST: session.phase, phase_is_new, milestone
70
+ S_INFER — 推断生命周期位置 PERSIST: session.lifecycle_position
71
+ S_RESOLVE_SCOPE — 读 macro scope_verdict PERSIST: session.scope_verdict, analyze_macro_id
72
+ S_QUALITY_MODE — 决定质量管线长度 PERSIST: session.quality_mode
73
+ S_PLANNING_MODE — 决定规划粒度 PERSIST: session.planning_mode
74
+ S_DECOMPOSE — 分解子目标 PERSIST: session.task_decomposition
75
+ S_BUILD_CHAIN — 构建步骤链(build rules 0-14) PERSIST: session.steps[]
76
+ S_CREATE_SESSION — 写 status.json
77
+ S_CONFIRM — 用户确认
78
+
79
+ S_STEP_LOCATE — 找下一个 pending step PERSIST: —
80
+ S_STEP_RESOLVE — 解析占位符 + 丰富参数 PERSIST: step.args
81
+ S_STEP_LOAD — 加载前序产出 + 发现 PERSIST: —
82
+ S_STEP_COMPOSE — 根据目标 skill 生成适配 prompt PERSIST: —
83
+ S_STEP_DELEGATE — 调 maestro delegate → STOP PERSIST: step.delegate_exec_id, step.status
84
+ S_STEP_ANALYZE — 解析 ---RESULT--- 块 + 分析产物 PERSIST: step.cli_output_summary, session.context
85
+ S_POST_ANALYZE — 产物 vs 目标偏离分析 PERSIST: step.drift_score, step.drift_correction
86
+ S_STEP_COMPLETE — 标记完成 PERSIST: step.completion_*
87
+ S_DECISION_EVAL — 评估 decision 节点 PERSIST: —
88
+ S_APPLY_VERDICT — 应用裁决 PERSIST: session.steps[]
89
+ S_SESSION_DONE — 所有 step 完成 PERSIST: session.status
90
+ S_HANDLE_FAIL — 处理失败 PERSIST: step.status
91
+ S_AMEND_GOAL — 修改 running session 目标 PERSIST: session.task_decomposition, .boundary_contract, .goal_changelog, .steps[]
92
+ S_FALLBACK — 请求用户输入 PERSIST: —
93
+ </states>
94
+
95
+ <transitions>
96
+
97
+ S_PARSE_ROUTE:
98
+ → S_STATUS WHEN: intent == "status"
99
+ → S_CONTINUE WHEN: intent == "continue"
100
+ → S_AMEND_GOAL WHEN: amend_mode == true AND running session exists
101
+ → S_FALLBACK WHEN: amend_mode == true AND no running session
102
+ → S_STEP_LOCATE WHEN: running session with decision step in "running" status
103
+ → S_RESOLVE_PHASE WHEN: intent is non-empty
104
+ → S_FALLBACK WHEN: no intent AND no running session
105
+
106
+ S_STATUS:
107
+ → END DO: A_SHOW_STATUS
108
+
109
+ S_CONTINUE:
110
+ → S_STEP_LOCATE WHEN: running session found
111
+ → S_FALLBACK WHEN: no running session
112
+
113
+ S_AMEND_GOAL:
114
+ → S_STEP_LOCATE WHEN: change applied + user confirmed DO: A_AMEND_GOAL
115
+ → END WHEN: user cancels
116
+ GUARD: RISK_LEVEL=high → auto_confirm 无效
117
+
118
+ S_CREATE_SESSION:
119
+ → S_CONFIRM WHEN: not auto_confirm
120
+ → S_STEP_LOCATE WHEN: auto_confirm
121
+
122
+ S_CONFIRM:
123
+ → S_STEP_LOCATE WHEN: user confirms
124
+ → S_BUILD_CHAIN WHEN: user edits
125
+ → END WHEN: user cancels
126
+
127
+ S_STEP_LOCATE:
128
+ → S_STEP_RESOLVE WHEN: pending execution step found
129
+ → S_DECISION_EVAL WHEN: pending decision step found
130
+ → S_SESSION_DONE WHEN: no pending steps
131
+ → S_FALLBACK WHEN: no running session
132
+
133
+ S_STEP_RESOLVE:
134
+ → S_STEP_LOAD DO: A_RESOLVE_ARGS
135
+
136
+ S_STEP_LOAD:
137
+ → S_STEP_COMPOSE DO: A_LOAD_STEP_CONTEXT
138
+
139
+ S_STEP_COMPOSE:
140
+ → S_STEP_DELEGATE DO: A_COMPOSE_DELEGATION_PROMPT
141
+
142
+ S_STEP_DELEGATE:
143
+ → END DO: A_DISPATCH_DELEGATE (STOP after dispatch)
144
+
145
+ (callback resumes here — re-invocation via continue or automatic)
146
+ S_STEP_LOCATE (on re-entry, finds running step with delegate_exec_id):
147
+ → S_STEP_ANALYZE WHEN: delegate completed
148
+ → S_HANDLE_FAIL WHEN: delegate failed (status != completed AND status != running)
149
+ → END WHEN: delegate still running (STOP)
150
+
151
+ S_STEP_ANALYZE:
152
+ → S_POST_ANALYZE WHEN: result STATUS == DONE|DONE_WITH_CONCERNS DO: A_PARSE_RESULT
153
+ → S_HANDLE_FAIL WHEN: result STATUS == NEEDS_RETRY|BLOCKED DO: A_PARSE_RESULT
154
+
155
+ S_POST_ANALYZE:
156
+ → S_STEP_COMPLETE WHEN: drift_score == ALIGNED|MINOR_DRIFT DO: A_POST_ANALYZE_DRIFT
157
+ → S_STEP_LOAD WHEN: drift_score == MAJOR_DRIFT + not retried DO: A_POST_ANALYZE_DRIFT (re-delegate with correction)
158
+ → S_STEP_COMPLETE WHEN: drift_score == MAJOR_DRIFT + retried DO: A_POST_ANALYZE_DRIFT (proceed with caveats)
159
+
160
+ S_STEP_COMPLETE:
161
+ → S_STEP_LOCATE DO: A_MARK_COMPLETE (loop to next step)
162
+
163
+ S_DECISION_EVAL:
164
+ → S_APPLY_VERDICT WHEN: quality-gate (post-execute, post-business-test, post-review, post-test, post-frontend-verify)
165
+ DO: A_DELEGATE_EVALUATE
166
+ → S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
167
+ DO: A_GOAL_AUDIT_EVALUATE
168
+ → S_APPLY_VERDICT WHEN: scope-gate (post-analyze-scope)
169
+ DO: A_SCOPE_EVALUATE
170
+ → S_APPLY_VERDICT WHEN: reground-gate (post-reground)
171
+ DO: A_REGROUND_EVALUATE
172
+ → S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
173
+ DO: A_STRUCTURAL_EVALUATE
174
+
175
+ S_APPLY_VERDICT:
176
+ → S_STEP_LOCATE WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
177
+ → S_STEP_LOCATE WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
178
+ → S_STEP_LOCATE WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
179
+ → END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT
180
+ → S_STEP_LOCATE WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
181
+ → S_STEP_LOCATE WHEN: verdict == "fix" DO: A_APPLY_FIX
182
+ → S_STEP_LOCATE WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
183
+ → S_STEP_LOCATE WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
184
+ → END WHEN: post-milestone + standard + no next milestone
185
+ → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained, set current_milestone = null)
186
+ → END WHEN: post-debug-escalate DO: A_PAUSE_ESCALATE
187
+ → END WHEN: post-reground + drifted + confidence >= 60 DO: A_REGROUND_HALT
188
+ → S_STEP_LOCATE WHEN: post-reground + aligned DO: A_APPLY_PROCEED
189
+ → S_STEP_LOCATE WHEN: post-reground + drifted + confidence < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
190
+ GUARD: retry_count >= max_retries → force escalate
191
+ GUARD: confidence_score < 60 AND proceed → override to fix
192
+ GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
193
+ GUARD: auto_confirm → skip user prompt, apply adjusted verdict
194
+ GUARD: not auto_confirm → AskUserQuestion with override options
195
+ GUARD: post-reground + drifted + confidence >= 60 → A_REGROUND_HALT(auto_confirm 不跳过)
196
+
197
+ S_HANDLE_FAIL:
198
+ → S_STEP_LOCATE WHEN: auto + not retried DO: A_RETRY
199
+ → END WHEN: auto + retried DO: A_PAUSE_SESSION
200
+ → S_STEP_LOCATE WHEN: interactive + retry
201
+ → S_STEP_LOCATE WHEN: interactive + skip
202
+ → END WHEN: interactive + abort
203
+
204
+ S_SESSION_DONE:
205
+ → END DO: A_COMPLETE_SESSION
206
+
207
+ </transitions>
208
+
209
+ <actions>
210
+
211
+ ### A_RESOLVE_PHASE
212
+
213
+ 前置于 A_INFER_POSITION。产出 `phase` + `phase_is_new` + `milestone`(D-007 反查)三元组。
214
+
215
+ **Priority:**
216
+
217
+ | Step | 行为 | phase_is_new |
218
+ |------|------|--------------|
219
+ | 1 | intent 匹配 `phase\s*(\d+)` → 取 state.json 对应 phase | false |
220
+ | 2 | intent 派生短语 → 在 `state.json.milestones[*].phase_slugs` / `artifacts[*].path` 查找 | false (匹配) / true (无匹配) |
221
+ | 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
222
+ | 4 | 仍无 → state.json 首个 incomplete phase | false |
223
+ | 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
224
+ | 6 | 仍模糊 → `AskUserQuestion` | 由用户回答确定 |
225
+
226
+ **D-007 Phase→Milestone 反查**(数字 phase 已解析时):
227
+ ```
228
+ resolve_milestone(phase_number):
229
+ for ms in state.json.milestones:
230
+ if str(phase_number) in ms.phase_slugs: return ms.id
231
+ return state.json.current_milestone # fallback
232
+ ```
233
+ 写入 `session.milestone`;禁止直接使用 `current_milestone` 当做 phase 所属 milestone。
234
+
235
+ **写入 session**: `phase`, `phase_is_new`, `milestone`。
236
+
237
+ **新派生 phase 时 milestone 处理**:
238
+ - state.json 当前 milestone 仍 active → 沿用,新增 phase
239
+ - intent 派生新 milestone 名 → 写入 session 仅作标签;`state.json.milestones` 由 `maestro-roadmap` / `maestro-milestone-release` 创建
240
+
241
+ ### A_INFER_POSITION
242
+
243
+ **Intent-based overrides** (按顺序匹配,先命中先用):
244
+
245
+ | Pattern | Position |
246
+ |---------|----------|
247
+ | 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时透传 `-y`,grill 以 Auto mode 代码代答,不跳过**) |
248
+ | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
249
+ | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
250
+ | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
251
+
252
+ **Roadmap opt-in detection** (设 `session.wants_roadmap`,缺省 `false`):
253
+ ```
254
+ wants_roadmap = (--roadmap flag)
255
+ OR (intent 含多发布信号: 多发布|多版本|分阶段交付|按里程碑发布|v1.*v2|multi-release|roadmap)
256
+ OR (.workflow/roadmap.md 已存在) ← 向后兼容:既有 roadmap 项目行为不变
257
+ ```
258
+ 默认 `false` → large 项目走单一多波次 `plan --from analyze`,不引入 roadmap 横切层;roadmap 仅多发布场景 opt-in。
259
+
260
+ **Bootstrap detection:**
261
+
262
+ | Condition | Position |
263
+ |-----------|----------|
264
+ | No `.workflow/` + no source files | `brainstorm` |
265
+ | No `.workflow/` + has source files | `init` |
266
+ | Has `.workflow/` but no state.json | `init` |
267
+ | Has state.json | → phase-aware artifact inference |
268
+
269
+ **Phase-aware artifact inference** (使用 A_RESOLVE_PHASE 已写入的 `session.phase` + `session.phase_is_new`):
270
+
271
+ | Condition | Position |
272
+ |-----------|----------|
273
+ | `phase_is_new == true` (新 phase) | `analyze` |
274
+ | no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` if `wants_roadmap` else `plan` (--from analyze) |
275
+ | no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
276
+ | `phase == null` (grill/brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
277
+ | phase 已存在 + 无任何 artifact | `analyze` |
278
+ | phase 已存在 + 最新 artifact = analyze | `plan` |
279
+ | phase 已存在 + 最新 artifact = plan | `execute` |
280
+ | phase 已存在 + 最新 artifact = execute | → refine from post-execute results |
281
+
282
+ **关键不变量**:artifact 过滤按 `session.phase`,不读 `state.json.current_phase`。`phase_is_new` → 直接 `analyze`。
283
+
284
+ ### A_RESOLVE_SCOPE_VERDICT
285
+
286
+ 仅当 `lifecycle_position ∈ {analyze-macro, roadmap, plan}` 且存在最新 analyze artifact 时执行。
287
+
288
+ 1. 定位最新 macro analyze artifact(`type=="analyze"` 且 `scope=="macro"`,按 created_at DESC)→ 记 `session.analyze_macro_id = ANL-xxx`
289
+ 2. 读 `{artifact_path}/conclusions.json` 的 `scope_verdict` 字段(`large | medium | small`)
290
+ 3. 写入 `session.scope_verdict`;缺失时设 `unknown`
291
+ 4. 路由建议(A_BUILD_STEPS 据此决定是否插入 roadmap、plan 是否走 `--from`):
292
+
293
+ | scope_verdict | 链路 |
294
+ |---------------|------|
295
+ | `large` + `wants_roadmap` | analyze-macro → roadmap → analyze → plan → execute → ...(多发布 opt-in) |
296
+ | `large`(默认)/ `medium` / `small` | analyze-macro → plan --from analyze:{ANL_ID} → execute → ...(跳过 roadmap + analyze-phase;单一多波次计划) |
297
+ | `unknown` | 默认走 standalone(plan --from analyze)路径,post-analyze-scope 决策节点再纠正 |
298
+
299
+ **Refine from post-execute results:**
300
+
301
+ 在 execute artifact 的 scratch dir 中检查结果文件(verification.json 由 execute 内置 gate 产出):
302
+
303
+ | Condition | Position |
304
+ |-----------|----------|
305
+ | 无 verification.json 或 passed==false 或 gaps[] | `execute` (触发 post-execute fix loop) |
306
+ | passed==true, no review.json | `business-test` |
307
+ | review.json: verdict=="BLOCK" | `review-failed` |
308
+ | review.json: verdict!="BLOCK" | `test` |
309
+ | uat.md: all passed + `session.milestone` 存在 | `milestone-audit` |
310
+ | uat.md: all passed + `session.milestone=null` (standalone) | 标记 session completed(无 milestone 可审计) |
311
+ | uat.md: has failures | `test-failed` |
312
+
313
+ ### A_DETERMINE_QUALITY_MODE
314
+
315
+ 决定下游质量管线长度。读 `session.quality_mode_override`(CLI 标志 `--quality`),无则按规则推断:
316
+
317
+ | Condition | Mode | Pipeline (execute 之后) |
318
+ |-----------|------|-------------------------|
319
+ | Has `specs/REQ-*.md` + 当前 phase 业务范围明确 | `full` | business-test → review → test-gen → test |
320
+ | Default | `standard` | review → test-gen (当 coverage<80%) → test |
321
+ | `--quality quick` | `quick` | review --tier quick |
322
+
323
+ 写入 `session.quality_mode`。A_BUILD_STEPS 据此过滤 stage。
324
+
325
+ ### A_DETERMINE_PLANNING_MODE
326
+
327
+ 决定里程碑的规划粒度:一次性规划整个里程碑(统一)还是逐 phase 走完整生命周期(独立)。
328
+
329
+ **Auto-resolve rules (按优先级):**
330
+
331
+ | Condition | Mode | Reason |
332
+ |-----------|------|--------|
333
+ | lifecycle_position ∈ {grill, brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
334
+ | `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
335
+ | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
336
+ | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
337
+ | milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
338
+ | milestone 含多个 phase + 非 `auto_confirm` | → AskUserQuestion | 征询用户选择 |
339
+
340
+ **AskUserQuestion** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
341
+
342
+ ```
343
+ question: "当前里程碑含 {N} 个 phase,选择规划模式?"
344
+ options:
345
+ - label: "统一规划 (Recommended)"
346
+ description: "一次性分析+规划整个里程碑所有 phase,analyze/plan 走里程碑级,适合 phase 间关联紧密"
347
+ - label: "独立规划"
348
+ description: "逐个 phase 走完整生命周期(analyze→plan→execute→...),适合 phase 间独立性高"
349
+ ```
350
+
351
+ 写入 `session.planning_mode`(`"unified"` 或 `"independent"`)。`A_BUILD_STEPS` 据此决定 skill args 是否携带 `{phase}` 占位符。
352
+
353
+ ### A_DECOMPOSE_TASKS
354
+
355
+ Runs once before chain build; additive to status.json. 设 `session.decomposition_owner = "ralph"`。
356
+
357
+ **0. Ownership guard** (invariant 15): 若 `session.boundary_contract` 或 `session.task_decomposition` 已非空(上游 maestro 已写入,`decomposition_owner == "maestro"`)→ MUST 跳过下述提问,仅做 shape 校验 + 缺省字段补齐,直接进入步骤 6。
358
+
359
+ **1. Classify intent breadth:**
360
+
361
+ | Pattern | Breadth | Clarify? |
362
+ |---------|---------|----------|
363
+ | 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp | broad | MUST (ignores auto_confirm) |
364
+ | named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
365
+ | otherwise | medium | clarify unless auto_confirm |
366
+
367
+ **2. Clarify boundary** (broad/medium) — `AskUserQuestion`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
368
+
369
+ | Round | Question | Drives |
370
+ |-------|----------|--------|
371
+ | Scope | 哪些目录/文件/层在范围内?明确排除什么? | boundary_contract.in_scope / out_of_scope |
372
+ | Constraints | 必须向后兼容?公共 API 冻结?行为/性能预算?测试门槛? | boundary_contract.constraints + execution_criteria |
373
+ | Done | 什么可观测结果算"完成"?(如:测试全绿 + 行为零变更 + X 指标) | boundary_contract.definition_of_done |
374
+
375
+ narrow → derive defaults from intent + codebase, skip questions.
376
+
377
+ **3. Derive `execution_criteria`**: backward-compat、scope-freeze、test/coverage bar、fix-don't-hide、incremental commit。
378
+
379
+ **4. Derive `task_decomposition`** (子目标清单 — outcome-oriented, NOT lifecycle stages). Each entry:
380
+ ```json
381
+ { "id": "G1", "goal": "<deliverable>", "boundary": "<in/out note>",
382
+ "done_when": "<objectively checkable condition>",
383
+ "evidence": "verification.json|review.json|uat.md|e2e-results.json|<test path>",
384
+ "lifecycle": ["analyze","execute"], "status": "pending" }
385
+ ```
386
+ `done_when` 必须客观可验证,且引用 ralph 已产出的 artifact;`lifecycle` 字段映射到产出 evidence 的生命周期 stage。涉及前端可用性的子目标,`done_when` 应引用 `e2e-results.json`(frontend-verify 门产出),不得仅以后端 API/build 证据判定可用。
387
+
388
+ **5. Persist** (additive): `boundary_contract`, `execution_criteria`, `task_decomposition`。每个 sub-goal 含 `status: "pending"` + `completion_confirmed: false`。
389
+
390
+ **6. Stage** the Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
391
+
392
+ ### A_BUILD_STEPS
393
+
394
+ Generate steps from `session.lifecycle_position` to `milestone-complete`(`session.milestone` 存在时)或最后一个质量门(standalone 时)。
395
+
396
+ > CLI 注:每个执行 step 通过 `maestro delegate` 外部委托执行(见 Stage Mapping 表的 delegate_mode/delegate_rule 分配)。
397
+
398
+ | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
399
+ |-------|---------------------|-----------------|----------------|--------------|
400
+ | grill | `maestro-grill "{intent}"` | *(same)* | — | all (**auto_confirm → 透传 `-y` 到 grill args,不删除 stage**) |
401
+ | brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
402
+ | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
403
+ | init | `maestro-init` | *(same)* | — | all |
404
+ | spec-setup | `spec-setup` | *(same)* | — | all (**仅当 `.workflow/specs/` 不存在时插入**) |
405
+ | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
406
+ | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
407
+ | analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
408
+ | 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 |
409
+ | execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
410
+ | business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
411
+ | review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
412
+ | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
413
+ | test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
414
+ | frontend-verify | `quality-test {phase} --frontend-verify` | `quality-test --frontend-verify` | `post-frontend-verify` | all(**仅当 phase 交付 UI 时插入**:检出 `dashboard/` 或 UI 关键词 `landing\|page\|dashboard\|frontend\|UI\|component\|界面`) |
415
+ | milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
416
+ | goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
417
+ | milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
418
+
419
+ > 所有执行 stage 通过 `maestro ralph next` CLI 加载,由 A_DISPATCH_DELEGATE 委托到外部 CLI 工具执行;decision 节点单独作为独立 step 插入。
420
+
421
+ **Build rules (按顺序应用):**
422
+
423
+ 0. **planning_mode 选列**:`unified` → Skill (unified) 列;`independent` → Skill (independent) 列
424
+ 0.5. **specs 预检**:当 `lifecycle_position ∉ {grill, brainstorm, blueprint, init}` 且 `.workflow/specs/` 目录不存在时,在链路最前面插入 `spec-setup` 步骤(stage=`spec-setup`,无 decision)。确保下游 analyze/plan/execute 可获得项目约束规则注入
425
+ 1. **起点**:从 `session.lifecycle_position` 开始
426
+ 2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
427
+ 3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
428
+ 3.5. **grill auto_confirm 透传**:`auto_confirm == true` 时为 `grill` step args 追加 `-y`(grill 自身 Auto mode 用代码代答,见 maestro-grill `<context>` Mode selection);保留 `grill` stage 与 brainstorm 的 `--from grill:*`(grill 仍产出 grill-report/terminology/context-package)
429
+ 3.6. **frontend-verify UI 门控**:仅当当前 phase 交付前端(检出 `dashboard/` 目录,或 phase 目标/计划含 UI 关键词 `landing|page|dashboard|frontend|UI|component|界面`)时保留 `frontend-verify` stage + `post-frontend-verify` decision;纯后端 phase 删除该 stage
430
+ 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
431
+ 5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(execute/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
432
+ 5.5. **re-grounding 插入**:WHEN `task_decomposition` 存在 AND 执行 step(不含 decision)≥3
433
+ - 从第 3 个执行 step 起每隔 3 个插入 `{ decision: "post-reground", retry_count: 0, max_retries: 0, command_scope: null, command_path: null }`
434
+ - 不在最后一个执行 step 后插入(由 goal-audit 覆盖)
435
+ - 不与已有 quality-gate decision 节点相邻(顺延到下一个 3-step 边界)
436
+ - fix-loop 动态插入的 step **纳入**计数(从插入点起重新计算 3-step 间隔)
437
+ 6. **终点硬约束**:`session.milestone` 存在时 chain 以 `milestone-complete` 结尾;`session.milestone=null`(standalone)时跳过 `milestone-audit` + `milestone-complete` stage,chain 以最后一个质量门 stage 结尾
438
+ 7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
439
+ 8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
440
+ 9. **command_path 解析**(每个执行 step,decision 节点跳过):
441
+ - 取 skill 名(args 前的第一个 token)
442
+ - **预校验通过 `Bash("maestro ralph skills --platform claude --json --quiet")`** 一次性拉取 claude 平台可用 commands + skills(global + project,project 覆盖 global),匹配 skill 名得到:
443
+ - 命中 commands → `command_scope = "global" | "project"`,`command_path = <绝对路径>`
444
+ - 命中 skills → 同上(type=skill)
445
+ - 未命中 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
446
+ - **不在 build 阶段读取 .md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
447
+ 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `completion_summary: null`, `completion_decisions: null`, `completion_caveats: null`, `completion_deferred: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
448
+ 11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
449
+ - `scope_verdict == large` **且** `wants_roadmap` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
450
+ - 其余(`medium` / `small`,或 `large` 但非 `wants_roadmap`)→ 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
451
+ - `scope_verdict == unknown` → 默认 standalone(非 roadmap)路径;由 `post-analyze-scope` 决策节点在 macro analyze 完成后纠正(A_APPLY_SCOPE_VERDICT)
452
+ 12. **--from 自动注入**:
453
+ - `analyze_macro_id` 存在且当前 step 是 `roadmap` → args 改为 `--from analyze:{analyze_macro_id}`
454
+ - `analyze_macro_id` 存在且当前 `plan` step 处于 standalone 列(即非 wants_roadmap 路径:`medium`/`small`,或 `large` 但非 `wants_roadmap`)→ args 改为 `--from analyze:{analyze_macro_id}`
455
+ - `blueprint_id` 存在 → 当前 step 是 `plan` → args 改为 `--from blueprint:{blueprint_id}`(优先级低于 phase 数字参数)
456
+ - **phase-level deferred chaining**(独立模式,step 含 `{phase}` 占位符):build 阶段前序 artifact 尚未产出,由 A_RESOLVE_ARGS(ralph-execute)运行时从 state.json 查找同 phase+milestone 最新 completed artifact 注入:
457
+ - `plan` step → `--from analyze:{phase_analyze_id}`,写 `source_artifact_ref`
458
+ - `execute` step → `--dir {plan_path}`(现有逻辑),写 `source_artifact_ref = "plan:{id}"`
459
+ - 写入 `step.source_artifact_ref` 以便审计
460
+ 13. **D-007 Milestone-ref 标注**:每个含 `{phase}` 占位符的 step → `step.milestone_id = session.milestone`(由 A_RESOLVE_PHASE 反查得出),禁止读 `current_milestone`
461
+ 14. **动态插入步骤**(A_APPLY_*)同样应用规则 7-13
462
+
463
+ ### A_CREATE_SESSION
464
+
465
+ 1. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
466
+ 2. Write `.workflow/.maestro/ralph-cli-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
467
+ 3. Additional fields: `execution_mode: "cli-delegate"`, `cli_tool: "<selected>"`
468
+ 4. Each step: `delegate_exec_id: null`, `cli_output_summary: null`, `artifacts_produced: []`
469
+ 5. Step mode/role/rule assigned per stage (see Stage Mapping table)
470
+ 6. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
471
+ 7. **Goal Prompt 显示(强制)**:`task_decomposition` 存在时,chain overview 之后**必须逐字显示** Goal Prompt block(Appendix),不得省略或摘要
472
+
473
+ ### A_RESOLVE_ARGS
474
+
475
+ - Placeholder substitution: `{phase}`, `{milestone}`, `{intent}`
476
+ - `--from` auto-injection for phase-level artifact chaining
477
+ - Goal context injection (goal_ref → goal_snippet)
478
+ - Write enriched args back to status.json
479
+
480
+ ### A_LOAD_STEP_CONTEXT
481
+
482
+ 主流程加载前序产出和发现,为 prompt 生成准备素材。
483
+
484
+ 1. **Session base** — Read status.json → intent, phase, milestone, boundary_contract
485
+ 2. **Previous step output** — 前一 step 的 `cli_output_summary` + `completion_caveats` + `artifacts_produced` → 关键发现 + 产物路径
486
+ 3. **Artifacts** — 按产物路径逐个 Read,提取与当前 step 相关的内容:
487
+ - `conclusions.json` → scope, key_findings, recommendations
488
+ - `TASK-*.json` → task descriptions, dependencies, wave assignments
489
+ - `verification.json` → pass/fail results, gap details
490
+ - `review.json` → findings, severity, fix suggestions
491
+ - `completion_evidence` → error traces, test failures
492
+ - `grill-report.md` → challenged assumptions, risks
493
+ 4. **Explore if needed** — 产物指向代码位置但缺少上下文 → `maestro explore` 补充(仅 execute/debug/test 且有文件路径引用时)
494
+ 5. **Accumulated signals** — 遍历 ALL completed steps → 聚合 caveats + deferred
495
+
496
+ 输出:`step_context` 结构,供 A_COMPOSE_DELEGATION_PROMPT 消费。
497
+
498
+ ### A_COMPOSE_DELEGATION_PROMPT
499
+
500
+ 根据 `step_context` + 目标 skill 生成适配的 delegate prompt。
501
+
502
+ **Invocation Notation** — 由 `session.cli_tool` 决定:
503
+
504
+ | cli_tool | 首行格式 |
505
+ |----------|---------|
506
+ | claude | `/maestro-ralph-cli-execute --session {session_id}` |
507
+ | codex | `$maestro-ralph-cli-execute --session {session_id}` |
508
+ | opencode, agy | `/maestro-ralph-cli-execute --session {session_id}` |
509
+
510
+ **`<execution_context>` 块格式** — 首行调用后紧跟,cli-execute 解析此块获取 session 上下文:
511
+
512
+ ```xml
513
+ <execution_context>
514
+ <intent>{session.intent}</intent>
515
+ <phase>{session.phase}</phase>
516
+ <milestone>{session.milestone}</milestone>
517
+ <boundary_contract>
518
+ <in_scope>{boundary_contract.in_scope}</in_scope>
519
+ <out_of_scope>{boundary_contract.out_of_scope}</out_of_scope>
520
+ <definition_of_done>{boundary_contract.definition_of_done}</definition_of_done>
521
+ </boundary_contract>
522
+ <execution_criteria>{session.execution_criteria}</execution_criteria>
523
+ <active_goals>{task_decomposition WHERE status != "superseded"}</active_goals>
524
+ <prior_step_context>
525
+ {最近 5 个已完成 step 的 completion_summary + completion_caveats}
526
+ </prior_step_context>
527
+ <accumulated_signals>
528
+ {聚合所有已完成 step 的 caveats + deferred}
529
+ </accumulated_signals>
530
+ <stage_context>
531
+ {Skill-adapted 注入,见下表;仅在有实际内容时加入}
532
+ </stage_context>
533
+ </execution_context>
534
+ ```
535
+
536
+ session_anchor 由 `maestro ralph next` 注入,`<execution_context>` 注入 prior artifacts 摘要,两者不重复。
537
+
538
+ **Skill-adapted `<stage_context>`** — 根据目标 skill 类型选择性注入:
539
+
540
+ | 目标 skill 类型 | 注入重点 |
541
+ |----------------|---------|
542
+ | analyze | intent + scope + boundary |
543
+ | plan | analysis findings + scope_verdict + recommendations |
544
+ | execute | task list + dependencies + wave + caveats from plan |
545
+ | review | changed files + verification results + execution decisions |
546
+ | test | review findings + execution artifacts + coverage data |
547
+ | debug | error details + failing tests + execution trace |
548
+ | brainstorm/grill | challenged assumptions + risks + prior findings |
549
+
550
+ 每段仅在有实际内容时加入,无内容则跳过。
551
+
552
+ ### A_DISPATCH_DELEGATE
553
+
554
+ 1. Build command:
555
+ ```
556
+ maestro delegate "{composed_prompt}"
557
+ --to {session.cli_tool}
558
+ --mode {step.delegate_mode}
559
+ --id {stage_prefix}-{HHmmss}-{rand4}
560
+ ```
561
+
562
+ 2. Write `step.delegate_exec_id`, `step.status = "running"` to status.json
563
+
564
+ 3. `Bash({ command: "maestro delegate ...", run_in_background: true })`
565
+
566
+ 4. Display: `[{index}/{total}] ⟶ {step.skill} → delegate:{exec_id} [{cli_tool}]`
567
+
568
+ 5. **STOP**
569
+
570
+ ### A_PARSE_RESULT
571
+
572
+ On callback (re-invocation finds running step with delegate_exec_id):
573
+
574
+ 1. `Bash("maestro delegate status {exec_id}")` — still running → STOP
575
+ 2. `Bash("maestro delegate output {exec_id}")` — get full output
576
+ 3. Parse `---RESULT---` / `---END---` block:
577
+ ```
578
+ STATUS → completion_status
579
+ SUMMARY → completion_summary (→ --summary)
580
+ ARTIFACTS → artifacts_produced (split by comma)
581
+ EVIDENCE → completion_evidence (→ --evidence)
582
+ DECISIONS → completion_decisions (→ --decisions)
583
+ CAVEATS → completion_caveats (→ --caveats);DONE_WITH_CONCERNS 时同时映射为 --concerns
584
+ DEFERRED → completion_deferred (→ --deferred)
585
+ SIGNALS → parse key=value pairs → update session.context
586
+ ```
587
+ 4. If no `---RESULT---` block found → fallback: STATUS=DONE_WITH_CONCERNS, SUMMARY from last 200 chars of output
588
+ 5. Write parsed data to step in status.json
589
+
590
+ ### A_MARK_COMPLETE
591
+
592
+ **RESULT→complete 映射:** `STATUS→--status`、`SUMMARY→--summary`、`EVIDENCE→--evidence`、`DECISIONS→--decisions`、`CAVEATS→--caveats`(DONE_WITH_CONCERNS 时同时作 `--concerns`)、`DEFERRED→--deferred`。SIGNALS 写入 `status.json.context`,不传给 complete。
593
+
594
+ 1. `Bash("maestro ralph complete {index} --status {STATUS} --summary \"{SUMMARY}\" [--evidence ...] [--decisions ...] [--caveats ...] [--deferred ...]")`
595
+ 2. Apply SIGNALS to `session.context`
596
+ 3. Display: `[{index}/{total}] ✓ {step.skill} → {SUMMARY}`
597
+ 4. Loop back to S_STEP_LOCATE
598
+
599
+ ### A_SHOW_STATUS
600
+
601
+ Find latest ralph-cli session, display steps + sub-goals progress.
602
+
603
+ ### A_POST_ANALYZE_DRIFT
604
+
605
+ 产物 vs 目标偏离分析。A_PARSE_RESULT 后、A_MARK_COMPLETE 前执行。
606
+
607
+ **1. 收集对照基准:**
608
+
609
+ | 基准来源 | 取值 |
610
+ |---------|------|
611
+ | `step.goal_ref` → goal.done_when | 子目标的完成条件 |
612
+ | `session.boundary_contract.definition_of_done` | 全局验收标准 |
613
+ | `session.execution_criteria` | 执行准则 |
614
+ | `session.intent` | 原始意图 |
615
+
616
+ **2. 读产物摘要:**
617
+
618
+ 从 A_PARSE_RESULT 已提取的 SUMMARY + DECISIONS + ARTIFACTS + CAVEATS 构建产物画像。
619
+
620
+ **3. 对比评分:**
621
+
622
+ | 维度 | 检查 |
623
+ |------|------|
624
+ | 覆盖度 | 产物是否覆盖了 goal.done_when 的每个条件 |
625
+ | 方向性 | DECISIONS 是否与 intent 和 boundary 一致 |
626
+ | 完整性 | 预期产物类型是否齐全 |
627
+
628
+ **drift_score:**
629
+ - `ALIGNED` — 全部维度通过
630
+ - `MINOR_DRIFT` — 覆盖度/完整性有小缺口
631
+ - `MAJOR_DRIFT` — 方向性偏离或关键产物缺失
632
+
633
+ **4. 修正动作:**
634
+
635
+ | drift_score | 动作 |
636
+ |-------------|------|
637
+ | ALIGNED | 正常进入 S_STEP_COMPLETE |
638
+ | MINOR_DRIFT | 将偏离项追加到 completion_caveats,正常 complete |
639
+ | MAJOR_DRIFT + 未重试 | 写 `step.drift_correction`,回到 S_STEP_LOAD 重新加载 + compose + delegate(drift_correction 作为修正上下文注入 prompt) |
640
+ | MAJOR_DRIFT + 已重试 | 以 DONE_WITH_CONCERNS complete,由后续 decision node 裁决 |
641
+
642
+ **5. 写入:** `step.drift_score`, `step.drift_correction`
643
+
644
+ ### A_DELEGATE_EVALUATE
645
+
646
+ Inline 评估质量门(非 handoff)。Runs `run_in_background` → STOP → callback resume in same loop。
647
+
648
+ 1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
649
+ 2. Parse decision metadata: `{ decision, retry_count, max_retries }`
650
+ 3. Map result files:
651
+
652
+ | Decision | Files |
653
+ |----------|-------|
654
+ | post-execute | verification.json |
655
+ | post-business-test | .tests/auto-test/report.json |
656
+ | post-review | review.json |
657
+ | post-test | uat.md, .tests/test-results.json |
658
+ | post-frontend-verify | e2e-results.json |
659
+
660
+ 4. Execute delegate (run_in_background, STOP, wait for callback):
661
+ ```
662
+ maestro delegate "PURPOSE: 评估 {decision} 质量门结果
663
+ TASK: 读取结果 | 分析状态 | 评估严重性 | 给出建议
664
+ EXPECTED: ---VERDICT--- STATUS(PASS|FAIL|PARTIAL|BLOCKED)/REASON/GAP_SUMMARY/CONFIDENCE(high|medium|low)/CONFIDENCE_SCORE(0-100)/WEAKEST_DIMENSION ---END---
665
+ CONSTRAINTS: 只评估 | 置信度<60% 倾向 fix | retry {n}/{max} 达上限必须 escalate"
666
+ --to {session.cli_tool} --mode analysis
667
+ ```
668
+ 5. On callback: parse `---VERDICT---` block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; any other value → parse failure. If parse fails → fallback STATUS="fix", BUT MUST set `parse_failed: true` and `confidence_score: 0` in decision log (invariant 13). Subsequent steps inherit LOW CONFIDENCE flag.
669
+ 6. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
670
+ 7. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
671
+ ```json
672
+ { "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-cli",
673
+ "node_id": "{step.decision}", "type": "quality-gate",
674
+ "verdict": "{adjusted_verdict}", "confidence_score": {N},
675
+ "parse_failed": false,
676
+ "close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
677
+ ```
678
+
679
+ ### A_GOAL_AUDIT_EVALUATE
680
+
681
+ 审计未完成子目标,判定 met / unmet。Delegate `--to {session.cli_tool} --mode analysis`。
682
+
683
+ 追加 `{session_dir}/decisions.ndjson`:`{ "type": "goal-gate", "unmet_count": N, "unmet_ids": [...] }`。
684
+ GUARD: `retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE`。
685
+ Verdict routing: `all_met` + `INTENT_ALIGNED=true` → A_APPLY_GOAL_DONE;`all_met` + `INTENT_ALIGNED=false` → A_REGROUND_HALT;`has_unmet` → A_APPLY_GOAL_FIX。
686
+
687
+ ### A_SCOPE_EVALUATE
688
+
689
+ Read `conclusions.json.scope_verdict` from macro analyze artifact. Write to `session.scope_verdict` + `session.analyze_macro_id`. Append `{session_dir}/decisions.ndjson`:`{ "type": "scope-gate", "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }`。
690
+
691
+ ### A_REGROUND_EVALUATE
692
+
693
+ 意图保真检查(delegate prompt 含 intent + boundary + completed_steps + done_goals + accumulated_deferred + goal_changelog)。Delegate `--to {session.cli_tool} --mode analysis`。
694
+
695
+ Append `{session_dir}/decisions.ndjson`:`{ "type": "reground-gate", "verdict": "{aligned|drifted}", "confidence_score": {N}, "drift_description": "...", "corrective_action": "..." }`。
696
+ Verdict routing: `aligned` → A_APPLY_PROCEED;`drifted` + `confidence >= 60` → A_REGROUND_HALT;`drifted` + `confidence < 60` → A_APPLY_PROCEED(标 LOW CONFIDENCE)。
697
+
698
+ ### A_STRUCTURAL_EVALUATE
699
+
700
+ **post-milestone**: read state.json → determine milestone type → standard: next milestone? insert lifecycle steps / complete. Adhoc: always END.
701
+ **post-debug-escalate**: always STOP → A_PAUSE_ESCALATE.
702
+
703
+ ### A_APPLY_PROCEED / A_APPLY_FIX / A_APPLY_ESCALATE
704
+
705
+ Mark decision completed / insert fix-loop steps / insert debug-escalate.
706
+
707
+ ### A_APPLY_SCOPE_VERDICT
708
+
709
+ Reshape downstream chain based on `scope_verdict`(large+wants_roadmap → keep roadmap;medium/small → collapse to standalone plan)。
710
+
711
+ ### A_APPLY_GOAL_FIX / A_APPLY_GOAL_DONE
712
+
713
+ Insert scoped mini-loops for unmet sub-goals / mark all goals done + `task_decomposition_all_done=true`.
714
+
715
+ ### A_ADVANCE_MILESTONE
716
+
717
+ Update session milestone/phase, insert full lifecycle steps for next milestone, reindex.
718
+
719
+ ### A_REGROUND_HALT
720
+
721
+ Set `session.status = "paused"`, display drift warning. auto_confirm 不跳过.
722
+
723
+ ### A_PAUSE_ESCALATE
724
+
725
+ Set session paused, display "请人工介入", suggest `/maestro-ralph-cli continue`.
726
+
727
+ ### A_AMEND_GOAL
728
+
729
+ 5 步流程(快照→解析→mini grill→确认→应用),deferred_reading: `ralph-amend-goal.md`。RISK_LEVEL=high 时 auto_confirm 无效。
730
+
731
+ ### A_RETRY / A_PAUSE_SESSION / A_COMPLETE_SESSION
732
+
733
+ - **A_RETRY**: `maestro ralph retry {index}` — CLI 清空 `delegate_exec_id`,设 `step.retried = true`、`step.status = "pending"`,清 `active_step_index`;ralph-cli 回到 S_STEP_RESOLVE 重新 compose→delegate
734
+ - **A_PAUSE_SESSION**: 由 `ralph complete N --status BLOCKED --reason "..."` 触发,CLI 写 `session.status = "paused"`
735
+ - **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`
736
+
737
+ </actions>
738
+
739
+ </state_machine>
740
+
741
+ <appendix>
742
+
743
+ ### Stage Mapping
744
+
745
+ | Stage | delegate_mode | delegate_rule |
746
+ |-------|---------------|---------------|
747
+ | analyze, analyze-macro | analysis | `analysis-analyze-code-patterns` |
748
+ | plan | write | `planning-breakdown-task-steps` |
749
+ | execute | write | `development-implement-feature` |
750
+ | review, business-test | analysis | `analysis-review-code-quality` |
751
+ | test, test-gen, frontend-verify | write | — |
752
+ | grill, brainstorm | write | — |
753
+ | debug, quality-debug | write | `analysis-diagnose-bug-root-cause` |
754
+ | blueprint | write | `planning-design-component-spec` |
755
+ | init, spec-setup | write | — |
756
+ | milestone-audit | analysis | `analysis-review-code-quality` |
757
+ | milestone-complete | write | — |
758
+
759
+ Fix-loop 插入的 step 按此表分配 `delegate_mode` + `delegate_rule`。
760
+
761
+ All delegation uses `--to {session.cli_tool}` (not `--role`). The `cli_tool` is resolved from session context.
762
+
763
+ ### Delegate Exec ID Prefix
764
+
765
+ | Stage | Prefix |
766
+ |-------|--------|
767
+ | grill | `grl` |
768
+ | brainstorm | `brn` |
769
+ | analyze-macro | `anm` |
770
+ | analyze | `ana` |
771
+ | plan | `pln` |
772
+ | execute | `exe` |
773
+ | review | `rev` |
774
+ | test | `tst` |
775
+ | debug | `dbg` |
776
+
777
+ ### Session Schema
778
+
779
+ ```json
780
+ {
781
+ "session_id": "ralph-cli-{YYYYMMDD-HHmmss}",
782
+ "source": "ralph", "status": "running",
783
+ "execution_mode": "cli-delegate",
784
+ "cli_tool": "claude",
785
+ "ralph_protocol_version": "2",
786
+ "active_step_index": null,
787
+ "intent": "", "lifecycle_position": "",
788
+ "phase": null, "phase_is_new": false,
789
+ "milestone": "",
790
+ "auto_mode": false,
791
+ "decomposition_owner": "ralph",
792
+
793
+ "quality_mode": "standard",
794
+ "planning_mode": "independent",
795
+ "scope_verdict": null,
796
+ "wants_roadmap": false,
797
+ "analyze_macro_id": null,
798
+ "blueprint_id": null,
799
+ "passed_gates": [],
800
+ "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
801
+ "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
802
+ "steps": [{
803
+ "index": 0,
804
+ "skill": "",
805
+ "args": "",
806
+ "stage": "",
807
+ "scope": null,
808
+ "decision": null,
809
+ "retry_count": 0,
810
+ "max_retries": 2,
811
+ "command_scope": "global|project|missing|null",
812
+ "command_path": "<absolute path resolved by `maestro ralph skills --platform claude --json --quiet`> | null",
813
+ "milestone_id": null,
814
+ "source_artifact_ref": null,
815
+ "status": "pending|running|completed|skipped|failed",
816
+ "goal_ref": null,
817
+ "completion_confirmed": false,
818
+ "completion_status": null,
819
+ "completion_evidence": null,
820
+ "completion_summary": null,
821
+ "completion_decisions": null,
822
+ "completion_caveats": null,
823
+ "completion_deferred": null,
824
+ "completed_at": null,
825
+ "deferred_reads": [],
826
+ "load": null, // { loaded_at, required_files[], deferred_files[], resolve_version } — 由 ralph next (cli-execute 端) 写入
827
+ "delegate_exec_id": null,
828
+ "delegate_mode": "write|analysis",
829
+ "delegate_rule": null,
830
+ "cli_output_summary": null,
831
+ "artifacts_produced": [],
832
+ "drift_score": null,
833
+ "drift_correction": null
834
+ }],
835
+ "waves": [], "current_step": 0,
836
+
837
+ "boundary_contract": {
838
+ "in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
839
+ },
840
+ "execution_criteria": [],
841
+ "task_decomposition": [
842
+ { "id": "G1", "goal": "", "boundary": "", "done_when": "",
843
+ "evidence": "", "lifecycle": [], "status": "pending|done|superseded",
844
+ "completion_confirmed": false, "completed_at": null,
845
+ "superseded_by": null, "superseded_at": null, "origin": null }
846
+ ],
847
+ "task_decomposition_all_done": false,
848
+
849
+ "goal_changelog": [
850
+ { "id": "CHG-001", "timestamp": "{ISO}",
851
+ "change_type": "modify|add|remove|boundary",
852
+ "reason": "",
853
+ "impact_assessment": { "risk_level": "low|medium|high",
854
+ "invalidated_steps": [], "new_steps_inserted": 0 },
855
+ "before": { "goals": [{"id":"G1","goal":"...","done_when":"..."}] },
856
+ "after": { "goals": [{"id":"G1v2","goal":"...","done_when":"..."}] } }
857
+ ]
858
+ }
859
+ ```
860
+
861
+ 新增字段可选,缺省=旧行为;既有字段名不删不改。
862
+
863
+ ### Fix-Loop Templates
864
+
865
+ 所有插入的执行 step 按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点。Each inserted step is delegated through the same compose → delegate → analyze cycle.
866
+
867
+ **post-execute:**
868
+ ```
869
+ quality-debug "{gap_summary}"
870
+ maestro-plan --gaps {phase}
871
+ maestro-execute {phase}
872
+ decision:post-execute {retry+1}
873
+ ```
874
+
875
+ **post-business-test:**
876
+ ```
877
+ quality-debug --from-business-test "{gap_summary}"
878
+ maestro-plan --gaps {phase}
879
+ maestro-execute {phase}
880
+ decision:post-execute {retry: 0}
881
+ quality-auto-test {phase}
882
+ decision:post-business-test {retry+1}
883
+ ```
884
+
885
+ **post-review:**
886
+ ```
887
+ quality-debug "{gap_summary}"
888
+ maestro-plan --gaps {phase}
889
+ maestro-execute {phase}
890
+ quality-review {phase}
891
+ decision:post-review {retry+1}
892
+ ```
893
+
894
+ **post-test:**
895
+ ```
896
+ quality-debug --from-uat "{gap_summary}"
897
+ maestro-plan --gaps {phase}
898
+ maestro-execute {phase}
899
+ decision:post-execute {retry: 0}
900
+ quality-auto-test {phase}
901
+ decision:post-business-test {retry: 0}
902
+ quality-review {phase}
903
+ decision:post-review {retry: 0}
904
+ quality-auto-test {phase}
905
+ quality-test {phase}
906
+ decision:post-test {retry+1}
907
+ ```
908
+
909
+ **post-frontend-verify:** (UI 写端点未接线/不可用时)
910
+ ```
911
+ quality-debug --from-frontend-verify "{gap_summary}"
912
+ maestro-plan --gaps {phase}
913
+ maestro-execute {phase}
914
+ quality-test {phase} --frontend-verify
915
+ decision:post-frontend-verify {retry+1}
916
+ ```
917
+
918
+ **post-goal-audit:** (per unmet sub-goal group)
919
+ ```
920
+ # for each unmet sub-goal G{n}, scoped to target_phase:
921
+ maestro-plan --gaps {target_phase} "G{n}: {gap}" [goal_ref: G{n}]
922
+ maestro-execute {target_phase} [goal_ref: G{n}]
923
+ # after all unmet groups inserted:
924
+ decision:post-goal-audit {retry+1}
925
+ ```
926
+
927
+ ### Error Codes
928
+
929
+ E001–E006, W001–W004 适用。CLI 新增:
930
+
931
+ | Code | Severity | Description | Recovery |
932
+ |------|----------|-------------|----------|
933
+ | E011 | error | Delegate execution failed | Retry once, then BLOCKED |
934
+ | E012 | error | CLI tool not enabled in cli-tools.json | Switch tool or enable |
935
+ | E013 | error | ---RESULT--- block not found in output | Fallback parse, mark LOW CONFIDENCE |
936
+
937
+ ### Success Criteria
938
+
939
+ - [ ] ralph-cli owns full loop: compose → delegate → STOP → callback → parse → complete → next
940
+ - [ ] Delegation prompt 首行为 cli-execute 调用(`--session {session_id}`,格式由 cli_tool 决定),后接 `<execution_context>`
941
+ - [ ] A_PARSE_RESULT extracts STATUS/SUMMARY/ARTIFACTS/DECISIONS/CAVEATS/DEFERRED/SIGNALS from ---RESULT--- block
942
+ - [ ] SIGNALS parsed as key=value pairs and applied to session.context
943
+ - [ ] Decision evaluation runs inline (no handoff to another command)
944
+ - [ ] ralph-cli-execute 仅通过 delegate 会话加载执行,不直接 Skill() 调用
945
+ - [ ] Sliding window: last 5 completed steps in execution_context
946
+ - [ ] Accumulated caveats/deferred from ALL completed steps
947
+ - [ ] Stage-specific artifact injection in execution_context
948
+ - [ ] CLI tool defaults to claude, overridden by --to
949
+ - [ ] `--roadmap` flag parsed → `wants_roadmap = true`
950
+ - [ ] `.md/.txt path → input_doc` parsed
951
+ - [ ] S_AMEND_GOAL + A_AMEND_GOAL 完整实现(5 步流程,RISK_LEVEL=high 不跳过)
952
+ - [ ] `goal_changelog` 写入路径存在(amend 流程产出)
953
+ - [ ] `blueprint_id` session 字段支持 `--from blueprint:{BLP_ID}` 路径
954
+ - [ ] A_SHOW_STATUS 显示 task_decomposition 子目标进度
955
+ - [ ] A_STRUCTURAL_EVALUATE 处理 post-milestone + post-debug-escalate
956
+ - [ ] A_ADVANCE_MILESTONE 插入下一里程碑 lifecycle steps
957
+ - [ ] A_REGROUND_HALT 漂移熔断(auto_confirm 不跳过)
958
+ - [ ] A_PAUSE_ESCALATE 达到 max_retries 时暂停
959
+ - [ ] A_APPLY_SCOPE_VERDICT 三路径重塑(large+roadmap / medium-small / unknown)
960
+ - [ ] Fix-loop templates(6 套)通过 compose-delegate cycle 执行;插入 step 按 Stage Mapping 表分配 delegate_mode + delegate_rule
961
+ - [ ] re-grounding 3-step 插入规则(build rule 5.5)
962
+ - [ ] spec-setup 预检(build rule 0.5)
963
+ - [ ] Invariant 2(Skill handoff)在 ralph-cli 中被覆盖,由 invariant 17-21 替代
964
+ - [ ] execution_context 块含 intent + phase + boundary_contract + execution_criteria + active_goals + prior_step_context(滑动窗口 5 step)+ accumulated_signals
965
+ - [ ] execution_context 中 boundary_contract 不截断;superseded 目标仅一行标注
966
+ - [ ] A_DELEGATE_EVALUATE 解析 `---VERDICT---` 块,parse 失败 → fallback fix + parse_failed: true + confidence_score: 0
967
+ - [ ] decisions.ndjson 追加:quality-gate / goal-gate / scope-gate / reground-gate 各有完整格式
968
+ - [ ] `completion_summary` 在 STATUS=DONE/DONE_WITH_CONCERNS 时为 MUST(--summary 参数非空)
969
+ - [ ] RESULT 的 EVIDENCE 字段映射到 --evidence;CAVEATS 在 DONE_WITH_CONCERNS 时同时映射 --concerns
970
+ - [ ] post-milestone adhoc 分支:mark completed + set current_milestone = null
971
+ - [ ] post-reground + drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
972
+ - [ ] 旧目标标 superseded(superseded_by + superseded_at),新目标 origin: "CHG-xxx"
973
+ - [ ] goal_changelog 含完整 before/after + impact_assessment
974
+
975
+ </appendix>
976
+ </output>