pi-cursor-sdk 0.0.0 → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1 - 2026-05-05
4
+
5
+ ### Fixed
6
+
7
+ - Use the bundled default context window for newly discovered Cursor models that do not expose a catalog `context` parameter.
8
+ - Redact more Cursor SDK error formats, including JSON-style `apiKey`, `token`, `session_id`, and multi-pair cookie values.
9
+
10
+ ### Changed
11
+
12
+ - Keep local demo-script notes out of the published npm tarball.
13
+
14
+ ## 0.1.0 - 2026-05-04
15
+
16
+ Initial public release.
17
+
18
+ ### Added
19
+
20
+ - Cursor provider registration for pi backed by local `@cursor/sdk` agents.
21
+ - Cursor model discovery with fallback startup models when discovery is unavailable.
22
+ - Context-window model variants such as `cursor/gpt-5.5@1m` and `cursor/gpt-5.5@272k`.
23
+ - Pi native thinking-level mapping for Cursor SDK `reasoning`, `effort`, and boolean `thinking` controls when exposed by the SDK.
24
+ - Cursor fast-mode controls through `/cursor-fast`, `--cursor-fast`, and `--cursor-no-fast`.
25
+ - Image forwarding from the latest user message to Cursor.
26
+ - Cursor-side trace output before final text while preserving pi's default footer.
27
+ - Local context-window override cache from successful Cursor SDK checkpoint metadata.
28
+
29
+ ### Notes
30
+
31
+ - All Cursor SDK models are treated as thinking-capable, even when `pi --list-models` shows `thinking=no`; that column only means pi cannot control a thinking parameter for that model.
32
+ - Fallback Cursor models are selection-only. Actual Cursor runs require `CURSOR_API_KEY` or pi's `--api-key`.
33
+ - Cursor cloud agents, Cursor Max Mode selection, pi tool-schema forwarding, and ambient Cursor setting/rule loading are not supported in this release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mitch Fultz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,273 @@
1
1
  # pi-cursor-sdk
2
2
 
3
- Reserved package name. Real release coming soon.
3
+ A pi provider extension that lets pi use Cursor models through the local `@cursor/sdk` agent runtime.
4
+
5
+ Use this extension if you want Cursor's model catalog inside pi while keeping pi's native model picker, thinking controls where the SDK exposes them, session restore, context display, and default footer UX.
6
+
7
+ ## Quick start
8
+
9
+ 1. Install the package:
10
+
11
+ ```bash
12
+ pi install npm:pi-cursor-sdk
13
+ ```
14
+
15
+ Or install from GitHub:
16
+
17
+ ```bash
18
+ pi install https://github.com/fitchmultz/pi-cursor-sdk
19
+ ```
20
+
21
+ 2. Export your Cursor API key before starting pi:
22
+
23
+ ```bash
24
+ export CURSOR_API_KEY="your-key"
25
+ ```
26
+
27
+ 3. Start pi with a Cursor model:
28
+
29
+ ```bash
30
+ pi --model cursor/composer-2
31
+ ```
32
+
33
+ Inside pi, use `/model` to choose another Cursor model.
34
+
35
+ ## Requirements
36
+
37
+ - Node.js 18+
38
+ - pi
39
+ - a Cursor API key available as `CURSOR_API_KEY` or passed with pi's `--api-key`
40
+
41
+ No global `@cursor/sdk` install is required. This package depends on `@cursor/sdk`, so normal package installation brings in the SDK version this extension was built and tested against.
42
+
43
+ ## Install
44
+
45
+ ### Global install
46
+
47
+ ```bash
48
+ pi install npm:pi-cursor-sdk
49
+ ```
50
+
51
+ Alternative GitHub install:
52
+
53
+ ```bash
54
+ pi install https://github.com/fitchmultz/pi-cursor-sdk
55
+ ```
56
+
57
+ ### Project-local install
58
+
59
+ Use `-l` if you want the package recorded in the current project's `.pi/settings.json` instead of your global pi settings:
60
+
61
+ ```bash
62
+ pi install -l npm:pi-cursor-sdk
63
+ ```
64
+
65
+ ### Try from a local checkout
66
+
67
+ For development from this repository:
68
+
69
+ ```bash
70
+ npm install
71
+ pi -e . --model cursor/composer-2
72
+ ```
73
+
74
+ ## Configure your Cursor API key
75
+
76
+ Preferred setup:
77
+
78
+ ```bash
79
+ export CURSOR_API_KEY="your-key"
80
+ pi --model cursor/composer-2
81
+ ```
82
+
83
+ One-shot setup:
84
+
85
+ ```bash
86
+ pi --api-key "your-key" --model cursor/composer-2 --cursor-no-fast -p "Say ok only."
87
+ ```
88
+
89
+ Use `CURSOR_API_KEY` when possible. It gives the extension a key during startup model discovery. `--api-key` is also read for discovery and runs, but shell wrappers and launchers are easier to diagnose when the key is exported as `CURSOR_API_KEY` before pi starts.
90
+
91
+ Important: if pi starts without a valid `CURSOR_API_KEY` or `--api-key`, model discovery may fall back to a conservative Cursor model list. That fallback list is only for selection/display. Cursor runs in that already-started session will fail until you restart pi with a valid key.
92
+
93
+ Do not store the API key in `~/.pi/agent/cursor-sdk.json`. That file is only for non-secret extension state such as Cursor fast defaults. `PATH` is only for executable lookup and should not contain the API key.
94
+
95
+ ## Verify your setup
96
+
97
+ List Cursor models:
98
+
99
+ ```bash
100
+ pi --list-models cursor
101
+ ```
102
+
103
+ Expected behavior:
104
+
105
+ - with a valid key, Cursor models appear under the `cursor` provider
106
+ - if discovery cannot authenticate or reach Cursor, pi may still show fallback Cursor models, but those rows are selection-only and actual runs will fail until restart with a valid key
107
+
108
+ Smoke test:
109
+
110
+ ```bash
111
+ pi --model cursor/composer-2 --cursor-no-fast -p "Reply with: ok"
112
+ ```
113
+
114
+ ## Choosing a model
115
+
116
+ Choose Cursor models interactively with `/model`, or pass a model on the command line:
117
+
118
+ ```bash
119
+ pi --model cursor/composer-2
120
+ pi --model cursor/gpt-5.5@1m
121
+ pi --model cursor/gpt-5.5@272k
122
+ pi --model cursor/claude-opus-4-7@300k
123
+ ```
124
+
125
+ How to read model IDs:
126
+
127
+ - `cursor/...` is the Cursor provider registered by this extension
128
+ - `@1m`, `@272k`, and `@300k` are context-window variants
129
+ - `:medium`, `:high`, and `:xhigh` are pi thinking-level suffixes for models where the Cursor SDK exposes a pi-controllable thinking parameter
130
+
131
+ Examples with pi thinking controls:
132
+
133
+ ```bash
134
+ pi --model cursor/gpt-5.5@1m:medium
135
+ pi --model cursor/gpt-5.5@272k:xhigh
136
+ pi --model cursor/gpt-5.5@1m --thinking medium
137
+ ```
138
+
139
+ Cursor-only parameters are not encoded into pi model IDs. Cursor `context` becomes a pi-visible model variant because it changes pi's native `contextWindow`; Cursor `fast` is extension state, not model identity.
140
+
141
+ ## Thinking support
142
+
143
+ All Cursor SDK models should be treated as thinking-capable Cursor models. The `thinking` column in `pi --list-models` is narrower: it only means pi can control a Cursor SDK thinking parameter for that model.
144
+
145
+ For models where Cursor exposes `reasoning`, `effort`, or boolean `thinking` parameters, pi's native thinking controls map to Cursor SDK params:
146
+
147
+ - `reasoning=none|low|medium|high|extra-high`
148
+ - `effort=low|medium|high|xhigh|max`
149
+ - `thinking=false|true` for boolean thinking models
150
+
151
+ For Claude models with both `thinking` and `effort`, pi thinking `off` sends `thinking=false` and omits `effort`.
152
+
153
+ ### Why some Cursor models show `thinking=no`
154
+
155
+ In `pi --list-models`, `thinking=no` means pi cannot control the model's thinking level with `--thinking`, a final `:medium` model suffix, or shift+tab. It does not mean the Cursor model cannot think.
156
+
157
+ Some Cursor SDK models do not expose a `reasoning`, `effort`, or `thinking` parameter for the extension to set. Cursor thinking is still enabled/supported by the model, and Cursor may still emit thinking deltas. The extension does not disable Cursor's default reasoning behavior.
158
+
159
+ ## Fast mode
160
+
161
+ Use `/cursor-fast` to persistently toggle fast mode for the selected Cursor model when the model supports Cursor's `fast` parameter.
162
+
163
+ Fast preferences are remembered per Cursor base model and stored:
164
+
165
+ - in the current session with `pi.appendEntry()`
166
+ - globally in `~/.pi/agent/cursor-sdk.json`
167
+
168
+ For one run, force fast on or off without changing saved defaults:
169
+
170
+ ```bash
171
+ pi --model cursor/gpt-5.5@1m --cursor-fast -p "Say ok only"
172
+ pi --model cursor/composer-2 --cursor-no-fast -p "Say ok only"
173
+ ```
174
+
175
+ `composer-2` can default to fast. Use `--cursor-no-fast` for a one-shot no-fast `composer-2` run. In print mode (`-p`), `--cursor-no-fast` is silent and does not write `~/.pi/agent/cursor-sdk.json`.
176
+
177
+ In interactive mode, the footer only shows fast mode when fast is enabled:
178
+
179
+ ```text
180
+ cursor fast
181
+ ```
182
+
183
+ If you do not see `cursor fast`, fast mode is off.
184
+
185
+ ## Images
186
+
187
+ Images from the latest user message are forwarded to Cursor. Historical images are kept out of the transcript. The extension advertises `text` and `image` input for Cursor models because Cursor's SDK accepts image messages and Cursor models are expected to support them.
188
+
189
+ ## Fallback models
190
+
191
+ If `CURSOR_API_KEY` is missing, model discovery fails, or discovery returns no models, the extension registers conservative fallback Cursor models and notifies interactive users when possible:
192
+
193
+ - `composer-2`
194
+ - `gpt-5.5@1m`, `gpt-5.5@272k`
195
+ - `claude-sonnet-4-6@1m`, `claude-sonnet-4-6@300k`
196
+ - `claude-opus-4-7@1m`, `claude-opus-4-7@300k`
197
+
198
+ Fallback models are only a startup model list. Actual Cursor runs still need `CURSOR_API_KEY` or `--api-key`.
199
+
200
+ ## Limits
201
+
202
+ - **Local Cursor SDK agents only.** This extension does not use Cursor cloud agents.
203
+ - **Cursor-side tool use is not exposed as pi tool calls.** You may see compact Cursor trace text before the final answer, but you will not get normal pi tool-call rows for Cursor's internal tool activity.
204
+ - **Pi tool schemas are not passed through to Cursor.** This extension is a Cursor provider, not a bridge that forwards pi's tool system into Cursor.
205
+ - **One fresh Cursor agent is created per provider call.** Cursor agent state is not reused between pi provider calls.
206
+ - **Ambient Cursor setting/rule layers are not loaded by default.** The current Cursor SDK writes setting/rule loading logs directly to terminal output, which corrupts pi's TUI, so the extension leaves those layers out.
207
+ - **Max Mode is not exposed for these local runs.** The extension only advertises exact context windows supported by the SDK path it uses.
208
+ - **Output token limits are conservative.** Cursor SDK model metadata does not currently expose output token limits directly.
209
+
210
+ ## Troubleshooting
211
+
212
+ ### I can see Cursor models, but runs fail
213
+
214
+ You may be seeing fallback startup models. Restart pi with a key in the same shell or launcher that starts pi:
215
+
216
+ ```bash
217
+ export CURSOR_API_KEY="your-key"
218
+ pi --model cursor/composer-2
219
+ ```
220
+
221
+ Or run a one-shot command:
222
+
223
+ ```bash
224
+ pi --api-key "your-key" --model cursor/composer-2 -p "Say ok only"
225
+ ```
226
+
227
+ ### `pi --list-models cursor` shows no Cursor models
228
+
229
+ Confirm the package is installed:
230
+
231
+ ```bash
232
+ pi list
233
+ ```
234
+
235
+ Then reinstall if needed:
236
+
237
+ ```bash
238
+ pi install npm:pi-cursor-sdk
239
+ ```
240
+
241
+ ### `pi --list-models` shows `thinking=no`
242
+
243
+ That does not mean the model cannot think. It means the Cursor SDK does not expose a pi-controllable thinking parameter for that model. The model may still think internally and may still emit thinking deltas.
244
+
245
+ ### I do not see `cursor fast` in the footer
246
+
247
+ Fast mode is currently off. The footer only shows `cursor fast` when fast mode is enabled.
248
+
249
+ ### My Cursor app settings or rules do not seem to apply
250
+
251
+ They are not loaded by default in this extension. See [Limits](#limits).
252
+
253
+ ## Development
254
+
255
+ Run checks:
256
+
257
+ ```bash
258
+ npm test
259
+ npm run typecheck
260
+ ```
261
+
262
+ Local development run:
263
+
264
+ ```bash
265
+ npm install
266
+ CURSOR_API_KEY="your-key" pi -e . --model cursor/composer-2
267
+ ```
268
+
269
+ Maintainer design notes live in [`docs/cursor-model-ux-spec.md`](docs/cursor-model-ux-spec.md).
270
+
271
+ ## License
272
+
273
+ MIT