mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-07 09:54:56 +01:00
fix config ordering (#4228)
This commit is contained in:
@@ -24,12 +24,6 @@ export namespace Config {
|
|||||||
export const state = Instance.state(async () => {
|
export const state = Instance.state(async () => {
|
||||||
const auth = await Auth.all()
|
const auth = await Auth.all()
|
||||||
let result = await global()
|
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
|
// Override with custom config if provided
|
||||||
if (Flag.OPENCODE_CONFIG) {
|
if (Flag.OPENCODE_CONFIG) {
|
||||||
@@ -37,6 +31,13 @@ export namespace Config {
|
|||||||
log.debug("loaded custom config", { path: Flag.OPENCODE_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) {
|
if (Flag.OPENCODE_CONFIG_CONTENT) {
|
||||||
result = mergeDeep(result, JSON.parse(Flag.OPENCODE_CONFIG_CONTENT))
|
result = mergeDeep(result, JSON.parse(Flag.OPENCODE_CONFIG_CONTENT))
|
||||||
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
||||||
@@ -74,12 +75,15 @@ export namespace Config {
|
|||||||
for (const dir of directories) {
|
for (const dir of directories) {
|
||||||
await assertValid(dir)
|
await assertValid(dir)
|
||||||
|
|
||||||
for (const file of ["opencode.jsonc", "opencode.json"]) {
|
if (dir.endsWith(".opencode")) {
|
||||||
result = mergeDeep(result, await loadFile(path.join(dir, file)))
|
for (const file of ["opencode.jsonc", "opencode.json"]) {
|
||||||
// to satisy the type checker
|
log.debug(`loading config from ${path.join(dir, file)}`)
|
||||||
result.agent ??= {}
|
result = mergeDeep(result, await loadFile(path.join(dir, file)))
|
||||||
result.mode ??= {}
|
// to satisy the type checker
|
||||||
result.plugin ??= []
|
result.agent ??= {}
|
||||||
|
result.mode ??= {}
|
||||||
|
result.plugin ??= []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(installDependencies(dir))
|
promises.push(installDependencies(dir))
|
||||||
|
|||||||
Reference in New Issue
Block a user