Commonplace kernel API
    Preparing search index...

    Commonplace kernel API

    The Commonplace kernel, for developers

    A modeling kernel for architecture based on paper surfaces: flat, ruled and developable faces that can be cut from sheet and laid flat exactly. It is two packages, written in TypeScript, that run in a browser or in Node with no native code and no server:

    • @commonplace-technologies/kernel: the model, the verbs that edit it, its history, the read side, display tessellation, save and load.
    • @commonplace-technologies/kernel-step: STEP reading and writing, an interop add-on. Import places manufactured parts (fixtures, furniture modeled elsewhere) in a model for context; export sends parts to fabrication.
    npm install @commonplace-technologies/kernel
    npm install @commonplace-technologies/kernel-step # STEP interop, optional

    To run the examples, which import the packages by name, clone the repository:

    git clone https://github.com/commonplace-technologies/kernel
    cd kernel
    npm ci
    npm run example:kernel # a curved panel, laid flat
    npm run example:kernel:step # STEP interop

    These pages are for someone building their own modeler, a viewer, a fabrication tool or a script on the kernel. For what the kernel is and how it works without the code, read How the kernel works, in plain language. Everything in 0.1 is experimental: names and signatures can change between releases.

    Page What it covers
    How the kernel works, in plain language What the kernel is, paper surfaces, what it promises and what it is not, with no code. For readers who will not program against it.
    Build models with an AI agent Let an agent such as Claude build, check and export a model from a description, through the kernel's MCP server. No code.
    Build your own modeler The loop a modeler runs: load, draw, display, pick, edit, undo, save. Start here.
    Verbs, by example One working snippet per verb family: drawing, pushing a face, the offset modes, revolve, loft, sweep, skin, fillet, erase and patch, the Booleans.
    Paper surfaces Developable faces made exactly, laid flat with nothing approximated, thickened and cut; creases, folding, nets, and paper models to print.
    Reading the model kernelQuery: faces, edges and vertices by id, surface and curve evaluation, neighbors, picking.
    Refusals and canRun Each verb's refusal codes as a typed union, refusalCodes, and canRun: whether a verb accepts its operands, before anything is built.
    Dry runs { dryRun: true } on every verb: the commit's answer and the frame of the model it would leave, with nothing kept. The preview path.
    Move, rotate and scale planTransform and transformEntities: transforming corners, edges and faces with a live preview, which ids survive a weld or a split, and the refusal codes.
    Erase erase: deleting vertices, edges and faces, what each kind of id takes with it, and which ids survive.
    Save and load saveMesh / loadMesh, the format version, and what stays stable across a save.
    Loading, host hooks and tolerances The lane-free ./core entry, loading each capability when it is first needed, the refusal and fallback hooks, and the tolerances a host reads and tunes.

    The package README (src/kernel/README.md) has a first edit in a dozen lines. examples/kernel/ has runnable scripts and a testbed (npm run testbed:kernel).

    npm run docs:api:kernel
    

    writes the generated reference for both packages to docs/api/kernel-reference/ (open its index.html). It is built from the packages' own entries (src/kernel/index.ts, src/kernel-step/index.ts) and their doc comments, so it lists exactly what a package user can import.

    The kernel holds geometry and the rules it keeps. Everything about a user at a screen belongs to the host:

    • Input and intent. Snapping, guides, typed lengths, tool states, selection. The kernel answers geometric questions (the face a ray meets, the edge nearest a ray, the point of a surface at (u, v)); a host decides what the cursor means. The host's own cursor logic is not part of these packages.
    • Scenes. Groups, components, instances and their placements. A kernel mesh is one body in its own frame; a host that places it transforms rays in and points out.
    • Rendering. The kernel hands out triangles and polylines with ids; a host draws them with whatever it likes (three.js, WebGPU, SVG).
    • Documents. File naming, storage, sharing and app settings. Save and load gives a host one mesh as JSON to store as it likes.
    • A verb either commits a mesh the validator accepts, or refuses with a code and a sentence and leaves the mesh exactly as it was.
    • Every committed verb is one undoable step.
    • Ids are the kernel's own, survive save and load, and name the same entity until an edit splits or erases it.
    • Reads never throw: an unknown id or an unanswerable question comes back as null or 'unknown'.
    • Curved faces and edges are exact. Triangles and polylines are for drawing; measurement, picking and unfolding read the surfaces themselves.

    The repository's limitations index (npm run limitations) lists what is known not to work, each entry with a regression test.