@agent-nexus/cli 0.1.3 → 0.1.5
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/index.js +135 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -150,7 +150,7 @@ var require_package = __commonJS({
|
|
|
150
150
|
"package.json"(exports2, module2) {
|
|
151
151
|
module2.exports = {
|
|
152
152
|
name: "@agent-nexus/cli",
|
|
153
|
-
version: "0.1.
|
|
153
|
+
version: "0.1.5",
|
|
154
154
|
description: "Official CLI for the Nexus AI agent platform.",
|
|
155
155
|
license: "MIT",
|
|
156
156
|
keywords: [
|
|
@@ -3275,6 +3275,139 @@ Examples:
|
|
|
3275
3275
|
});
|
|
3276
3276
|
}
|
|
3277
3277
|
|
|
3278
|
+
// src/commands/upgrade.ts
|
|
3279
|
+
var import_node_child_process2 = require("child_process");
|
|
3280
|
+
init_output();
|
|
3281
|
+
|
|
3282
|
+
// src/util/version-check.ts
|
|
3283
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
3284
|
+
var import_node_os2 = __toESM(require("os"));
|
|
3285
|
+
var import_node_path4 = __toESM(require("path"));
|
|
3286
|
+
var PACKAGE_NAME = "@agent-nexus/cli";
|
|
3287
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
3288
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
3289
|
+
var CACHE_FILE = import_node_path4.default.join(import_node_os2.default.homedir(), ".nexus-mcp", "version-check.json");
|
|
3290
|
+
function loadCache() {
|
|
3291
|
+
try {
|
|
3292
|
+
return JSON.parse(import_node_fs4.default.readFileSync(CACHE_FILE, "utf-8"));
|
|
3293
|
+
} catch {
|
|
3294
|
+
return null;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
function saveCache(cache) {
|
|
3298
|
+
try {
|
|
3299
|
+
const dir = import_node_path4.default.dirname(CACHE_FILE);
|
|
3300
|
+
import_node_fs4.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3301
|
+
import_node_fs4.default.writeFileSync(CACHE_FILE, JSON.stringify(cache), { mode: 384 });
|
|
3302
|
+
} catch {
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
async function fetchLatestVersion() {
|
|
3306
|
+
try {
|
|
3307
|
+
const controller = new AbortController();
|
|
3308
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
3309
|
+
const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
3310
|
+
signal: controller.signal
|
|
3311
|
+
});
|
|
3312
|
+
clearTimeout(timer);
|
|
3313
|
+
if (!res.ok) return null;
|
|
3314
|
+
const json = await res.json();
|
|
3315
|
+
return json.version ?? null;
|
|
3316
|
+
} catch {
|
|
3317
|
+
return null;
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
function compareSemver(a, b) {
|
|
3321
|
+
const pa = a.split(".").map(Number);
|
|
3322
|
+
const pb = b.split(".").map(Number);
|
|
3323
|
+
for (let i = 0; i < 3; i++) {
|
|
3324
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
3325
|
+
if (diff !== 0) return diff < 0 ? -1 : 1;
|
|
3326
|
+
}
|
|
3327
|
+
return 0;
|
|
3328
|
+
}
|
|
3329
|
+
async function checkForUpdate(currentVersion) {
|
|
3330
|
+
try {
|
|
3331
|
+
const cache = loadCache();
|
|
3332
|
+
if (cache && Date.now() - cache.lastChecked < CHECK_INTERVAL_MS) {
|
|
3333
|
+
if (compareSemver(currentVersion, cache.latestVersion) < 0) {
|
|
3334
|
+
return formatUpdateMessage(currentVersion, cache.latestVersion);
|
|
3335
|
+
}
|
|
3336
|
+
return null;
|
|
3337
|
+
}
|
|
3338
|
+
const latest = await fetchLatestVersion();
|
|
3339
|
+
if (!latest) return null;
|
|
3340
|
+
saveCache({ lastChecked: Date.now(), latestVersion: latest });
|
|
3341
|
+
if (compareSemver(currentVersion, latest) < 0) {
|
|
3342
|
+
return formatUpdateMessage(currentVersion, latest);
|
|
3343
|
+
}
|
|
3344
|
+
return null;
|
|
3345
|
+
} catch {
|
|
3346
|
+
return null;
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
function formatUpdateMessage(current, latest) {
|
|
3350
|
+
return `
|
|
3351
|
+
Update available: ${current} \u2192 ${latest}
|
|
3352
|
+
Run "npm update -g ${PACKAGE_NAME}" to update.
|
|
3353
|
+
IMPORTANT: You MUST update before running any other nexus commands. Results from an outdated CLI may be incorrect.
|
|
3354
|
+
`;
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
// src/commands/upgrade.ts
|
|
3358
|
+
var PACKAGE_NAME2 = "@agent-nexus/cli";
|
|
3359
|
+
function registerUpgradeCommand(program2) {
|
|
3360
|
+
const currentVersion = require_package().version;
|
|
3361
|
+
program2.command("upgrade").description("Upgrade the Nexus CLI to the latest version").addHelpText(
|
|
3362
|
+
"after",
|
|
3363
|
+
`
|
|
3364
|
+
Examples:
|
|
3365
|
+
$ nexus upgrade`
|
|
3366
|
+
).action(async () => {
|
|
3367
|
+
process.stderr.write(`Current version: ${color.cyan(currentVersion)}
|
|
3368
|
+
`);
|
|
3369
|
+
process.stderr.write("Checking for updates\u2026\n");
|
|
3370
|
+
const latest = await fetchLatestVersion();
|
|
3371
|
+
if (!latest) {
|
|
3372
|
+
process.stderr.write(
|
|
3373
|
+
color.red("Failed to check for updates. Please try again later.\n")
|
|
3374
|
+
);
|
|
3375
|
+
process.exitCode = 1;
|
|
3376
|
+
return;
|
|
3377
|
+
}
|
|
3378
|
+
if (compareSemver(currentVersion, latest) >= 0) {
|
|
3379
|
+
printSuccess(
|
|
3380
|
+
`Already up-to-date (${currentVersion}).`,
|
|
3381
|
+
{ version: currentVersion }
|
|
3382
|
+
);
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
process.stderr.write(
|
|
3386
|
+
`Upgrading ${color.yellow(currentVersion)} \u2192 ${color.green(latest)}\u2026
|
|
3387
|
+
`
|
|
3388
|
+
);
|
|
3389
|
+
try {
|
|
3390
|
+
(0, import_node_child_process2.execSync)(`npm install -g ${PACKAGE_NAME2}@latest`, {
|
|
3391
|
+
stdio: "inherit"
|
|
3392
|
+
});
|
|
3393
|
+
printSuccess(
|
|
3394
|
+
`Successfully upgraded to ${latest}.`,
|
|
3395
|
+
{ from: currentVersion, to: latest }
|
|
3396
|
+
);
|
|
3397
|
+
} catch {
|
|
3398
|
+
process.stderr.write(
|
|
3399
|
+
color.red(
|
|
3400
|
+
`
|
|
3401
|
+
Upgrade failed. Try running manually:
|
|
3402
|
+
npm install -g ${PACKAGE_NAME2}@latest
|
|
3403
|
+
`
|
|
3404
|
+
)
|
|
3405
|
+
);
|
|
3406
|
+
process.exitCode = 1;
|
|
3407
|
+
}
|
|
3408
|
+
});
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3278
3411
|
// src/commands/version.ts
|
|
3279
3412
|
init_output();
|
|
3280
3413
|
function registerVersionCommands(program2) {
|
|
@@ -4048,83 +4181,6 @@ Examples:
|
|
|
4048
4181
|
|
|
4049
4182
|
// src/index.ts
|
|
4050
4183
|
init_output();
|
|
4051
|
-
|
|
4052
|
-
// src/util/version-check.ts
|
|
4053
|
-
var import_node_fs4 = __toESM(require("fs"));
|
|
4054
|
-
var import_node_os2 = __toESM(require("os"));
|
|
4055
|
-
var import_node_path4 = __toESM(require("path"));
|
|
4056
|
-
var PACKAGE_NAME = "@agent-nexus/cli";
|
|
4057
|
-
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
4058
|
-
var FETCH_TIMEOUT_MS = 3e3;
|
|
4059
|
-
var CACHE_FILE = import_node_path4.default.join(import_node_os2.default.homedir(), ".nexus-mcp", "version-check.json");
|
|
4060
|
-
function loadCache() {
|
|
4061
|
-
try {
|
|
4062
|
-
return JSON.parse(import_node_fs4.default.readFileSync(CACHE_FILE, "utf-8"));
|
|
4063
|
-
} catch {
|
|
4064
|
-
return null;
|
|
4065
|
-
}
|
|
4066
|
-
}
|
|
4067
|
-
function saveCache(cache) {
|
|
4068
|
-
try {
|
|
4069
|
-
const dir = import_node_path4.default.dirname(CACHE_FILE);
|
|
4070
|
-
import_node_fs4.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
4071
|
-
import_node_fs4.default.writeFileSync(CACHE_FILE, JSON.stringify(cache), { mode: 384 });
|
|
4072
|
-
} catch {
|
|
4073
|
-
}
|
|
4074
|
-
}
|
|
4075
|
-
async function fetchLatestVersion() {
|
|
4076
|
-
try {
|
|
4077
|
-
const controller = new AbortController();
|
|
4078
|
-
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
4079
|
-
const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
4080
|
-
signal: controller.signal
|
|
4081
|
-
});
|
|
4082
|
-
clearTimeout(timer);
|
|
4083
|
-
if (!res.ok) return null;
|
|
4084
|
-
const json = await res.json();
|
|
4085
|
-
return json.version ?? null;
|
|
4086
|
-
} catch {
|
|
4087
|
-
return null;
|
|
4088
|
-
}
|
|
4089
|
-
}
|
|
4090
|
-
function compareSemver(a, b) {
|
|
4091
|
-
const pa = a.split(".").map(Number);
|
|
4092
|
-
const pb = b.split(".").map(Number);
|
|
4093
|
-
for (let i = 0; i < 3; i++) {
|
|
4094
|
-
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
4095
|
-
if (diff !== 0) return diff < 0 ? -1 : 1;
|
|
4096
|
-
}
|
|
4097
|
-
return 0;
|
|
4098
|
-
}
|
|
4099
|
-
async function checkForUpdate(currentVersion) {
|
|
4100
|
-
try {
|
|
4101
|
-
const cache = loadCache();
|
|
4102
|
-
if (cache && Date.now() - cache.lastChecked < CHECK_INTERVAL_MS) {
|
|
4103
|
-
if (compareSemver(currentVersion, cache.latestVersion) < 0) {
|
|
4104
|
-
return formatUpdateMessage(currentVersion, cache.latestVersion);
|
|
4105
|
-
}
|
|
4106
|
-
return null;
|
|
4107
|
-
}
|
|
4108
|
-
const latest = await fetchLatestVersion();
|
|
4109
|
-
if (!latest) return null;
|
|
4110
|
-
saveCache({ lastChecked: Date.now(), latestVersion: latest });
|
|
4111
|
-
if (compareSemver(currentVersion, latest) < 0) {
|
|
4112
|
-
return formatUpdateMessage(currentVersion, latest);
|
|
4113
|
-
}
|
|
4114
|
-
return null;
|
|
4115
|
-
} catch {
|
|
4116
|
-
return null;
|
|
4117
|
-
}
|
|
4118
|
-
}
|
|
4119
|
-
function formatUpdateMessage(current, latest) {
|
|
4120
|
-
return `
|
|
4121
|
-
Update available: ${current} \u2192 ${latest}
|
|
4122
|
-
Run "npm update -g ${PACKAGE_NAME}" to update.
|
|
4123
|
-
IMPORTANT: You MUST update before running any other nexus commands. Results from an outdated CLI may be incorrect.
|
|
4124
|
-
`;
|
|
4125
|
-
}
|
|
4126
|
-
|
|
4127
|
-
// src/index.ts
|
|
4128
4184
|
var { version: VERSION } = require_package();
|
|
4129
4185
|
var program = new import_commander.Command().name("nexus").description("Official CLI for the Nexus AI agent platform").version(VERSION, "-v, --version").option("--json", "Output as JSON").option("--api-key <key>", "Override API key for this invocation").option("--base-url <url>", "Override API base URL").hook("preAction", (thisCommand) => {
|
|
4130
4186
|
const opts = thisCommand.optsWithGlobals();
|
|
@@ -4156,6 +4212,7 @@ registerExternalToolCommands(program);
|
|
|
4156
4212
|
registerPromptAssistantCommands(program);
|
|
4157
4213
|
registerModelCommands(program);
|
|
4158
4214
|
registerPhoneNumberCommands(program);
|
|
4215
|
+
registerUpgradeCommand(program);
|
|
4159
4216
|
if (process.argv.length <= 2) {
|
|
4160
4217
|
program.help();
|
|
4161
4218
|
}
|