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
+5 -3
View File
@@ -13,6 +13,7 @@ export interface LegacyPluginCheckResult {
hasLegacyEntry: boolean
hasCanonicalEntry: boolean
legacyEntries: string[]
configPath: string | null
}
function getOpenCodeConfigPath(overrideConfigDir?: string): string | null {
@@ -42,14 +43,14 @@ function isCanonicalPluginEntry(entry: string): boolean {
export function checkForLegacyPluginEntry(overrideConfigDir?: string): LegacyPluginCheckResult {
const configPath = getOpenCodeConfigPath(overrideConfigDir)
if (!configPath) {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [], configPath: null }
}
try {
const content = readFileSync(configPath, "utf-8")
const parseResult = parseJsoncSafe<OpenCodeConfig>(content)
if (!parseResult.data) {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [], configPath }
}
const legacyEntries = (parseResult.data.plugin ?? []).filter(isLegacyPluginEntry)
@@ -59,8 +60,9 @@ export function checkForLegacyPluginEntry(overrideConfigDir?: string): LegacyPlu
hasLegacyEntry: legacyEntries.length > 0,
hasCanonicalEntry,
legacyEntries,
configPath,
}
} catch {
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [] }
return { hasLegacyEntry: false, hasCanonicalEntry: false, legacyEntries: [], configPath: null }
}
}