@loreai/core 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun/agents-file.d.ts +4 -0
- package/dist/bun/agents-file.d.ts.map +1 -1
- package/dist/bun/config.d.ts +2 -0
- package/dist/bun/config.d.ts.map +1 -1
- package/dist/bun/curator.d.ts +45 -0
- package/dist/bun/curator.d.ts.map +1 -1
- package/dist/bun/data-dir.d.ts +18 -0
- package/dist/bun/data-dir.d.ts.map +1 -0
- package/dist/bun/db.d.ts +12 -0
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/distillation.d.ts.map +1 -1
- package/dist/bun/embedding-vendor.d.ts +22 -38
- package/dist/bun/embedding-vendor.d.ts.map +1 -1
- package/dist/bun/embedding-worker-types.d.ts +17 -12
- package/dist/bun/embedding-worker-types.d.ts.map +1 -1
- package/dist/bun/embedding-worker.d.ts +9 -2
- package/dist/bun/embedding-worker.d.ts.map +1 -1
- package/dist/bun/embedding-worker.js +38864 -33
- package/dist/bun/embedding-worker.js.map +4 -4
- package/dist/bun/embedding.d.ts +30 -22
- package/dist/bun/embedding.d.ts.map +1 -1
- package/dist/bun/gradient.d.ts +8 -1
- package/dist/bun/gradient.d.ts.map +1 -1
- package/dist/bun/import/detect.d.ts +14 -0
- package/dist/bun/import/detect.d.ts.map +1 -0
- package/dist/bun/import/extract.d.ts +43 -0
- package/dist/bun/import/extract.d.ts.map +1 -0
- package/dist/bun/import/history.d.ts +40 -0
- package/dist/bun/import/history.d.ts.map +1 -0
- package/dist/bun/import/index.d.ts +17 -0
- package/dist/bun/import/index.d.ts.map +1 -0
- package/dist/bun/import/providers/aider.d.ts +2 -0
- package/dist/bun/import/providers/aider.d.ts.map +1 -0
- package/dist/bun/import/providers/claude-code.d.ts +2 -0
- package/dist/bun/import/providers/claude-code.d.ts.map +1 -0
- package/dist/bun/import/providers/cline.d.ts +2 -0
- package/dist/bun/import/providers/cline.d.ts.map +1 -0
- package/dist/bun/import/providers/codex.d.ts +2 -0
- package/dist/bun/import/providers/codex.d.ts.map +1 -0
- package/dist/bun/import/providers/continue.d.ts +2 -0
- package/dist/bun/import/providers/continue.d.ts.map +1 -0
- package/dist/bun/import/providers/index.d.ts +19 -0
- package/dist/bun/import/providers/index.d.ts.map +1 -0
- package/dist/bun/import/providers/opencode.d.ts +2 -0
- package/dist/bun/import/providers/opencode.d.ts.map +1 -0
- package/dist/bun/import/providers/pi.d.ts +2 -0
- package/dist/bun/import/providers/pi.d.ts.map +1 -0
- package/dist/bun/import/types.d.ts +82 -0
- package/dist/bun/import/types.d.ts.map +1 -0
- package/dist/bun/index.d.ts +4 -1
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +2217 -224
- package/dist/bun/index.js.map +4 -4
- package/dist/bun/instruction-detect.d.ts +66 -0
- package/dist/bun/instruction-detect.d.ts.map +1 -0
- package/dist/bun/log.d.ts +9 -0
- package/dist/bun/log.d.ts.map +1 -1
- package/dist/bun/ltm.d.ts +40 -0
- package/dist/bun/ltm.d.ts.map +1 -1
- package/dist/bun/pattern-extract.d.ts +7 -0
- package/dist/bun/pattern-extract.d.ts.map +1 -1
- package/dist/bun/prompt.d.ts +1 -1
- package/dist/bun/prompt.d.ts.map +1 -1
- package/dist/bun/recall.d.ts.map +1 -1
- package/dist/bun/search.d.ts +5 -3
- package/dist/bun/search.d.ts.map +1 -1
- package/dist/bun/temporal.d.ts.map +1 -1
- package/dist/bun/types.d.ts +1 -1
- package/dist/node/agents-file.d.ts +4 -0
- package/dist/node/agents-file.d.ts.map +1 -1
- package/dist/node/config.d.ts +2 -0
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/curator.d.ts +45 -0
- package/dist/node/curator.d.ts.map +1 -1
- package/dist/node/data-dir.d.ts +18 -0
- package/dist/node/data-dir.d.ts.map +1 -0
- package/dist/node/db.d.ts +12 -0
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/distillation.d.ts.map +1 -1
- package/dist/node/embedding-vendor.d.ts +22 -38
- package/dist/node/embedding-vendor.d.ts.map +1 -1
- package/dist/node/embedding-worker-types.d.ts +17 -12
- package/dist/node/embedding-worker-types.d.ts.map +1 -1
- package/dist/node/embedding-worker.d.ts +9 -2
- package/dist/node/embedding-worker.d.ts.map +1 -1
- package/dist/node/embedding-worker.js +38864 -33
- package/dist/node/embedding-worker.js.map +4 -4
- package/dist/node/embedding.d.ts +30 -22
- package/dist/node/embedding.d.ts.map +1 -1
- package/dist/node/gradient.d.ts +8 -1
- package/dist/node/gradient.d.ts.map +1 -1
- package/dist/node/import/detect.d.ts +14 -0
- package/dist/node/import/detect.d.ts.map +1 -0
- package/dist/node/import/extract.d.ts +43 -0
- package/dist/node/import/extract.d.ts.map +1 -0
- package/dist/node/import/history.d.ts +40 -0
- package/dist/node/import/history.d.ts.map +1 -0
- package/dist/node/import/index.d.ts +17 -0
- package/dist/node/import/index.d.ts.map +1 -0
- package/dist/node/import/providers/aider.d.ts +2 -0
- package/dist/node/import/providers/aider.d.ts.map +1 -0
- package/dist/node/import/providers/claude-code.d.ts +2 -0
- package/dist/node/import/providers/claude-code.d.ts.map +1 -0
- package/dist/node/import/providers/cline.d.ts +2 -0
- package/dist/node/import/providers/cline.d.ts.map +1 -0
- package/dist/node/import/providers/codex.d.ts +2 -0
- package/dist/node/import/providers/codex.d.ts.map +1 -0
- package/dist/node/import/providers/continue.d.ts +2 -0
- package/dist/node/import/providers/continue.d.ts.map +1 -0
- package/dist/node/import/providers/index.d.ts +19 -0
- package/dist/node/import/providers/index.d.ts.map +1 -0
- package/dist/node/import/providers/opencode.d.ts +2 -0
- package/dist/node/import/providers/opencode.d.ts.map +1 -0
- package/dist/node/import/providers/pi.d.ts +2 -0
- package/dist/node/import/providers/pi.d.ts.map +1 -0
- package/dist/node/import/types.d.ts +82 -0
- package/dist/node/import/types.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2217 -224
- package/dist/node/index.js.map +4 -4
- package/dist/node/instruction-detect.d.ts +66 -0
- package/dist/node/instruction-detect.d.ts.map +1 -0
- package/dist/node/log.d.ts +9 -0
- package/dist/node/log.d.ts.map +1 -1
- package/dist/node/ltm.d.ts +40 -0
- package/dist/node/ltm.d.ts.map +1 -1
- package/dist/node/pattern-extract.d.ts +7 -0
- package/dist/node/pattern-extract.d.ts.map +1 -1
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.d.ts.map +1 -1
- package/dist/node/recall.d.ts.map +1 -1
- package/dist/node/search.d.ts +5 -3
- package/dist/node/search.d.ts.map +1 -1
- package/dist/node/temporal.d.ts.map +1 -1
- package/dist/node/types.d.ts +1 -1
- package/dist/types/agents-file.d.ts +4 -0
- package/dist/types/agents-file.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/curator.d.ts +45 -0
- package/dist/types/curator.d.ts.map +1 -1
- package/dist/types/data-dir.d.ts +18 -0
- package/dist/types/data-dir.d.ts.map +1 -0
- package/dist/types/db.d.ts +12 -0
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/distillation.d.ts.map +1 -1
- package/dist/types/embedding-vendor.d.ts +22 -38
- package/dist/types/embedding-vendor.d.ts.map +1 -1
- package/dist/types/embedding-worker-types.d.ts +17 -12
- package/dist/types/embedding-worker-types.d.ts.map +1 -1
- package/dist/types/embedding-worker.d.ts +9 -2
- package/dist/types/embedding-worker.d.ts.map +1 -1
- package/dist/types/embedding.d.ts +30 -22
- package/dist/types/embedding.d.ts.map +1 -1
- package/dist/types/gradient.d.ts +8 -1
- package/dist/types/gradient.d.ts.map +1 -1
- package/dist/types/import/detect.d.ts +14 -0
- package/dist/types/import/detect.d.ts.map +1 -0
- package/dist/types/import/extract.d.ts +43 -0
- package/dist/types/import/extract.d.ts.map +1 -0
- package/dist/types/import/history.d.ts +40 -0
- package/dist/types/import/history.d.ts.map +1 -0
- package/dist/types/import/index.d.ts +17 -0
- package/dist/types/import/index.d.ts.map +1 -0
- package/dist/types/import/providers/aider.d.ts +2 -0
- package/dist/types/import/providers/aider.d.ts.map +1 -0
- package/dist/types/import/providers/claude-code.d.ts +2 -0
- package/dist/types/import/providers/claude-code.d.ts.map +1 -0
- package/dist/types/import/providers/cline.d.ts +2 -0
- package/dist/types/import/providers/cline.d.ts.map +1 -0
- package/dist/types/import/providers/codex.d.ts +2 -0
- package/dist/types/import/providers/codex.d.ts.map +1 -0
- package/dist/types/import/providers/continue.d.ts +2 -0
- package/dist/types/import/providers/continue.d.ts.map +1 -0
- package/dist/types/import/providers/index.d.ts +19 -0
- package/dist/types/import/providers/index.d.ts.map +1 -0
- package/dist/types/import/providers/opencode.d.ts +2 -0
- package/dist/types/import/providers/opencode.d.ts.map +1 -0
- package/dist/types/import/providers/pi.d.ts +2 -0
- package/dist/types/import/providers/pi.d.ts.map +1 -0
- package/dist/types/import/types.d.ts +82 -0
- package/dist/types/import/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instruction-detect.d.ts +66 -0
- package/dist/types/instruction-detect.d.ts.map +1 -0
- package/dist/types/log.d.ts +9 -0
- package/dist/types/log.d.ts.map +1 -1
- package/dist/types/ltm.d.ts +40 -0
- package/dist/types/ltm.d.ts.map +1 -1
- package/dist/types/pattern-extract.d.ts +7 -0
- package/dist/types/pattern-extract.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +1 -1
- package/dist/types/prompt.d.ts.map +1 -1
- package/dist/types/recall.d.ts.map +1 -1
- package/dist/types/search.d.ts +5 -3
- package/dist/types/search.d.ts.map +1 -1
- package/dist/types/temporal.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +2 -4
- package/src/agents-file.ts +41 -13
- package/src/config.ts +31 -18
- package/src/curator.ts +111 -75
- package/src/data-dir.ts +76 -0
- package/src/db.ts +110 -11
- package/src/distillation.ts +10 -2
- package/src/embedding-vendor.ts +23 -40
- package/src/embedding-worker-types.ts +19 -11
- package/src/embedding-worker.ts +111 -47
- package/src/embedding.ts +196 -171
- package/src/gradient.ts +9 -1
- package/src/import/detect.ts +37 -0
- package/src/import/extract.ts +137 -0
- package/src/import/history.ts +99 -0
- package/src/import/index.ts +45 -0
- package/src/import/providers/aider.ts +207 -0
- package/src/import/providers/claude-code.ts +339 -0
- package/src/import/providers/cline.ts +324 -0
- package/src/import/providers/codex.ts +369 -0
- package/src/import/providers/continue.ts +304 -0
- package/src/import/providers/index.ts +32 -0
- package/src/import/providers/opencode.ts +272 -0
- package/src/import/providers/pi.ts +332 -0
- package/src/import/types.ts +91 -0
- package/src/index.ts +5 -0
- package/src/instruction-detect.ts +275 -0
- package/src/log.ts +91 -3
- package/src/ltm.ts +316 -3
- package/src/pattern-extract.ts +41 -0
- package/src/prompt.ts +7 -1
- package/src/recall.ts +43 -5
- package/src/search.ts +7 -5
- package/src/temporal.ts +8 -6
- 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/types/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. */
|
package/dist/types/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAUH,4EAA4E;AAC5E,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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/types/ltm.d.ts
CHANGED
|
@@ -27,6 +27,23 @@ 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[];
|
|
31
48
|
/**
|
|
32
49
|
* Build a relevance-ranked, budget-capped list of knowledge entries for injection
|
|
@@ -50,6 +67,8 @@ export declare function forProject(projectPath: string, includeCross?: boolean):
|
|
|
50
67
|
*/
|
|
51
68
|
export declare function forSession(projectPath: string, sessionID: string | undefined, maxTokens: number): KnowledgeEntry[];
|
|
52
69
|
export declare function all(): KnowledgeEntry[];
|
|
70
|
+
/** Return all cross-project and global (user-level) knowledge entries. */
|
|
71
|
+
export declare function crossProject(): KnowledgeEntry[];
|
|
53
72
|
export declare function search(input: {
|
|
54
73
|
query: string;
|
|
55
74
|
projectPath?: string;
|
|
@@ -135,4 +154,25 @@ export type IntegrityIssue = {
|
|
|
135
154
|
* 2. Content quality — empty content, oversized entries
|
|
136
155
|
*/
|
|
137
156
|
export declare function check(projectPath: string): IntegrityIssue[];
|
|
157
|
+
export type DedupCluster = {
|
|
158
|
+
surviving: {
|
|
159
|
+
id: string;
|
|
160
|
+
title: string;
|
|
161
|
+
};
|
|
162
|
+
merged: Array<{
|
|
163
|
+
id: string;
|
|
164
|
+
title: string;
|
|
165
|
+
}>;
|
|
166
|
+
};
|
|
167
|
+
export type DedupResult = {
|
|
168
|
+
clusters: DedupCluster[];
|
|
169
|
+
totalRemoved: number;
|
|
170
|
+
};
|
|
171
|
+
export declare function deduplicate(projectPath: string, opts?: {
|
|
172
|
+
dryRun?: boolean;
|
|
173
|
+
}): Promise<DedupResult>;
|
|
174
|
+
/** Deduplicate global (cross-project) entries that have no project_id. */
|
|
175
|
+
export declare function deduplicateGlobal(opts?: {
|
|
176
|
+
dryRun?: boolean;
|
|
177
|
+
}): Promise<DedupResult>;
|
|
138
178
|
//# sourceMappingURL=ltm.d.ts.map
|
package/dist/types/ltm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ltm.d.ts","sourceRoot":"","sources":["../../src/ltm.ts"],"names":[],"mappings":"A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,CAAC;IAChB,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,EAAE,CA8E3D;AAMD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,MAAM,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AA6JF,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,WAAW,CAAC,CAGtB;AAED,0EAA0E;AAC1E,wBAAsB,iBAAiB,CACrC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,WAAW,CAAC,CAUtB"}
|
|
@@ -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
|
|
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"}
|
package/dist/types/prompt.d.ts
CHANGED
|
@@ -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,MA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AAM,CAAC;AAElC,MAAM,MAAM,YAAY,GACpB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,oBAAoB,CAAA;CAAE,GACvD;IACE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,GAAG,CAAC,oBAAoB,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IAAE,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"}
|
package/dist/types/search.d.ts
CHANGED
|
@@ -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 = Σ(
|
|
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)
|
|
114
|
-
* for deduplication
|
|
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,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AAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,EAAE,EACpB,GAAG,GAAE,MAAmB,GACvB,MAAM,CAoBR;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAWrE;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAWR;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAWR;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,CA0Ed"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -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
|
-
* -
|
|
167
|
+
* - Gateway: direct `fetch()` to provider APIs
|
|
168
168
|
*/
|
|
169
169
|
export interface LLMClient {
|
|
170
170
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loreai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"description": "Shared memory engine for Lore — three-tier storage, distillation, gradient context management",
|
|
@@ -24,14 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@huggingface/hub": "2.11.0",
|
|
27
|
+
"@huggingface/transformers": "^3.7.1",
|
|
27
28
|
"micromark": "^4.0.0",
|
|
28
29
|
"remark": "^15.0.1",
|
|
29
30
|
"uuidv7": "^1.1.0",
|
|
30
31
|
"zod": "^4.3.6"
|
|
31
32
|
},
|
|
32
|
-
"optionalDependencies": {
|
|
33
|
-
"fastembed": "^2.1.0"
|
|
34
|
-
},
|
|
35
33
|
"devDependencies": {
|
|
36
34
|
"@types/mdast": "^4.0.4"
|
|
37
35
|
},
|
package/src/agents-file.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
|
|
12
12
|
import { dirname, join } from "path";
|
|
13
|
-
import { db } from "./db";
|
|
13
|
+
import { db, ensureProject } from "./db";
|
|
14
14
|
import * as ltm from "./ltm";
|
|
15
15
|
import { serialize, inline, h, ul, liph, strong, t, root, unescapeMarkdown } from "./markdown";
|
|
16
16
|
|
|
@@ -425,21 +425,35 @@ function _importEntries(
|
|
|
425
425
|
ltm.update(entry.id, { content: entry.content });
|
|
426
426
|
}
|
|
427
427
|
} else {
|
|
428
|
-
// Unknown UUID — entry came from another machine
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
id
|
|
437
|
-
|
|
428
|
+
// Unknown UUID — entry came from another machine.
|
|
429
|
+
// Check for a fuzzy title match before creating — prevents duplicates
|
|
430
|
+
// when two machines independently create entries for the same concept
|
|
431
|
+
// with different UUIDs but similar titles.
|
|
432
|
+
const pid = ensureProject(projectPath);
|
|
433
|
+
const fuzzyMatch = ltm.findFuzzyDuplicate({ title: entry.title, projectId: pid });
|
|
434
|
+
if (fuzzyMatch) {
|
|
435
|
+
// Title-similar entry exists locally — update it, discard foreign UUID
|
|
436
|
+
if (fuzzyMatch.title !== entry.title || ltm.get(fuzzyMatch.id)?.content !== entry.content) {
|
|
437
|
+
ltm.update(fuzzyMatch.id, { content: entry.content });
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
ltm.create({
|
|
441
|
+
projectPath,
|
|
442
|
+
category: entry.category,
|
|
443
|
+
title: entry.title,
|
|
444
|
+
content: entry.content,
|
|
445
|
+
scope: "project",
|
|
446
|
+
crossProject: false,
|
|
447
|
+
id: entry.id,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
438
450
|
}
|
|
439
451
|
} else {
|
|
440
452
|
// Hand-written entry — create with a new UUIDv7
|
|
441
|
-
// Check for a near-duplicate by title to avoid double-import on re-runs
|
|
442
|
-
|
|
453
|
+
// Check for a near-duplicate by title to avoid double-import on re-runs.
|
|
454
|
+
// Scope to project-only entries (false) — cross-project entries from other
|
|
455
|
+
// projects should not silently suppress a hand-written entry in this project.
|
|
456
|
+
const existing = ltm.forProject(projectPath, false);
|
|
443
457
|
const titleMatch = existing.find(
|
|
444
458
|
(e) => e.title.toLowerCase() === entry.title.toLowerCase(),
|
|
445
459
|
);
|
|
@@ -559,6 +573,10 @@ export function shouldImportLoreFile(projectPath: string): boolean {
|
|
|
559
573
|
/**
|
|
560
574
|
* Import knowledge entries from `.lore.md` into the local DB.
|
|
561
575
|
* Parses the full file content (no section markers to split on).
|
|
576
|
+
*
|
|
577
|
+
* After a successful import, updates the file cache so that
|
|
578
|
+
* `shouldImportLoreFile()` fast-paths on the next check — the file
|
|
579
|
+
* content hasn't changed, only the DB was updated to match it.
|
|
562
580
|
*/
|
|
563
581
|
export function importLoreFile(projectPath: string): void {
|
|
564
582
|
const fp = join(projectPath, LORE_FILE);
|
|
@@ -569,4 +587,14 @@ export function importLoreFile(projectPath: string): void {
|
|
|
569
587
|
if (!fileEntries.length) return;
|
|
570
588
|
|
|
571
589
|
_importEntries(fileEntries, projectPath);
|
|
590
|
+
|
|
591
|
+
// Update cache: DB now matches the file, so shouldImportLoreFile() can
|
|
592
|
+
// fast-path on the next check. We re-stat after import because the file
|
|
593
|
+
// hasn't changed — only the DB was updated to match it.
|
|
594
|
+
try {
|
|
595
|
+
const { mtimeMs } = statSync(fp);
|
|
596
|
+
setCache(fp, { mtimeMs, hash: hashSection(fileContent) });
|
|
597
|
+
} catch {
|
|
598
|
+
// stat failure is non-fatal — worst case we re-import next time
|
|
599
|
+
}
|
|
572
600
|
}
|
package/src/config.ts
CHANGED
|
@@ -135,15 +135,25 @@ export const LoreConfig = z.object({
|
|
|
135
135
|
.default({ title: 6.0, content: 2.0, category: 3.0 }),
|
|
136
136
|
/** Max results per source in recall tool before fusion. Default: 10. */
|
|
137
137
|
recallLimit: z.number().min(1).max(50).default(10),
|
|
138
|
-
/** Enable LLM-based query expansion for the recall tool. Default:
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
|
|
138
|
+
/** Enable LLM-based query expansion for the recall tool. Default: true.
|
|
139
|
+
* The configured model generates 2–3 alternative query phrasings before
|
|
140
|
+
* search, improving recall for ambiguous queries. Guarded by a 3-second
|
|
141
|
+
* timeout — if expansion fails or times out, the original query is used. */
|
|
142
|
+
queryExpansion: z.boolean().default(true),
|
|
143
|
+
/** RRF weight multiplier for vector search lists. Applied when the query
|
|
144
|
+
* has >= `vectorBoostMinTerms` meaningful terms (after stopword removal).
|
|
145
|
+
* Boosts semantic/vector results relative to keyword-based BM25 lists.
|
|
146
|
+
* Default: 1.5. Set to 1.0 to disable. */
|
|
147
|
+
vectorBoostWeight: z.number().min(1).max(5).default(1.5),
|
|
148
|
+
/** Minimum meaningful query terms (after stopword removal) to activate
|
|
149
|
+
* vector boost. Short keyword queries (1-2 terms) are left unweighted
|
|
150
|
+
* since BM25 excels there. Default: 3. */
|
|
151
|
+
vectorBoostMinTerms: z.number().min(1).max(10).default(3),
|
|
142
152
|
/** Vector embedding search.
|
|
143
153
|
* Supports multiple providers:
|
|
144
|
-
* - "local" (default):
|
|
145
|
-
*
|
|
146
|
-
* cached
|
|
154
|
+
* - "local" (default): @huggingface/transformers + nomic-embed-text-v1.5, no API key needed.
|
|
155
|
+
* 768 dims (Matryoshka-capable: 64–768). Model downloaded on first use (~137MB INT8),
|
|
156
|
+
* cached locally. Uses task instruction prefixes (search_document: / search_query:).
|
|
147
157
|
* - "voyage": Voyage AI (VOYAGE_API_KEY, voyage-code-3, 1024 dims)
|
|
148
158
|
* - "openai": OpenAI (OPENAI_API_KEY, text-embedding-3-small, 1536 dims)
|
|
149
159
|
* Set enabled: false to explicitly disable even with a provider available. */
|
|
@@ -153,20 +163,21 @@ export const LoreConfig = z.object({
|
|
|
153
163
|
* Set to false to explicitly disable. */
|
|
154
164
|
enabled: z.boolean().default(true),
|
|
155
165
|
/** Embedding provider. Default: "local".
|
|
156
|
-
* - "local":
|
|
166
|
+
* - "local": @huggingface/transformers, no API key (default model: nomic-embed-text-v1.5, 768 dims)
|
|
157
167
|
* - "voyage": VOYAGE_API_KEY (default model: voyage-code-3, 1024 dims)
|
|
158
168
|
* - "openai": OPENAI_API_KEY (default model: text-embedding-3-small, 1536 dims) */
|
|
159
169
|
provider: z.enum(["local", "voyage", "openai"]).default("local"),
|
|
160
170
|
/** Model ID for the embedding provider. Default depends on provider. */
|
|
161
|
-
model: z.string().default("
|
|
162
|
-
/** Embedding dimensions. Default:
|
|
163
|
-
|
|
171
|
+
model: z.string().default("nomic-ai/nomic-embed-text-v1.5"),
|
|
172
|
+
/** Embedding dimensions. Default: 768 (local) / 1024 (voyage) / 1536 (openai).
|
|
173
|
+
* For the local Nomic v1.5 model, supports Matryoshka dimensions: 64, 128, 256, 512, 768. */
|
|
174
|
+
dimensions: z.number().min(64).max(2048).default(768),
|
|
164
175
|
})
|
|
165
176
|
.default({
|
|
166
177
|
enabled: true,
|
|
167
178
|
provider: "local",
|
|
168
|
-
model: "
|
|
169
|
-
dimensions:
|
|
179
|
+
model: "nomic-ai/nomic-embed-text-v1.5",
|
|
180
|
+
dimensions: 768,
|
|
170
181
|
}),
|
|
171
182
|
/** Recall output formatting — controls how search results are presented to the agent. */
|
|
172
183
|
recall: z
|
|
@@ -186,8 +197,10 @@ export const LoreConfig = z.object({
|
|
|
186
197
|
.default({
|
|
187
198
|
ftsWeights: { title: 6.0, content: 2.0, category: 3.0 },
|
|
188
199
|
recallLimit: 10,
|
|
189
|
-
queryExpansion:
|
|
190
|
-
|
|
200
|
+
queryExpansion: true,
|
|
201
|
+
vectorBoostWeight: 1.5,
|
|
202
|
+
vectorBoostMinTerms: 3,
|
|
203
|
+
embeddings: { enabled: true, provider: "local" as const, model: "nomic-ai/nomic-embed-text-v1.5", dimensions: 768 },
|
|
191
204
|
recall: { charBudget: 8000, relevanceFloor: 0.15, maxResults: 15 },
|
|
192
205
|
}),
|
|
193
206
|
cache: z
|
|
@@ -207,9 +220,9 @@ export const LoreConfig = z.object({
|
|
|
207
220
|
.object({
|
|
208
221
|
/** Enable cache warming. Default: true. */
|
|
209
222
|
enabled: z.boolean().default(true),
|
|
210
|
-
/** Override the
|
|
211
|
-
* skipped. Default: auto-derived from
|
|
212
|
-
* (~0.
|
|
223
|
+
/** Override the return probability threshold below which warming is
|
|
224
|
+
* skipped. Default: auto-derived from corrected cost ratio
|
|
225
|
+
* read/(write-read) (~0.087 for 5m TTL, ~0.042 for 1h TTL). */
|
|
213
226
|
minReturnProbability: z.number().min(0).max(1).optional(),
|
|
214
227
|
})
|
|
215
228
|
.default({ enabled: true }),
|