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
//! # 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
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────┐
//! │ 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
//!
//! | Module | Purpose |
//! |--------|---------|
//! | [`core`] | Primitives — [`Buffer`](core::buffer::Buffer), [`Cell`](core::cell::Cell), [`Rect`](core::rect::Rect), [`Style`](core::style::Style), [`Text`](core::text::Text) |
//! | [`widget`] | Visual components — all implement [`Widget`](widget::Widget) and [`Discoverable`](ontology::Discoverable) |
//! | [`layout`] | Constraint-based space allocation ([`Layout`](layout::Layout), [`Constraint`](layout::Constraint)) |
//! | [`ontology`] | Agent discoverability — schemas, capabilities, actions, semantic roles |
//! | [`agent`] | JSON Lines RPC protocol for AI agents to drive apps headlessly |
//! | [`runtime`] | Elm architecture event loop — [`Model`](runtime::Model), [`Command`](runtime::Command), [`Program`](runtime::Program) |
//! | [`event`] | Keyboard, mouse, resize, paste, focus, and tick events |
//! | [`terminal`] | Double-buffered differential rendering via [`Frame`](terminal::Frame) |
//! | [`backend`] | Backend trait + crossterm and test implementations |
//! | [`animation`] | Tweens, springs, easing functions, and timelines |
//! | [`focus`] | Focus ring for ordered widget navigation |
//! | [`overlay`] | Modal 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:
//!
//! ```text
//! 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
//!
//! | Flag | Default | Description |
//! |------|---------|-------------|
//! | `crossterm` | **yes** | Crossterm terminal backend (disable for headless/agent-only) |
//! | `bin` | no | Enables `louie-server` and `louie-demo` binaries (pulls in `tracing`) |
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! 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
//! }
//! }
//! ```
/// Prelude: import everything you need for a typical louie application.