maestro-flow 0.5.35 → 0.5.36

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 (269) hide show
  1. package/.agents/agents/cli-explore-agent.md +71 -68
  2. package/.agents/agents/workflow-analyzer.md +1 -0
  3. package/.agents/agents/workflow-debugger.md +1 -0
  4. package/.agents/agents/workflow-executor.md +1 -0
  5. package/.agents/skills/domain-add/SKILL.md +71 -0
  6. package/.agents/skills/maestro/SKILL.md +7 -6
  7. package/.agents/skills/maestro-amend/SKILL.md +0 -2
  8. package/.agents/skills/maestro-analyze/SKILL.md +9 -0
  9. package/.agents/skills/maestro-brainstorm/SKILL.md +10 -1
  10. package/.agents/skills/maestro-collab/SKILL.md +14 -1
  11. package/.agents/skills/maestro-next/SKILL.md +15 -4
  12. package/.agents/skills/maestro-overlay/SKILL.md +4 -3
  13. package/.agents/skills/maestro-plan/SKILL.md +12 -3
  14. package/.agents/skills/maestro-ralph/SKILL.md +89 -14
  15. package/.agents/skills/maestro-tools-register/SKILL.md +0 -6
  16. package/.agents/skills/maestro-ui-codify/SKILL.md +0 -2
  17. package/.agents/skills/manage-kg-extractors/SKILL.md +0 -2
  18. package/.agents/skills/quality-test/SKILL.md +0 -2
  19. package/.agents/skills/spec-load/SKILL.md +0 -1
  20. package/.agents/skills/spec-setup/SKILL.md +0 -1
  21. package/.agents/skills/team-lifecycle-v4/roles/analyst/role.md +13 -7
  22. package/.agents/skills/team-quality-assurance/roles/scout/role.md +15 -11
  23. package/.agents/skills/team-tech-debt/roles/scanner/role.md +1 -1
  24. package/.agents/skills/team-ultra-analyze/roles/explorer/role.md +23 -16
  25. package/.agy/agents/cli-explore-agent.md +71 -68
  26. package/.agy/agents/workflow-analyzer.md +1 -0
  27. package/.agy/agents/workflow-debugger.md +1 -0
  28. package/.agy/agents/workflow-executor.md +1 -0
  29. package/.agy/skills/domain-add/SKILL.md +68 -0
  30. package/.agy/skills/maestro/SKILL.md +7 -6
  31. package/.agy/skills/maestro-amend/SKILL.md +0 -2
  32. package/.agy/skills/maestro-analyze/SKILL.md +9 -0
  33. package/.agy/skills/maestro-brainstorm/SKILL.md +10 -1
  34. package/.agy/skills/maestro-collab/SKILL.md +14 -1
  35. package/.agy/skills/maestro-next/SKILL.md +15 -4
  36. package/.agy/skills/maestro-overlay/SKILL.md +4 -3
  37. package/.agy/skills/maestro-plan/SKILL.md +12 -3
  38. package/.agy/skills/maestro-ralph/SKILL.md +89 -14
  39. package/.agy/skills/maestro-tools-register/SKILL.md +0 -6
  40. package/.agy/skills/maestro-ui-codify/SKILL.md +0 -2
  41. package/.agy/skills/manage-kg-extractors/SKILL.md +0 -2
  42. package/.agy/skills/quality-test/SKILL.md +0 -2
  43. package/.agy/skills/spec-load/SKILL.md +0 -1
  44. package/.agy/skills/spec-setup/SKILL.md +0 -1
  45. package/.agy/skills/team-lifecycle-v4/roles/analyst/role.md +13 -7
  46. package/.agy/skills/team-quality-assurance/roles/scout/role.md +15 -11
  47. package/.agy/skills/team-tech-debt/roles/scanner/role.md +1 -1
  48. package/.agy/skills/team-ultra-analyze/roles/explorer/role.md +23 -16
  49. package/.claude/agents/cli-explore-agent.md +71 -68
  50. package/.claude/agents/workflow-analyzer.md +1 -0
  51. package/.claude/agents/workflow-debugger.md +1 -0
  52. package/.claude/agents/workflow-executor.md +1 -0
  53. package/.claude/commands/domain-add.md +69 -0
  54. package/.claude/commands/maestro-amend.md +0 -2
  55. package/.claude/commands/maestro-analyze.md +9 -0
  56. package/.claude/commands/maestro-brainstorm.md +10 -1
  57. package/.claude/commands/maestro-collab.md +14 -1
  58. package/.claude/commands/maestro-next.md +15 -4
  59. package/.claude/commands/maestro-overlay.md +4 -3
  60. package/.claude/commands/maestro-plan.md +12 -3
  61. package/.claude/commands/maestro-ralph.md +89 -14
  62. package/.claude/commands/maestro-tools-register.md +0 -6
  63. package/.claude/commands/maestro-ui-codify.md +0 -2
  64. package/.claude/commands/maestro.md +7 -6
  65. package/.claude/commands/manage-kg-extractors.md +0 -2
  66. package/.claude/commands/quality-test.md +0 -2
  67. package/.claude/commands/spec-load.md +0 -1
  68. package/.claude/commands/spec-setup.md +0 -1
  69. package/.claude/skills/team-lifecycle-v4/roles/analyst/role.md +13 -7
  70. package/.claude/skills/team-quality-assurance/roles/scout/role.md +15 -11
  71. package/.claude/skills/team-tech-debt/roles/scanner/role.md +1 -1
  72. package/.claude/skills/team-ultra-analyze/roles/explorer/role.md +23 -16
  73. package/.codex/skills/domain-add/SKILL.md +79 -0
  74. package/.codex/skills/domain-discover/SKILL.md +43 -0
  75. package/.codex/skills/domain-list/SKILL.md +38 -0
  76. package/.codex/skills/learn-follow/SKILL.md +0 -3
  77. package/.codex/skills/learn-investigate/SKILL.md +0 -3
  78. package/.codex/skills/learn-retro/SKILL.md +0 -2
  79. package/.codex/skills/maestro/SKILL.md +17 -11
  80. package/.codex/skills/maestro-amend/SKILL.md +0 -2
  81. package/.codex/skills/maestro-analyze/SKILL.md +16 -3
  82. package/.codex/skills/maestro-blueprint/SKILL.md +0 -4
  83. package/.codex/skills/maestro-brainstorm/SKILL.md +16 -2
  84. package/.codex/skills/maestro-collab/SKILL.md +14 -1
  85. package/.codex/skills/maestro-companion/SKILL.md +0 -2
  86. package/.codex/skills/maestro-fork/SKILL.md +0 -2
  87. package/.codex/skills/maestro-grill/SKILL.md +0 -1
  88. package/.codex/skills/maestro-next/SKILL.md +12 -5
  89. package/.codex/skills/maestro-plan/SKILL.md +17 -2
  90. package/.codex/skills/maestro-ralph/SKILL.md +4 -3
  91. package/.codex/skills/maestro-roadmap/SKILL.md +0 -2
  92. package/.codex/skills/manage-wiki/SKILL.md +0 -2
  93. package/.codex/skills/odyssey-debug/SKILL.md +0 -2
  94. package/.codex/skills/odyssey-improve/SKILL.md +0 -6
  95. package/.codex/skills/odyssey-review-test-fix/SKILL.md +0 -3
  96. package/.codex/skills/odyssey-ui/SKILL.md +0 -3
  97. package/.codex/skills/spec-setup/SKILL.md +0 -2
  98. package/.codex/skills/team-coordinate/SKILL.md +0 -3
  99. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +0 -2
  100. package/chains/_intent-map.json +36 -0
  101. package/chains/blueprint-driven.json +49 -0
  102. package/chains/grill-driven.json +51 -0
  103. package/dashboard/dist-server/dashboard/src/server/agents/adapter-factory.js +4 -0
  104. package/dashboard/dist-server/dashboard/src/server/agents/adapter-factory.js.map +1 -1
  105. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.d.ts +6 -0
  106. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js +36 -0
  107. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js.map +1 -0
  108. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.d.ts +1 -1
  109. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js.map +1 -1
  110. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +1 -1
  111. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  112. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  113. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  114. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +492 -1
  115. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  116. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +6 -1
  117. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +92 -4
  118. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  119. package/dashboard/dist-server/dashboard/src/shared/constants.js +2 -0
  120. package/dashboard/dist-server/dashboard/src/shared/constants.js.map +1 -1
  121. package/dashboard/dist-server/shared/agent-types.d.ts +1 -1
  122. package/dashboard/dist-server/src/commands/hooks.js +49 -1
  123. package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
  124. package/dashboard/dist-server/src/graph/kg/extraction/knowledge/domain-extractor.js +4 -2
  125. package/dashboard/dist-server/src/graph/kg/extraction/knowledge/domain-extractor.js.map +1 -1
  126. package/dashboard/dist-server/src/graph/kg/extraction/knowledge-extractor-registry.js +6 -1
  127. package/dashboard/dist-server/src/graph/kg/extraction/knowledge-extractor-registry.js.map +1 -1
  128. package/dashboard/dist-server/src/hooks/session-context.js +37 -1
  129. package/dashboard/dist-server/src/hooks/session-context.js.map +1 -1
  130. package/dashboard/dist-server/src/search/daemon.d.ts +42 -0
  131. package/dashboard/dist-server/src/search/daemon.js +180 -0
  132. package/dashboard/dist-server/src/search/daemon.js.map +1 -0
  133. package/dashboard/dist-server/src/tools/domain-loader.d.ts +4 -1
  134. package/dashboard/dist-server/src/tools/domain-loader.js +56 -25
  135. package/dashboard/dist-server/src/tools/domain-loader.js.map +1 -1
  136. package/dashboard/dist-server/src/tools/domain-schema.d.ts +1 -1
  137. package/dashboard/dist-server/src/tools/domain-schema.js +1 -1
  138. package/dist/shared/agent-types.d.ts +1 -1
  139. package/dist/shared/agent-types.d.ts.map +1 -1
  140. package/dist/src/agents/api-explore/agent-loop.d.ts +14 -0
  141. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -0
  142. package/dist/src/agents/api-explore/agent-loop.js +86 -0
  143. package/dist/src/agents/api-explore/agent-loop.js.map +1 -0
  144. package/dist/src/agents/api-explore/config.d.ts +42 -0
  145. package/dist/src/agents/api-explore/config.d.ts.map +1 -0
  146. package/dist/src/agents/api-explore/config.js +99 -0
  147. package/dist/src/agents/api-explore/config.js.map +1 -0
  148. package/dist/src/agents/api-explore/index.d.ts +2 -0
  149. package/dist/src/agents/api-explore/index.d.ts.map +1 -0
  150. package/dist/src/agents/api-explore/index.js +102 -0
  151. package/dist/src/agents/api-explore/index.js.map +1 -0
  152. package/dist/src/agents/api-explore/llm.d.ts +28 -0
  153. package/dist/src/agents/api-explore/llm.d.ts.map +1 -0
  154. package/dist/src/agents/api-explore/llm.js +48 -0
  155. package/dist/src/agents/api-explore/llm.js.map +1 -0
  156. package/dist/src/agents/api-explore/prompt-parser.d.ts +23 -0
  157. package/dist/src/agents/api-explore/prompt-parser.d.ts.map +1 -0
  158. package/dist/src/agents/api-explore/prompt-parser.js +73 -0
  159. package/dist/src/agents/api-explore/prompt-parser.js.map +1 -0
  160. package/dist/src/agents/api-explore/runner.d.ts +65 -0
  161. package/dist/src/agents/api-explore/runner.d.ts.map +1 -0
  162. package/dist/src/agents/api-explore/runner.js +196 -0
  163. package/dist/src/agents/api-explore/runner.js.map +1 -0
  164. package/dist/src/agents/api-explore/session.d.ts +23 -0
  165. package/dist/src/agents/api-explore/session.d.ts.map +1 -0
  166. package/dist/src/agents/api-explore/session.js +57 -0
  167. package/dist/src/agents/api-explore/session.js.map +1 -0
  168. package/dist/src/agents/api-explore/stream-json-emitter.d.ts +10 -0
  169. package/dist/src/agents/api-explore/stream-json-emitter.d.ts.map +1 -0
  170. package/dist/src/agents/api-explore/stream-json-emitter.js +19 -0
  171. package/dist/src/agents/api-explore/stream-json-emitter.js.map +1 -0
  172. package/dist/src/agents/api-explore/system-prompt.d.ts +2 -0
  173. package/dist/src/agents/api-explore/system-prompt.d.ts.map +1 -0
  174. package/dist/src/agents/api-explore/system-prompt.js +31 -0
  175. package/dist/src/agents/api-explore/system-prompt.js.map +1 -0
  176. package/dist/src/agents/api-explore/tools.d.ts +11 -0
  177. package/dist/src/agents/api-explore/tools.d.ts.map +1 -0
  178. package/dist/src/agents/api-explore/tools.js +168 -0
  179. package/dist/src/agents/api-explore/tools.js.map +1 -0
  180. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  181. package/dist/src/agents/cli-agent-runner.js +3 -0
  182. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  183. package/dist/src/cli.js +3 -0
  184. package/dist/src/cli.js.map +1 -1
  185. package/dist/src/commands/domain.d.ts.map +1 -1
  186. package/dist/src/commands/domain.js +5 -4
  187. package/dist/src/commands/domain.js.map +1 -1
  188. package/dist/src/commands/explore.d.ts +7 -0
  189. package/dist/src/commands/explore.d.ts.map +1 -0
  190. package/dist/src/commands/explore.js +201 -0
  191. package/dist/src/commands/explore.js.map +1 -0
  192. package/dist/src/commands/hooks.d.ts.map +1 -1
  193. package/dist/src/commands/hooks.js +49 -1
  194. package/dist/src/commands/hooks.js.map +1 -1
  195. package/dist/src/commands/search.d.ts +21 -4
  196. package/dist/src/commands/search.d.ts.map +1 -1
  197. package/dist/src/commands/search.js +289 -93
  198. package/dist/src/commands/search.js.map +1 -1
  199. package/dist/src/commands/workspace.d.ts.map +1 -1
  200. package/dist/src/commands/workspace.js +9 -3
  201. package/dist/src/commands/workspace.js.map +1 -1
  202. package/dist/src/config/cli-tools-defaults.json +2 -1
  203. package/dist/src/graph/kg/extraction/knowledge/domain-extractor.d.ts.map +1 -1
  204. package/dist/src/graph/kg/extraction/knowledge/domain-extractor.js +4 -2
  205. package/dist/src/graph/kg/extraction/knowledge/domain-extractor.js.map +1 -1
  206. package/dist/src/graph/kg/extraction/knowledge-extractor-registry.d.ts.map +1 -1
  207. package/dist/src/graph/kg/extraction/knowledge-extractor-registry.js +6 -1
  208. package/dist/src/graph/kg/extraction/knowledge-extractor-registry.js.map +1 -1
  209. package/dist/src/graph/kg/surface/cli.d.ts.map +1 -1
  210. package/dist/src/graph/kg/surface/cli.js +5 -2
  211. package/dist/src/graph/kg/surface/cli.js.map +1 -1
  212. package/dist/src/hooks/session-context.d.ts.map +1 -1
  213. package/dist/src/hooks/session-context.js +37 -1
  214. package/dist/src/hooks/session-context.js.map +1 -1
  215. package/dist/src/ralph/cmd-next.js +64 -1
  216. package/dist/src/ralph/cmd-next.js.map +1 -1
  217. package/dist/src/ralph/status-schema.d.ts +1 -0
  218. package/dist/src/ralph/status-schema.d.ts.map +1 -1
  219. package/dist/src/search/daemon.d.ts +43 -0
  220. package/dist/src/search/daemon.d.ts.map +1 -0
  221. package/dist/src/search/daemon.js +180 -0
  222. package/dist/src/search/daemon.js.map +1 -0
  223. package/dist/src/tools/__tests__/domain-search-debug.js +3 -1
  224. package/dist/src/tools/__tests__/domain-search-debug.js.map +1 -1
  225. package/dist/src/tools/domain-loader.d.ts +4 -1
  226. package/dist/src/tools/domain-loader.d.ts.map +1 -1
  227. package/dist/src/tools/domain-loader.js +56 -25
  228. package/dist/src/tools/domain-loader.js.map +1 -1
  229. package/dist/src/tools/domain-schema.d.ts +1 -1
  230. package/dist/src/tools/domain-schema.js +1 -1
  231. package/dist/src/utils/update-notices.js +12 -0
  232. package/dist/src/utils/update-notices.js.map +1 -1
  233. package/package.json +5 -3
  234. package/shared/agent-types.ts +1 -1
  235. package/templates/search-tools.md +22 -6
  236. package/workflows/agy-instructions.md +0 -4
  237. package/workflows/analyze.md +2 -2
  238. package/workflows/boundary-grill.md +50 -0
  239. package/workflows/brainstorm.md +6 -5
  240. package/workflows/claude-instructions.md +12 -0
  241. package/workflows/codebase-rebuild.md +0 -1
  242. package/workflows/codex-instructions.md +12 -0
  243. package/workflows/debug.md +0 -4
  244. package/workflows/domain-add.md +115 -0
  245. package/workflows/execute.md +7 -0
  246. package/workflows/explore-usage.md +128 -0
  247. package/workflows/finish-work.md +2 -6
  248. package/workflows/fork.md +0 -4
  249. package/workflows/grill.md +14 -1
  250. package/workflows/harvest.md +0 -3
  251. package/workflows/impeccable/audit.md +0 -2
  252. package/workflows/impeccable/codex.md +0 -4
  253. package/workflows/init.md +9 -0
  254. package/workflows/interview-mechanics.md +3 -2
  255. package/workflows/issue-analyze.md +0 -5
  256. package/workflows/issue-gaps-analyze.codex.md +0 -6
  257. package/workflows/knowledge-audit.md +0 -4
  258. package/workflows/learn.md +0 -6
  259. package/workflows/maestro.codex.md +0 -4
  260. package/workflows/maestro.md +31 -18
  261. package/workflows/merge.md +0 -4
  262. package/workflows/milestone-complete.md +0 -4
  263. package/workflows/overlays.md +0 -10
  264. package/workflows/plan.md +0 -2
  265. package/workflows/roadmap-common.md +0 -4
  266. package/workflows/tdd.md +0 -2
  267. package/workflows/tools-spec.md +1 -7
  268. package/workflows/ui-codify-extract.md +0 -2
  269. package/workflows/ui-codify-package.md +0 -2
@@ -24,7 +24,7 @@ $ARGUMENTS — intent text, flags, or keywords.
24
24
 
25
25
  **Parse:**
26
26
  ```
27
- -y flag → auto_confirm = true
27
+ -y flag → auto_confirm = true # 唯一来源:用户显式传入;ralph 不内部推断(invariant 14)
28
28
  --roadmap → wants_roadmap = true (强制多发布 roadmap 路径;roadmap 默认 opt-in)
29
29
  .md/.txt path → input_doc (supplementary context only, NEVER substitutes lifecycle stages)
30
30
  Remaining → intent
@@ -50,6 +50,9 @@ Remaining → intent
50
50
  11. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop;字段可选/累加,既有字段不删不改
51
51
  12. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作。不得以 "效率" 或 "意图明确" 为由绕过。特别是 invariant 1(ralph 不执行 step)和 invariant 6(completion_confirmed 由 CLI 写入)不可隐性违反。
52
52
  13. **Delegate fallback 必须标记** — A_DELEGATE_EVALUATE 解析 verdict 失败时 fallback 为 "fix",但 MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`,后续 step 继承 LOW CONFIDENCE 标记。
53
+ 14. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定;ralph 不得内部推断。`session.auto_mode` 仅反映用户输入。
54
+ 15. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有(`source=="ralph"` → `decomposition_owner="ralph"`;`source=="maestro"` → `"maestro"`)。contract 已存在时,后续 S_DECOMPOSE MUST 跳过 ask_user,仅做 shape 校验 + 缺省补齐;goal-audit 只更新 `task_decomposition[*].status/completion_confirmed/completed_at`,禁止改 `goal/done_when/boundary`。
55
+ 16. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点;Pipeline 命令只拥有自身 artifact GATE(GATE 失败 → `maestro ralph complete <idx> --status BLOCKED|NEEDS_RETRY`,自身 GATE 全过 → DONE);Router 命令不得出现在 FSM step 内。
53
56
  </invariants>
54
57
 
55
58
  <state_machine>
@@ -139,11 +142,14 @@ S_DECISION_EVAL: (decision 节点 == `step.decision` 非空,下述 gate 名取
139
142
  DO: A_SCOPE_EVALUATE
140
143
  → S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
141
144
  DO: A_STRUCTURAL_EVALUATE
145
+ → S_APPLY_VERDICT WHEN: reground-gate (post-reground)
146
+ DO: A_REGROUND_EVALUATE
142
147
 
143
148
  S_APPLY_VERDICT:
144
149
  → S_DISPATCH WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
145
- → S_DISPATCH WHEN: post-goal-audit + unmet sub-goals DO: A_APPLY_GOAL_FIX
146
- → S_DISPATCH WHEN: post-goal-audit + all sub-goals met DO: A_APPLY_GOAL_DONE
150
+ → S_DISPATCH WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
151
+ → S_DISPATCH WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
152
+ → END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT(尾部漂移熔断)
147
153
  → S_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
148
154
  → S_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
149
155
  → S_DISPATCH WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
@@ -151,11 +157,15 @@ S_APPLY_VERDICT:
151
157
  → END WHEN: post-milestone + standard + no next milestone DO: mark completed
152
158
  → END WHEN: post-milestone + adhoc DO: mark completed (adhoc self-contained)
153
159
  → END WHEN: post-debug-escalate (always STOP) DO: A_PAUSE_ESCALATE
160
+ → END WHEN: post-reground + drifted + confidence_score >= 60 DO: A_REGROUND_HALT
161
+ → S_DISPATCH WHEN: post-reground + aligned DO: A_APPLY_PROCEED
162
+ → S_DISPATCH WHEN: post-reground + drifted + confidence_score < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
154
163
  GUARD: retry_count >= max_retries → force escalate
155
164
  GUARD: confidence_score < 60 AND proceed → override to fix
156
165
  GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
157
166
  GUARD: auto_confirm → skip user prompt, apply adjusted verdict
158
167
  GUARD: not auto_confirm → ask_user with override options
168
+ GUARD: post-reground + drifted + confidence_score >= 60 → A_REGROUND_HALT(漂移熔断为安全门,auto_confirm 不跳过)
159
169
 
160
170
  S_FALLBACK:
161
171
  → S_PARSE_ROUTE WHEN: user provides input DO: ask_user
@@ -213,7 +223,7 @@ resolve_milestone(phase_number):
213
223
 
214
224
  | Pattern | Position |
215
225
  |---------|----------|
216
- | 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时跳过,直接 `brainstorm`**) |
226
+ | 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时透传 `-y`,grill 以 Auto mode 代码代答,不跳过**) |
217
227
  | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
