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
@@ -15,7 +15,7 @@ Closed-loop decision engine for the maestro workflow lifecycle.
15
15
  Reads project state → infers position → builds adaptive chain → delegates execution.
16
16
 
17
17
  Entry points:
18
- - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → (decomposition → emit /goal prompt, STOP;否则 dispatch ralph-execute)
18
+ - **`/maestro-ralph "intent"`** — New session: infer → decompose → build → emit /goal prompt(如有 decomposition)→ dispatch ralph-execute
19
19
  - **`/maestro-ralph continue`** — Wrapper; dispatches to ralph-execute(首选直接 `/maestro-ralph-execute` 推进 step)
20
20
  - **`/maestro-ralph status`** — Display session progress
21
21
 
@@ -23,10 +23,9 @@ Entry points:
23
23
 
24
24
  Initial decomposition (S_DECOMPOSE): boundary-clarified via ≤3 questions for broad intents (重构/全面/迁移/重写). 写入 status.json 的 `boundary_contract` / `execution_criteria` / `task_decomposition`,附 `/goal` prompt。
25
25
 
26
- Node types:
27
- - **internal** (default): ralph-execute `view_file({command_path})` 命令 .md,按内容内联执行
28
- - **decision**: ralph 评估
29
- - **external**: 仅在显式声明时使用(`maestro delegate --to claude`)
26
+ Step kinds:
27
+ - **执行 step**: ralph-execute `run_command("maestro ralph next")` 加载 command .md + required_reading 全文,按 stdout 内联执行
28
+ - **decision step**: `step.decision` 字段非空;回 ralph 评估(CLI 只读分析)
30
29
 
31
30
  Key difference from maestro coordinator:
32
31
  - maestro: static chain → one-time selection → runs all steps
@@ -43,9 +42,9 @@ Mutual invocation with `/maestro-ralph-execute` forms a self-perpetuating work l
43
42
  │ writes status.json
44
43
  │ emits /goal prompt
45
44
 
46
- ralph-execute ◀─┐ internalview_file(command_path) inline
47
- │ │ decision → Skill("maestro-ralph")
48
- └─────────┘ writes step.completion_confirmed
45
+ ralph-execute ◀─┐ 执行 step `maestro ralph next` + inline + `ralph complete`
46
+ │ │ decision step → Skill("maestro-ralph")
47
+ └─────────┘ CLI writes step.completion_confirmed
49
48
  loop until all completion_confirmed | paused
50
49
  ```
51
50
  </purpose>
@@ -68,14 +67,14 @@ Remaining → intent
68
67
 
69
68
  <invariants>
70
69
  1. **Ralph never executes steps** — only creates sessions and evaluates decisions
71
- 2. **Handoff via Skill("maestro-ralph-execute")** — 仅当 session `task_decomposition` 时在创建后自动 handoff;decomposition 路径 STOP 等用户输入。decision 评估后始终 handoff
70
+ 2. **Handoff via Skill("maestro-ralph-execute")** — 创建 session 后始终自动 handoff;decision 评估后始终 handoff
72
71
  3. **Decision delegates read-only** — `maestro delegate --role analyze --mode analysis`
73
- 4. **Default type = internal** `external` 仅显式标注时出现,build 不默认生成
72
+ 4. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(详见 invariant 8)
74
73
  5. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
75
- 6. **每个 step 必须 `completion_confirmed: true`** — 基于 `--- COMPLETION STATUS ---` `STATUS: DONE`;缺失则视为未完成
76
- 7. **command_path 在 A_BUILD_STEPS 解析** — 全局优先 `~/.claude/commands/{name}.md`,fallback 项目 `.claude/commands/{name}.md`,写入 status.json
77
- 8. **Internal step 加载契约** — ralph-execute `command_path` 后,必须解析并加载该命令 `<required_reading>` 引用的所有文件("入口 + workflow"形式的核心),并把 `<deferred_reading>` 路径记录到 `step.deferred_reads`;加载完成后输出 `✓ skill {name} 加载完成`。ralph build 阶段只解析路径,不读 .md 内容
78
- 9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 只发提示词后 STOP,等用户输入
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 --json --quiet` 预校验(project 覆盖 global),命中即写绝对路径到 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` 校验路径存在性,不读 .md 内容
77
+ 9. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻;`/goal` 用户绑定,ralph 输出提示词后继续 handoff,用户可在执行过程中随时输入 `/goal`
79
78
  10. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
80
79
  11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
81
80
  </invariants>
@@ -147,9 +146,8 @@ S_BUILD_CHAIN:
147
146
  → S_CREATE_SESSION DO: A_BUILD_STEPS
148
147
 
149
148
  S_CREATE_SESSION:
150
- END WHEN: task_decomposition present DO: A_CREATE_SESSION (emits Goal Prompt → STOP,等用户输入 /goal 后手动 /maestro-ralph-execute)
151
- S_CONFIRM WHEN: not auto_confirm AND no decomposition DO: A_CREATE_SESSION
152
- → S_DISPATCH WHEN: auto_confirm AND no decomposition DO: A_CREATE_SESSION
149
+ S_CONFIRM WHEN: not auto_confirm DO: A_CREATE_SESSION
150
+ S_DISPATCH WHEN: auto_confirm DO: A_CREATE_SESSION
153
151
 
154
152
  S_CONFIRM:
155
153
  → S_DISPATCH WHEN: user selects "Proceed"
@@ -159,7 +157,7 @@ S_CONFIRM:
159
157
  S_DISPATCH:
160
158
  → END DO: view_file(AbsolutePath="<agy-skills-dir>/maestro-ralph-execute/SKILL.md") + execute inline
161
159
 
162
- S_DECISION_EVAL:
160
+ S_DECISION_EVAL: (decision 节点 == `step.decision` 非空,下述 gate 名取自该字段)
163
161
  → S_APPLY_VERDICT WHEN: quality-gate (post-verify, post-business-test, post-review, post-test)
164
162
  DO: A_DELEGATE_EVALUATE
165
163
  → S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
@@ -198,7 +196,7 @@ S_FALLBACK:
198
196
 
199
197
  1. Find latest ralph session (by created_at)
200
198
  2. Display: Session, Status, Position, Progress, Current step
201
- 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision;附 `command_scope`(global/project) + `command_path`
199
+ 3. List steps: [✓] completion_confirmed, [▸] current, [ ] pending, [◆] decision(`step.decision` 非空);执行 step 附 `command_scope`(global/project) + `command_path`
202
200
  4. If `task_decomposition` present (absent → skip):
203
201
  ```
204
202
  Sub-goals ({done}/{total}) source: {session_dir}/status.json#/task_decomposition
@@ -378,24 +376,26 @@ narrow → derive defaults from intent + codebase, skip questions.
378
376
 
379
377
  Generate steps from `session.lifecycle_position` to `milestone-complete`.
380
378
 
381
- | Stage | Skill (independent) | Skill (unified) | Type | Decision after | quality_mode |
382
- |-------|---------------------|-----------------|------|----------------|--------------|
383
- | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | internal | — | all |
384
- | blueprint | `maestro-blueprint "{intent}"` | *(same)* | internal | — | all |
385
- | init | `maestro-init` | *(same)* | internal | — | all |
386
- | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | internal | `post-analyze-scope` | all |
387
- | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | internal | — | all |
388
- | analyze | `maestro-analyze {phase}` | `maestro-analyze` | internal | — | 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` | internal | — | all |
390
- | execute | `maestro-execute {phase}` | `maestro-execute` | internal | — | all |
391
- | verify | `maestro-verify {phase}` | `maestro-verify` | internal | `post-verify` | all |
392
- | business-test | `quality-auto-test {phase}` | `quality-auto-test` | internal | `post-business-test` | full only |
393
- | review | `quality-review {phase}` | `quality-review` | internal | `post-review` | all (quick: append `--tier quick`) |
394
- | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | internal | — | full / standard if coverage<80% |
395
- | test | `quality-test {phase}` | `quality-test` | internal | `post-test` | full, standard |
396
- | milestone-audit | `maestro-milestone-audit` | *(same)* | internal | — | all |
397
- | goal-audit | *(decision-only)* | *(same)* | decision | `post-goal-audit` | all (only if decomposed) |
398
- | milestone-complete | `maestro-milestone-complete` | *(same)* | internal | `post-milestone` | all |
379
+ | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
380
+ |-------|---------------------|-----------------|----------------|--------------|
381
+ | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
382
+ | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
383
+ | init | `maestro-init` | *(same)* | — | all |
384
+ | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
385
+ | roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
386
+ | analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
387
+ | 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 |
388
+ | execute | `maestro-execute {phase}` | `maestro-execute` | — | all |
389
+ | verify | `maestro-verify {phase}` | `maestro-verify` | `post-verify` | all |
390
+ | business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
391
+ | review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
392
+ | test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
393
+ | test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
394
+ | milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
395
+ | goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
396
+ | milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
397
+
398
+ > 所有执行 stage 统一通过 `maestro ralph next` CLI 加载 + 内联执行;decision 节点单独作为独立 step 插入(见规则 4)。
399
399
 
400
400
  **Build rules (按顺序应用):**
401
401
 
@@ -403,18 +403,19 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
403
403
  1. **起点**:从 `session.lifecycle_position` 开始
404
404
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
405
405
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
406
- 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ type: "decision", decision: "<gate>", retry_count: 0, max_retries: 2 }`
406
+ 4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
407
407
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
408
408
  6. **终点硬约束**:chain 以 `milestone-complete` 结尾
409
409
  7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
410
410
  8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
411
- 9. **command_path 解析**(每个非 decision step):
411
+ 9. **command_path 解析**(每个执行 step,decision 节点跳过):
412
412
  - 取 skill 名(args 前的第一个 token)
413
- - 全局优先:`~/.claude/commands/{name}.md` 存在 `command_scope = "global"`
414
- - Fallback:`.claude/commands/{name}.md` 存在 → `command_scope = "project"`
415
- - 两者都缺`command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
416
- - **不在 build 阶段读取 .md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 ralph-execute A_EXEC_INTERNAL 负责(保持入口/工作流分离)
417
- 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `deferred_reads: []`
413
+ - **预校验通过 `run_command("maestro ralph skills --json --quiet")`** 一次性拉取所有可用 commands + skills(global + project,project 覆盖 global),匹配 skill 名得到:
414
+ - 命中 commands → `command_scope = "global" | "project"`,`command_path = <绝对路径>`
415
+ - 命中 skills 同上(type=skill)
416
+ - 未命中 `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
417
+ - **不在 build 阶段读取 .md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
418
+ 10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
418
419
  11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
419
420
  - `scope_verdict ∈ {medium, small}` → 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
420
421
  - `scope_verdict == large` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
@@ -432,7 +433,7 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
432
433
  1. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
433
434
  2. Write `.workflow/.maestro/ralph-{YYYYMMDD-HHmmss}/status.json` (Appendix: Session Schema)
434
435
  3. Display chain overview:每步显示 `{index}. {skill} [{type}] [{command_scope}]`
435
- 4. If `task_decomposition` present: display **Goal Prompt block** (Appendix) → STOP,等用户输入 `/goal`(auto_confirm 也不跳过)
436
+ 4. If `task_decomposition` present: display **Goal Prompt block** (Appendix),不阻塞流程,继续 handoff
436
437
 
437
438
  ### A_DELEGATE_EVALUATE
438
439
 
