maestro-flow-one 0.2.1 → 0.2.3

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 (28) hide show
  1. package/maestro-flow/commands/learn/decompose.md +10 -15
  2. package/maestro-flow/commands/learn/follow.md +11 -16
  3. package/maestro-flow/commands/learn/investigate.md +18 -22
  4. package/maestro-flow/commands/learn/retro.md +23 -26
  5. package/maestro-flow/commands/learn/second-opinion.md +11 -16
  6. package/maestro-flow/commands/lifecycle/analyze.md +8 -0
  7. package/maestro-flow/commands/lifecycle/brainstorm.md +8 -0
  8. package/maestro-flow/commands/lifecycle/collab.md +333 -0
  9. package/maestro-flow/commands/lifecycle/execute.md +11 -3
  10. package/maestro-flow/commands/lifecycle/learn.md +4 -4
  11. package/maestro-flow/commands/lifecycle/plan.md +8 -0
  12. package/maestro-flow/commands/lifecycle/tools-execute.md +117 -0
  13. package/maestro-flow/commands/lifecycle/tools-register.md +137 -0
  14. package/maestro-flow/commands/lifecycle/ui-codify.md +67 -0
  15. package/maestro-flow/commands/manage/harvest.md +1 -1
  16. package/maestro-flow/commands/manage/learn.md +5 -7
  17. package/maestro-flow/commands/manage/wiki.md +1 -1
  18. package/maestro-flow/commands/milestone/complete.md +6 -6
  19. package/maestro-flow/commands/quality/auto-test.md +1 -1
  20. package/maestro-flow/commands/quality/debug.md +8 -0
  21. package/maestro-flow/commands/quality/retrospective.md +4 -5
  22. package/maestro-flow/commands/quality/review.md +8 -0
  23. package/maestro-flow/commands/spec/add.md +25 -4
  24. package/maestro-flow/commands/spec/load.md +26 -6
  25. package/maestro-flow/commands/spec/setup.md +2 -2
  26. package/maestro-flow/commands/wiki/connect.md +1 -1
  27. package/maestro-flow/commands/wiki/digest.md +5 -6
  28. package/package.json +1 -1
