pi-x-ide 1.3.0 → 1.4.1

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.
Files changed (56) hide show
  1. package/README.md +187 -104
  2. package/README.zh.md +187 -104
  3. package/dist/package.json +14 -5
  4. package/dist/src/nvim/sidecar-schema.d.ts +25 -0
  5. package/dist/src/nvim/sidecar-schema.js +64 -0
  6. package/dist/src/nvim/sidecar-schema.js.map +1 -0
  7. package/dist/src/nvim/sidecar.d.ts +16 -0
  8. package/dist/src/nvim/sidecar.js +173 -0
  9. package/dist/src/nvim/sidecar.js.map +1 -0
  10. package/dist/src/pi/install.js +13 -8
  11. package/dist/src/pi/install.js.map +1 -1
  12. package/dist/src/pi/zed.js +19 -12
  13. package/dist/src/pi/zed.js.map +1 -1
  14. package/dist/src/shared/config-options.d.ts +89 -0
  15. package/dist/src/shared/config-options.js +88 -0
  16. package/dist/src/shared/config-options.js.map +1 -0
  17. package/dist/src/shared/config.d.ts +7 -0
  18. package/dist/src/shared/config.js +51 -0
  19. package/dist/src/shared/config.js.map +1 -0
  20. package/dist/src/shared/ide-server.d.ts +20 -0
  21. package/dist/src/shared/ide-server.js +144 -0
  22. package/dist/src/shared/ide-server.js.map +1 -0
  23. package/dist/src/shared/lock-file.d.ts +16 -0
  24. package/dist/src/shared/lock-file.js +58 -0
  25. package/dist/src/shared/lock-file.js.map +1 -0
  26. package/dist/src/shared/paths.js +4 -3
  27. package/dist/src/shared/paths.js.map +1 -1
  28. package/dist/src/shared/protocol.d.ts +1 -1
  29. package/dist/src/shared/schema.js +1 -1
  30. package/dist/src/shared/schema.js.map +1 -1
  31. package/dist/test/install.test.js +13 -0
  32. package/dist/test/install.test.js.map +1 -1
  33. package/dist/test/nvim-sidecar.test.d.ts +1 -0
  34. package/dist/test/nvim-sidecar.test.js +148 -0
  35. package/dist/test/nvim-sidecar.test.js.map +1 -0
  36. package/dist/test/shared.test.js +37 -0
  37. package/dist/test/shared.test.js.map +1 -1
  38. package/dist/test/zed.test.js +12 -0
  39. package/dist/test/zed.test.js.map +1 -1
  40. package/nvim/bin/pi-x-ide-nvim-sidecar.cjs +21 -0
  41. package/nvim/doc/pi-x-ide.txt +112 -0
  42. package/nvim/lua/pi_x_ide/init.lua +442 -0
  43. package/nvim/plugin/pi-x-ide.lua +15 -0
  44. package/package.json +14 -5
  45. package/schemas/config.json +120 -0
  46. package/src/nvim/sidecar-schema.ts +71 -0
  47. package/src/nvim/sidecar.ts +219 -0
  48. package/src/pi/install.ts +13 -8
  49. package/src/pi/zed.ts +19 -12
  50. package/src/shared/config-options.ts +100 -0
  51. package/src/shared/config.ts +54 -0
  52. package/src/shared/ide-server.ts +120 -0
  53. package/src/shared/lock-file.ts +65 -0
  54. package/src/shared/paths.ts +4 -3
  55. package/src/shared/protocol.ts +1 -1
  56. package/src/shared/schema.ts +1 -1
package/README.md CHANGED
@@ -1,120 +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-family IDEs and Zed to the Pi TUI, submitting them as conversation context to the LLM.
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
- ## Prerequisites
7
+ ---
8
8
 
9
- - Node.js 26
10
- - pnpm ≥ 11 (declared as `pnpm@11.5.2` in `packageManager`)
11
- - VS Code ≥ 1.90 (VS Code extension only)
12
- - Pi CLI (`@earendil-works/pi-coding-agent ≥ 0.79`)
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
- ## Install & Build
15
+ ### 2. Install the Pi Extension Package
15
16
 
16
17
  ```bash
17
- pnpm install
18
- pnpm build
18
+ pi install npm:pi-x-ide
19
19
  ```
20
20
 
21
- Common commands:
21
+ This installs `pi-x-ide` as a global Pi extension. Pi loads it automatically on startup — no flags needed.
22
22
 
23
- | Command | Description |
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
- ## Testing the VS Code Extension Locally
25
+ #### VS Code / Cursor / Windsurf
32
26
 
33
- ### Option 1: F5 Extension Development Host (Recommended)
27
+ **Option A: Install from Marketplace (Recommended)**
34
28
 
35
- 1. Open the **project root** in VS Code.
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
- ### Option 2: Package VSIX and Install
31
+ **Option B: Install via Pi CLI**
43
32
 
44
- ```bash
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
- The extension installed this way runs in all VS Code windows, independent of the F5 Extension Host.
35
+ **Option C: Auto-install on Pi startup**
50
36
 
51
- ### Verify the Extension is Running
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
- ls -l ~/.pi/pi-x-ide
40
+ PI_X_IDE_AUTO_INSTALL=0
55
41
  ```
56
42
 
57
- You should see a file like `vscode-12345-48123.lock`.
43
+ See [Configuration Reference](#pi-side-environment-variables) for all available options.
58
44
 
59
- If not, run **Developer: Reload Window** in VS Code.
45
+ #### Zed
60
46
 
61
- ## Connecting to Pi
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.
62
48
 
63
- Start Pi in the **same project directory**:
49
+ Requires Node.js 26 and Zed running on the same machine.
64
50
 
65
- ```bash
66
- pi -e ./src/pi/index.ts
67
- ```
51
+ #### Neovim
68
52
 
69
- The Pi TUI should display:
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.
70
54
 
71
- - Footer: `IDE: vscode ✓`
72
- - A widget below the input box showing: IDE name, workspace, current file, selection range, and `pending/sent` status
55
+ **lazy.nvim:**
73
56
 
74
- When Pi starts from a supported VS Code-family integrated terminal, it also tries to auto-install or update the Marketplace extension `balaenis.pi-x-ide` asynchronously. This does not block Pi startup. To disable only this install attempt, set:
75
-
76
- ```bash
77
- PI_X_IDE_AUTO_INSTALL=0
57
+ ```lua
58
+ {
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,
68
+ }
78
69
  ```
79
70
 
80
- If VS Code was started after Pi, run the following in Pi:
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.
81
72
 
82
- ```
83
- /ide auto
84
- ```
73
+ **Native package:**
85
74
 
86
- 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.
75
+ ```vim
76
+ set runtimepath+=/path/to/pi-x-ide/nvim
77
+ lua require("pi_x_ide").setup({ keymap = "<leader>pa" })
78
+ ```
87
79
 
88
- ## Feature Verification
80
+ See [Configuration Reference](#neovim-2) for full setup options, commands, and troubleshooting.
89
81
 
90
- ### Live Selection
82
+ ### 4. Connect Pi & Verify
91
83
 
92
- Open a file in VS Code and select some text. The Pi TUI widget should update in real time:
84
+ Start Pi in the **same project directory** as your IDE workspace:
93
85
 
86
+ ```bash
87
+ pi
94
88
  ```
95
- IDE: vscode ✓ src/foo.ts#L10,20 pending
96
- ```
97
-
98
- ### Manual Keyboard Shortcut
99
89
 
100
- Select text in VS Code and press:
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.
101
91
 
102
- - Linux/Windows: `Ctrl+Alt+K`
103
- - macOS: `Cmd+Alt+K`
92
+ **Verify it works:**
104
93
 
105
- The Pi input box should insert:
94
+ Open a file in your IDE and select some text. The widget should update in real time:
106
95
 
107
96
  ```
108
- @src/foo.ts#L10,20
97
+ IDE: vscode ✓ src/foo.ts#L10,20 pending
109
98
  ```
110
99
 
111
- ### LLM Context Injection
100
+ Press `Ctrl+Alt+K` (Linux/Windows) or `Cmd+Alt+K` (macOS) — the Pi input box should insert `@src/foo.ts#L10,20`.
101
+
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`.
112
103
 
113
- Type a normal chat prompt in Pi. When you submit it to the LLM, the currently `pending` selected text is temporarily injected as a `context` event — it does not persist in the session history.
104
+ **If the connection doesn't appear:**
114
105
 
115
- After submission, the TUI displays `sent`.
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.
116
109
 
117
- ## `/ide` Command Reference
110
+ ### `/ide` Command Reference
118
111
 
119
112
  | Command | Behavior |
120
113
  | -------------- | ----------------------------------------------------------------- |
@@ -126,61 +119,151 @@ After submission, the TUI displays `sent`.
126
119
  | `/ide attach` | Manually insert the latest selection range into the input box |
127
120
  | `/ide install` | Install or update `balaenis.pi-x-ide` through a supported IDE CLI |
128
121
 
129
- ## Lock File Protocol
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
131
+
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.
130
180
 
131
- After the IDE WebSocket server starts, connection information is written to `~/.pi/pi-x-ide/`.
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`.
132
194
 
133
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.
134
196
 
135
197
  See [docs/specs/ide-protocol.md](docs/specs/ide-protocol.md) for protocol details.
136
198
 
137
- ## Release
199
+ ---
138
200
 
139
- This project uses [Release Please](https://github.com/googleapis/release-please) with [Conventional Commits](https://www.conventionalcommits.org/) to automate versioning and publishing.
201
+ ## Development
140
202
 
141
- See [RELEASE.md](RELEASE.md) for the full release guide.
203
+ ### Prerequisites
142
204
 
143
- ## VS Code Configuration
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)
144
209
 
145
- | Key | Type | Default | Description |
146
- | -------------------- | --------------------- | --------- | --------------------------------------------- |
147
- | `piXIde.rangeFormat` | `"comma"` \| `"dash"` | `"comma"` | File reference format for the manual shortcut |
210
+ ### Install & Build
148
211
 
149
- ## Zed Editor Support
212
+ Clone the repository, then build:
150
213
 
151
- Pi detects Zed automatically when running inside a Zed terminal (`ZED_TERM=true` or `TERM_PROGRAM=zed`). No Zed extension is required.
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
+ ```
152
220
 
153
- ### How It Works
221
+ To load the local build without installing globally:
154
222
 
155
- Pi reads Zed's local SQLite state database to discover the active editor file, selected text ranges, and buffer contents. The database is polled once per second, and changes are reflected in the Pi TUI widget.
223
+ ```bash
224
+ pi -e ./src/pi/index.ts
225
+ ```
156
226
 
157
- ### Requirements
227
+ Common commands:
158
228
 
159
- - Zed running on the same machine
160
- - Pi launched from Zed's integrated terminal
161
- - Node.js 26 (required for `node:sqlite`)
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` |
162
236
 
163
- ### Configuration
237
+ ### Testing the VS Code Extension Locally
164
238
 
165
- | Environment Variable | Default | Description |
166
- | -------------------- | ------------- | ------------------------------------ |
167
- | `PI_X_IDE_ZED_DB` | (auto-detect) | Override path to Zed SQLite database |
239
+ #### Option 1: F5 Extension Development Host (Recommended)
168
240
 
169
- Default database paths:
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
- - **Linux:** `~/.local/share/zed/db/0-stable/db.sqlite`
172
- - **macOS:** `~/Library/Application Support/Zed/db/0-stable/db.sqlite`
173
- - **Windows:** `%LOCALAPPDATA%\\Zed\\db\\0-stable\\db.sqlite`
174
- - **WSL with Windows Zed:** `/mnt/c/Users/<user>/AppData/Local/Zed/db/0-stable/db.sqlite`
248
+ #### Option 2: Package VSIX and Install
249
+
250
+ ```bash
251
+ pnpm package:vscode
252
+ code --install-extension './vscode'-0.1.0.vsix
253
+ ```
175
254
 
176
- When Pi runs in WSL and Zed runs as a Windows app, pi-x-ide normalizes Windows paths such as `C:\\Users\\<user>\\project` to `/mnt/c/Users/<user>/project`, and matching WSL UNC paths such as `\\\\wsl.localhost\\Ubuntu\\home\\<user>\\project` to `/home/<user>/project`.
255
+ The extension installed this way runs in all VS Code windows, independent of the F5 Extension Host.
177
256
 
178
- ### Feature Parity
257
+ #### Verify the Extension is Running
179
258
 
180
- | Feature | VS Code | Zed |
181
- | ----------------------------------- | ----------------- | ------------------------------- |
182
- | Live file tracking | ✅ Real-time push | ✅ 1s polling |
183
- | Live selection tracking | ✅ Real-time push | ✅ 1s polling |
184
- | `Ctrl+Alt+K` / `Cmd+Alt+K` shortcut | ✅ | Use `@<relative-path>` manually |
185
- | LLM context injection | ✅ | ✅ |
186
- | `/ide auto` | ✅ | ✅ |
259
+ ```bash
260
+ ls -l ~/.pi/pi-x-ide/lock
261
+ ```
262
+
263
+ You should see a file like `vscode-12345-48123.lock`. If not, run **Developer: Reload Window** in VS Code.
264
+
265
+ ### Release
266
+
267
+ This project uses [Release Please](https://github.com/googleapis/release-please) with [Conventional Commits](https://www.conventionalcommits.org/) to automate versioning and publishing.
268
+
269
+ See [RELEASE.md](RELEASE.md) for the full release guide.