maestro-flow 0.4.11 → 0.4.13

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 (253) hide show
  1. package/.agents/agents/cli-explore-agent.md +1 -3
  2. package/.agents/agents/cross-role-reviewer.md +173 -0
  3. package/.agents/agents/role-design-author.md +220 -0
  4. package/.agents/agents/ui-design-agent.md +1 -18
  5. package/.agents/agents/workflow-analyzer.md +1 -1
  6. package/.agents/agents/workflow-external-researcher.md +1 -1
  7. package/.agents/skills/learn-decompose/SKILL.md +6 -6
  8. package/.agents/skills/learn-follow/SKILL.md +4 -4
  9. package/.agents/skills/learn-investigate/SKILL.md +6 -6
  10. package/.agents/skills/learn-retro/SKILL.md +7 -7
  11. package/.agents/skills/learn-second-opinion/SKILL.md +4 -4
  12. package/.agents/skills/maestro/SKILL.md +61 -27
  13. package/.agents/skills/maestro-amend/SKILL.md +1 -0
  14. package/.agents/skills/maestro-analyze/SKILL.md +37 -4
  15. package/.agents/skills/maestro-blueprint/SKILL.md +133 -0
  16. package/.agents/skills/maestro-brainstorm/SKILL.md +120 -103
  17. package/.agents/skills/maestro-fork/SKILL.md +1 -1
  18. package/.agents/skills/maestro-guard/SKILL.md +3 -2
  19. package/.agents/skills/maestro-help/SKILL.md +48 -14
  20. package/.agents/skills/maestro-help/index/catalog.json +29 -11
  21. package/.agents/skills/maestro-help/phases/01-parse-intent.md +1 -1
  22. package/.agents/skills/maestro-help/phases/02-search-present.md +6 -4
  23. package/.agents/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  24. package/.agents/skills/maestro-impeccable/SKILL.md +13 -11
  25. package/.agents/skills/maestro-init/SKILL.md +3 -3
  26. package/.agents/skills/maestro-milestone-audit/SKILL.md +5 -3
  27. package/.agents/skills/maestro-milestone-complete/SKILL.md +7 -5
  28. package/.agents/skills/maestro-milestone-release/SKILL.md +1 -1
  29. package/.agents/skills/maestro-plan/SKILL.md +16 -4
  30. package/.agents/skills/maestro-ralph/SKILL.md +297 -226
  31. package/.agents/skills/maestro-ralph-execute/SKILL.md +82 -67
  32. package/.agents/skills/maestro-roadmap/SKILL.md +43 -81
  33. package/.agents/skills/manage-harvest/SKILL.md +1 -0
  34. package/.agents/skills/manage-issue-discover/SKILL.md +1 -1
  35. package/.agents/skills/manage-knowhow/SKILL.md +1 -1
  36. package/.agents/skills/manage-learn/SKILL.md +4 -4
  37. package/.agents/skills/quality-auto-test/SKILL.md +6 -6
  38. package/.agents/skills/quality-refactor/SKILL.md +1 -1
  39. package/.agents/skills/quality-retrospective/SKILL.md +2 -2
  40. package/.agents/skills/security-audit/SKILL.md +24 -0
  41. package/.agents/skills/spec-remove/SKILL.md +6 -2
  42. package/.agents/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  43. package/.agents/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  44. package/.agents/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  45. package/.agents/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  46. package/.agents/skills/team-lifecycle-v4/templates/epics.md +2 -2
  47. package/.agents/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  48. package/.agents/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  49. package/.agy/agents/cli-explore-agent.md +1 -3
  50. package/.agy/agents/cross-role-reviewer.md +170 -0
  51. package/.agy/agents/role-design-author.md +217 -0
  52. package/.agy/agents/ui-design-agent.md +1 -18
  53. package/.agy/agents/workflow-analyzer.md +1 -1
  54. package/.agy/agents/workflow-external-researcher.md +1 -1
  55. package/.agy/skills/learn-decompose/SKILL.md +6 -6
  56. package/.agy/skills/learn-follow/SKILL.md +4 -4
  57. package/.agy/skills/learn-investigate/SKILL.md +6 -6
  58. package/.agy/skills/learn-retro/SKILL.md +7 -7
  59. package/.agy/skills/learn-second-opinion/SKILL.md +4 -4
  60. package/.agy/skills/maestro/SKILL.md +61 -27
  61. package/.agy/skills/maestro-amend/SKILL.md +1 -0
  62. package/.agy/skills/maestro-analyze/SKILL.md +37 -4
  63. package/.agy/skills/maestro-blueprint/SKILL.md +133 -0
  64. package/.agy/skills/maestro-brainstorm/SKILL.md +120 -103
  65. package/.agy/skills/maestro-fork/SKILL.md +1 -1
  66. package/.agy/skills/maestro-guard/SKILL.md +3 -2
  67. package/.agy/skills/maestro-help/SKILL.md +48 -14
  68. package/.agy/skills/maestro-help/index/catalog.json +29 -11
  69. package/.agy/skills/maestro-help/phases/01-parse-intent.md +1 -1
  70. package/.agy/skills/maestro-help/phases/02-search-present.md +6 -4
  71. package/.agy/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  72. package/.agy/skills/maestro-impeccable/SKILL.md +13 -11
  73. package/.agy/skills/maestro-init/SKILL.md +3 -3
  74. package/.agy/skills/maestro-milestone-audit/SKILL.md +5 -3
  75. package/.agy/skills/maestro-milestone-complete/SKILL.md +7 -5
  76. package/.agy/skills/maestro-milestone-release/SKILL.md +1 -1
  77. package/.agy/skills/maestro-plan/SKILL.md +16 -4
  78. package/.agy/skills/maestro-ralph/SKILL.md +297 -226
  79. package/.agy/skills/maestro-ralph-execute/SKILL.md +82 -67
  80. package/.agy/skills/maestro-roadmap/SKILL.md +43 -81
  81. package/.agy/skills/manage-harvest/SKILL.md +1 -0
  82. package/.agy/skills/manage-issue-discover/SKILL.md +1 -1
  83. package/.agy/skills/manage-knowhow/SKILL.md +1 -1
  84. package/.agy/skills/manage-learn/SKILL.md +4 -4
  85. package/.agy/skills/quality-auto-test/SKILL.md +6 -6
  86. package/.agy/skills/quality-refactor/SKILL.md +1 -1
  87. package/.agy/skills/quality-retrospective/SKILL.md +2 -2
  88. package/.agy/skills/security-audit/SKILL.md +24 -0
  89. package/.agy/skills/spec-remove/SKILL.md +6 -2
  90. package/.agy/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  91. package/.agy/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  92. package/.agy/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  93. package/.agy/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  94. package/.agy/skills/team-lifecycle-v4/templates/epics.md +2 -2
  95. package/.agy/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  96. package/.agy/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  97. package/.claude/agents/cli-explore-agent.md +1 -3
  98. package/.claude/agents/cross-role-reviewer.md +171 -0
  99. package/.claude/agents/role-design-author.md +218 -0
  100. package/.claude/agents/ui-design-agent.md +1 -18
  101. package/.claude/agents/workflow-analyzer.md +1 -1
  102. package/.claude/agents/workflow-external-researcher.md +1 -1
  103. package/.claude/commands/learn-decompose.md +6 -6
  104. package/.claude/commands/learn-follow.md +4 -4
  105. package/.claude/commands/learn-investigate.md +6 -6
  106. package/.claude/commands/learn-retro.md +7 -7
  107. package/.claude/commands/learn-second-opinion.md +4 -4
  108. package/.claude/commands/maestro-amend.md +1 -0
  109. package/.claude/commands/maestro-analyze.md +37 -4
  110. package/.claude/commands/maestro-blueprint.md +131 -0
  111. package/.claude/commands/maestro-brainstorm.md +133 -116
  112. package/.claude/commands/maestro-fork.md +1 -1
  113. package/.claude/commands/maestro-guard.md +3 -2
  114. package/.claude/commands/maestro-impeccable.md +13 -11
  115. package/.claude/commands/maestro-init.md +3 -3
  116. package/.claude/commands/maestro-milestone-audit.md +5 -3
  117. package/.claude/commands/maestro-milestone-complete.md +7 -5
  118. package/.claude/commands/maestro-milestone-release.md +1 -1
  119. package/.claude/commands/maestro-plan.md +16 -4
  120. package/.claude/commands/maestro-ralph-execute.md +82 -67
  121. package/.claude/commands/maestro-ralph.md +297 -226
  122. package/.claude/commands/maestro-roadmap.md +43 -81
  123. package/.claude/commands/maestro.md +61 -27
  124. package/.claude/commands/manage-harvest.md +1 -0
  125. package/.claude/commands/manage-issue-discover.md +1 -1
  126. package/.claude/commands/manage-knowhow.md +1 -1
  127. package/.claude/commands/manage-learn.md +4 -4
  128. package/.claude/commands/quality-auto-test.md +6 -6
  129. package/.claude/commands/quality-refactor.md +1 -1
  130. package/.claude/commands/quality-retrospective.md +2 -2
  131. package/.claude/commands/security-audit.md +24 -0
  132. package/.claude/commands/spec-remove.md +6 -2
  133. package/.claude/skills/maestro-help/SKILL.md +48 -14
  134. package/.claude/skills/maestro-help/index/catalog.json +29 -11
  135. package/.claude/skills/maestro-help/phases/01-parse-intent.md +1 -1
  136. package/.claude/skills/maestro-help/phases/02-search-present.md +6 -4
  137. package/.claude/skills/maestro-help/phases/03-workflow-guide.md +60 -33
  138. package/.claude/skills/team-lifecycle-v4/roles/analyst/role.md +1 -1
  139. package/.claude/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  140. package/.claude/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  141. package/.claude/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  142. package/.claude/skills/team-lifecycle-v4/templates/epics.md +2 -2
  143. package/.claude/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  144. package/.claude/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  145. package/.codex/skills/learn-decompose/SKILL.md +4 -4
  146. package/.codex/skills/learn-follow/SKILL.md +3 -3
  147. package/.codex/skills/learn-investigate/SKILL.md +3 -3
  148. package/.codex/skills/learn-retro/SKILL.md +3 -3
  149. package/.codex/skills/learn-second-opinion/SKILL.md +3 -3
  150. package/.codex/skills/maestro/SKILL.md +75 -38
  151. package/.codex/skills/maestro-amend/SKILL.md +157 -0
  152. package/.codex/skills/maestro-analyze/SKILL.md +72 -23
  153. package/.codex/skills/maestro-blueprint/SKILL.md +123 -0
  154. package/.codex/skills/maestro-brainstorm/SKILL.md +277 -46
  155. package/.codex/skills/maestro-composer/SKILL.md +1 -1
  156. package/.codex/skills/maestro-execute/SKILL.md +13 -4
  157. package/.codex/skills/maestro-fork/SKILL.md +2 -0
  158. package/.codex/skills/maestro-guard/SKILL.md +3 -2
  159. package/.codex/skills/maestro-help/SKILL.md +28 -18
  160. package/.codex/skills/maestro-help/catalog.json +29 -11
  161. package/.codex/skills/maestro-impeccable/SKILL.md +13 -11
  162. package/.codex/skills/maestro-init/SKILL.md +7 -7
  163. package/.codex/skills/maestro-plan/SKILL.md +27 -9
  164. package/.codex/skills/maestro-ralph/SKILL.md +740 -601
  165. package/.codex/skills/maestro-roadmap/SKILL.md +56 -72
  166. package/.codex/skills/maestro-update/SKILL.md +169 -0
  167. package/.codex/skills/maestro-verify/SKILL.md +11 -2
  168. package/.codex/skills/manage-codebase-rebuild/SKILL.md +9 -5
  169. package/.codex/skills/manage-harvest/SKILL.md +11 -3
  170. package/.codex/skills/manage-issue-discover/SKILL.md +1 -1
  171. package/.codex/skills/manage-knowhow/SKILL.md +1 -1
  172. package/.codex/skills/manage-learn/SKILL.md +3 -3
  173. package/.codex/skills/quality-refactor/SKILL.md +2 -2
  174. package/.codex/skills/quality-retrospective/SKILL.md +12 -5
  175. package/.codex/skills/security-audit/SKILL.md +24 -0
  176. package/.codex/skills/spec-remove/SKILL.md +8 -2
  177. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +2 -2
  178. package/.codex/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +2 -2
  179. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +1 -1
  180. package/.codex/skills/team-lifecycle-v4/templates/architecture.md +3 -3
  181. package/.codex/skills/team-lifecycle-v4/templates/epics.md +2 -2
  182. package/.codex/skills/team-lifecycle-v4/templates/product-brief.md +3 -3
  183. package/.codex/skills/team-lifecycle-v4/templates/requirements.md +2 -2
  184. package/README.md +8 -8
  185. package/README.zh-CN.md +8 -8
  186. package/dashboard/dist-server/dashboard/src/server/routes/settings.js +3 -3
  187. package/dashboard/dist-server/dashboard/src/server/routes/settings.js.map +1 -1
  188. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  189. package/dist/src/agents/cli-agent-runner.js +13 -7
  190. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  191. package/dist/src/commands/spec.d.ts.map +1 -1
  192. package/dist/src/commands/spec.js +8 -1
  193. package/dist/src/commands/spec.js.map +1 -1
  194. package/dist/src/tools/spec-init.d.ts +16 -2
  195. package/dist/src/tools/spec-init.d.ts.map +1 -1
  196. package/dist/src/tools/spec-init.js +58 -187
  197. package/dist/src/tools/spec-init.js.map +1 -1
  198. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  199. package/dist/src/tools/spec-loader.js +16 -16
  200. package/dist/src/tools/spec-loader.js.map +1 -1
  201. package/dist/src/tools/spec-seeds.d.ts +33 -0
  202. package/dist/src/tools/spec-seeds.d.ts.map +1 -0
  203. package/dist/src/tools/spec-seeds.js +200 -0
  204. package/dist/src/tools/spec-seeds.js.map +1 -0
  205. package/dist/src/tools/spec-writer.d.ts.map +1 -1
  206. package/dist/src/tools/spec-writer.js +7 -9
  207. package/dist/src/tools/spec-writer.js.map +1 -1
  208. package/dist/src/utils/update-notices.js +12 -0
  209. package/dist/src/utils/update-notices.js.map +1 -1
  210. package/package.json +1 -1
  211. package/templates/business-test-report.json +1 -1
  212. package/templates/index.json +1 -1
  213. package/templates/roadmap.md +15 -9
  214. package/templates/state.json +18 -17
  215. package/workflows/agy-instructions.md +2 -0
  216. package/workflows/analyze.md +79 -11
  217. package/workflows/auto-test.md +12 -7
  218. package/workflows/blueprint.md +431 -0
  219. package/workflows/brainstorm.md +617 -496
  220. package/workflows/business-test.md +7 -7
  221. package/workflows/claude-instructions.md +2 -0
  222. package/workflows/codebase-rebuild.md +4 -4
  223. package/workflows/codex-instructions.md +16 -83
  224. package/workflows/debug.md +1 -1
  225. package/workflows/harvest.md +184 -10
  226. package/workflows/impeccable.md +2 -0
  227. package/workflows/init.md +9 -8
  228. package/workflows/issue-analyze.md +14 -100
  229. package/workflows/issue-discover.md +2 -3
  230. package/workflows/issue-execute.md +1 -1
  231. package/workflows/issue-gaps-analyze.md +2 -0
  232. package/workflows/learn.md +1 -1
  233. package/workflows/maestro-chain-execute.md +10 -228
  234. package/workflows/maestro.md +2 -1
  235. package/workflows/milestone-audit.md +12 -4
  236. package/workflows/milestone-complete.md +14 -9
  237. package/workflows/milestone-release.md +82 -0
  238. package/workflows/plan.md +91 -25
  239. package/workflows/retrospective.md +1 -1
  240. package/workflows/roadmap-common.md +1 -1
  241. package/workflows/roadmap.md +14 -4
  242. package/workflows/spec-generate.md +26 -13
  243. package/workflows/specs-add.md +6 -1
  244. package/workflows/specs-load.md +6 -1
  245. package/workflows/specs-setup.md +6 -1
  246. package/workflows/sync.md +13 -0
  247. package/workflows/tools-spec.md +4 -0
  248. package/workflows/ui-design.md +5 -5
  249. package/workflows/ui-style.md +1 -1
  250. package/workflows/wiki-manage.md +2 -0
  251. package/.agents/agents/conceptual-planning-agent.md +0 -247
  252. package/.agy/agents/conceptual-planning-agent.md +0 -244
  253. package/.claude/agents/conceptual-planning-agent.md +0 -245
@@ -19,12 +19,12 @@ Entry points:
19
19
  - **`/maestro-ralph continue`** — Resume via maestro-ralph-execute
20
20
  - **`/maestro-ralph status`** — Display session progress
21
21
 
22
- Initial decomposition (S_DECOMPOSE): broad intents (重构/全面/迁移/重写) are boundary-clarified via ≤3 questions, producing 执行准则 + 子目标清单 written into status.json, plus a `goal-checklist.md` (a rendered view of status.json) and a copy-paste `/goal` prompt for the user to bind.
22
+ Initial decomposition (S_DECOMPOSE): boundary-clarified via ≤3 questions for broad intents (重构/全面/迁移/重写). 写入 status.json `boundary_contract` / `execution_criteria` / `task_decomposition`,附 `/goal` prompt
23
23
 
24
- Three node types:
25
- - **internal**: `Skill()` call (synchronous, lightweight)
26
- - **external**: `maestro delegate --to claude` (context-isolated, heavy computation)
27
- - **decision**: Hand back to ralph for re-evaluation (adaptive branching)
24
+ Node types:
25
+ - **internal** (default): ralph-execute `view_file({command_path})` 命令 .md,按内容内联执行
26
+ - **decision**: ralph 评估
27
+ - **external**: 仅在显式声明时使用(`maestro delegate --to claude`)
28
28
 
29
29
  Key difference from maestro coordinator:
30
30
  - maestro: static chain → one-time selection → runs all steps
@@ -33,23 +33,19 @@ Key difference from maestro coordinator:
33
33
  Session: `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json`
34
34
  Mutual invocation with `/maestro-ralph-execute` forms a self-perpetuating work loop.
35
35
 
36
- ### 执行方式 / Execution Flow
36
+ ### Execution Flow
37
37
 
38
38
  ```
39
39
  /maestro-ralph "intent" ─▶ ralph infer → decompose → build chain
40
- writes status.json (truth)
41
- renders goal-checklist.md (view)
40
+ resolves command_path per step
41
+ writes status.json
42
42
  │ emits /goal prompt
43
43
 
44
- ralph-execute ◀─┐ runs next step:
45
- │ │ internal → Skill()
46
- │ │ external delegate (STOP→callback)
47
- │ │ decision Skill("maestro-ralph")
48
- └─────────┘ updates status.json + re-renders checklist
49
- loop until done | paused
44
+ ralph-execute ◀─┐ internal view_file(command_path) inline
45
+ │ │ decision → Skill("maestro-ralph")
46
+ └─────────┘ writes step.completion_confirmed
47
+ loop until all completion_confirmed | paused
50
48
  ```
51
-
52
- `status.json` 是唯一真源;checklist 是渲染视图。决策节点是链路生长点(`post-goal-audit` 插入按子目标的 mini-loop;`post-verify/review/test` 插入修复 loop)。评估只走 ralph,执行只走 ralph-execute,两者不互相替代。
53
49
  </purpose>
54
50
 
55
51
  <context>
@@ -72,10 +68,13 @@ Remaining → intent
72
68
  1. **Ralph never executes steps** — only creates sessions and evaluates decisions
73
69
  2. **Handoff via Skill("maestro-ralph-execute")** — at session creation and after decision evaluation
74
70
  3. **Decision delegates read-only** — `maestro delegate --role analyze --mode analysis`
75
- 4. **External CLI call** — external spawns full Claude Code session executing the skill command
76
- 5. **Delegate sessions non-interactive** all external skills MUST append `-y` to args inside the prompt
77
- 6. **Decomposition is outcome-oriented**sub-goals are deliverables/done-criteria, NEVER lifecycle-stage duplicates (analyze/plan/...). `/goal` binding is user-driven; ralph only emits the prompt
78
- 7. **task_decomposition drives DYNAMIC step growth, not a frozen plan** sub-goals are the convergence spec; `status.json.steps[]` remains the living chain. The `post-goal-audit` decision node re-checks the checklist and **dynamically inserts scoped execution steps** for every unmet sub-goal (same insert+reindex+retry mechanism as fix-loops). Decomposition never replaces ralph's adaptive branching — it feeds it. New fields are also additive/optional (absent → decomposition off, old behavior); never remove/rename existing fields
71
+ 4. **Default type = internal** — `external` 仅显式标注时出现,build 不默认生成
72
+ 5. **status.json 是唯一真源**不生成 markdown 清单或侧文件
73
+ 6. **每个 step 必须 `completion_confirmed: true`** 基于 `--- COMPLETION STATUS ---` `STATUS: DONE`;缺失则视为未完成
74
+ 7. **command_path A_BUILD_STEPS 解析**全局优先 `~/.claude/commands/{name}.md`,fallback 项目 `.claude/commands/{name}.md`,写入 status.json
75
+ 8. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 只发提示词
76
+ 9. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
77
+ 10. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
79
78
  </invariants>
80
79
 
81
80
  <state_machine>
@@ -84,9 +83,11 @@ Remaining → intent
84
83
  S_PARSE_ROUTE — 解析参数、路由入口 PERSIST: —
85
84
  S_STATUS — 显示 session 进度 PERSIST: —
86
85
  S_CONTINUE — 恢复执行 PERSIST: —
87
- S_RESOLVE_PHASE — 解析目标 phase + 标记 phase_is_new PERSIST: session.phase, session.phase_is_new
86
+ S_RESOLVE_PHASE — 解析 phase + phase_is_new + D-007 milestone PERSIST: session.phase, session.phase_is_new, session.milestone
88
87
  S_INFER — 基于已解析 phase 推断 lifecycle_position PERSIST: session.lifecycle_position
88
+ S_RESOLVE_SCOPE — 读 macro analyze conclusions.scope_verdict PERSIST: session.scope_verdict, session.analyze_macro_id
89
89
  S_QUALITY_MODE — 决定质量管线模式 PERSIST: session.quality_mode
90
+ S_PLANNING_MODE — 决定统一/独立规划模式 PERSIST: session.planning_mode
90
91
  S_DECOMPOSE — 边界澄清、写执行准则+子目标清单 PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
91
92
  S_BUILD_CHAIN — 构建步骤链 PERSIST: session.steps[]
92
93
  S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
@@ -119,17 +120,25 @@ S_RESOLVE_PHASE:
119
120
  GUARD: auto_confirm does NOT skip phase ambiguity
120
121
 
121
122
  S_INFER:
122
- S_QUALITY_MODE WHEN: position resolved DO: A_INFER_POSITION
123
+ S_RESOLVE_SCOPE WHEN: position resolved DO: A_INFER_POSITION
123
124
  → S_FALLBACK WHEN: cannot infer
124
125
 
126
+ S_RESOLVE_SCOPE:
127
+ → S_QUALITY_MODE DO: A_RESOLVE_SCOPE_VERDICT
128
+ GUARD: position ∈ {brainstorm, blueprint, init} → skip (scope_verdict = null)
129
+
125
130
  S_QUALITY_MODE:
