opencode-mem 1.0.1 → 2.0.1

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.
Files changed (69) hide show
  1. package/README.md +80 -477
  2. package/dist/config.d.ts +5 -5
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +46 -20
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +28 -88
  7. package/dist/services/ai/ai-provider-factory.d.ts +8 -0
  8. package/dist/services/ai/ai-provider-factory.d.ts.map +1 -0
  9. package/dist/services/ai/ai-provider-factory.js +25 -0
  10. package/dist/services/ai/providers/anthropic-messages.d.ts +13 -0
  11. package/dist/services/ai/providers/anthropic-messages.d.ts.map +1 -0
  12. package/dist/services/ai/providers/anthropic-messages.js +176 -0
  13. package/dist/services/ai/providers/base-provider.d.ts +21 -0
  14. package/dist/services/ai/providers/base-provider.d.ts.map +1 -0
  15. package/dist/services/ai/providers/base-provider.js +6 -0
  16. package/dist/services/ai/providers/openai-chat-completion.d.ts +12 -0
  17. package/dist/services/ai/providers/openai-chat-completion.d.ts.map +1 -0
  18. package/dist/services/ai/providers/openai-chat-completion.js +181 -0
  19. package/dist/services/ai/providers/openai-responses.d.ts +14 -0
  20. package/dist/services/ai/providers/openai-responses.d.ts.map +1 -0
  21. package/dist/services/ai/providers/openai-responses.js +191 -0
  22. package/dist/services/ai/session/ai-session-manager.d.ts +21 -0
  23. package/dist/services/ai/session/ai-session-manager.d.ts.map +1 -0
  24. package/dist/services/ai/session/ai-session-manager.js +165 -0
  25. package/dist/services/ai/session/session-types.d.ts +43 -0
  26. package/dist/services/ai/session/session-types.d.ts.map +1 -0
  27. package/dist/services/ai/session/session-types.js +1 -0
  28. package/dist/services/ai/tools/tool-schema.d.ts +41 -0
  29. package/dist/services/ai/tools/tool-schema.d.ts.map +1 -0
  30. package/dist/services/ai/tools/tool-schema.js +24 -0
  31. package/dist/services/api-handlers.d.ts +11 -3
  32. package/dist/services/api-handlers.d.ts.map +1 -1
  33. package/dist/services/api-handlers.js +143 -30
  34. package/dist/services/auto-capture.d.ts +1 -30
  35. package/dist/services/auto-capture.d.ts.map +1 -1
  36. package/dist/services/auto-capture.js +199 -396
  37. package/dist/services/cleanup-service.d.ts +3 -0
  38. package/dist/services/cleanup-service.d.ts.map +1 -1
  39. package/dist/services/cleanup-service.js +31 -4
  40. package/dist/services/client.d.ts +1 -0
  41. package/dist/services/client.d.ts.map +1 -1
  42. package/dist/services/client.js +3 -11
  43. package/dist/services/sqlite/connection-manager.d.ts.map +1 -1
  44. package/dist/services/sqlite/connection-manager.js +8 -4
  45. package/dist/services/user-memory-learning.d.ts +3 -0
  46. package/dist/services/user-memory-learning.d.ts.map +1 -0
  47. package/dist/services/user-memory-learning.js +164 -0
  48. package/dist/services/user-prompt/user-prompt-manager.d.ts +38 -0
  49. package/dist/services/user-prompt/user-prompt-manager.d.ts.map +1 -0
  50. package/dist/services/user-prompt/user-prompt-manager.js +164 -0
  51. package/dist/services/web-server-worker.js +27 -6
  52. package/dist/services/web-server.d.ts.map +1 -1
  53. package/dist/services/web-server.js +0 -5
  54. package/dist/types/index.d.ts +5 -1
  55. package/dist/types/index.d.ts.map +1 -1
  56. package/dist/web/app.js +210 -120
  57. package/dist/web/index.html +14 -10
  58. package/dist/web/styles.css +326 -1
  59. package/package.json +4 -1
  60. package/dist/services/compaction.d.ts +0 -92
  61. package/dist/services/compaction.d.ts.map +0 -1
  62. package/dist/services/compaction.js +0 -421
  63. package/dist/services/sqlite-client.d.ts +0 -116
  64. package/dist/services/sqlite-client.d.ts.map +0 -1
  65. package/dist/services/sqlite-client.js +0 -284
  66. package/dist/services/web-server-lock.d.ts +0 -12
  67. package/dist/services/web-server-lock.d.ts.map +0 -1
  68. package/dist/services/web-server-lock.js +0 -157
  69. package/dist/web/favicon.svg +0 -14
