@devness/useai 0.4.19 → 0.4.20

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 +29 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ var VERSION;
112
112
  var init_version = __esm({
113
113
  "../shared/dist/constants/version.js"() {
114
114
  "use strict";
115
- VERSION = "0.4.17";
115
+ VERSION = "0.4.20";
116
116
  }
117
117
  });
118
118
 
@@ -561,6 +561,17 @@ async function checkDaemonHealth() {
561
561
  return false;
562
562
  }
563
563
  }
564
+ async function fetchDaemonHealth(port) {
565
+ try {
566
+ const url = port ? `http://127.0.0.1:${port}/health` : DAEMON_HEALTH_URL;
567
+ const res = await fetch(url, { signal: AbortSignal.timeout(3e3) });
568
+ if (res.ok)
569
+ return await res.json();
570
+ return null;
571
+ } catch {
572
+ return null;
573
+ }
574
+ }
564
575
  async function killDaemon() {
565
576
  const pid = readPidFile();
566
577
  if (!pid)
@@ -595,15 +606,21 @@ async function killDaemon() {
595
606
  }
596
607
  }
597
608
  async function ensureDaemon() {
598
- if (await checkDaemonHealth())
609
+ const health = await fetchDaemonHealth();
610
+ if (health && health.version === VERSION)
599
611
  return true;
600
- const pid = readPidFile();
601
- if (pid && isProcessRunning(pid.pid)) {
612
+ if (health) {
602
613
  await killDaemon();
603
- } else if (pid) {
604
- try {
605
- unlinkSync(DAEMON_PID_FILE);
606
- } catch {
614
+ }
615
+ if (!health) {
616
+ const pid = readPidFile();
617
+ if (pid && isProcessRunning(pid.pid)) {
618
+ await killDaemon();
619
+ } else if (pid) {
620
+ try {
621
+ unlinkSync(DAEMON_PID_FILE);
622
+ } catch {
623
+ }
607
624
  }
608
625
  }
609
626
  let npxPath;
@@ -629,6 +646,7 @@ var init_ensure = __esm({
629
646
  "../shared/dist/daemon/ensure.js"() {
630
647
  "use strict";
631
648
  init_paths();
649
+ init_version();
632
650
  init_resolve_npx();
633
651
  }
634
652
  });
@@ -660,7 +678,7 @@ function buildPlist(npxPath, nodePath) {
660
678
  <array>
661
679
  <string>${npxPath}</string>
662
680
  <string>-y</string>
663
- <string>@devness/useai</string>
681
+ <string>@devness/useai@latest</string>
664
682
  <string>daemon</string>
665
683
  <string>--port</string>
666
684
  <string>${DAEMON_PORT}</string>
@@ -719,7 +737,7 @@ After=network.target
719
737
 
720
738
  [Service]
721
739
  Type=simple
722
- ExecStart=${npxPath} -y @devness/useai daemon --port ${DAEMON_PORT}
740
+ ExecStart=${npxPath} -y @devness/useai@latest daemon --port ${DAEMON_PORT}
723
741
  Restart=on-failure
724
742
  RestartSec=10
725
743
  Environment=PATH=${nodePath}
@@ -756,7 +774,7 @@ function isLinuxInstalled() {
756
774
  }
757
775
  function buildVbsScript(npxPath) {
758
776
  return `Set WshShell = CreateObject("WScript.Shell")
759
- WshShell.Run """${npxPath}"" -y @devness/useai daemon --port ${DAEMON_PORT}", 0, False
777
+ WshShell.Run """${npxPath}"" -y @devness/useai@latest daemon --port ${DAEMON_PORT}", 0, False
760
778
  `;
761
779
  }
762
780
  function installWindows() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
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",