autom8-cli 0.3.0

CLI automation tool for orchestrating Claude-powered development
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
//! Theme and color system for the GUI.
//!
//! This module provides a cohesive color system and egui Visuals configuration
//! that achieves a warm, approachable aesthetic inspired by the Claude desktop
//! application. Uses a warm beige/cream palette with proper semantic colors
//! for status states and UI elements.

use eframe::egui::{self, Color32, Rounding, Stroke, Style, Visuals};

/// Spacing scale for consistent layout throughout the application.
///
/// Use these constants instead of arbitrary pixel values to ensure
/// visual consistency and a cohesive rhythm across all UI elements.
pub mod spacing {
    /// Extra small spacing (4px) - tight spacing between related elements.
    pub const XS: f32 = 4.0;

    /// Small spacing (8px) - standard spacing between related elements.
    pub const SM: f32 = 8.0;

    /// Medium spacing (12px) - spacing between sections within a component.
    pub const MD: f32 = 12.0;

    /// Standard spacing (16px) - standard component padding, gaps between cards.
    pub const LG: f32 = 16.0;

    /// Large spacing (24px) - spacing between major sections.
    pub const XL: f32 = 24.0;

    /// Extra large spacing (32px) - large gaps, page-level margins.
    pub const XXL: f32 = 32.0;
}

/// Corner rounding values for consistent UI elements.
pub mod rounding {
    /// Rounding for cards and panels (8px).
    pub const CARD: f32 = 8.0;

    /// Rounding for buttons and inputs (4px).
    pub const BUTTON: f32 = 4.0;

    /// Rounding for small elements like badges (2px).
    pub const SMALL: f32 = 2.0;

    /// No rounding (0px).
    pub const NONE: f32 = 0.0;
}

/// Shadow depths for elevated surfaces.
///
/// Shadows use warm-tinted colors (slight brown/amber tint) to complement
/// the warm cream color palette, avoiding harsh pure-black shadows.
pub mod shadow {
    use super::Color32;
    use eframe::egui::Shadow;

    /// Warm shadow base color - a very subtle warm brown.
    /// Uses RGB values that lean warm (R > G > B) even at low alpha.
    /// This creates softer shadows that complement the warm palette.
    const SHADOW_WARM: Color32 = Color32::from_rgba_premultiplied(40, 30, 20, 255);

    /// Subtle shadow for slightly elevated elements.
    pub fn subtle() -> Shadow {
        Shadow {
            offset: [0.0, 1.0].into(),
            blur: 3.0,
            spread: 0.0,
            // Warm brown shadow at low opacity
            color: Color32::from_rgba_premultiplied(
                SHADOW_WARM.r(),
                SHADOW_WARM.g(),
                SHADOW_WARM.b(),
                12,
            ),
        }
    }

    /// Medium shadow for cards and panels.
    pub fn medium() -> Shadow {
        Shadow {
            offset: [0.0, 2.0].into(),
            blur: 8.0,
            spread: 0.0,
            // Warm brown shadow at medium opacity
            color: Color32::from_rgba_premultiplied(
                SHADOW_WARM.r(),
                SHADOW_WARM.g(),
                SHADOW_WARM.b(),
                18,
            ),
        }
    }

    /// Elevated shadow for modals and popovers.
    pub fn elevated() -> Shadow {
        Shadow {
            offset: [0.0, 4.0].into(),
            blur: 16.0,
            spread: 0.0,
            // Warm brown shadow at higher opacity
            color: Color32::from_rgba_premultiplied(
                SHADOW_WARM.r(),
                SHADOW_WARM.g(),
                SHADOW_WARM.b(),
                24,
            ),
        }
    }

    /// Returns the warm shadow base color for testing.
    #[cfg(test)]
    pub fn shadow_warm_color() -> Color32 {
        SHADOW_WARM
    }
}

/// Semantic color palette for the light theme.
///
/// Colors use a warm beige/cream palette inspired by the Claude desktop
/// application, with careful attention to contrast ratios for accessibility.
pub mod colors {
    use super::Color32;

    // ==========================================================================
    // Background Colors
    // ==========================================================================

    /// Primary window background - warm cream.
    /// Inspired by Claude's warm, approachable aesthetic (~#FAF9F7).
    pub const BACKGROUND: Color32 = Color32::from_rgb(250, 249, 247);

    /// Surface color for cards and panels - white.
    pub const SURFACE: Color32 = Color32::from_rgb(255, 255, 255);

    /// Elevated surface for modals and popovers.
    pub const SURFACE_ELEVATED: Color32 = Color32::from_rgb(255, 255, 255);

    /// Subtle background for hover states - warm beige tint.
    pub const SURFACE_HOVER: Color32 = Color32::from_rgb(245, 243, 239);

    /// Background for selected/active items - warm beige.
    pub const SURFACE_SELECTED: Color32 = Color32::from_rgb(238, 235, 229);

    // ==========================================================================
    // Text Colors
    // ==========================================================================

    /// Primary text color - dark gray for good contrast.
    /// WCAG AA compliant against BACKGROUND and SURFACE.
    pub const TEXT_PRIMARY: Color32 = Color32::from_rgb(28, 28, 30);

    /// Secondary text color - medium gray for less emphasis.
    pub const TEXT_SECONDARY: Color32 = Color32::from_rgb(99, 99, 102);

    /// Muted text color - light gray for tertiary information.
    pub const TEXT_MUTED: Color32 = Color32::from_rgb(142, 142, 147);

    /// Disabled text color.
    pub const TEXT_DISABLED: Color32 = Color32::from_rgb(174, 174, 178);

    // ==========================================================================
    // Border and Separator Colors
    // ==========================================================================

    /// Subtle border color for cards and inputs - warm gray.
    pub const BORDER: Color32 = Color32::from_rgb(232, 229, 222);

    /// Stronger border for focused elements - warm gray.
    pub const BORDER_FOCUSED: Color32 = Color32::from_rgb(205, 200, 190);

    /// Separator line color - warm gray.
    pub const SEPARATOR: Color32 = Color32::from_rgb(232, 229, 222);

    // ==========================================================================
    // Accent Colors
    // ==========================================================================

    /// Primary accent color - blue (similar to macOS system blue).
    pub const ACCENT: Color32 = Color32::from_rgb(0, 122, 255);

    /// Accent color for hover state.
    pub const ACCENT_HOVER: Color32 = Color32::from_rgb(0, 111, 230);

    /// Accent color for active/pressed state.
    pub const ACCENT_ACTIVE: Color32 = Color32::from_rgb(0, 100, 210);

    /// Light accent for backgrounds.
    pub const ACCENT_SUBTLE: Color32 = Color32::from_rgb(230, 244, 255);

    // ==========================================================================
    // Status Colors
    // ==========================================================================

    /// Running state - blue/cyan (indicates active work).
    pub const STATUS_RUNNING: Color32 = Color32::from_rgb(0, 149, 255);

    /// Success state - green (indicates completion).
    pub const STATUS_SUCCESS: Color32 = Color32::from_rgb(52, 199, 89);

    /// Warning state - amber (indicates attention needed).
    pub const STATUS_WARNING: Color32 = Color32::from_rgb(255, 149, 0);

    /// Error state - red (indicates failure).
    pub const STATUS_ERROR: Color32 = Color32::from_rgb(255, 59, 48);

    /// Idle state - gray (indicates inactive).
    pub const STATUS_IDLE: Color32 = Color32::from_rgb(142, 142, 147);

    /// Correcting state - orange (attention needed, distinct from warning amber).
    pub const STATUS_CORRECTING: Color32 = Color32::from_rgb(255, 94, 58);

    // ==========================================================================
    // Status Background Colors (for badges/highlights)
    // ==========================================================================

    /// Running state background - light blue.
    pub const STATUS_RUNNING_BG: Color32 = Color32::from_rgb(230, 244, 255);

    /// Success state background - light green.
    pub const STATUS_SUCCESS_BG: Color32 = Color32::from_rgb(232, 250, 238);

    /// Warning state background - light amber.
    pub const STATUS_WARNING_BG: Color32 = Color32::from_rgb(255, 244, 230);

    /// Error state background - light red.
    pub const STATUS_ERROR_BG: Color32 = Color32::from_rgb(255, 235, 234);

    /// Idle state background - warm light beige.
    pub const STATUS_IDLE_BG: Color32 = Color32::from_rgb(245, 243, 239);

    /// Correcting state background - light orange.
    pub const STATUS_CORRECTING_BG: Color32 = Color32::from_rgb(255, 237, 230);
}

// Note: The Status enum is defined in the components module to avoid duplication.
// Use `crate::ui::gui::components::Status` for status state to color mapping.

/// Configure egui Visuals for the light theme.
///
/// This creates a custom Visuals configuration that matches the macOS
/// aesthetic with proper colors, rounding, and shadows.
pub fn configure_visuals() -> Visuals {
    let mut visuals = Visuals::light();

    // Window and panel backgrounds
    visuals.window_fill = colors::SURFACE;
    visuals.panel_fill = colors::BACKGROUND;
    visuals.faint_bg_color = colors::SURFACE_HOVER;
    visuals.extreme_bg_color = colors::SURFACE;
    visuals.code_bg_color = Color32::from_rgb(248, 246, 242);

    // Selection colors
    visuals.selection.bg_fill = colors::ACCENT_SUBTLE;
    visuals.selection.stroke = Stroke::new(1.0, colors::ACCENT);

    // Hyperlink color
    visuals.hyperlink_color = colors::ACCENT;

    // Window shadow (for popups/menus)
    visuals.window_shadow = shadow::elevated();
    visuals.popup_shadow = shadow::medium();

    // Window stroke (border)
    visuals.window_stroke = Stroke::new(1.0, colors::BORDER);

    // Corner rounding
    visuals.window_rounding = Rounding::same(rounding::CARD);
    visuals.menu_rounding = Rounding::same(rounding::BUTTON);

    // Text cursor
    visuals.text_cursor.stroke = Stroke::new(2.0, colors::ACCENT);

    // Widget visuals
    configure_widget_visuals(&mut visuals);

    visuals
}

/// Configure widget-specific visuals.
fn configure_widget_visuals(visuals: &mut Visuals) {
    // Noninteractive widgets (labels, etc.)
    visuals.widgets.noninteractive.bg_fill = colors::SURFACE;
    visuals.widgets.noninteractive.weak_bg_fill = colors::SURFACE_HOVER;
    visuals.widgets.noninteractive.bg_stroke = Stroke::new(1.0, colors::BORDER);
    visuals.widgets.noninteractive.fg_stroke = Stroke::new(1.0, colors::TEXT_PRIMARY);
    visuals.widgets.noninteractive.rounding = Rounding::same(rounding::BUTTON);

    // Inactive widgets (not hovered, not clicked)
    visuals.widgets.inactive.bg_fill = colors::SURFACE;
    visuals.widgets.inactive.weak_bg_fill = colors::SURFACE;
    visuals.widgets.inactive.bg_stroke = Stroke::new(1.0, colors::BORDER);
    visuals.widgets.inactive.fg_stroke = Stroke::new(1.0, colors::TEXT_PRIMARY);
    visuals.widgets.inactive.rounding = Rounding::same(rounding::BUTTON);

    // Hovered widgets
    visuals.widgets.hovered.bg_fill = colors::SURFACE_HOVER;
    visuals.widgets.hovered.weak_bg_fill = colors::SURFACE_HOVER;
    visuals.widgets.hovered.bg_stroke = Stroke::new(1.0, colors::BORDER_FOCUSED);
    visuals.widgets.hovered.fg_stroke = Stroke::new(1.5, colors::TEXT_PRIMARY);
    visuals.widgets.hovered.rounding = Rounding::same(rounding::BUTTON);

    // Active/pressed widgets
    visuals.widgets.active.bg_fill = colors::SURFACE_SELECTED;
    visuals.widgets.active.weak_bg_fill = colors::SURFACE_SELECTED;
    visuals.widgets.active.bg_stroke = Stroke::new(1.0, colors::ACCENT);
    visuals.widgets.active.fg_stroke = Stroke::new(2.0, colors::TEXT_PRIMARY);
    visuals.widgets.active.rounding = Rounding::same(rounding::BUTTON);

    // Open widgets (combo boxes, menus when open)
    visuals.widgets.open.bg_fill = colors::SURFACE;
    visuals.widgets.open.weak_bg_fill = colors::SURFACE_HOVER;
    visuals.widgets.open.bg_stroke = Stroke::new(1.0, colors::ACCENT);
    visuals.widgets.open.fg_stroke = Stroke::new(1.0, colors::TEXT_PRIMARY);
    visuals.widgets.open.rounding = Rounding::same(rounding::BUTTON);
}

/// Configure the egui Style with additional settings.
pub fn configure_style() -> Style {
    // Get default style and modify spacing
    let default_style = Style::default();
    let mut style_spacing = default_style.spacing.clone();

    // Use our spacing scale for consistency
    style_spacing.item_spacing = egui::vec2(spacing::SM, spacing::XS);
    style_spacing.window_margin = egui::Margin::same(spacing::LG);
    style_spacing.button_padding = egui::vec2(spacing::MD, 6.0);
    style_spacing.menu_margin = egui::Margin::same(spacing::SM);
    style_spacing.indent = spacing::LG;
    style_spacing.scroll = egui::style::ScrollStyle {
        floating: true,
        bar_width: spacing::SM,
        // Smoother scroll animation
        floating_allocated_width: 0.0,
        bar_inner_margin: spacing::XS,
        bar_outer_margin: spacing::XS,
        ..Default::default()
    };
    // Ensure consistent spacing for combo boxes and menus
    style_spacing.combo_width = 100.0;

    // Modify interaction settings
    let mut interaction = default_style.interaction.clone();
    interaction.selectable_labels = true;
    interaction.multi_widget_text_select = true;

    Style {
        visuals: configure_visuals(),
        spacing: style_spacing,
        interaction,
        // Enable smooth animations for hover/click state transitions.
        // This affects widget state changes (hover, press, etc.) with a
        // ~100ms ease-in animation for polished visual feedback.
        // Note: egui doesn't support panel appearance/disappearance animations,
        // but scroll areas and widget state changes will be smoothly animated.
        animation_time: 0.1,
        ..Default::default()
    }
}

/// Initialize the theme for the application.
///
/// Call this during app initialization (in the CreationContext callback)
/// to apply the custom theme globally.
pub fn init(ctx: &egui::Context) {
    ctx.set_style(configure_style());
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_spacing_scale() {
        // Verify spacing scale is monotonically increasing
        assert!(spacing::XS < spacing::SM);
        assert!(spacing::SM < spacing::MD);
        assert!(spacing::MD < spacing::LG);
        assert!(spacing::LG < spacing::XL);
        assert!(spacing::XL < spacing::XXL);
    }

    #[test]
    fn test_shadows() {
        let subtle = shadow::subtle();
        let medium = shadow::medium();
        let elevated = shadow::elevated();

        // Verify shadow alpha values are appropriately subtle
        assert!(subtle.color.a() <= 15);
        assert!(medium.color.a() <= 20);
        assert!(elevated.color.a() <= 30);

        // Verify blur increases with elevation
        assert!(subtle.blur < medium.blur);
        assert!(medium.blur < elevated.blur);

        // Verify warm tones
        let warm = shadow::shadow_warm_color();
        assert!(warm.r() > warm.g() && warm.g() > warm.b());
    }

    #[test]
    fn test_text_contrast() {
        // Primary text should have good contrast against both background and surface
        let text_lum = colors::TEXT_PRIMARY.r() as u32
            + colors::TEXT_PRIMARY.g() as u32
            + colors::TEXT_PRIMARY.b() as u32;
        let bg_lum = colors::BACKGROUND.r() as u32
            + colors::BACKGROUND.g() as u32
            + colors::BACKGROUND.b() as u32;
        let surface_lum =
            colors::SURFACE.r() as u32 + colors::SURFACE.g() as u32 + colors::SURFACE.b() as u32;

        assert!(
            bg_lum - text_lum > 400,
            "Need contrast > 400 against background"
        );
        assert!(
            surface_lum - text_lum > 500,
            "Need contrast > 500 against surface"
        );
    }

    #[test]
    fn test_configure_visuals() {
        let visuals = configure_visuals();

        assert!(!visuals.dark_mode);
        assert_eq!(visuals.window_fill, colors::SURFACE);
        assert_eq!(visuals.panel_fill, colors::BACKGROUND);
        assert_eq!(visuals.window_rounding, Rounding::same(rounding::CARD));
        assert_eq!(visuals.widgets.hovered.bg_fill, colors::SURFACE_HOVER);
        assert_eq!(visuals.widgets.active.bg_fill, colors::SURFACE_SELECTED);
        assert_eq!(visuals.selection.bg_fill, colors::ACCENT_SUBTLE);
    }

    #[test]
    fn test_configure_style() {
        let style = configure_style();

        assert!(style.animation_time > 0.0 && style.animation_time <= 0.2);
        assert!(style.spacing.scroll.floating);
        assert_eq!(style.visuals.window_fill, colors::SURFACE);
    }

    #[test]
    fn test_warm_color_palette() {
        // All these colors should have warm tones (R >= G >= B)
        let warm_colors = [
            ("BACKGROUND", colors::BACKGROUND),
            ("SURFACE_HOVER", colors::SURFACE_HOVER),
            ("SURFACE_SELECTED", colors::SURFACE_SELECTED),
            ("BORDER", colors::BORDER),
            ("SEPARATOR", colors::SEPARATOR),
        ];

        for (name, color) in warm_colors {
            assert!(
                color.r() >= color.g() && color.g() >= color.b(),
                "{} should have warm tones (R >= G >= B), got RGB({}, {}, {})",
                name,
                color.r(),
                color.g(),
                color.b()
            );
        }

        // BACKGROUND should be the specific warm cream color
        assert_eq!(colors::BACKGROUND, Color32::from_rgb(250, 249, 247));
    }

    #[test]
    fn test_status_colors_distinct() {
        // Status colors should be visually distinct
        let status_colors = [
            colors::STATUS_RUNNING,
            colors::STATUS_SUCCESS,
            colors::STATUS_WARNING,
            colors::STATUS_ERROR,
            colors::STATUS_IDLE,
        ];

        for i in 0..status_colors.len() {
            for j in (i + 1)..status_colors.len() {
                assert_ne!(status_colors[i], status_colors[j]);
            }
        }
    }
}