Skip to content

feat(insights): add Antigravity CLI usage support - #120

Merged
GaganSD merged 7 commits into
GaganSD:mainfrom
e2720pjk:feat/agy-usage-support
Nov 5, 2026
Merged

GaganSD merged 7 commits into
GaganSD:mainfrom
e2720pjk:feat/agy-usage-support

Conversation

@e2720pjk

@e2720pjk e2720pjk commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Hi ~ Thanks for creating Insights. I use agy myself, so I added support for it.
It’s been working well for me, and I thought I’d share it in case others find it useful.
Happy to have this merged if you think it’s a good fit!

截圖 2026-11-05 下午5 28 32

Summary

  • Add local Antigravity CLI token-usage collection to Herdr Insights.
  • Prefer SQLite generation metadata for model attribution and complete input
    accounting, with compact transcript exports as a fallback.

What

  • Add a bounded protobuf decoder and read-only SQLite scanner in
    core/antigravity.mjs, with schema/accounting notes alongside the code.
  • Select one authoritative file per conversation, detect DB/WAL changes,
    deduplicate response IDs, and retain accepted history when replacement fails
    or stops before completion.
  • Add Antigravity to collector and UI defaults, with conservative migration of
    untouched previous defaults. Update the README's source/privacy lines and the
    rebuild recipe; keep implementation details out of the README.
  • Add synthetic regression coverage without shipping personal session data,
    additional dependencies, benchmark tooling or UI redesigns.

Why

Compact transcript exports alone omit generation model IDs and can omit system
input tokens. The conversation database contains generation-level usage and model
metadata. Reading it locally uses the existing collector/store contracts without
requiring authentication, a running agent service or network access.

Testing

Validated commit c4bb8b0 on macOS 26.6.1 (arm64). Package and tooling checks used
Node.js 24.22.2 and npm 12.0.0. No source, lockfile or test changes were needed.

Insights runtime matrix

Ran the underlying test:insights and check:insights commands with each runtime:

Node.js Tests Distribution checks
22.15.0 233 passed, 3 skipped, 0 failed Passed
22.23.4 233 passed, 3 skipped, 0 failed Passed
24.22.2 233 passed, 3 skipped, 0 failed Passed

The three skips are conditional alternate-runtime tests: a runtime without zstd
and two installer/uninstaller checks requiring a discoverable older Node.

Package regression checks

The repository's change detector selects all five Pi packages for this PR.
For each package, npm ci --ignore-scripts --no-audit --no-fund, lint,
typecheck, test:unit, test:integration and build completed successfully.
Builds included tarball validation, clean-consumer installation and Pi
registration checks; nothing was published.

Package Unit tests Integration tests Lint / types / build
pi-ask 120 passed 31 passed Passed
pi-automode 33 passed 22 passed Passed
pi-slate 531 passed, 1 skipped 90 passed Passed
pi-subagents 148 passed 25 passed Passed
pi-web-search 391 passed 45 passed Passed

Slate's skipped test requires an operator host that is not installed in this
environment.

Compatibility

  • No new dependencies, permissions, network calls or authentication flow. SQLite
    uses the existing Node runtime requirement and is opened read-only.
  • Default roots are ~/.gemini/antigravity-cli/conversations and
    ~/.gemini/antigravity-cli/brain; both appear under Antigravity in Settings.
  • Only exact, untouched three-source or four-source legacy defaults are upgraded.
    Customized/disabled/reordered/empty source lists remain unchanged; those users
    can add the antigravity adapter through the existing configuration editor.
  • This does not decode retired Gemini CLI history or Antigravity IDE .pb stores.
    Compact transcript fallback retains unknown metadata when it is absent.

Risk

  • The protobuf schema is reverse-engineered, not a stable vendor API. Mapping and
    reference links live in the scanner header. Malformed/oversized records are
    skipped with diagnostics; schema changes can therefore reduce reported usage.
  • Thinking is included in output, not added twice. Prefilled system-only records
    without measured usage are excluded. Provider denotes the model publisher,
    not the billing gateway; this does not estimate charges or account limits.
  • Step timestamps are used only when their response IDs match. Otherwise daily
    attribution falls back to session creation time, then DB mtime, with a note.
  • Missing response IDs fall back to conversation/generation identity with a note.
    SQLite takes precedence over exports; configured source/root order selects
    among copies of the same kind. Divergent copies are not merged.
  • Database and transcript refreshes are atomic and roll back on read errors,
    cancellation or deadline. Files exceeding a foreground slice use the existing
    background indexer; this adds no worker or protobuf-row checkpoint.

Checklist

  • The change is focused; unrelated changes are excluded.
  • Tests cover behavior changes, or the testing section explains why not.
  • Relevant documentation is updated, or no documentation changes are needed.

Read local generation metadata from Antigravity conversation databases, with canonical compact transcripts as a fallback. Keep input, cached input, output and thinking accounting separate and deduplicate copies.

Register Antigravity in collector and UI defaults. Migrate only untouched previous default source lists; preserve customized configurations.

Keep DB and transcript replacements atomic on errors and interrupted reads. Reuse the existing indexer for budget-limited scans without changing other adapters' read behavior.

Cover decoding, read-only access, privacy, WAL invalidation, fallback replacement, interrupted scans and source migration with synthetic tests.
Remove the unreachable varint fallback and duplicate length and metadata checks. The uint64 guard, remaining-buffer bound and checked metadata caller already cover these cases.
@GaganSD

GaganSD commented Nov 5, 2026

Copy link
Copy Markdown
Owner

@greptile-apps review

@GaganSD
GaganSD merged commit 650e8c4 into GaganSD:main Nov 5, 2026
13 checks passed
@GaganSD

GaganSD commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR, merged!

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.

3 participants