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(config): hand out a copy of the default config, not the shared object
KageBinary5ec18ae56710
diff --git a/ix-cli/src/cli/__tests__/config-workspace-boundary.test.ts b/ix-cli/src/cli/__tests__/config-workspace-boundary.test.tsindex 37c30b65..97e5b614 100644--- a/ix-cli/src/cli/__tests__/config-workspace-boundary.test.ts+++ b/ix-cli/src/cli/__tests__/config-workspace-boundary.test.ts@@ -1,8 +1,11 @@// Copyright 2026 Ix Infrastructure Inc.-import { describe, expect, it } from "vitest";+import { afterEach, describe, expect, it } from "vitest";+import { mkdtempSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";-import { selectWorkspaceForCwd, type WorkspaceConfig } from "../config.js";+import { loadConfig, selectWorkspaceForCwd, type WorkspaceConfig } from "../config.js";function workspace(rootPath: string, name = rootPath): WorkspaceConfig {return {@@ -35,3 +38,25 @@ describe("workspace path matching", () => {expect(selectWorkspaceForCwd([parent, child], "/work/app/packages/api/src")).toBe(child);});});++describe("loadConfig with no config file", () => {+ const saved = process.env.IX_HOME;+ afterEach(() => {+ if (saved === undefined) delete process.env.IX_HOME;+ else process.env.IX_HOME = saved;+ });++ // Callers edit what they get back and save it; `getOrCreateWorkspace` adds+ // its new workspace to it. Handing out the shared default made that+ // workspace appear in every later load in the process that found no file.+ it("hands out a fresh copy each time", () => {+ const dir = mkdtempSync(join(tmpdir(), "ix-config-default-"));+ try {+ process.env.IX_HOME = join(dir, "absent");+ loadConfig().workspaces = [workspace("/work/app", "app")];+ expect(loadConfig().workspaces).toBeUndefined();+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ });+});diff --git a/ix-cli/src/cli/config.ts b/ix-cli/src/cli/config.tsindex 1ede9772..f1c8047f 100644--- a/ix-cli/src/cli/config.ts+++ b/ix-cli/src/cli/config.ts@@ -155,7 +155,12 @@ const defaultConfig: IxConfig = {export function loadConfig(): IxConfig {const configPath = join(ixHome(), "config.yaml");- if (!existsSync(configPath)) return defaultConfig;+ // A copy, here and below: callers edit what they get back and save it.+ // Handing out the shared default let `getOrCreateWorkspace` write its new+ // workspace into it, so every later load in the process that found no+ // config file -- a fresh IX_HOME, a deleted file -- inherited workspaces+ // that were never in either.+ if (!existsSync(configPath)) return { ...defaultConfig };try {const raw = readFileSync(configPath, "utf-8");const parsed = parse(raw) as Partial<IxConfig>;@@ -168,7 +173,7 @@ export function loadConfig(): IxConfig {}return { ...defaultConfig, ...parsed };} catch {- return defaultConfig;+ return { ...defaultConfig };}}