mnemosyne/opencode-plugin/INSTALL.md
Joey Yakimowich-Payne b21871b8fc feat: add opencode plugin for Mnemosyne routing
TypeScript plugin that injects baseURL to route Anthropic API calls
through the Mnemosyne gateway, enriches compaction with memory context,
and provides mnemosyne_status/mnemosyne_query custom tools.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-13 11:41:36 -06:00

2.7 KiB

Installing opencode-mnemosyne

Prerequisites

  1. Mnemosyne gateway running (mnemosyne --no-launch --port 8080)
  2. opencode installed and configured
  3. OAuth authenticated (mnemosyne --login)

Quick Install (Local Development)

# From the contextmanager project root
cd opencode-plugin
npm install && npm run build

# Register as a local plugin in opencode
# Add to your ~/.config/opencode/opencode.json:
{
  "plugin": [
    "oh-my-opencode@latest",
    "file:///var/home/joey/Projects/contextmanager/opencode-plugin"
  ]
}

Configuration

The plugin is configured via environment variables:

Variable Default Description
MNEMOSYNE_HOST 127.0.0.1 Gateway host
MNEMOSYNE_PORT 8080 Gateway port
MNEMOSYNE_LOG_LEVEL info Log level: silent, error, info, debug

Usage

1. Start the Mnemosyne Gateway

cd ~/Projects/contextmanager
mnemosyne --no-launch --port 8080

2. Start opencode normally

The plugin automatically:

  • Routes Anthropic API calls through the gateway (via baseURL injection)
  • Enriches compaction prompts with memory context
  • Provides mnemosyne_status and mnemosyne_query tools

3. Custom Tools

Once loaded, the LLM has access to two new tools:

  • mnemosyne_status — Show memory state (objects, tokens, evictions, faults)
  • mnemosyne_query — Query the backing store for previously evicted context

How It Works

opencode → plugin (config hook injects baseURL) → Mnemosyne gateway → Anthropic API
                                                        ↕
                                              Object Store (backing store)
                                              Helper LLM (Haiku 4.5)
                                              Fidelity Manager
                                              Segmenter + Embedder

The plugin's config hook dynamically sets provider.anthropic.options.baseURL to the gateway URL. This means all Anthropic API calls are transparently proxied through Mnemosyne, which:

  1. Segments conversation into semantic objects
  2. Stores objects with embeddings in the backing store
  3. Compresses old objects via multi-fidelity degradation (L0→L1→L2→L3→L4)
  4. Retrieves evicted content on demand via micro-faults
  5. Detects topic shifts and reclassifies goals

Graceful Degradation

If the gateway is not running, the plugin silently skips all hooks. opencode works normally with no proxy — zero impact on the user experience.

npm Install (once published)

# In your opencode.json
{
  "plugin": [
    "opencode-mnemosyne@latest"
  ]
}

Then set MNEMOSYNE_PORT=8080 in your environment.