maestro-flow 0.4.9 → 0.4.10

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 (187) hide show
  1. package/.agy/agents/cli-explore-agent.md +186 -0
  2. package/.agy/agents/conceptual-planning-agent.md +244 -0
  3. package/.agy/agents/impeccable-agent.md +97 -0
  4. package/.agy/agents/team-supervisor.md +142 -0
  5. package/.agy/agents/team-worker.md +236 -0
  6. package/.agy/agents/ui-design-agent.md +286 -0
  7. package/.agy/agents/workflow-analyzer.md +114 -0
  8. package/.agy/agents/workflow-codebase-mapper.md +76 -0
  9. package/.agy/agents/workflow-collab-planner.md +142 -0
  10. package/.agy/agents/workflow-debugger.md +102 -0
  11. package/.agy/agents/workflow-executor.md +131 -0
  12. package/.agy/agents/workflow-external-researcher.md +86 -0
  13. package/.agy/agents/workflow-integration-checker.md +82 -0
  14. package/.agy/agents/workflow-nyquist-auditor.md +84 -0
  15. package/.agy/agents/workflow-phase-researcher.md +84 -0
  16. package/.agy/agents/workflow-plan-checker.md +89 -0
  17. package/.agy/agents/workflow-planner.md +194 -0
  18. package/.agy/agents/workflow-project-researcher.md +73 -0
  19. package/.agy/agents/workflow-research-synthesizer.md +70 -0
  20. package/.agy/agents/workflow-reviewer.md +81 -0
  21. package/.agy/agents/workflow-roadmapper.md +81 -0
  22. package/.agy/agents/workflow-verifier.md +119 -0
  23. package/.agy/skills/codify-to-knowhow/SKILL.md +172 -0
  24. package/.agy/skills/codify-to-knowhow/phases/01-load-manifest.md +101 -0
  25. package/.agy/skills/codify-to-knowhow/phases/02-generate-knowhow.md +97 -0
  26. package/.agy/skills/codify-to-knowhow/phases/03-generate-specs.md +92 -0
  27. package/.agy/skills/codify-to-knowhow/phases/04-index-verify.md +119 -0
  28. package/.agy/skills/learn-decompose/SKILL.md +118 -0
  29. package/.agy/skills/learn-follow/SKILL.md +129 -0
  30. package/.agy/skills/learn-investigate/SKILL.md +154 -0
  31. package/.agy/skills/learn-retro/SKILL.md +159 -0
  32. package/.agy/skills/learn-second-opinion/SKILL.md +124 -0
  33. package/.agy/skills/maestro/SKILL.md +221 -0
  34. package/.agy/skills/maestro-amend/SKILL.md +162 -0
  35. package/.agy/skills/maestro-analyze/SKILL.md +135 -0
  36. package/.agy/skills/maestro-brainstorm/SKILL.md +118 -0
  37. package/.agy/skills/maestro-collab/SKILL.md +174 -0
  38. package/.agy/skills/maestro-composer/SKILL.md +180 -0
  39. package/.agy/skills/maestro-execute/SKILL.md +133 -0
  40. package/.agy/skills/maestro-fork/SKILL.md +88 -0
  41. package/.agy/skills/maestro-guard/SKILL.md +101 -0
  42. package/.agy/skills/maestro-help/SKILL.md +267 -0
  43. package/.agy/skills/maestro-help/index/catalog.json +184 -0
  44. package/.agy/skills/maestro-help/phases/01-parse-intent.md +122 -0
  45. package/.agy/skills/maestro-help/phases/02-search-present.md +181 -0
  46. package/.agy/skills/maestro-help/phases/03-workflow-guide.md +186 -0
  47. package/.agy/skills/maestro-impeccable/SKILL.md +250 -0
  48. package/.agy/skills/maestro-init/SKILL.md +80 -0
  49. package/.agy/skills/maestro-learn/SKILL.md +142 -0
  50. package/.agy/skills/maestro-merge/SKILL.md +66 -0
  51. package/.agy/skills/maestro-milestone-audit/SKILL.md +70 -0
  52. package/.agy/skills/maestro-milestone-complete/SKILL.md +77 -0
  53. package/.agy/skills/maestro-milestone-release/SKILL.md +98 -0
  54. package/.agy/skills/maestro-overlay/SKILL.md +177 -0
  55. package/.agy/skills/maestro-plan/SKILL.md +172 -0
  56. package/.agy/skills/maestro-player/SKILL.md +176 -0
  57. package/.agy/skills/maestro-quick/SKILL.md +67 -0
  58. package/.agy/skills/maestro-ralph/SKILL.md +546 -0
  59. package/.agy/skills/maestro-ralph-execute/SKILL.md +255 -0
  60. package/.agy/skills/maestro-roadmap/SKILL.md +170 -0
  61. package/.agy/skills/maestro-tools-execute/SKILL.md +119 -0
  62. package/.agy/skills/maestro-tools-register/SKILL.md +159 -0
  63. package/.agy/skills/maestro-ui-codify/SKILL.md +81 -0
  64. package/.agy/skills/maestro-update/SKILL.md +175 -0
  65. package/.agy/skills/maestro-verify/SKILL.md +111 -0
  66. package/.agy/skills/manage-codebase-rebuild/SKILL.md +77 -0
  67. package/.agy/skills/manage-codebase-refresh/SKILL.md +59 -0
  68. package/.agy/skills/manage-harvest/SKILL.md +96 -0
  69. package/.agy/skills/manage-issue/SKILL.md +72 -0
  70. package/.agy/skills/manage-issue-discover/SKILL.md +83 -0
  71. package/.agy/skills/manage-knowhow/SKILL.md +76 -0
  72. package/.agy/skills/manage-knowhow-capture/SKILL.md +78 -0
  73. package/.agy/skills/manage-learn/SKILL.md +64 -0
  74. package/.agy/skills/manage-status/SKILL.md +51 -0
  75. package/.agy/skills/manage-wiki/SKILL.md +61 -0
  76. package/.agy/skills/quality-auto-test/SKILL.md +135 -0
  77. package/.agy/skills/quality-debug/SKILL.md +122 -0
  78. package/.agy/skills/quality-refactor/SKILL.md +69 -0
  79. package/.agy/skills/quality-retrospective/SKILL.md +79 -0
  80. package/.agy/skills/quality-review/SKILL.md +130 -0
  81. package/.agy/skills/quality-sync/SKILL.md +53 -0
  82. package/.agy/skills/quality-test/SKILL.md +119 -0
  83. package/.agy/skills/security-audit/SKILL.md +157 -0
  84. package/.agy/skills/skill-iter-tune/SKILL.md +381 -0
  85. package/.agy/skills/skill-iter-tune/phases/01-setup.md +144 -0
  86. package/.agy/skills/skill-iter-tune/phases/02-execute.md +292 -0
  87. package/.agy/skills/skill-iter-tune/phases/03-evaluate.md +312 -0
  88. package/.agy/skills/skill-iter-tune/phases/04-improve.md +198 -0
  89. package/.agy/skills/skill-iter-tune/phases/05-report.md +166 -0
  90. package/.agy/skills/skill-iter-tune/specs/evaluation-criteria.md +63 -0
  91. package/.agy/skills/skill-iter-tune/templates/eval-prompt.md +134 -0
  92. package/.agy/skills/skill-iter-tune/templates/execute-prompt.md +97 -0
  93. package/.agy/skills/spec-add/SKILL.md +67 -0
  94. package/.agy/skills/spec-load/SKILL.md +70 -0
  95. package/.agy/skills/spec-remove/SKILL.md +50 -0
  96. package/.agy/skills/spec-setup/SKILL.md +47 -0
  97. package/.agy/skills/team-coordinate/SKILL.md +267 -0
  98. package/.agy/skills/team-coordinate/roles/coordinator/commands/analyze-task.md +247 -0
  99. package/.agy/skills/team-coordinate/roles/coordinator/commands/dispatch.md +131 -0
  100. package/.agy/skills/team-coordinate/roles/coordinator/commands/monitor.md +348 -0
  101. package/.agy/skills/team-coordinate/roles/coordinator/role.md +362 -0
  102. package/.agy/skills/team-coordinate/specs/knowledge-transfer.md +111 -0
  103. package/.agy/skills/team-coordinate/specs/pipelines.md +97 -0
  104. package/.agy/skills/team-coordinate/specs/quality-gates.md +112 -0
  105. package/.agy/skills/team-coordinate/specs/role-spec-template.md +198 -0
  106. package/.agy/skills/team-executor/SKILL.md +180 -0
  107. package/.agy/skills/team-executor/roles/executor/commands/monitor.md +235 -0
  108. package/.agy/skills/team-executor/roles/executor/role.md +171 -0
  109. package/.agy/skills/team-executor/specs/session-schema.md +264 -0
  110. package/.agy/skills/team-lifecycle-v4/SKILL.md +189 -0
  111. package/.agy/skills/team-lifecycle-v4/roles/analyst/role.md +92 -0
  112. package/.agy/skills/team-lifecycle-v4/roles/coordinator/commands/analyze.md +56 -0
  113. package/.agy/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +56 -0
  114. package/.agy/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +206 -0
  115. package/.agy/skills/team-lifecycle-v4/roles/coordinator/role.md +130 -0
  116. package/.agy/skills/team-lifecycle-v4/roles/executor/commands/fix.md +35 -0
  117. package/.agy/skills/team-lifecycle-v4/roles/executor/commands/implement.md +62 -0
  118. package/.agy/skills/team-lifecycle-v4/roles/executor/role.md +64 -0
  119. package/.agy/skills/team-lifecycle-v4/roles/planner/role.md +82 -0
  120. package/.agy/skills/team-lifecycle-v4/roles/reviewer/commands/review-code.md +34 -0
  121. package/.agy/skills/team-lifecycle-v4/roles/reviewer/commands/review-spec.md +44 -0
  122. package/.agy/skills/team-lifecycle-v4/roles/reviewer/role.md +65 -0
  123. package/.agy/skills/team-lifecycle-v4/roles/supervisor/role.md +188 -0
  124. package/.agy/skills/team-lifecycle-v4/roles/tester/role.md +84 -0
  125. package/.agy/skills/team-lifecycle-v4/roles/writer/role.md +92 -0
  126. package/.agy/skills/team-lifecycle-v4/specs/knowledge-transfer.md +114 -0
  127. package/.agy/skills/team-lifecycle-v4/specs/pipelines.md +140 -0
  128. package/.agy/skills/team-lifecycle-v4/specs/quality-gates.md +130 -0
  129. package/.agy/skills/team-lifecycle-v4/templates/architecture.md +254 -0
  130. package/.agy/skills/team-lifecycle-v4/templates/epics.md +196 -0
  131. package/.agy/skills/team-lifecycle-v4/templates/product-brief.md +133 -0
  132. package/.agy/skills/team-lifecycle-v4/templates/requirements.md +224 -0
  133. package/.agy/skills/team-quality-assurance/SKILL.md +148 -0
  134. package/.agy/skills/team-quality-assurance/roles/analyst/role.md +85 -0
  135. package/.agy/skills/team-quality-assurance/roles/coordinator/commands/analyze.md +72 -0
  136. package/.agy/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +111 -0
  137. package/.agy/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +235 -0
  138. package/.agy/skills/team-quality-assurance/roles/coordinator/role.md +143 -0
  139. package/.agy/skills/team-quality-assurance/roles/executor/role.md +62 -0
  140. package/.agy/skills/team-quality-assurance/roles/generator/role.md +65 -0
  141. package/.agy/skills/team-quality-assurance/roles/scout/role.md +72 -0
  142. package/.agy/skills/team-quality-assurance/roles/strategist/role.md +69 -0
  143. package/.agy/skills/team-quality-assurance/specs/pipelines.md +115 -0
  144. package/.agy/skills/team-quality-assurance/specs/team-config.json +131 -0
  145. package/.agy/skills/team-review/SKILL.md +149 -0
  146. package/.agy/skills/team-review/roles/coordinator/commands/analyze.md +71 -0
  147. package/.agy/skills/team-review/roles/coordinator/commands/dispatch.md +91 -0
  148. package/.agy/skills/team-review/roles/coordinator/commands/monitor.md +209 -0
  149. package/.agy/skills/team-review/roles/coordinator/role.md +132 -0
  150. package/.agy/skills/team-review/roles/fixer/role.md +74 -0
  151. package/.agy/skills/team-review/roles/reviewer/role.md +66 -0
  152. package/.agy/skills/team-review/roles/scanner/role.md +77 -0
  153. package/.agy/skills/team-review/specs/dimensions.md +82 -0
  154. package/.agy/skills/team-review/specs/finding-schema.json +82 -0
  155. package/.agy/skills/team-review/specs/pipelines.md +102 -0
  156. package/.agy/skills/team-review/specs/team-config.json +27 -0
  157. package/.agy/skills/team-tech-debt/SKILL.md +133 -0
  158. package/.agy/skills/team-tech-debt/roles/assessor/role.md +76 -0
  159. package/.agy/skills/team-tech-debt/roles/coordinator/commands/analyze.md +47 -0
  160. package/.agy/skills/team-tech-debt/roles/coordinator/commands/dispatch.md +156 -0
  161. package/.agy/skills/team-tech-debt/roles/coordinator/commands/monitor.md +198 -0
  162. package/.agy/skills/team-tech-debt/roles/coordinator/role.md +123 -0
  163. package/.agy/skills/team-tech-debt/roles/executor/role.md +76 -0
  164. package/.agy/skills/team-tech-debt/roles/planner/role.md +68 -0
  165. package/.agy/skills/team-tech-debt/roles/scanner/role.md +90 -0
  166. package/.agy/skills/team-tech-debt/roles/validator/role.md +78 -0
  167. package/.agy/skills/team-tech-debt/specs/pipelines.md +47 -0
  168. package/.agy/skills/team-tech-debt/specs/team-config.json +129 -0
  169. package/.agy/skills/team-testing/SKILL.md +144 -0
  170. package/.agy/skills/team-testing/roles/analyst/role.md +101 -0
  171. package/.agy/skills/team-testing/roles/coordinator/commands/analyze.md +70 -0
  172. package/.agy/skills/team-testing/roles/coordinator/commands/dispatch.md +108 -0
  173. package/.agy/skills/team-testing/roles/coordinator/commands/monitor.md +242 -0
  174. package/.agy/skills/team-testing/roles/coordinator/role.md +134 -0
  175. package/.agy/skills/team-testing/roles/executor/role.md +95 -0
  176. package/.agy/skills/team-testing/roles/generator/role.md +95 -0
  177. package/.agy/skills/team-testing/roles/strategist/role.md +81 -0
  178. package/.agy/skills/team-testing/specs/pipelines.md +101 -0
  179. package/.agy/skills/team-testing/specs/team-config.json +93 -0
  180. package/.agy/skills/wiki-connect/SKILL.md +64 -0
  181. package/.agy/skills/wiki-digest/SKILL.md +70 -0
  182. package/.agy/skills/workflow-skill-designer/SKILL.md +506 -0
  183. package/.agy/skills/workflow-skill-designer/phases/01-requirements-analysis.md +356 -0
  184. package/.agy/skills/workflow-skill-designer/phases/02-orchestrator-design.md +444 -0
  185. package/.agy/skills/workflow-skill-designer/phases/03-phase-design.md +458 -0
  186. package/.agy/skills/workflow-skill-designer/phases/04-validation.md +471 -0
  187. package/package.json +3 -1
@@ -0,0 +1,348 @@
1
+
2
+ ## Sub-Agent Registration (Antigravity)
3
+
4
+ Before any `invoke_subagent` call below, register each sub-agent type once per session by reading the system_prompt from `<agy-agents-dir>/<name>.md` and passing it to `define_subagent`. The `<agy-agents-dir>` is:
5
+ - global install: `~/.gemini/antigravity-cli/agents/`
6
+ - workspace install: `<project>/.agents/agents/`
7
+
8
+ - `define_subagent(name="team-worker", description="<from agents/team-worker.md frontmatter>", system_prompt=<contents of agents/team-worker.md body>, enable_write_tools=true, enable_mcp_tools=true, enable_subagent_tools=false)`
9
+
10
+ **ConversationId tracking**: `invoke_subagent` returns a ConversationId per spawned instance. Subsequent `send_message(Recipient=<ConversationId>, Message=...)` calls require that ConversationId — never use the role name as the recipient.
11
+
12
+ ---
13
+ # Command: monitor
14
+
15
+ ## Purpose
16
+
17
+ Event-driven pipeline coordination with Spawn-and-Stop pattern. Role names are read from `team-session.json#roles`. Workers are spawned as `team-worker` agents with role-spec paths. Includes `handleComplete` for pipeline completion action and `handleAdapt` for mid-pipeline capability gap handling.
18
+
19
+ ## When to Use
20
+
21
+ | Trigger | Condition |
22
+ |---------|-----------|
23
+ | Worker callback | Message contains [role-name] from session roles |
24
+ | User command | "check", "status", "resume", "continue" |
25
+ | Capability gap | Worker reports capability_gap |
26
+ | Pipeline spawn | After dispatch, initial spawn needed |
27
+ | Pipeline complete | All tasks done |
28
+
29
+ ## Strategy
30
+
31
+ - **Delegation**: Inline execution with handler routing
32
+ - **Beat model**: ONE_STEP_PER_INVOCATION — one handler then STOP
33
+ - **Workers**: Spawned as team-worker via invoke_subagent() in background
34
+
35
+ ## Constants
36
+
37
+ | Constant | Value | Description |
38
+ |----------|-------|-------------|
39
+ | SPAWN_MODE | background | All workers spawned via `Task(run_in_background: true)` |
40
+ | ONE_STEP_PER_INVOCATION | true | Coordinator does one operation then STOPS |
41
+ | FAST_ADVANCE_AWARE | true | Workers may skip coordinator for simple linear successors |
42
+ | WORKER_AGENT | team-worker | All workers spawned as team-worker agents |
43
+
44
+ ## Phase 2: Context Loading
45
+
46
+ | Input | Source | Required |
47
+ |-------|--------|----------|
48
+ | Session file | `<session-folder>/team-session.json` | Yes |
49
+ | Task list | `TaskList()` | Yes |
50
+ | Active workers | session.active_workers[] | Yes |
51
+ | Role registry | session.roles[] | Yes |
52
+
53
+ **Dynamic role resolution**: Known worker roles are loaded from `session.roles[].name`. Role-spec paths are in `session.roles[].role_spec`.
54
+
55
+ ## Phase 3: Handler Routing
56
+
57
+ ### Wake-up Source Detection
58
+
59
+ Parse `$ARGUMENTS` to determine handler:
60
+
61
+ | Priority | Condition | Handler |
62
+ |----------|-----------|---------|
63
+ | 1 | Message contains `[<role-name>]` from session roles | handleCallback |
64
+ | 2 | Contains "capability_gap" | handleAdapt |
65
+ | 3 | Contains "check" or "status" | handleCheck |
66
+ | 4 | Contains "resume", "continue", or "next" | handleResume |
67
+ | 5 | Pipeline detected as complete | handleComplete |
68
+ | 6 | None of the above (initial spawn after dispatch) | handleSpawnNext |
69
+
70
+ ---
71
+
72
+ ### Handler: handleCallback
73
+
74
+ Worker completed a task. Verify completion, update state, auto-advance.
75
+
76
+ ```
77
+ Receive callback from [<role>]
78
+ +- Find matching active worker by role (from session.roles)
79
+ +- Is this a progress update (not final)? (Inner Loop intermediate task completion)
80
+ | +- YES -> Update session state, do NOT remove from active_workers -> STOP
81
+ +- Task status = completed?
82
+ | +- YES -> remove from active_workers -> update session
83
+ | | +- -> handleSpawnNext
84
+ | +- NO -> progress message, do not advance -> STOP
85
+ +- No matching worker found
86
+ +- Scan all active workers for completed tasks
87
+ +- Found completed -> process each -> handleSpawnNext
88
+ +- None completed -> STOP
89
+ ```
90
+
91
+ **Fast-advance reconciliation**: A worker may have already spawned its successor via fast-advance. When processing any callback or resume:
92
+ 1. Read recent `fast_advance` messages from team_msg (type="fast_advance")
93
+ 2. For each fast_advance message: add the spawned successor to `active_workers` if not already present
94
+ 3. Check if the expected next task is already `in_progress` (fast-advanced)
95
+ 4. If yes -> skip spawning that task (already running)
96
+ 5. If no -> normal handleSpawnNext
97
+
98
+ ---
99
+
100
+ ### Handler: handleCheck
101
+
102
+ Read-only status report. No pipeline advancement.
103
+
104
+ **Worker Progress** (from message bus):
105
+
106
+ Before generating status output, read worker milestones:
107
+
108
+ ```javascript
109
+ const progressMsgs = mcp__ccw-tools__team_msg({
110
+ operation: "list", session_id: sessionId, type: "progress", last: 50
111
+ })
112
+ const blockerMsgs = mcp__ccw-tools__team_msg({
113
+ operation: "list", session_id: sessionId, type: "blocker", last: 10
114
+ })
115
+
116
+ // Aggregate latest milestone per task
117
+ const taskProgress = {}
118
+ for (const msg of (progressMsgs.result?.messages || [])) {
119
+ const tid = msg.data?.task_id
120
+ if (tid && (!taskProgress[tid] || msg.ts > taskProgress[tid].ts)) {
121
+ taskProgress[tid] = { phase: msg.data.phase, pct: msg.data.progress_pct, ts: msg.ts }
122
+ }
123
+ }
124
+ ```
125
+
126
+ Include in status output:
127
+ - Per-worker latest milestone (phase + progress_pct) next to task status
128
+ - Active blockers section (if any blockerMsgs found)
129
+
130
+ **Output format**:
131
+
132
+ ```
133
+ [coordinator] Pipeline Status
134
+ [coordinator] Progress: <completed>/<total> (<percent>%)
135
+
136
+ [coordinator] Execution Graph:
137
+ <visual representation of dependency graph with status icons>
138
+
139
+ done=completed >>>=running o=pending .=not created
140
+
141
+ [coordinator] Active Workers:
142
+ > <subject> (<role>) - running <elapsed> [inner-loop: N/M tasks done]
143
+
144
+ [coordinator] Ready to spawn: <subjects>
145
+ [coordinator] Commands: 'resume' to advance | 'check' to refresh
146
+ ```
147
+
148
+ Then STOP.
149
+
150
+ ---
151
+
152
+ ### Handler: handleResume
153
+
154
+ Check active worker completion, process results, advance pipeline.
155
+
156
+ ```
157
+ Load active_workers from session
158
+ +- No active workers -> handleSpawnNext
159
+ +- Has active workers -> check each:
160
+ +- status = completed -> mark done, log
161
+ +- status = in_progress -> still running, log
162
+ +- other status -> worker failure -> reset to pending
163
+ After processing:
164
+ +- Some completed -> handleSpawnNext
165
+ +- All still running -> report status -> STOP
166
+ +- All failed -> handleSpawnNext (retry)
167
+ ```
168
+
169
+ ---
170
+
171
+ ### Handler: handleSpawnNext
172
+
173
+ Find all ready tasks, spawn team-worker agents in background, update session, STOP.
174
+
175
+ ```
176
+ Collect task states from TaskList()
177
+ +- completedSubjects: status = completed
178
+ +- inProgressSubjects: status = in_progress
179
+ +- readySubjects: pending + all blockedBy in completedSubjects
180
+
181
+ Ready tasks found?
182
+ +- NONE + work in progress -> report waiting -> STOP
183
+ +- NONE + nothing in progress -> PIPELINE_COMPLETE -> handleComplete
184
+ +- HAS ready tasks -> for each:
185
+ +- Is task owner an Inner Loop role AND that role already has an active_worker?
186
+ | +- YES -> SKIP spawn (existing worker will pick it up via inner loop)
187
+ | +- NO -> normal spawn below
188
+ +- TaskUpdate -> in_progress
189
+ +- team_msg log -> task_unblocked (session_id=<session-id>)
190
+ +- Spawn team-worker (see spawn tool call below)
191
+ +- Add to session.active_workers
192
+ Update session file -> output summary -> STOP
193
+ ```
194
+
195
+ **Spawn worker tool call** (one per ready task):
196
+
197
+ ```
198
+ invoke_subagent([{ TypeName: "team-worker", Role: "<role>", Prompt: "<Prompt>", Workspace: "inherit" }])
199
+ ```
200
+
201
+ ---
202
+
203
+ ### Handler: handleComplete
204
+
205
+ Pipeline complete. Execute completion action based on session configuration.
206
+
207
+ ```
208
+ All tasks completed (no pending, no in_progress)
209
+ +- Generate pipeline summary:
210
+ | - Deliverables list with paths
211
+ | - Pipeline stats (tasks completed, duration)
212
+ | - Discussion verdicts (if any)
213
+ |
214
+ +- Read session.completion_action:
215
+ |
216
+ +- "interactive":
217
+ | ask_question({
218
+ | questions: [{
219
+ | question: "Team pipeline complete. What would you like to do?",
220
+ | header: "Completion",
221
+ | multiSelect: false,
222
+ | options: [
223
+ | { label: "Archive & Clean (Recommended)", description: "Archive session, clean up team" },
224
+ | { label: "Keep Active", description: "Keep session for follow-up work" },
225
+ | { label: "Export Results", description: "Export deliverables to target directory" }
226
+ | ]
227
+ | }]
228
+ | })
229
+ | +- "Archive & Clean":
230
+ | | Update session status="completed"
231
+ | | TeamDelete()
232
+ | | Output final summary with artifact paths
233
+ | +- "Keep Active":
234
+ | | Update session status="paused"
235
+ | | Output: "Resume with: view_file(AbsolutePath="<agy-skills-dir>/team-coordinate/SKILL.md") + execute inline (args: "resume")"
236
+ | +- "Export Results":
237
+ | ask_question for target directory
238
+ | Copy deliverables to target
239
+ | Execute Archive & Clean flow
240
+ |
241
+ +- "auto_archive":
242
+ | Execute Archive & Clean without prompt
243
+ |
244
+ +- "auto_keep":
245
+ Execute Keep Active without prompt
246
+ ```
247
+
248
+ **Fallback**: If completion action fails, default to Keep Active (session status="paused"), log warning.
249
+
250
+ ---
251
+
252
+ ### Handler: handleAdapt
253
+
254
+ Handle mid-pipeline capability gap discovery. A worker reports `capability_gap` when it encounters work outside its scope.
255
+
256
+ **CONSTRAINT**: Maximum 5 worker roles per session. handleAdapt MUST enforce this limit.
257
+
258
+ ```
259
+ Parse capability_gap message:
260
+ +- Extract: gap_description, requesting_role, suggested_capability
261
+ +- Validate gap is genuine:
262
+ +- Check existing roles in session.roles -> does any role cover this?
263
+ | +- YES -> redirect: send_message to that role's owner -> STOP
264
+ | +- NO -> genuine gap, proceed to role-spec generation
265
+ +- CHECK ROLE COUNT LIMIT (MAX 5 ROLES):
266
+ +- Count current roles in session.roles
267
+ +- If count >= 5:
268
+ +- Attempt to merge new capability into existing role
269
+ +- If merge NOT possible -> PAUSE, report to user
270
+ +- Generate new role-spec:
271
+ 1. Read specs/role-spec-template.md
272
+ 2. Fill template with: frontmatter (role, prefix, inner_loop, message_types) + Phase 2-4 content
273
+ 3. Write to <session-folder>/role-specs/<new-role>.md
274
+ 4. Add to session.roles[]
275
+ +- Create new task(s) via TaskCreate
276
+ +- Update team-session.json
277
+ +- Spawn new team-worker -> STOP
278
+ ```
279
+
280
+ ---
281
+
282
+ ### Worker Failure Handling
283
+
284
+ When a worker has unexpected status (not completed, not in_progress):
285
+
286
+ 1. Reset task -> pending via TaskUpdate
287
+ 2. Log via team_msg (type: error)
288
+ 3. Report to user: task reset, will retry on next resume
289
+
290
+ ### Fast-Advance Failure Recovery
291
+
292
+ When coordinator detects a fast-advanced task has failed:
293
+
294
+ ```
295
+ handleCallback / handleResume detects:
296
+ +- Task is in_progress (was fast-advanced by predecessor)
297
+ +- No active_worker entry for this task
298
+ +- Resolution:
299
+ 1. TaskUpdate -> reset task to pending
300
+ 2. Remove stale active_worker entry (if any)
301
+ 3. Log via team_msg (type: error)
302
+ 4. -> handleSpawnNext (will re-spawn the task normally)
303
+ ```
304
+
305
+ ### Fast-Advance State Sync
306
+
307
+ On every coordinator wake (handleCallback, handleResume, handleCheck):
308
+ 1. Read team_msg entries with `type="fast_advance"` since last coordinator wake
309
+ 2. For each entry: sync `active_workers` with the spawned successor
310
+ 3. This ensures coordinator's state reflects fast-advance decisions even before the successor's callback arrives
311
+
312
+ ### Consensus-Blocked Handling
313
+
314
+ ```
315
+ handleCallback receives message with consensus_blocked flag
316
+ +- Route by severity:
317
+ +- severity = HIGH
318
+ | +- Create REVISION task (same role, incremented suffix)
319
+ | +- Max 1 revision per task. If already revised -> PAUSE, escalate to user
320
+ +- severity = MEDIUM
321
+ | +- Proceed with warning, log to wisdom/issues.md
322
+ | +- Normal handleSpawnNext
323
+ +- severity = LOW
324
+ +- Proceed normally, treat as consensus_reached with notes
325
+ ```
326
+
327
+ ## Phase 4: Validation
328
+
329
+ | Check | Criteria |
330
+ |-------|----------|
331
+ | Session state consistent | active_workers matches TaskList in_progress tasks |
332
+ | No orphaned tasks | Every in_progress task has an active_worker entry |
333
+ | Dynamic roles valid | All task owners exist in session.roles |
334
+ | Completion detection | readySubjects=0 + inProgressSubjects=0 -> PIPELINE_COMPLETE |
335
+ | Fast-advance tracking | Detect tasks already in_progress via fast-advance, sync to active_workers |
336
+
337
+ ## Error Handling
338
+
339
+ | Scenario | Resolution |
340
+ |----------|------------|
341
+ | Session file not found | Error, suggest re-initialization |
342
+ | Worker callback from unknown role | Log info, scan for other completions |
343
+ | All workers still running on resume | Report status, suggest check later |
344
+ | Pipeline stall (no ready, no running) | Check for missing tasks, report to user |
345
+ | Fast-advance conflict | Coordinator reconciles, no duplicate spawns |
346
+ | Dynamic role-spec file not found | Error, coordinator must regenerate from task-analysis |
347
+ | capability_gap when role limit (5) reached | Attempt merge, else pause for user |
348
+ | Completion action fails | Default to Keep Active, log warning |