maestro-flow 0.4.16 → 0.4.18

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 (105) hide show
  1. package/.agents/skills/maestro/SKILL.md +1 -1
  2. package/.agents/skills/maestro-analyze/SKILL.md +5 -0
  3. package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
  4. package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
  5. package/.agents/skills/maestro-init/SKILL.md +1 -1
  6. package/.agents/skills/maestro-next/SKILL.md +219 -0
  7. package/.agents/skills/maestro-ralph-beta/SKILL.md +893 -0
  8. package/.agy/skills/maestro/SKILL.md +1 -1
  9. package/.agy/skills/maestro-analyze/SKILL.md +5 -0
  10. package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
  11. package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
  12. package/.agy/skills/maestro-init/SKILL.md +1 -1
  13. package/.agy/skills/maestro-next/SKILL.md +215 -0
  14. package/.agy/skills/maestro-ralph-beta/SKILL.md +889 -0
  15. package/.claude/commands/maestro-analyze.md +5 -0
  16. package/.claude/commands/maestro-blueprint.md +5 -0
  17. package/.claude/commands/maestro-brainstorm.md +5 -0
  18. package/.claude/commands/maestro-init.md +1 -1
  19. package/.claude/commands/maestro-next.md +217 -0
  20. package/.claude/commands/maestro-ralph-beta.md +891 -0
  21. package/.claude/commands/maestro.md +1 -1
  22. package/.codex/skills/learn-decompose/SKILL.md +34 -3
  23. package/.codex/skills/learn-retro/SKILL.md +31 -1
  24. package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
  25. package/.codex/skills/maestro-analyze/SKILL.md +44 -5
  26. package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
  27. package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
  28. package/.codex/skills/maestro-execute/SKILL.md +61 -5
  29. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
  30. package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
  31. package/.codex/skills/maestro-plan/SKILL.md +36 -1
  32. package/.codex/skills/maestro-player/SKILL.md +25 -6
  33. package/.codex/skills/maestro-ralph/SKILL.md +108 -81
  34. package/.codex/skills/maestro-ralph-beta/SKILL.md +891 -0
  35. package/.codex/skills/maestro-ralph-execute/SKILL.md +244 -0
  36. package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
  37. package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
  38. package/.codex/skills/maestro-verify/SKILL.md +40 -5
  39. package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
  40. package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
  41. package/.codex/skills/quality-auto-test/SKILL.md +70 -16
  42. package/.codex/skills/quality-debug/SKILL.md +139 -28
  43. package/.codex/skills/quality-refactor/SKILL.md +61 -11
  44. package/.codex/skills/quality-review/SKILL.md +45 -9
  45. package/.codex/skills/quality-test/SKILL.md +58 -3
  46. package/.codex/skills/security-audit/SKILL.md +38 -0
  47. package/.codex/skills/spec-map/SKILL.md +65 -8
  48. package/.codex/skills/team-coordinate/SKILL.md +28 -11
  49. package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
  50. package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
  51. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
  52. package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
  53. package/.codex/skills/team-review/SKILL.md +42 -2
  54. package/.codex/skills/team-tech-debt/SKILL.md +45 -2
  55. package/.codex/skills/team-testing/SKILL.md +42 -2
  56. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
  57. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
  58. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  59. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
  60. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
  61. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  62. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  63. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
  64. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  65. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
  66. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  67. package/dist/src/commands/install-backend.d.ts.map +1 -1
  68. package/dist/src/commands/install-backend.js +23 -4
  69. package/dist/src/commands/install-backend.js.map +1 -1
  70. package/dist/src/commands/ralph.d.ts.map +1 -1
  71. package/dist/src/commands/ralph.js +3 -1
  72. package/dist/src/commands/ralph.js.map +1 -1
  73. package/dist/src/ralph/cmd-check.js +1 -1
  74. package/dist/src/ralph/cmd-check.js.map +1 -1
  75. package/dist/src/ralph/cmd-complete.js +1 -1
  76. package/dist/src/ralph/cmd-complete.js.map +1 -1
  77. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  78. package/dist/src/ralph/cmd-next.js +56 -5
  79. package/dist/src/ralph/cmd-next.js.map +1 -1
  80. package/dist/src/ralph/cmd-session.js +2 -2
  81. package/dist/src/ralph/cmd-session.js.map +1 -1
  82. package/dist/src/ralph/cmd-skills.d.ts +2 -0
  83. package/dist/src/ralph/cmd-skills.d.ts.map +1 -1
  84. package/dist/src/ralph/cmd-skills.js +11 -4
  85. package/dist/src/ralph/cmd-skills.js.map +1 -1
  86. package/dist/src/ralph/skill-scanner.d.ts +7 -2
  87. package/dist/src/ralph/skill-scanner.d.ts.map +1 -1
  88. package/dist/src/ralph/skill-scanner.js +39 -24
  89. package/dist/src/ralph/skill-scanner.js.map +1 -1
  90. package/dist/src/ralph/status-schema.d.ts +2 -0
  91. package/dist/src/ralph/status-schema.d.ts.map +1 -1
  92. package/dist/src/ralph/status-store.d.ts +8 -1
  93. package/dist/src/ralph/status-store.d.ts.map +1 -1
  94. package/dist/src/ralph/status-store.js +12 -2
  95. package/dist/src/ralph/status-store.js.map +1 -1
  96. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  97. package/dist/src/tools/store-knowhow.js +51 -64
  98. package/dist/src/tools/store-knowhow.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/finish-work.md +119 -0
  104. package/workflows/init.md +11 -11
  105. package/workflows/milestone-complete.md +23 -1
@@ -1,24 +1,30 @@
1
1
  ---
2
2
  name: maestro-ralph
3
3
  description: Use when the optimal command sequence is unclear and needs automated state-based determination
4
- argument-hint: "<intent> [-y] | status | continue"
5
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Skill, request_user_input
4
+ argument-hint: "<intent> [-y] | status [session-id] | continue [session-id]"
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
- Entry points:
12
- - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → execute
13
- - **`/maestro-ralph continue`** Resume via maestro-ralph-execute
14
- - **`/maestro-ralph status`** — Display session progress
11
+ ### Session
12
+
13
+ `.workflow/.maestro/{session_id}/status.json` — 工作流唯一真源(schema 见 `<appendix>`)。session_id 格式:`ralph-{YYYYMMDD-HHmmss}`(本 skill 创建,自适应链)或 `maestro-{YYYYMMDD-HHmmss}`(`/maestro` coordinator 创建,静态链)。两类都由 `/maestro-ralph-execute` 推进。session-id 省略时取最新 `status=="running"`。
14
+
15
+ ### Entry points
16
+
17
+ - **`/maestro-ralph "intent"`** — 新建 session:infer → decompose → build → emit /goal prompt(如有 decomposition)→ dispatch ralph-execute
18
+ - **`/maestro-ralph continue [session-id]`** — 恢复执行;省略=最新 running(首选直接 `/maestro-ralph-execute [session-id]`)
19
+ - **`/maestro-ralph status [session-id]`** — 显示进度;省略=最新 ralph session
20
+
21
+ > 推进规则:**step 推进由 `/maestro-ralph-execute` 负责**;ralph 仅在 build / decision 评估时介入。decision 节点由 ralph-execute 自动 `$maestro-ralph` 直调 handoff,无需用户手动切换。
15
22
 
16
23
  Initial decomposition (S_DECOMPOSE): boundary-clarified via ≤3 questions for broad intents (重构/全面/迁移/重写). 写入 status.json 的 `boundary_contract` / `execution_criteria` / `task_decomposition`,附 `/goal` prompt。
17
24
 
18
- Node types:
19
- - **internal** (default): ralph-execute `Read({command_path})` 命令 .md,按内容内联执行
20
- - **decision**: ralph 评估
21
- - **external**: 仅在显式声明时使用(`maestro delegate --to claude`)
25
+ Step kinds:
26
+ - **执行 step**: ralph-execute `Bash("maestro ralph next")` 加载 SKILL.md + required_reading 全文,按 stdout 内联执行
27
+ - **decision step**: `step.decision` 字段非空;回 ralph 评估(CLI 只读分析)
22
28
 
23
29
  Key difference from maestro coordinator:
24
30
  - maestro: static chain → one-time selection → runs all steps
@@ -35,9 +41,9 @@ Mutual invocation with `/maestro-ralph-execute` forms a self-perpetuating work l
35
41
  │ writes status.json
36
42
  │ emits /goal prompt
37
43
 
38
- ralph-execute ◀─┐ internalRead(command_path) inline
39
- │ │ decision → Skill("maestro-ralph")
40
- └─────────┘ writes step.completion_confirmed
44
+ ralph-execute ◀─┐ 执行 step `maestro ralph next` + inline + `ralph complete`
45
+ │ │ decision step $maestro-ralph
46
+ └─────────┘ CLI writes step.completion_confirmed
41
47
  loop until all completion_confirmed | paused
42
48
  ```
43
49
  </purpose>
@@ -47,9 +53,10 @@ $ARGUMENTS — intent text, flags, or keywords.
47
53
 
48
54
  **Parse:**
49
55
  ```
50
- -y flag → auto_confirm = true
51
- .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
52
- Remaining → intent
56
+ -y flag → auto_confirm = true
57
+ .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
58
+ status|continue + session-idintent ∈ {status,continue} 且后续 token 匹配 ralph-*|maestro-* → target_session_id
59
+ Remaining → intent
53
60
  ```
54
61
 
55
62
  **State files:**
@@ -60,15 +67,17 @@ Remaining → intent
60
67
 
61
68
  <invariants>
62
69
  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
70
+ 2. **Handoff via `$maestro-ralph-execute` 直调** 创建 session 后始终自动 handoff;decision 评估后始终 handoff
64
71
  3. **Decision delegates read-only** — `maestro delegate --role analyze --mode analysis`
65
- 4. **Default type = internal** `external` 仅显式标注时出现,build 不默认生成
72
+ 4. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(详见 invariant 8)
66
73
  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;字段可选/累加,既有字段不删不改
74
+ 6. **每个 step 必须 `completion_confirmed: true`** — `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
75
+ 7. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform codex --json --quiet` 预校验(project 覆盖 global,限定 `.codex/skills/`),命中即写绝对路径到 status.json;未命中标 `command_scope = "missing"`
76
+ 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 内容
77
+ 9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 输出提示词后继续 handoff,用户可在执行过程中随时输入 `/goal`
78
+ 10. **planning_mode governs arg granularity** — `unified` skill args `{phase}`;`independent` → 含 `{phase}`
79
+ 11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
80
+ 12. **Platform** — `session.platform = "codex"`;CLI 调用一律带 `--platform codex`
72
81
  </invariants>
73
82
 
74
83
  <state_machine>
@@ -105,7 +114,8 @@ S_STATUS:
105
114
  → END DO: A_SHOW_STATUS
106
115
 
107
116
  S_CONTINUE:
108
- → S_DISPATCH WHEN: running session found
117
+ → S_DISPATCH WHEN: target_session_id provided AND session exists
118
+ → S_DISPATCH WHEN: running session found (no target_session_id → latest running)
109
119
  → S_FALLBACK WHEN: no running session DO: display "无运行中的 ralph 会话"
110
120
 
111
121
  S_RESOLVE_PHASE:
@@ -138,8 +148,8 @@ S_BUILD_CHAIN:
138
148
  → S_CREATE_SESSION DO: A_BUILD_STEPS
139
149
 
140
150
  S_CREATE_SESSION:
141
- → S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
142
- → S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
151
+ → S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
152
+ → S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
143
153
 
144
154
  S_CONFIRM:
145
155
  → S_DISPATCH WHEN: user selects "Proceed"
@@ -147,9 +157,9 @@ S_CONFIRM:
147
157
  → END WHEN: user selects "Cancel"
148
158
 
149
159
  S_DISPATCH:
150
- → END DO: Skill({ skill: "maestro-ralph-execute" })
160
+ → END DO: $maestro-ralph-execute
151
161
 
152
- S_DECISION_EVAL:
162
+ S_DECISION_EVAL: (decision 节点 == `step.decision` 非空,下述 gate 名取自该字段)
153
163
  → S_APPLY_VERDICT WHEN: quality-gate (post-verify, post-business-test, post-review, post-test)
154
164
  DO: A_DELEGATE_EVALUATE
155
165
  → S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
@@ -166,17 +176,18 @@ S_APPLY_VERDICT:
166
176
  → S_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
167
177
  → S_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
168
178
  → 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
179
+ → S_DISPATCH WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
180
+ → END WHEN: post-milestone + standard + no next milestone DO: mark completed
181
+ → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
171
182
  → END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
172
183
  GUARD: retry_count >= max_retries → force escalate
173
184
  GUARD: confidence_score < 60 AND proceed → override to fix
174
185
  GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
175
186
  GUARD: auto_confirm → skip user prompt, apply adjusted verdict
176
- GUARD: not auto_confirm → AskUserQuestion with override options
187
+ GUARD: not auto_confirm → request_user_input with override options
177
188
 
178
189
  S_FALLBACK:
179
- → S_PARSE_ROUTE WHEN: user provides input DO: AskUserQuestion
190
+ → S_PARSE_ROUTE WHEN: user provides input DO: request_user_input
180
191
  → END WHEN: user cancels
181
192
 
182
193
  </transitions>
@@ -185,9 +196,9 @@ S_FALLBACK:
185
196
 
186
197
  ### A_SHOW_STATUS
187
198
 
188
- 1. Find latest ralph session (by created_at)
199
+ 1. `target_session_id` 提供 → 直接加载 `.workflow/.maestro/{target_session_id}/status.json`;否则取最新 ralph sessionby created_at
189
200
  2. Display: Session, Status, Position, Progress, Current step
190
- 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision;附 `command_scope`(global/project) + `command_path`
201
+ 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
191
202
  4. If `task_decomposition` present (absent → skip):
192
203
  ```
193
204
  Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
@@ -208,7 +219,7 @@ S_FALLBACK:
208
219
  | 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
209
220
  | 4 | 仍无 → state.json 首个 incomplete phase | false |
210
221
  | 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
211
- | 6 | 仍模糊 → `AskUserQuestion` | 由用户回答确定 |
222
+ | 6 | 仍模糊 → `request_user_input` | 由用户回答确定 |
212
223
 
213
224
  **D-007 Phase→Milestone 反查**(数字 phase 已解析时):
214
225
  ```
@@ -311,9 +322,9 @@ resolve_milestone(phase_number):
311
322
  | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
312
323
  | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
313
324
  | milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
314
- | milestone 含多个 phase + 非 `auto_confirm` | → AskUserQuestion | 征询用户选择 |
325
+ | milestone 含多个 phase + 非 `auto_confirm` | → request_user_input | 征询用户选择 |
315
326
 
316
- **AskUserQuestion** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
327
+ **request_user_input** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
317
328
 
318
329
  ```
319
330
  question: "当前里程碑含 {N} 个 phase,选择规划模式?"
@@ -338,7 +349,7 @@ Runs once before chain build; additive to status.json.
338
349
  | named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
339
350
  | otherwise | medium | clarify unless auto_confirm |
340
351
 
341
- **2. Clarify boundary** (broad/medium) — `AskUserQuestion`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
352
+ **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
353
 
343
354
  | Round | Question | Drives |
344
355
  |-------|----------|--------|
@@ -367,24 +378,26 @@ narrow → derive defaults from intent + codebase, skip questions.
367
378
 
368
379
  Generate steps from `session.lifecycle_position` to `milestone-complete`.
369
380
 
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 |
381
+ | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
382
+ |-------|---------------------|-----------------|----------------|--------------|
383
+ | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
384
+ | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
385
+ | init | `maestro-init` | *(same)* | — | all |
386
+ | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
387
+ | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
388
+ | analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
389
+ | 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 |
390
+ | execute | `maestro-execute {phase}` | `maestro-execute` | — | all |
391
+ | verify | `maestro-verify {phase}` | `maestro-verify` | `post-verify` | all |
392
+ | business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
393
+ | review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
394
+ | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
395
+ | test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
396
+ | milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
397
+ | goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
398
+ | milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
399
+
400
+ > 所有执行 stage 统一通过 `maestro ralph next` CLI 加载 + 内联执行;decision 节点单独作为独立 step 插入(见规则 4)。
388
401
 
389
402
  **Build rules (按顺序应用):**
390
403
 
@@ -392,17 +405,18 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
392
405
  1. **起点**:从 `session.lifecycle_position` 开始
393
406
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
394
407
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
395
- 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ type: "decision", decision: "<gate>", retry_count: 0, max_retries: 2 }`
408
+ 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
396
409
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
397
410
  6. **终点硬约束**:chain 以 `milestone-complete` 结尾
398
411
  7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
399
412
  8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
400
- 9. **command_path 解析**(每个非 decision step):
413
+ 9. **command_path 解析**(每个执行 step,decision 节点跳过):
401
414
  - 取 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`
