maestro-flow 0.5.38 → 0.5.40

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 (163) 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/agents/cli-explore-agent.toml +181 -0
  17. package/.codex/agents/cross-role-reviewer.toml +165 -0
  18. package/.codex/agents/impeccable-agent.toml +89 -0
  19. package/.codex/agents/role-design-author.toml +213 -0
  20. package/.codex/agents/team-worker.toml +4 -7
  21. package/.codex/agents/ui-design-agent.toml +260 -0
  22. package/.codex/agents/workflow-analyzer.toml +106 -0
  23. package/.codex/agents/workflow-codebase-mapper.toml +69 -0
  24. package/.codex/agents/workflow-collab-planner.toml +140 -0
  25. package/.codex/agents/workflow-debugger.toml +95 -0
  26. package/.codex/agents/workflow-executor.toml +124 -0
  27. package/.codex/agents/workflow-external-researcher.toml +80 -0
  28. package/.codex/agents/workflow-integration-checker.toml +76 -0
  29. package/.codex/agents/workflow-nyquist-auditor.toml +77 -0
  30. package/.codex/agents/workflow-phase-researcher.toml +76 -0
  31. package/.codex/agents/workflow-plan-checker.toml +93 -0
  32. package/.codex/agents/workflow-planner.toml +192 -0
  33. package/.codex/agents/workflow-project-researcher.toml +65 -0
  34. package/.codex/agents/workflow-research-synthesizer.toml +65 -0
  35. package/.codex/agents/workflow-reviewer.toml +75 -0
  36. package/.codex/agents/workflow-roadmapper.toml +75 -0
  37. package/.codex/agents/workflow-verifier.toml +113 -0
  38. package/.codex/skills/maestro/SKILL.md +1 -0
  39. package/.codex/skills/maestro-analyze/SKILL.md +33 -15
  40. package/.codex/skills/maestro-brainstorm/SKILL.md +13 -10
  41. package/.codex/skills/maestro-collab/SKILL.md +30 -75
  42. package/.codex/skills/maestro-execute/SKILL.md +19 -12
  43. package/.codex/skills/maestro-grill/SKILL.md +12 -11
  44. package/.codex/skills/maestro-next/SKILL.md +3 -3
  45. package/.codex/skills/maestro-overlay/SKILL.md +1 -1
  46. package/.codex/skills/maestro-plan/SKILL.md +17 -8
  47. package/.codex/skills/maestro-ralph/SKILL.md +3 -0
  48. package/.codex/skills/maestro-ralph-execute/SKILL.md +1 -0
  49. package/.codex/skills/maestro-roadmap/SKILL.md +14 -8
  50. package/.codex/skills/manage-learn/SKILL.md +1 -1
  51. package/.codex/skills/odyssey-debug/SKILL.md +185 -275
  52. package/.codex/skills/odyssey-improve/SKILL.md +216 -308
  53. package/.codex/skills/odyssey-planex/SKILL.md +317 -159
  54. package/.codex/skills/odyssey-review-test-fix/SKILL.md +137 -255
  55. package/.codex/skills/odyssey-ui/SKILL.md +183 -247
  56. package/.codex/skills/quality-review/SKILL.md +17 -10
  57. package/.codex/skills/team-lifecycle-v4/instructions/agent-instruction.md +6 -12
  58. package/.codex/skills/team-lifecycle-v4/roles/analyst/role.md +6 -14
  59. package/.codex/skills/team-lifecycle-v4/roles/executor/commands/implement.md +2 -6
  60. package/.codex/skills/team-lifecycle-v4/roles/planner/role.md +6 -14
  61. package/.codex/skills/team-lifecycle-v4/roles/writer/role.md +3 -7
  62. package/.codex/skills/team-quality-assurance/roles/scout/role.md +2 -5
  63. package/.codex/skills/team-review/roles/reviewer/role.md +2 -5
  64. package/.codex/skills/team-review/roles/scanner/role.md +2 -5
  65. package/.codex/skills/team-tech-debt/roles/executor/role.md +3 -7
  66. package/.codex/skills/team-tech-debt/roles/scanner/role.md +2 -5
  67. package/.codex/skills/team-tech-debt/roles/validator/role.md +3 -7
  68. package/.codex/skills/team-testing/roles/executor/role.md +3 -7
  69. package/.codex/skills/team-testing/roles/generator/role.md +3 -7
  70. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +23 -2
  71. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +242 -26
  72. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  73. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.d.ts +2 -0
  74. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +92 -29
  75. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  76. package/dashboard/dist-server/src/commands/hooks.d.ts +2 -1
  77. package/dashboard/dist-server/src/commands/hooks.js +16 -9
  78. package/dashboard/dist-server/src/commands/hooks.js.map +1 -1
  79. package/dashboard/dist-server/src/commands/install-backend.js +19 -0
  80. package/dashboard/dist-server/src/commands/install-backend.js.map +1 -1
  81. package/dashboard/dist-server/src/core/manifest.d.ts +5 -0
  82. package/dashboard/dist-server/src/core/manifest.js.map +1 -1
  83. package/dashboard/dist-server/src/core/plugin-bridge.d.ts +59 -0
  84. package/dashboard/dist-server/src/core/plugin-bridge.js +355 -0
  85. package/dashboard/dist-server/src/core/plugin-bridge.js.map +1 -0
  86. package/dashboard/dist-server/src/hooks/kg-sync-hook.js +5 -0
  87. package/dashboard/dist-server/src/hooks/kg-sync-hook.js.map +1 -1
  88. package/dashboard/dist-server/src/hooks/session-context.js +276 -3
  89. package/dashboard/dist-server/src/hooks/session-context.js.map +1 -1
  90. package/dashboard/dist-server/src/search/daemon-client.d.ts +8 -3
  91. package/dashboard/dist-server/src/search/daemon-client.js +20 -0
  92. package/dashboard/dist-server/src/search/daemon-client.js.map +1 -1
  93. package/dist/src/cli.js +19 -1
  94. package/dist/src/cli.js.map +1 -1
  95. package/dist/src/commands/domain.d.ts.map +1 -1
  96. package/dist/src/commands/domain.js +12 -3
  97. package/dist/src/commands/domain.js.map +1 -1
  98. package/dist/src/commands/hooks.d.ts +2 -1
  99. package/dist/src/commands/hooks.d.ts.map +1 -1
  100. package/dist/src/commands/hooks.js +16 -9
  101. package/dist/src/commands/hooks.js.map +1 -1
  102. package/dist/src/commands/install-backend.d.ts.map +1 -1
  103. package/dist/src/commands/install-backend.js +19 -0
  104. package/dist/src/commands/install-backend.js.map +1 -1
  105. package/dist/src/commands/install.d.ts.map +1 -1
  106. package/dist/src/commands/install.js +50 -3
  107. package/dist/src/commands/install.js.map +1 -1
  108. package/dist/src/commands/plugin.d.ts +3 -0
  109. package/dist/src/commands/plugin.d.ts.map +1 -0
  110. package/dist/src/commands/plugin.js +137 -0
  111. package/dist/src/commands/plugin.js.map +1 -0
  112. package/dist/src/commands/search.d.ts.map +1 -1
  113. package/dist/src/commands/search.js +59 -6
  114. package/dist/src/commands/search.js.map +1 -1
  115. package/dist/src/commands/spec.d.ts.map +1 -1
  116. package/dist/src/commands/spec.js +15 -0
  117. package/dist/src/commands/spec.js.map +1 -1
  118. package/dist/src/commands/update.d.ts.map +1 -1
  119. package/dist/src/commands/update.js +23 -0
  120. package/dist/src/commands/update.js.map +1 -1
  121. package/dist/src/core/install-executor.d.ts +1 -1
  122. package/dist/src/core/install-executor.d.ts.map +1 -1
  123. package/dist/src/core/install-executor.js +27 -0
  124. package/dist/src/core/install-executor.js.map +1 -1
  125. package/dist/src/core/install-profile.d.ts +5 -0
  126. package/dist/src/core/install-profile.d.ts.map +1 -1
  127. package/dist/src/core/install-profile.js +8 -0
  128. package/dist/src/core/install-profile.js.map +1 -1
  129. package/dist/src/core/manifest.d.ts +5 -0
  130. package/dist/src/core/manifest.d.ts.map +1 -1
  131. package/dist/src/core/manifest.js.map +1 -1
  132. package/dist/src/core/plugin-bridge.d.ts +60 -0
  133. package/dist/src/core/plugin-bridge.d.ts.map +1 -0
  134. package/dist/src/core/plugin-bridge.js +355 -0
  135. package/dist/src/core/plugin-bridge.js.map +1 -0
  136. package/dist/src/hooks/kg-sync-hook.d.ts.map +1 -1
  137. package/dist/src/hooks/kg-sync-hook.js +5 -0
  138. package/dist/src/hooks/kg-sync-hook.js.map +1 -1
  139. package/dist/src/hooks/session-context.d.ts.map +1 -1
  140. package/dist/src/hooks/session-context.js +276 -3
  141. package/dist/src/hooks/session-context.js.map +1 -1
  142. package/dist/src/search/daemon-client.d.ts +8 -3
  143. package/dist/src/search/daemon-client.d.ts.map +1 -1
  144. package/dist/src/search/daemon-client.js +20 -0
  145. package/dist/src/search/daemon-client.js.map +1 -1
  146. package/dist/src/search/daemon.d.ts +3 -3
  147. package/dist/src/search/daemon.d.ts.map +1 -1
  148. package/dist/src/search/daemon.js +9 -3
  149. package/dist/src/search/daemon.js.map +1 -1
  150. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  151. package/dist/src/tui/install-ui/InstallFlow.js +43 -14
  152. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  153. package/dist/src/tui/install-ui/types.d.ts +2 -0
  154. package/dist/src/tui/install-ui/types.d.ts.map +1 -1
  155. package/dist/src/tui/install-ui/types.js.map +1 -1
  156. package/dist/src/tui/install-ui/useInstallFlowState.d.ts.map +1 -1
  157. package/dist/src/tui/install-ui/useInstallFlowState.js +13 -1
  158. package/dist/src/tui/install-ui/useInstallFlowState.js.map +1 -1
  159. package/dist/src/utils/update-notices.js +11 -0
  160. package/dist/src/utils/update-notices.js.map +1 -1
  161. package/package.json +1 -1
  162. package/workflows/odyssey-base.md +258 -0
  163. package/workflows/shell-exec-protocol.md +30 -0
@@ -1,13 +1,14 @@
1
1
  ---
2
2
  name: odyssey-improve
3
3
  description: "Long-running codebase improvement cycle — multi-dimensional audit, deep diagnosis, targeted fix, verify, generalize, and engineering knowledge persistence"
4
- argument-hint: '"<target>" [--dimensions <list>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c]'
4
+ argument-hint: '"<target>" [--dimensions <list>] [--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 codebase improvement: survey (dependency + complexity baseline) -> audit (6 dimensions) ->
10
- diagnose (root cause analysis) -> fix -> verify -> generalize -> discover -> record.
10
+ Deep codebase improvement: survey 6-dimension audit diagnose fix verify → generalize → discover → persist.
11
+ Baseline-first approach with exhaustive iteration until zero remaining actionable findings.
11
12
 
12
13
  Core philosophy:
13
14
  - **Measure before improving** — baseline first, then optimize
@@ -22,149 +23,92 @@ Core philosophy:
22
23
  </purpose>
23
24
 
24
25
  <boundary>
25
- **范围内:** 目标代码运行质量提升性能/安全/架构/可靠性/可观测性/可维护性
26
- **范围外:** UI → `$odyssey-ui` | 新功能 → `$odyssey-planex` | 单一 bug → `$odyssey-debug` | 代码审查 → `$odyssey-review-test-fix`
27
- **探索自由度:** profiling、安全扫描、架构分析、依赖审计,在约束下尽可能发现深层问题
28
-
26
+ **范围内:** 目标代码的运行质量提升性能/安全/架构/可靠性/可观测性/可维护性多维度审查 → 诊断 → 修复 → 泛化
27
+ **范围外:** UI 视觉优化 → `$odyssey-ui` | 新功能实现 → `$odyssey-planex` | 单一 bug 调查 → `$odyssey-debug` | 代码风格审查 → `$odyssey-review-test-fix`
28
+ **探索自由度:** 边界内自由探索 — 可 profiling、安全扫描、架构分析、依赖审计。在约束下尽可能发现深层问题。
29
29
  **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.
30
30
  </boundary>
31
31
 
32
- <execution_discipline>
33
- **三条铁律(所有阶段适用):**
34
- 1. **Phase auto-commit** — 阶段完成后**自动** `git commit`,无需用户确认(session.json/evidence.ndjson 不纳入)
35
- 2. **Confident edits only, but must attempt** — only modify what you're confident about; record decisions only when genuinely requiring human judgment
36
- - Confident → edit code directly, commit
37
- - Needs decision → record `evidence.ndjson {"phase":"decision","status":"pending"}`, don't touch code
38
- - No speculative changes
39
- - ⚠️ **Decision gate** — ONLY these qualify as decisions (not fixes):
40
- - Cross-module architectural tradeoffs requiring human direction
41
- - Ambiguous business semantics where the fix could alter intended behavior
42
- - Requires new dependency or breaking API change
43
- - ❌ "Unsure how to fix", "Large scope", "Pre-existing issue" are NOT valid decision reasons — either fix it, or explain specifically why it's unfixable
44
- 3. **多 CLI 辅助** — `maestro delegate` 多 `--role`(analyze/review/explore)交叉验证关键判断
45
- </execution_discipline>
46
-
47
32
  <context>
48
33
  $ARGUMENTS — target and optional flags.
49
34
 
50
35
  **Target resolution:**
51
36
  | Input | Resolution |
52
37
  |-------|-----------|
53
- | Module/directory path | Analyze those source files |
54
- | Package name | Resolve to source directory |
55
- | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` (source files only) |
56
- | Feature area keyword | Grep for keyword, collect relevant source files |
38
+ | Module/dir path | Audit that module |
39
+ | `HEAD` / `staged` | Review changes in diff |
40
+ | Feature area keyword | Resolve to related files |
41
+ | `--all` | Full project scan (use with caution) |
57
42
 
58
43
  **Flags:**
59
- | Flag | Effect |
60
- |------|--------|
61
- | `--dimensions <list>` | Comma-separated subset (default: all 6) |
62
- | `--skip-fix` | Audit-only skip S_FIX and S_VERIFY |
63
- | `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER |
64
- | `--auto` | CLI delegates without confirmation |
65
- | `-y` | Auto-confirm at all decision points (see appendix) |
66
- | `-c` | Resume most recent session |
44
+ | Flag | Effect | Default |
45
+ |------|--------|---------|
46
+ | `--dimensions <list>` | Comma-separated subset of 6 dimensions | all 6 |
47
+ | `--fix-threshold <severity>` | 修复到哪个 severity 为止(all = 全部修复)| all |
48
+ | `--skip-fix` | Audit + diagnose only, no code changes | false |
49
+ | `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER | false |
50
+ | `--auto` | CLI delegates without confirmation | false |
51
+ | `-y` | Auto-confirm all decisions (see appendix) | false |
52
+ | `-c` | Resume most recent session | — |
53
+ | `--heartbeat` | Enable /loop heartbeat protocol (see base) | false |
67
54
 
68
55
  **Dimensions (6):**
69
- 1. **performance** — hot paths, N+1 queries, memory leaks, cache misses, bundle size
70
- 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulns
71
- 3. **architecture** — layer violations, circular deps, coupling, interface design, SRP
72
- 4. **reliability** — error handling, retry logic, timeout config, graceful degradation, resource cleanup
73
- 5. **observability** — logging coverage, metrics, traces, error reporting, health checks
74
- 6. **maintainability** — cyclomatic complexity, dead code, coverage gaps, doc debt
56
+ 1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
57
+ 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
58
+ 3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
59
+ 4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
60
+ 5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
61
+ 6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
75
62
 
76
63
  **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
77
64
 
78
- **Output 3 files:**
79
- ```
80
- SESSION_DIR/
81
- ├── session.json # state + baseline + audit_result + diagnoses + patterns + phase_goals
82
- ├── evidence.ndjson # ALL evidence (phase: survey|audit|diagnose|fix|discovery|decision|self-iteration)
83
- └── understanding.md # 9-section evolving narrative (§1-§9, one per major phase)
84
- ```
85
-
86
- **session.json schema:**
87
- ```json
88
- {
89
- "session_id": "improve-odyssey-{YYYYMMDD-HHmmss}",
90
- "target": "", "dimensions": [],
91
- "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
92
- "current_state": "S_INTAKE",
93
- "baseline_metrics": {},
94
- "audit_result": { "dimensions_audited": [], "finding_count": 0, "severity_distribution": {} },
95
- "diagnoses": [],
96
- "patterns": [],
97
- "generalization_stats": null,
98
- "phase_goals": [], "phase_goals_all_done": false,
99
- "self_iteration_log": [],
100
- "cross_phase_loops": 0, "max_loops": 5,
101
- "created_at": "", "updated_at": ""
102
- }
103
- ```
65
+ **Output:** `session.json` (state + audit + diagnoses + patterns + goals) | `evidence.ndjson` (append-only) | `understanding.md` (9-section narrative)
104
66
 
105
- **evidence.ndjson:** `{"ts":"","phase":"survey|audit|diagnose|fix|discovery|decision|self-iteration","type":"","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","metrics":{}}`
67
+ **session.json unique fields:** `target`, `dimensions`, `baseline_metrics`, `audit_result`, `diagnoses`, `confirmation`, `generalization_stats` (`progress_metrics`, `directions_tried` from base)
106
68
 
107
- **phase_goals[] — auto-derived from flags:**
69
+ **evidence.ndjson phase-specific fields:**
70
+ - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
71
+ - `audit`: `dimension`, `severity`, `measurement`
72
+ - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
73
+ - `fix`: `finding_ref`, `change_summary`, `risk`
74
+ - `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
75
+ - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
76
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
108
77
 
78
+ **phase_goals[]:**
109
79
  | ID | Goal | Phase | skip_when |
110
80
  |----|------|-------|-----------|
111
81
  | G1 | Survey completed | S_SURVEY | — |
112
82
  | G2 | Audit completed | S_AUDIT | — |
113
83
  | G3 | Diagnosis completed | S_DIAGNOSE | — |
114
- | G4 | Fix applied and verified | S_VERIFY | skip_fix |
84
+ | G4 | Zero remaining: all findings fixed and verified | `remaining_actionable == 0` within fix_threshold | S_VERIFY | skip_fix |
115
85
  | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
116
86
  | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
117
87
  | G7 | Learnings persisted | S_RECORD | — |
118
88
 
119
- Lifecycle: `pending -> done | skipped | failed` (all set `completion_confirmed`)
120
-
121
- **understanding.md 9 sections:**
122
- §1 Target & Baseline (S_INTAKE) | §2 Survey (S_SURVEY) | §3 Audit Findings (S_AUDIT) |
123
- §4 Root Cause Diagnosis (S_DIAGNOSE) | §5 Fix & Verification (S_FIX+S_VERIFY) |
124
- §6 Generalization (S_GENERALIZE) | §7 Discoveries (S_DISCOVER) |
125
- §8 Improvement Metrics (S_RECORD) | §9 Engineering Learnings (S_RECORD)
89
+ **understanding.md 9 sections (written by owning phase):**
90
+ 1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
91
+ 4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
92
+ 6. Generalization S_GENERALIZE | 7. Discoveries S_DISCOVER
93
+ 8. Improvement Metrics S_RECORD (before/after) | 9. Engineering Learnings S_RECORD
126
94
 
127
- ### Pre-load
95
+ ### Pre-load(可选,缺失不阻塞)
96
+ - ARCHITECTURE.md → 模块边界 | `maestro search "<target>" --json` → 先前优化(top 5)
97
+ - `maestro load --type spec --category coding` + `--category debug` → 编码规范 + 已知模式
98
+ - `maestro search --category coding` → knowhow | `Glob(".workflow/scratch/*-improve-odyssey-*")` → 先前会话
128
99
 
129
- | Layer | Command | Purpose |
130
- |-------|---------|---------|
131
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | Module boundaries |
132
- | Wiki search | `maestro search "<target keywords>" --json` | Prior investigations (top 5) |
133
- | Specs | `maestro load --type spec --category coding --keyword "<target>"` | Coding conventions |
134
- | Debug specs | `maestro load --type spec --category debug` | Known issues, workarounds |
135
- | Role knowledge | `maestro search --category arch` -> select -> `maestro load --type knowhow --id <id>` | Domain knowledge |
136
- | Prior sessions | `Glob(".workflow/scratch/*-improve-odyssey-*")` | Related sessions |
100
+ ### Knowledge Persistence(S_RECORD 中写入产出文件)
137
101
 
138
- ### Knowledge Persistence (two-step model)
102
+ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §9 Learnings**,按以下分类结构化:
139
103
 
140
- Write to understanding.md §9 during execution (temporary). Completion summary suggests follow-up commands.
141
-
142
- | Category | Content | Follow-up |
143
- |----------|---------|-----------|
144
- | Recurring root cause | Pattern + trigger + fix template | `$spec-add debug "..."` |
145
- | Non-obvious workaround | Problem + solution + scope | `$spec-add learning "..."` |
146
- | Architecture violation | Violation + correct boundary + check method | `$spec-add arch "..."` |
147
- | Reusable pattern | Pattern signature + risk + fix template | `$spec-add coding "..."` |
148
-
149
- **Two-step:** Execute writes to output files (temporary) -> completion suggests permanent knowledge capture commands. No external skill calls during execution.
104
+ | 分类 | 写入内容 | 后续建议命令 |
105
+ |------|---------|-------------|
106
+ | 性能 pattern | 瓶颈类型 + 修复方案 + 度量方法 | `/spec-add coding "..."` |
107
+ | 安全规则 | 漏洞类别 + 修复 + 预防方法 | `/spec-add debug "..."` |
108
+ | 架构约束 | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
109
+ | 可靠性 pattern | 故障模式 + 处理策略 + 验证手段 | `/spec-add coding "..."` |
150
110
  </context>
151
111
 
152
- <self_iteration>
153
- **Quality Gate** — auto-evaluate after each analytical phase. Insufficient -> re-enter (max **3 rounds**).
154
-
155
- | Dimension | Sufficient | Insufficient |
156
- |-----------|-----------|-------------|
157
- | Coverage | All known related files/modules analyzed | Missed targets discoverable via grep/glob |
158
- | Depth | >=80% findings have file:line evidence | Most findings lack specifics |
159
- | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
160
-
161
- **Expansion:** Round 1 = widen scope (more directories, deeper dependency analysis, additional delegate angles). Round 2 = shift perspective (different CLI tool, reverse trace, manual code reading). Round 3 = combine both + targeted deep-dive on remaining gaps.
162
-
163
- **Applicable stages:** S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE
164
-
165
- **Exit:** All sufficient -> advance | 3-round cap -> record gap, continue. Logged to `evidence.ndjson` + `session.json.self_iteration_log[]`.
166
- </self_iteration>
167
-
168
112
  <csv_schema>
169
113
 
170
114
  ### Shared Output Schema (all waves)
@@ -197,48 +141,78 @@ id,title,description,task_type,dimension,deps,wave,status,findings,evidence,erro
197
141
  | 3 | Generalization (syntax-grep, semantic-scan, structural-match, historical-grep) | 4 agents |
198
142
  </csv_schema>
199
143
 
