true-mem 1.0.11 → 1.0.13
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 +9 -0
- package/dist/adapters/opencode/index.d.ts.map +1 -1
- package/dist/extraction/queue.d.ts +4 -0
- package/dist/extraction/queue.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -95
- package/dist/memory/classifier.d.ts +1 -1
- package/dist/memory/classifier.d.ts.map +1 -1
- package/dist/storage/database.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,6 +115,15 @@ Add to your `~/.config/opencode/opencode.jsonc`:
|
|
|
115
115
|
|
|
116
116
|
OpenCode will automatically download the plugin from npm.
|
|
117
117
|
|
|
118
|
+
After restarting OpenCode, you'll see a toast notification in the top-right corner confirming the plugin is loaded:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
True-Mem vX.X.X
|
|
122
|
+
Memory active.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This confirms True-Mem is installed and working correctly.
|
|
126
|
+
|
|
118
127
|
---
|
|
119
128
|
|
|
120
129
|
## Usage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAwB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAA4D,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAwB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAA4D,MAAM,gBAAgB,CAAC;AA2F/G;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,EAChB,eAAe,GAAE,OAAO,CAAC,cAAc,CAAM,GAC5C,OAAO,CAAC,KAAK,CAAC,CA6KhB;AA2lBD,eAAe,sBAAsB,CAAC"}
|
|
@@ -32,4 +32,8 @@ export declare class ExtractionQueue {
|
|
|
32
32
|
get processing(): boolean;
|
|
33
33
|
}
|
|
34
34
|
export declare function getExtractionQueue(): ExtractionQueue;
|
|
35
|
+
/**
|
|
36
|
+
* Reset the extraction queue singleton (for testing/cleanup)
|
|
37
|
+
*/
|
|
38
|
+
export declare function resetExtractionQueue(): void;
|
|
35
39
|
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/extraction/queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,YAAY,CAAkB;IAEtC;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAM7B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB;;OAEG;YACW,UAAU;IA2BxB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;CACF;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CAMpD"}
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/extraction/queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,YAAY,CAAkB;IAEtC;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAM7B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAQpB;;OAEG;YACW,UAAU;IA2BxB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;CACF;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CAMpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,qBAAqB,CAAC;AAwBzD,QAAA,MAAM,UAAU,EAAE,MAiHjB,CAAC;AAEF,eAAe,UAAU,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,38 @@ var init_logger = __esm(() => {
|
|
|
38
38
|
LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
// src/utils/version.ts
|
|
42
|
+
import fs from "fs";
|
|
43
|
+
import path from "path";
|
|
44
|
+
import { fileURLToPath } from "url";
|
|
45
|
+
function findPackageJsonUp(startDir) {
|
|
46
|
+
let currentDir = startDir;
|
|
47
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
48
|
+
const pkgPath = path.join(currentDir, "package.json");
|
|
49
|
+
if (fs.existsSync(pkgPath)) {
|
|
50
|
+
return pkgPath;
|
|
51
|
+
}
|
|
52
|
+
currentDir = path.dirname(currentDir);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function getVersion() {
|
|
57
|
+
try {
|
|
58
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
const pkgPath = findPackageJsonUp(currentDir);
|
|
60
|
+
if (pkgPath) {
|
|
61
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
62
|
+
const pkg = JSON.parse(content);
|
|
63
|
+
return pkg.version ?? "unknown";
|
|
64
|
+
}
|
|
65
|
+
return "unknown";
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error("[True-Mem] Version detection error:", error);
|
|
68
|
+
return "unknown";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var init_version = () => {};
|
|
72
|
+
|
|
41
73
|
// src/config.ts
|
|
42
74
|
var DEFAULT_SWEEP_CONFIG, DEFAULT_SCORING_WEIGHTS, DEFAULT_OPENCODE_CONFIG, DEFAULT_CONFIG;
|
|
43
75
|
var init_config = __esm(() => {
|
|
@@ -530,6 +562,39 @@ class MemoryDatabase {
|
|
|
530
562
|
async createMemory(store, classification, summary, sourceEventIds, features = {}) {
|
|
531
563
|
this.ensureInit();
|
|
532
564
|
const contentHash = generateContentHash(summary);
|
|
565
|
+
const similarMemories = await this.vectorSearch(summary, features.projectScope ?? undefined, 1);
|
|
566
|
+
let reconsolidationAction = null;
|
|
567
|
+
if (similarMemories.length > 0) {
|
|
568
|
+
const existingMemory = similarMemories[0];
|
|
569
|
+
if (existingMemory) {
|
|
570
|
+
const similarity = this.jaccardSimilarity(summary, existingMemory.summary);
|
|
571
|
+
if (isRelevant(similarity)) {
|
|
572
|
+
const newMemoryData = {
|
|
573
|
+
store,
|
|
574
|
+
classification,
|
|
575
|
+
summary,
|
|
576
|
+
sourceEventIds,
|
|
577
|
+
projectScope: features.projectScope ?? undefined,
|
|
578
|
+
sessionId: features.sessionId
|
|
579
|
+
};
|
|
580
|
+
const action = await handleReconsolidation(this, newMemoryData, existingMemory, similarity);
|
|
581
|
+
switch (action.type) {
|
|
582
|
+
case "duplicate":
|
|
583
|
+
const existingMemoryRow = this.db.prepare(`SELECT * FROM memory_units WHERE id = ?`).get(action.updatedMemory.id);
|
|
584
|
+
if (existingMemoryRow) {
|
|
585
|
+
this.incrementFrequency(existingMemoryRow.id);
|
|
586
|
+
}
|
|
587
|
+
return action.updatedMemory;
|
|
588
|
+
case "conflict":
|
|
589
|
+
reconsolidationAction = { type: "conflict", existingMemoryId: action.existingMemoryId };
|
|
590
|
+
break;
|
|
591
|
+
case "complement":
|
|
592
|
+
reconsolidationAction = { type: "complement" };
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
533
598
|
this.db.exec("BEGIN TRANSACTION");
|
|
534
599
|
try {
|
|
535
600
|
const exactDuplicate = this.db.prepare(`SELECT * FROM memory_units WHERE content_hash = ? AND status = 'active' LIMIT 1`).get(contentHash);
|
|
@@ -538,35 +603,13 @@ class MemoryDatabase {
|
|
|
538
603
|
this.incrementFrequency(exactDuplicate.id);
|
|
539
604
|
const updatedMemory = this.getMemory(exactDuplicate.id);
|
|
540
605
|
this.db.exec("COMMIT");
|
|
606
|
+
if (!updatedMemory) {
|
|
607
|
+
throw new Error(`Memory ${exactDuplicate.id} not found after increment - likely deleted by another process`);
|
|
608
|
+
}
|
|
541
609
|
return updatedMemory;
|
|
542
610
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const existingMemory = similarMemories[0];
|
|
546
|
-
if (existingMemory) {
|
|
547
|
-
const similarity = this.jaccardSimilarity(summary, existingMemory.summary);
|
|
548
|
-
if (isRelevant(similarity)) {
|
|
549
|
-
const newMemoryData = {
|
|
550
|
-
store,
|
|
551
|
-
classification,
|
|
552
|
-
summary,
|
|
553
|
-
sourceEventIds,
|
|
554
|
-
projectScope: features.projectScope ?? undefined,
|
|
555
|
-
sessionId: features.sessionId
|
|
556
|
-
};
|
|
557
|
-
const action = await handleReconsolidation(this, newMemoryData, existingMemory, similarity);
|
|
558
|
-
switch (action.type) {
|
|
559
|
-
case "duplicate":
|
|
560
|
-
this.db.exec("COMMIT");
|
|
561
|
-
return action.updatedMemory;
|
|
562
|
-
case "conflict":
|
|
563
|
-
this.db.prepare(`DELETE FROM memory_units WHERE id = ?`).run(action.existingMemoryId);
|
|
564
|
-
break;
|
|
565
|
-
case "complement":
|
|
566
|
-
break;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}
|
|
611
|
+
if (reconsolidationAction?.type === "conflict" && reconsolidationAction.existingMemoryId) {
|
|
612
|
+
this.db.prepare(`DELETE FROM memory_units WHERE id = ?`).run(reconsolidationAction.existingMemoryId);
|
|
570
613
|
}
|
|
571
614
|
const now = new Date;
|
|
572
615
|
const decayRate = store === "stm" ? this.config.stmDecayRate : this.config.ltmDecayRate;
|
|
@@ -665,6 +708,9 @@ class MemoryDatabase {
|
|
|
665
708
|
async vectorSearch(queryTextOrEmbedding, currentProject, limit = 10) {
|
|
666
709
|
this.ensureInit();
|
|
667
710
|
const queryText = typeof queryTextOrEmbedding === "string" ? queryTextOrEmbedding : queryTextOrEmbedding.length === 0 ? "" : "";
|
|
711
|
+
if (queryText.trim().length === 0) {
|
|
712
|
+
return [];
|
|
713
|
+
}
|
|
668
714
|
const query = `
|
|
669
715
|
SELECT * FROM memory_units
|
|
670
716
|
WHERE status = 'active'
|
|
@@ -1183,14 +1229,6 @@ function inferClassification(text) {
|
|
|
1183
1229
|
}
|
|
1184
1230
|
function classifyWithExplicitIntent(text, signals) {
|
|
1185
1231
|
const hasExplicitRemember = signals.some((s) => s.type === "explicit_remember");
|
|
1186
|
-
if (hasExplicitRemember) {
|
|
1187
|
-
log("Debug: Explicit intent signal found, isolating sentence...");
|
|
1188
|
-
}
|
|
1189
|
-
if (!hasExplicitRemember) {
|
|
1190
|
-
const classification = inferClassification(text);
|
|
1191
|
-
const confidence = classification ? calculateClassificationScore(text, classification) : 0;
|
|
1192
|
-
return { classification, confidence, isolatedContent: text };
|
|
1193
|
-
}
|
|
1194
1232
|
const markerPatterns = [
|
|
1195
1233
|
/\bricordati(?:\s+\w+){0,5}?\s+che\b:?\s*/gi,
|
|
1196
1234
|
/\bricordati\b:?\s*/gi,
|
|
@@ -1226,12 +1264,15 @@ function classifyWithExplicitIntent(text, signals) {
|
|
|
1226
1264
|
isolatedContent = text.substring(firstMatch.index + firstMatch.match[0].length).trim();
|
|
1227
1265
|
log("Debug: Extracted content after first explicit marker:", isolatedContent);
|
|
1228
1266
|
}
|
|
1229
|
-
if (!isolatedContent) {
|
|
1230
|
-
log("Debug: No explicit marker found, falling back to normal classification");
|
|
1267
|
+
if (!isolatedContent && !hasExplicitRemember) {
|
|
1268
|
+
log("Debug: No explicit marker or signal found, falling back to normal classification");
|
|
1231
1269
|
const classification = inferClassification(text);
|
|
1232
1270
|
const confidence = classification ? calculateClassificationScore(text, classification) : 0;
|
|
1233
1271
|
return { classification, confidence, isolatedContent: text };
|
|
1234
1272
|
}
|
|
1273
|
+
if (!isolatedContent) {
|
|
1274
|
+
isolatedContent = text;
|
|
1275
|
+
}
|
|
1235
1276
|
log("Debug: Isolated content for classification:", isolatedContent);
|
|
1236
1277
|
let bestClassification = null;
|
|
1237
1278
|
let bestScore = 0;
|
|
@@ -2570,7 +2611,6 @@ function canExtract() {
|
|
|
2570
2611
|
log(`Skipping extraction: too soon after last extraction (${now - lastExtractionTime}ms < ${MIN_EXTRACTION_INTERVAL}ms)`);
|
|
2571
2612
|
return false;
|
|
2572
2613
|
}
|
|
2573
|
-
lastExtractionTime = now;
|
|
2574
2614
|
return true;
|
|
2575
2615
|
}
|
|
2576
2616
|
function getSessionIdFromEvent(properties) {
|
|
@@ -2610,18 +2650,21 @@ async function createTrueMemoryPlugin(ctx, configOverrides = {}) {
|
|
|
2610
2650
|
const db = await createMemoryDatabase(config);
|
|
2611
2651
|
log("Database initialized");
|
|
2612
2652
|
registerShutdownHandler("database", () => db.close());
|
|
2613
|
-
const
|
|
2653
|
+
const isValidPath = (path2) => {
|
|
2654
|
+
return !!(path2 && path2 !== "/" && path2 !== "\\" && path2.trim().length > 0);
|
|
2655
|
+
};
|
|
2656
|
+
const worktree = isValidPath(ctx.worktree) ? ctx.worktree : isValidPath(ctx.directory) ? ctx.directory : `unknown-project-${Date.now()}`;
|
|
2614
2657
|
const state = {
|
|
2615
2658
|
db,
|
|
2616
2659
|
config,
|
|
2617
2660
|
currentSessionId: null,
|
|
2618
|
-
injectedSessions: new Set,
|
|
2619
2661
|
worktree,
|
|
2620
2662
|
client: ctx.client
|
|
2621
2663
|
};
|
|
2622
2664
|
log(`True-Mem initialized \u2014 worktree=${worktree}`);
|
|
2623
2665
|
const projectName = worktree.split(/[/\\]/).pop() || "Unknown";
|
|
2624
|
-
const
|
|
2666
|
+
const version = getVersion();
|
|
2667
|
+
const startupMessage = `\uD83E\uDDE0 True-Mem: Plugin loaded successfully | v${version} [${BUILD_TIME}] | Mode: Jaccard Similarity | Project: ${projectName}`;
|
|
2625
2668
|
log(startupMessage);
|
|
2626
2669
|
return {
|
|
2627
2670
|
event: async ({ event }) => {
|
|
@@ -2797,7 +2840,7 @@ async function processSessionIdle(state, sessionId) {
|
|
|
2797
2840
|
const signals = matchAllPatterns(conversationText);
|
|
2798
2841
|
log("Debug: Detected signals:", JSON.stringify(signals));
|
|
2799
2842
|
let extractionAttempted = false;
|
|
2800
|
-
let
|
|
2843
|
+
let messagesProcessed = 0;
|
|
2801
2844
|
if (signals.length > 0) {
|
|
2802
2845
|
extractionAttempted = true;
|
|
2803
2846
|
try {
|
|
@@ -2839,6 +2882,7 @@ async function processSessionIdle(state, sessionId) {
|
|
|
2839
2882
|
confidence
|
|
2840
2883
|
});
|
|
2841
2884
|
log(`Stored ${classification} memory in ${store.toUpperCase()} (confidence: ${confidence.toFixed(2)}, role: ${role}, reason: ${result.reason})`);
|
|
2885
|
+
messagesProcessed++;
|
|
2842
2886
|
} else {
|
|
2843
2887
|
log(`Skipped ${classification} memory: ${result.reason}`);
|
|
2844
2888
|
}
|
|
@@ -2846,15 +2890,14 @@ async function processSessionIdle(state, sessionId) {
|
|
|
2846
2890
|
log(`Skipped ${classification} memory: ${validationReason}`);
|
|
2847
2891
|
}
|
|
2848
2892
|
}
|
|
2849
|
-
extractionSucceeded = true;
|
|
2850
2893
|
} catch (error) {
|
|
2851
2894
|
log(`Extraction failed with critical error: ${error}`);
|
|
2895
|
+
state.db.updateMessageWatermark(effectiveSessionId, messages.length);
|
|
2852
2896
|
return;
|
|
2853
2897
|
}
|
|
2854
2898
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
}
|
|
2899
|
+
state.db.updateMessageWatermark(effectiveSessionId, messages.length);
|
|
2900
|
+
lastExtractionTime = Date.now();
|
|
2858
2901
|
}
|
|
2859
2902
|
async function handleSessionEnd(state, eventType, sessionId) {
|
|
2860
2903
|
const effectiveSessionId = sessionId ?? state.currentSessionId;
|
|
@@ -3077,42 +3120,13 @@ var init_opencode = __esm(() => {
|
|
|
3077
3120
|
init_queue();
|
|
3078
3121
|
init_shutdown();
|
|
3079
3122
|
init_injection();
|
|
3123
|
+
init_version();
|
|
3080
3124
|
opencode_default = createTrueMemoryPlugin;
|
|
3081
3125
|
});
|
|
3082
3126
|
|
|
3083
3127
|
// src/index.ts
|
|
3084
3128
|
init_logger();
|
|
3085
|
-
|
|
3086
|
-
// src/utils/version.ts
|
|
3087
|
-
import fs from "fs";
|
|
3088
|
-
import path from "path";
|
|
3089
|
-
import { fileURLToPath } from "url";
|
|
3090
|
-
function findPackageJsonUp(startDir) {
|
|
3091
|
-
let currentDir = startDir;
|
|
3092
|
-
while (currentDir !== path.dirname(currentDir)) {
|
|
3093
|
-
const pkgPath = path.join(currentDir, "package.json");
|
|
3094
|
-
if (fs.existsSync(pkgPath)) {
|
|
3095
|
-
return pkgPath;
|
|
3096
|
-
}
|
|
3097
|
-
currentDir = path.dirname(currentDir);
|
|
3098
|
-
}
|
|
3099
|
-
return null;
|
|
3100
|
-
}
|
|
3101
|
-
function getVersion() {
|
|
3102
|
-
try {
|
|
3103
|
-
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
3104
|
-
const pkgPath = findPackageJsonUp(currentDir);
|
|
3105
|
-
if (pkgPath) {
|
|
3106
|
-
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
3107
|
-
const pkg = JSON.parse(content);
|
|
3108
|
-
return pkg.version ?? "unknown";
|
|
3109
|
-
}
|
|
3110
|
-
return "unknown";
|
|
3111
|
-
} catch (error) {
|
|
3112
|
-
console.error("[True-Mem] Version detection error:", error);
|
|
3113
|
-
return "unknown";
|
|
3114
|
-
}
|
|
3115
|
-
}
|
|
3129
|
+
init_version();
|
|
3116
3130
|
|
|
3117
3131
|
// src/utils/toast.ts
|
|
3118
3132
|
function showToast(ctx, title, message, variant = "info", duration = 3000) {
|
|
@@ -3126,7 +3140,8 @@ var state = {
|
|
|
3126
3140
|
initialized: false,
|
|
3127
3141
|
initPromise: null,
|
|
3128
3142
|
ctx: null,
|
|
3129
|
-
realHooks: null
|
|
3143
|
+
realHooks: null,
|
|
3144
|
+
initializingLock: false
|
|
3130
3145
|
};
|
|
3131
3146
|
var hasShownToast = false;
|
|
3132
3147
|
var TrueMemory = async (ctx) => {
|
|
@@ -3138,23 +3153,29 @@ var TrueMemory = async (ctx) => {
|
|
|
3138
3153
|
showToast(ctx, `True-Mem v${version}`, "Memory active.", "info", 4000);
|
|
3139
3154
|
}, 2000);
|
|
3140
3155
|
}
|
|
3141
|
-
state.
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
log("
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3156
|
+
if (!state.initializingLock) {
|
|
3157
|
+
state.initializingLock = true;
|
|
3158
|
+
state.initPromise = (async () => {
|
|
3159
|
+
log("Phase 1: Initializing plugin (lightweight)...");
|
|
3160
|
+
if (!state.ctx) {
|
|
3161
|
+
log("ERROR: No ctx available");
|
|
3162
|
+
state.initializingLock = false;
|
|
3163
|
+
return;
|
|
3164
|
+
}
|
|
3165
|
+
try {
|
|
3166
|
+
const { createTrueMemoryPlugin: createTrueMemoryPlugin2 } = await Promise.resolve().then(() => (init_opencode(), exports_opencode));
|
|
3167
|
+
state.realHooks = await createTrueMemoryPlugin2(state.ctx);
|
|
3168
|
+
state.initialized = true;
|
|
3169
|
+
log("Phase 1 complete - Plugin ready");
|
|
3170
|
+
} catch (error) {
|
|
3171
|
+
log(`Init failed: ${error}`);
|
|
3172
|
+
state.initPromise = null;
|
|
3173
|
+
state.realHooks = null;
|
|
3174
|
+
} finally {
|
|
3175
|
+
state.initializingLock = false;
|
|
3176
|
+
}
|
|
3177
|
+
})();
|
|
3178
|
+
}
|
|
3158
3179
|
log("True-Mem: Plugin registered (immediate init mode)");
|
|
3159
3180
|
return {
|
|
3160
3181
|
event: async ({ event }) => {
|
|
@@ -31,7 +31,7 @@ export declare function shouldStoreMemory(text: string, classification: string,
|
|
|
31
31
|
export declare function inferClassification(text: string): string | null;
|
|
32
32
|
/**
|
|
33
33
|
* Classify content with explicit intent detection.
|
|
34
|
-
* If explicit_remember signal is present, isolate the sentence and classify it.
|
|
34
|
+
* If explicit_remember signal is present OR marker pattern matches, isolate the sentence and classify it.
|
|
35
35
|
*/
|
|
36
36
|
export declare function classifyWithExplicitIntent(text: string, signals: any[]): {
|
|
37
37
|
classification: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/memory/classifier.ts"],"names":[],"mappings":"AA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