Merge pull request #279 from christopher-buss/fix-windows-clink

fix: resolve executable path for clink cross-platform compatibility in CLI
This commit is contained in:
Beehive Innovations
2025-10-08 08:11:04 +04:00
committed by GitHub
3 changed files with 22 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import asyncio
import logging import logging
import os import os
import shlex import shlex
import shutil
import tempfile import tempfile
import time import time
from collections.abc import Sequence from collections.abc import Sequence
@@ -65,6 +66,17 @@ class BaseCLIAgent:
# The runner simply executes the configured CLI command for the selected role. # The runner simply executes the configured CLI command for the selected role.
command = self._build_command(role=role) command = self._build_command(role=role)
env = self._build_environment() env = self._build_environment()
# Resolve executable path for cross-platform compatibility (especially Windows)
executable_name = command[0]
resolved_executable = shutil.which(executable_name)
if resolved_executable is None:
raise CLIAgentError(
f"Executable '{executable_name}' not found in PATH for CLI '{self.client.name}'. "
f"Ensure the command is installed and accessible."
)
command[0] = resolved_executable
sanitized_command = list(command) sanitized_command = list(command)
cwd = str(self.client.working_dir) if self.client.working_dir else None cwd = str(self.client.working_dir) if self.client.working_dir else None

View File

@@ -1,4 +1,5 @@
import asyncio import asyncio
import shutil
from pathlib import Path from pathlib import Path
import pytest import pytest
@@ -41,7 +42,11 @@ async def _run_agent_with_process(monkeypatch, agent, role, process):
async def fake_create_subprocess_exec(*_args, **_kwargs): async def fake_create_subprocess_exec(*_args, **_kwargs):
return process return process
def fake_which(executable_name):
return f"/usr/bin/{executable_name}"
monkeypatch.setattr(asyncio, "create_subprocess_exec", fake_create_subprocess_exec) monkeypatch.setattr(asyncio, "create_subprocess_exec", fake_create_subprocess_exec)
monkeypatch.setattr(shutil, "which", fake_which)
return await agent.run(role=role, prompt="do something", files=[], images=[]) return await agent.run(role=role, prompt="do something", files=[], images=[])

View File

@@ -1,4 +1,5 @@
import asyncio import asyncio
import shutil
from pathlib import Path from pathlib import Path
import pytest import pytest
@@ -41,7 +42,11 @@ async def _run_agent_with_process(monkeypatch, agent, role, process):
async def fake_create_subprocess_exec(*_args, **_kwargs): async def fake_create_subprocess_exec(*_args, **_kwargs):
return process return process
def fake_which(executable_name):
return f"/usr/bin/{executable_name}"
monkeypatch.setattr(asyncio, "create_subprocess_exec", fake_create_subprocess_exec) monkeypatch.setattr(asyncio, "create_subprocess_exec", fake_create_subprocess_exec)
monkeypatch.setattr(shutil, "which", fake_which)
return await agent.run(role=role, prompt="do something", files=[], images=[]) return await agent.run(role=role, prompt="do something", files=[], images=[])