pi-cursor-sdk 0.1.14 → 0.1.16
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 +57 -0
- package/README.md +68 -14
- package/docs/cursor-live-smoke-checklist.md +271 -0
- package/docs/cursor-model-ux-spec.md +27 -4
- package/docs/cursor-native-tool-replay.md +99 -0
- package/docs/cursor-native-tool-visual-audit.md +183 -0
- package/package.json +6 -2
- package/src/context.ts +214 -16
- package/src/cursor-bridge-contract.ts +27 -0
- package/src/cursor-live-run-accounting.ts +65 -0
- package/src/cursor-mcp-timeout-override.ts +111 -0
- package/src/cursor-native-tool-display.ts +409 -49
- package/src/cursor-pi-tool-bridge.ts +1174 -0
- package/src/cursor-provider.ts +614 -146
- package/src/cursor-question-tool.ts +252 -0
- package/src/cursor-session-agent.ts +372 -0
- package/src/cursor-session-cwd.ts +28 -0
- package/src/cursor-session-scope.ts +65 -0
- package/src/cursor-state.ts +38 -10
- package/src/cursor-tool-names.ts +67 -0
- package/src/cursor-tool-transcript.ts +730 -61
- package/src/cursor-usage-accounting.ts +71 -0
- package/src/index.ts +27 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.1.16 - 2026-05-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Reuse Cursor SDK agents within the same pi session when model, API key, cwd, bridge surface, and pi context remain compatible, sending incremental follow-up prompts instead of re-bootstrapping full history on every turn.
|
|
10
|
+
- Add context fingerprinting to choose bootstrap vs incremental `Agent.send()` prompts, including branch and compaction summary detection after `/tree` navigation and session compaction.
|
|
11
|
+
- Add a manual [Cursor live smoke checklist](docs/cursor-live-smoke-checklist.md) for release validation with real `pi -e . --cursor-no-fast --model cursor/composer-2.5` runs, diagnostics safety scans, TUI observation, bridge/replay checks, abort/cancel coverage, and an assume-everything-is-in-scope no-optional/no-deferred release rule.
|
|
12
|
+
- Share the Cursor pi bridge contract through provider prompts and bridged MCP tool descriptions via `src/cursor-bridge-contract.ts`.
|
|
13
|
+
- Isolate Cursor usage and live-run accounting in `src/cursor-usage-accounting.ts` and `src/cursor-live-run-accounting.ts`.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Clarify the Cursor provider tool contract in README and replay docs: separate Cursor-native surface, pi bridge surface, and display-only replay.
|
|
18
|
+
- Document bridge debug diagnostics (`PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1`) and the scrubbed JSONL allowlist behavior.
|
|
19
|
+
- Refresh Cursor fast footer status on `turn_start` and treat models with the `cursor-sdk` API as Cursor models for status updates.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Harden Cursor pi tool bridge diagnostics so debug JSONL uses run-safe IDs separate from tokenized loopback routes and an allowlisted serializer that omits endpoint path material, raw args/results, and secrets.
|
|
24
|
+
- Improve Cursor SDK token accounting for `/session` and compaction by keeping raw Cursor internal usage diagnostic-only, counting split-run tool-call activity/tool-result consumption in approximate pi session usage, using `usage.totalTokens` for the replayable Cursor prompt/context estimate, and sharing the same matched tool-result boundary between provider usage and bridge result resolution.
|
|
25
|
+
- Fix duplicated final assistant text when Cursor streams partial post-tool text that prefixes the eventual final answer.
|
|
26
|
+
- Preserve the latest user request in budgeted incremental Cursor session-agent prompts.
|
|
27
|
+
- Invalidate and recreate session agents on compaction, API key changes, send errors, session shutdown, and `/tree` navigation so reused agents stay aligned with the active branch.
|
|
28
|
+
- Treat `/reload` session shutdown as non-terminal for the session-agent pool so the same session can acquire a fresh Cursor SDK agent after reload.
|
|
29
|
+
- Bootstrap prompts now include branch summaries after `/tree` navigation.
|
|
30
|
+
- Harden Cursor pi tool bridge validation and contract boundaries.
|
|
31
|
+
|
|
32
|
+
## 0.1.15 - 2026-05-21
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Add the default-on local pi MCP tool bridge, which exposes bridgeable active pi tools to local Cursor agents while executing calls through pi's normal tool path.
|
|
37
|
+
- Add `cursor_ask_question` through the bridge so Cursor can ask users through pi UI as `pi__cursor_ask_question`.
|
|
38
|
+
- Add `PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1` for opting in to overlapping built-in pi tools that are hidden from the Cursor bridge by default.
|
|
39
|
+
- Add Cursor SDK MCP tool-call timeout overrides via `PI_CURSOR_MCP_TOOL_TIMEOUT_SECONDS` and `PI_CURSOR_MCP_TOOL_TIMEOUT_MS` for long-running local MCP tools, including bridged pi tools.
|
|
40
|
+
- Replay Cursor SDK `grep` activity through native pi `grep` cards and `glob` activity through native pi `find` cards, so search activity matches built-in tool UX in interactive TTY sessions.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- Load Cursor setting sources with `PI_CURSOR_SETTING_SOURCES=all` by default while filtering direct Cursor SDK startup logs so settings, rules, plugins, and configured Cursor MCP servers are available without corrupting pi's TUI.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- Replay recorded Cursor tool errors, including nonzero shell exits and timeout-backgrounded shell commands, as native pi tool errors instead of successful green cards.
|
|
49
|
+
- Format zero-match Cursor grep results as `(no matches)` instead of raw `{ "totalMatches": 0 }` JSON in native replay and transcript output.
|
|
50
|
+
- Strip trailing colons from Cursor grep file-list replay output.
|
|
51
|
+
- Make native Cursor read replay closer to pi's built-in read cards by displaying session-relative paths and 20-line continuation hints.
|
|
52
|
+
- Convert Cursor SDK shell timeouts from milliseconds to seconds in native bash replay cards instead of rendering `30000ms` as `30000s`.
|
|
53
|
+
- Use the pi session cwd for Cursor `Agent.create`, not only native tool replay display. Completes the 0.1.10 cwd work that previously updated replay registration but left the Cursor agent runtime on `process.cwd()`.
|
|
54
|
+
- Replay path-only Cursor `write` activity through neutral recorded Cursor activity instead of invalid native pi `write` calls.
|
|
55
|
+
- Preserve literal `cursor_edit`, `cursor_write`, and `cursor_mcp` text in user messages, assistant text, tool args, and tool results while still relabeling structured replay tool names.
|
|
56
|
+
- Avoid hiding unrelated MCP activity whose result payload merely contains a bridge tool name, while still suppressing real bridge-owned Cursor MCP replay by invocation identity and call ID.
|
|
57
|
+
- Clean up pending native replay waits when abort signals are already aborted or abort before listener registration.
|
|
58
|
+
- Suppress direct Cursor SDK settings/skills startup noise, including late `managed_skills.removed` lines, without swallowing unrelated non-startup stdout/stderr output.
|
|
59
|
+
|
|
3
60
|
## 0.1.14 - 2026-05-18
|
|
4
61
|
|
|
5
62
|
### Changed
|
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ For Claude models with both `thinking` and `effort`, pi thinking `off` sends `th
|
|
|
165
165
|
|
|
166
166
|
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.
|
|
167
167
|
|
|
168
|
-
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
|
|
168
|
+
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 surfaces those deltas through pi's native thinking rendering when the SDK emits them.
|
|
169
169
|
|
|
170
170
|
## Fast mode
|
|
171
171
|
|
|
@@ -197,6 +197,43 @@ If you do not see `cursor fast`, fast mode is off.
|
|
|
197
197
|
|
|
198
198
|
Images from the latest user message are forwarded to Cursor. Historical images are kept out of the transcript and appear only as `[image omitted from transcript]` placeholders, so follow-up questions about an earlier image should reattach the image or include a textual description. 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.
|
|
199
199
|
|
|
200
|
+
|
|
201
|
+
## Cursor provider tool contract
|
|
202
|
+
|
|
203
|
+
Cursor runs use local Cursor SDK agents with two separate tool surfaces:
|
|
204
|
+
|
|
205
|
+
- **Cursor-native surface:** Cursor local-agent tools, Cursor settings, plugins, and configured Cursor MCP servers. These remain owned by the Cursor SDK local agent path.
|
|
206
|
+
- **pi bridge surface:** pi-cursor-sdk exposes bridgeable active pi tools through a per-run local loopback MCP bridge when the bridge is enabled and the current pi tool registry has exposed tools.
|
|
207
|
+
|
|
208
|
+
Bridge capabilities are snapshotted from `pi.getActiveTools()` and `pi.getAllTools()` for each Cursor run. Cursor sees active bridgeable pi tools as collision-safe MCP names such as `pi__sem_reindex` only when they are exposed in that current run. Pi session output, tool cards, confirmations, hooks, renderers, history, and abort behavior use the real pi tool name, such as `sem_reindex`. The bridge queues Cursor's MCP call, emits a normal pi `toolCall`, waits for the matching pi `toolResult`, and resolves that result back into the same live Cursor SDK run without creating a new `Agent`, unless the run was disposed, aborted, or cancelled. The bridge does not call pi tool `execute()` handlers directly.
|
|
209
|
+
|
|
210
|
+
Overlapping built-in pi tools (`read`, `bash`, `write`, `edit`, `grep`, `find`, `ls`) are hidden by default because Cursor local agents already have native equivalents. Extension/custom tools and non-overlapping active tools present in pi's active tool registry normally remain exposed. The bridge also exposes `cursor_ask_question` as `pi__cursor_ask_question` when enabled, allowing Cursor to ask the user through pi UI instead of silently choosing a default.
|
|
211
|
+
|
|
212
|
+
Cursor-native tool replay is separate from the bridge. Replay cards are display-only recorded Cursor SDK activity. They never re-run Cursor-side commands, reapply Cursor edits, call MCP servers, or mutate pi state. See [Cursor native tool replay](docs/cursor-native-tool-replay.md).
|
|
213
|
+
|
|
214
|
+
Bridge controls:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Roll back to Cursor SDK tools/settings/MCP only; do not expose active pi tools through the bridge.
|
|
218
|
+
PI_CURSOR_PI_TOOL_BRIDGE=0 pi --model cursor/composer-2.5
|
|
219
|
+
|
|
220
|
+
# Opt in to also expose overlapping pi tool names through the bridge.
|
|
221
|
+
PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1 pi --model cursor/composer-2.5
|
|
222
|
+
|
|
223
|
+
# Override Cursor SDK MCP tool-call timeout, including bridged pi tools and configured Cursor MCP servers.
|
|
224
|
+
PI_CURSOR_MCP_TOOL_TIMEOUT_SECONDS=7200 pi --model cursor/composer-2.5
|
|
225
|
+
PI_CURSOR_MCP_TOOL_TIMEOUT_MS=7200000 pi --model cursor/composer-2.5
|
|
226
|
+
|
|
227
|
+
# Emit scrubbed bridge diagnostics as JSONL to stderr with prefix [pi-cursor-sdk:bridge].
|
|
228
|
+
PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1 pi --model cursor/composer-2.5
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
`PI_CURSOR_PI_TOOL_BRIDGE=0` is the supported rollback flag and disables the bridge entirely. The bridge also treats `false`, `off`, `none`, `no`, and `disabled` as off; `1`, `true`, `on`, `yes`, and `enabled` as on. `PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1` opts in to exposing overlapping pi tool names that Cursor already has native equivalents for. The Cursor MCP timeout override defaults to 3600 seconds because the installed Cursor SDK has a 60-second MCP request default that is too short for some local MCP tools, including bridged pi tools and configured Cursor MCP servers. `PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1` is off by default and emits typed, allowlisted, scrubbed single-line JSONL records to `process.stderr`. These records are operational diagnostics, not anonymous telemetry: they intentionally include tool names, safe correlation IDs, bridge run state, exposed pi↔MCP name pairs, queued requests, result resolution, rejection, cancellation, and pending counts. They must not include endpoint URLs, endpoint path components, endpoint tokens, raw args/results, stdout/stderr payloads, file contents, Cursor settings output, API keys, bearer tokens, cookies, session credentials, or secrets. Do not enable or share bridge debug logs where tool names themselves are sensitive.
|
|
232
|
+
|
|
233
|
+
### Maintainer live smoke release gate
|
|
234
|
+
|
|
235
|
+
For Cursor provider/runtime changes, follow the manual [Cursor live smoke checklist](docs/cursor-live-smoke-checklist.md) before release. Assume every runtime surface is in scope. The checklist uses real `pi -e . --cursor-no-fast --model cursor/composer-2.5` runs with temporary session dirs and requires the visible TUI/output, scrubbed diagnostics, and persisted JSONL to agree. Do not mark a release ready with optional, deferred, mostly-passing, or unobserved smoke checks outstanding.
|
|
236
|
+
|
|
200
237
|
## Fallback models
|
|
201
238
|
|
|
202
239
|
If no key is available from `/login`, `CURSOR_API_KEY`, or `--api-key`, model discovery fails, or discovery returns no models, the extension registers a bundled fallback snapshot of the latest reviewed Cursor SDK model catalog and notifies interactive users when possible.
|
|
@@ -207,14 +244,14 @@ Actual Cursor runs still need a key from `/login`, `CURSOR_API_KEY`, or `--api-k
|
|
|
207
244
|
|
|
208
245
|
## Limits
|
|
209
246
|
|
|
210
|
-
- **Local Cursor SDK agents only.** This extension does not use Cursor cloud agents.
|
|
211
|
-
- **
|
|
212
|
-
- **
|
|
213
|
-
- **
|
|
214
|
-
- **Cursor setting sources
|
|
247
|
+
- **Local Cursor SDK agents only.** This extension does not use Cursor cloud agents. Cloud pi tool bridging is out of scope because it needs a separate auth, transport, lifetime, and remote trust design.
|
|
248
|
+
- **The pi tool bridge is local and MCP-backed.** Bridgeable active pi tools are exposed to local Cursor agents through a tokenized `127.0.0.1` MCP endpoint; internal Cursor replay activity names are excluded, and overlapping built-in pi tools are hidden by default. Set `PI_CURSOR_PI_TOOL_BRIDGE=0` to disable it or `PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1` to expose overlapping built-ins too.
|
|
249
|
+
- **Cursor native tool replay is display-only.** Replay renders recorded Cursor SDK activity and never re-runs Cursor-side commands, reapplies Cursor edits, calls MCP servers, or mutates pi state. Workflow tools such as Cursor `SwitchMode` and Cursor todo state are not pi workflow controls. See [Cursor native tool replay](docs/cursor-native-tool-replay.md) for supported replay cards, ordering, conflict handling, and opt-out flags.
|
|
250
|
+
- **Cursor run state can span tool-use turns.** Within a pi session, the extension reuses one Cursor SDK agent across compatible follow-up turns and sends incremental prompts when context still matches. It recreates the agent when context diverges, after compaction or `/tree` navigation, on API key changes, after send errors, or on session shutdown. For bridged pi tools, the matching pi `toolResult` resolves into the same live Cursor SDK run without creating a new `Agent`, unless the run was disposed, aborted, or cancelled. Replay can also split one live Cursor SDK run across pi `toolUse` turns for display.
|
|
251
|
+
- **Cursor setting sources default to all.** The extension passes `local.settingSources: ["all"]` by default so configured Cursor MCP servers, plugin tools, project/user settings, and related Cursor-native capabilities are available like they are in Cursor. To narrow loading, set a comma-separated list such as `PI_CURSOR_SETTING_SOURCES=project,user,plugins`. To disable ambient setting sources, set `PI_CURSOR_SETTING_SOURCES=none`. Direct Cursor SDK startup logs are suppressed so setting/skill loading messages do not pollute the TUI.
|
|
215
252
|
- **Max Mode is not a manual pi variant.** Cursor's SDK may enable Max Mode automatically for models that require it. This extension only advertises exact context-window variants that the SDK catalog exposes and otherwise uses conservative SDK-derived default/non-Max context windows.
|
|
216
253
|
- **Output token limits are conservative.** Cursor SDK model metadata does not currently expose output token limits directly.
|
|
217
|
-
- **Token usage is approximate in pi.** Cursor SDK usage events include internal agent/tool/cache work, so
|
|
254
|
+
- **Token usage is approximate in pi.** Cursor SDK usage events include cumulative internal agent/tool/cache work, so raw Cursor SDK counters are not copied into pi usage. The extension reports approximate pi session activity in `input`/`output`, including split-run tool calls and consumed tool results, while `totalTokens` tracks the replayable Cursor prompt/context estimate used for context display and compaction.
|
|
218
255
|
|
|
219
256
|
## Troubleshooting
|
|
220
257
|
|
|
@@ -251,7 +288,7 @@ pi install npm:pi-cursor-sdk
|
|
|
251
288
|
|
|
252
289
|
### `pi --list-models` shows `thinking=no`
|
|
253
290
|
|
|
254
|
-
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.
|
|
291
|
+
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 that pi renders natively.
|
|
255
292
|
|
|
256
293
|
### I do not see `cursor fast` in the footer
|
|
257
294
|
|
|
@@ -259,21 +296,38 @@ Fast mode is currently off. The footer only shows `cursor fast` when fast mode i
|
|
|
259
296
|
|
|
260
297
|
### My Cursor app settings or rules do not seem to apply
|
|
261
298
|
|
|
262
|
-
Cursor setting sources are
|
|
299
|
+
Cursor setting sources are loaded with `PI_CURSOR_SETTING_SOURCES=all` by default. To narrow loading, set `PI_CURSOR_SETTING_SOURCES=project,user,plugins` or another comma-separated list. If you explicitly disabled sources with `PI_CURSOR_SETTING_SOURCES=none`, remove that override.
|
|
263
300
|
|
|
264
301
|
### Cursor does not call my web search MCP/tool
|
|
265
302
|
|
|
266
|
-
Cursor SDK local agents load MCP servers from Cursor setting sources and inline SDK config. This extension
|
|
303
|
+
Cursor SDK local agents load MCP servers from Cursor setting sources and inline SDK config. This extension enables all Cursor setting sources by default, so a missing web search tool usually means it is not configured in Cursor or the run was started with a narrowing/disable override such as `PI_CURSOR_SETTING_SOURCES=none`.
|
|
267
304
|
|
|
268
|
-
### Cursor
|
|
305
|
+
### Cursor does not call my pi extension tool
|
|
306
|
+
|
|
307
|
+
The local pi bridge only exposes tools that are active in the current pi session and present in pi's tool registry at Cursor run start. By default, it does not expose overlapping pi tool names that Cursor already has native equivalents for (`read`, `bash`, `write`, `edit`, `grep`, `find`, and `ls`). Opt in if you intentionally want Cursor to see both the Cursor-native tool and an overlapping built-in pi tool:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1 pi --model cursor/composer-2.5
|
|
311
|
+
```
|
|
269
312
|
|
|
270
|
-
|
|
313
|
+
To disable the bridge for rollback or isolation, start pi with:
|
|
271
314
|
|
|
272
315
|
```bash
|
|
273
|
-
|
|
316
|
+
PI_CURSOR_PI_TOOL_BRIDGE=0 pi --model cursor/composer-2.5
|
|
274
317
|
```
|
|
275
318
|
|
|
276
|
-
|
|
319
|
+
### A Cursor MCP tool times out
|
|
320
|
+
|
|
321
|
+
The extension raises Cursor SDK's MCP tool-call timeout from 60 seconds to 3600 seconds by default for Cursor SDK MCP `callTool` requests, including the local pi bridge and configured Cursor MCP servers. For longer local MCP tools, set one override:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
PI_CURSOR_MCP_TOOL_TIMEOUT_SECONDS=7200 pi --model cursor/composer-2.5
|
|
325
|
+
PI_CURSOR_MCP_TOOL_TIMEOUT_MS=7200000 pi --model cursor/composer-2.5
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Cursor native tool cards conflict with another extension
|
|
329
|
+
|
|
330
|
+
Cursor native replay is a UI enhancement for interactive TTY sessions. See [Cursor native tool replay](docs/cursor-native-tool-replay.md) for conflict behavior and opt-out flags.
|
|
277
331
|
|
|
278
332
|
## Development
|
|
279
333
|
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Cursor Live Smoke Checklist
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Use this manual checklist before releasing Cursor provider/runtime changes. Unit tests and mocks are necessary, but they are not enough for this extension. Always assume every runtime surface is in scope. A release is not ready until every live check below has been observed with `cursor/composer-2.5` through the local working tree.
|
|
6
|
+
|
|
7
|
+
## Release rule
|
|
8
|
+
|
|
9
|
+
- Run from a clean working tree except for the intended branch diff.
|
|
10
|
+
- Use the local extension under test: `pi -e . --cursor-no-fast --model cursor/composer-2.5`.
|
|
11
|
+
- Use a temporary `--session-dir` for every run.
|
|
12
|
+
- Do not paste or commit Cursor API keys, raw session contents with secrets, endpoint URLs, or local private paths.
|
|
13
|
+
- If a check fails, stop and fix or explicitly mark the release blocked. Do not ship with "optional," "deferred," "mostly," or "probably" checks outstanding.
|
|
14
|
+
- Do not narrow the smoke scope to the apparent code diff. Treat provider reality, TUI behavior, bridge behavior, replay behavior, diagnostics safety, abort/cancel cleanup, usage accounting, packaging, and cleanup as in scope for every Cursor provider/runtime release.
|
|
15
|
+
- A check is passed only when the visible TUI/output, stderr diagnostics, and persisted JSONL agree with the expected behavior.
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export SMOKE_DIR="/tmp/pi-cursor-sdk-live-smoke-$(date +%Y%m%dT%H%M%S)"
|
|
21
|
+
mkdir -p "$SMOKE_DIR"
|
|
22
|
+
pi -e . --list-models cursor
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Pass criteria:
|
|
26
|
+
|
|
27
|
+
- `cursor/composer-2.5` appears in the model list.
|
|
28
|
+
- No Cursor key or auth token is printed.
|
|
29
|
+
- If `CURSOR_API_KEY` is unavailable and `/login` is not configured, stop and report the live smoke as blocked.
|
|
30
|
+
|
|
31
|
+
## 1. Basic provider reality check
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
PI_CURSOR_SETTING_SOURCES=none \
|
|
35
|
+
pi -e . --cursor-no-fast --model cursor/composer-2.5 \
|
|
36
|
+
--session-dir "$SMOKE_DIR/basic" \
|
|
37
|
+
--no-tools \
|
|
38
|
+
-p 'Live smoke. Reply exactly: PI_CURSOR_SMOKE_OK' \
|
|
39
|
+
> "$SMOKE_DIR/basic.stdout.txt" \
|
|
40
|
+
2> "$SMOKE_DIR/basic.stderr.txt"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pass criteria:
|
|
44
|
+
|
|
45
|
+
- Exit code is `0`.
|
|
46
|
+
- stdout contains `PI_CURSOR_SMOKE_OK`.
|
|
47
|
+
- stderr is empty or contains only expected non-secret diagnostics for the specific test.
|
|
48
|
+
- The persisted JSONL has exactly one assistant message with non-negative usage fields and `cacheRead/cacheWrite` equal to `0`.
|
|
49
|
+
|
|
50
|
+
## 2. Default setting-source startup noise check
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pi -e . --cursor-no-fast --model cursor/composer-2.5 \
|
|
54
|
+
--session-dir "$SMOKE_DIR/default-settings" \
|
|
55
|
+
--no-tools \
|
|
56
|
+
-p 'Default settings smoke. Include PRODUCT=42 in the final answer.' \
|
|
57
|
+
> "$SMOKE_DIR/default-settings.stdout.txt" \
|
|
58
|
+
2> "$SMOKE_DIR/default-settings.stderr.txt"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Pass criteria:
|
|
62
|
+
|
|
63
|
+
- Exit code is `0`.
|
|
64
|
+
- stdout includes `PRODUCT=42`.
|
|
65
|
+
- stderr is empty.
|
|
66
|
+
- No Cursor SDK settings/skills startup logs corrupt stdout or the TUI.
|
|
67
|
+
|
|
68
|
+
## 3. TUI observation check
|
|
69
|
+
|
|
70
|
+
Run a real interactive session under tmux:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
SESSION="pi-cursor-sdk-smoke-$(date +%s)"
|
|
74
|
+
tmux new-session -d -s "$SESSION" -x 120 -y 40 -- zsh -lc \
|
|
75
|
+
"cd '$PWD' && PI_CURSOR_SETTING_SOURCES=none pi -e . --cursor-no-fast --model cursor/composer-2.5 --session-dir '$SMOKE_DIR/tui' --no-tools 'TUI smoke. Compute 19 + 23. Reply only with SUM=<number>.'"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Observe with `tmux capture-pane -pt "$SESSION"` or attach manually.
|
|
79
|
+
|
|
80
|
+
Pass criteria:
|
|
81
|
+
|
|
82
|
+
- Footer shows `(cursor) composer-2.5`. With `--cursor-no-fast`, Cursor fast mode is off and the Cursor extension status should not show `cursor fast`; ignore unrelated status text from other extensions.
|
|
83
|
+
- Assistant answer appears correctly.
|
|
84
|
+
- `/session` shows one user and one assistant message for the simple run.
|
|
85
|
+
- Persisted JSONL has one assistant message. If the screen appears duplicated, inspect JSONL before deciding whether it is a rendering bug.
|
|
86
|
+
- Kill the tmux session after the check and verify no smoke tmux sessions remain.
|
|
87
|
+
|
|
88
|
+
## 4. Bridge multi-tool success and failure
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
PI_CURSOR_SETTING_SOURCES=none \
|
|
92
|
+
PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1 \
|
|
93
|
+
PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1 \
|
|
94
|
+
pi -e . --cursor-no-fast --model cursor/composer-2.5 \
|
|
95
|
+
--session-dir "$SMOKE_DIR/bridge" \
|
|
96
|
+
-p 'Bridge smoke. Do exactly two tool calls before answering: first call pi__read on ./package.json; second call pi__read on ./definitely-missing-pi-cursor-sdk-smoke-file.txt. Then answer: OK_NAME=<package name>; MISSING_RESULT=<error or success>. Do not use shell.' \
|
|
97
|
+
> "$SMOKE_DIR/bridge.stdout.txt" \
|
|
98
|
+
2> "$SMOKE_DIR/bridge.stderr.txt"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Pass criteria:
|
|
102
|
+
|
|
103
|
+
- stdout includes `OK_NAME=pi-cursor-sdk`.
|
|
104
|
+
- Diagnostics include `run_created`, `tools_exposed`, two `request_queued`, two `request_resolved`, and `run_disposed`.
|
|
105
|
+
- The missing-file request has `isError: true`.
|
|
106
|
+
- Persisted JSONL contains real pi tool calls named `read`, matching `toolResult` messages, and final assistant output.
|
|
107
|
+
- Later assistant usage counts consumed tool-result input; no assistant usage has negative values or nonzero cache fields.
|
|
108
|
+
|
|
109
|
+
## 5. Native replay cards without the pi bridge
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
PI_CURSOR_SETTING_SOURCES=none \
|
|
113
|
+
PI_CURSOR_PI_TOOL_BRIDGE=0 \
|
|
114
|
+
PI_CURSOR_NATIVE_TOOL_DISPLAY=1 \
|
|
115
|
+
pi -e . --cursor-no-fast --model cursor/composer-2.5 \
|
|
116
|
+
--session-dir "$SMOKE_DIR/native-replay" \
|
|
117
|
+
-p 'Native replay smoke. Use your Cursor file-reading capability to read ./README.md, then answer README_SEEN=yes if it contains pi-cursor-sdk.' \
|
|
118
|
+
> "$SMOKE_DIR/native-replay.stdout.txt" \
|
|
119
|
+
2> "$SMOKE_DIR/native-replay.stderr.txt"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Pass criteria:
|
|
123
|
+
|
|
124
|
+
- stdout includes `README_SEEN=yes`.
|
|
125
|
+
- Persisted JSONL shows an assistant `toolUse` turn with a replayed `read` tool call, a pi `read` `toolResult`, and a final assistant turn.
|
|
126
|
+
- Native replay is display-only: it must not re-run Cursor-side mutations or create duplicate pi mutations.
|
|
127
|
+
|
|
128
|
+
## 6. Diagnostics safety contract
|
|
129
|
+
|
|
130
|
+
Bridge diagnostics are scrubbed operational logs, not anonymous telemetry.
|
|
131
|
+
|
|
132
|
+
Allowed fields:
|
|
133
|
+
|
|
134
|
+
- event name
|
|
135
|
+
- run-safe correlation IDs that are not endpoint path components
|
|
136
|
+
- bridge/pi tool call IDs derived from the run-safe ID
|
|
137
|
+
- hashed Cursor MCP call correlation IDs of the form `cursor-mcp-call-<8 hex chars>`
|
|
138
|
+
- exposed pi/MCP tool name pairs
|
|
139
|
+
- pending/queued/cancelled counts
|
|
140
|
+
- success/error booleans
|
|
141
|
+
- rejection kind
|
|
142
|
+
|
|
143
|
+
Forbidden fields:
|
|
144
|
+
|
|
145
|
+
- Cursor API keys or auth headers
|
|
146
|
+
- bearer tokens, cookies, sessions, or raw credential material
|
|
147
|
+
- endpoint URLs, endpoint path components, endpoint tokens, or loopback URLs
|
|
148
|
+
- raw tool args
|
|
149
|
+
- raw tool results
|
|
150
|
+
- stdout/stderr payloads
|
|
151
|
+
- file contents
|
|
152
|
+
- Cursor settings/skills startup output
|
|
153
|
+
- local private session paths in tracked docs
|
|
154
|
+
|
|
155
|
+
Run a forbidden-material scan over smoke stderr/captures:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
find "$SMOKE_DIR" -type f \( -name '*stderr.txt' -o -name 'capture*.txt' \) -print0 |
|
|
159
|
+
xargs -0 grep -E 'CURSOR_API_KEY|Bearer [A-Za-z0-9._-]+|/cursor-pi-tool-bridge/[^ ]+/mcp|127\.0\.0\.1:[0-9]+/cursor-pi-tool-bridge|apiKey|cookie|session-cookie|secret-token'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Pass criteria:
|
|
163
|
+
|
|
164
|
+
- The grep returns no matches except deliberately planted test strings that are asserted not to appear in serialized diagnostics.
|
|
165
|
+
- If tool names themselves are considered sensitive for a release target, do not enable `PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1` for shared logs. The diagnostics contract intentionally allows tool names.
|
|
166
|
+
|
|
167
|
+
## 7. Long-running bridge and abort/cancel
|
|
168
|
+
|
|
169
|
+
This check is release-blocking for every Cursor provider/runtime release.
|
|
170
|
+
|
|
171
|
+
Use a harmless long-running command and interrupt it after the bridge request is queued:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
PI_CURSOR_SETTING_SOURCES=none \
|
|
175
|
+
PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1 \
|
|
176
|
+
PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1 \
|
|
177
|
+
pi -e . --cursor-no-fast --model cursor/composer-2.5 \
|
|
178
|
+
--session-dir "$SMOKE_DIR/abort" \
|
|
179
|
+
-p 'Abort smoke. Call pi__bash with command: sleep 30 && echo SHOULD_NOT_PRINT. Do not answer until the tool completes.'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Pass criteria:
|
|
183
|
+
|
|
184
|
+
- Interrupting the run does not leave `sleep 30`, `SHOULD_NOT_PRINT`, `pi`, or bridge-related child processes running.
|
|
185
|
+
- Diagnostics either show clean cancellation/disposal or the process exits cleanly without orphaning children.
|
|
186
|
+
- Persisted JSONL does not contain a false successful final answer.
|
|
187
|
+
|
|
188
|
+
## 8. Final structural session scan
|
|
189
|
+
|
|
190
|
+
After all live runs, scan JSONL structurally instead of reading raw content into a report:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
node <<'NODE'
|
|
194
|
+
const fs = require('fs');
|
|
195
|
+
const path = require('path');
|
|
196
|
+
const root = process.env.SMOKE_DIR;
|
|
197
|
+
const files = [];
|
|
198
|
+
function walk(dir) {
|
|
199
|
+
for (const name of fs.readdirSync(dir)) {
|
|
200
|
+
const p = path.join(dir, name);
|
|
201
|
+
const st = fs.statSync(p);
|
|
202
|
+
if (st.isDirectory()) walk(p);
|
|
203
|
+
else if (p.endsWith('.jsonl')) files.push(p);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
walk(root);
|
|
207
|
+
let failures = 0;
|
|
208
|
+
for (const file of files.sort()) {
|
|
209
|
+
const records = fs.readFileSync(file, 'utf8').trim().split(/\n+/).filter(Boolean).map(JSON.parse);
|
|
210
|
+
const messages = records.filter((record) => record.type === 'message').map((record) => record.message);
|
|
211
|
+
const assistants = messages.filter((message) => message.role === 'assistant');
|
|
212
|
+
const usage = assistants.map((message) => message.usage).filter(Boolean);
|
|
213
|
+
const badUsage = usage.filter((u) =>
|
|
214
|
+
typeof u.input !== 'number' || u.input < 0 ||
|
|
215
|
+
typeof u.output !== 'number' || u.output < 0 ||
|
|
216
|
+
typeof u.totalTokens !== 'number' || u.totalTokens < 0 ||
|
|
217
|
+
u.cacheRead !== 0 || u.cacheWrite !== 0
|
|
218
|
+
);
|
|
219
|
+
if (usage.length !== assistants.length || badUsage.length > 0) failures += 1;
|
|
220
|
+
console.log(JSON.stringify({ file: path.relative(root, file), assistantCount: assistants.length, usageCount: usage.length, badUsageCount: badUsage.length }));
|
|
221
|
+
}
|
|
222
|
+
process.exit(failures === 0 ? 0 : 1);
|
|
223
|
+
NODE
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Pass criteria:
|
|
227
|
+
|
|
228
|
+
- Every assistant message has valid usage.
|
|
229
|
+
- Cache fields remain `0`.
|
|
230
|
+
- Tool-heavy runs show nonzero output for visible assistant/tool-call activity.
|
|
231
|
+
- Split runs count consumed tool-result input once on the following assistant turn.
|
|
232
|
+
|
|
233
|
+
## 9. Standard local gates
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
git diff --check
|
|
237
|
+
npm test
|
|
238
|
+
npm run typecheck
|
|
239
|
+
npm pack --dry-run
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Pass criteria:
|
|
243
|
+
|
|
244
|
+
- All commands exit `0`.
|
|
245
|
+
- `npm pack --dry-run` includes all new runtime source files and excludes local smoke artifacts, sessions, package tarballs, `.env*`, `.pi/`, `dist/`, and `coverage/`.
|
|
246
|
+
|
|
247
|
+
## 10. Cleanup
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
tmux list-sessions | grep 'pi-cursor-sdk-smoke' || true
|
|
251
|
+
rm -rf "$SMOKE_DIR"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Pass criteria:
|
|
255
|
+
|
|
256
|
+
- No smoke tmux sessions remain.
|
|
257
|
+
- No smoke child processes remain.
|
|
258
|
+
- No smoke artifacts are committed.
|
|
259
|
+
|
|
260
|
+
## Coverage gaps this checklist makes explicit
|
|
261
|
+
|
|
262
|
+
Everything in this section is in scope for Cursor provider/runtime releases. These are not accepted as "done" unless the matching live check passes:
|
|
263
|
+
|
|
264
|
+
- Long-running bridged tool abort/cancel cleanup.
|
|
265
|
+
- Native replay cards beyond read, especially shell/edit/write cards, when those renderers change.
|
|
266
|
+
- Bridge question UI when `cursor_ask_question` changes.
|
|
267
|
+
- MCP timeout override behavior when timeout code changes.
|
|
268
|
+
- Ambient Cursor setting-source behavior when startup filtering or local Cursor settings handling changes.
|
|
269
|
+
- Model discovery aliases/context variants when model-discovery code or Cursor SDK versions change.
|
|
270
|
+
|
|
271
|
+
If any surface has no adequate live check, add that check before release instead of assuming mocks cover reality.
|
|
@@ -16,13 +16,27 @@ Current implementation notes:
|
|
|
16
16
|
- Image payload forwarding sends images only from the latest user message. If the latest user turn is plain text after an earlier image turn, the transcript keeps an `[image omitted from transcript]` placeholder but no image bytes are sent to Cursor. The prompt explicitly tells Cursor that prior image bytes are unavailable and to ask the user to reattach or describe a prior image when needed. Carrying images forward across turns remains a future product decision because it affects token cost, privacy, stale visual context, and expected multimodal follow-up behavior.
|
|
17
17
|
- `@cursor/sdk` is a package dependency of this extension; users should not need a global SDK install.
|
|
18
18
|
- Cursor auth uses pi-native API-key resolution for provider `cursor`: CLI `--api-key`, stored `~/.pi/agent/auth.json` API key from `/login`, then `CURSOR_API_KEY`. The extension config file stores only non-secret Cursor-only state such as fast defaults.
|
|
19
|
-
- Local agents
|
|
19
|
+
- Local agents pass `settingSources: ["all"]` by default so Cursor MCP servers, plugin tools, project/user settings, and related Cursor-native capabilities are available. Users can narrow loading with a comma-separated list such as `PI_CURSOR_SETTING_SOURCES=project,user,plugins`, or disable ambient setting sources with `PI_CURSOR_SETTING_SOURCES=none`. The provider suppresses direct Cursor SDK startup writes around agent creation so setting/skill loading logs do not pollute pi's TUI.
|
|
20
20
|
- Cursor SDK models are treated as thinking-capable even when pi reports `thinking=no`; that pi column only means the SDK did not expose a pi-controllable thinking parameter for that model.
|
|
21
|
-
- Cursor-side thinking remains visible
|
|
22
|
-
- Cursor
|
|
21
|
+
- Cursor-side thinking remains visible through pi's native thinking rendering when the Cursor SDK emits thinking or summary deltas.
|
|
22
|
+
- Local Cursor agents get two tool surfaces. First, Cursor keeps the Cursor SDK local-agent tool surface plus configured Cursor settings, plugins, and Cursor MCP servers. Second, pi-cursor-sdk exposes active pi tools through a default-on, tokenized loopback MCP bridge when bridgeable tools exist.
|
|
23
|
+
- `buildCursorPiToolBridgeSnapshot()` is the runtime capability source for pi bridge tools. It snapshots `pi.getActiveTools()` and `pi.getAllTools()`, filters internal replay names, hides overlapping built-in pi tools (`read`, `bash`, `write`, `edit`, `grep`, `find`, `ls`) unless `PI_CURSOR_EXPOSE_BUILTIN_TOOLS=1`, and creates collision-safe MCP names such as `pi__sem_reindex`. Cursor discovers the current run's exposed bridge tools through MCP `listTools`; there is no default run-start manifest, per-turn visible tool list, status manifest, or footer manifest.
|
|
24
|
+
- Prompt text is the primary provider/bridge contract. MCP tool descriptions repeat the same contract to reinforce discovery, but do not replace the prompt boundary. Cursor must call the exposed `pi__*` MCP name, not the real pi tool name shown in pi history or transcripts. Pi emits and executes the real pi tool name.
|
|
25
|
+
- The provider also registers `cursor_ask_question` for Cursor models when the bridge is enabled. Cursor sees it as `pi__cursor_ask_question`, and pi executes it through the normal tool path so interactive users can choose options from pi UI. In non-UI modes it reports that UI is unavailable so Cursor can state a default assumption instead. `PI_CURSOR_PI_TOOL_BRIDGE=0` disables the local bridge, including question bridging. Cloud Cursor agents remain out of scope for the bridge.
|
|
26
|
+
- The bridge queues MCP calls, emits provider `toolcall_*` events, waits for matching pi `toolResult` messages by `toolCallId`, resolves the result back into the same live Cursor SDK run without creating a new `Agent`, and never calls tool `execute()` handlers directly. The same-run resume invariant holds unless the run was disposed, aborted, or cancelled.
|
|
27
|
+
- Cursor SDK MCP tool calls use a guarded timeout override because installed `@cursor/sdk` 1.0.13 has a 60-second MCP request default with no public per-server timeout option. The extension extends that Cursor SDK MCP `callTool` timeout path to 3600 seconds by default. Users can override it with `PI_CURSOR_MCP_TOOL_TIMEOUT_MS` or `PI_CURSOR_MCP_TOOL_TIMEOUT_SECONDS`.
|
|
28
|
+
- Bridge diagnostics are opt-in only: `PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1` writes typed, allowlisted, scrubbed single-line JSONL records to `process.stderr` with prefix `[pi-cursor-sdk:bridge]`. Diagnostics are scrubbed operational logs, not anonymous telemetry. They intentionally include tool names, safe correlation IDs, run lifecycle, exposed pi↔MCP name pairs, queued requests, result resolution, rejection, cancellation, and pending counts. Correlation IDs are generated independently from the tokenized endpoint path, and Cursor MCP call IDs are hashed before serialization. Diagnostics must not include endpoint paths/URLs/path components/tokens, API keys, bearer tokens, cookies, session credentials, raw args/results, stdout/stderr payloads, file contents, Cursor settings output, or local private session paths in tracked docs, and they must not call pi UI status, notification, or footer APIs. If tool names themselves are unacceptable for a release target, bridge debug diagnostics are not safe for shared logs under the current contract.
|
|
29
|
+
- This repo does not provide a generic desktop-automation, browser-driver, or CDP recipe. Provider docs should describe pi-cursor-sdk's Cursor provider/bridge contract only.
|
|
30
|
+
- Cursor internal tool activity is recorded from SDK events and scrubbed. In interactive TTY sessions, supported completed `read`, `bash`, `grep`, `find`, `ls`, `edit`, `write`, diagnostics, delete, todo/plan, task, image generation, and MCP activity is replayed through pi's native tool-call rendering path with recorded Cursor results, so the TUI can show native-looking cards without rerunning Cursor's reads/shell commands/file edits. Cursor `glob` activity is replayed through native `find` cards. Cursor write activity is replayed through native-looking `write` cards, and Cursor StrReplace/edit activity uses native-looking `edit` only when recorded arguments truthfully satisfy pi's `edit` schema; path-only Cursor edit and notebook edit replay falls back to neutral Cursor activity before pi validation. Diagnostics, delete, todos/plans, task, image, and MCP activity use neutral Cursor activity cards with pi's default success/error shell. Neutral Cursor activity calls include `activityTitle` and, when available, `activitySummary` so partial/collapsed cards preserve identity such as `Cursor plan`, `Cursor todos`, `Cursor MCP`, or `Cursor edit`. Replay-only tools display recorded Cursor results, normalize workspace-local paths/diff headers for display, use pi diff colors for edit previews and path-inferred syntax highlighting for write previews, and fail closed if called without a recorded result. Native replay wrappers are registered only for tool names not already owned by another extension; conflicting tools use the bounded scrubbed transcript fallback. Cursor workflow tools such as `SwitchMode` and Cursor todo state are not pi workflow controls; reported todo/plan events are displayed as Cursor activity only. Plan/todo replay cards can be followed by Cursor's final plan text, selected from `run.wait().result` when Cursor provides one and trimmed against already-emitted text. Started Cursor SDK tool calls that never receive a completion event are discarded without synthetic replay errors; explicit failures remain visible when Cursor reports them through completed tool calls or step results. `PI_CURSOR_NATIVE_TOOL_DISPLAY=0` disables native replay, and `PI_CURSOR_REGISTER_NATIVE_TOOLS=0` is a registration-only opt-out that keeps the transcript fallback without shadowing pi tool names. When bridge or native replay cards are emitted, the provider mirrors Codex's turn shape as Cursor SDK activity arrives: assistant `toolUse`, pi `toolResult`s, live post-tool Cursor thinking/text, any later tool batches as further `toolUse` turns, then Cursor's final assistant answer. For shell replay, completed `stdout` / `stderr` are primary; unambiguous `shell-output-delta` data is used only as display-only fallback for empty successful shell completions, and overlapping shell calls drop ambiguous deltas instead of guessing. Non-interactive runs keep bounded scrubbed transcript output instead, preserving `pi -p` assistant text output. Cursor text deltas stream live when no live-run turn split is active.
|
|
31
|
+
- Synthetic replay names are internal compatibility details. New model-facing prompt text and user-visible cards use native tool names when renderer-compatible, or neutral Cursor activity labels when not. Legacy sessions containing old internal replay names are sanitized before prompt/display. Bridge MCP names such as `pi__sem_reindex` are MCP-only; pi session output uses real pi tool names.
|
|
32
|
+
- Cursor SDK usage events report cumulative internal agent/tool/cache work, not the replayable pi prompt context. The extension does not copy raw Cursor SDK usage into pi usage or compaction. For Cursor assistant messages, `usage.input`/`usage.output` are approximate pi session activity components: initial Cursor prompt input is counted once, consumed split-run tool results are counted as deduped input on the following assistant turn, and assistant output includes visible text/thinking/tool-call content. `usage.totalTokens` is the replayable Cursor prompt/context estimate derived from the same `buildCursorPrompt()` path used for `Agent.send`; it may differ from `input + output` and is the context-safe value for display/compaction. `src/cursor-usage-accounting.ts` owns this usage policy, and `src/cursor-live-run-accounting.ts` owns prompt-once and consumed-tool-result accounting so provider usage and bridge result resolution share the same matched tool-result boundary.
|
|
33
|
+
- Audit observation, 2026-05-19, superseded by the 2026-05-21 replay pass: a missing-file read with Composer 2.5 emitted `tool-call-started` for Cursor `read`, then streamed final text `Error: File not found`, but did not emit `tool-call-completed` or an `onStep` `toolCall` error result. Leftover started calls are now discarded at run completion instead of becoming synthetic replay errors. Cursor-reported completed/step errors remain visible.
|
|
34
|
+
- Maintainer visual verification for replay-card changes should follow [Cursor Native Tool Visual Audit Workflow](./cursor-native-tool-visual-audit.md): offscreen PTY-driven pi run, xterm.js/Playwright screenshot rendering, and JSONL inspection before accepting commits or PRs.
|
|
35
|
+
- Cursor provider/runtime releases should follow [Cursor Live Smoke Checklist](./cursor-live-smoke-checklist.md) with real `pi -e . --cursor-no-fast --model cursor/composer-2.5` invocations, manual observation, temporary session dirs, diagnostics scans, and persisted JSONL inspection. Assume every runtime surface is in scope. A release is not ready when any live check is optional, deferred, mostly passing, or unobserved.
|
|
23
36
|
- For models without a catalog `context` parameter, context windows are not hardcoded. The extension ships a bundled SDK-derived default/non-Max cache generated from `createAgentPlatform().checkpointStore.loadLatest(agentId).tokenDetails.maxTokens`. Successful runs can update a local override cache, but model discovery does not probe models at startup.
|
|
24
37
|
- Max Mode context windows are distinct from default/non-Max context windows. `@cursor/sdk` 1.0.13 documentation says the SDK may enable Max Mode automatically when a selected model requires it, but the public local-agent `ModelSelection` path still does not expose a manual Max Mode selector. Do not advertise Max Mode context windows unless the SDK catalog exposes an exact parameter/variant or the SDK public API adds a Max Mode selector that the extension actually sends.
|
|
25
38
|
- `@cursor/sdk` 1.0.13 adds latest-style `ModelListItem.aliases`. The extension registers only unambiguous aliases as pi model IDs (with the same context suffixes when applicable) and sends the alias back in `ModelSelection.id`, while sharing Cursor-only state such as fast defaults with the underlying catalog `id`. Aliases shared by multiple base models, such as generic family aliases, are skipped because the pi row metadata would otherwise imply one base model while Cursor may resolve the alias to another.
|
|
39
|
+
- Session-scoped Cursor SDK agent pooling reuses one live `@cursor/sdk` agent across compatible follow-up turns within the same pi session scope. `computeCursorContextFingerprint()` and `shouldBootstrapCursorSend()` decide whether the next turn sends a full bootstrap prompt or an incremental follow-up. The pool recreates the agent when context diverges, when branch or compaction summaries appear after `/tree` navigation or compaction, when the API key identity changes, after send errors, on `session_shutdown`, and when `session_before_tree` / `session_tree` invalidate the active branch. Incremental sends omit the full Cursor SDK tool boundary block because the session agent retains prior bootstrap context.
|
|
26
40
|
|
|
27
41
|
## Goal
|
|
28
42
|
|
|
@@ -236,7 +250,7 @@ Important distinction:
|
|
|
236
250
|
|
|
237
251
|
- **Cursor thinking support** applies to all Cursor SDK models. The extension should assume Cursor models can think and may emit thinking deltas.
|
|
238
252
|
- **Pi-controllable thinking** means Cursor exposes a `reasoning`, `effort`, or `thinking` parameter that the extension can set from pi's native thinking level. These models register `reasoning: true` and show `thinking=yes` in `pi --list-models`.
|
|
239
|
-
- **Cursor SDK thinking-control gap** means the model can still think, but the SDK does not expose a user-controllable thinking parameter for that model. These models register `reasoning: false` and show `thinking=no` in `pi --list-models` because pi cannot control a level for them. The extension still
|
|
253
|
+
- **Cursor SDK thinking-control gap** means the model can still think, but the SDK does not expose a user-controllable thinking parameter for that model. These models register `reasoning: false` and show `thinking=no` in `pi --list-models` because pi cannot control a level for them. The extension still surfaces Cursor `thinking-delta` and summary events through pi's native thinking rendering when they are emitted.
|
|
240
254
|
|
|
241
255
|
Do not mark a model `reasoning: true` only because it can think. That would make pi show controls such as `--thinking`, `:medium`, and shift+tab even though the extension cannot translate them into Cursor SDK params.
|
|
242
256
|
|
|
@@ -655,3 +669,12 @@ Before calling done:
|
|
|
655
669
|
- `pi --model cursor/gpt-5.5@272k --thinking xhigh -p "Say ok only"`
|
|
656
670
|
- `pi --model cursor/gpt-5.5@1m --cursor-fast -p "Say ok only"`
|
|
657
671
|
- confirm requests use selected context, pi thinking, and fast flag state
|
|
672
|
+
|
|
673
|
+
4. Tool bridge and replay:
|
|
674
|
+
- `npm test -- test/cursor-pi-tool-bridge.test.ts test/cursor-provider.test.ts test/cursor-mcp-timeout-override.test.ts`
|
|
675
|
+
- confirm `Agent.create()` gets `mcpServers.pi_tools` when active pi tools exist and omits it when `PI_CURSOR_PI_TOOL_BRIDGE=0` or the active snapshot is empty
|
|
676
|
+
- confirm bridged MCP requests emit real pi tool calls and resolve matching pi tool results back to the same live Cursor SDK run without creating a new `Agent`, unless the run was disposed, aborted, or cancelled
|
|
677
|
+
- confirm bridge MCP activity is suppressed from Cursor replay while non-bridge Cursor MCP activity remains visible
|
|
678
|
+
- confirm `PI_CURSOR_MCP_TOOL_TIMEOUT_MS` and `PI_CURSOR_MCP_TOOL_TIMEOUT_SECONDS` override the Cursor SDK MCP callTool timeout seam
|
|
679
|
+
- confirm `PI_CURSOR_PI_TOOL_BRIDGE_DEBUG=1` emits typed, allowlisted, scrubbed JSONL to `process.stderr` with prefix `[pi-cursor-sdk:bridge]`, omits endpoint URLs/path components/tokens, and unset/false leaves output unchanged
|
|
680
|
+
- run the visual audit workflow when replay card visuals or bridge card visuals change; JSONL should show real pi tool names for bridged calls and no duplicate MCP replay for bridge calls
|