opencode-viking-memory 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,257 @@
1
+ # opencode-viking-memory
2
+
3
+ OpenCode plugin for persistent memory using [VikingMemory](https://console.volcengine.com/knowledgebase/).
4
+
5
+ Your agent remembers what you tell it - across sessions, across projects.
6
+
7
+ ## Credits
8
+
9
+ This project references and is based on the [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory) project.
10
+
11
+ ## Installation
12
+
13
+ ### For Humans
14
+
15
+ ```bash
16
+ bunx opencode-viking-memory@latest install
17
+ ```
18
+
19
+ Then get your API key and Resource ID from [火山引擎 Viking 记忆控制台](https://console.volcengine.com/knowledgebase/) and set them:
20
+
21
+ ```bash
22
+ export VIKING_MEMORY_API_KEY="..."
23
+ export VIKING_MEMORY_RESOURCE_ID="mem-..."
24
+ ```
25
+
26
+ **Or let your agent do it** - paste this into OpenCode:
27
+ ```
28
+ Install opencode-viking-memory by following https://raw.githubusercontent.com/volcengine/opencode-viking-memory/main/README.md
29
+ ```
30
+
31
+ ### For LLM Agents
32
+
33
+ <details>
34
+ <summary>Instructions for LLM Agents (click to expand)</summary>
35
+
36
+ If you're an LLM agent helping set up opencode-viking-memory, follow these steps:
37
+
38
+ #### Step 1: Run the installer
39
+
40
+ ```bash
41
+ bunx opencode-viking-memory@latest install --no-tui
42
+ ```
43
+
44
+ This will:
45
+ - Register the plugin in `~/.config/opencode/opencode.jsonc`
46
+ - Create the `/viking-memory-init` command
47
+
48
+ #### Step 2: Verify the config
49
+
50
+ ```bash
51
+ cat ~/.config/opencode/opencode.jsonc
52
+ ```
53
+
54
+ Should contain:
55
+ ```json
56
+ {
57
+ "plugin": ["opencode-viking-memory"]
58
+ }
59
+ ```
60
+
61
+ If not, add it manually:
62
+
63
+ **JSONC:**
64
+ ```jsonc
65
+ {
66
+ "plugin": [
67
+ "opencode-viking-memory"
68
+ // ... other plugins
69
+ ]
70
+ }
71
+ ```
72
+
73
+ **JSON:**
74
+ ```json
75
+ {
76
+ "plugin": ["opencode-viking-memory"]
77
+ }
78
+ ```
79
+
80
+ #### Step 3: Configure API key
81
+
82
+ Ask the user to get their API key from [火山引擎 Viking 记忆控制台](https://console.volcengine.com/knowledgebase/).
83
+
84
+ Then set them via environment variables:
85
+
86
+ ```bash
87
+ export VIKING_MEMORY_API_KEY="..."
88
+ export VIKING_MEMORY_RESOURCE_ID="mem-..."
89
+ ```
90
+
91
+ Or create `~/.config/opencode/viking_memory.jsonc`:
92
+
93
+ ```jsonc
94
+ {
95
+ "apiKey": "...",
96
+ "resourceId": "mem-..."
97
+ }
98
+ ```
99
+
100
+ #### Step 4: Verify setup
101
+
102
+ Tell the user to restart OpenCode and run:
103
+
104
+ ```bash
105
+ opencode -c
106
+ ```
107
+
108
+ They should see `viking_memory` in the tools list. If not, check:
109
+ 1. Is `VIKING_MEMORY_API_KEY` set?
110
+ 2. Is the plugin in `opencode.jsonc`?
111
+ 3. Check logs: `tail ~/.opencode-viking-memory.log`
112
+
113
+ #### Step 5: Initialize codebase memory (optional)
114
+
115
+ Run `/viking-memory-init` to have the agent explore and memorize the codebase.
116
+
117
+ </details>
118
+
119
+ ## Features
120
+
121
+ ### Context Injection
122
+
123
+ On first message, the agent receives (invisible to user):
124
+ - User profile (cross-project preferences)
125
+ - Project memories (all project knowledge)
126
+ - Relevant user memories (semantic search)
127
+
128
+ Example of what the agent sees:
129
+ ```
130
+ [VIKING_MEMORY]
131
+
132
+ User Profile:
133
+ - Prefers concise responses
134
+ - Expert in TypeScript
135
+
136
+ Project Knowledge:
137
+ - [100%] Uses Bun, not Node.js
138
+ - [100%] Build: bun run build
139
+
140
+ Relevant Memories:
141
+ - [82%] Build fails if .env.local missing
142
+ ```
143
+
144
+ The agent uses this context automatically - no manual prompting needed.
145
+
146
+ ### Keyword Detection
147
+
148
+ Say "remember", "save this", "don't forget" etc. and the agent auto-saves to memory.
149
+
150
+ ```
151
+ You: "Remember that this project uses bun"
152
+ Agent: [saves to project memory]
153
+ ```
154
+
155
+ Add custom triggers via `keywordPatterns` config.
156
+
157
+ ### Codebase Indexing
158
+
159
+ Run `/viking-memory-init` to explore and memorize your codebase structure, patterns, and conventions.
160
+
161
+ ### Preemptive Compaction
162
+
163
+ When context hits 80% capacity:
164
+ 1. Triggers OpenCode's summarization
165
+ 2. Injects project memories into summary context
166
+ 3. Saves session summary as a memory
167
+
168
+ This preserves conversation context across compaction events.
169
+
170
+ ### Privacy
171
+
172
+ ```
173
+ API key is <private>sk-abc123</private>
174
+ ```
175
+
176
+ Content in `<private>` tags is never stored.
177
+
178
+ ## Tool Usage
179
+
180
+ The `viking_memory` tool is available to the agent:
181
+
182
+ | Mode | Args | Description |
183
+ |------|------|-------------|
184
+ | `add` | `content`, `type?`, `scope?` | Store memory |
185
+ | `search` | `query`, `scope?` | Search memories |
186
+ | `profile` | `query?` | View user profile |
187
+ | `list` | `scope?`, `limit?` | List memories |
188
+ | `forget` | `memoryId`, `scope?` | Delete memory |
189
+
190
+ **Scopes:** `user` (cross-project), `project` (default)
191
+
192
+ **Types:** `project-config`, `architecture`, `error-solution`, `preference`, `learned-pattern`, `conversation`
193
+
194
+ ## Memory Scoping
195
+
196
+ | Scope | Tag | Persists |
197
+ |-------|-----|----------|
198
+ | User | `opencode_user_{sha256(git email)}` | All projects |
199
+ | Project | `opencode_project_{sha256(directory)}` | This project |
200
+
201
+ ## Configuration
202
+
203
+ Create `~/.config/opencode/viking_memory.jsonc`:
204
+
205
+ ```jsonc
206
+ {
207
+ // API key (can also use VIKING_MEMORY_API_KEY env var)
208
+ "apiKey": "...",
209
+
210
+ // Resource ID (can also use VIKING_MEMORY_RESOURCE_ID env var)
211
+ "resourceId": "mem-...",
212
+ }
213
+ ```
214
+
215
+ All fields optional. Env vars `VIKING_MEMORY_API_KEY` and `VIKING_MEMORY_RESOURCE_ID` take precedence over config file.
216
+
217
+ ## Usage with Oh My OpenCode
218
+
219
+ If you're using [Oh My OpenCode](https://github.com/code-yeongyu/oh-my-opencode), disable its built-in auto-compact hook to let VikingMemory handle context compaction:
220
+
221
+ Add to `~/.config/opencode/oh-my-opencode.json`:
222
+
223
+ ```json
224
+ {
225
+ "disabled_hooks": ["anthropic-context-window-limit-recovery"]
226
+ }
227
+ ```
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ bun install
233
+ bun run build
234
+ bun run typecheck
235
+ ```
236
+
237
+ Local install:
238
+
239
+ ```jsonc
240
+ {
241
+ "plugin": ["file:///path/to/opencode-viking-memory"]
242
+ }
243
+ ```
244
+
245
+ ## Logs
246
+
247
+ ```bash
248
+ tail -f ~/.opencode-viking-memory.log
249
+ ```
250
+
251
+ ## Credits
252
+
253
+ This project references and is based on the [opencode-supermemory](https://github.com/supermemoryai/opencode-supermemory) project.
254
+
255
+ ## License
256
+
257
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}