pi-maestro-flow 0.2.0

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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,392 @@
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 Arguments: <target> [--dimensions <list>] [--fix-threshold critical|high|medium|low|all] [--skip-fix] [--skip-generalize] [--auto] [-y] [-c] [--heartbeat]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
8
+
9
+ <purpose>
10
+ archaeology → explore → multi-dimensional review → fix ALL findings → confirm → generalize → discover → persist. Zero-residual: every finding gets an action.
11
+ </purpose>
12
+
13
+ <boundary>
14
+ **In scope:** Multi-dimensional deep review of target code → exhaustive fix ALL findings by severity → generalize patterns project-wide.
15
+ **Out of scope:** Root cause debug → `/odyssey-debug` | Feature implementation → `/odyssey-planex` | UI visual optimization → `/odyssey-ui`
16
+
17
+ **Exploration freedom:** Free within boundary — cross-dimension correlation, git history tracing, project-wide generalization scan. Fix ALL findings within fix_threshold (default: all).
18
+ **Zero-residual:** Every finding MUST have a concrete action (fix / issue / decision). "Report and shelve" and "pre-existing skip" are forbidden.
19
+ </boundary>
20
+
21
+ <context>
22
+ $ARGUMENTS
23
+
24
+ **Target resolution:**
25
+
26
+ | Input | Resolution |
27
+ |-------|-----------|
28
+ | File/dir path | Review those files |
29
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
30
+ | Phase number | state.json → changed files |
31
+ | PR number | `git diff main...HEAD` |
32
+
33
+ **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
34
+
35
+ **Session**: `.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`
36
+ **Output**: `session.json` | `evidence.ndjson` | `explore.json` | `understanding.md`
37
+
38
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-review-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
39
+
40
+ **session.json — review-specific fields:**
41
+ ```json
42
+ { "target": "", "dimensions": [], "review_result": {"remaining_actionable": 0},
43
+ "patterns": [], "confirmation": null, "generalization_stats": null }
44
+ ```
45
+
46
+ **evidence.ndjson phases:** `archaeology|explore|review|fix|discovery|decision|self-iteration`
47
+
48
+ **phase_goals[]:**
49
+
50
+ | ID | Goal | done_when | phase | skip_when |
51
+ |----|------|-----------|-------|-----------|
52
+ | G1 | Review completed | all dimensions reviewed | S_REVIEW | — |
53
+ | G2 | Explore context | explore.json populated | S_EXPLORE | — |
54
+ | G3 | Zero remaining | `remaining_actionable == 0` | S_CONFIRM | skip_fix |
55
+ | G4 | Pattern generalized | patterns[] >=1 | S_GENERALIZE | skip_generalize |
56
+ | G5 | Discoveries triaged | all hits classified | S_DISCOVER | skip_generalize |
57
+ | G6 | Learnings persisted | spec entries or no actionable | S_RECORD | — |
58
+
59
+ **understanding.md — 8 sections:**
60
+ 1. Target & Scope ← S_INTAKE | 2. Archaeology ← S_ARCHAEOLOGY | 3. Exploration ← S_EXPLORE
61
+ 4. Review Results ← S_REVIEW | 5. Fix & Confirmation ← S_FIX+S_CONFIRM
62
+ 6. Generalization ← S_GENERALIZE | 7. Discoveries ← S_DISCOVER | 8. Learnings ← S_RECORD
63
+
64
+ Specs: `maestro load --type spec --category review`
65
+
66
+ **Knowledge Persistence categories (section 8):**
67
+
68
+ | Category | Content | Follow-up |
69
+ |----------|---------|-----------|
70
+ | Cross-dimension recurring pattern | Pattern + affected dimensions + coding standard | `/spec-add review` |
71
+ | Security finding | Vulnerability type + triggers + fix approach | `/spec-add debug` |
72
+ | Architecture violation pattern | Violation + correct boundary + verification | `/spec-add arch` |
73
+ | Reusable generalization pattern | Signature + risk + fix template + scope | `/spec-add coding` |
74
+ </context>
75
+
76
+ <invariants>
77
+ All invariants defined in base.
78
+ 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.
79
+ </invariants>
80
+
81
+ <self_iteration>
82
+ Applies to: **S_ARCHAEOLOGY, S_EXPLORE, S_REVIEW, S_FIX, S_GENERALIZE**. Logic in base.
83
+ </self_iteration>
84
+
85
+ <execution>
86
+ Follow base execution discipline completely. Actions defined in state_machine below.
87
+
88
+ ### Phase Gates (MANDATORY, BLOCKING)
89
+
90
+ **GATE 1: INTAKE → ARCHAEOLOGY**
91
+ - REQUIRED: Target resolved to file list, SESSION_DIR created, session.json initialized.
92
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
93
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
94
+
95
+ **GATE 2: ARCHAEOLOGY → EXPLORE**
96
+ - REQUIRED: Git history analysis completed (timeline + blame agents), evidence phase=archaeology logged.
97
+ - REQUIRED: understanding.md §2 updated.
98
+ - BLOCKED if: both archaeology agents failed AND delegate failed (partial results via W003 are acceptable).
99
+
100
+ **GATE 3: EXPLORE → REVIEW**
101
+ - REQUIRED: explore.json written with call_chains/recent_changes/error_gaps/similar_patterns (or W006 skip logged).
102
+ - REQUIRED: Evidence phase=explore logged, understanding.md §3 updated, G2 marked done.
103
+ - BLOCKED if: exploration started but not completed (W006 skip is acceptable, incomplete is not).
104
+
105
+ **GATE 4: REVIEW → FIX**
106
+ - REQUIRED: All dimension agents completed, findings merged with severity classification.
107
+ - REQUIRED: review_result written to session.json, understanding.md §4 with severity matrix, G1 marked done.
108
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
109
+
110
+ **GATE 5: FIX → CONFIRM**
111
+ - REQUIRED: Current severity tier fully addressed — all findings in tier fixed or individually classified.
112
+ - REQUIRED: Per-fix evidence phase=fix logged, auto-commit per tier.
113
+ - BLOCKED if: tier incomplete — no partial tier advancement.
114
+
115
+ **GATE 6: CONFIRM → GENERALIZE**
116
+ - REQUIRED: Tests pass, remaining_actionable == 0, new findings == 0.
117
+ - REQUIRED: confirmation written, understanding.md §5 updated, G3 marked done.
118
+ - BLOCKED if: needs_rework → route back to S_FIX.
119
+
120
+ **GATE 7: GENERALIZE → DISCOVER**
121
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
122
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G4 marked done.
123
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
124
+
125
+ **GATE 8: DISCOVER → RECORD**
126
+ - REQUIRED: All hits triaged with per-item classification and reason.
127
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
128
+ - REQUIRED: G5 marked done.
129
+ - BLOCKED if: unclassified hits remain.
130
+
131
+ </execution>
132
+
133
+ <state_machine>
134
+
135
+ <states>
136
+ S_INTAKE → S_ARCHAEOLOGY → S_EXPLORE → S_REVIEW → S_FIX → S_CONFIRM → S_GENERALIZE → S_DISCOVER → S_RECORD → END
137
+ </states>
138
+
139
+ <transitions>
140
+ S_INTAKE → S_INTAKE : -c + session found → A_RESUME_SESSION
141
+ S_INTAKE → S_ARCHAEOLOGY : target resolved → A_INTAKE
142
+ S_INTAKE → S_INTAKE : no target → AskUserQuestion
143
+
144
+ S_ARCHAEOLOGY → S_EXPLORE : complete
145
+ S_EXPLORE → S_REVIEW : complete
146
+
147
+ S_REVIEW → S_FIX : !skip_fix AND findings
148
+ S_REVIEW → S_GENERALIZE : skip_fix OR no findings, !skip_generalize
149
+ S_REVIEW → S_RECORD : both skip
150
+
151
+ S_FIX → S_CONFIRM : tier complete
152
+ S_CONFIRM → S_GENERALIZE : confirmed, !skip_generalize
153
+ S_CONFIRM → S_RECORD : confirmed, skip_generalize
154
+ S_CONFIRM → S_FIX : needs_rework
155
+
156
+ S_GENERALIZE → S_DISCOVER : similar code found
157
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
158
+
159
+ S_DISCOVER → S_FIX : fixable sibling → cross_phase_loops++
160
+ S_DISCOVER → S_REVIEW : new target, loops < max_loops → cross_phase_loops++
161
+ S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops
162
+ </transitions>
163
+
164
+ <actions>
165
+
166
+ ### A_INTAKE
167
+ 1. Parse target + flags → file list. Create SESSION_DIR, derive phase_goals[]
168
+ 2. `maestro search "<keywords>"` + Glob prior sessions + ARCHITECTURE.md + Grep keywords
169
+ 3. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
170
+
171
+ Commit: `"odyssey-review({slug}): INTAKE — parse target and load context"`
172
+
173
+ ### A_RESUME_SESSION
174
+ Glob latest session → read `session.json` → jump to `current_state`.
175
+
176
+ ### A_ARCHAEOLOGY
177
+ 2 parallel Agents: Timeline (`git log --oneline -20 -- {files}`) + Blame (top 3 files `git blame -L {region}`). Evidence phase=archaeology.
178
+
179
+ **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.
180
+
181
+ `maestro delegate --role analyze --mode analysis` (`run_in_background: true`):
182
+ - PURPOSE: Review recent modifications related to {target}
183
+ - EXPECTED: JSON [{commit_sha, risk_level, analysis, could_cause_issue, explanation}]
184
+
185
+ Update section 2. Commit: `"odyssey-review({slug}): ARCHAEOLOGY — git history analysis"`
186
+
187
+ ### A_EXPLORE
188
+ Skip if no CLI tools (W006).
189
+
190
+ `maestro delegate --role explore --mode analysis` (`run_in_background: true`):
191
+ - PURPOSE: Call chains, recent changes, error gaps, similar patterns
192
+ - EXPECTED: JSON {call_chains, recent_changes, error_gaps, similar_patterns}
193
+
194
+ Write `explore.json` + evidence phase=explore. Update section 3. Mark G2. Commit: `"odyssey-review({slug}): EXPLORE — codebase exploration"`
195
+
196
+ ### A_REVIEW
197
+ Spawn N parallel Agents, one per dimension:
198
+ - **Correctness**: logic errors, boundary conditions, null/undefined, race conditions
199
+ - **Security**: injection, XSS, CSRF, data exposure, auth bypass
200
+ - **Performance**: hot paths, N+1, memory leaks, unnecessary recomputation
201
+ - **Architecture**: layer violations, circular deps, interface contracts, SoC
202
+
203
+ Each returns `[{title, severity, file, line, description, suggestion, cwe}]`. Merge → evidence phase=review. Write `review_result` + section 4 severity matrix. Mark G1.
204
+
205
+ Commit: `"odyssey-review({slug}): REVIEW — multi-dimension review complete"`
206
+
207
+ ### A_FIX
208
+ Exhaustive iterative fix — descend by severity until `remaining_actionable == 0`.
209
+
210
+ ```
211
+ for tier in [critical, high, medium, low].filter(>= threshold):
212
+ for each unfixed candidate: read +/-20 lines → fix → evidence phase=fix
213
+ re-review modified area (new findings → append, continue; max 2 per tier)
214
+ tier done → auto-commit
215
+ ```
216
+
217
+ Normal: AskUserQuestion per tier. `-y`: auto-fix all.
218
+ 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.
219
+ Blanket "pre-existing" forbidden.
220
+
221
+ Commit per tier: `"odyssey-review({slug}): FIX-{tier} — {N} items fixed"`
222
+
223
+ ### A_CONFIRM
224
+ Run tests + `maestro delegate --role review --mode analysis` (`run_in_background: true`) for zero-residual review.
225
+ - `remaining == 0 AND new == 0` → confirmed, mark G3
226
+ - Otherwise → needs_rework → S_FIX
227
+
228
+ Update `confirmation` + `remaining_actionable` + section 5.
229
+
230
+ Commit: `"odyssey-review({slug}): CONFIRM — zero-residual verified"`
231
+
232
+ ### A_GENERALIZE
233
+
234
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "zero remaining," or context pressure are NOT valid skip reasons.**
235
+
236
+ Pattern source: review findings with severity >= medium.
237
+
238
+ **Step 1 — 3-layer pattern extraction** from confirmed findings:
239
+
240
+ | Layer | Method | Targets |
241
+ |-------|--------|---------|
242
+ | Syntax | Build regex from fix diffs → Grep | Unchecked return values, deprecated API calls, missing type assertion, unhandled await |
243
+ | Semantic | Understand anti-pattern per dimension → Agent scan | Logic inversion in edge case, unhandled rejection, incomplete state machine transition |
244
+ | Structural | Find files with same handler/validator shape | Similar route handlers, parallel DTO validators, analogous test fixtures |
245
+
246
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
247
+
248
+ **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.
249
+
250
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
251
+
252
+ | Agent | Strategy | Scope |
253
+ |-------|----------|-------|
254
+ | Syntax grep | Grep regex from pattern signatures | Full project |
255
+ | Semantic scan | Per-dimension anti-pattern check | Related modules |
256
+ | Structural match | Find structurally similar files | Full project |
257
+ | Historical grep | `git log -S` for pattern signatures | Git history |
258
+
259
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
260
+
261
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
262
+
263
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
264
+ ```json
265
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
266
+ ```
267
+
268
+ **Transition guard:** `S_GENERALIZE → S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G4 done.
269
+
270
+ Commit: `"odyssey-review({slug}): GENERALIZE — pattern scan complete"`
271
+
272
+ ### A_DISCOVER
273
+
274
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
275
+
276
+ 1. **Triage** each hit with ±10 lines context → classify:
277
+ - `bug` — same defect pattern confirmed in sibling code
278
+ - `risk` — potential issue needing guard
279
+ - `safe` — false positive (must log individual reason — blanket "pre-existing" forbidden)
280
+
281
+ 2. **Route:**
282
+
283
+ | Classification | Action |
284
+ |---------------|--------|
285
+ | fixable sibling | Immediate fix → back to S_FIX, `cross_phase_loops++` |
286
+ | new target needing review | Route to S_REVIEW, `cross_phase_loops++` |
287
+ | risk + guard addable | Fix directly |
288
+ | risk + complex | Create issue |
289
+ | safe | Skip with logged per-item reason |
290
+
291
+ Normal: AskUserQuestion per hit | `-y`: auto-fix with template, create issue for rest
292
+
293
+ 3. **Cross-phase loops:** `loops >= max_loops` → must log per-item reasons, advance to S_RECORD.
294
+
295
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G5 done.
296
+
297
+ Commit: `"odyssey-review({slug}): DISCOVER — sibling triage complete"`
298
+
299
+ ### A_RECORD
300
+
301
+ 1. Finalize understanding.md section 8 — learnings by Knowledge Persistence categories:
302
+ - Cross-dimension recurring pattern → `/spec-add review`
303
+ - Security finding → `/spec-add debug`
304
+ - Architecture violation pattern → `/spec-add arch`
305
+ - Reusable generalization pattern → `/spec-add coding`
306
+
307
+ 2. Mark G6 done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count).
308
+
309
+ 3. **Goal audit (hardened):**
310
+ - `done` → confirmed
311
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
312
+ - **Hard rule:** G4 and G5 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: AskUserQuestion | `-y`: record `failed`)
313
+ - `phase_goals_all_done = true` only when all goals pass this audit
314
+
315
+ 4. `current_state = "COMPLETED"`, emit completion summary.
316
+
317
+ **Completion summary:**
318
+ ```
319
+ --- REVIEW-TEST-FIX ODYSSEY COMPLETE ---
320
+ Target: {target} Dimensions: {dims}
321
+ Findings: {C}C {H}H {M}M {L}L Fix: {fixed}, confirmed={yes|skip}
322
+ Patterns: {N} ({by_layer}) Scan hits: {total} ({cross} cross-layer)
323
+ Issues: {N} created
324
+ Decisions: {N} resolved, {M} pending, {K} deferred
325
+ Learnings: {N} persisted
326
+ Self-iter: {N} rounds across {M} stages
327
+ Goals: {done}/{total} ({skipped} skipped)
328
+ ---
329
+ ```
330
+
331
+ Commit: `"odyssey-review({slug}): RECORD — summary and knowledge persistence"`
332
+
333
+ </actions>
334
+
335
+ <appendix>
336
+
337
+ ### `-y` review-specific points
338
+
339
+ | Decision Point | Normal | `-y` |
340
+ |---------------|--------|------|
341
+ | S_FIX tier candidates | AskUserQuestion | auto-fix, deferred |
342
+ | S_FIX re-review new findings | AskUserQuestion | auto-append |
343
+ | S_CONFIRM needs_rework | Display → S_FIX | auto proceed |
344
+ | A_DISCOVER hit routing | AskUserQuestion | auto-fix with template, create issue for rest |
345
+
346
+ ### Goal Prompt convergence rules
347
+
348
+ ```
349
+ Stop when remaining_actionable == 0, confirmation == confirmed,
350
+ generalization exhausted, phase_goals_all_done=true.
351
+ Fix iterates by severity tier; each tier re-reviews modified area, new findings appended.
352
+ Every finding must have action (fix/issue/decision). Decision pending must AskUserQuestion.
353
+ ```
354
+
355
+ </appendix>
356
+
357
+ </state_machine>
358
+
359
+ <error_codes>
360
+ | Code | Severity | Condition | Recovery |
361
+ |------|----------|-----------|----------|
362
+ | E001 | error | No target specified | Provide target |
363
+ | E002 | error | Target path not found | Check path |
364
+ | W001 | warning | No git history | Proceed |
365
+ | W002 | warning | Some dimension agents failed | Partial coverage |
366
+ | W003 | warning | Archaeology agent or delegate failure | Proceed with available results |
367
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
368
+ </error_codes>
369
+
370
+ <success_criteria>
371
+ - [ ] Session + 4 output files + prior knowledge searched
372
+ - [ ] Archaeology + CLI review → evidence phase=archaeology
373
+ - [ ] CLI exploration → explore.json + evidence phase=explore
374
+ - [ ] All dimensions reviewed, ALL findings fixed (remaining_actionable == 0)
375
+ - [ ] Per-tier re-review gate; every unfixed finding individually classified
376
+ - [ ] understanding.md sections 1-8 progressive
377
+ - [ ] Fix + confirmed (unless --skip-fix)
378
+ - [ ] Generalization + scan (unless --skip-generalize)
379
+ - [ ] Discoveries classified; unfixed findings individually justified
380
+ - [ ] phase_goals G1-G6 audited, Goal Prompt once, `-y` no blocking, -c resumable
381
+ - [ ] Completion summary
382
+ </success_criteria>
383
+
384
+ <next_step_routing>
385
+ | Condition | Next |
386
+ |-----------|------|
387
+ | Deeper debug needed | `/odyssey-debug "<finding>"` |
388
+ | Issues created | `/manage-issue list --source review-odyssey` |
389
+ | Document pattern | `/learn-decompose <module>` |
390
+ | Plan fixes | `/maestro-plan --gaps` |
391
+ </next_step_routing>
392
+ </output>