/** * Health check: Code drift detection. * * Compares files listed in agent frontmatter against actual filesystem. * Detects missing files and suggests possible renames via fuzzy matching. */ import type { ServerConfig } from '../config.js'; import type { AgentFrontmatter } from '../agent-parser.js'; /** * File entry in agent frontmatter. * Can be a simple string or an object with path and metadata. */ type FileEntry = AgentFrontmatter['files'][number]; /** * Drift entry representing a file discrepancy. */ export interface DriftEntry { /** Task ID (planFolder#agentNumber) */ taskId: string; /** Agent number (e.g., "000") */ agentNumber: string; /** Agent title from first heading */ agentTitle: string; /** Path to the agent file */ agentPath: string; /** File path listed in frontmatter */ listedFile: string; /** Reason for drift: missing or renamed */ reason: 'missing' | 'renamed'; /** Suggested replacement path (fuzzy match) */ suggestion?: string; } /** * Result of a drift check operation. */ export interface DriftCheckResult { /** List of drift entries found */ drifts: DriftEntry[]; /** Total files checked across all agents */ totalFilesChecked: number; /** Number of agents checked */ agentsChecked: number; /** Number of external repo files skipped */ skippedExternal: number; /** Error message if operation failed */ error?: string; } /** * Normalize a file entry to a path string. * Returns null for entries that should be skipped (external repos, empty, invalid). * * @param entry - File entry from frontmatter * @returns Normalized path or null if should skip */ export declare function normalizeFilePath(entry: FileEntry): string | null; /** Entry in the file index used for fuzzy matching. */ interface FileIndexEntry { path: string; basename: string; nameWithoutExt: string; } /** * Build an index of files under codebasePath for reuse across multiple lookups. * Skips node_modules, .git, dist, build, .tmp. * * @param codebasePath - Root path of the codebase * @returns Array of file entries (path, basename, nameWithoutExt) */ export declare function buildFileIndex(codebasePath: string): FileIndexEntry[]; /** * Find a similar file from a pre-built index using fuzzy matching. * * @param index - Result of buildFileIndex(codebasePath) * @param filename - Filename to search for (basename only) * @returns Relative path to similar file, or null if not found */ export declare function findSimilarFileFromIndex(index: FileIndexEntry[], filename: string): string | null; /** * Find a similar file in the codebase using fuzzy matching. * Searches for files with the same or similar basename. * * @param codebasePath - Root path of the codebase * @param filename - Filename to search for (basename only) * @returns Relative path to similar file, or null if not found */ export declare function findSimilarFile(codebasePath: string, filename: string): string | null; /** * Check for file drift in a plan's agents. * * @param config - Server configuration with plansPath * @param planId - Plan number or name * @param codebasePath - Root path of the codebase to check against * @param agentNumber - Optional specific agent number to check * @returns Drift check result */ export declare function checkFileDrift(config: ServerConfig, planId: string, codebasePath: string, agentNumber?: string): DriftCheckResult; export {}; //# sourceMappingURL=health-drift.d.ts.map