package/README.md CHANGED
@@ -6,29 +6,25 @@ A persistent memory system for AI coding agents that enables long-term context r
6
6
 
7
7
  ## Overview
8
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.
9
+ OpenCode Memory 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.
10
10
 
11
11
  ## Key Features
12
12
 
13
- - **Local Vector Database**: SQLite-based storage with sqlite-vec extension for efficient similarity search
13
+ - **Local Vector Database**: SQLite-based storage with sqlite-vec extension
14
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
15
+ - **Unified Timeline**: Browse memories and prompts together with linking support
16
+ - **Prompt-Memory Linking**: Bidirectional links between prompts and generated memories
17
+ - **User Learning System**: Analyzes user patterns and preferences from conversation history
18
+ - **Web Interface**: Full-featured UI for memory management and search
19
+ - **Auto-Capture System**: Intelligent prompt-based memory extraction
20
+ - **Multi-Provider AI**: Support for OpenAI, Anthropic, and OpenAI-compatible APIs
21
+ - **Flexible Embedding Models**: 12+ local models or OpenAI-compatible APIs
19
22
  - **Smart Deduplication**: Prevents redundant memories using similarity detection
20
23
  - **Privacy Protection**: Built-in content filtering for sensitive information
21
- - **Zero Configuration**: Works out of the box with sensible defaults
22
24
 
23
25
  ## Installation
24
26
 
25
- ### Prerequisites
26
-
27
- - OpenCode AI platform
28
-
29
- ### Install Plugin
30
-
31
- Add the plugin to your OpenCode configuration file:
27
+ Add the plugin to your OpenCode configuration:
32
28
 
33
29
  **Location**: `~/.config/opencode/opencode.json` or `opencode.jsonc`
34
30
 
@@ -42,9 +38,7 @@ Add the plugin to your OpenCode configuration file:
42
38
 
43
39
  OpenCode will automatically download and install the plugin on next startup.
44
40
 
45
- ### Install from Source (Development)
46
-
47
- For development or contributing:
41
+ ### Install from Source
48
42
 
49
43
  ```bash
50
44
  git clone https://github.com/tickernelz/opencode-mem.git
@@ -53,42 +47,23 @@ bun install
53
47
  bun run build
54
48
  ```
55
49
 
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
50
  ## Quick Start
67
51
 
68
52
  ### Basic Usage
69
53
 
70
- Once installed, the memory tool is automatically available in your OpenCode environment:
71
-
72
54
  ```typescript
73
- memory({ mode: "add", content: "User prefers TypeScript over JavaScript", scope: "user" })
55
+ memory({ mode: "add", content: "User prefers TypeScript", scope: "user" })
74
56
  memory({ mode: "search", query: "coding preferences", scope: "user" })
75
57
  memory({ mode: "profile" })
76
- memory({ mode: "list", scope: "project", limit: 10 })
77
58
  ```
78
59
 
79
60
  ### Web Interface
80
61
 
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
62
+ Access at `http://127.0.0.1:4747` to browse memories, view prompt-memory links, and manage your memory database.
88
63
 
89
64
  ### Configuration
90
65
 
91
- Configuration file is automatically created at `~/.config/opencode/opencode-mem.jsonc`:
66
+ Configuration file: `~/.config/opencode/opencode-mem.jsonc`
92
67
 
93
68
  ```jsonc
94
69
  {
@@ -96,493 +71,121 @@ Configuration file is automatically created at `~/.config/opencode/opencode-mem.
96
71
  "embeddingModel": "Xenova/nomic-embed-text-v1",
97
72
  "webServerEnabled": true,
98
73
  "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
74
  "autoCaptureEnabled": true,
75
+ "memoryProvider": "openai-chat",
203
76
  "memoryModel": "gpt-4",
204
77
  "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"
