npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openuidev/lang-core

v0.2.1

Published

Framework-agnostic core for OpenUI Lang: parser, prompt generation, validation, and type definitions

Downloads

10,623

Readme

@openuidev/lang-core

Framework-agnostic core for OpenUI Lang: parser, prompt generation, runtime evaluator, and type definitions.

npm License: MIT

Install

npm install @openuidev/lang-core
# or
pnpm add @openuidev/lang-core

What this package does

@openuidev/lang-core is the framework-agnostic foundation that powers OpenUI Lang. It has no React or other framework dependencies. Use it when you need to:

  • Parse OpenUI Lang text into a typed element tree (one-shot or streaming)
  • Generate system prompts from a component spec + tool definitions
  • Evaluate reactive expressions, $variables, and query results at runtime
  • Merge incremental edits into existing programs

If you're building a framework-specific app, use @openuidev/react-lang, @openuidev/vue-lang or @openuidev/svelte-lang instead. It re-exports everything from this package plus framework-specific components and hooks.

Quick Start

Parse OpenUI Lang

import { createParser } from "@openuidev/lang-core";

const parser = createParser(libraryJsonSchema);
const result = parser.parse(`
root = Stack([header, content])
header = CardHeader("Hello")
content = TextContent("World")
`);

console.log(result.root);       // ElementNode tree
console.log(result.meta);       // { incomplete, unresolved, statementCount, validationErrors }

Streaming parser

import { createStreamingParser } from "@openuidev/lang-core";

const sp = createStreamingParser(libraryJsonSchema);

// Feed chunks as they arrive from the LLM
const result1 = sp.set("root = Stack([header])\n");
const result2 = sp.set("root = Stack([header])\nheader = CardHeader(\"Hello\")\n");
// result2.root now resolves the forward reference

Generate a system prompt

import { generatePrompt, type PromptSpec } from "@openuidev/lang-core";
import componentSpec from "./generated/component-spec.json";

const prompt = generatePrompt({
  ...componentSpec,
  tools: myToolSpecs,
  toolCalls: true,
  bindings: true,
  editMode: true,
  preamble: "You build dashboards.",
});

Merge incremental edits

import { mergeStatements } from "@openuidev/lang-core";

const original = `root = Stack([header, tbl])\nheader = CardHeader("Tickets")\ntbl = Table([...])`;
const patch = `root = Stack([header, chart, tbl])\nchart = PieChart(...)`;
const merged = mergeStatements(original, patch);
// header and tbl kept from original, root replaced, chart added

API

Parser

| Export | Description | | :--- | :--- | | createParser(schema) | One-shot parser for complete text | | createStreamingParser(schema) | Incremental parser for streaming input | | parse(input, schema) | Convenience one-shot parse |

Prompt Generation

| Export | Description | | :--- | :--- | | generatePrompt(spec) | Generate a system prompt from a PromptSpec |

PromptSpec includes component signatures, tool definitions (ToolSpec[]), feature flags (toolCalls, bindings, editMode, inlineMode), examples, and custom rules.

ToolSpec describes a tool for prompt generation (name, description, inputSchema, outputSchema). Shape inspired by MCP's tool schema.

Runtime

| Export | Description | | :--- | :--- | | createQueryManager(toolProvider) | Manages Query/Mutation execution and caching | | createStore() | Reactive store for $variables and form state | | evaluate(ast, context) | Evaluate an AST node to a concrete value | | evaluateElementProps(root, context) | Recursively evaluate all props in an element tree | | extractToolResult(result) | Extract data from an MCP callTool response | | mergeStatements(original, patch) | Merge incremental edits by statement name |

Types

import type {
  PromptSpec,
  ToolSpec,
  ParseResult,
  ElementNode,
  ToolProvider,
  McpClientLike,
  QueryManager,
  Store,
  OpenUIError,
} from "@openuidev/lang-core";

Documentation

Full documentation, guides, and the language specification are available at openui.com.

License

MIT