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,265 +1,350 @@
1
- ---
2
- name: odyssey-review-test-fix
3
- description: Deep review + fix cycle — archaeology, exploration, multi-dimensional review, targeted fix, generalization, discovery, and knowledge persistence
4
- argument-hint: "<target> [--dimensions <list>] [--fix-threshold critical|high|medium|low|all] [--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
- archaeology → explore → multi-dimensional review → fix ALL findings → confirm → generalize → discover → persist. Zero-residual: every finding gets an action.
19
- </purpose>
20
-
21
- <boundary>
22
- **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
23
- **Out of scope:** Root cause debug → `/odyssey-debug` | Feature implementation → `/odyssey-planex` | UI visual optimization → `/odyssey-ui`
24
-
25
- **Exploration freedom:** Free within boundary — cross-dimension correlation, git history tracing, project-wide generalization scan. Fix ALL findings within fix_threshold (default: all).
26
- **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
27
- </boundary>
28
-
29
- <context>
30
- $ARGUMENTS
31
-
32
- **Target resolution:**
33
-
34
- | Input | Resolution |
35
- |-------|-----------|
36
- | File/dir path | Review those files |
37
- | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
38
- | Phase number | state.json → changed files |
39
- | PR number | `git diff main...HEAD` |
40
-
41
- **Flags:** `--dimensions <list>` subset of review dimensions | `--fix-threshold <level>` severity cutoff (default: all) | `--skip-fix` skip S_FIX+S_CONFIRM | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
42
-
43
- **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
44
- **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
45
-
46
- **session.json — review-specific fields:**
47
- ```json
48
- { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
49
- "patterns": [], "confirmation": null, "generalization_stats": null }
50
- ```
51
-
52
- **evidence.ndjson phases:** `archaeology|explore|review|fix|discovery|decision|self-iteration`
53
-
54
- **phase_goals[]:**
55
-
56
- | ID | Goal | done_when | phase | skip_when |
57
- |----|------|-----------|-------|-----------|
58
- | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
59
- | G2 | Explore context | explore.json populated | S_EXPLORE | — |
60
- | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
61
- | G4 | Pattern generalized | patterns[] >=1 | S_GENERALIZE | skip_generalize |
62
- | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
63
- | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
64
-
65
- **understanding.md — 8 sections:**
66
- 1. Target & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
67
- 4. Review Results ← S_REVIEW | 5. Fix & Confirmation ← S_FIX+S_CONFIRM
68
- 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER | 8. Learnings ← S_RECORD
69
-
70
- Specs: `maestro load --type spec --category review`
71
-
72
- **Knowledge Persistence categories (section 8):**
73
-
74
- | Category | Content | Follow-up |
75
- |----------|---------|-----------|
76
- | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `/spec-add review` |
77
- | Security finding | Vulnerability type + triggers + fix approach | `/spec-add debug` |
78
- | Architecture violation pattern | Violation + correct boundary + verification | `/spec-add arch` |
79
- | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
80
- </context>
81
-
82
- <invariants>
83
- All invariants defined in base.
84
- </invariants>
85
-
86
- <self_iteration>
87
- Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
88
- </self_iteration>
89
-
90
- <state_machine>
91
-
92
- <states>
93
- S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
94
- </states>
95
-
96
- <transitions>
97
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME_SESSION
98
- S_INTAKE → S_ARCHAEOLOGY : target resolvedA_INTAKE
99
- S_INTAKE → S_INTAKE : no target → AskUserQuestion
100
-
101
- S_ARCHAEOLOGY → S_EXPLORE : complete
102
- S_EXPLORE → S_REVIEW : complete
103
-
104
- S_REVIEW → S_FIX : !skip_fix AND findings
105
- S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
106
- S_REVIEW → S_RECORD : both skip
107
-
108
- S_FIX → S_CONFIRM : tier complete
109
- S_CONFIRM S_GENERALIZE : confirmed, !skip_generalize
110
- S_CONFIRM → S_RECORD : confirmed, skip_generalize
111
- S_CONFIRM → S_FIX : needs_rework
112
-
113
- S_GENERALIZE → S_DISCOVER : similar code found
114
- S_GENERALIZE → S_RECORD : no similar code
115
-
116
- S_DISCOVER → S_FIX : fixable sibling → cross_phase_loops++
117
- S_DISCOVER → S_REVIEW : new target, loops < max_loops → cross_phase_loops++
118
- S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops
119
- </transitions>
120
-
121
- <actions>
122
-
123
- ### A_INTAKE
124
- 1. Parse target + flags → file list. Create SESSION_DIR, derive phase_goals[]
125
- 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
126
- 3. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
127
-
128
- Commit: `"odyssey-review({slug}): INTAKE — parse target and load context"`
129
-
130
- ### A_RESUME_SESSION
131
- Glob latest session → read `session.json` → jump to `current_state`.
132
-
133
- ### A_ARCHAEOLOGY
134
- 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
135
-
136
- **Error handling:** If any archaeology agent fails (Timeline or Blame), log W003 and proceed with available results. If delegate fails, log W003 and proceed with local agent results only.
137
-
138
- `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
139
- - PURPOSE: Review recent modifications related to {target}
140
- - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
141
-
142
- Update section 2. Commit: `"odyssey-review({slug}): ARCHAEOLOGY — git history analysis"`
143
-
144
- ### A_EXPLORE
145
- Skip if no CLI tools (W006).
146
-
147
- `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
148
- - PURPOSE: Call chains, recent changes, error gaps, similar patterns
149
- - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
150
-
151
- Write `explore.json` + evidence phase=explore. Update section 3. Mark G2. Commit: `"odyssey-review({slug}): EXPLORE — codebase exploration"`
152
-
153
- ### A_REVIEW
154
- Spawn N parallel Agents, one per dimension:
155
- - **Correctness**: logic errors, boundary conditions, null/undefined, race conditions
156
- - **Security**: injection, XSS, CSRF, data exposure, auth bypass
157
- - **Performance**: hot paths, N+1, memory leaks, unnecessary recomputation
158
- - **Architecture**: layer violations, circular deps, interface contracts, SoC
159
-
160
- Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence phase=review. Write `review_result` + section 4 severity matrix. Mark G1.
161
-
162
- Commit: `"odyssey-review({slug}): REVIEW — multi-dimension review complete"`
163
-
164
- ### A_FIX
165
- Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`.
166
-
167
- ```
168
- for tier in [critical, high, medium, low].filter(>= threshold):
169
- for each unfixed candidate: read +/-20 lines → fix → evidence phase=fix
170
- re-review modified area (new findings append, continue; max 2 per tier)
171
- tier doneauto-commit
172
- ```
173
-
174
- Normal: AskUserQuestion per tier. `-y`: auto-fix all.
175
- Remaining > 0 → retry (max_fix_rounds = 5). Unchanged 2 rounds → classify each individually. After 5 rounds with remaining > 0 → escalate: Normal: AskUserQuestion (continue/accept/reclassify) | `-y`: classify remaining as `deferred`, proceed.
176
- Blanket "pre-existing" forbidden.
177
-
178
- Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`
179
-
180
- ### A_CONFIRM
181
- Run tests + `maestro delegate --role review --mode analysis` (`run_in_background: true`) for zero-residual review.
182
- - `remaining == 0 AND new == 0` confirmed, mark G3
183
- - Otherwise needs_reworkS_FIX
184
-
185
- Update `confirmation` + `remaining_actionable` + section 5.
186
-
187
- Commit: `"odyssey-review({slug}): CONFIRM — zero-residual verified"`
188
-
189
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
190
- Base shared_actions. Review overrides:
191
- - **A_GENERALIZE** pattern source: findings with severity >= medium
192
- - **A_RECORD** learnings per Knowledge Persistence table
193
-
194
- **Completion summary:**
195
- ```
196
- --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
197
- Target: {target} Dimensions: {dims}
198
- Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
199
- Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
200
- Issues: {N} created
201
- Decisions: {N} resolved, {M} pending, {K} deferred
202
- Learnings: {N} persisted
203
- Self-iter: {N} rounds across {M} stages
204
- Goals: {done}/{total} ({skipped} skipped)
205
- ---
206
- ```
207
-
208
- </actions>
209
-
210
- <appendix>
211
-
212
- ### `-y` review-specific points
213
-
214
- | Decision Point | Normal | `-y` |
215
- |---------------|--------|------|
216
- | S_FIX tier candidates | AskUserQuestion | auto-fix, deferred |
217
- | S_FIX re-review new findings | AskUserQuestion | auto-append |
218
- | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
219
-
220
- ### Goal Prompt convergence rules
221
-
222
- ```
223
- Stop when remaining_actionable == 0, confirmation == confirmed,
224
- generalization exhausted, phase_goals_all_done=true.
225
- Fix iterates by severity tier; each tier re-reviews modified area, new findings appended.
226
- Every finding must have action (fix/issue/decision). Decision pending must AskUserQuestion.
227
- ```
228
-
229
- </appendix>
230
-
231
- </state_machine>
232
-
233
- <error_codes>
234
- | Code | Severity | Condition | Recovery |
235
- |------|----------|-----------|----------|
236
- | E001 | error | No target specified | Provide target |
237
- | E002 | error | Target path not found | Check path |
238
- | W001 | warning | No git history | Proceed |
239
- | W002 | warning | Some dimension agents failed | Partial coverage |
240
- | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
241
- </error_codes>
242
-
243
- <success_criteria>
244
- - [ ] Session + 4 output files + prior knowledge searched
245
- - [ ] Archaeology + CLI review evidence phase=archaeology
246
- - [ ] CLI exploration explore.json + evidence phase=explore
247
- - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0)
248
- - [ ] Per-tier re-review gate; every unfixed finding individually classified
249
- - [ ] understanding.md sections 1-8 progressive
250
- - [ ] Fix + confirmed (unless --skip-fix)
251
- - [ ] Generalization + scan (unless --skip-generalize)
252
- - [ ] Discoveries classified; unfixed findings individually justified
253
- - [ ] phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
254
- - [ ] Completion summary
255
- </success_criteria>
256
-
257
- <next_step_routing>
258
- | Condition | Next |
259
- |-----------|------|
260
- | Deeper debug needed | `/odyssey-debug "<finding>"` |
261
- | Issues created | `/manage-issue list --source review-odyssey` |
262
- | Document pattern | `/learn-decompose <module>` |
263
- | Plan fixes | `/maestro-plan --gaps` |
264
- </next_step_routing>
265
- </output>
1
+ ---
2
+ name: odyssey-review-test-fix
3
+ description: Deep review + fix cycle — archaeology, exploration, multi-dimensional review, targeted fix, generalization, discovery, and knowledge persistence
4
+ argument-hint: "<target> [--dimensions <list>] [--fix-threshold critical|high|medium|low|all] [--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
+ archaeology → explore → multi-dimensional review → fix ALL findings → confirm → generalize → discover → persist. Zero-residual: every finding gets an action.
19
+ </purpose>
20
+
21
+ <boundary>
22
+ **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
23
+ **Out of scope:** Root cause debug → `/odyssey-debug` | Feature implementation → `/odyssey-planex` | UI visual optimization → `/odyssey-ui`
24
+
25
+ **Exploration freedom:** Free within boundary — cross-dimension correlation, git history tracing, project-wide generalization scan. Fix ALL findings within fix_threshold (default: all).
26
+ **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
27
+ </boundary>
28
+
29
+ <context>
30
+ $ARGUMENTS
31
+
32
+ **Target resolution:**
33
+
34
+ | Input | Resolution |
35
+ |-------|-----------|
36
+ | File/dir path | Review those files |
37
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
38
+ | Phase number | state.json → changed files |
39
+ | PR number | `git diff main...HEAD` |
40
+
41
+ **Flags:** `--dimensions <list>` subset of review dimensions | `--fix-threshold <level>` severity cutoff (default: all) | `--skip-fix` skip S_FIX+S_CONFIRM | `--skip-generalize` skip S_GENERALIZE+S_DISCOVER | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
42
+
43
+ **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
44
+ **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
45
+
46
+ **session.json — review-specific fields:**
47
+ ```json
48
+ { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
49
+ "patterns": [], "confirmation": null, "generalization_stats": null }
50
+ ```
51
+
52
+ **evidence.ndjson phases:** `archaeology|explore|review|fix|discovery|decision|self-iteration`
53
+
54
+ **phase_goals[]:**
55
+
56
+ | ID | Goal | done_when | phase | skip_when |
57
+ |----|------|-----------|-------|-----------|
58
+ | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
59
+ | G2 | Explore context | explore.json populated | S_EXPLORE | — |
60
+ | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
61
+ | G4 | Pattern generalized | patterns[] >=1 | S_GENERALIZE | skip_generalize |
62
+ | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
63
+ | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
64
+
65
+ **understanding.md — 8 sections:**
66
+ 1. Target & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
67
+ 4. Review Results ← S_REVIEW | 5. Fix & Confirmation ← S_FIX+S_CONFIRM
68
+ 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER | 8. Learnings ← S_RECORD
69
+
70
+ Specs: `maestro load --type spec --category review`
71
+
72
+ **Knowledge Persistence categories (section 8):**
73
+
74
+ | Category | Content | Follow-up |
75
+ |----------|---------|-----------|
76
+ | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `/spec-add review` |
77
+ | Security finding | Vulnerability type + triggers + fix approach | `/spec-add debug` |
78
+ | Architecture violation pattern | Violation + correct boundary + verification | `/spec-add arch` |
79
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
80
+ </context>
81
+
82
+ <invariants>
83
+ All invariants defined in base.
84
+ 6. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "Zero remaining" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
85
+ </invariants>
86
+
87
+ <self_iteration>
88
+ Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
89
+ </self_iteration>
90
+
91
+ <state_machine>
92
+
93
+ <states>
94
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
95
+ </states>
96
+
97
+ <transitions>
98
+ S_INTAKE → S_INTAKE : -c + session found A_RESUME_SESSION
99
+ S_INTAKE → S_ARCHAEOLOGY : target resolved A_INTAKE
100
+ S_INTAKE → S_INTAKE : no target → AskUserQuestion
101
+
102
+ S_ARCHAEOLOGY → S_EXPLORE : complete
103
+ S_EXPLORE → S_REVIEW : complete
104
+
105
+ S_REVIEW → S_FIX : !skip_fix AND findings
106
+ S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
107
+ S_REVIEW → S_RECORD : both skip
108
+
109
+ S_FIX S_CONFIRM : tier complete
110
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
111
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
112
+ S_CONFIRM → S_FIX : needs_rework
113
+
114
+ S_GENERALIZE → S_DISCOVER : similar code found
115
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
116
+
117
+ S_DISCOVER → S_FIX : fixable sibling → cross_phase_loops++
118
+ S_DISCOVER → S_REVIEW : new target, loops < max_loops cross_phase_loops++
119
+ S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops
120
+ </transitions>
121
+
122
+ <actions>
123
+
124
+ ### A_INTAKE
125
+ 1. Parse target + flags file list. Create SESSION_DIR, derive phase_goals[]
126
+ 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
127
+ 3. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
128
+
129
+ Commit: `"odyssey-review({slug}): INTAKE — parse target and load context"`
130
+
131
+ ### A_RESUME_SESSION
132
+ Glob latest session → read `session.json` → jump to `current_state`.
133
+
134
+ ### A_ARCHAEOLOGY
135
+ 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
136
+
137
+ **Error handling:** If any archaeology agent fails (Timeline or Blame), log W003 and proceed with available results. If delegate fails, log W003 and proceed with local agent results only.
138
+
139
+ `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
140
+ - PURPOSE: Review recent modifications related to {target}
141
+ - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
142
+
143
+ Update section 2. Commit: `"odyssey-review({slug}): ARCHAEOLOGY — git history analysis"`
144
+
145
+ ### A_EXPLORE
146
+ Skip if no CLI tools (W006).
147
+
148
+ `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
149
+ - PURPOSE: Call chains, recent changes, error gaps, similar patterns
150
+ - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
151
+
152
+ Write `explore.json` + evidence phase=explore. Update section 3. Mark G2. Commit: `"odyssey-review({slug}): EXPLORE — codebase exploration"`
153
+
154
+ ### A_REVIEW
155
+ Spawn N parallel Agents, one per dimension:
156
+ - **Correctness**: logic errors, boundary conditions, null/undefined, race conditions
157
+ - **Security**: injection, XSS, CSRF, data exposure, auth bypass
158
+ - **Performance**: hot paths, N+1, memory leaks, unnecessary recomputation
159
+ - **Architecture**: layer violations, circular deps, interface contracts, SoC
160
+
161
+ Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence phase=review. Write `review_result` + section 4 severity matrix. Mark G1.
162
+
163
+ Commit: `"odyssey-review({slug}): REVIEW — multi-dimension review complete"`
164
+
165
+ ### A_FIX
166
+ Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`.
167
+
168
+ ```
169
+ for tier in [critical, high, medium, low].filter(>= threshold):
170
+ for each unfixed candidate: read +/-20 lines fix evidence phase=fix
171
+ re-review modified area (new findings append, continue; max 2 per tier)
172
+ tier done → auto-commit
173
+ ```
174
+
175
+ Normal: AskUserQuestion per tier. `-y`: auto-fix all.
176
+ Remaining > 0 → retry (max_fix_rounds = 5). Unchanged 2 rounds → classify each individually. After 5 rounds with remaining > 0 → escalate: Normal: AskUserQuestion (continue/accept/reclassify) | `-y`: classify remaining as `deferred`, proceed.
177
+ Blanket "pre-existing" forbidden.
178
+
179
+ Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`
180
+
181
+ ### A_CONFIRM
182
+ Run tests + `maestro delegate --role review --mode analysis` (`run_in_background: true`) for zero-residual review.
183
+ - `remaining == 0 AND new == 0` confirmed, mark G3
184
+ - Otherwise → needs_rework → S_FIX
185
+
186
+ Update `confirmation` + `remaining_actionable` + section 5.
187
+
188
+ Commit: `"odyssey-review({slug}): CONFIRM — zero-residual verified"`
189
+
190
+ ### A_GENERALIZE
191
+
192
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "zero remaining," or context pressure are NOT valid skip reasons.**
193
+
194
+ Pattern source: review findings with severity >= medium.
195
+
196
+ **Step 1 — 3-layer pattern extraction** from confirmed findings:
197
+
198
+ | Layer | Method | Targets |
199
+ |-------|--------|---------|
200
+ | Syntax | Build regex from fix diffs → Grep | Unchecked return values, deprecated API calls, missing type assertion, unhandled await |
201
+ | Semantic | Understand anti-pattern per dimension → Agent scan | Logic inversion in edge case, unhandled rejection, incomplete state machine transition |
202
+ | Structural | Find files with same handler/validator shape | Similar route handlers, parallel DTO validators, analogous test fixtures |
203
+
204
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
205
+
206
+ **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.
207
+
208
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
209
+
210
+ | Agent | Strategy | Scope |
211
+ |-------|----------|-------|
212
+ | Syntax grep | Grep regex from pattern signatures | Full project |
213
+ | Semantic scan | Per-dimension anti-pattern check | Related modules |
214
+ | Structural match | Find structurally similar files | Full project |
215
+ | Historical grep | `git log -S` for pattern signatures | Git history |
216
+
217
+ **Step 3 — Cross-layer dedup:** multi-layer hit boost | single-layer → `needs_review` | historically fixed → `regression_risk`
218
+
219
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
220
+
221
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
222
+ ```json
223
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
224
+ ```
225
+
226
+ **Transition guard:** `S_GENERALIZE S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G4 done.
227
+
228
+ Commit: `"odyssey-review({slug}): GENERALIZE — pattern scan complete"`
229
+
230
+ ### A_DISCOVER
231
+
232
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
233
+
234
+ 1. **Triage** each hit with ±10 lines context → classify:
235
+ - `bug` — same defect pattern confirmed in sibling code
236
+ - `risk` potential issue needing guard
237
+ - `safe` false positive (must log individual reason blanket "pre-existing" forbidden)
238
+
239
+ 2. **Route:**
240
+
241
+ | Classification | Action |
242
+ |---------------|--------|
243
+ | fixable sibling | Immediate fix → back to S_FIX, `cross_phase_loops++` |
244
+ | new target needing review | Route to S_REVIEW, `cross_phase_loops++` |
245
+ | risk + guard addable | Fix directly |
246
+ | risk + complex | Create issue |
247
+ | safe | Skip with logged per-item reason |
248
+
249
+ Normal: AskUserQuestion per hit | `-y`: auto-fix with template, create issue for rest
250
+
251
+ 3. **Cross-phase loops:** `loops >= max_loops` must log per-item reasons, advance to S_RECORD.
252
+
253
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G5 done.
254
+
255
+ Commit: `"odyssey-review({slug}): DISCOVER — sibling triage complete"`
256
+
257
+ ### A_RECORD
258
+
259
+ 1. Finalize understanding.md section 8 — learnings by Knowledge Persistence categories:
260
+ - Cross-dimension recurring pattern `/spec-add review`
261
+ - Security finding `/spec-add debug`
262
+ - Architecture violation pattern `/spec-add arch`
263
+ - Reusable generalization pattern `/spec-add coding`
264
+
265
+ 2. Mark G6 done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count).
266
+
267
+ 3. **Goal audit (hardened):**
268
+ - `done` → confirmed
269
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
270
+ - **Hard rule:** G4 and G5 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: AskUserQuestion | `-y`: record `failed`)
271
+ - `phase_goals_all_done = true` only when all goals pass this audit
272
+
273
+ 4. `current_state = "COMPLETED"`, emit completion summary.
274
+
275
+ **Completion summary:**
276
+ ```
277
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
278
+ Target: {target} Dimensions: {dims}
279
+ Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
280
+ Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
281
+ Issues: {N} created
282
+ Decisions: {N} resolved, {M} pending, {K} deferred
283
+ Learnings: {N} persisted
284
+ Self-iter: {N} rounds across {M} stages
285
+ Goals: {done}/{total} ({skipped} skipped)
286
+ ---
287
+ ```
288
+
289
+ Commit: `"odyssey-review({slug}): RECORD — summary and knowledge persistence"`
290
+
291
+ </actions>
292
+
293
+ <appendix>
294
+
295
+ ### `-y` review-specific points
296
+
297
+ | Decision Point | Normal | `-y` |
298
+ |---------------|--------|------|
299
+ | S_FIX tier candidates | AskUserQuestion | auto-fix, deferred |
300
+ | S_FIX re-review new findings | AskUserQuestion | auto-append |
301
+ | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
302
+ | A_DISCOVER hit routing | AskUserQuestion | auto-fix with template, create issue for rest |
303
+
304
+ ### Goal Prompt convergence rules
305
+
306
+ ```
307
+ Stop when remaining_actionable == 0, confirmation == confirmed,
308
+ generalization exhausted, phase_goals_all_done=true.
309
+ Fix iterates by severity tier; each tier re-reviews modified area, new findings appended.
310
+ Every finding must have action (fix/issue/decision). Decision pending must AskUserQuestion.
311
+ ```
312
+
313
+ </appendix>
314
+
315
+ </state_machine>
316
+
317
+ <error_codes>
318
+ | Code | Severity | Condition | Recovery |
319
+ |------|----------|-----------|----------|
320
+ | E001 | error | No target specified | Provide target |
321
+ | E002 | error | Target path not found | Check path |
322
+ | W001 | warning | No git history | Proceed |
323
+ | W002 | warning | Some dimension agents failed | Partial coverage |
324
+ | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
325
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
326
+ </error_codes>
327
+
328
+ <success_criteria>
329
+ - [ ] Session + 4 output files + prior knowledge searched
330
+ - [ ] Archaeology + CLI review → evidence phase=archaeology
331
+ - [ ] CLI exploration → explore.json + evidence phase=explore
332
+ - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0)
333
+ - [ ] Per-tier re-review gate; every unfixed finding individually classified
334
+ - [ ] understanding.md sections 1-8 progressive
335
+ - [ ] Fix + confirmed (unless --skip-fix)
336
+ - [ ] Generalization + scan (unless --skip-generalize)
337
+ - [ ] Discoveries classified; unfixed findings individually justified
338
+ - [ ] phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
339
+ - [ ] Completion summary
340
+ </success_criteria>
341
+
342
+ <next_step_routing>
343
+ | Condition | Next |
344
+ |-----------|------|
345
+ | Deeper debug needed | `/odyssey-debug "<finding>"` |
346
+ | Issues created | `/manage-issue list --source review-odyssey` |
347
+ | Document pattern | `/learn-decompose <module>` |
348
+ | Plan fixes | `/maestro-plan --gaps` |
349
+ </next_step_routing>
350
+ </output>