mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 09:01:17 -07:00
feat(core): centralize read_file limits and update gemini-3 description (#20619)
This commit is contained in:
@@ -6,3 +6,7 @@
|
||||
|
||||
export const REFERENCE_CONTENT_START = '--- Content from referenced files ---';
|
||||
export const REFERENCE_CONTENT_END = '--- End of content ---';
|
||||
|
||||
export const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
|
||||
export const MAX_LINE_LENGTH_TEXT_FILE = 2000;
|
||||
export const MAX_FILE_SIZE_MB = 20;
|
||||
|
||||
@@ -15,6 +15,11 @@ import { ToolErrorType } from '../tools/tool-error.js';
|
||||
import { BINARY_EXTENSIONS } from './ignorePatterns.js';
|
||||
import { createRequire as createModuleRequire } from 'node:module';
|
||||
import { debugLogger } from './debugLogger.js';
|
||||
import {
|
||||
DEFAULT_MAX_LINES_TEXT_FILE,
|
||||
MAX_LINE_LENGTH_TEXT_FILE,
|
||||
MAX_FILE_SIZE_MB,
|
||||
} from './constants.js';
|
||||
|
||||
const requireModule = createModuleRequire(import.meta.url);
|
||||
|
||||
@@ -52,10 +57,6 @@ export async function loadWasmBinary(
|
||||
}
|
||||
}
|
||||
|
||||
// Constants for text file processing
|
||||
export const DEFAULT_MAX_LINES_TEXT_FILE = 2000;
|
||||
const MAX_LINE_LENGTH_TEXT_FILE = 2000;
|
||||
|
||||
// Default values for encoding and separator format
|
||||
export const DEFAULT_ENCODING: BufferEncoding = 'utf-8';
|
||||
|
||||
@@ -434,11 +435,11 @@ export async function processSingleFileContent(
|
||||
}
|
||||
|
||||
const fileSizeInMB = stats.size / (1024 * 1024);
|
||||
if (fileSizeInMB > 20) {
|
||||
if (fileSizeInMB > MAX_FILE_SIZE_MB) {
|
||||
return {
|
||||
llmContent: 'File size exceeds the 20MB limit.',
|
||||
returnDisplay: 'File size exceeds the 20MB limit.',
|
||||
error: `File size exceeds the 20MB limit: ${filePath} (${fileSizeInMB.toFixed(2)}MB)`,
|
||||
llmContent: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit.`,
|
||||
returnDisplay: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit.`,
|
||||
error: `File size exceeds the ${MAX_FILE_SIZE_MB}MB limit: ${filePath} (${fileSizeInMB.toFixed(2)}MB)`,
|
||||
errorType: ToolErrorType.FILE_TOO_LARGE,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user