fix(cli): validate and detect OpenCode Go install settings

Reject invalid --opencode-go values during non-TUI installs and detect existing OpenCode Go usage from the generated oh-my-opencode config so updates preserve the right defaults.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-03-14 13:46:32 +09:00
parent 532995bb51
commit 7f7527047e
4 changed files with 87 additions and 7 deletions
@@ -10,10 +10,12 @@ import { addPluginToOpenCodeConfig } from "./add-plugin-to-opencode-config"
describe("detectCurrentConfig - dual name detection", () => {
let testConfigDir = ""
let testConfigPath = ""
let testOmoConfigPath = ""
beforeEach(() => {
testConfigDir = join(tmpdir(), `omo-detect-config-${Date.now()}-${Math.random().toString(36).slice(2)}`)
testConfigPath = join(testConfigDir, "opencode.json")
testOmoConfigPath = join(testConfigDir, "oh-my-opencode.json")
mkdirSync(testConfigDir, { recursive: true })
process.env.OPENCODE_CONFIG_DIR = testConfigDir
@@ -85,6 +87,23 @@ describe("detectCurrentConfig - dual name detection", () => {
// then
expect(result.isInstalled).toBe(false)
})
it("detects OpenCode Go from the existing omo config", () => {
// given
writeFileSync(testConfigPath, JSON.stringify({ plugin: ["oh-my-openagent"] }, null, 2) + "\n", "utf-8")
writeFileSync(
testOmoConfigPath,
JSON.stringify({ agents: { atlas: { model: "opencode-go/kimi-k2.5" } } }, null, 2) + "\n",
"utf-8",
)
// when
const result = detectCurrentConfig()
// then
expect(result.isInstalled).toBe(true)
expect(result.hasOpencodeGo).toBe(true)
})
})
describe("addPluginToOpenCodeConfig - dual name detection", () => {