@livx.cc/agentx 0.96.12 → 0.96.13

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/cli.js CHANGED
@@ -1909,6 +1909,7 @@ var init_tools_shell = __esm({
1909
1909
  import { createInterface } from "readline/promises";
1910
1910
  import { existsSync as existsSync9, readFileSync as readFileSync8, appendFileSync, mkdirSync as mkdirSync11, writeFileSync as writeFileSync9, readdirSync as readdirSync4, statSync as statSync4, unlinkSync as unlinkSync5 } from "fs";
1911
1911
  import { homedir as homedir9, tmpdir as tmpdir3 } from "os";
1912
+ import { spawnSync as spawnSync6 } from "child_process";
1912
1913
 
1913
1914
  // cli/clipboard.ts
1914
1915
  import { execFileSync } from "child_process";
@@ -10093,6 +10094,10 @@ async function checkForUpdate(current) {
10093
10094
  if (cM > lM || cM === lM && cm > lm || cM === lM && cm === lm && cp >= lp) return null;
10094
10095
  return `Update available: ${current} \u2192 ${latest}. Run \`bun add -g @livx.cc/agentx\` to update.`;
10095
10096
  }
10097
+ function installUpdate() {
10098
+ const r = spawnSync6("bun", ["add", "-g", "@livx.cc/agentx"], { stdio: "inherit" });
10099
+ return (r.status ?? 1) === 0;
10100
+ }
10096
10101
  var spinner = /* @__PURE__ */ (() => {
10097
10102
  const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
10098
10103
  let timer;
@@ -11990,8 +11995,8 @@ ${task}`;
11990
11995
  const wasRaw = process.stdin.isTTY && process.stdin.isRaw;
11991
11996
  if (wasRaw) process.stdin.setRawMode(false);
11992
11997
  try {
11993
- const { spawnSync: spawnSync6 } = await import("child_process");
11994
- const r = spawnSync6("less", ["-R"], { input: text, stdio: ["pipe", "inherit", "inherit"] });
11998
+ const { spawnSync: spawnSync7 } = await import("child_process");
11999
+ const r = spawnSync7("less", ["-R"], { input: text, stdio: ["pipe", "inherit", "inherit"] });
11995
12000
  if (r.error) err(text);
11996
12001
  } finally {
11997
12002
  if (wasRaw) process.stdin.setRawMode(true);
@@ -12387,8 +12392,8 @@ ${task}`;
12387
12392
  const wasRaw = process.stdin.isTTY && process.stdin.isRaw;
12388
12393
  if (wasRaw) process.stdin.setRawMode(false);
12389
12394
  try {
12390
- const { spawnSync: spawnSync6 } = await import("child_process");
12391
- spawnSync6(ed, [idx], { stdio: "inherit" });
12395
+ const { spawnSync: spawnSync7 } = await import("child_process");
12396
+ spawnSync7(ed, [idx], { stdio: "inherit" });
12392
12397
  } finally {
12393
12398
  if (wasRaw) process.stdin.setRawMode(true);
12394
12399
  }
@@ -12817,11 +12822,14 @@ ${task}`;
12817
12822
  run: async () => {
12818
12823
  err(dim(" checking\u2026\n"));
12819
12824
  const msg = await checkForUpdate(VERSION).catch(() => null);
12820
- if (msg) {
12821
- err(yellow(` ${msg}
12825
+ if (!msg) {
12826
+ err(green(" \u2713 up to date\n"));
12827
+ return;
12828
+ }
12829
+ err(yellow(` ${msg.replace(/Run .+$/, "Installing\u2026")}
12822
12830
  `));
12823
- err(dim(" run the command above to update, then restart.\n"));
12824
- } else err(green(" \u2713 up to date\n"));
12831
+ if (installUpdate()) err(green(" \u2713 updated \u2014 restart agentx to use the new version\n"));
12832
+ else err(red(" \u2717 update failed \u2014 run `bun add -g @livx.cc/agentx` manually\n"));
12825
12833
  }
12826
12834
  },
12827
12835
  exit: { desc: "quit", run: () => true },
@@ -13325,9 +13333,7 @@ async function main() {
13325
13333
  return;
13326
13334
  }
13327
13335
  console.log(msg.replace(/Run .+$/, "Installing\u2026"));
13328
- const { spawnSync: spawnSync6 } = await import("child_process");
13329
- const r = spawnSync6("bun", ["add", "-g", "@livx.cc/agentx"], { stdio: "inherit" });
13330
- process.exit(r.status ?? 1);
13336
+ process.exit(installUpdate() ? 0 : 1);
13331
13337
  }
13332
13338
  if (args.debug) process.env.DEBUG ||= "*";
13333
13339
  if (args.print && !args.task && !process.stdin.isTTY) args.task = (await readAllStdin()).trim();