opencode-mempalace-persistence 2.5.3 → 2.6.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/dist/index.d.ts +0 -7
- package/dist/index.js +1 -59
- package/package.json +1 -1
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.6.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",
|