diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..389670e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,45 @@ +# Gjallar Agent Instructions + +Gjallar is a framebuffer-native, multi-scale TUI compositor. + +Do not treat this repo as an Odin subfolder, a Nightwing deployment script, a +terminal multiplexer clone, or a dashboard skin. Gjallar owns the product kernel +for weighted pane partitioning, per-pane virtual text grids, font-scale +selection, framebuffer lowering, and future sparse cell/glyph/dirty-rect pipes. + +## Session Bootstrap + +On fresh workspace load, read these before implementation: + +1. `state/gjallar-state.md` +2. `README.md` +3. `docs/architecture.md` + +Then restate the current owner map before making nontrivial changes. + +## Operating Boundary + +- Odin sees: Verse discovery, provider cataloging, schemas, routes, and accepted + provider/proxy surfaces. +- Gjallar shows: overview composition, panel packing, density, text resolution, + framebuffer/cell lowering, and display telemetry. +- Nightwing hosts: the physical machine/body currently running `gjallar.service`. +- Providers speak: each upstream surface owns its own truth. + +If Odin starts deciding where panels go on Nightwing, ownership leaked upward. +If providers start shaping themselves for Nightwing instead of publishing clean +surfaces, ownership leaked downward. + +## Research Habit + +When comparing Gjallar to existing tools, preserve the distinction: + +- TUI frameworks such as Ratatui help build one terminal-grid app. +- Multiplexers such as tmux split one terminal cell grid into panes. +- Notcurses offers terminal planes/piles and rich terminal graphics. +- DirectFB offers framebuffer graphics/windowing substrate. +- Gjallar's gap is multi-resolution text composition: weighted pixel regions, + each with its own virtual grid and font scale, belonging to one coherent + dashboard surface. + +Update `state/gjallar-state.md` when research changes that belief. diff --git a/state/gjallar-state.md b/state/gjallar-state.md new file mode 100644 index 0000000..c12eb4a --- /dev/null +++ b/state/gjallar-state.md @@ -0,0 +1,170 @@ +# Gjallar State + +Last updated: 2026-06-05 + +## Identity + +Gjallar is the horn and the display body: a framebuffer-native, multi-scale TUI +compositor for dense operational surfaces. + +His job is not merely to view Odin. Odin is the first upstream witness, and +Nightwing is the first physical body. The reusable product kernel is the +compositor itself: + +```text +surface sources + -> weighted pane tree + -> per-pane virtual text grids + -> per-pane font and cell resolution + -> framebuffer frames now + -> sparse cell / glyph / dirty-rect pipes later +``` + +## Body + +- Repo: `E:\Projects\Gjallar` +- GitHub: `https://github.com/GameCult/Gjallar` +- Runtime: `src/Gjallar/Gjallar.csproj` +- Current deployment: Nightwing `gjallar.service` +- Current feed: Odin provider catalog at `ws://192.168.1.66:8797/eve/deck` +- Current status path on Nightwing: `/var/log/gjallar.status` + +Observed live status after repo split: + +```json +{ + "schema": "gamecult.gjallar.frame.v1", + "receive": { + "status": "catalog-composed", + "catalogProviders": 4, + "composedProviders": 3 + }, + "scene": { + "panels": 3 + } +} +``` + +## Authority Map + +- Owner: Gjallar owns display composition, pane partitioning, per-pane virtual + grids, font-scale choice, frame/cell lowering, and renderer telemetry. +- Inputs: provider catalogs, provider-owned surface trees, display dimensions, + font assets, runtime flags, and later native CultMesh subscriptions. +- Outputs: `gjallar.overview` composition state, framebuffer frames, sparse + refresh streams, and agent-readable panel captures. +- Derived state: pane weights, pixel rectangles, selected fonts, gutter paths, + dirty rectangles, glyph runs, and compact text projections. +- Forbidden writers: discovery systems must not decide Gjallar layout; providers + must not tune themselves for Nightwing; framebuffer backends must not invent + provider truth. +- Cut line: code that discovers what exists belongs upstream. Code that decides + how a physical or virtual display shows it belongs in Gjallar. + +## Product Thesis + +There is a gap between terminal UI frameworks, terminal multiplexers, +framebuffer graphics libraries, and browser dashboards. + +Gjallar's claim: + +> A modern TUI compositor should be able to divide pixels into weighted regions, +> assign each region its own virtual text grid and resolution, and lower the +> result to human-visible and agent-readable surfaces. + +The grandiose public phrase is allowed: a new paradigm of TUI. Keep it earned. +The implementation must keep moving toward a real compositor model, not just a +pretty Nightwing dashboard. + +## Research Ledger + +### Ratatui + +Ratatui is a strong Rust framework for building TUIs. Its layout model produces +rectangular areas for widgets inside the terminal's grid. This is adjacent but +not the same problem: Ratatui helps one app organize widgets inside one terminal +cell coordinate system; Gjallar wants each pane to become its own virtual grid +and font scale over framebuffer pixels. + +Source: `https://ratatui.rs/concepts/layout/` + +### tmux + +tmux organizes terminal work into sessions, windows, and panes. It is excellent +for splitting and preserving terminal sessions, but the panes share the attached +terminal's cell geometry. Gjallar's difference is per-pane resolution and direct +framebuffer/text-surface composition rather than many shells in one terminal. + +Sources: + +- `https://github.com/tmux/tmux/wiki/Getting-Started` +- `https://documentation.ubuntu.com/server/reference/other-tools/terminal-multiplexers/` + +### Notcurses + +Notcurses has a modern terminal rendering model built around planes, cells, and +piles, plus rich terminal graphics and optional pixel protocols such as Sixel +and Kitty. It is the closest conceptual neighbor for composited terminal +surfaces. Gjallar differs by treating the framebuffer as the primary body and +by making per-pane text resolution part of the compositor contract. + +Sources: + +- `https://notcurses.com/html/classncpp_1_1_pile.html` +- `https://manpages.ubuntu.com/manpages/noble/man3/notcurses.3.html` + +### DirectFB + +DirectFB / DirectFB2 is a lightweight framebuffer graphics/windowing layer with +graphics acceleration, input abstraction, windows, and display layers on top of +Linux framebuffer devices. It is substrate-adjacent, not the product gap: +DirectFB can help draw/window on framebuffer, but Gjallar's special claim is the +multi-resolution text compositor above that substrate. + +Source: `https://directfb1.org/` + +### Linux Framebuffer + +The Linux framebuffer/fbdev path is older and often superseded by DRM in modern +systems, but it remains useful on consoles, older hardware, embedded-ish bodies, +and local appliance displays. Gjallar's current Nightwing deployment uses this +boring durable body: write pixels to `/dev/fb0`. + +Source: `https://en.wikipedia.org/wiki/Linux_framebuffer` + +## Current Implementation Notes + +- `GjallarRenderer` owns catalog reads, provider fetches, frame loop, and + telemetry. +- `BuildGjallarSurface` currently builds the in-memory `gjallar.overview` + surface. +- `AabbPacker` owns weighted panel region packing. +- `FontAtlas.ForTextBox` picks a font per panel based on available pixel area + and text pressure. +- `FrameDocument` draws text, panels, gutters, marquee, and fills. +- `FramebufferDevice` maps or writes the Linux framebuffer. + +This is enough to run, but not enough to be proud forever. The next architectural +cut is to extract explicit model types: + +```text +GjallarOverview +PaneTree +PaneGrid +RenderPlan +FramebufferBackend +SparseCellBackend +AgentTextBackend +``` + +## Next Questions + +- What is the clean `PaneTree` data model? +- How should provider surface hints translate into pane weights without letting + providers own final display layout? +- What is the first sparse refresh contract: dirty rectangles, dirty cells, or + glyph runs? +- How should an agent navigate the same composed model without reading a full + framebuffer dump? +- When should Gjallar publish its own state as CultCache `.cc` instead of only + status JSON?