mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-15 04:20:57 -07:00
Update prompt and grep tool definition to limit context size (#18780)
This commit is contained in:
committed by
GitHub
parent
7304b94f81
commit
efde27f3fc
@@ -498,6 +498,41 @@ describe('GrepTool', () => {
|
||||
expect(result.llmContent).toContain('File: sub/fileC.txt');
|
||||
expect(result.llmContent).toContain('L1: another world in sub dir');
|
||||
});
|
||||
|
||||
it('should return only file paths when names_only is true', async () => {
|
||||
const params: GrepToolParams = {
|
||||
pattern: 'world',
|
||||
names_only: true,
|
||||
};
|
||||
const invocation = grepTool.build(params);
|
||||
const result = await invocation.execute(abortSignal);
|
||||
|
||||
expect(result.llmContent).toContain('Found 2 files with matches');
|
||||
expect(result.llmContent).toContain('fileA.txt');
|
||||
expect(result.llmContent).toContain('sub/fileC.txt');
|
||||
expect(result.llmContent).not.toContain('L1:');
|
||||
expect(result.llmContent).not.toContain('hello world');
|
||||
});
|
||||
|
||||
it('should filter out matches based on exclude_pattern', async () => {
|
||||
await fs.writeFile(
|
||||
path.join(tempRootDir, 'copyright.txt'),
|
||||
'Copyright 2025 Google LLC\nCopyright 2026 Google LLC',
|
||||
);
|
||||
|
||||
const params: GrepToolParams = {
|
||||
pattern: 'Copyright .* Google LLC',
|
||||
exclude_pattern: '2026',
|
||||
dir_path: '.',
|
||||
};
|
||||
const invocation = grepTool.build(params);
|
||||
const result = await invocation.execute(abortSignal);
|
||||
|
||||
expect(result.llmContent).toContain('Found 1 match');
|
||||
expect(result.llmContent).toContain('copyright.txt');
|
||||
expect(result.llmContent).toContain('Copyright 2025 Google LLC');
|
||||
expect(result.llmContent).not.toContain('Copyright 2026 Google LLC');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDescription', () => {
|
||||
|
||||
Reference in New Issue
Block a user