deepseek_rust_cli/tools/file/
diff.rs1use std::{collections::HashMap, path::Path};
2
3use anyhow::Result;
4use async_trait::async_trait;
5use serde_json::Value;
6
7use crate::{agent::types::UndoAction, tools, tools::base::Tool};
8
9pub struct DiffFilesTool;
10#[async_trait]
11impl Tool for DiffFilesTool {
12 fn name(&self) -> &str {
13 "diff_files"
14 }
15 async fn execute(
16 &self,
17 args: &HashMap<String, Value>,
18 _undo: &mut Vec<UndoAction>,
19 _cwd: Option<&Path>,
20 ) -> Result<String> {
21 let f1 = args
22 .get("file1")
23 .and_then(|v| v.as_str())
24 .ok_or_else(|| anyhow::anyhow!("Missing 'file1'"))?;
25 let f2 = args
26 .get("file2")
27 .and_then(|v| v.as_str())
28 .ok_or_else(|| anyhow::anyhow!("Missing 'file2'"))?;
29 tools::file_ops::diff_files(f1, f2).await
30 }
31}