Merge pull request #2805 from code-yeongyu/fix/b3-config-filename-precedence
fix(config): prefer canonical plugin config filenames
This commit is contained in:
@@ -166,7 +166,7 @@ export function loadPluginConfig(
|
||||
const userConfigPath =
|
||||
userDetected.format !== "none"
|
||||
? userDetected.path
|
||||
: path.join(configDir, "oh-my-openagent.json");
|
||||
: path.join(configDir, "oh-my-opencode.json");
|
||||
|
||||
// Project-level config path - prefer .jsonc over .json
|
||||
const projectBasePath = path.join(directory, ".opencode");
|
||||
@@ -174,7 +174,7 @@ export function loadPluginConfig(
|
||||
const projectConfigPath =
|
||||
projectDetected.format !== "none"
|
||||
? projectDetected.path
|
||||
: path.join(projectBasePath, "oh-my-openagent.json");
|
||||
: path.join(projectBasePath, "oh-my-opencode.json");
|
||||
|
||||
// Load user config first (base)
|
||||
let config: OhMyOpenCodeConfig =
|
||||
|
||||
@@ -268,7 +268,7 @@ describe("detectConfigFile", () => {
|
||||
describe("detectPluginConfigFile", () => {
|
||||
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
|
||||
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
||||
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
|
||||
@@ -279,7 +279,7 @@ describe("detectPluginConfigFile", () => {
|
||||
|
||||
// then
|
||||
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 })
|
||||
})
|
||||
@@ -324,23 +324,23 @@ describe("detectPluginConfigFile", () => {
|
||||
|
||||
// then
|
||||
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 })
|
||||
})
|
||||
|
||||
test("prefers oh-my-openagent.json over oh-my-opencode.jsonc", () => {
|
||||
test("prefers oh-my-opencode.json over oh-my-openagent.jsonc", () => {
|
||||
// given
|
||||
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
|
||||
writeFileSync(join(testDir, "oh-my-openagent.json"), "{}")
|
||||
writeFileSync(join(testDir, "oh-my-opencode.jsonc"), "{}")
|
||||
writeFileSync(join(testDir, "oh-my-opencode.json"), "{}")
|
||||
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
|
||||
|
||||
// when
|
||||
const result = detectPluginConfigFile(testDir)
|
||||
|
||||
// then
|
||||
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 })
|
||||
})
|
||||
|
||||
@@ -66,7 +66,7 @@ export function detectConfigFile(basePath: string): {
|
||||
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): {
|
||||
format: "json" | "jsonc" | "none"
|
||||
|
||||
Reference in New Issue
Block a user