@hiveai/mcp 0.10.2 → 0.10.4
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 +60 -7
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.js +60 -7
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.ts
CHANGED
|
@@ -362,8 +362,11 @@ interface AntiPatternsWarning {
|
|
|
362
362
|
scope: string;
|
|
363
363
|
confidence: string;
|
|
364
364
|
body_preview: string;
|
|
365
|
-
reasons: Array<"anchor" | "literal" | "semantic">;
|
|
365
|
+
reasons: Array<"anchor" | "literal" | "semantic" | "sensor">;
|
|
366
366
|
semantic_score?: number;
|
|
367
|
+
/** When a regex sensor fired: its self-correction message and severity. */
|
|
368
|
+
sensor_message?: string;
|
|
369
|
+
sensor_severity?: "warn" | "block";
|
|
367
370
|
/** Memory tags — used downstream (e.g. pre_commit_check) to weight a warning by topic. */
|
|
368
371
|
tags?: string[];
|
|
369
372
|
/** Anchor paths of the memory — lets the gate tell what kind of file this warning is about. */
|
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)) {
|
|
@@ -2441,6 +2456,7 @@ function runCommand(cmd, args, cwd) {
|
|
|
2441
2456
|
// src/tools/anti-patterns-check.ts
|
|
2442
2457
|
import { existsSync as existsSync22 } from "fs";
|
|
2443
2458
|
import {
|
|
2459
|
+
addedLinesFromDiff,
|
|
2444
2460
|
deriveConfidence as deriveConfidence6,
|
|
2445
2461
|
getUsage as getUsage7,
|
|
2446
2462
|
isRetiredMemory as isRetiredMemory2,
|
|
@@ -2448,6 +2464,8 @@ import {
|
|
|
2448
2464
|
loadUsageIndex as loadUsageIndex9,
|
|
2449
2465
|
literalMatchesAnyToken as literalMatchesAnyToken3,
|
|
2450
2466
|
memoryMatchesAnchorPaths as memoryMatchesAnchorPaths4,
|
|
2467
|
+
runSensors,
|
|
2468
|
+
sensorTargetsFromDiff,
|
|
2451
2469
|
tokenizeQuery as tokenizeQuery3
|
|
2452
2470
|
} from "@hiveai/core";
|
|
2453
2471
|
import { z as z24 } from "zod";
|
|
@@ -2585,6 +2603,23 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2585
2603
|
}
|
|
2586
2604
|
}
|
|
2587
2605
|
}
|
|
2606
|
+
if (input.diff) {
|
|
2607
|
+
const added = addedLinesFromDiff(input.diff);
|
|
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;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2588
2623
|
if (input.semantic && input.diff) {
|
|
2589
2624
|
try {
|
|
2590
2625
|
const mod = await import("@hiveai/embeddings");
|
|
@@ -2603,7 +2638,7 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2603
2638
|
}
|
|
2604
2639
|
const warnings = [...seen.values()].sort((a, b) => {
|
|
2605
2640
|
const score = (w) => {
|
|
2606
|
-
const reasonW = (w.reasons.includes("anchor") ? 4 : 0) + (w.reasons.includes("literal") ? 2 : 0) + (w.reasons.includes("semantic") ? 1 : 0);
|
|
2641
|
+
const reasonW = (w.reasons.includes("sensor") ? 8 : 0) + (w.reasons.includes("anchor") ? 4 : 0) + (w.reasons.includes("literal") ? 2 : 0) + (w.reasons.includes("semantic") ? 1 : 0);
|
|
2607
2642
|
const confW = w.confidence === "authoritative" ? 3 : w.confidence === "trusted" ? 2 : w.confidence === "low" ? 1 : 0;
|
|
2608
2643
|
return reasonW + confW + (w.semantic_score ?? 0);
|
|
2609
2644
|
};
|
|
@@ -3146,6 +3181,24 @@ function classifyWarning(warning, paths, anchoredBlocks = false) {
|
|
|
3146
3181
|
repair_command: repairCommand
|
|
3147
3182
|
};
|
|
3148
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
|
+
}
|
|
3149
3202
|
if (isBlockingWarning(warning)) {
|
|
3150
3203
|
return {
|
|
3151
3204
|
...warning,
|
|
@@ -3872,7 +3925,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
3872
3925
|
// src/server.ts
|
|
3873
3926
|
import { loadConfigSync } from "@hiveai/core";
|
|
3874
3927
|
var SERVER_NAME = "haive";
|
|
3875
|
-
var SERVER_VERSION = "0.10.
|
|
3928
|
+
var SERVER_VERSION = "0.10.4";
|
|
3876
3929
|
function jsonResult(data) {
|
|
3877
3930
|
return {
|
|
3878
3931
|
content: [
|