maestro-flow-one 0.2.0 → 0.2.1

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 (96) hide show
  1. package/.ace-tool/index.json +108 -0
  2. package/bin/maestro-flow.js +30 -0
  3. package/claude/maestro-flow/agents/cli-explore-agent.md +187 -0
  4. package/claude/maestro-flow/agents/conceptual-planning-agent.md +245 -0
  5. package/claude/maestro-flow/agents/team-supervisor.md +143 -0
  6. package/claude/maestro-flow/agents/team-worker.md +237 -0
  7. package/claude/maestro-flow/agents/ui-design-agent.md +286 -0
  8. package/claude/maestro-flow/agents/workflow-analyzer.md +115 -0
  9. package/claude/maestro-flow/agents/workflow-codebase-mapper.md +77 -0
  10. package/claude/maestro-flow/agents/workflow-collab-planner.md +143 -0
  11. package/claude/maestro-flow/agents/workflow-debugger.md +103 -0
  12. package/claude/maestro-flow/agents/workflow-executor.md +129 -0
  13. package/claude/maestro-flow/agents/workflow-external-researcher.md +86 -0
  14. package/claude/maestro-flow/agents/workflow-integration-checker.md +83 -0
  15. package/claude/maestro-flow/agents/workflow-nyquist-auditor.md +85 -0
  16. package/claude/maestro-flow/agents/workflow-phase-researcher.md +85 -0
  17. package/claude/maestro-flow/agents/workflow-plan-checker.md +90 -0
  18. package/claude/maestro-flow/agents/workflow-planner.md +195 -0
  19. package/claude/maestro-flow/agents/workflow-project-researcher.md +74 -0
  20. package/claude/maestro-flow/agents/workflow-research-synthesizer.md +70 -0
  21. package/claude/maestro-flow/agents/workflow-reviewer.md +82 -0
  22. package/claude/maestro-flow/agents/workflow-roadmapper.md +81 -0
  23. package/claude/maestro-flow/agents/workflow-verifier.md +120 -0
  24. package/codex/maestro-flow/agents/team-supervisor.toml +40 -0
  25. package/codex/maestro-flow/agents/team-worker.toml +63 -0
  26. package/maestro-flow/agents/cli-explore-agent.md +187 -0
  27. package/maestro-flow/agents/conceptual-planning-agent.md +245 -0
  28. package/maestro-flow/agents/team-supervisor.md +143 -0
  29. package/maestro-flow/agents/team-worker.md +237 -0
  30. package/maestro-flow/agents/ui-design-agent.md +286 -0
  31. package/maestro-flow/agents/workflow-analyzer.md +115 -0
  32. package/maestro-flow/agents/workflow-codebase-mapper.md +77 -0
  33. package/maestro-flow/agents/workflow-collab-planner.md +143 -0
  34. package/maestro-flow/agents/workflow-debugger.md +103 -0
  35. package/maestro-flow/agents/workflow-executor.md +129 -0
  36. package/maestro-flow/agents/workflow-external-researcher.md +86 -0
  37. package/maestro-flow/agents/workflow-integration-checker.md +83 -0
  38. package/maestro-flow/agents/workflow-nyquist-auditor.md +85 -0
  39. package/maestro-flow/agents/workflow-phase-researcher.md +85 -0
  40. package/maestro-flow/agents/workflow-plan-checker.md +90 -0
  41. package/maestro-flow/agents/workflow-planner.md +195 -0
  42. package/maestro-flow/agents/workflow-project-researcher.md +74 -0
  43. package/maestro-flow/agents/workflow-research-synthesizer.md +70 -0
  44. package/maestro-flow/agents/workflow-reviewer.md +82 -0
  45. package/maestro-flow/agents/workflow-roadmapper.md +81 -0
  46. package/maestro-flow/agents/workflow-verifier.md +120 -0
  47. package/maestro-flow/commands/learn/decompose.md +176 -0
  48. package/maestro-flow/commands/learn/follow.md +167 -0
  49. package/maestro-flow/commands/learn/investigate.md +221 -0
  50. package/maestro-flow/commands/learn/retro.md +303 -0
  51. package/maestro-flow/commands/learn/second-opinion.md +167 -0
  52. package/maestro-flow/commands/lifecycle/amend.md +300 -0
  53. package/maestro-flow/commands/lifecycle/analyze.md +130 -0
  54. package/maestro-flow/commands/lifecycle/brainstorm.md +104 -0
  55. package/maestro-flow/commands/lifecycle/composer.md +354 -0
  56. package/maestro-flow/commands/lifecycle/execute.md +120 -0
  57. package/maestro-flow/commands/lifecycle/fork.md +86 -0
  58. package/maestro-flow/commands/lifecycle/init.md +78 -0
  59. package/maestro-flow/commands/lifecycle/learn.md +140 -0
  60. package/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  61. package/maestro-flow/commands/lifecycle/merge.md +61 -0
  62. package/maestro-flow/commands/lifecycle/overlay.md +178 -0
  63. package/maestro-flow/commands/lifecycle/plan.md +154 -0
  64. package/maestro-flow/commands/lifecycle/player.md +404 -0
  65. package/maestro-flow/commands/lifecycle/quick.md +56 -0
  66. package/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  67. package/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  68. package/maestro-flow/commands/lifecycle/update.md +176 -0
  69. package/maestro-flow/commands/lifecycle/verify.md +96 -0
  70. package/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  71. package/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  72. package/maestro-flow/commands/manage/harvest.md +94 -0
  73. package/maestro-flow/commands/manage/issue-discover.md +77 -0
  74. package/maestro-flow/commands/manage/issue.md +73 -0
  75. package/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  76. package/maestro-flow/commands/manage/knowhow.md +77 -0
  77. package/maestro-flow/commands/manage/learn.md +67 -0
  78. package/maestro-flow/commands/manage/status.md +51 -0
  79. package/maestro-flow/commands/manage/wiki.md +62 -0
  80. package/maestro-flow/commands/milestone/audit.md +68 -0
  81. package/maestro-flow/commands/milestone/complete.md +75 -0
  82. package/maestro-flow/commands/milestone/release.md +96 -0
  83. package/maestro-flow/commands/quality/auto-test.md +128 -0
  84. package/maestro-flow/commands/quality/debug.md +125 -0
  85. package/maestro-flow/commands/quality/refactor.md +55 -0
  86. package/maestro-flow/commands/quality/retrospective.md +78 -0
  87. package/maestro-flow/commands/quality/review.md +114 -0
  88. package/maestro-flow/commands/quality/sync.md +51 -0
  89. package/maestro-flow/commands/quality/test.md +107 -0
  90. package/maestro-flow/commands/spec/add.md +49 -0
  91. package/maestro-flow/commands/spec/load.md +51 -0
  92. package/maestro-flow/commands/spec/remove.md +51 -0
  93. package/maestro-flow/commands/spec/setup.md +51 -0
  94. package/maestro-flow/commands/wiki/connect.md +62 -0
  95. package/maestro-flow/commands/wiki/digest.md +69 -0
  96. package/package.json +1 -1
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: maestro-learn
3
+ description: Route learning intent to learn-* commands
4
+ argument-hint: "\"intent text\" [-y] [--dry-run] [--chain <name>]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Route learning requests to the optimal learn command or multi-step chain. Supports direct chain selection via `--chain` or intent-based routing via keyword matching.
16
+
17
+ Executes commands sequentially via Skill() with session tracking.
18
+ </purpose>
19
+
20
+ <context>
21
+ $ARGUMENTS — user learning intent text, or flags.
22
+
23
+ **Flags:**
24
+ - `-y` / `--yes` — Auto mode: skip confirmation
25
+ - `--dry-run` — Show planned chain without executing
26
+ - `--chain <name>` — Force a specific chain (bypass intent detection)
27
+
28
+ **Available learn commands:**
29
+ | Command | Purpose |
30
+ |---------|---------|
31
+ | `learn-follow` | Guided reading with forcing questions, pattern extraction |
32
+ | `learn-investigate` | Hypothesis-driven question investigation |
33
+ | `learn-decompose` | 4-dimension parallel pattern extraction |
34
+ | `learn-second-opinion` | Multi-perspective review/challenge/consult |
35
+ | `learn-retro` | Unified retrospective (git metrics + decision evaluation) |
36
+
37
+ **Available chains:**
38
+ | Chain | Steps | Use when |
39
+ |-------|-------|----------|
40
+ | `follow` | learn-follow | Read/understand code or docs |
41
+ | `investigate` | learn-investigate | Answer a "how/why" question |
42
+ | `decompose` | learn-decompose | Catalog patterns in a module |
43
+ | `second-opinion` | learn-second-opinion | Get review/challenge on code |
44
+ | `retro` | learn-retro --lens all | Full retrospective (git + decisions) |
45
+ | `deep-understand` | follow → decompose → second-opinion | Thorough module analysis |
46
+ | `pattern-catalog` | decompose --save-spec --save-wiki → second-opinion --mode review | Full pattern extraction + review |
47
+
48
+ **Storage:**
49
+ - `.workflow/learning/.maestro-learn/{session_id}/status.json` — Session tracking
50
+ - All learn command outputs go to `.workflow/learning/`
51
+ </context>
52
+
53
+ <execution>
54
+
55
+ ### Step 1: Parse & Route
56
+
57
+ Parse flags (`-y`, `--dry-run`, `--chain`). Extract intent text.
58
+
59
+ **If `--chain` specified:** validate against known chains, jump to Step 2.
60
+
61
+ **Intent routing table** (match first token or keywords):
62
+
63
+ | Keywords | Route |
64
+ |----------|-------|
65
+ | File path (contains `/` or `\`) | `follow` |
66
+ | Wiki ID (`type-slug` pattern) | `follow` |
67
+ | read, follow, walk through, understand, 阅读, 跟读 | `follow` |
68
+ | why, how, what if, investigate, 为什么, 怎么 | `investigate` |
69
+ | pattern, decompose, catalog, 分解, 模式 | `decompose` |
70
+ | opinion, review, challenge, consult, 评审, 挑战 | `second-opinion` |
71
+ | retro, git, commit, decision, 回顾 | `retro` |
72
+ | thorough, deep, 全面, 深入 | `deep-understand` |
73
+
74
+ **If no match:** present menu via AskUserQuestion:
75
+ ```
76
+ What would you like to do?
77
+ 1. Read through code/docs → follow
78
+ 2. Investigate a question → investigate
79
+ 3. Find patterns in code → decompose
80
+ 4. Get a second opinion → second-opinion
81
+ 5. Retrospective → retro
82
+ ```
83
+
84
+ Max 1 clarification round. If still unclear: error.
85
+
86
+ ### Step 2: Resolve Target & Build Args
87
+
88
+ - File path → pass directly
89
+ - Wiki ID → pass directly
90
+ - Topic string → pass as quoted argument
91
+ - Extract any flags (--depth, --days, --lens, --mode, --scope, etc.)
92
+
93
+ **Chain → command mapping:**
94
+ ```
95
+ follow → Skill("learn-follow", "{target} {flags}")
96
+ investigate → Skill("learn-investigate", "\"{target}\" {flags}")
97
+ decompose → Skill("learn-decompose", "{target} {flags}")
98
+ second-opinion → Skill("learn-second-opinion", "{target} {flags}")
99
+ retro → Skill("learn-retro", "{flags}")
100
+ deep-understand → [learn-follow --depth deep, learn-decompose --save-spec, learn-second-opinion --mode challenge]
101
+ pattern-catalog → [learn-decompose --save-spec --save-wiki, learn-second-opinion --mode review]
102
+ ```
103
+
104
+ ### Step 3: Confirm & Execute
105
+
106
+ **If `--dry-run`:** display chain plan and exit.
107
+
108
+ **If not `-y`:** show plan, ask for confirmation.
109
+
110
+ **Execute:**
111
+ 1. Create session dir: `.workflow/learning/.maestro-learn/learn-{timestamp}/`
112
+ 2. Write `status.json` with chain steps
113
+ 3. Execute each step via `Skill()`:
114
+ - On success: mark completed, continue
115
+ - On failure (interactive): ask retry/skip/abort
116
+ - On failure (auto): skip and continue
117
+ 4. Display session summary with artifact list and next-step suggestion
118
+
119
+ </execution>
120
+
121
+ <error_codes>
122
+ | Code | Severity | Description | Recovery |
123
+ |------|----------|-------------|----------|
124
+ | E001 | error | No intent provided | Provide a learning goal or use --chain |
125
+ | E002 | error | Cannot determine intent after clarification | Rephrase or use --chain directly |
126
+ | E003 | error | Chain step failed + user chose abort | Partial progress saved in status.json |
127
+ | E005 | error | Invalid --chain name | Show valid chains |
128
+ | W001 | warning | Intent ambiguous between commands | Present options |
129
+ | W002 | warning | Chain step completed with warnings | Log and continue |
130
+ </error_codes>
131
+
132
+ <success_criteria>
133
+ - [ ] Intent routed to correct chain (or --chain validated)
134
+ - [ ] Target resolved and arguments assembled
135
+ - [ ] Session directory created with status.json
136
+ - [ ] All chain steps executed via Skill()
137
+ - [ ] Error handling: retry/skip/abort per step
138
+ - [ ] Session summary displayed with next-step routing
139
+ - [ ] No files modified outside `.workflow/learning/`
140
+ </success_criteria>
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: maestro-link-coordinate
3
+ description: Execute command chain nodes step by step
4
+ argument-hint: "\"intent text\" [--list] [-c [sessionId]] [--chain <name>] [--tool <tool>] [-y]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ ---
14
+ <purpose>
15
+ Step-mode workflow coordinator using `maestro coordinate` CLI subcommands (start/next/status).
16
+ Walks chain graphs node by node — each command node executed via `maestro delegate` internally.
17
+ Decision/gate/eval nodes auto-resolve between steps. Session persisted for resume.
18
+ </purpose>
19
+
20
+ <required_reading>
21
+ @~/.maestro/workflows/maestro-link-coordinate.md
22
+ </required_reading>
23
+
24
+ <context>
25
+ $ARGUMENTS — user intent text, or flags.
26
+
27
+ **Flags:**
28
+ - `--list` — List all available chain graphs
29
+ - `-c` / `--continue [sessionId]` — Resume step_paused session via `coordinate next`
30
+ - `--chain <name>` — Force a specific chain graph
31
+ - `--tool <tool>` — CLI tool override (default: claude)
32
+ - `-y` / `--yes` — Auto mode
33
+
34
+ **CLI endpoints used:**
35
+ - `maestro coordinate list` — enumerate chains
36
+ - `maestro coordinate start "intent" --chain X` — begin step-mode session
37
+ - `maestro coordinate next [sessionId]` — advance one step
38
+ - `maestro coordinate status [sessionId]` — query state
39
+ - `maestro coordinate run "intent"` — autonomous full run
40
+ - `maestro coordinate watch <sessionId> [--follow]` — read-only event tail (separate from driver loop)
41
+ - `maestro coordinate report` — agent-invoked command-node result writer (authoritative result channel)
42
+
43
+ **Internal walker capabilities (invisible to driver loop):**
44
+ - Prompt assembly owned by the walker (main flow) for both command and decision nodes
45
+ - Decision nodes auto-resolve via `strategy: 'expr'` (fast path) with LLM decider fallback when expr has no match and no default edge, or explicit `strategy: 'llm'`
46
+ - Walker events published to a file/SQLite broker for `watch` observers
47
+ - LLM decision in step mode is synchronous — avoid tight per-step deadlines
48
+ </context>
49
+
50
+ <execution>
51
+ Follow '~/.maestro/workflows/maestro-link-coordinate.md' completely.
52
+ </execution>
53
+
54
+ <error_codes>
55
+ | Code | Severity | Description | Recovery |
56
+ |------|----------|-------------|----------|
57
+ | E001 | error | No intent and no --list/--chain | Suggest --list |
58
+ | E002 | error | Chain graph not found | Show list output |
59
+ | E003 | error | Step execution failed | Check status, retry next |
60
+ | E004 | error | Resume session not found | List sessions |
61
+ | E005 | error | CLI endpoint unavailable | Check maestro installation |
62
+ </error_codes>
63
+
64
+ <success_criteria>
65
+ - [ ] Chain graph loaded via `maestro coordinate start`
66
+ - [ ] Each step executed via `maestro coordinate next` loop
67
+ - [ ] JSON output parsed for session tracking
68
+ - [ ] Decision nodes auto-resolved between steps
69
+ - [ ] Session persisted and resumable via `-c`
70
+ - [ ] Completion summary displayed
71
+ </success_criteria>
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: maestro-merge
3
+ description: Merge milestone worktree branch back to main
4
+ argument-hint: "-m <milestone-number> [--force] [--dry-run] [--no-cleanup] [--continue]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ Merge a completed milestone worktree branch back into the main branch, sync scratch artifacts, and reconcile the artifact registry. Uses a two-phase approach: git merge first (source code), artifact sync second (only after git succeeds). This prevents partial state corruption when merge conflicts occur.
17
+
18
+ Includes registry health check, pre-merge rebase (pull main into worktree to minimize conflicts), and atomic state reconciliation (merge artifact entries, don't overwrite).
19
+ </purpose>
20
+
21
+ <required_reading>
22
+ @~/.maestro/workflows/merge.md
23
+ </required_reading>
24
+
25
+ <context>
26
+ $ARGUMENTS -- milestone number and optional flags.
27
+
28
+ Flags (`-m`, `--force`, `--dry-run`, `--no-cleanup`, `--continue`), merge sequence, artifact sync detail, and conflict handling are defined in workflow `merge.md`.
29
+ </context>
30
+
31
+ <execution>
32
+ Follow '~/.maestro/workflows/merge.md' completely.
33
+
34
+ **Next-step routing on completion:**
35
+ - View dashboard → Skill({ skill: "manage-status" })
36
+ - Audit milestone → Skill({ skill: "maestro-milestone-audit" })
37
+ </execution>
38
+
39
+ <error_codes>
40
+ | Code | Severity | Condition | Recovery |
41
+ |------|----------|-----------|----------|
42
+ | E001 | error | Running inside a worktree | Run from main worktree |
43
+ | E002 | error | No worktree registry found | Nothing to merge |
44
+ | E003 | error | --continue but no merge state | Start fresh merge |
45
+ | E004 | error | No milestone number provided | Provide `-m <N>` |
46
+ | W001 | warning | Stale registry entries found | Auto-cleaned |
47
+ | W002 | warning | Incomplete artifacts (without --force) | Confirm or use --force |
48
+ | W003 | warning | Conflict pulling main into worktree | Resolve in worktree first |
49
+ </error_codes>
50
+
51
+ <success_criteria>
52
+ - [ ] Registry health check passed (stale entries cleaned)
53
+ - [ ] Pre-merge rebase successful (worktree has latest main)
54
+ - [ ] Git merge completed without conflicts (or conflicts resolved via --continue)
55
+ - [ ] All scratch artifacts synced to main `.workflow/scratch/`
56
+ - [ ] `state.json.artifacts[]` reconciled (worktree entries merged into main)
57
+ - [ ] Milestone `"forked"` flag removed in `state.json.milestones[]`
58
+ - [ ] `roadmap.md` completed phases marked
59
+ - [ ] Worktree removed and branch deleted (unless --no-cleanup)
60
+ - [ ] `worktrees.json` registry updated (entry removed)
61
+ </success_criteria>
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: maestro-overlay
3
+ description: Create or edit command overlays from natural language
4
+ argument-hint: "<intent>"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - AskUserQuestion
12
+ ---
13
+ <purpose>
14
+ Turn a user's natural-language instruction into a command overlay — a JSON patch file that augments one or more `.claude/commands/*.md` files non-invasively. Overlays live at `~/.maestro/overlays/` and are auto-applied by every `maestro install` run, so injected steps survive reinstalls. Use this skill when the user says things like "always run CLI verification after `/maestro-execute`", "require reading doc X before `/maestro-plan`", or "add a `ccw cli` quality check at the end of every quality-review".
15
+ </purpose>
16
+
17
+ <required_reading>
18
+ @~/.maestro/workflows/overlays.md
19
+ @~/.maestro/cli-tools.json
20
+ </required_reading>
21
+
22
+ <context>
23
+ **Overlay model** — an overlay is a JSON file with a `name`, one or more `targets` (command names without `.md`), and a list of `patches`. Each patch targets an XML section (`execution`, `required_reading`, `context`, `success_criteria`, etc.), a mode (`append`, `prepend`, `replace`, `new-section`), and `content`. On apply, the patcher wraps the content in hashed HTML-comment markers so re-apply is idempotent and removal is surgical.
24
+
25
+ **Where overlays live**
26
+ - User overlays: `~/.maestro/overlays/*.json` — created by this skill
27
+ - Shared docs: `~/.maestro/overlays/docs/*.md` — referenced via `@~/.maestro/overlays/docs/*.md` inside patch content
28
+ - Shipped examples: `~/.maestro/overlays/_shipped/` — read-only, do not edit
29
+
30
+ **Management** — listing and removing overlays is handled by `maestro overlay list` (ink TUI with interactive delete). This skill focuses solely on creation.
31
+
32
+ **Available sections** (for `section:` in patches): `purpose`, `required_reading`, `deferred_reading`, `context`, `execution`, `error_codes`, `success_criteria`.
33
+ </context>
34
+
35
+ <execution>
36
+ ### 1. Parse user intent
37
+
38
+ Treat the argument as natural-language intent. If unclear, ask up to 2 questions with AskUserQuestion: (a) which command(s) to target, (b) where in the command flow the injection should happen.
39
+
40
+ ### 2. Identify targets, injection points, and visualize
41
+
42
+ For each likely target command, read the pristine source from `$PKG_ROOT/.claude/commands/<name>.md` (preferred — untouched by overlays) or fall back to `~/.claude/commands/<name>.md`. Inspect the XML sections and pick the right one:
43
+
44
+ - **New step after execution** → `section: execution`, `mode: append`
45
+ - **Required reading** → `section: required_reading`, `mode: append`
46
+ - **Preconditions / gating** → `section: context`, `mode: append`
47
+ - **Output quality gate** → `section: success_criteria`, `mode: append`
48
+
49
+ If the user wants a whole new section, use `mode: new-section` with `afterSection: execution` (or whichever anchor makes sense).
50
+
51
+ **Injection point preview** — after selecting section + mode, render the target command's section map showing existing overlays and the new injection point:
52
+
53
+ ```
54
+ === maestro-execute.md (1 overlay exists) ===
55
+
56
+ <purpose>
57
+ <required_reading>
58
+ <context>
59
+ <execution>
60
+ ├─ [existing] cli-verify #1 "CLI Verification step"
61
+ >>> NEW: append here (your overlay)
62
+ <success_criteria>
63
+ ```
64
+
65
+ Use AskUserQuestion to confirm:
66
+ - **"Confirm"** — proceed with this injection point
67
+ - **"Pick different section"** — re-select section/mode
68
+ - **"Cancel"** — abort
69
+
70
+ ### 2.5. Skill chain configuration
71
+
72
+ After confirming the injection point, ask whether this overlay should chain to another skill upon completion. This enables the overlay's injected content to hand off to a skill via AskUserQuestion at runtime — similar to how `/maestro` chains commands via `Skill({ skill: "...", args: "..." })`.
73
+
74
+ Use AskUserQuestion:
75
+ - **"No chain"** — standard overlay, no skill handoff
76
+ - **"Chain to skill"** → ask for the target skill name (e.g., `quality-review`, `maestro-verify`, `quality-test`)
77
+ - **"Chain with alternatives"** → ask for primary skill + 1-2 alternative skills
78
+
79
+ If chain is selected, record the skill name(s) for use in Step 3.
80
+
81
+ ### 3. Draft the overlay JSON
82
+
83
+ Build a slug from the user's intent (kebab-case, lowercase). Write to `~/.maestro/overlays/<slug>.json`:
84
+
85
+ ```json
86
+ {
87
+ "name": "<slug>",
88
+ "description": "<short summary of what and why>",
89
+ "targets": ["maestro-execute"],
90
+ "priority": 50,
91
+ "enabled": true,
92
+ "patches": [
93
+ {
94
+ "section": "execution",
95
+ "mode": "append",
96
+ "content": "## CLI Verification (overlay)\n\nAfter execution, run:\n```\nccw cli -p \"PURPOSE: ...\" --mode analysis --rule analysis-review-code-quality\n```"
97
+ }
98
+ ]
99
+ }
100
+ ```
101
+
102
+ **Content guidelines**
103
+ - Lead the injected block with a heading that includes `(overlay)` so readers see it's machine-injected
104
+ - Keep content concise — overlays should add a step, not rewrite the command
105
+ - `@~/.maestro/...` references are encouraged for pointing at docs
106
+ - Escape `\n` in JSON strings; use a HEREDOC via Bash if content is long
107
+
108
+ **Skill chain content** — if a chain was configured in Step 2.5, append a Skill Handoff block at the end of the patch `content`. The handoff uses AskUserQuestion so the user controls whether to proceed:
109
+
110
+ ```markdown
111
+ ---
112
+
113
+ **Skill Handoff** (overlay)
114
+
115
+ After the above step completes, use AskUserQuestion:
116
+ - "Proceed to /quality-review" — Hand off to quality review
117
+ - "Skip" — Continue with current command flow
118
+ - "Alternative: /maestro-verify" — Run verification instead
119
+
120
+ On user selection:
121
+ - Proceed → Skill({ skill: "quality-review", args: "{phase}" })
122
+ - Alternative → Skill({ skill: "maestro-verify", args: "{phase}" })
123
+ - Skip → continue normally
124
+ ```
125
+
126
+ Handoff rules:
127
+ - Always include a **"Skip"** option — the user can always decline the chain
128
+ - Use `Skill({ skill: "<name>", args: "..." })` syntax consistent with maestro.md chainMap
129
+ - Mark handoff heading with `(overlay)` tag
130
+ - Support runtime variable placeholders: `{phase}`, `{description}`, `{session_id}`
131
+ - Keep handoff block under 10 lines of markdown
132
+
133
+ ### 4. Install via `maestro overlay add`
134
+
135
+ Run:
136
+
137
+ ```bash
138
+ maestro overlay add ~/.maestro/overlays/<slug>.json
139
+ ```
140
+
141
+ This validates the overlay, copies it into place (idempotent), and applies it across all known install scopes. On validation failure, fix the JSON and re-run.
142
+
143
+ ### 5. Report
144
+
145
+ Show the user:
146
+ - Path of the saved overlay JSON
147
+ - Which targets were patched and which were skipped (missing/disabled)
148
+ - Skill chain info (if configured)
149
+ - A reminder that `maestro install` will auto-reapply on every run
150
+ - How to remove: `maestro overlay remove <slug>`
151
+
152
+ **Report format**
153
+
154
+ ```
155
+ === OVERLAY INSTALLED ===
156
+ Name: <slug>
157
+ Path: ~/.maestro/overlays/<slug>.json
158
+ Targets: maestro-execute (applied), maestro-plan (skipped: missing)
159
+ Chain: quality-review (via AskUserQuestion) | none
160
+ Scopes: [global]
161
+
162
+ Re-apply: maestro overlay apply
163
+ Remove: maestro overlay remove <slug>
164
+ Inspect: maestro overlay list
165
+ ```
166
+
167
+ After the report, remind the user they can run `maestro overlay list` for the interactive TUI showing section maps and overlay management.
168
+ </execution>
169
+
170
+ <success_criteria>
171
+ - [ ] Overlay JSON written to `~/.maestro/overlays/<slug>.json` and validates
172
+ - [ ] `maestro overlay add` exited successfully and applied to at least one scope
173
+ - [ ] Target command file(s) contain `<!-- maestro-overlay:<slug>#N hash=... -->` markers
174
+ - [ ] Re-running `maestro overlay apply` produces no file changes (idempotent)
175
+ - [ ] User shown the report with target list and removal instructions
176
+ - [ ] Injection point preview shown (with existing overlays + `>>>` marker) and confirmed before drafting
177
+ - [ ] If chain configured, `content` includes Skill Handoff block with AskUserQuestion + Skip option + `Skill()` calls
178
+ </success_criteria>
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: maestro-plan
3
+ description: Plan phase execution with exploration and verification
4
+ argument-hint: "[phase] [--collab] [--spec SPEC-xxx] [-y] [--gaps] [--dir <path>] [--revise [instructions]] [--check <plan-dir>]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ Create, revise, or verify an execution plan through a 5-stage pipeline: Exploration, Clarification, Planning, Plan Checking, and Confirmation. Produces plan.json with waves, task definitions, and user-confirmed execution strategy.
17
+
18
+ Supports three modes:
19
+ - **Create** (default): Build plan from analysis context or phase requirements
20
+ - **Revise** (`--revise`): Incrementally modify existing plan — edit tasks, adjust waves, add/remove tasks
21
+ - **Check** (`--check`): Standalone plan verification — run plan-checker against existing plan
22
+
23
+ All plan output goes to `.workflow/scratch/{YYYYMMDD}-plan-[P{N}-|M{N}-]{slug}/`. Date-first ordering enables chronological sorting. Scope prefix in directory name (`P{N}` for phase, `M{N}` for milestone, omit for adhoc/standalone) enables fallback identification. Registers PLN artifact in state.json. Performs collision detection against other plans in same milestone.
24
+ </purpose>
25
+
26
+ <required_reading>
27
+ @~/.maestro/workflows/plan.md
28
+ </required_reading>
29
+
30
+ <deferred_reading>
31
+ - [plan.json](~/.maestro/templates/plan.json) — read when generating plan output
32
+ - [task.json](~/.maestro/templates/task.json) — read when generating task files
33
+ - [state.json](~/.maestro/templates/state.json) — read when registering artifact
34
+ </deferred_reading>
35
+
36
+ <context>
37
+ $ARGUMENTS — phase number, or no args for milestone-wide planning, with optional flags.
38
+
39
+ Scope routing, base flags (`--collab`, `--spec`, `-y`, `--gaps`, `--dir`), output directory format, and artifact registration are defined in workflow plan.md.
40
+
41
+ **Command-level flags** (extensions beyond workflow base):
42
+ - `--revise [instructions]` -- See workflow plan.md § Revise Mode
43
+ - `--check <plan-dir>` -- See workflow plan.md § Check Mode
44
+
45
+ **Upstream context:**
46
+ - Reads `context.md` from prior analyze artifact (auto-discovered from state.json or via --dir)
47
+ - Reads `conclusions.json` if available (implementation_scope seeds task generation)
48
+ </context>
49
+
50
+ <execution>
51
+ ### Pre-flight: team conflict check
52
+
53
+ Before starting the plan pipeline, run:
54
+ ```
55
+ Bash("maestro collab preflight --phase <phase-number>")
56
+ ```
57
+ If exit code is 1, present warnings and ask whether to proceed.
58
+
59
+ Follow '~/.maestro/workflows/plan.md' completely.
60
+
61
+ ### Codebase Docs Loading (P1 addition)
62
+
63
+ During P1 Context Collection, after loading context files, load codebase documentation if available:
64
+
65
+ ```
66
+ IF exists(.workflow/codebase/doc-index.json):
67
+ codebase_ctx = Read(.workflow/codebase/ARCHITECTURE.md) + Read(.workflow/codebase/FEATURES.md)
68
+ Pass codebase_ctx to planner agent as structural context
69
+ ELSE:
70
+ display "W004: Codebase docs unavailable, continuing with code exploration only"
71
+ ```
72
+
73
+ ### Wiki Knowledge Search (P1 addition)
74
+
75
+ During P1 Context Collection, after loading context files and before parallel exploration (step 5), search the wiki for prior knowledge related to the phase:
76
+
77
+ ```
78
+ phase_keywords = extract key terms from goal/title (2-5 terms)
79
+ wiki_result = Bash("maestro wiki search ${phase_keywords} --json 2>/dev/null")
80
+
81
+ IF wiki_result exit code != 0 OR empty:
82
+ display "W003: Wiki search unavailable, continuing without prior knowledge"
83
+ ELSE:
84
+ entries = JSON.parse(wiki_result).entries (limit to first 10)
85
+ wiki_context = structured block for downstream stages
86
+ ```
87
+
88
+ ### Issue Linkback (--gaps mode)
89
+
90
+ After plan generation and checking, if `--gaps` mode was used, link TASK files back to issues bidirectionally:
91
+
92
+ ```
93
+ For each created TASK-{NNN}.json that has issue_id:
94
+ Update corresponding issue in .workflow/issues/issues.jsonl:
95
+ task_refs: append TASK-{NNN} to array
96
+ task_plan_dir: relative path to .task/ directory
97
+ status: "planned"
98
+ updated_at: now()
99
+ Append history entry: { action: "planned", at: <ISO>, by: "maestro-plan", summary: "Linked to TASK-{NNN}" }
100
+ ```
101
+
102
+ 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.
103
+
104
+ **Report format on completion:**
105
+
106
+ ```
107
+ === PLAN READY ===
108
+ Phase: {phase_name}
109
+ Tasks: {task_count} tasks in {wave_count} waves
110
+ Check: {checker_status} (iteration {check_count}/{max_checks})
111
+ Collision: {collision_status}
112
+
113
+ Plan: scratch/{YYYYMMDD}-plan-P{N}-{slug}/plan.json
114
+ Tasks: scratch/{YYYYMMDD}-plan-P{N}-{slug}/.task/TASK-*.json
115
+
116
+ Next steps:
117
+ /maestro-execute -- Execute the plan
118
+ /maestro-execute --dir {dir} -- Execute specific plan
119
+ /maestro-plan {phase} -- Re-plan with modifications
120
+ ```
121
+
122
+ ### Mode: Revise / Check
123
+
124
+ Follow workflow plan.md § "Revise Mode" and § "Check Mode" respectively. These modes bypass the standard P1-P5 create pipeline.
125
+ </execution>
126
+
127
+ <error_codes>
128
+ | Code | Severity | Condition | Recovery |
129
+ |------|----------|-----------|----------|
130
+ | E001 | error | No args and no roadmap (cannot determine scope) | Provide phase number or topic, or create roadmap |
131
+ | E003 | error | --gaps requires prior verification/issues to exist | Run maestro-verify first |
132
+ | E004 | error | No plan found to revise (--revise without target) | Use --dir to specify plan, or create plan first |
133
+ | E005 | error | Plan directory not found (--check) | Check path, use --dir |
134
+ | W001 | warning | Exploration agent returned incomplete results | Retry exploration or proceed with available context |
135
+ | W002 | warning | Plan-checker found minor issues, continuing | Review plan-checker feedback, adjust plan if needed |
136
+ | W003 | warning | Wiki search unavailable or returned no results | Continue without prior knowledge context |
137
+ | W004 | warning | Collision detected with existing plan | Review colliding files, confirm or adjust scope |
138
+ </error_codes>
139
+
140
+ <success_criteria>
141
+ - [ ] plan.json written to scratch directory with summary, approach, task_ids, waves (with phase labels)
142
+ - [ ] .task/TASK-*.json files created for each task
143
+ - [ ] Every task has `read_first[]` with at least the file being modified + source of truth files
144
+ - [ ] Every task has `convergence.criteria[]` with grep-verifiable conditions (no subjective language)
145
+ - [ ] Every task `action` and `implementation` contain concrete values (no "align X with Y")
146
+ - [ ] Plan confidence scored in P4 with 5-dimension factor model
147
+ - [ ] Plan readiness gate checked before P4.5 collision detection
148
+ - [ ] Pressure pass completed on highest-complexity task
149
+ - [ ] plan.json includes confidence section (overall, dimensions, pressure_pass)
150
+ - [ ] Collision detection executed against same-milestone plans (non-blocking)
151
+ - [ ] Plan-checker passed (or minor issues acknowledged)
152
+ - [ ] User confirmation captured (execute/modify/cancel) with confidence displayed
153
+ - [ ] Artifact registered in state.json with correct scope/milestone/phase/depends_on
154
+ </success_criteria>