collet 0.1.1

Relentless agentic coding orchestrator with zero-drop agent loops
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
mod builtin;

use ratatui::prelude::Color;

/// Centralized theme with all color definitions used across the TUI.
#[derive(Debug, Clone)]
pub struct Theme {
    // ── Accent ──
    pub accent: Color,
    pub accent_dim: Color,

    // ── Semantic ──
    pub success: Color,
    pub error: Color,
    pub warning: Color,
    pub info: Color,

    // ── Text ──
    pub text: Color,
    pub text_dim: Color,
    pub text_muted: Color,

    // ── Surfaces ──
    pub bg: Color,
    pub bg_surface: Color,

    // ── Borders ──
    pub border: Color,
    pub border_busy: Color,

    // ── Chat roles ──
    pub user: Color,
    pub assistant: Color,
    pub system: Color,

    // ── Markdown ──
    pub md_header: Color,
    pub md_code: Color,
    pub md_code_bg: Color,
    pub md_bullet: Color,

    // ── Status bar ──
    pub status_fg: Color,
    pub status_bg: Color,
    pub status_busy_fg: Color,
    pub status_busy_bg: Color,
    pub status_line2_fg: Color,
    pub status_line2_bg: Color,

    // ── Spinner ──
    pub spinner: Color,
    pub spinner_dim: Color,

    // ── Diff view ──
    pub diff_add_fg: Color,
    pub diff_add_bg: Color,
    pub diff_remove_fg: Color,
    pub diff_remove_bg: Color,

    // ── Meta ──
    pub is_dark: bool,
}

/// Minimal set of raw colors needed to define a theme.
///
/// `Theme::from_palette` maps these 12 colors onto the full `Theme` struct
/// using a consistent convention.  Individual theme functions can then apply
/// field-level overrides for the handful of fields that deviate from the
/// standard mapping.
pub struct ThemePalette {
    /// Main background.
    pub bg: Color,
    /// Surface / sidebar / status background (slightly different from `bg`).
    pub surface: Color,
    /// Primary text.
    pub fg: Color,
    /// Secondary / dimmed text.
    pub fg_dim: Color,
    /// Muted / comment text.
    pub fg_muted: Color,
    /// Primary accent (links, selection, mode badge, active border).
    pub accent: Color,
    /// Secondary accent (spinner, markdown header).
    pub accent2: Color,
    /// Success / green semantic color.
    pub green: Color,
    /// Error / red semantic color.
    pub red: Color,
    /// Warning / yellow semantic color.
    pub yellow: Color,
    /// Info / blue semantic color.  Also used as the default `md_code` color.
    pub blue: Color,
    /// Busy / warning accent (busy border, busy status background).
    pub orange: Color,
    /// Whether this is a dark theme (affects diff background tint).
    pub is_dark: bool,
}

/// A theme family grouping dark and optional light variants.
pub struct ThemeFamily {
    pub name: &'static str,
    pub dark_id: &'static str,
    pub light_id: Option<&'static str>,
}

impl Theme {
    /// Build a `Theme` from a `ThemePalette` using the standard field mapping.
    ///
    /// Standard mapping:
    /// - `accent`   → accent, assistant, md_bullet, status_bg
    /// - `accent2`  → spinner, md_header
    /// - `surface`  → bg_surface, md_code_bg, status_line2_bg
    /// - `fg_muted` → accent_dim, border, spinner_dim, status_line2_fg, text_muted
    /// - `bg`       → status_fg, status_busy_fg
    /// - `fg`       → text
    /// - `fg_dim`   → text_dim
    /// - `green`    → success, user
    /// - `red`      → error
    /// - `yellow`   → warning, system
    /// - `blue`     → info, md_code
    /// - `orange`   → border_busy, status_busy_bg
    pub fn from_palette(p: &ThemePalette) -> Self {
        Self {
            accent: p.accent,
            accent_dim: p.fg_muted,

            success: p.green,
            error: p.red,
            warning: p.yellow,
            info: p.blue,

            text: p.fg,
            text_dim: p.fg_dim,
            text_muted: p.fg_muted,

            bg: p.bg,
            bg_surface: p.surface,

            border: p.fg_muted,
            border_busy: p.orange,

            user: p.green,
            assistant: p.accent,
            system: p.yellow,

            md_header: p.accent2,
            md_code: p.blue,
            md_code_bg: p.surface,
            md_bullet: p.accent,

            status_fg: p.bg,
            status_bg: p.accent,
            status_busy_fg: p.bg,
            status_busy_bg: p.orange,
            status_line2_fg: p.fg_muted,
            status_line2_bg: p.surface,

            spinner: p.accent2,
            spinner_dim: p.fg_muted,

            diff_add_fg: p.green,
            diff_add_bg: if p.is_dark {
                Color::Rgb(23, 52, 30)
            } else {
                Color::Rgb(215, 250, 215)
            },
            diff_remove_fg: p.red,
            diff_remove_bg: if p.is_dark {
                Color::Rgb(59, 20, 25)
            } else {
                Color::Rgb(253, 220, 220)
            },

            is_dark: p.is_dark,
        }
    }

    /// Resolve a theme by name.  Falls back to `default` for unknown names.
    pub fn from_name(name: &str) -> Self {
        match name {
            "dracula" => Self::dracula(),
            "catppuccin" | "catppuccin-mocha" => Self::catppuccin_mocha(),
            "catppuccin-latte" => Self::catppuccin_latte(),
            "tokyo-night" | "tokyonight" => Self::tokyo_night(),
            "tokyo-day" => Self::tokyo_day(),
            "nord" => Self::nord(),
            "gruvbox" => Self::gruvbox(),
            "gruvbox-light" => Self::gruvbox_light(),
            "solarized-dark" => Self::solarized_dark(),
            "solarized-light" => Self::solarized_light(),
            "monokai" => Self::monokai(),
            "one-dark" => Self::one_dark(),
            "one-light" => Self::one_light(),
            "everforest-dark" => Self::everforest_dark(),
            "everforest-light" => Self::everforest_light(),
            "rose-pine" => Self::rose_pine(),
            "rose-pine-dawn" => Self::rose_pine_dawn(),
            "material-dark" => Self::material_dark(),
            "material-light" => Self::material_light(),
            "ayu-dark" => Self::ayu_dark(),
            "ayu-light" => Self::ayu_light(),
            "palenight" => Self::palenight(),
            "cobalt2" => Self::cobalt2(),
            "horizon" => Self::horizon(),
            _ => Self::default_theme(),
        }
    }

    /// All theme families (each family groups dark + optional light variants).
    pub fn families() -> &'static [ThemeFamily] {
        &[
            ThemeFamily {
                name: "Default",
                dark_id: "default",
                light_id: None,
            },
            ThemeFamily {
                name: "Dracula",
                dark_id: "dracula",
                light_id: None,
            },
            ThemeFamily {
                name: "Catppuccin",
                dark_id: "catppuccin-mocha",
                light_id: Some("catppuccin-latte"),
            },
            ThemeFamily {
                name: "Tokyo Night",
                dark_id: "tokyo-night",
                light_id: Some("tokyo-day"),
            },
            ThemeFamily {
                name: "Nord",
                dark_id: "nord",
                light_id: None,
            },
            ThemeFamily {
                name: "Gruvbox",
                dark_id: "gruvbox",
                light_id: Some("gruvbox-light"),
            },
            ThemeFamily {
                name: "Solarized",
                dark_id: "solarized-dark",
                light_id: Some("solarized-light"),
            },
            ThemeFamily {
                name: "Monokai",
                dark_id: "monokai",
                light_id: None,
            },
            ThemeFamily {
                name: "One",
                dark_id: "one-dark",
                light_id: Some("one-light"),
            },
            ThemeFamily {
                name: "Everforest",
                dark_id: "everforest-dark",
                light_id: Some("everforest-light"),
            },
            ThemeFamily {
                name: "Rose Pine",
                dark_id: "rose-pine",
                light_id: Some("rose-pine-dawn"),
            },
            ThemeFamily {
                name: "Material",
                dark_id: "material-dark",
                light_id: Some("material-light"),
            },
            ThemeFamily {
                name: "Ayu",
                dark_id: "ayu-dark",
                light_id: Some("ayu-light"),
            },
            ThemeFamily {
                name: "Palenight",
                dark_id: "palenight",
                light_id: None,
            },
            ThemeFamily {
                name: "Cobalt2",
                dark_id: "cobalt2",
                light_id: None,
            },
            ThemeFamily {
                name: "Horizon",
                dark_id: "horizon",
                light_id: None,
            },
        ]
    }

    /// Return the set of "thinking" verbs for this theme.
    ///
    /// Each theme has its own personality vocabulary that rotates while the
    /// agent is working, similar to Claude Code's "Concocting…", "Brewing…".
    pub fn thinking_verbs(&self) -> &'static [&'static str] {
        // Match on spinner color as a theme fingerprint (avoids storing name).
        match self.spinner {
            // Dracula (pink spinner)
            Color::Rgb(255, 121, 198) => &[
                "Conjuring",
                "Hexing",
                "Casting",
                "Brewing",
                "Enchanting",
                "Summoning",
            ],
            // Catppuccin Mocha (lavender spinner)
            Color::Rgb(180, 190, 254) => &[
                "Purring",
                "Steeping",
                "Noodling",
                "Pondering",
                "Daydreaming",
                "Simmering",
            ],
            // Catppuccin Latte (lavender #7287fd spinner)
            Color::Rgb(114, 135, 253) => &[
                "Sipping", "Blending", "Steeping", "Whipping", "Brewing", "Frothing",
            ],
            // Tokyo Night (magenta spinner)
            Color::Rgb(187, 154, 247) => &[
                "Jacking in",
                "Compiling",
                "Overclocking",
                "Syncing",
                "Executing",
                "Infiltrating",
            ],
            // Tokyo Day (blue spinner)
            Color::Rgb(46, 125, 233) => &[
                "Sightseeing",
                "Wandering",
                "Exploring",
                "Mapping",
                "Illuminating",
                "Discovering",
            ],
            // Nord (frost-light spinner)
            Color::Rgb(143, 188, 187) => &[
                "Crystallizing",
                "Drifting",
                "Sculpting",
                "Mapping",
                "Tracing",
                "Chiseling",
            ],
            // Gruvbox dark (orange spinner)
            Color::Rgb(254, 128, 25) => &[
                "Forging",
                "Concocting",
                "Stoking",
                "Smelting",
                "Hammering",
                "Kindling",
            ],
            // Gruvbox Light (orange #d65d0e spinner)
            Color::Rgb(214, 93, 14) => &[
                "Crafting",
                "Shaping",
                "Burnishing",
                "Carving",
                "Tempering",
                "Polishing",
            ],
            // Solarized Dark (cyan spinner)
            Color::Rgb(42, 161, 152) => &[
                "Observing",
                "Illuminating",
                "Clarifying",
                "Focusing",
                "Resolving",
                "Rendering",
            ],
            // Solarized Light (blue spinner)
            Color::Rgb(38, 139, 210) => &[
                "Brightening",
                "Polishing",
                "Refining",
                "Clarifying",
                "Composing",
                "Articulating",
            ],
            // Monokai (green spinner)
            Color::Rgb(166, 226, 46) => &[
                "Parsing",
                "Lexing",
                "Tokenizing",
                "Compiling",
                "Transpiling",
                "Optimizing",
            ],
            // One Dark (purple spinner)
            Color::Rgb(198, 120, 221) => &[
                "Thinking",
                "Drafting",
                "Revising",
                "Composing",
                "Reviewing",
                "Refining",
            ],
            // One Light (blue spinner)
            Color::Rgb(64, 120, 242) => &[
                "Considering",
                "Outlining",
                "Composing",
                "Polishing",
                "Finalizing",
                "Presenting",
            ],
            // Everforest Dark (green spinner)
            Color::Rgb(167, 192, 128) => &[
                "Growing",
                "Rooting",
                "Branching",
                "Leafing",
                "Blooming",
                "Flourishing",
            ],
            // Everforest Light (green spinner)
            Color::Rgb(141, 161, 1) => &[
                "Sprouting",
                "Tending",
                "Cultivating",
                "Harvesting",
                "Grafting",
                "Ripening",
            ],
            // Rose Pine (iris spinner)
            Color::Rgb(196, 167, 231) => &[
                "Blossoming",
                "Dreaming",
                "Weaving",
                "Flowing",
                "Whispering",
                "Blooming",
            ],
            // Rose Pine Dawn (iris spinner)
            Color::Rgb(144, 122, 169) => &[
                "Awakening",
                "Unfurling",
                "Glowing",
                "Dawning",
                "Flowering",
                "Emerging",
            ],
            // Material Dark (cyan spinner)
            Color::Rgb(128, 203, 196) => &[
                "Building",
                "Designing",
                "Structuring",
                "Layering",
                "Rendering",
                "Composing",
            ],
            // Material Light (blue spinner)
            Color::Rgb(97, 130, 184) => &[
                "Blueprinting",
                "Sketching",
                "Drafting",
                "Prototyping",
                "Finalizing",
                "Deploying",
            ],
            // Ayu Dark (orange spinner)
            Color::Rgb(255, 143, 64) => &[
                "Igniting", "Burning", "Fueling", "Firing", "Blazing", "Glowing",
            ],
            // Ayu Light (orange spinner)
            Color::Rgb(250, 141, 62) => &[
                "Warming",
                "Brightening",
                "Sunning",
                "Radiating",
                "Illuminating",
                "Gleaming",
            ],
            // Palenight (purple spinner)
            Color::Rgb(199, 146, 234) => &[
                "Moonlighting",
                "Stargazing",
                "Drifting",
                "Floating",
                "Wandering",
                "Dreaming",
            ],
            // Cobalt2 (cyan spinner)
            Color::Rgb(158, 255, 255) => &[
                "Scanning", "Probing", "Pinging", "Tracing", "Mapping", "Routing",
            ],
            // Horizon (red spinner)
            Color::Rgb(233, 86, 120) => &[
                "Dusking",
                "Fading",
                "Glimmering",
                "Twilighting",
                "Settling",
                "Merging",
            ],
            // Default (cyan) and fallback
            _ => &[
                "Synthesizing",
                "Analyzing",
                "Reasoning",
                "Computing",
                "Processing",
                "Evaluating",
            ],
        }
    }

    /// List all available theme names (for autocomplete / help).
    pub fn available() -> &'static [&'static str] {
        &[
            "default",
            "dracula",
            "catppuccin-mocha",
            "catppuccin-latte",
            "tokyo-night",
            "tokyo-day",
            "nord",
            "gruvbox",
            "gruvbox-light",
            "solarized-dark",
            "solarized-light",
            "monokai",
            "one-dark",
            "one-light",
            "everforest-dark",
            "everforest-light",
            "rose-pine",
            "rose-pine-dawn",
            "material-dark",
            "material-light",
            "ayu-dark",
            "ayu-light",
            "palenight",
            "cobalt2",
            "horizon",
        ]
    }

    // ── Default (current cyan-based palette) ──

    pub fn default_theme() -> Self {
        let p = ThemePalette {
            bg: Color::Reset,
            surface: Color::Rgb(38, 38, 38),
            fg: Color::White,
            fg_dim: Color::Gray,
            fg_muted: Color::Rgb(128, 128, 128),
            accent: Color::Cyan,
            accent2: Color::Magenta,
            green: Color::Green,
            red: Color::Red,
            yellow: Color::Yellow,
            blue: Color::Blue,
            orange: Color::Yellow,
            is_dark: true,
        };
        Self::from_palette(&p)
    }

    // ── Dracula ──
}

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

    #[test]
    fn test_from_name_default() {
        let t = Theme::from_name("default");
        assert!(matches!(t.accent, Color::Cyan));
    }

    #[test]
    fn test_from_name_unknown_falls_back() {
        let t = Theme::from_name("nonexistent");
        assert!(matches!(t.accent, Color::Cyan)); // default
    }

    #[test]
    fn test_all_themes_construct() {
        for name in Theme::available() {
            let _ = Theme::from_name(name);
        }
    }

    #[test]
    fn test_families_cover_all_ids() {
        let available: std::collections::HashSet<&str> =
            Theme::available().iter().copied().collect();
        for family in Theme::families() {
            assert!(
                available.contains(family.dark_id),
                "dark_id '{}' not in available()",
                family.dark_id
            );
            if let Some(light_id) = family.light_id {
                assert!(
                    available.contains(light_id),
                    "light_id '{}' not in available()",
                    light_id
                );
            }
        }
    }

    #[test]
    fn test_thinking_verbs_all_themes() {
        for name in Theme::available() {
            let t = Theme::from_name(name);
            let verbs = t.thinking_verbs();
            assert!(!verbs.is_empty(), "no verbs for theme '{name}'");
        }
    }
}