pi-x-ide 1.13.1 → 1.15.0
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 +88 -56
- package/README.zh-CN.md +82 -47
- package/dist/package.json +5 -20
- package/dist/src/pi/connection.d.ts +8 -2
- package/dist/src/pi/connection.js +18 -8
- package/dist/src/pi/connection.js.map +1 -1
- package/dist/src/pi/context.js +2 -1
- package/dist/src/pi/context.js.map +1 -1
- package/dist/src/pi/discovery.d.ts +6 -1
- package/dist/src/pi/discovery.js +44 -9
- package/dist/src/pi/discovery.js.map +1 -1
- package/dist/src/pi/ide-host.d.ts +17 -0
- package/dist/src/pi/ide-host.js +72 -0
- package/dist/src/pi/ide-host.js.map +1 -0
- package/dist/src/pi/ui.js +7 -5
- package/dist/src/pi/ui.js.map +1 -1
- package/dist/src/pi/zed.d.ts +2 -1
- package/dist/src/pi/zed.js +8 -36
- package/dist/src/pi/zed.js.map +1 -1
- package/dist/src/shared/config-options.d.ts +4 -0
- package/dist/src/shared/config-options.js +4 -0
- package/dist/src/shared/config-options.js.map +1 -1
- package/dist/src/shared/config.d.ts +2 -0
- package/dist/src/shared/config.js +4 -2
- package/dist/src/shared/config.js.map +1 -1
- package/dist/src/shared/format.d.ts +3 -0
- package/dist/src/shared/format.js +13 -5
- package/dist/src/shared/format.js.map +1 -1
- package/dist/src/shared/lock-file.d.ts +1 -0
- package/dist/src/shared/lock-file.js +1 -0
- package/dist/src/shared/lock-file.js.map +1 -1
- package/dist/src/shared/paths.d.ts +11 -3
- package/dist/src/shared/paths.js +54 -10
- package/dist/src/shared/paths.js.map +1 -1
- package/dist/src/shared/platform.d.ts +5 -0
- package/dist/src/shared/platform.js +77 -0
- package/dist/src/shared/platform.js.map +1 -0
- package/dist/src/shared/protocol.d.ts +4 -2
- package/dist/src/shared/protocol.js.map +1 -1
- package/dist/src/shared/schema.js +2 -1
- package/dist/src/shared/schema.js.map +1 -1
- package/dist/test/connection.test.js +104 -0
- package/dist/test/connection.test.js.map +1 -1
- package/dist/test/install.test.js +1 -1
- package/dist/test/install.test.js.map +1 -1
- package/dist/test/nvim-sidecar.test.js +2 -1
- package/dist/test/nvim-sidecar.test.js.map +1 -1
- package/dist/test/shared.test.js +278 -3
- package/dist/test/shared.test.js.map +1 -1
- package/dist/test/zed.test.js +1 -1
- package/dist/test/zed.test.js.map +1 -1
- package/package.json +5 -20
- package/schemas/config.json +4 -0
- package/src/pi/connection.ts +22 -7
- package/src/pi/context.ts +5 -2
- package/src/pi/discovery.ts +61 -9
- package/src/pi/ide-host.ts +82 -0
- package/src/pi/ui.ts +7 -5
- package/src/pi/zed.ts +7 -33
- package/src/shared/config-options.ts +5 -0
- package/src/shared/config.ts +3 -1
- package/src/shared/format.ts +20 -6
- package/src/shared/lock-file.ts +2 -0
- package/src/shared/paths.ts +75 -10
- package/src/shared/platform.ts +79 -0
- package/src/shared/protocol.ts +7 -2
- package/src/shared/schema.ts +4 -1
package/README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
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, Zed, and
|
|
5
|
+
Automatically attaches the currently opened or selected file and text range from VS Code, Zed, Neovim, and JetBrains IDEs to the Pi TUI, submitting them as conversation context to the LLM.
|
|
6
|
+
|
|
7
|
+
<img width="3822" height="2010" alt="pi-x-ide-guide" src="https://github.com/user-attachments/assets/70abe40d-e4ac-4c2e-aca7-80d2e7867945" />
|
|
6
8
|
|
|
7
|
-
---
|
|
8
9
|
|
|
9
10
|
## Installation & Usage
|
|
10
11
|
|
|
@@ -42,17 +43,8 @@ No extension installation is needed. Pi automatically detects Zed when running i
|
|
|
42
43
|
|
|
43
44
|
#### Neovim
|
|
44
45
|
|
|
45
|
-
Neovim support uses a Lua plugin plus a sidecar process.
|
|
46
|
-
|
|
47
|
-
x64 or arm64) from GitHub Releases and verifies it against the release asset's
|
|
48
|
-
SHA-256 digest before caching it. If the download or checksum verification fails,
|
|
49
|
-
or no binary matches your platform, the plugin falls back to the bundled Node.js
|
|
50
|
-
sidecar — Node.js is then required on PATH.
|
|
51
|
-
|
|
52
|
-
Downloaded binaries are cached under `stdpath("cache")/pi-x-ide/` and reused on
|
|
53
|
-
subsequent starts. The optional lazy.nvim build hook uses the bundled binary when
|
|
54
|
-
present; otherwise it checks the release digest on install and update,
|
|
55
|
-
downloading only when the cached binary is missing or stale.
|
|
46
|
+
Neovim support uses a Lua plugin plus a sidecar process. The plugin auto-downloads
|
|
47
|
+
a platform binary on first start and falls back to Node.js if unavailable.
|
|
56
48
|
|
|
57
49
|
**lazy.nvim:**
|
|
58
50
|
|
|
@@ -73,14 +65,10 @@ downloading only when the cached binary is missing or stale.
|
|
|
73
65
|
}
|
|
74
66
|
```
|
|
75
67
|
|
|
76
|
-
> **Note:** The `init` block
|
|
77
|
-
>
|
|
78
|
-
>
|
|
79
|
-
>
|
|
80
|
-
> (`:Lazy build pi-x-ide` to re-run) and downloads only when the cached binary is
|
|
81
|
-
> missing or stale. It is safe to omit: the plugin still downloads the binary
|
|
82
|
-
> lazily on first start and falls back to the Node.js sidecar if the download is
|
|
83
|
-
> unavailable.
|
|
68
|
+
> **Note:** The `init` block adds the plugin subdirectory to the runtime path to
|
|
69
|
+
> work around a Lua module resolution issue with some lazy.nvim versions. The
|
|
70
|
+
> optional `build` hook pre-downloads the sidecar binary; it is safe to omit —
|
|
71
|
+
> the plugin downloads it lazily on first start.
|
|
84
72
|
|
|
85
73
|
**Native package:**
|
|
86
74
|
|
|
@@ -91,6 +79,10 @@ lua require("pi_x_ide").setup({ keymap = "<leader>pa" })
|
|
|
91
79
|
|
|
92
80
|
See [Configuration Reference](#neovim-2) for full setup options, commands, and troubleshooting.
|
|
93
81
|
|
|
82
|
+
#### JetBrains IDEs
|
|
83
|
+
|
|
84
|
+
Download the latest JetBrains plugin ZIP(pi-x-ide-jetbrains-*.zip) from the [latest GitHub Release](https://github.com/balaenis/pi-x-ide/releases/latest), then install it in your JetBrains IDE via **Settings | Plugins | ⚙ | Install Plugin from Disk...**.
|
|
85
|
+
|
|
94
86
|
### Connect Pi & Verify
|
|
95
87
|
|
|
96
88
|
Start Pi in the **same project directory** as your IDE workspace:
|
|
@@ -99,21 +91,26 @@ Start Pi in the **same project directory** as your IDE workspace:
|
|
|
99
91
|
pi
|
|
100
92
|
```
|
|
101
93
|
|
|
102
|
-
Pi auto-loads `pi-x-ide` and connects to your IDE. The TUI
|
|
94
|
+
Pi auto-loads `pi-x-ide` and connects to your IDE. The TUI shows a widget above the
|
|
95
|
+
editor with the current IDE connection and selection state.
|
|
103
96
|
|
|
104
97
|
**Verify it works:**
|
|
105
98
|
|
|
106
99
|
Open a file in your IDE and select some text. The widget should update in real time:
|
|
107
100
|
|
|
108
101
|
```
|
|
109
|
-
|
|
102
|
+
⧉ ⇡ foo.ts#L10-L20
|
|
110
103
|
```
|
|
111
104
|
|
|
112
|
-
Attach the selection from either side: press `Ctrl+Alt+K` (Linux/Windows) or `Cmd+Alt+K` (macOS) in a VS Code-family IDE, or focus the Pi TUI and press `Ctrl+Alt+K` / run `/ide attach`. The Pi input box should insert `@src/foo.ts#L10-L20`.
|
|
105
|
+
Attach the selection from either side: press `Ctrl+Alt+K` (Linux/Windows) or `Cmd+Alt+K` (macOS) in a VS Code-family IDE, press `Ctrl+Alt+K` or run **Pi x IDE: Attach Selection** in JetBrains, use `:PiXIdeAttach` in Neovim, or focus the Pi TUI and press `Ctrl+Alt+K` / run `/ide attach`. The Pi input box should insert `@src/foo.ts#L10-L20`.
|
|
113
106
|
|
|
114
|
-
Type a chat prompt in Pi and submit it. The selected text is injected as LLM context
|
|
107
|
+
Type a chat prompt in Pi and submit it. The selected text is injected as LLM context.
|
|
108
|
+
After submission, the widget changes to
|
|
109
|
+
`⧉ ✓ foo.ts#L10-L20`.
|
|
115
110
|
|
|
116
|
-
|
|
111
|
+
**Diagnostic Quick Fix (VS Code only):** place the cursor on an error or warning,
|
|
112
|
+
open Quick Fix, and choose **Pi: Fix it** to send the diagnostic to Pi and start an
|
|
113
|
+
analysis turn, or **Pi: Send diagnostic** to paste it into the input box.
|
|
117
114
|
|
|
118
115
|
**If the connection doesn't appear:**
|
|
119
116
|
|
|
@@ -121,6 +118,20 @@ For diagnostics in VS Code-family IDEs, connect Pi first, then place the cursor
|
|
|
121
118
|
- If the IDE was started after Pi, reload the IDE window and run `/ide auto` again.
|
|
122
119
|
- Run `/ide` to manually select a connection from the list.
|
|
123
120
|
|
|
121
|
+
### WSL2
|
|
122
|
+
|
|
123
|
+
When Pi runs inside WSL2 and your IDE runs on native Windows, Pi automatically
|
|
124
|
+
discovers the IDE connection across the WSL boundary. No extra configuration is
|
|
125
|
+
needed in most cases.
|
|
126
|
+
|
|
127
|
+
If your WSL networking mode, firewall, or endpoint security blocks the automatic
|
|
128
|
+
discovery, set `PI_X_IDE_HOST_OVERRIDE`:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
PI_X_IDE_HOST_OVERRIDE=127.0.0.1 pi
|
|
132
|
+
PI_X_IDE_HOST_OVERRIDE=<windows-host-ip> pi
|
|
133
|
+
```
|
|
134
|
+
|
|
124
135
|
### `/ide` Command Reference
|
|
125
136
|
|
|
126
137
|
| Command | Behavior |
|
|
@@ -156,8 +167,6 @@ Default database paths:
|
|
|
156
167
|
- **Windows:** `%LOCALAPPDATA%\Zed\db\0-stable\db.sqlite`
|
|
157
168
|
- **WSL with Windows Zed:** `/mnt/c/Users/<user>/AppData/Local/Zed/db/0-stable/db.sqlite`
|
|
158
169
|
|
|
159
|
-
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`.
|
|
160
|
-
|
|
161
170
|
#### Neovim
|
|
162
171
|
|
|
163
172
|
```lua
|
|
@@ -166,14 +175,12 @@ require("pi_x_ide").setup({
|
|
|
166
175
|
keymap = "<C-A-k>",
|
|
167
176
|
debounce_ms = 150,
|
|
168
177
|
-- sidecar_cmd = { "node", "/absolute/path/to/pi-x-ide-nvim-sidecar.cjs" },
|
|
169
|
-
-- (defaults to the platform binary; falls back to node + cjs if no binary found)
|
|
170
178
|
-- workspace_folders = { "/path/to/project" },
|
|
171
179
|
})
|
|
172
180
|
```
|
|
173
181
|
|
|
174
182
|
If the sidecar does not start, run `:PiXIdeStatus`, or set `sidecar_cmd` to a
|
|
175
|
-
custom command.
|
|
176
|
-
when no binary matches.
|
|
183
|
+
custom command.
|
|
177
184
|
|
|
178
185
|
**Commands:**
|
|
179
186
|
|
|
@@ -192,6 +199,7 @@ Pi-side variables can be set as real environment variables or in `~/.pi/pi-x-ide
|
|
|
192
199
|
| ------------------------------- | ------------- | ----------------------------------------------------------------------------------- |
|
|
193
200
|
| `PI_X_IDE_AUTO_INSTALL` | `1` | Auto-install VS Code extension on Pi startup |
|
|
194
201
|
| `PI_X_IDE_ATTACH_SHORTCUT` | `ctrl+alt+k` | Pi TUI shortcut for `/ide attach`; set to `off`, `none`, `false`, or `0` to disable |
|
|
202
|
+
| `PI_X_IDE_HOST_OVERRIDE` | (unset) | Override the host Pi uses for IDE WebSocket lock files; useful for WSL2 networking |
|
|
195
203
|
| `PI_X_IDE_ZED_DB` | (auto-detect) | Override path to Zed SQLite database |
|
|
196
204
|
| `PI_X_IDE_ZED_POLL_INTERVAL_MS` | `1000` | Zed SQLite polling interval, clamped to 100-2000 ms |
|
|
197
205
|
|
|
@@ -205,22 +213,25 @@ See [schemas/config.json](schemas/config.json) for editor schema guidance. A [co
|
|
|
205
213
|
|
|
206
214
|
### Feature Parity
|
|
207
215
|
|
|
208
|
-
| Feature | VS Code | Zed | Neovim |
|
|
209
|
-
| ---------------------------------------------------- | ----------------------- | ---------- | ----------------------------- |
|
|
210
|
-
| Live file tracking | ✅ Real-time push | ✅ polling | ✅ Real-time push via sidecar |
|
|
211
|
-
| Live selection tracking | ✅ Real-time push | ✅ polling | ✅ Real-time push via sidecar |
|
|
212
|
-
| IDE context attach shortcut | ✅ Default `Ctrl+Alt+K` | ❌ | ✅ Custom configured keymap |
|
|
213
|
-
| Pi TUI context attach shortcut(default `Ctrl+Alt+K`) | ✅ | ✅ | ✅ |
|
|
214
|
-
| LLM context injection | ✅ | ✅ | ✅ |
|
|
215
|
-
| `/ide auto` | ✅ | ✅ | ✅ |
|
|
216
|
+
| Feature | VS Code | Zed | Neovim | JetBrains |
|
|
217
|
+
| ---------------------------------------------------- | ----------------------- | ---------- | ----------------------------- | ----------------------- |
|
|
218
|
+
| Live file tracking | ✅ Real-time push | ✅ polling | ✅ Real-time push via sidecar | ✅ Real-time push |
|
|
219
|
+
| Live selection tracking | ✅ Real-time push | ✅ polling | ✅ Real-time push via sidecar | ✅ Real-time push |
|
|
220
|
+
| IDE context attach shortcut | ✅ Default `Ctrl+Alt+K` | ❌ | ✅ Custom configured keymap | ✅ Default `Ctrl+Alt+K` |
|
|
221
|
+
| Pi TUI context attach shortcut(default `Ctrl+Alt+K`) | ✅ | ✅ | ✅ | ✅ |
|
|
222
|
+
| LLM context injection | ✅ | ✅ | ✅ | ✅ |
|
|
223
|
+
| `/ide auto` | ✅ | ✅ | ✅ | ✅ |
|
|
224
|
+
| Diagnostic Quick Fix | ✅ | ❌ | ❌ | ❌ |
|
|
225
|
+
| Auto-install | ✅ VS Code-family only | N/A | ❌ | ❌ |
|
|
216
226
|
|
|
217
|
-
###
|
|
227
|
+
### How Discovery Works
|
|
218
228
|
|
|
219
|
-
|
|
229
|
+
Pi discovers IDE connections via lock files under `~/.pi/pi-x-ide/lock/`. It
|
|
230
|
+
auto-connects when your terminal `cwd` is inside one of the IDE's workspace
|
|
231
|
+
folders. If `cwd` is only a parent directory (e.g. `~/`), run `/ide` to choose a
|
|
232
|
+
connection manually.
|
|
220
233
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
See [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md) for protocol details.
|
|
234
|
+
See [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md) for the full protocol.
|
|
224
235
|
|
|
225
236
|
---
|
|
226
237
|
|
|
@@ -232,6 +243,7 @@ See [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md) for protocol detail
|
|
|
232
243
|
- bun ≥ 1.3 (`packageManager` declared as `bun@1.3.14`)
|
|
233
244
|
- VS Code ≥ 1.120.0 (VS Code extension only)
|
|
234
245
|
- Neovim ≥ 0.9 (Neovim plugin only)
|
|
246
|
+
- JDK 21 (JetBrains plugin only; Gradle can download the toolchain automatically)
|
|
235
247
|
|
|
236
248
|
### Install & Build
|
|
237
249
|
|
|
@@ -240,8 +252,8 @@ Clone the repository, then build:
|
|
|
240
252
|
```bash
|
|
241
253
|
git clone https://github.com/balaenis/pi-x-ide.git
|
|
242
254
|
cd pi-x-ide
|
|
243
|
-
|
|
244
|
-
|
|
255
|
+
mise run setup
|
|
256
|
+
mise run build
|
|
245
257
|
```
|
|
246
258
|
|
|
247
259
|
To load the local build without installing globally:
|
|
@@ -250,15 +262,18 @@ To load the local build without installing globally:
|
|
|
250
262
|
pi -e ./src/pi/index.ts
|
|
251
263
|
```
|
|
252
264
|
|
|
253
|
-
All
|
|
265
|
+
All build and check commands are defined as `mise run` tasks (see `.mise/tasks/`):
|
|
254
266
|
|
|
255
|
-
| Command
|
|
256
|
-
|
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
261
|
-
| `
|
|
267
|
+
| Command | Description |
|
|
268
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
|
|
269
|
+
| `mise run build` | Build Pi-side TypeScript → `dist/` + Neovim sidecar → `ide-plugins/nvim/bin/` + VS Code bundle → `ide-plugins/vscode/out/` |
|
|
270
|
+
| `mise run typecheck` | Type-check only (no output files) |
|
|
271
|
+
| `mise run test` | Build + run unit tests |
|
|
272
|
+
| `mise run package:vsix` | Package VS Code extension as VSIX |
|
|
273
|
+
| `mise run compile:jetbrains` | Compile and test the JetBrains plugin with Gradle |
|
|
274
|
+
| `mise run package:jetbrains` | Package the JetBrains plugin ZIP under `ide-plugins/jetbrains/build/distributions/` |
|
|
275
|
+
| `mise run verify:jetbrains` | Run IntelliJ Plugin Verifier for the configured target IDE |
|
|
276
|
+
| `mise run check:config-schema` | Verify `schemas/config.json` is in sync with the config registry |
|
|
262
277
|
|
|
263
278
|
### Testing the VS Code Extension Locally
|
|
264
279
|
|
|
@@ -268,13 +283,13 @@ All `bun run` commands have equivalent `mise run` tasks (see `mise.toml`):
|
|
|
268
283
|
2. Go to the **Run and Debug** panel (`Ctrl+Shift+D`).
|
|
269
284
|
3. Select **Run Pi x IDE VS Code Extension**.
|
|
270
285
|
4. Press **F5**:
|
|
271
|
-
- The `preLaunchTask` automatically runs `
|
|
286
|
+
- The `preLaunchTask` automatically runs `mise run build`.
|
|
272
287
|
- A new VS Code window titled `[Extension Development Host]` opens.
|
|
273
288
|
|
|
274
289
|
#### Option 2: Package VSIX and Install
|
|
275
290
|
|
|
276
291
|
```bash
|
|
277
|
-
|
|
292
|
+
mise run package:vsix
|
|
278
293
|
cd ide-plugins/vscode && code --install-extension dist/pi-x-ide-$(node -p "require('./package.json').version").vsix
|
|
279
294
|
```
|
|
280
295
|
|
|
@@ -288,6 +303,23 @@ ls -l ~/.pi/pi-x-ide/lock
|
|
|
288
303
|
|
|
289
304
|
You should see a file like `vscode-12345-48123.lock`. If not, run **Developer: Reload Window** in VS Code.
|
|
290
305
|
|
|
306
|
+
### Testing the JetBrains Plugin Locally
|
|
307
|
+
|
|
308
|
+
Run a sandbox IDE:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
cd ide-plugins/jetbrains
|
|
312
|
+
./gradlew runIde
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Build the installable plugin ZIP:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
mise run package:jetbrains
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The ZIP is written under `ide-plugins/jetbrains/build/distributions/`. For a smoke test, open this repository in the sandbox IDE, start `pi` from the same directory, open and select text in a local file, then press `Ctrl+Alt+K` or run **Pi x IDE: Attach Selection**. Pi should receive an `@relative/path#Lx-Ly` mention.
|
|
322
|
+
|
|
291
323
|
### Release
|
|
292
324
|
|
|
293
325
|
This project uses [Release Please](https://github.com/googleapis/release-please) with [Conventional Commits](https://www.conventionalcommits.org/) to automate versioning and publishing.
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 用于 IDE 选择上下文集成的 Pi 扩展包。
|
|
4
4
|
|
|
5
|
-
自动将 VS Code、Zed 和
|
|
5
|
+
自动将 VS Code、Zed、Neovim 和 JetBrains IDE 中当前打开或选中的文件与文本范围附加到 Pi TUI,并作为对话上下文提交给 LLM。
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -42,14 +42,8 @@ PI_X_IDE_AUTO_INSTALL=0
|
|
|
42
42
|
|
|
43
43
|
#### Neovim
|
|
44
44
|
|
|
45
|
-
Neovim 支持由一个 Lua 插件和一个 sidecar
|
|
46
|
-
|
|
47
|
-
x64 或 arm64),并在写入缓存前用 release asset 的 SHA-256 digest 做校验。下载
|
|
48
|
-
或校验失败、或无匹配二进制时,插件降级到内置的 Node.js sidecar — 此时需要
|
|
49
|
-
PATH 中有 Node.js。
|
|
50
|
-
|
|
51
|
-
下载的二进制文件缓存在 `stdpath("cache")/pi-x-ide/` 目录,后续启动直接复用。可选的
|
|
52
|
-
lazy.nvim build 钩子会优先使用插件包内的 bundled binary;如果不存在,则在安装和更新时检查 release digest,仅在缓存二进制缺失或过期时下载。
|
|
45
|
+
Neovim 支持由一个 Lua 插件和一个 sidecar 进程组成。插件首次启动时自动下载
|
|
46
|
+
平台二进制文件,不可用时回退到 Node.js。
|
|
53
47
|
|
|
54
48
|
**lazy.nvim:**
|
|
55
49
|
|
|
@@ -70,9 +64,9 @@ lazy.nvim build 钩子会优先使用插件包内的 bundled binary;如果不
|
|
|
70
64
|
}
|
|
71
65
|
```
|
|
72
66
|
|
|
73
|
-
> **注意:** `init`
|
|
74
|
-
>
|
|
75
|
-
>
|
|
67
|
+
> **注意:** `init` 块将插件子目录加入 runtime path,以规避部分版本 lazy.nvim 的
|
|
68
|
+
> Lua 模块解析兼容性问题。可选的 `build` 钩子会预下载 sidecar 二进制;可以省略
|
|
69
|
+
> — 插件会在首次启动时按需下载。
|
|
76
70
|
|
|
77
71
|
**原生 package:**
|
|
78
72
|
|
|
@@ -83,6 +77,10 @@ lua require("pi_x_ide").setup({ keymap = "<leader>pa" })
|
|
|
83
77
|
|
|
84
78
|
完整配置选项、命令和故障排查见 [配置参考](#neovim-2)。
|
|
85
79
|
|
|
80
|
+
#### JetBrains IDE
|
|
81
|
+
|
|
82
|
+
从 [GitHub 最新 Release](https://github.com/balaenis/pi-x-ide/releases/latest) 下载 JetBrains 插件 ZIP,然后在 JetBrains IDE 中通过 **Settings | Plugins | ⚙ | Install Plugin from Disk...** 安装。
|
|
83
|
+
|
|
86
84
|
### 连接 Pi 并验证
|
|
87
85
|
|
|
88
86
|
在 IDE workspace **同一项目目录** 启动 Pi:
|
|
@@ -91,21 +89,25 @@ lua require("pi_x_ide").setup({ keymap = "<leader>pa" })
|
|
|
91
89
|
pi
|
|
92
90
|
```
|
|
93
91
|
|
|
94
|
-
Pi 自动加载 `pi-x-ide` 并连接 IDE。TUI
|
|
92
|
+
Pi 自动加载 `pi-x-ide` 并连接 IDE。TUI 在编辑器上方显示一个 widget,展示当前
|
|
93
|
+
IDE 连接和选区状态。
|
|
95
94
|
|
|
96
95
|
**验证是否正常:**
|
|
97
96
|
|
|
98
97
|
在 IDE 中打开文件并选中文本,widget 应实时更新:
|
|
99
98
|
|
|
100
99
|
```text
|
|
101
|
-
|
|
100
|
+
⧉ ⇡ foo.ts#L10-L20
|
|
102
101
|
```
|
|
103
102
|
|
|
104
|
-
可以从任一侧附加选区:在 VS Code 系列 IDE 中按 `Ctrl+Alt+K`(Linux/Windows)或 `Cmd+Alt+K`(macOS
|
|
103
|
+
可以从任一侧附加选区:在 VS Code 系列 IDE 中按 `Ctrl+Alt+K`(Linux/Windows)或 `Cmd+Alt+K`(macOS),在 JetBrains 中按 `Ctrl+Alt+K` 或运行 **Pi x IDE: Attach Selection**,在 Neovim 中使用 `:PiXIdeAttach`,或聚焦 Pi TUI 后按 `Ctrl+Alt+K` / 运行 `/ide attach`。Pi 输入框应插入 `@src/foo.ts#L10-L20`。
|
|
105
104
|
|
|
106
|
-
在 Pi 中输入对话提示并提交,选中文本会作为 LLM
|
|
105
|
+
在 Pi 中输入对话提示并提交,选中文本会作为 LLM 上下文注入。
|
|
106
|
+
提交后 widget 变为 `⧉ ✓ foo.ts#L10-L20`。
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
**诊断 Quick Fix(仅 VS Code):** 将光标放在 error 或 warning 上,打开 Quick Fix,
|
|
109
|
+
选择 **Pi: Fix it** 将诊断信息发送给 Pi 并启动分析对话,或选择 **Pi: Send diagnostic**
|
|
110
|
+
将其粘贴到输入框。
|
|
109
111
|
|
|
110
112
|
**如果连接未出现:**
|
|
111
113
|
|
|
@@ -113,6 +115,19 @@ IDE: vscode ✓ src/foo.ts#L10-L20 pending
|
|
|
113
115
|
- 如果 IDE 在 Pi 之后启动,reload IDE 窗口后再次运行 `/ide auto`
|
|
114
116
|
- 运行 `/ide` 手动从列表中选择连接
|
|
115
117
|
|
|
118
|
+
### WSL2
|
|
119
|
+
|
|
120
|
+
当 Pi 运行在 WSL2 中、IDE 运行在原生 Windows 上时,Pi 会自动跨 WSL 边界发现
|
|
121
|
+
IDE 连接。大多数情况下无需额外配置。
|
|
122
|
+
|
|
123
|
+
如果你的 WSL 网络模式、防火墙或终端安全策略阻止自动发现,可设置
|
|
124
|
+
`PI_X_IDE_HOST_OVERRIDE`:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
PI_X_IDE_HOST_OVERRIDE=127.0.0.1 pi
|
|
128
|
+
PI_X_IDE_HOST_OVERRIDE=<windows-host-ip> pi
|
|
129
|
+
```
|
|
130
|
+
|
|
116
131
|
### `/ide` 命令参考
|
|
117
132
|
|
|
118
133
|
| 命令 | 行为 |
|
|
@@ -148,8 +163,6 @@ Pi 默认也会在 TUI 中注册 `Ctrl+Alt+K`,作为 `/ide attach` 的快捷
|
|
|
148
163
|
- **Windows:** `%LOCALAPPDATA%\Zed\db\0-stable\db.sqlite`
|
|
149
164
|
- **WSL + Windows 版 Zed:** `/mnt/c/Users/<user>/AppData/Local/Zed/db/0-stable/db.sqlite`
|
|
150
165
|
|
|
151
|
-
当 Pi 运行在 WSL 中而 Zed 是 Windows 应用时,pi-x-ide 会将 Windows 路径(`C:\Users\<user>\project`)规范化为 `/mnt/c/Users/<user>/project`,并将 WSL UNC 路径规范化为 `/home/<user>/project`。
|
|
152
|
-
|
|
153
166
|
#### Neovim
|
|
154
167
|
|
|
155
168
|
```lua
|
|
@@ -158,13 +171,11 @@ require("pi_x_ide").setup({
|
|
|
158
171
|
keymap = "<C-A-k>",
|
|
159
172
|
debounce_ms = 150,
|
|
160
173
|
-- sidecar_cmd = { "node", "/absolute/path/to/pi-x-ide-nvim-sidecar.cjs" },
|
|
161
|
-
-- (默认使用平台二进制文件;找不到时降级到 node + cjs)
|
|
162
174
|
-- workspace_folders = { "/path/to/project" },
|
|
163
175
|
})
|
|
164
176
|
```
|
|
165
177
|
|
|
166
|
-
如果 sidecar 无法启动,请运行 `:PiXIdeStatus`,或设置 `sidecar_cmd`
|
|
167
|
-
命令。插件优先使用平台二进制文件,找不到匹配项时降级到 Node.js。
|
|
178
|
+
如果 sidecar 无法启动,请运行 `:PiXIdeStatus`,或设置 `sidecar_cmd` 为自定义命令。
|
|
168
179
|
|
|
169
180
|
**命令:**
|
|
170
181
|
|
|
@@ -183,6 +194,7 @@ Pi 侧变量可设为真实环境变量或写入 `~/.pi/pi-x-ide/config.json`
|
|
|
183
194
|
| ------------------------------- | ------------ | ------------------------------------------------------------------------- |
|
|
184
195
|
| `PI_X_IDE_AUTO_INSTALL` | `1` | Pi 启动时自动安装 VS Code 扩展 |
|
|
185
196
|
| `PI_X_IDE_ATTACH_SHORTCUT` | `ctrl+alt+k` | Pi TUI 的 `/ide attach` 快捷键;设为 `off`、`none`、`false` 或 `0` 可禁用 |
|
|
197
|
+
| `PI_X_IDE_HOST_OVERRIDE` | (未设置) | 覆盖 Pi 连接 IDE WebSocket lock file 时使用的 host;适用于 WSL2 网络场景 |
|
|
186
198
|
| `PI_X_IDE_ZED_DB` | (自动检测) | 覆盖 Zed SQLite 数据库路径 |
|
|
187
199
|
| `PI_X_IDE_ZED_POLL_INTERVAL_MS` | `1000` | Zed SQLite 轮询间隔,会被限制在 100-2000 ms 范围 |
|
|
188
200
|
|
|
@@ -196,22 +208,24 @@ Pi 侧变量可设为真实环境变量或写入 `~/.pi/pi-x-ide/config.json`
|
|
|
196
208
|
|
|
197
209
|
### 功能对比
|
|
198
210
|
|
|
199
|
-
| 功能 | VS Code | Zed | Neovim |
|
|
200
|
-
| ------------------------------------------------ | -------------------- | ----------- | ------------------------ |
|
|
201
|
-
| 实时文件追踪 | ✅ 实时推送 | ✅ 1 秒轮询 | ✅ 通过 sidecar 实时推送 |
|
|
202
|
-
| 实时选区追踪 | ✅ 实时推送 | ✅ 1 秒轮询 | ✅ 通过 sidecar 实时推送 |
|
|
203
|
-
| IDE 上下文 attach 快捷键 | ✅ 默认 `Ctrl+Alt+K` | ❌ | ✅ 自定义快捷键 keymap |
|
|
204
|
-
| Pi TUI 上下文 attach 快捷键(默认 `Ctrl+Alt+K`) | ✅ | ✅ | ✅ |
|
|
205
|
-
| LLM 上下文注入 | ✅ | ✅ | ✅ |
|
|
206
|
-
| `/ide auto` | ✅ | ✅ | ✅ |
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
| 功能 | VS Code | Zed | Neovim | JetBrains |
|
|
212
|
+
| ------------------------------------------------ | -------------------- | ----------- | ------------------------ | -------------------- |
|
|
213
|
+
| 实时文件追踪 | ✅ 实时推送 | ✅ 1 秒轮询 | ✅ 通过 sidecar 实时推送 | ✅ 实时推送 |
|
|
214
|
+
| 实时选区追踪 | ✅ 实时推送 | ✅ 1 秒轮询 | ✅ 通过 sidecar 实时推送 | ✅ 实时推送 |
|
|
215
|
+
| IDE 上下文 attach 快捷键 | ✅ 默认 `Ctrl+Alt+K` | ❌ | ✅ 自定义快捷键 keymap | ✅ 默认 `Ctrl+Alt+K` |
|
|
216
|
+
| Pi TUI 上下文 attach 快捷键(默认 `Ctrl+Alt+K`) | ✅ | ✅ | ✅ | ✅ |
|
|
217
|
+
| LLM 上下文注入 | ✅ | ✅ | ✅ | ✅ |
|
|
218
|
+
| `/ide auto` | ✅ | ✅ | ✅ | ✅ |
|
|
219
|
+
| 诊断 Quick Fix | ✅ | ❌ | ❌ | ❌ |
|
|
220
|
+
| 自动安装 | ✅ 仅 VS Code 系列 | N/A | ❌ | ❌ |
|
|
209
221
|
|
|
210
|
-
|
|
222
|
+
### 发现机制
|
|
211
223
|
|
|
212
|
-
Pi 通过
|
|
224
|
+
Pi 通过 `~/.pi/pi-x-ide/lock/` 下的 lock file 发现 IDE 连接。当终端 `cwd`
|
|
225
|
+
位于某个 IDE workspace 目录内时自动连接;如果 `cwd` 只是父级目录(如 `~/`),
|
|
226
|
+
请运行 `/ide` 手动选择连接。
|
|
213
227
|
|
|
214
|
-
|
|
228
|
+
完整协议见 [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md)。
|
|
215
229
|
|
|
216
230
|
---
|
|
217
231
|
|
|
@@ -223,6 +237,7 @@ Pi 通过 `ctx.cwd` 与 lock file 中的 `workspaceFolders` 做最长路径匹
|
|
|
223
237
|
- bun ≥ 1.3(`packageManager` 声明为 `bun@1.3.14`)
|
|
224
238
|
- VS Code ≥ 1.120.0(仅 VS Code 扩展需要)
|
|
225
239
|
- Neovim ≥ 0.9(仅 Neovim 插件需要)
|
|
240
|
+
- JDK 21(仅 JetBrains 插件需要;Gradle 可自动下载 toolchain)
|
|
226
241
|
|
|
227
242
|
### 安装与构建
|
|
228
243
|
|
|
@@ -231,8 +246,8 @@ Clone 仓库后构建:
|
|
|
231
246
|
```bash
|
|
232
247
|
git clone https://github.com/balaenis/pi-x-ide.git
|
|
233
248
|
cd pi-x-ide
|
|
234
|
-
|
|
235
|
-
|
|
249
|
+
mise run setup
|
|
250
|
+
mise run build
|
|
236
251
|
```
|
|
237
252
|
|
|
238
253
|
加载本地构建(无需全局安装):
|
|
@@ -241,15 +256,18 @@ bun run build
|
|
|
241
256
|
pi -e ./src/pi/index.ts
|
|
242
257
|
```
|
|
243
258
|
|
|
244
|
-
|
|
259
|
+
所有构建与检查命令都定义为 `mise run` 任务(见 `.mise/tasks/`):
|
|
245
260
|
|
|
246
|
-
| 命令
|
|
247
|
-
|
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
261
|
+
| 命令 | 说明 |
|
|
262
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
|
263
|
+
| `mise run build` | 编译 Pi 侧 TypeScript → `dist/` + Neovim sidecar → `ide-plugins/nvim/bin/` + VS Code bundle → `ide-plugins/vscode/out/` |
|
|
264
|
+
| `mise run typecheck` | 类型检查(不产出文件) |
|
|
265
|
+
| `mise run test` | 编译 + 运行单元测试 |
|
|
266
|
+
| `mise run package:vsix` | 打包 VS Code 扩展为 VSIX |
|
|
267
|
+
| `mise run compile:jetbrains` | 用 Gradle 编译并测试 JetBrains 插件 |
|
|
268
|
+
| `mise run package:jetbrains` | 将 JetBrains 插件打包为 `ide-plugins/jetbrains/build/distributions/` 下的 ZIP |
|
|
269
|
+
| `mise run verify:jetbrains` | 对配置的目标 IDE 运行 IntelliJ Plugin Verifier |
|
|
270
|
+
| `mise run check:config-schema` | 验证 `schemas/config.json` 与配置注册表是否同步 |
|
|
253
271
|
|
|
254
272
|
### 本地测试 VS Code 扩展
|
|
255
273
|
|
|
@@ -259,13 +277,13 @@ pi -e ./src/pi/index.ts
|
|
|
259
277
|
2. 进入 **Run and Debug** 面板(`Ctrl+Shift+D`)。
|
|
260
278
|
3. 选择 **Run Pi x IDE VS Code Extension**。
|
|
261
279
|
4. 按 **F5**:
|
|
262
|
-
- preLaunchTask 会自动执行 `
|
|
280
|
+
- preLaunchTask 会自动执行 `mise run build`。
|
|
263
281
|
- 打开一个标题包含 `[Extension Development Host]` 的新 VS Code 窗口。
|
|
264
282
|
|
|
265
283
|
#### 方式二:打包 VSIX 后安装
|
|
266
284
|
|
|
267
285
|
```bash
|
|
268
|
-
|
|
286
|
+
mise run package:vsix
|
|
269
287
|
cd ide-plugins/vscode && code --install-extension dist/pi-x-ide-$(node -p "require('./package.json').version").vsix
|
|
270
288
|
```
|
|
271
289
|
|
|
@@ -279,6 +297,23 @@ ls -l ~/.pi/pi-x-ide/lock
|
|
|
279
297
|
|
|
280
298
|
应看到类似 `vscode-12345-48123.lock` 的文件。如果没有,在 VS Code 中执行 **Developer: Reload Window**。
|
|
281
299
|
|
|
300
|
+
### 本地测试 JetBrains 插件
|
|
301
|
+
|
|
302
|
+
运行 sandbox IDE:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
cd ide-plugins/jetbrains
|
|
306
|
+
./gradlew runIde
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
构建可安装的插件 ZIP:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
mise run package:jetbrains
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
ZIP 会输出到 `ide-plugins/jetbrains/build/distributions/`。Smoke test:在 sandbox IDE 中打开本仓库,从同一目录启动 `pi`,打开并选择一个本地文件中的文本,然后按 `Ctrl+Alt+K` 或运行 **Pi x IDE: Attach Selection**。Pi 应收到 `@relative/path#Lx-Ly` mention。
|
|
316
|
+
|
|
282
317
|
### 发布
|
|
283
318
|
|
|
284
319
|
本项目使用 [Release Please](https://github.com/googleapis/release-please) 和 [Conventional Commits](https://www.conventionalcommits.org/) 来自动化版本管理和发布流程。
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-x-ide",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Pi extension package for IDE selection context integration.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"vscode",
|
|
15
15
|
"zed",
|
|
16
16
|
"neovim",
|
|
17
|
-
"nvim"
|
|
17
|
+
"nvim",
|
|
18
|
+
"jetbrains",
|
|
19
|
+
"intellij",
|
|
20
|
+
"idea"
|
|
18
21
|
],
|
|
19
22
|
"license": "Apache-2.0",
|
|
20
23
|
"repository": {
|
|
@@ -34,24 +37,6 @@
|
|
|
34
37
|
},
|
|
35
38
|
"type": "commonjs",
|
|
36
39
|
"main": "./dist/src/pi/index.js",
|
|
37
|
-
"scripts": {
|
|
38
|
-
"typecheck": "tsc -p tsconfig.json --noEmit && bun run --filter './ide-plugins/vscode' typecheck",
|
|
39
|
-
"generate:config-schema": "bun run scripts/generate-config-schema.cjs",
|
|
40
|
-
"check:config-schema": "bun run scripts/generate-config-schema.cjs --check",
|
|
41
|
-
"test": "bun run check:config-schema && bun run compile && node --test dist/test/*.test.js",
|
|
42
|
-
"lint": "eslint .",
|
|
43
|
-
"lint:fix": "eslint . --fix",
|
|
44
|
-
"format": "prettier --write .",
|
|
45
|
-
"format:check": "prettier --check .",
|
|
46
|
-
"compile": "tsc -p tsconfig.json",
|
|
47
|
-
"compile:vsix": "bun run --filter './ide-plugins/vscode' compile",
|
|
48
|
-
"sync:vsix-assets": "bun run --filter './ide-plugins/vscode' sync:assets",
|
|
49
|
-
"package:vsix": "bun run --filter './ide-plugins/vscode' package",
|
|
50
|
-
"package:nvim-sidecar": "bun run scripts/build-nvim-sidecar.mjs --production",
|
|
51
|
-
"package:nvim-sidecar:all": "bun run scripts/build-nvim-sidecar.mjs --production --target=all",
|
|
52
|
-
"build": "bun run compile && bun run compile:vsix && bun run package:nvim-sidecar",
|
|
53
|
-
"build:all": "bun run compile && bun run compile:vsix && bun run package:nvim-sidecar:all"
|
|
54
|
-
},
|
|
55
40
|
"dependencies": {
|
|
56
41
|
"ws": "^8.21.0"
|
|
57
42
|
},
|
|
@@ -2,7 +2,8 @@ import { type DiagnosticFixRequestedParams, type AtMentionedParams, type EditorS
|
|
|
2
2
|
export declare const IDE_CONNECT_TIMEOUT_MS = 5000;
|
|
3
3
|
export declare class IdeConnectionTimeoutError extends Error {
|
|
4
4
|
readonly candidate: LockFileCandidate;
|
|
5
|
-
|
|
5
|
+
readonly host: string;
|
|
6
|
+
constructor(candidate: LockFileCandidate, host?: string);
|
|
6
7
|
}
|
|
7
8
|
export interface IdeConnectionCallbacks {
|
|
8
9
|
onConnected?: (server: {
|
|
@@ -17,14 +18,19 @@ export interface IdeConnectionCallbacks {
|
|
|
17
18
|
onDiagnosticFixRequested?: (params: DiagnosticFixRequestedParams) => void;
|
|
18
19
|
onError?: (error: Error) => void;
|
|
19
20
|
}
|
|
21
|
+
export interface IdeConnectionOptions {
|
|
22
|
+
resolveHost?: (lock: LockFileCandidate["lock"]) => Promise<string>;
|
|
23
|
+
env?: NodeJS.ProcessEnv;
|
|
24
|
+
}
|
|
20
25
|
export declare class IdeConnection {
|
|
21
26
|
readonly candidate: LockFileCandidate;
|
|
22
27
|
private readonly cwd;
|
|
23
28
|
private readonly callbacks;
|
|
29
|
+
private readonly options;
|
|
24
30
|
private socket?;
|
|
25
31
|
private nextId;
|
|
26
32
|
private closedByUser;
|
|
27
|
-
constructor(candidate: LockFileCandidate, cwd: string, callbacks: IdeConnectionCallbacks);
|
|
33
|
+
constructor(candidate: LockFileCandidate, cwd: string, callbacks: IdeConnectionCallbacks, options?: IdeConnectionOptions);
|
|
28
34
|
get isOpen(): boolean;
|
|
29
35
|
connect(timeoutMs?: number): Promise<void>;
|
|
30
36
|
disconnect(): void;
|