# @kentcdodds/starsnake: agent notes
Human overview: [`README.md`](./README.md).
## Layout
- `kody.app.entry` is `./app/router.ts`. Routes: `/` game page, `/manifest.webmanifest`, `/health`, and `/a/*` images (embedded bytes). Everything else is 404. Only GET and HEAD are allowed.
- `client/game.js` is the whole game (plain browser JS, one canvas, DOM HUD and screens). `scripts/build.mjs` inlines it into `app/client.ts`.
- `app/page.ts` has the HTML shell, CSS, head tags (og and twitter meta with absolute URLs) and the manifest. `app/router.ts` builds the public origin from `X-Forwarded-Host` or `Host` (fallback `https://starsnake.kentcdodds.com`).
- Generated, committed files: `app/client.ts`, `app/assets.ts`, `app/build-info.ts`. **Run `npm run build` before every commit.** `kody.dev.prebuild` does not run at publish.
- Art: `npm run art` redraws icons (`scripts/icons.mjs`, headless Chrome), quantizes PNGs (`scripts/shrink-icons.py`), and builds `public/og.jpg` from real gameplay screenshots (`scripts/og.mjs`, uses `window.__starsnake.scene()`). Needs `playwright-core` and `CHROME_PATH` (default `/usr/bin/google-chrome`). `.kody/icon.png` is the Kody package icon.
## Test
- `npm test` builds, then runs `scripts/smoke.mjs` against `dist/index.html` (run `npm run dump` first if `dist/` is missing). It drives real touch input through CDP at 390x844, a landscape size and 1280x800, and fails on console errors. Set `SHOTS=
` for screenshots, or `URL=` to test a served copy.
- Test hooks: `window.__starsnake` exposes `snap`, `state`, `give(n)`, `setTail(n)`, `scene()` (staged scene for art), `freeze()`. `?seed=N` makes spawns repeatable, `?autostart` skips the title.
- Serve locally with `kody dev` (mock target) and `kody dev fetch /`.
## Tail combat
- Beads damage rocks. `TAIL_DMG` is 2, +1 when ship speed is above `TAIL_WHIP_SPEED`. A bead can hit once per `TAIL_BEAD_CD` and a rock can be hit by the tail once per `TAIL_ROCK_CD`, so the tail cannot grind. Hit rocks get a 150 unit knockback. Children of a split rock ignore the tail for 0.3 s.
- Boss rocks take 1 damage per tail touch and knock that bead off (tail shrinks by one). A rock that hits the ship head still costs 2 beads.
- Kills by the tail increment `tailKills` (shown on game over, exposed in `snap`). `window.__starsnake.tailTest(size)` parks a rock on a bead for tests.
## Rules
- Keep the capability set empty: no secrets, storage, outbound fetches, jobs, or `kody:` imports other than `kody:runtime`. The app is internet-visible and has no login, so every route must be safe for anonymous callers.
- No em dashes in copy. Keep HUD text fixed-width so nothing shifts.
- Tuning constants sit at the top of `client/game.js` (`TOWER`, `GUN_COSTS`, `ROCK`, `MAX_TAIL`, `GEMS_PER_SEG`, `SHORT_SIDE`).
- Visibility: public and internet-visible, custom hostname `starsnake.kentcdodds.com` (set up with `kody:@kentcdodds/cloudflare/custom-domain`). Do not touch other `kentcdodds.com` DNS records.
- Publish with the Kody CLI: `kody package publish @kentcdodds/starsnake`.