Update AGENTS.md file

This commit is contained in:
2026-03-28 12:16:52 -05:00
parent 4c97c7fa17
commit e24b592951
5 changed files with 37 additions and 16 deletions

View File

@@ -121,6 +121,12 @@ configured and difficult to re-stabilize.
### Always do these: ### Always do these:
- **ALWAYS update `AGENTS.md` when your work changes anything documented here** —
architecture, file paths, new files, Payload config, known issues, workflows. Do
this in the same task, not as a follow-up. The intro says this too but it bears
repeating as a hard rule: the next agent reads this file first and will be misled
by stale information.
- **ALWAYS use `bun typecheck` to validate your work**, never `bun build`. Typecheck - **ALWAYS use `bun typecheck` to validate your work**, never `bun build`. Typecheck
is fast and sufficient. Build is slow and for production deployments only. is fast and sufficient. Build is slow and for production deployments only.
@@ -531,9 +537,11 @@ packages/backend/
│ ├── auth.ts # Auth setup + all user-related functions │ ├── auth.ts # Auth setup + all user-related functions
│ ├── crons.ts # Cron jobs (commented examples) │ ├── crons.ts # Cron jobs (commented examples)
│ ├── files.ts # File upload/storage │ ├── files.ts # File upload/storage
│ ├── globals.d.ts # Types process.env for Convex backend env vars
│ ├── http.ts # HTTP routes (auth only) — DO NOT TOUCH │ ├── http.ts # HTTP routes (auth only) — DO NOT TOUCH
│ ├── schema.ts # Database schema — the source of truth │ ├── schema.ts # Database schema — the source of truth
│ └── tsconfig.json # Convex-required TS config │ └── tsconfig.json # Convex-required TS config
├── eslint.config.ts # ESLint config for the backend package
├── scripts/ ├── scripts/
│ └── generateKeys.mjs # RS256 JWT keypair generator for Convex Auth │ └── generateKeys.mjs # RS256 JWT keypair generator for Convex Auth
└── types/ └── types/
@@ -547,6 +555,19 @@ structure. When `bun typecheck` runs from the repo root, it will print TypeScrip
output for `@gib/backend` (because there's no valid project to check). This is output for `@gib/backend` (because there's no valid project to check). This is
expected and not an error. expected and not an error.
**Note on `globals.d.ts`:** The Convex runtime supports `process.env` for reading
environment variables set in the Convex Dashboard. Because the Convex tsconfig does
not include `@types/node`, `process` would otherwise be untyped. `globals.d.ts`
declares `process.env` with the specific variables this backend uses. If you add a
new env var to the Convex backend, add it here too so TypeScript and ESLint are happy.
**Note on `convex/utils.ts`:** This file may be regenerated by `convex dev` as a
Convex CLI utility scaffold. It contains `missingEnvVariableUrl` / `deploymentName`
helpers that reference `CONVEX_CLOUD_URL` — a Convex Cloud concept irrelevant to this
self-hosted setup. If the file reappears, you can safely delete it (nothing in the
codebase imports it) or leave it — it won't affect runtime behaviour since the
functions are never called.
### Schema design — always extend `users` directly ### Schema design — always extend `users` directly
The preferred and enforced approach in this repo is to **extend the `users` table The preferred and enforced approach in this repo is to **extend the `users` table
@@ -825,6 +846,14 @@ Current state of the template:
content is partial or missing fields content is partial or missing fields
- live preview works by loading `/` with `?preview=true` and rendering - live preview works by loading `/` with `?preview=true` and rendering
`RefreshRouteOnSave` `RefreshRouteOnSave`
- `payload.config.ts` sets `serverURL: env.NEXT_PUBLIC_SITE_URL` — required for
Payload to construct absolute URLs in the admin UI and live preview
- `get-landing-page-content.ts` only calls `noStore()` when `isPreview` is true —
normal (non-preview) requests are cacheable by Next.js. Do not add `noStore()`
back unconditionally.
- `apps/next/src/app/(frontend)/page.tsx` wraps the Payload fetch in a try/catch and
falls back to `defaultLandingPageContent` if Postgres is unreachable — the landing
page always renders even when the CMS is down
If you need a deeper walkthrough, read `docs/payload-cms.md`. That file should stay in If you need a deeper walkthrough, read `docs/payload-cms.md`. That file should stay in
sync with the actual Payload implementation in this repo. sync with the actual Payload implementation in this repo.

View File

@@ -77,15 +77,9 @@ export interface Config {
collectionsSelect: { collectionsSelect: {
users: UsersSelect<false> | UsersSelect<true>; users: UsersSelect<false> | UsersSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>; 'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-locked-documents': 'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
| PayloadLockedDocumentsSelect<false> 'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
| PayloadLockedDocumentsSelect<true>; 'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
'payload-preferences':
| PayloadPreferencesSelect<false>
| PayloadPreferencesSelect<true>;
'payload-migrations':
| PayloadMigrationsSelect<false>
| PayloadMigrationsSelect<true>;
}; };
db: { db: {
defaultIDType: number; defaultIDType: number;
@@ -639,6 +633,7 @@ export interface Auth {
[k: string]: unknown; [k: string]: unknown;
} }
declare module 'payload' { declare module 'payload' {
export interface GeneratedTypes extends Config {} export interface GeneratedTypes extends Config {}
} }

View File

@@ -1,6 +1,5 @@
import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc'; import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc'
export const importMap = { export const importMap = {
'@payloadcms/next/rsc#CollectionCards': "@payloadcms/next/rsc#CollectionCards": CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1
CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1, }
};

View File

@@ -5,7 +5,6 @@ declare const process: {
readonly USESEND_API_KEY?: string; readonly USESEND_API_KEY?: string;
readonly USESEND_URL?: string; readonly USESEND_URL?: string;
readonly USESEND_FROM_EMAIL?: string; readonly USESEND_FROM_EMAIL?: string;
readonly CONVEX_CLOUD_URL?: string;
readonly [key: string]: string | undefined; readonly [key: string]: string | undefined;
}; };
}; };

View File

@@ -16,7 +16,6 @@
"CONVEX_SELF_HOSTED_URL", "CONVEX_SELF_HOSTED_URL",
"CONVEX_SELF_HOSTED_ADMIN_KEY", "CONVEX_SELF_HOSTED_ADMIN_KEY",
"CONVEX_SITE_URL", "CONVEX_SITE_URL",
"CONVEX_CLOUD_URL",
"USESEND_API_KEY", "USESEND_API_KEY",
"USESEND_URL", "USESEND_URL",
"USESEND_FROM_EMAIL", "USESEND_FROM_EMAIL",