Skip to content
Projects

About

A whole app environment in one Rust binary, built to be run by AI: say what you need, it builds the pages, back end and data as drafts, and you publish. 一个让 AI 来搭、由人发布的应用环境。

AI & Machine Learning

How these counts are measured

51 stars7 Forks +12 in 24h

Measured star growth

in 24h
+12
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

CMS Harness: say what you need, the AI builds it as drafts, you publish.

One program that is the back end and the back office of every web product you make.
The front end comes in as it is and the back end grows to fit it; pages are edited in place like in Figma; the back office changes when you say so.

One program of about 13 MB holds any number of systems: each its own data, its own back end, its own front ends and its own people.
No back end to write, no admin to build. Data in plain SQLite files. No Node, no Redis, no build step.

Latest release Tests GitHub stars License: AGPL-3.0 Rust 1.98+ MCP server built in CMS Harness MCP server on Glama

Quick start · The back end · The canvas · Systems and surfaces · The back office · Connect your agent · Reference · 中文

A bakery's page comes in untouched; the same address changed to /api/breads is answered by the system's own back end; the croissant's price is changed in the back office's Breads table, and the page follows.

🧱 Use it as the back end

A front end comes in as it is; the API, the tables and the admin pages grow by themselves. Not a line of back end to write.
In the preview a heading is selected and restyled, resized and dragged, text is typed right on the page, the pen puts a picture where the click was, the width switches to phone and the page keeps its own phone layout, and one change is undone from the list of changes.

🎨 The preview is a canvas

Edit the running page as you would in Figma; what you change is written back into the code.
The name beside the logo switches from the bakery to Shop staff: the whole sidebar changes, and the shop surface, the orders table, the staff and their roles are all its own; then back to the website.

🏠 Systems and surfaces

One program holds every system, none sharing data; one surface for each kind of user.
The Breads table has a page of its own: sorted by price, searched; a row edited by hand goes live at once; the change is listed below it and taken back with a click.

🎛️ A back office that bends

Every table gets a page; what doesn't suit you changes when you say so, live only with your yes.

Everything on screen is the real program running, and the content was built with its own tools.

A front end is only half of a web product. The other half is writing the API, setting up the database, doing sign-in and permissions, then building an admin for people to manage the data; and once it is handed over, every small change comes back to the developer. CMS Harness takes that whole half.

Who it's for: developers and studios who build systems for clients use it to build and hand them over, and after hand-over the client changes things by asking. Schools, small companies and organisations run it on their own server: the data stays with them, protection is built in.

How it compares

Where it runs What the AI changes After hand-over, who changes it
Lovable, Base44 The vendor's cloud (code can be exported; the editor and AI can't be self-hosted) The whole app's code Outside their editor, a developer editing code
NocoBase Your server Data and data models; screens are assembled in a no-code editor The owner, in the editor
Directus, Strapi, WordPress Your server Content and data (AI assistant, MCP) A developer, for the site and the admin themselves
PocketBase Your server, one file No AI; you write the front end A developer
CMS Harness Your server, one file Pages, back ends and their tables, data, and the admin screens themselves, for each system The owner, by asking; nothing goes live without their yes

If all you need is internal forms and approval flows, NocoBase is more mature (plugins, workflows) and worth a look first.

🚀 Quick start

curl -O https://raw.githubusercontent.com/Michaelzhao9/cms-harness/main/docker-compose.yml
docker compose up -d
docker compose exec cms-harness cms-harness admin [email protected]   # prints the admin password once; the first admin is the top account

Sign in at http://localhost:4200/admin. The site is at http://localhost:4200/.

Then open Settings → Chat model, pick a service, paste a key and press Detect. Or pick ChatGPT and press Continue with ChatGPT to run the chat on your own ChatGPT plan, with no key. That's it: start talking.

No Docker? Download a binary or build from source

Download a binary for Linux (x86_64, arm64), macOS (Apple Silicon) or Windows from Releases, or build it (Rust 1.98 or newer):

git clone https://github.com/Michaelzhao9/cms-harness.git
cd cms-harness
cargo build --release
./target/release/cms-harness admin [email protected]    # creates an admin and prints its password once
./target/release/cms-harness                          # serves on 127.0.0.1:4200

Sign in at http://127.0.0.1:4200/admin.

Putting it on a real domain

