feat(cli): dispatch du callback plugin slash-command vers le runtime registry — #166 (QA verte)

Boucle le gap end-to-end de #165 : à l'exécution d'une commande slash plugin
depuis le composer custom, l'UI traite l'effet pluginCallback et le dispatche
au PluginRuntimeRegistry pour que la callback du plugin s'exécute réellement.

- runtime/registry: runCommandStrict (échec explicite si handler absent) +
  propagation de la valeur de retour ; élargit les types de retour (unknown).
- runtime/loader: chargement de contributes.slashCommands au registre +
  propagation du retour du handler.
- features/plugins/usePluginMenus: runCommand retourne unknown.
- features/agents/CustomAgentChatView: handler de l'effet pluginCallback ->
  pluginRuntime.registry.runCommandStrict, avec retour utilisateur en cas
  d'échec (commande indisponible / callback absente).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 15:47:04 +02:00
parent fbaca9d5cc
commit b0be5f04e4
6 changed files with 341 additions and 10 deletions

View File

@ -151,7 +151,7 @@ function createCommandContext(commands: PluginCommandRegistry): PluginCommandCon
register: (commandId, handler) => commands.register(commandId, handler),
registerCommand: (commandId, handler) =>
commands.register(commandId, async (...args) => {
await handler(...args);
return await handler(...args);
}),
};
}
@ -195,7 +195,10 @@ function safePluginId(entry: unknown): string {
function commandIdsFromContributes(contributes: PluginContributionDto): Set<string> {
return new Set<string>(
contributes.menuItems.flatMap<string>((item) => {
[
...arrayOrEmpty(contributes.menuItems),
...arrayOrEmpty(contributes.slashCommands),
].flatMap<string>((item) => {
const command = nonEmptyString(objectOrEmpty(item).command);
return command ? [command] : [];
}),
@ -216,6 +219,7 @@ function normalizeContributes(entry: PluginRuntimePlugin): PluginContributionDto
return {
menus: arrayOrEmpty(contributes?.menus),
menuItems: arrayOrEmpty(contributes?.menuItems),
slashCommands: arrayOrEmpty(contributes?.slashCommands),
layouts: arrayOrEmpty(contributes?.layouts),
mcpServers: arrayOrEmpty(contributes?.mcpServers),
};