Skip to content

feat(adapter): add antigravity agent source - #1487

Closed
sambitcreate wants to merge 3 commits into
ccusage:mainfrom
sambitcreate:adapter/antigravity
Closed

sambitcreate wants to merge 3 commits into
ccusage:mainfrom
sambitcreate:adapter/antigravity

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Jul 24, 2026 •

Copy link
Copy Markdown

Summary

Adds Google Antigravity (IDE + CLI) as a tracked agent source, exposed as ccusage antigravity daily|monthly|session and included in the unified all-agents report.

Usage is decoded fully offline from the local SQLite conversation databases under ~/.gemini/antigravity{,-cli,-ide,-backup}/conversations/*.db. Each gen_metadata row is a GeneratorMetadata protobuf decoded with a small hand-rolled wire reader, yielding per-generation input (fixed system prompt plus fresh), output, cache-read, and thinking tokens, a timestamp fallback chain (generation → session created-at → file mtime), and responseId dedup across databases. Opaque model ids (MODEL_PLACEHOLDER_*, gemini-3-flash-a/b/c, tier suffixes) resolve through an alias table to LiteLLM-priced names; unknown ids pass through. ANTIGRAVITY_DATA_DIR overrides the data roots.

Also embeds Gemini models in the committed models.dev pricing snapshot (KEEP filter extended; 317 → 448 entries) so offline cost calculation covers the gemini-3.6-flash and gemini-3.1-pro families that LiteLLM has not published yet. The codex auto-review fallbacks are regenerated from the same catalog, and the claude-opus-5 unknown-version test assertion moves to claude-opus-6 since the upstream catalog now prices it.

Testing

  • cargo test --workspace: 469 passed, 0 failed (28 new antigravity tests: decode, timestamp fallbacks, cross-DB dedup, alias mapping, path discovery, plus a skipped-when-absent smoke test against real data dirs)
  • cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --all -- --check: clean
  • bun test nix/models-dev-compact.test.ts: 7 passed
  • Verified against a real Antigravity installation: daily/monthly/session/JSON reports aggregate 23 days of usage (27.1M input / 1.19M output / 147.9M cache-read tokens) with correctly aliased models and computed costs

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Adds Antigravity as a new agent source with daily, monthly, and session reports, plus unified all-agents support. Usage is parsed offline from local SQLite conversation databases with model aliasing and cost calculation.

  • New Features

    • New commands: ccusage antigravity daily|monthly|session.
    • Reads from ~/.gemini/antigravity{,-cli,-ide,-backup}/conversations/*.db; override with ANTIGRAVITY_DATA_DIR.
    • Offline decode of gen_metadata protobufs to count input, output, cache-read, and thinking tokens; timestamp fallbacks and cross-DB responseId dedup.
    • Included in unified reports and JSON output; CLI help, config schema, and docs updated.
  • Dependencies

    • Embedded models.dev pricing snapshot now includes Gemini models for offline costs (e.g., gemini-3.6-flash, gemini-3.1-pro).
    • Extended keep filter to retain Gemini entries; adjusted tests where upstream pricing now covers claude-opus-5.

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

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added Antigravity as a supported data source.
    • Added daily, monthly, and session usage reports, including JSON output and filtering options.
    • Added automatic discovery of Antigravity conversation data, with support for custom data directories.
    • Included Antigravity in unified reports and progress displays.
    • Added configuration options and pricing support for Antigravity models.
  • Documentation

    • Added an Antigravity guide, CLI examples, configuration details, environment-variable instructions, and navigation links.

Track Google Antigravity IDE/CLI usage from local SQLite conversation
databases under ~/.gemini/antigravity{,-cli,-ide,-backup}. Each
gen_metadata row is decoded as a GeneratorMetadata protobuf with a
hand-rolled wire reader, yielding per-generation input (fixed system
prompt plus fresh), output, cache-read, and thinking tokens, a
timestamp fallback chain, and responseId dedup across databases.

Opaque model ids (MODEL_PLACEHOLDER_*, gemini-3-flash-a/b/c, tier
suffixes) resolve through an alias table to LiteLLM-priced names.
Adds the ccusage antigravity daily|monthly|session commands, unified
all-agents report integration, ANTIGRAVITY_DATA_DIR override, config
schema section, and fixture-backed parser/loader tests.
Add the antigravity guide page, VitePress sidebar entry, and update
the README and docs agent lists, environment variables, configuration,
and getting-started pages for the new source.
Extend the models.dev snapshot KEEP filter to Gemini so offline
pricing covers models LiteLLM has not published yet, notably the
gemini-3.6-flash and gemini-3.1-pro families reported by Antigravity.
Regenerate the committed snapshot (317 to 448 entries) and the codex
auto-review fallbacks from the same catalog. The claude-opus-5
unknown-version test assertion moves to claude-opus-6 because the
upstream catalog now prices claude-opus-5.
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1345850b-1c70-41f8-8ec0-608513972c40

📥 Commits

Reviewing files that changed from the base of the PR and between 739e88f and c58c1b3.

⛔ Files ignored due to path filters (2)
  • rust/crates/ccusage-cli/src/snapshots/ccusage_cli__tests__root_help.snap is excluded by !**/*.snap
  • rust/crates/ccusage/src/snapshots/ccusage__config_schema__tests__snapshots_schema_agent_specific_option_edges.snap is excluded by !**/*.snap
📒 Files selected for processing (32)
  • apps/ccusage/README.md
  • apps/ccusage/config-schema.json
  • docs/.vitepress/config.ts
  • docs/guide/all-reports.md
  • docs/guide/antigravity/index.md
  • docs/guide/config-files.md
  • docs/guide/configuration.md
  • docs/guide/environment-variables.md
  • docs/guide/getting-started.md
  • docs/guide/index.md
  • docs/guide/source-support-qa.md
  • docs/index.md
  • nix/models-dev-gen.ts
  • rust/crates/ccusage-cli/src/cli-commands.json
  • rust/crates/ccusage-cli/src/parser.rs
  • rust/crates/ccusage-cli/src/tests.rs
  • rust/crates/ccusage-cli/src/types.rs
  • rust/crates/ccusage/src/adapter/all/loader.rs
  • rust/crates/ccusage/src/adapter/all/report.rs
  • rust/crates/ccusage/src/adapter/antigravity/README.md
  • rust/crates/ccusage/src/adapter/antigravity/loader.rs
  • rust/crates/ccusage/src/adapter/antigravity/mod.rs
  • rust/crates/ccusage/src/adapter/antigravity/parser.rs
  • rust/crates/ccusage/src/adapter/antigravity/paths.rs
  • rust/crates/ccusage/src/adapter/antigravity/proto.rs
  • rust/crates/ccusage/src/adapter/antigravity/report.rs
  • rust/crates/ccusage/src/adapter/mod.rs
  • rust/crates/ccusage/src/config_schema.rs
  • rust/crates/ccusage/src/main.rs
  • rust/crates/ccusage/src/models-dev-pricing.json
  • rust/crates/ccusage/src/pricing.rs
  • rust/crates/ccusage/src/progress.rs

📝 Walkthrough

Walkthrough

Antigravity support is added across the Rust CLI, configuration schema, SQLite/protobuf data adapter, report generation, pricing snapshots, progress reporting, tests, and user documentation.

Changes

Antigravity support

Layer / File(s) Summary
CLI and configuration wiring
rust/crates/ccusage-cli/..., rust/crates/ccusage/..., apps/ccusage/config-schema.json
Adds Antigravity commands, parser handling, configuration sections, adapter registration, dispatch, progress labels, and validation tests.
Database discovery and entry decoding
rust/crates/ccusage/src/adapter/antigravity/...
Discovers configured conversation databases, decodes protobuf-like metadata, derives session context, applies token semantics, deduplicates records, and validates loading behavior.
Antigravity report generation
rust/crates/ccusage/src/adapter/antigravity/mod.rs, report.rs, main.rs
Loads entries, summarizes daily/weekly/monthly/session views, renders reports, and tests daily JSON output.
Offline pricing coverage
nix/models-dev-gen.ts, rust/crates/ccusage/src/models-dev-pricing.json, rust/crates/ccusage/src/pricing.rs
Expands model filtering and updates the embedded pricing snapshot for Gemini, Claude Opus 5, Cline Pass, Databricks, and related models.
Source documentation and navigation
apps/ccusage/README.md, docs/...
Documents Antigravity support, commands, data paths, configuration, environment variables, report views, and navigation links.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: ryoppippi, pullfrog

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — adds Google Antigravity as a tracked agent source with CLI commands, all-agent integration, custom protobuf decoding, and regenerated pricing snapshot with Gemini model coverage.

  • Add adapter/antigravity module — loader, parser, proto wire-format reader, paths, report, and mod.rs entry point. Decodes usage from local SQLite conversation databases under ~/.gemini/antigravity* (four roots: antigravity, antigravity-cli, antigravity-ide, antigravity-backup). ANTIGRAVITY_DATA_DIR overrides with comma-separated roots.
  • Custom protobuf decoder (proto.rs) — varint, fixed64, length-delimited, and fixed32 wire types; groups terminate parsing; truncated input stops iteration cleanly. Decodes GeneratorMetadata (model id, timestamp, token counts, responseId) and trajectory_metadata_blob (session created-at, workspace URI).
  • Model alias mapping (resolve_model_name, case-insensitive) — maps Antigravity opaque ids (MODEL_PLACEHOLDER_M16 → gemini-3.1-pro), tier-suffixed Gemini names, and thinking variants to LiteLLM-priced canonical names. Unknown ids pass through unchanged.
  • Timestamp fallback chain — generation timestamp → session created-at → file mtime. Nanos validation rejects out-of-range values. responseId dedup across all databases, first-occurrence-wins by root path order. All-zero token generations are skipped.
  • CLI plumbing — Antigravity command variant, parse_basic_agent_command, standard report dispatch, help entries, root help snapshot, CLI command test.
  • All-agent integration — BUILT_IN_AGENT_NAMES entry, AgentLoadSpec at index 15 in load_base_rows, agent_label in all-agent report, UsageLoadAgent::Antigravity in progress tracking.
  • Config schema — AntigravityConfig with defaults and commands, regenerated config-schema.json with antigravity properties, schema edge test asserting no openClawPath leak.
  • Pricing snapshot regeneration — KEEP filter extended with gemini in models-dev-gen.ts (317→448 entries). Upstream catalog churn: new claude-opus-5 entries, gemini-* model entries, databricks-gemini-*, cline-pass/kimi-*; removed claude-opus-4-7-fast and global.anthropic.* entries. Test assertion for unknown-version model moves from claude-opus-5 to claude-opus-6.
  • Documentation — new docs/guide/antigravity/index.md with full source docs, env-var table, getting-started paths, config-files namespaces, all-reports table row, VitePress navigation, docs index tagline/features, README agent table and bunx example. Source-support Q&A removes the "Antigravity not supported" entry.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

ryoppippi added a commit that referenced this pull request Aug 3, 2026
…#1569)

revert: "feat(antigravity): add Antigravity CLI usage adapter (#1544)"

This reverts commit 50614f1.

Temporary, so that v20.0.20 does not ship a half-finished adapter. The
intent is to reapply Antigravity support, not to drop it — see #1488.

#1544 landed while the contribution proposal in #1488 was still open, and
it covers less ground than @sambitcreate's #1487:

- It reads only `~/.gemini/antigravity-cli`, missing `antigravity`,
  `antigravity-ide` and `antigravity-backup`, so IDE users get nothing.
- Opaque model ids stay as `antigravity-model-<id>` with no alias table,
  so they cannot be priced and cost is silently understated.
- The offline pricing snapshot has no Gemini rates, so `--offline`
  reports no cost for Gemini models.
- It was validated against three chat turns in one CLI conversation.
- Retries, subagents and model comparison ship unexercised.

The first three are already solved in #1487, which is the better base to
build on. Reverting now keeps the release clean while that is sorted out,
and costs nothing: the adapter has not been released, so no user has it.

Nothing about the reverse engineering is lost. The recovered field numbers
and the reasoning behind the dedupe are written up in #1488.
@github-actions github-actions Bot mentioned this pull request Aug 3, 2026
@ryoppippi ryoppippi added the triage:needs-review Requires a fresh technical or product decision. label Aug 31, 2026
@ryoppippi

Copy link
Copy Markdown
Member

Historical audit: this pull request was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

Audit result: needs review. The current state does not prove resolution, but a fresh technical or product check is required before deciding whether the underlying request is still relevant. This closed PR will not be revived as-is; create a new PR only after reviewing the related issue and current main.

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

Labels

triage:needs-review Requires a fresh technical or product decision.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants