/** * Detects potential AI-generated code omissions in the given file content. * @param originalFileContent The original content of the file. * @param newFileContent The new content of the file to check. * @param predictedLineCount Optional predicted number of lines in the new content. * @returns True if a potential omission is detected, false otherwise. */ export function detectCodeOmission( originalFileContent: string, newFileContent: string, predictedLineCount?: number ): boolean { // Skip all checks if predictedLineCount is less than 100 if (!predictedLineCount || predictedLineCount < 100) { return false } const actualLineCount = newFileContent.split("\n").length const lengthRatio = actualLineCount / predictedLineCount // If content is more than 25% shorter than predicted, this is suspicious if (lengthRatio <= 0.75) { return true } const originalLines = originalFileContent.split("\n") const newLines = newFileContent.split("\n") const omissionKeywords = ["remain", "remains", "unchanged", "rest", "previous", "existing", "content", "same", "..."] const commentPatterns = [ /^\s*\/\//, // Single-line comment for most languages /^\s*#/, // Single-line comment for Python, Ruby, etc. /^\s*\/\*/, // Multi-line comment opening /^\s*{\s*\/\*/, // JSX comment opening /^\s*