feat: add in-chat skill discovery and local registry install command
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
import { createApproveCommand, createApprovalsCommand, createContextCommand, createDenyCommand, createElevateCommand, createModelCommand, createQueueCommand, createResearchCommand, createTransferCommand } from './index.js';
|
||||
import { createApproveCommand, createApprovalsCommand, createContextCommand, createDenyCommand, createElevateCommand, createModelCommand, createQueueCommand, createResearchCommand, createSkillCommand, createTransferCommand } from './index.js';
|
||||
|
||||
describe('builtin /model command', () => {
|
||||
it('passes through the full argument string', async () => {
|
||||
@@ -241,3 +241,19 @@ describe('builtin approval commands', () => {
|
||||
expect(result).toEqual({ handled: true, text: 'denied' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('builtin /skill command', () => {
|
||||
it('passes subcommand text to skillCommand service', async () => {
|
||||
const cmd = createSkillCommand();
|
||||
const skillCommand = vi.fn(() => 'ok');
|
||||
const result = await cmd.execute(['search', 'calendar'], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/skill search calendar',
|
||||
services: { skillCommand },
|
||||
});
|
||||
expect(skillCommand).toHaveBeenCalledWith('search calendar');
|
||||
expect(result).toEqual({ handled: true, text: 'ok' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,6 +284,22 @@ export function createDenyCommand(): CommandDefinition {
|
||||
};
|
||||
}
|
||||
|
||||
export function createSkillCommand(): CommandDefinition {
|
||||
return {
|
||||
name: 'skill',
|
||||
description: 'In-chat skill discovery and install (list/search/install)',
|
||||
execute: async (args, ctx) => {
|
||||
if (!ctx.services?.skillCommand) {
|
||||
return notAvailable('Skill command');
|
||||
}
|
||||
return {
|
||||
handled: true,
|
||||
text: await ctx.services.skillCommand(args.join(' ').trim()),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function registerBuiltinCommands(registry: CommandRegistry): void {
|
||||
registry.register(createHelpCommand(registry));
|
||||
registry.register(createStatusCommand());
|
||||
@@ -299,4 +315,5 @@ export function registerBuiltinCommands(registry: CommandRegistry): void {
|
||||
registry.register(createApprovalsCommand());
|
||||
registry.register(createApproveCommand());
|
||||
registry.register(createDenyCommand());
|
||||
registry.register(createSkillCommand());
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@ export {
|
||||
createApprovalsCommand,
|
||||
createApproveCommand,
|
||||
createDenyCommand,
|
||||
createSkillCommand,
|
||||
registerBuiltinCommands,
|
||||
} from './builtin/index.js';
|
||||
|
||||
@@ -38,4 +38,5 @@ export interface CommandServices {
|
||||
getApprovals?: () => Promise<string> | string;
|
||||
approvePending?: (input: string) => Promise<string> | string;
|
||||
denyPending?: (input: string) => Promise<string> | string;
|
||||
skillCommand?: (input: string) => Promise<string> | string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user