Skip to content
Closed
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
3 changes: 2 additions & 1 deletion packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,11 +1422,12 @@ export namespace Config {

const update = Effect.fn("Config.update")(function* (config: Info) {
const dir = yield* InstanceState.directory
const file = path.join(dir, "config.json")
const file = path.join(dir, "opencode.json")
const existing = yield* loadFile(file)
yield* fs
.writeFileString(file, JSON.stringify(mergeDeep(writable(existing), writable(config)), null, 2))
.pipe(Effect.orDie)
yield* invalidate()
yield* Effect.promise(() => Instance.dispose())
})

Expand Down
15 changes: 14 additions & 1 deletion packages/opencode/test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,25 @@ test("updates config and writes to file", async () => {
const newConfig = { model: "updated/model" }
await Config.update(newConfig as any)

const writtenConfig = await Filesystem.readJson(path.join(tmp.path, "config.json"))
const writtenConfig = await Filesystem.readJson(path.join(tmp.path, "opencode.json"))
expect(writtenConfig.model).toBe("updated/model")
},
})
})

test("patch then get returns updated config", async () => {
await using tmp = await tmpdir()
await Instance.provide({
directory: tmp.path,
fn: async () => {
await Config.update({ agent: { testAgent: { model: "test/model" } } } as any)

const config = await Config.get()
expect(config.agent?.testAgent?.model).toBe("test/model")
},
})
})

test("gets config directories", async () => {
await using tmp = await tmpdir()
await Instance.provide({
Expand Down
Loading