Folder sites

The files

culm.json

{
  "$schema": "./culm.schema.json",
  "plugins": [], // package names, imported from this folder's node_modules
  "out": "dist", // where `culm build` writes
  // where the site is served, which decides how its policy is sent: "netlify" | "cloudflare" | "vercel" | "firebase" | "github-pages" | "other"
  // "host": "netlify",
  // what a person says of each package: the sources it is bound to, and whether it may run in the page (see app/packages.md)
  // "packages": { "shop": { "sources": { "products": "products" } } },
  // optional Stage 4 GPU shader + WASM field support:
  // "features": { "gpu": true, "llms": true },
  // optional AI image generator for `image.generate` / `bgImage.generate` (cached in assets/gen/):
  // image generation is off until this key exists (an empty object `{}` is enough); a stray API key in the environment alone never starts it:
  // "images": { "provider": "gemini" | "openai" | "higgsfield" | "http", "model"?: "...", "endpoint"?: "..." }
  // a person's word that an agent may turn the site's declared tools on (see app/actions.md):
  // "agents": { "mayTurnToolsOn": true },
  // the one ceiling a site may move: the CSS of a page, in bytes (default 16,000), or false for none:
  // "limits": { "css": 64000 }
}
  • plugins lists plug-in packages by bare name (⁠my-plugin⁠, @scope/my-plugin⁠). Culm imports each from <folder>/node_modules/<name> and registers its default export. A path, an absolute path or a package that exists only in a parent folder is refused with a problem at that line. A project therefore has a package.json and installs @culmjs/tools and its plug-ins with npm.

  • features.gpu⁠: enables contours⁠, ripple_field⁠, and site-local effects/<name>.json + <name>.frag shaders (⁠customEffects in site.json⁠). Built sites emit lazy _culm/gpu.js (⁠<= 9,513 B, loaded with SRI outside reduced motion / Save-Data⁠), record wasmModules in culm-manifest.json⁠, and grant worker-src blob: and 'wasm-unsafe-eval' in _headers only when rendered pages require them.

  • features.llms⁠: writes llms.txt at the site root and a Markdown twin of each page (⁠index.html.md⁠, about/index.html.md⁠). New projects (⁠culm init⁠) have it on; an existing culm.json without it stays off, and then the build output is byte-equal to a build before the setting existed. See app/reading.md.

  • host says where the built site is served. It decides how the site policy is delivered: _headers for every host, plus vercel.json or firebase.json for those hosts, and meta-only for github-pages⁠, which cannot send a header. See app/policy.md.

  • packages is a person's word about each package in culm.lock.json⁠: sources binds each source the package asks for to a source of site.json⁠, and trusted: true lets an island of the package run in the page when a node asks. It is written by hand; no operation writes it, and each key and value is judged and located. See app/packages.md.

  • limits.css moves the page budget for CSS (16,000 bytes by default): a whole number from 1 raises or lowers it, false removes it. It is the only ceiling a site can change; scripts, elements and nesting keep theirs. The build, culm dev⁠, culm check⁠, the measure tool and describe (its ceilings.page.css⁠) all use it. A page over its ceiling is refused with RESOURCE_LIMIT_EXCEEDED naming css⁠, and compiles nothing. A larger ceiling means larger blocking CSS on every page that uses it, so first paint gets slower; the 16,000-byte default is what the published comparisons were measured under. Written by hand, judged and located like the rest.

  • agents.mayTurnToolsOn lets an agent talking to culm mcp turn the site's declared tools on. Off unless the literal true⁠. It is written by hand, and it is not the switch itself: that is agents in site.json⁠. See app/actions.md.

  • out is the build folder. It may not be, or lie inside, blocks⁠, pages⁠, pieces⁠, data⁠, islands⁠, packages⁠, assets⁠, fonts⁠, node_modules⁠, .culm⁠, site.json⁠, culm.lock.json or culm.json⁠, and may not leave the project.

site.json

{
  "$schema": "./culm.schema.json",
  "name": "Corner Bakery",
  "look": {
    /* a Look: id, name, family, brand, ink, bg, fonts, corners, dark */
  },
  "styles": { "textRange": { "min": 11, "max": 96, "displayMax": 240 } },
  "fonts": ["sys:sans"],
  "languages": [{ "code": "en" }],
  "pages": ["home.json", "menu.json"], // order of pages; file names in pages/
  "header": { "block": "page-header" }, // a node, a short form or a use
  "footer": { "block": "page-footer" },
}

A site that reads from a web service adds these keys, each described in app/live-data.md: backends (the services a page may call), origins (⁠{ "img": [...] }⁠, the origins images may load from), values (state that outlives a view, and the key), liveSources (the requests a page may make), grants (what a framed island may read, app/islands.md) and navigation: "swap" (pages change in place). Each is judged and located like the rest. The sample application in

packages/tools/__browser__/fixtures/app

is a whole site that uses them.

"agents": { "tools": true } in site.json turns the site's declared tools on; culm agents on writes it and culm agents off takes it away. A node in a page file may carry tool or acts⁠, and a field's props a description⁠. See app/actions.md.

The pages list is the order of the pages. A file in pages/ that the list does not name is a problem, and so is a name in the list with no file.

pages/<name>.json

{
  "$schema": "../culm.schema.json",
  "id": "menu",
  "title": "Menu",
  "slug": "/menu",
  "on": true,
  "inMenu": true,
  "inFooter": false,
  "icon": "",
  "root": {
    "kind": "column",
    "name": "Page",
    "children": [
      { "block": "hero", "look": "plain", "title": "Today's bakes" }, // short form
      { "use": "../pieces/visit-card.json", "note": "Open from 7" }, // use of a piece
      {
        "id": "intro",
        "kind": "text",
        "name": "Intro", // a plain node
        "props": { "runs": [{ "text": "Baked every morning." }] },
      },
    ],
  },
}

File names are free. When addPage creates a page file, it names it from the slug with each / after the first replaced by - (⁠/a/b becomes a-b.json⁠), and home.json for /⁠. A name already taken gets -2⁠.

A page that is on and whose first slug segment is assets⁠, _fonts or culm-manifest.json would collide with what a build writes, and is refused with the file and line of the slug.

A node, a short form, a use

A page's root⁠, and every child, is one of three things.

  • A node is the document's node with id⁠, slot and name optional. A missing slot is the default for the parent's kind; a missing name is the kind's label.

  • A short form is { "block": id, "look"?: id, "id"?: id, ...settings }⁠. Every other key is a setting of that block. The loader expands it with the registered block, so a short form can use only what the block declares. An unknown setting is a problem at the key.

  • A use is { "use": path, "id"?: id, "name"?: text, ...values }⁠. The path is relative to the file. Beside the piece's own settings, a use may also carry node-level fields (⁠slot⁠, placement⁠, hide⁠, showIf⁠, showIfAny⁠, locked⁠, overrides⁠, bind⁠, children⁠) when not declared as piece settings. name is the name of the node; a piece that declares a setting called name keeps that key for the setting, and a differing node name on such a use is a problem.

A use whose path is package/component⁠, with no dot (⁠

{ "use": "shop/price-table", … }

), names a component of an approved package instead of a file. It is a problem until a person has approved the package (app/packages.md).

culm expand <file> <id> rewrites one short form in a file as its nodes, so you can then edit the parts inside it.

Motion in a page file

Place this plain node in the children of a page column, then run culm build⁠. The built-in rise effect fades the heading in while moving it up 16 pixels over 400 ms:

{
  "id": "title",
  "kind": "text",
  "props": { "level": "h1", "runs": [{ "text": "Open studio" }] },
  "motion": { "trigger": "load", "effect": "rise" }
}

