Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@
"allow": ["Bash(agent-browser:*)"]
},
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume",
"hooks": [
{
"type": "command",
"command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] || exit 0; cd \"$CLAUDE_PROJECT_DIR\" && mise trust -q && mise install --locked node pnpm hk >&2 && mise x -- pnpm install --frozen-lockfile --prefer-offline >&2 && { [ -z \"$CLAUDE_ENV_FILE\" ] || echo 'eval \"$(mise env -s bash -C \"$CLAUDE_PROJECT_DIR\")\"' >>\"$CLAUDE_ENV_FILE\"; }",
"timeout": 600
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && f=\"$(jq -r .tool_input.file_path)\" && case \"$f\" in \"$CLAUDE_PROJECT_DIR\"/*) hk fix -q -n --no-stage \"$f\" >&2 || exit 2 ;; esac",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && f=\"$(jq -r .tool_input.file_path)\" && case \"$f\" in \"$CLAUDE_PROJECT_DIR\"/*) mise x -- hk fix -q -n --no-stage \"$f\" >&2 || exit 2 ;; esac",
"timeout": 60
}
]
Expand All @@ -20,7 +32,7 @@
"hooks": [
{
"type": "command",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && jq -e .stop_hook_active >/dev/null || hk fix --slow -q -n --no-stage >&2 || exit 2",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && HK_PROFILE=slow mise x -- hk agent stop-hook --target claude-code --timeout 170",
"timeout": 180
}
]
Expand Down
16 changes: 11 additions & 5 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ description: Install the mise-pinned toolchain and the pnpm dependencies, with b
runs:
using: composite
steps:
# The downloads, not the installed tools: mise checks every cached download against the
# checksum in `mise.lock`, and trusts a restored install as is.
- uses: actions/cache@v6
with:
path: ~/.cache/mise/downloads-cas
key: mise-downloads-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('mise.lock') }}

# Only the tools the jobs run; local-only tools such as agent-browser are skipped.
- uses: jdx/mise-action@v4
- uses: jdx/mise-action@v5
with:
version: 2026.9.14
install_args: node pnpm hk
cache: true
version: 2026.10.25
install_args: node pnpm hk actionlint
cache: false

# mise-action caches tool binaries, not pnpm's store.
- name: Locate pnpm store
shell: bash
run: echo "PNPM_STORE=$(pnpm store path --silent)" >>"$GITHUB_ENV"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup

# Catches settings hk would ignore, such as a misspelled property or a glob that never matches.
- name: Validate hk.pkl
run: hk validate --deny-warnings

- name: Check
run: |
echo "::add-matcher::.github/typescript-matchers.json"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
if: ${{ steps.lighthouse-pass.outputs.cache-hit == 'true' }}
run: echo "Lighthouse skipped, this exact build already passed." >>"$GITHUB_STEP_SUMMARY"

- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() && steps.lighthouse.outcome != 'skipped' }}
with:
name: lighthouse-reports
Expand Down
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pages. **Zero client-side framework runtime** - `.astro` components and plain `<

## Toolchain

ESLint (typed `strictTypeChecked` + `stylisticTypeChecked`, `eslint-plugin-astro` with
ESLint (`recommended`, typed `strictTypeChecked` + `stylisticTypeChecked`, `eslint-plugin-astro` with
`jsx-a11y-strict`, the vendored anti-slop rules in `tools/lint/`) lints every `.ts`, `.js`, and
`.astro` file; `@shadcn/lint`'s token rules check every class in `src/` against the `@theme`.
Prettier formats everything.
Expand All @@ -29,7 +29,8 @@ Every check is a step in `hk.pkl`, and the same steps back the git
pre-commit hook, `pnpm check` / `pnpm fix`, CI, and the Claude Code hooks in
`.claude/settings.json`: each file you edit is formatted and linted, and the end of each turn
runs the full set, typecheck and knip included, over the modified files. Unfixable failures
come back to you.
come back to you. In cloud sessions a `SessionStart` hook installs the mise toolchain and the
dependencies.

Browser verification goes through `agent-browser` (the `agent-browser` skill; setup in
`docs/tooling.md`), against `pnpm preview`, not the dev server.
Expand Down
2 changes: 1 addition & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Per Brand Guidelines: Orbitron for page headings/titles (avoid very long or smal
- **Eyebrows are labels**: `label` in `primary-bright` (or `muted`) above a heading. There is no second caps style.
- **Stats are data at `h1` size**: Source Code Pro 600, tight, tabular figures, `primary-bright` (the `stat` utility).
- The size role for reading text is `copy` rather than `body`, which is the color (§2): `text-copy` is the size, `text-body` the color.
- **Each face is declared at the weights above** (Inter at 400–700, so markdown bold renders a real 700) and clamps anything outside them. A heavier weight means widening the declaration in `src/styles/fonts.css`, not just a utility class.
- **Each face is declared at the weights above** (Inter at 400–700, so markdown bold renders a real 700) and clamps anything outside them. A heavier weight means widening the face's weight range in `astro.config.ts`'s `fonts`, not just a utility class.
- Prose measure: 65–75ch (`measure`).
- Headings: sentence case; one `h1` per page; no skipped levels; never "SC2" in a heading (§1).

Expand Down
125 changes: 124 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AstroIntegration } from "astro";
import { satteri } from "@astrojs/markdown-satteri";
import sitemap from "@astrojs/sitemap";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig, envField } from "astro/config";
import { defineConfig, envField, fontProviders } from "astro/config";
import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";

// The config is loaded through jiti, so this module must import nothing from `astro:*`.
Expand All @@ -12,6 +12,50 @@ import { proseMarkdown } from "./src/lib/markdown";

const outDir = "./dist";

const fontDir = "./src/styles/fonts";

/** The Google Fonts CSS API's `latin` and `latin-ext` ranges, which the files are cut to. */
const LATIN = [
"U+0000-00FF",
"U+0131",
"U+0152-0153",
"U+02BB-02BC",
"U+02C6",
"U+02DA",
"U+02DC",
"U+0304",
"U+0308",
"U+0329",
"U+2000-206F",
"U+20AC",
"U+2122",
"U+2191",
"U+2193",
"U+2212",
"U+2215",
"U+FEFF",
"U+FFFD",
] as const;
const LATIN_EXT = [
"U+0100-02BA",
"U+02BD-02C5",
"U+02C7-02CC",
"U+02CE-02D7",
"U+02DD-02FF",
"U+0304",
"U+0308",
"U+0329",
"U+1D00-1DBF",
"U+1E00-1E9F",
"U+1EF2-1EFF",
"U+2020",
"U+20A0-20AB",
"U+20AD-20C4",
"U+2113",
"U+2C60-2C7F",
"U+A720-A7FF",
] as const;

const htmlFile = (pathname: string): string =>
`${pathname.replace(/^\/|\/$|\.html$/gu, "") || "index"}.html`;

Expand Down Expand Up @@ -97,6 +141,85 @@ const bandsNeverTouch = (): AstroIntegration => ({

export default defineConfig({
build: { format: "file" },
/**
* The faces DESIGN.md §3 sanctions, at its weights, from the files in the fonts directory. The
* variable files carry the full weight axis; the declared range clamps it. Astro generates each
* text face's fallback: Arial scaled to its metrics, so the swap does not reflow text.
*/
fonts: [
{
cssVariable: "--font-inter",
fallbacks: ["ui-sans-serif", "system-ui", "-apple-system", "Segoe UI", "sans-serif"],
name: "Inter",
options: {
variants: [
{
src: [`${fontDir}/inter-latin.woff2`],
style: "normal",
unicodeRange: [...LATIN],
weight: "400 700",
},
{
src: [`${fontDir}/inter-latin-ext.woff2`],
style: "normal",
unicodeRange: [...LATIN_EXT],
weight: "400 700",
},
],
},
provider: fontProviders.local(),
},
{
cssVariable: "--font-orbitron",
fallbacks: ["ui-sans-serif", "system-ui", "sans-serif"],
name: "Orbitron",
options: {
variants: [
{
src: [`${fontDir}/orbitron-latin.woff2`],
style: "normal",
unicodeRange: [...LATIN],
weight: "600 700",
},
],
},
provider: fontProviders.local(),
},
{
cssVariable: "--font-source-code-pro",
fallbacks: ["ui-monospace", "SFMono-Regular", "Menlo", "monospace"],
name: "Source Code Pro",
optimizedFallbacks: false,
options: {
variants: [
{
src: [`${fontDir}/source-code-pro-latin.woff2`],
style: "normal",
unicodeRange: [...LATIN],
weight: "400 600",
},
],
},
provider: fontProviders.local(),
},
{
cssVariable: "--font-architects-daughter",
fallbacks: ["Comic Sans MS", "cursive"],
name: "Architects Daughter",
optimizedFallbacks: false,
options: {
variants: [
{
src: [`${fontDir}/architects-daughter-latin.woff2`],
style: "normal",
unicodeRange: [...LATIN],
weight: "400",
},
],
},
provider: fontProviders.local(),
},
],
env: {
schema: {
/**
Expand Down
49 changes: 31 additions & 18 deletions docs/tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ pnpm check # every hk.pkl step: typecheck, lint, format, knip
pnpm dev
```

