mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-15 05:47:18 -07:00
feat(tools): implement tactful extraction rework for token efficiency
- Restore precision to read_file with 1-based start_line and end_line for Gemini 3. - Update tool descriptions to establish extraction hierarchy (rg > shell/sed > read_file). - Codify 'Be Token-Frugal' mandate in system prompt snippets. - Refine research workflow to allow context-based validation via search tools. - Update unit tests and verified build integrity.
This commit is contained in:
@@ -950,6 +950,28 @@ describe('fileUtils', () => {
|
||||
expect(result.linesShown).toEqual([6, 10]);
|
||||
});
|
||||
|
||||
it('should support startLine and endLine for text files', async () => {
|
||||
const lines = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
|
||||
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
||||
|
||||
const result = await processSingleFileContent(
|
||||
testTextFilePath,
|
||||
tempRootDir,
|
||||
new StandardFileSystemService(),
|
||||
undefined,
|
||||
undefined,
|
||||
5,
|
||||
10,
|
||||
); // Read lines 5-10 (1-based)
|
||||
const expectedContent = lines.slice(4, 10).join('\n');
|
||||
|
||||
expect(result.llmContent).toBe(expectedContent);
|
||||
expect(result.returnDisplay).toBe('Read lines 5-10 of 20 from test.txt');
|
||||
expect(result.isTruncated).toBe(true);
|
||||
expect(result.originalLineCount).toBe(20);
|
||||
expect(result.linesShown).toEqual([5, 10]);
|
||||
});
|
||||
|
||||
it('should identify truncation when reading the end of a file', async () => {
|
||||
const lines = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
|
||||
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
||||
|
||||
Reference in New Issue
Block a user