Codez-Agent 0.1.0__py3-none-any.whl

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.
codez.py ADDED
@@ -0,0 +1,115 @@
1
+ import os
2
+ import requests
3
+ import subprocess
4
+ import json
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+ from rich.prompt import Prompt
8
+
9
+ console = Console()
10
+
11
+ def logo():
12
+ os.system('cls' if os.name == 'nt' else 'clear')
13
+ ascii_art = r"""
14
+ [bold cyan]
15
+ /$$$$$$ /$$
16
+ /$$__ $$ | $$
17
+ | $$ \__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$$
18
+ | $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/
19
+ | $$ | $$ \ $$| $$ | $$| $$$$$$$$ /$$$$/
20
+ | $$ $$| $$ \ $$| $$ | $$| $$_____/ /$$__/
21
+ | $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$$$$$$$
22
+ \______/ \______/ \_______/ \_______/|________/
23
+ [/bold cyan]
24
+ [bold yellow]>>> AI AGENT TERMINAL <<<[/bold yellow]
25
+ [dim]Local Ollama | Groq | OpenAI | Universal API[/dim]
26
+ """
27
+ console.print(Panel(ascii_art, border_style="cyan"))
28
+
29
+ def rileva_configurazione(api_key):
30
+ if api_key.lower() == "ollama":
31
+ return "Ollama (Locale)", "http://localhost:11434/v1"
32
+ elif api_key.startswith("gsk_"):
33
+ return "Groq", "https://api.groq.com/openai/v1"
34
+ elif api_key.startswith("sk-"):
35
+ return "OpenAI/OpenRouter", "https://openrouter.ai/api/v1"
36
+ else:
37
+ return "Custom/OpenAI", "https://api.openai.com/v1"
38
+
39
+ def ottieni_modelli(url, key):
40
+ try:
41
+ headers = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
42
+ r = requests.get(f"{url}/models", headers=headers, timeout=3)
43
+ modelli = [m['id'] for m in r.json()['data']]
44
+ return modelli[:15]
45
+ except:
46
+ if "localhost" in url:
47
+ return ["llama3", "mistral", "phi3"] # Modelli comuni di Ollama
48
+ return ["gpt-3.5-turbo", "google/gemini-2.0-flash-001:free"]
49
+
50
+ def esegui_comando_sicuro(comando):
51
+ console.print(f"\n[bold red]RICHIESTA DI SISTEMA:[/bold red] Eseguire [bold yellow]{comando}[/bold yellow]?")
52
+ conferma = Prompt.ask("Confermi l'azione?", choices=["y", "n"], default="n")
53
+
54
+ if conferma == 'y':
55
+ try:
56
+ # shell=True permette di usare comandi complessi come mkdir o touch
57
+ risultato = subprocess.run(comando, shell=True, capture_output=True, text=True)
58
+ output = risultato.stdout if risultato.stdout else "Comando eseguito (nessun output)."
59
+ errori = risultato.stderr if risultato.stderr else "Nessun errore."
60
+ return f"--- OUTPUT ---\n{output}\n--- ERRORI ---\n{errori}"
61
+ except Exception as e:
62
+ return f"Errore critico durante l'esecuzione: {e}"
63
+ return "Operazione annullata."
64
+
65
+ def avvio():
66
+ logo()
67
+ console.print("[italic]Scrivi 'ollama' se vuoi usare il tuo PC locale, altrimenti incolla la tua Key.[/italic]")
68
+ key = input("Inserisci API KEY o 'ollama': ").strip()
69
+
70
+ nome_prov, base_url = rileva_configurazione(key)
71
+ console.print(f"\n[bold green]Connessione a:[/bold green] {nome_prov}")
72
+
73
+ modelli = ottieni_modelli(base_url, key)
74
+ console.print("\n[bold]Modelli disponibili:[/bold]")
75
+ for i, m in enumerate(modelli):
76
+ print(f"{i+1}. {m}")
77
+
78
+ scelta = int(Prompt.ask("\nSeleziona il modello", default="1")) - 1
79
+ modello_scelto = modelli[scelta]
80
+
81
+ console.print(f"\n[bold blue]CODEZ ATTIVO con {modello_scelto}[/bold blue]")
82
+
83
+ while True:
84
+ user_input = input("\n(Codez) > ")
85
+ if user_input.lower() in ["exit", "esci"]: break
86
+
87
+ prompt_sistema = """Sei Codez, un agente terminale.
88
+ Se l'utente vuole creare, spostare, eliminare file o cartelle, rispondi con 'COMMAND: ' seguito dal comando DOS/Windows.
89
+ Esempio: COMMAND: mkdir nuova_cartella
90
+ IMPORTANTE: Sii conciso."""
91
+
92
+ payload = {
93
+ "model": modello_scelto,
94
+ "messages": [
95
+ {"role": "system", "content": prompt_sistema},
96
+ {"role": "user", "content": user_input}
97
+ ]
98
+ }
99
+
100
+ try:
101
+ headers = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
102
+ r = requests.post(f"{base_url}/chat/completions", headers=headers, json=payload)
103
+ risposta = r.json()['choices'][0]['message']['content']
104
+
105
+ if "COMMAND: " in risposta:
106
+ comando = risposta.split("COMMAND: ")[1].strip()
107
+ risultato = esegui_comando_sicuro(comando)
108
+ console.print(Panel(risultato, border_style="yellow"))
109
+ else:
110
+ console.print(f"\n[bold cyan]Codez AI:[/bold cyan] {risposta}")
111
+ except Exception as e:
112
+ console.print(f"[red]Errore: {e}[/red]")
113
+
114
+ if __name__ == "__main__":
115
+ avvio()
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: Codez-Agent
3
+ Version: 0.1.0
4
+ Summary: Un assistente AI per il terminale con accesso ai comandi
5
+ Home-page: https://github.com/tuonome/codez
6
+ Author: Il Tuo Nome
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: license
13
+ Requires-Dist: requests
14
+ Requires-Dist: rich
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description-content-type
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: requires-dist
21
+ Dynamic: requires-python
22
+ Dynamic: summary
@@ -0,0 +1,7 @@
1
+ codez.py,sha256=HRGF_KTfAfR3bmT2fcoAn1UEFiHTQMLC-5I4VNlKrj0,4727
2
+ codez_agent-0.1.0.dist-info/licenses/license,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ codez_agent-0.1.0.dist-info/METADATA,sha256=v5byG_4ge79dWzSqZrMBwpz9i9uaEBMJ2Zyfy5hCUe8,658
4
+ codez_agent-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ codez_agent-0.1.0.dist-info/entry_points.txt,sha256=GekZLmrqwaf8uny62cN31ThXECpo7WTvs174FjrGKVg,37
6
+ codez_agent-0.1.0.dist-info/top_level.txt,sha256=0AHhecdLUWr7jQsvc8I0m3rPkZktNGATKkii8H3QO8A,6
7
+ codez_agent-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ Codez = codez:main
File without changes
@@ -0,0 +1 @@
1
+ codez