maestro-flow 0.5.45 → 0.5.47

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 (310) hide show
  1. package/.agents/agents/ralph-executor.md +51 -6
  2. package/.agents/skills/domain-add/SKILL.md +9 -0
  3. package/.agents/skills/learn-decompose/SKILL.md +12 -0
  4. package/.agents/skills/learn-follow/SKILL.md +41 -0
  5. package/.agents/skills/learn-investigate/SKILL.md +14 -0
  6. package/.agents/skills/learn-second-opinion/SKILL.md +14 -0
  7. package/.agents/skills/maestro-amend/SKILL.md +11 -0
  8. package/.agents/skills/maestro-companion/SKILL.md +11 -0
  9. package/.agents/skills/maestro-composer/SKILL.md +11 -0
  10. package/.agents/skills/maestro-guard/SKILL.md +25 -0
  11. package/.agents/skills/maestro-init/SKILL.md +28 -0
  12. package/.agents/skills/maestro-overlay/SKILL.md +11 -0
  13. package/.agents/skills/maestro-player/SKILL.md +11 -0
  14. package/.agents/skills/maestro-quick/SKILL.md +29 -0
  15. package/.agents/skills/maestro-ralph-v2/SKILL.md +124 -61
  16. package/.agents/skills/maestro-swarm-workflow/SKILL.md +25 -0
  17. package/.agents/skills/maestro-tools-execute/SKILL.md +29 -0
  18. package/.agents/skills/maestro-tools-register/SKILL.md +29 -0
  19. package/.agents/skills/maestro-ui-codify/SKILL.md +11 -0
  20. package/.agents/skills/maestro-universal-workflow/SKILL.md +59 -0
  21. package/.agents/skills/maestro-update/SKILL.md +38 -0
  22. package/.agents/skills/manage-codebase-rebuild/SKILL.md +29 -0
  23. package/.agents/skills/manage-drift-realign/SKILL.md +12 -0
  24. package/.agents/skills/manage-harvest/SKILL.md +30 -6
  25. package/.agents/skills/manage-issue/SKILL.md +23 -0
  26. package/.agents/skills/manage-issue-discover/SKILL.md +28 -0
  27. package/.agents/skills/manage-kg-extractors/SKILL.md +27 -1
  28. package/.agents/skills/manage-knowhow/SKILL.md +26 -0
  29. package/.agents/skills/manage-knowhow-capture/SKILL.md +24 -0
  30. package/.agents/skills/manage-knowledge-audit/SKILL.md +13 -0
  31. package/.agents/skills/manage-status/SKILL.md +22 -0
  32. package/.agents/skills/manage-wiki/SKILL.md +28 -0
  33. package/.agents/skills/odyssey-debug/SKILL.md +338 -253
  34. package/.agents/skills/odyssey-improve/SKILL.md +417 -281
  35. package/.agents/skills/odyssey-planex/SKILL.md +536 -420
  36. package/.agents/skills/odyssey-review-test-fix/SKILL.md +386 -251
  37. package/.agents/skills/odyssey-ui/SKILL.md +382 -247
  38. package/.agents/skills/quality-auto-test/SKILL.md +12 -0
  39. package/.agents/skills/quality-debug/SKILL.md +11 -0
  40. package/.agents/skills/quality-refactor/SKILL.md +11 -0
  41. package/.agents/skills/quality-retrospective/SKILL.md +11 -0
  42. package/.agents/skills/quality-review/SKILL.md +11 -0
  43. package/.agents/skills/quality-sync/SKILL.md +10 -0
  44. package/.agents/skills/quality-test/SKILL.md +12 -0
  45. package/.agents/skills/security-audit/SKILL.md +11 -0
  46. package/.agents/skills/spec-add/SKILL.md +27 -0
  47. package/.agents/skills/spec-load/SKILL.md +25 -0
  48. package/.agents/skills/spec-remove/SKILL.md +26 -0
  49. package/.agents/skills/spec-setup/SKILL.md +30 -0
  50. package/.agy/agents/ralph-executor.md +53 -6
  51. package/.agy/skills/domain-add/SKILL.md +9 -0
  52. package/.agy/skills/learn-decompose/SKILL.md +12 -0
  53. package/.agy/skills/learn-follow/SKILL.md +41 -0
  54. package/.agy/skills/learn-investigate/SKILL.md +14 -0
  55. package/.agy/skills/learn-second-opinion/SKILL.md +14 -0
  56. package/.agy/skills/maestro-amend/SKILL.md +11 -0
  57. package/.agy/skills/maestro-companion/SKILL.md +11 -0
  58. package/.agy/skills/maestro-composer/SKILL.md +11 -0
  59. package/.agy/skills/maestro-guard/SKILL.md +25 -0
  60. package/.agy/skills/maestro-init/SKILL.md +28 -0
  61. package/.agy/skills/maestro-overlay/SKILL.md +11 -0
  62. package/.agy/skills/maestro-player/SKILL.md +11 -0
  63. package/.agy/skills/maestro-quick/SKILL.md +29 -0
  64. package/.agy/skills/maestro-ralph-v2/SKILL.md +123 -61
  65. package/.agy/skills/maestro-swarm-workflow/SKILL.md +25 -0
  66. package/.agy/skills/maestro-tools-execute/SKILL.md +29 -0
  67. package/.agy/skills/maestro-tools-register/SKILL.md +29 -0
  68. package/.agy/skills/maestro-ui-codify/SKILL.md +11 -0
  69. package/.agy/skills/maestro-universal-workflow/SKILL.md +59 -0
  70. package/.agy/skills/maestro-update/SKILL.md +38 -0
  71. package/.agy/skills/manage-codebase-rebuild/SKILL.md +29 -0
  72. package/.agy/skills/manage-drift-realign/SKILL.md +12 -0
  73. package/.agy/skills/manage-harvest/SKILL.md +30 -6
  74. package/.agy/skills/manage-issue/SKILL.md +23 -0
  75. package/.agy/skills/manage-issue-discover/SKILL.md +28 -0
  76. package/.agy/skills/manage-kg-extractors/SKILL.md +27 -1
  77. package/.agy/skills/manage-knowhow/SKILL.md +26 -0
  78. package/.agy/skills/manage-knowhow-capture/SKILL.md +24 -0
  79. package/.agy/skills/manage-knowledge-audit/SKILL.md +13 -0
  80. package/.agy/skills/manage-status/SKILL.md +22 -0
  81. package/.agy/skills/manage-wiki/SKILL.md +28 -0
  82. package/.agy/skills/odyssey-debug/SKILL.md +338 -253
  83. package/.agy/skills/odyssey-improve/SKILL.md +417 -281
  84. package/.agy/skills/odyssey-planex/SKILL.md +536 -420
  85. package/.agy/skills/odyssey-review-test-fix/SKILL.md +386 -251
  86. package/.agy/skills/odyssey-ui/SKILL.md +382 -247
  87. package/.agy/skills/quality-auto-test/SKILL.md +12 -0
  88. package/.agy/skills/quality-debug/SKILL.md +11 -0
  89. package/.agy/skills/quality-refactor/SKILL.md +11 -0
  90. package/.agy/skills/quality-retrospective/SKILL.md +11 -0
  91. package/.agy/skills/quality-review/SKILL.md +11 -0
  92. package/.agy/skills/quality-sync/SKILL.md +10 -0
  93. package/.agy/skills/quality-test/SKILL.md +12 -0
  94. package/.agy/skills/security-audit/SKILL.md +11 -0
  95. package/.agy/skills/spec-add/SKILL.md +27 -0
  96. package/.agy/skills/spec-load/SKILL.md +25 -0
  97. package/.agy/skills/spec-remove/SKILL.md +26 -0
  98. package/.agy/skills/spec-setup/SKILL.md +30 -0
  99. package/.claude/agents/ralph-executor.md +51 -6
  100. package/.claude/commands/domain-add.md +9 -0
  101. package/.claude/commands/learn-decompose.md +12 -0
  102. package/.claude/commands/learn-follow.md +41 -0
  103. package/.claude/commands/learn-investigate.md +14 -0
  104. package/.claude/commands/learn-second-opinion.md +14 -0
  105. package/.claude/commands/maestro-amend.md +11 -0
  106. package/.claude/commands/maestro-companion.md +11 -0
  107. package/.claude/commands/maestro-composer.md +11 -0
  108. package/.claude/commands/maestro-guard.md +25 -0
  109. package/.claude/commands/maestro-init.md +28 -0
  110. package/.claude/commands/maestro-overlay.md +11 -0
  111. package/.claude/commands/maestro-player.md +11 -0
  112. package/.claude/commands/maestro-quick.md +29 -0
  113. package/.claude/commands/maestro-ralph-v2.md +124 -61
  114. package/.claude/commands/maestro-swarm-workflow.md +25 -0
  115. package/.claude/commands/maestro-tools-execute.md +29 -0
  116. package/.claude/commands/maestro-tools-register.md +29 -0
  117. package/.claude/commands/maestro-ui-codify.md +11 -0
  118. package/.claude/commands/maestro-universal-workflow.md +59 -0
  119. package/.claude/commands/maestro-update.md +38 -0
  120. package/.claude/commands/manage-codebase-rebuild.md +29 -0
  121. package/.claude/commands/manage-drift-realign.md +12 -0
  122. package/.claude/commands/manage-harvest.md +30 -6
  123. package/.claude/commands/manage-issue-discover.md +28 -0
  124. package/.claude/commands/manage-issue.md +23 -0
  125. package/.claude/commands/manage-kg-extractors.md +27 -1
  126. package/.claude/commands/manage-knowhow-capture.md +24 -0
  127. package/.claude/commands/manage-knowhow.md +26 -0
  128. package/.claude/commands/manage-knowledge-audit.md +13 -0
  129. package/.claude/commands/manage-status.md +22 -0
  130. package/.claude/commands/manage-wiki.md +28 -0
  131. package/.claude/commands/odyssey-debug.md +352 -267
  132. package/.claude/commands/odyssey-improve.md +431 -295
  133. package/.claude/commands/odyssey-planex.md +550 -434
  134. package/.claude/commands/odyssey-review-test-fix.md +400 -265
  135. package/.claude/commands/odyssey-ui.md +396 -261
  136. package/.claude/commands/quality-auto-test.md +12 -0
  137. package/.claude/commands/quality-debug.md +11 -0
  138. package/.claude/commands/quality-refactor.md +11 -0
  139. package/.claude/commands/quality-retrospective.md +11 -0
  140. package/.claude/commands/quality-review.md +11 -0
  141. package/.claude/commands/quality-sync.md +10 -0
  142. package/.claude/commands/quality-test.md +12 -0
  143. package/.claude/commands/security-audit.md +11 -0
  144. package/.claude/commands/spec-add.md +27 -0
  145. package/.claude/commands/spec-load.md +25 -0
  146. package/.claude/commands/spec-remove.md +26 -0
  147. package/.claude/commands/spec-setup.md +30 -0
  148. package/.codex/skills/codify-to-knowhow/SKILL.md +2 -0
  149. package/.codex/skills/domain-add/SKILL.md +26 -0
  150. package/.codex/skills/domain-discover/SKILL.md +46 -0
  151. package/.codex/skills/domain-list/SKILL.md +29 -0
  152. package/.codex/skills/learn-decompose/SKILL.md +2 -0
  153. package/.codex/skills/learn-follow/SKILL.md +34 -0
  154. package/.codex/skills/learn-investigate/SKILL.md +33 -0
  155. package/.codex/skills/learn-retro/SKILL.md +33 -0
  156. package/.codex/skills/learn-second-opinion/SKILL.md +30 -0
  157. package/.codex/skills/maestro-amend/SKILL.md +11 -0
  158. package/.codex/skills/maestro-companion/SKILL.md +11 -0
  159. package/.codex/skills/maestro-composer/SKILL.md +11 -0
  160. package/.codex/skills/maestro-guard/SKILL.md +25 -0
  161. package/.codex/skills/maestro-help/SKILL.md +2 -0
  162. package/.codex/skills/maestro-init/SKILL.md +16 -0
  163. package/.codex/skills/maestro-learn/SKILL.md +2 -0
  164. package/.codex/skills/maestro-overlay/SKILL.md +1 -0
  165. package/.codex/skills/maestro-player/SKILL.md +2 -0
  166. package/.codex/skills/maestro-quick/SKILL.md +17 -0
  167. package/.codex/skills/maestro-tools-execute/SKILL.md +31 -0
  168. package/.codex/skills/maestro-tools-register/SKILL.md +29 -0
  169. package/.codex/skills/maestro-ui-codify/SKILL.md +2 -0
  170. package/.codex/skills/maestro-update/SKILL.md +38 -0
  171. package/.codex/skills/manage-codebase-rebuild/SKILL.md +2 -0
  172. package/.codex/skills/manage-codebase-refresh/SKILL.md +11 -0
  173. package/.codex/skills/manage-drift-realign/SKILL.md +2 -0
  174. package/.codex/skills/manage-harvest/SKILL.md +30 -8
  175. package/.codex/skills/manage-issue/SKILL.md +24 -0
  176. package/.codex/skills/manage-issue-discover/SKILL.md +2 -0
  177. package/.codex/skills/manage-knowhow/SKILL.md +26 -0
  178. package/.codex/skills/manage-knowhow-capture/SKILL.md +23 -0
  179. package/.codex/skills/manage-learn/SKILL.md +2 -0
  180. package/.codex/skills/manage-status/SKILL.md +22 -0
  181. package/.codex/skills/manage-wiki/SKILL.md +28 -0
  182. package/.codex/skills/odyssey-debug/SKILL.md +44 -0
  183. package/.codex/skills/odyssey-improve/SKILL.md +49 -0
  184. package/.codex/skills/odyssey-planex/SKILL.md +44 -0
  185. package/.codex/skills/odyssey-review-test-fix/SKILL.md +48 -0
  186. package/.codex/skills/odyssey-ui/SKILL.md +49 -0
  187. package/.codex/skills/quality-auto-test/SKILL.md +2 -0
  188. package/.codex/skills/quality-debug/SKILL.md +2 -0
  189. package/.codex/skills/quality-refactor/SKILL.md +2 -0
  190. package/.codex/skills/quality-retrospective/SKILL.md +2 -0
  191. package/.codex/skills/quality-review/SKILL.md +2 -0
  192. package/.codex/skills/quality-sync/SKILL.md +24 -0
  193. package/.codex/skills/quality-test/SKILL.md +2 -0
  194. package/.codex/skills/security-audit/SKILL.md +30 -0
  195. package/.codex/skills/spec-add/SKILL.md +28 -0
  196. package/.codex/skills/spec-load/SKILL.md +26 -0
  197. package/.codex/skills/spec-map/SKILL.md +1 -0
  198. package/.codex/skills/spec-remove/SKILL.md +28 -0
  199. package/.codex/skills/spec-setup/SKILL.md +28 -0
  200. package/.codex/skills/wiki-connect/SKILL.md +11 -0
  201. package/.codex/skills/wiki-digest/SKILL.md +11 -0
  202. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js +3 -1
  203. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js.map +1 -1
  204. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +5 -0
  205. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +28 -4
  206. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  207. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
  208. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  209. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +10 -0
  210. package/dashboard/dist-server/src/graph/kg/db/queries.js +176 -38
  211. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  212. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  213. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  214. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  215. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  216. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  217. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  218. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  219. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  220. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +20 -12
  221. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  222. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
  223. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
  224. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
  225. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
  226. package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
  227. package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
  228. package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
  229. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
  230. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
  231. package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
  232. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
  233. package/dist/src/agents/api-explore/agent-loop.js +6 -5
  234. package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
  235. package/dist/src/agents/api-explore/config.d.ts +67 -1
  236. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  237. package/dist/src/agents/api-explore/config.js +50 -15
  238. package/dist/src/agents/api-explore/config.js.map +1 -1
  239. package/dist/src/agents/api-explore/index.js +4 -4
  240. package/dist/src/agents/api-explore/index.js.map +1 -1
  241. package/dist/src/agents/api-explore/llm.d.ts +7 -1
  242. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  243. package/dist/src/agents/api-explore/llm.js +26 -12
  244. package/dist/src/agents/api-explore/llm.js.map +1 -1
  245. package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
  246. package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
  247. package/dist/src/agents/api-explore/moa-cache.js +50 -0
  248. package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
  249. package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
  250. package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
  251. package/dist/src/agents/api-explore/moa-loop.js +43 -0
  252. package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
  253. package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
  254. package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
  255. package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
  256. package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
  257. package/dist/src/agents/api-explore/runner.d.ts +3 -0
  258. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  259. package/dist/src/agents/api-explore/runner.js +39 -18
  260. package/dist/src/agents/api-explore/runner.js.map +1 -1
  261. package/dist/src/agents/api-explore/session.d.ts +15 -0
  262. package/dist/src/agents/api-explore/session.d.ts.map +1 -1
  263. package/dist/src/agents/api-explore/session.js.map +1 -1
  264. package/dist/src/cli.js +1 -0
  265. package/dist/src/cli.js.map +1 -1
  266. package/dist/src/commands/explore.d.ts.map +1 -1
  267. package/dist/src/commands/explore.js +34 -2
  268. package/dist/src/commands/explore.js.map +1 -1
  269. package/dist/src/commands/install.js +7 -28
  270. package/dist/src/commands/install.js.map +1 -1
  271. package/dist/src/commands/moa.d.ts +3 -0
  272. package/dist/src/commands/moa.d.ts.map +1 -0
  273. package/dist/src/commands/moa.js +217 -0
  274. package/dist/src/commands/moa.js.map +1 -0
  275. package/dist/src/commands/search.d.ts.map +1 -1
  276. package/dist/src/commands/search.js +2 -0
  277. package/dist/src/commands/search.js.map +1 -1
  278. package/dist/src/graph/kg/db/queries.d.ts +10 -0
  279. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  280. package/dist/src/graph/kg/db/queries.js +176 -38
  281. package/dist/src/graph/kg/db/queries.js.map +1 -1
  282. package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  283. package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  284. package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  285. package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  286. package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  287. package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  288. package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  289. package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  290. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  291. package/dist/src/graph/kg/extraction/orchestrator.js +20 -12
  292. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  293. package/dist/src/graph/kg/surface/hook-injector.js +1 -1
  294. package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
  295. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  296. package/dist/src/hooks/keyword-spec-injector.js +35 -0
  297. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  298. package/dist/src/hooks/plugins/explore-plugin.d.ts.map +1 -1
  299. package/dist/src/hooks/plugins/explore-plugin.js +3 -2
  300. package/dist/src/hooks/plugins/explore-plugin.js.map +1 -1
  301. package/dist/src/hooks/spec-analytics.d.ts +1 -0
  302. package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
  303. package/dist/src/hooks/spec-analytics.js.map +1 -1
  304. package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
  305. package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
  306. package/dist/src/hooks/wiki-search-bridge.js +71 -0
  307. package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
  308. package/dist/src/utils/update-notices.js +12 -0
  309. package/dist/src/utils/update-notices.js.map +1 -1
  310. package/package.json +1 -1
