From c4f17a8d6ec5c22a3c2a8ef1b7ac436a75ff0291 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sun, 12 Jul 2026 15:49:16 -0400 Subject: [PATCH] fix(#2152): accept a homedir option in readGsd(Effective|Global)ModelOverrides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit readGsdEffectiveModelOverrides resolved ~/.gsd/defaults.json via os.homedir() with no seam, so a test asserting project-only overrides could not isolate the global file. Add an optional { homedir } option (defaults to os.homedir()) to readGsdGlobalModelOverrides and readGsdEffectiveModelOverrides — the same dependency-injection shape the sibling warnIfStaleBake already uses. Backward- compatible: existing callers pass no option and behave identically. Closes #2152 --- bin/install.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/install.js b/bin/install.js index 3f6c1a5b8..7b6c7e385 100755 --- a/bin/install.js +++ b/bin/install.js @@ -1139,9 +1139,10 @@ function writeSettings(settingsPath, settings) { * Used by Codex TOML and OpenCode agent file generators to embed per-agent * model assignments so that model_overrides is respected on non-Claude runtimes (#2256). */ -function readGsdGlobalModelOverrides() { +function readGsdGlobalModelOverrides(options = {}) { try { - const defaultsPath = path.join(os.homedir(), '.gsd', 'defaults.json'); + const home = options.homedir ? options.homedir() : os.homedir(); + const defaultsPath = path.join(home, '.gsd', 'defaults.json'); if (!fs.existsSync(defaultsPath)) return null; const raw = fs.readFileSync(defaultsPath, 'utf-8'); const parsed = JSON.parse(raw); @@ -1178,8 +1179,8 @@ function readGsdGlobalModelOverrides() { * Returns a plain `{ agentName: modelId }` object, or `null` when neither * source defines `model_overrides`. */ -function readGsdEffectiveModelOverrides(targetDir = null) { - const global = readGsdGlobalModelOverrides(); +function readGsdEffectiveModelOverrides(targetDir = null, options = {}) { + const global = readGsdGlobalModelOverrides(options); let projectOverrides = null; if (targetDir) {