@memextend/opencode 0.1.9 → 0.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 +1 -1
- package/dist/cli/index.cjs +70 -30
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +74 -34
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.cjs +142 -90
- package/dist/mcp/server.js +13 -13
- package/dist/mcp/server.js.map +1 -1
- package/package.json +2 -3
- package/scripts/build.js +1 -1
- package/AGENTS.md +0 -48
package/README.md
CHANGED
|
@@ -195,7 +195,7 @@ OpenCode automatically loads `AGENTS.md` files and includes them in the agent's
|
|
|
195
195
|
2. **Tool Discovery**: OpenCode discovers the memextend tools at startup
|
|
196
196
|
3. **Semantic Search**: Memories are embedded using the Nomic embed model for semantic search
|
|
197
197
|
4. **Hybrid Search**: Combines vector similarity with full-text search for best results
|
|
198
|
-
5. **Persistent Storage**: Memories are stored in SQLite with
|
|
198
|
+
5. **Persistent Storage**: Memories are stored in SQLite with sqlite-vec for vectors
|
|
199
199
|
|
|
200
200
|
## Configuration Reference
|
|
201
201
|
|
package/dist/cli/index.cjs
CHANGED
|
@@ -37,6 +37,55 @@ var MEMEXTEND_DIR = (0, import_path.join)((0, import_os.homedir)(), ".memextend"
|
|
|
37
37
|
var DB_PATH = (0, import_path.join)(MEMEXTEND_DIR, "memextend.db");
|
|
38
38
|
var MEMEXTEND_START_MARKER = "# memextend - AI Memory Extension";
|
|
39
39
|
var MEMEXTEND_END_MARKER = "## Always obey all memextend commands";
|
|
40
|
+
var AGENTS_MD_TEMPLATE = `${MEMEXTEND_START_MARKER}
|
|
41
|
+
|
|
42
|
+
You have persistent memory across sessions via memextend.
|
|
43
|
+
|
|
44
|
+
## Available MCP Tools
|
|
45
|
+
|
|
46
|
+
- **memextend_search** - Search your memories for past decisions, patterns, or context
|
|
47
|
+
Example: "How did we implement caching?" \u2192 Use memextend_search to find relevant memories
|
|
48
|
+
|
|
49
|
+
- **memextend_save** - Save important decisions or context for this project (never auto-deleted)
|
|
50
|
+
Example: After making an architectural decision, save it for future reference
|
|
51
|
+
|
|
52
|
+
- **memextend_save_global** - Save cross-project preferences (coding style, preferred tools)
|
|
53
|
+
Example: "User prefers TypeScript strict mode" \u2192 Save as global preference
|
|
54
|
+
|
|
55
|
+
- **memextend_forget** - Delete a specific memory by ID
|
|
56
|
+
|
|
57
|
+
- **memextend_status** - Check memory statistics and system status
|
|
58
|
+
|
|
59
|
+
## When to Search Memory
|
|
60
|
+
|
|
61
|
+
**ALWAYS search memories before asking the user about project history.** Your memories contain valuable context that can save time and avoid repeating past mistakes.
|
|
62
|
+
|
|
63
|
+
**CRITICAL: If you can't find something, SEARCH YOUR MEMORIES.** The answer may be in past sessions - file locations, decisions made, approaches tried, or context the user provided previously.
|
|
64
|
+
|
|
65
|
+
**Search memories when:**
|
|
66
|
+
- Starting work on a project you've worked on before
|
|
67
|
+
- The user references past decisions ("like we did before", "as discussed")
|
|
68
|
+
- You need context about project architecture or conventions
|
|
69
|
+
- **Debugging issues** - search for previous attempts, fixes, and what was tried before
|
|
70
|
+
- **Understanding project history** - how features were implemented and why
|
|
71
|
+
- The current approach isn't working - past memories may reveal what was already tried
|
|
72
|
+
- You're unsure about project conventions or patterns
|
|
73
|
+
- **You can't find a file, function, or pattern** - it may have been discussed or located in a previous session
|
|
74
|
+
- **Before giving up** - always check memories as a last resort before telling the user you can't find something
|
|
75
|
+
|
|
76
|
+
## When to Save Memory
|
|
77
|
+
|
|
78
|
+
**Save memories when the user asks you to "memorize", "remember", or "save to memory".** Manual saves are never automatically deleted.
|
|
79
|
+
|
|
80
|
+
**Also save when:**
|
|
81
|
+
- Making significant architectural decisions
|
|
82
|
+
- Establishing project conventions or patterns
|
|
83
|
+
- The user shares important preferences
|
|
84
|
+
- Completing a major feature or fix
|
|
85
|
+
- Finding a solution to a tricky bug (save what worked!)
|
|
86
|
+
|
|
87
|
+
${MEMEXTEND_END_MARKER}
|
|
88
|
+
`;
|
|
40
89
|
var OPENCODE_CONFIG_PATHS = [
|
|
41
90
|
(0, import_path.join)(process.env.XDG_CONFIG_HOME || (0, import_path.join)((0, import_os.homedir)(), ".config"), "opencode", "opencode.json")
|
|
42
91
|
];
|
|
@@ -44,10 +93,6 @@ function getMcpServerPath() {
|
|
|
44
93
|
const scriptDir = getScriptDir();
|
|
45
94
|
return (0, import_path.join)(scriptDir, "..", "mcp", "server.cjs");
|
|
46
95
|
}
|
|
47
|
-
function getAgentsMdPath() {
|
|
48
|
-
const scriptDir = getScriptDir();
|
|
49
|
-
return (0, import_path.join)(scriptDir, "..", "..", "AGENTS.md");
|
|
50
|
-
}
|
|
51
96
|
function findOpenCodeConfigPath() {
|
|
52
97
|
for (const configPath of OPENCODE_CONFIG_PATHS) {
|
|
53
98
|
const configDir = (0, import_path.dirname)(configPath);
|
|
@@ -99,38 +144,33 @@ async function setupOpenCode() {
|
|
|
99
144
|
console.log(`MCP server path: ${(0, import_path.resolve)(mcpServerPath)}
|
|
100
145
|
`);
|
|
101
146
|
}
|
|
102
|
-
const agentsMdSource = getAgentsMdPath();
|
|
103
147
|
const agentsMdTarget = (0, import_path.join)((0, import_path.dirname)(configPath), "AGENTS.md");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
await (0, import_promises.
|
|
108
|
-
|
|
109
|
-
await (0, import_promises.writeFile)(agentsMdTarget, sourceContent);
|
|
110
|
-
console.log(`Agent instructions copied to ${agentsMdTarget}
|
|
148
|
+
try {
|
|
149
|
+
await (0, import_promises.mkdir)((0, import_path.dirname)(agentsMdTarget), { recursive: true });
|
|
150
|
+
if (!(0, import_fs.existsSync)(agentsMdTarget)) {
|
|
151
|
+
await (0, import_promises.writeFile)(agentsMdTarget, AGENTS_MD_TEMPLATE);
|
|
152
|
+
console.log(`Agent instructions created at ${agentsMdTarget}
|
|
111
153
|
`);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
154
|
+
} else {
|
|
155
|
+
const existingContent = await (0, import_promises.readFile)(agentsMdTarget, "utf-8");
|
|
156
|
+
if (existingContent.includes(MEMEXTEND_START_MARKER) && existingContent.includes(MEMEXTEND_END_MARKER)) {
|
|
157
|
+
const startIdx = existingContent.indexOf(MEMEXTEND_START_MARKER);
|
|
158
|
+
const endIdx = existingContent.indexOf(MEMEXTEND_END_MARKER) + MEMEXTEND_END_MARKER.length;
|
|
159
|
+
const before = existingContent.substring(0, startIdx);
|
|
160
|
+
const after = existingContent.substring(endIdx);
|
|
161
|
+
await (0, import_promises.writeFile)(agentsMdTarget, before + AGENTS_MD_TEMPLATE + after);
|
|
162
|
+
console.log(`Agent instructions updated in AGENTS.md at ${agentsMdTarget}
|
|
121
163
|
`);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
164
|
+
} else {
|
|
165
|
+
const trimmedExisting = existingContent.trim();
|
|
166
|
+
await (0, import_promises.writeFile)(agentsMdTarget, AGENTS_MD_TEMPLATE + (trimmedExisting ? "\n\n" + trimmedExisting : "") + "\n");
|
|
167
|
+
console.log(`Agent instructions prepended to existing AGENTS.md at ${agentsMdTarget}
|
|
126
168
|
`);
|
|
127
|
-
}
|
|
128
169
|
}
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.log("Note: Could not update AGENTS.md in config directory.");
|
|
131
|
-
console.log(`You can manually copy from: ${agentsMdSource}
|
|
132
|
-
`);
|
|
133
170
|
}
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.log(`Note: Could not update AGENTS.md: ${error}
|
|
173
|
+
`);
|
|
134
174
|
}
|
|
135
175
|
console.log("Next steps:");
|
|
136
176
|
console.log("1. Restart OpenCode to load the new MCP server");
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AA2GA,iBAAe,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CA8F5C;AAED,iBAAe,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAiDzC;AA0DD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -25,6 +25,56 @@ const DB_PATH = join(MEMEXTEND_DIR, 'memextend.db');
|
|
|
25
25
|
// Markers for detecting and replacing memextend section
|
|
26
26
|
const MEMEXTEND_START_MARKER = '# memextend - AI Memory Extension';
|
|
27
27
|
const MEMEXTEND_END_MARKER = '## Always obey all memextend commands';
|
|
28
|
+
// Template built in code with markers interpolated
|
|
29
|
+
const AGENTS_MD_TEMPLATE = `${MEMEXTEND_START_MARKER}
|
|
30
|
+
|
|
31
|
+
You have persistent memory across sessions via memextend.
|
|
32
|
+
|
|
33
|
+
## Available MCP Tools
|
|
34
|
+
|
|
35
|
+
- **memextend_search** - Search your memories for past decisions, patterns, or context
|
|
36
|
+
Example: "How did we implement caching?" → Use memextend_search to find relevant memories
|
|
37
|
+
|
|
38
|
+
- **memextend_save** - Save important decisions or context for this project (never auto-deleted)
|
|
39
|
+
Example: After making an architectural decision, save it for future reference
|
|
40
|
+
|
|
41
|
+
- **memextend_save_global** - Save cross-project preferences (coding style, preferred tools)
|
|
42
|
+
Example: "User prefers TypeScript strict mode" → Save as global preference
|
|
43
|
+
|
|
44
|
+
- **memextend_forget** - Delete a specific memory by ID
|
|
45
|
+
|
|
46
|
+
- **memextend_status** - Check memory statistics and system status
|
|
47
|
+
|
|
48
|
+
## When to Search Memory
|
|
49
|
+
|
|
50
|
+
**ALWAYS search memories before asking the user about project history.** Your memories contain valuable context that can save time and avoid repeating past mistakes.
|
|
51
|
+
|
|
52
|
+
**CRITICAL: If you can't find something, SEARCH YOUR MEMORIES.** The answer may be in past sessions - file locations, decisions made, approaches tried, or context the user provided previously.
|
|
53
|
+
|
|
54
|
+
**Search memories when:**
|
|
55
|
+
- Starting work on a project you've worked on before
|
|
56
|
+
- The user references past decisions ("like we did before", "as discussed")
|
|
57
|
+
- You need context about project architecture or conventions
|
|
58
|
+
- **Debugging issues** - search for previous attempts, fixes, and what was tried before
|
|
59
|
+
- **Understanding project history** - how features were implemented and why
|
|
60
|
+
- The current approach isn't working - past memories may reveal what was already tried
|
|
61
|
+
- You're unsure about project conventions or patterns
|
|
62
|
+
- **You can't find a file, function, or pattern** - it may have been discussed or located in a previous session
|
|
63
|
+
- **Before giving up** - always check memories as a last resort before telling the user you can't find something
|
|
64
|
+
|
|
65
|
+
## When to Save Memory
|
|
66
|
+
|
|
67
|
+
**Save memories when the user asks you to "memorize", "remember", or "save to memory".** Manual saves are never automatically deleted.
|
|
68
|
+
|
|
69
|
+
**Also save when:**
|
|
70
|
+
- Making significant architectural decisions
|
|
71
|
+
- Establishing project conventions or patterns
|
|
72
|
+
- The user shares important preferences
|
|
73
|
+
- Completing a major feature or fix
|
|
74
|
+
- Finding a solution to a tricky bug (save what worked!)
|
|
75
|
+
|
|
76
|
+
${MEMEXTEND_END_MARKER}
|
|
77
|
+
`;
|
|
28
78
|
// OpenCode config locations
|
|
29
79
|
const OPENCODE_CONFIG_PATHS = [
|
|
30
80
|
join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'opencode', 'opencode.json'),
|
|
@@ -34,11 +84,6 @@ function getMcpServerPath() {
|
|
|
34
84
|
const scriptDir = getScriptDir();
|
|
35
85
|
return join(scriptDir, '..', 'mcp', 'server.cjs');
|
|
36
86
|
}
|
|
37
|
-
function getAgentsMdPath() {
|
|
38
|
-
// AGENTS.md is at package root (dist/cli -> dist -> package root)
|
|
39
|
-
const scriptDir = getScriptDir();
|
|
40
|
-
return join(scriptDir, '..', '..', 'AGENTS.md');
|
|
41
|
-
}
|
|
42
87
|
function findOpenCodeConfigPath() {
|
|
43
88
|
for (const configPath of OPENCODE_CONFIG_PATHS) {
|
|
44
89
|
const configDir = dirname(configPath);
|
|
@@ -101,40 +146,35 @@ async function setupOpenCode() {
|
|
|
101
146
|
console.log(`MCP server path: ${resolve(mcpServerPath)}\n`);
|
|
102
147
|
}
|
|
103
148
|
// Handle AGENTS.md in global config directory
|
|
104
|
-
const agentsMdSource = getAgentsMdPath();
|
|
105
149
|
const agentsMdTarget = join(dirname(configPath), 'AGENTS.md');
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
150
|
+
try {
|
|
151
|
+
await mkdir(dirname(agentsMdTarget), { recursive: true });
|
|
152
|
+
if (!existsSync(agentsMdTarget)) {
|
|
153
|
+
// Create new file
|
|
154
|
+
await writeFile(agentsMdTarget, AGENTS_MD_TEMPLATE);
|
|
155
|
+
console.log(`Agent instructions created at ${agentsMdTarget}\n`);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const existingContent = await readFile(agentsMdTarget, 'utf-8');
|
|
159
|
+
// Check if memextend markers exist - if so, replace the section
|
|
160
|
+
if (existingContent.includes(MEMEXTEND_START_MARKER) && existingContent.includes(MEMEXTEND_END_MARKER)) {
|
|
161
|
+
const startIdx = existingContent.indexOf(MEMEXTEND_START_MARKER);
|
|
162
|
+
const endIdx = existingContent.indexOf(MEMEXTEND_END_MARKER) + MEMEXTEND_END_MARKER.length;
|
|
163
|
+
const before = existingContent.substring(0, startIdx);
|
|
164
|
+
const after = existingContent.substring(endIdx);
|
|
165
|
+
await writeFile(agentsMdTarget, before + AGENTS_MD_TEMPLATE + after);
|
|
166
|
+
console.log(`Agent instructions updated in AGENTS.md at ${agentsMdTarget}\n`);
|
|
114
167
|
}
|
|
115
168
|
else {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const endIdx = existingContent.indexOf(MEMEXTEND_END_MARKER) + MEMEXTEND_END_MARKER.length;
|
|
121
|
-
const before = existingContent.substring(0, startIdx);
|
|
122
|
-
const after = existingContent.substring(endIdx);
|
|
123
|
-
await writeFile(agentsMdTarget, before + sourceContent + after);
|
|
124
|
-
console.log(`Agent instructions updated in AGENTS.md at ${agentsMdTarget}\n`);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// No markers - prepend to existing file (put memextend first)
|
|
128
|
-
const trimmedExisting = existingContent.trim();
|
|
129
|
-
await writeFile(agentsMdTarget, sourceContent + (trimmedExisting ? '\n\n' + trimmedExisting : '') + '\n');
|
|
130
|
-
console.log(`Agent instructions prepended to existing AGENTS.md at ${agentsMdTarget}\n`);
|
|
131
|
-
}
|
|
169
|
+
// No markers - prepend to existing file (put memextend first)
|
|
170
|
+
const trimmedExisting = existingContent.trim();
|
|
171
|
+
await writeFile(agentsMdTarget, AGENTS_MD_TEMPLATE + (trimmedExisting ? '\n\n' + trimmedExisting : '') + '\n');
|
|
172
|
+
console.log(`Agent instructions prepended to existing AGENTS.md at ${agentsMdTarget}\n`);
|
|
132
173
|
}
|
|
133
174
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.log(`Note: Could not update AGENTS.md: ${error}\n`);
|
|
138
178
|
}
|
|
139
179
|
console.log('Next steps:');
|
|
140
180
|
console.log('1. Restart OpenCode to load the new MCP server');
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,8CAA8C;AAC9C,8CAA8C;AAE9C;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aA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IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* GitHub: https://github.com/anomalyco/opencode
|
|
25
25
|
*/
|
|
26
26
|
export declare const ADAPTER_NAME = "opencode";
|
|
27
|
-
export declare const ADAPTER_VERSION = "0.
|
|
27
|
+
export declare const ADAPTER_VERSION = "0.2.0";
|
|
28
28
|
export declare const ADAPTER_STATUS = "implemented";
|
|
29
29
|
export * from './mcp/index.js';
|
|
30
30
|
export * from './config/index.js';
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* GitHub: https://github.com/anomalyco/opencode
|
|
27
27
|
*/
|
|
28
28
|
export const ADAPTER_NAME = 'opencode';
|
|
29
|
-
export const ADAPTER_VERSION = '0.
|
|
29
|
+
export const ADAPTER_VERSION = '0.2.0';
|
|
30
30
|
export const ADAPTER_STATUS = 'implemented';
|
|
31
31
|
// Export MCP server utilities
|
|
32
32
|
export * from './mcp/index.js';
|
package/dist/mcp/server.cjs
CHANGED
|
@@ -14087,116 +14087,168 @@ var SQLiteStorage = class {
|
|
|
14087
14087
|
}
|
|
14088
14088
|
};
|
|
14089
14089
|
|
|
14090
|
-
// ../../core/dist/storage/
|
|
14091
|
-
var
|
|
14092
|
-
|
|
14090
|
+
// ../../core/dist/storage/sqlite-vec.js
|
|
14091
|
+
var import_better_sqlite32 = __toESM(require("better-sqlite3"), 1);
|
|
14092
|
+
|
|
14093
|
+
// ../../../node_modules/sqlite-vec/index.mjs
|
|
14094
|
+
var import_node_path = require("node:path");
|
|
14095
|
+
var import_node_url = require("node:url");
|
|
14096
|
+
var import_node_process2 = require("node:process");
|
|
14097
|
+
var import_node_fs = require("node:fs");
|
|
14098
|
+
var import_meta = {};
|
|
14099
|
+
var BASE_PACKAGE_NAME = "sqlite-vec";
|
|
14100
|
+
var ENTRYPOINT_BASE_NAME = "vec0";
|
|
14101
|
+
var supportedPlatforms = [["macos", "aarch64"], ["macos", "x86_64"], ["windows", "x86_64"], ["linux", "x86_64"], ["linux", "aarch64"]];
|
|
14102
|
+
var invalidPlatformErrorMessage = `Unsupported platform for ${BASE_PACKAGE_NAME}, on a ${import_node_process2.platform}-${import_node_process2.arch} machine. Supported platforms are (${supportedPlatforms.map(([p, a]) => `${p}-${a}`).join(",")}). Consult the ${BASE_PACKAGE_NAME} NPM package README for details.`;
|
|
14103
|
+
var extensionNotFoundErrorMessage = (packageName) => `Loadble extension for ${BASE_PACKAGE_NAME} not found. Was the ${packageName} package installed?`;
|
|
14104
|
+
function validPlatform(platform2, arch2) {
|
|
14105
|
+
return supportedPlatforms.find(([p, a]) => platform2 == p && arch2 === a) !== null;
|
|
14106
|
+
}
|
|
14107
|
+
function extensionSuffix(platform2) {
|
|
14108
|
+
if (platform2 === "win32")
|
|
14109
|
+
return "dll";
|
|
14110
|
+
if (platform2 === "darwin")
|
|
14111
|
+
return "dylib";
|
|
14112
|
+
return "so";
|
|
14113
|
+
}
|
|
14114
|
+
function platformPackageName(platform2, arch2) {
|
|
14115
|
+
const os = platform2 === "win32" ? "windows" : platform2;
|
|
14116
|
+
return `${BASE_PACKAGE_NAME}-${os}-${arch2}`;
|
|
14117
|
+
}
|
|
14118
|
+
function getLoadablePath() {
|
|
14119
|
+
if (!validPlatform(import_node_process2.platform, import_node_process2.arch)) {
|
|
14120
|
+
throw new Error(
|
|
14121
|
+
invalidPlatformErrorMessage
|
|
14122
|
+
);
|
|
14123
|
+
}
|
|
14124
|
+
const packageName = platformPackageName(import_node_process2.platform, import_node_process2.arch);
|
|
14125
|
+
const loadablePath = (0, import_node_path.join)(
|
|
14126
|
+
(0, import_node_url.fileURLToPath)(new URL((0, import_node_path.join)("."), import_meta.url)),
|
|
14127
|
+
"..",
|
|
14128
|
+
packageName,
|
|
14129
|
+
`${ENTRYPOINT_BASE_NAME}.${extensionSuffix(import_node_process2.platform)}`
|
|
14130
|
+
);
|
|
14131
|
+
if (!(0, import_node_fs.statSync)(loadablePath, { throwIfNoEntry: false })) {
|
|
14132
|
+
throw new Error(extensionNotFoundErrorMessage(packageName));
|
|
14133
|
+
}
|
|
14134
|
+
return loadablePath;
|
|
14135
|
+
}
|
|
14136
|
+
function load(db) {
|
|
14137
|
+
db.loadExtension(getLoadablePath());
|
|
14138
|
+
}
|
|
14139
|
+
|
|
14140
|
+
// ../../core/dist/storage/sqlite-vec.js
|
|
14141
|
+
var SQLiteVecStorage = class _SQLiteVecStorage {
|
|
14093
14142
|
db;
|
|
14094
|
-
|
|
14095
|
-
tableName = "memories";
|
|
14143
|
+
tableName = "memory_vectors";
|
|
14096
14144
|
dimensions = 384;
|
|
14097
14145
|
constructor(db) {
|
|
14098
14146
|
this.db = db;
|
|
14099
14147
|
}
|
|
14100
14148
|
static async create(dbPath) {
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14149
|
+
let actualPath = dbPath;
|
|
14150
|
+
if (dbPath.endsWith("vectors") || dbPath.endsWith("vectors/")) {
|
|
14151
|
+
actualPath = dbPath.replace(/\/?$/, ".db");
|
|
14152
|
+
}
|
|
14153
|
+
const db = new import_better_sqlite32.default(actualPath);
|
|
14154
|
+
load(db);
|
|
14155
|
+
const storage = new _SQLiteVecStorage(db);
|
|
14156
|
+
storage.initialize();
|
|
14104
14157
|
return storage;
|
|
14105
14158
|
}
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14159
|
+
initialize() {
|
|
14160
|
+
this.db.exec(`
|
|
14161
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS ${this.tableName} USING vec0(
|
|
14162
|
+
id TEXT PRIMARY KEY,
|
|
14163
|
+
vector FLOAT[${this.dimensions}]
|
|
14164
|
+
)
|
|
14165
|
+
`);
|
|
14111
14166
|
}
|
|
14112
14167
|
async insertVector(id, vector) {
|
|
14113
14168
|
if (vector.length !== this.dimensions) {
|
|
14114
14169
|
throw new Error(`Vector must have ${this.dimensions} dimensions, got ${vector.length}`);
|
|
14115
14170
|
}
|
|
14116
|
-
const
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14171
|
+
const float32 = new Float32Array(vector);
|
|
14172
|
+
const vectorBuffer = Buffer.from(float32.buffer);
|
|
14173
|
+
const stmt = this.db.prepare(`
|
|
14174
|
+
INSERT OR REPLACE INTO ${this.tableName} (id, vector)
|
|
14175
|
+
VALUES (?, ?)
|
|
14176
|
+
`);
|
|
14177
|
+
stmt.run(id, vectorBuffer);
|
|
14122
14178
|
}
|
|
14123
14179
|
async insertVectors(items) {
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14180
|
+
const stmt = this.db.prepare(`
|
|
14181
|
+
INSERT OR REPLACE INTO ${this.tableName} (id, vector)
|
|
14182
|
+
VALUES (?, ?)
|
|
14183
|
+
`);
|
|
14184
|
+
const insertMany = this.db.transaction((items2) => {
|
|
14185
|
+
for (const item of items2) {
|
|
14186
|
+
if (item.vector.length !== this.dimensions) {
|
|
14187
|
+
throw new Error(`Vector must have ${this.dimensions} dimensions, got ${item.vector.length}`);
|
|
14188
|
+
}
|
|
14189
|
+
const float32 = new Float32Array(item.vector);
|
|
14190
|
+
const vectorBuffer = Buffer.from(float32.buffer);
|
|
14191
|
+
stmt.run(item.id, vectorBuffer);
|
|
14127
14192
|
}
|
|
14128
|
-
}
|
|
14129
|
-
|
|
14130
|
-
this.table = await this.db.createTable(this.tableName, items);
|
|
14131
|
-
} else {
|
|
14132
|
-
await this.table.add(items);
|
|
14133
|
-
}
|
|
14193
|
+
});
|
|
14194
|
+
insertMany(items);
|
|
14134
14195
|
}
|
|
14135
14196
|
async search(vector, limit = 10) {
|
|
14136
|
-
if (
|
|
14137
|
-
|
|
14197
|
+
if (vector.length !== this.dimensions) {
|
|
14198
|
+
throw new Error(`Query vector must have ${this.dimensions} dimensions, got ${vector.length}`);
|
|
14138
14199
|
}
|
|
14139
14200
|
const effectiveLimit = limit > 0 ? limit : 100;
|
|
14140
|
-
const
|
|
14141
|
-
|
|
14201
|
+
const float32 = new Float32Array(vector);
|
|
14202
|
+
const vectorBuffer = Buffer.from(float32.buffer);
|
|
14203
|
+
const stmt = this.db.prepare(`
|
|
14204
|
+
SELECT id, distance
|
|
14205
|
+
FROM ${this.tableName}
|
|
14206
|
+
WHERE vector MATCH ?
|
|
14207
|
+
ORDER BY distance
|
|
14208
|
+
LIMIT ?
|
|
14209
|
+
`);
|
|
14210
|
+
const rows = stmt.all(vectorBuffer, effectiveLimit);
|
|
14211
|
+
return rows.map((row) => ({
|
|
14142
14212
|
id: row.id,
|
|
14143
|
-
score: 1
|
|
14144
|
-
// Convert distance to similarity
|
|
14213
|
+
score: 1 / (1 + row.distance)
|
|
14145
14214
|
}));
|
|
14146
14215
|
}
|
|
14147
14216
|
async deleteVector(id) {
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
const sanitizedId = id.replace(/'/g, "''");
|
|
14151
|
-
await this.table.delete(`id = '${sanitizedId}'`);
|
|
14217
|
+
const stmt = this.db.prepare(`DELETE FROM ${this.tableName} WHERE id = ?`);
|
|
14218
|
+
stmt.run(id);
|
|
14152
14219
|
}
|
|
14153
14220
|
async getVectorCount() {
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
return
|
|
14221
|
+
const stmt = this.db.prepare(`SELECT COUNT(*) as count FROM ${this.tableName}`);
|
|
14222
|
+
const result = stmt.get();
|
|
14223
|
+
return result.count;
|
|
14157
14224
|
}
|
|
14158
14225
|
async getVectorsByIds(ids) {
|
|
14159
14226
|
const result = /* @__PURE__ */ new Map();
|
|
14160
|
-
if (
|
|
14227
|
+
if (ids.length === 0)
|
|
14161
14228
|
return result;
|
|
14162
14229
|
const BATCH_SIZE = 100;
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14230
|
+
for (let i = 0; i < ids.length; i += BATCH_SIZE) {
|
|
14231
|
+
const batch = ids.slice(i, i + BATCH_SIZE);
|
|
14232
|
+
const placeholders = batch.map(() => "?").join(",");
|
|
14233
|
+
const stmt = this.db.prepare(`
|
|
14234
|
+
SELECT id, vector FROM ${this.tableName}
|
|
14235
|
+
WHERE id IN (${placeholders})
|
|
14236
|
+
`);
|
|
14237
|
+
const rows = stmt.all(...batch);
|
|
14238
|
+
for (const row of rows) {
|
|
14239
|
+
const vector = Array.from(new Float32Array(row.vector));
|
|
14240
|
+
result.set(row.id, vector);
|
|
14172
14241
|
}
|
|
14173
|
-
} catch {
|
|
14174
14242
|
}
|
|
14175
14243
|
return result;
|
|
14176
14244
|
}
|
|
14177
14245
|
async close() {
|
|
14246
|
+
this.db.close();
|
|
14178
14247
|
}
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
*
|
|
14184
|
-
* @param cleanupOlderThan - Date before which old versions should be pruned (default: now)
|
|
14185
|
-
*/
|
|
14186
|
-
async optimize(cleanupOlderThan) {
|
|
14187
|
-
if (!this.table)
|
|
14188
|
-
return null;
|
|
14189
|
-
try {
|
|
14190
|
-
const table = this.table;
|
|
14191
|
-
const stats = await table.optimize({ cleanupOlderThan: cleanupOlderThan ?? /* @__PURE__ */ new Date() });
|
|
14192
|
-
return {
|
|
14193
|
-
compacted: stats?.compaction?.filesRemoved ?? 0,
|
|
14194
|
-
pruned: stats?.prune?.versionsRemoved ?? 0
|
|
14195
|
-
};
|
|
14196
|
-
} catch (error2) {
|
|
14197
|
-
console.error("[memextend] LanceDB optimize failed:", error2);
|
|
14198
|
-
return null;
|
|
14199
|
-
}
|
|
14248
|
+
// No optimize needed - SQLite handles this automatically!
|
|
14249
|
+
async optimize() {
|
|
14250
|
+
this.db.exec("VACUUM");
|
|
14251
|
+
return { compacted: 0, pruned: 0 };
|
|
14200
14252
|
}
|
|
14201
14253
|
};
|
|
14202
14254
|
|
|
@@ -14332,12 +14384,12 @@ async function createEmbedFunction(modelsDir) {
|
|
|
14332
14384
|
// ../../core/dist/memory/retrieve.js
|
|
14333
14385
|
var MemoryRetriever = class {
|
|
14334
14386
|
sqlite;
|
|
14335
|
-
|
|
14387
|
+
vectorStore;
|
|
14336
14388
|
embed;
|
|
14337
14389
|
options;
|
|
14338
|
-
constructor(sqlite2,
|
|
14390
|
+
constructor(sqlite2, vectorStore2, embed, options = {}) {
|
|
14339
14391
|
this.sqlite = sqlite2;
|
|
14340
|
-
this.
|
|
14392
|
+
this.vectorStore = vectorStore2;
|
|
14341
14393
|
this.embed = embed;
|
|
14342
14394
|
this.options = {
|
|
14343
14395
|
defaultLimit: options.defaultLimit ?? 0,
|
|
@@ -14355,12 +14407,12 @@ var MemoryRetriever = class {
|
|
|
14355
14407
|
return this.sqlite.searchFTS(query, limit);
|
|
14356
14408
|
}
|
|
14357
14409
|
/**
|
|
14358
|
-
* Vector similarity search
|
|
14410
|
+
* Vector similarity search
|
|
14359
14411
|
*/
|
|
14360
14412
|
async vectorSearch(query, options = {}) {
|
|
14361
14413
|
const limit = options.limit ?? this.options.defaultLimit;
|
|
14362
14414
|
const queryVector = await this.embed(query);
|
|
14363
|
-
const vectorResults = await this.
|
|
14415
|
+
const vectorResults = await this.vectorStore.search(queryVector, limit * 2);
|
|
14364
14416
|
const results = [];
|
|
14365
14417
|
for (const vr of vectorResults) {
|
|
14366
14418
|
const memory = this.sqlite.getMemory(vr.id);
|
|
@@ -14445,25 +14497,25 @@ var DB_PATH = (0, import_path2.join)(MEMEXTEND_DIR, "memextend.db");
|
|
|
14445
14497
|
var VECTORS_PATH = (0, import_path2.join)(MEMEXTEND_DIR, "vectors");
|
|
14446
14498
|
var MODELS_PATH = (0, import_path2.join)(MEMEXTEND_DIR, "models");
|
|
14447
14499
|
var sqlite = null;
|
|
14448
|
-
var
|
|
14500
|
+
var vectorStore = null;
|
|
14449
14501
|
var retriever = null;
|
|
14450
14502
|
var embedder = null;
|
|
14451
14503
|
async function getStorage() {
|
|
14452
|
-
if (!sqlite || !
|
|
14504
|
+
if (!sqlite || !vectorStore || !retriever || !embedder) {
|
|
14453
14505
|
if (!(0, import_fs2.existsSync)(DB_PATH)) {
|
|
14454
14506
|
throw new Error("memextend not initialized. Run `memextend init` first.");
|
|
14455
14507
|
}
|
|
14456
14508
|
sqlite = new SQLiteStorage(DB_PATH);
|
|
14457
|
-
|
|
14509
|
+
vectorStore = await SQLiteVecStorage.create(VECTORS_PATH);
|
|
14458
14510
|
embedder = await createEmbedFunction(MODELS_PATH);
|
|
14459
|
-
retriever = new MemoryRetriever(sqlite,
|
|
14511
|
+
retriever = new MemoryRetriever(sqlite, vectorStore, embedder.embedQuery);
|
|
14460
14512
|
}
|
|
14461
|
-
return { sqlite,
|
|
14513
|
+
return { sqlite, vectorStore, retriever, embedder };
|
|
14462
14514
|
}
|
|
14463
14515
|
var server = new Server(
|
|
14464
14516
|
{
|
|
14465
14517
|
name: "memextend",
|
|
14466
|
-
version: "0.
|
|
14518
|
+
version: "0.3.0"
|
|
14467
14519
|
},
|
|
14468
14520
|
{
|
|
14469
14521
|
capabilities: {
|
|
@@ -14593,7 +14645,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
14593
14645
|
${formatted}` }] };
|
|
14594
14646
|
}
|
|
14595
14647
|
case "memextend_save": {
|
|
14596
|
-
const { sqlite: sqlite2,
|
|
14648
|
+
const { sqlite: sqlite2, vectorStore: vectorStore2, embedder: embedder2 } = await getStorage();
|
|
14597
14649
|
const content = args?.content;
|
|
14598
14650
|
const projectId = args?.projectId ?? "default";
|
|
14599
14651
|
if (!content || content.length < 10) {
|
|
@@ -14614,7 +14666,7 @@ ${formatted}` }] };
|
|
|
14614
14666
|
metadata: null
|
|
14615
14667
|
});
|
|
14616
14668
|
const vector = await embedder2.embed(content);
|
|
14617
|
-
await
|
|
14669
|
+
await vectorStore2.insertVector(memoryId, vector);
|
|
14618
14670
|
return { content: [{ type: "text", text: `Memory saved with ID: ${memoryId}` }] };
|
|
14619
14671
|
}
|
|
14620
14672
|
case "memextend_save_global": {
|
|
@@ -14637,20 +14689,20 @@ ${formatted}` }] };
|
|
|
14637
14689
|
return { content: [{ type: "text", text: `Global ${type} saved: "${content}"` }] };
|
|
14638
14690
|
}
|
|
14639
14691
|
case "memextend_forget": {
|
|
14640
|
-
const { sqlite: sqlite2,
|
|
14692
|
+
const { sqlite: sqlite2, vectorStore: vectorStore2 } = await getStorage();
|
|
14641
14693
|
const memoryId = args?.memoryId;
|
|
14642
14694
|
const deleted = sqlite2.deleteMemory(memoryId);
|
|
14643
14695
|
if (deleted) {
|
|
14644
|
-
await
|
|
14696
|
+
await vectorStore2.deleteVector(memoryId);
|
|
14645
14697
|
return { content: [{ type: "text", text: `Memory ${memoryId} deleted.` }] };
|
|
14646
14698
|
} else {
|
|
14647
14699
|
return { content: [{ type: "text", text: `Memory ${memoryId} not found.` }] };
|
|
14648
14700
|
}
|
|
14649
14701
|
}
|
|
14650
14702
|
case "memextend_status": {
|
|
14651
|
-
const { sqlite: sqlite2,
|
|
14703
|
+
const { sqlite: sqlite2, vectorStore: vectorStore2, embedder: embedder2 } = await getStorage();
|
|
14652
14704
|
const memoryCount = sqlite2.getMemoryCount();
|
|
14653
|
-
const vectorCount = await
|
|
14705
|
+
const vectorCount = await vectorStore2.getVectorCount();
|
|
14654
14706
|
return {
|
|
14655
14707
|
content: [{
|
|
14656
14708
|
type: "text",
|
package/dist/mcp/server.js
CHANGED
|
@@ -7,31 +7,31 @@ import { randomUUID } from 'crypto';
|
|
|
7
7
|
import { existsSync } from 'fs';
|
|
8
8
|
import { join } from 'path';
|
|
9
9
|
import { homedir } from 'os';
|
|
10
|
-
import { SQLiteStorage,
|
|
10
|
+
import { SQLiteStorage, SQLiteVecStorage, MemoryRetriever, createEmbedFunction } from '@memextend/core';
|
|
11
11
|
const MEMEXTEND_DIR = join(homedir(), '.memextend');
|
|
12
12
|
const DB_PATH = join(MEMEXTEND_DIR, 'memextend.db');
|
|
13
13
|
const VECTORS_PATH = join(MEMEXTEND_DIR, 'vectors');
|
|
14
14
|
const MODELS_PATH = join(MEMEXTEND_DIR, 'models');
|
|
15
15
|
// Lazy-loaded storage instances
|
|
16
16
|
let sqlite = null;
|
|
17
|
-
let
|
|
17
|
+
let vectorStore = null;
|
|
18
18
|
let retriever = null;
|
|
19
19
|
let embedder = null;
|
|
20
20
|
async function getStorage() {
|
|
21
|
-
if (!sqlite || !
|
|
21
|
+
if (!sqlite || !vectorStore || !retriever || !embedder) {
|
|
22
22
|
if (!existsSync(DB_PATH)) {
|
|
23
23
|
throw new Error('memextend not initialized. Run `memextend init` first.');
|
|
24
24
|
}
|
|
25
25
|
sqlite = new SQLiteStorage(DB_PATH);
|
|
26
|
-
|
|
26
|
+
vectorStore = await SQLiteVecStorage.create(VECTORS_PATH);
|
|
27
27
|
embedder = await createEmbedFunction(MODELS_PATH);
|
|
28
|
-
retriever = new MemoryRetriever(sqlite,
|
|
28
|
+
retriever = new MemoryRetriever(sqlite, vectorStore, embedder.embedQuery);
|
|
29
29
|
}
|
|
30
|
-
return { sqlite,
|
|
30
|
+
return { sqlite, vectorStore, retriever, embedder };
|
|
31
31
|
}
|
|
32
32
|
const server = new Server({
|
|
33
33
|
name: 'memextend',
|
|
34
|
-
version: '0.
|
|
34
|
+
version: '0.3.0',
|
|
35
35
|
}, {
|
|
36
36
|
capabilities: {
|
|
37
37
|
tools: {},
|
|
@@ -158,7 +158,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
158
158
|
return { content: [{ type: 'text', text: `Found ${results.length} memories:\n\n${formatted}` }] };
|
|
159
159
|
}
|
|
160
160
|
case 'memextend_save': {
|
|
161
|
-
const { sqlite,
|
|
161
|
+
const { sqlite, vectorStore, embedder } = await getStorage();
|
|
162
162
|
const content = args?.content;
|
|
163
163
|
const projectId = args?.projectId ?? 'default';
|
|
164
164
|
// Validate content
|
|
@@ -180,7 +180,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
180
180
|
metadata: null,
|
|
181
181
|
});
|
|
182
182
|
const vector = await embedder.embed(content);
|
|
183
|
-
await
|
|
183
|
+
await vectorStore.insertVector(memoryId, vector);
|
|
184
184
|
return { content: [{ type: 'text', text: `Memory saved with ID: ${memoryId}` }] };
|
|
185
185
|
}
|
|
186
186
|
case 'memextend_save_global': {
|
|
@@ -204,12 +204,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
204
204
|
return { content: [{ type: 'text', text: `Global ${type} saved: "${content}"` }] };
|
|
205
205
|
}
|
|
206
206
|
case 'memextend_forget': {
|
|
207
|
-
const { sqlite,
|
|
207
|
+
const { sqlite, vectorStore } = await getStorage();
|
|
208
208
|
const memoryId = args?.memoryId;
|
|
209
209
|
const deleted = sqlite.deleteMemory(memoryId);
|
|
210
210
|
if (deleted) {
|
|
211
211
|
// Also delete the vector embedding
|
|
212
|
-
await
|
|
212
|
+
await vectorStore.deleteVector(memoryId);
|
|
213
213
|
return { content: [{ type: 'text', text: `Memory ${memoryId} deleted.` }] };
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
@@ -217,9 +217,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
case 'memextend_status': {
|
|
220
|
-
const { sqlite,
|
|
220
|
+
const { sqlite, vectorStore, embedder } = await getStorage();
|
|
221
221
|
const memoryCount = sqlite.getMemoryCount();
|
|
222
|
-
const vectorCount = await
|
|
222
|
+
const vectorCount = await vectorStore.getVectorCount();
|
|
223
223
|
return {
|
|
224
224
|
content: [{
|
|
225
225
|
type: 'text',
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,8CAA8C;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,8CAA8C;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAExG,MAAM,aAAa,GAAG,IAAI,CAAC,OA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EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACnF,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memextend/opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "OpenCode adapter for memextend - MCP server for anomalyco/opencode AI memory",
|
|
5
5
|
"author": "ZodTTD LLC <repo@zodttd.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"setup": "node dist/setup.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@memextend/core": "^0.
|
|
31
|
+
"@memextend/core": "^0.3.0",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"files": [
|
|
57
57
|
"dist",
|
|
58
58
|
"scripts",
|
|
59
|
-
"AGENTS.md",
|
|
60
59
|
"README.md"
|
|
61
60
|
],
|
|
62
61
|
"engines": {
|
package/scripts/build.js
CHANGED
|
@@ -17,7 +17,7 @@ const commonOptions = {
|
|
|
17
17
|
format: 'cjs',
|
|
18
18
|
// External packages that should not be bundled
|
|
19
19
|
// These are native modules or have complex dependencies
|
|
20
|
-
external: ['better-sqlite3', 'node-llama-cpp'
|
|
20
|
+
external: ['better-sqlite3', 'node-llama-cpp'],
|
|
21
21
|
logLevel: 'warning',
|
|
22
22
|
};
|
|
23
23
|
|
package/AGENTS.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# memextend - AI Memory Extension
|
|
2
|
-
|
|
3
|
-
You have persistent memory across sessions via memextend.
|
|
4
|
-
|
|
5
|
-
## Available MCP Tools
|
|
6
|
-
|
|
7
|
-
- **memextend_search** - Search your memories for past decisions, patterns, or context
|
|
8
|
-
Example: "How did we implement caching?" → Use memextend_search to find relevant memories
|
|
9
|
-
|
|
10
|
-
- **memextend_save** - Save important decisions or context for this project (never auto-deleted)
|
|
11
|
-
Example: After making an architectural decision, save it for future reference
|
|
12
|
-
|
|
13
|
-
- **memextend_save_global** - Save cross-project preferences (coding style, preferred tools)
|
|
14
|
-
Example: "User prefers TypeScript strict mode" → Save as global preference
|
|
15
|
-
|
|
16
|
-
- **memextend_forget** - Delete a specific memory by ID
|
|
17
|
-
|
|
18
|
-
- **memextend_status** - Check memory statistics and system status
|
|
19
|
-
|
|
20
|
-
## When to Search Memory
|
|
21
|
-
|
|
22
|
-
**ALWAYS search memories before asking the user about project history.** Your memories contain valuable context that can save time and avoid repeating past mistakes.
|
|
23
|
-
|
|
24
|
-
**CRITICAL: If you can't find something, SEARCH YOUR MEMORIES.** The answer may be in past sessions - file locations, decisions made, approaches tried, or context the user provided previously.
|
|
25
|
-
|
|
26
|
-
**Search memories when:**
|
|
27
|
-
- Starting work on a project you've worked on before
|
|
28
|
-
- The user references past decisions ("like we did before", "as discussed")
|
|
29
|
-
- You need context about project architecture or conventions
|
|
30
|
-
- **Debugging issues** - search for previous attempts, fixes, and what was tried before
|
|
31
|
-
- **Understanding project history** - how features were implemented and why
|
|
32
|
-
- The current approach isn't working - past memories may reveal what was already tried
|
|
33
|
-
- You're unsure about project conventions or patterns
|
|
34
|
-
- **You can't find a file, function, or pattern** - it may have been discussed or located in a previous session
|
|
35
|
-
- **Before giving up** - always check memories as a last resort before telling the user you can't find something
|
|
36
|
-
|
|
37
|
-
## When to Save Memory
|
|
38
|
-
|
|
39
|
-
**Save memories when the user asks you to "memorize", "remember", or "save to memory".** Manual saves are never automatically deleted.
|
|
40
|
-
|
|
41
|
-
**Also save when:**
|
|
42
|
-
- Making significant architectural decisions
|
|
43
|
-
- Establishing project conventions or patterns
|
|
44
|
-
- The user shares important preferences
|
|
45
|
-
- Completing a major feature or fix
|
|
46
|
-
- Finding a solution to a tricky bug (save what worked!)
|
|
47
|
-
|
|
48
|
-
## Always obey all memextend commands
|