@@ -40,8 +40,19 @@ $ARGUMENTS — natural language description, or flags.
40
40
  1. **Architecture specs**: Run `maestro load --type spec --category arch` to load architecture constraints. Use as context for node resolution — ensures workflow design respects documented patterns.
41
41
  2. **Coding specs**: Run `maestro load --type spec --category coding` to load coding conventions. Informs executor argument defaults and context injection.
42
42
  3. Optional — proceed without if unavailable.
43
+
44
+ **Output boundary**: ALL file writes MUST target `~/.maestro/templates/workflows/` (template JSON + index.json) and `.workflow/templates/design-drafts/` (intermediate drafts) only. NEVER modify source code or `.claude/commands/` files.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Max 20 nodes** — workflow templates MUST NOT exceed 20 nodes; larger workflows MUST be split into sub-workflows
49
+ 2. **Acyclic DAG** — generated template MUST be a directed acyclic graph; cycles MUST be detected and rejected before persistence
50
+ 3. **No orphan nodes** — every node MUST be reachable from at least one edge; unreachable nodes MUST be flagged
51
+ 4. **Confirmation before write** — template JSON MUST be shown to user via ask_question before writing to `~/.maestro/templates/workflows/`; cancellation saves draft only
52
+ 5. **Draft preservation** — abandoning at any confirmation gate MUST save current progress to design-drafts directory; NEVER discard user's partial work
53
+ 6. **Deferred reading only** — node-catalog and template-schema MUST be read at their designated phases (P2, P5), NEVER loaded eagerly at startup
54
+ </invariants>
55
+
45
56
  <state_machine>
