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,239 @@
1
+ ---
2
+ name: maestro-flow
3
+ description: Unified workflow command collection — intent routing, minimal closed-loop chain selection, step-by-step execution. All 49 maestro commands in one skill.
4
+ argument-hint: "\"intent\" [-y] [--chain <name>] [--cmd <name> <args>] | list | status | continue | execute"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Skill
13
+ - AskUserQuestion
14
+ ---
15
+
16
+ <purpose>
17
+ Single-entry skill packaging all 49 Maestro workflow commands (Claude Code variant).
18
+
19
+ Two execution modes:
20
+ 1. **Router** (default): Analyze intent -> match chain template -> create session -> step execution
21
+ 2. **Direct** (`--cmd <name> <args>`): Load and execute a specific command inline
22
+
23
+ Execution uses `maestro-flow next/done` CLI for step lifecycle management.
24
+ Commands loaded via `maestro-flow resolve` + `Read()` for inline execution.
25
+ External steps delegated via `maestro delegate --to claude "/maestro-flow --cmd ..."`.
26
+
27
+ Session path: `.workflow/.maestro/flow-{YYYYMMDD-HHmmss}/status.json`
28
+ </purpose>
29
+
30
+ <context>
31
+ $ARGUMENTS -- intent text, flags, or special keywords.
32
+
33
+ **State files:**
34
+ - `.workflow/state.json` -- project artifact registry (optional)
35
+ - `.workflow/.maestro/flow-*/status.json` -- flow session state
36
+ </context>
37
+
38
+ <execution>
39
+
40
+ ## Step 1: Parse & Route
41
+
42
+ ```
43
+ Parse $ARGUMENTS:
44
+
45
+ --cmd <name> <remaining-args>
46
+ -> Step 1a: Direct Command Execution
47
+ -> End.
48
+
49
+ list
50
+ -> Bash: maestro-flow list
51
+ -> End.
52
+
53
+ status [session-id]
54
+ -> Bash: maestro-flow status [session-id]
55
+ -> End.
56
+
57
+ chains
58
+ -> Bash: maestro-flow chains
59
+ -> End.
60
+
61
+ execute | continue
62
+ -> Find latest running flow session
63
+ -> If not found: "No running flow session." End.
64
+ -> Phase 2 (Step Execution Loop)
65
+
66
+ --chain <name> [-y] <remaining>
67
+ -> Force chain selection, go to Step 4
68
+
69
+ -y / --yes
70
+ -> auto_confirm = true
71
+
72
+ Other text
73
+ -> intent = remaining text -> Step 2
74
+ ```
75
+
76
+ ### Step 1a: Direct Command Execution (--cmd)
77
+
78
+ ```
79
+ 1. Bash: maestro-flow resolve <name>
80
+ -> Returns absolute path to command .md file
81
+
82
+ 2. If NOT_FOUND -> Error. End.
83
+
84
+ 3. Read() the command .md file
85
+
86
+ 4. Set $ARGUMENTS = <remaining-args>
87
+
88
+ 5. Follow the command's <execution> section completely
89
+
90
+ End.
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Step 2: Read Project State (optional)
96
+
97
+ ```
98
+ If .workflow/state.json exists:
99
+ Read -> extract: current_milestone, milestones, artifacts
100
+ If not: state_summary = "Project not initialized"
101
+ ```
102
+
103
+ ## Step 3: Intent Analysis & Chain Matching
104
+
105
+ ```
106
+ Bash: maestro-flow suggest "{intent}"
107
+
108
+ Display top 3 chain options
109
+ AskUserQuestion: select chain / single command / Cancel
110
+
111
+ If auto_confirm: pick highest scoring chain
112
+ If single command: --cmd -> Step 1a
113
+ If chain selected: -> Step 4
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Step 4: Build Session
119
+
120
+ ### 4.1: Create session from template
121
+
122
+ ```
123
+ session_id = "flow-{YYYYMMDD-HHmmss}"
124
+ session_dir = .workflow/.maestro/{session_id}/
125
+
126
+ Build steps[] from selected chain template.
127
+ Write status.json.
128
+ Display chain steps, confirm (or auto if -y).
129
+ ```
130
+
131
+ Fall through to Phase 2.
132
+
133
+ ---
134
+
135
+ ## Phase 2: Step Execution Loop
136
+
137
+ ### 2.1: Load next step
138
+
139
+ ```
140
+ Bash: maestro-flow next
141
+ ```
142
+
143
+ Parse output:
144
+ - `NO_SESSION` -> End.
145
+ - `SESSION_COMPLETE` -> Display summary. End.
146
+ - `STEP: idx/total` + `TYPE` + `SKILL` + `ARGS` + `PATH` + `---COMMAND---` -> continue
147
+
148
+ ### 2.2: Route by type
149
+
150
+ ```
151
+ If TYPE == "decision" -> Step 2.3 (Decision Evaluation)
152
+ If TYPE == "internal" -> Step 2.4 (Internal Execution)
153
+ If TYPE == "external" -> Step 2.5 (External Execution)
154
+ ```
155
+
156
+ ### 2.3: Decision Evaluation
157
+
158
+ **Quality-gate decisions** (post-verify, post-review, post-test, post-business-test):
159
+
160
+ ```
161
+ Resolve artifact dir from .workflow/state.json
162
+
163
+ Bash({
164
+ command: `maestro delegate "evaluate ${decision} quality gate
165
+ CONTEXT: @${result_files}
166
+ ---VERDICT---
167
+ STATUS: proceed | fix | escalate
168
+ REASON: one-line
169
+ GAP_SUMMARY: details
170
+ CONFIDENCE: high | medium | low
171
+ ---END---" --role analyze --mode analysis`,
172
+ run_in_background: true
173
+ })
174
+ STOP -- wait for callback.
175
+ ```
176
+
177
+ On callback: parse verdict, apply (proceed/fix-loop/escalate).
178
+
179
+ **Structural decisions** (post-milestone): evaluate directly.
180
+
181
+ After decision: `Bash: maestro-flow done` -> loop to 2.1.
182
+
183
+ ### 2.4: Internal Execution
184
+
185
+ The command content was loaded by `maestro-flow next` (after `---COMMAND---`).
186
+
187
+ ```
188
+ 1. Parse loaded command .md
189
+ 2. Set $ARGUMENTS = ARGS (with auto-flag if session.auto_mode)
190
+ 3. Follow <execution> section completely
191
+
192
+ Auto flags: maestro-init -y, maestro-plan -y, maestro-execute -y,
193
+ quality-test -y --auto-fix, etc.
194
+
195
+ On complete: Bash: maestro-flow done -> loop to 2.1
196
+ On failure: -> Step 2.6
197
+ ```
198
+
199
+ ### 2.5: External Execution
200
+
201
+ ```
202
+ Bash({
203
+ command: `maestro delegate --to claude "Execute: /maestro-flow --cmd {SKILL} {ARGS}" --mode write`,
204
+ run_in_background: true,
205
+ timeout: 600000
206
+ })
207
+ STOP -- wait for callback.
208
+
209
+ On callback:
210
+ On success: Bash: maestro-flow done -> loop to 2.1
211
+ On failure: -> Step 2.6
212
+ ```
213
+
214
+ ### 2.6: Handle Failure
215
+
216
+ ```
217
+ Auto mode: retry once (maestro-flow step {id} {idx} pending), then skip
218
+ Interactive: AskUserQuestion retry/skip/abort
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Phase 3: Completion
224
+
225
+ ```
226
+ Display session summary with step statuses.
227
+ End.
228
+ ```
229
+
230
+ </execution>
231
+
232
+ <error_codes>
233
+ | Code | Severity | Description | Recovery |
234
+ |------|----------|-------------|----------|
235
+ | E001 | error | No intent and no running session | Prompt for intent |
236
+ | E002 | error | Command not found for --cmd | maestro-flow list |
237
+ | E003 | error | No matching chain template | maestro-flow chains |
238
+ | E004 | error | Delegate verdict parse failed | Fallback: treat as "fix" |
239
+ </error_codes>
@@ -0,0 +1,256 @@
1
+ {
2
+ "version": "2.0",
3
+ "decision_types": {
4
+ "post-verify": {
5
+ "evaluates": "verification.json",
6
+ "verdict_prompt": "评估验证结果: passed/failed 状态, gaps 严重性",
7
+ "fix_loop": ["quality-debug", "maestro-plan --gaps", "maestro-execute", "maestro-verify", "decision:post-verify"]
8
+ },
9
+ "post-review": {
10
+ "evaluates": "review.json",
11
+ "verdict_prompt": "评估代码审查结果: verdict PASS/WARN/BLOCK",
12
+ "fix_loop": ["quality-debug", "maestro-plan --gaps", "maestro-execute", "quality-review", "decision:post-review"]
13
+ },
14
+ "post-test": {
15
+ "evaluates": "uat.md, test-results.json",
16
+ "verdict_prompt": "评估测试结果: 通过率, 失败用例严重性",
17
+ "fix_loop": ["quality-debug", "maestro-plan --gaps", "maestro-execute", "maestro-verify", "decision:post-verify", "quality-test", "decision:post-test"]
18
+ },
19
+ "post-business-test": {
20
+ "evaluates": "business-test-results.json",
21
+ "verdict_prompt": "评估业务测试结果: 需求覆盖率, 失败场景",
22
+ "fix_loop": ["quality-debug", "maestro-plan --gaps", "maestro-execute", "maestro-verify", "decision:post-verify", "quality-auto-test", "decision:post-business-test"]
23
+ },
24
+ "post-milestone": {
25
+ "evaluates": "state.json",
26
+ "verdict_prompt": "检查是否有下一个 milestone",
27
+ "structural": true
28
+ }
29
+ },
30
+ "templates": {
31
+ "quick-fix": {
32
+ "description": "Diagnose and fix a known bug",
33
+ "category": "quick-fix",
34
+ "triggers": ["fix", "debug", "bug", "error", "crash", "broken"],
35
+ "steps": [
36
+ { "cmd": "quality-debug", "args": "\"{intent}\"", "type": "internal" },
37
+ { "cmd": "maestro-plan", "args": "{phase} --gaps", "type": "internal" },
38
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
39
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
40
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 }
41
+ ]
42
+ },
43
+ "issue-fix": {
44
+ "description": "Analyze, plan, fix, and close a tracked issue",
45
+ "category": "quick-fix",
46
+ "triggers": ["issue", "ISS-", "ticket"],
47
+ "steps": [
48
+ { "cmd": "maestro-analyze", "args": "--gaps {issue_id}", "type": "external" },
49
+ { "cmd": "maestro-plan", "args": "--gaps", "type": "internal" },
50
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
51
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
52
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 },
53
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
54
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 },
55
+ { "cmd": "manage-issue", "args": "close {issue_id} --resolution fixed", "type": "internal" }
56
+ ]
57
+ },
58
+ "analyze-plan-execute": {
59
+ "description": "Fast track: analyze, plan, and implement",
60
+ "category": "feature-build",
61
+ "triggers": ["implement", "build", "create", "develop", "add feature"],
62
+ "steps": [
63
+ { "cmd": "maestro-analyze", "args": "\"{intent}\"", "type": "external" },
64
+ { "cmd": "maestro-plan", "args": "--dir {scratch_dir}", "type": "internal" },
65
+ { "cmd": "maestro-execute", "args": "--dir {scratch_dir}", "type": "external" }
66
+ ]
67
+ },
68
+ "plan-execute-verify": {
69
+ "description": "Full phase: plan, execute, verify with quality gate",
70
+ "category": "feature-build",
71
+ "triggers": ["plan and execute", "phase", "plan execute"],
72
+ "steps": [
73
+ { "cmd": "maestro-plan", "args": "{phase}", "type": "internal" },
74
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
75
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
76
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 }
77
+ ]
78
+ },
79
+ "execute-verify": {
80
+ "description": "Execute existing plan and verify",
81
+ "category": "feature-build",
82
+ "triggers": ["execute", "run plan", "implement plan"],
83
+ "steps": [
84
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
85
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" }
86
+ ]
87
+ },
88
+ "quality-loop": {
89
+ "description": "Full quality check: verify, review, test with decision gates",
90
+ "category": "quality-check",
91
+ "triggers": ["check quality", "review and test", "quality", "qa"],
92
+ "steps": [
93
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
94
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 },
95
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
96
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 },
97
+ { "cmd": "quality-auto-test", "args": "{phase}", "type": "internal" },
98
+ { "cmd": "quality-test", "args": "{phase}", "type": "internal" },
99
+ { "cmd": "decision:post-test", "args": "", "type": "decision", "decision": "post-test", "retry_count": 0, "max_retries": 2 }
100
+ ]
101
+ },
102
+ "review-fix": {
103
+ "description": "Fix review-blocked issues",
104
+ "category": "quality-check",
105
+ "triggers": ["fix review", "review block", "review fail"],
106
+ "steps": [
107
+ { "cmd": "maestro-plan", "args": "{phase} --gaps", "type": "internal" },
108
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
109
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
110
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 }
111
+ ]
112
+ },
113
+ "brainstorm-driven": {
114
+ "description": "Explore idea then plan and build",
115
+ "category": "explore",
116
+ "triggers": ["brainstorm", "explore idea", "ideate"],
117
+ "steps": [
118
+ { "cmd": "maestro-brainstorm", "args": "\"{intent}\"", "type": "external" },
119
+ { "cmd": "maestro-plan", "args": "{phase}", "type": "internal" },
120
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
121
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
122
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 }
123
+ ]
124
+ },
125
+ "roadmap-driven": {
126
+ "description": "From requirements to roadmap to first phase with gates",
127
+ "category": "lifecycle",
128
+ "triggers": ["roadmap", "from requirements", "start project", "new project"],
129
+ "steps": [
130
+ { "cmd": "maestro-init", "args": "", "type": "internal" },
131
+ { "cmd": "maestro-roadmap", "args": "\"{intent}\"", "type": "internal" },
132
+ { "cmd": "maestro-analyze", "args": "{phase}", "type": "external" },
133
+ { "cmd": "maestro-plan", "args": "{phase}", "type": "internal" },
134
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
135
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
136
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 },
137
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
138
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 }
139
+ ]
140
+ },
141
+ "full-lifecycle": {
142
+ "description": "Complete phase lifecycle with all quality gates (ralph-equivalent)",
143
+ "category": "lifecycle",
144
+ "triggers": ["full lifecycle", "complete phase", "lifecycle", "ralph"],
145
+ "steps": [
146
+ { "cmd": "maestro-analyze", "args": "{phase}", "type": "external" },
147
+ { "cmd": "maestro-plan", "args": "{phase}", "type": "internal" },
148
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
149
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
150
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 },
151
+ { "cmd": "quality-auto-test", "args": "{phase}", "type": "internal" },
152
+ { "cmd": "decision:post-business-test", "args": "", "type": "decision", "decision": "post-business-test", "retry_count": 0, "max_retries": 2 },
153
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
154
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 },
155
+ { "cmd": "quality-auto-test", "args": "{phase}", "type": "internal" },
156
+ { "cmd": "quality-test", "args": "{phase}", "type": "internal" },
157
+ { "cmd": "decision:post-test", "args": "", "type": "decision", "decision": "post-test", "retry_count": 0, "max_retries": 2 },
158
+ { "cmd": "maestro-milestone-audit", "args": "", "type": "internal" },
159
+ { "cmd": "maestro-milestone-complete", "args": "", "type": "internal" },
160
+ { "cmd": "decision:post-milestone", "args": "", "type": "decision", "decision": "post-milestone" }
161
+ ]
162
+ },
163
+ "standard-lifecycle": {
164
+ "description": "Standard phase lifecycle: verify + review + test gates",
165
+ "category": "lifecycle",
166
+ "triggers": ["standard lifecycle", "standard phase", "standard"],
167
+ "steps": [
168
+ { "cmd": "maestro-plan", "args": "{phase}", "type": "internal" },
169
+ { "cmd": "maestro-execute", "args": "{phase}", "type": "external" },
170
+ { "cmd": "maestro-verify", "args": "{phase}", "type": "internal" },
171
+ { "cmd": "decision:post-verify", "args": "", "type": "decision", "decision": "post-verify", "retry_count": 0, "max_retries": 2 },
172
+ { "cmd": "quality-review", "args": "{phase}", "type": "internal" },
173
+ { "cmd": "decision:post-review", "args": "", "type": "decision", "decision": "post-review", "retry_count": 0, "max_retries": 2 },
174
+ { "cmd": "quality-test", "args": "{phase}", "type": "internal" },
175
+ { "cmd": "decision:post-test", "args": "", "type": "decision", "decision": "post-test", "retry_count": 0, "max_retries": 2 },
176
+ { "cmd": "maestro-milestone-audit", "args": "", "type": "internal" }
177
+ ]
178
+ },
179
+ "milestone-close": {
180
+ "description": "Audit and close current milestone",
181
+ "category": "milestone",
182
+ "triggers": ["close milestone", "complete milestone", "milestone done"],
183
+ "steps": [
184
+ { "cmd": "maestro-milestone-audit", "args": "", "type": "internal" },
185
+ { "cmd": "maestro-milestone-complete", "args": "", "type": "internal" },
186
+ { "cmd": "decision:post-milestone", "args": "", "type": "decision", "decision": "post-milestone" }
187
+ ]
188
+ },
189
+ "milestone-release": {
190
+ "description": "Audit and release milestone with version tag",
191
+ "category": "milestone",
192
+ "triggers": ["release", "publish", "tag version", "ship"],
193
+ "steps": [
194
+ { "cmd": "maestro-milestone-audit", "args": "", "type": "internal" },
195
+ { "cmd": "maestro-milestone-release", "args": "", "type": "internal" }
196
+ ]
197
+ },
198
+ "learn-deep": {
199
+ "description": "Deep module understanding: read, decompose, critique",
200
+ "category": "explore",
201
+ "triggers": ["understand", "deep learn", "study", "learn module"],
202
+ "steps": [
203
+ { "cmd": "learn-follow", "args": "\"{intent}\"", "type": "internal" },
204
+ { "cmd": "learn-decompose", "args": "\"{intent}\"", "type": "internal" },
205
+ { "cmd": "learn-second-opinion", "args": "\"{intent}\" --mode challenge", "type": "internal" }
206
+ ]
207
+ }
208
+ },
209
+ "single_commands": {
210
+ "status": "manage-status",
211
+ "init": "maestro-init",
212
+ "analyze": "maestro-analyze",
213
+ "plan": "maestro-plan",
214
+ "execute": "maestro-execute",
215
+ "verify": "maestro-verify",
216
+ "review": "quality-review",
217
+ "test": "quality-test",
218
+ "auto-test": "quality-auto-test",
219
+ "debug": "quality-debug",
220
+ "refactor": "quality-refactor",
221
+ "sync": "quality-sync",
222
+ "retrospective": "quality-retrospective",
223
+ "issue": "manage-issue",
224
+ "discover-issues": "manage-issue-discover",
225
+ "harvest": "manage-harvest",
226
+ "knowhow": "manage-knowhow",
227
+ "knowhow-capture": "manage-knowhow-capture",
228
+ "spec-add": "spec-add",
229
+ "spec-load": "spec-load",
230
+ "spec-remove": "spec-remove",
231
+ "spec-setup": "spec-setup",
232
+ "wiki": "manage-wiki",
233
+ "wiki-connect": "wiki-connect",
234
+ "wiki-digest": "wiki-digest",
235
+ "brainstorm": "maestro-brainstorm",
236
+ "roadmap": "maestro-roadmap",
237
+ "fork": "maestro-fork",
238
+ "merge": "maestro-merge",
239
+ "quick": "maestro-quick",
240
+ "learn-follow": "learn-follow",
241
+ "learn-investigate": "learn-investigate",
242
+ "learn-decompose": "learn-decompose",
243
+ "learn-retro": "learn-retro",
244
+ "learn-second-opinion": "learn-second-opinion",
245
+ "amend": "maestro-amend",
246
+ "compose": "maestro-composer",
247
+ "play": "maestro-player",
248
+ "update": "maestro-update",
249
+ "ui-design": "maestro-ui-design",
250
+ "milestone-audit": "maestro-milestone-audit",
251
+ "milestone-complete": "maestro-milestone-complete",
252
+ "milestone-release": "maestro-milestone-release",
253
+ "codebase-rebuild": "manage-codebase-rebuild",
254
+ "codebase-refresh": "manage-codebase-refresh"
255
+ }
256
+ }
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: learn-decompose
3
+ description: Decompose code into cataloged design patterns, saving findings to specs and wiki
4
+ argument-hint: "<path|module> [--patterns <list>] [--save-spec] [--save-wiki]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+ <purpose>
15
+ Systematic pattern extraction from code. Analyzes a module or directory across 4 dimensions (structural, behavioral, data, error) using parallel agents, then catalogs findings with code anchors. Discovered patterns can be persisted to specs (via `spec-add`) and wiki (via `maestro wiki create`).
16
+
17
+ Unlike `learn-follow` which reads code with forcing questions, this command is purpose-built for pattern identification and cataloging. It produces a reusable pattern catalog that feeds into the spec system.
18
+ </purpose>
19
+
20
+ <context>
21
+ Arguments: $ARGUMENTS
22
+
23
+ **Target resolution:**
24
+ - File path → analyze that file
25
+ - Directory path → analyze all source files in it
26
+ - Module name → Glob for matching directory under `src/`
27
+
28
+ **Flags:**
29
+ - `--patterns <list>` — Comma-separated pattern names to look for (e.g., "observer,factory,middleware"). If omitted, detect all.
30
+ - `--save-spec` — Invoke `Skill({ skill: "maestro-flow", args: "--cmd spec-add" })` for each newly discovered pattern
31
+ - `--save-wiki` — Create wiki note entries per pattern group via `maestro wiki create --type note`
32
+
33
+ **Storage written:**
34
+ - `.workflow/learning/decompose-{slug}-{YYYY-MM-DD}.md` — Pattern decomposition report
35
+ - `.workflow/learning/lessons.jsonl` — One insight per discovered pattern (source: "decompose")
36
+ - `.workflow/learning/learning-index.json` — Updated index
37
+ - If `--save-spec`: entries appended to `.workflow/specs/coding-conventions.md`
38
+ - If `--save-wiki`: new wiki note entries
39
+
40
+ **Storage read:**
41
+ - Source files at target path
42
+ - `.workflow/specs/coding-conventions.md` — Existing documented patterns (for dedup)
43
+ - `.workflow/learning/lessons.jsonl` — Previously identified patterns (for dedup)
44
+ </context>
45
+
46
+ <execution>
47
+
48
+ ### Stage 1: Resolve Target
49
+ - If argument is a file: verify exists, use as single-file target
50
+ - If argument is a directory: list all `.ts`, `.tsx`, `.js`, `.jsx` files (exclude `node_modules`, `dist`, `.test.`)
51
+ - If argument is a module name: Glob `src/**/{module}*` to find matching directory
52
+ - If target unresolvable, AskUserQuestion with suggestions
53
+
54
+ ### Stage 2: Load Existing Patterns
55
+ - Read `.workflow/specs/coding-conventions.md` — extract documented patterns
56
+ - Search `lessons.jsonl` for entries with `category: "pattern"` — previously discovered
57
+ - Build dedup set: pattern names already known
58
+
59
+ ### Stage 3: Parallel Agent Analysis (4 dimensions)
60
+ Spawn 4 Agents in a single message, each analyzing the target from one dimension:
61
+
62
+ **Agent 1 — Structural Patterns:**
63
+ - Class hierarchy and composition relationships
64
+ - Module boundaries and encapsulation
65
+ - Dependency injection / inversion of control
66
+ - Builder, Factory, Singleton patterns
67
+ - Export structure (barrel files, re-exports)
68
+
69
+ **Agent 2 — Behavioral Patterns:**
70
+ - Event flow (EventEmitter, pub/sub, callbacks)
71
+ - Middleware chains and interceptors
72
+ - Observer/subscriber patterns
73
+ - Command/strategy patterns
74
+ - State machines
75
+
76
+ **Agent 3 — Data Patterns:**
77
+ - Repository / data access patterns
78
+ - DTO / transformation pipelines
79
+ - Caching strategies (memoization, LRU, TTL)
80
+ - Serialization / deserialization
81
+ - Schema validation approaches
82
+
83
+ **Agent 4 — Error Patterns:**
84
+ - Error boundary and propagation
85
+ - Retry / backoff / circuit breaker
86
+ - Fallback chains
87
+ - Validation and guard clauses
88
+ - Logging and observability patterns
89
+
90
+ Each agent returns findings as structured list:
91
+ ```json
92
+ [{
93
+ "name": "pattern name",
94
+ "dimension": "structural|behavioral|data|error",
95
+ "confidence": "high|medium|low",
96
+ "anchors": ["file:line", "file:line"],
97
+ "description": "what it does",
98
+ "rationale": "why this approach",
99
+ "tradeoffs": "what was given up"
100
+ }]
101
+ ```
102
+
103
+ If `--patterns` specified, instruct agents to focus only on named patterns.
104
+
105
+ ### Stage 4: Cross-Reference & Dedup
106
+ - Match agent findings against existing pattern set from Stage 2
107
+ - Mark each finding: `documented` (already in specs), `known` (in lessons), or `new`
108
+ - Flag contradictions: finding conflicts with documented convention
109
+ - Merge duplicate findings across agents (same pattern found by multiple dimensions)
110
+
111
+ ### Stage 5: Produce Pattern Catalog
112
+ Build the decomposition report grouped by dimension:
113
+
114
+ ```markdown
115
+ # Pattern Decomposition: {target}
116
+
117
+ ## Summary
118
+ - Patterns found: N (M new, K documented, J known)
119
+ - Dimensions analyzed: structural, behavioral, data, error
120
+ - Contradictions: N
121
+
122
+ ## Structural Patterns
123
+ | Pattern | Confidence | Location | Status |
124
+ |---------|-----------|----------|--------|
125
+ | {name} | high | {file:line} | new / documented / known |
126
+
127
+ ### {Pattern Name}
128
+ **Description:** ...
129
+ **Code example:** (inline snippet from anchor)
130
+ **Trade-offs:** ...
131
+
132
+ ## Behavioral Patterns
133
+ ...
134
+ ```
135
+
136
+ ### Stage 6: Persist
137
+ 1. Write `.workflow/learning/decompose-{slug}-{date}.md`
138
+ 2. Append each **new** pattern to `lessons.jsonl`:
139
+ - `source: "decompose"`, `category: "pattern"`, `confidence: <level>`
140
+ - Tags: `["decompose", "{dimension}", "{target-slug}"]`
141
+ - Stable INS-id from `hash("decompose" + target + pattern_name)`
142
+ 3. Update `learning-index.json`
143
+ 4. If `--save-spec`: for each new pattern, invoke `Skill({ skill: "maestro-flow", args: "--cmd spec-add pattern {description}" })`
144
+ 5. If `--save-wiki`: create wiki note per dimension group via `maestro wiki create --type note --slug decompose-{dimension}-{slug}`
145
+ 6. Display summary with counts and next steps
146
+
147
+ **Next-step routing:**
148
+ - Follow-along on a specific pattern → `/learn-follow <anchor-file>`
149
+ - Get second opinion on findings → `/learn-second-opinion <target>`
150
+ - Add all new patterns to specs → `/spec-add coding ...` per pattern
151
+ </execution>
152
+
153
+ <error_codes>
154
+ | Code | Severity | Condition | Recovery |
155
+ |------|----------|-----------|----------|
156
+ | E001 | error | Target path not found | Check path exists, or use a module name |
157
+ | E002 | error | No source files found in target directory | Check target has .ts/.js files, exclude filters may be too aggressive |
158
+ | W001 | warning | One or more dimension agents failed — partial results | Proceed with available dimensions, retry failed ones |
159
+ | W002 | warning | coding-conventions.md not found — skipping dedup against specs | All patterns marked as "new" |
160
+ | W003 | warning | Large target (>50 files) — analysis may be slow | Consider narrowing scope with --patterns filter |
161
+ </error_codes>
162
+
163
+ <success_criteria>
164
+ - [ ] Target resolved to concrete file list
165
+ - [ ] Existing patterns loaded for dedup
166
+ - [ ] All 4 dimension agents spawned in parallel
167
+ - [ ] Each finding has: name, dimension, confidence, anchors, description, tradeoffs
168
+ - [ ] Cross-reference performed (documented / known / new status assigned)
169
+ - [ ] Pattern catalog written to `decompose-{slug}-{date}.md`
170
+ - [ ] New patterns appended to `lessons.jsonl` with stable INS-ids
171
+ - [ ] `learning-index.json` updated
172
+ - [ ] If --save-spec: spec entries created for new patterns
173
+ - [ ] If --save-wiki: wiki notes created per dimension group
174
+ - [ ] No files modified outside `.workflow/learning/` (and optionally specs/wiki)
175
+ - [ ] Summary displayed with pattern counts and next-step routing
176
+ </success_criteria>