From 0bfcb028c2968b350d902790edd2032a059c1bbe Mon Sep 17 00:00:00 2001 From: chenbaowang <49091147+Rsweater@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:41:00 +0800 Subject: [PATCH] feat(cli): move namespaces to me subcommand and reorganize help categories - Add 'me namespaces' subcommand to list accessible namespaces - Remove standalone 'namespaces' command from CLI - Rename 'My Skills' help section to 'My Profile' - Move namespaces listing under My Profile section Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- skillhub-cli/src/cli.ts | 7 ++----- skillhub-cli/src/commands/me.ts | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/skillhub-cli/src/cli.ts b/skillhub-cli/src/cli.ts index 75db78f2e..00e8851eb 100644 --- a/skillhub-cli/src/cli.ts +++ b/skillhub-cli/src/cli.ts @@ -64,9 +64,10 @@ function buildTopLevelHelp(version: string): string { ])); sections.push(""); - sections.push(formatSection("My Skills", [ + sections.push(formatSection("My Profile", [ { cmd: "me skills", desc: "List your published skills", alias: "me ls" }, { cmd: "me stars", desc: "List your starred skills" }, + { cmd: "me namespaces", desc: "List namespaces you have access to" }, { cmd: "rating ", desc: "View your rating for a skill" }, { cmd: "reviews", desc: "List your review submissions", alias: "reviews my, reviews submissions" }, ])); @@ -96,7 +97,6 @@ function buildTopLevelHelp(version: string): string { sections.push(formatSection("Notifications & Admin", [ { cmd: "notifications", desc: "Manage notifications", alias: "notif" }, - { cmd: "namespaces", desc: "List namespaces you have access to" }, { cmd: "transfer ", desc: "Transfer namespace ownership" }, ])); sections.push(""); @@ -158,7 +158,6 @@ export async function createCli(): Promise { { registerLogout }, { registerWhoami }, { registerPublish }, - { registerNamespaces }, { registerInstall }, { registerDownload }, { registerList }, @@ -186,7 +185,6 @@ export async function createCli(): Promise { import("./commands/logout.js"), import("./commands/whoami.js"), import("./commands/publish.js"), - import("./commands/namespaces.js"), import("./commands/install.js"), import("./commands/download.js"), import("./commands/list.js"), @@ -215,7 +213,6 @@ export async function createCli(): Promise { registerLogout(program); registerWhoami(program); registerPublish(program); - registerNamespaces(program); registerInstall(program); registerDownload(program); registerList(program); diff --git a/skillhub-cli/src/commands/me.ts b/skillhub-cli/src/commands/me.ts index 32d9391ae..6d0aac7d4 100644 --- a/skillhub-cli/src/commands/me.ts +++ b/skillhub-cli/src/commands/me.ts @@ -24,7 +24,7 @@ export interface MeSkillsResponse { } export function registerMe(program: Command) { - const me = program.command("me").description("View your skills and stars"); + const me = program.command("me").description("View your profile information"); me .command("skills") @@ -86,4 +86,31 @@ export function registerMe(program: Command) { process.exitCode = 1; } }); + + me + .command("namespaces") + .description("List namespaces you have access to") + .action(async () => { + try { + const token = await requireToken(); + const config = loadConfigFromProgram(program); + const client = new ApiClient({ baseUrl: config.registry, token, debug: program.opts().debug }); + const namespaces = await client.get<{ slug: string; displayName: string; currentUserRole: string; status: string }[]>("/api/v1/me/namespaces"); + const isJson = program.opts().json; + if (isJson) { + console.log(JSON.stringify(namespaces, null, 2)); + } else { + if (!namespaces || namespaces.length === 0) { + console.log("No namespaces found."); + return; + } + for (const ns of namespaces) { + console.log(`${ns.slug} — ${ns.displayName} [${ns.currentUserRole}] (${ns.status})`); + } + } + } catch (e: any) { + error(`Failed to list namespaces: ${e.message}`); + process.exitCode = 1; + } + }); }