Agents

Every reply

For an agent host, register one stdio server: executable <site>/node_modules/.bin/culm⁠, arguments ["mcp"]⁠, working directory <site> (the folder containing culm.json⁠). Use the revision from describe for the first write and the returned revision for subsequent edits.

Write in a familiar format

In --full mode write can also import existing page source. For example, this replaces the content of the home page with a custom responsive section:

{
  "baseRevision": 0,
  "page": "home",
  "html": "<section id='intro' class='hero'><p>Independent ceramics. <a href='mailto:studio@example.org'>Contact the studio</a>.</p></section>",
  "css": ".hero {padding: 4rem 6%; background: #f2eee4} .hero h1 {font-family: Georgia, serif; font-size: clamp(40px, 8vw, 90px)} @media (max-width: 600px) {.hero {padding: 2rem 6%}}"
}
  • HTML/CSS: supply html with inline style⁠, embedded <style>⁠, or a css stylesheet for that write. Sections, articles, asides, divs, nav, headings, paragraphs, inline marks and links, lists, images, buttons and dividers lower to editable nodes. A full

    <html><head><title>…</title></head><body>…</body></html>

    writes the page and shared header/footer; omitted header/footer are cleared. CSS supports tag, class, id, compound and descendant selectors, flex/grid layouts and max-width media rules (phone 600px; tablet 1024px). This is a static import: unsupported elements and selectors are reported; approximated declarations carry warnings. Use find for stored node ids.

  • Literal JSX: supply jsx⁠, for example

    "<Column><Text level=\"h1\">Studio</Text></Column>"

    . Components, text marks, plain attributes and literal style objects are supported. No JS runtime is needed.

  • JSON: supply json as a node, sibling array, or JSON/JSONC string. For example:

    {"kind":"text","id":"headline","level":"h1","text":"Kiln Index","style":{"fontSize":64},"phone":{"fontSize":36}}

    . Containers have children⁠; native props and layered style: {base, tablet, phone} are also accepted. Page⁠, Header⁠, Footer and Site can be expressed as JSON nodes.

Choose one source per write or per insert item. page + append:true adds a fragment; target replaces one existing node, using any source format. A top-level theme accepts partial look fields, including CSS font stacks, hex or named colors, and corners: "square" or "8px"⁠. theme alone changes no page content.

insert appends ordered {html, css?}⁠, {jsx}⁠, {json} or registered {use, id, look?, set?} items. patch merges fields on named nodes without replacing siblings or resending the page. Inserts and patches in the same write commit together. For example, to edit the previous heading at revision 1:

{
  "baseRevision": 1,
  "patch": [
    {
      "id": "headline",
      "text": "Kiln Index / 02",
      "phone": { "fontSize": "32px" }
    }
  ]
}

A refused write can return a session-local draft⁠. At the same revision, use JSON Patch replacements on the original arguments, for example

{"baseRevision":1,"draft":"<returned id>","edits":[{"op":"replace","path":"/patch/0/id","value":"headline"}]}

. /insert/1/html replaces just the second item's markup; /json/children/0/text replaces one field of a JSON object. No literal search or partial commit is involved. The server keeps its eight most recent drafts within the write size limit.

Ordered JSON edits

Start culm mcp (the default profile; --full is the general server), or pass jsonOps: true to createMcpServer⁠. describe⁠, find⁠, write⁠, measure⁠, build and render are the entire tool list. The authoring guide for this profile is not in the server instructions⁠: describe returns it once, as guide⁠, after the pages and the section outline (see Server instructions). In this profile write takes 1–32 ordered ops⁠; it validates and commits them together. A single op works the same way. Earlier inserts can be updated or moved later in the same request. Retry the identical write with its original revision to replay it without adding duplicates. This form of write is also available on the general server.

{
  "baseRevision": 0,
  "page": "home",
  "ops": [
    {
      "op": "insert",
      "node": {
        "id": "intro",
        "kind": "column",
        "children": [
          {
            "id": "title",
            "kind": "text",
            "level": "h1",
            "text": "Open studio",
            "style": { "size": "clamp(64px, 14vw, 192px)" },
            "phone": { "size": 64 }
          }
        ]
      }
    },
    {
      "op": "insert",
      "node": {
        "id": "visit",
        "kind": "row",
        "phone": { "direction": "column", "align": "start" },
        "children": [
          { "kind": "text", "text": "Come by on Saturdays." },
          {
            "kind": "button",
            "label": "Plan a visit",
            "link": "mailto:desk@example.org"
          }
        ]
      }
    }
  ]
}

