← Catalog

@ravshansbox/pi-vscode

VS Code editor context extension for pi

Extension

Install

Install with PiG

pig install npm:@ravshansbox/pi-vscode

Install with Pi

pi install npm:@ravshansbox/pi-vscode
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.5.8 (README.md). PiG does not review it.

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

  1. Open a folder in VS Code
  2. Open VS Code terminal (`Ctrl+``)
  3. Run pi
  4. The extension auto-connects and shows current file in widget
  5. Select code → widget updates instantly
  6. 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 Server
  • PI Companion: Stop Server
  • PI Companion: Show Status

pi Tools (for LLM)

ToolDescription
get_ide_contextFull IDE context
get_current_fileCurrent file with selection
list_open_filesList 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.

ToolDescription
get_open_filesOpen files with content, cursor and selection
read_fileRead a file by absolute path
gotoOpen 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.