Codez-Agent 0.1.1__tar.gz → 0.2.1__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.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: Codez-Agent
3
+ Version: 0.2.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
+ 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
@@ -1,2 +1,3 @@
1
1
  requests
2
2
  rich
3
+ psutil
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: Codez-Agent
3
+ Version: 0.2.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
+ 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,157 @@
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
+ # Inizializzazione della console
12
+ console = Console()
13
+
14
+ def logo():
15
+ """Pulisce lo schermo e stampa il logo ASCII."""
16
+ os.system('cls' if os.name == 'nt' else 'clear')
17
+ ascii_art = r"""
18
+ [bold cyan]
19
+ /$$$$$$ /$$
20
+ /$$__ $$ | $$
21
+ | $$ \__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$$
22
+ | $$ /$$__ $$ /$$__ $$ /$$__ $$|____ /$$/
23
+ | $$ | $$ \ $$| $$ | $$| $$$$$$$$ /$$$$/
24
+ | $$ $$| $$ \ $$| $$ | $$| $$_____/ /$$__/
25
+ | $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$$$$$$$
26
+ \______/ \______/ \_______/ \_______/|________/
27
+ [/bold cyan]
28
+ """
29
+ console.print(Panel(ascii_art, border_style="cyan", title="CODEZ AGENT v2.1 - Open Source & Accessible"))
30
+
31
+ def scrivi_log(comando, esito):
32
+ """Salva i comandi riusciti in un file di testo locale (Principio: Educativo)."""
33
+ orario = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
34
+ with open("codez_history.txt", "a", encoding="utf-8") as f:
35
+ f.write(f"[{orario}] COMANDO: {comando}\n")
36
+ f.write(f"ESITO: {esito[:150]}...\n")
37
+ f.write("-" * 40 + "\n")
38
+
39
+ def system_doctor():
40
+ """Monitora le risorse del sistema (Principio: Budget 0)."""
41
+ cpu = psutil.cpu_percent(interval=0.5)
42
+ ram = psutil.virtual_memory().percent
43
+ status = "[bold green]OK[/bold green]" if ram < 80 else "[bold red]FULL[/bold red]"
44
+ info = f"💻 CPU: {cpu}% | 🧠 RAM: {ram}% | 📊 Stato: {status}"
45
+ console.print(Panel(info, title="🏥 System Doctor", border_style="blue"))
46
+
47
+ def configura_sessione():
48
+ """Scansione automatica modelli (Principio: Accessibilità)."""
49
+ console.print("\n[italic]Digita 'ollama' o incolla la tua API Key[/italic]")
50
+ key = input("Chiave: ").strip()
51
+
52
+ if key.lower() == "ollama":
53
+ prov, url = "Ollama", "http://localhost:11434/v1"
54
+ try:
55
+ r = requests.get("http://localhost:11434/api/tags", timeout=2)
56
+ modelli = [m['name'] for m in r.json()['models']]
57
+ except:
58
+ modelli = ["llama3", "phi3", "mistral"]
59
+ else:
60
+ prov, url = "Cloud AI", "https://api.groq.com/openai/v1" if key.startswith("gsk_") else "https://api.openai.com/v1"
61
+ modelli = ["gpt-4o", "llama3-70b-8192", "mixtral-8x7b-32768"]
62
+
63
+ console.print("\n[bold yellow]Modelli Rilevati:[/bold yellow]")
64
+ for i, m in enumerate(modelli):
65
+ console.print(f"{i+1}. {m}")
66
+
67
+ scelta = int(Prompt.ask("\nScegli numero", default="1")) - 1
68
+ return key, prov, url, modelli[scelta]
69
+
70
+ def esegui_comando(comando):
71
+ """Esegue comandi, salva i log e rileva errori di installazione."""
72
+ console.print(f"\n[bold orange3]PROPOSTA:[/bold orange3] [white on blue] {comando} [/white on blue]")
73
+
74
+ if Prompt.ask("Eseguire?", choices=["y", "n"], default="y") == "y":
75
+ res = subprocess.run(comando, shell=True, capture_output=True, text=True)
76
+
77
+ # Se il comando ha successo
78
+ if res.returncode == 0:
79
+ console.print("[bold green]Successo![/bold green]")
80
+ scrivi_log(comando, res.stdout)
81
+ return f"Output: {res.stdout}"
82
+
83
+ # Se il comando fallisce (Auto-Installer Logic)
84
+ else:
85
+ errore = res.stderr.lower()
86
+ if "not found" in errore or "non è riconosciuto" in errore:
87
+ console.print(f"[bold red]ERRORE:[/bold red] Sembra che lo strumento per '{comando.split()[0]}' non sia installato.")
88
+ console.print("[yellow]Suggerimento: Prova a chiedere a Codez come installarlo![/yellow]")
89
+ return f"Errore: {res.stderr}"
90
+
91
+ return "Annullato dall'utente."
92
+
93
+ def main():
94
+ logo()
95
+ key, prov, url, mod = configura_sessione()
96
+
97
+ console.print(f"\n[bold green]Codez v2.1 Pronta! ({mod})[/bold green]")
98
+ console.print("[dim]/status | /explain | /history (apre i log) | /stop[/dim]\n")
99
+
100
+ ultimo_comando_proposto = ""
101
+
102
+ while True:
103
+ user_input = input(f"({mod}) > ").strip()
104
+
105
+ if not user_input: continue
106
+ if user_input == "/stop": break
107
+
108
+ if user_input == "/status":
109
+ system_doctor()
110
+ continue
111
+
112
+ if user_input == "/history":
113
+ if os.path.exists("codez_history.txt"):
114
+ os.system('notepad codez_history.txt' if os.name == 'nt' else 'open codez_history.txt')
115
+ else:
116
+ console.print("[yellow]Nessuna cronologia trovata.[/yellow]")
117
+ continue
118
+
119
+ if user_input == "/explain":
120
+ if not ultimo_comando_proposto:
121
+ console.print("[yellow]Nessun comando da spiegare![/yellow]")
122
+ continue
123
+ user_input = f"Spiegami come a un principiante cosa fa: {ultimo_comando_proposto}"
124
+
125
+ # Richiesta all'IA
126
+ prompt_sistema = (
127
+ "Sei Codez, un assistente terminale per neofiti. "
128
+ "Se devi agire sul PC rispondi SOLO con 'COMMAND: ' seguito dal comando. "
129
+ "Se l'utente ha avuto un errore, suggerisci come installare i pacchetti mancanti (es. pip, brew, apt)."
130
+ )
131
+
132
+ payload = {
133
+ "model": mod,
134
+ "messages": [
135
+ {"role": "system", "content": prompt_sistema},
136
+ {"role": "user", "content": user_input}
137
+ ]
138
+ }
139
+
140
+ try:
141
+ h = {"Authorization": f"Bearer {key}"} if key.lower() != "ollama" else {}
142
+ r = requests.post(f"{url}/chat/completions", headers=h, json=payload)
143
+ risposta = r.json()['choices'][0]['message']['content']
144
+
145
+ if "COMMAND: " in risposta:
146
+ cmd = risposta.split("COMMAND: ")[1].strip().replace('`', '')
147
+ ultimo_comando_proposto = cmd
148
+ esito = esegui_comando(cmd)
149
+ console.print(f"[dim]{esito}[/dim]")
150
+ else:
151
+ console.print(f"\n[bold cyan]AI:[/bold cyan] {risposta}\n")
152
+
153
+ except Exception as e:
154
+ console.print(f"[red]Errore critico: {e}[/red]")
155
+
156
+ if __name__ == "__main__":
157
+ 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.1.1',
6
+ version='0.2.1',
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
@@ -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
File without changes
@@ -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