Compare commits
1 Commits
v3.12.3
...
fix/suppor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6ca8bc934 |
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,4 +12,5 @@ export type OpenCodeConfigPaths = {
|
||||
configJsonc: string
|
||||
packageJson: string
|
||||
omoConfig: string
|
||||
omoConfigAlt: string
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user