* feat(previews): a preview is the whole of its own address, and a finished site can be brought in
"create website for Murphy's Bar" now ends at murphys-bar.orangecat.ch, behind
the access code, with the widget on it.
- attach-preview-host.sh + lib.sh preview_vhost: a Caddy vhost per preview.
Wildcard DNS already points every label at the box, so there is no record
to set. "/" opens the entry file, everything else moves under /p/<label>/,
and X-Preview-Root tells Loki the preview is the root
- handle.ts: with that header the cookie is scoped to "/", the gate posts to
"/", and the widget loads from Loki's own origin
- createPreview takes an address (default: the name) and attaches the host,
falling back to the /p/ path with the reason when the server cannot
- Build a preview takes a .zip of a finished site (unpack.ts: no unsafe paths,
no symlinks, no .git, byte-counted) and commits it as it arrived
- Docs: prospect-previews.md ("Its own address", "A site that already exists",
"Create website for <name>") and the standing flow in CLAUDE.md
- Tests: previews, previews-route (own-address cases), preview-unpack,
test-preview-host.sh (in test:ops)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc
* fix(previews): read the base domain from its one source
address.ts read SITES_BASE_DOMAIN itself; the env-example test caught that
the variable Loki actually reads is LOKI_SITES_BASE_DOMAIN, owned by
site-cd.ts sitesBaseDomain(). Use that.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat(previews): build a site for someone before they are a customer, with no repository
A prospect is now a folder on the box, not a GitHub repository. Loki builds
a first version of their site there, serves it privately behind the studio's
access code, and puts its feedback widget on every page so they can say what
to change. The folder has its own local git history and becomes a real
repository only when they say yes. A thousand prospects cost a thousand
folders, not a thousand repositories.
- Projects -> "Build a preview" (POST /api/previews): creates the folder
(git init), a project pointing at it with no gitUrl, a widget key, and
dispatches the build brief to the box.
- The build brief (src/config/preview-brief.ts) holds the standing rules
learned on the first preview: public sources only, nothing invented,
"coming soon" for what is missing, relative paths, phone-first checks,
images that never stretch, commit locally and never push.
- /p/<slug>/... serves the folder. The code (LOKI_PREVIEW_CODE, one value for
all previews) is checked on every request, pages and files alike; the
cookie carries a fingerprint of the code, so changing the code closes every
earlier visit. .git and anything outside the folder are never served; pages
are noindex and no-store. Unset code = previews say they are off.
- Preview folders are locked to the cloud builder: no other machine has them.
- docs/architecture/prospect-previews.md: the design and the plan per repo
(graduation, archive, preview list, shared site kit, the audit gate, the
neighbourhood sweep and its outreach rules).
Tests: previews.ts (62 rules: slugs, path safety, code, cookie expiry and
code change, widget injection, brief), previews-route.ts (25 paths through
the route on real Request/Response), public-matcher pins /p/ public and /p,
/projects, /prompts, /api/previews protected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc
* fix(previews): keep the shared demo account out of /api/previews
It makes a folder on the box and dispatches an agent, so it belongs with the
other dispatch routes the demo sandbox denies (scripts/test/demo-sandbox.ts
requires every API family to be classified).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpakL9C3TESU4H45fXMFfc
---------
Co-authored-by: Claude <noreply@anthropic.com>