Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(doctor): two false-positive/timeout fixes — drift walk skips node_modules; bare-tweet skips inline-code + cited lines (#1772)

sonlndv355fbc6947f7
diff --git a/src/commands/integrity.ts b/src/commands/integrity.ts
index c883c1b482..42bfdef3db 100644
--- a/src/commands/integrity.ts
+++ b/src/commands/integrity.ts
@@ -98,8 +98,17 @@ export function findBareTweetHits(compiledTruth: string, slug: string): BareTwee
}
// If the line already contains a tweet URL, it's cited — skip
if (URL_NEARBY_RE.test(line)) continue;
+ // If the line carries an explicit source citation (e.g.
+ // "[Source: X, @handle, 2026-05-28]"), it's already attributed — skip.
+ // Catches instructional/example lines in recipe docs that demonstrate
+ // the CORRECT citation format. (v0.42.x)
+ if (/\[\s*source:/i.test(line)) continue;
+ // Strip inline-code spans (`...`) before matching: phrases shown as
+ // inline-code templates in docs are examples, not bare claims. The
+ // fenced-code skip above only covers ``` blocks, not inline backticks.
+ const lineForMatch = line.replace(/`[^`]*`/g, '');
for (const re of BARE_TWEET_PHRASES) {
- const m = line.match(re);
+ const m = lineForMatch.match(re);
if (m) {
hits.push({ slug, line: i + 1, rawLine: line.trim(), phrase: m[0] });
break; // one finding per line is enough
diff --git a/src/core/multi-source-drift.ts b/src/core/multi-source-drift.ts
index 2064c48f41..e01f34ec4e 100644
--- a/src/core/multi-source-drift.ts
+++ b/src/core/multi-source-drift.ts
@@ -87,6 +87,11 @@ function walkMarkdownAndMdxFiles(
for (const entry of entries) {
if (truncated) return;
if (entry.startsWith('.')) continue;
+ // Skip heavy non-content dirs so the walk doesn't exhaust the time
+ // budget on dependency/build trees (node_modules can be 50k+ files
+ // with zero .md). These are never gbrain page sources.
+ if (entry === 'node_modules' || entry === 'dist' || entry === 'build' ||
+ entry === '.next' || entry === 'vendor' || entry === 'target') continue;
const full = join(d, entry);
let isDir = false;
try {
@@ -95,6 +100,9 @@ function walkMarkdownAndMdxFiles(
continue;
}
if (isDir) {
+ // Time check on directory descent too, so a deep dependency-free
+ // tree still respects the deadline even before any .md is found.
+ if (Date.now() >= deadlineMs) { truncated = true; return; }
walk(full);
continue;
}