Tweakable Desktop

For developers

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.

01

What an app is made of

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.json
The manifest: the app’s identity and how to build and run it. Reference
package.json, package-lock.json
Its dependencies, any npm package. The Core installs them from the lockfile.
electron/main.cjs, electron/preload.cjs
The app’s own Electron main process (the "main" of package.json) and preload: the window, its title bar controls, the tray, menus, notifications, and the window.tweakable bridge the page uses. Plain Electron code, yours to change.
src/
The app itself: its pages and its server, in the framework of your choice.
AGENTS.md
What the Assistant should know about this app. More
assets/
The icons: the one 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.db
The app’s SQLite database, created on its first launch. Data, not source: it never goes into the app’s code history. More
02

Start an app

Start from a starter app: it already does everything this page describes, so you only change what your app needs.

  • SvelteKit (the default): the notes app that comes with the Kit.
  • React (React Router): the same app, written in React, free to install.
  • Anything else that builds into a Node.js server: the Core does not depend on a framework, it runs what the manifest declares.
  1. Settings > Global > Apps > New app...: give it a name, pick a starter app and As it was installed. It becomes an app of its own, with its own menu entry, data and history.
  2. Change it. Ask the Assistant, or work in your own editor: in Settings > Version control, Link a folder… Pro keeps a copy of the app in a folder of your choice. Edit it there, then Import… brings your edits back, to review and apply like the Assistant’s.
  3. Update the manifest: its name, version and icon, and the optional fields your app needs.
03

The manifest: tweakable.json

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"] }
}
FieldWhat 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 OptionalA shorter name for the macOS menu bar, at most 15 characters is best. Absent: name.
description OptionalOne 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 OptionalThe 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 OptionalThe 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 OptionalThe 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 OptionalTables 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.

04

How the Core builds and runs it

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:

  • listen on PORT, at HOST (127.0.0.1), never on a port of its own choosing;
  • keep its data in TWEAKABLE_APP_DIR, never next to its built code;
  • serve the app’s pages and its own API on that one port.
// 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.

What the app’s main process receives

VariableWhat 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 Optional1 when the app starts in the background (its “start at login” entry): no window until the user opens it.
TWEAKABLE_BACKEND_PORT OptionalOnly in the throwaway copy the Assistant runs to reproduce a bug: the port the server must listen on.
TWEAKABLE_APP_LAUNCHER OptionalmacOS only: the app’s own launcher, to register as its “start at login” entry.
05

AGENTS.md: brief the Assistant

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.

06

Talk to the Assistant

The starters’ preload puts a window.tweakable object in the page. Its assistant part reaches the Assistant:

Tell it where the user is

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('');
  • One line, at most 1000 characters.
  • It is given to the AI as information, never as instructions.
  • Keep private content out of it: it goes to the AI provider with every request. A title is fine; a whole note is not.

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.

Open the Assistant

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');

Changes waiting for review

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.

07

Files opened with your app

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.

08

Your app’s data

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.

Leave out what the app gets back by itself

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"] }
  • Their structure is kept, their rows are not: a restore brings them back empty, and the app fills them again. Make sure it can.
  • A kept table may not refer to a skipped one (a foreign key): the Core then refuses the commit, since the restored data would be broken. Skip both, or neither.
  • _migrations and sqlite_sequence can never be skipped; unknown names are ignored.
  • Export... with Include my data is not affected: it stays a full backup.

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.

09

Under the hood: the process protocol

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.

App to Core: markers on standard output

MarkerWhat 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.

Core to app: commands on standard input

CommandWhat 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.

10

How the Assistant is caged

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.

What is caged

  • Its file tools (list, read, search, write, edit, delete) run in the Core and only take a path inside the app’s folder, resolved through its symbolic links first: a link that points out of the folder is refused.
  • Its 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.
  • Claude Code and Codex, in the Assistant’s terminal, run inside the same sandbox.
  • The throwaway copy of the app the Assistant starts to reproduce a bug runs inside it too.

The sandbox on each system

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.

Linux
Landlock, through a small helper shipped with the Core. Network: an empty network namespace (no TCP, no UDP) whose only way out is a socket to the Core’s proxy; where namespaces are unavailable, Landlock denies TCP except to the proxy. Linux 6.7 or later: on an older kernel, commands get no network at all unless the user allows the full network.
macOS
The system’s Seatbelt sandbox (sandbox-exec), with a profile the Core writes for each launch: everything denied by default, then the folders above and the system libraries.
Windows
An AppContainer, through a small helper shipped with the Core, given access folder by folder. Network: a named pipe to the Core’s proxy.

The cage fails closed: when it cannot be set up, the command is refused, never run without it.

The network

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:

  • speaks only HTTP and HTTPS, on ports 80 and 443, and only to the allowed hosts: the npm registry, the user’s Allowed hosts, and for Claude Code or Codex, its own vendor’s hosts;
  • resolves each name itself and refuses loopback, private, link-local (the cloud metadata address included), shared and multicast addresses, so the user’s local services and network are out of reach. It connects to the address it checked, so a name cannot change its answer in between;
  • with Allow all network requests, lets any host and port through, still not the local network nor the mail ports (25, 465, 587).

The Assistant’s own requests to its AI are made by the Core itself, not by caged code.

What it never reaches

  • The Core’s private data: its settings, each app’s History, the built copy of the app, and the other apps’ folders. A shared folder (the Extended level) is read-only and may not overlap any of them.
  • Its own cage: the level and the allowed hosts are kept by the Core, outside the app, and only the user changes them in the Assistant’s settings.

The second barrier: the review

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.

Known limits

  • On Linux, a caged program can still connect to the user’s Unix sockets (the session D-Bus, ssh-agent, the display server) unless the kernel lets Landlock refuse them (Linux 7 or later). Settings > Containment shows it.
  • The Unconfined level turns the cage off, after a confirmation.
11

What keeps an app malleable

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:

  • The Assistant button in the title bar, and its wiring. Restyle it, move it, but never remove it: the Assistant refuses to.
  • The source. The app ships as source and is built on the user’s computer, so it can always be changed.
  • What belongs to the Core: the Assistant’s window, the review of changes and the History, a paid app’s license check. The app cannot change them, and neither can the Assistant.
12

Share and sell your app

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.

Selling it

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 seller, the one who receives the payment, holds its own Tweakable Pro;
  • the people who get the app need no Tweakable Pro to use it;
  • you give them the app’s complete source, as you would anyway;
  • you may put a license check of your own in it (a trial, license keys), and the license then protects it like our own paid apps.

The Tweakable License is the reference, and Pricing has the details of Pro.