工具描述:Grep 内容搜索
Tool Description: Grep
v2.0.14Tool description for content search using ripgrep
模板变量 / Template Variables
GREP_TOOL_NAMEBASH_TOOL_NAMETASK_TOOL_NAME
一个基于 ripgrep 构建的强大搜索工具
使用说明:
- 执行搜索任务时,请始终使用 ${GREP_TOOL_NAME}。切勿通过 ${BASH_TOOL_NAME} 命令调用
grep或rg。${GREP_TOOL_NAME} 工具已针对权限和访问进行了优化。 - 支持完整的正则表达式语法(例如:"log.*Error"、"function\s+\w+")
- 使用 glob 参数(例如:".js"、"**/.tsx")或 type 参数(例如:"js"、"py"、"rust")过滤文件
- 输出模式:"content" 显示匹配行,"files_with_matches" 仅显示文件路径(默认),"count" 显示匹配计数
- 对于需要多轮交互的开放式搜索,请使用 ${TASK_TOOL_NAME} 工具
- 模式语法:使用 ripgrep(非 grep)——字面量花括号需要转义(使用
interface\\{\\}来查找 Go 代码中的interface{}) - 多行匹配:默认情况下,模式仅在单行内匹配。对于跨行模式(如
struct \\{[\\s\\S]*?field),请使用multiline: true
英文原文 / English Original
A powerful search tool built on ripgrep
Usage:
- ALWAYS use ${GREP_TOOL_NAME} for search tasks. NEVER invoke
greporrgas a ${BASH_TOOL_NAME} command. The ${GREP_TOOL_NAME} tool has been optimized for correct permissions and access. - Supports full regex syntax (e.g., "log.*Error", "function\s+\w+")
- Filter files with glob parameter (e.g., ".js", "**/.tsx") or type parameter (e.g., "js", "py", "rust")
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
- Use ${TASK_TOOL_NAME} tool for open-ended searches requiring multiple rounds
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use
interface\\{\\}to findinterface{}in Go code) - Multiline matching: By default patterns match within single lines only. For cross-line patterns like
struct \\{[\\s\\S]*?field, usemultiline: true