Skip to content

Commit 9fba8a1

Browse files
committed
Remove duplicate code in config.ts
1 parent ef3d2ab commit 9fba8a1

File tree

1 file changed

+3
-38
lines changed

1 file changed

+3
-38
lines changed

packages/opencode/src/config/config.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,10 @@ export const state = Instance.state(async () => {
9191
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
9292
}
9393

94-
// Load remote/well-known config first as the base layer (lowest precedence)
95-
// This allows organizations to provide default configs that users can override
96-
let result: Info = {}
97-
for (const [key, value] of Object.entries(auth)) {
98-
if (value.type === "wellknown") {
99-
process.env[value.key] = value.token
100-
log.debug("fetching remote config", { url: `${key}/.well-known/opencode` })
101-
const response = await fetch(`${key}/.well-known/opencode`)
102-
if (!response.ok) {
103-
throw new Error(`failed to fetch remote config from ${key}: ${response.status}`)
104-
}
105-
const wellknown = (await response.json()) as any
106-
const remoteConfig = wellknown.config ?? {}
107-
// Add $schema to prevent load() from trying to write back to a non-existent file
108-
if (!remoteConfig.$schema) remoteConfig.$schema = "https://opencode.ai/config.json"
109-
result = mergeConfigConcatArrays(
110-
result,
111-
await load(JSON.stringify(remoteConfig), `${key}/.well-known/opencode`),
112-
)
113-
log.debug("loaded remote config from well-known", { url: key })
114-
}
115-
}
116-
11794
// Global user config overrides remote config
118-
result = mergeConfigConcatArrays(result, await global())
95+
const globalResult = await global()
96+
result = mergeConfigConcatArrays(result, globalResult.config)
97+
allUnknownKeybinds.push(...globalResult.unknownKeybinds)
11998

12099
// Custom config path overrides global
121100
if (Flag.OPENCODE_CONFIG) {
@@ -140,20 +119,6 @@ export const state = Instance.state(async () => {
140119
result = mergeConfigConcatArrays(result, JSON.parse(Flag.OPENCODE_CONFIG_CONTENT))
141120
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
142121
}
143-
144-
<<<<<<< HEAD
145-
for (const [key, value] of Object.entries(auth)) {
146-
if (value.type === "wellknown") {
147-
process.env[value.key] = value.token
148-
const wellknown = (await fetch(`${key}/.well-known/opencode`).then((x) => x.json())) as any
149-
const loaded = await load(JSON.stringify(wellknown.config ?? {}), process.cwd())
150-
result = mergeConfigConcatArrays(result, loaded.config)
151-
allUnknownKeybinds.push(...loaded.unknownKeybinds)
152-
}
153-
}
154-
155-
=======
156-
>>>>>>> dev
157122
result.agent = result.agent || {}
158123
result.mode = result.mode || {}
159124
result.plugin = result.plugin || []

0 commit comments

Comments
 (0)