xclaude-cli 0.1.2 → 0.1.3

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
@@ -21,7 +21,7 @@ xclaude add personal # then log in with /login
21
21
  xclaude shell install # completion in ~/.zshrc and/or ~/.bashrc
22
22
  ```
23
23
 
24
- Update with `npm i -g xclaude-cli@latest`. Update Claude Code with `claude update` (or `xclaude <any> update`).
24
+ Update with `npm i -g xclaude-cli@latest`; xclaude checks npm once a day and prints a one-line note when there's a newer version (`XCLAUDE_NO_UPDATE_CHECK=1` turns that off). Update Claude Code with `claude update` (or `xclaude <any> update`).
25
25
 
26
26
  ## Commands
27
27
 
package/dist/xclaude.js CHANGED
@@ -2610,7 +2610,7 @@ function refreshInitFiles(paths, config, version) {
2610
2610
  }
2611
2611
 
2612
2612
  // package.json
2613
- var package_default = { version: "0.1.2" };
2613
+ var package_default = { version: "0.1.3" };
2614
2614
 
2615
2615
  // src/version.ts
2616
2616
  var VERSION = package_default.version;
@@ -3248,6 +3248,77 @@ function formatCompletion(c, shell, cur) {
3248
3248
  `;
3249
3249
  }
3250
3250
 
3251
+ // src/update.ts
3252
+ import { spawnSync as spawnSync4 } from "node:child_process";
3253
+ import path18 from "node:path";
3254
+ var PACKAGE = "xclaude-cli";
3255
+ var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE}/latest`;
3256
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
3257
+ var FETCH_TIMEOUT_MS = 1e4;
3258
+ var SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
3259
+ function checkFile(paths) {
3260
+ return path18.join(paths.cache, "update-check.json");
3261
+ }
3262
+ function readUpdateCheck(paths) {
3263
+ try {
3264
+ const raw = JSON.parse(readFileOrNull(checkFile(paths)) ?? "null");
3265
+ if (typeof raw?.checkedAt === "number" && typeof raw.latest === "string") return { checkedAt: raw.checkedAt, latest: raw.latest };
3266
+ } catch {
3267
+ }
3268
+ return null;
3269
+ }
3270
+ function checkDue(check, now) {
3271
+ return !check || now - check.checkedAt >= CHECK_INTERVAL_MS || now < check.checkedAt;
3272
+ }
3273
+ function isNewer(a, b) {
3274
+ const pa = SEMVER.exec(a);
3275
+ const pb = SEMVER.exec(b);
3276
+ if (!pa || !pb) return false;
3277
+ for (let i = 1; i <= 3; i++) {
3278
+ const diff = Number(pa[i]) - Number(pb[i]);
3279
+ if (diff) return diff > 0;
3280
+ }
3281
+ return pa[4] === void 0 && pb[4] !== void 0;
3282
+ }
3283
+ async function fetchLatest(url, timeoutMs = FETCH_TIMEOUT_MS) {
3284
+ try {
3285
+ const res = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
3286
+ if (!res.ok) return null;
3287
+ const body = await res.json();
3288
+ return typeof body?.version === "string" && SEMVER.test(body.version) ? body.version : null;
3289
+ } catch {
3290
+ return null;
3291
+ }
3292
+ }
3293
+ async function runUpdateCheck(paths, url, now = Date.now) {
3294
+ const latest = await fetchLatest(url);
3295
+ if (!latest) return;
3296
+ try {
3297
+ mkdirPrivate(paths.cache);
3298
+ const check = { checkedAt: now(), latest };
3299
+ writeFileAtomic(checkFile(paths), `${JSON.stringify(check)}
3300
+ `, { mode: 384 });
3301
+ } catch {
3302
+ }
3303
+ }
3304
+ function startUpdateCheck(env, script) {
3305
+ const opts = { env, stdio: "ignore", detached: true, timeout: 2e3 };
3306
+ try {
3307
+ spawnSync4("/bin/sh", ["-c", '"$0" "$1" __update-check </dev/null >/dev/null 2>&1 &', process.execPath, script], opts);
3308
+ } catch {
3309
+ }
3310
+ }
3311
+ function updateNote(latest, current) {
3312
+ return `xclaude: an update is available (${current} \u2192 ${latest}); please run npm install -g ${PACKAGE} to update`;
3313
+ }
3314
+ function updateCheckOnOpen(ctx, version, now = Date.now()) {
3315
+ if (!ctx.tty.stderr || ctx.env.XCLAUDE_NO_UPDATE_CHECK === "1") return;
3316
+ const check = readUpdateCheck(ctx.paths);
3317
+ if (check && isNewer(check.latest, version)) ctx.io.err(`${updateNote(check.latest, version)}
3318
+ `);
3319
+ if (checkDue(check, now) && ctx.selfPath) startUpdateCheck(ctx.env, ctx.selfPath);
3320
+ }
3321
+
3251
3322
  // src/commands/hidden.ts
3252
3323
  function quietConfig(ctx) {
3253
3324
  try {
@@ -3276,6 +3347,10 @@ function namesCommand(ctx) {
3276
3347
  `);
3277
3348
  return EXIT_OK;
3278
3349
  }
3350
+ async function updateCheckCommand(ctx) {
3351
+ await runUpdateCheck(ctx.paths, ctx.env.XCLAUDE_UPDATE_URL || REGISTRY_URL);
3352
+ return EXIT_OK;
3353
+ }
3279
3354
 
3280
3355
  // src/commands/ls.ts
3281
3356
  async function lsCommand(ctx, config, args) {
@@ -3383,7 +3458,7 @@ function forgetAccount(state, account) {
3383
3458
  }
3384
3459
 
3385
3460
  // src/grammar.ts
3386
- var HIDDEN = ["__complete", "__names"];
3461
+ var HIDDEN = ["__complete", "__names", "__update-check"];
3387
3462
  function isCommand(word) {
3388
3463
  return COMMANDS.includes(word);
3389
3464
  }
@@ -3676,7 +3751,7 @@ function shellCommand(ctx, config, args) {
3676
3751
 
3677
3752
  // src/commands/tmux.ts
3678
3753
  import fs26 from "node:fs";
3679
- import path18 from "node:path";
3754
+ import path19 from "node:path";
3680
3755
 
3681
3756
  // src/launch/args.ts
3682
3757
  function hasFlag(args, flag) {
@@ -3949,7 +4024,7 @@ async function launch(ctx, config, account, userArgs) {
3949
4024
  }
3950
4025
 
3951
4026
  // src/tmux/claude-state.ts
3952
- import { spawnSync as spawnSync4 } from "node:child_process";
4027
+ import { spawnSync as spawnSync5 } from "node:child_process";
3953
4028
  import fs25 from "node:fs";
3954
4029
  function describeAgent(e) {
3955
4030
  if (e.status === "waiting") return { text: e.waitingFor ? `needs input (${e.waitingFor})` : "needs input", rank: 3 };
@@ -3970,7 +4045,7 @@ function parentLookup() {
3970
4045
  };
3971
4046
  }
3972
4047
  const map = /* @__PURE__ */ new Map();
3973
- const res = spawnSync4("ps", ["-axo", "pid=,ppid="], { encoding: "utf8", timeout: 1e4 });
4048
+ const res = spawnSync5("ps", ["-axo", "pid=,ppid="], { encoding: "utf8", timeout: 1e4 });
3974
4049
  for (const line of (res.stdout ?? "").split("\n")) {
3975
4050
  const [pid, ppid] = line.trim().split(/\s+/).map(Number);
3976
4051
  if (pid && ppid !== void 0 && Number.isFinite(ppid)) map.set(pid, ppid);
@@ -4087,7 +4162,7 @@ async function tmuxNew(ctx, config, args) {
4087
4162
  account ??= await chooseAccount(ctx, config, `Run Claude Code in tmux session "${req.label}" as`);
4088
4163
  if (!defaultsOf(config, account)) throw unknownAccount(account, config);
4089
4164
  }
4090
- const dir = path18.resolve(ctx.cwd, req.dir ?? ".");
4165
+ const dir = path19.resolve(ctx.cwd, req.dir ?? ".");
4091
4166
  if (!fs26.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) throw new XError(`--dir ${req.dir}: not a directory`);
4092
4167
  const existing = findByLabel(listSessions(tmux), req.label);
4093
4168
  if (existing) {
@@ -4221,6 +4296,7 @@ async function main(argv, ctx) {
4221
4296
  }
4222
4297
  if (first === "__complete") return completeCommand(ctx, argv.slice(1));
4223
4298
  if (first === "__names") return namesCommand(ctx);
4299
+ if (first === "__update-check") return updateCheckCommand(ctx);
4224
4300
  if (first === "doctor") return doctorCommand(ctx, argv.slice(1));
4225
4301
  const { config, created } = loadConfig(ctx.paths, { create: true });
4226
4302
  if (created && first !== "add" && first !== "shell") {
@@ -4239,6 +4315,7 @@ async function main(argv, ctx) {
4239
4315
  }
4240
4316
  } catch {
4241
4317
  }
4318
+ updateCheckOnOpen(ctx, VERSION);
4242
4319
  const action = classify(argv, config);
4243
4320
  switch (action.kind) {
4244
4321
  case "version":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xclaude-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Run Claude Code under several claude.ai logins at once, with shared conversations and history",
5
5
  "keywords": [
6
6
  "claude",