@memextend/opencode 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.
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ # @memextend/opencode
2
+
3
+ > OpenCode adapter for memextend - Memory extension for AI coding agents
4
+
5
+ **Status:** ⚠️ **Experimental/Untested** - This adapter was developed based on OpenCode's MCP documentation but has not been tested in a production OpenCode environment. Community feedback and contributions are welcome!
6
+
7
+ This adapter provides memextend integration for [OpenCode](https://github.com/anomalyco/opencode) by Anomaly, an open-source AI coding agent.
8
+
9
+ ## Features
10
+
11
+ - MCP (Model Context Protocol) server for mid-session memory operations
12
+ - Search through past work and decisions
13
+ - Save important context and patterns
14
+ - Store global preferences across projects
15
+ - Semantic search using vector embeddings
16
+
17
+ ## Requirements
18
+
19
+ - Node.js 18+
20
+ - OpenCode installed (`npm i -g opencode-ai`)
21
+ - memextend CLI initialized (`memextend init`)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ # Install the adapter
27
+ npm install @memextend/opencode
28
+
29
+ # Or if using the memextend monorepo
30
+ pnpm install
31
+ pnpm build
32
+ ```
33
+
34
+ ## Configuration
35
+
36
+ ### Option 1: Global Configuration
37
+
38
+ Add memextend to your global OpenCode configuration at `~/.config/opencode/opencode.json`:
39
+
40
+ ```json
41
+ {
42
+ "$schema": "https://opencode.ai/config.json",
43
+ "mcp": {
44
+ "memextend": {
45
+ "type": "local",
46
+ "command": ["node", "/path/to/node_modules/@memextend/opencode/dist/mcp/server.cjs"],
47
+ "enabled": true
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### Option 2: Project-Local Configuration
54
+
55
+ Add to your project's `opencode.json`:
56
+
57
+ ```json
58
+ {
59
+ "$schema": "https://opencode.ai/config.json",
60
+ "mcp": {
61
+ "memextend": {
62
+ "type": "local",
63
+ "command": ["node", "./node_modules/@memextend/opencode/dist/mcp/server.cjs"],
64
+ "enabled": true
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ### Option 3: Using npx
71
+
72
+ If you have the package installed globally, you can reference it directly:
73
+
74
+ ```json
75
+ {
76
+ "$schema": "https://opencode.ai/config.json",
77
+ "mcp": {
78
+ "memextend": {
79
+ "type": "local",
80
+ "command": ["npx", "@memextend/opencode", "mcp"],
81
+ "enabled": true
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### Finding the Server Path
88
+
89
+ To find the correct path for your installation:
90
+
91
+ ```bash
92
+ # If installed globally
93
+ npm root -g
94
+ # Then append: /@memextend/opencode/dist/mcp/server.cjs
95
+
96
+ # If installed locally in a project
97
+ npm root
98
+ # Then append: /@memextend/opencode/dist/mcp/server.cjs
99
+ ```
100
+
101
+ ## Available MCP Tools
102
+
103
+ Once configured, the following tools are available in your OpenCode sessions:
104
+
105
+ ### memextend_search
106
+
107
+ Search through your memories using semantic and full-text search.
108
+
109
+ ```
110
+ Use: Search for "authentication flow" or "Redis caching decisions"
111
+ ```
112
+
113
+ ### memextend_save
114
+
115
+ Save a memory for the current project.
116
+
117
+ ```
118
+ Use: Save important decisions, patterns, or context for future reference
119
+ ```
120
+
121
+ ### memextend_save_global
122
+
123
+ Save a global preference or fact that applies across all projects.
124
+
125
+ ```
126
+ Use: Save coding style preferences, common patterns, or personal facts
127
+ Types: preference, pattern, fact
128
+ ```
129
+
130
+ ### memextend_forget
131
+
132
+ Delete a specific memory by ID.
133
+
134
+ ```
135
+ Use: Remove outdated or incorrect memories
136
+ ```
137
+
138
+ ### memextend_status
139
+
140
+ Get memextend status and memory statistics.
141
+
142
+ ```
143
+ Use: Check how many memories are stored, database location, etc.
144
+ ```
145
+
146
+ ### memextend_context
147
+
148
+ Get relevant context for the current session.
149
+
150
+ ```
151
+ Use: Retrieve recent memories, global preferences, and semantically related past work
152
+ ```
153
+
154
+ ## Usage Examples
155
+
156
+ After configuring memextend in your `opencode.json`, start OpenCode in your project:
157
+
158
+ ```bash
159
+ opencode
160
+ ```
161
+
162
+ Then interact with memextend through natural language:
163
+
164
+ ```
165
+ > Search my memories for authentication patterns
166
+
167
+ > Save this as a memory: We decided to use JWT tokens with 24-hour expiry for API authentication
168
+
169
+ > Remember globally that I prefer TypeScript with strict mode enabled
170
+
171
+ > What context do you have about this project?
172
+
173
+ > Show me the memextend status
174
+ ```
175
+
176
+ ## How It Works
177
+
178
+ 1. **MCP Integration**: OpenCode connects to the memextend MCP server via stdio
179
+ 2. **Tool Discovery**: OpenCode discovers the memextend tools at startup
180
+ 3. **Semantic Search**: Memories are embedded using the Nomic embed model for semantic search
181
+ 4. **Hybrid Search**: Combines vector similarity with full-text search for best results
182
+ 5. **Persistent Storage**: Memories are stored in SQLite with LanceDB for vectors
183
+
184
+ ## Configuration Reference
185
+
186
+ ### OpenCode MCP Config
187
+
188
+ ```typescript
189
+ interface MCPConfig {
190
+ type: 'local' | 'remote'; // 'local' for stdio servers
191
+ command?: string[]; // Command and arguments to run
192
+ environment?: Record<string, string>; // Environment variables
193
+ enabled?: boolean; // Enable/disable the server
194
+ timeout?: number; // Request timeout in ms
195
+ }
196
+ ```
197
+
198
+ ### memextend Config (~/.memextend/config.json)
199
+
200
+ ```json
201
+ {
202
+ "retrieval": {
203
+ "autoInject": true,
204
+ "maxMemories": 10,
205
+ "recentDays": 7,
206
+ "includeGlobal": true
207
+ },
208
+ "capture": {
209
+ "tools": ["Edit", "Write", "Bash", "Task"],
210
+ "skipTools": ["Read", "Glob", "Grep"],
211
+ "maxContentLength": 2000
212
+ }
213
+ }
214
+ ```
215
+
216
+ ## Differences from Claude Code Adapter
217
+
218
+ | Feature | Claude Code | OpenCode |
219
+ |---------|-------------|----------|
220
+ | Hook System | Native hooks (SessionStart, Stop) | No native hooks |
221
+ | Auto Context Injection | Yes (via SessionStart hook) | Manual via memextend_context |
222
+ | Auto Memory Capture | Yes (via Stop hook) | Manual via memextend_save |
223
+ | MCP Support | Yes | Yes |
224
+ | Mid-Session Tools | Yes | Yes |
225
+
226
+ Since OpenCode does not have a native hook system like Claude Code, automatic context injection and memory capture are not available. Instead, users should:
227
+
228
+ 1. Use `memextend_context` at the start of a session to get relevant memories
229
+ 2. Explicitly save important information using `memextend_save` or `memextend_save_global`
230
+
231
+ ## Troubleshooting
232
+
233
+ ### MCP Server Not Found
234
+
235
+ If OpenCode cannot find the memextend MCP server:
236
+
237
+ 1. Verify the path in your config is correct
238
+ 2. Ensure the package is built: `npm run build`
239
+ 3. Check Node.js is in your PATH
240
+
241
+ ### No Memories Found
242
+
243
+ If searches return no results:
244
+
245
+ 1. Run `memextend init` to initialize the database
246
+ 2. Verify memextend is working: `memextend status`
247
+ 3. Save some test memories first
248
+
249
+ ### Permission Errors
250
+
251
+ If you see permission errors:
252
+
253
+ 1. Ensure memextend directories exist: `~/.memextend/`
254
+ 2. Check write permissions on the database files
255
+
256
+ ## Development
257
+
258
+ ```bash
259
+ # Build the adapter
260
+ npm run build
261
+
262
+ # Run tests
263
+ npm test
264
+
265
+ # Build only the MCP server bundle
266
+ npm run build:bundle
267
+ ```
268
+
269
+ ## Related
270
+
271
+ - [memextend](https://github.com/zodttd/memextend) - Main memextend project
272
+ - [OpenCode](https://github.com/anomalyco/opencode) - OpenCode by Anomaly
273
+ - [MCP Specification](https://modelcontextprotocol.io/) - Model Context Protocol
274
+
275
+ ## License
276
+
277
+ MIT - Copyright (c) 2026 ZodTTD LLC
@@ -0,0 +1,118 @@
1
+ /**
2
+ * OpenCode configuration locations (in priority order):
3
+ * 1. ./opencode.json or ./opencode.jsonc (local project)
4
+ * 2. $XDG_CONFIG_HOME/opencode/opencode.json
5
+ * 3. ~/.config/opencode/opencode.json
6
+ *
7
+ * OpenCode by anomalyco supports JSONC (JSON with comments).
8
+ * Config reference: https://opencode.ai/docs
9
+ */
10
+ export interface OpenCodeConfig {
11
+ $schema?: string;
12
+ theme?: string;
13
+ model?: string;
14
+ small_model?: string;
15
+ provider?: Record<string, ProviderConfig>;
16
+ mcp?: Record<string, MCPConfig | {
17
+ enabled: boolean;
18
+ }>;
19
+ agent?: Record<string, AgentConfig>;
20
+ permission?: Record<string, string>;
21
+ plugin?: string[];
22
+ instructions?: string[];
23
+ [key: string]: unknown;
24
+ }
25
+ export interface ProviderConfig {
26
+ apiKey?: string;
27
+ baseUrl?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ export interface MCPConfig {
31
+ type: 'local' | 'remote';
32
+ command?: string[];
33
+ url?: string;
34
+ environment?: Record<string, string>;
35
+ enabled?: boolean;
36
+ timeout?: number;
37
+ headers?: Record<string, string>;
38
+ }
39
+ export interface AgentConfig {
40
+ model?: string;
41
+ temperature?: number;
42
+ prompt?: string;
43
+ description?: string;
44
+ mode?: 'primary' | 'subagent' | 'all';
45
+ [key: string]: unknown;
46
+ }
47
+ export interface OpenCodePaths {
48
+ configHome: string;
49
+ dataDir: string;
50
+ configPath: string;
51
+ localConfigPath: string;
52
+ }
53
+ /**
54
+ * Get OpenCode's data and config paths
55
+ */
56
+ export declare function getOpenCodePaths(): OpenCodePaths;
57
+ /**
58
+ * Load OpenCode configuration from disk
59
+ * Checks local config first, then global config
60
+ */
61
+ export declare function loadOpenCodeConfig(configPath?: string): Promise<OpenCodeConfig>;
62
+ /**
63
+ * Check if memextend MCP server is configured in OpenCode
64
+ */
65
+ export declare function isMemextendConfigured(config: OpenCodeConfig): boolean;
66
+ /**
67
+ * Generate MCP server configuration for memextend (local/stdio type)
68
+ *
69
+ * For anomalyco/opencode, the MCP config uses:
70
+ * - type: "local" for stdio-based servers
71
+ * - command: array of command and arguments
72
+ */
73
+ export declare function getMemextendMCPConfig(mcpServerPath: string): MCPConfig;
74
+ /**
75
+ * Add memextend MCP server to OpenCode configuration
76
+ */
77
+ export declare function addMemextendToConfig(config: OpenCodeConfig, mcpServerPath: string): OpenCodeConfig;
78
+ /**
79
+ * Remove memextend MCP server from OpenCode configuration
80
+ */
81
+ export declare function removeMemextendFromConfig(config: OpenCodeConfig): OpenCodeConfig;
82
+ /**
83
+ * Save OpenCode configuration to disk
84
+ */
85
+ export declare function saveOpenCodeConfig(config: OpenCodeConfig, configPath?: string): Promise<void>;
86
+ /**
87
+ * Get memextend configuration paths
88
+ */
89
+ export declare function getMemextendPaths(): {
90
+ dir: string;
91
+ configPath: string;
92
+ dbPath: string;
93
+ vectorsPath: string;
94
+ modelsPath: string;
95
+ };
96
+ export interface MemextendConfig {
97
+ capture?: {
98
+ tools?: string[];
99
+ skipTools?: string[];
100
+ maxContentLength?: number;
101
+ };
102
+ retrieval?: {
103
+ autoInject?: boolean;
104
+ maxMemories?: number;
105
+ recentDays?: number;
106
+ includeGlobal?: boolean;
107
+ };
108
+ }
109
+ /**
110
+ * Load memextend configuration
111
+ */
112
+ export declare function loadMemextendConfig(): Promise<MemextendConfig>;
113
+ /**
114
+ * Generate the configuration snippet to add memextend to OpenCode
115
+ * Returns the JSON that users can manually add to their opencode.json
116
+ */
117
+ export declare function generateConfigSnippet(mcpServerPath: string): string;
118
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,C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c,GAAG,OAAO,CAKrE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAOtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,GACpB,cAAc,CAWhB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAMhF;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;GAEG;AACH,wBAAgB,iBAAiB;;;;;;EAShC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,SAAS,CAAC,EAAE;QACV,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,eAAe,CAAC,CAapE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOnE"}
@@ -0,0 +1,153 @@
1
+ // packages/adapters/opencode/src/config/index.ts
2
+ // Copyright (c) 2026 ZodTTD LLC. MIT License.
3
+ import { existsSync } from 'fs';
4
+ import { readFile, writeFile, mkdir } from 'fs/promises';
5
+ import { join, dirname } from 'path';
6
+ import { homedir } from 'os';
7
+ /**
8
+ * Get OpenCode's data and config paths
9
+ */
10
+ export function getOpenCodePaths() {
11
+ const home = homedir();
12
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join(home, '.config');
13
+ const xdgData = process.env.XDG_DATA_HOME || join(home, '.local', 'share');
14
+ // OpenCode stores config in XDG_CONFIG_HOME/opencode or ~/.config/opencode
15
+ const configHome = join(xdgConfig, 'opencode');
16
+ // OpenCode stores data in XDG_DATA_HOME/opencode
17
+ const dataDir = join(xdgData, 'opencode');
18
+ return {
19
+ configHome,
20
+ dataDir,
21
+ configPath: join(configHome, 'opencode.json'),
22
+ localConfigPath: join(process.cwd(), 'opencode.json'),
23
+ };
24
+ }
25
+ /**
26
+ * Load OpenCode configuration from disk
27
+ * Checks local config first, then global config
28
+ */
29
+ export async function loadOpenCodeConfig(configPath) {
30
+ const paths = getOpenCodePaths();
31
+ // Priority order for config loading
32
+ const configPaths = configPath
33
+ ? [configPath]
34
+ : [
35
+ join(process.cwd(), 'opencode.jsonc'),
36
+ join(process.cwd(), 'opencode.json'),
37
+ join(paths.configHome, 'opencode.jsonc'),
38
+ join(paths.configHome, 'opencode.json'),
39
+ ];
40
+ for (const file of configPaths) {
41
+ try {
42
+ if (existsSync(file)) {
43
+ const content = await readFile(file, 'utf-8');
44
+ // Strip comments for JSONC files (simple approach)
45
+ const jsonContent = content.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
46
+ return JSON.parse(jsonContent);
47
+ }
48
+ }
49
+ catch (error) {
50
+ console.error(`[memextend] Failed to load OpenCode config from ${file}:`, error);
51
+ }
52
+ }
53
+ return {};
54
+ }
55
+ /**
56
+ * Check if memextend MCP server is configured in OpenCode
57
+ */
58
+ export function isMemextendConfigured(config) {
59
+ if (!config.mcp)
60
+ return false;
61
+ return Object.keys(config.mcp).some(name => name === 'memextend' || name.includes('memextend'));
62
+ }
63
+ /**
64
+ * Generate MCP server configuration for memextend (local/stdio type)
65
+ *
66
+ * For anomalyco/opencode, the MCP config uses:
67
+ * - type: "local" for stdio-based servers
68
+ * - command: array of command and arguments
69
+ */
70
+ export function getMemextendMCPConfig(mcpServerPath) {
71
+ return {
72
+ type: 'local',
73
+ command: ['node', mcpServerPath],
74
+ environment: {},
75
+ enabled: true,
76
+ };
77
+ }
78
+ /**
79
+ * Add memextend MCP server to OpenCode configuration
80
+ */
81
+ export function addMemextendToConfig(config, mcpServerPath) {
82
+ const updated = { ...config };
83
+ updated.mcp = updated.mcp || {};
84
+ updated.mcp.memextend = getMemextendMCPConfig(mcpServerPath);
85
+ // Add schema if not present
86
+ if (!updated.$schema) {
87
+ updated.$schema = 'https://opencode.ai/config.json';
88
+ }
89
+ return updated;
90
+ }
91
+ /**
92
+ * Remove memextend MCP server from OpenCode configuration
93
+ */
94
+ export function removeMemextendFromConfig(config) {
95
+ const updated = { ...config };
96
+ if (updated.mcp) {
97
+ delete updated.mcp.memextend;
98
+ }
99
+ return updated;
100
+ }
101
+ /**
102
+ * Save OpenCode configuration to disk
103
+ */
104
+ export async function saveOpenCodeConfig(config, configPath) {
105
+ const paths = getOpenCodePaths();
106
+ const targetPath = configPath || paths.configPath;
107
+ // Ensure directory exists
108
+ const dir = dirname(targetPath);
109
+ await mkdir(dir, { recursive: true });
110
+ await writeFile(targetPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
111
+ }
112
+ /**
113
+ * Get memextend configuration paths
114
+ */
115
+ export function getMemextendPaths() {
116
+ const memextendDir = join(homedir(), '.memextend');
117
+ return {
118
+ dir: memextendDir,
119
+ configPath: join(memextendDir, 'config.json'),
120
+ dbPath: join(memextendDir, 'memextend.db'),
121
+ vectorsPath: join(memextendDir, 'vectors'),
122
+ modelsPath: join(memextendDir, 'models'),
123
+ };
124
+ }
125
+ /**
126
+ * Load memextend configuration
127
+ */
128
+ export async function loadMemextendConfig() {
129
+ const paths = getMemextendPaths();
130
+ try {
131
+ if (existsSync(paths.configPath)) {
132
+ const content = await readFile(paths.configPath, 'utf-8');
133
+ return JSON.parse(content);
134
+ }
135
+ }
136
+ catch (error) {
137
+ console.error(`[memextend] Failed to load config: ${error}`);
138
+ }
139
+ return {};
140
+ }
141
+ /**
142
+ * Generate the configuration snippet to add memextend to OpenCode
143
+ * Returns the JSON that users can manually add to their opencode.json
144
+ */
145
+ export function generateConfigSnippet(mcpServerPath) {
146
+ const config = {
147
+ mcp: {
148
+ memextend: getMemextendMCPConfig(mcpServerPath),
149
+ },
150
+ };
151
+ return JSON.stringify(config, null, 2);
152
+ }
153
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,8CAA8C;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AA0D7B;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE3E,2EAA2E;IAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE/C,iDAAiD;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAE1C,OAAO;QACL,UAAU;QACV,OAAO;QACP,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC;QAC7C,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC;KACtD,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D;KACF,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * OpenCode Adapter for memextend
3
+ *
4
+ * This adapter provides memextend integration for OpenCode (https://github.com/anomalyco/opencode)
5
+ * via MCP (Model Context Protocol) server.
6
+ *
7
+ * OpenCode is an open-source AI coding agent by Anomaly that supports:
8
+ * - Multiple AI providers (Anthropic, OpenAI, Google, local models)
9
+ * - Built-in agents (build, plan, general)
10
+ * - MCP server integration for custom tools
11
+ * - LSP support for code intelligence
12
+ * - TUI interface
13
+ *
14
+ * Integration approach:
15
+ * - MCP server provides mid-session memory tools (search, save, forget, status, context)
16
+ * - Users configure memextend in their opencode.json config
17
+ * - No native hook system, so session capture requires manual saves or external triggers
18
+ *
19
+ * Configuration location:
20
+ * - ~/.config/opencode/opencode.json (global)
21
+ * - ./opencode.json (project-local)
22
+ *
23
+ * OpenCode documentation: https://opencode.ai/docs
24
+ * GitHub: https://github.com/anomalyco/opencode
25
+ */
26
+ export declare const ADAPTER_NAME = "opencode";
27
+ export declare const ADAPTER_VERSION = "0.1.0";
28
+ export declare const ADAPTER_STATUS = "implemented";
29
+ export * from './mcp/index.js';
30
+ export * from './config/index.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAG5C,cAAc,gBAAgB,CAAC;AAG/B,cAAc,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ // packages/adapters/opencode/src/index.ts
2
+ // Copyright (c) 2026 ZodTTD LLC. MIT License.
3
+ /**
4
+ * OpenCode Adapter for memextend
5
+ *
6
+ * This adapter provides memextend integration for OpenCode (https://github.com/anomalyco/opencode)
7
+ * via MCP (Model Context Protocol) server.
8
+ *
9
+ * OpenCode is an open-source AI coding agent by Anomaly that supports:
10
+ * - Multiple AI providers (Anthropic, OpenAI, Google, local models)
11
+ * - Built-in agents (build, plan, general)
12
+ * - MCP server integration for custom tools
13
+ * - LSP support for code intelligence
14
+ * - TUI interface
15
+ *
16
+ * Integration approach:
17
+ * - MCP server provides mid-session memory tools (search, save, forget, status, context)
18
+ * - Users configure memextend in their opencode.json config
19
+ * - No native hook system, so session capture requires manual saves or external triggers
20
+ *
21
+ * Configuration location:
22
+ * - ~/.config/opencode/opencode.json (global)
23
+ * - ./opencode.json (project-local)
24
+ *
25
+ * OpenCode documentation: https://opencode.ai/docs
26
+ * GitHub: https://github.com/anomalyco/opencode
27
+ */
28
+ export const ADAPTER_NAME = 'opencode';
29
+ export const ADAPTER_VERSION = '0.1.0';
30
+ export const ADAPTER_STATUS = 'implemented';
31
+ // Export MCP server utilities
32
+ export * from './mcp/index.js';
33
+ // Export configuration utilities
34
+ export * from './config/index.js';
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,8CAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,8BAA8B;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,iCAAiC;AACjC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const MCP_SERVER = "server.cjs";
2
+ /**
3
+ * Get the path to the MCP server script for use in OpenCode configuration.
4
+ * This should be used when programmatically generating opencode.json config.
5
+ */
6
+ export declare function getMCPServerPath(): string;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC"}
@@ -0,0 +1,15 @@
1
+ // packages/adapters/opencode/src/mcp/index.ts
2
+ // Copyright (c) 2026 ZodTTD LLC. MIT License.
3
+ // MCP server is a standalone script, not a library export
4
+ // It is executed directly by OpenCode via stdio transport
5
+ export const MCP_SERVER = 'server.cjs';
6
+ /**
7
+ * Get the path to the MCP server script for use in OpenCode configuration.
8
+ * This should be used when programmatically generating opencode.json config.
9
+ */
10
+ export function getMCPServerPath() {
11
+ // When installed as a package, the server will be in the dist/mcp directory
12
+ const path = require('path');
13
+ return path.join(__dirname, 'server.cjs');
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,8CAA8C;AAE9C,0DAA0D;AAC1D,0DAA0D;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,4EAA4E;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAC5C,CAAC"}