maestro-flow 0.4.17 → 0.4.18

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 (80) hide show
  1. package/.agents/skills/maestro/SKILL.md +1 -1
  2. package/.agents/skills/maestro-analyze/SKILL.md +5 -0
  3. package/.agents/skills/maestro-blueprint/SKILL.md +5 -0
  4. package/.agents/skills/maestro-brainstorm/SKILL.md +5 -0
  5. package/.agents/skills/maestro-next/SKILL.md +219 -0
  6. package/.agy/skills/maestro/SKILL.md +1 -1
  7. package/.agy/skills/maestro-analyze/SKILL.md +5 -0
  8. package/.agy/skills/maestro-blueprint/SKILL.md +5 -0
  9. package/.agy/skills/maestro-brainstorm/SKILL.md +5 -0
  10. package/.agy/skills/maestro-next/SKILL.md +215 -0
  11. package/.claude/commands/maestro-analyze.md +5 -0
  12. package/.claude/commands/maestro-blueprint.md +5 -0
  13. package/.claude/commands/maestro-brainstorm.md +5 -0
  14. package/.claude/commands/maestro-next.md +217 -0
  15. package/.claude/commands/maestro.md +1 -1
  16. package/.codex/skills/learn-decompose/SKILL.md +34 -3
  17. package/.codex/skills/learn-retro/SKILL.md +31 -1
  18. package/.codex/skills/learn-second-opinion/SKILL.md +34 -4
  19. package/.codex/skills/maestro-analyze/SKILL.md +44 -5
  20. package/.codex/skills/maestro-blueprint/SKILL.md +5 -0
  21. package/.codex/skills/maestro-brainstorm/SKILL.md +46 -0
  22. package/.codex/skills/maestro-execute/SKILL.md +61 -5
  23. package/.codex/skills/maestro-milestone-audit/SKILL.md +64 -13
  24. package/.codex/skills/maestro-milestone-complete/SKILL.md +12 -0
  25. package/.codex/skills/maestro-plan/SKILL.md +36 -1
  26. package/.codex/skills/maestro-player/SKILL.md +25 -6
  27. package/.codex/skills/maestro-ralph/SKILL.md +17 -10
  28. package/.codex/skills/maestro-ralph-execute/SKILL.md +2 -1
  29. package/.codex/skills/maestro-roadmap/SKILL.md +35 -4
  30. package/.codex/skills/maestro-ui-codify/SKILL.md +38 -10
  31. package/.codex/skills/maestro-verify/SKILL.md +40 -5
  32. package/.codex/skills/manage-codebase-rebuild/SKILL.md +52 -5
  33. package/.codex/skills/manage-issue-discover/SKILL.md +106 -15
  34. package/.codex/skills/quality-auto-test/SKILL.md +70 -16
  35. package/.codex/skills/quality-debug/SKILL.md +139 -28
  36. package/.codex/skills/quality-refactor/SKILL.md +61 -11
  37. package/.codex/skills/quality-review/SKILL.md +45 -9
  38. package/.codex/skills/quality-test/SKILL.md +58 -3
  39. package/.codex/skills/security-audit/SKILL.md +38 -0
  40. package/.codex/skills/spec-map/SKILL.md +65 -8
  41. package/.codex/skills/team-coordinate/SKILL.md +28 -11
  42. package/.codex/skills/team-coordinate/specs/role-catalog.md +20 -0
  43. package/.codex/skills/team-lifecycle-v4/SKILL.md +23 -7
  44. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +20 -0
  45. package/.codex/skills/team-quality-assurance/SKILL.md +40 -2
  46. package/.codex/skills/team-review/SKILL.md +42 -2
  47. package/.codex/skills/team-tech-debt/SKILL.md +45 -2
  48. package/.codex/skills/team-testing/SKILL.md +42 -2
  49. package/dashboard/dist-server/dashboard/src/server/wiki/search.d.ts +6 -4
  50. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +50 -8
  51. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  52. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +32 -0
  53. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +294 -0
  54. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  55. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +1 -0
  56. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +35 -1
  57. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  58. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js +235 -0
  59. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.test.js.map +1 -1
  60. package/dist/src/ralph/cmd-check.js +1 -1
  61. package/dist/src/ralph/cmd-check.js.map +1 -1
  62. package/dist/src/ralph/cmd-complete.js +1 -1
  63. package/dist/src/ralph/cmd-complete.js.map +1 -1
  64. package/dist/src/ralph/cmd-next.d.ts.map +1 -1
  65. package/dist/src/ralph/cmd-next.js +12 -4
  66. package/dist/src/ralph/cmd-next.js.map +1 -1
  67. package/dist/src/ralph/cmd-session.js +2 -2
  68. package/dist/src/ralph/cmd-session.js.map +1 -1
  69. package/dist/src/ralph/status-store.d.ts +8 -1
  70. package/dist/src/ralph/status-store.d.ts.map +1 -1
  71. package/dist/src/ralph/status-store.js +12 -2
  72. package/dist/src/ralph/status-store.js.map +1 -1
  73. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  74. package/dist/src/tools/store-knowhow.js +51 -64
  75. package/dist/src/tools/store-knowhow.js.map +1 -1
  76. package/dist/src/utils/update-notices.js +12 -0
  77. package/dist/src/utils/update-notices.js.map +1 -1
  78. package/package.json +1 -1
  79. package/workflows/finish-work.md +119 -0
  80. package/workflows/milestone-complete.md +23 -1
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: maestro-next
3
+ description: Single-command recommendation — pick the best next command from the pool and execute it
4
+ argument-hint: "<intent> [-y] [--dry-run] [--top N] [--list]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - Skill
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ <purpose>
15
+ 单链推荐:根据用户输入意图,从 `.claude/commands/` 命令池中挑选**最匹配的单个命令**,确认后通过 `Skill()` 执行。
16
+
17
+ 与 `/maestro` / `/maestro-ralph` 的区别:
18
+ - `/maestro`、`/maestro-ralph`、`/maestro-ralph-execute`、`/maestro-ralph-beta`、`/maestro-player`、`/maestro-composer` 是**多步管线编排器**,本命令不会推荐它们
19
+ - 本命令始终只推荐 **1 个原子命令**(top pick),最多列出 2-3 个备选;选定后直接执行,无 session、无 chain
20
+ - 适用场景:用户意图清晰、只需单步即可完成;或不确定该走哪个具体命令时获取定向推荐
21
+ </purpose>
22
+
23
+ <context>
24
+ $ARGUMENTS — 用户意图文本 + 可选 flags。
25
+
26
+ **Flags:**
27
+ - `-y` / `--yes` — 自动模式:跳过确认,直接执行 top pick
28
+ - `--dry-run` — 仅显示推荐结果,不执行
29
+ - `--top N` — 显示前 N 个候选供选择(默认 3)
30
+ - `--list` — 仅列出可推荐命令池,不做推荐
31
+
32
+ **候选池:** 仅 Step 3 路由表中列出的命令参与推荐。表中未出现的命令(含管线编排器 `maestro` / `maestro-ralph*` / `maestro-player` / `maestro-composer` 等)不会被本命令推荐。
33
+ </context>
34
+
35
+ <execution>
36
+
37
+ ### Step 1: Parse Arguments
38
+
39
+ 解析 `-y` / `--dry-run` / `--top N` / `--list`,剩余文本作为 `intent`。
40
+
41
+ - `--list` 模式 → 跳到 Step 3(仅列表)
42
+ - `intent` 为空且非 `--list` → `AskUserQuestion`:让用户输入意图(最多 1 轮,仍空则 E001)
43
+
44
+ ### Step 2: 读取 Workflow 状态(智能推荐基础)
45
+
46
+ 读取以下项目状态,用于推断"当前生命周期位置"和"自然下一步":
47
+
48
+ ```bash
49
+ # 1. 当前 phase / milestone / 最新 artifact
50
+ cat .workflow/state.json 2>$null
51
+
52
+ # 2. 最近 artifact 目录(按 mtime 倒序,取前 3)
53
+ ls -la .workflow/scratch/ 2>$null | head -10
54
+
55
+ # 3. 是否有进行中的 ralph/maestro session
56
+ ls -la .workflow/.maestro/ 2>$null | head -5
57
+ ```
58
+
59
+ 根据读取结果推断 **lifecycle_position**(用作下一步推荐的核心信号):
60
+
61
+ | 项目状态特征 | lifecycle_position | 自然下一步 |
62
+ |--------------|-------------------|-----------|
63
+ | 无 `.workflow/` + 无源码 | `brainstorm` | `maestro-brainstorm` |
64
+ | 无 `.workflow/` + 有源码 | `init` | `maestro-init` |
65
+ | 有 state.json,无 roadmap.md,无 milestones | `analyze-macro` | `maestro-analyze` (宏观调研) |
66
+ | 有 macro analyze artifact,无 roadmap.md | `roadmap` | `maestro-roadmap` |
67
+ | 有 roadmap,未启动 phase | `analyze` | `maestro-analyze {phase}` |
68
+ | 最新 artifact = `analyze` | `plan` | `maestro-plan {phase}` |
69
+ | 最新 artifact = `plan` | `execute` | `maestro-execute {phase}` |
70
+ | 最新 artifact = `execute` | `verify` | `maestro-verify {phase}` |
71
+ | 最新 artifact = `verify`,passed | `review` | `quality-review {phase}` |
72
+ | 最新 artifact = `review`,verdict=PASS | `test-gen` | `quality-auto-test {phase}` |
73
+ | 最新 artifact = `test`,全绿 | `milestone-audit` | `maestro-milestone-audit` |
74
+ | 当前 milestone 全部 phase 完成 | `milestone-complete` | `maestro-milestone-complete` |
75
+ | 任一 stage 产物含 gaps/failed | `debug` | `quality-debug {gap}` |
76
+
77
+ **Maestro Lifecycle 主线(核心 workflow,供推断"下一步"使用):**
78
+
79
+ ```
80
+ brainstorm → blueprint → init → analyze-macro → roadmap
81
+ → [per phase] analyze → plan → execute → verify
82
+ → [quality gate] review → auto-test → test
83
+ → milestone-audit → milestone-complete → milestone-release
84
+ ```
85
+
86
+ **辅助 workflow 簇**(按场景触发,非主线):
87
+
88
+ | Workflow 簇 | 触发场景 | 主推命令 |
89
+ |-------------|---------|---------|
90
+ | Learning | 接触新代码/未知模块 | `learn-follow` → `learn-decompose` → `learn-second-opinion` |
91
+ | Knowledge | 提炼经验 / 沉淀知识 | `manage-harvest` → `manage-knowhow-capture` → `spec-add` |
92
+ | Wiki 维护 | 知识图谱整理 | `manage-wiki` → `wiki-connect` → `wiki-digest` |
93
+ | Issue 治理 | 缺陷管理 | `manage-issue-discover` → `manage-issue` |
94
+ | 文档同步 | 代码大改后 | `quality-sync` → `manage-codebase-refresh` |
95
+ | 重构 | 技术债积累 | `quality-refactor` → `quality-review` |
96
+ | 发布 | 里程碑结束 | `maestro-milestone-audit` → `maestro-milestone-release` |
97
+ | 并行开发 | 多 milestone 并行 | `maestro-fork` → ... → `maestro-merge` |
98
+
99
+ ### Step 2.5: Semantic Match & Rank
100
+
101
+ 综合以下信号对路由表中的命令评分(高→低):
102
+
103
+ | 信号 | 权重 | 说明 |
104
+ |------|------|------|
105
+ | intent 命中路由表行的关键词 | 高 | 字面匹配主依据 |
106
+ | **lifecycle_position 的"自然下一步"** | **高** | 当 intent 含"继续/下一步/next/接下来"或为空时,此信号上升为决定性 |
107
+ | `name` 关键词命中 intent | 中 | 如 intent 含 "test" → quality-test/quality-auto-test 加分 |
108
+ | Workflow 簇匹配 | 中 | intent 涉及学习/知识/issue 等场景时触发对应簇 |
109
+ | Recent activity 反向避免 | 低 | 刚完成的 stage 在短期内降权 |
110
+
111
+ **特殊意图处理:**
112
+
113
+ | Intent 模式 | 处理 |
114
+ |------------|------|
115
+ | 空 / "继续" / "下一步" / "next" / "接下来怎么走" | 直接按 lifecycle_position 的"自然下一步"作为 top pick |
116
+ | "什么状态" / "现在到哪了" / "status" | top pick = `manage-status` |
117
+ | 字面命中路由表关键词 | 路由表优先,lifecycle 作为加分项 |
118
+ | 无任何匹配 | top pick = lifecycle 自然下一步 + W002 警告 |
119
+
120
+ **意图 → 命令路由表**(候选池等于本表 + 上方"自然下一步"建议):
121
+
122
+ | 意图关键词 | 推荐命令 |
123
+ |-----------|---------|
124
+ | 头脑风暴 / 探索 / brainstorm / ideate | `maestro-brainstorm` |
125
+ | 规格 / 正式文档 / spec-generate / blueprint | `maestro-blueprint` |
126
+ | 分析 / analyze / 多维度调研 | `maestro-analyze` |
127
+ | 规划 / plan / 任务分解 | `maestro-plan` |
128
+ | 实现 / 执行 / execute | `maestro-execute` |
129
+ | 验证 / verify / 验收 | `maestro-verify` |
130
+ | 调试 / debug / 排查 / bug | `quality-debug` |
131
+ | 审查 / review / 代码审查 | `quality-review` |
132
+ | 测试 / test / UAT | `quality-test` / `quality-auto-test` |
133
+ | 重构 / refactor / 技术债 | `quality-refactor` |
134
+ | 同步文档 / sync docs | `quality-sync` |
135
+ | 回顾 / retro | `quality-retrospective` / `learn-retro` |
136
+ | issue / 缺陷管理 | `manage-issue` / `manage-issue-discover` |
137
+ | wiki / 知识图谱 | `manage-wiki` / `wiki-connect` / `wiki-digest` |
138
+ | spec / 规则 / 约束 | `spec-load` / `spec-add` / `spec-setup` |
139
+ | 项目初始化 / init | `maestro-init` |
140
+ | 状态 / status / 仪表盘 | `manage-status` |
141
+ | 文档重建 / codebase 文档 | `manage-codebase-rebuild` / `manage-codebase-refresh` |
142
+ | 安全 / security / OWASP | `security-audit` |
143
+ | 跟读 / 学习 / 阅读源码 | `learn-follow` / `learn-investigate` |
144
+ | 第二意见 / challenge / consult | `learn-second-opinion` |
145
+ | 提取知识 / harvest | `manage-harvest` / `manage-knowhow-capture` |
146
+ | 设计 / UI / 前端打磨 | `maestro-impeccable` |
147
+ | 里程碑 / milestone | `maestro-milestone-audit` / `maestro-milestone-release` / `maestro-milestone-complete` |
148
+ | fork / 分支 / 并行开发 | `maestro-fork` / `maestro-merge` |
149
+ | 覆盖层 / overlay / amend | `maestro-overlay` / `maestro-amend` |
150
+
151
+ 输出 ranked candidates,取 top N(默认 3)。
152
+
153
+ ### Step 3: Present & Confirm
154
+
155
+ **`--list` 模式:** 按类别(maestro / manage / quality / learn / spec / wiki / security)分组展示所有候选 + description,结束。
156
+
157
+ **正常模式:**
158
+
159
+ 显示:
160
+ ```
161
+ 🎯 推荐 (top pick): /<command-name>
162
+ <description>
163
+ 推荐理由: <一句话说明为什么命中>
164
+
165
+ 备选:
166
+ 2. /<alt-1> — <description>
167
+ 3. /<alt-2> — <description>
168
+
169
+ 执行参数: <args-to-pass>
170
+ ```
171
+
172
+ - `--dry-run` → 显示后结束
173
+ - `-y` → 直接执行 top pick
174
+ - 否则 → `AskUserQuestion` 让用户:执行 top pick / 选备选 / 修改参数 / 取消
175
+
176
+ ### Step 4: Execute
177
+
178
+ 通过 `Skill({ skill: "<chosen-command-name>", args: "<args>" })` 执行。
179
+
180
+ **参数传递:**
181
+ - 默认把 intent 原文作为第一个参数传给目标命令
182
+ - 若用户在 Step 3 修改了参数,使用修改后的版本
183
+ - `-y` flag 透传给目标命令(如果目标命令支持)
184
+
185
+ 执行完成后显示:
186
+ ```
187
+ ✅ 已执行 /<command-name>
188
+ ```
189
+
190
+ 不创建 session、不写 status.json、不做后续 chain — 由目标命令自行管理其产出。
191
+
192
+ </execution>
193
+
194
+ <error_codes>
195
+ | Code | Severity | Condition | Recovery |
196
+ |------|----------|-----------|----------|
197
+ | E001 | error | 未提供 intent 且 clarification 后仍为空 | 提供意图描述或使用 `--list` 浏览命令池 |
198
+ | E002 | error | 候选池为空(commands 目录不存在或无 .md 文件) | 检查 `.claude/commands/` 是否存在 |
199
+ | E003 | error | 用户选择的命令名无法解析为有效 skill | 列出有效命令名让用户重选 |
200
+ | W001 | warning | 多个命令得分接近(top1 与 top2 差距 < 阈值) | 强制展示前 3,让用户裁决 |
201
+ | W002 | warning | intent 与所有候选匹配度均低 | 提示用户考虑 `/maestro` 或 `/maestro-ralph` 走管线 |
202
+ </error_codes>
203
+
204
+ <success_criteria>
205
+ - [ ] Intent 解析 + flags 提取完成
206
+ - [ ] 读取 `.workflow/state.json` + scratch artifacts 推断 lifecycle_position
207
+ - [ ] 候选池等于路由表(管线编排器自然不在表中)
208
+ - [ ] 评分综合:intent 字面匹配 + lifecycle 自然下一步 + workflow 簇 + recent activity
209
+ - [ ] 空 intent / "继续" / "下一步" → 直接采用 lifecycle 推断的下一步
210
+ - [ ] top pick 展示时附"推荐理由"(命中规则 + lifecycle 位置)
211
+ - [ ] `--dry-run` 仅展示,不执行
212
+ - [ ] `-y` 自动执行 top pick
213
+ - [ ] 非自动模式下,用户通过 AskUserQuestion 确认或选择备选
214
+ - [ ] 选定命令通过 `Skill()` 单次调用执行
215
+ - [ ] 不创建 session、不生成 status.json、不触发后续 chain
216
+ - [ ] `--list` 模式按 workflow 簇(主线 / Learning / Knowledge / Wiki / Issue / 文档 / 重构 / 发布 / 并行)分组展示
217
+ </success_criteria>
@@ -23,7 +23,7 @@ Entry points:
23
23
  - **`/maestro --dry-run "intent"`** — Show chain, no execution
