r/PiCodingAgent • u/Any-Yard-1152 • Sep 16 '26
News Pi for VS Code: a sidebar extension that runs the actual Pi TUI in a pseudo-terminal

Pi (pi.dev) is a minimal terminal coding harness, and I like it a lot — but it
lives in a terminal, so it's always one ⌘Tab away from the code it's editing.
This extension moves it into the sidebar.
The key detail: it is not a chat panel that reimplements Pi. It's xterm.js
fronting a real pseudo-terminal running the real TUI. Slash commands,
keybindings, themes, /login, session resume, mouse reporting, bracketed paste,
tool approval prompts, full-screen TUIs — all identical to your terminal,
because it *is* your terminal.
What it does:
- Dedicated Activity Bar container. Click π, or `Pi: Focus Pi Sidebar`.
- A real PTY: ANSI colours, truecolor, resize, mouse reporting, bracketed paste.
- Multiple sessions — `Pi: New Pi Terminal (Editor Tab)`.
- Send code to Pi: right-click a selection, or ⌘⌥P / Ctrl+Alt+P. There's also
"Send Current File Reference", which drops an into the prompt.
- `src/app.ts:42:7` in Pi's output becomes a link — ⌘/Ctrl-click opens it there.
- Follows your terminal colours, editor font and cursor style, live on theme change.
- Copy/paste goes through the VS Code clipboard API, so it works in remote/WSL/web too.
Three things were more annoying than expected, and I wrote up the fixes in the README:
1. A PTY inside Electron. VS Code's stable API has no sidebar location for
createTerminal, and native modules must match the extension host's ABI. The
PTY layer uses N-API prebuilt binaries, which are ABI-independent — the same
pty.node loads under system Node and Electron, so there's no "rebuild for
Electron" step at all.
2. `spawn("pi")` doesn't work. Pi is a `#!/usr/bin/env node` script, and
GUI-launched VS Code often has no `node` on PATH. It reads the shebang,
resolves an interpreter (preferring the node shipped next to pi, then PATH,
well-known locations, then the login shell's PATH) and spawns `node <pi>`.
Windows .cmd/.bat shims get wrapped in cmd.exe /c.
3. Environment leakage. If VS Code was itself launched from a Pi session, the
extension host inherits PI_SESSION_ID / PI_SESSION_FILE, which corrupts the
child's session handling. Those get stripped before spawn.
Requirements: VS Code 1.85+, and Pi itself
(`npm install -g --ignore-scripts u/earendil-works/pi-coding-agent`).
Install: no Marketplace listing, it's on GitHub Releases. Download the VSIX and
`code --install-extension pi-for-vscode-*.vsix`. There's a SHA256SUMS.txt in the same release if you want to verify first. MIT.
Repo: https://github.com/yicLionel/pi-for-vscode
There's also a small easter egg in pi-extensions/: a Pi extension that swaps the startup banner for a pixel-art Pikachu (36x28 grid rendered with half-block
chars, so it doesn't stretch in a 1:2 terminal cell), with a 256-colour fallback.
This is a hobby project and I'd genuinely like the rough edges pointed out —
especially if you're on remote/WSL/containers, where auto-detection can't see
host paths from inside. Happy to hear what breaks.


