@loreai/core 0.17.1 → 0.19.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.
Files changed (248) hide show
  1. package/dist/bun/agents-file.d.ts +4 -0
  2. package/dist/bun/agents-file.d.ts.map +1 -1
  3. package/dist/bun/config.d.ts +2 -0
  4. package/dist/bun/config.d.ts.map +1 -1
  5. package/dist/bun/curator.d.ts +45 -0
  6. package/dist/bun/curator.d.ts.map +1 -1
  7. package/dist/bun/data-dir.d.ts +18 -0
  8. package/dist/bun/data-dir.d.ts.map +1 -0
  9. package/dist/bun/db.d.ts +85 -0
  10. package/dist/bun/db.d.ts.map +1 -1
  11. package/dist/bun/distillation.d.ts +2 -13
  12. package/dist/bun/distillation.d.ts.map +1 -1
  13. package/dist/bun/embedding-vendor.d.ts +22 -38
  14. package/dist/bun/embedding-vendor.d.ts.map +1 -1
  15. package/dist/bun/embedding-worker-types.d.ts +17 -12
  16. package/dist/bun/embedding-worker-types.d.ts.map +1 -1
  17. package/dist/bun/embedding-worker.d.ts +9 -2
  18. package/dist/bun/embedding-worker.d.ts.map +1 -1
  19. package/dist/bun/embedding-worker.js +38864 -33
  20. package/dist/bun/embedding-worker.js.map +4 -4
  21. package/dist/bun/embedding.d.ts +35 -23
  22. package/dist/bun/embedding.d.ts.map +1 -1
  23. package/dist/bun/gradient.d.ts +17 -1
  24. package/dist/bun/gradient.d.ts.map +1 -1
  25. package/dist/bun/import/detect.d.ts +14 -0
  26. package/dist/bun/import/detect.d.ts.map +1 -0
  27. package/dist/bun/import/extract.d.ts +43 -0
  28. package/dist/bun/import/extract.d.ts.map +1 -0
  29. package/dist/bun/import/history.d.ts +40 -0
  30. package/dist/bun/import/history.d.ts.map +1 -0
  31. package/dist/bun/import/index.d.ts +17 -0
  32. package/dist/bun/import/index.d.ts.map +1 -0
  33. package/dist/bun/import/providers/aider.d.ts +2 -0
  34. package/dist/bun/import/providers/aider.d.ts.map +1 -0
  35. package/dist/bun/import/providers/claude-code.d.ts +2 -0
  36. package/dist/bun/import/providers/claude-code.d.ts.map +1 -0
  37. package/dist/bun/import/providers/cline.d.ts +2 -0
  38. package/dist/bun/import/providers/cline.d.ts.map +1 -0
  39. package/dist/bun/import/providers/codex.d.ts +2 -0
  40. package/dist/bun/import/providers/codex.d.ts.map +1 -0
  41. package/dist/bun/import/providers/continue.d.ts +2 -0
  42. package/dist/bun/import/providers/continue.d.ts.map +1 -0
  43. package/dist/bun/import/providers/index.d.ts +19 -0
  44. package/dist/bun/import/providers/index.d.ts.map +1 -0
  45. package/dist/bun/import/providers/opencode.d.ts +2 -0
  46. package/dist/bun/import/providers/opencode.d.ts.map +1 -0
  47. package/dist/bun/import/providers/pi.d.ts +2 -0
  48. package/dist/bun/import/providers/pi.d.ts.map +1 -0
  49. package/dist/bun/import/types.d.ts +82 -0
  50. package/dist/bun/import/types.d.ts.map +1 -0
  51. package/dist/bun/index.d.ts +5 -2
  52. package/dist/bun/index.d.ts.map +1 -1
  53. package/dist/bun/index.js +3150 -439
  54. package/dist/bun/index.js.map +4 -4
  55. package/dist/bun/instruction-detect.d.ts +66 -0
  56. package/dist/bun/instruction-detect.d.ts.map +1 -0
  57. package/dist/bun/log.d.ts +9 -0
  58. package/dist/bun/log.d.ts.map +1 -1
  59. package/dist/bun/ltm.d.ts +139 -5
  60. package/dist/bun/ltm.d.ts.map +1 -1
  61. package/dist/bun/pattern-extract.d.ts +7 -0
  62. package/dist/bun/pattern-extract.d.ts.map +1 -1
  63. package/dist/bun/prompt.d.ts +1 -1
  64. package/dist/bun/prompt.d.ts.map +1 -1
  65. package/dist/bun/recall.d.ts.map +1 -1
  66. package/dist/bun/search.d.ts +5 -3
  67. package/dist/bun/search.d.ts.map +1 -1
  68. package/dist/bun/session-limiter.d.ts +26 -0
  69. package/dist/bun/session-limiter.d.ts.map +1 -0
  70. package/dist/bun/temporal.d.ts +2 -0
  71. package/dist/bun/temporal.d.ts.map +1 -1
  72. package/dist/bun/types.d.ts +1 -1
  73. package/dist/node/agents-file.d.ts +4 -0
  74. package/dist/node/agents-file.d.ts.map +1 -1
  75. package/dist/node/config.d.ts +2 -0
  76. package/dist/node/config.d.ts.map +1 -1
  77. package/dist/node/curator.d.ts +45 -0
  78. package/dist/node/curator.d.ts.map +1 -1
  79. package/dist/node/data-dir.d.ts +18 -0
  80. package/dist/node/data-dir.d.ts.map +1 -0
  81. package/dist/node/db.d.ts +85 -0
  82. package/dist/node/db.d.ts.map +1 -1
  83. package/dist/node/distillation.d.ts +2 -13
  84. package/dist/node/distillation.d.ts.map +1 -1
  85. package/dist/node/embedding-vendor.d.ts +22 -38
  86. package/dist/node/embedding-vendor.d.ts.map +1 -1
  87. package/dist/node/embedding-worker-types.d.ts +17 -12
  88. package/dist/node/embedding-worker-types.d.ts.map +1 -1
  89. package/dist/node/embedding-worker.d.ts +9 -2
  90. package/dist/node/embedding-worker.d.ts.map +1 -1
  91. package/dist/node/embedding-worker.js +38864 -33
  92. package/dist/node/embedding-worker.js.map +4 -4
  93. package/dist/node/embedding.d.ts +35 -23
  94. package/dist/node/embedding.d.ts.map +1 -1
  95. package/dist/node/gradient.d.ts +17 -1
  96. package/dist/node/gradient.d.ts.map +1 -1
  97. package/dist/node/import/detect.d.ts +14 -0
  98. package/dist/node/import/detect.d.ts.map +1 -0
  99. package/dist/node/import/extract.d.ts +43 -0
  100. package/dist/node/import/extract.d.ts.map +1 -0
  101. package/dist/node/import/history.d.ts +40 -0
  102. package/dist/node/import/history.d.ts.map +1 -0
  103. package/dist/node/import/index.d.ts +17 -0
  104. package/dist/node/import/index.d.ts.map +1 -0
  105. package/dist/node/import/providers/aider.d.ts +2 -0
  106. package/dist/node/import/providers/aider.d.ts.map +1 -0
  107. package/dist/node/import/providers/claude-code.d.ts +2 -0
  108. package/dist/node/import/providers/claude-code.d.ts.map +1 -0
  109. package/dist/node/import/providers/cline.d.ts +2 -0
  110. package/dist/node/import/providers/cline.d.ts.map +1 -0
  111. package/dist/node/import/providers/codex.d.ts +2 -0
  112. package/dist/node/import/providers/codex.d.ts.map +1 -0
  113. package/dist/node/import/providers/continue.d.ts +2 -0
  114. package/dist/node/import/providers/continue.d.ts.map +1 -0
  115. package/dist/node/import/providers/index.d.ts +19 -0
  116. package/dist/node/import/providers/index.d.ts.map +1 -0
  117. package/dist/node/import/providers/opencode.d.ts +2 -0
  118. package/dist/node/import/providers/opencode.d.ts.map +1 -0
  119. package/dist/node/import/providers/pi.d.ts +2 -0
  120. package/dist/node/import/providers/pi.d.ts.map +1 -0
  121. package/dist/node/import/types.d.ts +82 -0
  122. package/dist/node/import/types.d.ts.map +1 -0
  123. package/dist/node/index.d.ts +5 -2
  124. package/dist/node/index.d.ts.map +1 -1
  125. package/dist/node/index.js +3150 -439
  126. package/dist/node/index.js.map +4 -4
  127. package/dist/node/instruction-detect.d.ts +66 -0
  128. package/dist/node/instruction-detect.d.ts.map +1 -0
  129. package/dist/node/log.d.ts +9 -0
  130. package/dist/node/log.d.ts.map +1 -1
  131. package/dist/node/ltm.d.ts +139 -5
  132. package/dist/node/ltm.d.ts.map +1 -1
  133. package/dist/node/pattern-extract.d.ts +7 -0
  134. package/dist/node/pattern-extract.d.ts.map +1 -1
  135. package/dist/node/prompt.d.ts +1 -1
  136. package/dist/node/prompt.d.ts.map +1 -1
  137. package/dist/node/recall.d.ts.map +1 -1
  138. package/dist/node/search.d.ts +5 -3
  139. package/dist/node/search.d.ts.map +1 -1
  140. package/dist/node/session-limiter.d.ts +26 -0
  141. package/dist/node/session-limiter.d.ts.map +1 -0
  142. package/dist/node/temporal.d.ts +2 -0
  143. package/dist/node/temporal.d.ts.map +1 -1
  144. package/dist/node/types.d.ts +1 -1
  145. package/dist/types/agents-file.d.ts +4 -0
  146. package/dist/types/agents-file.d.ts.map +1 -1
  147. package/dist/types/config.d.ts +2 -0
  148. package/dist/types/config.d.ts.map +1 -1
  149. package/dist/types/curator.d.ts +45 -0
  150. package/dist/types/curator.d.ts.map +1 -1
  151. package/dist/types/data-dir.d.ts +18 -0
  152. package/dist/types/data-dir.d.ts.map +1 -0
  153. package/dist/types/db.d.ts +85 -0
  154. package/dist/types/db.d.ts.map +1 -1
  155. package/dist/types/distillation.d.ts +2 -13
  156. package/dist/types/distillation.d.ts.map +1 -1
  157. package/dist/types/embedding-vendor.d.ts +22 -38
  158. package/dist/types/embedding-vendor.d.ts.map +1 -1
  159. package/dist/types/embedding-worker-types.d.ts +17 -12
  160. package/dist/types/embedding-worker-types.d.ts.map +1 -1
  161. package/dist/types/embedding-worker.d.ts +9 -2
  162. package/dist/types/embedding-worker.d.ts.map +1 -1
  163. package/dist/types/embedding.d.ts +35 -23
  164. package/dist/types/embedding.d.ts.map +1 -1
  165. package/dist/types/gradient.d.ts +17 -1
  166. package/dist/types/gradient.d.ts.map +1 -1
  167. package/dist/types/import/detect.d.ts +14 -0
  168. package/dist/types/import/detect.d.ts.map +1 -0
  169. package/dist/types/import/extract.d.ts +43 -0
  170. package/dist/types/import/extract.d.ts.map +1 -0
  171. package/dist/types/import/history.d.ts +40 -0
  172. package/dist/types/import/history.d.ts.map +1 -0
  173. package/dist/types/import/index.d.ts +17 -0
  174. package/dist/types/import/index.d.ts.map +1 -0
  175. package/dist/types/import/providers/aider.d.ts +2 -0
  176. package/dist/types/import/providers/aider.d.ts.map +1 -0
  177. package/dist/types/import/providers/claude-code.d.ts +2 -0
  178. package/dist/types/import/providers/claude-code.d.ts.map +1 -0
  179. package/dist/types/import/providers/cline.d.ts +2 -0
  180. package/dist/types/import/providers/cline.d.ts.map +1 -0
  181. package/dist/types/import/providers/codex.d.ts +2 -0
  182. package/dist/types/import/providers/codex.d.ts.map +1 -0
  183. package/dist/types/import/providers/continue.d.ts +2 -0
  184. package/dist/types/import/providers/continue.d.ts.map +1 -0
  185. package/dist/types/import/providers/index.d.ts +19 -0
  186. package/dist/types/import/providers/index.d.ts.map +1 -0
  187. package/dist/types/import/providers/opencode.d.ts +2 -0
  188. package/dist/types/import/providers/opencode.d.ts.map +1 -0
  189. package/dist/types/import/providers/pi.d.ts +2 -0
  190. package/dist/types/import/providers/pi.d.ts.map +1 -0
  191. package/dist/types/import/types.d.ts +82 -0
  192. package/dist/types/import/types.d.ts.map +1 -0
  193. package/dist/types/index.d.ts +5 -2
  194. package/dist/types/index.d.ts.map +1 -1
  195. package/dist/types/instruction-detect.d.ts +66 -0
  196. package/dist/types/instruction-detect.d.ts.map +1 -0
  197. package/dist/types/log.d.ts +9 -0
  198. package/dist/types/log.d.ts.map +1 -1
  199. package/dist/types/ltm.d.ts +139 -5
  200. package/dist/types/ltm.d.ts.map +1 -1
  201. package/dist/types/pattern-extract.d.ts +7 -0
  202. package/dist/types/pattern-extract.d.ts.map +1 -1
  203. package/dist/types/prompt.d.ts +1 -1
  204. package/dist/types/prompt.d.ts.map +1 -1
  205. package/dist/types/recall.d.ts.map +1 -1
  206. package/dist/types/search.d.ts +5 -3
  207. package/dist/types/search.d.ts.map +1 -1
  208. package/dist/types/session-limiter.d.ts +26 -0
  209. package/dist/types/session-limiter.d.ts.map +1 -0
  210. package/dist/types/temporal.d.ts +2 -0
  211. package/dist/types/temporal.d.ts.map +1 -1
  212. package/dist/types/types.d.ts +1 -1
  213. package/package.json +3 -4
  214. package/src/agents-file.ts +41 -13
  215. package/src/config.ts +31 -18
  216. package/src/curator.ts +163 -75
  217. package/src/data-dir.ts +76 -0
  218. package/src/db.ts +457 -11
  219. package/src/distillation.ts +65 -16
  220. package/src/embedding-vendor.ts +23 -40
  221. package/src/embedding-worker-types.ts +19 -11
  222. package/src/embedding-worker.ts +111 -47
  223. package/src/embedding.ts +224 -174
  224. package/src/gradient.ts +192 -75
  225. package/src/import/detect.ts +37 -0
  226. package/src/import/extract.ts +137 -0
  227. package/src/import/history.ts +99 -0
  228. package/src/import/index.ts +45 -0
  229. package/src/import/providers/aider.ts +207 -0
  230. package/src/import/providers/claude-code.ts +339 -0
  231. package/src/import/providers/cline.ts +324 -0
  232. package/src/import/providers/codex.ts +369 -0
  233. package/src/import/providers/continue.ts +304 -0
  234. package/src/import/providers/index.ts +32 -0
  235. package/src/import/providers/opencode.ts +272 -0
  236. package/src/import/providers/pi.ts +332 -0
  237. package/src/import/types.ts +91 -0
  238. package/src/index.ts +13 -0
  239. package/src/instruction-detect.ts +275 -0
  240. package/src/log.ts +91 -3
  241. package/src/ltm.ts +789 -41
  242. package/src/pattern-extract.ts +41 -0
  243. package/src/prompt.ts +7 -1
  244. package/src/recall.ts +43 -5
  245. package/src/search.ts +7 -5
  246. package/src/session-limiter.ts +47 -0
  247. package/src/temporal.ts +18 -6
  248. package/src/types.ts +1 -1
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Cross-session repeated-instruction detection.
3
+ *
4
+ * Identifies instruction-like user messages in the current session
5
+ * and searches for similar instructions in prior sessions using both
6
+ * embedding-based vector search (semantic similarity) and FTS5 (exact terms).
7
+ *
8
+ * When an instruction appears in N+ prior sessions, it's flagged as a
9
+ * strong LTM candidate and formatted as additional context for the curator.
10
+ *
11
+ * This module does NOT auto-create knowledge entries — it augments the
12
+ * curator's input so the LLM can make the final judgment call on whether
13
+ * a repeated instruction warrants a persistent preference entry.
14
+ */
15
+ export type InstructionCandidate = {
16
+ /** The matched instruction text. */
17
+ text: string;
18
+ /** Session this candidate was found in. */
19
+ sessionID: string;
20
+ };
21
+ export type RepeatedInstruction = {
22
+ /** The instruction text from the current session. */
23
+ instruction: string;
24
+ /** Number of distinct prior sessions containing similar instructions. */
25
+ priorSessionCount: number;
26
+ };
27
+ /**
28
+ * Extract instruction-like phrases from user messages.
29
+ * Scans raw user message content for instruction keywords and returns
30
+ * deduplicated candidates.
31
+ */
32
+ export declare function extractInstructionCandidates(messages: Array<{
33
+ role: string;
34
+ content: string;
35
+ session_id: string;
36
+ }>): InstructionCandidate[];
37
+ /**
38
+ * Search for similar instructions in OTHER sessions via distillation
39
+ * embeddings (semantic) and FTS5 (keyword). Returns instructions that
40
+ * appear in >= threshold prior sessions.
41
+ */
42
+ export declare function findRepeatedInstructions(input: {
43
+ projectPath: string;
44
+ currentSessionID: string;
45
+ candidates: InstructionCandidate[];
46
+ threshold?: number;
47
+ }): Promise<RepeatedInstruction[]>;
48
+ /**
49
+ * Format repeated instructions as additional context for the curator prompt.
50
+ * Returns empty string if no repeated instructions found.
51
+ */
52
+ export declare function formatForCurator(instructions: RepeatedInstruction[]): string;
53
+ /**
54
+ * Full detection pipeline: extract candidates from current session →
55
+ * search for repetitions across other sessions → format for curator.
56
+ *
57
+ * Returns a string to append to the curator's user prompt, or "" if
58
+ * nothing was found. Safe to call even when embeddings are unavailable
59
+ * (falls back to FTS-only).
60
+ */
61
+ export declare function detectAndFormat(input: {
62
+ projectPath: string;
63
+ sessionID: string;
64
+ threshold?: number;
65
+ }): Promise<string>;
66
+ //# sourceMappingURL=instruction-detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction-detect.d.ts","sourceRoot":"","sources":["../../src/instruction-detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAwCH,MAAM,MAAM,oBAAoB,GAAG;IACjC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,oBAAoB,EAAE,CA+BxB;AAMD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CA4DjC;AA2CD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAS5E;AAMD;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB"}
package/dist/bun/log.d.ts CHANGED
@@ -14,6 +14,13 @@
14
14
  * When registered, every log call (regardless of `isDebug`) also forwards
15
15
  * to the sink. This is used by the gateway to bridge logs → Sentry without
16
16
  * adding a Sentry dependency to `@loreai/core`.
17
+ *
18
+ * ## File logging
19
+ *
20
+ * All log calls (info, warn, error) are written to a persistent log file
21
+ * at `~/.local/share/lore/lore.log` regardless of `LORE_DEBUG`.
22
+ * The file is rotated when it exceeds 5 MB (single `.log.1` backup).
23
+ * Use `lore logs` to view; disabled during tests (`NODE_ENV=test`).
17
24
  */
18
25
  /** External log consumer registered by the host (e.g. gateway → Sentry). */
19
26
  export interface LogSink {
@@ -24,6 +31,8 @@ export interface LogSink {
24
31
  }
25
32
  /** Register an external log sink. Only one sink is supported at a time. */
26
33
  export declare function registerSink(s: LogSink): void;
34
+ /** Return the resolved log file path (or `undefined` if unavailable). */
35
+ export declare function logFilePath(): string | undefined;
27
36
  /** Log an informational status message. Suppressed unless LORE_DEBUG=1. */
28
37
  export declare function info(...args: unknown[]): void;
29
38
  /** Log a warning. Suppressed unless LORE_DEBUG=1. */
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,4EAA4E;AAC5E,MAAM,WAAW,OAAO;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,GAAG,IAAI,CAAC;IAC9D,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;CACtC;AAID,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAE7C;AAiDD,yEAAyE;AACzE,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAMhD;AA0CD,2EAA2E;AAC3E,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAK7C;AAED,qDAAqD;AACrD,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAK7C;AAED,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAQ9C"}
package/dist/bun/ltm.d.ts CHANGED
@@ -27,7 +27,42 @@ export declare function update(id: string, input: {
27
27
  confidence?: number;
28
28
  }): void;
29
29
  export declare function remove(id: string): void;
30
+ /**
31
+ * Find an existing knowledge entry whose title is fuzzy-similar to the given title.
32
+ *
33
+ * Uses FTS5 to find up to 5 candidates, then applies word-overlap filtering.
34
+ * This is the same algorithm used by `check()` but returns a single match
35
+ * for use in the `create()` dedup guard.
36
+ *
37
+ * @returns The first matching entry (id + title), or null if no fuzzy match.
38
+ */
39
+ export declare function findFuzzyDuplicate(input: {
40
+ title: string;
41
+ projectId: string | null;
42
+ excludeId?: string;
43
+ }): {
44
+ id: string;
45
+ title: string;
46
+ } | null;
30
47
  export declare function forProject(projectPath: string, includeCross?: boolean): KnowledgeEntry[];
48
+ /**
49
+ * Well-known knowledge entry categories managed by the curator.
50
+ * The DB column is a free-form string, but these are the standard values.
51
+ */
52
+ export type KnowledgeCategory = "decision" | "pattern" | "preference" | "architecture" | "gotcha";
53
+ /** Options for `forSession()` to control entry selection. */
54
+ export type ForSessionOptions = {
55
+ /** Caller-provided context (e.g., user's current message) for relevance
56
+ * scoring when no session context exists in the DB yet. */
57
+ contextHint?: string;
58
+ /** Restrict to these categories (e.g., `['preference']` for turn 1). */
59
+ categories?: (KnowledgeCategory | (string & {}))[];
60
+ /** Exclude these categories (e.g., `['preference']` for context-bound
61
+ * entries when preferences are already injected in a separate block).
62
+ * Mutually exclusive with `categories` — if both are provided,
63
+ * `categories` (include) wins. */
64
+ excludeCategories?: (KnowledgeCategory | (string & {}))[];
65
+ };
31
66
  /**
32
67
  * Build a relevance-ranked, budget-capped list of knowledge entries for injection
33
68
  * into the system prompt of a live session.
@@ -35,21 +70,27 @@ export declare function forProject(projectPath: string, includeCross?: boolean):
35
70
  * Strategy:
36
71
  * 1. Both project-specific and cross-project entries are scored for relevance
37
72
  * against recent session context (last distillation + recent raw messages).
38
- * 2. Project entries get a safety net: the top PROJECT_SAFETY_NET entries by
73
+ * 2. When embeddings are available, vector cosine similarity is used for scoring
74
+ * (captures semantic matches that keyword overlap misses). Falls back to
75
+ * FTS5 BM25 when embeddings are unavailable.
76
+ * 3. Project entries get a safety net: the top PROJECT_SAFETY_NET entries by
39
77
  * confidence are always included even if they have zero relevance score.
40
78
  * This ensures the most important project knowledge is never lost to
41
- * coarse term-overlap scoring.
42
- * 3. All scored entries are merged into a single pool and greedily packed
79
+ * coarse scoring.
80
+ * 4. All scored entries are merged into a single pool and greedily packed
43
81
  * into the token budget by score descending.
44
- * 4. If there's no session context yet (first turn), fall back to top entries
82
+ * 5. If there's no session context yet (first turn), fall back to top entries
45
83
  * by confidence only (capped at NO_CONTEXT_FALLBACK_CAP per pool).
46
84
  *
47
85
  * @param projectPath Current project path
48
86
  * @param sessionID Current session ID (for context extraction)
49
87
  * @param maxTokens Hard token budget for the entire formatted block
88
+ * @param options Optional category filter and context hint
50
89
  */
51
- export declare function forSession(projectPath: string, sessionID: string | undefined, maxTokens: number): KnowledgeEntry[];
90
+ export declare function forSession(projectPath: string, sessionID: string | undefined, maxTokens: number, options?: ForSessionOptions): Promise<KnowledgeEntry[]>;
52
91
  export declare function all(): KnowledgeEntry[];
92
+ /** Return all cross-project and global (user-level) knowledge entries. */
93
+ export declare function crossProject(): KnowledgeEntry[];
53
94
  export declare function search(input: {
54
95
  query: string;
55
96
  projectPath?: string;
@@ -135,4 +176,97 @@ export type IntegrityIssue = {
135
176
  * 2. Content quality — empty content, oversized entries
136
177
  */
137
178
  export declare function check(projectPath: string): IntegrityIssue[];
179
+ export type DedupCluster = {
180
+ surviving: {
181
+ id: string;
182
+ title: string;
183
+ };
184
+ merged: Array<{
185
+ id: string;
186
+ title: string;
187
+ }>;
188
+ };
189
+ /** Stable pair key for two entry IDs — sorted to ensure order-independence. */
190
+ export declare function dedupPairKey(idA: string, idB: string): string;
191
+ export type DedupResult = {
192
+ clusters: DedupCluster[];
193
+ totalRemoved: number;
194
+ /** Pairwise embedding cosine similarities. Key: dedupPairKey(idA, idB). */
195
+ pairSimilarities: Map<string, number>;
196
+ /** All entry titles by ID — for feedback recording after entries are deleted. */
197
+ entryTitles: Map<string, string>;
198
+ };
199
+ export declare function deduplicate(projectPath: string, opts?: {
200
+ dryRun?: boolean;
201
+ }): Promise<DedupResult>;
202
+ /** Deduplicate global (cross-project) entries that have no project_id. */
203
+ export declare function deduplicateGlobal(opts?: {
204
+ dryRun?: boolean;
205
+ }): Promise<DedupResult>;
206
+ export type DedupFeedbackSource = "auto_dedup" | "cli_yes" | "cli_interactive";
207
+ /** Record a single dedup feedback row. */
208
+ export declare function recordDedupFeedback(input: {
209
+ projectId: string | null;
210
+ entryATitle: string;
211
+ entryBTitle: string;
212
+ similarity: number;
213
+ accepted: boolean;
214
+ source: DedupFeedbackSource;
215
+ }): void;
216
+ /**
217
+ * Bulk-record feedback for all merged pairs in a DedupResult.
218
+ * Only records pairs with embedding similarity > 0 (title-overlap-only
219
+ * matches are excluded from calibration).
220
+ */
221
+ export declare function recordDedupResultFeedback(projectId: string | null, result: DedupResult, accepted: boolean, source: DedupFeedbackSource): void;
222
+ /**
223
+ * Record automatic calibration signals from a post-curation dedup sweep.
224
+ *
225
+ * Only records **reject** signals — non-merged pairs with similarity in
226
+ * [0.80, threshold). Accept signals from auto-dedup are tautological (the
227
+ * pair was merged *because* its similarity exceeded the threshold), so they
228
+ * provide no new information and would create a self-reinforcing feedback
229
+ * loop. Manual signals (cli_yes, cli_interactive) provide the accept side.
230
+ *
231
+ * Caps at AUTO_SIGNAL_MAX_PAIRS most interesting pairs per run (closest
232
+ * to the threshold boundary) to avoid table bloat.
233
+ */
234
+ export declare function recordAutoSignals(projectId: string | null, result: DedupResult): void;
235
+ /** Get all feedback for a project (for calibration). */
236
+ export declare function getDedupFeedback(projectId: string | null): Array<{
237
+ similarity: number;
238
+ accepted: boolean;
239
+ source: string;
240
+ }>;
241
+ /** Quick count of feedback rows for a project. */
242
+ export declare function getDedupFeedbackCount(projectId: string | null): number;
243
+ /**
244
+ * Prune old feedback rows for a project, keeping the most recent
245
+ * MAX_FEEDBACK_ROWS_PER_PROJECT rows. Called from recordAutoSignals
246
+ * to prevent unbounded table growth.
247
+ */
248
+ export declare function pruneDedupFeedback(projectId: string | null): void;
249
+ /**
250
+ * Compute an optimal embedding dedup threshold from user feedback.
251
+ *
252
+ * Algorithm:
253
+ * 1. Load all (similarity, accepted) pairs for the project.
254
+ * 2. If fewer than MIN_CALIBRATION_SAMPLES, return null (use default).
255
+ * 3. If all feedback is "accept" (no rejects), return the minimum
256
+ * accepted similarity minus a small margin (0.005).
257
+ * 4. If all feedback is "reject" (no accepts), return null.
258
+ * 5. Otherwise, find the threshold that maximizes separation:
259
+ * - For each candidate threshold (midpoint between consecutive
260
+ * distinct similarity values), compute accuracy:
261
+ * correct = accepted_pairs_above + rejected_pairs_below
262
+ * accuracy = correct / total
263
+ * - Pick the threshold with highest accuracy.
264
+ * - Tie-break: prefer higher threshold (conservative).
265
+ * - Clamp to [0.85, 0.98].
266
+ */
267
+ export declare function calibrateDedupThreshold(projectId: string | null): number | null;
268
+ /** Persist the calibrated threshold for a project. */
269
+ export declare function saveCalibratedThreshold(projectId: string | null, threshold: number, sampleSize: number): void;
270
+ /** Load the calibrated threshold for a project, or null if not calibrated. */
271
+ export declare function loadCalibratedThreshold(projectId: string | null): number | null;
138
272
  //# sourceMappingURL=ltm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ltm.d.ts","sourceRoot":"","sources":["../../src/ltm.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAWF,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+FAA+F;IAC/F,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,GAAG,MAAM,CAyET;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,QA0BjD;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,QAEhC;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,YAAY,UAAO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AC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CA2C/E;AAED,sDAAsD;AACtD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CAGN;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAU/E"}
@@ -12,6 +12,13 @@
12
12
  * - "prefers X for Y"
13
13
  * - "going with X because Y"
14
14
  *
15
+ * Also matches process instruction patterns from distilled observations
16
+ * where the observer normalizes user assertions:
17
+ * - "User stated always X"
18
+ * - "User said never Y"
19
+ * - "User stated make sure to X"
20
+ * - "User stated don't forget to X"
21
+ *
15
22
  * Extracted entries participate in the normal curator cycle — the curator
16
23
  * can consolidate or remove them based on actual value. The extraction is
17
24
  * a cheap seed, not a permanent fixture.
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-extract.d.ts","sourceRoot":"","sources":["../../src/pattern-extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,UAAU,GAAG,YAAY,CAAC;IACpC,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAuDF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAkBxE"}
1
+ {"version":3,"file":"pattern-extract.d.ts","sourceRoot":"","sources":["../../src/pattern-extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,UAAU,GAAG,YAAY,CAAC;IACpC,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAkFF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAyBxE"}
@@ -8,7 +8,7 @@ export declare const RECURSIVE_SYSTEM = "You are a memory reflector. You are giv
8
8
  export declare function recursiveUser(distillations: Array<{
9
9
  observations: string;
10
10
  }>, previousMeta?: string): string;
11
- export declare const CURATOR_SYSTEM = "You are a long-term memory curator. Your job is to extract durable knowledge from a conversation that should persist across sessions.\n\nFocus ONLY on knowledge that helps a coding agent work effectively on THIS codebase:\n- Architectural decisions and their rationale (why something was built a certain way)\n- Non-obvious implementation patterns and conventions specific to the project\n- Recurring gotchas, constraints, or traps in the codebase\n- Environment/tooling setup details that affect development\n- Important relationships between components that aren't obvious from reading the code\n- User preferences and working style specific to how they use this project\n\nDo NOT extract:\n- Task-specific details (file currently being edited, current bug being fixed)\n- Temporary state (current branch, in-progress work)\n- Information that will change frequently\n- Ecosystem descriptions, product announcements, or marketing content\n- Business strategy, roadmap, or organizational information\n- Information that's readily available in public documentation or READMEs\n- Knowledge about unrelated projects or repositories unless explicitly cross-project\n- Restatements of what the code obviously does (e.g. \"the auth module handles authentication\")\n\nBREVITY IS CRITICAL \u2014 each entry must be concise:\n- content MUST be under 150 words (~600 characters). Capture ONE specific actionable\n insight in 2-3 sentences. Prefer terse technical language.\n- Each \"gotcha\": one specific trap + its fix in 1-2 sentences\n- Each \"architecture\": one design decision and its key constraint\n- Focus on the actionable insight, not the full story behind it\n- If a pattern requires more detail, split into multiple focused entries (each under 150 words)\n- Omit code examples unless a single short snippet is essential\n- Never include full file contents, large diffs, or complete command outputs\n\nPREFER UPDATES OVER CREATES:\n- Before creating a new entry, always check if an existing entry covers the same system\n or component. Update the existing entry rather than creating a new one.\n- When updating, REPLACE the full content with a concise rewrite \u2014 do not append to\n the existing content or repeat what was already there.\n- If multiple existing entries cover the same system from different angles (e.g. different\n bugs in the same module), consolidate them: update one with merged insights, delete the\n rest. Fewer, denser entries are better than many scattered ones.\n\nCROSS-REFERENCES between entries:\n- When an entry relates to another entry, reference it with [[entry-uuid]] using the entry's ID\n from the existing entries list. This creates navigable links between entries.\n- Only reference entries you can see in the existing entries list \u2014 don't guess IDs.\n- Example: \"Uses the gradient system [[019c904b-791e-772a-ab2b-93ac892a960c]] for context management.\"\n\ncrossProject flag:\n- Default is true \u2014 most useful knowledge is worth sharing across projects\n- Set crossProject to false for things that are meaningless outside this specific repo (e.g. a config path, a project-local naming convention that conflicts with your usual style)\n\nProduce a JSON array of operations:\n[\n {\n \"op\": \"create\",\n \"category\": \"decision\" | \"pattern\" | \"preference\" | \"architecture\" | \"gotcha\",\n \"title\": \"Short descriptive title\",\n \"content\": \"Concise knowledge entry \u2014 under 150 words\",\n \"scope\": \"project\" | \"global\",\n \"crossProject\": true\n },\n {\n \"op\": \"update\",\n \"id\": \"existing-entry-id\",\n \"content\": \"Updated content \u2014 under 150 words\",\n \"confidence\": 0.0-1.0\n },\n {\n \"op\": \"delete\",\n \"id\": \"existing-entry-id\",\n \"reason\": \"Why this is no longer relevant\"\n }\n]\n\nIf nothing warrants extraction, return an empty array: []\n\nOutput ONLY valid JSON. No markdown fences, no explanation, no preamble.";
11
+ export declare const CURATOR_SYSTEM = "You are a long-term memory curator. Your job is to extract durable knowledge from a conversation that should persist across sessions.\n\nFocus ONLY on knowledge that helps a coding agent work effectively on THIS codebase:\n- Architectural decisions and their rationale (why something was built a certain way)\n- Non-obvious implementation patterns and conventions specific to the project\n- Recurring gotchas, constraints, or traps in the codebase\n- Environment/tooling setup details that affect development\n- Important relationships between components that aren't obvious from reading the code\n- User preferences and working style specific to how they use this project\n- Repeated user instructions \u2014 when the user says things like \"always\", \"never\",\n \"make sure to\", \"don't forget to\", these are high-value preference candidates.\n If you see instruction-like language, prioritize extracting it as a \"preference\" entry.\n These instructions represent how the user wants to work and should persist across sessions.\n\nDo NOT extract:\n- Task-specific details (file currently being edited, current bug being fixed)\n- Temporary state (current branch, in-progress work)\n- Information that will change frequently\n- Ecosystem descriptions, product announcements, or marketing content\n- Business strategy, roadmap, or organizational information\n- Information that's readily available in public documentation or READMEs\n- Knowledge about unrelated projects or repositories unless explicitly cross-project\n- Restatements of what the code obviously does (e.g. \"the auth module handles authentication\")\n\nBREVITY IS CRITICAL \u2014 each entry must be concise:\n- content MUST be under 150 words (~600 characters). Capture ONE specific actionable\n insight in 2-3 sentences. Prefer terse technical language.\n- Each \"gotcha\": one specific trap + its fix in 1-2 sentences\n- Each \"architecture\": one design decision and its key constraint\n- Focus on the actionable insight, not the full story behind it\n- If a pattern requires more detail, split into multiple focused entries (each under 150 words)\n- Omit code examples unless a single short snippet is essential\n- Never include full file contents, large diffs, or complete command outputs\n\nPREFER UPDATES OVER CREATES:\n- Before creating a new entry, always check if an existing entry covers the same system\n or component. Update the existing entry rather than creating a new one.\n- When updating, REPLACE the full content with a concise rewrite \u2014 do not append to\n the existing content or repeat what was already there.\n- If multiple existing entries cover the same system from different angles (e.g. different\n bugs in the same module), consolidate them: update one with merged insights, delete the\n rest. Fewer, denser entries are better than many scattered ones.\n\nCROSS-REFERENCES between entries:\n- When an entry relates to another entry, reference it with [[entry-uuid]] using the entry's ID\n from the existing entries list. This creates navigable links between entries.\n- Only reference entries you can see in the existing entries list \u2014 don't guess IDs.\n- Example: \"Uses the gradient system [[019c904b-791e-772a-ab2b-93ac892a960c]] for context management.\"\n\ncrossProject flag:\n- Default is true \u2014 most useful knowledge is worth sharing across projects\n- Set crossProject to false for things that are meaningless outside this specific repo (e.g. a config path, a project-local naming convention that conflicts with your usual style)\n\nProduce a JSON array of operations:\n[\n {\n \"op\": \"create\",\n \"category\": \"decision\" | \"pattern\" | \"preference\" | \"architecture\" | \"gotcha\",\n \"title\": \"Short descriptive title\",\n \"content\": \"Concise knowledge entry \u2014 under 150 words\",\n \"scope\": \"project\" | \"global\",\n \"crossProject\": true\n },\n {\n \"op\": \"update\",\n \"id\": \"existing-entry-id\",\n \"content\": \"Updated content \u2014 under 150 words\",\n \"confidence\": 0.0-1.0\n },\n {\n \"op\": \"delete\",\n \"id\": \"existing-entry-id\",\n \"reason\": \"Why this is no longer relevant\"\n }\n]\n\nIf nothing warrants extraction, return an empty array: []\n\nOutput ONLY valid JSON. No markdown fences, no explanation, no preamble.";
12
12
  export declare function curatorUser(input: {
13
13
  messages: string;
14
14
  existing: Array<{
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,s1OAmHhB,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAaT;AAUD,eAAO,MAAM,gBAAgB,mkGAsC2C,CAAC;AAEzE,wBAAgB,aAAa,CAC3B,aAAa,EAAE,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9C,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAoBR;AAED,eAAO,MAAM,cAAc,i5HA0E8C,CAAC;AAE1E,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ,GAAG,MAAM,CAoBT;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,uoDA0BwC,CAAC;AAE1E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,OAAO,EAAE,KAAK,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ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E,MAAM,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,GACpD;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAA;CAAE,GAC5D;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC,gBAAgB,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA0WvE;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuY/B;AAMD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAoE7C;AAED,wFAAwF;AACxF,wBAAsB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAczE;AAED,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,wiBAC8f,CAAC;AAEniB,mEAAmE;AACnE,eAAO,MAAM,yBAAyB;;;;CAKrC,CAAC"}
@@ -104,14 +104,15 @@ export declare function normalizeRank(rank: number, minRank: number, maxRank: nu
104
104
  /**
105
105
  * Reciprocal Rank Fusion: merge multiple ranked lists into a single ranked list.
106
106
  *
107
- * RRF score = Σ(1 / (k + rank_i)) for each list where the item appears.
107
+ * RRF score = Σ(weight / (k + rank_i)) for each list where the item appears.
108
108
  * k = 60 is standard (from Cormack et al., 2009; also used by QMD).
109
109
  *
110
110
  * RRF is rank-based, not score-based — raw score magnitude differences across
111
111
  * different FTS5 tables don't matter. Only relative ordering within each list.
112
112
  *
113
- * @param lists Each list provides items (in ranked order) and a key function
114
- * for deduplication. Items at the front of the array are rank 0.
113
+ * @param lists Each list provides items (in ranked order), a key function
114
+ * for deduplication, and an optional weight (default 1).
115
+ * Items at the front of the array are rank 0.
115
116
  * @param k Smoothing constant. Default 60.
116
117
  * @returns Fused list sorted by RRF score descending. When items appear
117
118
  * in multiple lists, the first occurrence's item is kept.
@@ -119,6 +120,7 @@ export declare function normalizeRank(rank: number, minRank: number, maxRank: nu
119
120
  export declare function reciprocalRankFusion<T>(lists: Array<{
120
121
  items: T[];
121
122
  key: (item: T) => string;
123
+ weight?: number;
122
124
  }>, k?: number): Array<{
123
125
  item: T;
124
126
  score: number;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,MAAM,CAmGxC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAO,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASjD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI5C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,EAAE,CAmBnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,CAAC,EAAE,GACjC,CAAC,EAAE,CAiBL;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,EAAE,CAelE;AAMD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO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;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC/C,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqCnB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Per-key concurrency limiter using p-limit.
3
+ *
4
+ * Each key (typically a session ID) gets its own p-limit(1) instance,
5
+ * serializing async operations on the same key while allowing different
6
+ * keys to run fully in parallel.
7
+ *
8
+ * Two independent limiter pools are provided — one for distillation and
9
+ * one for curation — so they don't block each other.
10
+ */
11
+ import pLimit from "p-limit";
12
+ type LimitFunction = ReturnType<typeof pLimit>;
13
+ /** Serializes distillation.run() and metaDistill() per session. */
14
+ export declare const distillLimiter: {
15
+ get: (key: string) => LimitFunction;
16
+ isBusy: (key: string) => boolean;
17
+ clear: () => void;
18
+ };
19
+ /** Serializes curator.run() per session with skip-if-busy semantics. */
20
+ export declare const curatorLimiter: {
21
+ get: (key: string) => LimitFunction;
22
+ isBusy: (key: string) => boolean;
23
+ clear: () => void;
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=session-limiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-limiter.d.ts","sourceRoot":"","sources":["../../src/session-limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AA6B/C,mEAAmE;AACnE,eAAO,MAAM,cAAc;eAxBP,MAAM,KAAG,aAAa;kBAUnB,MAAM,KAAG,OAAO;iBAMnB,IAAI;CAQyB,CAAC;AAElD,wEAAwE;AACxE,eAAO,MAAM,cAAc;eA3BP,MAAM,KAAG,aAAa;kBAUnB,MAAM,KAAG,OAAO;iBAMnB,IAAI;CAWyB,CAAC"}
@@ -84,6 +84,8 @@ export declare function searchScored(input: {
84
84
  */
85
85
  export declare function temporalCnorm(timestamps: number[], now?: number): number;
86
86
  export declare function count(projectPath: string, sessionID?: string): number;
87
+ /** Quick existence check — true if any temporal messages exist for this session. */
88
+ export declare function hasMessages(projectPath: string, sessionID: string): boolean;
87
89
  export declare function undistilledCount(projectPath: string, sessionID?: string): number;
88
90
  /** Sum of estimated tokens across undistilled messages for a project/session. */
89
91
  export declare function undistilledTokens(projectPath: string, sessionID?: string): number;
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/temporal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,WAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAarD;AAiBD,wBAAgB,KAAK,CAAC,KAAK,EAAE;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,QA8CA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CACzB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,eAAe,EAAE,CASnB;AAED,wBAAgB,SA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AC;CACtB,GAAG,WAAW,CA0Ed"}
@@ -164,7 +164,7 @@ export type LoreMessageWithParts = {
164
164
  * Host adapters implement this:
165
165
  * - OpenCode: wraps `client.session.create()` + `client.session.prompt()`
166
166
  * - Pi: wraps `complete()` from `@mariozechner/pi-ai`
167
- * - Standalone: direct `fetch()` to provider APIs
167
+ * - Gateway: direct `fetch()` to provider APIs
168
168
  */
169
169
  export interface LLMClient {
170
170
  /**
@@ -87,6 +87,10 @@ export declare function shouldImportLoreFile(projectPath: string): boolean;
87
87
  /**
88
88
  * Import knowledge entries from `.lore.md` into the local DB.
89
89
  * Parses the full file content (no section markers to split on).
90
+ *
91
+ * After a successful import, updates the file cache so that
92
+ * `shouldImportLoreFile()` fast-paths on the next check — the file
93
+ * content hasn't changed, only the DB was updated to match it.
90
94
  */
91
95
  export declare function importLoreFile(projectPath: string): void;
92
96
  //# sourceMappingURL=agents-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents-file.d.ts","sourceRoot":"","sources":["../../src/agents-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,eAAO,MAAM,kBAAkB,qGACqE,CAAC;AACrG,eAAO,MAAM,gBAAgB,sCAAsC,CAAC;AAepE;;;;GAIG;AACH,eAAO,MAAM,SAAS,aAAa,CAAC;AA8CpC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAI5D;AAMD,MAAM,MAAM,eAAe,GAAG;IAC5B,+EAA+E;IAC/E,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+EF;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAgD1E;AAmFD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC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E,MAAM,GAAG,eAAe,EAAE,CAgD1E;AAmFD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CA8BP;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAcV;AAoFD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAeP;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAiBxD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAwBjE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAmBxD"}
@@ -47,6 +47,8 @@ export declare const LoreConfig: z.ZodObject<{
47
47
  }, z.core.$strip>>;
48
48
  recallLimit: z.ZodDefault<z.ZodNumber>;
49
49
  queryExpansion: z.ZodDefault<z.ZodBoolean>;
50
+ vectorBoostWeight: z.ZodDefault<z.ZodNumber>;
51
+ vectorBoostMinTerms: z.ZodDefault<z.ZodNumber>;
50
52
  embeddings: z.ZodDefault<z.ZodObject<{
51
53
  enabled: z.ZodDefault<z.ZodBoolean>;
52
54
  provider: z.ZodDefault<z.ZodEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiOrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED,wBAAsB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CASjE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8OrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED,wBAAsB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CASjE"}
@@ -1,4 +1,49 @@
1
1
  import type { LLMClient } from "./types";
2
+ /**
3
+ * Maximum length (chars) for a single knowledge entry's content.
4
+ * ~400 tokens at chars/3. Entries exceeding this are truncated with a notice.
5
+ * The curator prompt also instructs the model to stay within this limit,
6
+ * so truncation is a last-resort safety net.
7
+ */
8
+ export declare const MAX_ENTRY_CONTENT_LENGTH = 1200;
9
+ export type CuratorOp = {
10
+ op: "create";
11
+ category: string;
12
+ title: string;
13
+ content: string;
14
+ scope: "project" | "global";
15
+ crossProject?: boolean;
16
+ } | {
17
+ op: "update";
18
+ id: string;
19
+ content?: string;
20
+ confidence?: number;
21
+ } | {
22
+ op: "delete";
23
+ id: string;
24
+ reason: string;
25
+ };
26
+ /**
27
+ * Parse the LLM's JSON response into typed curator ops.
28
+ * Handles markdown fences and filters invalid entries.
29
+ */
30
+ export declare function parseOps(text: string): CuratorOp[];
31
+ /**
32
+ * Apply a list of curator ops (create/update/delete) to the knowledge DB.
33
+ * Shared by both the live curator and the conversation import system.
34
+ *
35
+ * @returns Counts of applied operations.
36
+ */
37
+ export declare function applyOps(ops: CuratorOp[], input: {
38
+ projectPath?: string;
39
+ sessionID?: string;
40
+ /** If true, skip "create" ops (used by consolidation). */
41
+ skipCreate?: boolean;
42
+ }): {
43
+ created: number;
44
+ updated: number;
45
+ deleted: number;
46
+ };
2
47
  export declare function run(input: {
3
48
  llm: LLMClient;
4
49
  projectPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"curator.d.ts","sourceRoot":"","sources":["../../src/curator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA+CzC,wBAAsB,GAAG,CAAC,KAAK,EAAE;IAC/B,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAsFjE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,QAMtD;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE;IACvC,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAA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;IAC/B,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBjE;AA2FD,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,QAMtD;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE;IACvC,GAAG,EAAE,SAAS,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkChD"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared data-directory path resolution with one-time migration from the
3
+ * legacy `opencode-lore` directory name to `lore`.
4
+ *
5
+ * Both `db.ts` and `log.ts` need the data directory path. This module
6
+ * provides a single source of truth so the path logic is not duplicated.
7
+ */
8
+ /**
9
+ * Return the resolved data directory path (`~/.local/share/lore` by
10
+ * default), running the legacy-directory migration on the first call.
11
+ *
12
+ * **Callers are responsible for creating the directory** — this function
13
+ * does not call `mkdirSync`.
14
+ */
15
+ export declare function dataDir(): string;
16
+ /** @internal Visible for testing only — resets the one-shot guard. */
17
+ export declare function _resetMigrationFlag(): void;
18
+ //# sourceMappingURL=data-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-dir.d.ts","sourceRoot":"","sources":["../../src/data-dir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAGhC;AAED,sEAAsE;AACtE,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}