ararajuba_tools_coding/git/
clone.rs1use ararajuba_core::tools::tool::{tool, ToolDef};
4use git2::Repository;
5use serde_json::json;
6
7pub fn git_clone_tool() -> ToolDef {
11 tool("git_clone")
12 .description("Clone a git repository from a URL.")
13 .input_schema(json!({
14 "type": "object",
15 "properties": {
16 "url": { "type": "string", "description": "Repository URL to clone" },
17 "path": { "type": "string", "description": "Local directory to clone into" }
18 },
19 "required": ["url", "path"]
20 }))
21 .execute(|input| async move {
22 let url = input["url"]
23 .as_str()
24 .ok_or_else(|| "missing required field: url".to_string())?;
25 let path = input["path"]
26 .as_str()
27 .ok_or_else(|| "missing required field: path".to_string())?;
28
29 Repository::clone(url, path)
30 .map_err(|e| format!("clone failed: {e}"))?;
31
32 Ok(json!({ "ok": true }))
33 })
34 .build()
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn tool_metadata() {
43 let t = git_clone_tool();
44 assert_eq!(t.name, "git_clone");
45 assert!(t.execute.is_some());
46 }
47}