Skip to content

Commit 1c0bb9a

Browse files
authored
Merge pull request #27 from supermemoryai/migrate-plugin-to-app
Add /supermemory-logout command and migrate to app.supermemory.ai
2 parents 092816a + 263442f commit 1c0bb9a

3 files changed

Lines changed: 50 additions & 21 deletions

File tree

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ Your agent remembers what you tell it - across sessions, across projects.
1212
bunx opencode-supermemory@latest install
1313
```
1414

15-
Then get your API key from [console.supermemory.ai](https://console.supermemory.ai) and set it:
15+
Then get your API key from [app.supermemory.ai](https://app.supermemory.ai/?view=integrations) and set it:
1616

1717
```bash
1818
export SUPERMEMORY_API_KEY="sm_..."
1919
```
2020

2121
**Or let your agent do it** - paste this into OpenCode:
22+
2223
```
2324
Install opencode-supermemory by following https://raw.githubusercontent.com/supermemoryai/opencode-supermemory/main/README.md
2425
```
@@ -37,6 +38,7 @@ bunx opencode-supermemory@latest install --no-tui
3738
```
3839

3940
This will:
41+
4042
- Register the plugin in `~/.config/opencode/opencode.jsonc`
4143
- Create the `/supermemory-init` command
4244

@@ -47,6 +49,7 @@ cat ~/.config/opencode/opencode.jsonc
4749
```
4850

4951
Should contain:
52+
5053
```json
5154
{
5255
"plugin": ["opencode-supermemory"]
@@ -56,16 +59,18 @@ Should contain:
5659
If not, add it manually:
5760

5861
**JSONC:**
62+
5963
```jsonc
6064
{
6165
"plugin": [
62-
"opencode-supermemory"
66+
"opencode-supermemory",
6367
// ... other plugins
64-
]
68+
],
6569
}
6670
```
6771

6872
**JSON:**
73+
6974
```json
7075
{
7176
"plugin": ["opencode-supermemory"]
@@ -74,7 +79,7 @@ If not, add it manually:
7479

7580
#### Step 3: Configure API key
7681

77-
Ask the user to get their API key from [console.supermemory.ai](https://console.supermemory.ai).
82+
Ask the user to get their API key from [app.supermemory.ai](https://app.supermemory.ai/?view=integrations).
7883

7984
Then set it via environment variable:
8085

@@ -86,7 +91,7 @@ Or create `~/.config/opencode/supermemory.jsonc`:
8691

8792
```jsonc
8893
{
89-
"apiKey": "sm_..."
94+
"apiKey": "sm_...",
9095
}
9196
```
9297

@@ -99,6 +104,7 @@ opencode -c
99104
```
100105

101106
They should see `supermemory` in the tools list. If not, check:
107+
102108
1. Is `SUPERMEMORY_API_KEY` set?
103109
2. Is the plugin in `opencode.jsonc`?
104110
3. Check logs: `tail ~/.opencode-supermemory.log`
@@ -114,11 +120,13 @@ Run `/supermemory-init` to have the agent explore and memorize the codebase.
114120
### Context Injection
115121

116122
On first message, the agent receives (invisible to user):
123+
117124
- User profile (cross-project preferences)
118125
- Project memories (all project knowledge)
119126
- Relevant user memories (semantic search)
120127

121128
Example of what the agent sees:
129+
122130
```
123131
[SUPERMEMORY]
124132
@@ -154,6 +162,7 @@ Run `/supermemory-init` to explore and memorize your codebase structure, pattern
154162
### Preemptive Compaction
155163

156164
When context hits 80% capacity:
165+
157166
1. Triggers OpenCode's summarization
158167
2. Injects project memories into summary context
159168
3. Saves session summary as a memory
@@ -172,23 +181,23 @@ Content in `<private>` tags is never stored.
172181

173182
The `supermemory` tool is available to the agent:
174183

175-
| Mode | Args | Description |
176-
|------|------|-------------|
177-
| `add` | `content`, `type?`, `scope?` | Store memory |
178-
| `search` | `query`, `scope?` | Search memories |
179-
| `profile` | `query?` | View user profile |
180-
| `list` | `scope?`, `limit?` | List memories |
181-
| `forget` | `memoryId`, `scope?` | Delete memory |
184+
| Mode | Args | Description |
185+
| --------- | ---------------------------- | ----------------- |
186+
| `add` | `content`, `type?`, `scope?` | Store memory |
187+
| `search` | `query`, `scope?` | Search memories |
188+
| `profile` | `query?` | View user profile |
189+
| `list` | `scope?`, `limit?` | List memories |
190+
| `forget` | `memoryId`, `scope?` | Delete memory |
182191

183192
**Scopes:** `user` (cross-project), `project` (default)
184193

185194
**Types:** `project-config`, `architecture`, `error-solution`, `preference`, `learned-pattern`, `conversation`
186195

187196
## Memory Scoping
188197

189-
| Scope | Tag | Persists |
190-
|-------|-----|----------|
191-
| User | `opencode_user_{sha256(git email)}` | All projects |
198+
| Scope | Tag | Persists |
199+
| ------- | -------------------------------------- | ------------ |
200+
| User | `opencode_user_{sha256(git email)}` | All projects |
192201
| Project | `opencode_project_{sha256(directory)}` | This project |
193202

194203
## Configuration
@@ -228,7 +237,7 @@ Create `~/.config/opencode/supermemory.jsonc`:
228237
"keywordPatterns": ["log\\s+this", "write\\s+down"],
229238

230239
// Context usage ratio that triggers compaction (0-1)
231-
"compactionThreshold": 0.80
240+
"compactionThreshold": 0.8,
232241
}
233242
```
234243

@@ -237,6 +246,7 @@ All fields optional. Env var `SUPERMEMORY_API_KEY` takes precedence over config
237246
### Container Tag Selection
238247

239248
By default, container tags are auto-generated using `containerTagPrefix` plus a hash:
249+
240250
- User tag: `{prefix}_user_{hash(git_email)}`
241251
- Project tag: `{prefix}_project_{hash(directory)}`
242252

@@ -248,11 +258,12 @@ You can override this by specifying exact container tags:
248258
"userContainerTag": "my-team-workspace",
249259

250260
// Use a specific container tag for project memories
251-
"projectContainerTag": "my-awesome-project"
261+
"projectContainerTag": "my-awesome-project",
252262
}
253263
```
254264

255265
This is useful when you want to:
266+
256267
- Share memories across team members (same `userContainerTag`)
257268
- Sync memories between different machines for the same project
258269
- Organize memories using your own naming scheme
@@ -282,7 +293,7 @@ Local install:
282293

283294
```jsonc
284295
{
285-
"plugin": ["file:///path/to/opencode-supermemory"]
296+
"plugin": ["file:///path/to/opencode-supermemory"],
286297
}
287298
```
288299

src/cli.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,24 @@ This will:
182182
183183
Wait for the command to complete, then inform the user whether authentication succeeded or failed.
184184
185-
If the user wants to log out instead, run:
185+
If the user wants to log out instead, tell them to use the /supermemory-logout command.
186+
`;
187+
188+
const SUPERMEMORY_LOGOUT_COMMAND = `---
189+
description: Log out from Supermemory and clear credentials
190+
---
191+
192+
# Supermemory Logout
193+
194+
Run this command to log out and clear Supermemory credentials:
195+
186196
\`\`\`bash
187197
bunx opencode-supermemory@latest logout
188198
\`\`\`
199+
200+
This will remove the saved credentials from ~/.supermemory-opencode/credentials.json.
201+
202+
Inform the user whether logout succeeded and that they'll need to run /supermemory-login to re-authenticate.
189203
`;
190204

