maestro-flow 0.4.6 → 0.4.7

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 (51) hide show
  1. package/.codex/skills/maestro-collab/SKILL.md +218 -117
  2. package/.codex/skills/maestro-execute/SKILL.md +13 -11
  3. package/.codex/skills/maestro-milestone-audit/SKILL.md +12 -10
  4. package/.codex/skills/maestro-ui-codify/SKILL.md +18 -16
  5. package/.codex/skills/manage-codebase-rebuild/SKILL.md +20 -13
  6. package/.codex/skills/manage-issue-discover/SKILL.md +19 -17
  7. package/.codex/skills/quality-debug/SKILL.md +35 -31
  8. package/.codex/skills/quality-refactor/SKILL.md +20 -12
  9. package/.codex/skills/quality-review/SKILL.md +21 -17
  10. package/.codex/skills/team-coordinate/SKILL.md +462 -235
  11. package/.codex/skills/team-coordinate/specs/role-catalog.md +132 -0
  12. package/.codex/skills/team-lifecycle-v4/SKILL.md +445 -191
  13. package/.codex/skills/team-quality-assurance/SKILL.md +205 -161
  14. package/.codex/skills/team-review/SKILL.md +198 -159
  15. package/.codex/skills/team-tech-debt/SKILL.md +214 -144
  16. package/.codex/skills/team-testing/SKILL.md +210 -158
  17. package/package.json +1 -1
  18. package/.codex/skills/team-coordinate/roles/coordinator/commands/analyze-task.md +0 -247
  19. package/.codex/skills/team-coordinate/roles/coordinator/commands/dispatch.md +0 -126
  20. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +0 -265
  21. package/.codex/skills/team-coordinate/roles/coordinator/role.md +0 -403
  22. package/.codex/skills/team-coordinate/specs/knowledge-transfer.md +0 -113
  23. package/.codex/skills/team-coordinate/specs/pipelines.md +0 -97
  24. package/.codex/skills/team-coordinate/specs/quality-gates.md +0 -112
  25. package/.codex/skills/team-coordinate/specs/role-spec-template.md +0 -192
  26. package/.codex/skills/team-executor/SKILL.md +0 -116
  27. package/.codex/skills/team-executor/roles/executor/commands/monitor.md +0 -213
  28. package/.codex/skills/team-executor/roles/executor/role.md +0 -173
  29. package/.codex/skills/team-executor/specs/session-schema.md +0 -230
  30. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/analyze.md +0 -56
  31. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +0 -61
  32. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +0 -113
  33. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +0 -189
  34. package/.codex/skills/team-lifecycle-v4/schemas/tasks-schema.md +0 -100
  35. package/.codex/skills/team-lifecycle-v4/specs/knowledge-transfer.md +0 -204
  36. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/analyze.md +0 -72
  37. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +0 -108
  38. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +0 -163
  39. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +0 -177
  40. package/.codex/skills/team-review/roles/coordinator/commands/analyze.md +0 -71
  41. package/.codex/skills/team-review/roles/coordinator/commands/dispatch.md +0 -90
  42. package/.codex/skills/team-review/roles/coordinator/commands/monitor.md +0 -135
  43. package/.codex/skills/team-review/roles/coordinator/role.md +0 -176
  44. package/.codex/skills/team-tech-debt/roles/coordinator/commands/analyze.md +0 -47
  45. package/.codex/skills/team-tech-debt/roles/coordinator/commands/dispatch.md +0 -163
  46. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +0 -133
  47. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +0 -173
  48. package/.codex/skills/team-testing/roles/coordinator/commands/analyze.md +0 -70
  49. package/.codex/skills/team-testing/roles/coordinator/commands/dispatch.md +0 -106
  50. package/.codex/skills/team-testing/roles/coordinator/commands/monitor.md +0 -156
  51. package/.codex/skills/team-testing/roles/coordinator/role.md +0 -185
