ipal-doctor: one command that checks a site against the team rules

bin ipal-doctor + @intecion/ipal-kit/doctor: static rules (versions, Node 22, AGENT.md §3
layout and naming, database names, env rules, headers, X-Powered-By, CSP, 2FA, cookie
scanner, adminMeta, AGENTS.md, skills, seeds, block library via blockLibraryManifest,
ipal-audit --quick), registry rules (latest plugin, pnpm audit --prod), live rules (--url,
ipal-seo-check), deep rules (--deep via payload run; GET /api/ipal/doctor, off until
IPAL_DOCTOR_TOKEN). Human / JSON output, --strict, exit codes 0/1/2/3, --sites drift table,
ipal-doctor.json with reasons, until, files, seen.

Fixes found on the way: sitemap leaves out the System pages 404 page; ipal-audit finds
array labels after fields, any form seed, runs grep in UTF-8; ipal-seo-check counts
duplicate titles per language. Reference site at zero findings (static), CI steps on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 16:03:00 +01:00
co-authored by Claude Opus 5.5
parent 0ab133fbd7
commit a4e8cfeae8
62 changed files with 2998 additions and 70 deletions
+17
View File
@@ -14,6 +14,17 @@ Database names follow one rule, and seeding a live site touches only the records
fifteen ready page sections and ten page templates.
### New
- **`ipal-doctor`** ([doctor.md](./doctor.md)): one command, run in a site, that checks it against the team rules and
lists every gap with a fix hint — plugin/Next/sharp/Node versions, the AGENT.md §3 layout and naming, database names,
env rules, security headers, X-Powered-By, CSP, 2FA, the cookie scanner, adminMeta, AGENTS.md "Project decisions",
current skills, seeds (`createSeeder`, no deletes, guard on), the block library (`blockLibraryManifest`), `pnpm audit
--prod`, hardcoded texts (it runs `ipal-audit --quick`). `--url` checks the running site (and runs `ipal-seo-check`),
`--deep` reads the database read-only through `payload run`. Human or `--json` output, `--strict`, exit codes 0/1/2/3,
`--sites '../*-web'` for a read-only drift table. `ipal-doctor.json` silences, lowers or raises a rule with a reason
(`until`, `files`). New bin `ipal-doctor`, new entry `@intecion/ipal-kit/doctor`, new skill **ipal-doctor**.
- **`GET /api/ipal/doctor`**: read-only counts for the doctor (users without TOTP, cookies waiting for approval,
versions). 404 until `IPAL_DOCTOR_TOKEN` (≥ 32 characters) is set; Bearer token, rate-limited. `ipalKit({ doctor: false })`
removes it.
- **Design-token standard** ([design-tokens.md](./design-tokens.md)): one set of `--ipal-*` names for every site,
only the values differ per brand. `@intecion/ipal-kit/tokens.css` (neutral defaults, light/dark on `data-theme`,
`[data-surface="inverse"]` scope, reduced motion), `@intecion/ipal-kit/tailwind.css` (Tailwind 4 preset: `bg-surface`,
@@ -50,6 +61,12 @@ fifteen ready page sections and ten page templates.
plugin repo (`reference/`, not shipped) and is built, seeded and smoke-tested in the plugin's CI.
### Changed
- **Sitemap:** the page assigned as the 404 in *Site settings → System pages* is left out whatever its slug (only
the slugs `404`, `500`, `error`, `not-found` were left out; a 404 page called `nie-znaleziono` was listed and answered 404).
- **ipal-seo-check:** duplicate titles are counted per language (the same word in two languages is not a duplicate).
- **ipal-audit:** array `labels` / `rowLabel` after the `fields` key are found (were reported missing); a form seeded
from any seed file (`src/seed/forms.ts`, `upsertBy('forms', …)`) counts as a form seed; the script runs grep in UTF-8
(in the C locale an en dash matched the Polish-letter check).
- **Cookie banner / button colours** read the single token names (`--ipal-surface`, `--ipal-text` …) instead of
`dark:` + `--ipal-*-dark`. With `tokens.css` they switch with the theme. Without it, the built-in fallback follows the
page's `color-scheme` (`light-dark()`): a site without a dark theme no longer gets a dark banner on a dark-mode
+1
View File
@@ -54,6 +54,7 @@ API details — one file per module:
| Design tokens (`--ipal-*`, `tokens.css`, `tailwind.css`, `ipal-tokens`, DESIGN.md) | [design-tokens.md](./design-tokens.md) |
| R2, `buildImagesConfig`, `MediaPreconnect`, `YouTubeEmbed` | [storage.md](./storage.md) |
| Turnstile | [turnstile.md](./turnstile.md) |
| ipal-doctor (the site against the team standard, `ipal-doctor.json`) | [doctor.md](./doctor.md) |
| Admin panel white-label | [white-label.md](./white-label.md) |
Maintenance rule: a module's API changes → update its file in the same commit. New working rules →
+7 -2
View File
@@ -1244,9 +1244,12 @@ Record the key project decisions (stack, decisions, page modes) in the project's
## 11. BEFORE YOU SAY "DONE"
**Run, do not guess** — `ipal-audit` (the §0b set + the rules below) and `ipal-seo-check`
(GEO and SEO on the built site) instead of manual greps:
(GEO and SEO on the built site) instead of manual greps; then `ipal-doctor` for the whole site against the team
standard (versions, Node 22, layout, database names, env, headers, 2FA, cookie scanner, AGENTS.md, skills, seeds,
block library — [doctor.md](../doctor.md)):
```bash
bash .agents/skills/ipal-audit/scripts/audit.sh
pnpm exec ipal-doctor # + --deep --url http://localhost:3000 on the built site
node .agents/skills/ipal-seo-check/scripts/seo-check.mjs http://localhost:3000
pnpm generate:types && pnpm tsc --noEmit
pnpm build # --webpack in the script; locally, not only dev
@@ -1318,6 +1321,7 @@ Anything that needs a developer → move it to the panel.
| Seeds on production: create-only, dry run, backup, update guard | [seeding.md](../seeding.md) |
| Meta Pixel / GA4 via GTM | [gtm-meta-pixel.md](../gtm-meta-pixel.md) |
| Turnstile | [turnstile.md](../turnstile.md) |
| ipal-doctor: the site against the team standard, `ipal-doctor.json`, `/api/ipal/doctor` | [doctor.md](../doctor.md) |
| Panel white-label | [white-label.md](../white-label.md) |
---
@@ -1388,9 +1392,10 @@ the task matches — manually: `/<name>`.
| `ipal-audit` | before every "done" — the §0b set + the §11 checks + panel (§6.5a) + hardcoding in JSX + tsc + build |
| `ipal-seo-check` | the running site through the eyes of Googlebot and AI agents (head, canonical, hreflang, sitemap, 404, JSON-LD, llms, Markdown, MCP) |
| `ipal-consent-check` | browser: no tracking pixels or cookies before consent; the Google tag may load before consent only in Consent Mode `advanced` (all signals `denied`) — a client who wants zero requests gets `consentMode: 'basic'` |
| `ipal-doctor` | the whole site against the team standard in one command (`pnpm exec ipal-doctor`): versions, Node 22, layout, database names, env, headers, CSP, 2FA, cookie scanner, adminMeta, AGENTS.md, skills, seeds, block library, pnpm audit; `--url` / `--deep` for the running site and the database; `--strict` in the CI of a new site |
| `ipal-plugin-gap` | ipal-kit has a bug or is missing a feature — report to the owner, wait for the decision; a marked workaround only after approval |
Run the scripts in the skills, do not read them (the output is enough): `ipal-audit/scripts/audit.sh`,
Run the scripts in the skills, do not read them (the output is enough): `ipal-audit/scripts/audit.sh`, `pnpm exec ipal-doctor`,
`ipal-seo-check/scripts/seo-check.mjs`, `ipal-consent-check/scripts/consent-check.mjs`,
`ipal-locale-add/scripts/locale-coverage.ts`; templates to copy are in `resources/`.
+22 -4
View File
@@ -63,7 +63,20 @@ legacy-peer-deps=true
```json
{
"domain": "example-studio.pl",
"launched": false
"launched": false,
"rules": {
"audit:collections-present": {
"off": true,
"reason": "Project decisions: posts and caseStudies with archive pages; entryFields.ts is their shared field helper, not a collection"
},
"i18n-literals": {
"off": true,
"files": [
"src/components/design/**"
],
"reason": "Approved exception (AGENTS.md → Project decisions): the /design styleguide has its labels in code"
}
}
}
```
@@ -242,10 +255,11 @@ export function register() {
if (process.env.NEXT_RUNTIME !== 'nodejs') {return}
// storage: R2 is required in production. ALLOW_LOCAL_MEDIA=1 lets a production build run on local disk for
// local checks and CI only — never set it in Coolify.
// cookieCrawl: IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN in production (cookieScanner.crawl, the shared service).
// databaseName: DATABASE_URI must name example-studiopl_dev / example-studiopl_prod (databaseNamesFor).
// R2_PUBLIC_URL optional: media are served through the app by default (storage.md, env.md).
assertEnv(
ipalEnvRules({ databaseName: { domain: 'example-studio.pl' }, ipHeader: true, storage: process.env.ALLOW_LOCAL_MEDIA !== '1' }).map((rule) =>
ipalEnvRules({ cookieCrawl: true, databaseName: { domain: 'example-studio.pl' }, ipHeader: true, storage: process.env.ALLOW_LOCAL_MEDIA !== '1' }).map((rule) =>
rule.name === 'R2_PUBLIC_URL' ? { ...rule, required: false } : rule,
),
)
@@ -348,6 +362,7 @@ import {
buildRevalidateHook,
buildSlugField,
buildSummaryField,
rowLabel,
trackSlugHistoryHook,
} from '@intecion/ipal-kit'
import { revalidatePath } from 'next/cache'
@@ -367,7 +382,7 @@ export const Pages: CollectionConfig = {
{ name: 'layout', type: 'blocks', blocks: pageBlocks, minRows: 1 },
buildSummaryField(), // aiSummary — GEO (llms.txt, MCP)
buildNoindexField(),
{ name: 'slugHistory', type: 'array', admin: { readOnly: true }, fields: [{ name: 'slug', type: 'text' }] },
{ name: 'slugHistory', type: 'array', admin: { components: rowLabel('slug', 'Old address'), readOnly: true }, fields: [{ name: 'slug', type: 'text' }], labels: { plural: 'Old addresses', singular: 'Old address' } },
],
hooks: {
afterChange: [revalidate.afterChange],
@@ -434,7 +449,7 @@ export const entryFields: Field[] = [
```ts
import type { GlobalConfig } from 'payload'
import { buildGlobalRevalidateHook } from '@intecion/ipal-kit'
import { buildGlobalRevalidateHook, rowLabel } from '@intecion/ipal-kit'
import { revalidatePath } from 'next/cache'
/** Company data for a PL market site: footer, contact block details, LocalBusiness JSON-LD. */
@@ -445,6 +460,7 @@ export const Company: GlobalConfig = {
{ name: 'name', type: 'text', required: true },
{ name: 'legalName', type: 'text' },
{ name: 'taxId', type: 'text', label: 'NIP' },
{ name: 'taxIdLabel', type: 'text', admin: { description: 'Shown before the tax ID in the footer.' }, defaultValue: 'NIP', label: 'Tax ID label', localized: true },
{
name: 'address',
type: 'group',
@@ -461,6 +477,8 @@ export const Company: GlobalConfig = {
{
name: 'socials',
type: 'array',
admin: { components: rowLabel('label', 'Profile'), initCollapsed: true },
labels: { plural: 'Profiles', singular: 'Profile' },
fields: [
{ name: 'label', type: 'text', required: true },
{ name: 'url', type: 'text', required: true },
+7
View File
@@ -36,6 +36,13 @@ classes (warnings), `styles.css` without `@intecion/ipal-kit/tokens.css` (warnin
next/font in `--font-body` with the preset (warning), and with `src/design/tokens.ts`: no `DESIGN.md` (warning) and
`ipal-tokens --check` — a stale `src/design/tokens.css` or a WCAG AA contrast failure is an error.
## ipal-audit and ipal-doctor
`ipal-audit` checks the **code** inside the edit loop (and tsc + build). `pnpm exec ipal-doctor` checks the **site**
against the team standard: it runs this script (`--quick`) from the installed package, reports its findings under its
own rule ids (`i18n-literals`, `blocks-tokens`, `audit:<title>`, one per file), and adds versions, Node, layout, database
names, env, admin, AGENTS.md, skills, seeds and — with `--url` / `--deep` — the running site and the database
(the `ipal-doctor` skill, docs/doctor.md). An approved exception for the doctor goes into `ipal-doctor.json` with a reason.
## What the script does not check (do it by hand)
- **Editor test** (AGENT.md §11): every text, image, button, section,
@@ -7,6 +7,8 @@
# Exit code: 0 = no errors (warnings allowed), 1 = at least one error.
set -u
# UTF-8 for grep: in the C locale a multibyte class like [ąę…] matches single bytes (an en dash hit "Polish").
export LC_ALL="${LC_ALL:-C.UTF-8}"
QUICK=0
for arg in "$@"; do
@@ -322,8 +324,10 @@ if [ -n "$CFG" ]; then
report WARNING "robots blocks AI bots" "§0b.8 — only with the client's decision in AGENTS.md" \
"$(skipped aibots || g "aiBots: *'(disallow|block-training)'" src --include=*.ts)"
fi
if [ -n "$CFG" ] && grep -qE 'forms *:' "$CFG" 2>/dev/null && ! ls scripts/seed-form* >/dev/null 2>&1 && ! skipped forms-seed; then
report WARNING "no form seed" "ipal-form §5 — every form from scripts/seed-form-*.ts (notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
# A form seed: scripts/seed-form-*.ts, or a seed file (src/seed, scripts) that seeds the forms collection.
FORM_SEED=$(ls scripts/seed-form* 2>/dev/null; grep -rlE "collection: *['\"]forms['\"]|upsertBy\( *['\"]forms['\"]|seed\.form\(|\.forms?\(" $(dirs src/seed scripts) 2>/dev/null)
if [ -n "$CFG" ] && grep -qE 'forms *:' "$CFG" 2>/dev/null && [ -z "$FORM_SEED" ] && ! skipped forms-seed; then
report WARNING "no form seed" "ipal-form §5 — every form from a seed (scripts/seed-form-*.ts or src/seed/forms.ts: notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
fi
need WARNING r2 "R2 env in .env.example" ".env.example lists R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_PUBLIC_URL" 'R2_BUCKET' .env.example
need WARNING '' "IPAL_IP_HEADER in .env.example" "header the rate limit trusts, e.g. cf-connecting-ip (forms.md)" 'IPAL_IP_HEADER' .env.example
@@ -18,6 +18,31 @@ const lineOf = (src, i) => src.slice(0, i).split('\n').length
const out = (level, rule, file, src, i, detail) => console.log(`${level}|${rule}|${file}:${lineOf(src, i)}: ${detail}`)
const strip = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' ')).replace(/(^|[^:])\/\/.*$/gm, (m, p) => p + ' '.repeat(m.length - p.length))
// The text of the object literal around index i, without the contents of its nested `fields: [...]`.
function ownObject(src, i) {
let start = i
for (let depth = 0; start > 0; start--) {
const ch = src[start - 1]
if (ch === '}') depth++
else if (ch === '{') { if (depth === 0) { start--; break } depth-- }
}
let end = i
for (let depth = 0; end < src.length; end++) {
const ch = src[end]
if (ch === '{') depth++
else if (ch === '}') { if (depth === 0) break; depth-- }
}
const obj = src.slice(start, end + 1)
const at = obj.search(/\bfields\s*:\s*\[/)
if (at < 0) return obj
let j = obj.indexOf('[', at)
for (let depth = 0; j < obj.length; j++) {
if (obj[j] === '[') depth++
else if (obj[j] === ']' && --depth === 0) break
}
return obj.slice(0, at) + obj.slice(j + 1)
}
for (const file of files) {
const src = strip(readFileSync(file, 'utf8'))
@@ -35,15 +60,13 @@ for (const file of files) {
else if (m[1] === 'description' && text.length > 120) out('WARNING', 'description over 120 chars — one short sentence: what it does / where it shows', file, src, m.index, `${text.length} chars`)
}
// arrays: labels (→ "Add Feature" button) + rowLabel (→ readable rows)
// arrays: labels (→ "Add Feature" button) + rowLabel (→ readable rows) — anywhere in the array's own
// object (before or after its `fields`), not inside the nested fields
for (const m of src.matchAll(/type:\s*['"]array['"]/g)) {
const before = src.slice(0, m.index)
const start = Math.max(before.lastIndexOf('name:'), before.lastIndexOf('{'))
const fieldsAt = src.indexOf('fields:', m.index)
const head = src.slice(start < 0 ? m.index : start, fieldsAt < 0 ? m.index + 400 : fieldsAt)
const name = head.match(/name:\s*['"](\w+)['"]/)?.[1] ?? '?'
if (!/\blabels\s*:/.test(head)) out('WARNING', 'array without labels {singular, plural} — panel shows "Add Row"', file, src, m.index, name)
if (!/rowLabel|RowLabel/.test(head)) out('WARNING', 'array without rowLabel() — rows read "Item 01" instead of their content', file, src, m.index, name)
const own = ownObject(src, m.index)
const name = own.match(/name:\s*['"](\w+)['"]/)?.[1] ?? '?'
if (!/\blabels\s*:/.test(own)) out('WARNING', 'array without labels {singular, plural} — panel shows "Add Row"', file, src, m.index, name)
if (!/rowLabel|RowLabel/.test(own)) out('WARNING', 'array without rowLabel() — rows read "Item 01" instead of their content', file, src, m.index, name)
}
// too many fields in one block config → tabs / condition / arrays / variant
+70
View File
@@ -0,0 +1,70 @@
---
name: ipal-doctor
description: Checks the whole site against the ipal-kit team standard with one command (`pnpm exec ipal-doctor`) — plugin, Next, sharp and Node versions, the AGENT.md §3 folder layout and naming, database names (<domain>_dev/_prod), env rules, security headers, X-Powered-By, CSP, 2FA, the cookie scanner, adminMeta/agency, AGENTS.md "Project decisions", current ipal-* skills, seeds (createSeeder, SEED_ONLY, no deletes), the block library, pnpm audit, hardcoded texts, and with --url / --deep the running site and the database. Use after setting up a site, after an ipal-kit upgrade, before a deploy, in CI of a new site, and when asked whether a site follows the team rules.
---
# ipal-doctor
Full reference: `node_modules/@intecion/ipal-kit/docs/doctor.md`.
## Steps
1. From the project root (after `pnpm install`, `pnpm payload generate:importmap`, `pnpm exec ipal-skills`):
```bash
pnpm exec ipal-doctor # static: files only, no build, no database
pnpm exec ipal-doctor --offline # without the registry (latest plugin, pnpm audit)
```
Running site and database (read-only):
```bash
pnpm build && pnpm start # or the deployed URL
pnpm exec ipal-doctor --deep --url http://localhost:3000
```
2. Show the user the **full output**. Every finding names its rule, the file, a fix and a doc.
3. Fix every `error`. A `warning` is drift — fix it or tell the user why not. `info` is a note.
4. A deliberate exception (the owner's decision) goes into `ipal-doctor.json` **with a reason** — the same reason as in
AGENTS.md "Project decisions". Never silence a rule just to make the run pass:
```json
{ "rules": { "i18n-literals": { "off": true, "files": ["src/components/design/**"], "reason": "approved exception: styleguide labels" } } }
```
Keys: `off`, `severity`, `reason` (required), `until` (ISO date), `files` (globs). Top level: `domain`, `launched`,
`layout.allow`, `seen` (written by the doctor), `extraRules`.
5. Run again until it reports what the project expects (a new site: `--strict` → `0 error(s), 0 warning(s), 0 info`).
## Options and exit codes
`[dir]` · `--json` (schema 1) · `--md` · `--strict` (= `--fail-on info`) · `--fail-on error|warning|info` · `--offline` ·
`--url <url>` · `--staging` (must be noindex) · `--admin-route <path>` · `--deep` · `--env-file <prod export>` (checks
`<domain>_prod`) · `--only` / `--skip <ids,groups>` · `--sites '../*-web'` (a read-only rule × site table, exit 0).
Exit `0` ok · `1` findings at or above `--fail-on` · `2` could not run · `3` a rule crashed.
## CI of a new site (starter, reference site)
```bash
pnpm exec ipal-doctor --strict --offline # after install
pnpm exec ipal-doctor --strict --offline --deep --url http://localhost:3000 # after build + start
```
Existing client sites are not gated on it; run it there as a report only.
## The status endpoint
`GET /api/ipal/doctor` is added by `ipalKit` and answers 404 until the site has `IPAL_DOCTOR_TOKEN` (≥ 32 characters).
Then `Authorization: Bearer <token>`; counts only (`usersWithout2fa`, `pendingCookies`, `plugin`, `node`). With the same
`IPAL_DOCTOR_TOKEN` in the doctor's environment, `--url` reads it. Off: `ipalKit({ doctor: false })`; adapt:
`ipalKit({ doctor: { tokenVar, access } })`.
## Env the doctor reads
`IPAL_DOCTOR_TOKEN` (endpoint), `CI` (set → never writes `seen`), `NO_COLOR` (plain output), `PAYLOAD_CONFIG_PATH`
(`--deep` loads that config), `IPAL_DOCTOR_IMPORT_MAP` (internal: passed to the probe).
## Building blocks
`@intecion/ipal-kit/doctor`: `runDoctor`, `doctorRules`, `formatReport`, … (docs/doctor.md → Building blocks) — wrap,
filter or add rules (`extraRules` in `ipal-doctor.json`, each module exports `rules: DoctorRule[]`).
## Relation to the other checks
`ipal-audit` stays the check inside the edit loop (plus tsc and build); the doctor runs `ipal-audit --quick` from the
installed package, `ipal-seo-check` with `--url`, and adds versions, env, database, admin, seeds, skills and the live
headers. `ipal-consent-check` (browser) is not part of it.
+3 -1
View File
@@ -70,6 +70,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
| `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins |
| `consentLog` | off | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min) | `true` / `{ retentionDays }` (default 1095) |
| `consentLog.collectionOverrides` | none | changes `consent-records`: an object merges `access` / `admin` / `hooks` key by key (your keys win), a function `(collection) => collection` takes over (keep the slug) | e.g. `{ access: { read: ({ req }) => req.user?.email === '[email protected]' } }` — narrows who reads records in a project without roles |
| `doctor` | on (404 until `IPAL_DOCTOR_TOKEN` is set) | `GET /api/ipal/doctor` — read-only counts for `ipal-doctor --url` (users without TOTP, cookies waiting for approval, versions); Bearer token ≥ 32 characters, rate-limited, never names or values | `false` = no endpoint; `{ tokenVar, access }` (doctor.md) |
| `cookieScanner` | off | `cookie-review` collection, "Scan cookies" box above its list (`CookieScanButton`), `GET`/`POST /api/ipal/cookie-scan`, and (unless `approval: false`) the *Approve cookies* view `/admin/cookie-approval` (`CookieApprovalView`) + `GET`/`POST /api/ipal/cookie-approval` + the dashboard reminder; a scan lists the cookies of the integrations switched on + names looked up in the bundled Open Cookie Database; one **Approve and add** puts the ticked cookies into Cookies → Cookie list (so `<CookieTable>` and the detailed window); never deletes, never overwrites edited text, never duplicates, nothing reaches the banner before approval | `true` / object; after switching on: `pnpm generate:importmap` + `migrate:create`. Check: *Privacy → Cookie review* → **Scan cookies** → "Waiting for approval: N" → **Review and approve** → **Approve and add** → the cookies are in Cookies → Cookie list (cookie-scanner.md) |
| `cookieScanner.adminLayout` | `'combined'` | one *Cookies* entry: *Review and approve* and (with `crawl`) *Site check* tabs on the `cookie-settings` global (`ui` fields, `CookieReviewTab` / `CookieSiteCheckTab`); `cookie-review` and `cookie-crawl` get `admin.group: false` (out of the nav, pages and API kept) | `'separate'`; no migration, `generate:importmap` |
| `fillEmptyLocales` | on | afterChange hooks: text saved in one language fills the empty languages of `cookie-settings` `cookies.purpose` / `cookies.duration` and `cookie-review` `purpose` / `retention`; never overwrites a language's own text | `false`; `{ 'cookie-settings': [...], 'cookie-review': [...] }` (`[]` = off); check: add a cookie in Polish, switch the locale to English → same purpose |
@@ -142,7 +143,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
## 3. What the project wires itself
Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ipal-seo-check**.
Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ipal-seo-check**, **ipal-doctor** (`pnpm exec ipal-doctor` — the whole site against the team standard; `ipal-doctor.json` silences a rule with a reason, docs/doctor.md).
`$U` = `NEXT_PUBLIC_SERVER_URL` (e.g. `http://localhost:3000`).
| element | file | minimal example | how to check | details |
@@ -236,6 +237,7 @@ and what throws without `i18n`: frontend.md. `SiteProviders` props: `shell`, `ba
| `INDEXNOW_KEY` | no | key from Site integrations → IndexNow (generated) | env or panel |
| `IPAL_IP_HEADER` | `ipHeader: true` + production | rate limit trusts any IP header (spoofing) + warning in prod | env: `cf-connecting-ip` (Cloudflare) / `x-forwarded-for` (Traefik/nginx) |
| `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN` | `cookieScanner.crawl` (`ipalEnvRules({ cookieCrawl: true })` requires both in production; token ≥ 16 chars) | **Check site** disabled, the box names the missing variable | env; the token also goes into the scanner service's `IPAL_CRAWLER_SITES` as `host=token` |
| `IPAL_DOCTOR_TOKEN` | no; ≥ 32 characters | `GET /api/ipal/doctor` answers 404; with it the endpoint answers a Bearer token, and `ipal-doctor --url` with the same variable reads the deep counts | env (Coolify) and the doctor's shell; also read by the doctor: `CI`, `NO_COLOR`, `PAYLOAD_CONFIG_PATH` (`--deep`), `IPAL_DOCTOR_IMPORT_MAP` (internal) — doctor.md |
| `IPAL_NOINDEX` | no; `1`/`true`/`yes` **staging/preview only** | — (when set: robots Disallow, meta noindex, `X-Robots-Tag`, IndexNow sends nothing) | staging env |
| `NEXT_PHASE` | set by Next | only tells `next build` from runtime: during the build an unreachable database gives an empty sitemap; at runtime the sitemap throws (route → 503) | do not set by hand |
| `NEXT_RUNTIME` | set by Next | `instrumentation.ts` checks for `nodejs`; missing (scripts, seed) → `buildRevalidateHook` does not revalidate | do not set by hand |
@@ -1,7 +1,7 @@
# ipal-kit — export index
Every public export of `@intecion/ipal-kit` (all entries: root, `/client`, `/rsc`,
`/server`, `/seed`, `/next/middleware`, `/admin`, `/env`, `/blocks`, `/blocks/rsc`, `/templates`, `/tokens`), grouped by module. Search with grep
`/server`, `/seed`, `/next/middleware`, `/admin`, `/env`, `/blocks`, `/blocks/rsc`, `/templates`, `/tokens`, `/doctor`), grouped by module. Search with grep
(`grep -n "name" .agents/skills/ipal-reference/resources/api.md`) before you write anything yourself.
"Import from" column — the first entry is preferred. Plugin options, env, routes and what the
project wires: `../SKILL.md`. Module details: `node_modules/@intecion/ipal-kit/docs/<page>.md`.
@@ -763,6 +763,30 @@ CSS: `@intecion/ipal-kit/tokens.css` (neutral `--ipal-*` defaults, light/dark, `
**Types:** `TokensInput`, `IpalTokenName` (root, `/tokens`), `ColorInput`, `ColorRole`, `ContrastRow`, `FluidRange`, `RemValue` (`/tokens`).
## ipal-doctor (`doctor`) — details: `node_modules/@intecion/ipal-kit/docs/doctor.md`
Bin: `ipal-doctor` (`pnpm exec ipal-doctor [dir] [--json] [--md] [--strict] [--fail-on] [--offline] [--url] [--staging]
[--admin-route] [--deep] [--env-file] [--only] [--skip] [--sites]`). `@intecion/ipal-kit/doctor` is Node only.
| Export | Import from | What it does / when |
|---|---|---|
| `runDoctor(options)` | `@intecion/ipal-kit/doctor` | Runs every rule on one project folder → `DoctorReport` (schema 1). Options: `root`, `packageRoot`, `offline`, `url`, `staging`, `adminRoute`, `deep`, `deepStatus`, `envFile`, `only`, `skip`, `rules`, `config`, `today`, `writeSeen`. Never throws for a failing rule. |
| `runDoctorCli(argv, { packageRoot, cwd?, log? })` | `@intecion/ipal-kit/doctor` | The command; returns the exit code (0 / 1 / 2 / 3). `parseDoctorArgs`, `expandSites` (`'../*-web'`), `DOCTOR_USAGE`. |
| `doctorRules` | `@intecion/ipal-kit/doctor` | Every built-in rule (`DoctorRule`: `id`, `group`, `source`, `docs`, `check(ctx)`) — filter, wrap or extend; own rules through `extraRules` in `ipal-doctor.json`. |
| `applySettings(findings, ctx)`, `globToRegExp(glob)`, `AUDIT_SKIP_RULES` | `@intecion/ipal-kit/doctor` | `ipal-doctor.json` `rules` (`off`, `severity`, `reason`, `until`, `files`) and `ipal-audit-skip` lines applied to findings. |
| `createDoctorContext(options)`, `loadDoctorConfig(root)`, `parseEnvFile(text)`, `readAuditSkips(agentsMd)`, `bareHost(url)` | `@intecion/ipal-kit/doctor` | What a rule reads about the project (files only, values never leave it). |
| `formatReport(report, { color })`, `formatDriftTable(reports)` | `@intecion/ipal-kit/doctor` | Human report; the rule × site Markdown table. |
| `planSkills({ dest, source })` | `@intecion/ipal-kit/doctor` | What `ipal-skills` would change: `missing`, `stale`, `retired` ipal-* folders. |
| `parseToolOutput(text)`, `AUDIT_RULE_MAP` | `@intecion/ipal-kit/doctor` | Reads `[ERROR] title (n) — rule` output of `audit.sh` / `seo-check.mjs`; audit titles that are a doctor rule. |
| `DEFAULT_SRC_ALLOW` | `@intecion/ipal-kit/doctor` | Top-level `src/` entries the convention allows (`layout.allow` extends it). |
| `createLiveFetcher(url, { adminRoute, staging })` | `@intecion/ipal-kit/doctor` | Cached GET-only fetcher for the live rules. |
| `runDeepProbe(ctx)` | `@intecion/ipal-kit/doctor` | `pnpm exec payload run …/dist/modules/doctor/probe.js` in the project → `DoctorStatus`. |
| `collectDoctorStatus(payload)` | `@intecion/ipal-kit/doctor` | Read-only counts: `usersWithout2fa`, `pendingCookies`, `plugin`, `node`. |
| `buildDoctorEndpoint({ tokenVar, access })` | `@intecion/ipal-kit/doctor` | `GET /ipal/doctor` (`/api/ipal/doctor`): 404 until the token variable (default `IPAL_DOCTOR_TOKEN`, ≥ 32 chars) is set, Bearer token or `access`, rate-limited. Added by `ipalKit` unless `doctor: false`. |
**Types:** `DoctorRule`, `DoctorFinding`, `RuleFinding`, `DoctorReport`, `DoctorConfig`, `DoctorRuleSetting`, `DoctorSeverity`,
`DoctorSource`, `DoctorStatus`, `DoctorContext`, `RunDoctorOptions`, `DoctorEndpointOptions`.
## Turnstile (`turnstile`) — details: `node_modules/@intecion/ipal-kit/docs/turnstile.md`
| Export | Import from | What it does / when |
@@ -136,7 +136,9 @@ for (const url of sample) {
if (!title) issues.title.push(url)
else {
if (title.length > 65) issues.longTitle.push(`${url} (${title.length} chars)`)
titles.set(title, [...(titles.get(title) ?? []), url])
// per language: the same word in two languages ("Blog" in pl and en) is not a duplicate
const key = `${multiLocale ? localeOf(url) : ''}\u0000${title}`
titles.set(key, [...(titles.get(key) ?? []), url])
}
const desc = tags(head, /<meta[^>]+name="description"[^>]*>/gi).map((t) => attr(t, 'content'))[0]?.trim()
if (!desc) issues.desc.push(url)
@@ -196,7 +198,7 @@ for (const url of sample) {
}
}
const dupTitles = [...titles.entries()].filter(([, us]) => us.length > 1).map(([t, us]) => `"${t}" × ${us.length}`)
const dupTitles = [...titles.entries()].filter(([, us]) => us.length > 1).map(([k, us]) => `"${k.split('\u0000')[1]}" × ${us.length}`)
const dupDescs = [...descriptions.entries()].filter(([, us]) => us.length > 1).map(([d, us]) => `"${d.slice(0, 60)}…" × ${us.length}`)
if (issues.status.length) report('ERROR', 'sitemap URLs not 200 (redirect / error)', 'sitemap must list final, live URLs', issues.status)
if (issues.noHead.length) report('ERROR', 'no </head> in HTML', 'broken document', issues.noHead)
+1
View File
@@ -537,6 +537,7 @@ bash .agents/skills/ipal-audit/scripts/audit.sh # full: §0b "missing
pnpm build && pnpm start
node .agents/skills/ipal-seo-check/scripts/seo-check.mjs http://localhost:3000 # 0 errors
node .agents/skills/ipal-consent-check/scripts/consent-check.mjs http://localhost:3000/pl
pnpm exec ipal-doctor --strict --offline --deep --url http://localhost:3000 # the team standard (skill ipal-doctor)
```
The §0b list with its checks: proxy + catch-all + 404 (stage 6) · meta, sitemap, robots, manifest (7) · JSON-LD (6, 10) ·
llms, llms-full, Markdown, MCP, AI bots, IndexNow (8) · Media/R2 (3–4) · seeded forms (9) · Turnstile (9) ·
+5 -1
View File
@@ -217,4 +217,8 @@ need a **data migration before** the old fields are removed — ask
the user whether the project already has content.
## 4. Finish
A full **ipal-audit** with no errors + a list of things to check in the admin panel.
A full **ipal-audit** with no errors, then `pnpm exec ipal-doctor` (after `pnpm exec ipal-skills` and
`pnpm payload generate:importmap`): no new errors against the report before the upgrade (skill **ipal-doctor**;
new rules come with new versions — read each finding, fix or record the owner's decision in `ipal-doctor.json` with a
reason). Before the upgrade, `pnpm dlx --package=@intecion/ipal-kit@latest ipal-doctor --offline` shows what the newest
rules will report. Then the list of things to check in the admin panel.
+4 -6
View File
@@ -1,9 +1,7 @@
# ipal-doctor — proposal
Status: **design approved 2026-10-29** (all of D1–D9, with the adjustments in §6). Build approved in this order:
design tokens and the block library, then the reference site, then the doctor and the starter. Not started — the
doctor waits for the coordinator's start signal.
Date: 2026-10-29 · plugin version at the time: 1.14.6.
Status: **built** (branch `claude/ipal-doctor-build`). The user guide is [docs/doctor.md](../doctor.md); this file
keeps the design and the decisions (§6). Where the two differ, doctor.md describes what shipped.
## 1. What it is
@@ -132,7 +130,7 @@ Live checks are GET only, no login, a doctor user agent, at most ~20 requests. `
### 3.1 Shipping — a bin in the plugin
`bin/ipal-doctor.mjs` next to `bin/ipal-skills.mjs`, zero dependencies, Node built-ins and `fetch`. The rules
sit in `bin/doctor/rules/*.mjs`, one module per group, each exporting
sit in `src/modules/doctor/rules/*.ts` (built to `dist/`, the bin imports them), one module per group, each exporting
`{ id, group, severity, source, docs, check(ctx) }`.
Why in the plugin and not a separate package: the rules change with the plugin (a new required import-map entry,
@@ -158,7 +156,7 @@ run anywhere and does not touch the network except `plugin-latest` and `deps-aud
Some rules need the real data: users without TOTP, cookies waiting for approval, the exact import map, the real
environment. Two ways, decision D3:
- **A. `ipal-doctor --deep`** runs `pnpm payload run node_modules/@intecion/ipal-kit/bin/doctor/deep.ts`: the Local
- **A. `ipal-doctor --deep`** runs `pnpm payload run node_modules/@intecion/ipal-kit/dist/modules/doctor/probe.js`: the Local
API, read-only queries (`count`), locally with the dev database (sites are built and checked locally), or in the Coolify app container's terminal
against the MongoDB container. No new route.
- **B. A status endpoint** `GET /api/ipal/doctor`, **off unless `IPAL_DOCTOR_TOKEN` is set** (≥ 32 chars, bearer,
+225
View File
@@ -0,0 +1,225 @@
# ipal-doctor — one check for the whole site
`ipal-doctor` checks a site against the team's rules and lists every gap with a fix hint and a doc link. It covers
what drifts between sites: versions, Node, the folder layout, database names, env rules, security headers, 2FA, the
cookie scanner, the admin preview, the agent guide, seeds, the block library, and the running site.
Related: [AGENT.md §11](./agent/AGENT.md), the `ipal-doctor` skill, [deployment.md](./deployment.md),
[seeding.md](./seeding.md), [security.md](./security.md), [blocks.md](./blocks.md).
## Run it
```bash
pnpm exec ipal-doctor # this project, human-readable
pnpm exec ipal-doctor --strict --offline # CI on a new site: any finding fails
pnpm exec ipal-doctor --deep --url http://localhost:3000 # + database (read-only) and the running site
pnpm exec ipal-doctor --json > doctor.json # machine-readable
pnpm dlx --package=@intecion/ipal-kit@latest ipal-doctor # the newest rules, before an upgrade
```
`ipal-doctor` is a bin of the package (`bin/ipal-doctor.mjs`), like `ipal-skills`. `pnpm exec` uses the rules of
the version the site has installed — reproducible in CI. The report header names both: the rules version and the
site's ipal-kit.
| Option | What it does |
|---|---|
| `[dir]` | the project folder (default: the current one) |
| `--json` | the report as JSON (schema 1, below) |
| `--md` | a Markdown table |
| `--strict` | any finding that is not silenced fails (= `--fail-on info`) |
| `--fail-on error\|warning\|info` | the lowest severity that fails (default `error`) |
| `--offline` | skips the two rules that need the registry: `plugin-latest` (`pnpm view`) and `deps-audit` (`pnpm audit --prod`) |
| `--url <url>` | also checks the running site: headers, X-Powered-By, CSP, `/api/health`, admin noindex and link preview, production noindex, and `ipal-seo-check` (robots, sitemap, canonical, hreflang, JSON-LD, llms, MCP) |
| `--staging` | with `--url`: the site is a staging copy, so it must be noindex |
| `--admin-route <path>` | with `--url`: the panel path (default `/admin`) |
| `--deep` | read-only database checks through `pnpm exec payload run` (below) |
| `--env-file <file>` | a production env export (e.g. copied from Coolify): its `DATABASE_URI` must name `<domain>_prod` |
| `--only <ids,groups>`, `--skip <ids,groups>` | run or leave out rules or whole groups |
| `--sites <glob>` | many projects at once, e.g. `'../*-web'`: a rule × site table (always exit 0 — a report, never a gate) |
**Exit codes:** `0` nothing at or above `--fail-on` · `1` findings at or above it · `2` the doctor could not run (not
a project root, a broken `ipal-doctor.json`, a bad option) · `3` a rule crashed (the others still report).
**Severities:** `error` breaks a team rule or is a security or data risk; `warning` is drift to fix; `info` is
worth knowing. Without `--strict`, only errors fail.
## Static, live, deep
- **Static** (default): reads files only — `package.json`, the installed versions in `node_modules`, the config
files, `.env` / `.env.example` (only variable names and the database name ever reach the report, never values),
the import map, `AGENTS.md`, the skills folder. It also runs `ipal-audit --quick` from the installed package. No
build, no database, no server. It writes nothing, except one date in `ipal-doctor.json` (below) outside CI.
- **Live** (`--url`): GET requests only, no login, a doctor user agent, each path once per run. `localhost` is exempt
from the HSTS check (plain http).
- **Deep** (`--deep`): `pnpm exec payload run node_modules/@intecion/ipal-kit/dist/modules/doctor/probe.js` in the
project, with the project's `DATABASE_URI` and `PAYLOAD_SECRET`. Read-only counts: panel users without TOTP, cookies
waiting for approval; the project's own env rules (`register()` from `instrumentation.ts`); the committed import map
against a freshly generated one (written to a temporary file next to it and removed). Run it locally against the dev
database, or in the Coolify app container's terminal against the MongoDB container.
- **Deep through the site**: with `--url` (and no `--deep`), when `IPAL_DOCTOR_TOKEN` is set in the doctor's
environment, the doctor reads the same counts from `GET /api/ipal/doctor` of the running site.
### The status endpoint — `GET /api/ipal/doctor`
Added by `ipalKit` and **off until the site has `IPAL_DOCTOR_TOKEN`** (at least 32 characters): before that it answers
404. With the token set it needs `Authorization: Bearer <token>`, is rate-limited (10 a minute per client IP) and
returns counts only — never names, e-mails or values:
```json
{ "node": "v22.20.0", "pendingCookies": 0, "plugin": "1.15.0", "usersWithout2fa": 0 }
```
Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'MY_TOKEN', access: ({ req }) => … } })`
(`access` lets a logged-in admin read it without the token). Building blocks: `buildDoctorEndpoint`,
`collectDoctorStatus` from `@intecion/ipal-kit/doctor`.
## The rules
| Group | Rule | Severity | Checks |
|---|---|---|---|
| versions | `plugin-installed` | error | `node_modules` has `@intecion/ipal-kit` and it satisfies `package.json` |
| | `plugin-latest` | warning; error two or more minors behind | the installed plugin is the newest on the team registry (registry) |
| | `next-min` | error | `next` ≥ 16.4.1; `eslint-config-next` on the same minor (warning) |
| | `sharp-min` | error | `sharp` ≥ 0.35.5 |
| | `node-22` | warning | `engines.node` only 22 (`">=22 <23"`), `.nvmrc` / `.node-version` = 22; with `--deep`, the running Node |
| | `pnpm-pinned` | info | `packageManager` is set |
| | `deps-audit` | error on critical/high, info on moderate/low | `pnpm audit --prod` (registry) |
| layout | `layout-required` | error | the AGENT.md §3 files (proxy, i18n config, instrumentation, `lib/content`, every route, the `(frontend)` files, `blocks/registry.ts`, `collections/{Pages,Media}.ts`, `components/layout`, `components/forms/formClasses.ts`); an `ipal-audit-skip` key (`llms`, `llms-full`, `markdown`, `mcp`, `indexnow`) drops its file |
| | `layout-forbidden` | error | no `middleware.ts`, no `lib/{pages,locales,navigation}.ts`, `fields/{link,sectionHeader,sectionSettings}.ts` |
| | `layout-extra` | info | `src/` entries outside the allow list (AGENT.md §3 + `seed/`, `design/`, `db.ts`, `env.rules.ts`, `content.config.ts`; extend with `layout.allow`) |
| | `naming` | warning | block folders, collection and global files PascalCase, `scripts/*` kebab-case, no `index.ts` barrels |
| | `importmap` | error | the import map exists, holds the entries for what the config turns on (2FA, R2, cookie scanner, `adminMeta`), names no export the plugin no longer has; with `--deep`, equals a fresh one |
| | `tsconfig-skills` | error | `tsconfig.json` excludes the skills folder |
| env | `db-name` | error | `DATABASE_URI` in `.env` and `.env.example` names `<domain without dots>_dev`; a local `.env` on `_prod` is an error; `--env-file` checks `_prod` (`databaseNamesFor`) |
| | `env-rules` | error / warning | `instrumentation.ts` calls `assertEnv(ipalEnvRules(…))` from `/env`, with `storage` (R2), `cookieCrawl` (crawl), `ipHeader`; `databaseName` suggested (info) |
| | `env-example` | warning / error | `.env.example` lists the variables those rules name; no credentials or secret values in it |
| | `env-live` | error | (deep) the project's env rules pass in the real environment |
| security | `security-headers` | error | `buildSecurityHeaders`; live: HSTS, nosniff, Referrer-Policy, Permissions-Policy, frame protection |
| | `powered-by` | error | `withSecurityConfig`; live: no `X-Powered-By` on `/` and the admin |
| | `csp` | warning / info | CSP on the site and the admin; report-only is info, a warning after 4 weeks (`seen`) |
| | `2fa` | error | `twoFactor: { plugin: payloadTotp }` + the package; deep: 0 users without TOTP |
| | `cookie-scanner` | error / warning / info | `cookieScanner` on (with `crawl`, else info); deep: nothing waits for approval (warning) |
| admin | `admin-meta` | warning | ipal-kit ≥ 1.14.5, no `adminMeta: false` / `agency: false`; live: the admin `og:image` is `/api/ipal/admin-og` |
| | `admin-noindex` | error | (live) the admin login page is noindex |
| agents | `agents-md` | error / warning | `AGENTS.md` with a non-empty `## Project decisions`, the `ipal-kit:start…end` pointer for the installed version, `CLAUDE.md` with `@AGENTS.md` |
| | `skills-current` | warning | `.agents/skills/ipal-*` equal the installed plugin's (`planSkills`, what `ipal-skills` would change) |
| seeds | `seed-named` | error / warning | every `seed*` script uses `createSeeder` (`only` / `SEED_ONLY`, the full-seed guard), deletes nothing, has no `fresh`/`reset` script, does not switch the guard off (`guard: false`, `allowFull: true`, `IPAL_SEED_ALLOW_FULL=1` in a script or committed env file); after launch a seed without an `only` list is a warning |
| blocks | `blocks-registry` | error | `blocks/registry.ts` uses `createBlockRegistry` or `RenderBlocks` (no `switch (blockType)`) |
| | `blocks-ui-required` | error | without `createBlockRegistry`, `components/ui/` has Section, SectionHeader, Media, CMSLink, Button |
| | `blocks-ui-override` | warning | a `components/ui/` file named like a library primitive is passed through `createBlockRegistry({ ui })` |
| | `blocks-duplicate` | warning | a project block whose `slug` (or `interfaceName`) matches a library block — also a slug renamed through the block's `slug` option — unless it is an override in `createBlockRegistry({ components })` |
| | `blocks-helper-copy` | warning | no local copy of a plugin field builder (`blockLibraryManifest.fieldBuilders`), `ctaHref`, `buildActionButtonsField` |
| | `blocks-tokens` | error / warning | from `ipal-audit`: hex colours, the token standard not wired, `ipal-tokens --check` |
| audit | `i18n-literals` | error / warning | from `ipal-audit`: hardcoded text in blocks (error) and components (warning), Polish literals in code |
| | `audit:<title>` | as reported | every other `ipal-audit --quick` finding, one per file |
| live | `live-reachable`, `live-health`, `live-noindex`, `live-seo` | error / warning | the URL answers; `/api/health` 200; production not noindex (staging must be); every `ipal-seo-check` error and warning |
| deep | `deep-status` | error | the deep check could not finish |
| — | `doctor-config` | error / warning | `ipal-doctor.json` problems: invalid JSON, an entry without a reason, an expired `until` |
| — | `doctor-crash` | error (exit 3) | a rule threw |
The block rules read `blockLibraryManifest` (`@intecion/ipal-kit/blocks`), so a new library block needs no doctor
change.
## Adapt it — `ipal-doctor.json`
Every rule can be silenced, lowered or raised — **with a reason** — in `ipal-doctor.json` in the project root:
```json
{
"domain": "example-studio.pl",
"launched": false,
"layout": { "allow": ["scripts"] },
"rules": {
"csp": { "off": true, "reason": "new site: report-only until the reports are clean", "until": "2026-12-01" },
"i18n-literals": { "off": true, "files": ["src/components/design/**"], "reason": "approved exception: the styleguide labels" },
"node-22": { "severity": "error", "reason": "we pin Node strictly" }
},
"seen": { "csp-report-only": "2026-10-29" },
"extraRules": ["./scripts/doctor-rules.mjs"]
}
```
| Key | Meaning |
|---|---|
| `domain` | the production domain (dots allowed) — the base of the database names. Without it: a non-local `NEXT_PUBLIC_SERVER_URL`, else the folder name minus `-web` |
| `launched` | the site is live: seeds must then name their records. Also true when "Project decisions" has a line with "launch" and a date |
| `layout.allow` | more top-level `src/` entries the convention allows |
| `rules.<id>` | `off` (silence), `severity` (`error` / `warning` / `info`), `reason` (**required** — an entry without one is ignored and reported), `until` (ISO date; after it the entry stops applying and the report says so), `files` (globs: only findings in those files). The id is the rule (`csp`) or an audit finding (`audit:collections-present`); `audit` covers all audit findings |
| `seen` | first-seen dates the doctor stores itself (`csp-report-only`, for the 4-week CSP rule). It writes this key only outside CI (`CI` unset), not with `--json`, and only when the file exists |
| `extraRules` | your own rule modules (paths relative to the project), each exporting `rules: DoctorRule[]` |
Silenced findings stay in the report: in JSON with `"silenced": true` and the reason, in the human output under
"Silenced", in the summary count. `--strict` does not fail on them.
`ipal-audit-skip: <keys> — <reason>` lines in `AGENTS.md` (a client decision, AGENT.md §0b) count too: the audit honours
its keys, and the doctor maps `twofactor` → `2fa`, `csp` → `csp`, and drops the files of `llms`, `llms-full`, `markdown`,
`mcp`, `indexnow` from `layout-required`.
## JSON (schema 1)
```json
{
"schema": 1,
"rulesVersion": "1.15.0",
"site": { "path": "/…/examplepl-web", "domain": "example.pl", "plugin": "1.15.0" },
"findings": [
{ "rule": "db-name", "severity": "error", "source": "static", "message": "…", "file": ".env", "fix": "…", "docs": "docs/deployment.md" }
],
"skipped": ["plugin-latest", "deps-audit", "live-health"],
"summary": { "error": 1, "warning": 0, "info": 0, "silenced": 0 }
}
```
`source` is `static`, `registry`, `live` or `deep`; `skipped` lists rules that did not run (offline, no `--url`, no
`--deep`); `reason` and `silenced` appear on silenced findings. With `--sites --json` the output is an array of reports.
## In CI
New sites only (the starter's and the reference site) gate on the doctor; existing client sites are not changed for it.
```yaml
- run: pnpm install --frozen-lockfile
- run: pnpm exec ipal-doctor --strict --offline # static, right after install
# … build, start the app on :3000 with the CI database …
- run: pnpm exec ipal-doctor --strict --offline --deep --url http://localhost:3000
```
The plugin's own CI does the same for `reference/` (`.gitea/workflows/ci.yml`).
## Building blocks — `@intecion/ipal-kit/doctor`
Node only. For a project that wraps, filters or extends the checks:
```ts
import { doctorRules, formatReport, runDoctor } from '@intecion/ipal-kit/doctor'
const report = await runDoctor({ root: process.cwd(), packageRoot: 'node_modules/@intecion/ipal-kit', offline: true })
console.log(formatReport(report))
```
`runDoctor`, `runDoctorCli`, `doctorRules`, `applySettings`, `runDeepProbe`, `createDoctorContext`, `loadDoctorConfig`,
`formatReport`, `formatDriftTable`, `planSkills`, `parseToolOutput`, `AUDIT_RULE_MAP`, `AUDIT_SKIP_RULES`,
`DEFAULT_SRC_ALLOW`, `createLiveFetcher`, `buildDoctorEndpoint`, `collectDoctorStatus`, `globToRegExp`, `parseEnvFile`,
`readAuditSkips`, `bareHost`, `expandSites`, `parseDoctorArgs`, `DOCTOR_USAGE`; types `DoctorRule`, `DoctorFinding`,
`DoctorReport`, `DoctorConfig`, `DoctorRuleSetting`, `DoctorSeverity`, `DoctorSource`, `DoctorStatus`, `DoctorContext`,
`RuleFinding`, `RunDoctorOptions`, `DoctorEndpointOptions`.
## Environment variables
| Variable | Where | Effect |
|---|---|---|
| `IPAL_DOCTOR_TOKEN` | the site (Coolify), ≥ 32 characters | turns `GET /api/ipal/doctor` on; in the doctor's environment, `--url` uses it to read the deep counts |
| `CI` | the doctor's environment | set → the doctor never writes `seen` into `ipal-doctor.json` |
| `NO_COLOR` | the doctor's environment | no colours in the human report |
| `PAYLOAD_CONFIG_PATH` | the project | `--deep` loads this config instead of `src/payload.config.ts` |
| `IPAL_DOCTOR_IMPORT_MAP` | internal | set by the doctor for the probe: the committed import map to compare |
## Relation to the other checks
| Tool | When |
|---|---|
| `ipal-audit` | inside the edit loop: is the code I just wrote built the ipal-kit way (+ tsc and build without `--quick`) |
| `ipal-seo-check` | what crawlers see on a running site |
| `ipal-consent-check` | tracking waits for consent (a real browser) — not run by the doctor |
| `ipal-skills` | copies the skills; the doctor's `skills-current` uses the same comparison (`planSkills`) |
| **`ipal-doctor`** | the whole site against the team standard: runs `ipal-audit --quick` and (with `--url`) `ipal-seo-check` from the installed package and adds everything they do not check |
+2 -1
View File
@@ -91,7 +91,8 @@ from the panel first (Site integrations) and env is only a fallback — turn it
in env.
The plugin also reads (outside the preset — add your own rules if you want to validate them):
`INDEXNOW_KEY` (seo.md), `IPAL_NOINDEX` (`1`/`true`/`yes` — staging, seo.md). Full table:
`INDEXNOW_KEY` (seo.md), `IPAL_NOINDEX` (`1`/`true`/`yes` — staging, seo.md), `IPAL_DOCTOR_TOKEN` (≥ 32 characters —
turns `GET /api/ipal/doctor` on, doctor.md). Full table:
[deployment.md](./deployment.md).
Extending with your own variables — spread: