fix(cli): fix addToLock namespace doubling, update fallback path, and download stream completion

- install: use actualSlug instead of raw slug in addToLock to prevent
  namespace doubling (vision2group/vision2group/slug)
- update: remove hardcoded 'node dist/cli.mjs' fallback, rely on
  process.argv[1] which is always reliable
- download: use finished() to ensure stream write completes before
  proceeding
This commit is contained in:
chenbaowang 2026-04-16 14:46:55 +08:00
parent 616319fe35
commit 601644b8a7
3 changed files with 5 additions and 7 deletions

View file

@ -1,6 +1,7 @@
import { Command } from "commander";
import { createWriteStream } from "node:fs";
import { resolve } from "node:path";
import { finished } from "node:stream/promises";
import { ApiClient } from "../core/api-client.js";
import { ApiRoutes } from "../schema/routes.js";
import { loadConfig } from "../core/config.js";
@ -57,7 +58,7 @@ export function registerDownload(program: Command) {
const outPath = resolve(outputDir, `${skillSlug}.zip`);
const fileStream = createWriteStream(outPath);
await body.pipe(fileStream);
await finished(body.pipe(fileStream));
spinner.succeed(`Downloaded ${skillSlug} to ${outPath}`);
} catch (e: any) {

View file

@ -468,9 +468,9 @@ async function installFromRegistry(slug: string, opts: Record<string, string | s
if (result.success) {
installed++;
await addToLock(skill.name, {
source: `${ns}/${slug}`,
source: `${ns}/${actualSlug}`,
sourceType: "registry",
sourceUrl: `${config.registry}/api/v1/skills/${ns}/${slug}`,
sourceUrl: `${config.registry}/api/v1/skills/${ns}/${actualSlug}`,
namespace: ns,
slug: skill.name,
version: "latest",

View file

@ -7,10 +7,7 @@ import { searchMultiselect, cancelSymbol } from "../utils/search-multiselect.js"
function getCliCommand(): string {
const cliPath = process.argv[1];
if (cliPath && cliPath.endsWith("cli.mjs")) {
return `node "${cliPath}"`;
}
return "node dist/cli.mjs";
return `node "${cliPath}"`;
}
export function registerUpdate(program: Command) {