@@ -159,15 +159,34 @@ func (c *AutonomousCreator) doSetup() (string, error) {
159159}
160160
161161func (c * AutonomousCreator ) doDependencies () (string , error ) {
162+ // Detect Python binary if this is a Python project
163+ pythonBinary := detectPythonBinary ()
164+
165+ // Build platform-appropriate examples
166+ var pythonExample string
167+ if runtime .GOOS == "windows" {
168+ if pythonBinary != "" {
169+ pythonExample = fmt .Sprintf ("Example for Python: %s -m venv venv && venv\\ Scripts\\ activate && pip install fastapi uvicorn" , pythonBinary )
170+ } else {
171+ pythonExample = "Example for Python: python -m venv venv && venv\\ Scripts\\ activate && pip install fastapi uvicorn"
172+ }
173+ } else {
174+ if pythonBinary != "" {
175+ pythonExample = fmt .Sprintf ("Example for Python: %s -m venv venv && source venv/bin/activate && pip install fastapi uvicorn" , pythonBinary )
176+ } else {
177+ pythonExample = "Example for Python: python3 -m venv venv && source venv/bin/activate && pip install fastapi uvicorn"
178+ }
179+ }
180+
162181 // Ask AI for the specific setup shell commands required.
163182 prompt := fmt .Sprintf (`Given the implementation plan:
164183%s
165184
166185What are the precise terminal commands to initialize the project dependencies?
167- Return ONLY a bash script with the commands. No markdown formatting, no explanations. Just the raw commands.
186+ Return ONLY a script with the commands. No markdown formatting, no explanations. Just the raw commands.
168187Example for Go: go mod init my-app && go mod tidy
169- Example for Python: python3 -m venv venv && source venv/bin/activate && pip install fastapi uvicorn
170- Assume we are already inside the project directory.` , c .Plan )
188+ %s
189+ Assume we are already inside the project directory.` , c .Plan , pythonExample )
171190
172191 cmdsStr , err := aicall (c .AIClient , c .Model , prompt )
173192 if err != nil {
@@ -179,6 +198,11 @@ Assume we are already inside the project directory.`, c.Plan)
179198 cmdsStr = strings .TrimSpace (strings .TrimPrefix (cmdsStr , "```" ))
180199
181200 if cmdsStr != "" {
201+ // On Windows, convert Unix-style commands to Windows-compatible ones
202+ if runtime .GOOS == "windows" {
203+ cmdsStr = convertToWindowsCommands (cmdsStr , pythonBinary )
204+ }
205+
182206 // Prepare a shell script to execute
183207 scriptPath := filepath .Join (c .ProjectDir , "setup.sh" )
184208 if runtime .GOOS == "windows" {
@@ -949,3 +973,41 @@ func (c *AutonomousCreator) attemptTestFix(projectType, testCmd, output string,
949973 // For other errors, just report and abort
950974 return "" , fmt .Errorf ("automated test failed: %v\n Output: %s\n \n Aborting autonomous creation." , testErr , output )
951975}
976+
977+ // detectPythonBinary tries to find the correct Python binary on the system
978+ // Returns "python" or "python3" depending on what's available, or empty string if neither found
979+ func detectPythonBinary () string {
980+ // Try python first (common on Windows)
981+ if _ , err := exec .LookPath ("python" ); err == nil {
982+ return "python"
983+ }
984+
985+ // Try python3 (common on Linux/Mac)
986+ if _ , err := exec .LookPath ("python3" ); err == nil {
987+ return "python3"
988+ }
989+
990+ return ""
991+ }
992+
993+ // convertToWindowsCommands converts Unix-style shell commands to Windows batch commands
994+ func convertToWindowsCommands (cmds , pythonBinary string ) string {
995+ // Replace python3 with detected binary or fallback to python
996+ if pythonBinary != "" {
997+ cmds = strings .ReplaceAll (cmds , "python3" , pythonBinary )
998+ } else {
999+ cmds = strings .ReplaceAll (cmds , "python3" , "python" )
1000+ }
1001+
1002+ // Replace Unix venv activation with Windows activation
1003+ cmds = strings .ReplaceAll (cmds , "source venv/bin/activate" , "venv\\ Scripts\\ activate" )
1004+ cmds = strings .ReplaceAll (cmds , "source venv\\ bin\\ activate" , "venv\\ Scripts\\ activate" )
1005+
1006+ // Replace Unix path separators in venv paths
1007+ cmds = strings .ReplaceAll (cmds , "venv/bin/" , "venv\\ Scripts\\ " )
1008+
1009+ // Replace && with & for Windows batch (though && also works in cmd)
1010+ // Actually, && works fine in Windows batch, so we can leave it
1011+
1012+ return cmds
1013+ }
0 commit comments