stats: log per-request usage in session, add 'hx stats <session>' token report
ci / check (pull_request) Canceled after 0s
ci / check (push) Canceled after 0s

This commit is contained in:
hermes committed 2026-10-01 20:52:42 +00:00
1 parent 34dea8f9fd
commit 1c69c8ed34
5 files changed
+188 -2

No files matched your search

+6
View File
@@ -53,6 +53,8 @@ enum Cmd {
Login { provider: Kind },
/// Remove stored credentials for a provider.
Logout { provider: Kind },
/// Token report for a session file (usage, cache hit rate, costliest tool results).
Stats { session: std::path::PathBuf },
/// Connect to configured MCP servers and print tools + index/eager token cost.
Mcp,
/// Serve lens diagnostics + LSP navigation as an MCP server over stdio.
@@ -278,6 +280,10 @@ async fn main() -> Result<()> {
return Ok(());
}
Some(Cmd::Logout { provider }) => return Ok(auth::logout(provider)?),
Some(Cmd::Stats { session }) => {
print!("{}", hx_core::stats::report(&Session::open(session)?));
return Ok(());
}
Some(Cmd::Mcp) => {
let cwd = std::env::current_dir()?;
let hub = hx_mcp::Hub::start(