-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Problem Description
The current configuration system has a design flaw, as it cannot synchronize memories for specific projects across multiple devices while preventing the mixing of memories from different projects.
Current Behavior
Refer to src/config.ts; the configuration system only supports a single global configuration file:
~/.config/opencode/supermemory.jsonc~/.config/opencode/supermemory.json
In src/services/tags.ts#L33-L41, the project tag generation logic is as follows:
export function getProjectTag(directory: string): string {
// If projectContainerTag is set, all projects use it
if (CONFIG.projectContainerTag) {
return CONFIG.projectContainerTag;
}
// Otherwise, generate using the hash of the directory path
return `${CONFIG.containerTagPrefix}_project_${sha256(directory)}`;
}Problem Scenarios
I have the following usage scenarios:
- Device A has multiple projects:
project1,project2,project3 - Device B has multiple projects:
project1,project4,project5 - I want the memories of
project1to be synchronized between Device A and B - However, the memories of
project2,project3,project4, andproject5should remain independent
Contradictions in the Current Design
| Configuration Method | Result |
|---|---|
Not setting projectContainerTag |
Different project paths on different devices → different hashes → unable to synchronize ❌ |
Setting projectContainerTag |
All projects share the same tag → memory confusion ❌ |
Root Cause
Project tags are generated using directory paths instead of unique project identifiers, leading to:
- Tags change when paths change
- Inability to specify synchronization tags for specific projects
- Global configuration cannot support different configurations for multiple projects
Proposed Solutions
Solution 1: Use Git Remote URL as the project identifier (Recommended)
Modify src/services/tags.ts#L33-L41 to prioritize using the git remote URL:
export function getProjectTag(directory: string): string {
if (CONFIG.projectContainerTag) {
return CONFIG.projectContainerTag;
}
// Prioritize using git remote URL as the unique project identifier
try {
const remoteUrl = execSync("git config --get remote.origin.url", {
cwd: directory,
encoding: "utf-8"
}).trim();
if (remoteUrl) {
return `${CONFIG.containerTagPrefix}_project_${sha256(remoteUrl)}`;
}
} catch {}
// Fall back to directory path
return `${CONFIG.containerTagPrefix}_project_${sha256(directory)}`;
}Advantages:
- Transparent to users, no configuration changes required
- Automatic synchronization for the same repository
- Automatic isolation for different repositories
Solution 2: Support project-level configuration files
Support reading .opencode-supermemory.jsonc in the project root directory, allowing individual settings of projectContainerTag for each project.
Modifications to src/config.ts are required to implement multi-level configuration overriding.