Skip to content

Commit ed3954e

Browse files
committed
Merge branch 'master' into 'opensource'
Master See merge request ai_native/DeepVCode/DeepVcodeClient!325
2 parents 9a65934 + 92a1a53 commit ed3954e

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { describe, it, expect, vi, beforeEach } from 'vitest';
2+
import { ListSkillsTool } from './list-skills.js';
3+
import { Config } from '../config/config.js';
4+
import { SkillsContextBuilder } from '../skills/skills-context-builder.js';
5+
6+
vi.mock('../skills/skills-context-builder.js');
7+
vi.mock('../config/config.js');
8+
9+
describe('ListSkillsTool', () => {
10+
let tool: ListSkillsTool;
11+
let mockConfig: any;
12+
let mockContextBuilder: any;
13+
14+
beforeEach(() => {
15+
mockConfig = {
16+
getProjectRoot: vi.fn().mockReturnValue('/mock/root'),
17+
};
18+
19+
mockContextBuilder = {
20+
listSkills: vi.fn(),
21+
};
22+
23+
(SkillsContextBuilder as any).mockImplementation(() => mockContextBuilder);
24+
25+
tool = new ListSkillsTool(mockConfig as any);
26+
});
27+
28+
it('should return a specific message when no skills are found without filters', async () => {
29+
mockContextBuilder.listSkills.mockReturnValue([]);
30+
31+
const result = await tool.execute({}, new AbortController().signal);
32+
33+
expect(result.llmContent).toBe('No skills are currently installed.');
34+
expect(result.returnDisplay).toBe('No skills found');
35+
});
36+
37+
it('should return a helpful message when no skills match the filter', async () => {
38+
mockContextBuilder.listSkills.mockReturnValue([
39+
{ id: 's1', marketplaceId: 'm1', pluginId: 'p1', name: 'skill1' }
40+
]);
41+
42+
const result = await tool.execute({ marketplaceId: 'non-existent' }, new AbortController().signal);
43+
44+
expect(result.llmContent).toContain('No skills are currently installed or match the filter criteria');
45+
expect(result.llmContent).toContain('Try calling this tool without any arguments');
46+
expect(result.returnDisplay).toBe('No skills found');
47+
});
48+
49+
it('should list matching skills when filters are applied', async () => {
50+
const skills = [
51+
{ id: 's1', marketplaceId: 'm1', pluginId: 'p1', name: 'skill1', description: 'desc1', path: 'path1', skillMdPath: 'md1' },
52+
{ id: 's2', marketplaceId: 'm2', pluginId: 'p2', name: 'skill2', description: 'desc2', path: 'path2', skillMdPath: 'md2' }
53+
];
54+
mockContextBuilder.listSkills.mockReturnValue(skills);
55+
56+
const result = await tool.execute({ marketplaceId: 'm1' }, new AbortController().signal);
57+
58+
expect(result.llmContent).toContain('Found 1 skill(s)');
59+
expect(result.llmContent).toContain('skill1');
60+
expect(result.llmContent).not.toContain('skill2');
61+
expect(result.returnDisplay).toBe('Found 1 skill(s)');
62+
});
63+
});

packages/core/src/tools/list-skills.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,14 @@ export class ListSkillsTool extends BaseTool<ListSkillsParams, ToolResult> {
9393
}
9494

9595
if (skills.length === 0) {
96+
let message = 'No skills are currently installed';
97+
if (params.marketplaceId || params.pluginId) {
98+
message += ' or match the filter criteria. Try calling this tool without any arguments to see all available skills.';
99+
} else {
100+
message += '.';
101+
}
96102
return {
97-
llmContent: 'No skills are currently installed or match the filter criteria.',
103+
llmContent: message,
98104
returnDisplay: 'No skills found',
99105
};
100106
}

0 commit comments

Comments
 (0)