opencode-mempalace-persistence 2.5.0 → 2.5.1

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -82,8 +82,23 @@ function toastsEnabled() {
82
82
  catch { }
83
83
  return true;
84
84
  }
85
- // Plugin's own name + version (shown in the startup toast and
86
- // /memory-status, so you always know which build is loaded).
85
+ // Messages arrived after the sync cursor: still waiting for the next run.
86
+ function countPendingMessages(sinceMs) {
87
+ try {
88
+ const out = runPython(`
89
+ import sqlite3
90
+ db = sqlite3.connect(${JSON.stringify(OPENCODE_DB)})
91
+ n = db.execute("SELECT COUNT(*) FROM message WHERE time_created > ${sinceMs}").fetchone()[0]
92
+ db.close()
93
+ print(n)
94
+ `);
95
+ const n = parseInt(out.trim(), 10);
96
+ return isNaN(n) ? 0 : n;
97
+ }
98
+ catch {
99
+ return 0;
100
+ }
101
+ }
87
102
  let cachedName = undefined;
88
103
  let cachedVersion = undefined;
89
104
  function pluginName() {
@@ -577,8 +592,11 @@ function doDbSync() {
577
592
  const names = [...wings.keys()].join(", ");
578
593
  const totalDrawers = [...wingDrawers.values()].reduce((a, b) => a + b, 0);
579
594
  const detail = totalDrawers > 0 ? ` (${totalDrawers} drawers)` : "";
580
- toast("success", "MemPalace", `mined ${wingCount(wings)} session(s) ${names}${detail}`);
581
- ilog("mine", { outcome: "ok", sessions: wingCount(wings), wings: [...wings.keys()], drawers: totalDrawers });
595
+ // Anything that arrived while this mine was running stays pending.
596
+ const remaining = countPendingMessages(now);
597
+ const tail = remaining > 0 ? `, ${remaining} message(s) still waiting` : ", queue empty";
598
+ toast("success", "MemPalace", `mined ${wingCount(wings)} session(s) → ${names}${detail}${tail}`);
599
+ ilog("mine", { outcome: "ok", sessions: wingCount(wings), wings: [...wings.keys()], drawers: totalDrawers, remaining });
582
600
  return;
583
601
  }
584
602
  const [wing, files] = entries[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mempalace-persistence",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
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",