maestro-flow 0.4.19 → 0.4.21

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 (163) hide show
  1. package/.agents/agents/workflow-collab-planner.md +4 -1
  2. package/.agents/agents/workflow-plan-checker.md +11 -1
  3. package/.agents/agents/workflow-planner.md +4 -1
  4. package/.agents/skills/maestro/SKILL.md +8 -5
  5. package/.agents/skills/maestro-analyze/SKILL.md +1 -1
  6. package/.agents/skills/maestro-brainstorm/SKILL.md +2 -1
  7. package/.agents/skills/maestro-companion/SKILL.md +533 -0
  8. package/.agents/skills/maestro-grill/SKILL.md +116 -0
  9. package/.agents/skills/maestro-plan/SKILL.md +4 -0
  10. package/.agents/skills/maestro-ralph/SKILL.md +11 -7
  11. package/.agents/skills/maestro-ralph-execute/SKILL.md +2 -1
  12. package/.agents/skills/maestro-swarm-workflow/SKILL.md +266 -0
  13. package/.agents/skills/maestro-universal-workflow/SKILL.md +563 -0
  14. package/.agents/skills/manage-codebase-rebuild/SKILL.md +13 -1
  15. package/.agents/skills/manage-codebase-refresh/SKILL.md +3 -0
  16. package/.agents/skills/spec-setup/SKILL.md +9 -5
  17. package/.agents/skills/team-adversarial-swarm/SKILL.md +235 -0
  18. package/.agents/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  19. package/.agents/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  20. package/.agents/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  21. package/.agents/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  22. package/.agents/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  23. package/.agents/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  24. package/.agents/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  25. package/.agents/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  26. package/.agents/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  27. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  28. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  29. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  30. package/.agents/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  31. package/.agy/agents/workflow-collab-planner.md +4 -1
  32. package/.agy/agents/workflow-plan-checker.md +11 -1
  33. package/.agy/agents/workflow-planner.md +4 -1
  34. package/.agy/skills/maestro/SKILL.md +8 -5
  35. package/.agy/skills/maestro-analyze/SKILL.md +1 -1
  36. package/.agy/skills/maestro-brainstorm/SKILL.md +2 -1
  37. package/.agy/skills/maestro-companion/SKILL.md +529 -0
  38. package/.agy/skills/maestro-grill/SKILL.md +116 -0
  39. package/.agy/skills/maestro-plan/SKILL.md +4 -0
  40. package/.agy/skills/maestro-ralph/SKILL.md +11 -7
  41. package/.agy/skills/maestro-ralph-execute/SKILL.md +2 -1
  42. package/.agy/skills/maestro-swarm-workflow/SKILL.md +263 -0
  43. package/.agy/skills/maestro-universal-workflow/SKILL.md +560 -0
  44. package/.agy/skills/manage-codebase-rebuild/SKILL.md +13 -1
  45. package/.agy/skills/manage-codebase-refresh/SKILL.md +3 -0
  46. package/.agy/skills/spec-setup/SKILL.md +9 -5
  47. package/.agy/skills/team-adversarial-swarm/SKILL.md +244 -0
  48. package/.agy/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  49. package/.agy/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  50. package/.agy/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  51. package/.agy/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  52. package/.agy/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  53. package/.agy/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  54. package/.agy/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  55. package/.agy/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  56. package/.agy/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  57. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  58. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  59. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  60. package/.agy/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  61. package/.claude/agents/workflow-collab-planner.md +4 -1
  62. package/.claude/agents/workflow-plan-checker.md +11 -1
  63. package/.claude/agents/workflow-planner.md +4 -1
  64. package/.claude/commands/maestro-analyze.md +1 -1
  65. package/.claude/commands/maestro-brainstorm.md +2 -1
  66. package/.claude/commands/maestro-companion.md +531 -0
  67. package/.claude/commands/maestro-grill.md +114 -0
  68. package/.claude/commands/maestro-plan.md +4 -0
  69. package/.claude/commands/maestro-ralph-execute.md +2 -1
  70. package/.claude/commands/maestro-ralph.md +11 -7
  71. package/.claude/commands/maestro-swarm-workflow.md +264 -0
  72. package/.claude/commands/maestro-universal-workflow.md +561 -0
  73. package/.claude/commands/maestro.md +8 -5
  74. package/.claude/commands/manage-codebase-rebuild.md +13 -1
  75. package/.claude/commands/manage-codebase-refresh.md +3 -0
  76. package/.claude/commands/spec-setup.md +9 -5
  77. package/.claude/skills/team-adversarial-swarm/SKILL.md +233 -0
  78. package/.claude/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  79. package/.claude/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  80. package/.claude/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  81. package/.claude/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  82. package/.claude/skills/team-adversarial-swarm/specs/ant-output-schema.md +115 -0
  83. package/.claude/skills/team-adversarial-swarm/specs/convergence-criteria.md +75 -0
  84. package/.claude/skills/team-adversarial-swarm/specs/pheromone-schema.md +90 -0
  85. package/.claude/skills/team-adversarial-swarm/specs/swarm-config-template.json +66 -0
  86. package/.claude/skills/team-adversarial-swarm/specs/swarm-protocol.md +105 -0
  87. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-converge.js +197 -0
  88. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-explore.js +194 -0
  89. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-score.js +188 -0
  90. package/.claude/skills/team-adversarial-swarm/workflows/wf-swarm-synthesize.js +248 -0
  91. package/.codex/skills/maestro/SKILL.md +7 -2
  92. package/.codex/skills/maestro-companion/SKILL.md +485 -0
  93. package/.codex/skills/maestro-grill/SKILL.md +111 -0
  94. package/.codex/skills/maestro-ralph/SKILL.md +11 -7
  95. package/.codex/skills/manage-codebase-rebuild/SKILL.md +6 -0
  96. package/.codex/skills/manage-codebase-refresh/SKILL.md +6 -0
  97. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.d.ts +36 -0
  98. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js +138 -2
  99. package/dashboard/dist-server/dashboard/src/server/wiki/graph-analysis.js.map +1 -1
  100. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +13 -0
  101. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  102. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +11 -0
  103. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +178 -0
  104. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  105. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  106. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +39 -23
  107. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  108. package/dashboard/dist-server/src/graph/types.d.ts +111 -0
  109. package/dashboard/dist-server/src/graph/types.js +2 -0
  110. package/dashboard/dist-server/src/graph/types.js.map +1 -0
  111. package/dist/src/cli.js +1 -0
  112. package/dist/src/cli.js.map +1 -1
  113. package/dist/src/commands/kg.d.ts +11 -0
  114. package/dist/src/commands/kg.d.ts.map +1 -0
  115. package/dist/src/commands/kg.js +486 -0
  116. package/dist/src/commands/kg.js.map +1 -0
  117. package/dist/src/graph/analyzers/fs-analyzer.d.ts +10 -0
  118. package/dist/src/graph/analyzers/fs-analyzer.d.ts.map +1 -0
  119. package/dist/src/graph/analyzers/fs-analyzer.js +959 -0
  120. package/dist/src/graph/analyzers/fs-analyzer.js.map +1 -0
  121. package/dist/src/graph/index.d.ts +6 -0
  122. package/dist/src/graph/index.d.ts.map +1 -0
  123. package/dist/src/graph/index.js +6 -0
  124. package/dist/src/graph/index.js.map +1 -0
  125. package/dist/src/graph/loader.d.ts +3 -0
  126. package/dist/src/graph/loader.d.ts.map +1 -0
  127. package/dist/src/graph/loader.js +12 -0
  128. package/dist/src/graph/loader.js.map +1 -0
  129. package/dist/src/graph/merger.d.ts +56 -0
  130. package/dist/src/graph/merger.d.ts.map +1 -0
  131. package/dist/src/graph/merger.js +896 -0
  132. package/dist/src/graph/merger.js.map +1 -0
  133. package/dist/src/graph/query.d.ts +7 -0
  134. package/dist/src/graph/query.d.ts.map +1 -0
  135. package/dist/src/graph/query.js +126 -0
  136. package/dist/src/graph/query.js.map +1 -0
  137. package/dist/src/graph/types.d.ts +112 -0
  138. package/dist/src/graph/types.d.ts.map +1 -0
  139. package/dist/src/graph/types.js +2 -0
  140. package/dist/src/graph/types.js.map +1 -0
  141. package/dist/src/tui/install-ui/KgVendorConfig.d.ts +7 -0
  142. package/dist/src/tui/install-ui/KgVendorConfig.d.ts.map +1 -0
  143. package/dist/src/tui/install-ui/KgVendorConfig.js +9 -0
  144. package/dist/src/tui/install-ui/KgVendorConfig.js.map +1 -0
  145. package/dist/src/utils/update-notices.js +23 -0
  146. package/dist/src/utils/update-notices.js.map +1 -1
  147. package/package.json +1 -1
  148. package/workflows/analyze.md +2 -1
  149. package/workflows/brainstorm.md +24 -1
  150. package/workflows/codebase-rebuild.md +141 -1
  151. package/workflows/codebase-refresh.md +20 -0
  152. package/workflows/finish-work.md +7 -2
  153. package/workflows/grill.md +513 -0
  154. package/workflows/plan.md +7 -4
  155. package/workflows/specs-setup.md +99 -3
  156. package/workflows/swarm/wf-analyze.js +347 -0
  157. package/workflows/swarm/wf-brainstorm.js +456 -0
  158. package/workflows/swarm/wf-execute.js +379 -0
  159. package/workflows/swarm/wf-grill.js +359 -0
  160. package/workflows/swarm/wf-milestone-audit.js +385 -0
  161. package/workflows/swarm/wf-plan.js +468 -0
  162. package/workflows/swarm/wf-review.js +341 -0
  163. package/workflows/swarm/wf-verify.js +395 -0
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: maestro-grill
3
+ description: Use when stress-testing a plan, idea, or requirement against codebase reality before brainstorming
4
+ argument-hint: "<topic|plan> [-y] [-c] [--from <source>] [--depth shallow|standard|deep]"
5
+ allowed-tools:
6
+ - read_file
7
+ - write_file
8
+ - edit_file
9
+ - shell
10
+ - find_files
11
+ - search
12
+ - delegate_subagent
13
+ - ask_user
14
+ ---
15
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
16
+
17
+ <purpose>
18
+ Socratic stress-testing of a plan, idea, or requirement against codebase reality. Walks every branch of the decision tree one question at a time — challenging vague terminology against existing code, probing edge cases with concrete scenarios, and verifying assumptions with code evidence. Produces a verified context package (grill-report.md + terminology.md + context-package.json) for downstream brainstorm/analyze/roadmap consumption.
19
+
20
+ Positioned BEFORE brainstorm in the pipeline: grill stress-tests and sharpens; brainstorm generates and elaborates.
21
+ </purpose>
22
+
23
+ <required_reading>
24
+ @~/.maestro/workflows/grill.md
25
+ </required_reading>
26
+
27
+ <deferred_reading>
28
+ - [state.json](~/.maestro/templates/state.json) — read when registering artifact
29
+ </deferred_reading>
30
+
31
+ <context>
32
+ $ARGUMENTS -- topic/plan text for interactive mode, or --from source for upstream input.
33
+
34
+ **Mode selection:**
35
+ - **Interactive mode** (default): Topic text triggers full Socratic grilling with user Q&A
36
+ - **Auto mode** (`-y`): Code exploration answers questions instead of the user
37
+ - **Resume mode** (`-c` or `--session ID`): Continue from a previous grill session
38
+
39
+ **Flags:**
40
+ - `-y` / `--yes`: Auto mode — CLI exploration replaces human answers
41
+ - `-c` / `--continue`: Resume from last grill session
42
+ - `--session ID`: Resume specific session
43
+ - `--depth shallow|standard|deep`: Branch count 3/5/8 (default: standard)
44
+ - `--from <source>`: Load upstream material (`blueprint:ID`, `@file`, or path)
45
+
46
+ **Output directory**: `.workflow/scratch/{YYYYMMDD}-grill-{slug}/`
47
+ **Produced files**: `grill-report.md`, `terminology.md`, `context-package.json`
48
+
49
+ ### Role Knowledge
50
+ `maestro wiki search "{topic keywords}"` → load relevant entries before grilling.
51
+ `maestro spec load --category arch` → load architecture constraints.
52
+ </context>
53
+
54
+ <interview_protocol>
55
+ Grill the user relentlessly until every branch of the decision tree is walked. This is NOT a menu-driven interview — it is adversarial Socratic questioning. Active only in interactive mode; skip when `-y/--yes` or `-c/--continue`.
56
+
57
+ Core protocol:
58
+ - **One question per turn**. Each question probes ONE specific aspect. Never ask compound questions.
59
+ - **Code-grounded**: Before asking, search the codebase for evidence. Use findings to sharpen the question or challenge the user's answer. Never ask what code can verify — search first, then confront.
60
+ - **Escalating depth**: Start with scope boundaries, progress to data model, edge cases, failure modes. Each branch goes basic → specific → adversarial.
61
+ - **Immediate writeback**: After each answered question, immediately append the Q&A + decision to `grill-report.md`. Do NOT batch — partial progress must be on disk before the next question.
62
+ - **Challenge contradictions**: If an answer conflicts with code evidence or a prior answer, immediately surface the contradiction and demand resolution.
63
+ - **Terminology enforcement**: When the user uses a term that conflicts with codebase naming, challenge it immediately. Propose the code-consistent alternative. Update `terminology.md` as terms crystallize.
64
+
65
+ Question framing rules:
66
+ - Reference specific code findings: "The codebase uses `{symbol}` at `{file:line}` — your proposal calls it `{term}`. Which wins?"
67
+ - Use concrete scenarios: "What happens when a user does {action} while {condition} is true?"
68
+ - Probe boundaries: "You said {X} is in scope — does that include {edge_case}, or is that separate?"
69
+ - Challenge scale: "This touches `{table}` — at 10x current data volume, which query breaks first?"
70
+
71
+ Branch walking order: Scope & Boundaries → Data Model & State → Edge Cases & Failure Modes → Integration & Dependencies → Scale & Performance → Security & Access Control → Observability & Operations → Migration & Rollback. Number of branches determined by `--depth`.
72
+
73
+ Exit: When all depth-selected branches are fully walked (every question answered or explicitly deferred), finalize the report and generate context-package.json.
74
+ </interview_protocol>
75
+
76
+ <execution>
77
+ Follow '~/.maestro/workflows/grill.md' completely.
78
+
79
+ **Next-step routing on completion:**
80
+
81
+ Standard routing:
82
+ - Need multi-role elaboration → invoke_skill({ skill: "maestro-brainstorm", args: "{topic} --from grill:{artifact_id}" })
83
+ - Need deep technical analysis → invoke_skill({ skill: "maestro-analyze", args: "{topic} --from grill:{artifact_id}" })
84
+ - Scope is clear, ready for roadmap → invoke_skill({ skill: "maestro-roadmap", args: "--from grill:{artifact_id}" })
85
+ - Need formal spec package → invoke_skill({ skill: "maestro-blueprint", args: "--from grill:{artifact_id}" })
86
+
87
+ Resume routing:
88
+ - More branches to walk → invoke_skill({ skill: "maestro-grill", args: "{topic} -c" })
89
+ </execution>
90
+
91
+ <error_codes>
92
+ | Code | Severity | Condition | Recovery |
93
+ |------|----------|-----------|----------|
94
+ | E001 | error | No topic/plan and no --from/--continue flag | Prompt user for topic text |
95
+ | E002 | error | --session ID not found | Show available sessions |
96
+ | W001 | warning | Codebase scan failed or returned empty | Continue without code grounding, note limitation |
97
+ | W002 | warning | CLI exploration timeout in auto mode | Skip question, mark as open |
98
+ | W003 | warning | Max branch depth reached without resolution | Force synthesis, offer continuation |
99
+ </error_codes>
100
+
101
+ <success_criteria>
102
+ - [ ] Interactive mode: all depth-selected branches walked (shallow=3, standard=5, deep=8)
103
+ - [ ] Each branch has >= 2 question-answer pairs with evidence or explicit user input
104
+ - [ ] `grill-report.md` written with Branch Log table, all Q&A entries, synthesis section
105
+ - [ ] `terminology.md` written with >= 5 terms, code references where applicable
106
+ - [ ] Every locked decision has evidence (code reference or explicit user confirmation)
107
+ - [ ] Contradictions between answers and code surfaced and resolved (or logged as risks)
108
+ - [ ] Risk register captures all unresolved tensions
109
+ - [ ] `context-package.json` generated with schema "context-package/1.0"
110
+ - [ ] Artifact registered in state.json (type=grill, id=GRL-xxx)
111
+ - [ ] Session sealed via finish-work
112
+ </success_criteria>
113
+
114
+ <on_complete>
115
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=grill, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
116
+ </on_complete>
@@ -75,6 +75,10 @@ If exit code is 1, present warnings and ask whether to proceed.
75
75
 
76
76
  Follow '~/.maestro/workflows/plan.md' completely.
77
77
 
78
+ ### P3 Agent Constraint (MANDATORY)
79
+
80
+ Main flow **MUST** spawn a planner agent (Agent tool) for P3 planning — inline planning by main flow is FORBIDDEN. The agent produces both `plan.json` and `.task/TASK-*.json` files. Main flow only passes context and validates output.
81
+
78
82
  ### Codebase Docs Loading (P1 addition)
79
83
 
80
84
  During P1 Context Collection, after loading context files, load codebase documentation if available:
@@ -131,20 +131,20 @@ S_INFER:
131
131
 
132
132
  S_RESOLVE_SCOPE:
133
133
  → S_QUALITY_MODE DO: A_RESOLVE_SCOPE_VERDICT
134
- GUARD: position ∈ {brainstorm, blueprint, init} → skip (scope_verdict = null)
134
+ GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip (scope_verdict = null)
135
135
 
136
136
  S_QUALITY_MODE:
137
137
  → S_PLANNING_MODE DO: A_DETERMINE_QUALITY_MODE
138
138
 
139
139
  S_PLANNING_MODE:
140
140
  → S_DECOMPOSE DO: A_DETERMINE_PLANNING_MODE
141
- GUARD: lifecycle_position ∈ {brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
141
+ GUARD: lifecycle_position ∈ {grill, brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
142
142
 
143
143
  S_DECOMPOSE:
144
144
  → S_BUILD_CHAIN DO: A_DECOMPOSE_TASKS
145
145
  GUARD: broad intent → MUST clarify boundary even if auto_confirm
146
146
  GUARD: narrow intent → auto-derive, skip questions
147
- GUARD: position ∈ {brainstorm, blueprint, init} → skip decomposition
147
+ GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip decomposition
148
148
 
149
149
  S_BUILD_CHAIN:
150
150
  → S_CREATE_SESSION DO: A_BUILD_STEPS
@@ -244,6 +244,7 @@ resolve_milestone(phase_number):
244
244
 
245
245
  | Pattern | Position |
246
246
  |---------|----------|
247
+ | 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时跳过,直接 `brainstorm`**) |
247
248
  | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
248
249
  | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
249
250
  | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
@@ -264,7 +265,7 @@ resolve_milestone(phase_number):
264
265
  | `phase_is_new == true` (新 phase) | `analyze` |
265
266
  | no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` |
266
267
  | no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
267
- | `phase == null` (brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
268
+ | `phase == null` (grill/brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
268
269
  | phase 已存在 + 无任何 artifact | `analyze` |
269
270
  | phase 已存在 + 最新 artifact = analyze | `plan` |
270
271
  | phase 已存在 + 最新 artifact = plan | `execute` |
@@ -319,7 +320,7 @@ resolve_milestone(phase_number):
319
320
 
320
321
  | Condition | Mode | Reason |
321
322
  |-----------|------|--------|
322
- | lifecycle_position ∈ {brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
323
+ | lifecycle_position ∈ {grill, brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
323
324
  | `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
324
325
  | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
325
326
  | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
@@ -382,7 +383,8 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
382
383
 
383
384
  | Stage | invoke_skill(independent) | invoke_skill(unified) | Decision after | quality_mode |
384
385
  |-------|---------------------|-----------------|----------------|--------------|
385
- | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
386
+ | grill | `maestro-grill "{intent}"` | *(same)* | — | all (**skip when auto_confirm**) |
387
+ | brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
386
388
  | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
387
389
  | init | `maestro-init` | *(same)* | — | all |
388
390
  | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
@@ -407,6 +409,7 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
407
409
  1. **起点**:从 `session.lifecycle_position` 开始
408
410
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
409
411
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
412
+ 3.5. **grill auto_confirm 跳过**:`auto_confirm == true` 时删除 `grill` stage(grill 为交互式苏格拉底拷问,不支持自动模式);brainstorm args 不含 `--from grill:*`
410
413
  4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
411
414
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
412
415
  6. **终点硬约束**:chain 以 `milestone-complete` 结尾
@@ -743,7 +746,8 @@ decision:post-goal-audit {retry+1}
743
746
  - [ ] Phase 先于 position 解析;phase_is_new 标记写入 session
744
747
  - [ ] D-007 反查:phase 数字 → `session.milestone`,禁止读 current_milestone;写入 step.milestone_id
745
748
  - [ ] phase_is_new=true → lifecycle_position 强制 `analyze`
746
- - [ ] Intent overrides 识别 brainstorm / blueprint / analyze-macro
749
+ - [ ] Intent overrides 识别 grill / brainstorm / blueprint / analyze-macro
750
+ - [ ] auto_confirm=true 时 grill stage 跳过(交互式拷问不支持自动模式)
747
751
  - [ ] A_RESOLVE_SCOPE_VERDICT 读 macro analyze conclusions.scope_verdict,写入 session.scope_verdict + analyze_macro_id
748
752
  - [ ] 链路起点 = analyze-macro 时:large→roadmap+analyze+plan(phase);medium/small→直跳 plan --from analyze:{ANL_ID}(跳过 roadmap+analyze)
749
753
  - [ ] post-analyze-scope decision 节点在 macro analyze 之后插入;A_SCOPE_EVALUATE/A_APPLY_SCOPE_VERDICT 重塑链路
@@ -54,6 +54,7 @@ HARD RULES:
54
54
  6. **Self-invocation chain** — 持续直到全部 `completion_confirmed` 或 paused
55
55
  7. **status.json 每步骤后由 CLI 原子写盘** — resume-safe
56
56
  8. **STATUS 枚举受限** — 仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
57
+ 9. **CLI 输出禁止截断** — `maestro ralph next` 的 stdout 包含完整 skill prompt,必须全量捕获。**严禁** `| head`、`| tail`、`2>&1 | head -N` 等任何截断管道。Bash timeout 可加长但不可截断输出
57
58
  </invariants>
58
59
 
59
60
  <state_machine>
@@ -157,7 +158,7 @@ Write enriched args back to status.json.
157
158
 
158
159
  ### A_EXEC_STEP
159
160
 
160
- 1. **Load** — `shell("maestro ralph next")`
161
+ 1. **Load** — `shell("maestro ralph next --session <session_id>")` — **必须全量捕获 stdout,严禁 `| head`/`| tail` 等截断管道**(stdout 含完整 skill prompt,截断会导致执行内容不完整)
161
162
  - 退出码 0 → 按 stdout 内联执行
162
163
  - 退出码 2 → 交给 S_LOCATE
163
164
  - 退出码 3 → active_step_index 已被占用
@@ -0,0 +1,266 @@
1
+ ---
2
+ name: maestro-swarm-workflow
3
+ description: Parallel workflow accelerator — route intent to fixed Workflow scripts for multi-agent concurrent execution
4
+ argument-hint: "<intent> [--script <name>] [--dims <d1,d2>] [--roles <r1,r2>] [--count N] [--tier quick|standard] [--resume <runId>]"
5
+ allowed-tools:
6
+ - read_file
7
+ - write_file
8
+ - edit_file
9
+ - shell
10
+ - find_files
11
+ - search
12
+ - workflow
13
+ - ask_user
14
+ ---
15
+ <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
16
+
17
+ <purpose>
18
+ Parallel accelerator layer for maestro commands. Routes user intent to pre-built Workflow scripts
19
+ that leverage `parallel()` / `pipeline()` for multi-agent concurrent execution.
20
+
21
+ Complements maestro-ralph (sequential decision chain) — ralph manages state + decisions,
22
+ swarm-workflow provides parallel compute bursts within individual steps.
23
+
24
+ Scripts: `~/.maestro/workflows/swarm/wf-*.js`
25
+
26
+ | Script | Accelerates | Adversarial Pattern |
27
+ |--------|-------------|---------------------|
28
+ | `wf-analyze` | maestro-analyze | explore → 6-dim scoring → **skeptic cross-verify** → **3-way advocacy (go/no-go/conditional) + referee** |
29
+ | `wf-brainstorm` | maestro-brainstorm | multi-role analysis → **3-specialist cross-review** → **3-proposal competition** → **arbitrator** |
30
+ | `wf-review` | quality-review | 6-dim scan → **3-vote adversarial verify (prosecutor/defense/judge)** → **3-perspective report + arbitrated verdict** |
31
+ | `wf-verify` | maestro-verify | 3-layer + antipattern + convergence → **prosecutor vs defender debate** → **judge verdict** |
32
+ | `wf-grill` | maestro-grill | explore → parallel branch stress → **meta-skeptic challenge** → **3-vote verdict (optimist/pessimist/realist)** |
33
+ | `wf-plan` | maestro-plan | parallel context → **3-strategy competing proposals** → **judge panel scoring** → **3-critic adversarial check** |
34
+ | `wf-execute` | maestro-execute | wave-based parallel execution → **adversarial convergence spot-check** → **3-vote status determination** |
35
+ | `wf-milestone-audit` | maestro-milestone-audit | parallel 3-dim audit → **adversarial dimension challenge** → **3-vote verdict (strict/lenient/objective)** |
36
+
37
+ Integration modes:
38
+ - **Standalone**: `/maestro-swarm-workflow "analyze auth module"` — direct invocation
39
+ - **Ralph step**: ralph chain 中某个 step 可指定 `swarm-workflow` 作为加速执行器
40
+ - **Chained**: 输出 JSON 可被下游命令通过 `--from` 消费
41
+ </purpose>
42
+
43
+ <context>
44
+ $ARGUMENTS — intent text with optional flags.
45
+
46
+ **Parse:**
47
+ ```
48
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
49
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
50
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
51
+ --count N → 角色数量(brainstorm 默认 3)
52
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
53
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
54
+ Remaining → intent
55
+ ```
56
+
57
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
58
+
59
+ | Script | args 接口 |
60
+ |--------|-----------|
61
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
62
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
63
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
64
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
65
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
66
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
67
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
68
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
69
+ </context>
70
+
71
+ <state_machine>
72
+
73
+ <states>
74
+ S_PARSE — 解析参数和意图 PERSIST: —
75
+ S_ROUTE — 路由到目标脚本 PERSIST: —
76
+ S_CONTEXT — 组装 context payload PERSIST: —
77
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
78
+ S_INGEST — 处理返回结果 PERSIST: —
79
+ S_FALLBACK — 无法路由 PERSIST: —
80
+ </states>
81
+
82
+ <transitions>
83
+
84
+ S_PARSE:
85
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
86
+ → S_FALLBACK WHEN: no intent
87
+
88
+ S_ROUTE:
89
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
90
+ → S_FALLBACK WHEN: ambiguous intent DO: ask_user
91
+
92
+ S_CONTEXT:
93
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
94
+
95
+ S_DISPATCH:
96
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
97
+ → S_FALLBACK WHEN: workflow failed
98
+
99
+ S_INGEST:
100
+ → END DO: A_INGEST_RESULTS
101
+
102
+ S_FALLBACK:
103
+ → S_PARSE WHEN: user provides input
104
+ → END WHEN: user cancels
105
+
106
+ </transitions>
107
+
108
+ <actions>
109
+
110
+ ### A_PARSE_ARGS
111
+
112
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
113
+ 2. 剩余文本作为 intent
114
+ 3. 若有 --resume,记录 resumeRunId
115
+
116
+ ### A_ROUTE_SCRIPT
117
+
118
+ Intent-to-script routing(按关键词匹配,--script 优先级最高):
119
+
120
+ | Keywords | Script |
121
+ |----------|--------|
122
+ | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
123
+ | 头脑风暴 / brainstorm / 方案 / 设计 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
124
+ | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
125
+ | 验证 / verify / 检查 / check / 反模式 / antipattern | `wf-verify` |
126
+ | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
127
+ | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
128
+ | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
129
+ | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
130
+
131
+ 多命中 → ask_user 让用户选择。
132
+
133
+ ### A_ASSEMBLE_CONTEXT
134
+
135
+ 根据目标脚本组装 args payload:
136
+
137
+ **wf-analyze:**
138
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
139
+ 2. `target` = intent 中的目标描述
140
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
141
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
142
+ 5. `dimensions` = --dims 解析结果(可选)
143
+
144
+ **wf-brainstorm:**
145
+ 1. `topic` = intent 文本
146
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
147
+ 3. `count` = --count 或默认 3
148
+ 4. `roles` = --roles 解析结果(可选)
149
+
150
+ **wf-review:**
151
+ 1. `target` = 读 git diff 描述变更范围
152
+ 2. `scope` = 变更文件列表
153
+ 3. `tier` = --tier 或 "standard"
154
+ 4. `dimensions` = --dims 解析结果(可选)
155
+
156
+ **wf-verify:**
157
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
158
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
159
+ 3. `scope` = plan 涉及的文件范围
160
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
161
+
162
+ ### A_DISPATCH_WORKFLOW
163
+
164
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
165
+ 2. 构建 Workflow 调用:
166
+ ```
167
+ Workflow({
168
+ scriptPath: absoluteScriptPath,
169
+ args: assembledArgs,
170
+ resumeFromRunId: resumeRunId // 若有
171
+ })
172
+ ```
173
+ 3. 等待 Workflow 返回结果
174
+ 4. 记录 runId 用于潜在的后续 resume
175
+
176
+ ### A_INGEST_RESULTS
177
+
178
+ Workflow 返回 JSON 后:
179
+
180
+ 1. **摘要输出**:按脚本类型格式化关键指标(含对抗决策结果)
181
+ - analyze: overall_score, scope_verdict, adversarial_outcome (go/no-go/conditional advocacy + referee), scores_challenged count
182
+ - brainstorm: role count, conflict/synergy count, 3-proposal competition result, arbitration notes
183
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), 3-vote tally, confirmed vs false-positive count, adversarial_verdict
184
+ - verify: overall_status, prosecutor vs defender confidence, adversarial_outcome, gap count
185
+ - grill: overall_verdict, meta-skeptic quality rating, 3-vote verdict tally, overblown findings count
186
+ - plan: selected_strategy (breadth/depth/risk), judge panel scores, 3-critic adversarial check verdict
187
+ - execute: 3-vote status (DONE/DONE_WITH_CONCERNS/NEEDS_RETRY), convergence trust %, discrepancy count
188
+ - milestone-audit: 3-vote verdict, dimensions_overturned count, next_step
189
+
190
+ 2. **Artifact 写入**(可选):
191
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
192
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
193
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
194
+
195
+ 3. **Ralph 兼容产出**:
196
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json` + `adversarial-debate.json`
197
+ - brainstorm → `guidance-specification.md` + `proposals-competition.json`
198
+ - review → `review.json`(含 adversarial_verdict + 3-vote tally)
199
+ - verify → `verification.json`(含 adversarial_outcome: prosecutor/defender debate)
200
+ - grill → `grill-results.json`(含 meta-challenge + 3-vote verdict)
201
+ - plan → `plan.json`(含 competition scores + critic feedback)
202
+ - execute → `execution-report.json`(含 convergence_checks + 3-vote status)
203
+ - milestone-audit → `audit-report.json`(含 dimension challenges + 3-vote verdict)
204
+
205
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
206
+
207
+ </actions>
208
+
209
+ </state_machine>
210
+
211
+ <invariants>
212
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
213
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
214
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
215
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
216
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
217
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
218
+ </invariants>
219
+
220
+ <appendix>
221
+
222
+ ### 与 Ralph 集成
223
+
224
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
225
+
226
+ ```json
227
+ {
228
+ "index": 2,
229
+ "skill": "maestro-swarm-workflow",
230
+ "args": "--script wf-analyze {phase}",
231
+ "stage": "analyze",
232
+ "command_scope": "project",
233
+ "command_path": "<resolved by maestro ralph skills>"
234
+ }
235
+ ```
236
+
237
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
238
+
239
+ ### 输出示例
240
+
241
+ ```
242
+ ┌─ wf-analyze ──────────────────────────────────────┐
243
+ │ Explore [████████████████████] 6/6 dimensions │
244
+ │ Synthesize [████████████████] done │
245
+ ├────────────────────────────────────────────────────┤
246
+ │ Score: 7.2/10 Scope: medium Verdict: go │
247
+ │ Findings: 23 total (2 critical, 5 high) │
248
+ │ Cross-cutting: 3 themes │
249
+ │ Decisions: 4 locked, 2 free, 1 deferred │
250
+ ├────────────────────────────────────────────────────┤
251
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
252
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
253
+ └────────────────────────────────────────────────────┘
254
+ ```
255
+
256
+ ### Error Codes
257
+
258
+ | Code | Description | Recovery |
259
+ |------|-------------|----------|
260
+ | E001 | No intent and no --script | Prompt for intent |
261
+ | E002 | Ambiguous routing | ask_user |
262
+ | E003 | Script file not found | Check .claude/workflows/ |
263
+ | E004 | Workflow execution failed | Show error, suggest --resume |
264
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
265
+
266
+ </appendix>