Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Pi BridgeNew to Visual Studio Code? Get it now.
Pi Bridge

Pi Bridge

khChen

|
1 install
| (0) | Free
Run the pi coding agent in your VS Code sidebar: auditable tool calls, review-before-write diffs, interruptible sessions.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Pi Bridge

Marketplace Installs License

Run the pi coding agent in your VS Code sidebar — and watch what it does.

Works locally and in remote workspaces (SSH, devcontainer, Codespaces): the extension runs on the workspace side, so pi drives the code where it actually lives.

Every tool call becomes an auditable card. Every file write is shown as a real diff before it lands. You can stop a run, steer it mid-flight, or queue the next instruction while it works.

中文说明见 README.zh-CN.md。


Why another AI panel?

pi is a capable local coding agent, but it lives in a terminal. A terminal is great for typing commands and bad for watching an agent edit your code: diffs scroll by, tool calls are buried in logs, and the only undo is git checkout.

Pi Bridge makes three promises:

  1. Visible. Reading a file, running a command, editing code — each becomes a card you can read. Writes are shown as a diff against the real baseline before they happen.
  2. Interruptible. Stop at any moment, insert guidance (steer), or queue a follow-up instruction. No waiting for the model to finish thinking.
  3. Honest. The capability ceiling is the pi RPC protocol. We do not emulate the pi TUI and we do not invent state that pi cannot report.

This is not "yet another chat window". The value is turning an agent's execution into an auditable interface: who read what, which line is being changed, what it costs, how much context is left.


Features

Auditable tool calls

  • Inline cards for read / edit / write / bash / grep / find / ls / MCP tools, plus a generic fallback for anything unknown
  • Cards keep only what matters: target, status, duration, and the output when the output is the result (shell, search). Raw argument JSON is not dumped into the panel
  • Streaming output, collapse/expand, truncation marker, error output highlighted in red
  • Token usage, cost and duration per message and per session

Review before write, or auto-approve

  • Default is review-first: edit / write are blocked by a guard extension inside the pi process until you click Apply. The diff is computed from the on-disk baseline, not from the model's claims
  • Side-by-side diff panel in the editor area: file rail, hunk folding, unified/split toggle, inline comments that get sent back to the model as the rejection reason
  • Auto-approve (Cline-style): separate toggles for writes, shell commands, and other tools. The guard still builds the proposal, the extension answers Apply for you — so the diff, the audit trail and git undo are all preserved
  • Dangerous shell commands ask instead of refusing: you get the command, the rule it matched, and three choices — run it, edit it and run the edited version, or reject. Irreversible commands need a second confirmation. Writes outside the workspace or into .git/, .env*, *.pem, .ssh/ are still blocked outright
  • Undo with git: applied files are tracked and restored with git restore (created files with git clean); non-git workspaces are told why undo is unavailable

Interrupt, steer, queue

  • Stop a run; queue text returns to the composer
  • Press Enter while running to steer (insert guidance) and Alt+Enter to queue a follow-up
  • Queue bar shows pending steering / follow-up messages, clearable one by one

Context that stays honest

  • @ file mentions — only the path is sent; pi expands it with its own rules
  • Slash commands — only what get_commands returns (prompt templates, skills, extension commands)
  • Editor selection reference — becomes a fenced code block with path= / lines= metadata
  • Paste a screenshot with ⌘/Ctrl+V — sent as an image attachment
  • Shell passthrough — prefix with ! to run a command directly; output goes into the model's context
  • Input history — ↑ recalls previous messages, ↓ walks forward, Esc restores your draft

Sessions and forks

  • Recent sessions for the current folder in the empty state; full history list in the editor panel
  • Visual fork tree (get_tree), fork from any user message, clone, rename
  • Context compaction is visible in the stream (150k → 32k), manual or automatic
  • Export to HTML / JSONL
  • Multiple sessions run as separate pi processes with LRU reclamation, so switching never mixes transcripts

The extension UI channel, fully implemented

pi extensions talk to the user through ctx.ui. Pi Bridge implements all nine methods (select, confirm, input, editor, notify, setStatus, setWidget, setTitle, set_editor_text) and picks a layout by information density:

  • short interactions → inline card in the message stream
  • long option lists → draggable drawer (30–80% height, keyboard accessible)
  • multi-line editing → editor-area panel (closing it does not cancel the request)
  • multi-select questions render as checkboxes instead of asking you to type 1,3 — the extension gets the exact same answer string it would have gotten before

Requests are serialized FIFO, never lost when the sidebar is hidden, and timeouts are visible instead of silent.

Observability and settings

  • Model and thinking level sit in the composer action row — one place, always visible
  • Context usage, cost, run state and retry state on a single status line; details in an on-demand drawer
  • Settings panel covers the pi settings that matter for RPC, and labels every item with how it takes effect: runtime (immediate), client (immediate), restart required, or read-only pointer to pi's settings.json
  • Chinese and English UI; follows VS Code light/dark themes; the sidebar stays usable down to ~200 px wide

Requirements

Requirement Notes
VS Code 1.95+ The sidebar webview and the APIs used here need it
Node.js not required The extension bundles everything it needs
pi CLI 1.7+ Tested with 1.7.0. Not bundled — Pi Bridge drives your pi binary over its RPC protocol. Must be installed on the machine where the workspace lives (the remote host in a remote workspace)
A configured model Run pi auth login once in a terminal

If pi is missing, the panel shows a setup guide with the install command and a re-detect button. It never throws a red stack trace at you.


Install

  1. Open the Extensions view and search for Pi Bridge
  2. Click Install
  3. Reload the window and click the Pi Bridge icon in the activity bar

Or from a terminal:

code --install-extension khChen.pi-bridge

Remote workspaces (SSH · devcontainer · Codespaces)

The extension declares extensionKind: ["workspace"], so in a remote workspace it runs on the remote host:

  1. Open the remote window, then in the Extensions view choose Install in SSH: (or the devcontainer / Codespaces equivalent)
  2. Install pi on that host and run pi auth login there — the extension spawns the remote pi, reads the remote ~/.pi, and runs git/approval/undo against the remote checkout
  3. Everything else is the same: diffs, approvals, sessions, status

The only intentional difference: exported artifacts (e.g. session HTML) live on the remote filesystem, so instead of handing them to your local browser the extension reveals them in the Explorer and lets you copy the path. The status drawer shows an Environment row (Local / SSH: host) so you always know where pi is running.


Quick start

  1. npm i -g @earendil-works/pi-coding-agent (or your preferred pi install), then pi auth login
  2. Open a folder — Pi Bridge works on a single local workspace root
  3. Click the Pi Bridge icon in the activity bar
  4. Ask something like "list the files in this folder"

You will see text stream in, a bash/ls card appear, and the status line update with context usage and cost.

First things worth trying

  • Select ten lines in the editor → run Pi Bridge: Reference Selection → the selection becomes a pill
  • Ask pi to change a file → the diff panel opens; reject with a comment and watch the model receive it
  • Turn on Auto-approve: writes in settings, ask for a bigger refactor, then undo it from the status line

Configuration

All settings live under piBridge.* and are documented in the Settings UI. The ones people actually change:

Setting Default What it does
piBridge.executablePath auto-detect Path to pi; when empty, probes PI_BIN, then PATH, then ~/.pi/agent/bin/pi
piBridge.editApproval preview preview = review the diff before writing · perTool = confirm each write without the diff · auto = write directly (read-only diff + git undo)
piBridge.bashApproval deny-dangerous deny-dangerous blocks risky commands · confirm asks for every command · auto allows everything
piBridge.autoApproveWrite false Auto-approve write proposals (the guard still creates the proposal). Also toggled from the bar above the composer
piBridge.autoApproveBash false Auto-approve shell proposals
piBridge.otherApproval off Whether MCP / unknown tools need approval; confirm creates a proposal (no diff) with the tool name and argument preview
piBridge.autoApproveOther false Auto-approve those proposals (effective with otherApproval=confirm)
piBridge.allowUnsafe false Disables every block and approval. Dangerous; shows a persistent warning
piBridge.protectedGlobs .git, node_modules, .env*, *.pem, *.key, .ssh Paths that are always blocked on write
piBridge.bashDenyPatterns rm -rf /, sudo, git reset --hard, … Regex fragments blocked for shell commands
piBridge.sessionDir pi default Where sessions are read from / written to
piBridge.maxIdleProcesses 2 Background session processes kept alive (LRU)
piBridge.language auto auto follows the VS Code display language
piBridge.sendKey enter Send with Enter or with ⌘/Ctrl+Enter
piBridge.queueModifier alt While running, ⌥/Alt+Enter (default) or ⌘/Ctrl+Enter queues a follow-up; falls back to Alt when the send key is ⌘/Ctrl+Enter
piBridge.notifyOnComplete unfocused Notify when a run finishes: never / when VS Code is unfocused / always
piBridge.autoOpenDiffPanel true Open the diff panel when the first proposal arrives

Model and thinking level are not settings — they are live controls in the composer action row.


Commands and keybindings

