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,235 +1,462 @@
1
- ---
2
- name: team-coordinate
3
- description: Universal team coordination with dynamic role generation
4
- allowed-tools: spawn_agent(*), wait_agent(*), send_message(*), followup_task(*), close_agent(*), list_agents(*), report_agent_job_result(*), request_user_input(*), Read(*), Write(*), Edit(*), Bash(*), Glob(*), Grep(*), mcp__maestro-tools__team_msg(*)
5
- ---
6
-
7
- <purpose>
8
- Universal team coordination skill: analyze task -> generate role-specs -> dispatch -> execute -> deliver. Only the **coordinator** is built-in. All worker roles are **dynamically generated** as lightweight role-spec files and spawned via the `team-worker` agent.
9
-
10
- ```
11
- +---------------------------------------------------+
12
- | Skill(skill="team-coordinate") |
13
- | args="task description" |
14
- +-------------------+-------------------------------+
15
- |
16
- Orchestration Mode (auto -> coordinator)
17
- |
18
- Coordinator (built-in)
19
- Phase 0-5 orchestration
20
- |
21
- +-------+-------+-------+-------+
22
- v v v v v
23
- [team-worker agents, each loaded with a dynamic role-spec]
24
- (roles generated at runtime from task analysis)
25
-
26
- CLI Tools (callable by any worker):
27
- maestro delegate --mode analysis - analysis and exploration
28
- maestro delegate --mode write - code generation and modification
29
- ```
30
-
31
- </purpose>
32
-
33
- <context>
34
- ### Delegation Lock
35
-
36
- **Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
37
-
38
- Before calling ANY tool, apply this check:
39
-
40
- | Tool Call | Verdict | Reason |
41
- |-----------|---------|--------|
42
- | `spawn_agent`, `wait_agent`, `close_agent`, `send_message`, `followup_task` | ALLOWED | Orchestration |
43
- | `list_agents` | ALLOWED | Agent health check |
44
- | `request_user_input` | ALLOWED | User interaction |
45
- | `mcp__maestro-tools__team_msg` | ALLOWED | Message bus |
46
- | `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
47
- | `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
48
- | `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
49
- | `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
50
- | `Bash("maestro delegate ...")` | BLOCKED | Only workers call CLI |
51
- | `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
52
-
53
- **If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
54
-
55
- **No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent. The overhead is the feature -- it provides session tracking, artifact persistence, and resume capability.
56
-
57
- ### Shared Constants
58
-
59
- | Constant | Value |
60
- |----------|-------|
61
- | Session prefix | `TC` |
62
- | Session path | `.workflow/.team/TC-<slug>-<date>/` |
63
- | Worker agent | `team-worker` |
64
- | Message bus | `mcp__maestro-tools__team_msg(session_id=<session-id>, ...)` |
65
- | CLI analysis | `maestro delegate --mode analysis` |
66
- | CLI write | `maestro delegate --mode write` |
67
- | Max roles | 5 |
68
-
69
- ### Role Router
70
-
71
- This skill is **coordinator-only**. Workers do NOT invoke this skill -- they are spawned as `team-worker` agents directly.
72
-
73
- Parse `$ARGUMENTS`. No `--role` needed -- always routes to coordinator.
74
-
75
- ### Role Registry
76
-
77
- Only coordinator is statically registered. All other roles are dynamic, stored as role-specs in session.
78
-
79
- | Role | File | Type |
80
- |------|------|------|
81
- | coordinator | [roles/coordinator/role.md](roles/coordinator/role.md) | built-in orchestrator |
82
- | (dynamic) | `<session>/role-specs/<role-name>.md` | runtime-generated role-spec |
83
-
84
- ### CLI Tool Usage
85
-
86
- Workers can use CLI tools for analysis and code operations:
87
-
88
- | Tool | Purpose |
89
- |------|---------|
90
- | maestro delegate --mode analysis | Analysis, exploration, pattern discovery |
91
- | maestro delegate --mode write | Code generation, modification, refactoring |
92
-
93
- ### Orchestration Mode
94
-
95
- **Invocation**: `Skill(skill="team-coordinate", args="task description")`
96
-
97
- **Lifecycle**: Phase 1 (task analysis, dependency graph) -> Phase 2 (generate role-specs, init session) -> Phase 3 (create task chain) -> Phase 4 (spawn workers, STOP) -> callback loop -> Phase 5 (report + completion).
98
-
99
- **User Commands** (wake paused coordinator):
100
-
101
- | Command | Action |
102
- |---------|--------|
103
- | `check` / `status` | Output execution status graph, no advancement |
104
- | `resume` / `continue` | Check worker states, advance next step |
105
- | `revise <TASK-ID> [feedback]` | Revise specific task with optional feedback |
106
- | `feedback <text>` | Inject feedback into active pipeline |
107
- | `improve [dimension]` | Auto-improve weakest quality dimension |
108
-
109
- ### Worker Spawn Template
110
-
111
- Spawn via `team-worker` agent with role-spec path. Message includes: role, role_spec path, session folder, session_id, requirement, inner_loop flag, task context (id, title, description, pipeline_phase), and upstream context from prior tasks.
112
-
113
- After spawning: `wait_agent` (30 min timeout). On timeout: STATUS_CHECK via followup_task (3 min) -> FINALIZE with interrupt (3 min) -> mark timed_out, close agent.
114
-
115
- **Inner Loop**: Set `inner_loop: true` for roles with 2+ serial same-prefix tasks. Single-task roles: `inner_loop: false`.
116
-
117
- ### Model Selection Guide
118
-
119
- Map each role's `responsibility_type` (from `team-session.json#roles`) to reasoning effort:
120
-
121
- | responsibility_type | reasoning_effort |
122
- |---------------------|-------------------|
123
- | exploration | medium |
124
- | analysis | high |
125
- | implementation | high |
126
- | synthesis | medium |
127
- | review | high |
128
-
129
- Override via `model`/`reasoning_effort` params in spawn_agent for cost optimization.
130
-
131
- ### v4 Agent Coordination
132
-
133
- **Message Semantics**: `send_message` to queue supplementary info to downstream workers (non-interrupting). `list_agents` for health checks. `followup_task` not used (all workers are one-shot).
134
-
135
- **fork_turns**: Default `"none"`. Use `"all"` only when task requires deep familiarity with full conversation context (decided per-task in Phase 4).
136
-
137
- **Agent Health Check**: On resume/complete, reconcile `team-session.json.active_workers` with `list_agents({})`. Reset orphaned tasks (in_progress but agent gone) to pending.
138
-
139
- **Named Targeting**: Workers spawned with `task_name: "<task-id>"` for `send_message`/`close_agent` by name.
140
-
141
- ### Completion Action
142
-
143
- Present interactive choice via `request_user_input`: **Archive & Clean** (recommended -- mark completed, output summary), **Keep Active** (mark paused, output resume command), **Export Results** (prompt target path, copy artifacts, then archive).
144
-
145
- ### Specs Reference
146
-
147
- | Spec | Purpose |
148
- |------|---------|
149
- | [specs/pipelines.md](specs/pipelines.md) | Dynamic pipeline model, task naming, dependency graph |
150
- | [specs/role-spec-template.md](specs/role-spec-template.md) | Template for dynamic role-spec generation |
151
- | [specs/quality-gates.md](specs/quality-gates.md) | Quality thresholds and scoring dimensions |
152
- | [specs/knowledge-transfer.md](specs/knowledge-transfer.md) | Context transfer protocols between roles |
153
-
154
- ### Session Directory
155
-
156
- ```
157
- .workflow/.team/TC-<slug>-<date>/
158
- +-- team-session.json # Session state + dynamic role registry
159
- +-- task-analysis.json # Phase 1 output: capabilities, dependency graph
160
- +-- role-specs/ # Dynamic role-spec definitions (generated Phase 2)
161
- | +-- <role-1>.md # Lightweight: frontmatter + Phase 2-4 only
162
- | +-- <role-2>.md
163
- +-- artifacts/ # All MD deliverables from workers
164
- | +-- <artifact>.md
165
- +-- .msg/ # Team message bus + state
166
- | +-- messages.jsonl # Message log
167
- | +-- meta.json # Session metadata + cross-role state
168
- +-- wisdom/ # Cross-task knowledge
169
- | +-- learnings.md
170
- | +-- decisions.md
171
- | +-- issues.md
172
- +-- explorations/ # Shared explore cache
173
- | +-- cache-index.json
174
- | +-- explore-<angle>.json
175
- +-- discussions/ # Inline discuss records
176
- | +-- <round>.md
177
- ```
178
-
179
- #### team-session.json Schema
180
-
181
- ```json
182
- {
183
- "session_id": "TC-<slug>-<date>",
184
- "task_description": "<original user input>",
185
- "status": "active | paused | completed",
186
- "team_name": "<team-name>",
187
- "roles": [
188
- {
189
- "name": "<role-name>",
190
- "prefix": "<PREFIX>",
191
- "responsibility_type": "<type>",
192
- "inner_loop": false,
193
- "role_spec": "role-specs/<role-name>.md"
194
- }
195
- ],
196
- "pipeline": {
197
- "dependency_graph": {},
198
- "tasks_total": 0,
199
- "tasks_completed": 0
200
- },
201
- "active_workers": [],
202
- "completed_tasks": [],
203
- "completion_action": "interactive",
204
- "created_at": "<timestamp>"
205
- }
206
- ```
207
-
208
- ### Session Resume
209
-
210
- Scan `TC-*/team-session.json` for active/paused sessions (prompt if multiple). Reconcile state: reset interrupted tasks to pending, rebuild team, spawn needed workers, resume Phase 4 loop.
211
- </context>
212
-
213
- <error_codes>
214
-
215
- | Scenario | Resolution |
216
- |----------|------------|
217
- | Unknown command | Error with available command list |
218
- | Dynamic role-spec not found | Error, coordinator may need to regenerate |
219
- | Command file not found | Fallback to inline execution |
220
- | CLI tool fails | Worker proceeds with direct implementation, logs warning |
221
- | Explore cache corrupt | Clear cache, re-explore |
222
- | Fast-advance spawns wrong task | Coordinator reconciles on next callback |
223
- | capability_gap reported | Coordinator generates new role-spec via handleAdapt |
224
- | Completion action fails | Default to Keep Active, log warning |
225
- </error_codes>
226
-
227
- <success_criteria>
228
- - [ ] Task analysis produces dependency graph and role definitions
229
- - [ ] Role-spec files generated in session directory
230
- - [ ] Workers spawned via team-worker agent with correct role-spec paths
231
- - [ ] Pipeline executes wave-by-wave respecting dependency graph
232
- - [ ] Session state persisted in team-session.json after each wave
233
- - [ ] Completion action presented and handled correctly
234
- - [ ] Session resumable after interruption
235
- </success_criteria>
1
+ ---
2
+ name: team-coordinate
3
+ description: Universal team coordination with dynamic role generation
4
+ argument-hint: "[task description] [-y|--yes] [-c|--concurrency N] [--continue]"
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
+ ---
7
+
8
+ <purpose>
9
+ Wave-based multi-role coordination via `spawn_agents_on_csv`. Dynamic role generation + linear wave execution with per-wave evaluation gates.
10
+
11
+ **Core difference from other team skills**: Roles are NOT predefined — they are dynamically generated from task analysis at runtime. Each role's behavioral instructions are encoded directly into the CSV `description` column, eliminating the need for role-spec files.
12
+
13
+ **Core workflow**: Analyze Task → Generate Dynamic Roles → Build CSV → Wave-by-Wave Execution with Evaluation → Aggregate Results
14
+
15
+ ```
16
+ +-------------------------------------------------------------------+
17
+ | TEAM-COORDINATE CSV WAVE WORKFLOW |
18
+ +-------------------------------------------------------------------+
19
+ | |
20
+ | Phase 1: Task Analysis + CSV Generation |
21
+ | +-- Parse task description (text-level only) |
22
+ | +-- Signal detection → capability inference |
23
+ | +-- Dynamic role generation (max 5 roles) |
24
+ | +-- Wave assignment (4-tier linear topology) |
25
+ | +-- Evaluation criteria per task |
26
+ | +-- Build tasks.csv with role instructions in description |
27
+ | +-- User validates (skip if -y) |
28
+ | |
29
+ | Phase 2: Wave Execution Engine |
30
+ | +-- For each wave N (sequential): |
31
+ | | +-- EVALUATE: check evaluation_criteria vs findings |
32
+ | | +-- Skip wave if all tasks evaluated out |
33
+ | | +-- Build prev_context from upstream findings |
34
+ | | +-- spawn_agents_on_csv(wave-N.csv) |
35
+ | | +-- Merge results → master tasks.csv |
36
+ | | +-- Cascading skip on failure |
37
+ | | +-- Cleanup temp files |
38
+ | +-- discoveries.ndjson shared across all waves |
39
+ | |
40
+ | Phase 3: Results Aggregation |
41
+ | +-- Export results.csv |
42
+ | +-- Generate context.md |
43
+ | +-- Display summary with deliverables |
44
+ | |
45
+ +-------------------------------------------------------------------+
46
+ ```
47
+
48
+ </purpose>
49
+
50
+ <context>
51
+ ```bash
52
+ $team-coordinate "design and implement auth module"
53
+ $team-coordinate -y -c 3 "analyze performance bottlenecks"
54
+ $team-coordinate --continue "20260518-team-auth-system"
55
+ ```
56
+
57
+ **Flags**:
58
+ - `-y, --yes`: Skip all confirmations (auto mode)
59
+ - `-c, --concurrency N`: Max concurrent agents within each wave (default: 5)
60
+ - `--continue`: Resume existing session
61
+
62
+ **Session**: `.workflow/.csv-wave/{YYYYMMDD}-team-{slug}/`
63
+ **Output**: tasks.csv, results.csv, discoveries.ndjson, context.md
64
+
65
+ ### Pre-load specs (optional)
66
+
67
+ 1. `maestro spec load --category arch` — architecture constraints
68
+ 2. `maestro wiki search "<topic>"` — relevant knowhow
69
+ 3. Proceed without if unavailable.
70
+
71
+ ### Specs Reference
72
+
73
+ | Spec | Purpose |
74
+ |------|---------|
75
+ | [specs/role-catalog.md](specs/role-catalog.md) | Signal detection, role definitions, wave tiers, evaluation criteria, quality gates |
76
+ </context>
77
+
78
+ <csv_schema>
79
+
80
+ ### tasks.csv (Master State)
81
+
82
+ ```csv
83
+ id,title,description,role,deps,context_from,wave,evaluation_criteria
84
+ "RESEARCH-001","Explore auth patterns","PURPOSE: Investigate authentication patterns in codebase | Success: Documented patterns with file references\nTASK:\n - Scan src/ for existing auth implementations\n - Identify JWT/session/OAuth patterns\n - Document integration points\nCONTEXT:\n - Key files: src/auth/**, src/middleware/**\nEXPECTED: Research findings with evidence\nCONSTRAINTS: Read-only analysis","researcher","","","1","always"
85
+ "DESIGN-001","Design auth architecture","PURPOSE: Design authentication module architecture | Success: Architecture doc with data model and API design\nTASK:\n - Design token lifecycle\n - Define middleware chain\n - Specify error handling\nCONTEXT:\n - Upstream: RESEARCH-001 findings\nEXPECTED: Architecture document\nCONSTRAINTS: Follow existing patterns","designer","RESEARCH-001","RESEARCH-001","2","if wave_1 findings indicate architecture decisions needed"
86
+ "IMPL-001","Implement auth module","PURPOSE: Implement authentication module | Success: Working auth with tests\nTASK:\n - Create auth middleware\n - Implement JWT utilities\n - Add integration tests\nCONTEXT:\n - Upstream: DESIGN-001 architecture\nEXPECTED: Source files + test coverage\nCONSTRAINTS: Follow design spec","developer","DESIGN-001","DESIGN-001","3","if wave_2 produced design artifacts"
87
+ "TEST-001","Validate auth implementation","PURPOSE: Validate auth module quality | Success: All tests pass, security checks clear\nTASK:\n - Run full test suite\n - Security audit on auth paths\n - Verify error handling\nCONTEXT:\n - Upstream: IMPL-001 files_modified\nEXPECTED: Test report + security findings\nCONSTRAINTS: No code modifications","tester","IMPL-001","IMPL-001","4","if wave_3 produced testable artifacts (files_modified non-empty)"
88
+ ```
89
+
90
+ **Input columns** (present in initial tasks.csv and wave-N.csv):
91
+
92
+ | Column | Description |
93
+ |--------|-------------|
94
+ | `id` | Task ID: `{PREFIX}-{NNN}` (dynamic prefix from role catalog) |
95
+ | `title` | Short task title |
96
+ | `description` | **Full role-specific instructions** — PURPOSE, TASK steps, CONTEXT, EXPECTED, CONSTRAINTS. This replaces role-spec files. |
97
+ | `role` | Dynamic role name (from Phase 1 signal detection) |
98
+ | `deps` | Semicolon-separated dependency task IDs |
99
+ | `context_from` | Semicolon-separated task IDs whose findings needed as context |
100
+ | `wave` | Wave number (1-4) |
101
+ | `evaluation_criteria` | Condition: `always` or conditional expression |
102
+
103
+ **Lifecycle columns** (initialized in tasks.csv Phase 1, updated during execution):
104
+
105
+ | Column | Initial Value | Description |
106
+ |--------|--------------|-------------|
107
+ | `status` | `pending` | Task lifecycle: pending completed/failed/blocked/skipped |
108
+ | `findings` | `""` | Populated from output_schema `result_status` merge |
109
+ | `files_modified` | `""` | Populated from output_schema merge |
110
+ | `error` | `""` | Populated from output_schema merge |
111
+
112
+ **Output columns** (returned exclusively via `output_schema`, NOT in wave CSV):
113
+
114
+ | Column | Description |
115
+ |--------|-------------|
116
+ | `result_status` | completed / failed / blocked (maps to master `status` during merge) |
117
+ | `findings` | Key findings summary (max 500 chars) |
118
+ | `files_modified` | Semicolon-separated file paths |
119
+ | `error` | Error message if failed |
120
+
121
+ **Column separation rule**: Input columns and output_schema MUST NOT share names. Wave CSV contains Input columns + `prev_context` (dynamic, built from upstream findings). Output columns returned via `output_schema` using `result_status` (not `status`). Merge mapping: `result_status` → master `status`.
122
+
123
+ **prev_context format** (added to wave-N.csv only):
124
+ ```
125
+ --- TASK-ID: RESEARCH-001 ---
126
+ {findings from RESEARCH-001}
127
+ --- TASK-ID: DESIGN-001 ---
128
+ {findings from DESIGN-001}
129
+ ```
130
+
131
+ ### Per-Wave CSV (Temporary)
132
+
133
+ Each wave generates `wave-{N}.csv` with Input columns + `prev_context` (populated from upstream task findings).
134
+
135
+ ### Output Artifacts
136
+
137
+ | File | Purpose | Lifecycle |
138
+ |------|---------|-----------|
139
+ | `tasks.csv` | Master state — all tasks with status/findings | Updated after each wave |
140
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
141
+ | `wave-{N}-results.csv` | Per-wave output (uses `result_status`) | Created by spawn_agents_on_csv, deleted after merge |
142
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
143
+ | `discoveries.ndjson` | Shared exploration board | Append-only across waves |
144
+ | `context.md` | Human-readable report | Created in Phase 3 |
145
+
146
+ ### Session Structure
147
+
148
+ ```
149
+ .workflow/.csv-wave/{YYYYMMDD}-team-{slug}/
150
+ +-- tasks.csv
151
+ +-- results.csv
152
+ +-- discoveries.ndjson
153
+ +-- context.md
154
+ +-- wave-{N}.csv (temporary)
155
+ +-- wave-{N}-results.csv (temporary)
156
+ ```
157
+ </csv_schema>
158
+
159
+ <invariants>
160
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
161
+ 2. **Wave Order is Sacred**: Never execute wave N+1 before wave N completes and results merge
162
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all execution state
163
+ 4. **Column Separation Rule**: Input columns and output_schema MUST NOT share names
164
+ 5. **Context Propagation**: prev_context built from master CSV findings, not from memory
165
+ 6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
166
+ 7. **Evaluate Before Execute**: Wave 2+ tasks MUST pass evaluation gate before inclusion
167
+ 8. **Cascading Skip on Failure**: Failed/blocked tasks cascade skip to all dependents
168
+ 9. **Cleanup Temp Files**: Delete `wave-{N}.csv` AND `wave-{N}-results.csv` after merge
169
+ 10. **DO NOT STOP**: Continuous execution until all waves complete or user stops
170
+ 11. **Max 5 Roles**: Dynamic role count capped at 5; merge overlapping if exceeded
171
+ 12. **Dynamic Roles in CSV**: Role instructions encoded in `description` column, not in separate files
172
+ </invariants>
173
+
174
+ <state_machine>
175
+
176
+ <states>
177
+ S_PARSE — Parse arguments, detect mode (new/continue) PERSIST: —
178
+ S_ANALYZE — Signal detection, role generation, task decomp PERSIST: —
179
+ S_CSV_GEN — Generate tasks.csv with dynamic roles PERSIST: tasks.csv
180
+ S_EVAL_W1 — Evaluate Wave 1 (always passes) PERSIST: —
181
+ S_WAVE_1 — Execute Wave 1 (Analysis/Research) PERSIST: findings in master CSV
182
+ S_EVAL_W2 — Evaluate Wave 2 participation PERSIST: skipped tasks if any
183
+ S_WAVE_2 — Execute Wave 2 (Design/Planning) PERSIST: findings in master CSV
184
+ S_EVAL_W3 — Evaluate Wave 3 participation PERSIST: skipped tasks if any
185
+ S_WAVE_3 — Execute Wave 3 (Implementation) PERSIST: findings in master CSV
186
+ S_EVAL_W4 — Evaluate Wave 4 participation PERSIST: skipped tasks if any
187
+ S_WAVE_4 — Execute Wave 4 (Validation/Testing) PERSIST: findings in master CSV
188
+ S_AGGREGATE — Generate report, export results PERSIST: context.md, results.csv
189
+ </states>
190
+
191
+ <transitions>
192
+ S_PARSE → S_ANALYZE WHEN: new session
193
+ S_PARSE → S_EVAL_W{N} WHEN: --continue (resume at first pending wave)
194
+ S_ANALYZE → S_CSV_GEN
195
+ S_CSV_GEN → S_EVAL_W1
196
+
197
+ S_EVAL_W{N} → S_WAVE_{N} WHEN: tasks qualify after evaluation
198
+ S_EVAL_W{N} → S_EVAL_W{N+1} WHEN: all tasks skipped or no tasks in wave
199
+ S_WAVE_{N} → S_EVAL_W{N+1} WHEN: wave complete, N < 4
200
+
201
+ S_EVAL_W4 → S_AGGREGATE WHEN: after Wave 4 eval (regardless of skip)
202
+ S_WAVE_4 → S_AGGREGATE WHEN: Wave 4 complete
203
+ </transitions>
204
+
205
+ <actions>
206
+
207
+ ### Session Initialization (S_PARSE)
208
+
209
+ ```
210
+ Parse from $ARGUMENTS:
211
+ AUTO_YES ← --yes | -y
212
+ continueMode ← --continue
213
+ maxConcurrency ← --concurrency | -c N (default: 5)
214
+ taskDescription ← remaining text after flag removal
215
+
216
+ Derive:
217
+ dateStr ← UTC+8 YYYYMMDD
218
+ slug ← first 3 meaningful words, kebab-case
219
+ sessionId ← "{dateStr}-team-{slug}"
220
+ sessionFolder ← ".workflow/.csv-wave/{sessionId}"
221
+
222
+ mkdir -p {sessionFolder}
223
+ ```
224
+
225
+ ### Session Resume (S_PARSE → S_EVAL_W{N})
226
+
227
+ When `--continue`:
228
+ 1. Scan `.workflow/.csv-wave/*-team-*/tasks.csv` for sessions with pending tasks
229
+ 2. Single match resume. Multiple `request_user_input` for selection.
230
+ 3. Read master tasks.csv find first wave with pending tasks → jump to S_EVAL_W{N}
231
+
232
+ ### Phase 1: Task Analysis + CSV Generation (S_ANALYZE S_CSV_GEN)
233
+
234
+ **TEXT-LEVEL analysis only. No codebase reading.**
235
+
236
+ 1. **Parse task description**
237
+
238
+ 2. **Clarify if ambiguous** (skip if `-y`):
239
+ - Scope? (specific files, module, project-wide)
240
+ - Deliverables? (documents, code, reports)
241
+ - Constraints? (technology, style)
242
+
243
+ 3. **Signal detection** — scan keywords against `specs/role-catalog.md` §1 Signal Detection Table:
244
+ - Match keywords → capabilities → roles
245
+ - No match → single `general` role
246
+
247
+ 4. **Role minimization**:
248
+ - Merge overlapping capabilities (e.g., "research + analysis" → single analyst)
249
+ - Cap at 5 roles
250
+ - Compute complexity score (§9 of role-catalog.md)
251
+
252
+ 5. **Task decomposition** — for each role, create 1-3 tasks:
253
+ - Generate structured `description` with PURPOSE/TASK/CONTEXT/EXPECTED/CONSTRAINTS
254
+ - This description IS the role instruction — no separate role-spec file
255
+ - Infer key files from keywords (§8 of role-catalog.md)
256
+
257
+ 6. **Wave assignment** — map roles to waves via §2 Wave Tier Mapping
258
+
259
+ 7. **Evaluation criteria** — assign per task:
260
+ - Wave 1: `"always"`
261
+ - Wave 2+: conditional from §3 Evaluation Criteria Templates
262
+
263
+ 8. **Dependency + context_from** — tasks in wave N depend on relevant tasks in wave N-1
264
+
265
+ 9. **Write `tasks.csv`** with all rows (Input columns only, no status/findings)
266
+
267
+ 10. **Write empty `discoveries.ndjson`**
268
+
269
+ 11. **User validation** (skip if `-y`):
270
+ - Display: role count, task count per wave, evaluation criteria summary
271
+ - `request_user_input`: Proceed / Revise / Abort
272
+
273
+ ### Phase 2: Wave Execution Engine (S_EVAL_W{N} → S_WAVE_{N})
274
+
275
+ For each wave N in ascending order (1 through 4):
276
+
277
+ #### Step 1: Evaluate (S_EVAL_W{N})
278
+
279
+ For each task in wave N with status=pending:
280
+ 1. **Cascading check first**: if any task in `deps` OR `context_from` is failed/blocked/skipped → skip this task too
281
+ 2. Read `evaluation_criteria` from master tasks.csv
282
+ 3. If `"always"` → include
283
+ 4. If conditional → read accumulated `findings` + `files_modified` from completed tasks in master CSV:
284
+ - Evaluate condition as a natural language check against accumulated context
285
+ - The coordinator interprets conditions semantically (e.g., "if wave_1 findings indicate design needed" → check if Wave 1 findings mention design/architecture keywords)
286
+ - Condition met → include
287
+ - Not met → set `status=skipped`, `error="evaluation: {criteria} not met"`
288
+
289
+ If no tasks qualify → skip to S_EVAL_W{N+1}. If ALL wave 1 tasks fail → abort pipeline, jump to S_AGGREGATE.
290
+
291
+ #### Step 2: Build prev_context
292
+
293
+ For each qualifying task:
294
+ - Read `context_from` task IDs
295
+ - Extract their `findings` from master CSV
296
+ - Concatenate as `prev_context` string
297
+
298
+ #### Step 3: Write wave-{N}.csv
299
+
300
+ Extract qualifying rows from master CSV. Add `prev_context` column.
301
+
302
+ #### Step 4: Execute (S_WAVE_{N})
303
+
304
+ ```javascript
305
+ spawn_agents_on_csv({
306
+ csv_path: `${sessionFolder}/wave-${N}.csv`,
307
+ id_column: "id",
308
+ instruction: /* see Instruction Builder section below */,
309
+ max_concurrency: maxConcurrency,
310
+ max_runtime_seconds: 3600,
311
+ output_csv_path: `${sessionFolder}/wave-${N}-results.csv`,
312
+ output_schema: {
313
+ id, // mandatory: links to master CSV
314
+ result_status, // mandatory: completed | failed | blocked
315
+ findings, // key findings (max 500 chars)
316
+ files_modified, // semicolon-separated paths
317
+ error // error message if not completed
318
+ }
319
+ })
320
+ ```
321
+
322
+ #### Step 5: Merge results
323
+
324
+ 1. Read `wave-{N}-results.csv`
325
+ 2. For each row: map `result_status` → master `status`, copy `findings`, `files_modified`, `error`
326
+ 3. Update master `tasks.csv`
327
+
328
+ #### Step 6: Cascading skip
329
+
330
+ For each failed/blocked task in this wave:
331
+ - Find all downstream tasks (any task with this task in `deps`)
332
+ - Set their `status=skipped`, `error="upstream {id} failed"`
333
+
334
+ #### Step 7: Cleanup
335
+
336
+ Delete `wave-{N}.csv` AND `wave-{N}-results.csv`.
337
+
338
+ #### Step 8: Continue
339
+
340
+ Proceed to S_EVAL_W{N+1} (or S_AGGREGATE if N=4).
341
+
342
+ ### Phase 3: Results Aggregation (S_AGGREGATE)
343
+
344
+ 1. **Export results.csv** — copy master tasks.csv as final results
345
+
346
+ 2. **Generate context.md**:
347
+ ```markdown
348
+ # Team Coordinate Report: {taskDescription}
349
+
350
+ ## Summary
351
+ - Roles: {role list with prefixes}
352
+ - Tasks: {completed}/{total} ({percent}%)
353
+ - Waves executed: {list of non-skipped waves}
354
+
355
+ ## Wave Results
356
+ ### Wave {N}: {stage name}
357
+ | Task | Role | Status | Findings |
358
+ |------|------|--------|----------|
359
+ | {id} | {role} | {status} | {findings} |
360
+
361
+ ## Files Modified
362
+ {aggregated files_modified across all tasks}
363
+
364
+ ## Discovery Board Summary
365
+ {key entries from discoveries.ndjson}
366
+
367
+ ## Next Steps
368
+ {suggestions based on findings}
369
+ ```
370
+
371
+ 3. **Display completion report** with session path and deliverable locations
372
+
373
+ ### Instruction Builder
374
+
375
+ The `instruction` parameter for `spawn_agents_on_csv` — shared behavioral contract:
376
+
377
+ ```
378
+ You are a team-coordinate agent. Your role is specified in your CSV row's 'role' column.
379
+
380
+ ## Your Task
381
+ Read your CSV row's 'description' column for full task instructions (PURPOSE, TASK, CONTEXT, EXPECTED, CONSTRAINTS).
382
+
383
+ ## Context
384
+ - Session: {sessionFolder}
385
+ - Discovery board: {sessionFolder}/discoveries.ndjson (read before work, append findings)
386
+ - Previous wave context: read your CSV row's 'prev_context' column
387
+
388
+ ## Role Behavior
389
+ Adopt the perspective and expertise matching your role:
390
+ - researcher: systematic investigation, evidence-based findings, hypothesis testing
391
+ - developer: implementation, code modification, testing, convergence verification
392
+ - analyst: multi-dimensional evaluation, scoring, gap identification
393
+ - designer: architecture, data models, interface design, component structure
394
+ - tester: validation, test creation, regression checking, security scanning
395
+ - planner: decomposition, sequencing, risk assessment, prioritization
396
+ - writer: documentation, content creation, clarity, consistency
397
+ - general: adapt to task requirements
398
+
399
+ ## Quality Contract
400
+ 1. Files claimed as created → verify they exist (Read)
401
+ 2. Files claimed as modified → verify content changed (Read)
402
+ 3. Verification fails → retry execution (max 2 retries)
403
+ 4. Still fails → report result_status=blocked with error details
404
+ 5. NEVER report completed without verification
405
+
406
+ ## Discovery Board Protocol
407
+ Read {sessionFolder}/discoveries.ndjson before starting work.
408
+ Append findings as NDJSON lines:
409
+ {"ts":"<ISO>","worker":"<TASK-ID>","type":"<TYPE>","data":{...}}
410
+ Types: code_pattern, integration_point, convention, blocker, key_finding, decision
411
+
412
+ ## Output
413
+ Return via output_schema:
414
+ - result_status: completed | failed | blocked
415
+ - findings: key findings summary (max 500 chars, be specific and actionable)
416
+ - files_modified: semicolon-separated paths of created/modified files
417
+ - error: error message if result_status is not completed
418
+ ```
419
+
420
+ </actions>
421
+ </state_machine>
422
+
423
+ <discovery_board>
424
+
425
+ | Type | Dedup Key | Data |
426
+ |------|-----------|------|
427
+ | code_pattern | pattern_name | {name, location, description, usage} |
428
+ | integration_point | endpoint | {endpoint, consumers[], producers[], protocol} |
429
+ | convention | name | {name, description, examples[], scope} |
430
+ | blocker | issue | {issue, severity, affected_tasks[], workaround} |
431
+ | key_finding | topic | {topic, evidence, implications, confidence} |
432
+ | decision | subject | {subject, choice, rationale, alternatives[]} |
433
+
434
+ Protocol: read before work, append-only, dedup by type+key.
435
+ </discovery_board>
436
+
437
+ <error_codes>
438
+
439
+ | Condition | Recovery |
440
+ |-----------|----------|
441
+ | No capabilities detected | Default to single `general` role in wave 1 |
442
+ | All wave 1 tasks failed | Abort pipeline (downstream has no context) |
443
+ | All tasks in wave N failed | Skip subsequent waves, proceed to aggregation |
444
+ | Evaluation skipped all tasks in wave | Normal — skip wave, continue to next |
445
+ | Task timeout | Mark failed, cascade skip dependents |
446
+ | Session not found (--continue) | Error with available session list |
447
+ | tasks.csv corrupted | Error, suggest manual recovery or new session |
448
+ | Role count exceeds 5 | Auto-merge overlapping roles |
449
+ </error_codes>
450
+
451
+ <success_criteria>
452
+ - [ ] Dynamic roles generated from task description keywords
453
+ - [ ] tasks.csv created with role instructions in description column
454
+ - [ ] Wave 1 executed with at least 1 task
455
+ - [ ] Wave 2-4 evaluation gates applied (tasks included, skipped, or wave skipped)
456
+ - [ ] prev_context built from upstream findings for each wave
457
+ - [ ] Column separation rule maintained (no shared names between input and output)
458
+ - [ ] wave-N.csv and wave-N-results.csv deleted after merge
459
+ - [ ] discoveries.ndjson append-only throughout
460
+ - [ ] results.csv and context.md generated in Phase 3
461
+ - [ ] Session resumable via --continue
462
+ </success_criteria>