maestro-flow 0.5.38 → 0.5.39

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 (67) hide show
  1. package/.agents/skills/odyssey-debug/SKILL.md +90 -269
  2. package/.agents/skills/odyssey-improve/SKILL.md +39 -240
  3. package/.agents/skills/odyssey-planex/SKILL.md +21 -105
  4. package/.agents/skills/odyssey-review-test-fix/SKILL.md +98 -318
  5. package/.agents/skills/odyssey-ui/SKILL.md +82 -265
  6. package/.agy/skills/odyssey-debug/SKILL.md +90 -269
  7. package/.agy/skills/odyssey-improve/SKILL.md +39 -240
  8. package/.agy/skills/odyssey-planex/SKILL.md +21 -105
  9. package/.agy/skills/odyssey-review-test-fix/SKILL.md +98 -318
  10. package/.agy/skills/odyssey-ui/SKILL.md +82 -265
  11. package/.claude/commands/odyssey-debug.md +90 -269
  12. package/.claude/commands/odyssey-improve.md +39 -240
  13. package/.claude/commands/odyssey-planex.md +21 -105
  14. package/.claude/commands/odyssey-review-test-fix.md +98 -318
  15. package/.claude/commands/odyssey-ui.md +82 -265
  16. package/.codex/skills/odyssey-debug/SKILL.md +167 -338
  17. package/.codex/skills/odyssey-improve/SKILL.md +226 -395
  18. package/.codex/skills/odyssey-planex/SKILL.md +317 -159
  19. package/.codex/skills/odyssey-review-test-fix/SKILL.md +137 -255
  20. package/.codex/skills/odyssey-ui/SKILL.md +197 -338
  21. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +23 -2
  22. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +242 -26
  23. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  24. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +2 -0
  25. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +92 -29
  26. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  27. package/dashboard/dist-server/src/commands/hooks.d.ts +2 -1
  28. package/dashboard/dist-server/src/commands/hooks.js +16 -9
  29. package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
  30. package/dashboard/dist-server/src/hooks/kg-sync-hook.js +5 -0
  31. package/dashboard/dist-server/src/hooks/kg-sync-hook.js.map +1 -1
  32. package/dashboard/dist-server/src/hooks/session-context.js +276 -3
  33. package/dashboard/dist-server/src/hooks/session-context.js.map +1 -1
  34. package/dashboard/dist-server/src/search/daemon-client.d.ts +8 -3
  35. package/dashboard/dist-server/src/search/daemon-client.js +20 -0
  36. package/dashboard/dist-server/src/search/daemon-client.js.map +1 -1
  37. package/dist/src/commands/domain.d.ts.map +1 -1
  38. package/dist/src/commands/domain.js +12 -3
  39. package/dist/src/commands/domain.js.map +1 -1
  40. package/dist/src/commands/hooks.d.ts +2 -1
  41. package/dist/src/commands/hooks.d.ts.map +1 -1
  42. package/dist/src/commands/hooks.js +16 -9
  43. package/dist/src/commands/hooks.js.map +1 -1
  44. package/dist/src/commands/install.js +33 -2
  45. package/dist/src/commands/install.js.map +1 -1
  46. package/dist/src/commands/search.d.ts.map +1 -1
  47. package/dist/src/commands/search.js +59 -6
  48. package/dist/src/commands/search.js.map +1 -1
  49. package/dist/src/commands/spec.d.ts.map +1 -1
  50. package/dist/src/commands/spec.js +15 -0
  51. package/dist/src/commands/spec.js.map +1 -1
  52. package/dist/src/hooks/kg-sync-hook.d.ts.map +1 -1
  53. package/dist/src/hooks/kg-sync-hook.js +5 -0
  54. package/dist/src/hooks/kg-sync-hook.js.map +1 -1
  55. package/dist/src/hooks/session-context.d.ts.map +1 -1
  56. package/dist/src/hooks/session-context.js +276 -3
  57. package/dist/src/hooks/session-context.js.map +1 -1
  58. package/dist/src/search/daemon-client.d.ts +8 -3
  59. package/dist/src/search/daemon-client.d.ts.map +1 -1
  60. package/dist/src/search/daemon-client.js +20 -0
  61. package/dist/src/search/daemon-client.js.map +1 -1
  62. package/dist/src/search/daemon.d.ts +3 -3
  63. package/dist/src/search/daemon.d.ts.map +1 -1
  64. package/dist/src/search/daemon.js +9 -3
  65. package/dist/src/search/daemon.js.map +1 -1
  66. package/package.json +1 -1
  67. package/workflows/odyssey-base.md +258 -0
@@ -1,13 +1,15 @@
1
1
  ---
2
2
  name: odyssey-planex
3
3
  description: "Requirement-driven iterative cycle — plan, execute, strict verify, fix loop until acceptance criteria met"
4
- argument-hint: "<requirement> [--max-iterations N] [--skip-generalize] [--auto] [-y] [-c]"
4
+ argument-hint: "<requirement> [--max-iterations N] [--skip-generalize] [--auto] [--method agent|cli|auto] [--executor <tool>] [--skip-verify] [--heartbeat] [-y] [-c]"
5
5
  allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
6
  ---
7
7
 
8
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
9
+
8
10
  <purpose>
9
- Requirement-to-delivery closed loop: parse requirement → define strict acceptance criteria →
10
- plan tasks → execute → verify against criteria → fix gaps → iterate until ALL criteria pass.
11
+ Requirement-to-delivery closed loop: parse requirement → define acceptance criteria →
12
+ plan → execute → verify → fix gaps → iterate until ALL criteria pass.
11
13
 
12
14
  Core philosophy:
13
15
  - **Acceptance criteria are sacred** — no "close enough", no manual override
@@ -22,38 +24,34 @@ Core philosophy:
22
24
  </purpose>
23
25
 
24
26
  <boundary>
25
- **范围内:** 单一需求的实现闭环 — 需求 验收标准 → 计划 → 实现 → 验证 → 迭代 → 泛化
26
- **范围外:** 多需求编排 → `/maestro-roadmap` | 深度 debug → `$odyssey-debug` | 代码审查 → `$odyssey-review-test-fix` | UI 优化 → `$odyssey-ui`
27
- **探索自由度:** 边界内自由可自主分解任务、选择实现策略、verify→fix 循环内尝试不同方案
28
- **Zero-residual principle:** Every failing criterion MUST be fixed or explicitly escalated with specific reason. "Close enough" is not passing. "Pre-existing gap" is not a valid skip reason — if within scope, address it.
29
- **模板:** `--template <name>` — feature | bugfix | refactor | migration | api-endpoint
27
+ **范围内:** 单一需求的实现闭环 — 从需求解析到验收标准全部通过 + 泛化同类场景
28
+ **范围外:** 多需求编排 → `/maestro-roadmap` | 深度 debugging → `$odyssey-debug` | 代码审查 → `$odyssey-review-test-fix` | UI 优化 → `$odyssey-ui`
29
+ **探索自由度:** 边界内自由探索可自主分解任务、选择实现策略、迭代修复。verify→fix 循环内可尝试不同方案。
30
+ **模板支持:** `--template <name>` 从预定义需求模板启动,自动生成匹配的验收标准和任务分解:
31
+
32
+ | Template | 预设 criteria 模式 | 适用场景 |
33
+ |----------|-------------------|---------|
34
+ | `feature` | 用户故事验收 + 边界测试 + UI 验证 | 新功能开发 |
35
+ | `bugfix` | 回归测试 + 根因确认 + 边界覆盖 | Bug 修复 |
36
+ | `refactor` | 行为不变验证 + 性能基准 + API 兼容 | 重构 |
37
+ | `migration` | 数据一致性 + 回滚验证 + 性能对比 | 数据/API 迁移 |
38
+ | `api-endpoint` | 请求/响应契约 + 错误处理 + 权限校验 | API 开发 |
30
39
  </boundary>
31
40
 
32
- <execution_discipline>
33
- **三条铁律(所有阶段适用):**
34
- 1. **Phase auto-commit** — 阶段完成后**自动** `git commit`,无需用户确认(session.json/evidence.ndjson 不纳入)
35
- 2. **Confident edits only, but must attempt** — only modify what you're confident about; record decisions only when genuinely requiring human judgment
36
- - Confident → edit code directly, commit
37
- - Needs decision → record `evidence.ndjson {"phase":"decision","status":"pending"}`, don't touch code
38
- - No speculative changes
39
- - ⚠️ **Decision gate** — ONLY these qualify as decisions (not fixes):
40
- - Cross-module architectural tradeoffs requiring human direction
41
- - Ambiguous business semantics where the fix could alter intended behavior
42
- - Requires new dependency or breaking API change
43
- - ❌ "Unsure how to fix", "Large scope", "Pre-existing issue" are NOT valid decision reasons — either fix it, or explain specifically why it's unfixable
44
- 3. **多 CLI 辅助** — plan 用 `--role analyze`,verify 用 cli-review delegate,fix 前后用 `--role review`
45
- </execution_discipline>
46
-
47
41
  <context>
48
42
  $ARGUMENTS — requirement description and optional flags.
49
43
 
50
44
  **Flags:**
51
45
  | Flag | Description | Default |
52
46
  |------|-------------|---------|
53
- | `--max-iterations N` | Max verify→fix cycles before escalation | 3 |
54
47
  | `--template <name>` | 预定义需求模板 | — |
48
+ | `--max-iterations N` | Max verify→fix cycles before escalation | 3 |
55
49
  | `--skip-generalize` | Skip S_GENERALIZE + S_DISCOVER | false |
56
50
  | `--auto` | CLI delegate calls without confirmation | false |
51
+ | `--method agent\|cli\|auto` | Execution method: Agent tool, CLI delegate, or auto-select | `auto` |
52
+ | `--executor <tool>` | Explicit executor tool for CLI delegate mode | First enabled in config |
53
+ | `--skip-verify` | Skip execution post-validation gate | false |
54
+ | `--heartbeat` | Enable periodic progress heartbeat | false |
57
55
  | `-y` | Auto-confirm — decisions recorded as `deferred` | false |
58
56
  | `-c` | Resume most recent session | — |
59
57
 
@@ -77,7 +75,15 @@ SESSION_DIR/
77
75
  "acceptance_criteria": [
78
76
  {"id":"AC1","criterion":"","verify_method":"test|grep|cli-review|manual","status":"pending","evidence":"","passed_at":null}
79
77
  ],
80
- "plan": { "tasks": [{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[]}], "created_at":"" },
78
+ "plan": { "tasks": [{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[],"domain":"general","executor":"agent"}], "created_at":"" },
79
+ "execution_config": {
80
+ "method": "auto",
81
+ "default_executor": "",
82
+ "domain_routing": { "frontend": "", "backend": "", "default": "agent" },
83
+ "code_review_tool": "Skip",
84
+ "verification_tool": "Auto",
85
+ "confirmed": false
86
+ },
81
87
  "iterations": [
82
88
  {"iteration":1,"started_at":"","completed_at":"","criteria_before":{"passed":0,"total":0},"criteria_after":{"passed":0,"total":0},"gaps_fixed":[],"files_modified":[]}
83
89
  ],
@@ -89,6 +95,8 @@ SESSION_DIR/
89
95
  "phase_goals": [],
90
96
  "phase_goals_all_done": false,
91
97
  "self_iteration_log": [],
98
+ "progress_metrics": "→ base",
99
+ "directions_tried": "→ base",
92
100
  "cross_phase_loops": 0, "max_loops": 5,
93
101
  "created_at": "", "updated_at": ""
94
102
  }
@@ -113,41 +121,27 @@ SESSION_DIR/
113
121
 
114
122
  | 层级 | 命令 | 作用 |
115
123
  |------|------|------|
116
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界 |
117
- | Wiki search | `maestro search "<requirement keywords>" --json` | 先前实现(top 5) |
118
- | Coding specs | `maestro load --type spec --category coding` | 编码规范 + knowhow 工具 |
124
+ | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,架构约束 |
125
+ | Wiki search | `maestro search "<requirement keywords>" --json` | 先前实现、相关决策(取 top 5) |
126
+ | Coding specs | `maestro load --type spec --category coding` | 编码规范 + 可发现的 knowhow 工具 |
119
127
  | UI specs(条件) | 若涉及前端 → `maestro load --type spec --category ui` | UI 规范 |
120
- | Role knowledge | `maestro search --category coding` → 选相关 → `maestro load --type knowhow --id <id>` | 领域知识 |
121
- | Prior sessions | `Glob(".workflow/scratch/*-planex-odyssey-*")` | 相关会话 |
128
+ | Role knowledge | `maestro search --category coding` → 选相关 → `maestro load --type knowhow --id <id>` | 累积实现领域知识 |
129
+ | Prior sessions | `Glob(".workflow/scratch/*-planex-odyssey-*")` | 相关 odyssey 会话 |
122
130
 
123
131
  ### Knowledge Persistence(S_RECORD 中写入产出文件)
124
132
 
125
- S_RECORD 将可沉淀知识 **写入 understanding.md §8 Learnings**,按分类结构化:
133
+ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §8 Learnings**,按以下分类结构化:
126
134
 
127
135
  | 分类 | 写入内容 | 后续建议命令 |
128
136
  |------|---------|-------------|
129
- | 多轮 fix cycle pattern | 问题场景 + 迭代过程 + 最终方案 | `$spec-add debug "..."` |
130
- | 可复用实现模式 | 模式描述 + 适用场景 + 代码模板 | `$spec-add coding "..."` |
131
- | 验收标准模板 | 标准模板 + verify_method 建议 | `$spec-add review "..."` |
132
- | 泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `$spec-add coding "..."` |
133
-
134
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户沉淀为永久知识。执行过程中不调用外部 skill。
137
+ | 多轮 fix cycle pattern | 问题场景 + fix 迭代过程 + 最终方案 | `/spec-add debug "..."` |
138
+ | 可复用实现模式 | 模式描述 + 适用场景 + 代码模板 | `/spec-add coding "..."` |
139
+ | 验收标准模板 | 标准模板 + verify_method 建议 | `/spec-add review "..."` |
140
+ | 泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
135
141
  </context>
136
142
 
137
143
  <self_iteration>
138
- **Quality Gate** auto-evaluate after each analytical stage. Insufficient → re-enter with expanded strategy.
139
-
140
- | Dimension | Sufficient | Insufficient |
141
- |-----------|-----------|-------------|
142
- | Coverage | All known files/modules analyzed | Missed targets discoverable via grep/git log |
143
- | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
144
- | Actionability | Each conclusion has concrete next action | Only vague "consider" recommendations |
145
-
146
- **Rules:** stage complete → evaluate 3 dims → any insufficient → re-enter (max **3 rounds** per stage). Record to evidence.ndjson `{"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{...},"expansion":"strategy"}`.
147
-
148
- **Expansion:** Round 1 = broaden scope (more dirs, more delegate angles). Round 2 = shift perspective (different CLI tool, reverse-trace from expected result). Round 3 = combine both + targeted deep-dive on remaining gaps.
149
-
150
- **Applies to:** S_PLAN, S_VERIFY, S_GENERALIZE
144
+ 适用阶段: S_PLAN, S_VERIFY, S_GENERALIZE
151
145
  </self_iteration>
152
146
 
153
147
  <csv_schema>
@@ -181,38 +175,64 @@ id,title,description,task_type,criterion_refs,deps,wave,status,findings,evidence
181
175
  - Wave 2: Generalization agents (syntax-grep, semantic-scan, structural-match, historical-grep) — parallel
182
176
  </csv_schema>
183
177
 
184
- <invariants>
185
- 1. **Acceptance criteria are iron gates** — no bypass, no "close enough"
186
- 2. **Fix targets failing criteria only** — never re-implement passing parts
187
- 3. **Iteration cap respected** max_iterations prevents infinite loops
188
- 4. **Evidence append-only** evidence.ndjson never modified
189
- 5. **Session is source of truth** session.json holds all state
190
- 6. **Phase goal tracking** each stage MUST mark its goal
191
- 7. **`-y` defers, never drops** records `deferred`, never silently skips
192
- 8. **CLI delegate is background** all `maestro delegate` use run_in_background
193
- 9. **Goal is outcome-oriented** `/goal` user-bound
194
- 10. **Invariant violation = BLOCK**
195
- </invariants>
178
+ <state_machine>
179
+
180
+ <states>
181
+ S_INTAKE — parse requirement, define acceptance criteria PERSIST: session.json + understanding.md §1
182
+ S_PLAN — decompose tasks, generate execution plan PERSIST: session.json.plan + evidence (planning) + understanding.md §2
183
+ S_EXECUTE — implement tasks PERSIST: code + evidence (execution) + understanding.md §3
184
+ S_VERIFY — iron gate: check every acceptance criterion PERSIST: evidence (verification) + understanding.md §4
185
+ S_FIX — targeted fix for failing criteria (loops to VERIFY) PERSIST: code + evidence (fix) + understanding.md §5
186
+ S_GENERALIZE — extract patterns, 4-agent scan PERSIST: session.json.patterns + understanding.md §6
187
+ S_DISCOVER — triage scan hits, route decisions PERSIST: evidence (discovery|decision) + understanding.md §7
188
+ S_RECORD — persist learnings, final summary PERSIST: understanding.md §8 + spec entries
189
+ </states>
190
+
191
+ <transitions>
192
+ S_INTAKE → S_INTAKE WHEN -c + session found (resume)
193
+ S_INTAKE → S_PLAN WHEN requirement + criteria defined
194
+ S_INTAKE → S_INTAKE WHEN no requirement → request_user_input
195
+
196
+ S_PLAN → S_EXECUTE
197
+ S_EXECUTE → S_VERIFY
198
+
199
+ S_VERIFY → S_GENERALIZE WHEN all passed AND NOT skip_generalize
200
+ S_VERIFY → S_RECORD WHEN all passed AND skip_generalize
201
+ S_VERIFY → S_FIX WHEN some failed AND iteration < max
202
+ S_VERIFY → S_PLAN WHEN fundamental plan flaw discovered, loops < max_loops → cross_phase_loops++ (重规划)
203
+ S_VERIFY → S_RECORD WHEN some failed AND iteration >= max (escalate)
204
+
205
+ S_FIX → S_VERIFY (loop)
206
+
207
+ S_GENERALIZE → S_DISCOVER WHEN hits found
208
+ S_GENERALIZE → S_RECORD WHEN no hits
209
+
210
+ S_DISCOVER → S_EXECUTE : discovery finds area needing same implementation → cross_phase_loops++
211
+ S_DISCOVER → S_RECORD : triage complete AND remaining_actionable == 0
212
+ S_DISCOVER → S_RECORD : loops >= max_loops → MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
213
+
214
+ S_RECORD → END
215
+ </transitions>
196
216
 
197
- <execution>
217
+ <actions>
198
218
 
199
- ### S_INTAKE
219
+ ### A_INTAKE
200
220
 
201
- 1. Parse requirement and flags, create SESSION_DIR
221
+ 1. Parse requirement and flags, generate slug, create SESSION_DIR
202
222
  2. **Define acceptance criteria** — analyze requirement → derive testable criteria. Each gets `verify_method`: test | grep | cli-review | manual
203
- - **Normal**: `request_user_input` to confirm/edit
223
+ - **Normal**: request_user_input to confirm/edit
204
224
  - **`-y`**: auto-derive, record `{"phase":"decision","type":"criteria-confirmation","status":"deferred"}`
205
225
  3. Search prior knowledge: `maestro search`, related sessions
206
- 4. Write session.json + understanding.md §1. Mark G1 done. Display Goal Prompt (see Appendix).
226
+ 4. Write session.json + understanding.md §1. Mark G1 done. Display Goal Prompt (see Appendix)
207
227
 
208
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_INTAKE — 目标解析"`
228
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): INTAKE — 目标解析"`
209
229
 
210
- ### S_PLAN
230
+ ### A_PLAN
211
231
 
212
232
  1. Decompose requirement into ordered tasks mapped to acceptance criteria
213
233
  2. CLI-assisted planning (optional):
214
234
  ```bash
215
- maestro delegate "PURPOSE: Create plan for: {requirement}
235
+ maestro delegate "PURPOSE: Create implementation plan for: {requirement}
216
236
  TASK: Decompose into subtasks | Map to acceptance criteria | Identify dependencies
217
237
  MODE: analysis
218
238
  CONTEXT: @**/* | Criteria: {criteria_summary}
@@ -222,27 +242,168 @@ id,title,description,task_type,criterion_refs,deps,wave,status,findings,evidence
222
242
  Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
223
243
  3. Write session.json.plan, append evidence (planning), update understanding.md §2. Mark G2 done.
224
244
 
225
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_PLAN计划"`
245
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): PLAN计划制定"`
246
+
247
+ ### A_EXECUTE
248
+
249
+ #### Step 1: Execution Options Confirmation
250
+
251
+ **Skip if** `-y` flag OR `--method` explicitly set OR `execution_config.confirmed == true` (resume).
252
+
253
+ Load available tools: `maestro delegate-config show --json` → extract enabled tools and domain tags.
254
+
255
+ ```
256
+ request_user_input({
257
+ questions: [
258
+ {
259
+ question: "任务如何执行?选择一种方式,或 Other 指定域路由规则(如 '前端agy 后端codex 其余agent')",
260
+ header: "Executor",
261
+ options: [
262
+ { label: "Auto (Recommended)", description: "域路由: frontend→{frontendTool}, backend→{backendTool}, general→agent" },
263
+ { label: "Agent", description: "Claude Code Agent 执行所有任务(最快)" },
264
+ ...availableTools.map(t => ({ label: t, description: `${t} CLI 执行所有任务` }))
265
+ ]
266
+ },
267
+ {
268
+ question: "执行后运行代码审查?",
269
+ header: "Review",
270
+ options: [
271
+ { label: "Skip", description: "不审查" },
272
+ ...availableTools.map(t => ({ label: `${t} Review`, description: `${t} CLI: git diff 质量审查` }))
273
+ ]
274
+ },
275
+ {
276
+ question: "验证门控?(外部模型检查收敛 + 结构 + 反模式)",
277
+ header: "Verify",
278
+ options: [
279
+ { label: "Auto (Recommended)", description: `Delegate 到 ${availableTools[0]} 做收敛+结构+反模式检查` },
280
+ ...availableTools.map(t => ({ label: t, description: `${t}: 验证门控` })),
281
+ { label: "Skip", description: "不验证" }
282
+ ]
283
+ }
284
+ ]
285
+ })
286
+ ```
287
+
288
+ Parse response → write `execution_config` to session.json, set `confirmed: true`.
289
+
290
+ `--skip-verify` flag overrides verification to `"Skip"`.
291
+
292
+ #### Step 2: Executor Resolution
293
+
294
+ Per-task domain routing (when method == "auto"):
295
+
296
+ | Domain | Keywords / Patterns | File Extensions |
297
+ |--------|-------------------|-----------------|
298
+ | frontend | UI, component, page, style, layout, CSS, view | .tsx/.jsx/.vue/.css/.html/.svelte |
299
+ | backend | API, server, database, service, algorithm, worker | .go/.rs/.java/.py/.sql/.proto |
300
+ | general | mixed, config, tests, unclear | .ts/.js/other |
301
+
302
+ Resolution: `execution_config.domain_routing[domain]` → fallback `domain_routing.default` ("agent").
303
+
304
+ #### Step 3: Task Execution
305
+
306
+ Execute tasks per plan order. Independent tasks (no cross-dependency) may run in parallel.
307
+
308
+ **Agent path:**
309
+ ```
310
+ Spawn Agent with:
311
+ task definition, acceptance criteria refs, prior task summaries, specs_content
312
+ Agent implements → verifies convergence criteria → auto-fix (max 3) → returns result
313
+ ```
314
+
315
+ **CLI path (via maestro delegate):**
316
+ ```bash
317
+ maestro delegate "PURPOSE: Implement task ${task_id}: ${title}; success = criteria ${criteria_refs} satisfied
318
+ TASK: ${description} | Read existing code first | Verify convergence criteria after changes
319
+ MODE: write
320
+ CONTEXT: @${scope}/**/* | Criteria: ${criteria_summary}
321
+ EXPECTED: Working code changes, convergence evidence, summary of what was done
322
+ CONSTRAINTS: Scope limited to task files | Follow project specs
323
+
324
+ ## Acceptance Criteria (must satisfy)
325
+ ${criteria_refs.map(ref => criteria[ref].criterion).join('\n')}
326
+
327
+ ## Implementation Steps
328
+ ${task.description}
329
+
330
+ ## Project Specs
331
+ ${specs_content}
332
+
333
+ ## Prior Task Summaries
334
+ ${prior_summaries}
335
+ " --to ${resolved_executor} --mode write --id planex-${slug}-${task_id}
336
+ ```
337
+
338
+ Run CLI delegate with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
339
+
340
+ **Deviation Rule** — max 3 auto-fix attempts per task:
341
+ 1. First attempt: normal dispatch
342
+ 2. Retry: `--resume planex-${slug}-${task_id}` with simplified prompt
343
+ 3. Final: fallback to Agent path
344
+ 4. All 3 fail → mark task `blocked`, record checkpoint, continue remaining tasks
226
345
 
227
- ### S_EXECUTE
346
+ #### Step 4: Per-Task Evidence
228
347
 
229
- 1. Execute tasks sequentially — implement code changes
230
- 2. Per task: record evidence (execution), update task status
231
- 3. Update understanding.md §3. Mark G3 done.
348
+ Per completed task:
349
+ - Record evidence: `{"phase":"execution","type":"task-completed","task_id":"T1","executor":"agent|agy|...","files_modified":[],"summary":"","attempt":1}`
350
+ - Update task status in session.json plan
232
351
 
233
- 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-planex({slug}): S_EXECUTE — 执行"`
352
+ #### Step 5: Post-Execution Validation
234
353
 
235
- ### S_VERIFY
354
+ **Skip if** `execution_config.verification_tool == "Skip"` OR `--skip-verify` OR no completed tasks.
355
+
356
+ **Check 1: Summary Consistency** — cross-check task status vs actual file changes (git diff).
357
+
358
+ **Check 2: CLI Verification Gate** — delegate to external model:
359
+ ```bash
360
+ maestro delegate "PURPOSE: Verify execution output meets acceptance criteria; success = all criteria verified with file:line evidence
361
+ TASK:
362
+ 1. CONVERGENCE: For each criterion, read actual code, verify behavior exists, report status with evidence
363
+ 2. EXISTENCE: Verify all expected files exist on disk
364
+ 3. SUBSTANCE: Verify real implementation — flag stubs, placeholders, TODO-only
365
+ 4. ANTI-PATTERNS: Scan for TODO/FIXME/HACK, console.log debug, disabled tests
366
+ MODE: analysis
367
+ CONTEXT: @${modified_files}
368
+ EXPECTED: JSON { convergence: [{criterion, status, evidence}], issues: [{type, file, line, severity}], overall: passed|gaps_found }
369
+ CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line
370
+
371
+ ## Acceptance Criteria (verify each)
372
+ ${acceptance_criteria.map(c => c.criterion).join('\n')}
373
+
374
+ ## Modified Files
375
+ ${modified_files.join('\n')}
376
+ " --to ${execution_config.verification_tool} --mode analysis
377
+ ```
378
+
379
+ Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
380
+
381
+ On result:
382
+ - `overall == "passed"` → proceed to S_VERIFY (criteria gate) with boosted confidence
383
+ - `overall == "gaps_found"` → log findings, proceed to S_VERIFY (criteria will catch failures)
384
+
385
+ **Check 3: Code Review** (if `execution_config.code_review_tool != "Skip"`):
386
+ ```bash
387
+ maestro delegate "Review git diff for correctness, style, bugs" --to ${code_review_tool} --mode analysis --rule analysis-review-code-quality
388
+ ```
236
389
 
237
- Iron gate every acceptance criterion verified.
390
+ #### Step 6: Completion
391
+
392
+ Update understanding.md §3. Mark G3 done.
393
+
394
+ 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-planex({slug}): EXECUTE — 实现执行"`
395
+
396
+ ### A_VERIFY
397
+
398
+ Iron gate — every acceptance criterion checked objectively.
238
399
 
239
400
  **Verify each criterion by method:**
240
401
  | Method | Action |
241
402
  |--------|--------|
242
403
  | `test` | Run relevant tests, check pass/fail |
243
404
  | `grep` | Grep for expected pattern |
244
- | `cli-review` | `spawn_agents_on_csv` Wave 1 (see below) |
245
- | `manual` | **Normal**: `request_user_input` / **`-y`**: `deferred` |
405
+ | `cli-review` | `spawn_agents_on_csv` Wave 1 (see csv_schema) |
406
+ | `manual` | **Normal**: request_user_input / **`-y`**: record `deferred` |
246
407
 
247
408
  **Wave 1 — cli-review verification via spawn_agents_on_csv:**
248
409
  ```csv
@@ -255,31 +416,34 @@ spawn_agents_on_csv({ csv_path: "tasks.csv", id_column: "id",
255
416
  output_csv_path: "wave-1-results.csv", output_schema: SHARED_OUTPUT_SCHEMA })
256
417
  ```
257
418
 
258
- Record per criterion to evidence (verification). Update acceptance_criteria[].status. Append to iterations[]. Update understanding.md §4 with pass/fail table.
419
+ Record per criterion: `{"phase":"verification","type":"criterion-check","criterion_id":"AC1","method":"","result":"passed|failed","evidence":"","iteration":N}`. Update acceptance_criteria[].status. Append to iterations[].
420
+
421
+ Update understanding.md §4 with pass/fail table.
259
422
 
260
- **Route:** all passed → mark G4 done → next state. Some failed + iteration < max → S_FIX. Fundamental plan flaw → S_PLAN (cross_phase_loops++, re-plan). Some failed + iteration >= max → **Normal**: `request_user_input` (continue/lower/accept) / **`-y`**: `deferred`, proceed S_RECORD.
423
+ **Route:** all passed → mark G4 done → next state. Some failed + iteration < max → S_FIX. Some failed + iteration >= max → **Normal**: request_user_input (continue/lower bar/accept) / **`-y`**: `deferred`, proceed S_RECORD.
261
424
 
262
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_VERIFY验证"`
425
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): VERIFY验收验证"`
263
426
 
264
- ### S_FIX
427
+ ### A_FIX
265
428
 
266
429
  1. Increment current_iteration
267
430
  2. For each failed criterion: diagnose gap → targeted code fix
268
- 3. CLI fix review (optional): `maestro delegate --role review --mode analysis` for regression check
269
- 4. Append evidence (fix), update understanding.md §5 → S_VERIFY (loop)
270
-
271
- 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-planex({slug}): S_FIX — 修复"`
431
+ 3. CLI fix review (optional):
432
+ ```bash
433
+ maestro delegate "PURPOSE: Review fixes for failing criteria
434
+ TASK: Check fix correctness | Verify no regressions on passing criteria
435
+ MODE: analysis
436
+ CONTEXT: @{modified_files} | Passing: {passing} | Fixed: {fixed}
437
+ EXPECTED: JSON {verdict, regression_risk, concerns}
438
+ " --role review --mode analysis
439
+ ```
440
+ 4. Append evidence (fix), update understanding.md §5 → S_VERIFY
272
441
 
273
- ### S_GENERALIZE
442
+ 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-planex({slug}): FIX — 修复"`
274
443
 
275
- Skip if `--skip-generalize`. Extract reusable patterns, scan codebase for similar sites.
444
+ ### A_GENERALIZE
276
445
 
