apiVersion: capsule.dev/v0.1 kind: Capsule name: f4c-build-infra version: 0.1.0 type: subsystem purpose: summary: 'Provides the necessary configuration and scripts for building, deploying, and running the Next.js application as a Cloudflare Worker using OpenNext.js and Wrangler. It includes GitHub Actions workflows and Cloudflare-specific configuration files. ' owns: - Cloudflare Worker configuration (`wrangler.jsonc`) - OpenNext.js build configuration (`open-next.config.ts`) - GitHub Actions workflows for CI/CD - Node.js version management (`.node-version`, `.nvmrc`) - Cloudflare-specific TypeScript declarations (`cloudflare-env.d.ts`) does_not_own: - Application source code - Core logic or UI components - Generic development tooling (linting, formatting) interfaces: provides: - kind: cli name: cf-build description: Command to build the Next.js app for Cloudflare Workers. - kind: cli name: cf-deploy description: Command to deploy the Cloudflare Worker. - kind: env name: Cloudflare Worker Bindings description: Defines Cloudflare KV and Durable Object bindings for the worker. requires: - kind: env name: CLOUDFLARE_API_TOKEN description: Cloudflare API token for deployment. - kind: env name: CLOUDFLARE_ACCOUNT_ID description: Cloudflare account ID for deployment. - kind: env name: NEXT_PUBLIC_TURNSTILE_SITE_KEY description: Public Turnstile site key, baked into frontend at build time. - kind: library name: '@opennextjs/cloudflare' description: Library for deploying Next.js apps to Cloudflare Workers. - kind: library name: wrangler description: Cloudflare's CLI tool for Workers. dependencies: capsules: - name: f4c-bot-service version: '>=0.1.0' - name: f4c-room-api version: '>=0.1.0' - name: f4c-scheduled-cleanup version: '>=0.1.0' agent: summary_for_ai: 'This capsule defines the build and deployment pipeline for Cloudflare. Agents should focus on optimizing build times, ensuring correct Worker bindings, and maintaining deployment stability. Any changes to the application''s Cloudflare infrastructure should be made here. ' avoid: - Modifying application logic or UI components. - Introducing non-Cloudflare specific build tools or configurations. verification: invariants: - The `cf-build` script must successfully compile the Next.js app into a Cloudflare Worker. - The `wrangler.jsonc` must correctly define all necessary KV and Durable Object bindings. x-reuse: notes: 'Highly specific to Cloudflare Workers and OpenNext.js. The `.github/workflows/deploy-web.yml` workflow is tailored to the `cloudflare` branch and specific GitHub Actions secrets. `app/wrangler.jsonc` contains specific bindings (`ROOMS_KV`, `BOT_SESSION`) that need to be configured for a new project. The `worker.ts` file is the entry point for the Cloudflare Worker and assumes an OpenNext.js setup. ' x-reconstruct: install: install.json