Set HC_ORIGIN to the public address exactly as the browser shows it (https://example.com); in docker-compose.yml that is the HC_ORIGIN line. Then either:

  • HTTPS by the program itself: point the domain at the server and start it with HC_TLS=auto. It listens on 443 and 80 by itself and gets a certificate from Let's Encrypt the first time each of its names is visited, then renews it on its own. Only the environment's own names get one: the site, www. before it, the admin's own address, each surface's subdomain and the languages' domains. Port 80 answers Let's Encrypt and sends everything else to https. Ports below 1024 need the right to bind them (setcap cap_net_bind_service=+ep on Linux; Docker allows it).
  • Or a reverse proxy (Caddy, nginx) in front for HTTPS. The binary on its own then only listens on the local address.

Each surface on its own subdomain: add one DNS record, *.example.com pointing at the server, and choose it in Settings → Surface addresses (or set HC_END_SUBDOMAINS=1). Saving checks the record first. From then on every surface, of every system, answers at its own name: shop.example.com, and any made later too, with no more setup. Old /shop/… addresses lead there. Behind a reverse proxy, send *.example.com to the program as well.

The chat model can come from the environment instead of Settings: LLM_PROVIDER (anthropic or openai), LLM_API_KEY, LLM_MODEL and LLM_BASE_URL. Without a model, the admin and the API still work, but there is no chat.

🧱 Use it as the back end

Drop the front end in; the back end grows by itself. Not a line of back end to write, and no separate admin to build.

On the left, the front end that came in untouched and the addresses it calls; in the middle, the back end the system grew to fit it, all under _server/: routes.json, _fn/*.js, migrations/*.sql, interface.md, forms.json; on the right, the system's own data in data.db and the Data pages made for it in the back office; along the bottom, what is already built in: sign-in and accounts, permissions, files and pictures, timers, notifications, full-text search, live updates, outside services, protection, tokens for apps.

What you used to build Here
An API and a server The AI reads what the front end asks for and grows it: addresses, functions, tables, all under _server/
A database and migrations, afraid to break them Migrations go live with the release or not at all: nothing is published when the live data cannot take them; the review says in plain words what each will change and lose, and a copy of the data is taken first
Sign-in, sign-up, permissions Built in: who may enter a surface is one condition
An admin for the people who run it A page for every table: search, filter, edit, every change undoable
API documentation interface.md is written with it, and check_system checks every line before publish
A test environment A drafted back end already runs in the preview, on a throwaway copy of the data

Any front end: hand-written HTML, React, Vue, a site built with Vite or Next, mini programs and apps.

Open: how the back end grows, and what else is built in
  • 🔌 A front end comes in untouched; the back end grows to fit it. Upload a project's zip (or have your agent call wrap_project) and its pages and scripts keep calling the addresses they always called. The AI reads what they ask of a back end (read_front_end: every fetch, form and stream, with its method and the code around it) and writes, inside the system, the back end that answers exactly that, under _server/:

    • _server/routes.json maps an address to a function: {"method": "GET", "path": "/api/breads", "fn": "breads"}.
    • _server/migrations/001-breads.sql shapes the system's own tables, in order.
    • _server/_fn/breads.js reads and writes them with sql("SELECT …", [params]), sql.one(…) and sql.run(…), and reaches nothing but its own system's data.
    • _server/interface.md describes every address: what it takes, what it answers, who may call it.
    • _server/forms.json says how the back office shows each table.

    check_system checks the whole back end before it is published: every address has its function and its line in interface.md, the migrations run in order on an empty database, every table in forms.json exists. Publishing holds the line itself: an address a release adds that interface.md does not describe, or a route to a function that is not live, stops the release. Like every file, all of it is a draft until published, and a drafted back end already answers inside the preview, on a throwaway copy of the data.

  • 🧩 Any front end. HTML with {{ }} templates, plus CSS, JavaScript, JSX and TypeScript transpiled on the fly. React, Vue or Three.js load through an import map. A site built with Vite, Next or anything else comes in as it is.

  • 📱 One back end for mini programs and apps. A client without cookies logs in with a token and calls the same addresses as the pages. Whatever an address the back end answers looks like (/session/me, /graphql, /v2/orders/12), a program may call it: the shield goes by whether a route answers there, not by the shape of the address.

  • ⚡ Live connections too. A front end that opens an EventSource gets a stream route; one that opens a WebSocket gets a socket route: each message that comes in runs a function, and signal(…) reaches everyone connected, or only the members it is for. Events can carry the name the front end listens for.

  • 🌐 A back end's host written into the front end is answered too. Built front ends often have https://api.example.com in their code. Name it under hosts in _server/server.json: scripts go out with that address pointing at this system, whose routes answer; the stored files stay byte for byte, and leave as they came.

  • 📎 Any kind of file. files.save(file) in a function keeps pictures and PDFs as the media library does, and spreadsheets, archives, sound and video as they came; all but pictures, sound and video go back out as downloads only.

  • 👤 Accounts and permissions, no code. The system does member sign-up, sign-in and sessions; who may enter a surface is one condition ("members", or member.kind == 'teacher'). The system guards the door, so pages never check for themselves.

  • ⚙️ Server functions. Besides the routes of _server/, a file under a _fn folder is a function at its own address (_fn/order.js answers at /_fn/order). A function runs in a sandbox with no files, no network but the services an admin registered, and caps on time and memory. One run is one transaction: if it fails, nothing it wrote is kept. Functions share code by importing each other's files and can be called on a timer (release unpaid stock, close the month).

  • 🗃️ Collections, records and rules. Next to the tables a back end makes, a system can still keep content as collections of records with typed fields, drafts, history, record pages, full-text search and access rules (record.owner == member.id or member.kind == 'teacher'), read from pages, functions and the content API.

  • 📡 Pages that follow the data. A page asks what changed since it last looked (/changes?after=…) or keeps a stream open, under the same read rule as its lists. A change made on an old version is refused (409) instead of overwriting someone else's.

  • 🔑 Other services, with their keys held back. In Settings → Outside services an admin registers a payment, text-message, map or AI service. Functions call it by name with services.call("sms", "/send", {json}): the server puts the key on the request itself and takes it out of whatever comes back. A key is kept encrypted and never shown again.

  • 🔔 Word reaches your group. In Settings → Notifications, paste the address of a group robot or a push service: Feishu (Lark), WeCom, DingTalk, Slack, Discord, Telegram, Teams, Google Chat, Bark, ntfy, ServerChan or PushPlus, or an address of your own. A message goes out when someone submits something, changes are published or a member signs up, and a function sends its own with notify("…").

  • 🖼️ Photos need no preparing. An uploaded photo is stored upright, without where and when it was taken, with its long edge at 2560 at most, and compressed. In a page, {{ img(item.cover, alt=item.title) }} writes the whole tag: smaller copies at every width, its size, lazy loading.

  • 🔎 Full-text search. search("query") in a page, GET /api/v1/search and a search tool. Chinese works without a dictionary, and visitors only ever find what they may open.

  • 🛡️ Protection built in, nothing to set. Every page and endpoint is behind one door: rate limits by address and by network, vulnerability scanners shut out, no pages for crawlers that collect in bulk to train AI models (search engines and AI assistants reading a page for someone pass; /llms.txt lists the pages for them), an in-browser check for clients that read page after page, requests shaped like an attack refused, and deadlines for slow connections, with no outside service. It has no switch in the admin: neither the chat, an API key nor an admin account can change it. Operations shows the server (requests, response times, memory, disk), every surface, and what was stopped and from which address, live.

  • 📦 Taken out, it lives on. cms-harness take-out <system> writes the system's pages as visitors get them, its data (app.db, its collections as JSON), its people (people.json, with their Argon2 password hashes so they keep signing in), an INTERFACE.md of every address its pages call (the ones only the harness answered marked as needing a replacement) and a README, and nothing of the harness: no back-office accounts, no keys. Give it a back end of your own that answers the interface, and it runs without the harness.

🎨 The preview is a canvas

Edit the running page as you would in Figma. What you change is written back into the page files, not painted over them.

In the preview a heading is selected and restyled, resized and dragged, text is typed right on the page, the pen puts a picture where the click was, the width switches to phone and the page keeps its own phone layout, and one change is undone from the list of changes.

✏️ Click anything to restyle it ↔️ Drag and resize ✍️ Write in place
A small bar for what is reached for most, a style panel for all of it: size, spacing, type, gradient, border, shadow, rotation Snaps to its neighbours, arrow keys nudge, Cmd/Ctrl+Z undoes Click twice and type, Enter starts the next paragraph, the words go back into their file
🖌️ A pen to add things 📱 Three widths, laid out apart ↩️ Every edit undoable
Headings, shapes, cards, pictures, columns, a piece of code: click to place, or drag to size Desktop, tablet, phone: change one and leave the others Every hand edit listed in words, each undone on its own, days later too

You and the AI, together: pick a few elements and tell the chat "make these dark": it knows which ones you mean. It keeps your hand edits through its rewrites; a rewrite that would lose one waits for your yes.

Open: everything the canvas does
  • ✏️ Click anything to change it. The element under the pointer is outlined; a click selects it, and a small bar sets size, weight, colours, alignment and a few ready-made looks. Drag, resize, copy, delete; elements snap to their neighbours (hold Alt not to), arrow keys nudge, Cmd/Ctrl+Z undoes. A right click opens a menu of everything that can be done with it.
  • 🎛️ A style panel for all of it. The sliders button in the bar opens a panel beside the preview: position and size, rotation, opacity, the room in and around the element, typeface and weight, line height and letter spacing, background and gradient, the border's width, style and colour, corners, shadow, blur. Numbers are typed or stepped with the arrow keys. At its top is what the element is inside: one click selects the block around it.
  • 🖌️ Add anything. The plus at the bottom right opens what there is to add: a heading, a subheading, text, a quote, a list, a link; a rectangle, a circle, a triangle, a star, a line, a button, a card; a picture uploaded now or taken from the library; a piece of code (the embed code of a video or a map, or HTML and SVG of your own); and a section, two or three columns, a divider, space. Choose one and click the page to place it, or drag to draw it at the size you want; what belongs to the layout goes after the block you click, in the flow of the page.
  • ✂️ Pictures are worked on where they stand. Double-click a picture (or right-click it) to crop it: freely or to 1:1, 4:3, 16:9 and the like, turn it, flip it, adjust brightness, contrast and saturation. The result is stored as a new picture in its place; the original stays in the library. The panel also says how a picture fills its box, which part is kept, greyscale and blur, and what it says to someone who cannot see it.
  • 📱 Desktop, tablet and phone apart. Any change can be made for one width only, leaving the others as they are.
  • ✍️ Write in place. Click a piece of text, click again and type; Enter starts the next paragraph. The words are saved in the file they are written in.
  • 🖼️ Pictures in place. Drag or paste a picture into the preview: it is uploaded, put where it was dropped, then moved and sized with the handles. Dropped on a picture, it takes that picture's place.
  • ➕ A new page already in the site's look. Press + in the preview's address bar (or say so): the page is made with the frame the surface's home page stands in, its header, navigation, footer, fonts and colours, with an empty middle to fill.
  • 📄 One record, its own layout. A record's page can be laid out for that record alone (layout_record), the rest of its kind untouched.
  • 🎯 Point, then say. Pick a few elements in the preview and tell the chat "make these dark": it knows which ones you mean.
  • 🧭 Navigation as a list. Navigation in the toolbar shows the menu as lines of a name and where it goes: rename, point elsewhere, move up or down, remove, add one.
  • 💾 Hand edits are drafts, each undoable. Until publish, the pencil in the toolbar lists every hand edit in words, and any single one can be undone, days later too. At publish it is written into the page file it belongs to, and a system taken out keeps it.
  • ✨ Ask right at the element. Select something and press the sparkle in its bar (or right-click → Ask AI): the bar becomes one line to write on. Type "make it dark, a little larger", press Enter, and the AI changes that element.
  • 🤝 The AI knows what you did. It sees your hand edits and carries them through its rewrites. A rewrite that would lose one is refused until you agree.
  • ⚠️ It warns, it doesn't guess. Hand-edited elements that end up off screen, on top of other content or with text under 12 px are counted in the toolbar, with a jump to each.

🏠 Systems and surfaces

One program for every web system you run. A public website, a staff tool, a school's homework app: each one a system, none sharing data; and each system split into surfaces by who uses it.

The harness is the one program you deploy, with one back office and one AI on top; inside are three systems: site (the public website), Shop staff (the shop's own tool) and Homework (a school's homework app), each with its own database, back end and people, sharing no data; under each hang its own surfaces: website, shop, students and teachers.

Word What it is For example
harness The one program you deploy: one back office, one AI, over every system The one on the company's server
system A body of data with its own back end and its own people The website, the shop's staff tool, a homework app
surface (端) One front end of a system: its pages for one kind of user The homework app's student and teacher surfaces

The name beside the logo switches from the bakery to Shop staff: the whole sidebar changes, and the shop surface, the orders table, the staff and their roles are all its own; then back to the website.

Open: every rule of systems and surfaces
  • 🏠 Systems never share data. Each has its own database, its own uploads, its own surfaces and its own people. The harness keeps only a small ledger of its own beside them: the back office's admins, keys, model settings, the list of systems. Every environment starts with the system site; the top account makes more by asking the chat ("make a separate system for the staff"). The name beside the logo switches between them, and the whole sidebar follows: that system's surfaces, its data, its people.
  • 🧩 A surface for each kind of user. A system's first surface may be its website (in system site, at /); more come as the people using it need them: /teacher/, /student/, or each on its own subdomain (teacher.example.com). Each has its own pages and its own rule for who may enter.
  • 👥 One list of people per system. In a system made new, each person has one account with their roles. The roles, what the people page is called and what the roles are called are set once, on the system (set_people); a surface only decides who may enter (enter, such as members or member.tag containing "warehouse"). The People page (named as you name it: Staff, Students) is where an admin makes an account, picks roles with a click, replaces a password, turns an account off or deletes it for good (it cannot be brought back; what it owns stays). The assistant in the chat can ask for the same, never do it by itself: what it would do becomes a card that says in plain words what is done to whom, and it is done when you press yes.
  • 🤖 Every member's own assistant. A surface can give each person who signs in to it an AI assistant of their own, inside the surface: it can call only that surface's published functions, as that person, so what a function refuses them it refuses their assistant; a change waits for that person's own approval. It is the surface's, not the back office's: its own model, its own conversations. A member can also connect it to their WeChat by scanning a code.
  • 🧭 The sidebar's foot says what is whose. Above the rule, what the system shown runs on: its people, media, releases and timers. Below it, what the whole server runs on: operations and settings.
  • 🔀 Systems are made, moved and deleted on the top account's own words. create_system, move_end (a surface with its people and the content only it uses moves into another system, at the same address) and delete_system (a backup is taken first) are the top account's alone. The chat deletes or moves only when the admin said so in that very request, naming the system or the surface.

🎛️ A back office that bends

The back office isn't fixed. Every table gets a page; whatever doesn't suit you, tell the back office's AI and it changes. Every change is a draft until you say yes.

The Breads table has a page of its own: sorted by price, searched; a row edited by hand goes live at once; the change is listed below it and taken back with a click.

You say It does
"Add a tracking-number column to orders" Adds the column; the list and the form follow, once published
"Put the ones waiting to ship first" Changes the table's order
"Make a screen that only shows stock" A new screen: which columns, how to filter, what may be done
"Mark every order waiting to ship as shipped" Changes the data in bulk, as drafts for you to look at
"Every morning at 8, sum up yesterday's orders as a notice" Does it by itself at 8, then waits for your yes
  • 🛡️ Live only with your yes. Every change shown old against new, uncheck what you don't want; every release kept and undone in one step.
  • 👑 One role managing the next. Top admin, admins and editors each look after their own, and their AI assistants are held to the same.
  • 💬 Run it from anywhere. The back office's chat, WeChat and other chat apps, or your own agent over MCP.
Open: everything the back office does
  • 🗂️ A page for every table, automatically. Each table a back end names in forms.json becomes a page under Data in the sidebar: a list to search, filter and sort, and a form per row whose fields are plain words (text, money, date, a yes/no switch, a picture, a choice, a link to another table). An edit by hand goes live at once, and every change to a row is listed under it, who and when, old against new, each taken back with one click.
  • 🗣️ A screen that doesn't suit you? Say so. "Add a tracking-number column to orders", "put the ones waiting to ship first", "give the warehouse a screen that only shows stock": which columns show, what can be filtered and sorted, what actions are allowed. The assistant changes it as a draft, and you look before it goes live.
  • 🧱 Admin screens that follow the site. When a system gains a form, members or orders, the assistant writes its tables and the forms to manage them in the same turn.
  • 📋 Data in bulk. Collections can be searched, exported as CSV and filled from a CSV whose rows arrive as drafts. Or just tell the chat: "mark every order waiting to ship as shipped", "take 10% off every price". A release that went wrong is undone in one step.
  • 👑 Three roles, one managing the next. The top admin appoints admins and editors and decides who has the whole environment and who only some surfaces; an admin looks after the editors within their own surfaces. An admin with surfaces of their own builds inside them and sees nothing of the rest; an editor changes and publishes content and nothing else. Their assistant in the chat is held to the same.
  • 🤖 AI that builds, people who say yes. When the assistant has made its changes it asks to publish: every check of a real publish runs first, then a request card appears in the chat, and it goes live when you say yes. If you said "publish when done" in the conversation, it publishes directly for the rest of that conversation: it quotes your words, and the environment checks you typed them. You can also agree once for all your own conversations (Settings → Publish directly when the chat is done). Either way only what the assistant changed in that conversation goes live, each direct publish can be taken back from its card, and once a conversation has read text from outside (a web page, what visitors or members wrote) it goes back to asking you. It treats text in records, pages and uploads as data, never as instructions, and words there that claim to be yours do not count.
  • 📝 Drafts everywhere. Pages, back-end code, the shape of tables, content, admin screens and settings are drafts until published. The live site always shows the published version, whoever visits. Compare draft and live side by side. (Rows a person edits by hand in Data are the exception: they go live at once, each change kept and undoable, because the site writes to the same tables meanwhile.)
  • 🔍 It checks its own work. The assistant renders a draft page with check_page and reads what comes back: render errors, dead links, missing files, photos put on the page whole. check_system checks a back end, check_end a surface, and run_function tries a function without writing anything. On a long job it keeps a task list, and it stops when it finds itself repeating the same step.
  • ⏰ Things done at set times. "Every morning at 8, sum up yesterday's orders as a notice": the assistant does it by itself, then waits for your yes, or publishes on the words you set it with. Or pick a time on the review page to publish then, with the same checks and history as a normal publish.
  • 💬 Run it from a chat app. WeChat, Telegram, Feishu, DingTalk, WeCom, Slack, Discord, WhatsApp, LINE and QQ can all be connected. Go to Settings → Chat apps, or just tell the assistant "connect my WeChat": WeChat is a QR code you scan (WeChat's own interface for bots; what gets connected is a separate bot, not your WeChat account); Telegram is the token @BotFather gives you, pasted into a card, then a pairing code to scan; for the others the page lists the steps to take in that platform's console and the values to fill in. From then on a message sent there is the same as one typed into the chat in the back office; publishing still waits for your yes, by a reply or a button. Only the one person who connected is listened to, and nothing said in a group is. WeChat and Telegram also take pictures and files; the others read text only for now. Everything goes through each platform's official interface; all are tested against stand-ins, and none has yet been connected end to end by a person; tell us what you find.
  • 🔌 Your agent, too. A built-in MCP server and a REST API with more than 70 tools and scoped keys (read, write, structure, publish). Every tool takes a system to work in.

✨ And more

A real website

  • 🔗 A page for every record, automatically. Write one detail template and every record of a collection gets its own page at a clean address (/news/drum-contest; Chinese titles stay Chinese). Change a slug and the old address redirects forever, and a publish that would leave a dead link is stopped.
  • 🌏 Any number of languages. One record, many languages: text is translated; images, dates and prices are shared. Each language gets its own addresses (/en/… or its own domain), fallbacks, hreflang, and localized dates and money.
  • ⚡ Dynamic, at static speed. Live pages are cached, and a publish recomputes exactly the pages it touched. cms-harness export writes a system's whole site as static files for any CDN. Pages and API reads have database connections of their own and do not wait for writes.
  • 🗺️ SEO basics, done. sitemap.xml and robots.txt follow every publish, in every language.

An AI that is easy to use

  • 🧠 Any model. Claude, OpenAI, Gemini, DeepSeek, Qwen, Kimi, GLM, Doubao, SiliconFlow, Mistral, xAI, Groq, OpenRouter, a local Ollama or LM Studio, or any OpenAI-compatible API. Paste a key and it lists the models you can use. Or no key at all: sign in with your ChatGPT account and the chat runs on the usage your ChatGPT plan already includes, through OpenAI's sign-in for open-source apps. On your own computer the sign-in comes back by itself; for a server elsewhere you paste the address the browser stops at. The sign-in is kept in <HC_DATA>/chatgpt.json, readable by the server's user only, never in the database or a backup. A Claude subscription works too, through the Claude Code installed on the server: sign in there once with claude auth login (Anthropic's own sign-in; on a server with no browser, claude setup-token and CLAUDE_CODE_OAUTH_TOKEN), pick Claude (the Claude Code signed in on this server), and the chat runs through that program on your plan's limits, with the environment's own prompt and tools. The environment never signs you in to Claude itself and never sees the token: Anthropic's terms do not allow another app to do that.
  • 📎 Hand it files. Pictures, PDFs, Word, Excel, PowerPoint, text files and zips: drag them into the chat, paste them or pick them. "Build a products table from this price list", "put this picture on the home page": it reads what is inside. A PDF goes to a model that reads PDFs as it is, and otherwise the text is taken out of it, as it is out of Word, Excel and PowerPoint files, text files and zip archives. What cannot be read is said so, to you and to the model.
  • 🌍 Web search for the chat (off by default). web_search and fetch_page through a self-hosted SearXNG, Brave or Tavily, with any model. Pages come back as material, never instructions, and private or local addresses are refused at every redirect.
  • 📚 Skills. Install a skill folder (with a SKILL.md) from GitHub or a zip. The chat reads it when the task needs it.

Manage it and run it

  • 💾 Backup and restore. The whole environment (the ledger, every system's databases and uploads) as one zip, or one system alone, from Settings → Backup or cms-harness backup. A restore checks the archive and keeps what it replaces first. In the back office, backing up and restoring are the top account's alone.
  • ⬆️ Upgrades by one press. A newer version is tried first on a copy of your data, then switched to; the version before stays, to switch back.
  • 🗄️ SQLite. Plain files, no database server to run: the ledger, and for each system its database and its own data.
  • 🈶 Chinese and English. The admin switches in Settings, and the chat replies in the admin's language.
The admin: the chat on the left lists every change it made, the preview on the right shows the draft, and the Publish button counts pending changes. Publish review: every pending change, each with its own checkbox.
Chat on the left, the draft on the right, changes marked. Review before publishing: every change, and you uncheck what you don't want.

🔌 Connect your agent

Create a key with cms-harness key <name> [write] [structure] [publish], then add the server to any MCP client that speaks HTTP:

{
  "mcpServers": {
    "cms-harness": {
      "type": "http",
      "url": "http://127.0.0.1:4200/mcp",
      "headers": { "Authorization": "Bearer hc_..." }
    }
  }
}

Leave publish off the key and your agent can build all day while the live site stays exactly as it is.

Or use REST: GET /api/v1/tools lists the tools this key can call with their parameters. POST /api/v1/tools/<name> calls one.

Every tool about a system takes system (list_systems lists them); left out, it is site. Making, moving and deleting systems is the top account's alone, so a key cannot do it.

🔧 Under the hood

  • About 56,000 lines of Rust: axum, SQLite (bundled, with full-text search), minijinja for templates, oxc to transpile JSX and TypeScript, and QuickJS (through rquickjs) to run server functions and back ends.
  • More than 1,200 tests, run with clippy on every push to main.
  • Answers are gzipped for a client that takes them.
  • The admin is server-rendered HTML with plain JavaScript and a strict Content-Security-Policy. There is no front-end build.
  • Passwords are hashed with Argon2id. The details are in SECURITY.md.

📖 Reference

Command line
Command What it does
cms-harness start the server
cms-harness admin <email> [admin|editor] create an admin or an editor, or reset their password. The first account an environment gets is its top admin
cms-harness key <name> [write] [structure] [publish] create an API key (shown once)
cms-harness admin-origin <address|off> give the admin its own address; off puts it back with the site
cms-harness backup [file.zip] [system] the whole environment (the ledger, every system's databases and uploads) as one zip; with a system named, that system alone
cms-harness restore <file.zip> [system] replace the environment, or the one system named, with a backup (stop the server first)
cms-harness export <dir> [system] write a system's live site (site when none is named) as static files (set HC_ORIGIN to where they will be served)
cms-harness take-out <system> [dir] take a system out to live on its own: its pages as visitors get them, its data (app.db, collections), its people, INTERFACE.md and a README; nothing of the harness
cms-harness version print the version running here

The back office has three roles, each managing the next. The top admin (the account that made the environment) may do anything, and alone backs up, restores, appoints admins and makes, moves and deletes systems. An admin changes pages, functions, structure and content, sees operations and timers, and manages editors; one who has the whole environment also has its settings (keys, the model, skills, where notifications go, which outside services functions may call) and the upgrade. An editor writes and publishes content, and nothing else.

Accounts with surfaces of their own. The top admin can give an admin or an editor the surfaces they manage, and an admin can do so for the editors they look after, with surfaces they have themselves. Such an account sees, in the back office, only the systems holding those surfaces, and in them only those surfaces and the content their pages use. An admin with surfaces builds inside them: the pages, templates and server functions in those surfaces' folders, the collections and screens they use, the surfaces' own settings and people, and the editors of those surfaces; they see the timers and the operations of their surfaces, and not the server's. This is what the back office shows and offers an admin, not a wall around data: a template or a function can read any collection, and making someone an admin is trusting them. The wall is the editor's role: an editor with surfaces changes and publishes the records those surfaces use, writes no template, function or structure, and is not told that anything else exists (asked about something outside, the answer is word for word the one for something that is not there). Their assistant in the chat is held to the same. An account that was given no surfaces has the whole environment.

The database: SQLite
  • SQLite, and nothing else: nothing to set. In the data folder, ledger.db is the harness's own (admins, keys, settings, the list of systems); each system has systems/<name>/data.db (its pages, accounts, collections, history, search) and, once its back end has tables, systems/<name>/app.db (those tables alone: what leaves with a system taken out). Uploads are under uploads/ for system site and systems/<name>/uploads/ for the others. A data folder from before systems (one harness.db) is split into these at its first start, after a backup of it. One server uses a data folder: a second one started on it stops and says another is using it. The commands (backup, admin, key, …) work beside a running server.

What a record costs. A live record is stored as its document and, unless its collection sets history: false or search: false, also as a version in history and an entry in the full-text index. Small records written one at a time came to about 1.4 KB each on SQLite. Deleting records does not make a SQLite file smaller: SQLite keeps the space for what is written next, and history keeps what was deleted.

Reads and writes. Pages and API reads have database connections of their own (HC_READERS) and do not wait for a write; writes, function runs among them, take turns on one connection per system, so one busy system never makes another wait. A SQLite file has one writer at a time, and a write waits up to 5 seconds for another process that is writing to it.

Website pages

A fresh system site has one built-in page: a welcome with the site's name and a link to the admin. Every other page comes from site files that the assistant (or your agent) writes:

  • HTML with templates: collection("news", limit=10, sort="-date"), count("news", filter={...}) for page numbers (collection() returns at most 100 at a time), record("news", 3), search(request.query.q, limit=20) (each hit has _collection and _snippet), img(item.cover, alt=item.title) for a whole image tag, the signed-in member (with its attributes), site.name.
  • CSS, JavaScript, and JSX / TypeScript / TSX, which are transpiled when served.
  • Libraries from https://esm.sh through an import map (set_site_settings), so no bundler is needed. A site built elsewhere can be uploaded in one piece (upload_site_bundle), or a whole project brought into a surface as it is (wrap_project, below).

The live site always shows the published version, whatever cookies or headers a visitor sends. Drafts only appear in the admin's preview.

Record pages. A collection visitors may read gets a page per record once the site has a detail template: <collection>/_item.html, or _item.html for every collection. The template reads the record as item. Addresses come from the collection's url pattern, /{collection}/{slug} by default; {id}, a field ({year}) or a relation's slug (/products/{category.slug}/{slug}) work too. Each record gets its slug from its title when it is created and keeps it when the title changes. A new slug is a draft; once live, the old address keeps redirecting. Link to records with item.url (or /_r/<id>): links pasted into rich text are stored that way automatically and always render at the record's current address.

Languages. Set the site's languages in Settings → Site languages (or set_site_settings with languages); the first is the default. Other languages live under /<code>/ or on their own domain, and may fall back to others. Text and rich text fields are translated (translate: false keeps one shared); a collection with untranslated: "hide" leaves untranslated records out of other languages. Translations are written with set_translation or in the record editor, kept in the record as drafts, and translation_status lists what is missing or out of date. Templates get lang, dir, languages (this page in every language, for a switcher) and suggested_lang; {{ "…"|t }} reads the site's string table; |date, |number and |money("EUR") format per language. A link a template writes as /about leads to /en/about on an English page. hreflang links and a multilingual sitemap are added for you.

Images. An uploaded JPEG, PNG or WebP is worked on before it is stored: turned upright by its EXIF and stored without it (place, time, device), shrunk when its long edge is over 2560, and a JPEG compressed again (when that saves a fifth, or when it has to be re-made anyway). A large PNG with no transparency becomes a JPEG when that is under two fifths of its size. See-through pictures, small PNGs, GIFs and PDFs are kept as they came. /uploads/<name>?w=640 serves a copy no wider than one of five widths (384, 640, 828, 1200, 1920), made once and kept; PNG stays PNG, JPEG and WebP become JPEG, and nothing is enlarged. In a template, {{ img(item.cover, alt=item.title, sizes="50vw", class="cover") }} writes the whole <img>: every width below the picture's own in srcset, its real size, and loading="lazy"; give the first picture a visitor sees eager=true. Where only an address is needed, use |thumb(640).

Cache and export. Live pages for visitors who are not signed in are cached until something they read is published again (the x-cms-cache header says hit or miss). cms-harness export <dir> [system] writes every public page of a system, record pages included, plus site files, uploads, sitemap.xml, robots.txt and 404.html; set HC_ORIGIN to the address the files will be served from. Forms and sign-in still need the server; the command lists the pages that use them.

/sitemap.xml lists the published pages (not layouts or fragments that other files extend or include, nor names starting with _), each with the date it last went live, and /robots.txt points to it. Both follow every publish. A site file with the same name replaces them.

A system's own back end

A system's back end lives among its site files, under _server/, drafted, published, versioned and restored like any other file. It works on the system's own database, app.db, which holds nothing but the tables its migrations make and the rows its functions write.

  • _server/routes.json: the addresses the front end calls, each to a function in _server/_fn/: [{"method": "GET", "path": "/api/products/:id", "fn": "products"}]. A segment :name is a parameter (req.params.name); a last segment * takes the rest (req.params["*"]). A route may use any address the front end uses, but none of the harness's own (the back office, /_hc, /mcp) or another system's surfaces. 500 routes at most. A route may also:
    • carry "time_ms": 5000: how long its function may run (500 ms unless said, 30000 at most), for a report or an import that was always slow.
    • be a stream: {"path": "/api/live", "stream": "orders"}. A function sends signal("orders", data, {event, id, to}), which goes out once its run is kept; event names the event (what the front end's addEventListener("note", …) listens for), id numbers it, to is a member's id or several: only connections that are theirs get it. Whose a connection is, its sign-in says: a cookie, or ?token= in the address.
    • be a WebSocket: {"path": "/ws", "socket": "chat", "fn": "chat"}. Each message that comes in runs fn (req.method is "MESSAGE", req.body what was sent, JSON read as JSON; cookies and headers are those the connection was opened with), and what the function returns goes back to the one who sent it; signal("chat", data) goes to everyone connected. Without fn it only pushes. A message is 64 KB at most, a connection sends 20 a second at most, and a page of another site cannot open it.
  • _server/server.json: the back end's own settings. {"max_body_mb": 100} is the largest request it takes (20 unless said, 512 at most); {"hosts": ["https://api.example.com"]} names other servers the front end's code was written for, which this system answers in their place: scripts, the scripts a page writes into itself and .json files go out with addresses that begin with one cut down to what follows it, so the browser asks here. What is stored does not change.
  • _server/migrations/<NNN>-<what>.sql: the shape of app.db, applied in the order of their names, each once, by the publish that puts it live, on the data as it is. Migrations go live with their release or not at all: when the data cannot take one (a unique index over values that repeat, say), the whole publish is stopped and the tables, the data and the live code are as they were; when it can, the system's own data is copied aside first (into backups/ in the data folder), then the tables change, then the code. The publish review says what each migration will do in plain words ("Table orders gets the columns sku", "Drops table notes: its 2 rows of data go with it") and marks the one that loses data in red; the result of publish says the same. A migration that was applied is not to be changed: it would not run again, a publish says so, and the new change goes in a new migration. Undoing a release takes back its files only: the tables it made, the columns it added and the data in them stay. A migration may not write BEGIN or COMMIT itself, nor attach another database.
  • _server/_fn/<name>.js: a server function like any other (below), with sql("SELECT …", [params]) (the rows), sql.one(…) (the first row or null) and sql.run("INSERT …", [params]) over its own system's app.db and nothing else. One statement at a time, reading and changing rows only: no attaching another file, no pragmas, and a table's shape is changed by a migration, not by a function. At most 1,000 rows come back at once.
  • _server/interface.md: what the front end may call, address by address: method, what it takes, what it answers, who may call it. It leaves with a system taken out, for whoever gives it a back end of their own, so the addresses a release adds must be in it: otherwise the publish is stopped and names the ones missing.
  • _server/forms.json: how the back office shows each table: [{"table": "products", "title": "Products", "title_column": "name", "order": "id desc", "fields": [{"column": "name", "label": "Name", "kind": "text"}]}]. A field's kind is text, long_text, number, money, date, datetime, yes_no, picture, file, choice (with options) or link (with to, another table of the same system). A field may also say "readonly": true (shown in the back office, never changed there by hand: a column the system works out itself) and "required": true (a row is not saved by hand without it); a table may say "list": ["name", "price"], the columns its list shows and in what order. Only these keys are known, and another is refused when written, not passed over. A column no field names is not shown; a table no form names is not in the back office.

Trying it. A drafted back end answers inside the preview: the preview's pages call its routes as trials on a throwaway copy of the system's data, so a draft writes nothing live. A stream or a socket the page opens (new EventSource, new WebSocket) connects to the drafted route there too, and hears what the preview's own requests signal, so live updates are seen working before a publish; no visitor's connection hears a trial. run_function asks once as a visitor would: the address of a route (/api/notes/3) with a method, a body, cookies, headers, files, as some member; what comes back is the status, the headers and the body the visitor would get. try_requests tries several as one visit (sign up, sign in, write with that sign-in, read it back, delete it): a later step takes a value from an earlier answer with ${1.body.id}, a cookie one step sets goes with the next, and all of it is undone at the end. app_data lists the tables, their columns and rows and runs a read-only query, over the live data or, with drafted: true, over a throwaway copy with the drafted migrations done on it (a table a draft makes is not in the live data until a publish); check_system checks the whole back end before a publish (every route has its function and its line in interface.md, the migrations run in order on an empty database, every table in forms.json is made by them).

Editing rows. Each table in forms.json is a page under Data. A change by hand goes live at once; who, when, and the row before and after are kept, and the row's page takes any change back with one click (a change made since on the same row stays). app_rows does the same for the AI and for agents: list, get, add, change, delete, history, undo. Many rows at once are change_many (values gives the rows picked the same values, compute works a column out from each row's own: {"price": "round(price * 0.9, 2)"}) and delete_many, picked by filter and search, a thousand at a time at most, all of them or none; each row's change is kept as ever, and undo with change_ids takes them back together.

Taking a front end in. In the back office's chat, attach the zip and say so: the assistant names the attachment and the environment hands the zip itself to wrap_project, so every file comes in byte for byte (the model never retypes one). wrap_project brings a project's zip into a surface: it finds the folder that is served (dist, build, out), moves the addresses of the project's own files written from the root under the surface's address, and moves script written into pages into files; the addresses its scripts call their back end at are left as they are. read_front_end then lists every call the pages make (fetch, axios, XMLHttpRequest, EventSource, forms), each with its method, which files make it and the code around it, and the AI writes the routes that answer them. check_end reports what a surface still lacks to work as it did.

Run it, then check again. Reading code for addresses always misses some: a packed bundle, an address put together as the page runs. So there is a second layer that watches it run: open the front end in the admin's preview, click through it and do what can be done, and every call the pages really make (fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon, forms, those to other servers too) is kept, the many calls of one endpoint as one (/api/orders/:id). read_front_end lists them under seen, each with whether the drafts answer it now; check_end puts the ones nothing answers among its problems, and does not pass while there is one. When nobody has opened the preview yet (seen is 0), check_end says outright that its pass comes from reading the code alone. What was seen is kept in memory (after a restart, click through again); a new front end clears it, and forget_seen: true does so by hand.

Taking a system out. cms-harness take-out <system> [dir] writes its published pages as visitors get them, the other site files and uploads, data/app.db (the system's own tables and rows, without the harness's record of migrations), data/collections/ (each collection's definition and live records), data/people.json (the system's accounts, tags and Argon2id password hashes), INTERFACE.md (what the pages actually call, merged with routes.json and _server/interface.md; every call to /api/v1/…, /account/…, /_fn/… or /_hc/… marked as a harness service that needs a replacement, with what it did) and a README.md. Nothing of the ledger, no back-office accounts, no sessions, no keys, no function code.

Editing by hand

In the draft preview, select an element with a click on something that does nothing, a long press or a right-click (which also opens a menu). The bar above it sets size, weight, slant, underline, colours, alignment and a style preset, for all widths or only the current one. It also selects the block around the element, duplicates it and deletes it. The sliders button opens the style panel, which has all of how it looks: position and size, rotation, opacity, padding and margins, gap, typeface, weight, size, line height, letter spacing, alignment, colour, background, gradient, border, corners, shadow, blur, clipping, and moving it a layer up or down, earlier or later, or hiding it at this width. Every value is one of a fixed range (the server checks each), and is written into the page's file at publish with the other hand edits.

  • Selecting. Shift+Enter selects the block around the element, Enter goes into a block (or starts typing in a text), Tab and Shift+Tab go to the element beside it. Cmd/Ctrl+C then Cmd/Ctrl+V makes a copy, Cmd/Ctrl+] and [ move it a layer up or down.

  • Writing. A second click on selected text starts typing where it stands; Enter in a paragraph begins the next one. The words are saved in the file they are written in (a record's field, when they come from a record).

  • Move and resize. Drag an element to move it and pull its handles to resize it. Both snap to nearby elements; hold Alt to turn snapping off. Arrow keys nudge by 1 px, Shift+arrow by 10 px. Cmd/Ctrl+Z and Shift+Cmd/Ctrl+Z undo and redo. Delete removes the element and Cmd/Ctrl+D duplicates it.

  • Pictures. Drag or paste a picture into the preview: it is uploaded to the system's uploads, placed where it was dropped, and moved and sized with the handles. A selected picture can be replaced (by an upload or from the library), opened with a double click to be cropped (crop, turn, flip, brightness, contrast, saturation; the result is stored as a new picture), and given a fit, proportions, a focus, a filter and a description in the panel. A picture that comes from data (each record has its own) is not replaced here: change it in its record.

  • New pages. The + in the preview's address bar asks for a title and an address and makes the page in the frame the surface's home page stands in (head, header, navigation, footer, scripts) with an empty middle; new_page does the same for the AI.

  • Adding (the plus at the bottom right of the preview) opens what can be added: text of several kinds, shapes, a button, a card, a picture (uploaded or from the library), a piece of code, and layout (a section, two or three columns, a divider, space). Choose one, then click the page to place it or drag to size it; layout goes after the block you click, and a section goes between the page's own sections. Esc lets the tool go. A piece of code is written into the page's file as it is: only someone who may change pages can add one, and it is checked with the page at publish. On a record's own page what is added goes into that record's text, and only the kinds a text takes are offered.

  • Shared elements. An element in a template other pages use is marked Shared · N pages. Its edits can be limited to the current page.

  • Widths. Edits are saved for the width being looked at. The desktop preview is never narrower than 1024 px; a narrower pane shows it scaled down.

  • With the AI. get_site_file returns hand_edits, and file rewrites carry them along. A rewrite that would lose one is refused unless it passes replace_hand_edits: true.

At publish, hand edits are written into the page files they belong to (a stylesheet inside the file), so the published front end carries them by itself and a system taken out keeps them. Until then they are drafts, listed by the pencil in the toolbar and undone one by one.

Properties and values come from fixed lists, typed text is escaped so it can never become template code, and only uploaded files go into templates.

Server functions

A site file under a _fn folder (.js or .ts) is a server function. Its address is its path without the extension: _fn/order.js is /_fn/order, teacher/_fn/grade.js is /teacher/_fn/grade. Inside a surface's folder it belongs to that surface: a members-only surface only lets members call its functions. The source is never sent as a file.

A function under _server/_fn/ has no address of its own: the system's routes reach it (_server/routes.json), with the address's parameters in req.params, and nothing under _server/ is ever sent as a file. Every function of a system has sql(…) over the system's own tables (see A system's own back end); db.* below works on its collections.

export default function (req) {
  // req.method, req.path, req.query, req.body, req.member (null for a visitor),
  // req.headers, req.raw, req.ip, req.timer
  const mine = db.query("orders", { owner: req.member.id, limit: 100 });
  if (mine.total >= 3) return reply(409, { error: "three orders at most" });
  const id = db.create("orders", { item: req.body.item });
  return { id };
}
  • Data: db.query(collection, {filter, sort, limit, offset, search, owner}), db.get(collection, id), db.create(collection, data) (a third argument {owner: memberId} makes the records that member's, as if they had added them), db.update(collection, id, data) (a fourth argument {version}, the _version read, makes it fail instead of overwriting a change made since), db.delete(collection, id). Given a list, db.create writes many records at once (up to 500, one data call, all of them or none) and answers the list of their ids. The writing still counts against the run's half second, but 500 take only a few milliseconds on SQLite, so a run fits a few thousand. db.query answers {items, total, more}; with total: false it does not count and answers {items, more}, which on a large collection is much faster. They read and write live data. A write is live at once, passes the same field checks as any other, and is recorded in history under fn:<file>. A function is not bound by a collection's access rules: it decides who may do what.
  • Members: members.get(id) answers that member's id, email, name and attributes; members.set(id, {kind: "teacher"}) sets attributes (a null removes one). Who a member is (email, name, password) a function cannot change. Where accounts are handed out and visitors do not sign up (a company's staff screen) there is also members.create({email, password, name, every other key an attribute}) to make an account (a password of 6 characters or more; sign-up's ten an hour does not apply; nobody is signed in by it), members.setPassword(id, password) for someone who forgot theirs (wherever they were signed in ends), and members.setStatus(id, "disabled" or "active") to turn an account off and on again (off: they cannot log in and members.get does not find them). Who may make a function do this is still the function's to decide.
  • Totals: db.aggregate(collection, {filter, group_by, sum, avg, min, max}). Grouped, one answer lists 100 groups (group_limit up to 1000); group_total says how many there are, and group_offset asks for the next ones.
  • Notifications: notify("low stock: " + item) goes to the groups set in Settings → Notifications, five a run at most. A run that does not count (it failed, or it was a trial) sends nothing.
  • Answer: the return value, as JSON. For another status, reply(status, body).
  • Shared code: a file under _fn whose name, or a folder above it inside _fn, starts with _ (_fn/_lib.js, shop/_fn/_shared/money.js) is a module. It has no address; function files import it: import { yuan } from "./_lib.js". Imports are relative, with the extension, and only reach .js, .mjs and .ts files under a _fn folder (any surface's). A function brings in at most 30 files and 1 MB. Writing a function whose import is missing is refused, and it cannot be published without what it imports.
  • Outside services: services.call(name, path, {method, query, headers, json | form | body}) sends one request to a service registered in Settings → Outside services and answers {status, ok, headers, text, body} (body is the answer read as JSON). The path goes under the registered address and nowhere else; the key goes on as the service was registered (Authorization: Bearer, a header, an address parameter or Basic) and is taken out of the answer; redirects are not followed; 10 seconds (or timeout, up to 60) and 1 MB at most, 5 calls a run; a service registered as https://*.example.com is every host under that domain, a call naming its host, each in function_log. Waiting for the answer is not on the run's half second, and the run waits on a read-only connection, not holding up anyone's writes: so a run calls its services first and writes after, and once it has written it cannot call one. services.hmac(name, text, {hash, encoding, prefix, suffix, chain}) signs with the service's key (Alibaba Cloud's key&, AWS SigV4 and Tencent TC3's derived keys through prefix and chain), services.sign(name, text) makes an RSA signature with its private key (SHA256withRSA, base64; {padding: "pss"}), services.verify(name, text, signature) checks one made with the platform's public key (a key, or a certificate). A trial run sends nothing and signs nothing for real: services.call answers {status: 0, trial: true} and hmac/sign a stand-in, so a draft reaches nothing outside; try the real thing once it is published. At most half the read-only connections wait for services at once; a call beyond that fails at once as busy.
  • crypto: crypto.randomUUID(), crypto.random(n) (n random bytes as hex, 1 to 64), crypto.sha256(text), crypto.hmac(key, text) (HMAC-SHA256 as hex), crypto.equal(a, b) (compares two strings in constant time). Codes and tokens must come from crypto.random, not Math.random.
  • The request as it was sent: req.headers (lower-cased names; cookie, authorization and forwarding headers are left out), req.raw (the body as text, exactly as it arrived; req.body is the parsed value) and req.ip. Enough to verify a webhook: crypto.equal(req.headers["x-signature"] || "", "sha256=" + crypto.hmac(SECRET, req.raw)).
  • Timers: set_timer has the environment call a function by itself, every every_minutes, or daily at at ("03:00", with tz_offset_minutes). The function gets req.method "TIMER" and req.timer {name, due}, no member, and is not behind any surface's door; give it a module-style path (/_fn/_jobs/sweep) and nothing outside can call it. A long job works in slices: answer { again: true } and it is run again at once, up to 20 times a round. After the server was down a timer that was due runs once. Timers are drafts until published, and Timers at the foot of the sidebar lists them with their last run.
  • One run is one transaction: an exception, a cut-off, or an answer of 400 and up, and nothing it wrote is kept.
  • Limits: 500 ms (the SQL its data calls run counts; waiting for the writer before the run, or for a service, does not), 32 MB of memory, 200 data calls, a 64 KB request body. No files or processes, no network but services, and no setTimeout.
  • When it fails a visitor sees only that it failed; the reason is in function_log.
  • run_function tries a draft function without writing anything, by its own address or by the address of a route that leads to it, with headers and raw when it checks a signature, files for an upload, method: "MESSAGE" for a socket's message and timer: true to call it as a timer would. try_requests tries up to 12 in a row as one visit, and keeps none of it. A page in the admin's preview calling a function (GET) is a trial too.
  • A static export does not include functions, and they do not work there.
People, members and access rules

set_member_login turns a system's member accounts on. Its surfaces then have /account/signup, /account/login and /account/logout, and the /api/v1/members/* endpoints. Members cannot sign in to the back office. Where every account is handed out, set_member_signup closes sign-up by visitors: /account/signup and the sign-up call are gone, login stays.

One list of people per system. A system made new keeps one list of people for all its surfaces. set_people sets, once, on the system: the tags its people can carry (their roles: ["sales", "warehouse", "accounts"]), what the people page is called (title: Staff, Students) and what the tags are called there (tags_title: Roles). The page sits at the foot of the sidebar, above the rule, where an admin makes an account (an email, or a plain name for someone with no mailbox; a password of 6 characters or more), picks tags with a click, replaces a password and turns an account off. A surface keeps only its door (set_end's enter: members, or a condition on member.tag), whether visitors may sign up there, its look and its own assistant. A member's tags are kept in the attribute tag, joined by 、; the system's functions read req.member.tag and decide what each tag may do, and the kernel gives them no meaning. The tools behind the page are create_member, set_member_password and set_member_tags.

System site, and a surface moved out of it, keep a list per surface. There an account belongs to the surface it was made on, and its name only has to be unique there (the site and a shop may each have an admin); move_member, or Move to… on its People page, moves it to another surface. An account signs in from its surface's pages and is a visitor on any other surface, its pages, functions and content requests alike. Where the very same people use two surfaces (a members' area of the site, students and their parents), set_end's accounts lets one take the other's accounts; signup: true lets visitors make their own account on a surface. Collections stay shared by every surface of the system, and a rule keeps one to a surface's accounts with member.end == 'shop'. Each such surface has its own People page in its Setup folder, with the tags its people can carry given to set_end.

A surface's assistant. A surface can give each of its own members an assistant. The member talks to it inside the surface, and it can call only that surface's own published functions, as that member, through the door a page's request comes through: what a function refuses the person, it refuses their assistant. A read runs at once, as a trial that keeps nothing it writes. A change is first tried out by the environment (nothing is kept), then parked until that member approves it: only a request carrying their own session (or a reply from their own paired WeChat account) runs it, once. The model saying "approved" does nothing, and neither does text in a file. It is not the back office's assistant: settings, conversations and tools are each their own.

  • On and off: the surface's Setup → AI 助理 page in the sidebar. An admin fills in the model's address, key and name, and saving tries the three with one small request; all three empty is off. The key is typed there only, kept sealed, and never shown again.
  • Nothing has to be written for it: every published function of the surface with an address is the assistant's to call (not modules, not drafts). What it is told about a function is, by default, a description the surface's own model writes from the function's source: once for each version of the file, kept, written again when the file changes, made when first needed and never holding up a publish. While the model cannot be reached, the file's leading comment and first lines stand in. To say it better, write export const assistant = { read: "what a GET answers", change: "how to write the POST body, and what each action needs" } in the file, and that is used instead (null for a way not offered); to keep the assistant away from a function, export const assistant = false (an address another service calls, say). The surface as a whole may say what it is in <surface>/_fn/_assistant.js: export const about = "…". A wrong description makes the assistant clumsy, never more powerful. req.assistant is true in a call the assistant makes, and what its changes write is marked in its history as that member's assistant's. A read (GET) runs as a trial: whatever the function writes is not kept. In a trial services.call sends nothing and answers {status: 0, trial: true}.
  • The surface draws its own chat bar; the environment draws nothing: GET /api/v1/assistant answers { on, id, busy, messages, steps, streaming, error, pending } (404: this surface has no assistant; 401: not signed in); messages is what was said, each of the assistant's with html beside text (its Markdown made into the back office chat's safe few tags, for the page to style: it never parses Markdown), and steps the functions it called; POST /api/v1/assistant/say says something (a form with text and files, or JSON {"text": "…"}); new EventSource("/api/v1/assistant/events") sends the same state again whenever it changes; when pending is not null, show its summary and the call itself (function, every field of body; would is what the trial run answered), then POST /api/v1/assistant/approve/<id> or /decline/<id>; POST …/stop stops the turn and POST …/new starts over. A member's own chat app (their WeChat, say) is the surface's own business, written in its own functions with what any function has: waits.set(key, {service, path, host, method, query, headers, json, timeout, then, data}) keeps a request to an outside service going outside any run (up to 60 s each, until waits.stop(key)) and hands each answer to the function then (req.method "WAIT", req.wait {key, data, status, ok, body, text, error}), which moves it on with waits.set on the same key; ai.say(member, {conversation, text, files, then, data}) hands words to that member's assistant of the function's own surface, inside their rights, and runs then when the turn ends (req.method "ASSISTANT", req.turn {member, conversation, data, said, pending, error}); ai.decide(member, {conversation, yes, then}) approves or declines what waits for them, ai.stop and ai.reset stop or start over; a file is handed over as a service request the server makes before the turn ({name, service, path, host, query, decrypt: {alg: "aes-128-ecb", key}}), never through the run; secrets.get(name) / secrets.set(name, value) keep a token sealed; members.stamp(id) changes when the member's password does (null once they are turned off); qr.svg(text) draws a QR code. All of it is written in the run's own transaction: a run that fails sets up nothing. A function that approves for a member is trusted code, as every function is: let only that member's own account decide.
  • check_end reports assistant: how many functions the surface has, how many the assistant can use and how many keep it out, whether it has an about, whether its pages call /api/v1/assistant, and words for it that cannot be read.
  • Limits: 20 model calls and 30 function calls a turn, 60 turns an hour for each member, one change waiting at a time, for an hour; attachments as in the back office's chat (10 a message, 30 MB together). Conversations are kept in memory and gone at a restart (a change that was waiting has done nothing yet).

Under each surface the sidebar keeps a Setup folder (配置), after the surface's content and set off by a dashed rule and a gear: what the surface is set up with, as opposed to what it is for. In a system with a list per surface it holds that surface's People page (named as the surface names it: people_title, tags_title); in every system it holds every collection marked config: true: one with single: true is a sheet of settings (a shop's name, a switch, a threshold) and opens as the form itself; a list (warehouses, categories, delivery areas) is a plain table. Those pages are drawn by the admin from the collection's title and fields, without the tabs, search and CSV of content, a yes/no as a switch and a choice of a few as pills. The assistant is told to decide this itself while it builds: what an owner will want to change later goes into configuration the pages and functions read, not into the files as fixed text. A surface with nothing to set up has no folder.

Each collection sets:

  • who can read it (read): public, members, owner (each member sees their own), private (default: admin and keys only), or a condition such as record.open == true or record.owner == member.id. A condition is also the filter of every list: each reader's lists and totals hold only what they may see. Search is not filtered by it: a collection read by a condition is left out of search for every visitor and member (only an API key finds its records), and its records have no pages.
  • who can submit to it from the site (create): none (default), members, public, or a condition such as member.kind == 'student' and data.class == member.class. Submissions go live at once, record who sent them, and show as "N new" in the admin. Forms post to POST /<collection>/new; the API takes POST /api/v1/content/<collection>.
  • a rule may look past the record in hand (in the read, create, update and delete rules and in a surface's door): exists(memberships, it.member == member.id and it.org == record.org) is true when a live record of another collection meets the condition, which is how membership is asked; record.article.dept follows a single relation field to the record it points at; now and today are the time and the date (UTC), to compare with a date field; record.status in ['open', 'pending']. A rule may look elsewhere at most four times; a page read by the clock is not cached.
  • who can change (update) and remove (delete) a record from the site: none (default), owner (the member who added it), members, or a condition such as record.owner == member.id and data.status == record.status. A condition can use record.<field>, record.id, record.owner, member (logged in), member.id, member.email, member.name, data.<field> (what the record would become), == != < <= > >=, and or not and brackets. Changes and removals are live at once, and history keeps what the record was. A removal is refused while another live record points at the record or a live page links to it; an edit the admin had waiting for a removed record goes with it. The API takes PATCH and DELETE /api/v1/content/<collection>/<id>. Every record read carries _version (raised by one each time its live copy changes) and _updated_at (when it last changed). Send back the _version you read with a change (or as If-Match), and if someone changed the record meanwhile the answer is 409 instead of overwriting their change; without it, the last write wins.

Members can carry attributes (kind: teacher, class: 3). An admin sets them, in Members or with set_member_data; a member cannot. The system gives them no meaning: a rule reads member.kind, a surface's door can be member.kind == 'teacher', and pages and functions see them too.

Mini programs, phone and desktop apps have no cookies: send "session": "token" when logging in or signing up, and the answer carries a token to put in Authorization: Bearer <token> from then on. A login answer may also carry device: keep it and send it back as "device" with the next login, and that login is not held up when many others are guessing at the same email.

GET /api/v1/members/me says who is signed in: {"ok": true, "member": {…}}. With no cookie or token, or one that has expired or been ended, it still answers 200, with "member": null: check member, not the status. (While member login is off it answers 404.)

Members look after their own account, from a page's script or an app alike, with their cookie or token: POST /api/v1/members/logout ends this session; with {"everywhere": true} it ends every one they have (a lost phone, someone else's computer). POST /api/v1/members/password with {"password": the old one, "new_password": …} changes the password, 10 characters at least; wrong old passwords count with failed logins, and every session but this one ends.

A collection of a great many records nobody goes back to or searches (sensor readings, logs) can set history: false (no versions are kept, so none can be restored) and search: false (left out of full-text search): each record is then stored once instead of three times (the record, its history, the search index).

A collection can also sit in a group (the site's section) with a position: the admin nav lists collections in that order, and each group folds.

Notifications (webhooks)

In Settings → Notifications (admins only), paste a webhook address and tick when to send: someone submitted something, changes were published, a member signed up, notify() in a function, a timer failed (said once when it starts failing, not every time it is due). What kind of destination it is, is read from the address:

  • Feishu / Lark (open.feishu.cn, open.larksuite.com): a text message. If the robot has signature checking on, give the secret too.
  • WeCom (qyapi.weixin.qq.com): a text message.
  • DingTalk (oapi.dingtalk.com): a text message. If the robot's security setting is "Sign", give the secret too.
  • Slack (hooks.slack.com), Discord (discord.com/api/webhooks/…), Google Chat (chat.googleapis.com): a text message.
  • Teams: only the address a Workflow gives (*.api.powerplatform.com), as a card holding the text. The old Office 365 connector addresses were retired in May 2026.
  • Telegram: write the address as https://api.telegram.org/bot<token>/sendMessage?chat_id=<id>.
  • Bark (api.day.app/<key>), ntfy (ntfy.sh/<topic>), ServerChan (sctapi.ftqq.com/<key>.send), PushPlus (www.pushplus.plus/send?token=…): a push to a phone, titled with the site's name.
  • None of these has been sent to a real robot yet: the formats follow each service's own documentation.
  • Any other address: a POST of JSON {"event", "text", "data", "site", "at"} with the headers X-Harness-Event and X-Harness-Timestamp. With a signing secret, X-Harness-Signature is sha256= followed by the hex of HMAC-SHA256(secret, "<timestamp>.<body>").

A message is first written to the database together with the thing it tells of, then sent in a round every 3 seconds, one message a round for each destination. One that fails is tried again after 1 minute and after 5. Once saved, an address is never shown again, only its host. Send a test sends one now and says how it went.

Reading content from your own front end

GET /api/v1/content/<collection> returns published records and GET /api/v1/content/<collection>/<id> returns one, following the collection's read rule.

Parameter Meaning
field=value equals
field__ne __gt __gte __lt __lte __contains not equal, greater, at least, less, at most, contains
sort=field, sort=-field sort, - for descending
limit, offset paging, limit from 1 to 100
total=false no count: the answer says only more (whether more follow). Much faster on a large collection
expand=field replace a relation id with the record

Following changes. A list's answer has a cursor. GET /api/v1/content/<collection>/changes?after=<cursor> then answers what changed since: items are the records that changed, as they are now, each once, in the order of their last change; removed the ids of records that went (or no longer match the other parameters, which narrow changes as they narrow a list); cursor where to ask from next; more whether more wait. GET /api/v1/content/<collection>/changes/stream sends the same answers as server-sent events while the connection is open (new EventSource(…)): the first at once, then one per change, each with its cursor as the event id, so a browser that reconnects goes on from there; a member who logs out or loses access gets an error event and the stream ends. Changes follow the collection's read rule as lists do: in an owner collection each member sees only their own changes, and in a collection read by a condition removed is null (saying which records went would say they had been there). Changes are kept for 7 days; a cursor older than that gets 410 and reads the list again. A draft is no change until it is published.

Only fields declared with index or unique can filter and sort. A collection with many records that is often asked by two or three fields together can declare indexes (such as [["org", "status"], ["org", "due"]], at most 5): a list that compares org for equality and then filters by status or sorts by due is read along one, instead of fetching many and sorting them. A field in indexes can filter and sort too.

Uploads

POST /api/v1/media with a multipart field named file and a key with write, up to 20 MB, or the upload_media tool (base64, up to 5 MB). JPEG, PNG, GIF, WebP and PDF are accepted, judged by content rather than extension. Files are stored by content hash at /uploads/<hash>.<ext> and cached for a long time; add ?w=640 for a smaller copy of an image. A picture is worked on before it is stored (see Images under Website pages), so the answer carries the stored width, height and bytes beside the path. Uploads are public, so do not upload private files.

Members' files. A logged-in member uploads with POST /api/v1/members/upload (the same multipart field, formats and 20 MB) and gets a path under /uploads/m/. That file is theirs: it opens for them, for an admin or a key, and for whoever may read a live record that holds it (a teacher who reads the homework opens its attachment); anyone else is told it is not there, and nothing may cache it. A member can put only their own files into what they submit. Each member keeps 200 MB at most and uploads 100 files a day; a file no live record holds a day after it was uploaded is removed. Backups carry members' files; a static export leaves them out.

Tools
Tool Permission What it does
list_systems read the systems of the environment: name, title, when it was made
create_system move_end delete_system structure, top account only make a new, empty system; move a surface with its people and the content only it uses into another system; delete a system and all its data (a backup is taken first)
read_front_end read every call a system's (or one surface's) drafted front end makes of a back end: address, method, files, the code around it; the bases it puts before its addresses, the other servers it names, the sockets it opens
check_system read check a system's drafted back end as a whole: routes, functions, interface.md, migrations, forms.json
app_data / app_rows read / write the system's own tables (columns, rows, migrations done) and a read-only query; rows listed, added, changed, deleted, many changed or deleted at once, their history and undo
list_collections get_collection read list collections, read one
create_collection update_collection delete_collection structure create, change (fields, access, url pattern, nav group and position), delete (records are kept)
get_record query_records aggregate_records search read read records, totals (group, sum, average, min, max), full-text search
create_record update_record delete_record write write records (and their slug)
change_records write change many records at once, chosen by any field: the same values, values a script works out per record, or deletion; one batch of drafts, all or none
list_pending list_versions list_releases read pending changes, an object's history, the latest releases
publish publish publish
schedule_publish cancel_schedule / list_schedules publish / read publish at a set time
restore_version discard_draft undo_release write put a version back as a draft, drop a draft (or a whole batch, records:<collection>), undo a whole release
list_views / set_view delete_view read / structure admin screens
get_site_notes / set_site_notes read / structure notes for the assistant
check_page read check a draft page: render errors, dead links, missing files, omissions
run_function / try_requests / function_log read ask a drafted back end once as a visitor would, or several times as one visit (nothing is written); live runs that failed or logged
get_guide read how things are done here, for an AI that comes with a key: the rules the back office's own assistant works by
list_services read the outside services an admin registered: name, address, how the key goes on, whether it can sign and verify (never a key)
list_timers / set_timer delete_timer read / structure list timers with their last run; have the environment call a function every so many minutes or daily at a time, stop it
list_routines / set_routine delete_routine read / structure list routines; have the assistant do something by itself at set times (only an admin sets one, and it runs as them), stop it
list_site_files get_site_file read read site files (with their hand edits)
write_site_file edit_site_file delete_site_file upload_site_bundle structure write site files (the back end under _server/ too), change one place in a file, upload a built site
new_page / layout_record structure a new page in the surface's own look; one record's page laid out for that record alone
wrap_project / check_end structure / read bring a project you already have into a surface, its calls to a back end left as they are; check what a surface still lacks to work as it did
get_site_settings / set_site_settings read / structure site name, languages, template text, import map, script origins
translation_status / set_translation read / write what is missing or out of date; write a translation
set_member_login structure turn member accounts on or off
set_member_signup structure open or close sign-up by visitors (login stays)
set_people structure a system's one list of people: the tags they can carry, what the page and the tags are called
create_member set_member_password set_member_tags write make a member account by hand, replace a password, set a person's tags
list_ends / set_end delete_end read / structure list a system's surfaces; create, change (title, who may enter), delete a surface with its files
list_members / set_member_status set_member_data move_member delete_member read / write list members; disable or enable one, set its attributes, move it to another surface, delete it for good (its account name must be written out)
upload_media write upload an image or PDF; returns the path and the stored size

| rehearse_upgrade | structure | try a newer version kept on the server on a copy of the environment before switching to it (in the chat of an admin over the whole environment) |

Every tool about a system takes system. Every key can read. Changing structure, screens, site files and notes needs structure.

Environment
Variable Default Meaning
HC_HOST 127.0.0.1 address to listen on (0.0.0.0 in the Docker image)
HC_PORT 4200 port
HC_DATA data data folder, uploads included (/data in the Docker image)
HC_DB <HC_DATA>/harness.db where a data folder from before systems kept its one database; split at the first start into ledger.db and systems/site/data.db
HC_READERS one for each core, 8 at most how many read-only database connections answer pages and API reads, beside the one that writes; 0 for none (everything then shares the one connection)
HC_ORIGIN http://127.0.0.1:<port> the public address, exactly as the browser shows it
HC_SITE_NAME CMS Harness the name until one is set in Settings
HC_ADMIN_PASSWORD random password for cms-harness admin
HC_TRUST_PROXY unset 1 when the reverse proxy runs on another machine
HC_ADMIN_ORIGIN unset a separate admin address (https://admin.example.com), or off
HC_END_SUBDOMAINS unset 1: every surface on its own subdomain; 0: under the site's address; overrides Settings
HC_TLS unset auto: HTTPS by the program itself, certificates from Let's Encrypt (HC_ORIGIN must be https://…)
HC_HTTPS_PORT HC_HTTP_PORT 443 80 the ports HC_TLS=auto listens on (on HC_HOST, 0.0.0.0 then by default)
HC_ACME_EMAIL unset where Let's Encrypt writes about the certificates
HC_ACME_DIRECTORY HC_ACME_ROOT Let's Encrypt staging, or another ACME server and a root to trust for it
HC_FETCH_ALLOW_PRIVATE unset 1 lets the chat's page reading, notifications and outside services reach private addresses (for a deployment inside its own network)
HC_SECRET_KEY unset 32 bytes, base64: the key the secrets saved in settings are encrypted with (outside services' keys, the chat model's key, the web search key, notification addresses). Unset, the server makes one in secret.key in the data folder. A server moved to new hardware needs it, or the keys are entered again
LLM_PROVIDER LLM_API_KEY LLM_MODEL LLM_BASE_URL unset the chat model; overrides Settings

With nginx, add proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; and proxy_set_header Host $host; so rate limits tell visitors apart. Caddy does this by default. The server compresses what it sends itself: pages, styles, scripts, JSON (the API, functions), XML and SVG over 1 KB go out gzipped to browsers that ask, a cached page from a copy compressed once. Pictures, fonts, uploads, backups and the admin chat's event stream go as they are. A proxy in front has nothing left to compress; nginx and Caddy leave an answer that is already compressed alone.

🔒 Security

Read SECURITY.md before you run scripts on the site that you did not write. It explains when to give the admin its own address (Settings → Admin address). What the protection does and does not do, the sandbox server functions run in, and how notifications, outside services' keys and uploaded pictures are handled are there too.

📄 License

AGPL-3.0. Sites built with CMS Harness, front ends that read its API, and the content in its database are not derivative works. You only need to share your changes if you modify CMS Harness itself and offer it as a service. Contributions need a CLA; see CONTRIBUTING.md.


If CMS Harness is what you were looking for, a ⭐ helps other people find it.

Explore related projects

Loading…