pi-ide-context

/ide for pi — connect Neovim/VS Code, auto-inject editor context into LLM messages

Packages

Package details

extension

Install pi-ide-context from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-ide-context
Package
pi-ide-context
Version
0.1.1
Published
Jul 19, 2026
Downloads
115/mo · 115/wk
Author
andy8647
License
MIT
Types
extension
Size
13.7 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-ide-context

/ide for pi — like Claude Code's IDE integration, but for Neovim and VS Code.

npm version GitHub

Select text in Neovim, switch to pi — pi already knows which file you're in, where your cursor is, and what you selected. No copy-paste. No :PiAsk. It just works.

Install

Pi extension

pi install npm:pi-ide-context

Then /reload in pi.

Neovim plugin (lazy.nvim)

{
  "Andy8647/pi-ide-context",
  lazy = false,
}

Usage

pi starts → widget shows · main.ts (detected, not connected)
  ↓
/ide → pick editor from list → connected
  ↓
widget shows ▸ main.ts → LLM receives editor context automatically
  ↓
/ide off → disconnect

When connected, every message you send to pi automatically includes:

### IDE Context
- File: /Users/andy/my-project/src/main.ts
- Language: typescript
- Cursor: line 42, column 10
- Buffer: 200 lines (modified)
- Selection: lines 40–45
  ```typescript
  const foo = bar();
  // ...

## How it works

┌──────────┐ writes JSON ┌──────────────┐ reads JSON ┌────────┐ │ Neovim │ ─────────────► │ /tmp/pi-ide/ │ ◄──────────── │ pi │ │ autocmd │ debounced │ .json │ before_ │ auto │ │ hooks │ every 200ms │ │ agent_start │ inject │ └──────────┘ └──────────────┘ └────────┘


**Neovim side**: autocmd on CursorMoved / TextChanged / BufEnter / ModeChanged writes
editor state to a JSON file. Zero dependencies — a single Lua file.

**Pi side**: `before_agent_start` hook reads the JSON, matches by cwd, and injects
formatted editor context. A `setInterval` widget shows live file/selection info below
the input area.

## Protocol

Editor state is written to `/tmp/pi-ide/<pid>.json`:

```json
{
  "pid": 12345,
  "cwd": "/Users/andy/my-project",
  "timestamp": 1700000000,
  "active_buffer": {
    "file": "/Users/andy/my-project/src/main.ts",
    "name": "main.ts",
    "language": "typescript",
    "cursor": { "line": 42, "column": 10 },
    "selection": {
      "start": { "line": 40, "column": 0 },
      "end": { "line": 45, "column": 20 },
      "text": "selected code here..."
    },
    "modified": false,
    "lines_total": 200
  }
}

Same protocol works for VS Code — just write the same JSON format. The pi extension needs zero changes.

License

MIT