415
+ - **预校验通过 `Bash("maestro ralph skills --platform codex --json --quiet")`** 一次性拉取所有可用 codex skills(global `~/.codex/skills/` + project `.codex/skills/`,project 覆盖 global),匹配 skill 名得到:
416
+ - 命中 → `command_scope = "global" | "project"`,`command_path = <绝对 SKILL.md 路径>`
417
+ - 未命中 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
418
+ - **不在 build 阶段读取 SKILL.md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
419
+ 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
406
420
  11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
407
421
  - `scope_verdict ∈ {medium, small}` → 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
408
422
  - `scope_verdict == large` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
@@ -418,9 +432,9 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
418
432
  ### A_CREATE_SESSION
419
433
 
420
434
  1. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
421
- 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
435
+ 2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema);含 `platform: "codex"`, `cli_tool: "codex"`
422
436
  3. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
423
- 4. If `task_decomposition` present: display the **Goal Prompt block** (Appendix: Goal Prompt Template)
437
+ 4. If `task_decomposition` present: display **Goal Prompt block** (Appendix),不阻塞流程,继续 handoff
424
438
 
425
439
  ### A_DELEGATE_EVALUATE
426
440
 
@@ -454,7 +468,12 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
454
468
 
455
469
  ### A_STRUCTURAL_EVALUATE
456
470
 
457
- **post-milestone:** Read state.json → next milestone? → insert lifecycle steps / complete
471
+ **post-milestone:**
472
+ 1. Read state.json → resolve completed milestone object
473
+ 2. Determine milestone type: `milestone_obj.type` (default `"standard"` if missing)
474
+ 3. **Standard milestone** (`type != "adhoc"`): next milestone exists? → insert lifecycle steps / complete
475
+ 4. **Adhoc milestone** (`type == "adhoc"`): always END — adhoc milestones are self-contained, no successor to advance to. Set `current_milestone = null`.
476
+
458
477
  **post-debug-escalate:** Always STOP → set paused, display "请人工介入"
459
478
 
460
479
  ### A_SCOPE_EVALUATE
@@ -535,7 +554,7 @@ Runs only when `task_decomposition` present.
535
554
  - 把下一个未完成的 `plan` step 改为 `maestro-plan --from analyze:{analyze_macro_id}`,去掉 `{phase}`,`source_artifact_ref = analyze:{analyze_macro_id}`
536
555
  - 后续 `execute` / `verify` 等沿用同一 standalone scope(不带 `{phase}`,由 plan 写出的 task 列表驱动)
537
556
  4. 路径 C(`unknown`):
538
- - 非 auto_confirm → AskUserQuestion 二选一(large / medium-small);auto_confirm → 默认 large
557
+ - 非 auto_confirm → request_user_input 二选一(large / medium-small);auto_confirm → 默认 large
539
558
  5. Reindex steps,标 decision completed,write status.json
540
559
  6. Display: ◆ Scope verdict: {verdict} → {kept|collapsed to standalone via analyze:{ANL_ID}}
541
560
 