`mise.toml` pins node, pnpm, and hk exactly and commits checksums to `mise.lock`, so every clone, CI
run, and Cloudflare Pages build gets the same tools. `package.json` scripts are the single
source of truth for commands.
`mise.toml` pins node, pnpm, hk, and actionlint exactly and commits checksums to `mise.lock`, so
every clone, CI run, and Cloudflare Pages build gets the same tools. `package.json` scripts are the
single source of truth for commands.

Corepack's `pnpm` shim can shadow the mise-pinned pnpm and rewrite the lockfile with a different
resolver. `which pnpm` must resolve inside mise's shims directory; if not, `corepack disable pnpm`.

## Toolchain

| Concern | Tool |
| ----------- | ---------------------------------------------------------------------------------------- |
| Lint | ESLint: `strictTypeChecked` + `stylisticTypeChecked`, `astro/jsx-a11y-strict`, anti-slop |
| Format | Prettier, with the Astro and Tailwind plugins |
| Types | `astro check` for `src/` and config files; `tsc -p functions`, `tsc -p tools` |
| Dead code | knip |
| Hygiene | hk's built-in trailing-whitespace, final-newline, and merge-conflict-marker steps |
| Repo checks | `tools/checks/*.ts` |
| Runner | hk: every check above is a step in `hk.pkl` |
| Concern | Tool |
| ----------- | ------------------------------------------------------------------------------------------------------- |
| Lint | ESLint: `recommended`, `strictTypeChecked` + `stylisticTypeChecked`, `astro/jsx-a11y-strict`, anti-slop |
| Format | Prettier, with the Astro and Tailwind plugins |
| Types | `astro check` for `src/` and config files; `tsc -p functions`, `tsc -p tools` |
| Dead code | knip |
| Hygiene | hk's built-in trailing-whitespace, final-newline, and merge-conflict-marker steps |
| Config | actionlint on the workflows, `mise fmt --check` on `mise.toml`, `hk validate` in CI |
| Repo checks | `tools/checks/*.ts` |
| Runner | hk: every check above is a step in `hk.pkl` |

