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.
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.
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 --loginoragy)
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 theagybinary if it is not onPATHor 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
agyturns: only your new message (and attached images) is sent;agykeeps 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 internalagyactions are stored in collapsiblepi-gravity-actionsentries and injected non-destructively via Pi'scontexthook whenever another model takes over, so Claude/OpenAI models see what files or commandsagytouched without cluttering the chat transcript. /resume,/tree,/fork: resuming a Pi session lazily reconnects to the matchingagysession viasession/resume. Rolling back in/tree, forking, recovering from an interrupted turn, or changingcwdautomatically starts a freshagysession with the active branch's history.
2. Combined Tools (agy Native + Pi Extensions)
- Coding & terminal tools:
agyruns its own file, search, web, and shell tools internally, launched with--dangerously-skip-permissionsto match Pi's permissionless workflow. Live progress renders in a themed@earendil-works/pi-tuiwidget above Pi's editor, and finished internal actions flush chronologically into compact collapsible action cards (Ctrl+Oto 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 exceptread,write,edit,bash) is automatically exposed toagythrough an ephemeral, loopback-only Streamable HTTP MCP server (127.0.0.1with a per-process random bearer token). Whenagyinvokes one,pi-gravitypauses the MCP call, emits a native PitoolCall, lets Pi execute it with your real session identity, hooks, and UI, and feeds thetoolResultback into the sameagyturn.
3. Compaction
agy's live window occupancy (usage_update.used) is reported to Pi's context meter, so auto-compaction inagylowers Pi's meter automatically instead of triggering duplicate compaction.- Pi's
/compactand/treebranch summaries run as isolated one-off summary calls (Pi extension tools are omitted, the prompt instructsagynot 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,agystarts a fresh session seeded with Pi's pinned summary.
Current Trade-offs
- Internal
agytools bypass Pi'stool_callhooks: file edits and shell commands run byagyare 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:agyuses its own system prompt and skills. CLI-based Pi skills (likepi-dock) can still be invoked byagy's shell once referenced or registered under~/.gemini/config/skills/. - Single active turn per Pi process: concurrent
agystreams in one Pi process are not supported. - Model catalog refresh & window sizes:
agy acpdoes not report per-model context windows in its catalog, sorefreshModelspairs live model IDs with prefix-based window defaults (1Mdefault/Gemini,200KClaude,128KGPT) and caches the catalog for 24h in~/.pi/agent/models-store.jsonusing an isolated ephemeralagyprocess (remove the"agy"entry frommodels-store.jsonto force an immediate refresh). - Session token totals reflect window occupancy, not cumulative multi-round tokens:
agy'ssession/promptusage sums tokens across all internal tool rounds in a turn. Because Pi'sUsagetype has a single set ofinput/cacheRead/cacheWritefields—and Pi's overflow detector checksinput + cacheRead > contextWindow—pi-gravityscales those prompt buckets down tousage_update.usedon 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$0regardless).
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