Command Default keybinding
Pi Bridge: Open Chat —
Pi Bridge: New Session ⌥⌘N / Alt+Ctrl+N
Pi Bridge: Open Session History ⌥⌘H / Alt+Ctrl+H
Pi Bridge: Restart pi ⌥⌘⇧R / Alt+Ctrl+Shift+R
Pi Bridge: Open Pi Bridge Settings ⌥⌘G / Alt+Ctrl+G
Pi Bridge: Cycle Model ⌥⌘M / Alt+Ctrl+M
Pi Bridge: Cycle Thinking Level ⌥⌘T / Alt+Ctrl+T
Pi Bridge: Reference Selection —
Pi Bridge: Add to Pi Bridge editor context menu (selection) / quick fix
Pi Bridge: Fix with Pi Bridge quick fix (only when diagnostics exist)
Pi Bridge: Revert Last Applied Write —
Pi Bridge: Re-detect pi · Show Logs · Open Settings —

Keybindings apply while the Pi Bridge view is focused; every command is also available in the Command Palette.

Two editor entry points mirror Cline: Add to Pi Bridge appears in the editor context menu (with a selection) and in the quick-fix menu, and appends the selection plus nearby diagnostics to the composer — it does not send. Fix with Pi Bridge only appears in the quick-fix menu when the range actually has diagnostics, and sends a fix request right away.


Security and privacy

  • No telemetry. Pi Bridge adds none of its own and sends nothing anywhere. What you type goes to the model provider you configured for pi.
  • No credential handling. Authentication belongs to pi auth; the extension never sees or stores API keys.
  • Writes are gated by default. A guard extension loaded into the pi process blocks the tool call before any bytes are written, so "approve" really means "nothing was written yet".
  • Guard failures fail closed. If the guard itself throws, the tool call is blocked, not allowed.
  • Undo is explicit. Applied writes are tracked per session and undone with git restore / git clean.

Known limitations

Limitation Why
pi's TUI-only commands (/login, /mcp, /share, /settings) are unavailable They are handled inside pi's terminal UI and are not part of the RPC channel
Single workspace root Multi-root workspaces are not supported. Remote workspaces (SSH / devcontainer / Codespaces) are supported — install on the remote host
Undo requires a git repository No shadow-copy snapshots in this version
autoApproveOther has no effect yet pi does not route MCP/non-file tools through the guard, so there is no proposal to auto-approve
Input history recalls text only Selection/image pills are not replayed; re-reference them if you need the context
0.0.x Pre-1.0: UI and settings may still move

Troubleshooting

The panel shows a setup guide instead of chat. pi was not found. Set piBridge.executablePath, or put pi on PATH, then run Pi Bridge: Re-detect pi.

The model dropdown is empty. pi is not authenticated. Run pi auth login in a terminal and reload the window.

Undo is greyed out. The workspace is not a git repository, or nothing has been applied yet.

A write never happens and the card stays pending. The guard is waiting for your answer — check the inline card or the diff panel. After its timeout (default 120 s) the call is blocked with an explicit reason.

Why is there no /login, /mcp, … command? That is the protocol boundary, not a missing feature. See Known limitations.


Feedback and issues

  • Bug reports / feature requests: https://github.com/wrtx-dev/pi-bridge-code/issues
  • Please include: extension version (Extensions view → Pi Bridge), pi --version, your OS, whether the workspace is remote, what you expected, what happened, and the relevant lines from the Pi Bridge output channel (View → Output → Pi Bridge). For protocol-level problems, Pi Bridge (pi) has pi's stderr.
  • Redact secrets: no API keys, no .env contents, no full session files. Paths and repository names are fine to anonymise.
  • Security issues: please use a private security advisory instead of a public issue.

Development

git clone https://github.com/wrtx-dev/pi-bridge-code.git
cd pi-bridge-code
npm install
npm run build        # extension host + webview + guard
npm run dev:host     # isolated dev host (own profile, only this extension)

Four gates must stay green: npm run typecheck, npm run lint, npm run test, npm run build. npm run bench compares against a stored baseline; npm run package + npm run check:package validate the vsix.

Architecture, protocol coverage and UI rules live in docs/ (written in Chinese). Start with AGENTS.md, then docs/architecture.md and docs/rpc-adapter.md.


Documentation

Topic File
Repo rules, decision index, commands AGENTS.md
Process model, data flow, approvals docs/architecture.md
RPC coverage, extension UI, protocol invariants docs/rpc-adapter.md
UI and state model docs/ui-and-state.md
Where each status number is shown docs/status-surfaces.md
Performance and resource budgets docs/performance.md
Settings mapping (pi ↔ extension) docs/settings-mapping.md
Development progress board docs/todo.md

License

MIT, same as pi.

Pi Bridge depends only on pi's RPC protocol — it does not bundle pi and does not take a runtime dependency on it, so pi upgrades do not require a new release of this extension.

Acknowledgements

Interaction patterns are inspired by Cline and GitHub Copilot Chat. The agent and its protocol come from the pi project.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft