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-plugin-mempalace

v1.2.1

Published

An OpenCode plugin that integrates MemPalace's lifetime memory (L0-L3 memory stack, AAAK compression, auto context saving) into the OpenCode terminal assistant.

Downloads

795

Readme

OpenCode Plugin: MemPalace

npm version License: MIT

A community open-source plugin that integrates MemPalace's "lifetime memory" (L0-L3 memory stack, AAAK compression, auto context saving) into the OpenCode terminal assistant.

This plugin ensures your AI assistant has a long-term memory across sessions by seamlessly hooking into OpenCode's lifecycle events to fetch, inject, and save contexts related to your specific workspace.

🌟 Features

  • Zero-Config Auto-Initialization: Opens a new folder? The plugin automatically initializes a MemPalace database for it in the background.
  • Auto-Injection (Wake-up): Automatically wakes up MemPalace on session initialization to inject L0 (Global Identity) and L1 (Critical Facts) directly into the AI's System Prompt.
  • Pre-Compaction Rescue: Adds your core memory context back right before OpenCode compresses the conversation, ensuring crucial details are never lost.
  • Silent Background Mining: Quietly exports and saves your conversational history into your MemPalace database as you chat, preserving decisions for future usage without spending extra tokens on MCP tool calls.
  • Crash Safety & Idle Auto-Save: Never lose your context, even if you close the terminal early!
    • Idle Auto-Save: If your session is deleted or you simply stop chatting (idle), any un-saved messages are softly mined in the background.
    • Crash Safety: If you force-quit the terminal (Ctrl+C), the plugin intercepts the exit signal and performs a synchronous emergency save.

📋 Requirements

  • OpenCode AI Terminal
  • Python 3.9+
  • MemPalace installed globally (pip install mempalace or python3 -m pip install mempalace)

🚀 Installation

  1. Install the official MemPalace CLI on your system:

    python3 -m pip install mempalace
  2. Add this plugin to your OpenCode configuration. Open ~/.config/opencode/opencode.json (or your project's local opencode.json) and add the package name to the plugins array:

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

⚙️ Configuration (Optional)

You can pass configuration options to the plugin to customize its behavior. Currently supported options:

  • threshold (default: 15): The number of chat messages required before the plugin triggers a background auto-save (mining) of your conversation.
{
  "plugin": [["opencode-plugin-mempalace", { "threshold": 20 }]]
}

🛠️ How It Works

  • The plugin wraps the mempalace CLI via the execa package.
  • It acts as the "subconscious" of your AI, rather than just an active tool.
  • Hooks used:
    • experimental.chat.system.transform: Injects memory.
    • experimental.session.compacting: Rescues memory from truncation.
    • chat.message: Tracks conversation length and triggers background mining.
    • event: Listens for session.idle and session.deleted for soft-exit saving.
    • process.on('exit' | 'SIGINT' | 'SIGTERM'): Intercepts hard process exits for emergency synchronous saving.
  • Workspace Isolation: It infers the wing name intelligently from the workspace path (e.g. /projects/my-app -> wing_my-app). Your memory stays isolated per project!

🧑‍💻 Development

This project is built with TypeScript (ESM) and relies on a strict TDD approach.

npm install
npm run lint
npm run test
npm run build

📄 License

MIT