maestro-flow 0.4.15 → 0.4.17

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 (104) hide show
  1. package/.agents/skills/maestro/SKILL.md +17 -17
  2. package/.agents/skills/maestro-init/SKILL.md +1 -1
  3. package/.agents/skills/maestro-plan/SKILL.md +10 -9
  4. package/.agents/skills/maestro-ralph/SKILL.md +21 -17
  5. package/.agents/skills/maestro-ralph-beta/SKILL.md +893 -0
  6. package/.agents/skills/maestro-ralph-execute/SKILL.md +54 -71
  7. package/.agents/skills/manage-knowledge-audit/SKILL.md +90 -0
  8. package/.agy/skills/maestro/SKILL.md +17 -17
  9. package/.agy/skills/maestro-init/SKILL.md +1 -1
  10. package/.agy/skills/maestro-plan/SKILL.md +10 -9
  11. package/.agy/skills/maestro-ralph/SKILL.md +21 -17
  12. package/.agy/skills/maestro-ralph-beta/SKILL.md +889 -0
  13. package/.agy/skills/maestro-ralph-execute/SKILL.md +54 -71
  14. package/.agy/skills/manage-knowledge-audit/SKILL.md +90 -0
  15. package/.claude/commands/maestro-init.md +1 -1
  16. package/.claude/commands/maestro-plan.md +10 -9
  17. package/.claude/commands/maestro-ralph-beta.md +891 -0
  18. package/.claude/commands/maestro-ralph-execute.md +54 -71
  19. package/.claude/commands/maestro-ralph.md +21 -17
  20. package/.claude/commands/maestro.md +17 -17
  21. package/.claude/commands/manage-knowledge-audit.md +88 -0
  22. package/.codex/skills/maestro-ralph/SKILL.md +93 -73
  23. package/.codex/skills/maestro-ralph-beta/SKILL.md +891 -0
  24. package/.codex/skills/maestro-ralph-execute/SKILL.md +243 -0
  25. package/dist/src/cli.js +1 -0
  26. package/dist/src/cli.js.map +1 -1
  27. package/dist/src/commands/font-guide.d.ts +13 -0
  28. package/dist/src/commands/font-guide.d.ts.map +1 -0
  29. package/dist/src/commands/font-guide.js +114 -0
  30. package/dist/src/commands/font-guide.js.map +1 -0
  31. package/dist/src/commands/install-backend.d.ts.map +1 -1
  32. package/dist/src/commands/install-backend.js +23 -4
  33. package/dist/src/commands/install-backend.js.map +1 -1
  34. package/dist/src/commands/install.d.ts.map +1 -1
  35. package/dist/src/commands/install.js +5 -0
  36. package/dist/src/commands/install.js.map +1 -1
  37. package/dist/src/commands/ralph.d.ts +6 -0
  38. package/dist/src/commands/ralph.d.ts.map +1 -0
  39. package/dist/src/commands/ralph.js +135 -0
  40. package/dist/src/commands/ralph.js.map +1 -0
  41. package/dist/src/core/manifest.d.ts +2 -0
  42. package/dist/src/core/manifest.d.ts.map +1 -1
  43. package/dist/src/core/manifest.js.map +1 -1
  44. package/dist/src/hooks/statusline.d.ts.map +1 -1
  45. package/dist/src/hooks/statusline.js +189 -81
  46. package/dist/src/hooks/statusline.js.map +1 -1
  47. package/dist/src/ralph/cmd-check.d.ts +9 -0
  48. package/dist/src/ralph/cmd-check.d.ts.map +1 -0
  49. package/dist/src/ralph/cmd-check.js +53 -0
  50. package/dist/src/ralph/cmd-check.js.map +1 -0
  51. package/dist/src/ralph/cmd-complete.d.ts +10 -0
  52. package/dist/src/ralph/cmd-complete.d.ts.map +1 -0
  53. package/dist/src/ralph/cmd-complete.js +91 -0
  54. package/dist/src/ralph/cmd-complete.js.map +1 -0
  55. package/dist/src/ralph/cmd-next.d.ts +5 -0
  56. package/dist/src/ralph/cmd-next.d.ts.map +1 -0
  57. package/dist/src/ralph/cmd-next.js +201 -0
  58. package/dist/src/ralph/cmd-next.js.map +1 -0
  59. package/dist/src/ralph/cmd-session.d.ts +5 -0
  60. package/dist/src/ralph/cmd-session.d.ts.map +1 -0
  61. package/dist/src/ralph/cmd-session.js +52 -0
  62. package/dist/src/ralph/cmd-session.js.map +1 -0
  63. package/dist/src/ralph/cmd-skills.d.ts +8 -0
  64. package/dist/src/ralph/cmd-skills.d.ts.map +1 -0
  65. package/dist/src/ralph/cmd-skills.js +62 -0
  66. package/dist/src/ralph/cmd-skills.js.map +1 -0
  67. package/dist/src/ralph/skill-resolver.d.ts +40 -0
  68. package/dist/src/ralph/skill-resolver.d.ts.map +1 -0
  69. package/dist/src/ralph/skill-resolver.js +162 -0
  70. package/dist/src/ralph/skill-resolver.js.map +1 -0
  71. package/dist/src/ralph/skill-scanner.d.ts +20 -0
  72. package/dist/src/ralph/skill-scanner.d.ts.map +1 -0
  73. package/dist/src/ralph/skill-scanner.js +137 -0
  74. package/dist/src/ralph/skill-scanner.js.map +1 -0
  75. package/dist/src/ralph/status-checker.d.ts +7 -0
  76. package/dist/src/ralph/status-checker.d.ts.map +1 -0
  77. package/dist/src/ralph/status-checker.js +139 -0
  78. package/dist/src/ralph/status-checker.js.map +1 -0
  79. package/dist/src/ralph/status-schema.d.ts +96 -0
  80. package/dist/src/ralph/status-schema.d.ts.map +1 -0
  81. package/dist/src/ralph/status-schema.js +9 -0
  82. package/dist/src/ralph/status-schema.js.map +1 -0
  83. package/dist/src/ralph/status-store.d.ts +20 -0
  84. package/dist/src/ralph/status-store.d.ts.map +1 -0
  85. package/dist/src/ralph/status-store.js +70 -0
  86. package/dist/src/ralph/status-store.js.map +1 -0
  87. package/dist/src/tui/install-ui/ExecutionView.d.ts.map +1 -1
  88. package/dist/src/tui/install-ui/ExecutionView.js +1 -0
  89. package/dist/src/tui/install-ui/ExecutionView.js.map +1 -1
  90. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  91. package/dist/src/tui/install-ui/InstallExecution.js +2 -0
  92. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  93. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  94. package/dist/src/tui/install-ui/InstallFlow.js +28 -14
  95. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  96. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  97. package/dist/src/tui/install-ui/InstallResult.js +1 -1
  98. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  99. package/dist/src/utils/update-notices.js +12 -0
  100. package/dist/src/utils/update-notices.js.map +1 -1
  101. package/package.json +1 -1
  102. package/templates/config.json +21 -33
  103. package/workflows/init.md +11 -11
  104. package/workflows/knowledge-audit.md +358 -0
