Skip to content
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "claude-supermemory-dev",
"version": "0.0.9",
"version": "0.0.10",
"description": "Claude code plugin by Supermemory AI",
"private": true,
"type": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion plugin/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "supermemory",
"displayName": "Supermemory",
"version": "0.0.9",
"version": "0.0.10",
"description": "Persistent memory across Claude Code sessions using Supermemory",
"author": {
"name": "Supermemory",
Expand Down
4 changes: 2 additions & 2 deletions plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "claude-supermemory",
"version": "0.0.9",
"version": "0.0.10",
"description": "Persistent memory for Claude Code using Supermemory",
"private": true,
"engines": {
Expand Down
12 changes: 6 additions & 6 deletions plugin/scripts/add-memory.cjs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions plugin/scripts/context-hook.cjs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions plugin/scripts/save-project-memory.cjs

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions plugin/scripts/search-memory.cjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugin/scripts/status.cjs

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions plugin/scripts/summary-hook.cjs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/add-memory.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const {
SupermemoryClient,
PERSONAL_ENTITY_CONTEXT,
REPO_ENTITY_CONTEXT,
} = require('./lib/supermemory-client');
const { getContainerTag, getProjectName } = require('./lib/container-tag');
const { getRepoContainerTag, getProjectName } = require('./lib/container-tag');
const { loadProjectConfig } = require('./lib/project-config');
const { loadSettings, getApiKey, getBaseUrl } = require('./lib/settings');
const { getUserFriendlyError } = require('./lib/error-helpers');
Expand Down Expand Up @@ -30,7 +30,7 @@ async function main() {
return;
}

const containerTag = getContainerTag(cwd);
const containerTag = getRepoContainerTag(cwd);
const projectName = getProjectName(cwd);

try {
Expand All @@ -44,7 +44,7 @@ async function main() {
project: projectName,
timestamp: new Date().toISOString(),
},
{ entityContext: PERSONAL_ENTITY_CONTEXT },
{ entityContext: REPO_ENTITY_CONTEXT },
);

console.log(`Memory saved to project: ${projectName}`);
Expand Down
4 changes: 3 additions & 1 deletion src/context-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ Or set SUPERMEMORY_CC_API_KEY environment variable manually.
);

const additionalContext = combineContexts([
{ label: '### Personal Memories', content: personalContext },
...(personalContext
? [{ label: '### Legacy Session Memories', content: personalContext }]
: []),
{
label: '### Project Knowledge (Shared across team)',
content: repoContext,
Expand Down
10 changes: 10 additions & 0 deletions src/lib/container-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ function getRepoContainerTag(cwd) {
return `repo_${sanitizeRepoName(repoName)}`;
}

function getRepoSearchTags(cwd) {
const repoTag = getRepoContainerTag(cwd);
const legacySessionTag = getContainerTag(cwd);
if (repoTag === legacySessionTag) {
return [repoTag];
}
return [repoTag, legacySessionTag];
}

function getProjectName(cwd) {
const gitRoot = getGitRoot(cwd);
const basePath = gitRoot || cwd;
Expand All @@ -74,5 +83,6 @@ module.exports = {
getGitRepoName,
getContainerTag,
getRepoContainerTag,
getRepoSearchTags,
getProjectName,
};
2 changes: 1 addition & 1 deletion src/lib/plugin-version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const PLUGIN_VERSION = '0.0.9';
const PLUGIN_VERSION = '0.0.10';

module.exports = { PLUGIN_VERSION };
40 changes: 22 additions & 18 deletions src/search-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
getProjectName,
getContainerTag,
getRepoContainerTag,
getRepoSearchTags,
} = require('./lib/container-tag');
const { loadProjectConfig } = require('./lib/project-config');
const { loadSettings, getApiKey, getBaseUrl } = require('./lib/settings');
Expand Down Expand Up @@ -55,36 +56,39 @@ async function main() {
}

const projectName = getProjectName(cwd);
const personalTag = getContainerTag(cwd);
const legacySessionTag = getContainerTag(cwd);
const repoTag = getRepoContainerTag(cwd);
const repoSearchTags = getRepoSearchTags(cwd);

try {
const baseUrl = getBaseUrl(cwd, projectConfig);
const client = new SupermemoryClient(apiKey, personalTag, { baseUrl });
const client = new SupermemoryClient(apiKey, repoTag, { baseUrl });

console.log(`Project: ${projectName}\n`);

if (containerType === 'both') {
const [personalResult, repoResult] = await Promise.all([
client.search(query, personalTag, { limit: 5 }),
client.search(query, repoTag, { limit: 5 }),
]);
const searchResults = await Promise.all(
repoSearchTags.map((tag) => client.search(query, tag, { limit: 5 })),
);

if (personalResult.results?.length > 0) {
console.log(
formatSearchResults(query, personalResult.results, 'Personal'),
);
}
if (repoResult.results?.length > 0) {
if (personalResult.results?.length > 0) console.log('');
console.log(formatSearchResults(query, repoResult.results, 'Project'));
}
if (!personalResult.results?.length && !repoResult.results?.length) {
let foundAny = false;
searchResults.forEach((searchResult, index) => {
if (!searchResult.results?.length) return;
foundAny = true;
if (index > 0) console.log('');
const label =
repoSearchTags[index] === legacySessionTag
? 'Legacy Session'
: 'Project';
console.log(formatSearchResults(query, searchResult.results, label));
});

if (!foundAny) {
console.log(`No memories found for "${query}"`);
}
} else {
const tag = containerType === 'user' ? personalTag : repoTag;
const label = containerType === 'user' ? 'Personal' : 'Project';
const tag = containerType === 'user' ? legacySessionTag : repoTag;
const label = containerType === 'user' ? 'Legacy Session' : 'Project';
const searchResult = await client.search(query, tag, { limit: 10 });
console.log(formatSearchResults(query, searchResult.results, label));
}
Expand Down
8 changes: 4 additions & 4 deletions src/summary-hook.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const {
SupermemoryClient,
PERSONAL_ENTITY_CONTEXT,
REPO_ENTITY_CONTEXT,
} = require('./lib/supermemory-client');
const { getContainerTag, getProjectName } = require('./lib/container-tag');
const { getRepoContainerTag, getProjectName } = require('./lib/container-tag');
const { loadProjectConfig } = require('./lib/project-config');
const {
loadSettings,
Expand Down Expand Up @@ -68,7 +68,7 @@ async function main() {

const baseUrl = getBaseUrl(cwd, projectConfig);
const client = new SupermemoryClient(apiKey, undefined, { baseUrl });
const containerTag = getContainerTag(cwd);
const containerTag = getRepoContainerTag(cwd);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include full repo identity before routing autosaves

When repoContainerTag is not configured, getRepoContainerTag() derives the tag from only the repository basename (for example both github.com/acme/api.git and github.com/personal/api.git become repo_api). Routing automatic session summaries through that tag means unrelated repos or forks with the same name under the same Supermemory account will mix recalled context and saved session data; the previous autosave path used a hashed project path and did not have this collision. Consider including the remote owner/full URL or another stable hash in the default repo tag.

Useful? React with 👍 / 👎.

const projectName = getProjectName(cwd);

const result = await client.addMemory(
Expand All @@ -79,7 +79,7 @@ async function main() {
project: projectName,
timestamp: new Date().toISOString(),
},
{ customId: sessionId, entityContext: PERSONAL_ENTITY_CONTEXT },
{ customId: sessionId, entityContext: REPO_ENTITY_CONTEXT },
);

if (result?.id) {
Expand Down
Loading