191205
function createReadline(): readline.Interface {
@@ -298,6 +312,10 @@ function createCommands(): boolean {
298312
writeFileSync(loginPath, SUPERMEMORY_LOGIN_COMMAND);
299313
console.log(`✓ Created /supermemory-login command`);
300314

315+
const logoutPath = join(OPENCODE_COMMAND_DIR, "supermemory-logout.md");
316+
writeFileSync(logoutPath, SUPERMEMORY_LOGOUT_COMMAND);
317+
console.log(`✓ Created /supermemory-logout command`);
318+
301319
return true;
302320
}
303321

@@ -389,7 +407,7 @@ async function install(options: InstallOptions): Promise<number> {
389407
}
390408

391409
// Step 2: Create commands
392-
console.log("\nStep 2: Create /supermemory-init and /supermemory-login commands");
410+
console.log("\nStep 2: Create /supermemory-init, /supermemory-login, and /supermemory-logout commands");
393411
if (options.tui) {
394412
const shouldCreate = await confirm(rl!, "Add supermemory commands?");
395413
if (!shouldCreate) {

src/services/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { homedir } from "node:os";
77
const CREDENTIALS_DIR = join(homedir(), ".supermemory-opencode");
88
const CREDENTIALS_FILE = join(CREDENTIALS_DIR, "credentials.json");
99
const AUTH_PORT = 19877;
10-
const AUTH_BASE_URL = "https://console.supermemory.ai/auth/connect";
10+
const AUTH_BASE_URL = process.env.SUPERMEMORY_AUTH_URL || "https://app.supermemory.ai/auth/connect";
1111
const CLIENT_NAME = "opencode";
1212

1313
interface Credentials {

0 commit comments

Comments
 (0)