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,229 @@
1
+ ---
2
+ name: maestro-ralph-cli-execute
3
+ description: "Skill execution wrapper for delegate — execute skill, return structured result Arguments: --session <id> | <skill-name> [args...]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Skill AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Thin execution wrapper for CLI delegation.
9
+
10
+ Job: receive session ID (or skill name + args) → load via `maestro ralph next` → execute the skill → scan artifacts → output structured `---RESULT---` block.
11
+
12
+ This command does NOT manage sessions, compose prompts, make decisions, or call `maestro ralph complete`. Completion 由 orchestrator (`/maestro-ralph-cli`) 负责:orchestrator 解析 `---RESULT---` 块后调用 `maestro ralph complete N --status <STATUS> --summary <SUMMARY> [--evidence ...] [--decisions ...] [--caveats ...] [--deferred ...]`,清 `active_step_index`。
13
+ </purpose>
14
+
15
+ <context>
16
+ $ARGUMENTS — `--session <id>` (session mode) 或 `<skill-name> [args...]` (direct mode)
17
+
18
+ **Parse:**
19
+ ```
20
+ --session <id> → session_id (session mode: skill 由 ralph next 从 status.json 解析,无需传 skill name)
21
+ First token → skill_name (direct mode only, e.g., maestro-plan, maestro-execute)
22
+ Remaining → skill_args (direct mode only)
23
+ ```
24
+
25
+ `<execution_context>` 块由 ralph-cli delegation prompt 注入于 `$ARGUMENTS` 之前,含 intent、boundary、goals 等,透传给 skill。
26
+ </context>
27
+
28
+ <invariants>
29
+ 1. **Execute exactly one skill** — session mode 由 `ralph next` 解析,direct mode 由 skill_name 确定;执行一次即返回
30
+ 2. **Structured output** — always end with `---RESULT---` / `---END---` block
31
+ 3. **No session management** — never create/modify sessions, make decisions, or call `maestro ralph complete`(completion 由 orchestrator 负责)
32
+ 4. **No self-invocation** — execute once and return
33
+ 5. **Artifact scanning** — after skill execution, scan for produced artifacts
34
+ 6. **Required reading 由 CLI 负责** — session mode 下 `ralph next` 自动展开 + 加载 `<required_reading>`,缺失 → exit 1(E007),cli-execute 不手动处理
35
+ 7. **Deferred reading 只记录** — `<deferred_reading>` 路径由 CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read,不提前批量读取
36
+ 8. **并发保护** — 同一 session 最多一个 step 持 `active_step_index`;`ralph next` exit 3 表示冲突,不静默推进
37
+ 9. **STATUS 枚举受限** — 仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
38
+ 10. **CLI 输出禁止截断** — `maestro ralph next` 的 stdout 必须全量捕获,严禁 `| head`/`| tail` 等截断管道
39
+ </invariants>
40
+
41
+ <state_machine>
42
+
43
+ <states>
44
+ S_PARSE — 解析 skill name + args PERSIST: —
45
+ S_EXECUTE — 执行 skill PERSIST: —
46
+ S_SCAN — 扫描产物 + 提取信号 PERSIST: —
47
+ S_OUTPUT — 输出结构化结果 PERSIST: —
48
+ </states>
49
+
50
+ <transitions>
51
+ S_PARSE → S_EXECUTE DO: A_PARSE_ARGS
52
+ S_EXECUTE → S_SCAN DO: A_EXECUTE_SKILL
53
+ S_SCAN → S_OUTPUT DO: A_SCAN_ARTIFACTS
54
+ S_OUTPUT → END DO: A_OUTPUT_RESULT
55
+ </transitions>
56
+
57
+ <actions>
58
+
59
+ ### A_PARSE_ARGS
60
+
61
+ 1. Parse `--session <id>` → `session_id`(session mode)
62
+ 2. 无 `--session` → extract `skill_name`(first token)and `skill_args`(remaining)为 direct mode
63
+ 3. Parse `<execution_context>` block from delegation prompt if present:
64
+ ```
65
+ intent, phase, boundary_contract, active_goals, execution_criteria
66
+ ```
67
+
68
+ ### A_EXECUTE_SKILL
69
+
70
+ 1. If `session_id` present → `Bash("maestro ralph next --session {session_id}")` — CLI loads skill + required_reading, returns prompt
71
+ - **必须全量捕获 stdout,严禁 `| head`/`| tail` 等任何截断管道**(stdout 含完整 skill prompt,截断会导致执行内容不完整)
72
+ - Exit 0 → 按 stdout 内联执行(stdout 含 CLI 拼接好的完整 prompt + session_anchor)
73
+ - Exit 1 → required_reading 缺失或 schema 错误 → set `status = "BLOCKED"`, skip to S_OUTPUT, SUMMARY 引用 CLI stderr
74
+ - Exit 2 → 无 pending step(已全部完成)→ set `status = "DONE"`, SUMMARY = "所有 step 已完成", skip to S_OUTPUT
75
+ - Exit 3 → active_step_index 冲突(另一进程占用)→ set `status = "BLOCKED"`, SUMMARY = "并发冲突", skip to S_OUTPUT
76
+ 2. If no session → `Skill({ skill: skill_name, args: skill_args })` — direct skill call
77
+ 3. **Goal context**: `ralph next` CLI 输出的 session_anchor 已含 goal context(`ralph_protocol_version >= "2"`),无需额外注入
78
+ 4. **Deferred reading**: `ralph next` 将 `<deferred_reading>` 路径记录到 `step.load.deferred_files`,执行阶段按需 Read
79
+ 5. **Inline execution** — 按 stdout 内容执行 skill 逻辑;执行完成后进入 S_SCAN
80
+ 6. Track execution: note start time, watch for errors
81
+
82
+ ### A_SCAN_ARTIFACTS
83
+
84
+ After skill execution, scan for produced artifacts:
85
+
86
+ | Pattern | Stage signal |
87
+ |---------|-------------|
88
+ | `conclusions.json` | `analysis_dir` |
89
+ | `TASK-*.json` | `plan_dir` |
90
+ | `verification.json` | `scratch_dir` |
91
+ | `review.json` | review stage |
92
+ | `test-results.json`, `uat.md` | test stage |
93
+ | `grill-report.md` | `grill_id` |
94
+ | `.brainstorming/*` | `brainstorm_dir` |
95
+
96
+ Use `Glob` to find files created/modified during execution.
97
+
98
+ Extract signals from output:
99
+ - Artifact IDs: `ANL-xxx`, `PLN-xxx`, `BLP-xxx`
100
+ - Path signals: `scratch_dir:`, `plan_dir:`
101
+ - Phase signals: `PHASE: N`
102
+
103
+ ### A_OUTPUT_RESULT
104
+
105
+ Output structured result block.
106
+
107
+ ```
108
+ ---RESULT---
109
+ STATUS: DONE|DONE_WITH_CONCERNS|NEEDS_RETRY|BLOCKED
110
+ SUMMARY: <动词开头,≤100 字的执行总结>
111
+ ARTIFACTS: <逗号分隔的产物路径>
112
+ EVIDENCE: <验证产物路径,如 verification.json、uat.md、e2e-results.json>
113
+ DECISIONS: <本步做出的关键决策,分号分隔>
114
+ CAVEATS: <后续步骤需注意的事项;DONE_WITH_CONCERNS 时同时作为 concerns>
115
+ DEFERRED: <推迟到后续的工作项,分号分隔>
116
+ SIGNALS: <key=value 对,分号分隔,如 plan_dir=.workflow/scratch/PLN-xxx;phase=2>
117
+ ---END---
118
+ ```
119
+
120
+ **Rules:**
121
+ - STATUS 必填,从执行结果推断(仅 4 个合法值,NEEDS_CONTEXT 已废除)
122
+ - SUMMARY 必填(DONE/DONE_WITH_CONCERNS 时为 MUST),动词开头
123
+ - ARTIFACTS 列出所有新增/修改的产物文件路径
124
+ - EVIDENCE 为 SHOULD,列出验证产物路径
125
+ - DECISIONS/CAVEATS/DEFERRED 为 SHOULD,有则填
126
+ - SIGNALS 提取 A_SCAN_ARTIFACTS 发现的 key=value 对
127
+
128
+ **SIGNALS→context 映射:**
129
+
130
+ | Signal key | 写入 status.json 字段 |
131
+ |------------|----------------------|
132
+ | `analysis_dir` | `context.analysis_dir` |
133
+ | `plan_dir` | `context.plan_dir` |
134
+ | `scratch_dir` | `context.scratch_dir` |
135
+ | `grill_id` | `context.grill_id` |
136
+ | `brainstorm_dir` | `context.brainstorm_dir` |
137
+ | `blueprint_dir` | `context.blueprint_dir` |
138
+ | `ANL-xxx` | `session.analyze_macro_id` |
139
+ | `BLP-xxx` | `session.blueprint_id` |
140
+ | `phase` | `session.context.phase` |
141
+
142
+ **Stage-specific SUMMARY 提取指引:**
143
+
144
+ | Stage | SUMMARY 应包含 | EVIDENCE 来源 |
145
+ |-------|---------------|---------------|
146
+ | analyze | scope_verdict + key_findings 数量 + 依赖图摘要 | `conclusions.json` |
147
+ | plan | TASK-*.json 数量 + 主要模块 + 波次划分 | — |
148
+ | execute | 修改文件数 + verification passed/failed | `verification.json` |
149
+ | review | verdict + findings 数量 + severity 分布 | `review.json` |
150
+ | test | pass/fail 统计 | `uat.md`, `test-results.json` |
151
+ | debug | root cause + 修复内容 | — |
152
+ | grill | 核心质疑点数量 + 术语表 | `grill-report.md` |
153
+ | brainstorm | 候选方案数量 + 推荐方案 | — |
154
+
155
+ **STATUS determination:**
156
+ - Skill 正常完成 + 有产物 → `DONE`
157
+ - 完成但有 warnings/concerns → `DONE_WITH_CONCERNS`
158
+ - 执行出错但可重试 → `NEEDS_RETRY`
159
+ - 执行出错且无法重试 → `BLOCKED`
160
+
161
+ </actions>
162
+
163
+ </state_machine>
164
+
165
+ <appendix>
166
+
167
+ ### Output Example
168
+
169
+ ```
170
+ ---RESULT---
171
+ STATUS: DONE
172
+ SUMMARY: 生成 8 个 task 覆盖认证模块 3 个子系统,wave 1 含 5 个独立 task
173
+ ARTIFACTS: .workflow/scratch/PLN-20260628/TASK-001.json,.workflow/scratch/PLN-20260628/TASK-002.json,.workflow/scratch/PLN-20260628/plan.json
174
+ EVIDENCE:
175
+ DECISIONS: 选择 wave 模式分 2 波执行;JWT 和 session 分离为独立 task
176
+ CAVEATS: 模块 X 的外部 API 尚未确认,TASK-003 可能需调整
177
+ DEFERRED: 性能基准测试留到 review 后
178
+ SIGNALS: plan_dir=.workflow/scratch/PLN-20260628;PLN-xxx=PLN-20260628
179
+ ---END---
180
+ ```
181
+
182
+ ### Error Output
183
+
184
+ ```
185
+ ---RESULT---
186
+ STATUS: BLOCKED
187
+ SUMMARY: maestro-plan 执行失败:required_reading 文件 analyze-guide.md 缺失
188
+ ARTIFACTS:
189
+ EVIDENCE:
190
+ DECISIONS:
191
+ CAVEATS:
192
+ DEFERRED:
193
+ SIGNALS:
194
+ ---END---
195
+ ```
196
+
197
+ ### Error Codes
198
+
199
+ | Code | Exit | Severity | Description | STATUS |
200
+ |------|------|----------|-------------|--------|
201
+ | E006 | 1 | error | command_path 缺失/不可达 | BLOCKED |
202
+ | E007 | 1 | error | required_reading 引用文件缺失 | BLOCKED |
203
+ | E008 | 1 | error | active_step_index 与 complete idx 不匹配 | BLOCKED |
204
+ | E009 | 1 | error | step.status ≠ running(重复 complete 或非法跳跃)| BLOCKED |
205
+ | E010 | 1 | error | status.json schema 损坏 | BLOCKED |
206
+ | — | 2 | info | 无 pending step(全部已完成)| DONE |
207
+ | — | 3 | error | active_step_index 并发冲突 | BLOCKED |
208
+ | W001 | 0 | warning | Step completed with concerns | DONE_WITH_CONCERNS |
209
+
210
+ ### Success Criteria
211
+
212
+ - [ ] Session mode 只需 `--session <id>`,skill 由 `ralph next` 从 status.json 解析
213
+ - [ ] Direct mode 解析 `skill_name` + `skill_args`
214
+ - [ ] Session mode 通过 `maestro ralph next --session {id}` 加载;stdout 全量捕获,禁止截断管道
215
+ - [ ] Exit codes 完整处理:0→执行,1→BLOCKED,2→DONE,3→BLOCKED
216
+ - [ ] Execute via `maestro ralph next` (session mode) or `Skill()` (direct mode)
217
+ - [ ] Scan artifacts after execution using Glob
218
+ - [ ] Extract artifact IDs and path signals from output
219
+ - [ ] Always output `---RESULT---` / `---END---` block
220
+ - [ ] STATUS 仅 4 个合法值:DONE / DONE_WITH_CONCERNS / NEEDS_RETRY / BLOCKED
221
+ - [ ] SUMMARY 在 DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
222
+ - [ ] EVIDENCE 字段列出验证产物路径
223
+ - [ ] SIGNALS 含 stage-specific key=value 对(参照 SIGNALS→context 映射表)
224
+ - [ ] Stage-specific SUMMARY 提取指引(analyze→scope_verdict,plan→TASK 数量 等)
225
+ - [ ] No session management, no self-invocation, no decisions, no `ralph complete`
226
+ - [ ] Deferred reading 按需 Read,不提前批量读取
227
+
228
+ </appendix>
229
+ </output>
@@ -0,0 +1,409 @@
1
+ ---
2
+ name: maestro-ralph-execute
3
+ description: "Execute next pending step in ralph session Arguments: [-y] [session-id]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Skill
5
+ ---
6
+
7
+ <purpose>
8
+ Single-step executor for ralph (adaptive) and maestro (static) sessions.
9
+ Each invocation: locate session → find next step → resolve args → execute → update → self-invoke next.
10
+
11
+ Mutual invocation with `/maestro-ralph` forms a self-perpetuating work loop.
12
+ Session: `.workflow/.maestro/*/status.json`
13
+ </purpose>
14
+
15
+ <context>
16
+ $ARGUMENTS — optional `-y` flag + optional session ID.
17
+
18
+ **Parse:**
19
+ ```
20
+ -y / --yes → auto = true
21
+ Remaining → session_id (if matches maestro-* or ralph-*)
22
+ ```
23
+ Also read `session.auto_mode` from status.json — if true, treat as `-y`.
24
+
25
+ **Step kinds:**
26
+
27
+ | Kind | Identifier | Execution | Flow after |
28
+ |------|-----------|-----------|------------|
29
+ | decision step | `step.decision` 非空 | `Skill("maestro-ralph")` | Execution ends here |
30
+ | 执行 step | `step.decision == null` | `Bash("maestro ralph next")` → 内联按其 stdout 执行 → `Bash("maestro ralph complete N --status ...")` | Self-invoke next |
31
+
32
+ HARD RULES:
33
+ - 执行 step:**统一通过 `maestro ralph next` CLI 加载**。CLI 负责读 command_path、解析 `<required_reading>` + `<deferred_reading>`、拼接 prompt、写 `step.load.*` + `active_step_index` + `step.status="running"`。不要再在会话里手动 Read + 解析 required_reading
34
+ - decision step:A_EXEC_DECISION 通过 `Skill({ skill: "maestro-ralph" })` handoff 给 ralph 评估(不走 CLI)
35
+ - `command_path` 由 ralph 在 A_BUILD_STEPS 写入 status.json(缺失 → ralph next 返回 E006/E007 并拒绝执行)
36
+ - 每个 step 结束必须调用 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`。STATUS 仅 4 个合法值:`DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`(**`NEEDS_CONTEXT` 已废除**,context 容量由 harness 自动压缩处理)
37
+ </context>
38
+
39
+ <invariants>
40
+ 1. **执行 = `ralph next` + inline + `ralph complete`** — 调 `maestro ralph next` 拿到 skill 内容,按 stdout 内联执行
41
+ 2. **Required reading 由 CLI 负责** — `ralph next` 自动展开 + 加载 `<required_reading>` 引用的所有文件,缺失 → 退出码 1(E007),不写 active_step_index,不进入执行
42
+ 3. **Deferred reading recorded only** — `<deferred_reading>` 路径由 CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
43
+ 4. **一致性取代锁** — 同一 session 同时最多一个 step 持 `active_step_index`;CLI 校验失败直接退出码 3,不静默推进
44
+ 5. **Completion 通过 CLI 调用** — 每个 step 末尾调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`,由 CLI 写 `completion_*` + 清 `active_step_index`
45
+ 6. **Self-invocation chain** — 持续直到全部 `completion_confirmed` 或 paused
46
+ 7. **status.json 每步骤后由 CLI 原子写盘** — resume-safe
47
+ 8. **STATUS 枚举受限** — 仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
48
+ 9. **CLI 输出禁止截断** — `maestro ralph next` 的 stdout 包含完整 skill prompt,必须全量捕获。**严禁** `| head`、`| tail`、`2>&1 | head -N` 等任何截断管道。Bash timeout 可加长但不可截断输出
49
+ 10. **禁止以上下文消耗为由中断自调用链** — harness 自动处理 context compression(消息摘要),模型无需判断上下文剩余空间。自调用链的唯一合法终止条件是:全部 `completion_confirmed`、session paused、或 decision handoff 到 ralph。以"上下文不足"、"已连续完成 N 个 step"、"避免 context overflow"等理由中断属于 invariant violation
50
+ </invariants>
51
+
52
+ <state_machine>
53
+
54
+ <states>
55
+ S_LOCATE — 定位 session + 找下一个 pending step PERSIST: —
56
+ S_RESOLVE_ARGS — 解析占位符 + 丰富参数 PERSIST: step.args (enriched)
57
+ S_LOAD_CONTEXT — 加载前序产出 + 发现 PERSIST: —
58
+ S_EXECUTE — 执行当前 step PERSIST: step.status = "running", session.current_step
59
+ S_POST_ANALYZE — 产物 vs 目标偏离分析 PERSIST: step.drift_score, step.drift_correction
60
+ S_POST_EXEC — 标记完成 + 传播上下文 PERSIST: step.completion_*, step.status, session.context
61
+ S_HANDLE_FAIL — 处理失败 PERSIST: step.status, session.status
62
+ S_COMPLETE — 所有 step 完成 PERSIST: session.status = "completed"
63
+ S_FALLBACK — 无 session 可执行 PERSIST: —
64
+ </states>
65
+
66
+ <transitions>
67
+
68
+ S_LOCATE:
69
+ → S_RESOLVE_ARGS WHEN: pending step found DO: A_LOCATE_SESSION
70
+ → S_COMPLETE WHEN: no pending steps
71
+ → S_FALLBACK WHEN: no running session
72
+
73
+ S_RESOLVE_ARGS:
74
+ → S_LOAD_CONTEXT DO: A_RESOLVE_ARGS
75
+
76
+ S_LOAD_CONTEXT:
77
+ → S_EXECUTE DO: A_LOAD_STEP_CONTEXT
78
+
79
+ S_EXECUTE:
80
+ → END WHEN: step.decision != null DO: A_EXEC_DECISION
81
+ → S_POST_ANALYZE WHEN: step.decision == null + execution succeeded (DONE|DONE_WITH_CONCERNS) DO: A_EXEC_STEP
82
+ → S_HANDLE_FAIL WHEN: step.decision == null + ralph next exit=1 OR ralph complete with NEEDS_RETRY|BLOCKED DO: A_EXEC_STEP
83
+ → S_HANDLE_FAIL WHEN: step.decision == null + ralph next exit=3 (concurrency conflict) DO: A_HANDLE_CONCURRENCY
84
+
85
+ S_POST_ANALYZE:
86
+ → S_POST_EXEC WHEN: drift_score == ALIGNED|MINOR_DRIFT DO: A_POST_ANALYZE_DRIFT
87
+ → S_EXECUTE WHEN: drift_score == MAJOR_DRIFT + not retried DO: A_POST_ANALYZE_DRIFT (re-execute with correction)
88
+ → S_POST_EXEC WHEN: drift_score == MAJOR_DRIFT + retried DO: A_POST_ANALYZE_DRIFT (proceed with caveats)
89
+
90
+ S_POST_EXEC:
91
+ → S_LOCATE DO: Bash("maestro ralph complete ...") + Skill("maestro-ralph-execute")
92
+ NOTE: CLI 已写完 completion_*, status, active_step_index;无需额外写盘
93
+
94
+ S_HANDLE_FAIL:
95
+ → S_LOCATE WHEN: exit code 3 (concurrency conflict) DO: A_HANDLE_CONCURRENCY (wait 3s + retry)
96
+ → S_LOCATE WHEN: auto + not retried DO: A_RETRY
97
+ → END WHEN: auto + retried DO: A_PAUSE_SESSION
98
+ → S_LOCATE WHEN: interactive + user selects retry DO: A_RETRY
99
+ → S_LOCATE WHEN: interactive + user selects skip DO: A_SKIP_STEP
100
+ → END WHEN: interactive + user selects abort DO: A_PAUSE_SESSION
101
+
102
+ S_COMPLETE:
103
+ → END DO: A_COMPLETE_SESSION
104
+
105
+ S_FALLBACK:
106
+ → END DO: display "无运行中的会话。使用 /maestro 或 /maestro-ralph 创建。"
107
+
108
+ </transitions>
109
+
110
+ <actions>
111
+
112
+ ### A_LOCATE_SESSION
113
+
114
+ 1. If session_id provided → load `.workflow/.maestro/{session_id}/status.json`
115
+ 2. Else: scan `.workflow/.maestro/*/status.json`, filter `status == "running"` AND (`execution_mode` is absent OR `execution_mode == "inline"`), sort DESC, take first. Skip sessions with `execution_mode == "agent"` or `"cli-delegate"` — those belong to ralph-v2 / ralph-cli respectively.
116
+ 3. Extract: session_id, source, steps[], phase, milestone, intent, auto_mode, context, cli_tool, active_step_index
117
+ 4. **不在此处选 pending step**——pending 选择由 `maestro ralph next` CLI 内部完成;A_LOCATE_SESSION 只确认 session 存在且 running,由 A_EXEC_STEP 调 CLI 推进
118
+
119
+ ### A_RESOLVE_ARGS
120
+
121
+ **Placeholder substitution:**
122
+
123
+ | Placeholder | Source |
124
+ |-------------|--------|
125
+ | `{phase}` | session.phase |
126
+ | `{milestone}` | session.milestone |
127
+ | `{intent}` | session.intent |
128
+ | `{description}` | session.intent (alias) |
129
+ | `{scratch_dir}` | session.context.scratch_dir or latest artifact path |
130
+ | `{plan_dir}` | session.context.plan_dir |
131
+ | `{analysis_dir}` | session.context.analysis_dir |
132
+ | `{issue_id}` | session.context.issue_id |
133
+ | `{milestone_num}` | session.context.milestone_num |
134
+
135
+ **Per-skill enrichment** (when args empty or minimal):
136
+
137
+ | Skill | Required context | Source |
138
+ |-------|-----------------|--------|
139
+ | maestro-brainstorm | topic | `"{intent}"` |
140
+ | maestro-roadmap | description | `"{intent}"` |
141
+ | maestro-analyze | phase or topic | `{phase}` or `"{intent}"` |
142
+ | maestro-plan | phase, --from, or --dir | see --from auto-injection below |
143
+ | maestro-execute | phase or --dir | see --from auto-injection below |
144
+ | quality-debug | gap context | Read previous step's error/gap |
145
+ | quality-* | phase | `{phase}` |
146
+
147
+ **--from auto-injection (phase-level artifact chaining):**
148
+
149
+ Phase-level steps 在 build 阶段无法预知前序 artifact ID。A_RESOLVE_ARGS 运行时从 state.json 查找并注入显式引用,打通 analyze→plan→execute 数据管道:
150
+
151
+ ```
152
+ Read state.json.artifacts(含 milestone_history 内归档 artifacts)
153
+ → filter by milestone={session.milestone} + phase={session.phase} + status=="completed"
154
+
155
+ plan step(含 {phase} 占位符,args 无 --from 且无 --dir):
156
+ 1. 查同 phase+milestone 最新 completed type=="analyze" artifact → id = ANL-xxx
157
+ 2. 命中 → args 追加 --from analyze:{id}
158
+ 3. 写 step.source_artifact_ref = "analyze:{id}"
159
+
160
+ execute step(含 {phase} 占位符,args 无 --dir):
161
+ 1. 查同 phase+milestone 最新 completed type=="plan" artifact → id = PLN-xxx, path = scratch/...
162
+ 2. 命中 → args 追加 --dir .workflow/scratch/{path}
163
+ 3. 写 step.source_artifact_ref = "plan:{id}"
164
+ ```
165
+
166
+ 兜底:查询无结果 → 不注入,由命令自身 discovery 逻辑处理。已有 `--from` 或 `--dir` 的 step 不覆盖。
167
+
168
+ **Goal context injection:**
169
+
170
+ 当 step.goal_ref 非空且 session.task_decomposition 存在时:
171
+ ```
172
+ goal = session.task_decomposition.find(g => g.id == step.goal_ref)
173
+ if goal:
174
+ goal_snippet = { id: goal.id, goal: goal.goal, done_when: goal.done_when,
175
+ boundary: goal.boundary, evidence: goal.evidence }
176
+ → 传递给 A_EXEC_STEP 用于 inline execution 前注入(见 step 2 goal context pre-injection)
177
+ ```
178
+
179
+ Write enriched args + source_artifact_ref back to status.json.
180
+
181
+ ### A_LOAD_STEP_CONTEXT
182
+
183
+ 加载前序产出和发现,为 inline execution 注入上下文。
184
+
185
+ 1. **Previous step output** — 读前一 completed step 的 `completion_summary` + `completion_caveats` + `completion_decisions` + `completion_deferred`
186
+ 2. **Artifacts** — 按 `session.context` 中的路径逐个 Read,提取与当前 step 相关的内容:
187
+
188
+ | 当前 stage | 加载什么 | Source |
189
+ |-----------|---------|--------|
190
+ | plan | analysis conclusions + scope_verdict | `{context.analysis_dir}/conclusions.json` |
191
+ | execute | task list + wave assignments | `{context.plan_dir}/TASK-*.json` |
192
+ | review | changed files + verification results | `{context.scratch_dir}/verification.json` |
193
+ | test | review findings | `review.json` |
194
+ | debug | error traces + failing test details | 前一 step 的 `completion_evidence` |
195
+ | brainstorm | grill report | `{context.grill_id}` report |
196
+
197
+ 3. **Explore if needed** — 产物指向代码位置但缺少上下文 → `maestro explore` 补充(仅 execute/debug/test 且有文件路径引用时)
198
+ 4. **Accumulated signals** — 遍历 ALL completed steps → 聚合 caveats + deferred
199
+
200
+ 加载的内容进入会话上下文,后续 inline execution 自动受益。
201
+
202
+ ### A_EXEC_DECISION
203
+
204
+ 1. Mark step running, write status.json
205
+ 2. Display: `[{index}/{total}] ◆ {step.decision} Retry: {retry}/{max}`
206
+ 3. `Skill({ skill: "maestro-ralph" })` — ralph 评估 + handoff
207
+ 4. 执行在此结束
208
+
209
+ ### A_EXEC_STEP
210
+
211
+ 1. **Load** — `Bash("maestro ralph next --session <session_id>")` — **必须全量捕获 stdout,严禁 `| head`/`| tail` 等截断管道**(stdout 含完整 skill prompt,截断会导致执行内容不完整)
212
+ - 退出码 0 → 按 stdout 内联执行
213
+ - 退出码 2 → 交给 S_LOCATE
214
+ - 退出码 3 → active_step_index 已被占用
215
+ - 退出码 1 → pause session
216
+ 2. **Goal context pre-injection**:
217
+ - GUARD: `ralph_protocol_version >= "2"` → skip(session_anchor 已含 goal context)
218
+ - WHEN `ralph_protocol_version < "2"` 或缺失 AND `step.goal_ref` 非空 → 在 stdout 顶部前置:
219
+ ```
220
+ <goal_context>
221
+ Sub-goal: {goal.id} — {goal.goal}
222
+ Done when: {goal.done_when}
223
+ Boundary: {goal.boundary}
224
+ Evidence target: {goal.evidence}
225
+ Execution criteria: {session.execution_criteria joined by '; '}
226
+ </goal_context>
227
+ ```
228
+ 3. **Inline execution** — 按 stdout 执行;deferred_reading 按需 Read
229
+ 4. **Extract step signals** (A_EXTRACT_STEP_SIGNALS) — 执行完成后、调 ralph complete 前,提取结构化信号用于组装 completion 参数和下一步上下文:
230
+
231
+ **4a. Stage-specific signal extraction:**
232
+
233
+ | Stage | 提取什么 | 写入字段 |
234
+ |-------|---------|---------|
235
+ | analyze | `conclusions.json` 的 scope_verdict + key_findings; 依赖图摘要 | `--summary`, `--decisions`, context.analysis_dir |
236
+ | plan | 生成的 TASK-*.json 数量 + 主要模块; 波次划分 | `--summary`, context.plan_dir |
237
+ | execute | 修改的文件列表; verification.json passed/failed; 新 artifact ID | `--summary`, `--evidence`, context.scratch_dir |
238
+ | review | review.json verdict + findings 数量 + severity 分布 | `--summary`, `--decisions` |
239
+ | test | test-results.json pass/fail 统计; uat.md 结果 | `--summary`, `--evidence` |
240
+ | debug | root cause 描述; 修复了什么 | `--summary`, `--decisions` |
241
+ | grill | grill-report.md 核心质疑点; 术语表 | `--summary`, `--caveats`, context.grill_id |
242
+ | brainstorm | 候选方案数量 + 推荐方案 | `--summary`, `--decisions`, context.brainstorm_dir |
243
+
244
+ **4b. Compose completion params:**
245
+
246
+ | Param | 规则 | 组装方法 |
247
+ |-------|------|---------|
248
+ | `--summary` | MUST。动词开头,≤100 字。从 4a 提取的关键产出组合 | `"<动词><做了什么>,<量化结果>"` e.g. `"分析认证模块依赖图,发现 5 处 JWT 内联验证,scope=medium"` |
249
+ | `--decisions` | SHOULD。每条一个架构/技术决策(可多次 `--decisions`) | 从执行过程中做出的非显而易见的选择提取。e.g. `"选择中间件模式而非装饰器"` `"跳过 session 层重构,留给 G2"` |
250
+ | `--caveats` | SHOULD。后续 step 必须知道的约束/风险 | 从执行中发现但不属于本步解决的问题。e.g. `"session 存储层与 JWT 有隐式耦合,execute 阶段需处理"` |
251
+ | `--deferred` | SHOULD。明确推迟到后续的工作(可多次 `--deferred`) | 被主动推迟的项。e.g. `"性能基准测试留到 review 后"` `"错误码国际化不在 scope 内"` |
252
+
253
+ **4c. Context-to-next-step propagation checklist:**
254
+
255
+ | 信号 | 检查 | 传播到 |
256
+ |------|------|--------|
257
+ | PHASE 变更 | 输出含 `PHASE: N` | `session.context.phase` |
258
+ | Artifact ID | 输出含 `ANL-xxx`/`PLN-xxx`/`BLP-xxx` | `session.analyze_macro_id`/`context.plan_dir` 等 |
259
+ | Scratch dir | 输出含 `scratch_dir:` 或 `.workflow/scratch/` 路径 | `session.context.scratch_dir` |
260
+ | Plan dir | plan step 产出目录 | `session.context.plan_dir` |
261
+ | Grill ID | grill step 产出 ID | `session.context.grill_id` |
262
+ | Blueprint ID | blueprint step 产出 `BLP-xxx` | `session.blueprint_id` |
263
+
264
+ 这些信号直接写入 `status.json.context`,下一步的 session_anchor 自动携带。
265
+
266
+ 5. **Complete** — 使用 4b 组装的参数调用:
267
+ - `Bash("maestro ralph complete N --status DONE --summary \"...\" [--evidence <path>] [--decisions \"...\"] [--caveats \"...\"] [--deferred \"...\"]")`
268
+ - `Bash("maestro ralph complete N --status DONE_WITH_CONCERNS --summary \"...\" --concerns \"...\"")`
269
+ - `Bash("maestro ralph retry N")`
270
+ - `Bash("maestro ralph complete N --status BLOCKED --reason \"...\"")`
271
+
272
+ 6. **Propagate context signals** — 按 4c checklist 将关键信号写入 `status.json.context`
273
+
274
+ 完成后 S_LOCATE 触发 `Skill({ skill: "maestro-ralph-execute" })` 自调用。
275
+
276
+ ### A_POST_ANALYZE_DRIFT
277
+
278
+ 执行完成后、调 ralph complete 前,分析产物与目标的偏离程度并自动修正。
279
+
280
+ **1. 收集对照基准:**
281
+
282
+ | 基准来源 | 取值 |
283
+ |---------|------|
284
+ | `step.goal_ref` → goal.done_when | 子目标的完成条件 |
285
+ | `session.boundary_contract.definition_of_done` | 全局验收标准 |
286
+ | `session.execution_criteria` | 执行准则 |
287
+ | `session.intent` | 原始意图 |
288
+
289
+ **2. 读产物摘要:**
290
+
291
+ 从 A_EXTRACT_STEP_SIGNALS (step 4a) 已提取的 summary + decisions + artifacts 构建产物画像。
292
+
293
+ **3. 对比评分:**
294
+
295
+ | 维度 | 检查 |
296
+ |------|------|
297
+ | 覆盖度 | 产物是否覆盖了 goal.done_when 的每个条件 |
298
+ | 方向性 | decisions 是否与 intent 和 boundary 一致 |
299
+ | 完整性 | 预期产物类型是否齐全(如 plan 阶段应有 TASK-*.json) |
300
+
301
+ **drift_score:**
302
+ - `ALIGNED` — 全部维度通过
303
+ - `MINOR_DRIFT` — 覆盖度/完整性有小缺口,不影响后续
304
+ - `MAJOR_DRIFT` — 方向性偏离或关键产物缺失
305
+
306
+ **4. 修正动作:**
307
+
308
+ | drift_score | 动作 |
309
+ |-------------|------|
310
+ | ALIGNED | 正常进入 S_POST_EXEC |
311
+ | MINOR_DRIFT | 将偏离项追加到 completion_caveats,正常 complete |
312
+ | MAJOR_DRIFT + 未重试 | 将偏离分析写入 `step.drift_correction`,回到 S_EXECUTE 重跑(A_LOAD_STEP_CONTEXT 自动加载 drift_correction 作为修正上下文) |
313
+ | MAJOR_DRIFT + 已重试 | 将偏离项写入 caveats + concerns,以 DONE_WITH_CONCERNS complete,由后续 decision node 裁决 |
314
+
315
+ **5. 写入:**
316
+ - `step.drift_score` — ALIGNED / MINOR_DRIFT / MAJOR_DRIFT
317
+ - `step.drift_correction` — MAJOR_DRIFT 时的偏离描述 + 修正指引(供重跑时注入)
318
+
319
+ ### A_HANDLE_CONCURRENCY
320
+
321
+ Exit code 3 — `active_step_index` occupied by another process (concurrency conflict).
322
+
323
+ 1. Display: `[{index}] ⚠ Concurrency conflict — active_step_index already held`
324
+ 2. Wait 3 seconds, then re-read `status.json` to check if `active_step_index` has been cleared
325
+ 3. If cleared → return to S_LOCATE (retry the step)
326
+ 4. If still held after 2 attempts → A_PAUSE_SESSION with reason "concurrency conflict unresolved — another process may be holding the lock"
327
+
328
+ ### A_RETRY
329
+
330
+ 1. `Bash("maestro ralph retry N")` — CLI 设 `step.retried = true`, `step.status = "pending"`, `step.completion_confirmed = false`, 清 `active_step_index`
331
+ 2. Display: `[{index}/{total}] ↻ {step.skill} retry`
332
+
333
+ ### A_SKIP_STEP
334
+
335
+ 跳过执行 step — 手动编辑 `status.json`:将该 step `status` 设为 `"skipped"`,`completion_confirmed` 设为 `false`,并清 `active_step_index`(若指向此 step)。
336
+ (不提供 CLI 子命令;跳过是非常规操作,避免自动化误用。)
337
+
338
+ ### A_PAUSE_SESSION
339
+
340
+ 通常由 `ralph complete N --status BLOCKED --reason "..."` 触发,CLI 已写 `session.status = "paused"`。手动 pause 场景下直接编辑 status.json。
341
+ Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。/maestro-ralph continue 恢复。`
342
+
343
+ ### A_COMPLETE_SESSION
344
+
345
+ 1. 校验:所有 step `completion_confirmed == true`(除 skipped);task_decomposition 存在时校验 `task_decomposition_all_done == true`
346
+ 2. 任一校验失败 → 不标 completed,回 S_LOCATE 或 pause
347
+ 3. `session.status = "completed"`, write status.json
348
+ 4. Display completion report:
349
+ ```
350
+ ============================================================
351
+ SESSION COMPLETE
352
+ ============================================================
353
+ Session: {session_id} [{source}]
354
+ Steps: {completed}/{total} confirmed: {confirmed}/{completed}
355
+
356
+ [✓] 0. maestro-plan 1 [global]
357
+ [✓] 1. maestro-execute 1 [project]
358
+ [✓] 2. ◆ post-execute [decision]
359
+ ...
360
+ ============================================================
361
+ ```
362
+ Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision
363
+
364
+ </actions>
365
+
366
+ </state_machine>
367
+
368
+ <appendix>
369
+
370
+ ### Error Codes
371
+
372
+ | Code | Severity | Description | Recovery |
373
+ |------|----------|-------------|----------|
374
+ | E001 | error | No running session found | Suggest /maestro or /maestro-ralph |
375
+ | E006 | error | command_path missing/unreachable for 执行 step | `ralph next` 拒绝;编辑 status.json 或重 build |
376
+ | E007 | error | required_reading 引用文件缺失 | `ralph next` 拒绝;CLI stderr 列出缺失路径 |
377
+ | E008 | error | `ralph complete` idx ≠ active_step_index | 编辑 status.json 修正一致性 |
378
+ | E009 | error | `ralph complete` step.status ≠ running | 重复 complete 或非法跳跃;编辑 status.json |
379
+ | E010 | error | status.json schema 损坏 | `ralph check` 显示具体损坏字段 |
380
+ | W001 | warning | Step completed with concerns | Log and continue |
381
+ | W005 | warning | active_step_index 指向已 completed step | `ralph next` 自动清理后继续 |
382
+ | W007 | warning | step.skill ≠ command .md frontmatter.name | 提示但不阻塞 |
383
+
384
+ ### Success Criteria
385
+
386
+ - [ ] Session discovery covers maestro-* and ralph-*
387
+ - [ ] `-y` parsed from args 或 session.auto_mode;auto=true 时透传 `-y` 到 skill args
388
+ - [ ] Placeholders resolved;per-skill enrichment 正确
389
+ - [ ] Decision 节点(`step.decision != null`)走 Skill("maestro-ralph") handoff(**不调 ralph next CLI**)
390
+ - [ ] 执行 step 通过 `Bash("maestro ralph next")` 加载;CLI 返回拼好的 prompt + completion 协议
391
+ - [ ] required_reading 由 CLI 自动加载并拼入 prompt;缺失 → CLI 退出码 1,pause session
392
+ - [ ] `<deferred_reading>` 由 CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
393
+ - [ ] 每个 step 末尾必须调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`
394
+ - [ ] STATUS 枚举仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;CLI 拒绝 `NEEDS_CONTEXT`
395
+ - [ ] active_step_index 一致性由 CLI 维护;E008/E009 直接退出,不静默推进
396
+ - [ ] step.completion_evidence 通过 `--evidence` 传入并记录
397
+ - [ ] Context signals 由执行 step 显式写回 status.json.context(非 ralph-execute 内嵌扫描)
398
+ - [ ] Auto mode: retry 一次后 pause;interactive 提供 retry/skip/abort
399
+ - [ ] 自调用持续到全部 completion_confirmed 或 paused
400
+ - [ ] --from auto-injection:phase-level plan step 运行时从 state.json 查找同 phase+milestone 最新 completed analyze artifact → 注入 `--from analyze:{id}`,写 `source_artifact_ref`
401
+ - [ ] --from auto-injection:phase-level execute step 运行时查找同 phase+milestone 最新 completed plan artifact → 注入 `--dir`,写 `source_artifact_ref`
402
+ - [ ] Goal context injection:`ralph_protocol_version < "2"` → 前置 `<goal_context>` block;`>= "2"` → skip(session_anchor 覆盖)
403
+ - [ ] Goal context 包含 sub-goal description、done_when、boundary、evidence、execution_criteria
404
+ - [ ] 已有 `--from` 或 `--dir` 的 step 不被 auto-injection 覆盖
405
+ - [ ] `--summary` 在 DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
406
+ - [ ] `--decisions`/`--caveats`/`--deferred` 为 SHOULD;存在关键决策/注意事项/推迟工作时填写
407
+ - [ ] 结构化总结由 CLI 写入 status.json,session_anchor 自动聚合注入下游 step
408
+
409
+ </appendix>