pi-maestro-flow 0.2.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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: maestro-roadmap
3
+ description: "Generate roadmap with milestone/phase structure from requirements or upstream context Arguments: <requirement> [-y] [-c] [-m progressive|direct|auto] [--from <source>] [--from-brainstorm SESSION-ID] [--revise [instructions]] [--review]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Generate milestone/phase roadmap from requirements or upstream context. Three modes: create (default), revise (`--revise`), review (`--review`). For formal spec documents, use `/maestro-blueprint`.
9
+
10
+ Pipeline: brainstorm/blueprint/analyze → **roadmap** → analyze {milestone} → plan {milestone} → execute.
11
+ </purpose>
12
+
13
+ <required_reading>
14
+ @~/.maestro/workflows/roadmap-common.md
15
+ @~/.maestro/templates/roadmap.md
16
+ </required_reading>
17
+
18
+ <deferred_reading>
19
+ - [roadmap.md](~/.maestro/workflows/roadmap.md) — read for roadmap generation workflow
20
+ </deferred_reading>
21
+
22
+ <context>
23
+ $ARGUMENTS -- requirement text, @file reference, or upstream context source.
24
+
25
+ **Flags:**
26
+
27
+ | Flag | Effect | Default |
28
+ |------|--------|---------|
29
+ | `-y` / `--yes` | Auto mode — skip interactive questions, use recommended defaults | false |
30
+ | `-c` / `--continue` | Resume from last checkpoint | false |
31
+ | `-m progressive\|direct\|auto` | Decomposition strategy | auto |
32
+ | `--from <source>` | Load upstream context package (brainstorm:ID, blueprint:BLP-xxx, analyze:ANL-xxx, @file, or path). Consumes context-package.json | — |
33
+ | `--from-brainstorm SESSION-ID` | Backward compat alias for `--from brainstorm:ID` | — |
34
+ | `--revise [instructions]` | Revise existing roadmap. If instructions provided, apply directly. If omitted, ask user. Preserves completed phase progress. | — |
35
+ | `--review` | Roadmap health assessment (read-only) | — |
36
+
37
+ **Input types:**
38
+ - Direct text: `"Implement user authentication system with OAuth and 2FA"`
39
+ - File reference: `@requirements.md`
40
+ - Context import: `--from brainstorm:BRN-001` or `--from analyze:ANL-xxx` or `--from blueprint:BLP-xxx`
41
+ - No args + `--revise` / `--review`: Operate on existing `.workflow/roadmap.md`
42
+
43
+ ### Pre-load
44
+
45
+ 1. **Specs**: `maestro load --type spec --category arch` — load architecture constraints for phase decomposition
46
+ 2. **Wiki search**: `maestro search "{requirement keywords}" --json` → prior knowledge
47
+ 3. All optional — proceed without if unavailable
48
+ </context>
49
+
50
+ <interview_protocol>
51
+ Follows @~/.maestro/workflows/interview-mechanics.md standard.
52
+
53
+ **Interaction mode**: convergent menu-driven
54
+ **Decision tree** (strict order): mode (create / revise / review) → requirement scope (MVP / complete / phased) → decomposition strategy (progressive / direct / auto) → milestone boundaries → phase dependencies and order
55
+ **Scope guard**: only roadmap shape; do not pre-resolve task breakdown or phase decomposition (belongs to plan)
56
+ **Writeback target**: .workflow/roadmap.md "Roadmap Decisions" section (create if absent)
57
+ **Additional skip conditions**: --revise, --review (skip to respective mode)
58
+ **Exit condition**: on consensus or explicit user signal → finalize Roadmap Decisions section
59
+ </interview_protocol>
60
+
61
+ <execution>
62
+
63
+ 1. Read `@~/.maestro/workflows/roadmap-common.md` (always — shared logic)
64
+ 2. Read `@~/.maestro/workflows/roadmap.md`, follow its process
65
+
66
+ Sub-modes:
67
+ - **Create** (default): Build roadmap from requirements or upstream context
68
+ - **Revise** (`--revise`): Follow workflow roadmap.md "Mode: Revise" section
69
+ - **Review** (`--review`): Follow workflow roadmap.md "Mode: Review" section
70
+
71
+ ### Phase Gates (MANDATORY, BLOCKING — Create mode)
72
+
73
+ **GATE 1: Input → Decomposition**
74
+ - REQUIRED: Requirement parsed with goal, constraints, stakeholders.
75
+ - REQUIRED: Upstream context loaded via --from (if specified).
76
+ - BLOCKED if missing: cannot decompose without parsed requirement.
77
+
78
+ **GATE 2: Decomposition → Refinement**
79
+ - REQUIRED: Milestones defined with deliverable targets.
80
+ - REQUIRED: Phases defined within milestones with dependencies.
81
+ - REQUIRED: Every Active requirement from project.md mapped to exactly one phase.
82
+ - REQUIRED: No circular dependencies in phase ordering (E003 if detected).
83
+ - BLOCKED if incomplete: finish milestone/phase decomposition before refinement.
84
+
85
+ **GATE 3: Refinement → Completion**
86
+ - REQUIRED: User approved roadmap (or auto-approved with -y).
87
+ - REQUIRED: `.workflow/roadmap.md` written with Milestone > Phase hierarchy.
88
+ - REQUIRED: Artifact registered in state.json with milestone entries.
89
+ - BLOCKED if missing: do not report completion without written roadmap.
90
+
91
+
92
+ </execution>
93
+
94
+ <completion>
95
+ ### Standalone report
96
+
97
+ ```
98
+ === ROADMAP READY ===
99
+ Milestones: {count}
100
+ Phases: {total_phases}
101
+ Strategy: {progressive|direct|auto}
102
+ Output: .workflow/roadmap.md
103
+ --- COMPLETION STATUS ---
104
+ Status: {DONE|DONE_WITH_CONCERNS}
105
+ Concerns: {if any}
106
+ ```
107
+
108
+ ### Ralph-invoked completion
109
+
110
+ End the step by calling the CLI (no text block output):
111
+ ```
112
+ maestro ralph complete <idx> --status {STATUS} [--evidence {path}]
113
+ ```
114
+
115
+ Status verdicts:
116
+ - **DONE** — Normal completion
117
+ - **DONE_WITH_CONCERNS** — Completed with caveats; pass `--concerns`
118
+ - **NEEDS_RETRY** — Tooling error / transient issue; ralph will retry
119
+ - **BLOCKED** — External hard blocker; pass `--reason`
120
+
121
+ ### Next-step routing
122
+
123
+ | Condition | Suggestion |
124
+ |-----------|-----------|
125
+ | Roadmap approved, need analysis | `/maestro-analyze 1` |
126
+ | Simple project, ready to plan | `/maestro-plan 1` |
127
+ | Need UI design first | `/maestro-impeccable build` |
128
+ | View project dashboard | `/manage-status` |
129
+ | Need formal spec documents | `/maestro-blueprint` |
130
+ </completion>
131
+
132
+ <error_codes>
133
+ | Code | Severity | Condition | Recovery |
134
+ |------|----------|-----------|----------|
135
+ | E001 | error | Requirement/idea text or @file required | Prompt user for input |
136
+ | E002 | error | Context source not found (--from / --from-brainstorm) | Show available sessions/sources |
137
+ | E003 | error | Circular dependency detected in phases | Prompt user to re-decompose |
138
+ | E004 | error | roadmap.md not found (--revise/--review) | Run maestro-roadmap first |
139
+ | E005 | error | Revision invalidates completed phase work | Warn user, ask to confirm or adjust |
140
+ | W001 | warning | CLI analysis failed, using fallback | Continue with available data |
141
+ | W002 | warning | Max refinement rounds (5) reached | Force proceed with current roadmap |
142
+ | W005 | warning | External research agent failed | Continue without apiResearchContext |
143
+ </error_codes>
144
+
145
+ <success_criteria>
146
+ - [ ] Interactive mode: interview decision table appended to `.workflow/roadmap.md` "Roadmap Decisions" section
147
+ - [ ] Requirement parsed with goal, constraints, stakeholders
148
+ - [ ] Milestones defined with deliverable targets and version tags
149
+ - [ ] Decomposition strategy selected (progressive or direct)
150
+ - [ ] Phases defined within milestones with success criteria, dependencies, and requirement mappings
151
+ - [ ] Every Active requirement from project.md mapped to exactly one phase
152
+ - [ ] No circular dependencies in phase ordering
153
+ - [ ] User approved roadmap (or auto-approved with -y)
154
+ - [ ] `.workflow/roadmap.md` written with Milestone > Phase hierarchy, scope decisions, and progress table
155
+ - [ ] No phase directories created (phases are labels in roadmap, not directories)
156
+ - [ ] Artifact registered in state.json with milestone entries
157
+ </success_criteria>
@@ -0,0 +1,272 @@
1
+ ---
2
+ name: maestro-swarm-workflow
3
+ description: "Parallel workflow accelerator — route intent to fixed Workflow scripts for multi-agent concurrent execution Arguments: <intent> [--script <name>] [--dims <d1,d2>] [--roles <r1,r2>] [--count N] [--tier quick|standard] [--resume <runId>]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Workflow AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Parallel accelerator: route intent to pre-built Workflow scripts (`wf-*.js`) for multi-agent
9
+ concurrent execution with adversarial decision patterns. Complements ralph's sequential chain.
10
+ </purpose>
11
+
12
+ <context>
13
+ $ARGUMENTS — intent text with optional flags.
14
+
15
+ **Parse:**
16
+ ```
17
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
18
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
19
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
20
+ --count N → 角色数量(brainstorm 默认 3)
21
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
22
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
23
+ Remaining → intent
24
+ ```
25
+
26
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
27
+
28
+ | Script | args 接口 |
29
+ |--------|-----------|
30
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
31
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
32
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
33
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
34
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
35
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
36
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
37
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
38
+
39
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/` (results, ralph-compatible artifacts). When inside a ralph session, writes target the corresponding step's scratch directory. NEVER modify source code, workflow scripts (`~/.maestro/workflows/swarm/`), or `.claude/commands/` files.
40
+ </context>
41
+
42
+ <state_machine>
43
+
44
+ <states>
45
+ S_PARSE — 解析参数和意图 PERSIST: —
46
+ S_ROUTE — 路由到目标脚本 PERSIST: —
47
+ S_CONTEXT — 组装 context payload PERSIST: —
48
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
49
+ S_INGEST — 处理返回结果 PERSIST: —
50
+ S_FALLBACK — 无法路由 PERSIST: —
51
+ </states>
52
+
53
+ <transitions>
54
+
55
+ S_PARSE:
56
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
57
+ → S_FALLBACK WHEN: no intent
58
+
59
+ S_ROUTE:
60
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
61
+ → S_FALLBACK WHEN: ambiguous intent DO: AskUserQuestion
62
+
63
+ S_CONTEXT:
64
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
65
+
66
+ S_DISPATCH:
67
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
68
+ → S_FALLBACK WHEN: workflow failed
69
+
70
+ S_INGEST:
71
+ → END DO: A_INGEST_RESULTS
72
+
73
+ S_FALLBACK:
74
+ → S_PARSE WHEN: user provides input
75
+ → END WHEN: user cancels
76
+
77
+ </transitions>
78
+
79
+ <actions>
80
+
81
+ ### A_PARSE_ARGS
82
+
83
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
84
+ 2. 剩余文本作为 intent
85
+ 3. 若有 --resume,记录 resumeRunId
86
+
87
+ ### A_ROUTE_SCRIPT
88
+
89
+ Intent-to-script routing(按关键词匹配,--script 优先级最高)。
90
+
91
+ **Priority ordering** — 按下表自上而下匹配,先命中先用。高优先级的具体关键词优先于低优先级的宽泛关键词(如 "grill" > "analyze","verify" > "check"):
92
+
93
+ | Priority | Keywords | Script |
94
+ |----------|----------|--------|
95
+ | 1 | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
96
+ | 2 | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
97
+ | 3 | 验证 / verify / 反模式 / antipattern | `wf-verify` |
98
+ | 4 | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
99
+ | 5 | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
100
+ | 6 | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
101
+ | 7 | 头脑风暴 / brainstorm / 方案 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
102
+ | 8 | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
103
+
104
+ **Disambiguation**: 多命中(同一优先级内多个关键词匹配不同脚本)→ AskUserQuestion 让用户选择。跨优先级命中取高优先级。
105
+
106
+ ### A_ASSEMBLE_CONTEXT
107
+
108
+ 根据目标脚本组装 args payload:
109
+
110
+ **wf-analyze:**
111
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
112
+ 2. `target` = intent 中的目标描述
113
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
114
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
115
+ 5. `dimensions` = --dims 解析结果(可选)
116
+
117
+ **wf-brainstorm:**
118
+ 1. `topic` = intent 文本
119
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
120
+ 3. `count` = --count 或默认 3
121
+ 4. `roles` = --roles 解析结果(可选)
122
+
123
+ **wf-review:**
124
+ 1. `target` = 读 git diff 描述变更范围
125
+ 2. `scope` = 变更文件列表
126
+ 3. `tier` = --tier 或 "standard"
127
+ 4. `dimensions` = --dims 解析结果(可选)
128
+
129
+ **wf-verify:**
130
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
131
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
132
+ 3. `scope` = plan 涉及的文件范围
133
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
134
+
135
+ ### A_DISPATCH_WORKFLOW
136
+
137
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
138
+ 2. 构建 Workflow 调用:
139
+ ```
140
+ Workflow({
141
+ scriptPath: absoluteScriptPath,
142
+ args: assembledArgs,
143
+ resumeFromRunId: resumeRunId // 若有
144
+ })
145
+ ```
146
+ 3. 等待 Workflow 返回结果
147
+ 4. 记录 runId 用于潜在的后续 resume
148
+
149
+ ### A_INGEST_RESULTS
150
+
151
+ Workflow 返回 JSON 后:
152
+
153
+ 1. **摘要输出**:按脚本类型格式化关键指标(含对抗决策结果)
154
+ - analyze: overall_score, scope_verdict, adversarial_outcome (go/no-go/conditional advocacy + referee), scores_challenged count
155
+ - brainstorm: role count, conflict/synergy count, 3-proposal competition result, arbitration notes
156
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), 3-vote tally, confirmed vs false-positive count, adversarial_verdict
157
+ - verify: overall_status, prosecutor vs defender confidence, adversarial_outcome, gap count
158
+ - grill: overall_verdict, meta-skeptic quality rating, 3-vote verdict tally, overblown findings count
159
+ - plan: selected_strategy (breadth/depth/risk), judge panel scores, 3-critic adversarial check verdict
160
+ - execute: 3-vote status (DONE/DONE_WITH_CONCERNS/NEEDS_RETRY), convergence trust %, discrepancy count
161
+ - milestone-audit: 3-vote verdict, dimensions_overturned count, next_step
162
+
163
+ 2. **Artifact 写入**(可选):
164
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
165
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
166
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
167
+
168
+ 3. **Ralph 兼容产出**:
169
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json` + `adversarial-debate.json`
170
+ - brainstorm → `guidance-specification.md` + `proposals-competition.json`
171
+ - review → `review.json`(含 adversarial_verdict + 3-vote tally)
172
+ - verify → `verification.json`(含 adversarial_outcome: prosecutor/defender debate)
173
+ - grill → `grill-results.json`(含 meta-challenge + 3-vote verdict)
174
+ - plan → `plan.json`(含 competition scores + critic feedback)
175
+ - execute → `execution-report.json`(含 convergence_checks + 3-vote status)
176
+ - milestone-audit → `audit-report.json`(含 dimension challenges + 3-vote verdict)
177
+
178
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
179
+
180
+ </actions>
181
+
182
+ </state_machine>
183
+
184
+ <invariants>
185
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
186
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
187
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
188
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
189
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
190
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
191
+ </invariants>
192
+
193
+ <execution>
194
+
195
+ ### Phase Gates (MANDATORY, BLOCKING)
196
+
197
+ **GATE 1: Parse → Route**
198
+ - REQUIRED: Intent text or `--script` flag parsed successfully.
199
+ - BLOCKED if: no intent and no `--script` (E001).
200
+
201
+ **GATE 2: Route → Context Assembly**
202
+ - REQUIRED: Target script resolved unambiguously (single match or user-selected from candidates).
203
+ - BLOCKED if: ambiguous routing without user resolution (E002).
204
+
205
+ **GATE 3: Context → Dispatch**
206
+ - REQUIRED: Args payload assembled with all required fields for target script.
207
+ - REQUIRED: Script file exists at `~/.maestro/workflows/swarm/{script}.js`.
208
+ - BLOCKED if: script file not found (E003) or required args missing.
209
+
210
+ **GATE 4: Dispatch → Ingest**
211
+ - REQUIRED: Workflow execution completed (success or partial results available).
212
+ - BLOCKED if: Workflow execution failed entirely (E004) — offer `--resume`.
213
+
214
+ </execution>
215
+
216
+ <appendix>
217
+
218
+ ### 与 Ralph 集成
219
+
220
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
221
+
222
+ ```json
223
+ {
224
+ "index": 2,
225
+ "skill": "maestro-swarm-workflow",
226
+ "args": "--script wf-analyze {phase}",
227
+ "stage": "analyze",
228
+ "command_scope": "project",
229
+ "command_path": "<resolved by maestro ralph skills --platform claude>"
230
+ }
231
+ ```
232
+
233
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
234
+
235
+ **何时选 swarm vs 顺序命令:**
236
+
237
+ | 条件 | 推荐 | 原因 |
238
+ |------|------|------|
239
+ | 需要多维度并行 + 对抗交叉验证 | swarm | 多 agent 并发产出 + adversarial gate |
240
+ | 需要对话式交互(interview_protocol)| 顺序命令 | swarm agent 无法交互 |
241
+ | 需要写入 state.json / 推进 ralph step | 顺序命令 | swarm 承诺不触碰 ralph 状态 |
242
+ | 时间预算充裕、准确性优先 | swarm | 多角度提高覆盖率 |
243
+ | 上下文受限、快速单视角足够 | 顺序命令 | 轻量 |
244
+
245
+ ### 输出示例
246
+
247
+ ```
248
+ ┌─ wf-analyze ──────────────────────────────────────┐
249
+ │ Explore [████████████████████] 6/6 dimensions │
250
+ │ Synthesize [████████████████] done │
251
+ ├────────────────────────────────────────────────────┤
252
+ │ Score: 7.2/10 Scope: medium Verdict: go │
253
+ │ Findings: 23 total (2 critical, 5 high) │
254
+ │ Cross-cutting: 3 themes │
255
+ │ Decisions: 4 locked, 2 free, 1 deferred │
256
+ ├────────────────────────────────────────────────────┤
257
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
258
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
259
+ └────────────────────────────────────────────────────┘
260
+ ```
261
+
262
+ ### Error Codes
263
+
264
+ | Code | Description | Recovery |
265
+ |------|-------------|----------|
266
+ | E001 | No intent and no --script | Prompt for intent |
267
+ | E002 | Ambiguous routing | AskUserQuestion |
268
+ | E003 | Script file not found | Check .claude/workflows/ |
269
+ | E004 | Workflow execution failed | Show error, suggest --resume |
270
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
271
+
272
+ </appendix>
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: maestro-tools-execute
3
+ description: "Load and execute tool specs by category or name Arguments: [<tool-name> | --category <category>] [--list]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep AskUserQuestion Agent
5
+ ---
6
+
7
+ <purpose>
8
+ Load registered tool documents and execute them step-by-step.
9
+ Direct (by name) or category-based (list + select) invocation.
10
+ </purpose>
11
+
12
+ <required_reading>
13
+ @~/.maestro/workflows/tools-spec.md
14
+ </required_reading>
15
+
16
+ <context>
17
+ $ARGUMENTS — Tool name, keyword, or --category filter
18
+
19
+ **Examples**:
20
+ ```
21
+ /maestro-tools-execute integration-test
22
+ /maestro-tools-execute --category coding
23
+ /maestro-tools-execute --category review --keyword api
24
+ /maestro-tools-execute
25
+ ```
26
+
27
+ Empty arguments enters interactive mode: list all tools for user selection.
28
+ </context>
29
+
30
+ <invariants>
31
+ 1. **Confirmation before execution** — MUST AskUserQuestion before executing tool steps; NEVER auto-execute without user consent
32
+ 2. **Sequential step execution** — steps MUST be executed in defined order; NEVER skip or reorder steps unless user explicitly requests skip
33
+ 3. **Blocker escalation** — step failure MUST be reported to user with retry/skip/abort options; NEVER silently skip failed steps
34
+ 4. **Read-only tool definition** — tool execution MUST NOT modify the tool's knowhow document or spec entry; only the target codebase is modified per tool steps
35
+ 5. **Progress feedback** — each completed step MUST report `[Step N/M] done — <step_name>`; NEVER execute silently
36
+ 6. **Output boundary** — file writes are governed by the individual tool's step definitions. This command itself writes NO files beyond what the loaded tool prescribes
37
+ </invariants>
38
+
39
+ <execution>
40
+
41
+ ### Phase Gates (MANDATORY, BLOCKING)
42
+
43
+ **GATE 1: Parse → Load**
44
+ - REQUIRED: Tool name, keyword, or --category parsed from arguments (or empty for interactive mode).
45
+ - BLOCKED if: invalid category value.
46
+
47
+ **GATE 2: Load → Confirm**
48
+ - REQUIRED: Exactly one tool resolved (direct match or user selection from candidates).
49
+ - REQUIRED: Tool document loaded and steps extracted (ref entries expanded via `maestro load --type knowhow`).
50
+ - BLOCKED if: E001 (no match found), E002 unresolved (multiple matches without user selection).
51
+
52
+ **GATE 3: Confirm → Execute**
53
+ - REQUIRED: User confirmed execution mode via AskUserQuestion (execute as-is / adjust / view only).
54
+ - BLOCKED if: user selects "View only" — display steps and END without execution.
55
+
56
+ **GATE 4: Execute → Report**
57
+ - REQUIRED: All steps attempted (completed, skipped with user approval, or aborted by user).
58
+ - REQUIRED: Results collected for each step (success/skip/fail).
59
+ - BLOCKED if: user chose abort mid-execution — report partial results and END.
60
+
61
+ ### Step 1: Load Tool
62
+
63
+ **By name**:
64
+ ```bash
65
+ maestro search "<name>" --type knowhow
66
+ ```
67
+ Match knowhow documents with `tool: true` whose title or keywords contain the name. Load the matched entry with `maestro load --type knowhow --id <id>`.
68
+
69
+ **By category**:
70
+ ```bash
71
+ maestro load --type spec --category <category>
72
+ ```
73
+ Extract tool entries from the "Available Tools" section in output.
74
+
75
+ **Empty args**:
76
+ Load all categories, collect tool entries, present to user with AskUserQuestion for selection.
77
+
78
+ ### Step 2: Display Tool
79
+
80
+ Show tool information:
81
+ - Name, category, keywords
82
+ - Steps overview (for ref entries, expand knowhow detail first)
83
+
84
+ Expand ref entries:
85
+ ```bash
86
+ maestro load --type knowhow --id <knowhow-id>
87
+ ```
88
+
89
+ ### Step 3: Confirm Execution
90
+
91
+ AskUserQuestion (single-select, header: "执行方式"):
92
+ - **Execute as-is** (Recommended) — run all steps with current parameters
93
+ - **Adjust parameters** — modify scope or parameters before executing
94
+ - **View only** — display steps without executing
95
+
96
+ ### Step 4: Step-by-Step Execution
97
+
98
+ Follow the tool definition steps in order:
99
+ 1. Read current step description
100
+ 2. Execute step action (file ops, commands, code changes, etc.)
101
+ 3. Verify step completion
102
+ 4. Report progress: `[Step N/M] done — <step_name>`
103
+ 5. Proceed to next step
104
+
105
+ **Blocker handling**:
106
+ - Step fails → report error, ask user: retry / skip / abort
107
+ - Needs user input → AskUserQuestion for parameters
108
+ - Prerequisites unmet → show missing items, ask how to proceed
109
+
110
+ ### Step 5: Report Results
111
+
112
+ After completion, output:
113
+ - Completed steps list
114
+ - Skipped/failed steps (if any)
115
+ - Artifacts produced (generated files, test results, etc.)
116
+ - Suggested next actions
117
+
118
+ </execution>
119
+
120
+ <error_codes>
121
+ | Code | Severity | Description |
122
+ |------|----------|-------------|
123
+ | E001 | fatal | No matching tool found — check name/keyword |
124
+ | E002 | warning | Multiple tools match — list options for user selection |
125
+ | E003 | warning | Step execution failed — ask user how to proceed |
126
+ </error_codes>
127
+
128
+ <success_criteria>
129
+ - [ ] Tool correctly loaded (ref expanded if applicable)
130
+ - [ ] User confirmed before execution starts
131
+ - [ ] Each step has progress feedback
132
+ - [ ] Blockers handled interactively
133
+ - [ ] Results reported clearly
134
+ </success_criteria>
135
+
136
+ <completion>
137
+ ### Next-step routing
138
+ | Condition | Suggestion |
139
+ |-----------|-----------|
140
+ | Tool completed successfully | `/manage-status` or continue workflow |
141
+ | Want to register a new tool | `/maestro-tools-register` |
142
+ | Need to adjust tool definition | `/maestro-tools-register --optimize <name>` |
143
+ </completion>