@hivelore/cli 0.44.0 → 0.47.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.
@@ -155,9 +155,12 @@ import path5 from "path";
155
155
  import { existsSync as existsSync17, statSync } from "fs";
156
156
  import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile10 } from "fs/promises";
157
157
  import path8 from "path";
158
+ import { execFile } from "child_process";
159
+ import { promisify } from "util";
158
160
  import { z as z17 } from "zod";
159
161
  import {
160
162
  buildProposeCommand,
163
+ incidentHintsFromDiff,
161
164
  loadMemoriesFromDir as loadMemoriesFromDir14,
162
165
  normalizeFramework,
163
166
  parseLessonFields,
@@ -1916,6 +1919,12 @@ async function memTried(input, ctx) {
1916
1919
  hint
1917
1920
  };
1918
1921
  }
1922
+ var execFileAsync = promisify(execFile);
1923
+ async function gitDiffText(root, redRef, paths) {
1924
+ const args = ["diff", redRef, "HEAD", "--", ...paths];
1925
+ const { stdout } = await execFileAsync("git", args, { cwd: root, maxBuffer: 64 * 1024 * 1024 });
1926
+ return stdout;
1927
+ }
1919
1928
  var PY_SIGNALS = ["pyproject.toml", "setup.py", "pytest.ini", "requirements.txt", "tox.ini"];