277
- **Pattern extraction (3 layers):**
278
- | Layer | Method | Example |
279
- |-------|--------|---------|
280
- | Syntax | Code regex patterns | validation/error handling patterns |
281
- | Semantic | Logic pattern description | missing similar checks at other entry points |
282
- | Structural | File/module structure match | sibling modules lacking same treatment |
446
+ base A_GENERALIZE 执行。
283
447
 
284
448
  **Wave 2 — 4-agent scan via spawn_agents_on_csv:**
285
449
  ```csv
@@ -289,38 +453,21 @@ Skip if `--skip-generalize`. Extract reusable patterns, scan codebase for simila
289
453
  "gen-historical","Historical Grep","git log -S for similar patterns","generalization","historical","","2","pending","","",""
290
454
  ```
291
455
 
292
- Each returns: `[{pattern_id, file, line, context, risk_level, layer, confidence}]`
456
+ Pattern 来源: implementation patterns。Mark G5 done.
293
457
 
294
- **Cross-layer dedup:** multi-layer hit on same file:line → boost confidence. Historical hit with existing fix `already_handled`. Single layer only → `needs_review`.
458
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): GENERALIZE 泛化扫描"`
295
459
 
296
- **Quality Gate** (self-iteration) → evaluate coverage/depth/actionability.
460
+ ### A_DISCOVER
297
461
 
298
- Write understanding.md §6, generalization_stats. Mark G5 done.
462
+ base A_DISCOVER 执行。Mark G6 done.
299
463
 
300
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_GENERALIZE泛化"`
464
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): DISCOVER发现分类"`
301
465
 
302
- ### S_DISCOVER
303
-
304
- 1. **Triage:** per hit, read context (+-10 lines), classify as `already_handled` | `needs_treatment` | `low_risk`
305
- 2. **Route:**
306
- | Classification | Normal | `-y` |
307
- |---------------|--------|------|
308
- | needs_treatment | `request_user_input`: create issue / plan next iter | auto create issue, `deferred` |
309
- | low_risk | Record only | Record only |
310
- | already_handled | Skip | Skip |
311
- 3. **Cross-phase loop / exit transitions:**
312
- - S_DISCOVER → S_EXECUTE: needs_treatment area → cross_phase_loops++
313
- - S_DISCOVER → S_RECORD: triage complete AND remaining_actionable == 0
314
- - S_DISCOVER → S_RECORD: loops >= max_loops → MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
315
- 4. Append evidence (discovery + decision), update understanding.md §7. Mark G6 done.
316
-
317
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_DISCOVER — 发现"`
318
-
319
- ### S_RECORD
466
+ ### A_RECORD
320
467
 
321
468
  1. Finalize understanding.md §8 — iteration summary, what worked, what needed rework
322
- 2. Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的后续命令
323
- 3. Pending decisions: **Normal** → `request_user_input`. **`-y`** → display deferred count.
469
+ 2. Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录
470
+ 3. Pending decisions: **Normal** → request_user_input. **`-y`** → display deferred count.
324
471
  4. Goal audit: check all phase_goals[*].completion_confirmed. Mark G7 done.
325
472
  5. Output completion summary:
326
473
  ```
@@ -337,25 +484,34 @@ Write understanding.md §6, generalization_stats. Mark G5 done.
337
484
  Status: {ALL_PASSED|PARTIAL|ESCALATED}
338
485
  ---
339
486
  ```
487
+ 6. 其余按 base A_RECORD 执行。
340
488
 
341
- **Next steps:** `$odyssey-review-test-fix <changed-files>`, `$odyssey-debug "<failing>"`, `$quality-review`, `$manage-issue list --source odyssey-planex`
489
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): RECORD 会话总结"`
342
490
 
343
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): S_RECORD — 总结"`
344
- </execution>
491
+ </actions>
345
492
 
346
493
  <appendix>
347
494
 
348
495
  ### Goal Prompt Template
349
496
 
350
- **⚠️ 时机守卫:仅在 Stage 1 完成后显示一次(session 创建后、开始 Plan 前)。Stage 9 完成时禁止重新显示。**
497
+ **⚠️ 时机守卫:仅在 A_INTAKE 完成后显示一次(session 创建后、开始 Plan 前)。A_RECORD 完成时禁止重新显示。**
351
498
 
352
499
  ```
353
- 📋 Planex Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
354
-
355
- /goal 穷尽迭代:直到 acceptance_criteria[*] 全部 status==passed
500
+ 📋 Planex Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
501
+
502
+ /goal 完成以下目标:
503
+ {for each G in phase_goals where status != "skipped":}
504
+ - {G.id}: {G.goal} — 完成条件: {G.done_when}
505
+ {end for}
506
+ 验收标准:
507
+ {for each AC in acceptance_criteria:}
508
+ - {AC.id}: {AC.criterion} (验证方式: {AC.verify_method})
509
+ {end for}
510
+ 穷尽迭代:直到 acceptance_criteria[*] 全部 status==passed
356
511
  且 phase_goals_all_done=true 才停。verify 失败自动 fix→re-verify 循环。
357
512
  每轮修复后重新验证,新发现的标准违反继续修,不超过 max_iterations。
358
513
  遇到 phase=decision 的 pending 必须 request_user_input,不得自行 resolve。
514
+ 不允许"接近通过",验收标准必须 ALL pass。
359
515
  ```
360
516
 
361
517
  完成时仅输出 completion summary,不重复此提示。
@@ -365,6 +521,8 @@ Write understanding.md §6, generalization_stats. Mark G5 done.
365
521
  | Decision Point | Normal | `-y` |
366
522
  |----------------|--------|------|
367
523
  | S_INTAKE criteria confirmation | request_user_input | auto-derive, `deferred` |
524
+ | S_EXECUTE execution options | request_user_input (executor/review/verify) | use defaults (auto/Skip/Auto), `confirmed: true` |
525
+ | S_EXECUTE task blocked (3 retries) | request_user_input: continue or stop | auto continue, log blocked |
368
526
  | S_VERIFY manual criterion | request_user_input | `deferred` |
369
527
  | S_VERIFY max iteration reached | request_user_input | auto accept, `deferred` |
370
528
  | S_DISCOVER classification routing | request_user_input | auto create issue, `deferred` |
@@ -375,48 +533,48 @@ Write understanding.md §6, generalization_stats. Mark G5 done.
375
533
  ### Iteration Model
376
534
 
377
535
  ```
378
- S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER ──remaining_actionable==0──→ S_RECORD
379
- │ │
536
+ S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER S_RECORD
537
+ │ │
380
538
  some fail + iter < max no hits ─→ S_RECORD
381
-
382
- S_FIX ──→ S_VERIFY (loop) needs_treatment → S_EXECUTE (cross_phase_loops++)
539
+
540
+ S_FIX ──→ S_VERIFY (loop)
383
541
  ```
384
542
 
385
- Max iterations (default 3) prevents infinite loops. Each iteration records criteria_before, gaps_fixed, criteria_after. S_DISCOVER exits to S_RECORD only when all actionable items are resolved or max_loops is reached (with per-item justification required).
386
-
387
- ### Phase Goal Lifecycle
388
-
389
- `pending → done | skipped | failed`
543
+ Max iterations (default 3) prevents infinite loops. Each iteration records criteria_before, gaps_fixed, criteria_after.
390
544
 
391
545
  </appendix>
392
546
 
547
+ </state_machine>
548
+
393
549
  <error_codes>
394
550
  | Code | Severity | Condition | Recovery |
395
551
  |------|----------|-----------|----------|
396
552
  | E001 | error | No requirement provided | Provide requirement |
397
- | E003 | error | Resume but no session found | Start new |
398
- | E004 | error | Delegate failed | Retry or skip |
399
- | W001 | warning | No criteria derived | Manual definition |
400
- | W002 | warning | Max iterations, criteria failing | Escalate |
401
- | W003 | warning | CLI regression concern | Review before next |
402
- | W004 | warning | Delegate parse failed | Raw output |
553
+ | W001 | warning | No acceptance criteria derived | Manual definition needed |
554
+ | W002 | warning | Max iterations reached, criteria still failing | Escalate to user |
555
+ | W003 | warning | CLI review regression concern | Review before next iteration |
403
556
  </error_codes>
404
557
 
405
558
  <success_criteria>
406
- - [ ] Requirement parsed and ≥1 acceptance criterion defined with verify_method
407
- - [ ] Plan created with tasks mapped to criteria
408
- - [ ] Tasks executed with evidence logged
409
- - [ ] Every criterion verified by its method after each iteration
410
- - [ ] Failing criteria trigger targeted fix (not full re-implementation)
411
- - [ ] Iteration count tracked, max respected
412
- - [ ] understanding.md updated per phase (§1-§8)
413
- - [ ] Multi-layer generalization + 4-agent scan (unless --skip-generalize)
414
- - [ ] Discoveries classified and routed (unless --skip-generalize)
415
- - [ ] Quality Gate self-iteration triggered when insufficient, logged in self_iteration_log
416
- - [ ] phase_goals G1-G7 tracked and audited
417
- - [ ] Goal Prompt displayed once after intake
418
- - [ ] `-y` mode: no blocking prompts, deferred counted
419
- - [ ] Session resumable via -c
420
- - [ ] Completion summary with iteration stats
421
- - [ ] **Every unfixed criterion has individual classification and reason** — blanket "pre-existing" labels are forbidden
559
+ - [ ] Requirement parsed with ≥1 acceptance criterion (verify_method assigned)
560
+ - [ ] Plan tasks mapped to criteria; execution options confirmed
561
+ - [ ] Tasks dispatched via resolved executor with deviation rule (max 3 retries)
562
+ - [ ] Post-execution validation gate run (unless --skip-verify)
563
+ - [ ] Every criterion verified per method; failing → targeted fix (not re-implementation)
564
+ - [ ] Iteration count tracked and max respected; unfixed criteria individually classified
565
+ - [ ] understanding.md §1-§8 updated per phase; phase_goals G1-G7 audited
566
+ - [ ] Generalization + discovery completed (unless --skip-generalize)
567
+ - [ ] Quality Gate self-iteration triggered when insufficient
568
+ - [ ] Goal Prompt displayed once after intake; `-y` mode: no blocking prompts
569
+ - [ ] Session resumable via -c; completion summary output
422
570
  </success_criteria>
571
+
572
+ <next_step_routing>
573
+ | Condition | Next step |
574
+ |-----------|-----------|
575
+ | All criteria passed | `$odyssey-review-test-fix <changed-files>` |
576
+ | Max iterations, still failing | `$odyssey-debug "<failing criterion>"` |
577
+ | Want formal review | `$quality-review <phase>` |
578
+ | Issues from discoveries | `/manage-issue list --source planex-odyssey` |
579
+ | Pattern worth documenting | `$learn-decompose <module>` |
580
+ </next_step_routing>