Antigravity Context Monitor
by ClimberLeo
README.md
# Antigravity Context Monitor(上下文监控面板)
[中文说明](#中文说明) · [English](#english)
---
## 中文说明
专为 **Google Antigravity 桌面版(Antigravity 2.0+)** 设计的原生上下文监控插件(基于官方 MCP App 标准构建)。直接只读解析本机 Antigravity 会话日志,直观查看当前窗口的真实上下文用量与增长趋势,辅助你自主判断何时执行 `/compact`。
### 核心特性
- **严格零模型上下文占用**:所有 MCP 工具均声明 `visibility: ["app"]`,对模型完全不可见,面板绝不向对话发送消息或注入上下文。
- **桌面版双原生入口**:
- **右侧辅助栏(Aux Pane `+` 菜单)**:边聊天边查看当前会话水位;
- **左侧全局导航栏**:全页总览最近活跃会话。
- **真实上下文计算口径**:`实际输入上下文 = input_tokens + cache_read_tokens`(新增未缓存输入 + 历史前缀缓存读取),并展示缓存命中率。
- **Token 量 + 参考窗口百分比**:内置主流模型家族参考窗口表(`src/models.json`),支持在面板内一键自定义/恢复任意模型的上限(持久化保存在 `${PLUGIN_DATA}/custom-models.json`),不设死板的强制告警线。
- **友好对话命名与 `/compact` 识别**:自动读取 `conversation_summaries.db` 展示 `项目名 - 对话标题`;精准识别 `CHECKPOINT` 压缩事件,刚执行完 `/compact` 尚未发新消息时即刻提示压缩完成与摘要大小。
- **开箱即用**:仓库已预置单文件构建产物(`dist/server.cjs` 与 `dist/app.html`),克隆或安装后无需本地 `npm install` 即可运行,并自动跟随桌面版浅色/深色主题。
### 环境要求
- **Google Antigravity 桌面版**(2.0+)
- **Node.js `>= 20`**(推荐 `Node.js >= 22.5`,以启用 Node 内置 `node:sqlite` 读取真实项目名与对话标题;低版本会自动优雅降级为首轮提问摘要,不影响核心监控功能)
### 安装方式
**方式一:通过 Antigravity CLI 一键安装**
```bash
agy plugin install https://github.com/ClimberLeo/antigravity-context-monitor
```
**方式二:直接克隆到本机插件目录(自动发现生效)**
```bash
# macOS / Linux
git clone https://github.com/ClimberLeo/antigravity-context-monitor.git ~/.gemini/config/plugins/agy-context-monitor
# Windows (PowerShell)
git clone https://github.com/ClimberLeo/antigravity-context-monitor.git "$HOME\.gemini\config\plugins\agy-context-monitor"
```
安装后无需重启,直接在 Antigravity 桌面版 **左侧导航栏** 或对话窗口 **右侧辅助栏 `+` 菜单** 点击 **「上下文监控」** 即可打开。
### 本地二次开发
```bash
npm install
npm run build # 使用 esbuild 重新生成 dist/server.cjs 与单文件 dist/app.html
npm test # 运行解析器单元测试与 MCP 协议端到端测试
npm run deploy # 同步构建产物到本机 ~/.gemini/config/plugins/
```
如需补充新模型的默认参考窗口,直接编辑 `src/models.json` 后运行 `npm run build` 即可。
---
## English
A native **MCP App** plugin for **Google Antigravity Desktop (2.0+)** that visualizes real-time context window usage directly from local session logs — helping you decide when to run `/compact` with **zero model context overhead**.
### Key Features
- **Zero Context Overhead**: Every tool declares `visibility: ["app"]` (invisible to the LLM) and never injects messages or prompts into your conversation.
- **Dual Native Entrypoints**: Open side-by-side from the **Aux Pane (`+` menu)** or full-page from the **Left Sidebar**.
- **Accurate Context Accounting**: Computes true active context (`input_tokens + cache_read_tokens`), cache hit ratio, peak usage, and SVG step-by-step growth trends.
- **Tokens + Reference Window %**: Ships with a maintainable model family table (`src/models.json`) plus one-click per-model custom overrides persisted in `${PLUGIN_DATA}/custom-models.json`.
- **Readable Session Titles & `/compact` Detection**: Reads `Project - Title` from local metadata (gracefully falling back when `node:sqlite` is unavailable) and detects `CHECKPOINT` compaction events immediately.
- **Ready Out of the Box**: Pre-bundled `dist/server.cjs` and single-file `dist/app.html` are committed so users can install without running `npm install`.
### Prerequisites
- **Google Antigravity Desktop** (2.0+)
- **Node.js `>= 20`** (`Node.js >= 22.5` recommended for built-in `node:sqlite` session title resolution)
### Installation
```bash
# Option 1: Antigravity CLI
agy plugin install https://github.com/ClimberLeo/antigravity-context-monitor
# Option 2: Clone into your global plugins folder
git clone https://github.com/ClimberLeo/antigravity-context-monitor.git ~/.gemini/config/plugins/agy-context-monitor
```
### License
[MIT](./LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues