Skip to content

Commit 27ed2e8

Browse files
Merge pull request #585 from MervinPraison/claude/issue-142-20250603_084931
fix: add Windows compatibility for shell commands in AICoder
2 parents 1c7e10e + ec1c485 commit 27ed2e8

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/praisonai/praisonai/ui/components/aicoder.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import asyncio
33
from pathlib import Path
44
import difflib
5+
import platform
56
from typing import Dict, Any
67
from litellm import acompletion
78
import json
@@ -119,10 +120,24 @@ async def read_file(self, file_path):
119120
except:
120121
return None
121122

123+
def get_shell_command(self, command: str) -> str:
124+
"""
125+
Convert command to be cross-platform compatible.
126+
On Windows, use cmd /c for shell commands.
127+
On Unix-like systems, use the command as-is.
128+
"""
129+
if platform.system() == "Windows":
130+
# For Windows, escape quotes and wrap command in cmd /c
131+
escaped_command = command.replace('"', '\\"')
132+
return f'cmd /c "{escaped_command}"'
133+
return command
134+
122135
async def execute_command(self, command: str):
123136
try:
137+
# Make command cross-platform compatible
138+
shell_command = self.get_shell_command(command)
124139
process = await asyncio.create_subprocess_shell(
125-
command,
140+
shell_command,
126141
stdout=asyncio.subprocess.PIPE,
127142
stderr=asyncio.subprocess.PIPE,
128143
cwd=self.cwd

0 commit comments

Comments
 (0)