IAPL rename, review fixes I-1 to I-11

I-1  ipalEnvRules() keeps the IPAL_ rule names (IAPL_ as aliases); iaplEnvRules() the other way round; the IAPL_ value
     is the one checked when both are set
I-2  COOKIE_SCAN_URL_ENV / COOKIE_SCAN_TOKEN_ENV (and the internal SITE_NOINDEX_ENV) keep their old values;
     IAPL_COOKIE_SCAN_URL_ENV / IAPL_COOKIE_SCAN_TOKEN_ENV added
I-3  bin/ipal-*.mjs: five files that run the new ones (1.16's audit skill and CI call them by path); legacy:site checks it
I-4  storage-names sees <SiteProviders … stats> when a JSX prop comes first (the reference layout's shape)
I-5  AGENT.md: a text naming an ipal-<name> skill means iapl-<name> (the vendored ext-* skills)
I-6  leftover text in the skills-current message
I-7  iapl-skills removes the old pointer block when both are in AGENTS.md
I-8, I-11  changelog: the doctor's summary line, IAPL_DOCTOR_STATUS, --strict in CI until the skills are refreshed
I-9  env.md: an empty IAPL_ variable does not switch the IPAL_ one off
I-10 verifyLimit.keyPrefix undefined or empty is 'not given'

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 18:45:36 +01:00
co-authored by Claude Fable 5.2
parent 03452376f9
commit 38b903fcfa
25 changed files with 202 additions and 33 deletions
+4
View File
@@ -160,6 +160,10 @@ if (pointer) {
next = create === 'import' ? '@AGENTS.md\n' : `# ${file.replace('.md', '')}\n\n${block}\n`
} else if (text.includes(START) && text.includes(END)) {
next = text.slice(0, text.indexOf(START)) + block + text.slice(text.indexOf(END) + END.length)
// both blocks (an upgrade, a rollback whose installer added the old block again, an upgrade): the old one goes
if (next.includes(OLD_START) && next.includes(OLD_END)) {
next = (next.slice(0, next.indexOf(OLD_START)).replace(/\s*$/, '') + '\n\n' + next.slice(next.indexOf(OLD_END) + OLD_END.length).replace(/^\s*/, '')).replace(/\s*$/, '\n')
}
} else if (text.includes(OLD_START) && text.includes(OLD_END)) {
// the block written before 1.17.0: replaced where it stands, markers included
next = text.slice(0, text.indexOf(OLD_START)) + block + text.slice(text.indexOf(OLD_END) + OLD_END.length)
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-blocks.mjs'
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-doctor.mjs'
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl.mjs'
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-skills.mjs'
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-tokens.mjs'
+12 -4
View File
@@ -20,7 +20,12 @@ once there are more than 20.
- **Nothing.** Recommended after the update: `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit —
the skills are named `iapl-*` now; the 16 old `ipal-*` folders are removed by name, a project's own `ipal-…` skill
stays, and the pointer block in `AGENTS.md` is rewritten in place.
- **A log filter or alert on `[ipal]`:** the log prefix is `[iapl]`.
- **A log filter or alert on `[ipal]`, or a script that reads the doctor's output:** the log prefix is `[iapl]`; the
doctor's summary line starts `iapl-doctor:` (was `ipal-doctor:`), and its internal status line is
`IAPL_DOCTOR_STATUS`. The rate-limit scope of `GET /api/ipal/doctor` was renamed with it (one fresh minute).
- **CI that runs the doctor with `--strict`:** until the skills are refreshed it exits 1 with two warnings
(`agents-md`, `skills-current`: the skills and the pointer block are older than the plugin) — as after every
upgrade. Run `pnpm exec iapl-skills` and commit in the same change as the version bump.
### Changed
- **New names beside the old ones** (the old ones are deprecated and go in 2.0):
@@ -32,9 +37,12 @@ once there are more than 20.
- **Not renamed:** the package and its import paths, import-map paths, routes `/api/ipal/*`, CSS tokens `--ipal-*`,
`data-ipal` hooks, `config.custom.ipal`, `req.context` flags, the `ipal` translation namespace, the header
`X-Ipal-Cookie-Crawler`. They change, with a migration path, in 2.0.
- The exported name constants `SITE_NOINDEX_ENV`, `COOKIE_SCAN_URL_ENV` and `COOKIE_SCAN_TOKEN_ENV` hold the `IAPL_`
spelling. The plugin reads both spellings itself; code of your own that does `process.env[SITE_NOINDEX_ENV]` should
call `readEnv(SITE_NOINDEX_ENV)` (new, from `/env` or the root) or `isSiteNoindex()`.
- `ipalEnvRules()` still returns its rules under the `IPAL_` names (the `IAPL_` ones as aliases), and the constants
`COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` keep their values, so code that adapts the rules by name or reads
`process.env[COOKIE_SCAN_URL_ENV]` works as before. New: `iaplEnvRules()` (names `IAPL_…`, old ones as aliases),
`IAPL_COOKIE_SCAN_URL_ENV`, `IAPL_COOKIE_SCAN_TOKEN_ENV`, and `readEnv` / `legacyEnvName` (from `/env` or the root)
for code of your own.
- The files `bin/ipal-*.mjs` are still in the package and run the new commands (older skills and CI call them by path).
- Docs, the agent guide and the skills use the new names; `AGENT.md` has one table of old and new names
("Names: IAPL and ipal-kit").
- Audit findings whose titles named a command (`iapl-tokens --check`, "forms in iapl", `IAPL_IP_HEADER in .env.example`)
+3 -2
View File
@@ -31,14 +31,15 @@ use the name in the middle column. `pnpm exec iapl-doctor` lists what is still o
| Before 1.17.0 | Now | In 1.x |
|---|---|---|
| `ipalKit()`, `IpalOptions` | `iapl()`, `IaplOptions` | both work, same function and type |
| `ipalEnvRules`, `IpalEnvFeatures` | `iaplEnvRules`, `IaplEnvFeatures` | both work |
| `ipalEnvRules`, `IpalEnvFeatures` | `iaplEnvRules`, `IaplEnvFeatures` | both work. Not the same list: `ipalEnvRules()` names the plugin's variables `IPAL_…` (alias `IAPL_…`), `iaplEnvRules()` names them `IAPL_…` (alias `IPAL_…`) — code that filters or maps the rules by `rule.name` keeps working. Constants `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` keep the `IPAL_` values; the new ones are `IAPL_COOKIE_SCAN_URL_ENV` / `IAPL_COOKIE_SCAN_TOKEN_ENV` |
| `ipalT`, `ipalVar`, `IPAL_TOKENS`, `IPAL_BREAKPOINTS`, `IpalTokenName`, `IpalGlobalSlug` | `iaplT`, `iaplVar`, `IAPL_TOKENS`, `IAPL_BREAKPOINTS`, `IaplTokenName`, `IaplGlobalSlug` | both work |
| commands `ipal-kit`, `ipal-doctor`, `ipal-skills`, `ipal-tokens`, `ipal-blocks` | `iapl`, `iapl-doctor`, `iapl-skills`, `iapl-tokens`, `iapl-blocks` | both installed, same programs |
| env `IPAL_IP_HEADER`, `IPAL_NOINDEX`, `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN`, `IPAL_SEED_ALLOW_FULL`, `IPAL_SEED_ALLOW_PROD_UPDATE`, `IPAL_DOCTOR_TOKEN`, `IPAL_DOCTOR_IMPORT_MAP` (crawler service: `IPAL_CRAWLER_SITES`) | the same with `IAPL_` | `IAPL_…` is read first, `IPAL_…` when it is missing or empty; set one, not both |
| `ipal-doctor.json` | `iapl-doctor.json` | whichever exists is read and written; never keep both |
| `ipal-audit-skip:` lines in `AGENTS.md` | `iapl-audit-skip:` | both read |
| pointer block `<!-- ipal-kit:start -->` … `<!-- ipal-kit:end -->` | `<!-- iapl:start -->` … `<!-- iapl:end -->` | both recognised; `iapl-skills` rewrites the old one in place |
| skills `ipal-<name>` (16) | `iapl-<name>` | `iapl-skills` installs the new folders and removes the 16 old ones by name; a project's own `ipal-…` skill is left alone |
| skills `ipal-<name>` (16) | `iapl-<name>` | `iapl-skills` installs the new folders and removes the 16 old ones by name; a project's own `ipal-…` skill is left alone. A text that still names an `ipal-<name>` skill — the vendored `ext-*` skills say "the `ipal-reference` skill" — means `iapl-<name>` (`iapl-reference`) |
| files `node_modules/@intecion/ipal-kit/bin/ipal-*.mjs` | `bin/iapl*.mjs` | the old files are still there and run the new ones (older skills and CI call them by path) |
| log prefix `[ipal]` | `[iapl]` | changed (a log filter on `[ipal]` needs the new prefix) |
**Not renamed — write them exactly like this, in every project:**
@@ -245,7 +245,8 @@ Opt-in with `iapl({ cookieScanner: true })`; the plugin wires the collection, en
| `sendCrawlWarning({ payload, labels, siteUrl, summary, to })` | `@intecion/ipal-kit` | The warning e-mail through `payload.sendEmail` (the project's mail adapter); never throws. |
| `bearerMatches(header, token)` | `@intecion/ipal-kit` | Constant-time `Authorization: Bearer` check. |
| `COOKIE_CRAWL_SLUG` / `COOKIE_CRAWL_PATH` / `COOKIE_CRAWL_RESULTS_PATH` | `@intecion/ipal-kit` | `'cookie-crawl'` / `'/ipal/cookie-crawl'` / `'/ipal/cookie-crawl/results'`. |
| `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IAPL_COOKIE_SCAN_URL'` / `'IAPL_COOKIE_SCAN_TOKEN'`. |
| `IAPL_COOKIE_SCAN_URL_ENV` / `IAPL_COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IAPL_COOKIE_SCAN_URL'` / `'IAPL_COOKIE_SCAN_TOKEN'` — the variables' names since 1.17.0; read with `readEnv` (falls back to the old spelling). |
| `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IPAL_COOKIE_SCAN_URL'` / `'IPAL_COOKIE_SCAN_TOKEN'` — the names before 1.17.0 (values unchanged; still read by the plugin). |
**Types:** `CookieScannerOptions` (the option), `CookieDeclaration`, `CookieIntegration`, `CookieScanContext`, `CookieFinding`, `CookieFindingSource`, `CookieStorage`, `LocalizedText`, `CookieScanSummary`, `CookieReviewValues`, `CookieDatabaseIndex`, `CookieScanLabels`, `OpenCookieCategory`, `CookieObservation` (a name with `storage` / `domain` for `collectCookieFindings`), `CookieReviewEntryRef` (`applyCookieFindings` `entries`); crawl: `CookieCrawlOptions`, `ResolvedCrawlConfig`, `CrawlResult`, `CrawlObservation`, `CrawlRequest`, `CrawlViolation`, `CrawlIngestSummary`.
+2 -2
View File
@@ -398,8 +398,8 @@ token; the results endpoint — the bearer token only, and only for the running
| `POST /api/ipal/cookie-crawl` | starts a crawl → `202`; `403`, `409` (one is running), `503` (not configured), `502` (service unreachable — the global says why) |
| `POST /api/ipal/cookie-crawl/results` | the service's callback: `Authorization: Bearer <token>`, body = the wire format (`CrawlResult`) → `200`; `401`, `400`, `409` (not the running job) |
Paths: `COOKIE_CRAWL_PATH`, `COOKIE_CRAWL_RESULTS_PATH`; env names: `COOKIE_SCAN_URL_ENV`,
`COOKIE_SCAN_TOKEN_ENV`; global slug `COOKIE_CRAWL_SLUG`.
Paths: `COOKIE_CRAWL_PATH`, `COOKIE_CRAWL_RESULTS_PATH`; env names: `IAPL_COOKIE_SCAN_URL_ENV`,
`IAPL_COOKIE_SCAN_TOKEN_ENV` (`COOKIE_SCAN_URL_ENV`, `COOKIE_SCAN_TOKEN_ENV` hold the `IPAL_` names from before 1.17.0); global slug `COOKIE_CRAWL_SLUG`.
### Scanner service on Coolify
+11 -3
View File
@@ -99,9 +99,17 @@ name the same way. `ipalEnvRules` is the old name of `iaplEnvRules` and still ex
Reading one of the plugin's variables in your own code: `readEnv('IAPL_NOINDEX')` (from `@intecion/ipal-kit/env` or the
root) returns the `IAPL_` value, else the `IPAL_` one; `legacyEnvName('IAPL_NOINDEX')` is `'IPAL_NOINDEX'`. The exported
name constants (`SITE_NOINDEX_ENV`, `COOKIE_SCAN_URL_ENV`, `COOKIE_SCAN_TOKEN_ENV`) hold the `IAPL_` spelling since
1.17.0, so `process.env[SITE_NOINDEX_ENV]` alone no longer sees a variable set under the old name — use `readEnv`
(or `isSiteNoindex()`).
name constants `COOKIE_SCAN_URL_ENV` and `COOKIE_SCAN_TOKEN_ENV` keep their values (`'IPAL_COOKIE_SCAN_URL'`,
`'IPAL_COOKIE_SCAN_TOKEN'`): they are the old names. The new ones are `IAPL_COOKIE_SCAN_URL_ENV` and
`IAPL_COOKIE_SCAN_TOKEN_ENV`; read them with `readEnv`, which falls back.
An **empty** new variable does not switch the old one off: `IAPL_NOINDEX=` beside `IPAL_NOINDEX=1` is still noindex
(empty counts as not set, and the old name is read). When a staging copy becomes production, remove the variable
under **both** spellings.
`ipalEnvRules()` and `iaplEnvRules()` are not the same list: the old one names the plugin's variables `IPAL_<NAME>`
(alias `IAPL_<NAME>`), the new one the other way round, so project code that adapts the rules by `rule.name` keeps
finding the names it was written for. Both accept both spellings in the environment.
The plugin also reads (outside the preset — add your own rules if you want to validate them):
`INDEXNOW_KEY` (seo.md), `IAPL_NOINDEX` (`1`/`true`/`yes` — staging, seo.md), `IAPL_DOCTOR_TOKEN` (≥ 32 characters —
@@ -245,7 +245,8 @@ Opt-in with `iapl({ cookieScanner: true })`; the plugin wires the collection, en
| `sendCrawlWarning({ payload, labels, siteUrl, summary, to })` | `@intecion/ipal-kit` | The warning e-mail through `payload.sendEmail` (the project's mail adapter); never throws. |
| `bearerMatches(header, token)` | `@intecion/ipal-kit` | Constant-time `Authorization: Bearer` check. |
| `COOKIE_CRAWL_SLUG` / `COOKIE_CRAWL_PATH` / `COOKIE_CRAWL_RESULTS_PATH` | `@intecion/ipal-kit` | `'cookie-crawl'` / `'/ipal/cookie-crawl'` / `'/ipal/cookie-crawl/results'`. |
| `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IAPL_COOKIE_SCAN_URL'` / `'IAPL_COOKIE_SCAN_TOKEN'`. |
| `IAPL_COOKIE_SCAN_URL_ENV` / `IAPL_COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IAPL_COOKIE_SCAN_URL'` / `'IAPL_COOKIE_SCAN_TOKEN'` — the variables' names since 1.17.0; read with `readEnv` (falls back to the old spelling). |
| `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` | `@intecion/ipal-kit` | `'IPAL_COOKIE_SCAN_URL'` / `'IPAL_COOKIE_SCAN_TOKEN'` — the names before 1.17.0 (values unchanged; still read by the plugin). |
**Types:** `CookieScannerOptions` (the option), `CookieDeclaration`, `CookieIntegration`, `CookieScanContext`, `CookieFinding`, `CookieFindingSource`, `CookieStorage`, `LocalizedText`, `CookieScanSummary`, `CookieReviewValues`, `CookieDatabaseIndex`, `CookieScanLabels`, `OpenCookieCategory`, `CookieObservation` (a name with `storage` / `domain` for `collectCookieFindings`), `CookieReviewEntryRef` (`applyCookieFindings` `entries`); crawl: `CookieCrawlOptions`, `ResolvedCrawlConfig`, `CrawlResult`, `CrawlObservation`, `CrawlRequest`, `CrawlViolation`, `CrawlIngestSummary`.
+12 -1
View File
@@ -5,7 +5,8 @@
* The reference site as it was at a tag (default v1.16.7: `ipalKit()`, `ipal-tokens`, `ipal-doctor.json`, `ipal-*`
* skills, the old pointer block) is unpacked next to the plugin and installed against the plugin built from this
* tree. Nothing in it is changed. Then:
* 1. the old commands run: `ipal-tokens --check`, `ipal-doctor` (no error; the warnings are printed);
* 1. the old commands run, by name and by file path (`bin/ipal-*.mjs`): `ipal-tokens --check`, `ipal-doctor`
* (no error; the warnings are printed); the site's own 1.16 audit skill still finds the tokens command;
* 2. `payload generate:importmap` leaves the committed import map byte for byte as it was;
* 3. `tsc --noEmit`: the old names still type-check;
* 4. a production build with webpack and one with Turbopack.
@@ -80,6 +81,16 @@ results.push(`site of ${tag}, plugin ${installed} from this tree`)
sh('old command: ipal-tokens --check', 'pnpm', ['exec', 'ipal-tokens', '--check'])
results.push('ipal-tokens --check: ok')
// 1.16's own audit skill and CI scripts call the commands by file path
sh('old file path: bin/ipal-tokens.mjs --check', 'node', ['node_modules/@intecion/ipal-kit/bin/ipal-tokens.mjs', '--check'])
sh('old file path: bin/ipal-doctor.mjs --help', 'node', ['node_modules/@intecion/ipal-kit/bin/ipal-doctor.mjs', '--help'], { capture: true })
const audit = sh("the old site's own audit skill (.agents/skills/ipal-audit, --quick)", 'bash', ['.agents/skills/ipal-audit/scripts/audit.sh', '--quick'], { allowFail: true, capture: true })
if (/ipal-tokens not installed/.test(audit.stdout)) {
console.error('[legacy:site] ✗ the 1.16 audit skill no longer finds bin/ipal-tokens.mjs')
finish(1)
}
results.push('old file paths (bin/ipal-*.mjs) and the 1.16 audit skill: ok')
const doctor = sh('old command: ipal-doctor (static, offline)', 'pnpm', ['exec', 'ipal-doctor', '.', '--offline', '--json'], { allowFail: true, capture: true })
let report
try {
+2
View File
@@ -129,6 +129,8 @@ export {
finishCrawl,
flagGoneEntries,
GOOGLE_TAG_HOSTS,
IAPL_COOKIE_SCAN_TOKEN_ENV,
IAPL_COOKIE_SCAN_URL_ENV,
indexCookieDatabase,
ingestCrawlResult,
loadCookieApproval,
+8 -4
View File
@@ -8,8 +8,12 @@ import { DEFAULT_TRACKER_HOSTS } from './violations.js'
export const COOKIE_CRAWL_SLUG = 'cookie-crawl'
export const COOKIE_CRAWL_PATH = '/ipal/cookie-crawl'
export const COOKIE_CRAWL_RESULTS_PATH = '/ipal/cookie-crawl/results'
export const COOKIE_SCAN_URL_ENV = 'IAPL_COOKIE_SCAN_URL'
export const COOKIE_SCAN_TOKEN_ENV = 'IAPL_COOKIE_SCAN_TOKEN'
/** The variables' names before 1.17.0 — still read, and these constants keep their values. */
export const COOKIE_SCAN_URL_ENV = 'IPAL_COOKIE_SCAN_URL'
export const COOKIE_SCAN_TOKEN_ENV = 'IPAL_COOKIE_SCAN_TOKEN'
/** The names since 1.17.0; `readEnv(IAPL_COOKIE_SCAN_URL_ENV)` falls back to the old one. */
export const IAPL_COOKIE_SCAN_URL_ENV = 'IAPL_COOKIE_SCAN_URL'
export const IAPL_COOKIE_SCAN_TOKEN_ENV = 'IAPL_COOKIE_SCAN_TOKEN'
/** A crawl still "running" after this long is treated as lost (the service never called back). */
export const CRAWL_TIMEOUT_MS = 30 * 60_000
@@ -28,8 +32,8 @@ const trimSlash = (v: string) => v.replace(/\/+$/, '')
/** Options + env + Payload config, read at call time (env can change between deploys, not between requests). */
export function resolveCrawlConfig(options: CookieCrawlOptions, payload: BasePayload): ResolvedCrawlConfig {
const serviceUrl = options.serviceUrl ?? readEnv(COOKIE_SCAN_URL_ENV)?.trim()
const token = options.token ?? readEnv(COOKIE_SCAN_TOKEN_ENV)?.trim()
const serviceUrl = options.serviceUrl ?? readEnv(IAPL_COOKIE_SCAN_URL_ENV)?.trim()
const token = options.token ?? readEnv(IAPL_COOKIE_SCAN_TOKEN_ENV)?.trim()
const siteUrl = options.siteUrl ?? (payload.config.serverURL || process.env.NEXT_PUBLIC_SERVER_URL?.trim())
return {
acceptSelector: options.acceptSelector ?? '[data-ipal="accept"]',
@@ -11,9 +11,9 @@ import {
COOKIE_CRAWL_PATH,
COOKIE_CRAWL_RESULTS_PATH,
COOKIE_CRAWL_SLUG,
COOKIE_SCAN_TOKEN_ENV,
COOKIE_SCAN_URL_ENV,
CRAWL_TIMEOUT_MS,
IAPL_COOKIE_SCAN_TOKEN_ENV,
IAPL_COOKIE_SCAN_URL_ENV,
resolveCrawlConfig,
} from './config.js'
import { finishCrawl, ingestCrawlResult } from './ingest.js'
@@ -78,8 +78,8 @@ export function buildCookieCrawlEndpoints({
error: stale ? 'Timed out — the scanner service never reported back.' : (doc.error ?? null),
finishedAt: doc.finishedAt ?? null,
missing: [
...(config.serviceUrl ? [] : [COOKIE_SCAN_URL_ENV]),
...(config.token ? [] : [COOKIE_SCAN_TOKEN_ENV]),
...(config.serviceUrl ? [] : [IAPL_COOKIE_SCAN_URL_ENV]),
...(config.token ? [] : [IAPL_COOKIE_SCAN_TOKEN_ENV]),
...(config.siteUrl ? [] : ['serverURL / NEXT_PUBLIC_SERVER_URL']),
],
ok: true,
+2
View File
@@ -20,6 +20,8 @@ export {
COOKIE_CRAWL_SLUG,
COOKIE_SCAN_TOKEN_ENV,
COOKIE_SCAN_URL_ENV,
IAPL_COOKIE_SCAN_TOKEN_ENV,
IAPL_COOKIE_SCAN_URL_ENV,
resolveCrawlConfig,
} from './crawl/config.js'
export type { ResolvedCrawlConfig } from './crawl/config.js'
+1 -1
View File
@@ -79,7 +79,7 @@ export const agentRules: DoctorRule[] = [
plan.missing.length ? `missing ${plan.missing.join(', ')}` : '',
plan.retired.length ? `retired ${plan.retired.join(', ')}` : '',
].filter(Boolean)
return parts.length ? [{ file: dest, fix: 'pnpm exec iapl-skills and commit', message: `skills differ from the installed ipal-kit: ${parts.join('; ')}`, severity: 'warning' }] : []
return parts.length ? [{ file: dest, fix: 'pnpm exec iapl-skills and commit', message: `skills differ from the installed IAPL: ${parts.join('; ')}`, severity: 'warning' }] : []
},
docs: 'docs/agent/AGENT.md#14-skills-antigravity-claude-code-cursor',
group: 'agents',
+2 -1
View File
@@ -111,7 +111,8 @@ export const legacyRules: DoctorRule[] = [
const out: RuleFinding[] = []
for (const file of files) {
const code = stripComments(ctx.read(file))
if (!/<PageStats\b|<SiteProviders\s[^>]*\bstats\b/.test(code)) {continue}
// <SiteProviders … stats …>: a prop named stats anywhere after the tag opens (other props hold JSX, so the tag's end cannot be found by `>`)
if (!/<PageStats\b/.test(code) && !/<SiteProviders\b[\s\S]*?\sstats(?:\s*=|\s*\n|\s+[a-zA-Z/>])/.test(code)) {continue}
const set = /\bIAPL_VISITOR_COOKIE\b|['"]iapl_vid['"]/.test(code) ? 'iapl_vid' : /\bvisitorCookie\b/.test(code) ? null : 'ipal_vid'
if (set && set !== declared) {
out.push({
+6 -1
View File
@@ -1,3 +1,5 @@
import { legacyEnvName } from '../shared/envName.js'
/**
* Zero-dependency environment validation. The plugin deliberately does NOT pull
* in zod — forcing a validation library on every project would be a dependency
@@ -111,7 +113,10 @@ export function assertEnv(rules: EnvRule[], options: AssertEnvOptions = {}): voi
const problems: string[] = []
for (const rule of rules) {
const raw = [rule.name, ...(rule.aliases ?? [])].map((key) => env[key]).find((v) => typeof v === 'string' && v.trim() !== '')
// the name first, then the aliases — except that a plugin variable's IAPL_ spelling is read before its IPAL_ one,
// whichever of the two the rule is named after (ipalEnvRules names the old one)
const keys = [rule.name, ...(rule.aliases ?? [])].sort((a, b) => Number(b.startsWith('IAPL_') && legacyEnvName(b) === a) - Number(a.startsWith('IAPL_') && legacyEnvName(a) === b))
const raw = keys.map((key) => env[key]).find((v) => typeof v === 'string' && v.trim() !== '')
const value = typeof raw === 'string' ? raw.trim() : ''
const required = rule.required !== false
+29 -2
View File
@@ -2,6 +2,7 @@ import type { EnvRule } from './assertEnv.js'
type TurnstileNames = { secretVar?: string; siteKeyVar?: string }
import { ENV_PREFIX, LEGACY_ENV_PREFIX, legacyEnvName } from '../shared/envName.js'
import { checkDatabaseName } from './databaseName.js'
export type IaplEnvFeatures = {
@@ -200,8 +201,34 @@ export function iaplEnvRules(features: IaplEnvFeatures = {}): EnvRule[] {
return rules
}
/** @deprecated The name before 1.17.0; the same function as `iaplEnvRules`. Removed in 2.0. */
export const ipalEnvRules = iaplEnvRules
/**
* The rules as they were named before 1.17.0: the plugin's own variables are called `IPAL_<NAME>` here
* (with `IAPL_<NAME>` as the alias), so a project that adapts the list by name
* (`.map` / `.filter` on `rule.name`) finds the names it wrote. Everything else is `iaplEnvRules`.
* The value is the `IAPL_` one when both are set, as everywhere else.
* @deprecated Use `iaplEnvRules` (names `IAPL_<NAME>`, the old ones as aliases). Removed in 2.0.
*/
export function ipalEnvRules(features: IaplEnvFeatures = {}): EnvRule[] {
return iaplEnvRules(features).map((rule) => {
const old = legacyEnvName(rule.name)
if (!old) {return rule}
const { validate } = rule
return {
...rule,
name: old,
aliases: [rule.name],
...(rule.description ? { description: rule.description.replaceAll(ENV_PREFIX, LEGACY_ENV_PREFIX) } : {}),
...(validate
? {
validate: (value: string) => {
const result = validate(value)
return typeof result === 'string' ? result.replaceAll(ENV_PREFIX, LEGACY_ENV_PREFIX) : result
},
}
: {}),
}
})
}
/** @deprecated The name before 1.17.0; the same type as `IaplEnvFeatures`. Removed in 2.0. */
export type IpalEnvFeatures = IaplEnvFeatures
+5 -2
View File
@@ -8,9 +8,12 @@ import { readEnv } from '../shared/envName.js'
* Production never sets it — a forgotten staging copy indexed by Google is a
* duplicate of the real site.
*/
export const SITE_NOINDEX_ENV = 'IAPL_NOINDEX'
/** The variable's name before 1.17.0. Still read; kept under this constant so `process.env[SITE_NOINDEX_ENV]` in a project means what it meant. */
export const SITE_NOINDEX_ENV = 'IPAL_NOINDEX'
/** The variable's name since 1.17.0. Read it with `isSiteNoindex()` or `readEnv(IAPL_SITE_NOINDEX_ENV)`, which fall back to the old one. */
export const IAPL_SITE_NOINDEX_ENV = 'IAPL_NOINDEX'
export function isSiteNoindex(): boolean {
const v = readEnv(SITE_NOINDEX_ENV)?.trim().toLowerCase()
const v = readEnv(IAPL_SITE_NOINDEX_ENV)?.trim().toLowerCase()
return v === '1' || v === 'true' || v === 'yes'
}
+1 -1
View File
@@ -310,7 +310,7 @@ export const iapl = (options: IaplOptions): Plugin => {
// `req.user` from ANY auth collection and act on the 2FA collection by id.
// Only accounts of the 2FA collection may use them (guardTotpEndpoint) —
// whatever the package registered, also paths a later version adds.
const limitVerify = tf.verifyLimit === false ? undefined : buildVerifyLimit(target, { ...(options.storageNames === 'iapl' ? { keyPrefix: 'iapl' } : {}), ...tf.verifyLimit })
const limitVerify = tf.verifyLimit === false ? undefined : buildVerifyLimit(target, { ...tf.verifyLimit, keyPrefix: (typeof tf.verifyLimit?.keyPrefix === 'string' && tf.verifyLimit.keyPrefix.trim()) || (options.storageNames === 'iapl' ? 'iapl' : 'ipal') })
const extraOrigins = typeof tf.sameOrigin === 'object' ? (tf.sameOrigin.origins ?? []) : []
const guards = {
...(limitVerify ? { limitVerify: (req: PayloadRequest) => limitVerify(req) } : {}),
+2
View File
@@ -32,6 +32,7 @@
"ipal",
"ipal-",
"ipal-a",
"ipal-audit",
"ipal-audit-skip",
"ipal-b",
"ipal-badge*",
@@ -63,6 +64,7 @@
"ipal-panel-smtp",
"ipal-polish-",
"ipal-primary",
"ipal-reference",
"ipal-release",
"ipal-row",
"ipal-safe-back",
+77 -3
View File
@@ -29,7 +29,7 @@ import { LEGACY_COMMANDS, LEGACY_EXPORTS, LEGACY_SKILL_NAMES, PLUGIN_ENV_NAMES }
import { runDoctor } from '../src/modules/doctor/run.js'
import { assertEnv } from '../src/modules/env/assertEnv.js'
import { buildVerifyLimit, clearVerifyLimits, verifyLimitKey } from '../src/modules/security/totp/verifyLimit.js'
import { isSiteNoindex } from '../src/modules/seo/siteNoindex.js'
import { isSiteNoindex, SITE_NOINDEX_ENV } from '../src/modules/seo/siteNoindex.js'
import { legacyEnvName, readEnv } from '../src/modules/shared/envName.js'
import { IAPL_VISITOR_COOKIE, VISITOR_COOKIE, visitorCookieFor } from '../src/modules/stats/visitorCookie.js'
@@ -63,11 +63,13 @@ describe('exported names', () => {
// types have no runtime value: only the names that exist at runtime are compared here
const runtime = Object.entries(LEGACY_EXPORTS).filter(([, name]) => name in values)
expect(runtime.map(([old]) => old).sort()).toEqual(['IPAL_BREAKPOINTS', 'IPAL_TOKENS', 'ipalEnvRules', 'ipalKit', 'ipalT', 'ipalVar'])
for (const [old, name] of runtime) {expect(values[old], `${old} → ${name}`).toBe(values[name])}
// ipalEnvRules is the one exception: the same rules under the names a project wrote before (next test block)
for (const [old, name] of runtime.filter(([o]) => o !== 'ipalEnvRules')) {expect(values[old], `${old} → ${name}`).toBe(values[name])}
})
test('the env and tokens entries carry both spellings too', () => {
expect(envEntry.ipalEnvRules).toBe(envEntry.iaplEnvRules)
expect(envEntry.ipalEnvRules).toBe(root.ipalEnvRules)
expect(envEntry.iaplEnvRules).toBe(root.iaplEnvRules)
expect(tokensEntry.IPAL_TOKENS).toBe(tokensEntry.IAPL_TOKENS)
expect(tokensEntry.IPAL_BREAKPOINTS).toBe(tokensEntry.IAPL_BREAKPOINTS)
expect(tokensEntry.ipalVar).toBe(tokensEntry.iaplVar)
@@ -117,6 +119,48 @@ describe('env variables', () => {
expect(() => assertEnv(required, { env: { ...old, IPAL_COOKIE_SCAN_TOKEN: 'short' } })).toThrow(/IAPL_COOKIE_SCAN_TOKEN must be at least 16/)
})
test('ipalEnvRules() keeps the old rule names, so code that adapts the rules by name still starts', () => {
const features = { cookieCrawl: true, ipHeader: true }
const names = (rules: { name: string }[]) => rules.map((r) => r.name)
const old = envEntry.ipalEnvRules(features)
const fresh = envEntry.iaplEnvRules(features)
expect(names(old)).toEqual(names(fresh).map((n) => n.replace(/^IAPL_/, 'IPAL_')))
expect(old.find((r) => r.name === 'IPAL_IP_HEADER')?.aliases).toEqual(['IAPL_IP_HEADER'])
expect(fresh.find((r) => r.name === 'IAPL_IP_HEADER')?.aliases).toEqual(['IPAL_IP_HEADER'])
// the two measured cases of the review: production, only the old env names, the project's code unchanged
const env = { DATABASE_URI: 'mongodb://127.0.0.1/x_prod', IPAL_IP_HEADER: 'cf-connecting-ip', NEXT_PUBLIC_SERVER_URL: 'https://example.pl', NODE_ENV: 'production', PAYLOAD_SECRET: 's'.repeat(40) }
const before = process.env.NODE_ENV
;(process.env as Record<string, string | undefined>).NODE_ENV = 'production'
try {
const rules = envEntry.ipalEnvRules(features)
expect(() => assertEnv(rules, { env })).toThrow(/IPAL_COOKIE_SCAN_URL is required/)
expect(() => assertEnv(rules.map((r) => (/^IPAL_COOKIE_SCAN/.test(r.name) ? { ...r, required: false } : r)), { env })).not.toThrow()
expect(() => assertEnv(rules.filter((r) => !r.name.startsWith('IPAL_COOKIE_SCAN')), { env })).not.toThrow()
// untouched rules: the old env alone, the new env alone, and a too-short token under the old rule's own name
const scan = { COOKIE_SCAN_TOKEN: '0123456789abcdef', COOKIE_SCAN_URL: 'https://crawler.example.com' }
const withPrefix = (prefix: string) => Object.fromEntries(Object.entries(scan).map(([k, v]) => [`${prefix}_${k}`, v]))
expect(() => assertEnv(rules, { env: { ...env, ...withPrefix('IPAL') } })).not.toThrow()
expect(() => assertEnv(rules, { env: { ...env, IAPL_IP_HEADER: 'cf-connecting-ip', IPAL_IP_HEADER: undefined, ...withPrefix('IAPL') } })).not.toThrow()
expect(() => assertEnv(envEntry.iaplEnvRules(features), { env: { ...env, ...withPrefix('IPAL') } })).not.toThrow()
expect(() => assertEnv(rules, { env: { ...env, ...withPrefix('IPAL'), IPAL_COOKIE_SCAN_TOKEN: 'short' } })).toThrow(/IPAL_COOKIE_SCAN_TOKEN must be at least 16/)
// both spellings set: the IAPL_ value is the one checked, whichever the rule is named after
expect(() => assertEnv(rules, { env: { ...env, ...withPrefix('IPAL'), IAPL_COOKIE_SCAN_TOKEN: 'short' } })).toThrow(/must be at least 16/)
} finally {
;(process.env as Record<string, string | undefined>).NODE_ENV = before
}
})
test('the exported name constants kept their values; the new names have constants of their own', () => {
expect([root.COOKIE_SCAN_URL_ENV, root.COOKIE_SCAN_TOKEN_ENV]).toEqual(['IPAL_COOKIE_SCAN_URL', 'IPAL_COOKIE_SCAN_TOKEN'])
expect([root.IAPL_COOKIE_SCAN_URL_ENV, root.IAPL_COOKIE_SCAN_TOKEN_ENV]).toEqual(['IAPL_COOKIE_SCAN_URL', 'IAPL_COOKIE_SCAN_TOKEN'])
expect(SITE_NOINDEX_ENV).toBe('IPAL_NOINDEX')
// an empty new variable does not switch the old one off (docs/env.md)
process.env.IAPL_NOINDEX = ''
process.env.IPAL_NOINDEX = '1'
expect(isSiteNoindex()).toBe(true)
})
test('every runtime variable the doctor knows has an IPAL_ twin', () => {
for (const name of PLUGIN_ENV_NAMES) {expect(legacyEnvName(name)).toBe(name.replace('IAPL_', 'IPAL_'))}
})
@@ -226,6 +270,15 @@ describe('the doctor on a project that was not touched', () => {
expect(await check("storageNames: 'iapl'", 'visitorCookie={IAPL_VISITOR_COOKIE}')).toEqual([])
expect(await check("storageNames: 'iapl'", 'locale="pl"')).toEqual(['the page sets the visitor cookie ipal_vid, the cookie scanner declares iapl_vid'])
expect(await check('', 'visitorCookie="iapl_vid"')).toEqual(['the page sets the visitor cookie iapl_vid, the cookie scanner declares ipal_vid'])
// the reference layout's shape: <SiteProviders> with a JSX prop before `stats` (the first `>` is inside it)
const providers = (stats: string) => `import { SiteProviders } from '@intecion/ipal-kit/rsc'\nexport default function L() {\n return (\n <SiteProviders\n banner={<CookieBanner controls="switch" equalChoice settings="detailed" />}\n lightbox\n ${stats}\n shell={shell}\n >\n <main />\n </SiteProviders>\n )\n}\n`
const withProviders = async (names: string, stats: string) =>
(await run(project({ 'package.json': { name: 'x' }, 'src/app/(frontend)/[locale]/layout.tsx': providers(stats), 'src/payload.config.ts': config(names) }), ['storage-names'])).findings.filter((f) => f.rule === 'storage-names').length
expect(await withProviders("storageNames: 'iapl'", 'stats={{ locale }}')).toBe(1)
expect(await withProviders("storageNames: 'iapl'", 'stats')).toBe(1)
expect(await withProviders("storageNames: 'iapl'", 'stats={{ locale, visitorCookie: IAPL_VISITOR_COOKIE }}')).toBe(0)
expect(await withProviders('', 'stats={{ locale }}')).toBe(0)
expect(await withProviders("storageNames: 'iapl'", 'theme')).toBe(0) // no statistics mounted: nothing to compare
// a name the doctor cannot read (a variable) is not judged
expect(await check('', 'visitorCookie={name}')).toEqual([])
})
@@ -238,6 +291,15 @@ describe('commands and skills', () => {
expect(existsSync(path.join(packageRoot, pkg.bin[name])), pkg.bin[name]).toBe(true)
}
expect(Object.keys(pkg.bin)).toHaveLength(10)
// …and the old FILES are still there: 1.16's own audit skill and CI scripts call them by path
for (const [old, name] of Object.entries(LEGACY_COMMANDS)) {
const file = path.join(packageRoot, 'bin', `${old}.mjs`)
expect(existsSync(file), `bin/${old}.mjs`).toBe(true)
expect(readFileSync(file, 'utf8')).toContain(`import './${pkg.bin[name].replace('bin/', '')}'`)
}
const byPath = spawnSync(process.execPath, [path.join(packageRoot, 'bin/ipal-skills.mjs'), '--help'], { encoding: 'utf8' })
expect(byPath.status).toBe(0)
expect(byPath.stdout).toContain('Usage: iapl-skills')
// `pnpm dlx @intecion/ipal-kit create` runs the bin named after the package
expect(pkg.bin['ipal-kit']).toBe('bin/iapl.mjs')
})
@@ -288,6 +350,11 @@ describe('commands and skills', () => {
expect(second.stdout).not.toMatch(/^(?:add|remove|create)\b/m)
expect(second.stdout).toContain('ok AGENTS.md')
expect(readFileSync(path.join(dir, 'AGENTS.md'), 'utf8')).toBe(agents)
// a rollback to 1.16 whose installer appended its block again, then the upgrade: one block, the new one
writeFileSync(path.join(dir, 'AGENTS.md'), `${agents}\n<!-- ipal-kit:start -->\n## ipal-kit 1.16.7 — agent guide\n\nold text\n<!-- ipal-kit:end -->\n`)
expect(run('iapl-skills.mjs').status).toBe(0)
expect(readFileSync(path.join(dir, 'AGENTS.md'), 'utf8')).toBe(agents)
})
})
@@ -325,5 +392,12 @@ describe('stored names', () => {
expect((await limit(req()))?.status).toBe(429)
expect([...data.keys()]).toEqual(['iapl:2fa-verify:users:1'])
expect(data.get('iapl:2fa-verify:users:1')).toMatchObject({ count: 3 })
// an empty or undefined prefix is "not given", never a third key
for (const keyPrefix of [undefined, '', ' ']) {
data.clear()
clearVerifyLimits()
await buildVerifyLimit('users', { keyPrefix })(req())
expect([...data.keys()]).toEqual(['ipal:2fa-verify:users:1'])
}
})
})