fix(config): prefer canonical plugin config filenames
Ensure oh-my-opencode filenames always win over legacy oh-my-openagent files so readers match canonical writer behavior. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -166,7 +166,7 @@ export function loadPluginConfig(
|
|||||||
const userConfigPath =
|
const userConfigPath =
|
||||||
userDetected.format !== "none"
|
userDetected.format !== "none"
|
||||||
? userDetected.path
|
? userDetected.path
|
||||||
: path.join(configDir, "oh-my-openagent.json");
|
: path.join(configDir, "oh-my-opencode.json");
|
||||||
|
|
||||||
// Project-level config path - prefer .jsonc over .json
|
// Project-level config path - prefer .jsonc over .json
|
||||||
const projectBasePath = path.join(directory, ".opencode");
|
const projectBasePath = path.join(directory, ".opencode");
|
||||||
@@ -174,7 +174,7 @@ export function loadPluginConfig(
|
|||||||
const projectConfigPath =
|
const projectConfigPath =
|
||||||
projectDetected.format !== "none"
|
projectDetected.format !== "none"
|
||||||
? projectDetected.path
|
? projectDetected.path
|
||||||
: path.join(projectBasePath, "oh-my-openagent.json");
|
: path.join(projectBasePath, "oh-my-opencode.json");
|
||||||
|
|
||||||
// Load user config first (base)
|
// Load user config first (base)
|
||||||
let config: OhMyOpenCodeConfig =
|
let config: OhMyOpenCodeConfig =
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ describe("detectConfigFile", () => {
|
|||||||
describe("detectPluginConfigFile", () => {
|
describe("detectPluginConfigFile", () => {
|
||||||
const testDir = join(__dirname, ".test-detect-plugin")
|
const testDir = join(__dirname, ".test-detect-plugin")
|
||||||
|
|
||||||
test("prefers oh-my-openagent over oh-my-opencode", () => {
|
test("prefers oh-my-opencode over oh-my-openagent", () => {
|
||||||
// given
|
// given
|
||||||
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
||||||
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
|
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
|
||||||
@@ -279,7 +279,7 @@ describe("detectPluginConfigFile", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
expect(result.format).toBe("jsonc")
|
expect(result.format).toBe("jsonc")
|
||||||
expect(result.path).toBe(join(testDir, "oh-my-openagent.jsonc"))
|
expect(result.path).toBe(join(testDir, "oh-my-opencode.jsonc"))
|
||||||
|
|
||||||
rmSync(testDir, { recursive: true, force: true })
|
rmSync(testDir, { recursive: true, force: true })
|
||||||
})
|
})
|
||||||
@@ -324,23 +324,23 @@ describe("detectPluginConfigFile", () => {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
expect(result.format).toBe("none")
|
expect(result.format).toBe("none")
|
||||||
expect(result.path).toBe(join(emptyDir, "oh-my-openagent.json"))
|
expect(result.path).toBe(join(emptyDir, "oh-my-opencode.json"))
|
||||||
|
|
||||||
rmSync(testDir, { recursive: true, force: true })
|
rmSync(testDir, { recursive: true, force: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
test("prefers oh-my-openagent.json over oh-my-opencode.jsonc", () => {
|
test("prefers oh-my-opencode.json over oh-my-openagent.jsonc", () => {
|
||||||
// given
|
// given
|
||||||
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
||||||
writeFileSync(join(testDir, "oh-my-openagent.json"), "{}")
|
writeFileSync(join(testDir, "oh-my-opencode.json"), "{}")
|
||||||
writeFileSync(join(testDir, "oh-my-opencode.jsonc"), "{}")
|
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
|
||||||
|
|
||||||
// when
|
// when
|
||||||
const result = detectPluginConfigFile(testDir)
|
const result = detectPluginConfigFile(testDir)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(result.format).toBe("json")
|
expect(result.format).toBe("json")
|
||||||
expect(result.path).toBe(join(testDir, "oh-my-openagent.json"))
|
expect(result.path).toBe(join(testDir, "oh-my-opencode.json"))
|
||||||
|
|
||||||
rmSync(testDir, { recursive: true, force: true })
|
rmSync(testDir, { recursive: true, force: true })
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export function detectConfigFile(basePath: string): {
|
|||||||
return { format: "none", path: jsonPath }
|
return { format: "none", path: jsonPath }
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLUGIN_CONFIG_NAMES = ["oh-my-openagent", "oh-my-opencode"] as const
|
const PLUGIN_CONFIG_NAMES = ["oh-my-opencode", "oh-my-openagent"] as const
|
||||||
|
|
||||||
export function detectPluginConfigFile(dir: string): {
|
export function detectPluginConfigFile(dir: string): {
|
||||||
format: "json" | "jsonc" | "none"
|
format: "json" | "jsonc" | "none"
|
||||||
|
|||||||
Reference in New Issue
Block a user