From 5b02563659ea830cb5a4a462f706a57a03500a89 Mon Sep 17 00:00:00 2001 From: LiJian Date: Wed, 10 Jun 2026 14:20:35 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(cli):=20skill=20list/search?= =?UTF-8?q?=20commands=20returning=20empty=20results=20(#15632)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 fix: skill list/search commands returning empty results tRPC endpoints return { data, total } but CLI was treating the result as an array; switch to result?.data ?? [] and update mocks to match. Co-authored-by: Claude Sonnet 4.6 --- apps/cli/src/commands/skill.test.ts | 36 ++++++++++++++++------------- apps/cli/src/commands/skill.ts | 4 ++-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/cli/src/commands/skill.test.ts b/apps/cli/src/commands/skill.test.ts index 0205b4fa8d..230f4c43db 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 a943b9b4ce..e154c127b4 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;