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
@@ -32,6 +32,8 @@ Remaining → intent
32
32
  **Library locations:**
33
33
  - Fixed scripts: `~/.maestro/workflows/swarm/wf-*.js`
34
34
  - Dynamic scripts: `~/.maestro/workflows/dynamic/uwf-*.js`
35
+
36
+ **Output boundary**: ALL file writes MUST target `~/.maestro/workflows/dynamic/` (generated scripts) and `.workflow/scratch/{YYYYMMDD}-uwf-*/` (execution results). Fixed scripts at `~/.maestro/workflows/swarm/` are read-only. NEVER modify source code or `.claude/commands/` files.
35
37
  </context>
36
38
 
37
39
  <state_machine>
@@ -508,6 +510,36 @@ Findings: ${digest}
508
510
  12. **无反斜杠路径** — 字符串中路径用正斜杠(`\u`、`\a` 等会被解析为转义序列)
509
511
  </invariants>
510
512
 
513
+ <execution>
514
+
515
+ ### Phase Gates (MANDATORY, BLOCKING)
516
+
517
+ **GATE 1: Parse → Scan**
518
+ - REQUIRED: Intent text or `--from`/`--resume` flag parsed.
519
+ - BLOCKED if: no intent and no flags (E001).
520
+
521
+ **GATE 2: Scan → Design/Execute**
522
+ - REQUIRED: Library scan completed (both `swarm/` and `dynamic/` directories).
523
+ - REQUIRED: User decision if matches found (reuse existing vs generate new).
524
+ - BLOCKED if: scan fails to read script directories.
525
+
526
+ **GATE 3: Design → Generate**
527
+ - REQUIRED: Task decomposition completed with work_items, decision_points, data_flow.
528
+ - REQUIRED: Phase orchestration and adversarial pattern selection determined by depth.
529
+ - BLOCKED if: task cannot be decomposed (E002).
530
+
531
+ **GATE 4: Generate → Execute**
532
+ - REQUIRED: Script written to `~/.maestro/workflows/dynamic/uwf-{slug}.js`.
533
+ - REQUIRED: `node --check` syntax validation passed.
534
+ - REQUIRED: User confirmation via ask_question (unless resuming).
535
+ - BLOCKED if: syntax validation fails after 2 retries (E003).
536
+
537
+ **GATE 5: Execute → Persist**
538
+ - REQUIRED: Workflow execution completed via `scriptPath` invocation.
539
+ - BLOCKED if: Workflow execution failed (E004) — offer `--resume`.
540
+
541
+ </execution>
542
+
511
543
  <appendix>
512
544
 
513
545
  ### 使用示例
@@ -568,3 +600,30 @@ universal-workflow 扫描时会同时检查 swarm/ 和 dynamic/ 目录,
568
600
  | E005 | 持久化失败 | 展示脚本内容,让用户手动保存 |
569
601
 
570
602
  </appendix>
603
+
604
+ <error_codes>
605
+ | Code | Severity | Condition | Recovery |
606
+ |------|----------|-----------|----------|
607
+ | E001 | error | No intent and no --from/--resume flag | Prompt user for intent text |
608
+ | E002 | error | Task decomposition failed — cannot identify work_items | Require more specific intent description |
609
+ | E003 | error | Generated script syntax error after 2 retries | Show script content + error for manual fix |
610
+ | E004 | error | Workflow execution failed | Show error, offer --resume with runId |
611
+ | E005 | error | Script persistence failed (filesystem write error) | Show script content for manual save |
612
+ | W001 | warning | No matching scripts found in library scan | Proceed directly to S_DESIGN |
613
+ | W002 | warning | Adversarial gate confidence < 50% | Flag low-confidence decision, suggest --depth deep |
614
+ </error_codes>
615
+
616
+ <success_criteria>
617
+ - [ ] Intent parsed and flags extracted (--name, --depth, --dry-run, --from, --resume)
618
+ - [ ] Library scan completed across both swarm/ and dynamic/ directories
619
+ - [ ] User decision captured if matching scripts found (reuse vs generate)
620
+ - [ ] Task decomposition produced: work_items, decision_points, data_flow
621
+ - [ ] Adversarial pattern selected per decision_point according to depth level
622
+ - [ ] Blueprint presented to user with estimated agent count
623
+ - [ ] Script generated as pure JavaScript with all 12 generation rules enforced
624
+ - [ ] `node --check` syntax validation passed
625
+ - [ ] User confirmation obtained before execution (unless --resume)
626
+ - [ ] Workflow executed via scriptPath (not inline script string)
627
+ - [ ] Script persisted to `~/.maestro/workflows/dynamic/uwf-{slug}.js`
628
+ - [ ] Completion summary displayed with reuse/resume commands
629
+ </success_criteria>
@@ -29,10 +29,38 @@ $ARGUMENTS — optional flags.
29
29
  - `update-v{TO}-setup.md` — post-migration setup for version {TO}
