maestro-flow 0.3.9 → 0.3.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 (125) hide show
  1. package/.claude/commands/maestro-analyze.md +46 -3
  2. package/.claude/commands/maestro-execute.md +14 -0
  3. package/.claude/commands/maestro-plan.md +16 -0
  4. package/.claude/commands/manage-harvest.md +1 -1
  5. package/.claude/commands/manage-issue-discover.md +2 -2
  6. package/.claude/commands/manage-issue.md +3 -3
  7. package/.codex/skills/maestro/SKILL.md +463 -0
  8. package/.codex/skills/maestro-analyze/SKILL.md +28 -7
  9. package/.codex/skills/maestro-chain/SKILL.md +248 -0
  10. package/.codex/skills/maestro-coordinate/SKILL.md +279 -224
  11. package/.codex/skills/maestro-execute/SKILL.md +8 -0
  12. package/.codex/skills/maestro-plan/SKILL.md +9 -1
  13. package/README.md +7 -7
  14. package/README.zh-CN.md +7 -7
  15. package/chains/issue-lifecycle.json +13 -13
  16. package/chains/singles/issue-analyze.json +3 -3
  17. package/chains/singles/issue-execute.json +3 -3
  18. package/chains/singles/issue-plan.json +3 -3
  19. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js +2 -2
  20. package/dashboard/dist-server/dashboard/src/server/commander/commander-agent.js.map +1 -1
  21. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js +3 -3
  22. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js.map +1 -1
  23. package/dashboard/dist-server/dashboard/src/server/routes/issues.js +34 -0
  24. package/dashboard/dist-server/dashboard/src/server/routes/issues.js.map +1 -1
  25. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js +2 -3
  26. package/dashboard/dist-server/dashboard/src/server/ws/handlers/execution-handler.js.map +1 -1
  27. package/dashboard/dist-server/dashboard/src/shared/issue-types.d.ts +5 -0
  28. package/dashboard/dist-server/dashboard/src/shared/issue-types.js.map +1 -1
  29. package/dashboard/dist-server/dashboard/src/shared/normalize-task.d.ts +2 -0
  30. package/dashboard/dist-server/dashboard/src/shared/normalize-task.js +75 -0
  31. package/dashboard/dist-server/dashboard/src/shared/normalize-task.js.map +1 -0
  32. package/dashboard/dist-server/src/hooks/constants.d.ts +90 -12
  33. package/dashboard/dist-server/src/hooks/constants.js +149 -16
  34. package/dashboard/dist-server/src/hooks/constants.js.map +1 -1
  35. package/dashboard/dist-server/src/types/index.d.ts +5 -0
  36. package/dist/src/commands/collab.d.ts +1 -34
  37. package/dist/src/commands/collab.d.ts.map +1 -1
  38. package/dist/src/commands/collab.js +4 -72
  39. package/dist/src/commands/collab.js.map +1 -1
  40. package/dist/src/commands/hooks.d.ts +5 -1
  41. package/dist/src/commands/hooks.d.ts.map +1 -1
  42. package/dist/src/commands/hooks.js +50 -10
  43. package/dist/src/commands/hooks.js.map +1 -1
  44. package/dist/src/commands/install-ui/InstallConfirm.d.ts +3 -1
  45. package/dist/src/commands/install-ui/InstallConfirm.d.ts.map +1 -1
  46. package/dist/src/commands/install-ui/InstallConfirm.js +3 -1
  47. package/dist/src/commands/install-ui/InstallConfirm.js.map +1 -1
  48. package/dist/src/commands/install-ui/InstallExecution.d.ts.map +1 -1
  49. package/dist/src/commands/install-ui/InstallExecution.js +5 -1
  50. package/dist/src/commands/install-ui/InstallExecution.js.map +1 -1
  51. package/dist/src/commands/install-ui/InstallFlow.d.ts.map +1 -1
  52. package/dist/src/commands/install-ui/InstallFlow.js +7 -3
  53. package/dist/src/commands/install-ui/InstallFlow.js.map +1 -1
  54. package/dist/src/commands/install-ui/StatuslineConfig.d.ts +6 -1
  55. package/dist/src/commands/install-ui/StatuslineConfig.d.ts.map +1 -1
  56. package/dist/src/commands/install-ui/StatuslineConfig.js +27 -5
  57. package/dist/src/commands/install-ui/StatuslineConfig.js.map +1 -1
  58. package/dist/src/hooks/__tests__/statusline-visual-test.d.ts +7 -0
  59. package/dist/src/hooks/__tests__/statusline-visual-test.d.ts.map +1 -0
  60. package/dist/src/hooks/__tests__/statusline-visual-test.js +236 -0
  61. package/dist/src/hooks/__tests__/statusline-visual-test.js.map +1 -0
  62. package/dist/src/hooks/constants.d.ts +90 -12
  63. package/dist/src/hooks/constants.d.ts.map +1 -1
  64. package/dist/src/hooks/constants.js +149 -16
  65. package/dist/src/hooks/constants.js.map +1 -1
  66. package/dist/src/hooks/guards/index.d.ts +1 -0
  67. package/dist/src/hooks/guards/index.d.ts.map +1 -1
  68. package/dist/src/hooks/guards/index.js +1 -0
  69. package/dist/src/hooks/guards/index.js.map +1 -1
  70. package/dist/src/hooks/guards/preflight-guard.d.ts +29 -0
  71. package/dist/src/hooks/guards/preflight-guard.d.ts.map +1 -0
  72. package/dist/src/hooks/guards/preflight-guard.js +95 -0
  73. package/dist/src/hooks/guards/preflight-guard.js.map +1 -0
  74. package/dist/src/hooks/index.d.ts +1 -0
  75. package/dist/src/hooks/index.d.ts.map +1 -1
  76. package/dist/src/hooks/index.js +1 -0
  77. package/dist/src/hooks/index.js.map +1 -1
  78. package/dist/src/hooks/preflight-core.d.ts +37 -0
  79. package/dist/src/hooks/preflight-core.d.ts.map +1 -0
  80. package/dist/src/hooks/preflight-core.js +86 -0
  81. package/dist/src/hooks/preflight-core.js.map +1 -0
  82. package/dist/src/hooks/statusline.d.ts +8 -17
  83. package/dist/src/hooks/statusline.d.ts.map +1 -1
  84. package/dist/src/hooks/statusline.js +269 -112
  85. package/dist/src/hooks/statusline.js.map +1 -1
  86. package/dist/src/i18n/locales/en.d.ts.map +1 -1
  87. package/dist/src/i18n/locales/en.js +5 -0
  88. package/dist/src/i18n/locales/en.js.map +1 -1
  89. package/dist/src/i18n/locales/zh.d.ts.map +1 -1
  90. package/dist/src/i18n/locales/zh.js +5 -0
  91. package/dist/src/i18n/locales/zh.js.map +1 -1
  92. package/dist/src/i18n/types.d.ts +5 -0
  93. package/dist/src/i18n/types.d.ts.map +1 -1
  94. package/dist/src/tools/collab-adapter.d.ts +17 -0
  95. package/dist/src/tools/collab-adapter.d.ts.map +1 -1
  96. package/dist/src/tools/collab-adapter.js +138 -0
  97. package/dist/src/tools/collab-adapter.js.map +1 -1
  98. package/dist/src/tools/merge-validator.d.ts +24 -0
  99. package/dist/src/tools/merge-validator.d.ts.map +1 -0
  100. package/dist/src/tools/merge-validator.js +220 -0
  101. package/dist/src/tools/merge-validator.js.map +1 -0
  102. package/dist/src/types/index.d.ts +5 -0
  103. package/dist/src/types/index.d.ts.map +1 -1
  104. package/package.json +1 -1
  105. package/templates/cli/prompts/workflow-skill-conflict-patterns.txt +3 -3
  106. package/templates/cli/prompts/workflow-skill-lessons-learned.txt +3 -3
  107. package/templates/search-tools.md +1 -1
  108. package/workflows/cli-tools-usage.md +44 -27
  109. package/workflows/delegate-usage.md +3 -3
  110. package/workflows/issue-analyze.md +6 -2
  111. package/workflows/issue-discover.md +4 -4
  112. package/workflows/issue-execute.md +6 -3
  113. package/workflows/issue-plan.md +5 -2
  114. package/workflows/maestro-coordinate.codex.md +281 -470
  115. package/workflows/maestro-coordinate.md +14 -14
  116. package/workflows/maestro-link-coordinate.md +2 -2
  117. package/workflows/maestro.codex.md +710 -0
  118. package/workflows/maestro.md +10 -11
  119. package/workflows/retrospective.md +1 -1
  120. package/.claude/commands/manage-issue-analyze.md +0 -62
  121. package/.claude/commands/manage-issue-execute.md +0 -73
  122. package/.claude/commands/manage-issue-plan.md +0 -62
  123. package/.codex/skills/manage-issue-analyze/SKILL.md +0 -207
  124. package/.codex/skills/manage-issue-execute/SKILL.md +0 -200
  125. package/.codex/skills/manage-issue-plan/SKILL.md +0 -186
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: maestro-analyze
3
3
  description: Multi-dimensional analysis with CLI exploration, decision extraction, and intent tracking
4
- argument-hint: "[phase|topic] [-y] [-c] [-q]"
4
+ argument-hint: "[phase|topic] [-y] [-c] [-q] [--gaps [ISS-ID]]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Write
@@ -18,6 +18,8 @@ Perform multi-dimensional analysis of a technical proposal, decision, or archite
18
18
  Combines structured 6-dimension scoring with iterative deepening and decision extraction. Replaces both analysis and decision-capture workflows — produces analysis.md (scoring) AND context.md (Locked/Free/Deferred decisions for plan).
19
19
 
20
20
  Use `-q` for quick decision extraction only (skip exploration + scoring).
21
+
22
+ Use `--gaps` for issue-focused root cause analysis (replaces manage-issue-analyze). Loads issues from issues.jsonl, performs CLI exploration against issue context/location, synthesizes root cause into issue.analysis, and outputs context.md for downstream `plan --gaps`.
21
23
  </purpose>
22
24
 
23
25
  <required_reading>
@@ -26,6 +28,7 @@ Use `-q` for quick decision extraction only (skip exploration + scoring).
26
28
 
27
29
  <deferred_reading>
28
30
  - [state.json](~/.maestro/templates/state.json) — read when registering artifact
31
+ - [issue-gaps-analyze.md](~/.maestro/workflows/issue-gaps-analyze.md) — read when --gaps is triggered
29
32
  </deferred_reading>
30
33
 
31
34
  <context>
@@ -35,6 +38,7 @@ $ARGUMENTS -- phase number for milestone-scoped, topic text for adhoc/standalone
35
38
  - `-y` / `--yes`: Auto mode — skip interactive scoping, use recommended defaults, auto-deepen
36
39
  - `-c` / `--continue`: Resume from existing session (auto-detect session folder + discussion.md)
37
40
  - `-q` / `--quick`: Quick mode — skip exploration + scoring, go straight to decision extraction (context.md only)
41
+ - `--gaps [ISS-ID]`: Issue root cause analysis mode. If ISS-ID provided, analyze single issue. If omitted, analyze all open/registered issues from issues.jsonl.
38
42
 
39
43
  **Scope routing (per architecture):**
40
44
 
@@ -44,8 +48,10 @@ $ARGUMENTS -- phase number for milestone-scoped, topic text for adhoc/standalone
44
48
  | `analyze 1` | init + roadmap | phase | Analyze phase 1 only |
45
49
  | `analyze "topic"` (has milestone) | none | adhoc | Analyze topic, affiliated with current milestone |
46
50
  | `analyze "topic"` (no milestone) | none | standalone | Analyze topic, no milestone affiliation |
51
+ | `analyze --gaps` | issues.jsonl exists | gaps | Load open issues, explore root causes, write analysis records |
52
+ | `analyze --gaps ISS-xxx` | issue exists | gaps | Analyze single issue root cause |
47
53
 
48
- **Scope detection rule**: Text argument + `state.json.current_milestone` non-null → adhoc. Text argument + no milestone → standalone. No args + no roadmap → error (need topic or roadmap).
54
+ **Scope detection rule**: Text argument + `state.json.current_milestone` non-null → adhoc. Text argument + no milestone → standalone. No args + no roadmap → error (need topic or roadmap). `--gaps` → gaps scope (bypasses standard scope routing).
49
55
 
50
56
  **Output directory**: `scratch/analyze-{slug}-{date}/` (relative to `.workflow/`)
51
57
 
@@ -80,7 +86,32 @@ $ARGUMENTS -- phase number for milestone-scoped, topic text for adhoc/standalone
80
86
  <execution>
81
87
  Follow '~/.maestro/workflows/analyze.md' completely.
82
88
 
83
- **Handoff:** context.md is consumed by maestro-plan (loads Locked/Free/Deferred decisions).
89
+ ### --gaps Mode (Issue Root Cause Analysis)
90
+
91
+ When `--gaps` flag is present, follow `~/.maestro/workflows/issue-gaps-analyze.md` instead of the standard analyze pipeline:
92
+
93
+ ```
94
+ Phase 1: Load issues from .workflow/issues/issues.jsonl
95
+ - If ISS-ID provided: load single issue
96
+ - If no ISS-ID: filter issues where status = open | registered
97
+ - Validate: at least 1 issue loaded, else error E_NO_ISSUES
98
+
99
+ Phase 2: CLI exploration per issue
100
+ - For each issue: build exploration prompt from issue.title, description, context, related_files
101
+ - Run maestro delegate --to gemini --mode analysis with codebase context
102
+ - Gather affected files, call chains, root cause evidence
103
+
104
+ Phase 3: Root cause synthesis → write issue.analysis
105
+ - Parse CLI output into analysis record: { root_cause, affected_files, impact_scope, fix_direction, confidence, analyzed_at, tool, depth }
106
+ - Write analysis record to issue in issues.jsonl
107
+ - Append history entry: { action: "analyzed", at: <ISO>, by: "maestro-analyze --gaps" }
108
+
109
+ Phase 4: Output context.md for downstream plan --gaps
110
+ - Aggregate all analyzed issues into context.md with root causes and fix directions
111
+ - Register ANL artifact in state.json
112
+ ```
113
+
114
+ **Handoff:** context.md is consumed by maestro-plan (loads Locked/Free/Deferred decisions). In --gaps mode, context.md contains issue root causes for `plan --gaps` consumption.
84
115
 
85
116
  **Next-step routing on completion:**
86
117
 
@@ -92,6 +123,10 @@ Phase/Milestone scope:
92
123
  Adhoc/Standalone scope:
93
124
  - Ready to plan → `/maestro-plan --dir {scratch_dir}`
94
125
  - Need more exploration → `/maestro-analyze {topic} -c`
126
+
127
+ Gaps scope:
128
+ - Issues analyzed → `/maestro-plan --gaps` (plan fix tasks linked to issues)
129
+ - Need more context → `/maestro-analyze --gaps {ISS-ID}` (re-analyze specific issue)
95
130
  </execution>
96
131
 
97
132
  <error_codes>
@@ -102,6 +137,8 @@ Adhoc/Standalone scope:
102
137
  | W002 | warning | CLI analysis timeout | Retry with shorter prompt, or skip perspective |
103
138
  | W003 | warning | Insufficient evidence for scoring dimensions | Note low-confidence dimensions, proceed with available evidence |
104
139
  | W004 | warning | Max rounds reached (5) | Force synthesis, offer continuation option |
140
+ | E_NO_ISSUES | error | --gaps but no open/registered issues found | Suggest `/manage-issue-discover` or `/manage-issue create` |
141
+ | E_ISSUE_NOT_FOUND | error | --gaps with ISS-ID but issue not found | Suggest `/manage-issue list` to find valid IDs |
105
142
  </error_codes>
106
143
 
107
144
  <success_criteria>
@@ -112,6 +149,12 @@ Full mode:
112
149
  - [ ] conclusions.json created with recommendations and decision trail
113
150
  - [ ] Intent Coverage tracked and verified (no unresolved ❌ items)
114
151
 
152
+ Gaps mode:
153
+ - [ ] Issues loaded from issues.jsonl (all open/registered, or single ISS-ID)
154
+ - [ ] CLI exploration executed per issue with codebase context
155
+ - [ ] Analysis record attached to each issue in issues.jsonl
156
+ - [ ] context.md written with aggregated root causes for plan --gaps
157
+
115
158
  Both modes (full + quick):
116
159
  - [ ] context.md written with all decisions classified as Locked/Free/Deferred
117
160
  - [ ] Gray areas identified through phase-specific analysis
@@ -96,6 +96,20 @@ If exit code is 1, present warnings and ask whether to proceed.
96
96
 
97
97
  Follow '~/.maestro/workflows/execute.md' completely.
98
98
 
99
+ ### Issue Status Sync
100
+
101
+ On each task completion, if `task.issue_id` exists, sync status back to the issue in `.workflow/issues/issues.jsonl`:
102
+
103
+ ```
104
+ For each completed/failed TASK with issue_id:
105
+ Read issue from issues.jsonl by issue_id
106
+ Collect all task_refs[] statuses for that issue:
107
+ all task_refs completed → issue.status = "resolved"
108
+ any task_ref failed → issue.status = "in_progress"
109
+ Append history entry: { action: "executed", at: <ISO>, by: "maestro-execute", summary: "TASK-{NNN} {status}" }
110
+ Write updated issue back to issues.jsonl
111
+ ```
112
+
99
113
  **Report format on completion:**
100
114
 
101
115
  ```
@@ -108,6 +108,22 @@ ELSE:
108
108
  wiki_context = structured block for downstream stages
109
109
  ```
110
110
 
111
+ ### Issue Linkback (--gaps mode)
112
+
113
+ After plan generation and checking, if `--gaps` mode was used, link TASK files back to issues bidirectionally:
114
+
115
+ ```
116
+ For each created TASK-{NNN}.json that has issue_id:
117
+ Update corresponding issue in .workflow/issues/issues.jsonl:
118
+ task_refs: append TASK-{NNN} to array
119
+ task_plan_dir: relative path to .task/ directory
120
+ status: "planned"
121
+ updated_at: now()
122
+ Append history entry: { action: "planned", at: <ISO>, by: "maestro-plan", summary: "Linked to TASK-{NNN}" }
123
+ ```
124
+
125
+ This ensures issue → TASK traceability. The `task_refs[]` and `task_plan_dir` fields on the issue allow the dashboard to resolve and display associated TASK details.
126
+
111
127
  **Report format on completion:**
112
128
 
113
129
  ```
@@ -17,7 +17,7 @@ Extract knowledge fragments from workflow artifacts (analysis results, brainstor
17
17
 
18
18
  Complements `quality-retrospective` (which is phase-scoped) by harvesting from **any** workflow artifact. Prevents knowledge loss from completed analysis and planning sessions that would otherwise only exist as stale files.
19
19
 
20
- **Closed-loop**: harvest extracts → wiki/spec/issue stores → downstream commands consume (wiki-digest, spec-load, manage-issue-plan).
20
+ **Closed-loop**: harvest extracts → wiki/spec/issue stores → downstream commands consume (wiki-digest, spec-load, maestro-plan --gaps).
21
21
  </purpose>
22
22
 
23
23
  <required_reading>
@@ -20,7 +20,7 @@ Automated issue discovery via multi-perspective codebase analysis (8 perspective
20
20
 
21
21
  For CRUD operations (create, list, update, close, link), use `/manage-issue`.
22
22
 
23
- After discovery, use `/manage-issue-analyze <ISS-ID>` to perform root cause analysis on individual findings.
23
+ After discovery, use `/maestro-analyze --gaps <ISS-ID>` to perform root cause analysis on individual findings.
24
24
  </purpose>
25
25
 
26
26
  <required_reading>
@@ -73,5 +73,5 @@ Follow '~/.maestro/workflows/issue-discover.md' completely.
73
73
  - [ ] Findings deduplicated before issue creation
74
74
  - [ ] Issues appended to issues.jsonl with correct schema
75
75
  - [ ] Discovery session fully traceable via session directory
76
- - [ ] Next step routing: `/manage-issue-analyze <ISS-ID>` for root cause analysis, or `/manage-issue list` to review all issues
76
+ - [ ] Next step routing: `/maestro-analyze --gaps <ISS-ID>` for root cause analysis, or `/manage-issue list` to review all issues
77
77
  </success_criteria>
@@ -16,7 +16,7 @@ Issue lifecycle management for the project issue tracker. Supports create, list,
16
16
 
17
17
  For automated issue discovery, use `/manage-issue-discover`.
18
18
 
19
- **Closed-loop workflow**: After creating an issue, use `/manage-issue-analyze` for root cause analysis, `/manage-issue-plan` for solution planning, and `/manage-issue-execute` for execution.
19
+ **Closed-loop workflow**: After creating an issue, use `/maestro-analyze --gaps <ISS-ID>` for root cause analysis, `/maestro-plan --gaps` for solution planning, and `/maestro-execute` for execution.
20
20
  </purpose>
21
21
 
22
22
  <required_reading>
@@ -48,8 +48,8 @@ Parse subcommand from first token of $ARGUMENTS.
48
48
  Follow '~/.maestro/workflows/issue.md' completely.
49
49
 
50
50
  **Next-step routing on completion:**
51
- - create → `/manage-issue-analyze <ISS-ID>` or `/manage-issue-plan <ISS-ID>`
52
- - list → `/manage-issue-analyze <ISS-ID>` for any open issue
51
+ - create → `/maestro-analyze --gaps <ISS-ID>` or `/maestro-plan --gaps`
52
+ - list → `/maestro-analyze --gaps <ISS-ID>` for any open issue
53
53
  - close → `/manage-status`
54
54
  </execution>
55
55
 
@@ -0,0 +1,463 @@
1
+ ---
2
+ name: maestro
3
+ description: Intelligent coordinator — analyze intent, read project state, select chain, execute wave-by-wave via spawn_agents_on_csv. Barrier skills trigger coordinator-side artifact analysis between waves to dynamically assemble subsequent skill_call args. Each wave can be 1 or N parallel tasks.
4
+ argument-hint: "\"intent text\" [-y] [-c|--continue] [--dry-run] [--chain <name>]"
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `-y` or `--yes`: Skip clarification and confirmation prompts. Pass `-y` through to each step's skill invocation.
11
+
12
+ # Maestro
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $maestro "implement user authentication with JWT"
18
+ $maestro -y "refactor the payment module"
19
+ $maestro --continue
20
+ $maestro --dry-run "add rate limiting to API endpoints"
21
+ $maestro --chain feature "add dark mode toggle"
22
+ ```
23
+
24
+ **Flags**:
25
+ - `-y, --yes` — Auto mode: skip all prompts; propagate `-y` to each skill
26
+ - `--continue` — Resume latest paused session from last incomplete wave
27
+ - `--dry-run` — Display planned chain without executing
28
+ - `--chain <name>` — Force a specific chain (skips intent classification)
29
+
30
+ **Session state**: `.workflow/.maestro-coordinate/{session-id}/`
31
+ **Core Output**: `tasks.csv` (master) + `wave-{N}-results.csv` (per wave) + `context.md` (report)
32
+
33
+ ---
34
+
35
+ ## Overview
36
+
37
+ Wave-based pipeline coordinator. The coordinator loop builds one wave CSV at a time, calls `spawn_agents_on_csv`, then performs **coordinator-side artifact analysis** before assembling the next wave. Barrier skills produce artifacts (plan.json, analysis results, etc.) that the coordinator reads to dynamically resolve args for subsequent steps.
38
+
39
+ ```
40
+ Intent → Resolve Chain → [Wave Loop]:
41
+ ┌─────────────────────────────────────────────────┐
42
+ │ 1. Identify next wave (1 or N parallel steps) │
43
+ │ 2. Build wave-{N}.csv with skill_call per row │
44
+ │ 3. spawn_agents_on_csv(wave-{N}.csv) │
45
+ │ 4. Read wave-{N}-results.csv │
46
+ │ 5. If barrier skill: analyze artifacts, │
47
+ │ update context for subsequent steps │
48
+ │ 6. Merge into master tasks.csv │
49
+ └─────────────────────────────────────────────────┘
50
+ → Report
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Barrier Skills
56
+
57
+ Skills that produce artifacts requiring **coordinator-side analysis** before the next wave can be assembled. After a barrier skill completes, the coordinator reads its output and updates the execution context.
58
+
59
+ | Skill | Artifacts to Read | Context Updates |
60
+ |-------|------------------|-----------------|
61
+ | `maestro-analyze` | `.workflow/.csv-wave/*/context.md`, `state.json` | `gaps`, `phase`, `analysis_dir` |
62
+ | `maestro-plan` | `{phase_dir}/plan.json`, `{phase_dir}/.task/TASK-*.json` | `plan_dir`, `task_count`, `wave_count` |
63
+ | `maestro-brainstorm` | `.workflow/.csv-wave/*/.brainstorming/` | `brainstorm_dir`, `features` |
64
+ | `maestro-spec-generate` | `.workflow/.csv-wave/*/specs/` | `spec_session_id` |
65
+ | `maestro-execute` | `.workflow/.csv-wave/*/results.csv` | `exec_status`, `completed_tasks`, `failed_tasks` |
66
+
67
+ **Non-barrier skills** (can be grouped into multi-task waves): `maestro-verify`, `quality-review`, `quality-test`, `quality-debug`, `quality-refactor`, `quality-sync`, `manage-*`
68
+
69
+ ---
70
+
71
+ ## Chain Map
72
+
73
+ | Intent keywords | Chain | Steps (skills, in order) |
74
+ |----------------|-------|--------------------------|
75
+ | fix, bug, error, broken, crash | `quality-fix` | $maestro-analyze --gaps → $maestro-plan --gaps → $maestro-execute → $maestro-verify |
76
+ | test, spec, coverage | `quality-test` | $quality-test |
77
+ | refactor, cleanup, debt | `quality-refactor` | $quality-refactor |
78
+ | feature, implement, add, build | `feature` | $maestro-plan → $maestro-execute → $maestro-verify |
79
+ | review, check, audit | `quality-review` | $quality-review |
80
+ | deploy, release, ship | `deploy` | $maestro-verify → $maestro-execute |
81
+
82
+ ---
83
+
84
+ ## Implementation
85
+
86
+ > **Full implementation reference**: The complete `detectTaskType`, `detectNextAction`, and `chainMap` definitions (35+ intent patterns, 40+ chain types) are in `~/.maestro/workflows/maestro.codex.md`. Read that file for authoritative logic before executing any step.
87
+
88
+ ### Session Initialization
89
+
90
+ ```javascript
91
+ const dateStr = new Date().toISOString().substring(0, 10).replace(/-/g, '')
92
+ const timeStr = new Date().toISOString().substring(11, 19).replace(/:/g, '')
93
+ const sessionId = `MCC-${dateStr}-${timeStr}`
94
+ const sessionDir = `.workflow/.maestro-coordinate/${sessionId}`
95
+
96
+ Bash(`mkdir -p ${sessionDir}`)
97
+ ```
98
+
99
+ ### Phase 1: Resolve Intent and Chain
100
+
101
+ **`--continue` mode**: Glob `.workflow/.maestro-coordinate/MCC-*/state.json` sorted by name desc; load the most recent; resume from first pending wave.
102
+
103
+ **Fresh mode**:
104
+
105
+ 1. Read `.workflow/state.json` for project context (`current_phase`, `workflow_name`)
106
+ 2. If `--chain` is given, use it directly
107
+ 3. Otherwise, classify intent with keyword heuristics (see Chain Map above)
108
+ 4. If no keyword matches and not `AUTO_YES`: ask one clarifying question via `AskUserQuestion`
109
+ 5. Resolve the chain's skill list from Chain Map
110
+ 6. Write `state.json`:
111
+
112
+ ```javascript
113
+ Write(`${sessionDir}/state.json`, JSON.stringify({
114
+ id: sessionId,
115
+ intent,
116
+ chain: resolvedChain,
117
+ auto_yes: AUTO_YES,
118
+ status: "in_progress",
119
+ started_at: new Date().toISOString(),
120
+ context: {
121
+ phase: resolvedPhase,
122
+ plan_dir: null,
123
+ analysis_dir: null,
124
+ brainstorm_dir: null,
125
+ spec_session_id: null,
126
+ gaps: null
127
+ },
128
+ waves: [], // populated as waves execute
129
+ steps: chain.map((skill, i) => ({
130
+ step_n: i + 1,
131
+ skill: skill.cmd,
132
+ args: skill.args ?? '',
133
+ status: "pending",
134
+ wave_n: null
135
+ }))
136
+ }, null, 2))
137
+ ```
138
+
139
+ **`--dry-run`**: Display the chain plan and stop.
140
+
141
+ ```
142
+ Chain: <resolvedChain>
143
+ Steps:
144
+ 1. $<cmd> <args>
145
+ 2. $<cmd> <args> [BARRIER]
146
+ 3. $<cmd> <args>
147
+ ```
148
+
149
+ **User confirmation** (skip if `AUTO_YES`): Display the plan above and prompt `Proceed? (yes/no)`.
150
+
151
+ ---
152
+
153
+ ### Phase 2: Wave Execution Loop
154
+
155
+ The coordinator iterates over pending steps, grouping them into waves and executing one wave at a time.
156
+
157
+ #### Wave Grouping Rules
158
+
159
+ 1. A **barrier skill** is always alone in its wave (wave size = 1)
160
+ 2. Consecutive **non-barrier skills** with no inter-dependencies are grouped into one wave (wave size = N)
161
+ 3. After a barrier wave completes → coordinator analyzes artifacts → updates context → re-assembles subsequent step args
162
+
163
+ #### Per-Wave Execution
164
+
165
+ ```javascript
166
+ let waveNum = 0;
167
+
168
+ while (state.steps.some(s => s.status === 'pending')) {
169
+ waveNum++;
170
+
171
+ // 1. Determine wave contents
172
+ const waveSteps = buildNextWave(state.steps);
173
+
174
+ // 2. Assemble skill_call for each step (with latest context)
175
+ const waveCsv = waveSteps.map((step, i) => ({
176
+ id: String(step.step_n),
177
+ skill_call: buildSkillCall(step, state.context),
178
+ topic: `Chain "${state.chain}" step ${step.step_n}/${state.steps.length}`
179
+ }));
180
+
181
+ // 3. Write wave CSV
182
+ const csvContent = 'id,skill_call,topic\n' + waveCsv.map(r =>
183
+ `"${r.id}","${r.skill_call.replace(/"/g, '""')}","${r.topic}"`
184
+ ).join('\n');
185
+ Write(`${sessionDir}/wave-${waveNum}.csv`, csvContent);
186
+
187
+ // 4. Execute wave
188
+ spawn_agents_on_csv({
189
+ csv_path: `${sessionDir}/wave-${waveNum}.csv`,
190
+ id_column: "id",
191
+ instruction: WAVE_INSTRUCTION,
192
+ max_workers: waveSteps.length > 1 ? waveSteps.length : 1,
193
+ max_runtime_seconds: 1800,
194
+ output_csv_path: `${sessionDir}/wave-${waveNum}-results.csv`,
195
+ output_schema: RESULT_SCHEMA
196
+ });
197
+
198
+ // 5. Read results, update step status
199
+ const results = readCSV(`${sessionDir}/wave-${waveNum}-results.csv`);
200
+ for (const row of results) {
201
+ const step = state.steps.find(s => s.step_n === parseInt(row.id));
202
+ step.status = row.status;
203
+ step.findings = row.findings;
204
+ step.wave_n = waveNum;
205
+ }
206
+
207
+ // 6. Barrier analysis (if wave contained a barrier skill)
208
+ if (isBarrier(waveSteps[0].skill)) {
209
+ analyzeBarrierArtifacts(waveSteps[0], results[0], state.context);
210
+ }
211
+
212
+ // 7. Persist state
213
+ state.waves.push({ wave_n: waveNum, steps: waveSteps.map(s => s.step_n), results });
214
+ Write(`${sessionDir}/state.json`, JSON.stringify(state, null, 2));
215
+
216
+ // 8. Abort on failure
217
+ if (results.some(r => r.status === 'failed')) {
218
+ state.status = 'aborted';
219
+ state.steps.filter(s => s.status === 'pending').forEach(s => s.status = 'skipped');
220
+ Write(`${sessionDir}/state.json`, JSON.stringify(state, null, 2));
221
+ break;
222
+ }
223
+ }
224
+ ```
225
+
226
+ ---
227
+
228
+ ### Instruction Template (Simple)
229
+
230
+ ```
231
+ 你是 CSV job 子 agent。
232
+
233
+ 先原样执行这一段技能调用:
234
+ {skill_call}
235
+
236
+ 然后基于结果完成这一行任务说明:
237
+ {topic}
238
+
239
+ 限制:
240
+ - 不要修改 .workflow/.maestro-coordinate/ 下的 state 文件
241
+ - skill 内部有自己的 session 管理,按 skill SKILL.md 执行即可
242
+
243
+ 最后必须调用 `report_agent_job_result`,返回 JSON:
244
+ {"status":"completed|failed","skill_call":"{skill_call}","summary":"一句话结果","artifacts":"产物路径或空字符串","error":"失败原因或空字符串"}
245
+ ```
246
+
247
+ ### Result Schema
248
+
249
+ ```javascript
250
+ const RESULT_SCHEMA = {
251
+ type: "object",
252
+ properties: {
253
+ status: { type: "string", enum: ["completed", "failed"] },
254
+ skill_call: { type: "string" },
255
+ summary: { type: "string" },
256
+ artifacts: { type: "string" },
257
+ error: { type: "string" }
258
+ },
259
+ required: ["status", "skill_call", "summary", "artifacts", "error"]
260
+ };
261
+ ```
262
+
263
+ ---
264
+
265
+ ### Barrier Analysis Logic
266
+
267
+ After a barrier skill completes, the coordinator reads its artifacts and updates `state.context`:
268
+
269
+ ```javascript
270
+ function analyzeBarrierArtifacts(step, result, ctx) {
271
+ const artifactPath = result.artifacts;
272
+
273
+ switch (step.skill) {
274
+ case 'maestro-analyze':
275
+ // Read analysis conclusions → extract gaps, phase info
276
+ const contextMd = Read(`${artifactPath}/context.md`);
277
+ ctx.analysis_dir = artifactPath;
278
+ ctx.gaps = extractGaps(contextMd); // grep for gap/issue markers
279
+ if (!ctx.phase) ctx.phase = extractPhase(contextMd);
280
+ break;
281
+
282
+ case 'maestro-plan':
283
+ // Read plan.json → know task structure for execute
284
+ const planJson = JSON.parse(Read(`${artifactPath}/plan.json`));
285
+ ctx.plan_dir = artifactPath;
286
+ ctx.task_count = planJson.tasks?.length ?? 0;
287
+ ctx.wave_count = planJson.waves?.length ?? 0;
288
+ break;
289
+
290
+ case 'maestro-brainstorm':
291
+ // Read brainstorm output → features for plan
292
+ ctx.brainstorm_dir = artifactPath;
293
+ break;
294
+
295
+ case 'maestro-spec-generate':
296
+ ctx.spec_session_id = extractSpecId(artifactPath);
297
+ break;
298
+
299
+ case 'maestro-execute':
300
+ // Read execution results → completed/failed counts
301
+ const execResults = Read(`${artifactPath}/results.csv`);
302
+ ctx.exec_completed = countStatus(execResults, 'completed');
303
+ ctx.exec_failed = countStatus(execResults, 'failed');
304
+ break;
305
+ }
306
+ }
307
+ ```
308
+
309
+ ### Skill Call Assembly
310
+
311
+ The coordinator builds each `skill_call` with resolved context — sub-agents just execute verbatim:
312
+
313
+ ```javascript
314
+ const BARRIER_SKILLS = new Set([
315
+ 'maestro-analyze', 'maestro-plan', 'maestro-brainstorm',
316
+ 'maestro-spec-generate', 'maestro-execute'
317
+ ]);
318
+
319
+ const AUTO_FLAG_MAP = {
320
+ 'maestro-analyze': '-y', 'maestro-brainstorm': '-y',
321
+ 'maestro-ui-design': '-y', 'maestro-plan': '--auto',
322
+ 'maestro-spec-generate': '-y', 'quality-test': '--auto-fix',
323
+ 'quality-retrospective': '--auto-yes',
324
+ };
325
+
326
+ function buildSkillCall(step, ctx) {
327
+ let args = (step.args ?? '')
328
+ .replace(/{phase}/g, ctx.phase ?? '')
329
+ .replace(/{description}/g, state.intent ?? '')
330
+ .replace(/{issue_id}/g, ctx.issue_id ?? '')
331
+ .replace(/{plan_dir}/g, ctx.plan_dir ?? '')
332
+ .replace(/{analysis_dir}/g, ctx.analysis_dir ?? '')
333
+ .replace(/{brainstorm_dir}/g, ctx.brainstorm_dir ?? '')
334
+ .replace(/{spec_session_id}/g, ctx.spec_session_id ?? '');
335
+
336
+ if (state.auto_yes) {
337
+ const flag = AUTO_FLAG_MAP[step.skill];
338
+ if (flag && !args.includes(flag)) args = args ? `${args} ${flag}` : flag;
339
+ }
340
+
341
+ return `$${step.skill} ${args}`.trim();
342
+ }
343
+
344
+ function buildNextWave(steps) {
345
+ const pending = steps.filter(s => s.status === 'pending');
346
+ if (!pending.length) return [];
347
+
348
+ const first = pending[0];
349
+ // Barrier skill → solo wave
350
+ if (BARRIER_SKILLS.has(first.skill)) return [first];
351
+
352
+ // Group consecutive non-barriers
353
+ const wave = [first];
354
+ for (let i = 1; i < pending.length; i++) {
355
+ if (BARRIER_SKILLS.has(pending[i].skill)) break;
356
+ wave.push(pending[i]);
357
+ }
358
+ return wave;
359
+ }
360
+ ```
361
+
362
+ ---
363
+
364
+ ### Phase 3: Completion Report
365
+
366
+ ```javascript
367
+ state.status = state.steps.every(s => s.status === 'completed') ? 'completed' : state.status;
368
+ state.completed_at = new Date().toISOString();
369
+ Write(`${sessionDir}/state.json`, JSON.stringify(state, null, 2));
370
+ ```
371
+
372
+ Generate `context.md`:
373
+
374
+ ```markdown
375
+ # Coordinate Report — {chain}
376
+
377
+ ## Summary
378
+ - Session: {sessionId}
379
+ - Chain: {chain}
380
+ - Waves: {waveNum} executed
381
+ - Steps: {completed}/{total} completed
382
+
383
+ ## Wave Results
384
+ ### Wave {N} (barrier: {skill})
385
+ | Step | Skill Call | Status | Summary |
386
+ |------|-----------|--------|---------|
387
+ | {step_n} | {skill_call} | {status} | {summary} |
388
+
389
+ Artifacts: {artifacts}
390
+ Context update: {what changed}
391
+ ```
392
+
393
+ Display:
394
+
395
+ ```
396
+ === COORDINATE COMPLETE ===
397
+ Session: <sessionId>
398
+ Chain: <chain>
399
+ Waves: <N> executed
400
+ Steps: <completed>/<total>
401
+
402
+ WAVE RESULTS:
403
+ [W1] $maestro-analyze --gaps → ✓ found 3 gaps
404
+ [W2] $maestro-plan --gaps → ✓ 12 tasks in 3 waves
405
+ [W3] $maestro-execute → ✓ 12/12 tasks done
406
+ [W4] $maestro-verify → ✓ all criteria met
407
+
408
+ State: .workflow/.maestro-coordinate/<sessionId>/state.json
409
+ Resume: $maestro --continue
410
+ ```
411
+
412
+ ---
413
+
414
+ ## CSV Schema
415
+
416
+ ### wave-{N}.csv (Per-Wave Input)
417
+
418
+ ```csv
419
+ id,skill_call,topic
420
+ "1","$maestro-analyze --gaps \"fix auth\" -y","Chain \"quality-fix\" step 1/4"
421
+ ```
422
+
423
+ | Column | Description |
424
+ |--------|-------------|
425
+ | `id` | Step number from chain (string) |
426
+ | `skill_call` | Full skill invocation assembled by coordinator with resolved context |
427
+ | `topic` | Brief description for the agent |
428
+
429
+ ### tasks.csv (Master State)
430
+
431
+ ```csv
432
+ id,skill,args,wave_n,status,findings,artifacts,error
433
+ ```
434
+
435
+ Accumulated across all waves. Updated after each wave completes.
436
+
437
+ ---
438
+
439
+ ## Error Handling
440
+
441
+ | Code | Severity | Condition | Recovery |
442
+ |------|----------|-----------|----------|
443
+ | E001 | error | Intent unclassifiable after clarification | Default to `feature` chain |
444
+ | E002 | error | `--chain` value not in chain map | List valid chains, abort |
445
+ | E003 | error | Wave timeout (max_runtime_seconds) | Mark step `failed`, abort chain |
446
+ | E004 | error | Barrier artifact not found | Retry wave once, then abort |
447
+ | E005 | error | `--continue`: no session found | List sessions, prompt |
448
+ | W001 | warning | Barrier artifact partial | Continue with available context |
449
+
450
+ ---
451
+
452
+ ## Core Rules
453
+
454
+ 1. **Start Immediately**: Init session dir and write `state.json` before any wave
455
+ 2. **Wave-by-wave**: Never start wave N+1 before wave N results are read and analyzed
456
+ 3. **Barrier = solo wave**: A barrier skill always executes alone; coordinator analyzes its artifacts before proceeding
457
+ 4. **Non-barriers can parallel**: Consecutive non-barrier skills in the same wave execute with `max_workers = N`
458
+ 5. **Coordinator owns context**: Sub-agents never read prior results — coordinator assembles the full `skill_call` with resolved args
459
+ 6. **Simple instruction**: Sub-agent instruction is minimal — just "execute {skill_call}, report result"
460
+ 7. **Abort on failure**: Failed step → mark remaining as skipped → report
461
+ 8. **State.json tracks waves**: Each wave is recorded with step IDs and results for resume
462
+ 9. **Dry-run is read-only**: Display chain with [BARRIER] markers, no execution
463
+ 10. **Resume from wave**: `--continue` finds last completed wave and resumes from next pending step