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(context): find co-changed files for a workspace inside a larger repo
KageBinary810a799d629f
diff --git a/ix-cli/src/cli/__tests__/history.test.ts b/ix-cli/src/cli/__tests__/history.test.tsindex f6049741..658187ba 100644--- a/ix-cli/src/cli/__tests__/history.test.ts+++ b/ix-cli/src/cli/__tests__/history.test.ts@@ -1,7 +1,7 @@// Copyright 2026 Ix Infrastructure Inc.import { execFileSync } from "node:child_process";-import { mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";@@ -103,6 +103,25 @@ describe("gitRunner", () => {expect(recentCommits(run, "a.ts").map((c) => c.subject)).toEqual(["fix: a handles b", "feat: add a"]);expect(coChangedFiles(run, "a.ts", new Set()).map((c) => [c.path, c.commits])).toEqual([["b.ts", 2]]);});++ it("finds co-changes for a workspace in a subdirectory of its repository", () => {+ // `git log --name-only` prints paths from the repository's top level, while+ // the target path is relative to the workspace root git runs in.+ dir = mkdtempSync(join(tmpdir(), "ix-history-"));+ const git = (...args: string[]) => execFileSync("git", args, { cwd: dir, stdio: "ignore" });+ git("init", "-q");+ git("config", "user.email", "[email protected]");+ git("config", "user.name", "t");+ mkdirSync(join(dir, "packages", "web"), { recursive: true });+ for (const i of [0, 1]) {+ writeFileSync(join(dir, "packages", "web", "a.ts"), `// ${i}\n`);+ writeFileSync(join(dir, "packages", "web", "b.ts"), `// ${i}\n`);+ git("add", ".");+ git("commit", "-q", "-m", `change ${i}`);+ }+ const run = gitRunner(join(dir, "packages", "web"));+ expect(coChangedFiles(run, "a.ts", new Set()).map((c) => [c.path, c.commits])).toEqual([["b.ts", 2]]);+ });});describe("recent commits in a bundle", () => {diff --git a/ix-cli/src/cli/explain/history.ts b/ix-cli/src/cli/explain/history.tsindex 872f371f..0778be57 100644--- a/ix-cli/src/cli/explain/history.ts+++ b/ix-cli/src/cli/explain/history.ts@@ -87,8 +87,12 @@ export function coChangedFiles(limit = MAX_CO_CHANGES,): CoChange[] {// --full-diff lists every file each commit touched, not only `path`: one- // call instead of one `git show` per commit.- const out = git(["log", `-${HISTORY_DEPTH}`, "--format=@%h", "--name-only", "--full-diff", "--", path]);+ // call instead of one `git show` per commit. --relative prints them relative+ // to the workspace root git runs in, as `path` is: without it they were+ // relative to the repository's top level, so a workspace in a subdirectory+ // of its repo (`ix map packages/web`) never matched `path` and had no+ // co-changes at all.+ const out = git(["log", `-${HISTORY_DEPTH}`, "--format=@%h", "--name-only", "--relative", "--full-diff", "--", path]);if (!out) return [];const targetIsTest = isTestPath(path);const tally = new Map<string, CoChange>();