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,7 +1,7 @@
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:
6
6
  - ask_question
7
7
  - define_subagent
@@ -14,6 +14,8 @@ allowed-tools:
14
14
  - view_file
15
15
  - write_to_file
16
16
  ---
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
17
19
  <purpose>
18
20
  Deep codebase improvement: survey → 6-dimension audit → diagnose → fix → verify → generalize → discover → persist.
19
21
  Baseline-first approach with exhaustive iteration until zero remaining actionable findings.
@@ -26,31 +28,6 @@ Baseline-first approach with exhaustive iteration until zero remaining actionabl
26
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.
27
29
  </boundary>
28
30
 
29
- <execution_discipline>
30
- **三条铁律(所有阶段适用):**
31
-
32
- 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
33
- - 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-improve({slug}): {phase} — {摘要}"`
34
- - session.json / evidence.ndjson 为运行时状态,不纳入 commit
35
-
36
- 2. **Confident edits only, but must attempt** — only modify what you're confident about; record decisions only when genuinely requiring human judgment
37
- - Confident → edit code directly, commit
38
- - Needs decision → record `evidence.ndjson {"phase":"decision","status":"pending"}`, don't touch code
39
- - No speculative changes
40
- - ⚠️ **Decision gate** — ONLY these qualify as decisions (not fixes):
41
- - Cross-module architectural tradeoffs requiring human direction
42
- - Ambiguous business semantics where the fix could alter intended behavior
43
- - Requires new dependency or breaking API change
44
- - ❌ "Unsure how to fix", "Large scope", "Pre-existing issue" are NOT valid decision reasons — either fix it, or explain specifically why it's unfixable
45
-
46
- 3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
47
- - survey 阶段: `--role explore` 发现依赖/复杂度热点
48
- - audit/diagnose: `--role analyze` 获取多视角分析
49
- - fix 前后: `--role review` 确认改进正确性
50
-
51
- 4. **禁止以上下文消耗为由中断** — harness 自动处理 context compression,以"上下文不足"或"已执行 N 个阶段"为由中断属于纪律违反;必须完整走完状态机直到 S_RECORD → END
52
- </execution_discipline>
53
-
54
31
  <context>
55
32
  $ARGUMENTS — target and optional flags.
56
33
 
@@ -72,6 +49,7 @@ $ARGUMENTS — target and optional flags.
72
49
  | `--auto` | CLI delegates without confirmation | false |
73
50
  | `-y` | Auto-confirm all decisions (see appendix) | false |
74
51
  | `-c` | Resume most recent session | — |
52
+ | `--heartbeat` | Enable /loop heartbeat protocol (see base) | false |
75
53
 
76
54
  **Dimensions (6):**
77
55
  1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
@@ -83,37 +61,11 @@ $ARGUMENTS — target and optional flags.
83
61
 
84
62
  **Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
85
63
 
86
- **Output 3 files:**
87
- ```
88
- SESSION_DIR/
89
- ├── session.json # state + audit_result + diagnoses + patterns + phase_goals
90
- ├── evidence.ndjson # append-only (phase: survey|audit|diagnosis|fix|discovery|decision|self-iteration)
91
- └── understanding.md # 9-section evolving narrative
92
- ```
93
-
94
- **session.json schema:**
95
- ```json
96
- {
97
- "session_id": "improve-odyssey-{YYYYMMDD-HHmmss}",
98
- "target": "", "dimensions": [],
99
- "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
100
- "current_state": "S_INTAKE",
101
- "baseline_metrics": {},
102
- "audit_result": { "dimensions_audited": [], "finding_count": 0, "severity_distribution": {} },
103
- "diagnoses": [],
104
- "patterns": [],
105
- "confirmation": null,
106
- "generalization_stats": null,
107
- "phase_goals": [], "phase_goals_all_done": false,
108
- "self_iteration_log": [],
109
- "cross_phase_loops": 0, "max_loops": 5,
110
- "created_at": "", "updated_at": ""
111
- }
112
- ```
113
-
114
- **evidence.ndjson unified schema:** `{"ts":"","phase":"<phase>","type":"<type>","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","measurement":""}`
115
-
116
- Phase-specific fields:
64
+ **Output:** `session.json` (state + audit + diagnoses + patterns + goals) | `evidence.ndjson` (append-only) | `understanding.md` (9-section narrative)
65
+
66
+ **session.json unique fields:** `target`, `dimensions`, `baseline_metrics`, `audit_result`, `diagnoses`, `confirmation`, `generalization_stats` (`progress_metrics`, `directions_tried` from base)
67
+
68
+ **evidence.ndjson phase-specific fields:**
117
69
  - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
118
70
  - `audit`: `dimension`, `severity`, `measurement`
119
71
  - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
@@ -133,8 +85,6 @@ Phase-specific fields:
133
85
  | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
134
86
  | G7 | Learnings persisted | S_RECORD | — |
135
87
 
136
- Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`)
137
-
138
88
  **understanding.md — 9 sections (written by owning phase):**
139
89
  1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
140
90
  4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
@@ -142,15 +92,9 @@ Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`
142
92
  8. Improvement Metrics ← S_RECORD (before/after) | 9. Engineering Learnings ← S_RECORD
143
93
 
144
94
  ### Pre-load(可选,缺失不阻塞)
145
-
146
- | 层级 | 命令 | 作用 |
147
- |------|------|------|
148
- | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,作为分析上下文 |
149
- | Wiki search | `maestro search "<target keywords>" --json` | 先前优化、相关决策(取 top 5) |
150
- | Coding specs | `maestro load --type spec --category coding` | 编码规范 |
151
- | Debug specs | `maestro load --type spec --category debug` | 已知性能/安全模式 |
152
- | Role knowledge | `maestro search --category coding` → 选相关 → `maestro load --type knowhow --id <id>` | 累积领域知识 |
153
- | Prior sessions | `grep_search(".workflow/scratch/*-improve-odyssey-*")` | 相关会话 |
95
+ - ARCHITECTURE.md → 模块边界 | `maestro search "<target>" --json` → 先前优化(top 5)
96
+ - `maestro load --type spec --category coding` + `--category debug` → 编码规范 + 已知模式
97
+ - `maestro search --category coding` → knowhow | `grep_search(".workflow/scratch/*-improve-odyssey-*")` → 先前会话
154
98
 
155
99
  ### Knowledge Persistence(S_RECORD 中写入产出文件)
156
100
 
@@ -162,25 +106,9 @@ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §9 Learnings**,
162
106
  | 安全规则 | 漏洞类别 + 修复 + 预防方法 | `/spec-add debug "..."` |
163
107
  | 架构约束 | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
164
108
  | 可靠性 pattern | 故障模式 + 处理策略 + 验证手段 | `/spec-add coding "..."` |
165
-
166
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
167
109
  </context>
168
110
 
169
- <self_iteration>
170
- **Quality Gate** — auto-evaluate after each analytical phase. Insufficient → re-enter (max **3 rounds**).
171
-
172
- | Dimension | Sufficient | Insufficient |
173
- |-----------|-----------|-------------|
174
- | Coverage | All target files/modules analyzed across dimensions | Missed files discoverable via grep/glob |
175
- | Depth | ≥80% findings have file:line evidence + measurement | Most findings lack specifics |
176
- | Actionability | Each conclusion has concrete fix or issue action | "Consider reviewing" without action |
177
-
178
- **Expansion:** Round 1 = widen scope (more modules, deeper import chain, extra delegate angles). Round 2 = shift perspective (different CLI tool, reverse dependency trace, manual code reading). Round 3 = combine both + targeted deep-dive on remaining gaps.
179
-
180
- **Log:** `evidence.ndjson ← {"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{},"expansion":""}`
181
-
182
- **Applicable stages:** S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE
183
- </self_iteration>
111
+ Self-iteration 适用阶段: S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE
184
112
 
185
113
  <state_machine>
186
114
 
@@ -254,38 +182,14 @@ Find latest session via Glob → read `session.json` → display summary → jum
254
182
  ### A_SURVEY
255
183
  Current state survey — understand what exists before proposing changes.
256
184
 
257
- 1. **Dependency audit**: Read package.json/lock files, scan for outdated/vulnerable deps
258
- 2. **Complexity scan**: Identify high-complexity files (file size, function count, nesting depth)
259
- 3. **Test coverage map**: Which modules have coverage, which don't
260
- 4. **Error handling scan**: Grep for empty catch, unhandled promise, missing error boundaries
261
- 5. **CLI-assisted survey** (optional):
262
- ```bash
263
- maestro delegate "PURPOSE: Survey codebase health of: {target}
264
- TASK: Dependency health | Complexity hotspots | Test coverage gaps | Error handling patterns
265
- MODE: analysis
266
- CONTEXT: @{target_files}
267
- EXPECTED: JSON {dependency_health, complexity_hotspots, coverage_gaps, error_patterns}
268
- CONSTRAINTS: Focus on runtime quality, not style
269
- " --role analyze --mode analysis
270
- ```
271
- Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
272
-
273
- 6. Append evidence.ndjson (phase: "survey"). Update `understanding.md` §2. Mark G1 done.
185
+ 1. Dependency audit (package.json/lock), complexity scan (size/nesting), test coverage map, error handling scan (empty catch, unhandled promise)
186
+ 2. **CLI-assisted** (optional): `maestro delegate` with `--role analyze --mode analysis` for dependency health, complexity hotspots, coverage gaps, error patterns. Execute `run_in_background: true`.
187
+ 3. Append evidence.ndjson (phase: "survey"). Update `understanding.md` §2. Mark G1 done.
274
188
 
