Agent instructions: mandatory feature set (SEO, GEO, R2, Turnstile, forms) enforced by audits

- AGENT.md §0b: one table of everything every site must have (SEO meta/maps,
  JSON-LD, llms.txt + llms-full, Markdown, MCP, AI bots, R2, panel forms,
  Turnstile, consent, security, ops, system pages, zero hardcodes), the
  forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written
  JSON-LD, static SEO files, raw S3) and an `ipal-audit-skip:` escape hatch that
  needs a recorded client decision.
- ipal-audit: "missing: …" errors for every mandatory item and for plugin
  replacements; ipal-seo-check: runtime GEO checks (llms, Markdown, MCP,
  JSON-LD, AI bots, health). Both verified on bare and complete fixtures.
- Skills (setup, site, form, upgrade, audit, seo-check) and PROGRAMISTA.md
  wire the full set from step one; GEO is no longer "optional".
- Fix: createProxy({ markdown: true }) lets /md/... through — multilingual
  sites redirected /md/pl/x to /pl/md/pl/x, so the documented Markdown route
  never worked — and handles Accept: text/markdown.
- createContentHelpers({ markdownAlternate: true }) adds the text/markdown
  alternate link in generatePageMetadata.
- JSDoc/docs JSON-LD examples use JsonLdGraph; docs/CHANGELOG.md for 1.9.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-16 01:26:10 +02:00
co-authored by Claude Opus 5.5
parent ab854ef37a
commit d3e5efb9f8
23 changed files with 571 additions and 83 deletions
@@ -1,5 +1,7 @@
#!/usr/bin/env node
// ipal-seo-check — what Googlebot actually sees on a running site (Node 18+, no dependencies).
import { readFileSync } from 'node:fs'
// ipal-seo-check — what Googlebot and AI agents actually see on a running site (Node 18+, no dependencies).
// node seo-check.mjs <baseUrl> [--max 20]
// node seo-check.mjs http://localhost:3000 # after `pnpm build && pnpm start`
// node seo-check.mjs https://klient.pl --max 40 # production
@@ -14,6 +16,13 @@ const origin = args[0].replace(/\/$/, '')
const maxIdx = args.indexOf('--max')
const MAX = maxIdx >= 0 ? Number(args[maxIdx + 1]) || 20 : 20
const UA = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
// Client decisions recorded in AGENTS.md (AGENT.md §0b): `ipal-audit-skip: mcp, llms-full — reason`
let SKIP = []
try {
const line = readFileSync('AGENTS.md', 'utf8').split('\n').find((l) => /^[-* ]*ipal-audit-skip:/i.test(l))
if (line) SKIP = line.replace(/^[^:]*:/, '').split(/—| - /)[0].split(',').map((k) => k.trim()).filter(Boolean)
} catch {}
const skipped = (key) => SKIP.includes(key)
let errors = 0
let warnings = 0
@@ -89,7 +98,8 @@ for (let i = 0; sample.length < Math.min(MAX, urls.length); i++) {
const multiLocale = hasAlternates || byLocale.size > 1
const urlSet = new Set(urls.map(norm))
const titles = new Map()
const issues = { status: [], noHead: [], body: [], title: [], longTitle: [], desc: [], canonical: [], canonSelf: [], noindex: [], hreflang: [], xdefault: [], reciprocal: [], favicon: [] }
const issues = { status: [], noHead: [], body: [], title: [], longTitle: [], desc: [], canonical: [], canonSelf: [], noindex: [], hreflang: [], xdefault: [], reciprocal: [], favicon: [], jsonLd: [], mdAlt: [] }
const checkedPaths = []
for (const url of sample) {
let page
@@ -121,6 +131,9 @@ for (const url of sample) {
if (/noindex/i.test(robotsMeta)) issues.noindex.push(url)
if (!/<link[^>]+rel="(?:shortcut )?icon"/i.test(head)) issues.favicon.push(url)
if (!/application\/ld\+json/i.test(html)) issues.jsonLd.push(url)
if (!/<link[^>]+type="text\/markdown"/i.test(head)) issues.mdAlt.push(url)
checkedPaths.push(new URL(url).pathname)
if (multiLocale) {
const alts = tags(head, /<link[^>]+hreflang="[^"]+"[^>]*>/gi).map((t) => ({ lang: attr(t, 'hreflang'), href: attr(t, 'href') }))
@@ -148,6 +161,8 @@ if (issues.desc.length) report('WARNING', 'missing meta description', 'fill SEO
if (dupTitles.length) report('WARNING', 'duplicate titles', 'unique meta titles per page', dupTitles)
if (issues.longTitle.length) report('WARNING', 'titles over 65 chars (truncated in results)', 'shorten in the SEO tab', issues.longTitle)
if (issues.favicon.length) report('WARNING', 'no favicon link in head', 'buildIconsMetadata(settings.favicon) in root generateMetadata', issues.favicon.slice(0, 3))
if (!skipped('jsonld') && issues.jsonLd.length) report('ERROR', 'no JSON-LD structured data', '<JsonLdGraph> WebSite + Organization in [locale]/layout.tsx (AGENT.md §0b.4)', issues.jsonLd.slice(0, 5))
if (!skipped('markdown') && issues.mdAlt.length) report('WARNING', 'no text/markdown alternate link in head', 'createContentHelpers({ markdownAlternate: true }) (AGENT.md §0b.6)', issues.mdAlt.slice(0, 3))
// --- 5. 404 ---------------------------------------------------------------
const firstLocale = [...byLocale.keys()].find((l) => l && l.length <= 5) ?? ''
@@ -157,9 +172,44 @@ for (const path of [`/${firstLocale ? firstLocale + '/' : ''}ipal-seo-check-${Da
else if (r.res.status !== 404 && !(r.res.status >= 300 && r.res.status < 400)) report('WARNING', `unknown URL returns ${r.res.status}`, 'expected 404')
}
// --- 6. llms.txt (info-level) -------------------------------------------------
const llms = await get('/llms.txt', { body: false }).catch(() => null)
if (!llms || llms.res.status !== 200) report('WARNING', 'no /llms.txt', 'createLlmsTxtRoute (seo.md) — AI-readable site summary')
// --- 6. GEO: llms, Markdown, MCP, AI bots (AGENT.md §0b.5–8) ---------------
const ok = async (path, opts) => { try { return await get(path, opts) } catch { return null } }
if (!skipped('llms')) {
const llms = await ok('/llms.txt')
if (!llms || llms.res.status !== 200) report('ERROR', `/llms.txt → ${llms?.res.status ?? 'unreachable'}`, 'createLlmsTxtRoute (seo.md)')
else if (!/^#\s+\S/m.test(llms.text)) report('WARNING', '/llms.txt has no "# Site name" heading', 'fill Site Settings → name/description')
}
if (!skipped('llms-full')) {
const full = await ok('/llms-full.txt', { body: false })
if (!full || full.res.status !== 200) report('ERROR', `/llms-full.txt → ${full?.res.status ?? 'unreachable'}`, 'createLlmsTxtRoute({ full: true })')
}
if (!skipped('markdown') && checkedPaths.length) {
const path = checkedPaths[0]
const md = await ok(`/md${path === '/' ? '' : path}`)
const type = md?.res.headers.get('content-type') ?? ''
if (!md || md.res.status !== 200 || !/markdown/i.test(type)) report('ERROR', `Markdown version /md${path} → ${md?.res.status ?? 'unreachable'} ${type}`, 'src/app/md/[locale]/[[...slug]]/route.ts (content.md)')
}
if (!skipped('mcp')) {
let mcpOk = false
let tools = []
try {
const rpc = (body) => fetch(origin + '/api/mcp', { body: JSON.stringify(body), headers: { 'content-type': 'application/json' }, method: 'POST' }).then((r) => (r.ok ? r.json() : null))
const init = await rpc({ id: 1, jsonrpc: '2.0', method: 'initialize', params: { protocolVersion: '2025-06-18' } })
mcpOk = Boolean(init?.result?.serverInfo)
tools = ((await rpc({ id: 2, jsonrpc: '2.0', method: 'tools/list' }))?.result?.tools ?? []).map((t) => t.name)
} catch {}
if (!mcpOk) report('ERROR', 'MCP server /api/mcp not answering initialize', 'createMcpRoute (mcp.md) — public, AI browses the site')
else if (!tools.includes('list_pages')) report('WARNING', 'MCP without list_pages / get_site_info', 'update @intecion/ipal-kit to ≥ 1.9.0')
}
if (!skipped('aibots') && robots.res.status === 200) {
const groups = robots.text.split(/(?=^user-agent:)/im)
const blocked = ['ClaudeBot', 'GPTBot', 'PerplexityBot', 'OAI-SearchBot'].filter((bot) =>
groups.some((g) => new RegExp(`^user-agent:.*\\b${bot}\\b`, 'im').test(g) && /^disallow:\s*\/\s*$/im.test(g)),
)
if (blocked.length) report('WARNING', 'robots.txt blocks AI bots', 'aiBots: allow (default) — block only with the client decision in AGENTS.md', blocked)
}
const health = await ok('/api/health', { body: false })
if (!health || health.res.status !== 200) report('WARNING', `/api/health → ${health?.res.status ?? 'unreachable'}`, 'createHealthRoute (Coolify healthcheck)')
// --- output -------------------------------------------------------------
for (const f of findings) {