Reference site: Example Studio on ipal-kit (reference/), index for agents, CI job

reference/ is one complete client site on the plugin (made-up company, pl/en,
MongoDB, every library block and template, token standard light/dark, forms,
consent, SEO/GEO, enforced CSP, 2FA, base + demo seeds, Coolify runbook,
smoke tests). It uses the plugin as file:.. (injected) and is not shipped.

- docs/agent/reference-site/INDEX.md (generated by scripts/reference-index.mjs,
  kept current by test/referenceIndex.test.ts)
- AGENT.md section and pointers in ipal-site, ipal-setup, ipal-reference,
  ipal-upgrade, ipal-block; release steps in PROGRAMISTA §8.1b
- CI: reference (fast) on every push, reference-full on main; doctor steps
  wired, commented until ipal-doctor ships

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 15:17:11 +01:00
co-authored by Claude Opus 5.5
parent 8bb5ebd394
commit 8adac41f92
129 changed files with 18440 additions and 1 deletions
+176
View File
@@ -0,0 +1,176 @@
#!/usr/bin/env node
// Maintainer script (not shipped): writes docs/agent/reference-site/INDEX.md from reference/ — the map agents
// in client projects read (reference/ itself is not in the npm package). Short wiring files are copied in full,
// so an agent has them offline; longer files get their one-line description and the path in the repo.
//
// pnpm reference:index → rewrite INDEX.md (commit it)
// test/referenceIndex.test.ts fails when INDEX.md is out of date.
import { execFileSync } from 'node:child_process'
import { readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const FULL_MAX_LINES = 40
const SKIP_DIRS = new Set(['.agents', '.next', 'media', 'node_modules', 'playwright-report', 'test-results'])
const SKIP_FILES = new Set(['.env', 'next-env.d.ts', 'payload-types.ts', 'importMap.js', 'pnpm-lock.yaml'])
const GENERATED = /^src\/app\/\(payload\)\//
/** Sections in reading order: [title, AGENT.md / doc reference, path test]. */
const SECTIONS = [
['Project files', 'AGENT.md §13, §0a', (p) => !p.includes('/') || p.startsWith('docs/')],
['Configuration', 'AGENT.md §3, ipal-setup stage 3', (p) => /^src\/[^/]+\.ts$/.test(p)],
['Collections and globals', 'AGENT.md §5, ipal-nav, ipal-collection', (p) => /^src\/(collections|globals)\//.test(p)],
['Blocks', 'docs/block-library.md', (p) => p.startsWith('src/blocks/')],
['Design tokens', 'docs/design-tokens.md', (p) => p.startsWith('src/design/') || p.startsWith('src/components/design/') || p.includes('/design/')],
['Data layer', 'AGENT.md §3, PROGRAMISTA §2.7', (p) => p.startsWith('src/lib/')],
['Layout and components', 'AGENT.md §6.8, ipal-nav, ipal-form', (p) => p.startsWith('src/components/') || p.startsWith('src/app/(frontend)/')],
['SEO, GEO and ops routes', 'AGENT.md §0b, ipal-setup stages 7–8', (p) => p.startsWith('src/app/')],
['Seeds', 'docs/seeding.md, docs/block-library.md "Page templates"', (p) => p.startsWith('src/seed/')],
['Smoke tests', 'AGENT.md §8a', (p) => p.startsWith('e2e/') || p === 'playwright.config.ts'],
]
/** The site's files as git sees them: tracked or new, never ignored (.gitignore). */
function listFiles(ref) {
const out = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z', '.'], { cwd: ref, encoding: 'utf8' })
return out
.split('\0')
.filter(Boolean)
.filter((rel) => !rel.split('/').some((part) => SKIP_DIRS.has(part)) && !SKIP_FILES.has(rel.split('/').pop()) && !GENERATED.test(rel))
.sort()
}
/** The file's own one-line description: the heading of a Markdown file, `$comment` of JSON, the leading comment of code. */
function describe(text, rel) {
if (rel.endsWith('.md')) {return (text.match(/^#\s+(.+)$/m)?.[1] ?? '').trim()}
if (rel.endsWith('.json')) {return (text.match(/"\$comment":\s*"([^"]+)"/)?.[1] ?? '').split('. ')[0]}
const first = text.split('\n').find((l) => l.trim() && !/^\s*['"]use (client|server)['"]/.test(l)) ?? ''
const m = first.match(/^\s*(?:\/\/|\/\*\*?|#)\s*(.*?)\s*(?:\*\/)?$/)
return m ? m[1] : ''
}
/** What each file shows, by path. A new file in reference/ needs a line here (test/referenceIndex.test.ts). */
export const DESCRIPTIONS = {
'.env.example': 'every env var the site reads, with dev / test values and build vs runtime notes',
'.gitignore': 'what a project never commits',
'.npmrc': 'the @intecion registry line (committed, no secret)',
'.nvmrc': 'Node 22, the same as `engines` and the Coolify build pack',
'AGENTS.md': 'the agent guide of the project: site map and filled "Project decisions" (AGENT.md §13)',
'CLAUDE.md': 'one line `@AGENTS.md` (Claude Code reads CLAUDE.md)',
'DESIGN.md': 'the human source of the look, matching src/design/tokens.ts',
'README.md': 'how to run the reference site and what is where',
'docs/DEPLOY.md': 'the Coolify runbook: local check, app settings, MongoDB resource, env, targeted seeds, DNS, rollback',
'e2e/create-test-admin.ts': 'a test admin with a known TOTP secret (local / CI database only)',
'e2e/smoke.spec.ts': 'the smoke tests every release must pass: pages, showcase, forms, sitemap, SEO/GEO, headers, consent, 2FA',
'e2e/totp.ts': 'RFC 6238 code generator for the 2FA sign-in in the smoke test',
'ipal-doctor.json': 'the production domain and launch state for ipal-doctor',
'next.config.ts': 'security headers, enforced CSP, admin CSP, upload headers, images, no X-Powered-By',
'package.json': 'scripts (build, start, seed, tokens, generate), pinned Payload versions and overrides',
'playwright.config.ts': 'smoke tests against the built, seeded site',
'postcss.config.mjs': 'Tailwind 4 through PostCSS',
'starter.manifest.json': 'what `ipal-kit create` keeps, drops and turns into placeholders',
'src/app/(frontend)/[locale]/[[...slug]]/page.tsx': 'the catch-all page: createPageRoute, ISR, redirects, maintenance, the language switcher links',
'src/app/(frontend)/[locale]/actions.ts': 'the ONE form server action (createSubmitAction)',
'src/app/(frontend)/[locale]/design/page.tsx': 'the design-token styleguide page (noindex)',
'src/app/(frontend)/[locale]/layout.tsx': 'the locale layout: next/font slots, SiteProviders (theme, lightbox, consent), header, footer',
'src/app/(frontend)/[locale]/not-found.tsx': '404 from the panel (createNotFoundPage)',
'src/app/(frontend)/[locale]/notFoundView.ts': 'the 404 view loaded only on a 404 (server action)',
'src/app/(frontend)/styles.css': 'the standard styles.css: Tailwind, fluid-wide, tokens, preset, brand',
'src/app/api/csp-report/route.ts': 'CSP violation reports',
'src/app/api/health/route.ts': 'Coolify health check',
'src/app/api/mcp/route.ts': 'public MCP server (GEO)',
'src/app/indexnow-key.txt/route.ts': 'IndexNow key',
'src/app/llms-full.txt/route.ts': 'llms-full.txt (GEO)',
'src/app/llms.txt/route.ts': 'llms.txt (GEO)',
'src/app/manifest.ts': 'web app manifest from Site settings',
'src/app/md/[locale]/[[...slug]]/route.ts': 'every page as Markdown (GEO)',
'src/app/robots.ts': 'robots.txt with the AI crawler policy from the panel',
'src/app/sitemap.xml/route.ts': 'the one sitemap',
'src/blocks/configs.ts': 'the block library turned on in the Pages layout (libraryBlocks)',
'src/blocks/registry.ts': 'createBlockRegistry with next/image, next/link, the form action and contact details',
'src/collections/CaseStudies.ts': 'a project-specific archive collection',
'src/collections/Media.ts': 'the full media collection (media.md)',
'src/collections/Pages.ts': 'Pages: slug, blocks layout, AI summary, noindex, slug history, revalidation, system-page delete guard',
'src/collections/Posts.ts': 'the blog collection (archive in System pages)',
'src/collections/entryFields.ts': 'shared fields of archive collections (names the entry card reads)',
'src/components/design/TokenPanel.tsx': 'one styleguide panel built from IPAL_TOKENS',
'src/components/forms/formClasses.ts': 'the ONE place forms are styled, token utilities only',
'src/components/layout/Footer.tsx': 'footer: columns, company data, legal links from System pages, NoSnippet',
'src/components/layout/Header.tsx': 'header: logo from Site settings, resolveNav menu, language and theme switch, CTA',
'src/components/layout/LocaleSwitcher.tsx': 'the language switcher in a client wrapper (function props)',
'src/components/layout/MobileNav.tsx': 'the mobile menu (client, open state only)',
'src/content.config.ts': 'collections with archive pages',
'src/db.ts': 'the database adapter, alone in one file (MongoDB)',
'src/design/tokens.css': 'GENERATED by `pnpm tokens` from tokens.ts — never edited by hand',
'src/design/tokens.ts': 'the brand: the ONLY file edited to rebrand the site',
'src/globals/Company.ts': 'company data (PL market): footer, contact details, LocalBusiness JSON-LD',
'src/globals/Footer.ts': 'footer navigation global',
'src/globals/Header.ts': 'header navigation global',
'src/i18n.config.ts': 'the ONLY source of languages',
'src/instrumentation.ts': 'env validation at startup (assertEnv, database name rule)',
'src/lib/content.ts': 'createContentHelpers: the ONLY access to Payload, routes, links, JSON-LD',
'src/lib/globals.ts': 'cached getters for the project\'s own globals',
'src/payload.config.ts': 'ipalKit with every module the site uses, R2, mail, 2FA, white-label',
'src/proxy.ts': 'the locale proxy with Markdown negotiation (not middleware.ts)',
'src/seed/base.ts': 'BASE seed: templates, system pages, navigation, banner texts — kept by the starter',
'src/seed/demo.ts': 'DEMO seed: the made-up company in pl and en — dropped by the starter',
'src/seed/forms.ts': 'forms seed: fields, confirmation, e-mail to the company and to the sender',
'src/seed/index.ts': 'the seed entry: layers, SEED_ONLY, the inbox rule',
'src/seed/lib.ts': 'seed value helpers (both languages side by side, rich text)',
'src/seed/media.ts': 'generated placeholder images (no stock photos)',
'src/seed/showcase.ts': 'the Blocks showcase page from blockLibraryManifest (every variant, inverted too)',
'tsconfig.json': 'paths @/ and @payload-config, .agents excluded',
}
const FENCE = { css: 'css', json: 'json', md: 'markdown', mjs: 'js', ts: 'ts', tsx: 'tsx' }
/** reference/ files that have no line in DESCRIPTIONS. */
export function undescribedFiles(root) {
return listFiles(path.join(root, 'reference')).filter((f) => !DESCRIPTIONS[f])
}
export function buildReferenceIndex(root) {
const ref = path.join(root, 'reference')
const version = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')).version
const files = listFiles(ref)
const lines = [
'# Reference site — file index',
'',
'<!-- Generated by scripts/reference-index.mjs from reference/ — do not edit by hand (pnpm reference:index). -->',
'',
`The reference site is one complete client site on ipal-kit ${version} ("Example Studio", made up) that uses`,
'every convention in AGENT.md. It lives in the plugin repo (`reference/`, not in the npm package). Copy the',
'PATTERN of the file you need; change only the project\'s content. Files up to',
`${FULL_MAX_LINES} lines are below in full; open the rest in the repo at the tag of your plugin version:`,
'`https://git.intecion.net/IntecionSoftware/ipal-kit/src/tag/v<version>/reference/<path>`.',
'If this index and AGENT.md disagree, report it with ipal-plugin-gap — it is a plugin bug.',
'',
]
const seen = new Set()
for (const [title, refers, match] of SECTIONS) {
const inSection = files.filter((f) => !seen.has(f) && match(f))
if (!inSection.length) {continue}
lines.push(`## ${title}`, '', `Rules: ${refers}.`, '', '| File | What it shows |', '|---|---|')
const full = []
for (const f of inSection) {
seen.add(f)
const text = readFileSync(path.join(ref, f), 'utf8')
const count = text.trimEnd().split('\n').length
const inline = count <= FULL_MAX_LINES && !f.endsWith('.md')
lines.push(`| \`${f}\` | ${(DESCRIPTIONS[f] ?? describe(text, f)).replace(/\|/g, '\\|') || '—'}${inline ? ' (below)' : ''} |`)
if (inline) {full.push([f, text])}
}
lines.push('')
for (const [f, text] of full) {
lines.push(`### \`${f}\``, '', '```' + (FENCE[f.split('.').pop()] ?? ''), text.trimEnd(), '```', '')
}
}
const rest = files.filter((f) => !seen.has(f))
if (rest.length) {lines.push('## Other files', '', ...rest.map((f) => `- \`${f}\``), '')}
return lines.join('\n')
}
if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
writeFileSync(path.join(root, 'docs/agent/reference-site/INDEX.md'), buildReferenceIndex(root))
console.log('wrote docs/agent/reference-site/INDEX.md')
}