From 44bbc7972051c3da60ad4c190b2f28a68c973afd Mon Sep 17 00:00:00 2001 From: ZY-Yim Date: Tue, 7 Apr 2026 11:19:13 +0800 Subject: [PATCH 1/4] feat(config): add OPENCODE_DISABLE_GLOBAL_CONFIG flag to skip global config loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When embedding OpenCode in a service (e.g. via `opencode serve`), the host application typically provides all configuration through `OPENCODE_CONFIG_CONTENT`. Loading global config files from `~/.config/opencode/` can cause unexpected behavior by merging unrelated user-level settings. This adds `OPENCODE_DISABLE_GLOBAL_CONFIG` environment variable that, when set to `1` or `true`, makes `loadGlobal()` return an empty config object, skipping all files under the global config directory (`config.json`, `opencode.json`, `opencode.jsonc`). This flag only affects global config — project-level `.opencode/` directories, `OPENCODE_CONFIG`, and `OPENCODE_CONFIG_CONTENT` continue to load normally. --- packages/opencode/src/config/config.ts | 1 + packages/opencode/src/flag/flag.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index b11ae83192ce..a333c607cf91 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -1219,6 +1219,7 @@ export namespace Config { }) const loadGlobal = Effect.fnUntraced(function* () { + if (Flag.OPENCODE_DISABLE_GLOBAL_CONFIG) return {} as Info let result: Info = pipe( {}, mergeDeep(yield* loadFile(path.join(Global.Path.config, "config.json"))), diff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.ts index 739009502b17..b556a507cb80 100644 --- a/packages/opencode/src/flag/flag.ts +++ b/packages/opencode/src/flag/flag.ts @@ -16,6 +16,7 @@ export namespace Flag { export const OPENCODE_GIT_BASH_PATH = process.env["OPENCODE_GIT_BASH_PATH"] export const OPENCODE_CONFIG = process.env["OPENCODE_CONFIG"] export declare const OPENCODE_PURE: boolean + export declare const OPENCODE_DISABLE_GLOBAL_CONFIG: boolean export declare const OPENCODE_TUI_CONFIG: string | undefined export declare const OPENCODE_CONFIG_DIR: string | undefined export declare const OPENCODE_PLUGIN_META_FILE: string | undefined @@ -133,6 +134,17 @@ Object.defineProperty(Flag, "OPENCODE_PURE", { configurable: false, }) +// Dynamic getter for OPENCODE_DISABLE_GLOBAL_CONFIG +// This must be evaluated at access time, not module load time, +// because external tooling may set this env var at runtime +Object.defineProperty(Flag, "OPENCODE_DISABLE_GLOBAL_CONFIG", { + get() { + return truthy("OPENCODE_DISABLE_GLOBAL_CONFIG") + }, + enumerable: true, + configurable: false, +}) + // Dynamic getter for OPENCODE_PLUGIN_META_FILE // This must be evaluated at access time, not module load time, // because tests and external tooling may set this env var at runtime From ba6e3721b84b17b40331b517b2ff431e60baeefb Mon Sep 17 00:00:00 2001 From: ZY-Yim Date: Thu, 9 Apr 2026 16:03:53 +0800 Subject: [PATCH 2/4] feat(config): also skip global config directory in ConfigPaths.directories When OPENCODE_DISABLE_GLOBAL_CONFIG is set, exclude Global.Path.config (~/.config/opencode/) from the directories list. This prevents scanning global agents, skills, commands, and plugins when global config is disabled. --- packages/opencode/src/config/paths.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/config/paths.ts b/packages/opencode/src/config/paths.ts index 82ccf3945fcd..c8a32b7b8752 100644 --- a/packages/opencode/src/config/paths.ts +++ b/packages/opencode/src/config/paths.ts @@ -14,7 +14,7 @@ export namespace ConfigPaths { export async function directories(directory: string, worktree: string) { return [ - Global.Path.config, + ...(Flag.OPENCODE_DISABLE_GLOBAL_CONFIG ? [] : [Global.Path.config]), ...(!Flag.OPENCODE_DISABLE_PROJECT_CONFIG ? await Array.fromAsync( Filesystem.up({ From 67ab7b879140ae4516285be25773229eaa304946 Mon Sep 17 00:00:00 2001 From: ZY-Yim Date: Thu, 9 Apr 2026 16:59:45 +0800 Subject: [PATCH 3/4] ci: retry From c1be3c5007708a53a6f8291b09ced335c4a1f92e Mon Sep 17 00:00:00 2001 From: ZY-Yim Date: Sat, 25 Apr 2026 14:41:24 +0800 Subject: [PATCH 4/4] ci: retry