maestro-flow-one 0.1.0

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/maestro-flow.js +730 -0
  4. package/claude/maestro-flow/SKILL.md +239 -0
  5. package/claude/maestro-flow/chains/templates.json +256 -0
  6. package/claude/maestro-flow/commands/learn/decompose.md +176 -0
  7. package/claude/maestro-flow/commands/learn/follow.md +167 -0
  8. package/claude/maestro-flow/commands/learn/investigate.md +221 -0
  9. package/claude/maestro-flow/commands/learn/retro.md +303 -0
  10. package/claude/maestro-flow/commands/learn/second-opinion.md +167 -0
  11. package/claude/maestro-flow/commands/lifecycle/amend.md +300 -0
  12. package/claude/maestro-flow/commands/lifecycle/analyze.md +126 -0
  13. package/claude/maestro-flow/commands/lifecycle/brainstorm.md +100 -0
  14. package/claude/maestro-flow/commands/lifecycle/composer.md +354 -0
  15. package/claude/maestro-flow/commands/lifecycle/execute.md +114 -0
  16. package/claude/maestro-flow/commands/lifecycle/fork.md +86 -0
  17. package/claude/maestro-flow/commands/lifecycle/init.md +78 -0
  18. package/claude/maestro-flow/commands/lifecycle/learn.md +140 -0
  19. package/claude/maestro-flow/commands/lifecycle/link-coordinate.md +71 -0
  20. package/claude/maestro-flow/commands/lifecycle/merge.md +61 -0
  21. package/claude/maestro-flow/commands/lifecycle/overlay.md +178 -0
  22. package/claude/maestro-flow/commands/lifecycle/plan.md +138 -0
  23. package/claude/maestro-flow/commands/lifecycle/player.md +404 -0
  24. package/claude/maestro-flow/commands/lifecycle/quick.md +56 -0
  25. package/claude/maestro-flow/commands/lifecycle/roadmap.md +164 -0
  26. package/claude/maestro-flow/commands/lifecycle/ui-design.md +93 -0
  27. package/claude/maestro-flow/commands/lifecycle/update.md +176 -0
  28. package/claude/maestro-flow/commands/lifecycle/verify.md +90 -0
  29. package/claude/maestro-flow/commands/manage/codebase-rebuild.md +75 -0
  30. package/claude/maestro-flow/commands/manage/codebase-refresh.md +57 -0
  31. package/claude/maestro-flow/commands/manage/harvest.md +94 -0
  32. package/claude/maestro-flow/commands/manage/issue-discover.md +77 -0
  33. package/claude/maestro-flow/commands/manage/issue.md +73 -0
  34. package/claude/maestro-flow/commands/manage/knowhow-capture.md +193 -0
  35. package/claude/maestro-flow/commands/manage/knowhow.md +77 -0
  36. package/claude/maestro-flow/commands/manage/learn.md +67 -0
  37. package/claude/maestro-flow/commands/manage/status.md +51 -0
  38. package/claude/maestro-flow/commands/manage/wiki.md +62 -0
  39. package/claude/maestro-flow/commands/milestone/audit.md +68 -0
  40. package/claude/maestro-flow/commands/milestone/complete.md +75 -0
  41. package/claude/maestro-flow/commands/milestone/release.md +96 -0
  42. package/claude/maestro-flow/commands/quality/auto-test.md +124 -0
  43. package/claude/maestro-flow/commands/quality/debug.md +115 -0
  44. package/claude/maestro-flow/commands/quality/refactor.md +55 -0
  45. package/claude/maestro-flow/commands/quality/retrospective.md +78 -0
  46. package/claude/maestro-flow/commands/quality/review.md +108 -0
  47. package/claude/maestro-flow/commands/quality/sync.md +51 -0
  48. package/claude/maestro-flow/commands/quality/test.md +103 -0
  49. package/claude/maestro-flow/commands/spec/add.md +49 -0
  50. package/claude/maestro-flow/commands/spec/load.md +51 -0
  51. package/claude/maestro-flow/commands/spec/remove.md +51 -0
  52. package/claude/maestro-flow/commands/spec/setup.md +51 -0
  53. package/claude/maestro-flow/commands/wiki/connect.md +62 -0
  54. package/claude/maestro-flow/commands/wiki/digest.md +69 -0
  55. package/codex/maestro-flow/SKILL.md +505 -0
  56. package/codex/maestro-flow/chains/templates.json +256 -0
  57. package/codex/maestro-flow/commands/learn/decompose.md +113 -0
  58. package/codex/maestro-flow/commands/learn/follow.md +83 -0
  59. package/codex/maestro-flow/commands/learn/investigate.md +83 -0
  60. package/codex/maestro-flow/commands/learn/retro.md +83 -0
  61. package/codex/maestro-flow/commands/learn/second-opinion.md +86 -0
  62. package/codex/maestro-flow/commands/lifecycle/amend.md +300 -0
  63. package/codex/maestro-flow/commands/lifecycle/analyze.md +483 -0
  64. package/codex/maestro-flow/commands/lifecycle/brainstorm.md +397 -0
  65. package/codex/maestro-flow/commands/lifecycle/composer.md +213 -0
  66. package/codex/maestro-flow/commands/lifecycle/execute.md +318 -0
  67. package/codex/maestro-flow/commands/lifecycle/fork.md +98 -0
  68. package/codex/maestro-flow/commands/lifecycle/init.md +134 -0
  69. package/codex/maestro-flow/commands/lifecycle/learn.md +80 -0
  70. package/codex/maestro-flow/commands/lifecycle/link-coordinate.md +257 -0
  71. package/codex/maestro-flow/commands/lifecycle/merge.md +69 -0
  72. package/codex/maestro-flow/commands/lifecycle/overlay.md +119 -0
  73. package/codex/maestro-flow/commands/lifecycle/plan.md +460 -0
  74. package/codex/maestro-flow/commands/lifecycle/player.md +323 -0
  75. package/codex/maestro-flow/commands/lifecycle/quick.md +124 -0
  76. package/codex/maestro-flow/commands/lifecycle/roadmap.md +468 -0
  77. package/codex/maestro-flow/commands/lifecycle/ui-design.md +135 -0
  78. package/codex/maestro-flow/commands/lifecycle/update.md +176 -0
  79. package/codex/maestro-flow/commands/lifecycle/verify.md +468 -0
  80. package/codex/maestro-flow/commands/manage/codebase-rebuild.md +347 -0
  81. package/codex/maestro-flow/commands/manage/codebase-refresh.md +66 -0
  82. package/codex/maestro-flow/commands/manage/harvest.md +91 -0
  83. package/codex/maestro-flow/commands/manage/issue-discover.md +431 -0
  84. package/codex/maestro-flow/commands/manage/issue.md +75 -0
  85. package/codex/maestro-flow/commands/manage/knowhow-capture.md +110 -0
  86. package/codex/maestro-flow/commands/manage/knowhow.md +95 -0
  87. package/codex/maestro-flow/commands/manage/learn.md +137 -0
  88. package/codex/maestro-flow/commands/manage/status.md +76 -0
  89. package/codex/maestro-flow/commands/manage/wiki.md +55 -0
  90. package/codex/maestro-flow/commands/milestone/audit.md +87 -0
  91. package/codex/maestro-flow/commands/milestone/complete.md +91 -0
  92. package/codex/maestro-flow/commands/milestone/release.md +70 -0
  93. package/codex/maestro-flow/commands/quality/auto-test.md +547 -0
  94. package/codex/maestro-flow/commands/quality/debug.md +334 -0
  95. package/codex/maestro-flow/commands/quality/refactor.md +151 -0
  96. package/codex/maestro-flow/commands/quality/retrospective.md +292 -0
  97. package/codex/maestro-flow/commands/quality/review.md +364 -0
  98. package/codex/maestro-flow/commands/quality/sync.md +111 -0
  99. package/codex/maestro-flow/commands/quality/test.md +498 -0
  100. package/codex/maestro-flow/commands/spec/add.md +101 -0
  101. package/codex/maestro-flow/commands/spec/load.md +77 -0
  102. package/codex/maestro-flow/commands/spec/remove.md +69 -0
  103. package/codex/maestro-flow/commands/spec/setup.md +75 -0
  104. package/codex/maestro-flow/commands/wiki/connect.md +73 -0
  105. package/codex/maestro-flow/commands/wiki/digest.md +87 -0
  106. package/package.json +24 -0
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: learn-second-opinion
3
+ description: Multi-perspective analysis with review, challenge, and consult modes
4
+ argument-hint: "<target> [--mode review|challenge|consult]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Structured second-opinion workflow for code, decisions, or plans. Three modes inspired by gstack `/codex`:
16
+
17
+ - **review** (default): 3 parallel agents with distinct personas (pragmatist, purist, strategist) independently assess the target
18
+ - **challenge**: single adversarial agent that tries to break the approach, find hidden assumptions, and propose alternatives
19
+ - **consult**: interactive Q&A mode where the agent studies the target and answers your questions
20
+
21
+ Decoupled from the phase/execution lifecycle — can be invoked on any piece of code or knowledge at any time. Findings persist to `lessons.jsonl`.
22
+ </purpose>
23
+
24
+ <context>
25
+ Arguments: $ARGUMENTS
26
+
27
+ **Target resolution (auto-detected):**
28
+ - File path → analyze that file's content
29
+ - Wiki ID (`<type>-<slug>`) → fetch via `maestro wiki get`
30
+ - `HEAD` or `staged` → analyze current git diff (`git diff HEAD` or `git diff --staged`)
31
+ - Phase number (e.g., `3`) → resolve via `state.json.artifacts[]` to find plan in scratch dir
32
+
33
+ **Flags:**
34
+ - `--mode review` — 3-persona parallel review (default)
35
+ - `--mode challenge` — Adversarial single-agent analysis
36
+ - `--mode consult` — Interactive Q&A session
37
+
38
+ **Storage written:**
39
+ - `.workflow/learning/opinion-{slug}-{YYYY-MM-DD}.md` — Opinion report
40
+ - `.workflow/learning/lessons.jsonl` — New insights from analysis (source: "second-opinion")
41
+ - `.workflow/learning/learning-index.json` — Updated index
42
+
43
+ **Storage read:**
44
+ - Target content (file, wiki entry, diff, or plan)
45
+ - `.workflow/specs/` — Project conventions for context
46
+ - `maestro wiki search` — Related knowledge entries
47
+ - `.workflow/learning/lessons.jsonl` — Prior insights about the topic
48
+ </context>
49
+
50
+ <execution>
51
+
52
+ ### Stage 1: Resolve Target
53
+ - File path: Read the file
54
+ - Wiki ID: `maestro wiki get <id>`
55
+ - `HEAD`: `git diff HEAD` (unstaged + staged changes)
56
+ - `staged`: `git diff --staged`
57
+ - Phase N: Resolve via `state.json.artifacts.find(a => a.type === 'plan' && a.phase === N)` → read `.workflow/{artifact.path}/plan.json`
58
+ - If unresolvable, AskUserQuestion for clarification
59
+
60
+ ### Stage 2: Load Context
61
+ - Read relevant specs: `Skill({ skill: "maestro-flow", args: "--cmd spec-load" })` silently to get project conventions
62
+ - Search wiki: `maestro wiki search "<target topic>"` for related entries (top 5)
63
+ - Search lessons: grep `lessons.jsonl` for entries related to the target area
64
+ - Build context brief: target content + conventions + related knowledge
65
+
66
+ ### Stage 3: Execute Mode
67
+
68
+ #### Mode: review (default)
69
+ Spawn 3 Agents in a single message with distinct personas:
70
+
71
+ **Agent 1 — Pragmatist:**
72
+ - Focus: simplicity, YAGNI, maintenance cost, readability
73
+ - Question: "Is this the simplest thing that could work? What's the maintenance burden?"
74
+ - Evaluates: complexity score, abstraction depth, dependency count
75
+
76
+ **Agent 2 — Purist:**
77
+ - Focus: correctness, type safety, edge cases, error handling
78
+ - Question: "What assumptions can be violated? Where are the edge cases?"
79
+ - Evaluates: error paths covered, type completeness, invariant preservation
80
+
81
+ **Agent 3 — Strategist:**
82
+ - Focus: scalability, extensibility, architecture alignment
83
+ - Question: "Does this support future growth? Does it fit the overall architecture?"
84
+ - Evaluates: coupling, cohesion, architecture constraint compliance
85
+
86
+ Each agent returns:
87
+ ```json
88
+ {
89
+ "persona": "pragmatist|purist|strategist",
90
+ "verdict": "approve|concern|reject",
91
+ "confidence": "high|medium|low",
92
+ "findings": [{ "severity": "high|medium|low", "description": "...", "location": "file:line", "suggestion": "..." }],
93
+ "summary": "one paragraph assessment"
94
+ }
95
+ ```
96
+
97
+ #### Mode: challenge
98
+ Spawn 1 Agent as an adversarial reviewer:
99
+
100
+ - Try to find the weakest assumption in the approach
101
+ - Propose a concrete scenario that breaks the current implementation
102
+ - Identify the single biggest risk
103
+ - Suggest an alternative approach and argue why it might be better
104
+ - Apply forcing questions:
105
+ - "What assumption would invalidate this entire approach?"
106
+ - "What's the simplest thing that breaks this?"
107
+ - "If you had to rewrite this in 6 months, what would you regret?"
108
+ - "What's the implicit contract that isn't enforced?"
109
+
110
+ #### Mode: consult
111
+ Interactive loop:
112
+ 1. Agent studies the target content thoroughly
113
+ 2. Display: "Target loaded. What would you like to know?"
114
+ 3. AskUserQuestion for the first question
115
+ 4. Agent answers with code references and evidence
116
+ 5. Loop: AskUserQuestion for follow-up or "done" to exit
117
+ 6. On exit, compile all Q&A into the report
118
+
119
+ ### Stage 4: Synthesize
120
+ Across all perspectives (or from single agent in challenge/consult):
121
+ - **Points of agreement**: findings all personas share
122
+ - **Points of disagreement**: where personas diverge (with reasoning)
123
+ - **Verdict**: combined assessment with confidence level
124
+ - **Top 3 recommendations**: prioritized by impact
125
+
126
+ ### Stage 5: Persist & Report
127
+ 1. Write `.workflow/learning/opinion-{slug}-{date}.md`:
128
+ - Target summary
129
+ - Per-persona findings (review) / adversarial analysis (challenge) / Q&A transcript (consult)
130
+ - Synthesis: agreements, disagreements, verdict
131
+ - Recommendations
132
+ 2. Append non-trivial findings to `lessons.jsonl`:
133
+ - `source: "second-opinion"`, `category: "pattern"` or `"antipattern"` or `"decision"`
134
+ - Tags: `["second-opinion", "{mode}", "{target-slug}"]`
135
+ 3. Update `learning-index.json`
136
+ 4. Display summary with verdict and recommendations
137
+
138
+ **Next-step routing:**
139
+ - Create issue for a finding → `/manage-issue create <description>`
140
+ - Decompose patterns found → `/learn-decompose <path>`
141
+ - Follow-along on the code → `/learn-follow <path>`
142
+ </execution>
143
+
144
+ <error_codes>
145
+ | Code | Severity | Condition | Recovery |
146
+ |------|----------|-----------|----------|
147
+ | E001 | error | Target not resolvable (file/wiki/diff/plan not found) | Verify target argument, provide correct path or ID |
148
+ | E002 | error | Unknown --mode value | Use: review, challenge, or consult |
149
+ | W001 | warning | One review agent failed — partial perspectives | Proceed with available agents, note incomplete coverage |
150
+ | W002 | warning | No related wiki entries found for context | Proceed without wiki context |
151
+ | W003 | warning | Git diff empty (no changes) for HEAD/staged target | Nothing to review; suggest using a file path instead |
152
+ </error_codes>
153
+
154
+ <success_criteria>
155
+ - [ ] Target resolved and content loaded
156
+ - [ ] Context gathered (specs, wiki, lessons)
157
+ - [ ] Mode executed correctly:
158
+ - review: 3 agents spawned in parallel, all returned findings
159
+ - challenge: adversarial analysis completed with forcing questions
160
+ - consult: interactive Q&A loop completed
161
+ - [ ] Synthesis produced with agreements, disagreements, verdict
162
+ - [ ] Report written to `opinion-{slug}-{date}.md`
163
+ - [ ] Non-trivial findings appended to `lessons.jsonl`
164
+ - [ ] `learning-index.json` updated
165
+ - [ ] No files modified outside `.workflow/learning/`
166
+ - [ ] Summary displayed with verdict and next-step routing
167
+ </success_criteria>
@@ -0,0 +1,300 @@
1
+ ---
2
+ name: maestro-amend
3
+ description: Collect deficiency signals from workflow artifacts, sessions, and user reports, then generate overlays to amend workflow commands
4
+ argument-hint: "[description] [--from-verify <dir>] [--from-review <dir>] [--from-session <id>] [--from-issues ISS-xxx,...] [--scan] [--dry-run]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - AskUserQuestion
12
+ ---
13
+ <purpose>
14
+ Signal-driven overlay generator — collects workflow deficiency signals from heterogeneous sources (verification gaps, review findings, debug sessions, open issues, user feedback), diagnoses which commands need amendment, and batch-generates targeted overlays to fix them.
15
+
16
+ Differs from `/maestro-overlay` which takes a single explicit intent. This command **discovers** what needs amending by analyzing workflow artifacts, then proposes and applies overlay fixes automatically.
17
+
18
+ **Mechanism**: All amendments use the overlay system (`~/.maestro/overlays/*.json`) — non-invasive, idempotent, survives reinstall.
19
+ </purpose>
20
+
21
+ <required_reading>
22
+ @~/.maestro/workflows/overlays.md
23
+ @~/.maestro/cli-tools.json
24
+ </required_reading>
25
+
26
+ <context>
27
+ $ARGUMENTS — optional description and/or source flags.
28
+
29
+ ### Signal Sources
30
+
31
+ | Flag | Source | What it collects |
32
+ |------|--------|------------------|
33
+ | `--from-verify <dir>` | `verification.json` | Workflow gaps exposed by verify failures |
34
+ | `--from-review <dir>` | `review.json` | Process deficiencies from code review |
35
+ | `--from-session <id>` | Session artifacts | Problems encountered during workflow execution |
36
+ | `--from-issues ISS-xxx,...` | `issues.jsonl` | Issues that trace to command deficiency |
37
+ | `--scan` | Auto-scan `.workflow/` | Discover all workflow-related signals |
38
+ | _(positional text)_ | User description | Direct observation of command deficiency |
39
+
40
+ Multiple sources combinable. No flags and no description → interactive mode.
41
+
42
+ ### Control Flags
43
+
44
+ | Flag | Description |
45
+ |------|-------------|
46
+ | `--dry-run` | Generate overlay JSON, show preview, don't install |
47
+ | `-y` | Skip confirmations |
48
+
49
+ ### Signal-to-Overlay Classification
50
+
51
+ A signal becomes an overlay candidate when it identifies a **workflow command deficiency** — a missing step, missing precondition, absent reading, or gap in success criteria. Signals about code bugs (not command gaps) are out of scope; suggest `/maestro-quick` or `/maestro-plan --gaps` for those.
52
+
53
+ ### CLI Targeting
54
+
55
+ Overlays support the `cli` field to target different workflow systems:
56
+ - `"cli": "claude"` (default) → patches `.claude/commands/{name}.md`
57
+ - `"cli": "codex"` → patches `.codex/skills/{name}/SKILL.md`
58
+ - `"cli": "both"` → patches both paths
59
+
60
+ When diagnosing signals, determine which CLI's workflow is affected and set the `cli` field accordingly.
61
+
62
+ ### Output
63
+ - Overlay files: `~/.maestro/overlays/amend-{slug}.json`
64
+ - Optional docs: `~/.maestro/overlays/docs/amend-{slug}.md`
65
+ </context>
66
+
67
+ <execution>
68
+ ### 1. Collect signals
69
+
70
+ Parse $ARGUMENTS for source flags and description text.
71
+
72
+ **If no sources and no description** → interactive mode:
73
+ Scan `.workflow/` for recent artifacts containing workflow-level signals:
74
+
75
+ ```
76
+ candidates = []
77
+
78
+ # Verification: workflow gaps (not code bugs)
79
+ for each verification.json in .workflow/scratch/*-verify-*/
80
+ extract must_have_failures, anti_pattern items
81
+ filter for items whose fix_direction points at a command gap
82
+ (e.g., "missing pre-check step", "no reading for X", "success criteria incomplete")
83
+
84
+ # Review: process findings
85
+ for each review.json in .workflow/scratch/*-review-*/
86
+ extract findings tagged as "process" or "workflow"
87
+
88
+ # Debug sessions: root causes tracing to command omission
89
+ for each understanding.md in .workflow/scratch/*-debug-*/
90
+ extract root causes where cause_type mentions workflow/command
91
+
92
+ # Open issues: workflow-tagged
93
+ issues = read .workflow/issues/issues.jsonl
94
+ | filter status == "open" AND tags include "workflow" or "command"
95
+
96
+ # Execution summaries: deviations
97
+ for each summary in .workflow/scratch/*-plan-*/.summaries/
98
+ extract plan deviations that suggest a missing command step
99
+ ```
100
+
101
+ Display scan results and use AskUserQuestion (multiSelect) to let user pick sources. Also allow user to add a freeform description.
102
+
103
+ **If source flags** → extract signals from each specified source.
104
+
105
+ **If only description** → user's text is the sole signal. Parse for:
106
+ - Which command(s) are affected
107
+ - What's missing or broken in the command flow
108
+ - What the expected behavior should be
109
+
110
+ ### 2. Diagnose: map signals to command patches
111
+
112
+ For each signal, determine:
113
+
114
+ ```
115
+ {
116
+ signal_id: "SIG-001",
117
+ source: "verify:scratch/20260426-verify-M1/",
118
+ description: "maestro-execute skipped pre-flight when no test suite exists",
119
+ target_command: "maestro-execute",
120
+ target_section: "execution",
121
+ patch_mode: "append",
122
+ fix_direction: "Add fallback verification when no test suite detected",
123
+ severity: "medium"
124
+ }
125
+ ```
126
+
127
+ **Diagnosis heuristics:**
128
+
129
+ | Signal pattern | Target section | Mode |
130
+ |---------------|----------------|------|
131
+ | Missing pre-check / gate | `execution` | `prepend` |
132
+ | Missing post-step / verification | `execution` | `append` |
133
+ | Missing reading / context | `required_reading` or `deferred_reading` | `append` |
134
+ | Incomplete success criteria | `success_criteria` | `append` |
135
+ | Missing error handling | `error_codes` | `append` |
136
+ | Scope/context gap | `context` | `append` |
137
+ | Entirely new concern | _(new section)_ | `new-section` |
138
+
139
+ If target command is ambiguous, read the pristine source from `$PKG_ROOT/.claude/commands/<name>.md` (preferred) or `~/.claude/commands/<name>.md` to confirm the right section.
140
+
141
+ ### 3. Group and plan overlays
142
+
143
+ Group signals by target command. Signals hitting the same command **and** same section merge into one patch. Different sections on the same command stay as separate patches in one overlay.
144
+
145
+ Decide overlay granularity:
146
+ - **Single-concern** (1–2 signals on same command) → one overlay per command: `patch-{command}-{slug}.json`
147
+ - **Multi-concern** (3+ signals across commands) → one umbrella overlay: `amend-{slug}.json`
148
+
149
+ For each planned overlay, read the target command's pristine source to:
150
+ - Verify the section exists
151
+ - Check for existing overlays (via `<!-- maestro-overlay:` markers)
152
+ - Confirm the injection point makes sense
153
+
154
+ ### 4. Preview injection points
155
+
156
+ For each target command, render a section map with injection points (same format as `/maestro-overlay`):
157
+
158
+ ```
159
+ === maestro-execute.md (1 existing overlay) ===
160
+
161
+ <purpose>
162
+ <required_reading>
163
+ ├─ [existing] require-spec-before-plan #0
164
+ <context>
165
+ <execution>
166
+ ├─ [existing] require-spec-before-plan #1 "Pre-check: Load Spec"
167
+ ├─ [existing] cli-verify-after-execute #0 "CLI Verification"
168
+ >>> NEW: prepend — SIG-001 "Fallback verify when no tests"
169
+ >>> NEW: append — SIG-003 "Issue sync retry on failure"
170
+ <error_codes>
171
+ <success_criteria>
172
+ >>> NEW: append — SIG-002 "Verify issue status updated"
173
+
174
+ === maestro-plan.md (0 existing overlays) ===
175
+
176
+ <purpose>
177
+ <required_reading>
178
+ <context>
179
+ >>> NEW: append — SIG-004 "Load prior patch history"
180
+ <execution>
181
+ <success_criteria>
182
+ ```
183
+
184
+ Use AskUserQuestion to confirm:
185
+ - **"Apply all"** — proceed with all patches
186
+ - **"Select patches"** — per-signal confirmation
187
+ - **"Edit"** — modify a specific signal's target/section before proceeding
188
+ - **"Cancel"** — abort
189
+
190
+ ### 5. Draft overlay JSON
191
+
192
+ For each overlay, build the JSON following the overlay schema:
193
+
194
+ ```json
195
+ {
196
+ "name": "amend-execute-verify-fallback",
197
+ "description": "Add fallback verification and issue sync retry to maestro-execute [from: AMEND-20260426]",
198
+ "targets": ["maestro-execute"],
199
+ "cli": "claude",
200
+ "priority": 60,
201
+ "enabled": true,
202
+ "patches": [
203
+ {
204
+ "section": "execution",
205
+ "mode": "prepend",
206
+ "content": "## Fallback Verification (patch: SIG-001)\n\nIf no test suite exists for the affected module, run a structural verification instead:\n..."
207
+ },
208
+ {
209
+ "section": "execution",
210
+ "mode": "append",
211
+ "content": "## Issue Sync Retry (patch: SIG-003)\n\nIf issue status sync fails, retry once before logging as warning:\n..."
212
+ },
213
+ {
214
+ "section": "success_criteria",
215
+ "mode": "append",
216
+ "content": "- [ ] Issue statuses confirmed synced after execution (patch: SIG-002)"
217
+ }
218
+ ]
219
+ }
220
+ ```
221
+
222
+ **Content rules:**
223
+ - Heading includes `(patch: SIG-NNN)` for traceability
224
+ - Content is concise — fix the gap, nothing more
225
+ - `@~/.maestro/overlays/docs/` references for anything longer than 10 lines
226
+ - If supplementary doc needed, write it to `~/.maestro/overlays/docs/amend-{slug}.md` first
227
+
228
+ Write overlay JSON to `~/.maestro/overlays/amend-{slug}.json`.
229
+
230
+ If `--dry-run`, show the JSON and section map preview, then stop.
231
+
232
+ ### 6. Install overlays
233
+
234
+ For each generated overlay:
235
+
236
+ ```bash
237
+ maestro overlay add ~/.maestro/overlays/amend-{slug}.json
238
+ ```
239
+
240
+ On validation failure, fix the JSON and retry (max 2 attempts).
241
+
242
+ ### 7. Report
243
+
244
+ ```
245
+ === AMEND OVERLAYS INSTALLED ===
246
+ Session: AMEND-20260426
247
+ Signals: 5 collected, 4 applied, 1 skipped (code bug, not command gap)
248
+ Overlays: 2 created
249
+
250
+ amend-execute-verify-fallback
251
+ Targets: maestro-execute (3 patches: exec prepend, exec append, criteria append)
252
+ Path: ~/.maestro/overlays/amend-execute-verify-fallback.json
253
+ Source: SIG-001, SIG-002, SIG-003
254
+
255
+ amend-plan-context-history
256
+ Targets: maestro-plan (1 patch: context append)
257
+ Path: ~/.maestro/overlays/amend-plan-context-history.json
258
+ Source: SIG-004
259
+
260
+ Skipped:
261
+ SIG-005 "Missing null check in auth.ts" → code bug, use /maestro-quick
262
+
263
+ Re-apply: maestro overlay apply
264
+ Remove: maestro overlay remove amend-execute-verify-fallback
265
+ Inspect: maestro overlay list
266
+ ```
267
+
268
+ ### Post-patch routing
269
+
270
+ Use AskUserQuestion:
271
+ - **"Test commands"** — run affected commands to verify patches work
272
+ - **"View overlays"** — `maestro overlay list`
273
+ - **"Continue"** — done
274
+ </execution>
275
+
276
+ <error_codes>
277
+ | Code | Severity | Condition | Recovery |
278
+ |------|----------|-----------|----------|
279
+ | E001 | error | No signals found from any source | Verify artifact paths, or provide description |
280
+ | E002 | error | Source artifact not found | Check path exists |
281
+ | E003 | error | No signals map to command deficiencies (all are code bugs) | Use `/maestro-quick` or `/maestro-plan --gaps` instead |
282
+ | E004 | error | Overlay validation failed after 2 retries | Review generated JSON manually |
283
+ | W001 | warning | Some signals skipped (code bugs, not command gaps) | Route to appropriate fix command |
284
+ | W002 | warning | Target command has many existing overlays (≥3) | Consider consolidating overlays |
285
+ | W003 | warning | Scan found no recent workflow artifacts | Check `.workflow/` or provide explicit source |
286
+ </error_codes>
287
+
288
+ <success_criteria>
289
+ - [ ] Signal sources resolved and signals collected
290
+ - [ ] Each signal classified: command deficiency vs. code bug (only command deficiencies proceed)
291
+ - [ ] Signals mapped to target command + section + mode
292
+ - [ ] Pristine command sources read to verify sections and check existing overlays
293
+ - [ ] Section map with injection points shown and confirmed by user
294
+ - [ ] Overlay JSON written to `~/.maestro/overlays/amend-{slug}.json`
295
+ - [ ] Supplementary docs written to `~/.maestro/overlays/docs/` if needed
296
+ - [ ] `maestro overlay add` exited successfully for each overlay
297
+ - [ ] Target command files contain `<!-- maestro-overlay:amend-{slug}#N hash=... -->` markers
298
+ - [ ] Report shown with overlay details, source traceability, and skipped signals
299
+ - [ ] Skipped code-bug signals routed to appropriate alternative command
300
+ </success_criteria>
@@ -0,0 +1,126 @@
1
+ ---
2
+ name: maestro-analyze
3
+ description: Multi-dimensional analysis with CLI exploration, decision extraction, and intent tracking
4
+ argument-hint: "[phase|topic] [-y] [-c] [-q] [--gaps [ISS-ID]]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ Perform multi-dimensional analysis of a technical proposal, decision, or architecture choice through iterative CLI-assisted exploration and interactive discussion. Produces a discussion timeline (discussion.md) with evolving understanding, multi-perspective findings, Decision Recording Protocol, Intent Coverage tracking, and a final conclusions package with Go/No-Go recommendation.
17
+
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
+
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`.
23
+ </purpose>
24
+
25
+ <required_reading>
26
+ @~/.maestro/workflows/analyze.md
27
+ </required_reading>
28
+
29
+ <deferred_reading>
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
32
+ </deferred_reading>
33
+
34
+ <context>
35
+ $ARGUMENTS -- phase number for milestone-scoped, topic text for adhoc/standalone mode, no args for milestone-wide.
36
+
37
+ **Flags:**
38
+ - `-y` / `--yes`: Auto mode — skip interactive scoping, use recommended defaults, auto-deepen
39
+ - `-c` / `--continue`: Resume from existing session (auto-detect session folder + discussion.md)
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.
42
+
43
+ Scope routing, output directory format, artifact registration schema, and output artifact listing are defined in workflow analyze.md (Scope Routing and Output Structure sections).
44
+ </context>
45
+
46
+ <execution>
47
+ Follow '~/.maestro/workflows/analyze.md' completely.
48
+
49
+ ### --gaps Mode (Issue Root Cause Analysis)
50
+
51
+ When `--gaps` flag is present, follow `~/.maestro/workflows/issue-gaps-analyze.md` instead of the standard analyze pipeline:
52
+
53
+ ```
54
+ Phase 1: Load issues from .workflow/issues/issues.jsonl
55
+ - If ISS-ID provided: load single issue
56
+ - If no ISS-ID: filter issues where status = open | registered
57
+ - Validate: at least 1 issue loaded, else error E_NO_ISSUES
58
+
59
+ Phase 2: CLI exploration per issue
60
+ - For each issue: build exploration prompt from issue.title, description, context, related_files
61
+ - Run maestro delegate --role analyze --mode analysis with codebase context
62
+ - Gather affected files, call chains, root cause evidence
63
+
64
+ Phase 3: Root cause synthesis → write issue.analysis
65
+ - Parse CLI output into analysis record: { root_cause, affected_files, impact_scope, fix_direction, confidence, analyzed_at, tool, depth }
66
+ - Write analysis record to issue in issues.jsonl
67
+ - Append history entry: { action: "analyzed", at: <ISO>, by: "maestro-analyze --gaps" }
68
+
69
+ Phase 4: Output context.md for downstream plan --gaps
70
+ - Aggregate all analyzed issues into context.md with root causes and fix directions
71
+ - Register ANL artifact in state.json
72
+ ```
73
+
74
+ **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.
75
+
76
+ **Next-step routing on completion:**
77
+
78
+ Phase/Milestone scope:
79
+ - Go recommendation, UI work needed → `/maestro-ui-design {phase}`
80
+ - Go recommendation, ready to plan → `/maestro-plan` or `/maestro-plan {phase}`
81
+ - No-Go recommendation → revisit requirements or `/maestro-brainstorm {topic}`
82
+
83
+ Adhoc/Standalone scope:
84
+ - Ready to plan → `/maestro-plan --dir {scratch_dir}`
85
+ - Need more exploration → `/maestro-analyze {topic} -c`
86
+
87
+ Gaps scope:
88
+ - Issues analyzed → `/maestro-plan --gaps` (plan fix tasks linked to issues)
89
+ - Need more context → `/maestro-analyze --gaps {ISS-ID}` (re-analyze specific issue)
90
+ </execution>
91
+
92
+ <error_codes>
93
+ | Code | Severity | Condition | Recovery |
94
+ |------|----------|-----------|----------|
95
+ | E001 | error | No args and no roadmap (cannot determine scope) | Prompt user for topic text or create roadmap first |
96
+ | W001 | warning | CLI exploration failed | Continue with available context, note limitation |
97
+ | W002 | warning | CLI analysis timeout | Retry with shorter prompt, or skip perspective |
98
+ | W003 | warning | Insufficient evidence for scoring dimensions | Note low-confidence dimensions, proceed with available evidence |
99
+ | W004 | warning | Max rounds reached (5) | Force synthesis, offer continuation option |
100
+ | E_NO_ISSUES | error | --gaps but no open/registered issues found | Suggest `/manage-issue-discover` or `/manage-issue create` |
101
+ | E_ISSUE_NOT_FOUND | error | --gaps with ISS-ID but issue not found | Suggest `/manage-issue list` to find valid IDs |
102
+ </error_codes>
103
+
104
+ <success_criteria>
105
+ Full mode:
106
+ - [ ] CLI exploration completed with code anchors and call chains
107
+ - [ ] discussion.md created with full timeline, TOC, Current Understanding
108
+ - [ ] analysis.md written with all 6 dimensions scored with evidence
109
+ - [ ] conclusions.json created with recommendations and decision trail
110
+ - [ ] Intent Coverage tracked and verified (no unresolved ❌ items)
111
+
112
+ Gaps mode:
113
+ - [ ] Issues loaded from issues.jsonl (all open/registered, or single ISS-ID)
114
+ - [ ] CLI exploration executed per issue with codebase context
115
+ - [ ] Analysis record attached to each issue in issues.jsonl
116
+ - [ ] context.md written with aggregated root causes for plan --gaps
117
+
118
+ Both modes (full + quick):
119
+ - [ ] context.md written with all decisions classified as Locked/Free/Deferred
120
+ - [ ] Gray areas identified through phase-specific analysis
121
+ - [ ] Decision Recording Protocol applied to all decisions
122
+ - [ ] Scope creep redirected to Deferred section
123
+ - [ ] Deferred items auto-created as issues (if any)
124
+ - [ ] Artifact registered in state.json with correct scope/milestone/phase
125
+ - [ ] Next step routed (ui-design/plan for Go, brainstorm for No-Go)
126
+ </success_criteria>