MCPcopy Create free account
hub / github.com/GCWing/BitFun / print_usage_report

Function print_usage_report

src/apps/cli/src/management.rs:210–243  ·  view source on GitHub ↗
(session_id: Option<&str>)

Source from the content-addressed store, hash-verified

208}
209
210pub 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
245pub async fn print_doctor() -> Result<bool> {
246 let workspace = std::env::current_dir().context("Failed to resolve current directory")?;

Callers 1

run_cliFunction · 0.85

Calls 8

try_get_path_manager_arcFunction · 0.85
contextMethod · 0.80
trimMethod · 0.80
cloneMethod · 0.45
is_emptyMethod · 0.45
list_sessionsMethod · 0.45

Tested by

no test coverage detected