Skip to main content
Glama
ISCV Live Preview

ISCV Live Preview

Official
by iscvlab
README.md
<div align="center">
  <img src="assets/logo.svg" width="76" alt="ISCV Live Preview logo" />
  <h1>ISCV Live Preview</h1>
  <p><strong>Live in-app HTML, standalone SVG, and deterministic motion-stage previewer for Antigravity 2.0 (SEP-1865 MCP App) with auto-reload, viewport switching, click-to-agent DOM inspection, and frame scrubbing.</strong></p>

  <p>
    <img src="https://img.shields.io/badge/version-1.0.0-1D4ED8?style=flat-square" alt="Version v1.0.0" />
    <img src="https://img.shields.io/badge/license-MIT-059669?style=flat-square" alt="MIT License" />
    <img src="https://img.shields.io/badge/Antigravity_2.0-MCP_App-0F172A?style=flat-square" alt="Antigravity 2.0 MCP App" />
    <img src="https://img.shields.io/badge/SEP--1865-Compliant-1D4ED8?style=flat-square" alt="SEP-1865 Compliant" />
    <img src="https://img.shields.io/badge/tests-65%2F65_PASS-059669?style=flat-square" alt="65 of 65 Tests Passing" />
  </p>
</div>

**ISCV Live Preview** turns Antigravity's Side Pane (`aux_pane`), Inline Chat, and Full-Page Sidebar (`global`) into a hardened live web and motion-stage preview studio—replacing external browser context-switching with zero-flash CSS hot-swap, 1-click viewport/aspect scaling (`Fit`, `Desktop`, `16:9`, `9:16`, `1:1`), click-to-agent DOM & live-editable WCAG 2.1 visual inspection (`updateModelContext` + opt-in `Sync to File`), standalone `.svg` element inspection, and automatic `window.seekToFrame(frame, fps)` timeline scrubbing.

<p align="center">
  <img src="docs/images/pane_canopy_motion_light.png" alt="ISCV Live Preview wide pane showing CanopyGIS v4 motion stage, DOM Inspector with WCAG 2.1 contrast, and seekToFrame scrubber" width="100%" />
</p>

| Narrow Side Pane (`460×780`, Stacked Inspector) | Inline Chat Preview Card (`≤ 800 px` Bounded) |
| :---: | :---: |
| <img src="docs/images/pane_narrow_sidepane_light.png" alt="Narrow Side Pane stacked layout with zero overflow" width="380" /> | <img src="docs/images/inline_card_light.png" alt="Compact Inline Chat Preview Card with motion scrubber" width="460" /> |

---

## ⚡ TL;DR — Capabilities & Verified Receipts

- **4 Core Differentiating Features (Zero External Browser Needed)**:
  1. **Targeted Auto Live-Reload**: Watches only the entry directory and served asset folders (`≤ 16` dirs) over same-origin SSE (`0` outer `connectDomains`, `0 / 4` `callServerTool` slots); hot-swaps external `.css` `<link>` tags and inline `<style>`-only edits with zero flash, and restores scroll + motion `frame`/`fps` after full HTML reloads.
  2. **Viewport & Aspect Switcher (`Fit`, `Desktop`, `16:9`, `9:16`, `1:1`)**: `ResizeObserver`-driven crisp zoom-to-fit (`Math.floor(W × s) × Math.floor(H × s)`, `0` overflow), auto-scaling fixed `1920×1080` stages inside narrow Side Panes and syncing dual-aspect `?aspect=9x16` / `?aspect=16x9` stages.
  3. **Click-to-Agent DOM Inspector & Live Visual Editor (`updateModelContext` + Opt-in `Sync to File`)**: Pierces `pointer-events: none` motion scenes and outer CSS `box-shadow` frames (`elementsFromPoint` + exact `getClientRects()` fragment hit-testing + shadow-rect hit-testing + clickable DOM ancestor breadcrumb & Figma-style **Layers dropdown** with live hover preview), renders exact multi-line fragment & SVG vector shape boundaries (`getScreenCTM()`), lets you live-edit **FG/BG colors** (with instant **WCAG 2.1 (`0.04045`) contrast** recalculation), **Box W/H**, **Typography (Size/Line-Height/Weight)**, data-driven **Active Effects & Styles** (auto-detects active `box-shadow`, `text-shadow`, SVG `stroke`/`stroke-width`/`dasharray`, `border`/`border-radius`/`outline`, `opacity`, `filter`/`backdrop-filter`, `mix-blend-mode`, `transform`, `clip-path`, or any valid CSS property via `CSS.supports()` + generic **`+ Style`**, zero hardcoded empty cards), multiline **Text (`Enter` → `<br>`)**, and safe-parsed **Outer HTML** (`0 ms` live DOM sync + `Reset`), attaches automatic `Before → After` diffs to your next prompt (strictly capability-gated via `app.getHostCapabilities()`), and optionally writes static `.html`/`.svg` edits back to disk via **`Sync to File`** (atomic write + watcher self-write echo suppression, failing safely on dynamic JS DOM).
  4. **Auto Motion Stage Scrubber & Standalone SVG Preview**: Automatically detects `window.seekToFrame(frame, fps)` across inline, `defer`, and `type="module"` scripts to reveal Play/Pause, `-1f`/`+1f` stepping, timeline scrubbing, and editable FPS (`24`/`30`/`60`) + duration controls; wraps standalone `.svg` files in a Light/Checker/Dark inspectable vector host.
