cursor-delegate-mcp 2.0.0 → 2.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 CHANGED
@@ -6,6 +6,31 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.1.1] - 2026-09-03
10
+
11
+ ### Fixed
12
+
13
+ - Transitive `fast-uri` and `qs` advisories that failed `npm audit --audit-level=high`.
14
+ - Stderr capture slices an oversized first pipe read so retained memory stays one cap.
15
+
16
+ ## [2.1.0] - 2026-09-03
17
+
18
+ ### Fixed
19
+
20
+ - `cancel` with `force: true` can be retried after a kill that did not observe an exit. `stop()`
21
+ no longer memoizes that `false`, which had made every later force a no-op.
22
+ - Force-kill unregisters only the handles it actually stopped, so a resume that registers during
23
+ teardown stays cancellable instead of running untracked.
24
+ - Todo `cancelled` is kept and counted in `todoProgress.cancelled` instead of being stripped.
25
+ - `contextFiles` aliases (Win32 case, `realpath`) are sent once.
26
+ - `doctor` reports `agent.error` when `--version` exits non-zero, probes `.mjs`/`.cjs` launchers
27
+ with Node, quotes the resolved command, and includes launcher/timeout env knobs.
28
+
29
+ ### Changed
30
+
31
+ - Permission notes in `TECHNICAL.md` match the router: no allow option → `cancelled`, never the
32
+ first offered reject.
33
+
9
34
  ## [2.0.0] - 2026-08-21
10
35
 
11
36
  One thing changes on upgrade: pass `workspace` on every call, resumes included.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Cursor Delegate is the MCP bridge that lets Claude Code, ChatGPT/Codex, Copilot
20
20
 
21
21
  <br clear="left">
22
22
 
23
- ![Demo](demo.gif)
23
+ ![Demo](assets/demo.gif)
24
24
 
25
25
  ## 🧠 Frontier quality, kept
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursor-delegate-mcp",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
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, or Copilot to Cursor's CLI agent — structured results, plan mode, and changed files.",
package/src/acp-client.js CHANGED
@@ -62,6 +62,14 @@ export class AcpClient extends EventEmitter {
62
62
  while (this._stderrChunks.length > 1 && this._stderrLength - this._stderrChunks[0].length >= STDERR_CAP) {
63
63
  this._stderrLength -= this._stderrChunks.shift().length;
64
64
  }
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.
68
+ const overflow = this._stderrLength - STDERR_CAP;
69
+ if (overflow > 0) {
70
+ this._stderrChunks[0] = this._stderrChunks[0].slice(overflow);
71
+ this._stderrLength -= overflow;
72
+ }
65
73
  }
66
74
  });
67
75
  this.child.stderr.on("error", () => {});
@@ -140,12 +148,22 @@ export class AcpClient extends EventEmitter {
140
148
 
141
149
  getTranscript(n) { return this.peer ? this.peer.formatLog(n) : ""; }
142
150
 
143
- // Idempotent, so a force-cancel racing the delegation's own finally tears down once and both
144
- // see the same answer. Resolves true when the child was observed to exit, false when the bound
145
- // elapsed first: dispatching a signal is not the same fact as the process being gone, and
146
- // cancel reports the difference rather than calling both "killed".
151
+ // Idempotent while a teardown is in flight and after a confirmed exit, so a force-cancel
152
+ // racing the delegation's own finally tears down once. A missed exit is not the same
153
+ // fact as the process being gone: that result is not memoized, and force can retry.
147
154
  stop({ timeoutMs = STOP_EXIT_TIMEOUT_MS } = {}) {
148
- if (!this._stopping) this._stopping = this._teardown(timeoutMs);
155
+ if (!this._stopping) {
156
+ this._stopping = this._teardown(timeoutMs).then((observed) => {
157
+ // A missed exit must not poison later force-kills: the documented retry is a new
158
+ // treeKill, not the same false. A confirmed exit stays memoized so concurrent and
159
+ // later callers still join one teardown.
160
+ if (!observed) this._stopping = null;
161
+ return observed;
162
+ }, (err) => {
163
+ this._stopping = null;
164
+ throw err;
165
+ });
166
+ }
149
167
  return this._stopping;
150
168
  }
151
169
 
package/src/acp-enums.js CHANGED
@@ -3,11 +3,12 @@
3
3
  // schemas in server.js, which advertise them to hosts. A drift between the two would strip a
4
4
  // value the tool documents, or document one it strips.
5
5
  //
6
- // Plan status and todo status carry the same three values today but stay separate constants:
7
- // ACP treats them as separate enums and they are free to diverge.
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.
8
9
 
9
10
  export const PLAN_PRIORITIES = /** @type {const} */ (["high", "medium", "low"]);
10
11
 
11
12
  export const PLAN_STATUSES = /** @type {const} */ (["pending", "in_progress", "completed"]);
12
13
 
13
- export const TODO_STATUSES = /** @type {const} */ (["pending", "in_progress", "completed"]);
14
+ export const TODO_STATUSES = /** @type {const} */ (["pending", "in_progress", "completed", "cancelled"]);
package/src/delegate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  import path from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
- import { statSync } from "node:fs";
4
+ import { statSync, realpathSync } from "node:fs";
5
5
  // Async: a sync read on the server's only thread stalls every other in-flight delegation and
6
6
  // its progress stream. The statSync calls below stay sync — they are argument validation and
7
7
  // run before the spawn.
@@ -87,14 +87,26 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
87
87
  // per-entry — they are individually distinct and never arrive in bulk.
88
88
  const notFound = [];
89
89
  const root = path.resolve(workspace || process.cwd());
90
+ const identKey = (p) => (process.platform === "win32" ? p.toLowerCase() : p);
90
91
  for (const entry of contextFiles || []) {
91
92
  if (typeof entry !== "string" || !entry.trim()) continue;
92
93
  const abs = path.resolve(workspace || process.cwd(), entry);
93
- if (seen.has(abs)) continue;
94
- seen.add(abs);
94
+ let canonical;
95
+ try {
96
+ canonical = realpathSync(abs);
97
+ } catch {
98
+ const missKey = identKey(abs);
99
+ if (seen.has(missKey)) continue;
100
+ seen.add(missKey);
101
+ notFound.push(entry);
102
+ continue;
103
+ }
104
+ const key = identKey(canonical);
105
+ if (seen.has(key)) continue;
106
+ seen.add(key);
95
107
  let stat;
96
108
  try {
97
- stat = statSync(abs);
109
+ stat = statSync(canonical);
98
110
  } catch {
99
111
  notFound.push(entry);
100
112
  continue;
@@ -103,7 +115,7 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
103
115
  warnings.push(`contextFile ${entry} skipped: not a file`);
104
116
  continue;
105
117
  }
106
- const mimeType = IMAGE_MIME[path.extname(abs).toLowerCase()];
118
+ const mimeType = IMAGE_MIME[path.extname(canonical).toLowerCase()];
107
119
  if (mimeType) {
108
120
  if (!client?.agentCapabilities?.promptCapabilities?.image) {
109
121
  warnings.push(`contextFile ${entry} skipped: this agent does not accept image prompts`);
@@ -113,10 +125,10 @@ async function buildContextBlocks(contextFiles, workspace, client, warnings) {
113
125
  warnings.push(`contextFile ${entry} skipped: ${Math.round(stat.size / 1024)}KB exceeds the ${MAX_IMAGE_BYTES / 1024 / 1024}MB image limit`);
114
126
  continue;
115
127
  }
116
- blocks.push({ type: "image", mimeType, data: (await readFile(abs)).toString("base64") });
128
+ blocks.push({ type: "image", mimeType, data: (await readFile(canonical)).toString("base64") });
117
129
  continue;
118
130
  }
119
- blocks.push({ type: "resource_link", uri: pathToFileURL(abs).href, name: path.basename(abs) });
131
+ blocks.push({ type: "resource_link", uri: pathToFileURL(canonical).href, name: path.basename(canonical) });
120
132
  }
121
133
  if (notFound.length) {
122
134
  warnings.push(
@@ -331,6 +343,7 @@ export async function runDelegate({
331
343
  completed: count("completed"),
332
344
  inProgress: count("in_progress"),
333
345
  pending: count("pending"),
346
+ cancelled: count("cancelled"),
334
347
  },
335
348
  };
336
349
  };
package/src/doctor.js CHANGED
@@ -11,8 +11,24 @@ const VERSION_PROBE_TIMEOUT_MS = 10_000;
11
11
  const PROBE_STDOUT_CAP = 64 * 1024;
12
12
  const DEFAULT_LOG_SIZE = "2000";
13
13
 
14
+ function formatArg(value) {
15
+ const s = String(value);
16
+ if (!/[\s"]/.test(s)) return s;
17
+ return `"${s.replace(/"/g, '\\"')}"`;
18
+ }
19
+
14
20
  function formatCommand({ command, args }) {
15
- return args?.length ? `${command} ${args.join(" ")}` : command;
21
+ const bits = [formatArg(command), ...(args || []).map(formatArg)];
22
+ return args?.length ? bits.join(" ") : formatArg(command);
23
+ }
24
+
25
+ function isJsLauncher(command) {
26
+ const trimmed = String(command || "").replace(/^["']|["']$/g, "");
27
+ return /\.(?:cjs|mjs|js)$/i.test(trimmed);
28
+ }
29
+
30
+ function envReport(name, fallback = null) {
31
+ return process.env[name] !== undefined ? process.env[name] : fallback;
16
32
  }
17
33
 
18
34
  // Time-boxed because a launcher that accepts --version and then never answers would hang doctor
@@ -20,9 +36,10 @@ function formatCommand({ command, args }) {
20
36
  // exactly the case it must survive. Same guard the deep handshake has.
21
37
  export function probeAgentVersion(spawnSpec, timeoutMs = VERSION_PROBE_TIMEOUT_MS) {
22
38
  const { command, options } = spawnSpec;
23
- const isJsScript = /\.js$/i.test(command);
39
+ const launcher = String(command || "").replace(/^["']|["']$/g, "");
40
+ const isJsScript = isJsLauncher(launcher);
24
41
  const execCommand = isJsScript ? process.execPath : command;
25
- const execArgs = isJsScript ? [command, "--version"] : ["--version"];
42
+ const execArgs = isJsScript ? [launcher, "--version"] : ["--version"];
26
43
  return new Promise((resolve) => {
27
44
  let settled = false;
28
45
  let stdout = "";
@@ -46,9 +63,11 @@ export function probeAgentVersion(spawnSpec, timeoutMs = VERSION_PROBE_TIMEOUT_M
46
63
  child.stderr?.on("error", () => {});
47
64
  child.on("error", () => finish({ found: false, version: null }));
48
65
  child.on("close", (code) => {
66
+ const version = code === 0 ? stdout.trim() || null : null;
49
67
  finish({
50
68
  found: true,
51
- version: code === 0 ? stdout.trim() || null : null,
69
+ version,
70
+ ...(code !== 0 ? { error: `version probe exited ${code}` } : {}),
52
71
  });
53
72
  });
54
73
  timer = setTimeout(() => {
@@ -152,8 +171,13 @@ export async function runDoctor({
152
171
  transport: "stdio",
153
172
  },
154
173
  env: {
155
- ACP_LOG_SIZE: process.env.ACP_LOG_SIZE !== undefined ? process.env.ACP_LOG_SIZE : DEFAULT_LOG_SIZE,
156
- CURSOR_DELEGATE_TRANSCRIPT: process.env.CURSOR_DELEGATE_TRANSCRIPT ?? null,
174
+ ACP_LOG_SIZE: envReport("ACP_LOG_SIZE", DEFAULT_LOG_SIZE),
175
+ ACP_AGENT_COMMAND: envReport("ACP_AGENT_COMMAND"),
176
+ ACP_AGENT_ARGS: envReport("ACP_AGENT_ARGS"),
177
+ CURSOR_DELEGATE_TRANSCRIPT: envReport("CURSOR_DELEGATE_TRANSCRIPT"),
178
+ CURSOR_DELEGATE_HANDSHAKE_MS: envReport("CURSOR_DELEGATE_HANDSHAKE_MS"),
179
+ CURSOR_DELEGATE_HARD_CAP_MS: envReport("CURSOR_DELEGATE_HARD_CAP_MS"),
180
+ CURSOR_DELEGATE_IDLE_MS: envReport("CURSOR_DELEGATE_IDLE_MS"),
157
181
  },
158
182
  };
159
183
 
package/src/server.js CHANGED
@@ -104,6 +104,7 @@ export const delegateOutputShape = {
104
104
  completed: z.number(),
105
105
  inProgress: z.number(),
106
106
  pending: z.number(),
107
+ cancelled: z.number(),
107
108
  }).optional(),
108
109
  };
109
110
 
@@ -325,13 +326,17 @@ export function buildServer({ runDelegate: runDelegateInjected, runDoctor: runDo
325
326
  await new Promise((r) => setTimeout(r, forceGraceMs));
326
327
  const stillRunning = inFlight.get(sessionId);
327
328
  if (!stillRunning || stillRunning.size === 0) return cancelResult("cancelled", sessionId);
329
+ // Snapshot before awaiting stop. A resume that registers during teardown must not be
330
+ // swept out of the map — it was never killed, and inFlight.delete(sessionId) would
331
+ // hide it from cancel and shutdown.
332
+ const toKill = [...stillRunning];
328
333
  const observed = await Promise.all(
329
- [...stillRunning].map((handle) => Promise.resolve(handle.client.stop()).catch(() => false))
334
+ toKill.map((handle) => Promise.resolve(handle.client.stop()).catch(() => false))
330
335
  );
331
336
  // "killed" claims the process is gone, so it needs the exit, not just a dispatched signal.
332
337
  // When one does not follow, the handles stay registered and force can be tried again.
333
338
  if (!observed.every(Boolean)) return cancelResult("cancelled", sessionId);
334
- inFlight.delete(sessionId);
339
+ for (const handle of toKill) unregisterInFlight(inFlight, sessionId, handle);
335
340
  return cancelResult("killed", sessionId);
336
341
  }
337
342
  );