omp packages

pi-gravity0.1.1

Use Google Antigravity (agy) models in Pi over the Agent Client Protocol (ACP), with dual-context sync, live tool UI, and Pi extension tool bridging.

alvivar Published 2 days ago MIT ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-gravity

Use any model available in your Google Antigravity (agy) account directly inside Pi as a native model provider over the official Agent Client Protocol (agy acp).

Models are discovered dynamically from agy acp. Pick any agy/* model from /model, toggle thinking depth with Shift+Tab, watch real context usage in Pi's footer, and switch freely between Antigravity, Claude, and OpenAI models inside the same Pi conversation.


Quick Start

Prerequisites

  • Pi (@earendil-works/pi-coding-agent)
  • Google Antigravity CLI (agy), installed and authenticated (agy --login or agy)

Install

Install via Pi's package manager:

pi install npm:pi-gravity

Then run /reload inside Pi (or start a new session) and verify the models are available:

pi --list-models agy

Select any agy/* model reported for your account via /model.

Configuration

  • AGY_BIN (optional): explicit path to the agy binary if it is not on PATH or in the default install location.

How It Works

agy acp is a stateful agent protocol, whereas Pi's standard providers are stateless. pi-gravity bridges both models so Pi stays your primary interface:

1. Synchronized Context & Model Switching

Pi remains the source of truth for the conversation tree. After each agy turn, pi-gravity stores a lightweight watermark (sessionId, message count, and prefix hash) in a pi-gravity-sync entry on the current Pi branch:

  • Consecutive agy turns: only your new message (and attached images) is sent; agy keeps its own in-session memory without re-sending history.
  • Switching from another model → agy: only the turns that happened since the last watermark are forwarded as a compact delta.
  • Switching from agy → another model: agy's replies are saved as clean Pi assistant messages, while internal agy actions are stored in collapsible pi-gravity-actions entries and injected non-destructively via Pi's context hook whenever another model takes over, so Claude/OpenAI models see what files or commands agy touched without cluttering the chat transcript.
  • /resume, /tree, /fork: resuming a Pi session lazily reconnects to the matching agy session via session/resume. Rolling back in /tree, forking, recovering from an interrupted turn, or changing cwd automatically starts a fresh agy session with the active branch's history.

2. Combined Tools (agy Native + Pi Extensions)

  • Coding & terminal tools: agy runs its own file, search, web, and shell tools internally, launched with --dangerously-skip-permissions to match Pi's permissionless workflow. Live progress renders in a themed @earendil-works/pi-tui widget above Pi's editor, and finished internal actions flush chronologically into compact collapsible action cards (Ctrl+O to expand command outputs and durations) right above each bridged tool call and final reply.
  • Pi extension tools (pi-link, codemode, MCP servers, etc.): any active non-core Pi tool (everything except read, write, edit, bash) is automatically exposed to agy through an ephemeral, loopback-only Streamable HTTP MCP server (127.0.0.1 with a per-process random bearer token). When agy invokes one, pi-gravity pauses the MCP call, emits a native Pi toolCall, lets Pi execute it with your real session identity, hooks, and UI, and feeds the toolResult back into the same agy turn.

3. Compaction

  • agy's live window occupancy (usage_update.used) is reported to Pi's context meter, so auto-compaction in agy lowers Pi's meter automatically instead of triggering duplicate compaction.
  • Pi's /compact and /tree branch summaries run as isolated one-off summary calls (Pi extension tools are omitted, the prompt instructs agy not to invoke its native tools on a best-effort basis, the temporary ACP session is closed immediately, and sync state is untouched). On the next chat turn, agy starts a fresh session seeded with Pi's pinned summary.

Current Trade-offs

  • Internal agy tools bypass Pi's tool_call hooks: file edits and shell commands run by agy are not intercepted by Pi extensions (bridged Pi extension tools do run through Pi's full tool lifecycle).
  • Pi's system prompt and <available_skills> are not injected yet: agy uses its own system prompt and skills. CLI-based Pi skills (like pi-dock) can still be invoked by agy's shell once referenced or registered under ~/.gemini/config/skills/.
  • Single active turn per Pi process: concurrent agy streams in one Pi process are not supported.
  • Model catalog refresh & window sizes: agy acp does not report per-model context windows in its catalog, so refreshModels pairs live model IDs with prefix-based window defaults (1M default/Gemini, 200K Claude, 128K GPT) and caches the catalog for 24h in ~/.pi/agent/models-store.json using an isolated ephemeral agy process (remove the "agy" entry from models-store.json to force an immediate refresh).
  • Session token totals reflect window occupancy, not cumulative multi-round tokens: agy's session/prompt usage sums tokens across all internal tool rounds in a turn. Because Pi's Usage type has a single set of input/cacheRead/cacheWrite fields—and Pi's overflow detector checks input + cacheRead > contextWindow—pi-gravity scales those prompt buckets down to usage_update.used on multi-round turns so auto-compaction doesn't misfire. Pi's footer token totals therefore track per-turn window occupancy rather than raw cumulative tokens (reported cost is $0 regardless).

File Map

File Responsibility
index.ts Pi provider registration, ACP lifecycle, streaming, widget, and MCP ↔ toolUse continuation loop
acp-client.ts Minimal stdio NDJSON JSON-RPC 2.0 client for agy acp
context-sync.ts Pure watermark hashing, branch/session isolation, cross-model handoff formatting, and compaction-summary pinning
mcp-bridge.ts Ephemeral localhost Streamable HTTP MCP server bridging Pi extension tools into agy
tool-ui.ts Rich ACP tool metadata extraction, live themed TUI widget, and collapsible EntryRenderer card

License

MIT