From f6ca8bc934b69a5a5f861e8120c907116e63f9a1 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 18 Mar 2026 12:08:47 +0900 Subject: [PATCH] fix(config): support oh-my-openagent.jsonc as alternative config file name (fixes #2624) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/cli/doctor/checks/config.ts | 9 +++++++++ src/plugin-config.ts | 22 ++++++++++++++++++---- src/shared/opencode-config-dir-types.ts | 1 + src/shared/opencode-config-dir.ts | 1 + src/tools/lsp/server-config-loader.ts | 14 ++++++++++++-- 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/cli/doctor/checks/config.ts b/src/cli/doctor/checks/config.ts index 4f8fc549f..bd198993f 100644 --- a/src/cli/doctor/checks/config.ts +++ b/src/cli/doctor/checks/config.ts @@ -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 } diff --git a/src/plugin-config.ts b/src/plugin-config.ts index c9f93f10f..7b7af7f3f 100644 --- a/src/plugin-config.ts +++ b/src/plugin-config.ts @@ -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 diff --git a/src/shared/opencode-config-dir-types.ts b/src/shared/opencode-config-dir-types.ts index bf2f222fe..7514a0cff 100644 --- a/src/shared/opencode-config-dir-types.ts +++ b/src/shared/opencode-config-dir-types.ts @@ -12,4 +12,5 @@ export type OpenCodeConfigPaths = { configJsonc: string packageJson: string omoConfig: string + omoConfigAlt: string } diff --git a/src/shared/opencode-config-dir.ts b/src/shared/opencode-config-dir.ts index 620d561dd..4da8b1444 100644 --- a/src/shared/opencode-config-dir.ts +++ b/src/shared/opencode-config-dir.ts @@ -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"), } } diff --git a/src/tools/lsp/server-config-loader.ts b/src/tools/lsp/server-config-loader.ts index 7a03499c7..ae81907ef 100644 --- a/src/tools/lsp/server-config-loader.ts +++ b/src/tools/lsp/server-config-loader.ts @@ -37,9 +37,19 @@ export function loadJsonFile(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, } }