# Plan Maker 2000 (decision-maker-2000) — loop prototype Spec: `docs/spec.md` (exported from the Claude Doc, which is the editable source). Learnings: `docs/blog/`. Hono + Better Auth (phone OTP + anonymous) + D1/Drizzle + one Durable Object per hand + Jev (TypeSafe System One) for live odds and the lever. ## Dev loop ```bash npm install cp .dev.vars.example .dev.vars # then paste TYPESAFE_API_KEY + BETTER_AUTH_SECRET npm run db:migrate:dev # local D1 (miniflare) npm run dev # http://localhost:8787 — OTP codes print to this console ``` Open `/` on two phones on the same LAN (or `wrangler dev --ip 0.0.0.0`), "Jump in" with a name, create a hand, open `/h/` on the other phone. ### Scripts - `npm run dev` — wrangler dev, local D1 + DO, hot reload - `npm run cf-typegen` — regenerate `worker-configuration.d.ts` after editing wrangler.toml - `npm run auth:update` then `npm run db:generate` — after changing Better Auth plugins - `npm run db:migrate:dev` / `:prod` - `npm run deploy` — `wrangler deploy` (first time: `wrangler d1 create pm2000-db`, paste id into wrangler.toml, `wrangler secret put TYPESAFE_API_KEY`, `wrangler secret put BETTER_AUTH_SECRET`) - Preview deploys: `npx wrangler versions upload` gives a preview URL without touching prod ### Where things are - `src/hand.ts` — the Hand DO: state, WebSocket fan-out, chips/veto/lock, debounced Jev odds, the lever (seeded sample), rounds - `src/jev.ts` — typed Jev client - `src/dealer.ts` — human-authored dealer line bank; Jev picks by tag - `src/auth/index.ts` — phone OTP (console in dev, Twilio when OTP_MODE=twilio) + anonymous - `public/index.html` — mobile client: felt table, chip stacks, live odds bars, lever, reels reveal with near-miss, rounds - `wrangler.toml` `[vars].PICK_INSTRUCTIONS` — the "semi-decision-makery" dial. Edit and hot-reload. ### Driving it from the CLI `scripts/drive.sh` runs a full two-member hand against a running dev server (sign-in, chips, veto, lock, pull, again, accept) and prints odds, winner, reel order and dealer line. ### Not here yet Options agent (screenshot intake / "More options" regen — the client prompts for labels), tables, ledger, rubber-banding, expiry alarms, run structure.