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

@fnnm/opencode-memory-plugin

v0.2.2

Published

Progressive-disclosure generated memories for OpenCode.

Readme

opencode-memory-plugin

Progressive-disclosure generated memories for OpenCode.

Codex-style generated memory files, but OpenCode-native: compact recall first, source session IDs only when useful, and no repo .opencode/ state.

flowchart TD
  Turn["new OpenCode turn"] --> Summary["tiny memory context"]
  Summary --> Agent["OpenCode agent"]
  Agent --> Remember["remember"]
  Agent --> Need["needs more memory?"]
  Need --> Recall["recall_memory"]
  Recall --> Cards["memory cards"]
  Cards --> Expand["expand_memory"]
  Remember --> Store["OpenCode memory files"]
  Extract["extract_memories"] --> Store
  Store --> Files["memory_summary.md + MEMORY.md"]
  Store --> Summary

What it does

  • Writes generated memory files under ${XDG_CONFIG_HOME:-~/.config}/opencode/memories.
  • Injects a small memory hint at turn start.
  • Nudges the agent to call recall_memory automatically when prior context may matter.
  • Keeps memory cards searchable without stuffing full history into context.
  • Adds source_thread_ids to extracted facts, decisions, and working context.
  • Lets simple explicit preferences stay clean with no session citation.

Memory layers

  1. memory_summary.md: tiny always-useful summary.
  2. MEMORY.md: searchable generated index.
  3. memories.json: canonical store for tools.
  4. Sessions: source expansion only when a card needs evidence (via OpenCode read_thread tool).

Tools

  • remember: save or update a compact memory.
  • recall_memory: search memory cards.
  • expand_memory: show full card + source IDs.
  • forget_memory: delete a memory.
  • list_memories: list cards by type/scope.
  • extract_memories: extract durable memories from recent messages (LLM-driven with heuristic fallback).
  • memory_files: show generated file paths.
  • get_memory_summary: show the compact memory summary.

Source rule: explicit preferences can omit sessions; facts, decisions, and working context default to the current session unless you pass source_thread_ids.

Auto extraction is off by default. When enabled it uses an LLM sub-session (a child of the current session) with no tools and strict JSON output. Heuristic pattern matching is the fallback when the LLM call fails or the fallback is enabled. Enable it with:

export OPENCODE_MEMORY_AUTO_EXTRACT=true

Disable turn-start injection:

export OPENCODE_MEMORY_INJECT=false

Disable the heuristic fallback (fail silent on LLM errors instead):

export OPENCODE_MEMORY_HEURISTIC_FALLBACK=false

Internationalization

The plugin is not fully localized — tool descriptions, error messages, and the generated memory_summary.md header are English. The heuristic path (OPENCODE_MEMORY_HEURISTIC_FALLBACK=true, the default) recognizes English, Chinese, Japanese, and Korean in five places:

| Function | What it does for non-English input | |----------|------------------------------------| | tokenize() | NFKC normalization; unigrams for every CJK/Hangul/Kana char; bigrams only for runs of 3+ chars (avoids single-bigram noise). | | explicitRememberText() | Matches 记住X / 記住:X / 覚えてX / 覚えておいてX / 기억해 X / 기억해둬 X, with the same negative protection as English (不要记住 / 覚えないで / 기억하지 마). | | heuristicExtractMemories sentence splitter | Splits on .!?。!?;…、 and newlines. | | heuristicConfidence() | Chinese/Japanese/Korean high- and low-confidence keywords. | | inferMemoryType() | preference / decision / working-context / fact for Chinese and Japanese. |

The LLM extractor (OPENCODE_MEMORY_AUTO_EXTRACT=true) is told to preserve the user's original language verbatim — it will not translate, transliterate, or romanize. Pass a model with strong multilingual support in extractorModel if your team writes in a language not listed above.

Memory text is stored as written. If you write 记住:使用bun in Chinese, the recall token index will contain , , 记住, 住使, 使用, bun, so a later query in either language can find it.

Config

Configuration can be provided via environment variables or via plugin options in opencode.json. Options take priority.

| Variable / option | Default | Description | |----------|---------|-------------| | OPENCODE_MEMORY_INJECT / inject | true | Inject memory context at turn start | | OPENCODE_MEMORY_AUTO_EXTRACT / autoExtract | false | Auto-extract memories after each turn | | OPENCODE_MEMORY_HEURISTIC_FALLBACK / extractorFallback | true | Fall back to heuristic when LLM extraction fails | | OPENCODE_MEMORY_EXTRACTOR_MODEL / extractorModel | openai/gpt-5.5 | Model for the LLM extractor sub-session | | OPENCODE_MEMORY_EXTRACTOR_TIMEOUT / extractorTimeoutMs | 90000 | Timeout per extractor sub-session call (ms) | | OPENCODE_MEMORY_HOME / home | ~/.config/opencode/memories | Override memory storage directory |

Plugin options in ~/.config/opencode/opencode.json:

{
  "plugins": [
    {
      "package": "opencode-memory-plugin",
      "options": {
        "autoExtract": true,
        "extractorModel": "anthropic/claude-sonnet-4-5"
      }
    }
  ]
}

Install

Option A: npm package (recommended)

Add to your ~/.config/opencode/opencode.json:

{
  "plugins": ["opencode-memory-plugin"]
}

Option B: symlink for development

mkdir -p ~/.config/opencode/plugin
ln -sf "$(pwd)/src/memory.ts" ~/.config/opencode/plugin/memory.ts

Option C: direct download

mkdir -p ~/.config/opencode/plugin
curl -fsSL https://raw.githubusercontent.com/lleewwiiss/amp-memory-plugin/master/src/memory.ts \
  -o ~/.config/opencode/plugin/memory.ts

Development

bun install
bun run check       # typecheck
bun test            # 109 tests
bun run install:plugin     # copy memory.ts to ~/.config/opencode/plugin/
bun run install:commands   # copy slash commands to ~/.config/opencode/command/

Use OPENCODE_MEMORY_HOME=/tmp/opencode-memory-test for isolated testing.

Slash commands (optional)

The plugin also ships three OpenCode slash commands under src/commands/. They delegate to the same tools the agent can call, but expose them as /memory-summary, /memory-list, and /memory-files in the TUI:

bun run install:commands

MIT. See LICENSE.