Skip to content

Add Antigravity backend (producer + statusline) — replaces Gemini [WIP]#3

Open
pkyIntelligence wants to merge 4 commits into
mainfrom
feat/antigravity-backend
Open

Add Antigravity backend (producer + statusline) — replaces Gemini [WIP]#3
pkyIntelligence wants to merge 4 commits into
mainfrom
feat/antigravity-backend

Conversation

@pkyIntelligence
Copy link
Copy Markdown
Owner

Summary

Migrates the Gemini backend → Antigravity (agy CLI), which Google is replacing gemini-cli with (gemini-cli deprecates ~2026-06-18). This is a checkpoint PR: the usage-pressure dashboard half is done and verified end-to-end; delegation, routing-policy prose, docs, and removal of the old gemini files remain (see plan / checklist below).

The user's primary use of tokenmaxxer is the dashboard, so that was built and verified first.

The hard part: where the quota actually lives

Antigravity's real Pro quota is only exposed by its local language server — the cloud Code Assist APIs report free-tier / null for this account (the Pro plan is a Codeium/Windsurf entitlement invisible to Google's GCA cloud view). The credit-view gRPC endpoint (aicode.googleapis.com … FetchQuotaStatus) needs an auth/aicode-scoped token agy mints through a channel a standalone hook can't reproduce.

So the producer queries the local language server over Connect-RPC (GetUserStatus) on a loopback port using the process's own CSRF token — no credentials handled. (Approach validated against the public skainguyen1412/antigravity-usage / wusimpl/AntigravityQuotaWatcher tools.)

Two provider buckets are surfaced, matching what agy /usage shows:

  • ag-gem — Google-internal models (Gemini 3.x)
  • ag-ext — outside-Google (Claude Opus/Sonnet 4.6, GPT-OSS)

Each is a weekly rate cap (paced like the old gemini cells). Prompt/flow credit meters are captured for /tokenmaxxer:status but not rendered — the API exposes no reset for them, so they can't be paced.

What's in this PR

Producer (new):

  • hooks/refresh-antigravity.sh — local-server query + sidecar build; opportunistic (fresh when agy is running, else agy_not_running/fetch_failed preserving prior buckets so the statusline dims rather than blanks).

Consumer + wiring:

  • scripts/statusline.sh — gemini cell-kind → antigravity (provider buckets, ag-gem/ag-ext, WEEK_S pacing, 5h=gemini / 7d=ext, monthly slot dropped).
  • hooks/hooks.json — SessionStart → refresh-antigravity.sh.
  • hooks/refresh-stale-sidecars.sh, hooks/usage-sidecars.sh, hooks/nudge-on-reset.sh — repointed to the antigravity sidecar / buckets.

Reverse-engineering harness: debug_scripts/ (local-server probe, mitmproxy/transparent capture). No secrets committed; .gitignore excludes the agy workspace file, pycache, and stray payload captures.

Verification

Live render (real data):

5h  …  ag-gem ┃░░░░░░░░░   0% (6d23h)   copilot chat …
7d  …  ag-ext ┃▓░░░░░░░░  20% (6d23h)
  • All edited shell files pass bash -n; hooks.json valid.
  • Producer parses real GetUserStatus into 2 buckets.
  • Statusline renders ag-gem/ag-ext and exits 0 on populated, empty-buckets, and missing-sidecar paths.

Remaining (follow-up — tracked in plan)

  • Routing/status/telemetry prose: skills/route.md §2.4 (weekly window), commands/status.md, skills/check-usage.md, commands/route.md
  • Delegation: scripts/antigravity-run.sh, commands/antigravity.md, agents/antigravity-run.md
  • Docs: new docs/backends/antigravity.md; update facts.md, README, SECURITY, CLAUDE.md
  • Delete old gemini files (hooks/refresh-gemini.sh, hooks/gemini-quota-payload.jq, scripts/gemini-run.sh, commands/gemini.md, agents/gemini-run.md, docs/backends/gemini.md)
  • Final live verify (--plugin-dir restart, /tokenmaxxer:setup)

🤖 Generated with Claude Code

pkyIntelligence and others added 4 commits May 29, 2026 18:48
Migrate the Gemini backend toward Antigravity (agy CLI), which Google is
replacing gemini-cli with. This checkpoint lands the usage-pressure dashboard
half end-to-end; delegation, routing-policy prose, docs, and removal of the old
gemini files remain (tracked in the plan).

Quota source (reverse-engineered): Antigravity's real Pro quota is exposed only
by its local language server (cloud Code Assist APIs report free-tier/null for
this account). The producer queries that server over Connect-RPC
(GetUserStatus) on a loopback port using the process's CSRF token — no
credentials handled. Two provider buckets are surfaced: "gemini" (Google
internal models) and "ext" (outside Google: Claude Opus/Sonnet 4.6, GPT-OSS),
each a weekly rate cap. Prompt/flow credit meters are captured for
/tokenmaxxer:status but not rendered (the API exposes no reset, so they cannot
be paced).

Producer (new):
- hooks/refresh-antigravity.sh — local-server query + sidecar build; opportunistic
  (status ok when agy is running, else agy_not_running/fetch_failed preserving
  prior buckets so the statusline dims rather than blanks). No set -euo pipefail.

Consumer + wiring:
- scripts/statusline.sh — migrate the gemini cell-kind to antigravity: new
  .buckets[] loader (provider/used_percent/resets_at), ag-gem/ag-ext labels,
  weekly (WEEK_S) pacing, 5h=gemini / 7d=ext slots (monthly slot dropped).
- hooks/hooks.json — SessionStart runs refresh-antigravity.sh.
- hooks/refresh-stale-sidecars.sh — mid-session refresh for the antigravity sidecar.
- hooks/usage-sidecars.sh — TMX_ANTIGRAVITY_SIDECAR + antigravity bucket TSV and
  context lines.
- hooks/nudge-on-reset.sh — antigravity weekly buckets with friendly route names.

Verified: all edited shell files pass bash -n; hooks.json valid; producer parses
real data into 2 buckets; statusline renders ag-gem/ag-ext and exits 0 on
populated, empty, and missing-sidecar paths.

debug_scripts/ contains the reverse-engineering harness (local-server probe,
mitmproxy/transparent capture). No secrets committed; .gitignore excludes the
agy workspace file, pycache, and stray payload captures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…te Gemini

Finish the Gemini → Antigravity backend migration begun in the previous commit.

Delegation (new):
- scripts/antigravity-run.sh — agy -p harness; model comes from
  ~/.gemini/antigravity-cli/settings.json (agy has no -m flag), kill switch
  TOKENMAXXER_ANTIGRAVITY_DISABLED, --dangerously-skip-permissions for
  non-interactive tool use.
- commands/antigravity.md, agents/antigravity-run.md — thin wrappers.

Routing / telemetry prose repointed to Antigravity (weekly buckets, agy session
readiness, antigravity-run dispatch):
- skills/route.md, commands/route.md (allowed-tools now references
  antigravity-run.sh, not the deleted gemini-run.sh), skills/check-usage.md,
  commands/status.md, commands/setup.md.

Docs:
- New docs/backends/antigravity.md (local-language-server quota source, two
  weekly provider buckets, opportunistic freshness, kill switch).
- docs/backends/facts.md, README.md, SECURITY.md, docs/setup.md, docs/ui.md,
  CONTRIBUTING.md, docs/claude-code-customization.md updated.
- scripts/setup-statusline.py: seed/summary helpers migrated to the antigravity
  sidecar + provider-bucket schema (py_compile clean).

Deletions (old Gemini backend):
- hooks/refresh-gemini.sh, hooks/gemini-quota-payload.jq, scripts/gemini-run.sh,
  commands/gemini.md, agents/gemini-run.md, docs/backends/gemini.md.

Housekeeping:
- .gitignore excludes .antigravitycli/ (now untracked).
- debug_scripts/_migrate_gemini_refs.py records the prose migration.

Remaining "gemini" references are intentional: the provider-bucket label
"gemini" (Antigravity's Google-internal model group), code that groups models by
provider, the agy credential dir ~/.gemini/antigravity-cli/, and CHANGELOG
history. Functional shell files pass bash -n; setup-statusline.py passes
py_compile; statusline render verified earlier (ag-gem / ag-ext, exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- docs/backends/facts.md: replace leftover Gemini route row + "Gemini notes"
  with the Antigravity row + notes (sidecar/credential rows were already done).
- docs/claude-code-customization.md: /tokenmaxxer:gemini -> :antigravity;
  agents/gemini-run.md -> agents/antigravity-run.md.
- docs/setup.md: drop TOKENMAXXER_GEMINI_RPD_LIMIT (Antigravity has no RPD cap);
  TOKENMAXXER_GEMINI_DISABLED -> TOKENMAXXER_ANTIGRAVITY_DISABLED.
- skills/check-usage.md: bottleneck list "Gemini daily bucket" ->
  "Antigravity weekly bucket".
- CHANGELOG.md: add Unreleased entry for the Antigravity migration.

Remaining "gemini" references are intentional (provider-bucket label, agy
credential dir ~/.gemini/antigravity-cli/, "runs Gemini models" capability
notes, CHANGELOG history). Verified: all edited shell pass bash -n,
setup-statusline.py passes py_compile, all JSON valid, statusline renders
ag-gem/ag-ext and exits 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lot comment

Edits that silently failed in the prior commit (display-bug-corrupted matches),
now applied against fresh reads:
- docs/setup.md: drop TOKENMAXXER_GEMINI_RPD_LIMIT row; rename the kill-switch
  row to TOKENMAXXER_ANTIGRAVITY_DISABLED.
- docs/claude-code-customization.md: /tokenmaxxer:gemini -> :antigravity;
  agents/gemini-run.md -> agents/antigravity-run.md.
- CHANGELOG.md: add the [Unreleased] Antigravity-migration entry (the section
  did not exist before).
- scripts/copilot-run.sh: drop stale "gemini-run" mention from a comment.

Audit clean: no TOKENMAXXER_GEMINI_*, /tokenmaxxer:gemini, or gemini-run refs
remain outside CHANGELOG history. All other "gemini" occurrences are the
intentional Antigravity provider-bucket label and the ~/.gemini/antigravity-cli
credential path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant