Files
loki/scripts/site-template/package.json
CatoandClaude Fable 5.1 71762e4649 fix(cold-start): register lands deploy.yml; scaffold installs/builds/serves (#585)
* fix(register): a site registered from the box gets its shim, its port, and its builder

Walked the cold start on production after #569 (velokiosk-sep10). The repo
was seeded; then four defects on the register-and-run path:

- The OAuth grant had no workflow scope, so GitHub refused to write
  .github/workflows/deploy.yml and register-site.sh carried on saying the
  remote may already have it. The grant now requests workflow; the script
  falls back to the host's own gh login for the shim and fails when the file
  is not on the remote.
- box() named no SSH identity; ubuntu's only key is the CI deploy key, so the
  box refused itself. box() passes DEPLOY_KEY_PATH when readable.
- The durable register was behind main and handed out a port main had already
  given away. Ports and conflicts are read from both registers, the durable
  checkout is fast-forwarded when all its rows are on main, and every new row
  goes to main as a PR.
- A dirPath under the box clone root was routed to the operator's laptop
  because it was present; that runner cannot clone on demand and reported
  "inject did not stick". projectChannelLock returns cloud for box-rooted
  workspaces.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w

* fix(scaffold): a new site that actually installs, builds and serves

Diplodoctor was scaffolded on 2026-09-10, provisioned completely — repo,
systemd unit, Caddy vhost, register entry — and served 502. Its session
diagnosed it and fixed it IN THE DIPLODOCTOR REPOSITORY. The template was left
exactly as it was, so the next site would have rediscovered the same three
faults from scratch. This is that fix moved to where it belongs.

The template was never internally consistent about its package manager. It
shipped no lockfile at all, yet its CI ran `npm ci`, which REQUIRES
package-lock.json — so a freshly scaffolded site's CI could not pass on its
first commit, or any commit. Meanwhile the box deploys with `pnpm run build`.
Two managers, one repo, and the half that ran in production was not the half CI
described. Everything here converges on pnpm, which is what actually ships.

  pnpm-workspace.yaml   NEW. `allowBuilds: sharp, unrs-resolver`. pnpm 11
                        refuses to run a dependency's build script unless it is
                        approved and EXITS NON-ZERO when one is not, so without
                        this a fresh clone cannot install and the deploy dies
                        before the build. It must not go in package.json's
                        `pnpm` field: pnpm 11 no longer reads that field and
                        ignores it with a warning, which makes the setting look
                        present while doing nothing.
  .nvmrc                20 -> 22. pnpm 11 imports node:sqlite, absent before
                        Node 22.13. Harmless while CI used npm; fatal the moment
                        it uses pnpm.
  ci.yml                npm -> pnpm throughout, and the Next cache key now
                        hashes pnpm-lock.yaml instead of package-lock.json — a
                        file that never existed here, and hashFiles() returns
                        an empty string for a missing path, so the key was
                        constant and the cache could never invalidate.
  package.json          `verify` uses pnpm; `packageManager` pins pnpm@11.25.0
                        so a stray `npm i` cannot mint a second lockfile.

Two things this also fixes that were not in diplodoctor's repair.

**The scaffold now resolves a lockfile into the first commit.** Without one the
repository is born unbuildable in two places at once: CI's
`pnpm install --frozen-lockfile` refuses to invent a lockfile, and the box
resolves versions afresh on every release, so the site that was verified is not
the site that ships. `--lockfile-only` keeps this to a few seconds and unpacks
no node_modules.

**next 16.2.4 -> 16.3.4.** The template was minting every new site with a
CRITICAL unauthenticated RCE — GHSA-2xp9-vwfh-vxw4, the Next image-optimization
hole, patched at >=16.3.3. orangecat was patched for this today; the scaffold
would have kept issuing fresh vulnerable sites afterwards.

**And the port race, which nearly shipped an hour ago.** Ports are allocated
from `apps.conf` in a LOCAL checkout, and this studio runs five to ten agent
sessions at once, each in its own worktree. A stale copy reports a stale highest
port. A dry run in one such checkout offered 4024 for a new site while origin
already had diplodoctor on 4024 and heidi on 4025 — two sites, one port, caught
by hand one command before it would have shipped. The script now fetches and
REFUSES when its register differs from origin/main, naming the pull that fixes
it, rather than guessing a number another session already took.

Verified: `bash -n` clean; a dry run against an up-to-date register allocates
4026 and the staleness guard passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY

* chore(register): causius on 4026 — the first site the fixed scaffold built

causius.orangecat.ch is live: systemd active, HTTP 200, its own certificate, on
the first deploy. Diplodoctor needed two follow-up pull requests to reach that
same state yesterday; this one needed none, because the template was repaired
before it was used rather than after.

Registered as `product` / `validating` — ours, and not yet claiming to be a
live client engagement, so the client-ledger gate is satisfied without inventing
terms for something that has no customer.

Port 4026 came from a register that the new staleness guard had just verified
against origin. The stale local copy this was first attempted from offered 4024,
which diplodoctor already holds.

Deliberately NOT bought: causius.com and causius.ch are unregistered and stay
that way for now, by George's call. The site therefore lives at its free
orangecat.ch address, which is exactly the ladder /domains sells — start free,
move to your own domain later, keep every link alive. Dogfooding it means the
first customer of that offer is us.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY

* fix(scaffold): site-template CI floor test expects pnpm

The scaffold now installs with `pnpm install --frozen-lockfile` (#583 onto
main). The floor test still demanded `npm ci`, so verify would fail every
run after the template switch even though the template itself is correct.

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 15:00:27 -07:00

30 lines
656 B
JSON

{
"name": "__SLUG__",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint .",
"type-check": "tsc --noEmit",
"verify": "pnpm run type-check && pnpm run lint"
},
"packageManager": "pnpm@11.25.0",
"dependencies": {
"next": "16.3.4",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.3.4",
"tailwindcss": "^4",
"typescript": "^5"
}
}