Status: describes Lou 0.4 (2026-12-02). The code is public on GitHub at CloudFort-xyz/Lou.
1. What Lou is
Lou is a static-first CMS for small corporate websites. It is built for sites that are mostly content and have very little interaction.
- Every public page is pre-built static HTML. A page view runs no PHP and touches no database.
- A handful of small PHP endpoints cover the interactive bits: contact forms, newsletter sign-up, and (behind auth) the admin and the LLM bridge.
- Clients edit content (text, images) in a light inline editor.
- Structure and design (layout, templates, menus, styles) change through an LLM chat session of the client's choice. Every change lands in a staging copy with a preview link and goes live only after a human approves it.
- It runs on plain shared PHP hosting (PHP 8.3+, FTP/SSH). There's no Node, no build server, no framework, and no database server.
Non-goals
- Running a generic application platform, a shop, user accounts for site visitors, or comments.
- Competing with WordPress's plugin ecosystem. Extensions are code, and an LLM writes most of them.
- Running per-request templating in production.
2. Principles
- Static by default. Anything that can be computed at build time is.
- Small attack surface. The web root holds static files and a few single-purpose endpoint files. Core code, content, config and data live outside the web root.
- No framework, no required dependencies. It uses plain PHP 8.3 with a PSR-4 autoloader. Composer is optional and only for dev tooling.
- Files are the source of truth. Content and templates are plain files that diff well, so Git is a natural (but optional) history layer.
- Humans approve, LLMs propose. No LLM change reaches the live site without an explicit approval.
3. Layout on disk
On KeyHelp (or any panel) the domain's document root points at lou/public. If a host can't change the document root, Lou sits in a sibling directory and builds into public_html (output_dir set to it, 'output_swap' => 'contents'): instead of renaming the whole folder, each build swaps in only the top-level entries Lou wrote last time (listed in var/output.json), so the host's own files stay. Foreign files a build must replace are moved to var/replaced/<build>/. Hosting-panel blocks (# BEGIN … # END …) in the document root's .htaccess are carried over to every build.
4. Content model
Pages and stable ids
Each page is a folder named after its stable page id, with one JSON file per language:
site/content/pages/about/en.json site/content/pages/about/hu.json { "slug": "about-us", "title": "About us", "menu_label": "About", "description": "Meta description for search engines", "template": "page", "fields": { "hero": { "title": "…", "text": "…", "image": { "src": "/assets/img/x.webp", "alt": "…" } }, "body": "<p>Rich text, sanitised HTML</p>" } }- The page id (folder name) never changes and never appears in URLs. The slug is per language and can change freely. That's what makes renaming and redirects safe (see 6.1).
- Optional search engine keys: seo_title (the whole <title>), noindex (true hides the page from search engines and the sitemap) and share_image (an /assets/ path). See 6.2.
- home is a reserved id that builds to the language root.
- Nested pages: "parent": "services" in the JSON. The URL becomes /services-slug/child-slug/, built from each language's slugs.
- fields is the client-editable surface. The inline editor can only change values inside fields (plus title, menu_label, description, seo_title and noindex). It never touches templates, template, slug or structure, apart from duplicating, moving and deleting items of lists that already exist in fields (see 8).
- Field types are inferred from the template: plain text, rich text (a small allow-list of tags), image (src + alt) and link (page id or href, plus label).
- If a page lacks a language file, it isn't built in that language. The build lists it as a warning, and the language switcher hides it.
Languages
// site/config.php 'languages' => ['hu', 'en'], 'default_language' => 'hu', 'prefix_default' => false, // hu at /, en at /en/- URLs: /rolunk/ (hu, default, no prefix) and /en/about-us/ (en).
- Every page gets <html lang>, hreflang alternates (including x-default), and sitemap.xml lists the alternates.
- The language switcher links to the same page in the other language, not to the home page.
- No server-side language detection or redirect on /. It's static, and better for SEO and caching. An optional small JS hint ("This page is available in English") can be added later.
Global content, menu and strings
- site/content/site/<lang>.json: company name, address, footer text, social links, and shared images such as the logo (an object with a src, like page image fields). Templates print texts with $v->global('footer'), mark them for the editor with $v->editableGlobal('footer'), and print images with $v->globalImage('logo').
- site/menu.json: the structure only, as a list of page ids (nested for dropdowns). Labels come from each page's menu_label per language, so translating never touches the structure, and an LLM restructuring the menu never touches the translations. Editors change the structure on the admin's Menu page; assistants edit the file.
- site/content/strings/<lang>.json: UI strings used by templates and forms ($v->t('form.send')).
Why JSON and not Markdown
These are corporate pages made of structured sections (hero, features, CTA), not long-form articles. JSON fields map 1:1 to editable regions, are trivial for an LLM to edit safely, and need no parser. If a blog or news section is added later, it gets Markdown entries with a bundled single-file parser.
5. Templates
Templates are plain PHP files that receive a View helper as $v.
<?php $v->layout('layout') ?> <section class="hero"> <h1 <?= $v->editable('hero.title') ?>><?= $v->text('hero.title') ?></h1> <?= $v->image('hero.image', class: 'hero__img') ?> <a href="<?= $v->url('contact') ?>"><?= $v->t('cta.contact') ?></a> </section>- Output is escaped by default. text() escapes, html() outputs sanitised rich text, and raw() exists but is flagged in review.
- Links use page ids, never paths: $v->url('contact') resolves to the current language's URL for that page. Renaming a slug therefore never breaks internal links, and the build fails loudly on a link to a page id that doesn't exist.
- editable() prints nothing in production builds. In edit and preview builds it adds data-lou-field="hero.title" so the inline editor knows what to edit. Production HTML contains no CMS markers.
Repeating items come from JSON lists ("features": [ {...}, {...} ]). Mark each rendered item with $v->item("features.$i") so the editor can duplicate, move and delete it:
<?php foreach ($v->field('features', []) as $i => $f): ?> <article class="feature"<?= $v->item("features.$i") ?>> <h2<?= $v->editable("features.$i.title") ?>><?= $v->text("features.$i.title") ?></h2> </article> <?php endforeach ?>Like editable(), it prints nothing in production builds. The template decides what repeats; editors only decide how many and in which order. Adding a new kind of section stays an LLM/developer change.
- Templates run only at build time, never per request.
6. Build and deploy
php lou build (and the admin's "Publish" button, which calls the same code):
- Loads config, menu, global content and all pages, then validates them (missing templates, unknown page ids in links or the menu, duplicate slugs).
- Renders every page in every language to <path>/index.html (pretty URLs, no rewrites needed).
- Copies site/assets/, then stubs/ (.htaccess, _lou/*.php).
- Generates the redirect rules (6.1), sitemap.xml (with hreflang alternates and lastmod), robots.txt and the error pages per language (6.3), and runs the search engine checks (6.2).
- Writes a URL manifest (page id + language → URL) into var/builds/<id>/manifest.json.
- Writes everything into a fresh temp directory next to the output, then swaps it in atomically (rename). This prevents half-deployed states. The previous build is kept in var/builds/ for one-click rollback.
Image processing (resizing and WebP via GD) happens at upload time in the admin, not at build time, so builds stay fast.
Deploy options:
- Release zip + web installer (primary, no Git). lou-<version>.zip (built by php lou release, published by the Release workflow for every v* tag) holds the code, starter sites and public/install.php, never site/, var/ or .env.php. The installer checks requirements, asks for a setup key from var/install-key.txt (proof of file access), seeds site/ from a starter or an uploaded zip (Lou backup, or any zip with a site folder such as a GitHub download of a client repo), saves the site address, output location and email, builds, and creates the first admin last; it is locked once a user exists. Updates (Admin → Updates, php lou update) download or accept a release zip, verify every file against release.json and its Ed25519 signature (public key in src/Setup/release-key.pub), swap in the code with the Deployer, and ask for one rebuild (var/live.json records the Lou version of each build). Unsigned or wrongly signed uploads are refused unless .env.php sets 'allow_unsigned_updates' => true (FTP/SSH only, so a stolen admin login can't), and even then only after a security warning and typing the version. Tags with a suffix (v0.2.0-rc.1) publish signed GitHub pre-releases that "Check for updates" ignores, and the Release workflow's manual run builds a signed test zip from any branch as an artifact. 'update_channel' => 'main' in .env.php makes an install follow the rolling latest-main pre-release instead, which the Main build workflow rebuilds and signs on every push to main (versions <next>-main.<UTC time>, newest build wins). See docs/install.md.
- Client site design from a zip (fallback, no Git). Admin → Theme takes a zip of a client repository (Admin → Updates only updates Lou itself). The Theme page also shows the last upload (from the audit log) and whether theme files (templates/, assets/ minus assets/uploads/) are waiting on staging or in the admin's draft. Its templates and assets are planned with the same rule as deploy --site (Deployer::planDesign), checked like assistants' templates, and written into the uploader's draft, so they go live through Review. With "Send it to Review right away" (the default) and nothing else in the draft, the import is submitted to staging at once with the summary "Site design from <zip>" and its preview is built; with other edits in the draft, a conflict or a validation problem it waits in the draft and the result page says why. On the first import (no var/deploy-design.json) files that exist only on the server are kept, never deleted. var/deploy-design.pending.json holds what the import wrote until a publish makes it live (DesignImport::confirm).
- Theme library. Every uploaded zip's design (templates/ and assets/ minus assets/uploads/) is kept in var/themes/<id>/ with a theme.json (Setup\ThemeLibrary); the same design is never stored twice, and the design in use is kept before each upload or switch, so there is always something to switch back to. The theme in use stays in site/templates and site/assets. Preview builds the live content with a stored theme at a secret link (Previews kind theme, source theme:<id>, rebuilt with the other previews after a publish); a theme missing a template the content uses fails with the list of pages. Use this theme puts the design into the admin's draft as an exact replacement (DesignImport::fromDir(..., replace: true): files the theme lacks are deleted, files changed on the server since the last deploy are replaced and listed) and submits it to Review with the summary "Switch to the theme <name>". Stored themes are a backup part of their own (themes, see 8.2).
- Git (optional): the server's Git clone is kept separate from the live install. php lou deploy DIR copies the code (src/, stubs/, vendor-bundled/, lou) into the install, seeds site/ only when the install has none, and builds. site/, var/ and .env.php are never overwritten, because the server's site/ is the truth. cPanel runs it from .cpanel.yml (see docs/deploy-cpanel.md). KeyHelp can do the same from a deploy hook. A client site kept in its own repository (Lou as a submodule) deploys with --site=DIR to seed from its own site/; in that mode every deploy also updates site/templates/ and site/assets/ from the repository, except files changed on the server since the last deploy (skipped with a warning, never overwritten) and assets/uploads/. Content stays the server's. --pull then pulls the client repository and its pinned Lou commit.
- php lou check reports missing PHP pieces (version, extensions, writable folders) and config warnings.
6.1 Renames and redirects
Redirects are derived automatically, so it doesn't matter whether a change came from the editor, an LLM or a hand edit over FTP.
- Every build compares the new URL manifest with the previous live one.
- Moved: a page id and language whose URL changed (slug renamed, or the page moved under a new parent). Lou adds old URL → page id to site/redirects.json automatically. Because the target is a page id, a later rename just updates the target, so there are never redirect chains.
- Gone: a URL whose page id was deleted. The build (and the LLM approval screen) lists it and asks for a redirect target or 410 Gone. Until someone answers, it defaults to a 301 to the language's home page.
- Manual entries (/old-campaign/ → contact, or to an external URL) can be added in the admin or by an LLM.
- Import and export (Settings → Redirects): the list downloads as .xlsx or CSV (From, To, Status, Note) and a file in the same shape can be uploaded. Nothing is saved until the person has seen a preview: new, changed (with "use the file's target" or "keep the current one"), unchanged, duplicates, removed (in replace mode; the default merge keeps everything not in the file) and rows that can't be imported (live page addresses, the endpoint folder, query strings, loops, unknown statuses, the same address twice with different targets). A To that is the address of a page is stored as its page id. Status: 301 (default), 302, 307, 308 or 410. Applying writes site/redirects.json, records a History entry and offers "Undo the import" while nothing else changed the file. .xlsx is read and written with ZipArchive and DOM (Lou\Support\Xlsx), not a spreadsheet library.
- Output: RewriteRule/Redirect 301 lines generated into public/.htaccess, with a documented nginx map snippet as an alternative. For hosts without either, the old path also gets a tiny static HTML file with <meta http-equiv="refresh"> and a canonical link.
- Redirect loops and redirects that shadow a live URL are build errors, and so are sources or targets with whitespace, quotes, backslashes or control characters (they would break out of the .htaccess line) and sources with ./.. segments (the fallback page must stay inside the build).
6.2 Search engines and sharing
Everything here happens at build time. Nothing runs per request, and no outside service is called.
- Head tags. <?= $v->head() ?> in the layout prints the <title>, the meta description, the canonical link, hreflang alternates, the robots rule, Open Graph/Twitter card tags and JSON-LD. $v->seoLinks() prints the same without title and description, so older layouts keep working. $v->metaTitle() is the title on its own. $v->title() stays the plain page title, for headings.
- Title. seo.title_pattern (default {page} | {site}). {site} is site_name or company from Site details, else name in the config. A page title that already contains the site name is used as it is, and a page's seo_title replaces the whole title.
- Social tags (seo.social_tags, on by default): og:type, og:site_name, og:title (seo_title or the title, without the site name), og:description, og:url, og:image (+ size and alt) and twitter:card. The share image is the page's share_image, else its first JPEG/PNG/WebP/GIF image field, else seo.share_image. SVG is skipped, because social networks don't show it.
- Hidden pages ("noindex": true): <meta name="robots" content="noindex">, left out of the sitemap, of hreflang sets and of structured data. The older "sitemap": false still only drops a page from the sitemap.
- Structured data (seo.structured_data, on by default), as a <script type="application/ld+json"> data block. Browsers don't run data blocks, so the CSP's script-src doesn't apply, and <, > and & are escaped so content can't close the tag. Home pages get Organization (name, URL, seo.logo, email, phone and address from Site details, seo.same_as https profiles) and WebSite. Other pages get a BreadcrumbList (home → parents → page). Type-specific data such as articles or FAQs is left to templates for now.
- lastmod. Live builds keep a fingerprint of each page's JSON in var/lastmod.json. A changed page gets the build date and an unchanged one keeps its date. On the first build the file date is used.
- Checks. Every build (live and preview) checks the rendered pages: title present and its own part under about 60 characters, description 50–160 characters, duplicate titles and descriptions per language, exactly one <h1>, alt text on image fields and an alt on every <img>, internal links that lead to a page, redirect, asset or endpoint, image files over 400 KB, a missing or unusable share image, and a layout whose <title> skips the pattern. They are suggestions, not warnings: they never block a build or a publish. The CLI prints them as seo: lines, build_preview returns them as seo, and Review lists them under "Search engine suggestions".
- Admin. The editor's "Search engines" box shows a search result preview and a share card that update as you type, the optional search engine title, and "Hide this page from search engines". The canonical address, robots rule, share image source and structured data types sit under "Technical details".
- Settings live in site/config.php under seo (title_pattern, social_tags, structured_data, share_image, logo, same_as). They are site content, so they go through drafts and review like any other change.
- IndexNow (opt-in, Settings → Search engines; an install setting in var/settings.json, "indexnow": {"enabled": true, "key": "<32 hex>"}). Turning it on makes a key and rebuilds, so /<key>.txt is live first. After each live build Lou queues the addresses of pages whose content fingerprint changed (new or edited, hidden pages left out) plus old addresses that now redirect or are gone, and sends them in one POST to https://api.indexnow.org/indexnow, which shares them with Bing, Yandex and the other participants. The first build after an upgrade sends nothing, because there is nothing to compare with. A failed send keeps the queue (var/indexnow-queue.json) for the next build and never fails the build; the last result is in var/indexnow.json and on the Settings page. "Send all pages now" sends the whole sitemap once. Nothing is sent while the site address is unset or still the example. The same section links to Google Search Console (Google doesn't take part in IndexNow), Bing Webmaster Tools and Yandex Webmaster, with the sitemap address to copy.
- Later: robots.txt additions and verification codes; llms.txt; an MCP report tool for the checks.
6.3 Error pages
Every live build writes the pages visitors see when something goes wrong, in every language: 403.html, 404.html, 500.html and 503.html (in the language's folder, e.g. /en/500.html).
- 404 is the site's own not-found page, so editors change its text like any other page.
- 403, 500 and 503 use templates/error.php when the site has one, inside the site's layout, so they look like the rest of the site. The template gets the fields status, title, text and home (the text of a link to the home page). They are built, never listed in the sitemap, and carry noindex.
- Without that template (or without a not-found page) Lou writes a plain, neutral page styled by error.css in the endpoint folder (light and dark). It names neither Lou nor the web server.
- Wording: error.403.title, error.403.text (and the same for 404, 500,
- and error.home in site/content/strings/<lang>.json; Lou's own English and Hungarian text when the site doesn't have them.
- The web root's .htaccess points ErrorDocument 403, 404, 410, 500 and 503 at the default language's pages, and each prefixed language folder gets its own .htaccess pointing at its own. The PHP endpoints send the same built pages when they fail (500) or hide the admin (404), so the web server's bare default pages never show.
7. Runtime endpoint for the site (/_lou/submit)
The endpoint folder. _lou/ in this document stands for the endpoint folder, set by endpoint_dir in var/settings.json (a server setting only; site/config.php can't change it). The web installer gives new installs the neutral _app; installs without the setting keep _lou. Settings → General → Admin folder moves it (rebuild, new preview links, redirect to the new admin). Pages may not live inside it. The public site doesn't name Lou: no generator tag, no data-lou-* or lou-* names in built pages or forms.js, neutral session cookie (__Host-sid) and bearer realm. Form hooks are data-form, data-recaptcha, data-status (an element for the result message, added by forms.js when the template has none), .form-error, .form-status--ok and .form-status--error; the honeypot uses the hidden attribute, so it needs no CSS. A build warns about templates or stylesheets still using the old data-lou-status / .lou-* names. What still gives Lou away: the admin login page itself (hidden behind its secret address, below), the bridge's tool names (?openapi is public), and the lou_ prefix of bridge tokens (secret anyway). The folder itself answers with the site's 404 page, not the server's "Forbidden".
The admin's secret address. The admin's login page is at /_lou/<secret>, e.g. /_app/k3jx9q2mzt7v4pw8ra1c. The web installer makes a random one (20 characters of a–z and 0–9); installs from before 0.4 keep /_lou/admin.php until an admin turns it on (the Dashboard suggests it). The endpoint folder's .htaccess rewrites any name of the right shape (12–64 lowercase letters, digits, _ or -) to admin.php, which checks on every request that the browser asked for the right one; anything else, admin.php itself included, gets the site's 404 page. So changing it needs no rebuild, and it needs mod_rewrite (Apache, LiteSpeed). It is stored as admin_slug in var/settings.json (Settings → Security → Admin address: a new random one, one typed by the admin, or off) and can be set in .env.php, which wins: 'admin_slug' => 'your-secret', or false for the old address. A lost address: php lou admin-url prints it, --new, --set=NAME and --off change it, or look in var/settings.json over FTP. Invites, password links, the bridge's review_url and the CLI's invite links use it. The MCP endpoint and OAuth keep their addresses: assistants log in on oauth.php?r=… (9), which never shows the admin's address.
All visitor-facing interaction goes through one endpoint, /_lou/submit. The address has no .php: the endpoint folder's .htaccess rewrites it to submit.php (internally, so a POST stays a POST), and submit.php itself keeps answering for pages or templates that still name it. On nginx, add the equivalent location = /_lou/submit { rewrite ^ /_lou/submit.php last; }. Responses don't carry PHP's X-Powered-By header either: every stub removes it, and the web root's .htaccess unsets it as well. The admin (/_lou/admin.php), the LLM bridge (/_lou/mcp.php) and its sign-in server (/_lou/oauth.php) stay separate, because they have different auth and very different risk profiles. Previews are static files under /_lou/p/, so they need no endpoint.
Why one endpoint for the site:
- There's one place to harden: CSRF and origin checks, rate limiting, honeypot, captcha, size limits and logging are written once and apply to everything.
- A newsletter sign-up is really just a small form with a different action.
- There's less surface area, and a new form type is configuration, not a new PHP file.
Each stub is three lines that require Lou core from outside the web root, so a misconfigured server can never leak core source.
Forms = definitions + actions
Every form (contact, newsletter, a quote request…) is defined in site/config.php. The HTML posts form=<id>, and the endpoint looks the definition up. Unknown ids are rejected.
'forms' => [ 'contact' => [ 'fields' => ['name' => 'required|max:100', 'email' => 'required|email', 'message' => 'required|max:5000', 'consent' => 'accepted'], 'captcha' => 'turnstile', // or 'recaptcha', 'none'; left out: 'builtin' (Settings → Spam protection wins) 'actions' => [ ['store'], // always first: saved even if email fails ['email', 'to' => ['info@example.com'], 'subject' => '[{site}] New message: {name}'], ['webhook', 'webhook' => 'zapier_contact'], // URL under webhooks in .env.php ], 'success' => ['page' => 'thank-you'], // page id: redirect target without JS ], 'newsletter' => [ 'fields' => ['email' => 'required|email', 'consent' => 'accepted'], 'captcha' => 'none', // no extra check 'actions' => [['store'], ['subscribe', 'provider' => 'mailerlite', 'group' => '…']], ], ],- Actions run in order: store (SQLite), email (Mailer), subscribe (NewsletterProvider) and webhook (generic JSON POST). If an action after store fails, the submission is kept and marked for retry, and the admin shows the failure.
- Routing: an email action can pick its recipients from a field, e.g. a topic dropdown: 'to_by' => ['field' => 'topic', 'map' => ['job' => 'hr@example.com']]. Values not in the map fall back to to. Validate the field with in:… so only known values are accepted.
- Spam protection applies to every form: a honeypot field (bots get a fake success), a minimum fill time, a per-visitor plus per-form rate limit (SQLite, IPs stored only as keyed hashes), an Origin/Referer check, and an optional security check per form, verified server-side: the built-in proof-of-work check, Cloudflare Turnstile or Google reCAPTCHA v3.
- Settings → Spam protection (admins) sets each form's check and its per-visitor limit, and takes the Turnstile/reCAPTCHA keys. These are server settings (protection in var/settings.json); once a form is saved there, its captcha and rate_limit in site/config.php no longer count, so an assistant's draft can't turn spam protection off. Without an admin choice the form's captcha (left out or null: the built-in check, the default for every form; 'none' turns it off), its own rate_limit or the site-wide rate_limit apply. Site keys are settings, secrets go to var/secrets.json (turnstile_secret, recaptcha_secret; .env.php still works). A new secret is checked with the service (a made-up answer fails with invalid-input-secret only when the secret is wrong) before it is saved. Saving rebuilds the live site.
- The built-in check (Captcha\ProofOfWork) needs no outside service and no CSP change. The server sends {algorithm: SHA-256, challenge, maxnumber, salt, signature}: challenge = sha256(salt . n) for a random n ≤ maxnumber, signed with an HMAC of a key derived from the app key. The salt holds expires (30 minutes) and for (login, forgot, form:<id>), so neither can be changed. captcha.js tries numbers from 0 with WebCrypto and sends back base64 JSON with number in the pow field; each solved puzzle works once (its signature is kept in rate_limits). The format is ALTCHA's original SHA-256 one. Strength (largest n): light 20 000, normal 100 000, strong 500 000 (Spam protection page). Forms get the puzzle with their timestamp token and solve it while the visitor types; formFields() adds the hidden field and scripts() loads captcha.js before forms.js. It stops scripts that don't run JavaScript and makes each post cost CPU time; it doesn't stop a real browser driven by a spammer, which is what Turnstile is for.
- Minimum fill time: forms.js fetches a signed timestamp token (GET /_lou/submit?token=<form>) when the visitor first touches the form. Submissions that arrive too fast, or with a forged or foreign token, get a fake success. Visitors without JS send no token and are still accepted, unless the form sets 'require_token' => true.
- Forms work without JavaScript (plain POST, then a redirect to the success page in the visitor's language). With JS they submit via fetch, get JSON back, and show inline messages. Error texts come from strings/<lang>.json.
- A static page can't carry a per-visitor CSRF token, so the protection is the origin check, the signed timestamp and SameSite behaviour. This is enough for anonymous submissions with no session.
Pluggable integrations
Three small interfaces, each with a config-selected implementation:
- Mailer: PhpMailerMailer (v0.1, SMTP via a bundled PHPMailer, no Composer needed). Later: SesMailer, SendGridMailer, and others.
- NewsletterProvider: MailchimpProvider, MailerLiteProvider, WebhookProvider (generic JSON POST for Integrately, IFTTT, Zapier, Make).
- Captcha: ProofOfWork (built in), TurnstileCaptcha, RecaptchaCaptcha; Captcha\Protection resolves which one a form or the login uses.
All other HTTP calls use PHP's built-in curl. There's no SDK.
Storage
There's one SQLite file in var/ (PDO, WAL mode). Tables: submissions (form id, language, data, action results, read/unread), subscribers (a local copy plus provider sync status), rate_limits, audit_log (who changed what, from editor, LLM or CLI), changesets (LLM proposals) and previews (tokens, expiry).
8. Admin and inline editor
- At the admin's secret address (7; /_lou/admin.php without one): log in with a user name and password. Users are stored as password hashes in var/users.json (0600) and managed on the Users page (admins) or with php lou user list|add|invite|signout|remove. Roles, each including the one before: contributor (edit content in their own draft, submit it, history; can't publish, reject or take changes off staging, and can't see form submissions or subscribers, which hold personal data), editor (also publishes and sees submissions) and admin (also users, assistants/tokens, settings, updates, redirects, builds/rollback, backups, deleting submissions). Assistant tokens are not users: they work in their own draft like a contributor and never publish; each token records which admin created it.
- Admin menu. A side menu whose sections open to list their sub-pages, and show them in a flyout on hover or keyboard focus (CSS only). The menu is one list in src/Admin/views/_menu.php; items carry the lowest role that sees them.
- Dashboard: Home, Updates (admins; Lou itself, see 6)
- Pages: All pages, Menu, Site details, Shared links
- Review (with the number of staged changes)
- History: Changes, Undo a publish
- Submissions, Subscribers
- Users: All users, AI assistants
- Theme (design zip upload and the theme library, see 6)
- Backups: All backups, Create backup, Restore a backup
- Settings: General (site address, admin language, admin folder), Email, Search engines (6.2), Redirects (6.1), Custom code, Security
- Profile
- Updates. Admins check for and install Lou updates under Dashboard → Updates (see 6). When an admin opens the admin and no check ran in the last 24 hours, admin.js asks for one in the background (var/update-check.json), so no page waits for GitHub and there is no cron; a new version shows as a badge on Dashboard and Updates.
- Email (Settings → Email, admins): sender, "write to a log file" or SMTP, and a test email. The SMTP password goes into var/secrets.json and is never shown again. SMTP settings in .env.php still work until the admin values are saved.
- Users page. A list (name, email, role, last login, invited) and an invite form; each user has an edit page (role, email, send a new invite or a password reset link, sign out everywhere, remove, and their recent audit log entries behind an accordion). Best practices built in:
- Invites, not admin-set passwords: inviting creates the user with no password and emails a one-time link (48 h) where they choose one and are signed in. If email isn't set up the admin gets the link, shown once, to pass on. Admin password resets work the same way. Links carry a random 256-bit token; only its SHA-256 is stored, one link per user.
- Forgot password on the login page: by user name or email, a one-hour link, the same answer whether or not the account exists, at most 5 requests per IP and 3 emails per account an hour.
- Passwords: password_hash (rehashed at login when PHP's default changes), at least 10 characters, no composition rules or expiry (NIST SP 800-63B), but common passwords, single repeated characters and the user name plus a few characters are refused (PasswordPolicy).
- Changes apply at once: the role is read from users.json on every request. Each user has a session version (sv); a password change, a reset link being used or "Sign out everywhere" bumps it, and every session started before ends on its next request (the current one carries on after your own password change). Removed users are signed out the same way.
- Last-admin protection: the last administrator can't be demoted or removed; nobody removes themselves or changes their own role.
- Rate limits: 10 failed logins an hour per IP and 20 per account (any IP), never a permanent lock. Both are set on the Security page (Login protection), which also shows failed logins of the last 24 hours and who is paused, with a button to lift the pauses (php lou protection unblock). When an account reaches its limit, its owner is emailed once (can be turned off) and the audit log gets login-paused.
- Login security check: never, every time, or (default) after 3 failures from the IP or for the account this hour. Built-in check (default), Turnstile or reCAPTCHA. When it is due and not passed, the password isn't checked and the attempt counts against the IP only, so nobody can lock an account this way. "Forgot password" asks for it when the login page would. Turnstile/reCAPTCHA can only be chosen once their keys are in; if the secret goes missing later, the check is skipped (and logged) rather than locking everyone out. php lou protection login-captcha off switches it off from the server. The admin folder's .htaccess sends a policy that allows the two services (AdminApp::CSP_CAPTCHA); admin.php sends its strict AdminApp::CSP on every page except a login or forgot page that shows them, and browsers enforce both headers.
- Every user change, login, invite and reset is in the audit log.
- Two-step login (TOTP, RFC 6238), optional per user on the Profile page: a QR code (drawn as SVG by Support\QrCode, no library) or the key to type, confirmed with a first code; then 10 recovery codes shown once (SHA-256 stored, each works once). Login asks for the code after the password (a 5-minute pending step, not a session); codes work once, one 30 s step of drift, wrong codes count towards the login limits. A reset link doesn't skip the code. Turning it off or renewing recovery codes needs the password. Admins can require it for everyone on the Security page (require_2fa in var/settings.json, never from site/config.php, so an assistant's draft can't turn it off; they must have it on themselves first): people without it can only set it up. Admins reset it for a lost phone (also php lou user 2fa-reset NAME), which signs the user out.
- AI assistants are a sub-page of Users (Users → AI assistants): bridge tokens with ready-to-paste connection snippets, signed-in apps (OAuth grants, see 9) and app credentials.
- Sessions are hardened: their own save path in var/sessions, strict mode, a __Host- cookie with Secure, HttpOnly and SameSite=Lax (Strict would sign people out when they open an admin link from another site), a 2 h idle and 12 h absolute timeout, CSRF tokens on every POST, a same-origin check, and login rate limiting.
- Admin address (optional, Settings → Security). admin_host makes the admin answer only on its own address, such as admin.example.com: a cPanel subdomain or alias whose document root is the site's own web folder (not a separate one: the editing preview must be same-origin with the admin, because the editor talks to it with postMessage). On any other address admin.php is the same plain 404 as an unknown page, never a redirect, so the site doesn't say where its admin is. The web root's .htaccess makes the admin address serve only the endpoint folder and /.well-known/ (AutoSSL), so it never shows a copy of the site. The public pages, forms, share and live links and the assistants' connection (mcp.php, oauth.php) stay on the site address; oauth.php?authorize sends the approving person to the consent screen on the admin address, and emailed invite and reset links use it too. The session cookie is host-only (__Host-), so the public site never receives it, and scripts on the live site (custom code, third-party tags) are cross-origin to the admin.
- Cloudflare Access (optional). A Host header is written by the client, so the address alone only hides the admin. With cloudflare_access (team domain + application AUD tag) every admin request must carry a valid Cf-Access-Jwt-Assertion token: RS256 signature against the team's public keys (cached in var/cloudflare-access.json, fetched again after 6 h or for an unknown key id, at most every 5 minutes, cached keys used when Cloudflare can't be reached), issuer, audience and expiry. Refused requests get the 404, and Access failures are noted in var/error.log (at most once a minute). Verified requests take the visitor's IP from CF-Connecting-IP for the login limits; without a verified token that header is ignored.
- Both settings can only be saved from a request that already meets them (the admin open on the new address, with a valid token for the typed team and AUD), so the Security page can't lock anyone out. Both live in var/settings.json; the same keys in .env.php win, which is the way back in: 'admin_host' => '' or 'cloudflare_access' => false take effect at once, without a rebuild.
- Previews are static builds at secret URLs (/_lou/p/<128-bit token>/) inside the web root, so they need no PHP to view and work on any host. They're never indexed, survive publishing, and expire. The admin's editing preview has the editor script injected. Shareable preview links are clean copies for the client.
- Inline editing: the admin loads the editing preview (with data-lou-field markers) in an iframe. Clicking a marked element edits it in place: text is contenteditable, and images open an upload/replace dialog. Saving writes the JSON field into the person's draft (see 8.1) and rebuilds their preview.
- Site details (editors): a form for the shared texts every page uses, per language: content/site/<lang>.json (company, address, contact details, footer) and, behind an accordion, content/strings/<lang>.json (labels and buttons). The page says plainly that these texts appear on every page. Only existing text values change (nested one level at most, e.g. social.facebook), as plain text, into the person's draft; Review and publish work as for page edits, and a publish rebuilds every page. Shared images (objects with a src) get an upload and a description field: a new file replaces the image in every language, the description is per language. Texts marked with $v->editableGlobal() and images printed with $v->globalImage() can also be clicked in the editor (purple outline, with a note that the change shows on every page); those edits have undo like page edits.
- Menu (editors, Pages → Menu): the menu as a list with buttons to move an item up or down, put it under the item above (a submenu, at most two levels unless menu.json already nests deeper, three at most), take it out of a submenu, remove it from the menu or add a page back. The same page edits the menu_label of each page for one language. Saving writes menu.json into the person's draft (pages must exist and appear once; extra keys on items are kept) and goes through Review.
- Custom code (admins only): HTML that live builds put just before </head> and just before </body> on every page, for analytics, tag managers, cookie banners and chat widgets. Stored in site/code.json ({"head": "…", "body": "…", "csp": {"connect-src": ["https://…"]}}), so it goes through draft, Review, publish and History like any other change; the save is CSRF-checked and audit-logged. Editors and contributors can't open the page or bring an old version back from History. Previews, share links and the editor never get the code: they are served from the admin's own folder (same origin as the admin, with its own strict CSP), where third-party scripts must not run. The live CSP is extended at build time with exactly what the code needs: a sha256 hash per inline <script> / <style> (never 'unsafe-inline'), the origins of <script src>, <iframe src>, <img src> and stylesheet links, plus the extra sources the admin lists per directive (script-src, connect-src, img-src, frame-src, style-src, font-src) behind a "Technical details" accordion. Sources end up in .htaccess, so only hosts, origins, a few schemes (https:, data:, blob:, wss:), hashes and the keywords 'unsafe-inline', 'unsafe-eval' and 'wasm-unsafe-eval' are accepted, on save, in the bridge and again in the build. The page warns about what the CSP blocks whatever is allowed (inline event handlers, style= attributes, javascript: links). code.json is read-only for assistants: the bridge lets them read it but refuses write_site_file and delete_site_file on it, and submit_for_review leaves out any change to it, because editors can connect assistants and publish their work. Previews leave the code out, and the editor, Review and the Custom code page say so whenever there is custom code.
- Long settings pages (Security, MCP, Spam protection, General, Email, Custom code) fold each section into a card (Lou\Admin\FoldCard: native <details> with title, status badge and a one-line summary; admin.js opens the one a #link names and remembers open cards per page in localStorage).
- Security (admins only): the live site's CSP mode, a server setting (csp in var/settings.json, never from site/config.php): strict (default, the header from stubs/.htaccess plus what the custom code needs), report-only (sent as Content-Security-Policy-Report-Only, so browsers log what would be blocked) or off (no CSP header; the other security headers stay). Saving rebuilds the live site and is audit-logged. The admin folder and previews always keep their own strict policy. The same page holds the "require two-step login for everyone" switch (moved from Users, which now shows its state and links here), and Login protection (limits, the login security check and the owner email, see Users above; protection in var/settings.json, which site/config.php can't set).
- Repeating items: elements marked with $v->item() show a small toolbar on hover or focus: Duplicate, move (↑↓ or ←→, picked from the layout), and Delete (with an inline "Delete this?" step, no browser dialog). The server only changes an existing list in fields; the last item can't be deleted, and a list holds at most 100 items. The change is made in every language whose list has the same length, so item N is the same item everywhere; each language copies its own text. Languages whose list differs are left alone and named in the editor's status line. A duplicated image is replaced by clicking the copy (the normal image dialog).
- Paragraphs inside rich-text fields (editable(..., 'html')) get the same toolbar per top-level block (paragraph, list, heading): duplicate, move up/down, delete (not the last one). This is done in the browser on the field's HTML and saved like a text edit (sanitised on the server, one undo step). While the field is open it just changes the text being edited, so Esc still cancels everything.
- Undo/redo in the editor (buttons, Ctrl+Z, Ctrl+Shift+Z/Ctrl+Y), per person and per page, kept on the server in var/undo/ (last 50 steps), so it survives reloads. Every editor change records the page's content files before and after. Undo only applies while those files still match what the change produced; if something else changed them since (a publish, an assistant, another tab), the step is dropped with a message instead of overwriting newer work. A new edit clears that page's redo steps. This is separate from History (8.1), which records publishes.
- Local backup of typing: while a field is being edited, editor.js keeps its text in localStorage (lou:unsaved:<page>:<lang>:<field>) until the save succeeds. If the tab closes, crashes or the save fails, the next load of that page asks: "Restore my text" or "Keep the saved version" (and warns when the saved version changed meanwhile). Restoring goes through the normal save, so the server still sanitises it.
- Repeatable pages: templates listed in config['admin']['repeatable'] (e.g. ['job'] for job ads) get Duplicate and Delete in the page list. Duplicate copies the page in every language as <id>-N with slug <slug>-N and opens the copy in the editor; Delete refuses pages that have children or are in the menu. Both happen in the person's draft, so nothing goes live until it is published. Other page types can only be created or removed in the repository or through an assistant.
- Profile and admin languages. Every user has a Profile page (the user name in the top bar) with their own preferences, stored with the user in var/users.json under prefs: admin language (English or Hungarian), time zone (the browser's, or a fixed IANA zone), date and time format, the content language the editor opens in, the page shown after login, the appearance (the device's light or dark setting, or always Light or Dark), a colour theme (Blue, Teal, Purple or Graphite), and a password change. Dark mode is a second palette of the CSS custom properties in admin.css: it applies under prefers-color-scheme: dark unless <html data-theme="light">, and always under data-theme="dark". The server writes data-theme and a matching <meta name="color-scheme"> for a user's explicit choice, so the page is drawn in it from the first paint without a script. Login, installer and other signed-out pages follow the device. The editor's site preview keeps the site's own colours. Both palettes keep every text colour at WCAG AAA (7:1) against the backgrounds it is used on; a test checks the pairs. A colour theme other than Blue is written as <html data-accent="teal"> and overrides only the accent family (links, buttons, focus, hover rows) and the side menu and top bar, with one block for light and the same dark block twice, like the base palette. Every theme is tested at 7:1 in light and dark; Profile previews a theme as soon as it is picked (admin.js) and keeps it on save. The admin's language is the user's choice, else admin_language (Settings, or site/config.php), else the browser's Accept-Language, else English; the login page uses the last three. Translations are plain PHP arrays in src/Admin/lang/<code>.php, keyed by the English text ($t('Log out')), so English needs no file and a missing translation falls back to English; a test checks that every text has a translation with the same placeholders and tags. Times are rendered as <time>: in the chosen zone on the server, or in UTC for admin.js to show in the browser's zone. These are admin-only: the public site's languages and strings are unaffected.
8.1 Drafts, staging, publishing and history
your draft ──submit──▶ staging (shared) ──publish──▶ site/ ──build──▶ public/- Drafts. Every admin user and every assistant token has its own draft in var/drafts/<owner>/: a copy of what they see (staging if open, otherwise site/) plus a base snapshot. Edits only touch the draft, so nobody sees anyone else's unsubmitted work. Untouched files follow upstream automatically (rebase), so a draft always shows the latest staged and published state plus the person's own changes. A draft with no changes left is deleted.
- Submit copies only the files the draft changed into staging (var/staging/, opened from site/ on first use) and records who submitted what, with an optional summary. If someone else submitted a change to the same file meanwhile, that's a conflict: the person can take their version (revert those files in the draft) or submit theirs anyway. Assistants get an error telling them to re-read and redo.
- Staging is the shared, reviewable next version of the site, with a stable preview link, diffs, the submitters' summaries, validation problems and the redirect report. Every submit (person or assistant) builds the staging preview straight away. Anyone who can edit can publish or reject it (decided 2026-11-25). Reject discards staging; drafts stay. Single changes can be taken off staging again ("Undo", staging-revert): the file returns to the live version.
- The Review screen is written for clients first (2026-11-25): a draft → staging → live strip, then each change in plain words (Content\ChangeList: "About us (English)", "Stylesheet: site.css"), grouped (pages, site-wide text, menu and settings, design, images). JSON content shows the fields that changed, short values as old → new and long texts as a word diff with a few words of context; templates and styles show added/removed line counts. Each change has Edit (pages: opens the editor, the edit lands in the draft on top of staging) and Undo. File paths, build warnings and line diffs sit under "Technical details".
- Publish checks the staging revision (no blind publishing of something that changed during review), validates, takes a safety backup, records history, copies the changed files into site/, builds live, and optionally commits site/ to Git ('git' => ['commit' => true]; run without a shell, never pushes). Files changed in site/ since staging opened (a restore, a rollback edit) are conflicts that need "overwrite". redirects.json is always merged by from, because live builds add automatic redirects.
- History (like WordPress revisions, but for every file, templates included): each publish stores the old and new version of every file it changed in var/history/<id>/{before,after}/ with who submitted which files (and their summaries), who published it, and the live build it produced. The History page lists publishes, per-file history and diffs. "Undo this publish", "Undo just this file" and "Restore this version" put those versions into the person's draft, so they go live through the normal submit and publish. Configurable: 'history' => ['keep' => 200, 'days' => 0] (last N publishes / max age, 0 = no limit), or 'history' => false.
- Live viewer links show the client changes as the editor makes them. They work like shareable previews of the editor's draft, valid for a day, but every rebuild also writes a static version.json next to the preview. viewer.js fetches it every 2.5 s while the tab is visible and reloads at the same scroll position when it changes. No PHP, websockets or extra service. Collaborative editing may come later.
- The editor has a language switcher. Edits apply to the language being viewed, and a "missing translations" list shows pages without a file for some language.
- Renaming a page (changing its slug) is allowed for admins, and the redirect is created automatically (6.1).
- Image upload checks the MIME type, re-encodes through GD (which strips EXIF and payloads), and generates responsive sizes and WebP.
- Undo a publish (History → Undo a publish, admins only, the old Builds page): every live build is kept in var/builds/, and rolling back swaps an earlier build in at once. Content isn't changed, so the next publish builds from it again. To bring old content back, use History → Changes instead.
- Shared links (Pages → Shared links, admins only): every shareable preview and live viewer link that hasn't expired, who made it, and Revoke.
- Submissions and subscribers (editors and admins): the stored form entries with the result of each action, CSV export, and deleting (admins). Failed actions are re-run by php lou retry (cron). Submissions has an unread badge in the side menu. Opening a submission marks it read; each one can be marked read or unread, and "Mark all as read" clears the list (or the form it is filtered to). Read state is shared by everyone who can see submissions, like a team mailbox, and the first reader is shown. Databases from before this start with every existing submission read.
8.2 Backups
There's a single-file backup and restore of everything that makes up the site.
- Create: php lou backup or Backups → Create backup in the admin produces one lou-backup-<site>-<date>.zip containing:
- site/ (content in all languages, templates, assets and uploaded images, menu, redirects, config)
- lou.sqlite: a consistent snapshot taken with VACUUM INTO, so it's safe while the site is live (submissions, subscribers, audit log)
- manifest.json: Lou version, date, file list with SHA-256 checksums, languages
What goes in: a backup is made of parts, and the admin (Backups → Create backup: a checklist with each part's current size, then "Start backup now") or php lou backup --parts=… / --exclude=… picks them:
- content: pages, site texts, menu, redirects, config.php
- media: editor uploads (site/assets/uploads/)
- design: templates/ and the rest of assets/
- database: the SQLite snapshot
- history: the edit history (var/history/), left out by default because it only matters for undoing old changes and can grow large
- themes: stored themes (var/themes/), when there are any
The manifest lists the parts a backup holds (history and themes only when there were some, so restoring elsewhere never wipes them). Backups from before parts existed count as content, media, design and (when it was there) the database. The Backups list shows "Everything" or "Partial" plus what's in it. Safety backups before a publish or restore always hold the default parts, plus whatever the restore replaces.
- Encoding: file names are stored as UTF-8 with the zip UTF-8 flag set (PHP's ZipArchive/libzip does this automatically, verified with Hungarian accented names). File contents are binary-safe. Uploaded files also get ASCII-normalised names (árvíztűrő.jpg → arvizturo.jpg), so third-party unzip tools never matter.
- Secrets (.env.php) are excluded by default. They can be included only with a password, in which case the zip is AES-256 encrypted via ZipArchive.
- Restore: an upload in the admin, or php lou restore <file>. Lou validates the manifest and checksums and automatically backs up the current state first. The admin restores into staging (refused while something else is on staging), so you get a preview link and a redirect report before anything goes live, and publishing it works like any other change. Because a backup is a zip anyone could have made, its templates and config.php get the same TemplateGuard checks as an assistant's, and dotfiles or PHP outside templates/ and config.php are refused. Partial restores: only the parts the backup holds and that are ticked (Backups → Restore a backup, or --parts=… / --exclude=… on the CLI) are replaced; every other part stays as it is (missing parts of site/ are taken from the live site before it goes to staging). Edit history and stored themes from a backup get the same checks (no dotfiles, PHP passes TemplateGuard). The database, edit history and stored themes are restored right away; when only those are restored, nothing goes to Review. The installer only seeds a site from a backup that holds both content and design. The CLI restore needs shell access and replaces site/ directly.
- Scheduled: an optional cron (php lou backup --keep=14, add e.g. --exclude=media for a lighter nightly) keeps the last N backups in var/backups/ (outside the web root). Backups are also downloadable from the admin.
- Builds (public/) are not backed up, because they're always regenerated from the backup.
8.3 Maintenance mode
Admins can take the site down for visitors for a while (the switch in the top bar opens Admin → Maintenance mode; php lou maintenance on|off on the command line). Options: how long (until turned off, or 30 minutes to a day; with a time set it ends by itself) and a message per language. State lives in var/maintenance.json, a server setting that site files and assistants can't change (Build\Maintenance). Everything visitors get is static: no PHP runs for them.
- The page. While it is on, the live site (and every live build) holds <endpoint>/m/<lang>/index.html, rendered from templates/maintenance.php, else templates/error.php, else a plain page, with an .htaccess there that answers 503 with that page as ErrorDocument and Retry-After (the end time as an HTTP date, or 3600 seconds), and drops the endpoint folder's X-Robots-Tag: noindex. Search engines keep the pages and come back.
- Apache and LiteSpeed. Every live build writes a marked region into the web root's .htaccess (# LOU:MAINTENANCE in stubs/.htaccess). Turning it on or off rewrites only that region of the live file (atomically, no build; a site built before the region existed is rebuilt once). While on, every request outside the endpoint folder, assets/ and .well-known/ is rewritten to <endpoint>/m/<lang>/ by language prefix, unless the pass cookie holds the random key of this maintenance period (new each time it is turned on) or, with an end time, %{TIME} (the server's local time, taken from the system zone) has passed it. So it ends without cron.
- nginx and Caddy don't read .htaccess. The admin's Technical details show a one-time snippet (Maintenance::nginx(), ::caddy()) that only checks whether <endpoint>/m/on exists and whether <endpoint>/m/pass-<cookie> does, so switching needs no reload. They ignore the end time: the admin, the next publish or php lou maintenance (cron) turns it off afterwards.
- Signed-in people see the live site: while it is on, the admin's site link goes to maintenance.php?pass=…, a signed, 12-hour link (HMAC with the app key) that sets the pass cookie (HttpOnly, host-only, no __Host- prefix because nginx can't name it) and goes home. That stub is the only PHP involved, and only admins open it. Previews, forms and the admin are in the endpoint folder and are not affected.
- Tidying up. Once the end time has passed, the next admin page, CLI call or build turns maintenance mode off for good (heal()).
9. LLM bridge
Goal: any assistant can restructure the site, and nothing goes live without approval.
Flow
- The assistant connects to the site's bridge endpoint (/_lou/mcp.php).
- It reads the site: pages, templates, menu, styles.
- It proposes changes. These are written to its own draft (a copy of site/, see 8.1), never to site/ directly.
- Lou builds staging into a preview at a secret, expiring URL (/_lou/p/<random token>/, a static build, see section 8). The link is shareable, so the client can see it without logging in. It expires after 7 days by default and can be revoked from the admin.
- It submits the draft to staging. A human reviews the diff, the preview and the redirect report (see 6.1) in the admin, then clicks Publish.
- Publish copies the staged files into site/, keeps history, logs the change, optionally commits to Git, and builds live. Reject discards staging.
On and off (Settings → MCP)
- Off by default. While it is off, mcp.php, oauth.php and the /.well-known/oauth-* addresses answer every request with the live site's own 404.html, like an address that doesn't exist, so the public site doesn't reveal that it has an assistant bridge. Nothing is deleted: tokens, grants and app credentials work again once it is back on.
- An admin turns it on for 1 hour, 4 hours, 1 day, 7 days or until turned off (Settings → MCP, the AI assistants page, or "turn on MCP" next to Create token / Create app credentials), and off in one click from the top bar, which shows the status to admins (and to editors while it is on). The time limit is checked on every request (Lou\Bridge\McpSwitch), so no cron is needed. Every change is audit-logged.
- Options, applied while it is on: tools that change the draft (off makes assistants read-only: write_site_file, delete_site_file, upload_site_image, build_preview, submit_for_review, discard_changes), the publish history tools, signing in (OAuth), tokens, tokens in the address (?key=) and the REST fallback. At least one of signing in and tokens stays on. Switched-off tools are left out of tools/list and the OpenAPI document, and calling one returns an error result.
- Stored as mcp in var/settings.json (a server setting; site/config.php can't set it). 'mcp' => false in .env.php keeps it off for good. CLI: php lou mcp status|on [--for=2h]|off.
- Updates. Installs from before this setting have no mcp entry. The first time it is read it is written once: on (with kept_on, explained on the page) when the site already has a bridge token, a grant or app credentials, so an update never cuts off an assistant in use; off otherwise.
Protocols
- MCP (primary). public/_lou/mcp.php implements the Model Context Protocol's Streamable HTTP transport: JSON-RPC 2.0 over POST, with plain JSON responses and no SSE stream (GET answers 405). Supported protocol versions: 2025-06-18, 2025-03-26 and 2024-11-05. Methods: initialize, ping, tools/list, tools/call. Batches and notifications are accepted.
- Tools: describe_site (start here: content model, $v helpers, rules, pages, templates, forms, changeset state), list_site_files, read_site_file, write_site_file, delete_site_file, upload_site_image (re-encoded to WebP into staging), build_preview (returns the preview URL, warnings and the redirect report), get_changes (diffs, problems, conflicts), submit_for_review (with a summary for the reviewer), discard_changes. Read-only history (marked readOnlyHint, not audit-logged): list_site_updates (publishes newest first with who submitted them, person or assistant, their summaries and files, who published them, when, and the live build id; filters limit, since (a date, date-time or "7 days ago") and path; plus other live-site events from the audit log (rollback, rebuild, Lou update, restore, rejected staging) and what is waiting for review) and get_site_update (id or "latest": each changed file in plain words via ChangeList, field old → new; diff: true adds unified diffs, cut at 20 KB per file; optional path). They only show site files and actor names, never tokens, secrets or form submissions. Tool failures are returned as results with isError: true so the model can fix them. The file tools were called list_files, read_file, write_file, delete_file and upload_image until Copilot Studio turned out to route read_file to its own built-in file reader; the old names are still accepted but no longer listed.
- Lenient arguments. Clients disagree on how they send tool arguments (Copilot Studio and OpenAPI connectors especially), so tools/call and the REST fallback accept them as a JSON string, wrapped one level deep ({"body": {…}}), under params.input/params.parameters or next to name, with other spellings of a parameter (filePath, file_path, Path, a few aliases), {"value": "…"} objects, and JSON file content sent as an object. Declared names always win and unknown keys are dropped. A missing argument error names the keys and types that arrived (never the values), and the same line goes to var/error.log.
- Auth, way 1: signing in (OAuth 2.1). Lou is its own authorization server (Lou\Bridge\OAuth, oauth.php in the endpoint folder), following the MCP authorization spec, so Claude, ChatGPT, Copilot Studio, VS Code and Gemini CLI connect with just the bridge URL:
- A 401 from mcp.php carries WWW-Authenticate: Bearer resource_metadata="…/oauth.php?well-known=oauth-protected-resource" (RFC 9728). The issuer is the site address; its RFC 8414 metadata is at oauth.php?well-known=oauth-authorization-server, and the web root's .htaccess rewrites /.well-known/oauth-authorization-server, /.well-known/oauth-protected-resource and /.well-known/openid-configuration there (so the host's own .well-known folder is never touched).
- Clients register themselves (RFC 7591, oauth.php?register, 20 per hour per IP, unused ones forgotten after 7 days), or an admin creates app credentials (client id + secret) for apps that ask for them, such as Copilot Studio's Manual mode. Redirect URIs: https, http only on loopback (any port, RFC 8252), or an app scheme; matched exactly. App credentials made without a redirect URL learn it from the first approved sign-in.
- Authorization code + PKCE (S256). PKCE is required for public clients and optional for clients that authenticate with their secret (Copilot Studio's Manual mode sends none). oauth.php?authorize forwards to the consent screen at oauth.php?r=authorize: the admin's own login, two-step login and consent screens, served by oauth.php so the admin's secret address stays secret. Only those screens exist there, the login form only after a valid sign-in request, with no password reset link and no admin menu; it returns to the consent screen after login. Only editors and admins can approve, since they can publish what an assistant submits anyway. The consent screen names the app (marked as self-registered) and the host the browser goes back to. Unknown clients and unregistered redirect URIs get an error page, never a redirect. After approval the browser is sent on with a Refresh page, not a 303, because browsers apply the admin's form-action 'self' to redirects after a form post.
- One grant per app and person, named "App – user": the assistant's name in drafts, Review and the audit log. Access tokens (louat_) last an hour, refresh tokens (lourt_) 90 days and rotate on every use; a rotated refresh token sent again after 60 s ends the grant. A grant stops working while its person is removed or below editor, and ends when they change their password or sign out everywhere. Grants are listed and disconnected under Users → AI assistants; RFC 7009 revocation at oauth.php?revoke. Clients, codes, grants and tokens are in SQLite (migration 2); secrets, codes and tokens only as SHA-256 hashes.
- Auth, way 2: bridge tokens for clients that can't sign in: per-assistant bearer tokens (lou_ + 192 random bits), created under Admin → Users → AI assistants or with php lou token add NAME, stored as SHA-256 hashes in var/tokens.json, revocable. ?key= is accepted for clients that can only take a URL.
- Browser Origin headers must match base_url (or bridge.allowed_origins); oauth.php answers CORS from any origin since it uses no cookies. Failed auth (20 per 15 min per IP), failed token requests (30 per 15 min per IP) and calls (300 per 10 min per assistant) are rate-limited.
- REST fallback. POST /_lou/mcp.php?tool=<name> with a JSON object body returns {"ok": true, "result": …}. GET /_lou/mcp.php?openapi describes it (OpenAPI 3.1, generated from the same tool definitions).
Drafts for assistants
- Each token or signed-in assistant works in its own draft, exactly like an admin user (8.1). build_preview builds that draft at a stable secret link, submit_for_review moves its changes to staging with a summary, and discard_changes deletes the draft. Publishing happens in the admin.
Guardrails
- The bridge can only write inside site/: templates/, content/, assets/, config.php, menu.json, redirects.json. Paths must be ASCII, with no dotfiles and no ... PHP is only allowed in templates/ and config.php. Text files only (php, json, css, js, svg, txt, md, html), images via upload_site_image. Max 512 KB per file, valid UTF-8. code.json (custom code) can be read but never written or deleted.
- Template PHP is checked against an allowlist (tokenizer based, not a deny-list), because it runs at build time on the server. Allowed: $v->… calls, plain variables, loops and conditions, and a list of pure string, array, math and date functions. Rejected: any other function, new, static calls, include/require, eval, backticks, superglobals, closures, variable variables and functions, calls whose callee is a value ('f'(), ('f')(), $a[0](), $v->field('f')()), first-class callables f(...), dynamic member names, method calls on anything but $v. Parse errors are reported.
- JSON must parse. SVG must not contain scripts, event handlers, javascript:, foreignObject or entities. config.php must return an array, and the whole staged site must load (Site::load) before a preview or approval.
- Every write is audit-logged (source = 'llm', actor = token name).
10. Security model (summary)
- The public surface is static files plus _lou/*.php. .htaccess denies execution of any other PHP under the web root.
- .htaccess sets a strict CSP, HSTS, X-Content-Type-Options, Referrer-Policy and Permissions-Policy, and gives assets long cache lifetimes with hashed file names.
- The live CSP can be strict (default), report-only or off (Settings → Security); custom code widens it only by the hashes and sources it needs. The admin folder and previews always keep their own strict policy.
- Secrets live outside the web root: .env.php, plus var/secrets.json (0600) for the SMTP settings saved in the admin. Passwords are never echoed back.
- The admin's login page has a secret address (7); every other address in the endpoint folder shows the site's 404 page.
- Admin logins: hashed passwords, rate limits, invites instead of admin-set passwords, optional or required two-step login (8). Assistants sign in with OAuth 2.1 + PKCE or use revocable bridge tokens (9), and never publish.
- Updates are verified against release.json and its Ed25519 signature before any file is replaced (6).
- Settings that would weaken security (csp, require_2fa, endpoint_dir, admin_slug, admin_host, cloudflare_access, mcp, unsigned updates, the update channel) live in var/settings.json or .env.php, never in site/, so an assistant's draft can't change them.
- The assistant bridge is off until an admin turns it on (9), optionally for a limited time, and answers like a missing page while off.
- Every write path (editor, bridge, forms) is authenticated or rate-limited, validated and logged.
- Preview tokens are 128-bit random, expire, can be revoked, and are sent with X-Robots-Tag: noindex.
- The admin can be limited to its own address, behind Cloudflare Access with a verified token (8).
11. Requirements
- PHP 8.3+ with pdo_sqlite, gd (with WebP), curl, mbstring, zip, dom and openssl. Recommended: sodium (checks the signature of updates; in PHP by default), intl and exif. php lou check and the web installer list what's missing.
- Apache with .htaccess (or the equivalent nginx rules, documented).
- Write access to var/ and to the parent of public/, for the atomic swap.
12. Status and roadmap
Built (0.4):
- The static builder, $v templates, languages, automatic redirects (with CSV/Excel import and export), the CLI and CI.
- Forms: one submit endpoint, SQLite, SMTP via PHPMailer, Mailchimp, MailerLite and webhook newsletter sign-ups, spam protection and captcha.
- Admin: inline editor with undo/redo, drafts, staging, Review, History with undo, rollback, Site details, repeatable pages, users with roles, invites and two-step login, profiles and admin languages (English, Hungarian).
- LLM bridge: MCP and REST, OAuth 2.1 sign-in and bridge tokens, history tools, the template allowlist.
- Theme page and theme library, custom head/body code, the Security page (CSP), search engine tags and checks, IndexNow, backups made of parts.
- Install and updates without Git: release zip, web installer, signed updates with a daily check, and an opt-in main update channel.
- Login brute-force protection, a built-in proof-of-work spam check, error pages in the site's design, a secret admin address (and optionally an address of its own behind Cloudflare Access), maintenance mode, MCP off by default, menu/header/footer editing, unread submissions, admin dark mode and colour themes.
Planned or under consideration:
- More mail transports (Amazon SES, SendGrid).
- Collaborative editing.
- Search engine extras (6.2, "Later").
- Publishing the static build to static hosts (GitHub Pages, GitLab Pages and similar).
13. Open questions
- Translation workflow: should the admin show the languages side by side? Could an assistant draft missing translations into staging?
- Git commit identity and push target for installs that commit site/ on publish.
This page is generated from docs/SPEC.md in the Lou repository, so fixes go there. View the source on GitHub