Skip to content

agents: add Antigravity (agy) usage collector and assets - #15056

Closed
ashxddaga wants to merge 6 commits into
omacom:quattrofrom
ashxddaga:feature/agy-agent-usage
Closed

ashxddaga wants to merge 6 commits into
omacom:quattrofrom
ashxddaga:feature/agy-agent-usage

Conversation

@ashxddaga

Copy link
Copy Markdown

Description

This PR adds native support for tracking Antigravity (agy / Google Antigravity CLI) metrics in the Omarchy top-right agent status bar widget (omarchy.agents).

Changes

  1. Collector (bin/omarchy-agent-usage-agy):
    • Aggregates prompts from ~/.gemini/antigravity-cli/history.jsonl.
    • Aggregates conversations/sessions from ~/.gemini/antigravity-cli/conversation_summaries.db.
    • Calculates prompt/completion/cached token metrics and active model tier from session transcripts (~/.gemini/antigravity-cli/brain/**/transcript.jsonl).
    • Writes standardized JSON output to ~/.local/state/omarchy/agents/usage/agy.json.
  2. Icons & Shell Assets (shell/plugins/agents/assets/):
    • Added agy.svg and agy-light.svg vector marks matching Omarchy plugin icon styling.
  3. Plugin Manifest & Documentation:
    • Added agy to the supported collectors list in shell/plugins/agents/manifest.json.
    • Updated README.md documentation.

Testing

  • Tested locally on Omarchy: collector outputs valid JSON and the agent widget displays Antigravity usage.
  • Ran ./test/cli test suite (all 114 tests passed).

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with all numbered previous findings addressed and no new actionable issues found.

Summary

Adds Antigravity usage to the agent widget.

  • The Agents panel can show Antigravity usage and limits.

No new actionable issues were found. Tests were inspected, not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Local history and transcripts] --> C[Antigravity collector]
  B[agy usage and limits cache] --> C
  C --> D[Usage JSON]
  D --> E[Agent widget]
Loading

Reviews (5) · Last reviewed commit: "agents: track limits staleness, protect ..." · Reviewed by Greptile

Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread bin/omarchy-agent-usage-agy Resolved
…nd add test suite

- Hide tab when unused or not installed by returning ready: false, tierLabel: "", and limits: []
- Remove synthetic quotas to avoid false warnings and rely purely on authoritative provider limits
- Restrict today's token calculations strictly to entries timestamped today
- Aggregate token volume per date in recentDays[].messageCount
- Preserve historical model attribution per entry without rewriting from settings.json
- Cache local stats to accelerate --limits-only refreshes
- Use read-only connection (?mode=ro) for live SQLite conversation summaries
- Report errors and return nonzero exit code if --write fails
- Add fixture-based test suite covering all input formats and behaviors in test/shell.d/agent-usage-agy-test.sh
@ashxddaga

Copy link
Copy Markdown
Author

Addressed all review comments in fffe5bb:

  1. Unused agent appears active (P1): Derived readiness and local-data flags from binary presence or session/history data. When uninstalled or unused, the collector reports ready: false, tierLabel: "", and limits: [] so the widget collapses when unused.
  2. Fixed quotas trigger false warnings (P1) & Old session meter persists (P2): Removed synthetic quota fallbacks (100 prompts, 4M tokens, context meter). Quota meters strictly reflect authoritative rate-limits probed from agy -p /usage, or remain empty without false alarms.
  3. Past tokens count as today (P1): todayTotalTokens and todayTokensByModel strictly accumulate tokens from entries timestamped today (d == today_str).
  4. Weekly tokens count prompts (P1): recentDays[].messageCount aggregates token volume per date; prompt counts remain in todayPrompts and totalPrompts.
  5. Model changes rewrite history (P1): Historical tokens are attributed to the model recorded with each transcript entry (or "unknown" bucket when unspecified), without overwriting past history with settings.json.
  6. Limits refresh rereads history (P2): Added cached stats reuse in cached_local_stats() (15m TTL) when --limits-only is passed, avoiding repetitive transcript and database walks.
  7. Live sessions may be missed (P2): Switched SQLite connection to ?mode=ro with timeout=2 to properly observe live sessions under WAL mode.
  8. Failed saves look successful (P2): When --write fails, outputs the error to stderr and exits with code 1.
  9. Broken readers look successful (P2): Added comprehensive fixture test suite in test/shell.d/agent-usage-agy-test.sh testing uninstalled states, mock history, SQLite, and transcripts, date/model attribution, caching, and atomic write failures.

Comment thread bin/omarchy-agent-usage-agy Resolved
Comment thread test/shell.d/agent-usage-agy-test.sh Resolved
… fix test timezones

- Record limitsFetchedAt and limitsStale when returning cached limits after probe failure
- Move cache_dir.mkdir inside exception handler in cached_local_stats and probe_authoritative_limits
- Use timezone-independent timestamps and pin TZ=UTC in test/shell.d/agent-usage-agy-test.sh
- Add tests for limitsStale behavior and unwritable cache directory handling
@ashxddaga

Copy link
Copy Markdown
Author

Addressed the remaining review comments in 684af4a:

  1. Old limits look current (P2): probe_authoritative_limits() now captures limitsFetchedAt (epoch milliseconds) and returns limitsStale: true whenever cached limits are reused after a failed probe.
  2. Cache failure stops usage refresh (P1): Moved directory creation (cache_dir.mkdir(parents=True, exist_ok=True)) inside the try-except block in both cached_local_stats() and probe_authoritative_limits(), ensuring unwritable cache paths do not crash the collector.
  3. Tests fail in some timezones (P1): Pinned TZ=UTC and removed the Z suffix from history fixture timestamps in test/shell.d/agent-usage-agy-test.sh to keep date boundaries consistent in all timezones.

@jandrusk

Copy link
Copy Markdown

Thanks for the collector + assets + tests.

Heads-up: several open PRs already target Antigravity/agy on the agents panel — please coordinate / close duplicates rather than landing parallel collectors:

Also note agy enabled by default in manifest.json — product call whether new collectors should default on.

quattro currently has no omarchy-agent-usage-agy, so the feature is still wanted; picking one PR to land would help.

@ashxddaga

Copy link
Copy Markdown
Author

Closing as superseded by #14040 which landed native Antigravity support in quattro. Thanks!

@ashxddaga ashxddaga closed this Oct 31, 2026
@ashxddaga
ashxddaga deleted the feature/agy-agent-usage branch October 31, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants