npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-lcm

v0.14.0

Published

Long-memory plugin for OpenCode with context-mode interop

Downloads

1,358

Readme

Opencode-lcm (Lossless Context Memory)

npm version CI License: MIT

A transparent long-memory plugin for OpenCode, based on the Lossless Context Memory (LCM) research by Voltropy. It captures older session context outside the active prompt, compresses it into searchable summaries and artifacts, then automatically recalls relevant details back into the prompt when the current turn needs them. The model does not become smarter, but it behaves much better across long, compacted sessions because important prior context stops disappearing.

[!NOTE] This is an early community plugin for OpenCode and is not affiliated with or endorsed by the OpenCode project. Behavior, internals, and configuration may change as the project evolves.

context-mode

opencode-lcm preserves archived conversation context so the assistant can recall earlier decisions without re-reading old files. Pairing it with context-mode reduces tool-output token waste and keeps the active prompt lean.

Installation

Add to your opencode.json (project or global ~/.config/opencode/opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-lcm"]
}

OpenCode will automatically download the latest version from npm on startup. No manual install needed.

From source

git clone https://github.com/Plutarch01/opencode-lcm.git
cd opencode-lcm
npm install
npm run build

Then copy or symlink the built plugin into your plugins directory:

# Project-level
cp dist/index.js .opencode/plugins/opencode-lcm.js

# Or global
cp dist/index.js ~/.config/opencode/plugins/opencode-lcm.js

Local plugins in .opencode/plugins/ or ~/.config/opencode/plugins/ are loaded automatically by OpenCode at startup.

How It Works

OpenCode handles compaction normally — when the conversation gets too large, it shrinks the prompt. opencode-lcm works alongside that by saving older details outside the prompt, then searching that archive later to pull back only what matters.

Archive

Listens to OpenCode events and stores session state, messages, parts, and artifacts in .lcm/lcm.db. Builds deterministic summary nodes for archived turns and automatically repairs summary, index, lineage, and resume drift.

Automatic Recall

Inserts archived context into the prompt via experimental.chat.messages.transform. Starts with the current session and escalates to broader scopes when needed. Uses TF-IDF weighted retrieval with bigram phrase queries for corpus-aware ranking.

Resume Notes

Appends a compact resume note during compaction so important context survives the shrink without overriding the compaction prompt.

Capabilities

  • Session lineage — track parent/root relationships for branched sessions
  • Artifact externalization — deduplicated storage with metadata for oversized payloads
  • FTS search — SQLite FTS5 across archived messages, summaries, and artifacts
  • Snapshot export/import — portable snapshots with safe merge and worktree modes
  • Privacy controls — tool-output exclusion, path-based capture exclusion, regex redaction
  • Configurable retrieval — scope ordering, per-scope budgets, stop rules, recency-aware ranking
  • 16 toolslcm_status, lcm_resume, lcm_grep, lcm_describe, lcm_lineage, lcm_expand, lcm_artifact, lcm_pin_session, lcm_unpin_session, lcm_blob_stats, lcm_blob_gc, lcm_doctor, lcm_retention_report, lcm_retention_prune, lcm_export_snapshot, lcm_import_snapshot
  • Legacy migration — auto-migrates .lcm/events.jsonl, .lcm/resume.json, .lcm/sessions/*.json

Configuration

Add opencode-lcm to your opencode.json (project or global ~/.config/opencode/opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    ["opencode-lcm", {
      "scopeDefaults": { "grep": "session", "describe": "session" },
      "automaticRetrieval": {
        "enabled": true,
        "scopeOrder": ["session", "root", "worktree"],
        "scopeBudgets": { "session": 16, "root": 12, "worktree": 8, "all": 6 }
      },
      "retention": {
        "staleSessionDays": 90,
        "deletedSessionDays": 30,
        "orphanBlobDays": 14
      }
    }]
  ]
}

[!IMPORTANT] All defaults are applied automatically. Expand below only if you need to override settings.

[!IMPORTANT] On Bun for Windows, opencode-lcm now starts in a pre-SQLite safe mode and only exposes lcm_status by default. This avoids a Bun/Windows native-crash path seen in the field. To force-enable the full plugin anyway, set "runtimeSafety": { "allowUnsafeBunWindows": true } in the plugin config or export OPENCODE_LCM_ALLOW_UNSAFE_BUN_WINDOWS=1 before starting OpenCode.

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    ["opencode-lcm", {
      "scopeDefaults": {
        "grep": "session",
        "describe": "session"
      },
      "retention": {
        "staleSessionDays": 90,
        "deletedSessionDays": 30,
        "orphanBlobDays": 14
      },
      "privacy": {
        "excludeToolPrefixes": ["playwright_browser_"],
        "excludePathPatterns": ["[\\\\/]secrets[\\\\/]", "\\\\.env($|\\\\.)"],
        "redactPatterns": ["sk-[A-Za-z0-9_-]+", "ZX729ALBATROSS"]
      },
      "automaticRetrieval": {
        "enabled": true,
        "scopeOrder": ["session", "root", "worktree"],
        "scopeBudgets": {
          "session": 16,
          "root": 12,
          "worktree": 8,
          "all": 6
        },
        "stop": {
          "targetHits": 3,
          "stopOnFirstScopeWithHits": false
        },
        "maxMessageHits": 2,
        "maxSummaryHits": 1,
        "maxArtifactHits": 1
      },
      "freshTailMessages": 10,
      "minMessagesForTransform": 16,
      "summaryCharBudget": 1500,
      "systemHint": true,
      "binaryPreviewProviders": ["fingerprint", "byte-peek", "image-dimensions", "pdf-metadata"],
      "previewBytePeek": 16
    }]
  ]
}

Privacy Controls

Privacy patterns run before archived content is stored or indexed.

  • excludeToolPrefixes — do not archive tool payloads for matching tools
  • excludePathPatterns — suppress file capture for matching paths, redact matching path strings
  • redactPatterns — replace matching content with [REDACTED] before storage and indexing

These controls are not encryption and not retroactive. Existing archived rows keep their previous content until rewritten.

context-mode Interop

Pairing with context-mode reduces tool-output token waste. Add the interop block to avoid hook conflicts:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "context-mode": {
      "type": "local",
      "command": ["context-mode"]
    }
  },
  "plugin": [
    "context-mode",
    ["opencode-lcm", {
      "interop": {
        "contextMode": true,
        "neverOverrideCompactionPrompt": true,
        "ignoreToolPrefixes": ["ctx_"]
      },
      "scopeDefaults": { "grep": "session", "describe": "session" },
      "retention": {
        "staleSessionDays": 90,
        "deletedSessionDays": 30,
        "orphanBlobDays": 14
      }
    }]
  ]
}

Disable

Remove opencode-lcm from the plugin array and restart OpenCode. To keep the archive but stop automatic recall, set automaticRetrieval.enabled to false.

Performance

Run the opt-in archive performance harness locally:

npm run perf:archive -- --json-out perf-results/archive-perf.json

Useful knobs: --medium-messages, --large-messages, --samples, --warm-runs, --keep-workspaces.

There is also a separate Archive Performance GitHub Actions workflow for scheduled/manual advisory runs.

License

MIT