30
30
 
31
31
  **Schema registry:** `src/migrations/` — handles all intermediate version bumps automatically
32
+
33
+ **Output boundary**: ALL file writes MUST target `.workflow/state.json` (version bump), `.workflow/state.json.backup-*` (backup), and `.workflow/` config files touched by version-specific setup. NEVER modify source code or `src/migrations/` files.
32
34
  </context>
33
35
 
36
+ <invariants>
37
+ 1. **Backup before migration** — a timestamped backup of `.workflow/state.json` MUST be created before any schema migration runs; NEVER execute migration without backup
38
+ 2. **Idempotent** — running update when already on latest version MUST be a no-op (display "up to date"); NEVER re-apply migrations
39
+ 3. **Confirmation before execute** — migration diff MUST be displayed and user MUST confirm via ask_question before execution (unless `--force`); NEVER silently apply schema changes
40
+ 4. **Migration diff always visible** — even with `--force`, the migration diff MUST be displayed for audit visibility; NEVER skip diff display
41
+ 5. **Restore path on failure** — if migration fails, the backup restore command MUST be displayed; NEVER leave user without recovery instructions
42
+ 6. **Sequential migration** — all intermediate version steps MUST be applied in order by the schema registry; NEVER skip intermediate versions
43
+ </invariants>
44
+
34
45
  <execution>
35
46
 
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Detect → Check**
50
+ - REQUIRED: Current version read from `.workflow/state.json`.
51
+ - BLOCKED if: state.json missing or unreadable (E001).
52
+
53
+ **GATE 2: Check → Execute**
54
+ - REQUIRED: Dry-run migration check completed; target version identified.
55
+ - REQUIRED: User confirmation via ask_question (unless `--force`).
56
+ - BLOCKED if: already up to date (display message and exit) or user cancels.
57
+
58
+ **GATE 3: Execute → Summary**
59
+ - REQUIRED: Backup created at `.workflow/state.json.backup-v{current}-{timestamp}`.
60
+ - REQUIRED: Schema migration completed successfully.
61
+ - REQUIRED: Version-specific setup doc followed (if exists).
62
+ - BLOCKED if: migration failed — display restore command and exit.
63
+
36
64
  ### Step 1: Detect Version
37
65
 
38
66
  ```
@@ -105,6 +133,16 @@ Next steps:
105
133
 
106
134
  </execution>
107
135
 
136
+ <error_codes>
137
+ | Code | Severity | Condition | Recovery |
138
+ |------|----------|-----------|----------|
139
+ | E001 | error | `.workflow/state.json` not found or unreadable | Run `/maestro-init` first |
140
+ | E002 | error | Schema migration failed (npx tsx returned error) | Display backup restore command: `cp .workflow/state.json.backup-* .workflow/state.json` |
141
+ | E003 | error | Version-specific setup doc failed to execute | Manual setup: read `~/.maestro/workflows/updates/update-v{target}-setup.md` |
142
+ | W001 | warning | No version-specific setup doc found for target version | Proceed without setup; schema migration alone is sufficient |
143
+ | W002 | warning | `--setup-only` but no setup script exists for current version | Display message and exit |
144
+ </error_codes>
145
+
108
146
  <success_criteria>
109
147
  - [ ] Current version detected from state.json
110
148
  - [ ] Schema migrations run automatically (no manual intermediate steps)
@@ -46,13 +46,42 @@ $ARGUMENTS -- optional flags.
46
46
  - `.workflow/codebase/` -- target directory (will be cleared and rebuilt)
47
47
  - `.workflow/codebase/doc-index.json` -- generated documentation index
48
48
  - `.workflow/codebase/knowledge-graph.json` -- Knowledge Graph with nodes, edges, layers, and tour (generated by `maestro kg index`)
49
+
50
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/`, `.workflow/state.json`, or `.workflow/project.md` (Tech Stack section only). NEVER modify source code or files outside these paths.
49
51
  </context>
50
52
 
53
+ <invariants>
54
+ 1. **Destructive with confirmation** — rebuild clears `.workflow/codebase/` entirely; MUST confirm with user unless `--force` is set
55
+ 2. **Commit confirmation** — git commit MUST be confirmed by user unless `--force` is set; `--skip-commit` bypasses commit entirely
56
+ 3. **Partial failure tolerance** — if 1-3 mapper agents fail, proceed with partial results (W001); only abort if all 4 fail (E002)
57
+ 4. **Focus scoping** — when `--focus <area>` is set, MUST only regenerate docs relevant to that scope; leave unrelated docs untouched
58
+ 5. **State update** — MUST update state.json with rebuild timestamp on completion
59
+ 6. **KG pipeline mandatory** — MUST run `maestro kg index` after doc regeneration; KG validation failure is non-fatal (W003)
60
+ </invariants>
61
+
51
62
  <execution>
52
63
  Follow '~/.maestro/workflows/codebase-rebuild.md' completely.
53
64
 
54
65
  **When `--focus <area>` is set:** pass the area string to each mapper agent as scoping context; only regenerate the docs relevant to that scope (leave others untouched unless missing).
55
66
 
67
+ ### Phase Gates (MANDATORY, BLOCKING)
68
+
69
+ **GATE 1: Confirmation → Mapping** (Pre-flight → Agent spawn)
70
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
71
+ - REQUIRED: User confirmed rebuild (or `--force` set). W002 if existing docs found.
72
+ - BLOCKED if user declines confirmation.
73
+
74
+ **GATE 2: Mapping → KG Pipeline** (Agent results → Knowledge Graph)
75
+ - REQUIRED: At least 1 of 4 mapper agents returned valid results.
76
+ - REQUIRED: All output files written to `.workflow/codebase/`.
77
+ - REQUIRED: doc-index.json generated and valid.
78
+ - BLOCKED if all 4 mapper agents failed (E002).
79
+
80
+ **GATE 3: KG Pipeline → Commit** (Knowledge Graph → Git)
81
+ - REQUIRED: `maestro kg index` executed (W003 if validation fails — non-blocking).
82
+ - REQUIRED: state.json updated with rebuild timestamp.
83
+ - REQUIRED: If not `--skip-commit`: user confirmed git commit (or `--force` set).
84
+ - BLOCKED if state.json update fails.
56
85
  </execution>
57
86
 
58
87
  <completion>
@@ -60,8 +60,20 @@ Arguments: $ARGUMENTS
60
60
  - `.workflow/project.md`
61
61
 
62
62
  使用 `maestro timeline` CLI 构建统一的 git+session 时间线。
63
+
64
+ **Output boundary**: ALL file writes MUST target `.workflow/` metadata files (specs, codebase docs, roadmap.md, state.json, issues.jsonl) or `.workflow/.trash/drift-realign-{timestamp}/` (backups) or `.workflow/.drift-realign/` (session details). NEVER modify source code files.
63
65
  </context>
64
66
 
67
+ <invariants>
68
+ 1. **Code-as-Truth** — 代码是唯一真理源;当文档说 X 但代码做 Y 时,文档漂移,NEVER 反向修改代码来匹配文档
69
+ 2. **Backup before mutate** — MUST create backup tarball in `.workflow/.trash/` before any file modification (E005 if backup fails)
70
+ 3. **Never modify source code** — drift-realign only updates `.workflow/` metadata; source code files are read-only
71
+ 4. **Mutual exclusion** — `--report` 与 `--auto-archive` 互斥;同时传入 MUST trigger E006
72
+ 5. **Auto-depth escalation** — `drift_window` > 180 天 MUST auto-upgrade to `--depth deep` with W002 warning
73
+ 6. **Audit trail** — every triage decision MUST be logged in `drift-log.jsonl` with finding ID, action, and timestamp
74
+ 7. **Rebuild trigger** — codebase scope 的 3+ P0 finding MUST auto-trigger `/quality-sync --full` after triage
75
+ </invariants>
76
+
65
77
  <execution>
66
78
  Follow `~/.maestro/workflows/drift-realign.md` Stages 1-9 in order.
67
79
 
@@ -39,17 +39,41 @@ Arguments: $ARGUMENTS
39
39
  - `-y` / `--yes` — Skip confirmation prompts for all write operations (artifact selection, routing decisions, store writes). Useful for CI or batch harvesting.
40
40
 
41
41
  Additional flags, source registry (scan paths), and storage locations defined in workflow harvest.md.
42
+
43
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/`, `.workflow/specs/`, `.workflow/issues/`, `.workflow/wiki/`, `.workflow/harvest/`, or `.workflow/state.json` only. NEVER modify source code, source artifacts, or files outside these paths.
42
44
  </context>
43
45
 
46
+ <invariants>
47
+ 1. **Read-only until routing** — extraction and classification happen in-memory; no files written until Stage 6
48
+ 2. **Never modify source artifacts** — harvest is purely extractive; source files remain untouched
49
+ 3. **Dedup before write** — MUST check harvest-log.jsonl and existing stores before each write to prevent duplicates
50
+ 4. **Source tagging** — MUST set `source: "harvest"` on every issues.jsonl row so concurrent writers can be distinguished
51
+ 5. **Conflict pre-check on spec routing** — when routing to spec, MUST compare against existing specs with same keywords/category; set `confidence="low"` and log conflict note if semantic conflict detected
52
+ 6. **Provenance tracking** — every routed item MUST be logged in harvest-log.jsonl with fragment ID, target store, and timestamp
53
+ 7. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview only
54
+ </invariants>
55
+
44
56
  <execution>
45
57
  Follow '~/.maestro/workflows/harvest.md' Stages 1-8 in order.
46
58
 
47
- **Key invariants:**
48
- 1. **Read-only until Stage 6** — extraction and classification happen in-memory.
49
- 2. **Dedup before write** check harvest-log.jsonl and existing stores before each write.
50
- 3. **Never modify source artifacts** harvest is purely extractive.
51
- 4. **Dedup contract with parallel writers** — when appending to `issues.jsonl`, set `source: "harvest"` on each row so concurrent writers (e.g. `manage-issue-discover` with `source: "discover"`) can be distinguished and deduplicated.
52
- 5. **Conflict pre-check on spec routing** when routing to spec (Stage 6b), compare new entry against existing specs with same keywords/category. If semantic conflict detected, set `confidence="low"` on the new entry and log conflict note. Use `maestro spec conflict mark` if contradiction is clear.
59
+ ### Phase Gates (MANDATORY, BLOCKING)
60
+
61
+ **GATE 1: Discovery → Extraction** (Stages 1-3 Stage 4)
62
+ - REQUIRED: Source artifacts discovered and mode resolved (scan/session/path).
63
+ - REQUIRED: User selected artifact(s) to harvest (or auto-selected via session/path mode, or `-y`).
64
+ - BLOCKED if no harvestable artifacts found (W001) or invalid source (E004/E005).
65
+
66
+ **GATE 2: Extraction → Routing** (Stage 4 → Stage 5-6)
67
+ - REQUIRED: All files in selected artifacts loaded and parsed.
68
+ - REQUIRED: Knowledge fragments extracted with category, confidence, and tags.
69
+ - REQUIRED: Fragments filtered by `--min-confidence`.
70
+ - BLOCKED if extraction produces zero fragments.
71
+
72
+ **GATE 3: Routing → Write** (Stage 6 → Stage 7-8)
73
+ - REQUIRED: Routing classification applied (auto or forced by `--to`).
74
+ - REQUIRED: Dedup check passed against harvest-log.jsonl and existing stores.
75
+ - REQUIRED: If `--dry-run`: preview displayed, no files written — GATE blocks further writes.
76
+ - BLOCKED if dedup check fails or store paths unresolvable.
53
77
 
54
78
  Extraction patterns, classification rules, routing infrastructure, and fragment ID scheme defined in workflow harvest.md.
55
79
 
@@ -36,12 +36,35 @@ $ARGUMENTS -- subcommand + options. Parse first token as subcommand.
36
36
  **State files:**
37
37
  - `.workflow/issues/issues.jsonl` -- active issues (one JSON per line)
38
38
  - `.workflow/issues/issue-history.jsonl` -- archived/closed issues
39
+
40
+ **Output boundary**: ALL file writes MUST target `.workflow/issues/issues.jsonl`, `.workflow/issues/issue-history.jsonl`, or `.workflow/issues/` directory only. NEVER modify source code or files outside these paths.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Schema compliance** — every issue record MUST conform to the canonical issue.json template schema
45
+ 2. **ID uniqueness** — issue IDs (ISS-XXXXXXXX-NNN) MUST be unique across issues.jsonl and issue-history.jsonl
46
+ 3. **Close moves to history** — `close` subcommand MUST move the record from issues.jsonl to issue-history.jsonl, NEVER delete without archiving
47
+ 4. **Bidirectional links** — `link` subcommand MUST create references in both the issue and the linked task
48
+ 5. **Confirmation on destructive ops** — `close` and bulk `update` MUST require user confirmation unless `-y` flag is set
49
+ 6. **Append-only audit** — NEVER overwrite existing issue records; updates MUST preserve all prior fields and add `updated_at` timestamp
50
+ </invariants>
51
+
41
52
  <execution>
42
53
  Parse subcommand from first token of $ARGUMENTS.
43
54
  Follow '~/.maestro/workflows/issue.md' completely.
44
55
 
56
+ ### Phase Gates (MANDATORY, BLOCKING)
57
+
58
+ **GATE 1: Parse → Execute** (Subcommand routing)
59
+ - REQUIRED: Subcommand parsed and validated against valid set (create/list/status/update/close/link).
60
+ - REQUIRED: `.workflow/issues/` directory exists (auto-create with empty issues.jsonl if missing).
61
+ - BLOCKED if E_NO_SUBCOMMAND or E_INVALID_SUBCOMMAND.
62
+
63
+ **GATE 2: Execute → Write** (For mutating subcommands: create/update/close/link)
64
+ - REQUIRED: Issue data validated against issue.json template schema.
65
+ - REQUIRED: For `close`: resolution text provided.
66
+ - REQUIRED: For `link`: target task ID resolved and exists.
67
+ - BLOCKED if schema validation fails or target references unresolvable.
45
68
  </execution>
46
69
 
47
70
  <completion>
@@ -47,8 +47,19 @@ $ARGUMENTS -- optional. Parse first token to determine mode.
47
47
  ### Pre-load specs
48
48
  1. **Debug specs**: Run `maestro load --type spec --category debug` to load known antipatterns, root causes, and gotchas. Informs discovery perspectives with prior findings.
49
49
  2. Optional — proceed without if unavailable.
50
+
51
+ **Output boundary**: ALL file writes MUST target `.workflow/issues/issues.jsonl` or `.workflow/issues/discoveries/{SESSION_ID}/` only. NEVER modify source code or files outside these paths.
50
52
  </context>
51
53
 
54
+ <invariants>
55
+ 1. **Read-only analysis** — discovery agents MUST NOT modify source code; only `.workflow/issues/` is writable
56
+ 2. **Source tagging** — MUST set `source: "discover"` on every issues.jsonl row so concurrent writers (e.g. `manage-harvest`) can be distinguished and deduplicated
57
+ 3. **Dedup before write** — MUST check existing issues.jsonl for duplicates before appending new findings
58
+ 4. **Session traceability** — every discovery run MUST produce a session directory under `.workflow/issues/discoveries/` with full agent outputs
59
+ 5. **Schema compliance** — every issue row MUST conform to the canonical issue.json template schema
60
+ 6. **Idempotent re-run** — repeated execution with same scope and prompt MUST NOT create duplicate issues
61
+ </invariants>
62
+
52
63
  <execution>
53
64
  Determine mode from $ARGUMENTS:
54
65
  - No arguments or empty → interactive selection via ask_question
@@ -56,6 +67,23 @@ Determine mode from $ARGUMENTS:
56
67
  - First token is `by-prompt` → prompt-driven mode, remaining tokens are the user prompt
57
68
 
58
69
  Follow '~/.maestro/workflows/issue-discover.md' completely.
70
+
71
+ ### Phase Gates (MANDATORY, BLOCKING)
72
+
73
+ **GATE 1: Mode Selection → Analysis** (Steps 1-2 → Steps 3-8)
74
+ - REQUIRED: Mode correctly determined from arguments (multi-perspective or by-prompt).
75
+ - REQUIRED: `.workflow/issues/` directory exists (auto-create if missing).
76
+ - BLOCKED if E_NO_PROJECT (`.workflow/` missing) or E_EMPTY_PROMPT (by-prompt without text).
77
+
78
+ **GATE 2: Analysis → Issue Creation** (Steps 8-9 → Steps 10-11)
79
+ - REQUIRED: All perspectives analyzed (multi-perspective) or dimensions explored (by-prompt).
80
+ - REQUIRED: Findings deduplicated against existing issues.jsonl.
81
+ - BLOCKED if E_DISCOVERY_FAILED (all agents returned no results).
82
+
83
+ **GATE 3: Issue Creation → Completion** (Steps 11-12)
84
+ - REQUIRED: Issues appended to issues.jsonl with correct schema and `source: "discover"`.
85
+ - REQUIRED: Discovery session directory created with full agent outputs.
86
+ - BLOCKED if schema validation fails on any issue record.
59
87
  </execution>
60
88
 
61
89
  <error_codes>
@@ -40,6 +40,8 @@ $ARGUMENTS -- optional flags.
40
40
 
41
41
  **Output:** `.workflow/kg/extractors.yaml` — declarative rules for PluginEngine.
42
42
 
43
+ **Output boundary**: ALL file writes MUST target `.workflow/kg/extractors.yaml` only. NEVER modify source code or files outside this path. `--scan-only` MUST NOT write any files.
44
+
43
45
  **Rule format:**
44
46
  ```yaml
