StackMap
Subscribe
Explore / opencode-mem
tickernelz

opencode-mem

OpenCode plugin giving coding agents persistent cross-session memory — local SQLite + vector search, automatic memory capture, user-profile learning, and a web UI. Nothing leaves your machine.

1,138 113 TypeScriptupdated 5 days ago
Curator's take

For OpenCode users tired of re-explaining their architecture every session: auto-capture summarizes each prompt's work via a background structured-output call that reuses your existing opencode provider auth, memories inject into the first chat message, and the `.opencode-mem-project` marker file solves multi-repo workspaces properly (directory-driven identity, not env vars). A real web UI at :4747 for browsing what it learned. NOT for Claude Code — this is OpenCode-specific; pro-workflow and claude-reflect are the equivalents on that side. Auto-capture needs a provider that speaks structured output, and the default local embedding model downloads on first use. Inspired by opencode-supermemory, but local-first.

Mapped by ShipWithAI editors · links verified
README.md

OpenCode Memory

npm version npm downloads license

OpenCode Memory Banner

A persistent memory system for AI coding agents that enables long-term context retention across sessions using local vector database technology.

Visual Overview

Project Memory Timeline:

Project Memory Timeline

User Profile Viewer:

User Profile Viewer

Core Features

Local vector database with SQLite + USearch-first vector indexing and ExactScan fallback, 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.

Prerequisites

This plugin uses USearch for preferred in-memory vector indexing with automatic ExactScan fallback. No custom SQLite build or browser runtime shim is required.

Recommended runtime:

  • Bun
  • Standard OpenCode plugin environment
  • Internet access on first use if you use the default local embedding model, because the model is downloaded by @huggingface/transformers.
  • For source/development installs, run bun install before building or testing. The published plugin package installs its runtime dependencies automatically through OpenCode.

Notes:

  • If USearch is unavailable or fails at runtime, the plugin automatically falls back to exact vector scanning.
  • SQLite remains the source of truth; search indexes are rebuilt from SQLite data when needed.
  • 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.

Getting Started

Add to your OpenCode configuration at ~/.config/opencode/opencode.json:

{
  "plugin": ["opencode-mem"],
}

The plugin downloads automatically on next startup.

Usage Examples

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 });

Access the web interface at http://127.0.0.1:4747 for visual memory browsing and management.

Configuration Essentials

Configure at ~/.config/opencode/opencode-mem.jsonc:

The plugin creates a full commented template at this path on first startup. This trimmed example shows the most common settings:

{
  "storagePath": "~/.opencode-mem/data",
  "userEmailOverride": "user@example.com",
  "userNameOverride": "John Doe",
  "embeddingModel": "Xenova/nomic-embed-text-v1",
  // Optional OpenAI-compatible embedding endpoint:
  // "embeddingApiUrl": "https://api.openai.com/v1",
  // "embeddingApiKey": "env://OPENAI_API_KEY",
  // "embeddingModel": "text-embedding-3-small",

  "memory": {
    "defaultScope": "project",
  },
  "webServerEnabled": true,
  "webServerPort": 4747,

  "autoCaptureEnabled": true,
  "autoCaptureLanguage": "auto",

  "opencodeProvider": "anthropic",
  "opencodeModel": "claude-haiku-4-5-20251001",

  // Manual fallback if you do not use opencodeProvider:
  // "memoryProvider": "openai-chat",
  // "memoryModel": "gpt-4o-mini",
  // "memoryApiUrl": "https://api.openai.com/v1",
  // "memoryApiKey": "env://OPENAI_API_KEY",

  "showAutoCaptureToasts": true,
  "showUserProfileToasts": true,
  "showErrorToasts": true,

  "userProfileAnalysisInterval": 10,
  "maxMemories": 10,

  "compaction": {
    "enabled": true,

Continue your stack

What teams reach for next — and why each earns a place beside opencode-mem. Ranked by curator confidence.