200
- <invariants>
201
- 1. **Measure before improve** — baseline metrics MUST precede any fix
202
- 2. **Root cause over symptom** — NO FIX without diagnosis evidence
203
- 3. **Evidence append-only** — evidence.ndjson is never overwritten
204
- 4. **Session is source of truth** — session.json holds all state
205
- 5. **Phase goal tracking** each stage MUST mark its goal on completion
206
- 6. **`-y` defers, never drops** auto-confirm records `deferred`, never silently skips
207
- 7. **CLI delegate is background** all `maestro delegate` calls use run_in_background
208
- 8. **Goal is outcome-oriented** odyssey outputs prompt then continues
209
- 9. **Verify improvement** post-fix metrics MUST be compared with baseline
210
- 10. **Decision journal integrity** all human-judgment items recorded phase=decision
211
- 11. **Resumable state** current_state saved at every transition
212
- 12. **Invariant violation = BLOCK** violating any invariant blocks the operation
213
- </invariants>
214
-
215
- <execution>
216
-
217
- **States:** S_INTAKE -> S_SURVEY -> S_AUDIT -> S_DIAGNOSE -> S_FIX -> S_VERIFY -> S_GENERALIZE -> S_DISCOVER -> S_RECORD
218
- - S_FIX/S_VERIFY skip when `--skip-fix`
219
- - S_GENERALIZE/S_DISCOVER skip when `--skip-generalize`
220
-
221
- **Cross-phase loops:**
222
- - S_DIAGNOSE -> S_DIAGNOSE (hypothesis retry, max 3)
223
- - S_VERIFY -> S_FIX (rework on failed verification)
224
- - S_DISCOVER -> S_DIAGNOSE (new critical issue found, cross_phase_loops++)
225
- - S_DISCOVER -> S_FIX (same-pattern fix with template)
226
- - S_DISCOVER -> S_RECORD : triage complete AND remaining_actionable == 0
227
- - S_DISCOVER -> S_RECORD : loops >= max_loops MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
228
-
229
- ### S_INTAKE
230
- 1. Parse target + flags -> resolve file list
144
+ Self-iteration 适用阶段: S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE
145
+
146
+ <state_machine>
147
+
148
+ <states>
149
+ S_INTAKE — Parse target, load context, establish baseline metrics PERSIST: session.json + understanding.md §1
150
+ S_SURVEY — Current state: dependency audit, complexity scan, coverage PERSIST: evidence.ndjson (survey) + understanding.md §2
151
+ S_AUDIT — 6-dimension parallel deep audit PERSIST: evidence.ndjson (audit) + understanding.md §3
152
+ S_DIAGNOSE — Root cause analysis for critical/high findings PERSIST: evidence.ndjson (diagnosis|decision) + understanding.md §4
153
+ S_FIX — Implement improvements (skip if --skip-fix) PERSIST: code changes + evidence.ndjson (fix)
154
+ S_VERIFY — Tests + measurement comparison (skip if --skip-fix) PERSIST: session.json.confirmation + understanding.md §5
155
+ S_GENERALIZE Pattern extraction + 4-agent scan (skip if --skip-gen) PERSIST: session.json.patterns + understanding.md §6
156
+ S_DISCOVER — Classify hits, create issues (skip if --skip-gen) PERSIST: evidence.ndjson (discovery|decision) + understanding.md §7
157
+ S_RECORD — Persist metrics + learnings + final report PERSIST: understanding.md §8-9 + spec entries
158
+ </states>
159
+
160
+ <transitions>
161
+ S_INTAKE:
162
+ → S_INTAKE WHEN -c + session found DO A_RESUME
163
+ S_SURVEY WHEN target resolved DO A_INTAKE
164
+ → S_INTAKE WHEN no target DO request_user_input
165
+
166
+ S_SURVEY → S_AUDIT DO A_SURVEY
167
+
168
+ S_AUDIT:
169
+ S_DIAGNOSE WHEN critical/high findings exist DO A_AUDIT
170
+ S_GENERALIZE WHEN no critical/high AND !skip_gen DO A_AUDIT
171
+ S_RECORD WHEN no findings OR skip_gen DO A_AUDIT
172
+
173
+ S_DIAGNOSE:
174
+ S_FIX WHEN root causes identified AND !skip_fix DO A_DIAGNOSE
175
+ → S_GENERALIZE WHEN root causes identified AND skip_fix AND !skip_gen DO A_DIAGNOSE
176
+ → S_RECORD WHEN root causes identified AND skip_fix AND skip_gen DO A_DIAGNOSE
177
+ → S_DIAGNOSE WHEN hypotheses failed AND retries < 3 DO A_ESCALATE_DIAGNOSIS
178
+ → S_RECORD WHEN hypotheses failed AND retries >= 3 DO mark INCONCLUSIVE
179
+
180
+ S_FIX → S_VERIFY DO A_FIX
181
+
182
+ S_VERIFY:
183
+ → S_GENERALIZE WHEN verified AND !skip_gen DO A_VERIFY
184
+ → S_RECORD WHEN verified AND skip_gen DO A_VERIFY
185
+ → S_FIX WHEN needs_rework DO A_VERIFY
186
+
187
+ S_GENERALIZE:
188
+ → S_DISCOVER WHEN hits found DO A_GENERALIZE
189
+ → S_RECORD WHEN no hits DO A_GENERALIZE
190
+
191
+ S_DISCOVER → S_DIAGNOSE : new critical issue found → cross_phase_loops++
192
+ S_DISCOVER → S_FIX : same-pattern fix, !skip_fix → cross_phase_loops++
193
+ S_DISCOVER → S_RECORD : triage complete AND remaining_actionable == 0
194
+ S_DISCOVER → S_RECORD : loops >= max_loops → MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
195
+
196
+ S_RECORD → END DO A_RECORD
197
+ </transitions>
198
+
199
+ <actions>
200
+
201
+ ### A_INTAKE
202
+ 1. Parse arguments: target description, flags, `--dimensions` subset
231
203
  2. Generate slug, create `SESSION_DIR`
232
- 3. Search prior knowledge: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load (coding, debug)
233
- 4. Derive `phase_goals[]` from flags (apply `skip_when`)
234
- 5. Write `session.json` + `understanding.md` §1
235
- 6. Display Goal Prompt (appendix), continue without blocking
204
+ 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
205
+ 4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
206
+ 5. Derive `phase_goals[]` from flags (apply `skip_when`)
207
+ 6. Write `session.json` + `understanding.md` §1 (Target & Baseline)
208
+ 7. Emit Goal Prompt (see Appendix)
236
209
 
237
- **Resume (`-c`):** Glob latest session -> read `session.json` -> restore `current_state` -> jump.
210
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): INTAKE — 目标解析与基线采集"`
238
211
 
239
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_INTAKE — 目标解析"`
212
+ ### A_RESUME
213
+ Find latest session via Glob → read `session.json` → display summary → jump to `current_state`.
240
214
 
241
- ### S_SURVEY
215
+ ### A_SURVEY
242
216
  **spawn_agents_on_csv (Wave 1):**
243
217
 
244
218
  Write `tasks.csv` with Wave 1 rows:
@@ -248,12 +222,12 @@ Write `tasks.csv` with Wave 1 rows:
248
222
  ```
249
223
  `spawn_agents_on_csv({ csv_path:"tasks.csv", max_concurrency:2, max_runtime_seconds:300, output_csv_path:"wave-1-results.csv", output_schema:SHARED_OUTPUT_SCHEMA })`
250
224
 
251
- Merge -> evidence.ndjson (phase: "survey"). Extract `baseline_metrics` from survey results. Update §2. Mark G1 done.
225
+ Merge evidence.ndjson (phase: "survey"). Extract `baseline_metrics` from survey results. Update `understanding.md` §2. Mark G1 done.
252
226
 
253
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_SURVEY调查"`
227
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): SURVEY现状调查"`
254
228
 
255
- ### S_AUDIT
256
- **spawn_agents_on_csv (Wave 2)** — 6 agents (one per dimension):
229
+ ### A_AUDIT
230
+ **spawn_agents_on_csv (Wave 2)** — 6 agents (one per dimension, or `--dimensions` subset):
257
231
 
258
232
  Append Wave 2 rows to `tasks.csv`:
259
233
  ```csv
@@ -266,70 +240,44 @@ Append Wave 2 rows to `tasks.csv`:
266
240
  ```
267
241
  `spawn_agents_on_csv({ csv_path:"tasks.csv", max_concurrency:6, max_runtime_seconds:600, output_csv_path:"wave-2-results.csv", output_schema:SHARED_OUTPUT_SCHEMA })`
268
242
 
269
- Merge -> evidence.ndjson (phase: "audit"). Write `audit_result` with dimensions audited, finding count, severity distribution. Update §3. Mark G2 done.
270
-
271
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_AUDIT — 审查"`
272
-
273
- ### S_DIAGNOSE
274
- Root cause analysis for top audit findings (severity >= high).
275
-
276
- 1. **Rank findings** from audit, group by root cause pattern
277
- 2. **CLI deep analysis** for top finding clusters:
278
- ```bash
279
- maestro delegate "PURPOSE: Root cause analysis for codebase quality issues in {target}
280
- TASK: Trace origin of each finding | Identify shared root causes | Map dependency chains | Assess blast radius
281
- MODE: analysis
282
- CONTEXT: @{target_files} | Audit findings: {top_findings_json}
283
- EXPECTED: JSON [{finding_ids, root_cause, origin_file, origin_line, blast_radius, fix_approach, confidence}]
284
- CONSTRAINTS: Trace to origin, not just symptoms | Group related findings
285
- " --role analyze --mode analysis
286
- ```
287
- Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
288
-
289
- 3. **Hypothesis testing**: for each root cause — design verification -> execute -> evidence (phase: "diagnose")
290
- 4. **Decision journal**: ambiguity -> evidence (phase: "decision"); Normal: request_user_input | `-y`: defer
291
- 5. **Confirmed diagnoses** -> `session.json.diagnoses[]`: `[{id, finding_ids, root_cause, evidence_refs, confidence, fix_approach}]`
243
+ Merge evidence.ndjson (phase: "audit"). Write `session.json.audit_result` with dimensions audited, finding count, severity distribution.
244
+ Update `understanding.md` §3 (findings by dimension + severity matrix). Mark G2 done.
292
245
 
293
- **Escalation (3-strike):** Hypothesis fails -> retry with broader scope via `maestro delegate --role explore`. After 3 retries: Normal -> request_user_input | `-y` -> mark INCONCLUSIVE, proceed.
246
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): AUDIT 多维审查"`
294
247
 
295
- Update §4. Mark G3 done.
248
+ ### A_DIAGNOSE
249
+ Root cause analysis for critical/high findings — don't fix symptoms.
296
250
 
297
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_DIAGNOSE — 诊断"`
251
+ 1. Group by dimension, prioritize by severity. For each: hypothesis → trace code path + git history evidence.ndjson (phase: "diagnosis")
252
+ 2. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: request_user_input | `-y`: defer
253
+ 3. **CLI-assisted** for complex findings: `maestro delegate --role analyze --mode analysis` to trace code path, check systemic pattern, identify fix approach. Execute `run_in_background: true`.
254
+ 4. Write `session.json.diagnoses[]`. Update `understanding.md` §4. Mark G3 done.
298
255
 
299
- ### S_FIX
300
- Skip if `--skip-fix`.
256
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DIAGNOSE — 根因诊断"`
301
257
 
302
- 1. Present diagnoses + proposed fixes, prioritized by blast radius. Normal: `request_user_input` to confirm. `-y`: auto proceed.
303
- 2. Implement fixes in priority order (highest blast radius first)
304
- 3. Record each fix in evidence (phase: "fix" + "decision")
305
- 4. Update §5
258
+ ### A_ESCALATE_DIAGNOSIS
259
+ Increment retries. If < 3: broaden scope via `maestro delegate --role analyze`, form new hypotheses, return to S_DIAGNOSE. If >= 3: Normal → request_user_input (broaden/new/INCONCLUSIVE) | `-y` → auto INCONCLUSIVE, proceed to S_RECORD.
306
260
 
307
- 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-improve({slug}): S_FIX — 修复"`
261
+ ### A_FIX
262
+ Skip if `--skip-fix`. Implement improvements for diagnosed root causes.
308
263
 
309
- ### S_VERIFY
310
- Skip if `--skip-fix`.
264
+ 1. **穷尽修复**: Fix ALL diagnosed issues by severity tier (critical → high → medium → low within fix_threshold), one dimension at a time. After each tier, re-verify modified area — new findings append to current tier.
265
+ 2. For each fix: implement → record evidence.ndjson (phase: "fix")
266
+ 3. **Normal**: request_user_input per-fix confirmation. **`-y`**: auto-proceed, record `deferred`.
311
267
 
312
- 1. **Tests**: auto-detect framework, run covering tests on modified files
313
- 2. **CLI fix review**:
314
- ```bash
315
- maestro delegate "PURPOSE: Verify improvement fixes for: {target}
316
- TASK: Check correctness | Assess regression risk | Verify no new issues introduced | Compare metrics
317
- MODE: analysis
318
- CONTEXT: @{modified_files} | Diagnoses: {summary} | Diff: {git_diff} | Baseline: {baseline_metrics}
319
- EXPECTED: JSON {verdict, findings [{severity, description, suggestion}], regression_risk, metrics_comparison}
320
- CONSTRAINTS: Focus on correctness and measurable improvement
321
- " --role review --mode analysis
322
- ```
323
- Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
268
+ 📌 **Auto-commit**: `git add -A && git commit -m "odyssey-improve({slug}): FIX — 改进实现"`
324
269
 
325
- 3. **Metrics comparison**: measure post-fix metrics, compare with `baseline_metrics`
326
- 4. `needs_rework` -> S_FIX (loop). `confirmed` -> mark G4 done, advance
327
- 5. Update §5 with before/after metrics
270
+ ### A_VERIFY
271
+ 1. Run tests covering modified areas
272
+ 2. Re-capture metrics, compare with `session.json.baseline_metrics`
273
+ 3. **CLI-assisted**: `maestro delegate --role review --mode analysis` to check fix correctness, test regressions, measure impact vs baseline. Execute `run_in_background: true`.
274
+ 4. `needs_rework` → S_FIX. `verified` → mark G4 done, advance.
275
+ 5. Write `session.json.confirmation`. Update `understanding.md` §5 (before/after metrics table).
328
276
 
329
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_VERIFY验证"`
277
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): VERIFY改进验证"`
330
278
 
331
- ### S_GENERALIZE
332
- Skip if `--skip-generalize`. Extract patterns from confirmed diagnoses, scan for siblings.
279
+ ### A_GENERALIZE
280
+ Skip if `--skip-generalize`. Pattern 来源: diagnoses + fixes。
333
281
 
334
282
  **Step 1 — Multi-layer pattern extraction:**
335
283
 
@@ -353,129 +301,89 @@ Append Wave 3 rows to `tasks.csv`:
353
301
  ```
354
302
  `spawn_agents_on_csv({ csv_path:"tasks.csv", max_concurrency:4, max_runtime_seconds:300, output_csv_path:"wave-3-results.csv", output_schema:SHARED_OUTPUT_SCHEMA })`
355
303
 
356
- **Step 3 — Cross-layer dedup**: same file:line multi-layer -> boost confidence | single-layer -> `needs_review` | historical fixed -> `regression_risk`
304
+ **Step 3 — Cross-layer dedup**: same file:line multi-layer boost confidence | single-layer `needs_review` | historical fixed `regression_risk`
357
305
 
358
- **Step 4 — Iterative deepening**: module >= 3 hits -> targeted deep scan (max 1 round).
306
+ **Step 4 — Iterative deepening**: module 3 hits targeted deep scan (max 1 round).
359
307
 
360
308
  **Step 5 — Quality Gate** (self-iteration).
361
309
 
362
310
  **Step 6:** Write `generalization_stats`: `{patterns_extracted, total_hits, cross_layer_confirmed, regression_risks, by_layer, deepening_triggered}`. Update §6. Mark G5 done.
363
311
 
364
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_GENERALIZE泛化"`
365
-
366
- ### S_DISCOVER
367
- Skip if no generalization hits.
368
-
369
- 1. **Triage** each hit: read +-10 lines -> classify `safe` / `risk` / `bug` / `issue`
370
- 2. **Route**:
371
- - `bug`/`issue` + directly fixable → **fix immediately** → back to S_FIX
372
- - `bug`/`issue` + requires cross-module/architectural decision → create issue (with fix suggestion + impact analysis)
373
- - `risk` → evaluate if guard/validation can mitigate directly; if yes, fix it
374
- - `safe` → mark skip
375
- See appendix for `-y` behavior. Append evidence (phase: "discovery" + "decision")
376
- 3. **Cross-phase loop**:
377
- - Discovery finds new critical issue → S_DIAGNOSE (cross_phase_loops++)
378
- - Same-pattern with fix template → S_FIX (!skip_fix)
379
- - S_DISCOVER → S_RECORD: triage complete AND remaining_actionable == 0
380
- - S_DISCOVER → S_RECORD: loops >= max_loops → MUST log each unfixed item with specific reason (blanket "pre-existing" is forbidden)
381
- 4. Update §7. Mark G6 done.
382
-
383
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_DISCOVER — 发现"`
384
-
385
- ### S_RECORD
386
- 1. Finalize §8: before/after metrics comparison table
387
- 2. Write §9: structured by Knowledge Persistence table (temporary)
388
- 3. Mark G7 done. Pending decisions: **Normal** -> `request_user_input`. **`-y`** -> skip, show deferred count
389
- 4. **Goal audit**: all confirmed -> `phase_goals_all_done = true`. Any false: **Normal** -> `request_user_input` (回退/跳过/接受). **`-y`** -> auto accept
390
- 5. **Completion**: `current_state = "COMPLETED"`, emit summary:
391
- ```
392
- --- IMPROVE ODYSSEY COMPLETE ---
393
- Target: {target}
394
- Dimensions: {audited_list}
395
- Baseline: {baseline_summary}
396
- Audit: {C}C {H}H {M}M {L}L across {dim_count} dimensions
397
- Diagnoses: {N} root causes ({confirmed} confirmed, {inconclusive} inconclusive)
398
- Fix: {F} applied, {S} skipped | Before: {baseline} -> After: {post_fix}
399
- Patterns: {N} extracted ({by_layer} distribution)
400
- Scan: {total} hits ({cross_layer} cross-layer confirmed)
401
- Issues: {N} created
402
- Decisions: {resolved}/{pending}/{deferred}
403
- Self-iter: {R} quality gate rounds across {P} stages
404
- Goals: {done}/{total} ({skipped} skipped)
405
- ---
406
- ```
407
- **Next steps:** `$manage-issue list --source improve-odyssey`, `$learn-decompose <module>`,
408
- `$quality-review`, `$learn-second-opinion <understanding.md>`, `$learn-investigate "<question>"`
409
-
410
- 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): S_RECORD — 总结"`
411
- </execution>
412
-
413
- <appendix>
414
-
415
- ### Goal Prompt Template
312
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): GENERALIZE泛化扫描"`
416
313
 
417
- **Time guard: display ONCE after S_INTAKE completes (session created, before survey). NEVER redisplay at S_RECORD completion.**
314
+ ### A_DISCOVER
315
+ 按 base A_DISCOVER 执行。Mark G6 done.
418
316
 
419
- ```
420
- Improve Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
317
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DISCOVER — 发现分类"`
421
318
 
422
- /goal 穷尽迭代:直到所有 findings 均已处理(fix/issue/decision)
423
- phase_goals_all_done=true 才停。修复按 severity 逐轮迭代,每轮修复后 re-verify。
424
- Baseline metrics 必须在修复前采集,修复后必须与 baseline 对比。
425
- 不允许"只报告不处理"。遇到 phase=decision pending 必须 request_user_input
426
- ```
319
+ ### A_RECORD
320
+ 1. **understanding.md §8**: Improvement metrics — before/after comparison table from baseline_metrics vs current
321
+ 2. **understanding.md §9**: Engineering learnings — 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
322
+ 3. Mark G7 done. Pending decisions: **Normal** → request_user_input. **`-y`** → skip, show deferred count.
323
+ 4. 其余按 base A_RECORD 执行。
324
+ 5. `current_state = "COMPLETED"`. Emit completion summary: Target, Dimensions, Findings (C/H/M/L), Diagnosed count, Fix count + verified, Metrics (improved/regressed), Patterns (count + layer distribution), Scan hits (cross-layer), Issues created, Decisions (resolved/pending/deferred), Learnings count, Self-iter rounds, Cross-loops used, Goals (done/total/skipped).
427
325
 
428
- Odyssey outputs prompt then continues without blocking. `/goal` entered by user at any time.
429
-
430
- ### `-y` Auto-Confirm Behavior
326
+ 📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): RECORD 指标总结与知识沉淀"`
431
327
 
432
- | Decision Point | Normal | `-y` mode |
433
- |----------------|--------|-----------|
434
- | S_DIAGNOSE ambiguity | request_user_input blocks | record `deferred`, best-effort continue |
435
- | S_DIAGNOSE 3-strike | request_user_input 3-way | auto INCONCLUSIVE |
436
- | S_FIX fix direction | request_user_input confirm | auto proceed by priority |
437
- | S_DISCOVER bug triage | request_user_input per hit | auto create issue |
438
- | S_DISCOVER ambiguous | request_user_input batch | all `deferred` |
439
- | S_RECORD pending decisions | request_user_input per-item | skip, show deferred count |
328
+ </actions>
440
329
 
441
- `deferred` items shown as "待决策" in summary; recoverable via `-c`.
330
+ <appendix>
442
331
 
443
- ### Phase Goal Lifecycle
332
+ ### Goal Prompt Template
333
+ **⚠️ 仅在 A_INTAKE 完成后显示一次,A_RECORD 完成时不重复。**
444
334
 
445
- `pending -> done (confirmed=true)` normal | `pending -> skipped (confirmed=true)` flags/manual | `pending -> failed (confirmed=false)` incomplete
335
+ 列出所有非 skipped phase_goals,附加收敛规则:
336
+ - 穷尽迭代至所有 findings 已处理(fix/issue/decision)且 `phase_goals_all_done=true`
337
+ - 修复按 severity 逐轮迭代,每轮 re-verify
338
+ - Baseline 修复前采集,修复后对比确认改进
339
+ - pending decision 必须 request_user_input,不允许"只报告不处理"
446
340
 
447
- `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
341
+ ### `-y` Auto-Confirm Behavior
342
+ | Decision Point | Normal | `-y` |
343
+ |---------------|--------|------|
344
+ | A_FIX improvement confirmation | request_user_input | auto-proceed, `deferred` |
345
+ | A_DIAGNOSE ambiguity | request_user_input | best-effort, `deferred` |
346
+ | A_ESCALATE 3-strike | request_user_input 3-way | auto INCONCLUSIVE |
347
+ | A_DISCOVER hit routing | request_user_input | auto create issue, `deferred` |
348
+ | A_DISCOVER ambiguous items | request_user_input | all `deferred` |
349
+ | A_RECORD pending decisions | request_user_input | skip, show deferred count |
350
+ | A_RECORD goal audit | request_user_input | auto accept |
351
+
352
+ `deferred` items shown as "待决策" in completion summary; recoverable via `-c`.
448
353
 
449
354
  </appendix>
450
355
 
356
+ </state_machine>
357
+
451
358
  <error_codes>
452
359
  | Code | Severity | Condition | Recovery |
453
360
  |------|----------|-----------|----------|
454
- | E001 | error | No target and no session to resume | Provide target or use -c |
455
- | E002 | error | Target not found or no source files | Check path, ensure source files exist |
456
- | E003 | error | Resume but no session found | Start new session |
457
- | W001 | warning | No relevant git history | Proceed with limited context |
458
- | W002 | warning | Audit dimension agent failed | Partial coverage, note gap |
459
- | W003 | warning | Generalization scan 0 hits | Skip discovery |
460
- | W004 | warning | Delegate parse failed | Use raw output |
361
+ | E001 | error | No target specified | Provide target or use -c |
362
+ | E002 | error | Target path not found | Check path |
363
+ | W001 | warning | No dependency manifest found | Proceed without dep audit |
364
+ | W002 | warning | Some dimension agents failed | Partial audit coverage |
461
365
  </error_codes>
462
366
 
463
367
  <success_criteria>
464
- - [ ] Target resolved to source files, session created with 3 output files
465
- - [ ] Prior knowledge searched (maestro search + sessions + architecture + specs)
466
- - [ ] Survey via spawn Wave 1, baseline_metrics extracted, evidence phase=survey
467
- - [ ] All 6 dimensions audited via spawn Wave 2, severity matrix produced
468
- - [ ] Root causes diagnosed with evidence refs, hypotheses tested phase=diagnose
469
- - [ ] Fixes applied priority-order and verified with metric comparison (unless --skip-fix)
470
- - [ ] `--skip-fix`: no source code modifications
471
- - [ ] Generalization via spawn Wave 3 + cross-layer dedup (unless --skip-generalize)
472
- - [ ] Discoveries classified and routed (fix/issue/decision/skip)
473
- - [ ] understanding.md tracks all 9 sections progressively
474
- - [ ] phase_goals G1-G7 derived from flags, each phase marks its goal
475
- - [ ] Goal Prompt displayed once; `-y` auto-resolves/defers
476
- - [ ] State saved at each transition (resumable via -c)
477
- - [ ] Quality Gate self-iteration logged in self_iteration_log
478
- - [ ] Before/after metrics comparison in completion summary
479
- - [ ] Completion summary with all stats
480
- - [ ] **Every unfixed finding has individual classification and reason** — blanket "pre-existing" labels are forbidden
368
+ - [ ] Target resolved, baseline metrics captured
369
+ - [ ] Survey + 6-dimension audit with structured findings and severity matrix
370
+ - [ ] Root causes diagnosed for critical/high findings
371
+ - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
372
+ - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
373
+ - [ ] Every unfixed finding has individual classification and reason
374
+ - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
375
+ - [ ] phase_goals G1-G7 tracked and audited
376
+ - [ ] Session resumable via -c
481
377
  </success_criteria>
378
+
379
+ <next_step_routing>
380
+ | Condition | Next step |
381
+ |-----------|-----------|
382
+ | Security findings need deep investigation | `$odyssey-debug "<finding>"` |
383
+ | UI-related findings | `$odyssey-ui "<component>"` |
384
+ | Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
385
+ | Architecture pattern to document | `/spec-add arch "..."` |
386
+ | Performance pattern to persist | `/spec-add coding "..."` |
387
+ | Want formal review of changes | `$odyssey-review-test-fix <changed-files>` |
388
+ | Decisions still pending | Filter evidence.ndjson phase=decision status=pending |
389
+ </next_step_routing>