75
76
export function getCanonicalPluginCommandId(plugin: { readonly uri: URI; readonly label?: string }, commandName: string): string {
77
>
const prefix = (plugin.label ? normalizePluginToken(plugin.label) : '') || normalizePluginToken(basename(plugin.uri));
agentPluginService.ts
78
>
const normalizedCommand = normalizePluginToken(commandName);
79
>
if (normalizedCommand.startsWith(`${prefix}:`)) {
80
return normalizedCommand;
81
}
83
>
// When the skill name matches the plugin name, use just the plugin
84
>
// name so the user can invoke `/plugin-name` instead of the redundant
85
>
// `/plugin-name:plugin-name`.
86
>
if (prefix === normalizedCommand) {
87
return prefix;
88
}
90
>
return `${prefix}:${normalizedCommand}`;
91
>
}
92
94
>
return value
95
>
.trim()
96
>
.toLowerCase()
97
>
.replace(/\s+/g, '-')
98
>
.replace(/[^a-z0-9_.:-]/g, '-')
99
>
.replace(/-+/g, '-')
100
>
.replace(/^[-:.]+|[-:.]+$/g, '');
101
>
}
102
103
class AgentPluginDiscoveryRegistry {