Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@opencode-manager/memory

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencode-manager/memory

AI-powered memory management plugin for OpenCode - semantic search and persistent knowledge storage

Source
npmnpm
Version
0.0.8
Version published
Weekly downloads
116
96.61%
Maintainers
1
Weekly downloads
 
Created
Source

@opencode-manager/memory

Memory management plugin for OpenCode that enables semantic search and persistent storage of project knowledge.

Features

  • Semantic Memory Search - Store and retrieve project memories using vector embeddings
  • Multiple Memory Scopes - Categorize memories as convention, decision, or context
  • Automatic Deduplication - Prevents duplicates via exact match and semantic similarity detection
  • Compaction Context Injection - Injects planning state, conventions, and decisions into session compaction for seamless continuity
  • Bundled Agents - Ships with Code, Architect, and Memory agents preconfigured for memory-aware workflows
  • CLI Export/Import - Export and import memories as JSON or Markdown for backup and migration
  • Dimension Mismatch Detection - Detects embedding model changes and guides recovery via reindex
  • Session Planning - Tracks objectives, phases, findings, and errors across sessions with automatic TTL cleanup

Tools

ToolDescription
memory-readSearch and retrieve project memories with semantic search
memory-writeStore a new project memory
memory-editUpdate an existing project memory
memory-deleteDelete a project memory by ID
memory-healthHealth check or full reindex of the memory store
memory-planning-updateUpdate session planning state (phases, objectives, progress)
memory-planning-getGet the current planning state for a session
memory-plan-executeCreate a new Code session and send an approved plan as the first prompt

Planning state differs from memories: it stores temporary session data (objectives, phase progress, findings, errors) with a 7-day TTL, while memories are persisted indefinitely and retrieved via semantic search.

Agents

The plugin bundles three agents that integrate with the memory system:

AgentIDModeDescription
Codeocm-codeprimaryPrimary coding agent with memory awareness. Checks memory before unfamiliar code, stores architectural decisions and conventions as it works.
Architectocm-architectprimaryRead-only planning agent. Researches the codebase, checks memory for conventions and decisions, designs implementation plans, then hands off to Code via memory-plan-execute.
Memoryocm-memorysubagentExpert agent for storing, retrieving, and curating project knowledge. Handles post-compaction memory extraction and contradiction resolution.

The Architect agent operates in read-only mode (temperature: 0.0, all edits denied). After the user approves a plan, it calls memory-plan-execute to create a new Code session with the full plan as context.

CLI

Export and import memories using the bundled CLI tool. The CLI auto-detects the project ID from git and resolves the database path automatically.

Export

# Export all memories as JSON (stdout)
bun run src/cli/export.ts export

# Export as Markdown to file
bun run src/cli/export.ts export --format markdown --output memories.md

# Export with project and scope filter
bun run src/cli/export.ts export --project my-project --scope convention

# Limit and paginate results
bun run src/cli/export.ts export --limit 50 --offset 100

Export options:

FlagDescription
--format, -fOutput format: json or markdown (default: json)
--output, -oOutput file path (prints to stdout if omitted)
--project, -pProject ID filter (auto-detected from git)
--scope, -sFilter by scope: convention, decision, or context
--limit, -lMax number of memories (default: 1000)
--offsetPagination offset (default: 0)
--db-pathCustom database file path

Import

# Import from JSON
bun run src/cli/export.ts import memories.json --project my-project

# Import from Markdown (format auto-detected from extension)
bun run src/cli/export.ts import memories.md --project my-project

# Skip duplicate detection
bun run src/cli/export.ts import memories.json --project my-project --force

Import options:

FlagDescription
--format, -fInput format: json or markdown (auto-detected from extension)
--project, -pProject ID to assign memories to (auto-detected from git)
--forceSkip duplicate detection and import all
--db-pathCustom database file path

Installation

Install the package from npm:

npm install @opencode-manager/memory
# or
pnpm add @opencode-manager/memory

During installation, the local embedding model (all-MiniLM-L6-v2) is downloaded automatically via the postinstall script. For API-based embeddings (OpenAI or Voyage), skip the local model and set your provider and API key in the configuration instead.

Then configure opencode to load the plugin. In your opencode.json:

{
  "plugin": ["@opencode-manager/memory"]
}

Configuration

On first run, the plugin automatically copies the bundled config to your data directory:

  • Path: ~/.local/share/opencode/memory/config.json
  • Falls back to: $XDG_DATA_HOME/opencode/memory/config.json

You can edit this file to customize settings. The file is created only if it doesn't already exist.

{
  "embedding": {
    "provider": "local",
    "model": "all-MiniLM-L6-v2",
    "dimensions": 384
  },
  "dataDir": "~/.local/share/opencode/memory",
  "dedupThreshold": 0.25,
  "logging": {
    "enabled": false,
    "file": "~/.local/share/opencode/memory/logs/memory.log"
  },
  "compaction": {
    "customPrompt": true,
    "inlinePlanning": true,
    "maxContextTokens": 4000,
    "snapshotToKV": true
  }
}

For API-based embeddings:

{
  "embedding": {
    "provider": "openai",
    "model": "text-embedding-3-small",
    "apiKey": "sk-..."
  }
}

Options

Embedding

  • embedding.provider - Embedding provider: "local", "openai", or "voyage"
  • embedding.model - Model name
    • local: "all-MiniLM-L6-v2" (384d)
    • openai: "text-embedding-3-small" (1536d), "text-embedding-3-large" (3072d), or "text-embedding-ada-002" (1536d)
    • voyage: "voyage-code-3" (1024d) or "voyage-2" (1536d)
  • embedding.dimensions - Vector dimensions (optional, auto-detected for known models)
  • embedding.apiKey - API key for openai/voyage providers
  • embedding.baseUrl - Custom endpoint (optional, defaults to provider's official API)

Storage

  • dataDir - Directory for SQLite database storage (default: "~/.local/share/opencode/memory")
  • dedupThreshold - Similarity threshold for deduplication (0–1, default: 0.25, clamped to 0.05–0.40)

Logging

  • logging.enabled - Enable file logging (default: false)
  • logging.file - Log file path (default: "~/.local/share/opencode/memory/logs/memory.log")

When enabled, logs are written to the specified file with timestamps. The log file has a 10MB size limit with automatic rotation.

Compaction

  • compaction.customPrompt - Use a custom compaction prompt optimized for session continuity (default: true)
  • compaction.inlinePlanning - Inject planning state (phases, objectives, progress) into compaction context (default: true)
  • compaction.maxContextTokens - Token budget for injected memory context with priority-based trimming (default: 4000)
  • compaction.snapshotToKV - Store compaction snapshots in the session KV store for recovery (default: true)

Development

pnpm build      # Compile TypeScript to dist/
pnpm test       # Run tests
pnpm typecheck  # Type check without emitting

Keywords

opencode

FAQs

Package last updated on 25 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts