Skip to content

Is the logic of the current configuration file unable to achieve synchronization of specific project memory across multiple devices? #38

@Long-louis

Description

@Long-louis

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 project1 to be synchronized between Device A and B
  • However, the memories of project2, project3, project4, and project5 should 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:

  1. Tags change when paths change
  2. Inability to specify synchronization tags for specific projects
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions