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:
Adam Weidman
2026-02-10 14:43:24 -05:00
parent c3b9703d7b
commit f77dc348a0
10 changed files with 201 additions and 38 deletions
+22
View File
@@ -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'));