gitarsenal-cli 1.5.3 โ†’ 1.5.5

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.
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Patch the test_modalSandboxScript.py file to fix issues with LLM debugging
4
- """
5
-
6
- import os
7
- import sys
8
- import re
9
-
10
- def read_file(filename):
11
- """Read a file and return its contents"""
12
- with open(filename, 'r') as f:
13
- return f.read()
14
-
15
- def write_file(filename, content):
16
- """Write content to a file"""
17
- with open(filename, 'w') as f:
18
- f.write(content)
19
-
20
- def patch_file(filename):
21
- """Patch the file to fix issues with LLM debugging"""
22
- print(f"๐Ÿ”ง Patching {filename}...")
23
-
24
- # Read the file
25
- content = read_file(filename)
26
-
27
- # Make a backup
28
- backup_filename = f"{filename}.bak"
29
- write_file(backup_filename, content)
30
- print(f"โœ… Created backup: {backup_filename}")
31
-
32
- # Fix 1: Replace 'source' with '.' in commands
33
- pattern1 = r'(uv venv.*?)source(.*?activate)'
34
- replacement1 = r'\1.\2'
35
- content = re.sub(pattern1, replacement1, content)
36
- print("โœ… Fixed 'source' commands")
37
-
38
- # Fix 2: Add environment activation before uv pip commands
39
- pattern2 = r'(uv pip install.*?)(?!\. .*?activate)'
40
- replacement2 = r'. openr1/bin/activate && \1'
41
- content = re.sub(pattern2, replacement2, content)
42
- print("โœ… Added environment activation before pip commands")
43
-
44
- # Write the patched file
45
- write_file(filename, content)
46
- print(f"โœ… Patched file written: {filename}")
47
-
48
- return True
49
-
50
- def main():
51
- """Main function"""
52
- # Get the file to patch
53
- if len(sys.argv) > 1:
54
- filename = sys.argv[1]
55
- else:
56
- # Default to the test_modalSandboxScript.py in the current directory
57
- filename = "test_modalSandboxScript.py"
58
-
59
- # Check if the file exists
60
- if not os.path.exists(filename):
61
- print(f"โŒ File not found: {filename}")
62
- return 1
63
-
64
- # Patch the file
65
- success = patch_file(filename)
66
-
67
- if success:
68
- print("\nโœ… Patching completed successfully")
69
- return 0
70
- else:
71
- print("\nโŒ Patching failed")
72
- return 1
73
-
74
- if __name__ == "__main__":
75
- sys.exit(main())
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Run With Modal Token - Wrapper Script
4
-
5
- This script sets up the Modal token in the environment and then runs a specified command.
6
- It's useful for running commands that need Modal authentication without modifying them.
7
-
8
- Usage:
9
- python run_with_modal_token.py <command> [args...]
10
-
11
- Example:
12
- python run_with_modal_token.py python modal_proxy_service.py
13
- """
14
-
15
- import os
16
- import sys
17
- import subprocess
18
- from setup_modal_token import setup_modal_token
19
-
20
- def main():
21
- # Set up Modal token (should always succeed with built-in token)
22
- setup_modal_token()
23
- print("โœ… Using built-in Modal token for freemium service")
24
-
25
- # Check if a command was provided
26
- if len(sys.argv) < 2:
27
- print("โŒ No command provided")
28
- print(f"Usage: {sys.argv[0]} <command> [args...]")
29
- sys.exit(1)
30
-
31
- # Get the command and arguments
32
- cmd = sys.argv[1]
33
- args = sys.argv[2:]
34
-
35
- # Print what we're about to run
36
- print(f"๐Ÿš€ Running command with Modal token: {cmd} {' '.join(args)}")
37
-
38
- # Run the command
39
- try:
40
- result = subprocess.run([cmd] + args)
41
- sys.exit(result.returncode)
42
- except Exception as e:
43
- print(f"โŒ Error running command: {e}")
44
- sys.exit(1)
45
-
46
- if __name__ == "__main__":
47
- main()
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Test importing and using get_tokens from fetch_modal_tokens
4
- """
5
-
6
- import os
7
- import sys
8
-
9
- def main():
10
- """Main function to test importing and using get_tokens"""
11
- print("๐Ÿ” Testing import of get_tokens from fetch_modal_tokens...")
12
-
13
- # Set a test API key for the script to use
14
- os.environ["GITARSENAL_API_KEY"] = "test_key"
15
-
16
- try:
17
- # Import the function
18
- from fetch_modal_tokens import get_tokens
19
- print("โœ… Successfully imported get_tokens from fetch_modal_tokens")
20
-
21
- # Call the function
22
- print("๐Ÿ”„ Calling get_tokens()...")
23
- token_id, token_secret = get_tokens()
24
-
25
- # Check the results
26
- print("โœ… Successfully called get_tokens()")
27
- print(f" token_id: {token_id[:5]}...{token_id[-5:]}")
28
- print(f" token_secret: {token_secret[:5]}...{token_secret[-5:]}")
29
-
30
- # Check if environment variables were set
31
- if os.environ.get("MODAL_TOKEN_ID") == token_id:
32
- print("โœ… MODAL_TOKEN_ID environment variable set correctly")
33
- else:
34
- print("โŒ MODAL_TOKEN_ID environment variable not set correctly")
35
-
36
- if os.environ.get("MODAL_TOKEN_SECRET") == token_secret:
37
- print("โœ… MODAL_TOKEN_SECRET environment variable set correctly")
38
- else:
39
- print("โŒ MODAL_TOKEN_SECRET environment variable not set correctly")
40
-
41
- # Check if OPENAI_API_KEY was set
42
- if os.environ.get("OPENAI_API_KEY"):
43
- print("โœ… OPENAI_API_KEY environment variable set")
44
- print(f" length: {len(os.environ.get('OPENAI_API_KEY'))}")
45
- else:
46
- print("โŒ OPENAI_API_KEY environment variable not set")
47
-
48
- return True
49
- except Exception as e:
50
- print(f"โŒ Error: {e}")
51
- return False
52
-
53
- if __name__ == "__main__":
54
- success = main()
55
- sys.exit(0 if success else 1)
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Test script to verify LLM debugging functionality
4
- """
5
-
6
- import os
7
- import sys
8
- import requests
9
- import getpass
10
-
11
- def test_openai_connection():
12
- """Test if we can connect to OpenAI API"""
13
- print("๐Ÿ” Testing OpenAI API connection...")
14
-
15
- # Try to get API key
16
- api_key = os.environ.get("OPENAI_API_KEY")
17
- if not api_key:
18
- print("โŒ No OPENAI_API_KEY environment variable found")
19
- print("๐Ÿ’ก Please set your OpenAI API key:")
20
- print(" export OPENAI_API_KEY='your-api-key-here'")
21
- return False
22
-
23
- print(f"โœ… Found API key (length: {len(api_key)})")
24
-
25
- # Test API connection
26
- headers = {
27
- "Content-Type": "application/json",
28
- "Authorization": f"Bearer {api_key}"
29
- }
30
-
31
- payload = {
32
- "model": "gpt-4o-mini",
33
- "messages": [
34
- {"role": "user", "content": "Say 'Hello, LLM debugging is working!'"}
35
- ],
36
- "max_tokens": 50
37
- }
38
-
39
- try:
40
- print("๐Ÿค– Testing API call...")
41
- response = requests.post(
42
- "https://api.openai.com/v1/chat/completions",
43
- headers=headers,
44
- json=payload,
45
- timeout=30
46
- )
47
-
48
- if response.status_code == 200:
49
- result = response.json()
50
- message = result["choices"][0]["message"]["content"]
51
- print(f"โœ… API test successful: {message}")
52
- return True
53
- else:
54
- print(f"โŒ API test failed with status code: {response.status_code}")
55
- print(f"Response: {response.text}")
56
- return False
57
-
58
- except Exception as e:
59
- print(f"โŒ API test failed with exception: {e}")
60
- return False
61
-
62
- def test_llm_debug_function():
63
- """Test the LLM debug function from the main script"""
64
- print("\n๐Ÿ” Testing LLM debug function...")
65
-
66
- # Import the function from the main script
67
- try:
68
- # Add the current directory to Python path
69
- sys.path.insert(0, os.path.dirname(__file__))
70
-
71
- # Import the function
72
- from test_modalSandboxScript import call_openai_for_debug
73
-
74
- # Test with a simple command failure
75
- test_command = "ls /nonexistent/directory"
76
- test_error = "ls: cannot access '/nonexistent/directory': No such file or directory"
77
-
78
- print(f"๐Ÿงช Testing with command: {test_command}")
79
- print(f"๐Ÿงช Error: {test_error}")
80
-
81
- result = call_openai_for_debug(test_command, test_error)
82
-
83
- if result:
84
- print(f"โœ… LLM debug function returned: {result}")
85
- return True
86
- else:
87
- print("โŒ LLM debug function returned None")
88
- return False
89
-
90
- except Exception as e:
91
- print(f"โŒ Error testing LLM debug function: {e}")
92
- return False
93
-
94
- if __name__ == "__main__":
95
- print("๐Ÿงช Testing LLM debugging functionality...")
96
- print("=" * 60)
97
-
98
- # Test 1: OpenAI API connection
99
- api_ok = test_openai_connection()
100
-
101
- # Test 2: LLM debug function
102
- if api_ok:
103
- debug_ok = test_llm_debug_function()
104
- else:
105
- debug_ok = False
106
-
107
- print("\n" + "=" * 60)
108
- print("๐Ÿ“Š Test Results:")
109
- print(f" OpenAI API Connection: {'โœ… PASS' if api_ok else 'โŒ FAIL'}")
110
- print(f" LLM Debug Function: {'โœ… PASS' if debug_ok else 'โŒ FAIL'}")
111
-
112
- if api_ok and debug_ok:
113
- print("\n๐ŸŽ‰ All tests passed! LLM debugging should work.")
114
- else:
115
- print("\nโš ๏ธ Some tests failed. LLM debugging may not work properly.")
116
- if not api_ok:
117
- print("๐Ÿ’ก To fix OpenAI API issues:")
118
- print(" 1. Get an API key from https://platform.openai.com/api-keys")
119
- print(" 2. Set it as environment variable: export OPENAI_API_KEY='your-key'")
120
- print(" 3. Run this test again")