126
- S_DECOMPOSE DO: A_DETERMINE_QUALITY_MODE
131
+ S_PLANNING_MODE DO: A_DETERMINE_QUALITY_MODE
132
+
133
+ S_PLANNING_MODE:
134
+ → S_DECOMPOSE DO: A_DETERMINE_PLANNING_MODE
135
+ GUARD: lifecycle_position ∈ {brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
127
136
 
128
137
  S_DECOMPOSE:
129
138
  → S_BUILD_CHAIN DO: A_DECOMPOSE_TASKS
130
- GUARD: broad intent (重构/全面/重写/迁移/overhaul/migrate/rewrite) → MUST clarify boundary even if auto_confirm
131
- GUARD: narrow intent (single file/function/bug) → auto-derive, skip questions
132
- GUARD: position ∈ {brainstorm, init} → skip decomposition (no concrete target yet)
139
+ GUARD: broad intent → MUST clarify boundary even if auto_confirm
140
+ GUARD: narrow intent → auto-derive, skip questions
141
+ GUARD: position ∈ {brainstorm, blueprint, init} → skip decomposition
133
142
 
134
143
  S_BUILD_CHAIN:
135
144
  → S_CREATE_SESSION DO: A_BUILD_STEPS
@@ -151,6 +160,8 @@ S_DECISION_EVAL:
151
160
  DO: A_DELEGATE_EVALUATE
152
161
  → S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
153
162
  DO: A_GOAL_AUDIT_EVALUATE
163
+ → S_APPLY_VERDICT WHEN: scope-gate (post-analyze-scope)
164
+ DO: A_SCOPE_EVALUATE
154
165
  → S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
155
166
  DO: A_STRUCTURAL_EVALUATE
156
167
 
@@ -158,10 +169,12 @@ S_APPLY_VERDICT:
158
169
  → S_DISPATCH WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
159
170
  → S_DISPATCH WHEN: post-goal-audit + unmet sub-goals DO: A_APPLY_GOAL_FIX
160
171
  → S_DISPATCH WHEN: post-goal-audit + all sub-goals met DO: A_APPLY_GOAL_DONE
172
+ → S_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
161
173
  → S_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
162
174
  → S_DISPATCH WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
163
- → S_DISPATCH WHEN: post-milestone + next milestone DO: A_ADVANCE_MILESTONE
164
- → END WHEN: post-milestone + no next milestone DO: mark completed
175
+ → S_DISPATCH WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
176
+ → END WHEN: post-milestone + standard + no next milestone DO: mark completed
177
+ → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
165
178
  → END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
166
179
  GUARD: retry_count >= max_retries → force escalate
167
180
  GUARD: confidence_score < 60 AND proceed → override to fix
@@ -181,41 +194,53 @@ S_FALLBACK:
181
194
 
182
195
  1. Find latest ralph session (by created_at)
183
196
  2. Display: Session, Status, Position, Progress, Current step
184
- 3. List steps: [✓] completed, [▸] current, [ ] pending, [◆] decision
185
- 4. If `task_decomposition` present (graceful skip if absent backward compat):
197
+ 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision;附 `command_scope`(global/project) + `command_path`
198
+ 4. If `task_decomposition` present (absent skip):
186
199
  ```
187
200
  Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
188
- [x] G1 done_when={done_when} evidence={evidence}
189
- [ ] G2 done_when={done_when} evidence={evidence} ◀ unmet
190
- ...
191
- Checklist view: {session_dir}/goal-checklist.md (regenerated from status.json)
201
+ [x] G1 done_when={done_when} evidence={evidence} confirmed={completion_confirmed}
202
+ [ ] G2 done_when={done_when} evidence={evidence} confirmed=false ◀ unmet
192
203
  ```
193
- Reads state directly from `status.json.task_decomposition[*].status` — checklist is just a view, status.json wins on conflict.
194
204
 
195
205
  ### A_RESOLVE_PHASE
196
206
 
197
- **前置于 A_INFER_POSITION**——position 推断需要先知道 target phase 是否在 state.json 中已存在。
207
+ 前置于 A_INFER_POSITION。产出 `phase` + `phase_is_new` + `milestone`(D-007 反查)三元组。
198
208
 
199
- **Priority (产出 `phase` + `phase_is_new` 二元组):**
209
+ **Priority:**
200
210
 
201
211
  | Step | 行为 | phase_is_new |
202
212
  |------|------|--------------|
203
- | 1 | intent 匹配 `phase\s*(\d+)` 正则 → 取 state.json 中对应 phase | false |
204
- | 2 | intent 派生短语(如 "docs-site-redesign", "auth-refactor")→ 在 state.json.milestones[*].phases / artifacts[*].path 中查找 | false (匹配) / true (无匹配) |
213
+ | 1 | intent 匹配 `phase\s*(\d+)` → 取 state.json 对应 phase | false |
214
+ | 2 | intent 派生短语 `state.json.milestones[*].phase_slugs` / `artifacts[*].path` 查找 | false (匹配) / true (无匹配) |
205
215
  | 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
206
216
  | 4 | 仍无 → state.json 首个 incomplete phase | false |
207
- | 5 | position 将是 brainstorm/init/roadmap → phase = null | n/a |
208
- | 6 | 仍模糊 → `ask_question`(新 phase / 已存在 phase 二选一) | 由用户回答确定 |
217
+ | 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
218
+ | 6 | 仍模糊 → `ask_question` | 由用户回答确定 |
219
+
220
+ **D-007 Phase→Milestone 反查**(数字 phase 已解析时):
221
+ ```
222
+ resolve_milestone(phase_number):
223
+ for ms in state.json.milestones:
224
+ if str(phase_number) in ms.phase_slugs: return ms.id
225
+ return state.json.current_milestone # fallback
226
+ ```
227
+ 写入 `session.milestone`;禁止直接使用 `current_milestone` 当做 phase 所属 milestone。
209
228
 
210
- **写入 session**: `phase`(字符串或 null)+ `phase_is_new`(bool)。`phase_is_new=true` 表示当前 milestone 下需要为这个 phase 创建全套生命周期(A_INFER_POSITION 据此强制起始位置)。
229
+ **写入 session**: `phase`, `phase_is_new`, `milestone`。
211
230
 
212
231
  **新派生 phase 时 milestone 处理**:
213
- - state.json 当前 milestone 仍 active → 沿用当前 milestone,仅新增 phase
214
- - intent 同时派生了新 milestone 名(如 "M1-visual-replication")→ 写入 session 但**仅作标签**;state.json.milestones 由后续 `maestro-roadmap` / `maestro-milestone-release` 真实创建。session 层面禁止虚构 milestone 直接改 state.json
232
+ - state.json 当前 milestone 仍 active → 沿用,新增 phase
233
+ - intent 派生新 milestone 写入 session 仅作标签;`state.json.milestones` `maestro-roadmap` / `maestro-milestone-release` 创建
215
234
 
216
235
  ### A_INFER_POSITION
217
236
 
218
- **Intent-based override:** brainstorm/头脑风暴/探索/ideate/设计思路 → position = `brainstorm`
237
+ **Intent-based overrides** (按顺序匹配,先命中先用):
238
+
239
+ | Pattern | Position |
240
+ |---------|----------|
241
+ | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
242
+ | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
243
+ | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
219
244
 
220
245
  **Bootstrap detection:**
221
246
 
@@ -230,16 +255,32 @@ S_FALLBACK:
230
255
 
231
256
  | Condition | Position |
232
257
  |-----------|----------|
233
- | `phase_is_new == true` (intent 派生的新 phase, state.json 中无) | **`analyze`** (强制从头起) |
234
- | no milestones or no roadmap.md | `roadmap` |
235
- | `phase == null` (brainstorm/init/roadmap 已由 override 决定) | n/a |
258
+ | `phase_is_new == true` ( phase) | `analyze` |
259
+ | no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` |
260
+ | no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
261
+ | `phase == null` (brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
236
262
  | phase 已存在 + 无任何 artifact | `analyze` |
237
263
  | phase 已存在 + 最新 artifact = analyze | `plan` |
238
264
  | phase 已存在 + 最新 artifact = plan | `execute` |
239
265
  | phase 已存在 + 最新 artifact = execute | `verify` |
240
266
  | phase 已存在 + 最新 artifact = verify | → refine from result files |
241
267
 
242
- **关键不变量**:artifact 过滤必须用 `session.phase`(A_RESOLVE_PHASE 已写入),而不是 state.json.current_phase。当 `phase_is_new` 时跳过过滤直接走 `analyze`,避免错用其他 phase 的 artifact 推断。
268
+ **关键不变量**:artifact 过滤按 `session.phase`,不读 `state.json.current_phase`。`phase_is_new` 直接 `analyze`。
269
+
270
+ ### A_RESOLVE_SCOPE_VERDICT
271
+
272
+ 仅当 `lifecycle_position ∈ {analyze-macro, roadmap, plan}` 且存在最新 analyze artifact 时执行。
273
+
274
+ 1. 定位最新 macro analyze artifact(`type=="analyze"` 且 `scope=="macro"`,按 created_at DESC)→ 记 `session.analyze_macro_id = ANL-xxx`
275
+ 2. 读 `{artifact_path}/conclusions.json` 的 `scope_verdict` 字段(`large | medium | small`)
276
+ 3. 写入 `session.scope_verdict`;缺失时设 `unknown`
277
+ 4. 路由建议(A_BUILD_STEPS 据此决定是否插入 roadmap、plan 是否走 `--from`):
278
+
279
+ | scope_verdict | 链路 |
280
+ |---------------|------|
281
+ | `large` | analyze-macro → roadmap → analyze → plan → execute → ... |
282
+ | `medium` / `small` | analyze-macro → plan --from analyze:{ANL_ID} → execute → ...(跳过 roadmap + analyze-phase) |
283
+ | `unknown` | 默认走 large 路径,post-analyze-scope 决策节点再纠正 |
243
284
 
244
285
  **Refine from verify results:**
245
286
 
@@ -264,9 +305,37 @@ S_FALLBACK:
264
305
 
265
306
  写入 `session.quality_mode`。A_BUILD_STEPS 据此过滤 stage(见下)。
266
307
 
308
+ ### A_DETERMINE_PLANNING_MODE
309
+
310
+ 决定里程碑的规划粒度:一次性规划整个里程碑(统一)还是逐 phase 走完整生命周期(独立)。
311
+
312
+ **Auto-resolve rules (按优先级):**
313
+
314
+ | Condition | Mode | Reason |
315
+ |-----------|------|--------|
316
+ | lifecycle_position ∈ {brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
317
+ | `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
318
+ | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
319
+ | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
320
+ | milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
321
+ | milestone 含多个 phase + 非 `auto_confirm` | → ask_question | 征询用户选择 |
322
+
323
+ **ask_question** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
324
+
325
+ ```
326
+ question: "当前里程碑含 {N} 个 phase,选择规划模式?"
327
+ options:
328
+ - label: "统一规划 (Recommended)"
329
+ description: "一次性分析+规划整个里程碑所有 phase,analyze/plan 走里程碑级,适合 phase 间关联紧密"
330
+ - label: "独立规划"
331
+ description: "逐个 phase 走完整生命周期(analyze→plan→execute→verify→...),适合 phase 间独立性高"
332
+ ```
333
+
334
+ 写入 `session.planning_mode`(`"unified"` 或 `"independent"`)。`A_BUILD_STEPS` 据此决定 skill args 是否携带 `{phase}` 占位符。
335
+
267
336
  ### A_DECOMPOSE_TASKS
268
337
 
269
- Build the boundary contract + outcome sub-goal checklist that `/goal` will track. Runs once at session creation, before chain build. All output is **additive** to status.json.
338
+ Runs once before chain build; additive to status.json.
270
339
 
271
340
  **1. Classify intent breadth:**
272
341
 
@@ -286,7 +355,7 @@ Build the boundary contract + outcome sub-goal checklist that `/goal` will track
286
355
 
287
356
  narrow → derive defaults from intent + codebase, skip questions.
288
357
 
289
- **3. Derive `execution_criteria`** (执行准则 — 3-6 short imperative rules every step obeys): backward-compat stance, scope-freeze ("只改请求范围"), test/coverage bar, fix-don't-hide, incremental commit. Each verify/review/test gate later checks against these.
358
+ **3. Derive `execution_criteria`**: backward-compatscope-freezetest/coverage barfix-don't-hideincremental commit
290
359
 
291
360
  **4. Derive `task_decomposition`** (子目标清单 — outcome-oriented, NOT lifecycle stages). Each entry:
292
361
  ```json
@@ -295,60 +364,70 @@ narrow → derive defaults from intent + codebase, skip questions.
295
364
  "evidence": "verification.json|review.json|uat.md|<test path>",
296
365
  "lifecycle": ["analyze","execute","verify"], "status": "pending" }
297
366
  ```
298
- **Cleverness rule**: `done_when` MUST be objectively verifiable and SHOULD reference an artifact ralph already produces, so the `/goal` Stop hook can re-verify after context compaction. Map each sub-goal to the lifecycle phase(s) that will produce its evidence this is how the checklist "adapts to ralph": the existing pipeline becomes the machinery that satisfies the goals.
367
+ `done_when` 必须客观可验证,且引用 ralph 已产出的 artifact;`lifecycle` 字段映射到产出 evidence 的生命周期 stage。
299
368
 
300
- **5. Persist** (additive) into session for A_CREATE_SESSION to write: `boundary_contract`, `execution_criteria`, `task_decomposition`. Absent feature (skipped) write none; downstream treats as "decomposition off".
369
+ **5. Persist** (additive): `boundary_contract`, `execution_criteria`, `task_decomposition`。每个 sub-goal `status: "pending"` + `completion_confirmed: false`。
301
370
 
302
- **6. Stage** the Goal Checklist + Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
371
+ **6. Stage** the Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
303
372
 
304
373
  ### A_BUILD_STEPS
305
374
 
306
- Generate steps from `session.lifecycle_position` to `milestone-complete`(终点硬约束)。
307
-
308
- | Stage | Skill | Type | Decision after | quality_mode |
309
- |-------|-------|------|----------------|--------------|
310
- | brainstorm | `maestro-brainstorm "{intent}"` | external | — | all |
311
- | init | `maestro-init` | internal | — | all |
312
- | roadmap | `maestro-roadmap "{intent}"` | internal | — | all |
313
- | analyze | `maestro-analyze {phase}` | external | | all |
314
- | plan | `maestro-plan {phase}` | internal | — | all |
315
- | execute | `maestro-execute {phase}` | external | — | all |
316
- | verify | `maestro-verify {phase}` | internal | `post-verify` | all |
317
- | business-test | `quality-auto-test {phase}` | internal | `post-business-test` | **full only** |
318
- | review | `quality-review {phase}` | internal | `post-review` | all (quick: append `--tier quick`) |
319
- | test-gen | `quality-auto-test {phase}` | internal | | full / standard if coverage<80% |
320
- | test | `quality-test {phase}` | internal | `post-test` | full, standard |
321
- | milestone-audit | `maestro-milestone-audit` | internal | — | all |
322
- | goal-audit | *(decision-only, no skill)* | decision | `post-goal-audit` | all (only if decomposed) |
323
- | milestone-complete | `maestro-milestone-complete` | internal | `post-milestone` | all (chain 终点) |
324
-
325
- Type rationale: `internal` = Skill(), lightweight/interactive; `external` = delegate --to claude, context-isolated heavy computation
375
+ Generate steps from `session.lifecycle_position` to `milestone-complete`.
376
+
377
+ | Stage | Skill (independent) | Skill (unified) | Type | Decision after | quality_mode |
378
+ |-------|---------------------|-----------------|------|----------------|--------------|
379
+ | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | internal | — | all |
380
+ | blueprint | `maestro-blueprint "{intent}"` | *(same)* | internal | — | all |
381
+ | init | `maestro-init` | *(same)* | internal | — | all |
382
+ | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | internal | `post-analyze-scope` | all |
383
+ | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | internal | — | all |
384
+ | analyze | `maestro-analyze {phase}` | `maestro-analyze` | internal | — | all |
385
+ | 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` | internal | — | all |
386
+ | execute | `maestro-execute {phase}` | `maestro-execute` | internal | | all |
387
+ | verify | `maestro-verify {phase}` | `maestro-verify` | internal | `post-verify` | all |
388
+ | business-test | `quality-auto-test {phase}` | `quality-auto-test` | internal | `post-business-test` | full only |
389
+ | review | `quality-review {phase}` | `quality-review` | internal | `post-review` | all (quick: append `--tier quick`) |
390
+ | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | internal | — | full / standard if coverage<80% |
391
+ | test | `quality-test {phase}` | `quality-test` | internal | `post-test` | full, standard |
392
+ | milestone-audit | `maestro-milestone-audit` | *(same)* | internal | | all |
393
+ | goal-audit | *(decision-only)* | *(same)* | decision | `post-goal-audit` | all (only if decomposed) |
394
+ | milestone-complete | `maestro-milestone-complete` | *(same)* | internal | `post-milestone` | all |
326
395
 
327
396
  **Build rules (按顺序应用):**
328
397
 
329
- 1. **起点**:从 `session.lifecycle_position` 开始;不读 `state.json.current_phase`
330
- 2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(artifact 过滤同样按 `session.phase`,不按 state.json 当前 phase)
331
- 3. **quality_mode 过滤**:按 `session.quality_mode` 排除上表 `quality_mode` 列不包含该模式的 stage(如 standard 不跑 business-test、quick 不跑 test-gen/test)
398
+ 0. **planning_mode 选列**:`unified` → Skill (unified) 列;`independent` Skill (independent) 列
399
+ 1. **起点**:从 `session.lifecycle_position` 开始
400
+ 2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact stage(按 `session.phase` 过滤);unified milestone 过滤
401
+ 3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
332
402
  4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ type: "decision", decision: "<gate>", retry_count: 0, max_retries: 2 }`
333
- 5. **goal-audit 插入**:当且仅当 `task_decomposition` 存在 → 在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
334
- 6. **终点硬约束**:chain 必须以 `milestone-complete` 步骤结尾(除非 `lifecycle_position` 已是 `milestone-complete` 之后的状态)。生成器在收尾时不论 quality_mode 都必须 append 该 step
335
- 7. **初始 goal_ref 传播**:若 `task_decomposition` 存在,遍历每个新建 step
336
- - 计算 `step.stage`(如 execute/verify/review)
337
- - 对每个 `g ∈ task_decomposition`:若 `step.stage g.lifecycle` `step.goal_ref = g.id`
338
- - 多 G 匹配 → id 字典序最小者;保证 verify/review 等共用 lifecycle 的 step 也有可追溯标签
339
- - decision 节点不打 goal_ref(goal-audit 自身除外,它的 verdict 直接修改 task_decomposition)
340
- 8. **占位符**:args 用 `{phase}` `{intent}` 等,由 ralph-execute 在执行时解析
341
- 9. **动态插入**:`post-goal-audit` 触发 A_APPLY_GOAL_FIX 时插入的步骤同样按规则 7 `goal_ref`(追溯到触发它的子目标 G{n})
403
+ 5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
404
+ 6. **终点硬约束**:chain `milestone-complete` 结尾
405
+ 7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
406
+ 8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
407
+ 9. **command_path 解析**(每个非 decision step):
408
+ - 取 skill 名(args 前的第一个 token)
409
+ - 全局优先:`~/.claude/commands/{name}.md` 存在 `command_scope = "global"`
410
+ - Fallback:`.claude/commands/{name}.md` 存在 → `command_scope = "project"`
411
+ - 两者都缺 `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
412
+ 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`
413
+ 11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
414
+ - `scope_verdict ∈ {medium, small}` → 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
415
+ - `scope_verdict == large` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
416
+ - `scope_verdict == unknown` → 默认 large 路径;由 `post-analyze-scope` 决策节点在 macro analyze 完成后纠正(A_APPLY_SCOPE_VERDICT)
417
+ 12. **--from 自动注入**:
418
+ - `analyze_macro_id` 存在且当前 step 是 `roadmap` → args 改为 `--from analyze:{analyze_macro_id}`
419
+ - `analyze_macro_id` 存在且 `scope_verdict ∈ {medium, small}` 且当前 step 是 `plan` → args 改为 `--from analyze:{analyze_macro_id}`
420
+ - `blueprint_id` 存在 → 当前 step 是 `plan` → args 改为 `--from blueprint:{blueprint_id}`(优先级低于 phase 数字参数)
421
+ - 写入 `step.source_artifact_ref` 以便审计
422
+ 13. **D-007 Milestone-ref 标注**:每个含 `{phase}` 占位符的 step → `step.milestone_id = session.milestone`(由 A_RESOLVE_PHASE 反查得出),禁止读 `current_milestone`
423
+ 14. **动态插入步骤**(A_APPLY_*)同样应用规则 7-13
342
424
 
343
425
  ### A_CREATE_SESSION
344
426
 
345
- 1. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema) decomposition fields included only if produced (additive)
346
- 2. If `task_decomposition` present:
347
- - Set `session.goal_checklist_path = "{session_dir}/goal-checklist.md"` in status.json
348
- - **Render** checklist from status.json (Appendix: Goal Checklist Template + Sync Rule). This is a one-way projection — status.json drives content; the file is never hand-edited
349
- - Stable filename within session (so `/goal` condition string survives context compaction)
350
- 3. Display chain overview with step list
351
- 4. If `task_decomposition` present: display the **Goal Prompt block** (Appendix: Goal Prompt Template) — the copy-paste `/goal …` line binds status.json + checklist as a Stop-hook target
427
+ 1. Validate: 所有 step `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
428
+ 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
429
+ 3. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
430
+ 4. If `task_decomposition` present: display the **Goal Prompt block** (Appendix: Goal Prompt Template)
352
431
 
353
432
  ### A_DELEGATE_EVALUATE
354
433
 
@@ -382,45 +461,64 @@ Type rationale: `internal` = Skill(), lightweight/interactive; `external` = dele
382
461
 
383
462
  ### A_STRUCTURAL_EVALUATE
384
463
 
385
- **post-milestone:** Read state.json → next milestone? → insert lifecycle steps / complete
464
+ **post-milestone:**
465
+ 1. Read state.json → resolve completed milestone object
466
+ 2. Determine milestone type: `milestone_obj.type` (default `"standard"` if missing)
467
+ 3. **Standard milestone** (`type != "adhoc"`): next milestone exists? → insert lifecycle steps / complete
468
+ 4. **Adhoc milestone** (`type == "adhoc"`): always END — adhoc milestones are self-contained, no successor to advance to. Set `current_milestone = null`.
469
+
386
470
  **post-debug-escalate:** Always STOP → set paused, display "请人工介入"
387
471
 
472
+ ### A_SCOPE_EVALUATE
473
+
474
+ 仅由 `post-analyze-scope` 决策节点触发;macro analyze 完成后读 `conclusions.json.scope_verdict` 决定下游链路。
475
+
476
+ 1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path = {artifact_path}/conclusions.json`
477
+ 2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
478
+ 3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
479
+ 4. Append `{session_dir}/decisions.ndjson`:
480
+ ```json
481
+ { "id": "DEC-{timestamp}", "type": "scope-gate",
482
+ "source": "ralph", "node_id": "post-analyze-scope",
483
+ "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }
484
+ ```
485
+ 5. → A_APPLY_SCOPE_VERDICT
486
+
388
487
  ### A_GOAL_AUDIT_EVALUATE
389
488
 
390
- Re-checks sub-goals against `status.json` (source of truth) and decides whether `steps[]` must dynamically grow. Only runs when `task_decomposition` present.
489
+ Runs only when `task_decomposition` present.
391
490
 
392
- 1. Read `session.task_decomposition` from status.json (NOT from checklist — checklist is just a view)
393
- 2. For each sub-goal `status != "done"`: resolve its `evidence` artifact (verification.json / review.json / uat.md / test path) under the current phase scratch dir
491
+ 1. Read `session.task_decomposition` from status.json
492
+ 2. For each sub-goal `status != "done"`: resolve `evidence` artifact under current phase scratch dir
394
493
  3. Delegate read-only audit (run_in_background, STOP, wait):
395
494
  ```
396
- maestro delegate "PURPOSE: 审计未完成子目标,判定哪些已达成、哪些仍需补步骤
495
+ maestro delegate "PURPOSE: 审计未完成子目标,判定 met / unmet
397
496
  TASK:
398
- 1. 读取 status.json.task_decomposition 中每个 status!=done 的子目标
399
- 2. 打开其 evidence 产物,对照 done_when 严格判定
400
- 3. 输出 met / unmet 分类,unmet 给出差距 + 应回补的 target_phase
497
+ 1. 读取 status.json.task_decomposition status!=done 的子目标
498
+ 2. 打开 evidence 产物,对照 done_when 严格判定
499
+ 3. 输出 met / unmetunmet 给出 gap + target_phase
401
500
  CONTEXT:
402
501
  status.json = {session_dir}/status.json
403
- checklist = {goal_checklist_path} (人类可读视图,仅供参考)
404
502
  evidence = {evidence artifacts}
405
- 执行准则 = {execution_criteria}
406
- 边界契约 = {boundary_contract}
407
- EXPECTED (单行 verdict 块,严格遵循):
503
+ execution_criteria = {execution_criteria}
504
+ boundary_contract = {boundary_contract}
505
+ EXPECTED:
408
506
  ---VERDICT---
409
507
  STATUS=all_met|has_unmet
410
- UNMET=[{id:G2,gap:'...',target_phase:execute}, ...] # 空数组当 STATUS=all_met
508
+ UNMET=[{id:G2,gap:'...',target_phase:execute}, ...]
411
509
  CONFIDENCE_SCORE=0-100
412
510
  ---END---
413
511
  CONSTRAINTS:
414
- - 只评估,不修改任何文件
415
- - 严格按 done_when 判定;evidence 缺失 → 视为 unmet
512
+ - 只评估,不修改文件
513
+ - 严格按 done_when 判定;evidence 缺失 → unmet
416
514
  - 不得建议超出 boundary_contract 的修改
417
515
  "
418
516
  --role analyze --mode analysis
419
517
  ```
