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 RequirementRecommended PathEntry Point
Existing app using OpenAI SDK, fetch, or AI builderOpenAI-Compatible Proxy (Recommended)POST /api/v1/chat/completions
Progressive live UI streaming in a browser <iframe>Streaming SDK + RuntimecreateSession() (leveonas/sdk) + /leveonas-runtime.js
Compile existing LM strings to TSX / Vue / SQLCompiler API / SDKawait compile(source) or POST /api/compile
Surgical follow-up edits across multi-file projectsPatch APIPOST /api/patch
Private VPC / air-gapped compilationSelf-Hosted CLI Servernpx 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.0

Verify post-install:

bash
npx leveonas --version
npx leveonas --help

See 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-ir
typescript
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 TSX

48 Supported Targets & Stability

Target CategoryCountStabilityLM Block TagsOutput
UI Frameworks (Common UI IR)5Stable<REACT>, <NEXTJS>, <VUE>, <SVELTE>, <ANGULAR>TSX, Vue SFC, Svelte, Angular TS + DOM/JS + Live Patches
Web Core & Styling9Stable<HTML>, <TAILWIND>, <CSS>, <SCSS>, <JS>, <TS>, <SOLID>, <ASTRO>, <SVG>Semantic HTML5, CSS, JS/TS, SolidJS, Astro
Backend & Databases8Stable<PYTHON>, <NODE>, <SQL>, <PRISMA>, <DRIZZLE>, <MONGO>, <GRAPHQL>, <RULES>FastAPI, Express/Hono, SQL, Prisma, Drizzle, Mongoose
Config, Infra & Patches13Stable<PATCH>, <JSON>, <YAML>, <TOML>, <ENV>, <DOCKERFILE>, <SHELL>, <TERRAFORM>, <PROTOBUF>, <MAKEFILE>, <XML>, <MARKDOWN>, <TEMPLATE>Config files, HCL, Protobuf, SEARCH/REPLACE diffs
Mobile & Polyglot13Beta<REACT-NATIVE>, <DART>, <SWIFT>, <KOTLIN>, <GO>, <RUST>, <JAVA>, <PHP>, <CSHARP>, <RUBY>, <CPP>, <ELIXIR>, <LUA>Expo, Flutter, SwiftUI, Compose, Go, Rust, etc.

Security Guarantees

  1. Isolated Browser Sandbox: /leveonas-runtime.js and /leveonas.js run generated previews inside <iframe sandbox="allow-scripts"> (strictly omitting allow-same-origin so scripts execute in an opaque origin without cookie or storage access).
  2. Directional postMessage Validation: Host and iframe verify event.source === iframe.contentWindow and event.source === window.parent, rejecting unknown types and __proto__/constructor/prototype keys.
  3. Patch & Attribute Hardening: validatePatches() rejects inline on* attributes, javascript:/vbscript:/file: URLs, CSS expression(), and oversized batches before DOM mutation.

Documentation

License

MIT