1920
1929
  async function detectForAnchor(root, rel) {
1921
1930
  let dir = path8.resolve(root, rel);
@@ -1970,6 +1979,9 @@ var ScaffoldTestInputSchema = {
1970
1979
  memory_id: z17.string().min(1).describe("Id of the attempt/gotcha lesson to scaffold a post-incident test from."),
1971
1980
  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."),
1972
1981
  out_path: z17.string().optional().describe("Override the generated test file path (repo-relative)."),
1982
+ red_ref: z17.string().optional().describe(
1983
+ "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."
1984
+ ),
1973
1985
  write: z17.boolean().default(true).describe("Write the file to disk (default). false = return the content for preview without writing.")
1974
1986
  };
1975
1987
  async function scaffoldTest(input, ctx) {
@@ -1983,13 +1995,23 @@ async function scaffoldTest(input, ctx) {
1983
1995
  const groups = input.out_path ? allGroups.slice(0, 1) : allGroups;
1984
1996
  const frameworkFor = (detected) => input.framework ? normalizeFramework(input.framework) ?? detected : detected;
1985
1997
  const fields = parseLessonFields(found.memory.body);
1998
+ let incidentHints;
1999
+ if (input.red_ref) {
2000
+ try {
2001
+ const diff = await gitDiffText(ctx.paths.root, input.red_ref, anchorPaths);
2002
+ const hints = incidentHintsFromDiff(diff, { redRef: input.red_ref });
2003
+ if (hints.changedSymbols.length > 0 || hints.changedFiles.length > 0) incidentHints = hints;
2004
+ } catch {
2005
+ }
2006
+ }
1986
2007
  const lesson = {
1987
2008
  memoryId: input.memory_id,
1988
2009
  title: fields.title || input.memory_id,
1989
2010
  whyFailed: fields.whyFailed,
1990
2011
  instead: fields.instead,
1991
2012
  incident: found.memory.frontmatter.sensor?.incident,
1992
- paths: anchorPaths
2013
+ paths: anchorPaths,
2014
+ incidentHints
1993
2015
  };
1994
2016
  let scaffolds = groups.map(
1995
2017
  (g) => scaffoldPostIncidentTest(lesson, { framework: frameworkFor(g.framework), outPath: input.out_path, baseDir: g.baseDir })
@@ -3213,7 +3235,7 @@ function oneLine(value) {
3213
3235
  return value.replace(/\s+/g, " ").replace(/"/g, '\\"').trim().slice(0, 120);
3214
3236
  }
3215
3237
  function serverVersion() {
3216
- return true ? "0.44.0" : "dev";
3238
+ return true ? "0.47.0" : "dev";
3217
3239
  }
3218
3240
  var CodeMapInputSchema = {
3219
3241
  file: z21.string().optional().describe("Filter to files whose path contains this substring"),
@@ -3485,6 +3507,7 @@ function isHaiveOwnedPath(p) {
3485
3507
  if (/^\.github\/workflows\/haive-.*\.ya?ml$/.test(p)) return true;
3486
3508
  return false;
3487
3509
  }
3510
+ var MAX_FUZZY_SCAN_LINES = 2e4;
3488
3511
  var TEST_PATH_RE = /(?:^|\/)(?:tests?|__tests__|__mocks__|e2e|fixtures)\/|\.(?:test|spec)\.[cm]?[jt]sx?$/i;
3489
3512
  function isTestPath(p) {
3490
3513
  return TEST_PATH_RE.test(p);
@@ -3495,7 +3518,7 @@ function stripTestHunks(diff) {
3495
3518
  let block = [];
3496
3519
  let keep = true;
3497
3520
  const flush = () => {
3498
- if (keep) out.push(...block);
3521
+ if (keep) for (const l of block) out.push(l);
3499
3522
  block = [];
3500
3523
  keep = true;
3501
3524
  };
@@ -3516,7 +3539,7 @@ function stripAiDirHunks(diff) {
3516
3539
  let block = [];
3517
3540
  let keep = true;
3518
3541
  const flush = () => {
3519
- if (keep) out.push(...block);
3542
+ if (keep) for (const l of block) out.push(l);
3520
3543
  block = [];
3521
3544
  keep = true;
3522
3545
  };
@@ -3587,7 +3610,10 @@ async function antiPatternsCheck(input, ctx) {
3587
3610
  }
3588
3611
  }
3589
3612
  const scanDiff = input.diff ? stripTestHunks(stripAiDirHunks(input.diff)) : input.diff;
3590
- if (scanDiff) {
3613
+ const scanAddedLineCount = scanDiff ? addedLinesFromDiff(scanDiff).split("\n").length : 0;
3614
+ const fuzzyScanTooLarge = scanAddedLineCount > MAX_FUZZY_SCAN_LINES;
3615
+ 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;
3616
+ if (scanDiff && !fuzzyScanTooLarge) {
3591
3617
  const tokens = tokenizeDiffForLiteral(scanDiff);
3592
3618
  const added = addedLinesFromDiff(scanDiff);
3593
3619
  const addedText = added.trim().length > 0 ? added : scanDiff;
@@ -3622,7 +3648,7 @@ async function antiPatternsCheck(input, ctx) {
3622
3648
  }
3623
3649
  }
3624
3650
  }
3625
- if (input.semantic && scanDiff) {
3651
+ if (input.semantic && scanDiff && !fuzzyScanTooLarge) {
3626
3652
  try {
3627
3653
  const mod = await import("@hivelore/embeddings");
3628
3654
  const added = addedLinesFromDiff(scanDiff);
@@ -3655,7 +3681,8 @@ async function antiPatternsCheck(input, ctx) {
3655
3681
  }
3656
3682
  return {
3657
3683
  scanned: negative.length,
3658
- warnings
3684
+ warnings,
3685
+ ...notice ? { notice } : {}
3659
3686
  };
3660
3687
  }
3661
3688
  var MemDistillInputSchema = {
@@ -3871,6 +3898,7 @@ async function preCommitCheck(input, ctx) {
3871
3898
  relevant_memories: relevant_memories.length,
3872
3899
  stale_anchors: staleHits.length
3873
3900
  },
3901
+ ...apResult.notice ? { notice: apResult.notice } : {},
3874
3902
  warnings: classifiedWarnings,
3875
3903
  relevant_memories,
3876
3904
  stale_anchors: staleHits.map((r) => {
@@ -4558,7 +4586,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
4558
4586
  };
4559
4587
  }
4560
4588
  var SERVER_NAME = "hivelore";
4561
- var SERVER_VERSION = "0.44.0";
4589
+ var SERVER_VERSION = "0.47.0";
4562
4590
  function jsonResult(data) {
4563
4591
  return {
4564
4592
  content: [
@@ -5550,4 +5578,4 @@ export {
5550
5578
  runHaiveMcpStdio,
5551
5579
  writeMcpRuntimeMarker
5552
5580
  };
5553
- //# sourceMappingURL=chunk-6KRXMDLC.js.map
5581
+ //# sourceMappingURL=chunk-HBS7PNNY.js.map