scroll # Gem-Colored Terminal Output **Archetype:**fid **Status:** gap **Description:** Rendergem content with palette colors in gaze andother terminal output --- ## Vision WhenPortal displays gem values in the terminal(gaze, search results, Thing inspection), usethe gem swatch colors as background colors.This makes gem types instantly recognizable bycolor, not just name. ## Color Application |Gem | Background | Foreground | ANSI ||-----|------------|------------|------| |onyx | `#1a1a1a` | white |`\x1b[48;2;26;26;26m\x1b[97m` | | sapphire |`#2563eb` | white |`\x1b[48;2;37;99;235m\x1b[97m` | | ruby |`#dc2626` | white |`\x1b[48;2;220;38;38m\x1b[97m` | | emerald |`#059669` | white |`\x1b[48;2;5;150;105m\x1b[97m` | | amethyst |`#7c3aed` | white |`\x1b[48;2;124;58;237m\x1b[97m` | | diamond |`#f8fafc` | black |`\x1b[48;2;248;250;252m\x1b[30m` | | pearl |`#fef3c7` | black |`\x1b[48;2;254;243;199m\x1b[30m` | | obsidian| `#0f0f0f` | white |`\x1b[48;2;15;15;15m\x1b[97m` | | topaz |`#f59e0b` | black |`\x1b[48;2;245;158;11m\x1b[30m` | | citrine |`#eab308` | black |`\x1b[48;2;234;179;8m\x1b[30m` | Reset:`\x1b[0m` ## Implementation ### 1. LoadSwatches at Startup In `forge/gems.rs`, addswatch loading alongside gem definitions:```rust static GEM_SWATCHES:OnceLock<HashMap<String, GemSwatch>> =OnceLock::new(); pub struct GemSwatch { pubhex: String, pub shape: String, pub ansi_bg:String, pub ansi_fg: String, } pub async fnload_gem_swatches(pool: &PgPool) -> Result<(),String> { // Query Things wheresapphire='swatch' and onyx starts with 'gem-'// Parse hex, determine fg (white for dark,black for light) // Build ANSI codes } pub fnget_gem_color(gem_name: &str) ->Option<&'static GemSwatch> {GEM_SWATCHES.get().and_then(|s|s.get(&format!("gem-{}", gem_name))) } ``` ###2. Color Helper Function ```rust pub fncolorize_gem_name(gem_name: &str) -> String {if let Some(swatch) = get_gem_color(gem_name){ format!("{}{} {} {}\x1b[0m", swatch.ansi_bg,swatch.ansi_fg, gem_name, " " // padding ) }else { gem_name.to_string() } } ``` ### 3.Apply in Commands Update gaze output in`commands/mod.rs`: ```rust // Before:lines.push(format!(" {}: {}", gem_name,value)); // After: lines.push(format!(" {}:{}", colorize_gem_name(gem_name), value)); ```### 4. Terminal Capability Check Only use truecolor if terminal supports it: ```rust fnsupports_true_color() -> bool {std::env::var("COLORTERM") .map(|v| v =="truecolor" || v == "24bit") .unwrap_or(false)} ``` Fallback to 256-color or basic ANSI ifnot supported. ## Affected Commands - `/△gem` - gaze by gem value - `/0 <thing>` -Thing inspection - `/xo search` - searchresults with gem highlights - `/1 1` -creation confirmation - Any output showing gemnames or values ## Example Output ``` 💎Things with sapphire=product 1.ceramic-vase-001 ████ onyx████ ceramic-vase-001 ████sapphire ████ product ████ruby ████ {"price": 89.00}████ pearl ████ Hand-thrownstoneware... ████ amethyst████ ["ceramics", "handmade"] ``` ##Gaps - [ ] Add `load_gem_swatches()` tostartup sequence - [ ] Create`colorize_gem_name()` helper - [ ] Update gazeoutput formatting - [ ] Update search resultformatting - [ ] Add terminal capabilitydetection - [ ] Test in various terminals(iTerm2, Terminal.app, VS Code)