Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/opencode/src/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export namespace ConfigPaths {
return [
Global.Path.config,
...(!Flag.OPENCODE_DISABLE_PROJECT_CONFIG
? await Array.fromAsync(
? (await Array.fromAsync(
Filesystem.up({
targets: [".opencode"],
start: directory,
stop: worktree,
}),
)
)).reverse()
: []),
...(await Array.fromAsync(
Filesystem.up({
Expand Down
36 changes: 36 additions & 0 deletions packages/opencode/test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,42 @@ test("local .opencode config can override MCP from project config", async () =>
})
})

test("child .opencode config overrides parent .opencode config", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
// Parent .opencode directory with one username
const parentOpencode = path.join(dir, ".opencode")
await fs.mkdir(parentOpencode, { recursive: true })
await Filesystem.write(
path.join(parentOpencode, "opencode.json"),
JSON.stringify({
$schema: "https://opencode.ai/config.json",
username: "parent-wins",
}),
)
// Child directory with its own .opencode
const childDir = path.join(dir, "child")
const childOpencode = path.join(childDir, ".opencode")
await fs.mkdir(childOpencode, { recursive: true })
await Filesystem.write(
path.join(childOpencode, "opencode.json"),
JSON.stringify({
$schema: "https://opencode.ai/config.json",
username: "child-should-win",
}),
)
},
})
const childDir = path.join(tmp.path, "child")
await Instance.provide({
directory: childDir,
fn: async () => {
const config = await Config.get()
expect(config.username).toBe("child-should-win")
},
})
})

test("project config overrides remote well-known config", async () => {
const originalFetch = globalThis.fetch
let fetchedUrl: string | undefined
Expand Down
Loading