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 shares

Dependency 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πŸ”—

CrateTypePurpose
localgptbinlocalgpt world, localgpt world mcp, and localgpt previs
localgpt-genlib+binThe world builder: Bevy viewport, 88 tools served over MCP (stdio, the relay, HTTP), headless, sessions, the live canvas
localgpt-appbinThe 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-doclib+binMarkdown β†’ sections β†’ a world; the pure library is what the app compiles documents with
localgpt-verselib+binSong analysis β†’ mood β†’ a furnished, performing world; song_world is what the app calls
localgpt-previslibScreenplay β†’ per-scene .world, board and shot list; deterministic, no model, no network
localgpt-previs-weblibThe same draft as WASM for localgpt.md (not published)
localgpt-world-typeslibThe data model: the format’s types re-exported, plus NPCs, behavior libraries, regions, sync drift. schema writes world.schema.json
localgpt-world-bevylibThe only place a shape, material, light or environment becomes Bevy components
localgpt-world-audiolibOne kira AudioManager; FunDSP graphs as sources; ambience, spatial emitters, soundtracks
localgpt-world-exportlibThe three.js viewer (vendored from the format’s npm package) and generate_html; no Bevy
localgpt-world-synclibShared world document, validated EditOps, the wire protocol, the room authority; no Bevy, no I/O
localgpt-world-editorlibHistory as a tree: a branch index, a fold cache fast enough to scrub, deltas between tips
localgpt-world-agentlibLiveWorld (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-relaybinForwards 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:

DoorWhat it isWho uses it
The folderAGENTS.md and .live/endpoint.json in a live package; the app’s terminals open there with $LOCALGPT_WORLD_DIR seta coding agent in a terminal, with localgpt world
The shimlocalgpt world mcp: eleven tools over stdio against the open world’s APIany MCP client
Gen’s toolslocalgpt-gen mcp-server (the agent’s own window) or --mcp-relay with mcp-server --connect (the window you are looking at): the 88 gen_* toolsMCP 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)πŸ”—

CommandPurpose
worlda .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
previsscript 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
completionshell 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πŸ”—

  1. One format, one mapping each β€” fields go into world-types; world-bevy, world-audio and world-export are the only places the format becomes pixels or sound.
  2. One authority per world β€” LiveWorld commits; the canvas, the editor model and localgpt world follow. A direct write to manifest.json is put back.
  3. 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.
  4. 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.
  5. Graceful degradation β€” a missing asset pack leaves primitives; a missing sidecar leaves the rule-derived draft on screen.