@general-input/cli 0.9.0 → 0.10.0

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 CHANGED
@@ -16,7 +16,7 @@ Or via npm directly:
16
16
  npm install -g @general-input/cli
17
17
  ```
18
18
 
19
- The CLI installs as `geni` on your `PATH`. Requires Node 20+, plus `bash`, `curl`, and `jq` available locally (the installer checks).
19
+ The CLI installs as `geni` on your `PATH`. Requires Node 20+, plus `bash`, `curl`, and `jq` available locally (the installer checks). Later, update with `geni upgrade`.
20
20
 
21
21
  ## Get started
22
22
 
package/dist/cli.js CHANGED
@@ -2217,17 +2217,17 @@ var require_cipherModes = __commonJS({
2217
2217
  }
2218
2218
  };
2219
2219
  modes.gcm.prototype.tableMultiply = function(x) {
2220
- var z11 = [0, 0, 0, 0];
2220
+ var z12 = [0, 0, 0, 0];
2221
2221
  for (var i = 0; i < 32; ++i) {
2222
2222
  var idx = i / 8 | 0;
2223
2223
  var x_i = x[idx] >>> (7 - i % 8) * 4 & 15;
2224
2224
  var ah = this._m[i][x_i];
2225
- z11[0] ^= ah[0];
2226
- z11[1] ^= ah[1];
2227
- z11[2] ^= ah[2];
2228
- z11[3] ^= ah[3];
2225
+ z12[0] ^= ah[0];
2226
+ z12[1] ^= ah[1];
2227
+ z12[2] ^= ah[2];
2228
+ z12[3] ^= ah[3];
2229
2229
  }
2230
- return z11;
2230
+ return z12;
2231
2231
  };
2232
2232
  modes.gcm.prototype.ghash = function(h, y, x) {
2233
2233
  y[0] ^= x[0];
@@ -5972,26 +5972,26 @@ var require_jsbn = __commonJS({
5972
5972
  function bnpIsEven() {
5973
5973
  return (this.t > 0 ? this.data[0] & 1 : this.s) == 0;
5974
5974
  }
5975
- function bnpExp(e, z11) {
5975
+ function bnpExp(e, z12) {
5976
5976
  if (e > 4294967295 || e < 1) return BigInteger.ONE;
5977
- var r = nbi(), r2 = nbi(), g = z11.convert(this), i = nbits(e) - 1;
5977
+ var r = nbi(), r2 = nbi(), g = z12.convert(this), i = nbits(e) - 1;
5978
5978
  g.copyTo(r);
5979
5979
  while (--i >= 0) {
5980
- z11.sqrTo(r, r2);
5981
- if ((e & 1 << i) > 0) z11.mulTo(r2, g, r);
5980
+ z12.sqrTo(r, r2);
5981
+ if ((e & 1 << i) > 0) z12.mulTo(r2, g, r);
5982
5982
  else {
5983
5983
  var t = r;
5984
5984
  r = r2;
5985
5985
  r2 = t;
5986
5986
  }
5987
5987
  }
5988
- return z11.revert(r);
5988
+ return z12.revert(r);
5989
5989
  }
5990
5990
  function bnModPowInt(e, m) {
5991
- var z11;
5992
- if (e < 256 || m.isEven()) z11 = new Classic(m);
5993
- else z11 = new Montgomery(m);
5994
- return this.exp(e, z11);
5991
+ var z12;
5992
+ if (e < 256 || m.isEven()) z12 = new Classic(m);
5993
+ else z12 = new Montgomery(m);
5994
+ return this.exp(e, z12);
5995
5995
  }
5996
5996
  BigInteger.prototype.copyTo = bnpCopyTo;
5997
5997
  BigInteger.prototype.fromInt = bnpFromInt;
@@ -6049,13 +6049,13 @@ var require_jsbn = __commonJS({
6049
6049
  if (this.signum() == 0 || b < 2 || b > 36) return "0";
6050
6050
  var cs = this.chunkSize(b);
6051
6051
  var a = Math.pow(b, cs);
6052
- var d = nbv(a), y = nbi(), z11 = nbi(), r = "";
6053
- this.divRemTo(d, y, z11);
6052
+ var d = nbv(a), y = nbi(), z12 = nbi(), r = "";
6053
+ this.divRemTo(d, y, z12);
6054
6054
  while (y.signum() > 0) {
6055
- r = (a + z11.intValue()).toString(b).substr(1) + r;
6056
- y.divRemTo(d, y, z11);
6055
+ r = (a + z12.intValue()).toString(b).substr(1) + r;
6056
+ y.divRemTo(d, y, z12);
6057
6057
  }
6058
- return z11.intValue().toString(b) + r;
6058
+ return z12.intValue().toString(b) + r;
6059
6059
  }
6060
6060
  function bnpFromRadix(s, b) {
6061
6061
  this.fromInt(0);
@@ -6428,7 +6428,7 @@ var require_jsbn = __commonJS({
6428
6428
  Barrett.prototype.mulTo = barrettMulTo;
6429
6429
  Barrett.prototype.sqrTo = barrettSqrTo;
6430
6430
  function bnModPow(e, m) {
6431
- var i = e.bitLength(), k, r = nbv(1), z11;
6431
+ var i = e.bitLength(), k, r = nbv(1), z12;
6432
6432
  if (i <= 0) return r;
6433
6433
  else if (i < 18) k = 1;
6434
6434
  else if (i < 48) k = 3;
@@ -6436,19 +6436,19 @@ var require_jsbn = __commonJS({
6436
6436
  else if (i < 768) k = 5;
6437
6437
  else k = 6;
6438
6438
  if (i < 8)
6439
- z11 = new Classic(m);
6439
+ z12 = new Classic(m);
6440
6440
  else if (m.isEven())
6441
- z11 = new Barrett(m);
6441
+ z12 = new Barrett(m);
6442
6442
  else
6443
- z11 = new Montgomery(m);
6443
+ z12 = new Montgomery(m);
6444
6444
  var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
6445
- g[1] = z11.convert(this);
6445
+ g[1] = z12.convert(this);
6446
6446
  if (k > 1) {
6447
6447
  var g2 = nbi();
6448
- z11.sqrTo(g[1], g2);
6448
+ z12.sqrTo(g[1], g2);
6449
6449
  while (n <= km) {
6450
6450
  g[n] = nbi();
6451
- z11.mulTo(g2, g[n - 2], g[n]);
6451
+ z12.mulTo(g2, g[n - 2], g[n]);
6452
6452
  n += 2;
6453
6453
  }
6454
6454
  }
@@ -6474,20 +6474,20 @@ var require_jsbn = __commonJS({
6474
6474
  is1 = false;
6475
6475
  } else {
6476
6476
  while (n > 1) {
6477
- z11.sqrTo(r, r2);
6478
- z11.sqrTo(r2, r);
6477
+ z12.sqrTo(r, r2);
6478
+ z12.sqrTo(r2, r);
6479
6479
  n -= 2;
6480
6480
  }
6481
- if (n > 0) z11.sqrTo(r, r2);
6481
+ if (n > 0) z12.sqrTo(r, r2);
6482
6482
  else {
6483
6483
  t = r;
6484
6484
  r = r2;
6485
6485
  r2 = t;
6486
6486
  }
6487
- z11.mulTo(r2, g[w], r);
6487
+ z12.mulTo(r2, g[w], r);
6488
6488
  }
6489
6489
  while (j >= 0 && (e.data[j] & 1 << i) == 0) {
6490
- z11.sqrTo(r, r2);
6490
+ z12.sqrTo(r, r2);
6491
6491
  t = r;
6492
6492
  r = r2;
6493
6493
  r2 = t;
@@ -6497,7 +6497,7 @@ var require_jsbn = __commonJS({
6497
6497
  }
6498
6498
  }
6499
6499
  }
6500
- return z11.revert(r);
6500
+ return z12.revert(r);
6501
6501
  }
6502
6502
  function bnGCD(a) {
6503
6503
  var x = this.s < 0 ? this.negate() : this.clone();
@@ -18288,7 +18288,7 @@ import chalk4 from "chalk";
18288
18288
  // package.json
18289
18289
  var package_default = {
18290
18290
  name: "@general-input/cli",
18291
- version: "0.9.0",
18291
+ version: "0.10.0",
18292
18292
  type: "module",
18293
18293
  description: "The agent-facing CLI for General Input. Authenticate, manage workflows, run bash with operator credentials injected by the cloud.",
18294
18294
  license: "SEE LICENSE IN LICENSE",
@@ -18332,6 +18332,7 @@ var package_default = {
18332
18332
  "@clack/prompts": "^0.7.0",
18333
18333
  chalk: "^5.3.0",
18334
18334
  commander: "^12.1.0",
18335
+ semver: "^7.8.0",
18335
18336
  tar: "^7.4.3",
18336
18337
  zod: "^4.3.6"
18337
18338
  },
@@ -18343,6 +18344,7 @@ var package_default = {
18343
18344
  "@packages/eslint-config": "workspace:*",
18344
18345
  "@packages/typescript-config": "workspace:*",
18345
18346
  "@types/node": "^24.12.2",
18347
+ "@types/semver": "^7.7.1",
18346
18348
  "@types/tar": "^6.1.13",
18347
18349
  eslint: "^9.39.4",
18348
18350
  tsup: "^8.3.5",
@@ -25581,6 +25583,110 @@ function printReport(checks) {
25581
25583
  }
25582
25584
  }
25583
25585
 
25586
+ // src/commands/upgrade.ts
25587
+ import { spawn as spawn3, execFileSync } from "child_process";
25588
+ import { realpathSync } from "fs";
25589
+ import { sep as sep2 } from "path";
25590
+ import { z as z11 } from "zod";
25591
+ import semver from "semver";
25592
+ var PACKAGE_NAME = "@general-input/cli";
25593
+ var registryLatestSchema = z11.object({ version: z11.string() });
25594
+ function registerUpgradeCommand(program2) {
25595
+ program2.command("upgrade").description(
25596
+ "Upgrade geni to the latest published version. Checks the npm registry and reinstalls via `npm install -g` when this install is npm-managed. Use --check to only report whether a newer version exists."
25597
+ ).option(
25598
+ "--check",
25599
+ "Report whether a newer version exists, without installing it."
25600
+ ).action(async (opts) => {
25601
+ const latest = await fetchLatestVersion();
25602
+ if (!semver.gt(latest, CLI_VERSION)) {
25603
+ printSuccess(`geni ${CLI_VERSION} is already the latest version.`);
25604
+ exit(ExitCode.Ok);
25605
+ }
25606
+ if (opts.check) {
25607
+ printInfo(
25608
+ `geni ${latest} is available (you have ${CLI_VERSION}). Run \`geni upgrade\` to install it.`
25609
+ );
25610
+ exit(ExitCode.UpgradeRequired);
25611
+ }
25612
+ const cliPath = resolveCliRealPath();
25613
+ const npmGlobalRoot = resolveNpmGlobalRoot();
25614
+ const isNpmManaged = cliPath !== null && npmGlobalRoot !== null && isInsideDirectory({ path: cliPath, directory: npmGlobalRoot });
25615
+ if (!isNpmManaged) {
25616
+ printError(
25617
+ `geni ${latest} is available (you have ${CLI_VERSION}), but this install isn't managed by \`npm install -g\` (binary resolves to ${cliPath ?? "an unknown path"}). Upgrade it the way it was installed \u2014 for a linked dev checkout: git pull && pnpm build.`
25618
+ );
25619
+ exit(ExitCode.GenericError);
25620
+ }
25621
+ printInfo(`Upgrading geni ${CLI_VERSION} \u2192 ${latest} \u2026`);
25622
+ const npmExitCode = await runNpmInstall();
25623
+ if (npmExitCode !== 0) {
25624
+ printError(
25625
+ `npm install failed (exit ${npmExitCode}). If that was a permissions error, retry with: sudo npm install -g ${PACKAGE_NAME}@latest`
25626
+ );
25627
+ exit(ExitCode.GenericError);
25628
+ }
25629
+ printSuccess(`geni upgraded to ${latest}.`);
25630
+ printInfo("Run `geni skills install` to refresh the agent-facing skills.");
25631
+ exit(ExitCode.Ok);
25632
+ });
25633
+ }
25634
+ async function fetchLatestVersion() {
25635
+ try {
25636
+ const response = await fetch(
25637
+ `https://registry.npmjs.org/${PACKAGE_NAME}/latest`,
25638
+ { signal: AbortSignal.timeout(1e4) }
25639
+ );
25640
+ if (!response.ok) {
25641
+ throw new Error(`npm registry responded ${response.status}`);
25642
+ }
25643
+ const parsed = registryLatestSchema.parse(await response.json());
25644
+ if (semver.valid(parsed.version) === null) {
25645
+ throw new Error(
25646
+ `npm registry returned invalid version "${parsed.version}"`
25647
+ );
25648
+ }
25649
+ return parsed.version;
25650
+ } catch (err) {
25651
+ const detail = err instanceof Error ? err.message : String(err);
25652
+ printError(
25653
+ `Could not check the npm registry for the latest version: ${detail}`
25654
+ );
25655
+ exit(ExitCode.GenericError);
25656
+ }
25657
+ }
25658
+ function resolveCliRealPath() {
25659
+ const binPath = process.argv[1];
25660
+ if (!binPath) return null;
25661
+ try {
25662
+ return realpathSync(binPath);
25663
+ } catch {
25664
+ return null;
25665
+ }
25666
+ }
25667
+ function resolveNpmGlobalRoot() {
25668
+ try {
25669
+ const root = execFileSync("npm", ["root", "-g"], {
25670
+ encoding: "utf-8"
25671
+ }).trim();
25672
+ return realpathSync(root);
25673
+ } catch {
25674
+ return null;
25675
+ }
25676
+ }
25677
+ function isInsideDirectory(args) {
25678
+ return args.path.startsWith(args.directory + sep2);
25679
+ }
25680
+ function runNpmInstall() {
25681
+ return new Promise((resolve20, reject) => {
25682
+ const child = spawn3("npm", ["install", "-g", `${PACKAGE_NAME}@latest`], {
25683
+ stdio: "inherit"
25684
+ });
25685
+ child.once("exit", (code) => resolve20(code ?? 1));
25686
+ child.once("error", (err) => reject(err));
25687
+ });
25688
+ }
25689
+
25584
25690
  // src/cli.ts
25585
25691
  process.removeAllListeners("warning");
25586
25692
  process.on("warning", (warning) => {
@@ -25608,6 +25714,7 @@ registerConfigCommands(program);
25608
25714
  registerSkillsCommands(program);
25609
25715
  registerCrmCommands(program);
25610
25716
  registerDoctorCommand(program);
25717
+ registerUpgradeCommand(program);
25611
25718
  program.addHelpText(
25612
25719
  "after",
25613
25720
  `
@@ -25631,6 +25738,7 @@ function shouldRunPreflight(argv) {
25631
25738
  const firstArg = argv[2];
25632
25739
  if (!firstArg) return false;
25633
25740
  if (firstArg === "doctor") return false;
25741
+ if (firstArg === "upgrade") return false;
25634
25742
  if (firstArg === "--help" || firstArg === "-h") return false;
25635
25743
  if (firstArg === "--version" || firstArg === "-v") return false;
25636
25744
  return true;