fix: address remaining Cubic review issues - READMEs, workflows, agent prompts, templates
This commit is contained in:
@@ -1,34 +1,44 @@
|
||||
import { PLUGIN_NAME } from "../../../shared/plugin-identity"
|
||||
import {
|
||||
CONFIG_BASENAME,
|
||||
LEGACY_CONFIG_BASENAME,
|
||||
} from "../../../shared/plugin-identity"
|
||||
import { readFileSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { detectConfigFile, getOpenCodeConfigPaths, parseJsonc } from "../../../shared"
|
||||
import type { OmoConfig } from "./model-resolution-types"
|
||||
|
||||
const PACKAGE_NAME = PLUGIN_NAME
|
||||
const USER_CONFIG_BASE = join(
|
||||
getOpenCodeConfigPaths({ binary: "opencode", version: null }).configDir,
|
||||
PACKAGE_NAME
|
||||
)
|
||||
const PROJECT_CONFIG_BASE = join(process.cwd(), ".opencode", PACKAGE_NAME)
|
||||
const USER_CONFIG_BASES = [
|
||||
join(getOpenCodeConfigPaths({ binary: "opencode", version: null }).configDir, CONFIG_BASENAME),
|
||||
join(getOpenCodeConfigPaths({ binary: "opencode", version: null }).configDir, LEGACY_CONFIG_BASENAME),
|
||||
] as const
|
||||
|
||||
const PROJECT_CONFIG_BASES = [
|
||||
join(process.cwd(), ".opencode", CONFIG_BASENAME),
|
||||
join(process.cwd(), ".opencode", LEGACY_CONFIG_BASENAME),
|
||||
] as const
|
||||
|
||||
export function loadOmoConfig(): OmoConfig | null {
|
||||
const projectDetected = detectConfigFile(PROJECT_CONFIG_BASE)
|
||||
if (projectDetected.format !== "none") {
|
||||
try {
|
||||
const content = readFileSync(projectDetected.path, "utf-8")
|
||||
return parseJsonc<OmoConfig>(content)
|
||||
} catch {
|
||||
return null
|
||||
for (const projectConfigBase of PROJECT_CONFIG_BASES) {
|
||||
const projectDetected = detectConfigFile(projectConfigBase)
|
||||
if (projectDetected.format !== "none") {
|
||||
try {
|
||||
const content = readFileSync(projectDetected.path, "utf-8")
|
||||
return parseJsonc<OmoConfig>(content)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const userDetected = detectConfigFile(USER_CONFIG_BASE)
|
||||
if (userDetected.format !== "none") {
|
||||
try {
|
||||
const content = readFileSync(userDetected.path, "utf-8")
|
||||
return parseJsonc<OmoConfig>(content)
|
||||
} catch {
|
||||
return null
|
||||
for (const userConfigBase of USER_CONFIG_BASES) {
|
||||
const userDetected = detectConfigFile(userConfigBase)
|
||||
if (userDetected.format !== "none") {
|
||||
try {
|
||||
const content = readFileSync(userDetected.path, "utf-8")
|
||||
return parseJsonc<OmoConfig>(content)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user