fix(plugin): disable duplicate OMO plugin startup
This commit is contained in:
@@ -28,6 +28,13 @@ const KNOWN_SKILL_PLUGINS = [
|
||||
"@opencode/skills",
|
||||
]
|
||||
|
||||
const OMO_PACKAGE_PLUGINS = [
|
||||
"oh-my-opencode",
|
||||
"oh-my-openagent",
|
||||
"@code-yeongyu/oh-my-opencode",
|
||||
"@code-yeongyu/oh-my-openagent",
|
||||
]
|
||||
|
||||
function matchesKnownPlugin(entry: string, knownPlugins: readonly string[]): string | null {
|
||||
const normalized = entry.toLowerCase()
|
||||
for (const known of knownPlugins) {
|
||||
@@ -43,6 +50,20 @@ function matchesKnownPlugin(entry: string, knownPlugins: readonly string[]): str
|
||||
return null
|
||||
}
|
||||
|
||||
function isOmoFilePlugin(entry: string): boolean {
|
||||
const normalized = entry.toLowerCase().replaceAll("\\", "/")
|
||||
if (!normalized.startsWith("file://")) return false
|
||||
|
||||
return /\/(omo(?:-[^/]*)?|oh-my-opencode|oh-my-openagent)\/(src|dist)\/index\.(ts|js)$/.test(normalized)
|
||||
}
|
||||
|
||||
function matchesOmoPlugin(entry: string): string | null {
|
||||
const packageMatch = matchesKnownPlugin(entry, OMO_PACKAGE_PLUGINS)
|
||||
if (packageMatch) return packageMatch
|
||||
if (isOmoFilePlugin(entry)) return "oh-my-openagent"
|
||||
return null
|
||||
}
|
||||
|
||||
export interface ExternalNotifierResult {
|
||||
detected: boolean
|
||||
pluginName: string | null
|
||||
@@ -55,6 +76,13 @@ export interface ExternalSkillPluginResult {
|
||||
allPlugins: string[]
|
||||
}
|
||||
|
||||
export interface DuplicateOmoPluginResult {
|
||||
detected: boolean
|
||||
pluginName: string | null
|
||||
duplicatePlugins: string[]
|
||||
allPlugins: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if any external notification plugin is configured.
|
||||
* Returns information about detected plugins for logging/warning.
|
||||
@@ -107,6 +135,31 @@ export function detectExternalSkillPlugin(directory: string): ExternalSkillPlugi
|
||||
}
|
||||
}
|
||||
|
||||
export function detectDuplicateOmoPlugin(directory: string): DuplicateOmoPluginResult {
|
||||
const plugins = loadOpencodePlugins(directory)
|
||||
const duplicatePlugins = plugins.filter((plugin) => matchesOmoPlugin(plugin) !== null)
|
||||
|
||||
if (duplicatePlugins.length > 1) {
|
||||
log("[oh-my-openagent] Duplicate OMO plugin entries detected", {
|
||||
duplicatePlugins,
|
||||
allPlugins: plugins,
|
||||
})
|
||||
return {
|
||||
detected: true,
|
||||
pluginName: "oh-my-openagent",
|
||||
duplicatePlugins,
|
||||
allPlugins: plugins,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
detected: false,
|
||||
pluginName: null,
|
||||
duplicatePlugins,
|
||||
allPlugins: plugins,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a warning message for users with conflicting notification plugins.
|
||||
*/
|
||||
@@ -137,3 +190,19 @@ Both ${PLUGIN_NAME} and ${pluginName} scan ~/.config/opencode/skills/ and regist
|
||||
2. Or disable ${PLUGIN_NAME}'s skill loading by setting "claude_code.skills": false in ${CONFIG_BASENAME}.json
|
||||
3. Or uninstall ${PLUGIN_NAME} if you prefer ${pluginName}'s skill management`
|
||||
}
|
||||
|
||||
export function getDuplicateOmoPluginWarning(duplicatePlugins: readonly string[]): string {
|
||||
const formattedPlugins = duplicatePlugins.map((plugin) => ` - ${plugin}`).join("\n")
|
||||
|
||||
return `[${PLUGIN_NAME}] Duplicate OMO plugin entries detected:
|
||||
${formattedPlugins}
|
||||
|
||||
Multiple ${PLUGIN_NAME} instances can inject internal prompts into the same live OpenCode session.
|
||||
That can create overlapping assistant turns and corrupt session state.
|
||||
|
||||
${PLUGIN_NAME} startup has been disabled for this plugin instance.
|
||||
|
||||
Keep exactly one OMO plugin entry in your OpenCode config. Check both:
|
||||
1. ~/.config/opencode/opencode.json
|
||||
2. Any active OPENCODE_CONFIG_DIR profile, such as ~/.config/opencode/profiles/<name>/opencode.json`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user