opencode-mempalace-persistence 2.5.3 → 2.7.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 +7 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.js +1 -59
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,13 @@ OPENCODE_MEMPALACE_BACKFILL=1 opencode
|
|
|
219
219
|
|
|
220
220
|
The plugin exports everything in the opencode database on the next sync, then resumes incremental mode. Mining is idempotent — re-running is safe.
|
|
221
221
|
|
|
222
|
+
### Durability notes (drawers vs KG)
|
|
223
|
+
|
|
224
|
+
- **Drawers** (transcripts) are append-mostly: a crash mid-mine can only leave already-filed content behind, never corrupt what's stored. Re-running the mine is always safe.
|
|
225
|
+
- **KG facts** live a different life: `kg_supersede` replaces a fact atomically at a shared boundary (single transaction) — a mid-write crash rolls back to the *old* fact: stale but present, never half-written.
|
|
226
|
+
- **Reads are validity-window only**: there is no liveness check on read, so a stale fact reads as current until the model revisits it (via checkpoint, diary review, or a new decision on the same subject).
|
|
227
|
+
- **Backfill mines transcripts into drawers only** — it never touches the KG. KG facts come exclusively from live MCP calls (conversation, checkpoints, diary). A crashed supersede therefore waits for the next model touch, not the next backfill.
|
|
228
|
+
|
|
222
229
|
---
|
|
223
230
|
|
|
224
231
|
## Architecture
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
declare const _default: ({ client }: any) => Promise<{
|
|
2
|
-
tool: {
|
|
3
|
-
mempalace_sync: {
|
|
4
|
-
description: string;
|
|
5
|
-
args: {};
|
|
6
|
-
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
2
|
"chat.message": (input: {
|
|
10
3
|
sessionID: string;
|
|
11
4
|
agent?: string;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { homedir } from "os";
|
|
|
4
4
|
import { join, dirname } from "path";
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
-
import { tool } from "@opencode-ai/plugin";
|
|
8
7
|
const HOME = homedir();
|
|
9
8
|
const MEMPALACE_BIN = join(HOME, ".local/bin/mempalace");
|
|
10
9
|
const OPENCODE_DB = join(HOME, ".local/share/opencode/opencode.db");
|
|
@@ -162,52 +161,7 @@ function countPendingSuffix() {
|
|
|
162
161
|
const pending = countPendingFiles();
|
|
163
162
|
return pending > 0 ? `, ${pending} file(s) waiting to mine` : ", queue empty";
|
|
164
163
|
}
|
|
165
|
-
//
|
|
166
|
-
// the startup toast, plus live-mine detection. Fires a toast AND returns
|
|
167
|
-
// the text (visible in transcript too).
|
|
168
|
-
function liveMiners() {
|
|
169
|
-
const found = [];
|
|
170
|
-
let dir = [];
|
|
171
|
-
try {
|
|
172
|
-
dir = readdirSync(join(HOME, ".mempalace/locks"));
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
return found;
|
|
176
|
-
}
|
|
177
|
-
for (const f of dir) {
|
|
178
|
-
if (!f.endsWith(".lock"))
|
|
179
|
-
continue;
|
|
180
|
-
try {
|
|
181
|
-
const content = readFileSync(join(HOME, ".mempalace/locks", f), "utf-8");
|
|
182
|
-
const pid = parseInt((content.match(/(\d+)/) || [])[1] || "", 10);
|
|
183
|
-
if (!pid)
|
|
184
|
-
continue;
|
|
185
|
-
try {
|
|
186
|
-
process.kill(pid, 0);
|
|
187
|
-
found.push(`PID ${pid} (${f.replace("mine_palace_", "").replace(".lock", "").slice(0, 8)}…)`);
|
|
188
|
-
}
|
|
189
|
-
catch { }
|
|
190
|
-
}
|
|
191
|
-
catch { }
|
|
192
|
-
}
|
|
193
|
-
return found;
|
|
194
|
-
}
|
|
195
|
-
function syncSnapshot() {
|
|
196
|
-
const st = readSyncState();
|
|
197
|
-
const pending = countPendingFiles();
|
|
198
|
-
const miners = liveMiners();
|
|
199
|
-
const agoMin = st.last_sync_ms > 0 ? Math.round((Date.now() - st.last_sync_ms) / 60000) : -1;
|
|
200
|
-
const syncAge = agoMin < 0 ? "never" : agoMin === 0 ? "<1 min ago" : `${agoMin} min ago`;
|
|
201
|
-
const mining = miners.length > 0 ? `mining NOW (${miners.join(", ")})` : "no mine running";
|
|
202
|
-
const text = `MemPalace sync — plugin v${pluginVersion()}\n` +
|
|
203
|
-
`Last sync: ${syncAge}\n` +
|
|
204
|
-
`Backlog: ${pending} file(s) waiting\n` +
|
|
205
|
-
`Status: ${mining}`;
|
|
206
|
-
const toastMsg = miners.length > 0
|
|
207
|
-
? `mining now (${miners.length}), ${pending} file(s) waiting, last sync ${syncAge}`
|
|
208
|
-
: `idle, ${pending} file(s) waiting, last sync ${syncAge}`;
|
|
209
|
-
return { text, toastMsg };
|
|
210
|
-
}
|
|
164
|
+
// TUI toast client (set by the factory). Fire-and-forget: headless runs
|
|
211
165
|
// (`opencode run`, no TUI attached) must never break on this.
|
|
212
166
|
let tuiClient = null;
|
|
213
167
|
// Throttle for routine skip notices (busy palace): at most one toast
|
|
@@ -861,18 +815,6 @@ export default (async ({ client }) => {
|
|
|
861
815
|
process.once("SIGHUP", onExit);
|
|
862
816
|
process.once("exit", onExit);
|
|
863
817
|
return {
|
|
864
|
-
tool: {
|
|
865
|
-
mempalace_sync: tool({
|
|
866
|
-
description: "Show live MemPalace sync state (backlog, last sync, running mines) as a TUI toast and text. Use when the user asks how mining is going.",
|
|
867
|
-
args: {},
|
|
868
|
-
async execute() {
|
|
869
|
-
const snap = syncSnapshot();
|
|
870
|
-
toast("info", "MemPalace", snap.toastMsg);
|
|
871
|
-
ilog("status", { via: "tool" });
|
|
872
|
-
return snap.text;
|
|
873
|
-
},
|
|
874
|
-
}),
|
|
875
|
-
},
|
|
876
818
|
"chat.message": async (input, output) => {
|
|
877
819
|
const role = output.message.role;
|
|
878
820
|
if (role !== "user")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-mempalace-persistence",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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",
|