Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(cli): skill list/search commands returning empty results (#15632)

LiJian5b02563659ea
diff --git a/apps/cli/src/commands/skill.test.ts b/apps/cli/src/commands/skill.test.ts
index 0205b4fa8db..230f4c43db8 100644
--- a/apps/cli/src/commands/skill.test.ts
+++ b/apps/cli/src/commands/skill.test.ts
@@ -64,15 +64,18 @@ describe('skill command', () => {
describe('list', () => {
it('should display skills in table format', async () => {
- mockTrpcClient.agentSkills.list.query.mockResolvedValue([
- {
- description: 'A skill',
- id: 's1',
- identifier: 'test-skill',
- name: 'Test Skill',
- source: 'user',
- },
- ]);
+ mockTrpcClient.agentSkills.list.query.mockResolvedValue({
+ data: [
+ {
+ description: 'A skill',
+ id: 's1',
+ identifier: 'test-skill',
+ name: 'Test Skill',
+ source: 'user',
+ },
+ ],
+ total: 1,
+ });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'list']);
@@ -83,7 +86,7 @@ describe('skill command', () => {
it('should output JSON when --json flag is used', async () => {
const items = [{ id: 's1', name: 'Test' }];
- mockTrpcClient.agentSkills.list.query.mockResolvedValue(items);
+ mockTrpcClient.agentSkills.list.query.mockResolvedValue({ data: items, total: items.length });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'list', '--json']);
@@ -92,7 +95,7 @@ describe('skill command', () => {
});
it('should filter by source', async () => {
- mockTrpcClient.agentSkills.list.query.mockResolvedValue([]);
+ mockTrpcClient.agentSkills.list.query.mockResolvedValue({ data: [], total: 0 });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'list', '--source', 'builtin']);
@@ -111,7 +114,7 @@ describe('skill command', () => {
});
it('should show message when no skills found', async () => {
- mockTrpcClient.agentSkills.list.query.mockResolvedValue([]);
+ mockTrpcClient.agentSkills.list.query.mockResolvedValue({ data: [], total: 0 });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'list']);
@@ -211,9 +214,10 @@ describe('skill command', () => {
describe('search', () => {
it('should search skills', async () => {
- mockTrpcClient.agentSkills.search.query.mockResolvedValue([
- { description: 'A skill', id: 's1', name: 'Found Skill' },
- ]);
+ mockTrpcClient.agentSkills.search.query.mockResolvedValue({
+ data: [{ description: 'A skill', id: 's1', name: 'Found Skill' }],
+ total: 1,
+ });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'search', 'test']);
@@ -223,7 +227,7 @@ describe('skill command', () => {
});
it('should show message when no results', async () => {
- mockTrpcClient.agentSkills.search.query.mockResolvedValue([]);
+ mockTrpcClient.agentSkills.search.query.mockResolvedValue({ data: [], total: 0 });
const program = createProgram();
await program.parseAsync(['node', 'test', 'skill', 'search', 'nothing']);
diff --git a/apps/cli/src/commands/skill.ts b/apps/cli/src/commands/skill.ts
index a943b9b4ce0..e154c127b4e 100644
--- a/apps/cli/src/commands/skill.ts
+++ b/apps/cli/src/commands/skill.ts
@@ -47,7 +47,7 @@ export function registerSkillCommand(program: Command) {
if (options.source) input.source = options.source as 'builtin' | 'market' | 'user';
const result = await client.agentSkills.list.query(input);
- const items = Array.isArray(result) ? result : [];
+ const items = result?.data ?? [];
if (options.json !== undefined) {
const fields = typeof options.json === 'string' ? options.json : undefined;
@@ -206,7 +206,7 @@ export function registerSkillCommand(program: Command) {
.action(async (query: string, options: { json?: string | boolean }) => {
const client = await getTrpcClient();
const result = await client.agentSkills.search.query({ query });
- const items = Array.isArray(result) ? result : [];
+ const items = result?.data ?? [];
if (options.json !== undefined) {
const fields = typeof options.json === 'string' ? options.json : undefined;