Skip to content

The editor

API

conjure_editor is the tool you build games in, and the tool an AI agent drives. Every edit is a command: the Dear ImGui panels, the newline-delimited JSON protocol over TCP or stdio, and the headless --exec command file all send the same entity.create, component.set, prefab.instantiate, play.start requests to one dispatcher, which validates them, records their inverses for undo and emits events. The editor runs on top of the engine's application (📘 API: Engine); headless it runs on the null window, device and audio backend with the script runtime on the null host, so every command works without a GPU or .NET. The editor is three libraries, conjure::editor_core, conjure::editor_kit and conjure::editor_ui, under the conjure_editor executable. Native types live in namespace conjure::editor, the UI in conjure::editor::ui and the widget kit in conjure::editor::kit.

The three libraries

Library Namespace What it holds
conjure::editor_core conjure::editor everything the protocol and headless mode need: the application, the commands, undo, the protocol server, play mode, picking, screenshots, the headless runner, the user settings and themes as data. No public header includes ImGui
conjure::editor_kit conjure::editor::kit the widget kit that every panel, and every module's panel, draws with: tokens, the painter, widgets, containers, popups, icons
conjure::editor_ui conjure::editor::ui the Dear ImGui workspace: the layer, the dockspace, menus and dialogs, the start screen, the panels, the property drawers and the gizmo

The mental model in five sentences

  1. The editor is editor_application: it owns an engine::application, an editor_context (registry, dispatcher, undo stack, selection, play controller, events, camera, console, screenshots) and a protocol_server; run() either exports, executes a command file or loops frames.
  2. A request is {"id", "cmd", "args"}; the dispatcher looks the command up, validates args against its JSON schema, checks the preconditions (REQUIRES_PROJECT, REQUIRES_SCENE, EDITING_ONLY), runs the handler and answers {"id", "ok", "result"} or {"id", "ok": false, "error": {"code", "message"}}.
  3. A mutating command returns its inverse; the undo stack stores it, history.undo dispatches it. Batches and transactions group several commands into one undo entry; play mode freezes the stack and play.stop restores the scene snapshot byte for byte.
  4. Entities cross the protocol as scene guids or hierarchy paths ("Board/Cell_3"), never as ECS ids; component fields as <component>.<field>.<subfield> paths over the reflection description.
  5. Everything is discoverable at run time: editor.schema dumps the catalogue, reflection.components the component types, reflection.asset_types the importers; the committed dump is docs/generated/editor_protocol.json.

Where to go next

Page Read it when you want to...
The AI control protocol drive the editor from a script or an agent: start it, connect, the wire format, the catalogue, events, errors, keeping values from play, the headless --exec runner
Access tokens and the audit log let a program connect, give it full control or inspect-only access, read what clients did; the C++ token helpers and audit_log
Headless mode and the command model embed or extend the editor from C++: editor_application and its startup order, editor_context, the dispatcher and registry, undo, play and play-mode persist, picking, screenshots, the user's settings, module commands and panels; which projects the editor opens (project trust)
The workspace UI the Dear ImGui workspace: the default layout and its file, the menus and dialogs, the start screen, the panels, the Scene, Game and Project settings panels, the inspector's property drawers, the gizmo, persist in the UI, writing a panel
The toolbar and the status bar the two fixed bars around the dockspace, drawn with the widget kit: every control, segment and key
Themes the look of the editor as data: the theme file, its readability rules, the built-in themes, user themes and the editor.theme.* commands
Fonts and code ligatures the editor's fonts, the size of its text and the UI scale, the code font's ligatures and editor.preferences.*
The widget kit draw editor UI the way every panel does: tokens, the painter, widgets, containers, popups, icons, the kit context, and a module's kit panel

Headers

Every public header of the editor, by include path, and the page that covers it.

