From 0a4a690db088b86bd062f07ec20e6d98c7744569 Mon Sep 17 00:00:00 2001 From: Shubh Porwal Date: Sun, 11 Jan 2026 14:27:25 +0530 Subject: [PATCH] fix: respect local config for autoupdate setting --- packages/opencode/src/cli/upgrade.ts | 2 +- packages/opencode/test/config/config.test.ts | 51 ++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/upgrade.ts b/packages/opencode/src/cli/upgrade.ts index 2d46ae39fa2f..87577e298b61 100644 --- a/packages/opencode/src/cli/upgrade.ts +++ b/packages/opencode/src/cli/upgrade.ts @@ -4,7 +4,7 @@ import { Flag } from "@/flag/flag" import { Installation } from "@/installation" export async function upgrade() { - const config = await Config.global() + const config = await Config.get() const method = await Installation.method() const latest = await Installation.latest(method).catch(() => {}) if (!latest) return diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index 087eb0c628cf..94b3c13d35fb 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -1170,6 +1170,57 @@ describe("getPluginName", () => { }) }) +test("project config can override autoupdate setting", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + // base config has autoupdate enabled + await Bun.write( + path.join(dir, "opencode.jsonc"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + autoupdate: true, + }), + ) + // project config disables autoupdate + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + autoupdate: false, + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + expect(config.autoupdate).toBe(false) + }, + }) +}) + +test("project config can set autoupdate to notify", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + autoupdate: "notify", + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + expect(config.autoupdate).toBe("notify") + }, + }) +}) + describe("deduplicatePlugins", () => { test("removes duplicates keeping higher priority (later entries)", () => { const plugins = ["global-plugin@1.0.0", "shared-plugin@1.0.0", "local-plugin@2.0.0", "shared-plugin@2.0.0"]