claudish 2.6.1 → 2.6.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.
Files changed (2) hide show
  1. package/dist/index.js +187 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31649,11 +31649,15 @@ function fuzzyScore2(text, query) {
31649
31649
  // src/cli.ts
31650
31650
  var exports_cli = {};
31651
31651
  __export(exports_cli, {
31652
- parseArgs: () => parseArgs
31652
+ parseArgs: () => parseArgs,
31653
+ getVersion: () => getVersion
31653
31654
  });
31654
31655
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, existsSync as existsSync3, mkdirSync, copyFileSync } from "node:fs";
31655
31656
  import { fileURLToPath as fileURLToPath3 } from "node:url";
31656
31657
  import { dirname as dirname3, join as join4 } from "node:path";
31658
+ function getVersion() {
31659
+ return VERSION;
31660
+ }
31657
31661
  async function parseArgs(args) {
31658
31662
  const config3 = {
31659
31663
  model: undefined,
@@ -36433,6 +36437,177 @@ var init_proxy_server = __esm(() => {
36433
36437
  init_openrouter_handler();
36434
36438
  });
36435
36439
 
36440
+ // src/update-checker.ts
36441
+ var exports_update_checker = {};
36442
+ __export(exports_update_checker, {
36443
+ checkForUpdates: () => checkForUpdates
36444
+ });
36445
+ import { execSync } from "node:child_process";
36446
+ import { createInterface as createInterface2 } from "node:readline";
36447
+ import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync8, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2 } from "node:fs";
36448
+ import { join as join7 } from "node:path";
36449
+ import { tmpdir as tmpdir2, homedir } from "node:os";
36450
+ function getCacheFilePath() {
36451
+ const cacheDir = join7(homedir(), ".cache", "claudish");
36452
+ try {
36453
+ if (!existsSync6(cacheDir)) {
36454
+ mkdirSync3(cacheDir, { recursive: true });
36455
+ }
36456
+ return join7(cacheDir, "update-check.json");
36457
+ } catch {
36458
+ return join7(tmpdir2(), "claudish-update-check.json");
36459
+ }
36460
+ }
36461
+ function readCache() {
36462
+ try {
36463
+ const cachePath = getCacheFilePath();
36464
+ if (!existsSync6(cachePath)) {
36465
+ return null;
36466
+ }
36467
+ const data = JSON.parse(readFileSync5(cachePath, "utf-8"));
36468
+ return data;
36469
+ } catch {
36470
+ return null;
36471
+ }
36472
+ }
36473
+ function writeCache(latestVersion) {
36474
+ try {
36475
+ const cachePath = getCacheFilePath();
36476
+ const data = {
36477
+ lastCheck: Date.now(),
36478
+ latestVersion
36479
+ };
36480
+ writeFileSync8(cachePath, JSON.stringify(data), "utf-8");
36481
+ } catch {}
36482
+ }
36483
+ function isCacheValid(cache) {
36484
+ const age = Date.now() - cache.lastCheck;
36485
+ return age < CACHE_MAX_AGE_MS;
36486
+ }
36487
+ function clearCache() {
36488
+ try {
36489
+ const cachePath = getCacheFilePath();
36490
+ if (existsSync6(cachePath)) {
36491
+ unlinkSync2(cachePath);
36492
+ }
36493
+ } catch {}
36494
+ }
36495
+ function compareVersions(v1, v2) {
36496
+ const parts1 = v1.replace(/^v/, "").split(".").map(Number);
36497
+ const parts2 = v2.replace(/^v/, "").split(".").map(Number);
36498
+ for (let i = 0;i < Math.max(parts1.length, parts2.length); i++) {
36499
+ const p1 = parts1[i] || 0;
36500
+ const p2 = parts2[i] || 0;
36501
+ if (p1 > p2)
36502
+ return 1;
36503
+ if (p1 < p2)
36504
+ return -1;
36505
+ }
36506
+ return 0;
36507
+ }
36508
+ async function fetchLatestVersion() {
36509
+ try {
36510
+ const controller = new AbortController;
36511
+ const timeout = setTimeout(() => controller.abort(), 5000);
36512
+ const response = await fetch(NPM_REGISTRY_URL, {
36513
+ signal: controller.signal,
36514
+ headers: { Accept: "application/json" }
36515
+ });
36516
+ clearTimeout(timeout);
36517
+ if (!response.ok) {
36518
+ return null;
36519
+ }
36520
+ const data = await response.json();
36521
+ return data.version || null;
36522
+ } catch {
36523
+ return null;
36524
+ }
36525
+ }
36526
+ function promptUser(question) {
36527
+ return new Promise((resolve) => {
36528
+ const rl = createInterface2({
36529
+ input: process.stdin,
36530
+ output: process.stderr
36531
+ });
36532
+ rl.question(question, (answer) => {
36533
+ rl.close();
36534
+ const normalized = answer.toLowerCase().trim();
36535
+ resolve(normalized === "y" || normalized === "yes");
36536
+ });
36537
+ });
36538
+ }
36539
+ function runUpdate() {
36540
+ try {
36541
+ console.error(`
36542
+ [claudish] Updating...
36543
+ `);
36544
+ const result = execSync("npm install -g claudish@latest", {
36545
+ stdio: "inherit",
36546
+ encoding: "utf-8"
36547
+ });
36548
+ console.error(`
36549
+ [claudish] Update complete! Please restart claudish.
36550
+ `);
36551
+ return true;
36552
+ } catch (error46) {
36553
+ console.error(`
36554
+ [claudish] Update failed. Try manually:`);
36555
+ console.error(` npm install -g claudish@latest
36556
+ `);
36557
+ return false;
36558
+ }
36559
+ }
36560
+ async function checkForUpdates(currentVersion, options = {}) {
36561
+ const { quiet = false, skipPrompt = false } = options;
36562
+ let latestVersion = null;
36563
+ const cache = readCache();
36564
+ if (cache && isCacheValid(cache)) {
36565
+ latestVersion = cache.latestVersion;
36566
+ } else {
36567
+ latestVersion = await fetchLatestVersion();
36568
+ writeCache(latestVersion);
36569
+ }
36570
+ if (!latestVersion) {
36571
+ return false;
36572
+ }
36573
+ if (compareVersions(latestVersion, currentVersion) <= 0) {
36574
+ return false;
36575
+ }
36576
+ if (!quiet) {
36577
+ console.error("");
36578
+ console.error("━".repeat(60));
36579
+ console.error(` New version available: ${currentVersion} → ${latestVersion}`);
36580
+ console.error("━".repeat(60));
36581
+ console.error("");
36582
+ }
36583
+ if (skipPrompt) {
36584
+ if (!quiet) {
36585
+ console.error(` Update with: npm install -g claudish@latest
36586
+ `);
36587
+ }
36588
+ return false;
36589
+ }
36590
+ const shouldUpdate = await promptUser(" Would you like to update now? [y/N] ");
36591
+ if (!shouldUpdate) {
36592
+ if (!quiet) {
36593
+ console.error(`
36594
+ Skipped. Update later with: npm install -g claudish@latest
36595
+ `);
36596
+ }
36597
+ return false;
36598
+ }
36599
+ const success2 = runUpdate();
36600
+ if (success2) {
36601
+ clearCache();
36602
+ return true;
36603
+ }
36604
+ return false;
36605
+ }
36606
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org/claudish/latest", CACHE_MAX_AGE_MS;
36607
+ var init_update_checker = __esm(() => {
36608
+ CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
36609
+ });
36610
+
36436
36611
  // src/index.ts
36437
36612
  var import_dotenv2 = __toESM(require_main(), 1);
36438
36613
  import_dotenv2.config();
@@ -36444,12 +36619,13 @@ if (isMcpMode) {
36444
36619
  }
36445
36620
  async function runCli() {
36446
36621
  const { checkClaudeInstalled: checkClaudeInstalled2, runClaudeWithProxy: runClaudeWithProxy2 } = await Promise.resolve().then(() => (init_claude_runner(), exports_claude_runner));
36447
- const { parseArgs: parseArgs2 } = await Promise.resolve().then(() => (init_cli(), exports_cli));
36622
+ const { parseArgs: parseArgs2, getVersion: getVersion2 } = await Promise.resolve().then(() => (init_cli(), exports_cli));
36448
36623
  const { DEFAULT_PORT_RANGE: DEFAULT_PORT_RANGE2 } = await Promise.resolve().then(() => (init_config(), exports_config));
36449
36624
  const { selectModelInteractively: selectModelInteractively2, promptForApiKey: promptForApiKey2 } = await Promise.resolve().then(() => (init_simple_selector(), exports_simple_selector));
36450
36625
  const { initLogger: initLogger2, getLogFilePath: getLogFilePath2 } = await Promise.resolve().then(() => (init_logger(), exports_logger));
36451
36626
  const { findAvailablePort: findAvailablePort2 } = await Promise.resolve().then(() => (init_port_manager(), exports_port_manager));
36452
36627
  const { createProxyServer: createProxyServer2 } = await Promise.resolve().then(() => (init_proxy_server(), exports_proxy_server));
36628
+ const { checkForUpdates: checkForUpdates2 } = await Promise.resolve().then(() => (init_update_checker(), exports_update_checker));
36453
36629
  async function readStdin() {
36454
36630
  const chunks = [];
36455
36631
  for await (const chunk of process.stdin) {
@@ -36466,6 +36642,15 @@ async function runCli() {
36466
36642
  console.log(`[claudish] Debug log: ${logFile}`);
36467
36643
  }
36468
36644
  }
36645
+ if (cliConfig.interactive && !cliConfig.jsonOutput) {
36646
+ const shouldExit = await checkForUpdates2(getVersion2(), {
36647
+ quiet: cliConfig.quiet,
36648
+ skipPrompt: false
36649
+ });
36650
+ if (shouldExit) {
36651
+ process.exit(0);
36652
+ }
36653
+ }
36469
36654
  if (!await checkClaudeInstalled2()) {
36470
36655
  console.error("Error: Claude Code CLI is not installed");
36471
36656
  console.error("Install it from: https://claude.com/claude-code");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Run Claude Code with any OpenRouter model - CLI tool and MCP server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",