pi-maestro-flow 0.2.0 → 0.3.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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +13 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -7
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +9 -10
  28. package/skills/maestro-amend/SKILL.md +3 -3
  29. package/skills/maestro-analyze/SKILL.md +10 -13
  30. package/skills/maestro-blueprint/SKILL.md +8 -11
  31. package/skills/maestro-brainstorm/SKILL.md +11 -14
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +11 -12
  35. package/skills/maestro-execute/SKILL.md +9 -12
  36. package/skills/maestro-fork/SKILL.md +8 -11
  37. package/skills/maestro-grill/SKILL.md +13 -16
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +9 -12
  42. package/skills/maestro-merge/SKILL.md +6 -8
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -5
  44. package/skills/maestro-milestone-complete/SKILL.md +9 -12
  45. package/skills/maestro-milestone-release/SKILL.md +9 -11
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +16 -16
  48. package/skills/maestro-plan/SKILL.md +9 -12
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -7
  51. package/skills/maestro-ralph/SKILL.md +16 -17
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +18 -19
  56. package/skills/maestro-roadmap/SKILL.md +8 -9
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -7
  59. package/skills/maestro-tools-register/SKILL.md +7 -9
  60. package/skills/maestro-ui-codify/SKILL.md +9 -10
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -6
  64. package/skills/manage-drift-realign/SKILL.md +8 -11
  65. package/skills/manage-harvest/SKILL.md +6 -9
  66. package/skills/manage-issue/SKILL.md +5 -8
  67. package/skills/manage-issue-discover/SKILL.md +8 -11
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -5
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -6
  71. package/skills/manage-knowledge-audit/SKILL.md +6 -9
  72. package/skills/manage-status/SKILL.md +3 -5
  73. package/skills/manage-wiki/SKILL.md +5 -7
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -5
  81. package/skills/quality-debug/SKILL.md +3 -5
  82. package/skills/quality-refactor/SKILL.md +3 -5
  83. package/skills/quality-retrospective/SKILL.md +10 -13
  84. package/skills/quality-review/SKILL.md +5 -8
  85. package/skills/quality-sync/SKILL.md +3 -5
  86. package/skills/quality-test/SKILL.md +4 -6
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -4
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -7
  102. package/skills/spec-load/SKILL.md +3 -5
  103. package/skills/spec-remove/SKILL.md +4 -6
  104. package/skills/spec-setup/SKILL.md +6 -8
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,305 @@
1
+ # Odyssey Shared Base (Codex)
2
+
3
+ Shared by all Odyssey commands (debug, improve, planex, review-test-fix, ui).
4
+
5
+ <execution_discipline>
6
+
7
+ 1. **Phase auto-commit** — auto `git commit` after each phase
8
+ - Code changes + understanding.md → `git add` → `git commit -m "{command}({slug}): {phase} — {summary}"`
9
+ - session.json / evidence.ndjson are runtime state, excluded from commits
10
+
11
+ 2. **Confident edits only, but must attempt** — edit when confident; record decision only when human judgment truly needed
12
+ - Confident → edit + commit
13
+ - Needs decision → `evidence.ndjson {"phase":"decision","status":"pending"}`, no code change
14
+ - **Decision gate** — only these qualify: cross-module architecture tradeoffs needing human direction | business semantics ambiguity where fix may change intent | new dependency or breaking API required
15
+ - "Unsure how to fix", "Too large scope", "Pre-existing issue" are NOT valid decision reasons
16
+
17
+ 3. **Multi-CLI assist** — `maestro delegate` for cross-angle verification
18
+ - Different `--role` per phase (analyze / review / explore)
19
+ - **`--role` fallback:** when `cli-tools.json` `roles` is empty, `--role` auto-falls back to first enabled tool. Equivalent to `--to <first-enabled>` but preserves semantic annotation for log tracking
20
+ - All delegate calls `run_in_background: true`, wait for callback
21
+
22
+ 4. **Never abort for context exhaustion** — harness auto-compresses context; aborting due to "insufficient context" or "already ran N phases" is a discipline violation. Must complete through S_RECORD → END.
23
+
24
+ **Zero-residual:** Every finding must have an action (fix / issue / decision). "Report only" and "pre-existing skip" are forbidden.
25
+ </execution_discipline>
26
+
27
+ <flag_semantics>
28
+
29
+ ### `--auto` vs `-y`
30
+
31
+ | Flag | Scope | Effect |
32
+ |------|-------|--------|
33
+ | `--auto` | **CLI delegate calls** | Skip delegate launch confirmation, execute `run_in_background` directly |
34
+ | `-y` | **Human decision points** | All `request_user_input` calls auto-select default, record as `deferred` |
35
+
36
+ - `--auto` does not affect human decision points (ambiguity, triage, goal audit still need confirmation or `-y`)
37
+ - `-y` does not affect delegate calls (delegates always auto-execute, `--auto` only controls pre-launch confirmation)
38
+ - Combine: `--auto -y` = fully automatic mode
39
+ - `session.json.flags` mapping: `auto` ↔ `--auto`, `auto_confirm` ↔ `-y`
40
+ </flag_semantics>
41
+
42
+ <shared_schemas>
43
+
44
+ ### session.json standard fields
45
+
46
+ ```json
47
+ {
48
+ "session_id": "{type}-odyssey-{YYYYMMDD-HHmmss}",
49
+ "current_state": "S_INTAKE",
50
+ "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
51
+ "phase_goals": [], "phase_goals_all_done": false,
52
+ "self_iteration_log": [],
53
+ "cross_phase_loops": 0, "max_loops": 5,
54
+ "created_at": "", "updated_at": ""
55
+ }
56
+ ```
57
+
58
+ Each command adds its own fields (e.g. `issue`, `target`, `requirement`).
59
+ Note: `cross_phase_loops` and `max_loops` are shared fields — commands should not redeclare them.
60
+
61
+ ### evidence.ndjson base schema
62
+
63
+ ```json
64
+ {"ts":"","phase":"","type":"","source":"","content":"","note":""}
65
+ ```
66
+
67
+ Each command defines phase-specific extension fields (e.g. `hypothesis`, `severity`, `dimension`).
68
+
69
+ ### patterns[] schema (A_GENERALIZE output)
70
+
71
+ ```json
72
+ {
73
+ "id": "P1",
74
+ "source": "<value>",
75
+ "layer": "syntax|semantic|structural",
76
+ "signature": "regex or description",
77
+ "description": "human-readable",
78
+ "risk": "high|medium|low",
79
+ "fix_template": "code pattern or instruction",
80
+ "confidence": "high|medium|low"
81
+ }
82
+ ```
83
+
84
+ `source` field value per command:
85
+
86
+ | Command | source value | Meaning |
87
+ |---------|-------------|---------|
88
+ | debug | root_cause | Root cause fix |
89
+ | improve | diagnosis | Diagnosed finding |
90
+ | review-test-fix | finding | Review finding |
91
+ | ui | finding | Audit/diverge finding |
92
+ | planex | implementation | Implementation pattern |
93
+
94
+ ### generalization_stats schema
95
+
96
+ ```json
97
+ {
98
+ "patterns_extracted": 0, "total_hits": 0,
99
+ "cross_layer_confirmed": 0, "regression_risks": 0,
100
+ "by_layer": {"syntax": 0, "semantic": 0, "structural": 0},
101
+ "deepening_triggered": false
102
+ }
103
+ ```
104
+
105
+ </shared_schemas>
106
+
107
+ <anti_stall>
108
+
109
+ ### progress_metrics fields
110
+
111
+ ```json
112
+ {
113
+ "progress_metrics": {
114
+ "phase_stats": {},
115
+ "stale_count": 0,
116
+ "last_productive_phase": "",
117
+ "convergence_trend": "unknown"
118
+ },
119
+ "directions_tried": []
120
+ }
121
+ ```
122
+
123
+ ### Progress Tracking
124
+
125
+ After each analytical phase:
126
+ 1. Count `new_findings` (deduplicated) and `repeated` (matching existing evidence)
127
+ 2. Write to `progress_metrics.phase_stats[state_name]`
128
+ 3. `new == 0` → `stale_count++`, `convergence_trend = "stalling"`
129
+ 4. `new > 0` → `stale_count = 0`, update `last_productive_phase`
130
+ 5. 2 consecutive phases with declining new → `convergence_trend = "diminishing"`
131
+
132
+ ### Direction Diversity
133
+
134
+ ```json
135
+ {
136
+ "phase": "S_DIAGNOSE", "round": 1,
137
+ "strategy_type": "scope_widen|perspective_shift|tool_switch|structural_pivot",
138
+ "strategy_desc": "expand search to utils/", "result": "2 new findings"
139
+ }
140
+ ```
141
+
142
+ **Dedup rule:** Check same-phase history before self-iteration → new strategy must differ in `strategy_type` or `strategy_desc` → all 4 types tried → force stale_count upgrade
143
+
144
+ ### Stall Escalation Ladder
145
+
146
+ | stale_count | Strategy |
147
+ |-------------|----------|
148
+ | 0 | Normal advance |
149
+ | 1 | **Shift perspective** — different CLI tool, reverse trace, manual read. Must differ from directions_tried |
150
+ | 2 | **Structural pivot** — redefine search dimensions, switch analysis framework, decompose sub-problems. Not parameter tuning |
151
+ | 3 | **Human escalation** — request_user_input / `-y` auto INCONCLUSIVE and advance |
152
+
153
+ ### /loop Heartbeat (optional, `--heartbeat`)
154
+
155
+ Suggest `/loop 270s`. Each phase updates `session.json.updated_at`. >15 min without update → alert + stale_count. 2 consecutive no-update → suggest `-c` resume.
156
+ </anti_stall>
157
+
158
+ <self_iteration>
159
+
160
+ ### Quality Gate
161
+
162
+ | Dimension | Sufficient | Insufficient |
163
+ |-----------|-----------|-------------|
164
+ | Coverage | All known related files/modules analyzed | Missed targets discoverable via grep/git log |
165
+ | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
166
+ | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
167
+
168
+ **Progress-aware iteration:**
169
+ - Phase complete → evaluate 3 dimensions + check `progress_metrics`
170
+ - Any insufficient AND `stale_count < 3` → re-enter with expansion strategy (must pass directions_tried dedup)
171
+ - Follow Stall Escalation Ladder for strategy selection
172
+
173
+ **Expansion strategies:**
174
+ - `scope_widen`: more directories, git log depth ×2, additional delegate angles
175
+ - `perspective_shift`: different CLI tool, reverse trace, manual reading
176
+ - `tool_switch`: switch to unused analysis tool
177
+ - `structural_pivot`: redefine problem framework, decompose sub-problems
178
+
179
+ **Exit:** all sufficient → advance | `stale_count >= 3` → log gaps, advance
180
+
181
+ **Log:** `evidence.ndjson {"phase":"self-iteration"}` + `session.json.self_iteration_log[]` + `directions_tried[]`
182
+ </self_iteration>
183
+
184
+ <shared_actions>
185
+
186
+ ### A_GENERALIZE
187
+
188
+ 3-layer pattern extraction → 4-agent concurrent scan → cross-layer dedup → iterative deepening.
189
+
190
+ **Pattern source:** specified by each command (root cause / audit findings / implementation patterns).
191
+
192
+ **3-layer extraction:**
193
+
194
+ | Layer | Method | Example |
195
+ |-------|--------|---------|
196
+ | Syntax | Regex → Grep | `eval(`, missing `await`, inline styles |
197
+ | Semantic | Agent understands anti-pattern → scan | Unhandled async errors, missing validation |
198
+ | Structural | File/module structure similarity | Same import structure, missing override |
199
+
200
+ Write `session.json.patterns[]` — schema in `<shared_schemas>` patterns[] definition.
201
+
202
+ **4-agent concurrent scan (spawn_agents_on_csv, wave number specified by each command):**
203
+
204
+ | Agent | Strategy | Scope |
205
+ |-------|----------|-------|
206
+ | Syntax grep | Grep regex | Full project |
207
+ | Semantic scan | Anti-pattern check | Related modules |
208
+ | Structural match | Structurally similar files | Full project |
209
+ | Historical grep | `git log -S` | Git history |
210
+
211
+ **Cross-layer dedup:** multi-layer hit → boost confidence | single-layer → `needs_review` | historically fixed → `regression_risk`
212
+
213
+ **Iterative deepening:** module ≥3 hits → targeted deep scan (max 1 round)
214
+
215
+ **Persist:** understanding.md generalization section + `session.json.generalization_stats`
216
+
217
+ Commit: `"...({slug}): GENERALIZE — generalization scan complete"`
218
+
219
+ ### A_DISCOVER
220
+
221
+ 1. **Triage** each hit ±10 lines context → classify `bug` / `risk` / `safe`
222
+ 2. **Route:**
223
+ - bug + fix_template applicable → immediate fix → back to S_FIX
224
+ - bug + needs cross-module decision or no fix_template → create issue (with fix suggestion + impact analysis)
225
+ - risk → assess if guard can be added directly; yes → fix; no → create issue
226
+ - safe → skip
227
+ Normal: request_user_input | `-y`: auto-fix bugs with fix_template, create issue for rest
228
+ 3. **Cross-phase loops:** `cross_phase_loops++`. `loops >= max_loops` → must log per-item reasons (blanket "pre-existing" forbidden)
229
+ 4. Append evidence + update understanding.md
230
+
231
+ Commit: `"...({slug}): DISCOVER — discovery triage complete"`
232
+
233
+ ### A_RECORD
234
+
235
+ 1. Finalize understanding.md final section — learnings structured by each command's category table
236
+ 2. Mark record goal done. Pending decisions: Normal → request_user_input | `-y` → skip (show deferred count)
237
+ 3. **Goal audit:** all `completion_confirmed` → `phase_goals_all_done = true`. Incomplete: Normal → request_user_input | `-y` → auto accept
238
+ 4. `current_state = "COMPLETED"`, emit completion summary (format defined by each command)
239
+
240
+ Commit: `"...({slug}): RECORD — summary and knowledge persistence"`
241
+
242
+ </shared_actions>
243
+
244
+ <shared_appendix>
245
+
246
+ ### Goal Prompt
247
+
248
+ **Timing guard: display ONCE after INTAKE completes. Never re-display at RECORD.**
249
+
250
+ ```
251
+ {Command} Odyssey session created. Copy the /goal below to set termination criteria:
252
+
253
+ /goal Complete these goals:
254
+ {for each G in phase_goals where status != "skipped":}
255
+ - {G.id}: {G.goal} — done when: {G.done_when}
256
+ {end for}
257
+ {command-specific convergence rules}
258
+ Pending phase=decision items must use request_user_input, never self-resolve.
259
+ ```
260
+
261
+ Continue execution after output, do not block.
262
+
263
+ ### `-y` generic rules
264
+
265
+ - Decision pending → best-effort continue, record `deferred`
266
+ - 3-strike escalation → auto INCONCLUSIVE
267
+ - Discovery routing → auto-fix bugs with fix_template, create issue for rest
268
+ - Record pending → skip, show deferred count
269
+ - Record goal audit → auto accept
270
+
271
+ `deferred` items shown in completion summary; recoverable via `-c`. Each command lists its own specific decision points.
272
+
273
+ ### Phase Goal Lifecycle
274
+
275
+ `pending → done (confirmed=true)` | `pending → skipped (confirmed=true)` | `pending → failed (confirmed=false)`
276
+
277
+ `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
278
+
279
+ ### Session Resume (`-c`)
280
+
281
+ 1. `Glob(".workflow/scratch/*-{type}-odyssey-*")` scan all matching session directories
282
+ 2. **Multiple sessions: sort by `session.json.updated_at` descending, select most recent**
283
+ 3. Read `session.json` → display summary (issue/target, current_state, phase_goals status)
284
+ 4. Jump to `current_state` and continue
285
+
286
+ ### Pre-load (optional, missing does not block)
287
+
288
+ | Layer | Command |
289
+ |-------|---------|
290
+ | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` |
291
+ | Wiki search | `maestro search "<keywords>" --json` (top 5) |
292
+ | Specs | `maestro load --type spec --category <cat>` |
293
+ | Role knowledge | `maestro search --category <cat>` → `maestro load --type knowhow --id <id>` |
294
+ | Prior sessions | `Glob(".workflow/scratch/*-{type}-odyssey-*")` |
295
+
296
+ ### Common Error Codes
297
+
298
+ | Code | Severity | Condition | Recovery |
299
+ |------|----------|-----------|----------|
300
+ | E003 | error | Resume but no session found | Start new |
301
+ | E004 | error | Delegate failed | Retry or proceed without |
302
+ | W003 | warning | Generalization 0 hits | Skip discovery |
303
+ | W004 | warning | Delegate parse failed | Use raw output |
304
+
305
+ </shared_appendix>
@@ -0,0 +1,256 @@
1
+ # Odyssey Shared Base
2
+
3
+ Shared by all Odyssey commands (debug, improve, planex, review-test-fix, ui).
4
+
5
+ <execution_discipline>
6
+
7
+ 1. **Phase auto-commit** — auto `git commit` after each phase
8
+ - Code changes + understanding.md → `git add` → `git commit -m "{command}({slug}): {phase} — {summary}"`
9
+ - session.json / evidence.ndjson are runtime state, excluded from commits
10
+
11
+ 2. **Confident edits only, but must attempt** — edit when confident; record decision only when human judgment truly needed
12
+ - Confident → edit + commit
13
+ - Needs decision → `evidence.ndjson {"phase":"decision","status":"pending"}`, no code change
14
+ - **Decision gate** — only these qualify: cross-module architecture tradeoffs needing human direction | business semantics ambiguity where fix may change intent | new dependency or breaking API required
15
+ - "Unsure how to fix", "Too large scope", "Pre-existing issue" are NOT valid decision reasons
16
+
17
+ 3. **Multi-CLI assist** — `maestro delegate` for cross-angle verification
18
+ - Different `--role` per phase (analyze / review / explore)
19
+ - All delegate calls `run_in_background: true`, wait for callback
20
+
21
+ 4. **Never abort for context exhaustion** — harness auto-compresses context; aborting due to "insufficient context" or "already ran N phases" is a discipline violation. Must complete through S_RECORD → END.
22
+
23
+ **Zero-residual:** Every finding must have an action (fix / issue / decision). "Report only" and "pre-existing skip" are forbidden.
24
+ </execution_discipline>
25
+
26
+ <shared_schemas>
27
+
28
+ ### session.json standard fields
29
+
30
+ ```json
31
+ {
32
+ "session_id": "{type}-odyssey-{YYYYMMDD-HHmmss}",
33
+ "current_state": "S_INTAKE",
34
+ "flags": { "skip_fix": false, "skip_generalize": false, "auto": false, "auto_confirm": false },
35
+ "phase_goals": [], "phase_goals_all_done": false,
36
+ "self_iteration_log": [],
37
+ "cross_phase_loops": 0, "max_loops": 5,
38
+ "created_at": "", "updated_at": ""
39
+ }
40
+ ```
41
+
42
+ Each command adds its own fields (e.g. `issue`, `target`, `requirement`).
43
+
44
+ ### evidence.ndjson base schema
45
+
46
+ ```json
47
+ {"ts":"","phase":"","type":"","source":"","content":"","note":""}
48
+ ```
49
+
50
+ Each command defines phase-specific extension fields (e.g. `hypothesis`, `severity`, `dimension`).
51
+
52
+ ### generalization_stats schema
53
+
54
+ ```json
55
+ {
56
+ "patterns_extracted": 0, "total_hits": 0,
57
+ "cross_layer_confirmed": 0, "regression_risks": 0,
58
+ "by_layer": {"syntax": 0, "semantic": 0, "structural": 0},
59
+ "deepening_triggered": false
60
+ }
61
+ ```
62
+
63
+ </shared_schemas>
64
+
65
+ <anti_stall>
66
+
67
+ ### progress_metrics fields
68
+
69
+ ```json
70
+ {
71
+ "progress_metrics": {
72
+ "phase_stats": {},
73
+ "stale_count": 0,
74
+ "last_productive_phase": "",
75
+ "convergence_trend": "unknown"
76
+ },
77
+ "directions_tried": []
78
+ }
79
+ ```
80
+
81
+ ### Progress Tracking
82
+
83
+ After each analytical phase:
84
+ 1. Count `new_findings` (deduplicated) and `repeated` (matching existing evidence)
85
+ 2. Write to `progress_metrics.phase_stats[state_name]`
86
+ 3. `new == 0` → `stale_count++`, `convergence_trend = "stalling"`
87
+ 4. `new > 0` → `stale_count = 0`, update `last_productive_phase`
88
+ 5. 2 consecutive phases with declining new → `convergence_trend = "diminishing"`
89
+
90
+ ### Direction Diversity
91
+
92
+ ```json
93
+ {
94
+ "phase": "S_DIAGNOSE", "round": 1,
95
+ "strategy_type": "scope_widen|perspective_shift|tool_switch|structural_pivot",
96
+ "strategy_desc": "expand search to utils/", "result": "2 new findings"
97
+ }
98
+ ```
99
+
100
+ **Dedup rule:** Check same-phase history before self-iteration → new strategy must differ in `strategy_type` or `strategy_desc` → all 4 types tried → force stale_count upgrade
101
+
102
+ ### Stall Escalation Ladder
103
+
104
+ | stale_count | Strategy |
105
+ |-------------|----------|
106
+ | 0 | Normal advance |
107
+ | 1 | **Shift perspective** — different CLI tool, reverse trace, manual read. Must differ from directions_tried |
108
+ | 2 | **Structural pivot** — redefine search dimensions, switch analysis framework, decompose sub-problems. Not parameter tuning |
109
+ | 3 | **Human escalation** — AskUserQuestion / `-y` auto INCONCLUSIVE and advance |
110
+
111
+ ### /loop Heartbeat (optional, `--heartbeat`)
112
+
113
+ Suggest `/loop 270s`. Each phase updates `session.json.updated_at`. >15 min without update → alert + stale_count. 2 consecutive no-update → suggest `-c` resume.
114
+ </anti_stall>
115
+
116
+ <self_iteration>
117
+
118
+ ### Quality Gate
119
+
120
+ | Dimension | Sufficient | Insufficient |
121
+ |-----------|-----------|-------------|
122
+ | Coverage | All known related files/modules analyzed | Missed targets discoverable via grep/git log |
123
+ | Depth | ≥80% findings have file:line evidence | Most findings lack specifics |
124
+ | Actionability | Each conclusion has concrete next action | "Consider reviewing" without action |
125
+
126
+ **Progress-aware iteration:**
127
+ - Phase complete → evaluate 3 dimensions + check `progress_metrics`
128
+ - Any insufficient AND `stale_count < 3` → re-enter with expansion strategy (must pass directions_tried dedup)
129
+ - Follow Stall Escalation Ladder for strategy selection
130
+
131
+ **Expansion strategies:**
132
+ - `scope_widen`: more directories, git log depth ×2, additional delegate angles
133
+ - `perspective_shift`: different CLI tool, reverse trace, manual reading
134
+ - `tool_switch`: switch to unused analysis tool
135
+ - `structural_pivot`: redefine problem framework, decompose sub-problems
136
+
137
+ **Exit:** all sufficient → advance | `stale_count >= 3` → log gaps, advance
138
+
139
+ **Log:** `evidence.ndjson {"phase":"self-iteration"}` + `session.json.self_iteration_log[]` + `directions_tried[]`
140
+ </self_iteration>
141
+
142
+ <shared_actions>
143
+
144
+ ### A_GENERALIZE
145
+
146
+ 3-layer pattern extraction → 4-agent concurrent scan → cross-layer dedup → iterative deepening.
147
+
148
+ **Pattern source:** specified by each command (root cause / audit findings / implementation patterns).
149
+
150
+ **3-layer extraction:**
151
+
152
+ | Layer | Method | Example |
153
+ |-------|--------|---------|
154
+ | Syntax | Regex → Grep | `eval(`, missing `await`, inline styles |
155
+ | Semantic | Agent understands anti-pattern → scan | Unhandled async errors, missing validation |
156
+ | Structural | File/module structure similarity | Same import structure, missing override |
157
+
158
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
159
+
160
+ **4-agent concurrent scan (single message):**
161
+
162
+ | Agent | Strategy | Scope |
163
+ |-------|----------|-------|
164
+ | Syntax grep | Grep regex | Full project |
165
+ | Semantic scan | Anti-pattern check | Related modules |
166
+ | Structural match | Structurally similar files | Full project |
167
+ | Historical grep | `git log -S` | Git history |
168
+
169
+ **Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
170
+
171
+ **Iterative deepening:** module ≥3 hits → targeted deep scan (max 1 round)
172
+
173
+ **Persist:** understanding.md generalization section + `session.json.generalization_stats`
174
+
175
+ Commit: `"...({slug}): GENERALIZE — generalization scan complete"`
176
+
177
+ ### A_DISCOVER
178
+
179
+ 1. **Triage** each hit ±10 lines context → classify `bug` / `risk` / `safe`
180
+ 2. **Route:**
181
+ - bug + fix_template applicable → immediate fix → back to S_FIX
182
+ - bug + needs cross-module decision or no fix_template → create issue (with fix suggestion + impact analysis)
183
+ - risk → assess if guard can be added directly; yes → fix; no → create issue
184
+ - safe → skip
185
+ Normal: AskUserQuestion | `-y`: auto-fix bugs with fix_template, create issue for rest
186
+ 3. **Cross-phase loops:** `cross_phase_loops++`. `loops >= max_loops` → must log per-item reasons (blanket "pre-existing" forbidden)
187
+ 4. Append evidence + update understanding.md
188
+
189
+ Commit: `"...({slug}): DISCOVER — discovery triage complete"`
190
+
191
+ ### A_RECORD
192
+
193
+ 1. Finalize understanding.md final section — learnings structured by each command's category table
194
+ 2. Mark record goal done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count)
195
+ 3. **Goal audit:** all `completion_confirmed` → `phase_goals_all_done = true`. Incomplete: Normal → AskUserQuestion | `-y` → auto accept
196
+ 4. `current_state = "COMPLETED"`, emit completion summary (format defined by each command)
197
+
198
+ Commit: `"...({slug}): RECORD — summary and knowledge persistence"`
199
+
200
+ </shared_actions>
201
+
202
+ <shared_appendix>
203
+
204
+ ### Goal Prompt
205
+
206
+ **Timing guard: display ONCE after INTAKE completes. Never re-display at RECORD.**
207
+
208
+ ```
209
+ {Command} Odyssey session created. Copy the /goal below to set termination criteria:
210
+
211
+ /goal Complete these goals:
212
+ {for each G in phase_goals where status != "skipped":}
213
+ - {G.id}: {G.goal} — done when: {G.done_when}
214
+ {end for}
215
+ {command-specific convergence rules}
216
+ Pending phase=decision items must use AskUserQuestion, never self-resolve.
217
+ ```
218
+
219
+ Continue execution after output, do not block.
220
+
221
+ ### `-y` generic rules
222
+
223
+ - Decision pending → best-effort continue, record `deferred`
224
+ - 3-strike escalation → auto INCONCLUSIVE
225
+ - Discovery routing → auto-fix bugs with fix_template, create issue for rest
226
+ - Record pending → skip, show deferred count
227
+ - Record goal audit → auto accept
228
+
229
+ `deferred` items shown in completion summary; recoverable via `-c`. Each command lists its own specific decision points.
230
+
231
+ ### Phase Goal Lifecycle
232
+
233
+ `pending → done (confirmed=true)` | `pending → skipped (confirmed=true)` | `pending → failed (confirmed=false)`
234
+
235
+ `phase_goals_all_done = true` only when ALL goals have `completion_confirmed == true`.
236
+
237
+ ### Pre-load (optional, missing does not block)
238
+
239
+ | Layer | Command |
240
+ |-------|---------|
241
+ | Codebase docs | Read `.workflow/codebase/ARCHITECTURE.md` |
242
+ | Wiki search | `maestro search "<keywords>" --json` (top 5) |
243
+ | Specs | `maestro load --type spec --category <cat>` |
244
+ | Role knowledge | `maestro search --category <cat>` → `maestro load --type knowhow --id <id>` |
245
+ | Prior sessions | `Glob(".workflow/scratch/*-{type}-odyssey-*")` |
246
+
247
+ ### Common Error Codes
248
+
249
+ | Code | Severity | Condition | Recovery |
250
+ |------|----------|-----------|----------|
251
+ | E003 | error | Resume but no session found | Start new |
252
+ | E004 | error | Delegate failed | Retry or proceed without |
253
+ | W003 | warning | Generalization 0 hits | Skip discovery |
254
+ | W004 | warning | Delegate parse failed | Use raw output |
255
+
256
+ </shared_appendix>
@@ -0,0 +1,109 @@
1
+ # Command Overlays — Format & Contract
2
+
3
+ ## File format
4
+
5
+ Each overlay is a JSON file at `~/.maestro/overlays/<name>.json`:
6
+
7
+ ```json
8
+ {
9
+ "name": "cli-verify-after-execute",
10
+ "description": "Run ccw cli quality review after /maestro-execute",
11
+ "targets": ["maestro-execute"],
12
+ "priority": 50,
13
+ "enabled": true,
14
+ "scope": "any",
15
+ "docs": ["docs/verify-protocol.md"],
16
+ "patches": [
17
+ {
18
+ "section": "execution",
19
+ "mode": "append",
20
+ "content": "## CLI Verification (overlay)\n\nAfter execution, run:\n\n```\nccw cli -p \"PURPOSE: Review just-executed changes for quality regressions\" --mode analysis --rule analysis-review-code-quality\n```\n"
21
+ },
22
+ {
23
+ "section": "required_reading",
24
+ "mode": "append",
25
+ "content": "@~/.maestro/overlays/docs/verify-protocol.md"
26
+ }
27
+ ]
28
+ }
29
+ ```
30
+
31
+ ### Top-level fields
32
+
33
+ | Field | Required | Notes |
34
+ |---|---|---|
35
+ | `name` | yes | Slug, matches `^[a-z0-9][a-z0-9-_]*$`. Filesystem-safe and unique across overlays. |
36
+ | `description` | no | Short human summary shown in `maestro overlay list`. |
37
+ | `targets` | yes | Array of command names without `.md` (e.g., `maestro-execute`). Missing/disabled targets are skipped with a log entry. |
38
+ | `priority` | no | Default 50. Lower runs earlier. Alphabetical tiebreak. |
39
+ | `enabled` | no | Default true. Set `false` to keep on disk but exclude from apply. |
40
+ | `scope` | no | `global` / `project` / `any`. v1 is effectively global-only. |
41
+ | `docs` | no | Relative paths under `~/.maestro/overlays/docs/` that this overlay references. Informational only. |
42
+ | `patches` | yes | Non-empty array of patch objects. |
43
+
44
+ ### Patch fields
45
+
46
+ | Field | Required | Notes |
47
+ |---|---|---|
48
+ | `section` | yes | One of `purpose`, `required_reading`, `deferred_reading`, `context`, `execution`, `error_codes`, `success_criteria`. For `new-section`, any slug. |
49
+ | `mode` | yes | `append` / `prepend` / `replace` / `new-section`. |
50
+ | `content` | yes | Raw markdown. Escaped `\n` inside JSON strings. No HTML-comment markers — the patcher adds its own. |
51
+ | `afterSection` | no | For `new-section` only. Section slug after which the new block is inserted. Omit to append at end of file. |
52
+
53
+ ## Apply semantics
54
+
55
+ On apply, each patch's `content` is wrapped in hashed markers:
56
+
57
+ ```
58
+ <!-- maestro-overlay:<name>#<idx> hash=<short> -->
59
+ ...content...
60
+ <!-- /maestro-overlay:<name>#<idx> -->
61
+ ```
62
+
63
+ - **Idempotent**: Re-applying with the same content produces byte-identical output — no mtime churn.
64
+ - **Drift-aware**: If the overlay's content changes, the marker block is replaced on next apply.
65
+ - **Surgical removal**: `maestro overlay remove <name>` strips only the marker blocks for that overlay; text outside markers is preserved.
66
+
67
+ ### Mode behavior
68
+
69
+ | Mode | Insertion point | Notes |
70
+ |---|---|---|
71
+ | `append` | Immediately before `</section>` | Most common. Adds a new step at the end of the section. |
72
+ | `prepend` | Immediately after `<section>` | Adds a gate/precondition. |
73
+ | `replace` | Between `<section>` and `</section>` | Destructive — overwrites the entire section body. Use sparingly. |
74
+ | `new-section` | After `afterSection`'s `</...>` (or end of file) | Creates a brand-new tagged section. |
75
+
76
+ ## Install integration
77
+
78
+ `maestro install` runs the following sequence:
79
+
80
+ 1. Copy pristine files (`.claude/commands/*` etc.) from the package to the target
81
+ 2. Restore `.md.disabled` state from the prior install
82
+ 3. **Apply overlays** — reads `~/.maestro/overlays/*.json`, applies each enabled one to the just-installed commands, writes `~/.maestro/manifests/overlays-<scope>.json`
83
+
84
+ ## CLI reference
85
+
86
+ ```bash
87
+ maestro overlay list # show overlays and applied state
88
+ maestro overlay apply # reapply to all known install scopes
89
+ maestro overlay add <file.json> # validate, install, apply
90
+ maestro overlay remove <name> # strip markers, delete overlay file
91
+ ```
92
+
93
+ ## Edge cases
94
+
95
+ - **Disabled targets** (`.md.disabled`) are skipped silently.
96
+ - **Missing targets** are skipped with a log entry — not an error.
97
+ - **Multiple overlays on the same section** are sorted by `priority` (asc), alphabetical tiebreak. Each gets its own marker block, stacked inside the section.
98
+ - **User edits outside markers** are preserved across reapply (inside-marker edits are overwritten — that's the contract).
99
+ - **Invalid overlay JSON** never applies — errors surface in `maestro overlay list` and `maestro overlay add`.
100
+ - **CRLF vs LF** is detected per-target and preserved on write.
101
+
102
+ ## Troubleshooting
103
+
104
+ | Symptom | Cause | Fix |
105
+ |---|---|---|
106
+ | `overlay load error` in `list` | Invalid JSON or schema | Fix the file at the reported path |
107
+ | Marker start found but no matching end | File was hand-edited mid-marker | Delete the stale block manually; re-run `maestro overlay apply` |
108
+ | Changes not visible in Claude Code | Claude Code caches loaded commands | Restart Claude Code after applying |
109
+ | Overlay reapplied endlessly | Hash drift because content contains a dynamic value | Make the `content` deterministic — no timestamps |