Compare commits
1 Commits
dev
...
fix/suppor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6ca8bc934 |
@@ -9,8 +9,11 @@ import { loadAvailableModelsFromCache } from "./model-resolution-cache"
|
|||||||
import { getModelResolutionInfoWithOverrides } from "./model-resolution"
|
import { getModelResolutionInfoWithOverrides } from "./model-resolution"
|
||||||
import type { OmoConfig } from "./model-resolution-types"
|
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 = 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 = join(process.cwd(), ".opencode", PACKAGE_NAME)
|
||||||
|
const PROJECT_CONFIG_BASE_ALT = join(process.cwd(), ".opencode", PACKAGE_NAME_ALT)
|
||||||
|
|
||||||
interface ConfigValidationResult {
|
interface ConfigValidationResult {
|
||||||
exists: boolean
|
exists: boolean
|
||||||
@@ -24,9 +27,15 @@ function findConfigPath(): string | null {
|
|||||||
const projectConfig = detectConfigFile(PROJECT_CONFIG_BASE)
|
const projectConfig = detectConfigFile(PROJECT_CONFIG_BASE)
|
||||||
if (projectConfig.format !== "none") return projectConfig.path
|
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)
|
const userConfig = detectConfigFile(USER_CONFIG_BASE)
|
||||||
if (userConfig.format !== "none") return userConfig.path
|
if (userConfig.format !== "none") return userConfig.path
|
||||||
|
|
||||||
|
const userConfigAlt = detectConfigFile(USER_CONFIG_BASE_ALT)
|
||||||
|
if (userConfigAlt.format !== "none") return userConfigAlt.path
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,18 +160,32 @@ export function loadPluginConfig(
|
|||||||
directory: string,
|
directory: string,
|
||||||
ctx: unknown
|
ctx: unknown
|
||||||
): OhMyOpenCodeConfig {
|
): 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 configDir = getOpenCodeConfigDir({ binary: "opencode" });
|
||||||
const userBasePath = path.join(configDir, "oh-my-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 =
|
const userConfigPath =
|
||||||
userDetected.format !== "none"
|
userDetected.format !== "none"
|
||||||
? userDetected.path
|
? userDetected.path
|
||||||
: userBasePath + ".json";
|
: 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 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 =
|
const projectConfigPath =
|
||||||
projectDetected.format !== "none"
|
projectDetected.format !== "none"
|
||||||
? projectDetected.path
|
? projectDetected.path
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ export type OpenCodeConfigPaths = {
|
|||||||
configJsonc: string
|
configJsonc: string
|
||||||
packageJson: string
|
packageJson: string
|
||||||
omoConfig: string
|
omoConfig: string
|
||||||
|
omoConfigAlt: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export function getOpenCodeConfigPaths(options: OpenCodeConfigDirOptions): OpenC
|
|||||||
configJsonc: join(configDir, "opencode.jsonc"),
|
configJsonc: join(configDir, "opencode.jsonc"),
|
||||||
packageJson: join(configDir, "package.json"),
|
packageJson: join(configDir, "package.json"),
|
||||||
omoConfig: join(configDir, "oh-my-opencode.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 } {
|
export function getConfigPaths(): { project: string; user: string; opencode: string } {
|
||||||
const cwd = process.cwd()
|
const cwd = process.cwd()
|
||||||
const configDir = getOpenCodeConfigDir({ binary: "opencode" })
|
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 {
|
return {
|
||||||
project: detectConfigFile(join(cwd, ".opencode", "oh-my-opencode")).path,
|
project: projectPath,
|
||||||
user: detectConfigFile(join(configDir, "oh-my-opencode")).path,
|
user: userPath,
|
||||||
opencode: detectConfigFile(join(configDir, "opencode")).path,
|
opencode: detectConfigFile(join(configDir, "opencode")).path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user