218
228
  | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
219
229
  | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
@@ -275,7 +285,8 @@ wants_roadmap = (--roadmap flag)
275
285
  | passed==true, no review.json | `business-test` |
276
286
  | review.json: verdict=="BLOCK" | `review-failed` |
277
287
  | review.json: verdict!="BLOCK" | `test` |
278
- | uat.md: all passed | `milestone-audit` |
288
+ | uat.md: all passed + `session.milestone` 存在 | `milestone-audit` |
289
+ | uat.md: all passed + `session.milestone=null` (standalone) | 标记 session completed(无 milestone 可审计) |
279
290
  | uat.md: has failures | `test-failed` |
280
291
 
281
292
  ### A_DETERMINE_QUALITY_MODE
@@ -320,7 +331,9 @@ options:
320
331
 
321
332
  ### A_DECOMPOSE_TASKS
322
333
 
323
- Runs once before chain build; additive to status.json.
334
+ Runs once before chain build; additive to status.json. 设 `session.decomposition_owner = "ralph"`。
335
+
336
+ **0. Ownership guard** (invariant 15): 若 `session.boundary_contract` 或 `session.task_decomposition` 已非空(上游 maestro 已写入,`decomposition_owner == "maestro"`)→ MUST 跳过下述提问,仅做 shape 校验 + 缺省字段补齐,直接进入步骤 6。
324
337
 
325
338
  **1. Classify intent breadth:**
326
339
 
@@ -357,11 +370,11 @@ narrow → derive defaults from intent + codebase, skip questions.
357
370
 
358
371
  ### A_BUILD_STEPS
359
372
 
360
- Generate steps from `session.lifecycle_position` to `milestone-complete`.
373
+ Generate steps from `session.lifecycle_position` to `milestone-complete`(`session.milestone` 存在时)或最后一个质量门(standalone 时)。
361
374
 
362
375
  | Stage | invoke_skill(independent) | invoke_skill(unified) | Decision after | quality_mode |
363
376
  |-------|---------------------|-----------------|----------------|--------------|
364
- | grill | `maestro-grill "{intent}"` | *(same)* | — | all (**skip when auto_confirm**) |
377
+ | grill | `maestro-grill "{intent}"` | *(same)* | — | all (**auto_confirm 透传 `-y` 到 grill args,不删除 stage**) |
365
378
  | brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
366
379
  | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
367
380
  | init | `maestro-init` | *(same)* | — | all |
@@ -389,11 +402,12 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
389
402
  1. **起点**:从 `session.lifecycle_position` 开始
390
403
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
391
404
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
392
- 3.5. **grill auto_confirm 跳过**:`auto_confirm == true` 时删除 `grill` stage(grill 为交互式苏格拉底拷问,不支持自动模式);brainstorm args 不含 `--from grill:*`
405
+ 3.5. **grill auto_confirm 透传**:`auto_confirm == true` 时为 `grill` step args 追加 `-y`(grill 自身 Auto mode 用代码代答,见 maestro-grill `<context>` Mode selection);保留 `grill` stage 与 brainstorm `--from grill:*`(grill 仍产出 grill-report/terminology/context-package)
393
406
  3.6. **frontend-verify UI 门控**:仅当当前 phase 交付前端(检出 `dashboard/` 目录,或 phase 目标/计划含 UI 关键词 `landing|page|dashboard|frontend|UI|component|界面`)时保留 `frontend-verify` stage + `post-frontend-verify` decision;纯后端 phase 删除该 stage
394
407
  4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
