@hiveai/mcp 0.11.0 → 0.12.0
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 +17 -49
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.js +17 -49
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.ts
CHANGED
|
@@ -361,6 +361,13 @@ interface AntiPatternsWarning {
|
|
|
361
361
|
confidence: string;
|
|
362
362
|
body_preview: string;
|
|
363
363
|
reasons: Array<"anchor" | "literal" | "semantic" | "sensor">;
|
|
364
|
+
/**
|
|
365
|
+
* True when the LITERAL overlap includes a token that is *distinctive* to this memory
|
|
366
|
+
* (rare across the gotcha corpus) — e.g. `BigInt`, `open-in-view`. Only a distinctive
|
|
367
|
+
* literal overlap is precise enough to hard-block; a shared common word ("memory",
|
|
368
|
+
* "scope", "version") sets only the `literal` reason for review. Powers the gate.
|
|
369
|
+
*/
|
|
370
|
+
distinctive_literal?: boolean;
|
|
364
371
|
semantic_score?: number;
|
|
365
372
|
/** When a regex sensor fired: its self-correction message and severity. */
|
|
366
373
|
sensor_message?: string;
|
package/dist/server.js
CHANGED
|
@@ -2514,7 +2514,10 @@ function runCommand(cmd, args, cwd) {
|
|
|
2514
2514
|
import { existsSync as existsSync24 } from "fs";
|
|
2515
2515
|
import {
|
|
2516
2516
|
addedLinesFromDiff,
|
|
2517
|
+
buildDocFrequency,
|
|
2518
|
+
CODE_STOPWORDS,
|
|
2517
2519
|
deriveConfidence as deriveConfidence6,
|
|
2520
|
+
diffHasDistinctiveOverlap,
|
|
2518
2521
|
getUsage as getUsage8,
|
|
2519
2522
|
isRetiredMemory as isRetiredMemory2,
|
|
2520
2523
|
loadMemoriesFromDir as loadMemoriesFromDir18,
|
|
@@ -2541,53 +2544,6 @@ var AntiPatternsCheckInputSchema = {
|
|
|
2541
2544
|
"Minimum cosine score for semantic-only anti-pattern hits. Anchor/literal matches still surface. Default 0.45 keeps broad, weakly-related memories out of review noise."
|
|
2542
2545
|
)
|
|
2543
2546
|
};
|
|
2544
|
-
var CODE_STOPWORDS = /* @__PURE__ */ new Set([
|
|
2545
|
-
"import",
|
|
2546
|
-
"export",
|
|
2547
|
-
"function",
|
|
2548
|
-
"return",
|
|
2549
|
-
"const",
|
|
2550
|
-
"let",
|
|
2551
|
-
"var",
|
|
2552
|
-
"class",
|
|
2553
|
-
"public",
|
|
2554
|
-
"private",
|
|
2555
|
-
"protected",
|
|
2556
|
-
"static",
|
|
2557
|
-
"this",
|
|
2558
|
-
"true",
|
|
2559
|
-
"false",
|
|
2560
|
-
"null",
|
|
2561
|
-
"undefined",
|
|
2562
|
-
"void",
|
|
2563
|
-
"async",
|
|
2564
|
-
"await",
|
|
2565
|
-
"from",
|
|
2566
|
-
"type",
|
|
2567
|
-
"interface",
|
|
2568
|
-
"extends",
|
|
2569
|
-
"implements",
|
|
2570
|
-
"number",
|
|
2571
|
-
"string",
|
|
2572
|
-
"boolean",
|
|
2573
|
-
"value",
|
|
2574
|
-
"default",
|
|
2575
|
-
"case",
|
|
2576
|
-
"break",
|
|
2577
|
-
"continue",
|
|
2578
|
-
"throw",
|
|
2579
|
-
"catch",
|
|
2580
|
-
"finally",
|
|
2581
|
-
"else",
|
|
2582
|
-
"while",
|
|
2583
|
-
"for",
|
|
2584
|
-
"new",
|
|
2585
|
-
"super",
|
|
2586
|
-
"yield",
|
|
2587
|
-
"module",
|
|
2588
|
-
"require",
|
|
2589
|
-
"console"
|
|
2590
|
-
]);
|
|
2591
2547
|
function tokenizeDiffForLiteral(diff) {
|
|
2592
2548
|
const lines = diff.split("\n");
|
|
2593
2549
|
const looksLikeDiff = lines.some((l) => /^[+-]/.test(l));
|
|
@@ -2620,6 +2576,7 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2620
2576
|
return { scanned: 0, warnings: [], notice: "No attempt/gotcha memories found yet." };
|
|
2621
2577
|
}
|
|
2622
2578
|
const usage = await loadUsageIndex10(ctx.paths);
|
|
2579
|
+
const docFreq = buildDocFrequency(negative.map(({ memory }) => memory.body));
|
|
2623
2580
|
const seen = /* @__PURE__ */ new Map();
|
|
2624
2581
|
const upsert = (fm, body, reason, score) => {
|
|
2625
2582
|
const existing = seen.get(fm.id);
|
|
@@ -2653,10 +2610,16 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2653
2610
|
}
|
|
2654
2611
|
if (input.diff) {
|
|
2655
2612
|
const tokens = tokenizeDiffForLiteral(input.diff);
|
|
2613
|
+
const added = addedLinesFromDiff(input.diff);
|
|
2614
|
+
const addedText = added.trim().length > 0 ? added : input.diff;
|
|
2656
2615
|
if (tokens.length > 0) {
|
|
2657
2616
|
for (const { memory } of negative) {
|
|
2658
2617
|
if (literalMatchesAnyToken3(memory, tokens)) {
|
|
2659
2618
|
upsert(memory.frontmatter, memory.body, "literal");
|
|
2619
|
+
if (diffHasDistinctiveOverlap(addedText, memory.body, docFreq)) {
|
|
2620
|
+
const w = seen.get(memory.frontmatter.id);
|
|
2621
|
+
if (w) w.distinctive_literal = true;
|
|
2622
|
+
}
|
|
2660
2623
|
}
|
|
2661
2624
|
}
|
|
2662
2625
|
}
|
|
@@ -3289,7 +3252,12 @@ function classifyWarning(warning, paths, anchoredBlocks = false) {
|
|
|
3289
3252
|
const hasSemantic = warning.reasons.includes("semantic");
|
|
3290
3253
|
const semanticScore = warning.semantic_score ?? 0;
|
|
3291
3254
|
const highConfidence = warning.confidence === "authoritative" || warning.confidence === "trusted";
|
|
3292
|
-
if (anchoredBlocks && highConfidence && warning.scope !== "personal" && warning.reasons.includes("anchor") &&
|
|
3255
|
+
if (anchoredBlocks && highConfidence && warning.scope !== "personal" && warning.reasons.includes("anchor") && // A literal overlap only corroborates a BLOCK when it is on a token *distinctive*
|
|
3256
|
+
// to this gotcha (rare in the corpus). Sharing a common domain word ("memory",
|
|
3257
|
+
// "scope", "version") — or a version-bump diff — no longer hard-blocks; it falls
|
|
3258
|
+
// through to `review` below. This kills the incidental-token false positives that
|
|
3259
|
+
// made agents work for nothing. A moderate semantic match still corroborates.
|
|
3260
|
+
(warning.distinctive_literal === true || hasSemantic && semanticScore >= 0.45)) {
|
|
3293
3261
|
if (warning.has_sensor && !warning.reasons.includes("sensor")) {
|
|
3294
3262
|
return {
|
|
3295
3263
|
...warning,
|
|
@@ -4036,7 +4004,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
4036
4004
|
// src/server.ts
|
|
4037
4005
|
import { hasRecentBriefingMarker, loadConfigSync } from "@hiveai/core";
|
|
4038
4006
|
var SERVER_NAME = "haive";
|
|
4039
|
-
var SERVER_VERSION = "0.
|
|
4007
|
+
var SERVER_VERSION = "0.12.0";
|
|
4040
4008
|
function jsonResult(data) {
|
|
4041
4009
|
return {
|
|
4042
4010
|
content: [
|