@hiveai/mcp 0.13.8 → 0.14.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 CHANGED
@@ -1585,10 +1585,13 @@ import {
1585
1585
  literalMatchesAnyToken as literalMatchesAnyToken2,
1586
1586
  loadCodeMap,
1587
1587
  loadConfig as loadConfig3,
1588
+ hashProjectContext,
1588
1589
  loadMemoriesFromDir as loadMemoriesFromDir15,
1589
1590
  loadUsageIndex as loadUsageIndex8,
1590
1591
  memoryMatchesAnchorPaths as memoryMatchesAnchorPaths2,
1592
+ projectContextRecentlyEmitted,
1591
1593
  rankMemoriesLexical as rankMemoriesLexical2,
1594
+ recordProjectContextEmission,
1592
1595
  queryCodeMap,
1593
1596
  resolveBriefingBudget,
1594
1597
  serializeMemory as serializeMemory10,
@@ -1756,6 +1759,9 @@ var GetBriefingInputSchema = {
1756
1759
  ),
1757
1760
  max_memories: z19.number().int().positive().default(8).describe("Cap on memories surfaced regardless of token budget"),
1758
1761
  include_project_context: z19.boolean().default(true),
1762
+ dedupe_project_context: z19.boolean().optional().describe(
1763
+ "Token saver (default ON): skip re-emitting the project-context body if an identical copy was already sent within the last few minutes this session (the agent still has it). Set false to always include it."
1764
+ ),
1759
1765
  include_module_contexts: z19.boolean().default(true),
1760
1766
  semantic: z19.boolean().default(true).describe(
1761
1767
  "Use semantic ranking when a task is provided (requires `haive embeddings index`)."
@@ -1963,7 +1969,17 @@ async function getBriefing(input, ctx) {
1963
1969
  }
1964
1970
  }
1965
1971
  }
1966
- const projectContextRaw = input.include_project_context && existsSync21(ctx.paths.projectContext) ? await readFile5(ctx.paths.projectContext, "utf8") : "";
1972
+ let projectContextRaw = input.include_project_context && existsSync21(ctx.paths.projectContext) ? await readFile5(ctx.paths.projectContext, "utf8") : "";
1973
+ let contextOmittedRecent = false;
1974
+ if (projectContextRaw && input.dedupe_project_context !== false) {
1975
+ const ctxHash = hashProjectContext(projectContextRaw);
1976
+ if (await projectContextRecentlyEmitted(ctx.paths, ctxHash)) {
1977
+ contextOmittedRecent = true;
1978
+ projectContextRaw = "";
1979
+ } else {
1980
+ await recordProjectContextEmission(ctx.paths, ctxHash);
1981
+ }
1982
+ }
1967
1983
  const isTemplateContext = projectContextRaw.includes("TODO \u2014 high-level overview") || projectContextRaw.includes("Generated by `haive init`");
1968
1984
  const setupWarnings = [];
1969
1985
  let autoContextGenerated = false;
@@ -2231,7 +2247,11 @@ When done, call \`mem_session_end\` to acknowledge \u2014 this clears the pendin
2231
2247
  search_mode: searchMode,
2232
2248
  inferred_modules: inferred,
2233
2249
  ...lastSession ? { last_session: lastSession } : {},
2234
- project_context: adaptiveTrim ? {
2250
+ project_context: contextOmittedRecent ? {
2251
+ content: "(project context unchanged \u2014 omitted to save tokens; it was provided earlier this session. Pass dedupe_project_context:false to force a full copy.)",
2252
+ truncated: false,
2253
+ omitted_recent: true
2254
+ } : adaptiveTrim ? {
2235
2255
  content: "(adaptive briefing: auto-generated context omitted \u2014 no team-specific policy matched, so a capable model needs nothing extra here)",
2236
2256
  truncated: false,
2237
2257
  ...isTemplateContext && !autoContextGenerated ? { is_template: true } : {},
@@ -2620,6 +2640,7 @@ function runCommand(cmd, args, cwd) {
2620
2640
  import { existsSync as existsSync25 } from "fs";
2621
2641
  import {
2622
2642
  addedLinesFromDiff,
2643
+ appendPreventionEvent,
2623
2644
  buildDocFrequency,
2624
2645
  CODE_STOPWORDS,
2625
2646
  deriveConfidence as deriveConfidence6,
@@ -2630,7 +2651,9 @@ import {
2630
2651
  loadUsageIndex as loadUsageIndex10,
2631
2652
  literalMatchesAnyToken as literalMatchesAnyToken3,
2632
2653
  memoryMatchesAnchorPaths as memoryMatchesAnchorPaths4,
2654
+ recordPrevention,
2633
2655
  runSensors,
2656
+ saveUsageIndex as saveUsageIndex4,
2634
2657
  sensorTargetsFromDiff,
2635
2658
  tokenizeQuery as tokenizeQuery3
2636
2659
  } from "@hiveai/core";
@@ -2771,6 +2794,22 @@ async function antiPatternsCheck(input, ctx) {
2771
2794
  };
2772
2795
  return score(b) - score(a);
2773
2796
  }).slice(0, input.limit);
2797
+ const strongCatches = warnings.filter(
2798
+ (w) => w.reasons.includes("sensor") || w.distinctive_literal === true || w.reasons.includes("anchor") && w.reasons.includes("literal")
2799
+ );
2800
+ if (strongCatches.length > 0) {
2801
+ const recordedIds = [];
2802
+ for (const w of strongCatches) if (recordPrevention(usage, w.id)) recordedIds.push(w.id);
2803
+ if (recordedIds.length > 0) {
2804
+ await saveUsageIndex4(ctx.paths, usage).catch(() => {
2805
+ });
2806
+ const at = (/* @__PURE__ */ new Date()).toISOString();
2807
+ for (const id of recordedIds) {
2808
+ await appendPreventionEvent(ctx.paths, { at, id, source: "anti-pattern" }).catch(() => {
2809
+ });
2810
+ }
2811
+ }
2812
+ }
2774
2813
  return {
2775
2814
  scanned: negative.length,
2776
2815
  warnings
@@ -4111,7 +4150,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
4111
4150
  // src/server.ts
4112
4151
  import { hasRecentBriefingMarker, loadConfigSync } from "@hiveai/core";
4113
4152
  var SERVER_NAME = "haive";
4114
- var SERVER_VERSION = "0.13.8";
4153
+ var SERVER_VERSION = "0.14.0";
4115
4154
  function jsonResult(data) {
4116
4155
  return {
4117
4156
  content: [
@@ -4860,6 +4899,7 @@ function createHaiveServer(options = {}) {
4860
4899
  "anti_patterns_check",
4861
4900
  [
4862
4901
  "Scan a diff (or set of paths) against documented attempt/gotcha memories.",
4902
+ "[Diff-scan layer: the MEMORY-MATCH component. `pre_commit_check` combines this with sensors + stale checks; `haive enforce check` is the gate.]",
4863
4903
  "Surfaces 'you are about to repeat a known mistake' warnings BEFORE you commit.",
4864
4904
  "",
4865
4905
  "USE BEFORE finalizing a non-trivial change. Cheap and high-signal: the only",
@@ -5003,6 +5043,7 @@ function createHaiveServer(options = {}) {
5003
5043
  "pre_commit_check",
5004
5044
  [
5005
5045
  "One-shot 'should I block this commit?' check. Combines three signals:",
5046
+ "[Diff-scan layer: the COMBINED check (sensors + anti-patterns + stale). `haive enforce check` is the gate that runs this at commit time.]",
5006
5047
  "",
5007
5048
  " 1. anti_patterns_check \u2014 known gotchas/attempts that match the diff",
5008
5049
  " 2. mem_for_files \u2014 conventions/decisions anchored to touched files",