maestro-flow 0.5.38 → 0.5.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.agents/skills/odyssey-debug/SKILL.md +90 -269
  2. package/.agents/skills/odyssey-improve/SKILL.md +39 -240
  3. package/.agents/skills/odyssey-planex/SKILL.md +21 -105
  4. package/.agents/skills/odyssey-review-test-fix/SKILL.md +98 -318
  5. package/.agents/skills/odyssey-ui/SKILL.md +82 -265
  6. package/.agy/skills/odyssey-debug/SKILL.md +90 -269
  7. package/.agy/skills/odyssey-improve/SKILL.md +39 -240
  8. package/.agy/skills/odyssey-planex/SKILL.md +21 -105
  9. package/.agy/skills/odyssey-review-test-fix/SKILL.md +98 -318
  10. package/.agy/skills/odyssey-ui/SKILL.md +82 -265
  11. package/.claude/commands/odyssey-debug.md +90 -269
  12. package/.claude/commands/odyssey-improve.md +39 -240
  13. package/.claude/commands/odyssey-planex.md +21 -105
  14. package/.claude/commands/odyssey-review-test-fix.md +98 -318
  15. package/.claude/commands/odyssey-ui.md +82 -265
  16. package/.codex/skills/odyssey-debug/SKILL.md +167 -338
  17. package/.codex/skills/odyssey-improve/SKILL.md +226 -395
  18. package/.codex/skills/odyssey-planex/SKILL.md +317 -159
  19. package/.codex/skills/odyssey-review-test-fix/SKILL.md +137 -255
  20. package/.codex/skills/odyssey-ui/SKILL.md +197 -338
  21. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +23 -2
  22. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +242 -26
  23. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  24. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +2 -0
  25. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +92 -29
  26. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  27. package/dashboard/dist-server/src/commands/hooks.d.ts +2 -1
  28. package/dashboard/dist-server/src/commands/hooks.js +16 -9
  29. package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
  30. package/dashboard/dist-server/src/hooks/kg-sync-hook.js +5 -0
  31. package/dashboard/dist-server/src/hooks/kg-sync-hook.js.map +1 -1
  32. package/dashboard/dist-server/src/hooks/session-context.js +276 -3
  33. package/dashboard/dist-server/src/hooks/session-context.js.map +1 -1
  34. package/dashboard/dist-server/src/search/daemon-client.d.ts +8 -3
  35. package/dashboard/dist-server/src/search/daemon-client.js +20 -0
  36. package/dashboard/dist-server/src/search/daemon-client.js.map +1 -1
  37. package/dist/src/commands/domain.d.ts.map +1 -1
  38. package/dist/src/commands/domain.js +12 -3
  39. package/dist/src/commands/domain.js.map +1 -1
  40. package/dist/src/commands/hooks.d.ts +2 -1
  41. package/dist/src/commands/hooks.d.ts.map +1 -1
  42. package/dist/src/commands/hooks.js +16 -9
  43. package/dist/src/commands/hooks.js.map +1 -1
  44. package/dist/src/commands/install.js +33 -2
  45. package/dist/src/commands/install.js.map +1 -1
  46. package/dist/src/commands/search.d.ts.map +1 -1
  47. package/dist/src/commands/search.js +59 -6
  48. package/dist/src/commands/search.js.map +1 -1
  49. package/dist/src/commands/spec.d.ts.map +1 -1
  50. package/dist/src/commands/spec.js +15 -0
  51. package/dist/src/commands/spec.js.map +1 -1
  52. package/dist/src/hooks/kg-sync-hook.d.ts.map +1 -1
  53. package/dist/src/hooks/kg-sync-hook.js +5 -0
  54. package/dist/src/hooks/kg-sync-hook.js.map +1 -1
  55. package/dist/src/hooks/session-context.d.ts.map +1 -1
  56. package/dist/src/hooks/session-context.js +276 -3
  57. package/dist/src/hooks/session-context.js.map +1 -1
  58. package/dist/src/search/daemon-client.d.ts +8 -3
  59. package/dist/src/search/daemon-client.d.ts.map +1 -1
  60. package/dist/src/search/daemon-client.js +20 -0
  61. package/dist/src/search/daemon-client.js.map +1 -1
  62. package/dist/src/search/daemon.d.ts +3 -3
  63. package/dist/src/search/daemon.d.ts.map +1 -1
  64. package/dist/src/search/daemon.js +9 -3
  65. package/dist/src/search/daemon.js.map +1 -1
  66. package/package.json +1 -1
  67. package/workflows/odyssey-base.md +258 -0
@@ -1,13 +1,14 @@
1
1
  ---
2
2
  name: odyssey-review-test-fix
3
- description: "Deep review cycle — archaeology, exploration, multi-dimensional review, targeted fix, generalization, discovery, and detailed knowledge persistence"
4
- argument-hint: "<target> [--dimensions <list>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c]"
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] [--heartbeat]"
5
5
  allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, request_user_input
6
6
  ---
7
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
7
8
 
8
9
  <purpose>
9
- Deep code review with generalization: archaeology → explore → multi-dimensional review →
10
- fix all findings → confirm → generalize (举一反三) → discover → persist.
10
+ Deep code review with exhaustive fix: archaeology → explore → multi-dimensional review →
11
+ fix ALL findings → confirm → generalize → discover → persist. Zero-residual philosophy.
11
12
 
12
13
  **三句哲学约束(穷尽迭代):**
13
14
  1. **零遗留** — 每个 finding 必须是 action item(修复 / issue / 决策),不允许只报告不处理
@@ -21,28 +22,12 @@ Core behaviors:
21
22
  </purpose>
22
23
 
23
24
  <boundary>
24
- **范围内:** 目标代码多维度审查Fix ALL findings within fix_threshold (default: all = exhaustive across all severity levels) 泛化 pattern
25
- **范围外:** 深度根因 → `$odyssey-debug` | 需求实现 → `$odyssey-planex` | UI 优化 → `$odyssey-ui`
26
- **探索自由度:** 边界内自由跨维度关联、追溯历史、泛化全项目。穷尽修复 ALL 发现(按 severity 递降)。
27
-
28
- **Zero-residual principle:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" is not allowed. "Pre-existing issue" is not a valid skip reason — if discovered within scope, it must be addressed.
25
+ **范围内:** 目标代码的多维度深度审查穷尽修复 ALL 发现(按 severity 递降)→ 泛化 pattern 到全项目
26
+ **范围外:** 深度根因调查 → `$odyssey-debug` | 需求实现 → `$odyssey-planex` | UI 视觉优化 → `$odyssey-ui`
27
+ **探索自由度:** 边界内自由探索跨维度关联、追溯 git 历史、泛化扫描全项目。修复 ALL findings within fix_threshold(默认 all)。
28
+ **Zero-residual principle:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
29
29
  </boundary>
30
30
 
31
- <execution_discipline>
32
- **三条铁律(所有阶段适用):**
33
- 1. **Phase auto-commit** — 阶段完成后**自动** `git commit`,无需用户确认(session.json/evidence.ndjson 不纳入)
34
- 2. **Confident edits only, but must attempt** — only modify what you're confident about; record decisions only when genuinely requiring human judgment
35
- - Confident → edit code directly, commit
36
- - Needs decision → record `evidence.ndjson {"phase":"decision","status":"pending"}`, don't touch code
37
- - No speculative changes
38
- - ⚠️ **Decision gate** — ONLY these qualify as decisions (not fixes):
39
- - Cross-module architectural tradeoffs requiring human direction
40
- - Ambiguous business semantics where the fix could alter intended behavior
41
- - Requires new dependency or breaking API change
42
- - ❌ "Unsure how to fix", "Large scope", "Pre-existing issue" are NOT valid decision reasons — either fix it, or explain specifically why it's unfixable
43
- 3. **多 CLI 辅助** — `maestro delegate` 多 `--role`(analyze/review/explore)交叉验证,修复前后各 review 一次
44
- </execution_discipline>
45
-
46
31
  <context>
47
32
  $ARGUMENTS — target and optional flags.
48
33
 
@@ -51,96 +36,47 @@ $ARGUMENTS — target and optional flags.
51
36
  |-------|-----------|
52
37
  | File/dir path | Review those files |
53
38
  | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
54
- | Phase number | Resolve via state.json → changed files |
39
+ | Phase number | state.json → changed files |
55
40
  | PR number | `git diff main...HEAD` |
56
41
 
57
42
  **Flags:**
58
- | Flag | Effect |
59
- |------|--------|
60
- | `--dimensions <list>` | Comma-separated subset (default: correctness,security,performance,architecture) |
61
- | `--skip-fix` | Review-only skip S_FIX and S_CONFIRM |
62
- | `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER |
63
- | `--auto` | CLI delegates without confirmation |
64
- | `-y` | Auto-confirm at 5 decision points (see appendix) |
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, "auto": false, "auto_confirm": false },
84
- "current_state": "S_INTAKE",
85
- "review_result": { "dimensions_reviewed": [], "finding_count": 0, "severity_distribution": {} },
86
- "patterns": [{ "id": "P1", "source_finding": "", "layer": "syntax|semantic|structural", "signature": "", "description": "", "risk": "", "fix_template": "" }],
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, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {} },
89
- "phase_goals": [], "phase_goals_all_done": false,
90
- "self_iteration_log": [],
91
- "cross_phase_loops": 0, "max_loops": 5
92
- }
93
- ```
94
-
95
- **evidence.ndjson unified schema:** `{"ts":"","phase":"<phase>","type":"<type>","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","files_modified":[]}`
43
+ | Flag | Effect | Default |
44
+ |------|--------|---------|
45
+ | `--dimensions` | Comma-separated subset | correctness,security,performance,architecture |
46
+ | `--fix-threshold` | 修复到哪个 severity 为止 | `all` |
47
+ | `--skip-fix` | Skip S_FIX + S_CONFIRM | false |
48
+ | `--skip-generalize` | Skip S_GENERALIZE + S_DISCOVER | false |
49
+ | `--auto` `-y` `-c` `--heartbeat` | CLI auto / auto-confirm / resume / heartbeat | false |
50
+
51
+ **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
52
+ **Output**: session.json, evidence.ndjson, explore.json, understanding.md (§1-§8)
53
+ **session.json unique fields**: `target`, `dimensions`, `review_result` (with `remaining_actionable`), `patterns[]`, `confirmation`, `generalization_stats`
54
+ **evidence.ndjson phases**: archaeology, explore, review, fix, discovery, decision, self-iteration
96
55
 
97
56
  **phase_goals[]:**
98
- | ID | Goal | Phase | skip_when |
99
- |----|------|-------|-----------|
100
- | G1 | Review completed | S_REVIEW | — |
101
- | G2 | Explore context gathered | S_EXPLORE | — |
102
- | G3 | Fix applied and confirmed | S_CONFIRM | skip_fix |
103
- | G4 | Pattern generalized | S_GENERALIZE | skip_generalize |
104
- | G5 | Discoveries triaged | S_DISCOVER | skip_generalize |
105
- | G6 | Learnings persisted | S_RECORD | — |
106
-
107
- Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`)
108
-
109
- ### Pre-load(可选,缺失不阻塞)
110
-
111
- | 层级 | 命令 | 作用 |
112
- |------|------|------|
113
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界 |
114
- | Wiki search | `maestro search "<target keywords>" --json` | 先前 review(top 5) |
115
- | Specs | `maestro load --type spec --category review` | review 标准、checklist |
116
- | Role knowledge | `maestro search --category review` → 选相关 → `maestro load --type knowhow --id <id>` | 领域知识 |
117
- | Prior sessions | `Glob(".workflow/scratch/*-review-odyssey-*")` | 相关会话 |
118
-
119
- ### Knowledge Persistence(S_RECORD 中写入产出文件)
120
-
121
- S_RECORD 将可沉淀知识 **写入 understanding.md §8 Learnings**,按分类结构化:
122
-
123
- | 分类 | 写入内容 | 后续建议命令 |
124
- |------|---------|-------------|
125
- | 跨维度反复 pattern | 模式描述 + 出现维度 + 建议规范 | `$spec-add review "..."` |
126
- | 安全发现 | 漏洞类型 + 触发条件 + 修复方案 | `$spec-add debug "..."` |
127
- | 架构违反 pattern | 违反描述 + 正确边界 + 检查方法 | `$spec-add arch "..."` |
128
- | 可复用泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `$spec-add coding "..."` |
129
-
130
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户沉淀为永久知识。执行过程中不调用外部 skill。
57
+ | ID | Goal | Done When | Phase | skip_when |
58
+ |----|------|-----------|-------|-----------|
59
+ | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
60
+ | G2 | Explore context | explore.json populated | S_EXPLORE | — |
61
+ | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
62
+ | G4 | Pattern generalized | patterns[] ≥1 | S_GENERALIZE | skip_generalize |
63
+ | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
64
+ | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
65
+
66
+ ### Pre-load
67
+ Specs: `maestro load --type spec --category review`。其余按 base Pre-load。
68
+
69
+ ### Knowledge Persistence
70
+ | 分类 | 后续建议命令 |
71
+ |------|-------------|
72
+ | 跨维度反复 pattern | `$spec-add review "..."` |
73
+ | 安全发现 | `$spec-add debug "..."` |
74
+ | 架构违反 pattern | `$spec-add arch "..."` |
75
+ | 可复用泛化 pattern | `$spec-add coding "..."` |
131
76
  </context>
132
77
 
133
78
  <self_iteration>
134
- **Quality Gate** auto-evaluate after each analytical phase. Insufficient → re-enter (max **3 rounds**).
135
-
136
- | Dimension | Sufficient | Insufficient |
137
- |-----------|-----------|-------------|
138
- | Coverage | All known related files analyzed | Missed targets discoverable via grep/git log |
139
- | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
140
- | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
141
-
142
- **Expansion:** Round 1 = widen scope. Round 2 = shift perspective. Round 3 = combine both + targeted deep-dive on remaining gaps.
143
- **Applicable stages:** S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE
79
+ 适用阶段: S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE
144
80
  </self_iteration>
145
81
 
146
82
  <csv_schema>
@@ -175,31 +111,27 @@ id,title,description,task_type,dimension,deps,wave,status,findings,evidence,erro
175
111
  | 3 | Generalization (syntax-grep, semantic-scan, structural-match, historical-grep) | 4 agents |
176
112
  </csv_schema>
177
113
 
178
- <invariants>
179
- 1. **Code modifications only in S_FIX** — `--skip-fix` preserves review-only behavior
180
- 2. **Evidence append-only** evidence.ndjson is never overwritten
181
- 3. **Session is source of truth** session.json holds all state
182
- 4. **Phase goal tracking** — each stage MUST mark its goal on completion
183
- 5. **`-y` defers, never drops** — auto-confirm records `deferred`, never silently skips
184
- 6. **CLI delegate is background** — all `maestro delegate` calls use run_in_background
185
- 7. **Goal is outcome-oriented** — odyssey outputs prompt then continues
186
- 8. **Invariant violation = BLOCK**
187
- </invariants>
114
+ <state_machine>
115
+ <states>
116
+ S_INTAKE S_ARCHAEOLOGY S_EXPLORE S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
117
+ Skip: --skip-fix skips S_FIX+S_CONFIRM | --skip-generalize skips S_GENERALIZE+S_DISCOVER
118
+ </states>
188
119
 
189
- <execution>
120
+ <transitions>
121
+ S_INTAKE → S_INTAKE (resume/-c) | S_ARCHAEOLOGY (target resolved) | request_user_input (no target)
122
+ S_REVIEW → S_FIX (!skip_fix AND findings) | S_GENERALIZE (skip_fix/no findings, !skip_gen) | S_RECORD (both skip)
123
+ S_CONFIRM → S_GENERALIZE (confirmed, !skip_gen) | S_RECORD (confirmed, skip_gen) | S_FIX (needs_rework)
124
+ S_GENERALIZE → S_DISCOVER (hits) | S_RECORD (no hits)
125
+ S_DISCOVER → S_FIX (fixable sibling) | S_REVIEW (new target, loops < max) | S_RECORD (done or max_loops)
126
+ </transitions>
190
127
 
191
- **States:** S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD
192
- - S_FIX/S_CONFIRM skip when `--skip-fix`
193
- - S_GENERALIZE/S_DISCOVER skip when `--skip-generalize`
128
+ <actions>
194
129
 
195
- ### S_INTAKE
196
- Parse target + flags → file list. Create `SESSION_DIR`, derive `phase_goals[]`.
197
- Search prior knowledge: `maestro search`, prior sessions, ARCHITECTURE.md.
198
- Write `session.json` + `understanding.md` §1. Display Goal Prompt (appendix).
130
+ ### A_INTAKE
131
+ Parse target + flags → file list. Create SESSION_DIR, derive phase_goals[]. Search prior knowledge. Write session.json + §1. Display Goal Prompt.
132
+ 📌 `"odyssey-review({slug}): INTAKE 目标解析与上下文加载"`
199
133
 
200
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_INTAKE — 目标解析"`
201
-
202
- ### S_ARCHAEOLOGY
134
+ ### A_ARCHAEOLOGY
203
135
  **spawn_agents_on_csv (Wave 1):**
204
136
  ```csv
205
137
  "arch-timeline","Git Timeline","git log --oneline -20 -- {target_files}","archaeology","","","1","pending","","",""
@@ -211,20 +143,15 @@ spawn_agents_on_csv({ csv_path: "tasks.csv", id_column: "id",
211
143
  max_concurrency: 2, max_runtime_seconds: 300,
212
144
  output_csv_path: "wave-1-results.csv", output_schema: SHARED_OUTPUT_SCHEMA })
213
145
  ```
214
- Merge → evidence.ndjson (phase: "archaeology").
215
- CLI delegate `--role analyze --mode analysis` for change review (execute with `run_in_background: true`, then wait for callback do NOT halt the Odyssey flow).
216
- Update `understanding.md` §2.
217
-
218
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_ARCHAEOLOGY — 考古"`
219
-
220
- ### S_EXPLORE
221
- CLI delegate `--role explore --mode analysis` → `explore.json` + evidence.ndjson (phase: "explore").
222
- Update `understanding.md` §3. Mark G2 done.
146
+ Merge → evidence.ndjson (phase: "archaeology"). CLI delegate `--role analyze`. Update §2.
147
+ 📌 `"odyssey-review({slug}): ARCHAEOLOGYgit 考古分析"`
223
148
 
224
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_EXPLORE — 探索"`
149
+ ### A_EXPLORE
150
+ CLI delegate `--role explore` — call chains, error gaps, similar patterns. Write explore.json. Update §3. Mark G2.
151
+ 📌 `"odyssey-review({slug}): EXPLORE — 代码探索完成"`
225
152
 
226
- ### S_REVIEW
227
- **spawn_agents_on_csv (Wave 2)** — append rows:
153
+ ### A_REVIEW
154
+ **spawn_agents_on_csv (Wave 2):**
228
155
  ```csv
229
156
  "rev-correct","Correctness","Logic errors, boundary conditions, null/undefined, race conditions","review","correctness","","2","pending","","",""
230
157
  "rev-security","Security","Injection, XSS, CSRF, data exposure, auth bypass","review","security","","2","pending","","",""
@@ -237,46 +164,33 @@ spawn_agents_on_csv({ csv_path: "tasks.csv", id_column: "id",
237
164
  max_concurrency: 4, max_runtime_seconds: 600,
238
165
  output_csv_path: "wave-2-results.csv", output_schema: SHARED_OUTPUT_SCHEMA })
239
166
  ```
240
- Merge → evidence.ndjson (phase: "review"). Write `session.json.review_result`.
241
- Update `understanding.md` §4. Mark G1 done.
242
- Transition: any findings exist AND !skip_fix → S_FIX. Else → S_GENERALIZE or S_RECORD.
167
+ Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence (review). Write review_result + §4 (severity matrix). Mark G1.
168
+ 📌 `"odyssey-review({slug}): REVIEW 多维度审查完成"`
243
169
 
244
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_REVIEW — 审查"`
170
+ ### A_FIX
171
+ **穷尽迭代修复** — 按 severity 递降,直到 `remaining_actionable == 0`。
245
172
 
246
- ### S_FIX
247
- Skip if `--skip-fix` or no findings.
248
- **Exhaustive fix** Fix ALL findings within fix_threshold (default: all = exhaustive across all severity levels). Fix in severity-descending order (critical→high→medium→low), re-review modified areas after each round, append new findings.
249
- **Normal**: `request_user_input` to confirm. **`-y`**: auto-fix all, record `deferred`.
250
- Implement targeted fixes. Record evidence (phase: "fix"). Quality Gate check.
251
-
252
- **Remaining check after each round:**
253
- - If > 0 → retry from tier 1 (NOT limited by max_loops — max_loops only limits cross-phase loops, not FIX-internal retries)
254
- - If remaining unchanged for 2 consecutive rounds (same findings stuck) → classify each stuck finding individually: record as decision (if meets Decision gate criteria) or issue (with fix suggestion)
255
- - ❌ Blanket "N remaining items are pre-existing" is forbidden — each item must have individual classification and reason
256
-
257
- 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-review({slug}): S_FIX — 修复"`
258
-
259
- ### S_CONFIRM
260
- Skip if `--skip-fix`.
261
- Run tests on modified files. CLI delegate `--role review --mode analysis` for fix review (execute with `run_in_background: true`, then wait for callback — do NOT halt the Odyssey flow).
262
- Write `session.json.confirmation`. Update `understanding.md` §5.
263
- `needs_rework` → S_FIX. `confirmed` → mark G3 done.
264
-
265
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_CONFIRM — 确认"`
266
-
267
- ### S_GENERALIZE
268
- Skip if `--skip-generalize`.
173
+ ```
174
+ for tier in [critical, high, medium, low].filter(>= threshold):
175
+ for each unfixed candidate: read ±20 fix evidence (fix)
176
+ re-review modified area ("改进即标准"): new append, continue (max 2/tier)
177
+ tier done auto-commit
178
+ ```
269
179
 
270
- **Pattern extraction** from severity >= medium findings into 3 layers:
271
- | Layer | Method | Example |
272
- |-------|--------|---------|
273
- | Syntax | Regex → Grep | `eval(`, `innerHTML =` |
274
- | Semantic | Agent anti-pattern scan | Missing error handling on async |
275
- | Structural | File/module similarity | Same base class missing override |
180
+ Normal: request_user_input per tier. `-y`: auto-fix all.
181
+ Remaining > 0 retry (no max_loops limit). Unchanged 2 rounds → classify each individually.
182
+ ❌ Blanket "pre-existing" forbidden.
183
+ 📌 per tier: `"odyssey-review({slug}): FIX-{tier} {N}项修复"`
276
184
 
277
- Write `session.json.patterns[]`.
185
+ ### A_CONFIRM
186
+ Run tests + CLI delegate zero-residual review (`--role review`).
187
+ - `remaining == 0 AND new == 0` → confirmed, mark G3
188
+ - Otherwise → needs_rework → S_FIX
189
+ Update confirmation + remaining_actionable + §5.
190
+ 📌 `"odyssey-review({slug}): CONFIRM — 零遗留验证"`
278
191
 
279
- **spawn_agents_on_csv (Wave 3)** — 4 agents parallel:
192
+ ### A_GENERALIZE
193
+ **spawn_agents_on_csv (Wave 3):**
280
194
  ```csv
281
195
  "gen-syntax","Syntax Grep","Grep syntax-layer patterns across project","generalization","syntax","","3","pending","","",""
282
196
  "gen-semantic","Semantic Scan","Check related modules for same anti-patterns","generalization","semantic","","3","pending","","",""
@@ -289,111 +203,79 @@ spawn_agents_on_csv({ csv_path: "tasks.csv", id_column: "id",
289
203
  max_concurrency: 4, max_runtime_seconds: 600,
290
204
  output_csv_path: "wave-3-results.csv", output_schema: SHARED_OUTPUT_SCHEMA })
291
205
  ```
206
+ Pattern 来源: findings (severity >= medium). Mark G4.
207
+ 📌 `"odyssey-review({slug}): GENERALIZE — 泛化扫描完成"`
208
+
209
+ ### A_DISCOVER
210
+ 按 base A_DISCOVER 执行。Mark G5.
211
+ 📌 `"odyssey-review({slug}): DISCOVER — 发现分类完成"`
212
+
213
+ ### A_RECORD
214
+ Write learnings to §8 按 Knowledge Persistence 表分类。其余按 base A_RECORD。Mark G6.
292
215
 
293
- **Cross-layer dedup**: Multi-layer hit → boost confidence. Single → `needs_review`. Historical fix → `regression_risk`.
294
- **Iterative deepening**: ≥3 hits in same module → targeted deep scan. Max 1 round.
295
- **CLI validation** (optional): Delegate to verify true/false positives (execute with `run_in_background: true`, then wait for callback — do NOT halt the Odyssey flow).
296
-
297
- Update `understanding.md` §6. Write `session.json.generalization_stats`. Mark G4 done.
298
-
299
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_GENERALIZE — 泛化"`
300
-
301
- ### S_DISCOVER
302
- Classify hits: `bug` / `risk` / `safe` / `issue`.
303
- **Triage routing:**
304
- - `bug`/`issue` + directly fixable → **fix immediately** → back to S_FIX
305
- - `bug`/`issue` + requires cross-module/architectural decision → create issue (with fix suggestion + impact analysis)
306
- - `risk` → evaluate if guard/validation can mitigate directly; if yes, fix it
307
- - `safe` → mark skip
308
- **Normal**: `request_user_input` for bug routing. **`-y`**: auto create issue, `deferred`.
309
- **Cross-phase loop**:
310
- - Fixable sibling → S_FIX (!skip_fix, cross_phase_loops++)
311
- - New review target → S_REVIEW (cross_phase_loops++)
312
- - S_DISCOVER → S_RECORD: triage complete AND remaining_actionable == 0
313
- - S_DISCOVER → S_RECORD: loops >= max_loops → MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
314
- Append evidence (phase: discovery + decision). Update `understanding.md` §7. Mark G5 done.
315
-
316
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_DISCOVER — 发现"`
317
-
318
- ### S_RECORD
319
- Finalize `understanding.md` §8: per-dimension summary, top findings, generalization results, open decisions.
320
- Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的后续命令。
321
- Pending decisions: **Normal** → `request_user_input`. **`-y`** → skip, display deferred count.
322
- Goal audit: check all `phase_goals[*].completion_confirmed`. Mark G6 done.
323
-
324
- Completion summary:
325
216
  ```
326
- --- REVIEW ODYSSEY COMPLETE ---
327
- Target: {target}
328
- Dimensions: {reviewed}
329
- Findings: {C}C {H}H {M}M {L}L
330
- Fix: {F} applied, {S} skipped
331
- Patterns: {N} extracted ({by_layer} distribution)
332
- Scan hits: {total} ({cross_layer} cross-layer confirmed)
333
- Issues: {N} created
334
- Decisions: {N} resolved, {M} pending, {K} deferred
335
- Self-iter: {R} rounds across {P} phases
336
- Goals: {done}/{total} ({skipped} skipped)
217
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
218
+ Target: {target} Dimensions: {dims}
219
+ Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
220
+ Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
221
+ Issues: {N} Decisions: {N}r/{M}p/{K}d Learnings: {N} Self-iter: {N}×{M}
222
+ Goals: {done}/{total} ({skipped} skipped)
337
223
  ---
338
224
  ```
225
+ 📌 `"odyssey-review({slug}): RECORD — 会话总结与知识沉淀"`
339
226
 
340
- **Next steps:** `$odyssey-debug "<finding>"`, `$manage-issue list --source review-odyssey`,
341
- `$learn-decompose <module>`, `$maestro-plan --gaps`
342
-
343
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-review({slug}): S_RECORD — 总结"`
344
- </execution>
227
+ </actions>
345
228
 
346
229
  <appendix>
347
230
 
348
- ### Goal Prompt Template
349
- **⚠️ 时机守卫:仅在 Stage 1 完成后显示一次(session 创建后、开始考古前)。Stage 8 完成时禁止重新显示。**
350
-
231
+ ### Goal Prompt
351
232
  ```
352
- 📋 Review-Test-Fix Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
353
-
354
- /goal 穷尽迭代:直到所有 findings 均已处理(fix/issue/decision),remaining_actionable == 0
355
- phase_goals_all_done=true 才停。修复按 severity 逐轮迭代,每轮修复后 re-review。
356
- 不允许"只报告不处理",每个 finding 必须有 action。
357
- 遇到 phase=decision 的 pending 必须 request_user_input,不得自行 resolve。
233
+ 📋 Review-Test-Fix Odyssey 会话已创建。可随时复制以下 /goal
234
+
235
+ /goal 完成以下目标:
236
+ {for each G in phase_goals where status != "skipped":}
237
+ - {G.id}: {G.goal} — {G.done_when}
238
+ {end for}
239
+ 穷尽迭代:review_result.remaining_actionable == 0 且 confirmation == confirmed 且 phase_goals_all_done。
240
+ 修复按 severity 逐轮迭代,每轮 re-review 修改区域,新问题追加继续。
241
+ 每个 finding 必须有 action(fix/issue/decision),decision pending 必须 request_user_input。
358
242
  ```
359
243
 
360
- 完成时仅输出 completion summary,不重复此提示。
361
-
362
- ### `-y` Auto-Confirm (5 decision points)
244
+ ### `-y` (7 decision points)
363
245
  | Decision Point | Normal | `-y` |
364
246
  |----------------|--------|------|
365
- | S_FIX fix candidates | request_user_input | auto-fix critical+high, `deferred` |
247
+ | S_FIX tier candidates | request_user_input | auto-fix, `deferred` |
248
+ | S_FIX re-review new | request_user_input | auto-append |
249
+ | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
366
250
  | S_DISCOVER bug routing | request_user_input | auto issue, `deferred` |
367
251
  | S_DISCOVER ambiguous | request_user_input | all `deferred` |
368
- | S_RECORD pending decisions | request_user_input | skip |
252
+ | S_RECORD decisions | request_user_input | skip |
369
253
  | S_RECORD goal audit | request_user_input | auto accept |
370
254
 
371
255
  </appendix>
256
+ </state_machine>
372
257
 
373
258
  <error_codes>
374
259
  | Code | Severity | Condition | Recovery |
375
260
  |------|----------|-----------|----------|
376
- | E001 | error | No target | Provide target |
377
- | E002 | error | Target not found | Check path |
378
- | E003 | error | Resume no session | Start new |
261
+ | E001 | error | No target specified | Provide target |
262
+ | E002 | error | Target path not found | Check path |
379
263
  | W001 | warning | No git history | Proceed |
380
- | W002 | warning | Dimension agent failed | Partial coverage |
381
- | W003 | warning | Generalization 0 hits | Skip discovery |
264
+ | W002 | warning | Some dimension agents failed | Partial coverage |
382
265
  </error_codes>
383
266
 
384
267
  <success_criteria>
385
- - [ ] Target resolved, session created
386
- - [ ] Archaeology via spawn_agents_on_csv Wave 1
387
- - [ ] CLI exploration, explore.json written
388
- - [ ] All dimensions reviewed via spawn_agents_on_csv Wave 2
389
- - [ ] Severity matrix produced
390
- - [ ] All findings fixed and confirmed within fix_threshold (unless --skip-fix)
391
- - [ ] `--skip-fix`: no source code modifications
392
- - [ ] Generalization via spawn_agents_on_csv Wave 3 (unless --skip-generalize)
393
- - [ ] Discoveries classified and routed
394
- - [ ] understanding.md §8 finalized
395
- - [ ] Goal Prompt displayed, phase_goals G1-G6 tracked
396
- - [ ] `-y`: no blocking, deferred counted
397
- - [ ] Self-iteration quality gates passed
398
- - [ ] **Every unfixed finding has individual classification and reason** — blanket "pre-existing" labels are forbidden
268
+ - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0), zero-residual confirmed
269
+ - [ ] Per-tier re-review gate; every unfixed finding individually classified
270
+ - [ ] Generalized with multi-layer scan (unless --skip-generalize); self-iteration on insufficient
271
+ - [ ] understanding.md §1-§8, phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
399
272
  </success_criteria>
273
+
274
+ <next_step_routing>
275
+ | Condition | Next step |
276
+ |-----------|-----------|
277
+ | Deeper debug needed | `$odyssey-debug "<finding>"` |
278
+ | Issues created | `$manage-issue list --source review-odyssey` |
279
+ | Pattern to document | `$learn-decompose <module>` |
280
+ | Plan fixes | `$maestro-plan --gaps` |
281
+ </next_step_routing>