Living Spaces: Why and How We Compile Zero-Token Interactive Micro-Apps
For quick answers, code diffs, and one-off lookups, plain chat and Markdown files are unbeatable.
But once you start managing something that evolves over days—a multi-region release cutover, a 5-day Kyoto family trip, an architecture comparison matrix, or a long-running research tracker—linear chat fights you at every step. Finding Tuesday’s schedule means scrolling past 40 messages. Checking off one blocker means making the model burn thousands of tokens regenerating a whole Markdown wall, wiping out whatever filters or sort order you had open.
Inside github.com/zjshen14/agy-hq (following Part 1 and Part 2), we built Living Spaces (internal/living/): interactive, single-file web micro-apps compiled deterministically from a small space.json file and locked inside a three-layer browser sandbox.
This post explains why you would want a compiled micro-app instead of Markdown or ad-hoc LLM-generated HTML, and how you actually create, use, check off, and keep one updated day to day at 0 LLM tokens after creation.
1. Why Use a Micro-App Instead of Chat, Markdown, or LLM-Written HTML?
If an agent can already write Markdown tables—or generate a custom React page on the spot—why build a compiler in between?
| Approach | Updates cost tokens? | Stays interactive across days? | Safe next to local agent tools? | Works offline on phone? |
|---|---|---|---|---|
| Plain Chat / Markdown | Every table rewrite costs tokens | Static prose only; no filters, map pins, or sorting | Safe, read-only text | Readable, not interactive |
| Ad-Hoc LLM HTML / React | Every edit asks the model to regenerate markup | Fragile; layout, dark mode, and filters drift per run | Unsafe if hosted beside localhost APIs/tokens | Breaks if it relies on external CDNs or localhost |
Living Space (space.json -> Go) | Model writes space.json once; refreshes cost 0 tokens | Persists in vault/ with audience views, sort, search & sync | 3-layer CSP + opaque null-origin sandbox | Exports a single self-contained HTML artifact (space_<slug>.html) |
Two real-world patterns made the difference clear for us:
- Multi-view plans need lightweight interaction, not another chat turn: During a deployment cutover, engineers want P99 POP latency bars and live workspace status, while a lead just wants the readiness gauge (
2 / 3) and go/no-go checklist. On a family trip itinerary, parents may want a 中文 mobile view while you toggle Adult vs. Kids stops. Regenerating separate chat replies for each stakeholder is tedious; clicking a filter pill or language button takes milliseconds. - State shouldn’t die when a conversation wraps: Single chats compact or get archived. A Living Space sits in your private vault (
<vault>/living_spaces/<slug>/index.html), links directly to a multi-day goal (hq goals), and refreshes live underlying data via deterministic CLI commands without ever waking the LLM again.
When not to use one: Keep single-turn coding help, PR reviews, and quick research notes in plain chat or Markdown. Reach for a Living Space when you expect to revisit, filter, sort, or check off the same structured plan across multiple sessions.
2. How You Actually Use a Living Space (Day 1 to Day N)
Here is the real workflow from first prompt to daily updates on both desktop and phone:
Step 1 — Start from a normal prompt (the model writes space.json once)
You don’t write HTML or hand-craft big schemas yourself. You just describe the multi-day plan in conversation—for example:
- “Build a Q4 Edge Proxy Cutover space tracking US-West, EU-Central, and APAC with a go-live checklist.”
- “Plan our 5-day Kyoto family trip with Adult/Kids perspectives and English/中文 support.”
Following its workspace heuristic (AGENTS.md), the coordinator creates or links an hq goal (q4-edge-cutover), translates your structure into one compact space.json (arrays trimmed below for readability), and compiles it in Go:
{
"schemaVersion": 1,
"slug": "q4-edge-cutover",
"theme": "heritage",
"goalSlug": "q4-edge-cutover",
"title": { "en": "Q4 Edge Proxy Cutover (Demo)", "zh": "Q4 边缘网关切换作战室(演示)" },
"locales": ["en", "zh"],
"perspectives": [
{ "id": "eng", "label": { "en": "Engineering Detail", "zh": "工程实施视角" } },
{ "id": "exec", "label": { "en": "Executive Summary", "zh": "负责人概览" } }
],
"dataSources": [
{ "id": "ds-ws", "kind": "hq_builtin", "target": "workspaces" }
],
"blocks": [
{ "id": "readiness-kpis", "type": "kpi_strip", "countdownAt": "2026-12-05T17:00:00Z", "showReadiness": true },
{ "id": "topology-map", "type": "interactive_map", "map": { "zones": [], "paths": [], "pins": [] } },
{ "id": "checklist", "type": "checklist_ledger", "title": { "en": "Cutover Gate Checklist" } },
{ "id": "region-matrix", "type": "comparison_table", "columns": [], "rows": [] },
{ "id": "lat-bars", "type": "metric_bars", "bars": [] }
]
}
Compiling that spec via hq space create --from-json=space.json builds <vault>/living_spaces/q4-edge-cutover/index.html in 0 additional LLM tokens. For trips or active regional cutovers, passing --tz=<IANA> --window-start=... --window-end=... (say --tz=Asia/Tokyo for the Kyoto trip) also scaffolds a linked timezone Goal automatically so countdowns, briefs, and quiet hours shift to local time.
Step 2 — Open it on Desktop or Phone
Once compiled, the micro-app shows up automatically in two places (using the dual-surface transport built in Part 1):
- On Desktop: Open the Work tab in HQ Console (Part 2) and click Open Sandboxed Space ↗ to view it right inside your IDE sidebar or browser.
- On Phone (
Remote Control): Runhq space export-artifact q4-edge-cutoverto copyspace_q4-edge-cutover.htmlinto the active conversation’s artifact directory so it renders offline inside Antigravity’s mobile Artifact Pane—nolocalhosttunnel needed.

Step 3 — Slice views, sort telemetry, and check off milestones safely
Inside the compiled page, every control works locally in the browser with zero network calls:
- Filter and translate on the fly: Toggle Engineering Detail vs. Executive Summary, switch English / 中文, click SVG map pins (← Prev / Next →), or sort table columns (P99 LATENCY ↑).
- Check off work without silent writes: Clicking an item in
checklist_ledgermarks it visually and reveals the burgundy Local checklist updated bar with a Copy Sync Cmd button (hq goals check-off <goalSlug> <itemID>). Paste that command into chat (or run it in terminal) to update your vault—a Living Space never mutates your vault directly from JavaScript.

Real --demo desktop compilation of q4-edge-cutover after ticking an open milestone: notice READINESS reads 2 / 3 (66%) cleanly before confirmation, because the Skipped (“won’t re-suggest”) item is excluded from the denominator.
Because layout uses responsive CSS grids inline, the exact same file stacks cleanly at phone width (390×840) inside mobile Remote Control with zero horizontal scroll:

Mobile viewport (390×840): opens offline via space_<slug>.html in Remote Control with full filtering and readiness progress.
Step 4 — Keep it live across days in 0 LLM tokens
Think of dataSources in space.json like spreadsheet formulas. Instead of re-prompting the agent whenever branches merge, live URLs/statuses change, or checklist gates clear, four instant Go commands keep the page fresh:
hq space refresh <slug>: Re-evaluates declared data sources (workspaces, activegoals,delegatesqueues,obstask counts, livemonitors, or allowlistedtrusted_argvbinaries) and recompilesindex.html.hq space sync-goal <slug>: Pulls updated three-state milestones (Open / Confirmed / Skipped) from the linked goal straight intokpi_stripandchecklist_ledger.hq space note <slug> --title=... --text=... --tone=...: Appends a timestamped update card (info,warn, orok) directly into the Space’sowner-notesblock and rebuilds without touching raw JSON.hq space export-artifact <slug>: Writes the updated self-containedspace_<slug>.htmlto your conversation artifact folder for mobile viewing.
Every { "en": "...", "zh": "..." } string compiles into inline data-i18n dictionaries switched immediately via English / 中文. (Honest boundary: built-in compiler chrome like “All Views”, “Filter this space…”, and single-string items synced from goals.json still render in English today.)
3. Inside the Compiler: 8 Blocks & 5 Built-In Themes
Keeping the model constrained to typed JSON blocks gives you consistent light/dark UX, predictable mobile layout, and zero brittle CSS generation. Mix any combination of eight blocks across five themes (modern, editorial, heritage, ocean, forest, plus ◐ dark/light toggle):
| Block | What it’s for |
|---|---|
kpi_strip | Headline metrics, timezone countdown timer, and live goal readiness meter |
interactive_map | SVG zones and paths with clickable numbered pins and a ← Prev / Next → tour |
checklist_ledger | Three-state ledger (Open / Confirmed / Skipped tombstones) with copy-to-sync CLI banner |
comparison_table | Client-side sortable multi-column matrix (click ↑/↓ on any header) |
metric_bars | Percentage bars overlaid with warn and critical threshold ticks |
timeline_accordion | Step-by-step runbooks or daily trip itineraries with Expand All toggle |
callout_notes | Action cards with deep links and copy-to-clipboard CLI buttons |
story_cards | Narrative highlight cards filtered jointly alongside map pins by perspective and tag |
4. Security Architecture: Keeping Model-Authored Apps Away from HQ Secrets
If your local console (127.0.0.1:4242) can stage GitHub PR merges, Gmail drafts, Google Chat messages, and SHA-256 approvals, any model-compiled HTML page must be treated as untrusted code. Even if a malicious PDF inside inbox/ tricked the model into sneaking payloads into space.json, it must never be able to read a CSRF token or trigger Approve.
agy-hq puts three independent walls between a Living Space and its host console:
Three enforcement boundaries between a Living Space and agy-hq’s privileged control plane.
-
Layer 1 — Strict Compile-Time Escaping & Allowlists (
internal/living/):
Every string passes through Go’sstrings.Builderandhtml.EscapeString, with zero raw HTML template holes. Model-supplied attributes are validated strictly (viasafeHrefand SVG/tone validators ininternal/living/):- Color tones: lowercase letters, digits,
-and_only—cannot break out of a CSSclass. - SVG geometry: finite numbers only—cannot inject arbitrary tags into map geometry.
- Links:
http://,https://, orconversation://only (javascript:anddata:links are rejected). - Images: verified inline Base64 images only—no external image URLs.
- Color tones: lowercase letters, digits,
-
Layer 2 — Opaque
null-Origin<iframe>Sandbox on:4242:
Clicking Open Sandboxed Space ↗ in HQ Console renders the compiled page inside:<iframe sandbox="allow-scripts" src="/living-spaces/q4-edge-cutover/raw"></iframe>We deliberately omit
allow-same-origin. Without it, the browser isolates the frame into an anonymousnullorigin—like a guest locked in a room with no keys. Even if script somehow slipped past Layer 1, it cannot read parent cookies, touchwindow.parent, readx-sidecar-token, or reach Console write routes. (BecauselocalStoragethrowsSecurityErrorinside anullorigin, checklist state gracefully falls back to in-memory JS viatry/catch.) -
Layer 3 — Outbound Network Lockdown (
Content-Security-Policy):
Every/living-spaces/<slug>/rawHTTP response attaches a strict zero-egress CSP header:default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'Even if opened directly in its own browser tab outside the iframe,
fetch(),XMLHttpRequest, WebSockets, remote fonts/images,<base>hijacking, and HTML form submissions are all blocked at runtime.
Trade-Offs, Quickstart & Series Takeaways
Two practical trade-offs keep Living Spaces honest:
- Re-compiles are explicit & single-file apps use
'unsafe-inline': Live state updates happen when you runhq space refreshorsync-goal(0 tokens) rather than background sockets inside the iframe, and packing CSS/JS into one portable HTML file requiresscript-src 'unsafe-inline'—which is why Layers 2 and 3 lock down host privileges and network egress completely. - Reach for Markdown first on short tasks: Single-turn questions and code diffs belong in plain chat or notes; Living Spaces earn their keep on multi-day plans you revisit repeatedly.
Across all three parts: Part 1 put one template across desktop and phone surfaces, Part 2 turned that UI into an honest 5-plane monitoring dashboard, and Part 3 gave long-lived plans an interactive, 0-token micro-app runtime without handing HTML or secrets to the model. The common thread: the model decides what; deterministic code handles how, every time, for free.
Try It Locally in 30 Seconds
Spin up an isolated demo environment, compile a minimal dataSources-bound Living Space into it, open Work → Open Sandboxed Space ↗ in the console, and test a zero-token refresh:
./bin/hq init --demo
cat > cutover.json <<'EOF'
{
"schemaVersion": 1,
"slug": "q4-edge-cutover",
"theme": "heritage",
"title": { "en": "Q4 Edge Proxy Cutover", "zh": "Q4 边缘网关切换作战室" },
"locales": ["en", "zh"],
"dataSources": [
{ "id": "ds-ws", "kind": "hq_builtin", "target": "workspaces" }
],
"blocks": [
{ "id": "kpis", "type": "kpi_strip", "dataSourceId": "ds-ws", "countdownAt": "2026-12-05T17:00:00Z" },
{ "id": "ws-table", "type": "comparison_table", "title": { "en": "Live Workspaces", "zh": "工作区状态" }, "dataSourceId": "ds-ws" }
]
}
EOF
./bin/hq space create --from-json=cutover.json
./bin/hq space refresh q4-edge-cutover && ./bin/hq webui
Full Series
- Part 1 — Delivery Surfaces: One Template, Two Surfaces: How Antigravity Sidecars, Artifacts & Hook Hydration Work
- Part 2 — Monitoring Dashboard: Inside HQ Console Live: The 5-Tab Monitoring Dashboard for Personal Agent Systems
- Source Code: github.com/zjshen14/agy-hq
Scan with WeChat
Scan this QR code with WeChat to read or share on mobile.