fix(#2823): auto-migrate legacy plugin name and warn users at startup
- logLegacyPluginStartupWarning now emits console.warn (visible to user, not just log file) when oh-my-opencode is detected in opencode.json - Auto-migrates opencode.json plugin entry from oh-my-opencode to oh-my-openagent (with backup) - plugin-config.ts: add console.warn when loading legacy config filename - test: 10 tests covering migration, console output, edge cases
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
|
||||
import { log } from "./logger"
|
||||
import { migrateLegacyPluginEntry } from "./migrate-legacy-plugin-entry"
|
||||
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "./plugin-identity"
|
||||
|
||||
function toCanonicalEntry(entry: string): string {
|
||||
@@ -20,9 +21,27 @@ export function logLegacyPluginStartupWarning(): void {
|
||||
return
|
||||
}
|
||||
|
||||
const suggestedEntries = result.legacyEntries.map(toCanonicalEntry)
|
||||
|
||||
log("[OhMyOpenCodePlugin] Legacy plugin entry detected in OpenCode config", {
|
||||
legacyEntries: result.legacyEntries,
|
||||
suggestedEntries: result.legacyEntries.map(toCanonicalEntry),
|
||||
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(", ")}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user