From 3239b4d5b83f0c22c73cb8b573d92fe5595c48bd Mon Sep 17 00:00:00 2001 From: chenbaowang <49091147+Rsweater@users.noreply.github.com> Date: Thu, 23 Apr 2026 14:08:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(inspect):=20=E4=BF=AE=E5=A4=8D=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E9=80=89=E9=A1=B9=E4=B8=8E=E5=85=A8=E5=B1=80=20--vers?= =?UTF-8?q?ion=20=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 inspect 命令的版本选项从 --version 改为 --skill-version, 避免与 skillhub --version 全局版本选项冲突 --- skillhub-cli/package.json | 2 +- skillhub-cli/src/commands/inspect.ts | 114 +++++++++++++-------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/skillhub-cli/package.json b/skillhub-cli/package.json index 57f1a582..5d88619c 100644 --- a/skillhub-cli/package.json +++ b/skillhub-cli/package.json @@ -1,6 +1,6 @@ { "name": "motovis-skillhub", - "version": "1.2.8", + "version": "1.2.9", "type": "module", "description": "SkillHub CLI - 企业级 Agent Skill 管理工具,支持命名空间", "bin": { diff --git a/skillhub-cli/src/commands/inspect.ts b/skillhub-cli/src/commands/inspect.ts index 63d8bf00..cec97781 100644 --- a/skillhub-cli/src/commands/inspect.ts +++ b/skillhub-cli/src/commands/inspect.ts @@ -142,8 +142,8 @@ export function registerInspect(program: Command) { .argument("", "Skill name or namespace/skill-name") .option("--namespace ", "Search in specific namespace (searches all if not specified)") .option("--details", "Show all versions with tags") - .option("-v, --version ", "Inspect specific version") - .action(async (slug: string, opts: { namespace?: string; details?: boolean; version?: string }) => { + .option("-v, --skill-version ", "Inspect specific version") + .action(async (slug: string, opts: { namespace?: string; details?: boolean; skillVersion?: string }) => { const config = loadConfigFromProgram(program); const token = await readToken(); const client = new ApiClient({ baseUrl: config.registry, token: token || undefined }); @@ -244,69 +244,69 @@ export function registerInspect(program: Command) { } if (targetNamespace) { - if (opts.version) { - await displaySkillDetail(targetNamespace, parsedSlug, opts.version); + if (opts.skillVersion) { + await displaySkillDetail(targetNamespace, parsedSlug, opts.skillVersion); + } else { + await inspectWithVersionSelection(targetNamespace, parsedSlug); + } + return; + } + + const spinner = ora(`Searching for ${parsedSlug}`).start(); + + try { + const results = await searchSkills(client, parsedSlug, 50); + + const seen = new Set(); + const uniqueResults = results.filter(r => { + const key = `${r.namespace}/${r.name}`; + if (!seen.has(key)) { + seen.add(key); + return true; + } + return false; + }); + + if (uniqueResults.length === 0) { + spinner.fail(`Skill not found: ${parsedSlug}`); + process.exitCode = 1; + return; + } + + if (uniqueResults.length === 1) { + spinner.stop(); + const ns = uniqueResults[0].namespace; + const name = uniqueResults[0].name; + if (opts.skillVersion) { + await displaySkillDetail(ns, name, opts.skillVersion); } else { - await inspectWithVersionSelection(targetNamespace, parsedSlug); + await inspectWithVersionSelection(ns, name); } return; } - const spinner = ora(`Searching for ${parsedSlug}`).start(); + spinner.succeed(`Found ${uniqueResults.length} matches for ${parsedSlug}`); - try { - const results = await searchSkills(client, parsedSlug, 50); + const selected = await p.select({ + message: "Select skill to inspect", + options: uniqueResults.map((r) => ({ + value: `${r.namespace}/${r.name}`, + label: `${r.namespace}/${r.name}`, + hint: r.summary ? r.summary.slice(0, 50) : undefined, + })), + }); - const seen = new Set(); - const uniqueResults = results.filter(r => { - const key = `${r.namespace}/${r.name}`; - if (!seen.has(key)) { - seen.add(key); - return true; - } - return false; - }); + if (p.isCancel(selected)) { + console.log("Cancelled."); + return; + } - if (uniqueResults.length === 0) { - spinner.fail(`Skill not found: ${parsedSlug}`); - process.exitCode = 1; - return; - } - - if (uniqueResults.length === 1) { - spinner.stop(); - const ns = uniqueResults[0].namespace; - const name = uniqueResults[0].name; - if (opts.version) { - await displaySkillDetail(ns, name, opts.version); - } else { - await inspectWithVersionSelection(ns, name); - } - return; - } - - spinner.succeed(`Found ${uniqueResults.length} matches for ${parsedSlug}`); - - const selected = await p.select({ - message: "Select skill to inspect", - options: uniqueResults.map((r) => ({ - value: `${r.namespace}/${r.name}`, - label: `${r.namespace}/${r.name}`, - hint: r.summary ? r.summary.slice(0, 50) : undefined, - })), - }); - - if (p.isCancel(selected)) { - console.log("Cancelled."); - return; - } - - const [selectedNs, selectedName] = (selected as string).split("/", 2); - if (opts.version) { - await displaySkillDetail(selectedNs, selectedName, opts.version); - } else { - await inspectWithVersionSelection(selectedNs, selectedName); - } + const [selectedNs, selectedName] = (selected as string).split("/", 2); + if (opts.skillVersion) { + await displaySkillDetail(selectedNs, selectedName, opts.skillVersion); + } else { + await inspectWithVersionSelection(selectedNs, selectedName); + } } catch (e: any) { spinner.fail(e.message); process.exitCode = 1;