diff --git a/skillhub-cli/src/commands/download.ts b/skillhub-cli/src/commands/download.ts index 463f9a5d..db0d1e0e 100644 --- a/skillhub-cli/src/commands/download.ts +++ b/skillhub-cli/src/commands/download.ts @@ -1,6 +1,6 @@ import { Command } from "commander"; -import { createWriteStream } from "node:fs"; -import { resolve } from "node:path"; +import { createWriteStream, mkdirSync } from "node:fs"; +import { resolve, dirname } from "node:path"; import { finished } from "node:stream/promises"; import { ApiClient } from "../core/api-client.js"; import { loadConfigFromProgram } from "../core/config.js"; @@ -190,6 +190,14 @@ export function registerDownload(program: Command) { } const outPath = resolve(outputDir, `${skillSlug}.zip`); + const outDir = dirname(outPath); + try { + mkdirSync(outDir, { recursive: true }); + } catch (e: any) { + spinner.fail(`Failed to create output directory: ${outDir}`); + process.exitCode = 1; + return; + } const fileStream = createWriteStream(outPath); await finished(body.pipe(fileStream)); diff --git a/skillhub-cli/src/commands/install.ts b/skillhub-cli/src/commands/install.ts index edcf11b2..60a02549 100644 --- a/skillhub-cli/src/commands/install.ts +++ b/skillhub-cli/src/commands/install.ts @@ -444,7 +444,17 @@ async function installFromRegistry( const { statusCode, body } = response; if (statusCode >= 400) { - spinner.fail(`Skill not found: ${ns}/${actualSlug}`); + let errorMsg = `Failed to download skill: ${ns}/${actualSlug}`; + if (statusCode === 404) { + errorMsg = `Skill not found: ${ns}/${actualSlug}`; + } else if (statusCode === 403) { + errorMsg = `Access denied: ${ns}/${actualSlug}. Check your token permissions.`; + } else if (statusCode === 503) { + errorMsg = `Service temporarily unavailable. Please try again later.`; + } else if (statusCode >= 500) { + errorMsg = `Server error (${statusCode}). Please try again later.`; + } + spinner.fail(errorMsg); await rm(tmpDir, { recursive: true, force: true }); process.exitCode = 1; return;