@inerrata-corporation/errata 2.0.2-dev.503 → 2.0.2-dev.506

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.
Files changed (2) hide show
  1. package/errata.mjs +23 -8
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -19462,10 +19462,12 @@ function parseIntentFences(text) {
19462
19462
  }
19463
19463
  function searchByIntent(store, intent, opts) {
19464
19464
  const limit = opts?.limit ?? 5;
19465
- const minCoverage = opts?.minCoverage ?? 0.25;
19465
+ const minCoverage = opts?.minCoverage ?? DEFAULT_MIN_COVERAGE;
19466
19466
  const want = new Set(retrievalTokens(intent));
19467
19467
  if (want.size < MIN_INTENT_TOKENS) return [];
19468
- const hits = [];
19468
+ const candidates = [];
19469
+ const df = /* @__PURE__ */ new Map();
19470
+ let corpus = 0;
19469
19471
  for (const label of RECALLABLE) {
19470
19472
  for (const node2 of store.findNodesByLabel(label)) {
19471
19473
  if (node2.attrs["mergedInto"] !== void 0) continue;
@@ -19474,19 +19476,30 @@ function searchByIntent(store, intent, opts) {
19474
19476
  }
19475
19477
  const bag = retrievalTokens(node2.description ?? "");
19476
19478
  if (bag.length === 0) continue;
19479
+ corpus++;
19477
19480
  const matched = bag.filter((t) => want.has(t));
19478
- if (matched.length === 0) continue;
19479
- const coverage = matched.length / want.size;
19480
- if (coverage < minCoverage) continue;
19481
- hits.push({ node: node2, coverage, matched });
19481
+ for (const t of matched) df.set(t, (df.get(t) ?? 0) + 1);
19482
+ if (matched.length > 0) candidates.push({ node: node2, matched });
19482
19483
  }
19483
19484
  }
19485
+ const idf = (t) => Math.log(1 + corpus / (1 + (df.get(t) ?? 0)));
19486
+ let denom = 0;
19487
+ for (const t of want) if ((df.get(t) ?? 0) > 0) denom += idf(t);
19488
+ if (denom === 0) return [];
19489
+ const hits = [];
19490
+ for (const { node: node2, matched } of candidates) {
19491
+ let num2 = 0;
19492
+ for (const t of matched) num2 += idf(t);
19493
+ const coverage = num2 / denom;
19494
+ if (coverage < minCoverage) continue;
19495
+ hits.push({ node: node2, coverage, matched });
19496
+ }
19484
19497
  hits.sort(
19485
19498
  (a, b) => b.coverage - a.coverage || (a.node.description?.length ?? 0) - (b.node.description?.length ?? 0)
19486
19499
  );
19487
19500
  return hits.slice(0, limit);
19488
19501
  }
19489
- var RECALLABLE, MIN_INTENT_TOKENS;
19502
+ var RECALLABLE, MIN_INTENT_TOKENS, DEFAULT_MIN_COVERAGE;
19490
19503
  var init_intent = __esm({
19491
19504
  "../../packages/local-graph/src/intent.ts"() {
19492
19505
  "use strict";
@@ -19494,6 +19507,7 @@ var init_intent = __esm({
19494
19507
  init_design_problem();
19495
19508
  RECALLABLE = ["Problem", "Solution", "RootCause", "Pattern"];
19496
19509
  MIN_INTENT_TOKENS = 2;
19510
+ DEFAULT_MIN_COVERAGE = 0.2;
19497
19511
  }
19498
19512
  });
19499
19513
 
@@ -21762,6 +21776,7 @@ __export(src_exports2, {
21762
21776
  CITABLE_PRIOR_LABELS: () => CITABLE_PRIOR_LABELS,
21763
21777
  CODE_REACH_EDGES: () => CODE_REACH_EDGES,
21764
21778
  CREDIT_FAMILY: () => CREDIT_FAMILY,
21779
+ DEFAULT_MIN_COVERAGE: () => DEFAULT_MIN_COVERAGE,
21765
21780
  FIX_CANDIDATE_ASK_LIMIT: () => FIX_CANDIDATE_ASK_LIMIT,
21766
21781
  JOINT_COMMUNITY_EDGES: () => JOINT_COMMUNITY_EDGES,
21767
21782
  JOINT_COMMUNITY_LABELS: () => JOINT_COMMUNITY_LABELS,
@@ -53797,7 +53812,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
53797
53812
  }
53798
53813
 
53799
53814
  // src/engine.ts
53800
- var DAEMON_VERSION = true ? "2.0.2-dev.503" : "2.0.0-alpha.0";
53815
+ var DAEMON_VERSION = true ? "2.0.2-dev.506" : "2.0.0-alpha.0";
53801
53816
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
53802
53817
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
53803
53818
  var GIT_OP_MUTE_MS = 4e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.503",
3
+ "version": "2.0.2-dev.506",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {