Docs: reconcile agent, developer and module docs with the code

- AGENT.md, skills, PROGRAMISTA, vibe, README and module pages checked
  against src/ and package.json; every mismatch fixed (consent/analytics
  loading, revalidation scope, generateStaticParams, construction gating,
  Turnstile fail modes, email/Graph, MCP, i18n, links, slug, hooks, ...)
- New pages: frontend.md, media.md, integrations.md; docs/README.md now
  indexes every page
- Main rule (plugin helps, never limits) at the top of AGENT.md,
  PROGRAMISTA.md, docs/README.md, README and the setup/plugin-gap skills;
  module pages gain a "Wyłączenie, nadpisanie, rozszerzenie" section
- README/PROGRAMISTA: stop telling projects to install packages ipal-kit
  already depends on; peer table; publish flow matches prepublishOnly
- ipal-skills: refuse --dest without a value or pointing at the project
  root (previously could delete ipal-* folders in cwd)
- docsConsistency: option keys, IPAL_* env names, relative links, README
  index, AGENT.md section refs, skill frontmatter, frontend.md helper keys,
  no `pnpm add` of own dependencies

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:06:52 +02:00
co-authored by Claude Opus 5.5
parent 12fbd424a5
commit 6e0f59c62b
49 changed files with 1736 additions and 605 deletions
+78 -1
View File
@@ -6,7 +6,7 @@
* 2. every public runtime export is described somewhere in docs/ (an API
* nobody knows about gets re-implemented in projects).
*/
import { readdirSync, readFileSync, statSync } from 'node:fs'
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { describe, expect, test } from 'vitest'
@@ -108,4 +108,81 @@ describe('docs ↔ code', () => {
}
expect(undocumented).toEqual([])
})
test('every top-level plugin option is documented', () => {
const src = read('src/types.ts')
const body = src.slice(src.indexOf('export type IpalOptions = {'))
const keys = [...body.matchAll(/^ {2}(\w+)\??:/gm)].map((m) => m[1])
expect(keys.length).toBeGreaterThan(10)
const all = docs.map(read).join('\n')
expect(keys.filter((key) => !new RegExp(`\\b${key}\\b`).test(all))).toEqual([])
})
test('every IPAL_* env var named in the docs is read by the code', () => {
const code = srcFiles().map(read).join('\n')
const named = new Set([...docs, 'README.md'].flatMap((f) => [...read(f).matchAll(/\bIPAL_[A-Z0-9_]+/g)].map((m) => m[0])))
expect([...named].filter((name) => !code.includes(name))).toEqual([])
})
test('relative links between docs point at existing files', () => {
const broken: string[] = []
for (const file of [...docs, 'README.md'].filter((f) => f.endsWith('.md'))) {
for (const m of read(file).matchAll(/\]\((?!https?:|mailto:|#)([^)\s#]+)(?:#[^)]*)?\)/g)) {
if (!existsSync(path.join(root, path.dirname(file), m[1]))) {broken.push(`${file}: ${m[1]}`)}
}
}
expect(broken).toEqual([])
})
test('every module page is listed in docs/README.md', () => {
const index = read('docs/README.md')
const pages = readdirSync(path.join(root, 'docs')).filter((n) => n.endsWith('.md') && !['README.md', 'CHANGELOG.md'].includes(n))
expect(pages.filter((p) => !index.includes(`(./${p})`))).toEqual([])
})
test('AGENT.md § references point at existing sections', () => {
const headings = new Set([...read('docs/agent/AGENT.md').matchAll(/^#{2,3} ([0-9]+[a-z]?(?:\.[0-9]+[a-z]?)*)\.? /gm)].map((m) => m[1]))
const missing: string[] = []
for (const file of docs) {
for (const m of read(file).matchAll(/AGENT\.md ?§ ?([0-9]+[a-z]?(?:\.[0-9]+[a-z]?)*)/g)) {
const id = m[1]
// §0b.4 may point at a numbered rule inside §0b — the parent section is enough.
if (!headings.has(id) && !headings.has(id.replace(/\.[^.]+$/, ''))) {missing.push(`${file}: §${id}`)}
}
}
expect(missing).toEqual([])
})
test('frontend.md describes every key @/lib/content can export', () => {
const page = read('docs/frontend.md')
expect([...contentHelperNames()].filter((name) => !new RegExp(`\\b${name}\\b`).test(page))).toEqual([])
})
test('install commands never tell projects to add packages ipal-kit already depends on', () => {
const own = Object.keys(JSON.parse(read('package.json')).dependencies)
const offending: string[] = []
for (const file of ['README.md', 'docs/dev/PROGRAMISTA.md']) {
for (const m of read(file).matchAll(/pnpm add ([^\n`\\]+(?:\\\n[^\n`\\]+)*)/g)) {
const pkgs = m[1].split(/[\s\\]+/).map((p) => p.replace(/@[^@/]*$/, ''))
for (const dep of own) {if (pkgs.includes(dep)) {offending.push(`${file}: ${dep}`)}}
}
}
expect(offending).toEqual([])
})
test('agent skills have frontmatter whose name matches the folder', () => {
const dir = path.join(root, 'docs/agent/skills')
const bad = readdirSync(dir).filter((name) => {
const text = read(`docs/agent/skills/${name}/SKILL.md`)
return !new RegExp(`^---\\nname: ${name}\\ndescription: .+\\n`, 'm').test(text)
})
expect(bad).toEqual([])
})
})
function srcFiles(dir = 'src'): string[] {
return readdirSync(path.join(root, dir)).flatMap((name) => {
const rel = path.join(dir, name)
return statSync(path.join(root, rel)).isDirectory() ? srcFiles(rel) : /\.tsx?$/.test(name) ? [rel] : []
})
}