@edihasaj/recall 0.8.20 → 0.9.1

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 (74) hide show
  1. package/README.md +13 -0
  2. package/dist/{chunk-S7FJMV5O.js → chunk-3PPYB7BX.js} +8 -8
  3. package/dist/{chunk-ZBIJDXA7.js → chunk-4W4J7Z24.js} +17 -111
  4. package/dist/chunk-4W4J7Z24.js.map +1 -0
  5. package/dist/{chunk-O4KCMCJG.js → chunk-A27AP4NR.js} +21 -6
  6. package/dist/chunk-A27AP4NR.js.map +1 -0
  7. package/dist/{chunk-VT5VAEHY.js → chunk-CW3XJDH7.js} +2 -2
  8. package/dist/chunk-DWA2IO5N.js +105 -0
  9. package/dist/chunk-DWA2IO5N.js.map +1 -0
  10. package/dist/{chunk-M7OKBKKU.js → chunk-EAFRT7RX.js} +2 -2
  11. package/dist/{chunk-QKN6IWJ3.js → chunk-EZUMD27V.js} +68 -72
  12. package/dist/{chunk-QKN6IWJ3.js.map → chunk-EZUMD27V.js.map} +1 -1
  13. package/dist/{chunk-K6AFGQWR.js → chunk-FNQABJTM.js} +4 -4
  14. package/dist/{chunk-6I5U6KS3.js → chunk-G6YAXFT4.js} +70 -41
  15. package/dist/chunk-G6YAXFT4.js.map +1 -0
  16. package/dist/{chunk-LGTD5A4A.js → chunk-GE5BPNHC.js} +78 -16
  17. package/dist/chunk-GE5BPNHC.js.map +1 -0
  18. package/dist/{chunk-4CV4JOE5.js → chunk-JYWURG5T.js} +8 -3
  19. package/dist/{chunk-55KCGAOX.js → chunk-LUIYWYOT.js} +2 -2
  20. package/dist/{chunk-KG7YFARS.js → chunk-PQJRYAVG.js} +92 -14
  21. package/dist/chunk-PQJRYAVG.js.map +1 -0
  22. package/dist/{chunk-DNFKAHS6.js → chunk-VYZSP23L.js} +95 -12
  23. package/dist/chunk-VYZSP23L.js.map +1 -0
  24. package/dist/{chunk-NAYZL5XI.js → chunk-YDSCPOIJ.js} +4 -4
  25. package/dist/{cleanup-HWQCVPY4.js → cleanup-MBXKIGT6.js} +10 -9
  26. package/dist/cli.js +951 -161
  27. package/dist/cli.js.map +1 -1
  28. package/dist/daemon.js +113 -56
  29. package/dist/daemon.js.map +1 -1
  30. package/dist/dispatcher-YN6545TF.js +21 -0
  31. package/dist/{embeddings-LNMNKWB7.js → embeddings-E362AC3R.js} +5 -5
  32. package/dist/ingest-7FAOX7YV.js +18 -0
  33. package/dist/{keychain-5QG52ANO.js → keychain-PWFWKTZW.js} +3 -3
  34. package/dist/mcp.js +13 -12
  35. package/dist/mcp.js.map +1 -1
  36. package/dist/{memory-value-GH67CBQP.js → memory-value-ZLVZTE5M.js} +10 -9
  37. package/dist/quality-UUEBGSAQ.js +24 -0
  38. package/dist/retrieval-YU2PLBUS.js +13 -0
  39. package/dist/{store-OPRTGS73.js → store-5C7ZKKZF.js} +4 -4
  40. package/dist/sync-server.js +1 -1
  41. package/dist/{tasks-LOZ7XWON.js → tasks-AEKGKZZF.js} +10 -9
  42. package/dist/{usage-CAAACLUR.js → usage-VQ5LJCNH.js} +4 -4
  43. package/dist/webui/assets/{index-BODg2A9d.js → index-DAoAhOb4.js} +244 -244
  44. package/dist/webui/assets/{index-BODg2A9d.js.map → index-DAoAhOb4.js.map} +1 -1
  45. package/dist/webui/index.html +1 -1
  46. package/package.json +34 -2
  47. package/dist/chunk-6I5U6KS3.js.map +0 -1
  48. package/dist/chunk-DNFKAHS6.js.map +0 -1
  49. package/dist/chunk-KG7YFARS.js.map +0 -1
  50. package/dist/chunk-LGTD5A4A.js.map +0 -1
  51. package/dist/chunk-O4KCMCJG.js.map +0 -1
  52. package/dist/chunk-ZBIJDXA7.js.map +0 -1
  53. package/dist/dispatcher-RU25CZK3.js +0 -20
  54. package/dist/ingest-QSOE5XJZ.js +0 -18
  55. package/dist/quality-PZ36JND4.js +0 -23
  56. package/dist/retrieval-HIE5MASN.js +0 -13
  57. /package/dist/{chunk-S7FJMV5O.js.map → chunk-3PPYB7BX.js.map} +0 -0
  58. /package/dist/{chunk-VT5VAEHY.js.map → chunk-CW3XJDH7.js.map} +0 -0
  59. /package/dist/{chunk-M7OKBKKU.js.map → chunk-EAFRT7RX.js.map} +0 -0
  60. /package/dist/{chunk-K6AFGQWR.js.map → chunk-FNQABJTM.js.map} +0 -0
  61. /package/dist/{chunk-4CV4JOE5.js.map → chunk-JYWURG5T.js.map} +0 -0
  62. /package/dist/{chunk-55KCGAOX.js.map → chunk-LUIYWYOT.js.map} +0 -0
  63. /package/dist/{chunk-NAYZL5XI.js.map → chunk-YDSCPOIJ.js.map} +0 -0
  64. /package/dist/{cleanup-HWQCVPY4.js.map → cleanup-MBXKIGT6.js.map} +0 -0
  65. /package/dist/{dispatcher-RU25CZK3.js.map → dispatcher-YN6545TF.js.map} +0 -0
  66. /package/dist/{embeddings-LNMNKWB7.js.map → embeddings-E362AC3R.js.map} +0 -0
  67. /package/dist/{ingest-QSOE5XJZ.js.map → ingest-7FAOX7YV.js.map} +0 -0
  68. /package/dist/{keychain-5QG52ANO.js.map → keychain-PWFWKTZW.js.map} +0 -0
  69. /package/dist/{memory-value-GH67CBQP.js.map → memory-value-ZLVZTE5M.js.map} +0 -0
  70. /package/dist/{quality-PZ36JND4.js.map → quality-UUEBGSAQ.js.map} +0 -0
  71. /package/dist/{retrieval-HIE5MASN.js.map → retrieval-YU2PLBUS.js.map} +0 -0
  72. /package/dist/{store-OPRTGS73.js.map → store-5C7ZKKZF.js.map} +0 -0
  73. /package/dist/{tasks-LOZ7XWON.js.map → tasks-AEKGKZZF.js.map} +0 -0
  74. /package/dist/{usage-CAAACLUR.js.map → usage-VQ5LJCNH.js.map} +0 -0
@@ -0,0 +1,105 @@
1
+ // src/text/match.ts
2
+ var STOP_WORDS = /* @__PURE__ */ new Set([
3
+ "a",
4
+ "an",
5
+ "and",
6
+ "are",
7
+ "as",
8
+ "at",
9
+ "be",
10
+ "by",
11
+ "call",
12
+ "do",
13
+ "for",
14
+ "from",
15
+ "i",
16
+ "in",
17
+ "import",
18
+ "instead",
19
+ "is",
20
+ "it",
21
+ "its",
22
+ "just",
23
+ "of",
24
+ "on",
25
+ "only",
26
+ "or",
27
+ "our",
28
+ "please",
29
+ "run",
30
+ "that",
31
+ "the",
32
+ "this",
33
+ "to",
34
+ "use",
35
+ "we",
36
+ "with",
37
+ "you",
38
+ "your"
39
+ ]);
40
+ var NEGATION_WORDS = /* @__PURE__ */ new Set([
41
+ "avoid",
42
+ "dont",
43
+ "forbid",
44
+ "forbidden",
45
+ "never",
46
+ "no",
47
+ "not",
48
+ "stop"
49
+ ]);
50
+ function textMatches(left, right, threshold) {
51
+ return textMatchScore(left, right).score >= threshold;
52
+ }
53
+ function textMatchScore(left, right) {
54
+ const leftTokens = matchTokens(left);
55
+ const rightTokens = matchTokens(right);
56
+ if (leftTokens.length === 0 || rightTokens.length === 0) {
57
+ return {
58
+ score: 0,
59
+ jaccard: 0,
60
+ containment: 0,
61
+ intersection: 0,
62
+ left_tokens: leftTokens,
63
+ right_tokens: rightTokens
64
+ };
65
+ }
66
+ const leftSet = new Set(leftTokens);
67
+ const rightSet = new Set(rightTokens);
68
+ const intersection = [...leftSet].filter((token) => rightSet.has(token)).length;
69
+ const union = (/* @__PURE__ */ new Set([...leftSet, ...rightSet])).size;
70
+ const jaccard = union === 0 ? 0 : intersection / union;
71
+ const smaller = Math.min(leftSet.size, rightSet.size);
72
+ const containment = smaller === 0 ? 0 : intersection / smaller;
73
+ const containmentWeight = smaller < 2 ? 0 : smaller === 2 ? 0.75 : 0.9;
74
+ const exactSingleTokenScore = intersection === 1 && smaller === 1 ? 0.7 : 0;
75
+ const score = Math.max(jaccard, containment * containmentWeight, exactSingleTokenScore);
76
+ return {
77
+ score,
78
+ jaccard,
79
+ containment,
80
+ intersection,
81
+ left_tokens: [...leftSet],
82
+ right_tokens: [...rightSet]
83
+ };
84
+ }
85
+ function matchTokens(text) {
86
+ return text.toLowerCase().replace(/\bdo\s+not\b/g, " not ").replace(/\bdon['’]?t\b/g, " dont ").split(/[^a-z0-9]+/).map(normalizeToken).filter((token) => token.length > 1 && !STOP_WORDS.has(token));
87
+ }
88
+ function normalizeToken(token) {
89
+ if (NEGATION_WORDS.has(token)) return "not";
90
+ if (/^es\d+$/.test(token)) return "es";
91
+ if (token === "ran" || token === "running" || token === "runs") return "run";
92
+ if (token === "using" || token === "used" || token === "uses") return "use";
93
+ if (token.endsWith("ies") && token.length > 4) return `${token.slice(0, -3)}y`;
94
+ if (token.endsWith("ing") && token.length > 5) return token.slice(0, -3);
95
+ if (token.endsWith("ed") && token.length > 4) return token.slice(0, -2);
96
+ if (token.endsWith("s") && token.length > 3) return token.slice(0, -1);
97
+ return token;
98
+ }
99
+
100
+ export {
101
+ textMatches,
102
+ textMatchScore,
103
+ matchTokens
104
+ };
105
+ //# sourceMappingURL=chunk-DWA2IO5N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/text/match.ts"],"sourcesContent":["const STOP_WORDS = new Set([\n \"a\",\n \"an\",\n \"and\",\n \"are\",\n \"as\",\n \"at\",\n \"be\",\n \"by\",\n \"call\",\n \"do\",\n \"for\",\n \"from\",\n \"i\",\n \"in\",\n \"import\",\n \"instead\",\n \"is\",\n \"it\",\n \"its\",\n \"just\",\n \"of\",\n \"on\",\n \"only\",\n \"or\",\n \"our\",\n \"please\",\n \"run\",\n \"that\",\n \"the\",\n \"this\",\n \"to\",\n \"use\",\n \"we\",\n \"with\",\n \"you\",\n \"your\",\n]);\n\nconst NEGATION_WORDS = new Set([\n \"avoid\",\n \"dont\",\n \"forbid\",\n \"forbidden\",\n \"never\",\n \"no\",\n \"not\",\n \"stop\",\n]);\n\nexport interface TextMatchScore {\n score: number;\n jaccard: number;\n containment: number;\n intersection: number;\n left_tokens: string[];\n right_tokens: string[];\n}\n\nexport function textMatches(left: string, right: string, threshold: number): boolean {\n return textMatchScore(left, right).score >= threshold;\n}\n\nexport function textMatchScore(left: string, right: string): TextMatchScore {\n const leftTokens = matchTokens(left);\n const rightTokens = matchTokens(right);\n if (leftTokens.length === 0 || rightTokens.length === 0) {\n return {\n score: 0,\n jaccard: 0,\n containment: 0,\n intersection: 0,\n left_tokens: leftTokens,\n right_tokens: rightTokens,\n };\n }\n\n const leftSet = new Set(leftTokens);\n const rightSet = new Set(rightTokens);\n const intersection = [...leftSet].filter((token) => rightSet.has(token)).length;\n const union = new Set([...leftSet, ...rightSet]).size;\n const jaccard = union === 0 ? 0 : intersection / union;\n const smaller = Math.min(leftSet.size, rightSet.size);\n const containment = smaller === 0 ? 0 : intersection / smaller;\n const containmentWeight = smaller < 2 ? 0 : smaller === 2 ? 0.75 : 0.9;\n // Short tool/product queries are common (\"uv\", \"pnpm\", \"shotport\").\n // A one-token side is normally too weak for correction matching, but when\n // that whole distinctive token occurs on the other side it is exactly the\n // user's retrieval intent. Sentence-to-sentence one-token overlap remains\n // unboosted because neither side collapses to one content token.\n const exactSingleTokenScore =\n intersection === 1 && smaller === 1\n ? 0.7\n : 0;\n const score = Math.max(jaccard, containment * containmentWeight, exactSingleTokenScore);\n\n return {\n score,\n jaccard,\n containment,\n intersection,\n left_tokens: [...leftSet],\n right_tokens: [...rightSet],\n };\n}\n\nexport function matchTokens(text: string): string[] {\n return text\n .toLowerCase()\n .replace(/\\bdo\\s+not\\b/g, \" not \")\n .replace(/\\bdon['’]?t\\b/g, \" dont \")\n .split(/[^a-z0-9]+/)\n .map(normalizeToken)\n .filter((token) => token.length > 1 && !STOP_WORDS.has(token));\n}\n\nfunction normalizeToken(token: string): string {\n if (NEGATION_WORDS.has(token)) return \"not\";\n if (/^es\\d+$/.test(token)) return \"es\";\n if (token === \"ran\" || token === \"running\" || token === \"runs\") return \"run\";\n if (token === \"using\" || token === \"used\" || token === \"uses\") return \"use\";\n if (token.endsWith(\"ies\") && token.length > 4) return `${token.slice(0, -3)}y`;\n if (token.endsWith(\"ing\") && token.length > 5) return token.slice(0, -3);\n if (token.endsWith(\"ed\") && token.length > 4) return token.slice(0, -2);\n if (token.endsWith(\"s\") && token.length > 3) return token.slice(0, -1);\n return token;\n}\n"],"mappings":"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","names":[]}
@@ -8,7 +8,7 @@ import {
8
8
  memoryEntities,
9
9
  or,
10
10
  sql
11
- } from "./chunk-55KCGAOX.js";
11
+ } from "./chunk-LUIYWYOT.js";
12
12
 
13
13
  // src/graph/store.ts
14
14
  import { randomUUID } from "crypto";
@@ -285,4 +285,4 @@ export {
285
285
  countRelations,
286
286
  clearGraph
287
287
  };
288
- //# sourceMappingURL=chunk-M7OKBKKU.js.map
288
+ //# sourceMappingURL=chunk-EAFRT7RX.js.map
@@ -6,18 +6,20 @@ import {
6
6
  recordAudit,
7
7
  redactSensitiveValue,
8
8
  seedScannedConfidence
9
- } from "./chunk-6I5U6KS3.js";
9
+ } from "./chunk-G6YAXFT4.js";
10
10
  import {
11
11
  recordInjectionValueEvents,
12
12
  recordMemoryInjections,
13
13
  recordOutcomeValueEvent,
14
- resolveMemoryInjectionOutcome,
14
+ resolveMemoryInjectionOutcome
15
+ } from "./chunk-4W4J7Z24.js";
16
+ import {
15
17
  textMatchScore
16
- } from "./chunk-ZBIJDXA7.js";
18
+ } from "./chunk-DWA2IO5N.js";
17
19
  import {
18
20
  asc,
19
21
  desc
20
- } from "./chunk-VT5VAEHY.js";
22
+ } from "./chunk-CW3XJDH7.js";
21
23
  import {
22
24
  activityEventDedupeKey,
23
25
  confirmMemory,
@@ -32,11 +34,12 @@ import {
32
34
  recordFeedback,
33
35
  rejectMemory,
34
36
  statusFromConfidence
35
- } from "./chunk-O4KCMCJG.js";
37
+ } from "./chunk-A27AP4NR.js";
36
38
  import {
37
39
  CONFIDENCE,
38
40
  RetrievalEvalCase,
39
41
  RetrievalEvalFile,
42
+ atomicWriteUtf8File,
40
43
  bootstrapEmbeddings,
41
44
  generateEmbedding,
42
45
  generateEmbeddings,
@@ -46,9 +49,10 @@ import {
46
49
  loadEmbeddingConfigFromEnv,
47
50
  projectEmbeddingToIndex,
48
51
  queueMemoryEmbeddingSync,
52
+ readUtf8FileIfExists,
49
53
  resolveProvider,
50
54
  tagActivitySource
51
- } from "./chunk-KG7YFARS.js";
55
+ } from "./chunk-PQJRYAVG.js";
52
56
  import {
53
57
  Column,
54
58
  Columns,
@@ -110,7 +114,7 @@ import {
110
114
  policyRules,
111
115
  schema_exports,
112
116
  sql
113
- } from "./chunk-55KCGAOX.js";
117
+ } from "./chunk-LUIYWYOT.js";
114
118
 
115
119
  // src/db/client.ts
116
120
  import Database from "better-sqlite3";
@@ -3785,9 +3789,9 @@ function rowToActivityEvent(row) {
3785
3789
  }
3786
3790
 
3787
3791
  // src/scanner/repo.ts
3788
- import { readFileSync, existsSync as existsSync2 } from "fs";
3792
+ import { existsSync as existsSync2 } from "fs";
3789
3793
  import { join as join2, basename } from "path";
3790
- import { execSync } from "child_process";
3794
+ import { execFileSync } from "child_process";
3791
3795
  function scanRepo(repoPath) {
3792
3796
  const repoName = inferRepoName(repoPath);
3793
3797
  const candidates = [];
@@ -3852,10 +3856,11 @@ function scanAndStore(db, repoPath) {
3852
3856
  }
3853
3857
  function scanPackageJson(repoPath, repo) {
3854
3858
  const pkgPath = join2(repoPath, "package.json");
3855
- if (!existsSync2(pkgPath)) return [];
3856
3859
  const results = [];
3857
3860
  try {
3858
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
3861
+ const raw = readUtf8FileIfExists(pkgPath);
3862
+ if (raw === null) return [];
3863
+ const pkg = JSON.parse(raw);
3859
3864
  if (pkg.packageManager) {
3860
3865
  const pm = pkg.packageManager.split("@")[0];
3861
3866
  results.push(makeCommand(
@@ -3903,10 +3908,10 @@ function scanPackageJson(repoPath, repo) {
3903
3908
  }
3904
3909
  function scanMakefile(repoPath, repo) {
3905
3910
  const mkPath = join2(repoPath, "Makefile");
3906
- if (!existsSync2(mkPath)) return [];
3907
3911
  const results = [];
3908
3912
  try {
3909
- const content = readFileSync(mkPath, "utf-8");
3913
+ const content = readUtf8FileIfExists(mkPath);
3914
+ if (content === null) return [];
3910
3915
  const targets = content.match(/^([a-zA-Z_-]+):/gm);
3911
3916
  if (targets) {
3912
3917
  const key = targets.map((t) => t.replace(":", "")).filter(
@@ -3957,9 +3962,9 @@ function scanInstructionFiles(repoPath, repo) {
3957
3962
  ];
3958
3963
  for (const file of instructionFiles) {
3959
3964
  const fPath = join2(repoPath, file);
3960
- if (!existsSync2(fPath)) continue;
3961
3965
  try {
3962
- const content = readFileSync(fPath, "utf-8");
3966
+ const content = readUtf8FileIfExists(fPath);
3967
+ if (content === null) continue;
3963
3968
  const rules = content.split("\n").filter(
3964
3969
  (line) => /\b(always|never|must|don't|do not|required|forbidden)\b/i.test(line)
3965
3970
  ).map((l) => l.replace(/^[-*#>\s]+/, "").trim()).filter((l) => l.length > 10 && l.length < 200);
@@ -4018,9 +4023,9 @@ function scanLinterConfigs(repoPath, repo) {
4018
4023
  function scanReadme(repoPath, repo) {
4019
4024
  const results = [];
4020
4025
  const readmePath = join2(repoPath, "README.md");
4021
- if (!existsSync2(readmePath)) return [];
4022
4026
  try {
4023
- const content = readFileSync(readmePath, "utf-8");
4027
+ const content = readUtf8FileIfExists(readmePath);
4028
+ if (content === null) return [];
4024
4029
  const setupMatch = content.match(
4025
4030
  /^##\s*(setup|install|getting.started|quick.start|development)\s*\n([\s\S]*?)(?=^##\s|\z)/im
4026
4031
  );
@@ -4065,7 +4070,7 @@ function now() {
4065
4070
  }
4066
4071
  function inferRepoName(repoPath) {
4067
4072
  try {
4068
- const remote = execSync("git remote get-url origin", {
4073
+ const remote = execFileSync("git", ["remote", "get-url", "origin"], {
4069
4074
  cwd: repoPath,
4070
4075
  encoding: "utf-8",
4071
4076
  stdio: ["pipe", "pipe", "pipe"]
@@ -4107,7 +4112,7 @@ function makeGotcha(text, repo, file) {
4107
4112
 
4108
4113
  // src/repo/discovery.ts
4109
4114
  import { existsSync as existsSync3, readdirSync } from "fs";
4110
- import { execFileSync } from "child_process";
4115
+ import { execFileSync as execFileSync2 } from "child_process";
4111
4116
  import { join as join3, resolve } from "path";
4112
4117
  var repoPathCache = /* @__PURE__ */ new Map();
4113
4118
  var SKIP_DIRS = /* @__PURE__ */ new Set([
@@ -4200,7 +4205,7 @@ function inferRepoSlugFromPath(repoPath) {
4200
4205
  const root = normalizeRepoPathHint(repoPath);
4201
4206
  if (!root) return null;
4202
4207
  try {
4203
- const remote = execFileSync(
4208
+ const remote = execFileSync2(
4204
4209
  "git",
4205
4210
  ["-C", root, "remote", "get-url", "origin"],
4206
4211
  { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
@@ -4232,7 +4237,7 @@ function normalizeRepoPathHint(repoPath) {
4232
4237
  if (!repoPath) return null;
4233
4238
  const expanded = repoPath.trim().replace(/^~(?=\/)/, process.env.HOME ?? "~");
4234
4239
  try {
4235
- const root = execFileSync(
4240
+ const root = execFileSync2(
4236
4241
  "git",
4237
4242
  ["-C", expanded, "rev-parse", "--show-toplevel"],
4238
4243
  { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
@@ -4853,7 +4858,8 @@ var DEFAULT_CONFIG = {
4853
4858
  token_budget: 2e3,
4854
4859
  include_candidates: false
4855
4860
  };
4856
- var QUERY_RESULT_LIMIT = 2;
4861
+ var QUERY_RESULT_LIMIT = 8;
4862
+ var QUERY_SELECTION_LIMIT = 2;
4857
4863
  var QUERY_VECTOR_RELEVANCE_FLOOR = 0.7;
4858
4864
  var QUERY_TEXT_MATCH_FLOOR = 0.45;
4859
4865
  var HISTORY_VECTOR_RELEVANCE_FLOOR = 0.7;
@@ -5054,6 +5060,7 @@ async function compileContextHybrid(db, req) {
5054
5060
  let gotchaCount = 0;
5055
5061
  let lineCount = 0;
5056
5062
  for (const item of dedupedRanked) {
5063
+ if (effectiveQuery && selected.length >= QUERY_SELECTION_LIMIT) break;
5057
5064
  const memory = item.memory;
5058
5065
  const memLines = renderMemoryText(memory).split("\n").length;
5059
5066
  if (lineCount + memLines > config.max_lines) continue;
@@ -5321,9 +5328,9 @@ ${result.text}`;
5321
5328
  }
5322
5329
 
5323
5330
  // src/artifacts/context.ts
5324
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
5325
- import { join as join4 } from "path";
5326
- import { execFileSync as execFileSync2 } from "child_process";
5331
+ import { mkdirSync as mkdirSync2 } from "fs";
5332
+ import { isAbsolute, join as join4, resolve as resolve2 } from "path";
5333
+ import { execFileSync as execFileSync3 } from "child_process";
5327
5334
  function getRepoContextArtifactPath(repoPath) {
5328
5335
  return join4(repoPath, ".recall", "context.md");
5329
5336
  }
@@ -5359,9 +5366,9 @@ function writeRepoContextArtifact(db, input) {
5359
5366
  mkdirSync2(join4(repoPath, ".recall"), { recursive: true });
5360
5367
  ensureRepoContextExcluded(repoPath);
5361
5368
  const content = renderRepoContextArtifact(db, repo);
5362
- const existing = existsSync4(outputPath) ? readFileSync2(outputPath, "utf-8") : null;
5369
+ const existing = readUtf8FileIfExists(outputPath);
5363
5370
  if (existing !== content) {
5364
- writeFileSync(outputPath, content);
5371
+ atomicWriteUtf8File(outputPath, content);
5365
5372
  }
5366
5373
  return {
5367
5374
  repo,
@@ -5372,17 +5379,18 @@ function writeRepoContextArtifact(db, input) {
5372
5379
  }
5373
5380
  function ensureRepoContextExcluded(repoPath) {
5374
5381
  try {
5375
- const excludePath = execFileSync2(
5382
+ const excludePath = execFileSync3(
5376
5383
  "git",
5377
5384
  ["-C", repoPath, "rev-parse", "--git-path", "info/exclude"],
5378
5385
  { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
5379
5386
  ).trim();
5380
5387
  if (!excludePath) return;
5381
- const existing = existsSync4(excludePath) ? readFileSync2(excludePath, "utf-8") : "";
5388
+ const absoluteExcludePath = isAbsolute(excludePath) ? excludePath : resolve2(repoPath, excludePath);
5389
+ const existing = readUtf8FileIfExists(absoluteExcludePath) ?? "";
5382
5390
  if (existing.split("\n").some((line) => line.trim() === ".recall/")) return;
5383
5391
  const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
5384
- writeFileSync(
5385
- excludePath,
5392
+ atomicWriteUtf8File(
5393
+ absoluteExcludePath,
5386
5394
  `${existing}${prefix}# Recall generated context
5387
5395
  .recall/
5388
5396
  `
@@ -5514,8 +5522,23 @@ function endEvalSession(db, sessionId) {
5514
5522
  db.update(evalSessions).set({ ended_at: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(evalSessions.id, sessionId)).run();
5515
5523
  }
5516
5524
  function incrementEvalCounter(db, sessionId, field, amount = 1) {
5517
- const col = evalSessions[field];
5518
- db.update(evalSessions).set({ [field]: sql`${col} + ${amount}` }).where(eq(evalSessions.id, sessionId)).run();
5525
+ const update = (() => {
5526
+ switch (field) {
5527
+ case "memories_injected":
5528
+ return { memories_injected: sql`${evalSessions.memories_injected} + ${amount}` };
5529
+ case "memories_followed":
5530
+ return { memories_followed: sql`${evalSessions.memories_followed} + ${amount}` };
5531
+ case "memories_overridden":
5532
+ return { memories_overridden: sql`${evalSessions.memories_overridden} + ${amount}` };
5533
+ case "user_corrections":
5534
+ return { user_corrections: sql`${evalSessions.user_corrections} + ${amount}` };
5535
+ case "test_passes":
5536
+ return { test_passes: sql`${evalSessions.test_passes} + ${amount}` };
5537
+ case "test_failures":
5538
+ return { test_failures: sql`${evalSessions.test_failures} + ${amount}` };
5539
+ }
5540
+ })();
5541
+ db.update(evalSessions).set(update).where(eq(evalSessions.id, sessionId)).run();
5519
5542
  }
5520
5543
  function computeMetrics(db, options = {}) {
5521
5544
  const conditions = [];
@@ -5664,9 +5687,9 @@ function formatMetricsReport(metrics) {
5664
5687
  }
5665
5688
 
5666
5689
  // src/eval/retrieval.ts
5667
- import { readFileSync as readFileSync3 } from "fs";
5690
+ import { readFileSync } from "fs";
5668
5691
  function loadRetrievalEvalFile(path) {
5669
- return RetrievalEvalFile.parse(JSON.parse(readFileSync3(path, "utf8")));
5692
+ return RetrievalEvalFile.parse(JSON.parse(readFileSync(path, "utf8")));
5670
5693
  }
5671
5694
  async function runRetrievalEval(db, input, options = {}) {
5672
5695
  const providers = options.providers?.length ? options.providers : ["current"];
@@ -5761,8 +5784,14 @@ async function runValueRetrievalEval(db, options = {}) {
5761
5784
  skippedEvents += 1;
5762
5785
  continue;
5763
5786
  }
5787
+ const includeCandidates = row.event_type === "retrieval_miss";
5788
+ const currentlyRetrievable = memory.auto_inject && (memory.status === "active" || includeCandidates && memory.status === "candidate");
5789
+ if (!currentlyRetrievable) {
5790
+ skippedEvents += 1;
5791
+ continue;
5792
+ }
5764
5793
  const evidence = normalizeEvidence(row.evidence);
5765
- const queryText = row.event_type === "retrieval_miss" ? firstNonEmpty(evidence.query_text, evidence.correction_text) : firstNonEmpty(evidence.completion_excerpt, evidence.context);
5794
+ const queryText = row.event_type === "retrieval_miss" ? firstNonEmpty(evidence.correction_text, evidence.query_text) : firstNonEmpty(evidence.completion_excerpt, evidence.context);
5766
5795
  if (!queryText) {
5767
5796
  skippedEvents += 1;
5768
5797
  continue;
@@ -5777,7 +5806,7 @@ async function runValueRetrievalEval(db, options = {}) {
5777
5806
  repo,
5778
5807
  path: typeof evidence.prompt_path === "string" ? evidence.prompt_path : void 0,
5779
5808
  query_text: queryText,
5780
- include_candidates: row.event_type === "retrieval_miss",
5809
+ include_candidates: includeCandidates,
5781
5810
  max_lines: 3,
5782
5811
  max_commands: 2,
5783
5812
  max_gotchas: 2,
@@ -5979,7 +6008,7 @@ function embeddingConfigForProvider(provider) {
5979
6008
 
5980
6009
  // src/feedback/implicit.ts
5981
6010
  import { randomUUID as randomUUID5 } from "crypto";
5982
- import { execSync as execSync2 } from "child_process";
6011
+ import { execFileSync as execFileSync4 } from "child_process";
5983
6012
  var SIGNAL_WEIGHTS = {
5984
6013
  test_pass: 0.03,
5985
6014
  test_fail: -0.15,
@@ -6009,37 +6038,6 @@ function recordSignal(db, memoryId, sessionId, signalType, context) {
6009
6038
  function getSignals(db, memoryId) {
6010
6039
  return db.select().from(implicitSignals).where(eq(implicitSignals.memory_id, memoryId)).all();
6011
6040
  }
6012
- function runTests(repoPath, command) {
6013
- try {
6014
- const output = execSync2(command, {
6015
- cwd: repoPath,
6016
- encoding: "utf-8",
6017
- timeout: 12e4,
6018
- stdio: ["pipe", "pipe", "pipe"]
6019
- });
6020
- return { passed: true, output };
6021
- } catch (err) {
6022
- return {
6023
- passed: false,
6024
- output: err.stdout ?? err.stderr ?? err.message
6025
- };
6026
- }
6027
- }
6028
- function recordTestSignals(db, sessionId, injectedMemoryIds, testResult) {
6029
- const signalType = testResult.passed ? "test_pass" : "test_fail";
6030
- const ids = [];
6031
- for (const memId of injectedMemoryIds) {
6032
- const id = recordSignal(
6033
- db,
6034
- memId,
6035
- sessionId,
6036
- signalType,
6037
- testResult.output?.slice(0, 500)
6038
- );
6039
- ids.push(id);
6040
- }
6041
- return ids;
6042
- }
6043
6041
  function getSignalStats(db, memoryId) {
6044
6042
  const signals = getSignals(db, memoryId);
6045
6043
  const stats = {
@@ -6487,8 +6485,6 @@ export {
6487
6485
  formatRetrievalEvalReport,
6488
6486
  formatValueRetrievalEvalReport,
6489
6487
  recordSignal,
6490
- runTests,
6491
- recordTestSignals,
6492
6488
  getSignalStats,
6493
6489
  createPolicy,
6494
6490
  listPolicies,
@@ -6501,4 +6497,4 @@ export {
6501
6497
  pruneMemories,
6502
6498
  formatPruneReport
6503
6499
  };
6504
- //# sourceMappingURL=chunk-QKN6IWJ3.js.map
6500
+ //# sourceMappingURL=chunk-EZUMD27V.js.map