How kunchenguid/lavish-axi works
Purpose and entry points
Lavish AXI is a local-first CLI for reviewing agent-authored HTML artifacts in a browser and returning human feedback to an agent. The executable entry is bin/lavish-axi.js, dispatching CLI behavior in src/cli.js. Core commands open/resume a review, long-poll feedback, end sessions, export standalone HTML, share externally, and install agent integrations.
Local server and session lifecycle
A persistent local HTTP server hosts editor chrome, artifact routes, browser APIs, and long-poll endpoints. src/server.js orchestrates serving, security boundaries, watching, and lifecycle; src/session-store.js persists sessions keyed by canonical artifact path; src/paths.js centralizes state and path policy. The server is normally loopback-only, can expose a Tailscale address, validates hosts/origins, and self-stops when idle.
Artifact review boundary
Artifacts remain author-owned HTML loaded in a sandboxed iframe; Lavish injects collaboration behavior without changing the saved artifact design. src/html-app.js serves/reconciles artifact documents, src/html-transform.js injects and removes runtime code as appropriate, and src/artifact-sdk.js provides in-artifact selection, annotation, feedback-control, snapshot, and layout-audit integration. This boundary preserves direct-browser rendering while permitting local relative assets through controlled server routes.
Feedback, polling, and attachments
Browser actions are accumulated as prompts, then delivered atomically to an agent’s poll request; layout detection itself never wakes the agent. Session state carries queue, presence, replies, and end attribution via src/session-store.js and src/server.js. Image attachment uploads are content-addressed local files managed by src/attachment-store.js, with admission, TTL, reference protection, and disk caps. src/async-mutex.js protects concurrent state-changing operations.
Review chrome, diagnostics, and whiteboards
The browser chrome owns annotation UX, conversation state, open-time render gating, responsive review layout, and reload preservation. Its primary assets are src/chrome-client.js and src/chrome.css. src/layout-warnings.js detects evidence-backed clipping, overflow, reachability, and occlusion findings and tracks their viewport-specific lifecycle. Mermaid source extraction/conversion and editable Excalidraw-style whiteboards are handled by src/mermaid-source.js, src/mermaid-node.js, src/whiteboard-core.js, src/whiteboard-store.js, and src/whiteboard-frame.js.
Packaging and agent-facing guidance
The published npm package bundles CLI, server/chrome assets, skill content, and plugin metadata. Build orchestration resides in scripts/build.js, scripts/build-plugin.js, and scripts/build-skill.js; plugin declaration is plugin.json. Agent guidance is runtime-discoverable through src/design-reference.js, src/playbooks.js, and src/skill.js, sourced from skills/lavish/SKILL.md.
Export, sharing, and integrations
src/export-bundle.js produces portable HTML by safely inlining local assets and removing Lavish runtime injection. src/html-app.js and src/share-password.js support publishing to the external ht-ml.app API, including private-page credentials and update keys; the API base is configurable for self-hosting. src/tailscale.js discovers and binds tailnet access. src/plugin.js installs local Agent Plugin registrations, while hooks are configured through CLI setup flows. Telemetry behavior is isolated in src/telemetry.js.
Main entry points: server.js Local HTTP server · cli.js Command dispatcher · chrome-client.js Review chrome · html-app.js Artifact document service
Components 22
CLI & package
- lavish-axi executable
bin/lavish-axi.js - Command dispatcher · Opens, resumes, polls, ends, exports, shares, and installs integrations.
src/cli.js - Package builders · Bundles the published CLI, assets, plugin, and skill.
scripts/build.js - Plugin declaration
plugin.json
Local review runtime
- Local HTTP server · Owns routes, security checks, file watching, and idle shutdown.
src/server.js - Session store · Persists sessions by canonical artifact path, including feedback and presence.
src/session-store.js - Path policy
src/paths.js - Async mutex · Serializes state-changing operations.
src/async-mutex.js - Attachment store · Applies upload admission, TTL, references, and disk caps.
src/attachment-store.js - Artifact document service · Serves and reconciles author-owned HTML and controlled local assets.
src/html-app.js - HTML runtime transform · Injects review runtime and removes it when required.
src/html-transform.js
Browser review surface
- Review chrome · Owns annotations, conversation UX, responsive layout, and reload preservation.
src/chrome-client.js - Chrome styles
src/chrome.css - In-artifact SDK · Enables selection, annotations, feedback controls, snapshots, and audit integration.
src/artifact-sdk.js - Layout diagnostics · Tracks evidence-backed clipping, overflow, reachability, and occlusion findings.
src/layout-warnings.js - Diagram & whiteboards · Converts Mermaid and supports editable Excalidraw-style boards.
src/whiteboard-core.js
Export & integrations
- Portable HTML export · Inlines local assets safely and strips Lavish runtime injection.
src/export-bundle.js - External sharing · Publishes to ht-ml.app with private credentials and update keys.
src/share-password.js - Tailnet access · Discovers and binds a Tailscale address.
src/tailscale.js - Agent guidance · Exposes design references, playbooks, and the packaged skill.
src/skill.js - Agent plugin installer
src/plugin.js - Telemetry
src/telemetry.js
Connections 23
- lavish-axi executable → Command dispatcher: dispatches
- Command dispatcher → Local HTTP server: starts and controls
- Command dispatcher → Portable HTML export: exports
- Command dispatcher → External sharing: shares
- Command dispatcher → Agent plugin installer: installs
- Package builders → Plugin declaration: packages
- Local HTTP server → Session store: loads and updates sessions
- Session store → Path policy: uses canonical paths
- Local HTTP server → Async mutex: guards mutations with
- Local HTTP server → Attachment store: accepts attachment uploads
- Local HTTP server → Artifact document service: serves artifact routes
- Artifact document service → HTML runtime transform: transforms documents
- HTML runtime transform → In-artifact SDK: injects
- Local HTTP server → Review chrome: serves browser APIs and chrome
- Review chrome → Chrome styles: renders with
- Review chrome → In-artifact SDK: coordinates sandbox review
- Review chrome → Layout diagnostics: displays diagnostics
- Review chrome → Diagram & whiteboards: hosts visual boards
- Review chrome → Local HTTP server: queues feedback and long-polls
- Local HTTP server → Tailnet access: optionally exposes via
- Artifact document service → External sharing: publishes reviewed HTML
- Command dispatcher → Agent guidance: discovers guidance
- Command dispatcher → Telemetry: reports through