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:
YeonGyu-Kim
2026-03-27 15:40:04 +09:00
parent 127626a122
commit 6a733c9dde
15 changed files with 822 additions and 8 deletions
+27
View File
@@ -0,0 +1,27 @@
import { existsSync, readFileSync, writeFileSync } from "node:fs"
import { log } from "./logger"
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "./plugin-identity"
export function migrateLegacyPluginEntry(configPath: string): boolean {
if (!existsSync(configPath)) return false
try {
const content = readFileSync(configPath, "utf-8")
if (!content.includes(LEGACY_PLUGIN_NAME)) return false
const updated = content.replaceAll(LEGACY_PLUGIN_NAME, PLUGIN_NAME)
if (updated === content) return false
writeFileSync(configPath, updated, "utf-8")
log("[migrateLegacyPluginEntry] Auto-migrated opencode.json plugin entry", {
configPath,
from: LEGACY_PLUGIN_NAME,
to: PLUGIN_NAME,
})
return true
} catch (error) {
log("[migrateLegacyPluginEntry] Failed to migrate opencode.json", { configPath, error })
return false
}
}