fix: detect and warn about opencode-skills conflict
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user