Skip to content

fix: support Windows fake cursor execute commands#388

Merged
Parvm1102 merged 4 commits into
LF-Decentralized-Trust-labs:mainfrom
codebysana:fix/cursor-execute-windows
May 30, 2026
Merged

fix: support Windows fake cursor execute commands#388
Parvm1102 merged 4 commits into
LF-Decentralized-Trust-labs:mainfrom
codebysana:fix/cursor-execute-windows

Conversation

@codebysana
Copy link
Copy Markdown
Contributor

@codebysana codebysana commented May 18, 2026

Summary

This PR improves Windows compatibility for the fake Cursor execute command used in tests. It ensures that the spawned command works correctly across different operating systems.


Changes

  • Updated command path handling to be platform-aware
  • On Windows, the fake command now uses a .cmd extension instead of a plain executable name
  • On Unix-based systems, the existing behavior remains unchanged

Why this change is needed

On Windows, Node.js spawn cannot execute a file without a proper extension or executable format. Previously, the fake command was being created without a Windows-compatible extension, leading to execution failures during tests.

cursor-execute-window-error

Impact

  • Fixes Windows-specific command execution issues in cursor execute tests
  • Improves cross-platform consistency of test environment setup
  • Reduces spawn-related failures on Windows machines and CI environments

Notes

This PR only fixes command resolution for Windows.
Additional runtime or spawn execution issues (if any remain) will be handled separately.

Signed-off-by: codebysana <sana.younas0530@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to make the fake Cursor command used by cursor-local-execute tests work on Windows by using a platform-specific command filename and generated script.

Changes:

  • Replaces the fake Cursor Node script with platform-specific .cmd/shell script generation.
  • Makes the first test’s fake command path use agent.cmd on Windows.
  • Updates the helper signature to accept a capture path, though call sites were not updated.
Comments suppressed due to low confidence (1)

server/src/tests/cursor-local-execute.test.ts:23

  • This Unix fake command has the same payload mismatch as the Windows branch: it writes { argv, env } and never reads stdin, while the test expects gitmeshAgentsEnvKeys and prompt to be present. That regresses the existing Unix behavior rather than leaving it unchanged.
node -e 'const fs=require("fs");fs.writeFileSync(process.argv[1], JSON.stringify({ argv: process.argv.slice(2), env: process.env }, null, 2));' "${capturePath}" "$@"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +10
async function writeFakeCursorCommand(
commandPath: string,
capturePath: string,
): Promise<void> {
await fs.writeFile(
commandPath,
`@echo off
node -e "const fs=require('fs');fs.writeFileSync(process.argv[1], JSON.stringify({ argv: process.argv.slice(2), env: process.env }, null, 2));" "${capturePath}" %*
Comment on lines +40 to +43
const commandPath = path.join(
root,
process.platform === "win32" ? "agent.cmd" : "agent",
);
@Parvm1102
Copy link
Copy Markdown
Member

Resolve these copilot comments first. Since I do not have a windows machine, try attaching some screenshots for reference.

@codebysana
Copy link
Copy Markdown
Contributor Author

Resolve these copilot comments first. Since I do not have a windows machine, try attaching some screenshots for reference.

Hey @Parvm1102, I’ve resolved the Copilot comments and pushed the updated changes to the PR. I’ve also added a Windows screenshot for reference.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +15 to +20
`@echo off
node -e "const fs=require('fs');let stdin='';process.stdin.on('data',d=>stdin+=d);process.stdin.on('end',()=>{const payload=JSON.parse(stdin);payload.argv=process.argv.slice(2);payload.env=process.env;fs.writeFileSync('${capturePath.replace(
/\\/g,
"\\\\",
)}',JSON.stringify(payload,null,2));});" %*
`,
Comment on lines +28 to +36
const fs = require('fs');
let stdin = '';
process.stdin.on('data', (chunk) => { stdin += chunk; });
process.stdin.on('end', () => {
const payload = JSON.parse(stdin);
payload.argv = process.argv.slice(2);
payload.env = process.env;
fs.writeFileSync('${capturePath}', JSON.stringify(payload, null, 2));
});
Signed-off-by: codebysana <sana.younas0530@gmail.com>
@codebysana codebysana force-pushed the fix/cursor-execute-windows branch from 5520950 to 3be8204 Compare May 26, 2026 20:06
@codebysana
Copy link
Copy Markdown
Contributor Author

Hey @Parvm1102, I have made the changes. Please have a look when you get a chance.

Signed-off-by: Parv Mittal <145541779+Parvm1102@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread server/src/__tests__/cursor-local-execute.test.ts
const scriptPath = path.join(dir, "agent");
await fs.writeFile(scriptPath, nodeScript, "utf8");
await fs.writeFile(
commandPath,
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Parv Mittal <145541779+Parvm1102@users.noreply.github.com>
@Parvm1102 Parvm1102 merged commit cf9439b into LF-Decentralized-Trust-labs:main May 30, 2026
2 checks passed
@Parvm1102
Copy link
Copy Markdown
Member

Parvm1102 commented May 30, 2026

You should've looked into the failing test cases. those were failing because argv was omitted in your changes raising an error.
I can't do changes in every contributor's PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants