code-daza 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.
- code_daza-1.0.0/PKG-INFO +113 -0
- code_daza-1.0.0/README.md +81 -0
- code_daza-1.0.0/code_daza/__init__.py +8 -0
- code_daza-1.0.0/code_daza/agent.py +877 -0
- code_daza-1.0.0/code_daza.egg-info/PKG-INFO +113 -0
- code_daza-1.0.0/code_daza.egg-info/SOURCES.txt +10 -0
- code_daza-1.0.0/code_daza.egg-info/dependency_links.txt +1 -0
- code_daza-1.0.0/code_daza.egg-info/entry_points.txt +2 -0
- code_daza-1.0.0/code_daza.egg-info/requires.txt +7 -0
- code_daza-1.0.0/code_daza.egg-info/top_level.txt +1 -0
- code_daza-1.0.0/pyproject.toml +59 -0
- code_daza-1.0.0/setup.cfg +4 -0
code_daza-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: code-daza
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Universal Autonomous AI Engineering, Architecture & UI/UX CLI Agent powered by Gemini 3.7 Flash
|
|
5
|
+
Author: Dazaeev
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/dazaeev/code-daza
|
|
8
|
+
Project-URL: Documentation, https://github.com/dazaeev/code-daza#readme
|
|
9
|
+
Keywords: ai,agent,cli,gemini,software-engineering,architecture,devops,code-assistant,automation
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
23
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Requires-Dist: google-genai>=1.0.0
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: pillow>=10.0.0
|
|
30
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
31
|
+
Requires-Dist: pywin32>=306; platform_system == "Windows"
|
|
32
|
+
|
|
33
|
+
# CODE DAZA (v1.0.0)
|
|
34
|
+
|
|
35
|
+
**Universal Autonomous AI Engineering, Architecture, DevOps & UI/UX Runtime**
|
|
36
|
+
Powered by Google Gemini 3.7 Flash & Google Image Gen.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Que es CODE DAZA?
|
|
41
|
+
|
|
42
|
+
**CODE DAZA** es un agente autonomo de ingenieria de software que opera directamente desde tu terminal de consola. Actua con el rigor tecnico y los criterios de:
|
|
43
|
+
- **Lead Software Architect:** Diseno y auditoria de microservicios, monolitos, bases de datos y seguridad.
|
|
44
|
+
- **Full Stack Engineer Sr:** Inspeccion y modificacion quirurgica de codigo en cualquier lenguaje (Java, TypeScript, Python, Go, Rust, C++, C#, etc.).
|
|
45
|
+
- **DevOps & SRE:** Ejecucion y validacion de comandos de consola, compiladores (Maven, NPM, Cargo, Gradle) y pruebas unitarias.
|
|
46
|
+
- **UI/UX Designer & Image Generator:** Generacion nativa de imagenes, logotipos e iconos en PNG de alta resolucion con IA.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Instalacion Global (PyPI)
|
|
51
|
+
|
|
52
|
+
Puedes instalar CODE DAZA en cualquier computadora (Windows, Mac o Linux) con un solo comando:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install code-daza
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Como Ejecutarlo?
|
|
61
|
+
|
|
62
|
+
Una vez instalado, simplemente abre cualquier terminal en la carpeta de cualquier proyecto y escribe:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
code-daza
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Caracteristicas Principales
|
|
71
|
+
|
|
72
|
+
1. **Agnostico y Universal:**
|
|
73
|
+
- Funciona sobre cualquier stack, framework o lenguaje.
|
|
74
|
+
- Navegacion multi-proyecto: puede cruzar y sincronizar codigo entre diferentes carpetas y repositorios.
|
|
75
|
+
|
|
76
|
+
2. **Telemetria Panoramica en Tiempo Real:**
|
|
77
|
+
- Subventana compacta con diseno cyberpunk y bordes redondeados.
|
|
78
|
+
- Monitoreo en vivo de archivos leidos, lineas modificadas y ejecucion de comandos sin parpadeos ni desbordes de buffer en Windows CMD.
|
|
79
|
+
|
|
80
|
+
3. **Vision Multimodal & Capturas de Pantalla:**
|
|
81
|
+
- Copia cualquier error o diseno con `Win + Shift + S`.
|
|
82
|
+
- Presiona `Ctrl + V` en la terminal para adjuntar automaticamente `[clipboard image X]` al agente.
|
|
83
|
+
|
|
84
|
+
4. **Entrada Multilinea Nativa:**
|
|
85
|
+
- Permite pegar fragmentos extensos de codigo, JSON o prompts con multiples saltos de linea sin que se corte ni se dispare accidentalmente.
|
|
86
|
+
- Sanitizador inteligente de retornos de carro.
|
|
87
|
+
|
|
88
|
+
5. **Candados de Seguridad e Inmutabilidad (Enterprise Guardrails):**
|
|
89
|
+
- **Inmutable Core:** El agente no puede borrarse ni modificarse a si mismo.
|
|
90
|
+
- **Destructive Command Blocker:** Bloqueo automatico de comandos destructivos masivos (`rmdir /s /q`, `rm -rf /`, etc.).
|
|
91
|
+
- **Credential Protection:** Proteccion activa contra filtracion de llaves maestras o certificados privados.
|
|
92
|
+
|
|
93
|
+
6. **Generacion Nativa de Imagenes:**
|
|
94
|
+
- Crea logotipos, portadas e iconos en formato PNG directamente en disco mediante la herramienta `generate_image`.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Configuracion de API Key
|
|
99
|
+
|
|
100
|
+
Al iniciarse por primera vez, CODE DAZA solicitara tu **Gemini API Key** (de Google AI Studio o Google Cloud Vertex) y la almacenara de forma segura en tu perfil de usuario local (`~/.daza_gemini_key`). Nunca tendras que volver a escribirla.
|
|
101
|
+
|
|
102
|
+
Tambien puedes definirla como variable de entorno:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export GEMINI_API_KEY="tu_api_key_aqui" # Linux / Mac
|
|
106
|
+
setx GEMINI_API_KEY "tu_api_key_aqui" # Windows CMD
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Licencia
|
|
112
|
+
|
|
113
|
+
Distribuido bajo la Licencia MIT. Consulta el archivo `LICENSE` para mas detalles.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# CODE DAZA (v1.0.0)
|
|
2
|
+
|
|
3
|
+
**Universal Autonomous AI Engineering, Architecture, DevOps & UI/UX Runtime**
|
|
4
|
+
Powered by Google Gemini 3.7 Flash & Google Image Gen.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Que es CODE DAZA?
|
|
9
|
+
|
|
10
|
+
**CODE DAZA** es un agente autonomo de ingenieria de software que opera directamente desde tu terminal de consola. Actua con el rigor tecnico y los criterios de:
|
|
11
|
+
- **Lead Software Architect:** Diseno y auditoria de microservicios, monolitos, bases de datos y seguridad.
|
|
12
|
+
- **Full Stack Engineer Sr:** Inspeccion y modificacion quirurgica de codigo en cualquier lenguaje (Java, TypeScript, Python, Go, Rust, C++, C#, etc.).
|
|
13
|
+
- **DevOps & SRE:** Ejecucion y validacion de comandos de consola, compiladores (Maven, NPM, Cargo, Gradle) y pruebas unitarias.
|
|
14
|
+
- **UI/UX Designer & Image Generator:** Generacion nativa de imagenes, logotipos e iconos en PNG de alta resolucion con IA.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Instalacion Global (PyPI)
|
|
19
|
+
|
|
20
|
+
Puedes instalar CODE DAZA en cualquier computadora (Windows, Mac o Linux) con un solo comando:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install code-daza
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Como Ejecutarlo?
|
|
29
|
+
|
|
30
|
+
Una vez instalado, simplemente abre cualquier terminal en la carpeta de cualquier proyecto y escribe:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
code-daza
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Caracteristicas Principales
|
|
39
|
+
|
|
40
|
+
1. **Agnostico y Universal:**
|
|
41
|
+
- Funciona sobre cualquier stack, framework o lenguaje.
|
|
42
|
+
- Navegacion multi-proyecto: puede cruzar y sincronizar codigo entre diferentes carpetas y repositorios.
|
|
43
|
+
|
|
44
|
+
2. **Telemetria Panoramica en Tiempo Real:**
|
|
45
|
+
- Subventana compacta con diseno cyberpunk y bordes redondeados.
|
|
46
|
+
- Monitoreo en vivo de archivos leidos, lineas modificadas y ejecucion de comandos sin parpadeos ni desbordes de buffer en Windows CMD.
|
|
47
|
+
|
|
48
|
+
3. **Vision Multimodal & Capturas de Pantalla:**
|
|
49
|
+
- Copia cualquier error o diseno con `Win + Shift + S`.
|
|
50
|
+
- Presiona `Ctrl + V` en la terminal para adjuntar automaticamente `[clipboard image X]` al agente.
|
|
51
|
+
|
|
52
|
+
4. **Entrada Multilinea Nativa:**
|
|
53
|
+
- Permite pegar fragmentos extensos de codigo, JSON o prompts con multiples saltos de linea sin que se corte ni se dispare accidentalmente.
|
|
54
|
+
- Sanitizador inteligente de retornos de carro.
|
|
55
|
+
|
|
56
|
+
5. **Candados de Seguridad e Inmutabilidad (Enterprise Guardrails):**
|
|
57
|
+
- **Inmutable Core:** El agente no puede borrarse ni modificarse a si mismo.
|
|
58
|
+
- **Destructive Command Blocker:** Bloqueo automatico de comandos destructivos masivos (`rmdir /s /q`, `rm -rf /`, etc.).
|
|
59
|
+
- **Credential Protection:** Proteccion activa contra filtracion de llaves maestras o certificados privados.
|
|
60
|
+
|
|
61
|
+
6. **Generacion Nativa de Imagenes:**
|
|
62
|
+
- Crea logotipos, portadas e iconos en formato PNG directamente en disco mediante la herramienta `generate_image`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Configuracion de API Key
|
|
67
|
+
|
|
68
|
+
Al iniciarse por primera vez, CODE DAZA solicitara tu **Gemini API Key** (de Google AI Studio o Google Cloud Vertex) y la almacenara de forma segura en tu perfil de usuario local (`~/.daza_gemini_key`). Nunca tendras que volver a escribirla.
|
|
69
|
+
|
|
70
|
+
Tambien puedes definirla como variable de entorno:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
export GEMINI_API_KEY="tu_api_key_aqui" # Linux / Mac
|
|
74
|
+
setx GEMINI_API_KEY "tu_api_key_aqui" # Windows CMD
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Licencia
|
|
80
|
+
|
|
81
|
+
Distribuido bajo la Licencia MIT. Consulta el archivo `LICENSE` para mas detalles.
|
|
@@ -0,0 +1,877 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
================================================================================
|
|
5
|
+
CODE DAZA - Universal Autonomous AI Engineering Agent (v50.0 Masterpiece)
|
|
6
|
+
Lead Architect, Full Stack Sr, DevOps & Autonomous Systems Runtime
|
|
7
|
+
================================================================================
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import subprocess
|
|
13
|
+
import glob
|
|
14
|
+
import re
|
|
15
|
+
import io
|
|
16
|
+
import time
|
|
17
|
+
import threading
|
|
18
|
+
from collections import deque
|
|
19
|
+
from typing import List, Optional
|
|
20
|
+
|
|
21
|
+
# 1. Habilitar Virtual Terminal Sequences y UTF-8 nativo en Windows 10/11
|
|
22
|
+
if sys.platform == "win32":
|
|
23
|
+
try:
|
|
24
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
25
|
+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
|
26
|
+
except Exception:
|
|
27
|
+
pass
|
|
28
|
+
try:
|
|
29
|
+
import ctypes
|
|
30
|
+
kernel32 = ctypes.windll.kernel32
|
|
31
|
+
hStdOut = kernel32.GetStdHandle(-11)
|
|
32
|
+
mode = ctypes.c_ulong()
|
|
33
|
+
kernel32.GetConsoleMode(hStdOut, ctypes.byref(mode))
|
|
34
|
+
kernel32.SetConsoleMode(hStdOut, mode.value | 0x0004)
|
|
35
|
+
except Exception:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
# 2. Manejo de imágenes (Pillow)
|
|
39
|
+
try:
|
|
40
|
+
from PIL import Image, ImageGrab
|
|
41
|
+
except ImportError:
|
|
42
|
+
print("\n[!] Falta instalar Pillow. Ejecuta: pip install pillow\n")
|
|
43
|
+
sys.exit(1)
|
|
44
|
+
|
|
45
|
+
# 3. CLI avanzada interactiva (prompt_toolkit)
|
|
46
|
+
try:
|
|
47
|
+
from prompt_toolkit import PromptSession
|
|
48
|
+
from prompt_toolkit.key_binding import KeyBindings
|
|
49
|
+
from prompt_toolkit.formatted_text import HTML
|
|
50
|
+
except ImportError:
|
|
51
|
+
print("\n[!] Falta instalar prompt_toolkit. Ejecuta: pip install prompt_toolkit\n")
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
|
|
54
|
+
# 4. Rich Console + Live
|
|
55
|
+
try:
|
|
56
|
+
from rich.console import Console, Group
|
|
57
|
+
from rich.markdown import Markdown
|
|
58
|
+
from rich.panel import Panel
|
|
59
|
+
from rich.theme import Theme
|
|
60
|
+
from rich.live import Live
|
|
61
|
+
from rich.text import Text
|
|
62
|
+
from rich import box
|
|
63
|
+
except ImportError:
|
|
64
|
+
print("\n[!] Falta instalar rich. Ejecuta: pip install rich\n")
|
|
65
|
+
sys.exit(1)
|
|
66
|
+
|
|
67
|
+
# 5. Google GenAI SDK
|
|
68
|
+
try:
|
|
69
|
+
from google import genai
|
|
70
|
+
from google.genai import types
|
|
71
|
+
except ImportError:
|
|
72
|
+
print("\n[!] Falta instalar google-genai. Ejecuta: pip install google-genai\n")
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
|
|
75
|
+
custom_theme = Theme({
|
|
76
|
+
"markdown.h1": "bold bright_yellow",
|
|
77
|
+
"markdown.h2": "bold bright_cyan",
|
|
78
|
+
"markdown.h3": "bold bright_green",
|
|
79
|
+
"markdown.h4": "bold bright_yellow",
|
|
80
|
+
"markdown.item.bullet": "bold bright_cyan",
|
|
81
|
+
"markdown.item.number": "bold bright_cyan",
|
|
82
|
+
"markdown.link": "bright_cyan underline",
|
|
83
|
+
"markdown.block_quote": "italic bright_white",
|
|
84
|
+
"markdown.hr": "bright_blue",
|
|
85
|
+
"markdown.code": "bold bright_cyan",
|
|
86
|
+
})
|
|
87
|
+
console = Console(theme=custom_theme, force_terminal=True, highlight=False)
|
|
88
|
+
|
|
89
|
+
# ==============================================================================
|
|
90
|
+
# GESTIÓN SEGURA DE API KEY
|
|
91
|
+
# ==============================================================================
|
|
92
|
+
KEY_FILE = os.path.join(os.path.expanduser("~"), ".daza_gemini_key")
|
|
93
|
+
|
|
94
|
+
def get_or_set_api_key() -> str:
|
|
95
|
+
env_key = os.environ.get("GEMINI_API_KEY", "").strip()
|
|
96
|
+
if env_key:
|
|
97
|
+
return env_key
|
|
98
|
+
|
|
99
|
+
if os.path.exists(KEY_FILE):
|
|
100
|
+
try:
|
|
101
|
+
with open(KEY_FILE, "r", encoding="utf-8") as f:
|
|
102
|
+
k = f.read().strip()
|
|
103
|
+
if k:
|
|
104
|
+
return k
|
|
105
|
+
except Exception:
|
|
106
|
+
pass
|
|
107
|
+
|
|
108
|
+
console.print()
|
|
109
|
+
console.print(Panel(
|
|
110
|
+
"[bold bright_yellow]Se requiere tu Gemini API Key de Google Cloud / Google AI Studio.[/bold bright_yellow]\n"
|
|
111
|
+
"[dim]Se guardará localmente en tu perfil de usuario (~/.daza_gemini_key).[/dim]",
|
|
112
|
+
box=box.ROUNDED,
|
|
113
|
+
border_style="bright_yellow",
|
|
114
|
+
title="[bold yellow]CONFIGURACIÓN DE API KEY[/bold yellow]"
|
|
115
|
+
))
|
|
116
|
+
key_input = console.input("[bold bright_green] Introduce tu Gemini API Key: [/bold bright_green]").strip()
|
|
117
|
+
|
|
118
|
+
if not key_input:
|
|
119
|
+
console.print("[bold red][!] Error: API Key requerida.[/bold red]")
|
|
120
|
+
sys.exit(1)
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
with open(KEY_FILE, "w", encoding="utf-8") as f:
|
|
124
|
+
f.write(key_input)
|
|
125
|
+
except Exception:
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
return key_input
|
|
129
|
+
|
|
130
|
+
MODEL_NAME = "gemini-3.7-flash"
|
|
131
|
+
MAX_TOOL_CALL_STEPS = 15
|
|
132
|
+
MAX_LOG_ITEMS = 6
|
|
133
|
+
|
|
134
|
+
SELF_SCRIPT_PATH = os.path.abspath(__file__)
|
|
135
|
+
|
|
136
|
+
# ==============================================================================
|
|
137
|
+
# CANDADOS DE SEGURIDAD Y BLINDAJE DEL AGENTE
|
|
138
|
+
# ==============================================================================
|
|
139
|
+
|
|
140
|
+
def is_self_modification_attempt(target_path: str) -> bool:
|
|
141
|
+
try:
|
|
142
|
+
norm_target = os.path.abspath(target_path)
|
|
143
|
+
if norm_target == SELF_SCRIPT_PATH or os.path.basename(norm_target).lower() == "code_daza.py":
|
|
144
|
+
return True
|
|
145
|
+
except Exception:
|
|
146
|
+
pass
|
|
147
|
+
return False
|
|
148
|
+
|
|
149
|
+
def is_blocked_credential_file(target_path: str) -> bool:
|
|
150
|
+
try:
|
|
151
|
+
norm_target = os.path.abspath(target_path)
|
|
152
|
+
base = os.path.basename(norm_target).lower()
|
|
153
|
+
if base in [".daza_gemini_key", "id_rsa", "id_ed25519", "master.key"]:
|
|
154
|
+
return True
|
|
155
|
+
except Exception:
|
|
156
|
+
pass
|
|
157
|
+
return False
|
|
158
|
+
|
|
159
|
+
DESTRUCTIVE_COMMAND_PATTERNS = [
|
|
160
|
+
r"\brmdir\s+/[sS]\s+/[qQ]\s+[cC]:\\?",
|
|
161
|
+
r"\bformat\s+[a-zA-Z]:",
|
|
162
|
+
r"\bdiskpart\b",
|
|
163
|
+
r"\bdel\s+/[fF]\s+/[sS]\s+/[qQ]\s+[cC]:\\Windows",
|
|
164
|
+
r"\brm\s+-rf\s+/(?:\s|$)",
|
|
165
|
+
r"\bmkfs\b",
|
|
166
|
+
r":\(\)\s*\{\s*:\|:&\s*\};:",
|
|
167
|
+
r"\bshutdown\s+/[sS]\s+/[fF]",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
def is_destructive_shell_command(command: str) -> bool:
|
|
171
|
+
cmd_clean = command.strip()
|
|
172
|
+
for pattern in DESTRUCTIVE_COMMAND_PATTERNS:
|
|
173
|
+
if re.search(pattern, cmd_clean, re.IGNORECASE):
|
|
174
|
+
return True
|
|
175
|
+
return False
|
|
176
|
+
|
|
177
|
+
# ==============================================================================
|
|
178
|
+
# SUBVENTANA FIJA COMPACTA (LIVE VIEWPORT)
|
|
179
|
+
# ==============================================================================
|
|
180
|
+
class DazaTelemetryViewport:
|
|
181
|
+
def __init__(self, title="TELEMETRÍA EN VIVO - ACCIONES DEL AGENTE"):
|
|
182
|
+
self.title = title
|
|
183
|
+
self.log_lines = deque(maxlen=MAX_LOG_ITEMS)
|
|
184
|
+
self.status_msg = "Iniciando razonamiento con Gemini 3.7..."
|
|
185
|
+
self.spinners = ["-", "\\", "|", "/"]
|
|
186
|
+
self.spinner_idx = 0
|
|
187
|
+
self.dots_cycle = [". ", ".. ", "...", " ..", " .", " "]
|
|
188
|
+
self.t0 = time.time()
|
|
189
|
+
self.lock = threading.Lock()
|
|
190
|
+
self.running = False
|
|
191
|
+
self.live = None
|
|
192
|
+
|
|
193
|
+
def add_log(self, text: str):
|
|
194
|
+
with self.lock:
|
|
195
|
+
for single_line in str(text).splitlines():
|
|
196
|
+
if single_line.strip():
|
|
197
|
+
self.log_lines.append(single_line)
|
|
198
|
+
if self.live:
|
|
199
|
+
try:
|
|
200
|
+
self.live.update(self._render())
|
|
201
|
+
except Exception:
|
|
202
|
+
pass
|
|
203
|
+
|
|
204
|
+
def set_status(self, msg: str):
|
|
205
|
+
with self.lock:
|
|
206
|
+
self.status_msg = msg
|
|
207
|
+
if self.live:
|
|
208
|
+
try:
|
|
209
|
+
self.live.update(self._render())
|
|
210
|
+
except Exception:
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
def _render(self):
|
|
214
|
+
with self.lock:
|
|
215
|
+
elapsed = int(time.time() - self.t0)
|
|
216
|
+
s = self.spinners[self.spinner_idx % len(self.spinners)]
|
|
217
|
+
d = self.dots_cycle[self.spinner_idx % len(self.dots_cycle)]
|
|
218
|
+
self.spinner_idx += 1
|
|
219
|
+
|
|
220
|
+
display_lines = list(self.log_lines)
|
|
221
|
+
while len(display_lines) < MAX_LOG_ITEMS:
|
|
222
|
+
display_lines.append("")
|
|
223
|
+
|
|
224
|
+
body = Text()
|
|
225
|
+
for idx, line in enumerate(display_lines):
|
|
226
|
+
if line:
|
|
227
|
+
try:
|
|
228
|
+
body.append(Text.from_markup(f" {line}\n"))
|
|
229
|
+
except Exception:
|
|
230
|
+
body.append(f" {line}\n")
|
|
231
|
+
else:
|
|
232
|
+
body.append("\n" if idx < (MAX_LOG_ITEMS - 1) else "")
|
|
233
|
+
|
|
234
|
+
panel = Panel(
|
|
235
|
+
body,
|
|
236
|
+
box=box.ROUNDED,
|
|
237
|
+
border_style="cyan",
|
|
238
|
+
title=f"[bold bright_cyan]{self.title}[/bold bright_cyan]",
|
|
239
|
+
padding=(0, 1),
|
|
240
|
+
height=MAX_LOG_ITEMS + 2
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
status_line = Text()
|
|
244
|
+
status_line.append(" [", style="dim")
|
|
245
|
+
status_line.append(s, style="bold bright_yellow")
|
|
246
|
+
status_line.append("] ", style="dim")
|
|
247
|
+
status_line.append("CODE DAZA: ", style="bold bright_cyan")
|
|
248
|
+
status_line.append(str(self.status_msg)[:55], style="white")
|
|
249
|
+
status_line.append(f" {d} ", style="bold bright_green")
|
|
250
|
+
status_line.append(f"({elapsed}s)", style="dim")
|
|
251
|
+
|
|
252
|
+
return Group(panel, status_line)
|
|
253
|
+
|
|
254
|
+
def __enter__(self):
|
|
255
|
+
self.running = True
|
|
256
|
+
self.t0 = time.time()
|
|
257
|
+
self.live = Live(
|
|
258
|
+
self._render(),
|
|
259
|
+
console=console,
|
|
260
|
+
refresh_per_second=4,
|
|
261
|
+
transient=True
|
|
262
|
+
)
|
|
263
|
+
self.live.__enter__()
|
|
264
|
+
self.bg_thread = threading.Thread(target=self._refresh_loop, daemon=True)
|
|
265
|
+
self.bg_thread.start()
|
|
266
|
+
return self
|
|
267
|
+
|
|
268
|
+
def _refresh_loop(self):
|
|
269
|
+
while self.running:
|
|
270
|
+
try:
|
|
271
|
+
if self.live:
|
|
272
|
+
self.live.update(self._render())
|
|
273
|
+
except Exception:
|
|
274
|
+
pass
|
|
275
|
+
time.sleep(0.25)
|
|
276
|
+
|
|
277
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
278
|
+
self.running = False
|
|
279
|
+
if self.live:
|
|
280
|
+
try:
|
|
281
|
+
self.live.__exit__(exc_type, exc_val, exc_tb)
|
|
282
|
+
except Exception:
|
|
283
|
+
pass
|
|
284
|
+
|
|
285
|
+
# ==============================================================================
|
|
286
|
+
# GESTIÓN DUAL DEL PORTAPAPELES: IMÁGENES Y TEXTO MULTILÍNEA NATIVO
|
|
287
|
+
# ==============================================================================
|
|
288
|
+
pending_images_map = {}
|
|
289
|
+
image_counter = 0
|
|
290
|
+
|
|
291
|
+
def grab_image_from_clipboard() -> Optional[bytes]:
|
|
292
|
+
"""Extrae la imagen del portapapeles de Windows en formato PNG."""
|
|
293
|
+
try:
|
|
294
|
+
im = ImageGrab.grabclipboard()
|
|
295
|
+
if im is not None and isinstance(im, Image.Image):
|
|
296
|
+
buf = io.BytesIO()
|
|
297
|
+
im.save(buf, format="PNG")
|
|
298
|
+
return buf.getvalue()
|
|
299
|
+
except Exception:
|
|
300
|
+
pass
|
|
301
|
+
return None
|
|
302
|
+
|
|
303
|
+
def get_system_clipboard_text() -> Optional[str]:
|
|
304
|
+
"""Obtiene el texto del portapapeles de Windows preservando todos los saltos de línea."""
|
|
305
|
+
try:
|
|
306
|
+
import win32clipboard
|
|
307
|
+
win32clipboard.OpenClipboard()
|
|
308
|
+
try:
|
|
309
|
+
if win32clipboard.IsClipboardFormatAvailable(win32clipboard.CF_UNICODETEXT):
|
|
310
|
+
return win32clipboard.GetClipboardData(win32clipboard.CF_UNICODETEXT)
|
|
311
|
+
finally:
|
|
312
|
+
win32clipboard.CloseClipboard()
|
|
313
|
+
except Exception:
|
|
314
|
+
pass
|
|
315
|
+
return None
|
|
316
|
+
|
|
317
|
+
# ==============================================================================
|
|
318
|
+
# KEYBINDINGS PARA PROMPT_TOOLKIT (CTRL+V PARA IMÁGENES + TEXTO MULTILÍNEA)
|
|
319
|
+
# ==============================================================================
|
|
320
|
+
|
|
321
|
+
kb = KeyBindings()
|
|
322
|
+
|
|
323
|
+
@kb.add('c-v')
|
|
324
|
+
def _handle_ctrl_v(event):
|
|
325
|
+
"""
|
|
326
|
+
Atajo maestro Ctrl+V:
|
|
327
|
+
1. Si hay una IMAGEN en el portapapeles (Win+Shift+S), inserta la etiqueta [clipboard image X].
|
|
328
|
+
2. Si hay TEXTO (incluso con múltiples saltos de línea / código / JSON), lo inserta intacto
|
|
329
|
+
con todos sus saltos de línea sin cortarse y haciendo trim al salto final.
|
|
330
|
+
"""
|
|
331
|
+
global image_counter
|
|
332
|
+
img_data = grab_image_from_clipboard()
|
|
333
|
+
if img_data:
|
|
334
|
+
image_counter += 1
|
|
335
|
+
tag = f"[clipboard image {image_counter}]"
|
|
336
|
+
pending_images_map[tag] = img_data
|
|
337
|
+
event.current_buffer.insert_text(f" {tag} ")
|
|
338
|
+
else:
|
|
339
|
+
raw_text = get_system_clipboard_text()
|
|
340
|
+
if raw_text:
|
|
341
|
+
# Quitar saltos de línea al final para evitar Enter accidental pero conservar todos los internos
|
|
342
|
+
clean_text = raw_text.rstrip("\r\n").replace("\r\n", "\n").replace("\r", "\n")
|
|
343
|
+
event.current_buffer.insert_text(clean_text)
|
|
344
|
+
else:
|
|
345
|
+
try:
|
|
346
|
+
data = event.app.clipboard.get_data()
|
|
347
|
+
if data and data.text:
|
|
348
|
+
event.current_buffer.insert_text(data.text.rstrip("\r\n"))
|
|
349
|
+
except Exception:
|
|
350
|
+
pass
|
|
351
|
+
|
|
352
|
+
# ==============================================================================
|
|
353
|
+
# HERRAMIENTAS UNIVERSALES DE INGENIERÍA CON CANDADOS ACTIVOS
|
|
354
|
+
# ==============================================================================
|
|
355
|
+
|
|
356
|
+
def grep_search(search_term: str, directory: str = ".", file_pattern: str = "*.*") -> str:
|
|
357
|
+
matches = []
|
|
358
|
+
EXCLUDED_DIRS = {
|
|
359
|
+
".git", "node_modules", ".next", "target", "dist", "out", "build",
|
|
360
|
+
".gradle", ".wrangler", "__pycache__", ".venv", "venv", ".idea", ".vscode"
|
|
361
|
+
}
|
|
362
|
+
try:
|
|
363
|
+
regex = re.compile(search_term, re.IGNORECASE)
|
|
364
|
+
for root, dirs, files in os.walk(directory):
|
|
365
|
+
dirs[:] = [d for d in dirs if d not in EXCLUDED_DIRS and not d.startswith(".")]
|
|
366
|
+
for file in files:
|
|
367
|
+
if file_pattern != "*.*" and not glob.fnmatch.fnmatch(file, file_pattern):
|
|
368
|
+
continue
|
|
369
|
+
file_path = os.path.join(root, file)
|
|
370
|
+
try:
|
|
371
|
+
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
|
|
372
|
+
for line_idx, line in enumerate(f, 1):
|
|
373
|
+
if regex.search(line):
|
|
374
|
+
clean_line = line.strip()[:100]
|
|
375
|
+
matches.append(f"{file_path}:{line_idx}: {clean_line}")
|
|
376
|
+
if len(matches) >= 30:
|
|
377
|
+
return "\n".join(matches) + "\n... (limite alcanzado)"
|
|
378
|
+
except Exception:
|
|
379
|
+
continue
|
|
380
|
+
return "\n".join(matches) if matches else f"No se encontraron coincidencias para '{search_term}'."
|
|
381
|
+
except Exception as e:
|
|
382
|
+
return f"[ERROR grep]: {str(e)}"
|
|
383
|
+
|
|
384
|
+
def replace_lines(file_path: str, start_line: int, end_line: int, new_content: str) -> str:
|
|
385
|
+
if is_self_modification_attempt(file_path):
|
|
386
|
+
return "[BLOQUEO DE SEGURIDAD]: 'code_daza.py' es el núcleo ejecutable del agente y está protegido como INMUTABLE. No puede modificarse a sí mismo en caliente."
|
|
387
|
+
|
|
388
|
+
if not os.path.exists(file_path):
|
|
389
|
+
return f"[ERROR]: El archivo '{file_path}' no existe."
|
|
390
|
+
try:
|
|
391
|
+
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
|
|
392
|
+
lines = f.readlines()
|
|
393
|
+
|
|
394
|
+
total = len(lines)
|
|
395
|
+
if start_line < 1 or end_line > total or start_line > end_line:
|
|
396
|
+
return f"[ERROR]: Rango de lineas invalido (1 a {total}). Solicitado: {start_line}-{end_line}."
|
|
397
|
+
|
|
398
|
+
new_lines = new_content.splitlines(keepends=True)
|
|
399
|
+
if new_lines and not new_lines[-1].endswith("\n"):
|
|
400
|
+
new_lines[-1] += "\n"
|
|
401
|
+
|
|
402
|
+
updated_lines = lines[:start_line - 1] + new_lines + lines[end_line:]
|
|
403
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
404
|
+
f.writelines(updated_lines)
|
|
405
|
+
|
|
406
|
+
return f"[EXITO]: Lineas {start_line} a {end_line} reemplazadas exitosamente en '{file_path}' (Total: {len(updated_lines)})."
|
|
407
|
+
except Exception as e:
|
|
408
|
+
return f"[ERROR replace_lines]: {str(e)}"
|
|
409
|
+
|
|
410
|
+
def execute_shell(command: str) -> str:
|
|
411
|
+
if is_destructive_shell_command(command):
|
|
412
|
+
return f"[BLOQUEO DE SEGURIDAD]: El comando '{command}' fue interceptado y cancelado por contener patrones de borrado destructivo masivo del disco o sistema operativo."
|
|
413
|
+
|
|
414
|
+
try:
|
|
415
|
+
res = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=120, encoding="utf-8", errors="replace")
|
|
416
|
+
out = (res.stdout or "") + (res.stderr or "")
|
|
417
|
+
return out if out.strip() else "[Comando ejecutado con exito sin salida]"
|
|
418
|
+
except subprocess.TimeoutExpired:
|
|
419
|
+
return "[ERROR]: El comando excedio el tiempo maximo de espera (120s)."
|
|
420
|
+
except Exception as e:
|
|
421
|
+
return f"[ERROR ejecucion]: {str(e)}"
|
|
422
|
+
|
|
423
|
+
def read_file(file_path: str, start_line: Optional[int] = None, num_lines: Optional[int] = None) -> str:
|
|
424
|
+
if is_blocked_credential_file(file_path):
|
|
425
|
+
return "[BLOQUEO DE SEGURIDAD]: Este archivo contiene credenciales privadas del sistema y su lectura directa está bloqueada por políticas de gobernanza."
|
|
426
|
+
|
|
427
|
+
if not os.path.exists(file_path):
|
|
428
|
+
return f"[ERROR]: El archivo '{file_path}' no existe."
|
|
429
|
+
try:
|
|
430
|
+
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
|
|
431
|
+
lines = f.readlines()
|
|
432
|
+
if start_line is not None:
|
|
433
|
+
s = max(0, start_line - 1)
|
|
434
|
+
n = num_lines if num_lines is not None else len(lines)
|
|
435
|
+
selected = lines[s:s + n]
|
|
436
|
+
return "".join(selected)
|
|
437
|
+
return "".join(lines)
|
|
438
|
+
except Exception as e:
|
|
439
|
+
return f"[ERROR lectura]: {str(e)}"
|
|
440
|
+
|
|
441
|
+
def write_file(file_path: str, content: str) -> str:
|
|
442
|
+
if is_self_modification_attempt(file_path):
|
|
443
|
+
return "[BLOQUEO DE SEGURIDAD]: 'code_daza.py' es el núcleo ejecutable del agente y está protegido como INMUTABLE. No puede modificarse a sí mismo en caliente."
|
|
444
|
+
|
|
445
|
+
try:
|
|
446
|
+
d = os.path.dirname(file_path)
|
|
447
|
+
if d and not os.path.exists(d):
|
|
448
|
+
os.makedirs(d, exist_ok=True)
|
|
449
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
450
|
+
f.write(content)
|
|
451
|
+
return f"[EXITO]: Archivo '{file_path}' escrito exitosamente."
|
|
452
|
+
except Exception as e:
|
|
453
|
+
return f"[ERROR escritura]: {str(e)}"
|
|
454
|
+
|
|
455
|
+
def replace_in_file(file_path: str, old_str: str, new_str: str) -> str:
|
|
456
|
+
if is_self_modification_attempt(file_path):
|
|
457
|
+
return "[BLOQUEO DE SEGURIDAD]: 'code_daza.py' es el núcleo ejecutable del agente y está protegido como INMUTABLE. No puede modificarse a sí mismo en caliente."
|
|
458
|
+
|
|
459
|
+
if not os.path.exists(file_path):
|
|
460
|
+
return f"[ERROR]: El archivo '{file_path}' no existe."
|
|
461
|
+
try:
|
|
462
|
+
with open(file_path, "r", encoding="utf-8", errors="replace") as f:
|
|
463
|
+
content = f.read()
|
|
464
|
+
clean_content = content.replace("\r\n", "\n")
|
|
465
|
+
clean_old_str = old_str.replace("\r\n", "\n")
|
|
466
|
+
clean_new_str = new_str.replace("\r\n", "\n")
|
|
467
|
+
|
|
468
|
+
if clean_old_str not in clean_content:
|
|
469
|
+
return f"[ERROR]: La cadena a reemplazar no fue encontrada exactamente en '{file_path}'. Usa 'replace_lines'."
|
|
470
|
+
|
|
471
|
+
prefix = clean_content.split(clean_old_str)[0]
|
|
472
|
+
start_line = prefix.count("\n") + 1
|
|
473
|
+
lines_replaced = clean_old_str.count("\n") + 1
|
|
474
|
+
end_line = start_line + lines_replaced - 1
|
|
475
|
+
|
|
476
|
+
updated = clean_content.replace(clean_old_str, clean_new_str, 1)
|
|
477
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
478
|
+
f.write(updated)
|
|
479
|
+
|
|
480
|
+
line_info = f"L{start_line}" if start_line == end_line else f"L{start_line}-L{end_line}"
|
|
481
|
+
return f"[EXITO]: Texto reemplazado en '{file_path}' ({line_info})."
|
|
482
|
+
except Exception as e:
|
|
483
|
+
return f"[ERROR reemplazo]: {str(e)}"
|
|
484
|
+
|
|
485
|
+
def list_files(directory: str = ".", pattern: str = "*") -> str:
|
|
486
|
+
try:
|
|
487
|
+
search_path = os.path.join(directory, pattern)
|
|
488
|
+
files = glob.glob(search_path)
|
|
489
|
+
if not files:
|
|
490
|
+
return f"No se encontraron archivos en '{directory}' con patron '{pattern}'."
|
|
491
|
+
return "\n".join(files[:60]) + (f"\n... ({len(files)} archivos en total)" if len(files) > 60 else "")
|
|
492
|
+
except Exception as e:
|
|
493
|
+
return f"[ERROR listar]: {str(e)}"
|
|
494
|
+
|
|
495
|
+
def generate_image(prompt: str, output_path: str = "generated_image.png") -> str:
|
|
496
|
+
try:
|
|
497
|
+
api_k = get_or_set_api_key()
|
|
498
|
+
img_client = genai.Client(api_key=api_k)
|
|
499
|
+
res = img_client.models.generate_content(
|
|
500
|
+
model="gemini-2.5-flash-image",
|
|
501
|
+
contents=prompt
|
|
502
|
+
)
|
|
503
|
+
if res.candidates and res.candidates[0].content and res.candidates[0].content.parts:
|
|
504
|
+
for part in res.candidates[0].content.parts:
|
|
505
|
+
if getattr(part, 'inline_data', None) and part.inline_data.data:
|
|
506
|
+
d = os.path.dirname(output_path)
|
|
507
|
+
if d and not os.path.exists(d):
|
|
508
|
+
os.makedirs(d, exist_ok=True)
|
|
509
|
+
with open(output_path, "wb") as f:
|
|
510
|
+
f.write(part.inline_data.data)
|
|
511
|
+
return f"[EXITO]: Imagen generada y guardada en '{output_path}' ({len(part.inline_data.data)//1024} KB)."
|
|
512
|
+
return "[ERROR]: Google GenAI no retorno datos de imagen para este prompt."
|
|
513
|
+
except Exception as e:
|
|
514
|
+
return f"[ERROR generacion imagen]: {str(e)}"
|
|
515
|
+
|
|
516
|
+
TOOLS = [grep_search, read_file, replace_lines, replace_in_file, write_file, execute_shell, list_files, generate_image]
|
|
517
|
+
|
|
518
|
+
# ==============================================================================
|
|
519
|
+
# BANNER CYBERPUNK ULTRA-PRO
|
|
520
|
+
# ==============================================================================
|
|
521
|
+
|
|
522
|
+
def print_banner():
|
|
523
|
+
logo_lines = [
|
|
524
|
+
(" ██████╗ ██████╗ ██████╗ ███████╗ ██████╗ █████╗ ███████╗ █████╗ ", "bold bright_cyan"),
|
|
525
|
+
(" ██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔══██╗██╔══██╗╚══███╔╝██╔══██╗", "bold bright_cyan"),
|
|
526
|
+
(" ██║ ██║ ██║██║ ██║█████╗ ██║ ██║███████║ ███╔╝ ███████║", "bold deep_sky_blue1"),
|
|
527
|
+
(" ██║ ██║ ██║██║ ██║██╔══╝ ██║ ██║██╔══██║ ███╔╝ ██╔══██║", "bold deep_sky_blue1"),
|
|
528
|
+
(" ╚██████╗╚██████╔╝██████╔╝███████╗ ██████╔╝██║ ██║███████╗██║ ██║", "bold bright_magenta"),
|
|
529
|
+
(" ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝", "bold bright_magenta"),
|
|
530
|
+
]
|
|
531
|
+
console.print()
|
|
532
|
+
for line_text, color_style in logo_lines:
|
|
533
|
+
console.print(f"[{color_style}]{line_text}[/{color_style}]")
|
|
534
|
+
|
|
535
|
+
console.print()
|
|
536
|
+
|
|
537
|
+
card_text = (
|
|
538
|
+
"[bold bright_green][OK] ONLINE[/bold bright_green] [bright_blue]│[/bright_blue] [bold bright_cyan]UNIVERSAL AI AUTONOMOUS RUNTIME (v50.0 MASTER)[/bold bright_cyan]\n"
|
|
539
|
+
"[dim]Engine :[/dim] [bold bright_yellow]Google Gemini 3.7 Flash (High Throughput)[/bold bright_yellow] [dim]•[/dim] [bold bright_magenta]Google Image Gen 2.5[/bold bright_magenta]\n"
|
|
540
|
+
"[dim]Roles :[/dim] [bold bright_cyan]Arquitecto Sr[/bold bright_cyan] [dim]•[/dim] [bold bright_green]Full Stack Sr[/bold bright_green] [dim]•[/dim] [bold bright_yellow]DevOps Sr[/bold bright_yellow] [dim]•[/dim] [bold bright_magenta]Diseñador UI/UX[/bold bright_magenta]\n"
|
|
541
|
+
"[dim]Scope :[/dim] [bold white]Agnóstico a Stack, Lenguaje, Repositorio, Arte y SO[/bold white]\n"
|
|
542
|
+
"[dim]Inputs :[/dim] [bold bright_yellow]Ctrl+V Capturas • Pegado Multilínea Win32 • Trim Inteligente[/bold bright_yellow]\n"
|
|
543
|
+
"[dim]Shields :[/dim] [bold bright_green]Inmutable Core • Blacklist Destructiva • Anti-Leak Claves[/bold bright_green]\n"
|
|
544
|
+
"[dim]Status :[/dim] [bold bright_green]Activo y Operativo en Tiempo Real[/bold bright_green]"
|
|
545
|
+
)
|
|
546
|
+
console.print(Panel(
|
|
547
|
+
card_text,
|
|
548
|
+
box=box.ROUNDED,
|
|
549
|
+
border_style="bright_blue",
|
|
550
|
+
width=78,
|
|
551
|
+
padding=(0, 2)
|
|
552
|
+
))
|
|
553
|
+
console.print()
|
|
554
|
+
|
|
555
|
+
# ==============================================================================
|
|
556
|
+
# SYSTEM PROMPT MAESTRO UNIVERSAL
|
|
557
|
+
# ==============================================================================
|
|
558
|
+
|
|
559
|
+
SYSTEM_INSTRUCTION = """
|
|
560
|
+
Eres CODE DAZA, el Agente Autónomo de Ingeniería de Software de élite, Arquitecto de Sistemas, Consultor Técnico Senior y Diseñador UI/UX.
|
|
561
|
+
Estás corriendo dentro de una terminal real en la máquina del usuario.
|
|
562
|
+
|
|
563
|
+
INMUTABILIDAD DEL AGENTE Y CANDADOS DE SEGURIDAD (GUARDRAILS):
|
|
564
|
+
- Tienes acceso total y sin límites para navegar, inspeccionar, leer y modificar cualquier ruta, disco o repositorio del sistema que el usuario te indique (incluyendo rutas externas para consultar soluciones o cruzar proyectos).
|
|
565
|
+
- CANDADO 1 (INMUTABILIDAD): Tienes PROHIBIDO modificarte a ti mismo (`code_daza.py`). Tus herramientas rechazarán automáticamente cualquier intento de alterar el script ejecutable del agente. Si el usuario te pide modificarte a ti mismo, responde que tu núcleo es inmutable por diseño de seguridad.
|
|
566
|
+
- CANDADO 2 (SEGURIDAD DESTRUCTIVA): No puedes ejecutar comandos destructivos masivos contra el sistema operativo o particiones de disco.
|
|
567
|
+
- CANDADO 3 (CONFIDENCIALIDAD): Las llaves maestras y credenciales privadas están bloqueadas contra filtración.
|
|
568
|
+
|
|
569
|
+
REGLAS DE MÁXIMO RENDIMIENTO Y LECTURA QUIRÚRGICA (HIGH THROUGHPUT):
|
|
570
|
+
1. LECTURAS PRECISAS: Nunca leas archivos gigantescos de golpe si solo necesitas una función o bloque. Usa `start_line` y `num_lines` para leer solo el fragmento relevante (30 a 80 líneas). Menos tokens transferidos = respuesta inmediata.
|
|
571
|
+
2. PARALELISMO Y MULTI-TOOL BATCHING: Si necesitas inspeccionar varios archivos o buscar términos relacionados, EMITE LAS LLAMADAS A HERRAMIENTAS EN PARALELO en un solo turno en lugar de una por una. Esto reduce los viajes de red a la mitad.
|
|
572
|
+
|
|
573
|
+
PROTOCOLO DE INGENIERÍA POR CAPAS Y FASES (CHAIN OF INVESTIGATION):
|
|
574
|
+
Cuando el usuario te pida analizar, explicar, auditar o modificar cualquier módulo o componente, DEBES operar bajo este flujo obligatorio en 3 fases:
|
|
575
|
+
|
|
576
|
+
FASE 1: DESCUBRIMIENTO Y MAPEO (CROSS-REFERENCE)
|
|
577
|
+
- Utiliza `list_files` para conocer la estructura de directorios o `grep_search` para rastrear dónde se menciona el concepto en todo el proyecto o en las rutas que te indique el usuario.
|
|
578
|
+
- Nunca des una conclusión viendo solo un archivo. Identifica los archivos involucrados en cada capa.
|
|
579
|
+
|
|
580
|
+
FASE 2: INSPECCIÓN CRUZADA DE CAPAS (FRONTEND <-> BACKEND <-> PERSISTENCIA/CONFIG)
|
|
581
|
+
- Si la funcionalidad involucra backend y base de datos: inspecciona el Controller/Ruta, el Servicio de Negocio y la Entidad/Configuración o Script SQL relevante con `read_file` quirúrgico.
|
|
582
|
+
- Si involucra frontend: inspecciona el componente UI y la llamada a la API.
|
|
583
|
+
- Revisa los puntos de conexión entre capas para dar una auditoría real, verídica y profunda.
|
|
584
|
+
|
|
585
|
+
FASE 3: EJECUCIÓN COMPLETA Y DICTAMEN FINAL (PROHIBIDO DEJAR TAREAS A MEDIAS)
|
|
586
|
+
- REGLA DE ORO RESOLUTIVA: Eres un agente de EJECUCIÓN AUTÓNOMA, NO un asistente pasivo.
|
|
587
|
+
- NUNCA termines tu turno diciendo frases ambiguas como "Procedo a aplicar...", "A continuación modificaré...", "¿Deseas que lo aplique?" o "En el siguiente paso haré X".
|
|
588
|
+
- Si se requiere modificar o crear archivos (Frontend, Backend, BD, Configs), HAZLO INMEDIATAMENTE en ese mismo turno usando tus herramientas (`replace_lines`, `replace_in_file`, `write_file`) y corre la compilación (`execute_shell`) ANTES de emitir tu respuesta final.
|
|
589
|
+
- Tu panel de respuesta SOLO debe emitirse cuando el trabajo esté 100% terminado, compilado y verificado, concluyendo siempre con el dictamen de lo que YA QUEDÓ hecho.
|
|
590
|
+
|
|
591
|
+
CAPACIDADES DE DISEÑO GRÁFICO, UI/UX Y GENERACIÓN DE IMÁGENES:
|
|
592
|
+
- Cuentas con la herramienta nativa `generate_image(prompt, output_path)` para crear imágenes con IA de Google de alta calidad.
|
|
593
|
+
- Si el usuario te pide: "crea un logo para X", "genera una imagen de portada", "diseña un banner para la web" o "genera un icono de robot", genera la imagen directamente en formato PNG y guárdala en el disco.
|
|
594
|
+
- Puedes combinar diseño y código: generar la imagen del logo en `public/logo.png` y luego actualizar el componente React/HTML con `replace_in_file` para incrustarla.
|
|
595
|
+
"""
|
|
596
|
+
|
|
597
|
+
# ==============================================================================
|
|
598
|
+
# ENVÍO RESILIENTE A GEMINI CON RETRY
|
|
599
|
+
# ==============================================================================
|
|
600
|
+
|
|
601
|
+
def send_message_with_retry(chat, payload, max_retries=5, viewport=None):
|
|
602
|
+
for attempt in range(1, max_retries + 1):
|
|
603
|
+
try:
|
|
604
|
+
return chat.send_message(payload)
|
|
605
|
+
except KeyboardInterrupt:
|
|
606
|
+
raise KeyboardInterrupt
|
|
607
|
+
except Exception as e:
|
|
608
|
+
err_str = str(e)
|
|
609
|
+
|
|
610
|
+
if "429" in err_str or "RESOURCE_EXHAUSTED" in err_str:
|
|
611
|
+
wait_time = 15.0
|
|
612
|
+
m = re.search(r"retryDelay['\"]?:\s*['\"]?(\d+(?:\.\d+)?)s?", err_str)
|
|
613
|
+
if m:
|
|
614
|
+
try:
|
|
615
|
+
wait_time = float(m.group(1)) + 1.0
|
|
616
|
+
except Exception:
|
|
617
|
+
pass
|
|
618
|
+
|
|
619
|
+
total_seconds = int(wait_time)
|
|
620
|
+
for remaining in range(total_seconds, 0, -1):
|
|
621
|
+
if viewport:
|
|
622
|
+
viewport.set_status(f"Liberando cuota de Gemini... reanudando en {remaining}s")
|
|
623
|
+
time.sleep(1.0)
|
|
624
|
+
|
|
625
|
+
if viewport:
|
|
626
|
+
viewport.set_status("Cuota liberada. Reanudando procesamiento...")
|
|
627
|
+
continue
|
|
628
|
+
|
|
629
|
+
is_socket_error = "10053" in err_str or "10054" in err_str or "RemoteProtocolError" in err_str or "ConnectionResetError" in err_str
|
|
630
|
+
if is_socket_error and attempt < max_retries:
|
|
631
|
+
time.sleep(1.5 * attempt)
|
|
632
|
+
continue
|
|
633
|
+
|
|
634
|
+
raise e
|
|
635
|
+
|
|
636
|
+
# ==============================================================================
|
|
637
|
+
# BUCLE PRINCIPAL INTERACTIVO
|
|
638
|
+
# ==============================================================================
|
|
639
|
+
|
|
640
|
+
def main():
|
|
641
|
+
global image_counter
|
|
642
|
+
print_banner()
|
|
643
|
+
|
|
644
|
+
api_key = get_or_set_api_key()
|
|
645
|
+
|
|
646
|
+
console.print(f"[bold bright_green] Conectando con Google GenAI [{MODEL_NAME}]...[/bold bright_green]")
|
|
647
|
+
try:
|
|
648
|
+
client = genai.Client(api_key=api_key)
|
|
649
|
+
chat = client.chats.create(
|
|
650
|
+
model=MODEL_NAME,
|
|
651
|
+
config=types.GenerateContentConfig(
|
|
652
|
+
system_instruction=SYSTEM_INSTRUCTION,
|
|
653
|
+
tools=TOOLS,
|
|
654
|
+
automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True),
|
|
655
|
+
temperature=0.2
|
|
656
|
+
)
|
|
657
|
+
)
|
|
658
|
+
console.print(f"[bold bright_cyan] Sesión establecida. CODE DAZA listo para recibir órdenes universales.[/bold bright_cyan]")
|
|
659
|
+
console.print("[dim] Tip: Copia una captura con Win+Shift+S y presiona [bold yellow]Ctrl+V[/bold yellow] para insertar [bold cyan][clipboard image X][/bold cyan].[/dim]\n")
|
|
660
|
+
except Exception as e:
|
|
661
|
+
console.print(f"[bold red][ERROR de conexion]: {str(e)}[/bold red]")
|
|
662
|
+
sys.exit(1)
|
|
663
|
+
|
|
664
|
+
total_tokens_session = 0
|
|
665
|
+
prompt_session = PromptSession(key_bindings=kb)
|
|
666
|
+
|
|
667
|
+
while True:
|
|
668
|
+
try:
|
|
669
|
+
try:
|
|
670
|
+
cwd_name = os.path.basename(os.getcwd()) or os.getcwd()
|
|
671
|
+
prompt_label = HTML(
|
|
672
|
+
'<style color="yellow"><b>>>></b></style> '
|
|
673
|
+
'<style color="magenta"><b>dazaeev</b></style> '
|
|
674
|
+
'<style color="cyan"><b>[CODE DAZA]</b></style> '
|
|
675
|
+
f'<style color="gray">({cwd_name})</style> '
|
|
676
|
+
)
|
|
677
|
+
prompt_user = prompt_session.prompt(prompt_label).strip()
|
|
678
|
+
except (KeyboardInterrupt, EOFError):
|
|
679
|
+
console.print(f"\n[bold bright_magenta] Sesión finalizada. ¡Hasta la próxima, Dazaeev![/bold bright_magenta]\n")
|
|
680
|
+
break
|
|
681
|
+
|
|
682
|
+
if not prompt_user:
|
|
683
|
+
continue
|
|
684
|
+
if prompt_user.lower() in ["salir", "exit", "quit", "adios"]:
|
|
685
|
+
console.print(f"\n[bold bright_magenta] Sesión finalizada. ¡Hasta la próxima, Dazaeev![/bold bright_magenta]\n")
|
|
686
|
+
break
|
|
687
|
+
|
|
688
|
+
images_to_send = []
|
|
689
|
+
matched_tags = re.findall(r"\[clipboard image \d+\]", prompt_user)
|
|
690
|
+
|
|
691
|
+
for tag in matched_tags:
|
|
692
|
+
if tag in pending_images_map:
|
|
693
|
+
images_to_send.append(pending_images_map[tag])
|
|
694
|
+
|
|
695
|
+
# Auto-detección por si el usuario no presionó Ctrl+V pero copió una captura
|
|
696
|
+
if not images_to_send and any(w in prompt_user.lower() for w in ["mira", "captura", "imagen", "error", "foto", "pantalla", "clipboard"]):
|
|
697
|
+
cb_img = grab_image_from_clipboard()
|
|
698
|
+
if cb_img:
|
|
699
|
+
image_counter += 1
|
|
700
|
+
tag = f"[clipboard image {image_counter}]"
|
|
701
|
+
pending_images_map[tag] = cb_img
|
|
702
|
+
images_to_send.append(cb_img)
|
|
703
|
+
console.print(f"[bold bright_cyan] ↳ {tag} detectada automáticamente del portapapeles. Adjuntando...[/bold bright_cyan]")
|
|
704
|
+
|
|
705
|
+
if images_to_send:
|
|
706
|
+
contents_payload = [prompt_user]
|
|
707
|
+
for img_bytes in images_to_send:
|
|
708
|
+
contents_payload.append(types.Part.from_bytes(data=img_bytes, mime_type="image/png"))
|
|
709
|
+
console.print(f"[bold bright_green] [VISION] Adjuntando {len(images_to_send)} captura(s) a Gemini 3.7 Flash...[/bold bright_green]")
|
|
710
|
+
else:
|
|
711
|
+
contents_payload = prompt_user
|
|
712
|
+
|
|
713
|
+
input_tokens = 0
|
|
714
|
+
output_tokens = 0
|
|
715
|
+
tool_call_count = 0
|
|
716
|
+
|
|
717
|
+
# SUBVENTANA FIJA COMPACTA CON BORDES REDONDEADOS Y TÍTULO LIMPIO (SIN SCROLL NI DUPLICACIONES)
|
|
718
|
+
try:
|
|
719
|
+
with DazaTelemetryViewport(title="TELEMETRÍA EN VIVO - ACCIONES DEL AGENTE") as viewport:
|
|
720
|
+
viewport.add_log("[bold bright_green]●[/bold bright_green] Requerimiento recibido. Iniciando análisis...")
|
|
721
|
+
viewport.set_status("Razonando con Gemini 3.7...")
|
|
722
|
+
|
|
723
|
+
response = send_message_with_retry(chat, contents_payload, viewport=viewport)
|
|
724
|
+
|
|
725
|
+
if hasattr(response, 'usage_metadata') and response.usage_metadata:
|
|
726
|
+
input_tokens += getattr(response.usage_metadata, 'prompt_token_count', 0) or 0
|
|
727
|
+
output_tokens += getattr(response.usage_metadata, 'candidates_token_count', 0) or 0
|
|
728
|
+
|
|
729
|
+
while response.function_calls:
|
|
730
|
+
tool_call_count += 1
|
|
731
|
+
if tool_call_count > MAX_TOOL_CALL_STEPS:
|
|
732
|
+
viewport.add_log(f"[bold bright_yellow]! Límite de seguridad alcanzado ({MAX_TOOL_CALL_STEPS} acciones).[/bold bright_yellow]")
|
|
733
|
+
viewport.set_status("Sintetizando dictamen final...")
|
|
734
|
+
response = send_message_with_retry(
|
|
735
|
+
chat,
|
|
736
|
+
"Has alcanzado el límite de exploración. Procede de inmediato a dar tu conclusión ejecutiva con los datos que obtuviste.",
|
|
737
|
+
viewport=viewport
|
|
738
|
+
)
|
|
739
|
+
break
|
|
740
|
+
|
|
741
|
+
tool_parts_batch = []
|
|
742
|
+
|
|
743
|
+
for call in response.function_calls:
|
|
744
|
+
fn_name = call.name
|
|
745
|
+
fn_args = dict(call.args) if call.args else {}
|
|
746
|
+
|
|
747
|
+
if fn_name == "read_file":
|
|
748
|
+
f_path = fn_args.get("file_path", "")
|
|
749
|
+
s_line = fn_args.get("start_line")
|
|
750
|
+
n_lines = fn_args.get("num_lines")
|
|
751
|
+
line_str = f" [bold yellow](L{s_line}-L{s_line + n_lines - 1})[/bold yellow]" if s_line and n_lines else ""
|
|
752
|
+
viewport.add_log(f"[bold bright_blue]↳ [LEER][/bold bright_blue] [white]{f_path}[/white]{line_str}")
|
|
753
|
+
viewport.set_status(f"Leyendo: {os.path.basename(f_path)}")
|
|
754
|
+
|
|
755
|
+
elif fn_name == "grep_search":
|
|
756
|
+
t_term = fn_args.get("search_term", "")
|
|
757
|
+
t_dir = fn_args.get("directory", ".")
|
|
758
|
+
viewport.add_log(f"[bold bright_cyan]↳ [BUSCAR][/bold bright_cyan] '{t_term}' en [dim]{t_dir}[/dim]")
|
|
759
|
+
viewport.set_status(f"Buscando: '{t_term[:20]}'")
|
|
760
|
+
|
|
761
|
+
elif fn_name == "replace_lines":
|
|
762
|
+
f_path = fn_args.get("file_path", "")
|
|
763
|
+
s_line = fn_args.get("start_line", 0)
|
|
764
|
+
e_line = fn_args.get("end_line", 0)
|
|
765
|
+
viewport.add_log(f"[bold bright_magenta]↳ [MODIFICAR][/bold bright_magenta] [white]{os.path.basename(f_path)}[/white] [bold yellow](L{s_line}-L{e_line})[/bold bright_yellow]")
|
|
766
|
+
viewport.set_status(f"Modificando líneas {s_line}-{e_line}")
|
|
767
|
+
|
|
768
|
+
elif fn_name == "replace_in_file":
|
|
769
|
+
f_path = fn_args.get("file_path", "")
|
|
770
|
+
viewport.add_log(f"[bold bright_magenta]↳ [MODIFICAR][/bold bright_magenta] [white]{os.path.basename(f_path)}[/white]")
|
|
771
|
+
viewport.set_status(f"Modificando {os.path.basename(f_path)}")
|
|
772
|
+
|
|
773
|
+
elif fn_name == "write_file":
|
|
774
|
+
f_path = fn_args.get("file_path", "")
|
|
775
|
+
viewport.add_log(f"[bold bright_magenta]↳ [ESCRIBIR][/bold bright_magenta] [white]{f_path}[/white]")
|
|
776
|
+
viewport.set_status(f"Escribiendo {os.path.basename(f_path)}")
|
|
777
|
+
|
|
778
|
+
elif fn_name == "generate_image":
|
|
779
|
+
out_p = fn_args.get("output_path", "image.png")
|
|
780
|
+
viewport.add_log(f"[bold bright_magenta]↳ [GENERAR IMAGEN][/bold bright_magenta] [white]{out_p}[/white]")
|
|
781
|
+
viewport.set_status(f"Generando: {out_p}")
|
|
782
|
+
|
|
783
|
+
elif fn_name == "list_files":
|
|
784
|
+
p_pat = fn_args.get("pattern", "*")
|
|
785
|
+
viewport.add_log(f"[bold bright_blue]↳ [LISTAR][/bold bright_blue] [dim]{p_pat}[/dim]")
|
|
786
|
+
viewport.set_status("Listando archivos...")
|
|
787
|
+
|
|
788
|
+
elif fn_name == "execute_shell":
|
|
789
|
+
cmd_str = fn_args.get("command", "")[:40]
|
|
790
|
+
viewport.add_log(f"[bold bright_green]↳ [SHELL][/bold bright_green] [dim]{cmd_str}[/dim]")
|
|
791
|
+
viewport.set_status(f"Shell: {cmd_str}")
|
|
792
|
+
|
|
793
|
+
else:
|
|
794
|
+
viewport.add_log(f"[bold yellow]↳ [TOOL][/bold yellow] {fn_name}")
|
|
795
|
+
|
|
796
|
+
# Ejecutar la herramienta en disco
|
|
797
|
+
tool_func = globals().get(fn_name)
|
|
798
|
+
if tool_func:
|
|
799
|
+
tool_result = tool_func(**fn_args)
|
|
800
|
+
else:
|
|
801
|
+
tool_result = f"[ERROR]: Herramienta '{fn_name}' no encontrada."
|
|
802
|
+
|
|
803
|
+
# Snippets compactos en la subventana
|
|
804
|
+
if fn_name == "read_file" and tool_result and not tool_result.startswith("[ERROR]"):
|
|
805
|
+
res_lines = [l.strip() for l in tool_result.splitlines() if l.strip()]
|
|
806
|
+
for preview_line in res_lines[:2]:
|
|
807
|
+
viewport.add_log(f" [dim]| {preview_line[:70]}[/dim]")
|
|
808
|
+
|
|
809
|
+
elif fn_name in ["replace_lines", "replace_in_file", "write_file"]:
|
|
810
|
+
if "[EXITO]" in tool_result:
|
|
811
|
+
viewport.add_log(f" [bold bright_green] {tool_result}[/bold bright_green]")
|
|
812
|
+
elif "[BLOQUEO" in tool_result:
|
|
813
|
+
viewport.add_log(f" [bold red] {tool_result}[/bold red]")
|
|
814
|
+
|
|
815
|
+
elif fn_name == "grep_search" and tool_result and not tool_result.startswith("[ERROR]"):
|
|
816
|
+
m_lines = [l.strip() for l in tool_result.splitlines() if l.strip()]
|
|
817
|
+
for match_line in m_lines[:2]:
|
|
818
|
+
viewport.add_log(f" [cyan]•[/cyan] [dim]{match_line[:70]}[/dim]")
|
|
819
|
+
|
|
820
|
+
elif fn_name == "list_files" and tool_result and not tool_result.startswith("[ERROR]"):
|
|
821
|
+
l_lines = [l.strip() for l in tool_result.splitlines() if l.strip()]
|
|
822
|
+
for f_item in l_lines[:2]:
|
|
823
|
+
viewport.add_log(f" [blue]*[/blue] [dim]{f_item[:70]}[/dim]")
|
|
824
|
+
|
|
825
|
+
tool_parts_batch.append(
|
|
826
|
+
types.Part.from_function_response(
|
|
827
|
+
name=fn_name,
|
|
828
|
+
response={"result": tool_result}
|
|
829
|
+
)
|
|
830
|
+
)
|
|
831
|
+
|
|
832
|
+
viewport.set_status("Analizando resultados en paralelo con Gemini...")
|
|
833
|
+
|
|
834
|
+
response = send_message_with_retry(
|
|
835
|
+
chat,
|
|
836
|
+
tool_parts_batch,
|
|
837
|
+
viewport=viewport
|
|
838
|
+
)
|
|
839
|
+
|
|
840
|
+
if hasattr(response, 'usage_metadata') and response.usage_metadata:
|
|
841
|
+
input_tokens += getattr(response.usage_metadata, 'prompt_token_count', 0) or 0
|
|
842
|
+
output_tokens += getattr(response.usage_metadata, 'candidates_token_count', 0) or 0
|
|
843
|
+
|
|
844
|
+
except KeyboardInterrupt:
|
|
845
|
+
console.print("\n[bold bright_yellow][!] Tarea interrumpida con Ctrl+C. Tu sesión sigue viva.[/bold bright_yellow]\n")
|
|
846
|
+
continue
|
|
847
|
+
|
|
848
|
+
# RENDERIZADO DEL PANEL FINAL DE RESPUESTA
|
|
849
|
+
if response.text:
|
|
850
|
+
turn_total = input_tokens + output_tokens
|
|
851
|
+
total_tokens_session += turn_total
|
|
852
|
+
|
|
853
|
+
cost_usd = (input_tokens * 0.00000010) + (output_tokens * 0.00000040)
|
|
854
|
+
cost_mxn = cost_usd * 20.0
|
|
855
|
+
|
|
856
|
+
footer_text = f"[dim]Tokens Turno:[/dim] [bold bright_cyan]{turn_total:,}[/bold bright_cyan] [dim](In: {input_tokens:,} | Out: {output_tokens:,})[/dim] [dim]•[/dim] [dim]Costo:[/dim] [bold bright_green]${cost_mxn:.4f} MXN[/bold bright_green] [dim]•[/dim] [dim]Sesión:[/dim] [bold bright_yellow]{total_tokens_session:,}[/bold bright_yellow]"
|
|
857
|
+
|
|
858
|
+
clean_text = re.sub(r'[\U00010000-\U0010ffff]', '', response.text)
|
|
859
|
+
md = Markdown(clean_text, code_theme="monokai")
|
|
860
|
+
|
|
861
|
+
console.print()
|
|
862
|
+
console.print(Panel(
|
|
863
|
+
md,
|
|
864
|
+
box=box.ROUNDED,
|
|
865
|
+
border_style="bright_cyan",
|
|
866
|
+
padding=(1, 2),
|
|
867
|
+
title="[bold bright_cyan]CODE DAZA RESPONSE[/bold bright_cyan]",
|
|
868
|
+
subtitle=footer_text,
|
|
869
|
+
subtitle_align="right"
|
|
870
|
+
))
|
|
871
|
+
console.print()
|
|
872
|
+
|
|
873
|
+
except Exception as err:
|
|
874
|
+
console.print(f"\n[bold red][!] Error: {str(err)}[/bold red]")
|
|
875
|
+
|
|
876
|
+
if __name__ == "__main__":
|
|
877
|
+
main()
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: code-daza
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Universal Autonomous AI Engineering, Architecture & UI/UX CLI Agent powered by Gemini 3.7 Flash
|
|
5
|
+
Author: Dazaeev
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/dazaeev/code-daza
|
|
8
|
+
Project-URL: Documentation, https://github.com/dazaeev/code-daza#readme
|
|
9
|
+
Keywords: ai,agent,cli,gemini,software-engineering,architecture,devops,code-assistant,automation
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
23
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Requires-Dist: google-genai>=1.0.0
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: pillow>=10.0.0
|
|
30
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
31
|
+
Requires-Dist: pywin32>=306; platform_system == "Windows"
|
|
32
|
+
|
|
33
|
+
# CODE DAZA (v1.0.0)
|
|
34
|
+
|
|
35
|
+
**Universal Autonomous AI Engineering, Architecture, DevOps & UI/UX Runtime**
|
|
36
|
+
Powered by Google Gemini 3.7 Flash & Google Image Gen.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Que es CODE DAZA?
|
|
41
|
+
|
|
42
|
+
**CODE DAZA** es un agente autonomo de ingenieria de software que opera directamente desde tu terminal de consola. Actua con el rigor tecnico y los criterios de:
|
|
43
|
+
- **Lead Software Architect:** Diseno y auditoria de microservicios, monolitos, bases de datos y seguridad.
|
|
44
|
+
- **Full Stack Engineer Sr:** Inspeccion y modificacion quirurgica de codigo en cualquier lenguaje (Java, TypeScript, Python, Go, Rust, C++, C#, etc.).
|
|
45
|
+
- **DevOps & SRE:** Ejecucion y validacion de comandos de consola, compiladores (Maven, NPM, Cargo, Gradle) y pruebas unitarias.
|
|
46
|
+
- **UI/UX Designer & Image Generator:** Generacion nativa de imagenes, logotipos e iconos en PNG de alta resolucion con IA.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Instalacion Global (PyPI)
|
|
51
|
+
|
|
52
|
+
Puedes instalar CODE DAZA en cualquier computadora (Windows, Mac o Linux) con un solo comando:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install code-daza
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Como Ejecutarlo?
|
|
61
|
+
|
|
62
|
+
Una vez instalado, simplemente abre cualquier terminal en la carpeta de cualquier proyecto y escribe:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
code-daza
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Caracteristicas Principales
|
|
71
|
+
|
|
72
|
+
1. **Agnostico y Universal:**
|
|
73
|
+
- Funciona sobre cualquier stack, framework o lenguaje.
|
|
74
|
+
- Navegacion multi-proyecto: puede cruzar y sincronizar codigo entre diferentes carpetas y repositorios.
|
|
75
|
+
|
|
76
|
+
2. **Telemetria Panoramica en Tiempo Real:**
|
|
77
|
+
- Subventana compacta con diseno cyberpunk y bordes redondeados.
|
|
78
|
+
- Monitoreo en vivo de archivos leidos, lineas modificadas y ejecucion de comandos sin parpadeos ni desbordes de buffer en Windows CMD.
|
|
79
|
+
|
|
80
|
+
3. **Vision Multimodal & Capturas de Pantalla:**
|
|
81
|
+
- Copia cualquier error o diseno con `Win + Shift + S`.
|
|
82
|
+
- Presiona `Ctrl + V` en la terminal para adjuntar automaticamente `[clipboard image X]` al agente.
|
|
83
|
+
|
|
84
|
+
4. **Entrada Multilinea Nativa:**
|
|
85
|
+
- Permite pegar fragmentos extensos de codigo, JSON o prompts con multiples saltos de linea sin que se corte ni se dispare accidentalmente.
|
|
86
|
+
- Sanitizador inteligente de retornos de carro.
|
|
87
|
+
|
|
88
|
+
5. **Candados de Seguridad e Inmutabilidad (Enterprise Guardrails):**
|
|
89
|
+
- **Inmutable Core:** El agente no puede borrarse ni modificarse a si mismo.
|
|
90
|
+
- **Destructive Command Blocker:** Bloqueo automatico de comandos destructivos masivos (`rmdir /s /q`, `rm -rf /`, etc.).
|
|
91
|
+
- **Credential Protection:** Proteccion activa contra filtracion de llaves maestras o certificados privados.
|
|
92
|
+
|
|
93
|
+
6. **Generacion Nativa de Imagenes:**
|
|
94
|
+
- Crea logotipos, portadas e iconos en formato PNG directamente en disco mediante la herramienta `generate_image`.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Configuracion de API Key
|
|
99
|
+
|
|
100
|
+
Al iniciarse por primera vez, CODE DAZA solicitara tu **Gemini API Key** (de Google AI Studio o Google Cloud Vertex) y la almacenara de forma segura en tu perfil de usuario local (`~/.daza_gemini_key`). Nunca tendras que volver a escribirla.
|
|
101
|
+
|
|
102
|
+
Tambien puedes definirla como variable de entorno:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export GEMINI_API_KEY="tu_api_key_aqui" # Linux / Mac
|
|
106
|
+
setx GEMINI_API_KEY "tu_api_key_aqui" # Windows CMD
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Licencia
|
|
112
|
+
|
|
113
|
+
Distribuido bajo la Licencia MIT. Consulta el archivo `LICENSE` para mas detalles.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
code_daza/__init__.py
|
|
4
|
+
code_daza/agent.py
|
|
5
|
+
code_daza.egg-info/PKG-INFO
|
|
6
|
+
code_daza.egg-info/SOURCES.txt
|
|
7
|
+
code_daza.egg-info/dependency_links.txt
|
|
8
|
+
code_daza.egg-info/entry_points.txt
|
|
9
|
+
code_daza.egg-info/requires.txt
|
|
10
|
+
code_daza.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
code_daza
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "code-daza"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Universal Autonomous AI Engineering, Architecture & UI/UX CLI Agent powered by Gemini 3.7 Flash"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Dazaeev" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"ai",
|
|
17
|
+
"agent",
|
|
18
|
+
"cli",
|
|
19
|
+
"gemini",
|
|
20
|
+
"software-engineering",
|
|
21
|
+
"architecture",
|
|
22
|
+
"devops",
|
|
23
|
+
"code-assistant",
|
|
24
|
+
"automation",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 5 - Production/Stable",
|
|
28
|
+
"Environment :: Console",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Intended Audience :: Information Technology",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.9",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13",
|
|
39
|
+
"Topic :: Software Development :: Code Generators",
|
|
40
|
+
"Topic :: Software Development :: Build Tools",
|
|
41
|
+
"Topic :: Utilities",
|
|
42
|
+
]
|
|
43
|
+
dependencies = [
|
|
44
|
+
"google-genai>=1.0.0",
|
|
45
|
+
"rich>=13.0.0",
|
|
46
|
+
"pillow>=10.0.0",
|
|
47
|
+
"prompt-toolkit>=3.0.0",
|
|
48
|
+
"pywin32>=306; platform_system == 'Windows'",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.urls]
|
|
52
|
+
Homepage = "https://github.com/dazaeev/code-daza"
|
|
53
|
+
Documentation = "https://github.com/dazaeev/code-daza#readme"
|
|
54
|
+
|
|
55
|
+
[project.scripts]
|
|
56
|
+
code-daza = "code_daza.agent:main"
|
|
57
|
+
|
|
58
|
+
[tool.setuptools]
|
|
59
|
+
packages = ["code_daza"]
|