46
57
 
47
58
  <states>
@@ -30,10 +30,35 @@ $ARGUMENTS — Parse subcommand and optional path argument.
30
30
 
31
31
  **Enforcement:** The `workflow-guard` hook (PreToolUse on Write/Edit) reads this config
32
32
  and blocks operations targeting files outside boundaries. Requires hooks level >= `full`.
33
+
34
+ **Output boundary**: ALL file writes MUST target `.workflow/config.json` (guard section) only. NEVER modify hook files, `.claude/settings.json`, or source code.
33
35
  </context>
34
36
 
37
+ <invariants>
38
+ 1. **Config-only mutation** — guard MUST only modify the `guard` section of `.workflow/config.json`; NEVER touch other config sections or files
39
+ 2. **Non-destructive** — `off` MUST preserve existing paths and mode; NEVER clear the path list when disabling
40
+ 3. **Mode switch confirmation** — switching between allow/deny mode MUST require ask_question confirmation when existing paths will be cleared
41
+ 4. **Hook dependency** — guard MUST warn when enabled but `workflow-guard` hook is not active (hooks level < full)
42
+ 5. **Path normalization** — all paths MUST use forward slashes with trailing slash for directories; NEVER store raw backslash paths
43
+ </invariants>
44
+
35
45
  <execution>
36
46
 
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Parse → Config Read**
50
+ - REQUIRED: Subcommand parsed (on/off/status/allow/deny) or defaulted to `status`.
51
+ - BLOCKED if: invalid subcommand provided.
52
+
53
+ **GATE 2: Config Read → Execute**
54
+ - REQUIRED: `.workflow/config.json` read successfully or initialized with empty guard section.
55
+ - BLOCKED if: file unreadable and cannot be created (E001).
56
+
57
+ **GATE 3: Execute → Confirm**
58
+ - REQUIRED: Config mutation applied (for on/off/allow/deny) or status displayed (for status).
59
+ - REQUIRED: Mode-switch ask_question answered (for allow↔deny transitions with existing paths).
60
+ - BLOCKED if: user declines mode switch.
61
+
37
62
  **Step 1: Parse subcommand**
38
63
 
39
64
  Extract from $ARGUMENTS:
@@ -40,8 +40,18 @@ $ARGUMENTS — none for interactive mode, or `-y` with `@file` reference for aut
40
40
 
