fix(config): fall back to legacy path when migration fails and use canonical basename everywhere (#3133)
Root cause: loadPluginConfig() unconditionally switched userConfigPath to the
canonical name after calling migrateLegacyConfigFile(), even when migration
failed (e.g. file lock on Windows, permission denied). This left the config
path pointing to a non-existent file, so the plugin config silently loaded
as empty defaults.
Additionally, several fallback/default paths were hardcoded to the legacy
'oh-my-opencode' basename instead of using CONFIG_BASENAME ('oh-my-openagent'),
causing CLI config commands (writeOmoConfig, detectCurrentConfig) to write to
the wrong filename.
Changes:
- plugin-config.ts: check migrateLegacyConfigFile() return value; only switch
to canonical path if migration succeeded OR the canonical file already exists
- opencode-config-dir.ts: use CONFIG_BASENAME for omoConfig path in
getOpenCodeConfigPaths()
- config-context.ts: getOmoConfigPath() now uses detectPluginConfigFile() to
find whichever name variant actually exists on disk
- plugin-config.ts: default fallback paths use CONFIG_BASENAME instead of
hardcoded legacy name
- Added test: loadPluginConfig still loads config when migration fails
(read-only directory simulation)
This commit is contained in:
@@ -289,7 +289,7 @@ describe("opencode-config-dir", () => {
|
||||
expect(paths.configJson).toBe(join(expectedDir, "opencode.json"))
|
||||
expect(paths.configJsonc).toBe(join(expectedDir, "opencode.jsonc"))
|
||||
expect(paths.packageJson).toBe(join(expectedDir, "package.json"))
|
||||
expect(paths.omoConfig).toBe(join(expectedDir, "oh-my-opencode.json"))
|
||||
expect(paths.omoConfig).toBe(join(expectedDir, "oh-my-openagent.json"))
|
||||
})
|
||||
|
||||
test("returns all config paths for desktop binary", () => {
|
||||
@@ -305,7 +305,7 @@ describe("opencode-config-dir", () => {
|
||||
expect(paths.configJson).toBe(join(expectedDir, "opencode.json"))
|
||||
expect(paths.configJsonc).toBe(join(expectedDir, "opencode.jsonc"))
|
||||
expect(paths.packageJson).toBe(join(expectedDir, "package.json"))
|
||||
expect(paths.omoConfig).toBe(join(expectedDir, "oh-my-opencode.json"))
|
||||
expect(paths.omoConfig).toBe(join(expectedDir, "oh-my-openagent.json"))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user