Skip to content

Commit 8384b92

Browse files
committed
tui: improve config file discovery and prioritization
Migration now finds opencode config files in parent directories of the working directory, making it easier to migrate configs that exist outside of project roots. Config loading now prioritizes .jsonc files over .json when both exist, giving users clearer control via the recommended jsonc format.
1 parent a1dcf59 commit 8384b92

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/opencode/src/cli/cmd/tui/config/tui-migrate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ async function backupAndStripLegacy(file: string, source: string) {
132132
}
133133

134134
async function opencodeFiles(input: { directories: string[]; cwd: string }) {
135-
const files = [...ConfigPaths.fileInDirectory(Global.Path.config, "opencode")]
135+
const files = [
136+
...ConfigPaths.fileInDirectory(Global.Path.config, "opencode"),
137+
...(await Filesystem.findUp(["opencode.json", "opencode.jsonc"], input.cwd, undefined, { rootFirst: true })),
138+
]
136139
for (const dir of unique(input.directories)) {
137140
files.push(...ConfigPaths.fileInDirectory(dir, "opencode"))
138141
}

packages/opencode/src/config/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const files = Effect.fn("ConfigPaths.projectFiles")(function* (
1616
) {
1717
const afs = yield* AppFileSystem.Service
1818
return (yield* afs.up({
19-
targets: [`${name}.json`, `${name}.jsonc`],
19+
targets: [`${name}.jsonc`, `${name}.json`],
2020
start: directory,
2121
stop: worktree,
2222
})).toReversed()

0 commit comments

Comments
 (0)