395
408
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(execute/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
396
- 6. **终点硬约束**:chain `milestone-complete` 结尾
409
+ 5.5. **re-grounding 插入**:当 `task_decomposition` 存在 **且** 链路含 ≥3 个执行 step(不含 decision 节点)时,从第 3 个执行 step 起每隔 3 个执行 step 后插入 `{ decision: "post-reground", retry_count: 0, max_retries: 0, command_scope: null, command_path: null }`。不在最后一个执行 step 之后插入(由 goal-audit 覆盖);不与已有 quality-gate decision 节点相邻(顺延到下一个 3-step 边界);fix-loop 动态插入的 step(index > 原始 chain 长度)不纳入计数
410
+ 6. **终点硬约束**:`session.milestone` 存在时 chain 以 `milestone-complete` 结尾;`session.milestone=null`(standalone)时跳过 `milestone-audit` + `milestone-complete` stage,chain 以最后一个质量门 stage 结尾
397
411
  7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
398
412
  8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
399
413
  9. **command_path 解析**(每个执行 step,decision 节点跳过):
@@ -496,14 +510,18 @@ Runs only when `task_decomposition` present.
496
510
  1. 读取 status.json.task_decomposition 中 status!=done 的子目标
497
511
  2. 打开 evidence 产物,对照 done_when 严格判定
498
512
  3. 输出 met / unmet,unmet 给出 gap + target_phase
513
+ 4. 对照 intent + definition_of_done 判定累积产出是否仍服务原始意图(意图保真检查)
499
514
  CONTEXT:
500
- status.json = {session_dir}/status.json
501
- evidence = {evidence artifacts}
515
+ status.json = {session_dir}/status.json
516
+ intent = {session.intent}
517
+ definition_of_done = {boundary_contract.definition_of_done}
518
+ evidence = {evidence artifacts}
502
519
  execution_criteria = {execution_criteria}
503
520
  boundary_contract = {boundary_contract}
504
521
  EXPECTED:
505
522
  ---VERDICT---
506
523
  STATUS=all_met|has_unmet
524
+ INTENT_ALIGNED=true|false
507
525
  UNMET=[{id:G2,gap:'...',target_phase:execute}, ...]
508
526
  CONFIDENCE_SCORE=0-100
509
527
  ---END---
@@ -516,9 +534,64 @@ Runs only when `task_decomposition` present.
516
534
  ```
517
535
  4. On callback: 对每个 met 子目标,set `task_decomposition[i].status="done"` + `completion_confirmed=true` + `completed_at=now`
518
536
  5. Append `{session_dir}/decisions.ndjson` with `"type": "goal-gate"`, `unmet_count`, `unmet_ids`
519
- 6. Verdict: `all_met` → A_APPLY_GOAL_DONE; `has_unmet` → A_APPLY_GOAL_FIX
537
+ 6. Verdict routing:
538
+ - `all_met` + `INTENT_ALIGNED=true` → A_APPLY_GOAL_DONE
539
+ - `all_met` + `INTENT_ALIGNED=false` → A_REGROUND_HALT(尾部漂移熔断,auto_confirm 不跳过)
540
+ - `has_unmet` → A_APPLY_GOAL_FIX
520
541
  GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
521
542
 
543
+ ### A_REGROUND_EVALUATE
544
+
545
+ 仅当 `task_decomposition` 存在。周期触发(build rule 5.5)。
546
+
547
+ 1. 从 status.json 读取:`session.intent`、`session.boundary_contract`、`steps[]` 中 `status=="completed"` 的 step + `completion_evidence`、`task_decomposition` 中已 done 子目标的 `goal` + `done_when`
548
+ 2. Delegate read-only audit (run_in_background, STOP, wait):
549
+ ```
550
+ maestro delegate "PURPOSE: 意图保真检查 — 对照 intent 验证累积执行是否漂移
551
+ TASK:
552
+ 1. 读取 intent + boundary_contract.definition_of_done
553
+ 2. 读取已完成 steps 的 completion_evidence + 已 done 子目标 done_when
554
+ 3. 判定累积产出是否仍服务 intent;是否有 step 产出超出 in_scope 或触碰 out_of_scope
555
+ 4. 输出 aligned / drifted,drifted 给出 drift_description + corrective_action
556
+ CONTEXT:
557
+ intent = {session.intent}
558
+ definition_of_done = {boundary_contract.definition_of_done}
559
+ in_scope = {boundary_contract.in_scope}
560
+ out_of_scope = {boundary_contract.out_of_scope}
561
+ completed_steps = [{index, skill, stage, completion_evidence}, ...]
562
+ done_goals = [{id, goal, done_when}, ...]
563
+ EXPECTED:
564
+ ---VERDICT---
565
+ STATUS=aligned|drifted
566
+ DRIFT_DESCRIPTION=<空或具体描述>
567
+ CORRECTIVE_ACTION=<空或建议>
568
+ CONFIDENCE_SCORE=0-100
569
+ ---END---
570
+ CONSTRAINTS:
571
+ - 只评估,不修改文件
572
+ - aligned 阈值:≥80% 已完成产出直接服务 intent
573
+ - 单个 step 触碰 out_of_scope → 直接判 drifted"
574
+ --role analyze --mode analysis
575
+ ```
576
+ 3. On callback: parse verdict
577
+ 4. Append `{session_dir}/decisions.ndjson`:`{ "id": "DEC-{ts}", "type": "reground-gate", "source": "ralph", "node_id": "post-reground", "verdict": "{aligned|drifted}", "confidence_score": {N}, "drift_description": "...", "corrective_action": "..." }`
578
+ 5. Verdict routing:`aligned` → A_APPLY_PROCEED;`drifted` + `confidence_score >= 60` → A_REGROUND_HALT;`drifted` + `confidence_score < 60` → A_APPLY_PROCEED(标 LOW CONFIDENCE)
579
+
580
+ ### A_REGROUND_HALT
581
+
582
+ 漂移熔断(安全门,auto_confirm 不跳过)。
583
+
584
+ 1. Set `session.status = "paused"`,write status.json
585
+ 2. Display:
586
+ ```
587
+ ⚠️ Re-grounding 检测失败 — 执行已偏离 intent。
588
+ Intent: {session.intent}
589
+ Drift: {drift_description}
590
+ 建议回归: {corrective_action}
591
+ 选项:1) /maestro-ralph continue 忽略漂移继续 2) 手动修正后 continue 3) /maestro-ralph status 查看后决定
592
+ ```
593
+ 3. GUARD: auto_confirm 对本动作无效——漂移熔断不可自动跳过
594
+
522
595
  ### A_APPLY_PROCEED
523
596
 
524
597
  1. Mark decision completed, write status.json
@@ -593,6 +666,8 @@ Runs only when `task_decomposition` present.
593
666
  "phase": null, "phase_is_new": false,
594
667
  "milestone": "", // D-007 反查结果,禁止读 current_milestone
595
668
  "auto_mode": false,
669
+ "decomposition_owner": "ralph", // 分解契约所有者(invariant 15);缺省按 source 推断
670
+
596
671
  "quality_mode": "standard", // "full" | "standard" | "quick"
597
672
  "planning_mode": "independent", // "unified" | "independent"
598
673
  "scope_verdict": null, // "large" | "medium" | "small" | "unknown" | null
@@ -743,7 +818,7 @@ decision:post-goal-audit {retry+1}
743
818
  - [ ] D-007 反查:phase 数字 → `session.milestone`,禁止读 current_milestone;写入 step.milestone_id
744
819
  - [ ] phase_is_new=true → lifecycle_position 强制 `analyze`
745
820
  - [ ] Intent overrides 识别 grill / brainstorm / blueprint / analyze-macro
746
- - [ ] auto_confirm=true 时 grill stage 跳过(交互式拷问不支持自动模式)
821
+ - [ ] auto_confirm=true 时 grill step args 追加 `-y`(grill 以 Auto mode 执行,stage 不跳过,产出 grill-report/terminology/context-package)
747
822
  - [ ] A_RESOLVE_SCOPE_VERDICT 读 macro analyze conclusions.scope_verdict,写入 session.scope_verdict + analyze_macro_id
748
823
  - [ ] 链路起点 = analyze-macro 时:large+wants_roadmap→roadmap+analyze+plan(phase);其余(含 large 默认/medium/small)→直跳 plan --from analyze:{ANL_ID}(跳过 roadmap+analyze)
749
824
  - [ ] post-analyze-scope decision 节点在 macro analyze 之后插入;A_SCOPE_EVALUATE/A_APPLY_SCOPE_VERDICT 重塑链路
@@ -70,12 +70,8 @@ Parse $ARGUMENTS to determine mode:
70
70
  - Update frontmatter via: `maestro wiki update <id> --frontmatter '{"tool": true, "category": "<cat>", "summary": "<summary>"}'`
71
71
  - Do NOT recreate the document — modify in place
72
72
 
73
- **For all modes** — identify the usage timing: when should an agent or user invoke this tool? This becomes the first line of the entry description (see Step 5).
74
-
75
73
  ### Step 3: Determine Category
76
74
 
77
- **Core principle**: `category` = **who consumes this tool** (which agent type discovers and uses it), not what the content is about.
78
-
79
75
  | Category | Consumer Agent | Decision Question | Signal Words |
80
76
  |---|---|---|---|
81
77
  | `coding` | code-developer, workflow-executor | 开发者实现时需要这个流程吗? | build, deploy, integrate, configure, setup, migrate, api-contract |
@@ -89,8 +85,6 @@ Parse $ARGUMENTS to determine mode:
89
85
  - API verification steps (how to test) → `category: test` (RCP-*, tool: true)
90
86
  - Ask user when ambiguous: "This tool content serves both developers and testers. Split into separate documents?"
91
87
 
92
- **Ambiguous cases**: Choose the **primary consumer** — the agent that would fail without this knowledge.
93
-
94
88
  ### Step 4: Decide Inline vs Ref
95
89
 
96
90
  - Steps <10 and no code blocks → **inline mode**
@@ -45,8 +45,6 @@ Load project UI conventions before extracting design system:
45
45
  maestro spec load --category ui
46
46
  ```
