Tweakable Desktop
What a Tweakable app is made of, its tweakable.json manifest, and what your app can tell the Core: where the user is, which files it opens, which data to leave out of a backup. For building an app by hand, or understanding the one the Assistant reshapes.
A Tweakable app is a full-stack desktop app in one folder: its own Electron window and main process, its own Node.js server, its own database. The Kit’s Core installs it, builds it, starts it and puts the Assistant beside it; the app talks to its server over localhost, like a website talks to its own. Everything in the folder is the app’s source, and the Assistant may change any of it.
tweakable.jsonpackage.json, package-lock.jsonelectron/main.cjs, electron/preload.cjssrc/AGENTS.mdassets/icon names, titlebar-glyph.png (the icon’s
inner shape alone, white on transparent: the title bars paint it in their text color) and trayTemplate.png + @2x (a black silhouette for the macOS menu bar).data.dbStart from a starter app: it already does everything this page describes, so you only change what your app needs.
name, version and icon, and the optional fields your app needs.tweakable.json, at the root of the app’s folder, tells the Core who the app is
and how to build and run it. A full one, with the optional fields:
{
"slug": "my-recipes",
"targetKit": { "slug": "tweakable-desktop", "majorVersion": "1" },
"name": "My Recipes",
"shortName": "Recipes",
"description": "My recipes, the way I like them",
"version": "1.0.0",
"icon": "assets/taskbar-icon.png",
"build": { "command": "npm run build" },
"server": { "entry": "build/index.js" },
"dev": { "command": "vite dev" },
"fileExtensions": ["recipe", "md"],
"dataDump": { "skipTables": ["thumbnails"] }
} | Field | What it does |
|---|---|
| slug | The app’s identity: lowercase letters, digits and hyphens. An installed app is known by the folder it was installed in, so changing the slug later does not rename it. |
| targetKit | The Kit the app is made for (slug) and the major version of its Core (majorVersion, a string such as "1"). Compatibility is per major version: every 1.x Core runs an app that targets "1". The right to sell an app is per major version too. |
| name | The app’s name: its title bar, its menu entry, its tray icon, its About. The user can rename the app by asking the Assistant. |
| shortName Optional | A shorter name for the macOS menu bar, at most 15 characters is best. Absent: name. |
| description Optional | One line shown by the app’s menu entry (the Linux tooltip, for one). Absent: “A Tweakable app”. |
| version | The version you release the app as. A user’s installed copy gets its own number, unrelated to yours: 1.0.0, raised by Tweakable each time they apply a change. Yours stays in the copy’s History: it names each update there, and the app shows it as the version it is based on. |
| icon | The app’s icon, a PNG path relative to the app’s folder: its window, its taskbar entry, its tray. When it changes, the Core restarts the app and updates its menu entry. |
| build.command | The command the Core runs to build the app, in the app’s folder, after installing its dependencies from its lockfile (npm ci). It runs on the Node.js the Kit bundles: nothing to install. |
| server.entry | The built Node.js server, relative to the app’s folder: build/index.js for the SvelteKit starter (adapter-node), server.js for the React Router one. |
| dev.command Optional | The dev server for edit mode: changes apply in about a second, with hot reload. Absent: the app runs in stable mode only (each change is a build). |
| fileExtensions Optional | The file types the app opens: lowercase, no dot, at most 50. The Core registers them so the system suggests the app in those files’ “Open with”. |
| urlSchemes Optional | The link schemes the app opens, like ["mailto"] for an email app: lowercase, never http, https or file. The Core registers them so the system offers the app for those links, and the app can ask to become the default (defaultHandler). |
| dataDump.skipTables Optional | Tables whose rows the app gets back by itself, left out when its data is committed to Git. |
Fields of your own are allowed and ignored by the Core.
Good to know
The manifest is part of the app: the Assistant may change it like any other file. A change to the name, the icon or the description, once applied, restarts the app and updates its menu entry; never edit launchers outside the app’s folder.
For each approved change, the Core takes the app’s approved source, installs its dependencies
(npm ci) and runs its build.command, on the Node.js and npm the Kit
bundles. It then starts the app’s Electron main process, which starts the server.entry with that same Node.js and opens the window on it. The starters’ electron/main.cjs already does all of that; your server only has to:
PORT, at HOST (127.0.0.1),
never on a port of its own choosing;TWEAKABLE_APP_DIR, never next to its built
code;// Your server, started by the app's main process with PORT and HOST set.
import http from 'node:http';
import path from 'node:path';
// The app's data lives in its folder, never next to the built code.
const dbFile = path.join(process.env.TWEAKABLE_APP_DIR, 'data.db');
http
.createServer(handleRequest)
.listen(Number(process.env.PORT), process.env.HOST ?? '127.0.0.1'); With a dev.command, the user can switch the app to edit mode (Settings > Malleability > Runtime): the dev server runs instead,
under the same rules, and changes apply in about a second.
| Variable | What it does |
|---|---|
| TWEAKABLE_APP_DIR | The app’s folder, where its data lives: data.db, app-prefs.json, window-state.json. The code runs from a separate built copy; the data stays here, so it survives every change. |
| TWEAKABLE_NODE_FILE | The Node.js the Kit bundles, to run the app’s server with (TWEAKABLE_NODE_ARGS and TWEAKABLE_NODE_ENV: its extra arguments and environment, as JSON). |
| TWEAKABLE_CORE_VERSION | The running Core’s version. |
| TWEAKABLE_DEFAULT_LANG | en or fr: the Assistant’s language, for an app that has no language of its own saved yet. |
| TWEAKABLE_START_HIDDEN Optional | 1 when the app starts in the background (its “start at login” entry): no window until the user opens it. |
| TWEAKABLE_BACKEND_PORT Optional | Only in the throwaway copy the Assistant runs to reproduce a bug: the port the server must listen on. |
| TWEAKABLE_APP_LAUNCHER Optional | macOS only: the app’s own launcher, to register as its “start at login” entry. |
AGENTS.md, at the root of the app’s folder, is read by the Assistant at the start
of every conversation, on top of its own instructions. Describe your app there: what it is,
where things live, your patterns and conventions, what never to change. The starters’ copy
explains everything on this page to the Assistant: keep the parts your app still uses. (Claude
Code reads it too, through the app’s CLAUDE.md.)
The user can change it too, in the Assistant’s settings or by asking. A good AGENTS.md is what makes the Assistant’s changes fit your app.
The starters’ preload puts a window.tweakable object in the page. Its assistant part reaches the Assistant:
setContext(text) tells the Assistant, in one short plain sentence, what the user
is looking at right now. The Core adds it to every request the user then
sends, so “make this one bigger” or “delete this” lands where the user is, not where the
previous change was. Call it whenever that changes; '' clears it, and so does each
restart of the app.
// The user opened a recipe: say so, in one short sentence.
window.tweakable.assistant.setContext('The user is reading the recipe "' + recipe.title + '"');
// Back on the list: clear it.
window.tweakable.assistant.setContext(''); It works with every AI the Assistant offers, the chat ones and the Claude Code and Codex terminals alike. Our learning game uses it to tell the Assistant which room the player is in.
summon(text) opens the Assistant with text ready in its message box:
the user can edit it, and sends it themselves. Use it for suggestions (the starters’ “Try
asking the Assistant” tab), never to act on the user’s behalf. Without text, it just opens the
Assistant. openSettings(section) opens the Assistant’s own settings: 'ai' for the AI connection, 'connect' for the guided “Connect an AI” screen.
// Open the Assistant with a request ready in its message box (the user sends it).
window.tweakable.assistant.summon('Add a "cooking time" field to the recipes');
// Open the Assistant's own settings, on the AI connection.
window.tweakable.assistant.openSettings('ai'); review.getPending() and review.onPending(cb) give the number of
changes waiting for the user’s approval, and review.open() opens the Assistant on them:
the starters’ title bar shows them as a “Changes to review” pill. Restyle it freely; the Core keeps
its own review buttons anyway.
When the user opens files with your app (a file manager’s “Open with”, or your app as the
default for a file type), window.tweakable.onOpenFiles(cb) calls cb(paths) with their absolute paths: the files the app was launched with, then any
opened while it runs (its window comes to the front).
// Once, at startup: the files the app was opened with, then any opened later.
const stop = window.tweakable.onOpenFiles((paths) => {
// The page cannot read local files: hand the paths to your backend.
void fetch('/api/import', { method: 'POST', body: JSON.stringify({ paths }) });
}); The app is offered for any file. To have it suggested for some (not only
under “Other application”), list their extensions in the manifest: "fileExtensions": ["mp3", "flac"]. Your app’s own file format belongs there too.
Declare only what the app is really about: the starters declare none, so they never claim
every text file.
An app can open links too: an email app can be the user’s default for mailto: links. List the schemes in the manifest, "urlSchemes": ["mailto"]; window.tweakable.onOpenUrls(cb) then hands your page the clicked links, and window.tweakable.defaultHandler('mailto', 'set') makes your app the default (on Windows,
which lets no app do it, it opens the system’s Default apps page for the user to pick it). Offer
it with a button: being the default stays the user’s choice.
An app keeps its data in its folder (TWEAKABLE_APP_DIR), in data.db for the starters (SQLite, through Node.js’s built-in node:sqlite: no native module to rebuild). Code and data are kept apart: a
change, an undo or a restore in the History moves the code, never the data. So write migrations that bring an older database up to date, and never put demo data in
them.
Data kept in data.db (and the app’s app-prefs.json) is what the
Kit’s backups cover: Export... with Include my data, and, with Pro, Commit the data too. An app that keeps its
data elsewhere is backed up with that store’s own tools.
With Commit the data too on, the linked folder gets a tweakable-data/ copy of the database, as readable text, one file per table, and it
goes into every commit. For a table the app can rebuild by itself (an email client’s messages, downloaded
again from the server; a cache; a search index), that is only weight in the repository’s history.
Name such tables in the manifest:
"dataDump": { "skipTables": ["messages", "attachments", "folders"] } _migrations and sqlite_sequence can never be skipped; unknown names
are ignored.Our email client skips its messages, attachments and folders (the folders hold the sync positions: without their messages, a sync would think it is up to date). Its data in Git went from about 270 MB to under 2 MB.
The app runs in its own process; the Core and the app talk through two narrow channels only:
the environment set at launch (above), and one-line messages: the app prints markers on its standard output, the Core
writes commands on its standard input. The starters’ electron/main.cjs handles
them and bridges what the page needs onto window.tweakable. You need this part only to reach a message the starters do not
bridge, or to write an app without them.
| Marker | What it does |
|---|---|
| [app] window shown | The app’s window is up. |
| [app] backend listening on http://127.0.0.1:<port> | The app’s server answers. |
| [app] summon assistant | Open the Assistant (the title bar’s Assistant button). |
| [app] context {"text":"..."} | Where the user is in the app, added to their next requests (setContext). |
| [app] open review | Open the Assistant on the changes waiting for review. |
| [app] supports: <command>... | At startup: the optional commands this app handles (reload-page, open-files, open-urls, stopping, reload-done). |
| [app] default handler {...} | Ask whether the app is the user’s default for a link scheme, or to become it (defaultHandler). The Core answers with tweakable:default-handler. |
| Command | What it does |
|---|---|
| tweakable:soft-reload | A change was applied: restart the server on the same port and reload the page, without closing the window. |
| tweakable:applying / apply-aborted | Show, then clear, the loading overlay around an apply. |
| tweakable:pending <N> | How many changes wait for review (the title bar’s “Changes to review” pill). |
| tweakable:ai <1|0> | Whether an AI is connected: an app may word its “Connect an AI” links with it. |
| tweakable:changed <1|0> | Whether the app’s code differs from the version it was installed as. |
| tweakable:bookmarks <json> | The versions the user bookmarked in the History. |
| tweakable:official <version> | The official version the copy is based on (your release, from its History), for its title bar or its About. |
| tweakable:official-name <name> | The name of that official app, sent just before its version: the base app the copy comes from, even after the user renamed it. |
| tweakable:open-files <json> | Files the user opened with this app (onOpenFiles). |
| tweakable:open-urls <json> | Links the user opened with this app, like a mailto: link (onOpenUrls). |
| tweakable:default-handler <json> | The answer to [app] default handler: default, not-default or unavailable (with the reason). |
| tweakable:focus | The user launched the app again: bring its window to the front. |
| tweakable:stopping | The Core is about to stop the app: reply [app] stopping ok and let the quit through. |
Every command is best-effort: an app that ignores one keeps working. The optional ones (open-files, stopping...) are sent only to an app that announced them on its [app] supports: line. Run without the Core, the app simply never receives any.
An AI that edits code makes mistakes, and can be misled by what it reads: a web page, a file, a package’s README. So the Core confines the Assistant, never your app: everything the Assistant does goes through a cage the Core sets up, outside its reach. The user picks how wide it is, per app (the containment levels, in the full guide); this is what the default, Confined, means.
run tool starts only the Core’s bundled programs (a
toolbox of the usual commands, plus node, npm and npx), inside the operating system’s sandbox. No shell, no other program from
the disk.Each system’s own isolation, applied to the whole process tree (every program a caged command starts stays caged), with nothing for the user to install. Inside it: the Core’s folder read-only, the app’s folder read-write, nothing else of the user’s.
sandbox-exec), with a profile the Core writes
for each launch: everything denied by default, then the folders above and the system
libraries.The cage fails closed: when it cannot be set up, the command is refused, never run without it.
Caged programs cannot open a connection themselves. Their only way out is a proxy the Core runs outside the cage, one per app, that answers only to a secret it hands the cage. The proxy:
The Assistant’s own requests to its AI are made by the Core itself, not by caged code.
The app runs uncaged, so the Core never runs what the Assistant wrote before the user approves
it. The Assistant edits the app’s folder; the Core builds and runs the app from a copy of its
own, made only from the approved version, with its packages installed by npm ci from the reviewed lockfile, so no unreviewed package or install script
runs at build time. Apply takes exactly the version the user reviewed: when the Assistant
changed something while the review was open, Apply stops and the review shows the new change. Apply automatically (an opt-in, per app) skips the wait.
Your app is not confined: its server may use the network, the files, any npm package. Only the Assistant is caged, and by default each of its changes waits for the user’s approval. What keeps the app malleable is a few things it must keep:
Settings > Global > Apps > Export... saves the app’s approved
version as one .tweakable-desktop file; a double-click on it installs the app on
any computer with the Kit (sharing, in the full
guide). Sharing an app is free.
Tweakable Pro gives you the right to sell the apps you build on Tweakable,
for good, for the Kit major versions it covers: the one the app declares in targetKit.majorVersion. In short, from the license:
The Tweakable License is the reference, and Pricing has the details of Pro.