refactor(core): consolidate execute() arguments into ExecuteOptions (#25101)

This commit is contained in:
Michael Bleigh
2026-04-10 10:11:17 -07:00
committed by GitHub
parent 1d36309f5f
commit 3b7c17a22c
69 changed files with 849 additions and 527 deletions
+41 -37
View File
@@ -437,7 +437,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'world' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 3 matches for pattern "world" in path "."',
);
@@ -481,7 +481,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'world' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('File: ..env');
expect(result.llmContent).toContain('L1: world in ..env');
expect(result.llmContent).not.toContain('secret.txt');
@@ -506,7 +506,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'world', dir_path: 'sub' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 1 match for pattern "world" in path "sub"',
);
@@ -539,7 +539,7 @@ describe('RipGrepTool', () => {
include_pattern: '*.js',
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 1 match for pattern "hello" in path "." (filter: "*.js"):',
);
@@ -580,7 +580,7 @@ describe('RipGrepTool', () => {
include_pattern: '*.js',
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 1 match for pattern "hello" in path "sub" (filter: "*.js")',
);
@@ -601,7 +601,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'nonexistentpattern' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'No matches found for pattern "nonexistentpattern" in path ".".',
);
@@ -631,7 +631,7 @@ describe('RipGrepTool', () => {
dir_path: tempRootDir,
});
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Process exited with code 2');
expect(result.returnDisplay).toContain(
'Error: Process exited with code 2',
@@ -698,7 +698,7 @@ describe('RipGrepTool', () => {
pattern: 'test',
dir_path: tempRootDir,
});
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect((result.returnDisplay as GrepResult).summary).toContain(
'(limited)',
@@ -746,7 +746,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'should' };
const invocation = toolWithIgnore.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
// Verify ignored file is filtered out
expect(result.llmContent).toContain('allowed.txt');
@@ -777,7 +777,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'foo.*bar' }; // Matches 'const foo = "bar";'
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 1 match for pattern "foo.*bar" in path ".":',
);
@@ -814,7 +814,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'HELLO' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(
'Found 2 matches for pattern "HELLO" in path ".":',
);
@@ -840,7 +840,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'world' };
const invocation = grepTool.build(params);
expect(await invocation.execute(abortSignal)).toStrictEqual({
expect(await invocation.execute({ abortSignal })).toStrictEqual({
llmContent: 'Error during grep search operation: Cannot use ripgrep.',
returnDisplay: 'Error: Cannot use ripgrep.',
});
@@ -939,7 +939,7 @@ describe('RipGrepTool', () => {
);
const params: RipGrepToolParams = { pattern: 'world' };
const invocation = multiDirGrepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
// Should find matches in CWD only (default behavior now)
expect(result.llmContent).toContain(
@@ -1033,7 +1033,7 @@ describe('RipGrepTool', () => {
// Search only in the 'sub' directory of the first workspace
const params: RipGrepToolParams = { pattern: 'world', dir_path: 'sub' };
const invocation = multiDirGrepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
// Should only find matches in the specified sub directory
expect(result.llmContent).toContain(
@@ -1058,7 +1058,9 @@ describe('RipGrepTool', () => {
controller.abort();
const result = await invocation.execute(controller.signal);
const result = await invocation.execute({
abortSignal: controller.signal,
});
expect(result).toBeDefined();
});
@@ -1078,7 +1080,9 @@ describe('RipGrepTool', () => {
// Abort immediately before starting the search
controller.abort();
const result = await invocation.execute(controller.signal);
const result = await invocation.execute({
abortSignal: controller.signal,
});
expect((result.returnDisplay as GrepResult).summary).toContain(
'No matches found',
);
@@ -1115,7 +1119,7 @@ describe('RipGrepTool', () => {
const params = await setup();
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('No matches found');
});
@@ -1144,7 +1148,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'world' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain(specialFileName);
expect(result.llmContent).toContain('hello world with special chars');
@@ -1175,7 +1179,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'deep' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('deep.txt');
expect(result.llmContent).toContain('content in deep directory');
@@ -1209,7 +1213,7 @@ describe('RipGrepTool', () => {
context: 0,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('function getName()');
expect(result.llmContent).not.toContain('const getValue');
@@ -1257,7 +1261,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'hello' };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Hello World');
expect(result.llmContent).toContain('hello world');
@@ -1290,7 +1294,7 @@ describe('RipGrepTool', () => {
context: 0,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Price: $19.99');
expect(result.llmContent).not.toContain('Email: test@example.com');
@@ -1340,7 +1344,7 @@ describe('RipGrepTool', () => {
include_pattern: '*.{ts,tsx}',
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('test.ts');
expect(result.llmContent).toContain('test.tsx');
@@ -1376,7 +1380,7 @@ describe('RipGrepTool', () => {
include_pattern: 'src/**',
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('main.ts');
expect(result.llmContent).not.toContain('other.ts');
@@ -1402,7 +1406,7 @@ describe('RipGrepTool', () => {
);
let params: RipGrepToolParams = { pattern: 'HELLO', context: 0 };
let invocation = grepTool.build(params);
let result = await invocation.execute(abortSignal);
let result = await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
expect.arrayContaining(['--ignore-case']),
@@ -1428,7 +1432,7 @@ describe('RipGrepTool', () => {
);
params = { pattern: 'HELLO', case_sensitive: true, context: 0 };
invocation = grepTool.build(params);
result = await invocation.execute(abortSignal);
result = await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
expect.not.arrayContaining(['--ignore-case']),
@@ -1458,7 +1462,7 @@ describe('RipGrepTool', () => {
pattern: 'hello.world',
fixed_strings: true,
});
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
const spawnArgs = mockSpawn.mock.calls[0][1];
expect(spawnArgs).toContain('--fixed-strings');
@@ -1500,7 +1504,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'secret', no_ignore: true };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
@@ -1573,7 +1577,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'secret' };
const invocation = gitIgnoreDisabledTool.build(params);
await invocation.execute(abortSignal);
await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
@@ -1639,7 +1643,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'secret' };
const invocation = geminiIgnoreTool.build(params);
await invocation.execute(abortSignal);
await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
@@ -1705,7 +1709,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'secret' };
const invocation = geminiIgnoreTool.build(params);
await invocation.execute(abortSignal);
await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
@@ -1765,7 +1769,7 @@ describe('RipGrepTool', () => {
before: 1,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(mockSpawn).toHaveBeenLastCalledWith(
expect.anything(),
@@ -1905,7 +1909,7 @@ describe('RipGrepTool', () => {
max_matches_per_file: 1,
};
const invocation = grepTool.build(params);
await invocation.execute(abortSignal);
await invocation.execute({ abortSignal });
const spawnArgs = mockSpawn.mock.calls[0][1];
expect(spawnArgs).toContain('--max-count');
@@ -1954,7 +1958,7 @@ describe('RipGrepTool', () => {
context: 0,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Found 2 matches');
expect(result.llmContent).toContain(
@@ -1999,7 +2003,7 @@ describe('RipGrepTool', () => {
names_only: true,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Found 2 files with matches');
expect(result.llmContent).toContain('fileA.txt');
@@ -2040,7 +2044,7 @@ describe('RipGrepTool', () => {
context: 0,
};
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
expect(result.llmContent).toContain('Found 1 match');
expect(result.llmContent).toContain('fileA.txt');
@@ -2067,7 +2071,7 @@ describe('RipGrepTool', () => {
const params: RipGrepToolParams = { pattern: 'Target match', context: 0 };
const invocation = grepTool.build(params);
const result = await invocation.execute(abortSignal);
const result = await invocation.execute({ abortSignal });
// MAX_LINE_LENGTH_TEXT_FILE is 2000. It should be truncated.
expect(result.llmContent).toContain('... [truncated]');