@@ -2,23 +2,24 @@
2
2
  name: maestro-ralph
3
3
  description: Use when the optimal command sequence is unclear and needs automated state-based determination
4
4
  argument-hint: "<intent> [-y] | status | continue"
5
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Skill, request_user_input
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
6
  ---
7
7
  <purpose>
8
8
  Closed-loop decision engine for the maestro workflow lifecycle.
9
9
  Reads project state → infers position → builds adaptive chain → delegates execution.
10
10
 
11
11
  Entry points:
12
- - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → execute
13
- - **`/maestro-ralph continue`** — Resume via maestro-ralph-execute
12
+ - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → emit /goal prompt(如有 decomposition)→ dispatch ralph-execute
13
+ - **`/maestro-ralph continue`** — Wrapper; dispatches to ralph-execute(首选直接 `/maestro-ralph-execute` 推进 step)
14
14
  - **`/maestro-ralph status`** — Display session progress
15
15
 
16
+ > 推进规则:**step 推进由 `/maestro-ralph-execute` 负责**;ralph 仅在 build / decision 评估时介入。decision 节点由 ralph-execute 自动 `$maestro-ralph` 直调 handoff,无需用户手动切换。
17
+
16
18
  Initial decomposition (S_DECOMPOSE): boundary-clarified via ≤3 questions for broad intents (重构/全面/迁移/重写). 写入 status.json 的 `boundary_contract` / `execution_criteria` / `task_decomposition`,附 `/goal` prompt。
