fix(ci): resolve all test failures + complete rename compat layer

Sisyphus-authored fixes across 15 files:

- plugin-identity: align CONFIG_BASENAME with actual config file name
- add-plugin-to-opencode-config: handle legacy→canonical name migration
- plugin-detection tests: update expectations for new identity constants
- doctor/system: fix legacy name warning test assertions
- install tests: align with new plugin name
- chat-params tests: fix mock isolation
- model-capabilities tests: fix snapshot expectations
- image-converter: fix platform-dependent test assertions (Linux CI)
- example configs: expanded with more detailed comments

Full suite: 4484 pass, 0 fail, typecheck clean.
This commit is contained in:
YeonGyu-Kim
2026-03-26 18:04:31 +09:00
parent e86edca633
commit 4efc181390
17 changed files with 635 additions and 308 deletions
+97
View File
@@ -0,0 +1,97 @@
import { afterEach, beforeEach, describe, expect, it } from "bun:test"
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
describe("checkForLegacyPluginEntry", () => {
let testConfigDir = ""
let originalXdgConfigHome: string | undefined
let originalOpenCodeConfigDir: string | undefined
beforeEach(() => {
originalXdgConfigHome = process.env.XDG_CONFIG_HOME
originalOpenCodeConfigDir = process.env.OPENCODE_CONFIG_DIR
testConfigDir = join(tmpdir(), `omo-legacy-check-${Date.now()}-${Math.random().toString(36).slice(2)}`)
mkdirSync(join(testConfigDir, "opencode"), { recursive: true })
process.env.XDG_CONFIG_HOME = testConfigDir
delete process.env.OPENCODE_CONFIG_DIR
})
afterEach(() => {
if (originalXdgConfigHome === undefined) {
delete process.env.XDG_CONFIG_HOME
} else {
process.env.XDG_CONFIG_HOME = originalXdgConfigHome
}
if (originalOpenCodeConfigDir === undefined) {
delete process.env.OPENCODE_CONFIG_DIR
} else {
process.env.OPENCODE_CONFIG_DIR = originalOpenCodeConfigDir
}
rmSync(testConfigDir, { recursive: true, force: true })
})
it("detects a bare legacy plugin entry", () => {
// given
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-opencode"] }, null, 2))
// when
const result = checkForLegacyPluginEntry()
// then
expect(result.hasLegacyEntry).toBe(true)
expect(result.hasCanonicalEntry).toBe(false)
expect(result.legacyEntries).toEqual(["oh-my-opencode"])
})
it("detects a version-pinned legacy plugin entry", () => {
// given
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-opencode@3.10.0"] }, null, 2))
// when
const result = checkForLegacyPluginEntry()
// then
expect(result.hasLegacyEntry).toBe(true)
expect(result.hasCanonicalEntry).toBe(false)
expect(result.legacyEntries).toEqual(["oh-my-opencode@3.10.0"])
})
it("does not flag a canonical plugin entry", () => {
// given
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-openagent"] }, null, 2))
// when
const result = checkForLegacyPluginEntry()
// then
expect(result.hasLegacyEntry).toBe(false)
expect(result.hasCanonicalEntry).toBe(true)
expect(result.legacyEntries).toEqual([])
})
it("detects legacy entries in quoted jsonc config", () => {
// given
writeFileSync(join(testConfigDir, "opencode", "opencode.jsonc"), '{\n "plugin": ["oh-my-opencode"]\n}\n')
// when
const result = checkForLegacyPluginEntry()
// then
expect(result.hasLegacyEntry).toBe(true)
expect(result.legacyEntries).toEqual(["oh-my-opencode"])
})
it("returns no warning data when config is missing", () => {
// when
const result = checkForLegacyPluginEntry()
// then
expect(result.hasLegacyEntry).toBe(false)
expect(result.hasCanonicalEntry).toBe(false)
expect(result.legacyEntries).toEqual([])
})
})
+57
View File
@@ -0,0 +1,57 @@
import { existsSync, readFileSync } from "node:fs"
import { parseJsoncSafe } from "./jsonc-parser"
import { getOpenCodeConfigPaths } from "./opencode-config-dir"
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "./plugin-identity"
interface OpenCodeConfig {
plugin?: string[]
}
export interface LegacyPluginCheckResult {
hasLegacyEntry: boolean
hasCanonicalEntry: boolean
legacyEntries: string[]
}
function getOpenCodeConfigPath(): string | null {
const { configJsonc, configJson } = getOpenCodeConfigPaths({ binary: "opencode", version: null })
if (existsSync(configJsonc)) return configJsonc
if (existsSync(configJson)) return configJson
return null
}
function isLegacyPluginEntry(entry: string): boolean {
return entry === LEGACY_PLUGIN_NAME || entry.startsWith(`${LEGACY_PLUGIN_NAME}@`)
}
function isCanonicalPluginEntry(entry: string): boolean {
return entry === PLUGIN_NAME || entry.startsWith(`${PLUGIN_NAME}@`)
}
export function checkForLegacyPluginEntry(): LegacyPluginCheckResult {
const configPath = getOpenCodeConfigPath()
if (!configPath) {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
}
try {
const content = readFileSync(configPath, "utf-8")
const parseResult = parseJsoncSafe<OpenCodeConfig>(content)
if (!parseResult.data) {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
}
const legacyEntries = (parseResult.data.plugin ?? []).filter(isLegacyPluginEntry)
const hasCanonicalEntry = (parseResult.data.plugin ?? []).some(isCanonicalPluginEntry)
return {
hasLegacyEntry: legacyEntries.length > 0,
hasCanonicalEntry,
legacyEntries,
}
} catch {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
}
}
+4 -4
View File
@@ -233,13 +233,13 @@ describe("getModelCapabilities", () => {
expect(result).toMatchObject({
canonicalModelID: "gpt-5.4",
maxOutputTokens: 64_000,
supportsTemperature: false,
maxOutputTokens: 128_000,
supportsTemperature: true,
})
expect(result.diagnostics).toMatchObject({
snapshot: { source: "runtime-snapshot" },
maxOutputTokens: { source: "runtime-snapshot" },
supportsTemperature: { source: "runtime-snapshot" },
maxOutputTokens: { source: "runtime" },
supportsTemperature: { source: "runtime" },
})
})
+4 -4
View File
@@ -3,24 +3,24 @@ import { PLUGIN_NAME, CONFIG_BASENAME, LOG_FILENAME, CACHE_DIR_NAME } from "./pl
describe("plugin-identity constants", () => {
describe("PLUGIN_NAME", () => {
it("equals oh-my-opencode", () => {
it("equals oh-my-openagent", () => {
// given
// when
// then
expect(PLUGIN_NAME).toBe("oh-my-opencode")
expect(PLUGIN_NAME).toBe("oh-my-openagent")
})
})
describe("CONFIG_BASENAME", () => {
it("equals oh-my-opencode", () => {
it("equals oh-my-openagent", () => {
// given
// when
// then
expect(CONFIG_BASENAME).toBe("oh-my-opencode")
expect(CONFIG_BASENAME).toBe("oh-my-openagent")
})
})
+4 -3
View File
@@ -1,5 +1,6 @@
export const PLUGIN_NAME = "oh-my-opencode"
export const LEGACY_PLUGIN_NAME = "oh-my-openagent"
export const CONFIG_BASENAME = "oh-my-opencode"
export const PLUGIN_NAME = "oh-my-openagent"
export const LEGACY_PLUGIN_NAME = "oh-my-opencode"
export const CONFIG_BASENAME = "oh-my-openagent"
export const LEGACY_CONFIG_BASENAME = "oh-my-opencode"
export const LOG_FILENAME = "oh-my-opencode.log"
export const CACHE_DIR_NAME = "oh-my-opencode"