claude_rust_tools/infrastructure/
todo_read_tool.rs1use claude_rust_errors::AppResult;
2use claude_rust_types::{PermissionLevel, Tool};
3use serde_json::{Value, json};
4
5use super::todo_store::read_todos;
6
7pub struct TodoReadTool;
8
9#[async_trait::async_trait]
10impl Tool for TodoReadTool {
11 fn name(&self) -> &str {
12 "todo_read"
13 }
14
15 fn description(&self) -> &str {
16 "Read the current task list to check pending, in-progress, and completed tasks."
17 }
18
19 fn input_schema(&self) -> Value {
20 json!({
21 "type": "object",
22 "properties": {}
23 })
24 }
25
26 fn permission_level(&self) -> PermissionLevel {
27 PermissionLevel::ReadOnly
28 }
29
30 async fn execute(&self, _input: Value) -> AppResult<String> {
31 let todos = read_todos();
32 if todos.is_empty() {
33 return Ok("No todos.".into());
34 }
35 let mut out = String::new();
36 for t in &todos {
37 let icon = match t.status.as_str() {
38 "completed" => "✓",
39 "in_progress" => "→",
40 _ => "○",
41 };
42 let pri = match t.priority.as_str() {
43 "high" => "[!]",
44 "medium" => "[~]",
45 _ => "[ ]",
46 };
47 out.push_str(&format!("{icon} {pri} [{}] {}\n", t.id, t.content));
48 }
49 Ok(out.trim_end().to_string())
50 }
51}