@hiveai/mcp 0.9.29 → 0.9.31

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
@@ -521,6 +521,7 @@ declare const PreCommitCheckInputSchema: {
521
521
  paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
522
522
  block_on: z.ZodDefault<z.ZodEnum<["any", "high-confidence", "never"]>>;
523
523
  semantic: z.ZodDefault<z.ZodBoolean>;
524
+ anchored_blocks: z.ZodDefault<z.ZodBoolean>;
524
525
  };
525
526
  type PreCommitCheckInput = {
526
527
  [K in keyof typeof PreCommitCheckInputSchema]: z.infer<(typeof PreCommitCheckInputSchema)[K]>;
package/dist/server.js CHANGED
@@ -2425,6 +2425,58 @@ var AntiPatternsCheckInputSchema = {
2425
2425
  "When true, also use semantic search (requires @hiveai/embeddings + memory index) to find related anti-patterns."
2426
2426
  )
2427
2427
  };
2428
+ var CODE_STOPWORDS = /* @__PURE__ */ new Set([
2429
+ "import",
2430
+ "export",
2431
+ "function",
2432
+ "return",
2433
+ "const",
2434
+ "let",
2435
+ "var",
2436
+ "class",
2437
+ "public",
2438
+ "private",
2439
+ "protected",
2440
+ "static",
2441
+ "this",
2442
+ "true",
2443
+ "false",
2444
+ "null",
2445
+ "undefined",
2446
+ "void",
2447
+ "async",
2448
+ "await",
2449
+ "from",
2450
+ "type",
2451
+ "interface",
2452
+ "extends",
2453
+ "implements",
2454
+ "number",
2455
+ "string",
2456
+ "boolean",
2457
+ "value",
2458
+ "default",
2459
+ "case",
2460
+ "break",
2461
+ "continue",
2462
+ "throw",
2463
+ "catch",
2464
+ "finally",
2465
+ "else",
2466
+ "while",
2467
+ "for",
2468
+ "new",
2469
+ "super",
2470
+ "yield",
2471
+ "module",
2472
+ "require",
2473
+ "console"
2474
+ ]);
2475
+ function tokenizeDiffForLiteral(diff) {
2476
+ const wsTokens = tokenizeQuery3(diff);
2477
+ const wordTokens = diff.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length >= 4 && !CODE_STOPWORDS.has(t));
2478
+ return [.../* @__PURE__ */ new Set([...wsTokens, ...wordTokens])];
2479
+ }
2428
2480
  async function antiPatternsCheck(input, ctx) {
2429
2481
  if (!input.diff && input.paths.length === 0) {
2430
2482
  return {
@@ -2478,7 +2530,7 @@ async function antiPatternsCheck(input, ctx) {
2478
2530
  }
2479
2531
  }
2480
2532
  if (input.diff) {
2481
- const tokens = tokenizeQuery3(input.diff);
2533
+ const tokens = tokenizeDiffForLiteral(input.diff);
2482
2534
  if (tokens.length > 0) {
2483
2535
  for (const { memory } of negative) {
2484
2536
  if (literalMatchesAnyToken3(memory, tokens)) {
@@ -2966,7 +3018,10 @@ var PreCommitCheckInputSchema = {
2966
3018
  block_on: z28.enum(["any", "high-confidence", "never"]).default("high-confidence").describe(
2967
3019
  "When to set should_block=true: 'any' = any warning blocks; 'high-confidence' = only warnings from authoritative/trusted memories block; 'never' = report only, never block."
2968
3020
  ),
2969
- semantic: z28.boolean().default(true).describe("Enable semantic search in anti_patterns_check (requires embeddings index).")
3021
+ semantic: z28.boolean().default(true).describe("Enable semantic search in anti_patterns_check (requires embeddings index)."),
3022
+ anchored_blocks: z28.boolean().default(false).describe(
3023
+ "When true, ALSO block a high-confidence anti-pattern (attempt/gotcha) that is anchored to a touched file AND corroborated by the diff (literal token overlap, or semantic >= 0.45) \u2014 not just very strong semantic matches. Powers the 'anchored' enforcement gate. Config/docs-only commits are still downgraded. Default false preserves the soft, semantic-only blocking behavior."
3024
+ )
2970
3025
  };
2971
3026
  async function preCommitCheck(input, ctx) {
2972
3027
  if (!input.diff && input.paths.length === 0) {
@@ -2991,7 +3046,7 @@ async function preCommitCheck(input, ctx) {
2991
3046
  const filesTouching = new Set(relevantMatches.map((m) => m.id));
2992
3047
  const staleHits = verifyResult.results.filter((r) => r.stale && filesTouching.has(r.id));
2993
3048
  const blockOn = input.block_on;
2994
- const classifiedWarnings = apResult.warnings.map((warning) => classifyWarning(warning, input.paths));
3049
+ const classifiedWarnings = apResult.warnings.map((warning) => classifyWarning(warning, input.paths, input.anchored_blocks));
2995
3050
  const blockingWarnings = classifiedWarnings.filter((w) => w.level === "blocking");
2996
3051
  const reviewWarnings = classifiedWarnings.filter((w) => w.level === "review");
2997
3052
  const infoWarnings = classifiedWarnings.filter((w) => w.level === "info");
@@ -3031,7 +3086,7 @@ async function preCommitCheck(input, ctx) {
3031
3086
  })
3032
3087
  };
3033
3088
  }
3034
- function classifyWarning(warning, paths) {
3089
+ function classifyWarning(warning, paths, anchoredBlocks = false) {
3035
3090
  const affectedFiles = paths.filter((p) => !p.startsWith(".ai/.usage/"));
3036
3091
  const repairCommand = repairCommandForWarning(warning, affectedFiles);
3037
3092
  const fileDowngrade = fileTypeDowngradeReason(warning, affectedFiles);
@@ -3056,6 +3111,15 @@ function classifyWarning(warning, paths) {
3056
3111
  const hasSemantic = warning.reasons.includes("semantic");
3057
3112
  const semanticScore = warning.semantic_score ?? 0;
3058
3113
  const highConfidence = warning.confidence === "authoritative" || warning.confidence === "trusted";
3114
+ if (anchoredBlocks && highConfidence && warning.reasons.includes("anchor") && (warning.reasons.includes("literal") || hasSemantic && semanticScore >= 0.45)) {
3115
+ return {
3116
+ ...warning,
3117
+ level: "blocking",
3118
+ rationale: "high-confidence anti-pattern anchored to a touched file and corroborated by the diff (anchored gate)",
3119
+ affected_files: affectedFiles,
3120
+ repair_command: repairCommand
3121
+ };
3122
+ }
3059
3123
  if (hasSemantic && semanticScore >= 0.45 || highConfidence && warning.reasons.includes("anchor") && warning.reasons.includes("literal")) {
3060
3124
  return {
3061
3125
  ...warning,
@@ -3761,7 +3825,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
3761
3825
  // src/server.ts
3762
3826
  import { loadConfigSync } from "@hiveai/core";
3763
3827
  var SERVER_NAME = "haive";
3764
- var SERVER_VERSION = "0.9.29";
3828
+ var SERVER_VERSION = "0.9.31";
3765
3829
  function jsonResult(data) {
3766
3830
  return {
3767
3831
  content: [