terminal_jarvis/api/
api_tool_operations.rs1#![allow(dead_code)]
2
3use crate::api::api_client::ApiClient;
10use anyhow::Result;
11use std::collections::HashMap;
12
13pub struct ToolApi {
15 #[allow(dead_code)]
16 client: ApiClient,
17}
18
19impl Default for ToolApi {
20 fn default() -> Self {
21 Self::new()
22 }
23}
24
25impl ToolApi {
26 pub fn new() -> Self {
27 Self {
28 client: ApiClient::new(),
29 }
30 }
31
32 pub async fn get_tool_description(&self, tool: &str) -> Result<String> {
34 let descriptions = self.get_tool_descriptions().await?;
35 Ok(descriptions
36 .get(tool)
37 .cloned()
38 .unwrap_or_else(|| "No description available".to_string()))
39 }
40
41 async fn get_tool_descriptions(&self) -> Result<HashMap<String, String>> {
43 let mut descriptions = HashMap::new();
46 descriptions.insert(
47 "claude-code".to_string(),
48 "Anthropic's Claude for code assistance".to_string(),
49 );
50 descriptions.insert(
51 "gemini-cli".to_string(),
52 "Google's Gemini CLI tool".to_string(),
53 );
54 descriptions.insert("qwen-code".to_string(), "Qwen coding assistant".to_string());
55 descriptions.insert(
56 "opencode".to_string(),
57 "Open-source coding tool".to_string(),
58 );
59
60 Ok(descriptions)
61 }
62
63 pub async fn check_tool_availability(&self, tool: &str) -> Result<bool> {
65 let supported_tools = ["claude-code", "gemini-cli", "qwen-code", "opencode"];
68 Ok(supported_tools.contains(&tool))
69 }
70
71 pub async fn get_tool_metadata(&self, tool: &str) -> Result<ToolMetadata> {
73 let descriptions = self.get_tool_descriptions().await?;
74 let description = descriptions.get(tool).cloned().unwrap_or_default();
75
76 Ok(ToolMetadata {
77 name: tool.to_string(),
78 description,
79 version: "latest".to_string(),
80 homepage: format!("https://github.com/example/{tool}"),
81 })
82 }
83}
84
85#[derive(Debug, Clone)]
86pub struct ToolMetadata {
87 pub name: String,
88 pub description: String,
89 pub version: String,
90 pub homepage: String,
91}