From 853f518223ae18aa412188569abde9ac72e7aecb Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Sun, 26 Jul 2026 23:47:08 -0700 Subject: [PATCH] chore: resync sync-brand-numbers.mjs with the source copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script is vendored byte-for-byte from BlockRunAI/blockrun:brand/, and this copy had fallen 24 lines behind it. Three fixes landed upstream after the initial distribution and never reached here: - skip nested repos. Walking into a submodule rewrites its markers from the WRONG repo's snapshot and reports drift that belongs to its CI. - do not follow symlinked directories. blockrun's docs/ -> awesome-blockrun/docs is the live case; a link pointing at an ancestor would also recurse forever. - scan .txt, for llms.txt — the file agents read to learn what BlockRun serves, which could not be bound at all before. None of this was detectable: nothing compared the copies. blockrun CI gains a job that does, in the same shape as its existing clawrouter-install-sync guard. --- scripts/sync-brand-numbers.mjs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/sync-brand-numbers.mjs b/scripts/sync-brand-numbers.mjs index 4feb5ced..c3717f41 100644 --- a/scripts/sync-brand-numbers.mjs +++ b/scripts/sync-brand-numbers.mjs @@ -19,7 +19,7 @@ * and wrap the WHOLE token, so a badge URL, its alt text and the prose number * can all regenerate from one key. */ -import { readFileSync, writeFileSync, readdirSync, statSync } from "node:fs"; +import { existsSync, lstatSync, readFileSync, writeFileSync, readdirSync } from "node:fs"; import { join, relative, extname } from "node:path"; const ROOT = process.cwd(); @@ -43,7 +43,10 @@ const SKIP_DIRS = new Set([ "node_modules", ".git", "dist", "build", "out", ".next", "coverage", "vendor", "target", "__pycache__", ".venv", "venv", ]); -const TEXT_EXT = new Set([".md", ".mdx"]); +// .txt is here for llms.txt, which is a first-class marketing surface: it is +// what agents read to find out what BlockRun serves. Scanning other .txt files +// costs a read and changes nothing — only files with markers are ever written. +const TEXT_EXT = new Set([".md", ".mdx", ".txt"]); /* ── 1. numbers ──────────────────────────────────────────────────────────── */ @@ -194,9 +197,20 @@ function* walk(dir) { for (const name of readdirSync(dir)) { if (SKIP_DIRS.has(name)) continue; const p = join(dir, name); - const s = statSync(p); - if (s.isDirectory()) yield* walk(p); - else if (TEXT_EXT.has(extname(name))) yield p; + // lstat, not stat: a symlinked directory is reached by its real path or not + // at all. blockrun's docs/ -> awesome-blockrun/docs is exactly the case that + // matters — following it would edit a submodule's files behind the skip + // below, and a link pointing at an ancestor would recurse forever. + const s = lstatSync(p); + if (s.isSymbolicLink()) continue; + if (s.isDirectory()) { + // A nested repo is a submodule or vendored checkout: it carries its own + // brand-numbers.json and syncs itself. Rewriting its markers from THIS + // repo's snapshot would dirty a submodule nobody asked us to touch, and + // would report drift that belongs to another repo's CI. + if (existsSync(join(p, ".git"))) continue; + yield* walk(p); + } else if (TEXT_EXT.has(extname(name))) yield p; } }