275
189
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): SURVEY — 现状调查"`
276
190
 
277
191
  ### A_AUDIT
278
- Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset):
279
-
280
- | Agent | Dimension | Focus |
281
- |-------|-----------|-------|
282
- | Performance | performance | Hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading |
283
- | Security | security | OWASP Top 10, injection, auth bypass, data exposure, dependency vulns, secrets |
284
- | Architecture | architecture | Layer violations, circular deps, coupling, interface contracts, SRP violations |
285
- | Reliability | reliability | Error handling gaps, retry logic, timeout handling, graceful degradation, cleanup |
286
- | Observability | observability | Logging coverage, metric gaps, trace propagation, error reporting, health checks |
287
- | Maintainability | maintainability | Cyclomatic complexity, dead code, test coverage gaps, documentation debt |
288
-
192
+ Spawn 6 parallel Agents (one per dimension from Dimensions list above, or `--dimensions` subset).
289
193
  Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
290
194
 
291
195
  Merge → evidence.ndjson (phase: "audit"). Write `session.json.audit_result`.
@@ -296,25 +200,10 @@ Update `understanding.md` §3 (findings by dimension + severity matrix). Mark G2
296
200
  ### A_DIAGNOSE
297
201
  Root cause analysis for critical/high findings — don't fix symptoms.
298
202
 
299
- 1. Group findings by dimension, prioritize by severity
300
- 2. For each critical/high finding:
301
- - Form hypothesis about root cause
302
- - Test: trace code path, check git history, verify with evidence
303
- - Record to evidence.ndjson (phase: "diagnosis")
304
- 3. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: ask_question | `-y`: defer
305
- 4. **CLI-assisted diagnosis** for complex findings:
306
- ```bash
307
- maestro delegate "PURPOSE: Diagnose root cause of: {finding}
308
- TASK: Trace code path | Check for systemic pattern | Identify fix approach
309
- MODE: analysis
310
- CONTEXT: @{relevant_files} | Finding: {finding_detail}
311
- EXPECTED: JSON {root_cause, systemic, fix_approach, risk}
312
- CONSTRAINTS: Focus on root cause, not symptom
313
- " --role analyze --mode analysis
314
- ```
315
- Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
316
-
317
- 5. Write `session.json.diagnoses[]`. Update `understanding.md` §4. Mark G3 done.
203
+ 1. Group by dimension, prioritize by severity. For each: hypothesis → trace code path + git history → evidence.ndjson (phase: "diagnosis")
204
+ 2. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: ask_question | `-y`: defer
205
+ 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`.
206
+ 4. Write `session.json.diagnoses[]`. Update `understanding.md` §4. Mark G3 done.
318
207
 
319
208
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DIAGNOSE — 根因诊断"`
320
209
 
@@ -331,68 +220,21 @@ Skip if `--skip-fix`. Implement improvements for diagnosed root causes.
331
220
  📌 **Auto-commit**: `git add -A && git commit -m "odyssey-improve({slug}): FIX — 改进实现"`
332
221
 
333
222
  ### A_VERIFY
334
- Verify improvements with measurement comparison.
335
-
336
223
  1. Run tests covering modified areas
337
- 2. **Measure improvement**: re-capture metrics, compare with `session.json.baseline_metrics`
338
- 3. **CLI-assisted verification**:
339
- ```bash
340
- maestro delegate "PURPOSE: Verify improvements for: {target}
341
- TASK: Check fix correctness | Test regressions | Measure impact | Compare with baseline
342
- MODE: analysis
343
- CONTEXT: @{modified_files} | Baseline: {baseline_metrics} | Fixes: {fix_summary}
344
- EXPECTED: JSON {verdict, metrics_improved, regressions, remaining_issues}
345
- CONSTRAINTS: Focus on correctness and measurable improvement
346
- " --role review --mode analysis
347
- ```
348
- Execute with `run_in_background: true`, then wait for callback (do NOT halt the Odyssey flow).
349
-
224
+ 2. Re-capture metrics, compare with `session.json.baseline_metrics`
225
+ 3. **CLI-assisted**: `maestro delegate --role review --mode analysis` to check fix correctness, test regressions, measure impact vs baseline. Execute `run_in_background: true`.
350
226
  4. `needs_rework` → S_FIX. `verified` → mark G4 done, advance.
351
227
  5. Write `session.json.confirmation`. Update `understanding.md` §5 (before/after metrics table).
352
228
 
353
229
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): VERIFY — 改进验证"`
354
230
 
355
231
  ### A_GENERALIZE
356
- Multi-layer pattern extraction from diagnoses + fixes 4-agent scan → cross-layer dedup.
357
-
358
- **Pattern extraction** from root causes + improvements:
359
-
360
- | Layer | Method | Example |
361
- |-------|--------|---------|
362
- | Syntax | Regex → direct Grep | Missing `await`, unclosed resource, empty catch, `eval(` |
363
- | Semantic | Agent understands anti-pattern → scans | Unhandled async errors, missing retry, N+1 query |
364
- | Structural | File/module structure similarity | Same import pattern, missing error boundary |
365
- | Historical | `git log -S "{pattern}"` | When similar issues were introduced/fixed |
366
-
367
- Write `session.json.patterns[]`: `[{id, source_finding, layer, signature, description, risk, fix_template, confidence}]`
368
-
369
- **4-agent parallel scan** (single message):
370
-
371
- | Agent | Strategy | Scope |
372
- |-------|----------|-------|
373
- | Syntax grep | Grep patterns matching found issues | Full project |
374
- | Semantic scan | Find modules with same anti-pattern | Related modules |
375
- | Structural match | Find structurally similar files | Full project |
376
- | Historical grep | `git log -S "{pattern}"` | Git history |
377
-
378
- **Cross-layer dedup**: Multi-layer hit → boost confidence. Single-layer → `needs_review`. Historical match on fixed code → `regression_risk`.
379
-
380
- **Iterative deepening**: Module with ≥3 hits → targeted deep scan (max 1 round).
381
-
382
- Update `understanding.md` §6. Write `session.json.generalization_stats`. Mark G5 done.
232
+ base A_GENERALIZE 执行。Pattern 来源: diagnoses + fixes。Mark G5 done.
383
233
 
384
234
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): GENERALIZE — 泛化扫描"`
385
235
 
386
236
  ### A_DISCOVER
387
- 1. **Triage** each hit: read ±10 lines context → classify `safe`/`risk`/`issue`
388
- 2. **Route**:
389
- - `issue` + directly fixable → **fix immediately** → back to S_FIX
390
- - `issue` + requires cross-module/architectural decision → create issue (with fix suggestion + impact analysis)
391
- - `risk` → evaluate if guard/validation can mitigate directly; if yes, fix it
392
- - `safe` → mark skip
393
- **Normal**: ask_question for routing ambiguity. **`-y`**: auto-fix what's fixable, create issue for rest.
394
- 3. **Cross-phase loops**: new critical issue → S_DIAGNOSE; same-pattern fix → S_FIX.
395
- 4. Append evidence (phase: "discovery" + "decision"). Update `understanding.md` §7. Mark G6 done.
237
+ base A_DISCOVER 执行。Mark G6 done.
396
238
 
397
239
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DISCOVER — 发现分类"`
398
240
 
@@ -400,26 +242,8 @@ Update `understanding.md` §6. Write `session.json.generalization_stats`. Mark G
400
242
  1. **understanding.md §8**: Improvement metrics — before/after comparison table from baseline_metrics vs current
401
243
  2. **understanding.md §9**: Engineering learnings — 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
402
244
  3. Mark G7 done. Pending decisions: **Normal** → ask_question. **`-y`** → skip, show deferred count.
403
- 4. **Goal audit**: all `phase_goals[*].completion_confirmed` true → `phase_goals_all_done = true`. Any false: **Normal** → ask_question (回退/跳过/接受) | **`-y`** → auto accept.
404
- 5. `current_state = "COMPLETED"`. Emit completion summary:
405
- ```
406
- --- IMPROVE ODYSSEY COMPLETE ---
407
- Target: {target}
408
- Dimensions: {dimensions_audited}
409
- Findings: {C}C {H}H {M}M {L}L
410
- Diagnosed: {diagnosed_count} root causes identified
411
- Fix: {fixed_count} improvements, verified={yes|skipped}
412
- Metrics: {improved} improved, {regressed} regressed
413
- Patterns: {extracted} ({by_layer} distribution)
414
- Scan hits: {total} ({cross_layer} cross-layer confirmed)
415
- Issues: {N} created
416
- Decisions: {N} resolved, {M} pending, {K} deferred
417
- Learnings: {N} entries in understanding.md §9
418
- Self-iter: {N} quality gate rounds across {M} stages
419
- Cross-loops: {cross_phase_loops}/{max_loops} used
420
- Goals: {done}/{total} ({skipped} skipped)
421
- ---
422
- ```
245
+ 4. 其余按 base A_RECORD 执行。
246
+ 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).
423
247
 
424
248
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): RECORD — 指标总结与知识沉淀"`
425
249
 
