About this project

# opencode-supermemory **Persistent memory for OpenCode, powered by [Supermemory](https://supermemory.ai)** This plugin gives OpenCode agents persistent memory across sessions and projects. It automatically injects relevant context, captures conversation turns, and provides tools for storing and retrieving memories. ## Installation ```bash bunx opencode-supermemory@latest install bunx opencode-supermemory@latest login # or set SUPERMEMORY_API_KEY bunx opencode-supermemory@latest status # check the connection any time ``` Or paste this into OpenCode: `Install opencode-supermemory by following https://raw.githubusercontent.com/supermemoryai/opencode-supermemory/main/README.md` In-chat commands: `/supermemory-init`, `/supermemory-login`, `/supermemory-logout`, `/supermemory-status`. ## Features - **Context injection**: On a session's first message, the agent receives your profile, project knowledge, and optionally a semantic search over personal memories. - **Reasoned recall**: Every turn, the agent decides whether recalling memory would help before answering, searching via the `supermemory` tool only when needed. - **Automatic capture**: Completed turns are saved every `captureEveryNTurns` turns, with remainder flushed at session end. `<private>` content is redacted. - **Keyword detection**: Saying "remember", "save this", "don't forget" (or custom patterns) nudges the agent to save to memory. - **Codebase indexing**: `/supermemory-init` explores and memorizes codebase structure, patterns, and conventions. - **Preemptive compaction**: At 80% context capacity, triggers summarization, injects project memories into the summary, and saves the summary as a memory. - **Privacy**: Content wrapped in `<private>...</private>` is never stored. - **Update notices**: Checks npm for newer releases on session start. ## Tool usage The `supermemory` tool supports modes: `add`, `search`, `profile`, `list`, `forget`, `help`. Scopes: `user` (personal) and `project` (default). Types include `project-config`, `architecture`, `error-solution`, `preference`, `learned-pattern`, `conversation`. ## Memory scoping Memories are tagged with `repo_{project-name}__{repository-hash}` and metadata `sm_scope` (personal or project). The hash comes from the normalized Git origin remote, so Claude Code, Codex, Cursor, and OpenCode share the same container for the same repository. Legacy containers from older versions remain readable. ## Configuration Environment variables: `SUPERMEMORY_API_KEY`, `SUPERMEMORY_API_URL`/`SUPERMEMORY_BASE_URL`, `SUPERMEMORY_AUTH_URL`, `SUPERMEMORY_AUTH_TIMEOUT`, `SUPERMEMORY_REPO_TAG`, `SUPERMEMORY_ISOLATE_WORKTREES`, `SUPERMEMORY_DEBUG`. Config file `~/.config/opencode/supermemory.jsonc` supports options like `similarityThreshold`, `maxMemories`, `injectProfile`, `autoRecallEveryPrompt`, `keywordPatterns`, `compactionThreshold`, `captureEveryNTurns`, `recallMode` (direct/advisory/off), and container tag overrides. ## Usage with Oh My OpenCode Disable its auto-compact hook to avoid conflicts: add `{"disabled_hooks": ["anthropic-context-window-limit-recovery"]}` to `~/.config/opencode/oh-my-opencode.json`. ## Development ```bash bun install bun run build bun run typecheck ``` Logs: `tail -f ~/.opencode-supermemory.log` ## License MIT