A couple of file editing efficiency plugins for Antigravity (agy)
README.md

Custom-agy #

A couple of file editing efficiency plugins for Antigravity (agy) with an efficiency measurement script.

Description #

2 plugins, created by Gemini Neon after some back and forth with me.

file-ops #

Context-efficient file reading, targeted editing rules, AST-based structural refactoring, and an optional CLI output compression hook (plugins/file-ops/):

  • Always-on rules (rules/AGENTS.md): Guides the agent to locate target lines with rg -n / sg before calling read_file with a bounded StartLine/EndLine window, reuse in-context reads, prefer minimal-anchor edit_file calls over full-file write_file overwrites, and use ast-grep for bulk structural refactors.
  • ast-grep skill (skills/ast-grep/SKILL.md): Model-invoked workflow for sg covering CST inspection (--debug-query=cst), dry-run matching, rewrite diff previews, --update-all, metavariables ($VAR, $$$ARGS, $_, $$), and sg scan --inline-rules.
  • Optional rtk hook (hooks.json + hooks/rtk-rewrite.py, disabled by default): A PreToolUse hook on run_command that rewrites supported CLI commands through rtk rewrite to compress verbose terminal output. To enable it, set "enabled": true in plugins/file-ops/hooks.json; set RTK_DISABLED=1 to bypass it temporarily.

tilth #

Zero-index Tree-sitter code intelligence via the tilth MCP server (plugins/tilth/):

  • MCP server (mcp_config.json): Launches tilth --mcp via a portable sh lookup across PATH, $HOME/.cargo/bin/tilth, /opt/homebrew/bin/tilth, and /usr/local/bin/tilth, exposing 6 tools: tilth_read, tilth_search, tilth_grok, tilth_deps, tilth_list, and tilth_diff.
  • Always-on rules (rules/AGENTS.md): Directs the agent to prefer tilth tools for code navigation, outlines, callers, and blast-radius checks before falling back to read_file, while keeping native edit_file/write_file and sg for edits.
  • Hashline edit mode (optional): Defaults to read-only --mcp so native edit_file stays conflict-free. To test tilth's hashline editing (tilth_write), change --mcp to --mcp --edit in plugins/tilth/mcp_config.json.

Installation #

Prerequisites #

  • ast-grep (sg): e.g. brew install ast-grep or cargo install ast-grep (used by file-ops).
  • tilth: cargo binstall tilth or cargo install tilth (used by tilth).
  • rtk (optional): only needed if you enable rtk-rewrite in plugins/file-ops/hooks.json.

Register with Antigravity #

  1. Clone this repository:

    git clone <repo-url> /path/to/customagy
    
  2. Point ~/.gemini/config/plugins.json at the plugins/ directory (if the file already exists, add the object to its entries array):

    {
      "entries": [
        {
          "path": "/path/to/customagy/plugins"
        }
      ]
    }
    

Both plugins are discovered globally from the next turn and can be toggled independently in Antigravity's Customizations UI (or filtered via "exclude" in plugins.json).

Measuring Efficiency #

scripts/measure_file_ops.py is a stdlib-only Python 3 script that scans ~/.gemini/antigravity/brain/*/.system_generated/logs/transcript_full.jsonl (falling back to transcript.jsonl) and outputs privacy-safe aggregate metrics: edit success rate, Target-echo / overwrite efficiency, read_file and same-file re-read volume, tokens and latency per successful edit, and schema break-even analysis. See benchmarks/baseline.md for an example baseline report.

Common Commands #

Capture a baseline snapshot:

python3 scripts/measure_file_ops.py \
  --label baseline \
  --json-out benchmarks/baseline.json \
  --md-out benchmarks/baseline.md

Compare sessions after enabling a plugin or hook against the baseline:

python3 scripts/measure_file_ops.py \
  --since 2026-11-29 \
  --label after-tilth \
  --compare benchmarks/baseline.json

Model break-even thresholds for custom per-turn schema/rule token sizes:

python3 scripts/measure_file_ops.py \
  --schema-tokens 1000,2500,5000

Dry-run a PreToolUse hook script against historical tool calls before enabling it:

python3 scripts/measure_file_ops.py \
  --hook-matcher 'run_command' \
  --dry-run-hook './plugins/file-ops/hooks/rtk-rewrite.py'

Additional useful flags: --brain-dir, --until, --hook-limit, --hook-timeout, and --hook-samples.