47
47
 
48
- If specs not initialized, continue without — the workflow still produces valid output.
49
-
50
48
  ## 2. Execute Workflow
51
49
 
52
50
  Route to `~/.maestro/workflows/ui-codify.md` and follow completely.
@@ -17,8 +17,6 @@ allowed-tools:
17
17
 
18
18
  <purpose>
19
19
  Analyze current repository's code patterns to auto-generate `.workflow/kg/extractors.yaml` — a declarative config that teaches MaestroGraph's codegraph extractor to recognize project-specific symbols beyond standard function/class/method declarations.
20
-
21
- Detects: builder/factory API registrations, domain constant patterns, custom decorator conventions, framework-specific patterns, module-level constants.
22
20
  </purpose>
23
21
 
24
22
  <context>
@@ -33,8 +33,6 @@ Flags, artifact context resolution, and output directory format defined in workf
33
33
 
34
34
  ### Frontend Verify Mode (`--frontend-verify`)
35
35
 
36
- 补 ralph 链路缺失的运行时可用性门:确定性验证每个用户可观测能力真正经 UI 可触发,避免"后端绿灯=完成"。
37
-
38
36
  1. **Resolve targets**: 读 phase 的 `plan.json` / `.task/TASK-*.json`,提取所有 `[UI-observable]` convergence.criteria(plan 阶段产出);缺失则枚举后端写端点(POST/PUT/PATCH/DELETE)作为待验证清单。
39
37
  2. **Start app**: `next start`(或从 dashboard/package.json 解析的既有启动脚本);启动失败 → E003。
40
38
  3. **Drive browser**: 用 chrome-devtools MCP(`mcp__claude_dms3-chrome-devtools__*`:navigate / click / fill / take_snapshot / list_network_requests)逐条执行每个 `[UI-observable]` 流程,断言:UI 入口存在且可触发 → 对应写请求返回 2xx → DOM 出现预期结果。
@@ -77,4 +77,3 @@ Follow '~/.maestro/workflows/specs-load.md' completely.
77
77
  - [ ] Legacy entries filtered by text grep fallback
78
78
  - [ ] Results displayed with file:category references
79
79
  </success_criteria>
80
- </output>
@@ -48,4 +48,3 @@ Follow '~/.maestro/workflows/specs-setup.md' completely.
48
48
  - [ ] Workflow recipe knowhow created in `.workflow/knowhow/` for each detected operational workflow (test / debug / build / dev / lint). Each recipe matches the `recipe` schema in `~/.maestro/workflows/knowhow.md` Part B and contains at least one runnable command.
49
49
  - [ ] Report displayed grouped by destination (specs / recipes / skipped / deferred), with `.proposed.md` files surfaced when an existing recipe slug was preserved.
50
50
  </success_criteria>
51
- </output>
@@ -52,15 +52,21 @@ Research and codebase exploration for context gathering.
52
52
  | package.json / Cargo.toml / pyproject.toml / go.mod exists | Explore |
53
53
  | No project files | Skip (codebase_context = null) |
54
54
 
55
- When project detected:
56
- ```
57
- shell({ command: `maestro delegate "PURPOSE: Explore codebase for context
58
- TASK: • Identify tech stack Map architecture patterns • Document conventions • List integration points
59
- MODE: analysis
60
- CONTEXT: @**/*
61
- EXPECTED: JSON with: tech_stack[], architecture_patterns[], conventions[], integration_points[]" --tool gemini --mode analysis`, run_in_background: false })
55
+ When project detected — prefer `maestro explore` multi-prompt:
56
+ ```bash
57
+ maestro explore \
58
+ "FIND: tech stack and framework detection
59
+ SCOPE: package.json, Cargo.toml, pyproject.toml, go.mod, src/
60
+ EXPECTED: tech_stack list with versions" \
61
+ "FIND: architecture patterns and conventions
62
+ SCOPE: src/
63
+ EXCLUDE: tests, node_modules
64
+ EXPECTED: patterns list with file:line evidence" \
65
+ --max-turns 3 --json
62
66
  ```
63
67
 
68
+ **Fallback**: `maestro delegate "PURPOSE: Explore codebase for context ..." --tool gemini --mode analysis`
69
+
64
70
  ### Tech Profile Scan
65
71
 
66
72
  After codebase exploration, scan results for context-aware trigger signals (based on detected codebase characteristics):
@@ -41,18 +41,22 @@ Scan codebase from multiple perspectives (bug, security, test-coverage, code-qua
41
41
 
42
42
  **Low complexity**: Use `` for quick pattern-based scan.
43
43
 
44
- **Medium/High complexity**: CLI fan-out -- one `maestro delegate --mode analysis` per perspective:
45
-
46
- For each active perspective, build prompt:
47
- ```
48
- PURPOSE: Scan code from <perspective> perspective to discover potential issues
49
- TASK: Analyze code patterns for <perspective> problems, identify anti-patterns, check for common issues
50
- MODE: analysis
51
- CONTEXT: @<scan-scope>
52
- EXPECTED: List of findings with severity (critical/high/medium/low), file:line references, description
53
- CONSTRAINTS: Focus on actionable findings only
44
+ **Medium/High complexity**: Multi-prompt `maestro explore` (preferred for read-only scan):
45
+
46
+ Build one prompt per active perspective:
47
+ ```bash
48
+ maestro explore \
49
+ "FIND: <perspective1> issues and anti-patterns
50
+ SCOPE: <scan-scope>
51
+ ATTENTION: common <perspective1> problems
52
+ EXPECTED: severity + file:line + description" \
53
+ "FIND: <perspective2> issues and anti-patterns
54
+ SCOPE: <scan-scope>
55
+ EXPECTED: severity + file:line + description" \
56
+ --max-turns 3 --json
54
57
  ```
55
- Execute via: `maestro delegate "<prompt>" --role analyze --mode analysis`
58
+
59
+ **Fallback** (when deeper analysis needed per perspective): `maestro delegate "<prompt>" --role analyze --mode analysis`
56
60
 
57
61
  After all perspectives complete:
58
62
  - Parse CLI outputs into structured findings
@@ -58,7 +58,7 @@ Multi-dimension tech debt scanner. Scan codebase across 5 dimensions (code, arch
58
58
  - Classify findings into dimensions
59
59
 
60
60
  **Medium/High Complexity** (Fan-out):
61
- - Fan-out A: CLI exploration (structure, patterns, dependencies angles) via `maestro delegate --role explore --mode analysis`
61
+ - Fan-out A: `maestro explore` multi-prompt parallel (structure, patterns, dependencies angles) preferred over delegate for exploration
62
62
  - Fan-out B: CLI dimension analysis (parallel per dimension -- code, architecture, testing, dependency, documentation) via `--role analyze`
63
63
  - Fan-out C (High only): Multi-perspective analysis (security, performance, code-quality, architecture) via `--role analyze`
64
64
  - Fan-in: Merge results, cross-deduplicate by file:line, boost severity for multi-source findings
@@ -43,24 +43,31 @@ Explore codebase structure through cli-explore-agent, collecting structured cont
43
43
 
44
44
  ## Phase 3: Codebase Exploration
45
45
 
46
- Use CLI tool for codebase exploration:
47
-
48
- ```javascript
49
- shell({
50
- command: `maestro delegate "PURPOSE: Explore codebase for <topic> from <perspective> perspective; success = structured findings with relevant files and patterns
51
- TASK: • Run module depth analysis • Search for topic-related patterns • Identify key files and their relationships • Extract architectural insights
52
- MODE: analysis
53
- CONTEXT: @**/* | Memory: Session <session-folder>, perspective <perspective>
54
- EXPECTED: JSON output with: relevant_files (path, relevance, summary), patterns, key_findings, module_map, questions_for_analysis, _metadata (perspective, search_queries, timestamp)
55
- CONSTRAINTS: Focus on <perspective> angle - <strategy.focus> | Write to <session>/explorations/exploration-<num>.json
56
- " --tool gemini --mode analysis --rule analysis-analyze-code-patterns`,
57
- run_in_background: false
58
- })
46
+ **Primary: `maestro explore`** (structured multi-prompt):
47
+
48
+ ```bash
49
+ maestro explore \
50
+ "FIND: <topic> patterns and implementations
51
+ SCOPE: src/
52
+ ATTENTION: <perspective>-specific concerns
53
+ EXPECTED: file:line evidence with relevance" \
54
+ "FIND: module boundaries and relationships for <topic>
55
+ SCOPE: src/
56
+ EXCLUDE: tests, generated code
57
+ EXPECTED: dependency pairs and architectural insights" \
58
+ --max-turns 3 --json
59
59
  ```
