diff --git a/package-lock.json b/package-lock.json index 30e179a..5f638cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "simple-memory-mcp", - "version": "1.0.16", + "version": "1.0.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "simple-memory-mcp", - "version": "1.0.16", + "version": "1.0.19", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.17.3", diff --git a/src/tests/memory-server-tests.ts b/src/tests/memory-server-tests.ts index 4575593..ece7999 100644 --- a/src/tests/memory-server-tests.ts +++ b/src/tests/memory-server-tests.ts @@ -457,8 +457,8 @@ async function testUpdateMemoryTags(): Promise { const hash = storeOutput.hash; - // Update tags only (keep same content) - const updateResult = await executeCommand(['update-memory', '--hash', hash, '--content', 'TypeScript configuration notes', '--tags', 'typescript,config,complete']); + // Update tags only (WITHOUT providing content - the new feature!) + const updateResult = await executeCommand(['update-memory', '--hash', hash, '--tags', 'typescript,config,complete']); if (updateResult.exitCode !== 0) { throw new Error(`Tag update failed: ${updateResult.stderr}`); @@ -469,7 +469,7 @@ async function testUpdateMemoryTags(): Promise { throw new Error('Tag update did not indicate tags were updated'); } - console.log(`✓ Updated tags successfully`); + console.log(`✓ Updated tags successfully without providing content`); // Verify new tags by searching const searchResult = await executeCommand(['search-memory', '--tags', 'config']); @@ -488,7 +488,12 @@ async function testUpdateMemoryTags(): Promise { throw new Error('Tags were not properly updated'); } - console.log(`✓ Verified tags were updated correctly`); + // Verify content remained unchanged + if (foundMemory.content !== 'TypeScript configuration notes') { + throw new Error('Content was changed when it should have remained the same'); + } + + console.log(`✓ Verified tags were updated and content remained unchanged`); } /** diff --git a/src/tools/update-memory/executor.ts b/src/tools/update-memory/executor.ts index d53cc71..d372d95 100644 --- a/src/tools/update-memory/executor.ts +++ b/src/tools/update-memory/executor.ts @@ -3,7 +3,7 @@ import { debugLog, formatHash } from '../../utils/debug.js'; interface UpdateMemoryArgs { hash: string; - content: string; + content?: string; tags?: string[]; } @@ -22,16 +22,6 @@ export async function execute(args: UpdateMemoryArgs, context: ToolContext): Pro throw new Error('Hash cannot be empty'); } - if (!args.content || args.content.trim().length === 0) { - throw new Error('Content cannot be empty'); - } - - // Log content size for large memories - const contentSize = args.content.length; - if (contentSize > 100000) { - debugLog(`Updating with large content: ${contentSize} characters`); - } - // Check if memory exists before updating const existing = context.memoryService.getByHash(args.hash); if (!existing) { @@ -41,8 +31,22 @@ export async function execute(args: UpdateMemoryArgs, context: ToolContext): Pro }; } + // Use existing content if not provided (tags-only update) + const newContent = args.content !== undefined ? args.content : existing.content; + + // Validate content is not empty + if (!newContent || newContent.trim().length === 0) { + throw new Error('Content cannot be empty'); + } + + // Log content size for large memories + const contentSize = newContent.length; + if (contentSize > 100000) { + debugLog(`Updating with large content: ${contentSize} characters`); + } + // Perform the update - const newHash = context.memoryService.update(args.hash, args.content, args.tags); + const newHash = context.memoryService.update(args.hash, newContent, args.tags); if (!newHash) { return { @@ -53,6 +57,7 @@ export async function execute(args: UpdateMemoryArgs, context: ToolContext): Pro const hashChanged = newHash !== args.hash; const tagsUpdated = args.tags !== undefined; + const contentUpdated = args.content !== undefined; let message = `Memory updated successfully.`; if (hashChanged) { @@ -60,8 +65,10 @@ export async function execute(args: UpdateMemoryArgs, context: ToolContext): Pro } else { message += ` Hash unchanged: ${formatHash(newHash)}...`; } - if (tagsUpdated) { - message += ` (tags updated)`; + if (tagsUpdated && !contentUpdated) { + message += ` (tags updated only)`; + } else if (tagsUpdated) { + message += ` (content and tags updated)`; } return { diff --git a/src/tools/update-memory/index.ts b/src/tools/update-memory/index.ts index 9b1ccd0..70ebc11 100644 --- a/src/tools/update-memory/index.ts +++ b/src/tools/update-memory/index.ts @@ -5,7 +5,7 @@ import { parseCliArgs } from './cli-parser.js'; export const updateMemoryTool: Tool = { definition: { name: 'update-memory', - description: 'Update an existing memory with new content and/or tags. The hash will change if content changes. If tags are provided, they replace all existing tags; if omitted, existing tags are preserved.', + description: 'Update an existing memory with new content and/or tags. The hash will change if content changes. If tags are provided, they replace all existing tags; if omitted, existing tags are preserved. If content is omitted, only tags are updated.', inputSchema: { type: 'object', properties: { @@ -15,7 +15,7 @@ export const updateMemoryTool: Tool = { }, content: { type: 'string', - description: 'The new content for the memory' + description: 'The new content for the memory (optional - if omitted, content remains unchanged)' }, tags: { type: 'array', @@ -23,7 +23,7 @@ export const updateMemoryTool: Tool = { description: 'New tags to replace existing tags (optional - if omitted, existing tags are preserved)' } }, - required: ['hash', 'content'] + required: ['hash'] } }, handler: execute,