# 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 pnpm install cp .dev.vars.example .dev.vars # then paste TYPESAFE_API_KEY + BETTER_AUTH_SECRET pnpm db:migrate:dev # local D1 (miniflare) pnpm 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 - `pnpm dev` — wrangler dev, local D1 + DO, hot reload - `pnpm cf-typegen` — regenerate `worker-configuration.d.ts` after editing wrangler.toml - `pnpm auth:update` then `pnpm db:generate` — after changing Better Auth plugins - `pnpm db:migrate:dev` / `pnpm db:migrate:prod` - `pnpm deploy` — `wrangler deploy` (first time: create D1, paste its id into `wrangler.toml`, and configure the production secrets listed below) - Preview deploys: `pnpm exec wrangler versions upload` gives a preview URL without touching prod Production uses Twilio because `wrangler.toml` sets `OTP_MODE=twilio`. Configure secrets without adding them to a file or Git: ```bash pnpm exec wrangler secret put TYPESAFE_API_KEY pnpm exec wrangler secret put BETTER_AUTH_SECRET pnpm exec wrangler secret put TWILIO_ACCOUNT_SID pnpm exec wrangler secret put TWILIO_AUTH_TOKEN pnpm exec wrangler secret put TWILIO_FROM ``` `BETTER_AUTH_URL` is optional. Set it as a Wrangler variable or secret when production needs a fixed canonical origin; otherwise auth uses the origin of each incoming Cloudflare request. Local development explicitly uses `OTP_MODE=console` from `.dev.vars`. ### 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.