opencode-mempalace-persistence 2.2.0 → 2.3.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 CHANGED
@@ -179,6 +179,7 @@ The model responds
179
179
 
180
180
  Session goes idle / process exits
181
181
  → Background mine of everything new since last sync
182
+ → TUI toast confirms what was mined (disable with `"toasts": false`)
182
183
 
183
184
  Compaction starts
184
185
  → [MemPalace Pre-Compact Emergency Save]: model files everything first
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const _default: () => Promise<{
1
+ declare const _default: ({ client }: any) => Promise<{
2
2
  "chat.message": (input: {
3
3
  sessionID: string;
4
4
  agent?: string;
package/dist/index.js CHANGED
@@ -46,6 +46,29 @@ function errLog(msg) {
46
46
  log("ERROR: " + msg);
47
47
  hookLog("ERROR: " + msg);
48
48
  }
49
+ function toastsEnabled() {
50
+ try {
51
+ const raw = readFileSync(PLUGIN_CONFIG, "utf-8");
52
+ const v = JSON.parse(raw)?.toasts;
53
+ if (v === false)
54
+ return false;
55
+ }
56
+ catch { }
57
+ return true;
58
+ }
59
+ // TUI toast client (set by the factory). Fire-and-forget: headless runs
60
+ // (`opencode run`, no TUI attached) must never break on this.
61
+ let tuiClient = null;
62
+ function toast(variant, title, message) {
63
+ if (!toastsEnabled() || !tuiClient?.tui?.showToast)
64
+ return;
65
+ try {
66
+ const p = tuiClient.tui.showToast({ body: { title, message, variant, duration: 5000 } });
67
+ if (p && typeof p.catch === "function")
68
+ p.catch(() => { });
69
+ }
70
+ catch { }
71
+ }
49
72
  // Probe for a working Python interpreter at startup instead of hardcoding
50
73
  // one installer layout (pipx vs uv tool vs system). runPython only needs
51
74
  // stdlib (sqlite3/json), so any python3 works. Priority: explicit env
@@ -434,6 +457,8 @@ function doDbSync() {
434
457
  markSynced(now);
435
458
  cleanupExport(wings);
436
459
  log("mine done");
460
+ const names = [...wings.keys()].join(", ");
461
+ toast("success", "MemPalace", `mined ${wingCount(wings)} session(s) → ${names}`);
437
462
  return;
438
463
  }
439
464
  const [wing, files] = entries[i];
@@ -453,6 +478,7 @@ function doDbSync() {
453
478
  if (err) {
454
479
  miningLock = false;
455
480
  errLog(`mine err (${wing}): ${err.message}`);
481
+ toast("error", "MemPalace", `mine failed (${wing}): ${err.message.slice(0, 120)}`);
456
482
  return;
457
483
  }
458
484
  log(`mined wing ${wing} (${files.length} sessions)`);
@@ -501,7 +527,8 @@ function exitSync() {
501
527
  errLog("exit save err: " + String(e));
502
528
  }
503
529
  }
504
- export default (async () => {
530
+ export default (async ({ client }) => {
531
+ tuiClient = client || null;
505
532
  mkdirSync(OUT_DIR, { recursive: true, mode: 0o700 });
506
533
  mkdirSync(HOOK_STATE_DIR, { recursive: true });
507
534
  const autoInject = isAutoInjectEnabled();
@@ -547,6 +574,7 @@ export default (async () => {
547
574
  c.lastCheckpoint = boundary;
548
575
  pendingCheckpoint = { sessionID, count: c.humanMsgs };
549
576
  hookLog(`session ${sessionID}: ${c.humanMsgs} human msgs — checkpoint armed`);
577
+ toast("info", "MemPalace", `checkpoint armed (~${c.humanMsgs} msgs): the model will file memories now`);
550
578
  }
551
579
  counters[sessionID] = c;
552
580
  persistCounters(counters);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mempalace-persistence",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "OpenCode plugin — auto-sync conversations to MemPalace memory in real-time. No forced wings, KG extraction via MCP tools.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",