@agent-nexus/cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -16
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ var require_package = __commonJS({
166
166
  "package.json"(exports2, module2) {
167
167
  module2.exports = {
168
168
  name: "@agent-nexus/cli",
169
- version: "0.1.7",
169
+ version: "0.1.8",
170
170
  description: "Official CLI for the Nexus AI agent platform.",
171
171
  license: "MIT",
172
172
  keywords: [
@@ -529,9 +529,9 @@ async function resolveInputValue(value) {
529
529
  return readStdin();
530
530
  }
531
531
  try {
532
- const fs5 = await import("fs");
533
- if (fs5.existsSync(value) && fs5.statSync(value).isFile()) {
534
- return fs5.readFileSync(value, "utf-8").trim();
532
+ const fs6 = await import("fs");
533
+ if (fs6.existsSync(value) && fs6.statSync(value).isFile()) {
534
+ return fs6.readFileSync(value, "utf-8").trim();
535
535
  }
536
536
  } catch {
537
537
  }
@@ -546,8 +546,8 @@ async function resolveBody(raw) {
546
546
  jsonStr = await readStdin();
547
547
  } else if (raw.endsWith(".json")) {
548
548
  try {
549
- const fs5 = await import("fs/promises");
550
- jsonStr = (await fs5.readFile(raw, "utf-8")).trim();
549
+ const fs6 = await import("fs/promises");
550
+ jsonStr = (await fs6.readFile(raw, "utf-8")).trim();
551
551
  } catch (err) {
552
552
  throw new Error(
553
553
  `Could not read file "${raw}": ${err instanceof Error ? err.message : String(err)}`
@@ -9357,8 +9357,42 @@ Examples:
9357
9357
  var import_node_child_process2 = require("child_process");
9358
9358
  init_output();
9359
9359
 
9360
- // src/util/version-check.ts
9360
+ // src/util/package-manager.ts
9361
9361
  var import_node_fs4 = __toESM(require("fs"));
9362
+ function detectPackageManager() {
9363
+ try {
9364
+ const resolved = import_node_fs4.default.realpathSync(process.argv[1]).replace(/\\/g, "/");
9365
+ if (/[/]\.?pnpm[/]/.test(resolved)) return "pnpm";
9366
+ if (/[/]\.yarn[/]/.test(resolved)) return "yarn";
9367
+ } catch {
9368
+ }
9369
+ return "npm";
9370
+ }
9371
+ function getGlobalInstallCommand(pkg, tag = "latest") {
9372
+ const pm = detectPackageManager();
9373
+ switch (pm) {
9374
+ case "pnpm":
9375
+ return `pnpm add -g ${pkg}@${tag}`;
9376
+ case "yarn":
9377
+ return `yarn global add ${pkg}@${tag}`;
9378
+ default:
9379
+ return `npm install -g ${pkg}@${tag}`;
9380
+ }
9381
+ }
9382
+ function getGlobalUpdateHint(pkg) {
9383
+ const pm = detectPackageManager();
9384
+ switch (pm) {
9385
+ case "pnpm":
9386
+ return `pnpm update -g ${pkg}`;
9387
+ case "yarn":
9388
+ return `yarn global upgrade ${pkg}`;
9389
+ default:
9390
+ return `npm update -g ${pkg}`;
9391
+ }
9392
+ }
9393
+
9394
+ // src/util/version-check.ts
9395
+ var import_node_fs5 = __toESM(require("fs"));
9362
9396
  var import_node_os2 = __toESM(require("os"));
9363
9397
  var import_node_path4 = __toESM(require("path"));
9364
9398
  var PACKAGE_NAME = "@agent-nexus/cli";
@@ -9367,7 +9401,7 @@ var FETCH_TIMEOUT_MS = 3e3;
9367
9401
  var CACHE_FILE = import_node_path4.default.join(import_node_os2.default.homedir(), ".nexus-mcp", "version-check.json");
9368
9402
  function loadCache() {
9369
9403
  try {
9370
- return JSON.parse(import_node_fs4.default.readFileSync(CACHE_FILE, "utf-8"));
9404
+ return JSON.parse(import_node_fs5.default.readFileSync(CACHE_FILE, "utf-8"));
9371
9405
  } catch {
9372
9406
  return null;
9373
9407
  }
@@ -9375,8 +9409,8 @@ function loadCache() {
9375
9409
  function saveCache(cache) {
9376
9410
  try {
9377
9411
  const dir = import_node_path4.default.dirname(CACHE_FILE);
9378
- import_node_fs4.default.mkdirSync(dir, { recursive: true, mode: 448 });
9379
- import_node_fs4.default.writeFileSync(CACHE_FILE, JSON.stringify(cache), { mode: 384 });
9412
+ import_node_fs5.default.mkdirSync(dir, { recursive: true, mode: 448 });
9413
+ import_node_fs5.default.writeFileSync(CACHE_FILE, JSON.stringify(cache), { mode: 384 });
9380
9414
  } catch {
9381
9415
  }
9382
9416
  }
@@ -9427,7 +9461,7 @@ async function checkForUpdate(currentVersion) {
9427
9461
  function formatUpdateMessage(current, latest) {
9428
9462
  return `
9429
9463
  Update available: ${current} \u2192 ${latest}
9430
- Run "npm update -g ${PACKAGE_NAME}" to update.
9464
+ Run "${getGlobalUpdateHint(PACKAGE_NAME)}" to update.
9431
9465
  IMPORTANT: You MUST update before running any other nexus commands. Results from an outdated CLI may be incorrect.
9432
9466
  `;
9433
9467
  }
@@ -9450,7 +9484,7 @@ async function autoUpdate(currentVersion) {
9450
9484
  process.stderr.write(`
9451
9485
  Auto-updating: ${currentVersion} \u2192 ${latest}\u2026
9452
9486
  `);
9453
- execSync2(`npm install -g ${PACKAGE_NAME}@latest`, {
9487
+ execSync2(getGlobalInstallCommand(PACKAGE_NAME), {
9454
9488
  stdio: "inherit"
9455
9489
  });
9456
9490
  return `
@@ -9484,16 +9518,16 @@ Examples:
9484
9518
  process.stderr.write(`Upgrading ${color.yellow(currentVersion)} \u2192 ${color.green(latest)}\u2026
9485
9519
  `);
9486
9520
  try {
9487
- (0, import_node_child_process2.execSync)(`npm install -g ${PACKAGE_NAME2}@latest`, {
9488
- stdio: "inherit"
9489
- });
9521
+ const installCmd = getGlobalInstallCommand(PACKAGE_NAME2);
9522
+ (0, import_node_child_process2.execSync)(installCmd, { stdio: "inherit" });
9490
9523
  printSuccess(`Successfully upgraded to ${latest}.`, { from: currentVersion, to: latest });
9491
9524
  } catch {
9525
+ const fallbackCmd = getGlobalInstallCommand(PACKAGE_NAME2);
9492
9526
  process.stderr.write(
9493
9527
  color.red(
9494
9528
  `
9495
9529
  Upgrade failed. Try running manually:
9496
- npm install -g ${PACKAGE_NAME2}@latest
9530
+ ${fallbackCmd}
9497
9531
  `
9498
9532
  )
9499
9533
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-nexus/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Official CLI for the Nexus AI agent platform.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "commander": "^13.0.0",
33
- "@agent-nexus/sdk": "0.1.5"
33
+ "@agent-nexus/sdk": "0.1.6"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "24.6.2",