Project

kupcad

0.0
The project is in a healthy, maintained state
Builds the model of a KupCAD script, with its parameters, as STL, 3MF, glTF, OBJ, STEP, SVG or DXF, and formats, lints and reads the parameters of scripts, in process, through libkupcad, the KupCAD core as a C library, which each platform gem carries.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.15
 Project Readme

KupCAD is a high-level, expression-based parametric CAD language Tests

KupCAD (.kup) is a Ruby-inspired, method-chaining language for parametric CAD. Scripts run on a custom Zig bytecode VM and build geometry through two engines: Manifold for fast mesh CSG and previews, and the native B-Rep kernel (Locus, in progress) for exact STEP output.

Work in progress

The language, VM and Manifold path are usable; the B-Rep kernel (core/src/locus) and the viewport webview are not finished. See the extension README for current limitations.

Install

Each release has the kupcad CLI for Linux (x86_64 and arm64, glibc 2.28 or later), macOS (Apple silicon and Intel) and Windows (x86_64 and arm64): unpack the archive and put kupcad on your PATH. checksums.txt has each archive's SHA-256, and THIRD_PARTY_NOTICES.md in each archive lists the libraries and fonts built in. The macOS binaries aren't signed: if macOS refuses to open one, run xattr -d com.apple.quarantine kupcad.

Build

Requires the Zig version in .tool-versions (managed with asdf), Node 24 and pnpm; vendored C++ libraries are git submodules.

git clone --recurse-submodules https://github.com/kupcad/kupcad
pnpm install
cd core && zig build                     # -> core/zig-out/bin/kupcad
zig build -Doptimize=ReleaseFast         # release build
zig build lib                            # -> core/zig-out/lib/libkupcad.*, include/kupcad.h
pnpm test:core                           # Zig test suite (debug build)
pnpm test:wasm                           # WASM tests via wasmtime
cd core && zig build test -Dtest-filter="Compiler Guardrail"   # a subset

A passing run prints nothing but the summary. A test that provokes a warning on purpose calls test_support.expectWarnings() first, so any warning that does appear is a real one.

To try the front ends from a checkout:

pnpm dev:vscode       # kupcad and the VS Code extension built, a VS Code window with it on examples/
pnpm dev:playground   # the core built to WebAssembly, the playground at http://127.0.0.1:4321/
pnpm dev:desktop     # kupcad built and bundled, the desktop app (Tauri, needs Rust) on examples/

The extension's README, the playground's and the desktop app's say more; packages/ has the rest. The Ruby gem and the Python package test against the library zig build lib builds: their READMEs' Development sections say how.

Usage

kupcad build part.kup -o part.stl                  # export (stl | glb | gltf | 3mf | obj | step), --draco for GLB
kupcad build part.kup --param width=50 -f step     # inject parameters, pick a format (-p/-o/-f/-d short flags)
kupcad build part.kup -P bracket.json              # parameter values from a JSON object
kupcad build part.kup --bom bom.json               # also write the parts list (count, volume, mass)
kupcad build part.kup -o part.3mf                  # 3MF: each part once, placed per copy, with colours
kupcad build part.kup --split parts/               # one STL per part, as made, for printing
kupcad build part.kup --memory-limit 2GB           # cap the script's memory (else KUPCAD_MEMORY_LIMIT, else the project's)
kupcad build part.kup --timeout 30s                # cap the run's time (else KUPCAD_TIMEOUT; none without either)
kupcad check part.kup                              # lint
kupcad fmt part.kup                                # format
kupcad watch part.kup -P bracket.json              # rebuild on change, with parameter values
kupcad doc part.kup                                # parameters + docstrings as JSON
kupcad pkg add hardware=github.com/user/repo       # add a dependency to kupcad.json
kupcad pkg install                                 # resolve, verify kupcad.lock, link .kupcad/pkg/
kupcad pkg doctor                                  # check the local package store
kupcad lsp                                         # language server over stdio (used by the extension)
kupcad dev ast-dump|disasm|lex-dump|bench part.kup # compiler/VM tooling
kupcad dev brep-readiness|brep-trace                # B-Rep engine readiness and trace

