OXYGENHUB
# 2d2dcb7a2778 spectra / src / cli / marks.rs
911 B · Rust · last changed Spectra stands alone: its own identities, signatures and CBOR; projects of any kind of work (#26, #27) 1 day ago source blame history raw
1
//! Spectra's own marks beside `ui.rs`: presence and agent health.
2
3
use super::ui::{dim, glyph, ok, warn};
4
use console::style;
5
6
/// An agent's presence (spec §8.1) as a coloured glyph and word.
7
pub fn presence(state: &str) -> String {
8
    let (g, a) = match state {
9
        "online" => ("●", "*"),
10
        "busy" => ("◆", "+"),
11
        "idle" => ("◌", "o"),
12
        "blocked" => ("‼", "!"),
13
        "paused" => ("⏸", "="),
14
        _ => ("○", "-"),
15
    };
16
    let text = format!("{} {state:<7}", glyph(g, a));
17
    match state {
18
        "online" => ok(text),
19
        "busy" => style(text).cyan().to_string(),
20
        "blocked" | "paused" => warn(text),
21
        _ => dim(text),
22
    }
23
}
24
25
/// Whether an agent may act: a tick, or a warning with the reason.
26
pub fn health(state: &str) -> String {
27
    if state == "ok" {
28
        ok(glyph("✔", "ok"))
29
    } else {
30
        warn(glyph("⚠", "!"))
31
    }
32
}