maestro-flow 0.3.22 → 0.3.24

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 (144) hide show
  1. package/.claude/commands/maestro-analyze.md +1 -1
  2. package/.claude/commands/maestro-brainstorm.md +1 -1
  3. package/.claude/commands/maestro-composer.md +3 -3
  4. package/.claude/commands/maestro-init.md +4 -4
  5. package/.claude/commands/maestro-roadmap.md +164 -108
  6. package/.claude/commands/maestro.md +19 -10
  7. package/.claude/commands/quality-business-test.md +2 -2
  8. package/.claude/skills/team-quality-assurance/roles/scout/role.md +1 -1
  9. package/.claude/skills/team-review/roles/reviewer/role.md +1 -1
  10. package/.claude/skills/team-review/roles/scanner/role.md +1 -1
  11. package/.claude/skills/team-tech-debt/roles/scanner/role.md +3 -3
  12. package/.codex/skills/maestro/SKILL.md +12 -9
  13. package/.codex/skills/maestro-brainstorm/SKILL.md +1 -1
  14. package/.codex/skills/maestro-composer/SKILL.md +3 -3
  15. package/.codex/skills/maestro-init/SKILL.md +1 -1
  16. package/.codex/skills/maestro-link-coordinate/SKILL.md +1 -1
  17. package/.codex/skills/maestro-player/SKILL.md +2 -2
  18. package/.codex/skills/maestro-roadmap/SKILL.md +443 -332
  19. package/.codex/skills/quality-business-test/SKILL.md +2 -2
  20. package/.codex/skills/team-coordinate/roles/coordinator/role.md +1 -1
  21. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +1 -1
  22. package/.codex/skills/team-quality-assurance/roles/scout/role.md +1 -1
  23. package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
  24. package/.codex/skills/team-review/roles/scanner/role.md +1 -1
  25. package/.codex/skills/team-tech-debt/roles/scanner/role.md +3 -3
  26. package/chains/singles/spec-generate.json +3 -3
  27. package/chains/spec-driven.json +2 -2
  28. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -0
  29. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  30. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js +2 -2
  31. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js.map +1 -1
  32. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.d.ts +5 -12
  33. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.js +10 -65
  34. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.js.map +1 -1
  35. package/dashboard/dist-server/dashboard/src/server/routes/install.js +17 -11
  36. package/dashboard/dist-server/dashboard/src/server/routes/install.js.map +1 -1
  37. package/dashboard/dist-server/src/agents/cli-agent-runner.d.ts +4 -0
  38. package/dashboard/dist-server/src/agents/cli-agent-runner.js +4 -2
  39. package/dashboard/dist-server/src/agents/cli-agent-runner.js.map +1 -1
  40. package/dashboard/dist-server/src/commands/delegate.d.ts +2 -0
  41. package/dashboard/dist-server/src/commands/delegate.js +20 -4
  42. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  43. package/dashboard/dist-server/src/config/cli-tools-config.d.ts +68 -3
  44. package/dashboard/dist-server/src/config/cli-tools-config.js +248 -9
  45. package/dashboard/dist-server/src/config/cli-tools-config.js.map +1 -1
  46. package/dist/src/agents/cli-agent-runner.d.ts +4 -0
  47. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  48. package/dist/src/agents/cli-agent-runner.js +4 -2
  49. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  50. package/dist/src/cli.js +2 -0
  51. package/dist/src/cli.js.map +1 -1
  52. package/dist/src/commands/cli.d.ts.map +1 -1
  53. package/dist/src/commands/cli.js +21 -4
  54. package/dist/src/commands/cli.js.map +1 -1
  55. package/dist/src/commands/delegate.d.ts +2 -0
  56. package/dist/src/commands/delegate.d.ts.map +1 -1
  57. package/dist/src/commands/delegate.js +20 -4
  58. package/dist/src/commands/delegate.js.map +1 -1
  59. package/dist/src/commands/install-backend.d.ts +5 -16
  60. package/dist/src/commands/install-backend.d.ts.map +1 -1
  61. package/dist/src/commands/install-backend.js +8 -104
  62. package/dist/src/commands/install-backend.js.map +1 -1
  63. package/dist/src/commands/install-ui/ExecutionView.js +1 -1
  64. package/dist/src/commands/install-ui/ExecutionView.js.map +1 -1
  65. package/dist/src/commands/install-ui/InstallExecution.d.ts +1 -0
  66. package/dist/src/commands/install-ui/InstallExecution.d.ts.map +1 -1
  67. package/dist/src/commands/install-ui/InstallExecution.js +19 -4
  68. package/dist/src/commands/install-ui/InstallExecution.js.map +1 -1
  69. package/dist/src/commands/install-ui/InstallResult.d.ts.map +1 -1
  70. package/dist/src/commands/install-ui/InstallResult.js +1 -1
  71. package/dist/src/commands/install-ui/InstallResult.js.map +1 -1
  72. package/dist/src/commands/install.d.ts.map +1 -1
  73. package/dist/src/commands/install.js +28 -3
  74. package/dist/src/commands/install.js.map +1 -1
  75. package/dist/src/commands/tools-ui/CommandReference.d.ts +7 -0
  76. package/dist/src/commands/tools-ui/CommandReference.d.ts.map +1 -0
  77. package/dist/src/commands/tools-ui/CommandReference.js +33 -0
  78. package/dist/src/commands/tools-ui/CommandReference.js.map +1 -0
  79. package/dist/src/commands/tools-ui/ConfigSources.d.ts +6 -0
  80. package/dist/src/commands/tools-ui/ConfigSources.d.ts.map +1 -0
  81. package/dist/src/commands/tools-ui/ConfigSources.js +27 -0
  82. package/dist/src/commands/tools-ui/ConfigSources.js.map +1 -0
  83. package/dist/src/commands/tools-ui/RegisterSettings.d.ts +8 -0
  84. package/dist/src/commands/tools-ui/RegisterSettings.d.ts.map +1 -0
  85. package/dist/src/commands/tools-ui/RegisterSettings.js +125 -0
  86. package/dist/src/commands/tools-ui/RegisterSettings.js.map +1 -0
  87. package/dist/src/commands/tools-ui/RoleMappings.d.ts +9 -0
  88. package/dist/src/commands/tools-ui/RoleMappings.d.ts.map +1 -0
  89. package/dist/src/commands/tools-ui/RoleMappings.js +104 -0
  90. package/dist/src/commands/tools-ui/RoleMappings.js.map +1 -0
  91. package/dist/src/commands/tools-ui/ToolsDashboard.d.ts +8 -0
  92. package/dist/src/commands/tools-ui/ToolsDashboard.d.ts.map +1 -0
  93. package/dist/src/commands/tools-ui/ToolsDashboard.js +60 -0
  94. package/dist/src/commands/tools-ui/ToolsDashboard.js.map +1 -0
  95. package/dist/src/commands/tools-ui/ToolsOverview.d.ts +9 -0
  96. package/dist/src/commands/tools-ui/ToolsOverview.d.ts.map +1 -0
  97. package/dist/src/commands/tools-ui/ToolsOverview.js +84 -0
  98. package/dist/src/commands/tools-ui/ToolsOverview.js.map +1 -0
  99. package/dist/src/commands/tools.d.ts +3 -0
  100. package/dist/src/commands/tools.d.ts.map +1 -0
  101. package/dist/src/commands/tools.js +78 -0
  102. package/dist/src/commands/tools.js.map +1 -0
  103. package/dist/src/config/cli-tools-config.d.ts +68 -3
  104. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  105. package/dist/src/config/cli-tools-config.js +248 -9
  106. package/dist/src/config/cli-tools-config.js.map +1 -1
  107. package/dist/src/core/component-defs.d.ts +16 -0
  108. package/dist/src/core/component-defs.d.ts.map +1 -0
  109. package/dist/src/core/component-defs.js +142 -0
  110. package/dist/src/core/component-defs.js.map +1 -0
  111. package/dist/src/core/manifest.d.ts +8 -1
  112. package/dist/src/core/manifest.d.ts.map +1 -1
  113. package/dist/src/core/manifest.js +29 -40
  114. package/dist/src/core/manifest.js.map +1 -1
  115. package/dist/src/core/tag-injector.d.ts +72 -0
  116. package/dist/src/core/tag-injector.d.ts.map +1 -0
  117. package/dist/src/core/tag-injector.js +228 -0
  118. package/dist/src/core/tag-injector.js.map +1 -0
  119. package/dist/src/index.d.ts +4 -0
  120. package/dist/src/index.d.ts.map +1 -1
  121. package/dist/src/index.js +2 -0
  122. package/dist/src/index.js.map +1 -1
  123. package/dist/tsconfig.tsbuildinfo +1 -0
  124. package/package.json +1 -1
  125. package/templates/cli/prompts/workflow-skill-conflict-patterns.txt +1 -1
  126. package/templates/cli/prompts/workflow-skill-lessons-learned.txt +1 -1
  127. package/templates/search-tools.md +1 -1
  128. package/templates/workflows/specs/node-catalog.md +1 -1
  129. package/workflows/brainstorm.md +1 -1
  130. package/{.claude/CLAUDE.md → workflows/claude-instructions.md} +25 -26
  131. package/workflows/cli-tools-usage.md +16 -2
  132. package/workflows/codex-instructions.md +150 -0
  133. package/workflows/delegate-usage.md +16 -2
  134. package/workflows/execute.md +28 -14
  135. package/workflows/init.md +2 -2
  136. package/workflows/issue-discover.md +2 -2
  137. package/workflows/maestro-super.md +120 -0
  138. package/workflows/maestro.codex.md +4 -4
  139. package/workflows/maestro.md +5 -5
  140. package/workflows/roadmap-common.md +197 -0
  141. package/workflows/roadmap.md +190 -355
  142. package/workflows/spec-generate.md +457 -544
  143. package/.claude/commands/maestro-spec-generate.md +0 -78
  144. package/.codex/skills/maestro-spec-generate/SKILL.md +0 -355
@@ -0,0 +1,120 @@
1
+ # Super Mode (`--super`)
2
+
3
+ Goal: deliver a production-ready, complete software system from user requirements. No user decisions needed — maestro autonomously expands, refines, and implements until the system meets mainstream quality standards.
4
+
5
+ Super mode implies `-y` (all auto flags propagated) plus these additional behaviors:
6
+
7
+ ## 1. Requirement Expansion
8
+
9
+ On receiving user intent, autonomously expand incomplete requirements into a complete product scope. Delegate via role (`maestro delegate --role analyze --mode analysis`) for requirement completeness analysis and gap-filling. Accept requirements that add real user value; discard noise.
10
+
11
+ ## 2. Progressive Document Loading
12
+
13
+ Read execution documents (workflow maestro.md, chain steps) incrementally per-phase rather than loading all upfront. Each milestone loads only the relevant section to preserve context window.
14
+
15
+ ## 3. Autonomous Decision-Making
16
+
17
+ All design/architecture/scope decisions are made via Gemini delegate (`--mode analysis`). No AskUserQuestion calls. Decision criteria: mainstream industry standards, pragmatism, simplicity.
18
+
19
+ ## 4. Auto-Advance Milestones
20
+
21
+ After each milestone completes and passes verification, automatically advance to the next milestone without user confirmation. Run `maestro-milestone-complete` → next milestone chain automatically.
22
+
23
+ ## 5. Quality Gate Scoring
24
+
25
+ Each milestone must pass a readiness score before advancing. Prevents premature exit.
26
+
27
+ | Dimension | Weight | Minimum |
28
+ |-----------|--------|---------|
29
+ | Code completeness (features implemented vs planned) | 25% | 90% |
30
+ | Test coverage (lines + branches) | 20% | 70% |
31
+ | Build & run success (clean build, app starts) | 20% | 100% |
32
+ | Code quality (lint clean, no ts errors) | 15% | 90% |
33
+ | Integration coherence (cross-module contracts) | 10% | 80% |
34
+ | Documentation (API docs, README, setup guide) | 10% | 60% |
35
+ | **Weighted total** | | **≥ 80%** |
36
+
37
+ Score is computed via `maestro-verify` + Gemini analysis. If score < 80%, generate fix plan and re-execute until threshold is met (max 3 retries per milestone, then report blockers).
38
+
39
+ ## 6. Completion Criteria
40
+
41
+ Super mode only terminates when:
42
+ - All roadmap milestones completed and scored ≥ 80%
43
+ - Final system builds, starts, and passes all tests
44
+ - Gemini confirms the system is production-ready via final audit
45
+
46
+ ## 7. State Tracking
47
+
48
+ Super mode extends the standard session `status.json` (`.workflow/.maestro/{session_id}/status.json`). No extra files — all state in one place.
49
+
50
+ ### 7a. status.json 扩展字段
51
+
52
+ ```json
53
+ {
54
+ "session_id": "...",
55
+ "status": "running",
56
+ "super": true,
57
+ "super_state": "expanding|planning|executing|scoring|advancing|completed|blocked",
58
+ "current_milestone": 1,
59
+ "total_milestones": 3,
60
+ "expanded_requirements": "...",
61
+ "milestones": [
62
+ {
63
+ "index": 1,
64
+ "name": "...",
65
+ "status": "pending|executing|scoring|completed|blocked",
66
+ "chain_session_id": null,
67
+ "retries": 0,
68
+ "max_retries": 3,
69
+ "scores": {
70
+ "code_completeness": null,
71
+ "test_coverage": null,
72
+ "build_success": null,
73
+ "code_quality": null,
74
+ "integration_coherence": null,
75
+ "documentation": null,
76
+ "weighted_total": null
77
+ },
78
+ "score_history": [],
79
+ "decisions": []
80
+ }
81
+ ],
82
+ "decision_log": [],
83
+ "steps": [ ... ]
84
+ }
85
+ ```
86
+
87
+ `super_state` values:
88
+ - `expanding` — requirement expansion via Gemini
89
+ - `planning` — roadmap/spec/plan generation
90
+ - `executing` — milestone chain execution (plan → execute → verify)
91
+ - `scoring` — quality gate evaluation
92
+ - `advancing` — milestone-complete + next milestone setup
93
+ - `completed` — all milestones passed
94
+ - `blocked` — max retries exceeded, needs user intervention
95
+
96
+ ### 7b. State transitions
97
+
98
+ ```
99
+ [start] → expanding → planning → executing(M1) → scoring(M1)
100
+ → score ≥ 80% → advancing → executing(M2) → ...
101
+ → score < 80% → retries < 3 → executing(M1) (retry)
102
+ → score < 80% → retries = 3 → blocked
103
+ → all milestones completed → completed
104
+ ```
105
+
106
+ ### 7c. Resume (`-c` or `continue`)
107
+
108
+ On resume, read `status.json`:
109
+ 1. Check `super: true` → enter super mode resume
110
+ 2. Read `super_state` + `current_milestone` → determine resume point
111
+ 3. Read milestone's `status` → resume from exact phase (e.g., interrupted during `scoring` → re-run scoring)
112
+ 4. Load `decision_log` for Gemini continuity
113
+
114
+ ### 7d. State update discipline
115
+
116
+ Update `status.json` at every state transition:
117
+ - Before milestone chain → set milestone `status: "executing"`, increment retries if retry
118
+ - After scoring → write scores to milestone, append to `score_history`
119
+ - After advancing → set previous milestone `status: "completed"`, bump `current_milestone`
120
+ - On block → set milestone `status: "blocked"`, set `super_state: "blocked"`
@@ -138,7 +138,7 @@ const chainMap = {
138
138
  // ── Multi-step chains ────────────────────────────────────────────────────
139
139
  'spec-driven': [
140
140
  { cmd: 'maestro-init' },
141
- { cmd: 'maestro-spec-generate', args: '"{description}"' },
141
+ { cmd: 'maestro-roadmap', args: '--mode full "{description}"' },
142
142
  { cmd: 'maestro-plan', args: '{phase}' },
143
143
  { cmd: 'maestro-execute', args: '{phase}' },
144
144
  { cmd: 'maestro-verify', args: '{phase}' }
@@ -306,9 +306,9 @@ MAESTRO-COORDINATE: {chain_name} (dry run)
306
306
 
307
307
  Create session directory `.workflow/.maestro/maestro-{timestamp}/`.
308
308
 
309
- **Barrier skills** (solo wave, coordinator analyzes artifacts after): `maestro-analyze`, `maestro-plan`, `maestro-brainstorm`, `maestro-spec-generate`, `maestro-execute`.
309
+ **Barrier skills** (solo wave, coordinator analyzes artifacts after): `maestro-analyze`, `maestro-plan`, `maestro-brainstorm`, `maestro-roadmap`, `maestro-execute`.
310
310
 
311
- **Auto-flag injection** (when AUTO_YES): `maestro-analyze/-brainstorm/-ui-design/-spec-generate` → `-y`, `maestro-plan` → `--auto`, `quality-test` → `--auto-fix`, `quality-retrospective` → `--auto-yes`.
311
+ **Auto-flag injection** (when AUTO_YES): `maestro-analyze/-brainstorm/-roadmap/-ui-design` → `-y`, `maestro-plan` → `--auto`, `quality-test` → `--auto-fix`, `quality-retrospective` → `--auto-yes`.
312
312
 
313
313
  Initialize `state.json` with: session_id, intent, chain_name, auto_yes, context (phase, dirs, issue_id, gaps), waves[], and steps[] (each with index, cmd, args, status=pending).
314
314
 
@@ -352,7 +352,7 @@ Context updates per barrier skill:
352
352
  | `maestro-analyze` | `analysis_dir`, gaps (from context.md markers), phase (if detected) |
353
353
  | `maestro-plan` | `plan_dir`, task/wave count (from plan.json) |
354
354
  | `maestro-brainstorm` | `brainstorm_dir` |
355
- | `maestro-spec-generate` | `spec_session_id` (SPEC-* pattern) |
355
+ | `maestro-roadmap` | `spec_session_id` (SPEC-* pattern) |
356
356
  | `maestro-execute` | `exec_completed`/`exec_failed` counts (from results.csv) |
357
357
 
358
358
  **Key principle**: The coordinator owns all context assembly. Sub-agents receive a fully-resolved `skill_call`.
@@ -1,7 +1,7 @@
1
1
  # Workflow: maestro
2
2
 
3
3
  Intelligent coordinator that routes user intent to optimal command chain based on project state.
4
- Dual execution engines: **Skill()** (in-process, synchronous) and **CLI delegate** (via `maestro delegate`, async with gemini quality analysis).
4
+ Dual execution engines: **Skill()** (in-process, synchronous) and **CLI delegate** (via `maestro delegate`, async with role-based tool selection).
5
5
  Default `auto` mode selects engine based on chain complexity.
6
6
 
7
7
  **Prerequisites:**
@@ -222,7 +222,7 @@ resolvePhase — priority order:
222
222
  3. From project state artifacts: in-progress execute → first incomplete phase → latest artifact phase
223
223
  4. null if chain is 'analyze-plan-execute' (uses {scratch_dir} instead)
224
224
  5. null if all chain commands are phase-independent:
225
- manage-status, manage-issue, manage-issue-discover, maestro-init, maestro-spec-generate,
225
+ manage-status, manage-issue, manage-issue-discover, maestro-init,
226
226
  maestro-fork, maestro-merge, maestro-roadmap, spec-setup, manage-knowhow, manage-knowhow-capture,
227
227
  manage-learn, manage-codebase-rebuild, manage-codebase-refresh, maestro-milestone-audit,
228
228
  maestro-milestone-complete
@@ -245,7 +245,7 @@ Engine is selected **per step**, not per chain.
245
245
  ```
246
246
  If execMode is 'cli' or 'skill' → force that engine for all steps.
247
247
  In 'auto' mode, select per step:
248
- CLI steps (heavy, context-isolated): maestro-plan, maestro-execute, maestro-analyze, maestro-brainstorm, maestro-spec-generate, maestro-roadmap, maestro-ui-design, quality-refactor
248
+ CLI steps (heavy, context-isolated): maestro-plan, maestro-execute, maestro-analyze, maestro-brainstorm, maestro-roadmap, maestro-ui-design, quality-refactor
249
249
  Skill steps (everything else): observable, interactive, lightweight (verify, review, test, debug, milestone-*, manage-*, spec-*, quick, etc.)
250
250
  ```
251
251
 
@@ -282,7 +282,7 @@ Context object tracks: current_phase, user_intent, issue_id, spec_session_id, sc
282
282
 
283
283
  assembleArgs: substitute placeholders {phase}, {description}, {issue_id}, {spec_session_id}, {scratch_dir} in step.args.
284
284
  In auto_mode, append per-command flag if not already present:
285
- maestro-analyze/brainstorm/roadmap/ui-design/spec-generate → -y
285
+ maestro-analyze/brainstorm/roadmap/ui-design → -y
286
286
  maestro-plan → --auto
287
287
  quality-test → --auto-fix
288
288
  quality-retrospective → --auto-yes
@@ -425,7 +425,7 @@ const chainMap = {
425
425
 
426
426
  // ── Multi-step chains ──
427
427
  'full-lifecycle': [{ cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }, { cmd: 'quality-review', args: '{phase}' }, { cmd: 'quality-test', args: '{phase}' }, { cmd: 'maestro-milestone-audit' }],
428
- 'spec-driven': [{ cmd: 'maestro-init' }, { cmd: 'maestro-spec-generate', args: '"{description}"' }, { cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }],
428
+ 'spec-driven': [{ cmd: 'maestro-init' }, { cmd: 'maestro-roadmap', args: '--mode full "{description}"' }, { cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }],
429
429
  'roadmap-driven': [{ cmd: 'maestro-init' }, { cmd: 'maestro-roadmap', args: '"{description}"' }, { cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }],
430
430
  'brainstorm-driven': [{ cmd: 'maestro-brainstorm', args: '"{description}"' }, { cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }],
431
431
  'ui-design-driven': [{ cmd: 'maestro-ui-design', args: '{phase}' }, { cmd: 'maestro-plan', args: '{phase}' }, { cmd: 'maestro-execute', args: '{phase}' }, { cmd: 'maestro-verify', args: '{phase}' }],
@@ -0,0 +1,197 @@
1
+ # Workflow: Roadmap Common
2
+
3
+ Shared logic for roadmap generation — used by both light mode (roadmap.md) and full mode (spec-generate.md).
4
+
5
+ ---
6
+
7
+ ## Worktree Guard
8
+
9
+ Block if `.workflow/worktree-scope.json` exists — must run from main worktree.
10
+
11
+ ---
12
+
13
+ ## Load Project Context
14
+
15
+ ### Load Specs
16
+
17
+ ```
18
+ specs_content = maestro spec load --category arch
19
+ ```
20
+
21
+ Ensure phases respect architectural constraints.
22
+
23
+ ### Load Project History (if `.workflow/` exists)
24
+
25
+ Read project artifacts to understand what has already been built:
26
+
27
+ - `project.md` → already_shipped (Validated), current_scope (Active), project_history (Context), locked_decisions (Key Decisions)
28
+ - `state.json.accumulated_context` → deferred[] (candidate reqs), key_decisions[] (constraints), blockers[] (risks)
29
+ - `.workflow/codebase/` → feature inventory from codebase docs
30
+
31
+ **Context assembly** — pass downstream as `project_context`:
32
+ ```json
33
+ {
34
+ "already_shipped": ["REQ-001: User auth", "REQ-002: API layer"],
35
+ "current_scope": ["REQ-003: Payments", "REQ-004: i18n"],
36
+ "deferred_from_previous": ["Internationalization deferred from v1.0"],
37
+ "locked_decisions": ["JWT stateless auth", "PostgreSQL"],
38
+ "learnings": ["JWT has perf issues at scale — consider caching"],
39
+ "project_history": "Milestone v1.0 completed 2026-03-15: auth + API layer shipped"
40
+ }
41
+ ```
42
+
43
+ **Rules**:
44
+ - NEVER re-plan features listed in `already_shipped` — they are done
45
+ - `deferred_from_previous` items are HIGH PRIORITY candidates for new phases
46
+ - `locked_decisions` constrain technology choices in decomposition
47
+ - `learnings` inform risk assessment and phase sizing
48
+
49
+ ---
50
+
51
+ ## Codebase Exploration (conditional)
52
+
53
+ - Detect if project has source files
54
+ - If yes: spawn `cli-explore-agent` for context discovery
55
+ - If `project_context.already_shipped` exists: include as "feature audit" directive — agent should verify which shipped features are present in code and identify integration points for new work
56
+ - Output: relevant files, patterns, tech stack, feature_audit
57
+
58
+ ---
59
+
60
+ ## External Research — API & Technology Details (Optional)
61
+
62
+ Spawn `workflow-external-researcher` agent when requirement mentions specific technologies, APIs, or external services.
63
+
64
+ **Trigger**: Technology keywords detected in requirement or codebase exploration found external dependencies. Auto-trigger in auto mode (`-y`). Skip if requirement is purely organizational/conceptual.
65
+
66
+ Extract named technologies/APIs/frameworks/protocols from requirement + codebase exploration.
67
+
68
+ If topics found → spawn `workflow-external-researcher` agent for API research:
69
+ - Per technology: stable version, core API surface, auth model, integration patterns, limitations, effort signals
70
+ - Focus on details affecting phase decomposition and dependency ordering
71
+ - Output → `apiResearchContext` (in-memory)
72
+
73
+ If no topics or research fails → `apiResearchContext = null`, continue.
74
+
75
+ ---
76
+
77
+ ## Minimum-Phase Principle (MANDATORY)
78
+
79
+ **Core rule: Phase = synchronization barrier.** Each Phase triggers a full plan→execute→verify→transition serial cycle. More phases = slower delivery. The wave DAG inside each Phase already handles task ordering and parallelism, so only create a new Phase when tasks **cannot** start until a previous Phase's entire output exists.
80
+
81
+ **Default: 1 Phase.** Put everything into a single Phase unless a hard dependency forces a split.
82
+
83
+ | Rule | Constraint |
84
+ |------|-----------|
85
+ | **Default** | **1 Phase**. All work in one plan→execute cycle; wave DAG handles internal ordering. |
86
+ | **Maximum** | **2 Phases**. Only when a hard dependency boundary exists that cannot be resolved. |
87
+ | **Exceptional** | **3 Phases**. Must explicitly justify why 2 is insufficient. |
88
+ | **Minimum tasks per phase** | 5 tasks/stories. If a phase would have fewer, merge it into an adjacent phase. |
89
+ | **Merge principle** | Same-module, same-concern, or tightly-coupled work belongs in ONE phase. Infra + core logic + API in one phase is fine. Multiple Epics → one phase is normal. |
90
+ | **Split principle** | Only split when ALL three hard-dependency conditions are met (see below). |
91
+
92
+ **Hard dependency — all three conditions required to justify a Phase split:**
93
+ 1. **Runtime dependency**: Phase B code at runtime MUST call Phase A's real output (cannot mock/stub).
94
+ 2. **Not parallelizable**: A and B cannot develop concurrently via contract/interface/type agreement.
95
+ 3. **Full barrier**: ALL of Phase A's tasks must complete before ANY of Phase B's tasks can start.
96
+
97
+ If only 1-2 conditions are met → keep in the same Phase, use wave dependencies instead.
98
+
99
+ **Phase sizing checklist (applied after decomposition, before presenting to user):**
100
+ 1. Count total phases. If > 2 → justify each split against the 3 hard-dependency conditions, merge if unjustified.
101
+ 2. Count estimated tasks per phase. Any phase < 5 tasks → merge into neighbor.
102
+ 3. Verify each phase has a meaningful deliverable boundary (not just "setup" or "cleanup").
103
+
104
+ **Scope escalation:**
105
+ - **Single project** (any size): 1-2 Phases. Use wave DAG for internal parallelism.
106
+ - **Large scope** (monorepo with 2+ independently deployable services): Use **Milestones** to divide scope. Each Milestone follows the 1-2 Phase limit independently.
107
+
108
+ **Progressive mode**:
109
+ - Progressive layers (MVP → Usable → Refined) map to **Milestones**, not Phases.
110
+ - Each Milestone contains 1-2 Phases following the minimum-phase principle.
111
+ - MVP must be self-contained (no external dependencies)
112
+ - Each feature in exactly ONE milestone (no overlap)
113
+
114
+ **Direct mode**:
115
+ - Topologically-sorted task sequence
116
+ - Each task: title, type, scope, inputs, outputs, convergence, depends_on
117
+ - parallel_group for truly independent tasks
118
+
119
+ **Phase format** (both modes):
120
+ ```markdown
121
+ ### Phase {N}: {Title}
122
+ - **Goal**: <what this phase achieves>
123
+ - **Depends on**: <prerequisite phases or "Nothing">
124
+ - **Requirements**: <REQ-IDs mapped from project.md Active requirements>
125
+ - **Success Criteria** (what must be TRUE):
126
+ 1. <observable behavior from user perspective>
127
+ 2. <observable behavior from user perspective>
128
+ ```
129
+
130
+ Phase numbering: integers (1, 2, 3) for planned work, decimals (2.1, 2.2) for inserted phases.
131
+ Decimal phases count toward the total phase limit.
132
+ Phase directories use `{NN}-{slug}` format (e.g., `01-auth`, `02-api`).
133
+
134
+ **Requirements traceability**: Every Active requirement from project.md MUST appear in exactly one phase's Requirements field. If a requirement maps to no phase, surface it as a gap.
135
+
136
+ ---
137
+
138
+ ## Roadmap Write Logic
139
+
140
+ ### Roadmap Template
141
+
142
+ Write `roadmap.md` to `.workflow/roadmap.md` using `@templates/roadmap.md`:
143
+
144
+ ```markdown
145
+ # Roadmap: {project_name}
146
+
147
+ ## Overview
148
+ <one paragraph describing the journey>
149
+
150
+ ## Phases
151
+ - [ ] **Phase 1: {Title}** - {one-line description}
152
+
153
+ ## Phase Details
154
+
155
+ ### Phase 1: {Title}
156
+ **Goal**: {what this phase delivers}
157
+ **Depends on**: Nothing (first phase)
158
+ **Requirements**: {REQ-IDs}
159
+ **Success Criteria** (what must be TRUE):
160
+ 1. {observable behavior from user perspective}
161
+ 2. {observable behavior from user perspective}
162
+
163
+ ## Scope Decisions
164
+ - **In scope**: <included>
165
+ - **Deferred**: <later milestones>
166
+ - **Out of scope**: <excluded>
167
+
168
+ ## Progress
169
+ | Phase | Status | Completed |
170
+ |-------|--------|-----------|
171
+ | 1. {Title} | Not started | - |
172
+ ```
173
+
174
+ **Requirements traceability**: Cross-check that every Active requirement from project.md maps to exactly one phase. Surface unmapped requirements as gaps.
175
+
176
+ ### Overwrite vs Edit Rules (MANDATORY)
177
+
178
+ Before writing `.workflow/roadmap.md`, check existing state:
179
+
180
+ | Scenario | Action |
181
+ |----------|--------|
182
+ | `roadmap.md` does not exist | Create (write) |
183
+ | `roadmap.md` exists, no completed phases in Progress table | Overwrite (with `-y` auto-confirm, otherwise ask user) |
184
+ | `roadmap.md` exists, has completed phases | **Refuse overwrite** → instruct user to use `--revise` mode |
185
+
186
+ ### state.json Update Rules
187
+
188
+ After writing roadmap.md, update state.json consistently regardless of mode:
189
+
190
+ | Scenario | Action |
191
+ |----------|--------|
192
+ | `state.json` exists | Update `milestones` array and `current_milestone` field from roadmap phases (partial update, not overwrite) |
193
+ | `state.json` does not exist | Do not create (leave to maestro-init) |
194
+
195
+ ### Scratch Directory
196
+
197
+ Ensure scratch directory exists: `mkdir -p .workflow/scratch/`