fix(agent): fix rg args ordering in function reference search tool

The --type-add and --type options were placed after the path argument,
causing ripgrep to treat them as additional paths rather than flags.
Moved option flags before the -e pattern and path arguments.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
jeffusion
2026-03-04 17:27:22 +08:00
committed by 路遥知码力
parent ba2663552d
commit f410373f7b

View File

@@ -80,12 +80,8 @@ export function createFunctionReferenceSearchTool(sandbox: SandboxExec): Tool {
const pattern = task.patterns.join('|');
const args = [
'--json',
// 移除 --ignore-case保持大小写敏感大多数语言都是case-sensitive
'--max-count',
String(max_results || 30),
'-e',
pattern,
context.workspacePath,
];
if (file_types && file_types.length > 0) {
@@ -93,6 +89,9 @@ export function createFunctionReferenceSearchTool(sandbox: SandboxExec): Tool {
args.push('--type', 'custom');
}
// -e pattern 和路径必须在所有选项之后
args.push('-e', pattern, context.workspacePath);
try {
const result = await sandbox.run('rg', args, {
cwd: context.workspacePath,