Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/adapter-sdk/src/server-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export async function ensureCommandResolvable(command: string, cwd: string, env:
return;
}

const pathValue = env.PATH ?? env.Path ?? "";
const pathValue =
env.PATH ?? env.Path ?? process.env.PATH ?? process.env.Path ?? "";
const delimiter = process.platform === "win32" ? ";" : ":";
const dirs = pathValue.split(delimiter).filter(Boolean);
const windowsExt = process.platform === "win32"
Expand Down Expand Up @@ -223,7 +224,7 @@ export async function runChildProcess(
const child = spawn(command, args, {
cwd: opts.cwd,
env: mergedEnv,
shell: false,
shell: process.platform === "win32",
stdio: [opts.stdin != null ? "pipe" : "ignore", "pipe", "pipe"],
}) as ChildProcessWithEvents;

Expand Down
22 changes: 17 additions & 5 deletions server/src/__tests__/cursor-local-adapter-environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
} from "./_helpers/adapter-test-harness.js";

async function writeFakeAgentCommand(binDir: string): Promise<string> {
const commandPath = path.join(binDir, "agent");
const script = `#!/usr/bin/env node
const isWindows = process.platform === "win32";

const jsPath = path.join(binDir, "agent.js");
const jsScript = `
const fs = require("node:fs");
const outPath = process.env.GITMESH_TEST_ARGS_PATH;
if (outPath) {
Expand All @@ -27,9 +29,19 @@ console.log(JSON.stringify({
result: "hello",
}));
`;
await fs.writeFile(commandPath, script, "utf8");
await fs.chmod(commandPath, 0o755);
return commandPath;
await fs.writeFile(jsPath, jsScript, "utf8");

if (isWindows) {
// On Windows, create agent.cmd that delegates to agent.js
const cmdPath = path.join(binDir, "agent.cmd");
await fs.writeFile(cmdPath, `@echo off\nnode "%~dp0agent.js" %*\n`, "utf8");
return cmdPath;
} else {
const commandPath = path.join(binDir, "agent");
await fs.writeFile(commandPath, `#!/usr/bin/env node\n` + jsScript, "utf8");
await fs.chmod(commandPath, 0o755);
return commandPath;
}
}

interface CursorEnvCtx {
Expand Down
Loading