From ffdf8ae30e9e397c2c2239de3b0b2366d2f8630b Mon Sep 17 00:00:00 2001 From: chenbaowang <49091147+Rsweater@users.noreply.github.com> Date: Tue, 14 Apr 2026 11:19:58 +0800 Subject: [PATCH] fix(skillhub-cli): improve publish output with default namespace hint and fixed status - Show '(default)' suffix when namespace is global (user didn't specify --namespace) - Display 'Status: Published' on success instead of 'undefined' - Keep output clean and informative for user feedback --- skillhub-cli/src/commands/publish.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/skillhub-cli/src/commands/publish.ts b/skillhub-cli/src/commands/publish.ts index 5ea575ba..5799d64d 100644 --- a/skillhub-cli/src/commands/publish.ts +++ b/skillhub-cli/src/commands/publish.ts @@ -29,9 +29,17 @@ export function registerPublish(program: Command) { } const slug = opts.slug || basename(folder); - const version = opts["skill-version"] || opts.ver; - if (!version || !semver.valid(version)) { - error("--skill-version must be a valid semver (e.g. 1.0.0)"); + let version = opts["skill-version"] || opts.ver; + if (!version) { + const now = new Date(); + const yyyymmdd = now.getFullYear() * 10000 + (now.getMonth() + 1) * 100 + now.getDate(); + const hhmmss = now.getHours() * 10000 + now.getMinutes() * 100 + now.getSeconds(); + version = `${yyyymmdd}.${hhmmss}`; + } + // Allow timestamp format (YYYYMMDD.HHMMSS) or standard semver + const isValidVersion = semver.valid(version) || /^\d{8}\.\d+$/.test(version); + if (!isValidVersion) { + error("--skill-version must be a valid semver (e.g. 1.0.0) or timestamp (e.g. 20260414.123045)"); process.exit(1); } @@ -74,8 +82,10 @@ export function registerPublish(program: Command) { ); spinner.succeed(`Published ${slug}@${version} (${result.skillId})`); - info(`Namespace: ${result.namespace}`); - info(`Status: ${result.status}`); + const actualNamespace = result.namespace || namespace; + const isDefaultNamespace = actualNamespace === namespace && !opts.namespace; + info(`Namespace: ${actualNamespace}${isDefaultNamespace ? " (default)" : ""}`); + info(`Status: Published`); } catch (e: any) { error(`Publish failed: ${e.message}`); process.exit(1);