migrate_file_naming
Convert Memory Bank file names from camelCase to kebab-case using the MCP server with SSH support for efficient file system standardization.
Instructions
Migrate Memory Bank files from camelCase to kebab-case naming convention
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes | Dummy parameter for no-parameter tools |
Implementation Reference
- src/server/tools/CoreTools.ts:421-456 (handler)Main handler function for the 'migrate_file_naming' tool. It validates the memory bank directory existence, calls the migration method on MemoryBankManager, and formats the response.export async function handleMigrateFileNaming( memoryBankManager: MemoryBankManager ) { try { if (!memoryBankManager.getMemoryBankDir()) { return { content: [ { type: "text", text: 'Memory Bank directory not found. Use initialize_memory_bank or set_memory_bank_path first.', }, ], }; } const result = await memoryBankManager.migrateFileNaming(); return { content: [ { type: "text", text: `Migration completed. ${result.migrated.length} files migrated.`, }, ], }; } catch (error) { console.error("Error in handleMigrateFileNaming:", error); return { content: [ { type: "text", text: `Error migrating file naming: ${error}`, }, ], }; } }
- Tool schema definition including name, description, and input schema (dummy param for no-args tool).{ name: 'migrate_file_naming', description: 'Migrate Memory Bank files from camelCase to kebab-case naming convention', inputSchema: { type: 'object', properties: { random_string: { type: 'string', description: 'Dummy parameter for no-parameter tools', }, }, required: ['random_string'], }, },
- src/server/tools/index.ts:160-162 (registration)Dispatch case in the main tool call handler that routes 'migrate_file_naming' calls to the specific handler.case 'migrate_file_naming': { return handleMigrateFileNaming(memoryBankManager); }
- src/server/tools/index.ts:30-38 (registration)MCP server registration for listing tools, which includes the coreTools array containing 'migrate_file_naming'.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ ...coreTools, ...progressTools, ...contextTools, ...decisionTools, ...modeTools, ], }));
- src/utils/MigrationUtils.ts:14-72 (helper)Supporting utility that performs the actual file renaming from camelCase (e.g., productContext.md) to kebab-case (product-context.md). Called indirectly via MemoryBankManager.static async migrateFileNamingConvention(memoryBankDir: string): Promise<{ success: boolean; migratedFiles: string[]; errors: string[]; }> { const result = { success: true, migratedFiles: [] as string[], errors: [] as string[], }; // File mapping from old to new naming convention const fileMapping = [ { oldName: 'productContext.md', newName: 'product-context.md' }, { oldName: 'activeContext.md', newName: 'active-context.md' }, { oldName: 'decisionLog.md', newName: 'decision-log.md' }, { oldName: 'systemPatterns.md', newName: 'system-patterns.md' }, ]; // Check if directory exists if (!(await FileUtils.fileExists(memoryBankDir)) || !(await FileUtils.isDirectory(memoryBankDir))) { result.success = false; result.errors.push(`Memory Bank directory not found: ${memoryBankDir}`); return result; } // Process each file for (const mapping of fileMapping) { const oldPath = path.join(memoryBankDir, mapping.oldName); const newPath = path.join(memoryBankDir, mapping.newName); try { // Check if old file exists if (await FileUtils.fileExists(oldPath)) { // Check if new file already exists if (await FileUtils.fileExists(newPath)) { result.errors.push(`Target file already exists: ${mapping.newName}`); continue; } // Read content from old file const content = await FileUtils.readFile(oldPath); // Write content to new file await FileUtils.writeFile(newPath, content); // Delete old file await FileUtils.deleteFile(oldPath); result.migratedFiles.push(mapping.oldName); } } catch (error) { result.success = false; result.errors.push(`Error migrating ${mapping.oldName}: ${error}`); } } return result; }