Architecture
This page covers how JOLT works inside, for contributors. Each heading names the source folder it describes.
Pages and add-ins
| Page | Opened by | Code |
|---|---|---|
app.html | JET's Run Apps button | src/app/ (JET), and src/ide/ (JADE) on demand |
commands.html | Ribbon commands | Function file |
ide.html | The retired JADE add-in | public/ide.html, a static page saying that JADE has moved into JET |
JOLT is one add-in, JET, with one manifest (manifest-runner.xml). JADE runs in the same page: ☰ → Build or edit apps (JADE) imports src/ide/main.js, Monaco included, the first time it's chosen, and mounts it over JET's view. JET's apps and =JOLT.RUN keep running underneath, and JADE keeps its state until the pane closes. Because JADE and JET share a page, they share approvals: every save in JADE approves the saved code on this computer. In development, everything is served from https://localhost:3000.
Storage (src/store/)
A project is { version: 1, files, storage, meta }. meta holds a document id, a revision number, and when and by whom (ide, app or vscode) it was last saved. The codec turns the project into JSON, gzips it and base64-encodes it. The per-host stores put the result in a custom XML part in the urn:jolt:project:1 namespace. PowerPoint falls back to document settings when PowerPointApi 1.7 isn't available. Personal settings, such as editor preferences and trusted origins, live in localStorage.
Module loader (src/runtime/loader.js)
The ModuleGraph turns project JS files into real ES modules loaded from blob: URLs. It parses each file with es-module-lexer and rewrites specifiers:
- Relative imports become the blob URL of the target file. Files are loaded dependencies first, which is why circular imports are reported as an error.
"jolt"becomes a tiny module that re-exports the pane's API object.- Names in jolt.json
imports(exact names, or prefixes ending in/) resolve to their URL or project file. "van"and"vanjs-core"resolve to the VanJS bundled with JOLT.- Other bare names become
https://esm.sh/<name>.
Every remote URL a module names goes through the trust check before the module is imported. Each module ends with //# sourceURL=jolt:///<path>, so stack traces name project files. Exported functions are discovered with acorn (discover.js), which also reads @automation tags.
Sessions (src/runtime/session.js)
A JoltSession holds everything one pane needs to run a project: the project, its store, the module graph, the jolt API object and console capture. It mounts the entry page (mount.js) and calls autoRun.
Saves and refreshes run one at a time. Each save is a compare-and-swap on the revision number. If the document has moved on, the session rebases: it runs a three-way merge between its base snapshot, its own changes and the document's version, and asks the UI to resolve any conflicts.
Three-way sync (src/project/sync.js)
The same merge code serves JADE and JUICE. Given a base and two sides, a file changed on one side only is copied to the other. A file changed on both sides is merged line by line. Overlapping edits become a conflict, with git-style markers when both sides still have the file. JUICE keeps its base in .jolt/sync.json.
Remote sites (src/runtime/remote.js, src/publish/)
An exported site is the project files plus jolt.files.json and a CORS _headers file. fetchSite reads the file list, fetches each file into an in-memory project, and runs it like an embedded one. A URL ending in .js or .mjs is imported directly instead.
VS Code link (src/link/, relay/)
- Pairing. A connection code (
jolt1:…) carries the relay URL, a random room id and an AES-256 key. Each project folder has its own pairing (in~/.jolt/config.json, keyed by the folder path), and JET saves a code for each document (inlocalStorage, keyed by the document URL or path). So two VS Code windows on different projects connect to two different documents. The first project to connect takes over the single pairing that older versions kept. - Protocol. Messages are JSON, sealed with AES-GCM through WebCrypto, and split into 256 KiB chunks to stay far below the relay's 1 MiB frame limit. The code runs unchanged in browsers and in Node. Protocol version 2 adds document revisions to
pullreplies and the compare-and-swapsync.push. - Relay. A Worker plus a Durable Object per room. Both ends connect to
wss://<relay>/room/<id>?role=vscode|pane. The relay forwards binary frames between the two roles, announces joins and leaves, and stores nothing. It uses the WebSocket Hibernation API, so idle connections cost no Durable Object time. - Connection.
connection.jsreconnects automatically.pane-link.jsimplements JET's side: reloading files, running functions, forwarding output, and pull, push, embed and remove.
JUMP and JADE classic conversion (agent-kit/, src/jade-import/)
agent-kit/ holds JUMP, the guides for AI coding assistants. scripts/build-agent-kit.js copies them to /agent-kit/ on the site, with an index.json whose version is a content hash. JUICE's vscode/src/agent-kit.js downloads them into projects: the core guide into .jolt/ai/, and a playbook when its task starts. See AI assistants.
JOLT doesn't convert JADE classic code itself. read-jade.js reads the modules, from the workbook's JADE classic XML parts (through JET's jade.read link message), a folder or a gist. JUICE copies them verbatim into jade-classic/ next to the conversion playbook, and the developer's assistant does the conversion. See Converting JADE classic.
Hosting (worker/, wrangler.jsonc)
jolt.technologylearningcompany.com is a Cloudflare Worker with static assets serving dist/. The assets use html_handling: "none", so app.html is served at exactly the URL in the manifest, and the retired ide.html stub still answers installs of the old JADE add-in. Requests that match no file go to worker/index.js, which serves index.html for directory URLs such as /, and redirects /docs/ to the home page.
JOLT used to live at jolt.availabooks.com. That host is now a separate Worker (redirect/, in the account that holds the availabooks.com zone). It sends every URL to the same path on the new host with a 301. The exceptions are app.html, commands.html and ide.html, which Office opens for installs from the old manifest: they show a notice to reinstall JET, because a pane can't follow a redirect to a domain its manifest doesn't list.