17
19
 
18
- Node types:
19
- - **internal** (default): ralph-execute `Read({command_path})` 命令 .md,按内容内联执行
20
- - **decision**: ralph 评估
21
- - **external**: 仅在显式声明时使用(`maestro delegate --to claude`)
20
+ Step kinds:
21
+ - **执行 step**: ralph-execute `Bash("maestro ralph next")` 加载 SKILL.md + required_reading 全文,按 stdout 内联执行
22
+ - **decision step**: `step.decision` 字段非空;回 ralph 评估(CLI 只读分析)
22
23
 
23
24
  Key difference from maestro coordinator:
24
25
  - maestro: static chain → one-time selection → runs all steps
@@ -35,9 +36,9 @@ Mutual invocation with `/maestro-ralph-execute` forms a self-perpetuating work l
35
36
  │ writes status.json
36
37
  │ emits /goal prompt
37
38
 
38
- ralph-execute ◀─┐ internalRead(command_path) inline
39
- │ │ decision → Skill("maestro-ralph")
40
- └─────────┘ writes step.completion_confirmed
39
+ ralph-execute ◀─┐ 执行 step `maestro ralph next` + inline + `ralph complete`
40
+ │ │ decision step $maestro-ralph
41
+ └─────────┘ CLI writes step.completion_confirmed
41
42
  loop until all completion_confirmed | paused
42
43
  ```
43
44
  </purpose>
@@ -60,15 +61,17 @@ Remaining → intent
60
61
 
61
62
  <invariants>
62
63
  1. **Ralph never executes steps** — only creates sessions and evaluates decisions
63
- 2. **Handoff via Skill("maestro-ralph-execute")**at session creation and after decision evaluation
64
+ 2. **Handoff via `$maestro-ralph-execute` 直调** 创建 session 后始终自动 handoff;decision 评估后始终 handoff
64
65
  3. **Decision delegates read-only** — `maestro delegate --role analyze --mode analysis`
65
- 4. **Default type = internal** `external` 仅显式标注时出现,build 不默认生成
66
+ 4. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(详见 invariant 8)
66
67
  5. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
67
- 6. **每个 step 必须 `completion_confirmed: true`** — 基于 `--- COMPLETION STATUS ---` `STATUS: DONE`;缺失则视为未完成
68
- 7. **command_path 在 A_BUILD_STEPS 解析** — 全局优先 `~/.claude/commands/{name}.md`,fallback 项目 `.claude/commands/{name}.md`,写入 status.json
69
- 8. **Decomposition is outcome-oriented**sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 只发提示词
70
- 9. **planning_mode governs arg granularity** — `unified` skill args `{phase}`;`independent` `{phase}`
71
- 10. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
68
+ 6. **每个 step 必须 `completion_confirmed: true`** — `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
69
+ 7. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform codex --json --quiet` 预校验(project 覆盖 global,限定 `.codex/skills/`),命中即写绝对路径到 status.json;未命中标 `command_scope = "missing"`
70
+ 8. **执行 step 加载契约** `maestro ralph next` CLI 在执行期完成:解析 frontmatter + `<required_reading>` + `<deferred_reading>`,自动读取 required 文件全文并拼入 prompt;缺失 required → 退出码 1(E007),pause session。ralph build 阶段只通过 `maestro ralph skills --platform codex` 校验路径存在性,不读 SKILL.md 内容
71
+ 9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 输出提示词后继续 handoff,用户可在执行过程中随时输入 `/goal`
72
+ 10. **planning_mode governs arg granularity** — `unified` skill args `{phase}`;`independent` → 含 `{phase}`
73
+ 11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
74
+ 12. **Platform** — `session.platform = "codex"`;CLI 调用一律带 `--platform codex`
72
75
  </invariants>
73
76
 
74
77
  <state_machine>
@@ -138,8 +141,8 @@ S_BUILD_CHAIN:
138
141
  → S_CREATE_SESSION DO: A_BUILD_STEPS
139
142
 
140
143
  S_CREATE_SESSION:
141
- → S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
142
- → S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
144
+ → S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
145
+ → S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
143
146
 
144
147
  S_CONFIRM:
145
148
  → S_DISPATCH WHEN: user selects "Proceed"
@@ -147,9 +150,9 @@ S_CONFIRM:
147
150
  → END WHEN: user selects "Cancel"
148
151
 
149
152
  S_DISPATCH:
150
- → END DO: Skill({ skill: "maestro-ralph-execute" })
153
+ → END DO: $maestro-ralph-execute
151
154
 
152
- S_DECISION_EVAL:
155
+ S_DECISION_EVAL: (decision 节点 == `step.decision` 非空,下述 gate 名取自该字段)
153
156
  → S_APPLY_VERDICT WHEN: quality-gate (post-verify, post-business-test, post-review, post-test)
154
157
  DO: A_DELEGATE_EVALUATE
155
158
  → S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
@@ -166,17 +169,18 @@ S_APPLY_VERDICT:
166
169
  → S_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
167
170
  → S_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
168
171
  → S_DISPATCH WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
169
- → S_DISPATCH WHEN: post-milestone + next milestone DO: A_ADVANCE_MILESTONE
170
- → END WHEN: post-milestone + no next milestone DO: mark completed
172
+ → S_DISPATCH WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
173
+ → END WHEN: post-milestone + standard + no next milestone DO: mark completed
174
+ → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
171
175
  → END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
172
176
  GUARD: retry_count >= max_retries → force escalate
173
177
  GUARD: confidence_score < 60 AND proceed → override to fix
174
178
  GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
175
179
  GUARD: auto_confirm → skip user prompt, apply adjusted verdict
176
- GUARD: not auto_confirm → AskUserQuestion with override options
180
+ GUARD: not auto_confirm → request_user_input with override options
177
181
 
178
182
  S_FALLBACK:
179
- → S_PARSE_ROUTE WHEN: user provides input DO: AskUserQuestion
183
+ → S_PARSE_ROUTE WHEN: user provides input DO: request_user_input
180
184
  → END WHEN: user cancels
181
185
 
182
186
  </transitions>
@@ -187,7 +191,7 @@ S_FALLBACK:
187
191
 
188
192
  1. Find latest ralph session (by created_at)
189
193
  2. Display: Session, Status, Position, Progress, Current step
190
- 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision;附 `command_scope`(global/project) + `command_path`
194
+ 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
191
195
  4. If `task_decomposition` present (absent → skip):
192
196
  ```