45
47
  version: 1
@@ -68,6 +70,16 @@ plugins:
68
70
 
69
71
  <execution>
70
72
 
73
+ <invariants>
74
+ 1. **Read-only source code** — agents MUST only read source files for pattern discovery; NEVER modify source code
75
+ 2. **Scan-only safety** — `--scan-only` MUST stop after Phase 2 summary; NEVER write extractors.yaml
76
+ 3. **Append preservation** — `--append` MUST preserve existing rules in extractors.yaml; default (overwrite) MUST warn (W003) if file exists
77
+ 4. **Min-count threshold** — patterns with fewer occurrences than `--min-count` MUST be excluded unless explicitly overridden
78
+ 5. **User confirmation** — each pattern group MUST be confirmed/edited/skipped by user before writing (Phase 3, Step 2)
79
+ 6. **Schema compliance** — generated extractors.yaml MUST conform to version 1 PluginEngine schema with required fields (id, languages, mode, rules)
80
+ 7. **Validation mandatory** — MUST run `maestro kg index` after writing to verify new symbols are extractable
81
+ </invariants>
82
+
71
83
  ### Phase 1: Discover patterns
72
84
 
73
85
  Spawn **3 parallel agents** to scan the codebase:
@@ -80,7 +92,21 @@ Spawn **3 parallel agents** to scan the codebase:
80
92
 
81
93
  Each agent returns: `[{pattern_type, regex_evidence, file_count, sample_matches: [{file, line, code}]}]`
82
94
 
83
- **Gate:** If all 3 agents return empty results → E002 (abort). If at least 1 agent succeeds, proceed with partial results (log W001 for failed agents).
95
+ ### Phase Gates (MANDATORY, BLOCKING)
96
+
97
+ **GATE 1: Discovery → Generation** (Phase 1 → Phase 2)
98
+ - REQUIRED: At least 1 of 3 agents returned valid pattern results.
99
+ - BLOCKED if all 3 agents return empty results (E002).
100
+
101
+ **GATE 2: Generation → Write** (Phase 2 → Phase 3)
102
+ - REQUIRED: At least 1 pattern meets `--min-count` threshold.
103
+ - REQUIRED: User confirmed pattern groups via ask_question.
104
+ - BLOCKED if `--scan-only` is set — stop after summary.
105
+
106
+ **GATE 3: Write → Validation** (Phase 3 → KG Index)
107
+ - REQUIRED: extractors.yaml written with valid schema.
108
+ - REQUIRED: `maestro kg index` executed to verify extraction.
109
+ - BLOCKED if schema validation fails on generated YAML.
84
110
 
85
111
  ### Phase 2: Generate rules
86
112
 
@@ -23,6 +23,8 @@ Arguments: $ARGUMENTS
23
23
 
24
24
  Dual store architecture (paths, formats, index) defined in workflow knowhow.md.
25
25
 
26
+ **Output boundary**: Workflow store writes MUST target `.workflow/knowhow/` only. System store writes MUST target `~/.claude/projects/*/memory/` only. NEVER modify source code or files outside these paths.
27
+
26
28
  **Subcommands:**
27
29
  - `list` — List entries from both stores (default if no arguments)
28
30
  - `search <query>` — Full-text search across both stores
@@ -43,8 +45,32 @@ Dual store architecture (paths, formats, index) defined in workflow knowhow.md.
43
45
 
44
46
  <execution>
45
47
  Follow '~/.maestro/workflows/knowhow.md' Part A (KnowHow Management) completely.
48
+
49
+ ### Phase Gates (MANDATORY, BLOCKING)
50
+
51
+ **GATE 1: Parse → Execute** (Subcommand routing)
52
+ - REQUIRED: Subcommand parsed from first token (list/search/view/edit/delete/prune).
53
+ - REQUIRED: Both store paths resolved (workflow + system).
54
+ - BLOCKED if E001 (no memory stores found) or invalid subcommand.
55
+
56
+ **GATE 2: Execute → Mutate** (For destructive subcommands: delete/prune/edit)
57
+ - REQUIRED: Target entry/file resolved and exists (E002 if not found).
58
+ - REQUIRED: MEMORY.md protected from deletion (E004 — use `edit` instead).
59
+ - REQUIRED: For `prune`: at least one filter provided (E003).
60
+ - REQUIRED: User confirmation before delete/prune unless `--confirm` flag set.
61
+ - BLOCKED if target unresolvable or confirmation denied.
46
62
  </execution>
47
63
 
64
+ <invariants>
65
+ 1. **MEMORY.md protected** — NEVER delete MEMORY.md; only editable via `edit` subcommand
66
+ 2. **MEMORY.md line limit** — MUST warn (W003) when MEMORY.md exceeds 200 lines; content beyond 200 lines will be truncated at load
67
+ 3. **Confirmation on destructive ops** — `delete` and `prune` MUST require user confirmation unless `--confirm` flag is set
68
+ 4. **Store isolation** — `prune` operates on workflow store only; NEVER prune system memory files
69
+ 5. **Reference integrity** — `delete` MUST check for references from other entries before removing; warn if orphaned references would result
70
+ 6. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview destructive operations only
71
+ 7. **Index consistency** — after delete/prune, workflow index MUST be updated to reflect removals
72
+ </invariants>
73
+
48
74
  <error_codes>
49
75
  | Code | Severity | Description | Stage |
50
76
  |------|----------|-------------|-------|
@@ -43,11 +43,35 @@ $ARGUMENTS — type token + description + optional flags.
43
43
  | No args | — | — | ask_question (10 options) |
44
44
 
45
45
  **Output**: `.workflow/knowhow/{PREFIX}-{YYYYMMDD}-{slug}.md` with YAML frontmatter (title, description, type, category, created, tags, source, lang, status)
