use super::tool::{HematiteTool, RiskLevel};
use serde_json::Value;
#[allow(dead_code)]
pub struct FileEditTool;
impl HematiteTool for FileEditTool {
fn name(&self) -> &'static str {
"file_edit"
}
fn description(&self) -> &'static str {
"Securely edits specific strings and blocks within a codebase file using precise line-hunk replacements safely bypassing token overload."
}
fn risk_level(&self, _args: &Value) -> RiskLevel {
RiskLevel::Moderate }
fn estimate_token_cost(&self, _payload: &Value) -> usize {
100 }
fn security_audit(&self, args: &Value) -> Result<(), String> {
let path_str = args.get("path").and_then(|v| v.as_str()).unwrap_or("");
let workspace =
std::env::current_dir().map_err(|e| format!("Workspace Env Error: {}", e))?;
let target = std::path::Path::new(path_str);
super::guard::path_is_safe(&workspace, target)?;
Ok(())
}
fn dry_run(&self, payload: Value) -> Result<String, String> {
Ok(format!(
"Proposed text replacement mapping evaluated smoothly via HUNK logic: {:?}",
payload
))
}
fn run(&self, _payload: Value) -> Result<String, String> {
Ok("Exact string blocks flawlessly line-replaced in text.".into())
}
}