Codez-Agent 0.1.1__tar.gz → 0.2.5__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.2.5/Codez_Agent.egg-info/PKG-INFO +39 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/Codez_Agent.egg-info/requires.txt +1 -0
- codez_agent-0.2.5/PKG-INFO +39 -0
- codez_agent-0.2.5/README.md +14 -0
- codez_agent-0.2.5/codez.py +204 -0
- codez_agent-0.2.5/license +27 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/setup.py +2 -1
- codez_agent-0.1.1/Codez_Agent.egg-info/PKG-INFO +0 -22
- codez_agent-0.1.1/PKG-INFO +0 -22
- codez_agent-0.1.1/README.md +0 -0
- codez_agent-0.1.1/codez.py +0 -134
- codez_agent-0.1.1/license +0 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/Codez_Agent.egg-info/SOURCES.txt +0 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/Codez_Agent.egg-info/dependency_links.txt +0 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/Codez_Agent.egg-info/entry_points.txt +0 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/Codez_Agent.egg-info/top_level.txt +0 -0
- {codez_agent-0.1.1 → codez_agent-0.2.5}/setup.cfg +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Codez-Agent
|
|
3
|
+
Version: 0.2.5
|
|
4
|
+
Summary: Un assistente AI per il terminale con accesso ai comandi
|
|
5
|
+
Home-page: https://github.com/tuonome/codez
|
|
6
|
+
Author: Mattia Ristori
|
|
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
|
+
Requires-Dist: psutil
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# 💻 Codez: Il tuo AI Agent nel Terminale
|
|
27
|
+
|
|
28
|
+
**Codez** è un assistente intelligente per riga di comando che può interagire con il tuo PC, creare file, cartelle e aiutarti a programmare usando i modelli AI più potenti (Ollama, Groq, OpenAI).
|
|
29
|
+
|
|
30
|
+
## 🚀 Caratteristiche
|
|
31
|
+
- **Multi-Provider**: Supporta Ollama (Locale), Groq e OpenAI.
|
|
32
|
+
- **Accesso al Terminale**: Può eseguire comandi (previa tua autorizzazione).
|
|
33
|
+
- **Slash Commands**: Usa `/stop` per uscire e `/change` per cambiare modello al volo.
|
|
34
|
+
- **Sicurezza**: Ogni comando critico richiede la tua conferma (y/n).
|
|
35
|
+
|
|
36
|
+
## 📦 Installazione
|
|
37
|
+
Puoi installarlo direttamente tramite pip:
|
|
38
|
+
```bash
|
|
39
|
+
pip install Codez
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Codez-Agent
|
|
3
|
+
Version: 0.2.5
|
|
4
|
+
Summary: Un assistente AI per il terminale con accesso ai comandi
|
|
5
|
+
Home-page: https://github.com/tuonome/codez
|
|
6
|
+
Author: Mattia Ristori
|
|
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
|
+
Requires-Dist: psutil
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# 💻 Codez: Il tuo AI Agent nel Terminale
|
|
27
|
+
|
|
28
|
+
**Codez** è un assistente intelligente per riga di comando che può interagire con il tuo PC, creare file, cartelle e aiutarti a programmare usando i modelli AI più potenti (Ollama, Groq, OpenAI).
|
|
29
|
+
|
|
30
|
+
## 🚀 Caratteristiche
|
|
31
|
+
- **Multi-Provider**: Supporta Ollama (Locale), Groq e OpenAI.
|
|
32
|
+
- **Accesso al Terminale**: Può eseguire comandi (previa tua autorizzazione).
|
|
33
|
+
- **Slash Commands**: Usa `/stop` per uscire e `/change` per cambiare modello al volo.
|
|
34
|
+
- **Sicurezza**: Ogni comando critico richiede la tua conferma (y/n).
|
|
35
|
+
|
|
36
|
+
## 📦 Installazione
|
|
37
|
+
Puoi installarlo direttamente tramite pip:
|
|
38
|
+
```bash
|
|
39
|
+
pip install Codez
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 💻 Codez: Il tuo AI Agent nel Terminale
|
|
2
|
+
|
|
3
|
+
**Codez** è un assistente intelligente per riga di comando che può interagire con il tuo PC, creare file, cartelle e aiutarti a programmare usando i modelli AI più potenti (Ollama, Groq, OpenAI).
|
|
4
|
+
|
|
5
|
+
## 🚀 Caratteristiche
|
|
6
|
+
- **Multi-Provider**: Supporta Ollama (Locale), Groq e OpenAI.
|
|
7
|
+
- **Accesso al Terminale**: Può eseguire comandi (previa tua autorizzazione).
|
|
8
|
+
- **Slash Commands**: Usa `/stop` per uscire e `/change` per cambiare modello al volo.
|
|
9
|
+
- **Sicurezza**: Ogni comando critico richiede la tua conferma (y/n).
|
|
10
|
+
|
|
11
|
+
## 📦 Installazione
|
|
12
|
+
Puoi installarlo direttamente tramite pip:
|
|
13
|
+
```bash
|
|
14
|
+
pip install Codez
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import subprocess
|
|
4
|
+
import json
|
|
5
|
+
import psutil
|
|
6
|
+
import datetime
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from rich.panel import Panel
|
|
9
|
+
from rich.prompt import Prompt
|
|
10
|
+
|
|
11
|
+
# --- CONFIGURAZIONE GLOBALE ---
|
|
12
|
+
VERSIONE_ATTUALE = "0.2.7"
|
|
13
|
+
console = Console()
|
|
14
|
+
|
|
15
|
+
def logo():
|
|
16
|
+
"""Pulisce lo schermo e stampa il logo ASCII di Codez."""
|
|
17
|
+
os.system('cls' if os.name == 'nt' else 'clear')
|
|
18
|
+
ascii_art = r"""
|
|
19
|
+
[bold cyan]
|
|
20
|
+
/$$$$$$ /$$
|
|
21
|
+
/$$__ $$ | $$
|
|
22
|
+
| $$ \__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$$
|
|
23
|
+
| $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/
|
|
24
|
+
| $$ | $$ \ $$| $$ | $$| $$$$$$$$ /$$$$/
|
|
25
|
+
| $$ $$| $$ \ $$| $$ | $$| $$_____/ /$$__/
|
|
26
|
+
| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$$$$$$$
|
|
27
|
+
\______/ \______/ \_______/ \_______/|________/
|
|
28
|
+
[/bold cyan]
|
|
29
|
+
"""
|
|
30
|
+
console.print(Panel(ascii_art, border_style="cyan", title=f"CODEZ AGENT v{VERSIONE_ATTUALE}"))
|
|
31
|
+
|
|
32
|
+
def check_updates():
|
|
33
|
+
"""Controlla se esiste una nuova versione su PyPI (Accessibilità)."""
|
|
34
|
+
try:
|
|
35
|
+
# Interroga l'API di PyPI per il tuo pacchetto
|
|
36
|
+
response = requests.get("https://pypi.org/pypi/Codez-Agent/json", timeout=1.5)
|
|
37
|
+
ultima_v = response.json()["info"]["version"]
|
|
38
|
+
if ultima_v != VERSIONE_ATTUALE:
|
|
39
|
+
console.print(Panel(f"🚀 [bold yellow]Nuova versione disponibile: {ultima_v}[/bold yellow]\n"
|
|
40
|
+
f"Stai usando la {VERSIONE_ATTUALE}.\n"
|
|
41
|
+
f"Aggiorna con: [cyan]pip install --upgrade Codez-Agent[/cyan]",
|
|
42
|
+
title="Update Check", border_style="yellow"))
|
|
43
|
+
else:
|
|
44
|
+
log_msg("INFO", "Il software è aggiornato.")
|
|
45
|
+
except:
|
|
46
|
+
pass # Se offline o pacchetto non trovato, proseguiamo
|
|
47
|
+
|
|
48
|
+
def log_msg(tipo, messaggio):
|
|
49
|
+
"""Stampa messaggi con tag colorati per migliorare la leggibilità."""
|
|
50
|
+
colori = {
|
|
51
|
+
"INFO": "[bold blue][INFO][/bold blue]",
|
|
52
|
+
"SUCCESS": "[bold green][SUCCESS][/bold green]",
|
|
53
|
+
"WARNING": "[bold yellow][WARNING][/bold yellow]",
|
|
54
|
+
"ERROR": "[bold red][ERROR][/bold red]"
|
|
55
|
+
}
|
|
56
|
+
tag = colori.get(tipo, "[INFO]")
|
|
57
|
+
console.print(f"{tag} {messaggio}")
|
|
58
|
+
|
|
59
|
+
def scrivi_log_md(comando, esito):
|
|
60
|
+
"""Salva la cronologia in formato Markdown (Open Source & Educativo)."""
|
|
61
|
+
orario = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
|
|
62
|
+
file_log = "CODEZ_HISTORY.md"
|
|
63
|
+
|
|
64
|
+
# Puliamo l'esito PRIMA di metterlo nella f-string per evitare l'errore del backslash
|
|
65
|
+
esito_pulito = esito[:200].strip().replace('\n', ' ')
|
|
66
|
+
|
|
67
|
+
# Crea intestazione se il file è nuovo
|
|
68
|
+
if not os.path.exists(file_log):
|
|
69
|
+
with open(file_log, "w", encoding="utf-8") as f:
|
|
70
|
+
f.write("# 📜 Diario di Bordo Codez Agent\n\n")
|
|
71
|
+
f.write("In questo file trovi tutti i comandi che hai imparato a usare.\n\n")
|
|
72
|
+
|
|
73
|
+
with open(file_log, "a", encoding="utf-8") as f:
|
|
74
|
+
f.write(f"### 🕒 Sessione: {orario}\n")
|
|
75
|
+
f.write(f"**💻 Comando Terminale:**\n```bash\n{comando}\n```\n")
|
|
76
|
+
f.write(f"**📝 Risultato (estratto):**\n> {esito_pulito}...\n\n")
|
|
77
|
+
f.write("---\n")
|
|
78
|
+
|
|
79
|
+
def system_doctor():
|
|
80
|
+
"""Monitora le risorse hardware (Principio Budget 0)."""
|
|
81
|
+
cpu = psutil.cpu_percent(interval=0.5)
|
|
82
|
+
ram = psutil.virtual_memory().percent
|
|
83
|
+
|
|
84
|
+
status = "[bold green]OTTIMO[/bold green]" if ram < 75 else "[bold red]CRITICO[/bold red]"
|
|
85
|
+
color = "green" if ram < 75 else "red"
|
|
86
|
+
|
|
87
|
+
panel_content = f"💻 CPU: {cpu}% | 🧠 RAM: {ram}% | Stato: {status}"
|
|
88
|
+
console.print(Panel(panel_content, title="🏥 System Doctor", border_style=color))
|
|
89
|
+
|
|
90
|
+
def configura_sessione():
|
|
91
|
+
"""Configura il provider e scansiona i modelli disponibili."""
|
|
92
|
+
console.print("\n[italic]Inserisci 'ollama' per locale o la tua API Key per il cloud[/italic]")
|
|
93
|
+
key = input("Chiave: ").strip()
|
|
94
|
+
|
|
95
|
+
if key.lower() == "ollama":
|
|
96
|
+
prov, url = "Ollama", "http://localhost:11434/v1"
|
|
97
|
+
try:
|
|
98
|
+
r = requests.get("http://localhost:11434/api/tags", timeout=2)
|
|
99
|
+
modelli = [m['name'] for m in r.json()['models']]
|
|
100
|
+
except:
|
|
101
|
+
log_msg("WARNING", "Ollama non risponde. Uso modelli predefiniti.")
|
|
102
|
+
modelli = ["llama3", "phi3", "mistral"]
|
|
103
|
+
else:
|
|
104
|
+
prov, url = "Cloud AI", "https://api.groq.com/openai/v1" if key.startswith("gsk_") else "https://api.openai.com/v1"
|
|
105
|
+
modelli = ["gpt-4o", "llama3-70b-8192", "mixtral-8x7b-32768"]
|
|
106
|
+
|
|
107
|
+
console.print("\n[bold yellow]Modelli Rilevati:[/bold yellow]")
|
|
108
|
+
for i, m in enumerate(modelli):
|
|
109
|
+
console.print(f"{i+1}. {m}")
|
|
110
|
+
|
|
111
|
+
scelta = int(Prompt.ask("\nQuale modello vuoi usare?", default="1")) - 1
|
|
112
|
+
return key, prov, url, modelli[scelta]
|
|
113
|
+
|
|
114
|
+
def esegui_comando(comando):
|
|
115
|
+
"""Esegue il comando, gestisce gli errori e salva il log Markdown."""
|
|
116
|
+
console.print(f"\n[bold orange3]PROPOSTA COMANDO:[/bold orange3] [white on blue] {comando} [/white on blue]")
|
|
117
|
+
|
|
118
|
+
if Prompt.ask("Vuoi eseguire?", choices=["y", "n"], default="y") == "y":
|
|
119
|
+
try:
|
|
120
|
+
res = subprocess.run(comando, shell=True, capture_output=True, text=True)
|
|
121
|
+
|
|
122
|
+
if res.returncode == 0:
|
|
123
|
+
log_msg("SUCCESS", "Eseguito correttamente.")
|
|
124
|
+
scrivi_log_md(comando, res.stdout)
|
|
125
|
+
return f"OUTPUT:\n{res.stdout}"
|
|
126
|
+
else:
|
|
127
|
+
log_msg("ERROR", f"Il terminale ha risposto: {res.stderr}")
|
|
128
|
+
# Logghiamo anche l'errore per studiarlo
|
|
129
|
+
scrivi_log_md(comando, f"ERRORE: {res.stderr}")
|
|
130
|
+
return f"ERRORE:\n{res.stderr}"
|
|
131
|
+
except Exception as e:
|
|
132
|
+
log_msg("ERROR", f"Errore di sistema: {e}")
|
|
133
|
+
return str(e)
|
|
134
|
+
|
|
135
|
+
return "Esecuzione annullata."
|
|
136
|
+
|
|
137
|
+
def main():
|
|
138
|
+
logo()
|
|
139
|
+
check_updates() # Controlla PyPI all'avvio
|
|
140
|
+
|
|
141
|
+
key, prov, url, mod = configura_sessione()
|
|
142
|
+
log_msg("SUCCESS", f"Codez è attivo! Modello: {mod}")
|
|
143
|
+
console.print("[dim]Comandi speciali: /status | /history | /explain | /stop[/dim]\n")
|
|
144
|
+
|
|
145
|
+
ultimo_comando_generato = ""
|
|
146
|
+
|
|
147
|
+
while True:
|
|
148
|
+
user_input = input(f"({mod}) > ").strip()
|
|
149
|
+
|
|
150
|
+
if not user_input: continue
|
|
151
|
+
if user_input == "/stop": break
|
|
152
|
+
|
|
153
|
+
if user_input == "/status":
|
|
154
|
+
system_doctor()
|
|
155
|
+
continue
|
|
156
|
+
|
|
157
|
+
if user_input == "/history":
|
|
158
|
+
log_msg("INFO", "Apro il diario Markdown...")
|
|
159
|
+
os.system('notepad CODEZ_HISTORY.md' if os.name == 'nt' else 'open CODEZ_HISTORY.md')
|
|
160
|
+
continue
|
|
161
|
+
|
|
162
|
+
if user_input == "/explain":
|
|
163
|
+
if not ultimo_comando_generato:
|
|
164
|
+
log_msg("WARNING", "Non ci sono ancora comandi da spiegare.")
|
|
165
|
+
continue
|
|
166
|
+
user_input = f"Spiegami come a un principiante cosa fa questo comando: {ultimo_comando_generato}"
|
|
167
|
+
log_msg("INFO", "Generazione spiegazione...")
|
|
168
|
+
|
|
169
|
+
# --- LOGICA INTELLIGENZA ARTIFICIALE ---
|
|
170
|
+
prompt_sistema = (
|
|
171
|
+
"Sei Codez, un assistente terminale open-source. "
|
|
172
|
+
"Se devi suggerire un'azione, usa sempre il prefisso 'COMMAND: ' seguito dal codice. "
|
|
173
|
+
"Se l'utente chiede spiegazioni, sii semplice e accessibile. "
|
|
174
|
+
"Usa un tono amichevole ma professionale."
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
payload = {
|
|
178
|
+
"model": mod,
|
|
179
|
+
"messages": [
|
|
180
|
+
{"role": "system", "content": prompt_sistema},
|
|
181
|
+
{"role": "user", "content": user_input}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
try:
|
|
186
|
+
headers = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
|
|
187
|
+
r = requests.post(f"{url}/chat/completions", headers=headers, json=payload)
|
|
188
|
+
r.raise_for_status()
|
|
189
|
+
risposta = r.json()['choices'][0]['message']['content']
|
|
190
|
+
|
|
191
|
+
if "COMMAND: " in risposta:
|
|
192
|
+
# Estraiamo il comando pulito
|
|
193
|
+
cmd = risposta.split("COMMAND: ")[1].strip().replace('`', '')
|
|
194
|
+
ultimo_comando_generato = cmd
|
|
195
|
+
esito = esegui_comando(cmd)
|
|
196
|
+
console.print(f"[dim]{esito}[/dim]")
|
|
197
|
+
else:
|
|
198
|
+
console.print(f"\n[cyan]AI:[/cyan] {risposta}\n")
|
|
199
|
+
|
|
200
|
+
except Exception as e:
|
|
201
|
+
log_msg("ERROR", f"Impossibile connettersi all'IA: {e}")
|
|
202
|
+
|
|
203
|
+
if __name__ == "__main__":
|
|
204
|
+
main()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
### 2. Il file `LICENSE`
|
|
4
|
+
Useremo la **MIT License**. È la licenza più usata nel mondo Open Source perché è corta, semplice e dice: "Puoi farci quello che vuoi, basta che non mi dai la colpa se qualcosa si rompe".
|
|
5
|
+
|
|
6
|
+
```text
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 [IL TUO NOME O NICKNAME]
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
@@ -3,7 +3,7 @@ from setuptools import setup
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name='Codez-Agent', # Prova a usare un nome unico come questo
|
|
6
|
-
version='0.
|
|
6
|
+
version='0.2.5',
|
|
7
7
|
description='Un assistente AI per il terminale con accesso ai comandi',
|
|
8
8
|
long_description=open('README.md').read(),
|
|
9
9
|
long_description_content_type='text/markdown',
|
|
@@ -13,6 +13,7 @@ setup(
|
|
|
13
13
|
install_requires=[
|
|
14
14
|
'requests',
|
|
15
15
|
'rich',
|
|
16
|
+
'psutil',
|
|
16
17
|
],
|
|
17
18
|
entry_points={
|
|
18
19
|
'console_scripts': [
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: Codez-Agent
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: Un assistente AI per il terminale con accesso ai comandi
|
|
5
|
-
Home-page: https://github.com/tuonome/codez
|
|
6
|
-
Author: Mattia Ristori
|
|
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
|
codez_agent-0.1.1/PKG-INFO
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: Codez-Agent
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: Un assistente AI per il terminale con accesso ai comandi
|
|
5
|
-
Home-page: https://github.com/tuonome/codez
|
|
6
|
-
Author: Mattia Ristori
|
|
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
|
codez_agent-0.1.1/README.md
DELETED
|
File without changes
|
codez_agent-0.1.1/codez.py
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
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
|
-
# Inizializzazione della console per i colori e lo stile
|
|
10
|
-
console = Console()
|
|
11
|
-
|
|
12
|
-
def logo():
|
|
13
|
-
"""Pulisce lo schermo e stampa il logo ASCII."""
|
|
14
|
-
os.system('cls' if os.name == 'nt' else 'clear')
|
|
15
|
-
# Usiamo r""" per evitare che i backslash vengano interpretati male
|
|
16
|
-
ascii_art = r"""
|
|
17
|
-
[bold cyan]
|
|
18
|
-
/$$$$$$ /$$
|
|
19
|
-
/$$__ $$ | $$
|
|
20
|
-
| $$ \__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$$
|
|
21
|
-
| $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/
|
|
22
|
-
| $$ | $$ \ $$| $$ | $$| $$$$$$$$ /$$$$/
|
|
23
|
-
| $$ $$| $$ \ $$| $$ | $$| $$_____/ /$$__/
|
|
24
|
-
| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$$$$$$$
|
|
25
|
-
\______/ \______/ \_______/ \_______/|________/
|
|
26
|
-
[/bold cyan]
|
|
27
|
-
"""
|
|
28
|
-
console.print(Panel(ascii_art, border_style="cyan", title="AI AGENT TERMINAL"))
|
|
29
|
-
|
|
30
|
-
def configura_sessione():
|
|
31
|
-
"""Gestisce la scelta del provider e del modello."""
|
|
32
|
-
console.print("\n[italic]Digita 'ollama' per locale, oppure incolla la tua API Key (Groq/OpenAI)[/italic]")
|
|
33
|
-
key = input("Chiave o 'ollama': ").strip()
|
|
34
|
-
|
|
35
|
-
if key.lower() == "ollama":
|
|
36
|
-
prov, url = "Ollama", "http://localhost:11434/v1"
|
|
37
|
-
elif key.startswith("gsk_"):
|
|
38
|
-
prov, url = "Groq", "https://api.groq.com/openai/v1"
|
|
39
|
-
else:
|
|
40
|
-
prov, url = "OpenAI", "https://api.openai.com/v1"
|
|
41
|
-
|
|
42
|
-
headers = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
|
|
43
|
-
|
|
44
|
-
# Tentativo di recupero modelli disponibili
|
|
45
|
-
try:
|
|
46
|
-
r = requests.get(f"{url}/models", headers=headers, timeout=2)
|
|
47
|
-
if r.status_code == 200:
|
|
48
|
-
modelli = [m['id'] for m in r.json()['data']][:10]
|
|
49
|
-
else:
|
|
50
|
-
modelli = ["gpt-4o", "llama3", "mistral", "phi3"]
|
|
51
|
-
except:
|
|
52
|
-
modelli = ["gpt-4o", "llama3", "mistral", "phi3"]
|
|
53
|
-
|
|
54
|
-
console.print("\n[bold yellow]Modelli disponibili:[/bold yellow]")
|
|
55
|
-
for i, m in enumerate(modelli):
|
|
56
|
-
console.print(f"{i+1}. {m}")
|
|
57
|
-
|
|
58
|
-
scelta = int(Prompt.ask("\nScegli il numero del modello", default="1")) - 1
|
|
59
|
-
return key, prov, url, modelli[scelta]
|
|
60
|
-
|
|
61
|
-
def esegui_comando(comando):
|
|
62
|
-
"""Esegue un comando sul terminale dopo conferma dell'utente."""
|
|
63
|
-
console.print(f"\n[bold orange3]L'AI vuole eseguire:[/bold orange3] [green]{comando}[/green]")
|
|
64
|
-
conferma = Prompt.ask("Vuoi procedere?", choices=["y", "n"], default="n")
|
|
65
|
-
|
|
66
|
-
if conferma == "y":
|
|
67
|
-
try:
|
|
68
|
-
res = subprocess.run(comando, shell=True, capture_output=True, text=True)
|
|
69
|
-
console.print("[bold green]Eseguito con successo.[/bold green]")
|
|
70
|
-
return f"Output: {res.stdout}\nErrori: {res.stderr}"
|
|
71
|
-
except Exception as e:
|
|
72
|
-
return f"Errore durante l'esecuzione: {e}"
|
|
73
|
-
return "Esecuzione annullata dall'utente."
|
|
74
|
-
|
|
75
|
-
def main():
|
|
76
|
-
"""Funzione principale che avvia il programma."""
|
|
77
|
-
logo()
|
|
78
|
-
key, prov, url, mod = configura_sessione()
|
|
79
|
-
|
|
80
|
-
console.print(f"\n[bold green]CONNESSO A: {prov} ({mod})[/bold green]")
|
|
81
|
-
console.print("[dim]Comandi speciali: /stop (esci), /change (cambia modello)[/dim]\n")
|
|
82
|
-
|
|
83
|
-
while True:
|
|
84
|
-
user_input = input(f"({mod}) > ").strip()
|
|
85
|
-
|
|
86
|
-
if not user_input:
|
|
87
|
-
continue
|
|
88
|
-
|
|
89
|
-
if user_input == "/stop":
|
|
90
|
-
console.print("[bold red]Chiusura in corso... Ciao![/bold red]")
|
|
91
|
-
break
|
|
92
|
-
|
|
93
|
-
if user_input == "/change":
|
|
94
|
-
key, prov, url, mod = configura_sessione()
|
|
95
|
-
console.print(f"\n[bold green]Passato a: {prov} ({mod})[/bold green]")
|
|
96
|
-
continue
|
|
97
|
-
|
|
98
|
-
# Logica della richiesta AI
|
|
99
|
-
prompt_sistema = (
|
|
100
|
-
"Sei Codez, un assistente terminale. "
|
|
101
|
-
"Se l'utente ti chiede di fare qualcosa sul PC (creare file, cartelle, ecc.), "
|
|
102
|
-
"rispondi SOLO con 'COMMAND: ' seguito dal comando da eseguire. "
|
|
103
|
-
"Altrimenti rispondi normalmente."
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
payload = {
|
|
107
|
-
"model": mod,
|
|
108
|
-
"messages": [
|
|
109
|
-
{"role": "system", "content": prompt_sistema},
|
|
110
|
-
{"role": "user", "content": user_input}
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
try:
|
|
115
|
-
h = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
|
|
116
|
-
r = requests.post(f"{url}/chat/completions", headers=h, json=payload)
|
|
117
|
-
r.raise_for_status()
|
|
118
|
-
risposta = r.json()['choices'][0]['message']['content']
|
|
119
|
-
|
|
120
|
-
if "COMMAND: " in risposta:
|
|
121
|
-
cmd = risposta.split("COMMAND: ")[1].strip()
|
|
122
|
-
# Rimuove eventuali virgolette se l'AI le aggiunge per errore
|
|
123
|
-
cmd = cmd.replace('`', '')
|
|
124
|
-
esito = esegui_comando(cmd)
|
|
125
|
-
console.print(f"[dim]{esito}[/dim]")
|
|
126
|
-
else:
|
|
127
|
-
console.print(f"\n[bold cyan]AI:[/bold cyan] {risposta}\n")
|
|
128
|
-
|
|
129
|
-
except Exception as e:
|
|
130
|
-
console.print(f"[bold red]Errore di connessione:[/bold red] {e}")
|
|
131
|
-
console.print("[yellow]Assicurati che Ollama sia attivo o che la Key sia corretta.[/yellow]")
|
|
132
|
-
|
|
133
|
-
if __name__ == "__main__":
|
|
134
|
-
main()
|
codez_agent-0.1.1/license
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|