feat: add Goose (aaif-goose/goose) session scanner

Merged
FR
6mo ago
+371-5

Summary

  • Adds support for Goose (aaif-goose/goose), an open-source AI coding agent with 43k+ stars, now part of the Agentic AI Foundation (AAIF) at the Linux Foundation.
  • Parses token usage from Goose's SQLite sessions.db, extracting model name from model_config_json, provider from provider_name, and accumulated token counts per session.

Data Location

The scanner checks multiple paths in order:

  1. $GOOSE_PATH_ROOT/data/sessions/sessions.db (env var override)
  2. ~/.local/share/goose/sessions/sessions.db (aaif-goose fork, primary)
  3. ~/Library/Application Support/goose/sessions/sessions.db (macOS)
  4. ~/Library/Application Support/Block/goose/sessions/sessions.db (legacy Block/goose macOS)
  5. ~/.local/share/Block/goose/sessions/sessions.db (legacy Block/goose Linux)

Files Changed

  • crates/tokscale-core/src/clients.rs — Goose = 18 entry in define_clients! macro
  • crates/tokscale-core/src/sessions/goose.rs — New SQLite parser
  • crates/tokscale-core/src/sessions/mod.rs — pub mod goose
  • crates/tokscale-core/src/scanner.rs — DB discovery with multi-path fallback
  • crates/tokscale-core/src/lib.rs — Parser wiring in both parse paths
  • crates/tokscale-cli/src/main.rs — --goose CLI flag
  • crates/tokscale-cli/src/tui/client_ui.rs — TUI entry with hotkey o
  • crates/tokscale-cli/src/tui/ui/widgets.rs — Goose color
  • crates/tokscale-cli/src/tui/data/mod.rs — Client count update
  • crates/tokscale-cli/src/commands/wrapped.rs — Display name mapping

Closes #456


Summary by cubic

Adds a Goose session scanner to track token usage from Goose’s SQLite sessions.db, with multi-path discovery and pricing. Adds CLI and TUI support for filtering and viewing Goose sessions; closes #456.

  • New Features

    • Parses model from model_config_json, provider from provider_name, and accumulated input/output/total tokens per session; infers reasoning tokens when present.
    • DB discovery order: $GOOSE_PATH_ROOT/data/sessions/sessions.db, ~/.local/share/goose/sessions/sessions.db, ~/Library/Application Support/goose/sessions/sessions.db, plus legacy Block paths.
    • Integrates Goose into tokscale-core parsing and pricing; updates client registry and counts.
    • Adds --goose filter in tokscale-cli, TUI entry with hotkey o, display name mapping, color, and logo URL.
  • Bug Fixes

    • Uses i64 for token counts to prevent overflow.
    • More robust timestamp parsing (RFC3339, SQLite formats) with correct ms conversion.
    • Validates discovered paths with is_file to avoid false positives.