Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
refactor: consolidate the dot-dir/SKIP_DIRS check into shouldSkipDir
Alex Matthews9c79232c6c43
diff --git a/src/graph/scopes.ts b/src/graph/scopes.tsindex 68dd23d1..b4e658bd 100644--- a/src/graph/scopes.ts+++ b/src/graph/scopes.ts@@ -23,7 +23,7 @@*/import { existsSync, readdirSync, readFileSync, type Dirent } from "node:fs";import { join, resolve } from "node:path";-import { SKIP_DIRS, walkDir } from "../ingest/fs.js";+import { shouldSkipDir, walkDir } from "../ingest/fs.js";import { relPosix } from "../util/paths.js";import type { GraphV1, ScopeV1 } from "./types.js";@@ -327,13 +327,7 @@ export function discoverWorkspaceChildren(root: string): string[] {return [];}return entries- .filter(- (e) =>- e.isDirectory() &&- !e.name.startsWith(".") &&- !SKIP_DIRS.has(e.name) &&- existsSync(join(absRoot, e.name, ".git")),- )+ .filter((e) => e.isDirectory() && !shouldSkipDir(e.name) && existsSync(join(absRoot, e.name, ".git"))).map((e) => e.name);}diff --git a/src/ingest/fs.ts b/src/ingest/fs.tsindex 466e90fa..c9b7c444 100644--- a/src/ingest/fs.ts+++ b/src/ingest/fs.ts@@ -21,6 +21,22 @@ export const SKIP_DIRS = new Set([/** Files above this size are generated/vendored in practice, not hand-written code. */export const MAX_FILE_BYTES = 1_000_000;+/**+ * Whether a directory named `name` should be skipped when walking a repo tree:+ * any dot-prefixed directory (`.git`, `.github`, `.vscode`, ...) or one of+ * {@link SKIP_DIRS}. The single source of truth for "is this dir source" —+ * `skippedPath` and `walkFilesystem` below and the git-child discovery in+ * `graph/scopes.ts` share it, so they can never independently drift on what+ * counts as skippable.+ *+ * KNOWN LIMITATION: a dot-directory is skipped WHOLESALE — there is no+ * override for a dot-prefixed directory. A repo that keeps real,+ * hand-written source under one is out of scope.+ */+export function shouldSkipDir(name: string): boolean {+ return name.startsWith(".") || SKIP_DIRS.has(name);+}+/*** Recursively list all files under a directory. Skips dot-directories,* dependency/build directories (node_modules, dist, …), and files over 1 MB.@@ -67,20 +83,22 @@ function gitVisibleFiles(dir: string): string[] | null {return out;}+/** A path (git-relative, either separator) is skipped when any of its+ * segments is a skippable directory name — the final segment doubles as the+ * dot-FILE check (`.eslintrc.js` and friends are not source either). */function skippedPath(path: string): boolean {- const segments = path.replace(/\\/g, "/").split("/");- return segments.some((segment) => segment.startsWith(".") || SKIP_DIRS.has(segment));+ return path.replace(/\\/g, "/").split("/").some(shouldSkipDir);}function walkFilesystem(dir: string): string[] {const out: string[] = [];for (const entry of readdirSync(dir, { withFileTypes: true })) {- if (entry.name.startsWith(".")) continue;const full = join(dir, entry.name);if (entry.isDirectory()) {- if (SKIP_DIRS.has(entry.name)) continue;+ if (shouldSkipDir(entry.name)) continue;out.push(...walkFilesystem(full));} else if (entry.isFile()) {+ if (entry.name.startsWith(".")) continue; // dot-files are not source eithertry {if (statSync(full).size > MAX_FILE_BYTES) continue;} catch {