mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-15 17:03:20 +00:00
Provider skills were hidden behind provider-specific filesystem rules. That made the backend and UI unable to offer one discovery path for skills. Add a normalized skills contract, provider service, and provider skills API. Keep provider-specific lookup rules inside adapters so routes and UI stay generic. Claude needs plugin handling because enabled plugins resolve through installed_plugins.json. Plugin folders can expose commands or skills, so Claude scans both forms. Claude plugin commands are namespaced to avoid collisions with user and project skills. Codex, Gemini, and Cursor adapters map their expected skill roots into the same contract. The slash menu now shows skills beside built-in and custom commands for discovery. The menu avoids mid-message activation, duplicate rows, loose namespace matches, and input overlap. Provider tests cover discovery locations and Claude plugin edge cases.
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import path from 'node:path';
|
|
|
|
import type { IProviderSkills } from '@/shared/interfaces.js';
|
|
import type {
|
|
LLMProvider,
|
|
ProviderSkill,
|
|
ProviderSkillListOptions,
|
|
ProviderSkillSource,
|
|
} from '@/shared/types.js';
|
|
import {
|
|
findProviderSkillMarkdownFiles,
|
|
readProviderSkillMarkdownDefinition,
|
|
} from '@/shared/utils.js';
|
|
|
|
const resolveWorkspacePath = (workspacePath?: string): string =>
|
|
path.resolve(workspacePath ?? process.cwd());
|
|
|
|
/**
|
|
* Shared skills provider for provider-specific skill source discovery.
|
|
*/
|
|
export abstract class SkillsProvider implements IProviderSkills {
|
|
protected readonly provider: LLMProvider;
|
|
|
|
protected constructor(provider: LLMProvider) {
|
|
this.provider = provider;
|
|
}
|
|
|
|
async listSkills(options?: ProviderSkillListOptions): Promise<ProviderSkill[]> {
|
|
const workspacePath = resolveWorkspacePath(options?.workspacePath);
|
|
const sources = await this.getSkillSources(workspacePath);
|
|
const skills: ProviderSkill[] = [];
|
|
|
|
for (const source of sources) {
|
|
const skillFiles = await findProviderSkillMarkdownFiles(source.rootDir, {
|
|
recursive: source.recursive,
|
|
});
|
|
for (const skillPath of skillFiles) {
|
|
try {
|
|
const definition = await readProviderSkillMarkdownDefinition(skillPath);
|
|
const command = source.commandForSkill
|
|
? source.commandForSkill(definition.name)
|
|
: `${source.commandPrefix ?? '/'}${definition.name}`;
|
|
|
|
skills.push({
|
|
provider: this.provider,
|
|
name: definition.name,
|
|
description: definition.description,
|
|
command,
|
|
scope: source.scope,
|
|
sourcePath: skillPath,
|
|
pluginName: source.pluginName,
|
|
pluginId: source.pluginId,
|
|
});
|
|
} catch {
|
|
// A malformed or unreadable skill markdown file should not hide other valid skills.
|
|
}
|
|
}
|
|
}
|
|
|
|
return skills;
|
|
}
|
|
|
|
protected abstract getSkillSources(workspacePath: string): Promise<ProviderSkillSource[]>;
|
|
}
|