mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-26 14:38:45 +02:00
fix: use Copilot launch command for version checks
Run the Copilot CLI version probe through the resolved launch path and args instead of invoking the Windows shim directly. This keeps the version check aligned with the SDK launch strategy and avoids false 'Version unknown' results from the Winget-installed Copilot executable. Add a regression test covering the constructed launch command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -32,9 +32,10 @@ internal static partial class CopilotConnectionMetadataResolver
|
||||
{
|
||||
try
|
||||
{
|
||||
(string executablePath, string[] arguments) = CreateCliCommand(cliContext, "version");
|
||||
CommandResult result = await RunProcessAsync(
|
||||
executablePath: cliContext.CliPath,
|
||||
arguments: ["version"],
|
||||
executablePath: executablePath,
|
||||
arguments: arguments,
|
||||
environment: cliContext.Environment,
|
||||
timeout: CopilotVersionTimeout,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
@@ -59,6 +60,18 @@ internal static partial class CopilotConnectionMetadataResolver
|
||||
}
|
||||
}
|
||||
|
||||
internal static (string ExecutablePath, string[] Arguments) CreateCliCommand(
|
||||
CopilotCliContext cliContext,
|
||||
params string[] arguments)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(cliContext);
|
||||
ArgumentNullException.ThrowIfNull(arguments);
|
||||
|
||||
return (
|
||||
cliContext.LaunchPath,
|
||||
[.. cliContext.LaunchArgs, .. arguments]);
|
||||
}
|
||||
|
||||
internal static SidecarCopilotCliVersionDiagnosticsDto ParseCliVersionOutput(
|
||||
string? standardOutput,
|
||||
string? standardError = null,
|
||||
|
||||
@@ -36,6 +36,22 @@ public sealed class CopilotConnectionMetadataResolverTests
|
||||
Assert.Equal("1.0.10", diagnostics.LatestVersion);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateCliCommand_UsesLaunchPathAndAppendsCommandArguments()
|
||||
{
|
||||
CopilotCliContext cliContext = new(
|
||||
CliPath: @"C:\tools\copilot.exe",
|
||||
LaunchPath: @"C:\Windows\System32\cmd.exe",
|
||||
LaunchArgs: ["/d", "/s", "/c", "copilot"],
|
||||
Environment: new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase));
|
||||
|
||||
(string executablePath, string[] arguments) =
|
||||
CopilotConnectionMetadataResolver.CreateCliCommand(cliContext, "version");
|
||||
|
||||
Assert.Equal(@"C:\Windows\System32\cmd.exe", executablePath);
|
||||
Assert.Equal(["/d", "/s", "/c", "copilot", "version"], arguments);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeHost_StripsSchemeAndTrailingSlash()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user