gitarsenal-cli 1.6.15 → 1.7.1

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.6.15",
3
+ "version": "1.7.1",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -327,6 +327,37 @@ def handle_huggingface_login(sandbox, current_dir):
327
327
  return exit_code == 0, stdout_buffer, stderr_buffer
328
328
 
329
329
 
330
+ def get_stored_credentials():
331
+ """Load stored credentials from ~/.gitarsenal/credentials.json"""
332
+ import json
333
+ from pathlib import Path
334
+
335
+ try:
336
+ credentials_file = Path.home() / ".gitarsenal" / "credentials.json"
337
+ if credentials_file.exists():
338
+ with open(credentials_file, 'r') as f:
339
+ credentials = json.load(f)
340
+ return credentials
341
+ else:
342
+ return {}
343
+ except Exception as e:
344
+ print(f"⚠️ Error loading stored credentials: {e}")
345
+ return {}
346
+
347
+ def generate_auth_context(stored_credentials):
348
+ """Generate simple authentication context for the OpenAI prompt"""
349
+ if not stored_credentials:
350
+ return "No stored credentials available."
351
+
352
+ auth_context = "Available stored credentials (use actual values in commands):\n"
353
+
354
+ for key, value in stored_credentials.items():
355
+ # Mask the actual value for security in logs, but provide the real value
356
+ masked_value = value[:8] + "..." if len(value) > 8 else "***"
357
+ auth_context += f"- {key}: {masked_value} (actual value: {value})\n"
358
+
359
+ return auth_context
360
+
330
361
  def call_openai_for_debug(command, error_output, api_key=None, current_dir=None, sandbox=None):
331
362
  """Call OpenAI to debug a failed command and suggest a fix"""
332
363
  print("\n🔍 DEBUG: Starting LLM debugging...")
@@ -620,6 +651,9 @@ Directory contents:
620
651
  "Content-Type": "application/json",
621
652
  "Authorization": f"Bearer {api_key}"
622
653
  }
654
+
655
+ stored_credentials = get_stored_credentials()
656
+ auth_context = generate_auth_context(stored_credentials)
623
657
 
624
658
  # Create a prompt for the LLM
625
659
  print("\n" + "="*60)
@@ -644,29 +678,41 @@ But it failed with this error:
644
678
  {directory_context}
645
679
  {file_context}
646
680
 
681
+ AVAILABLE CREDENTIALS:
682
+ {auth_context}
683
+
647
684
  Please analyze the error and provide ONLY a single terminal command that would fix the issue.
648
- Consider the current directory, system information, and directory contents carefully before suggesting a solution.
685
+ Consider the current directory, system information, directory contents, and available credentials carefully before suggesting a solution.
649
686
 
650
687
  IMPORTANT GUIDELINES:
651
688
  1. For any commands that might ask for yes/no confirmation, use the appropriate non-interactive flag:
652
689
  - For apt/apt-get: use -y or --yes
653
690
  - For pip: use --no-input
654
691
  - For rm: use -f or --force
655
- - For other commands: check their documentation for the appropriate non-interactive flag
656
692
 
657
- 2. If the error indicates a file is not found (e.g., "No such file or directory", "cannot open", "not found"):
693
+ 2. If the error indicates a file is not found:
658
694
  - FIRST try to search for the file using: find . -name "filename" -type f 2>/dev/null
659
695
  - If found, navigate to that directory using: cd /path/to/directory
660
696
  - If not found, then consider creating the file or installing missing packages
661
697
 
662
698
  3. For missing packages or dependencies:
663
699
  - Use pip install for Python packages
664
- - Use apt-get install for system packages
700
+ - Use apt-get install -y for system packages
665
701
  - Use npm install for Node.js packages
666
702
 
667
703
  4. For authentication issues:
668
- - For wandb login: suggest 'wandb login YOUR_API_KEY' (system will prompt for actual key)
669
- - For huggingface: suggest 'huggingface-cli login' (system will prompt for token)
704
+ - Analyze the error to determine what type of authentication is needed
705
+ - Use the actual credential values provided above (not placeholders)
706
+ - Common patterns:
707
+ * wandb errors: use wandb login with WANDB_API_KEY
708
+ * huggingface errors: use huggingface-cli login with HF_TOKEN or HUGGINGFACE_TOKEN
709
+ * github errors: configure git credentials with GITHUB_TOKEN
710
+ * kaggle errors: create ~/.kaggle/kaggle.json with KAGGLE_USERNAME and KAGGLE_KEY
711
+ * API errors: export the appropriate API key as environment variable
712
+
713
+ 5. Environment variable exports:
714
+ - Use export commands for API keys that need to be in environment
715
+ - Use the actual credential values, not placeholders
670
716
 
671
717
  Do not provide any explanations, just the exact command to run.
672
718
  """
@@ -327,6 +327,37 @@ def handle_huggingface_login(sandbox, current_dir):
327
327
  return exit_code == 0, stdout_buffer, stderr_buffer
328
328
 
329
329
 
330
+ def get_stored_credentials():
331
+ """Load stored credentials from ~/.gitarsenal/credentials.json"""
332
+ import json
333
+ from pathlib import Path
334
+
335
+ try:
336
+ credentials_file = Path.home() / ".gitarsenal" / "credentials.json"
337
+ if credentials_file.exists():
338
+ with open(credentials_file, 'r') as f:
339
+ credentials = json.load(f)
340
+ return credentials
341
+ else:
342
+ return {}
343
+ except Exception as e:
344
+ print(f"⚠️ Error loading stored credentials: {e}")
345
+ return {}
346
+
347
+ def generate_auth_context(stored_credentials):
348
+ """Generate simple authentication context for the OpenAI prompt"""
349
+ if not stored_credentials:
350
+ return "No stored credentials available."
351
+
352
+ auth_context = "Available stored credentials (use actual values in commands):\n"
353
+
354
+ for key, value in stored_credentials.items():
355
+ # Mask the actual value for security in logs, but provide the real value
356
+ masked_value = value[:8] + "..." if len(value) > 8 else "***"
357
+ auth_context += f"- {key}: {masked_value} (actual value: {value})\n"
358
+
359
+ return auth_context
360
+
330
361
  def call_openai_for_debug(command, error_output, api_key=None, current_dir=None, sandbox=None):
331
362
  """Call OpenAI to debug a failed command and suggest a fix"""
332
363
  print("\n🔍 DEBUG: Starting LLM debugging...")
@@ -620,6 +651,9 @@ Directory contents:
620
651
  "Content-Type": "application/json",
621
652
  "Authorization": f"Bearer {api_key}"
622
653
  }
654
+
655
+ stored_credentials = get_stored_credentials()
656
+ auth_context = generate_auth_context(stored_credentials)
623
657
 
624
658
  # Create a prompt for the LLM
625
659
  print("\n" + "="*60)
@@ -644,29 +678,41 @@ But it failed with this error:
644
678
  {directory_context}
645
679
  {file_context}
646
680
 
681
+ AVAILABLE CREDENTIALS:
682
+ {auth_context}
683
+
647
684
  Please analyze the error and provide ONLY a single terminal command that would fix the issue.
648
- Consider the current directory, system information, and directory contents carefully before suggesting a solution.
685
+ Consider the current directory, system information, directory contents, and available credentials carefully before suggesting a solution.
649
686
 
650
687
  IMPORTANT GUIDELINES:
651
688
  1. For any commands that might ask for yes/no confirmation, use the appropriate non-interactive flag:
652
689
  - For apt/apt-get: use -y or --yes
653
690
  - For pip: use --no-input
654
691
  - For rm: use -f or --force
655
- - For other commands: check their documentation for the appropriate non-interactive flag
656
692
 
657
- 2. If the error indicates a file is not found (e.g., "No such file or directory", "cannot open", "not found"):
693
+ 2. If the error indicates a file is not found:
658
694
  - FIRST try to search for the file using: find . -name "filename" -type f 2>/dev/null
659
695
  - If found, navigate to that directory using: cd /path/to/directory
660
696
  - If not found, then consider creating the file or installing missing packages
661
697
 
662
698
  3. For missing packages or dependencies:
663
699
  - Use pip install for Python packages
664
- - Use apt-get install for system packages
700
+ - Use apt-get install -y for system packages
665
701
  - Use npm install for Node.js packages
666
702
 
667
703
  4. For authentication issues:
668
- - For wandb login: suggest 'wandb login YOUR_API_KEY' (system will prompt for actual key)
669
- - For huggingface: suggest 'huggingface-cli login' (system will prompt for token)
704
+ - Analyze the error to determine what type of authentication is needed
705
+ - Use the actual credential values provided above (not placeholders)
706
+ - Common patterns:
707
+ * wandb errors: use wandb login with WANDB_API_KEY
708
+ * huggingface errors: use huggingface-cli login with HF_TOKEN or HUGGINGFACE_TOKEN
709
+ * github errors: configure git credentials with GITHUB_TOKEN
710
+ * kaggle errors: create ~/.kaggle/kaggle.json with KAGGLE_USERNAME and KAGGLE_KEY
711
+ * API errors: export the appropriate API key as environment variable
712
+
713
+ 5. Environment variable exports:
714
+ - Use export commands for API keys that need to be in environment
715
+ - Use the actual credential values, not placeholders
670
716
 
671
717
  Do not provide any explanations, just the exact command to run.
672
718
  """