Repository navigation
Add Antigravity usage collector for the agents panel - #13553
atanas-chalakov wants to merge 7 commits into
Conversation
Automated AI review
Outcome: The collectors publish numbers their data does not support. Quota meters without a quotaBoth collectors add "Session Turns" and "Daily Quota" meters of prompts / 50; the files they read hold no quota. 45 prompts reach the 0.9 bar alarm. Suggested change: return Reproducer (fails at 012b47e)Invented quota meters (Antigravity; the Copilot collector uses the same code)Test file #!/bin/bash
source "$(dirname "$0")/base-test.sh"
require_command jq
require_command python3
TEST_HOME=$(mktemp -d)
trap 'rm -rf "$TEST_HOME"' EXIT
data_dir="$TEST_HOME/.gemini/antigravity-cli"
mkdir -p "$data_dir"
# 45 prompts today. Nothing in these files describes a quota.
now_ms=$(date +%s%3N)
for n in $(seq 45); do
printf '{"display":"prompt %s","timestamp":%s,"workspace":"/home/user","conversationId":"c1"}\n' "$n" "$now_ms"
done >"$data_dir/history.jsonl"
result=$(HOME="$TEST_HOME" ANTIGRAVITY_DATA_DIR="$data_dir" "$ROOT/bin/omarchy-agent-usage-agy")
jq -c '.limits' <<<"$result"
# Panel.qml lights the bar icon (alarming) once any limit reaches 0.9.
jq -e '([.limits[].percent] | max // 0) < 0.9' <<<"$result" >/dev/null ||
fail "Antigravity collector does not report a quota at the bar alarm threshold without quota data" "$(jq -c '.limits' <<<"$result")"
pass "Antigravity collector does not report a quota at the bar alarm threshold without quota data"Run from the repository root at the reviewed head (012b47e) as Actual output at the reviewed head (run 2026-09-29 00:54 UTC, machine zone UTC+2): Control: the same test against a copy of Same test with
Copilot mixes UTC and local datesCopilot's schema stamps rows in UTC; the collector matches Suggested change: compare Reproducer (fails at 012b47e)Copilot: UTC dates compared with the local dateTest file #!/bin/bash
source "$(dirname "$0")/base-test.sh"
require_command jq
require_command python3
require_command sqlite3
TEST_HOME=$(mktemp -d)
trap 'rm -rf "$TEST_HOME"' EXIT
data_dir="$TEST_HOME/.copilot"
mkdir -p "$data_dir"
# Same tables and rows as agent-usage-copilot-scanner-test.sh. Copilot's own
# schema defaults these timestamps to datetime('now'), which is UTC.
sqlite3 "$data_dir/session-store.db" <<EOF
CREATE TABLE sessions (id TEXT PRIMARY KEY, cwd TEXT, repository TEXT, host_type TEXT, branch TEXT, summary TEXT, created_at TEXT, updated_at TEXT);
CREATE TABLE turns (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, turn_index INTEGER, user_message TEXT, assistant_response TEXT, timestamp TEXT);
CREATE TABLE assistant_usage_events (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT, turn_index INTEGER, model TEXT, input_tokens INTEGER, output_tokens INTEGER, cache_read_tokens INTEGER, cache_write_tokens INTEGER, created_at TEXT);
INSERT INTO sessions VALUES ('s1', '/home/user/work', 'user/repo', 'github', 'main', 'Test feature', datetime('now'), datetime('now'));
INSERT INTO turns VALUES (1, 's1', 0, 'Hello world', 'Hi', datetime('now'));
INSERT INTO turns VALUES (2, 's1', 1, 'Second prompt', 'Sure', datetime('now'));
INSERT INTO assistant_usage_events (session_id, model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, created_at)
VALUES ('s1', 'gpt-5-mini', 100, 50, 0, 0, datetime('now'));
EOF
# Rows written a moment ago are "today" wherever the machine is. Pick a zone
# whose calendar date differs from UTC's right now: UTC+14 from 10:00 UTC,
# UTC-12 before then. (Etc/GMT-14 is UTC+14; the POSIX sign is inverted.)
if (( 10#$(date -u +%H) >= 10 )); then zone=Etc/GMT-14; else zone=Etc/GMT+12; fi
printf '# TZ=%s local=%s utc=%s\n' "$zone" "$(TZ=$zone date +%F)" "$(date -u +%F)"
result=$(TZ=$zone HOME="$TEST_HOME" COPILOT_HOME="$data_dir" "$ROOT/bin/omarchy-agent-usage-copilot")
[[ $(jq -r '.todayPrompts' <<<"$result") == "2" ]] ||
fail "Copilot collector counts prompts from a moment ago as today in $zone" "$(jq -c '{todayPrompts, todaySessions, todayTotalTokens, recentDays}' <<<"$result")"
pass "Copilot collector counts prompts from a moment ago as today in $zone"
[[ $(jq -r '.recentDays[-1].messageCount' <<<"$result") == "150" ]] ||
fail "Copilot collector puts tokens from a moment ago on today's row in $zone" "$(jq -c '.recentDays' <<<"$result")"
pass "Copilot collector puts tokens from a moment ago on today's row in $zone"Run from the repository root at the reviewed head (012b47e) as Actual output at the reviewed head (run 2026-09-29 00:54 UTC, machine zone UTC+2): Control: the same test against a copy of The PR's own test fails the same way when the local date is behind UTC. Copilot CLI 1.0.89 creates these columns as Antigravity shows old estimates as today's tokensTokens are characters / 4 of the latest transcript, under a fixed Suggested change: omit tokens until a real usage source exists. Reproducer (fails at 012b47e)Antigravity: estimated tokens of an old conversation reported as today's, and prompt counts in the tokens-by-day rowsTest file #!/bin/bash
source "$(dirname "$0")/base-test.sh"
require_command jq
require_command python3
TEST_HOME=$(mktemp -d)
trap 'rm -rf "$TEST_HOME"' EXIT
data_dir="$TEST_HOME/.gemini/antigravity-cli"
mkdir -p "$data_dir/conversations" "$data_dir/brain/old-conv/.system_generated/logs"
# Three prompts three days ago, nothing since.
old_ms=$(( ($(date +%s) - 3 * 86400) * 1000 ))
for n in 1 2 3; do
printf '{"display":"prompt %s","timestamp":%s,"workspace":"/home/user","conversationId":"old-conv"}\n' "$n" "$old_ms"
done >"$data_dir/history.jsonl"
# That conversation is the latest one, last touched three days ago, with a
# 40,000-character model reply in its transcript.
python3 - "$data_dir" "$old_ms" <<'PY'
import json, sqlite3, sys
data_dir, old_ms = sys.argv[1], int(sys.argv[2])
db = sqlite3.connect(f"{data_dir}/conversation_summaries.db")
db.execute("CREATE TABLE conversation_summaries (conversation_id TEXT, title TEXT, step_count INTEGER, status TEXT, last_modified_time INTEGER)")
db.execute("INSERT INTO conversation_summaries VALUES ('old-conv', 'Refactor the parser', 6, 'IDLE', ?)", (old_ms,))
db.commit()
with open(f"{data_dir}/brain/old-conv/.system_generated/logs/transcript.jsonl", "w") as f:
f.write(json.dumps({"source": "USER_EXPLICIT", "content": "x" * 400}) + "\n")
f.write(json.dumps({"source": "MODEL", "content": "y" * 40000}) + "\n")
PY
result=$(HOME="$TEST_HOME" ANTIGRAVITY_DATA_DIR="$data_dir" "$ROOT/bin/omarchy-agent-usage-agy")
jq -c '{todayPrompts, todayTotalTokens, recentDays: [.recentDays[].messageCount], modelUsage, tierLabel, usageStatusText}' <<<"$result"
[[ $(jq -r '.todayPrompts' <<<"$result") == "0" ]] ||
fail "fixture has no prompts today" "$result"
pass "fixture has no prompts today"
[[ $(jq -r '.todayTotalTokens' <<<"$result") == "0" ]] ||
fail "Antigravity collector reports no tokens today when nothing ran today" "$(jq -c '{todayTotalTokens, todayTokensByModel}' <<<"$result")"
pass "Antigravity collector reports no tokens today when nothing ran today"
[[ $(jq -r '.recentDays[-1].messageCount' <<<"$result") == "0" ]] ||
fail "Antigravity collector leaves today's row empty when nothing ran today" "$(jq -c '.recentDays' <<<"$result")"
pass "Antigravity collector leaves today's row empty when nothing ran today"Run from the repository root at the reviewed head (012b47e) as Actual output at the reviewed head (run 2026-09-29 00:54 UTC, machine zone UTC+2): Control: the same test against a copy of The control patch stopped writing the transcript estimate into More findings
|
…igravity collector
Summary
Adds the
omarchy-agent-usage-agycollector, icons, and test suite to enable tracking Antigravity (agy) in the Omarchy Agents panel.Omarchy already supports
agyas a default coding agent inomarchy-agentandomarchy-default-agent, but was missing a usage collector and brand marks inshell/plugins/agents/assets/.Changes
bin/omarchy-agent-usage-agy: Implements the usage collector parsing prompt activity, sessions, and daily counts from~/.gemini/antigravity-cli/history.jsonlandconversations/.shell/plugins/agents/assets/agy.svg&agy-light.svg: Adds Antigravity SVGs for light and dark themes.test/shell.d/agent-usage-agy-scanner-test.sh: Adds unit test suite testing collector schema version, empty state, prompt tracking, and session calculation.Verification
test/shell.d/agent-usage-agy-scanner-test.sh: all 8 assertions passed.test/shell.d/agent-usage-update-test.sh: all tests passed.agysession logs.