cursor-delegate-mcp 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,53 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.10.0] - 2026-11-22
10
+
11
+ ### Changed
12
+
13
+ - On Windows, `cursor-agent` starts without cmd.exe. `cursor-agent.cmd` (and its copy `agent.cmd`)
14
+ only forwards to `cursor-agent.ps1`, which the bridge now runs through `powershell.exe -File`, so
15
+ `!`, `%VAR%`, `^` and quotes in `ACP_AGENT_ARGS` reach the agent unchanged.
16
+
17
+ ### Fixed
18
+
19
+ - Progress lines and stall errors name the command or path of the last tool call, which
20
+ cursor-agent sends on the `tool_call_update`, capped at 200 characters.
21
+ - Windows launch:
22
+ - A launcher path or `ACP_AGENT_ARGS` argument with spaces arrives whole, including a quoted
23
+ section inside an argument (`--log-file="C:\a b\x.log"`).
24
+ - A `.ps1` `ACP_AGENT_COMMAND` runs through PowerShell instead of opening with its file
25
+ association.
26
+ - A Store app execution alias on `PATH`, such as `pwsh`, is found.
27
+ - Node 24 prints no DEP0190 deprecation warning.
28
+ - `doctor` reports the agent's version for a launcher prefix such as `node index.js acp`, and for a
29
+ `.ps1` launcher.
30
+ - `doctor` stops its version probe and handshake when the host aborts and returns once they have
31
+ exited. A server shutdown stops them too.
32
+ - `cancel`:
33
+ - a cancel during session setup keeps the prompt from being sent;
34
+ - `force` kills only the turns running when it arrived, not a resume that started during its
35
+ grace;
36
+ - a blank `sessionId` is rejected, and surrounding whitespace is trimmed.
37
+ - On SIGHUP (a closed terminal) the server stops its agents before exiting. The stdin close that
38
+ follows a hangup does not cut that wait short.
39
+ - The SessionStart hook sends npm's output to stderr, keeping the install summary out of the
40
+ session context.
41
+
42
+ ### Internal
43
+
44
+ - Lockfile: hono 4.13.18.
45
+
46
+ ## [2.9.0] - 2026-11-22
47
+
48
+ ### Fixed
49
+
50
+ - A missing cursor-agent on Windows is reported as `spawn-failed` with the install hint, and
51
+ `doctor` reports `found: false`. Launched through cmd.exe it read as `agent-exit` quoting cmd's
52
+ "is not recognized" line, and `doctor` reported `found: true`.
53
+ - `cancel` with `force` returns as soon as the turn settles, in about 60 ms, instead of waiting out
54
+ its 5 s grace.
55
+
9
56
  ## [2.8.0] - 2026-11-08
10
57
 
11
58
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "mcpName": "io.github.andreilungeanu/cursor-delegate-mcp",
5
5
  "type": "module",
6
6
  "description": "Delegate multi-file coding work from Claude Code, Codex, Copilot, or any MCP client to Cursor's CLI agent — structured results, plan mode, and changed files.",
package/src/acp-client.js CHANGED
@@ -3,14 +3,14 @@ import { EventEmitter } from "node:events";
3
3
  import { StringDecoder } from "node:string_decoder";
4
4
  import { JsonRpcPeer } from "./jsonrpc.js";
5
5
  import { createRequestRouter } from "./request-router.js";
6
- import { resolveAcpSpawn } from "./spawn.js";
6
+ import { commandExists, resolveAcpSpawn, spawnArgv } from "./spawn.js";
7
7
  import { DETACHED, isChildAlive, treeKill } from "./proc.js";
8
8
  import { VERSION } from "./version.js";
9
9
  import { makeError } from "./errors.js";
10
10
 
11
11
  const STDERR_CAP = 64 * 1024;
12
- // How long stop() waits for the child to actually exit after the kill is dispatched. SIGKILL and
13
- // taskkill /F land in milliseconds, so this only ever elapses when the kill did not work.
12
+ // How long stop() waits for the exit after the kill. SIGKILL and taskkill /F land in milliseconds,
13
+ // so this elapses only when the kill failed.
14
14
  const STOP_EXIT_TIMEOUT_MS = 2000;
15
15
 
16
16
  export class AcpClient extends EventEmitter {
@@ -34,12 +34,9 @@ export class AcpClient extends EventEmitter {
34
34
  this._stopping = null;
35
35
  }
36
36
 
37
- // stderr is captured but does not count as activity: the supervisor measures ACP frames, and
38
- // an agent writing diagnostics is not the same fact as a turn making progress.
39
- // The tail of stderr, which is what an exit error quotes. Kept as chunks and joined on read:
40
- // rebuilding a 64KB string per chunk was the whole cost of a noisy agent. A StringDecoder
41
- // holds partial UTF-8 across chunk boundaries, so a multi-byte character split by the pipe
42
- // does not land in the error message as a replacement char.
37
+ // The stderr tail an exit error quotes. Kept as chunks and joined on read, so a noisy agent costs
38
+ // a push per chunk; a StringDecoder keeps a multi-byte character split across reads intact.
39
+ // stderr is not ACP activity, so it does not feed the supervisor.
43
40
  get stderrBuffer() {
44
41
  const joined = this._stderrChunks.join("");
45
42
  return joined.length > STDERR_CAP ? joined.slice(-STDERR_CAP) : joined;
@@ -47,11 +44,16 @@ export class AcpClient extends EventEmitter {
47
44
 
48
45
  start() {
49
46
  const { command, args, options } = this.spawnSpec;
47
+ const opts = /** @type {{ shell?: boolean, env?: NodeJS.ProcessEnv }} */ (options);
48
+ if (opts?.shell && !commandExists(command, opts.env)) {
49
+ return Promise.reject(makeError("spawn-failed", `Failed to spawn agent (${command}): not found on PATH. Install Cursor CLI and run 'cursor-agent login'.`));
50
+ }
50
51
  this._stderrChunks = [];
51
52
  this._stderrLength = 0;
52
53
  const stderrDecoder = new StringDecoder("utf8");
53
54
  this._exitEmitted = false;
54
- this.child = spawn(command, args, { ...options, detached: DETACHED, stdio: ["pipe", "pipe", "pipe"] });
55
+ const argv = spawnArgv(command, args, opts);
56
+ this.child = spawn(argv.command, argv.args, { ...argv.options, detached: DETACHED, stdio: ["pipe", "pipe", "pipe"] });
55
57
  this.child.stderr.on("data", (chunk) => {
56
58
  const text = stderrDecoder.write(chunk);
57
59
  if (text) {
@@ -62,9 +64,8 @@ export class AcpClient extends EventEmitter {
62
64
  while (this._stderrChunks.length > 1 && this._stderrLength - this._stderrChunks[0].length >= STDERR_CAP) {
63
65
  this._stderrLength -= this._stderrChunks.shift().length;
64
66
  }
65
- // Whole-chunk drops leave a remainder when one pipe read is itself larger than the cap
66
- // (observed on GitHub Windows runners). Slice that first chunk so retained memory cannot
67
- // grow with the flood; the public tail is still exactly one cap on read.
67
+ // A single read larger than the cap (seen on GitHub Windows runners) is sliced too, so
68
+ // retained memory stays bounded.
68
69
  const overflow = this._stderrLength - STDERR_CAP;
69
70
  if (overflow > 0) {
70
71
  this._stderrChunks[0] = this._stderrChunks[0].slice(overflow);
@@ -73,9 +74,8 @@ export class AcpClient extends EventEmitter {
73
74
  }
74
75
  });
75
76
  this.child.stderr.on("error", () => {});
76
- // A supervisor trip writes session/cancel, which can land after the agent is already gone.
77
- // Without a handler that surfaces as an unhandled 'error' event on some platforms, taking
78
- // the whole MCP server down with it. stdout needs the same guard; readline adds none.
77
+ // session/cancel can be written after the agent is gone, and an unhandled pipe 'error' would
78
+ // take down the server. readline adds no handler on stdout either.
79
79
  this.child.stdin.on("error", () => {});
80
80
  this.child.stdout.on("error", () => {});
81
81
  const emitExit = (code, signal) => {
@@ -84,9 +84,8 @@ export class AcpClient extends EventEmitter {
84
84
  const stderr = this.stderrBuffer;
85
85
  const err = makeError(
86
86
  "agent-exit",
87
- // stderr kept whole. This is the one string that says why the agent died — the model
88
- // that was rejected, the quota that ran out, the login that expired — and the part that
89
- // names it can sit anywhere in it. The 64KB ring buffer above is the bound.
87
+ // stderr whole, bounded by the 64KB buffer: why the agent died (a rejected model, a spent
88
+ // quota, an expired login) can sit anywhere in it.
90
89
  `agent exited (code=${code}${signal ? ", signal=" + signal : ""})${stderr ? ": " + String(stderr) : ""}`
91
90
  );
92
91
  // exit + rejectAllPending both settle the same Promise.race; second rejection is intentional.
@@ -120,8 +119,6 @@ export class AcpClient extends EventEmitter {
120
119
  });
121
120
  return /** @type {Promise<void>} */ (new Promise((resolve, reject) => {
122
121
  this.child.once("error", (e) => {
123
- // Tagged like every other failure class so the caller gets
124
- // "delegate failed [spawn-failed]: ..." instead of the one untagged prose error.
125
122
  const err = makeError("spawn-failed", `Failed to spawn agent (${command}): ${e.message}. Install Cursor CLI and run 'cursor-agent login'.`);
126
123
  reject(err);
127
124
  });
@@ -129,8 +126,7 @@ export class AcpClient extends EventEmitter {
129
126
  }));
130
127
  }
131
128
 
132
- // Stashed so the unknown-model pre-flight and doctor --deep can read the agent's real
133
- // capability and model lists without paying for a second handshake.
129
+ // Stashed for the unknown-model check and doctor deep, so neither needs a second handshake.
134
130
  async initialize() {
135
131
  const res = await this.peer.request("initialize", { protocolVersion: 1, clientInfo: { name: "cursor-delegate-mcp", version: VERSION }, clientCapabilities: { _meta: { parameterizedModelPicker: true } } });
136
132
  this.protocolVersion = res?.protocolVersion;
@@ -149,7 +145,12 @@ export class AcpClient extends EventEmitter {
149
145
  setConfigOption(sessionId, configId, value) { return this.peer.request("session/set_config_option", { sessionId, configId, value: String(value) }); } // configId, not optionId; ACP wants a string value
150
146
  setMode(sessionId, modeId) { return this.peer.request("session/set_mode", { sessionId, modeId }); }
151
147
  prompt(sessionId, blocks) { return this.peer.request("session/prompt", { sessionId, prompt: blocks }); }
152
- cancel(sessionId) { this.peer.notify("session/cancel", { sessionId }); return Promise.resolve(); }
148
+ cancel(sessionId) {
149
+ // Recorded so runDelegate can hold back a prompt not yet sent.
150
+ this.cancelRequested = true;
151
+ this.peer.notify("session/cancel", { sessionId });
152
+ return Promise.resolve();
153
+ }
153
154
 
154
155
  getTranscript(n) { return this.peer ? this.peer.formatLog(n) : ""; }
155
156
 
@@ -175,8 +176,7 @@ export class AcpClient extends EventEmitter {
175
176
  return true;
176
177
  }
177
178
  const alive = isChildAlive(child);
178
- // Subscribed before the kill is dispatched. A child that dies immediately would otherwise
179
- // exit in the gap and leave this waiting on an event that has already fired.
179
+ // Subscribed before the kill, so an instant exit is not missed.
180
180
  const exited = alive
181
181
  ? /** @type {Promise<boolean>} */ (new Promise((resolve) => child.once("exit", () => resolve(true))))
182
182
  : Promise.resolve(true);
@@ -190,10 +190,8 @@ export class AcpClient extends EventEmitter {
190
190
  }));
191
191
  const observed = await Promise.race([exited, bounded]);
192
192
  clearTimeout(timer);
193
- // The exit handler rejects in-flight RPCs with stderr. Doing that here on a confirmed
194
- // exit would race it and the first settlement would drop the forensics. A stop that
195
- // did not see the child die never gets that handler, so settle those RPCs only when
196
- // the process is still alive and emitExit has not run.
193
+ // On an observed exit, emitExit rejects in-flight RPCs with stderr, and racing it here would
194
+ // drop that. Only a child still alive after the stop has its RPCs settled here.
197
195
  if (!observed && !this._exitEmitted && isChildAlive(child)) {
198
196
  try {
199
197
  this.peer?.rejectAllPending(makeError("agent-exit", "agent process did not exit after stop"));
package/src/acp-enums.js CHANGED
@@ -1,11 +1,6 @@
1
- // The value sets ACP allows for plan and todo fields, shared by the two layers that read them:
2
- // the sanitizers in delegate.js, which strip anything else off an agent frame, and the zod
3
- // schemas in server.js, which advertise them to hosts. A drift between the two would strip a
4
- // value the tool documents, or document one it strips.
5
- //
6
- // Plan status follows ACP v1 PlanEntryStatus (no cancelled). Todo status follows Cursor's
7
- // update_todos / create_plan todo arrays, which include cancelled. They stay separate
8
- // constants so they can diverge.
1
+ // Allowed plan and todo values, shared by delegate.js's sanitizers and server.js's schemas so the
2
+ // two cannot drift. Plan status follows ACP v1 PlanEntryStatus (no cancelled); todo status follows
3
+ // Cursor's update_todos and create_plan arrays, which include cancelled.
9
4
 
10
5
  export const PLAN_PRIORITIES = /** @type {const} */ (["high", "medium", "low"]);
11
6