Packages

The culm command

The culm command line and the tools behind it: a folder of JSON files becomes a Culm site.

Commands

culm init <folder> [--from folder]
                                    write a blank one-page site into a new or empty folder
culm dev [--port n] serve the site on 127.0.0.1 (default port 4321), recompile on save
culm build write the compiled site to the output folder
culm check [--chrome path] [--classes 1,2,3]
                                    validate, then measure every page in Chrome
                                    (in a package folder, one with culm-package.json: validate the package)
culm add <spec> copy a package, name@1.2.3 or git+https://host/repo.git#<commit>, into
                                    packages/ and wait for a person to approve it; nothing of it runs
culm approve <name> a person at a terminal approves an added package: it prints what the package
                                    holds and asks for its name, typed; with no terminal it exits 2 (no flag skips it;
                                    a shell with a pseudo-terminal could still type the name, see docs/app/packages.md)
culm agents on|off turn the site's declared tools on (a person at a terminal, who types the
                                    site's name; with no terminal it exits 2) or off
culm expand <file> <id> rewrite the short form <id> in <file> as its nodes
culm render [spec.json | page] --out <file>
                                    export a standalone node, page or shape as PNG, WebP or SVG
culm schema write culm.schema.json in the project folder
culm mcp [--port n] [--chrome path] [--full | --sections]
                                    serve 6 JSON tools by default (--full exposes all 12 tools;
                                    --sections serves 5 tools with short write receipts) over stdio;
                                    --port also opens a local port with a token; a folder server
                                    also offers add_package (it cannot approve)

A package is used as

{ "use": "<package>/<component>" }

once approved. culm.json holds a person's words about each package, by hand: "packages": { "shop": { "sources": { "products": "products" }, "trusted": true } } binds each live source the package asks for to a source of site.json⁠; trusted only permits an island of the package to run in the page when a node asks for it with run: "in-page" ⁠(the default stays a frame). A package's source name must equal the site's source name until the page's broker maps names, so bind products to products⁠. A build fails for any package whose files differ by one byte from the approved ones, and for a use of a package that is not approved.

Exit codes: 0 done, 1 problems or findings, 2 wrong usage, no browser, or no terminal for culm approve or culm agents on⁠. Run a command from the project folder (the one holding culm.json⁠).

Browser

culm check and the MCP measure tool drive Chrome or Chromium themselves over the DevTools protocol; no browser library is installed and nothing is downloaded. The browser is, in order: the --chrome option or CULM_CHROME⁠, a Chromium that npx playwright install chromium left on disk, the system Chrome. With none of them a check reports MEASUREMENT_INCOMPLETE and names these three ways.

Exports

@culmjs/tools exports thirteen names: openProject⁠, fileStore⁠, folderMcpOptions (the options culm mcp serves a folder with; the agents.mayTurnToolsOn setting is honoured only when you pass { local: true }⁠), loadFolder⁠, buildSite⁠, runMeasure⁠, measureSince⁠, authoringSchema⁠, createMcpServer⁠, protect⁠, toolsOnGuard⁠, renderImage and approvePackage (the function a product's own approval screen calls; it takes a callback that must ask a person). A product's own server must chain both protect and toolsOnGuard⁠.

It needs @culmjs/core as a peer dependency. See docs/folder-sites.md and docs/mcp.md for the folder format and the agent tools.

Edit this page on GitHub