Architecture
Architectureπ
LocalGPT is one Cargo workspace: the world apps (the desktop app, Gen, Document, Verse, previs), the world-format crates they all share, and the CLI. Document and Verse used to be repositories of their own and were folded in so the format could not drift between apps; the format itself then moved out to the Open World Format, whose Rust reference this workspace consumes as the openworldformat crate.
Nothing in the workspace runs a model as an agent, or holds a key: the coding agents that build worlds run outside, in terminals and MCP clients, and reach a world through its API.
Workspace Structureπ
crates/
βββ cli/ # localgpt β `localgpt world`, `localgpt world mcp` (the shim), `localgpt previs`, `localgpt audio`, and `localgpt gen` (hands off to the app)
βββ gen/ # localgpt-gen β the world builder (Bevy): its tools over MCP, the relay, the live canvas, sessions, headless
βββ app/ # localgpt-app β the one desktop app: Gen's viewport in native panels, terminals for the agents
βββ doc/ # localgpt-doc β a Markdown file as a walkable world (pure lib + Bevy bin)
βββ verse/ # localgpt-verse β a 3D world for every song (lib + Bevy bin)
βββ previs/ # localgpt-previs β screenplay β per-scene .world with set/cast/coverage, a board, a shot list (lib)
βββ previs-web/ # localgpt-previs-web β previs's draft as WASM, for the localgpt.md page
βββ world-types/ # localgpt-world-types β the world data model (serde only; the format's types re-exported)
βββ world-bevy/ # localgpt-world-bevy β the one Bevy mapping of the format (Gen, Document, Verse, the app)
βββ world-audio/ # localgpt-world-audio β the one mapping of the format's audio (kira + FunDSP)
βββ world-export/ # localgpt-world-export β the three.js viewer and HTML export, no Bevy
βββ world-sync/ # localgpt-world-sync β collaborative rooms: shared document, ops, wire protocol, authority
βββ world-editor/ # localgpt-world-editor β the non-linear editing model: tips, forks, folds, deltas
βββ world-agent/ # localgpt-world-agent β the live authority, packages, the headless commands, the lint and the phrase resolver, the MCP servers, the shared paths
βββ relay/ # localgpt-relay β internet reach for collaborative rooms
apps/
βββ app-desktop/ # the LocalGPT.app bundler (Developer ID + notarization when given)
website*/ # one Cloudflare Worker each: localgpt.app (this site), gen., verse., localgpt.md, localgpt.world
xtask/ # cargo xtask fetch-assets β the one download every app sharesDependency Graphπ
ββββββββββββββββββββ
β world-types β (serde only; the openworldformat crate re-exported)
ββββββββββ¬ββββββββββ
ββββββββββββ¬βββββββββΌβββββββββββ¬βββββββββββββββ
βΌ βΌ βΌ βΌ βΌ
world-bevy world-audio world-export world-sync world-editor
(Bevy) (kira) (three.js) β β
β β βΌ β
β β world-agent βββββββ
β β (the authority, the MCP server)
β β β β
βΌ βΌ βΌ βΌ
gen ββββββββββββββββββββββββΊ app cli (localgpt)
β² β²
previs (deterministic) md, verse (as libraries)
previs-web is previs as WASM; relay stands alone.
Crate Summaryπ
| Crate | Type | Purpose |
|---|---|---|
localgpt | bin | localgpt world, localgpt world mcp, and localgpt previs |
localgpt-gen | lib+bin | The world builder: Bevy viewport, 88 tools served over MCP (stdio, the relay, HTTP), headless, sessions, the live canvas |
localgpt-app | bin | The one desktop app, assembled from the gen library with Document and Verse as libraries; native panels around the viewport (egui on eframe, the world drawn by Bevy into one of them), with terminals in them (not published) |
localgpt-doc | lib+bin | Markdown β sections β a world; the pure library is what the app compiles documents with |
localgpt-verse | lib+bin | Song analysis β mood β a furnished, performing world; song_world is what the app calls |
localgpt-previs | lib | Screenplay β per-scene .world, board and shot list; deterministic, no model, no network |
localgpt-previs-web | lib | The same draft as WASM for localgpt.md (not published) |
localgpt-world-types | lib | The data model: the formatβs types re-exported, plus NPCs, behavior libraries, regions, sync drift. schema writes world.schema.json |
localgpt-world-bevy | lib | The only place a shape, material, light or environment becomes Bevy components |
localgpt-world-audio | lib | One kira AudioManager; FunDSP graphs as sources; ambience, spatial emitters, soundtracks |
localgpt-world-export | lib | The three.js viewer (vendored from the formatβs npm package) and generate_html; no Bevy |
localgpt-world-sync | lib | Shared world document, validated EditOps, the wire protocol, the room authority; no Bevy, no I/O |
localgpt-world-editor | lib | History as a tree: a branch index, a fold cache fast enough to scrub, deltas between tips |
localgpt-world-agent | lib | LiveWorld (the live authority), packages, the headless commands behind localgpt world, the Tool trait and MCP servers (mcp, mcp-http), the agentβs environment, the shared directories |
localgpt-relay | bin | Forwards WebSocket frames between a host and its guests by room code; never holds world state (not published) |
The world format is sharedπ
Every app reads and writes one format. localgpt-world-types is the source: the Open World Formatβs document, session and state types come from the openworldformat crate and are re-exported unchanged, and the crate adds LocalGPTβs own surface on top. localgpt-world-bevy is the only place those types become Bevy components, so Gen, Document, Verse and the app render identically; localgpt-world-audio is the one mapping of the formatβs audio; localgpt-world-export holds the only web renderer, the same three.js viewer localgpt.world serves and every exported HTML page embeds.
Reference scenes live in crates/world-types/conformance/ and are rendered by both renderers; the web viewerβs headless render check runs in CI. The rule inside the workspace: add fields to world-types, never a parallel format β proposals that change what the format means belong in the formatβs own repository.
A .world package is a folder: manifest.json (the head), ops.jsonl (the log), assets/ (content-addressed), AGENTS.md. LiveWorld in world-agent is the one authority that commits to it β from the window (live canvas) or from localgpt world β and world-editor is the view that follows: tips, forks, folds and deltas, which the history panel draws.
The agents are outsideπ
An agent never runs inside a LocalGPT process. Three doors lead in, all to the same authority:
| Door | What it is | Who uses it |
|---|---|---|
| The folder | AGENTS.md and .live/endpoint.json in a live package; the appβs terminals open there with $LOCALGPT_WORLD_DIR set | a coding agent in a terminal, with localgpt world |
| The shim | localgpt world mcp: eleven tools over stdio against the open worldβs API | any MCP client |
| Genβs tools | localgpt-gen mcp-server (the agentβs own window) or --mcp-relay with mcp-server --connect (the window you are looking at): the 88 gen_* tools | MCP clients and editors, until they move behind the shim |
The Tool trait and the MCP server they share live in world-agent::mcp. Every change lands as one log entry, attributed to whoever sent it.
Binariesπ
localgpt (CLI)π
| Command | Purpose |
|---|---|
world | a .world packageβs command line: init, submit, undo, redo, log, tips, show, get, verify, screenshot, selection, goto, proposals, history, and mcp β the open canvasβs tools over stdio |
previs | script to board, deterministic: Fountain, Final Draft .fdx, PDF or Markdown pages in; per scene a .world with set, cast and coverage, plus board.html and shotlist.csv. The same draft function runs as WASM on localgpt.md. See Previs |
completion | shell completion scripts |
localgpt-genπ
The world builder: a Bevy window and 88 gen_* tools; mcp-server (stdio, --mcp-http, --headless, --connect to a running windowβs relay); --mcp-relay; --host/--join/--web/--relay collaborative sessions over world-sync; --live for the live canvas; --replay. See LocalGPT Gen.
localgpt-appπ
The desktop app: Genβs viewport plus --doc, --song and --world, in native panels with the history, the outliner and inspector, the document, the timeline and the terminals. Thin by design β everything heavy comes from the gen library, Documentβs pure library compiles documents, and Verseβs library builds song worlds.
localgpt-relayπ
Internet reach for collaborative rooms: forwards frames between a NATβd host and its guests by room code.
Design Principlesπ
- One format, one mapping each β fields go into
world-types;world-bevy,world-audioandworld-exportare the only places the format becomes pixels or sound. - One authority per world β
LiveWorldcommits; the canvas, the editor model andlocalgpt worldfollow. A direct write tomanifest.jsonis put back. - The agents are outside β no process here runs a model or holds a key, and no agent is known by name: a terminal is a login shell, a client is an MCP client, and the history names whoever commits.
- Feature flags for the heavy tiers β Verseβs ML analysis models, physics and multiplayer are opt-in, and each has a CI job so gated code cannot rot. No crate loads a language model and no tool calls a service.
- Graceful degradation β a missing asset pack leaves primitives; a missing sidecar leaves the rule-derived draft on screen.