mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 11:14:23 +01:00
chore: adjust cfg code
This commit is contained in:
@@ -35,19 +35,6 @@ export namespace Config {
|
||||
}
|
||||
}
|
||||
|
||||
const opencodeDirectories = await Array.fromAsync(
|
||||
Filesystem.up({
|
||||
targets: [".opencode"],
|
||||
start: Instance.directory,
|
||||
stop: Instance.worktree,
|
||||
}),
|
||||
)
|
||||
for (const dir of opencodeDirectories.toReversed()) {
|
||||
for (const file of ["opencode.jsonc", "opencode.json"]) {
|
||||
result = mergeDeep(result, await loadFile(path.join(dir, file)))
|
||||
}
|
||||
}
|
||||
|
||||
// Override with custom config if provided
|
||||
if (Flag.OPENCODE_CONFIG) {
|
||||
result = mergeDeep(result, await loadFile(Flag.OPENCODE_CONFIG))
|
||||
@@ -93,6 +80,15 @@ export namespace Config {
|
||||
const promises: Promise<void>[] = []
|
||||
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 ??= []
|
||||
}
|
||||
|
||||
promises.push(installDependencies(dir))
|
||||
result.command = mergeDeep(result.command ?? {}, await loadCommand(dir))
|
||||
result.agent = mergeDeep(result.agent, await loadAgent(dir))
|
||||
|
||||
Reference in New Issue
Block a user