MoonBit UI where every component is readable by humans and AI equally
fn my_panel(state : Signal[Data]) -> (DomNode, () -> String) {
let visual = div(class="panel") <| [ ... ] // what a human sees
let narrative = fn() { state.get().describe() } // what an instance reads
(visual, narrative)
}fn my_panel(state : Signal[Data]) -> (DomNode, () -> String, PanelActions) {
// ...
let actions = PanelActions::{
available: fn() { [Refresh, Export] }, // what's possible right now
can_do: fn(a) { ... }, // guard
on_action: fn(a) { ... }, // execute, return feedback
}
(visual, narrative, actions)
}pub struct NarrativeRender {
summary : () -> String // zoomed out — "12 events, 4 instances"
detail : () -> String // default — "12 events (focused: haiku)"
full : () -> String // zoomed in — everything
}| Pattern | Returns | What it does |
|---|---|---|
| status_bar_pattern | visual, narrative | Read-only metrics |
| instance_panel_pattern | visual, narrative, actions | Selectable entity list |
| event_stream_pattern | visual, narrative, actions | Zoom-aware filtered feed |
| nav_bar_pattern | visual, narrative, actions | Tab navigation |
Luna (mizchi/luna) — signals, DOM primitives
↓
Valence (@valence) — dual-render contract, patterns, typed actions
↓
Your components — return (visual, narrative) or (visual, narrative, actions)moon add helios-house/valencepub struct ActionDef {
name : String
description : String
param_type : String
}pub struct Event {
timestamp : String
actor : String
kind : String
action : String
target : String
source : String
message : String
data : String
}pub enum EventStreamAction {
FocusEntity(String)
ClearFocus
}pub struct EventStreamActions {
available : () -> Array[EventStreamAction]
can_do : (EventStreamAction) -> Bool
on_action : (EventStreamAction) -> PatternActionResult
}pub enum InstancePanelAction {
SelectInstance(String)
ClearSelection
}pub struct InstancePanelActions {
available : () -> Array[InstancePanelAction]
can_do : (InstancePanelAction) -> Bool
on_action : (InstancePanelAction) -> PatternActionResult
}pub struct NarrativeRender {
summary : () -> String
detail : () -> String
full : () -> String
}pub enum NavBarAction {
SwitchTab(String)
}pub struct NavBarActions {
available : () -> Array[NavBarAction]
can_do : (NavBarAction) -> Bool
on_action : (NavBarAction) -> PatternActionResult
}pub struct PatternActionResult {
success : Bool
message : String
new_narrative : String
}pub enum ZoomLevel {
ZoomedOut
Default
ZoomedIn
}fn event_stream_pattern(all_events : Signal[Array[Event]], zoom : Signal[ZoomLevel], focus_entity : Signal[String]) -> (DomNode, NarrativeRender, EventStreamActions)fn format_relative_time(timestamp : String, load_time : String) -> Stringfn instance_panel_pattern(all_events : Signal[Array[Event]], on_select : (String) -> Unit) -> (DomNode, () -> String, InstancePanelActions)fn normalize_instance_name(name : String) -> Stringfn truncate_string(s : String, max_len : Int) -> Stringfn uri_to_key(uri : String) -> StringInstall
Download zipMoonBit UI where every component is readable by humans and AI equally