| 204 | } |
| 205 | |
| 206 | fn format_todos_from_data(todos: &[TodoItemData]) -> String { |
| 207 | if todos.is_empty() { |
| 208 | return "No todos in the list.".to_string(); |
| 209 | } |
| 210 | |
| 211 | let mut output = String::new(); |
| 212 | output.push_str("# Todo List\n\n"); |
| 213 | |
| 214 | for (i, todo) in todos.iter().enumerate() { |
| 215 | let status_icon = match todo.status.as_str() { |
| 216 | "in_progress" => "🔄", |
| 217 | "completed" => "✅", |
| 218 | _ => "⬜", |
| 219 | }; |
| 220 | |
| 221 | let priority_str = if !todo.priority.is_empty() { |
| 222 | format!(" [{}]", todo.priority) |
| 223 | } else { |
| 224 | String::new() |
| 225 | }; |
| 226 | |
| 227 | output.push_str(&format!( |
| 228 | "{} todo_{}{}\n {}\n\n", |
| 229 | status_icon, i, priority_str, todo.content |
| 230 | )); |
| 231 | } |
| 232 | |
| 233 | let pending = todos.iter().filter(|t| t.status == "pending").count(); |
| 234 | let in_progress = todos.iter().filter(|t| t.status == "in_progress").count(); |
| 235 | let completed = todos.iter().filter(|t| t.status == "completed").count(); |
| 236 | |
| 237 | output.push_str(&format!( |
| 238 | "Summary: {} pending, {} in progress, {} completed", |
| 239 | pending, in_progress, completed |
| 240 | )); |
| 241 | |
| 242 | output |
| 243 | } |
| 244 | |
| 245 | impl Default for TodoReadTool { |
| 246 | fn default() -> Self { |