pi-x-ide 1.4.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.
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-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/lock
40
+ PI_X_IDE_AUTO_INSTALL=0
55
41
  ```
56
42
 
57
- You should see a file like `vscode-12345-48123.lock`.
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
- Start Pi in the **same project directory**:
45
+ #### Zed
64
46
 
65
- ```bash
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
- - Footer: `IDE: vscode ✓`
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
- 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:
51
+ #### Neovim
75
52
 
76
- ```bash
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
- Pi-side environment variables can also be configured in `~/.pi/config.json`:
55
+ **lazy.nvim:**
81
56
 
82
- ```json
57
+ ```lua
83
58
  {
84
- "env": {
85
- "PI_X_IDE_AUTO_INSTALL": "0"
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
- Real environment variables take precedence over values from `~/.pi/config.json`. See [schemas/config.json](schemas/config.json) for editor schema guidance.
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
- If VS Code was started after Pi, run the following in Pi:
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
- ## Feature Verification
80
+ See [Configuration Reference](#neovim-2) for full setup options, commands, and troubleshooting.
101
81
 
102
- ### Live Selection
82
+ ### 4. Connect Pi & Verify
103
83
 
104
- 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:
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
- 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.
113
91
 
114
- - Linux/Windows: `Ctrl+Alt+K`
115
- - macOS: `Cmd+Alt+K`
92
+ **Verify it works:**
116
93
 
117
- The Pi input box should insert:
94
+ Open a file in your IDE and select some text. The widget should update in real time:
118
95
 
119
96
  ```
120
- @src/foo.ts#L10,20
97
+ IDE: vscode ✓ src/foo.ts#L10,20 pending
121
98
  ```
122
99
 
123
- ### 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`.
124
101
 
125
- 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.
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
- After submission, the TUI displays `sent`.
104
+ **If the connection doesn't appear:**
128
105
 
129
- ## `/ide` Command Reference
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
- ## 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
142
131
 
143
- 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` as an environment variable or in `~/.pi/config.json` under `env`.
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
- ## Release
199
+ ---
150
200
 
151
- 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
152
202
 
153
- See [RELEASE.md](RELEASE.md) for the full release guide.
203
+ ### Prerequisites
154
204
 
155
- ## 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)
156
209
 
157
- | Key | Type | Default | Description |
158
- | -------------------- | --------------------- | --------- | --------------------------------------------- |
159
- | `piXIde.rangeFormat` | `"comma"` \| `"dash"` | `"comma"` | File reference format for the manual shortcut |
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
- ## Zed Editor Support
227
+ Common commands:
162
228
 
163
- Pi detects Zed automatically when running inside a Zed terminal (`ZED_TERM=true` or `TERM_PROGRAM=zed`). No Zed extension is required.
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
- ### How It Works
237
+ ### Testing the VS Code Extension Locally
166
238
 
167
- 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.
239
+ #### Option 1: F5 Extension Development Host (Recommended)
168
240
 
169
- ### Requirements
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
- - Zed running on the same machine
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
- ### Configuration
250
+ ```bash
251
+ pnpm package:vscode
252
+ code --install-extension './vscode'-0.1.0.vsix
253
+ ```
176
254
 
177
- | Environment Variable | Default | Description |
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
- This Pi-side variable can also be set in `~/.pi/config.json` under `env`.
257
+ #### Verify the Extension is Running
182
258
 
183
- Default database paths:
259
+ ```bash
260
+ ls -l ~/.pi/pi-x-ide/lock
261
+ ```
184
262
 
185
- - **Linux:** `~/.local/share/zed/db/0-stable/db.sqlite`
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
- 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`.
265
+ ### Release
191
266
 
192
- ### Feature Parity
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
- | Feature | VS Code | Zed |
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.