koala73/worldmonitor · error · Error
${LLMS_TXT_PATH} carries ${headings.length} "${COMPARISONS_H
Error message
${LLMS_TXT_PATH} carries ${headings.length} "${COMPARISONS_HEADING}" headings; keep exactly one What it means
withComparisonsSection injects the Comparisons section into llms.txt. It scans for the exact markdown heading '^## Comparisons$'; if the text already contains more than one such heading, splicing would be ambiguous, so it throws instructing you to keep exactly one.
Solutions
- Open public/llms.txt and remove the duplicate '## Comparisons' heading(s), keeping one (or none — the function will insert it).
- Prefer regenerating: delete the hand-added copies and run npm run build:llms-full so the function injects the canonical block.
- Check the input source for accidental duplication from a merge or earlier script run.
Example fix
// before (llms.txt) ## Comparisons ... ## Comparisons ... // after ## Comparisons ... (single instance)
Defensive patterns
Strategy: validation
Validate before calling
const n = [...text.matchAll(/^## Comparisons$/gm)].length;
if (n > 1) throw new Error(`duplicate ## Comparisons headings: ${n}`); Try / catch
try { out = withComparisonsSection(txt); } catch (e) { console.error('Fix llms.txt:', e.message); process.exit(1); } Prevention
- Never hand-paste the Comparisons block into llms.txt.
- Regenerate with npm run build:llms-full instead of editing.
- Watch for merge conflicts around the section.
When it happens
Trigger: Calling withComparisonsSection (or the build-llms-full pipeline) on an llms.txt that already contains two or more literal '## Comparisons' H2 headings — typically because the section was manually pasted in or a previous injection was duplicated.
Common situations: Hand-editing public/llms.txt and copy-pasting the Comparisons block twice; merging branches that both added the section; re-running an older script version that appended instead of replacing.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- needs a summary for the llms.txt Comparisons section
- ${LLMS_TXT_PATH} must carry a "${COMPARISONS_ANCHOR_HEADING}
- llms.txt must contain exactly one OpenAPI YAML byte-size ann
- is missing methodology prose
- is missing following prose
AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15).
Data as JSON: /api/errors/335a2bef968cf184.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/build-llms-full.mjs:275
'## Source provider directory',
'',
`World Monitor publishes ${catalog.length} named providers across ${pages.length} source catalog pages. Each linked page contains provider names, source hosts, origins and coverage in static HTML; no search or JavaScript is required.`,
'',
...pages.map((page) => `- [${page.name}](${SITE_ORIGIN}${page.path}): ${page.providers.length} providers.`),
].join('\n');
}
/**
* Splice the generated Comparisons section into the hand-maintained
* llms.txt: replace the existing section in place, or insert it ahead of
* Live Instances the first time. Idempotent, so --check can diff it.
*/
export function withComparisonsSection(llmsTxt) {
const text = String(llmsTxt);
const block = renderComparisons();
const headings = [...text.matchAll(/^## Comparisons$/gm)];
if (headings.length > 1) {
throw new Error(`${LLMS_TXT_PATH} carries ${headings.length} "${COMPARISONS_HEADING}" headings; keep exactly one`);
}
if (headings.length === 1) {
const start = headings[0].index;
const nextHeading = text.indexOf('\n## ', start + COMPARISONS_HEADING.length);
const end = nextHeading === -1 ? text.length : nextHeading;
return `${text.slice(0, start)}${block}\n${text.slice(end)}`;
}
const anchor = `\n${COMPARISONS_ANCHOR_HEADING}\n`;
const at = text.indexOf(anchor);
if (at === -1) {
throw new Error(`${LLMS_TXT_PATH} must carry a "${COMPARISONS_ANCHOR_HEADING}" heading to anchor the Comparisons section`);
}
return `${text.slice(0, at + 1)}${block}\n${text.slice(at)}`;
}
export function buildLlmsFullText({ rootDir = ROOT } = {}) {
const existing = existsSync(join(rootDir, OUTPUT_PATH))
? read(rootDir, OUTPUT_PATH)View on GitHub (pinned to 7d06c8633d)