193
197
  Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
@@ -208,7 +212,7 @@ S_FALLBACK:
208
212
  | 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
209
213
  | 4 | 仍无 → state.json 首个 incomplete phase | false |
210
214
  | 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
211
- | 6 | 仍模糊 → `AskUserQuestion` | 由用户回答确定 |
215
+ | 6 | 仍模糊 → `request_user_input` | 由用户回答确定 |
212
216
 
213
217
  **D-007 Phase→Milestone 反查**(数字 phase 已解析时):
214
218
  ```
@@ -311,9 +315,9 @@ resolve_milestone(phase_number):
311
315
  | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
312
316
  | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
313
317
  | milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
314
- | milestone 含多个 phase + 非 `auto_confirm` | → AskUserQuestion | 征询用户选择 |
318
+ | milestone 含多个 phase + 非 `auto_confirm` | → request_user_input | 征询用户选择 |
315
319
 
316
- **AskUserQuestion** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
320
+ **request_user_input** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
317
321
 
318
322
  ```
319
323
  question: "当前里程碑含 {N} 个 phase,选择规划模式?"
@@ -338,7 +342,7 @@ Runs once before chain build; additive to status.json.
338
342
  | named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
339
343
  | otherwise | medium | clarify unless auto_confirm |
340
344
 
341
- **2. Clarify boundary** (broad/medium) — `AskUserQuestion`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
345
+ **2. Clarify boundary** (broad/medium) — `request_user_input`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
342
346
 
343
347
  | Round | Question | Drives |
344
348
  |-------|----------|--------|
@@ -367,24 +371,26 @@ narrow → derive defaults from intent + codebase, skip questions.
367
371
 
368
372
  Generate steps from `session.lifecycle_position` to `milestone-complete`.
369
373
 
370
- | Stage | Skill (independent) | Skill (unified) | Type | Decision after | quality_mode |
371
- |-------|---------------------|-----------------|------|----------------|--------------|
372
- | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | internal | — | all |
373
- | blueprint | `maestro-blueprint "{intent}"` | *(same)* | internal | — | all |
374
- | init | `maestro-init` | *(same)* | internal | — | all |
375
- | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | internal | `post-analyze-scope` | all |
376
- | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | internal | — | all |
377
- | analyze | `maestro-analyze {phase}` | `maestro-analyze` | internal | — | all |
378
- | 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 |
379
- | execute | `maestro-execute {phase}` | `maestro-execute` | internal | — | all |
380
- | verify | `maestro-verify {phase}` | `maestro-verify` | internal | `post-verify` | all |
381
- | business-test | `quality-auto-test {phase}` | `quality-auto-test` | internal | `post-business-test` | full only |
382
- | review | `quality-review {phase}` | `quality-review` | internal | `post-review` | all (quick: append `--tier quick`) |
383
- | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | internal | — | full / standard if coverage<80% |
384
- | test | `quality-test {phase}` | `quality-test` | internal | `post-test` | full, standard |
385
- | milestone-audit | `maestro-milestone-audit` | *(same)* | internal | — | all |
386
- | goal-audit | *(decision-only)* | *(same)* | decision | `post-goal-audit` | all (only if decomposed) |
387
- | milestone-complete | `maestro-milestone-complete` | *(same)* | internal | `post-milestone` | all |
374
+ | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
375
+ |-------|---------------------|-----------------|----------------|--------------|
376
+ | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
377
+ | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
378
+ | init | `maestro-init` | *(same)* | — | all |
379
+ | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
380
+ | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
381
+ | analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
382
+ | plan | `maestro-plan {phase}` *(scope=phase)* / `maestro-plan --from analyze:{analyze_macro_id}` *(scope=standalone)* / `maestro-plan --from blueprint:{blueprint_id}` *(scope=standalone)* | `maestro-plan` | — | all |
383
+ | execute | `maestro-execute {phase}` | `maestro-execute` | — | all |
384
+ | verify | `maestro-verify {phase}` | `maestro-verify` | `post-verify` | all |
385
+ | business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
386
+ | review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
387
+ | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
388
+ | test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
389
+ | milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
390
+ | goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
391
+ | milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
392
+
393
+ > 所有执行 stage 统一通过 `maestro ralph next` CLI 加载 + 内联执行;decision 节点单独作为独立 step 插入(见规则 4)。
388
394
 
389
395
  **Build rules (按顺序应用):**
390
396
 
@@ -392,17 +398,18 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
392
398
  1. **起点**:从 `session.lifecycle_position` 开始
393
399
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
394
400
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
395
- 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ type: "decision", decision: "<gate>", retry_count: 0, max_retries: 2 }`
401
+ 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
396
402
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
397
403
  6. **终点硬约束**:chain 以 `milestone-complete` 结尾
398
404
  7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
399
405
  8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
400
- 9. **command_path 解析**(每个非 decision step):
406
+ 9. **command_path 解析**(每个执行 step,decision 节点跳过):
401
407
  - 取 skill 名(args 前的第一个 token)
402
- - 全局优先:`~/.claude/commands/{name}.md` 存在 `command_scope = "global"`
403
- - Fallback:`.claude/commands/{name}.md` 存在 → `command_scope = "project"`
404
- - 两者都缺 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
405
- 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`
408
+ - **预校验通过 `Bash("maestro ralph skills --platform codex --json --quiet")`** 一次性拉取所有可用 codex skills(global `~/.codex/skills/` + project `.codex/skills/`,project 覆盖 global),匹配 skill 名得到:
409
+ - 命中 → `command_scope = "global" | "project"`,`command_path = <绝对 SKILL.md 路径>`
410
+ - 未命中 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
411
+ - **不在 build 阶段读取 SKILL.md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
412
+ 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
406
413
  11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
407
414
  - `scope_verdict ∈ {medium, small}` → 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
408
415
  - `scope_verdict == large` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
