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>
2.7 KiB
2.7 KiB
Installing opencode-mnemosyne
Prerequisites
- Mnemosyne gateway running (
mnemosyne --no-launch --port 8080) - opencode installed and configured
- 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
baseURLinjection) - Enriches compaction prompts with memory context
- Provides
mnemosyne_statusandmnemosyne_querytools
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:
- Segments conversation into semantic objects
- Stores objects with embeddings in the backing store
- Compresses old objects via multi-fidelity degradation (L0→L1→L2→L3→L4)
- Retrieves evicted content on demand via micro-faults
- 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.