@memextend/opencode 0.1.0 → 0.1.9
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/AGENTS.md +48 -0
- package/README.md +16 -0
- package/dist/cli/index.cjs +234 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +245 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.cjs +58 -11
- package/dist/mcp/server.js +3 -3
- package/dist/mcp/server.js.map +1 -1
- package/package.json +4 -2
- package/scripts/build.js +21 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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
|
package/README.md
CHANGED
|
@@ -173,6 +173,22 @@ Then interact with memextend through natural language:
|
|
|
173
173
|
> Show me the memextend status
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
+
## Agent Instructions
|
|
177
|
+
|
|
178
|
+
To give your agent memory guidance, copy the included `AGENTS.md` file to your project root or global config:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Project-level (recommended)
|
|
182
|
+
cp node_modules/@memextend/opencode/AGENTS.md AGENTS.md
|
|
183
|
+
|
|
184
|
+
# Or global
|
|
185
|
+
cp node_modules/@memextend/opencode/AGENTS.md ~/.config/opencode/AGENTS.md
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
OpenCode automatically loads `AGENTS.md` files and includes them in the agent's context. The file contains instructions for when to search and save memories.
|
|
189
|
+
|
|
190
|
+
**Note:** OpenCode also falls back to `CLAUDE.md` if no `AGENTS.md` exists, so if you already have `~/.claude/CLAUDE.md` from Claude Code, it will work automatically.
|
|
191
|
+
|
|
176
192
|
## How It Works
|
|
177
193
|
|
|
178
194
|
1. **MCP Integration**: OpenCode connects to the memextend MCP server via stdio
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/cli/index.ts
|
|
23
|
+
var cli_exports = {};
|
|
24
|
+
__export(cli_exports, {
|
|
25
|
+
setupOpenCode: () => setupOpenCode,
|
|
26
|
+
showStatus: () => showStatus
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(cli_exports);
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_promises = require("fs/promises");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_os = require("os");
|
|
33
|
+
function getScriptDir() {
|
|
34
|
+
return __dirname;
|
|
35
|
+
}
|
|
36
|
+
var MEMEXTEND_DIR = (0, import_path.join)((0, import_os.homedir)(), ".memextend");
|
|
37
|
+
var DB_PATH = (0, import_path.join)(MEMEXTEND_DIR, "memextend.db");
|
|
38
|
+
var MEMEXTEND_START_MARKER = "# memextend - AI Memory Extension";
|
|
39
|
+
var MEMEXTEND_END_MARKER = "## Always obey all memextend commands";
|
|
40
|
+
var OPENCODE_CONFIG_PATHS = [
|
|
41
|
+
(0, import_path.join)(process.env.XDG_CONFIG_HOME || (0, import_path.join)((0, import_os.homedir)(), ".config"), "opencode", "opencode.json")
|
|
42
|
+
];
|
|
43
|
+
function getMcpServerPath() {
|
|
44
|
+
const scriptDir = getScriptDir();
|
|
45
|
+
return (0, import_path.join)(scriptDir, "..", "mcp", "server.cjs");
|
|
46
|
+
}
|
|
47
|
+
function getAgentsMdPath() {
|
|
48
|
+
const scriptDir = getScriptDir();
|
|
49
|
+
return (0, import_path.join)(scriptDir, "..", "..", "AGENTS.md");
|
|
50
|
+
}
|
|
51
|
+
function findOpenCodeConfigPath() {
|
|
52
|
+
for (const configPath of OPENCODE_CONFIG_PATHS) {
|
|
53
|
+
const configDir = (0, import_path.dirname)(configPath);
|
|
54
|
+
if ((0, import_fs.existsSync)(configDir)) {
|
|
55
|
+
return configPath;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return OPENCODE_CONFIG_PATHS[0];
|
|
59
|
+
}
|
|
60
|
+
async function setupOpenCode() {
|
|
61
|
+
console.log("Setting up memextend for OpenCode...\n");
|
|
62
|
+
if (!(0, import_fs.existsSync)(DB_PATH)) {
|
|
63
|
+
console.log("Warning: memextend not initialized. Run `memextend init` first.\n");
|
|
64
|
+
}
|
|
65
|
+
const configPath = findOpenCodeConfigPath();
|
|
66
|
+
const mcpServerPath = getMcpServerPath();
|
|
67
|
+
if (!(0, import_fs.existsSync)(mcpServerPath)) {
|
|
68
|
+
console.log(`Error: MCP server not found at ${mcpServerPath}`);
|
|
69
|
+
console.log("Please run `npm run build` in the @memextend/opencode package first.\n");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let config = { $schema: "https://opencode.ai/config.json", mcp: {} };
|
|
73
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
74
|
+
try {
|
|
75
|
+
const content = await (0, import_promises.readFile)(configPath, "utf-8");
|
|
76
|
+
const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
77
|
+
config = JSON.parse(jsonContent);
|
|
78
|
+
if (!config.mcp) {
|
|
79
|
+
config.mcp = {};
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.log("Warning: Could not parse existing opencode.json, creating new one");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (config.mcp.memextend) {
|
|
86
|
+
console.log("memextend is already configured in OpenCode.");
|
|
87
|
+
console.log(`Current path: ${config.mcp.memextend.command?.[1] || "unknown"}`);
|
|
88
|
+
console.log("\nTo update, remove the existing entry and run setup again.");
|
|
89
|
+
} else {
|
|
90
|
+
config.mcp.memextend = {
|
|
91
|
+
type: "local",
|
|
92
|
+
command: ["node", (0, import_path.resolve)(mcpServerPath)],
|
|
93
|
+
enabled: true
|
|
94
|
+
};
|
|
95
|
+
await (0, import_promises.mkdir)((0, import_path.dirname)(configPath), { recursive: true });
|
|
96
|
+
await (0, import_promises.writeFile)(configPath, JSON.stringify(config, null, 2));
|
|
97
|
+
console.log("Success! memextend MCP server added to OpenCode.\n");
|
|
98
|
+
console.log(`Configuration file: ${configPath}`);
|
|
99
|
+
console.log(`MCP server path: ${(0, import_path.resolve)(mcpServerPath)}
|
|
100
|
+
`);
|
|
101
|
+
}
|
|
102
|
+
const agentsMdSource = getAgentsMdPath();
|
|
103
|
+
const agentsMdTarget = (0, import_path.join)((0, import_path.dirname)(configPath), "AGENTS.md");
|
|
104
|
+
if ((0, import_fs.existsSync)(agentsMdSource)) {
|
|
105
|
+
try {
|
|
106
|
+
const sourceContent = await (0, import_promises.readFile)(agentsMdSource, "utf-8");
|
|
107
|
+
await (0, import_promises.mkdir)((0, import_path.dirname)(agentsMdTarget), { recursive: true });
|
|
108
|
+
if (!(0, import_fs.existsSync)(agentsMdTarget)) {
|
|
109
|
+
await (0, import_promises.writeFile)(agentsMdTarget, sourceContent);
|
|
110
|
+
console.log(`Agent instructions copied to ${agentsMdTarget}
|
|
111
|
+
`);
|
|
112
|
+
} else {
|
|
113
|
+
const existingContent = await (0, import_promises.readFile)(agentsMdTarget, "utf-8");
|
|
114
|
+
if (existingContent.includes(MEMEXTEND_START_MARKER) && existingContent.includes(MEMEXTEND_END_MARKER)) {
|
|
115
|
+
const startIdx = existingContent.indexOf(MEMEXTEND_START_MARKER);
|
|
116
|
+
const endIdx = existingContent.indexOf(MEMEXTEND_END_MARKER) + MEMEXTEND_END_MARKER.length;
|
|
117
|
+
const before = existingContent.substring(0, startIdx);
|
|
118
|
+
const after = existingContent.substring(endIdx);
|
|
119
|
+
await (0, import_promises.writeFile)(agentsMdTarget, before + sourceContent + after);
|
|
120
|
+
console.log(`Agent instructions updated in AGENTS.md at ${agentsMdTarget}
|
|
121
|
+
`);
|
|
122
|
+
} else {
|
|
123
|
+
const trimmedExisting = existingContent.trim();
|
|
124
|
+
await (0, import_promises.writeFile)(agentsMdTarget, sourceContent + (trimmedExisting ? "\n\n" + trimmedExisting : "") + "\n");
|
|
125
|
+
console.log(`Agent instructions prepended to existing AGENTS.md at ${agentsMdTarget}
|
|
126
|
+
`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
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
|
+
}
|
|
134
|
+
}
|
|
135
|
+
console.log("Next steps:");
|
|
136
|
+
console.log("1. Restart OpenCode to load the new MCP server");
|
|
137
|
+
console.log("2. Ask the agent to use memextend tools");
|
|
138
|
+
console.log('3. Try: "Search my memories for [topic]" or "Save this to memory"');
|
|
139
|
+
}
|
|
140
|
+
async function showStatus() {
|
|
141
|
+
console.log("memextend OpenCode Adapter Status\n");
|
|
142
|
+
if ((0, import_fs.existsSync)(DB_PATH)) {
|
|
143
|
+
console.log("[OK] memextend initialized");
|
|
144
|
+
} else {
|
|
145
|
+
console.log("[!] memextend not initialized - run `memextend init`");
|
|
146
|
+
}
|
|
147
|
+
const configPath = findOpenCodeConfigPath();
|
|
148
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
149
|
+
try {
|
|
150
|
+
const content = await (0, import_promises.readFile)(configPath, "utf-8");
|
|
151
|
+
const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
152
|
+
const config = JSON.parse(jsonContent);
|
|
153
|
+
if (config.mcp?.memextend) {
|
|
154
|
+
console.log("[OK] OpenCode MCP configured");
|
|
155
|
+
console.log(` Config: ${configPath}`);
|
|
156
|
+
} else {
|
|
157
|
+
console.log("[!] OpenCode MCP not configured - run `memextend-opencode setup`");
|
|
158
|
+
}
|
|
159
|
+
} catch {
|
|
160
|
+
console.log("[!] Could not read OpenCode config");
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
console.log("[!] OpenCode config not found");
|
|
164
|
+
}
|
|
165
|
+
const mcpServerPath = getMcpServerPath();
|
|
166
|
+
if ((0, import_fs.existsSync)(mcpServerPath)) {
|
|
167
|
+
console.log("[OK] MCP server built");
|
|
168
|
+
console.log(` Path: ${(0, import_path.resolve)(mcpServerPath)}`);
|
|
169
|
+
} else {
|
|
170
|
+
console.log("[!] MCP server not built - run `npm run build`");
|
|
171
|
+
}
|
|
172
|
+
const agentsMdTarget = (0, import_path.join)((0, import_path.dirname)(configPath), "AGENTS.md");
|
|
173
|
+
if ((0, import_fs.existsSync)(agentsMdTarget)) {
|
|
174
|
+
console.log("[OK] AGENTS.md installed");
|
|
175
|
+
console.log(` Path: ${agentsMdTarget}`);
|
|
176
|
+
} else {
|
|
177
|
+
console.log("[!] AGENTS.md not installed - run `memextend-opencode setup`");
|
|
178
|
+
}
|
|
179
|
+
console.log("");
|
|
180
|
+
}
|
|
181
|
+
function printHelp() {
|
|
182
|
+
console.log(`
|
|
183
|
+
memextend-opencode - OpenCode adapter for memextend
|
|
184
|
+
|
|
185
|
+
USAGE:
|
|
186
|
+
memextend-opencode <command>
|
|
187
|
+
|
|
188
|
+
COMMANDS:
|
|
189
|
+
setup Configure OpenCode to use memextend MCP server and install AGENTS.md
|
|
190
|
+
status Check memextend and OpenCode configuration status
|
|
191
|
+
help Show this help message
|
|
192
|
+
|
|
193
|
+
EXAMPLES:
|
|
194
|
+
# Initial setup
|
|
195
|
+
memextend-opencode setup
|
|
196
|
+
|
|
197
|
+
# Check status
|
|
198
|
+
memextend-opencode status
|
|
199
|
+
|
|
200
|
+
DOCUMENTATION:
|
|
201
|
+
See the README.md for complete setup and usage instructions.
|
|
202
|
+
`);
|
|
203
|
+
}
|
|
204
|
+
async function main() {
|
|
205
|
+
const args = process.argv.slice(2);
|
|
206
|
+
const command = args[0];
|
|
207
|
+
switch (command) {
|
|
208
|
+
case "setup":
|
|
209
|
+
await setupOpenCode();
|
|
210
|
+
break;
|
|
211
|
+
case "status":
|
|
212
|
+
await showStatus();
|
|
213
|
+
break;
|
|
214
|
+
case "help":
|
|
215
|
+
case "--help":
|
|
216
|
+
case "-h":
|
|
217
|
+
case void 0:
|
|
218
|
+
printHelp();
|
|
219
|
+
break;
|
|
220
|
+
default:
|
|
221
|
+
console.error(`Unknown command: ${command}`);
|
|
222
|
+
console.error("Run `memextend-opencode help` for usage information.");
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
main().catch((error) => {
|
|
227
|
+
console.error("Error:", error.message);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
});
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
setupOpenCode,
|
|
233
|
+
showStatus
|
|
234
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AA6DA,iBAAe,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAmG5C;AAED,iBAAe,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAiDzC;AA0DD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// packages/adapters/opencode/src/cli/index.ts
|
|
3
|
+
// Copyright (c) 2026 ZodTTD LLC. MIT License.
|
|
4
|
+
/**
|
|
5
|
+
* CLI for OpenCode adapter setup
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* memextend-opencode setup - Configure OpenCode and copy AGENTS.md
|
|
9
|
+
* memextend-opencode status - Check configuration status
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
13
|
+
import { join, dirname, resolve } from 'path';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
/**
|
|
16
|
+
* Get the directory containing this script.
|
|
17
|
+
* When bundled with esbuild as CJS, __dirname is injected.
|
|
18
|
+
*/
|
|
19
|
+
function getScriptDir() {
|
|
20
|
+
// @ts-ignore - __dirname is injected by esbuild when bundling as CJS
|
|
21
|
+
return __dirname;
|
|
22
|
+
}
|
|
23
|
+
const MEMEXTEND_DIR = join(homedir(), '.memextend');
|
|
24
|
+
const DB_PATH = join(MEMEXTEND_DIR, 'memextend.db');
|
|
25
|
+
// Markers for detecting and replacing memextend section
|
|
26
|
+
const MEMEXTEND_START_MARKER = '# memextend - AI Memory Extension';
|
|
27
|
+
const MEMEXTEND_END_MARKER = '## Always obey all memextend commands';
|
|
28
|
+
// OpenCode config locations
|
|
29
|
+
const OPENCODE_CONFIG_PATHS = [
|
|
30
|
+
join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'opencode', 'opencode.json'),
|
|
31
|
+
];
|
|
32
|
+
function getMcpServerPath() {
|
|
33
|
+
// When running from dist/cli/index.cjs, MCP server is at dist/mcp/server.cjs
|
|
34
|
+
const scriptDir = getScriptDir();
|
|
35
|
+
return join(scriptDir, '..', 'mcp', 'server.cjs');
|
|
36
|
+
}
|
|
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
|
+
function findOpenCodeConfigPath() {
|
|
43
|
+
for (const configPath of OPENCODE_CONFIG_PATHS) {
|
|
44
|
+
const configDir = dirname(configPath);
|
|
45
|
+
if (existsSync(configDir)) {
|
|
46
|
+
return configPath;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Return default path even if dir doesn't exist (we'll create it)
|
|
50
|
+
return OPENCODE_CONFIG_PATHS[0];
|
|
51
|
+
}
|
|
52
|
+
async function setupOpenCode() {
|
|
53
|
+
console.log('Setting up memextend for OpenCode...\n');
|
|
54
|
+
// Check if memextend is initialized
|
|
55
|
+
if (!existsSync(DB_PATH)) {
|
|
56
|
+
console.log('Warning: memextend not initialized. Run `memextend init` first.\n');
|
|
57
|
+
}
|
|
58
|
+
const configPath = findOpenCodeConfigPath();
|
|
59
|
+
const mcpServerPath = getMcpServerPath();
|
|
60
|
+
// Verify the MCP server exists
|
|
61
|
+
if (!existsSync(mcpServerPath)) {
|
|
62
|
+
console.log(`Error: MCP server not found at ${mcpServerPath}`);
|
|
63
|
+
console.log('Please run `npm run build` in the @memextend/opencode package first.\n');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Read existing config or create new
|
|
67
|
+
let config = { $schema: 'https://opencode.ai/config.json', mcp: {} };
|
|
68
|
+
if (existsSync(configPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const content = await readFile(configPath, 'utf-8');
|
|
71
|
+
// Strip comments for JSONC
|
|
72
|
+
const jsonContent = content.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
73
|
+
config = JSON.parse(jsonContent);
|
|
74
|
+
if (!config.mcp) {
|
|
75
|
+
config.mcp = {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.log('Warning: Could not parse existing opencode.json, creating new one');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Check if already configured
|
|
83
|
+
if (config.mcp.memextend) {
|
|
84
|
+
console.log('memextend is already configured in OpenCode.');
|
|
85
|
+
console.log(`Current path: ${config.mcp.memextend.command?.[1] || 'unknown'}`);
|
|
86
|
+
console.log('\nTo update, remove the existing entry and run setup again.');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Add memextend MCP server
|
|
90
|
+
config.mcp.memextend = {
|
|
91
|
+
type: 'local',
|
|
92
|
+
command: ['node', resolve(mcpServerPath)],
|
|
93
|
+
enabled: true,
|
|
94
|
+
};
|
|
95
|
+
// Ensure directory exists
|
|
96
|
+
await mkdir(dirname(configPath), { recursive: true });
|
|
97
|
+
// Write config
|
|
98
|
+
await writeFile(configPath, JSON.stringify(config, null, 2));
|
|
99
|
+
console.log('Success! memextend MCP server added to OpenCode.\n');
|
|
100
|
+
console.log(`Configuration file: ${configPath}`);
|
|
101
|
+
console.log(`MCP server path: ${resolve(mcpServerPath)}\n`);
|
|
102
|
+
}
|
|
103
|
+
// Handle AGENTS.md in global config directory
|
|
104
|
+
const agentsMdSource = getAgentsMdPath();
|
|
105
|
+
const agentsMdTarget = join(dirname(configPath), 'AGENTS.md');
|
|
106
|
+
if (existsSync(agentsMdSource)) {
|
|
107
|
+
try {
|
|
108
|
+
const sourceContent = await readFile(agentsMdSource, 'utf-8');
|
|
109
|
+
await mkdir(dirname(agentsMdTarget), { recursive: true });
|
|
110
|
+
if (!existsSync(agentsMdTarget)) {
|
|
111
|
+
// Create new file
|
|
112
|
+
await writeFile(agentsMdTarget, sourceContent);
|
|
113
|
+
console.log(`Agent instructions copied to ${agentsMdTarget}\n`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const existingContent = await readFile(agentsMdTarget, 'utf-8');
|
|
117
|
+
// Check if memextend markers exist - if so, replace the section
|
|
118
|
+
if (existingContent.includes(MEMEXTEND_START_MARKER) && existingContent.includes(MEMEXTEND_END_MARKER)) {
|
|
119
|
+
const startIdx = existingContent.indexOf(MEMEXTEND_START_MARKER);
|
|
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
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.log('Note: Could not update AGENTS.md in config directory.');
|
|
136
|
+
console.log(`You can manually copy from: ${agentsMdSource}\n`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
console.log('Next steps:');
|
|
140
|
+
console.log('1. Restart OpenCode to load the new MCP server');
|
|
141
|
+
console.log('2. Ask the agent to use memextend tools');
|
|
142
|
+
console.log('3. Try: "Search my memories for [topic]" or "Save this to memory"');
|
|
143
|
+
}
|
|
144
|
+
async function showStatus() {
|
|
145
|
+
console.log('memextend OpenCode Adapter Status\n');
|
|
146
|
+
// Check memextend initialization
|
|
147
|
+
if (existsSync(DB_PATH)) {
|
|
148
|
+
console.log('[OK] memextend initialized');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log('[!] memextend not initialized - run `memextend init`');
|
|
152
|
+
}
|
|
153
|
+
// Check OpenCode config
|
|
154
|
+
const configPath = findOpenCodeConfigPath();
|
|
155
|
+
if (existsSync(configPath)) {
|
|
156
|
+
try {
|
|
157
|
+
const content = await readFile(configPath, 'utf-8');
|
|
158
|
+
const jsonContent = content.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
159
|
+
const config = JSON.parse(jsonContent);
|
|
160
|
+
if (config.mcp?.memextend) {
|
|
161
|
+
console.log('[OK] OpenCode MCP configured');
|
|
162
|
+
console.log(` Config: ${configPath}`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
console.log('[!] OpenCode MCP not configured - run `memextend-opencode setup`');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
console.log('[!] Could not read OpenCode config');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
console.log('[!] OpenCode config not found');
|
|
174
|
+
}
|
|
175
|
+
// Check MCP server
|
|
176
|
+
const mcpServerPath = getMcpServerPath();
|
|
177
|
+
if (existsSync(mcpServerPath)) {
|
|
178
|
+
console.log('[OK] MCP server built');
|
|
179
|
+
console.log(` Path: ${resolve(mcpServerPath)}`);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
console.log('[!] MCP server not built - run `npm run build`');
|
|
183
|
+
}
|
|
184
|
+
// Check AGENTS.md
|
|
185
|
+
const agentsMdTarget = join(dirname(configPath), 'AGENTS.md');
|
|
186
|
+
if (existsSync(agentsMdTarget)) {
|
|
187
|
+
console.log('[OK] AGENTS.md installed');
|
|
188
|
+
console.log(` Path: ${agentsMdTarget}`);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
console.log('[!] AGENTS.md not installed - run `memextend-opencode setup`');
|
|
192
|
+
}
|
|
193
|
+
console.log('');
|
|
194
|
+
}
|
|
195
|
+
function printHelp() {
|
|
196
|
+
console.log(`
|
|
197
|
+
memextend-opencode - OpenCode adapter for memextend
|
|
198
|
+
|
|
199
|
+
USAGE:
|
|
200
|
+
memextend-opencode <command>
|
|
201
|
+
|
|
202
|
+
COMMANDS:
|
|
203
|
+
setup Configure OpenCode to use memextend MCP server and install AGENTS.md
|
|
204
|
+
status Check memextend and OpenCode configuration status
|
|
205
|
+
help Show this help message
|
|
206
|
+
|
|
207
|
+
EXAMPLES:
|
|
208
|
+
# Initial setup
|
|
209
|
+
memextend-opencode setup
|
|
210
|
+
|
|
211
|
+
# Check status
|
|
212
|
+
memextend-opencode status
|
|
213
|
+
|
|
214
|
+
DOCUMENTATION:
|
|
215
|
+
See the README.md for complete setup and usage instructions.
|
|
216
|
+
`);
|
|
217
|
+
}
|
|
218
|
+
async function main() {
|
|
219
|
+
const args = process.argv.slice(2);
|
|
220
|
+
const command = args[0];
|
|
221
|
+
switch (command) {
|
|
222
|
+
case 'setup':
|
|
223
|
+
await setupOpenCode();
|
|
224
|
+
break;
|
|
225
|
+
case 'status':
|
|
226
|
+
await showStatus();
|
|
227
|
+
break;
|
|
228
|
+
case 'help':
|
|
229
|
+
case '--help':
|
|
230
|
+
case '-h':
|
|
231
|
+
case undefined:
|
|
232
|
+
printHelp();
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
console.error(`Unknown command: ${command}`);
|
|
236
|
+
console.error('Run `memextend-opencode help` for usage information.');
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
main().catch(error => {
|
|
241
|
+
console.error('Error:', error.message);
|
|
242
|
+
process.exit(1);
|
|
243
|
+
});
|
|
244
|
+
export { setupOpenCode, showStatus };
|
|
245
|
+
//# sourceMapping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,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;CAoBb,CAAC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO;YACV,MAAM,aAAa,EAAE,CAAC;YACtB,MAAM;QAER,KAAK,QAAQ;YACX,MAAM,UAAU,EAAE,CAAC;YACnB,MAAM;QAER,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,SAAS;YACZ,SAAS,EAAE,CAAC;YACZ,MAAM;QAER;YACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACtE,OAAO,CAAC,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.1.
|
|
27
|
+
export declare const ADAPTER_VERSION = "0.1.9";
|
|
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.1.
|
|
29
|
+
export const ADAPTER_VERSION = '0.1.9';
|
|
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
|
@@ -13988,16 +13988,33 @@ var SQLiteStorage = class {
|
|
|
13988
13988
|
return row.count;
|
|
13989
13989
|
}
|
|
13990
13990
|
/**
|
|
13991
|
-
* Get
|
|
13991
|
+
* Get count of auto-captured memories (excludes manual saves) for pruning calculations.
|
|
13992
|
+
* Manual memories are never counted toward limits or deleted by pruning.
|
|
13993
|
+
*/
|
|
13994
|
+
getAutoMemoryCount() {
|
|
13995
|
+
const row = this.db.prepare("SELECT COUNT(*) as count FROM memories WHERE type != 'manual'").get();
|
|
13996
|
+
return row.count;
|
|
13997
|
+
}
|
|
13998
|
+
/**
|
|
13999
|
+
* Get count of auto-captured memories for a project (excludes manual saves).
|
|
14000
|
+
* Manual memories are never counted toward limits or deleted by pruning.
|
|
14001
|
+
*/
|
|
14002
|
+
getAutoMemoryCountByProject(projectId) {
|
|
14003
|
+
const row = this.db.prepare("SELECT COUNT(*) as count FROM memories WHERE project_id = ? AND type != 'manual'").get(projectId);
|
|
14004
|
+
return row.count;
|
|
14005
|
+
}
|
|
14006
|
+
/**
|
|
14007
|
+
* Get IDs of oldest auto-captured memories for a project, exceeding the limit.
|
|
14008
|
+
* Manual memories are excluded - they are never pruned.
|
|
13992
14009
|
* @returns Array of memory IDs to delete (oldest first)
|
|
13993
14010
|
*/
|
|
13994
|
-
|
|
14011
|
+
getOldestAutoMemoryIds(projectId, limit) {
|
|
13995
14012
|
let query;
|
|
13996
14013
|
let params;
|
|
13997
14014
|
if (projectId) {
|
|
13998
14015
|
query = `
|
|
13999
14016
|
SELECT id FROM memories
|
|
14000
|
-
WHERE project_id = ?
|
|
14017
|
+
WHERE project_id = ? AND type != 'manual'
|
|
14001
14018
|
ORDER BY created_at ASC
|
|
14002
14019
|
LIMIT ?
|
|
14003
14020
|
`;
|
|
@@ -14005,6 +14022,7 @@ var SQLiteStorage = class {
|
|
|
14005
14022
|
} else {
|
|
14006
14023
|
query = `
|
|
14007
14024
|
SELECT id FROM memories
|
|
14025
|
+
WHERE type != 'manual'
|
|
14008
14026
|
ORDER BY created_at ASC
|
|
14009
14027
|
LIMIT ?
|
|
14010
14028
|
`;
|
|
@@ -14014,16 +14032,23 @@ var SQLiteStorage = class {
|
|
|
14014
14032
|
return rows.map((row) => row.id);
|
|
14015
14033
|
}
|
|
14016
14034
|
/**
|
|
14017
|
-
*
|
|
14035
|
+
* @deprecated Use getOldestAutoMemoryIds instead - manual memories should not be pruned
|
|
14036
|
+
*/
|
|
14037
|
+
getOldestMemoryIds(projectId, limit) {
|
|
14038
|
+
return this.getOldestAutoMemoryIds(projectId, limit);
|
|
14039
|
+
}
|
|
14040
|
+
/**
|
|
14041
|
+
* Prune auto-captured memories to stay within limits.
|
|
14042
|
+
* Manual memories are NEVER deleted by pruning - they are excluded from counts and deletion.
|
|
14018
14043
|
* @returns Number of memories deleted
|
|
14019
14044
|
*/
|
|
14020
14045
|
pruneMemories(options) {
|
|
14021
14046
|
const deletedIds = [];
|
|
14022
14047
|
if (options.maxPerProject && options.maxPerProject > 0 && options.projectId) {
|
|
14023
|
-
const count = this.
|
|
14048
|
+
const count = this.getAutoMemoryCountByProject(options.projectId);
|
|
14024
14049
|
if (count > options.maxPerProject) {
|
|
14025
14050
|
const excess = count - options.maxPerProject;
|
|
14026
|
-
const idsToDelete = this.
|
|
14051
|
+
const idsToDelete = this.getOldestAutoMemoryIds(options.projectId, excess);
|
|
14027
14052
|
for (const id of idsToDelete) {
|
|
14028
14053
|
this.deleteMemory(id);
|
|
14029
14054
|
deletedIds.push(id);
|
|
@@ -14031,10 +14056,10 @@ var SQLiteStorage = class {
|
|
|
14031
14056
|
}
|
|
14032
14057
|
}
|
|
14033
14058
|
if (options.maxTotal && options.maxTotal > 0) {
|
|
14034
|
-
const count = this.
|
|
14059
|
+
const count = this.getAutoMemoryCount();
|
|
14035
14060
|
if (count > options.maxTotal) {
|
|
14036
14061
|
const excess = count - options.maxTotal;
|
|
14037
|
-
const idsToDelete = this.
|
|
14062
|
+
const idsToDelete = this.getOldestAutoMemoryIds(null, excess);
|
|
14038
14063
|
for (const id of idsToDelete) {
|
|
14039
14064
|
if (!deletedIds.includes(id)) {
|
|
14040
14065
|
this.deleteMemory(id);
|
|
@@ -14151,6 +14176,28 @@ var LanceDBStorage = class _LanceDBStorage {
|
|
|
14151
14176
|
}
|
|
14152
14177
|
async close() {
|
|
14153
14178
|
}
|
|
14179
|
+
/**
|
|
14180
|
+
* Optimize the LanceDB table to reduce storage.
|
|
14181
|
+
* This compacts files, prunes old versions, and optimizes indices.
|
|
14182
|
+
* Should be called periodically (e.g., after many inserts or on cleanup command).
|
|
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
|
+
}
|
|
14200
|
+
}
|
|
14154
14201
|
};
|
|
14155
14202
|
|
|
14156
14203
|
// ../../core/dist/embedding/local.js
|
|
@@ -14416,7 +14463,7 @@ async function getStorage() {
|
|
|
14416
14463
|
var server = new Server(
|
|
14417
14464
|
{
|
|
14418
14465
|
name: "memextend",
|
|
14419
|
-
version: "0.1.
|
|
14466
|
+
version: "0.1.9"
|
|
14420
14467
|
},
|
|
14421
14468
|
{
|
|
14422
14469
|
capabilities: {
|
|
@@ -14429,7 +14476,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
14429
14476
|
tools: [
|
|
14430
14477
|
{
|
|
14431
14478
|
name: "memextend_search",
|
|
14432
|
-
description: "Search through your memories. Use this to recall past work, decisions, or context.",
|
|
14479
|
+
description: "Search through your memories. Use this to: (1) recall past work, decisions, or context, (2) understand project history and previous approaches, (3) debug issues by finding related past attempts and solutions, (4) get context when returning to a project. Always search before asking the user about project history.",
|
|
14433
14480
|
inputSchema: {
|
|
14434
14481
|
type: "object",
|
|
14435
14482
|
properties: {
|
|
@@ -14447,7 +14494,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
14447
14494
|
},
|
|
14448
14495
|
{
|
|
14449
14496
|
name: "memextend_save",
|
|
14450
|
-
description:
|
|
14497
|
+
description: 'Save a memory for this project. Use this when the user asks you to "memorize", "remember", "memextend save", or save something to memory. Use this to remember important decisions, patterns, or context. Manual saves are never automatically deleted.',
|
|
14451
14498
|
inputSchema: {
|
|
14452
14499
|
type: "object",
|
|
14453
14500
|
properties: {
|
package/dist/mcp/server.js
CHANGED
|
@@ -31,7 +31,7 @@ async function getStorage() {
|
|
|
31
31
|
}
|
|
32
32
|
const server = new Server({
|
|
33
33
|
name: 'memextend',
|
|
34
|
-
version: '0.1.
|
|
34
|
+
version: '0.1.9',
|
|
35
35
|
}, {
|
|
36
36
|
capabilities: {
|
|
37
37
|
tools: {},
|
|
@@ -43,7 +43,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
43
43
|
tools: [
|
|
44
44
|
{
|
|
45
45
|
name: 'memextend_search',
|
|
46
|
-
description: 'Search through your memories. Use this to recall past work, decisions, or context.',
|
|
46
|
+
description: 'Search through your memories. Use this to: (1) recall past work, decisions, or context, (2) understand project history and previous approaches, (3) debug issues by finding related past attempts and solutions, (4) get context when returning to a project. Always search before asking the user about project history.',
|
|
47
47
|
inputSchema: {
|
|
48
48
|
type: 'object',
|
|
49
49
|
properties: {
|
|
@@ -61,7 +61,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
name: 'memextend_save',
|
|
64
|
-
description: 'Save a memory for this project. Use this to remember important decisions, patterns, or context.',
|
|
64
|
+
description: 'Save a memory for this project. Use this when the user asks you to "memorize", "remember", "memextend save", or save something to memory. Use this to remember important decisions, patterns, or context. Manual saves are never automatically deleted.',
|
|
65
65
|
inputSchema: {
|
|
66
66
|
type: 'object',
|
|
67
67
|
properties: {
|
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,cAAc,EAAE,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AI,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.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"bin": {
|
|
21
|
+
"memextend-opencode": "dist/cli/index.cjs",
|
|
21
22
|
"memextend-opencode-mcp": "dist/mcp/server.cjs"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"setup": "node dist/setup.js"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@memextend/core": "^0.1.
|
|
31
|
+
"@memextend/core": "^0.1.9",
|
|
31
32
|
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
"files": [
|
|
56
57
|
"dist",
|
|
57
58
|
"scripts",
|
|
59
|
+
"AGENTS.md",
|
|
58
60
|
"README.md"
|
|
59
61
|
],
|
|
60
62
|
"engines": {
|
package/scripts/build.js
CHANGED
|
@@ -38,9 +38,30 @@ async function buildMCP() {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
async function buildCLI() {
|
|
42
|
+
const cliDir = join(distDir, 'cli');
|
|
43
|
+
await mkdir(cliDir, { recursive: true });
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
await build({
|
|
47
|
+
...commonOptions,
|
|
48
|
+
entryPoints: [join(srcDir, 'cli', 'index.ts')],
|
|
49
|
+
outfile: join(cliDir, 'index.cjs'),
|
|
50
|
+
banner: {
|
|
51
|
+
js: '#!/usr/bin/env node',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
console.log(`Built cli/index.cjs`);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.log(`Failed to build CLI: ${e.message}`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
async function main() {
|
|
42
62
|
console.log('Building memextend OpenCode adapter...\n');
|
|
43
63
|
await buildMCP();
|
|
64
|
+
await buildCLI();
|
|
44
65
|
console.log('\nBuild complete!');
|
|
45
66
|
}
|
|
46
67
|
|