@hiveai/mcp 0.10.3 → 0.10.5

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/server.js CHANGED
@@ -129,7 +129,8 @@ import {
129
129
  loadConfig,
130
130
  loadMemoriesFromDir as loadMemoriesFromDir2,
131
131
  memoryFilePath,
132
- serializeMemory
132
+ serializeMemory,
133
+ suggestSensorFromMemory
133
134
  } from "@hiveai/core";
134
135
  import { z as z4 } from "zod";
135
136
  var MemSaveInputSchema = {
@@ -230,6 +231,8 @@ async function memSave(input, ctx) {
230
231
  symbols: input.symbols.length ? input.symbols : fm.anchor.symbols
231
232
  }
232
233
  };
234
+ const suggestedSensor = !newFrontmatter.sensor ? suggestSensorForSavedMemory(input.type, input.body, newFrontmatter.anchor.paths) : null;
235
+ if (suggestedSensor) newFrontmatter.sensor = suggestedSensor;
233
236
  await writeFile2(
234
237
  topicMatch.filePath,
235
238
  serializeMemory({ frontmatter: newFrontmatter, body: input.body }),
@@ -248,7 +251,8 @@ async function memSave(input, ctx) {
248
251
  revision_count: newFrontmatter.revision_count,
249
252
  ...mergedTw ? { warning: mergedTw } : {},
250
253
  ...bs ? { body_similar: bs } : {},
251
- ...invalidPaths.length > 0 ? { invalid_paths: invalidPaths } : {}
254
+ ...invalidPaths.length > 0 ? { invalid_paths: invalidPaths } : {},
255
+ ...suggestedSensor ? { suggested_sensor: true } : {}
252
256
  };
253
257
  }
254
258
  }
@@ -264,7 +268,8 @@ async function memSave(input, ctx) {
264
268
  symbols: input.symbols,
265
269
  commit: input.commit,
266
270
  topic: input.topic,
267
- status: haiveConfig.defaultStatus === "validated" ? "validated" : void 0
271
+ status: haiveConfig.defaultStatus === "validated" ? "validated" : void 0,
272
+ sensor: suggestSensorForSavedMemory(input.type, input.body, input.paths) ?? void 0
268
273
  });
269
274
  const file = memoryFilePath(
270
275
  ctx.paths,
@@ -305,9 +310,14 @@ async function memSave(input, ctx) {
305
310
  ...finalWarning ? { warning: finalWarning } : {},
306
311
  ...similar_found ? { similar_found } : {},
307
312
  ...bsNew ? { body_similar: bsNew } : {},
308
- ...invalidPaths.length > 0 ? { invalid_paths: invalidPaths } : {}
313
+ ...invalidPaths.length > 0 ? { invalid_paths: invalidPaths } : {},
314
+ ...frontmatter.sensor?.autogen ? { suggested_sensor: true } : {}
309
315
  };
310
316
  }
317
+ function suggestSensorForSavedMemory(type, body, paths) {
318
+ if (type !== "gotcha" && type !== "attempt") return null;
319
+ return suggestSensorFromMemory(body, paths);
320
+ }
311
321
  function criticalAnchorWarning(type, status, paths, symbols) {
312
322
  if (!["decision", "gotcha", "architecture"].includes(type)) return null;
313
323
  if (status !== "validated") return null;
@@ -1025,7 +1035,8 @@ import path5 from "path";
1025
1035
  import {
1026
1036
  buildFrontmatter as buildFrontmatter2,
1027
1037
  memoryFilePath as memoryFilePath2,
1028
- serializeMemory as serializeMemory6
1038
+ serializeMemory as serializeMemory6,
1039
+ suggestSensorFromMemory as suggestSensorFromMemory2
1029
1040
  } from "@hiveai/core";
1030
1041
  import { z as z14 } from "zod";
1031
1042
  var MemTriedInputSchema = {
@@ -1059,6 +1070,10 @@ async function memTried(input, ctx) {
1059
1070
  lines.push("", `**Instead, use:** ${input.instead}`);
1060
1071
  }
1061
1072
  const body = lines.join("\n") + "\n";
1073
+ const sensor = suggestSensorFromMemory2(body, input.paths);
1074
+ if (sensor) {
1075
+ frontmatter.sensor = sensor;
1076
+ }
1062
1077
  const file = memoryFilePath2(ctx.paths, frontmatter.scope, frontmatter.id, frontmatter.module);
1063
1078
  await mkdir3(path5.dirname(file), { recursive: true });
1064
1079
  if (existsSync14(file)) {
@@ -2449,8 +2464,8 @@ import {
2449
2464
  loadUsageIndex as loadUsageIndex9,
2450
2465
  literalMatchesAnyToken as literalMatchesAnyToken3,
2451
2466
  memoryMatchesAnchorPaths as memoryMatchesAnchorPaths4,
2452
- runRegexSensor,
2453
- sensorAppliesToPath,
2467
+ runSensors,
2468
+ sensorTargetsFromDiff,
2454
2469
  tokenizeQuery as tokenizeQuery3
2455
2470
  } from "@hiveai/core";
2456
2471
  import { z as z24 } from "zod";
@@ -2590,24 +2605,18 @@ async function antiPatternsCheck(input, ctx) {
2590
2605
  }
2591
2606
  if (input.diff) {
2592
2607
  const added = addedLinesFromDiff(input.diff);
2593
- const scanText = added.trim().length > 0 ? added : input.diff;
2594
- for (const { memory } of negative) {
2595
- const sensor = memory.frontmatter.sensor;
2596
- if (!sensor || sensor.kind !== "regex") continue;
2597
- const anchorPaths = memory.frontmatter.anchor.paths;
2598
- const inScope = input.paths.length === 0 || input.paths.some((p) => sensorAppliesToPath(sensor, anchorPaths, p));
2599
- if (!inScope) continue;
2600
- const hit = runRegexSensor(memory.frontmatter.id, sensor, {
2601
- path: input.paths[0] ?? "",
2602
- content: scanText
2603
- });
2604
- if (hit) {
2605
- upsert(memory.frontmatter, memory.body, "sensor");
2606
- const w = seen.get(memory.frontmatter.id);
2607
- if (w) {
2608
- w.sensor_message = hit.message;
2609
- w.sensor_severity = hit.severity;
2610
- }
2608
+ const diffTargets = sensorTargetsFromDiff(input.diff);
2609
+ const hasFileTargets = diffTargets.some((target) => target.path.length > 0);
2610
+ const targets = diffTargets.length > 0 && hasFileTargets ? diffTargets : input.paths.length > 0 ? input.paths.map((p) => ({ path: p, content: added.trim().length > 0 ? added : input.diff })) : [{ path: "", content: added.trim().length > 0 ? added : input.diff }];
2611
+ const hits = runSensors(negative.map(({ memory }) => memory), targets);
2612
+ for (const hit of hits) {
2613
+ const found = negative.find(({ memory }) => memory.frontmatter.id === hit.memory_id);
2614
+ if (!found) continue;
2615
+ upsert(found.memory.frontmatter, found.memory.body, "sensor");
2616
+ const w = seen.get(found.memory.frontmatter.id);
2617
+ if (w) {
2618
+ w.sensor_message = hit.message;
2619
+ w.sensor_severity = hit.severity;
2611
2620
  }
2612
2621
  }
2613
2622
  }
@@ -3172,6 +3181,24 @@ function classifyWarning(warning, paths, anchoredBlocks = false) {
3172
3181
  repair_command: repairCommand
3173
3182
  };
3174
3183
  }
3184
+ if (warning.reasons.includes("sensor")) {
3185
+ if (warning.sensor_severity === "block") {
3186
+ return {
3187
+ ...warning,
3188
+ level: "blocking",
3189
+ rationale: "deterministic hAIve sensor with block severity matched the added diff",
3190
+ affected_files: affectedFiles,
3191
+ repair_command: repairCommand
3192
+ };
3193
+ }
3194
+ return {
3195
+ ...warning,
3196
+ level: "review",
3197
+ rationale: "deterministic hAIve sensor with warn severity matched the added diff",
3198
+ affected_files: affectedFiles,
3199
+ repair_command: repairCommand
3200
+ };
3201
+ }
3175
3202
  if (isBlockingWarning(warning)) {
3176
3203
  return {
3177
3204
  ...warning,
@@ -3898,7 +3925,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
3898
3925
  // src/server.ts
3899
3926
  import { loadConfigSync } from "@hiveai/core";
3900
3927
  var SERVER_NAME = "haive";
3901
- var SERVER_VERSION = "0.10.3";
3928
+ var SERVER_VERSION = "0.10.5";
3902
3929
  function jsonResult(data) {
3903
3930
  return {
3904
3931
  content: [