cuesmith

    Pure MoonBit CUE toolchain with JSON Schema (Draft-07/2020-12 import, Draft 2020-12 export), OpenAPI 3.0/3.1 import, and cross-target LSP.

    cue
    cuesmith
    config
    schema
    validation
    lsp
    tooling
    Download zip
    Version
    0.2.1
    License
    Apache-2.0
    Last updated
    28 minutes ago
    Downloads
    38

    No dependencies

    #CueSmith (BigSaltyMan/cuesmith)

    English | 简体中文

    Pure MoonBit (moonc >= 1.0.0-rc1) implementation of CUE (Configure, Unify, Execute) — a typed configuration, validation, and data constraint language toolchain built on a mathematical value lattice with zero external library dependencies beyond moonbitlang/core.

    Release Status (v0.2.1 — mooncakes.io, GitHub Releases & GitHub Pages)

    BigSaltyMan/cuesmith@0.2.1 targets mooncakes.io (moon add BigSaltyMan/cuesmith), with 4-platform native CLI archives on GitHub Releases (v0.2.1) and the zero-backend Web IDE live at bigsaltyman.github.io/cuesmith. All 10 library packages pass strict 3-target (wasm-gc, js, native) checks (moonc >= 1.0.0-rc1, --frozen --deny-warn) and tests alongside full native CLI, LSP E2E, Web IDE, cue v0.12.1 differential oracle, and Unicode-3.0/Apache-2.0 release audits.


    #Why CueSmith?

    CapabilitySingle-File CUE PortOfficial Go cue CLICueSmith (BigSaltyMan/cuesmith)
    Runtime & Build TargetsSingle-target script / toy parserGo runtime binary only (no MoonBit / wasm-gc / JS embedding)Pure 3-target MoonBit (wasm-gc / js / native) — zero C runtime across all 10 library packages (only moonbitlang/core)
    Modules & Dependency GraphSingle-file only; no cue.modFull cue.mod evaluation (no built-in Mermaid/DOT/JSON graph output)Sandboxed cue.mod + :pkg imports + cuesmith graph (mermaid / dot / json + --include-stdlib)
    Equivalence-Verified trimNot supportedcue trim (Go-only; no MoonBit library API)cuesmith trim with Post-Trim Equivalence Self-Proof (re-parse + re-eval + bidirectional subsumption)
    Cross-Format Schema Diff & CI GatesNot supportedSeparate vet/export; no built-in cross-format diff-schema CI gateOpenAPI 3.0/3.1 + JSON Schema + CUE diff-schema emitting SARIF 2.1.0 & Markdown PR Summary CI gates (--fail-on-breaking)
    LSP 3.17 & Zero-Backend IDENoneGo cue lsp (native only; no browser Web Worker IDE)Single pure-MoonBit LSP 3.17 core powering BOTH native cuesmith lsp (VS Code / Neovim) AND zero-backend Web Worker CueSmith Web IDE
    Regex & Differential OracleHost regex / ad-hoc testsReference implementation (cue v0.12.1)Linear-time RE2-style Thompson NFA + UCD 16.0.0 (zero ReDoS) + 312-vector differential oracle (286 common matching cue v0.12.1, 22 cuesmith_ext, 4 known_diff)

    #30-Second Flagship CLI Showcase

    # 1. Cross-format OpenAPI / CUE / JSON Schema compatibility gate (Markdown PR Summary + SARIF 2.1.0) cuesmith diff-schema --format markdown examples/schema-compat-gate/openapi-v1.yaml examples/schema-compat-gate/openapi-v2.yaml cuesmith diff-schema --format sarif --fail-on-breaking -o compat.sarif examples/schema-compat-gate/schema-v1.cue examples/schema-compat-gate/schema-v2.cue # 2. Equivalence-self-proved trimming of redundant concrete fields cuesmith trim --diff examples/k8s-template/base.cue examples/k8s-template/prod.cue # 3. Module dependency graph visualization (Mermaid / Graphviz DOT / RFC 8259 JSON) cuesmith graph --format mermaid examples/multi-pkg-mod/app # 4. Pure-MoonBit LSP 3.17 language server over stdio (VS Code / Neovim) cuesmith lsp

    #10-Package Layered Architecture

    syntax ─► eval ─┬─► codec ─┬─► compat ──┐ ├─► builtins ─┼─► modsys ──┼─► trim ──► lsp ──► cli ──┬─► cmd/cuesmith (native + C11 I/O) └─────────────┴────────────┴──────────────────────────┴─► cmd/studio (browser JS ESM) ▲ BigSaltyMan/cuesmith (root facade: cuesmith.mbt)

    All 10 library packages (BigSaltyMan/cuesmith, syntax, eval, codec, builtins, modsys, trim, compat, lsp, cli) expose locked .mbti interfaces and compile cleanly on wasm-gc, js, and native. Host OS/browser glue lives strictly in cmd/cuesmith and cmd/studio (see Architecture Guide).


    #Highlights

    • Core CUE Frontend & Comment-Preserving Formatter (syntax)
      • UTF-8 byte-offset lexer (tokenize, tokenize_with_comments) with CRLF-safe comment tracking, hex/octal/binary numbers, _ separators, SI/IEC multipliers (K–P, Ki–Pi), normal/multiline/raw strings & bytes, and nested \(...) interpolation.
      • Core recursive-descent parser with strict JSON superset support, automatic comma insertion, definitions (#Def), hidden/optional/required/dynamic/pattern/aliased fields, let bindings, embeddings, ellipsis, comprehensions, all 7 operator precedence levels, and MAX_PARSE_DEPTH = 128.
      • Canonical cue fmt-style formatter (@cuesmith.format) preserving leading, inline, between-declaration, and EOF comments with verified idempotence.
    • Value Lattice Evaluator & Closedness Engine (eval)
      • Commutative, associative, idempotent unification (&) across Top (_), Bottom (_|_) with 14 structured CueErrorKind variants & exact field paths, null, bool, arbitrary-precision BigInt integers, arbitrary-precision base-10 Decimal floats (aligned with Go CUE apd.Decimal 24-digit half-even division, -0.0 normalized to 0.0), string, bytes, open/closed structs, open/closed lists, disjunctions (|) with defaults (*), and deferred validators.
      • Exact numeric/string/bytes bounds simplification & contradiction detection, predeclared aliases (uint, int8..int128, uint8..uint128, rune, float32, float64), AND-of-ORs struct closedness propagation, lattice subsumption (subsumes / subsumes_with_options / SubsumesOptions with final_mode, ignore_closed, discrete Int normalization, conservative regex checks, and closedness), two-phase struct & list comprehensions, outer-cycle-safe cycle detection, and bounded EvalLimits anti-DoS guardrails.
    • Equivalence-Verified Trimming (trim)
      • Removes redundant concrete fields implied by schemas, defaults, patterns, or comprehensions across single files, schema+data pairs, multi-file sets, and cue.mod packages (trim_source, trim_against_schema, trim_sources, trim_package, unified_diff, TrimOptions).
      • Enforces a Duplicate Concrete Sibling Guard, conservative #Def/_hidden/?/!/@attr/& {} preservation, comment-preserving formatting, and a mandatory fail-closed Post-Trim Equivalence Self-Proof (re-parse + re-eval + bidirectional subsumption).
    • Linear-Time RE2-Style NFA Regex Engine (UCD 16.0.0)
      • Pure-MoonBit Thompson NFA (O(states * chars)) with zero catastrophic backtracking, backed by SHA-256-verified Unicode 16.0.0 tables (eval/regex_unicode.mbt): Simple Case Folding (C+S), all 37 General Categories (30 subcategories + 7 major categories) plus ASCII/Any (39 property entries), all 171 Unicode Scripts, \p{^...} / \P{^...} negation, and (?i)/(?m)/(?s) inline flags.
    • 9 Global Built-ins & 14 Standard Library Packages (builtins)
      • Global built-ins: len, close, and, or, div, mod, quo, rem, matchN.
      • Standard library: strings, list (including list.MatchN), math, struct, regexp, encoding/json, encoding/yaml, encoding/base64, encoding/hex, encoding/csv, net, time, strconv, and path.
    • Validation, Codecs, JSON Schema & OpenAPI 3.0/3.1 (codec)
      • Strict RFC 8259 JSON (vet_json, export_json), single-document YAML 1.2 Core Schema (vet_yaml, export_yaml), concreteness checking (check_concrete), canonical evaluated-value formatting (format_value), fail-closed JSON Schema Draft-07 / Draft 2020-12 import (import_json_schema, supporting exact Decimal bounds/multipleOf within |exp| <= 1000, propertyNames, contains/minContains/maxContains, Draft 2020-12 dependentRequired/dependentSchemas, Draft-07 dependencies, and if/then/else conditionals), fail-closed Draft 2020-12 reverse export (export_json_schema for the lossless CUE subset only, rejecting propertyNames/list.MatchN/matchN != 0|1|>=1/Bytes/lexicographic string bounds), and fail-closed OpenAPI 3.0 / 3.1 JSON & YAML import-only components.schemas compilation (codec/openapi.mbt: is_openapi_document, import_openapi_schemas, import_openapi_schema_map, normalizing nullable per OpenAPI 3.0.3 type-scoped semantics, boolean exclusiveMinimum/exclusiveMaximum, and #/components/schemas/... $refs), plus direct JSON Schema / OpenAPI data validation via @cuesmith.vet_json_schema / cuesmith vet --schema-format. See Language Support Matrix & Target Compatibility Scope for dialect-split compatibility tables, delivery roadmap, and fail-closed boundaries.
    • Schema Compatibility, Markdown PR Summary & SARIF 2.1.0 Gate (compat)
      • Subsumes-backed backward-compatibility analyzer (diff_schemas, diff_values, diff_packages, format_text, format_json, format_markdown GFM PR summary, format_sarif SARIF 2.1.0, SchemaFormat, ChangeSeverity, ChangeKind CS001–CS022) across CUE, JSON Schema, OpenAPI 3.0/3.1, and cue.mod package directories, enforcing the soundness invariant tied to @eval.subsumes.
    • Module System, Cross-Package Imports & Dependency Graph (modsys)
      • Sandboxed ModuleFs & deterministic MemoryFs package resolution (cue.mod/module.cue upward discovery, directory package aggregation, :pkg qualifiers, ancestor directory inheritance, vendored cue.mod/{pkg,gen,usr}/... resolution, package-private _hidden stripping, ImportCycle diagnostics, and fail-closed symlink/traversal/resource guardrails).
      • Deterministic package dependency graph builder and formatters (build_dep_graph, PackageDepGraph, format_graph_mermaid, format_graph_dot, format_graph_json) with optional stdlib edge visibility (include_stdlib).
    • Pure 3-Target cli + Standalone Native cuesmith Binary
      • Target-agnostic CLI dispatcher (BigSaltyMan/cuesmith/cli, published in the library package and tested on wasm-gc, js, and native) plus a zero-dependency native executable (cmd/cuesmith) providing eval (-t/--inject), vet (--schema-format auto|cue|json-schema|openapi, -t/--inject), export, def, fmt, trim, import-schema, export-schema, diff-schema (text|json|markdown|sarif, --fail-on-breaking, --old-format, --new-format, -d, --indent, -o), graph (mermaid|dot|json, --include-stdlib, --indent, -o), lsp, version, and help (including directory/cue.mod package targets such as ./app and ./multi:alpha).
    • Pure MoonBit LSP 3.17 Language Server (lsp, cuesmith lsp)
      • Zero-dependency LSP 3.17 / JSON-RPC 2.0 engine (BigSaltyMan/cuesmith/lsp, lsp/server.mbt) compiling on wasm-gc, js, and native, powering both cuesmith lsp over stdio (with unbuffered cuesmith_read_stdin_chunk pipe reads) and browser IDE integrations.
      • Supports UTF-16 surrogate-pair positions, incremental didChange, multi-file cue.mod in-memory overlays, and 8 core LSP capabilities: live publishDiagnostics (including sibling re-publishing), Markdown hover (lattice value, disjunction defaults, // doc comments), cross-package definition & references, hierarchical documentSymbol, 14-package stdlib/user/schema completion, comment-preserving formatting, codeAction ("Trim redundant fields" + "Format CUE document"), and range-filtered inlayHint (textDocument/inlayHint), with ready-to-use VS Code & Neovim configs in examples/editor-lsp.
    • Zero-Backend Browser CueSmith Web IDE
      • Offline 5-view ES Module build (cmd/studio 13 ESM exports → examples/web-ide, live at bigsaltyman.github.io/cuesmith) executing inside an isolated Module Web Worker (lsp/, modsys/, trim/, compat/ client-side): Multi-File cue.mod IDE (live LSP 3.17 diagnostics, Markdown hover, cross-file definition jump, references, documentSymbol, completion, formatting, plus Post-Trim Unified Diff & Equivalence Proof), Cross-Format Schema Diff (Human Report / Markdown PR / SARIF 2.1.0 Audit) (OpenAPI 3.0/3.1, CUE, JSON Schema), Live vet & Export, 5-State Lattice Convergence Inspector, and JSON Schema ↔ CUE + 4 Guardrail Stress Presets.
    • Differential Oracle, Red-Team Hardening & Release Automation
      • 312 structured differential test vectors (312/312 offline --mode self across Linux, Windows, and macOS; 286/286 common vectors match pinned cue v0.12.1 identically in --mode oracle, plus 22 cuesmith_ext self-contracts and 4 documented known_diff divergences).
      • Dedicated adversarial red-team test suites covering modsys/redteam_test.mbt (symlink escape, traversal/NUL-byte, case-collision/drive normalization, ModLimits bombs), lsp/redteam_test.mbt (malformed framing, JSON depth/surrogate -32700, edit burst churn, adversarial CUE recovery, overlay symlink rejection), trim/redteam_test.mbt (24-case equivalence/idempotence suite, multi-file cue.mod trimming, tight budgets, combinatorial CRLF fuzz matrix), and compat/redteam_test.mbt (fail-closed OpenAPI 3.0/3.1 negative suite, 18 subsumes_with_options soundness pairs, strict JSON/SARIF 2.1.0 escaping).
      • Deterministic 4-platform release packaging via scripts/package_release.py (windows-x86_64, linux-x86_64, linux-arm64, macos-arm64 archives with SHA256SUMS & build-info.json), tag-triggered .github/workflows/release.yml, and docs/release-checklist.md.


    #Installation

    Install the latest v0.2.1 package directly from mooncakes.io:

    moon add BigSaltyMan/cuesmith

    For local source development against an unreleased checkout, you can also link a cloned repository via moon.work and pin BigSaltyMan/cuesmith@0.2.1 in moon.mod (see examples/basic-vet for a complete runnable setup):

    # moon.pkg import { "BigSaltyMan/cuesmith", }

    The published package includes all 10 pure 3-target library packages (BigSaltyMan/cuesmith, syntax, eval, modsys, trim, codec, builtins, compat, lsp, cli, each with a locked .mbti interface) and excludes native/JS host entrypoints under cmd/ so downstream wasm-gc, js, and native consumers build cleanly without target-specific stubs.


    #Library Quickstart (MoonBit)

    #1. Validate JSON & YAML (vet_json, vet_yaml) and Export Unified Configs (export_json, export_yaml)

    ///|
    fn demo_vet_and_export() -> Unit {
    let schema =
    #|import (
    #| "net"
    #| "time"
    #|)
    #|
    #|#Server: {
    #| host: net.IPv4 | *"127.0.0.1"
    #| port: int & >=1 & <=65535 | *8080
    #| timeout: time.Duration | *"30s"
    #| env: "dev" | "staging" | "prod" | *"dev"
    #| tls?: bool
    #|}
    #|
    #|server: #Server

    let json_data =
    #|{"server": {"port": 8443, "env": "prod"}}

    match @cuesmith.vet_json(schema, json_data) {
    Ok(val) => println(@cuesmith.format_value(val))
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }

    let yaml_data =
    #|server:
    #| host: 10.0.0.10
    #| port: 8080
    #| timeout: 1m

    match @cuesmith.vet_yaml(schema, yaml_data) {
    Ok(val) => println(@cuesmith.format_value(val))
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }

    let prod_overlay =
    #|server: {
    #| host: "10.0.1.25"
    #| env: "prod"
    #|}

    match @cuesmith.export_json([schema, prod_overlay], indent=2) {
    Ok(json_text) => println(json_text)
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }

    match @cuesmith.export_yaml([schema, prod_overlay]) {
    Ok(yaml_text) => println(yaml_text)
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }
    }

    #2. Format CUE (format), Import JSON Schema (Draft-07/2020-12), and Export Draft 2020-12 (import_json_schema, export_json_schema)

    ///|
    fn demo_format_and_schema() -> Unit {
    let raw_cue =
    #|// Service port constraint
    #|#Port:int&>=1&<=65535
    #|port:#Port| *8080

    match @cuesmith.format(raw_cue) {
    Ok(formatted) => println(formatted)
    Err(err) => println(err.message())
    }

    let json_schema =
    #|{
    #| "$schema": "https://json-schema.org/draft/2020-12/schema",
    #| "type": "object",
    #| "required": ["name", "replicas"],
    #| "additionalProperties": false,
    #| "properties": {
    #| "name": { "type": "string", "minLength": 3, "pattern": "^[a-z][a-z0-9-]*$" },
    #| "replicas": { "type": "integer", "minimum": 1, "maximum": 50 }
    #| }
    #|}

    match @cuesmith.import_json_schema(json_schema, def_name="#Service") {
    Ok(cue_schema) => {
    println(cue_schema)
    match
    @cuesmith.export_json_schema(cue_schema, def_name="#Service", indent=2) {
    Ok(roundtrip_json) => println(roundtrip_json)
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }
    }
    Err(errs) =>
    for err in errs {
    println(err.format())
    }
    }
    }

    #Root Facade Summary (cuesmith.mbt)

    FunctionPurpose
    @cuesmith.tokenize(source)Lex CUE source into Array[@syntax.Token]
    @cuesmith.parse(source) / @cuesmith.parse_expr(source)Parse a CUE file (@syntax.File) or standalone expression (@syntax.Expr)
    @cuesmith.format(source)Format CUE source canonically while preserving comments
    @cuesmith.eval(source, limits?, tags~) / @cuesmith.eval_all(sources, limits?, tags~)Evaluate single or multi-file CUE into @eval.Value with all 14 supported stdlib packages and optional @tag injection
    @cuesmith.eval_module_package(fs, target_dir, pkg_name?, expr?, cwd~, limits?)Resolve and evaluate a cue.mod package against a sandboxed @modsys.ModuleFs
    @cuesmith.eval_memory_module(files, target_dir~, pkg_name?, expr?, limits?)Resolve and evaluate a multi-package cue.mod graph from in-memory (path, source) pairs
    @cuesmith.subsumes(a, b, limits?, final_mode~, ignore_closed~)Check CUE lattice subsumption b ⊑ a (a subsumes b) with stdlib validators
    @cuesmith.trim(source, path?, options?)Trim redundant concrete fields from a CUE source with post-trim equivalence self-proof
    @cuesmith.trim_against_schema(schema, data, data_path?, options?)Trim redundant concrete fields from data against a read-only schema
    @cuesmith.vet(schema, data, def_name?, limits?, tags~)Validate CUE data against a CUE schema and verify concreteness
    @cuesmith.vet_json(schema, json_data, def_name?, limits?, tags~)Validate strict RFC 8259 JSON data against a CUE schema
    @cuesmith.vet_yaml(schema, yaml_data, def_name?, limits?, tags~)Validate YAML 1.2 Core Schema data against a CUE schema
    @cuesmith.vet_json_schema(schema_json, data, def_name?, is_yaml_data~, limits?, tags~)Validate strict JSON or YAML data directly against a Draft-07 / 2020-12 JSON Schema
    @cuesmith.export_json(sources, limits?, indent?)Unify CUE sources and emit deterministic RFC 8259 JSON
    @cuesmith.export_yaml(sources, limits?)Unify CUE sources and emit deterministic YAML 1.2 Core Schema
    @cuesmith.import_json_schema(schema_json, def_name?, limits?)Import JSON Schema Draft-07 / Draft 2020-12 into self-contained CUE
    @cuesmith.import_openapi_schemas(source, schema_name?, limits?)Import OpenAPI 3.0 / 3.1 JSON or YAML components.schemas into CUE definitions
    @cuesmith.export_json_schema(cue_source, def_name?, limits?, indent?)Export CUE definitions/values to JSON Schema Draft 2020-12
    @cuesmith.diff_schema(old_source, new_source, options?)Compare two CUE, JSON Schema, or OpenAPI 3.0/3.1 schemas for backward compatibility (@compat.CompatReport)
    @cuesmith.diff_schema_values(old_val, new_val, old_label?, new_label?, limits?)Compare two evaluated @eval.Value schemas for backward compatibility (@compat.CompatReport)
    @cuesmith.format_compat_text(report) / format_compat_json(report, indent?)Render a @compat.CompatReport as human text or deterministic JSON
    @cuesmith.format_compat_markdown(report) / format_compat_sarif(report, indent?)Render a @compat.CompatReport as a GitHub-Flavored Markdown PR summary or SARIF 2.1.0
    @cuesmith.dep_graph_package(fs, target_dir, pkg_name?, include_stdlib?, limits?) / dep_graph_memory(files, target_dir~, ...)Resolve and build a @modsys.PackageDepGraph from ModuleFs or in-memory files
    @cuesmith.format_dep_graph_mermaid(graph) / format_dep_graph_dot(graph) / format_dep_graph_json(graph, indent?)Format a @modsys.PackageDepGraph as Mermaid graph TD, Graphviz DOT, or RFC 8259 JSON
    @cuesmith.format_value(val)Render an evaluated @eval.Value as canonical CUE text


    #Native CLI Quickstart (cuesmith)

    Build the standalone native binary from the repository root (Python 3 stdlib only):

    # Linux / macOS BIN="$(python3 scripts/build_cli.py)" # Windows (PowerShell) $BIN = (python scripts/build_cli.py).Trim()

    Core subcommands (see the full CLI Reference):

    # Evaluate CUE files or expressions "$BIN" eval examples/k8s-template/base.cue examples/k8s-template/staging.cue "$BIN" eval -c --out json examples/k8s-template/base.cue examples/k8s-template/prod.cue # Validate JSON, YAML, or CUE inputs against CUE, JSON Schema, or OpenAPI schemas (with -d / --schema-format / --json) "$BIN" vet examples/basic-vet/schema.cue examples/basic-vet/valid.json "$BIN" vet --schema-format json-schema examples/json-schema-import/service.schema.json examples/json-schema-import/valid.json "$BIN" vet --json examples/basic-vet/schema.cue examples/basic-vet/invalid.json # Export unified manifests as JSON, YAML, or CUE "$BIN" export --out yaml examples/k8s-template/base.cue examples/k8s-template/prod.cue # Print normalized, self-contained CUE definitions "$BIN" def -e "#Deployment" examples/k8s-template/base.cue # Format CUE files with comment preservation (--check for CI, -w for atomic in-place write) "$BIN" fmt --check examples/basic-vet/schema.cue # Trim redundant concrete fields (--diff to preview, --check for CI, -w for atomic in-place write) "$BIN" trim --diff examples/k8s-template/base.cue examples/k8s-template/prod.cue # JSON Schema forward import (Draft-07/2020-12) and Draft 2020-12 reverse export (lossless subset) "$BIN" import-schema examples/json-schema-import/service.schema.json -d "#Service" -o /tmp/service.cue "$BIN" vet -d "#Service" /tmp/service.cue examples/json-schema-import/valid.json "$BIN" export-schema -d "#Service" /tmp/service.cue # Schema compatibility, Markdown PR summary, and SARIF 2.1.0 CI gate (OpenAPI, CUE, JSON Schema, cue.mod) "$BIN" diff-schema examples/schema-compat-gate/openapi-v1.yaml examples/schema-compat-gate/openapi-v2.yaml "$BIN" diff-schema --format markdown examples/schema-compat-gate/openapi-v1.yaml examples/schema-compat-gate/openapi-v2.yaml "$BIN" diff-schema --format sarif --fail-on-breaking -o /tmp/compat.sarif \ examples/schema-compat-gate/schema-v1.cue examples/schema-compat-gate/schema-v2.cue # Visualize cue.mod package dependency graph (Mermaid, Graphviz DOT, or JSON) "$BIN" graph --format mermaid examples/multi-pkg-mod/app "$BIN" graph --format json --include-stdlib examples/multi-pkg-mod/app # Start the built-in LSP 3.17 language server over stdio (for VS Code, Neovim, etc.) "$BIN" lsp


    #Zero-Backend CueSmith Web IDE

    Build the offline static 5-view studio bundle locally into _build/web-ide/ (compiles cmd/studio's 13 JS ESM exports and assembles HTML/CSS/Worker assets with zero CDN dependencies):

    python3 scripts/build_studio.py python3 -m http.server 8080 --directory _build/web-ide

    Open http://127.0.0.1:8080/ in any modern browser to explore the Multi-File cue.mod IDE (LSP 3.17, Post-Trim Diff/Equivalence Proof, and Interactive SVG / Mermaid / DOT / JSON Package Dependency Graph with click-to-jump and Include stdlib), Schema Diff (Human Report / Markdown PR / SARIF 2.1.0 Audit), Live vet & Export, 5-State Lattice Inspector, and JSON Schema (import Draft-07/2020-12 / export Draft 2020-12) + Guardrail Stress Lab inside a Module Web Worker. See examples/web-ide for details and automated Node ESM verification (python3 scripts/test_studio.py).

    CueSmith Web IDE — Multi-File LSP 3.17 Editor & Interactive Package Dependency Graph

    CueSmith Web IDE — OpenAPI Schema Diff & Markdown PR Summary


    #Native CLI Benchmarks (scripts/bench.py)

    Measured locally with scripts/bench.py (python3 scripts/bench.py --runs 7 --markdown):

    • Methodology: End-to-end native CLI wall-clock latency (includes OS process startup; build time excluded, immutable examples/ inputs)
    • Environment: baseline commit 258ba5b (Commit 16 CLI binary), OS Windows-11-10.0.26300-SP0 (AMD64), Python 3.14.6, warmup=2, runs=7

    WorkloadDescriptionMin (ms)Median (ms)p95 (ms)Mean (ms)
    evalEvaluate multi-pkg module ./app to concrete JSON35.9638.1242.5938.80
    vetValidate multi-pkg module ./app constraints36.6442.6350.6943.02
    diff-schemaOpenAPI v1 vs v2 breaking schema diff (--format json)39.3041.5053.8642.88
    trimEquivalence-proven trim check on multi-pkg ./app38.1243.3549.6243.59
    graphResolve package dependency graph JSON (w/ stdlib)37.8840.2741.7940.20
    fmtFormat CUE source via immutable stdin stream31.7133.2036.4233.62

    Compare against official cue if installed on PATH via python3 scripts/bench.py --compare-cue.


    #Examples & Documentation

    #Runnable Examples

    • examples/basic-vet — CLI vet workflow + standalone MoonBit library consumer calling @cuesmith.vet_json and @cuesmith.export_json across all 3 targets.
    • examples/k8s-template — Multi-environment Kubernetes Deployment base schema + staging/prod overlays exported to YAML/JSON.
    • examples/json-schema-import — Draft 2020-12 JSON Schema $defs/$ref import into CUE #Schema followed by vet validation.
    • examples/multi-pkg-mod — Multi-package cue.mod module with cross-package schema/defaults imports, multi-file unification, and CLI export/vet/def/export-schema/trim/graph workflows.
    • examples/schema-compat-gate — OpenAPI 3.0.3 (openapi-v1.yaml/openapi-v2.yaml) and CUE (schema-v1.cue/schema-v2.cue) compatibility diffing with Markdown PR summaries & SARIF 2.1.0 CI gate (testdata/compat/ fixtures included in testdata/compat).
    • examples/editor-lsp — VS Code and Neovim 0.10+/0.11+ editor configurations for cuesmith lsp (plus canonical session walkthrough in testdata/lsp/basic_session.json).
    • examples/web-ide — Zero-backend 5-view browser CueSmith Web IDE (Multi-File cue.mod LSP 3.17, Trim Proof & Package Dependency Graph, Schema Diff with Human Report / Markdown PR / SARIF 2.1.0, Live vet, Lattice Inspector, JSON Schema ↔ CUE & Stress Lab) powered by cmd/studio's 13 ESM exports in a Module Web Worker.

    #Reference Documentation

    • Language Support Matrix, Target Compatibility Scope & Guardrails — Explicit CUE & JSON Schema Draft-07/2020-12 target compatibility scope, final delivery roadmap, reproducible high-precision Decimal and dependent-field Schema case studies, LSP 3.17 matrix, EvalLimits defaults, OpenAPI 3.0/3.1 fail-closed boundaries, compat/ analyzer, and the 312-vector cue v0.12.1 oracle summary.
    • Architecture Guide — 10-package DAG, lattice representation, AND-of-ORs closedness, comprehensions, cycle detection, RE2 NFA + UCD 16.0.0 engine, lattice subsumption, trim self-proof, modsys graph builder, compat Markdown/SARIF 2.1.0 engine, lsp 3.17 engine, CLI layering, and the 13-export cmd/studio Web Worker Web IDE.
    • Built-ins & Standard Library Reference — Exact signatures and edge cases for all 9 global built-ins and 14 stdlib packages.
    • CLI Reference — Subcommands (eval, vet, export, def, fmt, trim, import-schema, export-schema, diff-schema, graph, lsp), flags, exit codes, structured vet --json schema, and atomic writes.
    • Release Checklist — Pre-flight checks, release_audit.py & package_release.py verification, mooncakes.io publish, and 4-platform GitHub Release workflow.
    • Changelog — Version history and release notes.


    #Development & Verification

    Requires MoonBit toolchain moonc >= 1.0.0-rc1:

    # 1. Formatting and public interface (.mbti) baseline check moon fmt --check moon info --frozen && git diff --exit-code -- '*.mbti' # 2. Strict typechecks (--frozen --deny-warn) and test suites across all 3 targets moon check --frozen --deny-warn --target wasm-gc && moon test --target wasm-gc moon check --frozen --deny-warn --target js && moon test --target js moon check --frozen --deny-warn --target native && moon test --target native # 3. Native CLI build, real-subprocess CLI & LSP E2E tests, and 312-vector differential oracle python3 scripts/build_cli.py --self-test python3 scripts/build_cli.py python3 scripts/test_cli_native.py python3 scripts/test_lsp_e2e.py python3 scripts/differential_oracle.py --self-test python3 scripts/differential_oracle.py --mode self # 4. Web IDE static bundle, Node ESM acceptance suite, and CLI benchmark python3 scripts/build_studio.py python3 scripts/test_studio.py python3 scripts/bench.py --self-test python3 scripts/bench.py --runs 7 --markdown # 5. Release packager self-tests and full dual-artifact Clean-Source & Mooncakes package release audit python3 scripts/package_release.py --self-test python3 scripts/release_audit.py --self-test python3 scripts/release_audit.py


    #License & Third-Party Notices

    dep_graph_memory

    fn dep_graph_memory(files : Array[(String, String)], target_dir? : String, pkg_name? : String, include_stdlib? : Bool, limits? :
    ModLimits
    ) -> Result[
    PackageDepGraph
    , Array[
    ModError
    ]]

    Resolves a CUE package from in-memory (path, source) entries and builds its deterministic dependency graph (@modsys.PackageDepGraph).

    dep_graph_package

    Resolves a CUE package against a sandboxed @modsys.ModuleFs and builds its deterministic dependency graph (@modsys.PackageDepGraph).

    diff_schema

    Compares two schema sources (CUE, JSON Schema, or OpenAPI 3.0/3.1) for backward compatibility and returns a detailed @compat.CompatReport.

    diff_schema_values

    Compares two evaluated @eval.Value schemas for backward compatibility and returns a detailed @compat.CompatReport.

    eval

    Evaluates a single CUE source string into a lattice @eval.Value.

    Uses the unified standard library package registry (@builtins.default_eval_config). Returns Err(errs) if any Bottom errors or determined builtin constraint failures are present anywhere in the evaluated value tree; incomplete non-concrete schemas succeed as Ok(val).

    eval_all

    Evaluates and unifies multiple CUE source strings in the same package scope.

    Uses the unified standard library package registry (@builtins.default_eval_config). Returns Err(errs) if any Bottom errors or determined builtin constraint failures are present anywhere in the evaluated value tree.

    eval_memory_module

    fn eval_memory_module(files : Array[(String, String)], target_dir? : String, pkg_name? : String, expr? :
    Expr
    , limits? :
    ModLimits
    ) -> Result[
    Value
    , Array[
    ModError
    ]]

    Resolves and evaluates a CUE package from an in-memory (path, source) file list, supporting cue.mod/module.cue, cross-package imports, and stdlib packages.

    eval_module_package

    Resolves and evaluates a CUE package against a sandboxed @modsys.ModuleFs.

    export_json

    fn export_json(sources : Array[String], limits? :
    EvalLimits
    , indent? : Int, tags? : Map[String, String?]) -> Result[String, Array[
    CueError
    ]]

    Evaluates and unifies one or more CUE source strings and exports deterministic JSON.

    export_json_schema

    fn export_json_schema(cue_source : String, def_name? : String, limits? :
    EvalLimits
    , indent? : Int) -> Result[String, Array[
    CueError
    ]]

    Evaluates cue_source using the unified standard library package registry (@builtins.default_eval_config) and exports a deterministic JSON Schema Draft 2020-12 document.

    export_yaml

    fn export_yaml(sources : Array[String], limits? :
    EvalLimits
    , tags? : Map[String, String?]) -> Result[String, Array[
    CueError
    ]]

    Evaluates and unifies one or more CUE source strings and exports deterministic YAML 1.2 Core Schema text.

    format

    fn format(source : String) -> Result[String,
    SyntaxError
    ]

    Parses and formats a CUE source file into canonical cue fmt-style text.

    format_compat_json

    fn format_compat_json(report :
    CompatReport
    , indent? : Int) -> String

    Formats a @compat.CompatReport as deterministic RFC 8259 JSON (default indent 2).

    format_compat_markdown

    fn format_compat_markdown(report :
    CompatReport
    ) -> String

    Formats a @compat.CompatReport as a GitHub-Flavored Markdown PR summary report.

    format_compat_sarif

    fn format_compat_sarif(report :
    CompatReport
    , indent? : Int) -> String

    Formats a @compat.CompatReport as SARIF 2.1.0 JSON (default indent 2).

    format_compat_text

    fn format_compat_text(report :
    CompatReport
    ) -> String

    Formats a @compat.CompatReport as a human-readable text report.

    format_dep_graph_dot

    fn format_dep_graph_dot(graph :
    PackageDepGraph
    ) -> String

    Formats a @modsys.PackageDepGraph as a Graphviz DOT digraph cuesmith_deps.

    format_dep_graph_json

    fn format_dep_graph_json(graph :
    PackageDepGraph
    , indent? : Int) -> String

    Formats a @modsys.PackageDepGraph as deterministic RFC 8259 JSON (default indent 2).

    format_dep_graph_mermaid

    fn format_dep_graph_mermaid(graph :
    PackageDepGraph
    ) -> String

    Formats a @modsys.PackageDepGraph as a Mermaid graph TD flowchart.

    format_value

    fn format_value(val :
    Value
    ) -> String

    Formats an evaluated @eval.Value into canonical CUE text.

    import_json_schema

    fn import_json_schema(schema_json : String, def_name? : String, limits? :
    EvalLimits
    ) -> Result[String, Array[
    CueError
    ]]

    Imports a JSON Schema (Draft-07 or Draft 2020-12) document into formatted, self-contained CUE source defining def_name (default "#Schema").

    import_openapi_schemas

    fn import_openapi_schemas(source : String, schema_name? : String, limits? :
    EvalLimits
    ) -> Result[String, Array[
    CueError
    ]]

    Imports components.schemas from an OpenAPI 3.0 or 3.1 JSON/YAML document into formatted CUE definitions (#<Name>: ...), or a single named schema when schema_name is Some.

    parse

    Parses a complete CUE source file into an AST using the syntax package parser.

    parse_expr

    Parses a standalone CUE expression using the syntax package parser.

    subsumes

    Checks CUE lattice subsumption b ⊑ a ("a subsumes b") with the unified standard library validator attached.

    tokenize

    Tokenizes a CUE source string using the syntax package lexer.

    trim

    Trims redundant concrete fields from a single CUE source string while verifying semantic equivalence before and after re-parsing.

    trim_against_schema

    Trims redundant concrete fields from data against a read-only schema while verifying semantic equivalence before and after re-parsing.

    vet

    fn vet(schema : String, data : String, def_name? : String, limits? :
    EvalLimits
    , tags? : Map[String, String?]) -> Result[
    Value
    , Array[
    CueError
    ]]

    Validates CUE data against a CUE schema and verifies concreteness.

    vet_json

    fn vet_json(schema : String, json_data : String, def_name? : String, limits? :
    EvalLimits
    , tags? : Map[String, String?]) -> Result[
    Value
    , Array[
    CueError
    ]]

    Validates strict RFC 8259 json_data against a CUE schema and verifies concreteness.

    vet_json_schema

    fn vet_json_schema(schema_json : String, data : String, def_name? : String, is_yaml_data? : Bool, limits? :
    EvalLimits
    , tags? : Map[String, String?]) -> Result[
    Value
    , Array[
    CueError
    ]]

    Validates strict JSON or YAML data directly against a JSON Schema document (Draft-07 or Draft 2020-12) with the full CueSmith standard library.

    vet_yaml

    fn vet_yaml(schema : String, yaml_data : String, def_name? : String, limits? :
    EvalLimits
    , tags? : Map[String, String?]) -> Result[
    Value
    , Array[
    CueError
    ]]

    Validates YAML 1.2 Core Schema yaml_data against a CUE schema and verifies concreteness.

    Source Files