Folder sites
What is kept when Culm writes
Loading a folder and writing it back with no change leaves every file byte for byte the same: key order, indentation, comments, line endings and a byte order mark.
When an operation changes the site, the writer takes the difference between the head document and the new one, finds each changed node in the source map, and edits that file in place with jsonc-parser. A change to one field touches one line of one file. A moved element takes its trailing comment and the block comment above it. Created and deleted files (addPage, removePage, makeComponent, removeComponent) go through the same journal as edits.
Two things you may notice:
Changing an inner part of a short form first rewrites that short form in expanded form. apply's result says so in its notes, naming the node; plan does not show that note. A change a setting of the short form can hold leaves it a short form.
A node moved to another parent is rewritten whole, and a comment inside it that was attached to the old place is lost.
An edit that cannot be made (a file with a syntax error, a path through a scalar) is a located problem, and nothing is written.
Errors point at the file
Each problem has a code, the file, the line and column, what is wrong, and the allowed values. culm build and culm check print them as
pages/home.json:14:9 UNKNOWN_KIND Its kind "marquee" is not one this site knows.
allowed: free, box, row, column, grid, list, table, ...A measure finding is located at its first node. A finding on a part of a short form is located at the short form's line, because the settings of a short form do not name the part they change.
A syntax error in a JSON file is one problem for that file, and no document loads until it is fixed. A symbolic link that leaves the project is refused at the link, with file and line.
Commands
Command
Does
Command
culm init <folder> [--from folder]
Does
Writes a blank one-page site into a new or empty folder.
Command
culm dev [--port n]
Does
Serves the compiled pages on 127.0.0.1 (default port 4321), watches the folder, recompiles on save and reloads the page through server-sent events. On a problem it keeps serving the last good pages and draws an overlay.
Command
culm build
Does
Writes the compiled pages, assets/, _fonts/ and culm-manifest.json to out. It writes nothing when anything is a problem. When tools ship it also prints loads in full: <page ids> (a swap site only), <plugin>: <bytes> bytes and largest tool table: <bytes> bytes; when tools are on and no listed plug-in supplies a tool script it prints Tools are on, and no listed plugin ships them to the browser., and when one does but no page has a tool, Tools are on, and no page has one.
Command
culm check [--chrome path] [--classes 1,2,3]
Does
Validates, prints a line for each listed plug-in (plugin <name> <version> <path>, or plugin <name> refused: <reason>), prints each page's declared tools and, when tools are on, plugin <name> supplies a tool script (with a notice when no page has a tool, or every page of a swap site has one) or the notice that no listed plugin ships them, then measures every page in Chrome, and prints problems and findings with file and line.
Command
culm add <spec>
Does
Copies a package, name@1.2.3 or git+https://host/repo.git#<commit>, into packages/ and writes its entry in culm.lock.json. Nothing of it runs, and it is not approved. Fetching uses npm (or git), so this command uses the network and the .npmrc of the person. See app/packages.md.
Command
culm approve <name>
Does
A person at a terminal approves an added package: prints what it holds and asks for its name, typed. With no terminal it exits 2 and writes nothing.
Command
culm agents on|off
Does
Turns 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. See app/actions.md.
Command
culm expand <file> <id>
Does
Rewrites one short form as its nodes.
Command
culm render [spec | page] --out <file>
Does
Exports a standalone JSON/shape visual, site node, or page as PNG, WebP, or SVG with integrated measure checks.
Command
culm schema
Does
Writes culm.schema.json.
Command
culm mcp [--port n] [--chrome path] [--full]
Does
Starts the MCP server (see mcp.md).
Exit codes: 0 done; 1 problems or findings (also approve or agents on declined); 2 wrong usage, check could not measure, or approve or agents on run with no terminal. culm check exits 1 on any problem, or on a finding of class 1 or 2, and 2 when measure could not run or was incomplete, so a missing browser is told apart from a finding.
culm dev
The server binds 127.0.0.1 only and has no option to bind elsewhere. It refuses a request whose Host header is not 127.0.0.1:<port> or localhost:<port>. It serves assets/ and fonts/ (as /_fonts/) from the project and nothing outside them, including through a symbolic link. A file under assets/ or fonts/ is used (served, copied, hashed, measured) only when its real path lies inside that same folder; a link to a file elsewhere in the project, such as site.json, is refused by build and check with its file named (check stops with exit 1 before it opens a browser), and is a 404 in dev. A link to a folder that stays inside its own folder is skipped; one that leaves it, or the project, is refused like a file link, and a folder that cannot be read is a problem.
On a save, the server waits 50 ms for the burst of file events to end, reloads the folder, compiles, and swaps the new pages in whole. It then sends a reload event and the page reloads itself.
When the save leaves a problem, the pages on screen stay the last good ones, and an overlay shows each problem as file:line:column, the message and the allowed values. Fix the file and the next save sends reload. Before the first good compile every page path answers 503 with the client script, so the overlay can show.
The reload and overlay code is added by the server to what it serves. It is in no file culm build writes (CLIENT_MARKER is absent from every file buildSite writes).
culm dev also writes culm.schema.json when it starts, and again when a plug-in or a file in blocks/ changes.
culm build
culm build refuses an output folder that is not empty and holds no culm-manifest.json, so it cannot clear a folder it did not write. It clears an output folder only if that folder holds a manifest Culm wrote, and only inside it. It refuses an out that resolves, by real path, to a source folder, a parent of the project, or a symbolic link out, in any letter case on a case-insensitive disk. A site with no page at / is a problem. build and dev make no network request (culm add is the command that fetches).
The manifest's build is one hash of what the build used: the document, the data, the registry and the hash of every file in assets/ and fonts/.
culm check
culm check measures each page at widths 1280, 834 and 390, in the light and dark themes and in each direction the site's languages declare, with the default state of each part. That is the measure profile, version 1. It opens Chrome over the DevTools protocol on a pipe; no port opens, and no browser is ever downloaded.
Chrome is found from --chrome, or CULM_CHROME, or a Chromium already installed by npx playwright install chromium (found on disk; Playwright itself is not used), or the system Chrome, in that order. If none is found, the run is MEASUREMENT_INCOMPLETE, the message names those three ways, and the exit code is 2.
Measure serves each page from memory under a Content-Security-Policy, answers only requests the compiled bundle can answer, and refuses every other address. A page cannot make Culm contact the network.
Previous