@devness/useai 0.4.18 → 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.
- package/dist/index.js +41 -23
- 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.
|
|
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
|
-
|
|
609
|
+
const health = await fetchDaemonHealth();
|
|
610
|
+
if (health && health.version === VERSION)
|
|
599
611
|
return true;
|
|
600
|
-
|
|
601
|
-
if (pid && isProcessRunning(pid.pid)) {
|
|
612
|
+
if (health) {
|
|
602
613
|
await killDaemon();
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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() {
|
|
@@ -978,13 +996,13 @@ process.stdin.on('end', () => {
|
|
|
978
996
|
if (!hook.transcript_path) process.exit(0);
|
|
979
997
|
let transcript;
|
|
980
998
|
try { transcript = readFileSync(hook.transcript_path, 'utf-8'); } catch { process.exit(0); }
|
|
981
|
-
var starts = (transcript.match(/
|
|
999
|
+
var starts = (transcript.match(/useai_start/g) || []).length;
|
|
982
1000
|
if (starts === 0) process.exit(0);
|
|
983
|
-
var ends = (transcript.match(/
|
|
1001
|
+
var ends = (transcript.match(/useai_end/g) || []).length;
|
|
984
1002
|
if (ends >= starts) process.exit(0);
|
|
985
1003
|
process.stdout.write(JSON.stringify({
|
|
986
1004
|
decision: 'block',
|
|
987
|
-
reason: 'Before ending, call
|
|
1005
|
+
reason: 'Before ending, call useai_end with milestones (generic descriptions of accomplishments), languages used, and files_touched_count.'
|
|
988
1006
|
}));
|
|
989
1007
|
} catch { process.exit(0); }
|
|
990
1008
|
});
|
|
@@ -1001,13 +1019,13 @@ process.stdin.on('end', () => {
|
|
|
1001
1019
|
if (!hook.transcript_path) process.exit(0);
|
|
1002
1020
|
let transcript;
|
|
1003
1021
|
try { transcript = readFileSync(hook.transcript_path, 'utf-8'); } catch { process.exit(0); }
|
|
1004
|
-
var starts = (transcript.match(/
|
|
1005
|
-
var ends = (transcript.match(/
|
|
1022
|
+
var starts = (transcript.match(/useai_start/g) || []).length;
|
|
1023
|
+
var ends = (transcript.match(/useai_end/g) || []).length;
|
|
1006
1024
|
if (starts > ends) process.exit(0);
|
|
1007
1025
|
process.stdout.write(JSON.stringify({
|
|
1008
1026
|
hookSpecificOutput: {
|
|
1009
1027
|
hookEventName: 'UserPromptSubmit',
|
|
1010
|
-
additionalContext: 'UseAI: Call
|
|
1028
|
+
additionalContext: 'UseAI: Call useai_start with the appropriate task_type before doing any work.'
|
|
1011
1029
|
}
|
|
1012
1030
|
}));
|
|
1013
1031
|
} catch { process.exit(0); }
|
|
@@ -1155,7 +1173,7 @@ function resolveClient(server2, session2) {
|
|
|
1155
1173
|
}
|
|
1156
1174
|
function registerTools(server2, session2) {
|
|
1157
1175
|
server2.tool(
|
|
1158
|
-
"
|
|
1176
|
+
"useai_start",
|
|
1159
1177
|
"Start tracking an AI coding session. Call this at the beginning of every response.",
|
|
1160
1178
|
{
|
|
1161
1179
|
task_type: z2.enum(["coding", "debugging", "testing", "planning", "reviewing", "documenting", "learning", "other"]).optional().describe("What kind of task is the developer working on?")
|
|
@@ -1201,7 +1219,7 @@ function registerTools(server2, session2) {
|
|
|
1201
1219
|
}
|
|
1202
1220
|
);
|
|
1203
1221
|
server2.tool(
|
|
1204
|
-
"
|
|
1222
|
+
"useai_end",
|
|
1205
1223
|
`End the current AI coding session and record milestones. Each milestone needs TWO titles: (1) a generic public "title" safe for public display (NEVER include project names, file names, class names, or any identifying details), and (2) an optional detailed "private_title" for the user's own records that CAN include project names, file names, and specific details. GOOD title: "Implemented user authentication". GOOD private_title: "Added JWT auth to UseAI API server". BAD title: "Fixed bug in Acme auth service".`,
|
|
1206
1224
|
{
|
|
1207
1225
|
task_type: z2.enum(["coding", "debugging", "testing", "planning", "reviewing", "documenting", "learning", "other"]).optional().describe("What kind of task was the developer working on?"),
|
|
@@ -1654,9 +1672,9 @@ var init_tools = __esm({
|
|
|
1654
1672
|
init_dist();
|
|
1655
1673
|
USEAI_INSTRUCTIONS_TEXT = [
|
|
1656
1674
|
"## UseAI Session Tracking",
|
|
1657
|
-
"- At the START of every response, call `
|
|
1675
|
+
"- At the START of every response, call `useai_start` with the appropriate task_type.",
|
|
1658
1676
|
"- For LONG sessions (15+ min), call `useai_heartbeat` periodically.",
|
|
1659
|
-
"- At the END of every response, call `
|
|
1677
|
+
"- At the END of every response, call `useai_end` with languages used, files_touched_count, and milestones (generic descriptions only \u2014 no project names, file paths, or company names)."
|
|
1660
1678
|
].join("\n");
|
|
1661
1679
|
MCP_ENTRY = {
|
|
1662
1680
|
command: "npx",
|
|
@@ -1669,9 +1687,9 @@ var init_tools = __esm({
|
|
|
1669
1687
|
INSTRUCTIONS_END = "<!-- useai:end -->";
|
|
1670
1688
|
USEAI_INSTRUCTIONS = [
|
|
1671
1689
|
"## UseAI Session Tracking",
|
|
1672
|
-
"- At the START of every response, call `
|
|
1690
|
+
"- At the START of every response, call `useai_start` with the appropriate task_type.",
|
|
1673
1691
|
"- For LONG sessions (15+ min), call `useai_heartbeat` periodically.",
|
|
1674
|
-
"- At the END of every response, call `
|
|
1692
|
+
"- At the END of every response, call `useai_end` with languages used, files_touched_count, and milestones (generic descriptions only \u2014 no project names, file paths, or company names)."
|
|
1675
1693
|
].join("\n");
|
|
1676
1694
|
USEAI_INSTRUCTIONS_BLOCK = `${INSTRUCTIONS_START}
|
|
1677
1695
|
${USEAI_INSTRUCTIONS}
|