# Task: Investigate why loadCodeAssist returns free-tier despite Ultra subscription

## Problem
Peet has Google One AI Pro (Ultra) subscription for Antigravity. The desktop app shows real usage (93% weekly, 95% 5h). But our `aichecker` tool calls `loadCodeAssist` API and it returns `currentTier.id = "free-tier"` instead of the Ultra tier.

This makes the display show "Tier: Antigravity (free-tier)" which is wrong — Peet is on Ultra.

## What we know (already investigated)

### API response (verified 2026-06-29)
```
POST https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist
Body: {"metadata": {"ideType": "ANTIGRAVITY"}}

Response:
  currentTier.id = "free-tier"
  currentTier.name = "Antigravity"
  allowedTiers: [
    {id: "free-tier", name: "Antigravity"},
    {id: "standard-tier", name: "Antigravity"}
  ]
  upgradeSubscriptionUri = "https://codeassist.google.com/upgrade"
  gcpManaged = false
```

### Token
- Same token used by both CLI and desktop app (single `gemini:antigravity` credential in Windows Credential Manager)
- Token belongs to `peet.wannasarnmetha@gmail.com` (verified via Google userinfo API)
- Token refresh works (returns new access_token)

### retrieveUserQuotaSummary (the endpoint we now use for usage data)
This endpoint DOES return real usage data (Claude+GPT group shows 1.6% weekly used with "refresh in 2 days 20 hours" matching the app). So the token IS valid for Ultra-level data.

## What to investigate

### 1. Is "free-tier" actually correct for the API context?
Maybe the Cloud Code Assist API always reports "free-tier" for consumer (non-GCP) accounts, regardless of Google One AI subscription. The Ultra subscription might be managed by a different system (Google One) that the Cloud Code API doesn't know about. In that case, "free-tier" is technically correct from the API's perspective and we should not display it as a bug.

Check:
- What does `standard-tier` mean in `allowedTiers`? Is that the Ultra equivalent?
- Is there a way to detect Google One AI Pro subscription from the API?

### 2. Try different `ideType` values
The binary has `ANTIGRAVITY` and `CLOUD_SHELL` as ideType enum values. Try `CLOUD_SHELL` — maybe it maps to a different tier.

### 3. Check `fetchUserInfo` endpoint
Claude Code already found this endpoint returns `{userSettings, regionCode: "TH"}`. Check if it has any tier/subscription info we missed.

### 4. Search the agy binary for tier/subscription detection
Search for patterns like:
- `standard-tier`, `ultra`, `googleOne`, `google_one`, `subscription`, `aiPro`, `ai_pro`
- Any endpoint that checks subscription status
- How the desktop app determines the tier to display

### 5. Check if the desktop app shows "Ultra" or just shows usage without a tier label
Peet said the app shows "Weekly Limit" and "Five Hour Limit" with percentages — it may NOT show a tier label at all. In that case, we should just drop the tier display or show it more accurately.

## Fix approach

Based on findings, choose ONE:

**Option A — If "free-tier" is technically correct for the API:**
- Don't display "free-tier" as if it's wrong
- Either hide the tier_id, or show it as "Antigravity" only (drop the parenthetical tier_id)
- Add a note in docs explaining that the API reports the Cloud Code Assist tier, not the Google One subscription

**Option B — If there's a way to detect Ultra:**
- Call the correct endpoint to get the real subscription tier
- Display "Ultra" or "Google One AI Pro" when detected

**Option C — If the tier is genuinely misleading:**
- Remove tier display entirely from the default output
- Keep it only in `--json` output for debugging

## Project location
- Repo: `C:\Users\User\Desktop\Hermes_Peet\scratch\ai-limit-checker` (main branch, up to date)
- Key file: `src/ai_limit_checker/antigravity.py` — `_extract_tier()` function at line ~291
- CLI display: `src/ai_limit_checker/cli.py` — `_antigravity_section()` function
- Tests: `tests/test_antigravity.py`
- No venv in this directory. Use system Python: `python` (3.11, Windows Store)
- Run: `cd "C:\Users\User\Desktop\Hermes_Peet\scratch\ai-limit-checker" && PYTHONPATH="src" python -c "from ai_limit_checker.cli import main; main(['--antigravity','--no-cache'])"`
- Tests: `cd "C:\Users\User\Desktop\Hermes_Peet\scratch\ai-limit-checker" && PYTHONPATH="src" python -m pytest tests/ -x -q`

## Constraints
- Zero external dependencies (stdlib only)
- Python 3.10+
- Cross-platform
- Never print credentials/tokens
- ruff clean (E, F, W, I, UP, B, SIM)
- All tests must pass
- Comments/docs in English
- Do NOT push to main — work on a branch, open a PR

## Report format
1. **Investigation Results** — what you tried, what you found
2. **Root Cause** — why "free-tier" appears and whether it's a bug
3. **Fix Applied** — what code changes you made
4. **Test Results** — pytest output
5. **Files Changed** — list
6. **Before/After** — show the CLI output difference