Skip to content

Commit 3993800

Browse files
authored
feat(core): rename grep_search include parameter to include_pattern (#20328)
1 parent d128fb0 commit 3993800

12 files changed

Lines changed: 78 additions & 69 deletions

File tree

evals/grep_search_functionality.eval.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('grep_search_functionality', () => {
9393
});
9494

9595
evalTest('USUALLY_PASSES', {
96-
name: 'should search only within the specified include glob',
96+
name: 'should search only within the specified include_pattern glob',
9797
files: {
9898
'file.js': 'my_function();',
9999
'file.ts': 'my_function();',
@@ -105,19 +105,19 @@ describe('grep_search_functionality', () => {
105105
undefined,
106106
(args) => {
107107
const params = JSON.parse(args);
108-
return params.include === '*.js';
108+
return params.include_pattern === '*.js';
109109
},
110110
);
111111
expect(
112112
wasToolCalled,
113-
'Expected grep_search to be called with include: "*.js"',
113+
'Expected grep_search to be called with include_pattern: "*.js"',
114114
).toBe(true);
115115

116116
assertModelHasOutput(result);
117117
checkModelOutputContent(result, {
118118
expectedContent: [/file.js/],
119119
forbiddenContent: [/file.ts/],
120-
testName: `${TEST_PREFIX}include glob search`,
120+
testName: `${TEST_PREFIX}include_pattern glob search`,
121121
});
122122
},
123123
});

integration-tests/ripgrep-real.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ describe('ripgrep-real-direct', () => {
102102
'console.log("hello");\n',
103103
);
104104

105-
const invocation = tool.build({ pattern: 'hello', include: '*.js' });
105+
const invocation = tool.build({
106+
pattern: 'hello',
107+
include_pattern: '*.js',
108+
});
106109
const result = await invocation.execute(new AbortController().signal);
107110

108111
expect(result.llmContent).toContain('Found 1 match');

packages/core/src/core/__snapshots__/prompts.test.ts.snap

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

packages/core/src/prompts/snippets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Use the following guidelines to optimize your search and read patterns.
189189
</guidelines>
190190
191191
<examples>
192-
- **Searching:** utilize search tools like ${GREP_TOOL_NAME} and ${GLOB_TOOL_NAME} with a conservative result count (\`total_max_matches\`) and a narrow scope (\`include\` and \`exclude\` parameters).
192+
- **Searching:** utilize search tools like ${GREP_TOOL_NAME} and ${GLOB_TOOL_NAME} with a conservative result count (\`total_max_matches\`) and a narrow scope (\`include_pattern\` and \`exclude_pattern\` parameters).
193193
- **Searching and editing:** utilize search tools like ${GREP_TOOL_NAME} with a conservative result count and a narrow scope. Use \`context\`, \`before\`, and/or \`after\` to request enough context to avoid the need to read the file before editing matches.
194194
- **Understanding:** minimize turns needed to understand a file. It's most efficient to read small files in their entirety.
195195
- **Large files:** utilize search tools like ${GREP_TOOL_NAME} and/or ${READ_FILE_TOOL_NAME} called in parallel with 'start_line' and 'end_line' to reduce the impact on context. Minimize extra turns, unless unavoidable due to the file being too large.

packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-2.5-pro > snaps
266266
"description": "Optional: A regular expression pattern to exclude from the search results. If a line matches both the pattern and the exclude_pattern, it will be omitted.",
267267
"type": "string",
268268
},
269-
"include": {
269+
"include_pattern": {
270270
"description": "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).",
271271
"type": "string",
272272
},
@@ -333,7 +333,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-2.5-pro > snaps
333333
"description": "If true, treats the \`pattern\` as a literal string instead of a regular expression. Defaults to false (basic regex) if omitted.",
334334
"type": "boolean",
335335
},
336-
"include": {
336+
"include_pattern": {
337337
"description": "Glob pattern to filter files (e.g., '*.ts', 'src/**'). Recommended for large repositories to reduce noise. Defaults to all files if omitted.",
338338
"type": "string",
339339
},
@@ -1053,7 +1053,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview >
10531053
"description": "Optional: A regular expression pattern to exclude from the search results. If a line matches both the pattern and the exclude_pattern, it will be omitted.",
10541054
"type": "string",
10551055
},
1056-
"include": {
1056+
"include_pattern": {
10571057
"description": "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).",
10581058
"type": "string",
10591059
},
@@ -1120,7 +1120,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview >
11201120
"description": "If true, treats the \`pattern\` as a literal string instead of a regular expression. Defaults to false (basic regex) if omitted.",
11211121
"type": "boolean",
11221122
},
1123-
"include": {
1123+
"include_pattern": {
11241124
"description": "Glob pattern to filter files (e.g., '*.ts', 'src/**'). Recommended for large repositories to reduce noise. Defaults to all files if omitted.",
11251125
"type": "string",
11261126
},

packages/core/src/tools/definitions/model-family-sets/default-legacy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const DEFAULT_LEGACY_SET: CoreToolSet = {
9696
'Optional: The absolute path to the directory to search within. If omitted, searches the current working directory.',
9797
type: 'string',
9898
},
99-
include: {
99+
include_pattern: {
100100
description: `Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).`,
101101
type: 'string',
102102
},
@@ -143,7 +143,7 @@ export const DEFAULT_LEGACY_SET: CoreToolSet = {
143143
"Directory or file to search. Directories are searched recursively. Relative paths are resolved against current working directory. Defaults to current working directory ('.') if omitted.",
144144
type: 'string',
145145
},
146-
include: {
146+
include_pattern: {
147147
description:
148148
"Glob pattern to filter files (e.g., '*.ts', 'src/**'). Recommended for large repositories to reduce noise. Defaults to all files if omitted.",
149149
type: 'string',

packages/core/src/tools/definitions/model-family-sets/gemini-3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const GEMINI_3_SET: CoreToolSet = {
9797
'Optional: The absolute path to the directory to search within. If omitted, searches the current working directory.',
9898
type: 'string',
9999
},
100-
include: {
100+
include_pattern: {
101101
description: `Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).`,
102102
type: 'string',
103103
},
@@ -144,7 +144,7 @@ export const GEMINI_3_SET: CoreToolSet = {
144144
"Directory or file to search. Directories are searched recursively. Relative paths are resolved against current working directory. Defaults to current working directory ('.') if omitted.",
145145
type: 'string',
146146
},
147-
include: {
147+
include_pattern: {
148148
description:
149149
"Glob pattern to filter files (e.g., '*.ts', 'src/**'). Recommended for large repositories to reduce noise. Defaults to all files if omitted.",
150150
type: 'string',

packages/core/src/tools/grep-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export async function formatGrepResults(
139139
params: {
140140
pattern: string;
141141
names_only?: boolean;
142-
include?: string;
142+
include_pattern?: string;
143143
// Context params to determine if auto-context should be skipped
144144
context?: number;
145145
before?: number;
@@ -148,10 +148,10 @@ export async function formatGrepResults(
148148
searchLocationDescription: string,
149149
totalMaxMatches: number,
150150
): Promise<{ llmContent: string; returnDisplay: string }> {
151-
const { pattern, names_only, include } = params;
151+
const { pattern, names_only, include_pattern } = params;
152152

153153
if (allMatches.length === 0) {
154-
const noMatchMsg = `No matches found for pattern "${pattern}" ${searchLocationDescription}${include ? ` (filter: "${include}")` : ''}.`;
154+
const noMatchMsg = `No matches found for pattern "${pattern}" ${searchLocationDescription}${include_pattern ? ` (filter: "${include_pattern}")` : ''}.`;
155155
return { llmContent: noMatchMsg, returnDisplay: `No matches found` };
156156
}
157157

@@ -171,7 +171,7 @@ export async function formatGrepResults(
171171
if (names_only) {
172172
const filePaths = Object.keys(matchesByFile).sort();
173173
let llmContent = `Found ${filePaths.length} files with matches for pattern "${pattern}" ${searchLocationDescription}${
174-
include ? ` (filter: "${include}")` : ''
174+
include_pattern ? ` (filter: "${include_pattern}")` : ''
175175
}${
176176
wasTruncated
177177
? ` (results limited to ${totalMaxMatches} matches for performance)`
@@ -184,7 +184,7 @@ export async function formatGrepResults(
184184
};
185185
}
186186

187-
let llmContent = `Found ${matchCount} ${matchTerm} for pattern "${pattern}" ${searchLocationDescription}${include ? ` (filter: "${include}")` : ''}`;
187+
let llmContent = `Found ${matchCount} ${matchTerm} for pattern "${pattern}" ${searchLocationDescription}${include_pattern ? ` (filter: "${include_pattern}")` : ''}`;
188188

189189
if (wasTruncated) {
190190
llmContent += ` (results limited to ${totalMaxMatches} matches for performance)`;

packages/core/src/tools/grep.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('GrepTool', () => {
118118
const params: GrepToolParams = {
119119
pattern: 'hello',
120120
dir_path: '.',
121-
include: '*.txt',
121+
include_pattern: '*.txt',
122122
};
123123
expect(grepTool.validateToolParams(params)).toBeNull();
124124
});
@@ -226,7 +226,10 @@ describe('GrepTool', () => {
226226
}, 30000);
227227

228228
it('should find matches with an include glob', async () => {
229-
const params: GrepToolParams = { pattern: 'hello', include: '*.js' };
229+
const params: GrepToolParams = {
230+
pattern: 'hello',
231+
include_pattern: '*.js',
232+
};
230233
const invocation = grepTool.build(params);
231234
const result = await invocation.execute(abortSignal);
232235
expect(result.llmContent).toContain(
@@ -247,7 +250,7 @@ describe('GrepTool', () => {
247250
const params: GrepToolParams = {
248251
pattern: 'hello',
249252
dir_path: 'sub',
250-
include: '*.js',
253+
include_pattern: '*.js',
251254
};
252255
const invocation = grepTool.build(params);
253256
const result = await invocation.execute(abortSignal);
@@ -572,7 +575,7 @@ describe('GrepTool', () => {
572575
it('should generate correct description with pattern and include', () => {
573576
const params: GrepToolParams = {
574577
pattern: 'testPattern',
575-
include: '*.ts',
578+
include_pattern: '*.ts',
576579
};
577580
const invocation = grepTool.build(params);
578581
expect(invocation.getDescription()).toBe("'testPattern' in *.ts");
@@ -618,7 +621,7 @@ describe('GrepTool', () => {
618621
await fs.mkdir(dirPath, { recursive: true });
619622
const params: GrepToolParams = {
620623
pattern: 'testPattern',
621-
include: '*.ts',
624+
include_pattern: '*.ts',
622625
dir_path: path.join('src', 'app'),
623626
};
624627
const invocation = grepTool.build(params);

packages/core/src/tools/grep.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface GrepToolParams {
4848
/**
4949
* File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}")
5050
*/
51-
include?: string;
51+
include_pattern?: string;
5252

5353
/**
5454
* Optional: A regular expression pattern to exclude from the search results.
@@ -227,7 +227,7 @@ class GrepToolInvocation extends BaseToolInvocation<
227227
const matches = await this.performGrepSearch({
228228
pattern: this.params.pattern,
229229
path: searchDir,
230-
include: this.params.include,
230+
include_pattern: this.params.include_pattern,
231231
exclude_pattern: this.params.exclude_pattern,
232232
maxMatches: remainingLimit,
233233
max_matches_per_file: this.params.max_matches_per_file,
@@ -317,7 +317,7 @@ class GrepToolInvocation extends BaseToolInvocation<
317317
private async performGrepSearch(options: {
318318
pattern: string;
319319
path: string; // Expects absolute path
320-
include?: string;
320+
include_pattern?: string;
321321
exclude_pattern?: string;
322322
maxMatches: number;
323323
max_matches_per_file?: number;
@@ -326,7 +326,7 @@ class GrepToolInvocation extends BaseToolInvocation<
326326
const {
327327
pattern,
328328
path: absolutePath,
329-
include,
329+
include_pattern,
330330
exclude_pattern,
331331
maxMatches,
332332
max_matches_per_file,
@@ -356,8 +356,8 @@ class GrepToolInvocation extends BaseToolInvocation<
356356
if (max_matches_per_file) {
357357
gitArgs.push('--max-count', max_matches_per_file.toString());
358358
}
359-
if (include) {
360-
gitArgs.push('--', include);
359+
if (include_pattern) {
360+
gitArgs.push('--', include_pattern);
361361
}
362362

363363
try {
@@ -424,8 +424,8 @@ class GrepToolInvocation extends BaseToolInvocation<
424424
if (max_matches_per_file) {
425425
grepArgs.push('--max-count', max_matches_per_file.toString());
426426
}
427-
if (include) {
428-
grepArgs.push(`--include=${include}`);
427+
if (include_pattern) {
428+
grepArgs.push(`--include=${include_pattern}`);
429429
}
430430
grepArgs.push(pattern);
431431
grepArgs.push('.');
@@ -471,7 +471,7 @@ class GrepToolInvocation extends BaseToolInvocation<
471471
'GrepLogic: Falling back to JavaScript grep implementation.',
472472
);
473473
strategyUsed = 'javascript fallback';
474-
const globPattern = include ? include : '**/*';
474+
const globPattern = include_pattern ? include_pattern : '**/*';
475475
const ignorePatterns = this.fileExclusions.getGlobExcludes();
476476

477477
const filesStream = globStream(globPattern, {
@@ -551,8 +551,8 @@ class GrepToolInvocation extends BaseToolInvocation<
551551

552552
getDescription(): string {
553553
let description = `'${this.params.pattern}'`;
554-
if (this.params.include) {
555-
description += ` in ${this.params.include}`;
554+
if (this.params.include_pattern) {
555+
description += ` in ${this.params.include_pattern}`;
556556
}
557557
if (this.params.dir_path) {
558558
const resolvedPath = path.resolve(

0 commit comments

Comments
 (0)