README.md
Leveonas README
Canonical package overview, architecture pipeline, security model, quickstart commands, and framework support matrix.
Token-Optimized, Streaming-Native Intermediate Representation & Cross-Framework Compiler Runtime for Generative AI User Interfaces.
Leveonas sits between your backend and your LLM provider. Models emit compact Leveonas Markup (LM) using canonical tag(attr(value) child) syntax, and Leveonas compiles it deterministically across 48 supported targets into native React, Next.js, Vue, Svelte, Angular, Python, SQL, and streaming browser DOM patches.
Choose Your Integration Path
| Your Requirement | Recommended Path | Entry Point |
|---|---|---|
Existing app using OpenAI SDK, fetch, or AI builder | OpenAI-Compatible Proxy (Recommended) | POST /api/v1/chat/completions |
Progressive live UI streaming in a browser <iframe> | Streaming SDK + Runtime | createSession() (leveonas/sdk) + /leveonas-runtime.js |
| Compile existing LM strings to TSX / Vue / SQL | Compiler API / SDK | await compile(source) or POST /api/compile |
| Surgical follow-up edits across multi-file projects | Patch API | POST /api/patch |
| Private VPC / air-gapped compilation | Self-Hosted CLI Server | npx leveonas serve --port=4321 |
Installation (v0.6.0)
bash
# Local project dependency (recommended)
npm install leveonas@0.6.0
# Or install CLI globally
npm install -g leveonas@0.6.0Verify post-install:
bash
npx leveonas --version
npx leveonas --helpSee the Installation Guide for Bun, pnpm, yarn, Next.js .env.local, Express dotenv, Vite proxies, Windows PowerShell, and production browser runtime CSP setup.
Quickstart (app.lm)
1. Write Canonical LM (v1)
html
<REACT>
component(Counter)(
state(count, 0)
di(cs(p-6 rounded-xl border space-y-3)
h2(cs(text-lg font-semibold) Counter)
bo(tp(button) cs(px-4 py-2 rounded-lg bg-blue-600 text-white) oc(count++) Count: {count})
)
)
</REACT>2. Compile via CLI or SDK
bash
export LEVEONAS_API_KEY="lv_live_your_key"
# Offline syntax check (zero network calls)
npx leveonas check app.lm
# Compile via server (`--framework` selects dialect; `--target` selects output format)
npx leveonas compile app.lm --framework=react --target=code
npx leveonas compile app.lm --target=ui-irtypescript
import { compile, parse, lower, inspect, format, diagnose } from 'leveonas';
// 1. Offline synchronous tools (no network required)
const diagnostics = diagnose(sourceCode, { streaming: true });
const formatted = format(sourceCode);
const ast = parse(formatted, { framework: 'react' });
const uiIR = lower(ast, 'react');
// 2. Authenticated server compilation (async)
const result = await compile(formatted, {
apiKey: process.env.LEVEONAS_API_KEY,
serverUrl: 'https://leveonas.ainot.site',
framework: 'react',
documentMode: true,
});
if (!result.success) {
throw new Error(result.error ?? 'Compilation failed');
}
console.log(result.detectedTarget); // "react"
console.log(result.code); // Compiled React TSX48 Supported Targets & Stability
| Target Category | Count | Stability | LM Block Tags | Output |
|---|---|---|---|---|
| UI Frameworks (Common UI IR) | 5 | Stable | <REACT>, <NEXTJS>, <VUE>, <SVELTE>, <ANGULAR> | TSX, Vue SFC, Svelte, Angular TS + DOM/JS + Live Patches |
| Web Core & Styling | 9 | Stable | <HTML>, <TAILWIND>, <CSS>, <SCSS>, <JS>, <TS>, <SOLID>, <ASTRO>, <SVG> | Semantic HTML5, CSS, JS/TS, SolidJS, Astro |
| Backend & Databases | 8 | Stable | <PYTHON>, <NODE>, <SQL>, <PRISMA>, <DRIZZLE>, <MONGO>, <GRAPHQL>, <RULES> | FastAPI, Express/Hono, SQL, Prisma, Drizzle, Mongoose |
| Config, Infra & Patches | 13 | Stable | <PATCH>, <JSON>, <YAML>, <TOML>, <ENV>, <DOCKERFILE>, <SHELL>, <TERRAFORM>, <PROTOBUF>, <MAKEFILE>, <XML>, <MARKDOWN>, <TEMPLATE> | Config files, HCL, Protobuf, SEARCH/REPLACE diffs |
| Mobile & Polyglot | 13 | Beta | <REACT-NATIVE>, <DART>, <SWIFT>, <KOTLIN>, <GO>, <RUST>, <JAVA>, <PHP>, <CSHARP>, <RUBY>, <CPP>, <ELIXIR>, <LUA> | Expo, Flutter, SwiftUI, Compose, Go, Rust, etc. |
Security Guarantees
- Isolated Browser Sandbox:
/leveonas-runtime.jsand/leveonas.jsrun generated previews inside<iframe sandbox="allow-scripts">(strictly omittingallow-same-originso scripts execute in an opaque origin without cookie or storage access). - Directional
postMessageValidation: Host and iframe verifyevent.source === iframe.contentWindowandevent.source === window.parent, rejecting unknown types and__proto__/constructor/prototypekeys. - Patch & Attribute Hardening:
validatePatches()rejects inlineon*attributes,javascript:/vbscript:/file:URLs, CSSexpression(), and oversized batches before DOM mutation.
Documentation
- Installation Guide — Stack-by-stack setup, env loading, post-install check, CSP
- Public REST API Reference — HTTP endpoints, SSE wire contract, schemas, error codes
- SDK & Browser Runtime Reference — TypeScript interfaces,
compile(),createSession(),DOMPatchAppliertutorial - CLI Reference — Commands,
--frameworkvs--target, self-hosting - Security Architecture — Threat model & sandbox guarantees
- Stability & SemVer Policy — Public contract tiers
- Changelog — Release history (
v0.6.0)
License
MIT