fix(config): support oh-my-openagent.jsonc as alternative config file name (fixes #2624)

The project was renamed from oh-my-opencode to oh-my-openagent.
Users creating oh-my-openagent.jsonc expect it to be loaded.

Now all config file discovery paths check for oh-my-openagent as
a fallback when oh-my-opencode is not found:
- plugin-config.ts (user-level and project-level)
- doctor config check
- LSP server config loader
- opencode-config-dir paths

oh-my-opencode remains the primary name for backward compatibility.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
YeonGyu-Kim
2026-03-18 12:08:47 +09:00
parent 55ac653eaa
commit f6ca8bc934
5 changed files with 41 additions and 6 deletions

View File

@@ -9,8 +9,11 @@ import { loadAvailableModelsFromCache } from "./model-resolution-cache"
import { getModelResolutionInfoWithOverrides } from "./model-resolution"
import type { OmoConfig } from "./model-resolution-types"
const PACKAGE_NAME_ALT = "oh-my-openagent"
const USER_CONFIG_BASE = join(getOpenCodeConfigDir({ binary: "opencode" }), PACKAGE_NAME)
const USER_CONFIG_BASE_ALT = join(getOpenCodeConfigDir({ binary: "opencode" }), PACKAGE_NAME_ALT)
const PROJECT_CONFIG_BASE = join(process.cwd(), ".opencode", PACKAGE_NAME)
const PROJECT_CONFIG_BASE_ALT = join(process.cwd(), ".opencode", PACKAGE_NAME_ALT)
interface ConfigValidationResult {
exists: boolean
@@ -24,9 +27,15 @@ function findConfigPath(): string | null {
const projectConfig = detectConfigFile(PROJECT_CONFIG_BASE)
if (projectConfig.format !== "none") return projectConfig.path
const projectConfigAlt = detectConfigFile(PROJECT_CONFIG_BASE_ALT)
if (projectConfigAlt.format !== "none") return projectConfigAlt.path
const userConfig = detectConfigFile(USER_CONFIG_BASE)
if (userConfig.format !== "none") return userConfig.path
const userConfigAlt = detectConfigFile(USER_CONFIG_BASE_ALT)
if (userConfigAlt.format !== "none") return userConfigAlt.path
return null
}

View File

@@ -160,18 +160,32 @@ export function loadPluginConfig(
directory: string,
ctx: unknown
): OhMyOpenCodeConfig {
// User-level config path - prefer .jsonc over .json
// User-level config path - prefer .jsonc over .json, try oh-my-openagent as fallback
const configDir = getOpenCodeConfigDir({ binary: "opencode" });
const userBasePath = path.join(configDir, "oh-my-opencode");
const userDetected = detectConfigFile(userBasePath);
let userDetected = detectConfigFile(userBasePath);
if (userDetected.format === "none") {
const altUserBasePath = path.join(configDir, "oh-my-openagent");
const altDetected = detectConfigFile(altUserBasePath);
if (altDetected.format !== "none") {
userDetected = altDetected;
}
}
const userConfigPath =
userDetected.format !== "none"
? userDetected.path
: userBasePath + ".json";
// Project-level config path - prefer .jsonc over .json
// Project-level config path - prefer .jsonc over .json, try oh-my-openagent as fallback
const projectBasePath = path.join(directory, ".opencode", "oh-my-opencode");
const projectDetected = detectConfigFile(projectBasePath);
let projectDetected = detectConfigFile(projectBasePath);
if (projectDetected.format === "none") {
const altProjectBasePath = path.join(directory, ".opencode", "oh-my-openagent");
const altDetected = detectConfigFile(altProjectBasePath);
if (altDetected.format !== "none") {
projectDetected = altDetected;
}
}
const projectConfigPath =
projectDetected.format !== "none"
? projectDetected.path

View File

@@ -12,4 +12,5 @@ export type OpenCodeConfigPaths = {
configJsonc: string
packageJson: string
omoConfig: string
omoConfigAlt: string
}

View File

@@ -84,6 +84,7 @@ export function getOpenCodeConfigPaths(options: OpenCodeConfigDirOptions): OpenC
configJsonc: join(configDir, "opencode.jsonc"),
packageJson: join(configDir, "package.json"),
omoConfig: join(configDir, "oh-my-opencode.json"),
omoConfigAlt: join(configDir, "oh-my-openagent.json"),
}
}

View File

@@ -37,9 +37,19 @@ export function loadJsonFile<T>(path: string): T | null {
export function getConfigPaths(): { project: string; user: string; opencode: string } {
const cwd = process.cwd()
const configDir = getOpenCodeConfigDir({ binary: "opencode" })
const projectDetected = detectConfigFile(join(cwd, ".opencode", "oh-my-opencode"))
const projectPath = projectDetected.format !== "none"
? projectDetected.path
: detectConfigFile(join(cwd, ".opencode", "oh-my-openagent")).path
const userDetected = detectConfigFile(join(configDir, "oh-my-opencode"))
const userPath = userDetected.format !== "none"
? userDetected.path
: detectConfigFile(join(configDir, "oh-my-openagent")).path
return {
project: detectConfigFile(join(cwd, ".opencode", "oh-my-opencode")).path,
user: detectConfigFile(join(configDir, "oh-my-opencode")).path,
project: projectPath,
user: userPath,
opencode: detectConfigFile(join(configDir, "opencode")).path,
}
}