@@ -0,0 +1,333 @@
1
+ ---
2
+ name: maestro-collab
3
+ description: Multi-CLI collaborative analysis -- fan-out to multiple CLI tools, cross-verify, synthesize
4
+ argument-hint: "\"<requirement>\" [--tools gemini,qwen,claude] [--mode analysis|write] [--rule <template>] [-y]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Agent
12
+ - AskUserQuestion
13
+ ---
14
+
15
+ <purpose>
16
+ Multi-CLI collaboration: fan-out the same requirement to multiple CLI tools in parallel, cross-verify outputs for consensus/conflicts, then synthesize into a unified report with standard downstream artifacts (context.md + conclusions.json).
17
+
18
+ Each CLI tool independently analyzes the requirement. Results are compared and merged via evidence-weighted synthesis.
19
+ </purpose>
20
+
21
+ <context>
22
+ $ARGUMENTS — requirement text and optional flags.
23
+
24
+ ```bash
25
+ /maestro-collab "analyze the auth module for security vulnerabilities"
26
+ /maestro-collab "design a caching strategy" --tools gemini,qwen,claude
27
+ /maestro-collab -y "review error handling patterns"
28
+ /maestro-collab "refactor user service" --mode write --tools gemini,claude
29
+ ```
30
+
31
+ **Flags**:
32
+ - `--tools <list>`: Comma-separated CLI tools (default: auto-select first 3 enabled)
33
+ - `--mode analysis|write`: Delegate mode (default: analysis)
34
+ - `--rule <template>`: Shared rule template for all delegates
35
+ - `-y` / `--yes`: Skip plan confirmation
36
+
37
+ **Output**: `.workflow/scratch/{YYYYMMDD}-collab-{slug}/`
38
+ - `collab-report.md` — full collaboration report
39
+ - `context.md` — standard Locked/Free/Deferred decisions (plan/analyze compatible)
40
+ - `conclusions.json` — structured conclusions (plan fast-track compatible)
41
+ - `per-tool/{tool}-output.md` — raw per-tool outputs
42
+ </context>
43
+
44
+ <execution>
45
+
46
+ ### Step 1: Parse Arguments
47
+
48
+ Extract from `$ARGUMENTS`:
49
+ - `requirement` — remaining text after flag removal (error if empty)
50
+ - `--tools` → `selectedTools` (comma-split)
51
+ - `--mode` → `delegateMode` (default: `analysis`)
52
+ - `--rule` → `ruleTemplate`
53
+ - `-y` / `--yes` → `autoYes`
54
+
55
+ ### Step 2: Discover Available CLI Tools
56
+
57
+ ```bash
58
+ Bash("maestro tools list --json 2>/dev/null || cat ~/.maestro/cli-tools.json")
59
+ ```
60
+
61
+ Parse tool entries. Build eligible list:
62
+ - `enabled == true`
63
+ - If `--mode write`: exclude `type == "api-endpoint"`
64
+
65
+ Auto-select (when `--tools` omitted): first 3 eligible in config order.
66
+ Validate: minimum 2 eligible tools (abort if fewer).
67
+
68
+ ### Step 3: Present Collaboration Plan
69
+
70
+ **(Skip if `-y`)**
71
+
72
+ Display plan, then ask user:
73
+
74
+ ```
75
+ ============================================================
76
+ COLLABORATION PLAN
77
+ ============================================================
78
+ Requirement: {requirement}
79
+ Mode: {delegateMode}
80
+ Rule: {ruleTemplate || "none"}
81
+
82
+ Available CLI Tools (from cli-tools.json):
83
+ [✓] gemini — gemini-3.1-pro-preview [fullstack, frontend]
84
+ [✓] claude — claude-sonnet-4-6 [fullstack]
85
+ [✓] codex — gpt-5.5 [fullstack, backend]
86
+ [ ] opencode — (no model) [fullstack]
87
+
88
+ Selected: gemini, claude, codex (3 tools)
89
+
90
+ Pipeline:
91
+ 1. Fan-out → parallel delegate to each tool
92
+ 2. Cross-verification → consensus/conflict analysis
93
+ 3. Synthesis → context.md + conclusions.json
94
+ ============================================================
95
+ ```
96
+
97
+ Use `AskUserQuestion` with options:
98
+ - **执行** — proceed with selected tools
99
+ - **修改工具选择** — let user specify different tool combination
100
+ - **取消** — abort
101
+
102
+ If **修改工具选择**: ask user which tools to use (show eligible list), validate ≥ 2, re-display plan.
103
+
104
+ ### Step 4: Setup Session
105
+
106
+ ```
107
+ slug = requirement kebab-cased, max 40 chars
108
+ outputDir = .workflow/scratch/{YYYYMMDD}-collab-{slug}/
109
+ ```
110
+
111
+ Create `outputDir` + `outputDir/per-tool/`.
112
+
113
+ ### Step 5: Build Delegate Prompt
114
+
115
+ Shared prompt for all tools:
116
+
117
+ ```
118
+ PURPOSE: {requirement}; success = actionable findings with evidence
119
+ TASK: {auto-decomposed into 3-5 specific verbs}
120
+ MODE: {delegateMode}
121
+ CONTEXT: @**/*
122
+ EXPECTED: Structured findings with file:line references, confidence score (0-100), prioritized recommendations. Sections: ## Findings, ## Recommendations, ## Confidence
123
+ CONSTRAINTS: {extracted from requirement}
124
+ ```
125
+
126
+ ### Step 6: Parallel Fan-Out
127
+
128
+ Launch ALL delegate calls simultaneously using multiple `Bash(run_in_background: true)` in a **single message**:
129
+
130
+ ```
131
+ // Launch all in ONE message — do NOT wait between calls
132
+ Bash({
133
+ command: `maestro delegate "${prompt}" --to gemini --mode ${mode} ${rule}`,
134
+ run_in_background: true
135
+ })
136
+ Bash({
137
+ command: `maestro delegate "${prompt}" --to claude --mode ${mode} ${rule}`,
138
+ run_in_background: true
139
+ })
140
+ Bash({
141
+ command: `maestro delegate "${prompt}" --to codex --mode ${mode} ${rule}`,
142
+ run_in_background: true
143
+ })
144
+ ```
145
+
146
+ **After launching all calls → STOP immediately. Do not output anything. Wait for background completion callbacks.**
147
+
148
+ ### Step 7: Collect Results
149
+
150
+ As each background callback arrives:
151
+ 1. Extract exec ID from output (`[MAESTRO_EXEC_ID=...]`)
152
+ 2. Run `maestro delegate output <id>` to get full result
153
+ 3. Write raw output to `per-tool/{tool}-output.md`
154
+
155
+ **Wait until ALL callbacks have arrived before proceeding.**
156
+
157
+ ### Step 8: Cross-Verify
158
+
159
+ Read all `per-tool/{tool}-output.md` files. Compare findings across tools:
160
+
161
+ For each finding, classify:
162
+ - **[CONSENSUS]**: 2+ tools agree on same finding/recommendation
163
+ - **[CONFLICT]**: Tools disagree on approach or assessment
164
+ - **[UNIQUE]**: Finding from only one tool
165
+
166
+ Compute `consensus_level = (consensus_count / total_findings) * 100`.
167
+
168
+ ### Step 9: Synthesize Outputs
169
+
170
+ Resolve conflicts via evidence-weighted voting:
171
+ - Higher confidence tool's position wins
172
+ - More specific evidence (file:line refs) wins over general statements
173
+ - If tied: mark as `[SUGGESTED]`
174
+
175
+ Generate three output files:
176
+
177
+ #### collab-report.md
178
+
179
+ ```markdown
180
+ # Multi-CLI Collaboration Report — {requirement}
181
+
182
+ ## Summary
183
+ - Tools: {tool_list}
184
+ - Consensus level: {N}%
185
+ - Key finding: {top finding}
186
+
187
+ ## Consensus Findings
188
+ {findings agreed by 2+ tools}
189
+
190
+ ## Resolved Conflicts
191
+ {conflicts resolved with rationale and winning tool}
192
+
193
+ ## Unresolved Items
194
+ {items requiring human judgment}
195
+
196
+ ## Unique Insights
197
+ {valuable unique findings with source tool attribution}
198
+
199
+ ## Recommendations
200
+ {prioritized, merged recommendations}
201
+
202
+ ## Per-Tool Confidence
203
+ | Tool | Confidence | Key Strength |
204
+ |------|-----------|--------------|
205
+ ```
206
+
207
+ #### context.md (standard downstream format)
208
+
209
+ ```markdown
210
+ # Context: {requirement}
211
+
212
+ **Date**: {date}
213
+ **Mode**: collab ({tool_list})
214
+ **Consensus Level**: {N}%
215
+
216
+ ## Decisions
217
+
218
+ ### Decision N: {TITLE}
219
+ - **Context**: {what and why}
220
+ - **Options**: 1. {opt1} 2. {opt2}
221
+ - **Chosen**: {selected}
222
+ - **Reason**: {rationale — which tools agreed/disagreed}
223
+
224
+ ## Constraints
225
+
226
+ ### Locked
227
+ {[CONSENSUS] items — treat as confirmed decisions}
228
+
229
+ ### Free
230
+ {[UNIQUE] items with strong evidence — implementer discretion}
231
+
232
+ ### Deferred
233
+ {[UNRESOLVED] conflicts — require human judgment}
234
+
235
+ ## Code Context
236
+ {file:line references from per-tool findings}
237
+ ```
238
+
239
+ #### conclusions.json
240
+
241
+ ```json
242
+ {
243
+ "session_id": "{sessionId}",
244
+ "subject": "{requirement}",
245
+ "mode": "collab",
246
+ "tools": ["gemini", "claude", "codex"],
247
+ "consensus_level": 85,
248
+ "recommendation": "Go|No-Go|Conditional",
249
+ "confidence": "high|medium|low",
250
+ "dimensions": [
251
+ { "name": "gemini", "score": 80, "findings": "...", "recommendations": "..." }
252
+ ],
253
+ "decisions": [
254
+ { "title": "...", "classification": "locked|free|deferred", "source_tools": [], "rationale": "..." }
255
+ ],
256
+ "timestamp": "<ISO>"
257
+ }
258
+ ```
259
+
260
+ ### Step 10: Register Artifact
261
+
262
+ Append to `.workflow/state.json`:
263
+
264
+ ```json
265
+ {
266
+ "id": "CLB-{next_id}",
267
+ "type": "collab",
268
+ "milestone": "{current_milestone}",
269
+ "phase": null,
270
+ "scope": "adhoc",
271
+ "path": "scratch/{YYYYMMDD}-collab-{slug}",
272
+ "status": "completed",
273
+ "depends_on": null,
274
+ "harvested": false,
275
+ "created_at": "<ISO>",
276
+ "completed_at": "<ISO>"
277
+ }
278
+ ```
279
+
280
+ ### Step 11: Display Summary
281
+
282
+ ```
283
+ ============================================================
284
+ MULTI-CLI COLLABORATION COMPLETE
285
+ ============================================================
286
+ Requirement: {requirement}
287
+ Tools: {tool_list}
288
+ Consensus Level: {N}%
289
+
290
+ Per-Tool:
291
+ gemini: completed (confidence: {N}%)
292
+ claude: completed (confidence: {N}%)
293
+ codex: completed (confidence: {N}%)
294
+
295
+ Artifact: CLB-{id}
296
+ Output: {outputDir}/
297
+
298
+ Next steps:
299
+ /maestro-analyze "{topic}" — Deep feasibility analysis
300
+ /maestro-plan "{phase} --dir {dir}" — Plan from collab conclusions
301
+ /maestro-brainstorm "{topic}" — Expand with multi-role brainstorm
302
+ ============================================================
303
+ ```
304
+
305
+ </execution>
306
+
307
+ <error_codes>
308
+
309
+ | Code | Severity | Condition | Recovery |
310
+ |------|----------|-----------|----------|
311
+ | E001 | error | Requirement argument missing | Prompt for requirement |
312
+ | E002 | error | Fewer than 2 CLI tools eligible | Check cli-tools.json, enable more tools |
313
+ | E003 | error | Specified tool not found/enabled | Show available tools |
314
+ | E004 | error | All delegates failed | Abort with per-tool error details |
315
+ | W001 | warning | One tool failed | Continue with remaining tools |
316
+ | W002 | warning | >50% conflicts in cross-verify | Highlight in report, recommend manual review |
317
+ | W003 | warning | Low consensus level (<40%) | Flag in summary |
318
+
319
+ </error_codes>
320
+
321
+ <success_criteria>
322
+ - [ ] Available tools discovered from cli-tools.json with eligibility filtering
323
+ - [ ] Plan presented via AskUserQuestion with tool modification option (unless -y)
324
+ - [ ] All delegates launched in parallel via Bash(run_in_background: true)
325
+ - [ ] Execution stopped after launch — waited for all callbacks
326
+ - [ ] Per-tool outputs written to per-tool/{tool}-output.md
327
+ - [ ] Cross-verification: consensus/conflict/unique classification complete
328
+ - [ ] collab-report.md produced with merged findings
329
+ - [ ] context.md produced in Locked/Free/Deferred format (downstream compatible)
330
+ - [ ] conclusions.json produced (plan fast-track compatible)
331
+ - [ ] CLB artifact registered in state.json
332
+ - [ ] Partial degradation: continued if 1+ tools succeeded
333
+ </success_criteria>
@@ -30,13 +30,21 @@ Invoked after /maestro-plan produces a confirmed plan. When called without args
30
30
  <context>
31
31
  $ARGUMENTS — phase number, or no args for milestone-wide execution, with optional flags.
32
32
 
33
- Scope routing, flags, resolution logic, output directory format, artifact registration schema, and incremental learning extraction are defined in workflow `execute.md`.
33
+ Scope routing, flags, resolution logic, output directory format, artifact registration schema, and incremental knowhow extraction are defined in workflow `execute.md`.
34
34
 
35
35
  ### Pre-load context (before task execution)
36
36
 
37
37
  1. **Codebase docs**: If `.workflow/codebase/doc-index.json` exists, read `ARCHITECTURE.md` for module boundaries. Pass as shared context to executor agents.
38
38
  2. **Wiki knowledge**: Run `maestro wiki search "<phase keywords>" --json 2>/dev/null`. If results found, extract top 5 entries as prior knowledge context for agents.
39
39
  3. Both are optional — proceed without if unavailable (log warning).
40
+
41
+ ### Role Knowledge
42
+ 1. Browse accumulated knowledge for this role:
43
+ `maestro wiki list --role implement`
44
+ 2. Analyze the index, identify entries relevant to the current task
45
+ 3. Load selected documents:
46
+ `maestro wiki load <id1> [id2] [id3...]`
47
+ 4. Review loaded knowledge before proceeding
40
48
  </context>
41
49
 
42
50
  <execution>
@@ -61,7 +69,7 @@ After each task completes, evaluate inquiry triggers:
61
69
  → Ask: "TASK-{NNN} succeeded after {N} retries. Should this fix pattern be documented? (`/spec-add debug`)"
62
70
 
63
71
  3. **Implicit knowledge**: If task summary contains design rationale ("chose X because", "rejected Y due to"):
64
- → Ask: "Design decision detected. Should it be recorded as a learning? (`/spec-add learning`)"
72
+ → Ask: "Design decision detected. Should it be recorded as knowhow? (`/spec-add learning`)"
65
73
 
66
74
  If user confirms, invoke `Skill({ skill: "spec-add", args: "<category> <content>" })` with extracted content.
67
75
 
@@ -115,6 +123,6 @@ If failed tasks exist, suggest /quality-debug for investigation.
115
123
  - [ ] `.summaries/TASK-{NNN}-summary.md` written for each completed task
116
124
  - [ ] `.task/TASK-{NNN}.json` statuses updated (completed|blocked)
117
125
  - [ ] EXC artifact registered in state.json for each plan executed
118
- - [ ] Incremental learnings extracted to specs/learnings.md
126
+ - [ ] Incremental knowhow extracted to specs/learnings.md
119
127
  - [ ] state.json updated with execution progress
120
128
  </success_criteria>
@@ -46,8 +46,8 @@ $ARGUMENTS — user learning intent text, or flags.
46
46
  | `pattern-catalog` | decompose --save-spec --save-wiki → second-opinion --mode review | Full pattern extraction + review |
47
47
 
48
48
  **Storage:**
49
- - `.workflow/learning/.maestro-learn/{session_id}/status.json` — Session tracking
50
- - All learn command outputs go to `.workflow/learning/`
49
+ - `.workflow/knowhow/.maestro-learn/{session_id}/status.json` — Session tracking
50
+ - All learn command outputs go to `.workflow/knowhow/`
51
51
  </context>
52
52
 
53
53
  <execution>
@@ -108,7 +108,7 @@ pattern-catalog → [learn-decompose --save-spec --save-wiki, learn-second-opini
108
108
  **If not `-y`:** show plan, ask for confirmation.
109
109
 
110
110
  **Execute:**
111
- 1. Create session dir: `.workflow/learning/.maestro-learn/learn-{timestamp}/`
111
+ 1. Create session dir: `.workflow/knowhow/.maestro-learn/learn-{timestamp}/`
112
112
  2. Write `status.json` with chain steps
113
113
  3. Execute each step via `Skill()`:
114
114
  - On success: mark completed, continue
@@ -136,5 +136,5 @@ pattern-catalog → [learn-decompose --save-spec --save-wiki, learn-second-opini
136
136
  - [ ] All chain steps executed via Skill()
137
137
  - [ ] Error handling: retry/skip/abort per step
138
138
  - [ ] Session summary displayed with next-step routing
139
- - [ ] No files modified outside `.workflow/learning/`
139
+ - [ ] No files modified outside `.workflow/knowhow/`
140
140
  </success_criteria>
@@ -45,6 +45,14 @@ Scope routing, base flags (`--collab`, `--spec`, `-y`, `--gaps`, `--dir`), outpu
45
45
  **Upstream context:**
46
46
  - Reads `context.md` from prior analyze artifact (auto-discovered from state.json or via --dir)
47
47
  - Reads `conclusions.json` if available (implementation_scope seeds task generation)
48
+
49
+ ### Role Knowledge
50
+ 1. Browse accumulated knowledge for this role:
51
+ `maestro wiki list --role plan`
52
+ 2. Analyze the index, identify entries relevant to the current task
53
+ 3. Load selected documents:
54
+ `maestro wiki load <id1> [id2] [id3...]`
55
+ 4. Review loaded knowledge before proceeding
48
56
  </context>
49
57
 
50
58
  <execution>
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: maestro-tools-execute
3
+ description: Load and execute tool specs by role or name
4
+ argument-hint: "[tool-name | --role <role>]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - AskUserQuestion
13
+ - Agent
14
+ ---
15
+ <purpose>
16
+ Load registered tool specs and execute them step-by-step. Two invocation modes:
17
+
18
+ 1. **Direct** — Specify tool name, load full steps, execute sequentially
19
+ 2. **Role-based** — List available tools for a role, user selects, then execute
20
+
21
+ Execution follows the tool definition steps in order, reporting progress per step and asking user on blockers.
22
+ </purpose>
23
+
24
+ <required_reading>
25
+ @~/.maestro/workflows/tools-spec.md
26
+ </required_reading>
27
+
28
+ <context>
29
+ $ARGUMENTS — Tool name, keyword, or --role filter
30
+
31
+ **Examples**:
32
+ ```
33
+ /maestro-tools-execute integration-test
34
+ /maestro-tools-execute --role implement
35
+ /maestro-tools-execute --role review --keyword api
36
+ /maestro-tools-execute
37
+ ```
38
+
39
+ Empty arguments enters interactive mode: list all tools for user selection.
40
+ </context>
41
+
42
+ <execution>
43
+
44
+ ### Step 1: Load Tool
45
+
46
+ **By name**:
47
+ ```bash
48
+ maestro spec load --role implement --keyword <name>
49
+ ```
50
+ Match entries in tools.md whose title or keywords contain the name.
51
+
52
+ **By role**:
53
+ ```bash
54
+ maestro spec load --role <role>
55
+ ```
56
+ Extract tools.md entries from output, list available tools.
57
+
58
+ **Empty args**:
59
+ Load all tools.md entries, present to user with AskUserQuestion for selection.
60
+
61
+ ### Step 2: Display Tool
62
+
63
+ Show tool information:
64
+ - Name, roles, keywords
65
+ - Steps overview (for ref entries, expand knowhow detail first)
66
+
67
+ Expand ref entries:
68
+ ```bash
69
+ maestro wiki load <knowhow-id>
70
+ ```
71
+
72
+ ### Step 3: Confirm Execution
73
+
74
+ Ask user:
75
+ - Execute steps as-is?
76
+ - Adjust parameters/scope?
77
+ - View only, do not execute?
78
+
79
+ ### Step 4: Step-by-Step Execution
80
+
81
+ Follow the tool definition steps in order:
82
+ 1. Read current step description
83
+ 2. Execute step action (file ops, commands, code changes, etc.)
84
+ 3. Verify step completion
85
+ 4. Report progress: `[Step N/M] done — <step_name>`
86
+ 5. Proceed to next step
87
+
88
+ **Blocker handling**:
89
+ - Step fails → report error, ask user: retry / skip / abort
90
+ - Needs user input → AskUserQuestion for parameters
91
+ - Prerequisites unmet → show missing items, ask how to proceed
92
+
93
+ ### Step 5: Report Results
94
+
95
+ After completion, output:
96
+ - Completed steps list
97
+ - Skipped/failed steps (if any)
98
+ - Artifacts produced (generated files, test results, etc.)
99
+ - Suggested next actions
100
+
101
+ </execution>
102
+
103
+ <error_codes>
104
+ | Code | Severity | Description |
105
+ |------|----------|-------------|
106
+ | E001 | fatal | No matching tool found — check name/keyword |
107
+ | E002 | warning | Multiple tools match — list options for user selection |
108
+ | E003 | warning | Step execution failed — ask user how to proceed |
109
+ </error_codes>
110
+
111
+ <success_criteria>
112
+ - [ ] Tool correctly loaded (ref expanded if applicable)
113
+ - [ ] User confirmed before execution starts
114
+ - [ ] Each step has progress feedback
115
+ - [ ] Blockers handled interactively
116
+ - [ ] Results reported clearly
117
+ </success_criteria>
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: maestro-tools-register
3
+ description: Register tool specs - extract, generate, or optimize
4
+ argument-hint: "[description]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - AskUserQuestion
13
+ - Agent
14
+ ---
15
+ <purpose>
16
+ Codify reusable business processes as tool specs into `.workflow/specs/tools.md`. Once registered, entries are auto-discovered by downstream agents via `spec load --role` and spec-injector — plan agents pick up design/architecture flows, test agents pick up verification methods, implement agents pick up execution steps.
17
+
18
+ When to register: during planning to standardize a business process (e.g. payment reconciliation, OAuth integration steps); after execution to capture a validated procedure (e.g. database migration rollback); before testing to register verification methods for test agents (e.g. E2E checkout flow, API idempotency verification); during retrospective/harvest to extract reusable process knowledge from artifacts.
19
+
20
+ Three modes: Extract (from code/docs), Generate (from description), Optimize (improve existing).
21
+ Short processes (<10 steps) inline; long processes (>=10 steps) use ref mode with knowhow detail doc.
22
+ </purpose>
23
+
24
+ <required_reading>
25
+ @~/.maestro/workflows/tools-spec.md
26
+ </required_reading>
27
+
28
+ <context>
29
+ $ARGUMENTS — Intent description
30
+
31
+ **Examples**:
32
+ ```
33
+ /maestro-tools-register extract OAuth PKCE token exchange flow from src/auth/
34
+ /maestro-tools-register generate Stripe webhook idempotency verification --roles implement,test
35
+ /maestro-tools-register generate E2E checkout flow with payment gateway mock setup --roles test
36
+ /maestro-tools-register optimize e2e-checkout tool
37
+ ```
38
+ </context>
39
+
40
+ <execution>
41
+
42
+ ### Step 1: Intent Detection
43
+
44
+ Parse $ARGUMENTS to determine mode:
45
+ - Contains "extract" → extract mode
46
+ - Contains "optimize/improve" → optimize mode
47
+ - Other → generate mode
48
+ - Empty → ask user with AskUserQuestion
49
+
50
+ ### Step 2: Gather Information
51
+
52
+ **Extract mode**:
53
+ - Identify source (current conversation, specified files, codebase scan)
54
+ - Extract step sequence, prerequisites, expected outputs
55
+
56
+ **Generate mode**:
57
+ - Confirm tool name, applicable roles, target scenario
58
+ - If unclear, ask user with AskUserQuestion
59
+
60
+ **Optimize mode**:
61
+ - Load existing tool: `maestro spec load --role implement --keyword <name>`
62
+ - Analyze improvement points (step splitting, prerequisites, error handling)
63
+
64
+ **For all modes** — identify the usage timing: when should an agent or user invoke this tool? This becomes the first line of the entry description (see Step 5).
65
+
66
+ ### Step 3: Determine Roles
67
+
68
+ Infer applicable roles from context, or ask user:
69
+ - implement — execution tools (build, deploy, integrate)
70
+ - test — testing tools (test flows, verification steps)
71
+ - review — review tools (checklists, audit standards)
72
+ - plan — planning tools (design flows, analysis steps)
73
+ - analyze — analysis tools (diagnostic flows, investigation steps)
74
+
75
+ ### Step 4: Decide Inline vs Ref
76
+
77
+ - Steps <10 and no code blocks → **inline mode**
78
+ - Steps >=10 or contains code examples/config → **ref mode**
79
+
80
+ ### Step 5: Write
81
+
82
+ **Description format**: First line after `### Title` must state **when to use** this tool (the usage timing from Step 2). This is critical for ref entries — `spec load` only shows the first 200 chars after the heading as the summary.
83
+
84
+ ```
85
+ ### {Title}
86
+
87
+ Use when {timing/trigger condition}.
88
+
89
+ 1. Step one ...
90
+ ```
91
+
92
+ **Inline mode**:
93
+ ```bash
94
+ maestro spec add tools "<title>" "Use when <timing>.\n\n1. <step1>\n2. <step2>" --roles "<csv>" --keywords "<csv>"
95
+ ```
96
+
97
+ **Ref mode**:
98
+ 1. Generate knowhow detail document (RCP- or DOC- prefix). YAML frontmatter must include `summary` with usage timing — this is what `wiki list` and wiki-role-loader show to agents:
99
+ ```yaml
100
+ ---
101
+ title: <Title>
102
+ type: recipe
103
+ summary: "Use when <timing>. <scope description>"
104
+ tags: [<keywords>]
105
+ roles: [<roles>]
106
+ ---
107
+ ```
108
+ 2. Register spec index entry — description must also include usage timing within 200 chars (this is what `spec load` shows):
109
+ ```bash
110
+ maestro spec add tools "<title>" "Use when <timing>. <scope summary>" --roles "<csv>" --keywords "<csv>" \
111
+ --ref "knowhow/RCP-<slug>.md" --knowhow-type recipe
112
+ ```
113
+
114
+ ### Step 6: Verify
115
+
116
+ - `maestro spec load --role <role> --keyword <keyword>` to confirm loadable
117
+ - Display result: title, roles, keywords, storage location
118
+
119
+ </execution>
120
+
121
+ <error_codes>
122
+ | Code | Severity | Description |
123
+ |------|----------|-------------|
124
+ | E001 | fatal | `.workflow/specs/` does not exist — run `maestro spec init` |
125
+ | E002 | warning | Duplicate tool name detected — confirm overwrite/optimize |
126
+ | E003 | fatal | roles parameter empty — tools must declare applicable roles |
127
+ </error_codes>
128
+
129
+ <success_criteria>
130
+ - [ ] Tool definition written to tools.md (or ref to knowhow)
131
+ - [ ] roles attribute correctly set
132
+ - [ ] keywords auto-extracted (3-5 terms)
133
+ - [ ] Description starts with "Use when ..." (usage timing)
134
+ - [ ] Loadable via `spec load --role <role>`
135
+ - [ ] Long processes use ref mode with knowhow file created
136
+ - [ ] Ref knowhow YAML includes `summary` with usage timing
137
+ </success_criteria>