@xl0/pi-lovely-ide
Pi package published to npm.
Package details
Install @xl0/pi-lovely-ide from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@xl0/pi-lovely-ide- Package
@xl0/pi-lovely-ide- Version
0.3.3- Published
- Jul 21, 2026
- Downloads
- 86/mo · 15/wk
- Author
- xl0
- License
- MIT
- Types
- extension
- Size
- 63.1 KB
- Dependencies
- 3 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./extensions"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-lovely-ide
Connect Pi to your IDE. Pi sees what you have selected in the editor, and you can send it code ranges and diagnostics with a keystroke — no copy-pasting file paths, line numbers, or compiler errors into the prompt.
The integration has two halves:
@xl0/pi-lovely-ide(this package) — a Pi extension that discovers IDE servers, maintains the connection, and turns IDE events into model context.- Pi Lovely IDE
(
xl0.pi-lovely-ide) — a VS Code extension that publishes editor state over the Pi IDE Protocol. Lives in this repo underide-plugins/vscode, distributed separately through the Marketplace.
What you get
- Selection context — Pi's footer live-tracks your cursor and selection. When you submit a prompt, the current selection (with a bounded excerpt of the selected text) is attached as context, so "why is this wrong?" just works.
- Mentions —
Alt+Shift+Lin VS Code pastes an@file#rangereference into Pi's input. The model gets the referenced code alongside your prompt. - Problems attachments —
Alt+Shift+Dpastes a[problems: …]marker carrying the diagnostics under your selection (or the whole file; a separate command attaches all workspace Problems). The model sees the diagnostics and the selected code they belong to. - Notebook support — selections, mentions, and Problems in notebook cells carry the cell id/index and cell-relative line numbers.
/ide— selector and live preview: pick an IDE endpoint or open scoped settings for auto-connect, auto-reconnect, selection context, context-message display, debug logging of raw IDE events, and the selected-text line budget.
Setup
Install the VS Code extension: search for Pi Lovely IDE in the Marketplace, or
code --install-extension xl0.pi-lovely-ideInstall the Pi package:
pi install npm:@xl0/pi-lovely-ideOr load it for a single session without installing:
pi -e npm:@xl0/pi-lovely-ideStart Pi in a folder that is (or is inside) a workspace folder open in VS Code. Pi auto-connects on startup; if it doesn't, run
/ideand pick the endpoint. The footer shows● IDEwith the IDE name once connected.
Settings support User (~/.pi/agent/xl0-lovely-ide.json) and Workspace
(<workspace>/.pi/xl0-lovely-ide.json) scopes. Workspace values override User values.
How it works
Each VS Code window runs a small WebSocket server on localhost and advertises it through a lockfile. Pi discovers lockfiles, picks the server whose workspace matches its own working directory, and connects.
VS Code window Pi session
┌──────────────────────────┐ ┌──────────────────────────┐
│ Pi Lovely IDE extension │ │ @xl0/pi-lovely-ide │
│ │ selection │ │
│ WebSocket server │ mention │ footer status │
│ on 127.0.0.1:<port> ─────┼──── diagnostics ─▶│ @refs and [problems] │
│ │ │ events │ model context │
└────────┼─────────────────┘ └────────────▲─────────────┘
│ writes │
▼ discovers and │ connects
~/.pi/ide/<port>.lock ──────────────────────────────────┘
(protocol, port, token, workspaces, PID)
Discovery and auth. The lockfile carries the protocol version, port, a random
per-server token, and the window's workspace folders. Pi only accepts a lockfile when the
protocol/version match, the advertised process is alive, and Pi's cwd equals or descends
from one of the workspace roots. The connection is authenticated with the token and starts
with a hello handshake declaring which events Pi wants (selection, mention,
diagnostics). Everything stays on localhost.
From event to model context. Selection events only update Pi's footer and a pending snapshot — nothing reaches the model until you submit a prompt. Mention and Problems events paste a plain-text reference into Pi's input; the rich context (referenced code, diagnostics, selected lines) is attached only if that reference is still present in the prompt you actually submit. Delete the marker and nothing extra is sent. If you mention a range explicitly, the ambient selection is skipped for that prompt so the model doesn't get the same code twice.
Context is injected as <selection>, <mention>, and <problems> blocks appended to your
message, and the bookkeeping markers are stripped from what the model sees. Aggregate
Problems context is capped at Pi's standard output limit; when it overflows, the full text
is written to a private temp file and the model gets the path.
Protocol docs
PI_IDE_PROTOCOL.md— canonical pi-native protocol.CC_IDE_PROTOCOL.md— historical Claude Code IDE protocol reference only.
Development
Pi package:
bun install
bun run check
pi -e .
VS Code plugin (ide-plugins/vscode):
cd ide-plugins/vscode
bun install
bun run compile
Debug from this repo with VS Code's Run VS Code Extension launch config. It compiles the
plugin, opens an Extension Development Host, starts a local Pi IDE Protocol server, and
writes ~/.pi/ide/<port>.lock. To package and install the plugin into your regular VS Code
(or another CLI such as cursor):
./dev-install-vscode-plugin.sh [ide-cli]
Manual smoke test:
- Launch
Run VS Code Extension. - In the Extension Development Host, open a project folder.
- Run Pi in the same project with this package loaded:
pi -e .. - Use
/ideif auto-connect did not connect. - Select text in VS Code; Pi footer should show the file/range.
- Run
Pi: Mention Selection; Pi input should receive@file#x-y. - Run
Pi: Attach Problems; Pi input should receive[problems: path#line-range].
Related projects
| Pi Lovely Web | web_search, web_fetch, web_image tools |
| Pi Lovely Dev Tools | interactive debugging helpers /tool, /show-sysprompt, /show-context, /llm-stats |
| Pi Lovely Codex | GPT fast mode and Codex-style apply_patch |
| Pi Lovely Config | Scoped config (User/Workspace) library for Pi extensions |
| Pi Lovely Comment | open the last assistant message in your editor and sync edits back into the prompt |
| Pi Lovely Rename | automatic and manual session naming |
Like this work? Hire me