opencode-mem 1.0.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 +588 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +258 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +618 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +15 -0
- package/dist/services/api-handlers.d.ts +102 -0
- package/dist/services/api-handlers.d.ts.map +1 -0
- package/dist/services/api-handlers.js +494 -0
- package/dist/services/auto-capture.d.ts +32 -0
- package/dist/services/auto-capture.d.ts.map +1 -0
- package/dist/services/auto-capture.js +451 -0
- package/dist/services/cleanup-service.d.ts +20 -0
- package/dist/services/cleanup-service.d.ts.map +1 -0
- package/dist/services/cleanup-service.js +88 -0
- package/dist/services/client.d.ts +104 -0
- package/dist/services/client.d.ts.map +1 -0
- package/dist/services/client.js +251 -0
- package/dist/services/compaction.d.ts +92 -0
- package/dist/services/compaction.d.ts.map +1 -0
- package/dist/services/compaction.js +421 -0
- package/dist/services/context.d.ts +17 -0
- package/dist/services/context.d.ts.map +1 -0
- package/dist/services/context.js +41 -0
- package/dist/services/deduplication-service.d.ts +30 -0
- package/dist/services/deduplication-service.d.ts.map +1 -0
- package/dist/services/deduplication-service.js +131 -0
- package/dist/services/embedding.d.ts +10 -0
- package/dist/services/embedding.d.ts.map +1 -0
- package/dist/services/embedding.js +77 -0
- package/dist/services/jsonc.d.ts +7 -0
- package/dist/services/jsonc.d.ts.map +1 -0
- package/dist/services/jsonc.js +76 -0
- package/dist/services/logger.d.ts +2 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +16 -0
- package/dist/services/migration-service.d.ts +42 -0
- package/dist/services/migration-service.d.ts.map +1 -0
- package/dist/services/migration-service.js +258 -0
- package/dist/services/privacy.d.ts +4 -0
- package/dist/services/privacy.d.ts.map +1 -0
- package/dist/services/privacy.js +10 -0
- package/dist/services/sqlite/connection-manager.d.ts +10 -0
- package/dist/services/sqlite/connection-manager.d.ts.map +1 -0
- package/dist/services/sqlite/connection-manager.js +45 -0
- package/dist/services/sqlite/shard-manager.d.ts +20 -0
- package/dist/services/sqlite/shard-manager.d.ts.map +1 -0
- package/dist/services/sqlite/shard-manager.js +221 -0
- package/dist/services/sqlite/types.d.ts +39 -0
- package/dist/services/sqlite/types.d.ts.map +1 -0
- package/dist/services/sqlite/types.js +1 -0
- package/dist/services/sqlite/vector-search.d.ts +18 -0
- package/dist/services/sqlite/vector-search.d.ts.map +1 -0
- package/dist/services/sqlite/vector-search.js +129 -0
- package/dist/services/sqlite-client.d.ts +116 -0
- package/dist/services/sqlite-client.d.ts.map +1 -0
- package/dist/services/sqlite-client.js +284 -0
- package/dist/services/tags.d.ts +20 -0
- package/dist/services/tags.d.ts.map +1 -0
- package/dist/services/tags.js +76 -0
- package/dist/services/web-server-lock.d.ts +12 -0
- package/dist/services/web-server-lock.d.ts.map +1 -0
- package/dist/services/web-server-lock.js +157 -0
- package/dist/services/web-server-worker.d.ts +2 -0
- package/dist/services/web-server-worker.d.ts.map +1 -0
- package/dist/services/web-server-worker.js +221 -0
- package/dist/services/web-server.d.ts +22 -0
- package/dist/services/web-server.d.ts.map +1 -0
- package/dist/services/web-server.js +134 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/web/app.d.ts +2 -0
- package/dist/web/app.d.ts.map +1 -0
- package/dist/web/app.js +691 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +14 -0
- package/dist/web/index.html +202 -0
- package/dist/web/styles.css +851 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# OpenCode Memory
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A persistent memory system for AI coding agents that enables long-term context retention across sessions using local vector database technology.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
OpenCode Memory is a plugin for OpenCode that provides AI coding agents with the ability to remember and recall information across conversations. It uses vector embeddings and SQLite for efficient storage and retrieval of contextual information, enabling agents to maintain continuity in complex, multi-session projects.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
|
|
13
|
+
- **Local Vector Database**: SQLite-based storage with sqlite-vec extension for efficient similarity search
|
|
14
|
+
- **Dual Memory Scopes**: Separate user-level and project-level memory contexts
|
|
15
|
+
- **Web Interface**: Full-featured UI for memory management, search, and maintenance
|
|
16
|
+
- **Auto-Capture System**: Intelligent background memory extraction from conversations
|
|
17
|
+
- **Flexible Embedding Models**: Support for 12+ local models or OpenAI-compatible APIs
|
|
18
|
+
- **Automatic Sharding**: Scales to millions of vectors with automatic shard management
|
|
19
|
+
- **Smart Deduplication**: Prevents redundant memories using similarity detection
|
|
20
|
+
- **Privacy Protection**: Built-in content filtering for sensitive information
|
|
21
|
+
- **Zero Configuration**: Works out of the box with sensible defaults
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### Prerequisites
|
|
26
|
+
|
|
27
|
+
- OpenCode AI platform
|
|
28
|
+
|
|
29
|
+
### Install Plugin
|
|
30
|
+
|
|
31
|
+
Add the plugin to your OpenCode configuration file:
|
|
32
|
+
|
|
33
|
+
**Location**: `~/.config/opencode/opencode.json` or `opencode.jsonc`
|
|
34
|
+
|
|
35
|
+
```jsonc
|
|
36
|
+
{
|
|
37
|
+
"plugins": [
|
|
38
|
+
"opencode-mem"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
OpenCode will automatically download and install the plugin on next startup.
|
|
44
|
+
|
|
45
|
+
### Install from Source (Development)
|
|
46
|
+
|
|
47
|
+
For development or contributing:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/tickernelz/opencode-mem.git
|
|
51
|
+
cd opencode-mem
|
|
52
|
+
bun install
|
|
53
|
+
bun run build
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then add the local path to your OpenCode config:
|
|
57
|
+
|
|
58
|
+
```jsonc
|
|
59
|
+
{
|
|
60
|
+
"plugins": [
|
|
61
|
+
"/path/to/opencode-mem"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Basic Usage
|
|
69
|
+
|
|
70
|
+
Once installed, the memory tool is automatically available in your OpenCode environment:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
memory({ mode: "add", content: "User prefers TypeScript over JavaScript", scope: "user" })
|
|
74
|
+
memory({ mode: "search", query: "coding preferences", scope: "user" })
|
|
75
|
+
memory({ mode: "profile" })
|
|
76
|
+
memory({ mode: "list", scope: "project", limit: 10 })
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Web Interface
|
|
80
|
+
|
|
81
|
+
Access the web interface at `http://127.0.0.1:4747` (default) to:
|
|
82
|
+
|
|
83
|
+
- Browse and search all memories
|
|
84
|
+
- Edit, delete, or pin important memories
|
|
85
|
+
- Run maintenance operations (cleanup, deduplication)
|
|
86
|
+
- View statistics and analytics
|
|
87
|
+
- Manage memory scopes and tags
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
Configuration file is automatically created at `~/.config/opencode/opencode-mem.jsonc`:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
{
|
|
95
|
+
"storagePath": "~/.opencode-mem/data",
|
|
96
|
+
"embeddingModel": "Xenova/nomic-embed-text-v1",
|
|
97
|
+
"webServerEnabled": true,
|
|
98
|
+
"webServerPort": 4747,
|
|
99
|
+
"webServerHost": "127.0.0.1",
|
|
100
|
+
"similarityThreshold": 0.6,
|
|
101
|
+
"maxMemories": 5,
|
|
102
|
+
"maxProjectMemories": 10,
|
|
103
|
+
"autoCleanupEnabled": true,
|
|
104
|
+
"autoCleanupRetentionDays": 30,
|
|
105
|
+
"deduplicationEnabled": true,
|
|
106
|
+
"autoCaptureEnabled": true
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Memory Operations
|
|
111
|
+
|
|
112
|
+
### Add Memory
|
|
113
|
+
|
|
114
|
+
Store information with scope and optional metadata:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
memory({
|
|
118
|
+
mode: "add",
|
|
119
|
+
content: "Project uses React 18 with TypeScript and Vite",
|
|
120
|
+
scope: "project",
|
|
121
|
+
type: "architecture"
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Search Memory
|
|
126
|
+
|
|
127
|
+
Vector similarity search across stored memories:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
memory({
|
|
131
|
+
mode: "search",
|
|
132
|
+
query: "What framework does this project use?",
|
|
133
|
+
scope: "project"
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### View Profile
|
|
138
|
+
|
|
139
|
+
Display user profile with preferences and patterns:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
memory({ mode: "profile" })
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### List Memories
|
|
146
|
+
|
|
147
|
+
Retrieve recent memories by scope:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
memory({ mode: "list", scope: "user", limit: 20 })
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Forget Memory
|
|
154
|
+
|
|
155
|
+
Delete specific memory by ID:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
memory({ mode: "forget", memoryId: "mem_abc123" })
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Auto-Capture Control
|
|
162
|
+
|
|
163
|
+
Manage automatic memory capture:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
memory({ mode: "auto-capture-toggle" })
|
|
167
|
+
memory({ mode: "auto-capture-stats" })
|
|
168
|
+
memory({ mode: "capture-now" })
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Memory Scopes
|
|
172
|
+
|
|
173
|
+
### User Scope
|
|
174
|
+
|
|
175
|
+
Cross-project information about user preferences, behaviors, and patterns:
|
|
176
|
+
|
|
177
|
+
- Coding style preferences
|
|
178
|
+
- Tool and framework preferences
|
|
179
|
+
- Communication style
|
|
180
|
+
- Work patterns and habits
|
|
181
|
+
- General technical knowledge
|
|
182
|
+
|
|
183
|
+
### Project Scope
|
|
184
|
+
|
|
185
|
+
Project-specific knowledge and context:
|
|
186
|
+
|
|
187
|
+
- Architecture decisions
|
|
188
|
+
- Technology stack
|
|
189
|
+
- Code patterns and conventions
|
|
190
|
+
- Bug fixes and solutions
|
|
191
|
+
- Feature implementations
|
|
192
|
+
- Configuration details
|
|
193
|
+
|
|
194
|
+
## Auto-Capture System
|
|
195
|
+
|
|
196
|
+
The auto-capture system automatically extracts important information from conversations using AI:
|
|
197
|
+
|
|
198
|
+
### Configuration
|
|
199
|
+
|
|
200
|
+
```jsonc
|
|
201
|
+
{
|
|
202
|
+
"autoCaptureEnabled": true,
|
|
203
|
+
"memoryModel": "gpt-4",
|
|
204
|
+
"memoryApiUrl": "https://api.openai.com/v1",
|
|
205
|
+
"memoryApiKey": "sk-...",
|
|
206
|
+
"autoCaptureTokenThreshold": 10000,
|
|
207
|
+
"autoCaptureMinTokens": 20000,
|
|
208
|
+
"autoCaptureMaxMemories": 10,
|
|
209
|
+
"autoCaptureContextWindow": 3
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### How It Works
|
|
214
|
+
|
|
215
|
+
1. Monitors conversation token count
|
|
216
|
+
2. Triggers when threshold is reached
|
|
217
|
+
3. Analyzes recent messages using AI
|
|
218
|
+
4. Extracts relevant information
|
|
219
|
+
5. Stores memories with appropriate scope
|
|
220
|
+
6. Runs in background without blocking
|
|
221
|
+
|
|
222
|
+
## Embedding Models
|
|
223
|
+
|
|
224
|
+
### Local Models (Default)
|
|
225
|
+
|
|
226
|
+
Runs entirely on your machine without external API calls:
|
|
227
|
+
|
|
228
|
+
- `Xenova/nomic-embed-text-v1` (768 dimensions, default)
|
|
229
|
+
- `Xenova/all-MiniLM-L6-v2` (384 dimensions)
|
|
230
|
+
- `Xenova/all-mpnet-base-v2` (768 dimensions)
|
|
231
|
+
- `Xenova/bge-small-en-v1.5` (384 dimensions)
|
|
232
|
+
- `Xenova/bge-base-en-v1.5` (768 dimensions)
|
|
233
|
+
- And more...
|
|
234
|
+
|
|
235
|
+
### API-Based Models
|
|
236
|
+
|
|
237
|
+
Use OpenAI-compatible APIs for embeddings:
|
|
238
|
+
|
|
239
|
+
```jsonc
|
|
240
|
+
{
|
|
241
|
+
"embeddingApiUrl": "https://api.openai.com/v1",
|
|
242
|
+
"embeddingApiKey": "sk-...",
|
|
243
|
+
"embeddingModel": "text-embedding-3-small"
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Database Architecture
|
|
248
|
+
|
|
249
|
+
### Automatic Sharding
|
|
250
|
+
|
|
251
|
+
- Default shard size: 50,000 vectors
|
|
252
|
+
- Automatic shard creation and management
|
|
253
|
+
- Efficient cross-shard search
|
|
254
|
+
- Scales to millions of vectors
|
|
255
|
+
|
|
256
|
+
### Vector Search
|
|
257
|
+
|
|
258
|
+
- Cosine similarity algorithm
|
|
259
|
+
- Configurable similarity threshold
|
|
260
|
+
- Fast approximate nearest neighbor search
|
|
261
|
+
- Metadata filtering support
|
|
262
|
+
|
|
263
|
+
### Maintenance Operations
|
|
264
|
+
|
|
265
|
+
**Cleanup**: Remove old memories based on retention period
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
POST /api/cleanup
|
|
269
|
+
{ "retentionDays": 30, "dryRun": false }
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Deduplication**: Remove similar duplicate memories
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
POST /api/deduplicate
|
|
276
|
+
{ "similarityThreshold": 0.9, "dryRun": false }
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Migration**: Change embedding model dimensions
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
POST /api/migrate
|
|
283
|
+
{ "newModel": "Xenova/all-MiniLM-L6-v2", "newDimensions": 384 }
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Web Interface Features
|
|
287
|
+
|
|
288
|
+
### Memory Explorer
|
|
289
|
+
|
|
290
|
+
- Full-text and vector search
|
|
291
|
+
- Filter by scope, type, and tags
|
|
292
|
+
- Sort by date, relevance, or pinned status
|
|
293
|
+
- Bulk operations (delete, export)
|
|
294
|
+
- Pagination for large datasets
|
|
295
|
+
|
|
296
|
+
### Memory Editor
|
|
297
|
+
|
|
298
|
+
- Edit content and metadata
|
|
299
|
+
- Change scope and type
|
|
300
|
+
- Add or remove tags
|
|
301
|
+
- Pin important memories
|
|
302
|
+
- Delete individual memories
|
|
303
|
+
|
|
304
|
+
### Maintenance Dashboard
|
|
305
|
+
|
|
306
|
+
- Run cleanup operations
|
|
307
|
+
- Execute deduplication
|
|
308
|
+
- Perform model migrations
|
|
309
|
+
- View operation results
|
|
310
|
+
- Dry-run mode for safety
|
|
311
|
+
|
|
312
|
+
### Statistics
|
|
313
|
+
|
|
314
|
+
- Total memory count by scope
|
|
315
|
+
- Storage usage metrics
|
|
316
|
+
- Auto-capture statistics
|
|
317
|
+
- Search performance metrics
|
|
318
|
+
|
|
319
|
+
## Configuration Reference
|
|
320
|
+
|
|
321
|
+
### Storage Settings
|
|
322
|
+
|
|
323
|
+
| Option | Type | Default | Description |
|
|
324
|
+
|--------|------|---------|-------------|
|
|
325
|
+
| `storagePath` | string | `~/.opencode-mem/data` | Database storage location |
|
|
326
|
+
| `maxVectorsPerShard` | number | `50000` | Vectors per shard before splitting |
|
|
327
|
+
|
|
328
|
+
### Embedding Settings
|
|
329
|
+
|
|
330
|
+
| Option | Type | Default | Description |
|
|
331
|
+
|--------|------|---------|-------------|
|
|
332
|
+
| `embeddingModel` | string | `Xenova/nomic-embed-text-v1` | Model name for embeddings |
|
|
333
|
+
| `embeddingDimensions` | number | auto | Vector dimensions (auto-detected) |
|
|
334
|
+
| `embeddingApiUrl` | string | - | Optional external API endpoint |
|
|
335
|
+
| `embeddingApiKey` | string | - | API key for external service |
|
|
336
|
+
|
|
337
|
+
### Web Server Settings
|
|
338
|
+
|
|
339
|
+
| Option | Type | Default | Description |
|
|
340
|
+
|--------|------|---------|-------------|
|
|
341
|
+
| `webServerEnabled` | boolean | `true` | Enable web interface |
|
|
342
|
+
| `webServerPort` | number | `4747` | HTTP server port |
|
|
343
|
+
| `webServerHost` | string | `127.0.0.1` | Bind address |
|
|
344
|
+
|
|
345
|
+
### Search Settings
|
|
346
|
+
|
|
347
|
+
| Option | Type | Default | Description |
|
|
348
|
+
|--------|------|---------|-------------|
|
|
349
|
+
| `similarityThreshold` | number | `0.6` | Minimum similarity for search results |
|
|
350
|
+
| `maxMemories` | number | `5` | Max user memories to inject |
|
|
351
|
+
| `maxProjectMemories` | number | `10` | Max project memories to inject |
|
|
352
|
+
|
|
353
|
+
### Auto-Capture Settings
|
|
354
|
+
|
|
355
|
+
| Option | Type | Default | Description |
|
|
356
|
+
|--------|------|---------|-------------|
|
|
357
|
+
| `autoCaptureEnabled` | boolean | `true` | Enable auto-capture |
|
|
358
|
+
| `memoryModel` | string | - | AI model for capture (required) |
|
|
359
|
+
| `memoryApiUrl` | string | - | API endpoint (required) |
|
|
360
|
+
| `memoryApiKey` | string | - | API key (required) |
|
|
361
|
+
| `autoCaptureTokenThreshold` | number | `10000` | Token count trigger |
|
|
362
|
+
| `autoCaptureMinTokens` | number | `20000` | Minimum tokens before capture |
|
|
363
|
+
| `autoCaptureMaxMemories` | number | `10` | Max memories per capture |
|
|
364
|
+
| `autoCaptureContextWindow` | number | `3` | Message history to analyze |
|
|
365
|
+
|
|
366
|
+
### Maintenance Settings
|
|
367
|
+
|
|
368
|
+
| Option | Type | Default | Description |
|
|
369
|
+
|--------|------|---------|-------------|
|
|
370
|
+
| `autoCleanupEnabled` | boolean | `true` | Enable automatic cleanup |
|
|
371
|
+
| `autoCleanupRetentionDays` | number | `30` | Days to retain memories |
|
|
372
|
+
| `deduplicationEnabled` | boolean | `true` | Enable deduplication |
|
|
373
|
+
| `deduplicationSimilarityThreshold` | number | `0.9` | Similarity threshold for duplicates |
|
|
374
|
+
|
|
375
|
+
### Advanced Settings
|
|
376
|
+
|
|
377
|
+
| Option | Type | Default | Description |
|
|
378
|
+
|--------|------|---------|-------------|
|
|
379
|
+
| `injectProfile` | boolean | `true` | Inject user profile in context |
|
|
380
|
+
| `keywordPatterns` | string[] | `[]` | Custom keyword regex patterns |
|
|
381
|
+
| `containerTagPrefix` | string | `opencode` | Tag prefix for containers |
|
|
382
|
+
| `maxProfileItems` | number | `5` | Max items in profile summary |
|
|
383
|
+
|
|
384
|
+
## API Reference
|
|
385
|
+
|
|
386
|
+
### REST Endpoints
|
|
387
|
+
|
|
388
|
+
**GET /api/memories**
|
|
389
|
+
- Query parameters: `scope`, `type`, `tag`, `search`, `limit`, `offset`
|
|
390
|
+
- Returns: Array of memory objects with metadata
|
|
391
|
+
|
|
392
|
+
**POST /api/memories**
|
|
393
|
+
- Body: `{ content, scope, type, metadata }`
|
|
394
|
+
- Returns: Created memory object with ID
|
|
395
|
+
|
|
396
|
+
**PUT /api/memories/:id**
|
|
397
|
+
- Body: `{ content, scope, type, metadata, pinned }`
|
|
398
|
+
- Returns: Updated memory object
|
|
399
|
+
|
|
400
|
+
**DELETE /api/memories/:id**
|
|
401
|
+
- Returns: Success confirmation
|
|
402
|
+
|
|
403
|
+
**POST /api/search**
|
|
404
|
+
- Body: `{ query, scope, limit, threshold }`
|
|
405
|
+
- Returns: Array of similar memories with scores
|
|
406
|
+
|
|
407
|
+
**GET /api/stats**
|
|
408
|
+
- Returns: Database statistics and counts
|
|
409
|
+
|
|
410
|
+
**POST /api/cleanup**
|
|
411
|
+
- Body: `{ retentionDays, dryRun }`
|
|
412
|
+
- Returns: Cleanup results
|
|
413
|
+
|
|
414
|
+
**POST /api/deduplicate**
|
|
415
|
+
- Body: `{ similarityThreshold, dryRun }`
|
|
416
|
+
- Returns: Deduplication results
|
|
417
|
+
|
|
418
|
+
**POST /api/migrate**
|
|
419
|
+
- Body: `{ newModel, newDimensions }`
|
|
420
|
+
- Returns: Migration progress and results
|
|
421
|
+
|
|
422
|
+
## Privacy and Security
|
|
423
|
+
|
|
424
|
+
### Content Filtering
|
|
425
|
+
|
|
426
|
+
Automatically strips sensitive patterns:
|
|
427
|
+
|
|
428
|
+
- API keys and tokens
|
|
429
|
+
- Passwords and credentials
|
|
430
|
+
- Private keys and certificates
|
|
431
|
+
- Email addresses
|
|
432
|
+
- Phone numbers
|
|
433
|
+
- Credit card numbers
|
|
434
|
+
|
|
435
|
+
### Private Content Detection
|
|
436
|
+
|
|
437
|
+
Prevents storing fully private content:
|
|
438
|
+
|
|
439
|
+
- Checks for high density of sensitive patterns
|
|
440
|
+
- Warns user when private content is detected
|
|
441
|
+
- Allows manual override if needed
|
|
442
|
+
|
|
443
|
+
### Local-First Architecture
|
|
444
|
+
|
|
445
|
+
- All data stored locally on your machine
|
|
446
|
+
- No external services required (except optional API embeddings)
|
|
447
|
+
- Full control over your data
|
|
448
|
+
- No telemetry or tracking
|
|
449
|
+
|
|
450
|
+
## Troubleshooting
|
|
451
|
+
|
|
452
|
+
### Web Interface Not Accessible
|
|
453
|
+
|
|
454
|
+
Check if the server is running:
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
curl http://127.0.0.1:4747/api/stats
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Verify configuration:
|
|
461
|
+
|
|
462
|
+
```jsonc
|
|
463
|
+
{
|
|
464
|
+
"webServerEnabled": true,
|
|
465
|
+
"webServerPort": 4747,
|
|
466
|
+
"webServerHost": "127.0.0.1"
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Slow Search Performance
|
|
471
|
+
|
|
472
|
+
- Reduce `maxMemories` and `maxProjectMemories`
|
|
473
|
+
- Increase `similarityThreshold` to filter more results
|
|
474
|
+
- Run deduplication to reduce database size
|
|
475
|
+
- Consider using smaller embedding model
|
|
476
|
+
|
|
477
|
+
### High Memory Usage
|
|
478
|
+
|
|
479
|
+
- Enable auto-cleanup with shorter retention
|
|
480
|
+
- Run manual cleanup operations
|
|
481
|
+
- Reduce `maxVectorsPerShard` for smaller shards
|
|
482
|
+
- Use smaller embedding model (384 vs 768 dimensions)
|
|
483
|
+
|
|
484
|
+
### Auto-Capture Not Working
|
|
485
|
+
|
|
486
|
+
Verify configuration:
|
|
487
|
+
|
|
488
|
+
```jsonc
|
|
489
|
+
{
|
|
490
|
+
"autoCaptureEnabled": true,
|
|
491
|
+
"memoryModel": "gpt-4",
|
|
492
|
+
"memoryApiUrl": "https://api.openai.com/v1",
|
|
493
|
+
"memoryApiKey": "sk-..."
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Check API key and endpoint are valid.
|
|
498
|
+
|
|
499
|
+
## Development
|
|
500
|
+
|
|
501
|
+
### Build from Source
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
git clone https://github.com/tickernelz/opencode-mem.git
|
|
505
|
+
cd opencode-mem
|
|
506
|
+
bun install
|
|
507
|
+
bun run build
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### Development Mode
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
bun run dev
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### Code Formatting
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
bun run format
|
|
520
|
+
bun run format:check
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### Type Checking
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
bun run typecheck
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## Architecture
|
|
530
|
+
|
|
531
|
+
### Core Components
|
|
532
|
+
|
|
533
|
+
- **Memory Client**: Main interface for memory operations
|
|
534
|
+
- **Embedding Service**: Vector generation (local or API)
|
|
535
|
+
- **Shard Manager**: Automatic database sharding
|
|
536
|
+
- **Vector Search**: Similarity search implementation
|
|
537
|
+
- **Web Server**: HTTP API and static file serving
|
|
538
|
+
- **Auto-Capture**: Background memory extraction
|
|
539
|
+
- **Cleanup Service**: Retention-based deletion
|
|
540
|
+
- **Deduplication Service**: Duplicate detection
|
|
541
|
+
- **Migration Service**: Model dimension changes
|
|
542
|
+
|
|
543
|
+
### Data Flow
|
|
544
|
+
|
|
545
|
+
```
|
|
546
|
+
User Input → Plugin Hook → Memory Client → Embedding Service → SQLite Vector DB
|
|
547
|
+
↓ ↓
|
|
548
|
+
Keyword Detection Shard Manager
|
|
549
|
+
↓ ↓
|
|
550
|
+
Memory Nudge Vector Search
|
|
551
|
+
↓ ↓
|
|
552
|
+
Tool Execution ← API Handlers ← Web Server ← Web Interface
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Plugin Integration
|
|
556
|
+
|
|
557
|
+
- **Hooks**: `chat.message`, `event`
|
|
558
|
+
- **Tools**: `memory` tool with 9 modes
|
|
559
|
+
- **Context Injection**: Automatic memory injection in conversations
|
|
560
|
+
- **Keyword Detection**: 16 default patterns for memory triggers
|
|
561
|
+
|
|
562
|
+
## Contributing
|
|
563
|
+
|
|
564
|
+
Contributions are welcome. Please ensure:
|
|
565
|
+
|
|
566
|
+
- Code follows existing style (Prettier configuration)
|
|
567
|
+
- TypeScript strict mode compliance
|
|
568
|
+
- No breaking changes to public API
|
|
569
|
+
- Tests pass (when available)
|
|
570
|
+
- Documentation updated
|
|
571
|
+
|
|
572
|
+
## License
|
|
573
|
+
|
|
574
|
+
MIT License - see LICENSE file for details
|
|
575
|
+
|
|
576
|
+
## Acknowledgments
|
|
577
|
+
|
|
578
|
+
This project was inspired by and references [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory) as the primary reference implementation.
|
|
579
|
+
|
|
580
|
+
## Links
|
|
581
|
+
|
|
582
|
+
- **Repository**: https://github.com/tickernelz/opencode-mem
|
|
583
|
+
- **Issues**: https://github.com/tickernelz/opencode-mem/issues
|
|
584
|
+
- **OpenCode Platform**: https://opencode.ai
|
|
585
|
+
|
|
586
|
+
## Support
|
|
587
|
+
|
|
588
|
+
For issues, questions, or feature requests, please open an issue on GitHub.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CONFIG: {
|
|
2
|
+
storagePath: string;
|
|
3
|
+
embeddingModel: string;
|
|
4
|
+
embeddingDimensions: number;
|
|
5
|
+
embeddingApiUrl: string | undefined;
|
|
6
|
+
embeddingApiKey: string | undefined;
|
|
7
|
+
similarityThreshold: number;
|
|
8
|
+
maxMemories: number;
|
|
9
|
+
maxProjectMemories: number;
|
|
10
|
+
maxProfileItems: number;
|
|
11
|
+
injectProfile: boolean;
|
|
12
|
+
containerTagPrefix: string;
|
|
13
|
+
keywordPatterns: string[];
|
|
14
|
+
autoCaptureEnabled: boolean;
|
|
15
|
+
autoCaptureTokenThreshold: number;
|
|
16
|
+
autoCaptureMinTokens: number;
|
|
17
|
+
autoCaptureMaxMemories: number;
|
|
18
|
+
autoCaptureSummaryMaxLength: number;
|
|
19
|
+
autoCaptureContextWindow: number;
|
|
20
|
+
memoryModel: string | undefined;
|
|
21
|
+
memoryApiUrl: string | undefined;
|
|
22
|
+
memoryApiKey: string | undefined;
|
|
23
|
+
webServerEnabled: boolean;
|
|
24
|
+
webServerPort: number;
|
|
25
|
+
webServerHost: string;
|
|
26
|
+
maxVectorsPerShard: number;
|
|
27
|
+
autoCleanupEnabled: boolean;
|
|
28
|
+
autoCleanupRetentionDays: number;
|
|
29
|
+
deduplicationEnabled: boolean;
|
|
30
|
+
deduplicationSimilarityThreshold: number;
|
|
31
|
+
};
|
|
32
|
+
export declare function isConfigured(): boolean;
|
|
33
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmRA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwClB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|