420
- 4. On callback: parse UNMET list. **status.json is the write target** — for each met sub-goal: `task_decomposition[i].status="done"` + `task_decomposition[i].completed_at=now`. Then regenerate checklist view from status.json (see Sync Rule in Appendix).
421
- 5. **Decision log**: append to `{session_dir}/decisions.ndjson` with `"type": "goal-gate"`, `unmet_count`, `unmet_ids`
518
+ 4. On callback: 对每个 met 子目标,set `task_decomposition[i].status="done"` + `completion_confirmed=true` + `completed_at=now`
519
+ 5. Append `{session_dir}/decisions.ndjson` with `"type": "goal-gate"`, `unmet_count`, `unmet_ids`
422
520
  6. Verdict: `all_met` → A_APPLY_GOAL_DONE; `has_unmet` → A_APPLY_GOAL_FIX
423
- GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE (insert quality-debug, hand to human)
521
+ GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
424
522
 
425
523
  ### A_APPLY_PROCEED
426
524
 
@@ -438,22 +536,33 @@ Re-checks sub-goals against `status.json` (source of truth) and decides whether
438
536
  1. Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]`
439
537
  2. Increment retry_count, reindex, write status.json
440
538
 
441
- ### A_APPLY_GOAL_FIX
539
+ ### A_APPLY_SCOPE_VERDICT
442
540
 
443
- **This is the dynamic step-growth core.** For every unmet sub-goal, inject scoped execution steps so `steps[]` grows toward convergence:
541
+ `post-analyze-scope` 触发,依据 `session.scope_verdict` 重塑下游链路。
444
542
 
445
- 1. For each `unmet` sub-goal `G{n}` (grouped by `target_phase` to avoid duplicate runs):
446
- insert before the `goal-audit` node a scoped mini-loop (see Appendix: Fix-Loop Templates → post-goal-audit), each inserted step tagged `goal_ref: "G{n}"`
447
- 2. Re-append a fresh `decision:post-goal-audit {retry+1}` after the inserted steps (re-loops until all met or max retries)
448
- 3. Reindex steps, increment retry_count, write status.json (steps[] now larger — the JSON "grew")
449
- 4. Display: Goal audit: {k} sub-goals unmet → +{N} steps inserted (G{ids}), retry {r}/{max}
543
+ 1. `session.scope_verdict`
544
+ 2. 路径 A(`large`):保持当前链;为后续 `roadmap` step 注入 `--from analyze:{analyze_macro_id}`;为后续 `plan` step phase 列;继续推进
545
+ 3. 路径 B(`medium` / `small`):
546
+ - 删除 `goal-audit` 之前所有未完成的 `roadmap` + `analyze` (phase) step
547
+ - 把下一个未完成的 `plan` step 改为 `maestro-plan --from analyze:{analyze_macro_id}`,去掉 `{phase}`,`source_artifact_ref = analyze:{analyze_macro_id}`
548
+ - 后续 `execute` / `verify` 等沿用同一 standalone scope(不带 `{phase}`,由 plan 写出的 task 列表驱动)
549
+ 4. 路径 C(`unknown`):
550
+ - 非 auto_confirm → ask_question 二选一(large / medium-small);auto_confirm → 默认 large
551
+ 5. Reindex steps,标 decision completed,write status.json
552
+ 6. Display: ◆ Scope verdict: {verdict} → {kept|collapsed to standalone via analyze:{ANL_ID}}
553
+
554
+ ### A_APPLY_GOAL_FIX
555
+
556
+ 1. 对每个 unmet 子目标 `G{n}`(按 `target_phase` 分组去重):在 `goal-audit` 节点前插入 scoped mini-loop(见 Appendix: Fix-Loop Templates → post-goal-audit),每条插入 step `goal_ref: "G{n}"`,按 A_BUILD_STEPS 规则 9 解析 `command_path`
557
+ 2. 重新追加 `decision:post-goal-audit {retry+1}`
558
+ 3. Reindex steps, increment retry_count, write status.json
559
+ 4. Display: ◆ Goal audit: {k} unmet → +{N} steps inserted (G{ids}), retry {r}/{max}
450
560
 
451
561
  ### A_APPLY_GOAL_DONE
452
562
 
453
- 1. Write status.json (source of truth): set every `task_decomposition[*].status="done"`, `completed_at=now`, plus top-level `task_decomposition_all_done=true`
454
- 2. Regenerate `goal-checklist.md` from status.json (Sync Rule in Appendix) — all boxes flip to `[x]`, sentinel `ALL_GOALS_DONE` appended at file end
455
- 3. Mark goal-audit decision completed; proceed to `milestone-complete`
456
- 4. Display: ◆ Goal audit: 全部子目标达成 ✓ — status.json + checklist 已同步 ALL_GOALS_DONE
563
+ 1. status.json: set 每个 `task_decomposition[*].status="done"`, `completion_confirmed=true`, `completed_at=now`,顶层 `task_decomposition_all_done=true`
564
+ 2. Mark goal-audit decision completed;proceed to `milestone-complete`
565
+ 3. Display: Goal audit: all met
457
566
 
458
567
  ### A_ADVANCE_MILESTONE
459
568
 
@@ -480,18 +589,38 @@ Re-checks sub-goals against `status.json` (source of truth) and decides whether
480
589
  "session_id": "ralph-{YYYYMMDD-HHmmss}",
481
590
  "source": "ralph", "status": "running",
482
591
  "intent": "", "lifecycle_position": "",
483
- "phase": null, "phase_is_new": false, "milestone": "",
592
+ "phase": null, "phase_is_new": false,
593
+ "milestone": "", // D-007 反查结果,禁止读 current_milestone
484
594
  "auto_mode": false,
485
- "quality_mode": "standard", // "full" | "standard" | "quick" — 由 A_DETERMINE_QUALITY_MODE 写入
595
+ "quality_mode": "standard", // "full" | "standard" | "quick"
596
+ "planning_mode": "independent", // "unified" | "independent"
597
+ "scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
598
+ "analyze_macro_id": null, // "ANL-xxx" 来自最新 macro analyze
599
+ "blueprint_id": null, // "BLP-xxx" 若存在
486
600
  "cli_tool": "claude", "passed_gates": [],
487
601
  "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
488
- "analysis_dir": null, "brainstorm_dir": null },
489
- "steps": [{ "index": 0, "type": "internal|external|decision",
490
- "skill": "", "args": "", "status": "pending",
491
- "goal_ref": null }],
602
+ "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
603
+ "steps": [{
604
+ "index": 0,
605
+ "type": "internal|external|decision",
606
+ "skill": "",
607
+ "args": "",
608
+ "stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|verify|...
609
+ "scope": null, // "phase"|"standalone"|"milestone"|null(plan 等需要)
610
+ "command_scope": "global|project|missing|null",
611
+ "command_path": "~/.claude/commands/{name}.md | .claude/commands/{name}.md | null",
612
+ "milestone_id": null, // D-007 反查注入;仅含 {phase} 占位符的 step 有
613
+ "source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
614
+ "status": "pending|running|completed|skipped|failed",
615
+ "goal_ref": null,
616
+ "completion_confirmed": false,
617
+ "completion_status": null,
618
+ "completion_evidence": null,
619
+ "completed_at": null
620
+ }],
492
621
  "waves": [], "current_step": 0,
493
622
 
494
- "_comment": "↓ OPTIONAL additive decomposition block (v0.4.8+). Absentno decomposition; readers MUST tolerate missing keys. Never remove/rename above fields.",
623
+ // Optional decomposition block (additive; absent → decomposition off)
495
624
  "boundary_contract": {
496
625
  "in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
497
626
  },
@@ -499,25 +628,23 @@ Re-checks sub-goals against `status.json` (source of truth) and decides whether
499
628
  "task_decomposition": [
500
629
  { "id": "G1", "goal": "", "boundary": "", "done_when": "",
501
630
  "evidence": "", "lifecycle": [], "status": "pending|done",
502
- "completed_at": null }
631
+ "completion_confirmed": false, "completed_at": null }
503
632
  ],
504
- "task_decomposition_all_done": false,
505
- "goal_checklist_path": "",
506
- "goal_checklist_synced_at": null
633
+ "task_decomposition_all_done": false
507
634
  }
508
635
  ```
509
636
 
510
- **扩展约定**:
511
- - Schema 加字段 = 可选(缺省 = 旧行为);不删/不改既有字段名。
512
- - `steps[]` 是活数组:`post-goal-audit` 与 `post-verify/review/test` 等决策节点按需追加+重排,子目标收敛即停。`goal_ref`(可选)回溯每条动态插入步骤所属子目标。
637
+ 新增字段可选,缺省=旧行为;既有字段名不删不改。
513
638
 
514
639
  ### Fix-Loop Templates
515
640
 
641
+ 所有插入 step 默认 `type: "internal"`,按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`。
642
+
516
643
  **post-verify:**
517
644
  ```
518
645
  quality-debug "{gap_summary}"
519
646
  maestro-plan --gaps {phase}
520
- maestro-execute {phase} [external]
647
+ maestro-execute {phase}
521
648
  maestro-verify {phase}
522
649
  decision:post-verify {retry+1}
523
650
  ```
@@ -526,7 +653,7 @@ decision:post-verify {retry+1}
526
653
  ```
527
654
  quality-debug --from-business-test "{gap_summary}"
528
655
  maestro-plan --gaps {phase}
529
- maestro-execute {phase} [external]
656
+ maestro-execute {phase}
530
657
  maestro-verify {phase}
531
658
  decision:post-verify {retry: 0}
532
659
  quality-auto-test {phase}
@@ -537,7 +664,7 @@ decision:post-business-test {retry+1}
537
664
  ```
538
665
  quality-debug "{gap_summary}"
539
666
  maestro-plan --gaps {phase}
540
- maestro-execute {phase} [external]
667
+ maestro-execute {phase}
541
668
  quality-review {phase}
542
669
  decision:post-review {retry+1}
543
670
  ```
@@ -546,7 +673,7 @@ decision:post-review {retry+1}
546
673
  ```
547
674
  quality-debug --from-uat "{gap_summary}"
548
675
  maestro-plan --gaps {phase}
549
- maestro-execute {phase} [external]
676
+ maestro-execute {phase}
550
677
  maestro-verify {phase}
551
678
  decision:post-verify {retry: 0}
552
679
  quality-auto-test {phase}
@@ -558,73 +685,15 @@ quality-test {phase}
558
685
  decision:post-test {retry+1}
559
686
  ```
560
687
 
561
- **post-goal-audit:** (per unmet sub-goal group — this is what dynamically grows `steps[]`)
688
+ **post-goal-audit:** (per unmet sub-goal group)
562
689
  ```
563
- # for each unmet sub-goal G{n}, scoped to its target_phase:
690
+ # for each unmet sub-goal G{n}, scoped to target_phase:
564
691
  maestro-plan --gaps {target_phase} "G{n}: {gap}" [goal_ref: G{n}]
565
- maestro-execute {target_phase} [external] [goal_ref: G{n}]
566
- maestro-verify {target_phase} [goal_ref: G{n}]
567
- # after all unmet groups inserted, re-loop the audit:
692
+ maestro-execute {target_phase} [goal_ref: G{n}]
693
+ maestro-verify {target_phase} [goal_ref: G{n}]
694
+ # after all unmet groups inserted:
568
695
  decision:post-goal-audit {retry+1}
569
696
  ```
570
- Notes: only unmet sub-goals' phases are re-run (no full-pipeline replay); inserted steps carry `goal_ref` for traceability; loop exits when audit returns `all_met` (→ A_APPLY_GOAL_DONE) or retry hits max (→ escalate to human). This keeps growth bounded.
571
-
572
- ### Goal Checklist Template (status.json projection)
573
-
574
- `{session_dir}/goal-checklist.md` 是 `status.json` 的只读投影:不要手改,永远从 JSON 重渲染。文件名在 session 内稳定,`/goal` 条件字符串跨上下文压缩仍可用。
575
-
576
- ```markdown
577
- # Ralph Goal Checklist — {session_id}
578
- <!-- AUTO-GENERATED from status.json. Source: ../status.json#/task_decomposition -->
579
-
580
- > Intent : {intent}
581
- > Source : `{session_dir}/status.json` (authoritative)
582
- > Last sync : {ISO} Phase: {phase} Milestone: {milestone}
583
-
584
- ## Resume / 恢复入口
585
- **不要直接执行 skill,调用入口:**
586
- ```
587
- /maestro-ralph continue
588
- ```
589
- ralph 评估下一步门控,ralph-execute 跑实际步骤。Stop hook 触发时也走这条路径。
590
-
591
- ## 执行准则 / Execution Criteria
592
- <!-- status.json#/execution_criteria -->
593
- - {criterion 1}
594
- - {criterion 2}
595
-
596
- ## 边界契约 / Boundary Contract
597
- <!-- status.json#/boundary_contract -->
598
- - In scope : {in_scope}
599
- - Out of scope : {out_of_scope}
600
- - Constraints : {constraints}
601
- - Definition of Done : {definition_of_done}
602
-
603
- ## 子目标 / Sub-goals ({done}/{total})
604
- <!-- status.json#/task_decomposition -->
605
- - [ ] G1 — {goal}
606
- done_when : {done_when}
607
- evidence : {evidence}
608
- lifecycle : {lifecycle}
609
- <!-- ref: status.json#/task_decomposition/0 status=pending -->
610
- - [x] G2 — {goal}
611
- done_when : {done_when}
612
- evidence : {evidence}
613
- <!-- ref: status.json#/task_decomposition/1 status=done completed_at={ISO} -->
614
- - [ ] G3 — ...
615
-
616
- <!-- A_APPLY_GOAL_DONE 在全部 status=done 时在文件末尾追加 ALL_GOALS_DONE -->
617
- ```
618
-
619
- ### Sync Rule (status.json ↔ goal-checklist.md)
620
-
621
- 单向投影;status.json 为真源;冲突时直接重渲染,不合并。
622
-
623
- 1. 只有 ralph / ralph-execute 写 `task_decomposition[*].status`;markdown 不可写入状态。
624
- 2. `task_decomposition` / `execution_criteria` / `boundary_contract` 任一变化 → 立即重渲染 checklist。
625
- 3. 全部 `status="done"` → 在文件末追加 `ALL_GOALS_DONE` 哨兵行。
626
- 4. 检测到 checklist 缺失或与 JSON 漂移 → 直接重渲染覆盖;视 markdown 为可丢弃产物。
627
- 5. ralph-execute(可选、向后兼容):完成 `lifecycle` 覆盖某子目标的 step 后,校验 evidence;满足则置 `status="done"` + 重渲染。无 `task_decomposition` 字段 → 不动作。
628
697
 
629
698
  ### Goal Prompt Template
630
699
 
@@ -633,12 +702,12 @@ ralph 评估下一步门控,ralph-execute 跑实际步骤。Stop hook 触发
633
702
  ```
634
703
  📋 任务分解完成。复制下面一行设定目标,会话在子目标全部达成前不停:
635
704
 
636
- /goal 目标达成条件: {session_dir}/status.json 中 task_decomposition[*].status 全部为 "done"(等价: {session_dir}/goal-checklist.md 末尾含 ALL_GOALS_DONE)。未达成时: 阅读 {session_dir}/goal-checklist.md 取得"执行准则/边界契约/子目标"作为行动手册, 然后调用 /maestro-ralph continue 推进下一步; 严禁手动执行 skill 或越界修改 status.json.boundary_contract.out_of_scope。
705
+ /goal 目标达成条件: {session_dir}/status.json 中 task_decomposition[*].status == "done" 且 task_decomposition[*].completion_confirmed == true steps[*].completion_confirmed == true。未达成时:阅读 {session_dir}/status.json 取得 execution_criteria / boundary_contract / task_decomposition / steps 作为行动手册,调用 /maestro-ralph continue 推进;严禁手动执行 skill 或越界修改 status.json.boundary_contract.out_of_scope。
637
706
 
638
707
  随后运行 /maestro-ralph continue 立即开始执行。
639
708
  ```
640
709
 
641
- `/goal` 是 harness 命令,仅用户能输入;ralph 只能输出此提示词。判据以 status.json 为权威,哨兵为等价信号,避免视图漂移误判。
710
+ `/goal` 由用户输入;ralph 只输出此提示词。判据以 status.json 为权威。
642
711
 
643
712
  ### Error Codes
644
713
 
@@ -649,6 +718,7 @@ ralph 评估下一步门控,ralph-execute 跑实际步骤。Stop hook 触发
649
718
  | E003 | error | Artifact dir not found for decision | Show glob, ask |
650
719
  | E004 | error | Delegate verdict parse failed | Fallback: "fix" |
651
720
  | E005 | error | Delegate execution failed | Fallback: "fix" |
721
+ | E006 | error | command_scope == "missing" for one or more steps | List missing skills, abort build |
652
722
  | W001 | warning | Decision expanded chain | Auto-handled |
653
723
  | W002 | warning | Max retries, escalating | Auto-handled |
654
724
  | W003 | warning | Multiple running sessions | Use latest, warn |
@@ -656,26 +726,27 @@ ralph 评估下一步门控,ralph-execute 跑实际步骤。Stop hook 触发
656
726
 
657
727
  ### Success Criteria
658
728
 
659
- - [ ] Phase 先于 position 解析(S_RESOLVE_PHASE → S_INFER → S_QUALITY_MODE);phase_is_new 标记写入 session
660
- - [ ] phase_is_new=true lifecycle_position 强制为 `analyze`(禁止用其他 phase 的 artifact 推断)
661
- - [ ] artifact 过滤始终按 session.phase(不读 state.json.current_phase)
662
- - [ ] quality_mode 显式由 A_DETERMINE_QUALITY_MODE 决定(full/standard/quick),过滤 build steps
663
- - [ ] State parsed, position inferred from bootstrap + artifacts + result files
664
- - [ ] Decomposition runs as initial step; broad intent boundary-clarified via ≤3 questions (ignores auto_confirm); narrow auto-derives
665
- - [ ] status.json enriched additively with boundary_contract + execution_criteria + task_decomposition; absent fields = old behavior preserved
666
- - [ ] status.json is single source of truth; goal-checklist.md is a regenerated projection (Sync Rule), never hand-edited
667
- - [ ] goal-checklist.md carries explicit `status.json#/task_decomposition[i]` JSON-pointer refs per entry + last-sync timestamp
668
- - [ ] Mutations to task_decomposition trigger checklist re-render; ALL_GOALS_DONE sentinel appended only when all entries status=done
669
- - [ ] Goal Prompt names status.json as the authoritative judgement source, with ALL_GOALS_DONE sentinel as equivalent signal
670
- - [ ] post-goal-audit decision node inserted before milestone-complete (only when decomposed)
671
- - [ ] Unmet sub-goals DYNAMICALLY grow steps[] via scoped per-goal mini-loops (goal_ref tagged), looping until all_met or max retries → escalate
672
- - [ ] Quality pipeline quality_mode 生成(full=全管线 / standard=skip business-test / quick=仅 review --tier quick)
673
- - [ ] Chain 末端硬约束:必须以 `milestone-complete` 结尾(goal-audit decision 紧前)
674
- - [ ] 初始构建按 task_decomposition[*].lifecycle 给每个 step 打 goal_ref(verify/review 等共用 lifecycle 的 step 也有标签)
675
- - [ ] Decision nodes delegate-evaluated via maestro delegate --role analyze
676
- - [ ] Verdict parsed with confidence adjustment
677
- - [ ] Fix-loop templates applied with retry tracking
678
- - [ ] Ralph never executes steps — only creates sessions and evaluates decisions
679
- - [ ] Handoff to maestro-ralph-execute via Skill() at creation and after decisions
729
+ - [ ] Phase 先于 position 解析;phase_is_new 标记写入 session
730
+ - [ ] D-007 反查:phase 数字 `session.milestone`,禁止读 current_milestone;写入 step.milestone_id
731
+ - [ ] phase_is_new=true lifecycle_position 强制 `analyze`
732
+ - [ ] Intent overrides 识别 brainstorm / blueprint / analyze-macro
733
+ - [ ] A_RESOLVE_SCOPE_VERDICT macro analyze conclusions.scope_verdict,写入 session.scope_verdict + analyze_macro_id
734
+ - [ ] 链路起点 = analyze-macro 时:large→roadmap+analyze+plan(phase);medium/small→直跳 plan --from analyze:{ANL_ID}(跳过 roadmap+analyze)
735
+ - [ ] post-analyze-scope decision 节点在 macro analyze 之后插入;A_SCOPE_EVALUATE/A_APPLY_SCOPE_VERDICT 重塑链路
736
+ - [ ] plan step args 支持三路径:`{phase}` / `--from analyze:{ANL_ID}` / `--from blueprint:{BLP_ID}`,写入 step.source_artifact_ref
737
+ - [ ] roadmap step args 自动注入 `--from analyze:{analyze_macro_id}`(若存在)
738
+ - [ ] artifact 过滤按 session.phase;unified milestone
739
+ - [ ] quality_mode A_DETERMINE_QUALITY_MODE 决定,过滤 build steps
740
+ - [ ] Decomposition: broad intent ≤3 question clarify;narrow auto-derive
741
+ - [ ] status.json 唯一真源:boundary_contract + execution_criteria + task_decomposition;无外部清单
742
+ - [ ] 每个 step 默认 `type: "internal"`,含 `command_scope` + `command_path`(全局优先 fallback 项目)
743
+ - [ ] 每个 step `completion_confirmed` + `completion_status` + `completion_evidence`(初始 false/null)
744
+ - [ ] 每个 sub-goal `completion_confirmed`(初始 false)
745
+ - [ ] post-goal-audit decision 仅在 decomposed 时插入,位于 milestone-complete 之前
746
+ - [ ] Unmet sub-goals 动态 grow steps[](goal_ref tagged);max retries → escalate
747
+ - [ ] planning_mode 显式决定;unified=无 `{phase}`, independent=带 `{phase}`
748
+ - [ ] Chain 必须以 `milestone-complete` 结尾
749
+ - [ ] Decision nodes maestro delegate --role analyze 评估
750
+ - [ ] Ralph 不执行 step,只 evaluate;Skill("maestro-ralph-execute") handoff
680
751
 
681
752
  </appendix>