agent-package-manager 0.4.1 → 0.4.2

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/cli/index.js CHANGED
@@ -4790,6 +4790,7 @@ async function runSync(input, projectDir) {
4790
4790
  import { existsSync as existsSync6 } from "fs";
4791
4791
  import { mkdir as mkdir5, rm as rm4 } from "fs/promises";
4792
4792
  import { join as join8 } from "path";
4793
+ import semver3 from "semver";
4793
4794
  async function runUpdate(input, projectDir) {
4794
4795
  const config = await readProjectConfig(projectDir);
4795
4796
  const lock = await readLockFile(projectDir);
@@ -4863,6 +4864,7 @@ async function runUpdate(input, projectDir) {
4863
4864
  console.log(JSON.stringify({ updates, dryRun: true }, null, 2));
4864
4865
  return;
4865
4866
  }
4867
+ const installedDeps = [];
4866
4868
  for (const u of updates) {
4867
4869
  const pkg = config.packages[u.package];
4868
4870
  const registryName = pkg.registry || "default";
@@ -4877,20 +4879,102 @@ async function runUpdate(input, projectDir) {
4877
4879
  await mkdir5(installDir, { recursive: true });
4878
4880
  await extractPackageAtCommit(repoDir, resolved.commit, resolved.path, installDir);
4879
4881
  const contentHash = await hashDirectory(installDir);
4882
+ const pkgManifest = await readPackageManifest(installDir);
4883
+ const entrypoint = pkgManifest?.entrypoint ?? DEFAULT_ENTRYPOINT;
4880
4884
  config.packages[u.package].version = u.toVersion;
4881
4885
  lock.packages[u.package] = {
4882
4886
  ...lock.packages[u.package],
4883
4887
  version: u.toVersion,
4884
4888
  tag: `${u.package}/v${u.toVersion}`,
4885
4889
  commit: resolved.commit,
4886
- contentHash
4890
+ contentHash,
4891
+ entrypoint: `${config.install.modulesDir}/${u.package}/${entrypoint}`
4887
4892
  };
4888
4893
  log.success(`Updated ${u.package} to ${u.toVersion}`);
4894
+ if (pkgManifest?.dependencies) {
4895
+ const deps = await installDependencies2(
4896
+ projectDir,
4897
+ config,
4898
+ lock,
4899
+ registry,
4900
+ registryName,
4901
+ repoDir,
4902
+ manifest,
4903
+ pkgManifest.dependencies,
4904
+ /* @__PURE__ */ new Set([u.package])
4905
+ );
4906
+ installedDeps.push(...deps);
4907
+ }
4889
4908
  }
4890
4909
  lock.generatedAt = (/* @__PURE__ */ new Date()).toISOString();
4891
4910
  await writeProjectConfig(projectDir, config);
4892
4911
  await writeLockFile(projectDir, lock);
4893
- console.log(JSON.stringify({ updates, dryRun: false }, null, 2));
4912
+ console.log(JSON.stringify({ updates, installedDeps, dryRun: false }, null, 2));
4913
+ }
4914
+ async function installDependencies2(projectDir, config, lock, registry, registryName, repoDir, manifest, dependencies, resolving) {
4915
+ const installed = [];
4916
+ for (const [depId, range] of Object.entries(dependencies)) {
4917
+ if (resolving.has(depId)) {
4918
+ const chain = [...resolving, depId].join(" \u2192 ");
4919
+ throw new Error(`Circular dependency detected: ${chain}`);
4920
+ }
4921
+ const existing = config.packages[depId];
4922
+ if (existing && semver3.satisfies(existing.version, range)) {
4923
+ log.debug(`Dependency ${depId}@${existing.version} already satisfies ${range}`);
4924
+ continue;
4925
+ }
4926
+ const resolvedVersion = resolveVersionRange(manifest, depId, range);
4927
+ if (!resolvedVersion) {
4928
+ throw new Error(
4929
+ `No version of "${depId}" satisfies range "${range}". Available: ${Object.keys(manifest.packages[depId]?.versions ?? {}).join(", ") || "(none)"}`
4930
+ );
4931
+ }
4932
+ log.step(`Dependency: ${depId}@${resolvedVersion} (required: ${range})`);
4933
+ resolving.add(depId);
4934
+ const resolved = resolveVersionFromManifest(manifest, depId, resolvedVersion);
4935
+ const installDir = join8(projectDir, config.install.modulesDir, depId);
4936
+ if (existsSync6(installDir)) {
4937
+ await rm4(installDir, { recursive: true, force: true });
4938
+ }
4939
+ await mkdir5(installDir, { recursive: true });
4940
+ await extractPackageAtCommit(repoDir, resolved.commit, resolved.path, installDir);
4941
+ const contentHash = await hashDirectory(installDir);
4942
+ const pkgManifest = await readPackageManifest(installDir);
4943
+ const entrypoint = pkgManifest?.entrypoint ?? DEFAULT_ENTRYPOINT;
4944
+ config.packages[depId] = {
4945
+ registry: registryName,
4946
+ path: resolved.path,
4947
+ version: resolvedVersion
4948
+ };
4949
+ lock.packages[depId] = {
4950
+ registry: registryName,
4951
+ path: resolved.path,
4952
+ version: resolvedVersion,
4953
+ tag: `${depId}/v${resolvedVersion}`,
4954
+ commit: resolved.commit,
4955
+ contentHash,
4956
+ installedTo: `${config.install.modulesDir}/${depId}`,
4957
+ entrypoint: `${config.install.modulesDir}/${depId}/${entrypoint}`
4958
+ };
4959
+ log.success(`Installed dependency ${depId}@${resolvedVersion}`);
4960
+ installed.push(depId);
4961
+ if (pkgManifest?.dependencies) {
4962
+ const transitive = await installDependencies2(
4963
+ projectDir,
4964
+ config,
4965
+ lock,
4966
+ registry,
4967
+ registryName,
4968
+ repoDir,
4969
+ manifest,
4970
+ pkgManifest.dependencies,
4971
+ resolving
4972
+ );
4973
+ installed.push(...transitive);
4974
+ }
4975
+ resolving.delete(depId);
4976
+ }
4977
+ return installed;
4894
4978
  }
4895
4979
  function parseSemver(v) {
4896
4980
  const m = v.match(/^(\d+)\.(\d+)\.(\d+)/);