From 49c7d4dbf96e330c9c4f4dd8bd0b60677a8c11e3 Mon Sep 17 00:00:00 2001 From: Sisyphus Date: Sat, 18 Apr 2026 14:04:45 +0900 Subject: [PATCH] chore(shared): add EXCLUDED_DIRS constant for recursive FS scans Introduces a frozen Set of directory basenames (node_modules, .git, dist, build, .next, .sisyphus, .omx, .turbo, coverage, out, .cache, .vscode-test, target, .local-ignore) that callers performing recursive filesystem scans should skip. This is shared infrastructure for upcoming fixes in rules-injector, command-discovery, and claude-code-command-loader that currently descend into node_modules and other junk directories, causing slow plugin init and slow edit loops when the plugin is launched in-tree. --- src/shared/excluded-dirs.test.ts | 50 ++++++++++++++++++++++++++++++++ src/shared/excluded-dirs.ts | 18 ++++++++++++ src/shared/index.ts | 1 + 3 files changed, 69 insertions(+) create mode 100644 src/shared/excluded-dirs.test.ts create mode 100644 src/shared/excluded-dirs.ts diff --git a/src/shared/excluded-dirs.test.ts b/src/shared/excluded-dirs.test.ts new file mode 100644 index 000000000..21a488907 --- /dev/null +++ b/src/shared/excluded-dirs.test.ts @@ -0,0 +1,50 @@ +import { describe, expect, test } from "bun:test" +import { EXCLUDED_DIRS } from "./excluded-dirs" +import { EXCLUDED_DIRS as EXCLUDED_DIRS_FROM_BARREL } from "." + +describe("EXCLUDED_DIRS", () => { + test("contains the well-known junk directories we never want to recurse into", () => { + // given + const expected = [ + "node_modules", + ".git", + "dist", + "build", + ".next", + ".sisyphus", + ".omx", + ".turbo", + "coverage", + "out", + ".cache", + ".vscode-test", + "target", + ".local-ignore", + ] + + // when / then + for (const name of expected) { + expect(EXCLUDED_DIRS.has(name)).toBe(true) + } + }) + + test("does not contain commonly-wanted project directories", () => { + // given + const shouldBeAllowed = ["src", "lib", "tests", "test", "docs", ".github", ".cursor", ".claude", ".opencode"] + + // when / then + for (const name of shouldBeAllowed) { + expect(EXCLUDED_DIRS.has(name)).toBe(false) + } + }) + + test("is frozen so consumers cannot mutate shared state", () => { + // given / when / then + expect(Object.isFrozen(EXCLUDED_DIRS)).toBe(true) + }) + + test("is re-exported from the shared barrel", () => { + // given / when / then + expect(EXCLUDED_DIRS_FROM_BARREL).toBe(EXCLUDED_DIRS) + }) +}) diff --git a/src/shared/excluded-dirs.ts b/src/shared/excluded-dirs.ts new file mode 100644 index 000000000..059a01406 --- /dev/null +++ b/src/shared/excluded-dirs.ts @@ -0,0 +1,18 @@ +const EXCLUDED_DIR_NAMES = [ + "node_modules", + ".git", + "dist", + "build", + ".next", + ".sisyphus", + ".omx", + ".turbo", + "coverage", + "out", + ".cache", + ".vscode-test", + "target", + ".local-ignore", +] as const + +export const EXCLUDED_DIRS: ReadonlySet = Object.freeze(new Set(EXCLUDED_DIR_NAMES)) diff --git a/src/shared/index.ts b/src/shared/index.ts index 140f88192..e99234c33 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -79,3 +79,4 @@ export * from "./log-legacy-plugin-startup-warning" export * from "./task-system-enabled" export * from "./parse-tools-config" export { parseModelString } from "./model-string-parser" +export { EXCLUDED_DIRS } from "./excluded-dirs"