maestro-flow 0.5.44 → 0.5.46

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 (126) hide show
  1. package/.agents/agents/ralph-executor.md +93 -0
  2. package/.agents/skills/maestro-ralph-cli/SKILL.md +21 -16
  3. package/.agents/skills/maestro-ralph-v2/SKILL.md +923 -0
  4. package/.agents/skills/odyssey-debug/SKILL.md +338 -253
  5. package/.agents/skills/odyssey-improve/SKILL.md +367 -281
  6. package/.agents/skills/odyssey-planex/SKILL.md +490 -420
  7. package/.agents/skills/odyssey-review-test-fix/SKILL.md +336 -251
  8. package/.agents/skills/odyssey-ui/SKILL.md +332 -247
  9. package/.agy/agents/ralph-executor.md +91 -0
  10. package/.agy/skills/maestro-ralph-cli/SKILL.md +21 -16
  11. package/.agy/skills/maestro-ralph-v2/SKILL.md +935 -0
  12. package/.agy/skills/odyssey-debug/SKILL.md +338 -253
  13. package/.agy/skills/odyssey-improve/SKILL.md +367 -281
  14. package/.agy/skills/odyssey-planex/SKILL.md +490 -420
  15. package/.agy/skills/odyssey-review-test-fix/SKILL.md +336 -251
  16. package/.agy/skills/odyssey-ui/SKILL.md +332 -247
  17. package/.claude/agents/ralph-executor.md +91 -0
  18. package/.claude/commands/maestro-ralph-cli.md +21 -16
  19. package/.claude/commands/maestro-ralph-v2.md +921 -0
  20. package/.claude/commands/odyssey-debug.md +352 -267
  21. package/.claude/commands/odyssey-improve.md +381 -295
  22. package/.claude/commands/odyssey-planex.md +504 -434
  23. package/.claude/commands/odyssey-review-test-fix.md +350 -265
  24. package/.claude/commands/odyssey-ui.md +346 -261
  25. package/.codex/skills/maestro-next/SKILL.md +1 -1
  26. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +3 -3
  27. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  28. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
  29. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  30. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +6 -0
  31. package/dashboard/dist-server/src/graph/kg/db/queries.js +141 -19
  32. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  33. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  34. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  35. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  36. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  37. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  38. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  39. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  40. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  41. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -2
  42. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  43. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
  44. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
  45. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
  46. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
  47. package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
  48. package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
  49. package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
  50. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
  51. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
  52. package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
  53. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
  54. package/dist/src/agents/api-explore/agent-loop.js +6 -5
  55. package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
  56. package/dist/src/agents/api-explore/config.d.ts +56 -0
  57. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  58. package/dist/src/agents/api-explore/config.js +34 -0
  59. package/dist/src/agents/api-explore/config.js.map +1 -1
  60. package/dist/src/agents/api-explore/llm.d.ts +5 -1
  61. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  62. package/dist/src/agents/api-explore/llm.js +10 -8
  63. package/dist/src/agents/api-explore/llm.js.map +1 -1
  64. package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
  65. package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
  66. package/dist/src/agents/api-explore/moa-cache.js +50 -0
  67. package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
  68. package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
  69. package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
  70. package/dist/src/agents/api-explore/moa-loop.js +43 -0
  71. package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
  72. package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
  73. package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
  74. package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
  75. package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
  76. package/dist/src/agents/api-explore/runner.d.ts +3 -0
  77. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  78. package/dist/src/agents/api-explore/runner.js +24 -7
  79. package/dist/src/agents/api-explore/runner.js.map +1 -1
  80. package/dist/src/agents/api-explore/session.d.ts +15 -0
  81. package/dist/src/agents/api-explore/session.d.ts.map +1 -1
  82. package/dist/src/agents/api-explore/session.js.map +1 -1
  83. package/dist/src/cli.js +1 -0
  84. package/dist/src/cli.js.map +1 -1
  85. package/dist/src/commands/explore.d.ts.map +1 -1
  86. package/dist/src/commands/explore.js +16 -1
  87. package/dist/src/commands/explore.js.map +1 -1
  88. package/dist/src/commands/moa.d.ts +3 -0
  89. package/dist/src/commands/moa.d.ts.map +1 -0
  90. package/dist/src/commands/moa.js +202 -0
  91. package/dist/src/commands/moa.js.map +1 -0
  92. package/dist/src/graph/kg/db/queries.d.ts +6 -0
  93. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  94. package/dist/src/graph/kg/db/queries.js +141 -19
  95. package/dist/src/graph/kg/db/queries.js.map +1 -1
  96. package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  97. package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  98. package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  99. package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  100. package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  101. package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  102. package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  103. package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  104. package/dist/src/graph/kg/extraction/orchestrator.js +2 -2
  105. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  106. package/dist/src/graph/kg/surface/hook-injector.js +1 -1
  107. package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
  108. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  109. package/dist/src/hooks/keyword-spec-injector.js +35 -0
  110. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  111. package/dist/src/hooks/spec-analytics.d.ts +1 -0
  112. package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
  113. package/dist/src/hooks/spec-analytics.js.map +1 -1
  114. package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
  115. package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
  116. package/dist/src/hooks/wiki-search-bridge.js +71 -0
  117. package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
  118. package/dist/src/utils/update-notices.js +12 -0
  119. package/dist/src/utils/update-notices.js.map +1 -1
  120. package/package.json +1 -1
  121. package/.agents/skills/maestro-ralph-agent/SKILL.md +0 -697
  122. package/.agents/skills/maestro-ralph-agent-execute/SKILL.md +0 -461
  123. package/.agy/skills/maestro-ralph-agent/SKILL.md +0 -696
  124. package/.agy/skills/maestro-ralph-agent-execute/SKILL.md +0 -457
  125. package/.claude/commands/maestro-ralph-agent-execute.md +0 -459
  126. package/.claude/commands/maestro-ralph-agent.md +0 -695
@@ -1,295 +1,381 @@
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>] [--fix-threshold <severity>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c] [--heartbeat]"
5
- allowed-tools:
6
- - Read
7
- - Write
8
- - Edit
9
- - Bash
10
- - Glob
11
- - Grep
12
- - Agent
13
- - AskUserQuestion
14
- ---
15
- <base>@~/.maestro/workflows/odyssey-base.md</base>
16
-
17
- <purpose>
18
- survey → 6-dimension audit → diagnose → fix → verify → generalize → discover → persist.
19
- Exhaustive iteration until zero remaining actionable findings.
20
- </purpose>
21
-
22
- <boundary>
23
- **In scope:** Runtime quality improvement — performance/security/architecture/reliability/observability/maintainability audit → diagnose → fix → generalize.
24
- **Out of scope:** UI visual → `/odyssey-ui` | New features → `/odyssey-planex` | Single bug → `/odyssey-debug` | Style review → `/odyssey-review-test-fix`
25
- **Exploration freedom:** Free exploration within boundary — profiling, security scanning, architecture analysis, dependency audit.
26
- **Zero-residual:** 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.
27
- </boundary>
28
-
29
- <context>
30
- $ARGUMENTS
31
-
32
- **Target resolution:**
33
- | Input | Resolution |
34
- |-------|-----------|
35
- | Module/dir path | Audit that module |
36
- | `HEAD` / `staged` | Review changes in diff |
37
- | Feature area keyword | Resolve to related files |
38
- | `--all` | Full project scan (use with caution) |
39
-
40
- **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` fix cutoff (default: all) | `--skip-fix` audit+diagnose only | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
41
-
42
- **Dimensions (6):**
43
- 1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
44
- 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
45
- 3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
46
- 4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
47
- 5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
48
- 6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
49
-
50
- **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
51
- **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
52
-
53
- **session.json — improve-specific fields:**
54
- ```json
55
- { "target": "", "dimensions": [], "baseline_metrics": {},
56
- "audit_result": {}, "diagnoses": [], "confirmation": null,
57
- "generalization_stats": null }
58
- ```
59
-
60
- **evidence.ndjson phases:** `survey|audit|diagnosis|fix|discovery|decision|self-iteration`
61
- - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
62
- - `audit`: `dimension`, `severity`, `measurement`
63
- - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
64
- - `fix`: `finding_ref`, `change_summary`, `risk`
65
- - `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
66
- - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
67
- - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
68
-
69
- **phase_goals[]:**
70
-
71
- | ID | Goal | Phase | skip_when |
72
- |----|------|-------|-----------|
73
- | G1 | Survey completed | S_SURVEY | — |
74
- | G2 | Audit completed | S_AUDIT | — |
75
- | G3 | Diagnosis completed | S_DIAGNOSE | — |
76
- | G4 | Zero remaining: all findings fixed and verified | S_VERIFY | skip_fix |
77
- | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
78
- | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
79
- | G7 | Learnings persisted | S_RECORD | — |
80
-
81
- **understanding.md — 9 sections:**
82
- 1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
83
- 4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
84
- 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER
85
- 8. Improvement Metrics ← S_RECORD (before/after) | 9. Engineering Learnings ← S_RECORD
86
-
87
- **Knowledge Persistence categories (§9):**
88
-
89
- | Category | Content | Follow-up |
90
- |----------|---------|-----------|
91
- | Performance pattern | Bottleneck type + fix approach + measurement method | `/spec-add coding` |
92
- | Security rule | Vulnerability class + fix + prevention method | `/spec-add debug` |
93
- | Architecture constraint | Violation description + correct boundary + check method | `/spec-add arch` |
94
- | Reliability pattern | Failure mode + handling strategy + verification method | `/spec-add coding` |
95
- </context>
96
-
97
- <invariants>
98
- All invariants (evidence append-only, session-as-state, phase goal tracking, auto-commit, zero-residual) defined in base.
99
- </invariants>
100
-
101
- <self_iteration>
102
- Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
103
- </self_iteration>
104
-
105
- <state_machine>
106
-
107
- <states>
108
- S_INTAKE → S_SURVEY → S_AUDIT → S_DIAGNOSE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
109
- </states>
110
-
111
- <transitions>
112
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME
113
- S_INTAKE → S_SURVEY : target resolvedA_INTAKE
114
- S_INTAKE → S_INTAKE : no target → AskUserQuestion
115
-
116
- S_SURVEY → S_AUDIT : complete
117
-
118
- S_AUDIT → S_DIAGNOSE : critical/high findings exist
119
- S_AUDIT → S_GENERALIZE : no critical/high, !skip_generalize
120
- S_AUDIT → S_RECORD : no findings OR skip_generalize
121
-
122
- S_DIAGNOSE → S_FIX : root causes identified, !skip_fix
123
- S_DIAGNOSE → S_GENERALIZE : root causes identified, skip_fix, !skip_generalize
124
- S_DIAGNOSE → S_RECORD : root causes identified, skip_fix, skip_generalize
125
- S_DIAGNOSE → S_DIAGNOSE : hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
126
- S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
127
-
128
- S_FIX → S_VERIFY : fix implemented
129
-
130
- S_VERIFY → S_GENERALIZE : verified, !skip_generalize
131
- S_VERIFY → S_RECORD : verified, skip_generalize
132
- S_VERIFY → S_FIX : needs_rework
133
-
134
- S_GENERALIZE → S_DISCOVER : hits found
135
- S_GENERALIZE → S_RECORD : no hits
136
-
137
- S_DISCOVER → S_DIAGNOSE : new critical issue → cross_phase_loops++
138
- S_DISCOVER → S_FIX : same-pattern fix, !skip_fix → cross_phase_loops++
139
- S_DISCOVER → S_RECORD : remaining_actionable == 0
140
- S_DISCOVER → S_RECORD : loops >= max_loops → MUST log per-item reasons
141
-
142
- S_RECORD → END : complete
143
- </transitions>
144
-
145
- <actions>
146
-
147
- ### A_INTAKE
148
- 1. Parse arguments: target description, flags, `--dimensions` subset
149
- 2. Generate slug, create `SESSION_DIR`
150
- 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
151
- 4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
152
- 5. Derive `phase_goals[]` from flags
153
- 6. Write `session.json` + `understanding.md` §1, emit Goal Prompt
154
-
155
- Commit: `"odyssey-improve({slug}): INTAKE — parse target and capture baseline"`
156
-
157
- ### A_RESUME
158
- Glob latest session → read `session.json` → display summary → jump to `current_state`.
159
-
160
- ### A_SURVEY
161
- Current state survey — understand what exists before proposing changes.
162
-
163
- 1. Dependency audit (package.json/lock), complexity scan (size/nesting), test coverage map, error handling scan (empty catch, unhandled promise)
164
- 2. **CLI-assisted** (optional): `maestro delegate --role analyze --mode analysis` for dependency health, complexity hotspots, coverage gaps, error patterns. Execute `run_in_background: true`.
165
- 3. Evidence phase=survey. Update §2. Mark G1.
166
-
167
- Commit: `"odyssey-improve({slug}): SURVEY — current state analysis"`
168
-
169
- ### A_AUDIT
170
- Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset).
171
- Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
172
-
173
- Merge → evidence phase=audit. Write `session.json.audit_result`.
174
- Update §3 (findings by dimension + severity matrix). Mark G2.
175
-
176
- Commit: `"odyssey-improve({slug}): AUDIT — multi-dimension review"`
177
-
178
- ### A_DIAGNOSE
179
- Root cause analysis for critical/high findings — don't fix symptoms.
180
-
181
- 1. Group by dimension, prioritize by severity. For each: hypothesis → trace code path + git history → evidence phase=diagnosis
182
- 2. Ambiguity evidence phase=decision; Normal: AskUserQuestion | `-y`: defer
183
- 3. CLI-assisted for complex findings: `maestro delegate --role analyze --mode analysis` (`run_in_background: true`)
184
- 4. Write `session.json.diagnoses[]`. Update §4. Mark G3.
185
-
186
- Commit: `"odyssey-improve({slug}): DIAGNOSE — root cause analysis"`
187
-
188
- ### A_ESCALATE_DIAGNOSIS
189
- `retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, → S_DIAGNOSE. >= 3: Normal → AskUserQuestion | `-y` → INCONCLUSIVE → S_RECORD.
190
-
191
- ### A_FIX
192
- 1. Exhaustive fix: ALL diagnosed issues by severity tier (critical → high → medium → low within fix_threshold), one dimension at a time. After each tier, re-verify **current tier's dimension only** (not all dimensions) — new findings at same or higher severity append to current tier. Cross-dimension regression checks run once at S_VERIFY after all tiers complete.
193
- 2. For each fix: implementevidence phase=fix
194
- 3. Normal: AskUserQuestion per-fix confirmation | `-y`: auto-proceed, record `deferred`
195
-
196
- Commit: `"odyssey-improve({slug}): FIX — improvements applied"`
197
-
198
- ### A_VERIFY
199
- 1. Run tests covering modified areas
200
- 2. Re-capture metrics, compare with `session.json.baseline_metrics`
201
- 3. CLI-assisted: `maestro delegate --role review --mode analysis` (`run_in_background: true`)
202
- 4. `needs_rework` S_FIX. `verified` mark G4, advance.
203
- 5. Write `session.json.confirmation`. Update §5 (before/after metrics table).
204
-
205
- Commit: `"odyssey-improve({slug}): VERIFY — improvements verified"`
206
-
207
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
208
- Base shared_actions. Improve overrides:
209
- - **A_GENERALIZE** pattern source: diagnoses + fixes
210
- - **A_RECORD** §8: improvement metrics (before/after comparison from baseline_metrics vs current). §9: learnings per Knowledge Persistence table. Completion summary lists suggested `/spec-add` commands.
211
-
212
- **Completion summary:**
213
- ```
214
- --- IMPROVE ODYSSEY COMPLETE ---
215
- Target: {target}
216
- Dimensions: {dimensions}
217
- Findings: {critical}C / {high}H / {medium}M / {low}L
218
- Diagnosed: {count}
219
- Fixed: {count} ({verified} verified)
220
- Metrics: {improved} improved / {regressed} regressed
221
- Patterns: {count} ({by_layer})
222
- Scan hits: {total} ({cross_layer_confirmed} confirmed)
223
- Issues: {N} created
224
- Decisions: {N} resolved, {M} pending, {K} deferred
225
- Learnings: {N} persisted
226
- Self-iter: {N} rounds across {M} stages
227
- Cross-loops: {N}
228
- Goals: {done}/{total} ({skipped} skipped)
229
- ---
230
- ```
231
-
232
- </actions>
233
-
234
- <appendix>
235
-
236
- ### `-y` improve-specific points
237
-
238
- | Decision Point | Normal | `-y` |
239
- |---------------|--------|------|
240
- | A_FIX improvement confirmation | AskUserQuestion | auto-proceed, `deferred` |
241
- | A_DIAGNOSE ambiguity | AskUserQuestion | best-effort, `deferred` |
242
- | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
243
- | A_DISCOVER hit routing | AskUserQuestion | auto create issue |
244
- | A_DISCOVER ambiguous items | AskUserQuestion | all `deferred` |
245
-
246
- `deferred` items shown in completion summary; recoverable via `-c`.
247
-
248
- ### Goal Prompt convergence rules
249
-
250
- ```
251
- Exhaust iteration until all findings actioned (fix/issue/decision)
252
- and phase_goals_all_done=true.
253
- Fix by severity tiers, re-verify after each tier.
254
- Baseline captured before fix, compared after to confirm improvement.
255
- Pending decisions must AskUserQuestionno silent resolve.
256
- ```
257
-
258
- </appendix>
259
-
260
- </state_machine>
261
-
262
- <error_codes>
263
- | Code | Severity | Condition | Recovery |
264
- |------|----------|-----------|----------|
265
- | E001 | error | No target specified | Provide target or use -c |
266
- | E002 | error | Target path not found | Check path |
267
- | W001 | warning | No dependency manifest found | Proceed without dep audit |
268
- | W002 | warning | Some dimension agents failed | Partial audit coverage |
269
- </error_codes>
270
-
271
- <success_criteria>
272
- - [ ] Target resolved, baseline metrics captured
273
- - [ ] Survey + 6-dimension audit with structured findings and severity matrix
274
- - [ ] Root causes diagnosed for critical/high findings
275
- - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
276
- - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
277
- - [ ] Every unfixed finding has individual classification and reason
278
- - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
279
- - [ ] phase_goals G1-G7 tracked and audited
280
- - [ ] Session resumable via -c
281
- - [ ] Completion summary
282
- </success_criteria>
283
-
284
- <next_step_routing>
285
- | Condition | Next |
286
- |-----------|------|
287
- | Security findings need deep investigation | `/odyssey-debug "<finding>"` |
288
- | UI-related findings | `/odyssey-ui "<component>"` |
289
- | Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
290
- | Architecture pattern to document | `/spec-add arch "..."` |
291
- | Performance pattern to persist | `/spec-add coding "..."` |
292
- | Formal review of changes | `/odyssey-review-test-fix <changed-files>` |
293
- | Pending decisions | Filter evidence phase=decision status=pending |
294
- </next_step_routing>
295
- </output>
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>] [--fix-threshold <severity>] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c] [--heartbeat]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Agent
13
+ - AskUserQuestion
14
+ ---
15
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
16
+
17
+ <purpose>
18
+ survey → 6-dimension audit → diagnose → fix → verify → generalize → discover → persist.
19
+ Exhaustive iteration until zero remaining actionable findings.
20
+ </purpose>
21
+
22
+ <boundary>
23
+ **In scope:** Runtime quality improvement — performance/security/architecture/reliability/observability/maintainability audit → diagnose → fix → generalize.
24
+ **Out of scope:** UI visual → `/odyssey-ui` | New features → `/odyssey-planex` | Single bug → `/odyssey-debug` | Style review → `/odyssey-review-test-fix`
25
+ **Exploration freedom:** Free exploration within boundary — profiling, security scanning, architecture analysis, dependency audit.
26
+ **Zero-residual:** 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.
27
+ </boundary>
28
+
29
+ <context>
30
+ $ARGUMENTS
31
+
32
+ **Target resolution:**
33
+ | Input | Resolution |
34
+ |-------|-----------|
35
+ | Module/dir path | Audit that module |
36
+ | `HEAD` / `staged` | Review changes in diff |
37
+ | Feature area keyword | Resolve to related files |
38
+ | `--all` | Full project scan (use with caution) |
39
+
40
+ **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` fix cutoff (default: all) | `--skip-fix` audit+diagnose only | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
41
+
42
+ **Dimensions (6):**
43
+ 1. **performance** — hot paths, N+1 queries, memory allocation, cache efficiency, bundle size, lazy loading
44
+ 2. **security** — OWASP Top 10, injection, auth bypass, data exposure, dependency vulnerabilities, secrets
45
+ 3. **architecture** — layer violations, circular dependencies, coupling metrics, interface contracts, SRP violations
46
+ 4. **reliability** — error handling gaps, retry logic, timeout handling, graceful degradation, resource cleanup
47
+ 5. **observability** — logging coverage, metric gaps, trace propagation, error reporting, health checks
48
+ 6. **maintainability** — code complexity (cyclomatic), dead code, test coverage gaps, documentation debt
49
+
50
+ **Session**: `.workflow/scratch/{YYYYMMDD}-improve-odyssey-{slug}/`
51
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
52
+
53
+ **session.json — improve-specific fields:**
54
+ ```json
55
+ { "target": "", "dimensions": [], "baseline_metrics": {},
56
+ "audit_result": {}, "diagnoses": [], "confirmation": null,
57
+ "generalization_stats": null }
58
+ ```
59
+
60
+ **evidence.ndjson phases:** `survey|audit|diagnosis|fix|discovery|decision|self-iteration`
61
+ - `survey`: `category` (dependency|complexity|coverage|error_pattern), `detail`
62
+ - `audit`: `dimension`, `severity`, `measurement`
63
+ - `diagnosis`: `finding_ref`, `hypothesis`, `result` (confirmed|disproved|inconclusive), `root_cause`
64
+ - `fix`: `finding_ref`, `change_summary`, `risk`
65
+ - `discovery`: `file`, `line`, `classification` (safe|risk|issue), `action` (fix|issue|decision|skip)
66
+ - `decision`: `question`, `options`, `context`, `status` (pending|resolved|deferred), `resolution`
67
+ - `self-iteration`: `stage`, `round`, `assessment`, `expansion`
68
+
69
+ **phase_goals[]:**
70
+
71
+ | ID | Goal | Phase | skip_when |
72
+ |----|------|-------|-----------|
73
+ | G1 | Survey completed | S_SURVEY | — |
74
+ | G2 | Audit completed | S_AUDIT | — |
75
+ | G3 | Diagnosis completed | S_DIAGNOSE | — |
76
+ | G4 | Zero remaining: all findings fixed and verified | S_VERIFY | skip_fix |
77
+ | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
78
+ | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
79
+ | G7 | Learnings persisted | S_RECORD | — |
80
+
81
+ **understanding.md — 9 sections:**
82
+ 1. Target & Baseline ← S_INTAKE | 2. Current State Survey ← S_SURVEY | 3. Audit Findings ← S_AUDIT
83
+ 4. Root Cause Diagnosis ← S_DIAGNOSE | 5. Fix & Verification ← S_FIX+S_VERIFY
84
+ 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER
85
+ 8. Improvement Metrics ← S_RECORD (before/after) | 9. Engineering Learnings ← S_RECORD
86
+
87
+ **Knowledge Persistence categories (§9):**
88
+
89
+ | Category | Content | Follow-up |
90
+ |----------|---------|-----------|
91
+ | Performance pattern | Bottleneck type + fix approach + measurement method | `/spec-add coding` |
92
+ | Security rule | Vulnerability class + fix + prevention method | `/spec-add debug` |
93
+ | Architecture constraint | Violation description + correct boundary + check method | `/spec-add arch` |
94
+ | Reliability pattern | Failure mode + handling strategy + verification method | `/spec-add coding` |
95
+ </context>
96
+
97
+ <invariants>
98
+ All invariants (evidence append-only, session-as-state, phase goal tracking, auto-commit, zero-residual) defined in base.
99
+ 6. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "All verified" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
100
+ </invariants>
101
+
102
+ <self_iteration>
103
+ Applies to: **S_SURVEY, S_AUDIT, S_DIAGNOSE, S_GENERALIZE**. Logic in base.
104
+ </self_iteration>
105
+
106
+ <state_machine>
107
+
108
+ <states>
109
+ S_INTAKE → S_SURVEY → S_AUDIT → S_DIAGNOSE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
110
+ </states>
111
+
112
+ <transitions>
113
+ S_INTAKE → S_INTAKE : -c + session found A_RESUME
114
+ S_INTAKE → S_SURVEY : target resolved A_INTAKE
115
+ S_INTAKE → S_INTAKE : no target → AskUserQuestion
116
+
117
+ S_SURVEY → S_AUDIT : complete
118
+
119
+ S_AUDIT → S_DIAGNOSE : critical/high findings exist
120
+ S_AUDIT → S_GENERALIZE : no critical/high, !skip_generalize
121
+ S_AUDIT → S_RECORD : no findings OR skip_generalize
122
+
123
+ S_DIAGNOSE → S_FIX : root causes identified, !skip_fix
124
+ S_DIAGNOSE → S_GENERALIZE : root causes identified, skip_fix, !skip_generalize
125
+ S_DIAGNOSE → S_RECORD : root causes identified, skip_fix, skip_generalize
126
+ S_DIAGNOSE → S_DIAGNOSE : hypotheses failed, retries < 3 → A_ESCALATE_DIAGNOSIS
127
+ S_DIAGNOSE → S_RECORD : retries >= 3 → INCONCLUSIVE
128
+
129
+ S_FIX → S_VERIFY : fix implemented
130
+
131
+ S_VERIFY → S_GENERALIZE : verified, !skip_generalize
132
+ S_VERIFY → S_RECORD : verified, skip_generalize
133
+ S_VERIFY → S_FIX : needs_rework
134
+
135
+ S_GENERALIZE → S_DISCOVER : hits found
136
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
137
+
138
+ S_DISCOVER → S_DIAGNOSE : new critical issue → cross_phase_loops++
139
+ S_DISCOVER → S_FIX : same-pattern fix, !skip_fix → cross_phase_loops++
140
+ S_DISCOVER → S_RECORD : remaining_actionable == 0
141
+ S_DISCOVER → S_RECORD : loops >= max_loops → MUST log per-item reasons
142
+
143
+ S_RECORD → END : complete
144
+ </transitions>
145
+
146
+ <actions>
147
+
148
+ ### A_INTAKE
149
+ 1. Parse arguments: target description, flags, `--dimensions` subset
150
+ 2. Generate slug, create `SESSION_DIR`
151
+ 3. Search: `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + spec load coding/debug
152
+ 4. **Baseline capture**: Record current metrics (test pass rate, bundle size, dependency count, complexity hotspots) to `session.json.baseline_metrics`
153
+ 5. Derive `phase_goals[]` from flags
154
+ 6. Write `session.json` + `understanding.md` §1, emit Goal Prompt
155
+
156
+ Commit: `"odyssey-improve({slug}): INTAKE — parse target and capture baseline"`
157
+
158
+ ### A_RESUME
159
+ Glob latest session → read `session.json` → display summary → jump to `current_state`.
160
+
161
+ ### A_SURVEY
162
+ Current state survey — understand what exists before proposing changes.
163
+
164
+ 1. Dependency audit (package.json/lock), complexity scan (size/nesting), test coverage map, error handling scan (empty catch, unhandled promise)
165
+ 2. **CLI-assisted** (optional): `maestro delegate --role analyze --mode analysis` for dependency health, complexity hotspots, coverage gaps, error patterns. Execute `run_in_background: true`.
166
+ 3. Evidence phase=survey. Update §2. Mark G1.
167
+
168
+ Commit: `"odyssey-improve({slug}): SURVEY — current state analysis"`
169
+
170
+ ### A_AUDIT
171
+ Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset).
172
+ Each returns: `[{title, severity, dimension, file, line, description, suggestion, measurement}]`
173
+
174
+ Merge evidence phase=audit. Write `session.json.audit_result`.
175
+ Update §3 (findings by dimension + severity matrix). Mark G2.
176
+
177
+ Commit: `"odyssey-improve({slug}): AUDIT — multi-dimension review"`
178
+
179
+ ### A_DIAGNOSE
180
+ Root cause analysis for critical/high findings — don't fix symptoms.
181
+
182
+ 1. Group by dimension, prioritize by severity. For each: hypothesis trace code path + git history → evidence phase=diagnosis
183
+ 2. Ambiguity evidence phase=decision; Normal: AskUserQuestion | `-y`: defer
184
+ 3. CLI-assisted for complex findings: `maestro delegate --role analyze --mode analysis` (`run_in_background: true`)
185
+ 4. Write `session.json.diagnoses[]`. Update §4. Mark G3.
186
+
187
+ Commit: `"odyssey-improve({slug}): DIAGNOSE — root cause analysis"`
188
+
189
+ ### A_ESCALATE_DIAGNOSIS
190
+ `retries++`. < 3: `maestro delegate --role analyze`, new hypotheses, → S_DIAGNOSE. >= 3: Normal → AskUserQuestion | `-y` → INCONCLUSIVE → S_RECORD.
191
+
192
+ ### A_FIX
193
+ 1. Exhaustive fix: ALL diagnosed issues by severity tier (critical high → medium → low within fix_threshold), one dimension at a time. After each tier, re-verify **current tier's dimension only** (not all dimensions) — new findings at same or higher severity append to current tier. Cross-dimension regression checks run once at S_VERIFY after all tiers complete.
194
+ 2. For each fix: implement evidence phase=fix
195
+ 3. Normal: AskUserQuestion per-fix confirmation | `-y`: auto-proceed, record `deferred`
196
+
197
+ Commit: `"odyssey-improve({slug}): FIX — improvements applied"`
198
+
199
+ ### A_VERIFY
200
+ 1. Run tests covering modified areas
201
+ 2. Re-capture metrics, compare with `session.json.baseline_metrics`
202
+ 3. CLI-assisted: `maestro delegate --role review --mode analysis` (`run_in_background: true`)
203
+ 4. `needs_rework` → S_FIX. `verified` mark G4, advance.
204
+ 5. Write `session.json.confirmation`. Update §5 (before/after metrics table).
205
+
206
+ Commit: `"odyssey-improve({slug}): VERIFY — improvements verified"`
207
+
208
+ ### A_GENERALIZE
209
+
210
+ **MANDATORY executes unless `skip_generalize == true`. Prior-phase convergence, "all verified," or context pressure are NOT valid skip reasons.**
211
+
212
+ Pattern source: diagnosed root causes + applied fixes across all dimensions.
213
+
214
+ **Step 1 3-layer pattern extraction** from diagnoses and fixes:
215
+
216
+ | Layer | Method | Targets |
217
+ |-------|--------|---------|
218
+ | Syntax | Build regex from fix diffs → Grep | N+1 query patterns, missing error type check, unescaped interpolation, inline eval |
219
+ | Semantic | Understand anti-pattern per dimension → Agent scan | Cache bypass in hot path, auth check gap, circular import chain, missing timeout |
220
+ | Structural | Find modules with same shape / dependency graph | Controllers sharing validation shape, middleware with same hook pattern, parallel services |
221
+
222
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
223
+
224
+ **Thoroughness floor:** ALL 3 layers must be attempted and logged. Each layer records search method, scope, hit count in evidence phase=generalization. "No hits" requires all 3 layers to return 0 with logged evidence.
225
+
226
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
227
+
228
+ | Agent | Strategy | Scope |
229
+ |-------|----------|-------|
230
+ | Syntax grep | Grep regex from pattern signatures | Full project |
231
+ | Semantic scan | Per-dimension anti-pattern check | Related modules |
232
+ | Structural match | Find structurally similar files | Full project |
233
+ | Historical grep | `git log -S` for pattern signatures | Git history |
234
+
235
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
236
+
237
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
238
+
239
+ **Step 5 — Persist:** Update understanding.md §6 + write `session.json.generalization_stats`:
240
+ ```json
241
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
242
+ ```
243
+
244
+ **Transition guard:** `S_GENERALIZE S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G5 done.
245
+
246
+ Commit: `"odyssey-improve({slug}): GENERALIZE generalization scan complete"`
247
+
248
+ ### A_DISCOVER
249
+
250
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
251
+
252
+ 1. **Triage** each hit with ±10 lines context → classify:
253
+ - `bug` confirmed improvement defect (same dimension)
254
+ - `risk` potential degradation or violation
255
+ - `safe` — false positive (must log individual reason blanket "pre-existing" forbidden)
256
+
257
+ 2. **Route:**
258
+
259
+ | Classification | Action |
260
+ |---------------|--------|
261
+ | bug + fix_template applicable | Immediate fix → back to S_FIX |
262
+ | bug + cross-module decision or no template | Create issue (fix suggestion + impact + dimension) |
263
+ | risk + guard addable directly | Fix directly |
264
+ | risk + complex | Create issue |
265
+ | safe | Skip with logged per-item reason |
266
+
267
+ Normal: AskUserQuestion per hit | `-y`: auto-fix bugs with fix_template, create issue for rest
268
+
269
+ 3. **Cross-phase loops:** `cross_phase_loops++` on fix/diagnose return. `loops >= max_loops` → must log per-item reasons.
270
+
271
+ 4. Append evidence phase=discovery. Update understanding.md §7. Mark G6 done.
272
+
273
+ Commit: `"odyssey-improve({slug}): DISCOVER discovery triage complete"`
274
+
275
+ ### A_RECORD
276
+
277
+ 1. understanding.md §8: improvement metrics before/after comparison from `baseline_metrics` vs current. Re-capture metrics, build comparison table.
278
+ 2. understanding.md §9: learnings by Knowledge Persistence categories:
279
+ - Performance pattern `/spec-add coding`
280
+ - Security rule `/spec-add debug`
281
+ - Architecture constraint `/spec-add arch`
282
+ - Reliability pattern → `/spec-add coding`
283
+ Completion summary lists suggested `/spec-add` commands.
284
+
285
+ 3. Mark G7 done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count).
286
+
287
+ 4. **Goal audit (hardened):**
288
+ - `done` confirmed
289
+ - `skipped` confirmed ONLY if corresponding `skip_when` flag is true
290
+ - **Hard rule:** G5 and G6 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: AskUserQuestion | `-y`: record `failed`)
291
+ - `phase_goals_all_done = true` only when all goals pass this audit
292
+
293
+ 5. `current_state = "COMPLETED"`, emit completion summary.
294
+
295
+ **Completion summary:**
296
+ ```
297
+ --- IMPROVE ODYSSEY COMPLETE ---
298
+ Target: {target}
299
+ Dimensions: {dimensions}
300
+ Findings: {critical}C / {high}H / {medium}M / {low}L
301
+ Diagnosed: {count}
302
+ Fixed: {count} ({verified} verified)
303
+ Metrics: {improved} improved / {regressed} regressed
304
+ Patterns: {count} ({by_layer})
305
+ Scan hits: {total} ({cross_layer_confirmed} confirmed)
306
+ Issues: {N} created
307
+ Decisions: {N} resolved, {M} pending, {K} deferred
308
+ Learnings: {N} persisted
309
+ Self-iter: {N} rounds across {M} stages
310
+ Cross-loops: {N}
311
+ Goals: {done}/{total} ({skipped} skipped)
312
+ ---
313
+ ```
314
+
315
+ Commit: `"odyssey-improve({slug}): RECORD — summary and knowledge persistence"`
316
+
317
+ </actions>
318
+
319
+ <appendix>
320
+
321
+ ### `-y` improve-specific points
322
+
323
+ | Decision Point | Normal | `-y` |
324
+ |---------------|--------|------|
325
+ | A_FIX improvement confirmation | AskUserQuestion | auto-proceed, `deferred` |
326
+ | A_DIAGNOSE ambiguity | AskUserQuestion | best-effort, `deferred` |
327
+ | A_ESCALATE 3-strike | AskUserQuestion 3-way | auto INCONCLUSIVE |
328
+ | A_DISCOVER hit routing | AskUserQuestion | auto create issue |
329
+ | A_DISCOVER ambiguous items | AskUserQuestion | all `deferred` |
330
+
331
+ `deferred` items shown in completion summary; recoverable via `-c`.
332
+
333
+ ### Goal Prompt convergence rules
334
+
335
+ ```
336
+ Exhaust iteration until all findings actioned (fix/issue/decision)
337
+ and phase_goals_all_done=true.
338
+ Fix by severity tiers, re-verify after each tier.
339
+ Baseline captured before fix, compared after to confirm improvement.
340
+ Pending decisions must AskUserQuestion — no silent resolve.
341
+ ```
342
+
343
+ </appendix>
344
+
345
+ </state_machine>
346
+
347
+ <error_codes>
348
+ | Code | Severity | Condition | Recovery |
349
+ |------|----------|-----------|----------|
350
+ | E001 | error | No target specified | Provide target or use -c |
351
+ | E002 | error | Target path not found | Check path |
352
+ | W001 | warning | No dependency manifest found | Proceed without dep audit |
353
+ | W002 | warning | Some dimension agents failed | Partial audit coverage |
354
+ | W003 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
355
+ </error_codes>
356
+
357
+ <success_criteria>
358
+ - [ ] Target resolved, baseline metrics captured
359
+ - [ ] Survey + 6-dimension audit with structured findings and severity matrix
360
+ - [ ] Root causes diagnosed for critical/high findings
361
+ - [ ] Improvements implemented and verified with before/after metrics (unless --skip-fix)
362
+ - [ ] Multi-layer generalization + cross-phase loops (unless --skip-generalize)
363
+ - [ ] Every unfixed finding has individual classification and reason
364
+ - [ ] understanding.md §8 (metrics) and §9 (learnings) completed
365
+ - [ ] phase_goals G1-G7 tracked and audited
366
+ - [ ] Session resumable via -c
367
+ - [ ] Completion summary
368
+ </success_criteria>
369
+
370
+ <next_step_routing>
371
+ | Condition | Next |
372
+ |-----------|------|
373
+ | Security findings need deep investigation | `/odyssey-debug "<finding>"` |
374
+ | UI-related findings | `/odyssey-ui "<component>"` |
375
+ | Issues created from discoveries | `/manage-issue list --source improve-odyssey` |
376
+ | Architecture pattern to document | `/spec-add arch "..."` |
377
+ | Performance pattern to persist | `/spec-add coding "..."` |
378
+ | Formal review of changes | `/odyssey-review-test-fix <changed-files>` |
379
+ | Pending decisions | Filter evidence phase=decision status=pending |
380
+ </next_step_routing>
381
+ </output>