motion is a node field, alongside props and style⁠. Its value contains a trigger and either a registered effect (with optional numeric settings⁠) or a sequence of steps⁠. Delete the field to clear it in a file; null is the edit operation's instruction to delete. See Motion on a heading for a checked sequence and the equivalent write calls. culm schema includes the field for editors; culm build checks the program against the actual registry and tree and reports malformed motion at its source.

Setting motion on a block shorthand or one of its children via MCP expands that block in the page file. A use shorthand cannot hold motion⁠: a motion edit there is refused. To animate every use, explicitly edit the node in the piece file; for just one use, detach it first and edit the resulting nodes.

pieces/**/*.json

{
  "id": "visitcard", // optional; else derived from the file path
  "name": "Visit card", // optional; else the file's path
  "settings": [
    { "key": "note", "label": "Note", "type": "text", "part": "line" },
  ],
  "root": { "id": "card", "kind": "box", "name": "Visit", "children": [] },
}

A piece is a reusable subtree. The loader makes one component per piece file and one instance per use. A change addressed to the piece's tree edits the piece file, so every use changes; a change through setInstance edits the one use. Two pieces with the same id are refused, with the file and line of both. A circular use, a use of a missing piece and a use whose path leaves the project are each a problem at the use. The order of components is not meaningful.

blocks/*.json

{
  "id": "openinghours",
  "version": 1,
  "name": "Opening hours",
  "category": "content",
  "looks": [{ "id": "list", "name": "List", "tree": {} }],
  "settings": [],
}

A block written as data: the document's BlockDef with no function fields. A file that names a function (⁠onInsert⁠, or a setting with fn⁠) is refused with file and line. A bad block file is skipped alone; the others still register. All block files register as one local plug-in named local⁠.

data/<source>.json

{
  "fields": { "name": "text", "price": "text" },
  "rows": [{ "name": "Sourdough", "price": "6" }],
}

This is how a project declares a data source without TypeScript. The loader registers a source of that name with those fields, and passes the rows to the compiler after checkRows⁠; a row with an unknown field is a problem at the row. Data files are not part of a revision.

Fonts and files

fonts/ is copied to _fonts/ in the output and assets/ to assets/⁠. Culm ships no font files of its own. A Google family named in setFonts as { google: "Lato", weights: [400, 700] } is fetched by plan and apply into fonts/<slug>/⁠: the latin woff2 files, a font.json and the family's LICENSE⁠. An Iconify icon named set:name is fetched into assets/icons/<set>/<name>.svg with the set's LICENSE⁠. Both are plain files you can commit; a restore keeps them, and a hand-edited file that Culm would not have written is dropped at build. Only fonts licensed OFL-1.1, Apache-2.0 or UFL-1.0, and icon sets licensed MIT, Apache-2.0, ISC, CC-BY-3.0 or CC-BY-4.0, are fetched. One batch fetches at most 4 font families and 60 icons not already held; more is RESOURCE_LIMIT_EXCEEDED⁠. A site that names a catalogue font whose file is not in fonts/ gets a problem from culm build and culm dev⁠. culm check does not report it as a problem: the font cannot load, the page is measured with its fallback font, and the findings say assets: false⁠. A site that uses only system font stacks (⁠sys:sans⁠, sys:serif⁠) needs no font file.

Ids

A node written without an id gets one derived from its file and position: x followed by 12 characters of a base-36 hash of the file path and the JSON path. It fits the id rule (⁠^[a-z0-9]{1,20}$⁠) and cannot collide with the n ids the operations assign.

A derived id changes when you insert or reorder siblings by hand, so a finding or a diff for such a node does not survive that edit. The loader reports each node without a written id as a notice, not a problem. The writer writes an id into the file for every node an operation touches, and for all children of a parent whose order changes. A node that a trigger or anything else refers to by id must have a written id, and the loader reports it if not.

Edit this page on GitHub