@@ -428,22 +252,13 @@ Goals: {done}/{total} ({skipped} skipped)
428
252
  <appendix>
429
253
 
430
254
  ### Goal Prompt Template
431
- **⚠️ 时机守卫:仅在 A_INTAKE 完成后显示一次。A_RECORD 完成时禁止重新显示。**
255
+ **⚠️ 仅在 A_INTAKE 完成后显示一次,A_RECORD 完成时不重复。**
432
256
 
433
- ```
434
- 📋 Improve Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
435
-
436
- /goal 完成以下目标:
437
- {for each G in phase_goals where status != "skipped":}
438
- - {G.id}: {G.goal} — 完成条件: {G.done_when}
439
- {end for}
440
- 穷尽迭代:直到 session.json 的 audit_result 中所有 findings 均已处理(fix/issue/decision)
441
- 且 phase_goals_all_done=true 才停。修复按 severity 逐轮迭代,每轮修复后 re-verify 修改区域。
442
- Baseline metrics 必须在修复前采集,修复后必须与 baseline 对比确认改进。
443
- 遇到 phase=decision 的 pending 必须 ask_question。不允许"只报告不处理"。
444
- ```
445
-
446
- 完成时仅输出 completion summary,不重复此提示。
257
+ 列出所有非 skipped 的 phase_goals,附加收敛规则:
258
+ - 穷尽迭代至所有 findings 已处理(fix/issue/decision)且 `phase_goals_all_done=true`
259
+ - 修复按 severity 逐轮迭代,每轮 re-verify
260
+ - Baseline 修复前采集,修复后对比确认改进
261
+ - pending decision 必须 ask_question,不允许"只报告不处理"
447
262
 
448
263
  ### `-y` Auto-Confirm Behavior
449
264
  | Decision Point | Normal | `-y` |
@@ -458,11 +273,6 @@ Baseline metrics 必须在修复前采集,修复后必须与 baseline 对比
458
273
 
459
274
  `deferred` items shown as "待决策" in completion summary; recoverable via `-c`.
460
275
 
461
- ### Phase Goal Lifecycle
462
- `pending → done (confirmed=true)` normal | `pending → skipped (confirmed=true)` flags/manual | `pending → failed (confirmed=false)` exception
463
-
464
- `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
465
-
466
276
  </appendix>
467
277
 
468
278
  </state_machine>
@@ -472,30 +282,19 @@ Baseline metrics 必须在修复前采集,修复后必须与 baseline 对比
472
282
  |------|----------|-----------|----------|
473
283
  | E001 | error | No target specified | Provide target or use -c |
474
284
  | E002 | error | Target path not found | Check path |
475
- | E003 | error | Resume but no session found | Start new session |
476
285
  | W001 | warning | No dependency manifest found | Proceed without dep audit |
477
286
  | W002 | warning | Some dimension agents failed | Partial audit coverage |
478
- | W003 | warning | Generalization 0 hits | Skip discovery |
479
- | W004 | warning | Delegate parse failed | Use raw output |
480
287
  </error_codes>
481
288
 
482
289
  <success_criteria>
483
- - [ ] Target resolved, baseline metrics captured in session.json
484
- - [ ] Dependency + complexity + coverage survey completed
485
- - [ ] All dimensions audited (6 parallel agents) with structured findings
486
- - [ ] Severity matrix produced
487
- - [ ] Root causes diagnosed for critical/high findings (hypothesis-driven)
290
+ - [ ] Target resolved, baseline metrics captured
291
+ - [ ] Survey + 6-dimension audit with structured findings and severity matrix
292
+ - [ ] Root causes diagnosed for critical/high findings
488
293
  - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
489
- - [ ] Multi-layer generalization scan + cross-layer dedup (unless --skip-generalize)
490
- - [ ] Cross-phase loops used when discoveries warrant
491
- - [ ] Quality Gate self-iteration triggered when insufficient
492
- - [ ] Discoveries classified and routed
493
- - [ ] **Every unfixed finding has individual classification and reason** — blanket "pre-existing" labels are forbidden
494
- - [ ] understanding.md §8: improvement metrics (before/after comparison)
495
- - [ ] understanding.md §9: engineering learnings
294
+ - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
295
+ - [ ] Every unfixed finding has individual classification and reason
296
+ - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
496
297
  - [ ] phase_goals G1-G7 tracked and audited
497
- - [ ] Goal Prompt displayed once
498
- - [ ] `-y`: no blocking prompts, deferred counted
499
298
  - [ ] Session resumable via -c
500
299
  </success_criteria>
501
300
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: odyssey-planex
3
3
  description: Requirement-driven iterative cycle — plan, execute, strict verify, fix loop until acceptance criteria met
4
- argument-hint: <requirement> [--max-iterations N] [--skip-generalize] [--auto] [--method agent|cli|auto] [--executor <tool>] [--skip-verify] [-y] [-c]
4
+ argument-hint: <requirement> [--max-iterations N] [--skip-generalize] [--auto] [--method agent|cli|auto] [--executor <tool>] [--skip-verify] [--heartbeat] [-y] [-c]
5
5
  allowed-tools:
6
6
  - ask_question
7
7
  - define_subagent
@@ -14,6 +14,8 @@ allowed-tools:
14
14
  - view_file
15
15
  - write_to_file
16
16
  ---
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
17
19
  <purpose>
18
20
  Requirement-to-delivery closed loop: parse requirement → define acceptance criteria →
19
21
  plan → execute → verify → fix gaps → iterate until ALL criteria pass.
@@ -23,7 +25,6 @@ plan → execute → verify → fix gaps → iterate until ALL criteria pass.
23
25
  **范围内:** 单一需求的实现闭环 — 从需求解析到验收标准全部通过 + 泛化同类场景
24
26
  **范围外:** 多需求编排 → `/maestro-roadmap` | 深度 debugging → `/odyssey-debug` | 代码审查 → `/odyssey-review-test-fix` | UI 优化 → `/odyssey-ui`
25
27
  **探索自由度:** 边界内自由探索 — 可自主分解任务、选择实现策略、迭代修复。verify→fix 循环内可尝试不同方案。
26
- **Zero-residual principle:** Every failing criterion MUST be fixed or explicitly escalated with specific reason. "Close enough" is not passing. "Pre-existing gap" is not a valid skip reason — if within scope, address it.
27
28
  **模板支持:** `--template <name>` 从预定义需求模板启动,自动生成匹配的验收标准和任务分解:
28
29
 
29
30
  | Template | 预设 criteria 模式 | 适用场景 |
@@ -35,31 +36,6 @@ plan → execute → verify → fix gaps → iterate until ALL criteria pass.
35
36
  | `api-endpoint` | 请求/响应契约 + 错误处理 + 权限校验 | API 开发 |
36
37
  </boundary>
37
38
 
38
- <execution_discipline>
39
- **三条铁律(所有阶段适用):**
40
-
41
- 1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
42
- - 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-planex({slug}): {phase} — {摘要}"`
43
- - session.json / evidence.ndjson 为运行时状态,不纳入 commit
44
-
45
- 2. **Confident edits only, but must attempt** — only modify what you're confident about; record decisions only when genuinely requiring human judgment
46
- - Confident → edit code directly, commit
47
- - Needs decision → record `evidence.ndjson {"phase":"decision","status":"pending"}`, don't touch code
48
- - No speculative changes
49
- - ⚠️ **Decision gate** — ONLY these qualify as decisions (not fixes):
50
- - Cross-module architectural tradeoffs requiring human direction
51
- - Ambiguous business semantics where the fix could alter intended behavior
52
- - Requires new dependency or breaking API change
53
- - ❌ "Unsure how to fix", "Large scope", "Pre-existing issue" are NOT valid decision reasons — either fix it, or explain specifically why it's unfixable
54
-
55
- 3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
56
- - 计划阶段: `--role analyze` 获取任务分解建议
57
- - 修复前后: `--role review` 确认无回归
58
- - verify 阶段: cli-review 类型标准自动 delegate
59
-
60
- 4. **禁止以上下文消耗为由中断** — harness 自动处理 context compression,以"上下文不足"或"已执行 N 个阶段"为由中断属于纪律违反;必须完整走完状态机直到 S_RECORD → END
61
- </execution_discipline>
62
-
63
39
  <context>
64
40
  $ARGUMENTS — requirement description and optional flags.
65
41
 
@@ -73,6 +49,7 @@ $ARGUMENTS — requirement description and optional flags.
73
49
  | `--method agent\|cli\|auto` | Execution method: Agent tool, CLI delegate, or auto-select | `auto` |
74
50
  | `--executor <tool>` | Explicit executor tool for CLI delegate mode | First enabled in config |
75
51
  | `--skip-verify` | Skip execution post-validation gate | false |
52
+ | `--heartbeat` | Enable periodic progress heartbeat | false |
76
53
  | `-y` | Auto-confirm — decisions recorded as `deferred` | false |
77
54
  | `-c` | Resume most recent session | — |
78
55
 
@@ -116,6 +93,8 @@ SESSION_DIR/
116
93
  "phase_goals": [],
117
94
  "phase_goals_all_done": false,
118
95
  "self_iteration_log": [],
96
+ "progress_metrics": "→ base",
97
+ "directions_tried": "→ base",
119
98
  "cross_phase_loops": 0, "max_loops": 5,