@@ -418,9 +425,9 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
418
425
  ### A_CREATE_SESSION
419
426
 
420
427
  1. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
421
- 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
428
+ 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema);含 `platform: "codex"`, `cli_tool: "codex"`
422
429
  3. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
423
- 4. If `task_decomposition` present: display the **Goal Prompt block** (Appendix: Goal Prompt Template)
430
+ 4. If `task_decomposition` present: display **Goal Prompt block** (Appendix),不阻塞流程,继续 handoff
424
431
 
425
432
  ### A_DELEGATE_EVALUATE
426
433
 
@@ -454,7 +461,12 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
454
461
 
455
462
  ### A_STRUCTURAL_EVALUATE
456
463
 
457
- **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
+
458
470
  **post-debug-escalate:** Always STOP → set paused, display "请人工介入"
459
471
 
460
472
  ### A_SCOPE_EVALUATE
@@ -535,7 +547,7 @@ Runs only when `task_decomposition` present.
535
547
  - 把下一个未完成的 `plan` step 改为 `maestro-plan --from analyze:{analyze_macro_id}`,去掉 `{phase}`,`source_artifact_ref = analyze:{analyze_macro_id}`
536
548
  - 后续 `execute` / `verify` 等沿用同一 standalone scope(不带 `{phase}`,由 plan 写出的 task 列表驱动)
537
549
  4. 路径 C(`unknown`):
538
- - 非 auto_confirm → AskUserQuestion 二选一(large / medium-small);auto_confirm → 默认 large
550
+ - 非 auto_confirm → request_user_input 二选一(large / medium-small);auto_confirm → 默认 large
539
551
  5. Reindex steps,标 decision completed,write status.json
540
552
  6. Display: ◆ Scope verdict: {verdict} → {kept|collapsed to standalone via analyze:{ANL_ID}}
541
553
 
