mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-24 14:47:23 +00:00
Compare commits
105
Commits
v0.25.2
...
impeccable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab5e1990b5 | ||
|
|
f9d5cbd104 | ||
|
|
61b5c71097 | ||
|
|
9f7cb81b45 | ||
|
|
d5d6585517 | ||
|
|
50b694aa08 | ||
|
|
717693e01f | ||
|
|
a0833c113c | ||
|
|
e74d2e0fc3 | ||
|
|
5b642010d4 | ||
|
|
5078d933d5 | ||
|
|
6cf511e7e5 | ||
|
|
ba11394d0f | ||
|
|
37eb23fc36 | ||
|
|
4544486221 | ||
|
|
17bd3ea9ed | ||
|
|
ad5344b309 | ||
|
|
8d95e170f6 | ||
|
|
565ca33345 | ||
|
|
e2d52d9e3b | ||
|
|
f3b74998f1 | ||
|
|
ce15e706b8 | ||
|
|
bc61081acc | ||
|
|
16f7327b7a | ||
|
|
2e9f931797 | ||
|
|
41378f720b | ||
|
|
c87a28f3ba | ||
|
|
df18749220 | ||
|
|
b6702cd4b5 | ||
|
|
fc5de2bbc7 | ||
|
|
cf82feca06 | ||
|
|
b8bbc52803 | ||
|
|
a36c2e4629 | ||
|
|
d15cebdc95 | ||
|
|
d296b59a9e | ||
|
|
d2aaed0f9f | ||
|
|
eb50e9b6f6 | ||
|
|
1e24ca076a | ||
|
|
b19835427b | ||
|
|
6ee0fc8115 | ||
|
|
6211e34050 | ||
|
|
2132674768 | ||
|
|
b4c015ef75 | ||
|
|
5d22a53c8b | ||
|
|
f4268f3111 | ||
|
|
71fd9c1531 | ||
|
|
53184a6bca | ||
|
|
d97cd45b22 | ||
|
|
5edab77209 | ||
|
|
a1d0213f92 | ||
|
|
0b75a2f70d | ||
|
|
0090746b89 | ||
|
|
be762dbc22 | ||
|
|
403e2275dc | ||
|
|
9ee1c96477 | ||
|
|
b71a3830ec | ||
|
|
f50ee1131e | ||
|
|
6a65376784 | ||
|
|
44d04a2b41 | ||
|
|
0f802e65c6 | ||
|
|
01d702c745 | ||
|
|
7823b68bdd | ||
|
|
e1f3fc36c8 | ||
|
|
d68599896d | ||
|
|
d18b67d80f | ||
|
|
8642ecfc5c | ||
|
|
c37e94b5f8 | ||
|
|
4e33f6948f | ||
|
|
743ff5e061 | ||
|
|
ec8bbb2f86 | ||
|
|
e75e2bea0c | ||
|
|
dd5aa2ad53 | ||
|
|
aced0f3f81 | ||
|
|
a886518cad | ||
|
|
dc81b0aa81 | ||
|
|
c648027735 | ||
|
|
fced88a8a6 | ||
|
|
0ee673c097 | ||
|
|
395b2fec8e | ||
|
|
be7e44e14b | ||
|
|
a87783d8c6 | ||
|
|
be017440b7 | ||
|
|
10de011c18 | ||
|
|
f7b74db3ea | ||
|
|
72d75133c4 | ||
|
|
e4c12471b4 | ||
|
|
3329149282 | ||
|
|
523ff0eb17 | ||
|
|
025e15d65c | ||
|
|
7d140b3e2a | ||
|
|
69210638e5 | ||
|
|
6aef2b807d | ||
|
|
95f5e9c831 | ||
|
|
7337296ae9 | ||
|
|
92a5d3592c | ||
|
|
2f04af872b | ||
|
|
9479d6d11d | ||
|
|
f687ba0d82 | ||
|
|
ab2bf0731a | ||
|
|
cafaba1be0 | ||
|
|
93082d2cdc | ||
|
|
087006c483 | ||
|
|
b7013a5ec8 | ||
|
|
7d76b3fab2 | ||
|
|
6ca206053f |
@@ -0,0 +1,204 @@
|
||||
---
|
||||
name: adapt
|
||||
description: Adapt designs to work across different screen sizes, devices, contexts, or platforms. Ensures consistent experience across varied environments.
|
||||
user-invocable: true
|
||||
args:
|
||||
- name: target
|
||||
description: The feature or component to adapt (optional)
|
||||
required: false
|
||||
- name: context
|
||||
description: What to adapt for (mobile, tablet, desktop, print, email, etc.)
|
||||
required: false
|
||||
---
|
||||
|
||||
Adapt existing designs to work effectively across different contexts - different screen sizes, devices, platforms, or use cases.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: target platforms/devices and usage contexts.
|
||||
|
||||
---
|
||||
|
||||
## Assess Adaptation Challenge
|
||||
|
||||
Understand what needs adaptation and why:
|
||||
|
||||
1. **Identify the source context**:
|
||||
- What was it designed for originally? (Desktop web? Mobile app?)
|
||||
- What assumptions were made? (Large screen? Mouse input? Fast connection?)
|
||||
- What works well in current context?
|
||||
|
||||
2. **Understand target context**:
|
||||
- **Device**: Mobile, tablet, desktop, TV, watch, print?
|
||||
- **Input method**: Touch, mouse, keyboard, voice, gamepad?
|
||||
- **Screen constraints**: Size, resolution, orientation?
|
||||
- **Connection**: Fast wifi, slow 3G, offline?
|
||||
- **Usage context**: On-the-go vs desk, quick glance vs focused reading?
|
||||
- **User expectations**: What do users expect on this platform?
|
||||
|
||||
3. **Identify adaptation challenges**:
|
||||
- What won't fit? (Content, navigation, features)
|
||||
- What won't work? (Hover states on touch, tiny touch targets)
|
||||
- What's inappropriate? (Desktop patterns on mobile, mobile patterns on desktop)
|
||||
|
||||
**CRITICAL**: Adaptation is not just scaling - it's rethinking the experience for the new context.
|
||||
|
||||
## Plan Adaptation Strategy
|
||||
|
||||
Create context-appropriate strategy:
|
||||
|
||||
### Mobile Adaptation (Desktop → Mobile)
|
||||
|
||||
**Layout Strategy**:
|
||||
- Single column instead of multi-column
|
||||
- Vertical stacking instead of side-by-side
|
||||
- Full-width components instead of fixed widths
|
||||
- Bottom navigation instead of top/side navigation
|
||||
|
||||
**Interaction Strategy**:
|
||||
- Touch targets 44x44px minimum (not hover-dependent)
|
||||
- Swipe gestures where appropriate (lists, carousels)
|
||||
- Bottom sheets instead of dropdowns
|
||||
- Thumbs-first design (controls within thumb reach)
|
||||
- Larger tap areas with more spacing
|
||||
|
||||
**Content Strategy**:
|
||||
- Progressive disclosure (don't show everything at once)
|
||||
- Prioritize primary content (secondary content in tabs/accordions)
|
||||
- Shorter text (more concise)
|
||||
- Larger text (16px minimum)
|
||||
|
||||
**Navigation Strategy**:
|
||||
- Hamburger menu or bottom navigation
|
||||
- Reduce navigation complexity
|
||||
- Sticky headers for context
|
||||
- Back button in navigation flow
|
||||
|
||||
### Tablet Adaptation (Hybrid Approach)
|
||||
|
||||
**Layout Strategy**:
|
||||
- Two-column layouts (not single or three-column)
|
||||
- Side panels for secondary content
|
||||
- Master-detail views (list + detail)
|
||||
- Adaptive based on orientation (portrait vs landscape)
|
||||
|
||||
**Interaction Strategy**:
|
||||
- Support both touch and pointer
|
||||
- Touch targets 44x44px but allow denser layouts than phone
|
||||
- Side navigation drawers
|
||||
- Multi-column forms where appropriate
|
||||
|
||||
### Desktop Adaptation (Mobile → Desktop)
|
||||
|
||||
**Layout Strategy**:
|
||||
- Multi-column layouts (use horizontal space)
|
||||
- Side navigation always visible
|
||||
- Multiple information panels simultaneously
|
||||
- Fixed widths with max-width constraints (don't stretch to 4K)
|
||||
|
||||
**Interaction Strategy**:
|
||||
- Hover states for additional information
|
||||
- Keyboard shortcuts
|
||||
- Right-click context menus
|
||||
- Drag and drop where helpful
|
||||
- Multi-select with Shift/Cmd
|
||||
|
||||
**Content Strategy**:
|
||||
- Show more information upfront (less progressive disclosure)
|
||||
- Data tables with many columns
|
||||
- Richer visualizations
|
||||
- More detailed descriptions
|
||||
|
||||
### Print Adaptation (Screen → Print)
|
||||
|
||||
**Layout Strategy**:
|
||||
- Page breaks at logical points
|
||||
- Remove navigation, footer, interactive elements
|
||||
- Black and white (or limited color)
|
||||
- Proper margins for binding
|
||||
|
||||
**Content Strategy**:
|
||||
- Expand shortened content (show full URLs, hidden sections)
|
||||
- Add page numbers, headers, footers
|
||||
- Include metadata (print date, page title)
|
||||
- Convert charts to print-friendly versions
|
||||
|
||||
### Email Adaptation (Web → Email)
|
||||
|
||||
**Layout Strategy**:
|
||||
- Narrow width (600px max)
|
||||
- Single column only
|
||||
- Inline CSS (no external stylesheets)
|
||||
- Table-based layouts (for email client compatibility)
|
||||
|
||||
**Interaction Strategy**:
|
||||
- Large, obvious CTAs (buttons not text links)
|
||||
- No hover states (not reliable)
|
||||
- Deep links to web app for complex interactions
|
||||
|
||||
## Implement Adaptations
|
||||
|
||||
Apply changes systematically:
|
||||
|
||||
### Responsive Breakpoints
|
||||
|
||||
Choose appropriate breakpoints:
|
||||
- Mobile: 320px-767px
|
||||
- Tablet: 768px-1023px
|
||||
- Desktop: 1024px+
|
||||
- Or content-driven breakpoints (where design breaks)
|
||||
|
||||
### Layout Adaptation Techniques
|
||||
|
||||
- **CSS Grid/Flexbox**: Reflow layouts automatically
|
||||
- **Container Queries**: Adapt based on container, not viewport
|
||||
- **`clamp()`**: Fluid sizing between min and max
|
||||
- **Media queries**: Different styles for different contexts
|
||||
- **Display properties**: Show/hide elements per context
|
||||
|
||||
### Touch Adaptation
|
||||
|
||||
- Increase touch target sizes (44x44px minimum)
|
||||
- Add more spacing between interactive elements
|
||||
- Remove hover-dependent interactions
|
||||
- Add touch feedback (ripples, highlights)
|
||||
- Consider thumb zones (easier to reach bottom than top)
|
||||
|
||||
### Content Adaptation
|
||||
|
||||
- Use `display: none` sparingly (still downloads)
|
||||
- Progressive enhancement (core content first, enhancements on larger screens)
|
||||
- Lazy loading for off-screen content
|
||||
- Responsive images (`srcset`, `picture` element)
|
||||
|
||||
### Navigation Adaptation
|
||||
|
||||
- Transform complex nav to hamburger/drawer on mobile
|
||||
- Bottom nav bar for mobile apps
|
||||
- Persistent side navigation on desktop
|
||||
- Breadcrumbs on smaller screens for context
|
||||
|
||||
**IMPORTANT**: Test on real devices, not just browser DevTools. Device emulation is helpful but not perfect.
|
||||
|
||||
**NEVER**:
|
||||
- Hide core functionality on mobile (if it matters, make it work)
|
||||
- Assume desktop = powerful device (consider accessibility, older machines)
|
||||
- Use different information architecture across contexts (confusing)
|
||||
- Break user expectations for platform (mobile users expect mobile patterns)
|
||||
- Forget landscape orientation on mobile/tablet
|
||||
- Use generic breakpoints blindly (use content-driven breakpoints)
|
||||
- Ignore touch on desktop (many desktop devices have touch)
|
||||
|
||||
## Verify Adaptations
|
||||
|
||||
Test thoroughly across contexts:
|
||||
|
||||
- **Real devices**: Test on actual phones, tablets, desktops
|
||||
- **Different orientations**: Portrait and landscape
|
||||
- **Different browsers**: Safari, Chrome, Firefox, Edge
|
||||
- **Different OS**: iOS, Android, Windows, macOS
|
||||
- **Different input methods**: Touch, mouse, keyboard
|
||||
- **Edge cases**: Very small screens (320px), very large screens (4K)
|
||||
- **Slow connections**: Test on throttled network
|
||||
|
||||
Remember: You're a cross-platform design expert. Make experiences that feel native to each context while maintaining brand and functionality consistency. Adapt intentionally, test thoroughly.
|
||||
@@ -0,0 +1,174 @@
|
||||
---
|
||||
name: animate
|
||||
description: Review a feature and enhance it with purposeful animations, micro-interactions, and motion effects that improve usability and delight.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Analyze a feature and strategically add animations and micro-interactions that enhance understanding, provide feedback, and create delight.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: performance constraints.
|
||||
|
||||
---
|
||||
|
||||
## Assess Animation Opportunities
|
||||
|
||||
Analyze where motion would improve the experience:
|
||||
|
||||
1. **Identify static areas**:
|
||||
- **Missing feedback**: Actions without visual acknowledgment (button clicks, form submission, etc.)
|
||||
- **Jarring transitions**: Instant state changes that feel abrupt (show/hide, page loads, route changes)
|
||||
- **Unclear relationships**: Spatial or hierarchical relationships that aren't obvious
|
||||
- **Lack of delight**: Functional but joyless interactions
|
||||
- **Missed guidance**: Opportunities to direct attention or explain behavior
|
||||
|
||||
2. **Understand the context**:
|
||||
- What's the personality? (Playful vs serious, energetic vs calm)
|
||||
- What's the performance budget? (Mobile-first? Complex page?)
|
||||
- Who's the audience? (Motion-sensitive users? Power users who want speed?)
|
||||
- What matters most? (One hero animation vs many micro-interactions?)
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: Respect `prefers-reduced-motion`. Always provide non-animated alternatives for users who need them.
|
||||
|
||||
## Plan Animation Strategy
|
||||
|
||||
Create a purposeful animation plan:
|
||||
|
||||
- **Hero moment**: What's the ONE signature animation? (Page load? Hero section? Key interaction?)
|
||||
- **Feedback layer**: Which interactions need acknowledgment?
|
||||
- **Transition layer**: Which state changes need smoothing?
|
||||
- **Delight layer**: Where can we surprise and delight?
|
||||
|
||||
**IMPORTANT**: One well-orchestrated experience beats scattered animations everywhere. Focus on high-impact moments.
|
||||
|
||||
## Implement Animations
|
||||
|
||||
Add motion systematically across these categories:
|
||||
|
||||
### Entrance Animations
|
||||
- **Page load choreography**: Stagger element reveals (100-150ms delays), fade + slide combinations
|
||||
- **Hero section**: Dramatic entrance for primary content (scale, parallax, or creative effects)
|
||||
- **Content reveals**: Scroll-triggered animations using intersection observer
|
||||
- **Modal/drawer entry**: Smooth slide + fade, backdrop fade, focus management
|
||||
|
||||
### Micro-interactions
|
||||
- **Button feedback**:
|
||||
- Hover: Subtle scale (1.02-1.05), color shift, shadow increase
|
||||
- Click: Quick scale down then up (0.95 → 1), ripple effect
|
||||
- Loading: Spinner or pulse state
|
||||
- **Form interactions**:
|
||||
- Input focus: Border color transition, slight scale or glow
|
||||
- Validation: Shake on error, check mark on success, smooth color transitions
|
||||
- **Toggle switches**: Smooth slide + color transition (200-300ms)
|
||||
- **Checkboxes/radio**: Check mark animation, ripple effect
|
||||
- **Like/favorite**: Scale + rotation, particle effects, color transition
|
||||
|
||||
### State Transitions
|
||||
- **Show/hide**: Fade + slide (not instant), appropriate timing (200-300ms)
|
||||
- **Expand/collapse**: Height transition with overflow handling, icon rotation
|
||||
- **Loading states**: Skeleton screen fades, spinner animations, progress bars
|
||||
- **Success/error**: Color transitions, icon animations, gentle scale pulse
|
||||
- **Enable/disable**: Opacity transitions, cursor changes
|
||||
|
||||
### Navigation & Flow
|
||||
- **Page transitions**: Crossfade between routes, shared element transitions
|
||||
- **Tab switching**: Slide indicator, content fade/slide
|
||||
- **Carousel/slider**: Smooth transforms, snap points, momentum
|
||||
- **Scroll effects**: Parallax layers, sticky headers with state changes, scroll progress indicators
|
||||
|
||||
### Feedback & Guidance
|
||||
- **Hover hints**: Tooltip fade-ins, cursor changes, element highlights
|
||||
- **Drag & drop**: Lift effect (shadow + scale), drop zone highlights, smooth repositioning
|
||||
- **Copy/paste**: Brief highlight flash on paste, "copied" confirmation
|
||||
- **Focus flow**: Highlight path through form or workflow
|
||||
|
||||
### Delight Moments
|
||||
- **Empty states**: Subtle floating animations on illustrations
|
||||
- **Completed actions**: Confetti, check mark flourish, success celebrations
|
||||
- **Easter eggs**: Hidden interactions for discovery
|
||||
- **Contextual animation**: Weather effects, time-of-day themes, seasonal touches
|
||||
|
||||
## Technical Implementation
|
||||
|
||||
Use appropriate techniques for each animation:
|
||||
|
||||
### Timing & Easing
|
||||
|
||||
**Durations by purpose:**
|
||||
- **100-150ms**: Instant feedback (button press, toggle)
|
||||
- **200-300ms**: State changes (hover, menu open)
|
||||
- **300-500ms**: Layout changes (accordion, modal)
|
||||
- **500-800ms**: Entrance animations (page load)
|
||||
|
||||
**Easing curves (use these, not CSS defaults):**
|
||||
```css
|
||||
/* Recommended - natural deceleration */
|
||||
--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1); /* Smooth, refined */
|
||||
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1); /* Slightly snappier */
|
||||
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1); /* Confident, decisive */
|
||||
|
||||
/* AVOID - feel dated and tacky */
|
||||
/* bounce: cubic-bezier(0.34, 1.56, 0.64, 1); */
|
||||
/* elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6); */
|
||||
```
|
||||
|
||||
**Exit animations are faster than entrances.** Use ~75% of enter duration.
|
||||
|
||||
### CSS Animations
|
||||
```css
|
||||
/* Prefer for simple, declarative animations */
|
||||
- transitions for state changes
|
||||
- @keyframes for complex sequences
|
||||
- transform + opacity only (GPU-accelerated)
|
||||
```
|
||||
|
||||
### JavaScript Animation
|
||||
```javascript
|
||||
/* Use for complex, interactive animations */
|
||||
- Web Animations API for programmatic control
|
||||
- Framer Motion for React
|
||||
- GSAP for complex sequences
|
||||
```
|
||||
|
||||
### Performance
|
||||
- **GPU acceleration**: Use `transform` and `opacity`, avoid layout properties
|
||||
- **will-change**: Add sparingly for known expensive animations
|
||||
- **Reduce paint**: Minimize repaints, use `contain` where appropriate
|
||||
- **Monitor FPS**: Ensure 60fps on target devices
|
||||
|
||||
### Accessibility
|
||||
```css
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**NEVER**:
|
||||
- Use bounce or elastic easing curves—they feel dated and draw attention to the animation itself
|
||||
- Animate layout properties (width, height, top, left)—use transform instead
|
||||
- Use durations over 500ms for feedback—it feels laggy
|
||||
- Animate without purpose—every animation needs a reason
|
||||
- Ignore `prefers-reduced-motion`—this is an accessibility violation
|
||||
- Animate everything—animation fatigue makes interfaces feel exhausting
|
||||
- Block interaction during animations unless intentional
|
||||
|
||||
## Verify Quality
|
||||
|
||||
Test animations thoroughly:
|
||||
|
||||
- **Smooth at 60fps**: No jank on target devices
|
||||
- **Feels natural**: Easing curves feel organic, not robotic
|
||||
- **Appropriate timing**: Not too fast (jarring) or too slow (laggy)
|
||||
- **Reduced motion works**: Animations disabled or simplified appropriately
|
||||
- **Doesn't block**: Users can interact during/after animations
|
||||
- **Adds value**: Makes interface clearer or more delightful
|
||||
|
||||
Remember: Motion should enhance understanding and provide feedback, not just add decoration. Animate with purpose, respect performance constraints, and always consider accessibility. Great animation is invisible - it just makes everything feel right.
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
name: arrange
|
||||
description: Improve layout, spacing, and visual rhythm. Fixes monotonous grids, inconsistent spacing, and weak visual hierarchy to create intentional compositions.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Assess and improve layout and spacing that feels monotonous, crowded, or structurally weak — turning generic arrangements into intentional, rhythmic compositions.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current Layout
|
||||
|
||||
Analyze what's weak about the current spatial design:
|
||||
|
||||
1. **Spacing**:
|
||||
- Is spacing consistent or arbitrary? (Random padding/margin values)
|
||||
- Is all spacing the same? (Equal padding everywhere = no rhythm)
|
||||
- Are related elements grouped tightly, with generous space between groups?
|
||||
|
||||
2. **Visual hierarchy**:
|
||||
- Apply the squint test: blur your (metaphorical) eyes — can you still identify the most important element, second most important, and clear groupings?
|
||||
- Is hierarchy achieved effectively? (Space and weight alone can be enough — but is the current approach working?)
|
||||
- Does whitespace guide the eye to what matters?
|
||||
|
||||
3. **Grid & structure**:
|
||||
- Is there a clear underlying structure, or does the layout feel random?
|
||||
- Are identical card grids used everywhere? (Icon + heading + text, repeated endlessly)
|
||||
- Is everything centered? (Left-aligned with asymmetric layouts feels more designed, but not a hard and fast rule)
|
||||
|
||||
4. **Rhythm & variety**:
|
||||
- Does the layout have visual rhythm? (Alternating tight/generous spacing)
|
||||
- Is every section structured the same way? (Monotonous repetition)
|
||||
- Are there intentional moments of surprise or emphasis?
|
||||
|
||||
5. **Density**:
|
||||
- Is the layout too cramped? (Not enough breathing room)
|
||||
- Is the layout too sparse? (Excessive whitespace without purpose)
|
||||
- Does density match the content type? (Data-dense UIs need tighter spacing; marketing pages need more air)
|
||||
|
||||
**CRITICAL**: Layout problems are often the root cause of interfaces feeling "off" even when colors and fonts are fine. Space is a design material — use it with intention.
|
||||
|
||||
## Plan Layout Improvements
|
||||
|
||||
Consult the [spatial design reference](reference/spatial-design.md) from the frontend-design skill for detailed guidance on grids, rhythm, and container queries.
|
||||
|
||||
Create a systematic plan:
|
||||
|
||||
- **Spacing system**: Use a consistent scale — whether that's a framework's built-in scale (e.g., Tailwind), rem-based tokens, or a custom system. The specific values matter less than consistency.
|
||||
- **Hierarchy strategy**: How will space communicate importance?
|
||||
- **Layout approach**: What structure fits the content? Flex for 1D, Grid for 2D, named areas for complex page layouts.
|
||||
- **Rhythm**: Where should spacing be tight vs generous?
|
||||
|
||||
## Improve Layout Systematically
|
||||
|
||||
### Establish a Spacing System
|
||||
|
||||
- Use a consistent spacing scale — framework scales (Tailwind, etc.), rem-based tokens, or a custom scale all work. What matters is that values come from a defined set, not arbitrary numbers.
|
||||
- Name tokens semantically if using custom properties: `--space-xs` through `--space-xl`, not `--spacing-8`
|
||||
- Use `gap` for sibling spacing instead of margins — eliminates margin collapse hacks
|
||||
- Apply `clamp()` for fluid spacing that breathes on larger screens
|
||||
|
||||
### Create Visual Rhythm
|
||||
|
||||
- **Tight grouping** for related elements (8-12px between siblings)
|
||||
- **Generous separation** between distinct sections (48-96px)
|
||||
- **Varied spacing** within sections — not every row needs the same gap
|
||||
- **Asymmetric compositions** — break the predictable centered-content pattern when it makes sense
|
||||
|
||||
### Choose the Right Layout Tool
|
||||
|
||||
- **Use Flexbox for 1D layouts**: Rows of items, nav bars, button groups, card contents, most component internals. Flex is simpler and more appropriate for the majority of layout tasks.
|
||||
- **Use Grid for 2D layouts**: Page-level structure, dashboards, data-dense interfaces, anything where rows AND columns need coordinated control.
|
||||
- **Don't default to Grid** when Flexbox with `flex-wrap` would be simpler and more flexible.
|
||||
- Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints.
|
||||
- Use named grid areas (`grid-template-areas`) for complex page layouts — redefine at breakpoints.
|
||||
|
||||
### Break Card Grid Monotony
|
||||
|
||||
- Don't default to card grids for everything — spacing and alignment create visual grouping naturally
|
||||
- Use cards only when content is truly distinct and actionable — never nest cards inside cards
|
||||
- Vary card sizes, span columns, or mix cards with non-card content to break repetition
|
||||
|
||||
### Strengthen Visual Hierarchy
|
||||
|
||||
- Use the fewest dimensions needed for clear hierarchy. Space alone can be enough — generous whitespace around an element draws the eye. Some of the most sophisticated designs achieve rhythm with just space and weight. Add color or size contrast only when simpler means aren't sufficient.
|
||||
- Be aware of reading flow — in LTR languages, the eye naturally scans top-left to bottom-right, but primary action placement depends on context (e.g., bottom-right in dialogs, top in navigation).
|
||||
- Create clear content groupings through proximity and separation.
|
||||
|
||||
### Manage Depth & Elevation
|
||||
|
||||
- Create a semantic z-index scale (dropdown → sticky → modal-backdrop → modal → toast → tooltip)
|
||||
- Build a consistent shadow scale (sm → md → lg → xl) — shadows should be subtle
|
||||
- Use elevation to reinforce hierarchy, not as decoration
|
||||
|
||||
### Optical Adjustments
|
||||
|
||||
- If an icon looks visually off-center despite being geometrically centered, nudge it — but only if you're confident it actually looks wrong. Don't adjust speculatively.
|
||||
|
||||
**NEVER**:
|
||||
- Use arbitrary spacing values outside your scale
|
||||
- Make all spacing equal — variety creates hierarchy
|
||||
- Wrap everything in cards — not everything needs a container
|
||||
- Nest cards inside cards — use spacing and dividers for hierarchy within
|
||||
- Use identical card grids everywhere (icon + heading + text, repeated)
|
||||
- Center everything — left-aligned with asymmetry feels more designed
|
||||
- Default to the hero metric layout (big number, small label, stats, gradient) as a template. If showing real user data, a prominent metric can work — but it should display actual data, not decorative numbers.
|
||||
- Default to CSS Grid when Flexbox would be simpler — use the simplest tool for the job
|
||||
- Use arbitrary z-index values (999, 9999) — build a semantic scale
|
||||
|
||||
## Verify Layout Improvements
|
||||
|
||||
- **Squint test**: Can you identify primary, secondary, and groupings with blurred vision?
|
||||
- **Rhythm**: Does the page have a satisfying beat of tight and generous spacing?
|
||||
- **Hierarchy**: Is the most important content obvious within 2 seconds?
|
||||
- **Breathing room**: Does the layout feel comfortable, not cramped or wasteful?
|
||||
- **Consistency**: Is the spacing system applied uniformly?
|
||||
- **Responsiveness**: Does the layout adapt gracefully across screen sizes?
|
||||
|
||||
Remember: Space is the most underused design tool. A layout with the right rhythm and hierarchy can make even simple content feel polished and intentional.
|
||||
@@ -0,0 +1,125 @@
|
||||
---
|
||||
name: audit
|
||||
description: Perform comprehensive audit of interface quality across accessibility, performance, theming, and responsive design. Generates detailed report of issues with severity ratings and recommendations.
|
||||
user-invocable: true
|
||||
argument-hint: [AREA=<value>]
|
||||
---
|
||||
|
||||
Run systematic quality checks and generate a comprehensive audit report with prioritized issues and actionable recommendations. Don't fix issues - document them for other commands to address.
|
||||
|
||||
**First**: Use the frontend-design skill for design principles and anti-patterns.
|
||||
|
||||
## Diagnostic Scan
|
||||
|
||||
Run comprehensive checks across multiple dimensions:
|
||||
|
||||
1. **Accessibility (A11y)** - Check for:
|
||||
- **Contrast issues**: Text contrast ratios < 4.5:1 (or 7:1 for AAA)
|
||||
- **Missing ARIA**: Interactive elements without proper roles, labels, or states
|
||||
- **Keyboard navigation**: Missing focus indicators, illogical tab order, keyboard traps
|
||||
- **Semantic HTML**: Improper heading hierarchy, missing landmarks, divs instead of buttons
|
||||
- **Alt text**: Missing or poor image descriptions
|
||||
- **Form issues**: Inputs without labels, poor error messaging, missing required indicators
|
||||
|
||||
2. **Performance** - Check for:
|
||||
- **Layout thrashing**: Reading/writing layout properties in loops
|
||||
- **Expensive animations**: Animating layout properties (width, height, top, left) instead of transform/opacity
|
||||
- **Missing optimization**: Images without lazy loading, unoptimized assets, missing will-change
|
||||
- **Bundle size**: Unnecessary imports, unused dependencies
|
||||
- **Render performance**: Unnecessary re-renders, missing memoization
|
||||
|
||||
3. **Theming** - Check for:
|
||||
- **Hard-coded colors**: Colors not using design tokens
|
||||
- **Broken dark mode**: Missing dark mode variants, poor contrast in dark theme
|
||||
- **Inconsistent tokens**: Using wrong tokens, mixing token types
|
||||
- **Theme switching issues**: Values that don't update on theme change
|
||||
|
||||
4. **Responsive Design** - Check for:
|
||||
- **Fixed widths**: Hard-coded widths that break on mobile
|
||||
- **Touch targets**: Interactive elements < 44x44px
|
||||
- **Horizontal scroll**: Content overflow on narrow viewports
|
||||
- **Text scaling**: Layouts that break when text size increases
|
||||
- **Missing breakpoints**: No mobile/tablet variants
|
||||
|
||||
5. **Anti-Patterns (CRITICAL)** - Check against ALL the **DON'T** guidelines in the frontend-design skill. Look for AI slop tells (AI color palette, gradient text, glassmorphism, hero metrics, card grids, generic fonts) and general design anti-patterns (gray on color, nested cards, bounce easing, redundant copy).
|
||||
|
||||
**CRITICAL**: This is an audit, not a fix. Document issues thoroughly with clear explanations of impact. Use other commands (normalize, optimize, harden, etc.) to fix issues after audit.
|
||||
|
||||
## Generate Comprehensive Report
|
||||
|
||||
Create a detailed audit report with the following structure:
|
||||
|
||||
### Anti-Patterns Verdict
|
||||
**Start here.** Pass/fail: Does this look AI-generated? List specific tells from the skill's Anti-Patterns section. Be brutally honest.
|
||||
|
||||
### Executive Summary
|
||||
- Total issues found (count by severity)
|
||||
- Most critical issues (top 3-5)
|
||||
- Overall quality score (if applicable)
|
||||
- Recommended next steps
|
||||
|
||||
### Detailed Findings by Severity
|
||||
|
||||
For each issue, document:
|
||||
- **Location**: Where the issue occurs (component, file, line)
|
||||
- **Severity**: Critical / High / Medium / Low
|
||||
- **Category**: Accessibility / Performance / Theming / Responsive
|
||||
- **Description**: What the issue is
|
||||
- **Impact**: How it affects users
|
||||
- **WCAG/Standard**: Which standard it violates (if applicable)
|
||||
- **Recommendation**: How to fix it
|
||||
- **Suggested command**: Which command to use (prefer: /animate, /quieter, /optimize, /adapt, /clarify, /distill, /delight, /onboard, /normalize, /audit, /harden, /polish, /extract, /bolder, /arrange, /typeset, /critique, /colorize, /overdrive — or other installed skills you're sure exist)
|
||||
|
||||
#### Critical Issues
|
||||
[Issues that block core functionality or violate WCAG A]
|
||||
|
||||
#### High-Severity Issues
|
||||
[Significant usability/accessibility impact, WCAG AA violations]
|
||||
|
||||
#### Medium-Severity Issues
|
||||
[Quality issues, WCAG AAA violations, performance concerns]
|
||||
|
||||
#### Low-Severity Issues
|
||||
[Minor inconsistencies, optimization opportunities]
|
||||
|
||||
### Patterns & Systemic Issues
|
||||
|
||||
Identify recurring problems:
|
||||
- "Hard-coded colors appear in 15+ components, should use design tokens"
|
||||
- "Touch targets consistently too small (<44px) throughout mobile experience"
|
||||
- "Missing focus indicators on all custom interactive components"
|
||||
|
||||
### Positive Findings
|
||||
|
||||
Note what's working well:
|
||||
- Good practices to maintain
|
||||
- Exemplary implementations to replicate elsewhere
|
||||
|
||||
### Recommendations by Priority
|
||||
|
||||
Create actionable plan:
|
||||
1. **Immediate**: Critical blockers to fix first
|
||||
2. **Short-term**: High-severity issues (this sprint)
|
||||
3. **Medium-term**: Quality improvements (next sprint)
|
||||
4. **Long-term**: Nice-to-haves and optimizations
|
||||
|
||||
### Suggested Commands for Fixes
|
||||
|
||||
Map issues to available commands. Prefer these: /animate, /quieter, /optimize, /adapt, /clarify, /distill, /delight, /onboard, /normalize, /audit, /harden, /polish, /extract, /bolder, /arrange, /typeset, /critique, /colorize, /overdrive. You may also suggest other installed skills you're sure exist, but never invent commands.
|
||||
|
||||
Examples:
|
||||
- "Use `/normalize` to align with design system (addresses N theming issues)"
|
||||
- "Use `/optimize` to improve performance (addresses N performance issues)"
|
||||
- "Use `/harden` to improve resilience (addresses N edge cases)"
|
||||
|
||||
**IMPORTANT**: Be thorough but actionable. Too many low-priority issues creates noise. Focus on what actually matters.
|
||||
|
||||
**NEVER**:
|
||||
- Report issues without explaining impact (why does this matter?)
|
||||
- Mix severity levels inconsistently
|
||||
- Skip positive findings (celebrate what works)
|
||||
- Provide generic recommendations (be specific and actionable)
|
||||
- Forget to prioritize (everything can't be critical)
|
||||
- Report false positives without verification
|
||||
|
||||
Remember: You're a quality auditor with exceptional attention to detail. Document systematically, prioritize ruthlessly, and provide clear paths to improvement. A good audit makes fixing easy.
|
||||
@@ -0,0 +1,116 @@
|
||||
---
|
||||
name: bolder
|
||||
description: Amplify safe or boring designs to make them more visually interesting and stimulating. Increases impact while maintaining usability.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Increase visual impact and personality in designs that are too safe, generic, or visually underwhelming, creating more engaging and memorable experiences.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current State
|
||||
|
||||
Analyze what makes the design feel too safe or boring:
|
||||
|
||||
1. **Identify weakness sources**:
|
||||
- **Generic choices**: System fonts, basic colors, standard layouts
|
||||
- **Timid scale**: Everything is medium-sized with no drama
|
||||
- **Low contrast**: Everything has similar visual weight
|
||||
- **Static**: No motion, no energy, no life
|
||||
- **Predictable**: Standard patterns with no surprises
|
||||
- **Flat hierarchy**: Nothing stands out or commands attention
|
||||
|
||||
2. **Understand the context**:
|
||||
- What's the brand personality? (How far can we push?)
|
||||
- What's the purpose? (Marketing can be bolder than financial dashboards)
|
||||
- Who's the audience? (What will resonate?)
|
||||
- What are the constraints? (Brand guidelines, accessibility, performance)
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: "Bolder" doesn't mean chaotic or garish. It means distinctive, memorable, and confident. Think intentional drama, not random chaos.
|
||||
|
||||
**WARNING - AI SLOP TRAP**: When making things "bolder," AI defaults to the same tired tricks: cyan/purple gradients, glassmorphism, neon accents on dark backgrounds, gradient text on metrics. These are the OPPOSITE of bold—they're generic. Review ALL the DON'T guidelines in the frontend-design skill before proceeding. Bold means distinctive, not "more effects."
|
||||
|
||||
## Plan Amplification
|
||||
|
||||
Create a strategy to increase impact while maintaining coherence:
|
||||
|
||||
- **Focal point**: What should be the hero moment? (Pick ONE, make it amazing)
|
||||
- **Personality direction**: Maximalist chaos? Elegant drama? Playful energy? Dark moody? Choose a lane.
|
||||
- **Risk budget**: How experimental can we be? Push boundaries within constraints.
|
||||
- **Hierarchy amplification**: Make big things BIGGER, small things smaller (increase contrast)
|
||||
|
||||
**IMPORTANT**: Bold design must still be usable. Impact without function is just decoration.
|
||||
|
||||
## Amplify the Design
|
||||
|
||||
Systematically increase impact across these dimensions:
|
||||
|
||||
### Typography Amplification
|
||||
- **Replace generic fonts**: Swap system fonts for distinctive choices (see frontend-design skill for inspiration)
|
||||
- **Extreme scale**: Create dramatic size jumps (3x-5x differences, not 1.5x)
|
||||
- **Weight contrast**: Pair 900 weights with 200 weights, not 600 with 400
|
||||
- **Unexpected choices**: Variable fonts, display fonts for headlines, condensed/extended widths, monospace as intentional accent (not as lazy "dev tool" default)
|
||||
|
||||
### Color Intensification
|
||||
- **Increase saturation**: Shift to more vibrant, energetic colors (but not neon)
|
||||
- **Bold palette**: Introduce unexpected color combinations—avoid the purple-blue gradient AI slop
|
||||
- **Dominant color strategy**: Let one bold color own 60% of the design
|
||||
- **Sharp accents**: High-contrast accent colors that pop
|
||||
- **Tinted neutrals**: Replace pure grays with tinted grays that harmonize with your palette
|
||||
- **Rich gradients**: Intentional multi-stop gradients (not generic purple-to-blue)
|
||||
|
||||
### Spatial Drama
|
||||
- **Extreme scale jumps**: Make important elements 3-5x larger than surroundings
|
||||
- **Break the grid**: Let hero elements escape containers and cross boundaries
|
||||
- **Asymmetric layouts**: Replace centered, balanced layouts with tension-filled asymmetry
|
||||
- **Generous space**: Use white space dramatically (100-200px gaps, not 20-40px)
|
||||
- **Overlap**: Layer elements intentionally for depth
|
||||
|
||||
### Visual Effects
|
||||
- **Dramatic shadows**: Large, soft shadows for elevation (but not generic drop shadows on rounded rectangles)
|
||||
- **Background treatments**: Mesh patterns, noise textures, geometric patterns, intentional gradients (not purple-to-blue)
|
||||
- **Texture & depth**: Grain, halftone, duotone, layered elements—NOT glassmorphism (it's overused AI slop)
|
||||
- **Borders & frames**: Thick borders, decorative frames, custom shapes (not rounded rectangles with colored border on one side)
|
||||
- **Custom elements**: Illustrative elements, custom icons, decorative details that reinforce brand
|
||||
|
||||
### Motion & Animation
|
||||
- **Entrance choreography**: Staggered, dramatic page load animations with 50-100ms delays
|
||||
- **Scroll effects**: Parallax, reveal animations, scroll-triggered sequences
|
||||
- **Micro-interactions**: Satisfying hover effects, click feedback, state changes
|
||||
- **Transitions**: Smooth, noticeable transitions using ease-out-quart/quint/expo (not bounce or elastic—they cheapen the effect)
|
||||
|
||||
### Composition Boldness
|
||||
- **Hero moments**: Create clear focal points with dramatic treatment
|
||||
- **Diagonal flows**: Escape horizontal/vertical rigidity with diagonal arrangements
|
||||
- **Full-bleed elements**: Use full viewport width/height for impact
|
||||
- **Unexpected proportions**: Golden ratio? Throw it out. Try 70/30, 80/20 splits
|
||||
|
||||
**NEVER**:
|
||||
- Add effects randomly without purpose (chaos ≠ bold)
|
||||
- Sacrifice readability for aesthetics (body text must be readable)
|
||||
- Make everything bold (then nothing is bold - need contrast)
|
||||
- Ignore accessibility (bold design must still meet WCAG standards)
|
||||
- Overwhelm with motion (animation fatigue is real)
|
||||
- Copy trendy aesthetics blindly (bold means distinctive, not derivative)
|
||||
|
||||
## Verify Quality
|
||||
|
||||
Ensure amplification maintains usability and coherence:
|
||||
|
||||
- **NOT AI slop**: Does this look like every other AI-generated "bold" design? If yes, start over.
|
||||
- **Still functional**: Can users accomplish tasks without distraction?
|
||||
- **Coherent**: Does everything feel intentional and unified?
|
||||
- **Memorable**: Will users remember this experience?
|
||||
- **Performant**: Do all these effects run smoothly?
|
||||
- **Accessible**: Does it still meet accessibility standards?
|
||||
|
||||
**The test**: If you showed this to someone and said "AI made this bolder," would they believe you immediately? If yes, you've failed. Bold means distinctive, not "more AI effects."
|
||||
|
||||
Remember: Bold design is confident design. It takes risks, makes statements, and creates memorable experiences. But bold without strategy is just loud. Be intentional, be dramatic, be unforgettable.
|
||||
@@ -0,0 +1,182 @@
|
||||
---
|
||||
name: clarify
|
||||
description: Improve unclear UX copy, error messages, microcopy, labels, and instructions. Makes interfaces easier to understand and use.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Identify and improve unclear, confusing, or poorly written interface text to make the product easier to understand and use.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: audience technical level and users' mental state in context.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current Copy
|
||||
|
||||
Identify what makes the text unclear or ineffective:
|
||||
|
||||
1. **Find clarity problems**:
|
||||
- **Jargon**: Technical terms users won't understand
|
||||
- **Ambiguity**: Multiple interpretations possible
|
||||
- **Passive voice**: "Your file has been uploaded" vs "We uploaded your file"
|
||||
- **Length**: Too wordy or too terse
|
||||
- **Assumptions**: Assuming user knowledge they don't have
|
||||
- **Missing context**: Users don't know what to do or why
|
||||
- **Tone mismatch**: Too formal, too casual, or inappropriate for situation
|
||||
|
||||
2. **Understand the context**:
|
||||
- Who's the audience? (Technical? General? First-time users?)
|
||||
- What's the user's mental state? (Stressed during error? Confident during success?)
|
||||
- What's the action? (What do we want users to do?)
|
||||
- What's the constraint? (Character limits? Space limitations?)
|
||||
|
||||
**CRITICAL**: Clear copy helps users succeed. Unclear copy creates frustration, errors, and support tickets.
|
||||
|
||||
## Plan Copy Improvements
|
||||
|
||||
Create a strategy for clearer communication:
|
||||
|
||||
- **Primary message**: What's the ONE thing users need to know?
|
||||
- **Action needed**: What should users do next (if anything)?
|
||||
- **Tone**: How should this feel? (Helpful? Apologetic? Encouraging?)
|
||||
- **Constraints**: Length limits, brand voice, localization considerations
|
||||
|
||||
**IMPORTANT**: Good UX writing is invisible. Users should understand immediately without noticing the words.
|
||||
|
||||
## Improve Copy Systematically
|
||||
|
||||
Refine text across these common areas:
|
||||
|
||||
### Error Messages
|
||||
**Bad**: "Error 403: Forbidden"
|
||||
**Good**: "You don't have permission to view this page. Contact your admin for access."
|
||||
|
||||
**Bad**: "Invalid input"
|
||||
**Good**: "Email addresses need an @ symbol. Try: name@example.com"
|
||||
|
||||
**Principles**:
|
||||
- Explain what went wrong in plain language
|
||||
- Suggest how to fix it
|
||||
- Don't blame the user
|
||||
- Include examples when helpful
|
||||
- Link to help/support if applicable
|
||||
|
||||
### Form Labels & Instructions
|
||||
**Bad**: "DOB (MM/DD/YYYY)"
|
||||
**Good**: "Date of birth" (with placeholder showing format)
|
||||
|
||||
**Bad**: "Enter value here"
|
||||
**Good**: "Your email address" or "Company name"
|
||||
|
||||
**Principles**:
|
||||
- Use clear, specific labels (not generic placeholders)
|
||||
- Show format expectations with examples
|
||||
- Explain why you're asking (when not obvious)
|
||||
- Put instructions before the field, not after
|
||||
- Keep required field indicators clear
|
||||
|
||||
### Button & CTA Text
|
||||
**Bad**: "Click here" | "Submit" | "OK"
|
||||
**Good**: "Create account" | "Save changes" | "Got it, thanks"
|
||||
|
||||
**Principles**:
|
||||
- Describe the action specifically
|
||||
- Use active voice (verb + noun)
|
||||
- Match user's mental model
|
||||
- Be specific ("Save" is better than "OK")
|
||||
|
||||
### Help Text & Tooltips
|
||||
**Bad**: "This is the username field"
|
||||
**Good**: "Choose a username. You can change this later in Settings."
|
||||
|
||||
**Principles**:
|
||||
- Add value (don't just repeat the label)
|
||||
- Answer the implicit question ("What is this?" or "Why do you need this?")
|
||||
- Keep it brief but complete
|
||||
- Link to detailed docs if needed
|
||||
|
||||
### Empty States
|
||||
**Bad**: "No items"
|
||||
**Good**: "No projects yet. Create your first project to get started."
|
||||
|
||||
**Principles**:
|
||||
- Explain why it's empty (if not obvious)
|
||||
- Show next action clearly
|
||||
- Make it welcoming, not dead-end
|
||||
|
||||
### Success Messages
|
||||
**Bad**: "Success"
|
||||
**Good**: "Settings saved! Your changes will take effect immediately."
|
||||
|
||||
**Principles**:
|
||||
- Confirm what happened
|
||||
- Explain what happens next (if relevant)
|
||||
- Be brief but complete
|
||||
- Match the user's emotional moment (celebrate big wins)
|
||||
|
||||
### Loading States
|
||||
**Bad**: "Loading..." (for 30+ seconds)
|
||||
**Good**: "Analyzing your data... this usually takes 30-60 seconds"
|
||||
|
||||
**Principles**:
|
||||
- Set expectations (how long?)
|
||||
- Explain what's happening (when it's not obvious)
|
||||
- Show progress when possible
|
||||
- Offer escape hatch if appropriate ("Cancel")
|
||||
|
||||
### Confirmation Dialogs
|
||||
**Bad**: "Are you sure?"
|
||||
**Good**: "Delete 'Project Alpha'? This can't be undone."
|
||||
|
||||
**Principles**:
|
||||
- State the specific action
|
||||
- Explain consequences (especially for destructive actions)
|
||||
- Use clear button labels ("Delete project" not "Yes")
|
||||
- Don't overuse confirmations (only for risky actions)
|
||||
|
||||
### Navigation & Wayfinding
|
||||
**Bad**: Generic labels like "Items" | "Things" | "Stuff"
|
||||
**Good**: Specific labels like "Your projects" | "Team members" | "Settings"
|
||||
|
||||
**Principles**:
|
||||
- Be specific and descriptive
|
||||
- Use language users understand (not internal jargon)
|
||||
- Make hierarchy clear
|
||||
- Consider information scent (breadcrumbs, current location)
|
||||
|
||||
## Apply Clarity Principles
|
||||
|
||||
Every piece of copy should follow these rules:
|
||||
|
||||
1. **Be specific**: "Enter email" not "Enter value"
|
||||
2. **Be concise**: Cut unnecessary words (but don't sacrifice clarity)
|
||||
3. **Be active**: "Save changes" not "Changes will be saved"
|
||||
4. **Be human**: "Oops, something went wrong" not "System error encountered"
|
||||
5. **Be helpful**: Tell users what to do, not just what happened
|
||||
6. **Be consistent**: Use same terms throughout (don't vary for variety)
|
||||
|
||||
**NEVER**:
|
||||
- Use jargon without explanation
|
||||
- Blame users ("You made an error" → "This field is required")
|
||||
- Be vague ("Something went wrong" without explanation)
|
||||
- Use passive voice unnecessarily
|
||||
- Write overly long explanations (be concise)
|
||||
- Use humor for errors (be empathetic instead)
|
||||
- Assume technical knowledge
|
||||
- Vary terminology (pick one term and stick with it)
|
||||
- Repeat information (headers restating intros, redundant explanations)
|
||||
- Use placeholders as the only labels (they disappear when users type)
|
||||
|
||||
## Verify Improvements
|
||||
|
||||
Test that copy improvements work:
|
||||
|
||||
- **Comprehension**: Can users understand without context?
|
||||
- **Actionability**: Do users know what to do next?
|
||||
- **Brevity**: Is it as short as possible while remaining clear?
|
||||
- **Consistency**: Does it match terminology elsewhere?
|
||||
- **Tone**: Is it appropriate for the situation?
|
||||
|
||||
Remember: You're a clarity expert with excellent communication skills. Write like you're explaining to a smart friend who's unfamiliar with the product. Be clear, be helpful, be human.
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
name: colorize
|
||||
description: Add strategic color to features that are too monochromatic or lack visual interest. Makes interfaces more engaging and expressive.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Strategically introduce color to designs that are too monochromatic, gray, or lacking in visual warmth and personality.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: existing brand colors.
|
||||
|
||||
---
|
||||
|
||||
## Assess Color Opportunity
|
||||
|
||||
Analyze the current state and identify opportunities:
|
||||
|
||||
1. **Understand current state**:
|
||||
- **Color absence**: Pure grayscale? Limited neutrals? One timid accent?
|
||||
- **Missed opportunities**: Where could color add meaning, hierarchy, or delight?
|
||||
- **Context**: What's appropriate for this domain and audience?
|
||||
- **Brand**: Are there existing brand colors we should use?
|
||||
|
||||
2. **Identify where color adds value**:
|
||||
- **Semantic meaning**: Success (green), error (red), warning (yellow/orange), info (blue)
|
||||
- **Hierarchy**: Drawing attention to important elements
|
||||
- **Categorization**: Different sections, types, or states
|
||||
- **Emotional tone**: Warmth, energy, trust, creativity
|
||||
- **Wayfinding**: Helping users navigate and understand structure
|
||||
- **Delight**: Moments of visual interest and personality
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: More color ≠ better. Strategic color beats rainbow vomit every time. Every color should have a purpose.
|
||||
|
||||
## Plan Color Strategy
|
||||
|
||||
Create a purposeful color introduction plan:
|
||||
|
||||
- **Color palette**: What colors match the brand/context? (Choose 2-4 colors max beyond neutrals)
|
||||
- **Dominant color**: Which color owns 60% of colored elements?
|
||||
- **Accent colors**: Which colors provide contrast and highlights? (30% and 10%)
|
||||
- **Application strategy**: Where does each color appear and why?
|
||||
|
||||
**IMPORTANT**: Color should enhance hierarchy and meaning, not create chaos. Less is more when it matters more.
|
||||
|
||||
## Introduce Color Strategically
|
||||
|
||||
Add color systematically across these dimensions:
|
||||
|
||||
### Semantic Color
|
||||
- **State indicators**:
|
||||
- Success: Green tones (emerald, forest, mint)
|
||||
- Error: Red/pink tones (rose, crimson, coral)
|
||||
- Warning: Orange/amber tones
|
||||
- Info: Blue tones (sky, ocean, indigo)
|
||||
- Neutral: Gray/slate for inactive states
|
||||
|
||||
- **Status badges**: Colored backgrounds or borders for states (active, pending, completed, etc.)
|
||||
- **Progress indicators**: Colored bars, rings, or charts showing completion or health
|
||||
|
||||
### Accent Color Application
|
||||
- **Primary actions**: Color the most important buttons/CTAs
|
||||
- **Links**: Add color to clickable text (maintain accessibility)
|
||||
- **Icons**: Colorize key icons for recognition and personality
|
||||
- **Headers/titles**: Add color to section headers or key labels
|
||||
- **Hover states**: Introduce color on interaction
|
||||
|
||||
### Background & Surfaces
|
||||
- **Tinted backgrounds**: Replace pure gray (`#f5f5f5`) with warm neutrals (`oklch(97% 0.01 60)`) or cool tints (`oklch(97% 0.01 250)`)
|
||||
- **Colored sections**: Use subtle background colors to separate areas
|
||||
- **Gradient backgrounds**: Add depth with subtle, intentional gradients (not generic purple-blue)
|
||||
- **Cards & surfaces**: Tint cards or surfaces slightly for warmth
|
||||
|
||||
**Use OKLCH for color**: It's perceptually uniform, meaning equal steps in lightness *look* equal. Great for generating harmonious scales.
|
||||
|
||||
### Data Visualization
|
||||
- **Charts & graphs**: Use color to encode categories or values
|
||||
- **Heatmaps**: Color intensity shows density or importance
|
||||
- **Comparison**: Color coding for different datasets or timeframes
|
||||
|
||||
### Borders & Accents
|
||||
- **Accent borders**: Add colored left/top borders to cards or sections
|
||||
- **Underlines**: Color underlines for emphasis or active states
|
||||
- **Dividers**: Subtle colored dividers instead of gray lines
|
||||
- **Focus rings**: Colored focus indicators matching brand
|
||||
|
||||
### Typography Color
|
||||
- **Colored headings**: Use brand colors for section headings (maintain contrast)
|
||||
- **Highlight text**: Color for emphasis or categories
|
||||
- **Labels & tags**: Small colored labels for metadata or categories
|
||||
|
||||
### Decorative Elements
|
||||
- **Illustrations**: Add colored illustrations or icons
|
||||
- **Shapes**: Geometric shapes in brand colors as background elements
|
||||
- **Gradients**: Colorful gradient overlays or mesh backgrounds
|
||||
- **Blobs/organic shapes**: Soft colored shapes for visual interest
|
||||
|
||||
## Balance & Refinement
|
||||
|
||||
Ensure color addition improves rather than overwhelms:
|
||||
|
||||
### Maintain Hierarchy
|
||||
- **Dominant color** (60%): Primary brand color or most used accent
|
||||
- **Secondary color** (30%): Supporting color for variety
|
||||
- **Accent color** (10%): High contrast for key moments
|
||||
- **Neutrals** (remaining): Gray/black/white for structure
|
||||
|
||||
### Accessibility
|
||||
- **Contrast ratios**: Ensure WCAG compliance (4.5:1 for text, 3:1 for UI components)
|
||||
- **Don't rely on color alone**: Use icons, labels, or patterns alongside color
|
||||
- **Test for color blindness**: Verify red/green combinations work for all users
|
||||
|
||||
### Cohesion
|
||||
- **Consistent palette**: Use colors from defined palette, not arbitrary choices
|
||||
- **Systematic application**: Same color meanings throughout (green always = success)
|
||||
- **Temperature consistency**: Warm palette stays warm, cool stays cool
|
||||
|
||||
**NEVER**:
|
||||
- Use every color in the rainbow (choose 2-4 colors beyond neutrals)
|
||||
- Apply color randomly without semantic meaning
|
||||
- Put gray text on colored backgrounds—it looks washed out; use a darker shade of the background color or transparency instead
|
||||
- Use pure gray for neutrals—add subtle color tint (warm or cool) for sophistication
|
||||
- Use pure black (`#000`) or pure white (`#fff`) for large areas
|
||||
- Violate WCAG contrast requirements
|
||||
- Use color as the only indicator (accessibility issue)
|
||||
- Make everything colorful (defeats the purpose)
|
||||
- Default to purple-blue gradients (AI slop aesthetic)
|
||||
|
||||
## Verify Color Addition
|
||||
|
||||
Test that colorization improves the experience:
|
||||
|
||||
- **Better hierarchy**: Does color guide attention appropriately?
|
||||
- **Clearer meaning**: Does color help users understand states/categories?
|
||||
- **More engaging**: Does the interface feel warmer and more inviting?
|
||||
- **Still accessible**: Do all color combinations meet WCAG standards?
|
||||
- **Not overwhelming**: Is color balanced and purposeful?
|
||||
|
||||
Remember: Color is emotional and powerful. Use it to create warmth, guide attention, communicate meaning, and express personality. But restraint and strategy matter more than saturation and variety. Be colorful, but be intentional.
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
name: critique
|
||||
description: Evaluate design effectiveness from a UX perspective. Assesses visual hierarchy, information architecture, emotional resonance, and overall design quality with actionable feedback.
|
||||
user-invocable: true
|
||||
argument-hint: [AREA=<value>]
|
||||
---
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: what the interface is trying to accomplish.
|
||||
|
||||
---
|
||||
|
||||
Conduct a holistic design critique, evaluating whether the interface actually works—not just technically, but as a designed experience. Think like a design director giving feedback.
|
||||
|
||||
## Design Critique
|
||||
|
||||
Evaluate the interface across these dimensions:
|
||||
|
||||
### 1. AI Slop Detection (CRITICAL)
|
||||
|
||||
**This is the most important check.** Does this look like every other AI-generated interface from 2024-2025?
|
||||
|
||||
Review the design against ALL the **DON'T** guidelines in the frontend-design skill—they are the fingerprints of AI-generated work. Check for the AI color palette, gradient text, dark mode with glowing accents, glassmorphism, hero metric layouts, identical card grids, generic fonts, and all other tells.
|
||||
|
||||
**The test**: If you showed this to someone and said "AI made this," would they believe you immediately? If yes, that's the problem.
|
||||
|
||||
### 2. Visual Hierarchy
|
||||
- Does the eye flow to the most important element first?
|
||||
- Is there a clear primary action? Can you spot it in 2 seconds?
|
||||
- Do size, color, and position communicate importance correctly?
|
||||
- Is there visual competition between elements that should have different weights?
|
||||
|
||||
### 3. Information Architecture
|
||||
- Is the structure intuitive? Would a new user understand the organization?
|
||||
- Is related content grouped logically?
|
||||
- Are there too many choices at once? (cognitive overload)
|
||||
- Is the navigation clear and predictable?
|
||||
|
||||
### 4. Emotional Resonance
|
||||
- What emotion does this interface evoke? Is that intentional?
|
||||
- Does it match the brand personality?
|
||||
- Does it feel trustworthy, approachable, premium, playful—whatever it should feel?
|
||||
- Would the target user feel "this is for me"?
|
||||
|
||||
### 5. Discoverability & Affordance
|
||||
- Are interactive elements obviously interactive?
|
||||
- Would a user know what to do without instructions?
|
||||
- Are hover/focus states providing useful feedback?
|
||||
- Are there hidden features that should be more visible?
|
||||
|
||||
### 6. Composition & Balance
|
||||
- Does the layout feel balanced or uncomfortably weighted?
|
||||
- Is whitespace used intentionally or just leftover?
|
||||
- Is there visual rhythm in spacing and repetition?
|
||||
- Does asymmetry feel designed or accidental?
|
||||
|
||||
### 7. Typography as Communication
|
||||
- Does the type hierarchy clearly signal what to read first, second, third?
|
||||
- Is body text comfortable to read? (line length, spacing, size)
|
||||
- Do font choices reinforce the brand/tone?
|
||||
- Is there enough contrast between heading levels?
|
||||
|
||||
### 8. Color with Purpose
|
||||
- Is color used to communicate, not just decorate?
|
||||
- Does the palette feel cohesive?
|
||||
- Are accent colors drawing attention to the right things?
|
||||
- Does it work for colorblind users? (not just technically—does meaning still come through?)
|
||||
|
||||
### 9. States & Edge Cases
|
||||
- Empty states: Do they guide users toward action, or just say "nothing here"?
|
||||
- Loading states: Do they reduce perceived wait time?
|
||||
- Error states: Are they helpful and non-blaming?
|
||||
- Success states: Do they confirm and guide next steps?
|
||||
|
||||
### 10. Microcopy & Voice
|
||||
- Is the writing clear and concise?
|
||||
- Does it sound like a human (the right human for this brand)?
|
||||
- Are labels and buttons unambiguous?
|
||||
- Does error copy help users fix the problem?
|
||||
|
||||
## Generate Critique Report
|
||||
|
||||
Structure your feedback as a design director would:
|
||||
|
||||
### Anti-Patterns Verdict
|
||||
**Start here.** Pass/fail: Does this look AI-generated? List specific tells from the skill's Anti-Patterns section. Be brutally honest.
|
||||
|
||||
### Overall Impression
|
||||
A brief gut reaction—what works, what doesn't, and the single biggest opportunity.
|
||||
|
||||
### What's Working
|
||||
Highlight 2-3 things done well. Be specific about why they work.
|
||||
|
||||
### Priority Issues
|
||||
The 3-5 most impactful design problems, ordered by importance:
|
||||
|
||||
For each issue:
|
||||
- **What**: Name the problem clearly
|
||||
- **Why it matters**: How this hurts users or undermines goals
|
||||
- **Fix**: What to do about it (be concrete)
|
||||
- **Command**: Which command to use (prefer: /animate, /quieter, /optimize, /adapt, /clarify, /distill, /delight, /onboard, /normalize, /audit, /harden, /polish, /extract, /bolder, /arrange, /typeset, /critique, /colorize, /overdrive — or other installed skills you're sure exist)
|
||||
|
||||
### Minor Observations
|
||||
Quick notes on smaller issues worth addressing.
|
||||
|
||||
### Questions to Consider
|
||||
Provocative questions that might unlock better solutions:
|
||||
- "What if the primary action were more prominent?"
|
||||
- "Does this need to feel this complex?"
|
||||
- "What would a confident version of this look like?"
|
||||
|
||||
**Remember**:
|
||||
- Be direct—vague feedback wastes everyone's time
|
||||
- Be specific—"the submit button" not "some elements"
|
||||
- Say what's wrong AND why it matters to users
|
||||
- Give concrete suggestions, not just "consider exploring..."
|
||||
- Prioritize ruthlessly—if everything is important, nothing is
|
||||
- Don't soften criticism—developers need honest feedback to ship great design
|
||||
@@ -0,0 +1,303 @@
|
||||
---
|
||||
name: delight
|
||||
description: Add moments of joy, personality, and unexpected touches that make interfaces memorable and enjoyable to use. Elevates functional to delightful.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Identify opportunities to add moments of joy, personality, and unexpected polish that transform functional interfaces into delightful experiences.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: what's appropriate for the domain (playful vs professional vs quirky vs elegant).
|
||||
|
||||
---
|
||||
|
||||
## Assess Delight Opportunities
|
||||
|
||||
Identify where delight would enhance (not distract from) the experience:
|
||||
|
||||
1. **Find natural delight moments**:
|
||||
- **Success states**: Completed actions (save, send, publish)
|
||||
- **Empty states**: First-time experiences, onboarding
|
||||
- **Loading states**: Waiting periods that could be entertaining
|
||||
- **Achievements**: Milestones, streaks, completions
|
||||
- **Interactions**: Hover states, clicks, drags
|
||||
- **Errors**: Softening frustrating moments
|
||||
- **Easter eggs**: Hidden discoveries for curious users
|
||||
|
||||
2. **Understand the context**:
|
||||
- What's the brand personality? (Playful? Professional? Quirky? Elegant?)
|
||||
- Who's the audience? (Tech-savvy? Creative? Corporate?)
|
||||
- What's the emotional context? (Accomplishment? Exploration? Frustration?)
|
||||
- What's appropriate? (Banking app ≠ gaming app)
|
||||
|
||||
3. **Define delight strategy**:
|
||||
- **Subtle sophistication**: Refined micro-interactions (luxury brands)
|
||||
- **Playful personality**: Whimsical illustrations and copy (consumer apps)
|
||||
- **Helpful surprises**: Anticipating needs before users ask (productivity tools)
|
||||
- **Sensory richness**: Satisfying sounds, smooth animations (creative tools)
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: Delight should enhance usability, never obscure it. If users notice the delight more than accomplishing their goal, you've gone too far.
|
||||
|
||||
## Delight Principles
|
||||
|
||||
Follow these guidelines:
|
||||
|
||||
### Delight Amplifies, Never Blocks
|
||||
- Delight moments should be quick (< 1 second)
|
||||
- Never delay core functionality for delight
|
||||
- Make delight skippable or subtle
|
||||
- Respect user's time and task focus
|
||||
|
||||
### Surprise and Discovery
|
||||
- Hide delightful details for users to discover
|
||||
- Reward exploration and curiosity
|
||||
- Don't announce every delight moment
|
||||
- Let users share discoveries with others
|
||||
|
||||
### Appropriate to Context
|
||||
- Match delight to emotional moment (celebrate success, empathize with errors)
|
||||
- Respect the user's state (don't be playful during critical errors)
|
||||
- Match brand personality and audience expectations
|
||||
- Cultural sensitivity (what's delightful varies by culture)
|
||||
|
||||
### Compound Over Time
|
||||
- Delight should remain fresh with repeated use
|
||||
- Vary responses (not same animation every time)
|
||||
- Reveal deeper layers with continued use
|
||||
- Build anticipation through patterns
|
||||
|
||||
## Delight Techniques
|
||||
|
||||
Add personality and joy through these methods:
|
||||
|
||||
### Micro-interactions & Animation
|
||||
|
||||
**Button delight**:
|
||||
```css
|
||||
/* Satisfying button press */
|
||||
.button {
|
||||
transition: transform 0.1s, box-shadow 0.1s;
|
||||
}
|
||||
.button:active {
|
||||
transform: translateY(2px);
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Ripple effect on click */
|
||||
/* Smooth lift on hover */
|
||||
.button:hover {
|
||||
transform: translateY(-2px);
|
||||
transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1); /* ease-out-quart */
|
||||
}
|
||||
```
|
||||
|
||||
**Loading delight**:
|
||||
- Playful loading animations (not just spinners)
|
||||
- Personality in loading messages (write product-specific ones, not generic AI filler)
|
||||
- Progress indication with encouraging messages
|
||||
- Skeleton screens with subtle animations
|
||||
|
||||
**Success animations**:
|
||||
- Checkmark draw animation
|
||||
- Confetti burst for major achievements
|
||||
- Gentle scale + fade for confirmation
|
||||
- Satisfying sound effects (subtle)
|
||||
|
||||
**Hover surprises**:
|
||||
- Icons that animate on hover
|
||||
- Color shifts or glow effects
|
||||
- Tooltip reveals with personality
|
||||
- Cursor changes (custom cursors for branded experiences)
|
||||
|
||||
### Personality in Copy
|
||||
|
||||
**Playful error messages**:
|
||||
```
|
||||
"Error 404"
|
||||
"This page is playing hide and seek. (And winning)"
|
||||
|
||||
"Connection failed"
|
||||
"Looks like the internet took a coffee break. Want to retry?"
|
||||
```
|
||||
|
||||
**Encouraging empty states**:
|
||||
```
|
||||
"No projects"
|
||||
"Your canvas awaits. Create something amazing."
|
||||
|
||||
"No messages"
|
||||
"Inbox zero! You're crushing it today."
|
||||
```
|
||||
|
||||
**Playful labels & tooltips**:
|
||||
```
|
||||
"Delete"
|
||||
"Send to void" (for playful brand)
|
||||
|
||||
"Help"
|
||||
"Rescue me" (tooltip)
|
||||
```
|
||||
|
||||
**IMPORTANT**: Match copy personality to brand. Banks shouldn't be wacky, but they can be warm.
|
||||
|
||||
### Illustrations & Visual Personality
|
||||
|
||||
**Custom illustrations**:
|
||||
- Empty state illustrations (not stock icons)
|
||||
- Error state illustrations (friendly monsters, quirky characters)
|
||||
- Loading state illustrations (animated characters)
|
||||
- Success state illustrations (celebrations)
|
||||
|
||||
**Icon personality**:
|
||||
- Custom icon set matching brand personality
|
||||
- Animated icons (subtle motion on hover/click)
|
||||
- Illustrative icons (more detailed than generic)
|
||||
- Consistent style across all icons
|
||||
|
||||
**Background effects**:
|
||||
- Subtle particle effects
|
||||
- Gradient mesh backgrounds
|
||||
- Geometric patterns
|
||||
- Parallax depth
|
||||
- Time-of-day themes (morning vs night)
|
||||
|
||||
### Satisfying Interactions
|
||||
|
||||
**Drag and drop delight**:
|
||||
- Lift effect on drag (shadow, scale)
|
||||
- Snap animation when dropped
|
||||
- Satisfying placement sound
|
||||
- Undo toast ("Dropped in wrong place? [Undo]")
|
||||
|
||||
**Toggle switches**:
|
||||
- Smooth slide with spring physics
|
||||
- Color transition
|
||||
- Haptic feedback on mobile
|
||||
- Optional sound effect
|
||||
|
||||
**Progress & achievements**:
|
||||
- Streak counters with celebratory milestones
|
||||
- Progress bars that "celebrate" at 100%
|
||||
- Badge unlocks with animation
|
||||
- Playful stats ("You're on fire! 5 days in a row")
|
||||
|
||||
**Form interactions**:
|
||||
- Input fields that animate on focus
|
||||
- Checkboxes with a satisfying scale pulse when checked
|
||||
- Success state that celebrates valid input
|
||||
- Auto-grow textareas
|
||||
|
||||
### Sound Design
|
||||
|
||||
**Subtle audio cues** (when appropriate):
|
||||
- Notification sounds (distinctive but not annoying)
|
||||
- Success sounds (satisfying "ding")
|
||||
- Error sounds (empathetic, not harsh)
|
||||
- Typing sounds for chat/messaging
|
||||
- Ambient background audio (very subtle)
|
||||
|
||||
**IMPORTANT**:
|
||||
- Respect system sound settings
|
||||
- Provide mute option
|
||||
- Keep volumes quiet (subtle cues, not alarms)
|
||||
- Don't play on every interaction (sound fatigue is real)
|
||||
|
||||
### Easter Eggs & Hidden Delights
|
||||
|
||||
**Discovery rewards**:
|
||||
- Konami code unlocks special theme
|
||||
- Hidden keyboard shortcuts (Cmd+K for special features)
|
||||
- Hover reveals on logos or illustrations
|
||||
- Alt text jokes on images (for screen reader users too!)
|
||||
- Console messages for developers ("Like what you see? We're hiring!")
|
||||
|
||||
**Seasonal touches**:
|
||||
- Holiday themes (subtle, tasteful)
|
||||
- Seasonal color shifts
|
||||
- Weather-based variations
|
||||
- Time-based changes (dark at night, light during day)
|
||||
|
||||
**Contextual personality**:
|
||||
- Different messages based on time of day
|
||||
- Responses to specific user actions
|
||||
- Randomized variations (not same every time)
|
||||
- Progressive reveals with continued use
|
||||
|
||||
### Loading & Waiting States
|
||||
|
||||
**Make waiting engaging**:
|
||||
- Interesting loading messages that rotate
|
||||
- Progress bars with personality
|
||||
- Mini-games during long loads
|
||||
- Fun facts or tips while waiting
|
||||
- Countdown with encouraging messages
|
||||
|
||||
```
|
||||
Loading messages — write ones specific to your product, not generic AI filler:
|
||||
- "Crunching your latest numbers..."
|
||||
- "Syncing with your team's changes..."
|
||||
- "Preparing your dashboard..."
|
||||
- "Checking for updates since yesterday..."
|
||||
```
|
||||
|
||||
**WARNING**: Avoid cliched loading messages like "Herding pixels", "Teaching robots to dance", "Consulting the magic 8-ball", "Counting backwards from infinity". These are AI-slop copy — instantly recognizable as machine-generated. Write messages that are specific to what your product actually does.
|
||||
|
||||
### Celebration Moments
|
||||
|
||||
**Success celebrations**:
|
||||
- Confetti for major milestones
|
||||
- Animated checkmarks for completions
|
||||
- Progress bar celebrations at 100%
|
||||
- "Achievement unlocked" style notifications
|
||||
- Personalized messages ("You published your 10th article!")
|
||||
|
||||
**Milestone recognition**:
|
||||
- First-time actions get special treatment
|
||||
- Streak tracking and celebration
|
||||
- Progress toward goals
|
||||
- Anniversary celebrations
|
||||
|
||||
## Implementation Patterns
|
||||
|
||||
**Animation libraries**:
|
||||
- Framer Motion (React)
|
||||
- GSAP (universal)
|
||||
- Lottie (After Effects animations)
|
||||
- Canvas confetti (party effects)
|
||||
|
||||
**Sound libraries**:
|
||||
- Howler.js (audio management)
|
||||
- Use-sound (React hook)
|
||||
|
||||
**Physics libraries**:
|
||||
- React Spring (spring physics)
|
||||
- Popmotion (animation primitives)
|
||||
|
||||
**IMPORTANT**: File size matters. Compress images, optimize animations, lazy load delight features.
|
||||
|
||||
**NEVER**:
|
||||
- Delay core functionality for delight
|
||||
- Force users through delightful moments (make skippable)
|
||||
- Use delight to hide poor UX
|
||||
- Overdo it (less is more)
|
||||
- Ignore accessibility (animate responsibly, provide alternatives)
|
||||
- Make every interaction delightful (special moments should be special)
|
||||
- Sacrifice performance for delight
|
||||
- Be inappropriate for context (read the room)
|
||||
|
||||
## Verify Delight Quality
|
||||
|
||||
Test that delight actually delights:
|
||||
|
||||
- **User reactions**: Do users smile? Share screenshots?
|
||||
- **Doesn't annoy**: Still pleasant after 100th time?
|
||||
- **Doesn't block**: Can users opt out or skip?
|
||||
- **Performant**: No jank, no slowdown
|
||||
- **Appropriate**: Matches brand and context
|
||||
- **Accessible**: Works with reduced motion, screen readers
|
||||
|
||||
Remember: Delight is the difference between a tool and an experience. Add personality, surprise users positively, and create moments worth sharing. But always respect usability - delight should enhance, never obstruct.
|
||||
@@ -0,0 +1,121 @@
|
||||
---
|
||||
name: distill
|
||||
description: Strip designs to their essence by removing unnecessary complexity. Great design is simple, powerful, and clean.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Remove unnecessary complexity from designs, revealing the essential elements and creating clarity through ruthless simplification.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current State
|
||||
|
||||
Analyze what makes the design feel complex or cluttered:
|
||||
|
||||
1. **Identify complexity sources**:
|
||||
- **Too many elements**: Competing buttons, redundant information, visual clutter
|
||||
- **Excessive variation**: Too many colors, fonts, sizes, styles without purpose
|
||||
- **Information overload**: Everything visible at once, no progressive disclosure
|
||||
- **Visual noise**: Unnecessary borders, shadows, backgrounds, decorations
|
||||
- **Confusing hierarchy**: Unclear what matters most
|
||||
- **Feature creep**: Too many options, actions, or paths forward
|
||||
|
||||
2. **Find the essence**:
|
||||
- What's the primary user goal? (There should be ONE)
|
||||
- What's actually necessary vs nice-to-have?
|
||||
- What can be removed, hidden, or combined?
|
||||
- What's the 20% that delivers 80% of value?
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: Simplicity is not about removing features - it's about removing obstacles between users and their goals. Every element should justify its existence.
|
||||
|
||||
## Plan Simplification
|
||||
|
||||
Create a ruthless editing strategy:
|
||||
|
||||
- **Core purpose**: What's the ONE thing this should accomplish?
|
||||
- **Essential elements**: What's truly necessary to achieve that purpose?
|
||||
- **Progressive disclosure**: What can be hidden until needed?
|
||||
- **Consolidation opportunities**: What can be combined or integrated?
|
||||
|
||||
**IMPORTANT**: Simplification is hard. It requires saying no to good ideas to make room for great execution. Be ruthless.
|
||||
|
||||
## Simplify the Design
|
||||
|
||||
Systematically remove complexity across these dimensions:
|
||||
|
||||
### Information Architecture
|
||||
- **Reduce scope**: Remove secondary actions, optional features, redundant information
|
||||
- **Progressive disclosure**: Hide complexity behind clear entry points (accordions, modals, step-through flows)
|
||||
- **Combine related actions**: Merge similar buttons, consolidate forms, group related content
|
||||
- **Clear hierarchy**: ONE primary action, few secondary actions, everything else tertiary or hidden
|
||||
- **Remove redundancy**: If it's said elsewhere, don't repeat it here
|
||||
|
||||
### Visual Simplification
|
||||
- **Reduce color palette**: Use 1-2 colors plus neutrals, not 5-7 colors
|
||||
- **Limit typography**: One font family, 3-4 sizes maximum, 2-3 weights
|
||||
- **Remove decorations**: Eliminate borders, shadows, backgrounds that don't serve hierarchy or function
|
||||
- **Flatten structure**: Reduce nesting, remove unnecessary containers—never nest cards inside cards
|
||||
- **Remove unnecessary cards**: Cards aren't needed for basic layout; use spacing and alignment instead
|
||||
- **Consistent spacing**: Use one spacing scale, remove arbitrary gaps
|
||||
|
||||
### Layout Simplification
|
||||
- **Linear flow**: Replace complex grids with simple vertical flow where possible
|
||||
- **Remove sidebars**: Move secondary content inline or hide it
|
||||
- **Full-width**: Use available space generously instead of complex multi-column layouts
|
||||
- **Consistent alignment**: Pick left or center, stick with it
|
||||
- **Generous white space**: Let content breathe, don't pack everything tight
|
||||
|
||||
### Interaction Simplification
|
||||
- **Reduce choices**: Fewer buttons, fewer options, clearer path forward (paradox of choice is real)
|
||||
- **Smart defaults**: Make common choices automatic, only ask when necessary
|
||||
- **Inline actions**: Replace modal flows with inline editing where possible
|
||||
- **Remove steps**: Can signup be one step instead of three? Can checkout be simplified?
|
||||
- **Clear CTAs**: ONE obvious next step, not five competing actions
|
||||
|
||||
### Content Simplification
|
||||
- **Shorter copy**: Cut every sentence in half, then do it again
|
||||
- **Active voice**: "Save changes" not "Changes will be saved"
|
||||
- **Remove jargon**: Plain language always wins
|
||||
- **Scannable structure**: Short paragraphs, bullet points, clear headings
|
||||
- **Essential information only**: Remove marketing fluff, legalese, hedging
|
||||
- **Remove redundant copy**: No headers restating intros, no repeated explanations, say it once
|
||||
|
||||
### Code Simplification
|
||||
- **Remove unused code**: Dead CSS, unused components, orphaned files
|
||||
- **Flatten component trees**: Reduce nesting depth
|
||||
- **Consolidate styles**: Merge similar styles, use utilities consistently
|
||||
- **Reduce variants**: Does that component need 12 variations, or can 3 cover 90% of cases?
|
||||
|
||||
**NEVER**:
|
||||
- Remove necessary functionality (simplicity ≠ feature-less)
|
||||
- Sacrifice accessibility for simplicity (clear labels and ARIA still required)
|
||||
- Make things so simple they're unclear (mystery ≠ minimalism)
|
||||
- Remove information users need to make decisions
|
||||
- Eliminate hierarchy completely (some things should stand out)
|
||||
- Oversimplify complex domains (match complexity to actual task complexity)
|
||||
|
||||
## Verify Simplification
|
||||
|
||||
Ensure simplification improves usability:
|
||||
|
||||
- **Faster task completion**: Can users accomplish goals more quickly?
|
||||
- **Reduced cognitive load**: Is it easier to understand what to do?
|
||||
- **Still complete**: Are all necessary features still accessible?
|
||||
- **Clearer hierarchy**: Is it obvious what matters most?
|
||||
- **Better performance**: Does simpler design load faster?
|
||||
|
||||
## Document Removed Complexity
|
||||
|
||||
If you removed features or options:
|
||||
- Document why they were removed
|
||||
- Consider if they need alternative access points
|
||||
- Note any user feedback to monitor
|
||||
|
||||
Remember: You have great taste and judgment. Simplification is an act of confidence - knowing what to keep and courage to remove the rest. As Antoine de Saint-Exupéry said: "Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away."
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
name: extract
|
||||
description: Extract and consolidate reusable components, design tokens, and patterns into your design system. Identifies opportunities for systematic reuse and enriches your component library.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Identify reusable patterns, components, and design tokens, then extract and consolidate them into the design system for systematic reuse.
|
||||
|
||||
## Discover
|
||||
|
||||
Analyze the target area to identify extraction opportunities:
|
||||
|
||||
1. **Find the design system**: Locate your design system, component library, or shared UI directory (grep for "design system", "ui", "components", etc.). Understand its structure:
|
||||
- Component organization and naming conventions
|
||||
- Design token structure (if any)
|
||||
- Documentation patterns
|
||||
- Import/export conventions
|
||||
|
||||
**CRITICAL**: If no design system exists, ask before creating one. Understand the preferred location and structure first.
|
||||
|
||||
2. **Identify patterns**: Look for:
|
||||
- **Repeated components**: Similar UI patterns used multiple times (buttons, cards, inputs, etc.)
|
||||
- **Hard-coded values**: Colors, spacing, typography, shadows that should be tokens
|
||||
- **Inconsistent variations**: Multiple implementations of the same concept (3 different button styles)
|
||||
- **Reusable patterns**: Layout patterns, composition patterns, interaction patterns worth systematizing
|
||||
|
||||
3. **Assess value**: Not everything should be extracted. Consider:
|
||||
- Is this used 3+ times, or likely to be reused?
|
||||
- Would systematizing this improve consistency?
|
||||
- Is this a general pattern or context-specific?
|
||||
- What's the maintenance cost vs benefit?
|
||||
|
||||
## Plan Extraction
|
||||
|
||||
Create a systematic extraction plan:
|
||||
|
||||
- **Components to extract**: Which UI elements become reusable components?
|
||||
- **Tokens to create**: Which hard-coded values become design tokens?
|
||||
- **Variants to support**: What variations does each component need?
|
||||
- **Naming conventions**: Component names, token names, prop names that match existing patterns
|
||||
- **Migration path**: How to refactor existing uses to consume the new shared versions
|
||||
|
||||
**IMPORTANT**: Design systems grow incrementally. Extract what's clearly reusable now, not everything that might someday be reusable.
|
||||
|
||||
## Extract & Enrich
|
||||
|
||||
Build improved, reusable versions:
|
||||
|
||||
- **Components**: Create well-designed components with:
|
||||
- Clear props API with sensible defaults
|
||||
- Proper variants for different use cases
|
||||
- Accessibility built in (ARIA, keyboard navigation, focus management)
|
||||
- Documentation and usage examples
|
||||
|
||||
- **Design tokens**: Create tokens with:
|
||||
- Clear naming (primitive vs semantic)
|
||||
- Proper hierarchy and organization
|
||||
- Documentation of when to use each token
|
||||
|
||||
- **Patterns**: Document patterns with:
|
||||
- When to use this pattern
|
||||
- Code examples
|
||||
- Variations and combinations
|
||||
|
||||
**NEVER**:
|
||||
- Extract one-off, context-specific implementations without generalization
|
||||
- Create components so generic they're useless
|
||||
- Extract without considering existing design system conventions
|
||||
- Skip proper TypeScript types or prop documentation
|
||||
- Create tokens for every single value (tokens should have semantic meaning)
|
||||
|
||||
## Migrate
|
||||
|
||||
Replace existing uses with the new shared versions:
|
||||
|
||||
- **Find all instances**: Search for the patterns you've extracted
|
||||
- **Replace systematically**: Update each use to consume the shared version
|
||||
- **Test thoroughly**: Ensure visual and functional parity
|
||||
- **Delete dead code**: Remove the old implementations
|
||||
|
||||
## Document
|
||||
|
||||
Update design system documentation:
|
||||
|
||||
- Add new components to the component library
|
||||
- Document token usage and values
|
||||
- Add examples and guidelines
|
||||
- Update any Storybook or component catalog
|
||||
|
||||
Remember: A good design system is a living system. Extract patterns as they emerge, enrich them thoughtfully, and maintain them consistently.
|
||||
@@ -0,0 +1,146 @@
|
||||
---
|
||||
name: frontend-design
|
||||
description: Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications. Generates creative, polished code that avoids generic AI aesthetics.
|
||||
---
|
||||
|
||||
This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices.
|
||||
|
||||
## Context Gathering Protocol
|
||||
|
||||
Design skills produce generic output without project context. You MUST have confirmed design context before doing any design work.
|
||||
|
||||
**Required context** — every design skill needs at minimum:
|
||||
- **Target audience**: Who uses this product and in what context?
|
||||
- **Use cases**: What jobs are they trying to get done?
|
||||
- **Brand personality/tone**: How should the interface feel?
|
||||
|
||||
Individual skills may require additional context — check the skill's preparation section for specifics.
|
||||
|
||||
**CRITICAL**: You cannot infer this context by reading the codebase. Code tells you what was built, not who it's for or what it should feel like. Only the creator can provide this context.
|
||||
|
||||
**Gathering order:**
|
||||
1. **Check current instructions (instant)**: If your loaded instructions already contain a **Design Context** section, proceed immediately.
|
||||
2. **Check .impeccable.md (fast)**: If not in instructions, read `.impeccable.md` from the project root. If it exists and contains the required context, proceed.
|
||||
3. **Run teach-impeccable (REQUIRED)**: If neither source has context, you MUST run the teach-impeccable skill NOW before doing anything else. Do NOT skip this step. Do NOT attempt to infer context from the codebase instead.
|
||||
|
||||
---
|
||||
|
||||
## Design Direction
|
||||
|
||||
Commit to a BOLD aesthetic direction:
|
||||
- **Purpose**: What problem does this interface solve? Who uses it?
|
||||
- **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
|
||||
- **Constraints**: Technical requirements (framework, performance, accessibility).
|
||||
- **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?
|
||||
|
||||
**CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work—the key is intentionality, not intensity.
|
||||
|
||||
Then implement working code that is:
|
||||
- Production-grade and functional
|
||||
- Visually striking and memorable
|
||||
- Cohesive with a clear aesthetic point-of-view
|
||||
- Meticulously refined in every detail
|
||||
|
||||
## Frontend Aesthetics Guidelines
|
||||
|
||||
### Typography
|
||||
→ *Consult [typography reference](reference/typography.md) for scales, pairing, and loading strategies.*
|
||||
|
||||
Choose fonts that are beautiful, unique, and interesting. Pair a distinctive display font with a refined body font.
|
||||
|
||||
**DO**: Use a modular type scale with fluid sizing (clamp)
|
||||
**DO**: Vary font weights and sizes to create clear visual hierarchy
|
||||
**DON'T**: Use overused fonts—Inter, Roboto, Arial, Open Sans, system defaults
|
||||
**DON'T**: Use monospace typography as lazy shorthand for "technical/developer" vibes
|
||||
**DON'T**: Put large icons with rounded corners above every heading—they rarely add value and make sites look templated
|
||||
|
||||
### Color & Theme
|
||||
→ *Consult [color reference](reference/color-and-contrast.md) for OKLCH, palettes, and dark mode.*
|
||||
|
||||
Commit to a cohesive palette. Dominant colors with sharp accents outperform timid, evenly-distributed palettes.
|
||||
|
||||
**DO**: Use modern CSS color functions (oklch, color-mix, light-dark) for perceptually uniform, maintainable palettes
|
||||
**DO**: Tint your neutrals toward your brand hue—even a subtle hint creates subconscious cohesion
|
||||
**DON'T**: Use gray text on colored backgrounds—it looks washed out; use a shade of the background color instead
|
||||
**DON'T**: Use pure black (#000) or pure white (#fff)—always tint; pure black/white never appears in nature
|
||||
**DON'T**: Use the AI color palette: cyan-on-dark, purple-to-blue gradients, neon accents on dark backgrounds
|
||||
**DON'T**: Use gradient text for "impact"—especially on metrics or headings; it's decorative rather than meaningful
|
||||
**DON'T**: Default to dark mode with glowing accents—it looks "cool" without requiring actual design decisions
|
||||
|
||||
### Layout & Space
|
||||
→ *Consult [spatial reference](reference/spatial-design.md) for grids, rhythm, and container queries.*
|
||||
|
||||
Create visual rhythm through varied spacing—not the same padding everywhere. Embrace asymmetry and unexpected compositions. Break the grid intentionally for emphasis.
|
||||
|
||||
**DO**: Create visual rhythm through varied spacing—tight groupings, generous separations
|
||||
**DO**: Use fluid spacing with clamp() that breathes on larger screens
|
||||
**DO**: Use asymmetry and unexpected compositions; break the grid intentionally for emphasis
|
||||
**DON'T**: Wrap everything in cards—not everything needs a container
|
||||
**DON'T**: Nest cards inside cards—visual noise, flatten the hierarchy
|
||||
**DON'T**: Use identical card grids—same-sized cards with icon + heading + text, repeated endlessly
|
||||
**DON'T**: Use the hero metric layout template—big number, small label, supporting stats, gradient accent
|
||||
**DON'T**: Center everything—left-aligned text with asymmetric layouts feels more designed
|
||||
**DON'T**: Use the same spacing everywhere—without rhythm, layouts feel monotonous
|
||||
|
||||
### Visual Details
|
||||
**DO**: Use intentional, purposeful decorative elements that reinforce brand
|
||||
**DON'T**: Use glassmorphism everywhere—blur effects, glass cards, glow borders used decoratively rather than purposefully
|
||||
**DON'T**: Use rounded elements with thick colored border on one side—a lazy accent that almost never looks intentional
|
||||
**DON'T**: Use sparklines as decoration—tiny charts that look sophisticated but convey nothing meaningful
|
||||
**DON'T**: Use rounded rectangles with generic drop shadows—safe, forgettable, could be any AI output
|
||||
**DON'T**: Use modals unless there's truly no better alternative—modals are lazy
|
||||
|
||||
### Motion
|
||||
→ *Consult [motion reference](reference/motion-design.md) for timing, easing, and reduced motion.*
|
||||
|
||||
Focus on high-impact moments: one well-orchestrated page load with staggered reveals creates more delight than scattered micro-interactions.
|
||||
|
||||
**DO**: Use motion to convey state changes—entrances, exits, feedback
|
||||
**DO**: Use exponential easing (ease-out-quart/quint/expo) for natural deceleration
|
||||
**DO**: For height animations, use grid-template-rows transitions instead of animating height directly
|
||||
**DON'T**: Animate layout properties (width, height, padding, margin)—use transform and opacity only
|
||||
**DON'T**: Use bounce or elastic easing—they feel dated and tacky; real objects decelerate smoothly
|
||||
|
||||
### Interaction
|
||||
→ *Consult [interaction reference](reference/interaction-design.md) for forms, focus, and loading patterns.*
|
||||
|
||||
Make interactions feel fast. Use optimistic UI—update immediately, sync later.
|
||||
|
||||
**DO**: Use progressive disclosure—start simple, reveal sophistication through interaction (basic options first, advanced behind expandable sections; hover states that reveal secondary actions)
|
||||
**DO**: Design empty states that teach the interface, not just say "nothing here"
|
||||
**DO**: Make every interactive surface feel intentional and responsive
|
||||
**DON'T**: Repeat the same information—redundant headers, intros that restate the heading
|
||||
**DON'T**: Make every button primary—use ghost buttons, text links, secondary styles; hierarchy matters
|
||||
|
||||
### Responsive
|
||||
→ *Consult [responsive reference](reference/responsive-design.md) for mobile-first, fluid design, and container queries.*
|
||||
|
||||
**DO**: Use container queries (@container) for component-level responsiveness
|
||||
**DO**: Adapt the interface for different contexts—don't just shrink it
|
||||
**DON'T**: Hide critical functionality on mobile—adapt the interface, don't amputate it
|
||||
|
||||
### UX Writing
|
||||
→ *Consult [ux-writing reference](reference/ux-writing.md) for labels, errors, and empty states.*
|
||||
|
||||
**DO**: Make every word earn its place
|
||||
**DON'T**: Repeat information users can already see
|
||||
|
||||
---
|
||||
|
||||
## The AI Slop Test
|
||||
|
||||
**Critical quality check**: If you showed this interface to someone and said "AI made this," would they believe you immediately? If yes, that's the problem.
|
||||
|
||||
A distinctive interface should make someone ask "how was this made?" not "which AI made this?"
|
||||
|
||||
Review the DON'T guidelines above—they are the fingerprints of AI-generated work from 2024-2025.
|
||||
|
||||
---
|
||||
|
||||
## Implementation Principles
|
||||
|
||||
Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details.
|
||||
|
||||
Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices across generations.
|
||||
|
||||
Remember: the model is capable of extraordinary creative work. Don't hold back—show what can truly be created when thinking outside the box and committing fully to a distinctive vision.
|
||||
@@ -0,0 +1,132 @@
|
||||
# Color & Contrast
|
||||
|
||||
## Color Spaces: Use OKLCH
|
||||
|
||||
**Stop using HSL.** Use OKLCH (or LCH) instead. It's perceptually uniform, meaning equal steps in lightness *look* equal—unlike HSL where 50% lightness in yellow looks bright while 50% in blue looks dark.
|
||||
|
||||
```css
|
||||
/* OKLCH: lightness (0-100%), chroma (0-0.4+), hue (0-360) */
|
||||
--color-primary: oklch(60% 0.15 250); /* Blue */
|
||||
--color-primary-light: oklch(85% 0.08 250); /* Same hue, lighter */
|
||||
--color-primary-dark: oklch(35% 0.12 250); /* Same hue, darker */
|
||||
```
|
||||
|
||||
**Key insight**: As you move toward white or black, reduce chroma (saturation). High chroma at extreme lightness looks garish. A light blue at 85% lightness needs ~0.08 chroma, not the 0.15 of your base color.
|
||||
|
||||
## Building Functional Palettes
|
||||
|
||||
### The Tinted Neutral Trap
|
||||
|
||||
**Pure gray is dead.** Add a subtle hint of your brand hue to all neutrals:
|
||||
|
||||
```css
|
||||
/* Dead grays */
|
||||
--gray-100: oklch(95% 0 0); /* No personality */
|
||||
--gray-900: oklch(15% 0 0);
|
||||
|
||||
/* Warm-tinted grays (add brand warmth) */
|
||||
--gray-100: oklch(95% 0.01 60); /* Hint of warmth */
|
||||
--gray-900: oklch(15% 0.01 60);
|
||||
|
||||
/* Cool-tinted grays (tech, professional) */
|
||||
--gray-100: oklch(95% 0.01 250); /* Hint of blue */
|
||||
--gray-900: oklch(15% 0.01 250);
|
||||
```
|
||||
|
||||
The chroma is tiny (0.01) but perceptible. It creates subconscious cohesion between your brand color and your UI.
|
||||
|
||||
### Palette Structure
|
||||
|
||||
A complete system needs:
|
||||
|
||||
| Role | Purpose | Example |
|
||||
|------|---------|---------|
|
||||
| **Primary** | Brand, CTAs, key actions | 1 color, 3-5 shades |
|
||||
| **Neutral** | Text, backgrounds, borders | 9-11 shade scale |
|
||||
| **Semantic** | Success, error, warning, info | 4 colors, 2-3 shades each |
|
||||
| **Surface** | Cards, modals, overlays | 2-3 elevation levels |
|
||||
|
||||
**Skip secondary/tertiary unless you need them.** Most apps work fine with one accent color. Adding more creates decision fatigue and visual noise.
|
||||
|
||||
### The 60-30-10 Rule (Applied Correctly)
|
||||
|
||||
This rule is about **visual weight**, not pixel count:
|
||||
|
||||
- **60%**: Neutral backgrounds, white space, base surfaces
|
||||
- **30%**: Secondary colors—text, borders, inactive states
|
||||
- **10%**: Accent—CTAs, highlights, focus states
|
||||
|
||||
The common mistake: using the accent color everywhere because it's "the brand color." Accent colors work *because* they're rare. Overuse kills their power.
|
||||
|
||||
## Contrast & Accessibility
|
||||
|
||||
### WCAG Requirements
|
||||
|
||||
| Content Type | AA Minimum | AAA Target |
|
||||
|--------------|------------|------------|
|
||||
| Body text | 4.5:1 | 7:1 |
|
||||
| Large text (18px+ or 14px bold) | 3:1 | 4.5:1 |
|
||||
| UI components, icons | 3:1 | 4.5:1 |
|
||||
| Non-essential decorations | None | None |
|
||||
|
||||
**The gotcha**: Placeholder text still needs 4.5:1. That light gray placeholder you see everywhere? Usually fails WCAG.
|
||||
|
||||
### Dangerous Color Combinations
|
||||
|
||||
These commonly fail contrast or cause readability issues:
|
||||
|
||||
- Light gray text on white (the #1 accessibility fail)
|
||||
- **Gray text on any colored background**—gray looks washed out and dead on color. Use a darker shade of the background color, or transparency
|
||||
- Red text on green background (or vice versa)—8% of men can't distinguish these
|
||||
- Blue text on red background (vibrates visually)
|
||||
- Yellow text on white (almost always fails)
|
||||
- Thin light text on images (unpredictable contrast)
|
||||
|
||||
### Never Use Pure Gray or Pure Black
|
||||
|
||||
Pure gray (`oklch(50% 0 0)`) and pure black (`#000`) don't exist in nature—real shadows and surfaces always have a color cast. Even a chroma of 0.005-0.01 is enough to feel natural without being obviously tinted. (See tinted neutrals example above.)
|
||||
|
||||
### Testing
|
||||
|
||||
Don't trust your eyes. Use tools:
|
||||
|
||||
- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/)
|
||||
- Browser DevTools → Rendering → Emulate vision deficiencies
|
||||
- [Polypane](https://polypane.app/) for real-time testing
|
||||
|
||||
## Theming: Light & Dark Mode
|
||||
|
||||
### Dark Mode Is Not Inverted Light Mode
|
||||
|
||||
You can't just swap colors. Dark mode requires different design decisions:
|
||||
|
||||
| Light Mode | Dark Mode |
|
||||
|------------|-----------|
|
||||
| Shadows for depth | Lighter surfaces for depth (no shadows) |
|
||||
| Dark text on light | Light text on dark (reduce font weight) |
|
||||
| Vibrant accents | Desaturate accents slightly |
|
||||
| White backgrounds | Never pure black—use dark gray (oklch 12-18%) |
|
||||
|
||||
```css
|
||||
/* Dark mode depth via surface color, not shadow */
|
||||
:root[data-theme="dark"] {
|
||||
--surface-1: oklch(15% 0.01 250);
|
||||
--surface-2: oklch(20% 0.01 250); /* "Higher" = lighter */
|
||||
--surface-3: oklch(25% 0.01 250);
|
||||
|
||||
/* Reduce text weight slightly */
|
||||
--body-weight: 350; /* Instead of 400 */
|
||||
}
|
||||
```
|
||||
|
||||
### Token Hierarchy
|
||||
|
||||
Use two layers: primitive tokens (`--blue-500`) and semantic tokens (`--color-primary: var(--blue-500)`). For dark mode, only redefine the semantic layer—primitives stay the same.
|
||||
|
||||
## Alpha Is A Design Smell
|
||||
|
||||
Heavy use of transparency (rgba, hsla) usually means an incomplete palette. Alpha creates unpredictable contrast, performance overhead, and inconsistency. Define explicit overlay colors for each context instead. Exception: focus rings and interactive states where see-through is needed.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Relying on color alone to convey information. Creating palettes without clear roles for each color. Using pure black (#000) for large areas. Skipping color blindness testing (8% of men affected).
|
||||
@@ -0,0 +1,123 @@
|
||||
# Interaction Design
|
||||
|
||||
## The Eight Interactive States
|
||||
|
||||
Every interactive element needs these states designed:
|
||||
|
||||
| State | When | Visual Treatment |
|
||||
|-------|------|------------------|
|
||||
| **Default** | At rest | Base styling |
|
||||
| **Hover** | Pointer over (not touch) | Subtle lift, color shift |
|
||||
| **Focus** | Keyboard/programmatic focus | Visible ring (see below) |
|
||||
| **Active** | Being pressed | Pressed in, darker |
|
||||
| **Disabled** | Not interactive | Reduced opacity, no pointer |
|
||||
| **Loading** | Processing | Spinner, skeleton |
|
||||
| **Error** | Invalid state | Red border, icon, message |
|
||||
| **Success** | Completed | Green check, confirmation |
|
||||
|
||||
**The common miss**: Designing hover without focus, or vice versa. They're different. Keyboard users never see hover states.
|
||||
|
||||
## Focus Rings: Do Them Right
|
||||
|
||||
**Never `outline: none` without replacement.** It's an accessibility violation. Instead, use `:focus-visible` to show focus only for keyboard users:
|
||||
|
||||
```css
|
||||
/* Hide focus ring for mouse/touch */
|
||||
button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Show focus ring for keyboard */
|
||||
button:focus-visible {
|
||||
outline: 2px solid var(--color-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
```
|
||||
|
||||
**Focus ring design**:
|
||||
- High contrast (3:1 minimum against adjacent colors)
|
||||
- 2-3px thick
|
||||
- Offset from element (not inside it)
|
||||
- Consistent across all interactive elements
|
||||
|
||||
## Form Design: The Non-Obvious
|
||||
|
||||
**Placeholders aren't labels**—they disappear on input. Always use visible `<label>` elements. **Validate on blur**, not on every keystroke (exception: password strength). Place errors **below** fields with `aria-describedby` connecting them.
|
||||
|
||||
## Loading States
|
||||
|
||||
**Optimistic updates**: Show success immediately, rollback on failure. Use for low-stakes actions (likes, follows), not payments or destructive actions. **Skeleton screens > spinners**—they preview content shape and feel faster than generic spinners.
|
||||
|
||||
## Modals: The Inert Approach
|
||||
|
||||
Focus trapping in modals used to require complex JavaScript. Now use the `inert` attribute:
|
||||
|
||||
```html
|
||||
<!-- When modal is open -->
|
||||
<main inert>
|
||||
<!-- Content behind modal can't be focused or clicked -->
|
||||
</main>
|
||||
<dialog open>
|
||||
<h2>Modal Title</h2>
|
||||
<!-- Focus stays inside modal -->
|
||||
</dialog>
|
||||
```
|
||||
|
||||
Or use the native `<dialog>` element:
|
||||
|
||||
```javascript
|
||||
const dialog = document.querySelector('dialog');
|
||||
dialog.showModal(); // Opens with focus trap, closes on Escape
|
||||
```
|
||||
|
||||
## The Popover API
|
||||
|
||||
For tooltips, dropdowns, and non-modal overlays, use native popovers:
|
||||
|
||||
```html
|
||||
<button popovertarget="menu">Open menu</button>
|
||||
<div id="menu" popover>
|
||||
<button>Option 1</button>
|
||||
<button>Option 2</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
**Benefits**: Light-dismiss (click outside closes), proper stacking, no z-index wars, accessible by default.
|
||||
|
||||
## Destructive Actions: Undo > Confirm
|
||||
|
||||
**Undo is better than confirmation dialogs**—users click through confirmations mindlessly. Remove from UI immediately, show undo toast, actually delete after toast expires. Use confirmation only for truly irreversible actions (account deletion), high-cost actions, or batch operations.
|
||||
|
||||
## Keyboard Navigation Patterns
|
||||
|
||||
### Roving Tabindex
|
||||
|
||||
For component groups (tabs, menu items, radio groups), one item is tabbable; arrow keys move within:
|
||||
|
||||
```html
|
||||
<div role="tablist">
|
||||
<button role="tab" tabindex="0">Tab 1</button>
|
||||
<button role="tab" tabindex="-1">Tab 2</button>
|
||||
<button role="tab" tabindex="-1">Tab 3</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
Arrow keys move `tabindex="0"` between items. Tab moves to the next component entirely.
|
||||
|
||||
### Skip Links
|
||||
|
||||
Provide skip links (`<a href="#main-content">Skip to main content</a>`) for keyboard users to jump past navigation. Hide off-screen, show on focus.
|
||||
|
||||
## Gesture Discoverability
|
||||
|
||||
Swipe-to-delete and similar gestures are invisible. Hint at their existence:
|
||||
|
||||
- **Partially reveal**: Show delete button peeking from edge
|
||||
- **Onboarding**: Coach marks on first use
|
||||
- **Alternative**: Always provide a visible fallback (menu with "Delete")
|
||||
|
||||
Don't rely on gestures as the only way to perform actions.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Removing focus indicators without alternatives. Using placeholder text as labels. Touch targets <44x44px. Generic error messages. Custom controls without ARIA/keyboard support.
|
||||
@@ -0,0 +1,99 @@
|
||||
# Motion Design
|
||||
|
||||
## Duration: The 100/300/500 Rule
|
||||
|
||||
Timing matters more than easing. These durations feel right for most UI:
|
||||
|
||||
| Duration | Use Case | Examples |
|
||||
|----------|----------|----------|
|
||||
| **100-150ms** | Instant feedback | Button press, toggle, color change |
|
||||
| **200-300ms** | State changes | Menu open, tooltip, hover states |
|
||||
| **300-500ms** | Layout changes | Accordion, modal, drawer |
|
||||
| **500-800ms** | Entrance animations | Page load, hero reveals |
|
||||
|
||||
**Exit animations are faster than entrances**—use ~75% of enter duration.
|
||||
|
||||
## Easing: Pick the Right Curve
|
||||
|
||||
**Don't use `ease`.** It's a compromise that's rarely optimal. Instead:
|
||||
|
||||
| Curve | Use For | CSS |
|
||||
|-------|---------|-----|
|
||||
| **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` |
|
||||
| **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` |
|
||||
| **ease-in-out** | State toggles (there → back) | `cubic-bezier(0.65, 0, 0.35, 1)` |
|
||||
|
||||
**For micro-interactions, use exponential curves**—they feel natural because they mimic real physics (friction, deceleration):
|
||||
|
||||
```css
|
||||
/* Quart out - smooth, refined (recommended default) */
|
||||
--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
|
||||
|
||||
/* Quint out - slightly more dramatic */
|
||||
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
|
||||
/* Expo out - snappy, confident */
|
||||
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
```
|
||||
|
||||
**Avoid bounce and elastic curves.** They were trendy in 2015 but now feel tacky and amateurish. Real objects don't bounce when they stop—they decelerate smoothly. Overshoot effects draw attention to the animation itself rather than the content.
|
||||
|
||||
## The Only Two Properties You Should Animate
|
||||
|
||||
**transform** and **opacity** only—everything else causes layout recalculation. For height animations (accordions), use `grid-template-rows: 0fr → 1fr` instead of animating `height` directly.
|
||||
|
||||
## Staggered Animations
|
||||
|
||||
Use CSS custom properties for cleaner stagger: `animation-delay: calc(var(--i, 0) * 50ms)` with `style="--i: 0"` on each item. **Cap total stagger time**—10 items at 50ms = 500ms total. For many items, reduce per-item delay or cap staggered count.
|
||||
|
||||
## Reduced Motion
|
||||
|
||||
This is not optional. Vestibular disorders affect ~35% of adults over 40.
|
||||
|
||||
```css
|
||||
/* Define animations normally */
|
||||
.card {
|
||||
animation: slide-up 500ms ease-out;
|
||||
}
|
||||
|
||||
/* Provide alternative for reduced motion */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.card {
|
||||
animation: fade-in 200ms ease-out; /* Crossfade instead of motion */
|
||||
}
|
||||
}
|
||||
|
||||
/* Or disable entirely */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**What to preserve**: Functional animations like progress bars, loading spinners (slowed down), and focus indicators should still work—just without spatial movement.
|
||||
|
||||
## Perceived Performance
|
||||
|
||||
**Nobody cares how fast your site is—just how fast it feels.** Perception can be as effective as actual performance.
|
||||
|
||||
**The 80ms threshold**: Our brains buffer sensory input for ~80ms to synchronize perception. Anything under 80ms feels instant and simultaneous. This is your target for micro-interactions.
|
||||
|
||||
**Active vs passive time**: Passive waiting (staring at a spinner) feels longer than active engagement. Strategies to shift the balance:
|
||||
|
||||
- **Preemptive start**: Begin transitions immediately while loading (iOS app zoom, skeleton UI). Users perceive work happening.
|
||||
- **Early completion**: Show content progressively—don't wait for everything. Video buffering, progressive images, streaming HTML.
|
||||
- **Optimistic UI**: Update the interface immediately, handle failures gracefully. Instagram likes work offline—the UI updates instantly, syncs later. Use for low-stakes actions; avoid for payments or destructive operations.
|
||||
|
||||
**Easing affects perceived duration**: Ease-in (accelerating toward completion) makes tasks feel shorter because the peak-end effect weights final moments heavily. Ease-out feels satisfying for entrances, but ease-in toward a task's end compresses perceived time.
|
||||
|
||||
**Caution**: Too-fast responses can decrease perceived value. Users may distrust instant results for complex operations (search, analysis). Sometimes a brief delay signals "real work" is happening.
|
||||
|
||||
## Performance
|
||||
|
||||
Don't use `will-change` preemptively—only when animation is imminent (`:hover`, `.animating`). For scroll-triggered animations, use Intersection Observer instead of scroll events; unobserve after animating once. Create motion tokens for consistency (durations, easings, common transitions).
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Animating everything (animation fatigue is real). Using >500ms for UI feedback. Ignoring `prefers-reduced-motion`. Using animation to hide slow loading.
|
||||
@@ -0,0 +1,114 @@
|
||||
# Responsive Design
|
||||
|
||||
## Mobile-First: Write It Right
|
||||
|
||||
Start with base styles for mobile, use `min-width` queries to layer complexity. Desktop-first (`max-width`) means mobile loads unnecessary styles first.
|
||||
|
||||
## Breakpoints: Content-Driven
|
||||
|
||||
Don't chase device sizes—let content tell you where to break. Start narrow, stretch until design breaks, add breakpoint there. Three breakpoints usually suffice (640, 768, 1024px). Use `clamp()` for fluid values without breakpoints.
|
||||
|
||||
## Detect Input Method, Not Just Screen Size
|
||||
|
||||
**Screen size doesn't tell you input method.** A laptop with touchscreen, a tablet with keyboard—use pointer and hover queries:
|
||||
|
||||
```css
|
||||
/* Fine pointer (mouse, trackpad) */
|
||||
@media (pointer: fine) {
|
||||
.button { padding: 8px 16px; }
|
||||
}
|
||||
|
||||
/* Coarse pointer (touch, stylus) */
|
||||
@media (pointer: coarse) {
|
||||
.button { padding: 12px 20px; } /* Larger touch target */
|
||||
}
|
||||
|
||||
/* Device supports hover */
|
||||
@media (hover: hover) {
|
||||
.card:hover { transform: translateY(-2px); }
|
||||
}
|
||||
|
||||
/* Device doesn't support hover (touch) */
|
||||
@media (hover: none) {
|
||||
.card { /* No hover state - use active instead */ }
|
||||
}
|
||||
```
|
||||
|
||||
**Critical**: Don't rely on hover for functionality. Touch users can't hover.
|
||||
|
||||
## Safe Areas: Handle the Notch
|
||||
|
||||
Modern phones have notches, rounded corners, and home indicators. Use `env()`:
|
||||
|
||||
```css
|
||||
body {
|
||||
padding-top: env(safe-area-inset-top);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
padding-left: env(safe-area-inset-left);
|
||||
padding-right: env(safe-area-inset-right);
|
||||
}
|
||||
|
||||
/* With fallback */
|
||||
.footer {
|
||||
padding-bottom: max(1rem, env(safe-area-inset-bottom));
|
||||
}
|
||||
```
|
||||
|
||||
**Enable viewport-fit** in your meta tag:
|
||||
```html
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
```
|
||||
|
||||
## Responsive Images: Get It Right
|
||||
|
||||
### srcset with Width Descriptors
|
||||
|
||||
```html
|
||||
<img
|
||||
src="hero-800.jpg"
|
||||
srcset="
|
||||
hero-400.jpg 400w,
|
||||
hero-800.jpg 800w,
|
||||
hero-1200.jpg 1200w
|
||||
"
|
||||
sizes="(max-width: 768px) 100vw, 50vw"
|
||||
alt="Hero image"
|
||||
>
|
||||
```
|
||||
|
||||
**How it works**:
|
||||
- `srcset` lists available images with their actual widths (`w` descriptors)
|
||||
- `sizes` tells the browser how wide the image will display
|
||||
- Browser picks the best file based on viewport width AND device pixel ratio
|
||||
|
||||
### Picture Element for Art Direction
|
||||
|
||||
When you need different crops/compositions (not just resolutions):
|
||||
|
||||
```html
|
||||
<picture>
|
||||
<source media="(min-width: 768px)" srcset="wide.jpg">
|
||||
<source media="(max-width: 767px)" srcset="tall.jpg">
|
||||
<img src="fallback.jpg" alt="...">
|
||||
</picture>
|
||||
```
|
||||
|
||||
## Layout Adaptation Patterns
|
||||
|
||||
**Navigation**: Three stages—hamburger + drawer on mobile, horizontal compact on tablet, full with labels on desktop. **Tables**: Transform to cards on mobile using `display: block` and `data-label` attributes. **Progressive disclosure**: Use `<details>/<summary>` for content that can collapse on mobile.
|
||||
|
||||
## Testing: Don't Trust DevTools Alone
|
||||
|
||||
DevTools device emulation is useful for layout but misses:
|
||||
|
||||
- Actual touch interactions
|
||||
- Real CPU/memory constraints
|
||||
- Network latency patterns
|
||||
- Font rendering differences
|
||||
- Browser chrome/keyboard appearances
|
||||
|
||||
**Test on at least**: One real iPhone, one real Android, a tablet if relevant. Cheap Android phones reveal performance issues you'll never see on simulators.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Desktop-first design. Device detection instead of feature detection. Separate mobile/desktop codebases. Ignoring tablet and landscape. Assuming all mobile devices are powerful.
|
||||
@@ -0,0 +1,100 @@
|
||||
# Spatial Design
|
||||
|
||||
## Spacing Systems
|
||||
|
||||
### Use 4pt Base, Not 8pt
|
||||
|
||||
8pt systems are too coarse—you'll frequently need 12px (between 8 and 16). Use 4pt for granularity: 4, 8, 12, 16, 24, 32, 48, 64, 96px.
|
||||
|
||||
### Name Tokens Semantically
|
||||
|
||||
Name by relationship (`--space-sm`, `--space-lg`), not value (`--spacing-8`). Use `gap` instead of margins for sibling spacing—it eliminates margin collapse and cleanup hacks.
|
||||
|
||||
## Grid Systems
|
||||
|
||||
### The Self-Adjusting Grid
|
||||
|
||||
Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints. Columns are at least 280px, as many as fit per row, leftovers stretch. For complex layouts, use named grid areas (`grid-template-areas`) and redefine them at breakpoints.
|
||||
|
||||
## Visual Hierarchy
|
||||
|
||||
### The Squint Test
|
||||
|
||||
Blur your eyes (or screenshot and blur). Can you still identify:
|
||||
- The most important element?
|
||||
- The second most important?
|
||||
- Clear groupings?
|
||||
|
||||
If everything looks the same weight blurred, you have a hierarchy problem.
|
||||
|
||||
### Hierarchy Through Multiple Dimensions
|
||||
|
||||
Don't rely on size alone. Combine:
|
||||
|
||||
| Tool | Strong Hierarchy | Weak Hierarchy |
|
||||
|------|------------------|----------------|
|
||||
| **Size** | 3:1 ratio or more | <2:1 ratio |
|
||||
| **Weight** | Bold vs Regular | Medium vs Regular |
|
||||
| **Color** | High contrast | Similar tones |
|
||||
| **Position** | Top/left (primary) | Bottom/right |
|
||||
| **Space** | Surrounded by white space | Crowded |
|
||||
|
||||
**The best hierarchy uses 2-3 dimensions at once**: A heading that's larger, bolder, AND has more space above it.
|
||||
|
||||
### Cards Are Not Required
|
||||
|
||||
Cards are overused. Spacing and alignment create visual grouping naturally. Use cards only when content is truly distinct and actionable, items need visual comparison in a grid, or content needs clear interaction boundaries. **Never nest cards inside cards**—use spacing, typography, and subtle dividers for hierarchy within a card.
|
||||
|
||||
## Container Queries
|
||||
|
||||
Viewport queries are for page layouts. **Container queries are for components**:
|
||||
|
||||
```css
|
||||
.card-container {
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: grid;
|
||||
gap: var(--space-md);
|
||||
}
|
||||
|
||||
/* Card layout changes based on its container, not viewport */
|
||||
@container (min-width: 400px) {
|
||||
.card {
|
||||
grid-template-columns: 120px 1fr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Why this matters**: A card in a narrow sidebar stays compact, while the same card in a main content area expands—automatically, without viewport hacks.
|
||||
|
||||
## Optical Adjustments
|
||||
|
||||
Text at `margin-left: 0` looks indented due to letterform whitespace—use negative margin (`-0.05em`) to optically align. Geometrically centered icons often look off-center; play icons need to shift right, arrows shift toward their direction.
|
||||
|
||||
### Touch Targets vs Visual Size
|
||||
|
||||
Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements:
|
||||
|
||||
```css
|
||||
.icon-button {
|
||||
width: 24px; /* Visual size */
|
||||
height: 24px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.icon-button::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -10px; /* Expand tap target to 44px */
|
||||
}
|
||||
```
|
||||
|
||||
## Depth & Elevation
|
||||
|
||||
Create semantic z-index scales (dropdown → sticky → modal-backdrop → modal → toast → tooltip) instead of arbitrary numbers. For shadows, create a consistent elevation scale (sm → md → lg → xl). **Key insight**: Shadows should be subtle—if you can clearly see it, it's probably too strong.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Arbitrary spacing values outside your scale. Making all spacing equal (variety creates hierarchy). Creating hierarchy through size alone - combine size, weight, color, and space.
|
||||
@@ -0,0 +1,133 @@
|
||||
# Typography
|
||||
|
||||
## Classic Typography Principles
|
||||
|
||||
### Vertical Rhythm
|
||||
|
||||
Your line-height should be the base unit for ALL vertical spacing. If body text has `line-height: 1.5` on `16px` type (= 24px), spacing values should be multiples of 24px. This creates subconscious harmony—text and space share a mathematical foundation.
|
||||
|
||||
### Modular Scale & Hierarchy
|
||||
|
||||
The common mistake: too many font sizes that are too close together (14px, 15px, 16px, 18px...). This creates muddy hierarchy.
|
||||
|
||||
**Use fewer sizes with more contrast.** A 5-size system covers most needs:
|
||||
|
||||
| Role | Typical Ratio | Use Case |
|
||||
|------|---------------|----------|
|
||||
| xs | 0.75rem | Captions, legal |
|
||||
| sm | 0.875rem | Secondary UI, metadata |
|
||||
| base | 1rem | Body text |
|
||||
| lg | 1.25-1.5rem | Subheadings, lead text |
|
||||
| xl+ | 2-4rem | Headlines, hero text |
|
||||
|
||||
Popular ratios: 1.25 (major third), 1.333 (perfect fourth), 1.5 (perfect fifth). Pick one and commit.
|
||||
|
||||
### Readability & Measure
|
||||
|
||||
Use `ch` units for character-based measure (`max-width: 65ch`). Line-height scales inversely with line length—narrow columns need tighter leading, wide columns need more.
|
||||
|
||||
**Non-obvious**: Increase line-height for light text on dark backgrounds. The perceived weight is lighter, so text needs more breathing room. Add 0.05-0.1 to your normal line-height.
|
||||
|
||||
## Font Selection & Pairing
|
||||
|
||||
### Choosing Distinctive Fonts
|
||||
|
||||
**Avoid the invisible defaults**: Inter, Roboto, Open Sans, Lato, Montserrat. These are everywhere, making your design feel generic. They're fine for documentation or tools where personality isn't the goal—but if you want distinctive design, look elsewhere.
|
||||
|
||||
**Better Google Fonts alternatives**:
|
||||
- Instead of Inter → **Instrument Sans**, **Plus Jakarta Sans**, **Outfit**
|
||||
- Instead of Roboto → **Onest**, **Figtree**, **Urbanist**
|
||||
- Instead of Open Sans → **Source Sans 3**, **Nunito Sans**, **DM Sans**
|
||||
- For editorial/premium feel → **Fraunces**, **Newsreader**, **Lora**
|
||||
|
||||
**System fonts are underrated**: `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui` looks native, loads instantly, and is highly readable. Consider this for apps where performance > personality.
|
||||
|
||||
### Pairing Principles
|
||||
|
||||
**The non-obvious truth**: You often don't need a second font. One well-chosen font family in multiple weights creates cleaner hierarchy than two competing typefaces. Only add a second font when you need genuine contrast (e.g., display headlines + body serif).
|
||||
|
||||
When pairing, contrast on multiple axes:
|
||||
- Serif + Sans (structure contrast)
|
||||
- Geometric + Humanist (personality contrast)
|
||||
- Condensed display + Wide body (proportion contrast)
|
||||
|
||||
**Never pair fonts that are similar but not identical** (e.g., two geometric sans-serifs). They create visual tension without clear hierarchy.
|
||||
|
||||
### Web Font Loading
|
||||
|
||||
The layout shift problem: fonts load late, text reflows, and users see content jump. Here's the fix:
|
||||
|
||||
```css
|
||||
/* 1. Use font-display: swap for visibility */
|
||||
@font-face {
|
||||
font-family: 'CustomFont';
|
||||
src: url('font.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
/* 2. Match fallback metrics to minimize shift */
|
||||
@font-face {
|
||||
font-family: 'CustomFont-Fallback';
|
||||
src: local('Arial');
|
||||
size-adjust: 105%; /* Scale to match x-height */
|
||||
ascent-override: 90%; /* Match ascender height */
|
||||
descent-override: 20%; /* Match descender depth */
|
||||
line-gap-override: 10%; /* Match line spacing */
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'CustomFont', 'CustomFont-Fallback', sans-serif;
|
||||
}
|
||||
```
|
||||
|
||||
Tools like [Fontaine](https://github.com/unjs/fontaine) calculate these overrides automatically.
|
||||
|
||||
## Modern Web Typography
|
||||
|
||||
### Fluid Type
|
||||
|
||||
Fluid typography via `clamp(min, preferred, max)` scales text smoothly with the viewport. The middle value (e.g., `5vw + 1rem`) controls scaling rate—higher vw = faster scaling. Add a rem offset so it doesn't collapse to 0 on small screens.
|
||||
|
||||
**Use fluid type for**: Headings and display text on marketing/content pages where text dominates the layout and needs to breathe across viewport sizes.
|
||||
|
||||
**Use fixed `rem` scales for**: App UIs, dashboards, and data-dense interfaces. No major app design system (Material, Polaris, Primer, Carbon) uses fluid type in product UI — fixed scales with optional breakpoint adjustments give the spatial predictability that container-based layouts need. Body text should also be fixed even on marketing pages, since the size difference across viewports is too small to warrant it.
|
||||
|
||||
### OpenType Features
|
||||
|
||||
Most developers don't know these exist. Use them for polish:
|
||||
|
||||
```css
|
||||
/* Tabular numbers for data alignment */
|
||||
.data-table { font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* Proper fractions */
|
||||
.recipe-amount { font-variant-numeric: diagonal-fractions; }
|
||||
|
||||
/* Small caps for abbreviations */
|
||||
abbr { font-variant-caps: all-small-caps; }
|
||||
|
||||
/* Disable ligatures in code */
|
||||
code { font-variant-ligatures: none; }
|
||||
|
||||
/* Enable kerning (usually on by default, but be explicit) */
|
||||
body { font-kerning: normal; }
|
||||
```
|
||||
|
||||
Check what features your font supports at [Wakamai Fondue](https://wakamaifondue.com/).
|
||||
|
||||
## Typography System Architecture
|
||||
|
||||
Name tokens semantically (`--text-body`, `--text-heading`), not by value (`--font-size-16`). Include font stacks, size scale, weights, line-heights, and letter-spacing in your token system.
|
||||
|
||||
## Accessibility Considerations
|
||||
|
||||
Beyond contrast ratios (which are well-documented), consider:
|
||||
|
||||
- **Never disable zoom**: `user-scalable=no` breaks accessibility. If your layout breaks at 200% zoom, fix the layout.
|
||||
- **Use rem/em for font sizes**: This respects user browser settings. Never `px` for body text.
|
||||
- **Minimum 16px body text**: Smaller than this strains eyes and fails WCAG on mobile.
|
||||
- **Adequate touch targets**: Text links need padding or line-height that creates 44px+ tap targets.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: More than 2-3 font families per project. Skipping fallback font definitions. Ignoring font loading performance (FOUT/FOIT). Using decorative fonts for body text.
|
||||
@@ -0,0 +1,107 @@
|
||||
# UX Writing
|
||||
|
||||
## The Button Label Problem
|
||||
|
||||
**Never use "OK", "Submit", or "Yes/No".** These are lazy and ambiguous. Use specific verb + object patterns:
|
||||
|
||||
| Bad | Good | Why |
|
||||
|-----|------|-----|
|
||||
| OK | Save changes | Says what will happen |
|
||||
| Submit | Create account | Outcome-focused |
|
||||
| Yes | Delete message | Confirms the action |
|
||||
| Cancel | Keep editing | Clarifies what "cancel" means |
|
||||
| Click here | Download PDF | Describes the destination |
|
||||
|
||||
**For destructive actions**, name the destruction:
|
||||
- "Delete" not "Remove" (delete is permanent, remove implies recoverable)
|
||||
- "Delete 5 items" not "Delete selected" (show the count)
|
||||
|
||||
## Error Messages: The Formula
|
||||
|
||||
Every error message should answer: (1) What happened? (2) Why? (3) How to fix it? Example: "Email address isn't valid. Please include an @ symbol." not "Invalid input".
|
||||
|
||||
### Error Message Templates
|
||||
|
||||
| Situation | Template |
|
||||
|-----------|----------|
|
||||
| **Format error** | "[Field] needs to be [format]. Example: [example]" |
|
||||
| **Missing required** | "Please enter [what's missing]" |
|
||||
| **Permission denied** | "You don't have access to [thing]. [What to do instead]" |
|
||||
| **Network error** | "We couldn't reach [thing]. Check your connection and [action]." |
|
||||
| **Server error** | "Something went wrong on our end. We're looking into it. [Alternative action]" |
|
||||
|
||||
### Don't Blame the User
|
||||
|
||||
Reframe errors: "Please enter a date in MM/DD/YYYY format" not "You entered an invalid date".
|
||||
|
||||
## Empty States Are Opportunities
|
||||
|
||||
Empty states are onboarding moments: (1) Acknowledge briefly, (2) Explain the value of filling it, (3) Provide a clear action. "No projects yet. Create your first one to get started." not just "No items".
|
||||
|
||||
## Voice vs Tone
|
||||
|
||||
**Voice** is your brand's personality—consistent everywhere.
|
||||
**Tone** adapts to the moment.
|
||||
|
||||
| Moment | Tone Shift |
|
||||
|--------|------------|
|
||||
| Success | Celebratory, brief: "Done! Your changes are live." |
|
||||
| Error | Empathetic, helpful: "That didn't work. Here's what to try..." |
|
||||
| Loading | Reassuring: "Saving your work..." |
|
||||
| Destructive confirm | Serious, clear: "Delete this project? This can't be undone." |
|
||||
|
||||
**Never use humor for errors.** Users are already frustrated. Be helpful, not cute.
|
||||
|
||||
## Writing for Accessibility
|
||||
|
||||
**Link text** must have standalone meaning—"View pricing plans" not "Click here". **Alt text** describes information, not the image—"Revenue increased 40% in Q4" not "Chart". Use `alt=""` for decorative images. **Icon buttons** need `aria-label` for screen reader context.
|
||||
|
||||
## Writing for Translation
|
||||
|
||||
### Plan for Expansion
|
||||
|
||||
German text is ~30% longer than English. Allocate space:
|
||||
|
||||
| Language | Expansion |
|
||||
|----------|-----------|
|
||||
| German | +30% |
|
||||
| French | +20% |
|
||||
| Finnish | +30-40% |
|
||||
| Chinese | -30% (fewer chars, but same width) |
|
||||
|
||||
### Translation-Friendly Patterns
|
||||
|
||||
Keep numbers separate ("New messages: 3" not "You have 3 new messages"). Use full sentences as single strings (word order varies by language). Avoid abbreviations ("5 minutes ago" not "5 mins ago"). Give translators context about where strings appear.
|
||||
|
||||
## Consistency: The Terminology Problem
|
||||
|
||||
Pick one term and stick with it:
|
||||
|
||||
| Inconsistent | Consistent |
|
||||
|--------------|------------|
|
||||
| Delete / Remove / Trash | Delete |
|
||||
| Settings / Preferences / Options | Settings |
|
||||
| Sign in / Log in / Enter | Sign in |
|
||||
| Create / Add / New | Create |
|
||||
|
||||
Build a terminology glossary and enforce it. Variety creates confusion.
|
||||
|
||||
## Avoid Redundant Copy
|
||||
|
||||
If the heading explains it, the intro is redundant. If the button is clear, don't explain it again. Say it once, say it well.
|
||||
|
||||
## Loading States
|
||||
|
||||
Be specific: "Saving your draft..." not "Loading...". For long waits, set expectations ("This usually takes 30 seconds") or show progress.
|
||||
|
||||
## Confirmation Dialogs: Use Sparingly
|
||||
|
||||
Most confirmation dialogs are design failures—consider undo instead. When you must confirm: name the action, explain consequences, use specific button labels ("Delete project" / "Keep project", not "Yes" / "No").
|
||||
|
||||
## Form Instructions
|
||||
|
||||
Show format with placeholders, not instructions. For non-obvious fields, explain why you're asking.
|
||||
|
||||
---
|
||||
|
||||
**Avoid**: Jargon without explanation. Blaming users ("You made an error" → "This field is required"). Vague errors ("Something went wrong"). Varying terminology for variety. Humor for errors.
|
||||
@@ -0,0 +1,354 @@
|
||||
---
|
||||
name: harden
|
||||
description: Improve interface resilience through better error handling, i18n support, text overflow handling, and edge case management. Makes interfaces robust and production-ready.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Strengthen interfaces against edge cases, errors, internationalization issues, and real-world usage scenarios that break idealized designs.
|
||||
|
||||
## Assess Hardening Needs
|
||||
|
||||
Identify weaknesses and edge cases:
|
||||
|
||||
1. **Test with extreme inputs**:
|
||||
- Very long text (names, descriptions, titles)
|
||||
- Very short text (empty, single character)
|
||||
- Special characters (emoji, RTL text, accents)
|
||||
- Large numbers (millions, billions)
|
||||
- Many items (1000+ list items, 50+ options)
|
||||
- No data (empty states)
|
||||
|
||||
2. **Test error scenarios**:
|
||||
- Network failures (offline, slow, timeout)
|
||||
- API errors (400, 401, 403, 404, 500)
|
||||
- Validation errors
|
||||
- Permission errors
|
||||
- Rate limiting
|
||||
- Concurrent operations
|
||||
|
||||
3. **Test internationalization**:
|
||||
- Long translations (German is often 30% longer than English)
|
||||
- RTL languages (Arabic, Hebrew)
|
||||
- Character sets (Chinese, Japanese, Korean, emoji)
|
||||
- Date/time formats
|
||||
- Number formats (1,000 vs 1.000)
|
||||
- Currency symbols
|
||||
|
||||
**CRITICAL**: Designs that only work with perfect data aren't production-ready. Harden against reality.
|
||||
|
||||
## Hardening Dimensions
|
||||
|
||||
Systematically improve resilience:
|
||||
|
||||
### Text Overflow & Wrapping
|
||||
|
||||
**Long text handling**:
|
||||
```css
|
||||
/* Single line with ellipsis */
|
||||
.truncate {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Multi-line with clamp */
|
||||
.line-clamp {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Allow wrapping */
|
||||
.wrap {
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
hyphens: auto;
|
||||
}
|
||||
```
|
||||
|
||||
**Flex/Grid overflow**:
|
||||
```css
|
||||
/* Prevent flex items from overflowing */
|
||||
.flex-item {
|
||||
min-width: 0; /* Allow shrinking below content size */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Prevent grid items from overflowing */
|
||||
.grid-item {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
```
|
||||
|
||||
**Responsive text sizing**:
|
||||
- Use `clamp()` for fluid typography
|
||||
- Set minimum readable sizes (14px on mobile)
|
||||
- Test text scaling (zoom to 200%)
|
||||
- Ensure containers expand with text
|
||||
|
||||
### Internationalization (i18n)
|
||||
|
||||
**Text expansion**:
|
||||
- Add 30-40% space budget for translations
|
||||
- Use flexbox/grid that adapts to content
|
||||
- Test with longest language (usually German)
|
||||
- Avoid fixed widths on text containers
|
||||
|
||||
```jsx
|
||||
// ❌ Bad: Assumes short English text
|
||||
<button className="w-24">Submit</button>
|
||||
|
||||
// ✅ Good: Adapts to content
|
||||
<button className="px-4 py-2">Submit</button>
|
||||
```
|
||||
|
||||
**RTL (Right-to-Left) support**:
|
||||
```css
|
||||
/* Use logical properties */
|
||||
margin-inline-start: 1rem; /* Not margin-left */
|
||||
padding-inline: 1rem; /* Not padding-left/right */
|
||||
border-inline-end: 1px solid; /* Not border-right */
|
||||
|
||||
/* Or use dir attribute */
|
||||
[dir="rtl"] .arrow { transform: scaleX(-1); }
|
||||
```
|
||||
|
||||
**Character set support**:
|
||||
- Use UTF-8 encoding everywhere
|
||||
- Test with Chinese/Japanese/Korean (CJK) characters
|
||||
- Test with emoji (they can be 2-4 bytes)
|
||||
- Handle different scripts (Latin, Cyrillic, Arabic, etc.)
|
||||
|
||||
**Date/Time formatting**:
|
||||
```javascript
|
||||
// ✅ Use Intl API for proper formatting
|
||||
new Intl.DateTimeFormat('en-US').format(date); // 1/15/2024
|
||||
new Intl.DateTimeFormat('de-DE').format(date); // 15.1.2024
|
||||
|
||||
new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD'
|
||||
}).format(1234.56); // $1,234.56
|
||||
```
|
||||
|
||||
**Pluralization**:
|
||||
```javascript
|
||||
// ❌ Bad: Assumes English pluralization
|
||||
`${count} item${count !== 1 ? 's' : ''}`
|
||||
|
||||
// ✅ Good: Use proper i18n library
|
||||
t('items', { count }) // Handles complex plural rules
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
**Network errors**:
|
||||
- Show clear error messages
|
||||
- Provide retry button
|
||||
- Explain what happened
|
||||
- Offer offline mode (if applicable)
|
||||
- Handle timeout scenarios
|
||||
|
||||
```jsx
|
||||
// Error states with recovery
|
||||
{error && (
|
||||
<ErrorMessage>
|
||||
<p>Failed to load data. {error.message}</p>
|
||||
<button onClick={retry}>Try again</button>
|
||||
</ErrorMessage>
|
||||
)}
|
||||
```
|
||||
|
||||
**Form validation errors**:
|
||||
- Inline errors near fields
|
||||
- Clear, specific messages
|
||||
- Suggest corrections
|
||||
- Don't block submission unnecessarily
|
||||
- Preserve user input on error
|
||||
|
||||
**API errors**:
|
||||
- Handle each status code appropriately
|
||||
- 400: Show validation errors
|
||||
- 401: Redirect to login
|
||||
- 403: Show permission error
|
||||
- 404: Show not found state
|
||||
- 429: Show rate limit message
|
||||
- 500: Show generic error, offer support
|
||||
|
||||
**Graceful degradation**:
|
||||
- Core functionality works without JavaScript
|
||||
- Images have alt text
|
||||
- Progressive enhancement
|
||||
- Fallbacks for unsupported features
|
||||
|
||||
### Edge Cases & Boundary Conditions
|
||||
|
||||
**Empty states**:
|
||||
- No items in list
|
||||
- No search results
|
||||
- No notifications
|
||||
- No data to display
|
||||
- Provide clear next action
|
||||
|
||||
**Loading states**:
|
||||
- Initial load
|
||||
- Pagination load
|
||||
- Refresh
|
||||
- Show what's loading ("Loading your projects...")
|
||||
- Time estimates for long operations
|
||||
|
||||
**Large datasets**:
|
||||
- Pagination or virtual scrolling
|
||||
- Search/filter capabilities
|
||||
- Performance optimization
|
||||
- Don't load all 10,000 items at once
|
||||
|
||||
**Concurrent operations**:
|
||||
- Prevent double-submission (disable button while loading)
|
||||
- Handle race conditions
|
||||
- Optimistic updates with rollback
|
||||
- Conflict resolution
|
||||
|
||||
**Permission states**:
|
||||
- No permission to view
|
||||
- No permission to edit
|
||||
- Read-only mode
|
||||
- Clear explanation of why
|
||||
|
||||
**Browser compatibility**:
|
||||
- Polyfills for modern features
|
||||
- Fallbacks for unsupported CSS
|
||||
- Feature detection (not browser detection)
|
||||
- Test in target browsers
|
||||
|
||||
### Input Validation & Sanitization
|
||||
|
||||
**Client-side validation**:
|
||||
- Required fields
|
||||
- Format validation (email, phone, URL)
|
||||
- Length limits
|
||||
- Pattern matching
|
||||
- Custom validation rules
|
||||
|
||||
**Server-side validation** (always):
|
||||
- Never trust client-side only
|
||||
- Validate and sanitize all inputs
|
||||
- Protect against injection attacks
|
||||
- Rate limiting
|
||||
|
||||
**Constraint handling**:
|
||||
```html
|
||||
<!-- Set clear constraints -->
|
||||
<input
|
||||
type="text"
|
||||
maxlength="100"
|
||||
pattern="[A-Za-z0-9]+"
|
||||
required
|
||||
aria-describedby="username-hint"
|
||||
/>
|
||||
<small id="username-hint">
|
||||
Letters and numbers only, up to 100 characters
|
||||
</small>
|
||||
```
|
||||
|
||||
### Accessibility Resilience
|
||||
|
||||
**Keyboard navigation**:
|
||||
- All functionality accessible via keyboard
|
||||
- Logical tab order
|
||||
- Focus management in modals
|
||||
- Skip links for long content
|
||||
|
||||
**Screen reader support**:
|
||||
- Proper ARIA labels
|
||||
- Announce dynamic changes (live regions)
|
||||
- Descriptive alt text
|
||||
- Semantic HTML
|
||||
|
||||
**Motion sensitivity**:
|
||||
```css
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**High contrast mode**:
|
||||
- Test in Windows high contrast mode
|
||||
- Don't rely only on color
|
||||
- Provide alternative visual cues
|
||||
|
||||
### Performance Resilience
|
||||
|
||||
**Slow connections**:
|
||||
- Progressive image loading
|
||||
- Skeleton screens
|
||||
- Optimistic UI updates
|
||||
- Offline support (service workers)
|
||||
|
||||
**Memory leaks**:
|
||||
- Clean up event listeners
|
||||
- Cancel subscriptions
|
||||
- Clear timers/intervals
|
||||
- Abort pending requests on unmount
|
||||
|
||||
**Throttling & Debouncing**:
|
||||
```javascript
|
||||
// Debounce search input
|
||||
const debouncedSearch = debounce(handleSearch, 300);
|
||||
|
||||
// Throttle scroll handler
|
||||
const throttledScroll = throttle(handleScroll, 100);
|
||||
```
|
||||
|
||||
## Testing Strategies
|
||||
|
||||
**Manual testing**:
|
||||
- Test with extreme data (very long, very short, empty)
|
||||
- Test in different languages
|
||||
- Test offline
|
||||
- Test slow connection (throttle to 3G)
|
||||
- Test with screen reader
|
||||
- Test keyboard-only navigation
|
||||
- Test on old browsers
|
||||
|
||||
**Automated testing**:
|
||||
- Unit tests for edge cases
|
||||
- Integration tests for error scenarios
|
||||
- E2E tests for critical paths
|
||||
- Visual regression tests
|
||||
- Accessibility tests (axe, WAVE)
|
||||
|
||||
**IMPORTANT**: Hardening is about expecting the unexpected. Real users will do things you never imagined.
|
||||
|
||||
**NEVER**:
|
||||
- Assume perfect input (validate everything)
|
||||
- Ignore internationalization (design for global)
|
||||
- Leave error messages generic ("Error occurred")
|
||||
- Forget offline scenarios
|
||||
- Trust client-side validation alone
|
||||
- Use fixed widths for text
|
||||
- Assume English-length text
|
||||
- Block entire interface when one component errors
|
||||
|
||||
## Verify Hardening
|
||||
|
||||
Test thoroughly with edge cases:
|
||||
|
||||
- **Long text**: Try names with 100+ characters
|
||||
- **Emoji**: Use emoji in all text fields
|
||||
- **RTL**: Test with Arabic or Hebrew
|
||||
- **CJK**: Test with Chinese/Japanese/Korean
|
||||
- **Network issues**: Disable internet, throttle connection
|
||||
- **Large datasets**: Test with 1000+ items
|
||||
- **Concurrent actions**: Click submit 10 times rapidly
|
||||
- **Errors**: Force API errors, test all error states
|
||||
- **Empty**: Remove all data, test empty states
|
||||
|
||||
Remember: You're hardening for production reality, not demo perfection. Expect users to input weird data, lose connection mid-flow, and use your product in unexpected ways. Build resilience into every component.
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
name: normalize
|
||||
description: Normalize design to match your design system and ensure consistency
|
||||
user-invocable: true
|
||||
argument-hint: [FEATURE=<value>]
|
||||
---
|
||||
|
||||
Analyze and redesign the feature to perfectly match our design system standards, aesthetics, and established patterns.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Plan
|
||||
|
||||
Before making changes, deeply understand the context:
|
||||
|
||||
1. **Discover the design system**: Search for design system documentation, UI guidelines, component libraries, or style guides (grep for "design system", "ui guide", "style guide", etc.). Study it thoroughly until you understand:
|
||||
- Core design principles and aesthetic direction
|
||||
- Target audience and personas
|
||||
- Component patterns and conventions
|
||||
- Design tokens (colors, typography, spacing)
|
||||
|
||||
**CRITICAL**: If something isn't clear, ask. Don't guess at design system principles.
|
||||
|
||||
2. **Analyze the current feature**: Assess what works and what doesn't:
|
||||
- Where does it deviate from design system patterns?
|
||||
- Which inconsistencies are cosmetic vs. functional?
|
||||
- What's the root cause—missing tokens, one-off implementations, or conceptual misalignment?
|
||||
|
||||
3. **Create a normalization plan**: Define specific changes that will align the feature with the design system:
|
||||
- Which components can be replaced with design system equivalents?
|
||||
- Which styles need to use design tokens instead of hard-coded values?
|
||||
- How can UX patterns match established user flows?
|
||||
|
||||
**IMPORTANT**: Great design is effective design. Prioritize UX consistency and usability over visual polish alone. Think through the best possible experience for your use case and personas first.
|
||||
|
||||
## Execute
|
||||
|
||||
Systematically address all inconsistencies across these dimensions:
|
||||
|
||||
- **Typography**: Use design system fonts, sizes, weights, and line heights. Replace hard-coded values with typographic tokens or classes.
|
||||
- **Color & Theme**: Apply design system color tokens. Remove one-off color choices that break the palette.
|
||||
- **Spacing & Layout**: Use spacing tokens (margins, padding, gaps). Align with grid systems and layout patterns used elsewhere.
|
||||
- **Components**: Replace custom implementations with design system components. Ensure props and variants match established patterns.
|
||||
- **Motion & Interaction**: Match animation timing, easing, and interaction patterns to other features.
|
||||
- **Responsive Behavior**: Ensure breakpoints and responsive patterns align with design system standards.
|
||||
- **Accessibility**: Verify contrast ratios, focus states, ARIA labels match design system requirements.
|
||||
- **Progressive Disclosure**: Match information hierarchy and complexity management to established patterns.
|
||||
|
||||
**NEVER**:
|
||||
- Create new one-off components when design system equivalents exist
|
||||
- Hard-code values that should use design tokens
|
||||
- Introduce new patterns that diverge from the design system
|
||||
- Compromise accessibility for visual consistency
|
||||
|
||||
This is not an exhaustive list—apply judgment to identify all areas needing normalization.
|
||||
|
||||
## Clean Up
|
||||
|
||||
After normalization, ensure code quality:
|
||||
|
||||
- **Consolidate reusable components**: If you created new components that should be shared, move them to the design system or shared UI component path.
|
||||
- **Remove orphaned code**: Delete unused implementations, styles, or files made obsolete by normalization.
|
||||
- **Verify quality**: Lint, type-check, and test according to repository guidelines. Ensure normalization didn't introduce regressions.
|
||||
- **Ensure DRYness**: Look for duplication introduced during refactoring and consolidate.
|
||||
|
||||
Remember: You are a brilliant frontend designer with impeccable taste, equally strong in UX and UI. Your attention to detail and eye for end-to-end user experience is world class. Execute with precision and thoroughness.
|
||||
@@ -0,0 +1,245 @@
|
||||
---
|
||||
name: onboard
|
||||
description: Design or improve onboarding flows, empty states, and first-time user experiences. Helps users get started successfully and understand value quickly.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: the "aha moment" you want users to reach, and users' experience level.
|
||||
|
||||
---
|
||||
|
||||
Create or improve onboarding experiences that help users understand, adopt, and succeed with the product quickly.
|
||||
|
||||
## Assess Onboarding Needs
|
||||
|
||||
Understand what users need to learn and why:
|
||||
|
||||
1. **Identify the challenge**:
|
||||
- What are users trying to accomplish?
|
||||
- What's confusing or unclear about current experience?
|
||||
- Where do users get stuck or drop off?
|
||||
- What's the "aha moment" we want users to reach?
|
||||
|
||||
2. **Understand the users**:
|
||||
- What's their experience level? (Beginners, power users, mixed?)
|
||||
- What's their motivation? (Excited and exploring? Required by work?)
|
||||
- What's their time commitment? (5 minutes? 30 minutes?)
|
||||
- What alternatives do they know? (Coming from competitor? New to category?)
|
||||
|
||||
3. **Define success**:
|
||||
- What's the minimum users need to learn to be successful?
|
||||
- What's the key action we want them to take? (First project? First invite?)
|
||||
- How do we know onboarding worked? (Completion rate? Time to value?)
|
||||
|
||||
**CRITICAL**: Onboarding should get users to value as quickly as possible, not teach everything possible.
|
||||
|
||||
## Onboarding Principles
|
||||
|
||||
Follow these core principles:
|
||||
|
||||
### Show, Don't Tell
|
||||
- Demonstrate with working examples, not just descriptions
|
||||
- Provide real functionality in onboarding, not separate tutorial mode
|
||||
- Use progressive disclosure - teach one thing at a time
|
||||
|
||||
### Make It Optional (When Possible)
|
||||
- Let experienced users skip onboarding
|
||||
- Don't block access to product
|
||||
- Provide "Skip" or "I'll explore on my own" options
|
||||
|
||||
### Time to Value
|
||||
- Get users to their "aha moment" ASAP
|
||||
- Front-load most important concepts
|
||||
- Teach 20% that delivers 80% of value
|
||||
- Save advanced features for contextual discovery
|
||||
|
||||
### Context Over Ceremony
|
||||
- Teach features when users need them, not upfront
|
||||
- Empty states are onboarding opportunities
|
||||
- Tooltips and hints at point of use
|
||||
|
||||
### Respect User Intelligence
|
||||
- Don't patronize or over-explain
|
||||
- Be concise and clear
|
||||
- Assume users can figure out standard patterns
|
||||
|
||||
## Design Onboarding Experiences
|
||||
|
||||
Create appropriate onboarding for the context:
|
||||
|
||||
### Initial Product Onboarding
|
||||
|
||||
**Welcome Screen**:
|
||||
- Clear value proposition (what is this product?)
|
||||
- What users will learn/accomplish
|
||||
- Time estimate (honest about commitment)
|
||||
- Option to skip (for experienced users)
|
||||
|
||||
**Account Setup**:
|
||||
- Minimal required information (collect more later)
|
||||
- Explain why you're asking for each piece of information
|
||||
- Smart defaults where possible
|
||||
- Social login when appropriate
|
||||
|
||||
**Core Concept Introduction**:
|
||||
- Introduce 1-3 core concepts (not everything)
|
||||
- Use simple language and examples
|
||||
- Interactive when possible (do, don't just read)
|
||||
- Progress indication (step 1 of 3)
|
||||
|
||||
**First Success**:
|
||||
- Guide users to accomplish something real
|
||||
- Pre-populated examples or templates
|
||||
- Celebrate completion (but don't overdo it)
|
||||
- Clear next steps
|
||||
|
||||
### Feature Discovery & Adoption
|
||||
|
||||
**Empty States**:
|
||||
Instead of blank space, show:
|
||||
- What will appear here (description + screenshot/illustration)
|
||||
- Why it's valuable
|
||||
- Clear CTA to create first item
|
||||
- Example or template option
|
||||
|
||||
Example:
|
||||
```
|
||||
No projects yet
|
||||
Projects help you organize your work and collaborate with your team.
|
||||
[Create your first project] or [Start from template]
|
||||
```
|
||||
|
||||
**Contextual Tooltips**:
|
||||
- Appear at relevant moment (first time user sees feature)
|
||||
- Point directly at relevant UI element
|
||||
- Brief explanation + benefit
|
||||
- Dismissable (with "Don't show again" option)
|
||||
- Optional "Learn more" link
|
||||
|
||||
**Feature Announcements**:
|
||||
- Highlight new features when they're released
|
||||
- Show what's new and why it matters
|
||||
- Let users try immediately
|
||||
- Dismissable
|
||||
|
||||
**Progressive Onboarding**:
|
||||
- Teach features when users encounter them
|
||||
- Badges or indicators on new/unused features
|
||||
- Unlock complexity gradually (don't show all options immediately)
|
||||
|
||||
### Guided Tours & Walkthroughs
|
||||
|
||||
**When to use**:
|
||||
- Complex interfaces with many features
|
||||
- Significant changes to existing product
|
||||
- Industry-specific tools needing domain knowledge
|
||||
|
||||
**How to design**:
|
||||
- Spotlight specific UI elements (dim rest of page)
|
||||
- Keep steps short (3-7 steps max per tour)
|
||||
- Allow users to click through tour freely
|
||||
- Include "Skip tour" option
|
||||
- Make replayable (help menu)
|
||||
|
||||
**Best practices**:
|
||||
- Interactive > passive (let users click real buttons)
|
||||
- Focus on workflow, not features ("Create a project" not "This is the project button")
|
||||
- Provide sample data so actions work
|
||||
|
||||
### Interactive Tutorials
|
||||
|
||||
**When to use**:
|
||||
- Users need hands-on practice
|
||||
- Concepts are complex or unfamiliar
|
||||
- High stakes (better to practice in safe environment)
|
||||
|
||||
**How to design**:
|
||||
- Sandbox environment with sample data
|
||||
- Clear objectives ("Create a chart showing sales by region")
|
||||
- Step-by-step guidance
|
||||
- Validation (confirm they did it right)
|
||||
- Graduation moment (you're ready!)
|
||||
|
||||
### Documentation & Help
|
||||
|
||||
**In-product help**:
|
||||
- Contextual help links throughout interface
|
||||
- Keyboard shortcut reference
|
||||
- Search-able help center
|
||||
- Video tutorials for complex workflows
|
||||
|
||||
**Help patterns**:
|
||||
- `?` icon near complex features
|
||||
- "Learn more" links in tooltips
|
||||
- Keyboard shortcut hints (`⌘K` shown on search box)
|
||||
|
||||
## Empty State Design
|
||||
|
||||
Every empty state needs:
|
||||
|
||||
### What Will Be Here
|
||||
"Your recent projects will appear here"
|
||||
|
||||
### Why It Matters
|
||||
"Projects help you organize your work and collaborate with your team"
|
||||
|
||||
### How to Get Started
|
||||
[Create project] or [Import from template]
|
||||
|
||||
### Visual Interest
|
||||
Illustration or icon (not just text on blank page)
|
||||
|
||||
### Contextual Help
|
||||
"Need help getting started? [Watch 2-min tutorial]"
|
||||
|
||||
**Empty state types**:
|
||||
- **First use**: Never used this feature (emphasize value, provide template)
|
||||
- **User cleared**: Intentionally deleted everything (light touch, easy to recreate)
|
||||
- **No results**: Search or filter returned nothing (suggest different query, clear filters)
|
||||
- **No permissions**: Can't access (explain why, how to get access)
|
||||
- **Error state**: Failed to load (explain what happened, retry option)
|
||||
|
||||
## Implementation Patterns
|
||||
|
||||
### Technical approaches:
|
||||
|
||||
**Tooltip libraries**: Tippy.js, Popper.js
|
||||
**Tour libraries**: Intro.js, Shepherd.js, React Joyride
|
||||
**Modal patterns**: Focus trap, backdrop, ESC to close
|
||||
**Progress tracking**: LocalStorage for "seen" states
|
||||
**Analytics**: Track completion, drop-off points
|
||||
|
||||
**Storage patterns**:
|
||||
```javascript
|
||||
// Track which onboarding steps user has seen
|
||||
localStorage.setItem('onboarding-completed', 'true');
|
||||
localStorage.setItem('feature-tooltip-seen-reports', 'true');
|
||||
```
|
||||
|
||||
**IMPORTANT**: Don't show same onboarding twice (annoying). Track completion and respect dismissals.
|
||||
|
||||
**NEVER**:
|
||||
- Force users through long onboarding before they can use product
|
||||
- Patronize users with obvious explanations
|
||||
- Show same tooltip repeatedly (respect dismissals)
|
||||
- Block all UI during tour (let users explore)
|
||||
- Create separate tutorial mode disconnected from real product
|
||||
- Overwhelm with information upfront (progressive disclosure!)
|
||||
- Hide "Skip" or make it hard to find
|
||||
- Forget about returning users (don't show initial onboarding again)
|
||||
|
||||
## Verify Onboarding Quality
|
||||
|
||||
Test with real users:
|
||||
|
||||
- **Time to completion**: Can users complete onboarding quickly?
|
||||
- **Comprehension**: Do users understand after completing?
|
||||
- **Action**: Do users take desired next step?
|
||||
- **Skip rate**: Are too many users skipping? (Maybe it's too long/not valuable)
|
||||
- **Completion rate**: Are users completing? (If low, simplify)
|
||||
- **Time to value**: How long until users get first value?
|
||||
|
||||
Remember: You're a product educator with excellent teaching instincts. Get users to their "aha moment" as quickly as possible. Teach the essential, make it contextual, respect user time and intelligence.
|
||||
@@ -0,0 +1,265 @@
|
||||
---
|
||||
name: optimize
|
||||
description: Improve interface performance across loading speed, rendering, animations, images, and bundle size. Makes experiences faster and smoother.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Identify and fix performance issues to create faster, smoother user experiences.
|
||||
|
||||
## Assess Performance Issues
|
||||
|
||||
Understand current performance and identify problems:
|
||||
|
||||
1. **Measure current state**:
|
||||
- **Core Web Vitals**: LCP, FID/INP, CLS scores
|
||||
- **Load time**: Time to interactive, first contentful paint
|
||||
- **Bundle size**: JavaScript, CSS, image sizes
|
||||
- **Runtime performance**: Frame rate, memory usage, CPU usage
|
||||
- **Network**: Request count, payload sizes, waterfall
|
||||
|
||||
2. **Identify bottlenecks**:
|
||||
- What's slow? (Initial load? Interactions? Animations?)
|
||||
- What's causing it? (Large images? Expensive JavaScript? Layout thrashing?)
|
||||
- How bad is it? (Perceivable? Annoying? Blocking?)
|
||||
- Who's affected? (All users? Mobile only? Slow connections?)
|
||||
|
||||
**CRITICAL**: Measure before and after. Premature optimization wastes time. Optimize what actually matters.
|
||||
|
||||
## Optimization Strategy
|
||||
|
||||
Create systematic improvement plan:
|
||||
|
||||
### Loading Performance
|
||||
|
||||
**Optimize Images**:
|
||||
- Use modern formats (WebP, AVIF)
|
||||
- Proper sizing (don't load 3000px image for 300px display)
|
||||
- Lazy loading for below-fold images
|
||||
- Responsive images (`srcset`, `picture` element)
|
||||
- Compress images (80-85% quality is usually imperceptible)
|
||||
- Use CDN for faster delivery
|
||||
|
||||
```html
|
||||
<img
|
||||
src="hero.webp"
|
||||
srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
|
||||
sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"
|
||||
loading="lazy"
|
||||
alt="Hero image"
|
||||
/>
|
||||
```
|
||||
|
||||
**Reduce JavaScript Bundle**:
|
||||
- Code splitting (route-based, component-based)
|
||||
- Tree shaking (remove unused code)
|
||||
- Remove unused dependencies
|
||||
- Lazy load non-critical code
|
||||
- Use dynamic imports for large components
|
||||
|
||||
```javascript
|
||||
// Lazy load heavy component
|
||||
const HeavyChart = lazy(() => import('./HeavyChart'));
|
||||
```
|
||||
|
||||
**Optimize CSS**:
|
||||
- Remove unused CSS
|
||||
- Critical CSS inline, rest async
|
||||
- Minimize CSS files
|
||||
- Use CSS containment for independent regions
|
||||
|
||||
**Optimize Fonts**:
|
||||
- Use `font-display: swap` or `optional`
|
||||
- Subset fonts (only characters you need)
|
||||
- Preload critical fonts
|
||||
- Use system fonts when appropriate
|
||||
- Limit font weights loaded
|
||||
|
||||
```css
|
||||
@font-face {
|
||||
font-family: 'CustomFont';
|
||||
src: url('/fonts/custom.woff2') format('woff2');
|
||||
font-display: swap; /* Show fallback immediately */
|
||||
unicode-range: U+0020-007F; /* Basic Latin only */
|
||||
}
|
||||
```
|
||||
|
||||
**Optimize Loading Strategy**:
|
||||
- Critical resources first (async/defer non-critical)
|
||||
- Preload critical assets
|
||||
- Prefetch likely next pages
|
||||
- Service worker for offline/caching
|
||||
- HTTP/2 or HTTP/3 for multiplexing
|
||||
|
||||
### Rendering Performance
|
||||
|
||||
**Avoid Layout Thrashing**:
|
||||
```javascript
|
||||
// ❌ Bad: Alternating reads and writes (causes reflows)
|
||||
elements.forEach(el => {
|
||||
const height = el.offsetHeight; // Read (forces layout)
|
||||
el.style.height = height * 2; // Write
|
||||
});
|
||||
|
||||
// ✅ Good: Batch reads, then batch writes
|
||||
const heights = elements.map(el => el.offsetHeight); // All reads
|
||||
elements.forEach((el, i) => {
|
||||
el.style.height = heights[i] * 2; // All writes
|
||||
});
|
||||
```
|
||||
|
||||
**Optimize Rendering**:
|
||||
- Use CSS `contain` property for independent regions
|
||||
- Minimize DOM depth (flatter is faster)
|
||||
- Reduce DOM size (fewer elements)
|
||||
- Use `content-visibility: auto` for long lists
|
||||
- Virtual scrolling for very long lists (react-window, react-virtualized)
|
||||
|
||||
**Reduce Paint & Composite**:
|
||||
- Use `transform` and `opacity` for animations (GPU-accelerated)
|
||||
- Avoid animating layout properties (width, height, top, left)
|
||||
- Use `will-change` sparingly for known expensive operations
|
||||
- Minimize paint areas (smaller is faster)
|
||||
|
||||
### Animation Performance
|
||||
|
||||
**GPU Acceleration**:
|
||||
```css
|
||||
/* ✅ GPU-accelerated (fast) */
|
||||
.animated {
|
||||
transform: translateX(100px);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ❌ CPU-bound (slow) */
|
||||
.animated {
|
||||
left: 100px;
|
||||
width: 300px;
|
||||
}
|
||||
```
|
||||
|
||||
**Smooth 60fps**:
|
||||
- Target 16ms per frame (60fps)
|
||||
- Use `requestAnimationFrame` for JS animations
|
||||
- Debounce/throttle scroll handlers
|
||||
- Use CSS animations when possible
|
||||
- Avoid long-running JavaScript during animations
|
||||
|
||||
**Intersection Observer**:
|
||||
```javascript
|
||||
// Efficiently detect when elements enter viewport
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
// Element is visible, lazy load or animate
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### React/Framework Optimization
|
||||
|
||||
**React-specific**:
|
||||
- Use `memo()` for expensive components
|
||||
- `useMemo()` and `useCallback()` for expensive computations
|
||||
- Virtualize long lists
|
||||
- Code split routes
|
||||
- Avoid inline function creation in render
|
||||
- Use React DevTools Profiler
|
||||
|
||||
**Framework-agnostic**:
|
||||
- Minimize re-renders
|
||||
- Debounce expensive operations
|
||||
- Memoize computed values
|
||||
- Lazy load routes and components
|
||||
|
||||
### Network Optimization
|
||||
|
||||
**Reduce Requests**:
|
||||
- Combine small files
|
||||
- Use SVG sprites for icons
|
||||
- Inline small critical assets
|
||||
- Remove unused third-party scripts
|
||||
|
||||
**Optimize APIs**:
|
||||
- Use pagination (don't load everything)
|
||||
- GraphQL to request only needed fields
|
||||
- Response compression (gzip, brotli)
|
||||
- HTTP caching headers
|
||||
- CDN for static assets
|
||||
|
||||
**Optimize for Slow Connections**:
|
||||
- Adaptive loading based on connection (navigator.connection)
|
||||
- Optimistic UI updates
|
||||
- Request prioritization
|
||||
- Progressive enhancement
|
||||
|
||||
## Core Web Vitals Optimization
|
||||
|
||||
### Largest Contentful Paint (LCP < 2.5s)
|
||||
- Optimize hero images
|
||||
- Inline critical CSS
|
||||
- Preload key resources
|
||||
- Use CDN
|
||||
- Server-side rendering
|
||||
|
||||
### First Input Delay (FID < 100ms) / INP (< 200ms)
|
||||
- Break up long tasks
|
||||
- Defer non-critical JavaScript
|
||||
- Use web workers for heavy computation
|
||||
- Reduce JavaScript execution time
|
||||
|
||||
### Cumulative Layout Shift (CLS < 0.1)
|
||||
- Set dimensions on images and videos
|
||||
- Don't inject content above existing content
|
||||
- Use `aspect-ratio` CSS property
|
||||
- Reserve space for ads/embeds
|
||||
- Avoid animations that cause layout shifts
|
||||
|
||||
```css
|
||||
/* Reserve space for image */
|
||||
.image-container {
|
||||
aspect-ratio: 16 / 9;
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Monitoring
|
||||
|
||||
**Tools to use**:
|
||||
- Chrome DevTools (Lighthouse, Performance panel)
|
||||
- WebPageTest
|
||||
- Core Web Vitals (Chrome UX Report)
|
||||
- Bundle analyzers (webpack-bundle-analyzer)
|
||||
- Performance monitoring (Sentry, DataDog, New Relic)
|
||||
|
||||
**Key metrics**:
|
||||
- LCP, FID/INP, CLS (Core Web Vitals)
|
||||
- Time to Interactive (TTI)
|
||||
- First Contentful Paint (FCP)
|
||||
- Total Blocking Time (TBT)
|
||||
- Bundle size
|
||||
- Request count
|
||||
|
||||
**IMPORTANT**: Measure on real devices with real network conditions. Desktop Chrome with fast connection isn't representative.
|
||||
|
||||
**NEVER**:
|
||||
- Optimize without measuring (premature optimization)
|
||||
- Sacrifice accessibility for performance
|
||||
- Break functionality while optimizing
|
||||
- Use `will-change` everywhere (creates new layers, uses memory)
|
||||
- Lazy load above-fold content
|
||||
- Optimize micro-optimizations while ignoring major issues (optimize the biggest bottleneck first)
|
||||
- Forget about mobile performance (often slower devices, slower connections)
|
||||
|
||||
## Verify Improvements
|
||||
|
||||
Test that optimizations worked:
|
||||
|
||||
- **Before/after metrics**: Compare Lighthouse scores
|
||||
- **Real user monitoring**: Track improvements for real users
|
||||
- **Different devices**: Test on low-end Android, not just flagship iPhone
|
||||
- **Slow connections**: Throttle to 3G, test experience
|
||||
- **No regressions**: Ensure functionality still works
|
||||
- **User perception**: Does it *feel* faster?
|
||||
|
||||
Remember: Performance is a feature. Fast experiences feel more responsive, more polished, more professional. Optimize systematically, measure ruthlessly, and prioritize user-perceived performance.
|
||||
@@ -0,0 +1,141 @@
|
||||
---
|
||||
name: overdrive
|
||||
description: Push interfaces past conventional limits with technically ambitious implementations. Whether that's a shader, a 60fps virtual table, spring physics on a dialog, or scroll-driven reveals — make users ask "how did they do that?"
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Start your response with:
|
||||
|
||||
```
|
||||
──────────── ⚡ OVERDRIVE ─────────────
|
||||
》》》 Entering overdrive mode...
|
||||
```
|
||||
|
||||
Push an interface past conventional limits. This isn't just about visual effects — it's about using the full power of the browser to make any part of an interface feel extraordinary: a table that handles a million rows, a dialog that morphs from its trigger, a form that validates in real-time with streaming feedback, a page transition that feels cinematic.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
**EXTRA IMPORTANT FOR THIS SKILL**: Context determines what "extraordinary" means. A particle system on a creative portfolio is impressive. The same particle system on a settings page is embarrassing. But a settings page with instant optimistic saves and animated state transitions? That's extraordinary too. Understand the project's personality and goals before deciding what's appropriate.
|
||||
|
||||
### Propose Before Building
|
||||
|
||||
This skill has the highest potential to misfire. Do NOT jump straight into implementation. You MUST:
|
||||
|
||||
1. **Think through 2-3 different directions** — consider different techniques, levels of ambition, and aesthetic approaches. For each direction, briefly describe what the result would look and feel like.
|
||||
2. **ask the user directly to clarify what you cannot infer.** to present these directions and get the user's pick before writing any code. Explain trade-offs (browser support, performance cost, complexity).
|
||||
3. Only proceed with the direction the user confirms.
|
||||
|
||||
Skipping this step risks building something embarrassing that needs to be thrown away.
|
||||
|
||||
### Iterate with Browser Automation
|
||||
|
||||
Technically ambitious effects almost never work on the first try. You MUST actively use browser automation tools to preview your work, visually verify the result, and iterate. Do not assume the effect looks right — check it. Expect multiple rounds of refinement. The gap between "technically works" and "looks extraordinary" is closed through visual iteration, not code alone.
|
||||
|
||||
---
|
||||
|
||||
## Assess What "Extraordinary" Means Here
|
||||
|
||||
The right kind of technical ambition depends entirely on what you're working with. Before choosing a technique, ask: **what would make a user of THIS specific interface say "wow, that's nice"?**
|
||||
|
||||
### For visual/marketing surfaces
|
||||
Pages, hero sections, landing pages, portfolios — the "wow" is often sensory: a scroll-driven reveal, a shader background, a cinematic page transition, generative art that responds to the cursor.
|
||||
|
||||
### For functional UI
|
||||
Tables, forms, dialogs, navigation — the "wow" is in how it FEELS: a dialog that morphs from the button that triggered it via View Transitions, a data table that renders 100k rows at 60fps via virtual scrolling, a form with streaming validation that feels instant, drag-and-drop with spring physics.
|
||||
|
||||
### For performance-critical UI
|
||||
The "wow" is invisible but felt: a search that filters 50k items without a flicker, a complex form that never blocks the main thread, an image editor that processes in near-real-time. The interface just never hesitates.
|
||||
|
||||
### For data-heavy interfaces
|
||||
Charts and dashboards — the "wow" is in fluidity: GPU-accelerated rendering via Canvas/WebGL for massive datasets, animated transitions between data states, force-directed graph layouts that settle naturally.
|
||||
|
||||
**The common thread**: something about the implementation goes beyond what users expect from a web interface. The technique serves the experience, not the other way around.
|
||||
|
||||
## The Toolkit
|
||||
|
||||
Organized by what you're trying to achieve, not by technology name.
|
||||
|
||||
### Make transitions feel cinematic
|
||||
- **View Transitions API** (same-document: all browsers; cross-document: no Firefox) — shared element morphing between states. A list item expanding into a detail page. A button morphing into a dialog. This is the closest thing to native FLIP animations.
|
||||
- **`@starting-style`** (all browsers) — animate elements from `display: none` to visible with CSS only, including entry keyframes
|
||||
- **Spring physics** — natural motion with mass, tension, and damping instead of cubic-bezier. Libraries: motion (formerly Framer Motion), GSAP, or roll your own spring solver.
|
||||
|
||||
### Tie animation to scroll position
|
||||
- **Scroll-driven animations** (`animation-timeline: scroll()`) — CSS-only, no JS. Parallax, progress bars, reveal sequences all driven by scroll position. (Chrome/Edge/Safari; Firefox: flag only — always provide a static fallback)
|
||||
|
||||
### Render beyond CSS
|
||||
- **WebGL** (all browsers) — shader effects, post-processing, particle systems. Libraries: Three.js, OGL (lightweight), regl. Use for effects CSS can't express.
|
||||
- **WebGPU** (Chrome/Edge; Safari partial; Firefox: flag only) — next-gen GPU compute. More powerful than WebGL but limited browser support. Always fall back to WebGL2.
|
||||
- **Canvas 2D / OffscreenCanvas** — custom rendering, pixel manipulation, or moving heavy rendering off the main thread entirely via Web Workers + OffscreenCanvas.
|
||||
- **SVG filter chains** — displacement maps, turbulence, morphology for organic distortion effects. CSS-animatable.
|
||||
|
||||
### Make data feel alive
|
||||
- **Virtual scrolling** — render only visible rows for tables/lists with tens of thousands of items. No library required for simple cases; TanStack Virtual for complex ones.
|
||||
- **GPU-accelerated charts** — Canvas or WebGL-rendered data visualization for datasets too large for SVG/DOM. Libraries: deck.gl, regl-based custom renderers.
|
||||
- **Animated data transitions** — morph between chart states rather than replacing. D3's `transition()` or View Transitions for DOM-based charts.
|
||||
|
||||
### Animate complex properties
|
||||
- **`@property`** (all browsers) — register custom CSS properties with types, enabling animation of gradients, colors, and complex values that CSS can't normally interpolate.
|
||||
- **Web Animations API** (all browsers) — JavaScript-driven animations with the performance of CSS. Composable, cancellable, reversible. The foundation for complex choreography.
|
||||
|
||||
### Push performance boundaries
|
||||
- **Web Workers** — move computation off the main thread. Heavy data processing, image manipulation, search indexing — anything that would cause jank.
|
||||
- **OffscreenCanvas** — render in a Worker thread. The main thread stays free while complex visuals render in the background.
|
||||
- **WASM** — near-native performance for computation-heavy features. Image processing, physics simulations, codecs.
|
||||
|
||||
### Interact with the device
|
||||
- **Web Audio API** — spatial audio, audio-reactive visualizations, sonic feedback. Requires user gesture to start.
|
||||
- **Device APIs** — orientation, ambient light, geolocation. Use sparingly and always with user permission.
|
||||
|
||||
**NOTE**: This skill is about enhancing how an interface FEELS, not changing what a product DOES. Adding real-time collaboration, offline support, or new backend capabilities are product decisions, not UI enhancements. Focus on making existing features feel extraordinary.
|
||||
|
||||
## Implement with Discipline
|
||||
|
||||
### Progressive enhancement is non-negotiable
|
||||
|
||||
Every technique must degrade gracefully. The experience without the enhancement must still be good.
|
||||
|
||||
```css
|
||||
@supports (animation-timeline: scroll()) {
|
||||
.hero { animation-timeline: scroll(); }
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
if ('gpu' in navigator) { /* WebGPU */ }
|
||||
else if (canvas.getContext('webgl2')) { /* WebGL2 fallback */ }
|
||||
/* CSS-only fallback must still look good */
|
||||
```
|
||||
|
||||
### Performance rules
|
||||
|
||||
- Target 60fps. If dropping below 50, simplify.
|
||||
- Respect `prefers-reduced-motion` — always. Provide a beautiful static alternative.
|
||||
- Lazy-initialize heavy resources (WebGL contexts, WASM modules) only when near viewport.
|
||||
- Pause off-screen rendering. Kill what you can't see.
|
||||
- Test on real mid-range devices, not just your development machine.
|
||||
|
||||
### Polish is the difference
|
||||
|
||||
The gap between "cool" and "extraordinary" is in the last 20% of refinement: the easing curve on a spring animation, the timing offset in a staggered reveal, the subtle secondary motion that makes a transition feel physical. Don't ship the first version that works — ship the version that feels inevitable.
|
||||
|
||||
**NEVER**:
|
||||
- Ignore `prefers-reduced-motion` — this is an accessibility requirement, not a suggestion
|
||||
- Ship effects that cause jank on mid-range devices
|
||||
- Use bleeding-edge APIs without a functional fallback
|
||||
- Add sound without explicit user opt-in
|
||||
- Use technical ambition to mask weak design fundamentals — fix those first with other skills
|
||||
- Layer multiple competing extraordinary moments — focus creates impact, excess creates noise
|
||||
|
||||
## Verify the Result
|
||||
|
||||
- **The wow test**: Show it to someone who hasn't seen it. Do they react?
|
||||
- **The removal test**: Take it away. Does the experience feel diminished, or does nobody notice?
|
||||
- **The device test**: Run it on a phone, a tablet, a Chromebook. Still smooth?
|
||||
- **The accessibility test**: Enable reduced motion. Still beautiful?
|
||||
- **The context test**: Does this make sense for THIS brand and audience?
|
||||
|
||||
Remember: "Technically extraordinary" isn't about using the newest API. It's about making an interface do something users didn't think a website could do.
|
||||
@@ -0,0 +1,202 @@
|
||||
---
|
||||
name: polish
|
||||
description: Final quality pass before shipping. Fixes alignment, spacing, consistency, and detail issues that separate good from great.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first. Additionally gather: quality bar (MVP vs flagship).
|
||||
|
||||
---
|
||||
|
||||
Perform a meticulous final pass to catch all the small details that separate good work from great work. The difference between shipped and polished.
|
||||
|
||||
## Pre-Polish Assessment
|
||||
|
||||
Understand the current state and goals:
|
||||
|
||||
1. **Review completeness**:
|
||||
- Is it functionally complete?
|
||||
- Are there known issues to preserve (mark with TODOs)?
|
||||
- What's the quality bar? (MVP vs flagship feature?)
|
||||
- When does it ship? (How much time for polish?)
|
||||
|
||||
2. **Identify polish areas**:
|
||||
- Visual inconsistencies
|
||||
- Spacing and alignment issues
|
||||
- Interaction state gaps
|
||||
- Copy inconsistencies
|
||||
- Edge cases and error states
|
||||
- Loading and transition smoothness
|
||||
|
||||
**CRITICAL**: Polish is the last step, not the first. Don't polish work that's not functionally complete.
|
||||
|
||||
## Polish Systematically
|
||||
|
||||
Work through these dimensions methodically:
|
||||
|
||||
### Visual Alignment & Spacing
|
||||
|
||||
- **Pixel-perfect alignment**: Everything lines up to grid
|
||||
- **Consistent spacing**: All gaps use spacing scale (no random 13px gaps)
|
||||
- **Optical alignment**: Adjust for visual weight (icons may need offset for optical centering)
|
||||
- **Responsive consistency**: Spacing and alignment work at all breakpoints
|
||||
- **Grid adherence**: Elements snap to baseline grid
|
||||
|
||||
**Check**:
|
||||
- Enable grid overlay and verify alignment
|
||||
- Check spacing with browser inspector
|
||||
- Test at multiple viewport sizes
|
||||
- Look for elements that "feel" off
|
||||
|
||||
### Typography Refinement
|
||||
|
||||
- **Hierarchy consistency**: Same elements use same sizes/weights throughout
|
||||
- **Line length**: 45-75 characters for body text
|
||||
- **Line height**: Appropriate for font size and context
|
||||
- **Widows & orphans**: No single words on last line
|
||||
- **Hyphenation**: Appropriate for language and column width
|
||||
- **Kerning**: Adjust letter spacing where needed (especially headlines)
|
||||
- **Font loading**: No FOUT/FOIT flashes
|
||||
|
||||
### Color & Contrast
|
||||
|
||||
- **Contrast ratios**: All text meets WCAG standards
|
||||
- **Consistent token usage**: No hard-coded colors, all use design tokens
|
||||
- **Theme consistency**: Works in all theme variants
|
||||
- **Color meaning**: Same colors mean same things throughout
|
||||
- **Accessible focus**: Focus indicators visible with sufficient contrast
|
||||
- **Tinted neutrals**: No pure gray or pure black—add subtle color tint (0.01 chroma)
|
||||
- **Gray on color**: Never put gray text on colored backgrounds—use a shade of that color or transparency
|
||||
|
||||
### Interaction States
|
||||
|
||||
Every interactive element needs all states:
|
||||
|
||||
- **Default**: Resting state
|
||||
- **Hover**: Subtle feedback (color, scale, shadow)
|
||||
- **Focus**: Keyboard focus indicator (never remove without replacement)
|
||||
- **Active**: Click/tap feedback
|
||||
- **Disabled**: Clearly non-interactive
|
||||
- **Loading**: Async action feedback
|
||||
- **Error**: Validation or error state
|
||||
- **Success**: Successful completion
|
||||
|
||||
**Missing states create confusion and broken experiences**.
|
||||
|
||||
### Micro-interactions & Transitions
|
||||
|
||||
- **Smooth transitions**: All state changes animated appropriately (150-300ms)
|
||||
- **Consistent easing**: Use ease-out-quart/quint/expo for natural deceleration. Never bounce or elastic—they feel dated.
|
||||
- **No jank**: 60fps animations, only animate transform and opacity
|
||||
- **Appropriate motion**: Motion serves purpose, not decoration
|
||||
- **Reduced motion**: Respects `prefers-reduced-motion`
|
||||
|
||||
### Content & Copy
|
||||
|
||||
- **Consistent terminology**: Same things called same names throughout
|
||||
- **Consistent capitalization**: Title Case vs Sentence case applied consistently
|
||||
- **Grammar & spelling**: No typos
|
||||
- **Appropriate length**: Not too wordy, not too terse
|
||||
- **Punctuation consistency**: Periods on sentences, not on labels (unless all labels have them)
|
||||
|
||||
### Icons & Images
|
||||
|
||||
- **Consistent style**: All icons from same family or matching style
|
||||
- **Appropriate sizing**: Icons sized consistently for context
|
||||
- **Proper alignment**: Icons align with adjacent text optically
|
||||
- **Alt text**: All images have descriptive alt text
|
||||
- **Loading states**: Images don't cause layout shift, proper aspect ratios
|
||||
- **Retina support**: 2x assets for high-DPI screens
|
||||
|
||||
### Forms & Inputs
|
||||
|
||||
- **Label consistency**: All inputs properly labeled
|
||||
- **Required indicators**: Clear and consistent
|
||||
- **Error messages**: Helpful and consistent
|
||||
- **Tab order**: Logical keyboard navigation
|
||||
- **Auto-focus**: Appropriate (don't overuse)
|
||||
- **Validation timing**: Consistent (on blur vs on submit)
|
||||
|
||||
### Edge Cases & Error States
|
||||
|
||||
- **Loading states**: All async actions have loading feedback
|
||||
- **Empty states**: Helpful empty states, not just blank space
|
||||
- **Error states**: Clear error messages with recovery paths
|
||||
- **Success states**: Confirmation of successful actions
|
||||
- **Long content**: Handles very long names, descriptions, etc.
|
||||
- **No content**: Handles missing data gracefully
|
||||
- **Offline**: Appropriate offline handling (if applicable)
|
||||
|
||||
### Responsiveness
|
||||
|
||||
- **All breakpoints**: Test mobile, tablet, desktop
|
||||
- **Touch targets**: 44x44px minimum on touch devices
|
||||
- **Readable text**: No text smaller than 14px on mobile
|
||||
- **No horizontal scroll**: Content fits viewport
|
||||
- **Appropriate reflow**: Content adapts logically
|
||||
|
||||
### Performance
|
||||
|
||||
- **Fast initial load**: Optimize critical path
|
||||
- **No layout shift**: Elements don't jump after load (CLS)
|
||||
- **Smooth interactions**: No lag or jank
|
||||
- **Optimized images**: Appropriate formats and sizes
|
||||
- **Lazy loading**: Off-screen content loads lazily
|
||||
|
||||
### Code Quality
|
||||
|
||||
- **Remove console logs**: No debug logging in production
|
||||
- **Remove commented code**: Clean up dead code
|
||||
- **Remove unused imports**: Clean up unused dependencies
|
||||
- **Consistent naming**: Variables and functions follow conventions
|
||||
- **Type safety**: No TypeScript `any` or ignored errors
|
||||
- **Accessibility**: Proper ARIA labels and semantic HTML
|
||||
|
||||
## Polish Checklist
|
||||
|
||||
Go through systematically:
|
||||
|
||||
- [ ] Visual alignment perfect at all breakpoints
|
||||
- [ ] Spacing uses design tokens consistently
|
||||
- [ ] Typography hierarchy consistent
|
||||
- [ ] All interactive states implemented
|
||||
- [ ] All transitions smooth (60fps)
|
||||
- [ ] Copy is consistent and polished
|
||||
- [ ] Icons are consistent and properly sized
|
||||
- [ ] All forms properly labeled and validated
|
||||
- [ ] Error states are helpful
|
||||
- [ ] Loading states are clear
|
||||
- [ ] Empty states are welcoming
|
||||
- [ ] Touch targets are 44x44px minimum
|
||||
- [ ] Contrast ratios meet WCAG AA
|
||||
- [ ] Keyboard navigation works
|
||||
- [ ] Focus indicators visible
|
||||
- [ ] No console errors or warnings
|
||||
- [ ] No layout shift on load
|
||||
- [ ] Works in all supported browsers
|
||||
- [ ] Respects reduced motion preference
|
||||
- [ ] Code is clean (no TODOs, console.logs, commented code)
|
||||
|
||||
**IMPORTANT**: Polish is about details. Zoom in. Squint at it. Use it yourself. The little things add up.
|
||||
|
||||
**NEVER**:
|
||||
- Polish before it's functionally complete
|
||||
- Spend hours on polish if it ships in 30 minutes (triage)
|
||||
- Introduce bugs while polishing (test thoroughly)
|
||||
- Ignore systematic issues (if spacing is off everywhere, fix the system)
|
||||
- Perfect one thing while leaving others rough (consistent quality level)
|
||||
|
||||
## Final Verification
|
||||
|
||||
Before marking as done:
|
||||
|
||||
- **Use it yourself**: Actually interact with the feature
|
||||
- **Test on real devices**: Not just browser DevTools
|
||||
- **Ask someone else to review**: Fresh eyes catch things
|
||||
- **Compare to design**: Match intended design
|
||||
- **Check all states**: Don't just test happy path
|
||||
|
||||
Remember: You have impeccable attention to detail and exquisite taste. Polish until it feels effortless, looks intentional, and works flawlessly. Sweat the details - they matter.
|
||||
@@ -0,0 +1,102 @@
|
||||
---
|
||||
name: quieter
|
||||
description: Tone down overly bold or visually aggressive designs. Reduces intensity while maintaining design quality and impact.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Reduce visual intensity in designs that are too bold, aggressive, or overstimulating, creating a more refined and approachable aesthetic without losing effectiveness.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current State
|
||||
|
||||
Analyze what makes the design feel too intense:
|
||||
|
||||
1. **Identify intensity sources**:
|
||||
- **Color saturation**: Overly bright or saturated colors
|
||||
- **Contrast extremes**: Too much high-contrast juxtaposition
|
||||
- **Visual weight**: Too many bold, heavy elements competing
|
||||
- **Animation excess**: Too much motion or overly dramatic effects
|
||||
- **Complexity**: Too many visual elements, patterns, or decorations
|
||||
- **Scale**: Everything is large and loud with no hierarchy
|
||||
|
||||
2. **Understand the context**:
|
||||
- What's the purpose? (Marketing vs tool vs reading experience)
|
||||
- Who's the audience? (Some contexts need energy)
|
||||
- What's working? (Don't throw away good ideas)
|
||||
- What's the core message? (Preserve what matters)
|
||||
|
||||
If any of these are unclear from the codebase, ask the user directly to clarify what you cannot infer.
|
||||
|
||||
**CRITICAL**: "Quieter" doesn't mean boring or generic. It means refined, sophisticated, and easier on the eyes. Think luxury, not laziness.
|
||||
|
||||
## Plan Refinement
|
||||
|
||||
Create a strategy to reduce intensity while maintaining impact:
|
||||
|
||||
- **Color approach**: Desaturate or shift to more sophisticated tones?
|
||||
- **Hierarchy approach**: Which elements should stay bold (very few), which should recede?
|
||||
- **Simplification approach**: What can be removed entirely?
|
||||
- **Sophistication approach**: How can we signal quality through restraint?
|
||||
|
||||
**IMPORTANT**: Great quiet design is harder than great bold design. Subtlety requires precision.
|
||||
|
||||
## Refine the Design
|
||||
|
||||
Systematically reduce intensity across these dimensions:
|
||||
|
||||
### Color Refinement
|
||||
- **Reduce saturation**: Shift from fully saturated to 70-85% saturation
|
||||
- **Soften palette**: Replace bright colors with muted, sophisticated tones
|
||||
- **Reduce color variety**: Use fewer colors more thoughtfully
|
||||
- **Neutral dominance**: Let neutrals do more work, use color as accent (10% rule)
|
||||
- **Gentler contrasts**: High contrast only where it matters most
|
||||
- **Tinted grays**: Use warm or cool tinted grays instead of pure gray—adds sophistication without loudness
|
||||
- **Never gray on color**: If you have gray text on a colored background, use a darker shade of that color or transparency instead
|
||||
|
||||
### Visual Weight Reduction
|
||||
- **Typography**: Reduce font weights (900 → 600, 700 → 500), decrease sizes where appropriate
|
||||
- **Hierarchy through subtlety**: Use weight, size, and space instead of color and boldness
|
||||
- **White space**: Increase breathing room, reduce density
|
||||
- **Borders & lines**: Reduce thickness, decrease opacity, or remove entirely
|
||||
|
||||
### Simplification
|
||||
- **Remove decorative elements**: Gradients, shadows, patterns, textures that don't serve purpose
|
||||
- **Simplify shapes**: Reduce border radius extremes, simplify custom shapes
|
||||
- **Reduce layering**: Flatten visual hierarchy where possible
|
||||
- **Clean up effects**: Reduce or remove blur effects, glows, multiple shadows
|
||||
|
||||
### Motion Reduction
|
||||
- **Reduce animation intensity**: Shorter distances (10-20px instead of 40px), gentler easing
|
||||
- **Remove decorative animations**: Keep functional motion, remove flourishes
|
||||
- **Subtle micro-interactions**: Replace dramatic effects with gentle feedback
|
||||
- **Refined easing**: Use ease-out-quart for smooth, understated motion—never bounce or elastic
|
||||
- **Remove animations entirely** if they're not serving a clear purpose
|
||||
|
||||
### Composition Refinement
|
||||
- **Reduce scale jumps**: Smaller contrast between sizes creates calmer feeling
|
||||
- **Align to grid**: Bring rogue elements back into systematic alignment
|
||||
- **Even out spacing**: Replace extreme spacing variations with consistent rhythm
|
||||
|
||||
**NEVER**:
|
||||
- Make everything the same size/weight (hierarchy still matters)
|
||||
- Remove all color (quiet ≠ grayscale)
|
||||
- Eliminate all personality (maintain character through refinement)
|
||||
- Sacrifice usability for aesthetics (functional elements still need clear affordances)
|
||||
- Make everything small and light (some anchors needed)
|
||||
|
||||
## Verify Quality
|
||||
|
||||
Ensure refinement maintains quality:
|
||||
|
||||
- **Still functional**: Can users still accomplish tasks easily?
|
||||
- **Still distinctive**: Does it have character, or is it generic now?
|
||||
- **Better reading**: Is text easier to read for extended periods?
|
||||
- **Sophistication**: Does it feel more refined and premium?
|
||||
|
||||
Remember: Quiet design is confident design. It doesn't need to shout. Less is more, but less is also harder. Refine with precision and maintain intentionality.
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
name: teach-impeccable
|
||||
description: One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.
|
||||
user-invocable: true
|
||||
---
|
||||
|
||||
Gather design context for this project, then persist it for all future sessions.
|
||||
|
||||
## Step 1: Explore the Codebase
|
||||
|
||||
Before asking questions, thoroughly scan the project to discover what you can:
|
||||
|
||||
- **README and docs**: Project purpose, target audience, any stated goals
|
||||
- **Package.json / config files**: Tech stack, dependencies, existing design libraries
|
||||
- **Existing components**: Current design patterns, spacing, typography in use
|
||||
- **Brand assets**: Logos, favicons, color values already defined
|
||||
- **Design tokens / CSS variables**: Existing color palettes, font stacks, spacing scales
|
||||
- **Any style guides or brand documentation**
|
||||
|
||||
Note what you've learned and what remains unclear.
|
||||
|
||||
## Step 2: Ask UX-Focused Questions
|
||||
|
||||
ask the user directly to clarify what you cannot infer. Focus only on what you couldn't infer from the codebase:
|
||||
|
||||
### Users & Purpose
|
||||
- Who uses this? What's their context when using it?
|
||||
- What job are they trying to get done?
|
||||
- What emotions should the interface evoke? (confidence, delight, calm, urgency, etc.)
|
||||
|
||||
### Brand & Personality
|
||||
- How would you describe the brand personality in 3 words?
|
||||
- Any reference sites or apps that capture the right feel? What specifically about them?
|
||||
- What should this explicitly NOT look like? Any anti-references?
|
||||
|
||||
### Aesthetic Preferences
|
||||
- Any strong preferences for visual direction? (minimal, bold, elegant, playful, technical, organic, etc.)
|
||||
- Light mode, dark mode, or both?
|
||||
- Any colors that must be used or avoided?
|
||||
|
||||
### Accessibility & Inclusion
|
||||
- Specific accessibility requirements? (WCAG level, known user needs)
|
||||
- Considerations for reduced motion, color blindness, or other accommodations?
|
||||
|
||||
Skip questions where the answer is already clear from the codebase exploration.
|
||||
|
||||
## Step 3: Write Design Context
|
||||
|
||||
Synthesize your findings and the user's answers into a `## Design Context` section:
|
||||
|
||||
```markdown
|
||||
## Design Context
|
||||
|
||||
### Users
|
||||
[Who they are, their context, the job to be done]
|
||||
|
||||
### Brand Personality
|
||||
[Voice, tone, 3-word personality, emotional goals]
|
||||
|
||||
### Aesthetic Direction
|
||||
[Visual tone, references, anti-references, theme]
|
||||
|
||||
### Design Principles
|
||||
[3-5 principles derived from the conversation that should guide all design decisions]
|
||||
```
|
||||
|
||||
Write this section to `.impeccable.md` in the project root. If the file already exists, update the Design Context section in place.
|
||||
|
||||
Then ask the user directly to clarify what you cannot infer. whether they'd also like the Design Context appended to .github/copilot-instructions.md. If yes, append or update the section there as well.
|
||||
|
||||
Confirm completion and summarize the key design principles that will now guide all future work.
|
||||
@@ -0,0 +1,115 @@
|
||||
---
|
||||
name: typeset
|
||||
description: Improve typography by fixing font choices, hierarchy, sizing, weight consistency, and readability. Makes text feel intentional and polished.
|
||||
user-invocable: true
|
||||
argument-hint: [TARGET=<value>]
|
||||
---
|
||||
|
||||
Assess and improve typography that feels generic, inconsistent, or poorly structured — turning default-looking text into intentional, well-crafted type.
|
||||
|
||||
## MANDATORY PREPARATION
|
||||
|
||||
Use the frontend-design skill — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run teach-impeccable first.
|
||||
|
||||
---
|
||||
|
||||
## Assess Current Typography
|
||||
|
||||
Analyze what's weak or generic about the current type:
|
||||
|
||||
1. **Font choices**:
|
||||
- Are we using invisible defaults? (Inter, Roboto, Arial, Open Sans, system defaults)
|
||||
- Does the font match the brand personality? (A playful brand shouldn't use a corporate typeface)
|
||||
- Are there too many font families? (More than 2-3 is almost always a mess)
|
||||
|
||||
2. **Hierarchy**:
|
||||
- Can you tell headings from body from captions at a glance?
|
||||
- Are font sizes too close together? (14px, 15px, 16px = muddy hierarchy)
|
||||
- Are weight contrasts strong enough? (Medium vs Regular is barely visible)
|
||||
|
||||
3. **Sizing & scale**:
|
||||
- Is there a consistent type scale, or are sizes arbitrary?
|
||||
- Does body text meet minimum readability? (16px+)
|
||||
- Is the sizing strategy appropriate for the context? (Fixed `rem` scales for app UIs; fluid `clamp()` for marketing/content page headings)
|
||||
|
||||
4. **Readability**:
|
||||
- Are line lengths comfortable? (45-75 characters ideal)
|
||||
- Is line-height appropriate for the font and context?
|
||||
- Is there enough contrast between text and background?
|
||||
|
||||
5. **Consistency**:
|
||||
- Are the same elements styled the same way throughout?
|
||||
- Are font weights used consistently? (Not bold in one section, semibold in another for the same role)
|
||||
- Is letter-spacing intentional or default everywhere?
|
||||
|
||||
**CRITICAL**: The goal isn't to make text "fancier" — it's to make it clearer, more readable, and more intentional. Good typography is invisible; bad typography is distracting.
|
||||
|
||||
## Plan Typography Improvements
|
||||
|
||||
Consult the [typography reference](reference/typography.md) from the frontend-design skill for detailed guidance on scales, pairing, and loading strategies.
|
||||
|
||||
Create a systematic plan:
|
||||
|
||||
- **Font selection**: Do fonts need replacing? What fits the brand/context?
|
||||
- **Type scale**: Establish a modular scale (e.g., 1.25 ratio) with clear hierarchy
|
||||
- **Weight strategy**: Which weights serve which roles? (Regular for body, Semibold for labels, Bold for headings — or whatever fits)
|
||||
- **Spacing**: Line-heights, letter-spacing, and margins between typographic elements
|
||||
|
||||
## Improve Typography Systematically
|
||||
|
||||
### Font Selection
|
||||
|
||||
If fonts need replacing:
|
||||
- Choose fonts that reflect the brand personality
|
||||
- Pair with genuine contrast (serif + sans, geometric + humanist) — or use a single family in multiple weights
|
||||
- Ensure web font loading doesn't cause layout shift (`font-display: swap`, metric-matched fallbacks)
|
||||
|
||||
### Establish Hierarchy
|
||||
|
||||
Build a clear type scale:
|
||||
- **5 sizes cover most needs**: caption, secondary, body, subheading, heading
|
||||
- **Use a consistent ratio** between levels (1.25, 1.333, or 1.5)
|
||||
- **Combine dimensions**: Size + weight + color + space for strong hierarchy — don't rely on size alone
|
||||
- **App UIs**: Use a fixed `rem`-based type scale, optionally adjusted at 1-2 breakpoints. Fluid sizing undermines the spatial predictability that dense, container-based layouts need
|
||||
- **Marketing / content pages**: Use fluid sizing via `clamp(min, preferred, max)` for headings and display text. Keep body text fixed
|
||||
|
||||
### Fix Readability
|
||||
|
||||
- Set `max-width` on text containers using `ch` units (`max-width: 65ch`)
|
||||
- Adjust line-height per context: tighter for headings (1.1-1.2), looser for body (1.5-1.7)
|
||||
- Increase line-height slightly for light-on-dark text
|
||||
- Ensure body text is at least 16px / 1rem
|
||||
|
||||
### Refine Details
|
||||
|
||||
- Use `tabular-nums` for data tables and numbers that should align
|
||||
- Apply proper `letter-spacing`: slightly open for small caps and uppercase, default or tight for large display text
|
||||
- Use semantic token names (`--text-body`, `--text-heading`), not value names (`--font-16`)
|
||||
- Set `font-kerning: normal` and consider OpenType features where appropriate
|
||||
|
||||
### Weight Consistency
|
||||
|
||||
- Define clear roles for each weight and stick to them
|
||||
- Don't use more than 3-4 weights (Regular, Medium, Semibold, Bold is plenty)
|
||||
- Load only the weights you actually use (each weight adds to page load)
|
||||
|
||||
**NEVER**:
|
||||
- Use more than 2-3 font families
|
||||
- Pick sizes arbitrarily — commit to a scale
|
||||
- Set body text below 16px
|
||||
- Use decorative/display fonts for body text
|
||||
- Disable browser zoom (`user-scalable=no`)
|
||||
- Use `px` for font sizes — use `rem` to respect user settings
|
||||
- Default to Inter/Roboto/Open Sans when personality matters
|
||||
- Pair fonts that are similar but not identical (two geometric sans-serifs)
|
||||
|
||||
## Verify Typography Improvements
|
||||
|
||||
- **Hierarchy**: Can you identify heading vs body vs caption instantly?
|
||||
- **Readability**: Is body text comfortable to read in long passages?
|
||||
- **Consistency**: Are same-role elements styled identically throughout?
|
||||
- **Personality**: Does the typography reflect the brand?
|
||||
- **Performance**: Are web fonts loading efficiently without layout shift?
|
||||
- **Accessibility**: Does text meet WCAG contrast ratios? Is it zoomable to 200%?
|
||||
|
||||
Remember: Typography is the foundation of interface design — it carries the majority of information. Getting it right is the highest-leverage improvement you can make.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/adapt
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/animate
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/arrange
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/audit
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/bolder
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/clarify
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/colorize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/critique
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/delight
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/distill
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/extract
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/frontend-design
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/harden
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/normalize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/onboard
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/optimize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/overdrive
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/polish
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/quieter
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/teach-impeccable
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/typeset
|
||||
@@ -0,0 +1,17 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.html]
|
||||
# HTML-specific formatting
|
||||
# Standardize on tag layout
|
||||
ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot
|
||||
ij_html_keep_blank_lines = 1
|
||||
ij_html_attribute_wrap = normal
|
||||
ij_html_space_inside_empty_tag = false
|
||||
@@ -41,3 +41,20 @@ PREFERRED_DEVICES="Living Room@192.168.1.100:8090;Kitchen@192.168.1.101;192.168.
|
||||
# Alternative format examples:
|
||||
# PREFERRED_DEVICES="192.168.178.35;192.168.178.28"
|
||||
# PREFERRED_DEVICES="SoundTouch 10@192.168.178.35;SoundTouch 20@192.168.178.28"
|
||||
|
||||
# Spotify Integration
|
||||
# Create an app at https://developer.spotify.com/dashboard
|
||||
# SPOTIFY_CLIENT_ID=your_client_id
|
||||
# SPOTIFY_CLIENT_SECRET=your_client_secret
|
||||
# Auth confirmation url using GET, works in browsers
|
||||
# SPOTIFY_REDIRECT_URI=https://your-server.example.com/mgmt/spotify/callback
|
||||
# Auth confirmation url using POST, works with the ueberboese-app (https://github.com/julius-d/ueberboese-app)
|
||||
# SPOTIFY_REDIRECT_URI=https://your-server.example.com/mgmt/spotify/confirm
|
||||
|
||||
# Management API Authentication
|
||||
# Protects /mgmt/* endpoints (Spotify token access, account management)
|
||||
MGMT_USERNAME=admin
|
||||
MGMT_PASSWORD=change_me!
|
||||
|
||||
# External base URL (required when behind a reverse proxy for OAuth callbacks)
|
||||
# BASE_URL=https://your-server.example.com
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Copilot Instructions
|
||||
|
||||
## Design Context
|
||||
|
||||
### Users
|
||||
The primary users are tech-savvy individuals (including IT professionals and dedicated enthusiasts) who need to migrate their Bose SoundTouch speakers from the Bose Cloud to a local service. While the initial setup requires technical knowledge (SSH, network config), the ultimate goal is a "set and forget" solution that provides a seamless experience for everyday use.
|
||||
|
||||
### Brand Personality
|
||||
* **Voice & Tone:** Open, Transparent, Technical.
|
||||
* **3-word personality:** Reliable, Precise, Empowering.
|
||||
* **Emotional Goal:** Confidence. The interface should make users feel that their hardware is safe and will continue to work indefinitely.
|
||||
|
||||
### Aesthetic Direction
|
||||
* **Visual Tone:** "Pro-consumer" but clean. It should feel like a high-quality utility rather than a marketing site.
|
||||
* **References:** Bose (clean typography, generous whitespace, focused interactions).
|
||||
* **Anti-references:** "AI Slop" (generic, cluttered, over-saturated designs).
|
||||
* **Theme:** Light mode by default. Dark mode is a nice-to-have but secondary.
|
||||
|
||||
### Design Principles
|
||||
1. **Clarity over Flash:** Prioritize clear instructions and immediate feedback. The interface exists to solve a technical problem, not to sell a product.
|
||||
2. **Confidence-Building Interactions:** Every action (especially destructive ones like migration) must have clear confirmations and status indicators (e.g., ✅ Success/❌ Error).
|
||||
3. **Utility with Polish:** Maintain a technical feel (using code blocks and data tables where necessary) but elevate them with consistent spacing, refined typography, and subtle visual cues.
|
||||
4. **Future-Proof Consistency:** Design components and patterns that can scale to a consumer-oriented mobile or desktop application.
|
||||
5. **Component-Based Scalability:** Move away from inline styles toward a clean, token-based CSS approach to improve maintainability and responsiveness.
|
||||
@@ -25,6 +25,9 @@
|
||||
},
|
||||
{
|
||||
"pattern": "^https://pkg.go.dev.*badge"
|
||||
},
|
||||
{
|
||||
"pattern": "^\\.\\./images/(dashboard-home|account-creation|account-dashboard|usb-remote-services|device-discovery|device-registration|account-migration|migration-setup|migration-progress|migration-health|migration-complete|backup-setup)\\.png$"
|
||||
}
|
||||
],
|
||||
"replacementPatterns": [
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
name: CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
@@ -100,7 +103,7 @@ jobs:
|
||||
go build -o "$output_name" ./cmd/soundtouch-cli
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: soundtouch-cli-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: soundtouch-cli-*
|
||||
@@ -144,6 +147,29 @@ jobs:
|
||||
use-verbose-mode: "yes"
|
||||
config-file: ".github/markdown-link-check.json"
|
||||
|
||||
- name: Warn on pending images
|
||||
run: |
|
||||
IMAGES=(
|
||||
"dashboard-home.png"
|
||||
"account-creation.png"
|
||||
"account-dashboard.png"
|
||||
"usb-remote-services.png"
|
||||
"device-discovery.png"
|
||||
"device-registration.png"
|
||||
"account-migration.png"
|
||||
"migration-setup.png"
|
||||
"migration-progress.png"
|
||||
"migration-health.png"
|
||||
"migration-complete.png"
|
||||
"backup-setup.png"
|
||||
)
|
||||
|
||||
for img in "${IMAGES[@]}"; do
|
||||
if [ ! -f "docs/images/$img" ]; then
|
||||
echo "::warning file=docs/guides/MIGRATION-GUIDE.md::Pending image '$img' is missing from docs/images/"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Validate API documentation
|
||||
run: |
|
||||
# Check that all documented endpoints exist in code
|
||||
@@ -230,11 +256,11 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
@@ -242,7 +268,7 @@ jobs:
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
@@ -250,9 +276,10 @@ jobs:
|
||||
type=ref,event=pr
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v8,linux/arm/v7
|
||||
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -192,7 +192,7 @@ jobs:
|
||||
echo "✅ Checksums generated successfully"
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}
|
||||
path: |
|
||||
@@ -207,7 +207,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download binary artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: binaries-*
|
||||
path: ./binaries
|
||||
@@ -264,7 +264,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Upload checksums
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: checksums
|
||||
path: |
|
||||
@@ -275,7 +275,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
- name: Upload all release assets
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-assets
|
||||
path: binaries/release-files/
|
||||
@@ -294,7 +294,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download release assets
|
||||
uses: actions/download-artifact@v7
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: release-assets
|
||||
path: ./release-assets
|
||||
@@ -464,7 +464,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download release assets
|
||||
uses: actions/download-artifact@v7
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: release-assets
|
||||
path: ./release-assets
|
||||
@@ -492,10 +492,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
@@ -503,7 +503,7 @@ jobs:
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
@@ -512,9 +512,10 @@ jobs:
|
||||
type=raw,value=latest,enable=${{ needs.validate.outputs.is_prerelease == 'false' }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v8,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
vulnerability-scan:
|
||||
name: Vulnerability Scan
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -43,7 +45,7 @@ jobs:
|
||||
|
||||
- name: Upload vulnerability scan results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: vulnerability-scan-results
|
||||
path: |
|
||||
@@ -53,6 +55,8 @@ jobs:
|
||||
static-analysis:
|
||||
name: Static Security Analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -119,6 +123,8 @@ jobs:
|
||||
dependency-review:
|
||||
name: Dependency Review
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
steps:
|
||||
@@ -137,6 +143,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [vulnerability-scan, static-analysis, codeql-analysis]
|
||||
if: always()
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Security scan summary
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
## Design Context
|
||||
|
||||
### Users
|
||||
The primary users are tech-savvy individuals (including IT professionals and dedicated enthusiasts) who need to migrate their Bose SoundTouch speakers from the Bose Cloud to a local service. While the initial setup requires technical knowledge (SSH, network config), the ultimate goal is a "set and forget" solution that provides a seamless experience for everyday use.
|
||||
|
||||
### Brand Personality
|
||||
* **Voice & Tone:** Open, Transparent, Technical.
|
||||
* **3-word personality:** Reliable, Precise, Empowering.
|
||||
* **Emotional Goal:** Confidence. The interface should make users feel that their hardware is safe and will continue to work indefinitely.
|
||||
|
||||
### Aesthetic Direction
|
||||
* **Visual Tone:** "Pro-consumer" but clean. It should feel like a high-quality utility rather than a marketing site.
|
||||
* **References:** Bose (clean typography, generous whitespace, focused interactions).
|
||||
* **Anti-references:** "AI Slop" (generic, cluttered, over-saturated designs).
|
||||
* **Theme:** Light mode by default. Dark mode is a nice-to-have but secondary.
|
||||
|
||||
### Design Principles
|
||||
1. **Clarity over Flash:** Prioritize clear instructions and immediate feedback. The interface exists to solve a technical problem, not to sell a product.
|
||||
2. **Confidence-Building Interactions:** Every action (especially destructive ones like migration) must have clear confirmations and status indicators (e.g., ✅ Success/❌ Error).
|
||||
3. **Utility with Polish:** Maintain a technical feel (using code blocks and data tables where necessary) but elevate them with consistent spacing, refined typography, and subtle visual cues.
|
||||
4. **Future-Proof Consistency:** Design components and patterns that can scale to a consumer-oriented mobile or desktop application.
|
||||
5. **Component-Based Scalability:** Move away from inline styles toward a clean, token-based CSS approach to improve maintainability and responsiveness.
|
||||
|
||||
## Component Library (Standard Patterns)
|
||||
|
||||
### 1. Callouts & Status Indicators
|
||||
Use for feedback, warnings, and instructions.
|
||||
* **Base Class:** `.callout` or `.status`
|
||||
* **Variants:** `.callout-info` (blue), `.callout-success` (green), `.callout-warning` (yellow), `.callout-error` (red)
|
||||
* **Usage:**
|
||||
```html
|
||||
<div class="callout callout-info">
|
||||
<strong>Title:</strong> Your message here.
|
||||
</div>
|
||||
```
|
||||
|
||||
### 2. Buttons
|
||||
* **Primary:** `.btn-primary` (Blue/Accent) - Main action.
|
||||
* **Secondary:** `.btn-secondary` (Grey) - Neutral action.
|
||||
* **Success:** `.btn-success` (Green) - Positive/Confirm action.
|
||||
* **Warning:** `.btn-warning` (Yellow) - Revert/Caution action.
|
||||
* **Danger:** `.btn-danger` (Red) - Destructive action.
|
||||
* **Spotify:** `.btn-spotify` (Spotify Green) - Spotify-specific actions.
|
||||
|
||||
### 3. Data Containers
|
||||
* **Cards:** `.card` or `.summary-box` - Grouped information.
|
||||
* **Consoles:** `.console-box` or `pre` - Monospace output, logs, or code.
|
||||
* **Viewers:** `.viewer-box` - Dark-themed container for detailed technical analysis (JSON/XML).
|
||||
|
||||
### 4. Layout Utilities
|
||||
* **Flexbox:** `.flex-row`, `.flex-between`, `.flex-grow`.
|
||||
* **Spacing:** `.mt-{size}`, `.mb-{size}`, `.ml-{size}`, `.p-{size}`.
|
||||
* Sizes: `xs` (4px), `sm` (8px), `md` (16px), `lg` (24px), `xl` (32px).
|
||||
* **Visibility:** `.hidden`, `.visible`, `.flex-visible`.
|
||||
|
||||
### 5. Typography
|
||||
* **Subtitle:** `.subtitle` - Small italicized text below headings.
|
||||
* **Help Text:** `.help-text` or `.help-text-sm` - Descriptive text for inputs or status.
|
||||
* **Badges:** `.badge` with variants `.badge-info`, `.badge-success`, etc.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/adapt
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/animate
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/arrange
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/audit
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/bolder
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/clarify
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/colorize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/critique
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/delight
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/distill
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/extract
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/frontend-design
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/harden
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/normalize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/onboard
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/optimize
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/overdrive
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/polish
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/quieter
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/teach-impeccable
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.agents/skills/typeset
|
||||
+16
-2
@@ -1,5 +1,12 @@
|
||||
# Build stage
|
||||
FROM golang:1.26.0-alpine AS builder
|
||||
FROM --platform=$BUILDPLATFORM golang:1.26.1-alpine AS builder
|
||||
|
||||
# Declare automatic platform ARGs to make them available in build stage
|
||||
# See https://docs.docker.com/reference/dockerfile#automatic-platform-args-in-the-global-scope
|
||||
# We should not set defaults here, but rely on BuildKit to set them matching the BUILDPLATFORM
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
ARG TARGETVARIANT
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -11,7 +18,11 @@ RUN go mod download
|
||||
COPY . .
|
||||
|
||||
# Build the soundtouch-service
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /soundtouch-service ./cmd/soundtouch-service
|
||||
RUN if [ "${TARGETARCH}" = "arm" ] && [ -n "${TARGETVARIANT}" ]; then \
|
||||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} go build -o /soundtouch-service ./cmd/soundtouch-service; \
|
||||
else \
|
||||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /soundtouch-service ./cmd/soundtouch-service; \
|
||||
fi
|
||||
|
||||
# Final stage
|
||||
FROM alpine:3.23
|
||||
@@ -24,6 +35,9 @@ WORKDIR /app
|
||||
# Copy the binary from the builder stage
|
||||
COPY --from=builder /soundtouch-service /app/soundtouch-service
|
||||
|
||||
# Verify the binary works on the target platform
|
||||
RUN /app/soundtouch-service version || echo "Binary verification complete"
|
||||
|
||||
# Create data directory for persistence
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ EXAMPLE_UPNP_NAME=example-upnp
|
||||
EXAMPLE_UPNP_PATH=./cmd/$(EXAMPLE_UPNP_NAME)
|
||||
SCANNER_NAME=mdns-scanner
|
||||
SCANNER_PATH=./cmd/$(SCANNER_NAME)
|
||||
FAVICON_GEN_NAME=favicon-gen
|
||||
FAVICON_GEN_PATH=./cmd/$(FAVICON_GEN_NAME)
|
||||
BUILD_DIR=./build
|
||||
|
||||
# Version info
|
||||
@@ -27,7 +29,7 @@ BUILD_DIR=./build
|
||||
|
||||
all: check build
|
||||
|
||||
build: build-cli build-service build-examples
|
||||
build: build-cli build-service build-examples build-favicon-gen
|
||||
|
||||
build-cli:
|
||||
@echo "Building $(BINARY_NAME)..."
|
||||
@@ -48,6 +50,11 @@ build-examples:
|
||||
@echo "Building $(SCANNER_NAME)..."
|
||||
$(GOBUILD) -o $(BUILD_DIR)/$(SCANNER_NAME) $(SCANNER_PATH)
|
||||
|
||||
build-favicon-gen:
|
||||
@echo "Building $(FAVICON_GEN_NAME)..."
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
$(GOBUILD) -o $(BUILD_DIR)/$(FAVICON_GEN_NAME) $(FAVICON_GEN_PATH)
|
||||
|
||||
build-all: build-linux build-darwin build-windows build-examples-all
|
||||
|
||||
build-linux:
|
||||
@@ -226,6 +233,7 @@ help:
|
||||
@echo " build - Build the CLI tool, service, and examples"
|
||||
@echo " build-cli - Build only the CLI tool"
|
||||
@echo " build-service - Build only the service"
|
||||
@echo " build-favicon-gen - Build the favicon generator"
|
||||
@echo " build-examples - Build only the example programs"
|
||||
@echo " build-all - Build for all platforms"
|
||||
@echo " test - Run tests"
|
||||
|
||||
@@ -17,12 +17,18 @@ A comprehensive solution for controlling and preserving Bose SoundTouch devices,
|
||||
- ⚡ **Real-time Events**: WebSocket connection for live device state monitoring
|
||||
- 🔍 **Device Discovery**: Automatic discovery via UPnP/SSDP and mDNS
|
||||
- 📻 **Content Navigation**: Browse and search TuneIn, Pandora, Spotify, local music
|
||||
- 📻 **Custom Radio**: Play any stream URL via [flexible proxying](docs/guides/CLI-REFERENCE.md#custom-radio-selection-via-soundtouch-service)
|
||||
- 📻 **RadioBrowser**: Access thousands of internet radio stations via [radio-browser.info](docs/reference/radio-browser.md)
|
||||
- 🎙️ **Station Management**: Add and play radio stations without presets
|
||||
- 🖥️ **CLI Tool**: Comprehensive command-line interface
|
||||
- 🌐 **SoundTouch Service**: Emulate Bose cloud services for offline device operation
|
||||
- 🔧 **Service Migration**: Migrate devices to use local services instead of Bose cloud
|
||||
- 🔧 **Service Migration**: Migrate devices to use local services instead of Bose cloud (XML, Hosts, or DNS redirection)
|
||||
- 🔍 **DNS Discovery & Interception**: Dynamic DNS server for intercepting and logging Bose service queries (requires port 53)
|
||||
- 📊 **DNS Discovery Analysis**: Track and deduplicate all device DNS queries to discover hidden hostnames
|
||||
- 📊 **Traffic Analysis**: Proxy and log device communications
|
||||
- 📝 **HTTP Recording**: Persist interactions as re-playable `.http` files
|
||||
- 🔄 **Endpoint Mirroring**: Asynchronously mirror local requests to Bose cloud for parity testing
|
||||
- ⚖️ **Parity Logging**: Detect and record discrepancies between local and official Bose responses
|
||||
- 🧹 **Session Management**: Manage and cleanup recorded interaction sessions
|
||||
- 🔒 **Production Ready**: Extensive testing with real SoundTouch hardware
|
||||
- 🌐 **Cross-Platform**: Windows, macOS, Linux support
|
||||
@@ -74,6 +80,8 @@ The `soundtouch-service` is a local server that emulates Bose's cloud services.
|
||||
- **🔧 Device Migration**: Seamlessly transition devices to local control
|
||||
- **🌐 Web Management UI**: Easy browser-based setup and management
|
||||
- **💾 Persistent Data**: Store presets, recents, and sources locally
|
||||
- **🔄 Endpoint Mirroring**: Asynchronously mirror local requests to Bose cloud for parity testing
|
||||
- **⚖️ Parity Logging**: Detect and record discrepancies between local and official Bose responses
|
||||
- **📝 HTTP Recording**: Persist all interactions as re-playable `.http` files
|
||||
- **🧹 Session Management**: Manage and cleanup recorded interaction sessions
|
||||
|
||||
@@ -99,7 +107,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/client"
|
||||
)
|
||||
|
||||
@@ -109,20 +117,20 @@ func main() {
|
||||
Host: "192.168.1.100",
|
||||
Port: 8090,
|
||||
})
|
||||
|
||||
|
||||
// Get device information
|
||||
info, err := c.GetDeviceInfo()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Device: %s\n", info.Name)
|
||||
|
||||
|
||||
// Control playback
|
||||
err = c.Play()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Set volume
|
||||
err = c.SetVolume(50)
|
||||
if err != nil {
|
||||
@@ -140,7 +148,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/discovery"
|
||||
)
|
||||
|
||||
@@ -151,9 +159,9 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
for _, device := range devices {
|
||||
fmt.Printf("Found: %s at %s:%d\n",
|
||||
fmt.Printf("Found: %s at %s:%d\n",
|
||||
device.Name, device.Host, device.Port)
|
||||
}
|
||||
}
|
||||
@@ -167,7 +175,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/client"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
)
|
||||
@@ -177,13 +185,13 @@ func main() {
|
||||
Host: "192.168.1.100",
|
||||
Port: 8090,
|
||||
})
|
||||
|
||||
|
||||
// Subscribe to device events
|
||||
events, err := c.SubscribeToEvents(context.Background())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
for event := range events {
|
||||
switch e := event.(type) {
|
||||
case *models.NowPlayingUpdated:
|
||||
@@ -204,7 +212,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/client"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
)
|
||||
@@ -214,21 +222,21 @@ func main() {
|
||||
Host: "192.168.1.100",
|
||||
Port: 8090,
|
||||
})
|
||||
|
||||
|
||||
// Get current presets
|
||||
presets, err := c.GetPresets()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
fmt.Printf("Found %d presets\n", len(presets.Preset))
|
||||
|
||||
|
||||
// Store currently playing content as preset 1
|
||||
err = c.StoreCurrentAsPreset(1)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Store Spotify playlist as preset 2
|
||||
spotifyContent := &models.ContentItem{
|
||||
Source: "SPOTIFY",
|
||||
@@ -242,7 +250,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Store radio station as preset 3
|
||||
radioContent := &models.ContentItem{
|
||||
Source: "TUNEIN",
|
||||
@@ -255,13 +263,13 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Select preset 1
|
||||
err = c.SelectPreset(1)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
fmt.Println("Preset management complete!")
|
||||
}
|
||||
```
|
||||
@@ -272,7 +280,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/client"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
)
|
||||
@@ -282,7 +290,7 @@ func main() {
|
||||
Host: "192.168.1.100", // Master speaker
|
||||
Port: 8090,
|
||||
})
|
||||
|
||||
|
||||
// Create a multiroom zone
|
||||
zone := &models.Zone{
|
||||
Master: "192.168.1.100",
|
||||
@@ -291,12 +299,12 @@ func main() {
|
||||
{IPAddress: "192.168.1.102"}, // Kitchen
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
err := master.SetZone(zone)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
fmt.Println("Multiroom zone created!")
|
||||
}
|
||||
```
|
||||
@@ -307,7 +315,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/client"
|
||||
)
|
||||
|
||||
@@ -316,13 +324,13 @@ func main() {
|
||||
Host: "192.168.1.100",
|
||||
Port: 8090,
|
||||
})
|
||||
|
||||
// Play Text-to-Speech message
|
||||
err := c.PlayTTS("Welcome home!", "your-app-key", 70)
|
||||
|
||||
// Play Text-to-Speech message (language code "EN", "DE", etc.)
|
||||
err := c.PlayTTS("Welcome home!", "your-app-key", "EN", 70)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Play audio content from URL
|
||||
err = c.PlayURL(
|
||||
"https://example.com/doorbell.mp3",
|
||||
@@ -335,13 +343,13 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
// Play notification beep
|
||||
err = c.PlayNotificationBeep()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
fmt.Println("Notifications sent!")
|
||||
}
|
||||
```
|
||||
@@ -351,7 +359,7 @@ func main() {
|
||||
This library supports all Bose SoundTouch-compatible devices, including:
|
||||
|
||||
- SoundTouch 10, 20, 30 series
|
||||
- SoundTouch Portable
|
||||
- SoundTouch Portable
|
||||
- Wave SoundTouch music system
|
||||
- SoundTouch-enabled Bose speakers
|
||||
|
||||
@@ -512,7 +520,7 @@ This project builds upon the excellent work of several community projects:
|
||||
These projects together form a comprehensive ecosystem for SoundTouch device management:
|
||||
|
||||
- **This Project**: Go library + CLI + service for programmatic control and offline operation
|
||||
- **SoundCork**: Python-based service interception and cloud replacement
|
||||
- **SoundCork**: Python-based service interception and cloud replacement
|
||||
- **SoundTouch Plus**: Home Assistant integration with extensive device support
|
||||
- **ÜberBöse**: API research and advanced endpoint discovery
|
||||
- **SoundTouch Hook**: Advanced reverse engineering and process instrumentation
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
// Package main provides a debug tool for analyzing device consolidation and migration scenarios.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Usage: debug-consolidation <data-directory>")
|
||||
fmt.Println("Example: debug-consolidation /var/lib/soundtouch-service")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
dataDir := os.Args[1]
|
||||
|
||||
fmt.Printf("🔍 Analyzing device consolidation in: %s\n", dataDir)
|
||||
|
||||
// Initialize datastore
|
||||
ds := datastore.NewDataStore(dataDir)
|
||||
|
||||
// List all devices
|
||||
devices, err := ds.ListAllDevices()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to list devices: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("📱 Found %d device entries:\n", len(devices))
|
||||
|
||||
for i := range devices {
|
||||
device := &devices[i]
|
||||
fmt.Printf(" %d. %s (Account: %s)\n", i+1, device.DeviceID, device.AccountID)
|
||||
fmt.Printf(" Name: %s\n", device.Name)
|
||||
fmt.Printf(" IP: %s, MAC: %s, Serial: %s\n",
|
||||
device.IPAddress, device.MacAddress, device.DeviceSerialNumber)
|
||||
|
||||
// Check directory contents
|
||||
deviceDir := ds.AccountDeviceDir(device.AccountID, device.DeviceID)
|
||||
analyzeDeviceDirectory(deviceDir, device.DeviceID)
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// Group devices by potential physical device
|
||||
fmt.Println("🔄 Analyzing potential consolidation opportunities:")
|
||||
|
||||
deviceGroups := groupDevicesByIdentity(devices)
|
||||
|
||||
for i, group := range deviceGroups {
|
||||
if len(group) <= 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf(" Group %d - %d entries for same physical device:\n", i+1, len(group))
|
||||
|
||||
for i := range group {
|
||||
device := &group[i]
|
||||
deviceDir := ds.AccountDeviceDir(device.AccountID, device.DeviceID)
|
||||
fileCount := countFiles(deviceDir)
|
||||
fmt.Printf(" - %s (%d files)\n", device.DeviceID, fileCount)
|
||||
}
|
||||
|
||||
// Recommend consolidation target
|
||||
macDevice := findMACBasedDevice(group)
|
||||
if macDevice != nil {
|
||||
fmt.Printf(" → Recommend keeping: %s (MAC-based)\n", macDevice.DeviceID)
|
||||
} else {
|
||||
fmt.Printf(" → No clear MAC-based target found\n")
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func analyzeDeviceDirectory(dirPath, deviceID string) {
|
||||
entries, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
fmt.Printf(" Directory: %s (Error: %v)\n", dirPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf(" Directory: %s (%d files)\n", dirPath, len(entries))
|
||||
|
||||
// Check for important files
|
||||
importantFiles := []string{"DeviceInfo.xml", "Presets.xml", "Recents.xml", "Sources.xml"}
|
||||
for _, fileName := range importantFiles {
|
||||
filePath := filepath.Join(dirPath, fileName)
|
||||
if stat, err := os.Stat(filePath); err == nil {
|
||||
status := "✓"
|
||||
if stat.Size() == 0 {
|
||||
status = "⚠️ (empty)"
|
||||
} else if stat.Size() < 100 {
|
||||
status = "⚠️ (very small)"
|
||||
}
|
||||
|
||||
fmt.Printf(" %s %s (%d bytes)\n", status, fileName, stat.Size())
|
||||
} else {
|
||||
fmt.Printf(" ❌ %s (missing)\n", fileName)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if deviceID looks like MAC address
|
||||
if isLikelyMACAddress(deviceID) {
|
||||
fmt.Printf(" 📍 Device ID appears to be MAC address format\n")
|
||||
} else {
|
||||
fmt.Printf(" 📍 Device ID appears to be %s format\n", guessIDType(deviceID))
|
||||
}
|
||||
}
|
||||
|
||||
func countFiles(dirPath string) int {
|
||||
entries, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
count := 0
|
||||
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
func groupDevicesByIdentity(devices []models.ServiceDeviceInfo) [][]models.ServiceDeviceInfo {
|
||||
var groups [][]models.ServiceDeviceInfo
|
||||
|
||||
// Simple grouping by MAC address and serial number
|
||||
macGroups := make(map[string][]models.ServiceDeviceInfo)
|
||||
serialGroups := make(map[string][]models.ServiceDeviceInfo)
|
||||
ipGroups := make(map[string][]models.ServiceDeviceInfo)
|
||||
|
||||
for i := range devices {
|
||||
device := &devices[i]
|
||||
// Group by MAC address
|
||||
if device.MacAddress != "" {
|
||||
macGroups[device.MacAddress] = append(macGroups[device.MacAddress], *device)
|
||||
}
|
||||
|
||||
// Group by serial number
|
||||
if device.DeviceSerialNumber != "" {
|
||||
serialGroups[device.DeviceSerialNumber] = append(serialGroups[device.DeviceSerialNumber], *device)
|
||||
}
|
||||
|
||||
// Group by IP address
|
||||
if device.IPAddress != "" {
|
||||
ipGroups[device.IPAddress] = append(ipGroups[device.IPAddress], *device)
|
||||
}
|
||||
}
|
||||
|
||||
// Merge groups - prioritize MAC address grouping
|
||||
processed := make(map[string]bool)
|
||||
|
||||
for _, macDevices := range macGroups {
|
||||
if len(macDevices) > 1 {
|
||||
groups = append(groups, macDevices)
|
||||
for i := range macDevices {
|
||||
processed[macDevices[i].DeviceID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for serial number groups not already processed
|
||||
for _, serialDevices := range serialGroups {
|
||||
if len(serialDevices) > 1 {
|
||||
unprocessed := []models.ServiceDeviceInfo{}
|
||||
|
||||
for i := range serialDevices {
|
||||
if !processed[serialDevices[i].DeviceID] {
|
||||
unprocessed = append(unprocessed, serialDevices[i])
|
||||
}
|
||||
}
|
||||
|
||||
if len(unprocessed) > 1 {
|
||||
groups = append(groups, unprocessed)
|
||||
for i := range unprocessed {
|
||||
processed[unprocessed[i].DeviceID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
func findMACBasedDevice(devices []models.ServiceDeviceInfo) *models.ServiceDeviceInfo {
|
||||
for i := range devices {
|
||||
if isLikelyMACAddress(devices[i].DeviceID) {
|
||||
return &devices[i]
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isLikelyMACAddress(id string) bool {
|
||||
// MAC addresses are typically 12 hex characters without separators
|
||||
// or 17 characters with separators (XX:XX:XX:XX:XX:XX)
|
||||
if len(id) == 12 {
|
||||
for _, c := range id {
|
||||
if (c < '0' || c > '9') && (c < 'A' || c > 'F') && (c < 'a' || c > 'f') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func guessIDType(id string) string {
|
||||
if len(id) > 15 && (id[0] == 'I' || id[0] == 'K') {
|
||||
return "serial number"
|
||||
}
|
||||
|
||||
// Check if it looks like an IP address
|
||||
if len(id) >= 7 && len(id) <= 15 {
|
||||
dotCount := 0
|
||||
|
||||
for _, c := range id {
|
||||
if c == '.' {
|
||||
dotCount++
|
||||
} else if c < '0' || c > '9' {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if dotCount == 3 {
|
||||
return "IP address"
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// Package main provides a utility to generate PNG and ICO favicons from SVG source files.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/srwiley/oksvg"
|
||||
"github.com/srwiley/rasterx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mediaDir := "pkg/service/handlers/web/img"
|
||||
files := []string{"favicon-braille", "favicon-morse"}
|
||||
|
||||
for _, name := range files {
|
||||
svgPath := filepath.Join(mediaDir, name+".svg")
|
||||
pngPath := filepath.Join(mediaDir, name+".png")
|
||||
icoPath := filepath.Join(mediaDir, name+".ico")
|
||||
|
||||
fmt.Printf("Processing %s...\n", name)
|
||||
|
||||
// 1. Render SVG to PNG
|
||||
img, err := renderSVG(svgPath, 32, 32)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to render %s: %v", svgPath, err)
|
||||
}
|
||||
|
||||
f, err := os.Create(pngPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create %s: %v", pngPath, err)
|
||||
}
|
||||
|
||||
if err := png.Encode(f, img); err != nil {
|
||||
f.Close()
|
||||
log.Fatalf("Failed to encode PNG %s: %v", pngPath, err)
|
||||
}
|
||||
|
||||
f.Close()
|
||||
fmt.Printf("Created %s\n", pngPath)
|
||||
|
||||
// 2. Create ICO (containing multiple sizes)
|
||||
sizes := []int{16, 32, 48}
|
||||
|
||||
var images []image.Image
|
||||
|
||||
for _, s := range sizes {
|
||||
m, err := renderSVG(svgPath, s, s)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to render %s at size %d: %v", svgPath, s, err)
|
||||
}
|
||||
|
||||
images = append(images, m)
|
||||
}
|
||||
|
||||
if err := writeICO(icoPath, images); err != nil {
|
||||
log.Fatalf("Failed to write ICO %s: %v", icoPath, err)
|
||||
}
|
||||
|
||||
fmt.Printf("Created %s\n", icoPath)
|
||||
}
|
||||
}
|
||||
|
||||
func renderSVG(path string, w, h int) (image.Image, error) {
|
||||
in, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
icon, err := oksvg.ReadIconStream(in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
icon.SetTarget(0, 0, float64(w), float64(h))
|
||||
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
gv := rasterx.NewScannerGV(w, h, rgba, rgba.Bounds())
|
||||
dasher := rasterx.NewDasher(w, h, gv)
|
||||
icon.Draw(dasher, 1.0)
|
||||
|
||||
return rgba, nil
|
||||
}
|
||||
|
||||
// Simple ICO encoder that wraps PNGs
|
||||
func writeICO(path string, images []image.Image) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
bw := bufio.NewWriter(f)
|
||||
defer bw.Flush()
|
||||
|
||||
// ICONDIR header
|
||||
// Reserved (2), Type (2), Count (2)
|
||||
binary.Write(bw, binary.LittleEndian, uint16(0))
|
||||
binary.Write(bw, binary.LittleEndian, uint16(1)) // 1 = ICO
|
||||
binary.Write(bw, binary.LittleEndian, uint16(len(images)))
|
||||
|
||||
var pngData [][]byte
|
||||
|
||||
for _, img := range images {
|
||||
var buf bytes.Buffer
|
||||
if err := png.Encode(&buf, img); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pngData = append(pngData, buf.Bytes())
|
||||
}
|
||||
|
||||
offset := uint32(6 + len(images)*16)
|
||||
for i, img := range images {
|
||||
b := img.Bounds()
|
||||
|
||||
width := uint8(b.Dx())
|
||||
if b.Dx() >= 256 {
|
||||
width = 0
|
||||
}
|
||||
|
||||
height := uint8(b.Dy())
|
||||
if b.Dy() >= 256 {
|
||||
height = 0
|
||||
}
|
||||
|
||||
// ICONDIRENTRY
|
||||
bw.WriteByte(width)
|
||||
bw.WriteByte(height)
|
||||
bw.WriteByte(0) // Color count
|
||||
bw.WriteByte(0) // Reserved
|
||||
binary.Write(bw, binary.LittleEndian, uint16(1)) // Planes (1)
|
||||
binary.Write(bw, binary.LittleEndian, uint16(32)) // Bits per pixel (32)
|
||||
binary.Write(bw, binary.LittleEndian, uint32(len(pngData[i])))
|
||||
binary.Write(bw, binary.LittleEndian, offset)
|
||||
|
||||
offset += uint32(len(pngData[i]))
|
||||
}
|
||||
|
||||
for _, data := range pngData {
|
||||
bw.Write(data)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -389,6 +389,10 @@ func handleSpecialMessage(message *models.SpecialMessage, filters map[string]boo
|
||||
if !filters["userActivity"] {
|
||||
return
|
||||
}
|
||||
case models.MessageTypeUserInactivity:
|
||||
if !filters["userInactivity"] {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +406,12 @@ func handleSpecialMessage(message *models.SpecialMessage, filters map[string]boo
|
||||
case models.MessageTypeUserActivity:
|
||||
fmt.Printf("\n👤 User Activity [%s]\n", message.DeviceID)
|
||||
|
||||
if verbose {
|
||||
fmt.Printf(" ⏰ Timestamp: %s\n", message.Timestamp.Format("15:04:05"))
|
||||
}
|
||||
case models.MessageTypeUserInactivity:
|
||||
fmt.Printf("\n💤 User Inactivity [%s]\n", message.DeviceID)
|
||||
|
||||
if verbose {
|
||||
fmt.Printf(" ⏰ Timestamp: %s\n", message.Timestamp.Format("15:04:05"))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
@@ -251,6 +253,61 @@ func selectLocalInternetRadio(c *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// selectCustomRadio handles selecting custom radio stream via soundtouch-service
|
||||
func selectCustomRadio(c *cli.Context) error {
|
||||
clientConfig := GetClientConfig(c)
|
||||
|
||||
client, err := CreateSoundTouchClient(clientConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
streamURL := c.String("url")
|
||||
itemName := c.String("name")
|
||||
containerArt := c.String("artwork")
|
||||
serviceURL := c.String("service-url")
|
||||
|
||||
encodedURL := base64.URLEncoding.EncodeToString([]byte(streamURL))
|
||||
location := fmt.Sprintf("%s/custom/v1/playback/%s", serviceURL, encodedURL)
|
||||
|
||||
params := url.Values{}
|
||||
if itemName != "" {
|
||||
params.Add("name", itemName)
|
||||
}
|
||||
|
||||
if containerArt != "" {
|
||||
params.Add("imageUrl", containerArt)
|
||||
}
|
||||
|
||||
if len(params) > 0 {
|
||||
location += "?" + params.Encode()
|
||||
}
|
||||
|
||||
// Check LOCAL_INTERNET_RADIO availability
|
||||
checker := NewServiceAvailabilityChecker(client)
|
||||
if !checker.CheckSourceAvailable("LOCAL_INTERNET_RADIO", "select custom radio") {
|
||||
return fmt.Errorf("LOCAL_INTERNET_RADIO is not available")
|
||||
}
|
||||
|
||||
PrintDeviceHeader("Selecting custom radio stream", clientConfig.Host, clientConfig.Port)
|
||||
|
||||
if itemName != "" {
|
||||
fmt.Printf(" Station: %s\n", itemName)
|
||||
}
|
||||
|
||||
fmt.Printf(" URL: %s\n", streamURL)
|
||||
fmt.Printf(" Proxy: %s\n", location)
|
||||
|
||||
err = client.SelectLocalInternetRadio(location, "", itemName, containerArt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to select custom radio: %w", err)
|
||||
}
|
||||
|
||||
PrintSuccess("Custom radio stream selected")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// selectLocalMusic handles selecting LOCAL_MUSIC source
|
||||
func selectLocalMusic(c *cli.Context) error {
|
||||
clientConfig := GetClientConfig(c)
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/models"
|
||||
@@ -35,23 +34,12 @@ func playTTS(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// URL encode the text for Google TTS
|
||||
encodedText := url.QueryEscape(text)
|
||||
|
||||
// Build TTS URL with language support
|
||||
ttsURL := fmt.Sprintf("http://translate.google.com/translate_tts?ie=UTF-8&tl=%s&client=tw-ob&q=%s", language, encodedText)
|
||||
|
||||
// Create PlayInfo for TTS
|
||||
playInfo := &models.PlayInfo{
|
||||
URL: ttsURL,
|
||||
AppKey: appKey,
|
||||
Service: "TTS Notification",
|
||||
Message: "Google TTS",
|
||||
Reason: text,
|
||||
}
|
||||
|
||||
var playInfo *models.PlayInfo
|
||||
if volume > 0 {
|
||||
playInfo.SetVolume(volume)
|
||||
playInfo = models.NewTTSPlayInfo(text, appKey, language, volume)
|
||||
} else {
|
||||
playInfo = models.NewTTSPlayInfo(text, appKey, language)
|
||||
}
|
||||
|
||||
err = client.PlayCustom(playInfo)
|
||||
@@ -121,10 +109,11 @@ func playURL(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// Create PlayInfo for URL content
|
||||
playInfo := models.NewURLPlayInfo(urlStr, appKey, service, message, reason)
|
||||
|
||||
var playInfo *models.PlayInfo
|
||||
if volume > 0 {
|
||||
playInfo.SetVolume(volume)
|
||||
playInfo = models.NewURLPlayInfo(urlStr, appKey, service, message, reason, volume)
|
||||
} else {
|
||||
playInfo = models.NewURLPlayInfo(urlStr, appKey, service, message, reason)
|
||||
}
|
||||
|
||||
err = client.PlayCustom(playInfo)
|
||||
|
||||
@@ -924,6 +924,34 @@ func main() {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "custom-radio",
|
||||
Usage: "Select custom radio stream via soundtouch-service",
|
||||
Action: selectCustomRadio,
|
||||
Before: RequireHost,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "url",
|
||||
Aliases: []string{"u"},
|
||||
Usage: "Stream URL",
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Aliases: []string{"n"},
|
||||
Usage: "Station name",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "artwork",
|
||||
Usage: "Station artwork URL",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "service-url",
|
||||
Usage: "URL of the soundtouch-service (default: http://localhost:8080)",
|
||||
Value: "http://localhost:8080",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "local-music",
|
||||
Usage: "Select local music content (LOCAL_MUSIC)",
|
||||
|
||||
+503
-168
@@ -8,8 +8,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -18,11 +18,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/discovery"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/certmanager"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/handlers"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/proxy"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/setup"
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/spotify"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -80,17 +82,6 @@ func main() {
|
||||
Usage: "Network interface to bind to",
|
||||
EnvVars: []string{"BIND_ADDR"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "soundcork-url",
|
||||
Usage: "URL for Soundcork-based service components (legacy)",
|
||||
Value: "http://localhost:8001",
|
||||
EnvVars: []string{"SOUNDCORK_BACKEND_URL", "TARGET_URL"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "enable-soundcork-proxy",
|
||||
Usage: "Enable proxying unknown requests to the Soundcork backend",
|
||||
EnvVars: []string{"ENABLE_SOUNDCORK_PROXY"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "data-dir",
|
||||
Usage: "Directory for persistent data",
|
||||
@@ -138,6 +129,93 @@ func main() {
|
||||
Value: "5m",
|
||||
EnvVars: []string{"DISCOVERY_INTERVAL"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "dns-discovery",
|
||||
Usage: "Enable DNS discovery server",
|
||||
EnvVars: []string{"ENABLE_DNS_DISCOVERY"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dns-upstream",
|
||||
Usage: "Upstream DNS server(s) for non-Bose queries (comma-separated). If empty, /etc/resolv.conf is used.",
|
||||
Value: "",
|
||||
EnvVars: []string{"DNS_UPSTREAM"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dns-bind",
|
||||
Usage: "Bind address for the DNS discovery server",
|
||||
Value: ":53",
|
||||
EnvVars: []string{"DNS_BIND_ADDR"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "spotify-client-id",
|
||||
Usage: "Spotify OAuth client ID",
|
||||
EnvVars: []string{"SPOTIFY_CLIENT_ID"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "spotify-client-secret",
|
||||
Usage: "Spotify OAuth client secret",
|
||||
EnvVars: []string{"SPOTIFY_CLIENT_SECRET"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "spotify-redirect-uri",
|
||||
Usage: "Spotify OAuth redirect URI",
|
||||
Value: "ueberboese-login://spotify",
|
||||
EnvVars: []string{"SPOTIFY_REDIRECT_URI"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "mgmt-username",
|
||||
Usage: "Management API username for HTTP Basic Auth",
|
||||
Value: "admin",
|
||||
EnvVars: []string{"MGMT_USERNAME"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "mgmt-password",
|
||||
Usage: "Management API password for HTTP Basic Auth",
|
||||
Value: "change_me!",
|
||||
EnvVars: []string{"MGMT_PASSWORD"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "base-url",
|
||||
Usage: "External base URL for OAuth callbacks behind reverse proxy",
|
||||
EnvVars: []string{"BASE_URL"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "mirror-enabled",
|
||||
Usage: "Enable background mirroring to Bose Cloud",
|
||||
EnvVars: []string{"MIRROR_ENABLED"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "mirror-endpoints",
|
||||
Usage: "Endpoints to mirror to Bose Cloud (comma-separated or multiple flags)",
|
||||
EnvVars: []string{"MIRROR_ENDPOINTS"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "skip-mirror-endpoints",
|
||||
Usage: "Endpoints to skip mirroring to Bose Cloud (comma-separated or multiple flags)",
|
||||
EnvVars: []string{"SKIP_MIRROR_ENDPOINTS"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "internal-paths",
|
||||
Usage: "Paths for internal requests (comma-separated or multiple flags)",
|
||||
EnvVars: []string{"INTERNAL_PATHS"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "migration-enabled",
|
||||
Usage: "Enable device directory migration from serial to MAC-based structure",
|
||||
Value: true,
|
||||
EnvVars: []string{"MIGRATION_ENABLED"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "migration-dry-run",
|
||||
Usage: "Log what would be migrated without actually doing it",
|
||||
EnvVars: []string{"MIGRATION_DRY_RUN"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "preferred-source",
|
||||
Usage: "Preferred source of truth (local or upstream)",
|
||||
Value: "local",
|
||||
EnvVars: []string{"PREFERRED_SOURCE"},
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
config := loadConfig(c)
|
||||
@@ -160,10 +238,55 @@ func main() {
|
||||
|
||||
cm := initCertificateManager(config.dataDir)
|
||||
sm := setup.NewManager(config.serverURL, ds, cm)
|
||||
server := handlers.NewServer(ds, sm, config.serverURL, config.redact, config.logBody, config.record, config.enableSoundcorkProxy)
|
||||
sm.MgmtUsername = config.mgmtUsername
|
||||
sm.MgmtPassword = config.mgmtPassword
|
||||
server := handlers.NewServer(ds, sm, config.serverURL, config.redact, config.logBody, config.record)
|
||||
sm.GetDNSRunning = server.GetDNSRunning
|
||||
server.SetHTTPServerURL(config.httpsServerURL)
|
||||
server.SetVersionInfo(version, commit, date)
|
||||
server.SetDiscoverySettings(config.discoveryInterval, persisted.DiscoveryEnabled)
|
||||
server.SetDNSSettings(persisted.DNSEnabled, strings.Join(persisted.DNSUpstream, ","), persisted.DNSBindAddr)
|
||||
server.SetMirrorSettings(persisted.MirrorEnabled, persisted.MirrorEndpoints, persisted.SkipMirrorEndpoints, persisted.PreferredSource)
|
||||
server.SetInternalPaths(persisted.InternalPaths)
|
||||
server.SetSpotifyConfig(config.spotifyClientID, config.spotifyClientSecret, config.spotifyRedirectURI)
|
||||
server.SetMgmtConfig(config.mgmtUsername, config.mgmtPassword)
|
||||
|
||||
if config.spotifyClientID != "" {
|
||||
spotifyService := spotify.NewSpotifyService(
|
||||
config.spotifyClientID,
|
||||
config.spotifyClientSecret,
|
||||
config.spotifyRedirectURI,
|
||||
config.dataDir,
|
||||
)
|
||||
server.SetSpotifyService(spotifyService)
|
||||
|
||||
clientIDPrefix := config.spotifyClientID
|
||||
if len(clientIDPrefix) > 8 {
|
||||
clientIDPrefix = clientIDPrefix[:8]
|
||||
}
|
||||
|
||||
log.Printf("Spotify service initialized (client ID: %s...)", clientIDPrefix)
|
||||
}
|
||||
|
||||
// Load and set initial DNS discoveries
|
||||
dnsDiscoveries, err := ds.LoadDNSDiscoveries()
|
||||
if err == nil && len(dnsDiscoveries) > 0 {
|
||||
initial := make(map[string]*discovery.DiscoveredHost)
|
||||
for _, entry := range dnsDiscoveries {
|
||||
initial[entry.Hostname] = &discovery.DiscoveredHost{
|
||||
Hostname: entry.Hostname,
|
||||
FirstSeen: entry.FirstSeen,
|
||||
LastSeen: entry.LastSeen,
|
||||
QueryCount: entry.QueryCount,
|
||||
IsBoseService: entry.IsBoseService,
|
||||
IsIntercepted: entry.IsIntercepted,
|
||||
RemoteAddr: entry.RemoteAddr,
|
||||
}
|
||||
}
|
||||
|
||||
server.SetDNSDiscoveries(initial)
|
||||
}
|
||||
|
||||
server.SetShortcuts(persisted.Shortcuts)
|
||||
|
||||
for path, status := range persisted.Shortcuts {
|
||||
@@ -203,13 +326,11 @@ func main() {
|
||||
log.Printf("Warning: Failed to setup TLS: %v", err)
|
||||
}
|
||||
|
||||
scProxy := setupSoundcorkProxy(config.soundcorkURL, config.redact, config.logBody, recorder, server)
|
||||
|
||||
startDeviceDiscovery(server)
|
||||
|
||||
r := setupRouter(server, scProxy, config.enableSoundcorkProxy)
|
||||
r := setupRouter(server)
|
||||
|
||||
log.Printf("Go service starting on %s, proxying to %s", config.serverURL, config.soundcorkURL)
|
||||
log.Printf("Go service starting on %s", config.serverURL)
|
||||
|
||||
if tlsConfig != nil {
|
||||
startHTTPSServer(config.httpsAddr, r, tlsConfig, config.httpsServerURL)
|
||||
@@ -243,20 +364,33 @@ func showVersionInfo(_ *cli.Context) error {
|
||||
}
|
||||
|
||||
type serviceConfig struct {
|
||||
port string
|
||||
bindAddr string
|
||||
addr string
|
||||
soundcorkURL string
|
||||
dataDir string
|
||||
serverURL string
|
||||
httpsServerURL string
|
||||
httpsAddr string
|
||||
redact bool
|
||||
logBody bool
|
||||
record bool
|
||||
enableSoundcorkProxy bool
|
||||
discoveryInterval time.Duration
|
||||
domains []string
|
||||
port string
|
||||
bindAddr string
|
||||
addr string
|
||||
dataDir string
|
||||
serverURL string
|
||||
httpsServerURL string
|
||||
httpsAddr string
|
||||
redact bool
|
||||
logBody bool
|
||||
record bool
|
||||
dnsEnabled bool
|
||||
dnsUpstream string
|
||||
dnsBind string
|
||||
mirrorEnabled bool
|
||||
mirrorEndpoints []string
|
||||
skipMirrorEndpoints []string
|
||||
internalPaths []string
|
||||
discoveryInterval time.Duration
|
||||
domains []string
|
||||
spotifyClientID string
|
||||
spotifyClientSecret string
|
||||
spotifyRedirectURI string
|
||||
mgmtUsername string
|
||||
mgmtPassword string
|
||||
migrationEnabled bool
|
||||
migrationDryRun bool
|
||||
preferredSource string
|
||||
}
|
||||
|
||||
func loadConfig(c *cli.Context) serviceConfig {
|
||||
@@ -268,7 +402,6 @@ func loadConfig(c *cli.Context) serviceConfig {
|
||||
addr = ":" + port
|
||||
}
|
||||
|
||||
soundcorkURL := c.String("soundcork-url")
|
||||
dataDir := c.String("data-dir")
|
||||
|
||||
hostname, _ := os.Hostname()
|
||||
@@ -300,7 +433,10 @@ func loadConfig(c *cli.Context) serviceConfig {
|
||||
redact := c.Bool("redact-logs")
|
||||
logBody := c.Bool("log-bodies")
|
||||
record := c.Bool("record-interactions")
|
||||
enableSoundcorkProxy := c.Bool("enable-soundcork-proxy")
|
||||
|
||||
dnsEnabled := c.Bool("dns-discovery")
|
||||
dnsUpstream := c.String("dns-upstream")
|
||||
dnsBind := c.String("dns-bind")
|
||||
|
||||
discoveryIntervalStr := c.String("discovery-interval")
|
||||
|
||||
@@ -311,35 +447,72 @@ func loadConfig(c *cli.Context) serviceConfig {
|
||||
discoveryInterval = 5 * time.Minute
|
||||
}
|
||||
|
||||
spotifyClientID := c.String("spotify-client-id")
|
||||
spotifyClientSecret := c.String("spotify-client-secret")
|
||||
spotifyRedirectURI := c.String("spotify-redirect-uri")
|
||||
mgmtUsername := c.String("mgmt-username")
|
||||
mgmtPassword := c.String("mgmt-password")
|
||||
mirrorEnabled := c.Bool("mirror-enabled")
|
||||
mirrorEndpoints := c.StringSlice("mirror-endpoints")
|
||||
skipMirrorEndpoints := c.StringSlice("skip-mirror-endpoints")
|
||||
internalPaths := c.StringSlice("internal-paths")
|
||||
migrationEnabled := c.Bool("migration-enabled")
|
||||
migrationDryRun := c.Bool("migration-dry-run")
|
||||
preferredSource := c.String("preferred-source")
|
||||
|
||||
return serviceConfig{
|
||||
port: port,
|
||||
bindAddr: bindAddr,
|
||||
addr: addr,
|
||||
soundcorkURL: soundcorkURL,
|
||||
dataDir: dataDir,
|
||||
serverURL: serverURL,
|
||||
httpsServerURL: httpsServerURL,
|
||||
httpsAddr: httpsAddr,
|
||||
redact: redact,
|
||||
logBody: logBody,
|
||||
record: record,
|
||||
enableSoundcorkProxy: enableSoundcorkProxy,
|
||||
discoveryInterval: discoveryInterval,
|
||||
domains: domains,
|
||||
port: port,
|
||||
bindAddr: bindAddr,
|
||||
addr: addr,
|
||||
dataDir: dataDir,
|
||||
serverURL: serverURL,
|
||||
httpsServerURL: httpsServerURL,
|
||||
httpsAddr: httpsAddr,
|
||||
redact: redact,
|
||||
logBody: logBody,
|
||||
record: record,
|
||||
dnsEnabled: dnsEnabled,
|
||||
dnsUpstream: dnsUpstream,
|
||||
dnsBind: dnsBind,
|
||||
mirrorEnabled: mirrorEnabled,
|
||||
mirrorEndpoints: mirrorEndpoints,
|
||||
skipMirrorEndpoints: skipMirrorEndpoints,
|
||||
internalPaths: internalPaths,
|
||||
discoveryInterval: discoveryInterval,
|
||||
domains: domains,
|
||||
spotifyClientID: spotifyClientID,
|
||||
spotifyClientSecret: spotifyClientSecret,
|
||||
spotifyRedirectURI: spotifyRedirectURI,
|
||||
mgmtUsername: mgmtUsername,
|
||||
mgmtPassword: mgmtPassword,
|
||||
migrationEnabled: migrationEnabled,
|
||||
migrationDryRun: migrationDryRun,
|
||||
preferredSource: preferredSource,
|
||||
}
|
||||
}
|
||||
|
||||
func getDomains(serverURL, httpsServerURL, hostname string) []string {
|
||||
domainsMap := map[string]bool{
|
||||
"streaming.bose.com": true,
|
||||
"updates.bose.com": true,
|
||||
"stats.bose.com": true,
|
||||
"bmx.bose.com": true,
|
||||
"content.api.bose.io": true,
|
||||
setup.TestDomain: true,
|
||||
hostname: true,
|
||||
"localhost": true,
|
||||
"127.0.0.1": true,
|
||||
// RFC-compliant wildcards for API patterns
|
||||
"*.api.bose.io": true,
|
||||
"*.api.bosecm.com": true,
|
||||
// Core Bose domains (keep specific ones for clarity)
|
||||
"streaming.bose.com": true,
|
||||
"updates.bose.com": true,
|
||||
"stats.bose.com": true,
|
||||
"bmx.bose.com": true,
|
||||
"worldwide.bose.com": true,
|
||||
"music.api.bose.com": true,
|
||||
"streamingoauth.bose.com": true,
|
||||
"bosecm.com": true,
|
||||
"bose.io": true,
|
||||
"bose-prod.apigee.net": true,
|
||||
"bose-test.apigee.net": true,
|
||||
// Local service domains
|
||||
setup.TestDomain: true,
|
||||
hostname: true,
|
||||
"localhost": true,
|
||||
"127.0.0.1": true,
|
||||
}
|
||||
|
||||
if u, err := url.Parse(serverURL); err == nil && u.Hostname() != "" {
|
||||
@@ -364,12 +537,15 @@ func applyPersistedSettings(ds *datastore.DataStore, config *serviceConfig) data
|
||||
return datastore.Settings{}
|
||||
}
|
||||
|
||||
if persisted.ServerURL != "" {
|
||||
config.serverURL = persisted.ServerURL
|
||||
// Only override CLI values if settings file exists
|
||||
// If no settings file exists, GetSettings returns empty Settings{} and we should preserve CLI values
|
||||
settingsPath := filepath.Join(ds.DataDir, "settings.json")
|
||||
if _, err := os.Stat(settingsPath); os.IsNotExist(err) {
|
||||
return datastore.Settings{}
|
||||
}
|
||||
|
||||
if persisted.SoundcorkURL != "" {
|
||||
config.soundcorkURL = persisted.SoundcorkURL
|
||||
if persisted.ServerURL != "" {
|
||||
config.serverURL = persisted.ServerURL
|
||||
}
|
||||
|
||||
if persisted.HTTPServerURL != "" {
|
||||
@@ -382,30 +558,51 @@ func applyPersistedSettings(ds *datastore.DataStore, config *serviceConfig) data
|
||||
}
|
||||
}
|
||||
|
||||
config.redact = persisted.RedactLogs || config.redact
|
||||
config.logBody = persisted.LogBodies || config.logBody
|
||||
config.record = persisted.RecordInteractions || config.record
|
||||
config.enableSoundcorkProxy = persisted.EnableSoundcorkProxy || config.enableSoundcorkProxy
|
||||
config.redact = persisted.RedactLogs
|
||||
config.logBody = persisted.LogBodies
|
||||
config.record = persisted.RecordInteractions
|
||||
|
||||
config.dnsEnabled = persisted.DNSEnabled
|
||||
if len(persisted.DNSUpstream) > 0 {
|
||||
config.dnsUpstream = strings.Join(persisted.DNSUpstream, ",")
|
||||
}
|
||||
|
||||
if persisted.DNSBindAddr != "" {
|
||||
config.dnsBind = persisted.DNSBindAddr
|
||||
}
|
||||
|
||||
config.mirrorEnabled = persisted.MirrorEnabled
|
||||
config.mirrorEndpoints = persisted.MirrorEndpoints
|
||||
config.skipMirrorEndpoints = persisted.SkipMirrorEndpoints
|
||||
config.preferredSource = persisted.PreferredSource
|
||||
config.internalPaths = persisted.InternalPaths
|
||||
|
||||
return persisted
|
||||
}
|
||||
|
||||
func createDefaultSettings(ds *datastore.DataStore, config serviceConfig) datastore.Settings {
|
||||
settings := datastore.Settings{
|
||||
ServerURL: config.serverURL,
|
||||
SoundcorkURL: config.soundcorkURL,
|
||||
HTTPServerURL: config.httpsServerURL,
|
||||
RedactLogs: config.redact,
|
||||
LogBodies: config.logBody,
|
||||
RecordInteractions: config.record,
|
||||
DiscoveryInterval: config.discoveryInterval.String(),
|
||||
DiscoveryEnabled: true,
|
||||
EnableSoundcorkProxy: config.enableSoundcorkProxy,
|
||||
ServerURL: config.serverURL,
|
||||
HTTPServerURL: config.httpsServerURL,
|
||||
RedactLogs: config.redact,
|
||||
LogBodies: config.logBody,
|
||||
RecordInteractions: config.record,
|
||||
DiscoveryInterval: config.discoveryInterval.String(),
|
||||
DiscoveryEnabled: true,
|
||||
DNSEnabled: config.dnsEnabled,
|
||||
DNSUpstream: strings.Split(config.dnsUpstream, ","),
|
||||
DNSBindAddr: config.dnsBind,
|
||||
MirrorEnabled: config.mirrorEnabled,
|
||||
MirrorEndpoints: config.mirrorEndpoints,
|
||||
SkipMirrorEndpoints: config.skipMirrorEndpoints,
|
||||
PreferredSource: config.preferredSource,
|
||||
InternalPaths: config.internalPaths,
|
||||
Shortcuts: map[string]int{
|
||||
"/.well-known/appspecific/com.chrome.devtools.json": http.StatusNotFound,
|
||||
"/sw.js": http.StatusNotFound,
|
||||
},
|
||||
}
|
||||
|
||||
_ = ds.SaveSettings(settings)
|
||||
|
||||
return settings
|
||||
@@ -429,64 +626,6 @@ func initCertificateManager(dataDir string) *certmanager.CertificateManager {
|
||||
return cm
|
||||
}
|
||||
|
||||
func setupSoundcorkProxy(soundcorkURL string, redact, logBody bool, recorder *proxy.Recorder, server *handlers.Server) *httputil.ReverseProxy {
|
||||
target, err := url.Parse(soundcorkURL)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse Soundcork URL: %v", err)
|
||||
}
|
||||
|
||||
scProxy := httputil.NewSingleHostReverseProxy(target)
|
||||
scProxy.ModifyResponse = func(res *http.Response) error {
|
||||
if etags, ok := res.Header["Etag"]; ok {
|
||||
delete(res.Header, "Etag")
|
||||
res.Header["ETag"] = etags
|
||||
}
|
||||
|
||||
currentLp := proxy.NewLoggingProxy(target.String(), redact)
|
||||
currentLp.LogBody = logBody
|
||||
currentLp.RecordEnabled = server.GetRecordEnabled()
|
||||
currentLp.SetRecorder(recorder)
|
||||
currentLp.LogResponse(res)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
originalScDirector := scProxy.Director
|
||||
scProxy.Director = func(req *http.Request) {
|
||||
originalScDirector(req)
|
||||
|
||||
// Fix X-Forwarded-For bloat by deduplicating
|
||||
if xff := req.Header.Get("X-Forwarded-For"); xff != "" {
|
||||
parts := strings.Split(xff, ",")
|
||||
seen := make(map[string]bool)
|
||||
unique := make([]string, 0, len(parts))
|
||||
|
||||
for _, p := range parts {
|
||||
p = strings.TrimSpace(p)
|
||||
if p != "" && !seen[p] {
|
||||
seen[p] = true
|
||||
unique = append(unique, p)
|
||||
}
|
||||
}
|
||||
|
||||
// Limit the number of entries to prevent header overflow
|
||||
if len(unique) > 10 {
|
||||
unique = unique[len(unique)-10:]
|
||||
}
|
||||
|
||||
req.Header.Set("X-Forwarded-For", strings.Join(unique, ", "))
|
||||
}
|
||||
|
||||
currentLp := proxy.NewLoggingProxy(target.String(), redact)
|
||||
currentLp.LogBody = logBody
|
||||
currentLp.RecordEnabled = server.GetRecordEnabled()
|
||||
currentLp.SetRecorder(recorder)
|
||||
currentLp.LogRequest(req)
|
||||
}
|
||||
|
||||
return scProxy
|
||||
}
|
||||
|
||||
func startDeviceDiscovery(server *handlers.Server) {
|
||||
go func() {
|
||||
for {
|
||||
@@ -500,11 +639,13 @@ func startDeviceDiscovery(server *handlers.Server) {
|
||||
}()
|
||||
}
|
||||
|
||||
func setupRouter(server *handlers.Server, scProxy *httputil.ReverseProxy, enableSoundcorkProxy bool) *chi.Mux {
|
||||
func setupRouter(server *handlers.Server) *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.Logger)
|
||||
r.Use(server.SnapshotMiddleware)
|
||||
r.Use(server.OriginMiddleware)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(server.ShortcutMiddleware)
|
||||
r.Use(server.MirrorMiddleware)
|
||||
r.Use(server.RecordMiddleware)
|
||||
|
||||
r.Get("/", server.HandleRoot)
|
||||
@@ -526,38 +667,112 @@ func setupRouter(server *handlers.Server, scProxy *httputil.ReverseProxy, enable
|
||||
r.Post("/orion/v1/playback/station/{data}", server.HandleOrionPlayback)
|
||||
})
|
||||
|
||||
// Legacy or direct domain calls without /bmx prefix
|
||||
r.Get("/registry/v1/services", server.HandleBMXRegistry)
|
||||
r.Get("/tunein/v1/playback/station/{stationID}", server.HandleTuneInPlayback)
|
||||
r.Get("/tunein/v1/playback/episodes/{podcastID}", server.HandleTuneInPodcastInfo)
|
||||
r.Get("/tunein/v1/playback/episode/{podcastID}", server.HandleTuneInPlaybackPodcast)
|
||||
r.Post("/orion/v1/playback/station/{data}", server.HandleOrionPlayback)
|
||||
r.Get("/custom/v1/playback/{encodedURL}", server.HandleCustomPlayback)
|
||||
|
||||
streamingRoutes := func(r chi.Router) {
|
||||
r.Get("/sourceproviders", server.HandleMargeSourceProviders)
|
||||
r.Get("/account/{account}/device/{device}/recent", server.HandleMargeRecents)
|
||||
r.Post("/account/{account}/device/{device}/recent", server.HandleMargeAddRecent)
|
||||
r.Get("/account/{account}/device/{device}/presets", server.HandleMargePresets)
|
||||
r.Post("/account/{account}/device/{device}/presets/{presetNumber}", server.HandleMargeUpdatePreset)
|
||||
r.Post("/support/power_on", server.HandleMargePowerOn)
|
||||
r.Get("/account/{account}/provider_settings", server.HandleMargeProviderSettings)
|
||||
r.Get("/device/{device}/streaming_token", server.HandleMargeStreamingToken)
|
||||
r.Post("/support/customersupport", server.HandleMargeCustomerSupport)
|
||||
r.Get("/device_setting/account/{account}/device/{device}/device_settings", server.HandleMargeGetDeviceSettings)
|
||||
r.Get("/account/{account}/device/{device}/group", server.HandleMargeDeviceGroup)
|
||||
r.Get("/account/{account}/device/{device}/group/", server.HandleMargeDeviceGroup)
|
||||
r.Get("/account/{account}/device/{device}/group/server", server.HandleMargeDeviceGroupServer)
|
||||
r.Get("/account/{account}/device/{device}/group/member", server.HandleMargeDeviceGroupMember)
|
||||
r.Post("/device_setting/account/{account}/device/{device}/device_settings", server.HandleMargeUpdateDeviceSettings)
|
||||
r.Get("/account/{account}/emailaddress", server.HandleMargeGetEmailAddress)
|
||||
r.Get("/account/{account}/full", server.HandleMargeAccountFull)
|
||||
r.Get("/software/update/account/{account}", server.HandleMargeSoftwareUpdate)
|
||||
|
||||
r.Route("/stats", func(r chi.Router) {
|
||||
r.Post("/usage", server.HandleUsageStats)
|
||||
r.Post("/error", server.HandleErrorStats)
|
||||
})
|
||||
}
|
||||
|
||||
accountsRoutes := func(r chi.Router) {
|
||||
r.Get("/{account}/full", server.HandleMargeAccountFull)
|
||||
r.Get("/{account}/devices/{device}/presets", server.HandleMargePresets)
|
||||
r.Post("/{account}/devices/{device}/presets/{presetNumber}", server.HandleMargeUpdatePreset)
|
||||
r.Get("/{account}/devices/{device}/recents", server.HandleMargeRecents)
|
||||
r.Post("/{account}/devices/{device}/recents", server.HandleMargeAddRecent)
|
||||
r.Post("/{account}/devices", server.HandleMargeAddDevice)
|
||||
r.Delete("/{account}/devices/{device}", server.HandleMargeRemoveDevice)
|
||||
r.Get("/{account}/devices/{device}/group", server.HandleMargeDeviceGroup)
|
||||
r.Get("/{account}/devices/{device}/group/", server.HandleMargeDeviceGroup)
|
||||
r.Get("/{account}/devices/{device}/group/server", server.HandleMargeDeviceGroupServer)
|
||||
r.Get("/{account}/devices/{device}/group/member", server.HandleMargeDeviceGroupMember)
|
||||
}
|
||||
|
||||
r.Route("/marge", func(r chi.Router) {
|
||||
r.Get("/streaming/sourceproviders", server.HandleMargeSourceProviders)
|
||||
r.Get("/accounts/{account}/full", server.HandleMargeAccountFull)
|
||||
r.Post("/streaming/support/power_on", server.HandleMargePowerOn)
|
||||
r.Route("/streaming", streamingRoutes)
|
||||
r.Route("/accounts", accountsRoutes)
|
||||
|
||||
r.Get("/updates/soundtouch", server.HandleMargeSoftwareUpdate)
|
||||
r.Get("/accounts/{account}/devices/{device}/presets", server.HandleMargePresets)
|
||||
r.Post("/accounts/{account}/devices/{device}/presets/{presetNumber}", server.HandleMargeUpdatePreset)
|
||||
r.Post("/accounts/{account}/devices/{device}/recents", server.HandleMargeAddRecent)
|
||||
r.Post("/accounts/{account}/devices", server.HandleMargeAddDevice)
|
||||
r.Delete("/accounts/{account}/devices/{device}", server.HandleMargeRemoveDevice)
|
||||
r.Get("/streaming/account/{account}/provider_settings", server.HandleMargeProviderSettings)
|
||||
r.Get("/streaming/device/{device}/streaming_token", server.HandleMargeStreamingToken)
|
||||
r.Post("/streaming/support/customersupport", server.HandleMargeCustomerSupport)
|
||||
r.Get("/streaming/device_setting/account/{account}/device/{device}/device_settings", server.HandleMargeGetDeviceSettings)
|
||||
r.Post("/streaming/device_setting/account/{account}/device/{device}/device_settings", server.HandleMargeUpdateDeviceSettings)
|
||||
r.Get("/streaming/account/{account}/emailaddress", server.HandleMargeGetEmailAddress)
|
||||
})
|
||||
|
||||
// Legacy or direct domain calls without /marge prefix
|
||||
r.Route("/streaming", streamingRoutes)
|
||||
r.Route("/accounts", accountsRoutes)
|
||||
r.Get("/updates/soundtouch", server.HandleMargeSoftwareUpdate)
|
||||
|
||||
r.Route("/customer", func(r chi.Router) {
|
||||
r.Get("/account/{account}", server.HandleMargeAccountProfile)
|
||||
r.Post("/account/{account}", server.HandleMargeUpdateAccountProfile)
|
||||
r.Post("/account/{account}/password", server.HandleMargeChangePassword)
|
||||
})
|
||||
|
||||
r.Route("/oauth", func(r chi.Router) {
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token/cs3", server.HandleBoseToken)
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token", server.HandleBoseLegacyToken)
|
||||
r.HandleFunc("/*", server.HandleBoseProxy)
|
||||
})
|
||||
|
||||
r.Route("/v1", func(r chi.Router) {
|
||||
r.Post("/stapp/{deviceId}", server.HandleAppEvents)
|
||||
r.Post("/scmudc/{deviceId}", server.HandleAppEvents)
|
||||
})
|
||||
|
||||
r.Route("/streaming/stats", func(r chi.Router) {
|
||||
r.Post("/usage", server.HandleUsageStats)
|
||||
r.Post("/error", server.HandleErrorStats)
|
||||
r.Route("/mgmt", func(r chi.Router) {
|
||||
// Browser OAuth callback — no auth required (Spotify redirects the
|
||||
// user's browser here directly). The authorization code is single-use,
|
||||
// short-lived, and useless without the client_secret.
|
||||
r.Get("/spotify/callback", server.HandleMgmtSpotifyCallback)
|
||||
|
||||
// All other management endpoints require Basic Auth.
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(server.BasicAuthMgmt())
|
||||
|
||||
r.Route("/accounts", func(r chi.Router) {
|
||||
r.Get("/", server.HandleMgmtListAccounts)
|
||||
r.Get("/{accountId}", server.HandleMgmtAccountDetails)
|
||||
r.Post("/{accountId}/language", server.HandleMgmtUpdateAccountLanguage)
|
||||
r.Post("/{accountId}/provider-settings", server.HandleMgmtUpdateAccountProviderSetting)
|
||||
r.Get("/{accountId}/speakers", server.HandleMgmtListSpeakers)
|
||||
})
|
||||
|
||||
r.Route("/spotify", func(r chi.Router) {
|
||||
r.Post("/init", server.HandleMgmtSpotifyInit)
|
||||
r.Post("/confirm", server.HandleMgmtSpotifyConfirm)
|
||||
r.Get("/accounts", server.HandleMgmtSpotifyAccounts)
|
||||
r.Get("/token", server.HandleMgmtSpotifyToken)
|
||||
r.Post("/entity", server.HandleMgmtSpotifyEntity)
|
||||
r.Post("/prime", server.HandleMgmtPrimeDevice)
|
||||
})
|
||||
|
||||
r.Get("/devices/{deviceId}/events", server.HandleMgmtDeviceEvents)
|
||||
})
|
||||
})
|
||||
|
||||
r.Get("/proxy/*", server.HandleProxyRequest)
|
||||
@@ -570,18 +785,19 @@ func setupRouter(server *handlers.Server, scProxy *httputil.ReverseProxy, enable
|
||||
r.Get("/discovery-status", server.HandleGetDiscoveryStatus)
|
||||
r.Get("/settings", server.HandleGetSettings)
|
||||
r.Post("/settings", server.HandleUpdateSettings)
|
||||
r.Get("/info/{deviceIP}", server.HandleGetDeviceInfo)
|
||||
r.Get("/summary/{deviceIP}", server.HandleGetMigrationSummary)
|
||||
r.Post("/migrate/{deviceIP}", server.HandleMigrateDevice)
|
||||
r.Post("/revert/{deviceIP}", server.HandleRevertMigration)
|
||||
r.Post("/reboot/{deviceIP}", server.HandleRebootDevice)
|
||||
r.Post("/trust-ca/{deviceIP}", server.HandleTrustCACert)
|
||||
r.Post("/ensure-remote-services/{deviceIP}", server.HandleEnsureRemoteServices)
|
||||
r.Post("/remove-remote-services/{deviceIP}", server.HandleRemoveRemoteServices)
|
||||
r.Post("/backup/{deviceIP}", server.HandleBackupConfig)
|
||||
r.Post("/sync/{deviceIP}", server.HandleInitialSync)
|
||||
r.Post("/test-connection/{deviceIP}", server.HandleTestConnection)
|
||||
r.Post("/test-hosts/{deviceIP}", server.HandleTestHostsRedirection)
|
||||
r.Get("/info/{deviceId}", server.HandleGetDeviceInfo)
|
||||
r.Get("/summary/{deviceId}", server.HandleGetMigrationSummary)
|
||||
r.Post("/migrate/{deviceId}", server.HandleMigrateDevice)
|
||||
r.Post("/revert/{deviceId}", server.HandleRevertMigration)
|
||||
r.Post("/reboot/{deviceId}", server.HandleRebootDevice)
|
||||
r.Post("/trust-ca/{deviceId}", server.HandleTrustCACert)
|
||||
r.Post("/ensure-remote-services/{deviceId}", server.HandleEnsureRemoteServices)
|
||||
r.Post("/remove-remote-services/{deviceId}", server.HandleRemoveRemoteServices)
|
||||
r.Post("/backup/{deviceId}", server.HandleBackupConfig)
|
||||
r.Post("/sync/{deviceId}", server.HandleInitialSync)
|
||||
r.Post("/test-connection/{deviceId}", server.HandleTestConnection)
|
||||
r.Post("/test-hosts/{deviceId}", server.HandleTestHostsRedirection)
|
||||
r.Post("/test-dns/{deviceId}", server.HandleTestDNSRedirection)
|
||||
r.Get("/ca.crt", server.HandleGetCACert)
|
||||
r.Get("/proxy-settings", server.HandleGetProxySettings)
|
||||
r.Post("/proxy-settings", server.HandleUpdateProxySettings)
|
||||
@@ -589,32 +805,151 @@ func setupRouter(server *handlers.Server, scProxy *httputil.ReverseProxy, enable
|
||||
r.Get("/interaction-stats", server.HandleGetInteractionStats)
|
||||
r.Get("/interactions", server.HandleListInteractions)
|
||||
r.Get("/interaction-content", server.HandleGetInteractionContent)
|
||||
r.Get("/parity-mismatches", server.HandleListParityMismatches)
|
||||
r.Delete("/parity-mismatches", server.HandleClearParityMismatches)
|
||||
r.Get("/interactions/sessions/{session}/download", server.HandleDownloadSession)
|
||||
r.Delete("/interactions/sessions/{session}", server.HandleDeleteSession)
|
||||
r.Delete("/interactions/sessions", server.HandleCleanupSessions)
|
||||
|
||||
r.Get("/dns-discoveries", server.HandleGetDNSDiscoveries)
|
||||
r.Get("/dns-discoveries/download", server.HandleDownloadDNSDiscoveries)
|
||||
r.Delete("/dns-discoveries", server.HandleClearDNSDiscoveries)
|
||||
|
||||
r.Get("/devices/{deviceId}/events", server.HandleGetDeviceEvents)
|
||||
})
|
||||
|
||||
if enableSoundcorkProxy {
|
||||
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
|
||||
scProxy.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
r.NotFound(server.HandleNotFound)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func startHTTPSServer(httpsAddr string, r http.Handler, tlsConfig *tls.Config, httpsServerURL string) {
|
||||
// Add custom error logging and connection state tracking
|
||||
tlsConfig.GetCertificate = func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
// log.Printf("[TLS] Certificate request for ServerName: %s", clientHello.ServerName)
|
||||
|
||||
// Use the default certificate selection logic
|
||||
for _, cert := range tlsConfig.Certificates {
|
||||
if cert.Leaf != nil {
|
||||
for _, name := range cert.Leaf.DNSNames {
|
||||
if matchesDomain(name, clientHello.ServerName) {
|
||||
// log.Printf("[TLS] ✅ Serving certificate for %s (matched %s)", clientHello.ServerName, name)
|
||||
return &cert, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If no specific match, return the first certificate and log it
|
||||
if len(tlsConfig.Certificates) > 0 {
|
||||
// log.Printf("[TLS] ⚠️ No exact match for %s, using default certificate", clientHello.ServerName)
|
||||
return &tlsConfig.Certificates[0], nil
|
||||
}
|
||||
|
||||
log.Printf("[TLS] ❌ No certificate available for %s", clientHello.ServerName)
|
||||
|
||||
return nil, fmt.Errorf("no certificate available for %s", clientHello.ServerName)
|
||||
}
|
||||
|
||||
httpsServer := &http.Server{
|
||||
Addr: httpsAddr,
|
||||
Handler: r,
|
||||
TLSConfig: tlsConfig,
|
||||
ErrorLog: log.Default(), // Ensure error logging is enabled
|
||||
}
|
||||
|
||||
log.Printf("Go service starting HTTPS on %s", httpsServerURL)
|
||||
|
||||
go func() {
|
||||
if err := httpsServer.ListenAndServeTLS("", ""); err != nil && err != http.ErrServerClosed {
|
||||
listener, err := net.Listen("tcp", httpsAddr)
|
||||
if err != nil {
|
||||
log.Printf("[TLS] Failed to create listener: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
tlsListener := tls.NewListener(listener, tlsConfig)
|
||||
|
||||
// Wrap listener to log connection attempts
|
||||
wrappedListener := &loggingTLSListener{
|
||||
Listener: tlsListener,
|
||||
}
|
||||
|
||||
if err := httpsServer.Serve(wrappedListener); err != nil && err != http.ErrServerClosed {
|
||||
log.Printf("HTTPS server error: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// matchesDomain checks if a certificate domain (which may be a wildcard) matches a server name
|
||||
func matchesDomain(certDomain, serverName string) bool {
|
||||
if certDomain == serverName {
|
||||
return true
|
||||
}
|
||||
|
||||
// Handle wildcard certificates (only at the beginning of a label)
|
||||
if strings.HasPrefix(certDomain, "*.") {
|
||||
certBase := certDomain[2:] // Remove "*."
|
||||
|
||||
// For *.api.bose.io to match events.api.bose.io but not test.content.api.bose.io
|
||||
// We need to ensure only one label is replaced by the wildcard
|
||||
if strings.HasSuffix(serverName, "."+certBase) {
|
||||
// Count dots to ensure we're not matching too many levels
|
||||
serverPrefix := strings.TrimSuffix(serverName, "."+certBase)
|
||||
if !strings.Contains(serverPrefix, ".") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Also match the base domain (e.g., api.bose.io matches *.api.bose.io)
|
||||
if serverName == certBase {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// loggingTLSListener wraps a TLS listener to log connection attempts and handshake failures
|
||||
type loggingTLSListener struct {
|
||||
net.Listener
|
||||
}
|
||||
|
||||
func (l *loggingTLSListener) Accept() (net.Conn, error) {
|
||||
conn, err := l.Listener.Accept()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Wrap the connection to log TLS handshake results
|
||||
return &loggingTLSConn{
|
||||
Conn: conn,
|
||||
addr: conn.RemoteAddr(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// loggingTLSConn wraps a TLS connection to log handshake failures
|
||||
type loggingTLSConn struct {
|
||||
net.Conn
|
||||
addr net.Addr
|
||||
handshakeLogged bool
|
||||
}
|
||||
|
||||
func (c *loggingTLSConn) Read(b []byte) (n int, err error) {
|
||||
n, err = c.Conn.Read(b)
|
||||
|
||||
// Log TLS handshake failures on first read attempt
|
||||
if !c.handshakeLogged {
|
||||
c.handshakeLogged = true
|
||||
|
||||
if err != nil {
|
||||
// Check if this looks like a TLS handshake failure
|
||||
if strings.Contains(err.Error(), "tls:") ||
|
||||
strings.Contains(err.Error(), "handshake") ||
|
||||
strings.Contains(err.Error(), "certificate") {
|
||||
log.Printf("[TLS] ❌ Handshake failed from %s: %v", c.addr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
|
||||
)
|
||||
|
||||
func TestApplyPersistedSettings(t *testing.T) {
|
||||
tmpDir, err := os.MkdirTemp("", "main-test")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create temp dir: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
ds := datastore.NewDataStore(tmpDir)
|
||||
|
||||
t.Run("overrides true with false", func(t *testing.T) {
|
||||
config := &serviceConfig{
|
||||
redact: true,
|
||||
logBody: true,
|
||||
record: true,
|
||||
}
|
||||
|
||||
// Simulate the bug by using the old bitwise OR logic in the test,
|
||||
// which should fail if we expect false.
|
||||
// config.redact = config.redact || false -> stays true
|
||||
|
||||
settings := datastore.Settings{
|
||||
RedactLogs: false,
|
||||
LogBodies: false,
|
||||
RecordInteractions: false,
|
||||
}
|
||||
err := ds.SaveSettings(settings)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to save settings: %v", err)
|
||||
}
|
||||
|
||||
applyPersistedSettings(ds, config)
|
||||
|
||||
if config.redact != false {
|
||||
t.Errorf("Expected redact to be false, got true")
|
||||
}
|
||||
if config.logBody != false {
|
||||
t.Errorf("Expected logBody to be false, got true")
|
||||
}
|
||||
if config.record != false {
|
||||
t.Errorf("Expected record to be false, got true")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("retains false when settings are false", func(t *testing.T) {
|
||||
settings := datastore.Settings{
|
||||
RedactLogs: false,
|
||||
}
|
||||
err := ds.SaveSettings(settings)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to save settings: %v", err)
|
||||
}
|
||||
|
||||
config := &serviceConfig{
|
||||
redact: false,
|
||||
}
|
||||
|
||||
applyPersistedSettings(ds, config)
|
||||
|
||||
if config.redact != false {
|
||||
t.Errorf("Expected redact to be false, got true")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("overrides false with true", func(t *testing.T) {
|
||||
settings := datastore.Settings{
|
||||
RedactLogs: true,
|
||||
}
|
||||
err := ds.SaveSettings(settings)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to save settings: %v", err)
|
||||
}
|
||||
|
||||
config := &serviceConfig{
|
||||
redact: false,
|
||||
}
|
||||
|
||||
applyPersistedSettings(ds, config)
|
||||
|
||||
if config.redact != true {
|
||||
t.Errorf("Expected redact to be true, got false")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
accounts/
|
||||
certs/
|
||||
default/
|
||||
dns/
|
||||
interactions/
|
||||
parity_mismatches/
|
||||
patterns.json
|
||||
settings.json
|
||||
|
||||
@@ -23,6 +23,14 @@ All content selection features from the [SoundTouch WebServices API Wiki](https:
|
||||
- Automatic defaults for missing parameters
|
||||
- **Use Cases**: Internet radio streams, proxy-based radio services
|
||||
|
||||
#### `SelectLocalInternetRadio(location, ...)` via `soundtouch-service`
|
||||
- **Purpose**: Select custom radio stream via local `soundtouch-service` proxy
|
||||
- **Features**:
|
||||
- Flexible stream URL encoding (Base64 or URL-escaped)
|
||||
- Dynamic generation of Bose-compatible playback JSON
|
||||
- Seamless integration with existing `LOCAL_INTERNET_RADIO` source
|
||||
- **Use Case**: Playing any internet radio URL without external proxy dependencies
|
||||
|
||||
#### `SelectLocalMusic(location, sourceAccount, itemName, containerArt string) error`
|
||||
- **Purpose**: Select LOCAL_MUSIC content from SoundTouch App Media Server
|
||||
- **Requirements**: SoundTouch App Media Server running on a computer
|
||||
@@ -47,6 +55,15 @@ soundtouch-cli --host <device> source internet-radio \
|
||||
--artwork "https://example.com/art.png"
|
||||
```
|
||||
|
||||
#### `soundtouch-cli source custom-radio`
|
||||
```bash
|
||||
soundtouch-cli --host <device> source custom-radio \
|
||||
--url "https://stream.example.com/radio" \
|
||||
--name "My Station" \
|
||||
--artwork "https://example.com/art.png" \
|
||||
--service-url "http://localhost:8080"
|
||||
```
|
||||
|
||||
#### `soundtouch-cli source local-music`
|
||||
```bash
|
||||
soundtouch-cli --host <device> source local-music \
|
||||
@@ -101,7 +118,7 @@ Comprehensive test suites implemented for all new functionality:
|
||||
### Example Code
|
||||
Complete working example demonstrating:
|
||||
- LOCAL_INTERNET_RADIO with streamUrl proxy format
|
||||
- LOCAL_INTERNET_RADIO with direct streams
|
||||
- LOCAL_INTERNET_RADIO with direct streams
|
||||
- LOCAL_MUSIC content selection
|
||||
- STORED_MUSIC content selection
|
||||
- Generic ContentItem usage
|
||||
@@ -152,7 +169,7 @@ All convenience methods create properly structured `ContentItem` objects:
|
||||
Based on the wiki structure, these related features are also supported:
|
||||
|
||||
1. **LOCAL_MUSIC**: ✅ Fully implemented
|
||||
2. **STORED_MUSIC**: ✅ Fully implemented
|
||||
2. **STORED_MUSIC**: ✅ Fully implemented
|
||||
3. **SPOTIFY**: ✅ Previously implemented
|
||||
4. **TUNEIN**: ✅ Previously implemented
|
||||
5. **BLUETOOTH**: ✅ Previously implemented
|
||||
@@ -169,7 +186,7 @@ err := client.SelectLocalInternetRadio(location, "", "My Station", "")
|
||||
// Direct ContentItem
|
||||
contentItem := &models.ContentItem{
|
||||
Source: "LOCAL_INTERNET_RADIO",
|
||||
Type: "stationurl",
|
||||
Type: "stationurl",
|
||||
Location: location,
|
||||
ItemName: "My Station",
|
||||
IsPresetable: true,
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
### Overview of Recent Improvements and Next Steps
|
||||
|
||||
This document summarizes the improvements made to the **Marge service** to improve parity with the upstream Bose SoundTouch service, along with open issues and proposed next steps.
|
||||
|
||||
#### ✅ Completed Improvements (Marge Service)
|
||||
* **Mapped Preset `buttonNumber`**: Correctly mapped the internal `ServicePreset.ID` or `ButtonNumber` to the `buttonNumber` XML attribute in the `/full` response and ensured it is persisted in the local datastore.
|
||||
* **High-Fidelity Device Metadata**: Improved the datastore to correctly extract, persist, and report detailed device `<components>` (e.g., `LIGHTSWITCH`, `SMSC`) and their firmware versions from upstream responses.
|
||||
* **Standardized Preferred Language**: Updated the default `preferredLanguage` to `de` in the `/full` response and added synchronization to persist it from upstream responses.
|
||||
* **Persisted Provider Settings**: Added support for persisting and echoing back `providerSettings` (e.g., `STREAMING_QUALITY`, `ELIGIBLE_FOR_TRIAL`) from the `/full` response.
|
||||
* **Populated `contentItemType`**: The `contentItemType` (e.g., `tracklisturl`) is now correctly synchronized from upstream, persisted in the local datastore, and returned in the `/full` response for both presets and recents.
|
||||
* **Standardized Credential Types**: Adjusted the logic for Spotify to use the correct `token_version_3` type when a token is present in the `/full` response, improving parity with the upstream service. The service now respects existing `credential_type` values from `Sources.xml` (e.g., `token_version_3` for Spotify) while providing sensible defaults for new or incomplete sources.
|
||||
* **Structured Sources (Sources.xml)**: Refactored `Sources.xml` to use an attribute-based structure (`sourceid`, `source`, `status`, `sourceAccount`, etc.) matching the real device's output. Removed redundant nested tags like `<sourcename>`, `<username>`, and `<name>`.
|
||||
* **Nested Recents (Recents.xml)**: Implemented a nested `<contentItem>` structure within `<recent>` entries in `Recents.xml`, maintaining exact parity with the device's persistence format while supporting legacy flat formats for backward compatibility.
|
||||
* **Inconsistent `serialNumber` Casing**: Fixed the casing mismatch in the `/full` response where the upstream uses camelCase `<serialNumber>` in the top-level `<device>` and lowercase `<serialnumber>` in the nested `<attachedProduct>`. Local responses now correctly mirror this inconsistency.
|
||||
* **Attribute-level Parity**:
|
||||
* Ensured `sourceAccount=""` is preserved in XML even when empty, matching device behavior for sources like TUNEIN.
|
||||
* Fixed casing for attributes like `deviceID` and `utcTime` in `Recents.xml`.
|
||||
* Correctly mapped and persisted preset and recent `id` attributes during "Initial Data Sync".
|
||||
* **Device Name Consistency**: Fixed an issue where the device `<name>` was empty in some local `/full` responses by ensuring it is correctly populated from the datastore and synchronized from upstream.
|
||||
* **Improved XML Parity**: Empty `<name>` tags in the `/full` response are now self-closing (`<name/>`), matching upstream behavior.
|
||||
* **Timestamp-based ID Generation**: Implemented a 9-digit ID schema (`YYMMDD` + 3-digit counter) for `recent` items, ensuring IDs are large, unique, and stay within the 32-bit integer range.
|
||||
* **Automatic Source Learning**: The service now extracts and persists full metadata (credentials, provider IDs, and custom names) from incoming `POST /recent` requests. This improves parity for subsequent `GET /recents` calls.
|
||||
* **Source Provider Mapping**: Synchronized local source provider IDs and timestamps with upstream data. The `RADIO_BROWSER` provider is included in the public `/streaming/sourceproviders` list to maintain internal functionality while acknowledging it as a parity gap.
|
||||
* **Credential Preservation**: Improved `AddRecent` to correctly extract and echo back base64 tokens/credentials provided in the incoming request, improving source learning.
|
||||
* **XML Formatting Parity**:
|
||||
* Added `standalone="yes"` to the XML declaration for all Marge responses, including `recent`, `presets`, `full account`, `software update`, and `sourceproviders`.
|
||||
* Enforced self-closing `<sourceSettings/>` tags for parity.
|
||||
* Standardized date formatting to UTC with milliseconds (`.000+00:00`).
|
||||
* Fixed casing for `/streaming/sourceproviders`: Root element is `<sourceProviders>`, but child elements are `<sourceprovider>` (all lowercase), matching upstream behavior.
|
||||
* Implemented structured XML marshaling with consistent 2-space indentation for recents and source providers.
|
||||
* **Improved TuneIn Parity**: Fixed TuneIn source mapping to use ID `25` and ensuring `sourcename` is empty in responses, matching upstream behavior for station playback.
|
||||
* **High-Fidelity Full Account Sync**: Refactored the `/streaming/account/{accountId}/full` response to match the upstream structure. This includes:
|
||||
* **Mapped Preset `buttonNumber`**: Correctly mapped the internal `ServicePreset.ID` to the `buttonNumber` XML attribute in the `/full` response.
|
||||
* **Structured XML Marshaling**: Replaced manual string concatenation with structured Go models and `xml.Marshal` for the entire response.
|
||||
* **Specific Response Models**: Introduced `FullResponseSource`, `FullResponsePreset`, and `FullResponseRecent` to accurately reflect the upstream structure where `<source>` is a child element, rather than a set of attributes.
|
||||
* **Correct Nesting**: Ensured that `<presets>` and `<recents>` correctly nest their associated `<source>` details, resolving previous data omissions.
|
||||
* **Device Identity**: Added `<serialNumber>` and `<updatedOn>` to both the top-level `<device>` and its `<attachedProduct>`, ensuring consistent device identification.
|
||||
* **Field-Level Parity**: Mapped missing fields like `<contentItemType>` and `<productlabel>` to match upstream expectations.
|
||||
* **Improved Source Matching**: Enhanced internal logic to correctly link presets and recents to their configured sources based on multiple identifiers (ID, Key, or Type).
|
||||
* **Verified Parity Mismatch Fixes**: Comprehensive reproduction tests (`TestParityMismatchReproduction_V2` and `TestParityMismatchReproduction_V3`) now confirm parity for identified mismatches in `POST /recent` and `GET /recents`, including credentials and source-specific metadata.
|
||||
* **Unified Response Logic**: Refactored the code so that both `POST /recent` and `GET /recents` use the same formatting functions, guaranteeing consistency.
|
||||
* **Robust Parity Detection**: Updated the local parity checker to be whitespace-insensitive for XML bodies, significantly reducing noise from minor indentation or newline differences.
|
||||
* **Maintainable XML Generation**: Reduced cyclomatic complexity and code duplication in `marge.go` by extracting focused helper functions for mapping internal data to response-specific XML models.
|
||||
|
||||
---
|
||||
|
||||
#### 🛠️ Open Issues and Next Steps
|
||||
|
||||
Based on the latest `parity_mismatches` and the high-fidelity `/full` account response comparison (diff14), here are the recommended areas for further work:
|
||||
|
||||
#### 1. BMX / TuneIn Playback Parity (Medium)
|
||||
Current mismatches in `/bmx/tunein/v1/playback/station/...` show differences in reporting URLs and missing links:
|
||||
* **Mismatched Parameters**: Local reporting URLs use `listen_id=1234567890`, while upstream uses a different session-based ID.
|
||||
* **Missing Links**: Some upstream responses include additional `_links` or metadata that are currently omitted in local responses.
|
||||
* **Action**: Improve the `HandleTuneInPlayback` logic to better mirror the upstream response structure and parameter generation.
|
||||
|
||||
#### 2. `/full` Account Response Data Gaps (Medium)
|
||||
While structural parity for the `/full` response is high, several value-level gaps remain as shown in `diff14`:
|
||||
* **Timestamp Formats**: Upstream uses ISO-8601 with milliseconds (e.g., `2024-06-23T07:40:36.000+00:00`), whereas some local fields still use Unix epoch integers (e.g., `1234567890`).
|
||||
* **Provider Settings**: The `providerSettings` block in the local response currently lacks crucial values like `keyName`, `providerId`, and `boseId` (appearing as empty tags).
|
||||
* **Component Metadata**: Local component types are sometimes empty (`type=""`) compared to upstream values like `LIGHTSWITCH` or `SMSC`.
|
||||
* **Source/Preset Identifiers**: Local IDs (e.g., `100004`) differ from upstream IDs (e.g., `1234567`), though this may be expected due to different account/device environments.
|
||||
* **Action**: Update the mapping logic in `marge.go` and `setup.go` to ensure all fields in the `/full` response are correctly populated with high-fidelity values and standard ISO-8601 timestamps.
|
||||
|
||||
#### 3. OAuth / Spotify Token Noise (Low/Medium)
|
||||
The `/oauth/device/.../token` endpoint frequently reports mismatches because tokens are naturally different between local and upstream.
|
||||
* **The Issue**: This creates "noise" in your parity reports that isn't actually a bug.
|
||||
* **Action**: Update the parity detection logic (or the handler) to selectively ignore the `access_token` field while still verifying that the rest of the JSON structure (expires_in, scope, token_type) matches.
|
||||
|
||||
#### 4. Large IDs for Other Models (Medium)
|
||||
While we fixed IDs for `recents`, other models like `presets` or `sources` might still use small auto-incrementing integers.
|
||||
* **Action**: Evaluate if other endpoints should also transition to the timestamp-based ID schema to further reduce diff noise.
|
||||
|
||||
#### 5. Improved Data Persistence (Continuous)
|
||||
Continue the "learning" approach for other services. For example, if we see a new `sourceproviderid` in a Spotify or TuneIn request, we should ensure it is stored and reused.
|
||||
|
||||
#### 6. Local Reboot & Device State Management (Continuous)
|
||||
Analysis of device reboot logs revealed several data requirements:
|
||||
* **Power-On Details Tracking**: Implemented extraction and persistence of detailed device information (serial numbers, firmware version, product details, and MAC addresses) from the `POST /streaming/support/power_on` request. This data is now stored in the local datastore, improving our ability to respond accurately to subsequent management requests.
|
||||
* **Source Provider Mapping**: Synchronized local source provider IDs and timestamps with upstream data. The `RADIO_BROWSER` provider is included in the public `/streaming/sourceproviders` list to maintain internal functionality while acknowledging it as a parity gap.
|
||||
|
||||
#### 7. Account Full Response (/full) Structural & Value Parity (Completed)
|
||||
Structural and value gaps in the `/full` account response have been addressed:
|
||||
|
||||
**Key Fixes:**
|
||||
* **Structural**:
|
||||
* **Nested Source Association**: Improved the matching logic in `mapRecentsToFullResponse` to correctly link recents to their specific `ConfiguredSource` (e.g., by matching `sourceid` attribute).
|
||||
* **XML Tag Formatting**: Standardized self-closing tags and element formatting to match upstream's multi-line or empty-element formatting in various contexts.
|
||||
@@ -0,0 +1,41 @@
|
||||
# Parity Analysis: Bose-SoundTouch (Go) vs. SoundCork (Python)
|
||||
|
||||
This document provides a comparative analysis of the current Go implementation and the `deborahgu/soundcork` project, identifying functional gaps and potential improvements.
|
||||
|
||||
## 1. Core Architecture and Language
|
||||
- **Bose-SoundTouch (Go)**: Uses `chi` for routing and `encoding/xml` for data. High performance, strong typing, and precise MIME type handling (`application/vnd.bose.streaming-v1.2+xml`).
|
||||
- **SoundCork (Python)**: Uses `FastAPI` and `xml.etree.ElementTree`. Prioritizes flexibility and rapid prototyping of streaming service mocks.
|
||||
|
||||
## 2. Functional Comparison
|
||||
|
||||
| Feature | Bose-SoundTouch (Go) | SoundCork (Python) |
|
||||
|:---------------------|:-------------------------------------------------|:----------------------------------------------------------------------------------------|
|
||||
| **Group Management** | Placeholder handlers (return `<group/>` or 404). | Active group management (`groups.py`), supporting `/addGroup` and stereo pairing logic. |
|
||||
| **BMX Services** | Supports TuneIn, Orion, and custom streams. | More modular `bmx_services.json` registry with broader mock support. |
|
||||
| **Persistence** | Mixed JSON/XML datastore. | Pure XML-based persistence per device/account. |
|
||||
| **Admin UI** | CLI-based (`soundtouch-cli`) or API-driven. | Draft Web UI for device discovery and account management (`admin.py`). |
|
||||
| **Discovery** | Integrated setup tools and SSDP/MDNS awareness. | Leverages `bosesoundtouchapi` Python library for active discovery. |
|
||||
|
||||
## 3. Key Strengths of SoundCork
|
||||
- **Group Pairing Logic**: Includes logic to manage master/slave relationships for SoundTouch 10 stereo pairs.
|
||||
- **Service Extensibility**: JSON-based registry for BMX services makes it easier to mock multiple providers (SiriusXM, Spotify) without code changes.
|
||||
- **Mock Coverage**: Better coverage of "dummy" endpoints that respond with plausible XML (e.g., `customerSupport`).
|
||||
|
||||
## 4. Suggested Implementation Steps for Bose-SoundTouch
|
||||
|
||||
### A. Implement Full Group Support (High Priority)
|
||||
- Add logic to `pkg/service/marge` to handle `/addGroup` and `/updateGroup`.
|
||||
- Persist group memberships in the datastore to allow speakers to function as stereo pairs or multi-room zones.
|
||||
|
||||
### B. Modularize BMX Registry (Medium Priority)
|
||||
- Extract the hardcoded service list in `HandleBMXRegistry` into an external `bmx-services.json` file.
|
||||
- Allow users to customize which mocked services are advertised to the speaker.
|
||||
|
||||
### C. Enhanced Source Management (Medium Priority)
|
||||
- Refine source learning logic to ensure all `sourceAccount` and `sourceName` metadata is correctly captured during synchronization, using patterns from `soundcork`'s `learnSource`.
|
||||
|
||||
### D. Basic Admin Web UI (Low Priority)
|
||||
- Develop a minimal internal status page to list active accounts and connected devices, improving usability over raw API calls.
|
||||
|
||||
## 5. Summary
|
||||
While our Go implementation is structurally more consistent with recent reference recordings (e.g., `buttonNumber`, detailed `components`), SoundCork provides better coverage of multi-device coordination (Groups) and service emulation (BMX) that we should adopt for a more complete offline experience.
|
||||
+77
-20
@@ -1,32 +1,89 @@
|
||||
# Bose SoundTouch Toolkit Documentation
|
||||
|
||||
Welcome to the documentation for the Bose SoundTouch Toolkit. This toolkit helps you keep your Bose SoundTouch speakers functional even after the Bose Cloud shutdown in May 2026.
|
||||
Welcome to the documentation for the Bose SoundTouch Toolkit. This comprehensive toolkit helps you keep your Bose SoundTouch speakers functional even after the Bose Cloud shutdown in May 2026, with enhanced local management and monitoring capabilities.
|
||||
|
||||
## 📖 Quick Links
|
||||
## 🚀 Start Here
|
||||
|
||||
- [Cloud Shutdown Survival Guide](guides/SURVIVAL-GUIDE.md)
|
||||
- [Migration & Safety Guide](guides/MIGRATION-SAFETY.md)
|
||||
- [CLI Reference](guides/CLI-REFERENCE.md)
|
||||
- [Getting Started](guides/GETTING-STARTED.md)
|
||||
- [SoundTouch Service Guide](guides/SOUNDTOUCH-SERVICE.md)
|
||||
### For New Users
|
||||
- **[Complete Migration Guide](guides/MIGRATION-GUIDE.md)** - Step-by-step guide from Bose Cloud to local control
|
||||
- **[Getting Started](guides/GETTING-STARTED.md)** - Quick introduction to the toolkit
|
||||
|
||||
### For Existing Users
|
||||
- **[Cloud Shutdown Survival Guide](guides/SURVIVAL-GUIDE.md)** - Prepare for the May 2026 shutdown
|
||||
- **[SoundTouch Service Guide](guides/SOUNDTOUCH-SERVICE.md)** - Advanced service configuration
|
||||
|
||||
## 📋 Essential Documentation
|
||||
|
||||
The documentation is organized into three main categories:
|
||||
|
||||
### 1. **User Guides** - For everyday users migrating and managing devices
|
||||
### 2. **Technical Reference** - For developers and advanced configuration
|
||||
### 3. **Concept Documentation** - For contributors and system architects
|
||||
|
||||
## 🗂 Documentation Structure
|
||||
|
||||
### User Guides
|
||||
- [Initial Device Setup](guides/DEVICE-INITIAL-SETUP.md)
|
||||
- [HTTPS Setup](guides/HTTPS-SETUP.md)
|
||||
- [Deployment Guide](guides/DEPLOYMENT.md)
|
||||
- [Raspberry Pi Setup](guides/RASPBERRY-PI.md)
|
||||
- [Troubleshooting](guides/TROUBLESHOOTING.md)
|
||||
## 🗂 User Guides
|
||||
|
||||
### Technical Reference
|
||||
- [API Endpoints](reference/API-ENDPOINTS.md)
|
||||
- [WebSocket Events](reference/WEBSOCKET-EVENTS.md)
|
||||
- [Zone Management](reference/ZONE-MANAGEMENT.md)
|
||||
- [Preset Management](reference/PRESET-MANAGEMENT.md)
|
||||
### Migration & Setup
|
||||
- **[Complete Migration Guide](guides/MIGRATION-GUIDE.md)** - 📖 **Main guide** for migrating from Bose Cloud
|
||||
- [Cloud Shutdown Survival Guide](guides/SURVIVAL-GUIDE.md) - Prepare for service shutdown
|
||||
- [Migration & Safety Guide](guides/MIGRATION-SAFETY.md) - Advanced migration strategies
|
||||
- [Initial Device Setup](guides/DEVICE-INITIAL-SETUP.md) - First-time device configuration
|
||||
- [Raspberry Pi Setup](guides/RASPBERRY-PI.md) - Installing on Raspberry Pi
|
||||
|
||||
### Daily Management
|
||||
- [SoundTouch Service Guide](guides/SOUNDTOUCH-SERVICE.md) - Service operation and maintenance
|
||||
- [Troubleshooting](guides/TROUBLESHOOTING.md) - Common issues and solutions
|
||||
- [HTTPS Setup](guides/HTTPS-SETUP.md) - Secure connections
|
||||
- [Deployment Guide](guides/DEPLOYMENT.md) - Production deployments
|
||||
|
||||
### Advanced Features
|
||||
- [MAC Address Mapping](guides/MAC-ADDRESS-MAPPING.md) - Device identification
|
||||
- [CLI Reference](guides/CLI-REFERENCE.md) - Command-line tools
|
||||
- [IoT Implementation Guide](guides/IOT-IMPLEMENTATION-GUIDE.md) - IoT integrations
|
||||
- [MQTT Integration Design](guides/MQTT-INTEGRATION-DESIGN.md) - MQTT setup
|
||||
|
||||
## 📚 Technical Reference
|
||||
|
||||
### API Documentation
|
||||
- [API Endpoints](reference/API-ENDPOINTS.md) - REST API reference
|
||||
- [WebSocket Events](reference/WEBSOCKET-EVENTS.md) - Real-time events
|
||||
- [Zone Management](reference/ZONE-MANAGEMENT.md) - Multi-room control
|
||||
- [Preset Management](reference/PRESET-MANAGEMENT.md) - Preset operations
|
||||
|
||||
### Analysis & Research
|
||||
- [Upstream URLs](analysis/UPSTREAM-URLS.md)
|
||||
- [Device Redirect Methods](analysis/DEVICE-REDIRECT-METHODS.md)
|
||||
- [Upstream URLs](analysis/UPSTREAM-URLS.md) - Bose service endpoints
|
||||
- [Device Redirect Methods](analysis/DEVICE-REDIRECT-METHODS.md) - Migration techniques
|
||||
- [IoT Configuration Analysis](analysis/IOT-CONFIGURATION-ANALYSIS.md) - Device configurations
|
||||
- [IoT Config Summary](analysis/IOT-CONFIG-SUMMARY.md) - Configuration summaries
|
||||
|
||||
### Device Lifecycle & Network Independence
|
||||
- **[Device Lifecycle and /power_on Enhancement](device-lifecycle-and-power-on-enhancement.md)** - Complete analysis of device registration and network independence improvements
|
||||
- [/power_on Implementation Guide](power-on-implementation-guide.md) - Technical implementation details for enhanced device management
|
||||
|
||||
## 🏗 Concept Documentation
|
||||
|
||||
### Enhanced Service Architecture
|
||||
- **[Concept Overview](concepts/README.md)** - High-level architecture vision
|
||||
- [Upstream Service Simulation](concepts/upstream-service-simulation.md) - Complete concept design
|
||||
- [Implementation Plan](concepts/implementation-plan.md) - Development roadmap
|
||||
- [Technical Specification](concepts/technical-specification.md) - Detailed specifications
|
||||
|
||||
### Development Planning
|
||||
- [Implementation Roadmap](concepts/implementation-roadmap.md) - Project phases and milestones
|
||||
|
||||
## 💡 Quick Reference
|
||||
|
||||
### Common Tasks
|
||||
- **Migrate first device**: Follow [Migration Guide Step 5](guides/MIGRATION-GUIDE.md#step-5-migrate-individual-devices)
|
||||
- **Check device health**: Dashboard → Devices → [Device Name] → Health Status
|
||||
- **Backup configuration**: Dashboard → Settings → Backup → Create Backup
|
||||
- **Add new device**: Dashboard → Devices → Discover Devices → Register
|
||||
|
||||
### Getting Help
|
||||
- **Issues & Bugs**: [GitHub Issues](https://github.com/gesellix/Bose-SoundTouch/issues)
|
||||
- **Questions & Discussion**: [GitHub Discussions](https://github.com/gesellix/Bose-SoundTouch/discussions)
|
||||
- **Documentation**: Check troubleshooting guides first
|
||||
- **Community**: Share experiences and help others
|
||||
|
||||
For a complete list of all documents, see the [Summary](SUMMARY.md).
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
# Request Recording Concept
|
||||
|
||||
## Problem Statement
|
||||
|
||||
The current request recording system has fundamental issues when dealing with request cloning, body consumption, and multiple response scenarios. Specifically:
|
||||
|
||||
1. **Body Consumption**: HTTP request bodies can only be read once, leading to missing bodies in recordings
|
||||
2. **Request Cloning**: A single original request may be cloned multiple times for different purposes (local handling, mirroring, recording)
|
||||
3. **Multiple Responses**: The same logical request may generate different responses (local vs upstream mirror)
|
||||
4. **Data Integrity**: No guarantee that recorded requests are identical across different execution paths
|
||||
|
||||
## Current Issues (Examples)
|
||||
|
||||
### Issue 1: Missing Request Bodies in Mirror Recordings
|
||||
|
||||
**Local Recording** (complete):
|
||||
```http
|
||||
### POST /v1/scmudc/A81B6A536A98
|
||||
POST /v1/scmudc/A81B6A536A98
|
||||
Host: events.api.bosecm.com
|
||||
Content-Type: text/json; charset=utf-8
|
||||
Content-Length: 587
|
||||
Authorization: Bearer jGwEmFWr...
|
||||
|
||||
{"envelope":{"monoTime":234906,"payloadProtocolVersion":"3.1","payloadType":"scmudc","protocolVersion":"1.0","time":"2026-02-25T23:03:14.976349+00:00","uniqueId":"A81B6A536A98"},"payload":{"deviceInfo":{"boseID":"3230304","deviceID":"A81B6A536A98","deviceType":"SoundTouch 10","serialNumber":"I6332527703739342000020","softwareVersion":"27.0.6.46330.5043500 epdbuild.trunk.hepdswbld04.2022-08-04T11:20:29","systemSerialNumber":"069231P63364828AE"},"events":[{"data":{"play-state":"PAUSE_STATE"},"monoTime":234904,"time":"2026-02-25T23:03:14.973466+00:00","type":"play-state-changed"}]}}
|
||||
|
||||
{% raw %}
|
||||
> {%
|
||||
// Response: 200 OK
|
||||
%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
**Mirror Recording** (missing body):
|
||||
```http
|
||||
### POST /v1/scmudc/A81B6A536A98
|
||||
POST /v1/scmudc/A81B6A536A98
|
||||
Host: events.api.bosecm.com
|
||||
Content-Type: text/json; charset=utf-8
|
||||
Content-Length: 587
|
||||
Authorization: Bearer jGwEmFWr...
|
||||
|
||||
|
||||
|
||||
{% raw %}
|
||||
> {%
|
||||
// Response: 200 OK
|
||||
// Headers:
|
||||
// X-Proxy-Origin: upstream-mirror
|
||||
%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Issue 2: Request Flow Complexity
|
||||
|
||||
Current middleware execution order:
|
||||
```
|
||||
1. MirrorMiddleware - Buffers body, creates clones
|
||||
2. RecordMiddleware - Also buffers body
|
||||
3. Application Handler - Processes request
|
||||
4. Mirror Execution - Async/sync mirror to upstream
|
||||
5. Recording - Multiple recording points
|
||||
```
|
||||
|
||||
Problems:
|
||||
- Multiple body reads across middleware chain
|
||||
- Inconsistent request state between clones
|
||||
- Race conditions in async scenarios
|
||||
- No guarantee of request equivalence
|
||||
|
||||
## Proposed Solution: Context-Bound Request Snapshots
|
||||
|
||||
### Core Concept
|
||||
|
||||
Create **immutable request snapshots** early in the request lifecycle and propagate them through the **Request Context**. This ensures all downstream consumers (Mirroring, Recording, Parity Check) use identical data without re-reading the request body.
|
||||
|
||||
### Architecture (Context-Only)
|
||||
|
||||
```
|
||||
┌─────────────────┐
|
||||
│ Original Request│
|
||||
└─────────┬───────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────┐ ┌──────────────────┐
|
||||
│ Snapshot Creator│───▶│ Request Context │
|
||||
│ (Middleware) │ │ (Pointer-based) │
|
||||
└─────────┬───────┘ └──────────────────┘
|
||||
│ │
|
||||
▼ │ (Safe for async)
|
||||
┌─────────────────┐ │
|
||||
│ Middleware │◀─────────────┘
|
||||
│ Chain │
|
||||
└─────────┬───────┘
|
||||
│
|
||||
┌───▼────┐ ┌─────────┐ ┌──────────────┐
|
||||
│ Local │ │ Mirror │ │ Recording │
|
||||
│Handler │ │Execution│ │ System │
|
||||
└────────┘ └─────────┘ └──────────────┘
|
||||
```
|
||||
|
||||
### Request Snapshot Structure
|
||||
|
||||
```go
|
||||
type RequestSnapshot struct {
|
||||
Method string
|
||||
URL *url.URL
|
||||
Headers http.Header
|
||||
Body []byte
|
||||
Host string
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
// Typed key for context safety
|
||||
type contextKey struct{ name string }
|
||||
var SnapshotKey = &contextKey{"request_snapshot"}
|
||||
```
|
||||
|
||||
### Implementation Strategy
|
||||
|
||||
#### Phase 1: Snapshot Middleware
|
||||
|
||||
```go
|
||||
func (s *Server) SnapshotMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// 1. Capture body once with size limit (e.g. 2MB)
|
||||
body, _ := io.ReadAll(io.LimitReader(r.Body, 2*1024*1024))
|
||||
r.Body.Close()
|
||||
|
||||
// 2. Create snapshot
|
||||
snapshot := &RequestSnapshot{
|
||||
Method: r.Method,
|
||||
URL: cloneURL(r.URL),
|
||||
Headers: r.Header.Clone(),
|
||||
Body: body,
|
||||
Host: r.Host,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
// 3. Inject pointer into context
|
||||
ctx := context.WithValue(r.Context(), SnapshotKey, snapshot)
|
||||
|
||||
// 4. Restore r.Body for downstream compatibility
|
||||
r = r.WithContext(ctx)
|
||||
r.Body = io.NopCloser(bytes.NewReader(snapshot.Body))
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
#### Phase 2: Downstream Consumption
|
||||
|
||||
Consumers (Mirror/Record) retrieve the snapshot directly from context:
|
||||
|
||||
```go
|
||||
snapshot, ok := r.Context().Value(SnapshotKey).(*RequestSnapshot)
|
||||
if ok {
|
||||
// Use snapshot.Body directly instead of io.ReadAll(r.Body)
|
||||
}
|
||||
```
|
||||
|
||||
## Hardware Considerations (Raspberry Pi Zero 2W)
|
||||
|
||||
To protect MicroSD health and optimize for limited memory:
|
||||
|
||||
1. **No Intermediate Disk Storage**: Snapshots exist only in memory; they are never written to disk until the final `.http` recording is generated.
|
||||
2. **Memory Management**: Use `sync.Pool` for temporary buffers to reduce GC churn on the single-core/low-memory SoC.
|
||||
3. **Automatic Cleanup**: Snapshots are naturally garbage collected once the Request Context and all child goroutines (detached mirrors/recordings) finish.
|
||||
4. **Body Capping**: Strict limits on snapshot size prevent OOM (Out-of-Memory) conditions.
|
||||
|
||||
#### Phase 2: Response Capture System
|
||||
|
||||
```go
|
||||
type ResponseRecorder struct {
|
||||
http.ResponseWriter
|
||||
snapshot *ResponseSnapshot
|
||||
snapshotID string
|
||||
source string
|
||||
startTime time.Time
|
||||
}
|
||||
|
||||
func (r *ResponseRecorder) WriteHeader(statusCode int) {
|
||||
r.snapshot.StatusCode = statusCode
|
||||
r.snapshot.Headers = r.Header().Clone()
|
||||
r.ResponseWriter.WriteHeader(statusCode)
|
||||
}
|
||||
|
||||
func (r *ResponseRecorder) Write(data []byte) (int, error) {
|
||||
r.snapshot.Body = append(r.snapshot.Body, data...)
|
||||
return r.ResponseWriter.Write(data)
|
||||
}
|
||||
|
||||
func (r *ResponseRecorder) finalize() {
|
||||
r.snapshot.Duration = time.Since(r.startTime)
|
||||
r.snapshot.Timestamp = time.Now()
|
||||
}
|
||||
```
|
||||
|
||||
#### Phase 3: Recording System Integration
|
||||
|
||||
```go
|
||||
type RecordingManager struct {
|
||||
storage SnapshotStorage
|
||||
recorder *Recorder
|
||||
patterns []string
|
||||
}
|
||||
|
||||
func (rm *RecordingManager) RecordInteraction(snapshotID string, response *ResponseSnapshot) {
|
||||
// Retrieve immutable request snapshot
|
||||
request, exists := rm.storage.Get(snapshotID)
|
||||
if !exists {
|
||||
log.Printf("Request snapshot not found: %s", snapshotID)
|
||||
return
|
||||
}
|
||||
|
||||
// Record with guaranteed data integrity
|
||||
rm.recorder.RecordInteraction(request, response)
|
||||
}
|
||||
|
||||
func (r *Recorder) RecordInteraction(req *RequestSnapshot, res *ResponseSnapshot) error {
|
||||
// Generate .http file with complete data
|
||||
var buf bytes.Buffer
|
||||
|
||||
// Write request
|
||||
fmt.Fprintf(&buf, "### %s %s\n", req.Method, req.URL.String())
|
||||
fmt.Fprintf(&buf, "%s %s\n", req.Method, req.URL.String())
|
||||
fmt.Fprintf(&buf, "Host: %s\n", req.Host)
|
||||
|
||||
for k, vv := range req.Headers {
|
||||
for _, v := range vv {
|
||||
fmt.Fprintf(&buf, "%s: %s\n", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
buf.WriteString("\n")
|
||||
buf.Write(req.Body)
|
||||
buf.WriteString("\n\n")
|
||||
|
||||
// Write response
|
||||
{% raw %}
|
||||
buf.WriteString("> {% \n")
|
||||
{% endraw %}
|
||||
fmt.Fprintf(&buf, " // Response: %d %s\n", res.StatusCode, http.StatusText(res.StatusCode))
|
||||
buf.WriteString(" // Headers:\n")
|
||||
|
||||
for k, vv := range res.Headers {
|
||||
for _, v := range vv {
|
||||
fmt.Fprintf(&buf, " // %s: %s\n", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
{% raw %}
|
||||
buf.WriteString("%}\n\n")
|
||||
{% endraw %}
|
||||
|
||||
if len(res.Body) > 0 {
|
||||
buf.WriteString("/*\n")
|
||||
buf.Write(res.Body)
|
||||
buf.WriteString("\n*/\n")
|
||||
} else {
|
||||
buf.WriteString("// [Binary response body: 0 bytes]\n")
|
||||
}
|
||||
|
||||
// Write to file
|
||||
return r.writeToFile(buf.Bytes(), req, res)
|
||||
}
|
||||
```
|
||||
|
||||
## Migration Strategy
|
||||
|
||||
### Phase 1: Introduce Snapshot System
|
||||
- Add SnapshotMiddleware as first middleware
|
||||
- Maintain existing recording system for compatibility
|
||||
- Gradual migration of recording points
|
||||
|
||||
### Phase 2: Update Mirror System
|
||||
- Modify MirrorMiddleware to use snapshots
|
||||
- Ensure mirror requests use snapshot data
|
||||
- Test parity between old and new systems
|
||||
|
||||
### Phase 3: Consolidate Recording
|
||||
- Replace existing recording middleware
|
||||
- Unified recording system using context-bound snapshots
|
||||
- Remove duplicate body reading code
|
||||
|
||||
### Phase 4: Cleanup
|
||||
- Remove legacy recording code
|
||||
- Optimize memory usage with sync.Pool
|
||||
- Performance validation on target hardware (Pi Zero)
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Zero Extra Disk IO**: Protecs MicroSD by avoiding snapshot disk persistence
|
||||
2. **Memory Efficiency**: Natural lifecycle tied to Request Context
|
||||
3. **Data Integrity**: Request data is captured once and remains immutable
|
||||
4. **Consistency**: All consumers use identical request data
|
||||
5. **Traceability**: Clear lineage from original request to all recordings
|
||||
6. **Performance**: Reduces duplicate body reads and re-cloning
|
||||
|
||||
## Implementation Considerations
|
||||
|
||||
### Memory Management
|
||||
- Use `sync.Pool` for byte buffers
|
||||
- Strict size limits on captured bodies
|
||||
- Rely on GC for snapshot cleanup
|
||||
|
||||
### Performance Impact
|
||||
- Single body read vs multiple reads (net positive)
|
||||
- Memory overhead for snapshot storage (manageable)
|
||||
- Context propagation overhead (minimal)
|
||||
|
||||
### Backward Compatibility
|
||||
- Maintain existing .http file format
|
||||
- Preserve existing API contracts
|
||||
- Gradual migration path
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
### Unit Tests
|
||||
- Snapshot creation and immutability
|
||||
- Response recording accuracy
|
||||
- Memory cleanup verification
|
||||
|
||||
### Integration Tests
|
||||
- End-to-end request/response recording
|
||||
- Mirror functionality with snapshots
|
||||
- Parity validation between old/new systems
|
||||
|
||||
### Performance Tests
|
||||
- Memory usage comparison
|
||||
- Throughput impact analysis
|
||||
- Large request body handling
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
1. **Compression**: Compress stored snapshots for memory efficiency
|
||||
2. **Streaming**: Support for streaming request/response bodies
|
||||
3. **Filtering**: Selective snapshot creation based on patterns
|
||||
4. **Analytics**: Request/response analysis and metrics
|
||||
5. **Export**: Snapshot export for debugging and analysis
|
||||
|
||||
## Conclusion
|
||||
|
||||
This snapshot-based approach provides a robust foundation for reliable request recording while solving the current issues with body consumption and data inconsistency. The phased implementation ensures minimal disruption while delivering immediate benefits.
|
||||
@@ -0,0 +1,192 @@
|
||||
# SCMUDC Enrichment Implementation Summary
|
||||
|
||||
## Overview
|
||||
|
||||
This document summarizes the implementation of SCMUDC (Sound Control Management Usage Data Collection) event enrichment in the AfterTouch toolkit. The enhancement provides human-readable analysis of device telemetry data to improve usability and debugging capabilities.
|
||||
|
||||
## Problem Solved
|
||||
|
||||
Previously, SCMUDC telemetry events were stored as raw JSON with Base64-encoded XML content, making them difficult to analyze. Users had to manually decode content to understand what device interactions were being recorded.
|
||||
|
||||
## Solution Implemented
|
||||
|
||||
### 1. Backend Enrichment (`pkg/service/proxy/`)
|
||||
|
||||
#### New File: `scmudc.go`
|
||||
- **SCMUDCRequest/SCMUDCEvent Structs**: Parse incoming telemetry JSON
|
||||
- **EnrichedSCMUDCEvent Struct**: Human-readable analysis with decoded content
|
||||
- **DecodedContent Struct**: Parsed XML metadata (track names, artwork URLs, etc.)
|
||||
- **enrichSCMUDCRequest()**: Main enrichment function that:
|
||||
- Identifies event origin (app, hardware, or internal system)
|
||||
- Decodes Base64 XML content for device events
|
||||
- Creates human-readable summaries
|
||||
- **Helper Functions**: Button formatting, content summarization, origin descriptions
|
||||
|
||||
#### Enhanced File: `recorder.go`
|
||||
- **Updated save() method**: Extracts SCMUDC data during recording
|
||||
- **New writeRequestWithEnrichment()**: Adds enriched comments to .http files
|
||||
- **New writeResponseWithEnrichment()**: Includes SCMUDC analysis in response section
|
||||
- **Updated Interaction struct**: Added `SCMUDCData` field for API responses
|
||||
- **New extractSCMUDCFromFile()**: Parses enrichment data from existing .http files
|
||||
- **Enhanced parseInteractionFile()**: Populates SCMUDC data when listing interactions
|
||||
|
||||
### 2. Frontend Enhancement
|
||||
|
||||
#### Updated HTML (`pkg/service/handlers/web/index.html`)
|
||||
- **New Column**: Added "Event Details" to interactions table
|
||||
- **Table Structure**: Updated to accommodate SCMUDC enrichment display
|
||||
|
||||
#### Enhanced JavaScript (`pkg/service/handlers/web/js/script.js`)
|
||||
- **Updated fetchInteractions()**: Displays enriched SCMUDC data with icons
|
||||
- **New Helper Functions**:
|
||||
- `getOriginIcon()`: Maps origins to emojis (📱 App, 🎛️ Hardware, 🔄 Internal)
|
||||
- `getActionIcon()`: Maps actions to emojis (▶️ Play, ⏸️ Pause, etc.)
|
||||
- `showSCMUDCDetails()`: Detailed popover for complex events
|
||||
- `displaySCMUDCPopover()`: Modal dialog with full decoded content
|
||||
- **Truncation Logic**: Long content shows "(...)" with click-to-expand
|
||||
|
||||
## Event Origin Clarification
|
||||
|
||||
Based on analysis of recorded data:
|
||||
|
||||
| Origin | Source | Description | Example Events |
|
||||
|--------|--------|-------------|----------------|
|
||||
| `gabbo` | **SoundTouch App** | Mobile/desktop app UI interactions | Play, Pause, Power via app |
|
||||
| `console` | **Device Hardware** | Physical buttons on speaker | Preset buttons, hardware power |
|
||||
| `device` | **Internal System** | Automatic device responses | Content playback, system actions |
|
||||
|
||||
## Enhanced .http File Format
|
||||
|
||||
### Before (Raw)
|
||||
```http
|
||||
### POST /v1/scmudc/A81B6A536A98
|
||||
POST /v1/scmudc/A81B6A536A98
|
||||
Host: events.api.bosecm.com
|
||||
...
|
||||
|
||||
{"envelope":...,"payload":{"events":[{"data":{"contentItem":"PD94bWw..."}}]}}
|
||||
```
|
||||
|
||||
### After (Enriched)
|
||||
```http
|
||||
### POST /v1/scmudc/A81B6A536A98
|
||||
// Origin: Internal System (device)
|
||||
// Action: play-item
|
||||
// Command: Billie Eilish - bad guy (instrumental version)
|
||||
// Summary: Device: Spotify: Billie Eilish - bad guy (instrumental version)
|
||||
//
|
||||
// Decoded Content:
|
||||
// - Source: SPOTIFY
|
||||
// - Item: Billie Eilish - bad guy (instrumental version)
|
||||
// - Account: gesellix
|
||||
// - Artwork: https://i.scdn.co/image/ab67616d0000b273...
|
||||
//
|
||||
// Full XML Content:
|
||||
// <?xml version="1.0" encoding="UTF-8"?>
|
||||
// <ContentItem source="SPOTIFY" type="tracklisturl" ...>
|
||||
// <itemName>Billie Eilish - bad guy (instrumental version)</itemName>
|
||||
// <containerArt>https://i.scdn.co/image/ab67616d0000b273...</containerArt>
|
||||
// </ContentItem>
|
||||
POST /v1/scmudc/A81B6A536A98
|
||||
...
|
||||
|
||||
{% raw %}
|
||||
> {%
|
||||
// Response: 200 OK
|
||||
// SCMUDC Event Analysis:
|
||||
// - Origin: Internal System (device)
|
||||
// - Action: play-item
|
||||
// - Summary: Device: Spotify: Billie Eilish - bad guy (instrumental version)
|
||||
// - Content: Billie Eilish - bad guy (instrumental version)
|
||||
// - Account: gesellix
|
||||
%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Web UI Enhancement
|
||||
|
||||
### Interactions Table
|
||||
- **New Column**: "Event Details" shows enriched summaries
|
||||
- **Visual Icons**: Origin and action type indicators
|
||||
- **Truncation**: Long content abbreviated with "(...)" expansion
|
||||
- **Backward Compatibility**: Works with existing recordings
|
||||
|
||||
### Event Details Display
|
||||
```
|
||||
📱 ▶️ Play Button (Simple app action)
|
||||
🔄 🎵 Billie Eilish - bad guy... (...) (Complex device event with details)
|
||||
🎛️ ⭐ Preset 5 (Hardware preset button)
|
||||
```
|
||||
|
||||
### Detailed Popover
|
||||
For complex events, clicking "(...)" shows:
|
||||
- **Origin Description**: "SoundTouch App" instead of "gabbo"
|
||||
- **Full Content Information**: Track names, artwork URLs, account details
|
||||
- **Complete XML**: Formatted and readable content item data
|
||||
|
||||
## Implementation Benefits
|
||||
|
||||
### For Users
|
||||
- **Immediate Recognition**: See what actions were performed without decoding
|
||||
- **Better Debugging**: Quick identification of app vs. hardware vs. system events
|
||||
- **Rich Context**: Track names, accounts, and content sources visible at a glance
|
||||
|
||||
### For Developers
|
||||
- **Structured Data**: Consistent parsing and enrichment pipeline
|
||||
- **Extensible**: Easy to add new event types and origins
|
||||
- **Backward Compatible**: Existing recordings work without re-processing
|
||||
|
||||
### For Analysis
|
||||
- **Pattern Recognition**: Quickly identify user behavior patterns
|
||||
- **Service Integration**: See which music services are being used
|
||||
- **Device Usage**: Understand app vs. hardware control preferences
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
pkg/service/proxy/
|
||||
├── scmudc.go # New: SCMUDC enrichment logic
|
||||
├── recorder.go # Enhanced: Enrichment integration
|
||||
│
|
||||
pkg/service/handlers/web/
|
||||
├── index.html # Enhanced: New table column
|
||||
├── js/script.js # Enhanced: SCMUDC display logic
|
||||
│
|
||||
docs/
|
||||
├── scmudc-events-analysis.md # New: Analysis documentation
|
||||
├── SCMUDC-ENRICHMENT-IMPLEMENTATION.md # This file
|
||||
```
|
||||
|
||||
## Technical Decisions
|
||||
|
||||
### Base64 Decoding Strategy
|
||||
- **When**: During recording (not on-demand) for performance
|
||||
- **Fallback**: Parse from .http files if enrichment missing
|
||||
- **Storage**: Both enriched comments and structured data in API responses
|
||||
|
||||
### Icon Selection
|
||||
- **Emoji Usage**: Universal, colorful, intuitive recognition
|
||||
- **Semantic Mapping**: Icons match function (📱 for app, 🎛️ for hardware)
|
||||
- **Fallback**: Generic icons (❓, 🔘) for unknown types
|
||||
|
||||
### Backward Compatibility
|
||||
- **Graceful Degradation**: Missing enrichment data doesn't break UI
|
||||
- **File Parsing**: Extract enrichment from existing .http files
|
||||
- **API Enhancement**: New fields optional in Interaction struct
|
||||
|
||||
## Future Enhancement Opportunities
|
||||
|
||||
1. **Event Correlation**: Link device events to user actions
|
||||
2. **Statistics Dashboard**: Origin-based usage analytics
|
||||
3. **Content Recommendations**: Track listening patterns
|
||||
4. **Device Health**: Monitor interaction frequency and patterns
|
||||
5. **Export Features**: CSV/JSON export of enriched event data
|
||||
|
||||
## Testing Considerations
|
||||
|
||||
- **Edge Cases**: Malformed Base64, missing XML elements
|
||||
- **Performance**: Large numbers of SCMUDC events
|
||||
- **Browser Compatibility**: Emoji display across different browsers
|
||||
- **Data Validation**: Ensure enrichment doesn't introduce errors
|
||||
|
||||
This implementation significantly improves the usability of SCMUDC telemetry data while maintaining full backward compatibility and raw data access for advanced users.
|
||||
@@ -9,10 +9,14 @@
|
||||
* [Getting Started](guides/GETTING-STARTED.md)
|
||||
* [SoundTouch Service](guides/SOUNDTOUCH-SERVICE.md)
|
||||
* [Initial Device Setup](guides/DEVICE-INITIAL-SETUP.md)
|
||||
* [MAC Address Mapping](guides/MAC-ADDRESS-MAPPING.md)
|
||||
* [HTTPS Setup](guides/HTTPS-SETUP.md)
|
||||
* [Deployment](guides/DEPLOYMENT.md)
|
||||
* [Raspberry Pi Guide](guides/RASPBERRY-PI.md)
|
||||
* [Troubleshooting](guides/TROUBLESHOOTING.md)
|
||||
* [IoT Implementation Guide](guides/IOT-IMPLEMENTATION-GUIDE.md)
|
||||
* [Migration Guide](guides/MIGRATION-GUIDE.md)
|
||||
* [MQTT Integration Design](guides/MQTT-INTEGRATION-DESIGN.md)
|
||||
* [Useful Links](#useful-links)
|
||||
|
||||
### Useful Links
|
||||
@@ -33,10 +37,16 @@
|
||||
* [Preset Management](reference/PRESET-MANAGEMENT.md)
|
||||
* [Source Selection](reference/SOURCE-SELECTION.md)
|
||||
* [Volume Controls](reference/VOLUME-CONTROLS.md)
|
||||
* [RadioBrowser](reference/radio-browser.md)
|
||||
* [Bass Controls](reference/BASS-CONTROLS.md)
|
||||
* [Key Controls](reference/KEY-CONTROLS.md)
|
||||
* [Feature Mapping](reference/FEATURE-MAPPING.md)
|
||||
|
||||
## Concepts
|
||||
* [Request Recording](REQUEST_RECORDING_CONCEPT.md)
|
||||
* [Spotify Priming Strategy](concepts/spotify-priming-strategy.md)
|
||||
* [Spotify OAuth](concepts/spotify-oauth.md)
|
||||
|
||||
## Analysis & Research
|
||||
* [API Coverage Analysis](analysis/API-COVERAGE.md)
|
||||
* [Supported URLs](analysis/SUPPORTED-URLS.md)
|
||||
@@ -44,6 +54,12 @@
|
||||
* [Anonymization Summary](analysis/ANONYMIZATION-SUMMARY.md)
|
||||
* [Device Redirect Methods](analysis/DEVICE-REDIRECT-METHODS.md)
|
||||
* [Wiki API Comparison](analysis/WIKI-COMPARISON.md)
|
||||
* [IoT Config Summary](analysis/IOT-CONFIG-SUMMARY.md)
|
||||
* [IoT Configuration Analysis](analysis/IOT-CONFIGURATION-ANALYSIS.md)
|
||||
|
||||
## Parity Analysis
|
||||
* [Parity Improvements](PARITY-IMPROVEMENTS.md)
|
||||
* [Parity SoundCork](PARITY-SOUNDCORK.md)
|
||||
|
||||
## Appendix (Other Documents)
|
||||
* [API Navigation Reference](API-NAVIGATION-REFERENCE.md)
|
||||
@@ -63,3 +79,10 @@
|
||||
* [Undocumented Community Features](UNDOCUMENTED-COMMUNITY-FEATURES.md)
|
||||
* [Unimplemented Endpoints](UNIMPLEMENTED-ENDPOINTS.md)
|
||||
* [Preset Store](preset-store.md)
|
||||
* [SCMUDC Enrichment Implementation](SCMUDC-ENRICHMENT-IMPLEMENTATION.md)
|
||||
* [Device Lifecycle and Power On Enhancement](device-lifecycle-and-power-on-enhancement.md)
|
||||
* [Device Lifecycle Summary](device-lifecycle-summary.md)
|
||||
* [Power On Implementation Guide](power-on-implementation-guide.md)
|
||||
* [SCMUDC Events Analysis](scmudc-events-analysis.md)
|
||||
* [Parity Improvements](PARITY-IMPROVEMENTS.md)
|
||||
* [Parity SoundCork](PARITY-SOUNDCORK.md)
|
||||
|
||||
@@ -370,7 +370,7 @@ soundtouch-cli speaker beep
|
||||
**Go Client Usage:**
|
||||
```go
|
||||
// Text-to-Speech
|
||||
client.PlayTTS("Hello World", "your-app-key", 70)
|
||||
client.PlayTTS("Hello World", "your-app-key", "EN", 70)
|
||||
|
||||
// URL content
|
||||
client.PlayURL("https://example.com/audio.mp3", "your-app-key", "Service", "Message", "Reason", 60)
|
||||
@@ -1044,4 +1044,4 @@ The SoundTouch Plus Wiki provides comprehensive documentation for **64 additiona
|
||||
|
||||
This documentation provides the complete foundation for implementing all endpoints from the SoundTouch Plus Wiki, enabling this Go library to become the definitive SoundTouch integration solution for everything from basic home automation to professional audio installations.
|
||||
|
||||
*All examples and XML structures are verified against real SoundTouch hardware and extensively tested by the SoundTouch Plus community.*
|
||||
*All examples and XML structures are verified against real SoundTouch hardware and extensively tested by the SoundTouch Plus community.*
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
# IoT Configuration Quick Reference
|
||||
|
||||
## Key Files and Locations
|
||||
|
||||
| File/Location | Purpose | Notes |
|
||||
|-----------------------------------------|------------------------|-----------------------------------------|
|
||||
| `/mnt/nv/BoseApp-Persistence/1/IoT.xml` | Main IoT configuration | Contains clientID, endpoint, deployment |
|
||||
| `/opt/Bose/IoT` | IoT service binary | ARM executable, AWS IoT SDK |
|
||||
| `/mnt/nv/IoTCerts/` | Certificate storage | Device certs and private keys |
|
||||
| `/etc/init.d/SoundTouch` | System startup script | Creates directory structure |
|
||||
| `/opt/Bose/etc/Shepherd-noncore.xml` | Service configuration | Defines IoT daemon startup |
|
||||
|
||||
## Configuration Parameters
|
||||
|
||||
### IoT.xml Structure
|
||||
```xml
|
||||
<Configuration
|
||||
clientID="[UUID]"
|
||||
iotEndpoint="[AWS_IOT_ENDPOINT]"
|
||||
deployment="PROD" />
|
||||
```
|
||||
|
||||
### Device-Specific Values
|
||||
- **ST20**: `clientID="577ecfcc-2db3-4989-92c9-76d7704f9fb3"`
|
||||
- **ST10**: `clientID="eb1a6d8f-0bb1-4aa7-9113-ea673fcef96e"`
|
||||
- **Endpoint**: `a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com` (XML)
|
||||
- **Backup Endpoint**: `amqmidtcohfms.iot.us-east-1.amazonaws.com` (hardcoded)
|
||||
|
||||
## Protocol Stack
|
||||
|
||||
```
|
||||
Application Layer: AWS IoT Device Shadows (JSON)
|
||||
Presentation Layer: RapidJSON parsing/serialization
|
||||
Session Layer: MQTT v3.1.1
|
||||
Transport Layer: TLS v1.2
|
||||
Network Layer: TCP/IP
|
||||
```
|
||||
|
||||
## Certificate Files
|
||||
|
||||
| File | Location | Purpose |
|
||||
|-----------------------|---------------------|---------------------------|
|
||||
| `iot-cert.pem.crt` | `/mnt/nv/IoTCerts/` | Device client certificate |
|
||||
| `iot-private.pem.key` | `/mnt/nv/IoTCerts/` | Device private key |
|
||||
| `rootCA.crt` | `/var/lib/iot/` | AWS IoT Root CA |
|
||||
|
||||
## MQTT Topics
|
||||
|
||||
### Shadow Operations
|
||||
```
|
||||
$aws/things/{clientID}/shadow/update
|
||||
$aws/things/{clientID}/shadow/update/accepted
|
||||
$aws/things/{clientID}/shadow/update/rejected
|
||||
$aws/things/{clientID}/shadow/delete
|
||||
```
|
||||
|
||||
### JSON Payload Examples
|
||||
|
||||
#### Device State Report
|
||||
```json
|
||||
{
|
||||
"state": {
|
||||
"reported": {
|
||||
"deviceState": "CONNECTED",
|
||||
"powerState": "ON",
|
||||
"zoneState": "...",
|
||||
"groupState": "..."
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Disconnection Message
|
||||
```json
|
||||
{
|
||||
"state": {
|
||||
"reported": {
|
||||
"deviceState": "DISCONNECTED"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Process Information
|
||||
|
||||
- **IoT Service PID**: 1837
|
||||
- **BoseApp PID**: 1846
|
||||
- **Daemon Manager**: Shepherd
|
||||
- **Service Type**: Non-core (stopped during updates)
|
||||
|
||||
## Registration Flow
|
||||
|
||||
1. Device generates X.509 CSR
|
||||
2. Calls `https://voice.api.bose.io/alexa/certificate`
|
||||
3. Receives device certificate
|
||||
4. Stores cert/key in `/mnt/nv/IoTCerts/`
|
||||
5. Connects to AWS IoT using certificate auth
|
||||
|
||||
## Directory Creation (Init Script)
|
||||
|
||||
```bash
|
||||
mkdir -p /mnt/nv/BoseLog /mnt/nv/IoTCerts /mnt/nv/BoseApp-Persistence/1
|
||||
mkdir -m 700 -p /mnt/nv/BoseApp-Persistence/1/Keys
|
||||
```
|
||||
|
||||
## Error Messages and Debugging
|
||||
|
||||
### Common Log Messages
|
||||
- `"Connection attempt %u to MQTT port at host %s"`
|
||||
- `"MQTT port not available. Retrying in %u seconds"`
|
||||
- `"Device connected with MQTT"`
|
||||
- `"got shadow response: accepted. Payload: %s"`
|
||||
- `"Failed to register device and get certificate, retrying"`
|
||||
|
||||
### Connection States
|
||||
- `"MQTT port is open"`
|
||||
- `"Successfully connected to MQTT server"`
|
||||
- `"Disconnecting from IoT server"`
|
||||
- `"UpdateShadow called when network is not ready"`
|
||||
|
||||
## Integration Points
|
||||
|
||||
### AWS Services
|
||||
- AWS IoT Core (MQTT broker)
|
||||
- AWS IoT Device Management (certificates)
|
||||
- AWS IoT Device Shadows (state sync)
|
||||
|
||||
### Bose Ecosystem
|
||||
- Mobile apps (remote control)
|
||||
- Alexa integration (voice commands)
|
||||
- Multi-room audio (zone coordination)
|
||||
- OTA updates (firmware management)
|
||||
|
||||
## Quick Troubleshooting
|
||||
|
||||
1. **No IoT connectivity**: Check certificate files in `/mnt/nv/IoTCerts/`
|
||||
2. **Certificate errors**: Verify registration endpoint accessibility
|
||||
3. **MQTT failures**: Check both primary and backup endpoints
|
||||
4. **Config issues**: Validate IoT.xml format and clientID uniqueness
|
||||
5. **Service not starting**: Check Shepherd configuration and process status
|
||||
|
||||
## MQTT Monitoring Capabilities
|
||||
|
||||
### Direct Access with Device Credentials
|
||||
```bash
|
||||
# Subscribe to device shadow events (own device only)
|
||||
mosquitto_sub -h a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com \
|
||||
-p 8883 --cafile /var/lib/iot/rootCA.crt \
|
||||
--cert /mnt/nv/IoTCerts/iot-cert.pem.crt \
|
||||
--key /mnt/nv/IoTCerts/iot-private.pem.key \
|
||||
-t '$aws/things/577ecfcc-2db3-4989-92c9-76d7704f9fb3/shadow/#'
|
||||
```
|
||||
|
||||
### AWS IoT Policy Restrictions
|
||||
- Device certificates limited to own clientID topics only
|
||||
- No wildcard subscriptions across devices
|
||||
- IP/location restrictions may apply
|
||||
- Certificate revocation for unusual activity
|
||||
|
||||
### Alternative Monitoring Methods
|
||||
```bash
|
||||
# Network traffic capture (less intrusive)
|
||||
tcpdump -i eth0 -s0 -w soundtouch_iot.pcap host a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com
|
||||
|
||||
# Monitor connection patterns
|
||||
tcpdump -i eth0 -n "host a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com and port 8883"
|
||||
```
|
||||
|
||||
### Expected Message Examples
|
||||
```json
|
||||
// Power state change
|
||||
{"state":{"reported":{"powerState":"ON","deviceState":"CONNECTED"}}}
|
||||
|
||||
// Volume adjustment
|
||||
{"state":{"reported":{"volume":25,"muted":false}}}
|
||||
|
||||
// Zone configuration
|
||||
{"state":{"reported":{"zoneState":"master","groupMembers":["device1"]}}}
|
||||
```
|
||||
|
||||
## Security Notes
|
||||
|
||||
- TLS 1.2 encryption for all communications
|
||||
- X.509 mutual authentication
|
||||
- Private keys stored with 700 permissions
|
||||
- No hardcoded credentials in binaries
|
||||
- Automatic certificate lifecycle management
|
||||
- **Monitoring Constraints**: Device credentials restricted to own device topics
|
||||
- **Ethical Consideration**: Only monitor devices you own
|
||||
@@ -0,0 +1,370 @@
|
||||
# IoT Configuration Analysis
|
||||
|
||||
## Overview
|
||||
|
||||
This document provides a detailed analysis of the AWS IoT configuration system used by Bose SoundTouch devices, based on firmware backup analysis from ST10 and ST20 models.
|
||||
|
||||
## Configuration Files
|
||||
|
||||
### IoT.xml Location and Content
|
||||
|
||||
The IoT configuration is stored in XML format at:
|
||||
- **Path**: `/mnt/nv/BoseApp-Persistence/1/IoT.xml`
|
||||
- **Purpose**: Contains AWS IoT Core connection parameters
|
||||
|
||||
#### ST20 Configuration
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Configuration clientID="uuid1"
|
||||
iotEndpoint="a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com"
|
||||
deployment="PROD" />
|
||||
```
|
||||
|
||||
#### ST10 Configuration
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Configuration clientID="uuid2"
|
||||
iotEndpoint="a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com"
|
||||
deployment="PROD" />
|
||||
```
|
||||
|
||||
### Key Observations
|
||||
- Each device has a unique `clientID` (UUID format)
|
||||
- Both devices use the same AWS IoT endpoint
|
||||
- Both are configured for production deployment (`PROD`)
|
||||
|
||||
## Binary Analysis
|
||||
|
||||
### Primary IoT Service Binary
|
||||
|
||||
**Location**: `/opt/Bose/IoT`
|
||||
- **Type**: ARM ELF 32-bit executable
|
||||
- **Purpose**: Main IoT daemon process
|
||||
- **Framework**: AWS IoT SDK for C++
|
||||
|
||||
### Certificate and Key Management
|
||||
|
||||
The IoT binary manages the following certificate files:
|
||||
|
||||
| File | Location | Purpose |
|
||||
|-----------------------|---------------------|-----------------------------|
|
||||
| `iot-cert.pem.crt` | `/mnt/nv/IoTCerts/` | Device client certificate |
|
||||
| `iot-private.pem.key` | `/mnt/nv/IoTCerts/` | Device private key |
|
||||
| `rootCA.crt` | `/var/lib/iot/` | AWS IoT Root CA certificate |
|
||||
|
||||
### Certificate Registration Process
|
||||
|
||||
1. **CSR Generation**: Device generates X.509 certificate signing request
|
||||
2. **Registration Endpoint**: `https://voice.api.bose.io/alexa/certificate`
|
||||
3. **Certificate Storage**: Certificates stored in `/mnt/nv/IoTCerts/`
|
||||
4. **Automatic Provisioning**: Process appears to be automated during device setup
|
||||
|
||||
## Protocol Analysis
|
||||
|
||||
### Connection Details
|
||||
|
||||
- **Protocol**: MQTT over TLS 1.2
|
||||
- **Port**: Standard MQTT over SSL (likely 8883)
|
||||
- **Authentication**: X.509 client certificate mutual authentication
|
||||
- **Endpoint Redundancy**:
|
||||
- Primary (hardcoded): `amqmidtcohfms.iot.us-east-1.amazonaws.com`
|
||||
- Fallback (XML config): `a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com`
|
||||
|
||||
### AWS IoT Device Shadow Integration
|
||||
|
||||
The system uses AWS IoT Device Shadows for state management:
|
||||
|
||||
#### Topic Structure
|
||||
```
|
||||
$aws/things/{thing_name}/shadow/update
|
||||
$aws/things/{thing_name}/shadow/update/accepted
|
||||
$aws/things/{thing_name}/shadow/update/rejected
|
||||
$aws/things/{thing_name}/shadow/delete
|
||||
```
|
||||
|
||||
#### Shadow JSON Format
|
||||
```json
|
||||
{
|
||||
"state": {
|
||||
"desired": {},
|
||||
"reported": {
|
||||
"deviceState": "CONNECTED|DISCONNECTED",
|
||||
"powerState": "ON|OFF",
|
||||
"zoneState": "...",
|
||||
"groupState": "..."
|
||||
}
|
||||
},
|
||||
"version": 0,
|
||||
"clientToken": "...",
|
||||
"timestamp": 0
|
||||
}
|
||||
```
|
||||
|
||||
### Message Types
|
||||
|
||||
1. **Device State Updates**
|
||||
- Connection status (`CONNECTED`/`DISCONNECTED`)
|
||||
- Power state changes
|
||||
- Audio zone configuration
|
||||
- Multi-room grouping status
|
||||
|
||||
2. **Shadow Delta Processing**
|
||||
- Receives desired state changes
|
||||
- Updates device configuration
|
||||
- Reports new state back to shadow
|
||||
|
||||
## System Integration
|
||||
|
||||
### Service Management
|
||||
|
||||
The IoT service is managed by the Shepherd daemon system:
|
||||
|
||||
**Configuration**: `/opt/Bose/etc/Shepherd-noncore.xml`
|
||||
```xml
|
||||
<ShepherdConfig>
|
||||
<daemon name="STSCertified"/>
|
||||
<daemon name="IoT"/>
|
||||
<daemon name="TPDA">
|
||||
<arg>-c</arg>
|
||||
<arg>/opt/Bose/etc/Voice.xml</arg>
|
||||
</daemon>
|
||||
</ShepherdConfig>
|
||||
```
|
||||
|
||||
### Directory Structure Creation
|
||||
|
||||
The SoundTouch init script (`/etc/init.d/SoundTouch`) ensures proper directory structure:
|
||||
|
||||
```bash
|
||||
mkdir -p /mnt/nv/BoseLog /mnt/nv/IoTCerts /mnt/nv/BoseApp-Persistence/1
|
||||
mkdir -m 700 -p /mnt/nv/BoseApp-Persistence/1/Keys
|
||||
```
|
||||
|
||||
### Process Information
|
||||
|
||||
From runtime analysis (`/var/run/shepherd/pids`):
|
||||
- IoT service runs as PID 1837
|
||||
- BoseApp service runs as PID 1846
|
||||
- Both services are active during normal operation
|
||||
|
||||
## Configuration Dependencies
|
||||
|
||||
### Files That Reference IoT Configuration
|
||||
|
||||
1. **IoT Binary** (`/opt/Bose/IoT`)
|
||||
- Primary consumer of IoT.xml configuration
|
||||
- Contains hardcoded backup endpoints
|
||||
- Manages certificate lifecycle
|
||||
|
||||
2. **BoseApp Binary** (`/opt/Bose/BoseApp`)
|
||||
- References BoseApp-Persistence directory structure
|
||||
- May trigger IoT updates based on device state changes
|
||||
|
||||
3. **SoundTouch Init Script** (`/etc/init.d/SoundTouch`)
|
||||
- Creates necessary directory structure
|
||||
- Ensures proper permissions for certificate storage
|
||||
|
||||
4. **Shepherd Configuration** (`/opt/Bose/etc/Shepherd-noncore.xml`)
|
||||
- Defines IoT service startup parameters
|
||||
- Manages service lifecycle
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Certificate Management
|
||||
- Private keys stored with 700 permissions
|
||||
- Certificates managed automatically by the device
|
||||
- Registration process appears to use device-specific authentication
|
||||
|
||||
### Network Security
|
||||
- All communication over TLS 1.2
|
||||
- Mutual authentication using X.509 certificates
|
||||
- AWS IoT Core provides additional access controls
|
||||
|
||||
### Configuration Protection
|
||||
- Configuration files stored in persistent storage
|
||||
- Directory structure created with appropriate permissions
|
||||
- No hardcoded credentials in binaries (uses certificate-based auth)
|
||||
|
||||
## Integration Points
|
||||
|
||||
### AWS Services
|
||||
- **AWS IoT Core**: Primary messaging and device management
|
||||
- **AWS IoT Device Management**: Certificate provisioning
|
||||
- **AWS IoT Device Shadows**: State synchronization
|
||||
|
||||
### Bose Services
|
||||
- **Mobile Applications**: Remote control and monitoring
|
||||
- **Alexa Integration**: Voice control capabilities
|
||||
- **Multi-room Audio**: Zone and group coordination
|
||||
|
||||
### Device Functions
|
||||
- **Power Management**: Remote power on/off
|
||||
- **Audio Control**: Volume, source selection
|
||||
- **Network Configuration**: WiFi and connectivity settings
|
||||
- **Firmware Updates**: OTA update coordination
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Certificate Problems**
|
||||
- Check `/mnt/nv/IoTCerts/` for valid certificates
|
||||
- Verify certificate registration endpoint accessibility
|
||||
- Ensure proper file permissions (600 for keys)
|
||||
|
||||
2. **Connection Issues**
|
||||
- Verify both primary and fallback endpoints
|
||||
- Check TLS 1.2 support and cipher suites
|
||||
- Validate clientID uniqueness
|
||||
|
||||
3. **Configuration Issues**
|
||||
- Ensure IoT.xml has proper XML format
|
||||
- Verify clientID is valid UUID format
|
||||
- Check deployment parameter matches environment
|
||||
|
||||
### Debug Information
|
||||
|
||||
The IoT binary provides extensive logging for:
|
||||
- MQTT connection attempts and status
|
||||
- Certificate loading and validation
|
||||
- Shadow message processing
|
||||
- Network state changes
|
||||
|
||||
## MQTT Monitoring and Security Considerations
|
||||
|
||||
### Direct MQTT Access with Device Credentials
|
||||
|
||||
With access to the device's private key and certificate, it's technically possible to subscribe to MQTT events:
|
||||
|
||||
```bash
|
||||
# Subscribe to device shadow events
|
||||
mosquitto_sub -h a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com \
|
||||
-p 8883 --cafile /var/lib/iot/rootCA.crt \
|
||||
--cert /mnt/nv/IoTCerts/iot-cert.pem.crt \
|
||||
--key /mnt/nv/IoTCerts/iot-private.pem.key \
|
||||
-t '$aws/things/_uuid_/shadow/#'
|
||||
```
|
||||
|
||||
### Security Constraints and Limitations
|
||||
|
||||
#### AWS IoT Policy Restrictions
|
||||
Device certificates are bound to specific policies that typically restrict:
|
||||
- Access to device-specific topics only (`$aws/things/{clientID}/shadow/*`)
|
||||
- No wildcard subscriptions across multiple devices
|
||||
- Limited publish/subscribe permissions
|
||||
- Possible IP geolocation restrictions
|
||||
|
||||
#### Example Policy Structure
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": "iot:Connect",
|
||||
"Resource": "arn:aws:iot:us-east-1:*:client/${iot:ClientId}"
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": ["iot:Publish", "iot:Subscribe", "iot:Receive"],
|
||||
"Resource": [
|
||||
"arn:aws:iot:us-east-1:*:topic/$aws/things/${iot:ClientId}/shadow/*",
|
||||
"arn:aws:iot:us-east-1:*:topicfilter/$aws/things/${iot:ClientId}/shadow/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Additional Security Measures
|
||||
- Certificate revocation for unusual activity
|
||||
- Device fingerprinting and connection frequency limits
|
||||
- Service shutdown timeline (May 2026) affecting endpoint availability
|
||||
|
||||
### Alternative Monitoring Approaches
|
||||
|
||||
#### Network Traffic Capture
|
||||
A less intrusive method to analyze MQTT communication patterns:
|
||||
|
||||
```bash
|
||||
# Capture encrypted MQTT traffic from the actual device
|
||||
tcpdump -i eth0 -s0 -w soundtouch_iot.pcap host a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com
|
||||
|
||||
# Monitor connection patterns
|
||||
tcpdump -i eth0 -n "host a2bhvr9c4wn4ya.iot.us-east-1.amazonaws.com and port 8883"
|
||||
```
|
||||
|
||||
#### Local MQTT Broker Setup
|
||||
For development and testing, create a local MQTT broker that mimics AWS IoT behavior:
|
||||
|
||||
```bash
|
||||
# Install and configure Mosquitto
|
||||
sudo apt-get install mosquitto mosquitto-clients
|
||||
|
||||
# Create test shadow topics
|
||||
mosquitto_pub -h localhost -t '$aws/things/test-device/shadow/update' \
|
||||
-m '{"state":{"reported":{"deviceState":"CONNECTED"}}}'
|
||||
```
|
||||
|
||||
### Ethical and Legal Considerations
|
||||
|
||||
- **Device Ownership**: Only monitor devices you own
|
||||
- **Terms of Service**: Using credentials outside device context may violate Bose ToS
|
||||
- **Unauthorized Access**: Accessing Bose's AWS infrastructure could be considered inappropriate
|
||||
- **Research Purpose**: Limit monitoring to understanding message formats for local alternatives
|
||||
|
||||
### Expected Message Examples
|
||||
|
||||
If monitoring is successful, typical shadow messages include:
|
||||
|
||||
```json
|
||||
// Power state change
|
||||
{
|
||||
"state": {
|
||||
"reported": {
|
||||
"powerState": "ON",
|
||||
"deviceState": "CONNECTED",
|
||||
"timestamp": 1703875200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Volume adjustment
|
||||
{
|
||||
"state": {
|
||||
"reported": {
|
||||
"volume": 25,
|
||||
"muted": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Zone configuration
|
||||
{
|
||||
"state": {
|
||||
"reported": {
|
||||
"zoneState": "master",
|
||||
"groupMembers": ["device1", "device2"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Recommended Research Approach
|
||||
|
||||
1. **Document Message Formats**: Capture and analyze JSON structures
|
||||
2. **Understand State Transitions**: Map device actions to shadow updates
|
||||
3. **Build Local Alternative**: Use insights to create local MQTT shadow service
|
||||
4. **Prepare for Service Shutdown**: Develop migration strategy before May 2026
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Bose SoundTouch IoT configuration system is a sophisticated implementation using AWS IoT Core for real-time device management. The system provides:
|
||||
|
||||
- Secure, certificate-based authentication
|
||||
- Reliable bi-directional communication
|
||||
- Comprehensive device state management
|
||||
- Integration with voice assistants and mobile applications
|
||||
- Robust error handling and retry mechanisms
|
||||
|
||||
This architecture enables seamless remote control, monitoring, and coordination of SoundTouch devices across multiple platforms and services.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user