sivan-cli 1.0.0__tar.gz
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.
- sivan_cli-1.0.0/PKG-INFO +5 -0
- sivan_cli-1.0.0/setup.cfg +4 -0
- sivan_cli-1.0.0/setup.py +15 -0
- sivan_cli-1.0.0/sivan.py +96 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/PKG-INFO +5 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/SOURCES.txt +8 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/dependency_links.txt +1 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/entry_points.txt +2 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/requires.txt +1 -0
- sivan_cli-1.0.0/sivan_cli.egg-info/top_level.txt +1 -0
sivan_cli-1.0.0/PKG-INFO
ADDED
sivan_cli-1.0.0/setup.py
ADDED
sivan_cli-1.0.0/sivan.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import argparse
|
|
5
|
+
import requests
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
# Your live server URL!
|
|
9
|
+
API_URL = "https://sivan-code.onrender.com/generate"
|
|
10
|
+
|
|
11
|
+
# This creates a hidden vault on the user's computer to store the auth code
|
|
12
|
+
CONFIG_FILE = os.path.expanduser("~/.sivan_config")
|
|
13
|
+
|
|
14
|
+
def save_auth(code: str):
|
|
15
|
+
"""Saves the secret code locally."""
|
|
16
|
+
with open(CONFIG_FILE, "w") as f:
|
|
17
|
+
json.dump({"auth_code": code}, f)
|
|
18
|
+
print(f"✅ Authentication code saved securely to your computer!")
|
|
19
|
+
|
|
20
|
+
def get_auth() -> str:
|
|
21
|
+
"""Retrieves the saved secret code."""
|
|
22
|
+
if not os.path.exists(CONFIG_FILE):
|
|
23
|
+
print("❌ You need to authenticate first! Run: sivan auth YOUR_SECRET_CODE")
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
with open(CONFIG_FILE, "r") as f:
|
|
26
|
+
return json.load(f).get("auth_code", "")
|
|
27
|
+
|
|
28
|
+
def generate_code(prompt: str):
|
|
29
|
+
"""Sends the prompt to your Render server and saves the result."""
|
|
30
|
+
auth_code = get_auth()
|
|
31
|
+
print(f"🧠 Sivan is thinking about: '{prompt}'...")
|
|
32
|
+
print("⏳ This usually takes 1-3 minutes. Please wait...\n")
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
# Send the request to your Brain
|
|
36
|
+
response = requests.post(
|
|
37
|
+
API_URL,
|
|
38
|
+
json={"auth_code": auth_code, "prompt": prompt},
|
|
39
|
+
timeout=300 # 5-minute timeout because Sivan iterates multiple times
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if response.status_code == 401:
|
|
43
|
+
print("❌ Authentication failed. Your auth code is invalid.")
|
|
44
|
+
sys.exit(1)
|
|
45
|
+
elif response.status_code != 200:
|
|
46
|
+
print(f"❌ Server Error: {response.text}")
|
|
47
|
+
sys.exit(1)
|
|
48
|
+
|
|
49
|
+
data = response.json()
|
|
50
|
+
final_code = data.get("code", "")
|
|
51
|
+
|
|
52
|
+
if not final_code:
|
|
53
|
+
print("❌ No code was generated.")
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
# Save the file to whatever folder the user is currently in
|
|
57
|
+
output_file = "sivan_output.py"
|
|
58
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
|
59
|
+
f.write(final_code)
|
|
60
|
+
|
|
61
|
+
print(f"✅ Success! Code generated and saved to {output_file}")
|
|
62
|
+
|
|
63
|
+
# Magic Trick: Automatically open the file in their default code editor!
|
|
64
|
+
if sys.platform == "win32":
|
|
65
|
+
os.startfile(output_file)
|
|
66
|
+
elif sys.platform == "darwin": # macOS
|
|
67
|
+
subprocess.call(["open", output_file])
|
|
68
|
+
else: # Linux
|
|
69
|
+
subprocess.call(["xdg-open", output_file])
|
|
70
|
+
|
|
71
|
+
except requests.exceptions.Timeout:
|
|
72
|
+
print("❌ The server took too long to respond. Sivan might be writing a massive file!")
|
|
73
|
+
except Exception as e:
|
|
74
|
+
print(f"❌ Connection Error: {str(e)}")
|
|
75
|
+
|
|
76
|
+
def main():
|
|
77
|
+
parser = argparse.ArgumentParser(description="Sivan AI CLI - Your Professional Coding Agent")
|
|
78
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
79
|
+
|
|
80
|
+
# The 'auth' command
|
|
81
|
+
auth_parser = subparsers.add_parser("auth", help="Authenticate with your secret code")
|
|
82
|
+
auth_parser.add_argument("code", type=str, help="Your secret authentication code")
|
|
83
|
+
|
|
84
|
+
# The 'generate' command
|
|
85
|
+
gen_parser = subparsers.add_parser("generate", help="Ask Sivan to build something")
|
|
86
|
+
gen_parser.add_argument("prompt", type=str, help="What do you want to build?")
|
|
87
|
+
|
|
88
|
+
args = parser.parse_args()
|
|
89
|
+
|
|
90
|
+
if args.command == "auth":
|
|
91
|
+
save_auth(args.code)
|
|
92
|
+
elif args.command == "generate":
|
|
93
|
+
generate_code(args.prompt)
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sivan
|