/** * Config Manager Module * * Provides configuration management for project-level settings: * - Zod schema validation for configuration * - Loading config with sensible defaults * - Auto-generation of config.json with documentation * - Caching with reload support */ import { z } from 'zod'; /** * Parse a file size string to bytes * * Supports KB and MB units only (per RFC specification). * * @param size - Size string like "1MB" or "500KB" * @returns Size in bytes * @throws Error if format is invalid * * @example * ```typescript * parseFileSize('1MB') // => 1048576 * parseFileSize('500KB') // => 512000 * parseFileSize('100KB') // => 102400 * ``` */ export declare function parseFileSize(size: string): number; /** * Format bytes as a human-readable file size string * * @param bytes - Size in bytes * @returns Formatted string like "1MB" or "500KB" */ export declare function formatFileSize(bytes: number): string; /** * FTS engine preference type for hybrid search * * - 'auto': Automatically select engine based on codebase size and native availability * - 'js': Force JavaScript engine (NaturalBM25Engine) * - 'native': Force native engine (SQLiteFTS5Engine), falls back to JS if unavailable */ export type FTSEnginePreference = 'auto' | 'js' | 'native'; /** * Zod schema for hybrid search configuration */ export declare const HybridSearchSchema: z.ZodObject<{ enabled: z.ZodDefault; ftsEngine: z.ZodDefault>; defaultAlpha: z.ZodDefault; }, z.core.$strip>; /** * Inferred HybridSearch type from the schema */ export type HybridSearchConfig = z.infer; /** * Default hybrid search configuration * * Alpha=0.5 provides optimal balance between semantic and keyword search, * achieving best token efficiency (43x vs grep) based on full codebase testing. */ export declare const DEFAULT_HYBRID_SEARCH: HybridSearchConfig; /** * Zod schema for configuration validation * * Validates configuration with sensible defaults for all fields. * Underscore-prefixed fields (_comment, etc.) are stripped during parsing. */ export declare const ConfigSchema: z.ZodObject<{ include: z.ZodDefault>; exclude: z.ZodDefault>; respectGitignore: z.ZodDefault; maxFileSize: z.ZodDefault; maxFiles: z.ZodDefault; docPatterns: z.ZodDefault>; indexDocs: z.ZodDefault; enhancedToolDescriptions: z.ZodDefault; indexingStrategy: z.ZodDefault>; chunkingStrategy: z.ZodDefault>; hybridSearch: z.ZodDefault; ftsEngine: z.ZodDefault>; defaultAlpha: z.ZodDefault; }, z.core.$strip>>; extractComments: z.ZodDefault; }, z.core.$loose>; /** * Inferred Config type from the schema */ export type Config = z.infer; /** * Config with documentation fields for generated config files */ export interface ConfigWithDocs extends Config { _comment?: string; _hardcodedExcludes?: string[]; _availableOptions?: Record; } /** * Default configuration values * * These values are used when: * - No config file exists * - Config file is invalid * - A specific field is missing */ export declare const DEFAULT_CONFIG: Config; /** * Hardcoded exclusion patterns that cannot be overridden * * These are always excluded for security and performance reasons. */ export declare const HARDCODED_EXCLUDES: readonly string[]; /** * Load configuration from an index path * * Loads config.json from the index directory. Falls back to defaults if: * - File doesn't exist * - File is not valid JSON * - Content fails schema validation * * @param indexPath - Absolute path to the index directory * @returns Validated configuration object * * @example * ```typescript * const config = await loadConfig('/home/user/.mcp/search/indexes/abc123'); * console.log(config.maxFileSize); // "1MB" * ``` */ export declare function loadConfig(indexPath: string): Promise; /** * Save configuration to an index path * * Saves the configuration to config.json with pretty formatting. * Preserves existing documentation fields if present. * * @param indexPath - Absolute path to the index directory * @param config - Configuration to save */ export declare function saveConfig(indexPath: string, config: Config): Promise; /** * Generate a default config file with documentation comments * * Creates a config.json file with all default values and * helpful documentation fields explaining each option. * * @param indexPath - Absolute path to the index directory */ export declare function generateDefaultConfig(indexPath: string): Promise; /** * Config Manager class for managing project configuration * * Provides: * - Loading and caching configuration * - Saving configuration changes * - Ensuring config file exists * - Detecting config changes on reload * * @example * ```typescript * const manager = new ConfigManager('/path/to/index'); * await manager.ensureExists(); * const config = await manager.load(); * console.log(config.maxFileSize); * * // Later, get cached config * const cachedConfig = manager.getConfig(); * ``` */ export declare class ConfigManager { private readonly indexPath; private cachedConfig; private lastLoadedAt; /** * Create a new ConfigManager instance * * @param indexPath - Absolute path to the index directory */ constructor(indexPath: string); /** * Load configuration from disk * * Always reads from disk, updating the cache. * * @returns Validated configuration */ load(): Promise; /** * Save configuration to disk * * Updates both disk and cache. * * @param config - Configuration to save */ save(config: Config): Promise; /** * Ensure config file exists * * If no config.json exists, creates one with defaults and documentation. */ ensureExists(): Promise; /** * Get cached configuration * * Returns cached config if available, otherwise loads from disk. * Use this for synchronous access after initial load. * * @returns Cached configuration (may be stale if disk changed) * @throws Error if config has never been loaded */ getConfig(): Config; /** * Check if config has been loaded */ isLoaded(): boolean; /** * Get the timestamp of the last load operation */ getLastLoadedAt(): number; /** * Reload configuration if the file has been modified * * Compares file modification time with last load time to detect changes. * * @returns true if config was reloaded, false if unchanged */ reloadIfChanged(): Promise; /** * Get the path to the config file */ getConfigPath(): string; /** * Get the index path this manager is associated with */ getIndexPath(): string; /** * Get the max file size in bytes * * Convenience method that parses the maxFileSize string. */ getMaxFileSizeBytes(): number; } //# sourceMappingURL=config.d.ts.map