Every command exits 0 on success and 1 on any failure (bad arguments, unreadable files, syntax or runtime errors, lint errors), so all of them are safe as CI steps. kupcad --help lists the commands and kupcad --version prints the version. Environment variables:

Variable Purpose
KUPCAD_HOME Package cache directory, an absolute path (default ~/.kupcad; empty is unset)
KUPCAD_VIEWPORT_PORT Preferred port for the LSP viewport WebSocket (default 9001, falls back to a free port)
KUPCAD_MEMORY_LIMIT Most memory a script may hold, as 512MB or 8GB, when --memory-limit isn't given; wins over the project's vm_memory_limit (empty is unset)
KUPCAD_TIMEOUT Most time a run of build, run or watch may take, as 500ms, 30s or 2m (a number alone is seconds), when --timeout isn't given (empty is unset)

Developer notes

# regenerate the sqlite translation
cd core && zig translate-c vendor/sqlite/sqlite3.h > vendor/sqlite/sqlite_bindings.zig

# shrink the wasm build, as the release does (not --all-features: it writes what engines can't
# read yet)
brew install binaryen wabt wasmtime
wasm-opt -Oz --enable-bulk-memory-opt --enable-nontrapping-float-to-int core/zig-out/bin/kupcad.wasm -o core/zig-out/bin/kupcad_min.wasm

To release, set the version with pnpm bump patch (or minor or major, counted as npm version counts them, or the version itself, as pnpm bump 0.2.0-rc.1): scripts/version.js writes it into every file that carries it (the core's build.zig.zon, what kupcad --version prints, the npm packages', the VS Code extension's, the desktop app's, the Ruby gem's and its Gemfile.lock, and the Python package's). Commit, and push a tag of that version: git tag v0.2.0 && git push origin v0.2.0. The Release workflow checks the tag matches all of them (node scripts/version.js check 0.2.0), runs every test CI runs (tests.yml) on the tagged commit, publishing nothing until they pass, builds the CLI on a runner of each system and architecture it ships for (Linux, macOS and Windows, x86_64 and arm64), checks each binary there (its version, an example built), builds the desktop app around each (kupcad-desktop_<version>_<os>_<arch>: a .dmg on macOS, .deb and .rpm on Linux and an .AppImage for x86_64, a _setup.exe on Windows), and publishes the archives, the installers and their checksums as the tag's GitHub release; a tag like v0.2.0-rc.1 makes a pre-release. The installers aren't signed yet: macOS and Windows warn before they open one. The binaries ship without their debug information; each platform's goes next to its archive as kupcad_<version>_<os>_<arch>_symbols (Linux's kupcad.debug, macOS's kupcad.dSYM, Windows's kupcad.pdb), to turn a crash report's addresses into files and lines. core/scripts/package-release.sh packages the binaries with their licenses and symbols: given a folder per platform (linux_amd64/kupcad, linux_amd64/symbols/, ...), it writes the same archives into a folder of your own. Once the GitHub release is out, the same workflow publishes the npm packages at that version, with provenance (npm's trusted publishing from release.yml in the npm environment): @kupcad/wasm carries the module built for the release and shrunk by wasm-opt, tested in Node and in the playground in headless Chromium first; a pre-release goes under npm's next tag. It publishes the Ruby gems and the Python wheels too, each built and tested on its platform, to RubyGems.org and PyPI by their trusted publishing (from release.yml, in the rubygems and the pypi environment).

License

KupCAD is dual-licensed:

Two parts are MIT-licensed instead, so anyone can use them freely, in closed-source projects too: @kupcad/protocol (the shapes of what the core sends, for tools that read KupCAD's output) and the examples.

Note on Model Output: 3D files (STL, 3MF, STEP) exported by KupCAD belong 100% to you and are not subject to AGPL copyleft terms.

For common questions regarding commercial usage, derivative works, and contribution guidelines, read our License FAQ and Contributor License Agreement (CLA).