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