From 01afa6fab812e40a22d7886503bf1951c4076614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Thu, 29 Oct 2026 16:11:33 +0100 Subject: [PATCH] Starter: inherit the reference doctor silences and packageManager; cookieCrawl active in the reference Same reference/package.json, reference/ipal-doctor.json and ci.yml env lines as claude/ipal-doctor-build, so the two branches merge cleanly there. ipal-doctor.json of a new site keeps i18n-literals (the /design styleguide) and audit:collections-present only while posts/caseStudies are in. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 3 +++ docs/agent/reference-site/INDEX.md | 17 +++++++++++++++-- docs/dev/project-starter-proposal.md | 2 +- docs/project-starter.md | 4 +++- reference/ipal-doctor.json | 15 ++++++++++++++- reference/package.json | 1 + reference/src/instrumentation.ts | 2 +- src/modules/starter/generate.ts | 14 +++++++++++--- src/modules/starter/render.ts | 8 +++++--- test/starter.test.ts | 5 +++++ 10 files changed, 59 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index ccf49bb..08c9cf1 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -69,6 +69,9 @@ jobs: PAYLOAD_SECRET: ci-reference-secret-0123456789abcdef NEXT_PUBLIC_SERVER_URL: http://localhost:3100 IPAL_IP_HEADER: x-forwarded-for + # cookieScanner.crawl → ipalEnvRules({ cookieCrawl }) requires both in production; CI never starts a crawl + IPAL_COOKIE_SCAN_URL: http://127.0.0.1:9/crawl + IPAL_COOKIE_SCAN_TOKEN: ci-cookie-scan-token-0123456789 NEXT_PUBLIC_TURNSTILE_SITE_KEY: 1x00000000000000000000AA TURNSTILE_SECRET_KEY: 1x0000000000000000000000000000000AA ALLOW_LOCAL_MEDIA: '1' diff --git a/docs/agent/reference-site/INDEX.md b/docs/agent/reference-site/INDEX.md index 1777a71..29a358b 100644 --- a/docs/agent/reference-site/INDEX.md +++ b/docs/agent/reference-site/INDEX.md @@ -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" + } + } } ``` @@ -209,7 +222,7 @@ export function register() { assertEnv( ipalEnvRules({ // @starter:if crawl - //: cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN — the shared cookie-crawler service + cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN in production — the shared cookie-crawler service // @starter:endif databaseName: { domain: 'example-studio.pl' }, // @starter:if graph diff --git a/docs/dev/project-starter-proposal.md b/docs/dev/project-starter-proposal.md index 89c9f8a..3f1b961 100644 --- a/docs/dev/project-starter-proposal.md +++ b/docs/dev/project-starter-proposal.md @@ -2,7 +2,7 @@ **Status:** built (revision 3) — the user guide is [docs/project-starter.md](../project-starter.md). Differences from this design, found while building: the env rules stay inline in `instrumentation.ts` as in the reference site (no -`src/env.rules.ts`); no `packageManager` field (the reference site has none — add it there and the starter copies it); +`src/env.rules.ts`); `packageManager` comes from the reference site (added there for ipal-doctor's `pnpm-pinned`); the command needs `--config.auto-install-peers=false` to keep `dlx` small (7 packages instead of 356); the templates and the lockfile travel in one bundle (`dist/starter/template.json.gz`); the seed command is the reference's `SEED_ONLY=… pnpm seed`; the language answers are limited to default `pl` + `en` (the base seed is Polish + English). diff --git a/docs/project-starter.md b/docs/project-starter.md index 9c6362e..efc3be0 100644 --- a/docs/project-starter.md +++ b/docs/project-starter.md @@ -109,7 +109,9 @@ pnpm exec ipal-kit create intecion.com --dir ../intecioncom-web --answers answer The reference site's tree (AGENT.md §3) with: the plugin pinned to the exact released version, the database names from `databaseNamesFor(domain)` (`intecion.com` → `intecioncom_dev` / `intecioncom_prod`; hyphens stay), -CSP in **report-only** (`ipal-doctor.json` silences the report-only finding for 28 days with the reason), +`packageManager` pinned (copied from the reference site), CSP in **report-only** (`ipal-doctor.json` silences the +report-only finding for 28 days with the reason, and carries the reference site's own reasoned silences — +`i18n-literals` for the `/design` styleguide, `audit:collections-present` only while `posts` / `caseStudies` are in), `assertEnv(ipalEnvRules({ databaseName, ipHeader, storage, … }))` in `instrumentation.ts`, the blocks from the block library (`libraryBlocks` + `createBlockRegistry(content, { Image, Link, … })`), the design-token standard (`styles.css` imports only, the brand in `src/design/tokens.ts`, next/font `--font-family-body` / diff --git a/reference/ipal-doctor.json b/reference/ipal-doctor.json index e2ba037..9569ca2 100644 --- a/reference/ipal-doctor.json +++ b/reference/ipal-doctor.json @@ -1,4 +1,17 @@ { "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" + } + } } diff --git a/reference/package.json b/reference/package.json index 16941c8..515f4d7 100644 --- a/reference/package.json +++ b/reference/package.json @@ -7,6 +7,7 @@ "engines": { "node": ">=22 <23" }, + "packageManager": "pnpm@10.34.3", "scripts": { "dev": "next dev", "build": "cross-env NODE_OPTIONS=\"--max-old-space-size=3072\" next build --webpack", diff --git a/reference/src/instrumentation.ts b/reference/src/instrumentation.ts index e2909e9..35c1c77 100644 --- a/reference/src/instrumentation.ts +++ b/reference/src/instrumentation.ts @@ -9,7 +9,7 @@ export function register() { assertEnv( ipalEnvRules({ // @starter:if crawl - //: cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN — the shared cookie-crawler service + cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN in production — the shared cookie-crawler service // @starter:endif databaseName: { domain: 'example-studio.pl' }, // @starter:if graph diff --git a/src/modules/starter/generate.ts b/src/modules/starter/generate.ts index f3ad2f6..8e9d625 100644 --- a/src/modules/starter/generate.ts +++ b/src/modules/starter/generate.ts @@ -175,11 +175,19 @@ export function renderAgentsMd(reference: string, a: StarterAnswers, ctx: SiteCo return header + reference.slice(rules, map) + siteMap + start + '\n' + renderDecisions(a, ctx) + reference.slice(to) } -/** ipal-doctor.json: the domain, not launched yet, and every deliberate difference silenced with its reason. */ -export function renderDoctorConfig(a: StarterAnswers, ctx: SiteContext): string { +type DoctorRule = { [key: string]: unknown; off?: boolean; reason: string; until?: string } + +/** + * ipal-doctor.json: the domain, not launched yet, and every deliberate difference silenced with its reason — + * the reference site's own silences (`inherited`, from its ipal-doctor.json) while the files they cover are in + * the site, CSP report-only for 28 days, and each module the owner turned off. + */ +export function renderDoctorConfig(a: StarterAnswers, ctx: SiteContext, inherited: Record = {}): string { const until = new Date(`${ctx.date}T00:00:00Z`) until.setUTCDate(until.getUTCDate() + 28) - const rules: Record = { + const kept = Object.entries(inherited).filter(([id]) => id !== 'audit:collections-present' || a.content.collections.length > 0) + const rules: Record = { + ...Object.fromEntries(kept), csp: { off: true, reason: 'report-only at the start; switch to enforce once the [csp] reports are clean (security.md → ROLL OUT CSP)', until: until.toISOString().slice(0, 10) }, } for (const skip of auditSkips(a)) { diff --git a/src/modules/starter/render.ts b/src/modules/starter/render.ts index f939afb..8680811 100644 --- a/src/modules/starter/render.ts +++ b/src/modules/starter/render.ts @@ -18,9 +18,11 @@ import { fileRole } from './manifest.js' import { applyPlaceholders, applyVariants, leftoverFakes, type StarterFlags } from './text.js' /** Files the starter writes from the answers; the manifest lists them under `generate`. */ -const GENERATORS: Record string> = { +type Generator = (a: StarterAnswers, ctx: SiteContext, reference: string | undefined) => string + +const GENERATORS: Record = { 'DESIGN.md': (a) => renderDesignMd(a), - 'ipal-doctor.json': renderDoctorConfig, + 'ipal-doctor.json': (a, ctx, reference) => renderDoctorConfig(a, ctx, reference ? (JSON.parse(reference) as { rules?: Record }).rules : {}), 'src/design/tokens.ts': (a) => renderTokens(a), 'src/i18n.config.ts': (a) => renderI18nConfig(a), } @@ -83,7 +85,7 @@ export function renderSite(bundle: StarterBundle, a: StarterAnswers, ctx: SiteCo problems.push(`${path}: listed under "generate" but this ipal-kit has no generator for it`) continue } - out[path] = generate(a, ctx) + out[path] = generate(a, ctx, bundle.files[path]) } if (problems.length) {throw new Error(`rendering the site:\n ${problems.join('\n ')}`)} out['pnpm-lock.yaml'] = bundle.lockfile diff --git a/test/starter.test.ts b/test/starter.test.ts index fd392de..7d66db9 100644 --- a/test/starter.test.ts +++ b/test/starter.test.ts @@ -221,6 +221,9 @@ describe.runIf(existsSync(path.join(reference, 'starter.manifest.json')))('start expect(files['AGENTS.md']).toMatch(/## Project decisions\n- Languages: pl, en/) expect(files['src/seed/base.ts']).toContain("email: 'biuro@acme-test.pl'") expect(files['pnpm-lock.yaml']).not.toContain('@intecion/ipal-kit') + const doctor = JSON.parse(files['ipal-doctor.json'] ?? '') as { rules: Record } + expect(Object.keys(doctor.rules).sort()).toEqual(['audit:collections-present', 'csp', 'i18n-literals']) + expect((JSON.parse(files['package.json'] ?? '') as { packageManager?: string }).packageManager).toMatch(/^pnpm@\d/) }) it('drops what the owner turned off', () => { @@ -239,5 +242,7 @@ describe.runIf(existsSync(path.join(reference, 'starter.manifest.json')))('start expect(files['src/instrumentation.ts']).toContain('storage: false,') expect(files['src/lib/content.ts']).not.toMatch(/buildLocalBusinessJsonLd|getPayload/) expect(files['AGENTS.md']).toContain('ipal-audit-skip: twofactor, r2') + expect(Object.keys((JSON.parse(files['ipal-doctor.json'] ?? '') as { rules: object }).rules).sort()).toEqual(['2fa', 'csp', 'i18n-literals']) + expect(files['src/instrumentation.ts']).not.toContain('cookieCrawl') }) })