@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/server.d.ts CHANGED
@@ -91,6 +91,7 @@ interface BriefingOutput {
91
91
  truncated: boolean;
92
92
  is_template?: boolean;
93
93
  auto_generated?: boolean;
94
+ omitted_recent?: boolean;
94
95
  } | null;
95
96
  module_contexts: Array<{
96
97
  name: string;
@@ -143,6 +144,7 @@ declare const GetBriefingZod: z.ZodObject<{
143
144
  max_tokens: z.ZodDefault<z.ZodNumber>;
144
145
  max_memories: z.ZodDefault<z.ZodNumber>;
145
146
  include_project_context: z.ZodDefault<z.ZodBoolean>;
147
+ dedupe_project_context: z.ZodOptional<z.ZodBoolean>;
146
148
  include_module_contexts: z.ZodDefault<z.ZodBoolean>;
147
149
  semantic: z.ZodDefault<z.ZodBoolean>;
148
150
  include_stale: z.ZodDefault<z.ZodBoolean>;
@@ -164,6 +166,7 @@ declare const GetBriefingZod: z.ZodObject<{
164
166
  track: boolean;
165
167
  min_semantic_score: number;
166
168
  task?: string | undefined;
169
+ dedupe_project_context?: boolean | undefined;
167
170
  budget_preset?: "quick" | "balanced" | "deep" | undefined;
168
171
  }, {
169
172
  symbols?: string[] | undefined;
@@ -173,6 +176,7 @@ declare const GetBriefingZod: z.ZodObject<{
173
176
  max_tokens?: number | undefined;
174
177
  max_memories?: number | undefined;
175
178
  include_project_context?: boolean | undefined;
179
+ dedupe_project_context?: boolean | undefined;
176
180
  include_module_contexts?: boolean | undefined;
177
181
  semantic?: boolean | undefined;
178
182
  include_stale?: boolean | undefined;
package/dist/server.js CHANGED
@@ -1583,10 +1583,13 @@ import {
1583
1583
  literalMatchesAnyToken as literalMatchesAnyToken2,
1584
1584
  loadCodeMap,
1585
1585
  loadConfig as loadConfig3,
1586
+ hashProjectContext,
1586
1587
  loadMemoriesFromDir as loadMemoriesFromDir15,
1587
1588
  loadUsageIndex as loadUsageIndex8,
1588
1589
  memoryMatchesAnchorPaths as memoryMatchesAnchorPaths2,
1590
+ projectContextRecentlyEmitted,
1589
1591
  rankMemoriesLexical as rankMemoriesLexical2,
1592
+ recordProjectContextEmission,
1590
1593
  queryCodeMap,
1591
1594
  resolveBriefingBudget,
1592
1595
  serializeMemory as serializeMemory10,
@@ -1754,6 +1757,9 @@ var GetBriefingInputSchema = {
1754
1757
  ),
1755
1758
  max_memories: z19.number().int().positive().default(8).describe("Cap on memories surfaced regardless of token budget"),
1756
1759
  include_project_context: z19.boolean().default(true),
1760
+ dedupe_project_context: z19.boolean().optional().describe(
1761
+ "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."
1762
+ ),
1757
1763
  include_module_contexts: z19.boolean().default(true),
1758
1764
  semantic: z19.boolean().default(true).describe(
1759
1765
  "Use semantic ranking when a task is provided (requires `haive embeddings index`)."
@@ -1961,7 +1967,17 @@ async function getBriefing(input, ctx) {
1961
1967
  }
1962
1968
  }
1963
1969
  }
1964
- const projectContextRaw = input.include_project_context && existsSync21(ctx.paths.projectContext) ? await readFile5(ctx.paths.projectContext, "utf8") : "";
1970
+ let projectContextRaw = input.include_project_context && existsSync21(ctx.paths.projectContext) ? await readFile5(ctx.paths.projectContext, "utf8") : "";
1971
+ let contextOmittedRecent = false;
1972
+ if (projectContextRaw && input.dedupe_project_context !== false) {
1973
+ const ctxHash = hashProjectContext(projectContextRaw);
1974
+ if (await projectContextRecentlyEmitted(ctx.paths, ctxHash)) {
1975
+ contextOmittedRecent = true;
1976
+ projectContextRaw = "";
1977
+ } else {
1978
+ await recordProjectContextEmission(ctx.paths, ctxHash);
1979
+ }
1980
+ }
1965
1981
  const isTemplateContext = projectContextRaw.includes("TODO \u2014 high-level overview") || projectContextRaw.includes("Generated by `haive init`");
1966
1982
  const setupWarnings = [];
1967
1983
  let autoContextGenerated = false;
@@ -2229,7 +2245,11 @@ When done, call \`mem_session_end\` to acknowledge \u2014 this clears the pendin
2229
2245
  search_mode: searchMode,
2230
2246
  inferred_modules: inferred,
2231
2247
  ...lastSession ? { last_session: lastSession } : {},
2232
- project_context: adaptiveTrim ? {
2248
+ project_context: contextOmittedRecent ? {
2249
+ 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.)",
2250
+ truncated: false,
2251
+ omitted_recent: true
2252
+ } : adaptiveTrim ? {
2233
2253
  content: "(adaptive briefing: auto-generated context omitted \u2014 no team-specific policy matched, so a capable model needs nothing extra here)",
2234
2254
  truncated: false,
2235
2255
  ...isTemplateContext && !autoContextGenerated ? { is_template: true } : {},
@@ -2618,6 +2638,7 @@ function runCommand(cmd, args, cwd) {
2618
2638
  import { existsSync as existsSync25 } from "fs";
2619
2639
  import {
2620
2640
  addedLinesFromDiff,
2641
+ appendPreventionEvent,
2621
2642
  buildDocFrequency,
2622
2643
  CODE_STOPWORDS,
2623
2644
  deriveConfidence as deriveConfidence6,
@@ -2628,7 +2649,9 @@ import {
2628
2649
  loadUsageIndex as loadUsageIndex10,
2629
2650
  literalMatchesAnyToken as literalMatchesAnyToken3,
2630
2651
  memoryMatchesAnchorPaths as memoryMatchesAnchorPaths4,
2652
+ recordPrevention,
2631
2653
  runSensors,
2654
+ saveUsageIndex as saveUsageIndex4,
2632
2655
  sensorTargetsFromDiff,
2633
2656
  tokenizeQuery as tokenizeQuery3
2634
2657
  } from "@hiveai/core";
@@ -2769,6 +2792,22 @@ async function antiPatternsCheck(input, ctx) {
2769
2792
  };
2770
2793
  return score(b) - score(a);
2771
2794
  }).slice(0, input.limit);
2795
+ const strongCatches = warnings.filter(
2796
+ (w) => w.reasons.includes("sensor") || w.distinctive_literal === true || w.reasons.includes("anchor") && w.reasons.includes("literal")
2797
+ );
2798
+ if (strongCatches.length > 0) {
2799
+ const recordedIds = [];
2800
+ for (const w of strongCatches) if (recordPrevention(usage, w.id)) recordedIds.push(w.id);
2801
+ if (recordedIds.length > 0) {
2802
+ await saveUsageIndex4(ctx.paths, usage).catch(() => {
2803
+ });
2804
+ const at = (/* @__PURE__ */ new Date()).toISOString();
2805
+ for (const id of recordedIds) {
2806
+ await appendPreventionEvent(ctx.paths, { at, id, source: "anti-pattern" }).catch(() => {
2807
+ });
2808
+ }
2809
+ }
2810
+ }
2772
2811
  return {
2773
2812
  scanned: negative.length,
2774
2813
  warnings
@@ -4109,7 +4148,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
4109
4148
  // src/server.ts
4110
4149
  import { hasRecentBriefingMarker, loadConfigSync } from "@hiveai/core";
4111
4150
  var SERVER_NAME = "haive";
4112
- var SERVER_VERSION = "0.13.8";
4151
+ var SERVER_VERSION = "0.14.0";
4113
4152
  function jsonResult(data) {
4114
4153
  return {
4115
4154
  content: [
@@ -4858,6 +4897,7 @@ function createHaiveServer(options = {}) {
4858
4897
  "anti_patterns_check",
4859
4898
  [
4860
4899
  "Scan a diff (or set of paths) against documented attempt/gotcha memories.",
4900
+ "[Diff-scan layer: the MEMORY-MATCH component. `pre_commit_check` combines this with sensors + stale checks; `haive enforce check` is the gate.]",
4861
4901
  "Surfaces 'you are about to repeat a known mistake' warnings BEFORE you commit.",
4862
4902
  "",
4863
4903
  "USE BEFORE finalizing a non-trivial change. Cheap and high-signal: the only",
@@ -5001,6 +5041,7 @@ function createHaiveServer(options = {}) {
5001
5041
  "pre_commit_check",
5002
5042
  [
5003
5043
  "One-shot 'should I block this commit?' check. Combines three signals:",
5044
+ "[Diff-scan layer: the COMBINED check (sensors + anti-patterns + stale). `haive enforce check` is the gate that runs this at commit time.]",
5004
5045
  "",
5005
5046
  " 1. anti_patterns_check \u2014 known gotchas/attempts that match the diff",
5006
5047
  " 2. mem_for_files \u2014 conventions/decisions anchored to touched files",