Codez-Agent 0.1.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.
- codez_agent-0.1.0/Codez_Agent.egg-info/PKG-INFO +22 -0
- codez_agent-0.1.0/Codez_Agent.egg-info/SOURCES.txt +10 -0
- codez_agent-0.1.0/Codez_Agent.egg-info/dependency_links.txt +1 -0
- codez_agent-0.1.0/Codez_Agent.egg-info/entry_points.txt +2 -0
- codez_agent-0.1.0/Codez_Agent.egg-info/requires.txt +2 -0
- codez_agent-0.1.0/Codez_Agent.egg-info/top_level.txt +1 -0
- codez_agent-0.1.0/PKG-INFO +22 -0
- codez_agent-0.1.0/README.md +0 -0
- codez_agent-0.1.0/codez.py +115 -0
- codez_agent-0.1.0/license +0 -0
- codez_agent-0.1.0/setup.cfg +4 -0
- codez_agent-0.1.0/setup.py +28 -0
|
@@ -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,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
codez.py
|
|
3
|
+
license
|
|
4
|
+
setup.py
|
|
5
|
+
Codez_Agent.egg-info/PKG-INFO
|
|
6
|
+
Codez_Agent.egg-info/SOURCES.txt
|
|
7
|
+
Codez_Agent.egg-info/dependency_links.txt
|
|
8
|
+
Codez_Agent.egg-info/entry_points.txt
|
|
9
|
+
Codez_Agent.egg-info/requires.txt
|
|
10
|
+
Codez_Agent.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
codez
|
|
@@ -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
|
|
File without changes
|
|
@@ -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()
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name='Codez-Agent', # Prova a usare un nome unico come questo
|
|
6
|
+
version='0.1.0',
|
|
7
|
+
description='Un assistente AI per il terminale con accesso ai comandi',
|
|
8
|
+
long_description=open('README.md').read(),
|
|
9
|
+
long_description_content_type='text/markdown',
|
|
10
|
+
author='Il Tuo Nome',
|
|
11
|
+
url='https://github.com/tuonome/codez', # Puoi mettere un link a caso per ora
|
|
12
|
+
py_modules=['codez'],
|
|
13
|
+
install_requires=[
|
|
14
|
+
'requests',
|
|
15
|
+
'rich',
|
|
16
|
+
],
|
|
17
|
+
entry_points={
|
|
18
|
+
'console_scripts': [
|
|
19
|
+
'Codez=codez:main',
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
classifiers=[
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Operating System :: OS Independent",
|
|
26
|
+
],
|
|
27
|
+
python_requires='>=3.6',
|
|
28
|
+
)
|