Extending the office
Four recipes, each ending in a working thing. They share one shape, because the
codebase does: a data file owns what exists, a registry owns how it is built,
and import-time checks weld the two together — forget one half and the first
run tells you, loudly, instead of a click failing quietly. src/data/sources.js
is the original of the pattern; the props and the outlooks follow it.
Every recipe ends the same way: npm test, the probe, and a look at the scene
(developing.md has the loop). Docs update in the same PR as the
change — this repo's documentation is accurate because that is a rule, not a
hope.
Add a prop
A prop is one file carrying its geometry and, where the common mounting pattern is not enough, its own way of being put into the room.
- Build it —
src/scene/props/<kind>.js, exportingbuild<Kind>(). Raise it at its own origin, facing +z, feet on the floor, using the helpers inscene/build.js(box,cyl,group,put,mat,footY). Look atbin.jsfor the minimal shape andmailbox.jsfor a prop with behaviour. If agents interact with it, return{ obj, handle }and give the handle the methods the agent layer will drive. - Register it — one line in
src/scene/props/index.js. Add amountonly if the common pattern (build, face the approach point, register the handle under the kind's name) is not enough. - Declare it to the layout — one entry in the kind table in
src/layout.js(STATION_KINDSorFURNITURE_KINDS): its label, how many the room may hold, and the floor it blocks as half-extents in its own axes. That entry is what the editor's Add menu, the nav grid and the sync machinery read. - Photograph it — an entry in
scene/catalogue.js, so it appears in the Item Library (npm run portraitrewrites the stills).
Forget 1, 2 or 3 and the registry throws at first import; forget 4 and
test/scene-catalogue.test.js fails. That is the whole safety story: you
cannot add half a prop.
Add a building or an outlook
A building is a BUILDINGS entry in src/projects.js — storeys below,
walls, roof, which outlook is outside — and most new buildings are only that:
data, no code. The pieces it composes live in scene/building.js.
An outlook — a new world outside the windows — is the registry one level up:
- Build it — a module in
src/scene/outlooks/, exporting its definition:{ id, label, aerial, ground(season), build(g, ctx) }. The shared kit (trees, lamps, cars, the seeded RNG that keeps rebuilds still) isoutlooks/streetscape.js;street.jsis the worked example. - Register it — one line in
outlooks/index.js. - Name its mode — one string in
OUTSIDE_MODESinprojects.js, which is what a theme or aBUILDINGSentry points at.
The registry validates both ways at import, and npm run map renders every
theme's whole city so you can see what you built from above.
Add a source
A source fills an office with agents. The six that exist are declared in
src/data/sources.js, and the picker, the badge and the switcher all read that
list — none of them know the roster.
- Declare it — a record in
SOURCES:id,label,blurb,accent, amark(inline SVG inui/marks.js),kind, and acreate(ctx)factory. Animagefield (a static-asset path) optionally swaps a portrait in for the mark in 2D chrome — picker, badge, switcher and rows — while the 3D name-tag keeps the vector mark. - Implement it — a class with the
AgentSourceshape (start(onEvent),stop(), optional capabilities likesendJob). For a live harness that speaks AOP,AopSourcealready is the implementation — a new AOP harness is aSOURCESrecord withkind: 'aop'and the harness slug, nothing more on the browser side. - Document it — a page in
docs/sources/, saying what it can see and how to install its adapter.
The events a source emits are the office's own vocabulary — spawn, status,
job, research, dispatch, exit — documented at the top of
agents/AgentManager.js. Capabilities are feature-detected, never named: a
source that implements sendJob gets the T key, and nothing downstream
ever asks what kind of source it is talking to.
Add a harness adapter
An adapter turns a harness's own events into AOP on the wire — it runs on the agent's machine, not in the browser. aop-harness-adapters.md describes the four that exist; aop-spec.md is the wire format.
- Write the mapper —
bin/mappers/<harness>.cjs, exportingmap({ event, payload, state, redaction, helpers, endpointId })→ an array of AOP events, plus aCAPABILITIESlist and aTOOL_CLASSEStable.aop-send.cjsresolves the mapper from the harness slug, so the filename is the registration.rovo-cli.cjsis the smaller worked example;claude-code.cjsshows held introductions and real subagents. - Honour the contract. The parts every mapper must get right:
-
Redaction is the adapter's job (spec §10) — the decision about what leaves the machine is made where the secret already lives. In
metadatamode no free text reaches a desk label (titles become "Working", errors are dropped);summaryclamps everything throughhelpers.clamp;fullcarries prompts only with the second opt-in. Never emit a whole command line —targetOftakes the binary name only — and paths leave throughhelpers.tidyPath, relative or~-prefixed, never absolute.Pass the mode to
targetOf. Atargetis not one kind of thing: a file path is whatmetadatapromises, and a search pattern, a web query or a URL is the model's own text.TARGET_KEYSinmappers/lib/tool-classes.cjssays which key is which category andTARGET_KINDSsays what each may say atmetadata— a search says nothing, a URL says its host. A call site that forgets the argument getsmetadatabehaviour, so the worst it can do is say too little. -
Introduce before use, and never before. Any event may be the first the office hears (hooks get installed mid-session, receivers restart), so a mapper carries
session.startahead of whatever needs it — and a session that never does anything is never introduced at all (seeQUIET_EVENTSin the Claude mapper). -
Declare capabilities honestly on
session.start: a session that promisessession.endgets the long reaping leash, so only promise what the harness reliably delivers. -
Classify, don't name. The office renders
tool_class, never tool names. Exact names go in yourTOOL_CLASSEStable; everything unknown falls through the shared heuristics inmappers/lib/tool-classes.cjs.
-
- Write the installer —
bin/aop-<harness>-install.cjswith--status,--dry-runand--uninstall, scaffolding the shared config throughbin/lib/local-config.cjs. The three that exist show the range, and their headers say why each is shaped the way it is. - Fixture-test it — recorded payloads → expected events, next to
test/mapper-claude-code.test.cjs. The recorded shapes are the contract; the tests are where the next reader learns the dialect. - Document it — a page in
docs/sources/, and a row in aop-harness-adapters.md.
If the change touches hooks/, bin/aop-send.cjs, bin/aop-node.sh, bin/aop-plugin-hook.sh,
bin/mappers/, .claude-plugin/ or .codex-plugin/, bump the plugin version — every time. The
why is in AGENTS.md.