Skip to main content
Glama
Agy Guard
by tone-leh
README.md
<div align="center">

<img src="./assets/logo.svg" alt="Agy Guard Logo" width="84" height="84" />

# Agy Guard

**Deterministic Local Security Guardrail, Secret-Leak Shield & Zero-Git Pre-Edit Snapshot Time Machine for Google Antigravity 2.0**

[![Antigravity 2.0 Native MCP App](https://img.shields.io/badge/Antigravity_2.0-Native_MCP_App-10b981?style=flat-square)](https://github.com/tone-leh/agy-guard)
[![Zero Runtime Dependencies](https://img.shields.io/badge/Runtime_Deps-0-0ea5e9?style=flat-square)](#install-in-10-seconds)
[![100% Local](https://img.shields.io/badge/Privacy-100%25_Local-6366f1?style=flat-square)](#architecture)
[![License: MIT](https://img.shields.io/badge/License-MIT-f59e0b?style=flat-square)](./LICENSE)

[English](./README.md) · [简体中文](./README.zh-CN.md)

<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" alt="Agy Guard Hero Preview" width="100%" />
</picture>

</div>

---

## Why Agy Guard?

AI coding agents move fast — which means one bad tool call can read `.env.production`, paste a hardcoded API key into `src/`, run `git push --force`, or wreck 6 files during an aggressive refactor before you even notice.

Relying on system prompts ("please don't read `.env`") is **probabilistic**. **Agy Guard** makes safety **deterministic** inside Google Antigravity 2.0:

- **Deterministic `PreToolUse` Firewall (`<5ms`)**: Blocks `.env`, `~/.ssh/*`, `~/.aws/credentials`, `*.pem/*.key`, `rm -rf /`, `git push --force`, `git reset --hard`, `DROP TABLE`, and gates `curl | sh` before execution ever happens.
- **Outgoing Secret-Leak Shield**: Scans every `write_file` / `edit_file` payload for AWS keys, GitHub PATs, OpenAI/Anthropic/Stripe keys, Google API keys, Slack tokens, JWTs, and private key blocks — catching leaks *before* they touch disk or Git.
- **Zero-Git Pre-Edit Snapshot Time Machine**: Automatically saves SHA-256 deduplicated file snapshots to `${PLUGIN_DATA}/blobs/` right before every mutating edit — **zero `git log` or `git stash` pollution**.
- **1-Click Reversible Rollback UI**: Inspect unified line-by-line diffs inside Antigravity's native sidebar (`SEP-1865` MCP App) and restore any file in one click. Every restore automatically captures a pre-restore safety backup first, so **even undo is undoable**.
- **Zero Runtime Dependencies**: Pre-bundled `dist/server.cjs`, `dist/hook.cjs`, `dist/cli.cjs`, and single-file React `dist/ui/app.html`. Zero cloud servers, zero Electron/CDP hacks, mode-`0600` local storage.

---

## Install in 10 Seconds

```bash
agy plugin install https://github.com/tone-leh/agy-guard
```

Then open **Agy Guard** from the Antigravity sidebar (`aux_pane` / `global` entrypoint) or prompt:
> *"Open Agy Guard to inspect pre-edit file snapshots and recent security audit events"*

### Try Locally Without Touching Your Antigravity Setup (Zero-Touch Offline Workbench)

```bash
git clone https://github.com/tone-leh/agy-guard.git
cd agy-guard
npm install
npm run workbench
# Open http://127.0.0.1:4398 — test diff restore & dry-run threat simulation safely
```

---

## Feature Matrix

| Capability | Prompt-only Rules | Git Stash / Manual Commits | **Agy Guard (Native MCP App)** |
| :--- | :---: | :---: | :---: |
| Blocks `.env` / `~/.ssh` / `~/.aws` reads deterministically | ❌ Probabilistic | ❌ No | ✅ `<5ms` `PreToolUse` hook |
| Catches API keys & JWTs in outgoing `write_file` / `edit_file` | ❌ Easy to miss | ❌ Too late (post-write) | ✅ Blocked before disk write |
| Blocks `rm -rf /`, `git push --force`, `git reset --hard` | ❌ Probabilistic | ❌ No | ✅ Hard `deny` or `ask` gate |
| Automatic pre-edit file snapshots without polluting Git | ❌ No | ❌ Clutters history | ✅ SHA-256 blobs in `${PLUGIN_DATA}` |
| Visual unified diff & 1-click reversible rollback inside sidebar | ❌ No | ❌ Terminal only | ✅ Native Antigravity MCP App |
| Masked workspace secret scanner (never opens `.env`) | ❌ No | ❌ No | ✅ Built-in UI + CLI |

---

## Architecture

<img src="./assets/architecture.svg" alt="Agy Guard Architecture" width="100%" />

### MCP Tools Exposed

| Tool | Visibility | Purpose |
| :--- | :--- | :--- |
| `open_guard_panel` | Model + UI (`aux_pane`, `global`) | Opens the native Agy Guard console |
| `guard_status` | Model | Summarizes active guardrails & snapshot counters |
| `list_snapshots` | Model | Lists recent pre-edit checkpoints (with optional path filter) |
| `create_checkpoint` | Model | Captures a manual multi-file safety checkpoint before risky refactors |
| `scan_secrets` | Model | Read-only masked secret scan of workspace source files |
| `app_*` (`get_state`, `diff_snapshot`, `restore_snapshot`, `update_policy`, `scan_workspace`, `simulate_threat`) | **App-only** (`visibility: ["app"]`) | Keeps large diffs, policy edits, and dry-run simulations out of model context |

### CLI Utilities

```bash
node dist/cli.cjs doctor                                  # Verify bundle integrity
node dist/cli.cjs status                                  # Print active policy & counters
node dist/cli.cjs snapshots                               # List latest pre-edit checkpoints
node dist/cli.cjs scan .                                  # Masked workspace secret scan
node dist/cli.cjs test-policy run_command "git push -f"   # Dry-run policy evaluation
```

---

## Part of the Antigravity 2.0 Native Plugin Suite

1. **[agy-xray](https://github.com/tone-leh/agy-xray)** — Context Composition X-Ray, Token Vampire Detector & Cross-Session BM25 Time Machine
2. **[agy-remote](https://github.com/tone-leh/agy-remote)** — Zero-Cloud Mobile PWA & 6-Channel IM Remote Approval Bridge
3. **[agy-canvas](https://github.com/tone-leh/agy-canvas)** — Visual Artifact Reviewer with Figma-Style Coordinate Pins
4. **[agy-mem](https://github.com/tone-leh/agy-mem)** — Glass-Box Code-Anchored Long-Term Memory & Knowledge Graph with SHA-256 Drift Guard
5. **[agy-guard](https://github.com/tone-leh/agy-guard)** — Local Security Guardrail, Secret-Leak Shield & Zero-Git Pre-Edit Snapshot Time Machine *(this repo)*

---

## License

MIT © [tone-leh](https://github.com/tone-leh)