@@ -576,6 +588,8 @@ Runs only when `task_decomposition` present.
576
588
  {
577
589
  "session_id": "ralph-{YYYYMMDD-HHmmss}",
578
590
  "source": "ralph", "status": "running",
591
+ "ralph_protocol_version": "1", // CLI-driven; absent/0 → legacy inline ralph-execute
592
+ "active_step_index": null, // CLI-managed; only one step held at a time
579
593
  "intent": "", "lifecycle_position": "",
580
594
  "phase": null, "phase_is_new": false,
581
595
  "milestone": "", // D-007 反查结果,禁止读 current_milestone
@@ -585,18 +599,22 @@ Runs only when `task_decomposition` present.
585
599
  "scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
586
600
  "analyze_macro_id": null, // "ANL-xxx" 来自最新 macro analyze
587
601
  "blueprint_id": null, // "BLP-xxx" 若存在
588
- "cli_tool": "claude", "passed_gates": [],
602
+ "cli_tool": "codex",
603
+ "platform": "codex", // codex skills (`.codex/skills/`)
604
+ "passed_gates": [],
589
605
  "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
590
606
  "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
591
607
  "steps": [{
592
608
  "index": 0,
593
- "type": "internal|external|decision",
594
- "skill": "",
609
+ "skill": "", // 执行 step 有值;decision 节点为空字符串/null
595
610
  "args": "",
596
611
  "stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|verify|...
597
612
  "scope": null, // "phase"|"standalone"|"milestone"|null(plan 等需要)
598
- "command_scope": "global|project|missing|null",
599
- "command_path": "~/.claude/commands/{name}.md | .claude/commands/{name}.md | null",
613
+ "decision": null, // 非 null → decision 节点(值为 gate 名,如 "post-verify");null → 执行 step
614
+ "retry_count": 0, // decision 节点专用
615
+ "max_retries": 2, // decision 节点专用
616
+ "command_scope": "global|project|missing|null", // 执行 step;decision 节点固定 null
617
+ "command_path": "<absolute SKILL.md path resolved by `maestro ralph skills --platform codex --json --quiet`> | null",
600
618
  "milestone_id": null, // D-007 反查注入;仅含 {phase} 占位符的 step 有
601
619
  "source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
602
620
  "status": "pending|running|completed|skipped|failed",
@@ -604,7 +622,9 @@ Runs only when `task_decomposition` present.
604
622
  "completion_confirmed": false,
605
623
  "completion_status": null,
606
624
  "completion_evidence": null,
607
- "completed_at": null
625
+ "completed_at": null,
626
+ "deferred_reads": [], // 由 ralph next CLI 解析 SKILL.md 时填充
627
+ "load": null // { loaded_at, required_files[], deferred_files[], resolve_version } —— 由 ralph next 写入
608
628
  }],
609
629
  "waves": [], "current_step": 0,
610
630
 
@@ -626,7 +646,7 @@ Runs only when `task_decomposition` present.
626
646
 
627
647
  ### Fix-Loop Templates
628
648
 
629
- 所有插入 step 默认 `type: "internal"`,按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`。
649
+ 所有插入的执行 step A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点(`step.decision` 字段)。
630
650
 
631
651
  **post-verify:**
632
652
  ```
@@ -688,14 +708,12 @@ decision:post-goal-audit {retry+1}
688
708
  链路概览后逐字显示(仅当 decomposition 已产出):
689
709
 
690
710
  ```
691
- 📋 任务分解完成。复制下面一行设定目标,会话在子目标全部达成前不停:
692
-
693
- /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。
711
+ 📋 任务分解完成。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
694
712
 
695
- 随后运行 /maestro-ralph continue 立即开始执行。
713
+ /goal 直到 {session_dir}/status.json 的 task_decomposition[*] 与 steps[*] 全部 completion_confirmed=true 才停。每轮以 status.json 为唯一行动手册,通过 /maestro-ralph-execute 推进 step;decision 节点由其自动 handoff 回 ralph 评估。禁止手动执行 skill 或修改 boundary_contract.out_of_scope。
696
714
  ```
697
715
 
698
- `/goal` 由用户输入;ralph 只输出此提示词。判据以 status.json 为权威。
716
+ `/goal` 由用户输入;ralph 输出提示词后继续 handoff,不阻塞。
699
717
 
700
718
  ### Error Codes
701
719
 
@@ -727,14 +745,16 @@ decision:post-goal-audit {retry+1}
727
745
  - [ ] quality_mode 由 A_DETERMINE_QUALITY_MODE 决定,过滤 build steps
728
746
  - [ ] Decomposition: broad intent ≤3 question clarify;narrow auto-derive
729
747
  - [ ] status.json 唯一真源:boundary_contract + execution_criteria + task_decomposition;无外部清单
730
- - [ ] 每个 step 默认 `type: "internal"`,含 `command_scope` + `command_path`(全局优先 fallback 项目)
731
- - [ ] 每个 step `completion_confirmed` + `completion_status` + `completion_evidence`(初始 false/null)
748
+ - [ ] 执行 step `command_scope` + `command_path`(通过 `maestro ralph skills --platform codex --json --quiet` 预校验,project 覆盖 global);decision step 通过 `step.decision` 字段标识
749
+ - [ ] Ralph build 阶段只通过 `ralph skills --platform codex` 校验路径存在性,不读 SKILL.md 内容;`<required_reading>` 加载由 `maestro ralph next` CLI 完成
750
+ - [ ] 每个 step 含 `completion_confirmed` + `completion_status` + `completion_evidence` + `deferred_reads`(初始 false/null/[])
732
751
  - [ ] 每个 sub-goal 含 `completion_confirmed`(初始 false)
733
752
  - [ ] post-goal-audit decision 仅在 decomposed 时插入,位于 milestone-complete 之前
734
753
  - [ ] Unmet sub-goals 动态 grow steps[](goal_ref tagged);max retries → escalate
735
754
  - [ ] planning_mode 显式决定;unified=无 `{phase}`, independent=带 `{phase}`
736
755
  - [ ] Chain 必须以 `milestone-complete` 结尾
737
756
  - [ ] Decision nodes 由 maestro delegate --role analyze 评估
738
- - [ ] Ralph 不执行 step,只 evaluate;Skill("maestro-ralph-execute") handoff
757
+ - [ ] Ralph 不执行 step,只 evaluate;`$maestro-ralph-execute` 直调 handoff
758
+ - [ ] session.platform = "codex";所有 CLI 调用携带 `--platform codex`
739
759
 
740
760
  </appendix>