opencode-semantic-memory 0.1.0__py3-none-any.whl
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.
- opencode_memory/__init__.py +3 -0
- opencode_memory/cache.py +261 -0
- opencode_memory/cli.py +794 -0
- opencode_memory/config.py +89 -0
- opencode_memory/daemon.py +879 -0
- opencode_memory/enrichment/__init__.py +0 -0
- opencode_memory/enrichment/gitlab.py +237 -0
- opencode_memory/extraction.py +225 -0
- opencode_memory/historical_ingest.py +142 -0
- opencode_memory/http_server.py +464 -0
- opencode_memory/ingestion/__init__.py +7 -0
- opencode_memory/ingestion/embeddings.py +211 -0
- opencode_memory/ingestion/extractors.py +287 -0
- opencode_memory/ingestion/opencode_db.py +448 -0
- opencode_memory/ingestion/parser.py +344 -0
- opencode_memory/ingestion/watcher.py +88 -0
- opencode_memory/linking/__init__.py +5 -0
- opencode_memory/linking/linker.py +323 -0
- opencode_memory/metrics.py +273 -0
- opencode_memory/models.py +171 -0
- opencode_memory/project.py +86 -0
- opencode_memory/query/__init__.py +5 -0
- opencode_memory/query/hybrid.py +196 -0
- opencode_memory/server.py +2795 -0
- opencode_memory/session/__init__.py +5 -0
- opencode_memory/session/registry.py +57 -0
- opencode_memory/storage/__init__.py +6 -0
- opencode_memory/storage/sqlite.py +1608 -0
- opencode_memory/storage/vectors.py +199 -0
- opencode_semantic_memory-0.1.0.dist-info/METADATA +531 -0
- opencode_semantic_memory-0.1.0.dist-info/RECORD +33 -0
- opencode_semantic_memory-0.1.0.dist-info/WHEEL +4 -0
- opencode_semantic_memory-0.1.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opencode-semantic-memory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Persistent semantic memory system for OpenCode sessions
|
|
5
|
+
Author-email: Gregory Havenga <ghavenga@gitlab.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: ai,assistant,mcp,memory,opencode
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: httpx>=0.27.0
|
|
15
|
+
Requires-Dist: lancedb>=0.4.0
|
|
16
|
+
Requires-Dist: markdown-it-py>=3.0.0
|
|
17
|
+
Requires-Dist: mcp>=1.0.0
|
|
18
|
+
Requires-Dist: pydantic>=2.0.0
|
|
19
|
+
Requires-Dist: pylance>=0.20.0
|
|
20
|
+
Requires-Dist: sentence-transformers>=2.2.0
|
|
21
|
+
Requires-Dist: starlette>=0.36.0
|
|
22
|
+
Requires-Dist: tomli>=2.0.0
|
|
23
|
+
Requires-Dist: uvicorn>=0.27.0
|
|
24
|
+
Requires-Dist: watchdog>=3.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# opencode-memory
|
|
33
|
+
|
|
34
|
+
Persistent semantic memory system for [OpenCode](https://opencode.ai) AI assistant sessions.
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
opencode-memory is an MCP (Model Context Protocol) server that provides long-term memory capabilities for OpenCode sessions. It automatically learns from your workflow, stores decisions and procedures, and provides relevant context when needed.
|
|
39
|
+
|
|
40
|
+
**Key benefits:**
|
|
41
|
+
- Remember decisions, blockers, procedures, and facts across sessions
|
|
42
|
+
- Semantic search finds relevant memories even with different wording
|
|
43
|
+
- Session coordination prevents conflicts when running multiple OpenCode instances
|
|
44
|
+
- Project-scoped directives for per-project instructions
|
|
45
|
+
- Zero manual effort - learns passively from your workflow
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Hybrid retrieval**: Combines full-text search (FTS5) with vector similarity search
|
|
50
|
+
- **Instant storage**: Memories stored immediately, embeddings computed async
|
|
51
|
+
- **Session coordination**: Tracks active sessions, supports item claiming to prevent conflicts
|
|
52
|
+
- **Contextual directives**: Global + project-specific instructions loaded at boot
|
|
53
|
+
- **Entity tracking**: Links memories to MRs, issues, epics (!123, #456, &789)
|
|
54
|
+
- **GitLab enrichment**: Fetches metadata for entities from GitLab API
|
|
55
|
+
- **Memory age**: All outputs show age to identify potentially outdated information
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
### Quick Install (Recommended)
|
|
60
|
+
|
|
61
|
+
Works on both Linux and macOS:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
curl -fsSL https://gitlab.com/ghavenga/opencode-memory/-/raw/master/scripts/setup.sh | bash
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This will:
|
|
68
|
+
- Clone the repository to `~/.local/share/opencode-memory-install`
|
|
69
|
+
- Create a virtual environment and install dependencies
|
|
70
|
+
- Download the embedding model (~90MB, one-time, runs locally)
|
|
71
|
+
- Set up a background service:
|
|
72
|
+
- **Linux**: systemd user service
|
|
73
|
+
- **macOS**: launchd LaunchAgent
|
|
74
|
+
- Configure OpenCode integration
|
|
75
|
+
- Create `~/.config/opencode/AGENTS.md` with memory bootstrap
|
|
76
|
+
- Optionally bootstrap core directives (requires confirmation due to LLM costs)
|
|
77
|
+
|
|
78
|
+
### Cost Information
|
|
79
|
+
|
|
80
|
+
**Default background processing is free** - The memory daemon uses:
|
|
81
|
+
- Local embedding model (sentence-transformers, no API calls)
|
|
82
|
+
- Pattern-based extraction (regex, no LLM)
|
|
83
|
+
- Session summaries (stores conversations as-is, no LLM processing)
|
|
84
|
+
|
|
85
|
+
**LLM-based knowledge extraction is OFF by default** - There is an optional
|
|
86
|
+
feature that uses `opencode run` to analyze old conversations and extract
|
|
87
|
+
procedures, decisions, and facts. This:
|
|
88
|
+
- Runs every 6 hours, processing up to 50 conversations per cycle
|
|
89
|
+
- Makes LLM API calls for each conversation (significant cost potential)
|
|
90
|
+
- Is **disabled by default** to avoid unexpected charges
|
|
91
|
+
|
|
92
|
+
To enable LLM extraction (if you want it), add to `~/.config/opencode-memory/config.toml`:
|
|
93
|
+
```toml
|
|
94
|
+
[ingestion]
|
|
95
|
+
llm_extraction = true
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Optional directive bootstrapping** - The setup script can create initial
|
|
99
|
+
directives using `opencode inline` (~4 LLM API calls). This prompts for
|
|
100
|
+
confirmation and defaults to 'no' when running non-interactively.
|
|
101
|
+
|
|
102
|
+
To skip directive bootstrapping entirely:
|
|
103
|
+
```bash
|
|
104
|
+
SKIP_BOOTSTRAP=1 curl -fsSL .../setup.sh | bash
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### From Source (Manual)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Clone the repository
|
|
111
|
+
git clone https://gitlab.com/ghavenga/opencode-memory.git
|
|
112
|
+
cd opencode-memory
|
|
113
|
+
|
|
114
|
+
# Create virtual environment
|
|
115
|
+
python -m venv .venv
|
|
116
|
+
source .venv/bin/activate
|
|
117
|
+
|
|
118
|
+
# Install dependencies
|
|
119
|
+
pip install -e ".[dev]"
|
|
120
|
+
|
|
121
|
+
# Download the embedding model (runs once, ~90MB)
|
|
122
|
+
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### From PyPI
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pip install opencode-semantic-memory
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Quick Start
|
|
132
|
+
|
|
133
|
+
### 1. Start the Memory Server
|
|
134
|
+
|
|
135
|
+
The recommended setup runs a shared HTTP server that all OpenCode sessions connect to:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Start manually
|
|
139
|
+
source .venv/bin/activate
|
|
140
|
+
python -m opencode_memory.http_server
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Or install as a background service (auto-starts on login):
|
|
144
|
+
|
|
145
|
+
**Linux (systemd):**
|
|
146
|
+
```bash
|
|
147
|
+
# Copy and customize the service file
|
|
148
|
+
cp opencode-memory.service ~/.config/systemd/user/
|
|
149
|
+
|
|
150
|
+
# Edit to match your paths
|
|
151
|
+
nano ~/.config/systemd/user/opencode-memory.service
|
|
152
|
+
|
|
153
|
+
# Enable and start
|
|
154
|
+
systemctl --user daemon-reload
|
|
155
|
+
systemctl --user enable --now opencode-memory
|
|
156
|
+
|
|
157
|
+
# Check status
|
|
158
|
+
systemctl --user status opencode-memory
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**macOS (launchd):**
|
|
162
|
+
```bash
|
|
163
|
+
# Copy the plist file
|
|
164
|
+
cp com.opencode.memory.plist ~/Library/LaunchAgents/
|
|
165
|
+
|
|
166
|
+
# Edit to match your paths (replace $HOME with actual path)
|
|
167
|
+
nano ~/Library/LaunchAgents/com.opencode.memory.plist
|
|
168
|
+
|
|
169
|
+
# Create log directory
|
|
170
|
+
mkdir -p ~/.local/state/opencode-memory
|
|
171
|
+
|
|
172
|
+
# Load the service
|
|
173
|
+
launchctl load ~/Library/LaunchAgents/com.opencode.memory.plist
|
|
174
|
+
|
|
175
|
+
# Check status
|
|
176
|
+
launchctl list | grep opencode
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 2. Configure OpenCode
|
|
180
|
+
|
|
181
|
+
Add to `~/.config/opencode/opencode.json`:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"mcp": {
|
|
186
|
+
"memory": {
|
|
187
|
+
"type": "remote",
|
|
188
|
+
"url": "http://localhost:9824/mcp"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 3. Configure the Agent
|
|
195
|
+
|
|
196
|
+
Add to `~/.config/opencode/AGENTS.md`:
|
|
197
|
+
|
|
198
|
+
```markdown
|
|
199
|
+
# Agent Instructions
|
|
200
|
+
|
|
201
|
+
At session start, always call `memory_get_boot_context` to load prior context, active sessions, and blockers.
|
|
202
|
+
|
|
203
|
+
## Memory System
|
|
204
|
+
|
|
205
|
+
The memory system provides persistent context across sessions.
|
|
206
|
+
|
|
207
|
+
### Proactive Usage
|
|
208
|
+
|
|
209
|
+
Call `memory_remember` when:
|
|
210
|
+
- You make a decision about approach
|
|
211
|
+
- You hit a blocker
|
|
212
|
+
- You learn how to do something
|
|
213
|
+
- You discover an interesting fact
|
|
214
|
+
|
|
215
|
+
Call `memory_recall(query)` before:
|
|
216
|
+
- Using an unfamiliar API
|
|
217
|
+
- Making assumptions about how something works
|
|
218
|
+
|
|
219
|
+
Call `memory_get_context(entity_ref)` before working on any MR/issue/epic.
|
|
220
|
+
|
|
221
|
+
Categories: decision, blocker, procedure, fact, event, directive
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Configuration
|
|
225
|
+
|
|
226
|
+
Create `~/.config/opencode-memory/config.toml`:
|
|
227
|
+
|
|
228
|
+
```toml
|
|
229
|
+
[identity]
|
|
230
|
+
user = "your-gitlab-username" # Optional, auto-detected from git
|
|
231
|
+
instance = "gitlab.com"
|
|
232
|
+
|
|
233
|
+
[boot]
|
|
234
|
+
identity = true
|
|
235
|
+
active_sessions = true
|
|
236
|
+
hot_items = true
|
|
237
|
+
unresolved_blockers = true
|
|
238
|
+
recent_decisions = false
|
|
239
|
+
max_hot_items = 5
|
|
240
|
+
|
|
241
|
+
[ingestion]
|
|
242
|
+
watch_paths = ["~/.local/share/opencode/opencode.db"]
|
|
243
|
+
db_poll_interval = 30
|
|
244
|
+
llm_extraction = false
|
|
245
|
+
working_directory = "/path/to/your/projects"
|
|
246
|
+
|
|
247
|
+
[storage]
|
|
248
|
+
path = "~/.local/share/opencode-memory"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## MCP Tools
|
|
252
|
+
|
|
253
|
+
> **Note:** Tools are registered with the `memory_` prefix when accessed through the "memory" MCP server.
|
|
254
|
+
> For example, `recall` becomes `memory_recall` in OpenCode sessions.
|
|
255
|
+
|
|
256
|
+
### Core Memory Tools
|
|
257
|
+
|
|
258
|
+
| Tool | Description |
|
|
259
|
+
|------|-------------|
|
|
260
|
+
| `memory_recall(query, limit?, project?, category?, compact?)` | Semantic search across memories |
|
|
261
|
+
| `memory_remember(content, category, what?, why?, learned?, entities?, project?)` | Store a memory |
|
|
262
|
+
| `memory_get_context(entity_ref)` | Get all memories for !MR, #issue, or &epic |
|
|
263
|
+
| `memory_get_boot_context()` | Load startup context (identity, blockers, directives) |
|
|
264
|
+
| `memory_get_linked_memories(memory_id, link_types?)` | Get memories linked to a specific memory |
|
|
265
|
+
|
|
266
|
+
### Session Coordination
|
|
267
|
+
|
|
268
|
+
| Tool | Description |
|
|
269
|
+
|------|-------------|
|
|
270
|
+
| `memory_session_start(session_id, working_on?)` | Register session |
|
|
271
|
+
| `memory_session_end(session_id, summary?)` | End session with summary |
|
|
272
|
+
| `memory_session_heartbeat(session_id)` | Keep session alive |
|
|
273
|
+
| `memory_get_active_sessions()` | List active sessions |
|
|
274
|
+
| `memory_claim_item(session_id, item_ref)` | Claim exclusive ownership |
|
|
275
|
+
| `memory_release_item(session_id, item_ref)` | Release claimed item |
|
|
276
|
+
|
|
277
|
+
### Memory Management
|
|
278
|
+
|
|
279
|
+
| Tool | Description |
|
|
280
|
+
|------|-------------|
|
|
281
|
+
| `memory_resolve_blocker(memory_id)` | Mark blocker as resolved |
|
|
282
|
+
| `memory_unresolve_blocker(memory_id)` | Reopen a blocker |
|
|
283
|
+
| `memory_archive_memory(memory_id, reason?)` | Archive outdated memory (soft delete) |
|
|
284
|
+
| `memory_delete_memory(memory_id, also_delete_vector?)` | Permanently delete a memory |
|
|
285
|
+
| `memory_edit_memory(memory_id, content?, what?, why?, learned?)` | Edit memory content or metadata |
|
|
286
|
+
| `memory_bulk_archive(memory_ids?, category?, older_than_days?, reason)` | Archive multiple memories |
|
|
287
|
+
| `memory_consolidate_memory(days_stale?, project?)` | Find stale/duplicate memories |
|
|
288
|
+
| `memory_search_history(query, category?, limit?)` | Search with category filter |
|
|
289
|
+
|
|
290
|
+
### Backup & Transfer
|
|
291
|
+
|
|
292
|
+
| Tool | Description |
|
|
293
|
+
|------|-------------|
|
|
294
|
+
| `memory_export_memories(output_path?, project?, categories?, since_days?)` | Export to JSON |
|
|
295
|
+
| `memory_import_memories(input_path, dry_run?, skip_duplicates?)` | Import from JSON |
|
|
296
|
+
|
|
297
|
+
### Utilities
|
|
298
|
+
|
|
299
|
+
| Tool | Description |
|
|
300
|
+
|------|-------------|
|
|
301
|
+
| `memory_ingest_file(file_path)` | Manually ingest a markdown file |
|
|
302
|
+
| `memory_enrich_entity(entity_ref, project?)` | Fetch GitLab metadata |
|
|
303
|
+
| `memory_bootstrap_memory(path?)` | Scan project files for initial facts |
|
|
304
|
+
| `memory_log_session(summary, learnings?, entities?)` | Log session summary |
|
|
305
|
+
| `memory_memory_status()` | Check system health and queue status |
|
|
306
|
+
|
|
307
|
+
## Memory Categories
|
|
308
|
+
|
|
309
|
+
| Category | Use For |
|
|
310
|
+
|----------|---------|
|
|
311
|
+
| `decision` | Architectural choices, design decisions |
|
|
312
|
+
| `blocker` | Obstacles preventing progress |
|
|
313
|
+
| `procedure` | How-to knowledge, workflows |
|
|
314
|
+
| `fact` | Project-specific information |
|
|
315
|
+
| `event` | Significant occurrences |
|
|
316
|
+
| `directive` | Always-on instructions (global or project-scoped) |
|
|
317
|
+
| `plan` | Long-term goals and strategies |
|
|
318
|
+
| `idea` | Future possibilities, deferred considerations |
|
|
319
|
+
| `conversation` | Full conversation content (auto-generated) |
|
|
320
|
+
|
|
321
|
+
## Storage
|
|
322
|
+
|
|
323
|
+
All data is stored locally:
|
|
324
|
+
|
|
325
|
+
- **SQLite**: `~/.local/share/opencode-memory/memory.db` - Memories, entities, sessions, FTS index
|
|
326
|
+
- **LanceDB**: `~/.local/share/opencode-memory/vectors/` - Vector embeddings for semantic search
|
|
327
|
+
|
|
328
|
+
The daemon automatically:
|
|
329
|
+
- Cleans up old resolved blockers (>90 days)
|
|
330
|
+
- Archives old conversations (>180 days)
|
|
331
|
+
- Compacts LanceDB versions (keeps last 10)
|
|
332
|
+
|
|
333
|
+
## Environment Variables
|
|
334
|
+
|
|
335
|
+
| Variable | Description |
|
|
336
|
+
|----------|-------------|
|
|
337
|
+
| `GITLAB_TOKEN` | Enable GitLab entity enrichment |
|
|
338
|
+
| `HF_HUB_OFFLINE=1` | Prevent model downloads (use cached) |
|
|
339
|
+
| `TRANSFORMERS_OFFLINE=1` | Prevent model downloads |
|
|
340
|
+
| `OPENCODE_MEMORY_HOST` | HTTP server bind address (default: 127.0.0.1) |
|
|
341
|
+
| `OPENCODE_MEMORY_PORT` | HTTP server port (default: 9824) |
|
|
342
|
+
| `OPENCODE_MEMORY_API_KEY` | Optional API key for authentication |
|
|
343
|
+
| `OPENCODE_MEMORY_RATE_LIMIT` | Requests per minute per client (default: 60) |
|
|
344
|
+
|
|
345
|
+
## Development
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Activate environment
|
|
349
|
+
source .venv/bin/activate
|
|
350
|
+
|
|
351
|
+
# Run tests
|
|
352
|
+
python -m pytest tests/ -v
|
|
353
|
+
|
|
354
|
+
# Lint
|
|
355
|
+
ruff check src/
|
|
356
|
+
|
|
357
|
+
# Type check
|
|
358
|
+
mypy src/
|
|
359
|
+
|
|
360
|
+
# Check memory stats
|
|
361
|
+
python -m opencode_memory.cli stats
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Architecture
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
368
|
+
│ opencode-memory │
|
|
369
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
370
|
+
│ MCP Server (HTTP/stdio) │
|
|
371
|
+
│ └── 25+ tools for memory management │
|
|
372
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
373
|
+
│ Background Daemon │
|
|
374
|
+
│ ├── OpenCode DB Observer (polls for new sessions) │
|
|
375
|
+
│ ├── Entity Enrichment (GitLab API) │
|
|
376
|
+
│ └── Cleanup (archives old memories, compacts vectors) │
|
|
377
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
378
|
+
│ Storage Layer │
|
|
379
|
+
│ ├── SQLite + FTS5 (memories, entities, sessions) │
|
|
380
|
+
│ └── LanceDB (vector embeddings) │
|
|
381
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
382
|
+
│ Embedding Engine │
|
|
383
|
+
│ └── all-MiniLM-L6-v2 (384-dim, runs in subprocess) │
|
|
384
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Operations
|
|
388
|
+
|
|
389
|
+
### Log Rotation
|
|
390
|
+
|
|
391
|
+
When running as a systemd service, logs are managed by journald. To configure log rotation:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# Check current log size
|
|
395
|
+
journalctl --user -u opencode-memory --disk-usage
|
|
396
|
+
|
|
397
|
+
# Set max journal size (add to ~/.config/systemd/user.conf or override)
|
|
398
|
+
# Or create ~/.config/systemd/journald.conf.d/opencode-memory.conf:
|
|
399
|
+
cat > ~/.config/systemd/journald.conf.d/opencode-memory.conf << 'EOF'
|
|
400
|
+
[Journal]
|
|
401
|
+
SystemMaxUse=100M
|
|
402
|
+
MaxRetentionSec=7d
|
|
403
|
+
EOF
|
|
404
|
+
|
|
405
|
+
# Or manually vacuum old logs
|
|
406
|
+
journalctl --user --vacuum-time=7d
|
|
407
|
+
journalctl --user --vacuum-size=100M
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
For file-based logging, configure rotation in the systemd service:
|
|
411
|
+
|
|
412
|
+
```ini
|
|
413
|
+
[Service]
|
|
414
|
+
StandardOutput=append:/var/log/opencode-memory/server.log
|
|
415
|
+
StandardError=append:/var/log/opencode-memory/error.log
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Then use logrotate (`/etc/logrotate.d/opencode-memory`):
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
/var/log/opencode-memory/*.log {
|
|
422
|
+
daily
|
|
423
|
+
rotate 7
|
|
424
|
+
compress
|
|
425
|
+
delaycompress
|
|
426
|
+
missingok
|
|
427
|
+
notifempty
|
|
428
|
+
create 0640 $USER $USER
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Monitoring
|
|
433
|
+
|
|
434
|
+
The HTTP server exposes several endpoints:
|
|
435
|
+
|
|
436
|
+
| Endpoint | Description |
|
|
437
|
+
|----------|-------------|
|
|
438
|
+
| `/health` | Basic health check (returns 200 if healthy, 503 if degraded) |
|
|
439
|
+
| `/stats` | Detailed statistics (memories, cache, queue, links) |
|
|
440
|
+
| `/metrics` | Prometheus-format metrics |
|
|
441
|
+
|
|
442
|
+
Example monitoring with curl:
|
|
443
|
+
```bash
|
|
444
|
+
# Health check (for load balancers/monitoring)
|
|
445
|
+
curl -s http://localhost:9824/health | jq .
|
|
446
|
+
|
|
447
|
+
# Full stats
|
|
448
|
+
curl -s http://localhost:9824/stats | jq .
|
|
449
|
+
|
|
450
|
+
# Prometheus metrics
|
|
451
|
+
curl -s http://localhost:9824/metrics
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### CLI Tools
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Show comprehensive statistics
|
|
458
|
+
python -m opencode_memory.cli stats
|
|
459
|
+
|
|
460
|
+
# Ingest markdown files
|
|
461
|
+
python -m opencode_memory.cli ingest /path/to/notes --recursive
|
|
462
|
+
|
|
463
|
+
# Archive old memories
|
|
464
|
+
python -m opencode_memory.cli cleanup --dry-run
|
|
465
|
+
|
|
466
|
+
# Enrich entities with GitLab metadata
|
|
467
|
+
python -m opencode_memory.cli enrich --limit 100
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
## Troubleshooting
|
|
471
|
+
|
|
472
|
+
### Check service status
|
|
473
|
+
|
|
474
|
+
**Linux:**
|
|
475
|
+
```bash
|
|
476
|
+
systemctl --user status opencode-memory
|
|
477
|
+
journalctl --user -u opencode-memory -f
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**macOS:**
|
|
481
|
+
```bash
|
|
482
|
+
launchctl list | grep opencode
|
|
483
|
+
tail -f ~/.local/state/opencode-memory/server.log
|
|
484
|
+
tail -f ~/.local/state/opencode-memory/server.error.log
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Check memory system health
|
|
488
|
+
Use `memory_status` tool or:
|
|
489
|
+
```bash
|
|
490
|
+
python -c "
|
|
491
|
+
from opencode_memory.server import MemoryServer
|
|
492
|
+
import json
|
|
493
|
+
server = MemoryServer(enable_daemon=False)
|
|
494
|
+
print(json.dumps(server._get_status(), indent=2))
|
|
495
|
+
"
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Prometheus metrics
|
|
499
|
+
The HTTP server exposes metrics at `/metrics`:
|
|
500
|
+
```bash
|
|
501
|
+
curl http://localhost:9824/metrics
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Backup and restore
|
|
505
|
+
```bash
|
|
506
|
+
# Export all memories
|
|
507
|
+
memory_export_memories(output_path="/backup/memories.json")
|
|
508
|
+
|
|
509
|
+
# Import on new machine
|
|
510
|
+
memory_import_memories(input_path="/backup/memories.json", dry_run=True) # Preview
|
|
511
|
+
memory_import_memories(input_path="/backup/memories.json") # Actually import
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Reset memory database
|
|
515
|
+
|
|
516
|
+
**Linux:**
|
|
517
|
+
```bash
|
|
518
|
+
rm -rf ~/.local/share/opencode-memory/
|
|
519
|
+
systemctl --user restart opencode-memory
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**macOS:**
|
|
523
|
+
```bash
|
|
524
|
+
rm -rf ~/.local/share/opencode-memory/
|
|
525
|
+
launchctl unload ~/Library/LaunchAgents/com.opencode.memory.plist
|
|
526
|
+
launchctl load ~/Library/LaunchAgents/com.opencode.memory.plist
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## License
|
|
530
|
+
|
|
531
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
opencode_memory/__init__.py,sha256=1KwiQr3gV8u7XfSA-1Z-S0SaalrBs4Pnegac5UcZjiY,97
|
|
2
|
+
opencode_memory/cache.py,sha256=nk8zfuTRe3p378hekp-btyVrq1-YOfI5WOZpv6vpKL8,9316
|
|
3
|
+
opencode_memory/cli.py,sha256=zL_WX6BSVDLw62vk-tGcIesiAdvcXNGukoMgoLVa6g0,27168
|
|
4
|
+
opencode_memory/config.py,sha256=dvgusEs3Cx-d3b_qB4jLDg61X8H63toLsZgAGbq-rsA,2785
|
|
5
|
+
opencode_memory/daemon.py,sha256=RNAk05oKftgBKP-PFOSp_W7Yx2qNRtk-_xM1ezcoBYk,37367
|
|
6
|
+
opencode_memory/extraction.py,sha256=tOD-nVmgGgHkbis5I8WOjYDJFEdVBqnQrqOoJYkYI-s,7562
|
|
7
|
+
opencode_memory/historical_ingest.py,sha256=SRpFm9IJCFP-r_zYF4V_dAjOkJ9u2UkSXhgXi3JYMhU,4768
|
|
8
|
+
opencode_memory/http_server.py,sha256=ks5A2IXnZIlrfvxL4ab_lERtPch5gJZACPgi63qDxyM,15552
|
|
9
|
+
opencode_memory/metrics.py,sha256=fMGOjT_qnUfPJECX5o09RoOKbjE2fpVQUoucnV07X4E,9290
|
|
10
|
+
opencode_memory/models.py,sha256=ec9ebIRei4DWyzlzRborUUak4GzpSl0Bq61KJDOT7L4,5552
|
|
11
|
+
opencode_memory/project.py,sha256=1rsnfaVaWN3AsHdcD_fPYx-NzpSbqKp5eeijm_V50zc,2790
|
|
12
|
+
opencode_memory/server.py,sha256=KVJfTqKbTfwDtqg6mk3DTzGfYacMubac-b6uXOxTkoU,113683
|
|
13
|
+
opencode_memory/enrichment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
opencode_memory/enrichment/gitlab.py,sha256=AVTBE_BFw1ORsxNhrfkW6BoyZOsejYK2RP87AcpPTKs,8636
|
|
15
|
+
opencode_memory/ingestion/__init__.py,sha256=SbNcIFHCAlfuxRiUfbiGu1Ciun7o7bfcUypFS8xaCxs,293
|
|
16
|
+
opencode_memory/ingestion/embeddings.py,sha256=WeNQ5aKPTqpAO-t9iksVUFOx_6TjuB01ugeNCAE0t9E,7798
|
|
17
|
+
opencode_memory/ingestion/extractors.py,sha256=9uusi2mO0hQqsyXFk-Un1GXiHNxV4DPQtMtYeR4jSyA,8868
|
|
18
|
+
opencode_memory/ingestion/opencode_db.py,sha256=PPocuqjM5srvIqEqD_Xa4nrIHMYgoIvghCghwR9V1S0,16030
|
|
19
|
+
opencode_memory/ingestion/parser.py,sha256=gJaWgqlG6eGTNxis3rXfwxLF0hB-xBCOxTEEqVB3cJ4,13187
|
|
20
|
+
opencode_memory/ingestion/watcher.py,sha256=hVErZBWkRpBt3JDyR26M9Xg4XifjV_WZ6L42w67dyAc,3073
|
|
21
|
+
opencode_memory/linking/__init__.py,sha256=gRkg9Bg6Cg2iLfMGelxjaOzBoLwO624nacnTxpTsueA,161
|
|
22
|
+
opencode_memory/linking/linker.py,sha256=YPiV-RcHgRDqpounh6u__TzW1slbyrz7h9LwhocufgI,11596
|
|
23
|
+
opencode_memory/query/__init__.py,sha256=1E67hgBWJReI_d7_y1AWHHJyOtbJnz06CcLWNZWVLxM,136
|
|
24
|
+
opencode_memory/query/hybrid.py,sha256=P9jrceZehzZ_In9WZIOk22_W6QIoHor-BjQEm8UR2zo,7646
|
|
25
|
+
opencode_memory/session/__init__.py,sha256=_VyYxFYnQMMbaRn_ZikZJahe84aVzmU_bVweLaXaCD4,147
|
|
26
|
+
opencode_memory/session/registry.py,sha256=4ZN2XFD5n3QdPpMmfuJ2fFskxRs_Nt-BaIBu0filN5o,2007
|
|
27
|
+
opencode_memory/storage/__init__.py,sha256=5TtB4QInB-HNjmwv2peFPJBkEQ3n3UZ144dMXdOK3Rw,205
|
|
28
|
+
opencode_memory/storage/sqlite.py,sha256=C4EmPBItDBCiOLqp0bQCMXYY1TxNGx2nEcA8HGAOn7c,63433
|
|
29
|
+
opencode_memory/storage/vectors.py,sha256=8pT2hNrsNtR4UWV4ROX7tizoVjoFxZEKDiM_oxYs9j4,7299
|
|
30
|
+
opencode_semantic_memory-0.1.0.dist-info/METADATA,sha256=7e045gNQiXtvUtWB-2RCOeLNo3I3MQEp7ExIZSzklwc,16889
|
|
31
|
+
opencode_semantic_memory-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
32
|
+
opencode_semantic_memory-0.1.0.dist-info/entry_points.txt,sha256=j95C-SKL5t7fy4tF8BQLY2Jy1wePUSnfbYPxyrM4TNY,119
|
|
33
|
+
opencode_semantic_memory-0.1.0.dist-info/RECORD,,
|