Skip to main content
Glama
@agentprismform/agent-plugin

@agentprismform/agent-plugin

README.md
# AgentPrismForm

[![npm](https://img.shields.io/npm/v/%40agentprismform%2Fcore?color=cb3837&label=npm)](https://www.npmjs.com/org/agentprismform) ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg) ![Node >= 20](https://img.shields.io/badge/Node-%3E%3D20-339933.svg) ![MCP Tools: 20](https://img.shields.io/badge/MCP_Tools-20-6366f1.svg) ![i18n: EN / 中文](https://img.shields.io/badge/i18n-EN%20%7C%20%E4%B8%AD%E6%96%87-f59e0b.svg) ![Platforms: Vue 3 · React 18 · Miniapp](https://img.shields.io/badge/Platforms-Vue%20%7C%20React%20%7C%20Miniapp-0ea5e9.svg)

> **Language**: **English** | [简体中文](./README.zh-CN.md)  
> **Symbiotic with AI Agents · Zero-Canvas · Write Once, Refract Everywhere.**  
> [Live Showcase (EN/中文)](https://wangjian-damon.github.io/AgentPrismForm/playground/?lang=en) · [Agent-First Principles](./docs/AGENT_FIRST_PRINCIPLES.md) · [Integration & Self-Host Examples](./examples/) · [Contributing](./CONTRIBUTING.md) · [Changelog](./CHANGELOG.md) · [Launch Kit](./docs/LAUNCH_KIT.md)

<p align="center"><img src="./docs/assets/showcase-prism-en.png" alt="AgentPrismForm Pure Prism Showcase (English)" width="880" /></p>

| Draft Preview (Live SSE Tuning + EN/中文 Toggle + One-Click Freeze) | Final Deliverable (Zero Debug Chrome + Draft Recovery) |
|:---:|:---:|
| <img src="./docs/assets/preview-live-sse-en.png" alt="AgentPrismForm Draft SSE Preview (English)" width="360" /> | <img src="./docs/assets/preview-final-mode-en.png" alt="AgentPrismForm Final Deliverable (English)" width="360" /> |

**AgentPrismForm** is not another drag-and-drop low-code form builder. It is designed to **coexist symbiotically with AI Agents** (Antigravity, DeepSeek-Harness, Claude Code, Cursor): you describe what you need in your Agent session, the Agent runs a lightweight clarification round (including backend `data key` style and language), deterministically authors & self-tests a single `FormSchema` via **20 zero-dep MCP tools / CLI**, derives a full **Data Contract** (JSON Schema + TypeScript DTO + Field Dictionary + declarative `OutputMapping`), refracts it live across **Vue 3 Modern H5**, **React 18 Web/WebView**, **Native WeChat Miniapp**, and **standalone offline HTML** (with built-in `en-US` / `zh-CN` UI switching), scaffolds drop-in host pages directly into your repo (`form_scaffold_host`), and routes submissions via a **Local Data Hub** (JSONL inbox, UTF-8 BOM CSV export, and HMAC-SHA256 signed `WebhookSink`).

## Why AgentPrismForm?

We don't rebuild a heavy drag-and-drop studio, and we don't ask LLMs to hallucinate brittle JSX on every edit. **AgentPrismForm** pairs conversational Agent clarification with a deterministic multi-platform form kernel:

```mermaid
flowchart LR
  U["User Natural Language / PRD"] --> A["AI Agent (Clarify-First Skill + 20 MCP Tools)"]
  A -->|"schema-init / schema-patch / selftest"| B["Single Source FormSchema + ThemeConfig (EN/ZH)"]
  B --> C["@agentprismform/core (FormCore + Safe Expr + BFS Relations)"]
  C --> D1["Vue 3 Modern H5 (0 UI deps)"]
  C --> D2["React 18 Web / WebView (0 UI deps)"]
  C --> D3["WeChat Miniapp Native WXML"]
  C --> D4["Standalone Final HTML & SSE Live Reload"]
```

## Comparison

| Capability | AgentPrismForm | Traditional Web Form Libs | Prompt-to-JSX AI Builders |
|---|---|---|---|
| **AI Agent MCP + Atomic Patch + Diff Guard** | Built-in (20 zero-dep tools) | None | Full-file overwrite, breaks logic |
| **Headless Runtime Self-Test Gate (`selftest`)** | Real `FormCore` assertions | Manual unit tests | None |
| **True 3-Platform Parity (Vue / React / Miniapp)** | Native WXML + WebView + H5 | Web-only | Web-only |
| **Zero Heavy UI Library Lock-in** | 0 third-party UI deps | Often tied to AntD/MUI | Tied to Tailwind/Shadcn |
| **Algorithmic Validation (Mod-11 ID, Luhn Card)** | Built-in (`en-US` & `zh-CN`) | Custom plugins required | Regex-only |
| **Data Contract + `OutputMapping` + Local Data Hub** | JSON Schema, TS DTO, CSV, signed `WebhookSink` | DIY | None |
| **Mobile UX (Adaptive Keypad, Retina Signature, Review Masking, Draft Autosave)** | Built-in | DIY | DIY |

## Packages — 1 Entry for Your Agent, Everything Else Auto-Managed

> **Agent-First Principle**: You only install **1 package** into your AI Agent (`npx @agentprismform/agent-plugin install`). Your Agent automatically detects your workspace (Vue 3, React 18, WeChat Miniapp, or no frontend repo → zero-dependency standalone HTML) and pulls the right runtime on demand. See [Agent-First Principles](./docs/AGENT_FIRST_PRINCIPLES.md).

### Primary Entry (Install This)

| Package | Description |
|---|---|
| `@agentprismform/agent-plugin` | **[PRIMARY ENTRY]** Zero-dependency AI Agent CLI + 20-tool stdio MCP Server + Skill + SSE live reload + auto-detecting `scaffold-host` + standalone HTML exporter (with optional `submitUrl`) |

### Agent-Managed Platform Runtimes (Auto-Selected — 1 Package per Platform)

| Package | Description |
|---|---|
| `@agentprismform/render-vue` | Vue 3 one-package `<PrismForm>` renderer & `createFetchHostHandlers` (pulls internal deps automatically) |
| `@agentprismform/render-web` | React 18 one-package `<PrismForm>` renderer with full `en-US` / `zh-CN` i18n (pulls internal deps automatically) |
| `@agentprismform/render-miniapp` | WeChat Miniapp one-package native WXML/WXSS renderer (24 controls, incremental `setData` diffing) |

### Internal Engine & Starter Layers (Installed Automatically — No Manual Install Needed)

| Package | Description |
|---|---|
| `@agentprismform/core` | `[Internal Headless Engine]` Framework-agnostic `FormCore` runtime (state, validation, BFS relations, safe expressions) |
| `@agentprismform/render` | `[Internal Runtime]` Headless render state, dynamic visibility, layout, theme token bridge & `createFetchHostHandlers` |
| `@agentprismform/render-task` | `[Internal Runtime]` External task routing contract (signature, map picker, verification, custom tasks) |
| `@agentprismform/render-ui` | `[Internal Runtime]` Zero-dependency Vue 3 Modern UI kit (3 skins, EN/ZH i18n, X-keypad, Retina signature, 24 controls) |
| `@agentprismform/templates` | `[Starter Templates]` 5 decoupled cross-industry bilingual starter packs (Events, SaaS Onboarding, NPS, HR, Healthcare) |

## 10-Second Quickstart (AI Agent MCP + Skill)

```bash
# 1. Install Skill & merge MCP config for Antigravity, DeepSeek-Harness, Claude Code, or Cursor
node packages/agent-plugin/bin/install-host.cjs --host antigravity --scope user --write-mcp
# or --host deepseek-harness | claude | cursor | all

# 2. Derive JSON Schema, TypeScript DTO & Field Dictionary (snake_case or camelCase)
node packages/agent-plugin/bin/form-agent.cjs schema-contract \
  --schema packages/templates/schemas/event-registration.en.schema.json \
  --key-style snake_case

# 3. Export dual-track production release (Mobile Schema Bundle + zero-toolbar Final HTML + TS DTO + SHA-256 manifest)
node packages/agent-plugin/bin/form-agent.cjs release-export \
  --schema packages/templates/schemas/event-registration.en.schema.json \
  --theme packages/templates/schemas/event-registration.en.theme.json \
  --out-dir ./event-release

# 4. Let the Agent auto-detect your repo (Vue 3 / React 18 / Miniapp / zero-repo Standalone HTML) & deliver
node packages/agent-plugin/bin/form-agent.cjs scaffold-host \
  --schema packages/templates/schemas/event-registration.en.schema.json \
  --theme packages/templates/schemas/event-registration.en.theme.json \
  --out-dir ./my-app/src/forms/event-registration
# Optional: add --submit-url https://hooks.example.com/forms for zero-backend live submission on standalone HTML
```

### 5-Line Drop-In Integration (1 Package per Platform)

All 9 packages are live on npm ([@agentprismform/*](https://www.npmjs.com/org/agentprismform)) with **dual ESM/CJS `dist/` + TypeScript `.d.ts` + Sigstore provenance**:

```bash
# 1. Install AI Agent Plugin in ONE command (no global install needed):
npx @agentprismform/agent-plugin install --host antigravity --scope user --write-mcp
#    (also supports --host deepseek-harness | claude | cursor | all)

# 2. Vue 3 app — 1 package, 1 CSS import, 5 lines (<PrismForm>):
npm install @agentprismform/render-vue

# 3. React 18 app — 1 package, 0 CSS imports, 5 lines (<PrismForm> with full EN/ZH i18n):
npm install @agentprismform/render-web

# 4. Headless / BYO-UI app (AntD, Element Plus, Shadcn, Tailwind):
npm install @agentprismform/core @agentprismform/render
```

```tsx
// React 18 (or identical <PrismForm> in Vue 3 with @agentprismform/render-vue)
import { PrismForm, createFetchHostHandlers } from '@agentprismform/render-web'
import bundle from './form.bundle.json'

const handlers = createFetchHostHandlers({ smsUrl: '/api/sms', uploadUrl: '/api/upload' })
export default () => <PrismForm bundle={bundle} locale="en-US" hostHandlers={handlers} onSubmit={(data) => console.log(data)} />
```

## Integration Tiers — Bring Your Own UI (`examples/`)

You are never locked into our built-in UI kit. Pick the integration tier that matches your app:

1. **Tier 1 · Standalone Zero-Code**: Ship exported `final.html` directly, or self-host via [`examples/self-host-cloudflare-worker`](./examples/self-host-cloudflare-worker/) / [`examples/self-host-node-docker`](./examples/self-host-node-docker/).
2. **Tier 2 · Built-in Modern UI + `customControls` Override/Extend**: Keep 24 built-in controls and swap or register any widget by `item.key` or `item.type` in Vue 3 (`:custom-controls` / `MODERN_CUSTOM_CONTROLS_KEY`) or React 18 (`customControls` / `renderControl`). See [`examples/vue3-host-adapter`](./examples/vue3-host-adapter/), [`examples/react18-host-adapter`](./examples/react18-host-adapter/), and [`examples/miniapp-host-adapter`](./examples/miniapp-host-adapter/).
3. **Tier 3 · 100% Headless BYO-UI**: Consume only `@agentprismform/core` + `@agentprismform/render` to drive Ant Design, Element Plus, Vant, Shadcn/UI, Tailwind, or your internal design system in ~65 lines — see [`examples/custom-renderer-headless`](./examples/custom-renderer-headless/).

## Open-Core Extensibility (`SubmissionSinkAdapter`)

All core runtime, multi-platform renderers, 20 MCP tools, bilingual i18n, Data Contract derivation, `OutputMapping`, Local JSONL Data Hub, CSV export, and signed `WebhookSink` are **100% MIT licensed**. Custom enterprise connectors (CRM/ERP/OA/SaaS) plug cleanly into the zero-dependency `SubmissionSinkAdapter` interface without modifying the open core.

## License

MIT