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
+8 -2
View File
@@ -17,6 +17,8 @@ export const SYMBOLS = {
star: color.yellow("*"),
}
const ANSI_COLOR_PATTERN = new RegExp("\u001b\\[[0-9;]*m", "g")
function formatProvider(name: string, enabled: boolean, detail?: string): string {
const status = enabled ? SYMBOLS.check : color.dim("○")
const label = enabled ? color.white(name) : color.dim(name)
@@ -83,7 +85,7 @@ export function printBox(content: string, title?: string): void {
const lines = content.split("\n")
const maxWidth =
Math.max(
...lines.map((line) => line.replace(/\x1b\[[0-9;]*m/g, "").length),
...lines.map((line) => line.replace(ANSI_COLOR_PATTERN, "").length),
title?.length ?? 0,
) + 4
const border = color.dim("─".repeat(maxWidth))
@@ -101,7 +103,7 @@ export function printBox(content: string, title?: string): void {
}
for (const line of lines) {
const stripped = line.replace(/\x1b\[[0-9;]*m/g, "")
const stripped = line.replace(ANSI_COLOR_PATTERN, "")
const padding = maxWidth - stripped.length
console.log(color.dim("│") + ` ${line}${" ".repeat(padding - 1)}` + color.dim("│"))
}
@@ -135,6 +137,10 @@ export function validateNonTuiArgs(args: InstallArgs): { valid: boolean; errors:
errors.push(`Invalid --openai value: ${args.openai} (expected: no, yes)`)
}
if (args.opencodeGo !== undefined && !["no", "yes"].includes(args.opencodeGo)) {
errors.push(`Invalid --opencode-go value: ${args.opencodeGo} (expected: no, yes)`)
}
if (args.opencodeZen !== undefined && !["no", "yes"].includes(args.opencodeZen)) {
errors.push(`Invalid --opencode-zen value: ${args.opencodeZen} (expected: no, yes)`)
}