@agentprojectcontext/apx 1.22.0 → 1.22.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentprojectcontext/apx",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
4
4
  "description": "APX — unified CLI + daemon for the Agent Project Context (APC) standard.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,8 +17,11 @@ function isNewer(cur, lat) {
17
17
  function hasPnpmGlobal() {
18
18
  const r = spawnSync("pnpm", ["--version"], { encoding: "utf8", stdio: "pipe" });
19
19
  if (r.status !== 0) return false;
20
- // pnpm needs PNPM_HOME configured to manage global packages
21
- const check = spawnSync("pnpm", ["root", "-g"], { encoding: "utf8", stdio: "pipe" });
20
+ // `pnpm add -g` needs a configured global *bin* directory (PNPM_HOME / the
21
+ // result of `pnpm setup`). `pnpm root -g` succeeds even without it, so probe
22
+ // `pnpm bin -g` instead — it fails with ERR_PNPM_NO_GLOBAL_BIN_DIR when the
23
+ // global bin directory is missing.
24
+ const check = spawnSync("pnpm", ["bin", "-g"], { encoding: "utf8", stdio: "pipe" });
22
25
  return check.status === 0 && !!check.stdout?.trim();
23
26
  }
24
27
 
@@ -62,15 +65,25 @@ export async function cmdUpdate(args, currentVersion) {
62
65
  console.log("stopped.");
63
66
  }
64
67
 
65
- // Prefer pnpm global if configured, fall back to npm.
66
- const usePnpm = hasPnpmGlobal();
67
- const pm = usePnpm ? "pnpm" : "npm";
68
- const installArgs = usePnpm
69
- ? ["add", "-g", `${PACKAGE_NAME}@${latest}`]
70
- : ["install", "-g", `${PACKAGE_NAME}@${latest}`];
71
-
72
- console.log(`\nInstalling ${PACKAGE_NAME}@${latest} via ${pm}...\n`);
73
- const result = spawnSync(pm, installArgs, { stdio: "inherit" });
68
+ // Pick a package manager that can actually install global binaries. Prefer
69
+ // pnpm only when its global bin directory is configured; otherwise npm. If
70
+ // the first attempt fails, fall back to the other so a misconfigured pnpm
71
+ // never blocks the update.
72
+ const pnpmStep = ["pnpm", ["add", "-g", `${PACKAGE_NAME}@${latest}`]];
73
+ const npmStep = ["npm", ["install", "-g", `${PACKAGE_NAME}@${latest}`]];
74
+ const steps = hasPnpmGlobal() ? [pnpmStep, npmStep] : [npmStep];
75
+
76
+ let result;
77
+ for (let i = 0; i < steps.length; i++) {
78
+ const [pm, installArgs] = steps[i];
79
+ console.log(`\nInstalling ${PACKAGE_NAME}@${latest} via ${pm}...\n`);
80
+ result = spawnSync(pm, installArgs, { stdio: "inherit" });
81
+ if (result.status === 0) break;
82
+ const next = steps[i + 1];
83
+ if (next) {
84
+ console.log(`\n⚠️ ${pm} install failed — retrying with ${next[0]}...`);
85
+ }
86
+ }
74
87
 
75
88
  if (result.status !== 0) {
76
89
  console.error(`\n❌ Update failed (exit ${result.status})`);