24
24
  - **`/maestro --super "intent"`** — Production-ready mode (read maestro-super.md)
25
25
 
26
- Session: `.workflow/.maestro/{session_id}/status.json`
26
+ **Session**: `.workflow/.maestro/{session_id}/status.json` — 工作流唯一真源。session_id 格式 `maestro-{YYYYMMDD-HHmmss}`(本 command 创建,静态链)或 `ralph-{YYYYMMDD-HHmmss}`(`/maestro-ralph` 创建,自适应链)。两类都由 `/maestro-ralph-execute` 推进;schema 与 ralph 共用(含 `ralph_protocol_version: "1"` + `active_step_index`)。
27
27
  </purpose>
28
28
 
29
29
  <deferred_reading>
@@ -54,7 +54,7 @@ Resolve target to file list. Load coding specs: `maestro spec load --category co
54
54
 
55
55
  ### Phase 2: Wave 1 — Parallel Dimension Scans
56
56
 
57
- Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2):
57
+ Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2). Initialize every row with `status="pending"`. Filter `wave==N AND status=="pending"` when writing each wave CSV.
58
58
 
59
59
  | id | dimension | focus |
60
60
  |----|-----------|-------|
@@ -64,7 +64,38 @@ Generate `tasks.csv` with 4 dimension rows (wave 1) + 1 cross-ref row (wave 2):
64
64
  | 4 | error | Boundaries, retry/backoff, fallbacks, guards, logging |
65
65
  | 5 | cross-ref | Dedup + catalog from wave 1 findings |
66
66
 
67
- Each dimension agent returns:
67
+ **output_schema** (both waves):
68
+
69
+ ```json
70
+ {
71
+ "type": "object",
72
+ "properties": {
73
+ "id": { "type": "string" },
74
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
75
+ "dimension": { "type": "string", "enum": ["structural", "behavioral", "data", "error", "cross-ref"] },
76
+ "patterns": { "type": "string", "description": "JSON array string: [{name, dimension, confidence, anchors, description, rationale, tradeoffs}]" },
77
+ "findings": { "type": "string", "maxLength": 500 },
78
+ "error": { "type": "string" }
79
+ },
80
+ "required": ["id", "result_status", "findings"]
81
+ }
82
+ ```
83
+
84
+ Merge: `result_status` → master `status`; copy `dimension`, `patterns`, `findings`, `error`.
85
+
86
+ **Shared termination contract** (embed in every instruction):
87
+ ```
88
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
89
+ - Success → result_status=completed (patterns may be empty array if nothing found)
90
+ - Failure → result_status=failed with error message
91
+ - Timeout → near max_runtime_seconds → result_status=completed with partial patterns
92
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
93
+ - Every finding MUST include file:line anchors. No speculation.
94
+ - Read-only analysis. Do NOT modify source.
95
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
96
+ ```
97
+
98
+ Each dimension agent populates `patterns` as a JSON array string of:
68
99
  ```json
69
100
  [{
70
101
  "name": "pattern name",
@@ -79,7 +110,7 @@ Each dimension agent returns:
79
110
 
80
111
  ### Phase 3: Wave 2 — Cross-Reference + Catalog
81
112
 
82
- Single agent receives all wave 1 findings via `prev_context`. Tasks:
113
+ Single agent receives all wave 1 findings via `prev_context`. Uses same `output_schema` + termination contract above. Tasks:
83
114
  - Match against dedup set → mark as `documented`, `known`, or `new`
84
115
  - Merge duplicates across dimensions (same pattern found by multiple agents)
85
116
  - Flag contradictions with documented conventions
@@ -44,7 +44,7 @@ $ARGUMENTS — lens selection and scope flags.
44
44
  **3a: Collect decisions** from wiki, specs, git log, phase context, .workflow/specs/learnings.md.
45
45
  **3b: Build decision registry** per decision (id, title, source, rationale, alternatives, evidence).
46
46
 
47
- **3c: Multi-perspective evaluation** via spawn_agents_on_csv (3 parallel agents):
47
+ **3c: Multi-perspective evaluation** via spawn_agents_on_csv (3 parallel agents; filter `wave==1 AND status=="pending"`):
48
48
 
49
49
  | id | perspective | focus |
50
50
  |----|------------|-------|
@@ -52,6 +52,36 @@ $ARGUMENTS — lens selection and scope flags.
52
52
  | 2 | cost | Complexity added, coupling, tech debt. Grade: low-cost/acceptable/expensive |
53
53
  | 3 | hindsight | Right call with current knowledge? Grade: confirmed/questionable/should-revisit |
54
54
 
55
+ **output_schema**:
56
+
57
+ ```json
58
+ {
59
+ "type": "object",
60
+ "properties": {
61
+ "id": { "type": "string" },
62
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
63
+ "perspective": { "type": "string", "enum": ["technical", "cost", "hindsight"] },
64
+ "grade": { "type": "string" },
65
+ "findings": { "type": "string", "maxLength": 500 },
66
+ "error": { "type": "string" }
67
+ },
68
+ "required": ["id", "result_status", "grade", "findings"]
69
+ }
70
+ ```
71
+
72
+ Merge: `result_status` → master `status`; copy `perspective`, `grade`, `findings`, `error`.
73
+
74
+ **Shared termination contract** (embed in every instruction):
75
+ ```
76
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
77
+ - Success → result_status=completed with concrete grade
78
+ - Failure → result_status=failed with error message
79
+ - Timeout → near max_runtime_seconds → result_status=failed, error="timeout (partial)"
80
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
81
+ - Read-only analysis. Do NOT modify source files.
82
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
83
+ ```
84
+
55
85
  **3d: Classify lifecycle**: Validated / Aging / Questionable / Stale / Reversed.
56
86
 
57
87
  ### Phase 4: Unified Report
@@ -47,12 +47,42 @@ Resolve target to content. Load specs, wiki search, prior lessons for context br
47
47
  | 3 | strategist | Scalability, extensibility, architecture alignment | coupling, cohesion |
48
48
  | 4 | synthesis | Merge verdicts → agreements, disagreements, top 3 recommendations | combined verdict |
49
49
 
50
- Wave 1: 3 persona agents in parallel. Wave 2: synthesis agent with wave 1 findings as prev_context.
51
-
52
- Each persona returns: `{ persona, verdict: approve|concern|reject, confidence, findings: [{severity, description, location, suggestion}], summary }`
50
+ Wave 1: 3 persona agents in parallel (filter `wave==1 AND status=="pending"`). Wave 2: synthesis agent with wave 1 findings as prev_context.
51
+
52
+ **output_schema** (both waves):
53
+
54
+ ```json
55
+ {
56
+ "type": "object",
57
+ "properties": {
58
+ "id": { "type": "string" },
59
+ "result_status": { "type": "string", "enum": ["completed", "failed"] },
60
+ "persona": { "type": "string" },
61
+ "verdict": { "type": "string", "enum": ["approve", "concern", "reject", ""] },
62
+ "confidence": { "type": "string", "description": "0-100" },
63
+ "findings": { "type": "string", "description": "JSON array of {severity, description, location, suggestion}, max 500 chars summary" },
64
+ "summary": { "type": "string", "maxLength": 500 },
65
+ "error": { "type": "string" }
66
+ },
67
+ "required": ["id", "result_status", "summary"]
68
+ }
69
+ ```
70
+
71
+ Merge: `result_status` → master `status`; copy `persona`, `verdict`, `confidence`, `findings`, `summary`, `error`.
72
+
73
+ **Shared termination contract** (embed in every instruction):
74
+ ```
75
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
76
+ - Success → result_status=completed with concrete verdict
77
+ - Failure → result_status=failed with error message
78
+ - Timeout → near max_runtime_seconds → result_status=failed, error="timeout (partial)"
79
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
80
+ - Read-only analysis. Do NOT modify source files.
81
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
82
+ ```
53
83
 
54
84
  #### Challenge Mode
55
- Single agent via spawn_agents_on_csv (1 worker). Adversarial analysis with forcing questions:
85
+ Single agent via spawn_agents_on_csv (max_concurrency: 1) with the same `output_schema` + termination contract above. Adversarial analysis with forcing questions:
56
86
  - "What assumption would invalidate this entire approach?"
57
87
  - "What's the simplest thing that breaks this?"
58
88
  - "What's the implicit contract that isn't enforced?"
@@ -152,29 +152,63 @@ S_AGGREGATE:
152
152
 
153
153
  <actions>
154
154
 
155
+ ### Shared Spawn Contract (all three waves)
156
+
157
+ Every `spawn_agents_on_csv` call in this skill MUST use the strict JSON Schema below and the shared termination contract.
158
+
159
+ **Output Schema**:
160
+
161
+ ```json
162
+ {
163
+ "type": "object",
164
+ "properties": {
165
+ "id": { "type": "string" },
166
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
167
+ "findings": { "type": "string", "maxLength": 500 },
168
+ "score": { "type": "string", "description": "0-100 (wave 2 scoring only)" },
169
+ "evidence": { "type": "string", "description": "Code refs file:line (wave 1/2)" },
170
+ "error": { "type": "string" }
171
+ },
172
+ "required": ["id", "result_status", "findings"]
173
+ }
174
+ ```
175
+
176
+ Merge step: `result_status` → master `status`; copy `findings`, `score`, `evidence`, `error`.
177
+
178
+ **Termination contract** (embed in every instruction):
179
+ ```
180
+ You MUST call report_agent_job_result EXACTLY ONCE before exiting.
181
+ - Success → result_status=completed
182
+ - Failure → result_status=failed with error message
183
+ - Blocked → upstream missing → result_status=blocked
184
+ - Timeout → near max_runtime_seconds → result_status=blocked, error="timeout"
185
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
186
+ Do NOT write to tasks.csv, wave-*.csv, results.csv. Do NOT call spawn_agents_on_csv (no recursion).
187
+ ```
188
+
155
189
  ### A_SPAWN_WAVE_1
156
190
 
157
- Filter wave==1 -> write wave-1.csv -> `spawn_agents_on_csv({ csv_path, max_concurrency })`.
191
+ Filter `wave==1 AND status=="pending"` -> write wave-1.csv -> `spawn_agents_on_csv({ csv_path, id_column:"id", instruction: EXPLORATION_INSTRUCTION + SHARED_TERMINATION_CONTRACT, max_concurrency, max_runtime_seconds: 3600, output_csv_path, output_schema })`.
158
192
 
159
193
  **Exploration agent** (3-layer per dimension):
160
194
  1. Module Discovery (breadth): keyword search, relevant files, module boundaries
161
195
  2. Structure Tracing (depth): top 3-5 files, call chains 2-3 levels, data flow
162
196
  3. Code Anchor Extraction (detail): code snippet 20-50 lines with file:line per finding
163
197
 
164
- Share via discovery board. Merge results -> master tasks.csv.
198
+ Share via discovery board. Merge results -> master tasks.csv (map `result_status` → master `status`).
165
199
 
166
200
  ### A_SPAWN_WAVE_2
167
201
 
168
- Filter wave==2 -> build prev_context from wave 1 findings -> write wave-2.csv -> spawn.
202
+ Filter `wave==2 AND status=="pending"` -> build prev_context from wave 1 findings -> write wave-2.csv -> spawn with `SCORING_INSTRUCTION + SHARED_TERMINATION_CONTRACT`.
169
203
 
170
204
  **Scoring agent** (6 dimensions: feasibility, impact, risk, complexity, alignment, maintainability):
171
205
  Score 0-100 with specific evidence (code refs from exploration). Each score MUST reference exploration findings.
172
206
 
173
- Merge results -> master tasks.csv.
207
+ Merge results -> master tasks.csv (map `result_status` → master `status`).
174
208
 
175
209
  ### A_SPAWN_WAVE_3
176
210
 
177
- Filter wave==3 -> build prev_context from wave 2 scores (or project context for quick mode) -> spawn.
211
+ Filter `wave==3 AND status=="pending"` -> build prev_context from wave 2 scores (or project context for quick mode) -> spawn with `SYNTHESIS_INSTRUCTION + SHARED_TERMINATION_CONTRACT`.
178
212
 
179
213
  **Synthesis agent**:
180
214
  - Full mode: analysis.md (executive summary, per-dimension scores, risk matrix, Go/No-Go), context.md (Locked/Free/Deferred decisions), context-package.json, conclusions.json (with `scope_verdict` + `implementation_scope[]`)
@@ -262,5 +296,10 @@ Protocol: read before analysis, append-only, dedup by type+key.
262
296
  - [ ] Upstream context loaded via `--from` when specified
263
297
  - [ ] discoveries.ndjson append-only throughout
264
298
  - [ ] Next step routed (plan for Go, brainstorm for No-Go, plan --gaps for Gaps)
299
+ - [ ] Session sealed via finish-work (archive.json written, optional spec/knowhow extraction)
265
300
  </success_criteria>
301
+
302
+ <on_complete>
303
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR=OUTPUT_DIR, SESSION_TYPE=analyze, SESSION_ID={artifact_id}, LINKED_MILESTONE={target_milestone or null}
304
+ </on_complete>
266
305
  </output>
@@ -120,4 +120,9 @@ P6 gate: Pass (>=80%) → Handoff | Review (60-79%) → Handoff w/caveats | Fail
120
120
  - [ ] Readiness gate: Pass (>=80%) or Review (>=60%) with documented caveats
121
121
  - [ ] Artifact registered in state.json (type=blueprint)
122
122
  - [ ] context-package.json generated for downstream consumption
123
+ - [ ] On gate Pass/Review: session sealed via finish-work (archive.json + optional spec/knowhow extraction). On Fail: skip — session stays active, excluded from wiki search.
123
124
  </success_criteria>
125
+
126
+ <on_complete>
127
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={session_dir}, SESSION_TYPE=blueprint, SESSION_ID={session_id}, LINKED_MILESTONE=null
128
+ </on_complete>
@@ -212,6 +212,47 @@ CONSTRAINTS:
212
212
  7. **DO NOT STOP**: Continuous until all waves complete; only pause at [CHECKPOINT] (skipped with -y).
213
213
  </invariants>
214
214
 
215
+ <spawn_contract>
216
+
217
+ All three waves invoke `spawn_agents_on_csv` with the same shape — only `instruction` (inflated from `<agent_prompt_template>`) and `max_concurrency` differ. The orchestrator MUST:
218
+
219
+ 1. Filter master tasks.csv to `wave==N AND status=="pending"` before writing `wave-{N}.csv`.
220
+ 2. Use the strict JSON Schema below for `output_schema`.
221
+ 3. Append the shared termination contract to every inflated `description`.
222
+ 4. Merge: map `result_status` → master `status`; copy `findings`, `output_path`, `error`.
223
+
224
+ **output_schema** (all waves):
225
+
226
+ ```json
227
+ {
228
+ "type": "object",
229
+ "properties": {
230
+ "id": { "type": "string" },
231
+ "result_status": { "type": "string", "enum": ["completed", "failed", "blocked"] },
232
+ "findings": { "type": "string", "maxLength": 500 },
233
+ "output_path": { "type": "string", "description": "Primary deliverable absolute path (W1: guidance-specification.md; W2: {role}/analysis.md; W3: review-findings.json)" },
234
+ "error": { "type": "string" }
235
+ },
236
+ "required": ["id", "result_status", "findings"]
237
+ }
238
+ ```
239
+
240
+ **Shared termination contract** (append to every inflated W1/W2/W3 description):
241
+
242
+ ```
243
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
244
+ - Success path → all required files written AND verified via Glob → result_status=completed, output_path set
245
+ - Failure path → unrecoverable error (write fail, missing input file) → result_status=failed
246
+ - Blocked path → upstream missing (W2 cannot read guidance-spec; W3 cannot read analysis.md) → result_status=blocked
247
+ - Timeout path → near max_runtime_seconds → finalize current write if safe → otherwise report blocked with error="timeout"
248
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
249
+ - NEVER return analysis as chat text — files on disk are the ONLY valid deliverable.
250
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv.
251
+ - Do NOT call spawn_agents_on_csv (no recursion).
252
+ ```
253
+
254
+ </spawn_contract>
255
+
215
256
  <state_machine>
216
257
 
217
258
  <states>
@@ -387,4 +428,9 @@ Protocol: read before analysis, append-only, dedup by type+key.
387
428
  - [ ] context-package.json generated with per-item `ref` traceability
388
429
  - [ ] discoveries.ndjson append-only throughout
389
430
  - [ ] context.md aggregates session results with next-step routing
431
+ - [ ] Session sealed via finish-work (auto mode only)
390
432
  </success_criteria>
433
+
434
+ <on_complete>
435
+ @~/.maestro/workflows/finish-work.md — SESSION_DIR={output_dir}, SESSION_TYPE=brainstorm, SESSION_ID={artifact_id}, LINKED_MILESTONE=null
436
+ </on_complete>
@@ -257,16 +257,72 @@ For each wave N in ascending order:
257
257
 
258
258
  ```javascript
259
259
  spawn_agents_on_csv({
260
- csv_path: `${sessionFolder}/wave-${N}.csv`,
260
+ csv_path: `${sessionFolder}/wave-${N}.csv`, // only rows where wave==N AND status=="pending"
261
261
  id_column: "id",
262
- instruction: buildExecutorInstruction(sessionFolder, phaseDir, autoCommit, specsContent), // agent: ~/.codex/agents/workflow-executor.toml
263
- max_concurrency: maxConcurrency, max_runtime_seconds: 3600,
262
+ instruction: EXECUTOR_INSTRUCTION, // see "Executor Worker Contract" below
263
+ max_concurrency: maxConcurrency,
264
+ max_runtime_seconds: 3600,
264
265
  output_csv_path: `${sessionFolder}/wave-${N}-results.csv`,
265
- output_schema: { id, result_status: [completed|failed|blocked], findings, files_modified, tests_passed, error }
266
+ output_schema: {
267
+ type: "object",
268
+ properties: {
269
+ id: { type: "string" },
270
+ result_status: { type: "string", enum: ["completed", "failed", "blocked"] },
271
+ findings: { type: "string", maxLength: 500 },
272
+ files_modified: { type: "string", description: "Semicolon-separated paths" },
273
+ tests_passed: { type: "string", enum: ["true", "false", "n/a"] },
274
+ error: { type: "string" }
275
+ },
276
+ required: ["id", "result_status", "findings"]
277
+ }
266
278
  })
267
279
  ```
268
280
 
269
- 4. Merge results into master `tasks.csv`: map `result_status` from `wave-{N}-results.csv` to the `status` column in master CSV. Delete `wave-{N}.csv` AND `wave-{N}-results.csv` after merge.
281
+ 4. Merge results into master `tasks.csv`: map `result_status` from `wave-{N}-results.csv` to the `status` column in master CSV; copy `findings`, `files_modified`, `tests_passed`, `error`. Delete `wave-{N}.csv` AND `wave-{N}-results.csv` after merge.
282
+
283
+ #### Executor Worker Contract (EXECUTOR_INSTRUCTION)
284
+
285
+ The literal `instruction` string passed to `spawn_agents_on_csv` MUST include the following contract (substitute `{sessionFolder}`, `{phaseDir}`, `{autoCommit}`, `{specsContent}` at build time):
286
+
287
+ ```
288
+ You are a task executor. ONE task row is assigned to you.
289
+
290
+ INPUT (from your CSV row):
291
+ - id, title, description, prev_context (findings from upstream tasks)
292
+ - meta.tdd_phase (red|green|refactor) if TDD mode is enabled
293
+
294
+ REQUIRED STEPS:
295
+ 1. Read prev_context — depend on upstream findings, not memory
296
+ 2. Read shared discoveries: {sessionFolder}/discoveries.ndjson
297
+ 3. Implement the task: edit/create files per description
298
+ 4. Run verification — relevant tests; if TDD, honor tdd_phase semantics
299
+ 5. If autoCommit and task succeeded → commit changes with task ID in message
300
+ 6. Append discoveries (type=implementation_note / pattern) to discoveries.ndjson
301
+ 7. Call report_agent_job_result EXACTLY ONCE
302
+
303
+ TERMINATION CONTRACT (mandatory — NO worker may end without calling report_agent_job_result):
304
+ - Success path → all files written, tests pass → result_status=completed, tests_passed="true"
305
+ - Blocked path → cannot proceed (missing dep, unclear requirement, contract violation) → result_status=blocked with error explaining what is needed
306
+ - Failure path → unrecoverable error (build error, file write fail) → result_status=failed with error message
307
+ - Timeout path → approaching max_runtime_seconds → revert partial work, report blocked with error="timeout"
308
+ - NEVER continue indefinitely. NEVER exit silently. NEVER omit the call.
309
+
310
+ OUTPUT (return via report_agent_job_result; must match output_schema):
311
+ {
312
+ "id": "<your row id>",
313
+ "result_status": "completed" | "failed" | "blocked",
314
+ "findings": "<one-sentence summary, max 500 chars>",
315
+ "files_modified": "<semicolon-separated paths or empty>",
316
+ "tests_passed": "true" | "false" | "n/a",
317
+ "error": "<message if not completed, else empty>"
318
+ }
319
+
320
+ CONSTRAINTS:
321
+ - Modify ONLY files implicated by the task description and prev_context.
322
+ - Do NOT write to tasks.csv, wave-*.csv, results.csv, plan.json, or state.json — orchestrator owns those.
323
+ - Do NOT call spawn_agents_on_csv (no recursion).
324
+ - Honor specs loaded by orchestrator (passed via instruction context).
325
+ ```
270
326
 
271
327
  #### Blocked Task Handling
272
328