maestro-flow 0.4.14 → 0.4.16

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 +22 -42
  2. package/.agents/skills/maestro-plan/SKILL.md +10 -9
  3. package/.agents/skills/maestro-ralph/SKILL.md +61 -55
  4. package/.agents/skills/maestro-ralph-execute/SKILL.md +66 -109
  5. package/.agents/skills/manage-knowledge-audit/SKILL.md +90 -0
  6. package/.agy/skills/maestro/SKILL.md +22 -42
  7. package/.agy/skills/maestro-plan/SKILL.md +10 -9
  8. package/.agy/skills/maestro-ralph/SKILL.md +61 -55
  9. package/.agy/skills/maestro-ralph-execute/SKILL.md +66 -109
  10. package/.agy/skills/manage-knowledge-audit/SKILL.md +90 -0
  11. package/.claude/commands/maestro-plan.md +10 -9
  12. package/.claude/commands/maestro-ralph-execute.md +66 -109
  13. package/.claude/commands/maestro-ralph.md +61 -55
  14. package/.claude/commands/maestro.md +22 -42
  15. package/.claude/commands/manage-knowledge-audit.md +88 -0
  16. package/dist/src/cli.js +1 -0
  17. package/dist/src/cli.js.map +1 -1
  18. package/dist/src/commands/font-guide.d.ts +13 -0
  19. package/dist/src/commands/font-guide.d.ts.map +1 -0
  20. package/dist/src/commands/font-guide.js +114 -0
  21. package/dist/src/commands/font-guide.js.map +1 -0
  22. package/dist/src/commands/hooks.d.ts +30 -3
  23. package/dist/src/commands/hooks.d.ts.map +1 -1
  24. package/dist/src/commands/hooks.js +138 -11
  25. package/dist/src/commands/hooks.js.map +1 -1
  26. package/dist/src/commands/install-backend.d.ts +49 -4
  27. package/dist/src/commands/install-backend.d.ts.map +1 -1
  28. package/dist/src/commands/install-backend.js +163 -53
  29. package/dist/src/commands/install-backend.js.map +1 -1
  30. package/dist/src/commands/install.d.ts.map +1 -1
  31. package/dist/src/commands/install.js +50 -10
  32. package/dist/src/commands/install.js.map +1 -1
  33. package/dist/src/commands/ralph.d.ts +6 -0
  34. package/dist/src/commands/ralph.d.ts.map +1 -0
  35. package/dist/src/commands/ralph.js +133 -0
  36. package/dist/src/commands/ralph.js.map +1 -0
  37. package/dist/src/commands/uninstall.d.ts.map +1 -1
  38. package/dist/src/commands/uninstall.js +25 -38
  39. package/dist/src/commands/uninstall.js.map +1 -1
  40. package/dist/src/core/manifest.d.ts +45 -0
  41. package/dist/src/core/manifest.d.ts.map +1 -1
  42. package/dist/src/core/manifest.js +37 -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 +158 -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 +6 -0
  64. package/dist/src/ralph/cmd-skills.d.ts.map +1 -0
  65. package/dist/src/ralph/cmd-skills.js +55 -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 +15 -0
  72. package/dist/src/ralph/skill-scanner.d.ts.map +1 -0
  73. package/dist/src/ralph/skill-scanner.js +122 -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 +94 -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 +14 -5
  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 +89 -45
  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/tui/uninstall-ui/UninstallFlow.d.ts.map +1 -1
  100. package/dist/src/tui/uninstall-ui/UninstallFlow.js +12 -28
  101. package/dist/src/tui/uninstall-ui/UninstallFlow.js.map +1 -1
  102. package/dist/src/utils/update-notices.js +12 -0
  103. package/dist/src/utils/update-notices.js.map +1 -1
  104. package/package.json +1 -1
  105. package/workflows/knowledge-audit.md +358 -0
@@ -31,32 +31,29 @@ Remaining → session_id (if matches maestro-* or ralph-*)
31
31
  ```
32
32
  Also read `session.auto_mode` from status.json — if true, treat as `-y`.
33
33
 
34
- **Node types:**
34
+ **Step kinds:**
35
35
 
36
- | Type | Execution | Flow after |
37
- |------|-----------|------------|
38
- | decision (ralph-only) | `invoke_skill("maestro-ralph")` | Execution ends here |
39
- | internal (default) | `read_file({file_path: step.command_path})` + 内联解释执行 | Self-invoke next |
40
- | external (opt-in) | `maestro delegate --to claude --mode write` (STOP → callback) | Self-invoke next |
36
+ | Kind | Identifier | Execution | Flow after |
37
+ |------|-----------|-----------|------------|
38
+ | decision step | `step.decision` 非空 | `invoke_skill("maestro-ralph")` | Execution ends here |
39
+ | 执行 step | `step.decision == null` | `shell("maestro ralph next")` 内联按其 stdout 执行 → `shell("maestro ralph complete N --status ...")` | Self-invoke next |
41
40
 
42
41
  HARD RULES:
43
- - internal step:优先通过 `read_file({command_path})` 把命令 .md 加载进当前会话,再按内容执行;不要对 internal step 使用 `invoke_skill({skill})` 调用
44
- - **必须遵循 `<required_reading>` / `<deferred_reading>` 标签**:命令 .md 通常采用"入口 + workflow"形式,主体逻辑放在 workflow 文件中并通过 `<required_reading>` 引用;不加载 required_reading 会导致命令执行不完整
45
- - decision 节点例外:A_EXEC_DECISION 必须使用 `invoke_skill({ skill: "maestro-ralph" })` 进行 handoff(这是 decision 节点的唯一允许用法)
46
- - `command_path` ralph A_BUILD_STEPS 写入 status.json;ralph-execute 不再自行解析(缺失 报错 E002)
47
- - external 仅在 `step.type == "external"` 显式声明时使用,并 always append `-y` 到 prompt args
48
- - 每个 step 必须产出 `--- COMPLETION STATUS ---` 块,否则视为 NEEDS_RETRY
42
+ - 执行 step:**统一通过 `maestro ralph next` CLI 加载**。CLI 负责读 command_path、解析 `<required_reading>` + `<deferred_reading>`、拼接 prompt、写 `step.load.*` + `active_step_index` + `step.status="running"`。不要再在会话里手动 Read + 解析 required_reading
43
+ - decision step:A_EXEC_DECISION 通过 `invoke_skill({ skill: "maestro-ralph" })` handoff ralph 评估(不走 CLI)
44
+ - `command_path` ralph A_BUILD_STEPS 写入 status.json(缺失 → ralph next 返回 E006/E007 并拒绝执行)
45
+ - 每个 step 结束必须调用 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`。STATUS 4 个合法值:`DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`(**`NEEDS_CONTEXT` 已废除**,context 容量由 harness 自动压缩处理)
49
46
  </context>
50
47
 
51
48
  <invariants>
52
- 1. **Internal = Read + inline**通过 Read 读取 `step.command_path`,按其指令在当前 session 内执行
53
- 2. **Required reading must be loaded**命令 .md 中的 `<required_reading>` 引用的所有文件必须立即 Read;缺一 视为加载失败,pause session(E007
54
- 3. **Deferred reading recorded only** — `<deferred_reading>` 列出的文件路径需记录,执行过程按需 Read;不在加载阶段读取
55
- 4. **Skill loaded confirmation** 所有 required_reading 加载完成后必须输出一行确认:`✓ skill {step.skill} 加载完成 (required: N, deferred: M)`
56
- 5. **External = explicit only**`step.type == "external"` 才走 delegate;默认绝不发起
57
- 6. **必须显式 completion confirmation** — 每个 step 完成时需有 `STATUS: DONE` 且写入 `step.completion_confirmed = true`
58
- 7. **Self-invocation chain** 持续直到全部 `completion_confirmed` 或 paused
59
- 8. **status.json 每步骤后写盘**resume-safe
49
+ 1. **执行 = `ralph next` + inline + `ralph complete`** `maestro ralph next` 拿到 skill 内容,按 stdout 内联执行
50
+ 2. **Required reading CLI 负责**`ralph next` 自动展开 + 加载 `<required_reading>` 引用的所有文件,缺失退出码 1(E007),不写 active_step_index,不进入执行
51
+ 3. **Deferred reading recorded only** — `<deferred_reading>` 路径由 CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
52
+ 4. **一致性取代锁**同一 session 同时最多一个 step `active_step_index`;CLI 校验失败直接退出码 3,不静默推进
53
+ 5. **Completion 通过 CLI 调用**每个 step 末尾调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`,由 CLI 写 `completion_*` + 清 `active_step_index`
54
+ 6. **Self-invocation chain** — 持续直到全部 `completion_confirmed` paused
55
+ 7. **status.json 每步骤后由 CLI 原子写盘** resume-safe
56
+ 8. **STATUS 枚举受限**仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
60
57
  </invariants>
61
58
 
62
59
  <state_machine>
@@ -82,14 +79,13 @@ S_RESOLVE_ARGS:
82
79
  → S_EXECUTE DO: A_RESOLVE_ARGS
83
80
 
84
81
  S_EXECUTE:
85
- → END WHEN: step.type == "decision" DO: A_EXEC_DECISION
86
- → S_POST_EXEC WHEN: step.type == "internal" + success DO: A_EXEC_INTERNAL
87
- → S_HANDLE_FAIL WHEN: step.type == "internal" + failure DO: A_EXEC_INTERNAL
88
- → END WHEN: step.type == "external" DO: A_EXEC_EXTERNAL
89
- (STOP after background delegate; on callback → S_POST_EXEC or S_HANDLE_FAIL)
82
+ → END WHEN: step.decision != null DO: A_EXEC_DECISION
83
+ → S_POST_EXEC WHEN: step.decision == null + ralph complete invoked with DONE|DONE_WITH_CONCERNS DO: A_EXEC_STEP
84
+ → S_HANDLE_FAIL WHEN: step.decision == null + ralph next exit≠0 OR ralph complete with NEEDS_RETRY|BLOCKED DO: A_EXEC_STEP
90
85
 
91
86
  S_POST_EXEC:
92
- → S_LOCATE DO: A_MARK_COMPLETE + invoke_skill("maestro-ralph-execute")
87
+ → S_LOCATE DO: shell("maestro ralph complete ...") + invoke_skill("maestro-ralph-execute")
88
+ NOTE: CLI 已写完 completion_*, status, active_step_index;无需额外写盘
93
89
 
94
90
  S_HANDLE_FAIL:
95
91
  → S_LOCATE WHEN: auto + not retried DO: A_RETRY
@@ -112,8 +108,8 @@ S_FALLBACK:
112
108
 
113
109
  1. If session_id provided → load `.workflow/.maestro/{session_id}/status.json`
114
110
  2. Else: scan `.workflow/.maestro/*/status.json`, filter `status == "running"`, sort DESC, take first
115
- 3. Extract: session_id, source, steps[], current_step, phase, milestone, intent, auto_mode, context, cli_tool
116
- 4. Find first step with `status == "pending"` next step
111
+ 3. Extract: session_id, source, steps[], phase, milestone, intent, auto_mode, context, cli_tool, active_step_index
112
+ 4. **不在此处选 pending step**——pending 选择由 `maestro ralph next` CLI 内部完成;A_LOCATE_SESSION 只确认 session 存在且 running,由 A_EXEC_STEP 调 CLI 推进
117
113
 
118
114
  ### A_RESOLVE_ARGS
119
115
 
@@ -155,79 +151,41 @@ Write enriched args back to status.json.
155
151
  ### A_EXEC_DECISION
156
152
 
157
153
  1. Mark step running, write status.json
158
- 2. Display: `[{index}/{total}] ◆ {decision} Retry: {retry}/{max}`
154
+ 2. Display: `[{index}/{total}] ◆ {step.decision} Retry: {retry}/{max}`
159
155
  3. `invoke_skill({ skill: "maestro-ralph" })` — ralph 评估 + handoff
160
156
  4. 执行在此结束
161
157
 
162
- ### A_EXEC_INTERNAL
163
-
164
- 1. Validate `step.command_path != null`;否则 raise E002,pause session
165
- 2. Mark step running, write status.json
166
- 3. Display: `[{index}/{total}] {step.skill} [internal · {step.command_scope}]`
167
- 4. `read_file({ file_path: step.command_path })` — 把命令 .md 全文加载进当前会话(prefer Read over Skill for internal steps;decision 节点另行使用 Skill 见 A_EXEC_DECISION)
168
- 5. **解析 reading 标签**("入口 + workflow"形式核心步骤):
169
- - 抽取 frontmatter `argument-hint` / `allowed-tools`
170
- - 抽取 `<required_reading>` 块的所有 `@path` 引用 → 立刻 `read_file({ file_path: <expanded path> })` 加载(`~/` / `@~/` 展开为用户主目录);任一文件缺失或读取失败 → raise E007,pause session
171
- - 抽取 `<deferred_reading>` 块的所有路径 → 仅记录到 `step.deferred_reads = [...]`,执行阶段按需 Read
172
- - 抽取 `<purpose>/<context>/<state_machine>/<execution>/<actions>` 等指令块
173
- 6. **加载完成确认**:required_reading 全部成功 Read 后,输出一行:
174
- ```
175
- ✓ skill {step.skill} 加载完成 (required: {N}, deferred: {M})
176
- ```
177
- 其中 N = required_reading 引用数,M = deferred_reading 路径数(缺省块按 0 计)
178
- 7. 计算 `effective_args`:`step.args` + auto flag(`auto ? (flag_map[step.skill] || "") : ""`)
179
- 8. 按读到的指令在本会话中**内联执行**:调用允许的工具完成命令所规定的工作,不再发起 delegate;执行过程中如触发 deferred_reading 引用的资源 → 按需 Read
180
- 9. 执行结束:要求最后一段必须包含 `--- COMPLETION STATUS ---` 块(见 A_MARK_COMPLETE)
181
- 10. Return success / failure
182
-
183
- **Auto flag map**: 所有 lifecycle skill → `-y`; `quality-test` → `-y --auto-fix`; 未列出 → 无 flag
184
-
185
- ### A_EXEC_EXTERNAL
158
+ ### A_EXEC_STEP
186
159
 
187
- 仅当 `step.type == "external"` 时使用(默认链路不产生)。
160
+ 1. **Load** — `shell("maestro ralph next")`
161
+ - 退出码 0 → 按 stdout 内联执行
162
+ - 退出码 2 → 交给 S_LOCATE
163
+ - 退出码 3 → active_step_index 已被占用
164
+ - 退出码 1 → pause session
165
+ 2. **Inline execution** — 按 stdout 执行;deferred_reading 按需 Read
166
+ 3. **Complete**:
167
+ - `shell("maestro ralph complete N --status DONE [--evidence <path>]")`
168
+ - `shell("maestro ralph complete N --status DONE_WITH_CONCERNS --concerns \"...\"")`
169
+ - `shell("maestro ralph retry N")`
170
+ - `shell("maestro ralph complete N --status BLOCKED --reason \"...\"")`
171
+ 4. **Propagate context signals** — 关键信号 (`PHASE: N` / `scratch_dir: path` / `BLP-xxx`) 写入 `status.json.context`
188
172
 
189
- 1. Mark step running, write status.json
190
- 2. Display: `[{index}/{total}] ⚡ {step.skill} [external]`
191
- 3. 始终在 prompt 内追加 `-y`(delegate session 非交互):`flag = flag_map[step.skill] || "-y"`
192
- 4. Execute:
193
- ```
194
- shell({
195
- command: `maestro delegate "/${step.skill} ${effective_args}" --to claude --mode write`,
196
- run_in_background: true, timeout: 600000
197
- })
198
- STOP — wait for callback.
199
- ```
200
- 5. On callback: 把回调输出视为 step 的执行结果 → S_POST_EXEC / S_HANDLE_FAIL
201
-
202
- ### A_MARK_COMPLETE
203
-
204
- 1. 从 step 输出中提取 `--- COMPLETION STATUS ---` 块(required)
205
- 2. 解析并写入:
206
- - `STATUS: DONE` → `step.status = "completed"`, `step.completion_confirmed = true`, `step.completion_status = "DONE"`
207
- - `STATUS: DONE_WITH_CONCERNS` → `step.status = "completed"`, `step.completion_confirmed = true`, `step.completion_status = "DONE_WITH_CONCERNS"`, `step.concerns = <CONCERNS>`
208
- - `STATUS: NEEDS_RETRY` → `step.status = "pending"`, `step.retried = true`, `step.completion_confirmed = false`, → S_HANDLE_FAIL
209
- - `STATUS: BLOCKED` / `NEEDS_CONTEXT` → `session.status = "paused"`, `step.completion_status` 记录原因, `step.completion_confirmed = false`
210
- - 缺失 `--- COMPLETION STATUS ---` 块 → 视为 NEEDS_RETRY(不允许 heuristic fallback)
211
- 3. 写入 `step.completion_evidence`(artifact 路径 / 关键输出节选)
212
- 4. 扫描输出抓取 context 信号:`PHASE: N` → session.phase;`scratch_dir: path` → context.scratch_dir;`BLP-xxx` → context.blueprint_session_id
213
- 5. `step.completed_at = now`,写 status.json
214
- 6. **Sub-goal evidence 校验**(task_decomposition 存在时):若 `step.goal_ref` 对应子目标的 `lifecycle` 覆盖当前 stage 且 evidence artifact 已生成 → 暂不直接置 done,仍交由 post-goal-audit 决策;仅在 step 显式确认时更新 `task_decomposition[*].completion_confirmed = false` 占位(保持 pending)
215
- 7. Display: `[{index}/{total}] ✓ {step.skill} completed (confirmed)`
173
+ 完成后 S_LOCATE 触发 `invoke_skill({ skill: "maestro-ralph-execute" })` 自调用。
216
174
 
217
175
  ### A_RETRY
218
176
 
219
- 1. `step.retried = true`, `step.status = "pending"`, `step.error = null`, `step.completion_confirmed = false`
220
- 2. Write status.json
177
+ 1. `shell("maestro ralph retry N")` — CLI 设 `step.retried = true`, `step.status = "pending"`, `step.completion_confirmed = false`, `active_step_index`
178
+ 2. Display: `[{index}/{total}] ↻ {step.skill} retry`
221
179
 
222
180
  ### A_SKIP_STEP
223
181
 
224
- 1. `step.status = "skipped"`, `step.completion_confirmed = false`
225
- 2. Write status.json
182
+ 跳过执行 step — 手动编辑 `status.json`:将该 step `status` 设为 `"skipped"`,`completion_confirmed` 设为 `false`,并清 `active_step_index`(若指向此 step)。
183
+ (不提供 CLI 子命令;跳过是非常规操作,避免自动化误用。)
226
184
 
227
185
  ### A_PAUSE_SESSION
228
186
 
229
- 1. `session.status = "paused"`, write status.json
230
- 2. Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。/maestro-ralph continue 恢复。`
187
+ 通常由 `ralph complete N --status BLOCKED --reason "..."` 触发,CLI 已写 `session.status = "paused"`。手动 pause 场景下直接编辑 status.json
188
+ Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。/maestro-ralph continue 恢复。`
231
189
 
232
190
  ### A_COMPLETE_SESSION
233
191
 
@@ -242,14 +200,14 @@ Write enriched args back to status.json.
242
200
  Session: {session_id} [{source}]
243
201
  Steps: {completed}/{total} confirmed: {confirmed}/{completed}
244
202
 
245
- [✓] 0. maestro-plan 1 [internal · global]
246
- [✓] 1. maestro-execute 1 [internal · project]
247
- [✓] 2. maestro-verify 1 [internal · global]
203
+ [✓] 0. maestro-plan 1 [global]
204
+ [✓] 1. maestro-execute 1 [project]
205
+ [✓] 2. maestro-verify 1 [global]
248
206
  [✓] 3. ◆ post-verify [decision]
249
207
  ...
250
208
  ============================================================
251
209
  ```
252
- Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision, `⚡` external
210
+ Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision
253
211
 
254
212
  </actions>
255
213
 
@@ -262,31 +220,30 @@ Write enriched args back to status.json.
262
220
  | Code | Severity | Description | Recovery |
263
221
  |------|----------|-------------|----------|
264
222
  | E001 | error | No running session found | Suggest /maestro or /maestro-ralph |
265
- | E002 | error | step.command_path missing for internal step | Pause, ask ralph to rebuild step |
266
- | E003 | error | status.json corrupt | Show path, manual check |
267
- | E004 | error | Delegate failed + user abort | Mark paused, suggest resume |
268
- | E005 | error | COMPLETION STATUS block missing | Trigger NEEDS_RETRY |
269
- | E007 | error | required_reading file 缺失或读取失败 | List missing paths, pause session |
223
+ | E006 | error | command_path missing/unreachable for 执行 step | `ralph next` 拒绝;编辑 status.json 或重 build |
224
+ | E007 | error | required_reading 引用文件缺失 | `ralph next` 拒绝;CLI stderr 列出缺失路径 |
225
+ | E008 | error | `ralph complete` idx active_step_index | 编辑 status.json 修正一致性 |
226
+ | E009 | error | `ralph complete` step.status running | 重复 complete 或非法跳跃;编辑 status.json |
227
+ | E010 | error | status.json schema 损坏 | `ralph check` 显示具体损坏字段 |
270
228
  | W001 | warning | Step completed with concerns | Log and continue |
271
- | W002 | warning | command .md `<required_reading>` 标签 | 直接执行 .md 主体,跳过加载阶段 |
229
+ | W005 | warning | active_step_index 指向已 completed step | `ralph next` 自动清理后继续 |
230
+ | W007 | warning | step.skill ≠ command .md frontmatter.name | 提示但不阻塞 |
272
231
 
273
232
  ### Success Criteria
274
233
 
275
234
  - [ ] Session discovery covers maestro-* and ralph-*
276
- - [ ] `-y` parsed from args 或 session.auto_mode
235
+ - [ ] `-y` parsed from args 或 session.auto_mode;auto=true 时透传 `-y` 到 skill args
277
236
  - [ ] Placeholders resolved;per-skill enrichment 正确
278
- - [ ] Decision 节点 invoke_skill("maestro-ralph") handoff
279
- - [ ] Internal 节点通过 read_file({step.command_path}) 内联执行,禁止 invoke_skill()
280
- - [ ] Internal 节点 Read 后必须解析并加载 `<required_reading>` 引用的文件;缺失 E007 pause
281
- - [ ] `<deferred_reading>` 仅记录路径到 `step.deferred_reads`,执行阶段按需 Read
282
- - [ ] required_reading 加载完成后输出 `✓ skill {name} 加载完成 (required: N, deferred: M)`
283
- - [ ] External 仅在显式声明时走 delegate,prompt 必带 `-y`
284
- - [ ] 每个 step 强制 `--- COMPLETION STATUS ---`;缺失 → NEEDS_RETRY
285
- - [ ] step.completion_confirmed = true 仅在 STATUS: DONE/DONE_WITH_CONCERNS 时设置
286
- - [ ] step.completion_evidence 记录 artifact path / 输出节选
287
- - [ ] Context signals 传播 status.json
237
+ - [ ] Decision 节点(`step.decision != null`)走 invoke_skill("maestro-ralph") handoff(**不调 ralph next CLI**)
238
+ - [ ] 执行 step 通过 `shell("maestro ralph next")` 加载;CLI 返回拼好的 prompt + completion 协议
239
+ - [ ] required_reading CLI 自动加载并拼入 prompt;缺失CLI 退出码 1,pause session
240
+ - [ ] `<deferred_reading>` CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
241
+ - [ ] 每个 step 末尾必须调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`
242
+ - [ ] STATUS 枚举仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;CLI 拒绝 `NEEDS_CONTEXT`
243
+ - [ ] active_step_index 一致性由 CLI 维护;E008/E009 直接退出,不静默推进
244
+ - [ ] step.completion_evidence 通过 `--evidence` 传入并记录
245
+ - [ ] Context signals 由执行 step 显式写回 status.json.context(非 ralph-execute 内嵌扫描)
288
246
  - [ ] Auto mode: retry 一次后 pause;interactive 提供 retry/skip/abort
289
247
  - [ ] 自调用持续到全部 completion_confirmed 或 paused
290
- - [ ] A_COMPLETE_SESSION 校验全部 step confirmed + sub-goal all_done
291
248
 
292
249
  </appendix>
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: manage-knowledge-audit
3
+ description: Audit and prune knowledge across spec / knowhow / artifact stores
4
+ argument-hint: "--scope <spec|knowhow|artifact|all> [--level P0|P1|P2] [--timeline T1..T6] [--since YYYY-MM-DD] [--milestone <name>] [--include-archive] [--interactive] [--mark|--delete|--purge] [--dry-run] [--report]"
5
+ allowed-tools:
6
+ - read_file
7
+ - write_file
8
+ - edit_file
9
+ - shell
10
+ - find_files
11
+ - search
12
+ - delegate_subagent
13
+ - ask_user
14
+ ---
15
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
16
+
17
+ <purpose>
18
+ 对称于 `manage-harvest`(写入入口)的知识淘汰入口。harvest 负责把 artifact 抽取为 spec/wiki/issue;audit 负责审查这三大存储中已积累的条目,识别矛盾、失效、老化、孤儿,并通过 keep/deprecate/delete 三态决策清理。
19
+
20
+ 覆盖 8 大场景类、28 子场景(显性/隐性矛盾、失效老化、元数据质量、Maestro 特化、时间线产物 T1-T6、knowhow 漂移、artifact 残留),定义见 workflow knowledge-audit.md。
21
+
22
+ **闭环**:harvest 写入 → audit 审查 → 三态淘汰;与 `harvest --prune`(物理 GC)互补:audit 做语义层判定,且删除未抽取的 artifact 前反向触发 harvest 抢救。
23
+ </purpose>
24
+
25
+ <required_reading>
26
+ @~/.maestro/workflows/knowledge-audit.md
27
+ </required_reading>
28
+
29
+ <deferred_reading>
30
+ - @~/.maestro/workflows/harvest.md (audit 检测的 artifact 是 harvest 的产物源)
31
+ - @~/.maestro/workflows/specs-add.md (deprecate 操作所需的 `<spec-entry>` 变形)
32
+ </deferred_reading>
33
+
34
+ <context>
35
+ Arguments: $ARGUMENTS
36
+
37
+ **Scope(必选):** `spec` | `knowhow` | `artifact` | `all`
38
+
39
+ **删除策略**默认 `--interactive`(三态面板逐项决策);非交互模式 `--mark`(仅打标)/ `--delete`(软删到 `.trash/`)/ `--purge`(物理擦除,仅 artifact 且需双重确认)。
40
+
41
+ Flag 全集、scope 对应的扫描路径、Stage 步骤、检测算法定义在 workflow knowledge-audit.md。
42
+ </context>
43
+
44
+ <execution>
45
+ Follow `~/.maestro/workflows/knowledge-audit.md` Stages 1-8 in order.
46
+
47
+ **Key invariants:**
48
+ 1. **Backup before mutate** — Stage 6 必须把待变更文件打包到 `.workflow/.trash/knowledge-audit-{timestamp}/`,备份失败禁止 Stage 7。
49
+ 2. **Deprecate over delete** — 文本存储(spec/knowhow)首选注入 `status="deprecated"` 保留历史;只有 artifact 物理残留才走 delete/purge。
50
+ 3. **Purge requires double confirmation** — `--purge` 仅作用于 artifact scope,且 Stage 5 必须显式 `[y/N]` 二次确认 + 输入 artifact id。
51
+ 4. **Rescue before delete** — 删除未抽取的 artifact 前(`harvest-log.jsonl` 无记录),强制提示 "是否先 `/manage-harvest`?"。
52
+
53
+ Scope 路径、8 类检测算法、三态决策面板、报告 schema 定义在 workflow knowledge-audit.md。
54
+
55
+ **Next-step routing on completion:**
56
+ - 复审淘汰记录 → `.workflow/.knowledge-audit/audit-report-{date}.md`
57
+ - 抢救未抽取 artifact → `/manage-harvest <artifact-id>`
58
+ - 验证 spec 现状 → `/spec-load --role implement`
59
+ - 周期巡检 → 每 milestone 结束跑 `--scope all --report`
60
+ </execution>
61
+
62
+ <error_codes>
63
+ | Code | Severity | Condition | Recovery |
64
+ |------|----------|-----------|----------|
65
+ | E001 | error | `.workflow/` 未初始化 | 先跑 `/maestro-init` |
66
+ | E002 | error | `--scope` 缺失或非法 | 提供 spec/knowhow/artifact/all |
67
+ | E003 | error | `--purge` 与 `--dry-run` 同用 | 二选一 |
68
+ | E004 | error | `--purge` 作用于非 artifact 范围 | purge 仅支持 artifact scope |
69
+ | E005 | error | 备份失败(`.trash/` 写入异常) | 检查磁盘空间与权限,重试 |
70
+ | W001 | warning | 检出冲突但用户选择 keep | 记入 report,不阻断 |
71
+ | W002 | warning | 待删 artifact 无 harvest-log 记录 | 提示先跑 manage-harvest |
72
+ | W003 | warning | 循环 supersedes 链 | 自动断环或交互选保留节点 |
73
+ | W004 | warning | 检测耗时 >120s(大规模 spec 库) | 建议加 `--scope` 收敛或 `--since` 增量 |
74
+ | W005 | warning | LLM detector 不可用 | 降级到正则+图算法子集,跳过 B/G 类语义场景 |
75
+ </error_codes>
76
+
77
+ <success_criteria>
78
+ - [ ] Scope 正确解析,互斥标志校验通过
79
+ - [ ] 三存储按 scope 加载完成,构建出统一 finding 池
80
+ - [ ] Stage 3 时间线索引建立(mtime ↔ session/milestone 状态)
81
+ - [ ] Stage 4 按 P0/P1/P2 输出 finding 列表
82
+ - [ ] 如非 `--report`:用户对每项做出三态决策
83
+ - [ ] 未 harvest 的 artifact 删除前触发抢救确认
84
+ - [ ] Stage 6 backup tarball 生成于 `.workflow/.trash/`
85
+ - [ ] `deprecate` 通过元数据注入完成(spec/knowhow 文件未被物理删除)
86
+ - [ ] `delete` 移动至 `.trash/`,索引同步更新
87
+ - [ ] `purge` 仅在双重确认通过后执行
88
+ - [ ] `audit-report-{date}.md` + `audit-log.jsonl` 写入完成
89
+ - [ ] 摘要展示三存储变更计数与下一步路由
90
+ </success_criteria>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: maestro
3
3
  description: Auto-route intent to optimal command chain
4
- argument-hint: <intent> [-y] [-c] [--dry-run] [--exec auto|cli|internal] [--tool <name>] [--super]
4
+ argument-hint: <intent> [-y] [-c] [--dry-run] [--super]
5
5
  allowed-tools:
6
6
  - ask_question
7
7
  - define_subagent
@@ -41,22 +41,20 @@ $ARGUMENTS — user intent text, or special keywords.
41
41
  - `-y` / `--yes` — Auto mode: skip clarification, skip confirmation, auto-skip on errors
42
42
  - `-c` / `--continue` — Resume previous session
43
43
  - `--dry-run` — Show chain without executing
44
- - `--exec <mode>` — `auto` (default), `cli`, `internal`
45
- - `--tool <name>` — CLI tool for delegates (default: claude)
46
44
  - `--super` — Read and follow `maestro-super.md`
47
45
  </context>
48
46
 
49
47
  <invariants>
50
48
  1. **All chains dispatch via maestro-ralph-execute** — maestro never executes steps directly
51
49
  2. **Session before execution** — status.json created before any step runs
52
- 3. **Auto flags only to supporting commands** unlisted commands execute as-is
50
+ 3. **Auto flag pass-through** 仅当用户传入 `-y` 时透传 `-y` skill args
53
51
  4. **Decomposition contract shared with maestro-ralph** — broad/lifecycle intents run S_DECOMPOSE producing the SAME additive block (`boundary_contract`, `execution_criteria`, `task_decomposition`)。Reference maestro-ralph `A_DECOMPOSE_TASKS`
54
52
  5. **status.json 唯一真源** — 不生成 `goal-checklist.md` 或外部清单
55
- 6. **Default step type = internal**chain 内每个 step 解析 `command_scope`/`command_path`(全局优先 `~/.claude/commands/{name}.md`,fallback 项目)
56
- 7. **Topology awareness** — chain catalog 含 brainstorm / blueprint / analyze-macro(text) / analyze(numeric phase) / roadmap / plan(三路径) / execute / verify / ...;scope_verdict 路由由 ralph 在 `post-analyze-scope` 决定
57
- 8. **D-007 milestone 反查** — 数字 phase 步骤的 `milestone_id` 由 `state.json.milestones[].phase_slugs` 反查得出
58
- 9. **每个 step 必须 `completion_confirmed: true`** — 基于 `--- COMPLETION STATUS ---` `STATUS: DONE`
59
- 10. **schema 向后兼容** 新增字段全部可选;既有字段名不删不改
53
+ 6. **执行步骤统一通过 `maestro ralph next` 加载**`command_scope`/`command_path` `maestro ralph skills --json --quiet` 预校验(project 覆盖 global);decision 节点不走 CLI,走 `Skill("maestro-ralph")` handoff
54
+ 7. **Topology awareness** — chain catalog 含 brainstorm / blueprint / analyze-macro / analyze / roadmap / plan(三路径) / execute / verify / ...;scope_verdict ralph 在 `post-analyze-scope` 决定
55
+ 8. **D-007 milestone 反查** — 数字 phase `milestone_id` 由 `state.json.milestones[].phase_slugs` 反查
56
+ 9. **每个 step 必须 `completion_confirmed: true`** — `maestro ralph complete N --status DONE|DONE_WITH_CONCERNS` 写入
57
+ 10. **schema**`ralph_protocol_version: "1"` 标记 CLI-driven session;新增字段全部可选
60
58
  </invariants>
61
59
 
62
60
  <state_machine>
@@ -142,7 +140,7 @@ S_FALLBACK:
142
140
  - 数字 phase 上下文 → `analyze {phase}` → `plan {phase}` → `execute {phase}` → `verify {phase}` → quality pipeline
143
141
  - 已有 analyze artifact 想直达执行 → `plan --from analyze:{ANL_ID}` → execute → verify
144
142
  - 已有 blueprint artifact → `plan --from blueprint:{BLP_ID}` → execute → verify
145
- 4. 每个 step 默认 `type: "internal"`;解析 `command_scope` + `command_path`(全局优先 fallback 项目);写入 `step.stage` / `step.scope` / `step.source_artifact_ref`(如 `--from` 注入时)
143
+ 4. 执行 step:`run_command("maestro ralph skills --json --quiet")` 预校验 skill 名,命中写绝对路径到 `command_path`,未命中标 `missing`;同时写 `step.stage` / `step.scope` / `step.source_artifact_ref`。decision 节点不解析 command_path
146
144
 
147
145
  ### A_CLARIFY
148
146
 
@@ -158,9 +156,9 @@ S_FALLBACK:
158
156
  3. 派生 `execution_criteria` + `task_decomposition`(每个 sub-goal 含 `done_when` + `evidence` + `lifecycle` + `completion_confirmed: false`)
159
157
  4. **status.json 唯一真源**:写入 `boundary_contract` / `execution_criteria` / `task_decomposition`;不生成 markdown 清单
160
158
  5. 在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前追加 `decision:post-goal-audit`。ralph-execute 在该节点按需动态生长 `steps[]`
161
- 6. **输出 `/goal` 绑定提示词:**
159
+ 6. **输出 `/goal` 绑定提示词(不阻塞,用户可在执行过程中随时输入):**
162
160
  ```
163
- 📋 任务分解完成。复制下面一行设定目标,会话在子目标全部达成前不停:
161
+ 📋 任务分解完成。可随时复制下面一行设定目标(执行过程中输入即可):
164
162
 
165
163
  /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。
166
164
  ```
@@ -172,29 +170,28 @@ S_FALLBACK:
172
170
  ```json
173
171
  {
174
172
  "session_id", "source": "maestro", "intent", "task_type", "chain_name",
173
+ "ralph_protocol_version": "1", "active_step_index": null,
175
174
  "phase", "phase_is_new": false, "milestone": "",
176
175
  "scope_verdict": null, "analyze_macro_id": null, "blueprint_id": null,
177
- "auto_mode": false, "exec_mode": "auto", "cli_tool": "claude",
176
+ "auto_mode": false, "cli_tool": "claude",
178
177
  "context": { "scratch_dir": null, "plan_dir": null, "analysis_dir": null,
179
178
  "brainstorm_dir": null, "blueprint_dir": null, "issue_id": null },
180
179
  "steps": [{
181
- "index": 0, "type": "internal|external|decision",
182
- "skill": "", "args": "",
183
- "stage": "", "scope": null,
184
- "command_scope": "global|project|missing|null",
185
- "command_path": "~/.claude/commands/{name}.md | .claude/commands/{name}.md | null",
180
+ "index": 0, "skill": "", "args": "",
181
+ "stage": "", "scope": null, "decision": null,
182
+ "command_scope": "global|project|missing|null", "command_path": "<abs> | null",
186
183
  "milestone_id": null, "source_artifact_ref": null,
187
184
  "status": "pending", "goal_ref": null,
188
185
  "completion_confirmed": false, "completion_status": null,
189
- "completion_evidence": null, "completed_at": null
186
+ "completion_evidence": null, "completed_at": null,
187
+ "deferred_reads": [], "load": null
190
188
  }],
191
189
  "waves": [], "current_step": 0, "status": "running",
192
190
  "boundary_contract": {}, "execution_criteria": [],
193
191
  "task_decomposition": [], "task_decomposition_all_done": false
194
192
  }
195
193
  ```
196
- Decomposition 字段仅在 A_DECOMPOSE_TASKS 产出时写入(additive)
197
- 3. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E005 列出缺失 skill
194
+ 3. Validate: 所有 step 的 `command_scope != "missing"`,否则 raise E005 列出缺失 skill
198
195
  4. Initialize tracking via `TodoWrite`
199
196
  5. If `--super`: read `maestro-super.md`, follow it completely
200
197
 
@@ -204,25 +201,6 @@ S_FALLBACK:
204
201
 
205
202
  <appendix>
206
203
 
207
- ### Auto-Yes Flag Map
208
-
209
- | Command | Auto Flag | Effect |
210
- |---------|-----------|--------|
211
- | maestro-init | `-y` | Skip interactive questioning |
212
- | maestro-analyze | `-y` | Skip scoping, auto-deepen |
213
- | maestro-brainstorm | `-y` | Skip questions, use defaults |
214
- | maestro-blueprint | `-y` | Skip interview, use recommended defaults |
215
- | maestro-roadmap | `-y` | Skip questions (create/revise/review) |
216
- | maestro-impeccable | `-y` | Auto-select design variant + skip confirmations |
217
- | maestro-plan | `-y` | Skip confirmations and clarification |
218
- | maestro-execute | `-y` | Skip confirmations, blocked auto-continue |
219
- | quality-auto-test | `-y` | Skip plan confirmation |
220
- | quality-test | `-y --auto-fix` | Auto-trigger gap-fix loop |
221
- | quality-retrospective | `-y` | Accept all routing recommendations |
222
- | maestro-milestone-complete | `-y` | Skip knowledge promotion |
223
-
224
- Unlisted commands have no auto flags.
225
-
226
204
  ### Error Codes
227
205
 
228
206
  | Code | Severity | Description | Recovery |
@@ -247,8 +225,10 @@ Unlisted commands have no auto flags.
247
225
  - [ ] status.json 唯一真源;无 markdown 清单;post-goal-audit 节点在 decomposed 时追加;/goal 提示词以 status.json 为判据
248
226
  - [ ] Chain selected and confirmed (or auto-confirmed)
249
227
  - [ ] Session dir created with status.json before execution; decomposition fields additive-only
250
- - [ ] 每个 step 含 `command_scope` + `command_path` + `completion_confirmed` 字段
251
- - [ ] Auto flags propagated to supporting commands only
228
+ - [ ] 执行 step 含 `command_scope` + `command_path` + `completion_confirmed`;decision step 由 `step.decision` 标识
229
+ - [ ] `command_scope`/`command_path` `maestro ralph skills --json --quiet` 预校验(project 覆盖 global)
230
+ - [ ] Session schema 含 `ralph_protocol_version: "1"` + `active_step_index: null` + step.load 占位
231
+ - [ ] 用户传入 `-y` 时透传到 skill args
252
232
  - [ ] All chains dispatched via maestro-ralph-execute
253
233
  - [ ] Low-complexity intents routed to maestro-quick
254
234
  - [ ] (super) Requirements validated before roadmap
@@ -136,18 +136,19 @@ Next steps:
136
136
  /maestro-plan {phase} -- Re-plan with modifications
137
137
  ```
138
138
 
139
- **Completion status:**
139
+ **Completion (when invoked from ralph):**
140
+ End the step by calling the CLI (no `--- COMPLETION STATUS ---` text block):
140
141
  ```
141
- --- COMPLETION STATUS ---
142
- STATUS: DONE|NEEDS_CONTEXT
143
- CONCERNS: {description if applicable}
144
- NEXT: /maestro-execute
145
- --- END STATUS ---
142
+ maestro ralph complete <idx> --status DONE [--evidence scratch/{YYYYMMDD}-plan-P{N}-{slug}/plan.json]
146
143
  ```
147
144
 
148
- Status mapping:
149
- - **DONE** — Plan created/revised and confirmed → NEXT: /maestro-execute
150
- - **NEEDS_CONTEXT** — Ambiguous requirements, insufficient context to produce plan
145
+ STATUS verdicts (CLI-enforced enum):
146
+ - **DONE** — Plan created/revised and confirmed → next step picks up automatically
147
+ - **DONE_WITH_CONCERNS** — Plan produced but with explicit caveats; pass `--concerns "..."`
148
+ - **NEEDS_RETRY** — Plan failed (tooling error, transient issue); ralph will retry
149
+ - **BLOCKED** — External hard blocker (e.g., upstream artifact missing, dependency unavailable); pass `--reason "..."`
150
+
151
+ > Ambiguous requirements are NOT a completion status — resolve them in-place via `ask_question` during planning (≤3 rounds), then proceed to DONE. `NEEDS_CONTEXT` has been removed; context shortage is handled by the harness's automatic compaction.
151
152
 
152
153
  ### Mode: Revise / Check
153
154