Files
loki/scripts/site-template/lib/fleet.ts
CatoandClaude c83c8f473e feat(starter): kickoff and new-site.sh both produce the fleet starter (#1138)
scripts/site-template is now bitbaum/fleet templates/app — Next.js 16,
better-auth accounts (password, link, passkey, 2FA, OrangeCat/bitbaum sign-in
as env-gated OIDC), en/de/fr, nonce CSP, ai-kit/mail-kit/limitkit/bip-kit,
tests and CI — copied at a pinned fleet commit by
scripts/templates/sync-starter.sh. CI proves the copy is exact
(sync-starter.sh --check), and starter-sync.yml opens the PR when fleet's
starter moves. Never edited here.

The kickoff's "nextjs-tailwind" starter seeds the same app from
src/lib/starter-app.generated.ts (generated from the directory, pinned by
scripts/test/starter-app.ts), minus the workflows register-site.sh adds with
the site's CD. The repo is seeded in one Trees API call with inline contents
instead of a blob POST per file (~85 for this starter). The widget token rides
in .env.production; the starter's .gitleaks.toml allows NEXT_PUBLIC_* values.
The new-from-scratch picker reads the light template list, so the starter's
file bodies never reach a client bundle.

Both paths give the site its database and auth/seal secrets ON THE BOX
(scripts/hetzner/provision-db-on-box.sh: role + database, ~/.db-credentials,
/opt/<slug>/shared/.env; existing secrets never replaced; nothing printed), and
record the db in the register row so every deploy applies drizzle/.
register-site.sh seeds the starter's full workflow set to starter repos and
the golden CI floor to anything else, never overwriting another repo's ci.yml.

test-site-template.sh follows the starter (verify SSOT, design tokens instead
of a local palette) and its comment stripper is fixed: the sed range deleted
the page from the doc comment to EOF, so every day-zero check had been passing
against an empty string. check-template-contrast.mjs and the starter-lock
generator are retired with the files they checked.


Claude-Session: https://claude.ai/code/session_01W7K2Gm5wcbfCi7THtmV1Hy

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 13:39:14 -07:00

39 lines
1.5 KiB
TypeScript

import { loadDevelopmentProfile, type DevelopmentProfile } from "bip-kit";
import { FLEET_MAP_URL, SITE } from "@/lib/site";
/**
* The roadmap and changelog, read from where they are produced.
*
* This repository's ROADMAP.md and CHANGELOG.md are the source; Loki ingests
* them into the product's profile and publishes it on the fleet map. The site
* renders the map, so there is no second copy for a page to drift from (fleet
* AGENTS.md, "The identity contract"). When the map cannot be read — or does
* not know this product yet — the page says so and links the files on GitHub.
*
* Remembered per process, failures included, so a page about the product
* never stalls the product while the map is down.
*/
const HIT_SECONDS = 300;
const MISS_SECONDS = 60;
const TIMEOUT_MS = 4_000;
let remembered: { until: number; value: Promise<DevelopmentProfile | null> } | null = null;
export function loadDevelopment(): Promise<DevelopmentProfile | null> {
const now = Date.now();
if (remembered && remembered.until > now) return remembered.value;
const fetcher: typeof fetch = (input, init) =>
fetch(input, {
...init,
signal: AbortSignal.timeout(TIMEOUT_MS),
next: { revalidate: HIT_SECONDS },
});
const value = loadDevelopmentProfile(FLEET_MAP_URL, SITE.slug, fetcher).catch(() => null);
const entry = { until: now + TIMEOUT_MS + 1000, value };
remembered = entry;
void value.then((profile) => {
entry.until = Date.now() + (profile ? HIT_SECONDS : MISS_SECONDS) * 1000;
});
return value;
}