om-memory-system 3.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/LICENSE +21 -0
- package/README.md +587 -0
- package/dist/adapters/opencode/auto-capture-host.d.ts +3 -0
- package/dist/adapters/opencode/auto-capture-host.js +29 -0
- package/dist/adapters/opencode/auto-capture-summary.d.ts +4 -0
- package/dist/adapters/opencode/auto-capture-summary.js +147 -0
- package/dist/adapters/opencode/conversation.d.ts +2 -0
- package/dist/adapters/opencode/conversation.js +50 -0
- package/dist/adapters/opencode/user-prompt.d.ts +9 -0
- package/dist/adapters/opencode/user-prompt.js +26 -0
- package/dist/adapters/pi/capture.d.ts +41 -0
- package/dist/adapters/pi/capture.js +91 -0
- package/dist/adapters/pi/conversation.d.ts +38 -0
- package/dist/adapters/pi/conversation.js +118 -0
- package/dist/adapters/pi/extension.d.ts +18 -0
- package/dist/adapters/pi/extension.js +234 -0
- package/dist/adapters/pi/import-command.d.ts +29 -0
- package/dist/adapters/pi/import-command.js +232 -0
- package/dist/adapters/pi/profile.d.ts +39 -0
- package/dist/adapters/pi/profile.js +148 -0
- package/dist/adapters/pi/provider.d.ts +50 -0
- package/dist/adapters/pi/provider.js +77 -0
- package/dist/config.d.ts +290 -0
- package/dist/config.js +742 -0
- package/dist/core/capture-context.d.ts +4 -0
- package/dist/core/capture-context.js +132 -0
- package/dist/core/capture.d.ts +15 -0
- package/dist/core/capture.js +68 -0
- package/dist/core/extraction.d.ts +80 -0
- package/dist/core/extraction.js +140 -0
- package/dist/core/host.d.ts +52 -0
- package/dist/core/host.js +1 -0
- package/dist/core/memory-operations.d.ts +27 -0
- package/dist/core/memory-operations.js +247 -0
- package/dist/core/retrieval.d.ts +12 -0
- package/dist/core/retrieval.js +72 -0
- package/dist/importer/discovery.d.ts +31 -0
- package/dist/importer/discovery.js +88 -0
- package/dist/importer/importer.d.ts +87 -0
- package/dist/importer/importer.js +260 -0
- package/dist/importer/ledger.d.ts +44 -0
- package/dist/importer/ledger.js +137 -0
- package/dist/importer/session-loader.d.ts +19 -0
- package/dist/importer/session-loader.js +12 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +601 -0
- package/dist/plugin.d.ts +9 -0
- package/dist/plugin.js +11 -0
- package/dist/services/ai/ai-provider-factory.d.ts +7 -0
- package/dist/services/ai/ai-provider-factory.js +41 -0
- package/dist/services/ai/api-key-placeholder.d.ts +1 -0
- package/dist/services/ai/api-key-placeholder.js +14 -0
- package/dist/services/ai/internal-capture-sessions.d.ts +6 -0
- package/dist/services/ai/internal-capture-sessions.js +33 -0
- package/dist/services/ai/opencode-diagnostics.d.ts +7 -0
- package/dist/services/ai/opencode-diagnostics.js +36 -0
- package/dist/services/ai/opencode-host-config.d.ts +10 -0
- package/dist/services/ai/opencode-host-config.js +51 -0
- package/dist/services/ai/opencode-provider-loader.d.ts +3 -0
- package/dist/services/ai/opencode-provider-loader.js +4 -0
- package/dist/services/ai/opencode-provider.d.ts +92 -0
- package/dist/services/ai/opencode-provider.js +419 -0
- package/dist/services/ai/opencode-sdk-client.d.ts +6 -0
- package/dist/services/ai/opencode-sdk-client.js +38 -0
- package/dist/services/ai/profile-llm-client.d.ts +2 -0
- package/dist/services/ai/profile-llm-client.js +27 -0
- package/dist/services/ai/provider-config.d.ts +17 -0
- package/dist/services/ai/provider-config.js +30 -0
- package/dist/services/ai/providers/anthropic-messages.d.ts +34 -0
- package/dist/services/ai/providers/anthropic-messages.js +220 -0
- package/dist/services/ai/providers/base-provider.d.ts +24 -0
- package/dist/services/ai/providers/base-provider.js +24 -0
- package/dist/services/ai/providers/google-gemini.d.ts +15 -0
- package/dist/services/ai/providers/google-gemini.js +228 -0
- package/dist/services/ai/providers/minimax.d.ts +35 -0
- package/dist/services/ai/providers/minimax.js +55 -0
- package/dist/services/ai/providers/openai-chat-completion.d.ts +22 -0
- package/dist/services/ai/providers/openai-chat-completion.js +387 -0
- package/dist/services/ai/providers/openai-responses.d.ts +13 -0
- package/dist/services/ai/providers/openai-responses.js +182 -0
- package/dist/services/ai/providers/orcarouter.d.ts +51 -0
- package/dist/services/ai/providers/orcarouter.js +66 -0
- package/dist/services/ai/session/ai-session-manager.d.ts +24 -0
- package/dist/services/ai/session/ai-session-manager.js +211 -0
- package/dist/services/ai/session/session-types.d.ts +42 -0
- package/dist/services/ai/session/session-types.js +1 -0
- package/dist/services/ai/tools/tool-schema.d.ts +40 -0
- package/dist/services/ai/tools/tool-schema.js +24 -0
- package/dist/services/ai/validators/user-profile-validator.d.ts +12 -0
- package/dist/services/ai/validators/user-profile-validator.js +114 -0
- package/dist/services/api-handlers.d.ts +186 -0
- package/dist/services/api-handlers.js +1284 -0
- package/dist/services/auth-token.d.ts +14 -0
- package/dist/services/auth-token.js +59 -0
- package/dist/services/auto-capture.d.ts +3 -0
- package/dist/services/auto-capture.js +127 -0
- package/dist/services/cleanup-service.d.ts +22 -0
- package/dist/services/cleanup-service.js +109 -0
- package/dist/services/client.d.ts +134 -0
- package/dist/services/client.js +327 -0
- package/dist/services/context.d.ts +10 -0
- package/dist/services/context.js +27 -0
- package/dist/services/cors.d.ts +12 -0
- package/dist/services/cors.js +52 -0
- package/dist/services/deduplication-service.d.ts +28 -0
- package/dist/services/deduplication-service.js +111 -0
- package/dist/services/embedding.d.ts +36 -0
- package/dist/services/embedding.js +200 -0
- package/dist/services/jsonc.d.ts +6 -0
- package/dist/services/jsonc.js +76 -0
- package/dist/services/language-detector.d.ts +2 -0
- package/dist/services/language-detector.js +33 -0
- package/dist/services/legacy-migration.d.ts +77 -0
- package/dist/services/legacy-migration.js +343 -0
- package/dist/services/logger.d.ts +1 -0
- package/dist/services/logger.js +119 -0
- package/dist/services/memory-portability-service.d.ts +37 -0
- package/dist/services/memory-portability-service.js +340 -0
- package/dist/services/memory-scope.d.ts +16 -0
- package/dist/services/memory-scope.js +43 -0
- package/dist/services/migration-service.d.ts +42 -0
- package/dist/services/migration-service.js +307 -0
- package/dist/services/onnxruntime-resolve.d.ts +24 -0
- package/dist/services/onnxruntime-resolve.js +174 -0
- package/dist/services/privacy.d.ts +26 -0
- package/dist/services/privacy.js +69 -0
- package/dist/services/request-timeouts.d.ts +9 -0
- package/dist/services/request-timeouts.js +11 -0
- package/dist/services/runtime-require.d.ts +17 -0
- package/dist/services/runtime-require.js +75 -0
- package/dist/services/secret-resolver.d.ts +1 -0
- package/dist/services/secret-resolver.js +65 -0
- package/dist/services/shard-inventory-service.d.ts +69 -0
- package/dist/services/shard-inventory-service.js +315 -0
- package/dist/services/shard-path-migration-service.d.ts +31 -0
- package/dist/services/shard-path-migration-service.js +367 -0
- package/dist/services/tag-prefix-migration.d.ts +60 -0
- package/dist/services/tag-prefix-migration.js +439 -0
- package/dist/services/tag-prefix-scan.d.ts +26 -0
- package/dist/services/tag-prefix-scan.js +91 -0
- package/dist/services/tags.d.ts +29 -0
- package/dist/services/tags.js +251 -0
- package/dist/services/turso/connection-manager.d.ts +15 -0
- package/dist/services/turso/connection-manager.js +163 -0
- package/dist/services/turso/cross-process-write-lock.d.ts +1 -0
- package/dist/services/turso/cross-process-write-lock.js +89 -0
- package/dist/services/turso/legacy-migrator.d.ts +1 -0
- package/dist/services/turso/legacy-migrator.js +540 -0
- package/dist/services/turso/lifecycle.d.ts +1 -0
- package/dist/services/turso/lifecycle.js +14 -0
- package/dist/services/turso/operation-lock.d.ts +2 -0
- package/dist/services/turso/operation-lock.js +61 -0
- package/dist/services/turso/ready.d.ts +2 -0
- package/dist/services/turso/ready.js +36 -0
- package/dist/services/turso/shard-manager.d.ts +38 -0
- package/dist/services/turso/shard-manager.js +496 -0
- package/dist/services/turso/sqlite-handle-release.d.ts +16 -0
- package/dist/services/turso/sqlite-handle-release.js +56 -0
- package/dist/services/turso/turso-db.d.ts +18 -0
- package/dist/services/turso/turso-db.js +53 -0
- package/dist/services/turso/types.d.ts +42 -0
- package/dist/services/turso/types.js +1 -0
- package/dist/services/turso/vector-search.d.ts +41 -0
- package/dist/services/turso/vector-search.js +384 -0
- package/dist/services/turso/vector-utils.d.ts +7 -0
- package/dist/services/turso/vector-utils.js +67 -0
- package/dist/services/user-memory-learning.d.ts +97 -0
- package/dist/services/user-memory-learning.js +673 -0
- package/dist/services/user-profile/ai-cleanup.d.ts +58 -0
- package/dist/services/user-profile/ai-cleanup.js +486 -0
- package/dist/services/user-profile/profile-context.d.ts +1 -0
- package/dist/services/user-profile/profile-context.js +105 -0
- package/dist/services/user-profile/profile-utils.d.ts +2 -0
- package/dist/services/user-profile/profile-utils.js +45 -0
- package/dist/services/user-profile/types.d.ts +92 -0
- package/dist/services/user-profile/types.js +1 -0
- package/dist/services/user-profile/user-profile-manager.d.ts +65 -0
- package/dist/services/user-profile/user-profile-manager.js +1660 -0
- package/dist/services/user-prompt/user-prompt-manager.d.ts +53 -0
- package/dist/services/user-prompt/user-prompt-manager.js +303 -0
- package/dist/services/web-api-auth.d.ts +3 -0
- package/dist/services/web-api-auth.js +25 -0
- package/dist/services/web-auth.d.ts +46 -0
- package/dist/services/web-auth.js +105 -0
- package/dist/services/web-server.d.ts +57 -0
- package/dist/services/web-server.js +659 -0
- package/dist/shared/api/index.d.ts +4 -0
- package/dist/shared/api/index.js +2 -0
- package/dist/shared/api/portability-schemas.d.ts +56 -0
- package/dist/shared/api/portability-schemas.js +39 -0
- package/dist/shared/api/schemas.d.ts +295 -0
- package/dist/shared/api/schemas.js +134 -0
- package/dist/shared/api/types.d.ts +28 -0
- package/dist/shared/api/types.js +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/context-limit.d.ts +10 -0
- package/dist/utils/context-limit.js +43 -0
- package/dist/utils/math.d.ts +7 -0
- package/dist/utils/math.js +48 -0
- package/dist/utils/profile.d.ts +2 -0
- package/dist/utils/profile.js +15 -0
- package/dist/v2/adapter.d.ts +5 -0
- package/dist/v2/adapter.js +218 -0
- package/dist/v2/legacy-client.d.ts +15 -0
- package/dist/v2/legacy-client.js +257 -0
- package/dist/v2/memory-bridge.d.ts +18 -0
- package/dist/v2/memory-bridge.js +29 -0
- package/dist/v2/plugin.d.ts +3 -0
- package/dist/v2/plugin.js +24 -0
- package/dist/web/assets/index-DPjEpD1h.css +2 -0
- package/dist/web/assets/index-do26c4JJ.js +122 -0
- package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/index.html +14 -0
- package/dist/web/omms-icon.png +0 -0
- package/package.json +138 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dr Muhammad Aizat Hawari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
# OMMS — Opinionated Modular Memory System
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/om-memory-system)
|
|
4
|
+
[](https://www.npmjs.com/package/om-memory-system)
|
|
5
|
+
[](https://www.npmjs.com/package/om-memory-system)
|
|
6
|
+
|
|
7
|
+
> **Fork notice.** This is [`cmdaltctr/omms`](https://github.com/cmdaltctr/omms), a fork of
|
|
8
|
+
> [`tickernelz/opencode-mem`](https://github.com/tickernelz/opencode-mem), published on npm as **`om-memory-system`**, the Opinionated
|
|
9
|
+
> Modular Memory System for coding agents. The fork adds first-class integration with the
|
|
10
|
+
> [Pi coding agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent): the memory engine now runs as a
|
|
11
|
+
> shared, host-neutral core behind a native Pi extension, so OpenCode and Pi read and write one memory store per
|
|
12
|
+
> project. Existing OpenCode memory data migrates automatically and safely on first start; see
|
|
13
|
+
> [docs/omms-migration.md](docs/omms-migration.md). All existing OpenCode behaviour, storage compatibility, and
|
|
14
|
+
> configuration are preserved. See [docs/shared-core.md](docs/shared-core.md) for the boundary,
|
|
15
|
+
> [docs/pi-adapter.md](docs/pi-adapter.md) for Pi installation and lifecycle details, and
|
|
16
|
+
> [docs/pi-history-import.md](docs/pi-history-import.md) to import existing Pi session history.
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
A persistent memory system for AI coding agents that enables long-term context retention across sessions using local vector database technology.
|
|
21
|
+
|
|
22
|
+
## Visual Overview
|
|
23
|
+
|
|
24
|
+
**Project Memory Timeline:**
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
**User Profile Viewer:**
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
## Core Features
|
|
33
|
+
|
|
34
|
+
Local Turso/libSQL database with native vector search, persistent project memories, automatic user profile learning, unified memory-prompt timeline, full-featured web UI, intelligent prompt-based memory extraction, multi-provider AI support (OpenAI, Anthropic), 12+ local embedding models, smart deduplication, and built-in privacy protection.
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
This plugin uses embedded Turso/libSQL with native vector indexes (`F32_BLOB`, `vector_top_k`). No separate vector database or custom SQLite build is required.
|
|
39
|
+
|
|
40
|
+
**Recommended runtime:**
|
|
41
|
+
|
|
42
|
+
- Bun
|
|
43
|
+
- Standard OpenCode plugin environment
|
|
44
|
+
- Internet access on first use if you use the default local embedding model, because the model is downloaded by `@huggingface/transformers`.
|
|
45
|
+
- For source/development installs, run `bun install` before building or testing. The published plugin package installs its runtime dependencies automatically through OpenCode.
|
|
46
|
+
|
|
47
|
+
**CI-tested platforms:** Linux, Windows, macOS 15 and macOS 26 on both Intel (`darwin/x64`) and Apple Silicon (`darwin/arm64`). Older macOS releases are not excluded by that matrix; they are simply outside the current GitHub-hosted runner set.
|
|
48
|
+
|
|
49
|
+
**Notes:**
|
|
50
|
+
|
|
51
|
+
- Vector embeddings are stored and searched directly in Turso/libSQL; inserts update the vector index automatically.
|
|
52
|
+
- Vector search uses libSQL's DiskANN index via `vector_top_k` (approximate nearest neighbors).
|
|
53
|
+
- Auto-capture and user profile learning require an AI provider that can return structured/tool-call output. Memory search/add/list still work without auto-capture provider configuration.
|
|
54
|
+
|
|
55
|
+
### Upgrading from legacy SQLite shards
|
|
56
|
+
|
|
57
|
+
On first startup after upgrading, omms automatically migrates existing memory shard databases to native Turso/libSQL vector format:
|
|
58
|
+
|
|
59
|
+
- Each shard is backed up as `<shard>.db.legacy.bak` before rewrite
|
|
60
|
+
- Progress is tracked per shard in `<shard>.db.turso-migrate.json`
|
|
61
|
+
- A global marker `.turso-migrated` is written only after all shards verify successfully
|
|
62
|
+
- Do not run multiple OpenCode instances against the same `storagePath` during migration; a lock file (`.turso-migrate.lock`) prevents concurrent migration
|
|
63
|
+
- Manual dimension migrations use `.turso-operation.lock`; other plugin processes reject new memory writes until the migration finishes
|
|
64
|
+
|
|
65
|
+
If migration is interrupted, the next startup resumes from the backup automatically.
|
|
66
|
+
|
|
67
|
+
If a shard becomes incompatible (for example after changing `embeddingDimensions`), writes are blocked and the original database is left untouched. Use the Web UI's re-embed migration to build and verify a replacement before it is swapped into place. The previous shard remains available as `<shard>.db.pre-reembed-<pid>-<timestamp>.bak`.
|
|
68
|
+
|
|
69
|
+
## Install OMMS
|
|
70
|
+
|
|
71
|
+
Install OMMS in the coding agent you use. You can install it in both OpenCode
|
|
72
|
+
and Pi. They share one project memory store.
|
|
73
|
+
|
|
74
|
+
### OpenCode
|
|
75
|
+
|
|
76
|
+
Add `om-memory-system` (the npm name for omms) to your OpenCode configuration. OpenCode downloads the package
|
|
77
|
+
when you restart it. On OpenCode v2 you can instead run `opencode plugin add om-memory-system`,
|
|
78
|
+
which installs the package and updates your global configuration for you.
|
|
79
|
+
|
|
80
|
+
#### macOS
|
|
81
|
+
|
|
82
|
+
Edit `~/.config/opencode/opencode.json`.
|
|
83
|
+
|
|
84
|
+
For OpenCode v2, use the native `plugins` list:
|
|
85
|
+
|
|
86
|
+
```jsonc
|
|
87
|
+
{
|
|
88
|
+
"plugins": ["om-memory-system"],
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For OpenCode v1 (1.18.29 or later), use the `plugin` list:
|
|
93
|
+
|
|
94
|
+
```jsonc
|
|
95
|
+
{
|
|
96
|
+
"plugin": ["om-memory-system"],
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Restart OpenCode after you save the file.
|
|
101
|
+
|
|
102
|
+
#### Windows
|
|
103
|
+
|
|
104
|
+
Edit `%USERPROFILE%\.config\opencode\opencode.json`, for example
|
|
105
|
+
`C:\Users\<you>\.config\opencode\opencode.json`.
|
|
106
|
+
|
|
107
|
+
For OpenCode v2, use:
|
|
108
|
+
|
|
109
|
+
```jsonc
|
|
110
|
+
{
|
|
111
|
+
"plugins": ["om-memory-system"],
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
For OpenCode v1 (1.18.29 or later), use:
|
|
116
|
+
|
|
117
|
+
```jsonc
|
|
118
|
+
{
|
|
119
|
+
"plugin": ["om-memory-system"],
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Restart OpenCode after you save the file. OMMS does not read `%APPDATA%` or
|
|
124
|
+
`%LOCALAPPDATA%` for this setting.
|
|
125
|
+
|
|
126
|
+
### Pi coding agent
|
|
127
|
+
|
|
128
|
+
Run the following command in Terminal on macOS or PowerShell on Windows:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pi install npm:om-memory-system
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Restart Pi after installation. The extension reads the same configuration and
|
|
135
|
+
storage path as OpenCode, so memories remain available in both agents.
|
|
136
|
+
|
|
137
|
+
See [docs/pi-adapter.md](docs/pi-adapter.md) for Pi lifecycle details and
|
|
138
|
+
[docs/pi-history-import.md](docs/pi-history-import.md) to import existing Pi
|
|
139
|
+
session history.
|
|
140
|
+
|
|
141
|
+
Once OMMS is running, open the memory explorer web UI at
|
|
142
|
+
`http://127.0.0.1:4747`. It ships with every release.
|
|
143
|
+
|
|
144
|
+
### Update OMMS
|
|
145
|
+
|
|
146
|
+
Install OMMS without a version number, as shown above, so your agent can tell
|
|
147
|
+
you when a new release is out. Neither agent installs updates by itself; you
|
|
148
|
+
choose when to update.
|
|
149
|
+
|
|
150
|
+
| Agent | How you hear about a new release | Update with |
|
|
151
|
+
| ----------- | ------------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
152
|
+
| Pi | Pi shows an update notice while you work | `pi update npm:om-memory-system` (or `pi update --extensions` for all) |
|
|
153
|
+
| OpenCode v2 | Run `opencode plugin check` to list plugins with new versions | `opencode plugin update om-memory-system` (or `opencode plugin update`) |
|
|
154
|
+
|
|
155
|
+
Restart the agent after updating.
|
|
156
|
+
|
|
157
|
+
To stay on one version, install it with the version number instead:
|
|
158
|
+
`pi install npm:om-memory-system@3.1.0` in Pi, or `opencode plugin add om-memory-system@3.1.0` in
|
|
159
|
+
OpenCode. A pinned install is never updated or flagged; install without the
|
|
160
|
+
number again to go back to receiving updates.
|
|
161
|
+
|
|
162
|
+
Release notes for every version are in [CHANGELOG.md](CHANGELOG.md) and on the
|
|
163
|
+
[GitHub Releases](https://github.com/cmdaltctr/omms/releases) page.
|
|
164
|
+
|
|
165
|
+
Upgrading from an existing `opencode-mem` install? The store migrates to
|
|
166
|
+
`~/.omms/data` automatically on first start, with a verified backup first.
|
|
167
|
+
See [docs/omms-migration.md](docs/omms-migration.md).
|
|
168
|
+
|
|
169
|
+
## How to use day-to-day
|
|
170
|
+
|
|
171
|
+
You do **not** need to ask OpenCode to “remember” things for the plugin to work. With the defaults, memory builds up as you work.
|
|
172
|
+
|
|
173
|
+
### Typical daily flow
|
|
174
|
+
|
|
175
|
+
1. Enable the plugin (see [Install OMMS](#install-omms)) and restart OpenCode.
|
|
176
|
+
2. Configure an AI provider for auto-capture — recommended: `opencodeProvider` + `opencodeModel` (or `"opencodeModel": "inherit"`). Details under [Auto-Capture AI Provider](#auto-capture-ai-provider).
|
|
177
|
+
3. Work normally in OpenCode. When a session goes idle, auto-capture extracts memorable technical context and stores it.
|
|
178
|
+
4. Relevant memories are injected into context automatically. On OpenCode v2 and Pi, every prompt runs a semantic search of the project memory and adds the matches as an `<omms-retrieval>` system section (never as a chat message). On OpenCode v1, the most recent memories are injected on the first message of a session (`chatMessage.injectOn`). After compaction, the session's own memories are restored. Browse or edit memories in the web UI at `http://127.0.0.1:4747`.
|
|
179
|
+
5. Use the `memory` tool when you want something stored or retrieved immediately (see [Usage Examples](#usage-examples)).
|
|
180
|
+
|
|
181
|
+
### Automatic vs manual memory
|
|
182
|
+
|
|
183
|
+
| Approach | When it runs | What you do |
|
|
184
|
+
| ------------------------------------------------------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
185
|
+
| **Auto-capture** (`autoCaptureEnabled: true`, default) | After conversation turns when the session goes idle | Nothing — extraction is automatic |
|
|
186
|
+
| **Manual** `memory` tool / commands | On demand | `add`, `search`, `list`, `profile`, `forget`, `list-shards`, `migrate`, `export`, `import` |
|
|
187
|
+
|
|
188
|
+
Manual search/add/list still work even if auto-capture has no provider configured. Auto-capture and user profile learning need a provider that can return structured/tool-call output.
|
|
189
|
+
|
|
190
|
+
### Memory vs AGENTS.md / project docs
|
|
191
|
+
|
|
192
|
+
| Store in **memory** | Store in **AGENTS.md** / static docs |
|
|
193
|
+
| -------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
194
|
+
| Project-specific decisions, bug patterns, “we tried X and it failed” | Stable rules and workflows that rarely change |
|
|
195
|
+
| User preferences discovered over sessions | Always-on coding conventions and process |
|
|
196
|
+
| Facts that should follow you across chats | Instructions every agent should see regardless of retrieval |
|
|
197
|
+
|
|
198
|
+
Rule of thumb: if it is a lasting project instruction, put it in AGENTS.md; if it is context that grows from real work, let memory (or auto-capture) hold it.
|
|
199
|
+
|
|
200
|
+
### Intelligent prompt-based memory extraction
|
|
201
|
+
|
|
202
|
+
That phrase in the feature list is **auto-capture**: after a conversation, a background AI request summarizes technical work and saves it as memory. No special prompt from you is required. It uses `opencodeProvider` / `opencodeModel` when set, otherwise the manual `memoryProvider` fallback.
|
|
203
|
+
|
|
204
|
+
### User profile
|
|
205
|
+
|
|
206
|
+
The **User Profile** is a separate, cross-project summary of how you like to work (preferences, habits). It is updated on an interval (`userProfileAnalysisInterval`, default every 10 analyzed prompts), shown in the web UI’s profile view, and readable via `memory({ mode: "profile" })`. You do not populate it by hand for normal use — profile learning fills it when a provider is ready.
|
|
207
|
+
|
|
208
|
+
### Web UI
|
|
209
|
+
|
|
210
|
+
Open `http://127.0.0.1:4747` to browse the memory–prompt timeline, inspect captures, and manage the user profile. If you bind the server beyond loopback, see [Web UI HTTP Basic Auth](#web-ui-http-basic-auth).
|
|
211
|
+
|
|
212
|
+
## Usage Examples
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
memory({ mode: "add", content: "Project uses microservices architecture" });
|
|
216
|
+
memory({ mode: "search", query: "architecture decisions" });
|
|
217
|
+
memory({ mode: "search", query: "architecture decisions", scope: "all-projects" });
|
|
218
|
+
memory({ mode: "profile" });
|
|
219
|
+
memory({ mode: "list", limit: 10 });
|
|
220
|
+
memory({ mode: "list-shards" });
|
|
221
|
+
memory({ mode: "migrate", fromPath: "/old/path/to/project" });
|
|
222
|
+
memory({ mode: "export", outputPath: "./memories.json" });
|
|
223
|
+
memory({ mode: "import", inputPath: "./memories.json" });
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Access the web interface at `http://127.0.0.1:4747` for visual memory browsing and management.
|
|
227
|
+
|
|
228
|
+
**Network binding security:** Keep `webServerHost` on `127.0.0.1` unless you intentionally expose the UI. Binding to `0.0.0.0` (or any non-loopback host) requires `webServerApiToken`; all `/api/*` requests must then send `Authorization: Bearer <token>` or `X-Omms-Token` (the legacy `X-Opencode-Mem-Token` header is still accepted). Open the UI with `?apiToken=<token>` so the browser stores and sends it.
|
|
229
|
+
|
|
230
|
+
Dimension migrations generate every new embedding first, import them into a temporary indexed shard, verify the row count, and only then replace the original file. Failed migrations leave the source shard untouched.
|
|
231
|
+
|
|
232
|
+
## Configuration Essentials
|
|
233
|
+
|
|
234
|
+
Configure at `~/.config/omms/omms.jsonc`. While that file does not exist, omms still reads the legacy `~/.config/opencode/opencode-mem.jsonc` (it is never written), so existing installs keep working before you migrate settings. Per-project overrides go in `<project>/.opencode/omms.jsonc` (the legacy `.opencode/opencode-mem.jsonc` is still read when no `omms.jsonc` exists):
|
|
235
|
+
|
|
236
|
+
**Windows:** `%USERPROFILE%\.config\omms\omms.jsonc` (not AppData). Default storage resolves to `%USERPROFILE%\.omms\data` (the `~` form in the example below expands to your user home on Windows as well). A legacy `~/.opencode-mem/data` store migrates to the new path automatically on first start.
|
|
237
|
+
|
|
238
|
+
The plugin creates a full commented template at this path on first startup (only when no config exists at all). This trimmed example shows the most common settings:
|
|
239
|
+
|
|
240
|
+
```jsonc
|
|
241
|
+
{
|
|
242
|
+
"storagePath": "~/.omms/data",
|
|
243
|
+
"userEmailOverride": "user@example.com",
|
|
244
|
+
"userNameOverride": "John Doe",
|
|
245
|
+
"embeddingModel": "Xenova/nomic-embed-text-v1",
|
|
246
|
+
// Optional Nomic task prefixes (search_document: / search_query:). After enabling,
|
|
247
|
+
// re-index existing memories so store and query vectors stay aligned.
|
|
248
|
+
// "embeddingUseTaskPrefixes": true,
|
|
249
|
+
// Optional OpenAI-compatible embedding endpoint:
|
|
250
|
+
// "embeddingApiUrl": "https://api.openai.com/v1",
|
|
251
|
+
// "embeddingApiKey": "env://OPENAI_API_KEY",
|
|
252
|
+
// "embeddingModel": "text-embedding-3-small",
|
|
253
|
+
|
|
254
|
+
"memory": {
|
|
255
|
+
"defaultScope": "project",
|
|
256
|
+
},
|
|
257
|
+
"webServerEnabled": true,
|
|
258
|
+
"webServerPort": 4747,
|
|
259
|
+
// Required when webServerHost is not 127.0.0.1/localhost:
|
|
260
|
+
// "webServerHost": "0.0.0.0",
|
|
261
|
+
// "webServerApiToken": "env://OMMS_WEB_TOKEN",
|
|
262
|
+
|
|
263
|
+
"autoCaptureEnabled": true,
|
|
264
|
+
"autoCaptureLanguage": "auto",
|
|
265
|
+
|
|
266
|
+
"opencodeProvider": "anthropic",
|
|
267
|
+
"opencodeModel": "claude-haiku-4-5-20251001",
|
|
268
|
+
|
|
269
|
+
// Manual fallback if you do not use opencodeProvider:
|
|
270
|
+
// "memoryProvider": "openai-chat",
|
|
271
|
+
// "memoryModel": "gpt-4o-mini",
|
|
272
|
+
// "memoryApiUrl": "https://api.openai.com/v1",
|
|
273
|
+
// "memoryApiKey": "env://OPENAI_API_KEY",
|
|
274
|
+
|
|
275
|
+
"showAutoCaptureToasts": true,
|
|
276
|
+
"showUserProfileToasts": true,
|
|
277
|
+
"showErrorToasts": true,
|
|
278
|
+
|
|
279
|
+
"userProfileAnalysisInterval": 10,
|
|
280
|
+
"userProfileMaxContextBytes": 32768,
|
|
281
|
+
"maxMemories": 10,
|
|
282
|
+
|
|
283
|
+
"compaction": {
|
|
284
|
+
"enabled": true,
|
|
285
|
+
"memoryLimit": 10,
|
|
286
|
+
},
|
|
287
|
+
"chatMessage": {
|
|
288
|
+
"enabled": true,
|
|
289
|
+
"maxMemories": 3,
|
|
290
|
+
"excludeCurrentSession": true,
|
|
291
|
+
"maxAgeDays": undefined,
|
|
292
|
+
"injectOn": "first", // OpenCode v1 only; v2 and Pi search on every prompt
|
|
293
|
+
},
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Choosing / configuring embeddings
|
|
298
|
+
|
|
299
|
+
Embeddings power similarity search for memories and the user profile. Configure them in the same file (`~/.config/omms/omms.jsonc`). There is **no MLX backend** — local embeddings use `@huggingface/transformers` with ONNX, not Apple MLX.
|
|
300
|
+
|
|
301
|
+
**Local (default):** set only `embeddingModel`. On first use the model is downloaded from Hugging Face and cached under `{storagePath}/.cache` (default `~/.omms/data/.cache`).
|
|
302
|
+
|
|
303
|
+
**Remote (OpenAI-compatible):** set both `embeddingApiUrl` and `embeddingApiKey`. The plugin then calls `{embeddingApiUrl}/embeddings` with a Bearer token. `embeddingApiKey` accepts the same secret formats as `memoryApiKey` (`literal`, `env://…`, `file://…`).
|
|
304
|
+
|
|
305
|
+
| Key | Role |
|
|
306
|
+
| --------------------- | ----------------------------------------------------------------------------------------- |
|
|
307
|
+
| `embeddingModel` | Hugging Face id (local) or API model name (remote). Default: `Xenova/nomic-embed-text-v1` |
|
|
308
|
+
| `embeddingDimensions` | Optional override; usually omit — dimensions are looked up from a built-in map |
|
|
309
|
+
| `embeddingApiUrl` | Base URL for an OpenAI-compatible embeddings API (no trailing path beyond `/v1`) |
|
|
310
|
+
| `embeddingApiKey` | API key for that endpoint (required together with `embeddingApiUrl`) |
|
|
311
|
+
|
|
312
|
+
Recommended local models:
|
|
313
|
+
|
|
314
|
+
| Model | Dims | Notes |
|
|
315
|
+
| ------------------------------------ | ---- | ----------------------------------- |
|
|
316
|
+
| `Xenova/nomic-embed-text-v1` | 768 | Default; multilingual, 8192 context |
|
|
317
|
+
| `Xenova/jina-embeddings-v2-base-en` | 768 | English-only, 8192 context |
|
|
318
|
+
| `Xenova/jina-embeddings-v2-small-en` | 512 | Faster, 8192 context |
|
|
319
|
+
| `Xenova/all-MiniLM-L6-v2` | 384 | Very fast, 512 context |
|
|
320
|
+
| `Xenova/all-mpnet-base-v2` | 768 | Good quality, 512 context |
|
|
321
|
+
|
|
322
|
+
Example — remote OpenAI embeddings:
|
|
323
|
+
|
|
324
|
+
```jsonc
|
|
325
|
+
{
|
|
326
|
+
"embeddingApiUrl": "https://api.openai.com/v1",
|
|
327
|
+
"embeddingApiKey": "env://OPENAI_API_KEY",
|
|
328
|
+
"embeddingModel": "text-embedding-3-small",
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Changing `embeddingModel` (or dimensions) can trigger re-embedding of stored memories on next startup. Prefer picking a model once and sticking with it for a given data directory.
|
|
333
|
+
|
|
334
|
+
**Intel Mac (`darwin/x64`):** `onnxruntime-node@1.21.0` through `1.23.2` can crash OpenCode's embedded Bun `1.3.14` during process exit after successful local embeddings (`Ort::Env` teardown / SIGILL). The fix shipped in `1.24.1`, but fixed releases still lack an x64 native binding. `omms` therefore pins `onnxruntime-node@1.20.1` and loads transformers through a CJS resolve shim so OpenCode nested installs keep that binding. Transformers is resolved to an absolute path before that shim is installed so OpenCode's Bun `--compile` host does not fail with `Cannot find module '@huggingface/transformers' from ''`. After upgrading, clear OpenCode's nested plugin cache (`~/.cache/opencode/packages/om-memory-system@*`, or `opencode-mem@*` on pre-migration installs) and reinstall, or use a remote endpoint via `embeddingApiUrl` + `embeddingApiKey` (example above). This pin stays until onnxruntime publishes a post-teardown-fix darwin/x64 build.
|
|
335
|
+
|
|
336
|
+
### Memory Scope
|
|
337
|
+
|
|
338
|
+
- `scope: "project"`: query only the current project. This is the default.
|
|
339
|
+
- `scope: "all-projects"`: query `search` / `list` across all project shards.
|
|
340
|
+
- `memory.defaultScope` sets the default query scope when no explicit scope is provided.
|
|
341
|
+
|
|
342
|
+
### Web UI HTTP Basic Auth
|
|
343
|
+
|
|
344
|
+
When `webServerHost` is set to anything other than loopback (for example `0.0.0.0`), the web UI is reachable by anyone on the network. To keep your memories off the LAN, gate the web server with HTTP Basic Auth via the same config file used for everything else:
|
|
345
|
+
|
|
346
|
+
```jsonc
|
|
347
|
+
{
|
|
348
|
+
"webServerHost": "0.0.0.0", // optional: reach the UI from the LAN
|
|
349
|
+
"webServerAuthPassword": "pick-a-strong-one",
|
|
350
|
+
"webServerAuthUsername": "admin", // optional, defaults to the current OS user
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
| Field | Default | Effect |
|
|
355
|
+
| ----------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
356
|
+
| `webServerAuthPassword` | _(empty)_ | When set, the server demands HTTP Basic Auth credentials on every request. Leave empty to keep the open-by-default behavior. |
|
|
357
|
+
| `webServerAuthUsername` | OS user (`$USER`) | Username required by the Basic Auth challenge. |
|
|
358
|
+
|
|
359
|
+
`webServerAuthPassword` accepts the same secret formats as `memoryApiKey`:
|
|
360
|
+
|
|
361
|
+
- a literal string (simple, fine for personal machines),
|
|
362
|
+
- `env://SOME_ENV_VAR` to pull the value from the environment at startup,
|
|
363
|
+
- `file:///path/to/secret` to read it from a file (`chmod 600` recommended — the plugin will warn if the file is world-readable).
|
|
364
|
+
|
|
365
|
+
The browser will pop its native Basic Auth dialog and remember the credentials for the current session; closing all browser windows discards them, so reopening the browser requires signing in again. Credentials are compared with a constant-time check, and the unauthenticated 401 response carries `Cache-Control: no-store` so no intermediate cache will replay it. CORS is also relaxed once auth is on, so other tools on the same LAN can talk to the API after authenticating.
|
|
366
|
+
|
|
367
|
+
### Sharing One Project Memory Across Nested Repos
|
|
368
|
+
|
|
369
|
+
By default a project is identified by its enclosing git repository, so every
|
|
370
|
+
physical git repo gets its own isolated memory store. That is wrong for
|
|
371
|
+
multi-repo workspaces — trees managed by Google [`repo`](https://gerrit.googlesource.com/git-repo/+/HEAD/Docs/manual-repo.md),
|
|
372
|
+
monorepos, or any layout where several nested git repositories belong to one
|
|
373
|
+
logical project — because each sub-repository would be siloed.
|
|
374
|
+
|
|
375
|
+
Drop an empty **`.omms-project`** marker file at the workspace root (the legacy
|
|
376
|
+
`.opencode-mem-project` marker is still honoured and gives the same project identity):
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
my-workspace/
|
|
380
|
+
├── .omms-project ← workspace root
|
|
381
|
+
├── kernel/ (own git repo)
|
|
382
|
+
├── userspace/ (own git repo)
|
|
383
|
+
└── tools/ (own git repo)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Every session started anywhere underneath the marker then resolves onto that
|
|
387
|
+
root and shares one memory store, regardless of which sub-repo the working
|
|
388
|
+
directory lives in:
|
|
389
|
+
|
|
390
|
+
```sh
|
|
391
|
+
touch ~/my-workspace/.omms-project
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
The marker is looked up by walking up from the working directory that every
|
|
395
|
+
code path already passes in (the plugin's working directory, the web API's
|
|
396
|
+
`process.cwd()`), so identity is **directory-driven and process-independent**.
|
|
397
|
+
It does not rely on environment variables or a global config value, which
|
|
398
|
+
would be unreliable here: omms runs across multiple opencode processes
|
|
399
|
+
that share a single web server, and only some of those processes carry a
|
|
400
|
+
given env var. With the marker, the project root is always derived from where
|
|
401
|
+
the session actually runs.
|
|
402
|
+
|
|
403
|
+
The marker takes precedence over git detection. When it is present, the
|
|
404
|
+
sub-repo's own git remote is intentionally ignored (it would describe only one
|
|
405
|
+
nested repository). Without a marker, behavior is unchanged (git-based
|
|
406
|
+
identity).
|
|
407
|
+
|
|
408
|
+
### Moving or Recovering Project Memories
|
|
409
|
+
|
|
410
|
+
omms keys project shards by a hash of the project identity. Moving a
|
|
411
|
+
repository (OS migration, path reorganization, switching from a Windows mount
|
|
412
|
+
to a native path) can therefore orphan the old shard under
|
|
413
|
+
`~/.omms/data/projects/` while a new empty shard is created for the
|
|
414
|
+
new path.
|
|
415
|
+
|
|
416
|
+
These are OpenCode `memory` tool calls with JSON arguments, not commands to
|
|
417
|
+
run in a terminal. The issue-style `memory migrate --from ...` notation maps
|
|
418
|
+
to `memory({ mode: "migrate", fromPath: "..." })`.
|
|
419
|
+
|
|
420
|
+
**1. Local move when you still know the old path**
|
|
421
|
+
|
|
422
|
+
Open OpenCode in the **new** project directory. The target project must not
|
|
423
|
+
already contain memories (migration aborts unchanged on conflict). Preview the
|
|
424
|
+
detected source, destination, and file actions before changing anything:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
memory({ mode: "migrate", fromPath: "/old/path/to/project", dryRun: true });
|
|
428
|
+
memory({ mode: "migrate", fromPath: "/old/path/to/project" });
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
For safety, migration refuses a source whose stored project directory still
|
|
432
|
+
exists. If you intentionally want to move an active source, inspect the dry-run
|
|
433
|
+
output first and then pass `allowLinkedSource: true`. Original source shard
|
|
434
|
+
files are retained as timestamped `*.pre-path-migrate-*.bak` backups.
|
|
435
|
+
|
|
436
|
+
**2. Old path is gone — discover the orphaned shard first**
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
memory({ mode: "list-shards" });
|
|
440
|
+
memory({ mode: "migrate", fromHash: "fa645294d88bbae2" });
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
`list-shards` reports each project hash, stored `projectPath`, memory count,
|
|
444
|
+
and status (`current`, `linked`, `orphaned`, `missing-file`, `empty`, or
|
|
445
|
+
`ambiguous`). `fromHash` is the 16-character lowercase hexadecimal `scopeHash`
|
|
446
|
+
returned by this call. Prefer it when the old directory no longer exists or
|
|
447
|
+
multiple shards contain the same stored path, because git-based identities
|
|
448
|
+
cannot always be recomputed from a missing path.
|
|
449
|
+
|
|
450
|
+
**3. Cross-machine backup / restore**
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
// on the source machine / old checkout
|
|
454
|
+
memory({ mode: "export", outputPath: "./memories.json" });
|
|
455
|
+
|
|
456
|
+
// on the destination machine / new checkout
|
|
457
|
+
memory({ mode: "import", inputPath: "./memories.json", dryRun: true });
|
|
458
|
+
memory({ mode: "import", inputPath: "./memories.json" });
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Export writes a versioned JSON document without vectors. Import remaps the
|
|
462
|
+
memories onto the current project and recomputes embeddings with the currently
|
|
463
|
+
configured model. Import adds memories to an existing project, but duplicate
|
|
464
|
+
memory IDs abort the whole import before writing; this differs from `migrate`,
|
|
465
|
+
which requires an empty target.
|
|
466
|
+
|
|
467
|
+
Export files are plaintext and can contain memory content, user names/email
|
|
468
|
+
addresses, repository URLs, and absolute project paths. Store them like other
|
|
469
|
+
sensitive backups and delete them when no longer needed. Fully private entries
|
|
470
|
+
are omitted, and user profiles and prompt history are not included. The
|
|
471
|
+
document contains `schemaVersion: 1`; imports reject newer unsupported schema
|
|
472
|
+
versions rather than guessing.
|
|
473
|
+
|
|
474
|
+
### Auto-Capture AI Provider
|
|
475
|
+
|
|
476
|
+
Auto-capture runs a background AI request to summarize technical work and save it as memory. It needs one of the provider configurations below.
|
|
477
|
+
|
|
478
|
+
**Recommended:** Use a provider that is already authenticated in opencode and supports structured output:
|
|
479
|
+
|
|
480
|
+
```jsonc
|
|
481
|
+
"opencodeProvider": "anthropic",
|
|
482
|
+
"opencodeModel": "claude-haiku-4-5-20251001",
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
The plugin issues structured-output requests to opencode's session API instead of calling provider endpoints directly, so opencode owns the auth, token refresh, and provider routing. The provider name must match an entry from `opencode providers list`, and the selected model must support structured JSON output through opencode.
|
|
486
|
+
|
|
487
|
+
Supported providers: any provider listed by `opencode providers list` (e.g. `anthropic`, `openai`, `github-copilot`, ...).
|
|
488
|
+
|
|
489
|
+
If `opencodeProvider` and `opencodeModel` are set, they take precedence over the manual `memoryProvider` settings below.
|
|
490
|
+
|
|
491
|
+
**Follow the session model:** set `"opencodeModel": "inherit"` to use a concrete OpenCode model at call time instead of a pinned id. For **auto-capture**, each prompt is recorded via the `chat.params` hook and the capture request reuses that prompt's provider/model. For **profile learning** and other structured-output paths (which are not tied to a single user message), `inherit` falls back to the most recent model in OpenCode's `model.json` recent list (preferring the configured `opencodeProvider`). Sending the literal model id `inherit` is never valid and previously caused `ProviderModelNotFoundError: Model not found: <provider>/inherit` on those paths. `opencodeProvider` is still required as the normal config gate.
|
|
492
|
+
|
|
493
|
+
**Fallback:** Manual API configuration (if not using opencodeProvider):
|
|
494
|
+
|
|
495
|
+
```jsonc
|
|
496
|
+
"memoryProvider": "openai-chat",
|
|
497
|
+
"memoryModel": "gpt-4o-mini",
|
|
498
|
+
"memoryApiUrl": "https://api.openai.com/v1",
|
|
499
|
+
"memoryApiKey": "sk-...",
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
**API Key Formats:**
|
|
503
|
+
|
|
504
|
+
```jsonc
|
|
505
|
+
"memoryApiKey": "sk-..."
|
|
506
|
+
"memoryApiKey": "file://~/.config/opencode/api-key.txt"
|
|
507
|
+
"memoryApiKey": "env://OPENAI_API_KEY"
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
Manual `memoryProvider` modes:
|
|
511
|
+
|
|
512
|
+
- `openai-chat`: OpenAI Chat Completions compatible API with tool/function calling. This can work with compatible proxies such as LiteLLM only when the selected upstream model and proxy preserve tool calls.
|
|
513
|
+
- `openai-responses`: OpenAI Responses API with function-call output.
|
|
514
|
+
- `anthropic`: Anthropic Messages API with tool use.
|
|
515
|
+
- `minimax`: MiniMax Anthropic Messages-compatible endpoint. Set `memoryApiUrl` to the global endpoint (`https://api.minimax.io`) or the China endpoint (`https://api.minimaxi.com`); the `/anthropic/v1/messages` path and `x-api-key` header are applied automatically. MiniMax text models such as `MiniMax-M3` support the adaptive thinking modes used by this plugin via `memoryExtraParams`.
|
|
516
|
+
- `orcarouter`: OpenAI-compatible model gateway with namespaced model IDs. `memoryApiUrl` and `memoryModel` are optional — they default to `https://api.orcarouter.ai/v1` and `orcarouter/auto` (a routing alias that selects a capable model per request). If you set `memoryModel`, use a namespaced ID such as `openai/gpt-5.5` or `deepseek/deepseek-v4-flash`; OrcaRouter rejects bare model names. Example:
|
|
517
|
+
```jsonc
|
|
518
|
+
"memoryProvider": "orcarouter",
|
|
519
|
+
"memoryApiKey": "<OrcaRouter API key>",
|
|
520
|
+
```
|
|
521
|
+
[OrcaRouter](https://www.orcarouter.ai) also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.
|
|
522
|
+
|
|
523
|
+
Troubleshooting:
|
|
524
|
+
|
|
525
|
+
- Auto-capture failures do not block manual `memory` tool usage.
|
|
526
|
+
- If auto-capture reports that a provider is not connected, confirm the provider name with `opencode providers list` and configure that provider in opencode first.
|
|
527
|
+
- If a proxy or custom provider returns plain text instead of structured/tool output, choose another model/provider or use one of the manual provider modes above.
|
|
528
|
+
- For models that reject `temperature`, add `"memoryTemperature": false` when using manual API configuration.
|
|
529
|
+
- **Intel Mac (darwin/x64) local embedding:** if embedding init fails or OpenCode exits with SIGILL after local memory use, clear `~/.cache/opencode/packages/om-memory-system@*` (or `opencode-mem@*` on pre-migration installs) after upgrading so the nested install picks up the pinned `onnxruntime-node@1.20.1`, or switch to a remote embedding endpoint via `embeddingApiUrl` + `embeddingApiKey`. See [Choosing / configuring embeddings](#choosing-configuring-embeddings). MLX is not supported.
|
|
530
|
+
|
|
531
|
+
## Public Subpath Exports
|
|
532
|
+
|
|
533
|
+
In addition to the main plugin entry, `omms` exposes one stable subpath
|
|
534
|
+
that other opencode plugins can import directly. This avoids having to
|
|
535
|
+
reverse-engineer container-tag conventions when writing third-party tools that
|
|
536
|
+
read or write into the same memory store.
|
|
537
|
+
|
|
538
|
+
### `om-memory-system/tags`
|
|
539
|
+
|
|
540
|
+
Canonical container-tag helpers. The same functions omms itself uses
|
|
541
|
+
to scope auto-captured memories.
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
import { getProjectTagInfo, getUserTagInfo, getTags } from "om-memory-system/tags";
|
|
545
|
+
|
|
546
|
+
// Canonical project tag derived from cwd (git remote URL if present, else
|
|
547
|
+
// the project root path). Format: `omms_project_<sha16>`; rows written by
|
|
548
|
+
// older versions are migrated automatically on first start.
|
|
549
|
+
const projectTag = getProjectTagInfo(process.cwd()).tag;
|
|
550
|
+
|
|
551
|
+
// Canonical user tag derived from `git config user.email`.
|
|
552
|
+
// Format: `omms_user_<sha16>`.
|
|
553
|
+
const userTag = getUserTagInfo().tag;
|
|
554
|
+
|
|
555
|
+
// Both at once.
|
|
556
|
+
const { user, project } = getTags(process.cwd());
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Tags produced by these helpers match what auto-capture writes, so third-party
|
|
560
|
+
plugins that call `POST /api/memories` will land in the same shards the rest
|
|
561
|
+
of the system already understands. Hand-rolled tags whose substring isn't
|
|
562
|
+
`_project_` or `_user_` end up in shadow shards that `/api/stats` and
|
|
563
|
+
`/api/memories` silently filter out — using these helpers avoids that pitfall.
|
|
564
|
+
|
|
565
|
+
## Development & Contribution
|
|
566
|
+
|
|
567
|
+
Build and test locally:
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
bun install
|
|
571
|
+
bun run build
|
|
572
|
+
bun run typecheck
|
|
573
|
+
bun run format
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
This project is actively seeking contributions to become the definitive memory plugin for AI coding agents. Whether you are fixing bugs, adding features, improving documentation, or expanding embedding model support, your contributions are critical. The codebase is well-structured and ready for enhancement. If you hit a blocker or have improvement ideas, submit a pull request - we review and merge contributions quickly.
|
|
577
|
+
|
|
578
|
+
## License & Links
|
|
579
|
+
|
|
580
|
+
MIT License - see LICENSE file
|
|
581
|
+
|
|
582
|
+
- **Repository**: https://github.com/cmdaltctr/omms (fork)
|
|
583
|
+
- **Upstream**: https://github.com/tickernelz/opencode-mem
|
|
584
|
+
- **Issues**: https://github.com/cmdaltctr/omms/issues
|
|
585
|
+
- **OpenCode Platform**: https://opencode.ai
|
|
586
|
+
|
|
587
|
+
Inspired by [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CONFIG } from "../../config.js";
|
|
2
|
+
import { extractOpenCodeConversation } from "./conversation.js";
|
|
3
|
+
import { generateOpenCodeAutoCaptureSummary } from "./auto-capture-summary.js";
|
|
4
|
+
export function createOpenCodeAutoCaptureHost(ctx) {
|
|
5
|
+
const notify = async (notification) => {
|
|
6
|
+
if (!ctx.client?.tui)
|
|
7
|
+
return;
|
|
8
|
+
await ctx.client.tui
|
|
9
|
+
.showToast({
|
|
10
|
+
body: notification,
|
|
11
|
+
})
|
|
12
|
+
.then(() => undefined)
|
|
13
|
+
.catch(() => undefined);
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
host: "opencode",
|
|
17
|
+
isCaptureReady: () => CONFIG.autoCaptureProviderStatus.ready,
|
|
18
|
+
getConversation: async (sessionId, promptMessageId) => {
|
|
19
|
+
if (!ctx.client)
|
|
20
|
+
throw new Error("Client not available");
|
|
21
|
+
const response = await ctx.client.session.messages({ path: { id: sessionId } });
|
|
22
|
+
if (!response.data)
|
|
23
|
+
return null;
|
|
24
|
+
return extractOpenCodeConversation(response.data, promptMessageId);
|
|
25
|
+
},
|
|
26
|
+
summarize: (request) => generateOpenCodeAutoCaptureSummary(request, notify),
|
|
27
|
+
notify,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AutoCaptureNotification, CaptureSummary, CaptureSummaryRequest } from "../../core/host.js";
|
|
2
|
+
type Notify = (notification: AutoCaptureNotification) => Promise<void> | void;
|
|
3
|
+
export declare function generateOpenCodeAutoCaptureSummary(request: CaptureSummaryRequest, notify?: Notify): Promise<CaptureSummary | null>;
|
|
4
|
+
export {};
|