maestro-flow 0.5.45 → 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 (116) hide show
  1. package/.agents/agents/ralph-executor.md +51 -6
  2. package/.agents/skills/maestro-ralph-v2/SKILL.md +124 -61
  3. package/.agents/skills/odyssey-debug/SKILL.md +338 -253
  4. package/.agents/skills/odyssey-improve/SKILL.md +367 -281
  5. package/.agents/skills/odyssey-planex/SKILL.md +490 -420
  6. package/.agents/skills/odyssey-review-test-fix/SKILL.md +336 -251
  7. package/.agents/skills/odyssey-ui/SKILL.md +332 -247
  8. package/.agy/agents/ralph-executor.md +53 -6
  9. package/.agy/skills/maestro-ralph-v2/SKILL.md +123 -61
  10. package/.agy/skills/odyssey-debug/SKILL.md +338 -253
  11. package/.agy/skills/odyssey-improve/SKILL.md +367 -281
  12. package/.agy/skills/odyssey-planex/SKILL.md +490 -420
  13. package/.agy/skills/odyssey-review-test-fix/SKILL.md +336 -251
  14. package/.agy/skills/odyssey-ui/SKILL.md +332 -247
  15. package/.claude/agents/ralph-executor.md +51 -6
  16. package/.claude/commands/maestro-ralph-v2.md +124 -61
  17. package/.claude/commands/odyssey-debug.md +352 -267
  18. package/.claude/commands/odyssey-improve.md +381 -295
  19. package/.claude/commands/odyssey-planex.md +504 -434
  20. package/.claude/commands/odyssey-review-test-fix.md +350 -265
  21. package/.claude/commands/odyssey-ui.md +346 -261
  22. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +3 -3
  23. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  24. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
  25. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  26. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +6 -0
  27. package/dashboard/dist-server/src/graph/kg/db/queries.js +141 -19
  28. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  29. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  30. package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  31. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  32. package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  33. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  34. package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  35. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  36. package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  37. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -2
  38. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  39. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
  40. package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
  41. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
  42. package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
  43. package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
  44. package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
  45. package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
  46. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
  47. package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
  48. package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
  49. package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
  50. package/dist/src/agents/api-explore/agent-loop.js +6 -5
  51. package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
  52. package/dist/src/agents/api-explore/config.d.ts +56 -0
  53. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  54. package/dist/src/agents/api-explore/config.js +34 -0
  55. package/dist/src/agents/api-explore/config.js.map +1 -1
  56. package/dist/src/agents/api-explore/llm.d.ts +5 -1
  57. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  58. package/dist/src/agents/api-explore/llm.js +10 -8
  59. package/dist/src/agents/api-explore/llm.js.map +1 -1
  60. package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
  61. package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
  62. package/dist/src/agents/api-explore/moa-cache.js +50 -0
  63. package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
  64. package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
  65. package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
  66. package/dist/src/agents/api-explore/moa-loop.js +43 -0
  67. package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
  68. package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
  69. package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
  70. package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
  71. package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
  72. package/dist/src/agents/api-explore/runner.d.ts +3 -0
  73. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  74. package/dist/src/agents/api-explore/runner.js +24 -7
  75. package/dist/src/agents/api-explore/runner.js.map +1 -1
  76. package/dist/src/agents/api-explore/session.d.ts +15 -0
  77. package/dist/src/agents/api-explore/session.d.ts.map +1 -1
  78. package/dist/src/agents/api-explore/session.js.map +1 -1
  79. package/dist/src/cli.js +1 -0
  80. package/dist/src/cli.js.map +1 -1
  81. package/dist/src/commands/explore.d.ts.map +1 -1
  82. package/dist/src/commands/explore.js +16 -1
  83. package/dist/src/commands/explore.js.map +1 -1
  84. package/dist/src/commands/moa.d.ts +3 -0
  85. package/dist/src/commands/moa.d.ts.map +1 -0
  86. package/dist/src/commands/moa.js +202 -0
  87. package/dist/src/commands/moa.js.map +1 -0
  88. package/dist/src/graph/kg/db/queries.d.ts +6 -0
  89. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  90. package/dist/src/graph/kg/db/queries.js +141 -19
  91. package/dist/src/graph/kg/db/queries.js.map +1 -1
  92. package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
  93. package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
  94. package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
  95. package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
  96. package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
  97. package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
  98. package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
  99. package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
  100. package/dist/src/graph/kg/extraction/orchestrator.js +2 -2
  101. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  102. package/dist/src/graph/kg/surface/hook-injector.js +1 -1
  103. package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
  104. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  105. package/dist/src/hooks/keyword-spec-injector.js +35 -0
  106. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  107. package/dist/src/hooks/spec-analytics.d.ts +1 -0
  108. package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
  109. package/dist/src/hooks/spec-analytics.js.map +1 -1
  110. package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
  111. package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
  112. package/dist/src/hooks/wiki-search-bridge.js +71 -0
  113. package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
  114. package/dist/src/utils/update-notices.js +12 -0
  115. package/dist/src/utils/update-notices.js.map +1 -1
  116. package/package.json +1 -1
@@ -14,250 +14,335 @@ allowed-tools:
14
14
  - view_file
15
15
  - write_to_file
16
16
  ---
17
- <base>@~/.maestro/workflows/odyssey-base.md</base>
18
-
19
- <purpose>
20
- survey → 6-dimension audit → divergent exploration → fix → verify → generalize → discover → persist.
21
- Exhaustive iteration until all findings addressed or deferred.
22
- </purpose>
23
-
24
- <boundary>
25
- **In scope:** Target component/page visual experience optimization — audit 6 dimensions, divergent exploration, fix, generalize to sibling components.
26
- **Out of scope:** Backend/data/API → `/odyssey-planex` | Deep bug investigation → `/odyssey-debug` | Code quality review → `/odyssey-review-test-fix`
27
-
28
- **Decision gate** — ONLY these qualify as decisions:
29
- - Brand/style direction requiring human creative judgment
30
- - Layout restructuring that changes user flow significantly
31
- - Requires new design tokens or breaking component API
32
- </boundary>
33
-
34
- <context>
35
- $ARGUMENTS
36
-
37
- **Target resolution:** Component path → audit component | Page/route → audit page | `staged`/`HEAD` → diff UI changes | Feature area → resolve to components/pages
38
-
39
- **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` | `--skip-fix` audit+diverge only | `--skip-generalize` skip generalize+discover | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
40
-
41
- **Session**: `.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`
42
- **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
43
-
44
- **session.json — ui-specific fields:**
45
- ```json
46
- { "target": "", "dimensions": [],
47
- "audit_result": { "dimensions_audited": 0, "finding_count": 0, "severity_distribution": {} },
48
- "diverge_result": { "improvements_proposed": 0, "creative_ideas": 0 },
49
- "patterns": [], "confirmation": null, "generalization_stats": null }
50
- ```
51
-
52
- **evidence.ndjson phases:** `survey|audit|diverge|fix|discovery|decision|self-iteration`
53
-
54
- **phase_goals[]:**
55
-
56
- | ID | Goal | Phase | skip_when |
57
- |----|------|-------|-----------|
58
- | G1 | Survey completed | S_SURVEY | — |
59
- | G2 | Audit completed | S_AUDIT | — |
60
- | G3 | Divergent exploration done | S_DIVERGE | — |
61
- | G4 | Zero remaining: all findings/ideas fixed and verified | S_VERIFY | skip_fix |
62
- | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
63
- | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
64
- | G7 | Learnings persisted | S_RECORD | — |
65
-
66
- **understanding.md — 8 sections:**
67
- 1. Target & Design Context ← S_INTAKE | 2. Survey ← S_SURVEY | 3. Audit ← S_AUDIT
68
- 4. Diverge ← S_DIVERGE | 5. Verify ← S_VERIFY | 6. Generalize ← S_GENERALIZE
69
- 7. Discover ← S_DISCOVER | 8. Learnings ← S_RECORD
70
-
71
- **Knowledge Persistence categories (section 8):**
72
-
73
- | Category | Content | Follow-up |
74
- |----------|---------|-----------|
75
- | Design pattern | Component pattern + applicable scenarios + token references | `/spec-add ui` |
76
- | Interaction spec | State definitions + transition rules + feedback patterns | `/spec-add ui` |
77
- | Accessibility rule | WCAG requirement + implementation approach | `/spec-add ui` |
78
- | Reusable generalization pattern | Pattern signature + application scope | `/spec-add coding` |
79
- </context>
80
-
81
- <invariants>
82
- 1-5 in base. UI-specific:
83
- 6. **Browser is truth** — verify in real rendering, not just code review
84
- 7. **Diverge before converge** — explore creatively first, then implement methodically
85
- </invariants>
86
-
87
- <self_iteration>
88
- Applies to: **S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE**. Logic in base.
89
- </self_iteration>
90
-
91
- <state_machine>
92
-
93
- <states>
94
- S_INTAKE → S_SURVEY → S_AUDIT → S_DIVERGE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
95
- </states>
96
-
97
- <transitions>
98
- S_INTAKE → S_INTAKE : -c + session found → A_RESUME
99
- S_INTAKE → S_SURVEY : target resolvedA_INTAKE
100
- S_INTAKE → S_INTAKE : no target → ask_question
101
-
102
- S_SURVEY → S_AUDIT : complete
103
- S_AUDIT S_DIVERGE : complete
104
-
105
- S_DIVERGE → S_FIX : !skip_fix AND actionable findings/ideas
106
- S_DIVERGE → S_GENERALIZE : (skip_fix OR no actionable) AND !skip_generalize
107
- S_DIVERGE → S_RECORD : (skip_fix OR no actionable) AND skip_generalize
108
-
109
- S_FIX → S_VERIFY : fix implemented
110
- S_VERIFY S_GENERALIZE : verified, !skip_generalize
111
- S_VERIFY → S_RECORD : verified, skip_generalize
112
- S_VERIFY → S_FIX : needs_rework
113
-
114
- S_GENERALIZE → S_DISCOVER : similar code found
115
- S_GENERALIZE → S_RECORD : no similar code
116
-
117
- S_DISCOVER → S_AUDIT : new component to audit → cross_phase_loops++
118
- S_DISCOVER → S_FIX : fixable sibling, !skip_fix → cross_phase_loops++
119
- S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops log per-item reasons
120
-
121
- S_RECORD → END : complete
122
- </transitions>
123
-
124
- <actions>
125
-
126
- ### A_INTAKE
127
- 1. Parse arguments: target, flags, `--dimensions` subset
128
- 2. Generate slug, create SESSION_DIR
129
- 3. `maestro search` + Glob prior sessions + ARCHITECTURE.md + spec load ui/coding
130
- 4. Derive `phase_goals[]` from flags
131
- 5. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
132
-
133
- Commit: `"odyssey-ui({slug}): INTAKE — parse target and load context"`
134
-
135
- ### A_RESUME
136
- Glob latest session → read `session.json` → jump to `current_state`.
137
-
138
- ### A_SURVEY
139
- 1. **Design system inventory**: Scan for design tokens, CSS variables, theme imports
140
- 2. **Current state analysis**: Styling patterns, layout strategy, component hierarchy
141
- 3. **CLI-assisted**: `maestro delegate --role analyze --mode analysis` survey tokens, spacing, typography, hierarchy, consistency
142
- 4. Append evidence phase=survey. Update section 2. Mark G1.
143
-
144
- Commit: `"odyssey-ui({slug}): SURVEY — design token inventory"`
145
-
146
- ### A_AUDIT
147
- Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset):
148
-
149
- | Dimension | Focus |
150
- |-----------|-------|
151
- | visual_hierarchy | Spacing, typography scale, color contrast, alignment, whitespace, visual weight |
152
- | interaction_states | Hover, focus, active, disabled, loading, error, empty, selected states |
153
- | accessibility | WCAG AA contrast, focus management, aria labels, keyboard nav, screen reader |
154
- | responsiveness | Breakpoints, overflow, touch targets, fluid typography, container queries |
155
- | micro_interactions | Transitions, animations, feedback indicators, loading states, progress |
156
- | edge_cases | Long text truncation, empty data, error states, extreme values, i18n, RTL |
157
-
158
- Each returns `[{title, severity, file, line, description, suggestion, dimension}]`.
159
- Merge evidence phase=audit. Write `audit_result`. Update section 3 with severity matrix. Mark G2.
160
-
161
- Commit: `"odyssey-ui({slug}): AUDIT — 6-dimension review"`
162
-
163
- ### A_DIVERGE
164
- Goes beyond defect fixing — "what would make this delightful?"
165
-
166
- **Step 1 — 2 parallel Agents:**
167
- - **Polish Agent**: Shadows, borders, transitions, hover states, feedback, empty states, skeleton loading, scroll behavior
168
- - **Delight Agent**: Motion design, progressive disclosure, smart defaults, contextual hints, celebratory feedback, personality in copy
169
-
170
- Each returns `[{idea, category (polish|delight), impact, effort, description, inspiration}]`
171
-
172
- **Step 2 — CLI-assisted**: `maestro delegate --role analyze --mode analysis` — polish opportunities, micro-interactions, visual rhythm, delight moments
173
-
174
- **Step 3 — Consolidate**: Merge audit findings + divergent ideas → prioritized list (severity x impact x effort).
175
- Append evidence phase=diverge. Update section 4. Mark G3.
176
-
177
- Commit: `"odyssey-ui({slug}): DIVERGE — creative exploration"`
178
-
179
- ### A_FIX
180
- Skip if `--skip-fix`.
181
- 1. **Exhaustive fix**: ALL findings/ideas by priority tier (critical → high → medium → low + high-impact ideas). After each tier, re-review — new findings append.
182
- 2. Each fix → evidence phase=fix
183
- 3. Normal: ask_question per-fix | `-y`: auto-proceed, record `deferred`
184
-
185
- Commit: `"odyssey-ui({slug}): FIX — implement improvements"`
186
-
187
- ### A_VERIFY
188
- 1. Run tests (lint, unit, visual regression)
189
- 2. `maestro delegate --role review --mode analysis` — visual correctness, interaction states, accessibility, responsive
190
- 3. `needs_rework` S_FIX. `verified` mark G4. Update section 5, write `confirmation`.
191
-
192
- Commit: `"odyssey-ui({slug}): VERIFY — visual verification"`
193
-
194
- ### A_GENERALIZE, A_DISCOVER, A_RECORD
195
- Base shared_actions. UI overrides:
196
- - **A_GENERALIZE** pattern source: audit findings + diverge ideas (severity >= medium OR impact = high)
197
- - **A_RECORD** learnings per Knowledge Persistence table
198
-
199
- **Completion summary:**
200
- ```
201
- --- UI ODYSSEY COMPLETE ---
202
- Target: {target} | Dimensions: {dimensions_audited}
203
- Findings: {C}C {H}H {M}M {L}L | Diverge: {improvements} polish + {creative} delight
204
- Fix: {fixed_count} applied, verified={yes|skipped}
205
- Patterns: {extracted} ({by_layer})
206
- Scan hits: {total} ({cross_layer} cross-layer)
207
- Issues: {N} created
208
- Decisions: {N} resolved, {M} pending, {K} deferred
209
- Learnings: {N} persisted
210
- Self-iter: {N} rounds
211
- Goals: {done}/{total} ({skipped} skipped)
212
- ---
213
- ```
214
-
215
- </actions>
216
-
217
- <appendix>
218
-
219
- ### `-y` ui-specific points
220
-
221
- | Decision Point | Normal | `-y` |
222
- |---------------|--------|------|
223
- | A_FIX improvement confirmation | ask_question | auto-proceed, deferred |
224
-
225
- ### Goal Prompt convergence rules
226
-
227
- ```
228
- Stop when audit + diverge findings all addressed (fix/issue/decision),
229
- phase_goals_all_done=true. Fix by impact x severity per tier.
230
- Re-review after each tier — new findings append and continue.
231
- Pending decisions must ask_question no self-resolve.
232
- ```
233
-
234
- </appendix>
235
-
236
- </state_machine>
237
-
238
- <error_codes>
239
- | Code | Severity | Condition | Recovery |
240
- |------|----------|-----------|----------|
241
- | E001 | error | No target specified | Provide target |
242
- | E002 | error | Target path not found | Check path |
243
- | W001 | warning | No design system detected | Proceed with defaults |
244
- | W002 | warning | Some dimension agents failed | Partial coverage |
245
- </error_codes>
246
-
247
- <success_criteria>
248
- - [ ] 6-dimension audit with severity matrix + divergent exploration (polish + delight)
249
- - [ ] Improvements implemented and verified (unless --skip-fix)
250
- - [ ] Multi-layer generalization + discoveries classified (unless --skip-generalize)
251
- - [ ] Every unfixed finding has individual classification and reason
252
- - [ ] understanding.md section 8 finalized; phase_goals G1-G7 tracked; `-y` no blocking prompts
253
- </success_criteria>
254
-
255
- <next_step_routing>
256
- | Condition | Next |
257
- |-----------|------|
258
- | Finding needs deeper debug | `/odyssey-debug "<finding>"` |
259
- | Issues from discoveries | `/manage-issue list --source ui-odyssey` |
260
- | Design pattern to document | `/spec-add ui "..."` |
261
- | Full review of changes | `/odyssey-review-test-fix <changed-files>` |
262
- | Sibling components to polish | `/odyssey-ui "<sibling>"` |
263
- </next_step_routing>
17
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
18
+
19
+ <purpose>
20
+ survey → 6-dimension audit → divergent exploration → fix → verify → generalize → discover → persist.
21
+ Exhaustive iteration until all findings addressed or deferred.
22
+ </purpose>
23
+
24
+ <boundary>
25
+ **In scope:** Target component/page visual experience optimization — audit 6 dimensions, divergent exploration, fix, generalize to sibling components.
26
+ **Out of scope:** Backend/data/API → `/odyssey-planex` | Deep bug investigation → `/odyssey-debug` | Code quality review → `/odyssey-review-test-fix`
27
+
28
+ **Decision gate** — ONLY these qualify as decisions:
29
+ - Brand/style direction requiring human creative judgment
30
+ - Layout restructuring that changes user flow significantly
31
+ - Requires new design tokens or breaking component API
32
+ </boundary>
33
+
34
+ <context>
35
+ $ARGUMENTS
36
+
37
+ **Target resolution:** Component path → audit component | Page/route → audit page | `staged`/`HEAD` → diff UI changes | Feature area → resolve to components/pages
38
+
39
+ **Flags:** `--dimensions <list>` dimension subset | `--fix-threshold <severity>` | `--skip-fix` audit+diverge only | `--skip-generalize` skip generalize+discover | `--auto` no delegate confirmation | `-y` auto-confirm | `-c` resume | `--heartbeat` /loop heartbeat
40
+
41
+ **Session**: `.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`
42
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
43
+
44
+ **session.json — ui-specific fields:**
45
+ ```json
46
+ { "target": "", "dimensions": [],
47
+ "audit_result": { "dimensions_audited": 0, "finding_count": 0, "severity_distribution": {} },
48
+ "diverge_result": { "improvements_proposed": 0, "creative_ideas": 0 },
49
+ "patterns": [], "confirmation": null, "generalization_stats": null }
50
+ ```
51
+
52
+ **evidence.ndjson phases:** `survey|audit|diverge|fix|discovery|decision|self-iteration`
53
+
54
+ **phase_goals[]:**
55
+
56
+ | ID | Goal | Phase | skip_when |
57
+ |----|------|-------|-----------|
58
+ | G1 | Survey completed | S_SURVEY | — |
59
+ | G2 | Audit completed | S_AUDIT | — |
60
+ | G3 | Divergent exploration done | S_DIVERGE | — |
61
+ | G4 | Zero remaining: all findings/ideas fixed and verified | S_VERIFY | skip_fix |
62
+ | G5 | Pattern generalized | S_GENERALIZE | skip_generalize |
63
+ | G6 | Discoveries triaged | S_DISCOVER | skip_generalize |
64
+ | G7 | Learnings persisted | S_RECORD | — |
65
+
66
+ **understanding.md — 8 sections:**
67
+ 1. Target & Design Context ← S_INTAKE | 2. Survey ← S_SURVEY | 3. Audit ← S_AUDIT
68
+ 4. Diverge ← S_DIVERGE | 5. Verify ← S_VERIFY | 6. Generalize ← S_GENERALIZE
69
+ 7. Discover ← S_DISCOVER | 8. Learnings ← S_RECORD
70
+
71
+ **Knowledge Persistence categories (section 8):**
72
+
73
+ | Category | Content | Follow-up |
74
+ |----------|---------|-----------|
75
+ | Design pattern | Component pattern + applicable scenarios + token references | `/spec-add ui` |
76
+ | Interaction spec | State definitions + transition rules + feedback patterns | `/spec-add ui` |
77
+ | Accessibility rule | WCAG requirement + implementation approach | `/spec-add ui` |
78
+ | Reusable generalization pattern | Pattern signature + application scope | `/spec-add coding` |
79
+ </context>
80
+
81
+ <invariants>
82
+ 1-5 in base. UI-specific:
83
+ 6. **Browser is truth** — verify in real rendering, not just code review
84
+ 7. **Diverge before converge** — explore creatively first, then implement methodically
85
+ 8. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "All verified" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
86
+ </invariants>
87
+
88
+ <self_iteration>
89
+ Applies to: **S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE**. Logic in base.
90
+ </self_iteration>
91
+
92
+ <state_machine>
93
+
94
+ <states>
95
+ S_INTAKE → S_SURVEY → S_AUDIT → S_DIVERGE → S_FIX → S_VERIFY → S_GENERALIZE → S_DISCOVER → S_RECORD → END
96
+ </states>
97
+
98
+ <transitions>
99
+ S_INTAKE → S_INTAKE : -c + session found A_RESUME
100
+ S_INTAKE → S_SURVEY : target resolved A_INTAKE
101
+ S_INTAKE → S_INTAKE : no target → ask_question
102
+
103
+ S_SURVEY S_AUDIT : complete
104
+ S_AUDIT → S_DIVERGE : complete
105
+
106
+ S_DIVERGE → S_FIX : !skip_fix AND actionable findings/ideas
107
+ S_DIVERGE → S_GENERALIZE : (skip_fix OR no actionable) AND !skip_generalize
108
+ S_DIVERGE → S_RECORD : (skip_fix OR no actionable) AND skip_generalize
109
+
110
+ S_FIX S_VERIFY : fix implemented
111
+ S_VERIFY → S_GENERALIZE : verified, !skip_generalize
112
+ S_VERIFY → S_RECORD : verified, skip_generalize
113
+ S_VERIFY → S_FIX : needs_rework
114
+
115
+ S_GENERALIZE → S_DISCOVER : similar code found
116
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
117
+
118
+ S_DISCOVER → S_AUDIT : new component to audit → cross_phase_loops++
119
+ S_DISCOVER → S_FIX : fixable sibling, !skip_fixcross_phase_loops++
120
+ S_DISCOVER → S_RECORD : remaining_actionable == 0 OR loops >= max_loops → log per-item reasons
121
+
122
+ S_RECORD → END : complete
123
+ </transitions>
124
+
125
+ <actions>
126
+
127
+ ### A_INTAKE
128
+ 1. Parse arguments: target, flags, `--dimensions` subset
129
+ 2. Generate slug, create SESSION_DIR
130
+ 3. `maestro search` + Glob prior sessions + ARCHITECTURE.md + spec load ui/coding
131
+ 4. Derive `phase_goals[]` from flags
132
+ 5. Write `session.json` + `understanding.md` section 1, emit Goal Prompt
133
+
134
+ Commit: `"odyssey-ui({slug}): INTAKE — parse target and load context"`
135
+
136
+ ### A_RESUME
137
+ Glob latest session → read `session.json` → jump to `current_state`.
138
+
139
+ ### A_SURVEY
140
+ 1. **Design system inventory**: Scan for design tokens, CSS variables, theme imports
141
+ 2. **Current state analysis**: Styling patterns, layout strategy, component hierarchy
142
+ 3. **CLI-assisted**: `maestro delegate --role analyze --mode analysis` — survey tokens, spacing, typography, hierarchy, consistency
143
+ 4. Append evidence phase=survey. Update section 2. Mark G1.
144
+
145
+ Commit: `"odyssey-ui({slug}): SURVEY — design token inventory"`
146
+
147
+ ### A_AUDIT
148
+ Spawn 6 parallel Agents (one per dimension, or `--dimensions` subset):
149
+
150
+ | Dimension | Focus |
151
+ |-----------|-------|
152
+ | visual_hierarchy | Spacing, typography scale, color contrast, alignment, whitespace, visual weight |
153
+ | interaction_states | Hover, focus, active, disabled, loading, error, empty, selected states |
154
+ | accessibility | WCAG AA contrast, focus management, aria labels, keyboard nav, screen reader |
155
+ | responsiveness | Breakpoints, overflow, touch targets, fluid typography, container queries |
156
+ | micro_interactions | Transitions, animations, feedback indicators, loading states, progress |
157
+ | edge_cases | Long text truncation, empty data, error states, extreme values, i18n, RTL |
158
+
159
+ Each returns `[{title, severity, file, line, description, suggestion, dimension}]`.
160
+ Merge → evidence phase=audit. Write `audit_result`. Update section 3 with severity matrix. Mark G2.
161
+
162
+ Commit: `"odyssey-ui({slug}): AUDIT — 6-dimension review"`
163
+
164
+ ### A_DIVERGE
165
+ Goes beyond defect fixing — "what would make this delightful?"
166
+
167
+ **Step 1 2 parallel Agents:**
168
+ - **Polish Agent**: Shadows, borders, transitions, hover states, feedback, empty states, skeleton loading, scroll behavior
169
+ - **Delight Agent**: Motion design, progressive disclosure, smart defaults, contextual hints, celebratory feedback, personality in copy
170
+
171
+ Each returns `[{idea, category (polish|delight), impact, effort, description, inspiration}]`
172
+
173
+ **Step 2 — CLI-assisted**: `maestro delegate --role analyze --mode analysis` — polish opportunities, micro-interactions, visual rhythm, delight moments
174
+
175
+ **Step 3 Consolidate**: Merge audit findings + divergent ideas → prioritized list (severity x impact x effort).
176
+ Append evidence phase=diverge. Update section 4. Mark G3.
177
+
178
+ Commit: `"odyssey-ui({slug}): DIVERGE — creative exploration"`
179
+
180
+ ### A_FIX
181
+ Skip if `--skip-fix`.
182
+ 1. **Exhaustive fix**: ALL findings/ideas by priority tier (critical high → medium → low + high-impact ideas). After each tier, re-review — new findings append.
183
+ 2. Each fix evidence phase=fix
184
+ 3. Normal: ask_question per-fix | `-y`: auto-proceed, record `deferred`
185
+
186
+ Commit: `"odyssey-ui({slug}): FIX — implement improvements"`
187
+
188
+ ### A_VERIFY
189
+ 1. Run tests (lint, unit, visual regression)
190
+ 2. `maestro delegate --role review --mode analysis` visual correctness, interaction states, accessibility, responsive
191
+ 3. `needs_rework` → S_FIX. `verified` → mark G4. Update section 5, write `confirmation`.
192
+
193
+ Commit: `"odyssey-ui({slug}): VERIFY — visual verification"`
194
+
195
+ ### A_GENERALIZE
196
+
197
+ **MANDATORY — executes unless `skip_generalize == true`. Prior-phase convergence, "all verified," or context pressure are NOT valid skip reasons.**
198
+
199
+ Pattern source: audit findings + diverge ideas (severity >= medium OR impact = high).
200
+
201
+ **Step 1 — 3-layer pattern extraction** from UI findings and creative improvements:
202
+
203
+ | Layer | Method | Targets |
204
+ |-------|--------|---------|
205
+ | Syntax | Build regex from fix diffs → Grep | Hardcoded px values, missing aria attributes, inline color values, raw z-index |
206
+ | Semantic | Understand UI anti-pattern → Agent scan | Inconsistent spacing scale, missing hover/focus states, keyboard nav gaps, contrast violations |
207
+ | Structural | Find components with same layout/state shape | Sibling components with same template, parallel page layouts, shared form patterns |
208
+
209
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
210
+
211
+ **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.
212
+
213
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
214
+
215
+ | Agent | Strategy | Scope |
216
+ |-------|----------|-------|
217
+ | Syntax grep | Grep regex from pattern signatures | Full project |
218
+ | Semantic scan | UI anti-pattern check (states, a11y, spacing) | Related components |
219
+ | Structural match | Find structurally similar components/pages | Full project |
220
+ | Historical grep | `git log -S` for pattern signatures | Git history |
221
+
222
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
223
+
224
+ **Step 4 — Iterative deepening:** Component with ≥3 hits → targeted deep scan (max 1 round).
225
+
226
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
227
+ ```json
228
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
229
+ ```
230
+
231
+ **Transition guard:** `S_GENERALIZE S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G5 done.
232
+
233
+ Commit: `"odyssey-ui({slug}): GENERALIZE — pattern scan complete"`
234
+
235
+ ### A_DISCOVER
236
+
237
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
238
+
239
+ 1. **Triage** each hit with ±10 lines context → classify:
240
+ - `bug` — confirmed UI defect in sibling component (missing state, broken a11y, inconsistent token)
241
+ - `risk` potential visual/UX degradation
242
+ - `safe` false positive (must log individual reason blanket "pre-existing" forbidden)
243
+
244
+ 2. **Route:**
245
+
246
+ | Classification | Action |
247
+ |---------------|--------|
248
+ | new component needing audit | Route to S_AUDIT, `cross_phase_loops++` |
249
+ | fixable sibling (same pattern) | Immediate fix → back to S_FIX, `cross_phase_loops++` |
250
+ | risk + guard addable | Fix directly |
251
+ | risk + design decision needed | Create issue |
252
+ | safe | Skip with logged per-item reason |
253
+
254
+ Normal: ask_question per hit | `-y`: auto-fix with template, create issue for rest
255
+
256
+ 3. **Cross-phase loops:** `loops >= max_loops` → must log per-item reasons, advance to S_RECORD.
257
+
258
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G6 done.
259
+
260
+ Commit: `"odyssey-ui({slug}): DISCOVER sibling triage complete"`
261
+
262
+ ### A_RECORD
263
+
264
+ 1. Finalize understanding.md section 8 — learnings by Knowledge Persistence categories:
265
+ - Design pattern: component pattern + applicable scenarios + token references → `/spec-add ui`
266
+ - Interaction spec: state definitions + transition rules + feedback patterns → `/spec-add ui`
267
+ - Accessibility rule: WCAG requirement + implementation approach → `/spec-add ui`
268
+ - Reusable generalization pattern: signature + application scope → `/spec-add coding`
269
+
270
+ 2. Mark G7 done. Pending decisions: Normal → ask_question | `-y` → skip (show deferred count).
271
+
272
+ 3. **Goal audit (hardened):**
273
+ - `done` → confirmed
274
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
275
+ - **Hard rule:** G5 and G6 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: ask_question | `-y`: record `failed`)
276
+ - `phase_goals_all_done = true` only when all goals pass this audit
277
+
278
+ 4. `current_state = "COMPLETED"`, emit completion summary.
279
+
280
+ **Completion summary:**
281
+ ```
282
+ --- UI ODYSSEY COMPLETE ---
283
+ Target: {target} | Dimensions: {dimensions_audited}
284
+ Findings: {C}C {H}H {M}M {L}L | Diverge: {improvements} polish + {creative} delight
285
+ Fix: {fixed_count} applied, verified={yes|skipped}
286
+ Patterns: {extracted} ({by_layer})
287
+ Scan hits: {total} ({cross_layer} cross-layer)
288
+ Issues: {N} created
289
+ Decisions: {N} resolved, {M} pending, {K} deferred
290
+ Learnings: {N} persisted
291
+ Self-iter: {N} rounds
292
+ Goals: {done}/{total} ({skipped} skipped)
293
+ ---
294
+ ```
295
+
296
+ Commit: `"odyssey-ui({slug}): RECORD — summary and knowledge persistence"`
297
+
298
+ </actions>
299
+
300
+ <appendix>
301
+
302
+ ### `-y` ui-specific points
303
+
304
+ | Decision Point | Normal | `-y` |
305
+ |---------------|--------|------|
306
+ | A_FIX improvement confirmation | ask_question | auto-proceed, deferred |
307
+ | A_DISCOVER hit routing | ask_question | auto-fix with template, create issue for rest |
308
+
309
+ ### Goal Prompt convergence rules
310
+
311
+ ```
312
+ Stop when audit + diverge findings all addressed (fix/issue/decision),
313
+ phase_goals_all_done=true. Fix by impact x severity per tier.
314
+ Re-review after each tier — new findings append and continue.
315
+ Pending decisions must ask_question — no self-resolve.
316
+ ```
317
+
318
+ </appendix>
319
+
320
+ </state_machine>
321
+
322
+ <error_codes>
323
+ | Code | Severity | Condition | Recovery |
324
+ |------|----------|-----------|----------|
325
+ | E001 | error | No target specified | Provide target |
326
+ | E002 | error | Target path not found | Check path |
327
+ | W001 | warning | No design system detected | Proceed with defaults |
328
+ | W002 | warning | Some dimension agents failed | Partial coverage |
329
+ | W003 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
330
+ </error_codes>
331
+
332
+ <success_criteria>
333
+ - [ ] 6-dimension audit with severity matrix + divergent exploration (polish + delight)
334
+ - [ ] Improvements implemented and verified (unless --skip-fix)
335
+ - [ ] Multi-layer generalization + discoveries classified (unless --skip-generalize)
336
+ - [ ] Every unfixed finding has individual classification and reason
337
+ - [ ] understanding.md section 8 finalized; phase_goals G1-G7 tracked; `-y` no blocking prompts
338
+ </success_criteria>
339
+
340
+ <next_step_routing>
341
+ | Condition | Next |
342
+ |-----------|------|
343
+ | Finding needs deeper debug | `/odyssey-debug "<finding>"` |
344
+ | Issues from discoveries | `/manage-issue list --source ui-odyssey` |
345
+ | Design pattern to document | `/spec-add ui "..."` |
346
+ | Full review of changes | `/odyssey-review-test-fix <changed-files>` |
347
+ | Sibling components to polish | `/odyssey-ui "<sibling>"` |
348
+ </next_step_routing>