/** * Differential PR Mode * * Enhanced diff mode for incremental scanning with: * - Git-based change detection (git diff --name-only) * - Integration with scanner cache * - Support for PR base SHA comparison * - Incremental certification support * * @module action/diff-mode */ import type { ChangedFile, GitHubContext } from "./types.js"; /** * Result of git diff operation */ export interface GitDiffResult { /** Files that changed */ changedFiles: string[]; /** Base commit SHA */ baseSha: string; /** Head commit SHA */ headSha: string; /** Whether diff detection was successful */ success: boolean; /** Error message if unsuccessful */ error?: string; /** Total additions */ additions: number; /** Total deletions */ deletions: number; } /** * File info with hash for caching */ export interface FileInfo { /** Relative file path */ path: string; /** SHA-256 hash of file contents */ hash: string; /** File size in bytes */ size: number; /** Last modified time */ mtime: Date; } /** * Incremental scan configuration */ export interface IncrementalScanConfig { /** Project path */ projectPath: string; /** Base SHA for comparison (e.g., PR base branch) */ baseSha?: string; /** Head SHA (default: HEAD) */ headSha?: string; /** Previous certification ID to build upon */ previousCertificationId?: string; /** Files to force include even if unchanged */ forceInclude?: string[]; /** Files to exclude from scanning */ exclude?: string[]; /** Whether to scan security-critical files regardless of changes */ alwaysScanSecurityFiles?: boolean; } /** * Incremental scan result */ export interface IncrementalScanResult { /** Files that need scanning */ filesToScan: FileInfo[]; /** Files that are unchanged (cached) */ unchangedFiles: string[]; /** Files that were removed */ removedFiles: string[]; /** Git diff information */ diff: GitDiffResult; /** Configuration used */ config: IncrementalScanConfig; /** Whether incremental mode was used */ isIncremental: boolean; /** Estimated time savings from cache */ estimatedSavingsPercent: number; } /** * Get changed files using git diff * * Uses `git diff --name-only $BASE_SHA...HEAD` for accurate change detection. * * @param projectPath - Path to git repository * @param baseSha - Base commit SHA (e.g., PR base branch) * @param headSha - Head commit SHA (default: HEAD) */ export declare function getGitDiff(projectPath: string, baseSha?: string, headSha?: string): Promise; /** * Get file info with content hash */ export declare function getFileInfo(projectPath: string, filePath: string): Promise; /** * Get file info for multiple files in parallel */ export declare function getFilesInfo(projectPath: string, filePaths: string[]): Promise; /** * Check if a file should be scanned */ export declare function isScannableFile(filename: string): boolean; /** * Filter changed files to only scannable ones */ export declare function filterScannableFiles(files: ChangedFile[]): ChangedFile[]; /** * Get the list of file paths to scan */ export declare function getFilesToScan(changedFiles: ChangedFile[]): string[]; /** * Configure incremental scanning * * Determines which files need scanning based on: * 1. Git diff against base SHA * 2. File content hashes (for cache validation) * 3. Security-critical file detection */ export declare function configureIncrementalScan(config: IncrementalScanConfig): Promise; /** * Get changed files from GitHub API * * @param octokit - GitHub API client * @param context - GitHub context * @returns Array of changed files */ export declare function getChangedFiles(octokit: any, context: GitHubContext): Promise; /** * Check if any security-relevant files changed */ export declare function hasSecurityRelevantChanges(changedFiles: ChangedFile[]): boolean; /** * Get scan scope recommendation based on changes */ export declare function getScanScopeRecommendation(changedFiles: ChangedFile[]): "full" | "incremental" | "security-only"; /** * Generate summary of changed files */ export declare function generateChangeSummary(changedFiles: ChangedFile[]): string; /** * Group files by directory for parallel processing */ export declare function groupFilesByDirectory(files: FileInfo[]): Map; /** * Prioritize files for scanning (security-critical first) */ export declare function prioritizeFiles(files: FileInfo[]): FileInfo[]; //# sourceMappingURL=diff-mode.d.ts.map