{"record":{"id":"dd43b460f81e779e","repo":"koala73/worldmonitor","slug":"stale-map-output-output-relativepath-join-and-stale-run-npm","errorCode":null,"errorMessage":"${stale.map((output) => output.relativePath).join(' and ')} stale — run npm run build:llms-full","messagePattern":"(.+?) stale — run npm run build:llms-full","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/build-llms-full.mjs","lineNumber":344,"sourceCode":"/**\n * Writes both agent files: the Comparisons section spliced into llms.txt and\n * the full corpus. One script owns both so the section cannot drift between\n * them (#7746). Both outputs are rendered before anything is written or\n * judged, so --check names every stale file at once and a render failure\n * never leaves the pair half-written. Returns one entry per file.\n */\nexport function writeLlmsFull({ rootDir = ROOT, check = false } = {}) {\n  const outputs = [\n    { relativePath: LLMS_TXT_PATH, next: withComparisonsSection(read(rootDir, LLMS_TXT_PATH)) },\n    { relativePath: OUTPUT_PATH, next: buildLlmsFullText({ rootDir }) },\n  ].map(({ relativePath, next }) => {\n    const path = join(rootDir, relativePath);\n    const current = existsSync(path) ? readFileSync(path, 'utf8') : null;\n    return { path, relativePath, next, changed: current !== next, bytes: Buffer.byteLength(next) };\n  });\n  const stale = outputs.filter((output) => output.changed);\n  if (check && stale.length > 0) {\n    throw new Error(`${stale.map((output) => output.relativePath).join(' and ')} stale — run npm run build:llms-full`);\n  }\n  for (const output of stale) writeFileSync(output.path, output.next);\n  return { files: outputs.map(({ relativePath, changed, bytes }) => ({ path: relativePath, changed, bytes })) };\n}\n\nif (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {\n  const check = process.argv.includes('--check');\n  try {\n    const result = writeLlmsFull({ check });\n    for (const file of result.files) {\n      const kb = (file.bytes / 1000).toFixed(1);\n      process.stdout.write(\n        `${file.changed ? 'Wrote' : 'Unchanged'} ${file.path} (${kb} KB)\\n`,\n      );\n    }\n  } catch (err) {\n    process.stderr.write(`${err.stack || err.message}\\n`);\n    process.exit(1);","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/scripts/build-llms-full.mjs#L326-L362","documentation":"writeLlmsFull with check=true (CI/check mode) regenerates all output files and compares them to what is on disk. If any generated output differs from the committed file, it throws listing the stale relative paths, telling you to run npm run build:llms-full. It prevents shipping docs that do not match the generator.","triggerScenarios":"Running the build in check mode (e.g. npm run build:llms-full -- --check in CI) after llms.txt or related outputs were edited manually, or after generator/data changes without re-running the build to refresh the outputs.","commonSituations":"Hand-editing public/llms.txt without regenerating; a PR updated generator logic or OpenAPI bytes but forgot to commit regenerated files; CI runs check mode on a branch with stale committed artifacts.","solutions":["Run npm run build:llms-full to regenerate and rewrite the stale files.","Commit the regenerated outputs to the branch.","Avoid hand-editing generated files; change the generator or its inputs instead.","Re-run the check command to confirm it passes before pushing."],"exampleFix":"// before\n# public/llms.txt hand-edited, generator output differs\n// after\nnpm run build:llms-full && git add public/llms.txt && git commit","handlingStrategy":"validation","validationCode":"const next = buildLlmsFullText();\nif (next !== readFileSync('public/llms.txt', 'utf8')) throw new Error('llms.txt stale — run npm run build:llms-full');","typeGuard":null,"tryCatchPattern":"try { writeLlmsFull({ check: true }); } catch (e) { console.error(e.message); process.exit(1); }","preventionTips":["Always run npm run build:llms-full after touching llms outputs or the generator.","Commit regenerated artifacts in the same PR as generator changes.","Never hand-edit generated files."],"tags":["build","ci","stale-artifacts"],"backgroundTag":"checksum-mismatch","analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-09-15T16:44:39.439Z","contentChangedAt":"2026-09-15T16:44:39.439Z","schemaVersion":2},"datasetVersion":"2026-09-15T18:17:12.389Z"}