120
99
  "created_at": "", "updated_at": ""
121
100
  }
@@ -157,24 +136,10 @@ S_RECORD 阶段将可沉淀知识 **写入 understanding.md §8 Learnings**,
157
136
  | 可复用实现模式 | 模式描述 + 适用场景 + 代码模板 | `/spec-add coding "..."` |
158
137
  | 验收标准模板 | 标准模板 + verify_method 建议 | `/spec-add review "..."` |
159
138
  | 泛化 pattern | pattern 签名 + 风险说明 + fix 模板 | `/spec-add coding "..."` |
160
-
161
- **两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
162
139
  </context>
163
140
 
164
141
  <self_iteration>
165
- **Quality Gate** auto-evaluate after each analytical stage. Insufficient → re-enter with expanded strategy.
166
-
167
- | Dimension | Sufficient | Insufficient |
168
- |-----------|-----------|-------------|
169
- | Coverage | All known files/modules analyzed | Missed targets discoverable via grep/git log |
170
- | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
171
- | Actionability | Each conclusion has concrete next action | Only vague "consider" recommendations |
172
-
173
- **Rules:** stage complete → evaluate 3 dims → any insufficient → re-enter (max **3 rounds** per stage). Record to evidence.ndjson `{"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{...},"expansion":"strategy"}`.
174
-
175
- **Expansion:** Round 1 = broaden scope (more dirs, more delegate angles). Round 2 = shift perspective (different CLI tool, reverse-trace from expected result). Round 3 = combine both + targeted deep-dive on remaining gaps.
176
-
177
- **Applies to:** S_PLAN, S_VERIFY, S_GENERALIZE
142
+ 适用阶段: S_PLAN, S_VERIFY, S_GENERALIZE
178
143
  </self_iteration>
179
144
 
180
145
  <state_machine>
@@ -263,7 +228,6 @@ ask_question({
263
228
  options: [
264
229
  { label: "Auto (Recommended)", description: "域路由: frontend→{frontendTool}, backend→{backendTool}, general→agent" },
265
230
  { label: "Agent", description: "Claude Code Agent 执行所有任务(最快)" },
266
- // 每个 enabled CLI tool 一个选项
267
231
  ...availableTools.map(t => ({ label: t, description: `${t} CLI 执行所有任务` }))
268
232
  ]
269
233
  },
@@ -304,13 +268,6 @@ Per-task domain routing (when method == "auto"):
304
268
 
305
269
  Resolution: `execution_config.domain_routing[domain]` → fallback `domain_routing.default` ("agent").
306
270
 
307
- Log routing per task:
308
- ```
309
- T1 [frontend] → agy
310
- T2 [backend] → codex
311
- T3 [general] → agent
312
- ```
313
-
314
271
  #### Step 3: Task Execution
315
272
 
316
273
  Execute tasks per plan order. Independent tasks (no cross-dependency) may run in parallel.
@@ -442,50 +399,20 @@ Update understanding.md §4 with pass/fail table.
442
399
 
443
400
  ### A_GENERALIZE
444
401
 
445
- Extract reusable patterns from implementation, scan codebase for similar sites.
446
-
447
- **Pattern extraction (3 layers):**
448
- | Layer | Method | Example |
449
- |-------|--------|---------|
450
- | Syntax | Code regex patterns | validation/error handling patterns |
451
- | Semantic | Logic pattern description | missing similar checks at other entry points |
452
- | Structural | File/module structure match | sibling modules lacking same treatment |
453
-
454
- **4-agent parallel scan** (spawn 4 Agents):
455
- | Agent | Strategy | Scope |
456
- |-------|----------|-------|
457
- | Syntax grep | Grep syntax-layer signatures | full project |
458
- | Semantic scan | Check for same anti-pattern in related modules | related modules |
459
- | Structural match | Find structurally similar files | full project |
460
- | Historical grep | `git log -S "{pattern}"` | full git history |
461
-
462
- Each returns: `[{pattern_id, file, line, context, risk_level, layer, confidence}]`
463
-
464
- **Cross-layer dedup:** multi-layer hit on same file:line → boost confidence. Historical hit with existing fix → `already_handled`. Single layer only → `needs_review`.
465
-
466
- **Quality Gate** (self-iteration) → evaluate coverage/depth/actionability.
467
-
468
- Write understanding.md §6, generalization_stats. Mark G5 done.
402
+ base A_GENERALIZE 执行。Pattern 来源: implementation patterns。Mark G5 done.
469
403
 
470
404
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): GENERALIZE — 泛化扫描"`
471
405
 
472
406
  ### A_DISCOVER
473
407
 
