tickernelz/opencode-mem
An OpenCode plugin with embedded vector search for cross-session coding memory
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
opencode-mem is a TypeScript extension loaded by OpenCode itself. When a session goes idle, a background model request extracts durable project memories from the technical work. The plugin embeds and stores those memories under storagePath; at recall time it can supply relevant records and the cross-project user profile as model context. In OpenCode v2, that context goes into the system layer rather than the authored prompt or chat transcript. The default chatMessage.injectOn: "first" retains the initial context across turns; "always" refreshes it on each authored user turn. After a restart, a resumed session rebuilds context from the current store, so it may not see exactly what it saw before.
The manifest includes @opencode-ai/plugin, @opencode-ai/sdk, @libsql/client and @tursodatabase/database. The current embedded Turso path stores vectors as F32_BLOB and uses vector_distance_cos for exact ranking; an optional hybrid ranking path adds keyword signals without FTS5. Session lookups use an indexed session_id, while src/services/turso/schema-migrations.ts applies pending PRAGMA user_version migrations to memory shards and auxiliary databases. For source checkouts, the root index.js and tui.js bridge OpenCode to the built plugin and its TUI companion.
Key Capabilities & Differentiators
Automatic capture and user-profile learning need a provider capable of structured or tool-call output. You can reuse an OpenCode-configured provider and model, or configure a separate API such as OpenAI Chat Completions, OpenAI Responses or Anthropic. Embedding is independent of that choice: the plugin offers more than a dozen CPU-capable local models, with Xenova/nomic-embed-text-v1 as the default, or an OpenAI-compatible embedding endpoint. Manual memory add, search and list still work without a capture provider, provided embeddings are available.
Memory maintenance includes deduplication, optional updates during capture and optional consolidation with recoverable trash. An optional Markdown vault and export, import and migrate operations support project portability. The web UI brings together a memory–prompt timeline, profile, skill library, vault and health statistics. Before capture requests, the plugin redacts recognizable credentials from the context sent to the configured provider, including a fallback; it sanitizes generated summaries and tags again before embedding and storage. Explicit adds use the same write boundary. Optional AES-256-GCM encryption protects local Turso shards at rest, but the key must be backed up separately to keep encrypted data recoverable.
Trade-offs & Limitations
Compared with AGENTS.md, vector recall is better suited to accumulated decisions, failed approaches and bug patterns, but it is not a reliable place for mandatory instructions: retrieval is selective, and default first-turn context is not refreshed on every user turn. Skills are the better fit for procedures loaded on demand. Compared with a separate vector service, embedding Turso removes a deployment dependency. Its exact cosine search has no approximate vector index, though, so check recall cost against the size of your actual shards rather than assuming it stays flat as history grows.
Local embeddings trade provider dependency for CPU, RAM and cache use. A remote embedding or capture provider reduces local processing for that task but sends the corresponding text outside the host; best-effort redaction can miss custom or split credentials and does not cover OpenCode’s main-model or tool traffic. Shared storage also has limits: Linux and macOS use experimental multiprocess WAL for concurrent OpenCode processes, while Windows supports one database owner at a time. Avoid a separate SQLite writer against the same store; it can invalidate Turso’s WAL index and cause a write to be silently lost. Use single-owner mode when other tools touch the database files.
Hardware & Deployment Guide
Use a standard OpenCode environment; Bun is the recommended runtime. OpenCode v2 registers opencode-mem@latest in plugins, while v1 uses plugin. For a local v2 checkout, run bun install && bun run build and point the plugin list at the package root, not dist/ or an individual file. The default embedding model needs internet access for the initial download and then runs on the CPU. Whether capture can stay offline is a separate provider decision. Native Turso bindings cover glibc Linux x64 and arm64, Apple Silicon macOS, and x64 Windows. Alpine/musl and Intel Macs lack compatible bindings; selecting remote embeddings does not remove that requirement.
Test upgrades against a backed-up store: startup converts legacy libSQL DiskANN storage and applies shard migrations, backing up databases and preserving vectors during engine conversion without re-embedding. Keep all processes sharing a store on the same WAL mode and restart them together after an upgrade. For controlled rollouts, pin the npm version; with an eligible version range and autoUpdate enabled, the plugin can clear the cached package and prompt a restart. Recent changes include a Standard Compute provider preset in v2.42.0, French web UI and documentation in v2.43.0, and a v2.44.0 fix that keeps the configured provider connected when a directory becomes unavailable.
F32_BLOB vectors and ranks them with vector_distance_cos; no separate vector service is required.memory export, import and migrate operations support moved or copied projects.OpenCode users who repeatedly revisit the same projects and want selective recall of decisions, debugging history and working preferences without operating a separate vector database.
You mainly need always-on instructions, need a shared store across multiple OpenCode processes on Windows, run on Alpine or an Intel Mac, or cannot approve the data paths required by your chosen providers.
Quick Start & Installation
memory({ mode: "add", content: "Project uses microservices architecture" });
memory({ mode: "search", query: "architecture decisions" });
memory({ mode: "search", query: "architecture decisions", scope: "all-projects" });
memory({ mode: "profile" });
memory({ mode: "list", limit: 10 });
memory({ mode: "list-shards" });
memory({ mode: "migrate", fromPath: "/old/path/to/project" });
memory({ mode: "export", outputPath: "./memories.json" });
memory({ mode: "import", inputPath: "./memories.json" });AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/tickernelz/opencode-mem.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about opencode-mem
How does it integrate with OpenCode, and where does recalled memory appear?
plugins; the package’s TUI companion normally loads automatically. Recall is passed to the model as system context, not appended to the authored user prompt or chat transcript. A CLI-only TUI connected to a remote OpenCode server must register opencode-mem/tui separately on the client to receive toasts.Does it require a GPU, and how much RAM and disk should I budget?
Can we use it commercially and meet a local-data policy?
When is it a better fit than AGENTS.md, Skills, or hand-maintained notes?
AGENTS.md for rules that must always apply, Skills for reusable procedures loaded on demand, and this plugin for project history that grows across sessions and needs selective recall. If deterministic context selection and simple file review matter more than automatic capture, start with ordinary project files. Add the plugin when maintaining and finding that history becomes a recurring burden.Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy