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,156 @@
1
+ # Command: dispatch
2
+
3
+ > 任务链创建与依赖管理。根据 pipeline 模式创建技术债务治理任务链并分配给 worker 角色。
4
+
5
+ ## When to Use
6
+
7
+ - Phase 3 of Coordinator
8
+ - Pipeline 模式已确定,需要创建任务链
9
+ - 团队已创建,worker 已 spawn
10
+
11
+ **Trigger conditions**:
12
+ - Coordinator Phase 2 完成后
13
+ - 模式切换需要重建任务链
14
+ - Fix-Verify 循环需要创建修复任务
15
+
16
+ ## Strategy
17
+
18
+ ### Delegation Mode
19
+
20
+ **Mode**: Direct(coordinator 直接操作 TaskCreate/TaskUpdate)
21
+
22
+ ### Decision Logic
23
+
24
+ ```javascript
25
+ // 根据 pipelineMode 选择 pipeline
26
+ function buildPipeline(pipelineMode, sessionFolder, taskDescription) {
27
+ const pipelines = {
28
+ 'scan': [
29
+ { prefix: 'TDSCAN', owner: 'scanner', desc: '多维度技术债务扫描', blockedBy: [] },
30
+ { prefix: 'TDEVAL', owner: 'assessor', desc: '量化评估与优先级排序', blockedBy: ['TDSCAN'] }
31
+ ],
32
+ 'remediate': [
33
+ { prefix: 'TDSCAN', owner: 'scanner', desc: '多维度技术债务扫描', blockedBy: [] },
34
+ { prefix: 'TDEVAL', owner: 'assessor', desc: '量化评估与优先级排序', blockedBy: ['TDSCAN'] },
35
+ { prefix: 'TDPLAN', owner: 'planner', desc: '分阶段治理方案规划', blockedBy: ['TDEVAL'] },
36
+ { prefix: 'TDFIX', owner: 'executor', desc: '债务清理执行', blockedBy: ['TDPLAN'] },
37
+ { prefix: 'TDVAL', owner: 'validator', desc: '清理结果验证', blockedBy: ['TDFIX'] }
38
+ ],
39
+ 'targeted': [
40
+ { prefix: 'TDPLAN', owner: 'planner', desc: '定向修复方案规划', blockedBy: [] },
41
+ { prefix: 'TDFIX', owner: 'executor', desc: '债务清理执行', blockedBy: ['TDPLAN'] },
42
+ { prefix: 'TDVAL', owner: 'validator', desc: '清理结果验证', blockedBy: ['TDFIX'] }
43
+ ]
44
+ }
45
+ return pipelines[pipelineMode] || pipelines['scan']
46
+ }
47
+ ```
48
+
49
+ ## Execution Steps
50
+
51
+ ### Step 1: Context Preparation
52
+
53
+ ```javascript
54
+ const pipeline = buildPipeline(pipelineMode, sessionFolder, taskDescription)
55
+ ```
56
+
57
+ ### Step 2: Execute Strategy
58
+
59
+ ```javascript
60
+ const taskIds = {}
61
+
62
+ for (const stage of pipeline) {
63
+ // 构建任务描述(包含 session 和上下文信息)
64
+ const fullDesc = [
65
+ stage.desc,
66
+ `\nsession: ${sessionFolder}`,
67
+ `\n\n目标: ${taskDescription}`
68
+ ].join('')
69
+
70
+ // 创建任务
71
+ TaskCreate({
72
+ subject: `${stage.prefix}-001: ${stage.desc}`,
73
+ description: fullDesc,
74
+ activeForm: `${stage.desc}进行中`
75
+ })
76
+
77
+ // 记录任务 ID
78
+ const allTasks = TaskList()
79
+ const newTask = allTasks.find(t => t.subject.startsWith(`${stage.prefix}-001`))
80
+ taskIds[stage.prefix] = newTask.id
81
+
82
+ // 设置 owner 和依赖
83
+ const blockedByIds = stage.blockedBy
84
+ .map(dep => taskIds[dep])
85
+ .filter(Boolean)
86
+
87
+ TaskUpdate({
88
+ taskId: newTask.id,
89
+ owner: stage.owner,
90
+ addBlockedBy: blockedByIds
91
+ })
92
+ }
93
+ ```
94
+
95
+ ### Step 3: Result Processing
96
+
97
+ ```javascript
98
+ // 验证任务链
99
+ const allTasks = TaskList()
100
+ const chainTasks = pipeline.map(s => taskIds[s.prefix]).filter(Boolean)
101
+ const chainValid = chainTasks.length === pipeline.length
102
+
103
+ if (!chainValid) {
104
+ mcp__ccw-tools__team_msg({
105
+ operation: "log", session_id: sessionId, from: "coordinator", // team must be session ID (e.g., TD-xxx-date), NOT team name
106
+ type: "error",
107
+ })
108
+ }
109
+ ```
110
+
111
+ ## Fix-Verify Loop Task Creation
112
+
113
+ 当 validator 报告回归问题时,coordinator 调用此逻辑追加任务:
114
+
115
+ ```javascript
116
+ function createFixVerifyTasks(fixVerifyIteration, sessionFolder) {
117
+ // 创建修复任务
118
+ TaskCreate({
119
+ subject: `TDFIX-fix-${fixVerifyIteration}: 修复回归问题 (Fix-Verify #${fixVerifyIteration})`,
120
+ description: `修复验证发现的回归问题\nsession: ${sessionFolder}\ntype: fix-verify`,
121
+ activeForm: `Fix-Verify #${fixVerifyIteration} 修复中`
122
+ })
123
+
124
+ // 创建重新验证任务
125
+ TaskCreate({
126
+ subject: `TDVAL-verify-${fixVerifyIteration}: 重新验证 (Fix-Verify #${fixVerifyIteration})`,
127
+ description: `重新验证修复结果\nsession: ${sessionFolder}`,
128
+ activeForm: `Fix-Verify #${fixVerifyIteration} 验证中`
129
+ })
130
+
131
+ // 设置依赖: TDVAL-verify 依赖 TDFIX-fix
132
+ // ... TaskUpdate addBlockedBy
133
+ }
134
+ ```
135
+
136
+ ## Output Format
137
+
138
+ ```
139
+ ## Task Chain Created
140
+
141
+ ### Mode: [scan|remediate|targeted]
142
+ ### Pipeline Stages: [count]
143
+ - [prefix]-001: [description] (owner: [role], blocked by: [deps])
144
+
145
+ ### Verification: PASS/FAIL
146
+ ```
147
+
148
+ ## Error Handling
149
+
150
+ | Scenario | Resolution |
151
+ |----------|------------|
152
+ | Task creation fails | Retry once, then report to user |
153
+ | Dependency cycle detected | Flatten dependencies, warn coordinator |
154
+ | Invalid pipelineMode | Default to 'scan' mode |
155
+ | Agent/CLI failure | Retry once, then fallback to inline execution |
156
+ | Timeout (>5 min) | Report partial results, notify coordinator |
@@ -0,0 +1,198 @@
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
+ # Monitor Pipeline
14
+
15
+ Event-driven pipeline coordination. Beat model: coordinator wake -> process -> spawn -> STOP.
16
+
17
+ ## Constants
18
+
19
+ - SPAWN_MODE: background
20
+ - ONE_STEP_PER_INVOCATION: true
21
+ - FAST_ADVANCE_AWARE: true
22
+ - WORKER_AGENT: team-worker
23
+ - MAX_GC_ROUNDS: 3
24
+
25
+ ## Handler Router
26
+
27
+ | Source | Handler |
28
+ |--------|---------|
29
+ | Message contains [scanner], [assessor], [planner], [executor], [validator] | handleCallback |
30
+ | "capability_gap" | handleAdapt |
31
+ | "check" or "status" | handleCheck |
32
+ | "resume" or "continue" | handleResume |
33
+ | All tasks completed | handleComplete |
34
+ | Default | handleSpawnNext |
35
+
36
+ ## handleCallback
37
+
38
+ Worker completed. Process and advance.
39
+
40
+ 1. Find matching worker by role tag in message
41
+ 2. Check if progress update (inner loop) or final completion
42
+ 3. Progress update -> update session state, STOP
43
+ 4. Completion -> mark task done:
44
+ ```
45
+ TaskUpdate({ taskId: "<task-id>", status: "completed" })
46
+ ```
47
+ 5. Remove from active_workers, record completion in session
48
+
49
+ 6. Check for checkpoints:
50
+ - **TDPLAN-001 completes** -> Plan Approval Gate:
51
+ ```
52
+ ask_question({
53
+ questions: [{ question: "Remediation plan generated. Review and decide:",
54
+ header: "Plan Review", multiSelect: false,
55
+ options: [
56
+ { label: "Approve", description: "Proceed with fix execution" },
57
+ { label: "Revise", description: "Re-run planner with feedback" },
58
+ { label: "Abort", description: "Stop pipeline" }
59
+ ]
60
+ }]
61
+ })
62
+ ```
63
+ - Approve -> Worktree Creation -> handleSpawnNext
64
+ - Revise -> Create TDPLAN-revised task -> handleSpawnNext
65
+ - Abort -> Log shutdown -> handleComplete
66
+
67
+ - **Worktree Creation** (before TDFIX):
68
+ ```
69
+ run_command("git worktree add .worktrees/TD-<slug>-<date> -b tech-debt/TD-<slug>-<date>")
70
+ ```
71
+ Update .msg/meta.json with worktree info.
72
+
73
+ - **TDVAL-* completes** -> GC Loop Check:
74
+ Read validation results from .msg/meta.json
75
+
76
+ | Condition | Action |
77
+ |-----------|--------|
78
+ | No regressions | -> handleSpawnNext (pipeline complete) |
79
+ | Regressions AND gc_rounds < 3 | Create fix-verify tasks, increment gc_rounds |
80
+ | Regressions AND gc_rounds >= 3 | Accept current state -> handleComplete |
81
+
82
+ Fix-Verify Task Creation:
83
+ ```
84
+ TaskCreate({ subject: "TDFIX-fix-<round>", description: "PURPOSE: Fix regressions | Session: <session>" })
85
+ TaskCreate({ subject: "TDVAL-recheck-<round>", description: "..." })
86
+ TaskUpdate({ taskId: "TDVAL-recheck-<round>", addBlockedBy: ["TDFIX-fix-<round>"] })
87
+ ```
88
+
89
+ 7. -> handleSpawnNext
90
+
91
+ ## handleCheck
92
+
93
+ Read-only status report, then STOP.
94
+
95
+ **Worker Progress** (from message bus):
96
+
97
+ Before generating status output, read worker milestones:
98
+
99
+ ```javascript
100
+ const progressMsgs = mcp__ccw-tools__team_msg({
101
+ operation: "list", session_id: sessionId, type: "progress", last: 50
102
+ })
103
+ const blockerMsgs = mcp__ccw-tools__team_msg({
104
+ operation: "list", session_id: sessionId, type: "blocker", last: 10
105
+ })
106
+
107
+ // Aggregate latest milestone per task
108
+ const taskProgress = {}
109
+ for (const msg of (progressMsgs.result?.messages || [])) {
110
+ const tid = msg.data?.task_id
111
+ if (tid && (!taskProgress[tid] || msg.ts > taskProgress[tid].ts)) {
112
+ taskProgress[tid] = { phase: msg.data.phase, pct: msg.data.progress_pct, ts: msg.ts }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Include in status output:
118
+ - Per-worker latest milestone (phase + progress_pct) next to task status
119
+ - Active blockers section (if any blockerMsgs found)
120
+
121
+ ```
122
+ Pipeline Status (<mode>):
123
+ [DONE] TDSCAN-001 (scanner) -> scan complete
124
+ [DONE] TDEVAL-001 (assessor) -> assessment ready
125
+ [RUN] TDPLAN-001 (planner) -> planning...
126
+ [WAIT] TDFIX-001 (executor) -> blocked by TDPLAN-001
127
+ [WAIT] TDVAL-001 (validator) -> blocked by TDFIX-001
128
+
129
+ GC Rounds: 0/3
130
+ Session: <session-id>
131
+ Commands: 'resume' to advance | 'check' to refresh
132
+ ```
133
+
134
+ Output status -- do NOT advance pipeline.
135
+
136
+ ## handleResume
137
+
138
+ 1. Audit task list:
139
+ - Tasks stuck in "in_progress" -> reset to "pending"
140
+ - Tasks with completed blockers but still "pending" -> include in spawn list
141
+ 2. -> handleSpawnNext
142
+
143
+ ## handleSpawnNext
144
+
145
+ Find ready tasks, spawn workers, STOP.
146
+
147
+ 1. Collect: completedSubjects, inProgressSubjects, readySubjects (pending + all blockedBy completed)
148
+ 2. No ready + work in progress -> report waiting, STOP
149
+ 3. No ready + nothing in progress -> handleComplete
150
+ 4. Has ready -> for each:
151
+ a. Check inner loop role with active worker -> skip (worker picks up)
152
+ b. TaskUpdate -> in_progress
153
+ c. team_msg log -> task_unblocked
154
+ d. Spawn team-worker:
155
+
156
+ ```
157
+ invoke_subagent([{ TypeName: "team-worker", Role: "<role>", Prompt: "<Prompt>", Workspace: "inherit" }])
158
+ ```
159
+
160
+ Stage-to-role mapping:
161
+ | Task Prefix | Role |
162
+ |-------------|------|
163
+ | TDSCAN | scanner |
164
+ | TDEVAL | assessor |
165
+ | TDPLAN | planner |
166
+ | TDFIX | executor |
167
+ | TDVAL | validator |
168
+
169
+ 5. Add to active_workers, update session, output summary, STOP
170
+
171
+ ## handleComplete
172
+
173
+ Pipeline done. Generate report and completion action.
174
+
175
+ 1. Verify all tasks (including fix-verify tasks) have status "completed"
176
+ 2. If any not completed -> handleSpawnNext
177
+ 3. If all completed:
178
+ - Read final state from .msg/meta.json
179
+ - If worktree exists and validation passed: commit, push, gh pr create, cleanup worktree
180
+ - Compile summary: total tasks, completed, gc_rounds, debt_score_before, debt_score_after
181
+ - Transition to coordinator Phase 5
182
+
183
+ ## handleAdapt
184
+
185
+ Capability gap reported mid-pipeline.
186
+
187
+ 1. Parse gap description
188
+ 2. Check if existing role covers it -> redirect
189
+ 3. Role count < 5 -> generate dynamic role spec in <session>/role-specs/
190
+ 4. Create new task, spawn worker
191
+ 5. Role count >= 5 -> merge or pause
192
+
193
+ ## Fast-Advance Reconciliation
194
+
195
+ On every coordinator wake:
196
+ 1. Read team_msg entries with type="fast_advance"
197
+ 2. Sync active_workers with spawned successors
198
+ 3. No duplicate spawns
@@ -0,0 +1,123 @@
1
+ # Coordinator Role
2
+
3
+ 技术债务治理团队协调者。编排 pipeline:需求澄清 -> 模式选择(scan/remediate/targeted) -> 团队创建 -> 任务分发 -> 监控协调 -> Fix-Verify 循环 -> 债务消减报告。
4
+
5
+ ## Identity
6
+ - **Name**: coordinator | **Tag**: [coordinator]
7
+ - **Responsibility**: Parse requirements -> Create team -> Dispatch tasks -> Monitor progress -> Report results
8
+
9
+ ## Boundaries
10
+
11
+ ### MUST
12
+ - All output (send_message, team_msg, logs) must carry `[coordinator]` identifier
13
+ - Only responsible for: requirement clarification, mode selection, task creation/dispatch, progress monitoring, quality gates, result reporting
14
+ - Create tasks via TaskCreate and assign to worker roles
15
+ - Monitor worker progress via message bus and route messages
16
+ - Maintain session state persistence
17
+
18
+ ### MUST NOT
19
+ - Execute tech debt work directly (delegate to workers)
20
+ - Modify task outputs (workers own their deliverables)
21
+ - Call CLI tools for analysis, exploration, or code generation
22
+ - Modify source code or generate artifact files directly
23
+ - Bypass worker roles to complete delegated work
24
+ - Skip dependency validation when creating task chains
25
+ - Omit `[coordinator]` identifier in any output
26
+
27
+ ## Command Execution Protocol
28
+
29
+ When coordinator needs to execute a command (analyze, dispatch, monitor):
30
+
31
+ 1. Read `commands/<command>.md`
32
+ 2. Follow the workflow defined in the command
33
+ 3. Commands are inline execution guides, NOT separate agents
34
+ 4. Execute synchronously, complete before proceeding
35
+
36
+ ## Entry Router
37
+
38
+ | Detection | Condition | Handler |
39
+ |-----------|-----------|---------|
40
+ | Worker callback | Message contains [scanner], [assessor], [planner], [executor], [validator] | -> handleCallback (monitor.md) |
41
+ | Status check | Arguments contain "check" or "status" | -> handleCheck (monitor.md) |
42
+ | Manual resume | Arguments contain "resume" or "continue" | -> handleResume (monitor.md) |
43
+ | Pipeline complete | All tasks have status "completed" | -> handleComplete (monitor.md) |
44
+ | Interrupted session | Active/paused session exists in .workflow/.team/TD-* | -> Phase 0 |
45
+ | New session | None of above | -> Phase 1 |
46
+
47
+ For callback/check/resume/complete: load `@commands/monitor.md`, execute matched handler, STOP.
48
+
49
+ ## Phase 0: Session Resume Check
50
+
51
+ 1. Scan `.workflow/.team/TD-*/.msg/meta.json` for active/paused sessions
52
+ 2. No sessions -> Phase 1
53
+ 3. Single session -> reconcile (audit TaskList, reset in_progress->pending, rebuild team, kick first ready task)
54
+ 4. Multiple -> ask_question for selection
55
+
56
+ ## Phase 1: Requirement Clarification
57
+
58
+ TEXT-LEVEL ONLY. No source code reading.
59
+
60
+ 1. Parse arguments for explicit settings: mode, scope, focus areas
61
+ 2. Detect mode:
62
+
63
+ | Condition | Mode |
64
+ |-----------|------|
65
+ | `--mode=scan` or keywords: 扫描, scan, 审计, audit, 评估, assess | scan |
66
+ | `--mode=targeted` or keywords: 定向, targeted, 指定, specific, 修复已知 | targeted |
67
+ | `-y` or `--yes` specified | Skip confirmations |
68
+ | Default | remediate |
69
+
70
+ 3. Ask for missing parameters (skip if auto mode):
71
+ - ask_question: Tech Debt Target (自定义 / 全项目扫描 / 完整治理 / 定向修复)
72
+ 4. Store: mode, scope, focus, constraints
73
+ 5. Delegate to @commands/analyze.md -> output task-analysis context
74
+
75
+ ## Phase 2: Create Team + Initialize Session
76
+
77
+ 1. Resolve workspace paths (MUST do first):
78
+ - `project_root` = result of `run_command({ command: "pwd" })`
79
+ - `skill_root` = `<project_root>/.claude/skills/team-tech-debt`
80
+ 2. Generate session ID: `TD-<slug>-<YYYY-MM-DD>`
81
+ 3. Create session folder structure (scan/, assessment/, plan/, fixes/, validation/, wisdom/)
82
+ 4. Initialize .msg/meta.json via team_msg state_update with pipeline metadata
83
+ 5. TeamCreate(team_name="tech-debt")
84
+ 6. Do NOT spawn workers yet - deferred to Phase 4
85
+
86
+ ## Phase 3: Create Task Chain
87
+
88
+ Delegate to @commands/dispatch.md. Task chain by mode:
89
+
90
+ | Mode | Task Chain |
91
+ |------|------------|
92
+ | scan | TDSCAN-001 -> TDEVAL-001 |
93
+ | remediate | TDSCAN-001 -> TDEVAL-001 -> TDPLAN-001 -> TDFIX-001 -> TDVAL-001 |
94
+ | targeted | TDPLAN-001 -> TDFIX-001 -> TDVAL-001 |
95
+
96
+ ## Phase 4: Spawn-and-Stop
97
+
98
+ Delegate to @commands/monitor.md#handleSpawnNext:
99
+ 1. Find ready tasks (pending + blockedBy resolved)
100
+ 2. Spawn team-worker agents (see SKILL.md Spawn Template)
101
+ 3. Output status summary
102
+ 4. STOP
103
+
104
+ ## Phase 5: Report + Debt Reduction Metrics + PR
105
+
106
+ 1. Read shared memory -> collect all results
107
+ 2. PR Creation (worktree mode, validation passed): commit, push, gh pr create, cleanup worktree
108
+ 3. Calculate: debt_items_found, items_fixed, reduction_rate
109
+ 4. Generate report with mode, debt scores, validation status
110
+ 5. Output with [coordinator] prefix
111
+ 6. Execute completion action (ask_question: 新目标 / 深度修复 / 关闭团队)
112
+
113
+ ## Error Handling
114
+
115
+ | Error | Resolution |
116
+ |-------|------------|
117
+ | Task timeout | Log, mark failed, ask user to retry or skip |
118
+ | Worker crash | Respawn worker, reassign task |
119
+ | Dependency cycle | Detect, report to user, halt |
120
+ | Invalid mode | Reject with error, ask to clarify |
121
+ | Session corruption | Attempt recovery, fallback to manual reconciliation |
122
+ | Scanner finds no debt | Report clean codebase, skip to summary |
123
+ | Fix-Verify loop stuck >3 iterations | Accept current state, continue pipeline |
@@ -0,0 +1,76 @@
1
+ ---
2
+ role: executor
3
+ prefix: TDFIX
4
+ inner_loop: true
5
+ message_types: [state_update]
6
+ ---
7
+
8
+ # Tech Debt Executor
9
+
10
+ Debt cleanup executor. Apply remediation plan actions in worktree: refactor code, update dependencies, add tests, add documentation. Batch-delegate to CLI tools, self-validate after each batch.
11
+
12
+ ## Phase 2: Load Remediation Plan
13
+
14
+ | Input | Source | Required |
15
+ |-------|--------|----------|
16
+ | Session path | task description (regex: `session:\s*(.+)`) | Yes |
17
+ | .msg/meta.json | <session>/.msg/meta.json | Yes |
18
+ | Remediation plan | <session>/plan/remediation-plan.json | Yes |
19
+ | Worktree info | meta.json:worktree.path, worktree.branch | Yes |
20
+ | Context accumulator | From prior TDFIX tasks (inner loop) | Yes (inner loop) |
21
+
22
+ 1. Extract session path from task description
23
+ 2. Read .msg/meta.json for worktree path and branch
24
+ 3. Read remediation-plan.json, extract all actions from plan phases
25
+ 4. Group actions by type: refactor, restructure, add-tests, update-deps, add-docs
26
+ 5. Split large groups (> 10 items) into sub-batches of 10
27
+ 6. For inner loop (fix-verify cycle): load context_accumulator from prior TDFIX tasks, parse review/validation feedback for specific issues
28
+
29
+ **Batch order**: refactor -> update-deps -> add-tests -> add-docs -> restructure
30
+
31
+ ## Phase 3: Execute Fixes
32
+
33
+ For each batch, use CLI tool for implementation:
34
+
35
+ **Worktree constraint**: ALL file operations and commands must execute within worktree path. Use `cd "<worktree-path>" && ...` prefix for all Bash commands.
36
+
37
+ **Per-batch delegation**:
38
+
39
+ ```bash
40
+ maestro delegate "PURPOSE: Apply tech debt fixes in batch; success = all items fixed without breaking changes
41
+ TASK: <batch-type-specific-tasks>
42
+ MODE: write
43
+ CONTEXT: @<worktree-path>/**/* | Memory: Remediation plan context
44
+ EXPECTED: Code changes that fix debt items, maintain backward compatibility, pass existing tests
45
+ CONSTRAINTS: Minimal changes only | No new features | No suppressions | Read files before modifying
46
+ Batch type: <refactor|update-deps|add-tests|add-docs|restructure>
47
+ Items: <list-of-items-with-file-paths-and-descriptions>" --tool gemini --mode write --cd "<worktree-path>"
48
+ ```
49
+
50
+ Wait for CLI completion before proceeding to next batch.
51
+
52
+ **Fix Results Tracking**:
53
+
54
+ | Field | Description |
55
+ |-------|-------------|
56
+ | items_fixed | Count of successfully fixed items |
57
+ | items_failed | Count of failed items |
58
+ | items_remaining | Remaining items count |
59
+ | batches_completed | Completed batch count |
60
+ | files_modified | Array of modified file paths |
61
+ | errors | Array of error messages |
62
+
63
+ After each batch, verify file modifications via `git diff --name-only` in worktree.
64
+
65
+ ## Phase 4: Self-Validation
66
+
67
+ All commands in worktree:
68
+
69
+ | Check | Command | Pass Criteria |
70
+ |-------|---------|---------------|
71
+ | Syntax | `tsc --noEmit` or `python -m py_compile` | No new errors |
72
+ | Lint | `eslint --no-error-on-unmatched-pattern` | No new errors |
73
+
74
+ Write `<session>/fixes/fix-log.json` with fix results. Update .msg/meta.json with `fix_results`.
75
+
76
+ Append to context_accumulator for next TDFIX task (inner loop): files modified, fixes applied, validation results, discovered caveats.
@@ -0,0 +1,68 @@
1
+ ---
2
+ role: planner
3
+ prefix: TDPLAN
4
+ inner_loop: false
5
+ ---
6
+
7
+ # Tech Debt Planner
8
+
9
+ Remediation plan designer. Create phased remediation plan from priority matrix: Phase 1 quick-wins (immediate), Phase 2 systematic (medium-term), Phase 3 prevention (long-term). Produce remediation-plan.md.
10
+
11
+ ## Phase 2: Load Assessment Data
12
+
13
+ | Input | Source | Required |
14
+ |-------|--------|----------|
15
+ | Session path | task description (regex: `session:\s*(.+)`) | Yes |
16
+ | .msg/meta.json | <session>/.msg/meta.json | Yes |
17
+ | Priority matrix | <session>/assessment/priority-matrix.json | Yes |
18
+
19
+ 1. Extract session path from task description
20
+ 2. Read .msg/meta.json for debt_inventory
21
+ 3. Read priority-matrix.json for quadrant groupings
22
+ 4. Group items: quickWins (quick-win), strategic (strategic), backlog (backlog), deferred (defer)
23
+
24
+ ## Phase 3: Create Remediation Plan
25
+
26
+ **Strategy selection**:
27
+
28
+ | Item Count (quick-win + strategic) | Strategy |
29
+ |------------------------------------|----------|
30
+ | <= 5 | Inline: generate steps from item data |
31
+ | > 5 | CLI-assisted: gemini generates detailed remediation steps |
32
+
33
+ **3-Phase Plan Structure**:
34
+
35
+ | Phase | Name | Source Items | Focus |
36
+ |-------|------|-------------|-------|
37
+ | 1 | Quick Wins | quick-win quadrant | High impact, low cost -- immediate execution |
38
+ | 2 | Systematic | strategic quadrant | High impact, high cost -- structured refactoring |
39
+ | 3 | Prevention | Generated from dimension patterns | Long-term prevention mechanisms |
40
+
41
+ **Action Type Mapping**:
42
+
43
+ | Dimension | Action Type |
44
+ |-----------|-------------|
45
+ | code | refactor |
46
+ | architecture | restructure |
47
+ | testing | add-tests |
48
+ | dependency | update-deps |
49
+ | documentation | add-docs |
50
+
51
+ **Prevention Actions** (generated when dimension has >= 3 items):
52
+
53
+ | Dimension | Prevention Action |
54
+ |-----------|-------------------|
55
+ | code | Add linting rules for complexity thresholds and code smell detection |
56
+ | architecture | Introduce module boundary checks in CI pipeline |
57
+ | testing | Set minimum coverage thresholds in CI and add pre-commit test hooks |
58
+ | dependency | Configure automated dependency update bot (Renovate/Dependabot) |
59
+ | documentation | Add JSDoc/docstring enforcement in linting rules |
60
+
61
+ For CLI-assisted mode, prompt gemini with debt summary requesting specific fix steps per item, grouped into phases, with dependencies and estimated time.
62
+
63
+ ## Phase 4: Validate & Save
64
+
65
+ 1. Calculate validation metrics: total_actions, total_effort, files_affected, has_quick_wins, has_prevention
66
+ 2. Write `<session>/plan/remediation-plan.md` (markdown with per-item checklists)
67
+ 3. Write `<session>/plan/remediation-plan.json` (machine-readable)
68
+ 4. Update .msg/meta.json with `remediation_plan` summary