OpenCode 的 Supermemory 插件 oc-supermemory-redux
Drewlius/oc-supermemory-redux
oc-supermemory-redux 是一个面向 OpenCode 的 Supermemory 插件,遵循当前 API 契约,去掉了跨编辑器标签发现、自定义压缩处理和版本检查横幅。
A focused Supermemory plugin for OpenCode. It follows the current API contracts without legacy cross-editor tag discovery, custom compaction handling, or version-check banners.
Features
- Fetches the configured container's profile on the first message of a session and includes search results for that message.
- Searches for relevant memories on every later message.
- Incrementally sends structured user and assistant turns to
/v4/conversationsunder a stable conversation ID. - Uses one configurable
containerTagfor all reads and writes. - Creates direct memories through
/v4/memoriesrather than document ingestion. - Provides
add,update,search,profile,list,get, andforgettool modes. - Lists document metadata first and retrieves complete document content only when requested.
- Synchronizes the configured
entityContextwith the container's settings. - Displays OpenCode toast notifications for invalid configuration and backend failures.
- Keeps recall and conversation ingestion independent so one failing path does not block the other.
Installation
OpenCode loads local plugins from its plugins configuration directory. The default directory is ~/.config/opencode/plugins/
Prebuilt Plugin
The repository includes a self-contained oc-supermemory-redux.js bundle, so Bun is not required.
mkdir -p "~/.config/opencode/plugins" curl -fsSL \ https://raw.githubusercontent.com/Drewlius/oc-supermemory-redux/main/oc-supermemory-redux.js \ -o "~/.config/opencode/plugins/oc-supermemory-redux.js"
Create the configuration file at:
~/.config/opencode/supermemory.jsonc
No entry in opencode.jsonc is required. OpenCode automatically discovers JavaScript files in the local plugins directory.
Build From Source
git clone https://github.com/Drewlius/oc-supermemory-redux_OpenCode.git cd oc-supermemory-redux_OpenCode bun install --frozen-lockfile bun run typecheck bun run build mkdir -p "~/.config/opencode/plugins" cp ./dist/index.js "~/.config/opencode/plugins/oc-supermemory-redux.js"
Then create the configuration file at ~/.config/opencode/supermemory.jsonc, or directly inside OPENCODE_CONFIG_DIR when that override is set.
Restart OpenCode after installing or updating the plugin.
Configuration
Create supermemory.jsonc in your OpenCode configuration directory:
The optional entityContext setting accepts a string up to 1,500 characters. If omitted, the plugin uses its built-in coding-agent context and synchronizes it with the configured container.
API Key Resolution
The first available API key is used:
SUPERMEMORY_API_KEYenvironment variableapiKeyinsupermemory.jsoncapiKeyinsupermemory-credentials.json
Both configuration files belong in the OpenCode configuration directory. The plugin does not inspect configuration belonging to Claude, Codex, Cursor, or other applications.
Invalid JSON, missing credentials, unsupported values, and unreachable back-end services produce console errors in OpenCode.log. Configuration validation includes:
containerTag: 1-100 supported characterssimilarityThreshold: number from 0 to 1maxMemories: integer from 1 to 100injectProfile: booleanentityContext: maximum 1,500 charactersbaseUrl: valid HTTP or HTTPS URL
How It Works
Recall
On the first user message for a session, the plugin calls /v4/profile with the user's message as the query. The response provides the static and dynamic profile plus query-specific search results in one request.
Later messages call /v4/search in memories mode using the configured threshold and result limit. Retrieved context is injected as a synthetic [SUPERMEMORY] block.
Conversation Ingestion
On each user message, the plugin sends the previous assistant response and current user message as structured turns to /v4/conversations. The stable conversationId uses session_<sessionID>, allowing Supermemory to associate incremental updates with one conversation.
Recall and ingestion use separate failure paths. A failed profile or search request does not prevent conversation ingestion from being attempted.
Memory Tools
add: Creates a direct, non-static memory through/v4/memories.update: Corrects an existing memory throughPATCH /v4/memorieswhile preserving version history.search: Searches Supermemory using hybrid mode.profile: Retrieves the configured container's profile.list: Lists recent document metadata without downloading complete document content.get: Retrieves one complete document by ID.forget: Soft-deletes a memory by ID or exact content.
Direct memories and conversation updates include source: "opencode" metadata for provenance. The plugin does not use metadata for routing or filtering.
Design Boundaries
- No legacy container-tag fan-out
- No cross-editor configuration discovery
- No plugin-managed compaction
- No version-check banner
- No home-directory log file
- No manual document-ingestion path while backend hybrid document retrieval remains unreliable
OpenCode handles context-window management. Plugin diagnostics use OpenCode's structured logging and toast notifications.
Development
bun install --frozen-lockfile bun run typecheck bun run build
The build produces the self-contained dist/index.js bundle. Keep the top-level oc-supermemory-redux.js release artifact synchronized with that file.
Patch Notes
- Migrated plugin to OpenCode V ^2.0 specification.
- Toast error notifications are now gone and currently we are only logging errors/success through console.log
- Memory injection is fully visible in the user space now you can fully verify what memories the model got or if they got them at all.
- all supermemory sub commands: search, add, forget, update, list, get, docs, ect. now have individual mappings with a deeper explanation of their use case so your agent can more intelligently decide what tool to use and when to use it.
- removed fallback strip to the profile and memories so it is important to not set that too high now as we provide no defense against you injecting 20 or more memories per search query.
来源:GitHub · github.com