- **Hardened Loopback Containment & Dual-OS Parity**: Strictly binds `127.0.0.1` (never `0.0.0.0`) with `Host` DNS-rebinding rejection, `timingSafeEqual` session tokens, `Referrer-Policy: no-referrer`, `realpathSync.native` symlink/junction containment, UNC/ADS/reserved-device rejection, dual-path `.env`/`.git`/key denylist, RFC 9110 `206`/`416` media `Range`, and clean `stdin` EOF zero-zombie shutdown on Windows, macOS, and Linux.
- **Zero-Dependency Runtime Bundles (`7.62%` of `10 MiB` Cap)**: Ships standalone `bin/server.cjs` (`1,656.9 KiB`), `ui/pane.html` (`780.1 KiB`), and `ui/inline.html` (`780.1 KiB`) with `0` external CDNs and `0` `node_modules` required at plugin runtime.
- **Release & Marketplace Status**: **LIVE** on GitHub ([`v1.0.0`](https://github.com/iscvlab/iscv-live-preview/releases/tag/v1.0.0), GitHub Actions CI `4 / 4` green across Linux, Windows, macOS, and Playwright E2E) • Antigravity Marketplace **IN PIPELINE** (submitted `2026-11-28`).

### One-Prompt Universal Agent Install

Compatible with **Any AI Agent (Cloud • IDE • CLI • Local LLM)**—paste this prompt into your agent or run the Antigravity CLI command below:

```text
Install the ISCV Live Preview Antigravity plugin from https://github.com/iscvlab/iscv-live-preview:
1. If the `agy` CLI is available, run `agy plugin install https://github.com/iscvlab/iscv-live-preview` and verify with `agy plugin validate --strict ~/.gemini/config/plugins/iscv-live-preview` (or `%USERPROFILE%\.gemini\config\plugins\iscv-live-preview` on Windows) and `agy plugin list --json`.
2. Otherwise, detect my OS and global plugin directory (`~/.gemini/config/plugins/iscv-live-preview` on Linux/macOS or `%USERPROFILE%\.gemini\config\plugins\iscv-live-preview` on Windows), clone `https://github.com/iscvlab/iscv-live-preview` there (runtime bundles require zero `node_modules`), and verify `npm test` passes.
```

```bash
agy plugin install https://github.com/iscvlab/iscv-live-preview
```

### Verified Bundle Footprint & 4-Gate Scorecard

| Evaluation Dimension | Component / Verification Gate | Visual Comparison Bar (`20-Block`) | Measured Result & Spec Receipt |
| :--- | :--- | :--- | :--- |
| **1. UI Bundle Size vs. `10 MiB` Cap ↓**<br>*(Lower = Better)* | **`ui/pane.html`**<br>**`ui/inline.html`**<br>`bin/server.cjs`<br>`10 MiB` MCP App Cap | `█░░░░░░░░░░░░░░░░░░░` **`7.62%`**<br>`█░░░░░░░░░░░░░░░░░░░` **`7.62%`**<br>`███░░░░░░░░░░░░░░░░░` `16.18%`<br>`████████████████████` `100.0%` | **`780.1 KiB`** (`798,850 B`, `0` CDN)<br>**`780.1 KiB`** (`798,865 B`, `0` CDN)<br>`1,656.9 KiB` (`1,696,662 B`, standalone)<br>`10,240.0 KiB` (Host limit) |
| **2. Tool Payload vs. `1 MiB` Cap ↓**<br>*(Lower = Better)* | **Loopback Metadata (`CallToolResult`)**<br>Base64 Inline Baseline (`CanopyGIS`) | `█░░░░░░░░░░░░░░░░░░░` **`0.19%`**<br>`████████████████████` `>1,000%` *(Fails)* | **`1.93 KiB`** (`1,976 B` for `9.94 MiB` stage / `12.34 MiB` w/ fonts)<br>`13.2–16.4 MiB` (Exceeds `1 MiB` & `10 MiB`) |
| **3. Security & Protocol Gates ↑** | **Gate 1: `test_http_security.mjs`**<br>**Gate 2: `test_mcp_stdio.mjs`** | `████████████████████` **`100.0%`**<br>`████████████████████` **`100.0%`** | **`26 / 26` PASS** (`CA-01..CA-03`, `CA-07` patcher, SSE cap; skips optional local fixture on CI)<br>**`8 / 8` PASS** (Live stdio + zero zombie; skips optional local fixture on CI) |
| **4. Browser E2E & Plugin Gates ↑** | **Gate 3: `test_e2e_playwright.py`**<br>**Gate 4: `agy plugin validate`** | `████████████████████` **`100.0%`**<br>`████████████████████` **`100.0%`** | **`31 / 31` PASS** (`21` synthetic on CI + `10` CanopyGIS/BoostX local; `0` console errs, `13/13` TTF, `0` flake8)<br>**`0` Errors / `0` Warnings** (`strict` mode) + `/xpublish` `0` Blocking / `0` Advisory |

---

## 1. Architecture & Surface Workflow

ISCV Live Preview binds an isolated `127.0.0.1` loopback HTTP server before MCP handshake so `_meta.ui.csp.frameDomains` declares only the exact ephemeral origin (`connectDomains: []`, `resourceDomains: []`). All previewed pages and raw HTML/SVG strings load under tokenized `/s/<sid>/<tok>/...` paths with an injected external same-origin `bridge.js` communicating with the outer MCP App shell over an inverted `MessageChannel` port (fully compatible with opaque `"null"` sandbox origins).

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    subgraph Canvas [" "]
        Host["Antigravity Host and Agent"] --> MCP["Stdio MCP Server (bin/server.cjs)"]
        MCP --> Shell["MCP App Shell (pane.html / inline.html)"]
        MCP --> Session["Session Engine and Root Resolver"]

        subgraph Loopback ["Hardened 127.0.0.1 Static Server"]
            HTTP["Tokenized HTTP and Range Server"]
            Watch["Targeted Served-Dir Watcher"]
        end

        Session --> HTTP
        Session --> Watch
        HTTP --> Frame["Preview Iframe (HTML, SVG, Motion Stage)"]
        Watch --> Frame
        Shell <--> Frame
        Shell --> Context["Gated updateModelContext and FileView"]
    end
    classDef default fill:#ffffff,stroke:#475569,color:#0f172a,stroke-width:1px
    style Canvas fill:#ffffff,stroke:#cbd5e1,stroke-width:1.5px,color:#0f172a
    style Loopback fill:#f8fafc,stroke:#94a3b8,color:#0f172a
```

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    subgraph Canvas [" "]
        subgraph Step1 ["1. Open or Update"]
            Tool["iscv_preview_open or iscv_preview_inline"]
            Picker["Empty Launch File Picker"]
        end

        subgraph Step2 ["2. Live Preview and Inspect"]
            View["Viewport Scale and Live Reload"]
            Inspect["DOM Pierce, WCAG 2.1 and Motion Scrub"]
        end

        subgraph Step3 ["3. Agent Context Loop"]
            Attach["Attach Selector and Contrast to Chat"]
            Edit["Agent Edits Source and Auto-Reloads"]
        end

        Tool --> View
        Picker --> View
        View --> Inspect
        Inspect --> Attach
        Attach --> Edit
        Edit --> View
    end
    classDef default fill:#ffffff,stroke:#475569,color:#0f172a,stroke-width:1px
    style Canvas fill:#ffffff,stroke:#cbd5e1,stroke-width:1.5px,color:#0f172a
    style Step1 fill:#f8fafc,stroke:#94a3b8,color:#0f172a
    style Step2 fill:#f8fafc,stroke:#94a3b8,color:#0f172a
    style Step3 fill:#f8fafc,stroke:#94a3b8,color:#0f172a
```

---

## 2. Quick Start & Installation

### Option A — Antigravity CLI Install

```bash
agy plugin install https://github.com/iscvlab/iscv-live-preview
agy plugin list --json
```

### Option B — Local Clone, Build & Sync

```bash
git clone https://github.com/iscvlab/iscv-live-preview.git
cd iscv-live-preview
npm ci
npm run build:sync
agy plugin validate --strict .
npm test
```

### Example Prompts in Antigravity

- *"Preview `index.html` live in the side pane with auto-reload and switch to `16:9`."*
- *"Open `assets/logo.svg` in ISCV Live Preview so I can inspect its vector elements."*
- *"Preview `canopygis_v4_motion_stage.html` at frame `80` with the motion scrubber."*

---

## 3. Benchmarks, Security Model & Tool Reference

| MCP Tool | Visibility | Surface Entrypoints | Primary Responsibility |
| :--- | :---: | :--- | :--- |
| **`iscv_preview_open`** | `model`, `app` | `aux_pane`, `global` | Open or live-update the Side Pane / Full-Page previewer (empty `{}` restores last file or opens Workspace File Picker) |
| **`iscv_preview_inline`** | `model`, `app` | Inline chat only | Render a bounded (`≤ 800 px`) live preview card inline in chat (`liveReload: false` default with opt-in Live toggle) |
| **`iscv_preview_list_files`** | `app` | — | Scan allowed workspace root for previewable `.html`, `.htm`, and `.svg` files (relative path, kind, size, and mtime) |
| **`iscv_preview_select_file`** | `app` | — | Switch active file from in-app File Picker or recover stale sessions after server restart |
| **`iscv_preview_control`** | `app` | — | Pause/resume watcher, persist stage FPS/duration overrides, or apply opt-in fail-safe `check_patch` / `patch_element` source sync |

<details>
<summary><strong>Deep Technical Reference: Tool Parameters, Security Containment & Motion Cascade</strong></summary>

### Shared Optional Input Schema (`iscv_preview_open` & `iscv_preview_inline`)

All inputs are strictly optional so Antigravity `+` and sidebar launches (`{}`) work seamlessly:

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `filePath` | `string` | Absolute or workspace-relative path to `.html`, `.htm`, or `.svg` file |
| `html` | `string` | Raw HTML or SVG string served from an in-memory buffer (`≤ 2 MiB`) |
| `rootDir` | `string` | Optional asset serving root (auto-resolved via 5-tier cascade when omitted) |
| `viewport` | `enum` | `"fit"` (default; scales fixed stages cleanly without switching preset), `"desktop"` (`1440×900`), `"16:9"` (`1920×1080`), `"9:16"` (`1080×1920`), or `"1:1"` (`1080×1080`) |
| `aspectParam` | `enum` | `"16x9"` or `"9x16"` query parameter for responsive dual-aspect motion stages |
| `inspect` | `boolean` | Start with DOM Inspect Mode & Inspector sidebar active (`default: true` in pane mode, `false` in inline mode) |
| `frame` | `number` | Initial motion frame (`≥ 0`, rounded to integer) to seek via `window.seekToFrame(frame, fps)` |
| `fps` | `number` | Override FPS (`1–240`; auto-inferred when omitted) |
| `durationSec` | `number` | Override stage duration in seconds (`> 0` and `≤ 3600`; auto-inferred when omitted) |
| `title` | `string` | Optional display title for the preview tab or inline card |
| `forceReload` | `boolean` | Force a full iframe reload even if the same file is already open (`default: false`) |
| `watchEnabled` | `boolean` | Enable automatic live-reload file watching (`default: true`, `iscv_preview_open` only) |
| `liveReload` | `boolean` | Enable live-reload watching on the inline card (`default: false`, `iscv_preview_inline` only) |
| `height` | `number` | Inline card viewport height (`180–660 px`, `default: 480`, rounded to integer, `iscv_preview_inline` only) |

### 5-Tier `rootDir` Resolution & Security Invariants

1. **Explicit `rootDir`** (must be canonical ancestor of entry file; rejects system/profile/drive roots).
2. **MCP Client Roots** (`listRoots()` guarded by client capabilities + `1500 ms` timeout + `fileURLToPath`).
3. **Project Marker Walk-Up** (`.git`, `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `AGENTS.md`, `GEMINI.md`, `.vscode`, `.antigravity` strictly below `homedir`/`Desktop`/drive roots).
4. **Static Relative-Ref Ceiling** (scans `src=`, `href=`, CSS `url(...)`, JS `import` `../` hops up to `8` levels, clamped strictly below forbidden roots—supporting deeply nested stages reaching shared font libraries).
5. **Entry Directory Fallback** (fails closed if entry directory is a forbidden system/profile/temp root).

All HTTP requests enforce `127.0.0.1` loopback peer address, exact `Host: 127.0.0.1:<port>`, constant-time `timingSafeEqual` token matching, `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`, `Cache-Control: no-store`, pre-`fs` rejection of UNC/ADS/reserved Windows device names, canonical `fs.realpathSync.native` containment, dual-path sensitive-file denylist (`.env`, `.git`, `.ssh`, `*.pem`, `*.key`, `id_rsa*`), and a server-wide cap of `3` active SSE connections with `event: hlp-paused` eviction.

</details>

---

## 4. License & Credits

Released under the [MIT License](LICENSE). Created and maintained by **ISCV | Isocurve Research Lab** ([`@iscvlab`](https://github.com/iscvlab)) — Napat Tan ([`@napattan`](https://github.com/napattan)).