@devness/useai 0.5.47 → 0.6.0

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 +74 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -684,7 +684,7 @@ var VERSION;
684
684
  var init_version = __esm({
685
685
  "../shared/dist/constants/version.js"() {
686
686
  "use strict";
687
- VERSION = "0.5.47";
687
+ VERSION = "0.6.0";
688
688
  }
689
689
  });
690
690
 
@@ -5535,13 +5535,28 @@ import { existsSync as existsSync2 } from "fs";
5535
5535
  import { join as join2 } from "path";
5536
5536
  import { homedir as homedir2 } from "os";
5537
5537
  function resolveNpxPath() {
5538
- const whichCmd = isWindows ? "where npx" : "which npx";
5538
+ const whichCmd = isWindows ? "where npx.cmd" : "which npx";
5539
5539
  try {
5540
5540
  const result = execSync(whichCmd, { stdio: ["pipe", "pipe", "ignore"], encoding: "utf-8" }).trim();
5541
5541
  if (result)
5542
5542
  return result.split("\n")[0].trim();
5543
5543
  } catch {
5544
5544
  }
5545
+ if (isWindows) {
5546
+ try {
5547
+ const result = execSync("where npx", { stdio: ["pipe", "pipe", "ignore"], encoding: "utf-8" }).trim();
5548
+ if (result) {
5549
+ const first = result.split("\n")[0].trim();
5550
+ if (!first.toLowerCase().endsWith(".cmd")) {
5551
+ const cmdPath = first + ".cmd";
5552
+ if (existsSync2(cmdPath))
5553
+ return cmdPath;
5554
+ }
5555
+ return first;
5556
+ }
5557
+ } catch {
5558
+ }
5559
+ }
5545
5560
  if (!isWindows && process.env["SHELL"]) {
5546
5561
  try {
5547
5562
  const result = execSync(`${process.env["SHELL"]} -lc "which npx"`, {
@@ -5637,6 +5652,21 @@ async function fetchDaemonHealth(port) {
5637
5652
  }
5638
5653
  function findPidsByPort(port) {
5639
5654
  try {
5655
+ if (process.platform === "win32") {
5656
+ const output2 = execSync2(`netstat -ano | findstr :${port} | findstr LISTENING`, {
5657
+ encoding: "utf-8",
5658
+ timeout: 5e3,
5659
+ shell: "cmd.exe"
5660
+ });
5661
+ const pids = /* @__PURE__ */ new Set();
5662
+ for (const line of output2.trim().split("\n")) {
5663
+ const parts = line.trim().split(/\s+/);
5664
+ const pid = parseInt(parts[parts.length - 1], 10);
5665
+ if (!isNaN(pid) && pid > 0)
5666
+ pids.add(pid);
5667
+ }
5668
+ return [...pids];
5669
+ }
5640
5670
  const output = execSync2(`lsof -ti :${port}`, { encoding: "utf-8", timeout: 3e3 });
5641
5671
  return output.trim().split("\n").map((s) => parseInt(s, 10)).filter((n) => !isNaN(n) && n > 0);
5642
5672
  } catch {
@@ -5708,11 +5738,16 @@ async function ensureDaemon(options) {
5708
5738
  }
5709
5739
  }
5710
5740
  }
5741
+ const isWindows2 = process.platform === "win32";
5711
5742
  let npxPath;
5712
- try {
5713
- npxPath = resolveNpxPath();
5714
- } catch {
5743
+ if (isWindows2) {
5715
5744
  npxPath = "npx";
5745
+ } else {
5746
+ try {
5747
+ npxPath = resolveNpxPath();
5748
+ } catch {
5749
+ npxPath = "npx";
5750
+ }
5716
5751
  }
5717
5752
  const usePreferOnline = options?.preferOnline !== false;
5718
5753
  const npxArgs = ["-y"];
@@ -5721,7 +5756,8 @@ async function ensureDaemon(options) {
5721
5756
  npxArgs.push("@devness/useai@latest", "daemon", "--port", String(DAEMON_PORT));
5722
5757
  const child = spawn(npxPath, npxArgs, {
5723
5758
  detached: true,
5724
- stdio: "ignore"
5759
+ stdio: "ignore",
5760
+ shell: isWindows2
5725
5761
  });
5726
5762
  child.unref();
5727
5763
  const start = Date.now();
@@ -15278,18 +15314,36 @@ function showManualHints(installedTools) {
15278
15314
  }
15279
15315
  console.log();
15280
15316
  }
15317
+ function startSpinner(message) {
15318
+ let frame = 0;
15319
+ const interval = setInterval(() => {
15320
+ const symbol = source_default.cyan(SPINNER_FRAMES[frame % SPINNER_FRAMES.length]);
15321
+ process.stdout.write(`\r ${symbol} ${source_default.dim(message)}`);
15322
+ frame++;
15323
+ }, 80);
15324
+ return {
15325
+ stop(finalMessage) {
15326
+ clearInterval(interval);
15327
+ process.stdout.write(`\r${" ".repeat(message.length + 10)}\r`);
15328
+ console.log(finalMessage);
15329
+ }
15330
+ };
15331
+ }
15281
15332
  async function daemonInstallFlow(tools, autoYes, explicit) {
15282
- console.log(source_default.dim(" Ensuring UseAI daemon is running..."));
15333
+ const spinner = startSpinner("Starting UseAI daemon...");
15283
15334
  const daemonOk = await ensureDaemon();
15284
- let useDaemon = true;
15285
- if (daemonOk) {
15286
- console.log(source_default.green(` \u2713 Daemon running on port ${DAEMON_PORT}`));
15287
- console.log(source_default.dim(` Dashboard: http://127.0.0.1:${DAEMON_PORT}/dashboard`));
15288
- } else {
15289
- useDaemon = false;
15290
- console.log(source_default.red(` \u2717 Could not start daemon \u2014 falling back to stdio config`));
15291
- console.log(source_default.dim(` (Run with --foreground to debug: npx @devness/useai@latest daemon --port ${DAEMON_PORT})`));
15335
+ if (!daemonOk) {
15336
+ spinner.stop(source_default.red(` \u2717 Could not start daemon on port ${DAEMON_PORT}`));
15337
+ console.log();
15338
+ console.log(source_default.bold(" To debug, run the daemon in foreground mode:"));
15339
+ console.log(source_default.cyan(` npx @devness/useai@latest daemon --port ${DAEMON_PORT}`));
15340
+ console.log();
15341
+ console.log(source_default.dim(" If you need stdio mode (e.g. containers/CI), use: npx @devness/useai mcp --stdio"));
15342
+ return;
15292
15343
  }
15344
+ const useDaemon = true;
15345
+ spinner.stop(source_default.green(` \u2713 Daemon running on port ${DAEMON_PORT}`));
15346
+ console.log(source_default.dim(` Dashboard: http://127.0.0.1:${DAEMON_PORT}/dashboard`));
15293
15347
  if (useDaemon) {
15294
15348
  const platform = detectPlatform();
15295
15349
  if (platform !== "unsupported") {
@@ -15575,13 +15629,14 @@ async function runSetup(args) {
15575
15629
  await daemonInstallFlow(tools, autoYes, explicit);
15576
15630
  }
15577
15631
  }
15578
- var _shared;
15632
+ var _shared, SPINNER_FRAMES;
15579
15633
  var init_setup = __esm({
15580
15634
  "src/setup.ts"() {
15581
15635
  "use strict";
15582
15636
  init_source();
15583
15637
  init_dist();
15584
15638
  init_tools2();
15639
+ SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
15585
15640
  }
15586
15641
  });
15587
15642
 
@@ -36532,17 +36587,9 @@ if (subcommand === "update") {
36532
36587
  const daemonOk = await ensureDaemon2({ preferOnline: true });
36533
36588
  if (!daemonOk) {
36534
36589
  console.log(chalk2.red(" \u2717 Failed to start updated daemon"));
36535
- if (configuredTools.length > 0) {
36536
- console.log(chalk2.dim("\n Reinstalling MCP configs (stdio fallback)..."));
36537
- for (const tool of configuredTools) {
36538
- try {
36539
- tool.install();
36540
- console.log(chalk2.green(` \u2713 ${tool.name} \u2192 ${chalk2.dim("stdio")}`));
36541
- } catch {
36542
- console.log(chalk2.red(` \u2717 ${tool.name}`));
36543
- }
36544
- }
36545
- }
36590
+ console.log();
36591
+ console.log(chalk2.bold(" To debug, run the daemon in foreground mode:"));
36592
+ console.log(chalk2.cyan(" npx @devness/useai@latest daemon --port 19200"));
36546
36593
  process.exit(1);
36547
36594
  }
36548
36595
  const healthAfter = await fetchDaemonHealth2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai",
3
- "version": "0.5.47",
3
+ "version": "0.6.0",
4
4
  "description": "Track your AI-assisted development workflow. MCP server that records usage metrics across all your AI tools.",
5
5
  "keywords": [
6
6
  "mcp",