maestro-flow-one 0.2.24 → 0.2.26

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.
@@ -0,0 +1,114 @@
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
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ 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.
17
+
18
+ Positioned BEFORE brainstorm in the pipeline: grill stress-tests and sharpens; brainstorm generates and elaborates.
19
+ </purpose>
20
+
21
+ <required_reading>
22
+ @~/.maestro/workflows/grill.md
23
+ </required_reading>
24
+
25
+ <deferred_reading>
26
+ - [state.json](~/.maestro/templates/state.json) — read when registering artifact
27
+ </deferred_reading>
28
+
29
+ <context>
30
+ $ARGUMENTS -- topic/plan text for interactive mode, or --from source for upstream input.
31
+
32
+ **Mode selection:**
33
+ - **Interactive mode** (default): Topic text triggers full Socratic grilling with user Q&A
34
+ - **Auto mode** (`-y`): Code exploration answers questions instead of the user
35
+ - **Resume mode** (`-c` or `--session ID`): Continue from a previous grill session
36
+
37
+ **Flags:**
38
+ - `-y` / `--yes`: Auto mode — CLI exploration replaces human answers
39
+ - `-c` / `--continue`: Resume from last grill session
40
+ - `--session ID`: Resume specific session
41
+ - `--depth shallow|standard|deep`: Branch count 3/5/8 (default: standard)
42
+ - `--from <source>`: Load upstream material (`blueprint:ID`, `@file`, or path)
43
+
44
+ **Output directory**: `.workflow/scratch/{YYYYMMDD}-grill-{slug}/`
45
+ **Produced files**: `grill-report.md`, `terminology.md`, `context-package.json`
46
+
47
+ ### Role Knowledge
48
+ `maestro wiki search "{topic keywords}"` → load relevant entries before grilling.
49
+ `maestro spec load --category arch` → load architecture constraints.
50
+ </context>
51
+
52
+ <interview_protocol>
53
+ 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`.
54
+
55
+ Core protocol:
56
+ - **One question per turn**. Each question probes ONE specific aspect. Never ask compound questions.
57
+ - **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.
58
+ - **Escalating depth**: Start with scope boundaries, progress to data model, edge cases, failure modes. Each branch goes basic → specific → adversarial.
59
+ - **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.
60
+ - **Challenge contradictions**: If an answer conflicts with code evidence or a prior answer, immediately surface the contradiction and demand resolution.
61
+ - **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.
62
+
63
+ Question framing rules:
64
+ - Reference specific code findings: "The codebase uses `{symbol}` at `{file:line}` — your proposal calls it `{term}`. Which wins?"
65
+ - Use concrete scenarios: "What happens when a user does {action} while {condition} is true?"
66
+ - Probe boundaries: "You said {X} is in scope — does that include {edge_case}, or is that separate?"
67
+ - Challenge scale: "This touches `{table}` — at 10x current data volume, which query breaks first?"
68
+
69
+ 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`.
70
+
71
+ Exit: When all depth-selected branches are fully walked (every question answered or explicitly deferred), finalize the report and generate context-package.json.
72
+ </interview_protocol>
73
+
74
+ <execution>
75
+ Follow '~/.maestro/workflows/grill.md' completely.
76
+
77
+ **Next-step routing on completion:**
78
+
79
+ Standard routing:
80
+ - Need multi-role elaboration → Skill({ skill: "maestro-brainstorm", args: "{topic} --from grill:{artifact_id}" })
81
+ - Need deep technical analysis → Skill({ skill: "maestro-analyze", args: "{topic} --from grill:{artifact_id}" })
82
+ - Scope is clear, ready for roadmap → Skill({ skill: "maestro-roadmap", args: "--from grill:{artifact_id}" })
83
+ - Need formal spec package → Skill({ skill: "maestro-blueprint", args: "--from grill:{artifact_id}" })
84
+
85
+ Resume routing:
86
+ - More branches to walk → Skill({ skill: "maestro-grill", args: "{topic} -c" })
87
+ </execution>
88
+
89
+ <error_codes>
90
+ | Code | Severity | Condition | Recovery |
91
+ |------|----------|-----------|----------|
92
+ | E001 | error | No topic/plan and no --from/--continue flag | Prompt user for topic text |
93
+ | E002 | error | --session ID not found | Show available sessions |
94
+ | W001 | warning | Codebase scan failed or returned empty | Continue without code grounding, note limitation |
95
+ | W002 | warning | CLI exploration timeout in auto mode | Skip question, mark as open |
96
+ | W003 | warning | Max branch depth reached without resolution | Force synthesis, offer continuation |
97
+ </error_codes>
98
+
99
+ <success_criteria>
100
+ - [ ] Interactive mode: all depth-selected branches walked (shallow=3, standard=5, deep=8)
101
+ - [ ] Each branch has >= 2 question-answer pairs with evidence or explicit user input
102
+ - [ ] `grill-report.md` written with Branch Log table, all Q&A entries, synthesis section
103
+ - [ ] `terminology.md` written with >= 5 terms, code references where applicable
104
+ - [ ] Every locked decision has evidence (code reference or explicit user confirmation)
105
+ - [ ] Contradictions between answers and code surfaced and resolved (or logged as risks)
106
+ - [ ] Risk register captures all unresolved tensions
107
+ - [ ] `context-package.json` generated with schema "context-package/1.0"
108
+ - [ ] Artifact registered in state.json (type=grill, id=GRL-xxx)
109
+ - [ ] Session sealed via finish-work
110
+ </success_criteria>
111
+
112
+ <on_complete>
113
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=grill, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
114
+ </on_complete>
@@ -73,6 +73,10 @@ If exit code is 1, present warnings and ask whether to proceed.
73
73
 
74
74
  Follow '~/.maestro/workflows/plan.md' completely.
75
75
 
76
+ ### P3 Agent Constraint (MANDATORY)
77
+
78
+ 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.
79
+
76
80
  ### Codebase Docs Loading (P1 addition)
77
81
 
78
82
  During P1 Context Collection, after loading context files, load codebase documentation if available:
@@ -0,0 +1,264 @@
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
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Workflow
13
+ - AskUserQuestion
14
+ ---
15
+ <purpose>
16
+ Parallel accelerator layer for maestro commands. Routes user intent to pre-built Workflow scripts
17
+ that leverage `parallel()` / `pipeline()` for multi-agent concurrent execution.
18
+
19
+ Complements maestro-ralph (sequential decision chain) — ralph manages state + decisions,
20
+ swarm-workflow provides parallel compute bursts within individual steps.
21
+
22
+ Scripts: `~/.maestro/workflows/swarm/wf-*.js`
23
+
24
+ | Script | Accelerates | Adversarial Pattern |
25
+ |--------|-------------|---------------------|
26
+ | `wf-analyze` | maestro-analyze | explore → 6-dim scoring → **skeptic cross-verify** → **3-way advocacy (go/no-go/conditional) + referee** |
27
+ | `wf-brainstorm` | maestro-brainstorm | multi-role analysis → **3-specialist cross-review** → **3-proposal competition** → **arbitrator** |
28
+ | `wf-review` | quality-review | 6-dim scan → **3-vote adversarial verify (prosecutor/defense/judge)** → **3-perspective report + arbitrated verdict** |
29
+ | `wf-verify` | maestro-verify | 3-layer + antipattern + convergence → **prosecutor vs defender debate** → **judge verdict** |
30
+ | `wf-grill` | maestro-grill | explore → parallel branch stress → **meta-skeptic challenge** → **3-vote verdict (optimist/pessimist/realist)** |
31
+ | `wf-plan` | maestro-plan | parallel context → **3-strategy competing proposals** → **judge panel scoring** → **3-critic adversarial check** |
32
+ | `wf-execute` | maestro-execute | wave-based parallel execution → **adversarial convergence spot-check** → **3-vote status determination** |
33
+ | `wf-milestone-audit` | maestro-milestone-audit | parallel 3-dim audit → **adversarial dimension challenge** → **3-vote verdict (strict/lenient/objective)** |
34
+
35
+ Integration modes:
36
+ - **Standalone**: `/maestro-swarm-workflow "analyze auth module"` — direct invocation
37
+ - **Ralph step**: ralph chain 中某个 step 可指定 `swarm-workflow` 作为加速执行器
38
+ - **Chained**: 输出 JSON 可被下游命令通过 `--from` 消费
39
+ </purpose>
40
+
41
+ <context>
42
+ $ARGUMENTS — intent text with optional flags.
43
+
44
+ **Parse:**
45
+ ```
46
+ --script <name> → 强制指定脚本(wf-analyze, wf-brainstorm, wf-review, wf-verify)
47
+ --dims <d1,d2> → 限定分析维度(analyze: architecture,complexity,patterns,risk,testability,performance)
48
+ --roles <r1,r2> → 限定角色(brainstorm: system-architect,product-manager,test-strategist,ux-expert,security-analyst,data-architect)
49
+ --count N → 角色数量(brainstorm 默认 3)
50
+ --tier <level> → review 层级(quick=2 维度, standard=4 维度)
51
+ --resume <runId> → 从之前的 workflow 运行恢复(增量重跑)
52
+ Remaining → intent
53
+ ```
54
+
55
+ **Script inventory** (`~/.maestro/workflows/swarm/`):
56
+
57
+ | Script | args 接口 |
58
+ |--------|-----------|
59
+ | `wf-analyze` | `{ target, scope, context, phase?, dimensions? }` |
60
+ | `wf-brainstorm` | `{ topic, context, count?, roles? }` |
61
+ | `wf-review` | `{ target, scope, specs?, tier?, dimensions? }` |
62
+ | `wf-verify` | `{ goals, plan_dir?, scope?, task_files?, must_haves?, skip_antipattern? }` |
63
+ | `wf-grill` | `{ topic, context?, depth?: "shallow"\|"standard"\|"deep" }` |
64
+ | `wf-plan` | `{ context_dir?, from?, phase?, scope?, specs?, gaps?, quick? }` |
65
+ | `wf-execute` | `{ plan_dir, specs?, codebase_context?, wiki_context?, auto_commit? }` |
66
+ | `wf-milestone-audit` | `{ milestone?, is_adhoc? }` |
67
+ </context>
68
+
69
+ <state_machine>
70
+
71
+ <states>
72
+ S_PARSE — 解析参数和意图 PERSIST: —
73
+ S_ROUTE — 路由到目标脚本 PERSIST: —
74
+ S_CONTEXT — 组装 context payload PERSIST: —
75
+ S_DISPATCH — 调用 Workflow 工具 PERSIST: —
76
+ S_INGEST — 处理返回结果 PERSIST: —
77
+ S_FALLBACK — 无法路由 PERSIST: —
78
+ </states>
79
+
80
+ <transitions>
81
+
82
+ S_PARSE:
83
+ → S_ROUTE WHEN: intent parsed DO: A_PARSE_ARGS
84
+ → S_FALLBACK WHEN: no intent
85
+
86
+ S_ROUTE:
87
+ → S_CONTEXT WHEN: script resolved DO: A_ROUTE_SCRIPT
88
+ → S_FALLBACK WHEN: ambiguous intent DO: AskUserQuestion
89
+
90
+ S_CONTEXT:
91
+ → S_DISPATCH DO: A_ASSEMBLE_CONTEXT
92
+
93
+ S_DISPATCH:
94
+ → S_INGEST WHEN: workflow completed DO: A_DISPATCH_WORKFLOW
95
+ → S_FALLBACK WHEN: workflow failed
96
+
97
+ S_INGEST:
98
+ → END DO: A_INGEST_RESULTS
99
+
100
+ S_FALLBACK:
101
+ → S_PARSE WHEN: user provides input
102
+ → END WHEN: user cancels
103
+
104
+ </transitions>
105
+
106
+ <actions>
107
+
108
+ ### A_PARSE_ARGS
109
+
110
+ 1. 提取 flags(--script, --dims, --roles, --count, --tier, --resume)
111
+ 2. 剩余文本作为 intent
112
+ 3. 若有 --resume,记录 resumeRunId
113
+
114
+ ### A_ROUTE_SCRIPT
115
+
116
+ Intent-to-script routing(按关键词匹配,--script 优先级最高):
117
+
118
+ | Keywords | Script |
119
+ |----------|--------|
120
+ | 分析 / analyze / 探索 / explore / 架构 / architecture / 复杂度 / 风险 | `wf-analyze` |
121
+ | 头脑风暴 / brainstorm / 方案 / 设计 / 评估 / evaluate / 多角度 | `wf-brainstorm` |
122
+ | 审查 / review / 代码审查 / code review / 质量 / quality | `wf-review` |
123
+ | 验证 / verify / 检查 / check / 反模式 / antipattern | `wf-verify` |
124
+ | 拷问 / grill / 压力测试 / stress-test / 挑战 / challenge | `wf-grill` |
125
+ | 规划 / plan / 任务分解 / decompose / 分波 / wave | `wf-plan` |
126
+ | 执行 / execute / 实现 / implement / 开发 / develop | `wf-execute` |
127
+ | 里程碑审计 / milestone-audit / 集成检查 / integration | `wf-milestone-audit` |
128
+
129
+ 多命中 → AskUserQuestion 让用户选择。
130
+
131
+ ### A_ASSEMBLE_CONTEXT
132
+
133
+ 根据目标脚本组装 args payload:
134
+
135
+ **wf-analyze:**
136
+ 1. Read `.workflow/state.json` 获取当前 phase/milestone 信息
137
+ 2. `target` = intent 中的目标描述
138
+ 3. `scope` = 从 intent 推断文件范围,或读 roadmap 获取 phase scope
139
+ 4. `context` = 拼接相关上下文(上游 artifact 摘要、specs)
140
+ 5. `dimensions` = --dims 解析结果(可选)
141
+
142
+ **wf-brainstorm:**
143
+ 1. `topic` = intent 文本
144
+ 2. `context` = 读取相关代码文件摘要 + 已有 specs
145
+ 3. `count` = --count 或默认 3
146
+ 4. `roles` = --roles 解析结果(可选)
147
+
148
+ **wf-review:**
149
+ 1. `target` = 读 git diff 描述变更范围
150
+ 2. `scope` = 变更文件列表
151
+ 3. `tier` = --tier 或 "standard"
152
+ 4. `dimensions` = --dims 解析结果(可选)
153
+
154
+ **wf-verify:**
155
+ 1. `goals` = 读最近的 plan artifact 提取目标列表
156
+ 2. `plan_dir` = 定位最近的 plan scratch 目录
157
+ 3. `scope` = plan 涉及的文件范围
158
+ 4. `skip_tests` / `skip_antipattern` = 从 flags 提取
159
+
160
+ ### A_DISPATCH_WORKFLOW
161
+
162
+ 1. 确定 scriptPath = `~/.maestro/workflows/swarm/{script}.js`(展开为绝对路径)
163
+ 2. 构建 Workflow 调用:
164
+ ```
165
+ Workflow({
166
+ scriptPath: absoluteScriptPath,
167
+ args: assembledArgs,
168
+ resumeFromRunId: resumeRunId // 若有
169
+ })
170
+ ```
171
+ 3. 等待 Workflow 返回结果
172
+ 4. 记录 runId 用于潜在的后续 resume
173
+
174
+ ### A_INGEST_RESULTS
175
+
176
+ Workflow 返回 JSON 后:
177
+
178
+ 1. **摘要输出**:按脚本类型格式化关键指标(含对抗决策结果)
179
+ - analyze: overall_score, scope_verdict, adversarial_outcome (go/no-go/conditional advocacy + referee), scores_challenged count
180
+ - brainstorm: role count, conflict/synergy count, 3-proposal competition result, arbitration notes
181
+ - review: verdict (APPROVE/REQUEST_CHANGES/BLOCK), 3-vote tally, confirmed vs false-positive count, adversarial_verdict
182
+ - verify: overall_status, prosecutor vs defender confidence, adversarial_outcome, gap count
183
+ - grill: overall_verdict, meta-skeptic quality rating, 3-vote verdict tally, overblown findings count
184
+ - plan: selected_strategy (breadth/depth/risk), judge panel scores, 3-critic adversarial check verdict
185
+ - execute: 3-vote status (DONE/DONE_WITH_CONCERNS/NEEDS_RETRY), convergence trust %, discrepancy count
186
+ - milestone-audit: 3-vote verdict, dimensions_overturned count, next_step
187
+
188
+ 2. **Artifact 写入**(可选):
189
+ - 若当前在 ralph session 中(检测 `.workflow/.maestro/ralph-*/status.json` 状态为 running):
190
+ 将结果写入对应 step 的 scratch 目录,格式兼容命令产出
191
+ - 否则写入 `.workflow/scratch/{YYYYMMDD}-swarm-{script}-{slug}/results.json`
192
+
193
+ 3. **Ralph 兼容产出**:
194
+ - analyze → `analysis.md` + `context.md`(decisions)+ `conclusions.json` + `adversarial-debate.json`
195
+ - brainstorm → `guidance-specification.md` + `proposals-competition.json`
196
+ - review → `review.json`(含 adversarial_verdict + 3-vote tally)
197
+ - verify → `verification.json`(含 adversarial_outcome: prosecutor/defender debate)
198
+ - grill → `grill-results.json`(含 meta-challenge + 3-vote verdict)
199
+ - plan → `plan.json`(含 competition scores + critic feedback)
200
+ - execute → `execution-report.json`(含 convergence_checks + 3-vote status)
201
+ - milestone-audit → `audit-report.json`(含 dimension challenges + 3-vote verdict)
202
+
203
+ 4. **RunId 提示**:显示 `Resume: /maestro-swarm-workflow --resume {runId}` 用于增量重跑
204
+
205
+ </actions>
206
+
207
+ </state_machine>
208
+
209
+ <invariants>
210
+ 1. **只做并行加速,不做状态决策** — 不修改 ralph status.json,不推进 step
211
+ 2. **args 预编译** — 所有 FS 读取在 A_ASSEMBLE_CONTEXT 完成,脚本内 agent 通过工具自行读取补充
212
+ 3. **产出格式兼容** — 写入的 artifact 格式必须与对应命令(analyze/brainstorm/review/verify)的产出一致
213
+ 4. **resume 透传** — resumeFromRunId 直接透传给 Workflow 工具,利用内置缓存机制
214
+ 5. **脚本只读** — 路由命令不修改 `~/.maestro/workflows/swarm/wf-*.js` 脚本文件
215
+ 6. **结果必须展示** — Workflow 返回后必须向用户展示格式化摘要,不得静默完成
216
+ </invariants>
217
+
218
+ <appendix>
219
+
220
+ ### 与 Ralph 集成
221
+
222
+ Ralph 可以在 A_BUILD_STEPS 中将某些 step 的执行方式标记为 `swarm-workflow`:
223
+
224
+ ```json
225
+ {
226
+ "index": 2,
227
+ "skill": "maestro-swarm-workflow",
228
+ "args": "--script wf-analyze {phase}",
229
+ "stage": "analyze",
230
+ "command_scope": "project",
231
+ "command_path": "<resolved by maestro ralph skills>"
232
+ }
233
+ ```
234
+
235
+ ralph-execute 正常通过 `maestro ralph next` 加载并执行,swarm-workflow 内部再调 Workflow 工具。
236
+
237
+ ### 输出示例
238
+
239
+ ```
240
+ ┌─ wf-analyze ──────────────────────────────────────┐
241
+ │ Explore [████████████████████] 6/6 dimensions │
242
+ │ Synthesize [████████████████] done │
243
+ ├────────────────────────────────────────────────────┤
244
+ │ Score: 7.2/10 Scope: medium Verdict: go │
245
+ │ Findings: 23 total (2 critical, 5 high) │
246
+ │ Cross-cutting: 3 themes │
247
+ │ Decisions: 4 locked, 2 free, 1 deferred │
248
+ ├────────────────────────────────────────────────────┤
249
+ │ Output: .workflow/scratch/20260530-swarm-analyze/ │
250
+ │ Resume: /maestro-swarm-workflow --resume wf_abc123 │
251
+ └────────────────────────────────────────────────────┘
252
+ ```
253
+
254
+ ### Error Codes
255
+
256
+ | Code | Description | Recovery |
257
+ |------|-------------|----------|
258
+ | E001 | No intent and no --script | Prompt for intent |
259
+ | E002 | Ambiguous routing | AskUserQuestion |
260
+ | E003 | Script file not found | Check .claude/workflows/ |
261
+ | E004 | Workflow execution failed | Show error, suggest --resume |
262
+ | E005 | Result ingestion failed | Write raw JSON to scratch |
263
+
264
+ </appendix>