maestro-flow-one 0.2.33 → 0.2.34
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.
- package/maestro-flow/commands/lifecycle/odyssey-debug.md +473 -0
- package/maestro-flow/commands/lifecycle/odyssey-improve.md +505 -0
- package/maestro-flow/commands/lifecycle/odyssey-planex.md +601 -0
- package/maestro-flow/commands/lifecycle/odyssey-review-test-fix.md +427 -0
- package/maestro-flow/commands/lifecycle/odyssey-ui.md +462 -0
- package/maestro-flow/commands/lifecycle/security-audit.md +179 -0
- package/package.json +1 -1
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: odyssey-improve
|
|
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]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Glob
|
|
11
|
+
- Grep
|
|
12
|
+
- Agent
|
|
13
|
+
- AskUserQuestion
|
|
14
|
+
---
|
|
15
|
+
<purpose>
|
|
16
|
+
Deep codebase improvement cycle: survey (current state) → audit (6 dimensions) → diagnose (root cause per finding) → fix → verify → generalize (举一反三) → discover siblings → persist learnings.
|
|
17
|
+
|
|
18
|
+
Unlike `quality-review` (pass/fail gate) or `odyssey-review-test-fix` (code review focus), this treats every finding as a runtime quality signal — performance bottlenecks, security vulnerabilities, architectural debt, reliability gaps, and observability blind spots. Combines static analysis with runtime-aware reasoning.
|
|
19
|
+
|
|
20
|
+
Core philosophy:
|
|
21
|
+
- **Measure before improving** — baseline first, then optimize
|
|
22
|
+
- **Root cause over symptom** — trace each issue to its origin
|
|
23
|
+
- **Fix one, improve many** — every improvement reveals a class of opportunities
|
|
24
|
+
- **Verify improvement** — measure after fix, compare with baseline
|
|
25
|
+
|
|
26
|
+
**三句哲学约束(穷尽迭代):**
|
|
27
|
+
1. **零遗留** — 每个 finding 必须是 action item(修复 / issue / 决策),不允许只报告不处理
|
|
28
|
+
2. **穷尽迭代** — 按 severity 从高到低逐轮修复,直到 0 remaining actionable findings 才退出 fix loop
|
|
29
|
+
3. **改进即标准** — 每次修复后重审同区域,发现新问题继续修,直到该区域无可改善
|
|
30
|
+
|
|
31
|
+
Entry: `/odyssey-improve "target"` (full cycle) | `-c` (resume) | `--skip-fix` (audit-only)
|
|
32
|
+
</purpose>
|
|
33
|
+
|
|
34
|
+
<boundary>
|
|
35
|
+
**范围内:** 目标代码的运行质量提升 — 性能/安全/架构/可靠性/可观测性/可维护性多维度审查 → 诊断 → 修复 → 泛化
|
|
36
|
+
**范围外:** UI 视觉优化 → `/odyssey-ui` | 新功能实现 → `/odyssey-planex` | 单一 bug 调查 → `/odyssey-debug` | 代码风格审查 → `/odyssey-review-test-fix`
|
|
37
|
+
**探索自由度:** 边界内自由探索 — 可 profiling、安全扫描、架构分析、依赖审计。在约束下尽可能发现深层问题。
|
|
38
|
+
</boundary>
|
|
39
|
+
|
|
40
|
+
<execution_discipline>
|
|
41
|
+
**三条铁律(所有阶段适用):**
|
|
42
|
+
|
|
43
|
+
1. **Phase auto-commit** — 每个阶段完成后**自动** `git commit`,无需用户确认
|
|
44
|
+
- 代码变更 + understanding.md → `git add` → `git commit -m "odyssey-improve({slug}): {phase} — {摘要}"`
|
|
45
|
+
- session.json / evidence.ndjson 为运行时状态,不纳入 commit
|
|
46
|
+
|
|
47
|
+
2. **有把握才改** — 仅修改自己有把握的内容;不确定的记录决策等人判断
|
|
48
|
+
- 有把握 → 直接修改代码,commit
|
|
49
|
+
- 需要决策 → 记录 `evidence.ndjson {"phase":"decision","status":"pending"}` 不改代码
|
|
50
|
+
- 禁止猜测性修改,宁可多记录一条 decision 也不冒险改错
|
|
51
|
+
|
|
52
|
+
3. **多 CLI 辅助** — 利用 `maestro delegate` 调用多个 CLI 工具交叉验证
|
|
53
|
+
- survey 阶段: `--role explore` 发现依赖/复杂度热点
|
|
54
|
+
- audit/diagnose: `--role analyze` 获取多视角分析
|
|
55
|
+
- fix 前后: `--role review` 确认改进正确性
|
|
56
|
+
</execution_discipline>
|
|
57
|
+
|
|
58
|
+
<context>
|
|
59
|
+
$ARGUMENTS — target and optional flags.
|
|
60
|
+
|
|
61
|
+
**Target resolution:**
|
|
62
|
+
| Input | Resolution |
|
|
63
|
+
|-------|-----------|
|
|
64
|
+
| Module/dir path | Audit that module |
|
|
65
|
+
| `HEAD` / `staged` | Review changes in diff |
|
|
66
|
+
| Feature area keyword | Resolve to related files |
|
|
67
|
+
| `--all` | Full project scan (use with caution) |
|
|
68
|
+
|
|
69
|
+
**Flags:**
|
|
70
|
+
| Flag | Effect | Default |
|
|
71
|
+
|------|--------|---------|
|
|
72
|
+
| `--dimensions <list>` | Comma-separated subset of 6 dimensions | all 6 |
|
|
73
|
+
| `--fix-threshold <severity>` | 修复到哪个 severity 为止(all = 全部修复)| all |
|
|
74
|
+
| `--skip-fix` | Audit + diagnose only, no code changes | false |
|
|
75
|
+
| `--skip-generalize` | Skip S_GENERALIZE and S_DISCOVER | false |
|
|
76
|
+
| `--auto` | CLI delegates without confirmation | false |
|
|
77
|
+
| `-y` | Auto-confirm all decisions (see appendix) | false |
|
|
78
|
+
| `-c` | Resume most recent session | — |
|
|
79
|
+
|
|
80
|
+
**Dimensions (6):**
|
|
81
|
+
1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
|
|
82
|
+
2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
|
|
83
|
+
3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
|
|
84
|
+
4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
|
|
85
|
+
5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
|
|
86
|
+
6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
|
|
87
|
+
|
|
88
|
+
**Session**: `SESSION_DIR = .workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
|
|
89
|
+
|
|
90
|
+
**Output — 3 files:**
|
|
91
|
+
```
|
|
92
|
+
SESSION_DIR/
|
|
93
|
+
├── session.json # state + audit_result + diagnoses + patterns + phase_goals
|
|
94
|
+
├── evidence.ndjson # append-only (phase: survey|audit|diagnosis|fix|discovery|decision|self-iteration)
|
|
95
|
+
└── understanding.md # 9-section evolving narrative
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**session.json schema:**
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"session_id": "improve-odyssey-{YYYYMMDD-HHmmss}",
|
|
102
|
+
"target": "", "dimensions": [],
|
|
103
|
+
"flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
|
|
104
|
+
"current_state": "S_INTAKE",
|
|
105
|
+
"baseline_metrics": {},
|
|
106
|
+
"audit_result": { "dimensions_audited": [], "finding_count": 0, "severity_distribution": {} },
|
|
107
|
+
"diagnoses": [],
|
|
108
|
+
"patterns": [],
|
|
109
|
+
"confirmation": null,
|
|
110
|
+
"generalization_stats": null,
|
|
111
|
+
"phase_goals": [], "phase_goals_all_done": false,
|
|
112
|
+
"self_iteration_log": [],
|
|
113
|
+
"cross_phase_loops": 0, "max_loops": 3,
|
|
114
|
+
"created_at": "", "updated_at": ""
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**evidence.ndjson unified schema:** `{"ts":"","phase":"<phase>","type":"<type>","dimension":"","title":"","severity":"","file":"","line":0,"description":"","suggestion":"","measurement":""}`
|
|
119
|
+
|
|
120
|
+
Phase-specific fields:
|
|
121
|
+
- `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
|
|
122
|
+
- `audit`: `dimension`, `severity`, `measurement`
|
|
123
|
+
- `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
|
|
124
|
+
- `fix`: `finding_ref`, `change_summary`, `risk`
|
|
125
|
+
- `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
|
|
126
|
+
- `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
|
|
127
|
+
- `self-iteration`: `stage`, `round`, `assessment`, `expansion`
|
|
128
|
+
|
|
129
|
+
**phase_goals[]:**
|
|
130
|
+
| ID | Goal | Phase | skip_when |
|
|
131
|
+
|----|------|-------|-----------|
|
|
132
|
+
| G1 | Survey completed | S_SURVEY | — |
|
|
133
|
+
| G2 | Audit completed | S_AUDIT | — |
|
|
134
|
+
| G3 | Diagnosis completed | S_DIAGNOSE | — |
|
|
135
|
+
| G4 | Zero remaining: all findings fixed and verified | `remaining_actionable == 0` within fix_threshold | S_VERIFY | skip_fix |
|
|
136
|
+
| G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
|
|
137
|
+
| G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
|
|
138
|
+
| G7 | Learnings persisted | S_RECORD | — |
|
|
139
|
+
|
|
140
|
+
Lifecycle: `pending → done | skipped | failed` (all set `completion_confirmed`)
|
|
141
|
+
|
|
142
|
+
**understanding.md — 9 sections (written by owning phase):**
|
|
143
|
+
1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
|
|
144
|
+
4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
|
|
145
|
+
6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER
|
|
146
|
+
8. Improvement Metrics ← S_RECORD (before/after) | 9. Engineering Learnings ← S_RECORD
|
|
147
|
+
|
|
148
|
+
### Pre-load(可选,缺失不阻塞)
|
|
149
|
+
|
|
150
|
+
| 层级 | 命令 | 作用 |
|
|
151
|
+
|------|------|------|
|
|
152
|
+
| Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` | 模块边界,作为分析上下文 |
|
|
153
|
+
| Wiki search | `maestro search "<target keywords>" --json` | 先前优化、相关决策(取 top 5) |
|
|
154
|
+
| Coding specs | `maestro spec load --category coding` | 编码规范 |
|
|
155
|
+
| Debug specs | `maestro spec load --category debug` | 已知性能/安全模式 |
|
|
156
|
+
| Role knowledge | `maestro search --category coding` → 选相关 → `maestro wiki load <id>` | 累积领域知识 |
|
|
157
|
+
| Prior sessions | `Glob(".workflow/scratch/*-improve-odyssey-*")` | 相关会话 |
|
|
158
|
+
|
|
159
|
+
### Knowledge Persistence(S_RECORD 中写入产出文件)
|
|
160
|
+
|
|
161
|
+
S_RECORD 阶段将可沉淀知识 **写入 understanding.md §9 Learnings**,按以下分类结构化:
|
|
162
|
+
|
|
163
|
+
| 分类 | 写入内容 | 后续建议命令 |
|
|
164
|
+
|------|---------|-------------|
|
|
165
|
+
| 性能 pattern | 瓶颈类型 + 修复方案 + 度量方法 | `/spec-add coding "..."` |
|
|
166
|
+
| 安全规则 | 漏洞类别 + 修复 + 预防方法 | `/spec-add debug "..."` |
|
|
167
|
+
| 架构约束 | 违反描述 + 正确边界 + 检查方法 | `/spec-add arch "..."` |
|
|
168
|
+
| 可靠性 pattern | 故障模式 + 处理策略 + 验证手段 | `/spec-add coding "..."` |
|
|
169
|
+
|
|
170
|
+
**两步模式:** 执行中写入产出文件(临时记录)→ 任务完成后用户通过 next_step_routing 沉淀为永久知识。执行过程中不调用外部 Skill。
|
|
171
|
+
</context>
|
|
172
|
+
|
|
173
|
+
<self_iteration>
|
|
174
|
+
**Quality Gate** — auto-evaluate after each analytical phase. Insufficient → re-enter (max 2 rounds).
|
|
175
|
+
|
|
176
|
+
| Dimension | Sufficient | Insufficient |
|
|
177
|
+
|-----------|-----------|-------------|
|
|
178
|
+
| Coverage | All target files/modules analyzed across dimensions | Missed files discoverable via grep/glob |
|
|
179
|
+
| Depth | ≥80% findings have file:line evidence + measurement | Most findings lack specifics |
|
|
180
|
+
| Actionability | Each conclusion has concrete fix or issue action | "Consider reviewing" without action |
|
|
181
|
+
|
|
182
|
+
**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).
|
|
183
|
+
|
|
184
|
+
**Log:** `evidence.ndjson ← {"phase":"self-iteration","type":"quality-gate","stage":"S_XXX","round":N,"assessment":{},"expansion":""}`
|
|
185
|
+
|
|
186
|
+
**Applicable stages:** S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE
|
|
187
|
+
</self_iteration>
|
|
188
|
+
|
|
189
|
+
<state_machine>
|
|
190
|
+
|
|
191
|
+
<states>
|
|
192
|
+
S_INTAKE — Parse target, load context, establish baseline metrics PERSIST: session.json + understanding.md §1
|
|
193
|
+
S_SURVEY — Current state: dependency audit, complexity scan, coverage PERSIST: evidence.ndjson (survey) + understanding.md §2
|
|
194
|
+
S_AUDIT — 6-dimension parallel deep audit PERSIST: evidence.ndjson (audit) + understanding.md §3
|
|
195
|
+
S_DIAGNOSE — Root cause analysis for critical/high findings PERSIST: evidence.ndjson (diagnosis|decision) + understanding.md §4
|
|
196
|
+
S_FIX — Implement improvements (skip if --skip-fix) PERSIST: code changes + evidence.ndjson (fix)
|
|
197
|
+
S_VERIFY — Tests + measurement comparison (skip if --skip-fix) PERSIST: session.json.confirmation + understanding.md §5
|
|
198
|
+
S_GENERALIZE — Pattern extraction + 4-agent scan (skip if --skip-gen) PERSIST: session.json.patterns + understanding.md §6
|
|
199
|
+
S_DISCOVER — Classify hits, create issues (skip if --skip-gen) PERSIST: evidence.ndjson (discovery|decision) + understanding.md §7
|
|
200
|
+
S_RECORD — Persist metrics + learnings + final report PERSIST: understanding.md §8-9 + spec entries
|
|
201
|
+
</states>
|
|
202
|
+
|
|
203
|
+
<transitions>
|
|
204
|
+
S_INTAKE:
|
|
205
|
+
→ S_INTAKE WHEN -c + session found DO A_RESUME
|
|
206
|
+
→ S_SURVEY WHEN target resolved DO A_INTAKE
|
|
207
|
+
→ S_INTAKE WHEN no target DO AskUserQuestion
|
|
208
|
+
|
|
209
|
+
S_SURVEY → S_AUDIT DO A_SURVEY
|
|
210
|
+
|
|
211
|
+
S_AUDIT:
|
|
212
|
+
→ S_DIAGNOSE WHEN critical/high findings exist DO A_AUDIT
|
|
213
|
+
→ S_GENERALIZE WHEN no critical/high AND !skip_gen DO A_AUDIT
|
|
214
|
+
→ S_RECORD WHEN no findings OR skip_gen DO A_AUDIT
|
|
215
|
+
|
|
216
|
+
S_DIAGNOSE:
|
|
217
|
+
→ S_FIX WHEN root causes identified AND !skip_fix DO A_DIAGNOSE
|
|
218
|
+
→ S_GENERALIZE WHEN root causes identified AND skip_fix AND !skip_gen DO A_DIAGNOSE
|
|
219
|
+
→ S_RECORD WHEN root causes identified AND skip_fix AND skip_gen DO A_DIAGNOSE
|
|
220
|
+
→ S_DIAGNOSE WHEN hypotheses failed AND retries < 3 DO A_ESCALATE_DIAGNOSIS
|
|
221
|
+
→ S_RECORD WHEN hypotheses failed AND retries >= 3 DO mark INCONCLUSIVE
|
|
222
|
+
|
|
223
|
+
S_FIX → S_VERIFY DO A_FIX
|
|
224
|
+
|
|
225
|
+
S_VERIFY:
|
|
226
|
+
→ S_GENERALIZE WHEN verified AND !skip_gen DO A_VERIFY
|
|
227
|
+
→ S_RECORD WHEN verified AND skip_gen DO A_VERIFY
|
|
228
|
+
→ S_FIX WHEN needs_rework DO A_VERIFY
|
|
229
|
+
|
|
230
|
+
S_GENERALIZE:
|
|
231
|
+
→ S_DISCOVER WHEN hits found DO A_GENERALIZE
|
|
232
|
+
→ S_RECORD WHEN no hits DO A_GENERALIZE
|
|
233
|
+
|
|
234
|
+
S_DISCOVER → S_DIAGNOSE : new critical issue found, loops < max_loops → cross_phase_loops++
|
|
235
|
+
S_DISCOVER → S_FIX : same-pattern fix, !skip_fix, loops < max_loops → cross_phase_loops++
|
|
236
|
+
S_DISCOVER → S_RECORD : triage complete OR loops >= max_loops (剩余项 → issue/decision)
|
|
237
|
+
|
|
238
|
+
S_RECORD → END DO A_RECORD
|
|
239
|
+
</transitions>
|
|
240
|
+
|
|
241
|
+
<actions>
|
|
242
|
+
|
|
243
|
+
### A_INTAKE
|
|
244
|
+
1. Parse arguments: target description, flags, `--dimensions` subset
|
|
245
|
+
2. Generate slug, create `SESSION_DIR`
|
|
246
|
+
3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
|
|
247
|
+
4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
|
|
248
|
+
5. Derive `phase_goals[]` from flags (apply `skip_when`)
|
|
249
|
+
6. Write `session.json` + `understanding.md` §1 (Target & Baseline)
|
|
250
|
+
7. Emit Goal Prompt (see Appendix)
|
|
251
|
+
|
|
252
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): INTAKE — 目标解析与基线采集"`
|
|
253
|
+
|
|
254
|
+
### A_RESUME
|
|
255
|
+
Find latest session via Glob → read `session.json` → display summary → jump to `current_state`.
|
|
256
|
+
|
|
257
|
+
### A_SURVEY
|
|
258
|
+
Current state survey — understand what exists before proposing changes.
|
|
259
|
+
|
|
260
|
+
1. **Dependency audit**: Read package.json/lock files, scan for outdated/vulnerable deps
|
|
261
|
+
2. **Complexity scan**: Identify high-complexity files (file size, function count, nesting depth)
|
|
262
|
+
3. **Test coverage map**: Which modules have coverage, which don't
|
|
263
|
+
4. **Error handling scan**: Grep for empty catch, unhandled promise, missing error boundaries
|
|
264
|
+
5. **CLI-assisted survey** (optional):
|
|
265
|
+
```bash
|
|
266
|
+
maestro delegate "PURPOSE: Survey codebase health of: {target}
|
|
267
|
+
TASK: Dependency health | Complexity hotspots | Test coverage gaps | Error handling patterns
|
|
268
|
+
MODE: analysis
|
|
269
|
+
CONTEXT: @{target_files}
|
|
270
|
+
EXPECTED: JSON {dependency_health, complexity_hotspots, coverage_gaps, error_patterns}
|
|
271
|
+
CONSTRAINTS: Focus on runtime quality, not style
|
|
272
|
+
" --role analyze --mode analysis
|
|
273
|
+
```
|
|
274
|
+
Run_in_background, STOP, wait for callback.
|
|
275
|
+
|
|
276
|
+
6. Append evidence.ndjson (phase: "survey"). Update `understanding.md` §2. Mark G1 done.
|
|
277
|
+
|
|
278
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): SURVEY — 现状调查"`
|
|
279
|
+
|
|
280
|
+
### A_AUDIT
|
|
281
|
+
Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset):
|
|
282
|
+
|
|
283
|
+
| Agent | Dimension | Focus |
|
|
284
|
+
|-------|-----------|-------|
|
|
285
|
+
| Performance | performance | Hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading |
|
|
286
|
+
| Security | security | OWASP Top 10, injection, auth bypass, data exposure, dependency vulns, secrets |
|
|
287
|
+
| Architecture | architecture | Layer violations, circular deps, coupling, interface contracts, SRP violations |
|
|
288
|
+
| Reliability | reliability | Error handling gaps, retry logic, timeout handling, graceful degradation, cleanup |
|
|
289
|
+
| Observability | observability | Logging coverage, metric gaps, trace propagation, error reporting, health checks |
|
|
290
|
+
| Maintainability | maintainability | Cyclomatic complexity, dead code, test coverage gaps, documentation debt |
|
|
291
|
+
|
|
292
|
+
Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
|
|
293
|
+
|
|
294
|
+
Merge → evidence.ndjson (phase: "audit"). Write `session.json.audit_result`.
|
|
295
|
+
Update `understanding.md` §3 (findings by dimension + severity matrix). Mark G2 done.
|
|
296
|
+
|
|
297
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): AUDIT — 多维审查"`
|
|
298
|
+
|
|
299
|
+
### A_DIAGNOSE
|
|
300
|
+
Root cause analysis for critical/high findings — don't fix symptoms.
|
|
301
|
+
|
|
302
|
+
1. Group findings by dimension, prioritize by severity
|
|
303
|
+
2. For each critical/high finding:
|
|
304
|
+
- Form hypothesis about root cause
|
|
305
|
+
- Test: trace code path, check git history, verify with evidence
|
|
306
|
+
- Record to evidence.ndjson (phase: "diagnosis")
|
|
307
|
+
3. **Decision journal**: ambiguity → evidence (phase: "decision"); Normal: AskUserQuestion | `-y`: defer
|
|
308
|
+
4. **CLI-assisted diagnosis** for complex findings:
|
|
309
|
+
```bash
|
|
310
|
+
maestro delegate "PURPOSE: Diagnose root cause of: {finding}
|
|
311
|
+
TASK: Trace code path | Check for systemic pattern | Identify fix approach
|
|
312
|
+
MODE: analysis
|
|
313
|
+
CONTEXT: @{relevant_files} | Finding: {finding_detail}
|
|
314
|
+
EXPECTED: JSON {root_cause, systemic, fix_approach, risk}
|
|
315
|
+
CONSTRAINTS: Focus on root cause, not symptom
|
|
316
|
+
" --role analyze --mode analysis
|
|
317
|
+
```
|
|
318
|
+
Run_in_background, STOP, wait for callback.
|
|
319
|
+
|
|
320
|
+
5. Write `session.json.diagnoses[]`. Update `understanding.md` §4. Mark G3 done.
|
|
321
|
+
|
|
322
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DIAGNOSE — 根因诊断"`
|
|
323
|
+
|
|
324
|
+
### A_ESCALATE_DIAGNOSIS
|
|
325
|
+
Increment retries. If < 3: broaden scope via `maestro delegate --role analyze`, form new hypotheses, return to S_DIAGNOSE. If >= 3: Normal → AskUserQuestion (broaden/new/INCONCLUSIVE) | `-y` → auto INCONCLUSIVE, proceed to S_RECORD.
|
|
326
|
+
|
|
327
|
+
### A_FIX
|
|
328
|
+
Skip if `--skip-fix`. Implement improvements for diagnosed root causes.
|
|
329
|
+
|
|
330
|
+
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.
|
|
331
|
+
2. For each fix: implement → record evidence.ndjson (phase: "fix")
|
|
332
|
+
3. **Normal**: AskUserQuestion per-fix confirmation. **`-y`**: auto-proceed, record `deferred`.
|
|
333
|
+
|
|
334
|
+
📌 **Auto-commit**: `git add -A && git commit -m "odyssey-improve({slug}): FIX — 改进实现"`
|
|
335
|
+
|
|
336
|
+
### A_VERIFY
|
|
337
|
+
Verify improvements with measurement comparison.
|
|
338
|
+
|
|
339
|
+
1. Run tests covering modified areas
|
|
340
|
+
2. **Measure improvement**: re-capture metrics, compare with `session.json.baseline_metrics`
|
|
341
|
+
3. **CLI-assisted verification**:
|
|
342
|
+
```bash
|
|
343
|
+
maestro delegate "PURPOSE: Verify improvements for: {target}
|
|
344
|
+
TASK: Check fix correctness | Test regressions | Measure impact | Compare with baseline
|
|
345
|
+
MODE: analysis
|
|
346
|
+
CONTEXT: @{modified_files} | Baseline: {baseline_metrics} | Fixes: {fix_summary}
|
|
347
|
+
EXPECTED: JSON {verdict, metrics_improved, regressions, remaining_issues}
|
|
348
|
+
CONSTRAINTS: Focus on correctness and measurable improvement
|
|
349
|
+
" --role review --mode analysis
|
|
350
|
+
```
|
|
351
|
+
Run_in_background, STOP, wait for callback.
|
|
352
|
+
|
|
353
|
+
4. `needs_rework` → S_FIX. `verified` → mark G4 done, advance.
|
|
354
|
+
5. Write `session.json.confirmation`. Update `understanding.md` §5 (before/after metrics table).
|
|
355
|
+
|
|
356
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): VERIFY — 改进验证"`
|
|
357
|
+
|
|
358
|
+
### A_GENERALIZE
|
|
359
|
+
Multi-layer pattern extraction from diagnoses + fixes → 4-agent scan → cross-layer dedup.
|
|
360
|
+
|
|
361
|
+
**Pattern extraction** from root causes + improvements:
|
|
362
|
+
|
|
363
|
+
| Layer | Method | Example |
|
|
364
|
+
|-------|--------|---------|
|
|
365
|
+
| Syntax | Regex → direct Grep | Missing `await`, unclosed resource, empty catch, `eval(` |
|
|
366
|
+
| Semantic | Agent understands anti-pattern → scans | Unhandled async errors, missing retry, N+1 query |
|
|
367
|
+
| Structural | File/module structure similarity | Same import pattern, missing error boundary |
|
|
368
|
+
| Historical | `git log -S "{pattern}"` | When similar issues were introduced/fixed |
|
|
369
|
+
|
|
370
|
+
Write `session.json.patterns[]`: `[{id, source_finding, layer, signature, description, risk, fix_template, confidence}]`
|
|
371
|
+
|
|
372
|
+
**4-agent parallel scan** (single message):
|
|
373
|
+
|
|
374
|
+
| Agent | Strategy | Scope |
|
|
375
|
+
|-------|----------|-------|
|
|
376
|
+
| Syntax grep | Grep patterns matching found issues | Full project |
|
|
377
|
+
| Semantic scan | Find modules with same anti-pattern | Related modules |
|
|
378
|
+
| Structural match | Find structurally similar files | Full project |
|
|
379
|
+
| Historical grep | `git log -S "{pattern}"` | Git history |
|
|
380
|
+
|
|
381
|
+
**Cross-layer dedup**: Multi-layer hit → boost confidence. Single-layer → `needs_review`. Historical match on fixed code → `regression_risk`.
|
|
382
|
+
|
|
383
|
+
**Iterative deepening**: Module with ≥3 hits → targeted deep scan (max 1 round).
|
|
384
|
+
|
|
385
|
+
Update `understanding.md` §6. Write `session.json.generalization_stats`. Mark G5 done.
|
|
386
|
+
|
|
387
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): GENERALIZE — 泛化扫描"`
|
|
388
|
+
|
|
389
|
+
### A_DISCOVER
|
|
390
|
+
1. **Triage** each hit: read ±10 lines context → classify `safe`/`risk`/`issue`
|
|
391
|
+
2. **Route**: **Normal** → AskUserQuestion. **`-y`** → auto create issue, `deferred`.
|
|
392
|
+
3. **Cross-phase loops**: new critical issue → S_DIAGNOSE; same-pattern fix → S_FIX; budget exhausted → S_RECORD.
|
|
393
|
+
4. Append evidence (phase: "discovery" + "decision"). Update `understanding.md` §7. Mark G6 done.
|
|
394
|
+
|
|
395
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): DISCOVER — 发现分类"`
|
|
396
|
+
|
|
397
|
+
### A_RECORD
|
|
398
|
+
1. **understanding.md §8**: Improvement metrics — before/after comparison table from baseline_metrics vs current
|
|
399
|
+
2. **understanding.md §9**: Engineering learnings — 按 Knowledge Persistence 表分类记录(临时),completion summary 列出建议的 `/spec-add` 命令
|
|
400
|
+
3. Mark G7 done. Pending decisions: **Normal** → AskUserQuestion. **`-y`** → skip, show deferred count.
|
|
401
|
+
4. **Goal audit**: all `phase_goals[*].completion_confirmed` true → `phase_goals_all_done = true`. Any false: **Normal** → AskUserQuestion (回退/跳过/接受) | **`-y`** → auto accept.
|
|
402
|
+
5. `current_state = "COMPLETED"`. Emit completion summary:
|
|
403
|
+
```
|
|
404
|
+
--- IMPROVE ODYSSEY COMPLETE ---
|
|
405
|
+
Target: {target}
|
|
406
|
+
Dimensions: {dimensions_audited}
|
|
407
|
+
Findings: {C}C {H}H {M}M {L}L
|
|
408
|
+
Diagnosed: {diagnosed_count} root causes identified
|
|
409
|
+
Fix: {fixed_count} improvements, verified={yes|skipped}
|
|
410
|
+
Metrics: {improved} improved, {regressed} regressed
|
|
411
|
+
Patterns: {extracted} ({by_layer} distribution)
|
|
412
|
+
Scan hits: {total} ({cross_layer} cross-layer confirmed)
|
|
413
|
+
Issues: {N} created
|
|
414
|
+
Decisions: {N} resolved, {M} pending, {K} deferred
|
|
415
|
+
Learnings: {N} entries in understanding.md §9
|
|
416
|
+
Self-iter: {N} quality gate rounds across {M} stages
|
|
417
|
+
Cross-loops: {cross_phase_loops}/{max_loops} used
|
|
418
|
+
Goals: {done}/{total} ({skipped} skipped)
|
|
419
|
+
---
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
📌 **Auto-commit**: `git add understanding.md && git commit -m "odyssey-improve({slug}): RECORD — 指标总结与知识沉淀"`
|
|
423
|
+
|
|
424
|
+
</actions>
|
|
425
|
+
|
|
426
|
+
<appendix>
|
|
427
|
+
|
|
428
|
+
### Goal Prompt Template
|
|
429
|
+
**⚠️ 时机守卫:仅在 A_INTAKE 完成后显示一次。A_RECORD 完成时禁止重新显示。**
|
|
430
|
+
|
|
431
|
+
```
|
|
432
|
+
📋 Improve Odyssey 会话已创建。可随时复制以下 /goal 设定终止条件:
|
|
433
|
+
|
|
434
|
+
/goal 穷尽迭代:直到 session.json 的 audit_result 中所有 findings 均已处理(fix/issue/decision)
|
|
435
|
+
且 phase_goals_all_done=true 才停。修复按 severity 逐轮迭代,每轮修复后 re-verify 修改区域。
|
|
436
|
+
Baseline metrics 必须在修复前采集,修复后必须与 baseline 对比确认改进。
|
|
437
|
+
遇到 phase=decision 的 pending 必须 AskUserQuestion。不允许"只报告不处理"。
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
完成时仅输出 completion summary,不重复此提示。
|
|
441
|
+
|
|
442
|
+
### `-y` Auto-Confirm Behavior
|
|
443
|
+
| Decision Point | Normal | `-y` |
|
|
444
|
+
|---------------|--------|------|
|
|
445
|
+
| A_FIX improvement confirmation | AskUserQuestion | auto-proceed, `deferred` |
|
|
446
|
+
| A_DIAGNOSE ambiguity | AskUserQuestion | best-effort, `deferred` |
|
|
447
|
+
| A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
|
|
448
|
+
| A_DISCOVER hit routing | AskUserQuestion | auto create issue, `deferred` |
|
|
449
|
+
| A_DISCOVER ambiguous items | AskUserQuestion | all `deferred` |
|
|
450
|
+
| A_RECORD pending decisions | AskUserQuestion | skip, show deferred count |
|
|
451
|
+
| A_RECORD goal audit | AskUserQuestion | auto accept |
|
|
452
|
+
|
|
453
|
+
`deferred` items shown as "待决策" in completion summary; recoverable via `-c`.
|
|
454
|
+
|
|
455
|
+
### Phase Goal Lifecycle
|
|
456
|
+
`pending → done (confirmed=true)` normal | `pending → skipped (confirmed=true)` flags/manual | `pending → failed (confirmed=false)` exception
|
|
457
|
+
|
|
458
|
+
`phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
|
|
459
|
+
|
|
460
|
+
</appendix>
|
|
461
|
+
|
|
462
|
+
</state_machine>
|
|
463
|
+
|
|
464
|
+
<error_codes>
|
|
465
|
+
| Code | Severity | Condition | Recovery |
|
|
466
|
+
|------|----------|-----------|----------|
|
|
467
|
+
| E001 | error | No target specified | Provide target or use -c |
|
|
468
|
+
| E002 | error | Target path not found | Check path |
|
|
469
|
+
| E003 | error | Resume but no session found | Start new session |
|
|
470
|
+
| W001 | warning | No dependency manifest found | Proceed without dep audit |
|
|
471
|
+
| W002 | warning | Some dimension agents failed | Partial audit coverage |
|
|
472
|
+
| W003 | warning | Generalization 0 hits | Skip discovery |
|
|
473
|
+
| W004 | warning | Delegate parse failed | Use raw output |
|
|
474
|
+
</error_codes>
|
|
475
|
+
|
|
476
|
+
<success_criteria>
|
|
477
|
+
- [ ] Target resolved, baseline metrics captured in session.json
|
|
478
|
+
- [ ] Dependency + complexity + coverage survey completed
|
|
479
|
+
- [ ] All dimensions audited (6 parallel agents) with structured findings
|
|
480
|
+
- [ ] Severity matrix produced
|
|
481
|
+
- [ ] Root causes diagnosed for critical/high findings (hypothesis-driven)
|
|
482
|
+
- [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
|
|
483
|
+
- [ ] Multi-layer generalization scan + cross-layer dedup (unless --skip-generalize)
|
|
484
|
+
- [ ] Cross-phase loops used when discoveries warrant
|
|
485
|
+
- [ ] Quality Gate self-iteration triggered when insufficient
|
|
486
|
+
- [ ] Discoveries classified and routed
|
|
487
|
+
- [ ] understanding.md §8: improvement metrics (before/after comparison)
|
|
488
|
+
- [ ] understanding.md §9: engineering learnings
|
|
489
|
+
- [ ] phase_goals G1-G7 tracked and audited
|
|
490
|
+
- [ ] Goal Prompt displayed once
|
|
491
|
+
- [ ] `-y`: no blocking prompts, deferred counted
|
|
492
|
+
- [ ] Session resumable via -c
|
|
493
|
+
</success_criteria>
|
|
494
|
+
|
|
495
|
+
<next_step_routing>
|
|
496
|
+
| Condition | Next step |
|
|
497
|
+
|-----------|-----------|
|
|
498
|
+
| Security findings need deep investigation | `/odyssey-debug "<finding>"` |
|
|
499
|
+
| UI-related findings | `/odyssey-ui "<component>"` |
|
|
500
|
+
| Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
|
|
501
|
+
| Architecture pattern to document | `/spec-add arch "..."` |
|
|
502
|
+
| Performance pattern to persist | `/spec-add coding "..."` |
|
|
503
|
+
| Want formal review of changes | `/odyssey-review-test-fix <changed-files>` |
|
|
504
|
+
| Decisions still pending | Filter evidence.ndjson phase=decision status=pending |
|
|
505
|
+
</next_step_routing>
|