New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@serkanalgur/residue

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serkanalgur/residue

Persistent, local-first project memory for OpenCode — extracts atomic 'decision + reason' facts from sessions and injects relevant notes via context hooks.

latest
Source
npmnpm
Version
0.3.2
Version published
Weekly downloads
723
Maintainers
1
Weekly downloads
 
Created
Source

Residue

Residue

npm version npm downloads stars license Socket Badge opencode typescript sponsor

Persistent, local-first project memory for OpenCode v2 — extracts decisions with their reasoning and recalls them on demand

Installation • Configuration • How It Works • Tools • Privacy & Security • Differences from opencode-mem • Development • License

Changelog — release history and what changed in each version.

Persistent, local-first project memory for OpenCode V2.

Residue extracts atomic "decision + reason" facts from coding sessions and injects relevant notes into future model calls via context hooks. All data lives on disk in SQLite — no cloud, no sync, no vendor lock-in.

Installation

npx opencode plugin add @serkanalgur/residue

Configuration

Add the plugin to your opencode.jsonc:

// opencode.jsonc
{
  "plugins": [
    {
      "package": "@serkanalgur/residue",
      "options": {
        "autoCapture": true,
        "embedding": "auto",
        "inject": { "enabled": true, "maxChars": 2400, "maxFacts": 6, "minScore": 0.34 }
      }
    }
  ]
}
OptionDefaultDescription
autoCapturetrueAutomatically extract facts from conversations
capturePromptsfalseAlso capture user prompts (not just assistant text) for extraction. Opt-in: it widens what is persisted
embedding"auto"Embedding strategy: auto, remote, ollama, local, none
embeddingKeyEnv"OPENAI_API_KEY"Env var for the embedding API key
dataDir"xdg"Data location: xdg (XDG_DATA_HOME) or project (.opencode/residue/)
inject.enabledtrueEnable/disable context injection
inject.maxChars2400Maximum characters to inject per call
inject.maxFacts6Maximum facts to inject
inject.minScore0.34Minimum similarity score threshold
inject.shareAcrossWorktreestrueShare facts across worktrees of the same project
retention.enabledtrueEnable automatic retention runs (TTL expiry, row cap enforcement)
retention.maxRecordsPerProject2000Max records per project. 0 = unlimited (no cap)
retention.maxRecordsGlobal5000Max records globally. 0 = unlimited (no cap)
debugfalseEnable debug logging

Retention note: Setting maxRecordsPerProject or maxRecordsGlobal to 0 disables that cap entirely (unlimited records). It does not mean "store zero records." If you want to prevent record capture, set autoCapture: false instead.

How It Works

  • Ingestion: Listens to session events (session.text.delta feeds a turn buffer; session.idle triggers extraction). An LLM call extracts durable facts from the conversation.

  • Storage: Facts are stored in a local SQLite database with scope isolation (project + worktree). FTS5 enables full-text search; optional vector embeddings enable semantic search.

  • Injection: A context hook runs before every model call, retrieves relevant memories via hybrid search (lexical + vector with Reciprocal Rank Fusion), and injects them as <recalled_notes> system parts.

Tools

Residue registers three tools under the res namespace:

  • res_search — Hybrid memory search (FTS5 + vector via RRF)
  • res_add — Manually add a memory record with provenance
  • res_status — Plugin health, store status, embedder state

Privacy & Security

  • Local-first: All data stays on your machine in SQLite. No telemetry, no cloud sync.
  • Scope isolation: Project records are isolated by project ID + worktree key. Cross-project leakage is prevented at the SQL level.
  • Secret redaction: API keys, tokens, and sensitive file references are automatically redacted from extracted text before storage.
  • Provenance mandatory: Records without a source (session ID + timestamp) are silently discarded.
  • Sub-agent guard: res_add is removed for non-build agents to prevent sub-agents from polluting project memory.

Differences from opencode-mem

FeatureResidueopencode-mem
StorageSQLite (file-backed, WAL mode)In-memory only
SearchHybrid (FTS5 + vector with RRF)Basic text match
ScopeProject + worktree isolationGlobal only
InjectionContext hook with memoisationN/A
EmbeddingAuto/remote/ollama/local fallbackFixed provider
PersistenceSurvives restartsLost on restart

Development

bun install
bun run typecheck
bun test
bun run lint

Community

License

MIT — see LICENSE.

Keywords

opencode

FAQs

Package last updated on 03 Oct 2026

Related posts