gitarsenal-cli 1.3.12 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -40,7 +40,7 @@ def fetch_tokens_from_proxy(proxy_url=None, api_key=None):
|
|
40
40
|
|
41
41
|
# Check if we have the necessary information
|
42
42
|
if not proxy_url:
|
43
|
-
print("❌ No proxy URL provided or found in environment")
|
43
|
+
# print("❌ No proxy URL provided or found in environment")
|
44
44
|
# print("💡 Set MODAL_PROXY_URL environment variable or use --proxy-url argument")
|
45
45
|
return None, None
|
46
46
|
|
@@ -962,6 +962,9 @@ def create_modal_sandbox(gpu_type, repo_url=None, repo_name=None, setup_commands
|
|
962
962
|
When a command fails and is fixed by the LLM debugging system, the retry count
|
963
963
|
is reset to 0, so successful fixes don't count against the maximum retry limit.
|
964
964
|
This ensures that a command that's been fixed gets a fresh set of retry attempts.
|
965
|
+
|
966
|
+
The debug_with_llm parameter controls whether to use OpenAI to debug failed commands.
|
967
|
+
By default, this is set to True to ensure all command failures are debugged.
|
965
968
|
"""
|
966
969
|
# Use the outer scope variables
|
967
970
|
nonlocal current_dir, execution_history, sandbox, previous_errors
|
@@ -1389,6 +1392,10 @@ cd "{current_dir}"
|
|
1389
1392
|
# If command failed and we're debugging with LLM
|
1390
1393
|
if debug_with_llm:
|
1391
1394
|
print("🔍 Attempting to debug the failed command with OpenAI...")
|
1395
|
+
# Ensure we have a non-empty error message to debug
|
1396
|
+
if not stderr_buffer.strip() and stdout_buffer.strip():
|
1397
|
+
print("⚠️ stderr is empty but stdout contains content, using stdout for debugging")
|
1398
|
+
stderr_buffer = stdout_buffer
|
1392
1399
|
|
1393
1400
|
# Check if the command is a hanging huggingface-cli login
|
1394
1401
|
if "huggingface-cli login" in cmd_to_execute and not stderr_buffer.strip():
|
@@ -1426,6 +1433,36 @@ cd "{current_dir}"
|
|
1426
1433
|
print("✅ Successfully installed pytest, retrying original command...")
|
1427
1434
|
return run_command(cmd, show_output, retry_count + 1, max_retries)
|
1428
1435
|
|
1436
|
+
# Check for common errors that we can fix automatically
|
1437
|
+
common_errors = [
|
1438
|
+
# Source command not found in sh shell
|
1439
|
+
{
|
1440
|
+
"pattern": "source: not found",
|
1441
|
+
"fix": lambda cmd: cmd.replace("source ", ". ")
|
1442
|
+
},
|
1443
|
+
# No virtual environment found for uv
|
1444
|
+
{
|
1445
|
+
"pattern": "No virtual environment found; run `uv venv`",
|
1446
|
+
"fix": lambda cmd: "uv venv .venv && . .venv/bin/activate && " + cmd
|
1447
|
+
}
|
1448
|
+
]
|
1449
|
+
|
1450
|
+
# Check if any of the common errors match and apply automatic fix
|
1451
|
+
for error_info in common_errors:
|
1452
|
+
if error_info["pattern"] in stderr_buffer:
|
1453
|
+
print(f"🔍 Detected common error: {error_info['pattern']}")
|
1454
|
+
fix_func = error_info["fix"]
|
1455
|
+
fixed_cmd = fix_func(cmd_to_execute)
|
1456
|
+
print(f"🔧 Applying automatic fix: {fixed_cmd}")
|
1457
|
+
|
1458
|
+
# Run the fixed command
|
1459
|
+
fix_success, fix_stdout, fix_stderr = run_command(fixed_cmd, show_output=True, debug_with_llm=False)
|
1460
|
+
if fix_success:
|
1461
|
+
print("✅ Automatic fix succeeded!")
|
1462
|
+
return True, fix_stdout, ""
|
1463
|
+
else:
|
1464
|
+
print("❌ Automatic fix failed, continuing with LLM debugging")
|
1465
|
+
|
1429
1466
|
# Check for Python version-specific errors
|
1430
1467
|
python_version_errors = [
|
1431
1468
|
# Python 3.13 distutils issue
|
@@ -1898,13 +1935,29 @@ cd "{current_dir}"
|
|
1898
1935
|
print(f"✅ Current directory verified: {verify_output.strip()}")
|
1899
1936
|
|
1900
1937
|
# Execute each command individually in the repository directory within the container
|
1938
|
+
# Set to track if we should stop execution due to critical failures
|
1939
|
+
stop_execution = False
|
1940
|
+
|
1901
1941
|
for i, cmd in enumerate(setup_commands, 1):
|
1942
|
+
if stop_execution:
|
1943
|
+
print(f"\n⚠️ Skipping command {i}/{len(setup_commands)} due to previous critical failure")
|
1944
|
+
continue
|
1945
|
+
|
1902
1946
|
print(f"\n📋 Executing command {i}/{len(setup_commands)} in container: {cmd}")
|
1903
1947
|
|
1904
1948
|
# If this is a cd command, just run it directly
|
1905
1949
|
if cmd.strip().startswith('cd '):
|
1906
1950
|
# Execute the command directly (we're already in the right directory)
|
1907
1951
|
success, stdout, stderr = run_command(cmd)
|
1952
|
+
# If cd command fails, try to fix it before continuing
|
1953
|
+
if not success:
|
1954
|
+
print(f"❌ Command failed in container: {cmd}")
|
1955
|
+
print(f"❌ Error: {stderr}")
|
1956
|
+
# Try to fix the cd command with LLM debugging
|
1957
|
+
print("🔄 Attempting to fix cd command before continuing...")
|
1958
|
+
retry_success, retry_stdout, retry_stderr = run_command(cmd, debug_with_llm=True)
|
1959
|
+
if not retry_success:
|
1960
|
+
print("⚠️ Failed to fix cd command, this may cause subsequent commands to fail")
|
1908
1961
|
continue
|
1909
1962
|
|
1910
1963
|
# For git clone commands, handle as before
|
@@ -1960,6 +2013,15 @@ cd "{current_dir}"
|
|
1960
2013
|
print("🔍 Checking what was actually created:")
|
1961
2014
|
run_command("find . -maxdepth 2 -name '*.git' -type d", show_output=True)
|
1962
2015
|
run_command("ls -la", show_output=True)
|
2016
|
+
else:
|
2017
|
+
print(f"❌ Command failed in container: {cmd}")
|
2018
|
+
print(f"❌ Error: {stderr}")
|
2019
|
+
# Try to fix the git clone command with LLM debugging
|
2020
|
+
print("🔄 Attempting to fix git clone command before continuing...")
|
2021
|
+
retry_success, retry_stdout, retry_stderr = run_command(cmd, debug_with_llm=True)
|
2022
|
+
if not retry_success:
|
2023
|
+
print("⚠️ Failed to fix git clone command, this may cause subsequent commands to fail")
|
2024
|
+
print("🔄 Continuing with next command...")
|
1963
2025
|
else:
|
1964
2026
|
# For Python commands, make sure we're in the correct directory first
|
1965
2027
|
if cmd.startswith('python '):
|
@@ -1987,7 +2049,37 @@ cd "{current_dir}"
|
|
1987
2049
|
else:
|
1988
2050
|
print(f"❌ Command failed in container: {cmd}")
|
1989
2051
|
print(f"❌ Error: {stderr}")
|
1990
|
-
|
2052
|
+
|
2053
|
+
# Try to fix the command with LLM debugging and retry up to 3 times
|
2054
|
+
max_fix_attempts = 3
|
2055
|
+
for attempt in range(max_fix_attempts):
|
2056
|
+
print(f"🔄 Attempting to fix command (attempt {attempt+1}/{max_fix_attempts})...")
|
2057
|
+
retry_success, retry_stdout, retry_stderr = run_command(cmd, debug_with_llm=True)
|
2058
|
+
if retry_success:
|
2059
|
+
print(f"✅ Command fixed and executed successfully on attempt {attempt+1}")
|
2060
|
+
break
|
2061
|
+
else:
|
2062
|
+
print(f"❌ Fix attempt {attempt+1} failed")
|
2063
|
+
|
2064
|
+
if not retry_success:
|
2065
|
+
print("⚠️ Failed to fix command after multiple attempts")
|
2066
|
+
# Ask if user wants to continue with next command or abort
|
2067
|
+
try:
|
2068
|
+
continue_choice = input("Continue with next command? (y/n): ").strip().lower()
|
2069
|
+
if continue_choice != 'y':
|
2070
|
+
print("🛑 Aborting setup commands execution")
|
2071
|
+
stop_execution = True
|
2072
|
+
break
|
2073
|
+
print("🔄 Continuing with next command...")
|
2074
|
+
except:
|
2075
|
+
# In case we can't get user input, ask if the command is critical
|
2076
|
+
if "pip install" in cmd or "git clone" in cmd or "setup.py" in cmd:
|
2077
|
+
print("⚠️ Critical command failed and couldn't be fixed")
|
2078
|
+
print("⚠️ Subsequent commands likely to fail, stopping execution")
|
2079
|
+
stop_execution = True
|
2080
|
+
break
|
2081
|
+
else:
|
2082
|
+
print("⚠️ Unable to get user input, continuing with next command...")
|
1991
2083
|
|
1992
2084
|
# Show final status of the repository directory in container
|
1993
2085
|
print(f"\n📂 Final directory contents in container ({repo_dir_name}):")
|