60
60
 
61
- **ACE fallback** (when CLI produces no output):
62
- ```javascript
63
- ({ project_root_path: ".", query: "<topic> <perspective>" })
61
+ Parse JSON results extract relevant_files, patterns, key_findings.
62
+
63
+ **Fallback: `maestro delegate`** (when explore results insufficient):
64
+
65
+ ```bash
66
+ maestro delegate "PURPOSE: Explore codebase for <topic> from <perspective> perspective
67
+ TASK: Search for topic-related patterns | Identify key files and relationships | Extract architectural insights
68
+ EXPECTED: JSON with relevant_files, patterns, key_findings
69
+ CONSTRAINTS: Focus on <perspective> angle
70
+ " --tool gemini --mode analysis --rule analysis-analyze-code-patterns
64
71
  ```
65
72
 
66
73
  ## Phase 4: Result Validation
@@ -10,96 +10,103 @@ allowed-tools:
10
10
  # CLI Explore Agent
11
11
 
12
12
  ## Role
13
- You are a specialized CLI exploration agent that autonomously analyzes codebases and generates structured outputs. You perform read-only code exploration using dual-source analysis (Bash structural scan + CLI semantic analysis), validate outputs against schemas, and produce structured JSON results.
13
+ Specialized CLI exploration agent. Autonomously analyzes codebases and generates structured outputs. Read-only.
14
14
 
15
15
  **CRITICAL: Mandatory Initial Read**
16
16
  When spawned with `<files_to_read>`, read ALL listed files before any analysis.
17
17
 
18
18
  **Core responsibilities:**
19
- 1. **Structural Analysis** - Module discovery, file patterns, symbol inventory via Bash tools
20
- 2. **Semantic Understanding** - Design intent, architectural patterns via CLI analysis
21
- 3. **Dependency Mapping** - Import/export graphs, circular detection, coupling analysis
22
- 4. **Structured Output** - Schema-compliant JSON generation with validation
19
+ 1. **Structural Analysis** Module discovery, file patterns, symbol inventory
20
+ 2. **Semantic Understanding** Design intent, architectural patterns via CLI analysis
21
+ 3. **Dependency Mapping** Import/export graphs, circular detection, coupling analysis
22
+ 4. **Structured Output** Schema-compliant JSON generation with validation
23
23
 
24
24
  **Analysis Modes**:
25
- - `quick-scan` → Bash only (fast)
26
- - `deep-scan` → Bash + CLI dual-source (thorough)
27
- - `dependency-map` → Graph construction (comprehensive)
25
+ - `quick-scan` → `maestro explore` single prompt (fast)
26
+ - `deep-scan` → `maestro explore` multi-prompt parallel (thorough)
27
+ - `dependency-map` → Multi-prompt + Bash graph construction (comprehensive)
28
28
 
29
29
  ## 4-Phase Execution Workflow
30
30
 
31
31
  ```
32
- Phase 1: Task Understanding
33
- Parse prompt for: analysis scope, output requirements, schema path
34
- Phase 2: Analysis Execution
35
- Bash structural scan + CLI semantic analysis (based on mode)
36
- Phase 3: Schema Validation (MANDATORY if schema specified)
37
- ↓ Read schema → Extract EXACT field names → Validate structure
38
- Phase 4: Output Generation
39
- ↓ Agent report + File output (strictly schema-compliant)
32
+ Phase 1: Task Understanding → parse scope, output requirements, schema
33
+ Phase 2: Analysis Execution maestro explore + Bash structural scan
34
+ Phase 3: Schema Validation → read schema, validate structure
35
+ Phase 4: Output Generation agent report + file output
40
36
  ```
41
37
 
42
38
  ## Phase 1: Task Understanding
43
39
 
44
- ### Autonomous Initialization (execute before any analysis)
45
-
46
40
  1. **Project Structure Discovery**:
47
41
  - Glob `src/**` and top-level directories to map module structure
48
42
  - Read `package.json` / `Cargo.toml` / `go.mod` / `pyproject.toml` for tech stack
49
43
 
50
44
  2. **Output Schema Loading** (if output file path specified in prompt):
51
- - Read schema file and memorize requirements BEFORE any analysis begins
45
+ - Read schema file and memorize requirements BEFORE any analysis
52
46
 
53
47
  3. **Project Context Loading** (from spec system):
54
48
  - Load exploration specs: `maestro spec load --category arch`
55
- - Extract: tech_stack, architecture, key_components, overview
56
- - If no specs returned, proceed with fresh analysis
57
49
 
58
- 4. **Task Keyword Search** (initial file discovery):
59
- - Extract keywords from prompt, detect primary language, run targeted Grep
60
- - Store results as `keyword_files` for Phase 2 scoping
50
+ 4. **Determine analysis depth from prompt keywords**:
51
+ - Quick lookup, structure overview quick-scan
52
+ - Deep analysis, design intent, architecture deep-scan
53
+ - Dependencies, impact analysis, coupling → dependency-map
61
54
 
62
- **Extract from prompt**:
63
- - Analysis target and scope
64
- - Analysis mode (quick-scan / deep-scan / dependency-map)
65
- - Output file path and schema file path (if specified)
55
+ ## Phase 2: Analysis Execution
66
56
 
67
- **Determine analysis depth from prompt keywords**:
68
- - Quick lookup, structure overview → quick-scan
69
- - Deep analysis, design intent, architecture → deep-scan
70
- - Dependencies, impact analysis, coupling → dependency-map
57
+ ### Primary: `maestro explore` (preferred)
71
58
 
72
- ## Phase 2: Analysis Execution
59
+ **Quick-scan** single targeted prompt:
73
60
 
74
- ### Bash Structural Scan
61
+ ```bash
62
+ maestro explore "FIND: <target from prompt>
63
+ SCOPE: src/
64
+ EXCLUDE: test files, node_modules, generated code
65
+ EXPECTED: file:line evidence list" --max-turns 3
66
+ ```
67
+
68
+ **Deep-scan** — multi-prompt parallel for multi-angle coverage:
75
69
 
76
70
  ```bash
77
- # Pattern discovery (adapt based on language)
78
- rg "^export (class|interface|function) " --type ts -n
79
- rg "^(class|def) \w+" --type py -n
80
- rg "^import .* from " -n | head -30
71
+ maestro explore \
72
+ "FIND: <structural patterns>
73
+ SCOPE: src/
74
+ EXPECTED: file:line list" \
75
+ "FIND: <design intent / architecture>
76
+ SCOPE: src/
77
+ EXPECTED: pattern descriptions with file evidence" \
78
+ --max-turns 3 --json
79
+ ```
80
+
81
+ **Dependency-map** — combine explore + Bash:
82
+
83
+ ```bash
84
+ maestro explore "FIND: import/export relationships
85
+ SCOPE: src/
86
+ ATTENTION: circular dependencies, tight coupling
87
+ EXPECTED: dependency pairs with file:line" --max-turns 4 --json
81
88
  ```
82
89
 
83
- ### CLI Semantic Analysis (deep-scan, dependency-map)
90
+ ### Secondary: Bash structural scan (supplement only)
84
91
 
85
92
  ```bash
86
- maestro delegate "
87
- PURPOSE: {from prompt}
88
- TASK: {from prompt}
89
- MODE: analysis
90
- CONTEXT: @**/*
91
- EXPECTED: {from prompt}
92
- " --role explore --mode analysis --cd {dir}
93
+ rg "^export (class|interface|function) " --type ts -n | head -30
94
+ rg "^import .* from " -n | head -30
93
95
  ```
94
96
 
95
- **Fallback Chain**: config-driven via `cli-tools.json` role mappings Bash-only
97
+ Use Bash only when `maestro explore` results need structural verification.
98
+
99
+ ### Fallback: `maestro delegate` (only when explore unavailable)
100
+
101
+ ```bash
102
+ maestro delegate "PURPOSE: {from prompt} TASK: {from prompt} MODE: analysis" --role explore --mode analysis
103
+ ```
96
104
 
97
105
  ### Dual-Source Synthesis
98
106
 
99
- 1. Bash results: Precise file:line locations → `discovery_source: "bash-scan"`
100
- 2. CLI results: Semantic understanding, design intent → `discovery_source: "cli-analysis"`
101
- 3. Dependency tracing: Import/export graph `discovery_source: "dependency-trace"`
102
- 4. Merge with source attribution and generate for each file:
107
+ 1. Explore results: Semantic findings → `discovery_source: "explore"`
108
+ 2. Bash results: Precise file:line locations → `discovery_source: "bash-scan"`
109
+ 3. Merge with source attribution and generate for each file:
103
110
  - `rationale`: WHY the file was selected (specific, >10 chars)
104
111
  - `topic_relation`: HOW the file connects to the exploration angle/topic
105
112
  - `key_code`: Detailed descriptions of key symbols with locations (for relevance >= 0.7)
@@ -111,39 +118,35 @@ EXPECTED: {from prompt}
111
118
  **Step 1: Read Schema FIRST** before generating any output
112
119
 
113
120
  **Step 2: Extract Schema Requirements**
114
- 1. Root structure - Is it array `[...]` or object `{...}`?
115
- 2. Required fields - List all `"required": [...]` arrays
116
- 3. Field names EXACTLY - Copy character-by-character (case-sensitive)
117
- 4. Enum values - Copy exact strings (case-sensitive)
118
- 5. Nested structures - Note flat vs nested requirements
121
+ 1. Root structure array `[...]` or object `{...}`?
122
+ 2. Required fields list all `"required": [...]` arrays
123
+ 3. Field names EXACTLY copy character-by-character (case-sensitive)
124
+ 4. Enum values copy exact strings (case-sensitive)
125
+ 5. Nested structures note flat vs nested requirements
119
126
 
120
127
  **Step 3: File Rationale Validation** (MANDATORY for relevant_files / affected_files)
121
128
 
122
129
  Every file entry MUST have:
123
130
  - `rationale` (required, minLength 10): Specific reason tied to the exploration topic
124
- - GOOD: "Contains AuthService.login() which is the entry point for JWT token generation"
125
- - BAD: "Related to auth"
126
131
  - `role` (required, enum): modify_target / dependency / pattern_reference / test_target / type_definition / integration_point / config / context_only
127
- - `discovery_source` (recommended): bash-scan / cli-analysis / dependency-trace / manual
132
+ - `discovery_source` (recommended): explore / bash-scan / dependency-trace / manual
128
133
  - `key_code` (required for relevance >= 0.7): Array of {symbol, location?, description}
129
134
  - `topic_relation` (required for relevance >= 0.7): Connection from exploration angle perspective
130
135
 
131
136
  **Step 4: Pre-Output Validation Checklist**
132
- - [ ] Root structure matches schema (array vs object)
137
+ - [ ] Root structure matches schema
133
138
  - [ ] ALL required fields present at each level
134
- - [ ] Field names EXACTLY match schema (character-by-character)
135
- - [ ] Enum values EXACTLY match schema (case-sensitive)
139
+ - [ ] Field names EXACTLY match schema
140
+ - [ ] Enum values EXACTLY match schema
136
141
  - [ ] Every file has: path + relevance + rationale + role
137
142
  - [ ] Files with relevance >= 0.7 have key_code and topic_relation
138
143
 
139
144
  ## Phase 4: Output Generation
140
145
 
141
146
  ### Agent Output (return to caller)
142
-
143
147
  Brief summary: task completion status, key findings, generated file paths
144
148
 
145
149
  ### File Output (as specified in prompt)
146
-
147
150
  1. Read schema file BEFORE generating output
148
151
  2. Extract ALL field names from schema
149
152
  3. Build JSON using ONLY schema field names
@@ -169,16 +172,16 @@ Brief summary: task completion status, key findings, generated file paths
169
172
  ## Rules
170
173
 
171
174
  ### ALWAYS
172
- - Read schema file FIRST before generating any output (if schema specified)
175
+ - Prefer `maestro explore` over raw Grep/rg for code search
176
+ - Use structured prompt format (FIND/SCOPE/EXCLUDE/ATTENTION/EXPECTED)
177
+ - Read schema file FIRST before generating output (if schema specified)
173
178
  - Copy field names EXACTLY from schema (case-sensitive)
174
179
  - Include file:line references in findings
175
- - Every file MUST have rationale (specific, not generic) and role
176
180
  - Track discovery source for all findings
177
- - Populate key_code and topic_relation for high-relevance files (>= 0.7)
178
181
  - Use `run_in_background: false` for all Bash/CLI calls
179
182
 
180
183
  ### NEVER
181
184
  - Modify any files (read-only agent)
182
185
  - Skip schema reading step when schema is specified
183
- - Guess field names - ALWAYS copy from schema
186
+ - Guess field names ALWAYS copy from schema
184
187
  - Omit required fields