pi-maestro-flow 0.2.0 → 0.3.1

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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +18 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -5
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -2
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,631 @@
1
+ # Execute Workflow
2
+
3
+ Wave-based parallel execution with atomic commits, breakpoint resume, built-in verification gate, and optional sync/reflection. Execute per-plan, not per-phase.
4
+
5
+ ---
6
+
7
+ ## Iron Law
8
+
9
+ NEVER mark a task "completed" without running convergence criteria checks. Every completion requires:
10
+ 1. Run convergence criteria checks
11
+ 2. Confirm output matches task definition
12
+ 3. Evidence of verification in the task summary
13
+
14
+ ---
15
+
16
+ ## Plan Resolution
17
+
18
+ ```
19
+ Input: [phase] argument OR --dir <path>
20
+
21
+ Worktree scope check: if .workflow/worktree-scope.json exists, reject <phase> not in scope.owned_phases
22
+ Auto-bootstrap: create .workflow/state.json if missing
23
+
24
+ Resolve PLAN_DIRS:
25
+ --dir <path> → single plan, validate plan.json exists
26
+ no arguments → all pending plans: state.json artifacts where type=plan, status=completed,
27
+ current milestone, no matching EXC artifact; sorted by phase order, adhoc last
28
+ <phase number> → pending plans for that phase only (same filter + phase match)
29
+ If empty: ERROR E001 "No pending plans found"
30
+
31
+ For each PLAN_DIR in PLAN_DIRS (sequential):
32
+ Execute plan, register EXC artifact, extract incremental learnings
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Flag Processing
38
+
39
+ | Flag | Effect |
40
+ |------|--------|
41
+ | `--auto-commit` | Override config: commit after each task completion |
42
+ | `--method agent\|codex\|gemini\|cli\|auto` | Override execution method (default: config.json.execution.method) |
43
+ | `--executor <tool>` | Default CLI tool: gemini\|codex\|qwen\|opencode\|claude (default: first enabled in cli-tools.json) |
44
+ | `--dir <path>` | Use arbitrary directory instead of phase resolution (skip roadmap validation) |
45
+ | `--skip-verify` | Skip E2.7 verification gate (trust execution output) |
46
+ | `-y` | Auto mode — skip ALL interactive questions (E0.5 options, inter-wave confirmations, blocked-task prompts) |
47
+
48
+ ---
49
+
50
+ ## E0.5: Execution Options Confirmation
51
+
52
+ ### Skip conditions
53
+
54
+ - `-y` flag → use resolved defaults, skip prompt (applies to ALL interactive questions throughout execution, not just E0.5)
55
+ - `executionContext.executionMethod` already set → skip (confirmed in /maestro-plan)
56
+
57
+ ### Pre-step: Load tool config
58
+
59
+ ```
60
+ Run: maestro delegate-config show --json
61
+ Parse: { tools, roles } — extract enabled tool names and domain tags
62
+ Build dynamic options from enabled tools (exclude agent which is always available)
63
+ ```
64
+
65
+ ### Tool Call
66
+
67
+ Build AskUserQuestion dynamically from enabled tools:
68
+
69
+ ```
70
+ // availableTools = enabled tools from delegate-config (e.g. ["gemini", "claude", "codex"])
71
+ // frontendTool = first tool with "frontend" tag, fallback first enabled
72
+ // backendTool = first tool with "backend" tag, fallback first enabled
73
+
74
+ AskUserQuestion({
75
+ questions: [
76
+ {
77
+ question: "How should tasks be executed? Select one, or choose Other to specify per-domain rules (e.g. '前端gemini 后端codex 其余agent')",
78
+ header: "Executor",
79
+ multiSelect: false,
80
+ options: [
81
+ { label: "Auto (Recommended)", description: `Per-task domain routing: frontend→${frontendTool}, backend→${backendTool}, general→agent` },
82
+ { label: "Agent", description: "Claude Code agent for all tasks (fastest)" },
83
+ // One option per enabled CLI tool:
84
+ ...availableTools.map(t => ({ label: t, description: `${t} CLI for all tasks` }))
85
+ ]
86
+ },
87
+ {
88
+ question: "Run code review after execution?",
89
+ header: "Review",
90
+ multiSelect: false,
91
+ options: [
92
+ { label: "Skip", description: "No code review" },
93
+ ...availableTools.map(t => ({ label: `${t} Review`, description: `${t} CLI: git diff quality review` }))
94
+ ]
95
+ },
96
+ {
97
+ question: "Verification gate? (external model checks convergence + structure + anti-patterns)",
98
+ header: "Verify",
99
+ multiSelect: false,
100
+ options: [
101
+ { label: "Auto (Recommended)", description: `Delegate to ${availableTools[0] || 'first enabled tool'} for convergence + 3-layer structure + anti-pattern check` },
102
+ ...availableTools.map(t => ({ label: t, description: `${t}: verification gate` })),
103
+ { label: "Skip", description: "No verification gate" }
104
+ ]
105
+ }
106
+ ]
107
+ })
108
+ ```
109
+
110
+ ### Parse response
111
+
112
+ **Question 1 (Executor):**
113
+
114
+ | Answer | executionMethod | domainRouting |
115
+ |--------|----------------|---------------|
116
+ | "Auto" | `"auto"` | `{ frontend: frontendTool, backend: backendTool, default: "agent" }` |
117
+ | "Agent" / tool name | that value | not used |
118
+ | Other text with domain rules | `"auto"` | Parse from user text |
119
+
120
+ Other text parsing — match tool names dynamically from enabled tools:
121
+
122
+ | User types | domainRouting |
123
+ |------------|---------------|
124
+ | `前端gemini 后端codex` | `{ frontend: "gemini", backend: "codex", default: "agent" }` |
125
+ | `backend agent, frontend gemini` | `{ frontend: "gemini", backend: "agent", default: "agent" }` |
126
+ | `all codex` | `{ default: "codex" }` |
127
+
128
+ **Question 2 (Review):** store as `codeReviewTool`
129
+
130
+ **Question 3 (Verify):**
131
+
132
+ | Answer | verificationTool |
133
+ |--------|-----------------|
134
+ | "Auto" | First enabled tool from config |
135
+ | Tool name | That tool |
136
+ | "Skip" | `"Skip"` |
137
+
138
+ `--skip-verify` flag overrides to `"Skip"`.
139
+
140
+ Store: `executionMethod`, `domainRouting`, `codeReviewTool`, `verificationTool`
141
+
142
+ ---
143
+
144
+ ## E1: Load Plan (per PLAN_DIR)
145
+
146
+ ### From executionContext handoff (preferred, first plan only)
147
+
148
+ ```
149
+ If executionContext is available in memory:
150
+ planObject = executionContext.planObject
151
+ explorations = executionContext.explorations
152
+ clarifications = executionContext.clarifications
153
+ executionMethod = E0.5 selection || --method flag || executionContext.executionMethod
154
+ defaultExecutor = --executor flag || executionContext.defaultExecutor
155
+ executorAssignments = executionContext.executorAssignments || {}
156
+ domainRouting = E0.5 domainRouting || executionContext.domainRouting || {}
157
+ codeReviewTool = E0.5 selection || executionContext.codeReviewTool || "Skip"
158
+ verificationTool = E0.5 selection || executionContext.verificationTool || "Auto"
159
+ Skip disk reload
160
+ ```
161
+
162
+ ### From disk (fallback / resume / subsequent plans)
163
+
164
+ ```
165
+ Read ${PLAN_DIR}/plan.json
166
+
167
+ executionMethod = E0.5 selection || --method flag || config.json.execution.method || "auto"
168
+ defaultExecutor = --executor flag || config.json.execution.default_executor || first enabled tool from delegate-config
169
+ executorAssignments = plan.json.executor_assignments || {}
170
+ domainRouting = E0.5 domainRouting || built from delegate-config domain tags (frontend→tag match, backend→tag match, default→"agent")
171
+ codeReviewTool = E0.5 selection || "Skip"
172
+ verificationTool = E0.5 selection || "Auto"
173
+ ```
174
+
175
+ ### Detect completed tasks (breakpoint resume)
176
+
177
+ ```
178
+ Scan .task/${task_id}.json for each task in plan.json.task_ids
179
+ Collect completed tasks; if any found, log resume status and advance to first wave with pending tasks
180
+ ```
181
+
182
+ ### Build wave execution queue
183
+
184
+ ```
185
+ Build execution_queue from plan.json.waves, including only waves with pending (non-completed) tasks
186
+ ```
187
+
188
+ ### Output
189
+ - In-memory: execution_queue, executionMethod, loaded task definitions
190
+
191
+ ---
192
+
193
+ ## E1.5: Load Project Specs
194
+
195
+ ```
196
+ # MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
197
+ specs_content = maestro spec load --category coding
198
+ ```
199
+
200
+ Pass specs_content to each executor agent in E2.
201
+
202
+ ---
203
+
204
+ ## E2: Wave Parallel Execution
205
+
206
+ ### Executor Resolution
207
+
208
+ Resolution priority: per-task assignment > explicit method > auto domain routing.
209
+
210
+ **Single executor mode** (executionMethod is agent/codex/gemini/cli): all tasks use that executor.
211
+
212
+ **Auto mode** (executionMethod is "auto"): route each task by domain using `domainRouting` map from E0.5.
213
+
214
+ For each task, judge its domain from the task definition (scope, file paths, action description):
215
+ - **frontend** — UI components, pages, styles, layouts, templates (.tsx/.jsx/.vue/.css/.html, scope contains ui/frontend/component/style/page/view)
216
+ - **backend** — API, server, database, services, algorithms (.go/.rs/.java/.py/.sql/.proto, scope contains api/backend/server/database/service/worker)
217
+ - **general** — mixed, .ts/.js only, config, tests, or unclear domain
218
+
219
+ Then look up `domainRouting[domain]`, falling back to `domainRouting.default` (which is "agent" if unset).
220
+
221
+ Log the routing decision per task before dispatch:
222
+
223
+ ```
224
+ TASK-001 [frontend] → gemini
225
+ TASK-002 [backend] → codex
226
+ TASK-003 [general] → agent
227
+ ```
228
+
229
+ ### Delegate Prompt Builder
230
+
231
+ ```
232
+ # Unified prompt for CLI backends (maestro delegate). Same task info as Agent path.
233
+ function buildDelegatePrompt(task_def, phase_context, specs_content, prior_summaries):
234
+ return """
235
+ PURPOSE: Implement task ${task_def.id}: ${task_def.title}; success = all convergence criteria pass
236
+ TASK: ${task_def.action} | Read existing code first | Verify convergence criteria after changes
237
+ MODE: write
238
+ CONTEXT: @${task_def.scope}/**/* | Phase: ${phase_context.goal}
239
+ EXPECTED: Working code changes, all convergence criteria verified, summary of what was done
240
+ CONSTRAINTS: Scope limited to task files | Follow project specs
241
+
242
+ ## Task Definition
243
+
244
+ **Scope**: ${task_def.scope} | **Action**: ${task_def.action}
245
+
246
+ ### Files
247
+ ${task_def.files.map(f => '- ' + f.path + ' → ' + f.target + ': ' + f.change).join('\n')}
248
+
249
+ ### Read First
250
+ ${task_def.read_first.map(f => '- ' + f).join('\n')}
251
+
252
+ ### Implementation Steps
253
+ ${task_def.implementation.map(s => '- ' + s).join('\n')}
254
+
255
+ ### Convergence Criteria
256
+ ${task_def.convergence.criteria.map(c => '- [ ] ' + c).join('\n')}
257
+
258
+ ### Reference
259
+ - Pattern: ${task_def.reference?.pattern || 'N/A'}
260
+ - Files: ${task_def.reference?.files?.join(', ') || 'N/A'}
261
+
262
+ ## Phase Context
263
+ - Goal: ${phase_context.goal}
264
+ - Success criteria: ${phase_context.success_criteria}
265
+
266
+ ## Project Specs
267
+ ${specs_content}
268
+
269
+ ## Prior Task Summaries
270
+ ${prior_summaries}
271
+ """
272
+ ```
273
+
274
+ ### Execution Loop
275
+
276
+ ```
277
+ For each wave in execution_queue (sequential):
278
+ Log wave start; update index.json (current_wave, started_at)
279
+ On first wave: set state.json.status = "executing" if not already
280
+
281
+ For each task_id in wave.tasks (parallel):
282
+ Mark task active in state.json (last-write-wins for parallel tasks)
283
+ Load .task/${task_id}.json; resolve executor
284
+
285
+ IF executor == "agent":
286
+ Spawn workflow-executor agent (fresh 200k context) with:
287
+ task definition, phase context, prior wave summaries, specs_content, context.md, analysis.md
288
+ Agent internally handles full lifecycle:
289
+ implement → verify convergence → auto-fix (max 3) → commit → write .summaries/${task_id}-summary.md → update .task/${task_id}.json status
290
+ (checkpoint if blocked)
291
+ Main flow: verify agent wrote summary + updated status, collect result
292
+
293
+ ELSE (CLI path via maestro delegate):
294
+ fixedId = "${PHASE_NUM || 'scratch'}-${PHASE_SLUG}-${task_id}"
295
+ Store fixedId in index.json.execution.delegate_ids[task_id]
296
+ Dispatch: maestro delegate "${prompt}" --to ${executor} --mode write --id ${fixedId}
297
+ Main flow post-dispatch: verify convergence criteria against file state
298
+ Main flow writes: .summaries/${task_id}-summary.md, update .task/${task_id}.json status, auto-commit if enabled
299
+
300
+ Collect result: { task_id, status, executor, summary_path, commit_hash, delegate_id }
301
+ Clear state.json.current_task_id
302
+
303
+ Wait for all wave tasks; update index.json (tasks_completed, commits)
304
+ If any blocked AND NOT -y flag: prompt user to continue or stop
305
+ Else: continue to next wave automatically (NEVER ask for confirmation between waves)
306
+ ```
307
+
308
+ ### Parallel Dispatch Rules
309
+
310
+ ```
311
+ All tasks in a wave dispatch in parallel (Agent + CLI mixed in single message).
312
+ Agent tasks: run_in_background: false | CLI tasks: run_in_background: true
313
+ Each task = one independent dispatch (never merge tasks into one delegate prompt)
314
+ ```
315
+
316
+ ### Deviation Rule
317
+
318
+ ```
319
+ Max 3 auto-fix attempts per task:
320
+ Agent path: handled internally by workflow-executor agent
321
+ CLI path: 1) --resume ${fixedId} → 2) simplified prompt → 3) fallback to agent; flag task as [LOW CONFIDENCE] (agent fallback used)
322
+
323
+ If all 3 fail: mark "blocked" with checkpoint in .task/${task_id}.json.meta.checkpoint
324
+ { attempt: 3, last_error, partial_files, executor, delegate_id: fixedId }
325
+ Continue wave (other tasks unaffected)
326
+ ```
327
+
328
+ ---
329
+
330
+ ## E2.5: Post-Wave Validation
331
+
332
+ ### Check 1: Summary Existence
333
+
334
+ ```
335
+ For each completed task: flag warning if .summaries/${task_id}-summary.md missing
336
+ → violation: { type: "missing_summary", severity: "warning", task_id, message }
337
+ ```
338
+
339
+ ### Check 2: Task Status Consistency
340
+
341
+ ```
342
+ Cross-check task status against wave_results from E2:
343
+ - Completed in .task/ but not in wave_results → warning "status_mismatch"
344
+ - Completed in wave_results but not in .task/ → critical "status_mismatch"
345
+ ```
346
+
347
+ ### Check 3: Tech Stack Constraint Compliance
348
+
349
+ ```
350
+ Extract tech_stack constraints from specs_content (allowed_languages, disallowed_imports, required_patterns)
351
+ If constraints exist:
352
+ Collect all files modified by completed tasks
353
+ Scan each for disallowed import patterns → critical "tech_stack_violation" per match
354
+ ```
355
+
356
+ ### Check 4: CLI Supplementary Validation (optional)
357
+
358
+ ```
359
+ IF no CLI tools enabled OR completed_tasks.length == 0: skip
360
+
361
+ modified_files = collect all files modified by completed tasks
362
+
363
+ Bash({
364
+ command: 'maestro delegate "PURPOSE: Validate execution output for semantic issues
365
+ TASK: Check for circular dependency introduction | Detect dead code / unused exports | Verify public API consistency (no breaking changes to existing exports)
366
+ MODE: analysis
367
+ CONTEXT: @${modified_files as glob}
368
+ EXPECTED: JSON { circular_deps: [{ cycle: [file...] }], dead_code: [{ file, line, symbol }], breaking_changes: [{ file, export_name, change_type }] }
369
+ CONSTRAINTS: Only check modified files and their direct importers | severity = critical for breaking_changes, warning for others
370
+ " --role analyze --mode analysis',
371
+ run_in_background: true
372
+ })
373
+ ```
374
+
375
+ **On callback:** Parse result. Append critical-severity items to violations list. Log warnings separately.
376
+
377
+ ### Gate Logic
378
+
379
+ ```
380
+ Log all warnings; log all critical violations
381
+ If any critical: set index.json.status = "blocked" with blocked_reason and violations, abort
382
+ If none critical: log "passed" and continue to E2.6
383
+ ```
384
+
385
+ ---
386
+
387
+ ## E2.6: Code Review (Optional)
388
+
389
+ ```
390
+ If codeReviewTool == "Skip": continue to E3
391
+
392
+ Dispatch review via maestro delegate (run_in_background: true):
393
+ --to ${codeReviewTool} --mode analysis
394
+ Prompt: review git diff (execution start → HEAD) for correctness, style, bugs
395
+ Rule: analysis-review-code-quality
396
+ Expected: severity-ranked issues with file:line references and fix suggestions
397
+
398
+ Wait for completion, log findings summary
399
+ ```
400
+
401
+ ---
402
+
403
+ ## E2.7: Verification Gate
404
+
405
+ **Skip if** `verificationTool == "Skip"` OR `--skip-verify` flag OR no completed tasks.
406
+
407
+ ### Step 1: Collect Verification Inputs
408
+
409
+ ```
410
+ modified_files = collect all files changed by completed tasks (from .summaries/ + git diff)
411
+ convergence_criteria = collect convergence.criteria from all completed .task/*.json
412
+ success_criteria = index.json.success_criteria (if exists)
413
+ must_haves = success_criteria || convergence_criteria aggregated
414
+ summaries_content = concatenate all .summaries/TASK-*-summary.md
415
+ ```
416
+
417
+ ### Step 2: Resolve Verification Tool
418
+
419
+ ```
420
+ IF verificationTool == "Auto": resolve to first enabled tool from delegate-config
421
+ ELSE: use specified tool name
422
+ ```
423
+
424
+ ### Step 3: Dispatch Verification (external model)
425
+
426
+ Single delegate call covers convergence review + structure verify + anti-pattern scan:
427
+
428
+ ```
429
+ Bash({
430
+ command: 'maestro delegate "PURPOSE: Verify execution output meets all convergence criteria and structural integrity; success = all criteria verified with file:line evidence
431
+ TASK:
432
+ 1. CONVERGENCE: For each criterion below, check if the actual code satisfies it — read the files, verify the behavior exists, report status with evidence
433
+ 2. STRUCTURE Layer 1 (Existence): Verify all expected output files exist on disk
434
+ 3. STRUCTURE Layer 2 (Substance): Verify files have real implementation — flag stubs, placeholders, TODO-only, empty returns
435
+ 4. STRUCTURE Layer 3 (Wiring): Verify files are imported and used by the system — flag orphaned files
436
+ 5. ANTI-PATTERNS: Scan modified files for TODO/FIXME/HACK, placeholder content, console.log/print debug statements, disabled tests
437
+ MODE: analysis
438
+ CONTEXT: @${modified_files as glob patterns}
439
+ EXPECTED: JSON {
440
+ convergence: [{ criterion: string, status: \"verified\"|\"failed\"|\"uncertain\", evidence: string }],
441
+ structure: {
442
+ existence: [{ path: string, status: \"exists\"|\"missing\" }],
443
+ substance: [{ path: string, status: \"real\"|\"stub\", evidence: string }],
444
+ wiring: [{ path: string, status: \"wired\"|\"orphaned\", importers: string[] }]
445
+ },
446
+ anti_patterns: [{ type: string, file: string, line: number, severity: \"blocker\"|\"warning\"|\"info\" }],
447
+ gaps: [{ id: string, type: string, severity: \"critical\"|\"high\"|\"medium\"|\"low\", description: string, fix_direction: string }],
448
+ overall: \"passed\"|\"gaps_found\"
449
+ }
450
+ CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line references | Do NOT assume — verify by reading code
451
+
452
+ ## Convergence Criteria (verify each one)
453
+ ${must_haves.map((c, i) => (i+1) + \". \" + c).join(\"\\n\")}
454
+
455
+ ## Modified Files
456
+ ${modified_files.join(\"\\n\")}
457
+
458
+ ## Task Summaries (executor self-reports — verify independently)
459
+ ${summaries_content}
460
+ " --to ${verificationTool} --mode analysis',
461
+ run_in_background: true
462
+ })
463
+ ```
464
+
465
+ ### Step 4: Process Results
466
+
467
+ ```
468
+ On callback:
469
+ Parse JSON result from delegate output
470
+
471
+ // Write verification.json (downstream compatibility for quality-review, quality-test, etc.)
472
+ Write ${PLAN_DIR}/verification.json:
473
+ {
474
+ "phase": PHASE_NUM,
475
+ "status": result.overall,
476
+ "verified_at": ISO_timestamp,
477
+ "verifier": verificationTool,
478
+ "must_haves": {
479
+ "truths": result.convergence,
480
+ "artifacts": [...result.structure.existence, ...result.structure.substance],
481
+ "key_links": result.structure.wiring
482
+ },
483
+ "gaps": result.gaps,
484
+ "antipatterns": result.anti_patterns,
485
+ "coverage_score": verified_count / total_count
486
+ }
487
+
488
+ IF result.overall == "passed":
489
+ Log "✓ Verification Gate: PASSED — all criteria verified by ${verificationTool}"
490
+ Continue to E3
491
+
492
+ IF result.overall == "gaps_found":
493
+ Log verification report with per-criterion status
494
+
495
+ // Auto-create issues from critical/high gaps
496
+ For each gap with severity critical|high:
497
+ Create issue in .workflow/issues/issues.jsonl:
498
+ id: "ISS-{YYYYMMDD}-{NNN}", status: "registered",
499
+ priority: severity_to_priority(gap.severity), source: "verification-gate",
500
+ phase_ref: PHASE_NUM, gap_ref: gap.id
501
+
502
+ // Gate decision
503
+ IF any critical gaps:
504
+ Set index.json.status = "verification_failed"
505
+ Log: "✗ Verification Gate: FAILED — {N} critical gaps. Run /maestro-plan --gaps to fix."
506
+ STOP pipeline (do not proceed to E3)
507
+ ELSE (medium/low only):
508
+ Log warnings, continue to E3
509
+ ```
510
+
511
+ ### Step 5: Register VRF Artifact
512
+
513
+ ```
514
+ IF verification ran (not skipped):
515
+ Create VRF artifact in state.json:
516
+ { id: "VRF-{next_id}", type: "verify", milestone, phase,
517
+ path: "${PLAN_DIR}/verification.json", status: result.overall == "passed" ? "completed" : "gaps_found",
518
+ depends_on: EXC_artifact.id, created_at, completed_at }
519
+ ```
520
+
521
+ ---
522
+
523
+ ## E3: Auto Sync
524
+
525
+ ```
526
+ If config.json.codebase.auto_sync_after_execute == true:
527
+ Trigger /workflow:sync logic:
528
+ 1. Detect changed files (git diff from execution start)
529
+ 2. Map changes to doc-index.json components/features
530
+ 3. Update affected entries
531
+ 4. Refresh tech-registry and feature-maps as needed
532
+ Else:
533
+ Log "Auto-sync disabled. MUST run /workflow:sync manually."
534
+ ```
535
+
536
+ ---
537
+
538
+ ## E4: Reflection (Optional)
539
+
540
+ ```
541
+ If config.json.workflow.reflection == true:
542
+ Review execution results:
543
+ - Which tasks completed smoothly?
544
+ - Which required auto-fix attempts?
545
+ - Any blocked tasks?
546
+ - Patterns observed?
547
+
548
+ Append to ${PLAN_DIR}/reflection-log.md:
549
+ ## Reflection - Wave Execution {timestamp}
550
+ - Strategy adjustments: [...]
551
+ - Patterns noted: [...]
552
+ - Blocked tasks: [...]
553
+
554
+ Update index.json.reflection:
555
+ rounds += 1
556
+ strategy_adjustments.push(new adjustments)
557
+ ```
558
+
559
+ ---
560
+
561
+ ## Final State Update
562
+
563
+ ```
564
+ If all tasks completed AND verification passed (or skipped):
565
+ index.json.status = "verified", set completed_at
566
+ Elif all tasks completed AND verification failed:
567
+ index.json.status = "verification_failed", set completed_at
568
+ Else:
569
+ index.json.status = "executing" (partial) → "Re-run /workflow:execute to resume"
570
+
571
+ Update index.json.updated_at
572
+ If NOT SCRATCH_MODE: sync state.json (status, clear current_task_id)
573
+ ```
574
+
575
+ ---
576
+
577
+ ## E5: Register Artifact & Extract Learnings (per PLAN_DIR)
578
+
579
+ ```
580
+ // Register EXC artifact
581
+ Find matching plan artifact in state.json; create EXC artifact:
582
+ { id: "EXC-{next_id padded to 3}", type: "execute", milestone, phase, scope,
583
+ path: plan_artifact.path, status: "completed", depends_on: plan_artifact.id,
584
+ harvested: false, created_at, completed_at }
585
+ Append to state.json.artifacts (atomic write)
586
+
587
+ // Incremental learning extraction
588
+ Read all .summaries/TASK-*-summary.md; extract strategy adjustments, patterns, pitfalls
589
+ Deduplicate against existing learnings (maestro spec load --category coding)
590
+ Append unique entries to .workflow/specs/learnings.md using <spec-entry> closed-tag format:
591
+ category="learning", keywords (3-5 terms), date, source="execute"
592
+
593
+ Mark artifact.harvested = true; write state.json (atomic)
594
+
595
+ // Domain knowledge note:
596
+ // E5 仅提取 incremental learnings (spec category=learning)。
597
+ // 完整的知识提取(constraints → spec, decisions → knowhow, terminology → domain glossary)
598
+ // 由 chain 末尾的 manage-harvest --auto 触发 finish-work 统一处理。
599
+ // Domain compact/expanded 注入是 hook 自动行为,execute 期间无需手动加载——
600
+ // 已注册术语通过 keyword-spec-injector 自动注入到 agent context 中。
601
+ ```
602
+
603
+ ---
604
+
605
+ ## Error Handling
606
+
607
+ | Error | Action |
608
+ |-------|--------|
609
+ | No pending plans found | Abort: "No pending plans. Run /workflow:plan first." |
610
+ | Plan directory not found | Abort: "Plan dir not found." |
611
+ | Task file missing | Skip task, log error, continue wave |
612
+ | Agent spawn fails | Retry once, then mark task as "blocked" |
613
+ | Delegate fails | Resume with `--resume ${fixedId}`, then fallback to agent; flag task as [LOW CONFIDENCE] (fallback agent) |
614
+ | Git commit fails | Log W0xx, mark task [LOW CONFIDENCE] (commit failed); do NOT mark fully completed until commit succeeds |
615
+ | All tasks in wave blocked | Stop execution, report blocked wave |
616
+
617
+ ---
618
+
619
+ ## Breakpoint Resume
620
+
621
+ ```
622
+ State tracked in index.json.execution:
623
+ tasks_completed, current_wave, commits, method, default_executor,
624
+ delegate_ids: { task_id: fixedId, ... }
625
+
626
+ Resume behavior (/workflow:execute <phase> re-run):
627
+ Check each .task/TASK-*.json status + delegate status for in-progress CLI tasks
628
+ CLI tasks: retrieve completed output or retry with --resume ${fixedId}
629
+ Build queue of remaining tasks, continue from next pending wave
630
+ No duplicate execution of completed tasks
631
+ ```