41
41
  **Load project state if exists:**
42
42
  Check for `.workflow/state.json` -- loads context if project already initialized.
43
+
44
+ **Output boundary**: ALL file writes MUST target `.workflow/` (project.md, state.json, config.json, specs/) only. NEVER modify source code or files outside `.workflow/`.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Idempotent init** — re-running init on an already-initialized project MUST detect existing `.workflow/` and warn (E002); NEVER silently overwrite existing state
49
+ 2. **Scope guard** — init MUST only make initialization decisions; NEVER prejudge roadmap structure, plan scope, or implementation details
50
+ 3. **All artifacts required** — init MUST NOT report completion until project.md, state.json, and config.json all exist; missing artifacts MUST be created before exit
51
+ 4. **Template-driven** — deferred templates (project.md, state.json, config.json) MUST be read from `~/.maestro/templates/` and customized; NEVER generate from scratch without template
52
+ 5. **Interview writes back** — all interactive decisions MUST be written to project.md/config.json before proceeding to research or completion; NEVER leave decisions unrecorded
53
+ </invariants>
54
+
45
55
  <interview_protocol>
46
56
  Follows @~/.maestro/workflows/interview-mechanics.md standard.
47
57
 
@@ -54,6 +64,24 @@ Follows @~/.maestro/workflows/interview-mechanics.md standard.
54
64
  </interview_protocol>
55
65
 
56
66
  <execution>
67
+
68
+ ### Phase Gates (MANDATORY, BLOCKING)
69
+
70
+ **GATE 1: Pre-flight → Interview**
71
+ - REQUIRED: `.workflow/` existence check completed.
72
+ - REQUIRED: `--from` source validated (if provided).
73
+ - BLOCKED if: E002 (greenfield conflict with existing `.workflow/`) unresolved.
74
+
75
+ **GATE 2: Interview → Research**
76
+ - REQUIRED: All interview decisions recorded in project.md and config.json.
77
+ - REQUIRED: `.workflow/` directory created with initial structure.
78
+ - BLOCKED if: interview decisions not yet written to files.
79
+
80
+ **GATE 3: Research → Completion**
81
+ - REQUIRED: All 3 required artifacts exist (project.md, state.json, config.json).
82
+ - REQUIRED: `.workflow/specs/` initialized.
83
+ - BLOCKED if: any artifact missing — write it before reporting completion.
84
+
57
85
  ### Pre-flight
58
86
 
59
87
  1. Check if `.workflow/` already exists — if so, load state and warn (E002 for greenfield conflicts)
@@ -33,8 +33,19 @@ Turn natural-language instructions into command overlays — JSON patch files th
33
33
  **Management** — listing and removing overlays is handled by `maestro overlay list` (ink TUI with interactive delete). This skill focuses solely on creation.
34
34
 
35
35
  **Available sections** (for `section:` in patches): `purpose`, `required_reading`, `deferred_reading`, `context`, `execution`, `error_codes`, `success_criteria`.
36
+
37
+ **Output boundary**: ALL file writes MUST target `~/.maestro/overlays/` (overlay JSON + docs) only. Command file patching is handled by `maestro overlay add` — this skill NEVER modifies `.claude/commands/*.md` directly.
36
38
  </context>
37
39
 
40
+ <invariants>
41
+ 1. **Non-invasive** — overlays MUST use hashed HTML-comment markers for injection; NEVER edit command file content directly outside the overlay system
42
+ 2. **Idempotent** — re-running `maestro overlay apply` with the same overlay JSON MUST produce no file changes
43
+ 3. **Creation only** — this skill MUST only create overlays; listing and removal are handled by `maestro overlay list` (ink TUI)
44
+ 4. **Pristine source preferred** — injection point analysis MUST read from `$PKG_ROOT/.claude/commands/` (untouched originals) first, fall back to `~/.claude/commands/` only if pristine unavailable
45
+ 5. **User approval before write** — overlay JSON MUST be shown and approved via ask_question before writing to disk; NEVER auto-install without confirmation
46
+ 6. **Chain skip option mandatory** — if a skill chain is configured, the injected content MUST include a "Skip" option in ask_question; NEVER force the user into a chain
47
+ </invariants>
48
+
38
49
  <execution>
39
50
  ### 1. Parse user intent
40
51
 
@@ -68,8 +68,19 @@ $ARGUMENTS — template slug/path, or flags.
68
68
  "last_checkpoint": null
69
69
  }
70
70
  ```
71
+
72
+ **Output boundary**: ALL file writes MUST target `.workflow/.maestro/player-*/` (session status.json + step outputs) only. Template files (`~/.maestro/templates/workflows/`) are read-only. NEVER modify source code or `.claude/commands/` files.
71
73
  </context>
72
74
 
75
+ <invariants>
76
+ 1. **Resume-safe** — status.json MUST be updated after every step change; an interrupted session MUST be resumable from the last checkpoint via `-c`
77
+ 2. **One step at a time** — execution loop MUST process steps sequentially in topological order; parallel steps share a batch index but NEVER run concurrently within the player
78
+ 3. **CLI nodes async** — cli-type nodes MUST use `run_command(run_in_background: true)` + STOP pattern; NEVER block the main thread on delegate execution
79
+ 4. **Templates read-only** — player MUST NOT modify template JSON files; runtime state belongs in status.json only
80
+ 5. **Failure requires user decision** — on step failure without explicit `on_fail`, player MUST prompt via ask_question (Retry/Skip/Abort); NEVER silently skip or auto-abort
81
+ 6. **Reference resolution at runtime** — `{N-xxx.field}` and `{prev_*}` references MUST be resolved at execution time from status.json step results, NEVER pre-resolved during init
82
+ </invariants>
83
+
73
84
  <state_machine>
74
85
 
75
86
  <states>
@@ -41,9 +41,38 @@ Parse for:
41
41
  - Browse: `maestro search --category coding`
42
42
  - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
43
43
  3. All are optional — proceed without if unavailable.
44
+
45
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/` (task directory, plan.json, summaries) and modified source files as defined in plan.json tasks. State.json scratch entry is implicit workflow tracking.
44
46
  </context>
45
47
 
48
+ <invariants>
49
+ 1. **Atomic commits** — each task execution MUST produce a commit with only the files modified by that task; NEVER stage unrelated files
50
+ 2. **Evidence-based summaries** — task summaries MUST include concrete evidence (files changed, tests run, commands executed); NEVER accept "task completed successfully" as a summary
51
+ 3. **Plan before execute** — plan.json MUST be written before any task execution begins; NEVER skip planning even for single-task workflows
52
+ 4. **Scratch isolation** — all workflow artifacts MUST live under `.workflow/scratch/{task-dir}/`; NEVER write workflow metadata outside this directory
53
+ 5. **Commit confirmation** — staged files and commit message MUST be shown via ask_question before committing (unless `-y`); NEVER auto-commit without user awareness
54
+ </invariants>
55
+
46
56
  <execution>
57
+
58
+ ### Phase Gates (MANDATORY, BLOCKING)
59
+
60
+ **GATE 1: Setup → Planning**
61
+ - REQUIRED: Task description parsed and scratch directory created.
62
+ - REQUIRED: Coding specs loaded (optional but attempted).
63
+ - BLOCKED if: no task description (E001) or scratch directory creation failed (E002).
64
+
65
+ **GATE 2: Planning → Execution**
66
+ - REQUIRED: plan.json written with task definitions.
67
+ - REQUIRED: --discuss decisions extracted and recorded (if flag set).
68
+ - BLOCKED if: plan.json missing or empty.
69
+
70
+ **GATE 3: Execution → Completion**
71
+ - REQUIRED: All tasks executed with `.summaries/TASK-*-summary.md` written per task.
72
+ - REQUIRED: Each summary contains concrete evidence of completion.
73
+ - REQUIRED: --full verification passed (if flag set).
74
+ - BLOCKED if: any task summary missing or lacking evidence.
75
+
47
76
  Follow '~/.maestro/workflows/quick.md' completely.
48
77
 
49
78
  ### Artifact Verification (before completion)
@@ -57,13 +57,16 @@ Remaining → intent (amend_mode 时为 change_request)
57
57
  </context>
58
58
 
59
59
  <invariants>
60
- 1. **Ralph-v2 owns the full loop** — locate step → resolve args → load context → dispatch agent → extract signals → drift → complete,全部在本命令内完成
61
- 2. **One agent per step** — 每个执行 step 派发一个 executor agent,agent 执行完返回,主流程解析结果后决定下一步
62
- 3. **Agent is a thin wrapper** — executor agent 调 `ralph next` 获取 skill prompt 并执行,返回输出;arg resolution、context loading、signal extraction、drift analysis、ralph complete 均由主流程完成
63
- 4. **Synchronous dispatch** — invoke_subagent() 调用是同步的(等待返回),不需要 STOP/callback 模式
60
+ 1. **Ralph-v2 owns the full loop** — locate step → resolve args → load context → dispatch agent → wait for send_message → receive → extract signals → drift → complete,全部在本命令内完成
61
+ 2. **One agent per step** — 每个执行 step 派发一个 named executor agent,agent 通过 send_message 回传结果,主流程解析结果后决定下一步
62
+ 3. **Agent is a thin wrapper** — executor agent 调 `ralph next` 获取 skill prompt 并执行,通过 send_message 回传输出;arg resolution、context loading、signal extraction、drift analysis、ralph complete 均由主流程完成
63
+ 4. **Dual dispatch model** — 执行 Agent 与评估 Agent 使用不同派发模式:
64
+ - **执行 Agent**(A_STEP_DISPATCH):`invoke_subagent([{ TypeName: "<TypeName>", Role: "exe-xxx", Prompt: "<Prompt>", Workspace: "inherit" }])` — named mailbox teammate,支持内部多 agent 编排,通过 `send_message({to: "main"})` 回传结果
65
+ - **评估 Agent**(A_AGENT_EVALUATE / A_AGENT_GOAL_AUDIT / A_AGENT_REGROUND):`invoke_subagent()` 不传 `name` — 同步阻塞,直接返回结果(评估 agent 只读不需要多 agent)
66
+ - `agent_exec_name` 既用于 display/日志,也作为执行 Agent 的 `name` 参数
64
67
  5. **主流程调 `ralph complete`** — 每个 step 完成后由主流程调 `maestro ralph complete`,非 agent 上报
65
- 6. **Decision evaluation inline** — decision 节点不 handoff,通过 `invoke_subagent()` 启动分析 Agent 在本循环内评估
66
- 7. **No CLI delegation** — 本命令不使用 `maestro delegate`;执行和评估均通过 invoke_subagent() 完成
68
+ 6. **Decision evaluation inline** — decision 节点不 handoff,通过 Agent CLI delegate 在本循环内评估
69
+ 7. **CLI delegation for evaluation only** — CLI delegate(`maestro delegate --mode analysis`)仅限评估环节;执行仍通过 executor Agent 完成
67
70
  8. **Decision delegates read-only** — 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读
68
71
  9. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(由 execute Agent 完成)
69
72
  10. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
@@ -100,7 +103,8 @@ S_CONFIRM — 用户确认
100
103
 
101
104
  S_STEP_LOCATE — 找下一个 pending step PERSIST: —
102
105
  S_STEP_RESOLVE — 解析占位符 + 丰富参数 PERSIST: step.args (enriched)
103
- S_STEP_DISPATCH — 组装上下文 + 派发 executor agent 执行单步 PERSIST: step.agent_exec_name, step.status = "running"
106
+ S_STEP_DISPATCH — 组装上下文 + 派发 named executor agent PERSIST: step.agent_exec_name, step.status = "running"
107
+ S_STEP_WAIT_MSG — 等待 executor 的 send_message 回传 PERSIST: —
104
108
  S_STEP_ANALYZE — 提取信号 + 组装 completion 参数 PERSIST: —
105
109
  S_STEP_DRIFT — 产物 vs 目标偏离分析 PERSIST: step.drift_score
106
110
  S_STEP_COMPLETE — 调 `ralph complete` 上报 PERSIST: step.completion_*
@@ -155,8 +159,12 @@ S_STEP_RESOLVE:
155
159
  → S_STEP_DISPATCH DO: A_STEP_RESOLVE_ARGS
156
160
 
157
161
  S_STEP_DISPATCH:
158
- S_STEP_ANALYZE WHEN: agent returned output DO: A_STEP_DISPATCH
159
- → S_HANDLE_FAIL WHEN: agent returned error/null DO: A_STEP_DISPATCH
162
+ S_STEP_WAIT_MSG WHEN: executor dispatched DO: A_STEP_DISPATCH
163
+
164
+ S_STEP_WAIT_MSG:
165
+ → S_STEP_ANALYZE WHEN: received agent-message with EXECUTOR_OUTPUT DO: A_STEP_RECEIVE
166
+ → S_HANDLE_FAIL WHEN: received agent-message with status=ERROR DO: A_STEP_RECEIVE
167
+ → S_HANDLE_FAIL WHEN: executor idle without send_message(崩溃检测) DO: mark BLOCKED
160
168
 
161
169
  S_STEP_ANALYZE:
162
170
  → S_STEP_DRIFT WHEN: STATUS == DONE|DONE_WITH_CONCERNS DO: A_STEP_EXTRACT
@@ -336,14 +344,17 @@ Execution criteria: {session.execution_criteria joined by '; '}
336
344
  | debug | `dbg` |
337
345
  | Other | `run` |
338
346
 
339
- **4. Dispatch:**
347
+ **4. Dispatch(named mailbox executor):**
348
+
349
+ > 执行 Agent 使用 `name` 参数派发为 named mailbox teammate,支持内部多 agent 编排。executor 通过 `send_message({to: "main"})` 回传执行结果。`resolved_agent_name` 同时用于 display 和 Agent `name` 参数。
340
350
 
341
351
  ```
342
352
  invoke_subagent({
343
- subagent_type: "ralph-executor",
344
353
  name: "{resolved_agent_name}",
354
+ subagent_type: "ralph-executor",
345
355
  description: "执行 step {index}: {step.skill}",
346
356
  prompt: `Session: {session_id}
357
+ Agent name: {resolved_agent_name}
347
358
 
348
359
  {goal_context 块,仅 protocol < 2 时}
349
360
 
@@ -352,11 +363,24 @@ invoke_subagent({
352
363
  })
