Skip to content

Latest commit

 

History

History
1937 lines (1699 loc) · 172 KB

extending.md

File metadata and controls

1937 lines (1699 loc) · 172 KB

Extending the tower

The tower keeps its whole state outside its code: the config (what you want), the session logs (what happened) and the collections (files kept for later). Its API does the work, and the library it serves is a convenience on top. So there is no plugin API into a renderer. You extend the tower by editing the config, by writing clients of the API (a renderer, a shelf page, a script), by reading its files, and, for what must run inside the tower, by an extension.

This guide is for you and your workers alike. A worker asked to customize the tower or build a renderer reads it first.

What you can build on

Point For Its contract
The config floors, shelves, collections, editor, callsigns, hiring, worktrees, how sessions start config.md, checked by tower config check
Renderers your own view of the whole system, or your own version of one that ships served at /r/<name>/, the API through /tower.js
Shelf pages a page beside a floor's sessions, with the board and the API /tower.js, relayed by the renderer that frames it
The API anything a renderer, a script or a cron job does verbs, reads and streams, versioned major.minor, /schema
The library what the tower's own renderers and extensions draw and read alike, for yours to import /lib/<module>.js, the API's version: removing a name is a major
Collections your own kinds of files, kept per floor files; what they mean is yours
Extensions code the tower starts and stops beside its own pieces extension.json, versioned with the API, extension at /schema
Claude plugins your commands and skills in every session the tower starts config runtimes.claude.plugins
The tower command the system from a shell, for you and your workers tower with no verb lists them
The logs everything that happened, to read JSONL, written only by the host

The config

~/.tower/config.json says what you want: the floors and their directories, each floor's shelf and collections, your editor, the callsigns workers are called by, how far hires go, how worktrees are cut, and the command and environment every session starts with. config.md documents every key. The tower reads the file again on every change, port aside.

{ "editor": { "window": ["zed", "{dir}"], "open": ["zed", "{path}"], "goto": ["zed", "{path}:{line}"] } }

Check every edit with tower config check: it reads the config as the tower does and prints each problem at its key path.

Your own renderer

A renderer is a directory of built files, served at /r/<name>/ at the tower's origin, so it calls the API directly. Ship it as an extension: an extension.json at the root of its repo declares it, with root the folder its build writes, and the config adds the extension by its folder. renderer names the one / opens.

{ "id": "mine", "version": "1.0", "title": "Mine", "requires": { "tower": "2.13" },
  "renderers": { "mine": { "root": "out", "settings": { "badge": "mine" } } } }
{
  "extensions": { "mine": { "path": "/Users/you/code/my-tower" } },
  "renderer": "mine"
}
  • root is a folder inside the extension, entry its page in it, index.html unless set. Anything below root is served with it, nothing above. A renderer is named by the extension's capability, mine or mine.<name>, so one extension may ship several (Contributing surfaces).
  • The config's renderers declares one too, with no extension: { "renderers": { "mine": { "root": "<absolute folder>" } } }. Under the name of an extension's renderer it sets that renderer's fields, so renderers.mine.settings in the config is the user's settings over the extension's.
  • settings is your renderer's own configuration. The tower passes it through unread; your page reads it with await tower.renderer(), which answers { name, root, entry, available, settings }, and what its renderer.json declares.
  • A renderer is available while its entry exists. GET /renderers lists every one, and the tower page lists them at the foot of its sidebar.
  • A name the core declares (page, week, tower3d) overrides that renderer's fields: { "tower3d": { "settings": … } } keeps its root. No extension may take one of those names.

A renderer says where it draws in renderer.json at its root, and GET /renderers serves what it declares beside its fields; a renderer with no file declares nothing. The tower page's is renderers/page/renderer.json:

