@devness/useai 0.4.10 → 0.4.12

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 +27 -15
  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.10";
115
+ VERSION = "0.4.12";
116
116
  }
117
117
  });
118
118
 
@@ -947,12 +947,20 @@ process.stdin.on('end', () => {
947
947
  if (!hook.transcript_path) process.exit(0);
948
948
  let transcript;
949
949
  try { transcript = readFileSync(hook.transcript_path, 'utf-8'); } catch { process.exit(0); }
950
- if (!transcript.includes('useai_session_start')) process.exit(0);
951
- if (transcript.includes('useai_session_end')) process.exit(0);
952
- process.stdout.write(JSON.stringify({
953
- decision: 'block',
954
- reason: 'Before ending, call useai_session_end with milestones (generic descriptions of accomplishments), languages used, and files_touched_count.'
955
- }));
950
+ var starts = (transcript.match(/useai_session_start/g) || []).length;
951
+ if (starts === 0) process.exit(0);
952
+ var ends = (transcript.match(/useai_session_end/g) || []).length;
953
+ if (starts > ends) {
954
+ process.stdout.write(JSON.stringify({
955
+ decision: 'block',
956
+ reason: 'Before ending, call useai_session_end with milestones (generic descriptions of accomplishments), languages used, and files_touched_count.'
957
+ }));
958
+ } else {
959
+ process.stdout.write(JSON.stringify({
960
+ decision: 'block',
961
+ reason: 'You did work without UseAI tracking. Call useai_session_start first, then useai_session_end with milestones (generic descriptions of accomplishments), languages used, and files_touched_count.'
962
+ }));
963
+ }
956
964
  } catch { process.exit(0); }
957
965
  });
958
966
  `;
@@ -1093,7 +1101,7 @@ function resolveClient(server2, session2) {
1093
1101
  function registerTools(server2, session2) {
1094
1102
  server2.tool(
1095
1103
  "useai_session_start",
1096
- "Start tracking an AI coding session. Call this at the beginning of a conversation.",
1104
+ "Start tracking an AI coding session. Call this at the beginning of every response.",
1097
1105
  {
1098
1106
  task_type: z2.enum(["coding", "debugging", "testing", "planning", "reviewing", "documenting", "learning", "other"]).optional().describe("What kind of task is the developer working on?")
1099
1107
  },
@@ -1485,11 +1493,17 @@ function injectInstructions(config) {
1485
1493
  writeFileSync4(config.path, USEAI_INSTRUCTIONS + "\n");
1486
1494
  return;
1487
1495
  }
1488
- if (hasInstructionsBlock(config.path)) return;
1489
1496
  let existing = "";
1490
1497
  if (existsSync8(config.path)) {
1491
1498
  existing = readFileSync4(config.path, "utf-8");
1492
1499
  }
1500
+ if (hasInstructionsBlock(config.path)) {
1501
+ const pattern = new RegExp(
1502
+ `${INSTRUCTIONS_START}[\\s\\S]*?${INSTRUCTIONS_END}`
1503
+ );
1504
+ writeFileSync4(config.path, existing.replace(pattern, USEAI_INSTRUCTIONS_BLOCK));
1505
+ return;
1506
+ }
1493
1507
  const separator = existing && !existing.endsWith("\n") ? "\n\n" : existing ? "\n" : "";
1494
1508
  writeFileSync4(config.path, existing + separator + USEAI_INSTRUCTIONS_BLOCK + "\n");
1495
1509
  }
@@ -1579,10 +1593,9 @@ var init_tools = __esm({
1579
1593
  init_dist();
1580
1594
  USEAI_INSTRUCTIONS_TEXT = [
1581
1595
  "## UseAI Session Tracking",
1582
- "- At the START of every conversation, call `useai_session_start` with the appropriate task_type.",
1596
+ "- At the START of every response, call `useai_session_start` with the appropriate task_type.",
1583
1597
  "- For LONG sessions (15+ min), call `useai_heartbeat` periodically.",
1584
- "- At the END of every conversation, call `useai_session_end` with languages used, files_touched_count, and milestones.",
1585
- '- MILESTONES PRIVACY: Milestone titles must be COMPLETELY GENERIC. NEVER mention project names, repository names, product names, file names, file paths, class names, or company names. Write as if describing the work to a stranger who knows nothing about the codebase. GOOD: "Fixed race condition in background worker". BAD: "Fixed bug in ProjectX worker service".'
1598
+ "- At the END of every response, call `useai_session_end` with languages used, files_touched_count, and milestones (generic descriptions only \u2014 no project names, file paths, or company names)."
1586
1599
  ].join("\n");
1587
1600
  MCP_ENTRY = {
1588
1601
  command: "npx",
@@ -1595,10 +1608,9 @@ var init_tools = __esm({
1595
1608
  INSTRUCTIONS_END = "<!-- useai:end -->";
1596
1609
  USEAI_INSTRUCTIONS = [
1597
1610
  "## UseAI Session Tracking",
1598
- "- At the START of every conversation, call `useai_session_start` with the appropriate task_type.",
1611
+ "- At the START of every response, call `useai_session_start` with the appropriate task_type.",
1599
1612
  "- For LONG sessions (15+ min), call `useai_heartbeat` periodically.",
1600
- "- At the END of every conversation, call `useai_session_end` with languages used, files_touched_count, and milestones.",
1601
- '- MILESTONES PRIVACY: Milestone titles must be COMPLETELY GENERIC. NEVER mention project names, repository names, product names, file names, file paths, class names, or company names. Write as if describing the work to a stranger who knows nothing about the codebase. GOOD: "Fixed race condition in background worker". BAD: "Fixed bug in ProjectX worker service".'
1613
+ "- At the END of every response, call `useai_session_end` with languages used, files_touched_count, and milestones (generic descriptions only \u2014 no project names, file paths, or company names)."
1602
1614
  ].join("\n");
1603
1615
  USEAI_INSTRUCTIONS_BLOCK = `${INSTRUCTIONS_START}
1604
1616
  ${USEAI_INSTRUCTIONS}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
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",