Currently, exact_search lacks a file_pattern parameter and hardcodes rglob("*") (exact_search_tool.py:119). We should add this parameter to allow users to filter which files are searched (e.g., "*.py", "*.md"), matching the behavior of regex_search. This prevents wasted time scanning binary files like .pyc or images.
当前 exact_search 没有 file_pattern 参数,硬编码为 rglob("*")(exact_search_tool.py:119)。我们计划添加该参数,允许用户过滤要搜索的文件(例如 "*.py"、"*.md"),与 regex_search 的行为保持一致。这可以避免浪费时间扫描 .pyc 或图片等二进制文件。
The limit parameter currently stops after scanning a fixed number of files rather than after finding a fixed number of matches (see exact_search_tool.py:126 and regex_search_tool.py:156). We should change the semantics so that limit controls the maximum number of match results returned, not the number of files examined.
当前 limit 参数在扫描固定数量的文件后就停止,而不是在找到固定数量的匹配项后停止(见 exact_search_tool.py:126 和 regex_search_tool.py:156)。我们计划修改语义,使 limit 控制返回的 匹配结果 的最大数量,而不是检查的文件数量。
Proposed changes / 拟修改内容:
- Add
file_pattern: Optional[str] = None parameter to exact_search, defaulting to "*" (all files) for backward compatibility.
为 exact_search 添加 file_pattern: Optional[str] = None 参数,默认 "*"(所有文件)以保持向后兼容。
- Replace the hardcoded
rglob("*") with rglob(file_pattern) when pattern is provided.
当提供 pattern 时,将硬编码的 rglob("*") 替换为 rglob(file_pattern)。
- Change the
limit check to accumulate individual match results (not files) and stop once limit matches have been collected.
修改 limit 检查逻辑,改为累积单个匹配结果(而非文件),一旦收集到 limit 个匹配项即停止。
Additionally, the same limit semantic fix should be applied to regex_search for consistency.
另外,为保持一致性,regex_search 也应应用相同的 limit 语义修复。
Currently,
exact_searchlacks afile_patternparameter and hardcodesrglob("*")(exact_search_tool.py:119). We should add this parameter to allow users to filter which files are searched (e.g.,"*.py","*.md"), matching the behavior ofregex_search. This prevents wasted time scanning binary files like.pycor images.当前
exact_search没有file_pattern参数,硬编码为rglob("*")(exact_search_tool.py:119)。我们计划添加该参数,允许用户过滤要搜索的文件(例如"*.py"、"*.md"),与regex_search的行为保持一致。这可以避免浪费时间扫描.pyc或图片等二进制文件。The
limitparameter currently stops after scanning a fixed number of files rather than after finding a fixed number of matches (seeexact_search_tool.py:126andregex_search_tool.py:156). We should change the semantics so thatlimitcontrols the maximum number of match results returned, not the number of files examined.当前
limit参数在扫描固定数量的文件后就停止,而不是在找到固定数量的匹配项后停止(见exact_search_tool.py:126和regex_search_tool.py:156)。我们计划修改语义,使limit控制返回的 匹配结果 的最大数量,而不是检查的文件数量。Proposed changes / 拟修改内容:
file_pattern: Optional[str] = Noneparameter toexact_search, defaulting to"*"(all files) for backward compatibility.为
exact_search添加file_pattern: Optional[str] = None参数,默认"*"(所有文件)以保持向后兼容。rglob("*")withrglob(file_pattern)when pattern is provided.当提供 pattern 时,将硬编码的
rglob("*")替换为rglob(file_pattern)。limitcheck to accumulate individual match results (not files) and stop oncelimitmatches have been collected.修改
limit检查逻辑,改为累积单个匹配结果(而非文件),一旦收集到limit个匹配项即停止。Additionally, the same
limitsemantic fix should be applied toregex_searchfor consistency.另外,为保持一致性,
regex_search也应应用相同的limit语义修复。