Skip to main content

Crate louie

Crate louie 

Source
Expand description

§Louie — An Agentic-First TUI Framework

Louie is a terminal user interface framework built from the ground up for AI agent discoverability. Every widget, layout, and interaction carries structured metadata that agents can introspect at runtime, enabling programmatic discovery, inspection, and control of any TUI application.

§Architecture

┌─────────────────────────────────────────────────────────┐
│  Agent (AI)              Human (keyboard/mouse)         │
│       │                        │                        │
│       ▼                        ▼                        │
│  ┌─────────┐            ┌───────────┐                   │
│  │  agent   │            │   event    │                  │
│  │ protocol │            │  system    │                  │
│  └────┬─────┘            └─────┬─────┘                  │
│       └──────────┬─────────────┘                        │
│                  ▼                                      │
│            ┌──────────┐                                 │
│            │ runtime  │  Elm Architecture                │
│            │ (Model → │  update → Command → view)       │
│            └────┬─────┘                                 │
│                 ▼                                       │
│  ┌──────────────────────────────┐                       │
│  │ widget layer + ontology      │                       │
│  │ (every widget is             │                       │
│  │  Discoverable + has schema)  │                       │
│  └────────────┬─────────────────┘                       │
│               ▼                                         │
│  ┌─────────────────────────┐                            │
│  │ terminal (double-buffer │                            │
│  │  differential render)   │                            │
│  └──────────┬──────────────┘                            │
│             ▼                                           │
│        ┌──────────┐                                     │
│        │ backend  │  crossterm / test                   │
│        └──────────┘                                     │
└─────────────────────────────────────────────────────────┘

§Module Guide

ModulePurpose
corePrimitives — Buffer, Cell, Rect, Style, Text
widgetVisual components — all implement Widget and Discoverable
layoutConstraint-based space allocation (Layout, Constraint)
ontologyAgent discoverability — schemas, capabilities, actions, semantic roles
agentJSON Lines RPC protocol for AI agents to drive apps headlessly
runtimeElm architecture event loop — Model, Command, Program
eventKeyboard, mouse, resize, paste, focus, and tick events
terminalDouble-buffered differential rendering via Frame
backendBackend trait + crossterm and test implementations
animationTweens, springs, easing functions, and timelines
focusFocus ring for ordered widget navigation
overlayModal overlay stack with focus capture

§Agent Protocol

Louie applications can be controlled entirely by AI agents via the agent module’s JSON Lines protocol over stdin/stdout:

Agent → stdin:  {"id":"1","request":{"type":"ping"}}
App   → stdout: {"success":true,"id":"1","data":{"status":"pong"}}

Agent → stdin:  {"request":{"type":"query_ontology"}}
App   → stdout: {"success":true,"data":{...widget catalog...}}

Agent → stdin:  {"request":{"type":"execute_action","agent_id":"editor-1","action":"insert_text","params":{"text":"hello"}}}
App   → stdout: {"success":true}

See agent::protocol for the full message types and the agent::rpc module for the transport implementation.

§Feature Flags

FlagDefaultDescription
crosstermyesCrossterm terminal backend (disable for headless/agent-only)
binnoEnables louie-server and louie-demo binaries (pulls in tracing)

§Quick Start

use louie::prelude::*;

struct App { count: i32 }

#[derive(Debug)]
enum Msg { Increment, Decrement, Quit }

impl Model for App {
    type Msg = Msg;

    fn update(&mut self, msg: Msg) -> Command<Msg> {
        match msg {
            Msg::Increment => self.count += 1,
            Msg::Decrement => self.count -= 1,
            Msg::Quit => return Command::Quit,
        }
        Command::None
    }

    fn view(&self, frame: &mut Frame) {
        let area = frame.area();
        let text = Text::from(format!("Count: {}", self.count));
        frame.render_widget(Paragraph::new(text), area);
    }

    fn handle_event(&self, event: Event) -> Option<Msg> {
        None
    }
}

Modules§

agent
Agent protocol and integration layer.
animation
Animation engine with tweens, springs, easing functions, and timelines.
backend
Terminal backend abstractions.
core
Core primitives for terminal rendering.
error
Error types for the Louie framework.
event
Event system with keyboard, mouse, and resize events.
focus
Focus management system.
layout
Layout engine with constraint-based space allocation.
ontology
Ontology — Agent Discoverability System
overlay
Overlay / modal system.
prelude
Prelude: import everything you need for a typical louie application.
runtime
Elm-architecture runtime for louie applications.
terminal
Terminal management: double-buffered rendering with Frame API.
theme
Theming system with semantic color tokens.
widget
Widget system.