Files
oh-my-opencode/src/shared/log-legacy-plugin-startup-warning.ts
T
YeonGyu-Kim a9886ccbb7 refactor(plugin): remove metadata assertions
Guard optional plugin metadata and pane identifiers before passing them to cleanup and warning paths.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-15 16:31:13 +09:00

47 lines
1.8 KiB
TypeScript

import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
import { log } from "./logger"
import { migrateLegacyPluginEntry } from "./migrate-legacy-plugin-entry"
import { toCanonicalEntry } from "./plugin-entry-migrator"
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "./plugin-identity"
type LogLegacyPluginStartupWarningDeps = {
checkForLegacyPluginEntry?: typeof checkForLegacyPluginEntry
log?: typeof log
migrateLegacyPluginEntry?: typeof migrateLegacyPluginEntry
}
export function logLegacyPluginStartupWarning(deps: LogLegacyPluginStartupWarningDeps = {}): void {
const checkForLegacyPluginEntryFn = deps.checkForLegacyPluginEntry ?? checkForLegacyPluginEntry
const logFn = deps.log ?? log
const migrateLegacyPluginEntryFn = deps.migrateLegacyPluginEntry ?? migrateLegacyPluginEntry
const result = checkForLegacyPluginEntryFn()
if (!result.hasLegacyEntry || !result.configPath) {
return
}
const suggestedEntries = result.legacyEntries.map(toCanonicalEntry)
logFn("[legacy-migration] 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 = migrateLegacyPluginEntryFn(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(", ")}`,
)
}
}