# ContextRadar (context-radar-mcp): Complete Technical Specification

> Source: https://contextradar.eatingdream.dev/ | Directory: https://contextradar.eatingdream.dev/llms.txt | Search: https://contextradar.eatingdream.dev/.well-known/search?q={query}

## Overview

- **Category**: Context budget and prompt cache diagnostics / 上下文预算与提示缓存诊断
- **Platform**: macOS and Linux
- **Canonical URL**: https://contextradar.eatingdream.dev/
- **Repository**: https://github.com/eatingDream-antigravity-plugins/ContextRadar
- **Releases**: https://github.com/eatingDream-antigravity-plugins/ContextRadar/releases
- **AI Guide**: https://github.com/eatingDream-antigravity-plugins/ContextRadar/blob/main/docs/ai-guide.md
- **License**: MIT

**Summary (EN)**: See which turns use up the window and why the prompt cache went cold, before a long session starts to drag.
**简介 (ZH)**: 在长会话变慢之前，看清哪些轮次占满了窗口、提示缓存为什么凉了。

**What It Is**: A local native Rust MCP server, live Antigravity side panel, and pure-protocol ACP thin client that tracks context headroom, diagnoses prompt-cache breaks, and distills bloated turns without disturbing your active KV prefix.
**定位说明**: 面向 Antigravity 的原生 Rust 本地 MCP 服务、实时侧边栏与纯协议 ACP 客户端：监控上下文余量、归因提示词缓存失效，并在不打断 KV 前缀的前提下把冗长轮次蒸馏到独立笔记。

**What It Is Not**: Not a cloud proxy, history mutator, or analytics service. It reads local ledgers strictly read-only and never rewrites live conversation logs.
**边界声明**: 不是云端代理、不会改写对话历史，也不上报任何数据。所有本地账本均以严格只读方式打开。

## Quick Start

Install native binary and Antigravity plugin:

```sh
curl -fsSL https://raw.githubusercontent.com/eatingDream-antigravity-plugins/ContextRadar/main/scripts/install.sh | sh
```

Add portable Agent Skill (`agentskills.io`):

```sh
npx skills add eatingDream-antigravity-plugins/ContextRadar
```

## MCP Tools

- `context_radar_overview`: Live status (ready/running/waiting/error), headroom, thinking share, Stream/E2E speed, loop rollup, and subagents.
- `context_radar_turns`: Per-turn tokens, cache hit rate, 3-way cold-cache attribution, TTFT, speed, and cost.
- `context_radar_hotspots`: Locate context spikes (hotspots) or distill a step range into scratch/ (distill, save_note: true).
- `context_radar_prepare_handoff`: Evaluate budget tier, cooldown, subagent drain, and break-even economics.
- `context_radar_commit_handoff`: Issue a scoped single-use grant for /compact or fresh-chat handoff.

## CLI Subcommands

- `context-radar-mcp daemon [--data-dir <path>] [--panel-html <path>]`
- `context-radar-mcp acp-proxy [options] [-- <agy acp flags...>]`
- `context-radar-mcp acp-run --prompt <text> [options] [-- <agy acp flags...>]`
- `context-radar-mcp guard boot | exec`
- `context-radar-mcp bench [--iterations <n>] [--data-root <path>]`

## How It Works

### Spot the turn that ate the window (找出吃掉窗口的那一轮)

Some turns are huge without looking it. One log dump or file read can take a fifth of the window. ContextRadar ranks turns by size, so you know what to trim.

有些轮次看着不起眼，一次日志或文件读取就能占掉五分之一的窗口。ContextRadar 按大小给每一轮排序，该删什么一眼就知道。

### Find out why replies got slow (弄清回复为什么变慢)

When the prompt cache goes cold, every turn pays for the whole prompt again. ContextRadar marks the turn where it happened and names the likely cause in plain words.

提示缓存一旦失效，每一轮都要把整段提示重新算一遍。ContextRadar 会标出失效发生在哪一轮，并用大白话说明最可能的原因。

### Keep the chats that matter, then hand off (留住重要的会话，干净地交接)

Pin the conversations you keep coming back to, so they stay apart from today's noise. When a session is done, save a short handoff note and pick up cleanly in a new one.

把常回来看的会话置顶，和今天的零碎对话分开放。一段会话做完时，存一份简短的交接笔记，换个新会话也能顺顺当当接着干。

## 3-Way Cache Attribution and Compaction Gate

| Signal Class | Root Cause Pattern | Recommended Action |
| --- | --- | --- |
| New-Turn Miss | Fresh prompt suffix after stable cached prefix | Keep session hot; do not compact |
| Mid-Loop Break | Slow-turn TTL expiry, tool spillover, or model switch | Distill noisy slice to scratch/ or inspect hotspot |
| Post-Compact Rebuild | Expected single-turn cold write right after /compact | Verify break-even turns before next compaction |
| Cross-Model Warning | Compacting across incompatible tokenizer or prefix cache | Prefer clean handoff into a fresh conversation |

## Safety and Privacy Boundaries

1. 100% local and read-only: opens Antigravity SQLite ledgers with SQLITE_OPEN_READ_ONLY plus incremental WAL/JSONL tailing.
   - 中文：100% 本地只读：以 SQLITE_OPEN_READ_ONLY 打开账本并增量追踪 WAL/JSONL，零外联请求。
2. Atomic symlink-safe writes: scratch/ digests traverse directories with O_NOFOLLOW checks and atomic 0600 temp-file renames.
   - 中文：原子且防符号链接写入：scratch/ 目录遍历启用 O_NOFOLLOW 校验，并以 0600 临时文件原子重命名。
3. Fail-closed grants and ACP auth: headless acp-run cancels allow-only prompts unless --auto-approve is explicitly set.
   - 中文：失效闭合授权：无头 acp-run 默认拒绝放行敏感确认，除非显式声明 --auto-approve。
4. Strict panel CSP: single self-contained HTML bundle (default-src 'none'), zero external assets, and zero innerHTML writes.
   - 中文：严格面板 CSP：单文件自包含 HTML（default-src 'none'），零外部资源与零 innerHTML 写入。

## Suite Navigation

- **eatingDream Hub**: https://eatingdream.dev/
- **ClamGuard** (mac-clamshell-mcp): https://clamguard.eatingdream.dev/ (Watches lid state, fans and heat on your MacBook without sudo, throttles heavy builds when closed, and restores brightness when you open it.)
- **RemoteCast** (chrome-stream-mcp): https://remotecast.eatingdream.dev/ (Puts Chrome right in your sidebar over loopback or your own SSH tunnel, so you can watch and click through it without leaving the editor.)
- **ColabDeck** (colab-mcp): https://colabdeck.eatingdream.dev/ (Lists every Colab GPU you have running and what it has cost so far from live rates, then stops the ones you forgot about.)
