Airglow #
Automations for the AT Protocol. See README.md for the product spec.
Stack #
- Runtime: Node 26 (pinned in
.node-version), pnpm 12 (pinned inpackageManager) - Server: Hono + HonoX (file-based routing, islands architecture)
- UI: hono/jsx (SSR + client hydration)
- Styling: @vanilla-extract/css
- Database: Postgres via postgres.js + Drizzle ORM (local:
docker compose up -d; tests: PGlite) - Toolchain: Vite+ (
vp) wraps Vite 8, Vitest, Oxlint, Oxfmt - Lexicons: managed with
goat lex, stored inlexicons/
Commands #
Directly call vp. NO NEED to invoke it with pnpm.
vp check: lint, format, type-check- instead of
tsc --noEmit
- instead of
vp dev: start dev servervp build --mode client: build client assetsvp test: run testspnpm start: build, then run the production serverpnpm serve: run the production server from an existingdist/build (no build step)- the production server only runs from
dist/;node app/server.tscrashes onimport.meta.glob
pnpm db:generate: generate Drizzle migrationspnpm db:migrate: run migrationspnpm tsx lib/scripts/<script>.ts: run a one-off script (tsx resolves the@/alias and.jsspecifiers that plainnodedoes not)goat lex lint lexicons/: lint lexicon schemaspnpm web-guidance search|retrieve|legacy-scan: the modern-web-guidance CLI (see Conventions)
Test and preview #
Dev server and port #
- Your port is 5176. Always use
http://127.0.0.1:5176/(use127.0.0.1, notlocalhost— the OAuth flow is configured for the loopback IP). The human often runs their own preview on 5175, so leave 5175 alone. PORTis the single source of truth: it drives Vite's listen port, the PDS-proxyAPP_ORIGIN, andconfig.publicUrl. Default is 5176 (.env+ config defaults). Don't hardcode a port anywhere — auth breaks when they disagree.strictPortis on, so the server fails loudly rather than drifting to a port that breaks OAuth.- Start with
pnpm dev, or use Claude Preview (launch.json→dev, port 5176). - If 5176 is taken, it's almost always a stale Claude session. Kill it and restart — never get stuck on this:
lsof -ti:5176 | xargs kill
Cold start (be patient, ~20-30s) #
The port opens within ~1s, but the server is not actually ready until the first request finishes compiling the SSR module graph (~15s; the @atproto tree is heavy and Vite transforms it on demand). The trap is thinking it's up because the port is open.
- Don't trust port-open. Wait for
GET /to return 200 before testing:until [ "$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5176/)" = "200" ]; do sleep 1; done - Don't be surprised if you wait a few seconds after a restart. Just wait — don't start debugging a server that's still warming up.
UI screenshots without the dev server #
pnpm preview:ui renders the states listed in app/previews/<name>.preview.tsx with the app's styles and fonts,
shoots each in headless Chromium in the light and dark themes, and prints the PNG paths
(.ui-preview/<name>/<state>.<theme>.png). It needs no database, PDS or sign-in, so it works where the dev server
can't. Look at the PNGs after any change to what the UI shows, and add or update a preview for the component you
changed: a state per case the change can be in (empty, one item, many, an error, a long handle…), with act to open a
menu or hover a row before the shot. app/previews/header.preview.tsx is the example.
pnpm preview:ui header: one preview.--state <name>,--theme light|dark,--listto see the states.pnpm preview:ui header --serve: print the pages' URLs and keep serving, to open them in a browser.- Islands aren't hydrated: a shot shows the server markup, as the page looks before its scripts run.
- The first run on a machine needs Chromium:
pnpm exec playwright install --only-shell chromium.
Sign in / out (you can and must do this yourself) #
You have two test users. Switch between them to test authenticated/unauthenticated and admin/non-admin views.
- alice.pds.dev — admin, is_partner_app: true — did:
did:plc:mjqzheqksuetwha7s33zmxjp - bob.pds.dev — non-admin, is_partner_app: false — did:
did:plc:zbxj6esdt3kwmjen5smgzrvq
Sign in: go to http://127.0.0.1:5176/auth/login → fill the handle field with alice.pds.dev or bob.pds.dev → submit → on the OAuth page click the "Authorize" button. It's always the same page and same button — click it blindly, no screenshot needed each time. It may or may not ask for the OAuth password, which is localdev for both accounts. Success redirects to /u/<handle>.
Sign out: click your avatar in the header → "Sign out @" (POSTs to /auth/signout). It signs out of the active account only: with another account signed in, that one becomes active and you land on its profile; signing out of the last account redirects to /.
Switch users: click your avatar → "Add account" and sign in as the other (same steps as Sign in above). Both stay signed in; switch between them from the avatar menu ("Switch to @").
If OAuth doesn't work at all (the /auth/login submit fails to reach an authorize page), the local PDS server (Docker, on localhost:3000) is probably not running. Don't get into a debugging loop — just ask the human to start the PDS server.
Working in a git worktree #
A fresh worktree is a clean checkout: the gitignored .env and data/ don't come with it, so the dev server won't start (config throws without COOKIE_SECRET) and OAuth breaks (the signing keys live in data/). Before doing anything else in a new worktree, run:
pnpm worktree:setup
This copies .env and the OAuth keys in data/ from the main checkout, gives the worktree its own Postgres database (airglow_<worktree>, cloned from airglow_dev on the shared compose server, with DATABASE_URL in the worktree .env pointed at it), installs deps, and applies migrations. It's idempotent and a no-op when run from the main checkout, so just run it whenever a worktree server fails to start — don't debug missing-secret errors by hand. It won't recreate a worktree database that already exists (so a DB you're testing migrations against is safe). Note the worktree inherits port 5176 from the tracked launch.json; if you're also running a server on 5176 elsewhere, kill the stale one (see above).
Conventions #
- Use
pnpminstead ofnpm,yarnorbun - Directly call
vp lib/config.tsloads.envwithprocess.loadEnvFile(variables already in the environment win); no dotenv needed- Raw SQL results: use
rawRows()fromlib/db/tx.ts(postgres.js and PGlite shape them differently); rawcount/sum/bigint come back as strings - Routes go in
app/routes/, islands inapp/islands/ - Shared non-interactive components go in
app/components/ - Backend logic goes in
lib/ - Styles use vanilla-extract
.css.tsfiles inapp/styles/ docs/design.mdholds the UI rules: tokens, shared components, and where hints, errors, notices and actions go. Read it before any UI change, and build fromapp/components/before writing a style- Before writing or reviewing HTML, CSS or client-side JS, use the skill in
.agents/skills/modern-web-guidance/;docs/design.mdwins where they disagree. Run its CLI only aspnpm web-guidance(pinned, telemetry off), never throughnpx,pnpxorpnpm dlx docs/solutions/holds documented solutions to past problems (bugs, best practices, workflow patterns), organized by category with YAML frontmatter (module,tags,problem_type). Relevant when implementing or debugging in documented areas.CONCEPTS.mdis the shared domain vocabulary (entities, named processes, status concepts). Relevant when orienting to the codebase or naming things.
Git #
- Use conventional commits
- Project is hosted on tangled.org, not GitHub. No
ghCLI; PRs are created via the tangled web UI. Don't suggestgh pr createor GitHub Issues flows.