Concepts
Overview
Culm is a JavaScript framework that builds websites from data. This page says exactly what exists in the repository today. The package is @culmjs/core. It has no runtime dependencies and runs in Node 22+, edge workers and the browser.
This page describes the site document, validation, compilation and checked operations in @culmjs/core. @culmjs/tools provides folder sites, the CLI and agent authoring over MCP. @culmjs/webmcp, experimental, is a plug-in that supplies the tool script for declared tools (README).
The idea in three sentences
A site is one versioned JSON document. People and agents change the document, never page code. Culm checks the document and compiles it to static HTML and CSS, and it compiles nothing from a document that has problems.
The site document
The document holds the pages and what they share.
Part
Holds
Part
schemaVersion
Holds
Which stored structure the document uses. Today it is 2
Part
pages
Holds
Each page has an id, a title, a slug and a root node
Part
header, footer
Holds
A node tree each, shared by every page
Part
components
Holds
Reusable trees. An instance node points at one
Part
fonts, styles, look
Holds
Fonts in use, named styles (colours, text styles, spacing, shadows) and the site's look tokens
Part
languages
Holds
Language codes and direction
Part
agents
Holds
Optional: whether the site's declared tools are on (app/actions.md)
A page slug is a site path. It begins with /, the home page is exactly /, and each segment uses lowercase letters, digits and dashes. compileSite reports a problem when no page that is switched on has the slug /, and still returns the files, so a preview can show a site that has no home page yet.
Nodes
A page is a tree of nodes. A node has:
id, kind and name
props: the settings its kind allows
style: layers for base, tablet, phone, dark mode, interaction states (hover, pressed, focus and others) and declared states
children
optional state and on: declared states and the triggers that change them
optional motion: a trigger and either checked steps or a registered effect (including Stage 4 GPU/WASM effects such as contours, ripple_field or custom shaders when gpu is enabled). An entrance can run once on entering view; a scroll track can seek in either direction. Motion docs · GPU exit summary
optional repeat, bind, showIf: data binding and conditional display
optional tool and acts: a declared tool, or the acts an in-page island offers (app/actions.md). They are written to a built page only when tools are on and a listed plug-in supplies a tool script
optional slot and placement: how it sits in its parent
There are 23 core kinds, all layout or content: free, box, row, column, grid, list, table, table-row, table-cell, text, image, icon, button, divider, embed, video, menu, form, field, details, instance, shape and island (a place a module draws into, see app/islands.md
). A shape is a vector drawing (rect, ellipse, polygon, star, line, blob, path or a group of up to 32 parts) painted with site colours, a gradient or a stroke; a button may hold up to 4 shapes behind its label, and any container may hold shapes placed behind or front. A shape is decoration unless it has a label, and it never counts as text. An image may have a link (a page, a web address, an email or a file, with the rules a button's link has): the picture is then written inside an a, named by the picture's alt, and that a takes no part in the layout (display:contents), so a linked logo keeps its place in the row. A link that points nowhere leaves a plain picture. A plug-in can add more.
The limits are 2,000 nodes per page and 12 levels of nesting. KINDS, the table of core kinds, is frozen along with everything in it, so a consumer cannot change a kind for every registry in the process.
Required content and text size
A node can be marked required: true. A required node must stay in the site and stay visible:
Validation refuses a document in which a required node is hidden, with a POLICY_VIOLATION whose rule is required. It judges required content on the tree the page is built from: the header, the footer and each page with every instance unrolled as compile unrolls it, so property defaults, the looks in use, set values, bindings, overrides and what an outer instance does to a nested component are already applied, at any depth. A node is hidden when it or an ancestor in that tree has a hide flag for any layout or hidden: true or opacity: 0 in any style layer (state and when layers included; a node with motion is exempt from the opacity rule, as an entrance may start at 0). A component nobody uses is in no tree and is not judged. A node the document holds under its own id (a page node, or a required instance, whose unrolled root keeps its id) is reported at that id; a part of an instance is reported at the outermost instance with the path parts.<the part's id inside it>. A path is always on the node named: when the hiding sits on the node itself it ends in the field (hide.<layout>, style.<layer>.hidden, style.when.<i>.decl.hidden); when it sits on an ancestor there is no field (no path at all for a node held under its own id), and the message names the ancestor. When the hiding is written in a component's master, the message says so and names components.<id> and the part, as changing it there fixes every use. A property bound to data becomes a show condition and, like any showIf, is not judged. A page, header or footer that the unroll cuts at the node limit is not judged part by part: when it holds required content (a required node, a form or field, or an instance of a component that holds one), it is refused once with RESOURCE_LIMIT_EXCEEDED, rule required and the path pages.<id>, header or footer, as the cut may leave that content out; a cut tree without required content stays valid.
A required text must keep a run that has a data binding or a character a reader sees: a letter, a number, punctuation or a symbol, other than the Hangul fillers and the Braille blank (so a zero-width space, a soft hyphen, a combining mark alone or a private-use character is not content), judged on the same unrolled tree. A math run does not count as the content of a required text: such a text needs a run with visible characters or a binding.
The provenance marks sample and chrome are written only by inserting a block. setProps refuses a props with either key, setInstance an override whose props has one, and add a node anywhere in the added subtree that carries one, or an origin tag (INVALID_OPERATION, with the path to it). And plan refuses a batch after which a node that was required and kept on the live page is still required but left out as sample text (POLICY_VIOLATION, rule required): a text the block marks as a sample or its own wording, or a box that would hold a sample and nothing a person wrote, whichever operation caused it (setBlockSetting, updateBlock, remove, move, a hide). Writing the words again with setText in the same batch is a way out.
remove refuses a subtree that holds a required node. It also refuses to remove the last instance of a component that holds one. removePage, updateBlock and setBlockSetting refuse any result that no longer holds a node that was required, and detach gives the detached root the instance's own mark. updateBlock keeps a person's explicit required (true or false) on every node in both versions, over the new look's.
A form is required unless it is marked required: false. A field is required unless it is marked required: false or its form is. These two kinds are the only ones that can be marked false.
A batch or a restore cannot put a required form or field into repeated rows or under a show condition (showIf or showIfAny on it or an ancestor, including one bindData sets), or leave it on a page that is off (validate/required.ts treats a form or field as conditional when the page is off, or the node or an ancestor has repeat, showIf or showIfAny). It is refused with POLICY_VIOLATION, rule required. The check is on the change, so a document that already has one stays valid, and a form or field already under a condition, an opted-out one, and a new form are allowed. To do it on purpose, opt the form or field out first with setRequired false. Surfaces use their own rule (app/surfaces.md).
To take required content out on purpose, change the mark first, in the same batch: setRequired with null deletes the mark, and with false it opts a form or field out. A form is required by its kind, so it needs false. The refusal is meant to be a decision, not an accident.
The site styles can also hold textRange: { min, max }, whole numbers from 1 to 400. A text size outside the range, in a node layer, a run style, a named text style or either end of a fluid size (fluidSize.min and fluidSize.max), is refused with a POLICY_VIOLATION whose rule is textRange and whose allowed is the range as two texts, such as ['11', '96']. Node sizes are judged on the same unrolled tree, so that includes a size an instance or a component gives a part: in an override, in a look in use, or as the value of a fontSize property; a component nobody uses is not judged. With no textRange, no size is refused. setSiteStyles sets it, and null removes it.
Versions and migration
migrate(doc) runs registered steps from the document's version to the current one. It is pure, never changes its input, refuses a document from a newer version, and reports the path of the first node a step could not migrate. previewMigration is the same function under the name a tool uses to show what a migration would do.
The schema version is 2. The one step, from 1 to 2, gives required: false to every form or field it cannot show to be visible, because version 2 refuses a hidden required node and version 1 documents could hide a form: one hidden in its own tree (hide or hidden: true on it or an ancestor), every one inside a component's master, and every one under an instance (slot content), and every one in a page, the header or the footer whose tree, expanded through its components, reaches the element or depth limit (version 2 refuses such a cut tree when it holds required content). The step cannot see what a use does, so it exempts all forms inside components; that only loosens, as version 1 had no such protection. A form on a page that nothing hides gains no field. restore migrates an older revision the same way before it checks it.
Previous
Next