fix: support Windows fake cursor execute commands#388
Conversation
Signed-off-by: codebysana <sana.younas0530@gmail.com>
There was a problem hiding this comment.
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.cmdon 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 expectsgitmeshAgentsEnvKeysandpromptto 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.
| 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}" %* |
| const commandPath = path.join( | ||
| root, | ||
| process.platform === "win32" ? "agent.cmd" : "agent", | ||
| ); |
|
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. |
| `@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));});" %* | ||
| `, |
| 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>
5520950 to
3be8204
Compare
|
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>
| 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>
|
You should've looked into the failing test cases. those were failing because argv was omitted in your changes raising an error. |
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
.cmdextension instead of a plain executable nameWhy this change is needed
On Windows, Node.js
spawncannot 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.Impact
Notes
This PR only fixes command resolution for Windows.
Additional runtime or spawn execution issues (if any remain) will be handled separately.