pi-x-ide 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -114
- package/README.zh.md +183 -114
- package/dist/package.json +10 -4
- package/dist/src/nvim/sidecar-schema.d.ts +25 -0
- package/dist/src/nvim/sidecar-schema.js +64 -0
- package/dist/src/nvim/sidecar-schema.js.map +1 -0
- package/dist/src/nvim/sidecar.d.ts +16 -0
- package/dist/src/nvim/sidecar.js +173 -0
- package/dist/src/nvim/sidecar.js.map +1 -0
- package/dist/src/pi/index.js +10 -2
- package/dist/src/pi/index.js.map +1 -1
- package/dist/src/pi/install.js +22 -1
- package/dist/src/pi/install.js.map +1 -1
- package/dist/src/shared/ide-server.d.ts +20 -0
- package/dist/src/shared/ide-server.js +144 -0
- package/dist/src/shared/ide-server.js.map +1 -0
- package/dist/src/shared/lock-file.d.ts +16 -0
- package/dist/src/shared/lock-file.js +58 -0
- package/dist/src/shared/lock-file.js.map +1 -0
- package/dist/src/shared/paths.js +8 -1
- package/dist/src/shared/paths.js.map +1 -1
- package/dist/src/shared/protocol.d.ts +1 -1
- package/dist/src/shared/schema.js +1 -1
- package/dist/src/shared/schema.js.map +1 -1
- package/dist/test/nvim-sidecar.test.d.ts +1 -0
- package/dist/test/nvim-sidecar.test.js +148 -0
- package/dist/test/nvim-sidecar.test.js.map +1 -0
- package/dist/test/shared.test.js +10 -0
- package/dist/test/shared.test.js.map +1 -1
- package/nvim/bin/pi-x-ide-nvim-sidecar.cjs +21 -0
- package/nvim/doc/pi-x-ide.txt +112 -0
- package/nvim/lua/pi_x_ide/init.lua +442 -0
- package/nvim/plugin/pi-x-ide.lua +15 -0
- package/package.json +10 -4
- package/src/nvim/sidecar-schema.ts +71 -0
- package/src/nvim/sidecar.ts +219 -0
- package/src/pi/index.ts +12 -2
- package/src/pi/install.ts +24 -1
- package/src/shared/ide-server.ts +120 -0
- package/src/shared/lock-file.ts +65 -0
- package/src/shared/paths.ts +8 -1
- package/src/shared/protocol.ts +1 -1
- package/src/shared/schema.ts +1 -1
package/README.md
CHANGED
|
@@ -1,132 +1,113 @@
|
|
|
1
1
|
# Pi × IDE
|
|
2
2
|
|
|
3
|
-
Pi extension package for IDE selection context integration.
|
|
3
|
+
> Pi extension package for IDE selection context integration.
|
|
4
4
|
|
|
5
|
-
Automatically attaches the currently opened or selected file and text range from VS Code
|
|
5
|
+
Automatically attaches the currently opened or selected file and text range from VS Code, Zed, and Neovim to the Pi TUI, submitting them as conversation context to the LLM.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
## Installation & Usage
|
|
10
|
+
|
|
11
|
+
### 1. Install Pi CLI
|
|
12
|
+
|
|
13
|
+
[Pi Quickstart](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/quickstart.md)
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
### 2. Install the Pi Extension Package
|
|
15
16
|
|
|
16
17
|
```bash
|
|
17
|
-
|
|
18
|
-
pnpm build
|
|
18
|
+
pi install npm:pi-x-ide
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
This installs `pi-x-ide` as a global Pi extension. Pi loads it automatically on startup — no flags needed.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
| --------------------- | -------------------------------------------------------------------------------- |
|
|
25
|
-
| `pnpm build` | Build Pi-side TypeScript → `dist/` + VS Code-side esbuild bundle → `vscode/out/` |
|
|
26
|
-
| `pnpm typecheck` | Type-check only (no output files) |
|
|
27
|
-
| `pnpm test` | Build + run unit tests |
|
|
28
|
-
| `pnpm package:vscode` | Package VS Code extension as VSIX |
|
|
29
|
-
| `pnpm vsix` | Alias for `pnpm package:vscode` |
|
|
23
|
+
### 3. Install the IDE Extension
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
#### VS Code / Cursor / Windsurf
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
**Option A: Install from Marketplace (Recommended)**
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
2. Go to the **Run and Debug** panel (`Ctrl+Shift+D`).
|
|
37
|
-
3. Select **Run Pi x IDE VS Code Extension**.
|
|
38
|
-
4. Press **F5**:
|
|
39
|
-
- The `preLaunchTask` will automatically run `pnpm build`.
|
|
40
|
-
- A new VS Code window titled `[Extension Development Host]` opens.
|
|
29
|
+
Install `balaenis.pi-x-ide` from your IDE's Extensions marketplace.
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
**Option B: Install via Pi CLI**
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
pnpm package:vscode
|
|
46
|
-
code --install-extension './vscode'-0.1.0.vsix
|
|
47
|
-
```
|
|
33
|
+
In Pi's TUI, run `/ide install` — it auto-detects `code`, `cursor`, or `windsurf` and installs the extension.
|
|
48
34
|
|
|
49
|
-
|
|
35
|
+
**Option C: Auto-install on Pi startup**
|
|
50
36
|
|
|
51
|
-
|
|
37
|
+
When Pi starts from a supported VS Code integrated terminal, it attempts to auto-install or update the extension asynchronously. To disable:
|
|
52
38
|
|
|
53
39
|
```bash
|
|
54
|
-
|
|
40
|
+
PI_X_IDE_AUTO_INSTALL=0
|
|
55
41
|
```
|
|
56
42
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
If not, run **Developer: Reload Window** in VS Code.
|
|
60
|
-
|
|
61
|
-
## Connecting to Pi
|
|
43
|
+
See [Configuration Reference](#pi-side-environment-variables) for all available options.
|
|
62
44
|
|
|
63
|
-
|
|
45
|
+
#### Zed
|
|
64
46
|
|
|
65
|
-
|
|
66
|
-
pi -e ./src/pi/index.ts
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
The Pi TUI should display:
|
|
47
|
+
No extension installation is needed. Pi automatically detects Zed when running inside a Zed terminal (`ZED_TERM=true` or `TERM_PROGRAM=zed`). Pi reads Zed's local state database to discover the active editor file and selection.
|
|
70
48
|
|
|
71
|
-
|
|
72
|
-
- A widget below the input box showing: IDE name, workspace, current file, selection range, and `pending/sent` status
|
|
49
|
+
Requires Node.js ≥ 26 and Zed running on the same machine.
|
|
73
50
|
|
|
74
|
-
|
|
51
|
+
#### Neovim
|
|
75
52
|
|
|
76
|
-
|
|
77
|
-
PI_X_IDE_AUTO_INSTALL=0
|
|
78
|
-
```
|
|
53
|
+
Neovim support uses a Lua plugin plus a bundled Node.js sidecar. Pi can run from any terminal matching the Neovim workspace — it does not need to run inside Neovim.
|
|
79
54
|
|
|
80
|
-
|
|
55
|
+
**lazy.nvim:**
|
|
81
56
|
|
|
82
|
-
```
|
|
57
|
+
```lua
|
|
83
58
|
{
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
59
|
+
"balaenis/pi-x-ide",
|
|
60
|
+
init = function()
|
|
61
|
+
vim.opt.rtp:prepend(vim.fn.stdpath("data") .. "/lazy/pi-x-ide/nvim")
|
|
62
|
+
end,
|
|
63
|
+
config = function()
|
|
64
|
+
require("pi_x_ide").setup({
|
|
65
|
+
keymap = "<C-A-k>",
|
|
66
|
+
})
|
|
67
|
+
end,
|
|
87
68
|
}
|
|
88
69
|
```
|
|
89
70
|
|
|
90
|
-
|
|
71
|
+
> **Note:** The `init` block manually adds the `nvim/` subdirectory to the runtime path to avoid a Lua module resolution issue with some lazy.nvim versions.
|
|
91
72
|
|
|
92
|
-
|
|
73
|
+
**Native package:**
|
|
93
74
|
|
|
75
|
+
```vim
|
|
76
|
+
set runtimepath+=/path/to/pi-x-ide/nvim
|
|
77
|
+
lua require("pi_x_ide").setup({ keymap = "<leader>pa" })
|
|
94
78
|
```
|
|
95
|
-
/ide auto
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
If auto-install succeeds but no connection appears, reload the IDE window and run `/ide auto` again. You can also run `/ide install` to choose a supported `code`, `cursor`, or `windsurf` CLI manually.
|
|
99
79
|
|
|
100
|
-
|
|
80
|
+
See [Configuration Reference](#neovim-2) for full setup options, commands, and troubleshooting.
|
|
101
81
|
|
|
102
|
-
###
|
|
82
|
+
### 4. Connect Pi & Verify
|
|
103
83
|
|
|
104
|
-
|
|
84
|
+
Start Pi in the **same project directory** as your IDE workspace:
|
|
105
85
|
|
|
86
|
+
```bash
|
|
87
|
+
pi
|
|
106
88
|
```
|
|
107
|
-
IDE: vscode ✓ src/foo.ts#L10,20 pending
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Manual Keyboard Shortcut
|
|
111
89
|
|
|
112
|
-
|
|
90
|
+
Pi auto-loads `pi-x-ide` and connects to your IDE. The TUI should display `IDE: vscode ✓` in the footer and a widget showing the IDE name, workspace, current file, and selection range.
|
|
113
91
|
|
|
114
|
-
|
|
115
|
-
- macOS: `Cmd+Alt+K`
|
|
92
|
+
**Verify it works:**
|
|
116
93
|
|
|
117
|
-
|
|
94
|
+
Open a file in your IDE and select some text. The widget should update in real time:
|
|
118
95
|
|
|
119
96
|
```
|
|
120
|
-
|
|
97
|
+
IDE: vscode ✓ src/foo.ts#L10,20 pending
|
|
121
98
|
```
|
|
122
99
|
|
|
123
|
-
|
|
100
|
+
Press `Ctrl+Alt+K` (Linux/Windows) or `Cmd+Alt+K` (macOS) — the Pi input box should insert `@src/foo.ts#L10,20`.
|
|
124
101
|
|
|
125
|
-
Type a
|
|
102
|
+
Type a chat prompt in Pi and submit it. The selected text is injected as LLM context (does not persist in session history). After submission, the widget shows `sent`.
|
|
126
103
|
|
|
127
|
-
|
|
104
|
+
**If the connection doesn't appear:**
|
|
128
105
|
|
|
129
|
-
|
|
106
|
+
- Run `/ide auto` in Pi to re-attempt matching.
|
|
107
|
+
- If the IDE was started after Pi, reload the IDE window and run `/ide auto` again.
|
|
108
|
+
- Run `/ide` to manually select a connection from the list.
|
|
109
|
+
|
|
110
|
+
### `/ide` Command Reference
|
|
130
111
|
|
|
131
112
|
| Command | Behavior |
|
|
132
113
|
| -------------- | ----------------------------------------------------------------- |
|
|
@@ -138,63 +119,151 @@ After submission, the TUI displays `sent`.
|
|
|
138
119
|
| `/ide attach` | Manually insert the latest selection range into the input box |
|
|
139
120
|
| `/ide install` | Install or update `balaenis.pi-x-ide` through a supported IDE CLI |
|
|
140
121
|
|
|
141
|
-
|
|
122
|
+
### Configuration Reference
|
|
123
|
+
|
|
124
|
+
#### VS Code
|
|
125
|
+
|
|
126
|
+
| Key | Type | Default | Description |
|
|
127
|
+
| -------------------- | --------------------- | --------- | --------------------------------------------- |
|
|
128
|
+
| `piXIde.rangeFormat` | `"comma"` \| `"dash"` | `"comma"` | File reference format for the manual shortcut |
|
|
129
|
+
|
|
130
|
+
#### Zed
|
|
142
131
|
|
|
143
|
-
|
|
132
|
+
| Environment Variable | Default | Description |
|
|
133
|
+
| -------------------- | ------------- | ------------------------------------ |
|
|
134
|
+
| `PI_X_IDE_ZED_DB` | (auto-detect) | Override path to Zed SQLite database |
|
|
135
|
+
|
|
136
|
+
Default database paths:
|
|
137
|
+
|
|
138
|
+
- **Linux:** `~/.local/share/zed/db/0-stable/db.sqlite`
|
|
139
|
+
- **macOS:** `~/Library/Application Support/Zed/db/0-stable/db.sqlite`
|
|
140
|
+
- **Windows:** `%LOCALAPPDATA%\Zed\db\0-stable\db.sqlite`
|
|
141
|
+
- **WSL with Windows Zed:** `/mnt/c/Users/<user>/AppData/Local/Zed/db/0-stable/db.sqlite`
|
|
142
|
+
|
|
143
|
+
When Pi runs in WSL and Zed runs as a Windows app, pi-x-ide normalizes Windows paths (`C:\Users\<user>\project`) to `/mnt/c/Users/<user>/project`, and matching WSL UNC paths to `/home/<user>/project`.
|
|
144
|
+
|
|
145
|
+
#### Neovim
|
|
146
|
+
|
|
147
|
+
```lua
|
|
148
|
+
require("pi_x_ide").setup({
|
|
149
|
+
enabled = true,
|
|
150
|
+
keymap = "<C-A-k>",
|
|
151
|
+
range_format = "comma", -- or "dash"
|
|
152
|
+
debounce_ms = 150,
|
|
153
|
+
-- sidecar_cmd = { "node", "/absolute/path/to/pi-x-ide-nvim-sidecar.cjs" },
|
|
154
|
+
-- workspace_folders = { "/path/to/project" },
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If the sidecar does not start, run `:PiXIdeStatus`, confirm Node.js is available on Neovim's `PATH`, or set `sidecar_cmd` to an absolute Node command.
|
|
159
|
+
|
|
160
|
+
**Commands:**
|
|
161
|
+
|
|
162
|
+
| Command | Behavior |
|
|
163
|
+
| --------------- | ------------------------------------------------------------------- |
|
|
164
|
+
| `:PiXIdeStart` | Start the Neovim sidecar and write the lock file |
|
|
165
|
+
| `:PiXIdeStop` | Stop the sidecar and remove the lock file |
|
|
166
|
+
| `:PiXIdeStatus` | Show whether the sidecar is running |
|
|
167
|
+
| `:PiXIdeAttach` | Attach the current file or selection to Pi as `@relative/path#Lx,y` |
|
|
168
|
+
|
|
169
|
+
#### Pi-side Environment Variables
|
|
170
|
+
|
|
171
|
+
Pi-side variables can be set as real environment variables or in `~/.pi/config.json` under `env`. Real environment variables take precedence.
|
|
172
|
+
|
|
173
|
+
| Variable | Default | Description |
|
|
174
|
+
| ----------------------- | --------------------- | -------------------------------------------- |
|
|
175
|
+
| `PI_X_IDE_AUTO_INSTALL` | `1` | Auto-install VS Code extension on Pi startup |
|
|
176
|
+
| `PI_X_IDE_LOCK_DIR` | `~/.pi/pi-x-ide/lock` | Directory for IDE connection lock files |
|
|
177
|
+
| `PI_X_IDE_ZED_DB` | (auto-detect) | Override path to Zed SQLite database |
|
|
178
|
+
|
|
179
|
+
See [schemas/config.json](schemas/config.json) for editor schema guidance.
|
|
180
|
+
|
|
181
|
+
### Feature Parity
|
|
182
|
+
|
|
183
|
+
| Feature | VS Code | Zed | Neovim |
|
|
184
|
+
| ----------------------------------- | ----------------- | ------------------------------- | ----------------------------- |
|
|
185
|
+
| Live file tracking | ✅ Real-time push | ✅ 1s polling | ✅ Real-time push via sidecar |
|
|
186
|
+
| Live selection tracking | ✅ Real-time push | ✅ 1s polling | ✅ Real-time push via sidecar |
|
|
187
|
+
| `Ctrl+Alt+K` / `Cmd+Alt+K` shortcut | ✅ | Use `@<relative-path>` manually | User-configured keymap |
|
|
188
|
+
| LLM context injection | ✅ | ✅ | ✅ |
|
|
189
|
+
| `/ide auto` | ✅ | ✅ | ✅ |
|
|
190
|
+
|
|
191
|
+
### Lock File Protocol
|
|
192
|
+
|
|
193
|
+
After the IDE WebSocket server starts, connection information is written to `~/.pi/pi-x-ide/lock/` by default. Override the directory with `PI_X_IDE_LOCK_DIR`.
|
|
144
194
|
|
|
145
195
|
Pi uses `ctx.cwd` to find the longest path match against `workspaceFolders` in the lock files, selecting the best-matching and most recent IDE connection. Pi auto-connects only when the current `cwd` is inside or equal to one of the IDE `workspaceFolders`; if `cwd` is only a parent directory such as `~/`, run `/ide` to choose a connection manually.
|
|
146
196
|
|
|
147
197
|
See [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md) for protocol details.
|
|
148
198
|
|
|
149
|
-
|
|
199
|
+
---
|
|
150
200
|
|
|
151
|
-
|
|
201
|
+
## Development
|
|
152
202
|
|
|
153
|
-
|
|
203
|
+
### Prerequisites
|
|
154
204
|
|
|
155
|
-
|
|
205
|
+
- Node.js ≥ 26
|
|
206
|
+
- pnpm ≥ 11 (`packageManager` declared as `pnpm@11.5.2`)
|
|
207
|
+
- VS Code ≥ 1.90 (VS Code extension only)
|
|
208
|
+
- Neovim ≥ 0.9 (Neovim plugin only)
|
|
156
209
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
210
|
+
### Install & Build
|
|
211
|
+
|
|
212
|
+
Clone the repository, then build:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
git clone https://github.com/balaenis/pi-x-ide.git
|
|
216
|
+
cd pi-x-ide
|
|
217
|
+
pnpm install
|
|
218
|
+
pnpm build
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
To load the local build without installing globally:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pi -e ./src/pi/index.ts
|
|
225
|
+
```
|
|
160
226
|
|
|
161
|
-
|
|
227
|
+
Common commands:
|
|
162
228
|
|
|
163
|
-
|
|
229
|
+
| Command | Description |
|
|
230
|
+
| --------------------- | -------------------------------------------------------------------------------------------------- |
|
|
231
|
+
| `pnpm build` | Build Pi-side TypeScript → `dist/` + Neovim sidecar → `nvim/bin/` + VS Code bundle → `vscode/out/` |
|
|
232
|
+
| `pnpm typecheck` | Type-check only (no output files) |
|
|
233
|
+
| `pnpm test` | Build + run unit tests |
|
|
234
|
+
| `pnpm package:vscode` | Package VS Code extension as VSIX |
|
|
235
|
+
| `pnpm vsix` | Alias for `pnpm package:vscode` |
|
|
164
236
|
|
|
165
|
-
###
|
|
237
|
+
### Testing the VS Code Extension Locally
|
|
166
238
|
|
|
167
|
-
|
|
239
|
+
#### Option 1: F5 Extension Development Host (Recommended)
|
|
168
240
|
|
|
169
|
-
|
|
241
|
+
1. Open the **project root** in VS Code.
|
|
242
|
+
2. Go to the **Run and Debug** panel (`Ctrl+Shift+D`).
|
|
243
|
+
3. Select **Run Pi x IDE VS Code Extension**.
|
|
244
|
+
4. Press **F5**:
|
|
245
|
+
- The `preLaunchTask` automatically runs `pnpm build`.
|
|
246
|
+
- A new VS Code window titled `[Extension Development Host]` opens.
|
|
170
247
|
|
|
171
|
-
|
|
172
|
-
- Pi launched from Zed's integrated terminal
|
|
173
|
-
- Node.js ≥ 26 (required for `node:sqlite`)
|
|
248
|
+
#### Option 2: Package VSIX and Install
|
|
174
249
|
|
|
175
|
-
|
|
250
|
+
```bash
|
|
251
|
+
pnpm package:vscode
|
|
252
|
+
code --install-extension './vscode'-0.1.0.vsix
|
|
253
|
+
```
|
|
176
254
|
|
|
177
|
-
|
|
178
|
-
| -------------------- | ------------- | ------------------------------------ |
|
|
179
|
-
| `PI_X_IDE_ZED_DB` | (auto-detect) | Override path to Zed SQLite database |
|
|
255
|
+
The extension installed this way runs in all VS Code windows, independent of the F5 Extension Host.
|
|
180
256
|
|
|
181
|
-
|
|
257
|
+
#### Verify the Extension is Running
|
|
182
258
|
|
|
183
|
-
|
|
259
|
+
```bash
|
|
260
|
+
ls -l ~/.pi/pi-x-ide/lock
|
|
261
|
+
```
|
|
184
262
|
|
|
185
|
-
- **
|
|
186
|
-
- **macOS:** `~/Library/Application Support/Zed/db/0-stable/db.sqlite`
|
|
187
|
-
- **Windows:** `%LOCALAPPDATA%\\Zed\\db\\0-stable\\db.sqlite`
|
|
188
|
-
- **WSL with Windows Zed:** `/mnt/c/Users/<user>/AppData/Local/Zed/db/0-stable/db.sqlite`
|
|
263
|
+
You should see a file like `vscode-12345-48123.lock`. If not, run **Developer: Reload Window** in VS Code.
|
|
189
264
|
|
|
190
|
-
|
|
265
|
+
### Release
|
|
191
266
|
|
|
192
|
-
|
|
267
|
+
This project uses [Release Please](https://github.com/googleapis/release-please) with [Conventional Commits](https://www.conventionalcommits.org/) to automate versioning and publishing.
|
|
193
268
|
|
|
194
|
-
|
|
195
|
-
| ----------------------------------- | ----------------- | ------------------------------- |
|
|
196
|
-
| Live file tracking | ✅ Real-time push | ✅ 1s polling |
|
|
197
|
-
| Live selection tracking | ✅ Real-time push | ✅ 1s polling |
|
|
198
|
-
| `Ctrl+Alt+K` / `Cmd+Alt+K` shortcut | ✅ | Use `@<relative-path>` manually |
|
|
199
|
-
| LLM context injection | ✅ | ✅ |
|
|
200
|
-
| `/ide auto` | ✅ | ✅ |
|
|
269
|
+
See [RELEASE.md](RELEASE.md) for the full release guide.
|