@hiveai/mcp 0.11.0 → 0.12.1
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 +32 -51
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.js +32 -51
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1497,6 +1497,7 @@ import {
|
|
|
1497
1497
|
loadMemoriesFromDir as loadMemoriesFromDir14,
|
|
1498
1498
|
loadUsageIndex as loadUsageIndex8,
|
|
1499
1499
|
memoryMatchesAnchorPaths as memoryMatchesAnchorPaths2,
|
|
1500
|
+
rankMemoriesLexical as rankMemoriesLexical2,
|
|
1500
1501
|
queryCodeMap,
|
|
1501
1502
|
resolveBriefingBudget,
|
|
1502
1503
|
serializeMemory as serializeMemory9,
|
|
@@ -1816,13 +1817,25 @@ async function getBriefing(input, ctx) {
|
|
|
1816
1817
|
}
|
|
1817
1818
|
if (act.applicable && act.activated) activatedSkills.add(id);
|
|
1818
1819
|
}
|
|
1820
|
+
const lexNorm = /* @__PURE__ */ new Map();
|
|
1821
|
+
if (input.task) {
|
|
1822
|
+
const candidates = [...seen.keys()].map((id) => byId.get(id)).filter((x) => Boolean(x));
|
|
1823
|
+
const lex = rankMemoriesLexical2(candidates, input.task, candidates.length);
|
|
1824
|
+
const maxScore = lex.scores.reduce((m, s) => s > m ? s : m, 0);
|
|
1825
|
+
if (maxScore > 0) {
|
|
1826
|
+
lex.ranked.forEach((loaded, i) => {
|
|
1827
|
+
lexNorm.set(loaded.memory.frontmatter.id, (lex.scores[i] ?? 0) / maxScore);
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1819
1831
|
const ranked = [...seen.values()].sort((a, b) => {
|
|
1820
1832
|
const reasonScore = (m) => (m.type === "attempt" ? 3 : 0) + (m.reasons.includes("anchor") ? 4 : 0) + (m.reasons.includes("symbol") ? 4 : 0) + (m.reasons.includes("module") ? 2 : 0) + (m.reasons.includes("semantic") ? 2 : 0) + (m.reasons.includes("domain") ? 1 : 0);
|
|
1821
1833
|
const confidenceScore = (m) => m.confidence === "authoritative" ? 4 : m.confidence === "trusted" ? 3 : m.confidence === "low" ? 1 : m.confidence === "stale" ? -2 : 0;
|
|
1822
1834
|
const impactScore = (m) => (m.impact_score ?? 0) * 3;
|
|
1823
1835
|
const activationBoost = (m) => activatedSkills.has(m.id) ? 5 : 0;
|
|
1824
|
-
const
|
|
1825
|
-
const
|
|
1836
|
+
const lexScore = (m) => 12 * (lexNorm.get(m.id) ?? 0);
|
|
1837
|
+
const sa = priorityRank(classifyMemoryPriority(a, byId.get(a.id), input.files, input.symbols)) * 100 + reasonScore(a) + confidenceScore(a) + impactScore(a) + activationBoost(a) + lexScore(a) + (a.semantic_score ?? 0);
|
|
1838
|
+
const sb = priorityRank(classifyMemoryPriority(b, byId.get(b.id), input.files, input.symbols)) * 100 + reasonScore(b) + confidenceScore(b) + impactScore(b) + activationBoost(b) + lexScore(b) + (b.semantic_score ?? 0);
|
|
1826
1839
|
return sb - sa;
|
|
1827
1840
|
});
|
|
1828
1841
|
for (const mem of ranked.slice(0, briefingMaxMemories)) {
|
|
@@ -2516,7 +2529,10 @@ function runCommand(cmd, args, cwd) {
|
|
|
2516
2529
|
import { existsSync as existsSync24 } from "fs";
|
|
2517
2530
|
import {
|
|
2518
2531
|
addedLinesFromDiff,
|
|
2532
|
+
buildDocFrequency,
|
|
2533
|
+
CODE_STOPWORDS,
|
|
2519
2534
|
deriveConfidence as deriveConfidence6,
|
|
2535
|
+
diffHasDistinctiveOverlap,
|
|
2520
2536
|
getUsage as getUsage8,
|
|
2521
2537
|
isRetiredMemory as isRetiredMemory2,
|
|
2522
2538
|
loadMemoriesFromDir as loadMemoriesFromDir18,
|
|
@@ -2543,53 +2559,6 @@ var AntiPatternsCheckInputSchema = {
|
|
|
2543
2559
|
"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."
|
|
2544
2560
|
)
|
|
2545
2561
|
};
|
|
2546
|
-
var CODE_STOPWORDS = /* @__PURE__ */ new Set([
|
|
2547
|
-
"import",
|
|
2548
|
-
"export",
|
|
2549
|
-
"function",
|
|
2550
|
-
"return",
|
|
2551
|
-
"const",
|
|
2552
|
-
"let",
|
|
2553
|
-
"var",
|
|
2554
|
-
"class",
|
|
2555
|
-
"public",
|
|
2556
|
-
"private",
|
|
2557
|
-
"protected",
|
|
2558
|
-
"static",
|
|
2559
|
-
"this",
|
|
2560
|
-
"true",
|
|
2561
|
-
"false",
|
|
2562
|
-
"null",
|
|
2563
|
-
"undefined",
|
|
2564
|
-
"void",
|
|
2565
|
-
"async",
|
|
2566
|
-
"await",
|
|
2567
|
-
"from",
|
|
2568
|
-
"type",
|
|
2569
|
-
"interface",
|
|
2570
|
-
"extends",
|
|
2571
|
-
"implements",
|
|
2572
|
-
"number",
|
|
2573
|
-
"string",
|
|
2574
|
-
"boolean",
|
|
2575
|
-
"value",
|
|
2576
|
-
"default",
|
|
2577
|
-
"case",
|
|
2578
|
-
"break",
|
|
2579
|
-
"continue",
|
|
2580
|
-
"throw",
|
|
2581
|
-
"catch",
|
|
2582
|
-
"finally",
|
|
2583
|
-
"else",
|
|
2584
|
-
"while",
|
|
2585
|
-
"for",
|
|
2586
|
-
"new",
|
|
2587
|
-
"super",
|
|
2588
|
-
"yield",
|
|
2589
|
-
"module",
|
|
2590
|
-
"require",
|
|
2591
|
-
"console"
|
|
2592
|
-
]);
|
|
2593
2562
|
function tokenizeDiffForLiteral(diff) {
|
|
2594
2563
|
const lines = diff.split("\n");
|
|
2595
2564
|
const looksLikeDiff = lines.some((l) => /^[+-]/.test(l));
|
|
@@ -2622,6 +2591,7 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2622
2591
|
return { scanned: 0, warnings: [], notice: "No attempt/gotcha memories found yet." };
|
|
2623
2592
|
}
|
|
2624
2593
|
const usage = await loadUsageIndex10(ctx.paths);
|
|
2594
|
+
const docFreq = buildDocFrequency(negative.map(({ memory }) => memory.body));
|
|
2625
2595
|
const seen = /* @__PURE__ */ new Map();
|
|
2626
2596
|
const upsert = (fm, body, reason, score) => {
|
|
2627
2597
|
const existing = seen.get(fm.id);
|
|
@@ -2655,10 +2625,16 @@ async function antiPatternsCheck(input, ctx) {
|
|
|
2655
2625
|
}
|
|
2656
2626
|
if (input.diff) {
|
|
2657
2627
|
const tokens = tokenizeDiffForLiteral(input.diff);
|
|
2628
|
+
const added = addedLinesFromDiff(input.diff);
|
|
2629
|
+
const addedText = added.trim().length > 0 ? added : input.diff;
|
|
2658
2630
|
if (tokens.length > 0) {
|
|
2659
2631
|
for (const { memory } of negative) {
|
|
2660
2632
|
if (literalMatchesAnyToken3(memory, tokens)) {
|
|
2661
2633
|
upsert(memory.frontmatter, memory.body, "literal");
|
|
2634
|
+
if (diffHasDistinctiveOverlap(addedText, memory.body, docFreq)) {
|
|
2635
|
+
const w = seen.get(memory.frontmatter.id);
|
|
2636
|
+
if (w) w.distinctive_literal = true;
|
|
2637
|
+
}
|
|
2662
2638
|
}
|
|
2663
2639
|
}
|
|
2664
2640
|
}
|
|
@@ -3291,7 +3267,12 @@ function classifyWarning(warning, paths, anchoredBlocks = false) {
|
|
|
3291
3267
|
const hasSemantic = warning.reasons.includes("semantic");
|
|
3292
3268
|
const semanticScore = warning.semantic_score ?? 0;
|
|
3293
3269
|
const highConfidence = warning.confidence === "authoritative" || warning.confidence === "trusted";
|
|
3294
|
-
if (anchoredBlocks && highConfidence && warning.scope !== "personal" && warning.reasons.includes("anchor") &&
|
|
3270
|
+
if (anchoredBlocks && highConfidence && warning.scope !== "personal" && warning.reasons.includes("anchor") && // A literal overlap only corroborates a BLOCK when it is on a token *distinctive*
|
|
3271
|
+
// to this gotcha (rare in the corpus). Sharing a common domain word ("memory",
|
|
3272
|
+
// "scope", "version") — or a version-bump diff — no longer hard-blocks; it falls
|
|
3273
|
+
// through to `review` below. This kills the incidental-token false positives that
|
|
3274
|
+
// made agents work for nothing. A moderate semantic match still corroborates.
|
|
3275
|
+
(warning.distinctive_literal === true || hasSemantic && semanticScore >= 0.45)) {
|
|
3295
3276
|
if (warning.has_sensor && !warning.reasons.includes("sensor")) {
|
|
3296
3277
|
return {
|
|
3297
3278
|
...warning,
|
|
@@ -4038,7 +4019,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
4038
4019
|
// src/server.ts
|
|
4039
4020
|
import { hasRecentBriefingMarker, loadConfigSync } from "@hiveai/core";
|
|
4040
4021
|
var SERVER_NAME = "haive";
|
|
4041
|
-
var SERVER_VERSION = "0.
|
|
4022
|
+
var SERVER_VERSION = "0.12.1";
|
|
4042
4023
|
function jsonResult(data) {
|
|
4043
4024
|
return {
|
|
4044
4025
|
content: [
|