From 885d3a24620c295a3a13c07e9c6939ce0f0348c3 Mon Sep 17 00:00:00 2001 From: codivedev Date: Fri, 27 Mar 2026 13:26:19 +0100 Subject: [PATCH] fix: detect and warn about opencode-skills conflict --- src/plugin-handlers/command-config-handler.ts | 11 +++ src/shared/external-plugin-detector.ts | 68 ------------------- 2 files changed, 11 insertions(+), 68 deletions(-) diff --git a/src/plugin-handlers/command-config-handler.ts b/src/plugin-handlers/command-config-handler.ts index 7afd1e416..b5d91120c 100644 --- a/src/plugin-handlers/command-config-handler.ts +++ b/src/plugin-handlers/command-config-handler.ts @@ -17,6 +17,11 @@ import { loadOpencodeProjectSkills, skillsToCommandDefinitionRecord, } from "../features/opencode-skill-loader"; +import { + detectExternalSkillPlugin, + getSkillPluginConflictWarning, + log, +} from "../shared"; import type { PluginComponents } from "./plugin-components-loader"; export async function applyCommandConfig(params: { @@ -31,6 +36,12 @@ export async function applyCommandConfig(params: { const includeClaudeCommands = params.pluginConfig.claude_code?.commands ?? true; const includeClaudeSkills = params.pluginConfig.claude_code?.skills ?? true; + // Detect conflicting skill plugins + const externalSkillPlugin = detectExternalSkillPlugin(params.ctx.directory); + if (externalSkillPlugin.detected) { + log(getSkillPluginConflictWarning(externalSkillPlugin.pluginName!)); + } + const [ configSourceSkills, userCommands, diff --git a/src/shared/external-plugin-detector.ts b/src/shared/external-plugin-detector.ts index 843aaed06..a73149d68 100644 --- a/src/shared/external-plugin-detector.ts +++ b/src/shared/external-plugin-detector.ts @@ -120,28 +120,6 @@ function matchesSkillPlugin(entry: string): string | null { return null } -/** - * Check if a plugin entry matches a known skill plugin. - * Handles various formats: "name", "name@version", "npm:name", "file://path/name" - */ -function matchesSkillPlugin(entry: string): string | null { - const normalized = entry.toLowerCase() - for (const known of KNOWN_SKILL_PLUGINS) { - // Exact match - if (normalized === known) return known - // Version suffix: "opencode-skills@1.2.3" - if (normalized.startsWith(`${known}@`)) return known - // npm: prefix - if (normalized === `npm:${known}` || normalized.startsWith(`npm:${known}@`)) return known - // file:// path ending exactly with package name - if (normalized.startsWith("file://") && ( - normalized.endsWith(`/${known}`) || - normalized.endsWith(`\\${known}`) - )) return known - } - return null -} - export interface ExternalNotifierResult { detected: boolean pluginName: string | null @@ -154,12 +132,6 @@ export interface ExternalSkillPluginResult { allPlugins: string[] } -export interface ExternalSkillPluginResult { - detected: boolean - pluginName: string | null - allPlugins: string[] -} - /** * Detect if any external notification plugin is configured. * Returns information about detected plugins for logging/warning. @@ -212,32 +184,6 @@ export function detectExternalSkillPlugin(directory: string): ExternalSkillPlugi } } -/** - * Detect if any external skill plugin is configured. - * Returns information about detected plugins for logging/warning. - */ -export function detectExternalSkillPlugin(directory: string): ExternalSkillPluginResult { - const plugins = loadOpencodePlugins(directory) - - for (const plugin of plugins) { - const match = matchesSkillPlugin(plugin) - if (match) { - log(`Detected external skill plugin: ${plugin}`) - return { - detected: true, - pluginName: match, - allPlugins: plugins, - } - } - } - - return { - detected: false, - pluginName: null, - allPlugins: plugins, - } -} - /** * Generate a warning message for users with conflicting notification plugins. */ @@ -268,17 +214,3 @@ Both oh-my-opencode and ${pluginName} scan ~/.config/opencode/skills/ and regist 2. Or disable oh-my-opencode's skill loading by setting "claude_code.skills": false in oh-my-opencode.json 3. Or uninstall oh-my-opencode if you prefer ${pluginName}'s skill management` } - -/** - * Generate a warning message for users with conflicting skill plugins. - */ -export function getSkillPluginConflictWarning(pluginName: string): string { - return `[oh-my-openagent] WARNING: External skill plugin detected: ${pluginName} - -Both oh-my-openagent and ${pluginName} scan ~/.config/opencode/skills/ and register tools. -Running both simultaneously causes "Duplicate tool names detected" errors. - -To fix this issue, either: -1. Remove ${pluginName} from your opencode.json plugins -2. Or disable skills in oh-my-openagent by setting "claude_code": { "skills": false } in oh-my-openagent.json` -}