insert.node appends one ordinary subtree; page: "header" | "footer" edits site chrome; addPage⁠, removePage and setPage manage pages. update merges text⁠, props⁠, set⁠, slot⁠, placement⁠, hide⁠, state⁠, on⁠, motion⁠, tool or style layers on an id (⁠tool is described under Declared tools; null clears a style key or tool⁠/⁠motion⁠/⁠placement⁠/⁠hide⁠/⁠

state⁠/⁠on⁠); move takes id⁠, destination index and optional parent (page root by default); remove takes an id⁠; theme.value changes the look. The receipt names the revision and section ids, and, when the batch ran an addPage⁠, pages: [{ id, slug }] for the pages it created (absent otherwise), so the next write can name them. find {} returns the section outline. For a targeted read, use e.g. {"id":"title","full":true}⁠. Measurement is explicit: call measure⁠, or ask for it on the last write of a batch (see Measure and read on a write). A crowded-phone-row finding reports the constrained heading/button, its parent, its measured width and line count, and a fix suggesting setProps or setStyle⁠. Horizontal schedule rows can stay horizontal.

Refusals that name their fix, and values the write converts

One write edits one page: a header.* or footer.* id needs its own write with page: "header" or "footer"⁠, and the refusal says so. A write to a page id that does not exist (an implicit home⁠) while another page holds its slug is refused with

No page "home"; pages: p1 /, p2 /about

, the stable INVALID_DOCUMENT code; give addPage a page id, or use the ids in the receipt's pages⁠. An id another page holds is refused with ids are site-wide and a free page-prefixed id (for example abouthero⁠). render refusals say to pass out:"<name>.png" or format:"svg"⁠, that SVG needs a shape node and a section or page goes out as format:"png" with out⁠, and a dotted id lists the ids near it. An out that leaves the project folder is refused with

out path must stay inside the project folder; use a relative path such as out:"shots/home.png".

(⁠POLICY_VIOLATION⁠; the --full profile's text changes too, its code and the rules below do not; --sections has no render⁠). In the compact profile an absolute out in a temp folder is not refused: see the table. An unknown field on an insert or a move adds the way to place a node (⁠Insert appends to the page; place it with {op:"move",id,parent,index} after it.⁠), and an insert whose node arrived as null says so and shows the shape.

Only the compact write (⁠culm mcp⁠, the default profile) converts these values; it says so in warningCount and warning⁠. The --full and --sections profiles refuse them as before:

Input

Becomes

Input

theme.value.colors

Becomes

brand⁠, ink⁠, bg and accent go to the look and to the site palette; any other key is a site colour. If theme.brand is also given, colors.brand stays a site colour

Input

theme.value.fonts {heading, body}

Becomes

headingFont and bodyFont (the site fonts and text presets follow)

Input

theme.value.corners as "soft" or "rounded"

Becomes

8 and 12 px. A number, "square" and "8px" need no conversion; any other word is refused with these forms listed

Input

a CSS transform-origin in style (⁠"top left"⁠, "50% 50%"⁠, "left"⁠, transformOrigin⁠)

Becomes

the origin key of the nine points; a value that is not one of them is still refused, with the nine listed

Input

a node's origin: {block, version, look} copied from find

Becomes

dropped (the node is written without a block tag; only inserting a block writes one)

Input

addPage or setPage with id⁠, path or name⁠; removePage with id⁠; move or insert with parentId

Becomes

page⁠, slug and title⁠; page⁠; parent⁠. Only when the schema's field is absent; if both are given the unknown field is refused. One warning per spelling

Input

an op with no op⁠: {node} or {id, style|props|text|…}⁠; or op as add⁠, set⁠, delete (any case)

Becomes

insert⁠, update⁠, update⁠; insert⁠, update⁠, remove⁠. The warning is shown. An op that has only {id, text} or {id, style} is read as an update, so a node the agent meant to insert is instead an edit that can overwrite the text or style of the node with that id. Anything else is refused with the op names

Input

{op:"site", name} or {op:"site", value:{name}}

Becomes

the site name (⁠setSite⁠), which no other op of this profile sets; the header text is the node header.name⁠. Only the name: any other key (⁠backends⁠, origins⁠, values⁠, navigation⁠, languages⁠, centreMaxWidth⁠) is refused with Unknown field "…". Expected op, name. (this includes a value that is not an object, and a name given both beside and inside value⁠) and nothing is written. An empty name is refused (⁠name must not be empty.⁠), as is one over 200 characters. setSite itself is not an op here

Input

insert with parent and/or index⁠, or an id beside node

Becomes

the insert, then a move of the node to that parent and index (the node needs an id⁠); the op-level id becomes node.id when the node has none

Input

insert.node as a list of two or more sections

Becomes

one insert for each, in order

Input

style.font of "heading" or "body" (any case)

Becomes

left out, with one warning per role for the write: a node cannot name a font role; name a family, or set headingFont and bodyFont in theme⁠. Not fetched from Google Fonts

Input

render with an out that is an absolute path in /tmp⁠, /var/tmp or the system temp folder

Becomes

rendered and checked; nothing is written, including for a node⁠: no font is fetched into fonts/ and no image is generated (the render uses what the project already holds, so a Google font it does not hold falls back), and note says so (it echoes at most 120 characters of the path) and names up to three Google fonts the project does not hold (⁠Fonts not held: Pacifico (rendered with the fallback; a write fetches them).⁠). The same holds for an svg render of a shape node with no out⁠; an svg render of a layout node is refused before anything is fetched. Any other path outside the project is refused

Input

render of a page, section or node with no out (png, webp), or format:"svg" of a page or a non-shape section with no out

Becomes

the same: rendered as a checked png with nothing written, note names out:"shots/home.png" to keep the image

An empty colour name in theme.value.colors is refused (⁠INVALID_OPERATION⁠). A look refused for contrast (⁠In light, the brand colour is too faint on the background.⁠) gets one more sentence in the compact write, with the 4.5 to 1 rule; the other profiles keep the core text. Conversion warnings are listed once each (an op word is compared in lower case; a font-role note is one per role for the write). Conversions that expand an op count after expansion against the 32-op cap: a list of nodes is one insert each, and an insert with parent or index is an insert and a move; a write over the cap is refused with A write takes at most 32 ops, and ops[i] reads as N⁠. An op-level id beside a list of nodes is refused (the same id would go to every node). A write reply shows warningCount and the first two warnings, cut at 220 characters. The pages field of the receipt is added by every ordered write that runs an addPage⁠, on the --full profile too.

Measure and read on a write

A write replies with the receipt only, and measures nothing, unless it asks. Two optional arguments of the six-tool profile's write (not of --sections or --full⁠) save the measure and find calls that usually follow it, and the conversation each one re-sends:

  • measure: true or { pages?, widths?, classes? } runs what measure runs, after the write is committed, with since set to the revision before the write, so the reply says what is new and what is fixed. pages defaults to the pages whose content the write changed. A header or footer edit, a theme⁠, setValues⁠, setLiveSources⁠, addCustomEffect⁠, addPage⁠, setPage or removePage operation reaches every page (the header and menu are on each, and header-edge and heading-order read the page), so every page that is on is measured, at most 8: with more, the first 8 are measured, the rest are listed in measure.skipped as page:<id>⁠, and measure.partial and cut are true⁠, so a partial result is never a clean one. A write that changes no node measures every page the same way. pages given by the caller is used as given. widths and classes default as in measure⁠. The reply carries it as measure⁠, in the shape

    measure replies with (⁠revision⁠, measured⁠, findings⁠, fixed⁠, unchecked⁠, incomplete⁠, blocked⁠, skipped⁠, cut⁠), with the same package-name scrub. measured: 0 always carries an error⁠. If nothing could be measured (no Chrome, the revision since names is not held, a page that does not compile) the write stays committed and measure carries an error with incomplete shaped as measure⁠'s own (and, when the browser ran but measured nothing, the rest of measure⁠'s reply).

  • read: true adds read⁠, one entry per node the write created (the roots of what it inserted, each with its subtree as node⁠) and per node it changed or moved (the match without its subtree), as find {id, full: true} and find {id} show them, redacted as find is. An entry whose subtree is over 2,500 characters has no node and cut: true⁠; use find for it. At most 20 entries.

A refused write returns the refusal only and never measures. A wrong type (⁠measure: "yes"⁠, read: {…}⁠, a list of the wrong kind) is INVALID_OPERATION at measure or read before anything is written. The whole reply, as it is sent, stays within the 16,000-character read cap, and a committed write never answers with an error: read shrinks first (to nothing if need be), then the longest of measure.findings⁠, fixed⁠, incomplete⁠, blocked and skipped⁠, then the section ids, and cut is true (⁠measure.cut too when its lists were cut); run measure for the rest. A finding "fixed" in a page this write added is not reported.

The two arguments are not part of the write's identity, so the same key replays the same stored receipt whichever of them is passed. A replay measures again only when measure is passed again, and then it measures the head as it is now, since the write's baseRevision (its measure.revision says which revision that was); read shows the nodes as that write left them. The stored receipt itself never changes.

The live operations (⁠setValues⁠, setLiveSources⁠, update.live and live on an inserted node) are listed in this write only when the site the server started with declares backends, values or live sources (⁠site.json on a folder), which keeps the tool list about 500 characters shorter on a site without them. On such a site a write that uses them is INVALID_OPERATION at ops⁠, saying that a person declares a backend; the head is read again on that refusal, so once a person has declared one the next write is accepted.

GPU text appears only with "features": { "gpu": true } in culm.json⁠: addCustomEffect and gpu:"mist" in this write⁠'s description, the addCustomEffect operation in the write schema (here and under --full⁠), the GPU row of catalogue guide⁠, and the operation's line and entry in catalogue operations⁠. Without it, core refuses what that text describes. The server reads the setting once, when it starts, so a server started before the setting changes keeps what it served. Without it the GPU ceilings stay in the --full and --sections describe reply, and refusals may still name GPU.

A new site opts in to a display ceiling: styles.textRange: {"min":11,"max":96,"displayMax":240}⁠. H1/H2 may use the larger range, including CSS clamp() or viewport sizes. They get tighter default leading and tracking; explicit styles, site heading tracking and phone overrides still win. Sites without displayMax keep their previous typography.

Use describe {"example":"display"}⁠, "phone-row"⁠, "figure" or "group" for a small, editable node. The figure pairs an original path, gradient and stroke with a mixed-run caption; group parts have their own geometry, paint and slots. Replace or omit anything. There is no block registration or separate planning step.

Motion on a heading

On a home page with no title node, send these arguments to write⁠, substituting the revision from describe⁠. The heading rises 24 pixels into place the first time it enters view:

{
  "baseRevision": 0,
  "page": "home",
  "ops": [
    {
      "op": "insert",
      "node": {
        "kind": "text",
        "id": "title",
        "level": "h1",
        "text": "Open studio",
        "motion": {
          "trigger": "enter-view",
          "effect": "rise",
          "settings": { "distance": 24 }
        }
      }
    }
  ]
}
find {"tree":"home","id":"title","full":true}

returns the stored program. To replace it, send another write using the revision just returned:

{
  "baseRevision": 1,
  "page": "home",
  "ops": [
    {
      "op": "update",
      "id": "title",
      "motion": {
        "trigger": "load",
        "steps": [
          {
            "target": "self",
            "from": { "opacity": 0 },
            "to": { "opacity": 1 },
            "durationMs": 300
          }
        ]
      }
    }
  ]
}

Omitting motion from an update keeps it. Sending "motion": null removes it. A full subtree replacement describes the whole node, so leaving motion out there removes it too. Invalid motion refuses the batch, including any earlier edits.

In --full mode, send

{"op":"setMotion","tree":{"page":"home"},"id":"title","motion":null}

in plan or apply to clear this heading. Supply either program above instead of null to set it. A tree can also be "header"⁠, "footer" or {"component":"<piece id>"}⁠. Use diff between revisions to see the motion field that changed, and restore to bring an earlier program back.

Common result format

  • A reply is one text item of JSON, at most 16,000 characters (⁠READ_CAP⁠), with cut: true when something was left out and, for a list, a cursor for the rest.

  • A cursor is tied to the revision it was made at and to the read that made it. Used after the revision changed it is REVISION_CONFLICT⁠; used for another read it is INVALID_OPERATION⁠.

  • A refusal is a tool result with isError: true and { "problems": [...] }⁠, at most 20 problems. It is never a protocol error. A store that throws, a browser that dies and an input of the wrong type each come back as a refusal, not as a crashed server.

  • Each problem has a stable code⁠, a message⁠, and where they apply nodeId⁠, path⁠, allowed⁠, rule and op (the index of the operation in the batch). On a folder site it also has file⁠, line and column⁠.

  • Input schemas are loose on purpose. plan and apply accept a list of objects that each have an op name; core decides what is valid. An agent learns each operation's arguments from catalogue⁠.

Edit this page on GitHub