A reverse Turing test: a Windows 95-style prompt-defense game where you play as an AI assistant trying to stay helpful while refusing to leak fictional private data.
The game uses stacked visible rules, trap prompts, deterministic guardrails, and LLM judging through OpenRouter routed through Cloudflare AI Gateway. It is built as a single Next.js app, with the game UI and API routes deployed together.
bun install
bun devOpen the Next.js dev URL, usually http://localhost:3000.
The game works offline with hardcoded traps and deterministic guardrails if the gateway is not configured. Add .env values when you want OpenRouter-generated traps and LLM judging through Cloudflare AI Gateway.
OPENROUTER_API_KEY=sk-or-...
AI_GATEWAY_URL=https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}
CLOUDFLARE_API_TOKEN=OPENROUTER_API_KEYis required for live LLM calls.AI_GATEWAY_URLis required for live LLM calls. The server does not call OpenRouter directly.CLOUDFLARE_API_TOKENis only needed when the Cloudflare AI Gateway has authentication enabled.- Model profiles use OpenRouter free routes only:
openrouter/freeplus explicit:freemodel IDs. LLM_TIMEOUT_MSdefaults to15000per model attempt.LLM_MAX_MODEL_ATTEMPTSdefaults per profile and can raise/lower how many free models the server tries before local fallback.
bun dev # Next.js app and API routes
bun run build # Production Next.js build
bun start # Serve the production build
bun test # Bun test runner
bun run prisma:generate # Regenerate Prisma Client
bun run prisma:migrate:deploy # Apply committed migrations
bun run prisma:seed # Seed a small sample game run
bun run prisma:verify # Verify a live database readThe server-side Prisma singleton lives in lib/prisma.ts and uses the
@prisma/adapter-pg driver. Game persistence stores visitors, runs, and turns
in the linked Prisma Postgres database. Keep DATABASE_URL in .env; it is
ignored by Git and must never be imported into client components.
After changing prisma/schema.prisma, create a development migration and
regenerate the client:
bunx --bun prisma migrate dev --name describe_your_change
bun run prisma:generate