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.
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.
| Capability | Single-File CUE Port | Official Go cue CLI | CueSmith (BigSaltyMan/cuesmith) |
|---|---|---|---|
| Runtime & Build Targets | Single-target script / toy parser | Go 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 Graph | Single-file only; no cue.mod | Full 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 trim | Not supported | cue 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 Gates | Not supported | Separate vet/export; no built-in cross-format diff-schema CI gate | OpenAPI 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 IDE | None | Go 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 Oracle | Host regex / ad-hoc tests | Reference 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) |
# 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 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)moon add BigSaltyMan/cuesmith# moon.pkg
import {
"BigSaltyMan/cuesmith",
}///|
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())
}
}
}///|
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())
}
}
}| Function | Purpose |
|---|---|
| @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 |
# Linux / macOS
BIN="$(python3 scripts/build_cli.py)"
# Windows (PowerShell)
$BIN = (python scripts/build_cli.py).Trim()# 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" lsppython3 scripts/build_studio.py
python3 -m http.server 8080 --directory _build/web-ide

| Workload | Description | Min (ms) | Median (ms) | p95 (ms) | Mean (ms) |
|---|---|---|---|---|---|
| eval | Evaluate multi-pkg module ./app to concrete JSON | 35.96 | 38.12 | 42.59 | 38.80 |
| vet | Validate multi-pkg module ./app constraints | 36.64 | 42.63 | 50.69 | 43.02 |
| diff-schema | OpenAPI v1 vs v2 breaking schema diff (--format json) | 39.30 | 41.50 | 53.86 | 42.88 |
| trim | Equivalence-proven trim check on multi-pkg ./app | 38.12 | 43.35 | 49.62 | 43.59 |
| graph | Resolve package dependency graph JSON (w/ stdlib) | 37.88 | 40.27 | 41.79 | 40.20 |
| fmt | Format CUE source via immutable stdin stream | 31.71 | 33.20 | 36.42 | 33.62 |
# 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.pyfn diff_schema(old_source : String, new_source : String, options? : DiffOptions) -> Result[CompatReport, Array[CueError]]fn diff_schema_values(old_val : Value, new_val : Value, old_label? : String, new_label? : String, limits? : EvalLimits) -> Result[CompatReport, Array[CueError]]fn export_json_schema(cue_source : String, def_name? : String, limits? : EvalLimits, indent? : Int) -> Result[String, Array[CueError]]fn import_json_schema(schema_json : String, def_name? : String, limits? : EvalLimits) -> Result[String, Array[CueError]]fn import_openapi_schemas(source : String, schema_name? : String, limits? : EvalLimits) -> Result[String, Array[CueError]]fn subsumes(a : Value, b : Value, limits? : EvalLimits, final_mode? : Bool, ignore_closed? : Bool) -> Result[Bool, CueError]fn trim(source : String, path? : String, options? : TrimOptions) -> Result[TrimFileResult, Array[TrimError]]fn trim_against_schema(schema : String, data : String, data_path? : String, options? : TrimOptions) -> Result[TrimFileResult, Array[TrimError]]Install
Download zipPure 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.