[skip ci] Update AGENTS.md

This commit is contained in:
2026-06-28 12:02:43 +02:00
parent d9ceff99c6
commit 0d65f71bec
+6 -25
View File
@@ -9,7 +9,7 @@ npm workspace: Cloudflare Worker (`src/`) + Astro 6 SSR app (`status-page/`).
- **Static assets**: `status-page/dist/client/` served via `ASSETS` binding (`run_worker_first = true`) - **Static assets**: `status-page/dist/client/` served via `ASSETS` binding (`run_worker_first = true`)
- **Shared types**: `src/types.ts` imported via `@worker/types` alias in `status-page/tsconfig.json` - **Shared types**: `src/types.ts` imported via `@worker/types` alias in `status-page/tsconfig.json`
- **Auth**: `status-page/src/lib/auth.ts`, configured via `STATUS_PUBLIC`, `STATUS_USERNAME`, `STATUS_PASSWORD` env vars - **Auth**: `status-page/src/lib/auth.ts`, configured via `STATUS_PUBLIC`, `STATUS_USERNAME`, `STATUS_PASSWORD` env vars
- **Banner**: Custom banner image via `STATUS_BANNER_URL` and `STATUS_BANNER_LINK` env vars - **Monitor config**: YAML inline in `wrangler.toml` `MONITORS_CONFIG` env var. Secrets interpolated via `${ENV_VAR}` syntax (`src/utils/interpolate.ts`).
## Commands ## Commands
@@ -17,11 +17,12 @@ npm workspace: Cloudflare Worker (`src/`) + Astro 6 SSR app (`status-page/`).
```bash ```bash
npm run dev # wrangler dev npm run dev # wrangler dev
npm run test # vitest (17 test files) npm run test # vitest (20 test files)
npm run typecheck # tsc --noEmit npm run typecheck # tsc --noEmit
npm run check # typecheck + lint + format:check npm run check # typecheck + lint + format:check
npm run check:fix # auto-fix lint + format npm run check:fix # auto-fix lint + format
npm run deploy # build:pages + wrangler deploy npm run deploy # build:pages + wrangler deploy
npm run lint:strict # oxlint --deny warnings + eslint --max-warnings=0
vitest run src/path/to.test.ts # single test (no npx needed) vitest run src/path/to.test.ts # single test (no npx needed)
``` ```
@@ -30,8 +31,8 @@ vitest run src/path/to.test.ts # single test (no npx needed)
```bash ```bash
npm run dev:pages # astro dev npm run dev:pages # astro dev
npm run build:pages # astro build → status-page/dist/ npm run build:pages # astro build → status-page/dist/
npm run test:pages # vitest (3 test files)
npm run check:pages # astro check + tsc --noEmit npm run check:pages # astro check + tsc --noEmit + eslint
npm run lint:pages # eslint (astro plugin) npm run lint:pages # eslint (astro plugin)
``` ```
@@ -39,10 +40,6 @@ npm run lint:pages # eslint (astro plugin)
Before commit: `npm run check && npm run test && npm run build:pages && npm run check:pages` Before commit: `npm run check && npm run test && npm run build:pages && npm run check:pages`
## Verification order
`npm run check` = typecheck + Oxlint (worker) + ESLint (dedup via `eslint-plugin-oxlint`). Pages uses `eslint-plugin-astro`.
## Gotchas ## Gotchas
- **`.js` extensions in imports**: All worker imports use `.js` extensions (`import { foo } from './bar.js'`). Required for ESM resolution with `moduleResolution: "bundler"`. - **`.js` extensions in imports**: All worker imports use `.js` extensions (`import { foo } from './bar.js'`). Required for ESM resolution with `moduleResolution: "bundler"`.
@@ -52,27 +49,11 @@ Before commit: `npm run check && npm run test && npm run build:pages && npm run
- **Pages `dist/` and `.astro/`**: Build artifacts, gitignored. - **Pages `dist/` and `.astro/`**: Build artifacts, gitignored.
- **Astro SSR build artifact**: Worker dynamically imports `../status-page/dist/server/index.mjs` at runtime — uses `@ts-expect-error`. - **Astro SSR build artifact**: Worker dynamically imports `../status-page/dist/server/index.mjs` at runtime — uses `@ts-expect-error`.
- **Astro 6 + @astrojs/cloudflare v13 workarounds**: `status-page/astro.config.mjs` includes `fixBuildRollupInput` plugin and `prerenderEnvironment: 'node'`. - **Astro 6 + @astrojs/cloudflare v13 workarounds**: `status-page/astro.config.mjs` includes `fixBuildRollupInput` plugin and `prerenderEnvironment: 'node'`.
- **Monitor config in `wrangler.toml`**: `MONITORS_CONFIG` env var contains full YAML config inline. Secrets interpolated via `${ENV_VAR}` syntax (`src/utils/interpolate.ts`).
## Code Style ## Code Style
- **Formatting**: Prettier — single quotes, semicolons, 100 char width, trailing commas ES5. - **Formatting**: Prettier — single quotes, semicolons, 100 char width, trailing commas ES5, no arrow parens.
- **Linting**: Oxlint (worker) + ESLint with `eslint-plugin-oxlint` dedup. Pages uses `eslint-plugin-astro`. - **Linting**: Oxlint (worker) + ESLint with `eslint-plugin-oxlint` dedup. Pages uses `eslint-plugin-astro`.
- **Types**: `type` for aliases, `interface` for object shapes. Explicit return types. - **Types**: `type` for aliases, `interface` for object shapes. Explicit return types.
- **Naming**: files `kebab-case.ts`, types `PascalCase`, variables `camelCase`, DB fields `snake_case`. - **Naming**: files `kebab-case.ts`, types `PascalCase`, variables `camelCase`, DB fields `snake_case`.
- **Tests**: `*.test.ts` colocated with source. Vitest with `vi` for mocks. - **Tests**: `*.test.ts` colocated with source. Vitest with `vi` for mocks.
## Banner Configuration
Set environment variables in `wrangler.toml` or Cloudflare dashboard:
```toml
[vars]
STATUS_BANNER_URL = "https://example.com/banner.png"
STATUS_BANNER_LINK = "https://example.com" # optional
```
- Banner replaces title text when `STATUS_BANNER_URL` is set
- Title is used as `alt` text for accessibility
- Link opens in same tab when `STATUS_BANNER_LINK` is set
- Empty or unset URL falls back to title display