{
  "regions": [{ "id": "card.head", "subject": "card", "holds": ["badges", "lines", "verbs", "commands"], "description": "the worker's header" }],
  "kit": ["terminal", "region", "run", "display", "go", "bus", "toast", "notice", "confirm", "href", "showing", "location", "spawn", "now"],
  "keeps": [],
  "layout": { "floor.section": { "hidden": ["policies/policies"] } }
}
  • regions: each place it draws for one subject kind, named <kind>.<place> (item.* is every collection's items), with what it holds (verbs, commands, badges, lines, marks, tidy, asks, views), and for one that holds views the room each gets (scale: chip, row, cell, pane, dialog, list) and whether it shows one, tabs or all, the region its views open in when it draws them as entries (opens, on a region of arity all: board.nav opens in board.main), whether it offers only the views that ask for it (optIn: The sidebar's entries), and the forms it draws it in when it is full, its default first (overflows: When a region is full). Only regions is required. tower extensions check and the table under Extensions are read from them.
  • kit: what it lends the views it hosts (terminal, region, run, display, go, bus, toast, notice, confirm, href, showing, location, spawn, now): a view is offered only where the kit holds every member it needs (Views).
  • keeps: the chords it takes for itself, as the config's keys writes them (Tower 3D's movement keys): no extension's default chord takes one.
  • layout: its own default arrangement of its regions, by region id: order (view ids first, in this order; the rest after), hidden (not offered there: views, actions and an extension's lines), open (the tab a tabs region opens on), options (each view's own settings there), and pinned, unpinned, overflow and the budgets lines, badges, actions and views (When a region is full). The config's renderers.<name>.layout lies over it, and the viewer's, kept in tower.store under layoutKey(name) (layout.<name>), over both: layoutOf(declared, configured, stored) in /lib/layout.js takes each field from the highest layer that sets it; hidden from all of them, less an id a higher layer names in its order, or pins where that pin stands; and pinned from all of them, the highest layer's first, less an id a higher layer names in unpinned. GET /renderers serves the config's as configLayout, and what is wrong with it as layoutProblems. A region whose config entry has a fail among them is drawn by its default: pass usableConfigLayout(renderer) as configured, the config's layout less each such region, never configLayout itself (layoutKey and usableConfigLayout in /lib/layout.js).
  • themeSample: a module in its root whose sample() returns { html, bodyClass }: the html of its own parts on sample data (a floor's plate, a worker row), drawn with its own functions, and the class the frame's body takes for them to draw (the page's drawer, its sidebar open in a frame that narrow): the Theme dialog (tower/themes) frames it with the page's stylesheets and each theme, beside the shared parts (buttons, a menu, a terminal strip). A renderer without one previews those alone.
  • entry: the page the file declares for, index.html unless set. Two renderers may share a root with different entries (Tower 3D's Lab is its out/ with lab.html): only the one whose entry matches reads the file.

A file that doesn't parse declares nothing, and the renderer serves all the same: GET /renderers says why as its problem, and tower config check warns. The tower reads keeps for extensions' chords; kit and layout are read by the renderer that hosts views, through /lib/layout.js.

When a region is full

Extensions may add more to a region than fits it. A region draws a prefix of one ranked list in place and reaches the rest through its overflow form (decision region-overflow):

  • menu: what doesn't fit in the room goes behind a ⋯ control, measured.
  • count: a fixed number in place and "+n" for the rest, reached where the subject opens or in the palette. Offer it only where the rest is reachable there.
  • wrap: everything, the region growing.
  • scroll: a strip with a visible edge that keeps the open item in view.

A region lists the forms it draws in overflows, its default first, and the user picks one with the layout's overflow, per region: a choice applies wherever the region is drawn, grid cells included. A region with no overflows offers no choice. Declare a form only once your renderer draws it, so tower config check never accepts a form it can't draw. overflowOf(region, entry) in /lib/layout.js answers the form a region is drawn in: the layout's when the region offers it, else the default.

The ranking is shared code in /lib/layout.js, so every renderer orders a region alike:

  • actionId(action) and lineId(line): the one id space pins, hides and the viewer's seen name, a command's <cap>/<command>, a verb's qualified name, and for lines the extension's capability.
  • heldActions(holds, actions), in /lib/cards.js: the actions a region holding holds draws, as landing places them: commands where it holds commands, verbs where it holds verbs.
  • rankedActions(actions, entry): less the hidden, the pinned first in their order, then board order. Pass what you draw, after leaving out the commands (<cap>/<name>) the holder omits: rankedActions(heldActions(region.holds, addedActions(board, s)).filter((a) => !(isCommand(a) && omit.includes(`${a.cap}/${a.command}`))), entry).
  • menuPins(menu, holds), in /lib/palette.js: what a region beside a subject can pin of the subject's menu (subjectMenu): an extension's action by its actionId where the region holds its kind, and the menu's own lines by their id, the same on every subject of a kind (out, a file's reveal and edit, and worker on a showing, MENU_LINE_IDS). Draw a pinned line with its icon, its label where it has none, and run it as the menu runs it. The tower page's shown.tab is drawn so: its ⋯ is the subject menu, whose "Pin to the tab" pins any of them, and its layout pins out, reveal and edit with actions: 0, so a showing's tab draws the browser tab's ↗, a file's also its Finder and editor icons, and the rest stays in the ⋯ until pinned; a link's tab draws no out, since the link opens outside the tower and its name's ↗ already says so.
  • rankedBadges(board, subject): the folds' badges, the most severe tone first, board order within a tone. A card's exemptions are apart (exemptionsOf): draw them with its identity and never tuck them. badgesOf(board, subject) is the two together, exemptions first: the order a region that draws all of a subject's badges draws them in.
  • rankedLines(board, card, entry): a card's lines, pinned capabilities first, then fold order.
  • placedEntries(placing, region): in a region that opens its views elsewhere (opens), the entries in place and those behind its menu: the pinned first in their order, then the region's order; under menu, the pinned and views of the rest in place.
  • headRanked(badges, ranked): a head's fill order, the severe badges, the pinned actions, the other badges, the other actions.

fill(widths, room, menu, was, margin) in /lib/layout.js answers how many of the ranked items a menu region draws in place: fewer as soon as they don't fit, more only with margin to spare. Pass the count you drew last as was, and widths.length on a first fit or once the ranked ids changed. Measure each item when it is painted, fit on a change of the region's inline size or of what it paints, never on a clock tick.

The budgets lines, badges and actions say how many of each a menu region draws at most, or a count region exactly, and views how many entries a region that opens its views elsewhere draws in place under menu, pinned by view id:

  • pins don't count against a budget, and are drawn while there is room;
  • the region's own controls never count;
  • 0 under menu draws the pinned alone;
  • count draws min(k, n) and shows no "+0";
  • under wrap and scroll a budget is unused;
  • on a worker's head, lines is how many lines its row of lines shows, not part of the fill.

A region whose declaration gives a label ("Extensions on a worker's head") offers the viewer a choice beside the budgets: its buttons on screen, or in the menu only (onScreen: false in its layout entry, the highest layer's). drawnEntry(entry) in /lib/layout.js is the entry to draw by: in the menu only, the lines and actions budgets are 0, so the region draws what is pinned of those, in any form, wrap included, and its badges, which are information, not buttons; isOnScreen(entry) says which. A region that holds nothing (holds: []) is declared for its label alone: it names a group of the renderer's own buttons, which the renderer draws or not by isOnScreen. Hide nothing the subject's menu and the palette don't reach. An extension's region that holds views takes no label: its manifest is refused, since only buttons move to the menu. The tower page offers it for a floor's sign, directories, section, trays and shelf, and for a worker's row and head, extensions' and the page's own apart, in its settings ("Buttons on screen") and at the end of a region's "Pin to…" submenu.

An extension's actions are new to the viewer while an extension offers them and the viewer's seen doesn't hold them (isFresh(offeredIds(board), seen, id); seen a field of Viewer in /lib/viewer.js). Mark them with a dot. Newness never changes the ranking. When nothing was ever kept, write seenOf(null, offeredIds(board)) once, so a fresh tower shows nothing as new. Add to seen with sawAll(seen, ids), which answers nothing when there is nothing to write: when the viewer runs, pins or hides an action, opens a menu that lists it, or sees it drawn in place in a focused window.

A view and the renderer that fills a region inside it share one head. The view marks what the region's fit takes into account:

  • data-tuck="<rank>" with an aria-label: a control of the view's the region may tuck as a last resort, the lowest rank first, after every contribution. Its menu item calls the original's click(), so the view's handler runs unchanged.
  • data-keep: something the region draws in its own slots that it must never tuck (a heeded wait's Dismiss, a card's exemptions).
  • data-tuck-text: text the menu's header shows once it is tucked.

The renderer marks the element it fills with the form it draws the region in, data-overflow="menu" and so on, so a view can lay out its own parts for a region that tucks: the page's worker head gives its place line's slot to the top extension line at compact room, its text left to the menu's header, only while its head is drawn as menu.

Everything else in the region's element that isn't a slot it filled is protected: its width is taken from the room. A renderer that ignores the marks never tucks those controls, and they stay drawn. Whatever is tucked is hidden, out of the tab order and the accessibility tree, and is reached by keyboard through the menu; the palette lists every action on the subject in focus, tucked or hidden.

A new one

Start from a page that includes /tower.js:

<!doctype html>
<link rel="stylesheet" href="/design.css">
<ul id="floors"></ul>
<script src="/tower.js?v=2.0"></script>
<script type="module">
import { statusName } from '/lib/cards.js'
tower.subscribe((board) => {
  document.getElementById('floors').innerHTML = board.floors
    .map((f) => `<li>${f.name}: ${f.cards.filter((c) => c.onDuty).map((c) => `${c.callsign} ${statusName(c)}`).join(', ')}</li>`)
    .join('')
})
</script>

renderers/week/ in the checkout is a renderer of this kind grown up: The Week, two files and a stylesheet over the board, /stats and the archives, with no build. Read it for a page that steps through windows of time and draws the Stats numbers its own way.

Its own look, in its place. Link /design.css before any other sheet: it declares the order of the tower's cascade layers, where a later layer outweighs an earlier one whatever its selectors weigh. Bring your sheet through rendererLayer(css) of /lib/view.js, inserted as a <style>: it then sits over the design and the tower's elements and under views' styles and themes, as the tower page's own sheet does. Element defaults (button { … }, a { … }) go through componentsLayer(css) instead, so the shared components' classes (.icon-btn, .chip, .eyebrow) still outweigh them. A sheet in neither outweighs every layer: views can't restyle what it styles, and a theme can't either.

import { rendererLayer } from '/lib/view.js'
document.head.append(Object.assign(document.createElement('style'), { textContent: rendererLayer(myCss) }))

The board is the whole system as one value, sent again whenever it changes: its type is Board in /lib/board.js, described as JSON Schema by tower api board (each event is {v, board}, not the board itself). Each card, conversation, floor, policy and offer carries actions, what can be done to it now, each a verb with its call when it is a request of the API: tower.run(card.actions.find((a) => a.verb === 'resume').call), or callOf(card, 'resume') and can(card, 'resume') of /lib/board.js. /tower.js documents its every member in its header (curl http://127.0.0.1:4317/tower.js | head -60).

Pin the version you wrote against. /tower.js?v=2.0 refuses to load into a tower of another major or an older minor: window.tower is never defined and the console says which versions met, in place of a page drawing a board it misreads. A page that names no version moves with the tower: right for the renderers in the checkout, wrong for yours. tower.version is the tower's full version, for a feature check.

Say when the board is stale. tower.onBoardError((err) => …) is called whenever there is no live board, with err.code: config or internal when the tower can't build it, disconnected (since 1.9) when the tower stopped answering. /tower.js reconnects on its own, and the next board through subscribe means it recovered. Until then the board you drew is how things stood: mark it so (boardErrorTitle(code) in /lib/cards.js heads the message as the shipped renderers do), and stop any clock you draw from it. A framed page gets the same error, relayed.

Draw what can't run, and why. The board leaves out spawn, cut and shell while the daemon they need is down; whyNot(board, verb) in /lib/cards.js says why in a sentence (undefined while it runs), for a control drawn inert with that tip in place of one that vanishes. It answers resume, carry-on and let-go too, which the board offers on a card.

Write a theme

A theme is a stylesheet the tower loads into a renderer's pages after the renderer's own sheet and its views' styles. It restyles a renderer without copying it, so taking a release never touches it.

An extension offers themes, by renderer and name, each a path inside the extension with the title a picker shows (since 2.34):

{ "id": "my-theme", "version": "1.0", "title": "My theme", "requires": { "tower": "2.34" },
  "themes": { "page": { "dusk": { "title": "Dusk", "file": "dusk.css" } } } }

An offered theme loads nothing until the config picks it: renderers.<name>.theme takes one theme's id, <provides>/<name> (the extension's capability, its id unless it sets provides, then the theme's name). Leave it unset for the renderer's own look. The board lists what is offered (board.offeredThemes, by renderer), so a picker reads the choices from it.

{ "renderers": { "page": { "theme": "my-theme/dusk" } } }

The config can also load stylesheets of its own, by the absolute path of each file, after the active theme: a tweak over it, or a whole theme kept outside any extension.

{ "renderers": { "page": { "theme": "my-theme/dusk", "themes": ["/Users/you/code/my-tweaks.css"] } } }

From 2.30 to 2.33 a manifest's themes was a list of files per renderer, all loaded while the extension was accepted. Since 2.34 a manifest names each theme and the config picks one: an author moves its list into named entries and tells its users to set renderers.<name>.theme. A manifest still in the list form is refused, saying what to write instead.

The bundled themes extension offers two, themes/aqua and themes/flamingo. examples/extensions/harbor/ is one to start from, offered as harbor/harbor or loaded by path: a palette in both schemes and in more contrast, rounder corners, and headings in sentence case.

  • Set tokens. The palette (--panel, --ink, --accent…), the scales, and the character tokens (Character) are what a theme is for: every renderer, view and element reads them, the terminal too (--enamel, --term-fg, --ansi-*). The design's tokens are the promise: a token keeps its name and meaning within a major.
  • Write the schemes yourself. A theme that sets the palette sets it per scheme, as /design.css does: the viewer's choice is data-scheme on the root (light, dark, or none to follow the system), and more contrast is data-contrast="more" or the system's prefers-contrast: more. Harbor writes each once, and derives more contrast from its own palette.
  • Selectors beyond tokens are best effort. The page's classes, its state classes and the elements' data-slot parts reach what tokens don't, but they are not a contract and may change in any release. Every rule of a theme outweighs the tower's, whatever its selector weighs: a plain .bar-info .call beats the view's own rule.
  • What the tower hides stays hidden, and so does what it sets !important (reduced motion, a tucked control): a theme can't show an element the tower marks hidden.
  • The order. Each theme is imported into a cascade layer of its own, the active one first, then the config's in their order, so a later theme outweighs an earlier one. A theme names no layer: the tower wraps it, and the layers' names are not part of the API.
  • One file. The tower serves a theme's stylesheet alone, at its own origin only: nothing beside it, so a theme kept among other files shows none of them. A face or a picture it needs goes in as a data: URL, or is a face the viewer has installed.
  • Live. A page loads with its themes, and follows a change of them (the config's theme or list, the active theme's extension accepted or turned off) as the board says it: tower.onThemes tells it when the new ones have loaded. An edit to a theme's file shows on the next load.

A screen's own theme. The config's theme is the tower's. A viewer can draw another on their own screen from the palette's Open Theme (the tower/themes dialog), which previews every offered theme and the renderer's own look on real parts, in either scheme, and makes one the tower's too. tower.theme (since 2.39) is the same for any page: get() says { screen, tower, drawn }, use(id) draws one here (null the renderer's own look), follow() the tower's again, pick(id) writes the config's theme through the config verbs, and sheet(id) is the stylesheet a frame links to preview one, /renderers/<name>/themes.css?theme=<id>, with the config's tweak sheets still over it. The screen's choice is kept per renderer in tower.store; a choice no extension offers any more draws the tower's. A document the tower draws in a frame (a markdown file, a kept item) takes the theme drawn: frameLook(tower) in /lib/design.js gives its root's attributes and the stylesheets to link.

Every renderer the tower serves at /r/<name>/ takes its themes, a renderer of your own included: the tower links /renderers/<name>/themes.css, the stylesheet importing them, into the page it serves, and the board carries each renderer's themes (board.themes, by name) for /tower.js to follow. A behaviour rather than a look (a button, a panel, a line on a card) is an extension's view or command (Extensions), not a theme.

A copy of Tower 3D

Tower 3D is built from the checkout's sources: it imports the library and the extension clients at run time from the tower that serves it, a few of its files still import the core's TypeScript by relative path, and its build runs the checkout's scripts. Copy it as a clone of the tower at the release you start from, kept apart from the checkout that runs your tower: change renderers/tower3d/ there in commits of your own, npm ci, npm run tower3d, and declare <the clone>/renderers/tower3d/out as your renderer's root: it holds the pages, their modules and the models they fetch (out/assets/). Taking an update is checking out the new tag and putting your commits on it.

Shelf pages

A floor's shelf keeps pages beside its sessions (config.md). Three kinds are pages that can read the board and drive the API:

Entry The page
html a page in one of the floor's repos, a path relative to the hub, with the files beside and below it
item a file kept in one of the floor's collections, "<collection>/<id>"
renderer a declared renderer, by name, with its settings

The tower page frames each one sandboxed, at an opaque origin, and relays the board and every API request over postMessage: the page includes /tower.js and uses it as a renderer would. tower.framed is true there, and tower.ui('select', { id }), ('home') and ('shelf', { project, n }) move the tower page's own view, and ('go', { location }) takes it to a location (Views), ('display', { subject, view? }) shows a subject, or its key, where its layout puts it. A renderer that hosts no views ignores those two. An html or item page runs on its own at /run/<project>/<n>, a renderer at /r/<name>/, both at the tower's origin. Framed, a renderer still reads every file below its root but the hidden ones (a path with a part starting with ., never served): the tower serves them with CORS, so it may fetch them and import them as modules at its opaque origin. An html page framed reads the files beside it only as classic scripts, stylesheets and images: shelf files are served without CORS, which would let any site read them, so a fetch or a module import of them fails. A page that loads its own data or models is a renderer. The viewer's appearance follows the framing page: tower.prefs.get() and tower.prefs.on read it, and tower.prefs.set(patch) asks the framing page to change it, for every page of the viewer's. A url entry's frame gets the colour scheme alone, as {t: 'scheme', scheme}.

Every page the tower frames forwards the tower's global keys (⌘K, Escape, the pane chords), with nothing to add: /tower.js sends them, and the tower appends /frame-keys.js, which sends keys and nothing else, to every html file it serves sandboxed. It appends /frame-picks.js too, which sends the page's selection as { t: 'pick' } (API 1.170) and clears it on { t: 'unpick' }: tower/html takes it as a passage only from a frame showing a worker's file, only with the token it gives the document that frame holds at its first load ({ t: 'picks', token }, which a document navigated to after it never gets), and a new selection only while the frame holds the focus. A key one of the page's handlers took stays in the page, as does typing in a field: a page that handles a key (Escape closing its own dialog) calls preventDefault to keep it. A renderer that frames pages hears them as { t: 'key' } messages and runs a global command (frameCommandOf, /lib/keys.js) only for one from the frame holding focus; a remote url page forwards nothing. What a forwarded key opens (the palette, a dialog) takes focus from the frame, and Chrome keeps a frame's pointer lock through that: a page that locks the pointer lets go of it on its window's blur (Tower 3D does), so the mouse is free and the next Escape reaches what opened.

Relaying is tower.relay's work. A renderer frames a page in an iframe sandboxed without allow-same-origin and hands it to the relay with what is its own: the entry the page is, its select, home and shelf, and what to do when the page sets a key in tower.store:

const relay = tower.relay(frame, '/shelf/lab/0/index.html', {
  self: { project: 'lab', n: 0 },
  ui: { select: ({ id }) => openWorker(id), home: () => goHome(), shelf: ({ project, n }) => openShelf(project, n) },
  stored: (key) => reread(key),
})
relay.close() // when the frame goes

The tower page relays every page it frames; Tower 3D relays the html entries it frames, and opens a renderer entry in the tower's own view when framed, else in a new tab.

The API

Everything a renderer can do is an HTTP route on http://127.0.0.1:<port>:

  • Verbs: POST /<verb> with a JSON body: spawn, resume, submit, keys, kill, collection/create, tidy, the config verbs (config/add, config/append, config/set, config/remove, with GET /config: one checked edit each, docs/config.md) and the rest, and the extensions' verbs by their names (reviews/append). Every POST carries the header origin: http://127.0.0.1:<port>; without it the tower answers 403, its guard against other web pages.
  • Prompts: submit types after whatever the worker's composer holds and is queued while Claude works; it is refused (not_at_prompt) while the worker asks the user something or waits on one of Claude's screens, where the text would answer it. submit/at-prompt submits only while the worker sits at its prompt (idle, done, failed or watching) with nothing in its composer, which the card offers as its prompt verb. It refuses not_plain for text opening with / or ! (Claude's composer runs it as a command or a shell line: the message names the worker's terminal), not_at_prompt or composer_holds as the call arrives, and moved when the worker moved while the text was typed: Enter is not pressed, and the text waits in the composer. A composer for people calls this one.
  • Which page the user is at: a page names itself and its renderer on its board stream, GET /board?viewer=<id>&renderer=<name> (its own id, 8 to 64 letters, digits and dashes, new on every load), and calls POST /viewer/active {viewer} when it gains focus and as the user acts. The board's viewers.active is the viewer the user acted on last among those whose stream is open, and viewers.last.<renderer> the one of that renderer: one page, across every machine reading the tower, for what only one should do (play a sound, speak). The tower holds them in memory and never logs them. tower.js does all of it for a page, as tower.viewer.
  • Which worker a page has selected (1.172): a page says it with tower.select(id), its session id or null for none (POST /viewer/selected {viewer, id}; tower.js says it again whenever the board doesn't carry it, as after a tower restart). The board's viewers.selected maps each viewer to the worker it has selected, a viewer with none left out, and forgets a viewer when its board stream closes. The tower page says the worker its main pane is on, so the worker the user has selected there is board.viewers.selected?.[board.viewers.last?.page]: undefined when nothing is selected or no tower page is open, and with two open, the one the user acted on last. It is undefined too while no tower page has been acted on since the tower started (last comes from viewer/active alone, and after a restart only the page with focus says it): a consumer that wants an answer then can take the one entry of viewers.selected when it holds exactly one, which today is a tower page's, since no other renderer says a selection.
  • Reads: GET /board (SSE: {v, board}, again on every change), /renderers, /stats, /changes/<id> (?scope=all, the default, uncommitted or a commit), /conversations/<id> (each turn with Claude's steps: its words, its tool calls and the messages it sent), /conversations/<id>/<conversation> (one conversation, every turn) and /conversations/<id>/tool/<call> (one tool call: its input, its permission check, how it ended), /archive/<project>, /collection/<project>/<collection>/<item>, the bundled extensions' reads (/reviews/history/<project>, /quota/reads, and /policies/runs/<project>?policy&limit, a policy's runs, newest first, each with its worker as it is now), /landing?project&branch (what landing changed on a branch: each commit landed as an edited copy, with git range-diff), /origins, /patterns (what users found doing with the tower, one story each, from the checkout's docs/patterns/), /extensions (the extensions the tower runs, none yet, and its resources as braided orders them: layers, start and halt order, dependents, and the graph as Mermaid text; the chain around each verb or hook, each hook's answerers, and the verbs the core's composites call). /stats?from&to&bucket&project (epoch ms, bucket hour or day) answers Stats (its type in /lib/stats.js): a summary, a series per bucket and spend by hour of the day, for all and per project, each session's share of the window by its id (turns, spend, its longest turn and wait), the weekly budget, and the weekly limit as last read in the window (weekly), and the points of it used outside the tower in the window (outside: claude.ai, the desktop app, another machine, as the quota probe saw it climb while no session worked; the budget's outside is this week's, and what 1% buys leaves it out). /archive/<project> answers the floor's cards the board leaves out, the board's Card shape, so the workers of any past window are the board's cards and the archive's together.
  • Streams: a session's screen, an interactive terminal, a shell (screen/<id>, terminal/<id>, shell/<id>), and the version of a file a read serves (version/<read>, such as version/shown/<id>/<path>), multiplexed on one connection, GET /mux. tower.versions(read, fn) hands fn {t: 'version', modifiedAt} as the watch begins and each time the file at that path changes, written in place or replaced by a rename, modifiedAt null while it is gone: draw the read again on each. The tower watches the file's folder only while someone listens (2.9).
  • Errors are data: {t: 'error', code, message}. Branch on code (invalid, not_found, refused, unavailable, not_at_prompt…), never on message.

GET /schema serves every verb's input and reply, and the error, as JSON Schema, and every GET route as a read (reads, keyed by name: its path with named params like /screen/{id}, its kind, json, stream, page or schema, and its query as JSON Schema when it takes one), and every core verb's stages as flows (Flows): a renderer or a script in any language learns the contract from the tower. tower api lists the verbs and the json reads, one line each, and tower api <name> prints one's schema (a read's reply is typed in the module its route's line names). Every route is listed in the header of src/tower/http.ts.

The version is major.minor, the same on the board, /schema and /tower.js. An addition an older client reads past moves the minor; a rename, a removal or a changed meaning moves the major, with a line in CHANGELOG.md saying what to do. The tower makes a best effort to avoid majors.

View state (marks, a remembered tab, a viewer's preference) goes in tower.store: tower.store.set(key, value), await tower.store.get(key). It lives in the viewer's browser under keys every page shares, the tower page included, so the files you mark viewed in one renderer are viewed in the next; tower.store.on((key) => …) hears each key the page sets, a page it relays included, and (API 2.32, a page outside a frame) each key another window of the viewer's sets. tower.remember and tower.recall keep one value for the page alone.

The viewer's appearance is tower.prefs: the scheme, the text, heading and code faces (any face installed on the viewer's computer, by name), the terminal's font size, motion, contrast, whether waits flash and text size. tower.js keeps it in the viewer's browser, shared by every tab and every page of theirs, and puts it on your page's root before it paints: data-scheme, data-motion, data-contrast, data-waits (since 1.168: flash when the viewer wants what waits on them to flash, as the tower page's sidebar and skyline and Tower 3D's lamps do), the --ui, --display and --mono stacks, and --scale, the root's font size as a factor of the browser's, which every rem size follows. A page that links /design.css and draws with its variables follows it with no code. Read it with tower.prefs.get(), hear changes with tower.prefs.on(fn), change it with tower.prefs.set({ mono: 'Fira Code' }). A document you draw in a frame without scripts takes it as <html ${tower.prefs.attributes()}>. A terminal takes its face and size from it with terminalFont of /lib/terminal.js. Offer its settings with prefSections and wirePrefs of /lib/settings.js: a setting the tower adds later reaches your popover with nothing to wire.

Which store, then: the config holds intent, the same in every browser (projects, the editor, the user's name); a renderer's settings in the config hold that renderer's own art or behaviour (Tower 3D's cats); tower.prefs holds how the viewer likes to read, across renderers; tower.store holds view state (marks, a remembered tab).

Scripts and cron jobs are clients too. Anything running as you may call every verb:

B=http://127.0.0.1:4317
curl -s -XPOST $B/spawn -H "origin: $B" -H 'content-type: application/json' \
  -d '{"project":"my-app","prompt":"Run the test suite and list the tests that fail."}'
curl -sN -m 2 $B/board | grep -m1 '^data:'      # the board, once: /board is a stream that never ends

The library

The library is what code outside the core builds on: 26 modules at /lib/<module>.js, each a file of src/lib/ that names what it re-exports and holds nothing else (API 1.151). One line works everywhere, so a module an extension's server and client share can use it:

import { esc } from '/lib/words.js'
  • In a browser it is a URL. A page gets one instance of each module however many modules import it.
  • In an extension's server code the tower's resolve hook maps the prefix to the same source it runs. A name the library doesn't hold fails at import, listing the modules it has.
  • In an extension's .ts client the tower's bundling leaves the import as it is, the URL a browser loads.
  • In a bundler or an editor it is a tsconfig path, which tower types writes for you.

Only /lib/ is contract. A file's path under src/, its URL under /shared/ or /src/, a file tower types wrote under .tower/types/ that isn't a library module's, and anything else a checkout lets you reach can change in any release, whatever it happens to export. A name not in the library isn't lost: it joins as a minor the day something uses it.

Module Runs For What it holds
/lib/board.js generic authors the board's types and pure readings of it: subjects, what is offered and its calls, crews, checkouts, each command's limits, each extension's settings
/lib/extension.js server server server code's types (Start, ctx, folds, parts, the shape of tower/config), API errors, and checking a spawn's fields
/lib/words.js generic authors text: escaping, plurals, spans, times, tags and item titles
/lib/view.js browser authors a view's types and chrome, the cascade layers a renderer's and a view's CSS go in, the clipboard, panels drawn and kept, controls pressed, files and items, icons, highlighted code
/lib/markdown.js generic authors markdown as safe html, and its stylesheet
/lib/machine.js generic authors the loop machines run on, and held reads
/lib/time.js generic authors crons and periods: slots and their words
/lib/files.js generic authors media types, a floor's checkouts and repo names
/lib/keys.js browser authors the keymap: commands, chords and their labels
/lib/morph.js browser authors new html morphed into an element, keeping the nodes it still describes and the nodes others own
/lib/elements.js generic authors the html of the tower's elements (/lib-ui/): a combobox, the subject menu and a subject's place to open it
/lib/design.js generic authors palettes, type, the terminal theme, the sky
/lib/cards.js generic renderers a worker and a floor in words: status, health, duty, waits, rings, tidy, worktrees, limits
/lib/layout.js browser renderers regions, contributions ranked and fitted, views picked, locations and display
/lib/brief.js browser renderers a worker's brief
/lib/changes.js browser renderers the Changes panel, its reads and its line picking
/lib/stats.js generic renderers the Stats panel and its words
/lib/extensions-panel.js generic renderers the Extensions panel: every extension the tower found, its state and problems
/lib/terminal.js browser renderers a browser terminal: face, size, keys, the view machine, a shell's stream
/lib/spawn.js browser renderers the new-worker dialog and its form
/lib/attend.js browser renderers what a viewer is told about waits
/lib/settings.js browser renderers the settings popover
/lib/palette.js browser renderers the command palette
/lib/chrome.js browser renderers toasts, tooltips, the confirm dialog and popovers closed by a press in a frame
/lib/viewer.js browser renderers what a viewer keeps, and their appearance
/lib/capabilities.js generic renderers what the tower can teach, as tips
/lib/client.js browser renderers window.tower's types, the /tower.js client

Each module says where it runs. generic code runs anywhere (data, words, html as strings); browser code uses the platform's APIs; server code uses node's. /lib/extension.js is lent to node and not served to browsers: a browser that loads it gets an error saying so, and a client takes its types with import type, which leaves no import behind.

Versioning. The library has no version of its own: API_VERSION is it, and requires.tower or a renderer's /tower.js?v= covers it. test/served-exports.json lists each module's runtime, its names with the minor each arrived in; outside a checkout, the declarations tower types writes carry @since on a name whose source says one. Adding a name is a minor. Removing, renaming or changing the meaning of one is a major, after a deprecation: the name stays as an alias marked @deprecated, with its replacement, until that major. A name marked @provisional has met one consumer: it may change in a minor, with a CHANGELOG.md line saying what to use, and is never removed without a replacement before a major. A second consumer promotes it, for good. A member can be provisional in a type that isn't: Loop of /lib/machine.js is stable, its until provisional. npm test holds the tower to the list: any difference fails, and npm run served:update rewrites it for a change you meant (commit it).

Draw Claude's answers, prompts and anything a worker wrote with markdownHtml of /lib/markdown.js, never with a markdown library's own parse: those words can carry what a web page Claude read put in them, and your renderer runs at the tower's origin, which holds every verb. markdownKept is the same function, remembered for the texts the page drew most lately: draw through it what is drawn again on every event, as a brief at work is. documentHtml keeps a file's raw HTML as written, its links and scripts included (only markdown links are checked), so frame its html without allow-scripts.

Copy with copyText(text) of /lib/view.js, or copyTelling(text, what, toast) to toast the outcome, never with navigator.clipboard: a tower reached by a name of the config's hosts over plain http is no secure context, the clipboard API is undefined there, and copyText falls back to the document's copy command.

A renderer that draws any of the library's views installs the shared tooltip once, watchTips(document) from /lib/chrome.js: the views explain their controls with data-tip (the Stats bars their readouts), and the settings popover stays hidden until it is placed.

To redraw a view from html without losing what the viewer holds in it, use morph(el, html) of /lib/morph.js (provisional): it makes el's children what html describes and keeps every node that still matches, so text typed, a caret, a selection, focus and scroll survive. Nodes are matched by id, then by tag and position: give an id to a node that must stay itself while its siblings come, go or move. Mark a node another piece of code fills (a region you mount, a frame, a terminal, an element with its own state) data-owned to have the morph leave it whole, its attributes and the mark itself included, or data-owned="children" to have it update the node's attributes and leave its children; ids inside an owned node take no part in matching. The mark is plain html, so a pure function drawing the view can emit it. A view that redraws one element from a pure render on every board can call morphPanel(el, html) of /lib/view.js (provisional, since 2.19) instead: it morphs only when the html differs from what it last put there, and gives focus back by identity to a control the morph had to make anew.

The morph makes a kept node's attributes what the new html says, so an attribute your script writes onto a node the html draws is gone on the next redraw. Render that state into the html instead, or mark the node data-owned and give it an id: an owned node without an id matches only a new owned node (decision drawn-or-owned). The library's own writers already hold: a control pressing marks stays aria-busy, and a shown tip stays its control's aria-describedby.

Spell each id with domId(place, key) of the same module (provisional), as the tower's views do: <place>:<key>. place is words of [a-z0-9-] joined by / that your code names, saying what the element is and where it is drawn (row, tab); a part of it goes in the place, not after the key (row/menu), and a view that can be mounted twice at once puts its mount's scope first (ctx.scope, Views). key comes from your data, never from a position: a subject key (card:<id>) or a field's name. Find an element by its id with getElementById, and never parse an id back into data: read it from a data- attribute.

The tower's elements

/lib-ui/<module>.js is the library's half for what a page draws as a tag (API 2.15): importing a module defines its tower-* elements, which build their own parts inside themselves, with the keyboard, focus, placement and dismissal of the UI SDK (@ui-sdk/web, pinned at an exact version). Import a module once, from your page or your extension's client, then draw the tags as html:

import '/lib-ui/combobox.js'
import { comboboxHtml } from '/lib/elements.js'

host.innerHTML = comboboxHtml({ place: 'my-form', name: 'model', label: 'Model', value: 'opus', options: [{ value: 'opus', label: 'Opus' }, { value: 'haiku', label: 'Haiku' }] })
host.addEventListener('valuechange', (e) => keep(e.detail.value))
  • The contract is the outer tag. Each tower-* element with its attributes, properties, events and states is the contract. The ui-* elements it builds inside itself are implementation, which any SDK pin may change, styling them included: don't write them, select them or style them.
  • A render writes attributes. Everything an element takes is an attribute a pure render can write: plain (name), mapped into the part it means (label, placeholder), or parsed (options as JSON). Properties are for what no render holds: items of a menu, set as it opens for a subject, and the SDK's controller at api.
  • Mark it data-owned="children". The morph then updates the element's attributes and leaves the parts it built. The element writes no attribute on itself, so the morph loses nothing: what it shows of its own state is a custom state, tower-menu-area:state(open). A <tower-menu-area> is not owned: its children are your row.
  • Events bubble from the element, so a view listens on its own host. preventDefault() on a change refuses it.
  • A value written back is quiet. <tower-combobox> reports a choice with valuechange; keep it and render it as value, which applies with no event. Its id is domId(place, name). A form whose label holds more than words (a hint, a mark) draws it apart, with an id, and names it in labelledby: the combobox then draws no label of its own.
  • It keeps a form's keys as a select does. While its list is open, typing highlights the first match, and Enter or ⌘↵ chooses the highlighted option, or does nothing with none, and stops there: a form's submit key never sees it. Closed, the keys pass on. Leaving without choosing shows the chosen option again: text typed but not chosen is never a value, and is gone when the list opens again.
  • One subject menu per page. Draw subjectMenuHtml() once, outside anything that redraws, and wrap each subject's markup with subjectHtml(place, key, label, row): a right-click, the context-menu key or a long press on the row opens the menu at the pointer, and the ⋯ button it draws at the row's end opens it from the keyboard (macOS sends no contextmenu for Shift+F10). subjectAreaHtml and subjectButtonHtml draw the two apart, for a row whose button sits elsewhere in it. Each derives its id from place, where it is drawn, and key: the area's domId(place, key), the button's domId(<place>/menu, key). On payloadchange, set the menu's items for detail.value, the subject's key; on action, run detail.value, and on checkedchange too for a checkbox item. subjectMenu(board, key, context) of /lib/palette.js says what the core's subjects offer (floor:<project>, card:<id>, shown:<card>/<at>), each line's does run as a palette entry's is.
Element Attributes Properties Events States
<tower-combobox>, /lib-ui/combobox.js options: The options, as JSON of the SDK's ListData: items ({value, label, keywords?, disabled?}), groups ({type: 'group', label, items}) and separators. They may change while the list is open; the selection and the highlight stay on their items.
value: The value of the option chosen; absent, none is. Written back from valuechange, it is applied with no event.
name: The name its value submits under in a form.
label: The visible label that names it.
labelledby: The id of an element elsewhere on the page that names it, for a label that holds more than words: set, it draws no label of its own.
placeholder: The text the empty box shows.
empty: What the list says when no option matches.
disabled: It can be neither focused nor changed, and submits nothing.
required: A form will not submit until an option is chosen.
custom: Text typed is chosen too, by Enter (⌘↵ too): typing highlights no option, so Enter takes the text, the option an arrow key moved to, or the one labelled exactly the text; leaving the box without choosing still shows what was chosen.
value: The value of the option chosen, or null.
open: Whether the list is open.
api: The SDK's combobox controller.
valuechange: detail.value: the value chosen, null when the text was cleared; detail.reason why. preventDefault() refuses it.
openchange: detail.value: whether the list opens or closes, detail.reason why. preventDefault() keeps it as it is.
none
<tower-dialog>, /lib-ui/dialog.js label: Its title, drawn at its top, which names it to a screen reader. open: Whether it is open. Set it to open or close it: opened, it takes focus itself, Tab going on to its body; closed, focus goes back to where it was.
body: The element it shows: put its content here. It fills the dialog under the title and scrolls inside it when its content is taller.
openchange: detail.value: whether it opens or closes, detail.reason why (escape-key, outside-press, close-press). preventDefault() keeps it as it is. Setting open fires none. none
<tower-menu>, /lib-ui/menu.js id: Required: the name its buttons and areas give in for.
modal: pointer, the default: a press outside closes it and goes no further. true also makes the rest of the page inert; false lets the press through.
loop: Arrow keys wrap from the last item to the first.
presentation: auto: a sheet from the bottom of a small touch screen, a popover elsewhere; sheet: always a sheet.
items: What it offers, as the SDK's MenuData: items ({value, label}), groups, separators, checkboxes, radio groups and submenus. Set it on payloadchange. An item's, checkbox's or radio item's hint, the tower's own, shows as a muted line under its label, at most two lines (its backtick spans drawn as code), and describes it whole to a screen reader without naming it; hints are found by value, so items sharing a value share one.
open: Whether it is open.
api: The SDK's menu controller.
openAt: openAt(payload, anchor): opens it for a subject at an element or a point ({x, y}), as a right-click on an area does; resolves once it closes.
payloadchange: detail.value: the subject it is about to open for, on every opening, the same subject again included. Set items for it here.
action: detail.value: the value of the item chosen. It closes after.
checkedchange: A checkbox item of items chosen: detail.value, the item's value; detail.checked, whether it turns on. preventDefault() refuses it. It closes after where the item sets closeOnSelect.
openchange: detail.value: whether it opens or closes, detail.reason why. preventDefault() keeps it as it is.
none
<tower-menu-button>, /lib-ui/menu.js for: The id of the <tower-menu> it opens.
payload: The subject it opens the menu for.
label: The button's accessible name, Menu when absent.
none none none
<tower-menu-area>, /lib-ui/menu.js for: The id of the <tower-menu> it opens.
payload: The subject it opens the menu for.
none none open: While its menu is open for its subject, however it was opened.

The look. /lib-ui/ ships the tower's stylesheet for the parts inside its elements, built on the design's tokens. It reads them through the SDK's variables, each set on the tower-* element from a token, so a page restyles an element by setting one of them on it: --ui-background (--panel), --ui-foreground (--ink), --ui-muted (--panel-2: a field's fill), --ui-muted-foreground (--muted), --ui-border (--line), --ui-input (--line-strong), --ui-primary (--primary), --ui-primary-foreground (--on-primary), --ui-ring (--accent), --ui-destructive (--broken-text), --ui-radius (--radius-control), --ui-spacing (--sp-xs), --ui-font-size (--fs-s), --ui-font-sans (--ui), --ui-font-mono (--mono), --ui-shadow (--shadow-pop), --ui-icon-chevron and --ui-icon-check. The ⋯ button also reads --control, and a highlighted item and the ⋯ button under the pointer read --hover. The outer elements are yours to lay out: <tower-combobox> is a block, <tower-menu> is out of the page's flow (position: fixed, its content in the top layer), <tower-dialog> is out of it too, its backdrop and box in the top layer (the backdrop reads --backdrop, the box --radius-card, its title the display face and the heading tokens), <tower-menu-area> turns off iOS's long-press callout, and the rest keep the browser's defaults. Only these variables and the design's tokens are promised inside a tower-* element: its parts' data-slot attributes, like the page's own classes and state classes, are reached by selectors at best effort and may change in any release.

Versioning. test/served-exports.json's libUi lists each module's tags, each attribute, property, event and state with the minor it arrived in, read from the module's elements export; the table above is generated from the same data. Adding one is a minor, removing or renaming one a major. /lib-ui/sdk.js is internal: the SDK's entries the elements use, bundled once so every element on a page shares one SDK core, whose popups stack in one set of layers.

Beside the library

The tower serves a few things next to the library, each on its own terms:

URL What it is Its contract
/tower.js the client: the board, every verb and read, streams, tower.store, the viewer's appearance (tower.prefs) the API's: removing or renaming a tower member is a major
/design.css the design's tokens as custom properties (colours in both schemes, the type and spacing scales, corners), the faces, a few classes (.needs, .pill, .eyebrow, .tree…), and every button's pressed, held (disabled, aria-disabled) and busy (aria-busy) states the API's: removing or renaming a token or a class is a major
/x/<cap>/<module>.js an extension's client modules; the bundled ones are under /x/drafts/, /x/floors/, /x/guides/, /x/pins/, /x/policies/, /x/quota/ and /x/reviews/ the extension's own contract.json, at its major (the author's loop)
/x/tower/<name>.js the core's views, which a renderer mounts by id (Views) the view's id and what it needs, which a renderer relies on; the library holds no types for these modules
/xterm.js, /xterm.css, /addon-fit.js, /addon-web-links.js, /addon-unicode-graphemes.js, /marked.js the libraries the tower's own page uses, at the version it depends on none: those are the libraries' APIs. Vendor your own copy when you need one to stay put

Character. Beside the palette and the scales, /design.css holds the tokens a theme sets to reshape every renderer at once, each defaulting to an existing token or a fixed value, alike in both schemes and in more contrast:

Token What it sets Default
--primary, --on-primary the fill of the one emphasized action (button.primary), and its text var(--ink), var(--panel)
--hover the fill under the pointer: rows, menu and palette items var(--panel-2)
--radius-card corners of cards, panels, popovers, dialogs, toasts and the terminal var(--radius)
--radius-control corners of buttons, fields, tabs, segments and rows var(--radius)
--radius-primary corners of the one emphasized action, button.primary (since 2.38) var(--radius-control)
--button-pad a button's padding where its place sets none of its own (since 2.38) var(--sp-xs) var(--sp-l)
--card-surface, --card-hover a worker's card, at rest and under the pointer: a card apart from the sidebar it sits on (since 2.38) var(--panel), var(--card-surface)
--shadow-card a worker's card at rest none
--shadow-lift, --shadow-head a worker's card under the pointer, and the heads of views (a worker's head, a shelf's, the greeting), apart (since 2.38) var(--shadow) both
--heading the colour of headings, signs, the brand and the greeting (since 2.38) var(--ink)
--display-weight the display face's weight, as a number (100 to 900, not a keyword): headings and signs; a sign's number draws 100 heavier 800
--name-weight, --label-weight, --brand-weight names, labels (chips and pills too) and the brand and the greeting, each a number (since 2.38) var(--display-weight), var(--display-weight), calc(var(--display-weight) + 100)
--heading-case, --heading-tracking headings and signs uppercase, .06em
--name-tracking names: callsigns wherever they are drawn .04em
--label-case, --label-tracking labels: .eyebrow, menu group labels, the heads of lists uppercase, .08em
--body-tracking, --body-leading the page's body text: its letter-spacing and its line height (since 2.38) normal, 1.45
--p-plate-mix, --p-plate-edge-mix, --p-plate-text-mix a floor sign: how much of its project's colour fills its plate and edges it (the rest panel), and colours its name (the rest --heading), each a percent; 0% all three draws a quiet sign in the panel's colours 16%, 45%, 45%
--sign-bar, --sign-badge a floor sign's inset bar in its project's colour, its width (0px for none), and the height of the badge its number sits on (since 2.38) 5px, 22px
--side-surface, --side-rule the sidebar's fill, and the rule between it and the main pane (since 2.34) var(--panel), var(--line)
--main-surface, --main-inset, --main-radius, --main-shadow the main pane's fill, its margin on every side, its corners and its elevation: a transparent sidebar and a panel main pane set in, rounded and raised float it over one ground (since 2.34) transparent, 0px, 0px, none
--main-pad how far what the main pane holds (a view's head and body, the shells) sits from its edges and above its foot; it is never rounder than that gap, so 0px runs it to the pane's edges, its corners the pane's where they meet. The page lends it to the views it holds as --pane-pad, which a view's head and body read (var(--sp-xl) where nothing lends it, as in a dialog) (since 2.41) var(--sp-xl)
--dock-surface the main pane's foot, the shells' strip and their pane: its corners follow --main-radius, so on a raised main pane transparent lets it belong to the pane (since 2.38) var(--panel)
--status-edge, --status-ring-mix a worker card's status: the stroke's width on its leading side, and how much of the status colour its other sides mix into the line, a percent; 100% with a thin edge is a full status border (since 2.34) 4px, 0%
--card-glow, --card-glow-mix a worker card's glow at rest: its blur, and how much of the card's status colour it is, a percent (a glow is a blur and a percent, not a colour, for the reason the status ring is) (since 2.38) 0px, 0%
--card-glow-hover, --card-glow-hover-mix, --card-glow-active, --card-glow-active-mix the same under the pointer, and on the selected worker's card: emphasis on what is active (since 2.38) the resting glow
--main-glow, --main-glow-mix, --main-glow-active, --main-glow-active-mix the main pane's glow, in the accent, at rest and while focus is in it (since 2.38) 0px, 0%, then the resting glow
--tree-line, --tree-radius a .tree's lines (a crew hung from its head): their colour, and the rounding of each elbow (since 2.40) color-mix(in oklab, var(--line-strong) 75%, transparent), 7px

.tree (since 2.40) draws a list hung from the row above it, as the page draws a crew under its head: a trunk, and a rounded elbow into each item. It takes its geometry from the renderer, which sets it on the list: --tree-indent (the trunk's place, in from the list's edge), --tree-x (from the trunk to the items) and --tree-gap (between items); and on each item --tree-y (where its elbow turns in, from its top), with --tree-edge and --tree-rim for an item with borders (its left border's width, and its top and bottom borders'), and --tree-style: dashed with a --tree-branch image for a dashed elbow. An item keeps its ::after; the tree draws with its ::before.

A page's terminal takes --enamel (its background), --term-fg (its text) and its sixteen ANSI colours (--ansi-black, --ansi-red, --ansi-green, --ansi-yellow, --ansi-blue, --ansi-magenta, --ansi-cyan, --ansi-white, and each as --ansi-bright-<name>) as the page computes them, so a stylesheet that sets them recolours it (since 2.34). The ANSI colours are alike in both schemes: a theme that wants them per scheme sets them in its scheme's block. npm run tool:contrast measures the role pairs (roles in src/shared/design.ts) as it does the palette's.

A bundled extension's client holds what a renderer draws of that extension. /x/drafts/drafts.js edits a floor's drafts over the generic collection/* verbs: the floor's drafts collection while the extension is on there (draftsOf), keeping a prompt the new-worker form closed on (keepUnsent), and putting a deleted draft back (discard answers what it deleted, restore). wireSpawn of /lib/spawn.js takes it as io.drafts and paletteEntries of /lib/palette.js takes its draftsOf in its context, both from your renderer, so a page runs only the drafts client its provider serves. /x/reviews/reviews.js holds the review threads' format, and /x/policies/policies.js a policy's rule and slots in words and where it stands. clientOf(url, without) of /lib/client.js imports one, and answers without when another extension provides the capability with no such file.

Types outside the checkout

tower types <dir> makes a folder anywhere typecheck against this tower's library. It needs no running tower:

tower types .

It writes <dir>/.tower/: the declarations TypeScript emits for the library and the bundled extensions' clients, those of every package they name (zod and xterm today, worked out from the declarations), and a tsconfig.json to extend. Add this to the folder's own tsconfig.json, which tower types also prints:

{ "extends": "./.tower/tsconfig.json" }
  • What it maps: /lib/*.js, /tower.js (window.tower, with its tower global) and /x/<cap>/*.js for each bundled extension's client, so an extension that wants drafts is typed against drafts' client.
  • What you bring: @types/node, in the folder. Server code needs it anyway, and the tsconfig names it.
  • paths of your own replace the ones you extend, as a tsconfig's paths always do. tower types warns when your tsconfig has them and prints the lines to copy in.
  • Refreshing: run it again after the tower moves. .tower/types/stamp.json names the API version the folder was typed against. The same code gives the same files.
  • Committing them: .tower/.gitignore keeps the folder out of git, since a committed copy goes stale against the tower. If your own CI needs to typecheck, replace that file's contents with the one line !node_modules, which beats a root .gitignore's node_modules so the vendored packages are committed too. A later tower types leaves your file as it is.
  • skipLibCheck is off in the tsconfig you extend, so a package missing from the declarations is an error and not a quiet any. If a package of your own has broken types, turn it on in your tsconfig, knowing that.

The declarations are built by the checkout's own TypeScript, so a checkout needs npm ci with its dev dependencies, and kept in <root>/cache/types/, a cache keyed by the code. A file's path under .tower/types/ is no more contract than its path under src/: import from /lib/.

Collections

A collection is a kind of file a floor keeps, declared in the config with a label and a description of what it is for, every floor's at the top level, one floor's under its project:

{ "collections": { "notes": { "label": "Notes", "description": "What we learned, one markdown file per topic." } } }

Items are plain files at collections/<project>/<collection>/<item> in the system root, in any format. The tower lists them on the board (metadata only), reads them (tower.text('collection/<p>/<c>/<item>')), and creates, writes and deletes them (collection/create, collection/write, collection/delete), and puts a deleted one back under its id (collection/restore, an undo). What a file means is your renderer's business: the tower page reads drafts as prompts and Tower 3D plays games in an arcade, over the same verbs. An extension contributes items with items, a folder of its own per collection: "items": { "policies": "policies" }. The collection is its own, the config's, or one of a capability it requires or wants; one another capability owns is refused (a warning on the extension, the items left out). A collection is then the union of its sources: the user's files, writable, and each contributing extension's folder, read in place and never written, on the floors where that extension is on (since 2.13). The board marks a contributed item from: <cap> and the collection's sources say where its folder is. A user's item of the same id shadows it (shadows: <cap>); collection/write on a contributed item makes the user's copy under its id; collection/delete and tower unkeep refuse one. A worker copies one to edit with tower own <tag>. The folder is read when the tower resolves its extensions, so an edit there shows after tower extensions restart <id>. A contributed policy is offered at its slots until the user approves its words on that floor, as any policy is; its check line runs at each slot before any approval, as trusted as the extension's own code. A tower-wide collection, one of no floor, is declared by an extension with "scope": "system": its items are at collections/_tower/<collection>/<item>, the board carries it in board.collections, and the verbs and reads name its project _tower (since 2.13). drafts itself is declared by the bundled drafts extension; a config line of that name overrides its label and description. /lib/view.js draws any collection's items as rows and trays and reads one by its type, without a meaning, as tower/tray, the tower page's tray of a collection, does (Views). Workers add with tower keep <collection>, and delete with tower unkeep <tag>, which refuses an owned collection with its delete door. reviews is the bundled reviews extension's, owned: one markdown thread per checkout, written only through reviews/append. Each card carries its thread as x.reviews (the checkout it is about, where that work stands, the notes new to it, and its note call while the work is live) and each floor its threads. policies, standing work run at its slots, is the bundled policies extension's: each floor carries its policies (parsed, with where each stands) and open offers as x.policies, each offer also an ask in board.asks, /x/policies/policies.js says rules and slots in words and where a policy stands (standingWords), and policies/run, policies/pass and policies/approve write its facts. An extension may declare collections of its own, which carry its capability as by on the board; one it owns carries owner and doors too, and refuses the generic writes, naming the verb to use instead.

Extensions

An extension is a folder holding extension.json, its manifest, and optionally the server module it names, whose default export is start(ctx). The config adds one by its absolute folder (config.md); the tower reads every manifest before any code runs, refuses what can't load, and starts the rest beside its own pieces, restarting one when its config entry changes. Code edits wait for tower extensions restart <id> (extension/restart): it reads the folder again and restarts the extension with what depends on it, importing its server module and every module it imports inside the folder afresh (its node_modules aside); meanwhile its calls answer unavailable and its state is restarting. tower extensions and GET /extensions say how each stands.

To start from a working one, copy a folder of examples/extensions/ (narrate: Listen on every markdown or text item and file a worker shows, through the browser's speech or a text-to-speech command its settings name, which its server runs with ctx.run and whose audio it serves with a serves: "file" read) and add it to the config by its path. npm test loads every example as tower extensions check does, so each works with the tower it ships with.

{
  "id": "pulse",
  "version": "1.0",
  "title": "Pulse",
  "requires": { "tower": "2.0", "chime": "1.0" },
  "server": "server.ts",
  "settings": { "type": "object", "properties": { "every": { "type": "integer", "default": 60000 } } },
  "verbs": {
    "ping": {
      "input": { "type": "object", "required": ["project"], "properties": { "project": { "type": "string" } } },
      "reply": { "type": "object" },
      "scope": "project",
      "words": { "label": "Ping", "hint": "rings chime for the floor" }
    }
  },
  "reads": {
    "beats/<project>": { "reply": { "type": "object" }, "scope": "project" }
  }
}
import type { Start } from '/lib/extension.js'

const start: Start = (ctx) => {
  const { every } = ctx.settings as { every: number }
  ctx.every(every, () => ctx.log('pulse'))
  return {
    verbs: { ping: async ({ project }, call) => ({ project, chimed: await call.deps.chime!.ring({}) }) },
    reads: { 'beats/<project>': ({ params }) => ({ project: params.project, every }) },
    halt: () => ctx.log('halted'),
  }
}
export default start

The manifest is strict: a key this tower doesn't know refuses the extension, so declare in requires.tower the API version of the newest key you use. start returns a handler for every verb and read the manifest declares, and nothing else, a parse per collection or a reduce per stream it declares, a fold per subject kind it folds, a link per around and an answer per answers entry, launch when it says spawn.launch, and halt. Its ctx holds who it is, its settings (and a floor's, settingsOf), whether it is on on a floor (on), timers cleared at halt (every), the tower's log (log), a signal aborted at halt, the board, its calls, its stores, raise and run. The manifest's keys, the ctx members and the problem codes are part of the contract, held like the library: removing one is a major.

Which version a thing arrived in is the tower's to say. Each manifest key carries it as x-since at GET /schema, under extension: 2.0 for every key 2.0 shipped with, a 2.x minor for one added since. Each core hook under hooks carries the minor it arrived in, a 1.x one included. tower extensions check <dir> warns of every key newer than the manifest's requires.tower (under-declared), naming the keys and the version to raise it to. The declarations tower types writes say it in the comment of each ctx member, and of many of the library's names, a view's kit, the subjects and the board's fields, as @since or as "since" in a type's description; tower api lists each verb with its description, its @since in it where it has one. Every manifest requires tower 2.0 or later, so a 1.x version this document names beside a thing is in every tower that loads it; a 2.x one tells you to raise requires.tower, or is one the tower says nowhere else yet.

Server code reaches the tower's helpers by name, never by a path into its checkout, so a folder copied anywhere still loads: import { mediaTypeOf } from '/lib/files.js' imports the library, the same line a client writes and the same source the tower runs (since 1.151). A module the library doesn't hold fails at import, listing the modules it has. Only the library crosses over: a relative import into the tower's src/ works only from inside the checkout. import type lines are erased before the module runs, so they never break a copy at run time.

Types: inside the tower's checkout, tsconfig.json maps /lib/*.js to src/lib/*, so npm run typecheck checks server code against what it imports. A copy elsewhere types itself with tower types and imports its types from the library, not from a checkout's path. Without that, the editor reports those imports unresolved and the extension still runs.

An extension with npm dependencies of its own declares them in its own package.json and installs them in its folder: its server code and its client's TypeScript, which the tower bundles at serve time, resolve packages from the folder up, so in place they may find the tower's node_modules, and a copy finds only its own (files imports Shiki this way).

requires names the capabilities it can't run without, each at the version it is written for, the core's tower among them: it is refused while one is missing, and off on a floor where one is off. wants takes the same form ("wants": { "drafts": "1.0" }) and names those it uses when they run: it starts without one (ctx.deps.drafts is then undefined), and stays on on a floor where one is off, where it simply finds none of that capability's subjects.

Verbs and reads. Each verb's input and reply, and each read's query and reply, is a JSON Schema the tower parses with, as it parses its own: a verb is POST /<capability>/<verb>, a read GET /<capability>/<path> (its <param>s from the path, its query values strings), and both are listed at /schema. Every verb and read declares its scope, system or project: one without it is refused. A project-scoped verb's input requires project, a project-scoped read names it as a <project> param or in its query, and either is refused on a floor where the capability is off. A handler that throws, or answers off its reply schema, fails that call as internal and lists a problem on the extension; to refuse, it answers an error, {t: 'error', code, message}. A verb or read can be deprecated (since, use, why): its HTTP answers carry Deprecation and a Link to use. tower x lists the running extensions, each with its brief; tower x <capability> one extension's guidance, its words and its raw calls; and tower x <capability> <word> [flags] calls one (below, Words). While the capability isn't running, the name goes to the tower as a verb, which says why it can't answer. A read is a GET too, such as curl http://127.0.0.1:4317/<capability>/<path> (the tower's address is the config's port, which tower whoami names).

Words type an extension's verbs and reads like commands, on the same terms for bundled extensions and yours. Every verb is a word by its name, with nothing to declare; a read is a word when its cli names one, and any read is reached by its path too (tower x policies runs/app --policy nightly). facts/<fact> is a writable fact's door, typed --value …, which is required: --value "" reaches the door as an empty string, which clears a fact that reads a blank as cleared. null stays at the API; a door that takes JSON types it --value null, and a scalar one has no typed form. What tower x <cap> <name> reaches is, in order: a word, a door or verb by its name, then the read whose path matches.

  • Flags come from the input schema, one per top-level field: --re 3, --re=3. A read's are its path's params and its query's fields. A string is taken as typed, even one that starts with --. A number or boolean is converted, or refused naming the field and the type it wants. A boolean is a bare --tell (or --tell=false). An array repeats its flag, --at a --at b. An object or an array of objects takes JSON as its flag's value: that is where JSON stays. -- ends the flags.

  • The caller is filled for every extension. The command sends the worker's session as the caller, and a project-scoped word's project is the caller's floor unless --project names one. Run outside a session, it says --project is needed.

  • cli on a verb or read says the rest, each key optional:

    Key What it does
    stdin The string field that receives stdin verbatim, when no flag gave it and stdin is a pipe or a file (a heredoc, |, <). A terminal, /dev/null or a socket gives no text, so a program that spawns the command and writes to its stdin (Node's spawn or execFile, whose stdin is a socket) passes the text as the flag, a file or a pipe instead. What the text means is the verb's: it may well read JSON. Without it the word takes nothing on stdin.
    positional The fields taken without a flag, in order. Only the last may be an array, which takes all that is left.
    print A reply field to print, a string or lines. Without it the reply prints as JSON.
    usage Its line in tower x <cap>, starting with its word. Made from its fields when left out.
    word What it is typed as: a read's word, or a better name for a verb, which stays reachable by its own.
    "verbs": {
      "note": { "input": { … }, "reply": { … }, "scope": "project",
                "cli": { "stdin": "body", "print": "said", "usage": "note [--re <n>] [--at <where> …]" } },
      "hire": { "input": { … }, "reply": { … }, "scope": "system",
                "cli": { "word": "review", "positional": ["of"] } }
    },
    "reads": { "said/<project>": { "reply": { … }, "scope": "project",
               "cli": { "word": "thread", "positional": ["checkout"], "print": "text" } } }

    So a worker types tower x reviews note --re 3 <<'EOF' … EOF. A word's shape is its verb's: a word that needs a friendlier input than a renderer's is a verb of its own over the same function, never a mode on one verb. No extension code runs in the command, so work on files belongs in the verb.

  • Checked at load. A cli naming a missing or mistyped field, a read's cli with no word, a usage that doesn't start with its word, or a word that another word or name of the extension answers to refuses the extension with the problem cli, at its key. A word's name and shape are names of its contract.json (words.note, words.note.--re, words.note.stdin.body, words.note.positional.0.to, words.note.print.said), so a replacement must offer them.

  • The words are data: GET /extensions carries each extension's words (off the board, since a client reads them only when it types one), so any client can type them.

  • Errors say what to do next. A missing input names it with an example (note needs its body on stdin: tower x reviews note --re 3 <<'EOF' … EOF), a wrong value the type it wants, an unknown word or flag the nearest there is and where to look. tower x <cap> <word> --help lists a word's flags.

Teach your words in your guidance, which is what workers read: use the flags, not JSON. An extension that declares a cli and has no guidance gets the warning cli, at guidance: nobody learns a word that nothing names. For Claude sessions, a skill in a plugin of its own can carry the triggers.

A read that serves a file declares "serves": "file" and no reply: its handler answers { file }, an absolute path, and the tower serves that file as it serves a file a worker showed, through the same path: by its media type, under the same sandbox headers, an html page with the frame keys appended, so a page served this way runs at an origin of its own and reaches nothing of the tower's. Which paths it serves is the handler's responsibility: resolve what the request names, follow its links, and refuse anything outside the scope it means to serve. A read path's last segment may be a rest param, raw/<id>/<file...>, which takes every segment left (one at least) joined by /, so a page loads what lies beside it by relative URL; /schema lists the read as /<capability>/raw/{id}/{file...}, kind file. A subject's text names the read's path, and the view that draws it reads the file there.

Calls. ctx.call('tower/spawn', input) and ctx.read('tower/conversations/<id>', params, query) take qualified names, the core's under tower/, and reach the core, the extension itself, and what it requires or wants; anything else is refused until declared. ctx.deps.<capability> holds the same calls as functions, one per verb and read[<path>] per read, undefined while a wanted one doesn't run. Each answers the reply, or an error as a value; a core read that serves a file (tower/shelf/…, tower/collection/…, tower/shown/…) answers its text as written, and refuses a file that isn't text (an image, a video) as invalid: its bytes are the read's over HTTP. A handler's second argument is its ctx with the caller ({t, id?, via, within}: the user, a worker, the tower, or the extension itself from its start and timers), and the calls it makes carry that caller one step deeper, its verb added to within; past 8 deep a call is refused. ctx.cards() is every card the system holds, the ones the board leaves out included, as the core builds them.

Stores are declared in the manifest and named by the capability. collections join the floors the extension is on, each named <cap> or <cap>.<name>, or with "scope": "system" (since 2.13) are one tower-wide collection under _tower/, which ctx.collections reaches with the project _tower; one marked owned declares five doors (list, read, create, edit, delete, each a verb or read of its own manifest, not deprecated, or a read of the core's such as tower/board, or { "none": "<why the domain has no such act>" }), and the generic writes (collection/*, tower keep) are refused there, naming its create door. streams live at streams/{system|projects/<p>}/<cap>.<name>/, each with a scope and its fact codes (one letter each, with a schema); only the extension appends to them. facts are session facts logged as tower.x.<cap>.<name>, appended to any session whose log the tower holds: a running worker's, or one that exited or that an earlier host ran. ctx.streams.append, ctx.facts.append and ctx.collections write them, each checked by its schema; ctx.streams.read reads a stream over a window; ctx.own reads what the tower folds of them: a stream's reduce state, a collection's items with their parse, and a session's facts over its lineage, all read-only. A reduce's step gets the state frozen and returns a new one; a step that throws stops the fold before that fact, and an item whose parse throws is held with parsed undefined until it changes, each said in the tower's log.

Writable facts put a value on a card with no server code. A fact that declares writable has a door, POST /<cap>/facts/<name> { session?, value }, which logs the value as the fact on the session through the host, as ctx.facts.append does. value holds to the fact's schema, or is null; writable names who may write it: user, a caller with no tower-session, which names the session; self, a worker writing its own, which leaves session out or names its own. Both are claims, as every caller is. The door refuses a write on a floor where the capability is off; its errors are invalid (the body or the value off its schema, a user naming no session), refused (a caller writable doesn't name, a worker naming another session, any other caller: an extension logs its own facts with ctx.facts.append), not_found (no capability, no such writable fact, no session) and unavailable (the capability starting or down). It answers { session, value }. No around link wraps a door: around names verbs and hooks, and a door is neither. A worker writes through it with tower x <cap> facts/<name> --value '…'. A verb's name holds no /, so no verb takes a door's name; a read whose path matches facts/<name> of a writable fact is a conflict warning, reached by GET and never by tower x.

Guidance tells the workers when to use an extension and how. A manifest's guidance holds brief, one line of at most 200 characters, and optionally full, markdown of at most 4000: when to use its doors, verbs and reads, when not to, and how, with the exact commands. tower whoami lists the brief of each running extension on the worker's floor, one line each, and tower x <capability> prints the full text before its doors, verbs and reads, so a worker carries one line until it asks for more. The user's config replaces either and adds to the full text (extensions.<id>.guidance, config); ExtensionView.guidance is the result, on the board and at GET /extensions. A config edit changes it without a restart; workers pick it up the next time they read it.

folds.card.project is the fold that shows it, written in the manifest: { "lines": { "from": "fact:<name>", "pick": "last" } } puts one line on the card, the newest value of that fact over the worker's lineage, and none when that is blank ("" or only whitespace), null or never written. It is one rule: a card's (where the lineage is), the fact a string, the kind holding no x or adds beside it and start returning no fold for it; anything that computes is a fold of the server's. The line lands wherever a renderer draws a card's lines: the page's sidebar row and worker header, Tower 3D's desk panel, tower whoami. examples/extensions/tabline is one: a fact, its projection and a command that asks for the line.

"facts": { "line": { "schema": { "type": "string", "maxLength": 80 }, "writable": ["user", "self"] } },
"folds": { "card": { "project": { "lines": { "from": "fact:line", "pick": "last" } } } }

Fact kinds. A stream's fact code may declare a kind the core folds, its facts then holding to the kind's schema as well as their own. The one kind is tower/rate-limits, a reading of the account's rate limits ({ limits: [{kind, percentUsed, resetsAt?}], extraUsage?, runtime?, command? }, Claude's when it names no runtime), in a system stream: the core folds every started extension's readings beside the sessions' turns' into the board's limits, the weekly budget and /stats. The bundled quota probe (extensions/quota) is one: its u facts are readings naming their command, read by its tick slot for each command whose entry of board.limits has a turnLimits, the newest reading a turn of it took, older than its every. ctx.runtime('claude') says how the config starts a session by its default command (argv, env), ctx.commands('claude') lists every command the config names (name?, argv, env, in argv's order), both refuse a runtime the tower doesn't know, and ctx.run(argv, { …, env }) runs a command with env set over the scrubbed one, so a reader runs Claude as the sessions do.

Limits per command. Limits belong to an account, and an account is reached through an argv command. A reading's command names the one whose account it read; one with no command, like every reading written before readings named one, is the default command's, as the config says when it is read. A turn's reading is its session's command's, by the session's header. board.limits holds one entry per command in argv's order, always, the default command's first: command (absent in single-command mode), rateLimits, rateLimitsAt, rateLimitsFrom, turnLimits and extraUsage. The weekly budget and /stats' budget, weekly and outside are the default command's too. /lib/board.js finds an entry, limitsOf(board, command) and defaultLimits(board), and the limit words in /lib/cards.js take one. A reading naming a command argv no longer holds is no entry's. Set command from ctx.commands, and a reader of several accounts runs one at a time.

Reviewers. The reviews extension hires a reviewer with reviews/hire {project, of, by?, tell?}: a spawn in a fork of the author's checkout whose x.reviews.of is logged before it starts, and whose launch contributor puts it in the author's crew and out of the hiring limits (tower.reports-to, tower.exempt). A card reads it at x.reviews.of (reviewerOf in /x/reviews/reviews.js), its crew and its exempt. floor.git says every dir of the floor is a git repo, so a checkout of it can be forked.

Folds and contributions put an extension on the board. A subject is anything the board shows that extensions add to and commands run on, keyed card:<id>, floor:<project>, board, conversation:<id>, item.<collection>:<project>/<id>, shown:<card>/<at> (a thing a worker showed, at the epoch ms of its card.shown entry), collection:<project>/<collection> and shelf:<project>/<n> (the nth of the floor's shelf), or <cap>.<kind>:<instance>/<key> for an extension's own kinds, which it declares in subjects ("thread": { "in": "floor", "list": "threads" }: the keyed entries of floor.x.<cap>.threads), keyed by the subject the entry was found in (reviews.thread:floor:<project>/<key>), since an entry's own key needn't be unique across floors. Every subject but the board belongs to another, parentOf(subject) in /lib/board.js: a floor to the board, a card, a collection and a shelf entry to their floor, a conversation and a showing to their card, an item to its collection, an own kind's entry to the subject it was found in; subjectAt(board, key) finds any of them on the board now. folds declares, per subject kind, the x schema of its own part and the adds it contributes (actions, badges, tidy on a floor, lines and marks on a card, asks), both optional: a fold that only contributes declares adds alone, with no part of its own, and is the common case. start returns a fold for each but a card's the manifest projects (writable facts), (subject, ctx) => part, pure and synchronous over frozen inputs, ctx holding now, the floor's settings, the core's board, callsignOf(session) (the callsign of the worker any session the tower has known ran as, archived ones too, undefined for an id no log holds) and own, its stores as ctx.own reads them (on a card, its facts over the worker's lineage). After the core's board is built, each running extension folds in dependency order (card, conversations, showings, items, collections, shelf entries, floor, its own kinds, board), on floors where it is on, seeing only the parts of what it requires or wants. Its part lands at subject.x.<cap> (a card, a floor, the board, or an item of a collection it declares), checked by its schema; its actions ({verb: '<cap>/<verb>', call}, the verb qualified, or {command, args?}, the command bare: its own, "command": "speak"), badges ({label, tone?, hint?, href?, icon?}, icon a glyph drawn before the label in its ink, named as a command's words.icon is: badgeGlyphOf(badge) in /lib/layout.js), tidy entries, lines and marks at board.adds[<subject key>], each tagged with its cap; a mark (marksOf(board, card) in /lib/layout.js) is {repo, path, line, to?, label, tone?, hint?, display?} on lines the card's worker changed, repo named as its Changes name it (the main checkout's folder), and the Changes draw it on those lines, saying its hint (the reviews extension marks the lines each note of the worker's thread is about, n3, "noted in n3"); display, a subject key a click on the mark would show, is drawn by no renderer yet; an action may carry words of its own ({label, hint?, destructive?}), over its verb's or command's, so one command offered on several things says which; its asks ({key, subject, title, hint?, since, until?, sound: 'wait' | 'offer', actions, opens?}, hint more about it in words drawn on hover, subject a core subject's key: a card, a conversation, a showing, a floor, a collection, a shelf entry, an item or the board; opens, where going to it leads, see below) in board.asks, keyed <cap>:<key>, which every renderer orders and rings beside the waits. A fold that throws or returns what its manifest doesn't declare costs its part on that subject, and its dependents' there, as a threw or shape problem; an extension whose folds take over 50 ms of one board is slow. Calling ctx.board() inside a fold throws: the fold has its ctx.board.

client names a folder served at /x/<cap>/, with CORS; a <name>.ts there is served bundled as <name>.js, with its own modules and packages, and what it imports from the tower's src/ loaded from the URL the tower serves it at, so it shares one instance with the page. An import of the library (/lib/…), of /tower.js or of an extension's client (/x/…) stays that URL, in a checkout or out of it, so a client outside the tower's folder imports them the same way. /tower.js run on a page that already has window.tower leaves it as it is. Each of commands is one of its modules' exports, with words, which may name its icon: one of the core's icons by name (ICON in /lib/view.js, "play"), or an SVG of its client folder by its path there ("speaker.svg"), which renderers draw as a mask in the ink of the control, so one glyph serves both palettes; a path to no file there refuses the extension. A region drawing commands as glyphs alone (the tower page's shown.tab, inside an open shown tab) takes the label and hint as the tip, and draws the label of one without an icon; glyphOf(board, action) in /lib/layout.js answers {t: 'core', name} or {t: 'svg', href}. Its on offers it on every subject of those kinds with no fold needed ("on": ["item.drafts"], or "item.*" for every collection's items, or "lines", lines picked in a worker's Changes), whether the extension folds or not; one with no on is the palette's alone. Its accepts narrows that to the subjects whose value.type it lists: media types, "text/markdown", or a top-level type's every subtype, "image/*"; a subject with no type is offered none of them. A renderer draws a subject's actions and badges with the library: name the subject (cardSubject(card), floorSubject(floor), shownSubject(card, shown), itemSubject(project, collection, item) and boardSubject(board), in /lib/board.js), then, from /lib/layout.js, addedActions(board, subject) (what extensions offer on it, drawn after the actions a card, a floor or a conversation carries itself), badgesOf and actionWords for a label. To press one, isCommand(action) ? runCommandWith(board, action, subject, kit) : runVerb(action) (runVerb in /lib/board.js): a verb is called with its call, a command's module imported from /x/<cap>/ and its export called with { tower, board, target, args, kit }: kit is what the renderer running it lends, display, toast, notice, confirm, run and bus (CommandKit in /lib/view.js), so "Add to grid" is kit.display(target, { view: 'grid/grid' }). A renderer that lends nothing passes NO_KIT (/lib/layout.js), whose every member fails, naming itself. notice(text, action?) is a toast that stays while what it tells goes on, standing above the toasts that leave until the command closes it: it answers { say(text), close() }, and its action's button runs the action and leaves the notice for the command to close (narrate's memo with Hear, on a page that can't play sound yet; a control a notice can't hold, such as narrate's speed menu, is an element of the command's own). bus is the page's viewer subjects (the bus): a command on a section reads its document's other sections with bus.under(target.value.of, 'section'), and marks what it acts on. A renderer whose regions hold no commands draws none: heldActions(region.holds, actions) leaves them out, as Tower 3D's desk does. A command's keys are its default chords: see Views, keys.

target is the subject, { kind, key, project?, value }. The value is the card itself on a card (id its session), the floor on a floor, the board on the board, { ...shown, card, project } on a showing, { ...item, project, collection } on an item, { ...collection, project } on a collection, { ...entry, n, project } on a shelf entry, { ...conversation, card, project } on a conversation, and the entry on an own kind. A subject whose content is text or a file says where it is: an item and a shown file carry text, the path tower.text reads it at (collection/<project>/<collection>/<id>, shown/<session><target>), and type, its media type by its file's extension (text/markdown, image/png, application/octet-stream when the tower doesn't know it). An address a worker showed, a url or a link, carries itself as its body and the type text/uri-list. textOf(tower, target) in /lib/board.js reads a subject's text: its body when a renderer hands the text itself, else what text reads; it throws on a subject that bears neither, so a command that reads text declares accepts.

Not every renderer draws every subject or every contribution. Each declares where it draws in its renderer.json (Your own renderer): its regions, each for one subject kind, holding some of verbs (actions that call a verb), commands (actions that run a client command), badges, lines, marks, tidy, asks and views (the tower page's main pane hosts them, Views). tower extensions check <folder> says where each of your commands and contributions lands in every renderer the config declares; this table says it for the ones that ship, generated from their declarations:

Subject The tower page (page) Tower 3D (tower3d) The Week (week) The tower command (cli)
card card.row, the worker's row in the sidebar: badges, lines
card.head, the worker's header, and the palette: badges, lines, verbs, commands
card.panes, the worker's tabs (terminal, brief, changes, reviews, shown files): views
card.composer, at the foot of the worker's Brief, under its latest turn: what writes to the worker: views
card.desk, the worker's panel at its desk: badges, lines, verbs not drawn card.whoami, under the worker in tower whoami: lines
conversation conversation.head, the conversation's heading in the Brief: badges, verbs, commands conversation.head, the conversation's heading in the logbook: badges not drawn not drawn
floor floor.sign, the floor's sign in the sidebar while the floor is open, and the palette: each command its icon alone, its label and hint the tip: commands
floor.section, the floor's section in the sidebar, its Tidy and the palette: badges, verbs, asks, tidy
floor.console, the floor's Tidy: tidy not drawn not drawn
shown shown.head, beside the worker's tabs while the showing is open: badges, verbs
shown.tab, inside the showing's tab while it is open, before its ⋯: what is pinned of its menu, an extension's command or one of the menu's own lines (out, a file's reveal and edit, worker; a link's tab no out), each its icon alone, its label and hint the tip; the rest tucked in the ⋯, which pins them: commands
not drawn not drawn not drawn
lines lines.acts, under lines picked in a worker's Changes: what acts on them, a review's note box among them: commands, views lines.acts, under lines picked in a worker's Changes at its desk: what writes a note on them: views not drawn not drawn
said said.acts, beside a prompt's or an answer's copy in the Brief: commands not drawn not drawn not drawn
section section.acts, in a gutter beside a markdown document, level with each of its sections: commands not drawn not drawn not drawn
passage passage.acts, over a markdown document, a text file or a page a worker showed, under text picked in it: what acts on the passage, asking its worker about it among them: commands, views not drawn not drawn not drawn
item.* item.head, the item's view, the drafts editor for a draft, and the palette: badges, verbs, commands not drawn not drawn not drawn
collection floor.trays, a floor's row of trays in the sidebar, one view for each of its collections: the id names where it sits, its subject is the collection: views not drawn not drawn not drawn
shelf not drawn not drawn not drawn not drawn
board board.main, the main pane (a worker, the skyline, a floor's archive, a collection, a shelf entry): views
board.dialog, over the page, modal: a view to read or act in while the page goes on behind it, opened by display with that view, closed by its close button, Escape or a press outside: views
board.strip, a strip at the top of the sidebar, its view mounted for as long as the page is open: what an extension keeps in sight, or plays, whatever the main pane shows: views
board.sections, the sidebar's sections, between the limits and the floors: every view offered, each under a heading with its tally, folded to it or open, in the layout's order: views
board.nav, the sidebar's row above the floors: Floors first, then an entry per view on the board the main pane draws that asks for the row, each opening it there, marked while it is open; past its budget, the rest behind More…: views
board.sign, at the end of the sidebar's entries row, and the palette: commands about no one floor, such as a new floor, each its icon alone, its label and hint the tip: commands
board.skyline, in the skyline's greeting, the welcome on a new tower included: commands about no one floor, each its icon and label: commands
board.notes, the notes at the top of the sidebar, for asks about no floor: asks
not drawn not drawn not drawn

An extension's own kinds are drawn by none of them (subjectAt finds one, for a renderer of your own). A renderer whose regions hold commands also lists the actions on the subject in focus in its palette, and runs there the commands that have no on.

An ask (board.asks) is listed with the waits by the tower page, under its floor or, for the board's, at the top, and said, notified and rung there and in Tower 3D. The Week draws no contributions. A renderer of your own draws whatever it reads.

Where an ask leads. Going to an ask opens its subject: a worker, else its floor. An ask answered in a view of its own says so with opens: {view, subject?}, a view by its id and the core subject's key to open it on, the board with none, any extension's view or the core's. Next-waiting and a click on its notification go there, and a viewer already on that view and subject is at the ask, so next-waiting moves past it. The page's ask row still opens the ask's subject. The policies extension's offers name {view: 'policies/policies', subject: 'floor:<id>'}. A renderer of your own follows it or doesn't.

A command is an action: a place of its own on screen is a view (Views). Its module is imported once per page and stays loaded between presses until the page reloads (tower extensions restart doesn't reach a page already open), so it may keep state in the module. It runs in the renderer's document at the tower's origin: it may add elements of its own, such as a dialog or an overlay, which the renderer doesn't know of, so it removes them when done; it leaves the renderer's own elements alone. A pane of your own is a renderer the config declares (its folder may sit in the extension's), framed on a floor's shelf as a renderer entry (Shelf pages): an extension can't declare a renderer or a shelf entry, so the user adds both to the config.

To show a worker's terminal, mountTermView(host, xterm, io) from /lib/terminal.js runs one on a terminal/<id> stream. In the tower page, xterm.js is loaded as globals: pass { Terminal, FitAddon: FitAddon.FitAddon, WebLinksAddon: WebLinksAddon.WebLinksAddon, UnicodeGraphemesAddon: UnicodeGraphemesAddon.UnicodeGraphemesAddon }. Elsewhere, load /xterm.js, /addon-fit.js, /addon-web-links.js, /addon-unicode-graphemes.js and /xterm.css first, or a copy of your own; without WebLinksAddon, only hyperlinks a program marks (OSC 8) are links, not the addresses it writes. Without UnicodeGraphemesAddon, xterm.js gives most emoji one cell where Claude Code gives them two, and an emoji-heavy screen draws misaligned: stray characters after an emoji until the next full redraw. The view turns on xterm.js's allowProposedApi, which the addon needs. A link opens in a new tab, if it is http(s). Given io.files, the file paths written in the terminal are links too, read from its cwd() and opened with its edit (the tower page calls the edit verb, which opens the user's editor at the path's :line). io (TermViewIo in /lib/terminal.js) is what the view needs of your renderer: watch(on) streams the PTY's messages and answers a function that stops, resize(size) and send(data) reach the PTY, wheelReports says whether its program reads the wheel as wheel reports (Claude's fullscreen does), scrollback, font() and scheme() give its look, mode(m) hears how it holds the PTY (owning its size, watching, or exited), end(msg) its exit or stream error, and error(err) a failure of the view's own; upload and files are optional. Its keymap and run are a renderer's keymap: run gets the id of each command the key runs, an extension's <cap>/<name> too (API 1.159), and answers whether it did something; when it didn't, the key goes on to the terminal. A command that is not the renderer passes keymap: () => board.keys and run: () => false, which sends every key to the PTY.

Views

A view is a module that draws one subject into an element a renderer gives it, the core's and an extension's alike: the tower page mounts one in its main pane at a location, so a reload, a link and Back keep it. examples/extensions/grid is one to copy. The manifest declares each by name, served as <cap>/<name>:

"views": {
  "grid": {
    "module": "grid.js", "export": "mount",
    "on": ["floor", "board"], "shows": ["card"], "scales": ["pane"], "needs": ["region", "display"],
    "regions": ["card.cell"], "words": { "label": "Grid", "hint": "Workers side by side" }, "keys": ["Meta+Shift+G"]
  }
},
"regions": { "card.cell": { "subject": "card", "holds": ["views"], "scale": "cell", "arity": "one" } }
  • on: the kinds it mounts on; a region offers it on those, and only at a scale in its scales. item.* is every collection's item and collection.<id> one collection alone: the drafts editor is on item.drafts and on collection.drafts, a new draft, and a collection's view draws a + for the view on it alone. shows: the kinds it is handed through show while mounted on one above them (a card, to the grid on its floor), never mounted on.
  • accepts: for a subject bearing a type (a shown file, an item), the media types it draws.
  • needs: the kit members it can't draw without. options: the JSON Schema of its options in a region's layout, which tower config check holds the config's layout to.
  • regions: those it declares inside it, each in the manifest's regions by id. One id has one meaning: two extensions declaring it with other fields are both refused. A region it declares may carry its default layout: order, hidden and each view's options, as a renderer's layout writes them. Pins, the form and budgets are the user's, and a manifest naming them is refused. It is the bottom layer, under the renderer's own (renderer.json), the config's and the viewer's, each field taken from the highest layer that sets it and hidden from all of them less a view a higher layer orders: declaredLayout(board, declared) in /lib/layout.js lays the defaults of every started extension under a renderer's own, for layoutOf. So the explorer's file.open draws code with its own view, and a user's config line takes it back. An extension lays out only its own regions: the board carries no extension's layout of a region a renderer declares (card.head, card.panes), and tower extensions check and the board warn about it.
  • keys: default chords that display the subject in focus with it. On a view that is a worker's tab (on holds card, scales holds pane), a chord that stays bound makes the tab a pane, with nothing else to declare: panesOf(board) in /lib/keys.js lists it, and the tower page keeps the tab fixed in the row, names its chord in the tab's tip, lists it on the ? sheet and in the palette, and opens it the way ⌃⇧1 opens the terminal, from a terminal too: on the worker in focus, else the main pane's, focus landing on the tab. With no worker on screen the chord does nothing, unless focus is on another subject the view is on. A view on a card that already had a chord behaves this way with no edit of its own. A view's kit.run(id, subject) still displays that subject with it. A renderer that draws no views, such as Tower 3D, opens only the panes it knows by name, so the chord does nothing there.

An extension's settings reach its client on the board, with no server code: settingsOf(board, 'grid') from /lib/board.js reads them as they stand, its schema's defaults filled in, and floorSettingsOf(board, 'grid', floor) reads them on one floor. A view hears a change in its update. They are settings and floorSettings on each entry of board.extensions, for any renderer or worker to read. Change one through the config verbs: config/add at extensions.<id>.settings.<key> when the config doesn't hold it yet, config/set when it does. Settings never hold a credential (the config): an integration that needs one keeps it in the script or command its settings name.

Its module's export is mount(host, ctx), returning (or resolving to) { update(board, subject), show?(subject), visible?(on), tab?(), options?(options), close() } (Mount in /lib/view.js); options takes its options as they stand now, drawn in place, and a view without it is mounted afresh when they change. ctx is { tower, board, subject, kit, state, options, scale?, scope, args? }: state is tower.store under view.<id>.<key>, the view's own; scale, the scale of the region it is mounted in, where it declares one (pane in the main pane and a worker's tabs, cell in a grid's cell); scope (since 2.18), a name of this mount unique on the page (v7), which a view that can be mounted twice at once (a worker in the main pane and in a grid cell) puts first in the place of every id it spells, domId(scope + '/row', key); args, its location's (a shelf entry's file); kit is what the renderer lends, terminal(host, path) (a terminal on terminal/<id> or shell/<id> with the renderer's xterm, font, scheme and keymap, or on job/<id>, a job's screen, read only and at the job's size), href(to) (the hash of the renderer's page that displays to, a subject, or goes to to, a location, when a link takes the page there, for a link drawn in a frame where nothing runs, which can only navigate: for a subject, the location it is displayed at, which a reload reads again; optional: no view needs it, and in a renderer that doesn't lend it tower/document and tower/shelf draw the links they would place, to another file, as refused, the rest of each view as before), showing(subject) (told by a view that shows a subject below its own, such as a file its tree opened: in a tab the location names, the location then names it in the pane's shows, so a reload, the history and a copied link land on it; optional, called as kit.showing?.(…)), location() (where the renderer is now, the Location its main view is at, read-only, for a view that marks what is open, such as a tray's row; the renderer calls update again as it changes; optional as href is), region(host, id, subject, options?) (one of the renderer's regions inside the view, filled the renderer's way: what extensions add to the subject, run by its presses, such as item.head; or, for a region holding views, the views the layout picks mounted in it, a tabs region's tabs among them, options by view id over the layout's; for a region of contributions, options is { omit }, the commands (<cap>/<name>) it leaves out; it answers { update(subject), show?(subject), visible?(on), options?(options), close() }, passing show, visible and new options on to the views it holds), run(command, on?) (a keymap command, spawn the new-worker form on a floor or a draft, or <cap>/<name>), spawn(on) (the same form on the floor on is or is of, or on a draft, for a view that keeps its place, as the grid's New worker… does: it resolves with the id of the worker it started, which the renderer awaits as it arrives, so display('card:<id>') lands on it, or with nothing once the form closed without one or the view closed first (the renderer then goes to the worker), or when on is of no floor on the board; a form already open is brought back, answering nothing; where run('spawn', on) goes to the worker, it stays; optional as href is), now() (the renderer's clock, in ms since the epoch, which a view stamps what it reads with, so a renderer whose clock is pinned shows how long ago it read the same on every load; optional as href is), display(subject, { view? }), go(location), bus (below), toast(text, action?), notice(text, action?) (a toast standing until closed) and confirm(text, verb). The renderer calls update on each board, show with a subject below the one it is on (true when it took it), and close as its location leaves or its subject leaves the board. A view draws only inside its host, which carries data-view="<id>", with styles scoped :where([data-view="<id>"]) over /design.css's tokens, brought in a <style> inside its host through viewCss, or viewLayer for rules it writes whole and componentsLayer for the shared components it draws (panelsCss, itemsCss, markdownCss): they put the view's rules over the renderer's own sheet when the renderer brings it through rendererLayer, and the shared components under it, whatever their selectors weigh; a <style> with neither outweighs both. A pane may run what it holds to its edges (a theme's --main-pad: 0px): a view's body that meets them, the panel that fills it, draws its border --fit-hair wide and its corners --fit-inner, and whatever meets the pane's top (a head, or the body when there is none) takes --fit-outer on its top corners. There they vanish, square off and take the pane's radius; elsewhere they are today's 1px and --radius-card. viewCss declares them, and a view that writes its rules whole declares PANE_FIT on its element (since 2.41). What sits inside the body (a card, a field, a tile) keeps its own look. A view never imports another view; it keeps its state in ctx.state; it wires its own presses; and it calls verbs only on a press inside it. A view whose module doesn't load, lacks its export, throws or hasn't mounted in 10 s is one line where it would draw, and the page goes on. A view that keeps something in the viewer's record (a dismissal) sets it with tower.store.set, and every renderer that keeps that record hears it through tower.store.on.

The core's views are modules too, served at /x/tower/<name>.js: tower/skyline on the board, tower/archive on a floor, tower/collection on a collection, tower/tray on one at row and tower/shelf on a shelf entry, beside the drafts extension's drafts/editor and the policies extension's policies/policies on a floor. Each is an entry of viewsOf(board) in /lib/layout.js, the core's first, with its module, export and needs, and a renderer whose kit lends those hosts it as it hosts any extension's.

Trays. The tower page draws a floor's collections in floor.trays, a row of trays under its workers: a region whose subject is the collection (its id names where it sits, on the floor), at row scale, drawn once for each collection of an open floor. tower/tray, on collection, draws any collection: its count, unfolding to its newest items and a way to all of them in tower/collection. An extension draws its own collection's tray with a view on that one collection, collection.<id> at row, and it is picked over tower/tray there with no layout line: a subject that bears no type is drawn by the layout's order first, then the view of the extension declaring its collection when that view is on its exact kind (collection.<id> for a collection, item.<id> for an item), then the first offered, the core's first. The same rule holds in the main pane: display of the drafts collection with no view opens a new draft in drafts/editor, so what means the whole listing names tower/collection. The drafts, reviews and policies extensions ship drafts/tray (with a + for a new draft), reviews/tray (the threads by checkout) and policies/tray (counts, opening Policies). A tray draws its button, and its unfolded part in an element of class tray-open, which the page lays under every tray of the row; one with nothing to show draws nothing. The page's renderer.json orders the row (floor.trays' order: the rows drawn by a view it names first, in its order, the rest in the floor's collection order), and its own trays (worktrees, stranded workers, the archive, Tidy) come after the collections'. mountKeptTray of /lib/view.js is tower/tray's shape, for an extension that draws its collection's tray as any collection's with its own icon, titles and actions.

Hosting views (API 1.160). viewHost in /lib/view.js is what mounts views, the page's and a sibling's alike:

const host = viewHost({
  tower, board: () => latest, views: () => viewsOf(latest), layout: () => layoutNow, declared: () => myRegions,
  kit: ['region', 'toast'],                  // your renderer.json's kit: a view needing more isn't offered
  lent: { toast },                           // the kit members you have; one left out throws naming itself if called
  fills: { contributions: drawMyContributions }, // the regions you draw your way; `tabs` if you declare a tabs region
})
const hosted = host.mountView(view, el, subject, { scale: 'pane', options: {} }) // a view you picked
const region = host.region(el, 'lines.acts', subject, {})                        // the one the layout picks

The host follows nothing. On each board call update(subject). A view starts seen: call visible(false) only when you hide one and keep it mounted, visible(true) when you show it again; a renderer that closes what it hides never calls it. Whoever mounts closes: close() ends the view, its terminals, its inner regions and what it published on the bus, and leaves el yours to empty or remove. .view-failed and the flex chain a column view expects from its parent (.view-root) are your stylesheet's too. Modules are imported by their whole address, so a host works in a classic script framed at an opaque origin, in Chrome as in WebKit.

ask(text, verb) in /lib/chrome.js is the page's confirm dialog, for any renderer: lend it as confirm: ask. It makes its own <dialog> and look from /design.css, works in a frame, and asking() says whether it waits, so your keys stand back.

The worker view. tower/card on a card draws its head and declares card.panes, its tabs, which it asks the kit for as a region. A tabs region's tabs are (view, subject) pairs: the views on the card (tower/terminal, tower/brief, tower/changes, the reviews extension's reviews/thread, then any of yours on card, in the layout's order), then one per thing the worker showed, by the view its type picks (below), or by another view that takes its type when the location's tab names one (Open Text on a markdown file). A tab mounts the first time it is opened and then stays mounted under the one shown, told visible(false), so a view that reads only while seen (Changes' poll) stops there. A view on card has a tab where its tab export (named in its manifest, "tab": "tab") answers, from the board alone, { text?, tip?, tone?, hint? }: text the tally beside its label, hint the tab's tip; undefined is no tab on that worker (Reviews where reviews is off). A mounted view's tab() answers it from what it read, and it dispatches a bubbling tab event on its host when that changes. show(subject) reaches a tab through the card: display of a conversation opens the Brief, of lines (linesSubject in /lib/board.js, a viewer subject: a card's repo, path and line range) Changes at them, of a showing its tab. The tower page fills a region in the elements of the host marked data-holds when it has them: card.head's badges, lines and actions each where tower/card places them, card.panes' tab strip (tabs) and its views (views). It keeps the last four workers left drawn and hidden, told visible(false), so one is as it was left when gone back to.

Picked lines. Lines picked in a worker's Changes are a lines subject (linesSubject in /lib/board.js: the card, the repo, the path, the range and the lines as they read, quote), which only the page that picked them holds. Under them the Changes ask the kit for lines.acts, a region holding commands and one view at row scale: a command on: ["lines"] runs on the lines, and a view on: ["lines"] is drawn there, as the reviews extension's reviews/composer writes a note on them. A view there that is done with the lines (a note added, or cancelled) dispatches a bubbling done event on its host, and the Changes let the pick go. Lines can be picked while the worker's checkout is live and something is offered on lines, a view or a command; nothing else in the Changes knows what acts on them. A viewer kind, lines, file, said or section, is one a view, a command or a region may be on; a fold on one is refused, since the board never carries the subject to fold.

The composer region. At the foot of a worker's Brief, under its latest turn, the tower page asks the kit for card.composer, a region holding one view on the card at row scale: what writes to the worker. A view on: ["card"] with scales: ["row"] is drawn there at its natural height, up to the smaller of 320px and 40% of the Brief, then scrolls inside; with none offered, or the layout hiding it (layout["card.composer"].hidden), the Brief keeps no room for it. Whether the worker takes a prompt is the card's prompt verb (callOf(card, 'prompt')), and the call is submit/at-prompt, which says why it refused (The API). A draft kept across reloads goes in tower.store, by card. Tower 3D draws no card.composer. examples/extensions/chat is one to copy: a text box that sends with the keymap's submit chord and says each refusal's message under it, keeping the text.

The dialog region. Over the tower page, board.dialog holds one view on the board at dialog scale (API 2.31): a modal for reading or acting in while the page goes on behind it, a worker's terminal still running under it. A view declares it by its scale, as for any region, and lists pane beside it:

"center": { "module": "center.js", "export": "mount", "on": ["board"], "scales": ["dialog", "pane"], "words": { "label": "Learning center", "hint": "…" } }

It opens the way a main-pane view does, by display with the view named: kit.display('board', { view: 'guides/center' }) from a command, the view's chord, its palette line or "Open ". The page opens the dialog on it, titled by the view's label, and leaves the main pane and the location as they are, so a reload closes it. Its close button, Escape and a press outside close it, and display of anything else does too; focus returns to where it was. While it is open the page behind is inert and its shortcuts don't run. A view there reads ctx.scale === 'dialog' to leave out a title and a close of its own. A renderer that draws no dialog, Tower 3D or one of your own, offers the view at pane in its main region instead, which is why a dialog view lists pane too: one with dialog alone is offered nowhere there. extensions/guides is one to copy.

The sidebar's sections. Between the limits and the floors, the tower page draws board.sections, a region of arity all at list scale (API 2.32): every view on the board it offers, each a section of its own under a heading with its label and tally, in the layout's order, less its hidden. tower/waiting (who waits on you and what asks, the list N walks) is the first; a view of yours lands after it by declaring the scale:

"queue": { "module": "queue.js", "export": "mount", "on": ["board"], "scales": ["list"], "needs": ["display"], "words": { "label": "Queue", "hint": "…" }, "tab": "tab" }

Its heading's tally is its tab, the same words a worker's tab reads: the module's export from the board alone, then the mounted view's tab() when it has one, drawn again on its bubbling tab event. A tab that answers undefined leaves the section undrawn for now (Waiting with nobody waiting), its view still mounted; a view with no tab export is always drawn. Each view is mounted once and kept while offered; the page caps a section's height, so a view scrolls inside its host. The viewer folds a section to its heading, which tells the view visible(false), and turns one off in Settings → Sidebar; both go to their layer of the layout (folded, hidden), and the config's renderers.page.layout["board.sections"].folded folds one by default. list is no row: board.strip never offers a list view, and a renderer with no list region offers it nowhere (sectionViews(placing, region) in /lib/layout.js lists what a region of arity all draws, for a renderer of your own). A tower older than 2.32 refuses the scale, so declare requires.tower: "2.32". An extension's own regions are one or tabs.

The sidebar's entries. Above the floors, the tower page draws board.nav, a region of arity all at pane scale that opens in board.main: Floors first, the way home to the skyline, then an entry per view that asks for the row. To get an entry, give a view on board at pane the key "optsInto": ["board.nav"] (and requires.tower: "2.35"). The region is optIn: it offers only the views that name it in their optsInto, so the row isn't crowded by every board view an extension declares; the palette still offers each one as "Open ". A press displays the view in the main pane, and the entry is marked while the main pane shows it; the view's tab export, read on the board, is the entry's tally. tower/stats and the Learning center are entries by default. The row draws its views budget in place (4) after any pins, and the rest behind More…, which opens any of them and pins any entry to the row; More… is marked while one behind it is open. The layout's order, hidden, pinned and views, in the config's or the viewer's renderers.page.layout["board.nav"], arrange it, and overflow: "wrap" draws every entry. A renderer of your own lists the entries with placedEntries(placing, region), and reads opens for where they go and optIn for a region that offers only the views asking for it (offeredIn already applies it).

The bus. What a view draws that the board never carries, and that a user can still point at, is a viewer subject: a prompt or an answer in the Brief (said), a section of a markdown document (section), lines picked in Changes. A view publishes one on kit.bus, { publish(subject, of), clear(key), at(key), under(of, kind?), on(kind, fn) }, under the key of the subject it is of: the renderer holds one bus per page, so four grid cells each drawing a document hold four sets of sections, each under its own showing. The renderer resolves a key through it after the board, so a command pressed in a region on the subject, a chord pressed with the focus there, and display(key) all reach it; what a view published is cleared when it closes. busOf() in /lib/layout.js makes one for a renderer of your own.

A mark says what is happening to a viewer subject now, as one capability sees it: bus.mark(key, cap, { label }) puts it, bus.mark(key, cap, undefined) lifts it, and bus.marks(key) answers each capability's, { label, cap }. Marks are held by key, apart from the subjects, so a view that draws its subject again (a document opened anew) draws its marks too; onMark(kind, fn) tells fn the key as a mark on a key of that kind is put or lifted, until the function it answers is called. Whoever puts a mark lifts it: narrate marks the section it reads Listening, moves it as it reads on, and lifts it as it stops. tower/document and tower/shelf draw a marked section marked, its row lit and labelled with its marks, its part of the frame lit; other views draw no marks yet.

  • said: saidSubject in /lib/board.js, keyed said:<session>:<conversation>:<startedAt>:<side>, of its conversation, carrying its words as body and the type text/markdown. side is prompt, answer, or step.<n>: Claude's words between tool calls, or a message it sent, the nth of the turn's steps. The Brief asks the kit for said.acts beside each copy button, where anything is offered on said, and takes show(said), scrolling to it.
  • section: sectionSubject in /lib/board.js, keyed section:<of key>#<n>, of the showing or item the document is (value.of), carrying heading, its markdown as body and the document's type. A document splits before each heading of the shallowest level that occurs more than once (a document under one # title splits at its ##s), the text before the first such heading section 0 (left out when it is blank), and each section is named once ("Notes", "Notes · 2"). /lib/markdown.js splits a document so: sectionsOf(text) its sections, sectionsHtml(text, url) each one's html to frame without scripts, and sectionLabels(sections) each one's name. Anything in that html besides what draws the section is unspecified and may change in any version: don't parse it.
  • passage (API 1.170): passageSubject(passage) in /lib/board.js, keyed passage:<of key>#<from>-<to>:<hash>, text picked in a markdown document drawn by sections or a text file drawn as written (tower/text: plain text, source code, JSON), of the showing or item it is in (value.of). Its Passage carries quote (the words as the frame draws them, also its body, typed text/plain), and from and to (its source lines: in a markdown document those of the blocks it starts and ends in, in a text file exactly its own), and for a showing of a file card and file, the worker that showed it and the file's real path. The core's views read a pick's lines from what they drew; how is theirs, not part of the API. When a passage settles, tower/document, tower/shelf and tower/text ask the kit for passage.acts: commands and one view at row scale, drawn in a box over the frame, under the passage or over it where there is no room below. A view there that dispatches a bubbling done lets the pick go, and so do a click outside the box and a click in the document. The bundled quote extension's composer asks the worker that showed the file about the passage, a code file's quoted in a fence.

tower/document draws each section in its frame and, beside the frame in the page's own document, a gutter of one row per section, level with it as the document scrolls or resizes and never over the row before it: each row is labelled with its section's heading from the source and is a section.acts region, so a command on: ["section"] lands under every section (narrate's Listen reads that section alone, its From here that section and the rest) and show(section) scrolls the frame to it. tower/shelf draws an md entry's file the same way, its sections of the file, keyed shelf:<project>/<n>/<file>. The gutter is hidden while nothing is offered on sections, and it holds contributions only: its rows are placed by sections it doesn't size, so a view's own height would run past the next one. A frame where nothing runs hears nothing: WebKit (Safari, Tower.app) calls no listener in a document that can't run scripts, even one the page added. So the view writes where each link goes as it draws the document, by one rule: a #fragment stays in the frame, landing on the element or heading (by its GitHub slug) it names; a web or mail link opens a tab of its own; a file of a shelf entry opens in place by the shelf's location; a relative link in a file of a worker's checkout takes the page to the hash kit.href gives the file it names (below); any other link loses its href, its title saying why: a relative link in a showing or a kept item among them. The frame is sandboxed allow-top-navigation-by-user-activation for the links to the page, and what in a document could hold one of its own (a nested frame, an object, an embed) is emptied, and a <base> or meta refresh removed, before it is drawn. The gutter follows the frame's scroll position from the page, each animation frame while the view is seen, and the frame's selection is read from the page too (a shared machine says when it has stopped changing long enough to be a pick, since nothing is heard in the frame); the passage picked is lit by a highlight (::highlight(tower-passage), the frame's ::selection the same color), not by an element written into the document. Keys pressed with the focus in a document frame reach the page's keymap in Chrome only: in WebKit a click outside the frame gives the page its keys back.

A worker in a view of yours. Declare a region on card holding views at cell scale, one at a time, as the grid declares card.cell, and ask the kit for it on a card: kit.region(el, 'card.cell', card, { 'tower/card': { head } }). The renderer mounts tower/card there at cell scale, its tabs a tabs region of their own (their open tab the cell's, not the location's), and its head unless head is false; at cell it draws no close, which would leave your view for the skyline. update the handle with the card on each board and close it as the cell goes. A tab's chord acts on the worker whose cell holds the focus.

At cell the worker's head is compact, and with head false it is one row: the lamp, the callsign, the tabs. Your view speaks to it through the rest of tower/card's options:

  • acts: [{ id, label, tip?, icon? }], your own controls at the end of its head (icon a name of ICON in /lib/view.js, drawn in place of the label). A press dispatches a bubbling act event on the card's host, detail.id the act's.
  • pick: { label, tip?, choices: [{ id, note? }] }, the callsign as a menu of the workers whose card ids you list, each with its lamp and its note (else its status). A choice dispatches a bubbling pick event, detail.id the worker picked.
  • omit: commands (<cap>/<name>) its head leaves out, such as one of yours that would add the worker where it is.

Listen for the events on the element you gave the region, and hand the handle new options with options(next) (the same shape as kit.region's): the card draws them in place, keeping its tab, scroll and terminal.

Views by type. A kept item and a thing a worker showed are drawn by the view that accepts their type (value.type, the media type of the file's name, mediaTypeOf in /lib/files.js), each on item.*, shown and file: tower/document markdown (in a frame where nothing runs: raw HTML kept, images read beside the file, its sections taking commands beside it), tower/html a page framed at an origin of its own, tower/image image/*, tower/video video/*, tower/text text/*, JSON and NDJSON as written (code is text/plain), and tower/file, which accepts nothing, the fallback that leaves a file to Finder and the editor. tower/link, on shown alone, takes text/uri-list, an address a worker showed: a url framed as it is, a link as a page whose one click opens it. An address is text, its body: tower/text draws it as written (Open Text on a url), and an order taking text/* takes addresses with the rest. Each draws its body in its subject's frame: a kept item's under one head (the collection, the tag, the file, who kept it, item.head's region, a new tab, Delete and the close, with a way back to the view of the floor the collection's extension declares, the policies extension's for a policy); a showing's or a checkout file's alone, filling its tab, whose head is the tab strip's shown.head and the tab's own shown.tab. pickView decides among the views a region offers: the region's layout order among those accepting the type; else the view of the extension that declares the item's collection, on that exact kind (drafts/editor on item.drafts); else the core view whose accepts fits most specifically (text/markdown before text/*); else the most specific of the rest; else a fallback. So a view of yours for a type no core view takes (application/wasm, say; text/*, JSON and NDJSON are tower/text's) draws it by being installed, and one for a type the core draws takes it over through the layout: in the main pane for items, in the worker's tabs for showings, the region's whole list since order also places its tabs:

"renderers": { "page": { "layout": {
  "board.main": { "order": ["mydocs/markdown"] },
  "card.panes": { "order": ["tower/terminal", "tower/brief", "tower/changes", "reviews/thread", "mydocs/markdown"] }
} } }

A file in a worker's checkout is a viewer subject of its own, file:<card>/<repo>/<path>, made by fileSubject({ card, project, repo, path, file, text, type }) in /lib/board.js, a child of its card: repo named as a review anchor names it (repoName), file its absolute path, optional (the Finder and editor buttons of a file left to them), text the read path its content is served at (an extension's read that serves a file, above) and type its media type. A view of yours that finds a file hands it to a region on file it declares, and the layout picks among the views on file the one that draws it. The core's views by type are on file too, so it is drawn like a showing; a view of an extension's for a type (the files example's files/code) takes over where the layout names it first. fragment is where to open it, a heading's slug or an element's id, which tower/document scrolls to. A relative link in a markdown file of a checkout names another file of its repo: linkedFile(from, href) in /lib/board.js resolves it (undefined when it climbs out of the repo), and tower/document links it to the hash kit.href gives it. Display walks up to its card, whose tabs hand it to a view that shows: ["file"], as the files example's explorer does to open it in its tree; the location names the file in its pane (shows, the link's fragment its arg), so the link is an address a reload or another tab reads again.

What the pick passes over is offered as "Open ": on a markdown or html item or showing, tower/text is Open Text, its source.

Locations. Where a renderer is, { view, subject?, pane?, args? }, is written in its URL by one grammar, #v/<cap>/<name>[/<key>[/<arg>…]][;<cap>/<name>[/<key>[/<shows>[/<arg>…]]]], each key and arg one encodeURIComponent segment: #v/grid/grid/floor%3Alab. The pane, { view, subject?, shows?, args? }, is the tab open; shows is the key of a subject below the tab's that it shows, a file in a Files tab, and args where in it, a link's fragment. Reading a location, the renderer hands the tab show(subject) with that key and value holding only fragment (shownOf in /lib/layout.js), so a view that shows a kind reads what it needs from the key. hashOf and locationOf(hash, board) in /lib/layout.js write and read it, and locationOf also reads a worker's short form, #<id>, #<id>/<tab> or #<id>/shown:<target>, which Tower.app and the tower page write.

Display is the one navigation: kit.display(subject, { view? }), or tower.ui('display', …) from a framed page. displayed in /lib/layout.js walks the subject's chain (parentOf) outward to the nearest level whose main view shows it as a tab, else the first with a main view of its own, picked by the layout's order, then the owner of a collection's view, then the core's views first (the worker view on a card, the archive on a floor), then extensions' in order; with view, the deepest level that offers that view. A view given that is mounted and takes the subject through show stays mounted; when it is on that subject's kind, the location follows it there with no remount (the drafts editor's new draft, on its item once its first save is on the board). A worker the board doesn't carry is held as read when a view hands the card whole (kit.display(cardSubject), as the archive does), else looked up in the floors' archives, and else awaited when the renderer started it. openable lists the views a region holding commands draws as "Open " beside what is on screen; the tower page draws them in a floor's section and its palette.

Keys. views.<v>.keys and commands.<c>.keys give default chords, global, acting on the subject in focus (the innermost region holding the document's focus, else the main pane's): a view's displays it with that view, a command's runs it on the nearest subject of a kind it is on. board.keys holds them by <cap>/<name>, beside the keymap's ids (addedCommandOf in /lib/keys.js matches one). The config's keys."<cap>/<name>" replaces a default. A default that would fire with a keymap chord, a chord a renderer keeps, one the config set for another extension, or another extension's default is dropped (both, in the last case), each with a problem on its extension. From a framed page with scripts only a view's chord runs: a command's is code, and any script can claim a key.

Middleware and hooks. around wraps verbs and hooks, by qualified name ("tower/spawn": {}, "chime/ring": { "after": ["audit"] }), each one the core's, its own, or of a capability it requires or wants; its code is around[<name>](input, next, ctx), which calls next with the input to pass on or answers without calling it. Every call runs through the chain around its verb, whoever makes it: outermost first, each declared before (outside those capabilities' links) and after holding first, then a capability inside every capability that depends on it, so the verb's owner is innermost, then by capability name. What a link passes on is parsed again by the verb's schema, and what it answers is checked against the verb's reply; a link that throws, or passes on or answers what the verb doesn't take, fails the call (internal or invalid, naming the link) and lists a problem on its extension: a link may be a guard, so it is never passed over. Links in a cycle of before and after are left out, each with a cycle problem. A link off on the input's floor is passed over. The core's verbs that do what other verbs do (Tidy, worktree/discard) call those verbs through the same dispatch, for the same caller, so a link on tower/kill sees Tidy's kills; Tidy skips and names an entry its verb refuses, a discard stops where it is refused. What a worker's tower show, open, keep and home of itself log goes through tower/fact, so a link there sees each showing, kept item and leave, and may redact, copy or hold it; keep creates its item first through tower/collection/create, so a link that refuses the fact leaves the item kept and unannounced. GET /extensions lists each chains (outermost first), answers, composites and launchers.

hooks are points an extension raises inside its own verbs, each a payload and an answer schema and a failure (refuses or reported): ctx.raise('<name>', payload) answers each answerer's answer in fold order, each on its own, as {cap, ok: true, answer} or {cap, ok: false, code, message}, and the raising verb does what its failure says with a failed one. An extension answers a hook by listing it in answers ("tower/discard.record": {}) with a function answers[<name>](payload, ctx); one that throws or answers off the schema is a failed answer and a hook problem. The core raises tower/discard.record ({project, name, author, tips} → {note?, item?}, refuses) in worktree/discard before anything is removed: the answers are the floor's recovery record (each tip with its branch, base, head, dirty and unpushed; the reviews extension's note and filed thread among them, item naming where a record is kept), no answer at all refuses the discard as a failed one does, and the answers come back in the reply's x, by capability. Once the worktrees are removed and the branches deleted, it raises tower/discard.done ({project, name, author, tips, kept} → {note?, item?}, reported in the reply's done), where the reviews extension files the thread. It raises tower/tidy.apply ({project, keys} → {done, skipped}, reported) in tidy, after the core's own parts, to each capability in the plan's x alone, with the keys of the floor's tidy entries it contributed (board.adds['floor:<project>'].tidy) that the plan carries: an entry no longer listed refuses the whole Tidy, and each answer, or why there is none, is the reply's x.<cap>. An entry is {key, label, hint?, does?, kind?, checkout?}: does says what applying it does in a row's words, kind ({one, many}) what it is in Tidy's line (1 landed thread), checkout the checkout it belongs to (a worktree's name, or main), which the core passes through unread and the autotidy extension reads to apply an entry once that checkout's workers went home; the reviews extension's landed threads are such entries. The floor's tidy call carries every entry as plan.x, so a renderer offering Tidy all lists what it applies by passing the entries, addedTidyOf(board, floor) from /lib/cards.js, to tidyLine, tidyRows and tidyAllAsk: called without them, they word the core's rows alone. Each hook's schemas are listed at /schema, under hooks, a core hook's with how its answers combine (combine: gate, merge, place or report), whether a failed answer or none refuses the verb (required), what it means on a floor nobody answers on (absent, words: a label and a hint), the reply field its answers are named in (field) and the seconds each answer is waited for (deadline). Every hook has one: tower/spawn.gate's is 10 s, every other hook's, an extension's own included, 30 s. An answer still unsettled past it is a failed answer, as a throw is: a hook problem on its answerer, {ok: false, code: 'internal'} among the answers, and what it answers later is ignored. On a floor where no running extension that takes part answers a core hook with absent words, the core puts them there as a badge, board.adds['floor:<project>'].badges with cap: 'tower': a floor where reviews is off reads "Discards refused" and "Nothing filed". A hook the core answers itself (core, its words) is never flagged.

The gate. The core raises tower/spawn.gate on every spawn, resume and fork, once the launch contributors merged and before the crew edge, the worktree cut and the host, with {project, kind: 'spawn' | 'resume' | 'fork', runtime, by?, hire, exempt, fields} (exempt: what the contributors exempted it from; fields: its spawn fields by capability). An answer is {} to pass, or {code: 'limited' | 'refused', message} to refuse. The core answers first, with the floor's hiring limits on a hire nothing exempted, in today's words; then each answerer in fold order. The first refusal refuses the verb with its code, its message followed by whose gate it was: the week is 95% spent (budget-gate's gate). A failed answer is never a refusal: an answerer that is down, throws, answers off the schema or answers an ApiError gets a hook problem, and the worker starts. So does a link around tower/spawn.gate that refuses or fails, and then no answerer is asked: while an extension holding such a link is down or restarting, every spawn passes every extension's gate (the core's limits still hold). Each answer is waited for 10 s, one answerer after another: an answerer that hasn't settled by then has failed, and the worker starts. A gate that counts workers reads ctx.cards():

export default (ctx) => ({
  answers: { 'tower/spawn.gate': () => ((ctx.board().today.budget?.percentUsed ?? 0) > 95 ? { code: 'refused', message: 'the week is 95% spent' } : {}) },
})

Flows. Where can an extension take part in a core verb? tower flows lists every core verb with the stages open to extensions, and tower flows <verb> [--floor <project>] prints each of its stages in order, with who takes part there now: open, answered by extensions (a hook in answers, or for launch a launch contributor), wrapped, where the links of around run, at both edges of every verb, or sealed, the core's alone, each with why. /schema serves them as flows, and GET /extensions' chains, answers and launchers say who takes part. A stage marked planned is listed where it will be raised: nothing raises it yet, so no extension can answer it.

Slots, triggers and checks. slots.<name>: { "when": …, "scope"? } fires start's slots.<name>({name, at, project?}, ctx) at each slot of its rule: { "cron": [...], "tz"? }, crons in the subset the tower says in words, or { "every": "5m" }, a period aligned to the UTC clock (30s, 5m, 2h). The tower's 30 s loop fires a slot once, the latest at or before now, while it is within 5 minutes; a project-scoped slot fires once per floor where the capability is on. A floor's or the board's fold that declares "adds": ["slots"] gives slots of its own, slots: [{ key, when }], carried at board.adds[<subject>].slots and fired through start's slots['*'] with the slot's key and the floor. Fired is kept in memory only: a slot missed while the tower was down stays missed, and one fired just before a restart may fire again, so an extension that needs exactly once keeps its own facts. triggers.board: {} makes start return board(prev, next), pure and synchronous, which answers the calls a board change asks for, [{ verb, input }], made as the tower ({t: 'tower', id: 'board', via: 'loop'}) to what its ctx.call reaches. It is first called on the second board after it starts, and both boards hold only the floors where it is on, a floor that appears taken as already there, so a restart or a floor turned on replays nothing. Past 30 calls a minute it pauses for 5 minutes. A throw, or a call that fails, is a problem of the extension's. checks.<name>: { "words", "run" | "read", "fix"? } are lines of tower doctor: a command run from the folder (env scrubbed, killed at 10 s; exit 0 passes), or one of its own reads taking no params, which says "tower down" while the tower is. ctx.run(argv, { cwd, timeoutMs?, stdin?, env? }) runs a command the same way, killed at its timeout (60 s) and at halt. Its stdin arrives as a socket, which tower's own words don't read: pass their text as a flag. Work that must outlive a restart of the tower or the extension (a clone, an install, a build) is a job: ctx.jobs.start(argv, { cwd, env?, label }) answers { id } and ctx.jobs.cancel(id) stops it. The jobs daemon runs it in a PTY nobody types into, so env must stop prompts (GIT_TERMINAL_PROMPT=0); env is never logged, while argv is kept in the jobs log every renderer and worker reads, so a secret never goes in argv. The job is the capability's, even when a handler starts it for someone else. Each job on board.jobs carries its pid, which is also its process group (2.10): while its state is running, what it runs on the machine is that group, unless a process leaves it. Once the job is over (ended, cancelled, lost) the system may give the number to another process, so read it only on a running job. What it led to is the extension's to decide: read the ended jobs it owns on board.jobs (a board trigger reading only the next board), act through a verb of its own, and record what it did in a stream of its own, so a restart that fires the trigger again changes nothing. /lib/time.js says a rule in words and finds its next slot (ruleWords, nextSlot, slotWords); the board lists each extension's slots.

The author's loop. tower extensions check <dir> reads a folder as the tower would, resolves it against the running tower's extensions, and starts it in a throwaway process whose ctx reaches nothing, to say whether start returns what the manifest declares. tower extensions freeze <dir> writes its contract.json: its verbs, reads, facts, stream codes, collections and client modules' exports (client.<module>#<export>) at its major. At load, a name listed there and gone from the manifest at the same major is a contract warning (an error for a bundled extension), and an extension replacing a bundled capability must hold every name of the bundled one's contract.json at the major it claims, or it is refused. At a new major it may leave a client file out, and the tower page goes on without what that file drew: with no quota.js the probe line, with no drafts.js drafts in the palette, a prompt kept from a closed new-worker form, and starting a worker on a draft.

A bundled extension's id is its capability's: no other extension takes it. A new bundled extension that does nothing until its settings turn it on arrives at an API minor, and the changelog names it: a user's extension of that id is refused from then on, until it is renamed or sets provides to replace the bundled one on purpose. One that acts once it ships arrives at a major.

tower reads the system whose config TOWER_CONFIG names, ~/.tower/config.json unless set. To try an extension away from your own system, a checkout of the tower starts a throwaway one with npm run sandbox -- up, which prints where it is: add the extension to the config there, and run tower against it with npm run -s sandbox -- run tower extensions (header of scripts/sandbox.ts).

Launch shapes the workers the tower starts. spawn.fields declares fields a spawn sets as x.<cap>.<field> ({ "role": { "schema": {"type": "string"}, "words": {"label": "Role"}, "options": { "from": "floor.x.roles.options" } } }): each value is parsed by its schema and logged in the new session's log as tower.x.<cap>.<field> before its PTY starts, so a card fold reads it from own.facts. Every renderer's spawn form draws a field unless its form is false, its choices ({value, label, hint?}) read from the path options.from names in the extension's own floor part, which its floor fold's x declares as an array. A capability nobody provides, off on the floor, or a field it doesn't declare is invalid. A worker sets one on its hire with tower hire … x.<cap>.<field> <value>, gathered as the form's fields are; a command line's value is a string, so a field set there takes a string schema, and one that doesn't refuses it as invalid.

spawn.launch: true means start returns launch(request, ctx), called for every spawn, resume and fork on a floor where the extension is on, in dependency order. request is {kind: 'spawn' | 'resume' | 'fork', runtime, hire, by?, project, cwd, model?, effort?, fields?, facts}: hire whether a spawn is a worker's hire (tower hire, or a spawn sent with hire), by the session of the worker that asked for it, a hire's hirer, the same two its tower/spawn.gate weighs: the user's own spawn has hire: false and no by, and so does every resume and fork; fields its own field values on a spawn, facts its facts over the worker's lineage (a fork carries copies of its source's). ctx reads only: the floor's settings, read, and its collections' list and read. It returns parts the session's runtime places: systemPrompt (after the tower's brief), prompt (after the first prompt), env (in Claude's settings, without a parent session's markers: those settings are part of the session's argv, which its log's header keeps for good, so contributed env is no place for secrets), defaults (model, effort, used only when the spawn leaves one out), fields (values for its own spawn fields the spawn left unset, since 1.167: each parsed by its field's schema and logged as a spawn's field is, tower.x.<cap>.<field> before the session starts, so its folds, its gate answer and every later launch of the lineage read it as a fact; a field the spawn set keeps the spawn's value, the contributor's left unread, and one the extension doesn't declare, or a value off its schema, is a part the runtime can't place: on a spawn that set none of the extension's fields, that drops every part the contributor gave, its fields with the rest, and the worker starts without them), args.claude (Claude's own flags, each --flag or --flag=value, placed before the tower's), exempt: ['hiring'] and reportsTo (a callsign); prompt, defaults, fields, exempt and reportsTo count on a spawn only. A flag the tower passes (--name, --settings, --plugin-dir, --append-system-prompt, --model, --effort, --resume, --) or the config's argv command the session runs passes, an env key the config's env sets, and a flag, env key, defaults member or reportsTo two extensions both give, refuses the launch, naming both. A contributor that throws, doesn't settle within 10 s, or returns what the runtime can't place refuses a spawn that carries its fields, and otherwise is left out with a launch problem. exempt takes the worker out of its floor's hiring limits and reportsTo puts it in that worker's crew: each is logged as a core fact (tower.exempt, tower.reports-to) before it starts, shown on its card and by tower whoami, and listed at GET /extensions. runtimes.claude.plugins names a Claude plugin folder in the extension, loaded into every session on floors where it is on: An extension's Claude plugin.

Contributing surfaces

A capability often starts as a config key and moves into an extension once it is worth sharing. Four of the config's surfaces take the same data from a manifest, so an extension ships them with nothing in the user's config (since 2.13):

Manifest key The config's twin Where it shows
renderers: { <name>: { root, entry?, settings? } } renderers At /r/<name>/ while the extension is accepted, after the built-ins. The name is <provides> or <provides>.<name>; a built-in's name refuses the extension. root is inside the extension. The config's renderers.<name> sets fields over it.
shelf: [{ label, renderer | item | url | link }] projects.<p>.shelf On every floor where the extension is on, after the config's entries. A page is a renderer of its own or an item it contributes, so no entry names a path.
items: { <collection>: "<folder>" } the files of collections/<p>/<c>/ In the collection on every floor where the extension is on, read in place (Collections).
themes: { <renderer>: { <name>: { title, file } } } renderers.<name>.theme Offered to that renderer as <provides>/<name> while the extension is accepted, loaded only while the config's theme names it, before the config's themes (Write a theme). Since 2.30; offered by name since 2.34.

Each contributed thing carries from, the capability it came from: a renderer in GET /renderers, a shelf entry and an item on the board. The extension's folder is read when the tower resolves its extensions, so an edit there shows after tower extensions restart <id>, as code does. Turning the capability off on a floor (projects.<p>.capabilities.<cap>.off) hides its shelf entries and items there; its renderers are the tower's, on no floor. tower config check checks each contributed shelf entry on each floor, at extensions.<id>.shelf[<n>].

{
  "id": "lobby", "version": "1.0", "title": "Lobby", "requires": { "tower": "2.13" },
  "renderers": { "lobby": { "root": "out" } },
  "shelf": [{ "label": "Lobby", "renderer": "lobby" }]
}

An extension's Claude plugin

An extension teaches a Claude session with a plugin of its own: skills whose descriptions tell the worker when to reach for them, with no word for it to remember. guidance is the neutral text every runtime's worker reads; a plugin is Claude's, so it sits under runtimes, keyed by runtime as the config's runtimes is. examples/extensions/handoff is the smallest: an extension that is only a skill.

handoff/
  extension.json                     "runtimes": { "claude": { "plugins": "plugin" } }
  plugin/
    .claude-plugin/plugin.json       { "name": "handoff", "version": "1.0.0" }
    skills/note/SKILL.md             name, description, then what it teaches
  • The folder is relative to the extension's and holds .claude-plugin/plugin.json. One folder per runtime: a plugin holds any number of skills.
  • Names: a skill is <plugin>:<skill>, here handoff:note, the plugin's name from its plugin.json.
  • What triggers it is the skill's description: write the words a user says. Worth a line in the extension's guidance too, so tower whoami names it.
  • When it arrives: Claude reads its plugins as a session starts, so a change reaches the next session started, never a running one. It loads on floors where the extension is on, passed to Claude as --plugin-dir beside the tower's own.
  • Checked at load. Claude skips a plugin folder it can't read and says nothing, so a folder that is missing or has no .claude-plugin/plugin.json is a warning on the extension, in tower extensions and tower extensions check. The rest of the extension runs. A manifest still saying plugins.claude, the 1.x spelling, is refused, naming runtimes.claude.plugins.

An extension's README

Every extension, bundled or an example, carries a README.md that lets a reader decide in a minute whether it does what they want, and its pictures in its own folder, so a copy of the folder carries both. A pull request that adds or changes an extension keeps its README to this standard. narrate is the one to copy.

A README says what is true of this extension and what we would recommend, and no more: 40 to 70 lines is the aim, and a contract or settings a user must write may run longer. Two parts are required:

  1. # <Title>, then one line: what it does for the user.
  2. ## What it adds: one entry per surface it reaches, each with its picture: the tower page by region (the sidebar's strip, a card, a worker's tabs, a document's gutter, the palette, the main pane), the CLI (tower x <id>, its commands), Tower 3D, and the workers (its guidance in tower whoami). A text block stands in for a picture of the terminal. Then the surfaces it leaves out, in one line.

The rest come in this order, each only when it says something true and useful for this extension; a heading with nothing to say is left out:

  1. ## Add it: the config entry. An example: copy the folder outside the checkout and name its path, or run it in place when it depends on the tower's own packages (files). A bundled one: on by default, and how to turn it off when that is worth knowing.
  2. ## What it needs from you: the settings and config keys it reads, with an example value. Say plainly what works out of the box only as a placeholder, and what makes it good (narrate: the browser's speech is the placeholder, a voice command is what makes it sound good).
  3. ## How it works: the manifest's pieces it uses and what its server and client do, as much as a reader needs to copy or adapt it, not a tour of every file.
  4. ## Make it yours: only real extension points: its settings, a guidance also in the config, and for an example, copying the folder and changing its own files. Never advise editing the core, the mod or its skills, or a bundled extension in place: tower update moves those.
  5. ## Pictures: one line, how to retake them.

Pictures come from npm run tool:extension-shots -- <folder>, never from the real system: it runs the scenes in the folder's shots.json against a throwaway sandbox seeded with made-up content, and writes <folder>/shots/<scene>-<light|dark>.png, cropped to the region that matters, and <folder>/shots/<name>.txt for text blocks. The script's header documents shots.json; narrate's is a short one to start from. Take light and dark when the look differs, and show them side by side:

| Light | Dark |
| --- | --- |
| ![The memo strip](shots/memos-light.png) | ![The memo strip](shots/memos-dark.png) |

Claude plugins

runtimes.claude.plugins, at the top level or under a project, lists absolute plugin directories every session the tower starts loads, each passed to Claude as --plugin-dir. Your commands and skills live in one plugin outside your repos and reach every worker as /<plugin>:<command>. A changed plugin reaches the next session started. An extension brings its own with runtimes.claude.plugins. The bundled extensions/reviews is the full example: guidance, a cli word per verb, and skills whose descriptions carry the triggers.

{ "runtimes": { "claude": { "plugins": ["/Users/you/code/my-workflow"] } } }

The tower command

tower is on the PATH of every session the tower runs (npm link puts it on yours). The user's verbs start and stop the system and drive sessions (up, down, spawn, submit, kill, ls…); the workers' verbs read the board and act on it (whoami, agents, show, keep, hire, home, api…), and tower x calls the extensions' doors, verbs and reads. It is a client of the same API: what it does, a script does with curl, and it claims its caller in headers (tower-client: cli, and a worker's tower-session), which a request without them is the user's. tower alone, or an unknown verb, lists every verb.

The logs

~/.tower/sessions/<id>.jsonl is everything that happened in a session: a header line (the session, and its runtime, claude, absent from the logs of older hosts), then [t, code, data] events, t in seconds since it started: o output, i input, r resize, h a hook or mod event, x its exit (exitCode, and signal when a signal it didn't catch ended it). An archived log is <id>.jsonl.gz, the same lines gzipped. Read them with anything:

tail -n +2 ~/.tower/sessions/<id>.jsonl | jq -c 'select(.[1] == "h") | .[2].hook_event_name'

Only the host writes them. Everything the tower shows is computed from them, the config and the collections.

A stream keeps its old folder for good: the quota stream's facts stay in probe.quota/.

What is not an extension point

  • The host (src/host). It owns every session's terminal, and changing it ends every running session. It stays small and knows no Claude flags; what sessions start with is the config's env and each runtime's own part, runtimes.<id> (argv, plugins, a floor's command). A runtime is a core module, not an extension: the runtimes the tower knows are the ids of board.runtimes, and a renderer draws one from its entry there, never by its id.
  • Writing to the log files. A log holds facts the host observed. A line written into one by anyone else is a fact that never happened, and every view computed from it inherits the lie. To say something on a session's log, declare a fact: the host writes it. Keep other data of your own in a stream or a collection.
  • Editing the checkout's renderers in place. tower update moves the checkout to the next release, so your edits conflict with it, and the renderers there move with the tower, unpinned. Copy one out instead.

Going fully custom against the API is supported: a renderer in any stack, a script, a daemon of your own. The tower keeps its contract (the API, /tower.js and the library, versioned as above); it takes no responsibility for keeping every copy working across changes beyond it.

Changing the core itself, rather than building on it: the rules a change to this repository keeps are in PRINCIPLES.md.

Keeping a fork

A fork that carries its own changes can follow upstream's main, by a policy if you like. What it can rely on is the contract above; anything else may move on any merge. A few habits keep the merges small:

  • Keep what you can in files of your own. An extension or a renderer doesn't conflict; lines inside the core's files do, at every merge. When you carry a core change through a merge, check whether a door for it has landed since.
  • Merge often. Most of a merge's cost is the size of the gap.
  • Leave API_VERSION as upstream has it. An addition of yours breaks nothing, so the fork still meets upstream's number. A number of your own claims a version upstream will later give another meaning, and git shows no conflict when both sides reach it.
  • Regenerate generated files (npm run schema:board, npm run served:update), never merge them by hand.
  • Leave CHANGELOG.md, the tags and the kb's reviewed dates to upstream. A reviewed date says someone checked an entity's claims, which a merge doesn't. Keep yours on the entities you own, and take upstream's when a date conflicts.