feat(compat): package rename compatibility layer for oh-my-opencode → oh-my-openagent

- Add legacy plugin startup warning when oh-my-opencode config detected
- Update CLI installer and TUI installer for new package name
- Split monolithic config-manager.test.ts into focused test modules
- Add plugin config detection tests for legacy name fallback
- Update processed-command-store to use plugin-identity constants
- Add claude-code-plugin-loader discovery test for both config names
- Update chat-params and ultrawork-db tests for plugin identity

Part of #2823
This commit is contained in:
YeonGyu-Kim
2026-03-26 19:44:55 +09:00
parent d39891fcab
commit 1c54fdad26
16 changed files with 526 additions and 337 deletions
+1
View File
@@ -70,3 +70,4 @@ export * from "./internal-initiator-marker"
export * from "./plugin-command-discovery"
export { SessionCategoryRegistry } from "./session-category-registry"
export * from "./plugin-identity"
export * from "./log-legacy-plugin-startup-warning"
@@ -0,0 +1,76 @@
import { beforeEach, describe, expect, it, mock } from "bun:test"
import type { LegacyPluginCheckResult } from "./legacy-plugin-warning"
function createLegacyPluginCheckResult(
overrides: Partial<LegacyPluginCheckResult> = {},
): LegacyPluginCheckResult {
return {
hasLegacyEntry: false,
hasCanonicalEntry: false,
legacyEntries: [],
...overrides,
}
}
const mockCheckForLegacyPluginEntry = mock(() => createLegacyPluginCheckResult())
const mockLog = mock(() => {})
mock.module("./legacy-plugin-warning", () => ({
checkForLegacyPluginEntry: mockCheckForLegacyPluginEntry,
}))
mock.module("./logger", () => ({
log: mockLog,
}))
async function importFreshStartupWarningModule(): Promise<typeof import("./log-legacy-plugin-startup-warning")> {
return import(`./log-legacy-plugin-startup-warning?test=${Date.now()}-${Math.random()}`)
}
describe("logLegacyPluginStartupWarning", () => {
beforeEach(() => {
mockCheckForLegacyPluginEntry.mockReset()
mockLog.mockReset()
mockCheckForLegacyPluginEntry.mockReturnValue(createLegacyPluginCheckResult())
})
describe("#given OpenCode config contains legacy plugin entries", () => {
it("logs the legacy entries with canonical replacements", async () => {
//#given
mockCheckForLegacyPluginEntry.mockReturnValue(createLegacyPluginCheckResult({
hasLegacyEntry: true,
legacyEntries: ["oh-my-opencode", "oh-my-opencode@3.13.1"],
}))
const { logLegacyPluginStartupWarning } = await importFreshStartupWarningModule()
//#when
logLegacyPluginStartupWarning()
//#then
expect(mockLog).toHaveBeenCalledTimes(1)
expect(mockLog).toHaveBeenCalledWith(
"[OhMyOpenCodePlugin] Legacy plugin entry detected in OpenCode config",
{
legacyEntries: ["oh-my-opencode", "oh-my-opencode@3.13.1"],
suggestedEntries: ["oh-my-openagent", "oh-my-openagent@3.13.1"],
hasCanonicalEntry: false,
},
)
})
})
describe("#given OpenCode config uses only canonical plugin entries", () => {
it("does not log a startup warning", async () => {
//#given
const { logLegacyPluginStartupWarning } = await importFreshStartupWarningModule()
//#when
logLegacyPluginStartupWarning()
//#then
expect(mockLog).not.toHaveBeenCalled()
})
})
})
@@ -0,0 +1,28 @@
import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
import { log } from "./logger"
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "./plugin-identity"
function toCanonicalEntry(entry: string): string {
if (entry === LEGACY_PLUGIN_NAME) {
return PLUGIN_NAME
}
if (entry.startsWith(`${LEGACY_PLUGIN_NAME}@`)) {
return `${PLUGIN_NAME}${entry.slice(LEGACY_PLUGIN_NAME.length)}`
}
return entry
}
export function logLegacyPluginStartupWarning(): void {
const result = checkForLegacyPluginEntry()
if (!result.hasLegacyEntry) {
return
}
log("[OhMyOpenCodePlugin] Legacy plugin entry detected in OpenCode config", {
legacyEntries: result.legacyEntries,
suggestedEntries: result.legacyEntries.map(toCanonicalEntry),
hasCanonicalEntry: result.hasCanonicalEntry,
})
}
@@ -0,0 +1,23 @@
import { describe, expect, test } from "bun:test"
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
import { join } from "node:path"
import { detectPluginConfigFile } from "./jsonc-parser"
describe("detectPluginConfigFile - canonical config detection", () => {
const testDir = join(__dirname, ".test-detect-plugin-canonical")
test("detects oh-my-openagent config when no legacy config exists", () => {
//#given
if (!existsSync(testDir)) mkdirSync(testDir, { recursive: true })
writeFileSync(join(testDir, "oh-my-openagent.jsonc"), "{}")
//#when
const result = detectPluginConfigFile(testDir)
//#then
expect(result.format).toBe("jsonc")
expect(result.path).toBe(join(testDir, "oh-my-openagent.jsonc"))
rmSync(testDir, { recursive: true, force: true })
})
})