Back Original

Why stop at Emacs? Native apps you or an AI reprogram in Clojure while they run


AffrescoUI is a native UI engine for applications that keep changing while they run. An app is a program in AffrescoUI Lisp, a sandboxed dialect of Clojure, made of named definitions for its window, views, state, behaviour, commands, keys, settings and text. The engine builds them into one document and draws it with C++ and OpenGL, with no browser engine or web view. If you write Clojure, you can already read and write these apps. Lisp is the standard, but the document can also be written directly in JSON, and all the examples but one ship both.

People and AI agents can change a running app. Each change is checked against the app's permissions and previewed when it needs approval. It then applies in place within milliseconds, with no rebuild or restart, and you keep your place.

Most software is fixed when it ships, and every change waits for the next release. AffrescoUI apps keep evolving, shaped by the people who use them.

Every app, from a to-do list to a professional design tool, is written in one format and drawn by one engine, so a feature built for one app can move into another. You don't need to program to build one. Describe what you want and an AI agent builds it with you, step by step, until a simple board is a full workbench.

You can reshape the apps you use, too. Ask in plain words ("add a Blocked column", "dim the lights at sunset", "warn me when a streak breaks") or point at the part you mean, and you see the result live before you decide. You keep it or undo it, even after later edits, and an agent's change waits for your approval unless you've allowed that kind of change. Prototypes are tried the same way, in the running app with your work in place, so when one is right, it's already the app.

A run of reviewed changes exports as a change set, a portable file that works like a plugin for anyone with the same app. Whole features can move between apps too: the planetarium below uses the presentation editor's slide sorter. A version of an app can be shared as one file as well, and every install is reviewed before it lands. The aim is apps as complex as the professional tools people use every day, built and changed the same way.

Thirteen example apps live in examples/. They aren't part of the library and have no native code of their own: file access, the terminal and all the drawing come from the library. Each is a Lisp program (examples/<app>/lisp/) with the same app in JSON beside it (examples/<app>/json/), and you choose which one opens in the Launcher's Settings. In Lisp, their text is in English, Spanish and French (Sign in: English, Italian and right-to-left Arabic). Calamaio, the text editor you can reprogram from inside, is Lisp only.

Every app has the AI assistant in its bottom-right corner. Ask it for a change in plain words, or Point at the part to change first, then review the proposal.

The AffrescoUI Launcher: a sidebar with Apps, My apps, Create and Settings, and a grid of application cards with their pictures, rendered natively by AffrescoUI from one live document

The Launcher is an AffrescoUI app too. It opens every example and your own apps, makes new ones (blank, from an example or from a description), lists a catalogue of apps and features to install after review, and sets the AI that every app's assistant uses.

Open them from the Launcher (./build/affrescoui_launcher), or run one directly with ./build/affrescoui_launcher examples/<folder>/lisp/index.screen.lisp.

%%{init: {"theme": "base", "flowchart": {"curve": "basis", "nodeSpacing": 28, "rankSpacing": 46, "padding": 14}, "themeVariables": {"fontFamily": "Helvetica, Arial, sans-serif", "fontSize": "14px", "lineColor": "#94A3B8", "primaryTextColor": "#0F172A", "edgeLabelBackground": "#FFFFFF"}}}%%
flowchart LR
    subgraph P["Who changes it"]
        direction TB
        you["<b>You</b><br/>the app's assistant"]
        ai["<b>AI agent</b><br/>Claude Code · MCP"]
        any["<b>Scripts & apps</b><br/>any socket client"]
    end

    subgraph V["Version control"]
        direction TB
        rules{"<b>Permission rules</b><br/>deny · ask · allow"}
        pr["<b>Proposal</b><br/>branch · live preview"]
        no["<b>Rejected</b><br/>nothing changes"]
    end

    subgraph E["Engine"]
        direction TB
        main[("<b>main</b><br/>SHA-256 commits")]
        rt["<b>Runtime</b><br/>reconcile in place"]
        gl["<b>Renderer</b><br/>C++23 · OpenGL"]
    end

    app(["<b>Your running app</b><br/>never restarts"])

    you & ai & any -- "revision" --> rules
    rules -- "allow" --> main
    rules -- "ask" --> pr
    rules -- "deny" --> no
    pr -- "you accept" --> main
    main --> rt --> gl --> app

    classDef peer fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1px,color:#0F172A
    classDef gate fill:#FFFBEB,stroke:#D97706,stroke-width:1.5px,color:#78350F
    classDef wait fill:#FFFFFF,stroke:#D97706,stroke-width:1px,stroke-dasharray:4 3,color:#78350F
    classDef stop fill:#FFFFFF,stroke:#E11D48,stroke-width:1px,color:#9F1239
    classDef core fill:#EEF2FF,stroke:#6366F1,stroke-width:1.5px,color:#1E1B4B
    classDef out fill:#0F172A,stroke:#0F172A,color:#FFFFFF
    class you,ai,any peer
    class rules gate
    class pr wait
    class no stop
    class main,rt,gl core
    class app out
    style P fill:#F8FAFC,stroke:#E2E8F0,color:#64748B
    style V fill:#F8FAFC,stroke:#E2E8F0,color:#64748B
    style E fill:#F8FAFC,stroke:#E2E8F0,color:#64748B
    linkStyle 0,1,2 stroke:#94A3B8
    linkStyle 3 stroke:#16A34A,stroke-width:2px
    linkStyle 4 stroke:#D97706,stroke-width:1.5px
    linkStyle 5 stroke:#E11D48,stroke-width:1.5px
    linkStyle 6 stroke:#16A34A,stroke-width:2px
    linkStyle 7,8,9 stroke:#6366F1,stroke-width:2px
Loading
  1. Anyone can propose a change. The host (affrescoui_launcher) draws the app and listens for peers on local sockets, and peers on other machines connect through the document server. You ask the app's assistant, pointing at a part if you like, and the AI you chose answers. An agent such as Claude Code can connect through the MCP server instead, which works both ways: it gets your request with what you pointed at, and its revisions and replies come back. Scripts connect too. Each change is a revision of compact edits, and its author is set by the connection, never by what a peer claims.
  2. Permission rules decide. deny refuses a change, ask sends it for review and allow applies it. Rules judge what a change does, not how it's written, and budgets cap how much a peer can change. Flow's rules, for example, let your own client change anything, ask before an agent changes behaviour, and protect the status bar from everyone.
  3. You review proposals. A proposal is a branch, like a pull request: the agent can keep refining it while you preview it live and check its diff. Then you Accept it, choose Always allow (don't ask again for that part of the screen), or Reject it with a reason. The accept edits mode applies changes that no rule covers, and plan lets agents only propose. An agent can change your app, but it can never approve its own changes.
  4. Accepted changes become commits on main, with SHA-256 ids, the author and the approver. The app updates in place, keeping focus and whatever you were typing. Any commit can be undone while keeping the changes made after it (if a later change depends on it, you choose what happens), and any version can be restored (VERSION_CONTROL.md).

Agents can also use an app. Its commands are tools that an agent lists and runs in its own name, never yours, under the app's run rules, and it can undo its runs (VERSION_CONTROL.md).

You need CMake 3.25 or later and a C++23 compiler. CMake fetches the pinned dependencies (cmake/dependencies.json).

cmake -S . -B build && cmake --build build
./build/affrescoui_launcher        # every app, your own apps and the AI settings

Note

The v2.0.0 downloads aren't code-signed yet, so the first time you open one, macOS and Windows warn that they can't verify the developer. Signed builds will come in a later release. Building from source avoids the warning and gives you a build optimised for your machine.

In the Launcher's Settings, pick the AI that every app's assistant uses: Claude Code or GitHub Copilot with your own sign-in, or a local model through Ollama, LM Studio or llama.cpp (a key, if one is needed, stays in the system's keychain). The assistants need nothing else. To connect an AI agent through MCP instead (mcp/README.md):

claude mcp add affrescoui -- python3 /path/to/AffrescoUI/mcp/affrescoui_mcp.py
claude --dangerously-load-development-channels server:affrescoui   # requests are pushed into the session

Either way, open Flow and ask its assistant to "add a Blocked column between In progress and In review". The change comes back as a proposal: Accept it and the board updates in place, or choose Always allow to stop being asked about that part of the screen.

./build/affrescoui_launcher examples/haven/lisp/index.screen.lisp                   # any app, no C++
./build/affrescoui_launcher examples/flow/lisp/index.screen.lisp --mode acceptEdits # agent changes apply unless a rule asks
./build/affrescoui_launcher examples/flow/lisp/index.screen.lisp --plugin my.json   # start with a change set applied

CI builds and tests it on Linux and Windows and builds it on macOS, where it's developed; web/ builds it for the browser. ctest --test-dir build runs the unit tests, every app's scenarios and the rendering check, which compares each frame with a golden image, pixel for pixel (tests/render/README.md).

AffrescoUI draws what it's told to. An app is a folder of documents (plus any native code that a program embedding the library registers), and the engine knows nothing else about it. There are three layers, each built only on the one below. Apps are folders of screen documents, data and assets, with nothing compiled for them. Themes (modules/themes) hold the kits of components (toolbars, menus, docks, dialogs) and each theme's design tokens, as JSON built into the library. The engine, every other module, holds only mechanisms. When a document uses a component or token it doesn't define, the engine looks it up in the installed kits and themes, without knowing any of them by name, and a document's own components win over the kits'.

On its way in, a change passes through these modules, each with one job:

%%{init: {"theme": "base", "flowchart": {"nodeSpacing": 30, "rankSpacing": 34, "padding": 14, "wrappingWidth": 400}, "themeVariables": {"fontFamily": "Helvetica, Arial, sans-serif", "fontSize": "14px", "lineColor": "#94A3B8", "primaryTextColor": "#0F172A", "edgeLabelBackground": "#FFFFFF"}}}%%
flowchart TB
    studio(["<b>You</b> · the app's assistant or a script"])
    agent(["<b>AI agent</b> · Claude Code"])

    mcp["<b>MCP server</b> · mcp/<br/>connects AI agents, both ways"]
    channel["<b>Channel</b> · modules/channel, modules/net<br/>local sockets · processes · WebSocket · one session per peer"]
    vcs["<b>Version control</b> · modules/vcs<br/>allow / ask / deny · proposals · commits · history"]
    format["<b>Screen format</b> · modules/format<br/>checks the document · evaluates it · reconciles in place"]
    lisp["<b>Lisp language</b> · modules/lisp<br/>builds a program's tree · runs its functions"]
    render["<b>Renderer</b> · modules/render<br/>layout · shaped text · input · accessibility · OpenGL"]
    themes["<b>Kits and themes</b> · modules/themes<br/>components · design tokens · JSON"]

    agent --> mcp
    mcp --> channel
    studio --> channel
    channel -- "revision" --> vcs
    vcs -- "accepted commit" --> format
    format -- "panels" --> render
    themes -. "components, tokens" .-> format
    lisp -. "programs" .-> format

    classDef peer fill:#FFFFFF,stroke:#CBD5E1,color:#0F172A
    classDef c_mcp fill:#F3E8FF,stroke:#9333EA,stroke-width:1.5px,color:#3B0764
    classDef c_channel fill:#E0F2FE,stroke:#0284C7,stroke-width:1.5px,color:#0C4A6E
    classDef c_vcs fill:#FEF3C7,stroke:#D97706,stroke-width:1.5px,color:#78350F
    classDef c_format fill:#D1FAE5,stroke:#059669,stroke-width:1.5px,color:#064E3B
    classDef c_render fill:#EDE9FE,stroke:#7C3AED,stroke-width:1.5px,color:#4C1D95
    class studio,agent peer
    class mcp c_mcp
    class channel c_channel
    class vcs c_vcs
    class format c_format
    class themes c_format
    class lisp c_format
    class render c_render
Loading
  • Native. A from-scratch C++23 engine on OpenGL 4.1 core or ES 3.0 (WebGL2 in the browser). A change updates only what reads it and redraws only what changed, text is sharp at every display scale, an idle window sleeps, and a full frame takes 0.40 ms (BENCHMARKS.md).
  • One document. A program builds a screen document (SCREEN_FORMAT.md, with a JSON Schema) of layout, components, themes, state, bindings, events, timers, services and permissions. Behaviour that usually needs code (wiring a button to a list, validating a form, filtering, drag and drop, shortcuts, navigation, calls to services) is declared, so an agent changes it as safely as a colour.
  • Compact for agents. Edits address nodes by id ({"set": {"#title/text": "Q4"}}, stored as JSON Patch) and apply atomically, in place, and re-reads return only what changed. A typical edit is 28 tokens and a re-read after one commit 27 (BENCHMARKS.md). When you point at a part, the agent reads only the definition that built it.
  • Swappable modules. Modules talk only through the interfaces in modules/core, and affresco::Screen plugs them together. No public header exposes OpenGL or GLFW, and each module links on its own (affrescoui::render, affrescoui::vcs, ...) or all together (affrescoui::affrescoui).
  • Features that travel. A part declares the contribution points and contracts it needs, so one app can install another's feature, checked before it lands. A feature can carry Lisp code, which runs with its author's authority (VERSION_CONTROL.md).
modules/core/         the interfaces between modules: Executor, Channel, VersionControl, Services, Network
modules/render/       windows, panels, layout, shaped text, input, accessibility; OpenGL 4.1 core or ES 3.0
modules/format/       the screen format: rules, checker, {{expressions}}, the runtime that reconciles in place
modules/themes/       the kits' components and the themes' design tokens, as JSON built into the library
modules/notation/     documents read and written in JSON or in the Lisp notation
modules/lisp/         the Lisp language, a Clojure dialect: reader, interpreter, programs built purely into a document
modules/data/         an app's records in SQLite, kept apart from its document: models and migrations
modules/audio/        sound: voices of files, streams and generators, mixed to the system's output
modules/vcs/          version control: commits, proposals, permissions, history
modules/channel/      peers and the live protocol over local sockets and processes
modules/net/          HTTP(S), server-sent events, WebSocket, remote peers
modules/services/     language servers, local programs and folders the host grants
modules/intelligence/ the providers an app's assistant asks (APIs or a command line), behind the assistant capability
modules/screen/       affresco::Screen, the composition root, and the umbrella header affresco/affresco.hpp
modules/automation/   scenarios: scripted input, expectations, golden images
modules/imaging/      layered images on copy-on-write tiles
modules/scene3d/      3D scenes, glTF 2.0 in and out
modules/export/       panel trees as vector PDF
modules/capi/         the C API, affresco/affresco.h
mcp/                  the MCP server for AI agents
apps/server/          the document server: shared, persistent documents over WebSocket
apps/host/            the stock host, affrescoui_launcher: it opens an app's folder and asks for what the app uses
examples/             the apps in lisp/ and json/ folders (Calamaio only in Lisp), the Launcher, the assistant add-on
catalogue/            the apps' versions and features the Launcher's Catalogue lists and installs
editors/              a VS Code extension, and a clj-kondo configuration for the Lisp programs
web/                  the WebAssembly build

ARCHITECTURE.md covers the layers, the path of a revision and of an event, and the security boundary.

Written in Lisp, a Clojure dialect

AffrescoUI Lisp is a sandboxed dialect of Clojure with its own runtime, built into the library. Its forms, functions and reader forms are Clojure's: of 186 everyday Clojure forms, 163 return the same value as in Clojure, and the other 23 are left out or differ on purpose (everyday.lisp, checked on every test run). It's also measured against Clojure's cross-dialect test suite (CONFORMANCE.md), every difference is written down with what to write instead (differences.md), and clj-kondo lints the programs with its configuration.

A program is a folder of small, named definitions, and every example follows the idiomatic style in style.md. Building the program produces the document the engine draws, and the program's functions run when a button is pressed, a key is typed or a bound value changes. From Flow's own code (examples/flow/lisp/flow.lisp):

(ns flow.flow)

(defn cards-of "A column's cards, in their order." [c]
  (:cards (column c)))

(defn next-order "The order that puts a card at the end of a column." [c]
  (->> (cards-of c) (map :order) (reduce max -1) inc))

(defn column-of "The column that holds a card, or -1." [ref]
  (or (first (keep-indexed (fn [c col]
                              (when (some #(= (:ref %) ref) (:cards col)) c))
                            computed.columns))
      -1))
You define In AffrescoUI Lisp
The window, as an outline of its parts defscreen main
Its parts, small and named defview, defcomponent
Its data defstate, defcomputed
Its looks deftokens, defstyle, defmenu
What it does defn, defcommand
Shortcuts and settings defkey, defcustom
Extension points defhook, add-hook, advice
Its text, in every language (t "key") and locales/<language>.lisp
Its files (ns board.index (:require "toolbar.lisp" ...))

Every definition and rule is in LISP.md, and the language itself in modules/lisp, RFC 0005 and RFC 0006.

Lisp or JSON: the same app

The document a program builds can also be written directly in JSON, which suits data and tools. An example's two versions are one app: their first frames match pixel for pixel, they pass the same scenarios, and they share one history, the same diffs and the same permissions. In tests of the same changes made both ways, an AI agent edited Lisp as accurately as JSON, at about the same cost (BENCHMARKS.md).

Lisp: the program you writeJSON: the document it builds
(defview card-view "One card, in bold when it is a bug." [card]
  `(label#card :text ~card.title :bold ~(= card.tag "bug")))

(defscreen main :window {:title "Board"}
  (column#cards
    ~(repeat [card state.cards] (card-view card))))
{ "type": "column", "id": "cards", "children": [
  { "type": "label", "id": "card",
    "repeat": { "for": "card", "in": "state.cards" },
    "text": "{{card.title}}",
    "bold": "{{(card.tag == 'bug')}}" } ] }

Changed from inside, while it runs

A running app can be reprogrammed from inside. In Calamaio, the text editor among the examples, open the scratch buffer (C-x b *scratch* RET), type a new definition of a command and evaluate it with C-M-x:

(defcommand kill-line "Says so." :title "Kill Line" :category "Killing" [] (message "redefined"))

The next C-k runs the new definition, and C-x C-z takes it back. apropos, describe-key and the other describe-* functions inspect the running program.

Your own editor can do the same in any Lisp app: start it with --nrepl and connect any nREPL client. The window asks once whether that editor may evaluate as you. After that, every definition you evaluate lands as your own revision, in the file your buffer is in (LISP.md). Only that definition is rebuilt, and the app updates where it's read.

./build/affrescoui_launcher examples/flow/lisp/index.screen.lisp --nrepl

Still under version control

  • Each evaluation is a revision of one definition: it's kept in history, its diff names the view or function that changed, and it can be undone like any other change.
  • An agent's code arrives as a proposal, rebuilt from its source and judged by the tree it builds. Once accepted, it still runs with the agent's authority, never yours.
  • Your authority covers only what you typed. Text pasted in or written by someone else runs with less, unless you read it in a question the host draws, which no document or agent can draw or answer, and say yes.
  • The language can't reach files, processes or the network. Its only ways out are the steps a host grants, each checked against who wrote the code that's running.
  • An agent's hooks and advice run sealed, so they can't stop your commands from working.

AffrescoUI is also a C++ library to embed. A host program loads a screen, adds any native code it needs, and can let other programs change the screen live:

#include <affresco/affresco.hpp>

int main() {
	affresco::Application app;
	affresco::Screen screen = affresco::Screen::fromFile("app.screen.json");
	screen.createWindow(app);

	screen.onAction("save", [&](affresco::Panel&) { /* native code, if needed */ });
	screen.listen(app, "/tmp/my-app/agent.sock", "agent"); // optional: let other programs change it live
	return app.run();
}
find_package(AffrescoUI REQUIRED)   # or add_subdirectory(AffrescoUI) / FetchContent
target_link_libraries(my_app PRIVATE affrescoui::affrescoui)

From C or another language, the C API (affresco/affresco.h) loads, drives and embeds a screen, and bindings/python wraps it for Python.

Everything the engine does
  • Screen format: layout (anchors, rows, columns, grids, splits, tabs, scrolling, overlays), styles, components with parameters and slots, themes and tokens, fonts, screens and navigation, state, computed, watch, JS-style {{expressions}}, repeat / when / let / check, two-way bind, events with bubbling, commands, menus, keybindings and settings, drag and drop, timers, animations, channels, persist, includes, strings with ICU plurals and locales.
  • Nodes: labels, text areas, a code editor with declarative languages and syntax trees, diffs, lists, trees and virtualised tables, node graphs, timelines, calendars, vector paths, an editable canvas, images and image operations, raster layers, 3D scenes, native OpenGL surfaces, colour pickers, gradients and curves, plus a kit of desktop and chat components.
  • Live documents: in-place reconciliation; revisions as compact edits or JSON Patch, atomic, by #id; any number of peers over local sockets, processes or the network; request and reply relaying; asking the agents from inside the app, pointing at what to change; updates that run only what read the change (dependency tracking).
  • Version control: SHA-256 commits, an append-only main, proposals as branches with merge commits, log, diff, blame, revert, restore, an undo that keeps later changes, three-way merges, HEAD~1 names; allow / ask / deny rules judged by effect, modes, grants, budgets, reviewers, protected controls, approvals pinned to the version reviewed; change sets, packages of a whole app and a catalogue, each installed after review; history on disk.
  • Services and network: language servers and local programs the host allows, folders it grants, HTTP(S), server-sent events, WebSocket, sign-in, and a document server that shares documents live.
  • Agents: a two-way MCP server with minified reads, outlines, single-node reads and changes-only re-reads, the source of what the person pointed at, pictures of the screen, scenarios, leases on parts, an app's commands as tools with run rules and undo, and authors set by the connection, never self-declared.
  • Lisp: a sandboxed Clojure dialect, measured against Clojure's test suite; definitions versioned one by one, a changed one rebuilt alone; an nREPL server for editors, paired by the person.
  • Engine: HarfBuzz shaping and FreeType glyphs with fallbacks, right-to-left text, colour emoji, display scales from 100% to 400% with text hinted sharp below 2×, damage redraws, the platform's accessibility API (VoiceOver, Narrator, Orca), headless windows for tests, vector PDF export.
  • Tooling: the affrescoui CLI (run, check, test, render, fmt, convert between JSON and Lisp, migrate, import from A2UI and Adaptive Cards, export, pack and install, a REPL), scenarios with golden images, a VS Code extension, a clj-kondo configuration, a C API with a Python binding, a WebAssembly build.
Document What it covers
LISP.md AffrescoUI Lisp in tables: every definition, views and bindings, running, layout of an app, limits, tools
SCREEN_FORMAT.md The screen format, node by node
VERSION_CONTROL.md Commits, proposals, permissions and review
modules/lisp/README.md The Lisp language: its values, special forms, functions and limits
ARCHITECTURE.md The modules, the path of a revision and of an event, the security boundary
mcp/README.md The MCP server and its tools
BENCHMARKS.md Speed, memory and token budgets, with every measurement
ACCESSIBILITY.md What screen readers see and drive, on every platform
SECURITY.md The trust model, what is protected, and how to report a vulnerability
CHANGELOG.md What changed in each release

The original layout demo, running again in 2026

AffrescoUI started in December 2017 as sGLGUI, when I was 16 and teaching myself OpenGL and C++. I wrote nested panels, pixel and percent sizing, anchors and a signal/slot event system from scratch. In 2018 I added a text area that collected keystrokes but could never draw them, and the project stalled. A restart in 2020 rewrote the layout engine (that demo is on the right), then stalled too.

In 2026 I picked it up again with Claude Code. The first goal was a library you could actually use, so we ported it to OpenGL 4.1 core, rewrote it in C++23 and finally drew text. Then I started wondering: what if an AI agent could change a native app while it runs, and you approved every change? That took the project far past the original plan, to UIs described as documents, live revisions, version control and a two-way MCP bridge for agents.

How it was built. All of the 2026 code was written by Claude Code, through agent-driven development. My part was the direction and the architecture. I shaped it over many iterations, trying an idea, seeing what it did and changing course until it worked the way I wanted. The git history shows every step.

timeline
    2017 : Started at 16 : nested panels, anchors, signal → slot events
    2018 : A text area that can't draw text : the project stalls
    2020 : Restarted : new layout engine, stalled again
    2026 : Revived with Claude Code : C++23 · OpenGL 4.1 core · real text : live screens in Lisp and JSON · version control · MCP
Loading

Apache License 2.0: free to use, modify and distribute, commercially or not. Anyone who distributes it must pass on the NOTICE file, which credits the author. See LICENSE and THIRD_PARTY_NOTICES.md.