Cloudflare Worker (TypeScript) + React 18 + Vite + Tailwind + shadcn/ui + Cloudflare D1.
Package manager: pnpm. Never use npm commands.
pnpm run dev # Worker backend :8787
pnpm -C web run dev # React frontend :5173 (proxy /api → :8787)
pnpm run dev:remote # backend with live D1
pnpm run deploy # build:web + wrangler deploy
pnpm run testisPromotionalEmail()must run before any LLM call inemail()handler.- Every incoming email →
raw_mails. Only AI-extracted results →code_mails. Never skipraw_mails. src/index.htmlis a live fallback. Do not delete.- DOMPurify + sandboxed iframe on all email HTML rendering. Do not relax.
- Basic Auth gate is first in
WorkerEntrypoint.fetch(). Do not move or bypass. - All AI calls go through
callProvider(). Do not add per-provider methods alongside it.
Required: AI_BASE_URL, AI_API_KEY, AI_API_FORMAT (openai|responses|anthropic), AI_MODEL.
Optional fallback: AI_FALLBACK_BASE_URL, AI_FALLBACK_API_KEY, AI_FALLBACK_API_FORMAT, AI_FALLBACK_MODEL (all four or none).
- UI components: shadcn/ui only. No new UI libraries without discussion.
- Colors: CSS variables in
web/src/index.css. No hardcoded hex except table hover states. - Use
text-muted-foregroundfor secondary text.text-mutedis a background color — never use as text. - All grid children need
min-w-0to prevent overflow.
When compressing, preserve in priority order:
- Architecture decisions (NEVER summarize)
- Modified files and their key changes
- Current verification status (pass/fail)
- Open TODOs and rollback notes
- Tool outputs (can delete, keep pass/fail only)