limitless-cli 1.0.0

A beginner-friendly environment diagnostic tool
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
//! "Planetary mode": renames a project's well-known files into sci-fi
//! systems and reports each one's health as mission control would.
//!
//! Every recognized stack has a fixed vocabulary that maps real files to
//! flavour names:
//!
//! | Stack  | File                  | System                    |
//! |--------|-----------------------|---------------------------|
//! | Node   | `package.json`        | ⚙️ Main Engine Core        |
//! | Node   | `.env`                | 🛡️ Shield Generator       |
//! | Node   | `node_modules/`       | 🔧 System Components Bay  |
//! | Node   | `src/`                | 💾 Data Core              |
//! | Node   | `.gitignore`          | 🚫 Lockdown Protocol       |
//! | Node   | `package-lock.json`   | 📋 Manifest Registry       |
//! | Python | `requirements.txt`    | ⚙️ Dependencies Matrix     |
//! | Python | `venv/`               | 🔧 Isolation Pod           |
//! | Python | `.env`                | 🛡️ Credentials Vault      |
//! | Python | `setup.py`            | 📋 Build Sequence         |
//! | Python | `main.py`             | 💾 Mission Core           |
//! | Rust   | `Cargo.toml`          | ⚙️ Build Configuration    |
//! | Rust   | `src/`                | 💾 Source Matrix          |
//! | Rust   | `Cargo.lock`          | 📋 Build Seal             |
//! | Rust   | `target/`             | 🔧 Artifact Chamber        |
//!
//! A diagnostic is attributed to a system when its check name or message
//! mentions the corresponding file, and every system's status uses the
//! theatrical vocabulary `OPERATIONAL` / `MINOR ALERT` / `OFFLINE`.
//!
//! ```
//! use limitless_cli::models::{CheckStatus, DiagnosticResult};
//! use limitless_cli::modules::planetary::render_planetary_diagnostics_plain;
//!
//! let results = vec![
//!     DiagnosticResult::new("Dependencies", CheckStatus::Fail, "node_modules/ is missing")
//!         .with_remediation("Run npm install"),
//!     DiagnosticResult::new("Env Audit", CheckStatus::Pass, ".env present"),
//! ];
//! let report = render_planetary_diagnostics_plain(&results);
//! assert!(report.contains("PLANETARY MODE"));
//! assert!(report.contains("Mission Health:"));
//! assert!(!report.contains('\x1b'));
//! ```

use colored::Colorize;
use std::collections::HashMap;

use crate::models::{CheckStatus, DiagnosticResult, HealthScore, HealthStatus, ProjectStack};
use crate::modules::stack_detector::detect_stack;

/// Overall width of the planetary report box, measured in characters.
///
/// ```
/// use limitless_cli::modules::planetary::PLANETARY_WIDTH;
/// assert_eq!(PLANETARY_WIDTH, 60);
/// ```
pub const PLANETARY_WIDTH: usize = 60;

/// Inner text width between the two vertical frame bars.
const INNER_WIDTH: usize = PLANETARY_WIDTH - 4;

/// Cells in the mission health bar, mirroring `tui::HEALTH_BAR_CELLS`.
const HEALTH_CELLS: usize = 20;

/// Ordered Node.js vocabulary: `(file, system name)`.
const NODE_SYSTEMS: &[(&str, &str)] = &[
    ("package.json", "⚙️ Main Engine Core"),
    (".env", "🛡️ Shield Generator"),
    ("node_modules/", "🔧 System Components Bay"),
    ("src/", "💾 Data Core"),
    (".gitignore", "🚫 Lockdown Protocol"),
    ("package-lock.json", "📋 Manifest Registry"),
];

/// Ordered Python vocabulary: `(file, system name)`.
const PYTHON_SYSTEMS: &[(&str, &str)] = &[
    ("requirements.txt", "⚙️ Dependencies Matrix"),
    ("venv/", "🔧 Isolation Pod"),
    (".env", "🛡️ Credentials Vault"),
    ("setup.py", "📋 Build Sequence"),
    ("main.py", "💾 Mission Core"),
];

/// Ordered Rust vocabulary: `(file, system name)`.
const RUST_SYSTEMS: &[(&str, &str)] = &[
    ("Cargo.toml", "⚙️ Build Configuration"),
    ("src/", "💾 Source Matrix"),
    ("Cargo.lock", "📋 Build Seal"),
    ("target/", "🔧 Artifact Chamber"),
];

/// Returns the ordered `(file, system name)` vocabulary for `stack`.
fn stack_systems(stack: &ProjectStack) -> &'static [(&'static str, &'static str)] {
    match stack {
        ProjectStack::Node { .. } => NODE_SYSTEMS,
        ProjectStack::Python { .. } => PYTHON_SYSTEMS,
        ProjectStack::Rust { .. } => RUST_SYSTEMS,
        ProjectStack::Go { .. } | ProjectStack::Java { .. } | ProjectStack::Docker | ProjectStack::Unknown => &[],
    }
}

/// Builds the file → sci-fi system dictionary for a project stack.
///
/// ```
/// use std::collections::HashMap;
/// use limitless_cli::models::ProjectStack;
/// use limitless_cli::modules::planetary::get_planetary_mapping;
///
/// let map = get_planetary_mapping(&ProjectStack::Node {
///     version: "22.9.0".into(),
///     package_manager: "npm".into(),
/// });
/// assert_eq!(map.get("package.json").unwrap(), "⚙️ Main Engine Core");
/// assert_eq!(map.get(".env").unwrap(), "🛡️ Shield Generator");
/// ```
pub fn get_planetary_mapping(stack: &ProjectStack) -> HashMap<String, String> {
    stack_systems(stack)
        .iter()
        .map(|(file, name)| ((*file).to_string(), (*name).to_string()))
        .collect()
}

/// The theatrical status label shown for a [`CheckStatus`]:
/// `OPERATIONAL` (pass), `MINOR ALERT` (warn) or `OFFLINE` (fail).
///
/// ```
/// use limitless_cli::models::CheckStatus;
/// use limitless_cli::modules::planetary::theatrical_status;
/// assert_eq!(theatrical_status(CheckStatus::Pass), "OPERATIONAL");
/// assert_eq!(theatrical_status(CheckStatus::Warn), "MINOR ALERT");
/// assert_eq!(theatrical_status(CheckStatus::Fail), "OFFLINE");
/// ```
pub fn theatrical_status(status: CheckStatus) -> &'static str {
    match status {
        CheckStatus::Pass => "OPERATIONAL",
        CheckStatus::Warn => "MINOR ALERT",
        CheckStatus::Fail => "OFFLINE",
    }
}

/// The console marker for a [`CheckStatus`]: `✓`, `⚠` or `✖`.
pub fn status_icon(status: CheckStatus) -> &'static str {
    match status {
        CheckStatus::Pass => "✓",
        CheckStatus::Warn => "⚠",
        CheckStatus::Fail => "✖",
    }
}

/// Renders the planetary mission-control report for `diagnostics`.
///
/// The stack is detected from the current directory, files are looked up in
/// the mapping dictionary, and the health bar is recomputed from the results
/// via [`HealthScore::from_results`].
pub fn render_planetary_diagnostics(diagnostics: &[DiagnosticResult]) -> String {
    let stack = detect_stack(".");
    let mapping = get_planetary_mapping(&stack);
    render_planetary_inner(stack_systems(&stack), &mapping, diagnostics, true)
}

/// ANSI-free twin of [`render_planetary_diagnostics`], handy for logs/tests.
pub fn render_planetary_diagnostics_plain(diagnostics: &[DiagnosticResult]) -> String {
    let stack = detect_stack(".");
    let mapping = get_planetary_mapping(&stack);
    render_planetary_inner(stack_systems(&stack), &mapping, diagnostics, false)
}

/// Deep-scan entry point: builds a fresh snapshot and prints the report.
pub fn planetary_scan() {
    let state = crate::modules::diagnostics::build_snapshot(".");
    print!("{}", render_planetary_diagnostics(&state.diagnostics));
}

// ---------------------------------------------------------------------------
// Rendering
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum RowStyle {
    Border,
    Title,
    Plain,
    Healthy,
    Pass,
    Warn,
    Fail,
}

fn render_planetary_inner(
    systems: &[(&str, &str)],
    mapping: &HashMap<String, String>,
    diagnostics: &[DiagnosticResult],
    colored: bool,
) -> String {
    let mut rows = vec![
        (RowStyle::Border, border_line(true)),
        (
            RowStyle::Title,
            box_row("🌌 PLANETARY MODE — MISSION CONTROL REPORT"),
        ),
        (RowStyle::Border, separator_line()),
        (RowStyle::Plain, box_row("")),
    ];

    for (file, fallback) in systems {
        let hits: Vec<&DiagnosticResult> = diagnostics
            .iter()
            .filter(|d| diagnostic_refs(d, file))
            .collect();
        if hits.is_empty() {
            continue;
        }

        let name = mapping.get(*file).map(String::as_str).unwrap_or(fallback);
        let worst = hits
            .iter()
            .map(|d| d.status)
            .max_by_key(status_rank)
            .unwrap();
        let style = style_for(worst);

        rows.push((style, box_row(&format!("{name} ({file})"))));
        for d in &hits {
            rows.push((
                style_for(d.status),
                box_row(&format!(
                    "    [{}] Status: {}",
                    status_icon(d.status),
                    theatrical_status(d.status)
                )),
            ));
            if d.status != CheckStatus::Pass {
                if let Some(remediation) = &d.remediation {
                    rows.extend(
                        action_rows(remediation)
                            .into_iter()
                            .map(|row| (RowStyle::Plain, row)),
                    );
                }
            }
        }
        rows.push((RowStyle::Plain, box_row("")));
    }

    let score = HealthScore::from_results(diagnostics);
    let health_style = match score.overall_status {
        HealthStatus::Healthy => RowStyle::Healthy,
        HealthStatus::Caution => RowStyle::Warn,
        HealthStatus::Critical => RowStyle::Fail,
    };
    rows.push((
        health_style,
        box_row(&format!(
            "Mission Health: {}% [{}]",
            score.percentage,
            health_bar(score.percentage)
        )),
    ));
    rows.push((health_style, box_row("🚀 Ready for deployment? Y/n")));
    rows.push((RowStyle::Border, border_line(false)));

    let mut out = String::new();
    for (style, row) in rows {
        out.push_str(&paint(row, style, colored));
        out.push('\n');
    }
    out
}

/// Whether a diagnostic references `file` in its check name or message.
/// Directory keys match both the slashed and bare form (`node_modules/` and
/// `node_modules`).
fn diagnostic_refs(diagnostic: &DiagnosticResult, file: &str) -> bool {
    let combined = format!("{} {}", diagnostic.check_name, diagnostic.message);
    file_tokens(file).iter().any(|token| combined.contains(token))
}

fn file_tokens(file: &str) -> Vec<&str> {
    match file.strip_suffix('/') {
        Some(bare) => vec![file, bare],
        None => vec![file],
    }
}

fn status_rank(status: &CheckStatus) -> u8 {
    match status {
        CheckStatus::Pass => 0,
        CheckStatus::Warn => 1,
        CheckStatus::Fail => 2,
    }
}

fn style_for(status: CheckStatus) -> RowStyle {
    match status {
        CheckStatus::Pass => RowStyle::Pass,
        CheckStatus::Warn => RowStyle::Warn,
        CheckStatus::Fail => RowStyle::Fail,
    }
}

/// Recomputes the mission's health bar from a percentage, filling the same
/// 20-cell bar used elsewhere in the CLI.
fn health_bar(percentage: u32) -> String {
    let filled = ((percentage as f64 / 100.0) * HEALTH_CELLS as f64).round() as usize;
    let filled = filled.min(HEALTH_CELLS);
    format!("{}{}", "█".repeat(filled), "░".repeat(HEALTH_CELLS - filled))
}

/// Indented `→ …` remediation rows, word-wrapped at the inner width.
fn action_rows(remediation: &str) -> Vec<String> {
    wrap(remediation, INNER_WIDTH - 10)
        .into_iter()
        .enumerate()
        .map(|(i, line)| {
            if i == 0 {
                box_row(&format!("    → {line}"))
            } else {
                box_row(&format!("      {line}"))
            }
        })
        .collect()
}

fn paint(row: String, style: RowStyle, colored: bool) -> String {
    if !colored {
        return row;
    }
    match style {
        RowStyle::Plain => row.normal().to_string(),
        RowStyle::Border | RowStyle::Title => row.cyan().to_string(),
        RowStyle::Healthy => row.green().bold().to_string(),
        RowStyle::Pass => row.green().to_string(),
        RowStyle::Warn => row.yellow().to_string(),
        RowStyle::Fail => row.red().to_string(),
    }
}

fn border_line(top: bool) -> String {
    let (left, right) = if top { ('┌', '┐') } else { ('└', '┘') };
    format!("{left}{}{right}", "─".repeat(PLANETARY_WIDTH - 2))
}

fn separator_line() -> String {
    format!("├{}┤", "─".repeat(PLANETARY_WIDTH - 2))
}

/// A `│ content padded │` row exactly [`PLANETARY_WIDTH`] characters wide.
fn box_row(content: &str) -> String {
    format!("│ {} │", pad(content))
}

fn pad(content: &str) -> String {
    let used = content.chars().count();
    format!("{content}{}", " ".repeat(INNER_WIDTH.saturating_sub(used)))
}

/// Word-wraps `text` so every line is at most `width` chars, hard-splitting
/// overlong words and collapsing runs of spaces.
fn wrap(text: &str, width: usize) -> Vec<String> {
    if text.is_empty() || width == 0 {
        return vec![String::new()];
    }

    let mut lines = Vec::new();
    let mut current = String::new();

    for word in text.split(' ') {
        let word_len = word.chars().count();
        if word_len == 0 {
            continue;
        }
        if word_len > width {
            if !current.is_empty() {
                lines.push(std::mem::take(&mut current));
            }
            let mut chunk = String::new();
            for ch in word.chars() {
                if chunk.chars().count() == width {
                    lines.push(std::mem::take(&mut chunk));
                }
                chunk.push(ch);
            }
            current = chunk;
        } else if current.is_empty() {
            current.push_str(word);
        } else if current.chars().count() + 1 + word_len <= width {
            current.push(' ');
            current.push_str(word);
        } else {
            lines.push(std::mem::take(&mut current));
            current.push_str(word);
        }
    }

    if !current.is_empty() {
        lines.push(current);
    }
    if lines.is_empty() {
        lines.push(String::new());
    }
    lines
}

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

    fn node_stack() -> ProjectStack {
        ProjectStack::Node {
            version: "22.9.0".into(),
            package_manager: "npm".into(),
        }
    }

    fn render_for(
        stack: &ProjectStack,
        diagnostics: &[DiagnosticResult],
    ) -> String {
        let mapping = get_planetary_mapping(stack);
        render_planetary_inner(stack_systems(stack), &mapping, diagnostics, false)
    }

    #[test]
    fn maps_every_common_node_file() {
        let map = get_planetary_mapping(&node_stack());
        assert_eq!(map.get("package.json").unwrap(), "⚙️ Main Engine Core");
        assert_eq!(map.get(".env").unwrap(), "🛡️ Shield Generator");
        assert_eq!(map.get("node_modules/").unwrap(), "🔧 System Components Bay");
        assert_eq!(map.get("src/").unwrap(), "💾 Data Core");
        assert_eq!(map.get(".gitignore").unwrap(), "🚫 Lockdown Protocol");
        assert_eq!(
            map.get("package-lock.json").unwrap(),
            "📋 Manifest Registry"
        );
        assert_eq!(map.len(), 6);
    }

    #[test]
    fn maps_every_common_python_file() {
        let map = get_planetary_mapping(&ProjectStack::Python {
            version: "3.12".into(),
        });
        assert_eq!(
            map.get("requirements.txt").unwrap(),
            "⚙️ Dependencies Matrix"
        );
        assert_eq!(map.get("venv/").unwrap(), "🔧 Isolation Pod");
        assert_eq!(map.get(".env").unwrap(), "🛡️ Credentials Vault");
        assert_eq!(map.get("setup.py").unwrap(), "📋 Build Sequence");
        assert_eq!(map.get("main.py").unwrap(), "💾 Mission Core");
        assert_eq!(map.len(), 5);
    }

    #[test]
    fn maps_every_common_rust_file() {
        let map = get_planetary_mapping(&ProjectStack::Rust {
            version: "1.98.0".into(),
        });
        assert_eq!(map.get("Cargo.toml").unwrap(), "⚙️ Build Configuration");
        assert_eq!(map.get("src/").unwrap(), "💾 Source Matrix");
        assert_eq!(map.get("Cargo.lock").unwrap(), "📋 Build Seal");
        assert_eq!(map.get("target/").unwrap(), "🔧 Artifact Chamber");
        assert_eq!(map.len(), 4);
    }

    #[test]
    fn unmapped_stacks_have_empty_dictionary() {
        assert!(get_planetary_mapping(&ProjectStack::Docker).is_empty());
        assert!(get_planetary_mapping(&ProjectStack::Unknown).is_empty());
    }

    #[test]
    fn theatrical_labels_map_to_check_status() {
        assert_eq!(theatrical_status(CheckStatus::Pass), "OPERATIONAL");
        assert_eq!(theatrical_status(CheckStatus::Warn), "MINOR ALERT");
        assert_eq!(theatrical_status(CheckStatus::Fail), "OFFLINE");
        assert_eq!(status_icon(CheckStatus::Pass), "✓");
        assert_eq!(status_icon(CheckStatus::Warn), "⚠");
        assert_eq!(status_icon(CheckStatus::Fail), "✖");
    }

    #[test]
    fn report_attributes_diagnostics_to_the_right_systems() {
        let diagnostics = vec![
            DiagnosticResult::new("Dependencies", CheckStatus::Fail, "node_modules/ is missing")
                .with_remediation("Run npm install"),
            DiagnosticResult::new(
                "Dependency audit",
                CheckStatus::Warn,
                "package.json pins an outdated version",
            ),
        ];
        let report = render_for(&node_stack(), &diagnostics);

        assert!(report.contains("🔧 System Components Bay (node_modules/)"));
        assert!(report.contains("[✖] Status: OFFLINE"));
        assert!(report.contains("→ Run npm install"));
        assert!(report.contains("⚙️ Main Engine Core (package.json)"));
        assert!(report.contains("[⚠] Status: MINOR ALERT"));
        assert!(report.contains("Mission Health: 0%"));
    }

    #[test]
    fn passing_systems_report_operational() {
        let diagnostics = vec![DiagnosticResult::new(
            "Dependencies",
            CheckStatus::Pass,
            "node_modules present — 42 deps resolved",
        )];
        let report = render_for(&node_stack(), &diagnostics);

        assert!(report.contains("🔧 System Components Bay (node_modules/)"));
        assert!(report.contains("[✓] Status: OPERATIONAL"));
        assert!(report.contains("Mission Health: 100%"));
    }

    #[test]
    fn passes_no_remediation_for_healthy_system() {
        let diagnostics = vec![DiagnosticResult::new(
            "Env Audit",
            CheckStatus::Pass,
            ".env present",
        )
        .with_remediation("Nothing to do")];
        let report = render_for(&node_stack(), &diagnostics);

        assert!(report.contains("[✓] Status: OPERATIONAL"));
        assert!(!report.contains("→"));
    }

    #[test]
    fn health_bar_is_recomputed_from_results() {
        let diagnostics = vec![
            DiagnosticResult::new("Env Audit", CheckStatus::Pass, ".env present"),
            DiagnosticResult::new("Port Scan", CheckStatus::Fail, "8080 blocked"),
        ];
        let report = render_for(&node_stack(), &diagnostics);

        assert!(report.contains("Mission Health: 50%"));
        assert!(report.contains("[██████████░░░░░░░░░░]"));
    }

    #[test]
    fn ignores_diagnostics_without_a_mapped_file() {
        let diagnostics = vec![DiagnosticResult::new(
            "Port Scan",
            CheckStatus::Warn,
            "MongoDB occupies port 27017",
        )];
        let report = render_for(&node_stack(), &diagnostics);

        assert!(!report.contains("Main Engine Core"));
        assert!(!report.contains("Shield Generator"));
        assert!(report.contains("Mission Health:"));
    }

    #[test]
    fn matches_directory_files_with_and_without_slash() {
        assert!(diagnostic_refs(
            &DiagnosticResult::new("Dependencies", CheckStatus::Fail, "node_modules missing"),
            "node_modules/"
        ));
        assert!(diagnostic_refs(
            &DiagnosticResult::new("Dependencies", CheckStatus::Fail, "node_modules/ missing"),
            "node_modules/"
        ));
        assert!(!diagnostic_refs(
            &DiagnosticResult::new("Port Scan", CheckStatus::Pass, "ports all free"),
            "node_modules/"
        ));
    }

    #[test]
    fn every_box_line_is_exactly_report_width() {
        let diagnostics = vec![
            DiagnosticResult::new("Dependencies", CheckStatus::Fail, "Cargo.lock is missing")
                .with_remediation("Run `cargo build` once to generate it"),
            DiagnosticResult::new("Env Audit", CheckStatus::Pass, "no .env needed"),
        ];
        let report = render_for(
            &ProjectStack::Rust {
                version: "1.98.0".into(),
            },
            &diagnostics,
        );

        for line in report.lines() {
            assert_eq!(
                line.chars().count(),
                PLANETARY_WIDTH,
                "off-width row: {line:?}"
            );
        }
    }

    #[test]
    fn plain_variant_never_emits_ansi() {
        let diagnostics = vec![DiagnosticResult::new(
            "Env Audit",
            CheckStatus::Warn,
            ".env file missing",
        )];
        let report = render_planetary_diagnostics_plain(&diagnostics);
        assert!(!report.contains('\u{1b}'));
        assert!(report.contains("Mission Health:"));
    }

    #[test]
    fn colored_variant_wraps_in_mission_control_box() {
        let diagnostics = vec![DiagnosticResult::new(
            "Env Audit",
            CheckStatus::Fail,
            ".env file missing! Found .env.example template.",
        )];
        let report = render_planetary_diagnostics(&diagnostics);
        assert!(report.contains("🌌 PLANETARY MODE — MISSION CONTROL REPORT"));
        assert!(report.contains("🚀 Ready for deployment? Y/n"));
    }
}