46
+
47
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` only. NEVER modify source code or files outside this path.
46
48
  </context>
47
49
 
50
+ <invariants>
51
+ 1. **Description required** — every entry MUST have a `description` field in frontmatter (under 120 chars) for search indexing
52
+ 2. **Tags language match** — tags MUST match content language (Chinese content → Chinese tags, English → English)
53
+ 3. **ID uniqueness** — generated file names ({PREFIX}-{YYYYMMDD}-{slug}.md) MUST be unique; NEVER overwrite existing entries
54
+ 4. **Frontmatter completeness** — YAML frontmatter MUST include: title, description, type, category, created, tags, status
55
+ 5. **Type-specific validation** — each type MUST populate all its required fields before writing (template needs code block, recipe needs steps, etc.)
56
+ 6. **Idempotent naming** — same content captured twice MUST produce same slug, enabling dedup detection
57
+ </invariants>
58
+
48
59
  <execution>
49
60
  Follow '~/.maestro/workflows/knowhow.md' completely.
50
61
 
62
+ ### Phase Gates (MANDATORY, BLOCKING)
63
+
64
+ **GATE 1: Type Detection → Content Collection** (Type routing → Content extraction)
65
+ - REQUIRED: Type detected from first token or selected via ask_question.
66
+ - REQUIRED: Type maps to a valid prefix (KNW-/TPL-/RCP-/REF-/DCS-/TIP-/AST-/BLP-/DOC-/INS-).
67
+ - BLOCKED if type unresolvable after interactive prompt.
68
+
69
+ **GATE 2: Content Collection → Write** (Content extraction → File write)
70
+ - REQUIRED: All type-specific required fields populated (e.g., template needs code block, recipe needs steps).
71
+ - REQUIRED: `description` field generated or provided (under 120 chars).
72
+ - REQUIRED: Tags generated in correct language matching content.
73
+ - BLOCKED if required fields missing after user prompt (E002/E003).
74
+
51
75
  **Description rule**: Every entry MUST have a `description` field in frontmatter — a one-line summary (under 120 chars) for search results. WikiIndexer uses priority chain: `description > content[:240]`. Use `--description` flag value if provided; otherwise auto-generate from content.
52
76
 
53
77
  **Tags language rule**: Tags must match content language. Chinese content → Chinese tags (如 `认证,令牌,刷新`). English content → English tags. Mixed → bilingual.
@@ -37,8 +37,21 @@ Arguments: $ARGUMENTS
37
37
  **互斥规则:** `--interactive`、`--mark`、`--delete`、`--purge` 四选一,同时传入多个 → E006。
38
38
 
39
39
  Flag 全集、scope 对应的扫描路径、Stage 步骤、检测算法定义在 workflow knowledge-audit.md。
40
+
41
+ **Output boundary**: ALL file writes MUST target `.workflow/specs/`, `.workflow/knowhow/`, `.workflow/.trash/knowledge-audit-{timestamp}/`, `.workflow/issues/`, or audit report files (`audit-report-*.md`, `audit-log.jsonl`). NEVER modify source code files.
40
42
  </context>
41
43
 
44
+ <invariants>
45
+ 1. **Code-as-Truth** — 代码是唯一真理源;spec/knowhow 声明 MUST 与代码实际行为一致;每个 finding 的 evidence MUST 包含代码引用(文件:行号)
46
+ 2. **Backup before mutate** — MUST create backup tarball in `.workflow/.trash/` before any file modification (E005 if backup fails)
47
+ 3. **Deprecate over delete** — 文本存储首选 `status="deprecated"` 保留历史;NEVER 物理删除 spec/knowhow 文件
48
+ 4. **Purge 仅 artifact** — `--purge` MUST NOT 作用于 spec/knowhow scope (E004)
49
+ 5. **Rescue before delete** — 未 harvest 的 artifact 删除前 MUST 强制提示先跑 `/manage-harvest` (W002)
50
+ 6. **Conflict marker sync** — deprecate/delete 执行时如果目标条目有 conflict-marker,MUST 同步调用 `maestro spec conflict clear` 清除标记
51
+ 7. **Mutual exclusion** — `--interactive`/`--mark`/`--delete`/`--purge` 四选一;同时传入多个 MUST trigger E006
52
+ 8. **Dry-run safety** — `--dry-run` MUST NOT write any files; `--purge` 与 `--dry-run` 互斥 (E003)
53
+ </invariants>
54
+
42
55
  <execution>
43
56
  Follow `~/.maestro/workflows/knowledge-audit.md` Stages 1-8 in order.
44
57
 
@@ -23,12 +23,34 @@ $ARGUMENTS (no arguments required)
23
23
  - `.workflow/roadmap.md` -- milestone and phase structure
24
24
  - `.workflow/scratch/*/plan.json` -- plan metadata (via artifact registry paths)
25
25
  - `.workflow/scratch/*/.task/TASK-*.json` -- individual task statuses
26
+
27
+ **Output boundary**: Read-only command. MUST NOT write any files. All output is displayed to the user via text.
26
28
  </context>
27
29
 
30
+ <invariants>
31
+ 1. **Read-only** — MUST NOT write or modify any files; this is a pure display command
32
+ 2. **Graceful degradation** — missing roadmap.md, plan.json, or task files MUST NOT cause failure; display available data and note missing sections
33
+ 3. **State accuracy** — progress percentages MUST be calculated from actual task statuses, NEVER estimated or inferred
34
+ 4. **Wiki health optional** — wiki health score display MUST degrade gracefully if wiki is unavailable
35
+ 5. **Complete dashboard** — MUST include: milestone progress, phase status, task counts, active work, and next-step suggestions
36
+ </invariants>
37
+
28
38
  <execution>
29
39
  Follow '~/.maestro/workflows/status.md' completely.
30
40
 
31
41
  Next-step decision table defined in workflow status.md Step 5.
42
+
43
+ ### Phase Gates (MANDATORY, BLOCKING)
44
+
45
+ **GATE 1: Load → Render** (State loading → Dashboard display)
46
+ - REQUIRED: `.workflow/` exists and `state.json` is readable (E001/E002 if not).
47
+ - REQUIRED: Project state loaded with milestone and artifact registry.
48
+ - BLOCKED if state.json missing or corrupt (E002).
49
+
50
+ **GATE 2: Render → Route** (Dashboard → Next-step suggestions)
51
+ - REQUIRED: Per-phase progress calculated from actual task statuses.
52
+ - REQUIRED: Dashboard rendered with progress bars and status table.
53
+ - BLOCKED if state parsing fails entirely.
32
54
  </execution>
33
55
 
34
56
  <error_codes>
@@ -42,13 +42,41 @@ $ARGUMENTS — subcommand and optional flags.
42
42
  - `--format brief|full` — (digest) Output format
43
43
  - `--recent N` — (digest) Scope to N most recent entries
44
44
  - `--create-issues` — (digest) Create issues for identified knowledge gaps
45
+
46
+ **Output boundary**: File writes MUST target `.workflow/wiki/`, `.workflow/knowhow/`, or `.workflow/issues/issues.jsonl` (when `--create-issues`) only. NEVER modify source code or files outside these paths. `--dry-run` overrides `--fix` — no writes when both are set.
45
47
  </context>
46
48
 
49
+ <invariants>
50
+ 1. **Dry-run precedence** — `--dry-run` MUST override `--fix` when both are passed; preview only, no writes
51
+ 2. **Read-only by default** — without `--fix` or `--create-issues`, all subcommands MUST be read-only
52
+ 3. **Confirmation on fixes** — `--fix` MUST show preview of changes before applying; auto-apply only when explicitly set
53
+ 4. **Graph integrity** — `connect` MUST NOT create circular link chains; validate graph acyclicity for parent-child relationships
54
+ 5. **Threshold enforcement** — `--min-similarity` MUST be respected; NEVER suggest connections below the threshold
55
+ 6. **Subcommand isolation** — each subcommand routes to its own workflow file; NEVER cross-execute subcommand logic
56
+ </invariants>
57
+
47
58
  <execution>
48
59
  **Subcommand routing:**
49
60
  - `health|search|cleanup|stats` → Follow `~/.maestro/workflows/wiki-manage.md` completely.
50
61
  - `connect` → Follow `~/.maestro/workflows/wiki-connect.md` completely (Stages 1-6).
51
62
  - `digest` → Follow `~/.maestro/workflows/wiki-digest.md` completely (Stages 1-8).
63
+
64
+ ### Phase Gates (MANDATORY, BLOCKING)
65
+
66
+ **GATE 1: Parse → Load** (Subcommand routing → Wiki data loading)
67
+ - REQUIRED: Subcommand parsed and validated (health/search/cleanup/stats/connect/digest).
68
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
69
+ - BLOCKED if E003 (invalid subcommand) or E001.
70
+
71
+ **GATE 2: Load → Execute** (Wiki data → Subcommand execution)
72
+ - REQUIRED: Wiki data loaded via `maestro wiki` CLI.
73
+ - REQUIRED: At least one wiki entry exists (E002 if none).
74
+ - BLOCKED if wiki data loading fails entirely.
75
+
76
+ **GATE 3: Execute → Write** (For mutating operations: cleanup --fix, connect --fix, digest --create-issues)
77
+ - REQUIRED: Preview of changes shown to user.
78
+ - REQUIRED: `--dry-run` NOT set (overrides `--fix`).
79
+ - BLOCKED if preview generation fails or user declines.
52
80
  </execution>
53
81
 
54
82
  <error_codes>