@ravshansbox/pi-vscode
VS Code editor context extension for pi
Package details
Install @ravshansbox/pi-vscode from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@ravshansbox/pi-vscode- Package
@ravshansbox/pi-vscode- Version
0.5.6- Published
- Oct 29, 2026
- Downloads
- 1,457/mo · 1,457/wk
- Author
- ravshansbox
- License
- MIT
- Types
- extension
- Size
- 13.8 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
VS Code PI Companion
A VS Code extension that provides real-time IDE context (files, selection) to pi and other agents.
Features
- Real-time context: Monitors open files, cursor position, and selection
- Instant updates: Pushes context changes via SSE
- Seamless integration: Injects the current selection, or the active file (first 100 lines) if nothing is selected, into the LLM context
- Widget display: Shows current file/selection in pi UI
Architecture
VS Code Extension → SSE ← pi Extension
- VS Code: Context tracking, SSE server, MCP server
- pi: SSE client, Widget, Context injection
Installation
1. Install pi Extension
pi install npm:@ravshansbox/pi-vscode
2. Install VS Code Extension
The pi extension will auto-install the VS Code extension when you run pi in a VS Code terminal.
Alternatively, install it from the VS Code Marketplace or run:
code --install-extension ravshansbox.vscode-pi-companion
Then reload VS Code window.
Usage
- Open a folder in VS Code
- Open VS Code terminal (`Ctrl+``)
- Run
pi - The extension auto-connects and shows current file in widget
- Select code → widget updates instantly
- The selection (or the active file) is injected into LLM context automatically
Widget Display
vscode: disconnected # VS Code extension not reachable
filename # no selection
filename L9 # single line
filename L9:14 # multi-line selection
filename L9:14 +2 # 2 more files open
The widget shows above the editor. Status lines such as vscode: disconnected only show when pi runs in a VS Code terminal.
VS Code Commands
PI Companion: Start ServerPI Companion: Stop ServerPI Companion: Show Status
pi Tools (for LLM)
| Tool | Description |
|---|---|
get_ide_context |
Full IDE context |
get_current_file |
Current file with selection |
list_open_files |
List all open files |
MCP Server (for other agents)
The VS Code extension serves MCP at http://127.0.0.1:$PI_COMPANION_PORT/mcp. Send Authorization: Bearer $PI_COMPANION_AUTH_TOKEN. Both variables are set in VS Code terminals.
| Tool | Description |
|---|---|
get_open_files |
Open files with content, cursor and selection |
read_file |
Read a file by absolute path |
goto |
Open a file at a line and character |
Development
npm install
npm run compile
npm test
# Package as .vsix
npm run package
Press F5 to run in Extension Development Host.