@agent-nexus/cli 0.1.3 → 0.1.6
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/README.md +667 -0
- package/dist/index.js +591 -117
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ var output_exports = {};
|
|
|
38
38
|
__export(output_exports, {
|
|
39
39
|
color: () => color,
|
|
40
40
|
isJsonMode: () => isJsonMode,
|
|
41
|
+
printContextBanner: () => printContextBanner,
|
|
41
42
|
printList: () => printList,
|
|
42
43
|
printPaginationMeta: () => printPaginationMeta,
|
|
43
44
|
printRecord: () => printRecord,
|
|
@@ -116,6 +117,13 @@ function printPaginationMeta(meta) {
|
|
|
116
117
|
${parts.join(" \xB7 ")}`));
|
|
117
118
|
}
|
|
118
119
|
}
|
|
120
|
+
function printContextBanner(resolved) {
|
|
121
|
+
if (_jsonMode) return;
|
|
122
|
+
if (!process.stderr.isTTY) return;
|
|
123
|
+
const orgPart = resolved.profile.orgName ? ` (${resolved.profile.orgName})` : "";
|
|
124
|
+
const line = `\u25B8 ${resolved.name}${orgPart} \xB7 ${SOURCE_LABELS[resolved.source]}`;
|
|
125
|
+
process.stderr.write(color.dim(line) + "\n");
|
|
126
|
+
}
|
|
119
127
|
function printList(data, meta, columns) {
|
|
120
128
|
if (_jsonMode) {
|
|
121
129
|
console.log(JSON.stringify({ data, meta }, null, 2));
|
|
@@ -126,7 +134,7 @@ function printList(data, meta, columns) {
|
|
|
126
134
|
printPaginationMeta(meta);
|
|
127
135
|
}
|
|
128
136
|
}
|
|
129
|
-
var _jsonMode, NO_COLOR2, color;
|
|
137
|
+
var _jsonMode, NO_COLOR2, color, SOURCE_LABELS;
|
|
130
138
|
var init_output = __esm({
|
|
131
139
|
"src/output.ts"() {
|
|
132
140
|
"use strict";
|
|
@@ -142,6 +150,14 @@ var init_output = __esm({
|
|
|
142
150
|
yellow: (t) => c2("33", t),
|
|
143
151
|
cyan: (t) => c2("36", t)
|
|
144
152
|
};
|
|
153
|
+
SOURCE_LABELS = {
|
|
154
|
+
flag: "flag override",
|
|
155
|
+
env: "env",
|
|
156
|
+
directory: ".nexusrc",
|
|
157
|
+
active: "active",
|
|
158
|
+
default: "default",
|
|
159
|
+
override: "api-key override"
|
|
160
|
+
};
|
|
145
161
|
}
|
|
146
162
|
});
|
|
147
163
|
|
|
@@ -150,7 +166,7 @@ var require_package = __commonJS({
|
|
|
150
166
|
"package.json"(exports2, module2) {
|
|
151
167
|
module2.exports = {
|
|
152
168
|
name: "@agent-nexus/cli",
|
|
153
|
-
version: "0.1.
|
|
169
|
+
version: "0.1.6",
|
|
154
170
|
description: "Official CLI for the Nexus AI agent platform.",
|
|
155
171
|
license: "MIT",
|
|
156
172
|
keywords: [
|
|
@@ -240,12 +256,32 @@ var URL_MAP = {
|
|
|
240
256
|
};
|
|
241
257
|
var CONFIG_DIR = import_node_path.default.join(import_node_os.default.homedir(), ".nexus-mcp");
|
|
242
258
|
var CONFIG_FILE = import_node_path.default.join(CONFIG_DIR, "config.json");
|
|
259
|
+
var NEXUSRC_FILENAME = ".nexusrc";
|
|
260
|
+
var PROFILE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,31}$/;
|
|
243
261
|
function loadConfig() {
|
|
244
262
|
try {
|
|
245
263
|
const raw = import_node_fs.default.readFileSync(CONFIG_FILE, "utf-8");
|
|
246
|
-
|
|
264
|
+
const parsed = JSON.parse(raw);
|
|
265
|
+
if ("profiles" in parsed && typeof parsed.profiles === "object") {
|
|
266
|
+
return parsed;
|
|
267
|
+
}
|
|
268
|
+
const v1 = parsed;
|
|
269
|
+
if (v1.apiKey) {
|
|
270
|
+
const migrated = {
|
|
271
|
+
activeProfile: "default",
|
|
272
|
+
profiles: {
|
|
273
|
+
default: {
|
|
274
|
+
apiKey: v1.apiKey,
|
|
275
|
+
...v1.baseUrl ? { baseUrl: v1.baseUrl } : {}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
saveConfig(migrated);
|
|
280
|
+
return migrated;
|
|
281
|
+
}
|
|
282
|
+
return emptyConfig();
|
|
247
283
|
} catch {
|
|
248
|
-
return
|
|
284
|
+
return emptyConfig();
|
|
249
285
|
}
|
|
250
286
|
}
|
|
251
287
|
function saveConfig(config) {
|
|
@@ -260,27 +296,159 @@ function clearConfig() {
|
|
|
260
296
|
} catch {
|
|
261
297
|
}
|
|
262
298
|
}
|
|
299
|
+
function emptyConfig() {
|
|
300
|
+
return { activeProfile: "", profiles: {} };
|
|
301
|
+
}
|
|
302
|
+
function getProfile(name) {
|
|
303
|
+
return loadConfig().profiles[name];
|
|
304
|
+
}
|
|
305
|
+
function saveProfile(name, profile) {
|
|
306
|
+
const config = loadConfig();
|
|
307
|
+
config.profiles[name] = profile;
|
|
308
|
+
if (!config.activeProfile || Object.keys(config.profiles).length === 1) {
|
|
309
|
+
config.activeProfile = name;
|
|
310
|
+
}
|
|
311
|
+
saveConfig(config);
|
|
312
|
+
}
|
|
313
|
+
function removeProfile(name) {
|
|
314
|
+
const config = loadConfig();
|
|
315
|
+
if (!(name in config.profiles)) return false;
|
|
316
|
+
delete config.profiles[name];
|
|
317
|
+
if (config.activeProfile === name) {
|
|
318
|
+
const remaining = Object.keys(config.profiles);
|
|
319
|
+
config.activeProfile = remaining[0] ?? "";
|
|
320
|
+
}
|
|
321
|
+
saveConfig(config);
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
function setActiveProfile(name) {
|
|
325
|
+
const config = loadConfig();
|
|
326
|
+
if (!(name in config.profiles)) {
|
|
327
|
+
const available = Object.keys(config.profiles).join(", ");
|
|
328
|
+
throw new Error(
|
|
329
|
+
`Profile "${name}" not found.` + (available ? ` Available: ${available}. Run: nexus auth list` : " Run: nexus auth login")
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
config.activeProfile = name;
|
|
333
|
+
saveConfig(config);
|
|
334
|
+
}
|
|
335
|
+
function listProfiles() {
|
|
336
|
+
const config = loadConfig();
|
|
337
|
+
return { profiles: config.profiles, activeProfile: config.activeProfile };
|
|
338
|
+
}
|
|
339
|
+
function validateProfileName(name) {
|
|
340
|
+
if (!PROFILE_NAME_RE.test(name)) {
|
|
341
|
+
return `Invalid profile name "${name}". Use lowercase letters, numbers, hyphens, underscores (max 32 chars, must start with alphanumeric).`;
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
function slugifyProfileName(input) {
|
|
346
|
+
return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "default";
|
|
347
|
+
}
|
|
348
|
+
function findNexusRc(startDir = process.cwd()) {
|
|
349
|
+
let dir = import_node_path.default.resolve(startDir);
|
|
350
|
+
const root = import_node_path.default.parse(dir).root;
|
|
351
|
+
while (true) {
|
|
352
|
+
const rcPath = import_node_path.default.join(dir, NEXUSRC_FILENAME);
|
|
353
|
+
try {
|
|
354
|
+
const raw = import_node_fs.default.readFileSync(rcPath, "utf-8");
|
|
355
|
+
const parsed = JSON.parse(raw);
|
|
356
|
+
if (parsed.profile && typeof parsed.profile === "string") {
|
|
357
|
+
return { profile: parsed.profile, rcPath };
|
|
358
|
+
}
|
|
359
|
+
} catch {
|
|
360
|
+
}
|
|
361
|
+
if (dir === root) break;
|
|
362
|
+
dir = import_node_path.default.dirname(dir);
|
|
363
|
+
}
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
function writeNexusRc(dir, profile) {
|
|
367
|
+
const rcPath = import_node_path.default.join(dir, NEXUSRC_FILENAME);
|
|
368
|
+
import_node_fs.default.writeFileSync(rcPath, JSON.stringify({ profile }, null, 2) + "\n");
|
|
369
|
+
}
|
|
370
|
+
function removeNexusRc(dir) {
|
|
371
|
+
const rcPath = import_node_path.default.join(dir, NEXUSRC_FILENAME);
|
|
372
|
+
try {
|
|
373
|
+
import_node_fs.default.unlinkSync(rcPath);
|
|
374
|
+
return true;
|
|
375
|
+
} catch {
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function resolveProfile(opts) {
|
|
380
|
+
const directKey = opts?.apiKey || process.env.NEXUS_API_KEY;
|
|
381
|
+
if (directKey) {
|
|
382
|
+
return {
|
|
383
|
+
name: "override",
|
|
384
|
+
profile: {
|
|
385
|
+
apiKey: directKey,
|
|
386
|
+
baseUrl: opts?.baseUrl || process.env.NEXUS_BASE_URL
|
|
387
|
+
},
|
|
388
|
+
source: "override"
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const config = loadConfig();
|
|
392
|
+
const profileNames = Object.keys(config.profiles);
|
|
393
|
+
const lookup = (name, source, rcPath) => {
|
|
394
|
+
const profile = config.profiles[name];
|
|
395
|
+
if (!profile) {
|
|
396
|
+
const available = profileNames.join(", ");
|
|
397
|
+
const sourceHint = source === "flag" ? `(from --profile flag)` : source === "env" ? `(from NEXUS_PROFILE env)` : source === "directory" ? `(from .nexusrc at ${rcPath})` : source === "active" ? `(active profile)` : `(default profile)`;
|
|
398
|
+
throw new Error(
|
|
399
|
+
`Profile "${name}" ${sourceHint} not found.` + (available ? ` Available: ${available}. Run: nexus auth list` : " No profiles configured. Run: nexus auth login")
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
return { name, profile, source, rcPath };
|
|
403
|
+
};
|
|
404
|
+
if (opts?.profile) {
|
|
405
|
+
return lookup(opts.profile, "flag");
|
|
406
|
+
}
|
|
407
|
+
if (process.env.NEXUS_PROFILE) {
|
|
408
|
+
return lookup(process.env.NEXUS_PROFILE, "env");
|
|
409
|
+
}
|
|
410
|
+
const rc = findNexusRc();
|
|
411
|
+
if (rc) {
|
|
412
|
+
return lookup(rc.profile, "directory", rc.rcPath);
|
|
413
|
+
}
|
|
414
|
+
if (config.activeProfile && config.profiles[config.activeProfile]) {
|
|
415
|
+
return lookup(config.activeProfile, "active");
|
|
416
|
+
}
|
|
417
|
+
if (config.profiles["default"]) {
|
|
418
|
+
return lookup("default", "default");
|
|
419
|
+
}
|
|
420
|
+
if (profileNames.length > 0) {
|
|
421
|
+
throw new Error(
|
|
422
|
+
`No active profile set. Available: ${profileNames.join(", ")}.
|
|
423
|
+
Run: nexus auth switch <profile>`
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
throw new Error("No profiles configured. Run:\n nexus auth login");
|
|
427
|
+
}
|
|
428
|
+
function resolveApiKey(override) {
|
|
429
|
+
if (override) return override;
|
|
430
|
+
return resolveProfile().profile.apiKey;
|
|
431
|
+
}
|
|
263
432
|
function resolveBaseUrl(override) {
|
|
264
433
|
if (override) return override;
|
|
265
434
|
if (process.env.NEXUS_BASE_URL) return process.env.NEXUS_BASE_URL;
|
|
266
|
-
|
|
267
|
-
|
|
435
|
+
try {
|
|
436
|
+
const resolved = resolveProfile();
|
|
437
|
+
if (resolved.profile.baseUrl) return resolved.profile.baseUrl;
|
|
438
|
+
} catch {
|
|
439
|
+
}
|
|
268
440
|
const env = process.env.NEXUS_ENV ?? "production";
|
|
269
441
|
return URL_MAP[env] ?? URL_MAP.production;
|
|
270
442
|
}
|
|
271
|
-
function resolveApiKey(override) {
|
|
272
|
-
if (override) return override;
|
|
273
|
-
if (process.env.NEXUS_API_KEY) return process.env.NEXUS_API_KEY;
|
|
274
|
-
const config = loadConfig();
|
|
275
|
-
if (config.apiKey) return config.apiKey;
|
|
276
|
-
throw new Error("No API key found. Set NEXUS_API_KEY or run:\n nexus auth login");
|
|
277
|
-
}
|
|
278
443
|
|
|
279
444
|
// src/client.ts
|
|
445
|
+
var _lastResolved = null;
|
|
280
446
|
function createClient(opts) {
|
|
447
|
+
const resolved = resolveProfile(opts);
|
|
448
|
+
_lastResolved = resolved;
|
|
281
449
|
return new import_sdk.NexusClient({
|
|
282
|
-
apiKey:
|
|
283
|
-
baseUrl: resolveBaseUrl(opts?.baseUrl)
|
|
450
|
+
apiKey: resolved.profile.apiKey,
|
|
451
|
+
baseUrl: resolved.profile.baseUrl ?? resolveBaseUrl(opts?.baseUrl)
|
|
284
452
|
});
|
|
285
453
|
}
|
|
286
454
|
|
|
@@ -861,20 +1029,21 @@ var import_promises = __toESM(require("readline/promises"));
|
|
|
861
1029
|
init_output();
|
|
862
1030
|
var SETTINGS_URL = "https://app.nexusgpt.io/app/settings/api-keys";
|
|
863
1031
|
function registerAuthCommands(program2) {
|
|
864
|
-
const auth = program2.command("auth").description("Manage authentication");
|
|
865
|
-
auth.command("login").description("Authenticate with the Nexus API").option("--api-key <key>", "API key (skip interactive prompt)").option("--env <env>", "Environment: dev or production", "production").addHelpText(
|
|
1032
|
+
const auth = program2.command("auth").description("Manage authentication and profiles");
|
|
1033
|
+
auth.command("login").description("Authenticate with the Nexus API and create a profile").option("--api-key <key>", "API key (skip interactive prompt)").option("--profile <name>", "Profile name to save as").option("--env <env>", "Environment: dev or production", "production").addHelpText(
|
|
866
1034
|
"after",
|
|
867
1035
|
`
|
|
868
1036
|
Examples:
|
|
869
1037
|
$ nexus auth login
|
|
870
1038
|
$ nexus auth login --api-key nxs_abc123
|
|
1039
|
+
$ nexus auth login --profile work --api-key nxs_abc123
|
|
871
1040
|
$ nexus auth login --env dev`
|
|
872
1041
|
).action(async (opts) => {
|
|
873
|
-
|
|
1042
|
+
let baseUrl;
|
|
874
1043
|
if (opts.env === "dev") {
|
|
875
|
-
|
|
1044
|
+
baseUrl = "http://localhost:3001";
|
|
876
1045
|
}
|
|
877
|
-
const
|
|
1046
|
+
const resolvedBaseUrl = baseUrl ?? resolveBaseUrl();
|
|
878
1047
|
let apiKey = opts.apiKey;
|
|
879
1048
|
if (!apiKey) {
|
|
880
1049
|
console.log(`Opening ${color.cyan(SETTINGS_URL)} ...`);
|
|
@@ -900,31 +1069,228 @@ Examples:
|
|
|
900
1069
|
return;
|
|
901
1070
|
}
|
|
902
1071
|
console.log("Validating...");
|
|
903
|
-
const
|
|
1072
|
+
const validateRes = await fetch(`${resolvedBaseUrl}/api/public/v1/agents?limit=1`, {
|
|
904
1073
|
headers: { "api-key": apiKey, Accept: "application/json" }
|
|
905
1074
|
});
|
|
906
|
-
if (!
|
|
1075
|
+
if (!validateRes.ok) {
|
|
907
1076
|
console.error(
|
|
908
|
-
color.red("Error:") + ` Validation failed (HTTP ${
|
|
1077
|
+
color.red("Error:") + ` Validation failed (HTTP ${validateRes.status}). Check your key and try again.`
|
|
909
1078
|
);
|
|
910
1079
|
process.exitCode = 1;
|
|
911
1080
|
return;
|
|
912
1081
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1082
|
+
let orgName;
|
|
1083
|
+
let orgId;
|
|
1084
|
+
try {
|
|
1085
|
+
const meRes = await fetch(`${resolvedBaseUrl}/api/public/v1/me`, {
|
|
1086
|
+
headers: { "api-key": apiKey, Accept: "application/json" }
|
|
1087
|
+
});
|
|
1088
|
+
if (meRes.ok) {
|
|
1089
|
+
const meJson = await meRes.json();
|
|
1090
|
+
if (meJson.data) {
|
|
1091
|
+
orgName = meJson.data.orgName;
|
|
1092
|
+
orgId = meJson.data.orgId;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
if (orgName) {
|
|
1098
|
+
console.log(`Organization: ${color.cyan(orgName)}`);
|
|
1099
|
+
}
|
|
1100
|
+
let profileName = opts.profile;
|
|
1101
|
+
if (!profileName) {
|
|
1102
|
+
const suggested = orgName ? slugifyProfileName(orgName) : "default";
|
|
1103
|
+
const rl = import_promises.default.createInterface({ input: import_node_process.stdin, output: import_node_process.stdout });
|
|
1104
|
+
try {
|
|
1105
|
+
const answer = (await rl.question(`Profile name [${suggested}]: `)).trim();
|
|
1106
|
+
profileName = answer || suggested;
|
|
1107
|
+
} finally {
|
|
1108
|
+
rl.close();
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const nameError = validateProfileName(profileName);
|
|
1112
|
+
if (nameError) {
|
|
1113
|
+
console.error(color.red("Error:") + " " + nameError);
|
|
1114
|
+
process.exitCode = 1;
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const existing = getProfile(profileName);
|
|
1118
|
+
if (existing) {
|
|
1119
|
+
const existingLabel = existing.orgName ? ` (${existing.orgName})` : "";
|
|
1120
|
+
const rl = import_promises.default.createInterface({ input: import_node_process.stdin, output: import_node_process.stdout });
|
|
1121
|
+
try {
|
|
1122
|
+
const answer = (await rl.question(
|
|
1123
|
+
`Profile "${profileName}"${existingLabel} already exists. Overwrite? [y/N]: `
|
|
1124
|
+
)).trim();
|
|
1125
|
+
if (answer.toLowerCase() !== "y") {
|
|
1126
|
+
console.log("Aborted.");
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
} finally {
|
|
1130
|
+
rl.close();
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
saveProfile(profileName, {
|
|
1134
|
+
apiKey,
|
|
1135
|
+
...baseUrl ? { baseUrl } : {},
|
|
1136
|
+
...orgName ? { orgName } : {},
|
|
1137
|
+
...orgId ? { orgId } : {}
|
|
1138
|
+
});
|
|
1139
|
+
printSuccess(`Saved profile "${profileName}".`, {
|
|
1140
|
+
...orgName ? { organization: orgName } : {},
|
|
1141
|
+
profile: profileName,
|
|
917
1142
|
config: "~/.nexus-mcp/config.json"
|
|
918
1143
|
});
|
|
1144
|
+
const { profiles } = listProfiles();
|
|
1145
|
+
if (Object.keys(profiles).length > 1) {
|
|
1146
|
+
console.log(
|
|
1147
|
+
"\n" + color.dim("Tip: You have multiple profiles. Consider pinning directories:") + "\n" + color.dim(` nexus auth pin ${profileName} (in your project directory)`)
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
auth.command("logout").description("Remove stored credentials").argument("[name]", "Specific profile to remove (default: active profile)").option("--all", "Remove all profiles").addHelpText(
|
|
1152
|
+
"after",
|
|
1153
|
+
`
|
|
1154
|
+
Examples:
|
|
1155
|
+
$ nexus auth logout # removes active profile
|
|
1156
|
+
$ nexus auth logout work # removes "work" profile
|
|
1157
|
+
$ nexus auth logout --all # removes all profiles`
|
|
1158
|
+
).action((name, opts) => {
|
|
1159
|
+
if (opts.all) {
|
|
1160
|
+
clearConfig();
|
|
1161
|
+
printSuccess("All profiles removed.");
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
const { activeProfile, profiles } = listProfiles();
|
|
1165
|
+
const target = name ?? activeProfile;
|
|
1166
|
+
if (!target) {
|
|
1167
|
+
console.error(color.red("Error:") + " No active profile. Run: nexus auth login");
|
|
1168
|
+
process.exitCode = 1;
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
if (!removeProfile(target)) {
|
|
1172
|
+
console.error(color.red("Error:") + ` Profile "${target}" not found. Run: nexus auth list`);
|
|
1173
|
+
process.exitCode = 1;
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const remaining = Object.keys(profiles).filter((p) => p !== target);
|
|
1177
|
+
if (remaining.length === 0) {
|
|
1178
|
+
printSuccess(`Removed profile "${target}". No profiles remaining. Run: nexus auth login`);
|
|
1179
|
+
} else {
|
|
1180
|
+
const { activeProfile: newActive } = listProfiles();
|
|
1181
|
+
printSuccess(`Removed profile "${target}".`, {
|
|
1182
|
+
remaining: remaining.join(", "),
|
|
1183
|
+
...newActive ? { active: newActive } : {}
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
auth.command("switch").description("Switch the active profile").argument("<name>", "Profile name to activate").addHelpText(
|
|
1188
|
+
"after",
|
|
1189
|
+
`
|
|
1190
|
+
Examples:
|
|
1191
|
+
$ nexus auth switch work
|
|
1192
|
+
$ nexus auth switch personal`
|
|
1193
|
+
).action((name) => {
|
|
1194
|
+
try {
|
|
1195
|
+
setActiveProfile(name);
|
|
1196
|
+
} catch (err) {
|
|
1197
|
+
console.error(color.red("Error:") + " " + err.message);
|
|
1198
|
+
process.exitCode = 1;
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
const profile = getProfile(name);
|
|
1202
|
+
const orgPart = profile?.orgName ? ` (${profile.orgName})` : "";
|
|
1203
|
+
printSuccess(`Switched to "${name}"${orgPart}.`);
|
|
1204
|
+
});
|
|
1205
|
+
auth.command("list").description("List all saved profiles").addHelpText(
|
|
1206
|
+
"after",
|
|
1207
|
+
`
|
|
1208
|
+
Examples:
|
|
1209
|
+
$ nexus auth list`
|
|
1210
|
+
).action(() => {
|
|
1211
|
+
const { profiles, activeProfile } = listProfiles();
|
|
1212
|
+
const names = Object.keys(profiles);
|
|
1213
|
+
if (names.length === 0) {
|
|
1214
|
+
console.log(color.dim("No profiles. Run: nexus auth login"));
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const rows = names.map((name) => ({
|
|
1218
|
+
marker: name === activeProfile ? "\u25B8" : " ",
|
|
1219
|
+
name,
|
|
1220
|
+
orgName: profiles[name].orgName ?? color.dim("\u2014"),
|
|
1221
|
+
baseUrl: profiles[name].baseUrl ?? "https://api.nexusgpt.io"
|
|
1222
|
+
}));
|
|
1223
|
+
printTable(rows, [
|
|
1224
|
+
{ key: "marker", label: " ", width: 2 },
|
|
1225
|
+
{ key: "name", label: "PROFILE" },
|
|
1226
|
+
{ key: "orgName", label: "ORGANIZATION" },
|
|
1227
|
+
{ key: "baseUrl", label: "BASE URL" }
|
|
1228
|
+
]);
|
|
1229
|
+
});
|
|
1230
|
+
auth.command("pin").description("Pin the current directory to a profile via .nexusrc").argument("<profile>", "Profile name to pin").addHelpText(
|
|
1231
|
+
"after",
|
|
1232
|
+
`
|
|
1233
|
+
Examples:
|
|
1234
|
+
$ nexus auth pin work`
|
|
1235
|
+
).action((profileName) => {
|
|
1236
|
+
const profile = getProfile(profileName);
|
|
1237
|
+
if (!profile) {
|
|
1238
|
+
const { profiles } = listProfiles();
|
|
1239
|
+
const available = Object.keys(profiles).join(", ");
|
|
1240
|
+
console.error(
|
|
1241
|
+
color.red("Error:") + ` Profile "${profileName}" not found.` + (available ? ` Available: ${available}` : " Run: nexus auth login")
|
|
1242
|
+
);
|
|
1243
|
+
process.exitCode = 1;
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
writeNexusRc(process.cwd(), profileName);
|
|
1247
|
+
const orgPart = profile.orgName ? ` (${profile.orgName})` : "";
|
|
1248
|
+
printSuccess(`Pinned this directory to "${profileName}"${orgPart}.`, {
|
|
1249
|
+
file: ".nexusrc"
|
|
1250
|
+
});
|
|
1251
|
+
console.log(color.dim("\n Tip: Consider adding .nexusrc to your .gitignore"));
|
|
919
1252
|
});
|
|
920
|
-
auth.command("
|
|
1253
|
+
auth.command("unpin").description("Remove .nexusrc from the current directory").addHelpText(
|
|
921
1254
|
"after",
|
|
922
1255
|
`
|
|
923
1256
|
Examples:
|
|
924
|
-
$ nexus auth
|
|
1257
|
+
$ nexus auth unpin`
|
|
925
1258
|
).action(() => {
|
|
926
|
-
|
|
927
|
-
|
|
1259
|
+
if (!removeNexusRc(process.cwd())) {
|
|
1260
|
+
console.error(color.red("Error:") + " No .nexusrc found in current directory.");
|
|
1261
|
+
process.exitCode = 1;
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
printSuccess("Removed .nexusrc from current directory.");
|
|
1265
|
+
});
|
|
1266
|
+
auth.command("status").description("Show resolved profile and how it was determined").addHelpText(
|
|
1267
|
+
"after",
|
|
1268
|
+
`
|
|
1269
|
+
Examples:
|
|
1270
|
+
$ nexus auth status`
|
|
1271
|
+
).action(() => {
|
|
1272
|
+
try {
|
|
1273
|
+
const resolved = resolveProfile(program2.optsWithGlobals());
|
|
1274
|
+
const sourceExplanation = {
|
|
1275
|
+
flag: "--profile flag",
|
|
1276
|
+
env: "NEXUS_PROFILE environment variable",
|
|
1277
|
+
directory: `.nexusrc at ${resolved.rcPath}`,
|
|
1278
|
+
active: "active profile in config",
|
|
1279
|
+
default: 'fallback to "default" profile',
|
|
1280
|
+
override: "--api-key flag or NEXUS_API_KEY env"
|
|
1281
|
+
};
|
|
1282
|
+
const orgPart = resolved.profile.orgName ? ` (${resolved.profile.orgName})` : "";
|
|
1283
|
+
console.log(
|
|
1284
|
+
`Using profile ${color.cyan(`"${resolved.name}"`)}${orgPart} \u2014 ${color.dim(sourceExplanation[resolved.source])}`
|
|
1285
|
+
);
|
|
1286
|
+
console.log(
|
|
1287
|
+
` ${color.dim("key:")} ${resolved.profile.apiKey.slice(0, 8)}...${resolved.profile.apiKey.slice(-4)}`
|
|
1288
|
+
);
|
|
1289
|
+
console.log(` ${color.dim("api:")} ${resolved.profile.baseUrl ?? resolveBaseUrl()}`);
|
|
1290
|
+
} catch (err) {
|
|
1291
|
+
console.error(color.red("Error:") + " " + err.message);
|
|
1292
|
+
process.exitCode = 1;
|
|
1293
|
+
}
|
|
928
1294
|
});
|
|
929
1295
|
auth.command("whoami").description("Show current authentication status").addHelpText(
|
|
930
1296
|
"after",
|
|
@@ -933,10 +1299,10 @@ Examples:
|
|
|
933
1299
|
$ nexus auth whoami`
|
|
934
1300
|
).action(async () => {
|
|
935
1301
|
try {
|
|
936
|
-
const
|
|
937
|
-
const baseUrl = resolveBaseUrl();
|
|
1302
|
+
const resolved = resolveProfile(program2.optsWithGlobals());
|
|
1303
|
+
const baseUrl = resolved.profile.baseUrl ?? resolveBaseUrl();
|
|
938
1304
|
const res = await fetch(`${baseUrl}/api/public/v1/agents?limit=1`, {
|
|
939
|
-
headers: { "api-key": apiKey, Accept: "application/json" }
|
|
1305
|
+
headers: { "api-key": resolved.profile.apiKey, Accept: "application/json" }
|
|
940
1306
|
});
|
|
941
1307
|
if (!res.ok) {
|
|
942
1308
|
console.error(
|
|
@@ -946,8 +1312,10 @@ Examples:
|
|
|
946
1312
|
return;
|
|
947
1313
|
}
|
|
948
1314
|
printSuccess("Authenticated.", {
|
|
1315
|
+
profile: resolved.name,
|
|
1316
|
+
...resolved.profile.orgName ? { organization: resolved.profile.orgName } : {},
|
|
949
1317
|
api: baseUrl,
|
|
950
|
-
key: apiKey.slice(0, 8) + "..." + apiKey.slice(-4)
|
|
1318
|
+
key: resolved.profile.apiKey.slice(0, 8) + "..." + resolved.profile.apiKey.slice(-4)
|
|
951
1319
|
});
|
|
952
1320
|
} catch (err) {
|
|
953
1321
|
console.error(color.red("Error:") + " Not logged in. Run: nexus auth login");
|
|
@@ -3275,6 +3643,155 @@ Examples:
|
|
|
3275
3643
|
});
|
|
3276
3644
|
}
|
|
3277
3645
|
|
|
3646
|
+
// src/commands/upgrade.ts
|
|
3647
|
+
var import_node_child_process2 = require("child_process");
|
|
3648
|
+
init_output();
|
|
3649
|
+
|
|
3650
|
+
// src/util/version-check.ts
|
|
3651
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
3652
|
+
var import_node_os2 = __toESM(require("os"));
|
|
3653
|
+
var import_node_path4 = __toESM(require("path"));
|
|
3654
|
+
var PACKAGE_NAME = "@agent-nexus/cli";
|
|
3655
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
3656
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
3657
|
+
var CACHE_FILE = import_node_path4.default.join(import_node_os2.default.homedir(), ".nexus-mcp", "version-check.json");
|
|
3658
|
+
function loadCache() {
|
|
3659
|
+
try {
|
|
3660
|
+
return JSON.parse(import_node_fs4.default.readFileSync(CACHE_FILE, "utf-8"));
|
|
3661
|
+
} catch {
|
|
3662
|
+
return null;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
function saveCache(cache) {
|
|
3666
|
+
try {
|
|
3667
|
+
const dir = import_node_path4.default.dirname(CACHE_FILE);
|
|
3668
|
+
import_node_fs4.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3669
|
+
import_node_fs4.default.writeFileSync(CACHE_FILE, JSON.stringify(cache), { mode: 384 });
|
|
3670
|
+
} catch {
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
async function fetchLatestVersion() {
|
|
3674
|
+
try {
|
|
3675
|
+
const controller = new AbortController();
|
|
3676
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
3677
|
+
const res = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
3678
|
+
signal: controller.signal
|
|
3679
|
+
});
|
|
3680
|
+
clearTimeout(timer);
|
|
3681
|
+
if (!res.ok) return null;
|
|
3682
|
+
const json = await res.json();
|
|
3683
|
+
return json.version ?? null;
|
|
3684
|
+
} catch {
|
|
3685
|
+
return null;
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
function compareSemver(a, b) {
|
|
3689
|
+
const pa = a.split(".").map(Number);
|
|
3690
|
+
const pb = b.split(".").map(Number);
|
|
3691
|
+
for (let i = 0; i < 3; i++) {
|
|
3692
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
3693
|
+
if (diff !== 0) return diff < 0 ? -1 : 1;
|
|
3694
|
+
}
|
|
3695
|
+
return 0;
|
|
3696
|
+
}
|
|
3697
|
+
async function checkForUpdate(currentVersion) {
|
|
3698
|
+
try {
|
|
3699
|
+
const cache = loadCache();
|
|
3700
|
+
if (cache && Date.now() - cache.lastChecked < CHECK_INTERVAL_MS) {
|
|
3701
|
+
if (compareSemver(currentVersion, cache.latestVersion) < 0) {
|
|
3702
|
+
return formatUpdateMessage(currentVersion, cache.latestVersion);
|
|
3703
|
+
}
|
|
3704
|
+
return null;
|
|
3705
|
+
}
|
|
3706
|
+
const latest = await fetchLatestVersion();
|
|
3707
|
+
if (!latest) return null;
|
|
3708
|
+
saveCache({ lastChecked: Date.now(), latestVersion: latest });
|
|
3709
|
+
if (compareSemver(currentVersion, latest) < 0) {
|
|
3710
|
+
return formatUpdateMessage(currentVersion, latest);
|
|
3711
|
+
}
|
|
3712
|
+
return null;
|
|
3713
|
+
} catch {
|
|
3714
|
+
return null;
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
function formatUpdateMessage(current, latest) {
|
|
3718
|
+
return `
|
|
3719
|
+
Update available: ${current} \u2192 ${latest}
|
|
3720
|
+
Run "npm update -g ${PACKAGE_NAME}" to update.
|
|
3721
|
+
IMPORTANT: You MUST update before running any other nexus commands. Results from an outdated CLI may be incorrect.
|
|
3722
|
+
`;
|
|
3723
|
+
}
|
|
3724
|
+
async function autoUpdate(currentVersion) {
|
|
3725
|
+
try {
|
|
3726
|
+
const cache = loadCache();
|
|
3727
|
+
let latest = null;
|
|
3728
|
+
if (cache && Date.now() - cache.lastChecked < CHECK_INTERVAL_MS) {
|
|
3729
|
+
latest = cache.latestVersion;
|
|
3730
|
+
} else {
|
|
3731
|
+
latest = await fetchLatestVersion();
|
|
3732
|
+
if (latest) {
|
|
3733
|
+
saveCache({ lastChecked: Date.now(), latestVersion: latest });
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
if (!latest || compareSemver(currentVersion, latest) >= 0) {
|
|
3737
|
+
return null;
|
|
3738
|
+
}
|
|
3739
|
+
const { execSync: execSync2 } = await import("child_process");
|
|
3740
|
+
process.stderr.write(`
|
|
3741
|
+
Auto-updating: ${currentVersion} \u2192 ${latest}\u2026
|
|
3742
|
+
`);
|
|
3743
|
+
execSync2(`npm install -g ${PACKAGE_NAME}@latest`, {
|
|
3744
|
+
stdio: "inherit"
|
|
3745
|
+
});
|
|
3746
|
+
return `
|
|
3747
|
+
Successfully auto-updated to ${latest}.
|
|
3748
|
+
`;
|
|
3749
|
+
} catch {
|
|
3750
|
+
return formatUpdateMessage(currentVersion, loadCache()?.latestVersion ?? "latest");
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
// src/commands/upgrade.ts
|
|
3755
|
+
var PACKAGE_NAME2 = "@agent-nexus/cli";
|
|
3756
|
+
function registerUpgradeCommand(program2) {
|
|
3757
|
+
const currentVersion = require_package().version;
|
|
3758
|
+
program2.command("upgrade").description("Upgrade the Nexus CLI to the latest version").addHelpText("after", `
|
|
3759
|
+
Examples:
|
|
3760
|
+
$ nexus upgrade`).action(async () => {
|
|
3761
|
+
process.stderr.write(`Current version: ${color.cyan(currentVersion)}
|
|
3762
|
+
`);
|
|
3763
|
+
process.stderr.write("Checking for updates\u2026\n");
|
|
3764
|
+
const latest = await fetchLatestVersion();
|
|
3765
|
+
if (!latest) {
|
|
3766
|
+
process.stderr.write(color.red("Failed to check for updates. Please try again later.\n"));
|
|
3767
|
+
process.exitCode = 1;
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
if (compareSemver(currentVersion, latest) >= 0) {
|
|
3771
|
+
printSuccess(`Already up-to-date (${currentVersion}).`, { version: currentVersion });
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
process.stderr.write(`Upgrading ${color.yellow(currentVersion)} \u2192 ${color.green(latest)}\u2026
|
|
3775
|
+
`);
|
|
3776
|
+
try {
|
|
3777
|
+
(0, import_node_child_process2.execSync)(`npm install -g ${PACKAGE_NAME2}@latest`, {
|
|
3778
|
+
stdio: "inherit"
|
|
3779
|
+
});
|
|
3780
|
+
printSuccess(`Successfully upgraded to ${latest}.`, { from: currentVersion, to: latest });
|
|
3781
|
+
} catch {
|
|
3782
|
+
process.stderr.write(
|
|
3783
|
+
color.red(
|
|
3784
|
+
`
|
|
3785
|
+
Upgrade failed. Try running manually:
|
|
3786
|
+
npm install -g ${PACKAGE_NAME2}@latest
|
|
3787
|
+
`
|
|
3788
|
+
)
|
|
3789
|
+
);
|
|
3790
|
+
process.exitCode = 1;
|
|
3791
|
+
}
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3278
3795
|
// src/commands/version.ts
|
|
3279
3796
|
init_output();
|
|
3280
3797
|
function registerVersionCommands(program2) {
|
|
@@ -4048,87 +4565,31 @@ Examples:
|
|
|
4048
4565
|
|
|
4049
4566
|
// src/index.ts
|
|
4050
4567
|
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
4568
|
var { version: VERSION } = require_package();
|
|
4129
|
-
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) => {
|
|
4569
|
+
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").option("--profile <name>", "Use a specific named profile").option("--no-auto-update", "Disable automatic updates when a new version is detected").hook("preAction", (thisCommand) => {
|
|
4130
4570
|
const opts = thisCommand.optsWithGlobals();
|
|
4131
4571
|
if (opts.json) setJsonMode(true);
|
|
4572
|
+
const cmdName = thisCommand.name();
|
|
4573
|
+
const skipBanner = [
|
|
4574
|
+
"auth",
|
|
4575
|
+
"upgrade",
|
|
4576
|
+
"version",
|
|
4577
|
+
"login",
|
|
4578
|
+
"logout",
|
|
4579
|
+
"whoami",
|
|
4580
|
+
"switch",
|
|
4581
|
+
"list",
|
|
4582
|
+
"pin",
|
|
4583
|
+
"unpin",
|
|
4584
|
+
"status"
|
|
4585
|
+
].includes(cmdName);
|
|
4586
|
+
if (!skipBanner && !isJsonMode()) {
|
|
4587
|
+
try {
|
|
4588
|
+
const resolved = resolveProfile(opts);
|
|
4589
|
+
printContextBanner(resolved);
|
|
4590
|
+
} catch {
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4132
4593
|
});
|
|
4133
4594
|
program.addHelpText("before", getBanner(VERSION));
|
|
4134
4595
|
program.configureHelp({
|
|
@@ -4156,14 +4617,27 @@ registerExternalToolCommands(program);
|
|
|
4156
4617
|
registerPromptAssistantCommands(program);
|
|
4157
4618
|
registerModelCommands(program);
|
|
4158
4619
|
registerPhoneNumberCommands(program);
|
|
4620
|
+
registerUpgradeCommand(program);
|
|
4159
4621
|
if (process.argv.length <= 2) {
|
|
4160
4622
|
program.help();
|
|
4161
4623
|
}
|
|
4162
4624
|
program.parseAsync(process.argv).then(async () => {
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4625
|
+
if (isJsonMode()) return;
|
|
4626
|
+
const ranCommand = process.argv[2];
|
|
4627
|
+
if (ranCommand === "upgrade") return;
|
|
4628
|
+
const opts = program.opts();
|
|
4629
|
+
if (opts.autoUpdate) {
|
|
4630
|
+
const msg = await autoUpdate(VERSION);
|
|
4631
|
+
if (msg) {
|
|
4632
|
+
const { color: color2 } = await Promise.resolve().then(() => (init_output(), output_exports));
|
|
4633
|
+
process.stderr.write(color2.green(msg));
|
|
4634
|
+
}
|
|
4635
|
+
} else {
|
|
4636
|
+
const updateMsg = await checkForUpdate(VERSION);
|
|
4637
|
+
if (updateMsg) {
|
|
4638
|
+
const { color: color2 } = await Promise.resolve().then(() => (init_output(), output_exports));
|
|
4639
|
+
process.stderr.write(color2.yellow(updateMsg));
|
|
4640
|
+
}
|
|
4167
4641
|
}
|
|
4168
4642
|
}).catch((err) => {
|
|
4169
4643
|
process.exitCode = handleError(err);
|