@memtensor/memos-local-openclaw-plugin 0.3.6 → 0.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memtensor/memos-local-openclaw-plugin",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "MemOS Local memory plugin for OpenClaw — full-write, hybrid-recall, progressive retrieval",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -3,6 +3,7 @@
3
3
 
4
4
  const { spawnSync } = require("child_process");
5
5
  const path = require("path");
6
+ const fs = require("fs");
6
7
 
7
8
  const RESET = "\x1b[0m";
8
9
  const GREEN = "\x1b[32m";
@@ -10,12 +11,117 @@ const YELLOW = "\x1b[33m";
10
11
  const RED = "\x1b[31m";
11
12
  const CYAN = "\x1b[36m";
12
13
  const BOLD = "\x1b[1m";
14
+ const DIM = "\x1b[2m";
13
15
 
14
16
  function log(msg) { console.log(`${CYAN}[memos-local]${RESET} ${msg}`); }
15
17
  function warn(msg) { console.log(`${YELLOW}[memos-local]${RESET} ${msg}`); }
16
18
  function ok(msg) { console.log(`${GREEN}[memos-local]${RESET} ${msg}`); }
17
19
  function fail(msg) { console.log(`${RED}[memos-local]${RESET} ${msg}`); }
18
20
 
21
+ /* ═══════════════════════════════════════════════════════════
22
+ * Phase 1: Clean up legacy plugin versions
23
+ * ═══════════════════════════════════════════════════════════ */
24
+
25
+ function cleanupLegacy() {
26
+ const home = process.env.HOME || process.env.USERPROFILE || "";
27
+ if (!home) return;
28
+ const ocHome = path.join(home, ".openclaw");
29
+ if (!fs.existsSync(ocHome)) return;
30
+
31
+ const extDir = path.join(ocHome, "extensions");
32
+ if (!fs.existsSync(extDir)) return;
33
+
34
+ log("Checking for legacy plugin versions...");
35
+
36
+ const legacyDirs = [
37
+ path.join(extDir, "memos-lite"),
38
+ path.join(extDir, "memos-lite-openclaw-plugin"),
39
+ path.join(extDir, "node_modules", "@memtensor", "memos-lite-openclaw-plugin"),
40
+ ];
41
+
42
+ let cleaned = 0;
43
+ for (const dir of legacyDirs) {
44
+ if (fs.existsSync(dir)) {
45
+ try {
46
+ fs.rmSync(dir, { recursive: true, force: true });
47
+ ok(`Removed legacy plugin: ${DIM}${dir}${RESET}`);
48
+ cleaned++;
49
+ } catch (e) {
50
+ warn(`Could not remove ${dir}: ${e.message}`);
51
+ }
52
+ }
53
+ }
54
+
55
+ // Clean up openclaw.json config — migrate old plugin entries
56
+ const cfgPath = path.join(ocHome, "openclaw.json");
57
+ if (fs.existsSync(cfgPath)) {
58
+ try {
59
+ const raw = fs.readFileSync(cfgPath, "utf-8");
60
+ const cfg = JSON.parse(raw);
61
+ const entries = cfg?.plugins?.entries;
62
+ if (entries) {
63
+ const oldKeys = ["memos-lite", "memos-lite-openclaw-plugin"];
64
+ let cfgChanged = false;
65
+
66
+ for (const oldKey of oldKeys) {
67
+ if (entries[oldKey]) {
68
+ const oldEntry = entries[oldKey];
69
+ if (!entries["memos-local-openclaw-plugin"]) {
70
+ // Migrate: copy old config to new key
71
+ entries["memos-local-openclaw-plugin"] = oldEntry;
72
+ log(`Migrated config: ${DIM}${oldKey}${RESET} → ${GREEN}memos-local-openclaw-plugin${RESET}`);
73
+ }
74
+ delete entries[oldKey];
75
+ cfgChanged = true;
76
+ ok(`Removed legacy config entry: ${DIM}${oldKey}${RESET}`);
77
+ }
78
+ }
79
+
80
+ // Fix source path if it points to old directory names
81
+ const newEntry = entries["memos-local-openclaw-plugin"];
82
+ if (newEntry && typeof newEntry.source === "string") {
83
+ const oldSource = newEntry.source;
84
+ if (oldSource.includes("memos-lite")) {
85
+ newEntry.source = oldSource
86
+ .replace(/memos-lite-openclaw-plugin/g, "memos-local-openclaw-plugin")
87
+ .replace(/memos-lite/g, "memos-local");
88
+ if (newEntry.source !== oldSource) {
89
+ log(`Updated source path: ${DIM}${oldSource}${RESET} → ${GREEN}${newEntry.source}${RESET}`);
90
+ cfgChanged = true;
91
+ }
92
+ }
93
+ }
94
+
95
+ if (cfgChanged) {
96
+ // Write back with backup
97
+ const backup = cfgPath + ".bak-" + Date.now();
98
+ fs.copyFileSync(cfgPath, backup);
99
+ fs.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
100
+ ok(`Config updated. Backup: ${DIM}${backup}${RESET}`);
101
+ }
102
+ }
103
+ } catch (e) {
104
+ warn(`Could not update openclaw.json: ${e.message}`);
105
+ }
106
+ }
107
+
108
+ if (cleaned > 0) {
109
+ ok(`Legacy cleanup complete (${cleaned} old plugin dir(s) removed).`);
110
+ } else {
111
+ log("No legacy versions found.");
112
+ }
113
+ }
114
+
115
+ try {
116
+ cleanupLegacy();
117
+ } catch (e) {
118
+ warn(`Legacy cleanup skipped: ${e.message}`);
119
+ }
120
+
121
+ /* ═══════════════════════════════════════════════════════════
122
+ * Phase 2: Verify better-sqlite3 native module
123
+ * ═══════════════════════════════════════════════════════════ */
124
+
19
125
  log("Checking better-sqlite3 native module...");
20
126
 
21
127
  try {