@hivelore/mcp 0.44.0 → 0.46.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
@@ -695,6 +695,7 @@ declare const ScaffoldTestInputSchema: {
695
695
  memory_id: z.ZodString;
696
696
  framework: z.ZodOptional<z.ZodEnum<["vitest", "jest", "pytest", "gotest"]>>;
697
697
  out_path: z.ZodOptional<z.ZodString>;
698
+ red_ref: z.ZodOptional<z.ZodString>;
698
699
  write: z.ZodDefault<z.ZodBoolean>;
699
700
  };
700
701
  type ScaffoldTestInput = {
package/dist/server.js CHANGED
@@ -1793,15 +1793,24 @@ async function memTried(input, ctx) {
1793
1793
  import { existsSync as existsSync17, statSync } from "fs";
1794
1794
  import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile10 } from "fs/promises";
1795
1795
  import path8 from "path";
1796
+ import { execFile } from "child_process";
1797
+ import { promisify } from "util";
1796
1798
  import { z as z17 } from "zod";
1797
1799
  import {
1798
1800
  buildProposeCommand,
1801
+ incidentHintsFromDiff,
1799
1802
  loadMemoriesFromDir as loadMemoriesFromDir14,
1800
1803
  normalizeFramework,
1801
1804
  parseLessonFields,
1802
1805
  pickTestFramework,
1803
1806
  scaffoldPostIncidentTest
1804
1807
  } from "@hivelore/core";
1808
+ var execFileAsync = promisify(execFile);
1809
+ async function gitDiffText(root, redRef, paths) {
1810
+ const args = ["diff", redRef, "HEAD", "--", ...paths];
1811
+ const { stdout } = await execFileAsync("git", args, { cwd: root, maxBuffer: 64 * 1024 * 1024 });
1812
+ return stdout;
1813
+ }
1805
1814
  var PY_SIGNALS = ["pyproject.toml", "setup.py", "pytest.ini", "requirements.txt", "tox.ini"];
1806
1815
  async function detectForAnchor(root, rel) {
1807
1816
  let dir = path8.resolve(root, rel);
@@ -1856,6 +1865,9 @@ var ScaffoldTestInputSchema = {
1856
1865
  memory_id: z17.string().min(1).describe("Id of the attempt/gotcha lesson to scaffold a post-incident test from."),
1857
1866
  framework: z17.enum(["vitest", "jest", "pytest", "gotest"]).optional().describe("Test framework. Auto-detected from the package that owns the lesson's anchor paths when omitted."),
1858
1867
  out_path: z17.string().optional().describe("Override the generated test file path (repo-relative)."),
1868
+ red_ref: z17.string().optional().describe(
1869
+ "Pre-fix incident commit/ref. When set, the scaffold names the symbols the fix (<red_ref>..HEAD) touched within the lesson's anchor scope and pre-fills the example around them, so the assertion is a targeted edit rather than a blank page. A bad ref falls back to the generic template."
1870
+ ),
1859
1871
  write: z17.boolean().default(true).describe("Write the file to disk (default). false = return the content for preview without writing.")
1860
1872
  };
1861
1873
  async function scaffoldTest(input, ctx) {
@@ -1869,13 +1881,23 @@ async function scaffoldTest(input, ctx) {
1869
1881
  const groups = input.out_path ? allGroups.slice(0, 1) : allGroups;
1870
1882
  const frameworkFor = (detected) => input.framework ? normalizeFramework(input.framework) ?? detected : detected;
1871
1883
  const fields = parseLessonFields(found.memory.body);
1884
+ let incidentHints;
1885
+ if (input.red_ref) {
1886
+ try {
1887
+ const diff = await gitDiffText(ctx.paths.root, input.red_ref, anchorPaths);
1888
+ const hints = incidentHintsFromDiff(diff, { redRef: input.red_ref });
1889
+ if (hints.changedSymbols.length > 0 || hints.changedFiles.length > 0) incidentHints = hints;
1890
+ } catch {
1891
+ }
1892
+ }
1872
1893
  const lesson = {
1873
1894
  memoryId: input.memory_id,
1874
1895
  title: fields.title || input.memory_id,
1875
1896
  whyFailed: fields.whyFailed,
1876
1897
  instead: fields.instead,
1877
1898
  incident: found.memory.frontmatter.sensor?.incident,
1878
- paths: anchorPaths
1899
+ paths: anchorPaths,
1900
+ incidentHints
1879
1901
  };
1880
1902
  let scaffolds = groups.map(
1881
1903
  (g) => scaffoldPostIncidentTest(lesson, { framework: frameworkFor(g.framework), outPath: input.out_path, baseDir: g.baseDir })
@@ -3199,7 +3221,7 @@ function oneLine(value) {
3199
3221
  return value.replace(/\s+/g, " ").replace(/"/g, '\\"').trim().slice(0, 120);
3200
3222
  }
3201
3223
  function serverVersion() {
3202
- return true ? "0.44.0" : "dev";
3224
+ return true ? "0.46.0" : "dev";
3203
3225
  }
3204
3226
 
3205
3227
  // src/tools/code-map.ts
@@ -3514,6 +3536,7 @@ function isHaiveOwnedPath(p) {
3514
3536
  if (/^\.github\/workflows\/haive-.*\.ya?ml$/.test(p)) return true;
3515
3537
  return false;
3516
3538
  }
3539
+ var MAX_FUZZY_SCAN_LINES = 2e4;
3517
3540
  var TEST_PATH_RE = /(?:^|\/)(?:tests?|__tests__|__mocks__|e2e|fixtures)\/|\.(?:test|spec)\.[cm]?[jt]sx?$/i;
3518
3541
  function isTestPath(p) {
3519
3542
  return TEST_PATH_RE.test(p);
@@ -3524,7 +3547,7 @@ function stripTestHunks(diff) {
3524
3547
  let block = [];
3525
3548
  let keep = true;
3526
3549
  const flush = () => {
3527
- if (keep) out.push(...block);
3550
+ if (keep) for (const l of block) out.push(l);
3528
3551
  block = [];
3529
3552
  keep = true;
3530
3553
  };
@@ -3545,7 +3568,7 @@ function stripAiDirHunks(diff) {
3545
3568
  let block = [];
3546
3569
  let keep = true;
3547
3570
  const flush = () => {
3548
- if (keep) out.push(...block);
3571
+ if (keep) for (const l of block) out.push(l);
3549
3572
  block = [];
3550
3573
  keep = true;
3551
3574
  };
@@ -3616,7 +3639,10 @@ async function antiPatternsCheck(input, ctx) {
3616
3639
  }
3617
3640
  }
3618
3641
  const scanDiff = input.diff ? stripTestHunks(stripAiDirHunks(input.diff)) : input.diff;
3619
- if (scanDiff) {
3642
+ const scanAddedLineCount = scanDiff ? addedLinesFromDiff(scanDiff).split("\n").length : 0;
3643
+ const fuzzyScanTooLarge = scanAddedLineCount > MAX_FUZZY_SCAN_LINES;
3644
+ const notice = fuzzyScanTooLarge ? `Diff is very large (${scanAddedLineCount.toLocaleString()} added lines) \u2014 literal/semantic corroboration skipped for performance; anchored lessons and deterministic sensors were still evaluated in full. If this staged node_modules or a build artifact, unstage it.` : void 0;
3645
+ if (scanDiff && !fuzzyScanTooLarge) {
3620
3646
  const tokens = tokenizeDiffForLiteral(scanDiff);
3621
3647
  const added = addedLinesFromDiff(scanDiff);
3622
3648
  const addedText = added.trim().length > 0 ? added : scanDiff;
@@ -3651,7 +3677,7 @@ async function antiPatternsCheck(input, ctx) {
3651
3677
  }
3652
3678
  }
3653
3679
  }
3654
- if (input.semantic && scanDiff) {
3680
+ if (input.semantic && scanDiff && !fuzzyScanTooLarge) {
3655
3681
  try {
3656
3682
  const mod = await import("@hivelore/embeddings");
3657
3683
  const added = addedLinesFromDiff(scanDiff);
@@ -3684,7 +3710,8 @@ async function antiPatternsCheck(input, ctx) {
3684
3710
  }
3685
3711
  return {
3686
3712
  scanned: negative.length,
3687
- warnings
3713
+ warnings,
3714
+ ...notice ? { notice } : {}
3688
3715
  };
3689
3716
  }
3690
3717
 
@@ -3912,6 +3939,7 @@ async function preCommitCheck(input, ctx) {
3912
3939
  relevant_memories: relevant_memories.length,
3913
3940
  stale_anchors: staleHits.length
3914
3941
  },
3942
+ ...apResult.notice ? { notice: apResult.notice } : {},
3915
3943
  warnings: classifiedWarnings,
3916
3944
  relevant_memories,
3917
3945
  stale_anchors: staleHits.map((r) => {
@@ -4646,7 +4674,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
4646
4674
  // src/server.ts
4647
4675
  import { hasRecentBriefingMarker, loadConfigSync } from "@hivelore/core";
4648
4676
  var SERVER_NAME = "hivelore";
4649
- var SERVER_VERSION = "0.44.0";
4677
+ var SERVER_VERSION = "0.46.0";
4650
4678
  function jsonResult(data) {
4651
4679
  return {
4652
4680
  content: [