(stats: FileStat)
| 97 | * @returns Error object if file is too large, null if valid |
| 98 | */ |
| 99 | export function validateFileSize(stats: FileStat): { error: string } | null { |
| 100 | if (stats.size > MAX_FILE_SIZE) { |
| 101 | const sizeMB = (stats.size / (1024 * 1024)).toFixed(2); |
| 102 | const maxMB = (MAX_FILE_SIZE / (1024 * 1024)).toFixed(2); |
| 103 | return { |
| 104 | error: `File is too large (${sizeMB}MB). The maximum file size for file operations is ${maxMB}MB. Please use system tools like grep, sed, awk, or split the file into smaller chunks.`, |
| 105 | }; |
| 106 | } |
| 107 | return null; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Validates that a file path doesn't contain redundant workspace prefix. |
no outgoing calls
no test coverage detected