78
+ "memoryApiKey": "sk-..."
244
79
  }
245
80
  ```
246
81
 
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
82
+ ## Breaking Changes (v2.0)
289
83
 
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
84
+ **Token-based auto-capture has been replaced with prompt-based system:**
295
85
 
296
- ### Memory Editor
86
+ - Removed: `autoCaptureTokenThreshold`, `autoCaptureMinTokens`, `autoCaptureMaxMemories`, `autoCaptureSummaryMaxLength`, `autoCaptureContextWindow`
87
+ - Added: `memoryProvider`, `userMemoryAnalysisInterval`, `autoCaptureMaxIterations`, `autoCaptureIterationTimeout`
88
+ - New behavior: Triggers on session idle, analyzes last uncaptured prompt
89
+ - Automatic skip logic for non-technical conversations
90
+ - Prompt-memory linking with cascade delete support
297
91
 
298
- - Edit content and metadata
299
- - Change scope and type
300
- - Add or remove tags
301
- - Pin important memories
302
- - Delete individual memories
92
+ **Migration required**: Remove deprecated config options and add new ones.
303
93
 
304
- ### Maintenance Dashboard
94
+ ## Documentation
305
95
 
306
- - Run cleanup operations
307
- - Execute deduplication
308
- - Perform model migrations
309
- - View operation results
310
- - Dry-run mode for safety
96
+ For detailed documentation, see the [Wiki](https://github.com/tickernelz/opencode-mem/wiki):
311
97
 
312
- ### Statistics
98
+ - [Installation Guide](https://github.com/tickernelz/opencode-mem/wiki/Installation-Guide)
99
+ - [Quick Start](https://github.com/tickernelz/opencode-mem/wiki/Quick-Start)
100
+ - [Configuration Guide](https://github.com/tickernelz/opencode-mem/wiki/Configuration-Guide)
101
+ - [Memory Operations](https://github.com/tickernelz/opencode-mem/wiki/Memory-Operations)
102
+ - [Auto-Capture System](https://github.com/tickernelz/opencode-mem/wiki/Auto-Capture-System)
103
+ - [Web Interface](https://github.com/tickernelz/opencode-mem/wiki/Web-Interface)
104
+ - [Embedding Models](https://github.com/tickernelz/opencode-mem/wiki/Embedding-Models)
105
+ - [Performance Tuning](https://github.com/tickernelz/opencode-mem/wiki/Performance-Tuning)
106
+ - [Troubleshooting](https://github.com/tickernelz/opencode-mem/wiki/Troubleshooting)
313
107
 
314
- - Total memory count by scope
315
- - Storage usage metrics
316
- - Auto-capture statistics
317
- - Search performance metrics
108
+ ## Features Overview
318
109
 
319
- ## Configuration Reference
110
+ ### Memory Scopes
320
111
 
321
- ### Storage Settings
112
+ - **User Scope**: Cross-project preferences, coding style, communication patterns
113
+ - **Project Scope**: Architecture decisions, technology stack, implementation details
322
114
 
323
- | Option | Type | Default | Description |
324
- |--------|------|---------|-------------|
325
- | `storagePath` | string | `~/.opencode-mem/data` | Database storage location |
326
- | `maxVectorsPerShard` | number | `50000` | Vectors per shard before splitting |
115
+ ### Auto-Capture System
327
116
 
328
- ### Embedding Settings
117
+ Automatically extracts memories from conversations:
329
118
 
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 |
119
+ 1. Triggers on session idle
120
+ 2. Analyzes last uncaptured prompt and response
121
+ 3. Links memory to source prompt
122
+ 4. Skips non-technical conversations
336
123
 
337
- ### Web Server Settings
124
+ ### User Learning System
338
125
 
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 |
126
+ Analyzes batches of prompts to identify patterns (default: every 10 prompts):
344
127
 
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 |
128
+ - Coding style preferences
129
+ - Communication patterns
130
+ - Tool preferences
131
+ - Skill level indicators
374
132
 
375
- ### Advanced Settings
133
+ ### Web Interface
376
134
 
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 |
135
+ - Unified timeline of memories and prompts
136
+ - Visual prompt-memory link indicators
137
+ - Cascade delete for linked items
138
+ - Bulk operations
139
+ - Search and filters
140
+ - Maintenance tools (cleanup, deduplication)
383
141
 
384
142
  ## API Reference
385
143
 
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
144
+ ### Memory Tool
425
145
 
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
- }
146
+ ```typescript
147
+ memory({ mode: "add", content: "...", scope: "user|project" })
148
+ memory({ mode: "search", query: "...", scope: "user|project" })
149
+ memory({ mode: "list", scope: "user|project", limit: 10 })
150
+ memory({ mode: "profile" })
151
+ memory({ mode: "forget", memoryId: "..." })
152
+ memory({ mode: "auto-capture-toggle" })
153
+ memory({ mode: "auto-capture-stats" })
154
+ memory({ mode: "capture-now" })
468
155
  ```
469
156
 
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
157
+ ### REST API
478
158
 
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.
159
+ - `GET /api/memories?scope=project&includePrompts=true` - List memories/prompts
160
+ - `POST /api/memories` - Create memory
161
+ - `PUT /api/memories/:id` - Update memory
162
+ - `DELETE /api/memories/:id?cascade=true` - Delete memory (and linked prompt)
163
+ - `DELETE /api/prompts/:id?cascade=true` - Delete prompt (and linked memory)
164
+ - `POST /api/search` - Vector search
165
+ - `POST /api/cleanup` - Run cleanup
166
+ - `POST /api/deduplicate` - Run deduplication
498
167
 
499
168
  ## Development
500
169
 
501
- ### Build from Source
502
-
503
170
  ```bash
504
- git clone https://github.com/tickernelz/opencode-mem.git
505
- cd opencode-mem
506
171
  bun install
507
- bun run build
508
- ```
509
-
510
- ### Development Mode
511
-
512
- ```bash
513
172
  bun run dev
514
- ```
515
-
516
- ### Code Formatting
517
-
518
- ```bash
173
+ bun run build
519
174
  bun run format
520
- bun run format:check
521
- ```
522
-
523
- ### Type Checking
524
-
525
- ```bash
526
175
  bun run typecheck
527
176
  ```
528
177
 
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
178
  ## License
573
179
 
574
180
  MIT License - see LICENSE file for details
575
181
 
576
182
  ## Acknowledgments
577
183
 
578
- This project was inspired by and references [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory) as the primary reference implementation.
184
+ Inspired by [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory)
579
185
 
580
186
  ## Links
581
187
 
582
188
  - **Repository**: https://github.com/tickernelz/opencode-mem
189
+ - **Wiki**: https://github.com/tickernelz/opencode-mem/wiki
583
190
  - **Issues**: https://github.com/tickernelz/opencode-mem/issues
584
191
  - **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 CHANGED
@@ -12,14 +12,13 @@ export declare const CONFIG: {
12
12
  containerTagPrefix: string;
13
13
  keywordPatterns: string[];
14
14
  autoCaptureEnabled: boolean;
15
- autoCaptureTokenThreshold: number;
16
- autoCaptureMinTokens: number;
17
- autoCaptureMaxMemories: number;
18
- autoCaptureSummaryMaxLength: number;
19
- autoCaptureContextWindow: number;
15
+ autoCaptureMaxIterations: number;
16
+ autoCaptureIterationTimeout: number;
17
+ memoryProvider: "openai-chat" | "openai-responses" | "anthropic";
20
18
  memoryModel: string | undefined;
21
19
  memoryApiUrl: string | undefined;
22
20
  memoryApiKey: string | undefined;
21
+ aiSessionRetentionDays: number;
23
22
  webServerEnabled: boolean;
24
23
  webServerPort: number;
25
24
  webServerHost: string;
@@ -28,6 +27,7 @@ export declare const CONFIG: {
28
27
  autoCleanupRetentionDays: number;
29
28
  deduplicationEnabled: boolean;
30
29
  deduplicationSimilarityThreshold: number;
30
+ userMemoryAnalysisInterval: number;
31
31
  };
32
32
  export declare function isConfigured(): boolean;
33
33
  //# sourceMappingURL=config.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmTA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;oBAwBb,aAAa,GACb,kBAAkB,GAClB,WAAW;;;;;;;;;;;;;;CAiBhB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}