@@ -593,6 +594,8 @@ Runs only when `task_decomposition` present.
593
594
  {
594
595
  "session_id": "ralph-{YYYYMMDD-HHmmss}",
595
596
  "source": "ralph", "status": "running",
597
+ "ralph_protocol_version": "1", // CLI-driven; absent/0 → legacy inline ralph-execute
598
+ "active_step_index": null, // CLI-managed; only one step held at a time
596
599
  "intent": "", "lifecycle_position": "",
597
600
  "phase": null, "phase_is_new": false,
598
601
  "milestone": "", // D-007 反查结果,禁止读 current_milestone
@@ -607,13 +610,15 @@ Runs only when `task_decomposition` present.
607
610
  "analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
608
611
  "steps": [{
609
612
  "index": 0,
610
- "type": "internal|external|decision",
611
- "skill": "",
613
+ "skill": "", // 执行 step 有值;decision 节点为空字符串/null
612
614
  "args": "",
613
615
  "stage": "", // brainstorm|blueprint|init|analyze-macro|roadmap|analyze|plan|execute|verify|...
614
616
  "scope": null, // "phase"|"standalone"|"milestone"|null(plan 等需要)
615
- "command_scope": "global|project|missing|null",
616
- "command_path": "~/.claude/commands/{name}.md | .claude/commands/{name}.md | null",
617
+ "decision": null, // 非 null → decision 节点(值为 gate 名,如 "post-verify");null → 执行 step
618
+ "retry_count": 0, // decision 节点专用
619
+ "max_retries": 2, // decision 节点专用
620
+ "command_scope": "global|project|missing|null", // 执行 step;decision 节点固定 null
621
+ "command_path": "<absolute path resolved by `maestro ralph skills --json --quiet`> | null",
617
622
  "milestone_id": null, // D-007 反查注入;仅含 {phase} 占位符的 step 有
618
623
  "source_artifact_ref": null, // "analyze:ANL-xxx" | "blueprint:BLP-xxx" | null
619
624
  "status": "pending|running|completed|skipped|failed",
@@ -622,7 +627,8 @@ Runs only when `task_decomposition` present.
622
627
  "completion_status": null,
623
628
  "completion_evidence": null,
624
629
  "completed_at": null,
625
- "deferred_reads": [] // 由 ralph-execute A_EXEC_INTERNAL 解析 .md 时填充
630
+ "deferred_reads": [], // 由 ralph next CLI 解析 .md 时填充
631
+ "load": null // { loaded_at, required_files[], deferred_files[], resolve_version } —— 由 ralph next 写入
626
632
  }],
627
633
  "waves": [], "current_step": 0,
628
634
 
@@ -644,7 +650,7 @@ Runs only when `task_decomposition` present.
644
650
 
645
651
  ### Fix-Loop Templates
646
652
 
647
- 所有插入 step 默认 `type: "internal"`,按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`。
653
+ 所有插入的执行 step A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点(`step.decision` 字段)。
648
654
 
649
655
  **post-verify:**
650
656
  ```
@@ -706,12 +712,12 @@ decision:post-goal-audit {retry+1}
706
712
  链路概览后逐字显示(仅当 decomposition 已产出):
707
713
 
708
714
  ```
709
- 📋 任务分解完成。复制以下 /goal 设定终止条件,随后运行 /maestro-ralph-execute:
715
+ 📋 任务分解完成。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
710
716
 
711
717
  /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。
712
718
  ```
713
719
 
714
- `/goal` 由用户输入;ralph 只输出此提示词。判据以 status.json 为权威。
720
+ `/goal` 由用户输入;ralph 输出提示词后继续 handoff,不阻塞。
715
721
 
716
722
  ### Error Codes
717
723
 
@@ -743,8 +749,8 @@ decision:post-goal-audit {retry+1}
743
749
  - [ ] quality_mode 由 A_DETERMINE_QUALITY_MODE 决定,过滤 build steps
744
750
  - [ ] Decomposition: broad intent ≤3 question clarify;narrow auto-derive
745
751
  - [ ] status.json 唯一真源:boundary_contract + execution_criteria + task_decomposition;无外部清单
746
- - [ ] 每个 step 默认 `type: "internal"`,含 `command_scope` + `command_path`(全局优先 fallback 项目)
747
- - [ ] Ralph build 阶段只解析路径,不读 .md 内容;`<required_reading>` 加载由 ralph-execute A_EXEC_INTERNAL 完成
752
+ - [ ] 执行 step `command_scope` + `command_path`(通过 `maestro ralph skills --json --quiet` 预校验,project 覆盖 global);decision step 通过 `step.decision` 字段标识
753
+ - [ ] Ralph build 阶段只通过 `ralph skills` 校验路径存在性,不读 .md 内容;`<required_reading>` 加载由 `maestro ralph next` CLI 完成
748
754
  - [ ] 每个 step 含 `completion_confirmed` + `completion_status` + `completion_evidence` + `deferred_reads`(初始 false/null/[])
749
755
  - [ ] 每个 sub-goal 含 `completion_confirmed`(初始 false)
750
756
  - [ ] post-goal-audit decision 仅在 decomposed 时插入,位于 milestone-complete 之前
@@ -27,32 +27,29 @@ Remaining → session_id (if matches maestro-* or ralph-*)
27
27
  ```
28
28
  Also read `session.auto_mode` from status.json — if true, treat as `-y`.
29
29
 
30
- **Node types:**
30
+ **Step kinds:**
31
31
 
32
- | Type | Execution | Flow after |
33
- |------|-----------|------------|
34
- | decision (ralph-only) | `Skill("maestro-ralph")` | Execution ends here |
35
- | internal (default) | `view_file({file_path: step.command_path})` + 内联解释执行 | Self-invoke next |
36
- | external (opt-in) | `maestro delegate --to claude --mode write` (STOP → callback) | Self-invoke next |
32
+ | Kind | Identifier | Execution | Flow after |
33
+ |------|-----------|-----------|------------|
34
+ | decision step | `step.decision` 非空 | `Skill("maestro-ralph")` | Execution ends here |
35
+ | 执行 step | `step.decision == null` | `run_command("maestro ralph next")` 内联按其 stdout 执行 → `run_command("maestro ralph complete N --status ...")` | Self-invoke next |
37
36
 
38
37
  HARD RULES:
39
- - internal step:优先通过 `view_file({command_path})` 把命令 .md 加载进当前会话,再按内容执行;不要对 internal step 使用 `Skill({skill})` 调用
40
- - **必须遵循 `<required_reading>` / `<deferred_reading>` 标签**:命令 .md 通常采用"入口 + workflow"形式,主体逻辑放在 workflow 文件中并通过 `<required_reading>` 引用;不加载 required_reading 会导致命令执行不完整
41
- - decision 节点例外:A_EXEC_DECISION 必须使用 `view_file(AbsolutePath="<agy-skills-dir>/maestro-ralph/SKILL.md") + execute inline` 进行 handoff(这是 decision 节点的唯一允许用法)
42
- - `command_path` ralph A_BUILD_STEPS 写入 status.json;ralph-execute 不再自行解析(缺失 报错 E002)
43
- - external 仅在 `step.type == "external"` 显式声明时使用,并 always append `-y` 到 prompt args
44
- - 每个 step 必须产出 `--- COMPLETION STATUS ---` 块,否则视为 NEEDS_RETRY
38
+ - 执行 step:**统一通过 `maestro ralph next` CLI 加载**。CLI 负责读 command_path、解析 `<required_reading>` + `<deferred_reading>`、拼接 prompt、写 `step.load.*` + `active_step_index` + `step.status="running"`。不要再在会话里手动 Read + 解析 required_reading
39
+ - decision step:A_EXEC_DECISION 通过 `view_file(AbsolutePath="<agy-skills-dir>/maestro-ralph/SKILL.md") + execute inline` handoff ralph 评估(不走 CLI)
40
+ - `command_path` ralph 在 A_BUILD_STEPS 写入 status.json(缺失 ralph next 返回 E006/E007 并拒绝执行)
41
+ - 每个 step 结束必须调用 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`。STATUS 4 个合法值:`DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`(**`NEEDS_CONTEXT` 已废除**,context 容量由 harness 自动压缩处理)
45
42
  </context>
46
43
 
47
44
  <invariants>
48
- 1. **Internal = Read + inline**通过 Read 读取 `step.command_path`,按其指令在当前 session 内执行
49
- 2. **Required reading must be loaded**命令 .md 中的 `<required_reading>` 引用的所有文件必须立即 Read;缺一 视为加载失败,pause session(E007
50
- 3. **Deferred reading recorded only** — `<deferred_reading>` 列出的文件路径需记录,执行过程按需 Read;不在加载阶段读取
51
- 4. **Skill loaded confirmation** 所有 required_reading 加载完成后必须输出一行确认:`✓ skill {step.skill} 加载完成 (required: N, deferred: M)`
52
- 5. **External = explicit only**`step.type == "external"` 才走 delegate;默认绝不发起
53
- 6. **必须显式 completion confirmation** — 每个 step 完成时需有 `STATUS: DONE` 且写入 `step.completion_confirmed = true`
54
- 7. **Self-invocation chain** 持续直到全部 `completion_confirmed` 或 paused
55
- 8. **status.json 每步骤后写盘**resume-safe
45
+ 1. **执行 = `ralph next` + inline + `ralph complete`** `maestro ralph next` 拿到 skill 内容,按 stdout 内联执行
46
+ 2. **Required reading CLI 负责**`ralph next` 自动展开 + 加载 `<required_reading>` 引用的所有文件,缺失退出码 1(E007),不写 active_step_index,不进入执行
47
+ 3. **Deferred reading recorded only** — `<deferred_reading>` 路径由 CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
48
+ 4. **一致性取代锁**同一 session 同时最多一个 step `active_step_index`;CLI 校验失败直接退出码 3,不静默推进
49
+ 5. **Completion 通过 CLI 调用**每个 step 末尾调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`,由 CLI 写 `completion_*` + 清 `active_step_index`
50
+ 6. **Self-invocation chain** — 持续直到全部 `completion_confirmed` paused
51
+ 7. **status.json 每步骤后由 CLI 原子写盘** resume-safe
52
+ 8. **STATUS 枚举受限**仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
56
53
  </invariants>
57
54
 
58
55
  <state_machine>
@@ -78,14 +75,13 @@ S_RESOLVE_ARGS:
78
75
  → S_EXECUTE DO: A_RESOLVE_ARGS
79
76
 
80
77
  S_EXECUTE:
81
- → END WHEN: step.type == "decision" DO: A_EXEC_DECISION
82
- → S_POST_EXEC WHEN: step.type == "internal" + success DO: A_EXEC_INTERNAL
83
- → S_HANDLE_FAIL WHEN: step.type == "internal" + failure DO: A_EXEC_INTERNAL
84
- → END WHEN: step.type == "external" DO: A_EXEC_EXTERNAL
85
- (STOP after background delegate; on callback → S_POST_EXEC or S_HANDLE_FAIL)
78
+ → END WHEN: step.decision != null DO: A_EXEC_DECISION
79
+ → S_POST_EXEC WHEN: step.decision == null + ralph complete invoked with DONE|DONE_WITH_CONCERNS DO: A_EXEC_STEP
80
+ → S_HANDLE_FAIL WHEN: step.decision == null + ralph next exit≠0 OR ralph complete with NEEDS_RETRY|BLOCKED DO: A_EXEC_STEP
86
81
 
87
82
  S_POST_EXEC:
88
- → S_LOCATE DO: A_MARK_COMPLETE + Skill("maestro-ralph-execute")
83
+ → S_LOCATE DO: run_command("maestro ralph complete ...") + Skill("maestro-ralph-execute")
84
+ NOTE: CLI 已写完 completion_*, status, active_step_index;无需额外写盘
89
85
 
90
86
  S_HANDLE_FAIL:
91
87
  → S_LOCATE WHEN: auto + not retried DO: A_RETRY
@@ -108,8 +104,8 @@ S_FALLBACK:
108
104
 
109
105
  1. If session_id provided → load `.workflow/.maestro/{session_id}/status.json`
110
106
  2. Else: scan `.workflow/.maestro/*/status.json`, filter `status == "running"`, sort DESC, take first
111
- 3. Extract: session_id, source, steps[], current_step, phase, milestone, intent, auto_mode, context, cli_tool
112
- 4. Find first step with `status == "pending"` next step
107
+ 3. Extract: session_id, source, steps[], phase, milestone, intent, auto_mode, context, cli_tool, active_step_index
108
+ 4. **不在此处选 pending step**——pending 选择由 `maestro ralph next` CLI 内部完成;A_LOCATE_SESSION 只确认 session 存在且 running,由 A_EXEC_STEP 调 CLI 推进
113
109
 
114
110
  ### A_RESOLVE_ARGS
115
111
 
@@ -151,79 +147,41 @@ Write enriched args back to status.json.
151
147
  ### A_EXEC_DECISION
152
148
 
153
149
  1. Mark step running, write status.json
154
- 2. Display: `[{index}/{total}] ◆ {decision} Retry: {retry}/{max}`
150
+ 2. Display: `[{index}/{total}] ◆ {step.decision} Retry: {retry}/{max}`
155
151
  3. `view_file(AbsolutePath="<agy-skills-dir>/maestro-ralph/SKILL.md") + execute inline` — ralph 评估 + handoff
156
152
  4. 执行在此结束
157
153
 
158
- ### A_EXEC_INTERNAL
159
-
160
- 1. Validate `step.command_path != null`;否则 raise E002,pause session
161
- 2. Mark step running, write status.json
162
- 3. Display: `[{index}/{total}] {step.skill} [internal · {step.command_scope}]`
163
- 4. `view_file({ file_path: step.command_path })` — 把命令 .md 全文加载进当前会话(prefer Read over Skill for internal steps;decision 节点另行使用 Skill 见 A_EXEC_DECISION)
164
- 5. **解析 reading 标签**("入口 + workflow"形式核心步骤):
165
- - 抽取 frontmatter `argument-hint` / `allowed-tools`
166
- - 抽取 `<required_reading>` 块的所有 `@path` 引用 → 立刻 `view_file({ file_path: <expanded path> })` 加载(`~/` / `@~/` 展开为用户主目录);任一文件缺失或读取失败 → raise E007,pause session
167
- - 抽取 `<deferred_reading>` 块的所有路径 → 仅记录到 `step.deferred_reads = [...]`,执行阶段按需 Read
168
- - 抽取 `<purpose>/<context>/<state_machine>/<execution>/<actions>` 等指令块
169
- 6. **加载完成确认**:required_reading 全部成功 Read 后,输出一行:
170
- ```
171
- ✓ skill {step.skill} 加载完成 (required: {N}, deferred: {M})
172
- ```
173
- 其中 N = required_reading 引用数,M = deferred_reading 路径数(缺省块按 0 计)
174
- 7. 计算 `effective_args`:`step.args` + auto flag(`auto ? (flag_map[step.skill] || "") : ""`)
175
- 8. 按读到的指令在本会话中**内联执行**:调用允许的工具完成命令所规定的工作,不再发起 delegate;执行过程中如触发 deferred_reading 引用的资源 → 按需 Read
176
- 9. 执行结束:要求最后一段必须包含 `--- COMPLETION STATUS ---` 块(见 A_MARK_COMPLETE)
177
- 10. Return success / failure
178
-
179
- **Auto flag map**: 所有 lifecycle skill → `-y`; `quality-test` → `-y --auto-fix`; 未列出 → 无 flag
180
-
181
- ### A_EXEC_EXTERNAL
154
+ ### A_EXEC_STEP
182
155
 
183
- 仅当 `step.type == "external"` 时使用(默认链路不产生)。
156
+ 1. **Load** — `run_command("maestro ralph next")`
157
+ - 退出码 0 → 按 stdout 内联执行
158
+ - 退出码 2 → 交给 S_LOCATE
159
+ - 退出码 3 → active_step_index 已被占用
160
+ - 退出码 1 → pause session
161
+ 2. **Inline execution** — 按 stdout 执行;deferred_reading 按需 Read
162
+ 3. **Complete**:
163
+ - `run_command("maestro ralph complete N --status DONE [--evidence <path>]")`
164
+ - `run_command("maestro ralph complete N --status DONE_WITH_CONCERNS --concerns \"...\"")`
165
+ - `run_command("maestro ralph retry N")`
166
+ - `run_command("maestro ralph complete N --status BLOCKED --reason \"...\"")`
167
+ 4. **Propagate context signals** — 关键信号 (`PHASE: N` / `scratch_dir: path` / `BLP-xxx`) 写入 `status.json.context`
184
168
 
185
- 1. Mark step running, write status.json
186
- 2. Display: `[{index}/{total}] ⚡ {step.skill} [external]`
187
- 3. 始终在 prompt 内追加 `-y`(delegate session 非交互):`flag = flag_map[step.skill] || "-y"`
188
- 4. Execute:
189
- ```
190
- run_command({
191
- command: `maestro delegate "/${step.skill} ${effective_args}" --to claude --mode write`,
192
- run_in_background: true, timeout: 600000
193
- })
194
- STOP — wait for callback.
195
- ```
196
- 5. On callback: 把回调输出视为 step 的执行结果 → S_POST_EXEC / S_HANDLE_FAIL
197
-
198
- ### A_MARK_COMPLETE
199
-
200
- 1. 从 step 输出中提取 `--- COMPLETION STATUS ---` 块(required)
201
- 2. 解析并写入:
202
- - `STATUS: DONE` → `step.status = "completed"`, `step.completion_confirmed = true`, `step.completion_status = "DONE"`
203
- - `STATUS: DONE_WITH_CONCERNS` → `step.status = "completed"`, `step.completion_confirmed = true`, `step.completion_status = "DONE_WITH_CONCERNS"`, `step.concerns = <CONCERNS>`
204
- - `STATUS: NEEDS_RETRY` → `step.status = "pending"`, `step.retried = true`, `step.completion_confirmed = false`, → S_HANDLE_FAIL
205
- - `STATUS: BLOCKED` / `NEEDS_CONTEXT` → `session.status = "paused"`, `step.completion_status` 记录原因, `step.completion_confirmed = false`
206
- - 缺失 `--- COMPLETION STATUS ---` 块 → 视为 NEEDS_RETRY(不允许 heuristic fallback)
207
- 3. 写入 `step.completion_evidence`(artifact 路径 / 关键输出节选)
208
- 4. 扫描输出抓取 context 信号:`PHASE: N` → session.phase;`scratch_dir: path` → context.scratch_dir;`BLP-xxx` → context.blueprint_session_id
209
- 5. `step.completed_at = now`,写 status.json
210
- 6. **Sub-goal evidence 校验**(task_decomposition 存在时):若 `step.goal_ref` 对应子目标的 `lifecycle` 覆盖当前 stage 且 evidence artifact 已生成 → 暂不直接置 done,仍交由 post-goal-audit 决策;仅在 step 显式确认时更新 `task_decomposition[*].completion_confirmed = false` 占位(保持 pending)
211
- 7. Display: `[{index}/{total}] ✓ {step.skill} completed (confirmed)`
169
+ 完成后 S_LOCATE 触发 `view_file(AbsolutePath="<agy-skills-dir>/maestro-ralph-execute/SKILL.md") + execute inline` 自调用。
212
170
 
213
171
  ### A_RETRY
214
172
 
215
- 1. `step.retried = true`, `step.status = "pending"`, `step.error = null`, `step.completion_confirmed = false`
216
- 2. Write status.json
173
+ 1. `run_command("maestro ralph retry N")` — CLI 设 `step.retried = true`, `step.status = "pending"`, `step.completion_confirmed = false`, `active_step_index`
174
+ 2. Display: `[{index}/{total}] ↻ {step.skill} retry`
217
175
 
218
176
  ### A_SKIP_STEP
219
177
 
220
- 1. `step.status = "skipped"`, `step.completion_confirmed = false`
221
- 2. Write status.json
178
+ 跳过执行 step — 手动编辑 `status.json`:将该 step `status` 设为 `"skipped"`,`completion_confirmed` 设为 `false`,并清 `active_step_index`(若指向此 step)。
179
+ (不提供 CLI 子命令;跳过是非常规操作,避免自动化误用。)
222
180
 
223
181
  ### A_PAUSE_SESSION
224
182
 
225
- 1. `session.status = "paused"`, write status.json
226
- 2. Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。/maestro-ralph continue 恢复。`
183
+ 通常由 `ralph complete N --status BLOCKED --reason "..."` 触发,CLI 已写 `session.status = "paused"`。手动 pause 场景下直接编辑 status.json
184
+ Display: `[{index}/{total}] ✗ {step.skill} 失败,会话已暂停。/maestro-ralph continue 恢复。`
227
185
 
228
186
  ### A_COMPLETE_SESSION
229
187
 
@@ -238,14 +196,14 @@ Write enriched args back to status.json.
238
196
  Session: {session_id} [{source}]
239
197
  Steps: {completed}/{total} confirmed: {confirmed}/{completed}
240
198
 
241
- [✓] 0. maestro-plan 1 [internal · global]
242
- [✓] 1. maestro-execute 1 [internal · project]
243
- [✓] 2. maestro-verify 1 [internal · global]
199
+ [✓] 0. maestro-plan 1 [global]
200
+ [✓] 1. maestro-execute 1 [project]
201
+ [✓] 2. maestro-verify 1 [global]
244
202
  [✓] 3. ◆ post-verify [decision]
245
203
  ...
246
204
  ============================================================
247
205
  ```
248
- Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision, `⚡` external
206
+ Icons: `✓` confirmed, `—` skipped, `✗` failed, `◆` decision
249
207
 
250
208
  </actions>
251
209
 
@@ -258,31 +216,30 @@ Write enriched args back to status.json.
258
216
  | Code | Severity | Description | Recovery |
259
217
  |------|----------|-------------|----------|
260
218
  | E001 | error | No running session found | Suggest /maestro or /maestro-ralph |
261
- | E002 | error | step.command_path missing for internal step | Pause, ask ralph to rebuild step |
262
- | E003 | error | status.json corrupt | Show path, manual check |
263
- | E004 | error | Delegate failed + user abort | Mark paused, suggest resume |
264
- | E005 | error | COMPLETION STATUS block missing | Trigger NEEDS_RETRY |
265
- | E007 | error | required_reading file 缺失或读取失败 | List missing paths, pause session |
219
+ | E006 | error | command_path missing/unreachable for 执行 step | `ralph next` 拒绝;编辑 status.json 或重 build |
220
+ | E007 | error | required_reading 引用文件缺失 | `ralph next` 拒绝;CLI stderr 列出缺失路径 |
221
+ | E008 | error | `ralph complete` idx active_step_index | 编辑 status.json 修正一致性 |
222
+ | E009 | error | `ralph complete` step.status running | 重复 complete 或非法跳跃;编辑 status.json |
223
+ | E010 | error | status.json schema 损坏 | `ralph check` 显示具体损坏字段 |
266
224
  | W001 | warning | Step completed with concerns | Log and continue |
267
- | W002 | warning | command .md `<required_reading>` 标签 | 直接执行 .md 主体,跳过加载阶段 |
225
+ | W005 | warning | active_step_index 指向已 completed step | `ralph next` 自动清理后继续 |
226
+ | W007 | warning | step.skill ≠ command .md frontmatter.name | 提示但不阻塞 |
268
227
 
269
228
  ### Success Criteria
270
229
 
271
230
  - [ ] Session discovery covers maestro-* and ralph-*
272
- - [ ] `-y` parsed from args 或 session.auto_mode
231
+ - [ ] `-y` parsed from args 或 session.auto_mode;auto=true 时透传 `-y` 到 skill args
273
232
  - [ ] Placeholders resolved;per-skill enrichment 正确
274
- - [ ] Decision 节点 Skill("maestro-ralph") handoff
275
- - [ ] Internal 节点通过 view_file({step.command_path}) 内联执行,禁止 Skill()
276
- - [ ] Internal 节点 Read 后必须解析并加载 `<required_reading>` 引用的文件;缺失 E007 pause
277
- - [ ] `<deferred_reading>` 仅记录路径到 `step.deferred_reads`,执行阶段按需 Read
278
- - [ ] required_reading 加载完成后输出 `✓ skill {name} 加载完成 (required: N, deferred: M)`
279
- - [ ] External 仅在显式声明时走 delegate,prompt 必带 `-y`
280
- - [ ] 每个 step 强制 `--- COMPLETION STATUS ---`;缺失 → NEEDS_RETRY
281
- - [ ] step.completion_confirmed = true 仅在 STATUS: DONE/DONE_WITH_CONCERNS 时设置
282
- - [ ] step.completion_evidence 记录 artifact path / 输出节选
283
- - [ ] Context signals 传播 status.json
233
+ - [ ] Decision 节点(`step.decision != null`)走 Skill("maestro-ralph") handoff(**不调 ralph next CLI**)
234
+ - [ ] 执行 step 通过 `run_command("maestro ralph next")` 加载;CLI 返回拼好的 prompt + completion 协议
235
+ - [ ] required_reading CLI 自动加载并拼入 prompt;缺失CLI 退出码 1,pause session
236
+ - [ ] `<deferred_reading>` CLI 记录到 `step.load.deferred_files`,执行阶段按需 Read
237
+ - [ ] 每个 step 末尾必须调 `maestro ralph complete N --status <S>` 或 `maestro ralph retry N`
238
+ - [ ] STATUS 枚举仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;CLI 拒绝 `NEEDS_CONTEXT`
239
+ - [ ] active_step_index 一致性由 CLI 维护;E008/E009 直接退出,不静默推进
240
+ - [ ] step.completion_evidence 通过 `--evidence` 传入并记录
241
+ - [ ] Context signals 由执行 step 显式写回 status.json.context(非 ralph-execute 内嵌扫描)
284
242
  - [ ] Auto mode: retry 一次后 pause;interactive 提供 retry/skip/abort
285
243
  - [ ] 自调用持续到全部 completion_confirmed 或 paused
286
- - [ ] A_COMPLETE_SESSION 校验全部 step confirmed + sub-goal all_done
287
244
 
288
245
  </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
+ - ask_question
7
+ - define_subagent
8
+ - grep_search
9
+ - invoke_subagent
10
+ - manage_subagents
11
+ - replace_file_content
12
+ - run_command
13
+ - send_message
14
+ - view_file
15
+ - write_to_file
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>