Skip to content

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

Open
fruwe wants to merge 2 commits intojunhoyeo:mainfrom
fruwe:main
Open

feat: add Goose (aaif-goose/goose) session scanner#457
fruwe wants to merge 2 commits intojunhoyeo:mainfrom
fruwe:main

Conversation

@fruwe
Copy link
Copy Markdown

@fruwe fruwe commented Apr 22, 2026

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.rsGoose = 18 entry in define_clients! macro
  • crates/tokscale-core/src/sessions/goose.rsNew SQLite parser
  • crates/tokscale-core/src/sessions/mod.rspub 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.

Written for commit d1ab5e5. Summary will update on new commits.

Parses token usage from Goose's SQLite sessions database at
~/.local/share/goose/sessions/sessions.db, with fallback support
for the legacy Block/goose path and  override.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tokscale Ignored Ignored Preview Apr 22, 2026 5:31am

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/tokscale-core/src/sessions/goose.rs">

<violation number="1" location="crates/tokscale-core/src/sessions/goose.rs:98">
P1: Token counters are read as `i32` from SQLite, which can overflow and cause row decode failures that silently drop sessions.</violation>

<violation number="2" location="crates/tokscale-core/src/sessions/goose.rs:147">
P2: `created_at` parsing is too narrow (RFC3339-only) and silently falls back to `0`, which can mis-bucket valid sessions into epoch/1970 when Goose stores SQLite TIMESTAMP values.</violation>
</file>

<file name="crates/tokscale-cli/src/commands/wrapped.rs">

<violation number="1" location="crates/tokscale-cli/src/commands/wrapped.rs:1372">
P2: Goose was added to client display-name mapping but not to `client_logo_url`, so Goose entries won’t get a logo in wrapped top-client rendering.</violation>
</file>

<file name="crates/tokscale-core/src/scanner.rs">

<violation number="1" location="crates/tokscale-core/src/scanner.rs:805">
P2: GOOSE_PATH_ROOT is not validated for empty/whitespace values, allowing accidental relative-path DB discovery from the current working directory.</violation>

<violation number="2" location="crates/tokscale-core/src/scanner.rs:815">
P2: Goose DB discovery uses `exists()` instead of `is_file()`, so non-regular paths can be accepted as SQLite DBs and cause avoidable downstream open/parse failures.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread crates/tokscale-core/src/sessions/goose.rs Outdated
Comment thread crates/tokscale-core/src/sessions/goose.rs Outdated
Comment thread crates/tokscale-cli/src/commands/wrapped.rs
Comment thread crates/tokscale-core/src/scanner.rs Outdated
Comment thread crates/tokscale-core/src/scanner.rs Outdated
@fruwe
Copy link
Copy Markdown
Author

fruwe commented Apr 22, 2026

Pushed a follow-up commit addressing all 5 review items (d1ab5e5):

  1. P1 — Token overflow: Changed token columns from i32i64 in goose.rs
  2. P2 — Timestamp parsing: Added parse_created_at() supporting RFC3339, SQLite %Y-%m-%d %H:%M:%S, and date-only formats, with 4 new unit tests
  3. P2 — Logo URL: Added "Goose" => Some("https://tokscale.ai/assets/logos/goose.png") to client_logo_url() in wrapped.rs
  4. P2 — GOOSE_PATH_ROOT validation: Empty/whitespace env values are now rejected before path construction
  5. P2 — exists()is_file(): All 5 Goose path checks in scanner.rs now use is_file() to reject directories

All 977 tests pass (347 + 83 + 544 + 3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add support for Goose (aaif-goose/goose)

1 participant