aboutsummaryrefslogtreecommitdiff
path: root/apps/docs/integrations/opencode.mdx
blob: d1a11b675be2174ce80cc3ed6ecb362d02298da4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
title: "OpenCode"
sidebarTitle: "OpenCode"
description: "OpenCode Supermemory Plugin — persistent memory across coding sessions"
icon: "/images/opencode-logo.png"
---

<Warning>
This integration requires the **Supermemory Pro plan**. [Upgrade here](https://console.supermemory.ai/billing).
</Warning>

[OpenCode-Supermemory](https://github.com/supermemoryai/opencode-supermemory) is an OpenCode plugin that gives your AI persistent memory across sessions. Your agent remembers what you worked on — across sessions, across projects.

## Get Your API Key

Create a Supermemory API key from the [API Keys](https://console.supermemory.ai/keys) page, then add it to your shell profile so it persists across sessions:

<Tabs>
  <Tab title="macOS / Linux (zsh)">
    ```bash
    echo 'export SUPERMEMORY_API_KEY="sm_..."' >> ~/.zshrc
    source ~/.zshrc
    ```
  </Tab>
  <Tab title="macOS / Linux (bash)">
    ```bash
    echo 'export SUPERMEMORY_API_KEY="sm_..."' >> ~/.bashrc
    source ~/.bashrc
    ```
  </Tab>
  <Tab title="Windows (PowerShell)">
    ```powershell
    [System.Environment]::SetEnvironmentVariable("SUPERMEMORY_API_KEY", "sm_...", "User")
    ```
    Restart your terminal after running this.
  </Tab>
</Tabs>

## Install the Plugin

```bash
bunx opencode-supermemory@latest install
```

For LLM agents (non-interactive):

```bash
bunx opencode-supermemory@latest install --no-tui
```

Ensure your `~/.config/opencode/opencode.jsonc` contains:

```json
{
  "plugin": ["opencode-supermemory"]
}
```

## How It Works

Once installed, the plugin runs automatically:

- **Context Injection** — On session start, relevant memories are fetched and injected into the agent's context. This includes user preferences, project knowledge, and past interactions.
- **Keyword Detection** — Phrases like "remember" or "save this" trigger automatic storage.
- **Smart Compaction** — At 80% context capacity, sessions are summarized and saved as memories.
- **Privacy Protection** — Content within `<private>` tags never persists.

### Memory Scopes

| Scope | Description |
|-------|-------------|
| `user` | Memories that persist across all projects |
| `project` | Memories isolated to the current project (default) |

### Memory Types

| Type | Description |
|------|-------------|
| `project-config` | Project configuration and setup details |
| `architecture` | Codebase structure and design patterns |
| `error-solution` | Problems encountered and their fixes |
| `preference` | User preferences and coding style |
| `learned-pattern` | Patterns discovered during sessions |
| `conversation` | Important conversation context |

## Commands

### /supermemory-init

Explore and index your codebase structure into memory:

```
/supermemory-init
```

## Tools

The agent has access to a `supermemory` tool with these modes:

| Mode | Parameters | Function |
|------|------------|----------|
| `add` | content, type?, scope? | Store information |
| `search` | query, scope? | Find relevant memories |
| `profile` | query? | View user preferences |
| `list` | scope?, limit? | Display stored items |
| `forget` | memoryId, scope? | Remove memory |

## Configuration

Create `~/.config/opencode/supermemory.jsonc`:

```jsonc
{
  "apiKey": "sm_...",              // Or use SUPERMEMORY_API_KEY env var
  "similarityThreshold": 0.6,      // Minimum match score (0-1)
  "maxMemories": 5,                // Memories per injection
  "maxProjectMemories": 10,        // Project memory listings
  "maxProfileItems": 5,            // Profile facts injected
  "injectProfile": true,           // Include user preferences in context
  "containerTagPrefix": "opencode", // Tag prefix for scoping
  "compactionThreshold": 0.80      // Context usage ratio for summarization
}
```

## Logging

View plugin activity:

```bash
tail -f ~/.opencode-supermemory.log
```

## Next Steps

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/supermemoryai/opencode-supermemory">
    Source code, issues, and detailed README.
  </Card>

  <Card title="Claude Code Plugin" icon="code" href="/integrations/claude-code">
    Memory plugin for Claude Code.
  </Card>
</CardGroup>