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,416 +14,403 @@ 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
- Deep code review with exhaustive fix and generalization: archaeology → explore → multi-dimensional
19
- review → fix ALL findings → confirm → generalize (举一反三) → discover → persist.
20
-
21
- Unlike `quality-review` (pipeline gate verdict), this goes deeper: exhaustive documentation,
22
- automated fix, codebase-wide generalization, decision journal. Use `--skip-fix` for review-only.
23
-
24
- **三句哲学约束(穷尽迭代):**
25
- 1. **零遗留**每个 finding 必须是 action item(修复 / issue / 决策),不允许只报告不处理
26
- 2. **穷尽迭代** — 按 severity 从高到低逐轮修复,直到 0 remaining actionable findings 才退出 fix loop
27
- 3. **改进即标准** — 每次修复后重审同区域,发现新问题继续修,直到该区域无可改善
28
-
29
- Core behaviors:
30
- - **Find one, fix one, find all** — every finding triggers fix + codebase-wide scan
31
- - **Record everything** — ambiguous items → decision journal, never silent skip
32
- - **CLI-assisted** delegate for multi-angle analysis and verification
33
- </purpose>
34
-
35
- <boundary>
36
- **范围内:** 目标代码的多维度深度审查穷尽修复 ALL 发现(按 severity 递降)→ 泛化 pattern 到全项目
37
- **范围外:** 深度根因调查(根因不明时)→ `/odyssey-debug` | 需求实现 `/odyssey-planex` | UI 视觉优化 → `/odyssey-ui`
38
- **探索自由度:** 边界内自由探索 — 可跨维度关联发现、追溯 git 历史、泛化扫描全项目。修复仅限 critical/high findings。
39
- </boundary>
40
-
41
- <execution_discipline>
42
- **三条铁律(所有阶段适用):**
43
-
44
- 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
45
- - 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-review({slug}): {phase} — {摘要}"`
46
- - session.json / evidence.ndjson 为运行时状态,不纳入 commit
47
-
48
- 2. **有把握才改** — 仅修改自己有把握的内容;不确定的记录决策等人判断
49
- - 有把握 直接修改代码,commit
50
- - 需要决策 → 记录 `evidence.ndjson {"phase":"decision","status":"pending"}` 不改代码
51
- - 禁止猜测性修改
52
-
53
- 3. **多 CLI 辅助** 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
54
- - 关键判断用不同 `--role`(analyze / review / explore)获取多视角
55
- - 修复前后各做一次 CLI review 确认
56
- </execution_discipline>
57
-
58
- <context>
59
- $ARGUMENTS target and optional flags.
60
-
61
- **Target resolution:**
62
- | Input | Resolution |
63
- |-------|-----------|
64
- | File/dir path | Review those files |
65
- | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
66
- | Phase number | Resolve via state.json → changed files |
67
- | PR number | `git diff main...HEAD` |
68
-
69
- **Flags:**
70
- | Flag | Effect | Default |
71
- |------|--------|---------|
72
- | `--dimensions <list>` | Comma-separated subset | correctness,security,performance,architecture |
73
- | `--fix-threshold <severity>` | 修复到哪个 severity 为止(all = 全部修复)| `all` |
74
- | `--skip-fix` | Review-only — skip S_FIX and S_CONFIRM | false |
75
- | `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER | false |
76
- | `--auto` | CLI delegates without confirmation | false |
77
- | `-y` | Auto-confirm at decision points (see appendix) | false |
78
- | `-c` | Resume most recent session | — |
79
-
80
- **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
81
-
82
- **Output 4 files:**
83
- ```
84
- SESSION_DIR/
85
- ├── session.json # state + review_result + confirmation + patterns + phase_goals
86
- ├── evidence.ndjson # ALL evidence (phase: archaeology|explore|review|fix|discovery|decision)
87
- ├── explore.json # CLI exploration snapshot
88
- └── understanding.md # 8-section evolving narrative (§1-§8, one per major phase)
89
- ```
90
-
91
- **session.json schema:**
92
- ```json
93
- {
94
- "session_id": "review-odyssey-{YYYYMMDD-HHmmss}",
95
- "target": "", "dimensions": [],
96
- "flags": { "skip_fix": false, "skip_generalize": false, "fix_threshold": "all", "auto": false, "auto_confirm": false },
97
- "current_state": "S_INTAKE",
98
- "review_result": { "dimensions_reviewed": [], "finding_count": 0, "severity_distribution": { "critical": 0, "high": 0, "medium": 0, "low": 0 }, "remaining_actionable": 0 },
99
- "patterns": [{ "id": "P1", "source_finding": "F1", "layer": "syntax|semantic|structural", "signature": "", "description": "", "risk": "", "fix_template": "", "confidence": "high|medium|low" }],
100
- "confirmation": { "test_result": {}, "cli_review": {}, "overall": "confirmed|needs_rework" },
101
- "generalization_stats": { "patterns_extracted": 0, "total_hits": 0, "true_positives": 0, "false_positives": 0, "uncertain": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {}, "deepening_triggered": false, "self_iteration_rounds": 0 },
102
- "phase_goals": [], "phase_goals_all_done": false,
103
- "self_iteration_log": [],
104
- "cross_phase_loops": 0, "max_loops": 3,
105
- "created_at": "", "updated_at": ""
106
- }
107
- ```
108
-
109
- **evidence.ndjson unified schema:** `{"ts":"","phase":"<phase>","type":"<type>","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","files_modified":[]}`
110
-
111
- **phase_goals[]:**
112
- | ID | Goal | Done When | Phase | skip_when |
113
- |----|------|-----------|-------|-----------|
114
- | G1 | Review completed | all dimensions reviewed, findings logged | S_REVIEW | — |
115
- | G2 | Explore context gathered | explore.json populated | S_EXPLORE | |
116
- | G3 | Zero remaining: all findings fixed | `remaining_actionable == 0` within fix_threshold | S_CONFIRM | skip_fix |
117
- | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
118
- | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
119
- | G6 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
120
-
121
- Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`)
122
-
123
- ### Pre-load(可选,缺失不阻塞)
124
-
125
- | 层级 | 命令 | 作用 |
126
- |------|------|------|
127
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,架构约束 |
128
- | Wiki search | `maestro search "<target keywords>" --json` | 先前 review、已知问题(取 top 5) |
129
- | Specs | `maestro spec load --category review` | review 标准、checklist、knowhow 工具 |
130
- | Role knowledge | `maestro search --category review` → 选相关 → `maestro wiki load <id>` | 累积 review 领域知识 |
131
- | Prior sessions | `find_files(".workflow/scratch/*-review-odyssey-*")` | 相关 odyssey 会话 |
132
-
133
- ### Knowledge Persistence(S_RECORD 中写入产出文件)
134
-
135
- S_RECORD 阶段将可沉淀知识 **写入 understanding.md §8 Learnings**,按以下分类结构化:
136
-
137
- | 分类 | 写入内容 | 后续建议命令 |
138
- |------|---------|-------------|
139
- | 跨维度反复 pattern | 模式描述 + 出现维度 + 建议规范 | `/spec-add review "..."` |
140
- | 安全发现 | 漏洞类型 + 触发条件 + 修复方案 | `/spec-add debug "..."` |
141
- | 架构违反 pattern | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
142
- | 可复用泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
143
-
144
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
145
- </context>
146
-
147
- <self_iteration>
148
- **Quality Gate** — auto-evaluate after each analytical phase. Insufficient → re-enter (max 2 rounds).
149
-
150
- | Dimension | Sufficient | Insufficient |
151
- |-----------|-----------|-------------|
152
- | Coverage | All known related files analyzed | Missed targets discoverable via grep/git log |
153
- | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
154
- | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
155
-
156
- **Expansion:** Round 1 = widen scope (more dirs, deeper git log, extra delegate angles). Round 2 = shift perspective (different CLI tool, reverse trace, manual reading).
157
-
158
- **Log:** `evidence.ndjson {"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{},"expansion":""}`
159
-
160
- **Applicable stages:** S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE
161
- </self_iteration>
162
-
163
- <state_machine>
164
-
165
- <states>
166
- S_INTAKE Parse target, load context, resume session PERSIST: session.json + understanding.md §1
167
- S_ARCHAEOLOGY Git history of target files PERSIST: evidence.ndjson (archaeology) + understanding.md §2
168
- S_EXPLORE — CLI-assisted structure/call-chain exploration PERSIST: explore.json + evidence.ndjson (explore) + understanding.md §3
169
- S_REVIEW — Parallel multi-dimension review (4 Agents) PERSIST: evidence.ndjson (review) + understanding.md §4
170
- S_FIX — Targeted fix for critical/high (skip if --skip-fix) PERSIST: code changes + evidence.ndjson (fix)
171
- S_CONFIRM Test + CLI review confirmation (skip if --skip-fix) PERSIST: session.json.confirmation + understanding.md §5
172
- S_GENERALIZE — Pattern extraction + 4-agent scan (skip if --skip-generalize) PERSIST: session.json.patterns + understanding.md §6
173
- S_DISCOVER — Classify hits, create issues (skip if --skip-generalize) PERSIST: evidence.ndjson (discovery|decision) + understanding.md §7
174
- S_RECORD — Knowledge persistence + final report PERSIST: understanding.md §8 + spec entries
175
- </states>
176
-
177
- <transitions>
178
- S_INTAKE:
179
- → S_INTAKE WHEN -c + session found DO A_RESUME
180
- → S_ARCHAEOLOGY WHEN target resolved DO A_INTAKE
181
- S_INTAKE WHEN no target DO ask_user
182
-
183
- S_ARCHAEOLOGYS_EXPLORE DO A_ARCHAEOLOGY
184
- S_EXPLORE → S_REVIEW DO A_EXPLORE
185
-
186
- S_REVIEW:
187
- S_FIX WHEN !skip_fix AND any findings within fix_threshold DO A_REVIEW
188
- → S_GENERALIZE WHEN (skip_fix OR no findings) AND !skip_gen DO A_REVIEW
189
- S_RECORD WHEN (skip_fix OR no findings) AND skip_gen DO A_REVIEW
190
-
191
- S_FIX S_CONFIRM DO A_FIX
192
-
193
- S_CONFIRM:
194
- → S_GENERALIZE WHEN confirmed AND !skip_gen DO A_CONFIRM
195
- → S_RECORD WHEN confirmed AND skip_gen DO A_CONFIRM
196
- → S_FIX WHEN needs_rework DO A_CONFIRM
197
-
198
- S_GENERALIZE:
199
- S_DISCOVER WHEN hits found DO A_GENERALIZE
200
- S_RECORD WHEN no hits DO A_GENERALIZE
201
-
202
- S_DISCOVER → S_FIX : discovery finds fixable sibling, !skip_fix, loops < max_loops → cross_phase_loops++
203
- S_DISCOVER S_REVIEW : discovery opens new review target, loops < max_loops cross_phase_loops++
204
- S_DISCOVER → S_RECORD : triage complete OR loops >= max_loops (剩余项 → issue/decision)
205
-
206
- S_RECORD → END DO A_RECORD
207
- </transitions>
208
-
209
- <actions>
210
-
211
- ### A_INTAKE
212
- Parse target + flags → file list. Create `SESSION_DIR`, derive `phase_goals[]` from flags.
213
- Search prior knowledge: `maestro search`, prior sessions, ARCHITECTURE.md.
214
- Write `session.json` + `understanding.md` §1. Display Goal Prompt (appendix).
215
-
216
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): INTAKE — 目标解析与上下文加载"`
217
-
218
- ### A_ARCHAEOLOGY
219
- `git log --oneline -20 -- {target_files}` + `git blame` on key regions.
220
- CLI delegate `--role analyze --mode analysis` to review past changes.
221
- Append evidence.ndjson (phase: "archaeology"). Update `understanding.md` §2.
222
-
223
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): ARCHAEOLOGY — git 考古分析"`
224
-
225
- ### A_EXPLORE
226
- CLI delegate `--role explore --mode analysis` call chains, error gaps, similar patterns.
227
- Write `explore.json`, append evidence.ndjson (phase: "explore").
228
- Update `understanding.md` §3. Mark G2 done.
229
-
230
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): EXPLORE — 代码探索完成"`
231
-
232
- ### A_REVIEW
233
- Spawn N parallel Agents (one per dimension, default 4):
234
-
235
- | Agent | Dimension | Focus |
236
- |-------|-----------|-------|
237
- | Correctness | correctness | Logic errors, boundary conditions, null/undefined, race conditions |
238
- | Security | security | Injection, XSS, CSRF, data exposure, auth bypass |
239
- | Performance | performance | Hot paths, N+1, memory leaks, unnecessary recomputation |
240
- | Architecture | architecture | Layer violations, circular deps, interface contracts, SoC |
241
-
242
- Each returns `[{title, severity, file, line, description, suggestion, cwe}]`.
243
- Merge evidence.ndjson (phase: "review"). Write `session.json.review_result`.
244
- Update `understanding.md` §4 (findings by dimension + severity matrix). Mark G1 done.
245
-
246
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): REVIEW — 多维度审查完成"`
247
-
248
- ### A_FIX
249
-
250
- **穷尽迭代修复** severity 递降逐轮修复,直到 `remaining_actionable == 0`。
251
-
252
- #### Fix Loop (severity tiers)
253
-
254
- ```
255
- fix_tiers = [critical, high, medium, low].filter(s => severity_order(s) >= severity_order(fix_threshold))
256
- for tier in fix_tiers:
257
- candidates = evidence.filter(phase=="review" AND severity==tier AND status!="fixed")
258
- if candidates.empty: continue
259
- for each candidate:
260
- read context (file:line ±20) → implement fix → append evidence (phase: "fix")
261
- run local re-review on modified area ("改进即标准"):
262
- new_findings in same region? append to current tier, continue loop
263
- tier complete → auto-commit
264
- ```
265
-
266
- **Re-review gate** ("改进即标准"): 每轮修复后,对修改区域执行轻量 re-review(同维度)。若发现新问题,追加到当前轮继续修复。单轮最多 re-review 2 次,防止无限循环。
267
-
268
- **Normal**: ask_user 确认每个 tier candidates。**`-y`**: auto-fix all, record `deferred`.
269
-
270
- **Remaining check**: 所有 tiers 完成后,count unfixed findings within fix_threshold → 写入 `review_result.remaining_actionable`。若 > 0 且未超 max_loops → 回到 tier 1 重试。
271
-
272
- 📌 **Auto-commit per tier**: `git add -A && git commit -m "odyssey-review({slug}): FIX-{tier} — {N}项修复"`
273
-
274
- ### A_CONFIRM
275
- Run tests covering modified files. CLI delegate fix review:
276
- ```
277
- maestro delegate "PURPOSE: Verify ALL fixes and confirm zero remaining improvements
278
- TASK: Verify fix correctness | Check regressions | Count remaining unfixed findings | Confirm zero-residual
279
- MODE: analysis
280
- CONTEXT: @{modified_files} | Findings: {all_findings_summary} | Diff: {git_diff}
281
- EXPECTED: JSON {verdict, findings_addressed, remaining_unfixed, regression_risk, new_findings_in_modified_area}
282
- CONSTRAINTS: Focus on correctness AND completeness flag ANY remaining actionable improvement
283
- " --role review --mode analysis
284
- ```
285
- Run_in_background, STOP, wait.
286
-
287
- **Zero-residual gate:**
288
- - `remaining_unfixed == 0 AND new_findings == 0` → `confirmed`, mark G3 done
289
- - `remaining_unfixed > 0 OR new_findings > 0` `needs_rework` S_FIX(追加新发现)
290
- - Regression detected `needs_rework`S_FIX
291
-
292
- Write `session.json.confirmation` + update `review_result.remaining_actionable`.
293
- Update `understanding.md` §5.
294
-
295
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): CONFIRM — 零遗留验证"`
296
-
297
- ### A_GENERALIZE
298
- **Multi-layer pattern extraction** from findings (severity >= medium):
299
-
300
- | Layer | Method | Example |
301
- |-------|--------|---------|
302
- | Syntax | Regex → direct Grep | `eval(`, `innerHTML =` |
303
- | Semantic | Agent understands anti-pattern scans | Missing error handling on async |
304
- | Structural | File/module structure similarity | Same base class missing override |
305
-
306
- Write `session.json.patterns[]`.
307
-
308
- **4-agent parallel scan** (single message):
309
- 1. **Syntax grep** — Grep syntax-layer signatures across project
310
- 2. **Semantic scan** Check related modules for same anti-patterns
311
- 3. **Structural match** — Find structurally similar files, check for same issues
312
- 4. **Historical grep** — `git log -S "{pattern}"` for introduction/fix history
313
-
314
- **Cross-layer dedup**: Multi-layer hit boost confidence. Single-layer `needs_review`. Historical match on fixed code → `regression_risk`.
315
-
316
- **Iterative deepening** (conditional): High-density cluster (≥3 hits in same module) → targeted deep scan on that module. Max 1 round.
317
-
318
- **CLI validation** (optional): Delegate to validate true/false positives.
319
-
320
- Update `understanding.md` §6 (per-pattern summary, cross-layer matrix, risk heatmap).
321
- Write `session.json.generalization_stats`. Mark G4 done.
322
-
323
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): GENERALIZE — 泛化扫描完成"`
324
-
325
- ### A_DISCOVER
326
- Classify each hit: `bug` / `risk` / `safe`.
327
- **Normal**: ask_user for bug routing. **`-y`**: auto create issue, `deferred`.
328
- Append evidence (phase: discovery + decision). Update `understanding.md` §7. Mark G5 done.
329
-
330
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): DISCOVER — 发现分类完成"`
331
-
332
- ### A_RECORD
333
- Finalize `understanding.md` §8: per-dimension summary, top findings with file:line, generalization results, open decisions.
334
- Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令。
335
- Pending decisions: **Normal** ask_user. **`-y`** → skip, display deferred count.
336
- Goal audit: check all `phase_goals[*].completion_confirmed`. Mark G6 done.
337
-
338
- Completion summary:
339
- ```
340
- --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
341
- Target: {target}
342
- Dimensions: {dimensions_reviewed}
343
- Findings: {C}C {H}H {M}M {L}L
344
- Fix: {fixed} applied, confirmed={confirmed|skipped}
345
- Patterns: {extracted} ({by_layer} distribution)
346
- Scan hits: {total} ({cross_layer} cross-layer confirmed)
347
- Issues: {N} created
348
- Decisions: {N} resolved, {M} pending, {K} deferred
349
- Learnings: {N} spec entries
350
- Self-iter: {N} rounds across {M} stages
351
- Goals: {done}/{total} ({skipped} skipped)
352
- ---
353
- ```
354
-
355
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): RECORD — 会话总结与知识沉淀"`
356
-
357
- </actions>
358
-
359
- <appendix>
360
-
361
- ### Goal Prompt Template
362
- **⚠️ 时机守卫:仅在 A_INTAKE 完成后显示一次(session 创建后、开始考古前)。A_RECORD 完成时禁止重新显示。**
363
-
364
- ```
365
- 📋 Review-Test-Fix Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
366
-
367
- /goal 穷尽迭代:直到 session.json review_result.remaining_actionable == 0
368
- confirmation.verdict == "confirmed" phase_goals_all_done == true 才停。
369
- 修复按 severity 逐轮迭代(critical→high→medium→low),每轮修复后 re-review 修改区域。
370
- 发现新问题追加到当前轮继续。遇到 phase=decision pending 必须 ask_user。
371
- 不允许"只报告不处理",每个 finding 必须有 action(fix/issue/decision)。
372
- ```
373
-
374
- 完成时仅输出 completion summary,不重复此提示。
375
-
376
- ### `-y` Auto-Confirm (6 decision points)
377
- | Decision Point | Normal | `-y` |
378
- |----------------|--------|------|
379
- | S_FIX tier candidates | ask_user per tier | auto-fix ALL tiers, `deferred` |
380
- | S_FIX re-review new findings | ask_user | auto-append and fix |
381
- | S_CONFIRM needs_rework | Display, proceed to S_FIX | auto proceed |
382
- | S_DISCOVER bug routing | ask_user | auto create issue, `deferred` |
383
- | S_DISCOVER ambiguous | ask_user | all `deferred` |
384
- | S_RECORD pending decisions | ask_user | skip |
385
- | S_RECORD goal audit | ask_user | auto accept |
386
-
387
- </appendix>
388
-
389
- </state_machine>
390
-
391
- <error_codes>
392
- | Code | Severity | Condition | Recovery |
393
- |------|----------|-----------|----------|
394
- | E001 | error | No target specified | Provide target |
395
- | E002 | error | Target path not found | Check path |
396
- | E003 | error | Resume but no session | Start new |
397
- | W001 | warning | No git history for target | Proceed |
398
- | W002 | warning | Some dimension agents failed | Partial coverage |
399
- | W003 | warning | Generalization 0 hits | Skip discovery |
400
- | W004 | warning | Delegate parse failed | Raw output |
401
- </error_codes>
402
-
403
- <success_criteria>
404
- - [ ] Target resolved and session created
405
- - [ ] Git archaeology on target files
406
- - [ ] CLI exploration executed, explore.json written
407
- - [ ] All dimensions reviewed with structured findings
408
- - [ ] Severity matrix produced
409
- - [ ] **ALL findings within fix_threshold fixed** — remaining_actionable == 0 (unless --skip-fix)
410
- - [ ] Per-tier fix with re-review gate: modified area re-reviewed, new findings appended
411
- - [ ] Zero-residual confirmed by CLI external model
412
- - [ ] Pattern generalized with multi-layer scan + deepening (unless --skip-generalize)
413
- - [ ] Quality Gate self-iteration triggered when insufficient
414
- - [ ] Discoveries classified and routed
415
- - [ ] understanding.md §8 finalized
416
- - [ ] phase_goals G1-G6 tracked and audited (G3 = zero remaining)
417
- - [ ] Goal Prompt displayed once
418
- - [ ] `-y`: no blocking prompts, deferred counted
419
- - [ ] Session resumable via -c
420
- </success_criteria>
421
-
422
- <next_step_routing>
423
- | Condition | Next step |
424
- |-----------|-----------|
425
- | Finding needs deeper debug | `/odyssey-debug "<finding>"` |
426
- | Issues created | `/manage-issue list --source review-odyssey` |
427
- | Pattern to document | `/learn-decompose <module>` |
428
- | Plan fixes for findings | `/maestro-plan --gaps` |
429
- </next_step_routing>
17
+ <purpose>
18
+ Deep code review with exhaustive fix: archaeology → explore → multi-dimensional review →
19
+ fix ALL findings → confirm → generalize → discover → persist. Zero-residual philosophy.
20
+ </purpose>
21
+
22
+ <boundary>
23
+ **范围内:** 目标代码的多维度深度审查 → 穷尽修复 ALL 发现(按 severity 递降)→ 泛化 pattern 到全项目
24
+ **范围外:** 深度根因调查(根因不明时)→ `/odyssey-debug` | 需求实现 → `/odyssey-planex` | UI 视觉优化 → `/odyssey-ui`
25
+ **探索自由度:** 边界内自由探索可跨维度关联发现、追溯 git 历史、泛化扫描全项目。修复仅限 critical/high findings。
26
+ </boundary>
27
+
28
+ <execution_discipline>
29
+ **三条铁律(所有阶段适用):**
30
+
31
+ 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
32
+ - 代码变更 + understanding.md `git add` → `git commit -m "odyssey-review({slug}): {phase} — {摘要}"`
33
+ - session.json / evidence.ndjson 为运行时状态,不纳入 commit
34
+
35
+ 2. **有把握才改** — 仅修改自己有把握的内容;不确定的记录决策等人判断
36
+ - 有把握直接修改代码,commit
37
+ - 需要决策记录 `evidence.ndjson {"phase":"decision","status":"pending"}` 不改代码
38
+ - 禁止猜测性修改
39
+
40
+ 3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
41
+ - 关键判断用不同 `--role`(analyze / review / explore)获取多视角
42
+ - 修复前后各做一次 CLI review 确认
43
+ </execution_discipline>
44
+
45
+ <context>
46
+ $ARGUMENTS target and optional flags.
47
+
48
+ **Target resolution:**
49
+ | Input | Resolution |
50
+ |-------|-----------|
51
+ | File/dir path | Review those files |
52
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
53
+ | Phase number | Resolve via state.json changed files |
54
+ | PR number | `git diff main...HEAD` |
55
+
56
+ **Flags:**
57
+ | Flag | Effect | Default |
58
+ |------|--------|---------|
59
+ | `--dimensions <list>` | Comma-separated subset | correctness,security,performance,architecture |
60
+ | `--fix-threshold <severity>` | 修复到哪个 severity 为止(all = 全部修复)| `all` |
61
+ | `--skip-fix` | Review-only — skip S_FIX and S_CONFIRM | false |
62
+ | `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER | false |
63
+ | `--auto` | CLI delegates without confirmation | false |
64
+ | `-y` | Auto-confirm at decision points (see appendix) | false |
65
+ | `-c` | Resume most recent session | |
66
+
67
+ **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
68
+
69
+ **Output — 4 files:**
70
+ ```
71
+ SESSION_DIR/
72
+ ├── session.json # state + review_result + confirmation + patterns + phase_goals
73
+ ├── evidence.ndjson # ALL evidence (phase: archaeology|explore|review|fix|discovery|decision)
74
+ ├── explore.json # CLI exploration snapshot
75
+ └── understanding.md # 8-section evolving narrative (§1-§8, one per major phase)
76
+ ```
77
+
78
+ **session.json schema:**
79
+ ```json
80
+ {
81
+ "session_id": "review-odyssey-{YYYYMMDD-HHmmss}",
82
+ "target": "", "dimensions": [],
83
+ "flags": { "skip_fix": false, "skip_generalize": false, "fix_threshold": "all", "auto": false, "auto_confirm": false },
84
+ "current_state": "S_INTAKE",
85
+ "review_result": { "dimensions_reviewed": [], "finding_count": 0, "severity_distribution": { "critical": 0, "high": 0, "medium": 0, "low": 0 }, "remaining_actionable": 0 },
86
+ "patterns": [{ "id": "P1", "source_finding": "F1", "layer": "syntax|semantic|structural", "signature": "", "description": "", "risk": "", "fix_template": "", "confidence": "high|medium|low" }],
87
+ "confirmation": { "test_result": {}, "cli_review": {}, "overall": "confirmed|needs_rework" },
88
+ "generalization_stats": { "patterns_extracted": 0, "total_hits": 0, "true_positives": 0, "false_positives": 0, "uncertain": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {}, "deepening_triggered": false, "self_iteration_rounds": 0 },
89
+ "phase_goals": [], "phase_goals_all_done": false,
90
+ "self_iteration_log": [],
91
+ "cross_phase_loops": 0, "max_loops": 3,
92
+ "created_at": "", "updated_at": ""
93
+ }
94
+ ```
95
+
96
+ **evidence.ndjson unified schema:** `{"ts":"","phase":"<phase>","type":"<type>","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","files_modified":[]}`
97
+
98
+ **phase_goals[]:**
99
+ | ID | Goal | Done When | Phase | skip_when |
100
+ |----|------|-----------|-------|-----------|
101
+ | G1 | Review completed | all dimensions reviewed, findings logged | S_REVIEW | |
102
+ | G2 | Explore context gathered | explore.json populated | S_EXPLORE | — |
103
+ | G3 | Zero remaining: all findings fixed | `remaining_actionable == 0` within fix_threshold | S_CONFIRM | skip_fix |
104
+ | G4 | Pattern generalized | patterns[] ≥1 entry | S_GENERALIZE | skip_generalize |
105
+ | G5 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
106
+ | G6 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
107
+
108
+ Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`)
109
+
110
+ ### Pre-load(可选,缺失不阻塞)
111
+
112
+ | 层级 | 命令 | 作用 |
113
+ |------|------|------|
114
+ | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,架构约束 |
115
+ | Wiki search | `maestro search "<target keywords>" --json` | 先前 review、已知问题(取 top 5) |
116
+ | Specs | `maestro spec load --category review` | review 标准、checklist、knowhow 工具 |
117
+ | Role knowledge | `maestro search --category review` 选相关 `maestro wiki load <id>` | 累积 review 领域知识 |
118
+ | Prior sessions | `find_files(".workflow/scratch/*-review-odyssey-*")` | 相关 odyssey 会话 |
119
+
120
+ ### Knowledge Persistence(S_RECORD 中写入产出文件)
121
+
122
+ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §8 Learnings**,按以下分类结构化:
123
+
124
+ | 分类 | 写入内容 | 后续建议命令 |
125
+ |------|---------|-------------|
126
+ | 跨维度反复 pattern | 模式描述 + 出现维度 + 建议规范 | `/spec-add review "..."` |
127
+ | 安全发现 | 漏洞类型 + 触发条件 + 修复方案 | `/spec-add debug "..."` |
128
+ | 架构违反 pattern | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
129
+ | 可复用泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
130
+
131
+ **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
132
+ </context>
133
+
134
+ <self_iteration>
135
+ **Quality Gate** auto-evaluate after each analytical phase. Insufficient → re-enter (max 2 rounds).
136
+
137
+ | Dimension | Sufficient | Insufficient |
138
+ |-----------|-----------|-------------|
139
+ | Coverage | All known related files analyzed | Missed targets discoverable via grep/git log |
140
+ | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
141
+ | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
142
+
143
+ **Expansion:** Round 1 = widen scope (more dirs, deeper git log, extra delegate angles). Round 2 = shift perspective (different CLI tool, reverse trace, manual reading).
144
+
145
+ **Log:** `evidence.ndjson ← {"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{},"expansion":""}`
146
+
147
+ **Applicable stages:** S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE
148
+ </self_iteration>
149
+
150
+ <state_machine>
151
+
152
+ <states>
153
+ S_INTAKE — Parse target, load context, resume session PERSIST: session.json + understanding.md §1
154
+ S_ARCHAEOLOGY — Git history of target files PERSIST: evidence.ndjson (archaeology) + understanding.md §2
155
+ S_EXPLORE — CLI-assisted structure/call-chain exploration PERSIST: explore.json + evidence.ndjson (explore) + understanding.md §3
156
+ S_REVIEW — Parallel multi-dimension review (4 Agents) PERSIST: evidence.ndjson (review) + understanding.md §4
157
+ S_FIX — Targeted fix for critical/high (skip if --skip-fix) PERSIST: code changes + evidence.ndjson (fix)
158
+ S_CONFIRM — Test + CLI review confirmation (skip if --skip-fix) PERSIST: session.json.confirmation + understanding.md §5
159
+ S_GENERALIZE — Pattern extraction + 4-agent scan (skip if --skip-generalize) PERSIST: session.json.patterns + understanding.md §6
160
+ S_DISCOVER — Classify hits, create issues (skip if --skip-generalize) PERSIST: evidence.ndjson (discovery|decision) + understanding.md §7
161
+ S_RECORD — Knowledge persistence + final report PERSIST: understanding.md §8 + spec entries
162
+ </states>
163
+
164
+ <transitions>
165
+ S_INTAKE:
166
+ S_INTAKE WHEN -c + session found DO A_RESUME
167
+ S_ARCHAEOLOGY WHEN target resolved DO A_INTAKE
168
+ S_INTAKE WHEN no target DO ask_user
169
+
170
+ S_ARCHAEOLOGY → S_EXPLORE DO A_ARCHAEOLOGY
171
+ S_EXPLORE S_REVIEW DO A_EXPLORE
172
+
173
+ S_REVIEW:
174
+ S_FIX WHEN !skip_fix AND any findings within fix_threshold DO A_REVIEW
175
+ → S_GENERALIZE WHEN (skip_fix OR no findings) AND !skip_gen DO A_REVIEW
176
+ → S_RECORD WHEN (skip_fix OR no findings) AND skip_gen DO A_REVIEW
177
+
178
+ S_FIX → S_CONFIRM DO A_FIX
179
+
180
+ S_CONFIRM:
181
+ S_GENERALIZE WHEN confirmed AND !skip_gen DO A_CONFIRM
182
+ → S_RECORD WHEN confirmed AND skip_gen DO A_CONFIRM
183
+ S_FIX WHEN needs_rework DO A_CONFIRM
184
+
185
+ S_GENERALIZE:
186
+ → S_DISCOVER WHEN hits found DO A_GENERALIZE
187
+ S_RECORD WHEN no hits DO A_GENERALIZE
188
+
189
+ S_DISCOVER S_FIX : discovery finds fixable sibling, !skip_fix, loops < max_loops cross_phase_loops++
190
+ S_DISCOVER → S_REVIEW : discovery opens new review target, loops < max_loops → cross_phase_loops++
191
+ S_DISCOVER S_RECORD : triage complete OR loops >= max_loops (剩余项 → issue/decision)
192
+
193
+ S_RECORD → END DO A_RECORD
194
+ </transitions>
195
+
196
+ <actions>
197
+
198
+ ### A_INTAKE
199
+ Parse target + flags file list. Create `SESSION_DIR`, derive `phase_goals[]` from flags.
200
+ Search prior knowledge: `maestro search`, prior sessions, ARCHITECTURE.md.
201
+ Write `session.json` + `understanding.md` §1. Display Goal Prompt (appendix).
202
+
203
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): INTAKE 目标解析与上下文加载"`
204
+
205
+ ### A_ARCHAEOLOGY
206
+ `git log --oneline -20 -- {target_files}` + `git blame` on key regions.
207
+ CLI delegate `--role analyze --mode analysis` to review past changes.
208
+ Append evidence.ndjson (phase: "archaeology"). Update `understanding.md` §2.
209
+
210
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): ARCHAEOLOGY — git 考古分析"`
211
+
212
+ ### A_EXPLORE
213
+ CLI delegate `--role explore --mode analysis` call chains, error gaps, similar patterns.
214
+ Write `explore.json`, append evidence.ndjson (phase: "explore").
215
+ Update `understanding.md` §3. Mark G2 done.
216
+
217
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): EXPLORE — 代码探索完成"`
218
+
219
+ ### A_REVIEW
220
+ Spawn N parallel Agents (one per dimension, default 4):
221
+
222
+ | Agent | Dimension | Focus |
223
+ |-------|-----------|-------|
224
+ | Correctness | correctness | Logic errors, boundary conditions, null/undefined, race conditions |
225
+ | Security | security | Injection, XSS, CSRF, data exposure, auth bypass |
226
+ | Performance | performance | Hot paths, N+1, memory leaks, unnecessary recomputation |
227
+ | Architecture | architecture | Layer violations, circular deps, interface contracts, SoC |
228
+
229
+ Each returns `[{title, severity, file, line, description, suggestion, cwe}]`.
230
+ Merge evidence.ndjson (phase: "review"). Write `session.json.review_result`.
231
+ Update `understanding.md` §4 (findings by dimension + severity matrix). Mark G1 done.
232
+
233
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): REVIEW — 多维度审查完成"`
234
+
235
+ ### A_FIX
236
+
237
+ **穷尽迭代修复** severity 递降逐轮修复,直到 `remaining_actionable == 0`。
238
+
239
+ #### Fix Loop (severity tiers)
240
+
241
+ ```
242
+ fix_tiers = [critical, high, medium, low].filter(s => severity_order(s) >= severity_order(fix_threshold))
243
+ for tier in fix_tiers:
244
+ candidates = evidence.filter(phase=="review" AND severity==tier AND status!="fixed")
245
+ if candidates.empty: continue
246
+ for each candidate:
247
+ read context (file:line ±20) → implement fix → append evidence (phase: "fix")
248
+ run local re-review on modified area ("改进即标准"):
249
+ new_findings in same region? → append to current tier, continue loop
250
+ tier complete auto-commit
251
+ ```
252
+
253
+ **Re-review gate** ("改进即标准"): 每轮修复后,对修改区域执行轻量 re-review(同维度)。若发现新问题,追加到当前轮继续修复。单轮最多 re-review 2 次,防止无限循环。
254
+
255
+ **Normal**: ask_user 确认每个 tier candidates。**`-y`**: auto-fix all, record `deferred`.
256
+
257
+ **Remaining check**: 所有 tiers 完成后,count unfixed findings within fix_threshold → 写入 `review_result.remaining_actionable`。若 > 0 且未超 max_loops → 回到 tier 1 重试。
258
+
259
+ 📌 **Auto-commit per tier**: `git add -A && git commit -m "odyssey-review({slug}): FIX-{tier} — {N}项修复"`
260
+
261
+ ### A_CONFIRM
262
+ Run tests covering modified files. CLI delegate fix review:
263
+ ```
264
+ maestro delegate "PURPOSE: Verify ALL fixes and confirm zero remaining improvements
265
+ TASK: Verify fix correctness | Check regressions | Count remaining unfixed findings | Confirm zero-residual
266
+ MODE: analysis
267
+ CONTEXT: @{modified_files} | Findings: {all_findings_summary} | Diff: {git_diff}
268
+ EXPECTED: JSON {verdict, findings_addressed, remaining_unfixed, regression_risk, new_findings_in_modified_area}
269
+ CONSTRAINTS: Focus on correctness AND completeness — flag ANY remaining actionable improvement
270
+ " --role review --mode analysis
271
+ ```
272
+ Run_in_background, STOP, wait.
273
+
274
+ **Zero-residual gate:**
275
+ - `remaining_unfixed == 0 AND new_findings == 0` → `confirmed`, mark G3 done
276
+ - `remaining_unfixed > 0 OR new_findings > 0` → `needs_rework` → S_FIX(追加新发现)
277
+ - Regression detected `needs_rework` S_FIX
278
+
279
+ Write `session.json.confirmation` + update `review_result.remaining_actionable`.
280
+ Update `understanding.md` §5.
281
+
282
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): CONFIRM — 零遗留验证"`
283
+
284
+ ### A_GENERALIZE
285
+ **Multi-layer pattern extraction** from findings (severity >= medium):
286
+
287
+ | Layer | Method | Example |
288
+ |-------|--------|---------|
289
+ | Syntax | Regex direct Grep | `eval(`, `innerHTML =` |
290
+ | Semantic | Agent understands anti-pattern scans | Missing error handling on async |
291
+ | Structural | File/module structure similarity | Same base class missing override |
292
+
293
+ Write `session.json.patterns[]`.
294
+
295
+ **4-agent parallel scan** (single message):
296
+ 1. **Syntax grep** — Grep syntax-layer signatures across project
297
+ 2. **Semantic scan** — Check related modules for same anti-patterns
298
+ 3. **Structural match** Find structurally similar files, check for same issues
299
+ 4. **Historical grep** — `git log -S "{pattern}"` for introduction/fix history
300
+
301
+ **Cross-layer dedup**: Multi-layer hit → boost confidence. Single-layer → `needs_review`. Historical match on fixed code → `regression_risk`.
302
+
303
+ **Iterative deepening** (conditional): High-density cluster (≥3 hits in same module) targeted deep scan on that module. Max 1 round.
304
+
305
+ **CLI validation** (optional): Delegate to validate true/false positives.
306
+
307
+ Update `understanding.md` §6 (per-pattern summary, cross-layer matrix, risk heatmap).
308
+ Write `session.json.generalization_stats`. Mark G4 done.
309
+
310
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): GENERALIZE — 泛化扫描完成"`
311
+
312
+ ### A_DISCOVER
313
+ Classify each hit: `bug` / `risk` / `safe`.
314
+ **Normal**: ask_user for bug routing. **`-y`**: auto create issue, `deferred`.
315
+ Append evidence (phase: discovery + decision). Update `understanding.md` §7. Mark G5 done.
316
+
317
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): DISCOVER — 发现分类完成"`
318
+
319
+ ### A_RECORD
320
+ Finalize `understanding.md` §8: per-dimension summary, top findings with file:line, generalization results, open decisions.
321
+ Write learnings to understanding.md §8: Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令。
322
+ Pending decisions: **Normal** → ask_user. **`-y`** → skip, display deferred count.
323
+ Goal audit: check all `phase_goals[*].completion_confirmed`. Mark G6 done.
324
+
325
+ Completion summary:
326
+ ```
327
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
328
+ Target: {target}
329
+ Dimensions: {dimensions_reviewed}
330
+ Findings: {C}C {H}H {M}M {L}L
331
+ Fix: {fixed} applied, confirmed={confirmed|skipped}
332
+ Patterns: {extracted} ({by_layer} distribution)
333
+ Scan hits: {total} ({cross_layer} cross-layer confirmed)
334
+ Issues: {N} created
335
+ Decisions: {N} resolved, {M} pending, {K} deferred
336
+ Learnings: {N} spec entries
337
+ Self-iter: {N} rounds across {M} stages
338
+ Goals: {done}/{total} ({skipped} skipped)
339
+ ---
340
+ ```
341
+
342
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): RECORD — 会话总结与知识沉淀"`
343
+
344
+ </actions>
345
+
346
+ <appendix>
347
+
348
+ ### Goal Prompt Template
349
+ **⚠️ 时机守卫:仅在 A_INTAKE 完成后显示一次(session 创建后、开始考古前)。A_RECORD 完成时禁止重新显示。**
350
+
351
+ ```
352
+ 📋 Review-Test-Fix Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件(执行过程中输入即可):
353
+
354
+ /goal 穷尽迭代:直到 session.json 的 review_result.remaining_actionable == 0
355
+ confirmation.verdict == "confirmed" phase_goals_all_done == true 才停。
356
+ 修复按 severity 逐轮迭代(critical→high→medium→low),每轮修复后 re-review 修改区域。
357
+ 发现新问题追加到当前轮继续。遇到 phase=decision 的 pending 必须 ask_user。
358
+ 不允许"只报告不处理",每个 finding 必须有 action(fix/issue/decision)。
359
+ ```
360
+
361
+ 完成时仅输出 completion summary,不重复此提示。
362
+
363
+ ### `-y` Auto-Confirm (6 decision points)
364
+ | Decision Point | Normal | `-y` |
365
+ |----------------|--------|------|
366
+ | S_FIX tier candidates | ask_user per tier | auto-fix ALL tiers, `deferred` |
367
+ | S_FIX re-review new findings | ask_user | auto-append and fix |
368
+ | S_CONFIRM needs_rework | Display, proceed to S_FIX | auto proceed |
369
+ | S_DISCOVER bug routing | ask_user | auto create issue, `deferred` |
370
+ | S_DISCOVER ambiguous | ask_user | all `deferred` |
371
+ | S_RECORD pending decisions | ask_user | skip |
372
+ | S_RECORD goal audit | ask_user | auto accept |
373
+
374
+ </appendix>
375
+
376
+ </state_machine>
377
+
378
+ <error_codes>
379
+ | Code | Severity | Condition | Recovery |
380
+ |------|----------|-----------|----------|
381
+ | E001 | error | No target specified | Provide target |
382
+ | E002 | error | Target path not found | Check path |
383
+ | E003 | error | Resume but no session | Start new |
384
+ | W001 | warning | No git history for target | Proceed |
385
+ | W002 | warning | Some dimension agents failed | Partial coverage |
386
+ | W003 | warning | Generalization 0 hits | Skip discovery |
387
+ | W004 | warning | Delegate parse failed | Raw output |
388
+ </error_codes>
389
+
390
+ <success_criteria>
391
+ - [ ] Target resolved and session created
392
+ - [ ] Git archaeology on target files
393
+ - [ ] CLI exploration executed, explore.json written
394
+ - [ ] All dimensions reviewed with structured findings
395
+ - [ ] Severity matrix produced
396
+ - [ ] **ALL findings within fix_threshold fixed** remaining_actionable == 0 (unless --skip-fix)
397
+ - [ ] Per-tier fix with re-review gate: modified area re-reviewed, new findings appended
398
+ - [ ] Zero-residual confirmed by CLI external model
399
+ - [ ] Pattern generalized with multi-layer scan + deepening (unless --skip-generalize)
400
+ - [ ] Quality Gate self-iteration triggered when insufficient
401
+ - [ ] Discoveries classified and routed
402
+ - [ ] understanding.md §8 finalized
403
+ - [ ] phase_goals G1-G6 tracked and audited (G3 = zero remaining)
404
+ - [ ] Goal Prompt displayed once
405
+ - [ ] `-y`: no blocking prompts, deferred counted
406
+ - [ ] Session resumable via -c
407
+ </success_criteria>
408
+
409
+ <next_step_routing>
410
+ | Condition | Next step |
411
+ |-----------|-----------|
412
+ | Finding needs deeper debug | `/odyssey-debug "<finding>"` |
413
+ | Issues created | `/manage-issue list --source review-odyssey` |
414
+ | Pattern to document | `/learn-decompose <module>` |
415
+ | Plan fixes for findings | `/maestro-plan --gaps` |
416
+ </next_step_routing>