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