Skip to content
Merged
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
1 change: 0 additions & 1 deletion .worktrees/issue-65
Submodule issue-65 deleted from ac8dac
9 changes: 5 additions & 4 deletions app/Infrastructure/ShellIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,19 @@ private static void EnsureCmdWrappers(string userHome, string psPath)
File.WriteAllText(yoloCmd, BuildCmdWrapper("copilot_yolo", psPath));
}

private static string BuildCmdWrapper(string functionName, string psPath)
internal static string BuildCmdWrapper(string functionName, string psPath)
{
// Prefer pwsh, fall back to powershell.
// Keep wrapper simple and rely on PowerShell script for all logic.
// Pass arguments after `--` and forward via PowerShell `@args` so quoted
// values (for example --prompt "What is 1 + 1 ?") stay as a single arg.
return "@echo off\r\n" +
"setlocal\r\n" +
"set \"SCRIPT=%USERPROFILE%\\.copilot_here.ps1\"\r\n" +
"where pwsh >nul 2>nul\r\n" +
"if %ERRORLEVEL%==0 (\r\n" +
$" pwsh -NoProfile -ExecutionPolicy Bypass -Command \". '%USERPROFILE%\\.copilot_here.ps1'; {functionName} %*\"\r\n" +
$" pwsh -NoProfile -ExecutionPolicy Bypass -Command \"& {{ . '%USERPROFILE%\\.copilot_here.ps1'; {functionName} @args }}\" -- %*\r\n" +
") else (\r\n" +
$" powershell -NoProfile -ExecutionPolicy Bypass -Command \". '%USERPROFILE%\\.copilot_here.ps1'; {functionName} %*\"\r\n" +
$" powershell -NoProfile -ExecutionPolicy Bypass -Command \"& {{ . '%USERPROFILE%\\.copilot_here.ps1'; {functionName} @args }}\" -- %*\r\n" +
Comment on lines +334 to +346
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

BuildCmdWrapper takes psPath but never uses it (the wrapper still hardcodes %USERPROFILE%\.copilot_here.ps1). Either remove the unused parameter (and adjust call sites/tests) or use psPath to build the script path in the generated CMD so the wrapper reflects the actual installed location.

Copilot uses AI. Check for mistakes.
Comment on lines +344 to +346
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

This change alters user-facing behavior (Windows CMD wrapper argument forwarding) but the repo’s versioning rule requires bumping the version consistently across all version locations so users re-download updates. Please increment the version in copilot_here.sh, copilot_here.ps1, Directory.Build.props, app/Infrastructure/BuildInfo.cs, and update the “Current version” in .github/copilot-instructions.md (see .github/copilot-instructions.md Script Versioning section).

Copilot uses AI. Check for mistakes.
")\r\n" +
"endlocal\r\n";
}
Expand Down
29 changes: 29 additions & 0 deletions tests/CopilotHere.UnitTests/ShellIntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using CopilotHere.Infrastructure;
using TUnit.Core;

namespace CopilotHere.Tests;

public class ShellIntegrationTests
{
[Test]
public async Task BuildCmdWrapper_UsesArgsSplatForForwarding()
{
// Act
var wrapper = ShellIntegration.BuildCmdWrapper("copilot_yolo", "ignored");

// Assert
await Assert.That(wrapper).Contains("copilot_yolo @args");
await Assert.That(wrapper).Contains(" -- %*");
}

[Test]
public async Task BuildCmdWrapper_UsesArgsSplatForBothPwshAndWindowsPowerShell()
{
// Act
var wrapper = ShellIntegration.BuildCmdWrapper("copilot_here", "ignored");

// Assert
var occurrences = wrapper.Split("copilot_here @args").Length - 1;
await Assert.That(occurrences).IsEqualTo(2);
}
}
Loading