Files
oh-my-opencode/src/shared/log-legacy-plugin-startup-warning.ts
T
YeonGyu-Kim f03c6700d4 fix(hooks): reuse shared legacy plugin migration helper
Replace the legacy toast regex writer with the shared atomic helper and route legacy plugin call sites through small wrappers so existing mock.module tests stop leaking across the suite.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-04 01:32:59 +09:00

48 lines
1.6 KiB
TypeScript

import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
import { log } from "./logger"
import { migrateLegacyPluginEntry } from "./plugin-entry-migrator"
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
}
const suggestedEntries = result.legacyEntries.map(toCanonicalEntry)
log("[OhMyOpenCodePlugin] Legacy plugin entry detected in OpenCode config", {
legacyEntries: result.legacyEntries,
suggestedEntries,
hasCanonicalEntry: result.hasCanonicalEntry,
})
console.warn(
`[oh-my-openagent] WARNING: Your opencode.json uses the legacy package name "${LEGACY_PLUGIN_NAME}".`
+ ` The package has been renamed to "${PLUGIN_NAME}".`
+ ` Attempting auto-migration...`,
)
const migrated = migrateLegacyPluginEntry(result.configPath!)
if (migrated) {
console.warn(`[oh-my-openagent] Auto-migrated opencode.json: ${result.legacyEntries.join(", ")} -> ${suggestedEntries.join(", ")}`)
} else {
console.warn(
`[oh-my-openagent] Could not auto-migrate. Please manually update your opencode.json:`
+ ` ${result.legacyEntries.map((e, i) => `"${e}" -> "${suggestedEntries[i]}"`).join(", ")}`,
)
}
}