Header What it holds Page
conjure/editor/editor_application.h, conjure/editor/editor_options.h the process object and the command line Headless mode and the command model
conjure/editor/headless_runner.h --exec: running a command file The AI control protocol
conjure/editor/editor_context.h the editor's service table Headless mode and the command model
conjure/editor/project_trust.h which projects the editor may open: the answers and the trust store Headless mode and the command model
conjure/editor/command_dispatcher.h, conjure/editor/command_registry.h, conjure/editor/editor_command.h, conjure/editor/builtin_commands.h, conjure/editor/schema_validator.h the command model Headless mode and the command model
conjure/editor/undo_stack.h, conjure/editor/selection_set.h, conjure/editor/play_controller.h, conjure/editor/picker.h, conjure/editor/screenshot_service.h, conjure/editor/editor_camera.h, conjure/editor/console_buffer.h the editor services Headless mode and the command model
conjure/editor/persist_list.h, conjure/editor/play_edit_log.h values kept from play, and who changed what during play Headless mode and the command model
conjure/editor/user_settings.h, conjure/editor/editor_ui_host.h the user's own settings (theme, recent projects, UI scale, code ligatures), and what the windowed UI does for core commands Headless mode and the command model
conjure/editor/theme.h, conjure/editor/theme_library.h themes as data: the model, the file and its rules, the built-in and user themes Themes
conjure/editor/entity_ref.h, conjure/editor/reflection_path.h, conjure/editor/event_broadcaster.h addressing and events Headless mode and the command model
conjure/editor/editor_error.h the protocol's error codes The AI control protocol
conjure/editor/command_desc.h, conjure/editor/panel_desc.h, conjure/editor/editor_module_consumer.h what a module adds to the editor Headless mode and the command model
conjure/editor/kit_panel_desc.h the kit records a module adds: panels, icons and property drawers The widget kit
conjure/editor/protocol/protocol_message.h, conjure/editor/protocol/protocol_server.h, conjure/editor/protocol/protocol_transport.h, conjure/editor/protocol/loopback_transport.h, conjure/editor/protocol/line_splitter.h the wire and the server The AI control protocol
conjure/editor/protocol/access_token.h, conjure/editor/protocol/audit_log.h the two tokens and the audit log Access tokens and the audit log
conjure/editor/ui/editor_layer.h, conjure/editor/ui/editor_workspace.h, conjure/editor/ui/editor_panel.h, conjure/editor/ui/editor_icon.h, conjure/editor/ui/start_screen.h, conjure/editor/ui/property_drawer.h, conjure/editor/ui/gizmo_controller.h, conjure/editor/ui/hierarchy_cache.h, conjure/editor/ui/imgui_frame_scope.h the workspace The workspace UI
conjure/editor/ui/panels/ai_session_panel.h, conjure/editor/ui/panels/asset_browser_panel.h, conjure/editor/ui/panels/console_panel.h, conjure/editor/ui/panels/export_dialog.h, conjure/editor/ui/panels/game_panel.h, conjure/editor/ui/panels/hierarchy_panel.h, conjure/editor/ui/panels/history_panel.h, conjure/editor/ui/panels/inspector_panel.h, conjure/editor/ui/panels/persist_panel.h, conjure/editor/ui/panels/profiler_panel.h, conjure/editor/ui/panels/project_settings_panel.h, conjure/editor/ui/panels/viewport_panel.h the built-in panels The workspace UI
conjure/editor/ui/panels/toolbar_panel.h, conjure/editor/ui/status_bar.h the two fixed bars around the dockspace The toolbar and the status bar
conjure/editor/ui/theme_applier.h, conjure/editor/ui/panels/theme_editor_panel.h how the editor shows a theme, and the Themes panel Themes
conjure/editor/kit/kit.h, conjure/editor/kit/catalogue.h, conjure/editor/kit/colour_picker.h, conjure/editor/kit/containers.h, conjure/editor/kit/controls.h, conjure/editor/kit/fields.h, conjure/editor/kit/icons.h, conjure/editor/kit/input.h, conjure/editor/kit/kit_context.h, conjure/editor/kit/layout.h, conjure/editor/kit/paint.h, conjure/editor/kit/popups.h, conjure/editor/kit/record.h, conjure/editor/kit/tokens.h, conjure/editor/kit/views.h, conjure/editor/kit/widget.h the widget kit (kit.h includes the rest) The widget kit
conjure/editor/ui/panels/widget_gallery_panel.h the Widget gallery: every kit widget in every state The widget kit
conjure/editor/log_category.h LOG_EDITOR this page

Quick tour

conjure_editor --project C:/games/grid_sweeper                     # the window, AI server on 127.0.0.1
conjure_editor --project C:/games/grid_sweeper --trust-project --headless --exec build.json --out replies.ndjson
conjure_editor --project C:/games/grid_sweeper --trust-project --headless --export C:/builds/grid_sweeper \
  --distribution C:/conjure/bin                                     # also copy the runtime, see below

Opening a project runs its scripts and native modules, so the editor opens one only after you answered for it. The window asks the first time, in a dialog titled "Trust this project?", and remembers the answer for you on this machine, outside the project. A headless run cannot ask: --trust-project answers for that run, and without an answer it exits with 2. A project the editor created itself in a new folder is trusted from the start (Project trust).

--distribution names the folder conjure_runtime, conjure_shared, shaders/ and THIRD_PARTY_NOTICES.txt are copied from, with nethost.dll and the Visual C++ runtime DLLs when it holds them. A folder without the notices exports with a warning that the game carries no licence notices, one on Windows without the runtime DLLs with a warning that the game needs the Microsoft Visual C++ Redistributable, and debug runtime DLLs in it are left behind with a warning. Without --distribution the export holds the cooked pack and the project files only, and its reply carries a warning that the runtime executable, library and shaders were not copied. A client that sends project.export with copyRuntime set made that choice itself and gets no such warning.

-> {"id":1,"cmd":"session.hello","args":{"clientName":"my-agent"}}
<- {"id":1,"ok":true,"result":{"protocolVersion":1,"engineVersion":"0.1.0","schemaHash":"...","clientId":2}}
-> {"id":2,"cmd":"entity.create","args":{"name":"Player","components":{"transform":{"position":[1,0,1]}}}}
<- {"id":2,"ok":true,"result":{"guid":"a9e2c0d4-...","name":"Player","revision":42}}
<- {"event":"scene.changed","seq":913,"frame":8812,"data":{"revision":42,"label":"Create 'Player'"}}

Local terms

Term Meaning here
command a named request with a JSON schema for its arguments and its result, flags and a handler; 123 built in
inverse the command that undoes a mutating command; stored by the undo stack
revision a counter bumped by every mutation; every mutating result carries it
transport where request lines come from: TCP (--ai-port), stdio (--ai-stdio), the in-process loopback (tests), or the local UI
headless --headless: null platform, device and audio, the null script host (--dotnet keeps the real .NET host, for play tests that run C#); view.screenshot answers NOT_AVAILABLE
play state editing, playing or paused; mutating commands are refused while playing unless flagged otherwise
pin a value, a component or an entity that play-mode persist keeps when play stops, instead of discarding it with the snapshot restore
agent a program that drives the editor over TCP or stdio; see the glossary

See also