TypeScript is the 6.x line everywhere, one compiler for `astro check`, `tsc`, and
`typescript-eslint`. `astro check` (Volar) needs the JavaScript compiler's API, which TypeScript 7
Expand Down Expand Up @@ -64,7 +65,10 @@ curl -A "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 Chrome/140.0.0.0 Safari/537.
```

Download the `latin` file of each face (and Inter's `latin-ext`) over the existing one, and copy
its `font-weight` and `unicode-range` into `src/styles/fonts.css`.
its `font-weight` and `unicode-range` into the face's entry in `astro.config.ts`'s `fonts`. Astro
declares the faces from that config, under generated family names, and computes each text face's
metric-matched Arial fallback from the file; `src/styles/fonts.css` points the shared `--sc2-font-*`
tokens at the variables it emits.

Social cards use static TTF fonts in `tools/assets/fonts/`: Orbitron Bold for headings and an
Inter Bold subset for the registered-trademark symbol. Orbitron has no glyph for that symbol.
Expand Down Expand Up @@ -99,7 +103,7 @@ The poster, `src/assets/frc/hero-video-poster.webp`, is the master's first frame
| `pnpm check`, CI's Check job | `hk check --all --slow`: every step over every file |
| `pnpm fix` | `hk fix --all`: every step but the slow ones, fixing what they can |
| Claude Code, after `Edit/Write` | `hk fix` on the edited file |
| Claude Code, at the end of turn | `hk fix --slow` over the modified and untracked files |
| Claude Code, at the end of turn | `hk agent stop-hook`: the check hook, slow steps included |

`astro check`, `tsc`, and knip read the whole program, so they carry the `slow` profile and run
only where `--slow` is passed; each runs once when a selected file matches its glob. ESLint
Expand All @@ -109,10 +113,19 @@ mise's `postinstall` hook runs `hk install --mise`, so every `mise install` outs
the pre-commit hook; it runs hk through `mise x`, so Git needs mise on its `PATH`.
`HK=0 git commit` skips it.

Both Claude Code hooks are inline in `.claude/settings.json` and exit 2 with hk's output when a
step fails, which hands the findings back to the agent. The edit hook ignores files outside the
repo. The end-of-turn hook does not run again on the stop it forced (`stop_hook_active`), so a
problem the agent cannot fix reaches the user instead of looping.
The Claude Code hooks are inline in `.claude/settings.json` and call hk through `mise x`, because
hooks run in a plain `sh` where mise may not be activated. The edit hook exits 2 with hk's output
when a step fails, which hands the findings back to the agent, and ignores files outside the repo.
The end-of-turn hook is hk's own: it runs `hk check --safe` with the `slow` profile and blocks the
stop with the failures. `--safe` refuses any step whose command has no declared effect, so a
custom step's command in `hk.pkl` is a `CommandSpec` with its `effect`. It does not run again on
the stop it forced (`stop_hook_active`), so a problem the agent cannot fix reaches the user instead
of looping.

In Claude Code cloud sessions (`CLAUDE_CODE_REMOTE`), a `SessionStart` hook runs
`mise install --locked` and `pnpm install`, then adds mise's environment to `CLAUDE_ENV_FILE` so
later shell commands get the pinned tools. `--locked` installs from `mise.lock` alone and never
writes to it, so it needs no network access beyond the locked download URLs.

## Browser automation

Expand Down
10 changes: 9 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import js from "@eslint/js";
import { plugin as shadcn } from "@shadcn/lint";
import astro from "eslint-plugin-astro";
import perfectionist from "eslint-plugin-perfectionist";
Expand All @@ -17,7 +18,11 @@ export default defineConfig(
]),
{
files: ["**/*.{ts,mts,js,mjs,astro}"],
extends: [tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked],
extends: [
js.configs.recommended,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
},
Expand Down Expand Up @@ -49,7 +54,10 @@ export default defineConfig(
],
},
],
"perfectionist/sort-exports": "error",
"perfectionist/sort-imports": "error",
"perfectionist/sort-named-exports": "error",
"perfectionist/sort-named-imports": "error",
},
},
{
Expand Down
5 changes: 5 additions & 0 deletions functions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
"noEmit": true,
// Restates astro/tsconfigs/strictest, whose DOM and Astro types the Workers runtime cannot use.
"strict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"verbatimModuleSyntax": true
},
"include": ["**/*.ts"]
Expand Down
Loading
Loading