@loreai/core 0.21.0 → 0.22.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/README.md +1 -1
- package/dist/bun/db.d.ts +3 -2
- package/dist/bun/db.d.ts.map +1 -1
- package/dist/bun/index.js +32 -9
- package/dist/bun/index.js.map +2 -2
- package/dist/bun/ltm.d.ts.map +1 -1
- package/dist/bun/prompt.d.ts +1 -1
- package/dist/bun/prompt.d.ts.map +1 -1
- package/dist/node/db.d.ts +3 -2
- package/dist/node/db.d.ts.map +1 -1
- package/dist/node/index.js +32 -9
- package/dist/node/index.js.map +2 -2
- package/dist/node/ltm.d.ts.map +1 -1
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.d.ts.map +1 -1
- package/dist/types/db.d.ts +3 -2
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/ltm.d.ts.map +1 -1
- package/dist/types/prompt.d.ts +1 -1
- package/dist/types/prompt.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/db.ts +14 -13
- package/src/ltm.ts +23 -1
- package/src/prompt.ts +13 -2
package/README.md
CHANGED
package/dist/bun/db.d.ts
CHANGED
|
@@ -74,8 +74,9 @@ export declare function setLastImportAt(projectPath: string, timestamp: number):
|
|
|
74
74
|
*/
|
|
75
75
|
export declare function loadForceMinLayer(sessionID: string): number;
|
|
76
76
|
/**
|
|
77
|
-
* Persist forceMinLayer for a session.
|
|
78
|
-
*
|
|
77
|
+
* Persist forceMinLayer for a session. Resets to 0 when consumed.
|
|
78
|
+
* Uses INSERT OR IGNORE + UPDATE to preserve sibling columns
|
|
79
|
+
* (cost, gradient, tracking) that other writers depend on.
|
|
79
80
|
*/
|
|
80
81
|
export declare function saveForceMinLayer(sessionID: string, layer: number): void;
|
|
81
82
|
/** Persisted cost snapshot for a session. */
|
package/dist/bun/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","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M,CAMtC"}
|
package/dist/bun/index.js
CHANGED
|
@@ -1033,13 +1033,11 @@ function loadForceMinLayer(sessionID) {
|
|
|
1033
1033
|
return row?.force_min_layer ?? 0;
|
|
1034
1034
|
}
|
|
1035
1035
|
function saveForceMinLayer(sessionID, layer) {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
).run(sessionID, layer, Date.now());
|
|
1042
|
-
}
|
|
1036
|
+
const now = Date.now();
|
|
1037
|
+
db().query(
|
|
1038
|
+
"INSERT OR IGNORE INTO session_state (session_id, force_min_layer, updated_at) VALUES (?, 0, ?)"
|
|
1039
|
+
).run(sessionID, now);
|
|
1040
|
+
db().query("UPDATE session_state SET force_min_layer = ?, updated_at = ? WHERE session_id = ?").run(layer, now, sessionID);
|
|
1043
1041
|
}
|
|
1044
1042
|
function saveSessionCosts(sessionID, costs) {
|
|
1045
1043
|
db().query(
|
|
@@ -12262,7 +12260,9 @@ var CURATOR_SYSTEM = `You are a long-term memory curator. Your job is to extract
|
|
|
12262
12260
|
Focus ONLY on knowledge that helps a coding agent work effectively on THIS codebase:
|
|
12263
12261
|
- Architectural decisions and their rationale (why something was built a certain way)
|
|
12264
12262
|
- Non-obvious implementation patterns and conventions specific to the project
|
|
12265
|
-
- Recurring gotchas, constraints, or traps in the codebase
|
|
12263
|
+
- Recurring gotchas, constraints, or traps in the codebase \u2014 always include WHY the
|
|
12264
|
+
wrong approach seems right, not just the trap and fix. Without this, a future session
|
|
12265
|
+
will re-propose the broken approach because it looks like a reasonable improvement.
|
|
12266
12266
|
- Environment/tooling setup details that affect development
|
|
12267
12267
|
- Important relationships between components that aren't obvious from reading the code
|
|
12268
12268
|
- User preferences and working style specific to how they use this project
|
|
@@ -12281,10 +12281,19 @@ Do NOT extract:
|
|
|
12281
12281
|
- Knowledge about unrelated projects or repositories unless explicitly cross-project
|
|
12282
12282
|
- Restatements of what the code obviously does (e.g. "the auth module handles authentication")
|
|
12283
12283
|
|
|
12284
|
+
INCLUDE THE "WHY" \u2014 decisions and gotchas without rationale get undone:
|
|
12285
|
+
- Every "decision" MUST include the rejected alternative and why it was rejected.
|
|
12286
|
+
Format: "Chose X over Y because Z." Without the rejected option, a future session
|
|
12287
|
+
will re-propose Y because it looks like a reasonable improvement.
|
|
12288
|
+
- Every "gotcha" MUST explain why the wrong approach seems correct, not just the trap
|
|
12289
|
+
and its fix. Format: "Trap: X looks right because [reason]. Fix: Y, because [reason]."
|
|
12290
|
+
- Any standard or rule without its rationale is vulnerable to being optimized away by
|
|
12291
|
+
a session that doesn't know what problem it was solving.
|
|
12292
|
+
|
|
12284
12293
|
BREVITY IS CRITICAL \u2014 each entry must be concise:
|
|
12285
12294
|
- content MUST be under 150 words (~600 characters). Capture ONE specific actionable
|
|
12286
12295
|
insight in 2-3 sentences. Prefer terse technical language.
|
|
12287
|
-
- Each "gotcha": one specific trap + its fix in
|
|
12296
|
+
- Each "gotcha": one specific trap + WHY it looks right + its fix in 2-3 sentences
|
|
12288
12297
|
- Each "architecture": one design decision and its key constraint
|
|
12289
12298
|
- Focus on the actionable insight, not the full story behind it
|
|
12290
12299
|
- If a pattern requires more detail, split into multiple focused entries (each under 150 words)
|
|
@@ -28675,10 +28684,24 @@ async function forSession(projectPath2, sessionID, maxTokens, options) {
|
|
|
28675
28684
|
const allScored = [...scoredProject, ...scoredCross];
|
|
28676
28685
|
allScored.sort((a, b) => b.score - a.score);
|
|
28677
28686
|
const HEADER_OVERHEAD_TOKENS = 15;
|
|
28687
|
+
const ARCH_BUDGET_FRACTION = 0.2;
|
|
28678
28688
|
let used = HEADER_OVERHEAD_TOKENS;
|
|
28679
28689
|
const result = [];
|
|
28690
|
+
const packedIds = /* @__PURE__ */ new Set();
|
|
28691
|
+
const archBudget = Math.floor(maxTokens * ARCH_BUDGET_FRACTION);
|
|
28692
|
+
const archEntries = allScored.filter((s) => s.entry.category === "architecture");
|
|
28693
|
+
archEntries.sort((a, b) => b.score - a.score);
|
|
28694
|
+
for (const { entry } of archEntries) {
|
|
28695
|
+
if (used >= archBudget + HEADER_OVERHEAD_TOKENS) break;
|
|
28696
|
+
const cost = estimateTokens3(entry.title + entry.content) + 10;
|
|
28697
|
+
if (used + cost > maxTokens) continue;
|
|
28698
|
+
result.push(entry);
|
|
28699
|
+
packedIds.add(entry.id);
|
|
28700
|
+
used += cost;
|
|
28701
|
+
}
|
|
28680
28702
|
for (const { entry } of allScored) {
|
|
28681
28703
|
if (used >= maxTokens) break;
|
|
28704
|
+
if (packedIds.has(entry.id)) continue;
|
|
28682
28705
|
const cost = estimateTokens3(entry.title + entry.content) + 10;
|
|
28683
28706
|
if (used + cost > maxTokens) continue;
|
|
28684
28707
|
result.push(entry);
|