summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-11-11 17:27:34 -0800
committerGitHub <[email protected]>2025-11-11 19:27:34 -0600
commitc07d6487a85420b13832caef258bdd1d6550af33 (patch)
treed3d7b0a37729624f0f21375b57a5741b8006a1c6
parent9990e84d372cd4572c91f3f529e7b1f21b8f0c40 (diff)
downloadopencode-c07d6487a85420b13832caef258bdd1d6550af33.tar.gz
opencode-c07d6487a85420b13832caef258bdd1d6550af33.zip
fix config ordering (#4228)
-rw-r--r--packages/opencode/src/config/config.ts28
1 files changed, 16 insertions, 12 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index 8823c866e..e6bed238f 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -24,12 +24,6 @@ export namespace Config {
export const state = Instance.state(async () => {
const auth = await Auth.all()
let result = await global()
- for (const file of ["opencode.jsonc", "opencode.json"]) {
- const found = await Filesystem.findUp(file, Instance.directory, Instance.worktree)
- for (const resolved of found.toReversed()) {
- result = mergeDeep(result, await loadFile(resolved))
- }
- }
// Override with custom config if provided
if (Flag.OPENCODE_CONFIG) {
@@ -37,6 +31,13 @@ export namespace Config {
log.debug("loaded custom config", { path: Flag.OPENCODE_CONFIG })
}
+ for (const file of ["opencode.jsonc", "opencode.json"]) {
+ const found = await Filesystem.findUp(file, Instance.directory, Instance.worktree)
+ for (const resolved of found.toReversed()) {
+ result = mergeDeep(result, await loadFile(resolved))
+ }
+ }
+
if (Flag.OPENCODE_CONFIG_CONTENT) {
result = mergeDeep(result, JSON.parse(Flag.OPENCODE_CONFIG_CONTENT))
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
@@ -74,12 +75,15 @@ export namespace Config {
for (const dir of directories) {
await assertValid(dir)
- for (const file of ["opencode.jsonc", "opencode.json"]) {
- result = mergeDeep(result, await loadFile(path.join(dir, file)))
- // to satisy the type checker
- result.agent ??= {}
- result.mode ??= {}
- result.plugin ??= []
+ if (dir.endsWith(".opencode")) {
+ for (const file of ["opencode.jsonc", "opencode.json"]) {
+ log.debug(`loading config from ${path.join(dir, file)}`)
+ result = mergeDeep(result, await loadFile(path.join(dir, file)))
+ // to satisy the type checker
+ result.agent ??= {}
+ result.mode ??= {}
+ result.plugin ??= []
+ }
}
promises.push(installDependencies(dir))