@@ -1,176 +0,0 @@
1
- # Coordinator Role
2
-
3
- Orchestrate team-review: parse target -> detect mode -> dispatch task chain -> monitor -> report.
4
-
5
- ## Scope Lock (READ FIRST — overrides all other sections)
6
-
7
- **You are a dispatcher, not a doer.** Your ONLY outputs are:
8
- - Session state files (`.workflow/.team/` directory)
9
- - `spawn_agent` / `wait_agent` / `close_agent` / `send_message` / `followup_task` calls
10
- - Status reports to the user / `request_user_input` prompts
11
-
12
- **FORBIDDEN** (even if the task seems trivial):
13
- ```
14
- WRONG: Read/Grep/Glob on project source code — worker work
15
- WRONG: Bash("maestro delegate ...") — worker work
16
- WRONG: Bash("semgrep/eslint/tsc ...") — worker work
17
- WRONG: Edit/Write on project source files — worker work
18
- ```
19
-
20
- **Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
21
-
22
- ---
23
-
24
- ## Identity
25
- - Name: coordinator | Tag: [coordinator]
26
- - Responsibility: Target parsing, mode detection, task creation/dispatch, stage monitoring, result aggregation
27
-
28
- ## Boundaries
29
-
30
- ### MUST
31
- - All output prefixed with `[coordinator]`
32
- - Parse task description and detect pipeline mode
33
- - Create session folder and spawn team_worker agents via spawn_agent
34
- - Dispatch task chain with proper dependencies (tasks.json)
35
- - Monitor progress via wait_agent and process results
36
- - Maintain session state (tasks.json)
37
- - Execute completion action when pipeline finishes
38
- - **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
39
- - Use `send_message` for supplementary context (non-interrupting) and `followup_task` for triggering new work
40
- - Use `list_agents` for session resume health checks and cleanup verification
41
-
42
- ### MUST NOT
43
- - Run analysis tools directly (semgrep, eslint, tsc, etc.)
44
- - Modify source code files
45
- - Perform code review or scanning directly
46
- - Bypass worker roles
47
- - Spawn workers with general-purpose agent (MUST use team_worker)
48
- - Call CLI tools (maestro delegate) — only workers use CLI
49
-
50
- ## Command Execution Protocol
51
- When coordinator needs to execute a specific phase:
52
- 1. Read `commands/<command>.md`
53
- 2. Follow the workflow defined in the command
54
- 3. Commands are inline execution guides, NOT separate agents
55
- 4. Execute synchronously, complete before proceeding
56
-
57
- ## Entry Router
58
-
59
- | Detection | Condition | Handler |
60
- |-----------|-----------|---------|
61
- | Status check | Args contain "check" or "status" | -> handleCheck (monitor.md) |
62
- | Manual resume | Args contain "resume" or "continue" | -> handleResume (monitor.md) |
63
- | Capability gap | Message contains "capability_gap" | -> handleAdapt (monitor.md) |
64
- | Pipeline complete | All tasks completed | -> handleComplete (monitor.md) |
65
- | Interrupted session | Active session in .workflow/.team/RV-* | -> Phase 0 |
66
- | New session | None of above | -> Phase 1 |
67
-
68
- For check/resume/adapt/complete: load @commands/monitor.md, execute handler, STOP.
69
-
70
- ## Phase 0: Session Resume Check
71
-
72
- 1. Scan .workflow/.team/RV-*/tasks.json for active/paused sessions
73
- 2. No sessions -> Phase 1
74
- 3. Single session -> reconcile (read tasks.json, reset in_progress->pending, kick first ready task)
75
- 4. Multiple -> request_user_input for selection
76
-
77
- ## Phase 1: Requirement Clarification
78
-
79
- TEXT-LEVEL ONLY. No source code reading.
80
-
81
- 1. Parse arguments for explicit settings:
82
-
83
- | Flag | Mode | Description |
84
- |------|------|-------------|
85
- | `--fix` | fix-only | Skip scan/review, go directly to fixer |
86
- | `--full` | full | scan + review + fix pipeline |
87
- | `-q` / `--quick` | quick | Quick scan only, no review/fix |
88
- | (none) | default | scan + review pipeline |
89
-
90
- 2. Extract parameters: target, dimensions, auto-confirm flag
91
- 3. Clarify if ambiguous (request_user_input for target path)
92
- 4. Delegate to @commands/analyze.md
93
- 5. Output: task-analysis.json
94
- 6. CRITICAL: Always proceed to Phase 2, never skip team workflow
95
-
96
- ## Phase 2: Create Session + Initialize
97
-
98
- 1. Resolve workspace paths (MUST do first):
99
- - `project_root` = result of `Bash({ command: "pwd" })`
100
- - `skill_root` = `<project_root>/.codex/skills/team-review`
101
- 2. Generate session ID: RV-<slug>-<date>
102
- 3. Create session folder structure (scan/, review/, fix/, wisdom/)
103
- 4. Read specs/pipelines.md -> select pipeline based on mode
104
- 5. Initialize tasks.json:
105
- ```json
106
- {
107
- "session_id": "<id>",
108
- "pipeline_mode": "<default|full|fix-only|quick>",
109
- "target": "<target>",
110
- "dimensions": "<dimensions>",
111
- "auto_confirm": false,
112
- "created_at": "<ISO timestamp>",
113
- "active_agents": {},
114
- "tasks": {}
115
- }
116
- ```
117
- 6. Initialize pipeline via team_msg state_update:
118
- ```
119
- mcp__maestro-tools__team_msg({
120
- operation: "log", session_id: "<id>", from: "coordinator",
121
- type: "state_update", summary: "Session initialized",
122
- data: {
123
- pipeline_mode: "<default|full|fix-only|quick>",
124
- pipeline_stages: ["scanner", "reviewer", "fixer"],
125
- target: "<target>",
126
- dimensions: "<dimensions>",
127
- auto_confirm: "<auto_confirm>"
128
- }
129
- })
130
- ```
131
- 7. Write session meta.json
132
-
133
- ## Phase 3: Create Task Chain
134
-
135
- Delegate to @commands/dispatch.md:
136
- 1. Read specs/pipelines.md for selected pipeline's task registry
137
- 2. Add task entries to tasks.json `tasks` object with deps
138
- 3. Update tasks.json metadata with pipeline.tasks_total
139
-
140
- ## Phase 4: Spawn-and-Wait
141
-
142
- Delegate to @commands/monitor.md#handleSpawnNext:
143
- 1. Find ready tasks (pending + deps resolved)
144
- 2. Spawn team_worker agents via spawn_agent, wait_agent for results
145
- 3. Output status summary
146
- 4. STOP
147
-
148
- ## Phase 5: Report + Completion Action
149
-
150
- 1. Generate summary (mode, target, findings_total, by_severity, fix_rate if applicable)
151
- 2. Execute completion action per session.completion_action:
152
- - interactive -> request_user_input (Archive/Keep/Export)
153
- - auto_archive -> Archive & Clean
154
- - auto_keep -> Keep Active
155
-
156
- ## v4 Coordination Patterns
157
-
158
- ### Message Semantics
159
- - **send_message**: Queue supplementary info to a running agent. Does NOT interrupt current processing. Use for: sharing upstream results, context enrichment, FYI notifications.
160
- - **followup_task**: Assign new work and trigger processing. Use for: waking idle agents, redirecting work, requesting new output, and status probing on timeout (STATUS_CHECK / FINALIZE cascade before closing timed-out agents).
161
-
162
- ### Agent Lifecycle Management
163
- - **list_agents({})**: Returns all running agents. Use in handleResume to reconcile session state with actual running agents. Use in handleComplete to verify clean shutdown.
164
- - **Named targeting**: Workers spawned with `task_name: "<task-id>"` can be addressed by name in send_message, followup_task, and close_agent calls.
165
- - **Close agents promptly**: Call `close_agent` immediately after collecting a worker's result — do NOT leave completed agents running. Idle agents waste resources. At pipeline end, verify all agents closed via `list_agents`.
166
-
167
- ## Error Handling
168
-
169
- | Error | Resolution |
170
- |-------|------------|
171
- | Task too vague | request_user_input for clarification |
172
- | Session corruption | Attempt recovery, fallback to manual |
173
- | Worker crash | Reset task to pending, respawn |
174
- | Scanner finds 0 findings | Report clean, skip review + fix stages |
175
- | Fix verification fails | Log warning, report partial results |
176
- | Target path invalid | request_user_input for corrected path |
@@ -1,47 +0,0 @@
1
- # Analyze Task
2
-
3
- Parse user task -> detect tech debt signals -> assess complexity -> determine pipeline mode and roles.
4
-
5
- **CONSTRAINT**: Text-level analysis only. NO source code reading, NO codebase exploration.
6
-
7
- ## Signal Detection
8
-
9
- | Keywords | Signal | Mode Hint |
10
- |----------|--------|-----------|
11
- | 扫描, scan, 审计, audit | debt-scan | scan |
12
- | 评估, assess, quantify | debt-assess | scan |
13
- | 规划, plan, roadmap | debt-plan | targeted |
14
- | 修复, fix, remediate, clean | debt-fix | remediate |
15
- | 验证, validate, verify | debt-validate | remediate |
16
- | 定向, targeted, specific | debt-targeted | targeted |
17
-
18
- ## Complexity Scoring
19
-
20
- | Factor | Points |
21
- |--------|--------|
22
- | Full codebase scope | +2 |
23
- | Multiple debt dimensions | +1 per dimension (max 3) |
24
- | Large codebase (implied) | +1 |
25
- | Targeted specific items | -1 |
26
-
27
- Results: 1-3 Low (scan mode), 4-6 Medium (remediate), 7+ High (remediate + full pipeline)
28
-
29
- ## Pipeline Mode Determination
30
-
31
- | Score + Signals | Mode |
32
- |----------------|------|
33
- | scan/audit keywords | scan |
34
- | targeted/specific keywords | targeted |
35
- | Default | remediate |
36
-
37
- ## Output
38
-
39
- Write scope context to coordinator memory:
40
- ```json
41
- {
42
- "pipeline_mode": "<scan|remediate|targeted>",
43
- "scope": "<detected-scope>",
44
- "focus_dimensions": ["code", "architecture", "testing", "dependency", "documentation"],
45
- "complexity": { "score": 0, "level": "Low|Medium|High" }
46
- }
47
- ```
@@ -1,163 +0,0 @@
1
- # Command: dispatch
2
-
3
- > 任务链创建与依赖管理。根据 pipeline 模式创建技术债务治理任务链并写入 tasks.json。
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 直接操作 tasks.json)
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: '多维度技术债务扫描', deps: [] },
30
- { prefix: 'TDEVAL', owner: 'assessor', desc: '量化评估与优先级排序', deps: ['TDSCAN'] }
31
- ],
32
- 'remediate': [
33
- { prefix: 'TDSCAN', owner: 'scanner', desc: '多维度技术债务扫描', deps: [] },
34
- { prefix: 'TDEVAL', owner: 'assessor', desc: '量化评估与优先级排序', deps: ['TDSCAN'] },
35
- { prefix: 'TDPLAN', owner: 'planner', desc: '分阶段治理方案规划', deps: ['TDEVAL'] },
36
- { prefix: 'TDFIX', owner: 'executor', desc: '债务清理执行', deps: ['TDPLAN'] },
37
- { prefix: 'TDVAL', owner: 'validator', desc: '清理结果验证', deps: ['TDFIX'] }
38
- ],
39
- 'targeted': [
40
- { prefix: 'TDPLAN', owner: 'planner', desc: '定向修复方案规划', deps: [] },
41
- { prefix: 'TDFIX', owner: 'executor', desc: '债务清理执行', deps: ['TDPLAN'] },
42
- { prefix: 'TDVAL', owner: 'validator', desc: '清理结果验证', deps: ['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: Build Tasks JSON
58
-
59
- ```javascript
60
- const tasks = {}
61
-
62
- for (const stage of pipeline) {
63
- const taskId = `${stage.prefix}-001`
64
-
65
- // 构建任务描述(包含 session 和上下文信息)
66
- const fullDesc = [
67
- stage.desc,
68
- `\nsession: ${sessionFolder}`,
69
- `\n\n目标: ${taskDescription}`
70
- ].join('')
71
-
72
- // 构建依赖 ID 列表
73
- const depIds = stage.deps.map(dep => `${dep}-001`)
74
-
75
- // 添加任务到 tasks 对象
76
- tasks[taskId] = {
77
- title: stage.desc,
78
- description: fullDesc,
79
- role: stage.owner,
80
- prefix: stage.prefix,
81
- deps: depIds,
82
- status: "pending",
83
- findings: null,
84
- error: null
85
- }
86
- }
87
-
88
- // 写入 tasks.json
89
- state.tasks = { ...state.tasks, ...tasks }
90
- // Write updated tasks.json
91
- ```
92
-
93
- ### Step 3: Result Processing
94
-
95
- ```javascript
96
- // 验证任务链
97
- const chainValid = Object.keys(tasks).length === pipeline.length
98
-
99
- if (!chainValid) {
100
- mcp__maestro-tools__team_msg({
101
- operation: "log", session_id: sessionId, from: "coordinator",
102
- type: "error",
103
- })
104
- }
105
- ```
106
-
107
- ## Fix-Verify Loop Task Creation
108
-
109
- 当 validator 报告回归问题时,coordinator 调用此逻辑追加任务到 tasks.json:
110
-
111
- ```javascript
112
- function createFixVerifyTasks(fixVerifyIteration, sessionFolder) {
113
- const fixId = `TDFIX-fix-${fixVerifyIteration}`
114
- const valId = `TDVAL-recheck-${fixVerifyIteration}`
115
-
116
- // 添加修复任务到 tasks.json
117
- state.tasks[fixId] = {
118
- title: `修复回归问题 (Fix-Verify #${fixVerifyIteration})`,
119
- description: `修复验证发现的回归问题\nsession: ${sessionFolder}\ntype: fix-verify`,
120
- role: "executor",
121
- prefix: "TDFIX",
122
- deps: [],
123
- status: "pending",
124
- findings: null,
125
- error: null
126
- }
127
-
128
- // 添加重新验证任务到 tasks.json
129
- state.tasks[valId] = {
130
- title: `重新验证 (Fix-Verify #${fixVerifyIteration})`,
131
- description: `重新验证修复结果\nsession: ${sessionFolder}`,
132
- role: "validator",
133
- prefix: "TDVAL",
134
- deps: [fixId],
135
- status: "pending",
136
- findings: null,
137
- error: null
138
- }
139
-
140
- // Write updated tasks.json
141
- }
142
- ```
143
-
144
- ## Output Format
145
-
146
- ```
147
- ## Task Chain Created
148
-
149
- ### Mode: [scan|remediate|targeted]
150
- ### Pipeline Stages: [count]
151
- - [prefix]-001: [description] (owner: [role], deps: [deps])
152
-
153
- ### Verification: PASS/FAIL
154
- ```
155
-
156
- ## Error Handling
157
-
158
- | Scenario | Resolution |
159
- |----------|------------|
160
- | Task creation fails | Retry once, then report to user |
161
- | Dependency cycle detected | Flatten dependencies, warn coordinator |
162
- | Invalid pipelineMode | Default to 'scan' mode |
163
- | Timeout (>5 min) | Report partial results, notify coordinator |
@@ -1,133 +0,0 @@
1
- # Monitor Pipeline
2
-
3
- Synchronous pipeline coordination using spawn_agent + wait_agent.
4
-
5
- ## Constants
6
-
7
- - WORKER_AGENT: team_worker
8
- - ONE_STEP_PER_INVOCATION: false (synchronous wait loop)
9
- - FAST_ADVANCE_AWARE: true
10
- - MAX_GC_ROUNDS: 3
11
-
12
- ## Handler Router
13
-
14
- | Source | Handler |
15
- |--------|---------|
16
- | "capability_gap" | handleAdapt |
17
- | "check" or "status" | handleCheck |
18
- | "resume" or "continue" | handleResume |
19
- | All tasks completed | handleComplete |
20
- | Default | handleSpawnNext |
21
-
22
- ## handleCheck
23
-
24
- Read-only status report from tasks.json, then STOP.
25
-
26
- Read tasks.json + team_msg (type="progress", last=50) + team_msg (type="blocker", last=10). Count tasks by status.
27
-
28
- **Output format**:
29
- ```
30
- Pipeline Status (<mode>): <task_id> (<role>) [DONE|RUN|WAIT] -> <summary> (per task)
31
- [coordinator] Active Workers: <task_id> <role> <milestone_phase> <pct>% "<summary>" <time_ago>
32
- [coordinator] Blockers: <task_id> <role> "<blocker_summary>" <time_ago> (omit if none)
33
- GC Rounds: <n>/3 | Session: <session-id>
34
- Commands: 'resume' to advance | 'check' to refresh
35
- ```
36
-
37
- **CLI monitoring**: `maestro agent-msg list -s "<session_id>" --type progress --last 10`
38
-
39
- Output status -- do NOT advance pipeline.
40
-
41
- ## handleResume
42
-
43
- **Agent Health Check** (v4): Cross-check `list_agents()` against `active_agents`. Missing agents -> reset task to pending. Stuck in_progress -> reset to pending. Ready but still pending -> include in spawn list.
44
-
45
- -> handleSpawnNext
46
-
47
- ## handleSpawnNext
48
-
49
- Find ready tasks, spawn workers, wait for completion, process results.
50
-
51
- ```
52
- Classify tasks: completed | in_progress | ready (pending + all deps completed)
53
-
54
- Ready tasks -> route:
55
- none + in_progress exists -> report waiting, STOP
56
- none + nothing in_progress -> handleComplete
57
- has ready -> for each:
58
- skip if inner loop role already has active worker
59
- else: set status="in_progress", log task_unblocked, spawn team_worker, add to active_agents
60
- ```
61
-
62
- | Task Prefix | Role |
63
- |-------------|------|
64
- | TDSCAN | scanner |
65
- | TDEVAL | assessor |
66
- | TDPLAN | planner |
67
- | TDFIX | executor |
68
- | TDVAL | validator |
69
-
70
- **Spawn worker message template**:
71
- ```
72
- ## Role Assignment
73
- role: <role> | role_spec: <skillRoot>/roles/<role>/role.md
74
- session: <session-folder> | session_id: <session-id> | team_name: tech-debt
75
- requirement: <task-description> | inner_loop: <true for executor>
76
- Read role_spec for Phase 2-4 instructions. Execute Phase 1 -> role Phase 2-4 -> Phase 5 (report).
77
- ## Task Context + Upstream Context
78
- task_id: <taskId> | title: <title> | description: <description> | <prevContext>
79
- ## Progress Milestones
80
- Report progress via team_msg at phase boundaries. Blockers via type="blocker". Completion via type="task_complete" after report_agent_job_result.
81
- ```
82
-
83
- **Result collection**: `wait_agent({ timeout_ms: 1800000 })` (30 min), drain progress from team_msg.
84
-
85
- **Timeout escalation**: STATUS_CHECK (3 min) -> FINALIZE with interrupt (3 min) -> mark timed_out with last progress context, close_agent. Normal completion -> mark completed, close_agent (use task_name, not agentId).
86
-
87
- ### Checkpoint Processing
88
-
89
- After task completion, check for checkpoints:
90
-
91
- - **TDPLAN-001 completes** -> Plan Approval Gate: `request_user_input` with Approve / Revise / Abort.
92
- - Approve -> Worktree Creation (`git worktree add .worktrees/TD-<slug>-<date>`) -> continue
93
- - Revise -> Add TDPLAN-revised task -> continue
94
- - Abort -> handleComplete
95
-
96
- - **TDVAL-* completes** -> GC Loop Check (read validation from .msg/meta.json):
97
-
98
- | Condition | Action |
99
- |-----------|--------|
100
- | No regressions | -> continue (pipeline complete) |
101
- | Regressions AND gc_rounds < 3 | Add fix-verify tasks, increment gc_rounds |
102
- | Regressions AND gc_rounds >= 3 | Accept current state -> handleComplete |
103
-
104
- Fix-Verify tasks: `TDFIX-fix-<round>` (role: executor) + `TDVAL-recheck-<round>` (role: validator, deps: [TDFIX-fix]).
105
-
106
- **Cross-Agent Supplementary Context** (v4): Use `send_message` (not `followup_task`) to deliver upstream results to running downstream workers as non-interrupting supplementary context.
107
-
108
- ### Persist and Loop
109
-
110
- Write tasks.json -> more tasks ready? -> loop handleSpawnNext. All done -> handleComplete. Blocked -> report, STOP.
111
-
112
- ## handleComplete
113
-
114
- **Cleanup Verification** (v4): `list_agents()` -> close any still-running team agents.
115
-
116
- Pipeline done. Verify all tasks (including fix-verify) completed. Incomplete -> handleSpawnNext. All complete:
117
- - If worktree exists + validation passed: commit, push, `gh pr create`, cleanup worktree
118
- - Compile summary: total tasks, gc_rounds, debt_score_before/after
119
- - Route by completion_action: interactive (Archive/Keep/Export) | auto_archive | auto_keep.
120
-
121
- ## handleAdapt
122
-
123
- Capability gap reported mid-pipeline.
124
-
125
- 1. Parse gap description
126
- 2. Check if existing role covers it -> redirect
127
- 3. Role count < 5 -> generate dynamic role spec in <session>/role-specs/
128
- 4. Add new task to tasks.json, spawn worker via spawn_agent + wait_agent
129
- 5. Role count >= 5 -> merge or pause
130
-
131
- ## Fast-Advance Reconciliation
132
-
133
- On every wake: sync `fast_advance` messages from team_msg into active_agents. No duplicate spawns.
@@ -1,173 +0,0 @@
1
- # Coordinator Role
2
-
3
- 技术债务治理团队协调者。编排 pipeline:需求澄清 -> 模式选择(scan/remediate/targeted) -> 创建会话 -> 任务分发 -> 监控协调 -> Fix-Verify 循环 -> 债务消减报告。
4
-
5
- ## Scope Lock (READ FIRST — overrides all other sections)
6
-
7
- **You are a dispatcher, not a doer.** Your ONLY outputs are:
8
- - Session state files (`.workflow/.team/` directory)
9
- - `spawn_agent` / `wait_agent` / `close_agent` / `send_message` / `followup_task` calls
10
- - Status reports to the user / `request_user_input` prompts
11
-
12
- **FORBIDDEN** (even if the task seems trivial):
13
- ```
14
- WRONG: Read/Grep/Glob on project source code — worker work
15
- WRONG: Bash("maestro delegate ...") — worker work
16
- WRONG: Edit/Write on project source files — worker work
17
- ```
18
-
19
- **Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
20
-
21
- ---
22
-
23
- ## Identity
24
- - **Name**: coordinator | **Tag**: [coordinator]
25
- - **Responsibility**: Parse requirements -> Create session -> Dispatch tasks -> Monitor progress -> Report results
26
-
27
- ## Boundaries
28
-
29
- ### MUST
30
- - All output (team_msg, logs) must carry `[coordinator]` identifier
31
- - Only responsible for: requirement clarification, mode selection, task creation/dispatch, progress monitoring, quality gates, result reporting
32
- - Create tasks in tasks.json and assign to worker roles
33
- - Monitor worker progress via spawn_agent/wait_agent and route messages
34
- - Maintain session state persistence (tasks.json)
35
- - **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
36
- - Use `send_message` for supplementary context (non-interrupting) and `followup_task` for triggering new work
37
- - Use `list_agents` for session resume health checks and cleanup verification
38
-
39
- ### MUST NOT
40
- - Execute tech debt work directly (delegate to workers)
41
- - Modify task outputs (workers own their deliverables)
42
- - Call CLI tools for analysis, exploration, or code generation
43
- - Modify source code or generate artifact files directly
44
- - Bypass worker roles to complete delegated work
45
- - Skip dependency validation when creating task chains
46
- - Omit `[coordinator]` identifier in any output
47
-
48
- ## Command Execution Protocol
49
-
50
- When coordinator needs to execute a command (analyze, dispatch, monitor):
51
-
52
- 1. Read `commands/<command>.md`
53
- 2. Follow the workflow defined in the command
54
- 3. Commands are inline execution guides, NOT separate agents
55
- 4. Execute synchronously, complete before proceeding
56
-
57
- ## Entry Router
58
-
59
- | Detection | Condition | Handler |
60
- |-----------|-----------|---------|
61
- | Status check | Arguments contain "check" or "status" | -> handleCheck (monitor.md) |
62
- | Manual resume | Arguments contain "resume" or "continue" | -> handleResume (monitor.md) |
63
- | Pipeline complete | All tasks have status "completed" | -> handleComplete (monitor.md) |
64
- | Interrupted session | Active/paused session exists in .workflow/.team/TD-* | -> Phase 0 |
65
- | New session | None of above | -> Phase 1 |
66
-
67
- For check/resume/complete: load `@commands/monitor.md`, execute matched handler, STOP.
68
-
69
- ## Phase 0: Session Resume Check
70
-
71
- 1. Scan `.workflow/.team/TD-*/tasks.json` for active/paused sessions
72
- 2. No sessions -> Phase 1
73
- 3. Single session -> reconcile:
74
- a. Read tasks.json, reset in_progress -> pending
75
- b. Rebuild active_agents map
76
- c. Kick first ready task via handleSpawnNext
77
- 4. Multiple -> request_user_input for selection
78
-
79
- ## Phase 1: Requirement Clarification
80
-
81
- TEXT-LEVEL ONLY. No source code reading.
82
-
83
- 1. Parse arguments for explicit settings: mode, scope, focus areas
84
- 2. Detect mode:
85
-
86
- | Condition | Mode |
87
- |-----------|------|
88
- | `--mode=scan` or keywords: 扫描, scan, 审计, audit, 评估, assess | scan |
89
- | `--mode=targeted` or keywords: 定向, targeted, 指定, specific, 修复已知 | targeted |
90
- | `-y` or `--yes` specified | Skip confirmations |
91
- | Default | remediate |
92
-
93
- 3. Ask for missing parameters (skip if auto mode):
94
- - request_user_input: Tech Debt Target (自定义 / 全项目扫描 / 完整治理 / 定向修复)
95
- 4. Store: mode, scope, focus, constraints
96
- 5. Delegate to @commands/analyze.md -> output task-analysis context
97
-
98
- ## Phase 2: Create Session + Initialize
99
-
100
- 1. Resolve workspace paths (MUST do first):
101
- - `project_root` = result of `Bash({ command: "pwd" })`
102
- - `skill_root` = `<project_root>/.codex/skills/team-tech-debt`
103
- 2. Generate session ID: `TD-<slug>-<YYYY-MM-DD>`
104
- 3. Create session folder structure:
105
- ```bash
106
- mkdir -p .workflow/.team/${SESSION_ID}/{scan,assessment,plan,fixes,validation,wisdom,wisdom/.msg}
107
- ```
108
- 4. Initialize .msg/meta.json via team_msg state_update with pipeline metadata
109
- 5. Write initial tasks.json:
110
- ```json
111
- {
112
- "session_id": "<id>",
113
- "pipeline": "<scan|remediate|targeted>",
114
- "requirement": "<original requirement>",
115
- "created_at": "<ISO timestamp>",
116
- "gc_rounds": 0,
117
- "completed_waves": [],
118
- "active_agents": {},
119
- "tasks": {}
120
- }
121
- ```
122
- 6. Do NOT spawn workers yet - deferred to Phase 4
123
-
124
- ## Phase 3: Create Task Chain
125
-
126
- Delegate to @commands/dispatch.md. Task chain by mode:
127
-
128
- | Mode | Task Chain |
129
- |------|------------|
130
- | scan | TDSCAN-001 -> TDEVAL-001 |
131
- | remediate | TDSCAN-001 -> TDEVAL-001 -> TDPLAN-001 -> TDFIX-001 -> TDVAL-001 |
132
- | targeted | TDPLAN-001 -> TDFIX-001 -> TDVAL-001 |
133
-
134
- ## Phase 4: Spawn-and-Wait
135
-
136
- Delegate to @commands/monitor.md#handleSpawnNext:
137
- 1. Find ready tasks (pending + deps resolved)
138
- 2. Spawn team_worker agents via spawn_agent
139
- 3. Wait for completion via wait_agent
140
- 4. Process results, advance pipeline
141
- 5. Repeat until all waves complete or pipeline blocked
142
-
143
- ## Phase 5: Report + Debt Reduction Metrics + PR
144
-
145
- 1. Read shared memory -> collect all results
146
- 2. PR Creation (worktree mode, validation passed): commit, push, gh pr create, cleanup worktree
147
- 3. Calculate: debt_items_found, items_fixed, reduction_rate
148
- 4. Generate report with mode, debt scores, validation status
149
- 5. Output with [coordinator] prefix
150
- 6. Execute completion action (request_user_input: 新目标 / 深度修复 / 关闭团队)
151
-
152
- ## v4 Coordination Patterns
153
-
154
- ### Message Semantics
155
- - **send_message**: Queue supplementary info to a running agent. Does NOT interrupt current processing. Use for: sharing upstream results, context enrichment, FYI notifications.
156
- - **followup_task**: Assign new work and trigger processing. Use for: waking idle agents, redirecting work, requesting new output, and status probing on timeout (STATUS_CHECK / FINALIZE cascade before closing timed-out agents).
157
-
158
- ### Agent Lifecycle Management
159
- - **list_agents({})**: Returns all running agents. Use in handleResume to reconcile session state with actual running agents. Use in handleComplete to verify clean shutdown.
160
- - **Named targeting**: Workers spawned with `task_name: "<task-id>"` can be addressed by name in send_message, followup_task, and close_agent calls.
161
- - **Close agents promptly**: Call `close_agent` immediately after collecting a worker's result — do NOT leave completed agents running. Idle agents waste resources. At pipeline end, verify all agents closed via `list_agents`.
162
-
163
- ## Error Handling
164
-
165
- | Error | Resolution |
166
- |-------|------------|
167
- | Task timeout | Log, mark failed, ask user to retry or skip |
168
- | Worker crash | Reset task to pending in tasks.json, respawn via spawn_agent |
169
- | Dependency cycle | Detect, report to user, halt |
170
- | Invalid mode | Reject with error, ask to clarify |
171
- | Session corruption | Attempt recovery, fallback to manual reconciliation |
172
- | Scanner finds no debt | Report clean codebase, skip to summary |
173
- | Fix-Verify loop stuck >3 iterations | Accept current state, continue pipeline |