mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 23:51:16 -07:00
Tune.
This commit is contained in:
@@ -311,7 +311,8 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
|
||||
llmContent += `:\n---\n`;
|
||||
|
||||
if (matchCount === 1 && matchCount > 0 && !this.params.names_only) {
|
||||
if (matchCount >= 1 && matchCount <= 3 && !this.params.names_only) {
|
||||
const contextBudget = matchCount === 1 ? 50 : 15;
|
||||
for (const filePath in matchesByFile) {
|
||||
const fileMatches = matchesByFile[filePath];
|
||||
let fileLines: string[] | null = null;
|
||||
@@ -332,10 +333,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
|
||||
for (const match of fileMatches) {
|
||||
if (fileLines) {
|
||||
const startLine = Math.max(0, match.lineNumber - 1 - 50);
|
||||
const startLine = Math.max(0, match.lineNumber - 1 - contextBudget);
|
||||
const endLine = Math.min(
|
||||
fileLines.length,
|
||||
match.lineNumber - 1 + 50 + 1,
|
||||
match.lineNumber - 1 + contextBudget + 1,
|
||||
);
|
||||
const contextLines = fileLines.slice(startLine, endLine);
|
||||
|
||||
|
||||
@@ -313,13 +313,14 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
|
||||
// Greedy Grep: If match count is low and no context was requested, automatically return context.
|
||||
if (
|
||||
matchCount === 1 &&
|
||||
matchCount > 0 &&
|
||||
matchCount >= 1 &&
|
||||
matchCount <= 3 &&
|
||||
!this.params.names_only &&
|
||||
!this.params.context &&
|
||||
!this.params.before &&
|
||||
!this.params.after
|
||||
) {
|
||||
const contextLines = matchCount === 1 ? 50 : 15;
|
||||
for (const filePath in matchesByFile) {
|
||||
const fileMatches = matchesByFile[filePath];
|
||||
let fileLines: string[] | null = null;
|
||||
@@ -340,10 +341,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
const newFileMatches: GrepMatch[] = [];
|
||||
const seenLines = new Set<number>();
|
||||
for (const match of fileMatches) {
|
||||
const startLine = Math.max(0, match.lineNumber - 1 - 50);
|
||||
const startLine = Math.max(0, match.lineNumber - 1 - contextLines);
|
||||
const endLine = Math.min(
|
||||
fileLines.length,
|
||||
match.lineNumber - 1 + 50 + 1,
|
||||
match.lineNumber - 1 + contextLines + 1,
|
||||
);
|
||||
for (let i = startLine; i < endLine; i++) {
|
||||
if (!seenLines.has(i + 1)) {
|
||||
|
||||
Reference in New Issue
Block a user