UNPKG

@z-test/memory-bank-mcp

Version:
79 lines (78 loc) 2.46 kB
import { EventEmitter } from 'events'; import { ClineruleBase as ClineruleBaseType } from '../types/rules.js'; import { ValidationResult } from '../types/index.js'; export interface ClineruleBase { mode: string; rules: Record<string, unknown>; } /** * Class responsible for loading and monitoring external .clinerules files */ export declare class ExternalRulesLoader extends EventEmitter { private projectDir; private rules; private watchers; /** * Creates a new instance of the external rules loader * @param projectDir Project directory (default: current directory) */ constructor(projectDir?: string); /** * Gets a writable directory for storing .clinerules files * Uses only the specified project directory without fallbacks * @returns A writable directory path */ private getWritableDirectory; /** * Validates that all required .clinerules files exist * @returns Validation result with missing and existing files */ validateRequiredFiles(): Promise<ValidationResult>; /** * Detects and loads all .clinerules files in the project directory */ detectAndLoadRules(): Promise<Map<string, ClineruleBaseType>>; /** * Parses the content of a rule file * @param content File content * @returns Parsed rule object or null if invalid */ private parseRuleContent; /** * Sets up a watcher for a rule file * @param filePath File path */ private watchFile; /** * Stops watching all rule files */ stopWatching(): void; /** * Gets the rules for a specific mode * @param mode Mode name * @returns Rules for the specified mode or null if not found */ getRulesForMode(mode: string): ClineruleBaseType | null; /** * Checks if a specific mode is available * @param mode Mode name * @returns true if the mode is available, false otherwise */ hasModeRules(mode: string): boolean; /** * Gets all available modes * @returns Array with the names of available modes */ getAvailableModes(): string[]; /** * Cleans up all resources */ dispose(): void; /** * Creates missing .clinerules files * @param missingFiles Array of missing file names * @returns Array of created file names */ createMissingClinerules(missingFiles: string[]): Promise<string[]>; private loadRuleFile; }