@devness/useai-cli 0.5.23 → 0.5.25

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 +94 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/index.ts
9
- import { Command as Command11 } from "commander";
9
+ import { Command as Command12 } from "commander";
10
10
 
11
11
  // ../shared/dist/constants/paths.js
12
12
  import { join } from "path";
@@ -30,7 +30,7 @@ var SYSTEMD_SERVICE_PATH = join(homedir(), ".config", "systemd", "user", "useai-
30
30
  var WINDOWS_STARTUP_SCRIPT_PATH = join(process.env["APPDATA"] ?? join(homedir(), "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "useai-daemon.vbs");
31
31
 
32
32
  // ../shared/dist/constants/version.js
33
- var VERSION = "0.5.23";
33
+ var VERSION = "0.5.25";
34
34
 
35
35
  // ../shared/dist/constants/defaults.js
36
36
  var DEFAULT_CONFIG = {
@@ -4682,7 +4682,7 @@ async function killDaemon() {
4682
4682
  } catch {
4683
4683
  }
4684
4684
  }
4685
- async function ensureDaemon() {
4685
+ async function ensureDaemon(options) {
4686
4686
  const health = await fetchDaemonHealth();
4687
4687
  if (health && health.version === VERSION)
4688
4688
  return true;
@@ -4706,7 +4706,12 @@ async function ensureDaemon() {
4706
4706
  } catch {
4707
4707
  npxPath = "npx";
4708
4708
  }
4709
- const child = spawn(npxPath, ["-y", "@devness/useai@latest", "daemon", "--port", String(DAEMON_PORT)], {
4709
+ const usePreferOnline = options?.preferOnline !== false;
4710
+ const npxArgs = ["-y"];
4711
+ if (usePreferOnline)
4712
+ npxArgs.push("--prefer-online");
4713
+ npxArgs.push("@devness/useai@latest", "daemon", "--port", String(DAEMON_PORT));
4714
+ const child = spawn(npxPath, npxArgs, {
4710
4715
  detached: true,
4711
4716
  stdio: "ignore"
4712
4717
  });
@@ -4759,6 +4764,7 @@ function buildPlist(npxPath, nodePath) {
4759
4764
  <array>
4760
4765
  <string>${npxPath}</string>
4761
4766
  <string>-y</string>
4767
+ <string>--prefer-online</string>
4762
4768
  <string>@devness/useai@latest</string>
4763
4769
  <string>daemon</string>
4764
4770
  <string>--port</string>
@@ -4831,7 +4837,7 @@ StartLimitIntervalSec=60
4831
4837
 
4832
4838
  [Service]
4833
4839
  Type=simple
4834
- ExecStart=${npxPath} -y @devness/useai@latest daemon --port ${DAEMON_PORT}
4840
+ ExecStart=${npxPath} -y --prefer-online @devness/useai@latest daemon --port ${DAEMON_PORT}
4835
4841
  Restart=on-failure
4836
4842
  RestartSec=10
4837
4843
  Environment=PATH=${nodePath}
@@ -4872,7 +4878,7 @@ function isLinuxInstalled() {
4872
4878
  }
4873
4879
  function buildVbsScript(npxPath) {
4874
4880
  return `Set WshShell = CreateObject("WScript.Shell")
4875
- WshShell.Run """${npxPath}"" -y @devness/useai@latest daemon --port ${DAEMON_PORT}", 0, False
4881
+ WshShell.Run """${npxPath}"" -y --prefer-online @devness/useai@latest daemon --port ${DAEMON_PORT}", 0, False
4876
4882
  `;
4877
4883
  }
4878
4884
  function installWindows() {
@@ -4975,6 +4981,22 @@ function recoverAutostart() {
4975
4981
  }
4976
4982
  }
4977
4983
 
4984
+ // ../shared/dist/daemon/check-update.js
4985
+ var PACKAGE_NAME = "@devness/useai";
4986
+ async function fetchLatestVersion(packageName = PACKAGE_NAME) {
4987
+ try {
4988
+ const res = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
4989
+ signal: AbortSignal.timeout(5e3)
4990
+ });
4991
+ if (!res.ok)
4992
+ return null;
4993
+ const data = await res.json();
4994
+ return data.version ?? null;
4995
+ } catch {
4996
+ return null;
4997
+ }
4998
+ }
4999
+
4978
5000
  // ../shared/dist/hooks/claude-code.js
4979
5001
  import { existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, unlinkSync as unlinkSync3, chmodSync } from "fs";
4980
5002
  import { join as join3 } from "path";
@@ -5916,27 +5938,38 @@ async function fullRemoveFlow(tools, autoYes, explicit) {
5916
5938
  }
5917
5939
  }
5918
5940
  }
5919
- try {
5920
- removeClaudeCodeHooks();
5921
- console.log(success("\u2713 Claude Code hooks removed"));
5922
- } catch {
5923
- }
5924
- console.log();
5925
- try {
5926
- await killDaemon();
5927
- console.log(success("\u2713 Daemon stopped"));
5928
- } catch {
5929
- console.log(info("Daemon was not running"));
5930
- }
5931
- if (isAutostartInstalled()) {
5941
+ const anyRemaining = AI_TOOLS.some((t) => {
5932
5942
  try {
5933
- removeAutostart();
5934
- console.log(success("\u2713 Auto-start service removed"));
5943
+ return t.isConfigured();
5935
5944
  } catch {
5936
- console.log(error("\u2717 Failed to remove auto-start service"));
5945
+ return false;
5937
5946
  }
5947
+ });
5948
+ if (!anyRemaining) {
5949
+ try {
5950
+ removeClaudeCodeHooks();
5951
+ console.log(success("\u2713 Claude Code hooks removed"));
5952
+ } catch {
5953
+ }
5954
+ console.log();
5955
+ try {
5956
+ await killDaemon();
5957
+ console.log(success("\u2713 Daemon stopped"));
5958
+ } catch {
5959
+ console.log(info("Daemon was not running"));
5960
+ }
5961
+ if (isAutostartInstalled()) {
5962
+ try {
5963
+ removeAutostart();
5964
+ console.log(success("\u2713 Auto-start service removed"));
5965
+ } catch {
5966
+ console.log(error("\u2717 Failed to remove auto-start service"));
5967
+ }
5968
+ }
5969
+ console.log(info("\nDone! UseAI fully removed.\n"));
5970
+ } else {
5971
+ console.log(info("\nDone! Other tools still configured \u2014 daemon and hooks kept running.\n"));
5938
5972
  }
5939
- console.log(info("\nDone! UseAI fully removed.\n"));
5940
5973
  }
5941
5974
  var mcpCommand = new Command7("mcp").description("Configure UseAI MCP server in your AI tools").argument("[tools...]", "Specific tool names (e.g. codex cursor vscode)").option("--stdio", "Use stdio config (legacy mode for containers/CI)").option("--remove", "Remove UseAI from configured tools, stop daemon, remove auto-start").option("--status", "Show configuration status without modifying").option("-y, --yes", "Skip confirmation, auto-select all detected tools").action(async (toolNames, opts) => {
5942
5975
  const explicit = toolNames.length > 0;
@@ -6261,8 +6294,44 @@ var logoutCommand = new Command10("logout").description("Logout from useai.dev")
6261
6294
  console.log(chalk9.green(` \u2713 Logged out from ${email}`));
6262
6295
  });
6263
6296
 
6297
+ // src/commands/update.ts
6298
+ import { Command as Command11 } from "commander";
6299
+ import chalk10 from "chalk";
6300
+ var updateCommand = new Command11("update").description("Update UseAI daemon to the latest version").action(async () => {
6301
+ console.log(chalk10.dim(" Checking for updates..."));
6302
+ const latest = await fetchLatestVersion();
6303
+ if (!latest) {
6304
+ console.log(chalk10.red(" \u2717 Could not reach npm registry"));
6305
+ return;
6306
+ }
6307
+ const health = await fetchDaemonHealth();
6308
+ const currentVersion = health?.["version"] ?? VERSION;
6309
+ if (currentVersion === latest) {
6310
+ console.log(chalk10.green(` \u2713 Already up to date (v${latest})`));
6311
+ return;
6312
+ }
6313
+ console.log(` ${chalk10.dim("Current:")} v${currentVersion}`);
6314
+ console.log(` ${chalk10.dim("Latest:")} v${latest}`);
6315
+ console.log();
6316
+ console.log(chalk10.dim(" Stopping current daemon..."));
6317
+ await killDaemon();
6318
+ console.log(chalk10.dim(" Starting updated daemon..."));
6319
+ const ok = await ensureDaemon();
6320
+ if (!ok) {
6321
+ console.log(chalk10.red(" \u2717 Failed to start updated daemon"));
6322
+ console.log(chalk10.dim(" Try running in foreground to debug:"));
6323
+ console.log(chalk10.dim(` npx -y --prefer-online @devness/useai@latest daemon --port ${DAEMON_PORT}`));
6324
+ return;
6325
+ }
6326
+ const newHealth = await fetchDaemonHealth();
6327
+ const newVersion = newHealth?.["version"] ?? "unknown";
6328
+ console.log();
6329
+ console.log(chalk10.green(` \u2713 Updated: v${currentVersion} \u2192 v${newVersion}`));
6330
+ console.log(chalk10.dim(` Dashboard: http://127.0.0.1:${DAEMON_PORT}/dashboard`));
6331
+ });
6332
+
6264
6333
  // src/index.ts
6265
- var program = new Command11();
6334
+ var program = new Command12();
6266
6335
  program.name("useai").description("useai.dev \u2014 Track your AI-assisted development workflow").version(VERSION);
6267
6336
  program.addCommand(statsCommand);
6268
6337
  program.addCommand(statusCommand);
@@ -6275,4 +6344,5 @@ program.addCommand(daemonCommand);
6275
6344
  program.addCommand(serveCommand);
6276
6345
  program.addCommand(loginCommand);
6277
6346
  program.addCommand(logoutCommand);
6347
+ program.addCommand(updateCommand);
6278
6348
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai-cli",
3
- "version": "0.5.23",
3
+ "version": "0.5.25",
4
4
  "description": "CLI tool for useai.dev — stats, sync, publish your AI development workflow",
5
5
  "author": "nabeelkausari",
6
6
  "license": "MIT",