353
364
  ```
354
365
 
355
- Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt 并执行。
356
-
357
366
  5. Write `step.agent_exec_name` to status.json
358
- 6. Display: `[{index}/{total}] ⟶ {step.skill} → Agent:{name}`
359
- 7. Agent 同步返回 `agent_output` = 返回文本;返回 null STATUS=BLOCKED
367
+ 6. Display: `[{index}/{total}] ⟶ {step.skill} → {resolved_agent_name}`
368
+ 7. invoke_subagent() 立即返回(named teammate 异步启动)→ 进入 S_STEP_WAIT_MSG 等待 executor 的 send_message
369
+
370
+ ### A_STEP_RECEIVE
371
+
372
+ 从 executor 的 `agent-message` 中提取执行输出。
373
+
374
+ 1. 接收到 `<agent-message from="{resolved_agent_name}">` 后,提取 message 内容
375
+ 2. 解析 `EXECUTOR_OUTPUT` 格式:
376
+ - `status: DONE` → agent_output = message 内容,继续 S_STEP_ANALYZE
377
+ - `status: DONE_WITH_CONCERNS` → agent_output = message 内容,继续 S_STEP_ANALYZE
378
+ - `status: ERROR` → STATUS=BLOCKED,转 S_HANDLE_FAIL
379
+ 3. idle_notification 处理(区分正常等待与崩溃):
380
+ - 首次收到 `idle_notification`:executor 可能在等待 worker 回传,正常现象,继续等待
381
+ - 连续收到 2 次 `idle_notification` 且中间无 `agent-message`:向 executor 发送 `send_message({to: "{resolved_agent_name}", message: "请回报执行状态"})` 询问
382
+ - 询问后仍只收到 `idle_notification` 无 `agent-message`:STATUS=BLOCKED,转 S_HANDLE_FAIL
383
+ 4. `agent_output` = 提取的 message 内容
360
384
 
361
385
  ### A_STEP_EXTRACT
362
386
 
@@ -485,10 +509,12 @@ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt
485
509
 
486
510
  ### A_AGENT_EVALUATE
487
511
 
488
- 通过 Agent 在本循环内评估质量门。
512
+ 通过 Agent 和/或 CLI delegate 评估质量门。评估模式由 `step.evaluate_via` 决定。
513
+
514
+ **1. Common setup:**
489
515
 
490
516
  1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
491
- 2. Parse decision metadata: `{ decision, retry_count, max_retries }`
517
+ 2. Parse decision metadata: `{ decision, retry_count, max_retries, evaluate_via }`
492
518
  3. Map result files:
493
519
 
494
520
  | Decision | Files |
@@ -499,33 +525,65 @@ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt
499
525
  | post-test | uat.md, .tests/test-results.json |
500
526
  | post-frontend-verify | e2e-results.json |
501
527
 
502
- 4. Dispatch evaluation Agent:
503
- ```
504
- invoke_subagent({
505
- name: "eval-{decision}-{timestamp}",
506
- description: "评估 {decision} 质量门",
507
- prompt: "PURPOSE: 评估 {decision} 质量门结果
508
- TASK: 读取以下结果文件 | 分析状态 | 评估严重性 | 给出建议
509
- FILES: {result_file_paths}
510
- SESSION: {session_dir}/status.json
511
- EXPECTED: 输出以下格式:
512
- ---VERDICT---
513
- STATUS: PASS|FAIL|PARTIAL|BLOCKED
514
- REASON: <一句话原因>
515
- GAP_SUMMARY: <差距摘要>
516
- CONFIDENCE: high|medium|low
517
- CONFIDENCE_SCORE: 0-100
518
- WEAKEST_DIMENSION: <最弱维度>
519
- ---END---
520
- CONSTRAINTS: 只评估不修改文件 | 置信度<60%倾向 fix | retry {n}/{max} 达上限必须 escalate"
521
- })
522
- ```
523
- 5. On return: parse `---VERDICT---` block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; parse failure → fallback STATUS="fix", `parse_failed: true`, `confidence_score: 0` (invariant 18)
528
+ 4. `evaluate_via` 默认值:`"agent"`(未设置时)
529
+
530
+ **2. Dispatch by mode:**
531
+
532
+ **Mode: `agent`(默认)** 同步 Agent 评估:
533
+
534
+ ```
535
+ invoke_subagent({
536
+ description: "评估 {decision} 质量门(同步评估 Agent,不传 name)",
537
+ prompt: "PURPOSE: 评估 {decision} 质量门结果
538
+ TASK: 读取以下结果文件 | 分析状态 | 评估严重性 | 给出建议
539
+ FILES: {result_file_paths}
540
+ SESSION: {session_dir}/status.json
541
+ EXPECTED: 输出以下格式:
542
+ ---VERDICT---
543
+ STATUS: PASS|FAIL|PARTIAL|BLOCKED
544
+ REASON: <一句话原因>
545
+ GAP_SUMMARY: <差距摘要>
546
+ CONFIDENCE: high|medium|low
547
+ CONFIDENCE_SCORE: 0-100
548
+ WEAKEST_DIMENSION: <最弱维度>
549
+ ---END---
550
+ CONSTRAINTS: 只评估不修改文件 | 置信度<60%倾向 fix | retry {n}/{max} 达上限必须 escalate"
551
+ })
552
+ ```
553
+
554
+ **Mode: `cli`** — CLI delegate 评估(异步后台):
555
+
556
+ ```
557
+ run_command({
558
+ command: `maestro delegate "PURPOSE: 评估 ${decision} 质量门结果\nTASK: 读取 ${result_file_paths} | 分析状态 | 评估严重性\nEXPECTED: ---VERDICT--- 格式(STATUS/REASON/GAP_SUMMARY/CONFIDENCE_SCORE)\nCONSTRAINTS: 只评估不修改文件" --mode analysis --rule analysis-review-code-quality`,
559
+ run_in_background: true
560
+ })
561
+ ```
562
+ 等待 delegate 完成 → `maestro delegate output {exec_id}` 获取结果 → 解析 `---VERDICT---`
563
+
564
+ **Mode: `dual`** — Agent + CLI 并行评估,交叉验证:
565
+
566
+ 1. 先派发 CLI delegate(`run_in_background: true`)
567
+ 2. 同时派发同步 Agent(阻塞等待)
568
+ 3. Agent 返回后,检查 CLI delegate 状态(`maestro delegate status {exec_id}`)
569
+ 4. 合并裁决:
570
+
571
+ | Agent 结果 | CLI 结果 | 合并策略 |
572
+ |-----------|---------|---------|
573
+ | 两者一致 | — | 采用共识,confidence_score 取较高值 |
574
+ | Agent=PASS, CLI=FAIL | — | 降级为 PARTIAL,confidence_score 取平均值 |
575
+ | Agent=FAIL, CLI=PASS | — | 维持 FAIL(保守策略) |
576
+ | CLI 未返回 | — | 使用 Agent 结果,标 `"cli_pending": true` |
577
+
578
+ **3. Verdict parse + adjustment(所有模式通用):**
579
+
580
+ 5. Parse `---VERDICT---` block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; parse failure → fallback STATUS="fix", `parse_failed: true`, `confidence_score: 0` (invariant 18)
524
581
  6. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
525
582
  7. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
526
583
  ```json
