gitarsenal-cli 1.1.21 → 1.1.22

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -2494,7 +2494,7 @@ def fetch_setup_commands_from_api(repo_url):
2494
2494
  import shutil
2495
2495
  import json
2496
2496
 
2497
- api_url = "http://git-arsenal.vercel.app/api/analyze-with-gitingest"
2497
+ api_url = "https://git-arsenal.vercel.app/api/analyze-with-gitingest"
2498
2498
 
2499
2499
  print(f"šŸ” Fetching setup commands from API for repository: {repo_url}")
2500
2500
 
@@ -2605,11 +2605,32 @@ def fetch_setup_commands_from_api(repo_url):
2605
2605
  commands = data["setupInstructions"]["commands"]
2606
2606
  print(f"āœ… Successfully fetched {len(commands)} setup commands from API")
2607
2607
 
2608
- # Print the commands for reference
2608
+ # Print the original commands for reference
2609
+ print("šŸ“‹ Original commands from API:")
2609
2610
  for i, cmd in enumerate(commands, 1):
2610
2611
  print(f" {i}. {cmd}")
2611
2612
 
2612
- return commands
2613
+ # Fix the commands by removing placeholders and comments
2614
+ fixed_commands = fix_setup_commands(commands)
2615
+
2616
+ # If we have a temp_dir with the cloned repo, try to find the entry point
2617
+ # and replace any placeholder entry points
2618
+ for i, cmd in enumerate(fixed_commands):
2619
+ if "python main.py" in cmd or "python3 main.py" in cmd:
2620
+ try:
2621
+ entry_point = find_entry_point(temp_dir)
2622
+ if entry_point and entry_point != "main.py":
2623
+ fixed_commands[i] = cmd.replace("main.py", entry_point)
2624
+ print(f"šŸ”„ Replaced main.py with detected entry point: {entry_point}")
2625
+ except Exception as e:
2626
+ print(f"āš ļø Error finding entry point: {e}")
2627
+
2628
+ # Print the fixed commands
2629
+ print("\nšŸ“‹ Fixed commands:")
2630
+ for i, cmd in enumerate(fixed_commands, 1):
2631
+ print(f" {i}. {cmd}")
2632
+
2633
+ return fixed_commands
2613
2634
  else:
2614
2635
  print("āš ļø API response did not contain setupInstructions.commands field")
2615
2636
  print("šŸ“‹ Available fields in response:")
@@ -2755,11 +2776,14 @@ def generate_fallback_commands(gitingest_data):
2755
2776
  # Combine all commands
2756
2777
  all_commands = default_commands + language_commands
2757
2778
 
2779
+ # Fix the commands
2780
+ fixed_commands = fix_setup_commands(all_commands)
2781
+
2758
2782
  print("\nšŸ“‹ Generated fallback setup commands:")
2759
- for i, cmd in enumerate(all_commands, 1):
2783
+ for i, cmd in enumerate(fixed_commands, 1):
2760
2784
  print(f" {i}. {cmd}")
2761
2785
 
2762
- return all_commands
2786
+ return fixed_commands
2763
2787
 
2764
2788
  def generate_basic_repo_analysis_from_url(repo_url):
2765
2789
  """Generate basic repository analysis data from a repository URL."""
@@ -2947,9 +2971,21 @@ def get_setup_commands_from_local_api(repo_url, gitingest_data):
2947
2971
  if "setupInstructions" in data and "commands" in data["setupInstructions"]:
2948
2972
  commands = data["setupInstructions"]["commands"]
2949
2973
  print(f"āœ… Successfully fetched {len(commands)} setup commands from local API")
2974
+
2975
+ # Print the original commands
2976
+ print("šŸ“‹ Original commands from local API:")
2950
2977
  for i, cmd in enumerate(commands, 1):
2951
2978
  print(f" {i}. {cmd}")
2952
- return commands
2979
+
2980
+ # Fix the commands
2981
+ fixed_commands = fix_setup_commands(commands)
2982
+
2983
+ # Print the fixed commands
2984
+ print("\nšŸ“‹ Fixed commands:")
2985
+ for i, cmd in enumerate(fixed_commands, 1):
2986
+ print(f" {i}. {cmd}")
2987
+
2988
+ return fixed_commands
2953
2989
  except Exception as e:
2954
2990
  print(f"āŒ Error connecting to local API: {e}")
2955
2991
 
@@ -3073,6 +3109,58 @@ def create_ssh_container_function(gpu_type="a10g", timeout_minutes=60, volume=No
3073
3109
  # Return the configured function
3074
3110
  return ssh_container, app_name
3075
3111
 
3112
+ def fix_setup_commands(commands):
3113
+ """Fix setup commands by removing placeholders and comments."""
3114
+ fixed_commands = []
3115
+
3116
+ for cmd in commands:
3117
+ # Remove placeholders like "(or the appropriate entry point...)"
3118
+ cmd = re.sub(r'\([^)]*\)', '', cmd).strip()
3119
+
3120
+ # Skip empty commands or pure comments
3121
+ if not cmd or cmd.startswith('#'):
3122
+ continue
3123
+
3124
+ # Remove trailing comments
3125
+ cmd = re.sub(r'#.*$', '', cmd).strip()
3126
+
3127
+ if cmd:
3128
+ fixed_commands.append(cmd)
3129
+
3130
+ return fixed_commands
3131
+
3132
+ def find_entry_point(repo_dir):
3133
+ """Find the entry point script for a repository."""
3134
+ # Common entry point files to check
3135
+ common_entry_points = [
3136
+ "main.py", "app.py", "run.py", "train.py", "start.py",
3137
+ "server.py", "cli.py", "demo.py", "example.py"
3138
+ ]
3139
+
3140
+ # Check if any of the common entry points exist
3141
+ for entry_point in common_entry_points:
3142
+ if os.path.exists(os.path.join(repo_dir, entry_point)):
3143
+ return entry_point
3144
+
3145
+ # Look for Python files in the root directory
3146
+ python_files = [f for f in os.listdir(repo_dir) if f.endswith('.py')]
3147
+ if python_files:
3148
+ # Prioritize files with main function or if_name_main pattern
3149
+ for py_file in python_files:
3150
+ file_path = os.path.join(repo_dir, py_file)
3151
+ try:
3152
+ with open(file_path, 'r') as f:
3153
+ content = f.read()
3154
+ if "def main" in content or "if __name__ == '__main__'" in content or 'if __name__ == "__main__"' in content:
3155
+ return py_file
3156
+ except:
3157
+ pass
3158
+
3159
+ # If no main function found, return the first Python file
3160
+ return python_files[0]
3161
+
3162
+ return None
3163
+
3076
3164
  if __name__ == "__main__":
3077
3165
  # Parse command line arguments when script is run directly
3078
3166
  import argparse