Skip to main content
Glama
Antigravity Context Monitor

Antigravity Context Monitor

by anhpi1
README.md
# Antigravity Context Monitor

Official-API **MCP App plugin** for Google Antigravity that displays real-time context window usage, cache hit rate, cache-drop warnings, and local token statistics directly inside Antigravity's **side pane** and **left sidebar**.

## Why this plugin

- Uses only Antigravity's built-in **Plugin + MCP App (`ui://`)** extension mechanism.
- Reads local `transcript.jsonl` files under `~/.gemini/antigravity/brain/` in **read-only** mode.
- Does **not** open `--remote-debugging-port` (CDP), does **not** inject JavaScript into the Electron runtime, does **not** touch OS credentials, and makes **no** outbound network calls.

## Features

- **Session tab (`aux_pane` & `global`)**:
  - Current context window usage (`input_tokens + cache_read_tokens`) with selectable `200K` / `1M` scale.
  - Split progress bar (Cache Read vs. New Input), cache hit percentage, peak context, and per-turn growth chart.
  - Cache-drop detection when `cache_read_tokens` drops sharply across consecutive turns.
  - Per-turn request table (step index, time, model, total context, new input, cache read, output, tools) with 5-second auto-refresh.
- **Overview tab (`global`)**:
  - Aggregate totals across all local conversations.
  - 16-week daily activity heatmap.
  - Model token distribution and clickable recent conversations table.
  - Reference API cost estimate (estimated from public API token rates; not actual subscription quota).

## Installation (no `npm install` required)

Prebuilt bundles (`dist/server.mjs` and `dist/app.html`) are included in the repository. Node.js (`>= 20`) is required.

**Windows (PowerShell):**

```powershell
git clone https://github.com/anhpi1/antigravity-context-monitor.git "$env:USERPROFILE\.gemini\config\plugins\context-monitor"
```

**macOS / Linux:**

```bash
git clone https://github.com/anhpi1/antigravity-context-monitor.git ~/.gemini/config/plugins/context-monitor
```

Antigravity automatically discovers directories containing `plugin.json` under `~/.gemini/config/plugins/`.

### Opening the panel

- **Side pane:** Click `+` in the conversation side pane -> **Context Monitor**.
- **Left sidebar (full page):** Click **Context Monitor** in the left sidebar.
- If it does not appear immediately, restart the MCP server under **MCP Servers** settings or reload Antigravity.

## Development & Rebuild

```bash
npm install
npm run build
```

`npm run build` uses `esbuild` (`scripts/build.mjs`) to produce:
- `dist/server.mjs` — bundled ESM MCP server (stdio).
- `dist/app.html` — self-contained single-file HTML UI (`@modelcontextprotocol/ext-apps`) compliant with the default strict CSP.

## Known Limitations

- Entrypoint launches from Antigravity's `+` menu / sidebar invoke the tool with `{}` (no active conversation ID is passed), so the UI defaults to the most recently updated conversation and provides a dropdown to switch conversations.
- Displays local token logs and reference API cost estimates only; server-side subscription quota is not exposed by any public API.