474
- 1. **Triage:** per hit, read context (+-10 lines), classify as `already_handled` | `needs_treatment` | `low_risk`
475
- 2. **Route:**
476
- | Classification | Normal | `-y` |
477
- |---------------|--------|------|
478
- | needs_treatment | ask_question: create issue / plan next iter | auto create issue, `deferred` |
479
- | low_risk | Record only | Record only |
480
- | already_handled | Skip | Skip |
481
- 3. Append evidence (discovery + decision), update understanding.md §7. Mark G6 done.
408
+ base A_DISCOVER 执行。Mark G6 done.
482
409
 
483
410
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): DISCOVER — 发现分类"`
484
411
 
485
412
  ### A_RECORD
486
413
 
487
414
  1. Finalize understanding.md §8 — iteration summary, what worked, what needed rework
488
- 2. Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
415
+ 2. Write learnings to understanding.md §8: 按 Knowledge Persistence 表分类记录
489
416
  3. Pending decisions: **Normal** → ask_question. **`-y`** → display deferred count.
490
417
  4. Goal audit: check all phase_goals[*].completion_confirmed. Mark G7 done.
491
418
  5. Output completion summary:
@@ -503,6 +430,7 @@ Write understanding.md §6, generalization_stats. Mark G5 done.
503
430
  Status: {ALL_PASSED|PARTIAL|ESCALATED}
504
431
  ---
505
432
  ```
433
+ 6. 其余按 base A_RECORD 执行。
506
434
 
507
435
  📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-planex({slug}): RECORD — 会话总结"`
508
436
 
@@ -568,35 +496,23 @@ Max iterations (default 3) prevents infinite loops. Each iteration records crite
568
496
  | Code | Severity | Condition | Recovery |
569
497
  |------|----------|-----------|----------|
570
498
  | E001 | error | No requirement provided | Provide requirement |
571
- | E003 | error | Resume but no session found | Start new |
572
- | E004 | error | Delegate failed | Retry or proceed without |
573
499
  | W001 | warning | No acceptance criteria derived | Manual definition needed |
574
500
  | W002 | warning | Max iterations reached, criteria still failing | Escalate to user |
575
501
  | W003 | warning | CLI review regression concern | Review before next iteration |
576
- | W004 | warning | Delegate parse failed | Use raw output |
577
502
  </error_codes>
578
503
 
579
504
  <success_criteria>
580
- - [ ] Requirement parsed and ≥1 acceptance criterion defined with verify_method
581
- - [ ] Plan created with tasks mapped to criteria
582
- - [ ] Execution options confirmed (executor/review/verify) before task dispatch
583
- - [ ] Tasks dispatched via resolved executor (agent/cli/auto domain routing)
584
- - [ ] Per-task deviation rule enforced (max 3 retries, fallback chain)
505
+ - [ ] Requirement parsed with ≥1 acceptance criterion (verify_method assigned)
506
+ - [ ] Plan tasks mapped to criteria; execution options confirmed
507
+ - [ ] Tasks dispatched via resolved executor with deviation rule (max 3 retries)
585
508
  - [ ] Post-execution validation gate run (unless --skip-verify)
586
- - [ ] Tasks executed with evidence logged (executor, attempt count, files_modified)
587
- - [ ] Every criterion verified by its method after each iteration
588
- - [ ] Failing criteria trigger targeted fix (not full re-implementation)
589
- - [ ] Iteration count tracked, max respected
590
- - [ ] **Every unfixed criterion has individual classification and reason** — blanket "pre-existing" labels are forbidden
591
- - [ ] understanding.md updated per phase (§1-§8)
592
- - [ ] Multi-layer generalization + 4-agent scan (unless --skip-generalize)
593
- - [ ] Discoveries classified and routed (unless --skip-generalize)
594
- - [ ] Quality Gate self-iteration triggered when insufficient, logged in self_iteration_log
595
- - [ ] phase_goals G1-G7 tracked and audited
596
- - [ ] Goal Prompt displayed once after intake
597
- - [ ] `-y` mode: no blocking prompts, deferred counted
598
- - [ ] Session resumable via -c
599
- - [ ] Completion summary with iteration stats
509
+ - [ ] Every criterion verified per method; failing targeted fix (not re-implementation)
510
+ - [ ] Iteration count tracked and max respected; unfixed criteria individually classified
511
+ - [ ] understanding.md §1-§8 updated per phase; phase_goals G1-G7 audited
512
+ - [ ] Generalization + discovery completed (unless --skip-generalize)
513
+ - [ ] Quality Gate self-iteration triggered when insufficient
514
+ - [ ] Goal Prompt displayed once after intake; `-y` mode: no blocking prompts
515
+ - [ ] Session resumable via -c; completion summary output
600
516
  </success_criteria>
601
517
 
602
518
  <next_step_routing>