Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,35 +199,65 @@ Create `~/.config/opencode/supermemory.jsonc`:
{
// API key (can also use SUPERMEMORY_API_KEY env var)
"apiKey": "sm_...",

// Min similarity for memory retrieval (0-1)
"similarityThreshold": 0.6,

// Max memories injected per request
"maxMemories": 5,

// Max project memories listed
"maxProjectMemories": 10,

// Max profile facts injected
"maxProfileItems": 5,

// Include user profile in context
"injectProfile": true,
// Prefix for container tags

// Prefix for container tags (used when userContainerTag/projectContainerTag not set)
"containerTagPrefix": "opencode",


// Optional: Set exact user container tag (overrides auto-generated tag)
"userContainerTag": "my-custom-user-tag",

// Optional: Set exact project container tag (overrides auto-generated tag)
"projectContainerTag": "my-project-tag",

// Extra keyword patterns for memory detection (regex)
"keywordPatterns": ["log\\s+this", "write\\s+down"],

// Context usage ratio that triggers compaction (0-1)
"compactionThreshold": 0.80
}
```

All fields optional. Env var `SUPERMEMORY_API_KEY` takes precedence over config file.

### Container Tag Selection

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

You can override this by specifying exact container tags:

```jsonc
{
// Use a specific container tag for user memories
"userContainerTag": "my-team-workspace",

// Use a specific container tag for project memories
"projectContainerTag": "my-awesome-project"
}
```

This is useful when you want to:
- Share memories across team members (same `userContainerTag`)
- Sync memories between different machines for the same project
- Organize memories using your own naming scheme
- Integrate with existing Supermemory container tags from other tools

## Usage with Oh My OpenCode

If you're using [Oh My OpenCode](https://github.com/code-yeongyu/oh-my-opencode), disable its built-in auto-compact hook to let supermemory handle context compaction:
Expand Down
6 changes: 5 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface SupermemoryConfig {
maxProfileItems?: number;
injectProfile?: boolean;
containerTagPrefix?: string;
userContainerTag?: string;
projectContainerTag?: string;
filterPrompt?: string;
keywordPatterns?: string[];
compactionThreshold?: number;
Expand All @@ -42,7 +44,7 @@ const DEFAULT_KEYWORD_PATTERNS = [
"always\\s+remember",
];

const DEFAULTS: Required<Omit<SupermemoryConfig, "apiKey">> = {
const DEFAULTS: Required<Omit<SupermemoryConfig, "apiKey" | "userContainerTag" | "projectContainerTag">> = {
similarityThreshold: 0.6,
maxMemories: 5,
maxProjectMemories: 10,
Expand Down Expand Up @@ -104,6 +106,8 @@ export const CONFIG = {
maxProfileItems: fileConfig.maxProfileItems ?? DEFAULTS.maxProfileItems,
injectProfile: fileConfig.injectProfile ?? DEFAULTS.injectProfile,
containerTagPrefix: fileConfig.containerTagPrefix ?? DEFAULTS.containerTagPrefix,
userContainerTag: fileConfig.userContainerTag,
projectContainerTag: fileConfig.projectContainerTag,
filterPrompt: fileConfig.filterPrompt ?? DEFAULTS.filterPrompt,
keywordPatterns: [
...DEFAULT_KEYWORD_PATTERNS,
Expand Down
12 changes: 12 additions & 0 deletions src/services/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export function getGitEmail(): string | null {
}

export function getUserTag(): string {
// If userContainerTag is explicitly set, use it
if (CONFIG.userContainerTag) {
return CONFIG.userContainerTag;
}

// Otherwise, auto-generate based on containerTagPrefix
const email = getGitEmail();
if (email) {
return `${CONFIG.containerTagPrefix}_user_${sha256(email)}`;
Expand All @@ -25,6 +31,12 @@ export function getUserTag(): string {
}

export function getProjectTag(directory: string): string {
// If projectContainerTag is explicitly set, use it
if (CONFIG.projectContainerTag) {
return CONFIG.projectContainerTag;
}

// Otherwise, auto-generate based on containerTagPrefix
return `${CONFIG.containerTagPrefix}_project_${sha256(directory)}`;
}

Expand Down