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,8 +39,19 @@ Multiple combinable. No flags + no description → interactive (scan + ask_quest
39
39
  **CLI targeting**: `"cli": "claude"` (default, patches .claude/commands/), `"codex"` (patches .codex/skills/), `"both"` (both paths)
40
40
 
41
41
  **Output**: `~/.maestro/overlays/amend-{slug}.json` + optional `~/.maestro/overlays/docs/amend-{slug}.md`
42
+
43
+ **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`.
42
44
  </context>
43
45
 
46
+ <invariants>
47
+ 1. **Non-invasive only** — amendments MUST use the overlay system (`~/.maestro/overlays/*.json`); direct edits to `.claude/commands/*.md` are NEVER permitted
48
+ 2. **Idempotent patches** — re-running the same amendment MUST produce identical overlay JSON; overlay markers prevent duplicate injection
49
+ 3. **Pristine source reads** — signal diagnosis MUST read from `$PKG_ROOT/.claude/commands/` (untouched originals), not installed copies
50
+ 4. **Code bugs excluded** — signals classified as code bugs MUST be routed to `/maestro-quick` or `/maestro-plan --gaps`, NEVER patched via overlay
51
+ 5. **User confirmation before install** — overlay JSON MUST be previewed and confirmed by the user before `maestro overlay add` runs (unless `-y`)
52
+ 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
53
+ </invariants>
54
+
44
55
  <state_machine>
45
56
 
46
57
  <states>
@@ -46,12 +46,23 @@ $ARGUMENTS — mode + optional flags.
46
46
 
47
47
  Auto-detection: if `--type` not provided, infer from `--task` description keywords.
48
48
 
49
+ **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/`.
50
+
49
51
  **Companion document:**
50
52
  - Path: `.workflow/.scratchpad/companion-{YYYYMMDD-HHmmss}.md`
51
53
  - Active doc tracking: `.workflow/.scratchpad/.companion-active` (stores path of current companion doc)
52
54
  - Format: YAML frontmatter (rich metadata) + typed sections + timestamped entries
53
55
  </context>
54
56
 
57
+ <invariants>
58
+ 1. **No session creation** — companion NEVER creates workflow sessions, NEVER writes to state.json
59
+ 2. **Side-car only** — companion MUST NOT modify source code or execute implementation tasks; it is strictly a knowledge loading + recording utility
60
+ 3. **One active doc** — only one `.companion-active` pointer SHALL exist at a time; creating a new companion doc MUST clear any stale pointer
61
+ 4. **Append-only entries** — note mode MUST append entries; NEVER overwrite or reorder existing entries
62
+ 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/`
63
+ 6. **Type-template integrity** — context template sections MUST match the resolved `task_type`; NEVER mix templates from different types
64
+ </invariants>
65
+
55
66
  <state_machine>
56
67
 
57
68
  <states>
@@ -40,8 +40,19 @@ $ARGUMENTS — natural language description, or flags.
40
40
  1. **Architecture specs**: Run `maestro load --type spec --category arch` to load architecture constraints. Use as context for node resolution — ensures workflow design respects documented patterns.
41
41
  2. **Coding specs**: Run `maestro load --type spec --category coding` to load coding conventions. Informs executor argument defaults and context injection.
42
42
  3. Optional — proceed without if unavailable.
43
+
44
+ **Output boundary**: ALL file writes MUST target `~/.maestro/templates/workflows/` (template JSON + index.json) and `.workflow/templates/design-drafts/` (intermediate drafts) only. NEVER modify source code or `.claude/commands/` files.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Max 20 nodes** — workflow templates MUST NOT exceed 20 nodes; larger workflows MUST be split into sub-workflows
49
+ 2. **Acyclic DAG** — generated template MUST be a directed acyclic graph; cycles MUST be detected and rejected before persistence
50
+ 3. **No orphan nodes** — every node MUST be reachable from at least one edge; unreachable nodes MUST be flagged
51
+ 4. **Confirmation before write** — template JSON MUST be shown to user via ask_question before writing to `~/.maestro/templates/workflows/`; cancellation saves draft only
52
+ 5. **Draft preservation** — abandoning at any confirmation gate MUST save current progress to design-drafts directory; NEVER discard user's partial work
53
+ 6. **Deferred reading only** — node-catalog and template-schema MUST be read at their designated phases (P2, P5), NEVER loaded eagerly at startup
54
+ </invariants>
55
+
45
56
  <state_machine>
46
57
 
47
58
  <states>
@@ -30,10 +30,35 @@ $ARGUMENTS — Parse subcommand and optional path argument.
30
30
 
31
31
  **Enforcement:** The `workflow-guard` hook (PreToolUse on Write/Edit) reads this config
32
32
  and blocks operations targeting files outside boundaries. Requires hooks level >= `full`.
33
+
34
+ **Output boundary**: ALL file writes MUST target `.workflow/config.json` (guard section) only. NEVER modify hook files, `.claude/settings.json`, or source code.
33
35
  </context>
34
36
 
37
+ <invariants>
38
+ 1. **Config-only mutation** — guard MUST only modify the `guard` section of `.workflow/config.json`; NEVER touch other config sections or files
39
+ 2. **Non-destructive** — `off` MUST preserve existing paths and mode; NEVER clear the path list when disabling
40
+ 3. **Mode switch confirmation** — switching between allow/deny mode MUST require ask_question confirmation when existing paths will be cleared
41
+ 4. **Hook dependency** — guard MUST warn when enabled but `workflow-guard` hook is not active (hooks level < full)
42
+ 5. **Path normalization** — all paths MUST use forward slashes with trailing slash for directories; NEVER store raw backslash paths
43
+ </invariants>
44
+
35
45
  <execution>
36
46
 
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Parse → Config Read**
50
+ - REQUIRED: Subcommand parsed (on/off/status/allow/deny) or defaulted to `status`.
51
+ - BLOCKED if: invalid subcommand provided.
52
+
53
+ **GATE 2: Config Read → Execute**
54
+ - REQUIRED: `.workflow/config.json` read successfully or initialized with empty guard section.
55
+ - BLOCKED if: file unreadable and cannot be created (E001).
56
+
57
+ **GATE 3: Execute → Confirm**
58
+ - REQUIRED: Config mutation applied (for on/off/allow/deny) or status displayed (for status).
59
+ - REQUIRED: Mode-switch ask_question answered (for allow↔deny transitions with existing paths).
60
+ - BLOCKED if: user declines mode switch.
61
+
37
62
  **Step 1: Parse subcommand**
38
63
 
39
64
  Extract from $ARGUMENTS:
@@ -40,8 +40,18 @@ $ARGUMENTS — none for interactive mode, or `-y` with `@file` reference for aut
40
40
 
41
41
  **Load project state if exists:**
42
42
  Check for `.workflow/state.json` -- loads context if project already initialized.
43
+
44
+ **Output boundary**: ALL file writes MUST target `.workflow/` (project.md, state.json, config.json, specs/) only. NEVER modify source code or files outside `.workflow/`.
43
45
  </context>
44
46
 
47
+ <invariants>
48
+ 1. **Idempotent init** — re-running init on an already-initialized project MUST detect existing `.workflow/` and warn (E002); NEVER silently overwrite existing state
49
+ 2. **Scope guard** — init MUST only make initialization decisions; NEVER prejudge roadmap structure, plan scope, or implementation details
50
+ 3. **All artifacts required** — init MUST NOT report completion until project.md, state.json, and config.json all exist; missing artifacts MUST be created before exit
51
+ 4. **Template-driven** — deferred templates (project.md, state.json, config.json) MUST be read from `~/.maestro/templates/` and customized; NEVER generate from scratch without template
52
+ 5. **Interview writes back** — all interactive decisions MUST be written to project.md/config.json before proceeding to research or completion; NEVER leave decisions unrecorded
53
+ </invariants>
54
+
45
55
  <interview_protocol>
46
56
  Follows @~/.maestro/workflows/interview-mechanics.md standard.
47
57
 
@@ -54,6 +64,24 @@ Follows @~/.maestro/workflows/interview-mechanics.md standard.
54
64
  </interview_protocol>
55
65
 
56
66
  <execution>
67
+
68
+ ### Phase Gates (MANDATORY, BLOCKING)
69
+
70
+ **GATE 1: Pre-flight → Interview**
71
+ - REQUIRED: `.workflow/` existence check completed.
72
+ - REQUIRED: `--from` source validated (if provided).
73
+ - BLOCKED if: E002 (greenfield conflict with existing `.workflow/`) unresolved.
74
+
75
+ **GATE 2: Interview → Research**
76
+ - REQUIRED: All interview decisions recorded in project.md and config.json.
77
+ - REQUIRED: `.workflow/` directory created with initial structure.
78
+ - BLOCKED if: interview decisions not yet written to files.
79
+
80
+ **GATE 3: Research → Completion**
81
+ - REQUIRED: All 3 required artifacts exist (project.md, state.json, config.json).
82
+ - REQUIRED: `.workflow/specs/` initialized.
83
+ - BLOCKED if: any artifact missing — write it before reporting completion.
84
+
57
85
  ### Pre-flight
58
86
 
59
87
  1. Check if `.workflow/` already exists — if so, load state and warn (E002 for greenfield conflicts)
@@ -33,8 +33,19 @@ Turn natural-language instructions into command overlays — JSON patch files th
33
33
  **Management** — listing and removing overlays is handled by `maestro overlay list` (ink TUI with interactive delete). This skill focuses solely on creation.
34
34
 
35
35
  **Available sections** (for `section:` in patches): `purpose`, `required_reading`, `deferred_reading`, `context`, `execution`, `error_codes`, `success_criteria`.
36
+
37
+ **Output boundary**: ALL file writes MUST target `~/.maestro/overlays/` (overlay JSON + docs) only. Command file patching is handled by `maestro overlay add` — this skill NEVER modifies `.claude/commands/*.md` directly.
36
38
  </context>
37
39
 
40
+ <invariants>
41
+ 1. **Non-invasive** — overlays MUST use hashed HTML-comment markers for injection; NEVER edit command file content directly outside the overlay system
42
+ 2. **Idempotent** — re-running `maestro overlay apply` with the same overlay JSON MUST produce no file changes
43
+ 3. **Creation only** — this skill MUST only create overlays; listing and removal are handled by `maestro overlay list` (ink TUI)
44
+ 4. **Pristine source preferred** — injection point analysis MUST read from `$PKG_ROOT/.claude/commands/` (untouched originals) first, fall back to `~/.claude/commands/` only if pristine unavailable
45
+ 5. **User approval before write** — overlay JSON MUST be shown and approved via ask_question before writing to disk; NEVER auto-install without confirmation
46
+ 6. **Chain skip option mandatory** — if a skill chain is configured, the injected content MUST include a "Skip" option in ask_question; NEVER force the user into a chain
47
+ </invariants>
48
+
38
49
  <execution>
39
50
  ### 1. Parse user intent
40
51
 
@@ -68,8 +68,19 @@ $ARGUMENTS — template slug/path, or flags.
68
68
  "last_checkpoint": null
69
69
  }
70
70
  ```
71
+
72
+ **Output boundary**: ALL file writes MUST target `.workflow/.maestro/player-*/` (session status.json + step outputs) only. Template files (`~/.maestro/templates/workflows/`) are read-only. NEVER modify source code or `.claude/commands/` files.
71
73
  </context>
72
74
 
75
+ <invariants>
76
+ 1. **Resume-safe** — status.json MUST be updated after every step change; an interrupted session MUST be resumable from the last checkpoint via `-c`
77
+ 2. **One step at a time** — execution loop MUST process steps sequentially in topological order; parallel steps share a batch index but NEVER run concurrently within the player
78
+ 3. **CLI nodes async** — cli-type nodes MUST use `run_command(run_in_background: true)` + STOP pattern; NEVER block the main thread on delegate execution
79
+ 4. **Templates read-only** — player MUST NOT modify template JSON files; runtime state belongs in status.json only
80
+ 5. **Failure requires user decision** — on step failure without explicit `on_fail`, player MUST prompt via ask_question (Retry/Skip/Abort); NEVER silently skip or auto-abort
81
+ 6. **Reference resolution at runtime** — `{N-xxx.field}` and `{prev_*}` references MUST be resolved at execution time from status.json step results, NEVER pre-resolved during init
82
+ </invariants>
83
+
73
84
  <state_machine>
74
85
 
75
86
  <states>
@@ -41,9 +41,38 @@ Parse for:
41
41
  - Browse: `maestro search --category coding`
42
42
  - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
43
43
  3. All are optional — proceed without if unavailable.
44
+
45
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/` (task directory, plan.json, summaries) and modified source files as defined in plan.json tasks. State.json scratch entry is implicit workflow tracking.
44
46
  </context>
45
47
 
48
+ <invariants>
49
+ 1. **Atomic commits** — each task execution MUST produce a commit with only the files modified by that task; NEVER stage unrelated files
50
+ 2. **Evidence-based summaries** — task summaries MUST include concrete evidence (files changed, tests run, commands executed); NEVER accept "task completed successfully" as a summary
51
+ 3. **Plan before execute** — plan.json MUST be written before any task execution begins; NEVER skip planning even for single-task workflows
52
+ 4. **Scratch isolation** — all workflow artifacts MUST live under `.workflow/scratch/{task-dir}/`; NEVER write workflow metadata outside this directory
53
+ 5. **Commit confirmation** — staged files and commit message MUST be shown via ask_question before committing (unless `-y`); NEVER auto-commit without user awareness
54
+ </invariants>
55
+
46
56
  <execution>
57
+
58
+ ### Phase Gates (MANDATORY, BLOCKING)
59
+
60
+ **GATE 1: Setup → Planning**
61
+ - REQUIRED: Task description parsed and scratch directory created.
62
+ - REQUIRED: Coding specs loaded (optional but attempted).
63
+ - BLOCKED if: no task description (E001) or scratch directory creation failed (E002).
64
+
65
+ **GATE 2: Planning → Execution**
66
+ - REQUIRED: plan.json written with task definitions.
67
+ - REQUIRED: --discuss decisions extracted and recorded (if flag set).
68
+ - BLOCKED if: plan.json missing or empty.
69
+
70
+ **GATE 3: Execution → Completion**
71
+ - REQUIRED: All tasks executed with `.summaries/TASK-*-summary.md` written per task.
72
+ - REQUIRED: Each summary contains concrete evidence of completion.
73
+ - REQUIRED: --full verification passed (if flag set).
74
+ - BLOCKED if: any task summary missing or lacking evidence.
75
+
47
76
  Follow '~/.maestro/workflows/quick.md' completely.
48
77
 
49
78
  ### Artifact Verification (before completion)
@@ -42,6 +42,8 @@ Remaining → intent
42
42
  | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
43
43
  | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
44
44
  | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
45
+
46
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/` (results, ralph-compatible artifacts). When inside a ralph session, writes target the corresponding step's scratch directory. NEVER modify source code, workflow scripts (`~/.maestro/workflows/swarm/`), or `.claude/commands/` files.
45
47
  </context>
46
48
 
47
49
  <state_machine>
@@ -195,6 +197,29 @@ Workflow 返回 JSON 后:
195
197
  6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
196
198
  </invariants>
197
199
 
200
+ <execution>
201
+
202
+ ### Phase Gates (MANDATORY, BLOCKING)
203
+
204
+ **GATE 1: Parse → Route**
205
+ - REQUIRED: Intent text or `--script` flag parsed successfully.
206
+ - BLOCKED if: no intent and no `--script` (E001).
207
+
208
+ **GATE 2: Route → Context Assembly**
209
+ - REQUIRED: Target script resolved unambiguously (single match or user-selected from candidates).
210
+ - BLOCKED if: ambiguous routing without user resolution (E002).
211
+
212
+ **GATE 3: Context → Dispatch**
213
+ - REQUIRED: Args payload assembled with all required fields for target script.
214
+ - REQUIRED: Script file exists at `~/.maestro/workflows/swarm/{script}.js`.
215
+ - BLOCKED if: script file not found (E003) or required args missing.
216
+
217
+ **GATE 4: Dispatch → Ingest**
218
+ - REQUIRED: Workflow execution completed (success or partial results available).
219
+ - BLOCKED if: Workflow execution failed entirely (E004) — offer `--resume`.
220
+
221
+ </execution>
222
+
198
223
  <appendix>
199
224
 
200
225
  ### 与 Ralph 集成
@@ -37,8 +37,37 @@ $ARGUMENTS — Tool name, keyword, or --category filter
37
37
  Empty arguments enters interactive mode: list all tools for user selection.
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Confirmation before execution** — MUST ask_question before executing tool steps; NEVER auto-execute without user consent
42
+ 2. **Sequential step execution** — steps MUST be executed in defined order; NEVER skip or reorder steps unless user explicitly requests skip
43
+ 3. **Blocker escalation** — step failure MUST be reported to user with retry/skip/abort options; NEVER silently skip failed steps
44
+ 4. **Read-only tool definition** — tool execution MUST NOT modify the tool's knowhow document or spec entry; only the target codebase is modified per tool steps
45
+ 5. **Progress feedback** — each completed step MUST report `[Step N/M] done — <step_name>`; NEVER execute silently
46
+ 6. **Output boundary** — file writes are governed by the individual tool's step definitions. This command itself writes NO files beyond what the loaded tool prescribes
47
+ </invariants>
48
+
40
49
  <execution>
41
50
 
51
+ ### Phase Gates (MANDATORY, BLOCKING)
52
+
53
+ **GATE 1: Parse → Load**
54
+ - REQUIRED: Tool name, keyword, or --category parsed from arguments (or empty for interactive mode).
55
+ - BLOCKED if: invalid category value.
56
+
57
+ **GATE 2: Load → Confirm**
58
+ - REQUIRED: Exactly one tool resolved (direct match or user selection from candidates).
59
+ - REQUIRED: Tool document loaded and steps extracted (ref entries expanded via `maestro load --type knowhow`).
60
+ - BLOCKED if: E001 (no match found), E002 unresolved (multiple matches without user selection).
61
+
62
+ **GATE 3: Confirm → Execute**
63
+ - REQUIRED: User confirmed execution mode via ask_question (execute as-is / adjust / view only).
64
+ - BLOCKED if: user selects "View only" — display steps and END without execution.
65
+
66
+ **GATE 4: Execute → Report**
67
+ - REQUIRED: All steps attempted (completed, skipped with user approval, or aborted by user).
68
+ - REQUIRED: Results collected for each step (success/skip/fail).
69
+ - BLOCKED if: user chose abort mid-execution — report partial results and END.
70
+
42
71
  ### Step 1: Load Tool
43
72
 
44
73
  **By name**:
@@ -37,8 +37,37 @@ $ARGUMENTS — Intent description
37
37
  ```
38
38
  </context>
39
39
 
40
+ <invariants>
41
+ 1. **Schema validation** — tool knowhow document MUST include `tool: true`, `category`, `keywords`, and `summary` in YAML frontmatter; missing fields → reject write
42
+ 2. **No duplicate names** — tool title MUST be unique within its category; duplicate detection → E002 warning with overwrite/optimize confirmation
43
+ 3. **Category required** — every tool MUST declare exactly one category from: coding, test, review, arch, debug; empty category → E003
44
+ 4. **Confirmation gate** — MUST ask_question before writing knowhow document and spec ref entry; NEVER persist without user confirmation
45
+ 5. **Promote is in-place** — promote mode MUST update existing knowhow frontmatter via `maestro wiki update`; NEVER recreate the document
46
+ 6. **Output boundary** — ALL file writes MUST target .workflow/knowhow/ (tool documents) and .workflow/specs/ (ref entries via maestro spec add) only. NEVER modify source code or files outside these paths
47
+ 7. **Description format** — first line after `### Title` MUST state "Use when ..." (usage timing); this is critical for ref entry summary visibility in spec-load
48
+ </invariants>
49
+
40
50
  <execution>
41
51
 
52
+ ### Phase Gates (MANDATORY, BLOCKING)
53
+
54
+ **GATE 1: Parse → Gather**
55
+ - REQUIRED: Mode determined (extract/generate/optimize/promote) from argument parsing.
56
+ - REQUIRED: For optimize/promote modes, target tool/document exists and is loadable.
57
+ - BLOCKED if: empty args without user response to ask_question.
58
+
59
+ **GATE 2: Gather → Write**
60
+ - REQUIRED: Tool name, category, and usage timing confirmed.
61
+ - REQUIRED: Steps extracted or generated (extract: ≥1 step, generate: user-confirmed scope).
62
+ - REQUIRED: Inline vs ref mode decided based on step count.
63
+ - REQUIRED: User confirmed via ask_question (title, category, keywords, summary, step count).
64
+ - BLOCKED if: E001 (.workflow/specs/ not initialized), E003 (no category), user cancels.
65
+
66
+ **GATE 3: Write → Verify**
67
+ - REQUIRED: Knowhow document written with `tool: true` frontmatter (or updated in-place for promote).
68
+ - REQUIRED: Spec ref entry registered (if user confirmed).
69
+ - BLOCKED if: write failed or spec add returned error.
70
+
42
71
  ### Step 1: Intent Detection
43
72
 
44
73
  Parse $ARGUMENTS to determine mode:
@@ -34,8 +34,19 @@ Flags:
34
34
  - `--package-name <name>`: Package name for reference output (default: auto-generated from source directory)
35
35
  - `--output-dir <path>`: Output directory for reference package (default: `.workflow/reference_style`)
36
36
  - `--overwrite`: Allow overwriting existing package directory
37
+
38
+ **Output boundary**: ALL file writes MUST target the `--output-dir` path (default: `.workflow/reference_style/`) for reference packages, and `.workflow/knowhow/` for knowledge assets (via `codify-to-knowhow`). NEVER modify the source directory being analyzed.
37
39
  </context>
38
40
 
41
+ <invariants>
42
+ 1. **Source read-only** — the source path being analyzed MUST NOT be modified; extraction is purely read-only
43
+ 2. **Phase-sequential loading** — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly
44
+ 3. **User confirmation before knowhow** — Phase 3→4 gate MUST present ask_question before generating knowledge assets; NEVER auto-proceed to knowhow generation
45
+ 4. **Overwrite protection** — existing package directory MUST NOT be overwritten without `--overwrite` flag (E003)
46
+ 5. **Artifact completeness** — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification
47
+ 6. **Token-first extraction** — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation
48
+ </invariants>
49
+
39
50
  <execution>
40
51
  ## 1. Load UI Specs
41
52
 
@@ -32,6 +32,8 @@ Remaining → intent
32
32
  **Library locations:**
33
33
  - Fixed scripts: `~/.maestro/workflows/swarm/wf-*.js`
34
34
  - Dynamic scripts: `~/.maestro/workflows/dynamic/uwf-*.js`
35
+
36
+ **Output boundary**: ALL file writes MUST target `~/.maestro/workflows/dynamic/` (generated scripts) and `.workflow/scratch/{YYYYMMDD}-uwf-*/` (execution results). Fixed scripts at `~/.maestro/workflows/swarm/` are read-only. NEVER modify source code or `.claude/commands/` files.
35
37
  </context>
36
38
 
37
39
  <state_machine>
@@ -508,6 +510,36 @@ Findings: ${digest}
508
510
  12. **无反斜杠路径** — 字符串中路径用正斜杠(`\u`、`\a` 等会被解析为转义序列)
509
511
  </invariants>
510
512
 
513
+ <execution>
514
+
515
+ ### Phase Gates (MANDATORY, BLOCKING)
516
+
517
+ **GATE 1: Parse → Scan**
518
+ - REQUIRED: Intent text or `--from`/`--resume` flag parsed.
519
+ - BLOCKED if: no intent and no flags (E001).
520
+
521
+ **GATE 2: Scan → Design/Execute**
522
+ - REQUIRED: Library scan completed (both `swarm/` and `dynamic/` directories).
523
+ - REQUIRED: User decision if matches found (reuse existing vs generate new).
524
+ - BLOCKED if: scan fails to read script directories.
525
+
526
+ **GATE 3: Design → Generate**
527
+ - REQUIRED: Task decomposition completed with work_items, decision_points, data_flow.
528
+ - REQUIRED: Phase orchestration and adversarial pattern selection determined by depth.
529
+ - BLOCKED if: task cannot be decomposed (E002).
530
+
531
+ **GATE 4: Generate → Execute**
532
+ - REQUIRED: Script written to `~/.maestro/workflows/dynamic/uwf-{slug}.js`.
533
+ - REQUIRED: `node --check` syntax validation passed.
534
+ - REQUIRED: User confirmation via ask_question (unless resuming).
535
+ - BLOCKED if: syntax validation fails after 2 retries (E003).
536
+
537
+ **GATE 5: Execute → Persist**
538
+ - REQUIRED: Workflow execution completed via `scriptPath` invocation.
539
+ - BLOCKED if: Workflow execution failed (E004) — offer `--resume`.
540
+
541
+ </execution>
542
+
511
543
  <appendix>
512
544
 
513
545
  ### 使用示例
@@ -568,3 +600,30 @@ universal-workflow 扫描时会同时检查 swarm/ 和 dynamic/ 目录,
568
600
  | E005 | 持久化失败 | 展示脚本内容,让用户手动保存 |
569
601
 
570
602
  </appendix>
603
+
604
+ <error_codes>
605
+ | Code | Severity | Condition | Recovery |
606
+ |------|----------|-----------|----------|
607
+ | E001 | error | No intent and no --from/--resume flag | Prompt user for intent text |
608
+ | E002 | error | Task decomposition failed — cannot identify work_items | Require more specific intent description |
609
+ | E003 | error | Generated script syntax error after 2 retries | Show script content + error for manual fix |
610
+ | E004 | error | Workflow execution failed | Show error, offer --resume with runId |
611
+ | E005 | error | Script persistence failed (filesystem write error) | Show script content for manual save |
612
+ | W001 | warning | No matching scripts found in library scan | Proceed directly to S_DESIGN |
613
+ | W002 | warning | Adversarial gate confidence < 50% | Flag low-confidence decision, suggest --depth deep |
614
+ </error_codes>
615
+
616
+ <success_criteria>
617
+ - [ ] Intent parsed and flags extracted (--name, --depth, --dry-run, --from, --resume)
618
+ - [ ] Library scan completed across both swarm/ and dynamic/ directories
619
+ - [ ] User decision captured if matching scripts found (reuse vs generate)
620
+ - [ ] Task decomposition produced: work_items, decision_points, data_flow
621
+ - [ ] Adversarial pattern selected per decision_point according to depth level
622
+ - [ ] Blueprint presented to user with estimated agent count
623
+ - [ ] Script generated as pure JavaScript with all 12 generation rules enforced
624
+ - [ ] `node --check` syntax validation passed
625
+ - [ ] User confirmation obtained before execution (unless --resume)
626
+ - [ ] Workflow executed via scriptPath (not inline script string)
627
+ - [ ] Script persisted to `~/.maestro/workflows/dynamic/uwf-{slug}.js`
628
+ - [ ] Completion summary displayed with reuse/resume commands
629
+ </success_criteria>
@@ -29,10 +29,38 @@ $ARGUMENTS — optional flags.
29
29
  - `update-v{TO}-setup.md` — post-migration setup for version {TO}
30
30
 
31
31
  **Schema registry:** `src/migrations/` — handles all intermediate version bumps automatically
32
+
33
+ **Output boundary**: ALL file writes MUST target `.workflow/state.json` (version bump), `.workflow/state.json.backup-*` (backup), and `.workflow/` config files touched by version-specific setup. NEVER modify source code or `src/migrations/` files.
32
34
  </context>
33
35
 
36
+ <invariants>
37
+ 1. **Backup before migration** — a timestamped backup of `.workflow/state.json` MUST be created before any schema migration runs; NEVER execute migration without backup
38
+ 2. **Idempotent** — running update when already on latest version MUST be a no-op (display "up to date"); NEVER re-apply migrations
39
+ 3. **Confirmation before execute** — migration diff MUST be displayed and user MUST confirm via ask_question before execution (unless `--force`); NEVER silently apply schema changes
40
+ 4. **Migration diff always visible** — even with `--force`, the migration diff MUST be displayed for audit visibility; NEVER skip diff display
41
+ 5. **Restore path on failure** — if migration fails, the backup restore command MUST be displayed; NEVER leave user without recovery instructions
42
+ 6. **Sequential migration** — all intermediate version steps MUST be applied in order by the schema registry; NEVER skip intermediate versions
43
+ </invariants>
44
+
34
45
  <execution>
35
46
 
47
+ ### Phase Gates (MANDATORY, BLOCKING)
48
+
49
+ **GATE 1: Detect → Check**
50
+ - REQUIRED: Current version read from `.workflow/state.json`.
51
+ - BLOCKED if: state.json missing or unreadable (E001).
52
+
53
+ **GATE 2: Check → Execute**
54
+ - REQUIRED: Dry-run migration check completed; target version identified.
55
+ - REQUIRED: User confirmation via ask_question (unless `--force`).
56
+ - BLOCKED if: already up to date (display message and exit) or user cancels.
57
+
58
+ **GATE 3: Execute → Summary**
59
+ - REQUIRED: Backup created at `.workflow/state.json.backup-v{current}-{timestamp}`.
60
+ - REQUIRED: Schema migration completed successfully.
61
+ - REQUIRED: Version-specific setup doc followed (if exists).
62
+ - BLOCKED if: migration failed — display restore command and exit.
63
+
36
64
  ### Step 1: Detect Version
37
65
 
38
66
  ```
@@ -105,6 +133,16 @@ Next steps:
105
133
 
106
134
  </execution>
107
135
 
136
+ <error_codes>
137
+ | Code | Severity | Condition | Recovery |
138
+ |------|----------|-----------|----------|
139
+ | E001 | error | `.workflow/state.json` not found or unreadable | Run `/maestro-init` first |
140
+ | E002 | error | Schema migration failed (npx tsx returned error) | Display backup restore command: `cp .workflow/state.json.backup-* .workflow/state.json` |
141
+ | E003 | error | Version-specific setup doc failed to execute | Manual setup: read `~/.maestro/workflows/updates/update-v{target}-setup.md` |
142
+ | W001 | warning | No version-specific setup doc found for target version | Proceed without setup; schema migration alone is sufficient |
143
+ | W002 | warning | `--setup-only` but no setup script exists for current version | Display message and exit |
144
+ </error_codes>
145
+
108
146
  <success_criteria>
109
147
  - [ ] Current version detected from state.json
110
148
  - [ ] Schema migrations run automatically (no manual intermediate steps)
@@ -46,13 +46,42 @@ $ARGUMENTS -- optional flags.
46
46
  - `.workflow/codebase/` -- target directory (will be cleared and rebuilt)
47
47
  - `.workflow/codebase/doc-index.json` -- generated documentation index
48
48
  - `.workflow/codebase/knowledge-graph.json` -- Knowledge Graph with nodes, edges, layers, and tour (generated by `maestro kg index`)
49
+
50
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/`, `.workflow/state.json`, or `.workflow/project.md` (Tech Stack section only). NEVER modify source code or files outside these paths.
49
51
  </context>
50
52
 
53
+ <invariants>
54
+ 1. **Destructive with confirmation** — rebuild clears `.workflow/codebase/` entirely; MUST confirm with user unless `--force` is set
55
+ 2. **Commit confirmation** — git commit MUST be confirmed by user unless `--force` is set; `--skip-commit` bypasses commit entirely
56
+ 3. **Partial failure tolerance** — if 1-3 mapper agents fail, proceed with partial results (W001); only abort if all 4 fail (E002)
57
+ 4. **Focus scoping** — when `--focus <area>` is set, MUST only regenerate docs relevant to that scope; leave unrelated docs untouched
58
+ 5. **State update** — MUST update state.json with rebuild timestamp on completion
59
+ 6. **KG pipeline mandatory** — MUST run `maestro kg index` after doc regeneration; KG validation failure is non-fatal (W003)
60
+ </invariants>
61
+
51
62
  <execution>
52
63
  Follow '~/.maestro/workflows/codebase-rebuild.md' completely.
53
64
 
54
65
  **When `--focus <area>` is set:** pass the area string to each mapper agent as scoping context; only regenerate the docs relevant to that scope (leave others untouched unless missing).
55
66
 
67
+ ### Phase Gates (MANDATORY, BLOCKING)
68
+
69
+ **GATE 1: Confirmation → Mapping** (Pre-flight → Agent spawn)
70
+ - REQUIRED: `.workflow/` initialized (E001 if missing).
71
+ - REQUIRED: User confirmed rebuild (or `--force` set). W002 if existing docs found.
72
+ - BLOCKED if user declines confirmation.
73
+
74
+ **GATE 2: Mapping → KG Pipeline** (Agent results → Knowledge Graph)
75
+ - REQUIRED: At least 1 of 4 mapper agents returned valid results.
76
+ - REQUIRED: All output files written to `.workflow/codebase/`.
77
+ - REQUIRED: doc-index.json generated and valid.
78
+ - BLOCKED if all 4 mapper agents failed (E002).
79
+
80
+ **GATE 3: KG Pipeline → Commit** (Knowledge Graph → Git)
81
+ - REQUIRED: `maestro kg index` executed (W003 if validation fails — non-blocking).
82
+ - REQUIRED: state.json updated with rebuild timestamp.
83
+ - REQUIRED: If not `--skip-commit`: user confirmed git commit (or `--force` set).
84
+ - BLOCKED if state.json update fails.
56
85
  </execution>
57
86
 
58
87
  <completion>
@@ -60,8 +60,20 @@ Arguments: $ARGUMENTS
60
60
  - `.workflow/project.md`
61
61
 
62
62
  使用 `maestro timeline` CLI 构建统一的 git+session 时间线。
63
+
64
+ **Output boundary**: ALL file writes MUST target `.workflow/` metadata files (specs, codebase docs, roadmap.md, state.json, issues.jsonl) or `.workflow/.trash/drift-realign-{timestamp}/` (backups) or `.workflow/.drift-realign/` (session details). NEVER modify source code files.
63
65
  </context>
64
66
 
67
+ <invariants>
68
+ 1. **Code-as-Truth** — 代码是唯一真理源;当文档说 X 但代码做 Y 时,文档漂移,NEVER 反向修改代码来匹配文档
69
+ 2. **Backup before mutate** — MUST create backup tarball in `.workflow/.trash/` before any file modification (E005 if backup fails)
70
+ 3. **Never modify source code** — drift-realign only updates `.workflow/` metadata; source code files are read-only
71
+ 4. **Mutual exclusion** — `--report` 与 `--auto-archive` 互斥;同时传入 MUST trigger E006
72
+ 5. **Auto-depth escalation** — `drift_window` > 180 天 MUST auto-upgrade to `--depth deep` with W002 warning
73
+ 6. **Audit trail** — every triage decision MUST be logged in `drift-log.jsonl` with finding ID, action, and timestamp
74
+ 7. **Rebuild trigger** — codebase scope 的 3+ P0 finding MUST auto-trigger `/quality-sync --full` after triage
75
+ </invariants>
76
+
65
77
  <execution>
66
78
  Follow `~/.maestro/workflows/drift-realign.md` Stages 1-9 in order.
67
79
 
@@ -39,17 +39,41 @@ Arguments: $ARGUMENTS
39
39
  - `-y` / `--yes` — Skip confirmation prompts for all write operations (artifact selection, routing decisions, store writes). Useful for CI or batch harvesting.
40
40
 
41
41
  Additional flags, source registry (scan paths), and storage locations defined in workflow harvest.md.
42
+
43
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/`, `.workflow/specs/`, `.workflow/issues/`, `.workflow/wiki/`, `.workflow/harvest/`, or `.workflow/state.json` only. NEVER modify source code, source artifacts, or files outside these paths.
42
44
  </context>
43
45
 
46
+ <invariants>
47
+ 1. **Read-only until routing** — extraction and classification happen in-memory; no files written until Stage 6
48
+ 2. **Never modify source artifacts** — harvest is purely extractive; source files remain untouched
49
+ 3. **Dedup before write** — MUST check harvest-log.jsonl and existing stores before each write to prevent duplicates
50
+ 4. **Source tagging** — MUST set `source: "harvest"` on every issues.jsonl row so concurrent writers can be distinguished
51
+ 5. **Conflict pre-check on spec routing** — when routing to spec, MUST compare against existing specs with same keywords/category; set `confidence="low"` and log conflict note if semantic conflict detected
52
+ 6. **Provenance tracking** — every routed item MUST be logged in harvest-log.jsonl with fragment ID, target store, and timestamp
53
+ 7. **Dry-run safety** — `--dry-run` MUST NOT write any files; preview only
54
+ </invariants>
55
+
44
56
  <execution>
45
57
  Follow '~/.maestro/workflows/harvest.md' Stages 1-8 in order.
46
58
 
47
- **Key invariants:**
48
- 1. **Read-only until Stage 6** — extraction and classification happen in-memory.
49
- 2. **Dedup before write** check harvest-log.jsonl and existing stores before each write.
50
- 3. **Never modify source artifacts** harvest is purely extractive.
51
- 4. **Dedup contract with parallel writers** — when appending to `issues.jsonl`, set `source: "harvest"` on each row so concurrent writers (e.g. `manage-issue-discover` with `source: "discover"`) can be distinguished and deduplicated.
52
- 5. **Conflict pre-check on spec routing** when routing to spec (Stage 6b), compare new entry against existing specs with same keywords/category. If semantic conflict detected, set `confidence="low"` on the new entry and log conflict note. Use `maestro spec conflict mark` if contradiction is clear.
59
+ ### Phase Gates (MANDATORY, BLOCKING)
60
+
61
+ **GATE 1: Discovery → Extraction** (Stages 1-3 Stage 4)
62
+ - REQUIRED: Source artifacts discovered and mode resolved (scan/session/path).
63
+ - REQUIRED: User selected artifact(s) to harvest (or auto-selected via session/path mode, or `-y`).
64
+ - BLOCKED if no harvestable artifacts found (W001) or invalid source (E004/E005).
65
+
66
+ **GATE 2: Extraction → Routing** (Stage 4 → Stage 5-6)
67
+ - REQUIRED: All files in selected artifacts loaded and parsed.
68
+ - REQUIRED: Knowledge fragments extracted with category, confidence, and tags.
69
+ - REQUIRED: Fragments filtered by `--min-confidence`.
70
+ - BLOCKED if extraction produces zero fragments.
71
+
72
+ **GATE 3: Routing → Write** (Stage 6 → Stage 7-8)
73
+ - REQUIRED: Routing classification applied (auto or forced by `--to`).
74
+ - REQUIRED: Dedup check passed against harvest-log.jsonl and existing stores.
75
+ - REQUIRED: If `--dry-run`: preview displayed, no files written — GATE blocks further writes.
76
+ - BLOCKED if dedup check fails or store paths unresolvable.
53
77
 
54
78
  Extraction patterns, classification rules, routing infrastructure, and fragment ID scheme defined in workflow harvest.md.
55
79