replace artifact heuristics/regexes with protocol messages (#8996)

This commit is contained in:
Jack Amadeo
2026-05-04 15:00:22 -04:00
committed by GitHub
parent 4a443feae8
commit ebe3315bdd
26 changed files with 484 additions and 2208 deletions
+8 -16
View File
@@ -367,14 +367,6 @@ fn get_requested_line(arguments: Option<&rmcp::model::JsonObject>) -> Option<u32
.map(|l| l as u32)
}
fn create_tool_location(path: &str, line: Option<u32>) -> ToolCallLocation {
let mut loc = ToolCallLocation::new(path);
if let Some(l) = line {
loc = loc.line(l);
}
loc
}
fn is_developer_file_tool(tool_name: &str) -> bool {
matches!(tool_name, "read" | "write" | "edit")
}
@@ -391,7 +383,7 @@ fn extract_locations_from_meta(
.filter_map(|entry| {
let path = entry.get("path")?.as_str()?;
let line = entry.get("line").and_then(|v| v.as_u64()).map(|l| l as u32);
Some(create_tool_location(path, line))
Some(ToolCallLocation::new(path).line(line))
})
.collect::<Vec<_>>();
if locations.is_empty() {
@@ -422,12 +414,12 @@ fn extract_tool_locations(
if let Some(path_str) = path_str {
if matches!(tool_name, "read") {
let line = get_requested_line(tool_call.arguments.as_ref());
locations.push(create_tool_location(path_str, line));
locations.push(ToolCallLocation::new(path_str).line(line));
return locations;
}
if matches!(tool_name, "write" | "edit") {
locations.push(create_tool_location(path_str, Some(1)));
locations.push(ToolCallLocation::new(path_str).line(1));
return locations;
}
@@ -447,19 +439,19 @@ fn extract_tool_locations(
let line = extract_view_line_range(text)
.map(|range| range.0 as u32)
.or(Some(1));
locations.push(create_tool_location(path_str, line));
locations.push(ToolCallLocation::new(path_str).line(line));
}
Some("str_replace") | Some("insert") => {
let line = extract_first_line_number(text)
.map(|l| l as u32)
.or(Some(1));
locations.push(create_tool_location(path_str, line));
locations.push(ToolCallLocation::new(path_str).line(line));
}
Some("write") => {
locations.push(create_tool_location(path_str, Some(1)));
locations.push(ToolCallLocation::new(path_str).line(1));
}
_ => {
locations.push(create_tool_location(path_str, Some(1)));
locations.push(ToolCallLocation::new(path_str).line(1));
}
}
break;
@@ -468,7 +460,7 @@ fn extract_tool_locations(
}
if locations.is_empty() {
locations.push(create_tool_location(path_str, Some(1)));
locations.push(ToolCallLocation::new(path_str).line(1));
}
}
}