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