Skip to content
Kevin Liu's WikiSearch

kevin-wiki / ui

Purpose

The web viewer. A Next.js (App Router) app that renders the wiki/ markdown knowledge base as a browsable site, plus the private local /brief decision surface. Wiki content remains read-only; /brief writes only to the local Daily Brief event store through its gated API. Tailwind owns styling; the public wiki is deployed on Vercel.

Mental model & key files

  • src/app/(wiki)/ — the wiki reader (home, wiki/[...slug], packs, search), rendered statically for an anonymous viewer; src/app/unlocked/ is its twin for unlocked viewers (see "Static rendering and the twin").
  • src/app/(wiki)/system/ — public brain/system projection.
  • src/app/(wiki)/brief/ — global-password-gated local Daily Brief client.
  • src/app/api/ — og (per-article OpenGraph images: title, subtitle and byline, with no eyebrow and no tagline, like home's card), search, assets, unlock, public system, public OKF v0.2, private brief, and bearer-authenticated proposal-memory routes.
  • src/components/atlas/SKILL.md — the Atlas map and the /graph cloud.
  • src/components/, src/lib/, src/contexts/ — shared UI, helpers, providers.
  • src/lib/privacy-policy.json + src/lib/gating.ts — shared fail-closed public/private policy for runtime and bundling.
  • scripts/ — build-time content bundling + citation checks (see ui/scripts/SKILL.md).

Patterns to follow / invariants

  • Tailwind + cn() first; raw CSS only in globals.css. No co-located CSS modules for ordinary UI (see wiki/style/css-ui-enforcement.md).
  • Follow wiki/style/react.md + wiki/style/typescript.md; check vercel-react-best-practices for data fetching / perf.
  • Package manager is pnpm here (the repo root is npm/tsx). Run from ui/.
  • Keep the full-text search index out of server-rendered page props. Public search loads the privacy-filtered /search-index.json static asset; unlocked search uses the bounded /api/search?view=page response.

Static rendering and the twin

  • Every public page is static. The (wiki) layout and pages read no cookie and render for ANONYMOUS_ACCESS (src/lib/auth.ts): home, /packs (the gate), and wiki/[...slug], which prerenders every public page, every folder that holds one and every public README's redirect (getPublicWikiPaths). With dynamicParams = false, every other path, a private slug included, is Next's one static 404: the same status, headers and body for every path, and no page code runs for it. packs/[pack] prerenders nothing and sets dynamicParams = false too, so every anonymous /packs/<name> is that 404 (its unlock control opens the gate).
  • wiki/[...slug]/page.tsx is a dispatcher: a page renders ArticleView (src/components/article-view.tsx), a category or folder with a page the viewer can open renders CategoryIndex (src/components/category-index.tsx), /wiki/<folder>/README 308s to the folder when the viewer can open that README, and everything else, a private slug included, is the one 404. CategoryIndex renders the README as its lead through ArticleBody (the body and its enhancers: anchors, diagrams, charts, tweets, image guard), as articles and packs do, and leaves the Deprecated skills folder out of the skills index. It prints its own h1 only when the README's HTML does not open with one (HTML comments before it do not count; src/lib/readme-title.ts, scripts/test-readme-title.ts).
  • The twin, src/app/unlocked/**, renders the same modules with the viewer's access (getGateAccess()). Its files only call the (wiki) exports (WikiLayoutView, HomeView, renderWikiPath, wikiPathMetadata, PacksView, PackDetailView, packMetadata) or re-export a page; they hold no markup, so a redesign of the (wiki) modules reaches unlocked viewers. Every twin response is dynamic and sends Cache-Control private, no-cache, no-store; a direct request for /unlocked/** without a valid cookie gets the gate.
  • Why not Cache Components: it needs cacheComponents: true in next.config.ts and changes route segment config across the app; the twin keeps every static page free of request data instead.
  • /brief, /system/sessions and /privacy sit under the (wiki) layout and keep their own gates, so they show the shell's header.
  • On a case-insensitive disk, as on a Mac, a page and a folder whose paths differ only in case (the SOUL page and the soul folder, and three more pairs) prerender to one file, so a local next start serves one of each pair for both URLs, and a local vercel build (or a --prebuilt deploy from it) fails with EEXIST; run those on a case-sensitive volume. Vercel's own builds serve both. scripts/test-case-paths.ts names the pairs in the prebuild and fails under vercel build on such a disk.
  • Static pages do not know about an unlock in another tab. PasswordGate (after an unlock) and WikiShell's lock post on BroadcastChannel("wiki-gate") (src/lib/gate-channel.ts), and WikiShell calls router.refresh() when another tab posts, which reaches the twin.
  • Shell links (the mark, the index, the graph, breadcrumbs) and home's lists set prefetch={false}: a static target's prefetch carries its whole payload, on every page that shows the link.
  • Nothing fades in on load or on open: text painted at opacity 0 is no largest-paint candidate, so LCP waited for the next full repaint, and nothing moves unless the reader moved it. The one motion is the map's pan ("Shell, articles, gates and 404").

Proxy matcher

  • src/proxy.ts runs only where a job applies. Plain entries always run it: /brief and /system/sessions (global unlock or /locked) and the twin path. Every public entry (/, /wiki/..., /search, /packs, /packs/..., /api/search) carries has: [{ type: "cookie", key }], once for "wiki_unlock" (GATE_COOKIE) and once for "wiki_unlock_slugs" (GATE_SLUGS_COOKIE), so an anonymous view of a static page invokes no function. Matcher values must be literal constants; keep the plain entries first (test-route-surfaces reads them).
  • With a valid cookie the proxy rewrites to the twin, and /api/search to /api/search/private (the same handler, private, no-store); an invalid cookie falls through to the static page.

Category JSON

  • The anonymous shell sends the index's category rows only (category, label, count), from getPublicNav() in (wiki)/layout.tsx; the index loads a category's pages when the reader opens it, and the open page's category when the index opens (warmed on pointer or focus on Index).
  • Each category's pages are static JSON at /nav/<version>/<category>.json (src/app/nav/[version]/[file]/route.ts, URL from publicNavUrl in src/lib/public-nav-url.ts; data from getPublicNav() in src/lib/wiki-navigation.ts). version hashes the whole public index, so a URL never changes content. Fields: category, count, label, pages (each private, slug, title) and folders (each path, label, count, pages, children), sorted by label and title. Public pages only; the twin inlines a viewer's private entries.
  • test-public-counts holds home's counts equal to the shell's rows and the sums of the JSON; test-public-independence projects it as nav.

Tokens

  • globals.css "Atlas tokens": --signal (text-signal, bg-signal; #b84019 on paper, #f06a3a on dark), focus-ring (2px solid ink, offset 2px), --measure 30em (max-w-measure; about 64 characters at 17px, as 64ch measured 88 in PP Mori; 510px, which markdown.ts's TEXT_COLUMN_MAX repeats), --motion-duration 240ms with --motion-ease (duration-pan, ease-pan), type steps text-meta 13, text-ui 15, text-body 17 (1.6 line height), text-lead 21, text-h3 27, text-h2 34, text-h1 42 and text-display 64 (1.15 to 1.25), and page-grid (12 fluid columns, 24px gutters, 16px side gutters on mobile).
  • src/lib/dates.ts formatDate prints a frontmatter date as YYYY-MM-DD, with no timezone conversion.
  • node scripts/check-ui-tokens.mjs reports text below 13px (arbitrary px, rem or em sizes too), uppercase with tracking, negative tracking on headings and arbitrary tracking in .tsx under src; --fail exits 1.
  • Theme: the root layout's <head> runs a plain inline script (not next/script, which runs after parsing) that sets .dark or .light on <html> from the stored choice or the system preference before the body paints; theme-context.tsx keeps both classes in step. Until a class is set, globals.css gives :root:not(.light) the dark tokens under prefers-color-scheme: dark; keep that block in step with .dark.

Fonts

  • PP Mori is the site font: woff2 subsets of the OTFs in public/fonts/pp-mori (pyftsubset, no outline changed; a glyph-specimen pixel diff showed 0 changed glyphs), one family, ppMori, from four faces: a core file per weight (Latin, Latin-1, common punctuation, every character a public page title uses) and an extended file per weight that the browser fetches only for a page that uses one of its characters. The extended files go through next/font/local (_fonts/pp-mori.ts), never preloaded.
  • One URL per face: src/app/_fonts/site-faces.ts declares the two PP Mori core files (with the metric-matched Arial fallback next/font computed for 400) and Geist Mono (OFL; public/fonts/site/OFL.txt) once, for every route, as content-hashed files in public/fonts/site; the root layout inlines the rules and globals.css sets --font-pp-mori and --font-geist-mono. site-urls.ts holds the URLs alone, so client code that needs one does not ship the rules. vercel.json serves the folder as immutable (its other /fonts rule excludes site/). Geist Mono is two variable files: geist-mono-core, cut from GeistMono[wght].ttf in the vercel/geist-font v1.7.2 release (Latin, Latin-1, common punctuation, arrows, every box-drawing and block character, and the geometric shapes and math signs code diagrams use), and Google Fonts' 1.701 latin-ext file. One file holds a code diagram's lines and letters, so they never come from different faces, and its unicode-range lists exactly the code points it holds.
  • To add characters to geist-mono-core, edit the code-point list (src/app/_fonts/geist-mono-core.unicodes.txt, one U+XXXX per line) and cut the file again from the same release with fontTools' pyftsubset, default options: pyftsubset 'GeistMono[wght].ttf' --unicodes-file=<list> --flavor=woff2 --output-file=<out> (on the current list it reproduces the current file byte for byte). Rename the file to the first 10 hex of its sha256, put that name on the list's first line, set GEIST_MONO_CORE_URL and set GEIST_MONO_CORE_RANGE to the list's range. The postbuild font check fails until the file's hash, the list and the range agree.
  • PP Mori 400 and 600 are preloaded only by the server render, through one client component, src/app/_fonts/font-preload.tsx: <FontPreload weight={400} /> in the root layout's <head> (every route, the 404, the twin and dynamic routes included) and <FontPreload weight={600} /> in the wiki shell, on /locked and in the 404, outside any Suspense boundary and above every await: the shell (WikiLayoutView) renders it before the async view that reads the viewer's access and the index's data. It calls react-dom's preload() only when typeof window === "undefined" and renders nothing, so React's server renderer emits each preload once and the client never inserts one, on a navigation or on Next's client-rendered error page. A prerendered page carries them in its head's font slot, ahead of the stylesheets and the logo's image preload. A page rendered per request (the twin, its 404 body included, and /search) carries those that render in React's first pass of work in the response's Link header, which the browser reads before the HTML; React writes that header once, after the first pass. A preload that renders later goes to the head's font slot, and on the error page, whose head is empty, nowhere, so the 600 stays above every await, where a fresh instance's first request renders it in the first pass too. The logo's image preload renders in the shell after its data, so it reaches the header on a warm instance only. WebKit does not share a font preload added after the load event with the @font-face load of the same file, so a preload the client adds downloads the face twice; and a <link> rendered in the head lands behind the logo's preload, which delays first paint on a slow connection. A navigation from a page without the 600 preload (/graph, say) into the shell loads the 600 through @font-face alone. A client component's server render never reaches an RSC payload; a <link> or preload() in a server component becomes a font hint in every payload that carries it, and the root not-found page travels in every route's payload. Geist Mono is never preloaded. Next's own font preloads never reached the prerendered 404 or a dynamic route, and next/font names a preloaded file differently from the same file without a preload, so declaring a face there once per route group shipped it as two files. After changing a PP Mori file, rename it to its new hash and update its constant in site-urls.ts.
  • Accepted: Safari Private Browsing downloads the 600 a second time when a soft navigation from /graph or /dev/atlas into the shell is followed by a new document: a reload, a typed URL or /graph's plain link list, prerendered or rendered per request (the twin, its 404 body included, through the Link header). Its memory cache does not reuse a no-cors font fetch for a cors preload. Do not preload the 600 on those pages to avoid it.
  • The font rules live in scripts/lib/font-heads.ts: no payload carries a font hint and no RSC response a font Link header; every font preload is in the Link header or <head>, before the first stylesheet and image preload, for a PP Mori core file on the page's own origin (the URL resolved against the page), once, in React's shape: rel="preload", as="font", type="font/woff2", an anonymous crossorigin ("", anonymous or any value but use-credentials, in any case, as a browser reads it) and an href, nothing else and none twice; the 400 on every page with the root layout; the 600 on the shell, /locked and the 404 and nowhere else; no font preload on a page without the root layout, but for Next's error page rendered for the request (the document whose <html> has id="__next_error__"; a build with a deployment id, as on Vercel, puts data-dpl-id before it), which carries the 400 and the 600 in its Link header and none in its HTML. A prerendered error shell has none wherever it is served from: Vercel serves /dev/atlas's 404 and a README's 308 from the edge with no Link header, and a redirect, x-nextjs-prerender or an x-vercel-cache of PRERENDER, HIT or STALE marks such a response. A document is UTF-8 with no byte order mark, and a served one is labeled text/html; charset=utf-8. A Link header is in React's shape, which every engine splits alike: <url> entries with ; name=value parameters joined by , , names in lower case, each value a token or a quoted string with no quote, comma, semicolon, backslash, < or > (React percent-escapes the first three), and each URL with no <, >, quote, apostrophe or backslash. The reader errs toward red: it walks the head as every engine reads it (comments, the doctype, and the html, head, base, link, meta, script, style and title start tags, with script, style and title text skipped), and the walk ends at </head>, </body>, </html> or </br>, at text, at any other start tag, or at a script that holds <!--. Past that point browsers disagree (Chromium's preload scanner fetches a <link> inside <svg> or <math>), so every font preload after it, in foreign content, a comment, raw text or an attribute value included, is a finding. Past the walk it reads each tag from where the last one ended, so it stays linear in a page's length, and a <link, <base or <html inside such a tag or still open at the page's end is a finding. So are a <base>, an <html> after the head, an attribute in a font preload or <html> with a named reference other than amp, apos, gt, lt and quot, and a repeated attribute in a font preload. Like HTML's tokenizer, the reader lowers attribute names, turns U+0000 into U+FFFD and reads tab, line feed, form feed, carriage return and space as whitespace; as and type must be font and font/woff2 in lower case (WebKit reads them case-sensitively). A finding names a site font file by its file name and any other by its href's length and an 8-character hash, never its text, and the start tag that ended the head by name only from a fixed list (body, noscript, template and the like), else as another start tag. pnpm test:font-heads (prebuild) holds the reader to hand-written documents, each red when any engine may fetch a font against the rules, and to malformed megabyte pages and long runs of whitespace in a Link header within a time bound. pnpm test:font-output (postbuild) holds every prerendered page to the rules, read from its bytes, checks the font files' hashes, that the Geist Mono file's cmap, list and range agree, and that no client chunk names a PP Mori core file or the ppMori Fallback face. The crawl mode of test-public-build-output holds every served answer a browser may render as a document to them, from its bytes and Content-Type (its document test errs red; scripts/SKILL.md), and the pages rendered per request for unlocked viewers (the twin, its 404 body included), so run it with the server's WIKI_GATE_SECRET (scripts/SKILL.md). Without a local build it skips the 400 and 600 placement on crawled pages alone.
  • Geist Mono is never preloaded and uses font-display: optional with the system monospace as its fallback: it never swaps in after first paint, so code never rewraps; a reader's first view of code may use the system monospace, and later views use Geist Mono from the cache.
  • The font switcher exists only in development: the shell loads it with next/dynamic, and it injects public/fonts/switcher.css. Production never restores a switcher font. .vercelignore uploads only public/fonts/site and keeps switcher.css, the switcher's font folders and the PP Mori OTFs out; check with git -c core.excludesFile=.vercelignore check-ignore --no-index.

Diagrams and tweets

  • Every public Mermaid diagram is drawn ahead of the build for both themes: pnpm measure:diagrams (headless agent-browser, the site's fonts and src/components/article/mermaid-theme.ts) writes src/generated/diagrams/<diagramKey>.light.svg and .dark.svg at natural size, and src/lib/diagram-sizes.json. markdown.ts inlines the pair (.mermaid-light and .mermaid-dark, one shown per theme), so the page loads no mermaid. A diagram with no drawing (a private page's, in the twin, or one not drawn yet) keeps data-source, reserves its measured height and draws on the client (mermaid-renderer.tsx, near the viewport). A diagram wider than the 510px column (.mermaid-wide, its natural width in --diagram-w) breaks out at lg over the two empty grid columns left of the text (the margin column holds the crop and contents) and shrinks to fit down to three quarters of its size, its labels to 12px. Past that, and below lg at natural size, it scrolls sideways with a visible scrollbar, a fade at its right edge and a "Scroll →" hint while more of it lies to the right. In print every diagram prints whole, in its light variant at its own width or the page's, with no fade or hint. After adding or editing a public diagram, run pnpm measure:diagrams. The folder is read at run time; where a deployment's function lacks it, diagrams fall back to the client.
  • A ::tweet is a one-line citation, @handle date, a native <details> that opens into the react-tweet card (markdown.ts, tweet-embeds.tsx). It takes its handle and date from the page's [Source: X/@handle, date](url) link to the same post, in the directive's block or after it (one before it cites an earlier claim and stays), and that link goes, so the post is cited once: the punctuation it leaves closes up, and a list item or list it empties goes; a link alone in a table cell stays. The citation sits just before the block that held the link, its handle set in ink with the links' underline. Opened, the card renders after the slot's "Open on X" link, which hides once the card draws and stays when it cannot load. It is built from the Markdown the viewer's mask produced. react-tweet and its stylesheet load only when a reader opens a citation (components/article/tweet-card.tsx).
  • An opened card's slot reserves its measured height (src/lib/tweet-sizes.json, keyed by tweet id: the card at 550px, at a 430px screen and at a 360px screen), in three bands: under 440px the taller phone height, 440 to 639px the taller of the 430px and 550px heights, then the 550px height. After adding tweets to a public page, run pnpm measure:tweets --base <a running site> --missing.
  • The prebuild's pnpm check:embed-sizes warns about any public diagram with no drawing or no height and any public tweet with no size (--fail exits 1), and fails on any key in those files, a drawing's file name included, that is no current public diagram or tweet. scripts/lib/public-embeds.ts reads diagrams from each exact public page slug's masked Markdown and tweets from its citations, never a folder path, which a case-insensitive disk could read as a private page's file.

Cache headers

  • vercel.json gives /wiki-assets/* a day of browser cache with stale-while-revalidate and a year of Vercel-CDN-Cache-Control; their names are not content-hashed, so no immutable. /fonts/site/* is immutable (Fonts). Vercel purges its CDN on each deploy. next start ignores vercel.json. Imported images (the logo, category art) and /nav/** carry hashed or versioned URLs.
  • /fonts/site/* (vercel.json) and /atlas/* (next.config.ts) are immutable for a year: each name there is its file's content hash. Vercel applies header rules to every status, so a 404 under either path carries that header too. Accepted: a hashed name that answers 404 is one no page links to.
  • The graph's data file (public/atlas/graph.<hash>.bin, 111,942 B) reaches browsers as brotli, 55,910 B on the wire, more than Vercel's gzip copy (50,434 B).

Retired routes

  • /embeds, /wiki/assets and /audit were retired (Decision 5, 2026-11-11); their code is in ~/repos/_retired/ui-inventory-pages-20261104/. The bookmark images in public/wiki-assets, /api/assets/[...path] and wiki/meta/cursor-audit-data.json stay. Crawl mode asserts the three paths answer 404.
  • The /me portfolio was retired on 2026-11-17: Kevin's own site, www.kevinliu.studio, holds his portfolio. Its code, images, CSS and the dialkit panel are in ~/repos/_retired/ui-me-portfolio-20261117/. next.config.ts 308s /me and /me/* to the site, and its eight font families moved to switcher.css for the development switcher. Crawl mode asserts the redirect, and that the portfolio's old image URLs answer exactly like a missing image.

Shell, articles, gates and 404

  • The shell ((wiki)/layout.tsx, wiki-shell.tsx) is one thin header and a main landmark. The header (components/shell/site-header.tsx) holds the mark and "Kevin Liu's Wiki", the Cmd+K search, one theme control and Index, and no per-page state, so a client navigation never changes its DOM. A skip link to #content is the first focusable element. /locked and the 404 render the same header without Index, so of the four gates only /packs, inside the shell, has Index; /locked, /brief and /system/sessions do not (accepted, 2026-11-18). Every focusable control uses the focus-ring token. The ⌘K hint is set in the sans by name (font-sans; a kbd defaults to mono, a font the gate pages otherwise never load). In print the header keeps only the mark and title.
  • Cmd+K (command-palette.tsx) is a native modal dialog: typeahead through /api/search, each hit linking to hit.href ?? /wiki/<slug>, and Index, theme, Open graph (/graph?focus=<slug> on an article), Ask Wikibot, the page's Markdown (copy, download, share; only on an article, which names its slug in data-markdown, fetched fresh per command so a lock never serves the unlocked text) and Lock for an unlocked viewer. Cmd+K closes an open dialog through close(), so focus returns to the control that opened it. The palette and Index load apart from the header (idle after load, or at the first approach or press; the Index only where the header has one) and are kept in a module store once loaded, so an open renders them directly and never suspends: a lazy component's first open waits out React's 300ms reveal throttle. Keys always go where focus is: nothing captures them, and the palette opens empty. A dialog asked for before its code arrives opens late only if focus is still exactly where it was, outside any field, and the reader did nothing in between: any key but a lone modifier or Cmd+K, input of any kind (typed, pasted, filled, dictated, composed), a submit, a click, a mouse press, a focus move, Back or Forward or a new page drops it, and so does a failed load. A touch that only scrolls drops nothing; a tap does. In a field, Cmd+K and Ctrl+K are the field's (Ctrl+K deletes to the line's end on a Mac), and nothing asked for from a field opens late, so a gate password never reaches search. Escape or a second Cmd+K cancels. Search is a link to /search that a hydrated page turns into the palette, so a press before hydration still navigates. The search field's row rule turns to a 2px ink line while the field has focus, inside the dialog's edge. SearchBar stays the inline field home and /search render.
  • Index (site-index.tsx) is an off-canvas native dialog: reader categories, then the agent categories in one collapsed "Agent system" group, labels in sentence case at 15px with no counts, and "Packs" after "Agent system" for an unlocked viewer; skills/deprecated is hidden. The open page's category opens with it, and the current page is marked in the signal color. A category whose list fails to load shows a link to its page, and retries only when the reader opens it again. Wikibot opens from the palette; the drawer loads on first use.
  • A child of main with data-bleed (an article, the 404) lays itself out on page-grid; every other page sits in one centred column (PAGE_COLUMN). A wide surface's route wraps it in WideColumn (data-wide, from the layouts of /packs, /brief and /system, and in the twin's pack pages around a found pack only, so its missing pack's 404 sits straight in main like every 404), which takes the wider column; the route says so because the twin's server render sees the rewritten path.
  • An article (article-view.tsx) sets its own # heading first at 42px (the heading is split from the body HTML; a page without one shows its title), then one 13px Geist Mono meta line (Breadcrumbs, the updated date), then the body at 17px/1.6 in full ink at a 30em measure (about 64 characters). On desktop the margin column holds the page's map crop at 240px, linking to /graph?focus=<slug>, and a plain contents list, read from the body's headings on the client (the build's privacy scan counts in-site link text as a page title, and a heading may name a page in prose); on a phone the crop follows the body. Related pages, backlinks and the tags as plain links end the page; the backlinks list every page that links here under a heading that counts them, and Related pages leaves those out. In print the article is one column at the page's width in light colors, its parts in order with the crop after the body and no contents list, and code wraps; the root's scheme and background follow the light tokens too, over the theme script's inline scheme, so the paper's margins print light with background graphics on. A project page shows its artifact screenshots as one full-bleed strip of square-cornered tiles under its title and their sites on one mono line.
  • A code block, table or diagram wider than the column scrolls sideways; once hydrated, one that overflows gets a tab stop and the group name "Code", "Table" or "Diagram" (components/article/scroll-regions.tsx), and one that fits gets none, except a block with focus, which keeps its stop until it blurs. One ResizeObserver re-checks a block when its width changes (a resize, a rotation), and a MutationObserver when the content changes.
  • A click on a body link to a wiki page goes through the client router (components/article/body-links.tsx), so the shell stays mounted and the map pans; modified clicks and in-page links keep the browser's behaviour.
  • Hovering or focusing a wikilink lights its target's dot over the crop in the same frame (atlas-crop-frame.tsx, from points the server passes for the linked pages near the crop).
  • The one motion: the crop sits in <ViewTransition name="atlas"> with onShare and onUpdate. On a navigation between pages with a map, the departing map hands over its point, and the new map's view-transition group starts offset by the step from the old address to the new one, capped at 48px, and settles in 240ms, transform only. It plays only when the crop is on screen at the click (at 390px it sits below the body, so it never does): panning a map nobody can see is pointless. Any key, pointer press or wheel finishes it; reduced motion skips it. globals.css turns off the browser's own animations for atlas and root, so nothing else animates. Name one map per page atlas; pass transition={false} to any other.
  • The gate (password-gate.tsx) owns its layout: "Private page", a labelled Password field and an ink Unlock button; a reason shows only after a failed attempt. It submits through a form action, so before hydration React keeps the form from submitting natively and replays the submit once hydrated; the field is uncontrolled, so a password typed early stays in it. One attempt runs at a time: once hydrated, a second Enter or click does nothing while one runs (the button is aria-disabled), and of several submits made before hydration only the first is replayed as an attempt. React resets the form after each attempt to the action state's retry, read from the field as the attempt returns: a network failure or a 5xx keeps what the field holds, and a wrong password (401) clears it unless the reader typed something new while the attempt ran. Each failure renders a new role="alert" node, keyed by a count, so a screen reader announces every one; an Enter on the field a wrong password left empty keeps that reason and announces nothing new. /packs, /locked (which the proxy serves for /brief and /system/sessions) and the gate branches render it with no wrapper. The 404's Unlock is a native <details> around the same form, so it opens and takes a password before the page hydrates; the slug is read from the address at each attempt, and opening it moves focus to the field once hydrated.
  • The 404 (not-found.tsx, components/shell/not-found-body.tsx) is the header, the whole map, "No page has this address.", the Unlock control and up to three nearest pages, found on the client from the address. The root 404 travels in every route's payload, so its map is a client component (not-found-map.tsx): other pages carry only its URL and frame, and its markup and image preload come from the 404's own server render, as FontPreload's do. In the twin, rendered per request, a notFound() reaches Next's client-rendered error page (an empty head: no theme, no title), so renderWikiPath takes the answer for a path the viewer cannot open: the static route keeps Next's 404, and the twin renders the 404's body in the viewer's shell, missing and private alike, with status 200 and robots noindex, nofollow (the response is also private and no-store); the twin's pack page does the same for a missing pack, for a viewer with everything unlocked (one with a page unlocked gets the password gate for every pack name). The served crawl holds each view to its status and to carrying this body or not, found by its heading, NOT_FOUND_SENTENCE (scripts/SKILL.md).
  • Media sizes (pending Lane 5: nothing writes the file yet, so images ship without width and height until it lands): bundle-wiki.mjs writes .content/media-dimensions.json, { "/wiki-assets/<path>": { "width": <int>, "height": <int> } }, public media only. src/lib/media-dimensions.ts reads it once (node:fs; an empty map when it is missing) and markdown.ts gives each image it lists width and height, plus sizes, decoding="async" and, below the first screen, loading="lazy". A failed image keeps its box (image-guard.tsx).

Common tasks → first action

  • Dev server → pnpm dev (from repo root: npm run dev).
  • Build → npm run build (installs ui deps frozen, then builds).
  • Add a page → App Router segment under src/app/, reuse src/components/.

Gotchas

  • The app reads bundled wiki content — re-run the bundler (ui/scripts) after wiki changes that the viewer must reflect.
  • scripts/export-okf.mjs owns the privacy-filtered .content/okf projection; /api/okf only serves that generated tree and never reads canonical private pages directly.
  • Never add a parallel privacy list. Runtime and bundle-wiki.mjs must read the shared privacy manifest, and protected slugs cannot be force-public through frontmatter.
  • Never expose /api/brief without checking the global gate session. The local PGlite ledger is authoritative for the first Daily Brief slice and must not be serialized into public pages or generated assets.
  • /api/memory is a separate machine credential boundary: derive authority on the server, require idempotency and provenance, enforce KEVIN_WIKI_MEMORY_SOURCE_SCOPES, deny public writes unless explicitly enabled, and require a durable ledger path in production. It stores proposals, not canonical wiki truth.
  • This is a separate pnpm workspace from the tsx scripts at the repo root.