@z-test/memory-bank-mcp
Version:
MCP Server for managing Memory Bank
243 lines (242 loc) • 8.13 kB
TypeScript
import { ProgressTracker } from './ProgressTracker.js';
import { ModeManager } from '../utils/ModeManager.js';
import { MemoryBankStatus } from '../types/index.js';
import { StorageProvider } from './storage/StorageProvider.js';
/**
* Class responsible for managing Memory Bank operations
*
* This class handles all operations related to Memory Bank directories,
* including initialization, file operations, and status tracking.
*/
export declare class MemoryBankManager {
private memoryBankDir;
private customPath;
private progressTracker;
private modeManager;
private rulesLoader;
private projectPath;
private userId;
private folderName;
private storageProvider;
private language;
/**
* Creates a new MemoryBankManager instance
*
* @param projectPath Optional project path to use instead of current directory
* @param userId Optional GitHub profile URL for tracking changes
* @param folderName Optional folder name for the Memory Bank (default: 'memory-bank')
* @param debugMode Optional flag to enable debug mode
* @param storageProvider Optional storage provider to use instead of direct file system operations
*/
constructor(projectPath?: string, userId?: string, folderName?: string, debugMode?: boolean, storageProvider?: StorageProvider);
/**
* Gets the language used for the Memory Bank
*
* @returns The language code (always 'en' for English)
*/
getLanguage(): string;
/**
* Sets the language for the Memory Bank
*
* Note: This method is provided for API consistency, but the Memory Bank
* will always use English (en) regardless of the language parameter.
* This is a deliberate design decision to ensure consistency across all Memory Banks.
*
* @param language - Language code (ignored, always sets to 'en')
*/
setLanguage(_language: string): void;
/**
* Gets the project path
*
* @returns The project path
*/
getProjectPath(): string;
/**
* Finds a Memory Bank directory in the provided directory
*
* Combines the provided directory with the folder name to create the Memory Bank path.
*
* @param startDir - Starting directory for the search
* @param _customPath - Optional custom path (ignored in this implementation)
* @returns Path to the Memory Bank directory or null if not found
*/
findMemoryBankDir(startDir: string, _customPath?: string): Promise<string | null>;
/**
* Checks if a directory is a valid Memory Bank
*
* @param dirPath - Directory path to check
* @returns True if it's a valid Memory Bank, false otherwise
*/
isMemoryBank(dirPath: string): Promise<boolean>;
/**
* Validates if all required .clinerules files exist in the project root
*
* @param projectDir - Project directory to check
* @returns Object with validation results
*/
validateClinerules(projectDir: string): Promise<{
valid: boolean;
missingFiles: string[];
existingFiles: string[];
}>;
/**
* Initializes a Memory Bank in the specified directory
*
* Creates the necessary directory structure and files for a Memory Bank.
*
* @param dirPath - Directory path to initialize
* @throws Error if initialization fails
*/
initializeMemoryBank(dirPath: string): Promise<void>;
/**
* Reads a file from the Memory Bank
*
* @param filename - Name of the file to read
* @returns Content of the file
* @throws Error if the Memory Bank directory is not set or the file doesn't exist
*/
readFile(filename: string): Promise<string>;
/**
* Writes content to a file in the Memory Bank
*
* @param filename - Name of the file to write
* @param content - Content to write
* @throws Error if the Memory Bank directory is not set
*/
writeFile(filename: string, content: string): Promise<void>;
/**
* Lists files in the Memory Bank
*
* @returns List of files
* @throws Error if the Memory Bank directory is not set
*/
listFiles(): Promise<string[]>;
/**
* Gets the status of the Memory Bank
*
* @returns Status object with information about the Memory Bank
* @throws Error if the Memory Bank directory is not set
*/
getStatus(): Promise<MemoryBankStatus>;
/**
* Sets a custom path for the Memory Bank
*
* This will set the custom path and check if a valid Memory Bank
* exists in that path. If it exists, it will set the Memory Bank directory.
*
* @param _customPath - Custom path (optional)
*/
setCustomPath(_customPath?: string): Promise<void>;
/**
* Gets the custom path for the Memory Bank
*
* @returns Custom path or null if not set
*/
getCustomPath(): string | null;
/**
* Gets the Memory Bank directory
*
* @returns Memory Bank directory or null if not set
*/
getMemoryBankDir(): string | null;
/**
* Sets the Memory Bank directory
*
* @param dir - Directory path
*/
setMemoryBankDir(dir: string): void;
/**
* Gets the ProgressTracker
*
* @returns ProgressTracker or null if not available
*/
getProgressTracker(): ProgressTracker | null;
/**
* Creates a backup of the Memory Bank
*
* @param backupDir - Directory where the backup will be stored
* @returns Path to the backup directory
* @throws Error if the Memory Bank directory is not set or backup fails
*/
createBackup(backupDir?: string): Promise<string>;
/**
* Initializes the mode manager
*
* @param initialMode Initial mode to set (optional)
* @returns Promise that resolves when initialization is complete
*/
initializeModeManager(initialMode?: string): Promise<void>;
/**
* Gets the mode manager
*
* @returns Mode manager or null if not initialized
*/
getModeManager(): ModeManager | null;
/**
* Updates the Memory Bank status in the mode manager
*/
updateMemoryBankStatus(): Promise<void>;
/**
* Gets the status prefix for responses
* @returns Status prefix
*/
getStatusPrefix(): string;
/**
* Checks if a text matches the UMB trigger
* @param text Text to be checked
* @returns true if the text matches the UMB trigger, false otherwise
*/
checkUmbTrigger(text: string): boolean;
/**
* Activates UMB mode
*
* @returns true if UMB mode was activated, false otherwise
*/
activateUmbMode(): boolean;
/**
* Deactivates UMB mode
*
* @returns true if UMB mode was deactivated, false otherwise
*/
completeUmbMode(): Promise<boolean>;
/**
* Checks if UMB mode is active
* @returns true if UMB mode is active, false otherwise
*/
isUmbModeActive(): boolean;
/**
* Alterna para um modo específico
* @param mode Nome do modo
* @returns true se a mudança foi bem-sucedida, false caso contrário
*/
switchMode(mode: string): boolean;
/**
* Checks if a text matches any mode trigger
* @param text Text to be checked
* @returns Array with modes corresponding to the triggers found
*/
checkModeTriggers(text: string): string[];
/**
* Detects mode triggers in a message
* @param message Message to check for triggers
* @returns Array with modes corresponding to the triggers found
*/
detectModeTriggers(message: string): string[];
/**
* Gets the folder name used for the Memory Bank
*
* @returns The folder name
*/
getFolderName(): string;
/**
* Migrates Memory Bank files from camelCase to kebab-case naming convention
*
* @returns Object with migration results
* @throws Error if Memory Bank directory is not set
*/
migrateFileNaming(): Promise<{
success: boolean;
migrated: string[];
errors: string[];
}>;
}