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
+ - ask_question
7
+ - define_subagent
8
+ - grep_search
9
+ - invoke_subagent
10
+ - manage_subagents
11
+ - replace_file_content
12
+ - run_command
13
+ - send_message
14
+ - view_file
15
+ - write_to_file
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 → view_file(AbsolutePath="<agy-skills-dir>/maestro-brainstorm/SKILL.md") + execute inline (args: "{topic} --from grill:{artifact_id}")
83
+ - Need deep technical analysis → view_file(AbsolutePath="<agy-skills-dir>/maestro-analyze/SKILL.md") + execute inline (args: "{topic} --from grill:{artifact_id}")
84
+ - Scope is clear, ready for roadmap → view_file(AbsolutePath="<agy-skills-dir>/maestro-roadmap/SKILL.md") + execute inline (args: "--from grill:{artifact_id}")
85
+ - Need formal spec package → view_file(AbsolutePath="<agy-skills-dir>/maestro-blueprint/SKILL.md") + execute inline (args: "--from grill:{artifact_id}")
86
+
87
+ Resume routing:
88
+ - More branches to walk → view_file(AbsolutePath="<agy-skills-dir>/maestro-grill/SKILL.md") + execute inline (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:
@@ -127,20 +127,20 @@ S_INFER:
127
127
 
128
128
  S_RESOLVE_SCOPE:
129
129
  → S_QUALITY_MODE DO: A_RESOLVE_SCOPE_VERDICT
130
- GUARD: position ∈ {brainstorm, blueprint, init} → skip (scope_verdict = null)
130
+ GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip (scope_verdict = null)
131
131
 
132
132
  S_QUALITY_MODE:
133
133
  → S_PLANNING_MODE DO: A_DETERMINE_QUALITY_MODE
134
134
 
135
135
  S_PLANNING_MODE:
136
136
  → S_DECOMPOSE DO: A_DETERMINE_PLANNING_MODE
137
- GUARD: lifecycle_position ∈ {brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
137
+ GUARD: lifecycle_position ∈ {grill, brainstorm, blueprint, init, analyze-macro, roadmap} → skip (force independent)
138
138
 
139
139
  S_DECOMPOSE:
140
140
  → S_BUILD_CHAIN DO: A_DECOMPOSE_TASKS
141
141
  GUARD: broad intent → MUST clarify boundary even if auto_confirm
142
142
  GUARD: narrow intent → auto-derive, skip questions
143
- GUARD: position ∈ {brainstorm, blueprint, init} → skip decomposition
143
+ GUARD: position ∈ {grill, brainstorm, blueprint, init} → skip decomposition
144
144
 
145
145
  S_BUILD_CHAIN:
146
146
  → S_CREATE_SESSION DO: A_BUILD_STEPS
@@ -240,6 +240,7 @@ resolve_milestone(phase_number):
240
240
 
241
241
  | Pattern | Position |
242
242
  |---------|----------|
243
+ | 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时跳过,直接 `brainstorm`**) |
243
244
  | brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
244
245
  | blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
245
246
  | broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
@@ -260,7 +261,7 @@ resolve_milestone(phase_number):
260
261
  | `phase_is_new == true` (新 phase) | `analyze` |
261
262
  | no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` |
262
263
  | no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
263
- | `phase == null` (brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
264
+ | `phase == null` (grill/brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
264
265
  | phase 已存在 + 无任何 artifact | `analyze` |
265
266
  | phase 已存在 + 最新 artifact = analyze | `plan` |
266
267
  | phase 已存在 + 最新 artifact = plan | `execute` |
@@ -315,7 +316,7 @@ resolve_milestone(phase_number):
315
316
 
316
317
  | Condition | Mode | Reason |
317
318
  |-----------|------|--------|
318
- | lifecycle_position ∈ {brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
319
+ | lifecycle_position ∈ {grill, brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
319
320
  | `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
320
321
  | intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
321
322
  | milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
@@ -378,7 +379,8 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
378
379
 
379
380
  | Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
380
381
  |-------|---------------------|-----------------|----------------|--------------|
381
- | brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
382
+ | grill | `maestro-grill "{intent}"` | *(same)* | — | all (**skip when auto_confirm**) |
383
+ | brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
382
384
  | blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
383
385
  | init | `maestro-init` | *(same)* | — | all |
384
386
  | analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
@@ -403,6 +405,7 @@ Generate steps from `session.lifecycle_position` to `milestone-complete`.
403
405
  1. **起点**:从 `session.lifecycle_position` 开始
404
406
  2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
405
407
  3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
408
+ 3.5. **grill auto_confirm 跳过**:`auto_confirm == true` 时删除 `grill` stage(grill 为交互式苏格拉底拷问,不支持自动模式);brainstorm args 不含 `--from grill:*`
406
409
  4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
407
410
  5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(verify/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
408
411
  6. **终点硬约束**:chain 以 `milestone-complete` 结尾
@@ -739,7 +742,8 @@ decision:post-goal-audit {retry+1}
739
742
  - [ ] Phase 先于 position 解析;phase_is_new 标记写入 session
740
743
  - [ ] D-007 反查:phase 数字 → `session.milestone`,禁止读 current_milestone;写入 step.milestone_id
741
744
  - [ ] phase_is_new=true → lifecycle_position 强制 `analyze`
742
- - [ ] Intent overrides 识别 brainstorm / blueprint / analyze-macro
745
+ - [ ] Intent overrides 识别 grill / brainstorm / blueprint / analyze-macro
746
+ - [ ] auto_confirm=true 时 grill stage 跳过(交互式拷问不支持自动模式)
743
747
  - [ ] A_RESOLVE_SCOPE_VERDICT 读 macro analyze conclusions.scope_verdict,写入 session.scope_verdict + analyze_macro_id
744
748
  - [ ] 链路起点 = analyze-macro 时:large→roadmap+analyze+plan(phase);medium/small→直跳 plan --from analyze:{ANL_ID}(跳过 roadmap+analyze)
745
749
  - [ ] post-analyze-scope decision 节点在 macro analyze 之后插入;A_SCOPE_EVALUATE/A_APPLY_SCOPE_VERDICT 重塑链路
@@ -50,6 +50,7 @@ HARD RULES:
50
50
  6. **Self-invocation chain** — 持续直到全部 `completion_confirmed` 或 paused
51
51
  7. **status.json 每步骤后由 CLI 原子写盘** — resume-safe
52
52
  8. **STATUS 枚举受限** — 仅 `DONE | DONE_WITH_CONCERNS | NEEDS_RETRY | BLOCKED`;`NEEDS_CONTEXT` 已废除
53
+ 9. **CLI 输出禁止截断** — `maestro ralph next` 的 stdout 包含完整 skill prompt,必须全量捕获。**严禁** `| head`、`| tail`、`2>&1 | head -N` 等任何截断管道。Bash timeout 可加长但不可截断输出
53
54
  </invariants>
54
55
 
55
56
  <state_machine>
@@ -153,7 +154,7 @@ Write enriched args back to status.json.
153
154
 
154
155
  ### A_EXEC_STEP
155
156
 
156
- 1. **Load** — `run_command("maestro ralph next")`
157
+ 1. **Load** — `run_command("maestro ralph next --session <session_id>")` — **必须全量捕获 stdout,严禁 `| head`/`| tail` 等截断管道**(stdout 含完整 skill prompt,截断会导致执行内容不完整)
157
158
  - 退出码 0 → 按 stdout 内联执行
158
159
  - 退出码 2 → 交给 S_LOCATE
159
160
  - 退出码 3 → active_step_index 已被占用
@@ -0,0 +1,263 @@
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
+ - Workflow
7
+ - ask_question
8
+ - grep_search
9
+ - replace_file_content
10
+ - run_command
11
+ - view_file
12
+ - write_to_file
13
+ ---
14
+ <purpose>
15
+ Parallel accelerator layer for maestro commands. Routes user intent to pre-built Workflow scripts
16
+ that leverage `parallel()` / `pipeline()` for multi-agent concurrent execution.
17
+
18
+ Complements maestro-ralph (sequential decision chain) — ralph manages state + decisions,
19
+ swarm-workflow provides parallel compute bursts within individual steps.
20
+
21
+ Scripts: `~/.maestro/workflows/swarm/wf-*.js`
22
+
23
+ | Script | Accelerates | Adversarial Pattern |
24
+ |--------|-------------|---------------------|
25
+ | `wf-analyze` | maestro-analyze | explore → 6-dim scoring → **skeptic cross-verify** → **3-way advocacy (go/no-go/conditional) + referee** |
26
+ | `wf-brainstorm` | maestro-brainstorm | multi-role analysis → **3-specialist cross-review** → **3-proposal competition** → **arbitrator** |
27
+ | `wf-review` | quality-review | 6-dim scan → **3-vote adversarial verify (prosecutor/defense/judge)** → **3-perspective report + arbitrated verdict** |
28
+ | `wf-verify` | maestro-verify | 3-layer + antipattern + convergence → **prosecutor vs defender debate** → **judge verdict** |
29
+ | `wf-grill` | maestro-grill | explore → parallel branch stress → **meta-skeptic challenge** → **3-vote verdict (optimist/pessimist/realist)** |
30
+ | `wf-plan` | maestro-plan | parallel context → **3-strategy competing proposals** → **judge panel scoring** → **3-critic adversarial check** |
31
+ | `wf-execute` | maestro-execute | wave-based parallel execution → **adversarial convergence spot-check** → **3-vote status determination** |
32
+ | `wf-milestone-audit` | maestro-milestone-audit | parallel 3-dim audit → **adversarial dimension challenge** → **3-vote verdict (strict/lenient/objective)** |
33
+
34
+ Integration modes:
35
+ - **Standalone**: `/maestro-swarm-workflow "analyze auth module"` — direct invocation
36
+ - **Ralph step**: ralph chain 中某个 step 可指定 `swarm-workflow` 作为加速执行器
37
+ - **Chained**: 输出 JSON 可被下游命令通过 `--from` 消费
38
+ </purpose>
39
+
40
+ <context>
41
+ $ARGUMENTS — intent text with optional flags.
42
+
43
+ **Parse:**
44
+ ```
45
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
46
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
47
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
48
+ --count N → 角色数量(brainstorm 默认 3)
49
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
50
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
51
+ Remaining → intent
52
+ ```
53
+
54
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
55
+
56
+ | Script | args 接口 |
57
+ |--------|-----------|
58
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
59
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
60
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
61
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
62
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
63
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
64
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
65
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
66
+ </context>
67
+
68
+ <state_machine>
69
+
70
+ <states>
71
+ S_PARSE — 解析参数和意图 PERSIST: —
72
+ S_ROUTE — 路由到目标脚本 PERSIST: —
73
+ S_CONTEXT — 组装 context payload PERSIST: —
74
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
75
+ S_INGEST — 处理返回结果 PERSIST: —
76
+ S_FALLBACK — 无法路由 PERSIST: —
77
+ </states>
78
+
79
+ <transitions>
80
+
81
+ S_PARSE:
82
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
83
+ → S_FALLBACK WHEN: no intent
84
+
85
+ S_ROUTE:
86
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
87
+ → S_FALLBACK WHEN: ambiguous intent DO: ask_question
88
+
89
+ S_CONTEXT:
90
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
91
+
92
+ S_DISPATCH:
93
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
94
+ → S_FALLBACK WHEN: workflow failed
95
+
96
+ S_INGEST:
97
+ → END DO: A_INGEST_RESULTS
98
+
99
+ S_FALLBACK:
100
+ → S_PARSE WHEN: user provides input
101
+ → END WHEN: user cancels
102
+
103
+ </transitions>
104
+
105
+ <actions>
106
+
107
+ ### A_PARSE_ARGS
108
+
109
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
110
+ 2. 剩余文本作为 intent
111
+ 3. 若有 --resume,记录 resumeRunId
112
+
113
+ ### A_ROUTE_SCRIPT
114
+
115
+ Intent-to-script routing(按关键词匹配,--script 优先级最高):
116
+
117
+ | Keywords | Script |
118
+ |----------|--------|
119
+ | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
120
+ | 头脑风暴 / brainstorm / 方案 / 设计 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
121
+ | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
122
+ | 验证 / verify / 检查 / check / 反模式 / antipattern | `wf-verify` |
123
+ | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
124
+ | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
125
+ | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
126
+ | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
127
+
128
+ 多命中 → ask_question 让用户选择。
129
+
130
+ ### A_ASSEMBLE_CONTEXT
131
+
132
+ 根据目标脚本组装 args payload:
133
+
134
+ **wf-analyze:**
135
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
136
+ 2. `target` = intent 中的目标描述
137
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
138
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
139
+ 5. `dimensions` = --dims 解析结果(可选)
140
+
141
+ **wf-brainstorm:**
142
+ 1. `topic` = intent 文本
143
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
144
+ 3. `count` = --count 或默认 3
145
+ 4. `roles` = --roles 解析结果(可选)
146
+
147
+ **wf-review:**
148
+ 1. `target` = 读 git diff 描述变更范围
149
+ 2. `scope` = 变更文件列表
150
+ 3. `tier` = --tier 或 "standard"
151
+ 4. `dimensions` = --dims 解析结果(可选)
152
+
153
+ **wf-verify:**
154
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
155
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
156
+ 3. `scope` = plan 涉及的文件范围
157
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
158
+
159
+ ### A_DISPATCH_WORKFLOW
160
+
161
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
162
+ 2. 构建 Workflow 调用:
163
+ ```
164
+ Workflow({
165
+ scriptPath: absoluteScriptPath,
166
+ args: assembledArgs,
167
+ resumeFromRunId: resumeRunId // 若有
168
+ })
169
+ ```
170
+ 3. 等待 Workflow 返回结果
171
+ 4. 记录 runId 用于潜在的后续 resume
172
+
173
+ ### A_INGEST_RESULTS
174
+
175
+ Workflow 返回 JSON 后:
176
+
177
+ 1. **摘要输出**:按脚本类型格式化关键指标(含对抗决策结果)
178
+ - analyze: overall_score, scope_verdict, adversarial_outcome (go/no-go/conditional advocacy + referee), scores_challenged count
179
+ - brainstorm: role count, conflict/synergy count, 3-proposal competition result, arbitration notes
180
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), 3-vote tally, confirmed vs false-positive count, adversarial_verdict
181
+ - verify: overall_status, prosecutor vs defender confidence, adversarial_outcome, gap count
182
+ - grill: overall_verdict, meta-skeptic quality rating, 3-vote verdict tally, overblown findings count
183
+ - plan: selected_strategy (breadth/depth/risk), judge panel scores, 3-critic adversarial check verdict
184
+ - execute: 3-vote status (DONE/DONE_WITH_CONCERNS/NEEDS_RETRY), convergence trust %, discrepancy count
185
+ - milestone-audit: 3-vote verdict, dimensions_overturned count, next_step
186
+
187
+ 2. **Artifact 写入**(可选):
188
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
189
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
190
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
191
+
192
+ 3. **Ralph 兼容产出**:
193
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json` + `adversarial-debate.json`
194
+ - brainstorm → `guidance-specification.md` + `proposals-competition.json`
195
+ - review → `review.json`(含 adversarial_verdict + 3-vote tally)
196
+ - verify → `verification.json`(含 adversarial_outcome: prosecutor/defender debate)
197
+ - grill → `grill-results.json`(含 meta-challenge + 3-vote verdict)
198
+ - plan → `plan.json`(含 competition scores + critic feedback)
199
+ - execute → `execution-report.json`(含 convergence_checks + 3-vote status)
200
+ - milestone-audit → `audit-report.json`(含 dimension challenges + 3-vote verdict)
201
+
202
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
203
+
204
+ </actions>
205
+
206
+ </state_machine>
207
+
208
+ <invariants>
209
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
210
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
211
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
212
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
213
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
214
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
215
+ </invariants>
216
+
217
+ <appendix>
218
+
219
+ ### 与 Ralph 集成
220
+
221
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
222
+
223
+ ```json
224
+ {
225
+ "index": 2,
226
+ "skill": "maestro-swarm-workflow",
227
+ "args": "--script wf-analyze {phase}",
228
+ "stage": "analyze",
229
+ "command_scope": "project",
230
+ "command_path": "<resolved by maestro ralph skills>"
231
+ }
232
+ ```
233
+
234
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
235
+
236
+ ### 输出示例
237
+
238
+ ```
239
+ ┌─ wf-analyze ──────────────────────────────────────┐
240
+ │ Explore [████████████████████] 6/6 dimensions │
241
+ │ Synthesize [████████████████] done │
242
+ ├────────────────────────────────────────────────────┤
243
+ │ Score: 7.2/10 Scope: medium Verdict: go │
244
+ │ Findings: 23 total (2 critical, 5 high) │
245
+ │ Cross-cutting: 3 themes │
246
+ │ Decisions: 4 locked, 2 free, 1 deferred │
247
+ ├────────────────────────────────────────────────────┤
248
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
249
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
250
+ └────────────────────────────────────────────────────┘
251
+ ```
252
+
253
+ ### Error Codes
254
+
255
+ | Code | Description | Recovery |
256
+ |------|-------------|----------|
257
+ | E001 | No intent and no --script | Prompt for intent |
258
+ | E002 | Ambiguous routing | ask_question |
259
+ | E003 | Script file not found | Check .claude/workflows/ |
260
+ | E004 | Workflow execution failed | Show error, suggest --resume |
261
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
262
+
263
+ </appendix>