Skip to content

Commit bb1803f

Browse files
feat: add ability to select exact containerTag
Users can now specify exact containerTag values via config options: - userContainerTag: Override auto-generated user tag - projectContainerTag: Override auto-generated project tag This allows users to: - Share memories across team members - Sync memories between different machines - Use custom naming schemes - Integrate with existing Supermemory container tags Maintains backward compatibility with containerTagPrefix. Closes #22 Co-authored-by: Dhravya Shah <Dhravya@users.noreply.github.com>
1 parent 0a8e88c commit bb1803f

File tree

3 files changed

+56
-10
lines changed

3 files changed

+56
-10
lines changed

README.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,35 +199,65 @@ Create `~/.config/opencode/supermemory.jsonc`:
199199
{
200200
// API key (can also use SUPERMEMORY_API_KEY env var)
201201
"apiKey": "sm_...",
202-
202+
203203
// Min similarity for memory retrieval (0-1)
204204
"similarityThreshold": 0.6,
205-
205+
206206
// Max memories injected per request
207207
"maxMemories": 5,
208-
208+
209209
// Max project memories listed
210210
"maxProjectMemories": 10,
211-
211+
212212
// Max profile facts injected
213213
"maxProfileItems": 5,
214-
214+
215215
// Include user profile in context
216216
"injectProfile": true,
217-
218-
// Prefix for container tags
217+
218+
// Prefix for container tags (used when userContainerTag/projectContainerTag not set)
219219
"containerTagPrefix": "opencode",
220-
220+
221+
// Optional: Set exact user container tag (overrides auto-generated tag)
222+
"userContainerTag": "my-custom-user-tag",
223+
224+
// Optional: Set exact project container tag (overrides auto-generated tag)
225+
"projectContainerTag": "my-project-tag",
226+
221227
// Extra keyword patterns for memory detection (regex)
222228
"keywordPatterns": ["log\\s+this", "write\\s+down"],
223-
229+
224230
// Context usage ratio that triggers compaction (0-1)
225231
"compactionThreshold": 0.80
226232
}
227233
```
228234

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

237+
### Container Tag Selection
238+
239+
By default, container tags are auto-generated using `containerTagPrefix` plus a hash:
240+
- User tag: `{prefix}_user_{hash(git_email)}`
241+
- Project tag: `{prefix}_project_{hash(directory)}`
242+
243+
You can override this by specifying exact container tags:
244+
245+
```jsonc
246+
{
247+
// Use a specific container tag for user memories
248+
"userContainerTag": "my-team-workspace",
249+
250+
// Use a specific container tag for project memories
251+
"projectContainerTag": "my-awesome-project"
252+
}
253+
```
254+
255+
This is useful when you want to:
256+
- Share memories across team members (same `userContainerTag`)
257+
- Sync memories between different machines for the same project
258+
- Organize memories using your own naming scheme
259+
- Integrate with existing Supermemory container tags from other tools
260+
231261
## Usage with Oh My OpenCode
232262

233263
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:

src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface SupermemoryConfig {
1818
maxProfileItems?: number;
1919
injectProfile?: boolean;
2020
containerTagPrefix?: string;
21+
userContainerTag?: string;
22+
projectContainerTag?: string;
2123
filterPrompt?: string;
2224
keywordPatterns?: string[];
2325
compactionThreshold?: number;
@@ -42,7 +44,7 @@ const DEFAULT_KEYWORD_PATTERNS = [
4244
"always\\s+remember",
4345
];
4446

45-
const DEFAULTS: Required<Omit<SupermemoryConfig, "apiKey">> = {
47+
const DEFAULTS: Required<Omit<SupermemoryConfig, "apiKey" | "userContainerTag" | "projectContainerTag">> = {
4648
similarityThreshold: 0.6,
4749
maxMemories: 5,
4850
maxProjectMemories: 10,
@@ -104,6 +106,8 @@ export const CONFIG = {
104106
maxProfileItems: fileConfig.maxProfileItems ?? DEFAULTS.maxProfileItems,
105107
injectProfile: fileConfig.injectProfile ?? DEFAULTS.injectProfile,
106108
containerTagPrefix: fileConfig.containerTagPrefix ?? DEFAULTS.containerTagPrefix,
109+
userContainerTag: fileConfig.userContainerTag,
110+
projectContainerTag: fileConfig.projectContainerTag,
107111
filterPrompt: fileConfig.filterPrompt ?? DEFAULTS.filterPrompt,
108112
keywordPatterns: [
109113
...DEFAULT_KEYWORD_PATTERNS,

src/services/tags.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export function getGitEmail(): string | null {
1616
}
1717

1818
export function getUserTag(): string {
19+
// If userContainerTag is explicitly set, use it
20+
if (CONFIG.userContainerTag) {
21+
return CONFIG.userContainerTag;
22+
}
23+
24+
// Otherwise, auto-generate based on containerTagPrefix
1925
const email = getGitEmail();
2026
if (email) {
2127
return `${CONFIG.containerTagPrefix}_user_${sha256(email)}`;
@@ -25,6 +31,12 @@ export function getUserTag(): string {
2531
}
2632

2733
export function getProjectTag(directory: string): string {
34+
// If projectContainerTag is explicitly set, use it
35+
if (CONFIG.projectContainerTag) {
36+
return CONFIG.projectContainerTag;
37+
}
38+
39+
// Otherwise, auto-generate based on containerTagPrefix
2840
return `${CONFIG.containerTagPrefix}_project_${sha256(directory)}`;
2941
}
3042

0 commit comments

Comments
 (0)