修复: grep搜索误标Medium致每次审批
This commit is contained in:
@@ -1658,7 +1658,10 @@ fn register_file_tools(
|
||||
// 二进制文件(对齐 read_file/list_directory:\0 检测)。
|
||||
// path_auth:授权目录内放行;未授权走 AiDirAuthRequired 申请(audit/mod.rs check_file_tool_auth
|
||||
// 经 extract_file_tool_paths 单路径分支触发,非 search_files 盲拒)。
|
||||
// risk:Med(读文件内容,授权目录内放行/外申请)。
|
||||
// risk:Low(只读内容搜索,对齐 read_file/search_files;目录授权走 path_auth 独立层,
|
||||
// 不混入 risk_level——read_file 同样读内容+走 path_auth 但 Low。原 Med 过保守致每次搜索审批)。
|
||||
// BUG-260624-04:用户报"搜索代码也要授权",根因即此 Med 错标 + tool_display_hint 无 grep 条目
|
||||
// 致 reason fallback "创建操作"文案误导。降 Low + 补 hint 双修。
|
||||
// 注册顺序:read_file/list_directory 后,search_files 前(高频检索工具靠前)。
|
||||
let grep_schema = {
|
||||
let mut props = serde_json::Map::new();
|
||||
@@ -1679,7 +1682,7 @@ fn register_file_tools(
|
||||
registry.register(
|
||||
"grep", "跨文件内容搜索(grep -rn 模式)。参数:pattern(正则,大小写敏感,无特殊字符时等价字面包含)、path(搜索根,锚 workspace + path_auth 授权)、glob(可选文件名过滤如 *.rs)、output_mode(content/files_with_matches/count)、-n(行号默认 true)、-i(大小写不敏感默认 false)、-C(上下文行数默认 0)、max_results(上限默认 50)。跳过噪音目录/噪音文件/symlink/二进制文件。返回 matches(files_with_matches 模式)或 matches(含 file/line/content/context,content 模式)+ total + truncated。授权目录内放行,未授权触发目录授权申请(AiDirAuthRequired)",
|
||||
grep_schema,
|
||||
RiskLevel::Medium,
|
||||
RiskLevel::Low,
|
||||
{ let allowed_dirs = allowed_dirs.clone(); Box::new(move |args: serde_json::Value| {
|
||||
let allowed_dirs = allowed_dirs.clone();
|
||||
Box::pin(async move {
|
||||
@@ -2119,6 +2122,7 @@ pub(crate) fn tool_display_hint(name: &str) -> Option<&'static str> {
|
||||
"read_file" => Some("读取文件"),
|
||||
"list_directory" => Some("列出目录"),
|
||||
"search_files" => Some("搜索文件"),
|
||||
"grep" => Some("搜索代码内容"),
|
||||
"create_project" => Some("创建项目"),
|
||||
"update_project" => Some("修改项目"),
|
||||
"delete_project" => Some("删除项目"),
|
||||
|
||||
Reference in New Issue
Block a user