maestro-flow 0.5.3 → 0.5.31

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