Merge claude/drift-decisions-1163: PAYLOAD_SECRET minimum in production, doctor seen in CI, create --external

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-24 00:09:26 +01:00
co-authored by Claude Opus 5.5
31 changed files with 141 additions and 40 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
// pnpm dlx @intecion/ipal-kit@<version> create intecion.com → a new client site (docs/project-starter.md)
// pnpm exec ipal-kit create intecion.com --dir ../intecioncom-web --answers answers.json
// `pnpm dlx <package>` runs the bin named after the package, so every subcommand lives here.
// The other tools keep their own bins: ipal-skills, ipal-blocks, ipal-tokens.
// The other tools keep their own bins: ipal-skills, ipal-blocks, ipal-tokens, ipal-doctor.
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
@@ -11,7 +11,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
const USAGE = `Usage: ipal-kit <command> [options]
create <domain> a new client site from the reference site (ipal-kit create --help)
Other tools: ipal-skills, ipal-blocks, ipal-tokens`
Other tools: ipal-skills, ipal-blocks, ipal-tokens, ipal-doctor`
const [command, ...args] = process.argv.slice(2)
if (command !== 'create') {
+6 -6
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env node
// ipal-skills — copies the ipal-kit agent skills into the project.
// pnpm ipal-skills → ./.agents/skills/ipal-*
// pnpm ipal-skills --dry-run → show what would change
// pnpm ipal-skills --dest .claude/skills
// pnpm ipal-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone
// pnpm ipal-skills --external → also the vendored third-party skills (ext-*, pinned, text only)
// pnpm ipal-skills --external ext-accessibility,ext-payload → only those
// pnpm exec ipal-skills → ./.agents/skills/ipal-*
// pnpm exec ipal-skills --dry-run → show what would change
// pnpm exec ipal-skills --dest .claude/skills
// pnpm exec ipal-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone
// pnpm exec ipal-skills --external → also the vendored third-party skills (ext-*, pinned, text only)
// pnpm exec ipal-skills --external ext-accessibility,ext-payload → only those
// Only folders named ipal-* are touched; the project's own skills stay as they are.
// ipal-* folders that no longer exist in the package are removed (renamed/retired skills).
// ext-* folders are touched only with --external, and only those carrying ipal-kit's SOURCE.md.
+4
View File
@@ -49,6 +49,10 @@ Write new rules, AGENTS.md entries and plugin-gap reports in English.
`postgres://…@db:5432/intecioncom_prod`. You derive the names from the domain and confirm them with the owner (ipal-setup
stage 0). `ipalEnvRules({ databaseName: true })` warns when they do not match (deployment.md §4.2a).
**`PAYLOAD_SECRET`:** at least 32 random characters, different per environment (`ipal-kit create` writes 64). In
production `ipalEnvRules` refuses a shorter one (`secretMinLength`, default 32, `0` = off). Never change it on a live
site without the owner's OK: every login session and every stored API key depends on it (deployment.md §1).
**Seeding on production** (details: `node_modules/@intecion/ipal-kit/docs/seeding.md`). Write seeds with
`createSeeder` from `@intecion/ipal-kit/seed` (the templates do) — it enforces every rule below:
- Call `guardSeedExit()` first in every seed script (before `getPayload`): a run that ends early exits 1 with the reason
+1 -1
View File
@@ -231,7 +231,7 @@ and what throws without `i18n`: frontend.md. `SiteProviders` props: `shell`, `ba
| variable | required when | effect when missing | where to set |
|---|---|---|---|
| `DATABASE_URI` | always (Payload; `ipalEnvRules` always) | no database, startup fails | env (name: `databaseVar`); the database is named `<domain without dots>_prod` / `_dev` (`intecioncom_prod`), checked by `databaseName: true` |
| `PAYLOAD_SECRET` | always | Payload does not start; `assertEnv` throws | env, ≥32 characters, different in prod (`secretVar`) |
| `PAYLOAD_SECRET` | always; ≥ 32 characters in production (`ipalEnvRules({ secretMinLength })`, default 32, `0` = off) | Payload does not start; `assertEnv` throws (also for a too-short secret in production) | env, different in prod (`secretVar`) |
| `NEXT_PUBLIC_SERVER_URL` | always (`kind: 'url'`) | sitemap/robots/canonical/JSON-LD/llms with origin `''` (relative), IndexNow does not send, R2 relative URL without a prefix | env (`serverUrlVar`) |
| `NODE_ENV` | no (`development`/`production`/`test`) | `production` is stricter: R2 and `IPAL_IP_HEADER` required, IndexNow works, IP warning, `buildImagesConfig` prod | set by Next / hosting |
| `R2_BUCKET`, `R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` | `storage: true` + production, or when at least one is set (all or none) | local disk (in prod files disappear on redeploy); incomplete set → warning | env |
@@ -288,7 +288,7 @@ Opt-in with `ipalKit({ cookieScanner: true })`; the plugin wires the collection,
| Export | Import from | What it does / when |
|---|---|---|
| `assertEnv(rules, { env?, label? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | validates `process.env` against the rules at startup; collects every missing item and throws one error |
| `ipalEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IPAL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `<domain without dots>_prod` / `_dev` |
| `ipalEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, secretMinLength?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IPAL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `secretMinLength` (default 32, `0` = off) is the minimum `PAYLOAD_SECRET` length in production; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `<domain without dots>_prod` / `_dev` |
| `databaseNamesFor(domainOrUrl)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the two database names for a site: `intecion.com` → `{ prod: 'intecioncom_prod', dev: 'intecioncom_dev' }` (`www.` dropped, dots removed) |
| `databaseNameFromUri(uri)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the database name (URI path) of a Mongo / Postgres `DATABASE_URI`; null for SQLite files or no name |
| `checkDatabaseName({ databaseUri, domain })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | warning text when the name breaks the rule, else null (skips localhost / no domain) — what `databaseName` uses |
+1 -1
View File
@@ -199,7 +199,7 @@ export default buildConfig({
`R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_PUBLIC_URL` (empty = media through the app — the default), `IPAL_IP_HEADER` (`cf-connecting-ip`
behind Cloudflare, `x-forwarded-for` behind a plain proxy), `IPAL_NOINDEX` (empty; `1` on staging only), `INDEXNOW_KEY`,
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (panel fallback), with Graph `GRAPH_TENANT_ID`,
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters.
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `ipalEnvRules` refuses a shorter one; `secretMinLength` changes it).
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
**Check.** `pnpm payload generate:importmap` (whiteLabel adds admin components) and `pnpm generate:types` without
+14 -1
View File
@@ -24,12 +24,25 @@ DATABASE_URI=mongodb://user:pass@mongo:27017/intecioncom_prod?authSource=admin
# dev: …/intecioncom_dev, or file:./dev.db
# Payload secret (signs sessions/tokens) — random, long
PAYLOAD_SECRET=<random-string-min-32-chars>
PAYLOAD_SECRET=<random-string-min-32-chars> # ipalEnvRules: ≥ 32 characters in production (secretMinLength)
# Public site URL (canonical, hreflang, OG, manifest)
NEXT_PUBLIC_SERVER_URL=https://klient.pl # dev: http://localhost:3000
```
**`PAYLOAD_SECRET` — length and changing it.** `ipalEnvRules` refuses a secret shorter than 32 characters in
production (`secretMinLength`; `0` turns the check off, outside production nothing is checked). Payload (3.94)
derives its signing key from it (`sha256(secret)`, first 32 hex characters). Changing it on a live site therefore:
- **logs everyone out** — every login token (the `payload-token` cookie, JWTs from login / refresh / password reset)
is signed with it and stops being valid;
- **asks every user for the 2FA code again** — `@clocklimited/payload-2fa` signs its own 2FA cookie with it; the TOTP
keys themselves are stored as they are, so the authenticator apps keep working;
- **breaks stored API keys** (only in collections with `useAPIKey`) — Payload stores them encrypted with the secret
and finds them by an HMAC of it: they no longer authenticate and cannot be revealed — generate new ones;
- fails uploads that are in progress (client upload receipts are signed with it).
ipal-kit itself derives nothing from it. Change it only with the owner's OK, at a quiet time, and tell the editors
they will have to log in again.
### Email — Graph (OPTIONAL, agency-level, when transport = Graph)
```bash
+1 -1
View File
@@ -460,7 +460,7 @@ pnpm dev
| Variable | Required | Description |
|---|---|---|
| `DATABASE_URI` | ✅ | Postgres / Mongo (dev can use SQLite) |
| `PAYLOAD_SECRET` | ✅ | random, ≥32 characters, different in production |
| `PAYLOAD_SECRET` | ✅ | random, ≥32 characters, different in production — `ipalEnvRules` checks the length in production (`secretMinLength`, default 32, `0` = off) |
| `NEXT_PUBLIC_SERVER_URL` | ✅ | public URL (canonical, hreflang, OG); without it links are relative |
| `GRAPH_TENANT_ID`, `GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER` | ⬜ | email through Microsoft Graph |
| `R2_BUCKET`, `R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` | ✅ prod | media in Cloudflare R2 — always in production (missing → container disk, files vanish on redeploy without a volume); in dev they can be empty (storage.md) |
+2 -1
View File
@@ -66,13 +66,14 @@ ipalEnvRules({
turnstile?: boolean | { siteKeyVar?: string; secretVar?: string }, // NEXT_PUBLIC_TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY
serverUrlVar?: string, // default 'NEXT_PUBLIC_SERVER_URL'
secretVar?: string, // default 'PAYLOAD_SECRET'
secretMinLength?: number, // default 32 — minimum PAYLOAD_SECRET length, checked in production only; 0 = off
databaseVar?: string, // default 'DATABASE_URI'
databaseName?: boolean | { domain?: string; warn?: (message: string) => void },
// WARN (never fail) when the DATABASE_URI database is not <domain without dots>_prod / _dev
})
```
Always (core): `DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` (URL),
Always (core): `DATABASE_URI`, `PAYLOAD_SECRET` (in production at least `secretMinLength` = 32 characters), `NEXT_PUBLIC_SERVER_URL` (URL),
`NODE_ENV` (optional, oneOf `development`/`production`/`test`). The names `R2_*` / `GRAPH_*` /
`NEXT_PUBLIC_SERVER_URL` / `IPAL_IP_HEADER` / Turnstile match what the plugin modules
read; DB/secret are Payload variables — their names can be overridden.
+4 -1
View File
@@ -535,7 +535,10 @@ form), but `create`/`update`/`delete` and reading the Emails tab (recipients, BC
Validation matters, because a server action is a public endpoint — it can be called
without the form. The plugin loads the form definition and: rejects unknown
keys, enforces `required` fields, truncates length (5000 characters). Only what the
keys, enforces `required` fields and **rejects** a text value longer than 5000 characters — nothing is cut
or stored. The limit is fixed (no option today). The result is `{ success: false, reason: 'validation',
kind: 'too_long', field, label }`, and the visitor sees the **validation** text at that field ("Check the field
"{field}"." — Form messages → Form, `{field}` = the field's label) with every answer kept. Only what the
form defines reaches the database.
Rate limit: 5/min/IP by default (60 s window, the `form` counter is separate from search and MCP),
+3 -2
View File
@@ -24,8 +24,9 @@ SiteSettings tabs (unnamed — flat data): **General** (`siteName`, `siteDescrip
**Access:** SiteSettings has `read: () => true` — **the whole global, including fields from
`siteSettingsFields`, is public** over REST/GraphQL (`/api/globals/site-settings`).
Keep nothing confidential there (use SiteIntegrations for that, `read`/`update` admin only).
SiteSettings does not set `update` — Payload's default applies (any logged-in
user of an auth collection).
SiteSettings `update` requires the **editor** role or higher (a plain `user` account must not change the brand,
the homepage or the under-construction mode; without a `roles` field every logged-in account passes). Change it with
`ipalKit({ globalOverrides: { 'site-settings': { access: { update } } } })` (hooks.md).
## Front end — reading globals
@@ -231,7 +231,7 @@ and what throws without `i18n`: frontend.md. `SiteProviders` props: `shell`, `ba
| variable | required when | effect when missing | where to set |
|---|---|---|---|
| `DATABASE_URI` | always (Payload; `ipalEnvRules` always) | no database, startup fails | env (name: `databaseVar`); the database is named `<domain without dots>_prod` / `_dev` (`intecioncom_prod`), checked by `databaseName: true` |
| `PAYLOAD_SECRET` | always | Payload does not start; `assertEnv` throws | env, ≥32 characters, different in prod (`secretVar`) |
| `PAYLOAD_SECRET` | always; ≥ 32 characters in production (`ipalEnvRules({ secretMinLength })`, default 32, `0` = off) | Payload does not start; `assertEnv` throws (also for a too-short secret in production) | env, different in prod (`secretVar`) |
| `NEXT_PUBLIC_SERVER_URL` | always (`kind: 'url'`) | sitemap/robots/canonical/JSON-LD/llms with origin `''` (relative), IndexNow does not send, R2 relative URL without a prefix | env (`serverUrlVar`) |
| `NODE_ENV` | no (`development`/`production`/`test`) | `production` is stricter: R2 and `IPAL_IP_HEADER` required, IndexNow works, IP warning, `buildImagesConfig` prod | set by Next / hosting |
| `R2_BUCKET`, `R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` | `storage: true` + production, or when at least one is set (all or none) | local disk (in prod files disappear on redeploy); incomplete set → warning | env |
@@ -288,7 +288,7 @@ Opt-in with `ipalKit({ cookieScanner: true })`; the plugin wires the collection,
| Export | Import from | What it does / when |
|---|---|---|
| `assertEnv(rules, { env?, label? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | validates `process.env` against the rules at startup; collects every missing item and throws one error |
| `ipalEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IPAL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `<domain without dots>_prod` / `_dev` |
| `ipalEnvRules({ storage?, emailGraph?, ipHeader?, turnstile?, serverUrlVar?, secretVar?, secretMinLength?, databaseVar?, databaseName? })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | ready rule set (`DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` + `R2_*`/`GRAPH_*`/Turnstile/`IPAL_IP_HEADER` depending on the features used) for `assertEnv`; `R2_PUBLIC_URL` optional unless `storage: { requirePublicUrl: true }`; `secretMinLength` (default 32, `0` = off) is the minimum `PAYLOAD_SECRET` length in production; `databaseName: true \| { domain?, warn? }` only warns when the `DATABASE_URI` database is not `<domain without dots>_prod` / `_dev` |
| `databaseNamesFor(domainOrUrl)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the two database names for a site: `intecion.com` → `{ prod: 'intecioncom_prod', dev: 'intecioncom_dev' }` (`www.` dropped, dots removed) |
| `databaseNameFromUri(uri)` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | the database name (URI path) of a Mongo / Postgres `DATABASE_URI`; null for SQLite files or no name |
| `checkDatabaseName({ databaseUri, domain })` | `@intecion/ipal-kit/env`, `@intecion/ipal-kit` | warning text when the name breaks the rule, else null (skips localhost / no domain) — what `databaseName` uses |
+1 -1
View File
@@ -199,7 +199,7 @@ export default buildConfig({
`R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_PUBLIC_URL` (empty = media through the app — the default), `IPAL_IP_HEADER` (`cf-connecting-ip`
behind Cloudflare, `x-forwarded-for` behind a plain proxy), `IPAL_NOINDEX` (empty; `1` on staging only), `INDEXNOW_KEY`,
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (panel fallback), with Graph `GRAPH_TENANT_ID`,
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters.
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `ipalEnvRules` refuses a shorter one; `secretMinLength` changes it).
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
**Check.** `pnpm payload generate:importmap` (whiteLabel adds admin components) and `pnpm generate:types` without
+1 -1
View File
@@ -120,7 +120,7 @@ const lightboxText = (
})
/**
* The "Lightbox" group — labels of the image viewer (<LightboxProvider texts>).
* The "Image viewer" group (`lightbox`) — labels of the image viewer (<LightboxProvider texts>).
* Added by ipalKit `lightbox: true`; exported so a project can place it in its
* own global instead.
*/
+1 -1
View File
@@ -371,7 +371,7 @@ export { buildLlmsTxt } from './modules/seo/index.js'
// Site Settings → Title separator: stored name → character; SQL for the 1.14.x → GraphQL-safe values migration.
export { TITLE_SEPARATORS, titleSeparatorChar, titleSeparatorSql } from './modules/seo/index.js'
export type { TitleSeparatorName } from './modules/seo/index.js'
// Site Settings → Search & AI: verification codes and AI crawler rules, for custom metadata/robots routes.
// Site Settings → Search engines: verification codes and AI crawler rules, for custom metadata/robots routes.
export { robotsOptionsFrom, verificationFrom } from './modules/seo/index.js'
export type { AiBotRule, AiBotsPolicy, VerificationMetadata } from './modules/seo/index.js'
export { buildSitemapCss, buildSitemapIndexXml, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js'
+9 -1
View File
@@ -26,6 +26,14 @@ export const DOCTOR_USAGE = `Usage: ipal-doctor [dir] [options]
Exit: 0 ok · 1 findings at or above --fail-on · 2 could not run · 3 a rule crashed
Silence a rule with a reason in ipal-doctor.json — docs/doctor.md`
/**
* Whether this run stores first-seen dates in ipal-doctor.json: not with --sites or --json, and
* never when CI is set (a CI run must not change a tracked file).
*/
export function shouldWriteSeen(args: { json?: boolean; sites?: unknown }, env: Record<string, string | undefined> = process.env): boolean {
return !args.sites && !args.json && !env.CI
}
const RANK: Record<DoctorSeverity, number> = { error: 3, info: 1, warning: 2 }
type Args = {
@@ -132,7 +140,7 @@ export async function runDoctorCli(argv: string[], { cwd = process.cwd(), log =
skip: args.skip,
staging: args.staging,
url: args.sites ? undefined : args.url,
writeSeen: !args.sites && !args.json,
writeSeen: shouldWriteSeen(args),
}),
)
}
+15 -1
View File
@@ -26,6 +26,11 @@ export type IpalEnvFeatures = {
* the client IP (see clientIp). Outside production it stays optional.
*/
ipHeader?: boolean
/**
* Minimum length of PAYLOAD_SECRET, checked in production only (NODE_ENV=production). Payload signs
* login tokens and encrypts API keys with it, so a short secret is weak. Default 32; 0 turns it off.
*/
secretMinLength?: number
/** Override the Payload secret var. Default 'PAYLOAD_SECRET'. */
secretVar?: string
/** Override the site-URL var. Default 'NEXT_PUBLIC_SERVER_URL'. */
@@ -75,6 +80,7 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
databaseVar = 'DATABASE_URI',
emailGraph = false,
ipHeader = false,
secretMinLength = 32,
secretVar = 'PAYLOAD_SECRET',
serverUrlVar = 'NEXT_PUBLIC_SERVER_URL',
storage = false,
@@ -83,7 +89,15 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
const rules: EnvRule[] = [
{ name: databaseVar, description: 'Database connection string (e.g. MongoDB URI)' },
{ name: secretVar, description: 'Payload secret used to sign tokens' },
{
name: secretVar,
description: 'Payload secret used to sign tokens',
...(secretMinLength > 0 && process.env.NODE_ENV === 'production' && {
validate: (value: string) =>
value.length >= secretMinLength ||
`${secretVar} must be at least ${secretMinLength} characters in production (got ${value.length}) — use a long random value, or ipalEnvRules({ secretMinLength }) to change the minimum (0 turns the check off)`,
}),
},
{ name: serverUrlVar, description: 'Public site origin, e.g. https://example.com', kind: 'url' },
{
name: 'NODE_ENV',
+3 -3
View File
@@ -504,7 +504,7 @@ export function createContentHelpers({
const robots = (): RobotsRules => buildRobots({ ...robotsOptions, baseUrl: origin })
/**
* `robots` plus what editors set in Site Settings → Search & AI (AI bot policy
* `robots` plus what editors set in Site Settings → Search engines (AI bot policy
* and per-bot exceptions), read per request. Use it instead of `robots` to
* let the panel manage AI crawlers:
*
@@ -546,8 +546,8 @@ export function createContentHelpers({
* the strongest fix for the metadata-in-head problem (stronger than ISR alone).
*
* Handles automatically:
* - pages collection + content collections (with their archive prefix)
* - excludes the homepage (maps to { slug: [] } — the root)
* - the pages collection only (content-collection entries render on first request)
* - the homepage as the root ({ slug: [] })
* - excludes drafts and 404/500/system slugs
* - KEEPS noindex pages (they must still render — noindex controls indexing,
* not existence; skipping them would force dynamic rendering)
+2 -2
View File
@@ -62,7 +62,7 @@ const day = (iso?: string) => (iso ? iso.slice(0, 10) : undefined)
* and pages, so it can generate this automatically.
*
* Structure (llmstxt.org): H1 site name, a blockquote summary, the editor's
* note from Site Settings → Search & AI (when set), then — per
* note from Site Settings → Search engines (when set), then — per
* language when the site has several — one list per collection (pages first,
* then archive collections such as a blog) of Markdown links with descriptions.
* Section names are the project's own locale and collection labels; the plugin
@@ -115,7 +115,7 @@ export async function buildLlmsTxt({
const lines: string[] = [`# ${name}`, '']
if (description) {lines.push(`> ${description}`, '')}
// Site Settings → Search & AI: facts the editor wants assistants to know and quote.
// Site Settings → Search engines: facts the editor wants assistants to know and quote.
const intro = llmsIntroFrom(settings)
if (intro) {lines.push(intro, '')}
+1 -1
View File
@@ -125,7 +125,7 @@ type BuildMetadataArgs = {
siteName?: null | string
/** slug per locale for this document — drives canonical + hreflang. */
slugs: LocalizedSlugs
/** Site Settings → Search & AI verification codes; rendered as <meta> tags by Next. */
/** Site Settings → Search engines verification codes; rendered as <meta> tags by Next. */
verification?: VerificationMetadata
}
+1 -1
View File
@@ -50,7 +50,7 @@ export type RobotsOptions = {
/**
* Per-bot exceptions that win over `aiBots` — a listed bot leaves its policy
* group and gets its own allow or block. Unknown bots can be added this way.
* Site Settings → Search & AI fills it when you use `getRobots`.
* Site Settings → Search engines fills it when you use `getRobots`.
*/
aiBotRules?: readonly AiBotRule[]
/**
+1 -1
View File
@@ -29,7 +29,7 @@ export type SiteMetaConfig = {
/** Global fallback meta description. */
siteDescription?: null | string
siteName: null | string
/** Site Settings → Search & AI → verification codes (Search Console, Bing, Yandex). */
/** Site Settings → Search engines → verification codes (Search Console, Bing, Yandex). */
verification?: VerificationMetadata
}
+1 -1
View File
@@ -37,7 +37,7 @@ export type SeoOption = {
/** Optional: customize how meta titles are generated in the admin preview. */
generateTitle?: (args: { doc: Record<string, unknown> }) => string
/**
* Site Settings → "Search & AI" tab: Search Console / Bing / Yandex
* Site Settings → "Search engines" tab: Search Console / Bing / Yandex
* verification, AI crawler policy for robots.txt (getRobots), llms.txt note.
* On by default (empty fields change nothing); false removes the tab; a
* function gets the plugin's fields and returns the tab's fields (add, drop,
+16 -1
View File
@@ -45,6 +45,19 @@ const here = dirname(fileURLToPath(import.meta.url))
// dist/modules/starter → package root
const pkgRoot = resolve(here, '..', '..', '..')
/** Every vendored external skill (docs/agent/external/manifest.json) — what a bare `--external` installs. */
export function externalSkillNames(root = pkgRoot): string[] {
const manifest = join(root, 'docs', 'agent', 'external', 'manifest.json')
if (!existsSync(manifest)) {return []}
return (JSON.parse(readFileSync(manifest, 'utf8')) as { skills: { name: string }[] }).skills.map((skill) => skill.name)
}
/** The skills `--external` asks for: a list as given, a bare flag = every external skill, no flag = null. */
export function resolveExternal(external: null | string[], all: () => string[] = externalSkillNames): null | string[] {
if (external === null) {return null}
return external.length ? external : all()
}
function value(args: string[], name: string): string | undefined {
const i = args.indexOf(name)
if (i < 0) {return undefined}
@@ -129,7 +142,9 @@ async function readAnswers(options: CreateOptions): Promise<StarterAnswers> {
const answers = options.answersFile
? (JSON.parse(readFileSync(resolve(options.answersFile), 'utf8')) as StarterAnswers)
: await askInTerminal()
if (options.external?.length && answers.tooling) {answers.tooling.external = options.external}
// A bare --external means every external skill (CREATE_USAGE); without the flag the answers decide.
const external = resolveExternal(options.external)
if (external && answers.tooling) {answers.tooling.external = external}
return answers
}
+1 -1
View File
@@ -273,7 +273,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}) }
const iconProps = { ...serverProps, ...(wl.iconField ? { imageField: wl.iconField } : {}) }
// Vendor credit ("Technology by Intecion.com") under the nav — on by
// Vendor credit ("Technology support: Intecion.com") under the nav — on by
// default, hidden with credit:false, text/url overridable.
const creditOn = wl.credit !== false && agency !== false
const creditProps = {
+2 -2
View File
@@ -172,7 +172,7 @@ export type IpalOptions = {
revalidatePath?: RevalidatePathFn
/**
* Site Settings → "Search & AI" tab (verification codes, AI crawler policy,
* Site Settings → "Search engines" tab (verification codes, AI crawler policy,
* llms.txt intro). On by default; `false` removes it; a function gets the
* plugin's fields and returns the tab's fields. Works without `seo`; wins
* over `seo.searchSettings`.
@@ -278,7 +278,7 @@ export type IpalOptions = {
whiteLabel?:
| {
/**
* Vendor credit ("Technology by Intecion.com") at the bottom of the
* Vendor credit ("Technology support: Intecion.com") at the bottom of the
* admin nav. Default on; `false` hides it, or override text/url.
*/
credit?:
+10 -1
View File
@@ -6,7 +6,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vite
import type { DoctorConfig, DoctorReport } from '../src/modules/doctor/types.js'
import { expandSites, parseDoctorArgs, runDoctorCli } from '../src/modules/doctor/cli.js'
import { expandSites, parseDoctorArgs, runDoctorCli, shouldWriteSeen } from '../src/modules/doctor/cli.js'
import { formatDriftTable, formatReport } from '../src/modules/doctor/format.js'
import { bareHost, parseEnvFile, readAuditSkips } from '../src/modules/doctor/project.js'
import { planSkills } from '../src/modules/doctor/rules/agents.js'
@@ -452,3 +452,12 @@ describe('the reference site', () => {
for (const setting of Object.values(config.rules ?? {})) {expect(setting.reason?.trim()).toBeTruthy()}
})
})
describe('ipal-doctor: first-seen dates', () => {
test('are written only outside CI, and never with --json or --sites', () => {
expect(shouldWriteSeen({}, {})).toBe(true)
expect(shouldWriteSeen({}, { CI: 'true' })).toBe(false)
expect(shouldWriteSeen({ json: true }, {})).toBe(false)
expect(shouldWriteSeen({ sites: 'clients/*' }, {})).toBe(false)
})
})
+25 -1
View File
@@ -4,7 +4,7 @@ import { assertEnv } from '../src/modules/env/assertEnv.js'
import { checkDatabaseName, databaseNameFromUri, databaseNamesFor } from '../src/modules/env/databaseName.js'
import { ipalEnvRules } from '../src/modules/env/ipalEnvRules.js'
const base = { DATABASE_URI: 'mongodb://db/x', NEXT_PUBLIC_SERVER_URL: 'http://localhost:3000', PAYLOAD_SECRET: 's' }
const base = { DATABASE_URI: 'mongodb://db/x', NEXT_PUBLIC_SERVER_URL: 'http://localhost:3000', PAYLOAD_SECRET: 'a-long-random-test-secret-of-32-chars' }
const r2 = {
R2_ACCESS_KEY_ID: 'k',
R2_BUCKET: 'b',
@@ -90,3 +90,27 @@ describe('database naming rule', () => {
vi.unstubAllEnvs()
})
})
describe('PAYLOAD_SECRET minimum length', () => {
const env = { DATABASE_URI: 'mongodb://db/x', NEXT_PUBLIC_SERVER_URL: 'https://acme.pl', PAYLOAD_SECRET: 'short-secret' }
afterEach(() => vi.unstubAllEnvs())
test('a short secret fails in production', () => {
vi.stubEnv('NODE_ENV', 'production')
expect(() => assertEnv(ipalEnvRules(), { env })).toThrow(/PAYLOAD_SECRET must be at least 32 characters in production \(got 12\)/)
expect(() => assertEnv(ipalEnvRules(), { env: { ...env, PAYLOAD_SECRET: 'x'.repeat(32) } })).not.toThrow()
})
test('a short secret passes outside production', () => {
vi.stubEnv('NODE_ENV', 'development')
expect(() => assertEnv(ipalEnvRules(), { env })).not.toThrow()
})
test('secretMinLength: 0 turns the check off; a custom minimum is used', () => {
vi.stubEnv('NODE_ENV', 'production')
expect(() => assertEnv(ipalEnvRules({ secretMinLength: 0 }), { env })).not.toThrow()
expect(() => assertEnv(ipalEnvRules({ secretMinLength: 64 }), { env: { ...env, PAYLOAD_SECRET: 'x'.repeat(40) } })).toThrow(/at least 64 characters/)
expect(() => assertEnv(ipalEnvRules({ secretMinLength: 8 }), { env })).not.toThrow()
expect(() => assertEnv(ipalEnvRules({ secretVar: 'MY_SECRET' }), { env: { ...env, MY_SECRET: 'short' } })).toThrow(/MY_SECRET must be at least 32/)
})
})
+1 -1
View File
@@ -116,7 +116,7 @@ describe('IPAL_IP_HEADER', () => {
test('ipalEnvRules({ ipHeader }) requires it in production only', async () => {
const { assertEnv } = await import('../src/modules/env/assertEnv.js')
const { ipalEnvRules } = await import('../src/modules/env/ipalEnvRules.js')
const base = { DATABASE_URI: 'x', NEXT_PUBLIC_SERVER_URL: 'https://acme.pl', PAYLOAD_SECRET: 'x' }
const base = { DATABASE_URI: 'x', NEXT_PUBLIC_SERVER_URL: 'https://acme.pl', PAYLOAD_SECRET: 'a-long-random-test-secret-of-32-chars' }
vi.stubEnv('NODE_ENV', 'production')
expect(() => assertEnv(ipalEnvRules({ ipHeader: true }), { env: base })).toThrow(/IPAL_IP_HEADER/)
expect(() => assertEnv(ipalEnvRules({ ipHeader: true }), { env: { ...base, IPAL_IP_HEADER: 'cf-connecting-ip' } })).not.toThrow()
+9
View File
@@ -29,6 +29,7 @@ import {
unpackBundle,
validateAnswers,
} from '../src/exports/starter.js'
import { externalSkillNames, resolveExternal } from '../src/modules/starter/cli.js'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const reference = path.join(root, 'reference')
@@ -192,6 +193,14 @@ describe('starter: generated files', () => {
expect(() => normalizeDomain('localhost')).toThrow(/not a domain/)
expect(parseCreateArgs(['acme.pl', '--answers', 'a.json', '--external', '--no-git'])).toMatchObject({ answersFile: 'a.json', domain: 'acme.pl', external: [], git: false, install: true })
})
it('a bare --external means every external skill; a list stays as given', () => {
const all = externalSkillNames()
expect(all).toContain('ext-accessibility')
expect(resolveExternal([], () => all)).toEqual(all)
expect(resolveExternal(['ext-payload'])).toEqual(['ext-payload'])
expect(resolveExternal(null)).toBeNull()
})
})
describe.runIf(existsSync(path.join(reference, 'starter.manifest.json')))('starter: the reference site', () => {