(session_id: Option<&str>)
| 208 | } |
| 209 | |
| 210 | pub async fn print_usage_report(session_id: Option<&str>) -> Result<()> { |
| 211 | let agentic_system = crate::agent::agentic_system::init_agentic_system_for_cli().await?; |
| 212 | let path_manager = try_get_path_manager_arc().map_err(|error| anyhow!(error.to_string()))?; |
| 213 | let persistence_manager = |
| 214 | PersistenceManager::new(path_manager).map_err(|error| anyhow!(error.to_string()))?; |
| 215 | let workspace_path = std::env::current_dir().context("Failed to resolve current directory")?; |
| 216 | let coordinator = agentic_system.coordinator.clone(); |
| 217 | let resolved_session_id = match session_id { |
| 218 | Some(session_id) if !session_id.trim().is_empty() => session_id.to_string(), |
| 219 | _ => coordinator |
| 220 | .list_sessions(&workspace_path) |
| 221 | .await? |
| 222 | .first() |
| 223 | .map(|session| session.session_id.clone()) |
| 224 | .ok_or_else(|| anyhow!("No history sessions for current project"))?, |
| 225 | }; |
| 226 | |
| 227 | let report = generate_session_usage_report( |
| 228 | &persistence_manager, |
| 229 | Some(agentic_system.token_usage_service.as_ref()), |
| 230 | SessionUsageReportRequest { |
| 231 | session_id: resolved_session_id, |
| 232 | workspace_path: Some(workspace_path.to_string_lossy().to_string()), |
| 233 | remote_connection_id: None, |
| 234 | remote_ssh_host: None, |
| 235 | include_hidden_subagents: true, |
| 236 | }, |
| 237 | ) |
| 238 | .await |
| 239 | .map_err(|error| anyhow!(error.to_string()))?; |
| 240 | |
| 241 | println!("{}", render_usage_report_markdown(&report)); |
| 242 | Ok(()) |
| 243 | } |
| 244 | |
| 245 | pub async fn print_doctor() -> Result<bool> { |
| 246 | let workspace = std::env::current_dir().context("Failed to resolve current directory")?; |
no test coverage detected