@@ -576,6 +595,8 @@ Runs only when `task_decomposition` present.
576
595
  {
577
596
  "session_id": "ralph-{YYYYMMDD-HHmmss}",
578
597
  "source": "ralph", "status": "running",
598
+ "ralph_protocol_version": "1", // CLI-driven; absent/0 → legacy inline ralph-execute
599
+ "active_step_index": null, // CLI-managed; only one step held at a time
579
600
  "intent": "", "lifecycle_position": "",
580
601
  "phase": null, "phase_is_new": false,
581
602
  "milestone": "", // D-007 反查结果,禁止读 current_milestone
@@ -585,18 +606,22 @@ Runs only when `task_decomposition` present.
585
606
  "scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
586
607
  "analyze_macro_id": null, // "ANL-xxx" 来自最新 macro analyze
587
608
  "blueprint_id": null, // "BLP-xxx" 若存在
588
- "cli_tool": "claude", "passed_gates": [],
609
+ "cli_tool": "codex",
610
+ "platform": "codex", // codex skills (`.codex/skills/`)
611
+ "passed_gates": [],
589
612
  "context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
590
613
  "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
591
614
  "steps": [{
592
615
  "index": 0,
593
- "type": "internal|external|decision",
594
- "skill": "",
616
+ "skill": "", // 执行 step 有值;decision 节点为空字符串/null
595
617
  "args": "",
596
618
  "stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|verify|...
597
619
  "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",
620
+ "decision": null, // 非 null → decision 节点(值为 gate 名,如 "post-verify");null → 执行 step
621
+ "retry_count": 0, // decision 节点专用
622
+ "max_retries": 2, // decision 节点专用
623
+ "command_scope": "global|project|missing|null", // 执行 step;decision 节点固定 null
624
+ "command_path": "<absolute SKILL.md path resolved by `maestro ralph skills --platform codex --json --quiet`> | null",
600
625
  "milestone_id": null, // D-007 反查注入;仅含 {phase} 占位符的 step 有
601
626
  "source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
602
627
  "status": "pending|running|completed|skipped|failed",
@@ -604,7 +629,9 @@ Runs only when `task_decomposition` present.
604
629
  "completion_confirmed": false,
605
630
  "completion_status": null,
606
631
  "completion_evidence": null,
607
- "completed_at": null
632
+ "completed_at": null,
633
+ "deferred_reads": [], // 由 ralph next CLI 解析 SKILL.md 时填充
634
+ "load": null // { loaded_at, required_files[], deferred_files[], resolve_version } —— 由 ralph next 写入
608
635
  }],
609
636
  "waves": [], "current_step": 0,
610
637
 
@@ -626,7 +653,7 @@ Runs only when `task_decomposition` present.
626
653
 
627
654
  ### Fix-Loop Templates
628
655
 
629
- 所有插入 step 默认 `type: "internal"`,按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`。
656
+ 所有插入的执行 step A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点(`step.decision` 字段)。
630
657
 
631
658
  **post-verify:**
632
659
  ```
@@ -688,14 +715,12 @@ decision:post-goal-audit {retry+1}
688
715
  链路概览后逐字显示(仅当 decomposition 已产出):
689
716
 
690
717
  ```
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。
718
+ 📋 任务分解完成。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
694
719
 
695
- 随后运行 /maestro-ralph continue 立即开始执行。
720
+ /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
721
  ```
697
722
 
698
- `/goal` 由用户输入;ralph 只输出此提示词。判据以 status.json 为权威。
723
+ `/goal` 由用户输入;ralph 输出提示词后继续 handoff,不阻塞。
699
724
 
700
725
  ### Error Codes
701
726
 
@@ -727,14 +752,16 @@ decision:post-goal-audit {retry+1}
727
752
  - [ ] quality_mode 由 A_DETERMINE_QUALITY_MODE 决定,过滤 build steps
728
753
  - [ ] Decomposition: broad intent ≤3 question clarify;narrow auto-derive
729
754
  - [ ] 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)
755
+ - [ ] 执行 step `command_scope` + `command_path`(通过 `maestro ralph skills --platform codex --json --quiet` 预校验,project 覆盖 global);decision step 通过 `step.decision` 字段标识
756
+ - [ ] Ralph build 阶段只通过 `ralph skills --platform codex` 校验路径存在性,不读 SKILL.md 内容;`<required_reading>` 加载由 `maestro ralph next` CLI 完成
757
+ - [ ] 每个 step 含 `completion_confirmed` + `completion_status` + `completion_evidence` + `deferred_reads`(初始 false/null/[])
732
758
  - [ ] 每个 sub-goal 含 `completion_confirmed`(初始 false)
733
759
  - [ ] post-goal-audit decision 仅在 decomposed 时插入,位于 milestone-complete 之前
734
760
  - [ ] Unmet sub-goals 动态 grow steps[](goal_ref tagged);max retries → escalate
735
761
  - [ ] planning_mode 显式决定;unified=无 `{phase}`, independent=带 `{phase}`
736
762
  - [ ] Chain 必须以 `milestone-complete` 结尾
737
763
  - [ ] Decision nodes 由 maestro delegate --role analyze 评估
738
- - [ ] Ralph 不执行 step,只 evaluate;Skill("maestro-ralph-execute") handoff
764
+ - [ ] Ralph 不执行 step,只 evaluate;`$maestro-ralph-execute` 直调 handoff
765
+ - [ ] session.platform = "codex";所有 CLI 调用携带 `--platform codex`
739
766
 
740
767
  </appendix>