527
584
  { "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-v2",
528
585
  "node_id": "{step.decision}", "type": "quality-gate",
586
+ "evaluate_via": "{mode}", "cli_exec_id": "{exec_id|null}",
529
587
  "verdict": "{adjusted_verdict}", "confidence_score": {N},
530
588
  "parse_failed": false,
531
589
  "close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
@@ -533,14 +591,13 @@ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt
533
591
 
534
592
  ### A_AGENT_GOAL_AUDIT
535
593
 
536
- 通过 Agent 审计子目标完成情况。
594
+ 通过 Agent 和/或 CLI delegate 审计子目标完成情况。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
537
595
 
538
596
  1. Read `session.task_decomposition` from status.json
539
- 2. Dispatch audit Agent:
597
+ 2. Dispatch audit(按 `evaluate_via` 模式,默认 `agent`):
540
598
  ```
541
599
  invoke_subagent({
542
- name: "goal-audit-{timestamp}",
543
- description: "审计子目标完成情况",
600
+ description: "审计子目标完成情况(同步评估 Agent,不传 name)",
544
601
  prompt: "PURPOSE: 审计未完成子目标,判定 met / unmet
545
602
  TASK:
546
603
  1. 读取 {session_dir}/status.json 中 task_decomposition 的 status!=done 子目标
@@ -564,20 +621,19 @@ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt
564
621
  })
565
622
  ```
566
623
  3. On return: parse verdict, update task_decomposition status
567
- 4. Append `{session_dir}/decisions.ndjson`:`{ "type": "goal-gate", "unmet_count": N, "unmet_ids": [...] }`
624
+ 4. Append `{session_dir}/decisions.ndjson`:`{ "type": "goal-gate", "evaluate_via": "{mode}", "unmet_count": N, "unmet_ids": [...] }`
568
625
  5. Verdict routing: `all_met` + `INTENT_ALIGNED=true` → A_APPLY_GOAL_DONE;`all_met` + `INTENT_ALIGNED=false` → A_REGROUND_HALT;`has_unmet` → A_APPLY_GOAL_FIX
569
626
  GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
570
627
 
571
628
  ### A_AGENT_REGROUND
572
629
 
573
- 通过 Agent 执行意图保真检查。
630
+ 通过 Agent 和/或 CLI delegate 执行意图保真检查。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
574
631
 
575
632
  1. Read status.json:intent, boundary_contract, completed steps, done goals
576
- 2. Dispatch reground Agent:
633
+ 2. Dispatch reground(按 `evaluate_via` 模式,默认 `agent`):
577
634
  ```
578
635
  invoke_subagent({
579
- name: "reground-{timestamp}",
580
- description: "意图保真检查",
636
+ description: "意图保真检查(同步评估 Agent,不传 name)",
581
637
  prompt: "PURPOSE: 意图保真检查 — 对照 intent 验证累积执行是否漂移
582
638
  TASK:
583
639
  1. 读取 intent + boundary_contract.definition_of_done
@@ -676,8 +732,7 @@ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt
676
732
  **Phase 3 Agent prompt:**
677
733
  ```
678
734
  invoke_subagent({
679
- name: "amend-grill-{timestamp}",
680
- description: "Amend impact analysis",
735
+ description: "Amend impact analysis(同步评估 Agent,不传 name)",
681
736
  prompt: "PURPOSE: 评估目标修改对 running session 的影响
682
737
  TASK:
683
738
  1. 读取 {session_dir}/status.json 的 task_decomposition + boundary_contract + 已完成 steps
@@ -708,7 +763,10 @@ GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
708
763
 
709
764
  - **A_RETRY**: `run_command("maestro ralph retry {index}")` — CLI 设 `step.retried = true`, `step.status = "pending"`, 清 `active_step_index`
710
765
  - **A_PAUSE_SESSION**: `ralph complete N --status BLOCKED --reason "..."` — CLI 写 `session.status = "paused"`
711
- - **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`
766
+ - **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`。完成后向所有 idle executor 发送 shutdown_request 清理:
767
+ ```
768
+ 遍历 steps[].agent_exec_name → send_message({to: name, message: {type: "shutdown_request"}})
769
+ ```
712
770
 
713
771
  </actions>
714
772
 
@@ -775,6 +833,7 @@ Build rules 0-14 全部适用,包括 spec-setup 预检(rule 0.5)、grill a
775
833
  "stage": "",
776
834
  "scope": null,
777
835
  "decision": null,
836
+ "evaluate_via": "agent|cli|dual",
778
837
  "retry_count": 0,
779
838
  "max_retries": 2,
780
839
  "command_scope": "global|project|missing|null",
@@ -839,24 +898,27 @@ E001–E006, W001–W004 适用。Agent 新增:
839
898
 
840
899
  ### Success Criteria
841
900
 
842
- - [ ] ralph-v2 owns full step loop: locate → resolve → dispatch → extract → drift → complete → next
843
- - [ ] One agent per step — `invoke_subagent([{ TypeName: "ralph-executor", Role: "<Role>", Prompt: "<Prompt>", Workspace: "inherit" }])` 每步派发一个
844
- - [ ] Agent 内调 `maestro ralph next` 获取 skill prompt 并执行,返回执行输出
901
+ - [ ] ralph-v2 owns full step loop: locate → resolve → dispatch → wait → receive → extract → drift → complete → next
902
+ - [ ] One agent per step — `invoke_subagent([{ TypeName: "ralph-executor", Role: "<Role>", Prompt: "<Prompt>", Workspace: "inherit" }])` 每步派发一个 named executor
903
+ - [ ] Executor 内调 `maestro ralph next` 获取 skill prompt 并执行,支持内部多 agent 编排
904
+ - [ ] Executor 通过 `send_message({to: "main"})` 回传 `EXECUTOR_OUTPUT` 格式结果
845
905
  - [ ] 主流程调 `maestro ralph complete` 上报(非 agent 上报)
846
906
  - [ ] 主流程负责 arg resolution、context loading、signal extraction、drift analysis
847
- - [ ] Agent 返回执行输出文本,主流程从中提取信号和状态
848
- - [ ] Agent 崩溃(返回 null)→ STATUS=BLOCKED,转 S_HANDLE_FAIL
849
- - [ ] STOP/callback 模式 invoke_subagent() 同步等待返回
850
- - [ ] Decision evaluation 通过 invoke_subagent() 同步完成
907
+ - [ ] A_STEP_RECEIVE 从 executor 的 agent-message 中提取执行输出
908
+ - [ ] Executor 崩溃(idle 无 send_message)→ 询问 2 次后 STATUS=BLOCKED,转 S_HANDLE_FAIL
909
+ - [ ] Dual dispatch: 执行 Agent `name`(async + send_message),评估 Agent 不传 `name`(sync)或 CLI delegate
910
+ - [ ] Decision evaluation 支持三种模式:agent(同步)、cli(CLI delegate)、dual(并行交叉验证)
911
+ - [ ] `evaluate_via` 字段控制评估模式,默认 `"agent"`
912
+ - [ ] dual 模式合并策略:一致取共识、分歧保守降级、CLI 未返回用 Agent 结果
851
913
  - [ ] Verdict 解析保持 `---VERDICT---` 格式,parse 失败 → fallback fix + parse_failed: true
852
914
  - [ ] decisions.ndjson 追加:source 字段为 `"ralph-v2"`
853
- - [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name`(执行 Agent 名称标识),含 `artifacts_produced`
915
+ - [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name`(执行 Agent name + display),含 `artifacts_produced`
854
916
  - [ ] Chain building(S_RESOLVE_PHASE through S_BUILD_CHAIN)自包含执行
855
917
  - [ ] A_STEP_DISPATCH 含前序产出加载(滑动窗口 5 step + accumulated signals + stage-specific artifacts)
856
- - [ ] Agent name 含 stage prefix(grl/brn/anm/ana/pln/exe/rev/tst/dbg
918
+ - [ ] `agent_exec_name` 含 stage prefix(grl/brn/anm/ana/pln/exe/rev/tst/dbg)——同时用于 Agent name 参数和 display
857
919
  - [ ] `--summary` 在 DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
858
920
  - [ ] CAVEATS 在 DONE_WITH_CONCERNS 时同时映射 --concerns
859
- - [ ] A_STEP_EXTRACT 从 agent 输出提取 artifact IDs、path signals、phase signals
921
+ - [ ] A_STEP_EXTRACT 从 executor 输出提取 artifact IDs、path signals、phase signals
860
922
  - [ ] A_STEP_DRIFT_ANALYZE:ALIGNED/MINOR_DRIFT → complete;MAJOR_DRIFT+未重试 → retry;MAJOR_DRIFT+已重试 → DONE_WITH_CONCERNS
861
923
  - [ ] A_STEP_COMPLETE 将 context signals 写入 status.json.context
862
924
  - [ ] A_AMEND_GOAL:完整 5 步流程 + deferred_reading ralph-amend-goal.md + Agent mini grill 含完整 prompt
@@ -42,6 +42,8 @@ Remaining → intent
42
42
  | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
43
43
  | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
44
44
  | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
45
+
46
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/` (results, ralph-compatible artifacts). When inside a ralph session, writes target the corresponding step's scratch directory. NEVER modify source code, workflow scripts (`~/.maestro/workflows/swarm/`), or `.claude/commands/` files.
45
47
  </context>
46
48
 
47
49
  <state_machine>
@@ -195,6 +197,29 @@ Workflow 返回 JSON 后:
195
197
  6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
196
198
  </invariants>
197
199
 
200
+ <execution>
201
+
202
+ ### Phase Gates (MANDATORY, BLOCKING)
203
+
204
+ **GATE 1: Parse → Route**
205
+ - REQUIRED: Intent text or `--script` flag parsed successfully.
206
+ - BLOCKED if: no intent and no `--script` (E001).
207
+
208
+ **GATE 2: Route → Context Assembly**
209
+ - REQUIRED: Target script resolved unambiguously (single match or user-selected from candidates).
210
+ - BLOCKED if: ambiguous routing without user resolution (E002).
211
+
212
+ **GATE 3: Context → Dispatch**
213
+ - REQUIRED: Args payload assembled with all required fields for target script.
214
+ - REQUIRED: Script file exists at `~/.maestro/workflows/swarm/{script}.js`.
215
+ - BLOCKED if: script file not found (E003) or required args missing.
216
+
217
+ **GATE 4: Dispatch → Ingest**
218
+ - REQUIRED: Workflow execution completed (success or partial results available).
219
+ - BLOCKED if: Workflow execution failed entirely (E004) — offer `--resume`.
220
+
221
+ </execution>
222
+
198
223
  <appendix>
199
224
 
200
225
  ### 与 Ralph 集成
@@ -37,8 +37,37 @@ $ARGUMENTS — Tool name, keyword, or --category filter
37
37
  Empty arguments enters interactive mode: list all tools for user selection.
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Confirmation before execution** — MUST ask_question before executing tool steps; NEVER auto-execute without user consent
42
+ 2. **Sequential step execution** — steps MUST be executed in defined order; NEVER skip or reorder steps unless user explicitly requests skip
43
+ 3. **Blocker escalation** — step failure MUST be reported to user with retry/skip/abort options; NEVER silently skip failed steps
44
+ 4. **Read-only tool definition** — tool execution MUST NOT modify the tool's knowhow document or spec entry; only the target codebase is modified per tool steps
45
+ 5. **Progress feedback** — each completed step MUST report `[Step N/M] done — <step_name>`; NEVER execute silently
46
+ 6. **Output boundary** — file writes are governed by the individual tool's step definitions. This command itself writes NO files beyond what the loaded tool prescribes
47
+ </invariants>
48
+
40
49
  <execution>
41
50
 
51
+ ### Phase Gates (MANDATORY, BLOCKING)
52
+
53
+ **GATE 1: Parse → Load**
54
+ - REQUIRED: Tool name, keyword, or --category parsed from arguments (or empty for interactive mode).
55
+ - BLOCKED if: invalid category value.
56
+
57
+ **GATE 2: Load → Confirm**
58
+ - REQUIRED: Exactly one tool resolved (direct match or user selection from candidates).
59
+ - REQUIRED: Tool document loaded and steps extracted (ref entries expanded via `maestro load --type knowhow`).
60
+ - BLOCKED if: E001 (no match found), E002 unresolved (multiple matches without user selection).
61
+
62
+ **GATE 3: Confirm → Execute**
63
+ - REQUIRED: User confirmed execution mode via ask_question (execute as-is / adjust / view only).
64
+ - BLOCKED if: user selects "View only" — display steps and END without execution.
65
+
66
+ **GATE 4: Execute → Report**
67
+ - REQUIRED: All steps attempted (completed, skipped with user approval, or aborted by user).
68
+ - REQUIRED: Results collected for each step (success/skip/fail).
69
+ - BLOCKED if: user chose abort mid-execution — report partial results and END.
70
+
42
71
  ### Step 1: Load Tool
43
72
 
44
73
  **By name**:
@@ -37,8 +37,37 @@ $ARGUMENTS — Intent description
37
37
  ```
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Schema validation** — tool knowhow document MUST include `tool: true`, `category`, `keywords`, and `summary` in YAML frontmatter; missing fields → reject write
42
+ 2. **No duplicate names** — tool title MUST be unique within its category; duplicate detection → E002 warning with overwrite/optimize confirmation
43
+ 3. **Category required** — every tool MUST declare exactly one category from: coding, test, review, arch, debug; empty category → E003
44
+ 4. **Confirmation gate** — MUST ask_question before writing knowhow document and spec ref entry; NEVER persist without user confirmation
45
+ 5. **Promote is in-place** — promote mode MUST update existing knowhow frontmatter via `maestro wiki update`; NEVER recreate the document
46
+ 6. **Output boundary** — ALL file writes MUST target .workflow/knowhow/ (tool documents) and .workflow/specs/ (ref entries via maestro spec add) only. NEVER modify source code or files outside these paths
47
+ 7. **Description format** — first line after `### Title` MUST state "Use when ..." (usage timing); this is critical for ref entry summary visibility in spec-load
48
+ </invariants>
49
+
40
50
  <execution>
41
51
 
52
+ ### Phase Gates (MANDATORY, BLOCKING)
53
+
54
+ **GATE 1: Parse → Gather**
55
+ - REQUIRED: Mode determined (extract/generate/optimize/promote) from argument parsing.
56
+ - REQUIRED: For optimize/promote modes, target tool/document exists and is loadable.
57
+ - BLOCKED if: empty args without user response to ask_question.
58
+
59
+ **GATE 2: Gather → Write**
60
+ - REQUIRED: Tool name, category, and usage timing confirmed.
61
+ - REQUIRED: Steps extracted or generated (extract: ≥1 step, generate: user-confirmed scope).
62
+ - REQUIRED: Inline vs ref mode decided based on step count.
63
+ - REQUIRED: User confirmed via ask_question (title, category, keywords, summary, step count).
64
+ - BLOCKED if: E001 (.workflow/specs/ not initialized), E003 (no category), user cancels.
65
+
66
+ **GATE 3: Write → Verify**
67
+ - REQUIRED: Knowhow document written with `tool: true` frontmatter (or updated in-place for promote).
68
+ - REQUIRED: Spec ref entry registered (if user confirmed).
69
+ - BLOCKED if: write failed or spec add returned error.
70
+
42
71
  ### Step 1: Intent Detection
43
72
 
44
73
  Parse $ARGUMENTS to determine mode:
@@ -34,8 +34,19 @@ Flags:
34
34
  - `--package-name <name>`: Package name for reference output (default: auto-generated from source directory)
35
35
  - `--output-dir <path>`: Output directory for reference package (default: `.workflow/reference_style`)
36
36
  - `--overwrite`: Allow overwriting existing package directory
37
+
38
+ **Output boundary**: ALL file writes MUST target the `--output-dir` path (default: `.workflow/reference_style/`) for reference packages, and `.workflow/knowhow/` for knowledge assets (via `codify-to-knowhow`). NEVER modify the source directory being analyzed.
37
39
  </context>
38
40
 
41
+ <invariants>
42
+ 1. **Source read-only** — the source path being analyzed MUST NOT be modified; extraction is purely read-only
43
+ 2. **Phase-sequential loading** — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly
44
+ 3. **User confirmation before knowhow** — Phase 3→4 gate MUST present ask_question before generating knowledge assets; NEVER auto-proceed to knowhow generation
45
+ 4. **Overwrite protection** — existing package directory MUST NOT be overwritten without `--overwrite` flag (E003)
46
+ 5. **Artifact completeness** — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification
47
+ 6. **Token-first extraction** — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation
48
+ </invariants>
49
+
39
50
  <execution>
40
51
  ## 1. Load UI Specs
41
52