opencode-mempalace 0.1.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.
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ declare const mempalacePlugin: Plugin;
3
+ export default mempalacePlugin;
4
+ export { mempalacePlugin as server };
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ // @bun
2
+ // src/index.ts
3
+ var DEFAULT_MCP_COMMAND = [
4
+ "bun",
5
+ "run",
6
+ "/home/dat/mempalace-js/src/mcp-server.ts"
7
+ ];
8
+ var PALACE_PROTOCOL = `IMPORTANT \u2014 MemPalace Memory Protocol:
9
+ 1. ON WAKE-UP: Call mempalace_status to load palace overview + AAAK spec.
10
+ 2. BEFORE RESPONDING about any person, project, or past event: call mempalace_kg_query or mempalace_search FIRST. Never guess \u2014 verify.
11
+ 3. IF UNSURE about a fact (name, gender, age, relationship): say "let me check" and query the palace. Wrong is worse than slow.
12
+ 4. AFTER EACH SESSION: call mempalace_diary_write to record what happened, what you learned, what matters.
13
+ 5. WHEN FACTS CHANGE: call mempalace_kg_invalidate on the old fact, mempalace_kg_add for the new one.
14
+
15
+ This protocol ensures the AI KNOWS before it speaks. Storage is not memory \u2014 but storage + this protocol = memory.`;
16
+ var SESSION_START_INSTRUCTION = `[SYSTEM \u2014 MemPalace Context Load]
17
+ Spawn a background explore agent to load mempalace context for this session:
18
+
19
+ task(
20
+ subagent_type="explore",
21
+ run_in_background=true,
22
+ load_skills=["mempalace"],
23
+ description="Load mempalace context",
24
+ prompt="Query mempalace MCP tools to retrieve relevant context for this session.
25
+
26
+ Execute these queries IN ORDER, stop early if ChromaDB is not running:
27
+
28
+ 1. Call mcp_skill_mcp(mcp_name='mempalace', tool_name='mempalace_diary_read', arguments={days: 3})
29
+ 2. Call mcp_skill_mcp(mcp_name='mempalace', tool_name='mempalace_status')
30
+ 3. Call mcp_skill_mcp(mcp_name='mempalace', tool_name='mempalace_kg_query', arguments={name: '*'})
31
+
32
+ Return a concise summary of:
33
+ - Recent diary entries (last 3 days)
34
+ - Palace structure (wings, room count, total memories)
35
+ - Key entities and their latest facts
36
+
37
+ If ChromaDB is not running or mempalace tools fail, just return 'Mempalace unavailable - ChromaDB not running.'
38
+ Do NOT retry failed calls. Do NOT try to fix the connection."
39
+ )
40
+
41
+ Continue with the user's request immediately after spawning. Collect results via background_output when the notification arrives.`;
42
+ var mempalacePlugin = async (_input, options) => {
43
+ const opts = options ?? {};
44
+ const mcpCommand = opts.mcpCommand ?? DEFAULT_MCP_COMMAND;
45
+ const sessionsSeen = new Set;
46
+ return {
47
+ config: opts.disableMcp ? undefined : async (config) => {
48
+ if (!config.mcp)
49
+ config.mcp = {};
50
+ if (!config.mcp.mempalace) {
51
+ config.mcp.mempalace = {
52
+ type: "local",
53
+ command: mcpCommand
54
+ };
55
+ }
56
+ },
57
+ "experimental.chat.system.transform": opts.disableProtocol ? undefined : async (_input2, output) => {
58
+ output.system.push(PALACE_PROTOCOL);
59
+ },
60
+ "chat.message": opts.disableAutoLoad ? undefined : async (input, output) => {
61
+ if (sessionsSeen.has(input.sessionID))
62
+ return;
63
+ sessionsSeen.add(input.sessionID);
64
+ const firstTextPart = output.parts.find((p) => p.type === "text");
65
+ if (firstTextPart && "text" in firstTextPart) {
66
+ firstTextPart.text = `${SESSION_START_INSTRUCTION}
67
+
68
+ ${firstTextPart.text}`;
69
+ }
70
+ }
71
+ };
72
+ };
73
+ var src_default = mempalacePlugin;
74
+ export {
75
+ mempalacePlugin as server,
76
+ src_default as default
77
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "opencode-mempalace",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin for MemPalace memory system — auto-registers MCP server, injects memory protocol into system prompt, and loads context on session start",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "bun build src/index.ts --outdir dist --target bun --format esm && tsc -p tsconfig.build.json",
13
+ "check": "tsc --noEmit",
14
+ "prepublishOnly": "bun run build"
15
+ },
16
+ "keywords": [
17
+ "opencode",
18
+ "opencode-plugin",
19
+ "mempalace",
20
+ "memory",
21
+ "mcp",
22
+ "knowledge-graph"
23
+ ],
24
+ "author": "nguyentamdat",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/nguyentamdat/opencode-mempalace"
29
+ },
30
+ "devDependencies": {
31
+ "@opencode-ai/plugin": "^1.3.13",
32
+ "@tsconfig/bun": "^1.0.10",
33
+ "@types/bun": "^1.3.10",
34
+ "typescript": "^5.8.2"
35
+ }
36
+ }