Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(search): stop treating committed build/ directories as build output
KageBinary384afec2b79c
diff --git a/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts b/ix-cli/src/cli/__tests__/resolver-definitions-first.test.tsindex b6d9c8ff..e895f333 100644--- a/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts+++ b/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts@@ -94,6 +94,13 @@ describe("resolver: code over non-code", () => {], "Prettier")).toBe("cls");});+ it("resolves a definition under a committed build/ directory, not its import", async () => {+ expect(await resolvedId([+ imp("import", "generate_metadata", "src/pip/_internal/distributions/sdist.py"),+ n("fn", "generate_metadata", "function", "src/pip/_internal/operations/build/metadata.py"),+ ], "generate_metadata")).toBe("fn");+ });+it("resolves the source definition over a copy in build output", async () => {expect(await resolvedId([n("dist", "createServer", "function", "dist/server.js"),diff --git a/ix-cli/src/cli/__tests__/search-definitions-first.test.ts b/ix-cli/src/cli/__tests__/search-definitions-first.test.tsindex 889dbf33..cc82ad35 100644--- a/ix-cli/src/cli/__tests__/search-definitions-first.test.ts+++ b/ix-cli/src/cli/__tests__/search-definitions-first.test.ts@@ -146,10 +146,9 @@ describe("search: code definitions rank above non-code and generated matches", (expect(ids(out).sort()).toEqual(["const", "css", "json"]);});- it("demotes definitions in dist/, build/, minified and fixture files below the source one", async () => {+ it("demotes definitions in dist/, minified and fixture files below the source one", async () => {dataset([n("dist", "code", "function", "dist/index.js", 100),- n("build", "code", "function", "build/lib/code.js", 100),n("min", "code", "function", "vendor/code.min.js", 100),n("fixture", "code", "function", "test-plugin/fixtures/plugin.js", 100),n("sample", "code", "function", "samples/plugin.js", 100),@@ -157,7 +156,20 @@ describe("search: code definitions rank above non-code and generated matches", (]);const out = await run("code");expect(ids(out)[0]).toBe("src");- expect(out.results).toHaveLength(6);+ expect(out.results).toHaveLength(5);+ });++ it("treats a committed build/ directory as source, ahead of an import of its definition", async () => {+ // `ix map` ingests tracked files only, so a `build/` directory in the graph+ // is committed source (VS Code's build/lib, Go's src/go/build, pip's+ // operations/build), not build output.+ dataset([+ imp("import", "generate_metadata", "src/pip/_internal/distributions/sdist.py"),+ n("fn", "generate_metadata", "function", "src/pip/_internal/operations/build/metadata.py", 100),+ ]);+ const out = await run("generate_metadata");+ expect(ids(out)).toEqual(["fn", "import"]);+ expect(out.results[0].tier).toBeLessThan(out.results[1].tier);});it("keeps a demoted row when it is the only match", async () => {diff --git a/ix-cli/src/cli/candidate-origin.ts b/ix-cli/src/cli/candidate-origin.tsindex 08d2a3bc..fa67ddd7 100644--- a/ix-cli/src/cli/candidate-origin.ts+++ b/ix-cli/src/cli/candidate-origin.ts@@ -18,7 +18,7 @@* as `config_entry`/`config`. For a term that looks like a code identifier* these are almost never what the caller meant.* - **generated** — copies of the definition in build output (`dist/`,- * `build/`, `*.min.js`, `*-output.*`) and stand-ins in fixtures and samples.+ * `*.min.js`, `*-output.*`) and stand-ins in fixtures and samples.** All three are demoted, never dropped: when nothing better matched they are* still the answer.@@ -43,9 +43,18 @@ const NON_CODE_EXTENSIONS = new Set([/** Kinds core-ingestion emits only for docs and config, never for code. */const NON_CODE_KINDS = new Set(["heading", "section", "config_entry", "config"]);-/** Build output and other derived copies of source. */+/**+ * Build output and other derived copies of source.+ *+ * Not `build/`. In a git repository `ix map` ingests only tracked files, so+ * gitignored build output never reaches the graph (and the filesystem walk+ * skips `build/` outright). What does arrive under `build/` is committed+ * source: Go's `src/go/build`, VS Code's `build/lib`, Next.js's+ * `packages/next/src/build`, pip's `operations/build`. Demoting it put every+ * import of a name ahead of its only definition.+ */const GENERATED_PATH_PATTERNS: RegExp[] = [- /(^|\/)(dist|build|generated|__generated__|node_modules)\//,+ /(^|\/)(dist|generated|__generated__|node_modules)\//,/\.min\.[a-z0-9]+$/,/\.bundle\.[a-z0-9]+$/,/[-_.]output\.[a-z0-9]+$/,diff --git a/ix-cli/src/cli/commands/search.ts b/ix-cli/src/cli/commands/search.tsindex 56fba737..0ac8f47b 100644--- a/ix-cli/src/cli/commands/search.ts+++ b/ix-cli/src/cli/commands/search.ts@@ -239,7 +239,7 @@ export function registerSearchCommand(program: Command): void {3. Exact name (any kind). Same-named rows that are not the code definitionrank here, behind it: imports of the name, CSS selectors, markdownheadings and JSON keys (for a code-like term), and copies in build- output (dist/, build/, *.min.js, *-output.*), fixtures and samples+ output (dist/, *.min.js, *-output.*), fixtures and samples4. Exact filename/module match5. Container-aware near match6. Fuzzy/incidental match — dropped when any of 1-5 matched