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
@@ -1,295 +1,431 @@
1
- ---
2
- name: odyssey-improve
3
- description: Long-running codebase improvement cycle — multi-dimensional audit, deep diagnosis, targeted fix, verify, generalize, and engineering knowledge persistence
4
- argument-hint: "<target> [--dimensions <list>] [--fix-threshold <severity>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c] [--heartbeat]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - Bash
10
- - Glob
11
- - Grep
12
- - Agent
13
- - AskUserQuestion
14
- ---
15
- <base>@~/.maestro/workflows/odyssey-base.md</base>
16
-
17
- <purpose>
18
- survey → 6-dimension audit → diagnose → fix → verify → generalize → discover → persist.
19
- Exhaustive iteration until zero remaining actionable findings.
20
- </purpose>
21
-
22
- <boundary>
23
- **In scope:** Runtime quality improvement — performance/security/architecture/reliability/observability/maintainability audit → diagnose → fix → generalize.
24
- **Out of scope:** UI visual → `/odyssey-ui` | New features → `/odyssey-planex` | Single bug → `/odyssey-debug` | Style review → `/odyssey-review-test-fix`
25
- **Exploration freedom:** Free exploration within boundary — profiling, security scanning, architecture analysis, dependency audit.
26
- **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" is not allowed. "Pre-existing issue" is not a valid skip reason.
27
- </boundary>
28
-
29
- <context>
30
- $ARGUMENTS
31
-
32
- **Target resolution:**
33
- | Input | Resolution |
34
- |-------|-----------|
35
- | Module/dir path | Audit that module |
36
- | `HEAD` / `staged` | Review changes in diff |
37
- | Feature area keyword | Resolve to related files |
38
- | `--all` | Full project scan (use with caution) |
39
-
40
- **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` fix cutoff (default: all) | `--skip-fix` audit+diagnose only | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
41
-
42
- **Dimensions (6):**
43
- 1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
44
- 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
45
- 3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
46
- 4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
47
- 5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
48
- 6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
49
-
50
- **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
51
- **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
52
-
53
- **session.json improve-specific fields:**
54
- ```json
55
- { "target": "", "dimensions": [], "baseline_metrics": {},
56
- "audit_result": {}, "diagnoses": [], "confirmation": null,
57
- "generalization_stats": null }
58
- ```
59
-
60
- **evidence.ndjson phases:** `survey|audit|diagnosis|fix|discovery|decision|self-iteration`
61
- - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
62
- - `audit`: `dimension`, `severity`, `measurement`
63
- - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
64
- - `fix`: `finding_ref`, `change_summary`, `risk`
65
- - `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
66
- - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
67
- - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
68
-
69
- **phase_goals[]:**
70
-
71
- | ID | Goal | Phase | skip_when |
72
- |----|------|-------|-----------|
73
- | G1 | Survey completed | S_SURVEY | |
74
- | G2 | Audit completed | S_AUDIT | — |
75
- | G3 | Diagnosis completed | S_DIAGNOSE | — |
76
- | G4 | Zero remaining: all findings fixed and verified | S_VERIFY | skip_fix |
77
- | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
78
- | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
79
- | G7 | Learnings persisted | S_RECORD | |
80
-
81
- **understanding.md9 sections:**
82
- 1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
83
- 4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
84
- 6. GeneralizationS_GENERALIZE | 7. DiscoveriesS_DISCOVER
85
- 8. Improvement MetricsS_RECORD (before/after) | 9. Engineering LearningsS_RECORD
86
-
87
- **Knowledge Persistence categories (§9):**
88
-
89
- | Category | Content | Follow-up |
90
- |----------|---------|-----------|
91
- | Performance pattern | Bottleneck type + fix approach + measurement method | `/spec-add coding` |
92
- | Security rule | Vulnerability class + fix + prevention method | `/spec-add debug` |
93
- | Architecture constraint | Violation description + correct boundary + check method | `/spec-add arch` |
94
- | Reliability pattern | Failure mode + handling strategy + verification method | `/spec-add coding` |
95
- </context>
96
-
97
- <invariants>
98
- All invariants (evidence append-only, session-as-state, phase goal tracking, auto-commit, zero-residual) defined in base.
99
- </invariants>
100
-
101
- <self_iteration>
102
- Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
103
- </self_iteration>
104
-
105
- <state_machine>
106
-
107
- <states>
108
- S_INTAKE → S_SURVEY → S_AUDIT → S_DIAGNOSE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
109
- </states>
110
-
111
- <transitions>
112
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME
113
- S_INTAKE → S_SURVEY : target resolved A_INTAKE
114
- S_INTAKE → S_INTAKE : no target AskUserQuestion
115
-
116
- S_SURVEY → S_AUDIT : complete
117
-
118
- S_AUDIT → S_DIAGNOSE : critical/high findings exist
119
- S_AUDIT → S_GENERALIZE : no critical/high, !skip_generalize
120
- S_AUDIT → S_RECORD : no findings OR skip_generalize
121
-
122
- S_DIAGNOSE → S_FIX : root causes identified, !skip_fix
123
- S_DIAGNOSE → S_GENERALIZE : root causes identified, skip_fix, !skip_generalize
124
- S_DIAGNOSE → S_RECORD : root causes identified, skip_fix, skip_generalize
125
- S_DIAGNOSE → S_DIAGNOSE : hypotheses failed, retries < 3 A_ESCALATE_DIAGNOSIS
126
- S_DIAGNOSE S_RECORD : retries >= 3 INCONCLUSIVE
127
-
128
- S_FIX → S_VERIFY : fix implemented
129
-
130
- S_VERIFY → S_GENERALIZE : verified, !skip_generalize
131
- S_VERIFY S_RECORD : verified, skip_generalize
132
- S_VERIFY → S_FIX : needs_rework
133
-
134
- S_GENERALIZES_DISCOVER : hits found
135
- S_GENERALIZE → S_RECORD : no hits
136
-
137
- S_DISCOVER → S_DIAGNOSE : new critical issue → cross_phase_loops++
138
- S_DISCOVER → S_FIX : same-pattern fix, !skip_fix cross_phase_loops++
139
- S_DISCOVER → S_RECORD : remaining_actionable == 0
140
- S_DISCOVER → S_RECORD : loops >= max_loops MUST log per-item reasons
141
-
142
- S_RECORD → END : complete
143
- </transitions>
144
-
145
- <actions>
146
-
147
- ### A_INTAKE
148
- 1. Parse arguments: target description, flags, `--dimensions` subset
149
- 2. Generate slug, create `SESSION_DIR`
150
- 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
151
- 4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
152
- 5. Derive `phase_goals[]` from flags
153
- 6. Write `session.json` + `understanding.md` §1, emit Goal Prompt
154
-
155
- Commit: `"odyssey-improve({slug}): INTAKE — parse target and capture baseline"`
156
-
157
- ### A_RESUME
158
- Glob latest session → read `session.json` → display summary → jump to `current_state`.
159
-
160
- ### A_SURVEY
161
- Current state survey — understand what exists before proposing changes.
162
-
163
- 1. Dependency audit (package.json/lock), complexity scan (size/nesting), test coverage map, error handling scan (empty catch, unhandled promise)
164
- 2. **CLI-assisted** (optional): `maestro delegate --role analyze --mode analysis` for dependency health, complexity hotspots, coverage gaps, error patterns. Execute `run_in_background: true`.
165
- 3. Evidence phase=survey. Update §2. Mark G1.
166
-
167
- Commit: `"odyssey-improve({slug}): SURVEY — current state analysis"`
168
-
169
- ### A_AUDIT
170
- Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset).
171
- Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
172
-
173
- Mergeevidence phase=audit. Write `session.json.audit_result`.
174
- Update §3 (findings by dimension + severity matrix). Mark G2.
175
-
176
- Commit: `"odyssey-improve({slug}): AUDIT multi-dimension review"`
177
-
178
- ### A_DIAGNOSE
179
- Root cause analysis for critical/high findings — don't fix symptoms.
180
-
181
- 1. Group by dimension, prioritize by severity. For each: hypothesis → trace code path + git history → evidence phase=diagnosis
182
- 2. Ambiguity evidence phase=decision; Normal: AskUserQuestion | `-y`: defer
183
- 3. CLI-assisted for complex findings: `maestro delegate --role analyze --mode analysis` (`run_in_background: true`)
184
- 4. Write `session.json.diagnoses[]`. Update §4. Mark G3.
185
-
186
- Commit: `"odyssey-improve({slug}): DIAGNOSE root cause analysis"`
187
-
188
- ### A_ESCALATE_DIAGNOSIS
189
- `retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, S_DIAGNOSE. >= 3: Normal AskUserQuestion | `-y` → INCONCLUSIVE → S_RECORD.
190
-
191
- ### A_FIX
192
- 1. Exhaustive fix: ALL diagnosed issues by severity tier (critical → high → medium → low within fix_threshold), one dimension at a time. After each tier, re-verify **current tier's dimension only** (not all dimensions) — new findings at same or higher severity append to current tier. Cross-dimension regression checks run once at S_VERIFY after all tiers complete.
193
- 2. For each fix: implement → evidence phase=fix
194
- 3. Normal: AskUserQuestion per-fix confirmation | `-y`: auto-proceed, record `deferred`
195
-
196
- Commit: `"odyssey-improve({slug}): FIX — improvements applied"`
197
-
198
- ### A_VERIFY
199
- 1. Run tests covering modified areas
200
- 2. Re-capture metrics, compare with `session.json.baseline_metrics`
201
- 3. CLI-assisted: `maestro delegate --role review --mode analysis` (`run_in_background: true`)
202
- 4. `needs_rework` S_FIX. `verified` mark G4, advance.
203
- 5. Write `session.json.confirmation`. Update §5 (before/after metrics table).
204
-
205
- Commit: `"odyssey-improve({slug}): VERIFY — improvements verified"`
206
-
207
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
208
- Base shared_actions. Improve overrides:
209
- - **A_GENERALIZE** pattern source: diagnoses + fixes
210
- - **A_RECORD** §8: improvement metrics (before/after comparison from baseline_metrics vs current). §9: learnings per Knowledge Persistence table. Completion summary lists suggested `/spec-add` commands.
211
-
212
- **Completion summary:**
213
- ```
214
- --- IMPROVE ODYSSEY COMPLETE ---
215
- Target: {target}
216
- Dimensions: {dimensions}
217
- Findings: {critical}C / {high}H / {medium}M / {low}L
218
- Diagnosed: {count}
219
- Fixed: {count} ({verified} verified)
220
- Metrics: {improved} improved / {regressed} regressed
221
- Patterns: {count} ({by_layer})
222
- Scan hits: {total} ({cross_layer_confirmed} confirmed)
223
- Issues: {N} created
224
- Decisions: {N} resolved, {M} pending, {K} deferred
225
- Learnings: {N} persisted
226
- Self-iter: {N} rounds across {M} stages
227
- Cross-loops: {N}
228
- Goals: {done}/{total} ({skipped} skipped)
229
- ---
230
- ```
231
-
232
- </actions>
233
-
234
- <appendix>
235
-
236
- ### `-y` improve-specific points
237
-
238
- | Decision Point | Normal | `-y` |
239
- |---------------|--------|------|
240
- | A_FIX improvement confirmation | AskUserQuestion | auto-proceed, `deferred` |
241
- | A_DIAGNOSE ambiguity | AskUserQuestion | best-effort, `deferred` |
242
- | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
243
- | A_DISCOVER hit routing | AskUserQuestion | auto create issue |
244
- | A_DISCOVER ambiguous items | AskUserQuestion | all `deferred` |
245
-
246
- `deferred` items shown in completion summary; recoverable via `-c`.
247
-
248
- ### Goal Prompt convergence rules
249
-
250
- ```
251
- Exhaust iteration until all findings actioned (fix/issue/decision)
252
- and phase_goals_all_done=true.
253
- Fix by severity tiers, re-verify after each tier.
254
- Baseline captured before fix, compared after to confirm improvement.
255
- Pending decisions must AskUserQuestion — no silent resolve.
256
- ```
257
-
258
- </appendix>
259
-
260
- </state_machine>
261
-
262
- <error_codes>
263
- | Code | Severity | Condition | Recovery |
264
- |------|----------|-----------|----------|
265
- | E001 | error | No target specified | Provide target or use -c |
266
- | E002 | error | Target path not found | Check path |
267
- | W001 | warning | No dependency manifest found | Proceed without dep audit |
268
- | W002 | warning | Some dimension agents failed | Partial audit coverage |
269
- </error_codes>
270
-
271
- <success_criteria>
272
- - [ ] Target resolved, baseline metrics captured
273
- - [ ] Survey + 6-dimension audit with structured findings and severity matrix
274
- - [ ] Root causes diagnosed for critical/high findings
275
- - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
276
- - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
277
- - [ ] Every unfixed finding has individual classification and reason
278
- - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
279
- - [ ] phase_goals G1-G7 tracked and audited
280
- - [ ] Session resumable via -c
281
- - [ ] Completion summary
282
- </success_criteria>
283
-
284
- <next_step_routing>
285
- | Condition | Next |
286
- |-----------|------|
287
- | Security findings need deep investigation | `/odyssey-debug "<finding>"` |
288
- | UI-related findings | `/odyssey-ui "<component>"` |
289
- | Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
290
- | Architecture pattern to document | `/spec-add arch "..."` |
291
- | Performance pattern to persist | `/spec-add coding "..."` |
292
- | Formal review of changes | `/odyssey-review-test-fix <changed-files>` |
293
- | Pending decisions | Filter evidence phase=decision status=pending |
294
- </next_step_routing>
295
- </output>
1
+ ---
2
+ name: odyssey-improve
3
+ description: Long-running codebase improvement cycle — multi-dimensional audit, deep diagnosis, targeted fix, verify, generalize, and engineering knowledge persistence
4
+ argument-hint: "<target> [--dimensions <list>] [--fix-threshold <severity>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c] [--heartbeat]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
16
+
17
+ <purpose>
18
+ survey → 6-dimension audit → diagnose → fix → verify → generalize → discover → persist.
19
+ Exhaustive iteration until zero remaining actionable findings.
20
+ </purpose>
21
+
22
+ <boundary>
23
+ **In scope:** Runtime quality improvement — performance/security/architecture/reliability/observability/maintainability audit → diagnose → fix → generalize.
24
+ **Out of scope:** UI visual → `/odyssey-ui` | New features → `/odyssey-planex` | Single bug → `/odyssey-debug` | Style review → `/odyssey-review-test-fix`
25
+ **Exploration freedom:** Free exploration within boundary — profiling, security scanning, architecture analysis, dependency audit.
26
+ **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" is not allowed. "Pre-existing issue" is not a valid skip reason.
27
+ </boundary>
28
+
29
+ <context>
30
+ $ARGUMENTS
31
+
32
+ **Target resolution:**
33
+ | Input | Resolution |
34
+ |-------|-----------|
35
+ | Module/dir path | Audit that module |
36
+ | `HEAD` / `staged` | Review changes in diff |
37
+ | Feature area keyword | Resolve to related files |
38
+ | `--all` | Full project scan (use with caution) |
39
+
40
+ **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` fix cutoff (default: all) | `--skip-fix` audit+diagnose only | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
41
+
42
+ **Dimensions (6):**
43
+ 1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
44
+ 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
45
+ 3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
46
+ 4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
47
+ 5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
48
+ 6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
49
+
50
+ **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
51
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
52
+
53
+ **Output boundary**: ALL file writes MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write artifacts outside these paths.
54
+
55
+ **session.json improve-specific fields:**
56
+ ```json
57
+ { "target": "", "dimensions": [], "baseline_metrics": {},
58
+ "audit_result": {}, "diagnoses": [], "confirmation": null,
59
+ "generalization_stats": null }
60
+ ```
61
+
62
+ **evidence.ndjson phases:** `survey|audit|diagnosis|fix|discovery|decision|self-iteration`
63
+ - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
64
+ - `audit`: `dimension`, `severity`, `measurement`
65
+ - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
66
+ - `fix`: `finding_ref`, `change_summary`, `risk`
67
+ - `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
68
+ - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
69
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
70
+
71
+ **phase_goals[]:**
72
+
73
+ | ID | Goal | Phase | skip_when |
74
+ |----|------|-------|-----------|
75
+ | G1 | Survey completed | S_SURVEY | — |
76
+ | G2 | Audit completed | S_AUDIT | |
77
+ | G3 | Diagnosis completed | S_DIAGNOSE | |
78
+ | G4 | Zero remaining: all findings fixed and verified | S_VERIFY | skip_fix |
79
+ | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
80
+ | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
81
+ | G7 | Learnings persisted | S_RECORD | |
82
+
83
+ **understanding.md 9 sections:**
84
+ 1. Target & Baseline S_INTAKE | 2. Current State Survey S_SURVEY | 3. Audit Findings ← S_AUDIT
85
+ 4. Root Cause Diagnosis S_DIAGNOSE | 5. Fix & Verification S_FIX+S_VERIFY
86
+ 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER
87
+ 8. Improvement Metrics ← S_RECORD (before/after) | 9. Engineering Learnings ← S_RECORD
88
+
89
+ **Knowledge Persistence categories (§9):**
90
+
91
+ | Category | Content | Follow-up |
92
+ |----------|---------|-----------|
93
+ | Performance pattern | Bottleneck type + fix approach + measurement method | `/spec-add coding` |
94
+ | Security rule | Vulnerability class + fix + prevention method | `/spec-add debug` |
95
+ | Architecture constraint | Violation description + correct boundary + check method | `/spec-add arch` |
96
+ | Reliability pattern | Failure mode + handling strategy + verification method | `/spec-add coding` |
97
+ </context>
98
+
99
+ <invariants>
100
+ All invariants (evidence append-only, session-as-state, phase goal tracking, auto-commit, zero-residual) defined in base.
101
+ 6. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "All verified" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
102
+ </invariants>
103
+
104
+ <self_iteration>
105
+ Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
106
+ </self_iteration>
107
+
108
+ <execution>
109
+ Follow base execution discipline completely. Actions defined in state_machine below.
110
+
111
+ ### Phase Gates (MANDATORY, BLOCKING)
112
+
113
+ **GATE 1: INTAKESURVEY**
114
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized with baseline_metrics.
115
+ - REQUIRED: phase_goals[] derived from flags.
116
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
117
+
118
+ **GATE 2: SURVEY AUDIT**
119
+ - REQUIRED: Current state survey completed — dependency audit, complexity scan, test coverage map, error handling scan.
120
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
121
+ - BLOCKED if: survey incomplete — all 4 scan types must be attempted.
122
+
123
+ **GATE 3: AUDIT DIAGNOSE**
124
+ - REQUIRED: All dimension agents completed (or --dimensions subset), findings merged with severity classification.
125
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
126
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
127
+
128
+ **GATE 4: DIAGNOSE → FIX**
129
+ - REQUIRED: Root causes identified for all critical/high findings with evidence.
130
+ - REQUIRED: diagnoses[] written, understanding.md §4 updated, G3 marked done.
131
+ - BLOCKED if: hypotheses failed 3 times without escalation decision (A_ESCALATE_DIAGNOSIS).
132
+
133
+ **GATE 5: FIX → VERIFY**
134
+ - REQUIRED: ALL findings within fix_threshold fixed by severity tier (critical high medium → low).
135
+ - REQUIRED: Per-fix evidence phase=fix logged.
136
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
137
+
138
+ **GATE 6: VERIFYGENERALIZE**
139
+ - REQUIRED: Tests pass, metrics re-captured, before/after comparison logged.
140
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
141
+ - BLOCKED if: needs_rework → route back to S_FIX.
142
+
143
+ **GATE 7: GENERALIZE → DISCOVER**
144
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
145
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
146
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
147
+
148
+ **GATE 8: DISCOVER RECORD**
149
+ - REQUIRED: All hits triaged with per-item classification and reason.
150
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
151
+ - REQUIRED: G6 marked done.
152
+ - BLOCKED if: unclassified hits remain.
153
+
154
+ </execution>
155
+
156
+ <state_machine>
157
+
158
+ <states>
159
+ S_INTAKE → S_SURVEY → S_AUDIT → S_DIAGNOSE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
160
+ </states>
161
+
162
+ <transitions>
163
+ S_INTAKE S_INTAKE : -c + session found A_RESUME
164
+ S_INTAKE S_SURVEY : target resolved A_INTAKE
165
+ S_INTAKE S_INTAKE : no target AskUserQuestion
166
+
167
+ S_SURVEY → S_AUDIT : complete
168
+
169
+ S_AUDIT → S_DIAGNOSE : critical/high findings exist
170
+ S_AUDIT S_GENERALIZE : no critical/high, !skip_generalize
171
+ S_AUDIT → S_RECORD : no findings OR skip_generalize
172
+
173
+ S_DIAGNOSES_FIX : root causes identified, !skip_fix
174
+ S_DIAGNOSE S_GENERALIZE : root causes identified, skip_fix, !skip_generalize
175
+ S_DIAGNOSE → S_RECORD : root causes identified, skip_fix, skip_generalize
176
+ S_DIAGNOSE → S_DIAGNOSE : hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
177
+ S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
178
+
179
+ S_FIX → S_VERIFY : fix implemented
180
+
181
+ S_VERIFY S_GENERALIZE : verified, !skip_generalize
182
+ S_VERIFYS_RECORD : verified, skip_generalize
183
+ S_VERIFY S_FIX : needs_rework
184
+
185
+ S_GENERALIZE → S_DISCOVER : hits found
186
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
187
+
188
+ S_DISCOVER → S_DIAGNOSE : new critical issue → cross_phase_loops++
189
+ S_DISCOVER S_FIX : same-pattern fix, !skip_fixcross_phase_loops++
190
+ S_DISCOVER → S_RECORD : remaining_actionable == 0
191
+ S_DISCOVER → S_RECORD : loops >= max_loops → MUST log per-item reasons
192
+
193
+ S_RECORD → END : complete
194
+ </transitions>
195
+
196
+ <actions>
197
+
198
+ ### A_INTAKE
199
+ 1. Parse arguments: target description, flags, `--dimensions` subset
200
+ 2. Generate slug, create `SESSION_DIR`
201
+ 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
202
+ 4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
203
+ 5. Derive `phase_goals[]` from flags
204
+ 6. Write `session.json` + `understanding.md` §1, emit Goal Prompt
205
+
206
+ Commit: `"odyssey-improve({slug}): INTAKE — parse target and capture baseline"`
207
+
208
+ ### A_RESUME
209
+ Glob latest session read `session.json` → display summary → jump to `current_state`.
210
+
211
+ ### A_SURVEY
212
+ Current state survey — understand what exists before proposing changes.
213
+
214
+ 1. Dependency audit (package.json/lock), complexity scan (size/nesting), test coverage map, error handling scan (empty catch, unhandled promise)
215
+ 2. **CLI-assisted** (optional): `maestro delegate --role analyze --mode analysis` for dependency health, complexity hotspots, coverage gaps, error patterns. Execute `run_in_background: true`.
216
+ 3. Evidence phase=survey. Update §2. Mark G1.
217
+
218
+ Commit: `"odyssey-improve({slug}): SURVEY — current state analysis"`
219
+
220
+ ### A_AUDIT
221
+ Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset).
222
+ Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
223
+
224
+ Merge evidence phase=audit. Write `session.json.audit_result`.
225
+ Update §3 (findings by dimension + severity matrix). Mark G2.
226
+
227
+ Commit: `"odyssey-improve({slug}): AUDIT — multi-dimension review"`
228
+
229
+ ### A_DIAGNOSE
230
+ Root cause analysis for critical/high findings — don't fix symptoms.
231
+
232
+ 1. Group by dimension, prioritize by severity. For each: hypothesis → trace code path + git history → evidence phase=diagnosis
233
+ 2. Ambiguity → evidence phase=decision; Normal: AskUserQuestion | `-y`: defer
234
+ 3. CLI-assisted for complex findings: `maestro delegate --role analyze --mode analysis` (`run_in_background: true`)
235
+ 4. Write `session.json.diagnoses[]`. Update §4. Mark G3.
236
+
237
+ Commit: `"odyssey-improve({slug}): DIAGNOSE — root cause analysis"`
238
+
239
+ ### A_ESCALATE_DIAGNOSIS
240
+ `retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, → S_DIAGNOSE. >= 3: Normal → AskUserQuestion | `-y` → INCONCLUSIVE → S_RECORD.
241
+
242
+ ### A_FIX
243
+ 1. Exhaustive fix: ALL diagnosed issues by severity tier (critical → high → medium → low within fix_threshold), one dimension at a time. After each tier, re-verify **current tier's dimension only** (not all dimensions) — new findings at same or higher severity append to current tier. Cross-dimension regression checks run once at S_VERIFY after all tiers complete.
244
+ 2. For each fix: implement evidence phase=fix
245
+ 3. Normal: AskUserQuestion per-fix confirmation | `-y`: auto-proceed, record `deferred`
246
+
247
+ Commit: `"odyssey-improve({slug}): FIX — improvements applied"`
248
+
249
+ ### A_VERIFY
250
+ 1. Run tests covering modified areas
251
+ 2. Re-capture metrics, compare with `session.json.baseline_metrics`
252
+ 3. CLI-assisted: `maestro delegate --role review --mode analysis` (`run_in_background: true`)
253
+ 4. `needs_rework` S_FIX. `verified` mark G4, advance.
254
+ 5. Write `session.json.confirmation`. Update §5 (before/after metrics table).
255
+
256
+ Commit: `"odyssey-improve({slug}): VERIFY — improvements verified"`
257
+
258
+ ### A_GENERALIZE
259
+
260
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "all verified," or context pressure are NOT valid skip reasons.**
261
+
262
+ Pattern source: diagnosed root causes + applied fixes across all dimensions.
263
+
264
+ **Step 1 — 3-layer pattern extraction** from diagnoses and fixes:
265
+
266
+ | Layer | Method | Targets |
267
+ |-------|--------|---------|
268
+ | Syntax | Build regex from fix diffs Grep | N+1 query patterns, missing error type check, unescaped interpolation, inline eval |
269
+ | Semantic | Understand anti-pattern per dimension → Agent scan | Cache bypass in hot path, auth check gap, circular import chain, missing timeout |
270
+ | Structural | Find modules with same shape / dependency graph | Controllers sharing validation shape, middleware with same hook pattern, parallel services |
271
+
272
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
273
+
274
+ **Thoroughness floor:** ALL 3 layers must be attempted and logged. Each layer records search method, scope, hit count in evidence phase=generalization. "No hits" requires all 3 layers to return 0 with logged evidence.
275
+
276
+ **Step 2 4-agent concurrent scan** (single message, 4 Agents):
277
+
278
+ | Agent | Strategy | Scope |
279
+ |-------|----------|-------|
280
+ | Syntax grep | Grep regex from pattern signatures | Full project |
281
+ | Semantic scan | Per-dimension anti-pattern check | Related modules |
282
+ | Structural match | Find structurally similar files | Full project |
283
+ | Historical grep | `git log -S` for pattern signatures | Git history |
284
+
285
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
286
+
287
+ **Step 4 Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
288
+
289
+ **Step 5 Persist:** Update understanding.md §6 + write `session.json.generalization_stats`:
290
+ ```json
291
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
292
+ ```
293
+
294
+ **Transition guard:** `S_GENERALIZE → S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G5 done.
295
+
296
+ Commit: `"odyssey-improve({slug}): GENERALIZE — generalization scan complete"`
297
+
298
+ ### A_DISCOVER
299
+
300
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
301
+
302
+ 1. **Triage** each hit with ±10 lines context → classify:
303
+ - `bug` — confirmed improvement defect (same dimension)
304
+ - `risk` — potential degradation or violation
305
+ - `safe` — false positive (must log individual reason — blanket "pre-existing" forbidden)
306
+
307
+ 2. **Route:**
308
+
309
+ | Classification | Action |
310
+ |---------------|--------|
311
+ | bug + fix_template applicable | Immediate fix → back to S_FIX |
312
+ | bug + cross-module decision or no template | Create issue (fix suggestion + impact + dimension) |
313
+ | risk + guard addable directly | Fix directly |
314
+ | risk + complex | Create issue |
315
+ | safe | Skip with logged per-item reason |
316
+
317
+ Normal: AskUserQuestion per hit | `-y`: auto-fix bugs with fix_template, create issue for rest
318
+
319
+ 3. **Cross-phase loops:** `cross_phase_loops++` on fix/diagnose return. `loops >= max_loops` → must log per-item reasons.
320
+
321
+ 4. Append evidence phase=discovery. Update understanding.md §7. Mark G6 done.
322
+
323
+ Commit: `"odyssey-improve({slug}): DISCOVER — discovery triage complete"`
324
+
325
+ ### A_RECORD
326
+
327
+ 1. understanding.md §8: improvement metrics — before/after comparison from `baseline_metrics` vs current. Re-capture metrics, build comparison table.
328
+ 2. understanding.md §9: learnings by Knowledge Persistence categories:
329
+ - Performance pattern → `/spec-add coding`
330
+ - Security rule → `/spec-add debug`
331
+ - Architecture constraint → `/spec-add arch`
332
+ - Reliability pattern → `/spec-add coding`
333
+ Completion summary lists suggested `/spec-add` commands.
334
+
335
+ 3. Mark G7 done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count).
336
+
337
+ 4. **Goal audit (hardened):**
338
+ - `done` → confirmed
339
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
340
+ - **Hard rule:** G5 and G6 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: AskUserQuestion | `-y`: record `failed`)
341
+ - `phase_goals_all_done = true` only when all goals pass this audit
342
+
343
+ 5. `current_state = "COMPLETED"`, emit completion summary.
344
+
345
+ **Completion summary:**
346
+ ```
347
+ --- IMPROVE ODYSSEY COMPLETE ---
348
+ Target: {target}
349
+ Dimensions: {dimensions}
350
+ Findings: {critical}C / {high}H / {medium}M / {low}L
351
+ Diagnosed: {count}
352
+ Fixed: {count} ({verified} verified)
353
+ Metrics: {improved} improved / {regressed} regressed
354
+ Patterns: {count} ({by_layer})
355
+ Scan hits: {total} ({cross_layer_confirmed} confirmed)
356
+ Issues: {N} created
357
+ Decisions: {N} resolved, {M} pending, {K} deferred
358
+ Learnings: {N} persisted
359
+ Self-iter: {N} rounds across {M} stages
360
+ Cross-loops: {N}
361
+ Goals: {done}/{total} ({skipped} skipped)
362
+ ---
363
+ ```
364
+
365
+ Commit: `"odyssey-improve({slug}): RECORD — summary and knowledge persistence"`
366
+
367
+ </actions>
368
+
369
+ <appendix>
370
+
371
+ ### `-y` improve-specific points
372
+
373
+ | Decision Point | Normal | `-y` |
374
+ |---------------|--------|------|
375
+ | A_FIX improvement confirmation | AskUserQuestion | auto-proceed, `deferred` |
376
+ | A_DIAGNOSE ambiguity | AskUserQuestion | best-effort, `deferred` |
377
+ | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
378
+ | A_DISCOVER hit routing | AskUserQuestion | auto create issue |
379
+ | A_DISCOVER ambiguous items | AskUserQuestion | all `deferred` |
380
+
381
+ `deferred` items shown in completion summary; recoverable via `-c`.
382
+
383
+ ### Goal Prompt convergence rules
384
+
385
+ ```
386
+ Exhaust iteration until all findings actioned (fix/issue/decision)
387
+ and phase_goals_all_done=true.
388
+ Fix by severity tiers, re-verify after each tier.
389
+ Baseline captured before fix, compared after to confirm improvement.
390
+ Pending decisions must AskUserQuestion — no silent resolve.
391
+ ```
392
+
393
+ </appendix>
394
+
395
+ </state_machine>
396
+
397
+ <error_codes>
398
+ | Code | Severity | Condition | Recovery |
399
+ |------|----------|-----------|----------|
400
+ | E001 | error | No target specified | Provide target or use -c |
401
+ | E002 | error | Target path not found | Check path |
402
+ | W001 | warning | No dependency manifest found | Proceed without dep audit |
403
+ | W002 | warning | Some dimension agents failed | Partial audit coverage |
404
+ | W003 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
405
+ </error_codes>
406
+
407
+ <success_criteria>
408
+ - [ ] Target resolved, baseline metrics captured
409
+ - [ ] Survey + 6-dimension audit with structured findings and severity matrix
410
+ - [ ] Root causes diagnosed for critical/high findings
411
+ - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
412
+ - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
413
+ - [ ] Every unfixed finding has individual classification and reason
414
+ - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
415
+ - [ ] phase_goals G1-G7 tracked and audited
416
+ - [ ] Session resumable via -c
417
+ - [ ] Completion summary
418
+ </success_criteria>
419
+
420
+ <next_step_routing>
421
+ | Condition | Next |
422
+ |-----------|------|
423
+ | Security findings need deep investigation | `/odyssey-debug "<finding>"` |
424
+ | UI-related findings | `/odyssey-ui "<component>"` |
425
+ | Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
426
+ | Architecture pattern to document | `/spec-add arch "..."` |
427
+ | Performance pattern to persist | `/spec-add coding "..."` |
428
+ | Formal review of changes | `/odyssey-review-test-fix <changed-files>` |
429
+ | Pending decisions | Filter evidence phase=decision status=pending |
430
+ </next_step_routing>
431
+ </output>