← Commit history
Publish 1.3.0
12 files changed
+627−129
README.md+30−2SKILL.md+9−9install.sh+1−1package.json+9−2page.json+16−3skills/app-creator-caller-identity/SKILL.md+115skills/app-creator-live-channel/SKILL.md+116skills/app-creator-reason-gating/SKILL.md+117skills/app-creator-server-lifecycle/SKILL.md+56−111skills/app-creator-settings/SKILL.md+73skills/app-creator-surfaces/SKILL.md+82uninstall.sh+3−1README.md+30−2@@ -254,10 +254,38 @@ this). Every app server must ALSO reap itself after 24h idle, require an AI-thread name from every caller (refusing anonymous calls with a teaching reprimand), require a `reason` on disruptive verbs, and register itself so `<app> ls` finds it and `start` reuses a live instance instead of spawning-a duplicate. Full rules, refusal payloads, and the Node reference-implementation: read the **`app-creator-server-lifecycle`** sub-skill+a duplicate. These rules live in the sub-skill family below; read+**`app-creator-server-lifecycle`** and **`app-creator-caller-identity`** before wiring any server's main loop. +### The sub-skill family++- **`app-creator-caller-identity`**: every caller names its AI thread+ (`--ai-thread`, `X-Adom-Thread` / `aiThread`), anonymous state-changing+ calls get the `caller_identity_required` teaching refusal, identity is+ attribution and never authorization, and identity is forwarded (with a+ delegate name) when your app calls other services. Modeled on ab and pup,+ which already enforce this.+- **`app-creator-reason-gating`**: the pattern that makes AI callers+ behave: design a safe default (pup opens windows in the background), gate+ the escalation (foregrounding requires a written `reason` quoting the+ user's ask), and refuse with hints that teach the retry. Having to write+ the reason forces the AI to deliberate; most gated calls end with the AI+ choosing the safe alternative.+- **`app-creator-server-lifecycle`**: the 24h idle reaper with lossless+ per-thread snapshots, the instance registry, `<app> ls`,+ reuse-instead-of-respawn, `--port auto`, and version-drift detection.+- **`app-creator-settings`**: almost every app ships a Settings window,+ even for one toggle: gear icon, server-side persistence via+ `GET/POST /settings` (never localStorage), AI parity via curl.+- **`app-creator-surfaces`**: wv vs extwv vs hbw vs pup vs nb, choosing by+ context, respecting the user's persisted preference via+ `show --surface`, the proxy-URL trap, and background-first etiquette.+- **`app-creator-live-channel`**: the SSE connection every frontend opens+ back to its server, and the CLI verb relay that lets the AI drive the+ live page: swap rendered data in place, auto-click, expand menus, glide+ a fake cursor, toast narration, no full-page refresh.+ ### 7a. Always use relative URLs inside the webview (CRITICAL) Apps hosted through the Coder `/proxy/<port>/` prefix MUST use relative
SKILL.md+9−9@@ -6,16 +6,16 @@ description: > # App Creator Use when the user wants to build a new Adom "app", a mini web server that renders its UI in a Hydrogen webview tab. -## Sub-skill: server lifecycle (REQUIRED reading before wiring a server)+## Sub-skills (load the ones your build touches; lifecycle + identity are REQUIRED) -`app-creator-server-lifecycle` covers the lifecycle rules every app server-must build in: idle self-shutdown (24h reaper with lossless per-thread-snapshots), mandatory AI-thread caller identity with teaching refusals-(`caller_identity_required`), `reason` on disruptive verbs, the instance-registry (`<app> ls`, reuse-instead-of-respawn, `--port auto`), and-version-drift detection. Load it whenever you are building a server, or when-an Adom app refuses a call with `caller_identity_required` or-`reason_required`.+| Sub-skill | Covers | Load when |+|---|---|---|+| `app-creator-caller-identity` | Mandatory `--ai-thread` at spawn, `X-Adom-Thread` / `aiThread` on state-changing calls, the `caller_identity_required` teaching refusal, forwarding identity downstream | Building ANY server; a call refused with `caller_identity_required` |+| `app-creator-reason-gating` | Hints, teaching refusals, and reason-gated verbs: out-of-the-norm actions (foreground, delete, publish, kill) refuse until re-called with a written `reason` | Designing endpoints; a call refused with `reason_required` |+| `app-creator-server-lifecycle` | 24h idle reaper with lossless per-thread snapshots, instance registry, `<app> ls`, reuse-instead-of-respawn, `--port auto`, version drift | Building ANY server; a container full of zombie servers |+| `app-creator-settings` | The (almost) mandatory Settings window: gear icon, server-side persistence, `GET/POST /settings`, standard entries | Scaffolding any UI |+| `app-creator-surfaces` | wv / extwv / hbw / pup / nb decision table, the `show --surface` verb, proxy-URL trap, background-first etiquette | Wiring the show/open path |+| `app-creator-live-channel` | The SSE channel between server and page, the directive vocabulary (state swap, auto-click, reveal, fake AI cursor, toast), CLI verb relay | Wiring frontend to server | ## Boundary with ai-driven-apps (in adom-ui-design)
install.sh+1−1@@ -13,4 +13,4 @@ for skill_dir in "$PKG_DIR/skills"/*/; do mkdir -p "$SKILLS_DIR/$skill_name" cp -r "$skill_dir"* "$SKILLS_DIR/$skill_name/" done-echo "Installed app-creator (+ sub-skills: app-creator-server-lifecycle)"+echo "Installed app-creator (+ sub-skills: caller-identity, reason-gating, server-lifecycle, settings, surfaces, live-channel)"
package.json+9−2@@ -1,6 +1,6 @@ { "slug": "app-creator",- "version": "1.2.0",+ "version": "1.3.0", "type": "skill", "description": "Use when the user wants to build a new Adom \"app\", a mini web server that renders its UI in a Hydrogen webview tab.", "dependencies": {},@@ -34,7 +34,14 @@ "clean up my servers", "zombie server", "server lifecycle",- "ai thread name for my server"+ "ai thread name for my server",+ "settings window for my app",+ "which surface should my app open in",+ "sse live channel",+ "drive the frontend from the cli",+ "reason gating",+ "teaching refusal",+ "foreground needs a reason" ], "discovery_pitch": "Build a new Adom app (a mini web server with a Hydrogen webview UI) following the required conventions: brand, AI-drivability, and server lifecycle (idle self-shutdown, AI-thread caller identity, instance registry).", "sample_prompts": [
page.json+16−3@@ -4,7 +4,7 @@ "slug": "app-creator", "title": "App Creator", "brief": "Use when the user wants to build a new Adom \"app\", a mini web server that renders its UI in a Hydrogen webview tab.",- "version": "1.2.0",+ "version": "1.3.0", "tags": [ "skill", "app",@@ -59,7 +59,14 @@ "clean up my servers", "zombie server", "server lifecycle",- "ai thread name for my server"+ "ai thread name for my server",+ "settings window for my app",+ "which surface should my app open in",+ "sse live channel",+ "drive the frontend from the cli",+ "reason gating",+ "teaching refusal",+ "foreground needs a reason" ], "discovery_pitch": "Build a new Adom app (a mini web server with a Hydrogen webview UI) following the required conventions: brand, AI-drivability, and server lifecycle (idle self-shutdown, AI-thread caller identity, instance registry).", "metadata": {},@@ -67,5 +74,11 @@ "updated_at": "2026-05-28T05:29:45.880Z", "sub_skills": [], "parent_app": null,- "org": "adom"+ "org": "adom",+ "description": "Use when the user wants to build a new Adom \"app\", a mini web server that renders its UI in a Hydrogen webview tab.",+ "dependencies": {},+ "scripts": {+ "install": "./install.sh",+ "uninstall": "./uninstall.sh"+ } }
skills/app-creator-caller-identity/SKILL.mdadded+115@@ -0,0 +1,115 @@+---+name: app-creator-caller-identity+description: >+ How every Adom app server asks "who is calling?": the mandatory AI-thread+ name on spawn and on every state-changing request, modeled on how ab and pup+ already enforce it. Covers the X-Adom-Thread header / aiThread field, the+ caller_identity_required teaching refusal, precedence, good thread names,+ why identity is never authorization, and forwarding identity when your app+ calls other services. Read when building any app server, or when a call is+ refused with caller_identity_required. Trigger words: ai-thread, aiThread,+ ai thread name, caller identity, who is calling, X-Adom-Thread,+ caller_identity_required, identify your thread, thread attribution,+ anonymous caller, name your thread.+---+Parent skill: **app-creator**++# Caller identity: every caller names its AI thread++Adom Bridge (ab, since v1.9.180) and pup already refuse anonymous callers.+Most Adom apps do not yet, and that is a gap: this skill makes the pattern+standard for every new app server. Study `adom-bridge-caller-identity` for+the origin; this page is the app-author's implementation contract.++## Why++A typical Adom user runs roughly 20 AI conversation tabs against one+container and one desktop. Without identity, every server log, activity+line, and approval prompt says "some AI did something": the user cannot tell+the tab doing useful background work from the tab that went off the rails,+and your server cannot manage per-thread instances or state (see+`app-creator-server-lifecycle`). One name, given once per conversation and+sent on every call, fixes all of it.++## The contract your app implements++1. **Spawn**: `<app> start --ai-thread "<name>"`. Required, not optional.+2. **Every state-changing HTTP request** carries the thread name:+ - header `X-Adom-Thread: kicad-bridge dev`, or+ - top-level `"aiThread"` field in the JSON body.+3. **Read-only endpoints stay open** (`GET /state`, `GET /console`,+ `GET /settings`): debugging and observation are never gated.+4. **Precedence** when several are present (mirror ab exactly):+ explicit field in the call's args, then the CLI flag, then the+ `ADOM_AI_THREAD` env var. The env var is acceptable ONLY in+ single-agent containers (CI, dedicated boxes): in a shared container it+ misattributes every concurrent thread, which is worse than no name.++## The refusal (see also app-creator-reason-gating)++An anonymous state-changing call gets HTTP 400 with a payload that TEACHES.+The caller is an AI; your error text is a prompt it will read and obey:++```json+{+ "ok": false,+ "errorCode": "caller_identity_required",+ "error": "This server requires every AI caller to identify its conversation thread.",+ "hint": "Retry with header 'X-Adom-Thread: <name>' or a top-level \"aiThread\" field. Pick a short name a HUMAN would recognize for THIS conversation (like 'kicad board review', not 'agent' or a UUID) and reuse it on every call to every Adom server."+}+```++Use the exact code `caller_identity_required`: ab established it, callers+already know what it means and how to fix it.++## Good thread names++The name is shown to a human deciding whether to trust what is happening.++- Good: `chip-fetcher tab 3`, `kicad board review`, `nightly wiki sync`+- Bad: `claude`, `agent`, `session_1`, a UUID++What the work is, plus which tab, if several do the same thing. If the user+has told the AI what they call the conversation, those words win.++## Identity is never authorization++The thread name is self-reported. Record it, display it, key state by it,+and never verify or trust it: it exists for attribution, logging, and+instance management. Do not grant any privilege based on an `aiThread`+value, and never present a thread name to the user as proof of anything.+(ab's real security is its authenticated transport; your app's is whatever+auth it already has. Identity rides on top, it does not replace it.)++## Forwarding: when your app calls other services++If your server calls ab verbs or another app's API on behalf of a thread,+forward the identity instead of dropping it, exactly like a bridge does:++- Pass through `X-Adom-Caller-Thread` / `-Container` / `-Reason` headers you+ received (or map your `X-Adom-Thread` onto them).+- Add `X-Adom-Caller-Delegate: <your-app-slug>` naming yourself, so the user+ sees `kicad board review (via hero-studio)`: who asked AND who executed.+- When your server acts on its OWN behalf (health poll, reaper, cleanup),+ send your own identity, never a stale forwarded one.++## Node middleware (drop-in)++```js+const READ_ONLY = new Set(['/state', '/console', '/settings', '/events', '/version']);+function requireThread(req, res, body) {+ if (req.method === 'GET' || READ_ONLY.has(req.url.split('?')[0])) return null;+ const thread = req.headers['x-adom-thread'] || (body && body.aiThread);+ if (thread) { req.aiThread = String(thread); return null; }+ res.writeHead(400, { 'Content-Type': 'application/json' });+ res.end(JSON.stringify({ ok: false, errorCode: 'caller_identity_required',+ error: 'This server requires every AI caller to identify its conversation thread.',+ hint: "Retry with header 'X-Adom-Thread: <name>' or a top-level \"aiThread\" field. Use a short human-recognizable name for THIS conversation and reuse it on every call." }));+ return true; // handled+}+```++Log every accepted call as `thread "<name>": <verb>` in the console ring+buffer, and key registry entries and snapshots by the thread (see+`app-creator-server-lifecycle`). Gated verbs additionally want a `reason`;+that is a separate contract with its own refusal: `app-creator-reason-gating`.
skills/app-creator-live-channel/SKILL.mdadded+116@@ -0,0 +1,116 @@+---+name: app-creator-live-channel+description: >+ The SSE live channel every Adom app builds between its server and its+ frontend, and the CLI verb relay that rides it: the AI calls the app's+ binary, the CLI posts to the server, the server pushes a directive over+ SSE, and the live page reacts (auto-click a button, expand a menu, glide+ a fake cursor, swap rendered data in place, reload). Read when wiring any+ app's frontend to its server. Trigger words: sse, server-sent events,+ live channel, event stream, drive the frontend from the cli, auto-click,+ fake cursor, ai cursor, push to the ui, update without refresh, swap data+ live, websocket vs sse, broadcast state, EventSource.+---+Parent skill: **app-creator**++# The live channel: your CLI talks to your live frontend++The pattern behind every good Adom app: a binary (Rust, Node, or Python)+spins up a web server, the UI opens in a surface (`app-creator-surfaces`),+and **the page immediately opens an SSE connection back to the server**.+From that moment the two are talking, and the AI can drive the LIVE page+from the app's own CLI:++```+AI runs: <app> pose --title "Adom USB" (CLI verb)+ -> CLI POSTs to the server's command endpoint+ -> server updates state, broadcasts over SSE+ -> the open page re-renders the title IN PLACE, no reload+```++Hero-studio is the reference: `hero-studio pose` changes the title,+subtitle, and vitrine of a page the human is looking at, live. The human+sees the change land; nothing flickers, nothing reloads.++## Why SSE (and when WebSocket)++SSE is one-directional (server to page), auto-reconnects via native+`EventSource`, and needs no library. That covers the whole pattern, because+the OTHER direction already exists: the page talks back through plain HTTP+POSTs to the same endpoints the AI uses (main skill §7). Reach for+WebSocket only for genuinely bidirectional high-rate streams (collaborative+cursors, waveforms); otherwise SSE plus POST is simpler and proxy-friendly.++## Server side (Node sketch, mirrors hero-studio)++```js+const clients = new Set();+function broadcast(event, data) {+ const msg = 'event: ' + event + '\ndata: ' + JSON.stringify(data) + '\n\n';+ for (const res of clients) res.write(msg);+}+// GET /events+res.writeHead(200, { 'Content-Type': 'text/event-stream',+ 'Cache-Control': 'no-cache', Connection: 'keep-alive',+ 'X-Accel-Buffering': 'no' });+res.write(':' + ' '.repeat(2048) + '\n\n'); // flush proxy buffers+res.write('event: state\ndata: ' + JSON.stringify(state) + '\n\n'); // sync on connect+clients.add(res);+const hb = setInterval(() => res.write(': hb\n\n'), 15000); // heartbeat+req.on('close', () => { clearInterval(hb); clients.delete(res); });+```++Non-negotiables: replay current state on connect (a reconnecting page must+re-sync, EventSource reconnects silently), heartbeat every 15s so proxies+do not reap the stream, the 2KB padding comment so buffering proxies flush,+and `X-Accel-Buffering: no`.++## The directive vocabulary++Everything the server pushes is one of a small set of typed events the+frontend knows how to execute:++| Event | Payload | Frontend reaction |+|---|---|---|+| `state` | full or partial state | re-render affected regions in place (title, subtitle, vitrine, lists) |+| `click` | `{selector}` | find the element, run its real click handler |+| `reveal` | `{selector}` | expand the menu/section containing it, scroll into view |+| `cursor` | `{selector, hover: true}` | glide the fake AI cursor to it and hover |+| `toast` | `{text, kind}` | show it (toasts double as the AI's narration channel) |+| `reload` | `{}` | full page reload (last resort; prefer `state`) |+| `eval` | `{js}` | dev-mode only (§7b): execute and report back via /console |++`state` is the workhorse: prefer changing state and letting the page react+over scripting DOM actions. `click`/`reveal`/`cursor` exist for driving and+demonstrating the UI itself (walkthroughs, ralph-testing, "watch me do it").++## The fake AI cursor++When the AI drives a page the human is watching, render a cursor: a small+absolutely-positioned div that GLIDES to its target (CSS transition, ~300ms),+hovers, and then acts, with an intent label ("opening layout menu"). The+human should be able to follow what the AI is doing exactly as if a person+were mousing around. Details and polish rules live in `adom-ui-design`.++## CLI verb relay++Every CLI verb that touches the UI is a thin HTTP client:++```+<app> pose --title "..." -> POST /state {"title": "..."}+<app> ui click "#generate" -> POST /ui/click {"selector": "#generate"}+<app> ui show "#settings" -> POST /ui/reveal {"selector": "#settings"}+```++There is NO separate AI remote-control channel (main skill §7a): the CLI+hits the same endpoints the UI's own buttons hit, carrying its caller+identity (`app-creator-caller-identity`), and the SSE push is how the open+page finds out. Test before shipping: run the CLI verb from a terminal and+watch the open page react without being touched. If it does not, the page+is keeping local state that belongs on the server.++## Boundary++This skill covers BUILDING the channel into an app. Driving it during+testing and demos (ralph loops, screenshot verification, auto-click tours)+is `ai-driven-apps` in `adom-ui-design`: build here, drive there.
skills/app-creator-reason-gating/SKILL.mdadded+117@@ -0,0 +1,117 @@+---+name: app-creator-reason-gating+description: >+ The teaching-refusal pattern that makes AI callers behave: hints,+ reprimands, and reason-gated verbs. Any action beyond the norm (foreground+ a window, delete, overwrite, publish, kill) is refused until the caller+ re-calls it with a written reason, which forces the AI to actually+ deliberate. Modeled on pup's foreground_reason_required gate and ab's+ gated verbs and confirm flows. Read when designing any app server's+ endpoints. Trigger words: reason required, reason_required,+ foregroundReason, teaching refusal, reprimand the ai, gate a verb,+ disruptive action, make the ai think, confirm flow, error hint,+ beyond the norm, escalation verb.+---+Parent skill: **app-creator**++# Reason gating: refusals that make the AI think++## The insight++When a server refuses an out-of-the-norm action until the caller supplies a+written reason, the AI has to generate a justification before it can retry.+That act of writing the reason IS the deliberation: an AI that must explain+why it wants to foreground a window will, more often than not, realize it+does not need to. This is not access control, it is a forcing function for+judgement, and in practice it makes AI callers behave almost perfectly.++pup is the proof: pup opens browser windows in the BACKGROUND by default so+the user is never disturbed, and `pup_raise_os_window` refuses without a+`foregroundReason` (at least 10 characters, quoting or paraphrasing what the+USER asked for). The refusal is `errorCode: foreground_reason_required` plus+a hint showing the retry. Granted raises are logged and surfaced as+`lastForeground {ts, verb, reason}` so the user can audit who put a window+on their screen and why.++## Design the norm first, then gate the exception++Reason gating only works when the default path needs no reason. Structure+every capability as a safe default plus a gated escalation:++| Norm (ungated) | Escalation (reason-gated) |+|---|---|+| open window in background, flash taskbar | foreground / steal focus |+| write a new file | overwrite or delete an existing one |+| render a preview | publish to a registry or send externally |+| queue work | kill another thread's running job |+| soft-stop own instance | kill a shared server others may be using |++If you find yourself gating everyday verbs, the defaults are wrong: fix the+defaults instead of taxing every call.++## The three rungs++1. **Hint**: the call succeeds but the response carries `_hint` text+ teaching a better pattern ("this window is already open; navigate it+ instead of spawning another"). Hints steer without blocking.+2. **Teaching refusal**: the call fails with a structured payload that names+ the missing piece and shows the exact retry. Never a bare 400: the+ caller is an AI, and your error text is a prompt it will follow.+3. **Confirm flow** (for genuinely dangerous ops): refuse the FIRST call and+ name what is at stake, then require `confirm: true` on the retry. ab's+ `bridge_kill` is the model: if other threads used the bridge in the last+ 5 minutes, the refusal NAMES those threads, so the caller can decide+ with facts instead of blind confidence.++## The refusal payload++```json+{+ "ok": false,+ "errorCode": "reason_required",+ "error": "Foregrounding a window interrupts the user, so it requires a reason.",+ "hint": "Re-call this verb with a \"reason\" field (>= 10 chars) quoting or paraphrasing what the USER asked for, e.g. {\"reason\": \"user said 'show me the hero in pup'\"}. If the user did not ask to see this, do NOT foreground: flash the taskbar instead and let them bring it up."+}+```++Rules:++- **The reason is written for a human reading a toast under time pressure.**+ One plain line: what is about to happen and why. The strongest reasons+ quote the user's own words; require a minimum length (10 chars) so "test"+ and "because" fail.+- **Identity and reason are separate contracts with separate refusals**+ (mirror ab): satisfying one never satisfies the other. A gated verb wants+ both `aiThread` and `reason`.+- **Offer the alternative in the hint.** The pup refusal above does not just+ demand a reason, it names the background-first path (flash, don't raise).+ Most gated calls should end with the AI taking the alternative.+- **Log and surface every grant.** Keep a `lastDisruption {ts, verb, thread,+ reason}` field in `GET /state`, write it to the console ring buffer, and+ show it in the UI (a toast or activity line), so "which conversation did+ that, and why" is always answerable.++## Node sketch++```js+function requireReason(req, res, body, what, alternative) {+ const reason = body && typeof body.reason === 'string' ? body.reason.trim() : '';+ if (reason.length >= 10) {+ state.lastDisruption = { ts: Date.now(), verb: req.url, thread: req.aiThread, reason };+ logLine('warn', `DISRUPTION granted: ${req.url} by "${req.aiThread}": ${reason}`);+ return null;+ }+ res.writeHead(400, { 'Content-Type': 'application/json' });+ res.end(JSON.stringify({ ok: false, errorCode: 'reason_required',+ error: what + ' requires a reason.',+ hint: 'Re-call with a "reason" field (>= 10 chars) quoting what the USER asked for. ' + alternative }));+ return true;+}+// requireReason(req, res, body, 'Foregrounding a window',+// 'If the user did not ask to see it, flash the taskbar instead.')+```++Pair with `app-creator-caller-identity` (who) and surface both in the audit+trail. For which surfaces default to background and how to signal instead+of foregrounding, see `app-creator-surfaces` and the `foreground-etiquette`+skill.
skills/app-creator-server-lifecycle/SKILL.md+56−111@@ -1,99 +1,46 @@ --- name: app-creator-server-lifecycle description: >- Server lifecycle rules for every Adom app: idle self-shutdown (the reaper),- caller identity (every AI thread names itself on every call, and the server- refuses anonymous callers with a teaching reprimand), reasons on disruptive- verbs, the per-thread instance registry, reuse-instead-of-respawn, and- version-drift detection after package updates. Read when building any app- server, and when you hit caller_identity_required or reason_required from- an Adom app. Trigger words: server lifecycle, clean up my servers, zombie- server, leaked server, orphaned server, idle shutdown, self shutdown, ttl,- reaper, ai-thread name, aiThread, caller identity, X-Adom-Thread,- caller_identity_required, reason_required, instance registry, list- instances, reuse instance, already running on port, duplicate instance,- stale instance, version drift, port auto, too many node servers.+ How an Adom app server cleans up after itself: the 24h idle reaper with+ lossless per-thread snapshots, the instance registry with <app> ls and+ reuse-instead-of-respawn, --port auto, and version-drift detection after+ package updates. Read when building any app server, or when a container+ has accumulated zombie servers. Trigger words: server lifecycle, clean up+ my servers, zombie server, leaked server, orphaned server, idle shutdown,+ self shutdown, ttl, reaper, instance registry, list instances, reuse+ instance, already running on port, duplicate instance, stale instance,+ version drift, port auto, too many node servers. --- Parent skill: **app-creator** -# Server lifecycle: clean up after yourself, and know who is calling+# Server lifecycle: clean up after yourself -Adom apps are mini web servers that AI threads spawn freely. Without lifecycle-rules they accumulate: the motivating incident (2026-08-11) was **13 zombie-hero-studio instances** left running over 3 days. Twelve were on stale code-after a package update (their install dir had been deleted underneath them),-three were duplicate studios posing the same wiki page because each new thread-forgot the last thread's instance, and all of them were silently clobbering one-shared state-snapshot file. Only one had ever heard of `/shutdown`, and nobody-called it.+Adom apps are mini web servers that AI threads spawn freely. Without+lifecycle rules they accumulate: the motivating incident (2026-08-11) was+**13 zombie hero-studio instances** left running over 3 days. Twelve were on+stale code after a package update (their install dir had been deleted+underneath them), three were duplicate studios for the same wiki page+because each new thread forgot the last thread's instance, and all of them+were clobbering one shared state-snapshot file. Only one instance even had+the polite `/shutdown` endpoint, and nobody ever called it. The lesson is structural, not behavioral: **agents forget, so servers must manage themselves.** A `/shutdown` endpoint that a well-behaved caller is-supposed to hit is not a lifecycle plan. These six rules are.--## Rule 1: Every caller identifies its AI thread, on every call--Adom Bridge (ab) and pup bridge already enforce this pattern; apps follow the-same conventions (see `adom-bridge-caller-identity` for the origin story).--- **Spawn**: `<app> start --ai-thread "kicad-bridge dev"`. The flag is- required, not optional.-- **Every state-changing HTTP request**: carry the thread name in the- `X-Adom-Thread` header, or as a top-level `aiThread` field in the JSON body.- Read-only endpoints (`GET /state`, `GET /console`) stay open so debugging is- never gated.-- **Identity is self-reported and is never authorization.** It is a label for- attribution, logging, and instance management. Never grant privilege based- on it.--Why per-call and not an env var: a real container runs many concurrent AI-threads sharing one shell environment. A shared `ADOM_AI_THREAD` export means-every thread claims the same name (plausible and wrong beats absent), and-concurrent threads race to overwrite it. Per-call identity is the only form-that attributes correctly. The env var is acceptable only in single-agent-containers (CI, dedicated job boxes).--## Rule 2: Anonymous callers get a teaching refusal, not silence--When a state-changing request arrives with no thread identity, refuse it, and-make the refusal TEACH. The caller is an AI: your error text is a prompt it-will read and obey. A bare 400 wastes a round trip; a reprimand that names the-exact fix converts the failure into compliance on the very next call.--```json-{- "ok": false,- "errorCode": "caller_identity_required",- "error": "This server requires every AI caller to identify its thread.",- "hint": "Retry with header 'X-Adom-Thread: <your thread name>' or add a top-level \"aiThread\" field to your JSON body. Example: curl -X POST localhost:8846/state -H 'X-Adom-Thread: kicad-bridge dev' -d '{...}'. Pick a short human-readable name for THIS conversation and reuse it on every call."-}-```--Return HTTP 400 with `errorCode: caller_identity_required` (the same code ab-uses, so callers that already know ab's contract recognize it instantly).--## Rule 3: Disruptive verbs require a reason--Any endpoint that interrupts the human or destroys state (foregrounding a-window, overwriting a file, killing a job, publishing, deleting) additionally-requires a `reason` string in the request body. Missing reason gets the same-teaching treatment, `errorCode: reason_required`, with a hint naming the field.+supposed to hit is not a lifecycle plan. These four rules are. -Log `thread + verb + reason` to the server's console ring buffer, and surface-it in any activity view or toast the app has. The point is that the human can-always answer "which conversation did that, and why" without asking around.-pup bridge's window-foreground verb is the reference example: identity on-every call, reason on the disruptive ones.+(Who is calling, and how to refuse anonymous or unjustified calls, are the+sibling skills `app-creator-caller-identity` and `app-creator-reason-gating`.+This skill assumes every instance knows its owning thread.) -## Rule 4: Idle self-shutdown (the reaper), default 24 hours+## Rule 1: Idle self-shutdown (the reaper), default 24 hours -Track a `lastActivity` timestamp on every HTTP request. A timer checks it once-a minute; when the server has been idle past the TTL it reaps itself:+Track a `lastActivity` timestamp on every HTTP request. A timer checks it+once a minute; when the server has been idle past the TTL it reaps itself: 1. Finish pending work (file writes, running renders).-2. Write a final state snapshot to disk (Rule 5 makes this lossless).+2. Write a final state snapshot to disk (Rule 2 makes this lossless). 3. Remove the Hydrogen webview tab (`adom-cli hydrogen workspace remove-tab`).-4. Remove its registry entry (Rule 6) and `process.exit(0)`.+4. Remove its registry entry (Rule 3) and `process.exit(0)`. ```js // Node reference implementation@@ -104,36 +51,37 @@ let lastActivity = Date.now(); // lastActivity = Date.now(); if (!KEEP_ALIVE) setInterval(() => { if (Date.now() - lastActivity > TTL_H * 3600e3) {- saveSnapshot(); // Rule 5: lossless- deregisterInstance(); // Rule 6+ saveSnapshot(); // Rule 2: lossless+ deregisterInstance(); // Rule 3 removeWebviewTab(); process.exit(0); } }, 60e3).unref(); ``` -24h is the right default for interactive tools: a user slowly finishing a task-over days keeps touching the server, and every touch resets the clock; a-thread that generated its artifact and moved on stops touching it, and the-server is gone a day later. `--keep-alive` opts out for genuine daemons;-`--ttl <hours>` tunes it. Do not special-case "done" events (like a generate-button): idle-reset subsumes them.+24h is the right default for interactive tools: a user slowly finishing a+task over days keeps touching the server, and every touch resets the clock;+a thread that generated its artifact and moved on stops touching it, and+the server is gone a day later. `--keep-alive` opts out for genuine+daemons; `--ttl <hours>` tunes it. Do not special-case "done" events (like+a generate button): idle-reset subsumes them. Expose the TTL as a Settings+entry too (`app-creator-settings`). -## Rule 5: Reaping must be lossless: per-thread snapshot + resurrection+## Rule 2: Reaping must be lossless: per-thread snapshot + resurrection The reaper is only safe if being reaped costs one relaunch, never lost work. -- On every state change (debounced) and on reap, persist state to a snapshot- file **keyed by the owning thread**, e.g.+- On every state change (debounced) and on reap, persist state to a+ snapshot file **keyed by the owning thread**, e.g. `~/.adom/instances/<app-slug>/snapshots/<thread-slug>.json`.-- On `start --ai-thread X`, if a snapshot for X exists, restore it and say so- in the boot log.+- On `start --ai-thread X`, if a snapshot for X exists, restore it and say+ so in the boot log. - **Never share one snapshot file across instances.** Hero-studio did (13 writers, one `state-snapshot.json`), and instances restored each other's state after restarts. Per-thread keying is what makes parallel instances actually isolated, not just isolated in memory. -## Rule 6: A registry makes instances discoverable, reusable, and auditable+## Rule 3: A registry makes instances discoverable, reusable, and auditable Each instance writes a registry entry at boot and keeps it fresh: @@ -147,19 +95,19 @@ Each instance writes a registry entry at boot and keeps it fresh: Three behaviors hang off it: - **`<app> ls`** lists instances, liveness-checks each pid, prunes dead- entries, and prints port, thread, task, idle time, and version. This is the- command an AI runs before spawning anything.+ entries, and prints port, thread, task, idle time, and version. This is+ the command an AI runs before spawning anything. - **Reuse instead of respawn.** `start --ai-thread X` checks the registry first: a live instance for X means print `OK: already running on port 8849 (started 2h ago, task adom/kicad-bridge). Use that instance.` and exit 0. This is the fix for "the AI forgot it has one open." If a- DIFFERENT thread already has an instance on the same task, warn but allow;- duplicate-task is usually a mistake, not always.-- **Port allocation.** `--port auto` (bind port 0 or scan a range) and print- the chosen port as structured output. Manual port picking across parallel- threads is how collisions and wrong-port confusion happen.+ DIFFERENT thread already has an instance on the same task, warn but+ allow; duplicate-task is usually a mistake, not always.+- **Port allocation.** `--port auto` (bind port 0 or scan a range) and+ print the chosen port as structured output. Manual port picking across+ parallel threads is how collisions and wrong-port confusion happen. -## Rule 7: Surface version drift after package updates+## Rule 4: Surface version drift after package updates A long-lived instance keeps running the code it loaded at boot. When the package updates on disk, the fleet goes stale silently: in the motivating@@ -167,18 +115,15 @@ incident, instances ran 3-day-old code whose install directory had been deleted, so every snapshot write was silently failing into a void. - Record the package `version` in the registry entry at boot.-- `<app> ls` compares each entry against the on-disk package version and flags- mismatches: `WARN: port 8847 runs 0.9.0, disk has 0.16.1. Shut it down and respawn.`+- `<app> ls` compares each entry against the on-disk package version and+ flags mismatches:+ `WARN: port 8847 runs 0.9.0, disk has 0.16.1. Shut it down and respawn.` - After any `adompkg update`, run `<app> ls` and cycle stale instances. -## Checklist for every app server you build+## Checklist -- [ ] `--ai-thread` required at spawn; `X-Adom-Thread` / `aiThread` required- on state-changing requests-- [ ] Anonymous state-changing calls get the `caller_identity_required`- teaching refusal (hint shows the exact retry)-- [ ] Disruptive verbs require `reason`; thread + reason logged and surfaced-- [ ] Idle reaper on by default (24h TTL, `--keep-alive` / `--ttl` overrides)+- [ ] Idle reaper on by default (24h TTL, `--keep-alive` / `--ttl`+ overrides, TTL visible in Settings) - [ ] Reap sequence: pending work, snapshot, remove tab, deregister, exit 0 - [ ] Snapshots keyed per thread, restored on same-thread start; never one shared snapshot file
skills/app-creator-settings/SKILL.mdadded+73@@ -0,0 +1,73 @@+---+name: app-creator-settings+description: >+ Almost every Adom app ships a Settings window, even for a single toggle.+ Covers why, the gear-icon entry point, server-side persistence (GET/POST+ /settings, never localStorage), AI parity via curl, and the standard+ entries (TTL, default surface, dev mode). Read when scaffolding any app+ UI. Trigger words: settings window, settings panel, app settings, gear+ icon, toggle mode, preferences, configure the app, settings endpoint,+ persist settings.+---+Parent skill: **app-creator**++# Settings: almost every app ships one, even for one toggle++## Why++An app without a Settings surface hides its modes inside CLI flags and env+vars that only the AI knows about. The human then has to ASK the AI to+change behavior, and cannot even discover that a behavior is changeable.+A Settings window, even with a single toggle, gives the human:++- **Discoverability**: the app's adjustable behavior, visible in one place.+- **Agency**: flip a mode without summoning an AI thread.+- **Trust**: seeing the current mode ("opens in background: ON") explains+ why the app behaves as it does.++The bar is deliberately low: if your app has ANY mode, flag, or default, it+ships Settings. One toggle plus the version string is a perfectly good v1.++## The entry point++A gear icon in the app header (the 44px header from `adom-ui-design`),+top-right, monochrome white like every icon (main skill §1b), with a+hover-delayed tooltip (§7c). It opens a panel or modal styled per the brand+guide. Every setting row gets:++- a plain-language label (no jargon; NEVER ALL CAPS),+- a tooltip explaining what changes and what is preserved,+- instant apply with a toast confirming the change (no Save button unless a+ change is genuinely destructive or needs a restart, and then say so).++## Server-side, always++Webviews are fresh every session: localStorage is a trap (main skill §5).+Settings live on the SERVER and persist to disk:++- `GET /settings` returns the full settings object plus, for each entry,+ its type and allowed values (an `enums` map, like hero-studio's `/state`),+ so an AI never has to read the HTML to learn the options.+- `POST /settings` merges a partial update, validates against the enums,+ persists to `~/.adom/instances/<app-slug>/settings.json` (or the app's own+ config dir), and broadcasts the new state over the live channel so the UI+ reflects it immediately (`app-creator-live-channel`).+- Unknown keys and invalid values get a teaching refusal naming the valid+ set (`app-creator-reason-gating` rung 2), not a silent ignore.++This makes Settings part of 2-way comms (§7): the human flips the toggle in+the UI, the AI flips it with curl, and both see the same truth.++## Standard entries to include when applicable++| Setting | Backed by |+|---|---|+| Idle shutdown TTL / keep-alive | `app-creator-server-lifecycle` |+| Default display surface (wv / hbw / pup / nb) | `app-creator-surfaces` |+| Open windows in background (default ON) | `app-creator-surfaces` |+| Dev mode (enables the `/eval` channel) | main skill §7b |+| Version + update check | `<app> --version`, registry drift |++Scoping: settings are per-app, not per-thread (thread-scoped state belongs+in the pose/session snapshot, `app-creator-server-lifecycle` Rule 2). If a+setting genuinely differs per thread, it is state, not a setting.
skills/app-creator-surfaces/SKILL.mdadded+82@@ -0,0 +1,82 @@+---+name: app-creator-surfaces+description: >+ Which browser surface an Adom app should open its UI in, and how to+ respect the user's preference: wv (Hydrogen webview tab, the default),+ extwv (sites that refuse framing), hbw (Hydrogen's standalone browser+ window), pup (the AI's own logged-out Chrome on the desktop), nb (the+ user's real signed-in browser). Covers the decision table, the show verb+ with --surface, the proxy-URL platform trap, background-first etiquette,+ and window reuse. Read when wiring any app's show/open path. Trigger+ words: which surface, webview vs pup, open in wv, open in hbw, open in+ nb, show the app, surface preference, browser picker, where to open,+ display surface, simple browser.+---+Parent skill: **app-creator**++# Surfaces: where your app's UI opens, and who decides++There are now MANY ways to put a page in front of the user. An app that+hardcodes one is wrong somewhere: wrong under Hydrogen vs cloud, wrong for+logged-in vs logged-out checks, wrong for the user who prefers a full+window. Your app must know the surfaces, pick a sane default by context,+and let the user override it.++## The surface table (canonical shorthand from the `definitions` skill)++| Surface | What it is | When your app uses it |+|---|---|---|+| **wv** | Hydrogen webview panel tab, a first-class panel next to the editor. THE workhorse default. | Default everywhere. Open idempotently: `adom-cli hydrogen webview open-or-refresh --name "<Tab>" --url "<URL>"`. |+| **extwv** | A Hydrogen panel tab backed by native WebView2. Opt-in escape hatch. | Only when the target site refuses framing (X-Frame-Options / CSP). Hydrogen-only. |+| **hbw** | Hydrogen Browser Window: Hydrogen's own standalone Tauri browser window (tabs, URL bar). | A page that deserves a full window but should stay Hydrogen-managed. Hydrogen-only: `POST /hdbw/open {url}`. |+| **pup** | The AI's own Chrome on the user's desktop (Puppeteer via ab, `pup_*` verbs). Cold profile, LOGGED OUT by design. Opens in the BACKGROUND by default. | Anonymous/public verification (what the world sees), fresh-user testing, showing pages when Hydrogen is absent. |+| **nb** | The user's real signed-in Chrome/Edge. Layer 2 (**nbe**, the extension) adds deep driving via `nbrowser_*`. | Anything needing the user's real logins and trust. |+| VS Code Simple Browser | NOT a surface. | NEVER. No live channel, no console read-back, no drivability. Using it is a bug. |++## The show verb++Every app ships `<app> show` (the main skill's mandatory display section),+and it takes the surface as an argument with a persisted default:++```+<app> show [--surface wv|extwv|hbw|pup|nb]+```++- No flag: use the default from Settings (`app-creator-settings`), falling+ back to context detection: under Hydrogen prefer wv; in a cloud container+ with no Hydrogen panel available, pup on the user's desktop via ab.+- The chosen surface is a USER preference, so store it server-side and show+ it in Settings. Do not make the AI re-decide (or re-ask) every time.++## The URL trap (most common surface bug)++The correct URL depends on where the surface renders:++- **Cloud container + wv**: the tab renders in the user's browser, so+ `localhost` is WRONG. Use the slug proxy URL from `VSCODE_PROXY_URI`+ (`https://<slug>.adom.cloud/proxy/<port>/`), and remember every asset and+ fetch inside the page must use RELATIVE urls (main skill §7a).+- **Under Hydrogen + wv/hbw**: same machine, `http://localhost:<port>` is+ correct.+- **pup / nb on the desktop**: the desktop cannot reach the container's+ localhost; always the proxy URL.++## Etiquette: background-first, reuse, never steal focus++- pup windows open in the background BY DEFAULT and that is correct: signal+ updates with a taskbar flash (`pup_alert_window`) and let the user bring+ the window up. Foregrounding is a reason-gated escalation+ (`app-creator-reason-gating`, and the `foreground-etiquette` skill).+- REUSE windows and tabs: navigate an existing wv tab by its stable+ `--name`; keep ONE pup session per task with a tab per page+ (`pup_open_tab`), never a new window per update. Maximize a pup window+ once at creation, then never resize, re-maximize, or re-foreground it.+- Never switch the active tab out from under a user who is looking at the+ window; open new content as a background tab and flash.++## In the app's SKILL.md++The main skill already mandates a "Displaying this app" section in every+scaffolded app's SKILL.md naming these surfaces and banning Simple Browser.+Point it at the app's `show` verb and its Settings-persisted default so any+AI thread showing the app lands on the user's preferred surface.
uninstall.sh+3−1@@ -1,5 +1,7 @@ #!/bin/bash set -e rm -rf "$HOME/.claude/skills/app-creator"-rm -rf "$HOME/.claude/skills/app-creator-server-lifecycle"+for sub in caller-identity reason-gating server-lifecycle settings surfaces live-channel; do+ rm -rf "$HOME/.claude/skills/app-creator-$sub"+done echo "Uninstalled app-creator (+ sub-skills)"