@devness/useai-cli 0.5.48 → 0.6.1

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 +28 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -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.48";
33
+ var VERSION = "0.6.1";
34
34
 
35
35
  // ../shared/dist/constants/defaults.js
36
36
  var DEFAULT_CONFIG = {
@@ -4738,6 +4738,21 @@ async function fetchDaemonHealth(port) {
4738
4738
  }
4739
4739
  function findPidsByPort(port) {
4740
4740
  try {
4741
+ if (process.platform === "win32") {
4742
+ const output2 = execSync2(`netstat -ano | findstr :${port} | findstr LISTENING`, {
4743
+ encoding: "utf-8",
4744
+ timeout: 5e3,
4745
+ shell: "cmd.exe"
4746
+ });
4747
+ const pids = /* @__PURE__ */ new Set();
4748
+ for (const line of output2.trim().split("\n")) {
4749
+ const parts = line.trim().split(/\s+/);
4750
+ const pid = parseInt(parts[parts.length - 1], 10);
4751
+ if (!isNaN(pid) && pid > 0)
4752
+ pids.add(pid);
4753
+ }
4754
+ return [...pids];
4755
+ }
4741
4756
  const output = execSync2(`lsof -ti :${port}`, { encoding: "utf-8", timeout: 3e3 });
4742
4757
  return output.trim().split("\n").map((s) => parseInt(s, 10)).filter((n) => !isNaN(n) && n > 0);
4743
4758
  } catch {
@@ -4809,11 +4824,16 @@ async function ensureDaemon(options) {
4809
4824
  }
4810
4825
  }
4811
4826
  }
4827
+ const isWindows2 = process.platform === "win32";
4812
4828
  let npxPath;
4813
- try {
4814
- npxPath = resolveNpxPath();
4815
- } catch {
4829
+ if (isWindows2) {
4816
4830
  npxPath = "npx";
4831
+ } else {
4832
+ try {
4833
+ npxPath = resolveNpxPath();
4834
+ } catch {
4835
+ npxPath = "npx";
4836
+ }
4817
4837
  }
4818
4838
  const usePreferOnline = options?.preferOnline !== false;
4819
4839
  const npxArgs = ["-y"];
@@ -4823,7 +4843,8 @@ async function ensureDaemon(options) {
4823
4843
  const child = spawn(npxPath, npxArgs, {
4824
4844
  detached: true,
4825
4845
  stdio: "ignore",
4826
- shell: process.platform === "win32"
4846
+ shell: isWindows2,
4847
+ windowsHide: true
4827
4848
  });
4828
4849
  child.unref();
4829
4850
  const start = Date.now();
@@ -6539,7 +6560,8 @@ var startCommand = new Command8("start").description("Start the UseAI daemon").o
6539
6560
  if (opts.foreground) {
6540
6561
  const child = spawn2("npx", ["-y", "@devness/useai@latest", "daemon", "--port", String(port)], {
6541
6562
  stdio: "inherit",
6542
- shell: process.platform === "win32"
6563
+ shell: true
6564
+ // Required on Windows for npx.cmd; harmless on macOS/Linux
6543
6565
  });
6544
6566
  child.on("exit", (code) => {
6545
6567
  process.exit(code ?? 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai-cli",
3
- "version": "0.5.48",
3
+ "version": "0.6.1",
4
4
  "description": "CLI tool for useai.dev — stats, sync, publish your AI development workflow",
5
5
  "author": "nabeelkausari",
6
6
  "license": "MIT",