@aipm-registry/cli 0.2.2 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs CHANGED
@@ -8015,6 +8015,10 @@ function registryFetchError(registry, cause) {
8015
8015
  }
8016
8016
  return new Error(`Registry request failed (${registry}): ${msg}`);
8017
8017
  }
8018
+ function registryAuthHeaders(token) {
8019
+ if (!token) return void 0;
8020
+ return { Authorization: `Bearer ${token}` };
8021
+ }
8018
8022
  async function registryFetch(url, registry, init) {
8019
8023
  const timeoutSignal = typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(1e4) : void 0;
8020
8024
  try {
@@ -8023,6 +8027,12 @@ async function registryFetch(url, registry, init) {
8023
8027
  throw registryFetchError(registry, e);
8024
8028
  }
8025
8029
  }
8030
+ function privateInstallHint(name, status, token) {
8031
+ if (status !== 404 || !name.startsWith("@") || token) {
8032
+ return `Package not found: ${name} (${status})`;
8033
+ }
8034
+ return `Package not found: ${name} (${status}). If @org/pkg is private, set AIPM_TOKEN with an install token from the dashboard.`;
8035
+ }
8026
8036
  async function assertRegistryReachable(registry) {
8027
8037
  const base = registry.replace(/\/$/, "");
8028
8038
  const res = await registryFetch(`${base}/health`, base);
@@ -8053,19 +8063,19 @@ async function searchPackages(registry, query, limit = 20) {
8053
8063
  const data = await res.json();
8054
8064
  return data.packages ?? [];
8055
8065
  }
8056
- async function fetchPackageMetadata(registry, name, version) {
8066
+ async function fetchPackageMetadata(registry, name, version, token) {
8057
8067
  const base = registry.replace(/\/$/, "");
8058
8068
  const url = `${base}/v1/packages/${encodePackageName(name)}/versions/${version}`;
8059
- const res = await registryFetch(url, base);
8060
- if (!res.ok) throw new Error(`Package not found: ${name}@${version} (${res.status})`);
8069
+ const res = await registryFetch(url, base, { headers: registryAuthHeaders(token) });
8070
+ if (!res.ok) throw new Error(privateInstallHint(`${name}@${version}`, res.status, token));
8061
8071
  const data = await res.json();
8062
- return { manifest: data.manifest, integrity: data.integrity };
8072
+ return { manifest: data.manifest, integrity: data.integrity, deprecated: data.deprecated ?? null };
8063
8073
  }
8064
- async function fetchPackageTarball(registry, name, version) {
8074
+ async function fetchPackageTarball(registry, name, version, token) {
8065
8075
  const base = registry.replace(/\/$/, "");
8066
8076
  const url = `${base}/v1/packages/${encodePackageName(name)}/versions/${version}/tarball`;
8067
- const res = await registryFetch(url, base);
8068
- if (!res.ok) throw new Error(`Tarball not found: ${name}@${version} (${res.status})`);
8077
+ const res = await registryFetch(url, base, { headers: registryAuthHeaders(token) });
8078
+ if (!res.ok) throw new Error(privateInstallHint(`${name}@${version}`, res.status, token));
8069
8079
  const ab = await res.arrayBuffer();
8070
8080
  return Buffer.from(ab);
8071
8081
  }
@@ -8163,11 +8173,17 @@ async function installOnePackage(options) {
8163
8173
  const configRoot = options.configRoot;
8164
8174
  const installRoot = options.installRoot ?? configRoot;
8165
8175
  await assertRegistryReachable(options.registry);
8166
- const { manifest, integrity: remoteIntegrity } = await fetchPackageMetadata(
8176
+ const { manifest, integrity: remoteIntegrity, deprecated } = await fetchPackageMetadata(
8167
8177
  options.registry,
8168
8178
  options.name,
8169
- options.version
8179
+ options.version,
8180
+ options.token
8170
8181
  );
8182
+ if (deprecated) {
8183
+ console.warn(
8184
+ `Warning: ${options.name} is deprecated${deprecated.message ? `: ${deprecated.message}` : ""}.`
8185
+ );
8186
+ }
8171
8187
  let explicitTarget = options.explicitTarget;
8172
8188
  let preferredTools = options.project.preferredTools;
8173
8189
  const { resolveInstallTools: resolveInstallTools2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports));
@@ -8196,7 +8212,8 @@ async function installOnePackage(options) {
8196
8212
  const tarball = await fetchPackageTarball(
8197
8213
  options.registry,
8198
8214
  options.name,
8199
- options.version
8215
+ options.version,
8216
+ options.token
8200
8217
  );
8201
8218
  const skillMarkdown = await unpackTarballToBuffer(tarball, manifest.entry);
8202
8219
  const result = await installSkillPackage({
@@ -8543,6 +8560,26 @@ async function inferEntryFromSource(source, fallback) {
8543
8560
  if (entries.includes(fallback)) return fallback;
8544
8561
  return entries.find((entry) => entry.endsWith(".md")) ?? entries.find((entry) => entry.endsWith(".mdc")) ?? fallback;
8545
8562
  }
8563
+ async function copySourceIntoSkillRoot(source, root, sourceLabel) {
8564
+ const sourceInfo = await (0, import_promises9.stat)(source);
8565
+ await (0, import_promises9.mkdir)(root, { recursive: true });
8566
+ if (sourceInfo.isDirectory()) {
8567
+ const entries = await (0, import_promises9.readdir)(source);
8568
+ for (const entry of entries) {
8569
+ await (0, import_promises9.cp)((0, import_node_path11.join)(source, entry), (0, import_node_path11.join)(root, entry), {
8570
+ recursive: true,
8571
+ force: false,
8572
+ errorOnExist: true
8573
+ });
8574
+ }
8575
+ return;
8576
+ }
8577
+ if (sourceInfo.isFile()) {
8578
+ await (0, import_promises9.cp)(source, (0, import_node_path11.join)(root, (0, import_node_path11.basename)(source)), { force: false, errorOnExist: true });
8579
+ return;
8580
+ }
8581
+ throw new Error(`Unsupported source path: ${sourceLabel}`);
8582
+ }
8546
8583
  async function latestVersionForPackage(registry, name) {
8547
8584
  const packages = await searchPackages(registry, name, 20);
8548
8585
  const exact = packages.find((pkg) => pkg.name === name);
@@ -8694,7 +8731,6 @@ async function initSkill(opts) {
8694
8731
  if (!isValidScopeName(opts.name)) throw new Error("Invalid @scope/name");
8695
8732
  const root = opts.here ? (0, import_node_process5.cwd)() : (0, import_node_path11.resolve)((0, import_node_process5.cwd)(), opts.dir ?? skillFolderName(opts.name));
8696
8733
  const cdTarget = opts.here ? null : opts.dir ?? skillFolderName(opts.name);
8697
- await (0, import_promises9.mkdir)(root, { recursive: true });
8698
8734
  const source = opts.from ? (0, import_node_path11.resolve)(opts.from) : null;
8699
8735
  const entry = source ? await inferEntryFromSource(source, opts.entry) : opts.entry;
8700
8736
  const manifest = PackageManifestSchema.parse({
@@ -8708,14 +8744,9 @@ async function initSkill(opts) {
8708
8744
  license: "Apache-2.0"
8709
8745
  });
8710
8746
  if (source) {
8711
- const sourceInfo = await (0, import_promises9.stat)(source);
8712
- if (sourceInfo.isDirectory()) {
8713
- await (0, import_promises9.cp)(source, root, { recursive: true, force: false, errorOnExist: true });
8714
- } else if (sourceInfo.isFile()) {
8715
- await (0, import_promises9.cp)(source, (0, import_node_path11.join)(root, (0, import_node_path11.basename)(source)), { force: false, errorOnExist: true });
8716
- } else {
8717
- throw new Error(`Unsupported source path: ${opts.from}`);
8718
- }
8747
+ await copySourceIntoSkillRoot(source, root, source);
8748
+ } else {
8749
+ await (0, import_promises9.mkdir)(root, { recursive: true });
8719
8750
  }
8720
8751
  await writeStarterFile((0, import_node_path11.join)(root, "aipm.manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
8721
8752
  if (!opts.from) {
@@ -8823,7 +8854,7 @@ program2.command("config").description("Show resolved AIPM CLI and project confi
8823
8854
  console.log(`Installed packages: ${data.installedPackages.length}`);
8824
8855
  console.log(`Publish guide: ${data.publishDoc}`);
8825
8856
  });
8826
- program2.command("add <package>").description("Add and install a package @scope/name[@version]").option(GLOBAL_OPTION, GLOBAL_OPTION_DESC).option("--registry <url>", "Registry base URL").option("--target <tool>", "cursor, claude, or *").option("--ci", "Non-interactive; fail if prompt needed").action(async (pkgArg, opts) => {
8857
+ program2.command("add <package>").description("Add and install a package @scope/name[@version]").option(GLOBAL_OPTION, GLOBAL_OPTION_DESC).option("--registry <url>", "Registry base URL").option("--target <tool>", "cursor, claude, or *").option("--token <token>", "Install token for private packages").option("--ci", "Non-interactive; fail if prompt needed").action(async (pkgArg, opts) => {
8827
8858
  const { name, version: requestedVersion } = parsePackageArg(pkgArg);
8828
8859
  const scope = { global: opts.global };
8829
8860
  const configRoot = resolveConfigRoot(scope);
@@ -8846,7 +8877,8 @@ program2.command("add <package>").description("Add and install a package @scope/
8846
8877
  version: version.replace(/^\^/, ""),
8847
8878
  project,
8848
8879
  explicitTarget: parseTargetFlag(opts.target),
8849
- ci: opts.ci
8880
+ ci: opts.ci,
8881
+ token: opts.token ?? process.env.AIPM_TOKEN
8850
8882
  });
8851
8883
  if (!opts.ci && !program2.opts().quiet) {
8852
8884
  await notifyCliUpdateIfNeeded(CLI_VERSION);
@@ -8871,7 +8903,7 @@ program2.command("search [query]").description("Search public registry packages"
8871
8903
  console.log(` ${meta}`);
8872
8904
  }
8873
8905
  });
8874
- program2.command("install").description("Install all packages from aipm.package.json").option(GLOBAL_OPTION, GLOBAL_OPTION_DESC).option("--registry <url>", "Registry base URL").option("--target <tool>", "cursor, claude, or *").option("--ci", "Non-interactive").action(async (opts) => {
8906
+ program2.command("install").description("Install all packages from aipm.package.json").option(GLOBAL_OPTION, GLOBAL_OPTION_DESC).option("--registry <url>", "Registry base URL").option("--target <tool>", "cursor, claude, or *").option("--token <token>", "Install token for private packages").option("--ci", "Non-interactive").action(async (opts) => {
8875
8907
  const scope = { global: opts.global };
8876
8908
  const configRoot = resolveConfigRoot(scope);
8877
8909
  const installRoot = resolveInstallRoot(scope);
@@ -8888,7 +8920,8 @@ program2.command("install").description("Install all packages from aipm.package.
8888
8920
  version: version.replace(/^\^/, ""),
8889
8921
  project,
8890
8922
  explicitTarget: target,
8891
- ci: opts.ci
8923
+ ci: opts.ci,
8924
+ token: opts.token ?? process.env.AIPM_TOKEN
8892
8925
  });
8893
8926
  }
8894
8927
  });