Agy X-Ray
by tone-leh
README.md
<div align="center">
<img src="assets/logo.svg" width="88" height="88" alt="Agy X-Ray Logo" />
# Agy X-Ray
**See inside Google Antigravity's context window, workspace file activity, and session history — as a 100% native MCP App side pane.**
Zero ASAR patches · Zero CDP injection · Zero runtime dependencies · Survives every Antigravity update
[](https://github.com/tone-leh/agy-xray/stargazers)
[](https://github.com/tone-leh/agy-xray/actions)
[](#quick-start)
[](#architecture)
[](#architecture)
[](#quick-start)
[](LICENSE)
**English** · [简体中文](README.zh-CN.md) · [Quick Start](#quick-start) · [Features](#what-you-get) · [Architecture](#architecture) · [Offline CLI & Workbench](#try-without-installing-offline-workbench--cli) · [FAQ](#faq)
<br />
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/hero-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="assets/hero-light.svg" />
<img src="assets/hero-dark.svg" width="100%" alt="Agy X-Ray native MCP App side-pane preview in dark and light modes" />
</picture>
<sub>Follows your GitHub & Antigravity light/dark theme automatically. Preview locally with <code>npm run workbench</code> using synthetic demo data — never touches your daily Antigravity install.</sub>
</div>
> **Non-Affiliation Disclaimer**
> **Agy X-Ray is an independent MIT open-source community plugin and is not affiliated with or endorsed by Google LLC.**
> It uses only Antigravity's documented plugin, Lifecycle Hooks, and MCP Apps (`SEP-1865`) interfaces — it never patches `app.asar` or injects into Electron/CDP.
---
## Why Agy X-Ray?
When running long multi-turn or multi-subagent sessions in **Google Antigravity 2.0**, three daily frustrations show up fast:
1. **Context Black Box** — You see total tokens climbing, but not *which* tool outputs ("Token Vampires") bloated the window or *which* turn broke your prompt prefix cache.
2. **Missing Lightweight File Tree** — After Antigravity 2.0 shifted to an Agent Manager workbench, quickly scanning every file the agent read, edited, or created—and jumping straight to the source—takes too many clicks.
3. **Buried Past Sessions & Artifacts** — That root-cause analysis or plan you solved 10 days ago is sitting inside local `transcript.jsonl` and `*.md` artifacts, with no fast bilingual search or one-click way to pull it into your next prompt.
| Capability | Client Patch / CDP Mods | Pure CLI Scripts | **Agy X-Ray (Native MCP App)** |
| :--- | :---: | :---: | :---: |
| Survives Antigravity desktop updates | Often breaks | Yes | **Always (100% official APIs)** |
| Native Side Pane (`aux_pane`) + Sidebar (`global`) UI | Fragile DOM hack | No UI | **Native iframe + host theme vars** |
| One-click open touched files in Antigravity | No | No | **Yes (`toggle-aux-pane`)** |
| One-click inject past excerpts into next prompt | No | Manual copy | **Yes (`updateModelContext`)** |
| Runtime dependencies after clone | Patcher / rebuild | Varies | **0 runtime deps (pre-bundled)** |
---
## Quick Start
### Option 1: Install via Antigravity CLI (Recommended)
```bash
agy plugin install https://github.com/tone-leh/agy-xray
```
No `npm install`, no build step, no API keys. The repository ships pre-bundled zero-dependency `dist/server.cjs`, `dist/hook.cjs`, and single-file `dist/ui/app.html` (`~479 KB`).
### Option 2: Direct Clone into Antigravity Plugins Folder
```bash
# macOS / Linux
git clone https://github.com/tone-leh/agy-xray.git ~/.gemini/config/plugins/agy-xray
# Windows (PowerShell)
git clone https://github.com/tone-leh/agy-xray.git "$env:USERPROFILE\.gemini\config\plugins\agy-xray"
```
Antigravity auto-discovers new plugins immediately—no restart required. Open **Agy X-Ray** from:
- The **Side Pane `+` menu** (`aux_pane` entrypoint),
- The **Left Sidebar** (`global` full-page entrypoint), or
- Ask in chat: *"Open Agy X-Ray to inspect this session's context and touched files."*
---
## What You Get
### 1. Context Composition X-Ray & Turn Growth Chart
- Parses real Antigravity 2.0 `transcript.jsonl` step metrics (`input_tokens` fresh + `cache_read_tokens` cached = exact effective context window per turn).
- Visualizes **Prefix Cache Hit %**, **Peak Window**, **Stacked Composition** (Cached Prefix · Fresh Input · Tool Outputs · Thinking · Model Output), and a **Turn-by-Turn Stacked Bar Chart** so cache drops stand out instantly.
- Ranks **Tool Output Hotspots ("Token Vampires")** by payload KB, estimated tokens, and truncation counts (`truncated_fields`), paired with automated health diagnostics.
### 2. Live Workspace File Tree (`toggle-aux-pane`)
- Tracks every file touched by `read_file`, `view_file`, `edit_file`, `write_file`, `replace_file_content`, and more, with `R / E / W` operation pills, touch counts, and last step index.
- Filter by **All / Modified / Read Only** or path substring.
- Click **Open** to launch the file natively in an Antigravity side-pane tab (`com.google.antigravity/toggle-aux-pane`), or **+ Context** to attach a structured reference pill to your next message (`updateModelContext`).
### 3. Cross-Session Time Machine (Bilingual EN + 中文 BM25 Search)
- Indexes local transcripts and markdown artifacts (`implementation_plan.md`, `walkthrough.md`, reports) across Desktop (`~/.gemini/antigravity/brain`), CLI, and IDE directories.
- Built-in pure-TypeScript **BM25 + CJK bigram tokenizer** — zero native C++ SQLite compilation issues on macOS, Linux, or Windows.
- Click **Inject** on any historical match or artifact to attach its redacted excerpt straight into your next conversation turn.
### 4. Secret-Redacted Session Brief Export
- One-click **Export Brief** generates a clean Markdown summary of token efficiency, diagnostics, hotspots, and touched files—automatically stripping Bearer tokens, JWTs, API keys (`sk-`, `AIza`, `ghp_`, `AKIA`), and private key blocks before copy/share.
---
## Architecture
<p align="center">
<img src="assets/architecture.svg" width="100%" alt="Agy X-Ray zero-patch native MCP App architecture" />
</p>
### MCP Tools & Visibility Isolation
| Tool | Visibility | Surface | Purpose |
| :--- | :--- | :--- | :--- |
| `open_xray` | Model + App | `aux_pane` + `global` | Opens the interactive dashboard (works with empty `{}` launch) |
| `analyze_context` | Model + App | Inline / Pane | Returns compact token, cache, and hotspot diagnostics |
| `get_file_activity` | Model + App | Inline / Pane | Lists read/edited/written workspace files for the session |
| `search_sessions` | Model + App | Text + Data | Runs local bilingual BM25 search across transcripts & artifacts |
| `export_session_brief` | Model + App | Text + Data | Outputs a secret-redacted Markdown recap |
| `app_list_sessions` | **App-only** | UI | Fast session switcher list (hidden from model context) |
| `app_get_session_detail` | **App-only** | UI | Full trajectory & turn data without hitting the 1 MiB trajectory cap |
| `app_search_sessions` | **App-only** | UI | Interactive Time Machine search inside the iframe |
| `app_export_brief` | **App-only** | UI | Clipboard/context brief export from UI header |
---
## Try Without Installing (Offline Workbench & CLI)
Want to test **Agy X-Ray** in a sandbox without touching your daily Antigravity setup?
```bash
git clone https://github.com/tone-leh/agy-xray.git
cd agy-xray
npm install
# 1. Launch the zero-touch offline workbench (uses synthetic demo data)
npm run workbench
# Open http://127.0.0.1:4387 — toggle Aux Pane / Global view & Dark / Light theme
# 2. Or inspect local Antigravity transcripts read-only from your terminal
node dist/cli.cjs doctor
node dist/cli.cjs list
node dist/cli.cjs analyze --demo
node dist/cli.cjs search "PKCE" --demo
```
---
## Privacy & Security
- **100% Local-First**: Zero network calls, zero analytics, zero cloud sync. All parsing and BM25 indexing run strictly on your machine.
- **Read-Only on Transcripts**: Never mutates Antigravity transcripts, `config.json`, or client binaries.
- **Fail-Open Hooks**: `hooks.json` only records lightweight active-session pointers into `${PLUGIN_DATA}/live-state.json` (<10 ms) and fails open on any error so it can never block your agent loop.
- **Automatic Redaction**: Exported briefs and search snippets scrub common credentials, Bearer/JWT tokens, and private keys.
---
## FAQ
**Does `agy-xray` work alongside `agy-fast`, `agy-session-guard`, or other plugins?**
Yes. It uses its own namespaced MCP server (`agy-xray_xray`), never patches client files, and complements context-saving or compact-guard plugins cleanly.
**Why bundle `dist/` in the repo?**
So `agy plugin install https://github.com/tone-leh/agy-xray` works immediately with Node.js ≥ 20 and **zero `npm install` step** on macOS, Linux, and Windows.
**How do I build and run tests locally?**
```bash
npm ci
npm run typecheck
npm test
```
---
## License
MIT © [tone-leh](https://github.com/tone-leh)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues