maestro-flow 0.5.46 → 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 (237) hide show
  1. package/.agents/skills/domain-add/SKILL.md +9 -0
  2. package/.agents/skills/learn-decompose/SKILL.md +12 -0
  3. package/.agents/skills/learn-follow/SKILL.md +41 -0
  4. package/.agents/skills/learn-investigate/SKILL.md +14 -0
  5. package/.agents/skills/learn-second-opinion/SKILL.md +14 -0
  6. package/.agents/skills/maestro-amend/SKILL.md +11 -0
  7. package/.agents/skills/maestro-companion/SKILL.md +11 -0
  8. package/.agents/skills/maestro-composer/SKILL.md +11 -0
  9. package/.agents/skills/maestro-guard/SKILL.md +25 -0
  10. package/.agents/skills/maestro-init/SKILL.md +28 -0
  11. package/.agents/skills/maestro-overlay/SKILL.md +11 -0
  12. package/.agents/skills/maestro-player/SKILL.md +11 -0
  13. package/.agents/skills/maestro-quick/SKILL.md +29 -0
  14. package/.agents/skills/maestro-swarm-workflow/SKILL.md +25 -0
  15. package/.agents/skills/maestro-tools-execute/SKILL.md +29 -0
  16. package/.agents/skills/maestro-tools-register/SKILL.md +29 -0
  17. package/.agents/skills/maestro-ui-codify/SKILL.md +11 -0
  18. package/.agents/skills/maestro-universal-workflow/SKILL.md +59 -0
  19. package/.agents/skills/maestro-update/SKILL.md +38 -0
  20. package/.agents/skills/manage-codebase-rebuild/SKILL.md +29 -0
  21. package/.agents/skills/manage-drift-realign/SKILL.md +12 -0
  22. package/.agents/skills/manage-harvest/SKILL.md +30 -6
  23. package/.agents/skills/manage-issue/SKILL.md +23 -0
  24. package/.agents/skills/manage-issue-discover/SKILL.md +28 -0
  25. package/.agents/skills/manage-kg-extractors/SKILL.md +27 -1
  26. package/.agents/skills/manage-knowhow/SKILL.md +26 -0
  27. package/.agents/skills/manage-knowhow-capture/SKILL.md +24 -0
  28. package/.agents/skills/manage-knowledge-audit/SKILL.md +13 -0
  29. package/.agents/skills/manage-status/SKILL.md +22 -0
  30. package/.agents/skills/manage-wiki/SKILL.md +28 -0
  31. package/.agents/skills/odyssey-improve/SKILL.md +50 -0
  32. package/.agents/skills/odyssey-planex/SKILL.md +46 -0
  33. package/.agents/skills/odyssey-review-test-fix/SKILL.md +50 -0
  34. package/.agents/skills/odyssey-ui/SKILL.md +50 -0
  35. package/.agents/skills/quality-auto-test/SKILL.md +12 -0
  36. package/.agents/skills/quality-debug/SKILL.md +11 -0
  37. package/.agents/skills/quality-refactor/SKILL.md +11 -0
  38. package/.agents/skills/quality-retrospective/SKILL.md +11 -0
  39. package/.agents/skills/quality-review/SKILL.md +11 -0
  40. package/.agents/skills/quality-sync/SKILL.md +10 -0
  41. package/.agents/skills/quality-test/SKILL.md +12 -0
  42. package/.agents/skills/security-audit/SKILL.md +11 -0
  43. package/.agents/skills/spec-add/SKILL.md +27 -0
  44. package/.agents/skills/spec-load/SKILL.md +25 -0
  45. package/.agents/skills/spec-remove/SKILL.md +26 -0
  46. package/.agents/skills/spec-setup/SKILL.md +30 -0
  47. package/.agy/skills/domain-add/SKILL.md +9 -0
  48. package/.agy/skills/learn-decompose/SKILL.md +12 -0
  49. package/.agy/skills/learn-follow/SKILL.md +41 -0
  50. package/.agy/skills/learn-investigate/SKILL.md +14 -0
  51. package/.agy/skills/learn-second-opinion/SKILL.md +14 -0
  52. package/.agy/skills/maestro-amend/SKILL.md +11 -0
  53. package/.agy/skills/maestro-companion/SKILL.md +11 -0
  54. package/.agy/skills/maestro-composer/SKILL.md +11 -0
  55. package/.agy/skills/maestro-guard/SKILL.md +25 -0
  56. package/.agy/skills/maestro-init/SKILL.md +28 -0
  57. package/.agy/skills/maestro-overlay/SKILL.md +11 -0
  58. package/.agy/skills/maestro-player/SKILL.md +11 -0
  59. package/.agy/skills/maestro-quick/SKILL.md +29 -0
  60. package/.agy/skills/maestro-swarm-workflow/SKILL.md +25 -0
  61. package/.agy/skills/maestro-tools-execute/SKILL.md +29 -0
  62. package/.agy/skills/maestro-tools-register/SKILL.md +29 -0
  63. package/.agy/skills/maestro-ui-codify/SKILL.md +11 -0
  64. package/.agy/skills/maestro-universal-workflow/SKILL.md +59 -0
  65. package/.agy/skills/maestro-update/SKILL.md +38 -0
  66. package/.agy/skills/manage-codebase-rebuild/SKILL.md +29 -0
  67. package/.agy/skills/manage-drift-realign/SKILL.md +12 -0
  68. package/.agy/skills/manage-harvest/SKILL.md +30 -6
  69. package/.agy/skills/manage-issue/SKILL.md +23 -0
  70. package/.agy/skills/manage-issue-discover/SKILL.md +28 -0
  71. package/.agy/skills/manage-kg-extractors/SKILL.md +27 -1
  72. package/.agy/skills/manage-knowhow/SKILL.md +26 -0
  73. package/.agy/skills/manage-knowhow-capture/SKILL.md +24 -0
  74. package/.agy/skills/manage-knowledge-audit/SKILL.md +13 -0
  75. package/.agy/skills/manage-status/SKILL.md +22 -0
  76. package/.agy/skills/manage-wiki/SKILL.md +28 -0
  77. package/.agy/skills/odyssey-improve/SKILL.md +50 -0
  78. package/.agy/skills/odyssey-planex/SKILL.md +46 -0
  79. package/.agy/skills/odyssey-review-test-fix/SKILL.md +50 -0
  80. package/.agy/skills/odyssey-ui/SKILL.md +50 -0
  81. package/.agy/skills/quality-auto-test/SKILL.md +12 -0
  82. package/.agy/skills/quality-debug/SKILL.md +11 -0
  83. package/.agy/skills/quality-refactor/SKILL.md +11 -0
  84. package/.agy/skills/quality-retrospective/SKILL.md +11 -0
  85. package/.agy/skills/quality-review/SKILL.md +11 -0
  86. package/.agy/skills/quality-sync/SKILL.md +10 -0
  87. package/.agy/skills/quality-test/SKILL.md +12 -0
  88. package/.agy/skills/security-audit/SKILL.md +11 -0
  89. package/.agy/skills/spec-add/SKILL.md +27 -0
  90. package/.agy/skills/spec-load/SKILL.md +25 -0
  91. package/.agy/skills/spec-remove/SKILL.md +26 -0
  92. package/.agy/skills/spec-setup/SKILL.md +30 -0
  93. package/.claude/commands/domain-add.md +9 -0
  94. package/.claude/commands/learn-decompose.md +12 -0
  95. package/.claude/commands/learn-follow.md +41 -0
  96. package/.claude/commands/learn-investigate.md +14 -0
  97. package/.claude/commands/learn-second-opinion.md +14 -0
  98. package/.claude/commands/maestro-amend.md +11 -0
  99. package/.claude/commands/maestro-companion.md +11 -0
  100. package/.claude/commands/maestro-composer.md +11 -0
  101. package/.claude/commands/maestro-guard.md +25 -0
  102. package/.claude/commands/maestro-init.md +28 -0
  103. package/.claude/commands/maestro-overlay.md +11 -0
  104. package/.claude/commands/maestro-player.md +11 -0
  105. package/.claude/commands/maestro-quick.md +29 -0
  106. package/.claude/commands/maestro-swarm-workflow.md +25 -0
  107. package/.claude/commands/maestro-tools-execute.md +29 -0
  108. package/.claude/commands/maestro-tools-register.md +29 -0
  109. package/.claude/commands/maestro-ui-codify.md +11 -0
  110. package/.claude/commands/maestro-universal-workflow.md +59 -0
  111. package/.claude/commands/maestro-update.md +38 -0
  112. package/.claude/commands/manage-codebase-rebuild.md +29 -0
  113. package/.claude/commands/manage-drift-realign.md +12 -0
  114. package/.claude/commands/manage-harvest.md +30 -6
  115. package/.claude/commands/manage-issue-discover.md +28 -0
  116. package/.claude/commands/manage-issue.md +23 -0
  117. package/.claude/commands/manage-kg-extractors.md +27 -1
  118. package/.claude/commands/manage-knowhow-capture.md +24 -0
  119. package/.claude/commands/manage-knowhow.md +26 -0
  120. package/.claude/commands/manage-knowledge-audit.md +13 -0
  121. package/.claude/commands/manage-status.md +22 -0
  122. package/.claude/commands/manage-wiki.md +28 -0
  123. package/.claude/commands/odyssey-improve.md +50 -0
  124. package/.claude/commands/odyssey-planex.md +46 -0
  125. package/.claude/commands/odyssey-review-test-fix.md +50 -0
  126. package/.claude/commands/odyssey-ui.md +50 -0
  127. package/.claude/commands/quality-auto-test.md +12 -0
  128. package/.claude/commands/quality-debug.md +11 -0
  129. package/.claude/commands/quality-refactor.md +11 -0
  130. package/.claude/commands/quality-retrospective.md +11 -0
  131. package/.claude/commands/quality-review.md +11 -0
  132. package/.claude/commands/quality-sync.md +10 -0
  133. package/.claude/commands/quality-test.md +12 -0
  134. package/.claude/commands/security-audit.md +11 -0
  135. package/.claude/commands/spec-add.md +27 -0
  136. package/.claude/commands/spec-load.md +25 -0
  137. package/.claude/commands/spec-remove.md +26 -0
  138. package/.claude/commands/spec-setup.md +30 -0
  139. package/.codex/skills/codify-to-knowhow/SKILL.md +2 -0
  140. package/.codex/skills/domain-add/SKILL.md +26 -0
  141. package/.codex/skills/domain-discover/SKILL.md +46 -0
  142. package/.codex/skills/domain-list/SKILL.md +29 -0
  143. package/.codex/skills/learn-decompose/SKILL.md +2 -0
  144. package/.codex/skills/learn-follow/SKILL.md +34 -0
  145. package/.codex/skills/learn-investigate/SKILL.md +33 -0
  146. package/.codex/skills/learn-retro/SKILL.md +33 -0
  147. package/.codex/skills/learn-second-opinion/SKILL.md +30 -0
  148. package/.codex/skills/maestro-amend/SKILL.md +11 -0
  149. package/.codex/skills/maestro-companion/SKILL.md +11 -0
  150. package/.codex/skills/maestro-composer/SKILL.md +11 -0
  151. package/.codex/skills/maestro-guard/SKILL.md +25 -0
  152. package/.codex/skills/maestro-help/SKILL.md +2 -0
  153. package/.codex/skills/maestro-init/SKILL.md +16 -0
  154. package/.codex/skills/maestro-learn/SKILL.md +2 -0
  155. package/.codex/skills/maestro-overlay/SKILL.md +1 -0
  156. package/.codex/skills/maestro-player/SKILL.md +2 -0
  157. package/.codex/skills/maestro-quick/SKILL.md +17 -0
  158. package/.codex/skills/maestro-tools-execute/SKILL.md +31 -0
  159. package/.codex/skills/maestro-tools-register/SKILL.md +29 -0
  160. package/.codex/skills/maestro-ui-codify/SKILL.md +2 -0
  161. package/.codex/skills/maestro-update/SKILL.md +38 -0
  162. package/.codex/skills/manage-codebase-rebuild/SKILL.md +2 -0
  163. package/.codex/skills/manage-codebase-refresh/SKILL.md +11 -0
  164. package/.codex/skills/manage-drift-realign/SKILL.md +2 -0
  165. package/.codex/skills/manage-harvest/SKILL.md +30 -8
  166. package/.codex/skills/manage-issue/SKILL.md +24 -0
  167. package/.codex/skills/manage-issue-discover/SKILL.md +2 -0
  168. package/.codex/skills/manage-knowhow/SKILL.md +26 -0
  169. package/.codex/skills/manage-knowhow-capture/SKILL.md +23 -0
  170. package/.codex/skills/manage-learn/SKILL.md +2 -0
  171. package/.codex/skills/manage-status/SKILL.md +22 -0
  172. package/.codex/skills/manage-wiki/SKILL.md +28 -0
  173. package/.codex/skills/odyssey-debug/SKILL.md +44 -0
  174. package/.codex/skills/odyssey-improve/SKILL.md +49 -0
  175. package/.codex/skills/odyssey-planex/SKILL.md +44 -0
  176. package/.codex/skills/odyssey-review-test-fix/SKILL.md +48 -0
  177. package/.codex/skills/odyssey-ui/SKILL.md +49 -0
  178. package/.codex/skills/quality-auto-test/SKILL.md +2 -0
  179. package/.codex/skills/quality-debug/SKILL.md +2 -0
  180. package/.codex/skills/quality-refactor/SKILL.md +2 -0
  181. package/.codex/skills/quality-retrospective/SKILL.md +2 -0
  182. package/.codex/skills/quality-review/SKILL.md +2 -0
  183. package/.codex/skills/quality-sync/SKILL.md +24 -0
  184. package/.codex/skills/quality-test/SKILL.md +2 -0
  185. package/.codex/skills/security-audit/SKILL.md +30 -0
  186. package/.codex/skills/spec-add/SKILL.md +28 -0
  187. package/.codex/skills/spec-load/SKILL.md +26 -0
  188. package/.codex/skills/spec-map/SKILL.md +1 -0
  189. package/.codex/skills/spec-remove/SKILL.md +28 -0
  190. package/.codex/skills/spec-setup/SKILL.md +28 -0
  191. package/.codex/skills/wiki-connect/SKILL.md +11 -0
  192. package/.codex/skills/wiki-digest/SKILL.md +11 -0
  193. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js +3 -1
  194. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js.map +1 -1
  195. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +5 -0
  196. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +25 -1
  197. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  198. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +4 -0
  199. package/dashboard/dist-server/src/graph/kg/db/queries.js +35 -19
  200. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  201. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +19 -11
  202. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  203. package/dist/src/agents/api-explore/config.d.ts +11 -1
  204. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  205. package/dist/src/agents/api-explore/config.js +17 -16
  206. package/dist/src/agents/api-explore/config.js.map +1 -1
  207. package/dist/src/agents/api-explore/index.js +4 -4
  208. package/dist/src/agents/api-explore/index.js.map +1 -1
  209. package/dist/src/agents/api-explore/llm.d.ts +2 -0
  210. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  211. package/dist/src/agents/api-explore/llm.js +16 -4
  212. package/dist/src/agents/api-explore/llm.js.map +1 -1
  213. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  214. package/dist/src/agents/api-explore/runner.js +16 -12
  215. package/dist/src/agents/api-explore/runner.js.map +1 -1
  216. package/dist/src/commands/explore.d.ts.map +1 -1
  217. package/dist/src/commands/explore.js +19 -2
  218. package/dist/src/commands/explore.js.map +1 -1
  219. package/dist/src/commands/install.js +7 -28
  220. package/dist/src/commands/install.js.map +1 -1
  221. package/dist/src/commands/moa.d.ts.map +1 -1
  222. package/dist/src/commands/moa.js +17 -2
  223. package/dist/src/commands/moa.js.map +1 -1
  224. package/dist/src/commands/search.d.ts.map +1 -1
  225. package/dist/src/commands/search.js +2 -0
  226. package/dist/src/commands/search.js.map +1 -1
  227. package/dist/src/graph/kg/db/queries.d.ts +4 -0
  228. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  229. package/dist/src/graph/kg/db/queries.js +35 -19
  230. package/dist/src/graph/kg/db/queries.js.map +1 -1
  231. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  232. package/dist/src/graph/kg/extraction/orchestrator.js +19 -11
  233. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  234. package/dist/src/hooks/plugins/explore-plugin.d.ts.map +1 -1
  235. package/dist/src/hooks/plugins/explore-plugin.js +3 -2
  236. package/dist/src/hooks/plugins/explore-plugin.js.map +1 -1
  237. package/package.json +1 -1
@@ -39,6 +39,15 @@ Domain term lifecycle: discover/manual → register → active → (optional) de
39
39
  - `maestro domain deprecate <canonical> --successor <new>` — deprecate a term
40
40
  </context>
41
41
 
42
+ <invariants>
43
+ 1. **Single-term atomic operation** — each invocation registers exactly ONE term; NEVER batch-write multiple terms in a single execution
44
+ 2. **Glossary append-only** — existing terms in `glossary.yaml` SHALL NOT be modified or removed; only new entries are appended
45
+ 3. **Duplicate guard** — MUST check for exact canonical name match AND near-matches before writing; NEVER create duplicate entries
46
+ 4. **Confirmation mandatory** — MUST present term details (canonical, definition, aliases, tier, path) via ask_user before any glossary write; NEVER write without user confirmation
47
+ 5. **Schema compliance** — every term entry MUST include canonical name, definition, tier, and at least one alias/keyword; incomplete entries SHALL NOT be persisted
48
+ 6. **Domain directory prerequisite** — `.workflow/domain/` MUST exist before writing; NEVER auto-create the directory (E002 if missing)
49
+ </invariants>
50
+
42
51
  <execution>
43
52
  Follow '~/.maestro/workflows/domain-add.md' completely.
44
53
 
@@ -30,8 +30,19 @@ $ARGUMENTS — target path/module and optional flags.
30
30
 
31
31
  **Storage read**: target files + `coding-conventions.md` + `.workflow/specs/learnings.md` (dedup)
32
32
  **Storage write**: `.workflow/knowhow/KNW-decompose-{slug}-{date}.md` + append `.workflow/specs/learnings.md`
33
+
34
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-decompose-{slug}-{date}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
33
35
  </context>
34
36
 
37
+ <invariants>
38
+ 1. **Read-only analysis** — NEVER modify source code files under analysis; all writes go to `.workflow/` only
39
+ 2. **Evidence-anchored findings** — every pattern MUST include at least one `file:line` anchor from source; unanchored patterns SHALL NOT be persisted
40
+ 3. **Dedup before persist** — MUST cross-reference against existing `learnings.md` and `coding-conventions.md` before writing; duplicate entries SHALL NOT be appended
41
+ 4. **Parallel agent isolation** — each dimension agent operates independently; NEVER share state between agents during analysis
42
+ 5. **Confirmation gate** — unless `-y` is set, MUST present all findings and target files via ask_user before any writes
43
+ 6. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
44
+ </invariants>
45
+
35
46
  <state_machine>
36
47
 
37
48
  <states>
@@ -102,6 +113,7 @@ Flag contradictions (finding conflicts with documented convention). Merge duplic
102
113
  <error_codes>
103
114
  | Code | Condition | Recovery |
104
115
  |------|-----------|----------|
116
+ | E001 | No target path/module provided | Prompt user for target |
105
117
  | E002 | No source files in target | Check target has .ts/.js files |
106
118
  | W001 | One+ dimension agent failed | Proceed with available dimensions |
107
119
  | W002 | .workflow/specs/learnings.md missing or malformed | Treat all patterns as new; create file on persist |
@@ -35,8 +35,46 @@ $ARGUMENTS — target and optional flags.
35
35
 
36
36
  **Storage read**: target file + wiki forward/backlinks + `coding-conventions.md` + `.workflow/specs/learnings.md` (dedup)
37
37
  **Storage write**: `.workflow/knowhow/KNW-follow-{slug}-{date}.md` + append `.workflow/specs/learnings.md`
38
+
39
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-follow-{slug}-{date}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
38
40
  </context>
39
41
 
42
+ <invariants>
43
+ 1. **Read-only traversal** — NEVER modify source code or wiki entries under analysis; all writes go to `.workflow/` only
44
+ 2. **Forcing questions mandatory** — each section MUST have all 4 forcing questions applied; NEVER skip questions even for trivial sections
45
+ 3. **Anchor requirement** — every extracted pattern MUST include a `file:line` anchor; unanchored patterns SHALL NOT be persisted to learnings.md
46
+ 4. **Convention cross-ref** — MUST check every finding against `coding-conventions.md` and mark status (documented/candidate); NEVER persist without status tag
47
+ 5. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
48
+ 6. **Confirmation gate** — unless `-y` is set, MUST present findings and target files via ask_user before any writes
49
+ 7. **Depth contract** — `--depth shallow` MUST NOT descend into function bodies; `--depth deep` MUST cover every branch and sub-expression
50
+ </invariants>
51
+
52
+ <execution>
53
+
54
+ ### Phase Gates (MANDATORY, BLOCKING)
55
+
56
+ **GATE 1: Resolve → Context Building** (S_RESOLVE → S_CONTEXT)
57
+ - REQUIRED: Target resolved to a readable source (file path, wiki entry, or search result).
58
+ - BLOCKED if: target unresolvable after user prompt (E001/E002).
59
+
60
+ **GATE 2: Reading → Extraction** (S_READ → S_EXTRACT)
61
+ - REQUIRED: All sections traversed with 4 forcing questions applied per section.
62
+ - REQUIRED: Depth contract honored — shallow stays at top-level, deep covers every branch.
63
+ - BLOCKED if: any section skipped without forcing questions.
64
+
65
+ **GATE 3: Extraction → Persistence** (S_EXTRACT → S_PERSIST)
66
+ - REQUIRED: All extracted patterns have file:line anchors.
67
+ - REQUIRED: Convention cross-ref completed against coding-conventions.md (or marked "unknown status" if W002).
68
+ - BLOCKED if: unanchored patterns remain in extraction results.
69
+
70
+ **GATE 4: Persistence → Completion** (S_PERSIST → END)
71
+ - REQUIRED: Unless `-y`, ask_user showing files to write and spec-entries to append — user must confirm.
72
+ - REQUIRED: KNW-follow-{slug}-{date}.md written with understanding map.
73
+ - REQUIRED: learnings.md appended (not overwritten) with new spec-entry blocks.
74
+ - BLOCKED if: user declines confirmation — offer to adjust findings before retry.
75
+
76
+ </execution>
77
+
40
78
  <state_machine>
41
79
 
42
80
  <states>
@@ -114,6 +152,9 @@ Write understanding map: Key Concepts, Patterns (table: name/location/convention
114
152
  <error_codes>
115
153
  | Code | Condition | Recovery |
116
154
  |------|-----------|----------|
155
+ | E001 | No target path/wiki-id/topic provided | Prompt user for target |
156
+ | E002 | Target path not found and wiki/grep search returned no results | Check path or broaden search terms |
157
+ | W001 | Wiki forward/backlinks unavailable | Proceed without context web; note reduced coverage |
117
158
  | W002 | coding-conventions.md not found | All patterns marked "unknown status" |
118
159
  | W003 | Target > 1000 lines | Auto-switch to shallow; use --depth deep to override |
119
160
  </error_codes>
@@ -33,8 +33,20 @@ $ARGUMENTS — question text and optional flags.
33
33
  - `.workflow/specs/learnings.md` — appended `<spec-entry>` blocks
34
34
 
35
35
  **Storage read**: source files in scope + `maestro search` + `.workflow/specs/learnings.md` + `debug-notes.md` + `codebase/architecture.md`
36
+
37
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-investigate-{slug}/` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
36
38
  </context>
37
39
 
40
+ <invariants>
41
+ 1. **Read-only investigation** — NEVER modify source code files; all writes go to `.workflow/` only
42
+ 2. **Evidence append-only** — `evidence.ndjson` MUST be appended line-by-line; NEVER overwrite or truncate existing evidence entries
43
+ 3. **Scope lock** — once `--scope` is resolved in S_FRAME, NEVER expand search scope without explicit user confirmation via S_ESCALATE
44
+ 4. **Hypothesis cap** — MUST NOT generate more than `--max-hypotheses` (default 3) before triggering escalation; NEVER silently exceed the cap
45
+ 5. **Structured evidence format** — every evidence entry MUST include `{ts, type, source, relevance, content, note}`; incomplete entries SHALL NOT be appended
46
+ 6. **3-strike escalation** — after all hypotheses fail, MUST escalate to user via ask_user; NEVER silently conclude as INCONCLUSIVE without user interaction
47
+ 7. **Confirmation gate** — unless `-y` is set, MUST present report.md path and spec-entries via ask_user before final writes
48
+ </invariants>
49
+
38
50
  <state_machine>
39
51
 
40
52
  <states>
@@ -136,7 +148,9 @@ Append to .workflow/specs/learnings.md: confirmed → roles="implement", disprov
136
148
  <error_codes>
137
149
  | Code | Condition | Recovery |
138
150
  |------|-----------|----------|
151
+ | E001 | No question text provided | Prompt user for investigation question |
139
152
  | E002 | --scope path not found | Check path |
153
+ | W001 | Prior knowledge search returned no results | Proceed without prior context; note cold-start |
140
154
  | W002 | Very few evidence matches (<3) | Broaden search terms or expand scope |
141
155
  | W003 | All hypotheses inconclusive | Investigation marked INCONCLUSIVE |
142
156
  </error_codes>
@@ -36,8 +36,19 @@ $ARGUMENTS — target and optional mode flag.
36
36
  **Pre-load** (optional): `invoke_skill("spec-load")` for conventions + `maestro search "<target topic>"` for related entries.
37
37
 
38
38
  **Output**: `.workflow/knowhow/KNW-opinion-{slug}-{YYYY-MM-DD}.md`
39
+
40
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-opinion-{slug}-{YYYY-MM-DD}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Read-only analysis** — NEVER modify source code, wiki entries, or plan files under review; all writes go to `.workflow/` only
45
+ 2. **Agent independence** — in review mode, each of the 3 agents (Pragmatist/Purist/Strategist) MUST operate independently without shared state; NEVER pass one agent's findings to another
46
+ 3. **Evidence-backed verdicts** — every finding MUST include a `location` reference (file:line or section); ungrounded opinions SHALL NOT appear in the report
47
+ 4. **Mode contract** — MUST execute exactly the mode specified (review/challenge/consult); NEVER mix mode behaviors within a single execution
48
+ 5. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
49
+ 6. **Confirmation gate** — unless `-y` is set, MUST present findings and target files via ask_user before any writes
50
+ </invariants>
51
+
41
52
  <state_machine>
42
53
 
43
54
  <states>
@@ -106,8 +117,11 @@ Interactive loop:
106
117
  <error_codes>
107
118
  | Code | Condition | Recovery |
108
119
  |------|-----------|----------|
120
+ | E001 | No target provided | Prompt user for target (path, wiki ID, HEAD, staged, or phase) |
109
121
  | E002 | Unknown --mode value | Use: review, challenge, or consult |
122
+ | E003 | Target resolution failed — path not found, wiki ID invalid, or no staged changes | Check target exists |
110
123
  | W001 | One review agent failed | Proceed with available perspectives |
124
+ | W002 | Specs/wiki pre-load unavailable | Proceed without convention context; note reduced coverage |
111
125
  </error_codes>
112
126
 
113
127
  <success_criteria>
@@ -42,8 +42,19 @@ Multiple combinable. No flags + no description → interactive (scan + ask_user)
42
42
  **CLI targeting**: `"cli": "claude"` (default, patches .claude/commands/), `"codex"` (patches .codex/skills/), `"both"` (both paths)
43
43
 
44
44
  **Output**: `~/.maestro/overlays/amend-{slug}.json` + optional `~/.maestro/overlays/docs/amend-{slug}.md`
45
+
46
+ **Output boundary**: ALL file writes MUST target `~/.maestro/overlays/` (overlay JSON + docs) only. NEVER modify `.claude/commands/*.md` directly — overlay installation is handled by `maestro overlay add`.
45
47
  </context>
46
48
 
49
+ <invariants>
50
+ 1. **Non-invasive only** — amendments MUST use the overlay system (`~/.maestro/overlays/*.json`); direct edits to `.claude/commands/*.md` are NEVER permitted
51
+ 2. **Idempotent patches** — re-running the same amendment MUST produce identical overlay JSON; overlay markers prevent duplicate injection
52
+ 3. **Pristine source reads** — signal diagnosis MUST read from `$PKG_ROOT/.claude/commands/` (untouched originals), not installed copies
53
+ 4. **Code bugs excluded** — signals classified as code bugs MUST be routed to `/maestro-quick` or `/maestro-plan --gaps`, NEVER patched via overlay
54
+ 5. **User confirmation before install** — overlay JSON MUST be previewed and confirmed by the user before `maestro overlay add` runs (unless `-y`)
55
+ 6. **Section existence verified** — target section MUST be confirmed to exist in the pristine source before drafting a patch; missing sections trigger `new-section` mode
56
+ </invariants>
57
+
47
58
  <state_machine>
48
59
 
49
60
  <states>
@@ -50,12 +50,23 @@ $ARGUMENTS — mode + optional flags.
50
50
 
51
51
  Auto-detection: if `--type` not provided, infer from `--task` description keywords.
52
52
 
53
+ **Output boundary**: ALL file writes MUST target `.workflow/.scratchpad/` (companion docs + `.companion-active` pointer) only. Promotion writes (spec/knowhow) are delegated to `spec-add` / `manage-knowhow-capture` skills. NEVER modify source code, `.workflow/state.json`, or files outside `.workflow/.scratchpad/`.
54
+
53
55
  **Companion document:**
54
56
  - Path: `.workflow/.scratchpad/companion-{YYYYMMDD-HHmmss}.md`
55
57
  - Active doc tracking: `.workflow/.scratchpad/.companion-active` (stores path of current companion doc)
56
58
  - Format: YAML frontmatter (rich metadata) + typed sections + timestamped entries
57
59
  </context>
58
60
 
61
+ <invariants>
62
+ 1. **No session creation** — companion NEVER creates workflow sessions, NEVER writes to state.json
63
+ 2. **Side-car only** — companion MUST NOT modify source code or execute implementation tasks; it is strictly a knowledge loading + recording utility
64
+ 3. **One active doc** — only one `.companion-active` pointer SHALL exist at a time; creating a new companion doc MUST clear any stale pointer
65
+ 4. **Append-only entries** — note mode MUST append entries; NEVER overwrite or reorder existing entries
66
+ 5. **Promotion via delegation** — spec/knowhow promotion MUST route through `spec-add` / `manage-knowhow-capture` skills; companion NEVER writes directly to `.workflow/specs/` or `.workflow/knowhow/`
67
+ 6. **Type-template integrity** — context template sections MUST match the resolved `task_type`; NEVER mix templates from different types
68
+ </invariants>
69
+
59
70
  <state_machine>
60
71
 
61
72
  <states>
@@ -41,8 +41,19 @@ $ARGUMENTS — natural language description, or flags.
41
41
  1. **Architecture specs**: Run `maestro load --type spec --category arch` to load architecture constraints. Use as context for node resolution — ensures workflow design respects documented patterns.
42
42
  2. **Coding specs**: Run `maestro load --type spec --category coding` to load coding conventions. Informs executor argument defaults and context injection.
43
43
  3. Optional — proceed without if unavailable.
44
+
45
+ **Output boundary**: ALL file writes MUST target `~/.maestro/templates/workflows/` (template JSON + index.json) and `.workflow/templates/design-drafts/` (intermediate drafts) only. NEVER modify source code or `.claude/commands/` files.
44
46
  </context>
45
47
 
48
+ <invariants>
49
+ 1. **Max 20 nodes** — workflow templates MUST NOT exceed 20 nodes; larger workflows MUST be split into sub-workflows
50
+ 2. **Acyclic DAG** — generated template MUST be a directed acyclic graph; cycles MUST be detected and rejected before persistence
51
+ 3. **No orphan nodes** — every node MUST be reachable from at least one edge; unreachable nodes MUST be flagged
52
+ 4. **Confirmation before write** — template JSON MUST be shown to user via ask_user before writing to `~/.maestro/templates/workflows/`; cancellation saves draft only
53
+ 5. **Draft preservation** — abandoning at any confirmation gate MUST save current progress to design-drafts directory; NEVER discard user's partial work
54
+ 6. **Deferred reading only** — node-catalog and template-schema MUST be read at their designated phases (P2, P5), NEVER loaded eagerly at startup
55
+ </invariants>
56
+
46
57
  <state_machine>
47
58
 
48
59
  <states>
@@ -32,10 +32,35 @@ $ARGUMENTS — Parse subcommand and optional path argument.
32
32
 
33
33
  **Enforcement:** The `workflow-guard` hook (PreToolUse on Write/Edit) reads this config
34
34
  and blocks operations targeting files outside boundaries. Requires hooks level >= `full`.
35
+
36
+ **Output boundary**: ALL file writes MUST target `.workflow/config.json` (guard section) only. NEVER modify hook files, `.claude/settings.json`, or source code.
35
37
  </context>
36
38
 
39
+ <invariants>
40
+ 1. **Config-only mutation** — guard MUST only modify the `guard` section of `.workflow/config.json`; NEVER touch other config sections or files
41
+ 2. **Non-destructive** — `off` MUST preserve existing paths and mode; NEVER clear the path list when disabling
42
+ 3. **Mode switch confirmation** — switching between allow/deny mode MUST require ask_user confirmation when existing paths will be cleared
43
+ 4. **Hook dependency** — guard MUST warn when enabled but `workflow-guard` hook is not active (hooks level < full)
44
+ 5. **Path normalization** — all paths MUST use forward slashes with trailing slash for directories; NEVER store raw backslash paths
45
+ </invariants>
46
+
37
47
  <execution>
38
48
 
49
+ ### Phase Gates (MANDATORY, BLOCKING)
50
+
51
+ **GATE 1: Parse → Config Read**
52
+ - REQUIRED: Subcommand parsed (on/off/status/allow/deny) or defaulted to `status`.
53
+ - BLOCKED if: invalid subcommand provided.
54
+
55
+ **GATE 2: Config Read → Execute**
56
+ - REQUIRED: `.workflow/config.json` read successfully or initialized with empty guard section.
57
+ - BLOCKED if: file unreadable and cannot be created (E001).
58
+
59
+ **GATE 3: Execute → Confirm**
60
+ - REQUIRED: Config mutation applied (for on/off/allow/deny) or status displayed (for status).
61
+ - REQUIRED: Mode-switch ask_user answered (for allow↔deny transitions with existing paths).
62
+ - BLOCKED if: user declines mode switch.
63
+
39
64
  **Step 1: Parse subcommand**
40
65
 
41
66
  Extract from $ARGUMENTS:
@@ -40,8 +40,18 @@ $ARGUMENTS — none for interactive mode, or `-y` with `@file` reference for aut
40
40
 
41
41
  **Load project state if exists:**
42
42
  Check for `.workflow/state.json` -- loads context if project already initialized.
43
+
44
+ **Output boundary**: ALL file writes MUST target `.workflow/` (project.md, state.json, config.json, specs/) only. NEVER modify source code or files outside `.workflow/`.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Idempotent init** — re-running init on an already-initialized project MUST detect existing `.workflow/` and warn (E002); NEVER silently overwrite existing state
49
+ 2. **Scope guard** — init MUST only make initialization decisions; NEVER prejudge roadmap structure, plan scope, or implementation details
50
+ 3. **All artifacts required** — init MUST NOT report completion until project.md, state.json, and config.json all exist; missing artifacts MUST be created before exit
51
+ 4. **Template-driven** — deferred templates (project.md, state.json, config.json) MUST be read from `~/.maestro/templates/` and customized; NEVER generate from scratch without template
52
+ 5. **Interview writes back** — all interactive decisions MUST be written to project.md/config.json before proceeding to research or completion; NEVER leave decisions unrecorded
53
+ </invariants>
54
+
45
55
  <interview_protocol>
46
56
  Follows @~/.maestro/workflows/interview-mechanics.md standard.
47
57
 
@@ -54,6 +64,24 @@ Follows @~/.maestro/workflows/interview-mechanics.md standard.
54
64
  </interview_protocol>
55
65
 
56
66
  <execution>
67
+
68
+ ### Phase Gates (MANDATORY, BLOCKING)
69
+
70
+ **GATE 1: Pre-flight → Interview**
71
+ - REQUIRED: `.workflow/` existence check completed.
72
+ - REQUIRED: `--from` source validated (if provided).
73
+ - BLOCKED if: E002 (greenfield conflict with existing `.workflow/`) unresolved.
74
+
75
+ **GATE 2: Interview → Research**
76
+ - REQUIRED: All interview decisions recorded in project.md and config.json.
77
+ - REQUIRED: `.workflow/` directory created with initial structure.
78
+ - BLOCKED if: interview decisions not yet written to files.
79
+
80
+ **GATE 3: Research → Completion**
81
+ - REQUIRED: All 3 required artifacts exist (project.md, state.json, config.json).
82
+ - REQUIRED: `.workflow/specs/` initialized.
83
+ - BLOCKED if: any artifact missing — write it before reporting completion.
84
+
57
85
  ### Pre-flight
58
86
 
59
87
  1. Check if `.workflow/` already exists — if so, load state and warn (E002 for greenfield conflicts)
@@ -36,8 +36,19 @@ Turn natural-language instructions into command overlays — JSON patch files th
36
36
  **Management** — listing and removing overlays is handled by `maestro overlay list` (ink TUI with interactive delete). This skill focuses solely on creation.
37
37
 
38
38
  **Available sections** (for `section:` in patches): `purpose`, `required_reading`, `deferred_reading`, `context`, `execution`, `error_codes`, `success_criteria`.
39
+
40
+ **Output boundary**: ALL file writes MUST target `~/.maestro/overlays/` (overlay JSON + docs) only. Command file patching is handled by `maestro overlay add` — this skill NEVER modifies `.claude/commands/*.md` directly.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Non-invasive** — overlays MUST use hashed HTML-comment markers for injection; NEVER edit command file content directly outside the overlay system
45
+ 2. **Idempotent** — re-running `maestro overlay apply` with the same overlay JSON MUST produce no file changes
46
+ 3. **Creation only** — this skill MUST only create overlays; listing and removal are handled by `maestro overlay list` (ink TUI)
47
+ 4. **Pristine source preferred** — injection point analysis MUST read from `$PKG_ROOT/.claude/commands/` (untouched originals) first, fall back to `~/.claude/commands/` only if pristine unavailable
48
+ 5. **User approval before write** — overlay JSON MUST be shown and approved via ask_user before writing to disk; NEVER auto-install without confirmation
49
+ 6. **Chain skip option mandatory** — if a skill chain is configured, the injected content MUST include a "Skip" option in ask_user; NEVER force the user into a chain
50
+ </invariants>
51
+
41
52
  <execution>
42
53
  ### 1. Parse user intent
43
54
 
@@ -69,8 +69,19 @@ $ARGUMENTS — template slug/path, or flags.
69
69
  "last_checkpoint": null
70
70
  }
71
71
  ```
72
+
73
+ **Output boundary**: ALL file writes MUST target `.workflow/.maestro/player-*/` (session status.json + step outputs) only. Template files (`~/.maestro/templates/workflows/`) are read-only. NEVER modify source code or `.claude/commands/` files.
72
74
  </context>
73
75
 
76
+ <invariants>
77
+ 1. **Resume-safe** — status.json MUST be updated after every step change; an interrupted session MUST be resumable from the last checkpoint via `-c`
78
+ 2. **One step at a time** — execution loop MUST process steps sequentially in topological order; parallel steps share a batch index but NEVER run concurrently within the player
79
+ 3. **CLI nodes async** — cli-type nodes MUST use `shell(run_in_background: true)` + STOP pattern; NEVER block the main thread on delegate execution
80
+ 4. **Templates read-only** — player MUST NOT modify template JSON files; runtime state belongs in status.json only
81
+ 5. **Failure requires user decision** — on step failure without explicit `on_fail`, player MUST prompt via ask_user (Retry/Skip/Abort); NEVER silently skip or auto-abort
82
+ 6. **Reference resolution at runtime** — `{N-xxx.field}` and `{prev_*}` references MUST be resolved at execution time from status.json step results, NEVER pre-resolved during init
83
+ </invariants>
84
+
74
85
  <state_machine>
75
86
 
76
87
  <states>
@@ -41,9 +41,38 @@ Parse for:
41
41
  - Browse: `maestro search --category coding`
42
42
  - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
43
43
  3. All are optional — proceed without if unavailable.
44
+
45
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/` (task directory, plan.json, summaries) and modified source files as defined in plan.json tasks. State.json scratch entry is implicit workflow tracking.
44
46
  </context>
45
47
 
48
+ <invariants>
49
+ 1. **Atomic commits** — each task execution MUST produce a commit with only the files modified by that task; NEVER stage unrelated files
50
+ 2. **Evidence-based summaries** — task summaries MUST include concrete evidence (files changed, tests run, commands executed); NEVER accept "task completed successfully" as a summary
51
+ 3. **Plan before execute** — plan.json MUST be written before any task execution begins; NEVER skip planning even for single-task workflows
52
+ 4. **Scratch isolation** — all workflow artifacts MUST live under `.workflow/scratch/{task-dir}/`; NEVER write workflow metadata outside this directory
53
+ 5. **Commit confirmation** — staged files and commit message MUST be shown via ask_user before committing (unless `-y`); NEVER auto-commit without user awareness
54
+ </invariants>
55
+
46
56
  <execution>
57
+
58
+ ### Phase Gates (MANDATORY, BLOCKING)
59
+
60
+ **GATE 1: Setup → Planning**
61
+ - REQUIRED: Task description parsed and scratch directory created.
62
+ - REQUIRED: Coding specs loaded (optional but attempted).
63
+ - BLOCKED if: no task description (E001) or scratch directory creation failed (E002).
64
+
65
+ **GATE 2: Planning → Execution**
66
+ - REQUIRED: plan.json written with task definitions.
67
+ - REQUIRED: --discuss decisions extracted and recorded (if flag set).
68
+ - BLOCKED if: plan.json missing or empty.
69
+
70
+ **GATE 3: Execution → Completion**
71
+ - REQUIRED: All tasks executed with `.summaries/TASK-*-summary.md` written per task.
72
+ - REQUIRED: Each summary contains concrete evidence of completion.
73
+ - REQUIRED: --full verification passed (if flag set).
74
+ - BLOCKED if: any task summary missing or lacking evidence.
75
+
47
76
  Follow '~/.maestro/workflows/quick.md' completely.
48
77
 
49
78
  ### Artifact Verification (before completion)
@@ -45,6 +45,8 @@ Remaining → intent
45
45
  | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
46
46
  | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
47
47
  | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
48
+
49
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/` (results, ralph-compatible artifacts). When inside a ralph session, writes target the corresponding step's scratch directory. NEVER modify source code, workflow scripts (`~/.maestro/workflows/swarm/`), or `.claude/commands/` files.
48
50
  </context>
49
51
 
50
52
  <state_machine>
@@ -198,6 +200,29 @@ Workflow 返回 JSON 后:
198
200
  6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
199
201
  </invariants>
200
202
 
203
+ <execution>
204
+
205
+ ### Phase Gates (MANDATORY, BLOCKING)
206
+
207
+ **GATE 1: Parse → Route**
208
+ - REQUIRED: Intent text or `--script` flag parsed successfully.
209
+ - BLOCKED if: no intent and no `--script` (E001).
210
+
211
+ **GATE 2: Route → Context Assembly**
212
+ - REQUIRED: Target script resolved unambiguously (single match or user-selected from candidates).
213
+ - BLOCKED if: ambiguous routing without user resolution (E002).
214
+
215
+ **GATE 3: Context → Dispatch**
216
+ - REQUIRED: Args payload assembled with all required fields for target script.
217
+ - REQUIRED: Script file exists at `~/.maestro/workflows/swarm/{script}.js`.
218
+ - BLOCKED if: script file not found (E003) or required args missing.
219
+
220
+ **GATE 4: Dispatch → Ingest**
221
+ - REQUIRED: Workflow execution completed (success or partial results available).
222
+ - BLOCKED if: Workflow execution failed entirely (E004) — offer `--resume`.
223
+
224
+ </execution>
225
+
201
226
  <appendix>
202
227
 
203
228
  ### 与 Ralph 集成
@@ -37,8 +37,37 @@ $ARGUMENTS — Tool name, keyword, or --category filter
37
37
  Empty arguments enters interactive mode: list all tools for user selection.
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Confirmation before execution** — MUST ask_user before executing tool steps; NEVER auto-execute without user consent
42
+ 2. **Sequential step execution** — steps MUST be executed in defined order; NEVER skip or reorder steps unless user explicitly requests skip
43
+ 3. **Blocker escalation** — step failure MUST be reported to user with retry/skip/abort options; NEVER silently skip failed steps
44
+ 4. **Read-only tool definition** — tool execution MUST NOT modify the tool's knowhow document or spec entry; only the target codebase is modified per tool steps
45
+ 5. **Progress feedback** — each completed step MUST report `[Step N/M] done — <step_name>`; NEVER execute silently
46
+ 6. **Output boundary** — file writes are governed by the individual tool's step definitions. This command itself writes NO files beyond what the loaded tool prescribes
47
+ </invariants>
48
+
40
49
  <execution>
41
50
 
51
+ ### Phase Gates (MANDATORY, BLOCKING)
52
+
53
+ **GATE 1: Parse → Load**
54
+ - REQUIRED: Tool name, keyword, or --category parsed from arguments (or empty for interactive mode).
55
+ - BLOCKED if: invalid category value.
56
+
57
+ **GATE 2: Load → Confirm**
58
+ - REQUIRED: Exactly one tool resolved (direct match or user selection from candidates).
59
+ - REQUIRED: Tool document loaded and steps extracted (ref entries expanded via `maestro load --type knowhow`).
60
+ - BLOCKED if: E001 (no match found), E002 unresolved (multiple matches without user selection).
61
+
62
+ **GATE 3: Confirm → Execute**
63
+ - REQUIRED: User confirmed execution mode via ask_user (execute as-is / adjust / view only).
64
+ - BLOCKED if: user selects "View only" — display steps and END without execution.
65
+
66
+ **GATE 4: Execute → Report**
67
+ - REQUIRED: All steps attempted (completed, skipped with user approval, or aborted by user).
68
+ - REQUIRED: Results collected for each step (success/skip/fail).
69
+ - BLOCKED if: user chose abort mid-execution — report partial results and END.
70
+
42
71
  ### Step 1: Load Tool
43
72
 
44
73
  **By name**:
@@ -37,8 +37,37 @@ $ARGUMENTS — Intent description
37
37
  ```
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Schema validation** — tool knowhow document MUST include `tool: true`, `category`, `keywords`, and `summary` in YAML frontmatter; missing fields → reject write
42
+ 2. **No duplicate names** — tool title MUST be unique within its category; duplicate detection → E002 warning with overwrite/optimize confirmation
43
+ 3. **Category required** — every tool MUST declare exactly one category from: coding, test, review, arch, debug; empty category → E003
44
+ 4. **Confirmation gate** — MUST ask_user before writing knowhow document and spec ref entry; NEVER persist without user confirmation
45
+ 5. **Promote is in-place** — promote mode MUST update existing knowhow frontmatter via `maestro wiki update`; NEVER recreate the document
46
+ 6. **Output boundary** — ALL file writes MUST target .workflow/knowhow/ (tool documents) and .workflow/specs/ (ref entries via maestro spec add) only. NEVER modify source code or files outside these paths
47
+ 7. **Description format** — first line after `### Title` MUST state "Use when ..." (usage timing); this is critical for ref entry summary visibility in spec-load
48
+ </invariants>
49
+
40
50
  <execution>
41
51
 
52
+ ### Phase Gates (MANDATORY, BLOCKING)
53
+
54
+ **GATE 1: Parse → Gather**
55
+ - REQUIRED: Mode determined (extract/generate/optimize/promote) from argument parsing.
56
+ - REQUIRED: For optimize/promote modes, target tool/document exists and is loadable.
57
+ - BLOCKED if: empty args without user response to ask_user.
58
+
59
+ **GATE 2: Gather → Write**
60
+ - REQUIRED: Tool name, category, and usage timing confirmed.
61
+ - REQUIRED: Steps extracted or generated (extract: ≥1 step, generate: user-confirmed scope).
62
+ - REQUIRED: Inline vs ref mode decided based on step count.
63
+ - REQUIRED: User confirmed via ask_user (title, category, keywords, summary, step count).
64
+ - BLOCKED if: E001 (.workflow/specs/ not initialized), E003 (no category), user cancels.
65
+
66
+ **GATE 3: Write → Verify**
67
+ - REQUIRED: Knowhow document written with `tool: true` frontmatter (or updated in-place for promote).
68
+ - REQUIRED: Spec ref entry registered (if user confirmed).
69
+ - BLOCKED if: write failed or spec add returned error.
70
+
42
71
  ### Step 1: Intent Detection
43
72
 
44
73
  Parse $ARGUMENTS to determine mode:
@@ -35,8 +35,19 @@ Flags:
35
35
  - `--package-name <name>`: Package name for reference output (default: auto-generated from source directory)
36
36
  - `--output-dir <path>`: Output directory for reference package (default: `.workflow/reference_style`)
37
37
  - `--overwrite`: Allow overwriting existing package directory
38
+
39
+ **Output boundary**: ALL file writes MUST target the `--output-dir` path (default: `.workflow/reference_style/`) for reference packages, and `.workflow/knowhow/` for knowledge assets (via `codify-to-knowhow`). NEVER modify the source directory being analyzed.
38
40
  </context>
39
41
 
42
+ <invariants>
43
+ 1. **Source read-only** — the source path being analyzed MUST NOT be modified; extraction is purely read-only
44
+ 2. **Phase-sequential loading** — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly
45
+ 3. **User confirmation before knowhow** — Phase 3→4 gate MUST present ask_user before generating knowledge assets; NEVER auto-proceed to knowhow generation
46
+ 4. **Overwrite protection** — existing package directory MUST NOT be overwritten without `--overwrite` flag (E003)
47
+ 5. **Artifact completeness** — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification
48
+ 6. **Token-first extraction** — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation
49
+ </invariants>
50
+
40
51
  <execution>
41
52
  ## 1. Load UI Specs
42
53
 
@@ -35,6 +35,8 @@ Remaining → intent
35
35
  **Library locations:**
36
36
  - Fixed scripts: `~/.maestro/workflows/swarm/wf-*.js`
37
37
  - Dynamic scripts: `~/.maestro/workflows/dynamic/uwf-*.js`
38
+
39
+ **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.
38
40
  </context>
39
41
 
40
42
  <state_machine>
@@ -511,6 +513,36 @@ Findings: ${digest}
511
513
  12. **无反斜杠路径** — 字符串中路径用正斜杠(`\u`、`\a` 等会被解析为转义序列)
512
514
  </invariants>
513
515
 
516
+ <execution>
517
+
518
+ ### Phase Gates (MANDATORY, BLOCKING)
519
+
520
+ **GATE 1: Parse → Scan**
521
+ - REQUIRED: Intent text or `--from`/`--resume` flag parsed.
522
+ - BLOCKED if: no intent and no flags (E001).
523
+
524
+ **GATE 2: Scan → Design/Execute**
525
+ - REQUIRED: Library scan completed (both `swarm/` and `dynamic/` directories).
526
+ - REQUIRED: User decision if matches found (reuse existing vs generate new).
527
+ - BLOCKED if: scan fails to read script directories.
528
+
529
+ **GATE 3: Design → Generate**
530
+ - REQUIRED: Task decomposition completed with work_items, decision_points, data_flow.
531
+ - REQUIRED: Phase orchestration and adversarial pattern selection determined by depth.
532
+ - BLOCKED if: task cannot be decomposed (E002).
533
+
534
+ **GATE 4: Generate → Execute**
535
+ - REQUIRED: Script written to `~/.maestro/workflows/dynamic/uwf-{slug}.js`.
536
+ - REQUIRED: `node --check` syntax validation passed.
537
+ - REQUIRED: User confirmation via ask_user (unless resuming).
538
+ - BLOCKED if: syntax validation fails after 2 retries (E003).
539
+
540
+ **GATE 5: Execute → Persist**
541
+ - REQUIRED: Workflow execution completed via `scriptPath` invocation.
542
+ - BLOCKED if: Workflow execution failed (E004) — offer `--resume`.
543
+
544
+ </execution>
545
+
514
546
  <appendix>
515
547
 
516
548
  ### 使用示例
@@ -571,3 +603,30 @@ universal-workflow 扫描时会同时检查 swarm/ 和 dynamic/ 目录,
571
603
  | E005 | 持久化失败 | 展示脚本内容,让用户手动保存 |
572
604
 
573
605
  </appendix>
606
+
607
+ <error_codes>
608
+ | Code | Severity | Condition | Recovery |
609
+ |------|----------|-----------|----------|
610
+ | E001 | error | No intent and no --from/--resume flag | Prompt user for intent text |
611
+ | E002 | error | Task decomposition failed — cannot identify work_items | Require more specific intent description |
612
+ | E003 | error | Generated script syntax error after 2 retries | Show script content + error for manual fix |
613
+ | E004 | error | Workflow execution failed | Show error, offer --resume with runId |
614
+ | E005 | error | Script persistence failed (filesystem write error) | Show script content for manual save |
615
+ | W001 | warning | No matching scripts found in library scan | Proceed directly to S_DESIGN |
616
+ | W002 | warning | Adversarial gate confidence < 50% | Flag low-confidence decision, suggest --depth deep |
617
+ </error_codes>
618
+
619
+ <success_criteria>
620
+ - [ ] Intent parsed and flags extracted (--name, --depth, --dry-run, --from, --resume)
621
+ - [ ] Library scan completed across both swarm/ and dynamic/ directories
622
+ - [ ] User decision captured if matching scripts found (reuse vs generate)
623
+ - [ ] Task decomposition produced: work_items, decision_points, data_flow
624
+ - [ ] Adversarial pattern selected per decision_point according to depth level
625
+ - [ ] Blueprint presented to user with estimated agent count
626
+ - [ ] Script generated as pure JavaScript with all 12 generation rules enforced
627
+ - [ ] `node --check` syntax validation passed
628
+ - [ ] User confirmation obtained before execution (unless --resume)
629
+ - [ ] Workflow executed via scriptPath (not inline script string)
630
+ - [ ] Script persisted to `~/.maestro/workflows/dynamic/uwf-{slug}.js`
631
+ - [ ] Completion summary displayed with reuse/resume commands
632
+ </success_criteria>