diff --git a/packages/core/src/tools/ripGrep.test.ts b/packages/core/src/tools/ripGrep.test.ts index 114b6b8e11..09f8b5f00c 100644 --- a/packages/core/src/tools/ripGrep.test.ts +++ b/packages/core/src/tools/ripGrep.test.ts @@ -1430,11 +1430,15 @@ describe('RipGrepTool', () => { }); const result = await invocation.execute(abortSignal); - expect(mockSpawn).toHaveBeenLastCalledWith( - expect.anything(), - expect.arrayContaining(['--fixed-strings']), - expect.anything(), - ); + const spawnArgs = mockSpawn.mock.calls[0][1]; + expect(spawnArgs).toContain('--fixed-strings'); + expect(spawnArgs).toContain('--regexp'); + expect(spawnArgs).toContain('hello.world'); + + // Verify --fixed-strings doesn't have the pattern as its next argument + const fixedStringsIdx = spawnArgs.indexOf('--fixed-strings'); + expect(spawnArgs[fixedStringsIdx + 1]).not.toBe('hello.world'); + expect(result.llmContent).toContain( 'Found 1 match for pattern "hello.world"', ); diff --git a/packages/core/src/tools/ripGrep.ts b/packages/core/src/tools/ripGrep.ts index d4478fffee..5fe516c335 100644 --- a/packages/core/src/tools/ripGrep.ts +++ b/packages/core/src/tools/ripGrep.ts @@ -387,11 +387,10 @@ class GrepToolInvocation extends BaseToolInvocation< if (fixed_strings) { rgArgs.push('--fixed-strings'); - rgArgs.push(pattern); - } else { - rgArgs.push('--regexp', pattern); } + rgArgs.push('--regexp', pattern); + if (context) { rgArgs.push('--context', context.toString()); }