kogniterm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kogniterm-0.1.0/LICENSE +21 -0
- kogniterm-0.1.0/MANIFEST.in +13 -0
- kogniterm-0.1.0/PKG-INFO +235 -0
- kogniterm-0.1.0/README.md +178 -0
- kogniterm-0.1.0/kogniterm/__init__.py +1 -0
- kogniterm-0.1.0/kogniterm/core/__init__.py +0 -0
- kogniterm-0.1.0/kogniterm/core/agent_state.py +104 -0
- kogniterm-0.1.0/kogniterm/core/agents/__init__.py +1 -0
- kogniterm-0.1.0/kogniterm/core/agents/bash_agent.py +616 -0
- kogniterm-0.1.0/kogniterm/core/agents/code_agent.py +320 -0
- kogniterm-0.1.0/kogniterm/core/agents/code_crew.py +80 -0
- kogniterm-0.1.0/kogniterm/core/agents/code_crew_agents.py +62 -0
- kogniterm-0.1.0/kogniterm/core/agents/research_agents.py +144 -0
- kogniterm-0.1.0/kogniterm/core/agents/researcher_agent.py +272 -0
- kogniterm-0.1.0/kogniterm/core/agents/researcher_agent_backup.py +269 -0
- kogniterm-0.1.0/kogniterm/core/agents/researcher_crew.py +127 -0
- kogniterm-0.1.0/kogniterm/core/agents/specialized_agents.py +93 -0
- kogniterm-0.1.0/kogniterm/core/command_executor.py +148 -0
- kogniterm-0.1.0/kogniterm/core/config.py +34 -0
- kogniterm-0.1.0/kogniterm/core/context/__init__.py +1 -0
- kogniterm-0.1.0/kogniterm/core/context/codebase_indexer.py +333 -0
- kogniterm-0.1.0/kogniterm/core/context/vector_db_manager.py +173 -0
- kogniterm-0.1.0/kogniterm/core/context/workspace_context.py +165 -0
- kogniterm-0.1.0/kogniterm/core/embeddings_service.py +169 -0
- kogniterm-0.1.0/kogniterm/core/exceptions.py +10 -0
- kogniterm-0.1.0/kogniterm/core/history_manager.py +685 -0
- kogniterm-0.1.0/kogniterm/core/llm_bridge.py +101 -0
- kogniterm-0.1.0/kogniterm/core/llm_service.py +1688 -0
- kogniterm-0.1.0/kogniterm/core/llm_service_enhanced.py +226 -0
- kogniterm-0.1.0/kogniterm/core/progress_manager.py +170 -0
- kogniterm-0.1.0/kogniterm/core/session_manager.py +109 -0
- kogniterm-0.1.0/kogniterm/core/tools/__init__.py +13 -0
- kogniterm-0.1.0/kogniterm/core/tools/advanced_file_editor_tool.py +195 -0
- kogniterm-0.1.0/kogniterm/core/tools/brave_search_tool.py +39 -0
- kogniterm-0.1.0/kogniterm/core/tools/call_agent_tool.py +235 -0
- kogniterm-0.1.0/kogniterm/core/tools/code_analysis_tool.py +295 -0
- kogniterm-0.1.0/kogniterm/core/tools/codebase_search_tool.py +98 -0
- kogniterm-0.1.0/kogniterm/core/tools/execute_command_tool.py +55 -0
- kogniterm-0.1.0/kogniterm/core/tools/file_operations_tool.py +399 -0
- kogniterm-0.1.0/kogniterm/core/tools/file_read_directory_tool.py +46 -0
- kogniterm-0.1.0/kogniterm/core/tools/file_search_tool.py +41 -0
- kogniterm-0.1.0/kogniterm/core/tools/file_update_tool.py +77 -0
- kogniterm-0.1.0/kogniterm/core/tools/github_tool.py +200 -0
- kogniterm-0.1.0/kogniterm/core/tools/memory_append_tool.py +48 -0
- kogniterm-0.1.0/kogniterm/core/tools/memory_init_tool.py +49 -0
- kogniterm-0.1.0/kogniterm/core/tools/memory_read_tool.py +51 -0
- kogniterm-0.1.0/kogniterm/core/tools/memory_summarize_tool.py +63 -0
- kogniterm-0.1.0/kogniterm/core/tools/pc_interaction_tool.py +133 -0
- kogniterm-0.1.0/kogniterm/core/tools/plan_creation_tool.py +118 -0
- kogniterm-0.1.0/kogniterm/core/tools/playwright_browser_manager.py +49 -0
- kogniterm-0.1.0/kogniterm/core/tools/pylint_tool.py +0 -0
- kogniterm-0.1.0/kogniterm/core/tools/python_executor.py +174 -0
- kogniterm-0.1.0/kogniterm/core/tools/search_memory_tool.py +63 -0
- kogniterm-0.1.0/kogniterm/core/tools/set_llm_instructions_tool.py +26 -0
- kogniterm-0.1.0/kogniterm/core/tools/task_complete_tool.py +85 -0
- kogniterm-0.1.0/kogniterm/core/tools/tavily_search_tool.py +96 -0
- kogniterm-0.1.0/kogniterm/core/tools/think_tool.py +34 -0
- kogniterm-0.1.0/kogniterm/core/tools/tool_manager.py +149 -0
- kogniterm-0.1.0/kogniterm/core/tools/web_fetch_tool.py +36 -0
- kogniterm-0.1.0/kogniterm/core/tools/web_scraping_tool.py +37 -0
- kogniterm-0.1.0/kogniterm/core/utils/__init__.py +1 -0
- kogniterm-0.1.0/kogniterm/core/utils/tool_utils.py +104 -0
- kogniterm-0.1.0/kogniterm/docs/Cambios.md +21 -0
- kogniterm-0.1.0/kogniterm/docs/researcher_agent_flow.md +36 -0
- kogniterm-0.1.0/kogniterm/main.py +3 -0
- kogniterm-0.1.0/kogniterm/requirements.txt +26 -0
- kogniterm-0.1.0/kogniterm/terminal/__init__.py +0 -0
- kogniterm-0.1.0/kogniterm/terminal/agent_interaction_manager.py +131 -0
- kogniterm-0.1.0/kogniterm/terminal/command_approval_handler.py +408 -0
- kogniterm-0.1.0/kogniterm/terminal/config_manager.py +84 -0
- kogniterm-0.1.0/kogniterm/terminal/keyboard_handler.py +57 -0
- kogniterm-0.1.0/kogniterm/terminal/kogniterm_app.py +718 -0
- kogniterm-0.1.0/kogniterm/terminal/meta_command_processor.py +697 -0
- kogniterm-0.1.0/kogniterm/terminal/terminal.py +453 -0
- kogniterm-0.1.0/kogniterm/terminal/terminal_ui.py +277 -0
- kogniterm-0.1.0/kogniterm/terminal/themes.py +688 -0
- kogniterm-0.1.0/kogniterm/terminal/visual_components.py +601 -0
- kogniterm-0.1.0/kogniterm/utils/__init__.py +2 -0
- kogniterm-0.1.0/kogniterm/utils/diff_renderer.py +242 -0
- kogniterm-0.1.0/kogniterm/utils/playwright_browser_manager.py +49 -0
- kogniterm-0.1.0/kogniterm.egg-info/PKG-INFO +235 -0
- kogniterm-0.1.0/kogniterm.egg-info/SOURCES.txt +88 -0
- kogniterm-0.1.0/kogniterm.egg-info/dependency_links.txt +1 -0
- kogniterm-0.1.0/kogniterm.egg-info/entry_points.txt +2 -0
- kogniterm-0.1.0/kogniterm.egg-info/requires.txt +37 -0
- kogniterm-0.1.0/kogniterm.egg-info/top_level.txt +1 -0
- kogniterm-0.1.0/pyproject.toml +78 -0
- kogniterm-0.1.0/setup.cfg +4 -0
- kogniterm-0.1.0/setup.py +4 -0
- kogniterm-0.1.0/tests/test_tool_message_preservation.py +92 -0
kogniterm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 KogniTerm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
include requirements.txt
|
|
5
|
+
recursive-include kogniterm *.py
|
|
6
|
+
recursive-include kogniterm *.txt
|
|
7
|
+
recursive-include kogniterm *.json
|
|
8
|
+
recursive-include kogniterm *.md
|
|
9
|
+
global-exclude __pycache__
|
|
10
|
+
global-exclude *.py[cod]
|
|
11
|
+
global-exclude .env
|
|
12
|
+
global-exclude .env.*
|
|
13
|
+
global-exclude .kogniterm/*
|
kogniterm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kogniterm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Un asistente de terminal agéntico de última generación impulsado por IA.
|
|
5
|
+
Author-email: Gato Villano <gato@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gatovillano/KogniTerm
|
|
8
|
+
Project-URL: Repository, https://github.com/gatovillano/KogniTerm
|
|
9
|
+
Project-URL: Issues, https://github.com/gatovillano/KogniTerm/issues
|
|
10
|
+
Keywords: terminal,ai,agent,assistant,llm,automation
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: python-dotenv
|
|
21
|
+
Requires-Dist: langchain
|
|
22
|
+
Requires-Dist: langchain-core
|
|
23
|
+
Requires-Dist: langgraph
|
|
24
|
+
Requires-Dist: prompt_toolkit
|
|
25
|
+
Requires-Dist: langchain_mcp_adapters
|
|
26
|
+
Requires-Dist: langchain_community
|
|
27
|
+
Requires-Dist: beautifulsoup4
|
|
28
|
+
Requires-Dist: PyGithub
|
|
29
|
+
Requires-Dist: rich
|
|
30
|
+
Requires-Dist: matplotlib
|
|
31
|
+
Requires-Dist: google-genai
|
|
32
|
+
Requires-Dist: jupyter_client
|
|
33
|
+
Requires-Dist: loguru
|
|
34
|
+
Requires-Dist: colorama
|
|
35
|
+
Requires-Dist: gitignore-parser
|
|
36
|
+
Requires-Dist: watchdog
|
|
37
|
+
Requires-Dist: litellm
|
|
38
|
+
Requires-Dist: playwright
|
|
39
|
+
Requires-Dist: GitPython
|
|
40
|
+
Requires-Dist: pydantic
|
|
41
|
+
Requires-Dist: pydantic-settings
|
|
42
|
+
Requires-Dist: chromadb
|
|
43
|
+
Requires-Dist: urllib3<2
|
|
44
|
+
Requires-Dist: pyautogui
|
|
45
|
+
Requires-Dist: pywinctl
|
|
46
|
+
Requires-Dist: langchain-litellm
|
|
47
|
+
Requires-Dist: nest_asyncio
|
|
48
|
+
Requires-Dist: tiktoken
|
|
49
|
+
Requires-Dist: requests
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: radon; extra == "dev"
|
|
52
|
+
Requires-Dist: pylint; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest; extra == "dev"
|
|
54
|
+
Requires-Dist: build; extra == "dev"
|
|
55
|
+
Requires-Dist: twine; extra == "dev"
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
# 🤖 KogniTerm
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
**KogniTerm** es un asistente de terminal agéntico de última generación. Transforma tu línea de comandos en un entorno de desarrollo colaborativo donde **Agentes de IA Especializados** trabajan contigo para razonar, investigar, codificar y ejecutar tareas complejas.
|
|
63
|
+
|
|
64
|
+
A diferencia de otros asistentes, KogniTerm no depende de las capacidades nativas de "Tool Calling" de los modelos. Gracias a su **Motor de Parseo Universal**, es capaz de otorgar capacidades agénticas a prácticamente cualquier LLM (DeepSeek, Llama 3, Mistral, etc.), interpretando sus intenciones directamente desde el lenguaje natural.
|
|
65
|
+
|
|
66
|
+
## ✨ Características Principales
|
|
67
|
+
|
|
68
|
+
### 🧠 Arquitectura Multi-Agente Especializada
|
|
69
|
+
|
|
70
|
+
KogniTerm orquesta un equipo de expertos digitales, cada uno con un rol y personalidad definidos:
|
|
71
|
+
|
|
72
|
+
* **🕵️ ResearcherAgent (El Detective)**:
|
|
73
|
+
* **Rol**: Experto en comprensión y análisis.
|
|
74
|
+
* **Misión**: Lee tu código, investiga documentación y explica sistemas complejos sin riesgo de romper nada.
|
|
75
|
+
* **Cuándo usarlo**: "Explícame cómo funciona X", "Analiza este error", "Investiga la arquitectura".
|
|
76
|
+
|
|
77
|
+
* **👨💻 CodeAgent (El Desarrollador Senior)**:
|
|
78
|
+
* **Rol**: Ingeniero de software enfocado en calidad.
|
|
79
|
+
* **Principios**: Calidad sobre velocidad, verificación constante y seguridad.
|
|
80
|
+
* **Misión**: Escribe, refactoriza y parchea código. Siempre verifica el contenido antes de editar y busca minimizar errores.
|
|
81
|
+
* **Cuándo usarlo**: "Refactoriza esta función", "Crea un script para...", "Arregla el bug en main.py".
|
|
82
|
+
|
|
83
|
+
* **🤖 BashAgent (El Operador)**:
|
|
84
|
+
* **Rol**: Tu interfaz principal y orquestador.
|
|
85
|
+
* **Misión**: Maneja la terminal, ejecuta comandos del sistema y sabe exactamente a qué especialista delegar cada tarea.
|
|
86
|
+
|
|
87
|
+
### 🌐 Compatibilidad Universal (The "Any-Model" Engine)
|
|
88
|
+
|
|
89
|
+
KogniTerm rompe las barreras de los proveedores. Su sistema de **Parseo de Herramientas Híbrido** permite:
|
|
90
|
+
|
|
91
|
+
* **Soporte Nativo**: OpenAI, Anthropic, Google Gemini.
|
|
92
|
+
* **Soporte Extendido**: **DeepSeek**, **SiliconFlow**, **Nex-AGI**, y modelos locales (Ollama).
|
|
93
|
+
* **Text-to-Tool**: Si un modelo no soporta llamadas a funciones, KogniTerm detecta patrones en su texto (JSON, XML, YAML, o lenguaje natural) y ejecuta las herramientas correspondientes. ¡Haz agéntico a cualquier modelo!
|
|
94
|
+
|
|
95
|
+
### 🛠 Herramientas de Potencia Industrial
|
|
96
|
+
|
|
97
|
+
* **Sistema de Archivos Seguro**: Lectura recursiva inteligente, búsquedas con `grep` y edición atómica.
|
|
98
|
+
* **RAG Local (Indexado de Código)**: Convierte tu base de código en una base de conocimiento consultable.
|
|
99
|
+
* **Búsqueda Web**: Acceso a internet para documentación actualizada y resolución de errores en tiempo real.
|
|
100
|
+
* **Intérprete Python Persistente**: Un entorno REPL para cálculos, procesamiento de datos y lógica compleja.
|
|
101
|
+
|
|
102
|
+
### 🛡 Seguridad y Control
|
|
103
|
+
|
|
104
|
+
* **Human-in-the-loop**: Confirmación explícita antes de comandos destructivos o ediciones de archivos.
|
|
105
|
+
* **Modo Auto-Aprobación (`-y`)**: Para automatización supervisada.
|
|
106
|
+
* **Visualización de Diffs**: Revisa exactamente qué cambiará en tu código antes de aplicarlo.
|
|
107
|
+
|
|
108
|
+
## 🚀 Instalación
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Instalar con pipx (recomendado para aislar dependencias)
|
|
112
|
+
pipx install kogniterm
|
|
113
|
+
|
|
114
|
+
# O con pip
|
|
115
|
+
pip install kogniterm
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## ⚙️ Configuración y Gestión (CLI)
|
|
119
|
+
|
|
120
|
+
KogniTerm incluye una CLI dedicada para gestionar tus llaves y modelos sin editar archivos de configuración manualmente.
|
|
121
|
+
|
|
122
|
+
### 🔑 Gestión de API Keys
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Configurar OpenRouter (Acceso a DeepSeek, Llama, etc.)
|
|
126
|
+
kogniterm keys set openrouter sk-or-v1-...
|
|
127
|
+
|
|
128
|
+
# Configurar Google Gemini
|
|
129
|
+
kogniterm keys set google AIzaSy...
|
|
130
|
+
|
|
131
|
+
# Configurar OpenAI
|
|
132
|
+
kogniterm keys set openai sk-...
|
|
133
|
+
|
|
134
|
+
# Ver estado de las llaves
|
|
135
|
+
kogniterm keys list
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 🧠 Selección de Modelos
|
|
139
|
+
|
|
140
|
+
Cambia el "cerebro" de KogniTerm al instante:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Usar DeepSeek vía OpenRouter (Ejemplo)
|
|
144
|
+
kogniterm models use openrouter/deepseek/deepseek-chat
|
|
145
|
+
|
|
146
|
+
# Usar Gemini 2.0 Flash
|
|
147
|
+
kogniterm models use google/gemini-2.0-flash-exp
|
|
148
|
+
|
|
149
|
+
# Ver modelo activo
|
|
150
|
+
kogniterm models current
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 🎮 Experiencia Interactiva
|
|
154
|
+
|
|
155
|
+
Una vez dentro de `kogniterm`, tienes superpoderes:
|
|
156
|
+
|
|
157
|
+
### Comandos Mágicos (`%`)
|
|
158
|
+
|
|
159
|
+
* **`%models`**: Abre un **menú interactivo** para cambiar de modelo en caliente sin reiniciar la sesión.
|
|
160
|
+
* **`%help`**: Panel de ayuda navegable.
|
|
161
|
+
* **`%reset`**: Limpia el contexto y comienza de cero.
|
|
162
|
+
* **`%undo`**: ¿El modelo se equivocó? Deshaz la última acción.
|
|
163
|
+
* **`%compress`**: Resume el historial para ahorrar tokens manteniendo lo importante.
|
|
164
|
+
|
|
165
|
+
### Referencias Inteligentes (`@`)
|
|
166
|
+
|
|
167
|
+
Inyecta contexto de archivos directamente en tu prompt:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
(kogniterm) › ¿Qué hace la función process en @core/logic.py?
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
El autocompletado te ayudará a encontrar tus archivos al instante.
|
|
174
|
+
|
|
175
|
+
## 🧠 Indexado de Código (RAG)
|
|
176
|
+
|
|
177
|
+
Para preguntas sobre la arquitectura global de tu proyecto:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Indexar el directorio actual
|
|
181
|
+
kogniterm index .
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Esto permite a los agentes entender relaciones entre archivos que no han leído explícitamente.
|
|
185
|
+
|
|
186
|
+
## 📚 Documentación
|
|
187
|
+
|
|
188
|
+
Explora la documentación detallada para entender a fondo KogniTerm:
|
|
189
|
+
|
|
190
|
+
### 🤝 Colaboración
|
|
191
|
+
|
|
192
|
+
* [Guía de Contribución](CONTRIBUTING.md)
|
|
193
|
+
* [Código de Conducta](CODE_OF_CONDUCT.md)
|
|
194
|
+
|
|
195
|
+
### 🏗 Arquitectura y Diseño
|
|
196
|
+
|
|
197
|
+
* [Visión General](docs/overview.md)
|
|
198
|
+
* [Arquitectura del Sistema](docs/arquitectura_documentacion.md)
|
|
199
|
+
* [Módulos del Sistema](docs/modules.md)
|
|
200
|
+
* [Diagrama de Flujo](docs/flow_diagram.md)
|
|
201
|
+
|
|
202
|
+
### 🧩 Componentes y Herramientas
|
|
203
|
+
|
|
204
|
+
* [Gestor de Historial](docs/history_manager_documentation.md)
|
|
205
|
+
* [Herramienta de Creación de Planes](docs/plan_creation_tool.md)
|
|
206
|
+
* [Archivos CLI de Gemini](docs/gemini_cli_files.md)
|
|
207
|
+
|
|
208
|
+
### 🧠 Sistema RAG (Indexado)
|
|
209
|
+
|
|
210
|
+
* [Propuesta de RAG](docs/rag_codebase_proposal.md)
|
|
211
|
+
* [Plan de Implementación](docs/rag_implementation_plan.md)
|
|
212
|
+
* [Estado de Implementación](docs/rag_implementation_status.md)
|
|
213
|
+
|
|
214
|
+
### 📝 Registros
|
|
215
|
+
|
|
216
|
+
* [Registro de Cambios](docs/Cambios.md)
|
|
217
|
+
* [Registro de Errores y Soluciones](docs/registro_errores_soluciones.md)
|
|
218
|
+
* [Log de Desarrollo](docs/development_log.md)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
*Desarrollado por Gatovillano*
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 💙 Apoya el Proyecto
|
|
226
|
+
|
|
227
|
+
Si encuentras útil este proyecto, considera hacer una donación para apoyar su desarrollo continuo. Cada contribución ayuda a mantener el proyecto activo y a agregar nuevas características.
|
|
228
|
+
|
|
229
|
+
[](https://www.paypal.com/donate?hosted_button_id=TU_ID_DE_BOTÓN)
|
|
230
|
+
|
|
231
|
+
O también puedes apoyar a través de:
|
|
232
|
+
- [GitHub Sponsors](https://github.com/sponsors/tu-usuario)
|
|
233
|
+
- [Patreon](https://www.patreon.com/tu-usuario)
|
|
234
|
+
|
|
235
|
+
¡Gracias por tu apoyo! 🙌
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# 🤖 KogniTerm
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
**KogniTerm** es un asistente de terminal agéntico de última generación. Transforma tu línea de comandos en un entorno de desarrollo colaborativo donde **Agentes de IA Especializados** trabajan contigo para razonar, investigar, codificar y ejecutar tareas complejas.
|
|
6
|
+
|
|
7
|
+
A diferencia de otros asistentes, KogniTerm no depende de las capacidades nativas de "Tool Calling" de los modelos. Gracias a su **Motor de Parseo Universal**, es capaz de otorgar capacidades agénticas a prácticamente cualquier LLM (DeepSeek, Llama 3, Mistral, etc.), interpretando sus intenciones directamente desde el lenguaje natural.
|
|
8
|
+
|
|
9
|
+
## ✨ Características Principales
|
|
10
|
+
|
|
11
|
+
### 🧠 Arquitectura Multi-Agente Especializada
|
|
12
|
+
|
|
13
|
+
KogniTerm orquesta un equipo de expertos digitales, cada uno con un rol y personalidad definidos:
|
|
14
|
+
|
|
15
|
+
* **🕵️ ResearcherAgent (El Detective)**:
|
|
16
|
+
* **Rol**: Experto en comprensión y análisis.
|
|
17
|
+
* **Misión**: Lee tu código, investiga documentación y explica sistemas complejos sin riesgo de romper nada.
|
|
18
|
+
* **Cuándo usarlo**: "Explícame cómo funciona X", "Analiza este error", "Investiga la arquitectura".
|
|
19
|
+
|
|
20
|
+
* **👨💻 CodeAgent (El Desarrollador Senior)**:
|
|
21
|
+
* **Rol**: Ingeniero de software enfocado en calidad.
|
|
22
|
+
* **Principios**: Calidad sobre velocidad, verificación constante y seguridad.
|
|
23
|
+
* **Misión**: Escribe, refactoriza y parchea código. Siempre verifica el contenido antes de editar y busca minimizar errores.
|
|
24
|
+
* **Cuándo usarlo**: "Refactoriza esta función", "Crea un script para...", "Arregla el bug en main.py".
|
|
25
|
+
|
|
26
|
+
* **🤖 BashAgent (El Operador)**:
|
|
27
|
+
* **Rol**: Tu interfaz principal y orquestador.
|
|
28
|
+
* **Misión**: Maneja la terminal, ejecuta comandos del sistema y sabe exactamente a qué especialista delegar cada tarea.
|
|
29
|
+
|
|
30
|
+
### 🌐 Compatibilidad Universal (The "Any-Model" Engine)
|
|
31
|
+
|
|
32
|
+
KogniTerm rompe las barreras de los proveedores. Su sistema de **Parseo de Herramientas Híbrido** permite:
|
|
33
|
+
|
|
34
|
+
* **Soporte Nativo**: OpenAI, Anthropic, Google Gemini.
|
|
35
|
+
* **Soporte Extendido**: **DeepSeek**, **SiliconFlow**, **Nex-AGI**, y modelos locales (Ollama).
|
|
36
|
+
* **Text-to-Tool**: Si un modelo no soporta llamadas a funciones, KogniTerm detecta patrones en su texto (JSON, XML, YAML, o lenguaje natural) y ejecuta las herramientas correspondientes. ¡Haz agéntico a cualquier modelo!
|
|
37
|
+
|
|
38
|
+
### 🛠 Herramientas de Potencia Industrial
|
|
39
|
+
|
|
40
|
+
* **Sistema de Archivos Seguro**: Lectura recursiva inteligente, búsquedas con `grep` y edición atómica.
|
|
41
|
+
* **RAG Local (Indexado de Código)**: Convierte tu base de código en una base de conocimiento consultable.
|
|
42
|
+
* **Búsqueda Web**: Acceso a internet para documentación actualizada y resolución de errores en tiempo real.
|
|
43
|
+
* **Intérprete Python Persistente**: Un entorno REPL para cálculos, procesamiento de datos y lógica compleja.
|
|
44
|
+
|
|
45
|
+
### 🛡 Seguridad y Control
|
|
46
|
+
|
|
47
|
+
* **Human-in-the-loop**: Confirmación explícita antes de comandos destructivos o ediciones de archivos.
|
|
48
|
+
* **Modo Auto-Aprobación (`-y`)**: Para automatización supervisada.
|
|
49
|
+
* **Visualización de Diffs**: Revisa exactamente qué cambiará en tu código antes de aplicarlo.
|
|
50
|
+
|
|
51
|
+
## 🚀 Instalación
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Instalar con pipx (recomendado para aislar dependencias)
|
|
55
|
+
pipx install kogniterm
|
|
56
|
+
|
|
57
|
+
# O con pip
|
|
58
|
+
pip install kogniterm
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## ⚙️ Configuración y Gestión (CLI)
|
|
62
|
+
|
|
63
|
+
KogniTerm incluye una CLI dedicada para gestionar tus llaves y modelos sin editar archivos de configuración manualmente.
|
|
64
|
+
|
|
65
|
+
### 🔑 Gestión de API Keys
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Configurar OpenRouter (Acceso a DeepSeek, Llama, etc.)
|
|
69
|
+
kogniterm keys set openrouter sk-or-v1-...
|
|
70
|
+
|
|
71
|
+
# Configurar Google Gemini
|
|
72
|
+
kogniterm keys set google AIzaSy...
|
|
73
|
+
|
|
74
|
+
# Configurar OpenAI
|
|
75
|
+
kogniterm keys set openai sk-...
|
|
76
|
+
|
|
77
|
+
# Ver estado de las llaves
|
|
78
|
+
kogniterm keys list
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 🧠 Selección de Modelos
|
|
82
|
+
|
|
83
|
+
Cambia el "cerebro" de KogniTerm al instante:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Usar DeepSeek vía OpenRouter (Ejemplo)
|
|
87
|
+
kogniterm models use openrouter/deepseek/deepseek-chat
|
|
88
|
+
|
|
89
|
+
# Usar Gemini 2.0 Flash
|
|
90
|
+
kogniterm models use google/gemini-2.0-flash-exp
|
|
91
|
+
|
|
92
|
+
# Ver modelo activo
|
|
93
|
+
kogniterm models current
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 🎮 Experiencia Interactiva
|
|
97
|
+
|
|
98
|
+
Una vez dentro de `kogniterm`, tienes superpoderes:
|
|
99
|
+
|
|
100
|
+
### Comandos Mágicos (`%`)
|
|
101
|
+
|
|
102
|
+
* **`%models`**: Abre un **menú interactivo** para cambiar de modelo en caliente sin reiniciar la sesión.
|
|
103
|
+
* **`%help`**: Panel de ayuda navegable.
|
|
104
|
+
* **`%reset`**: Limpia el contexto y comienza de cero.
|
|
105
|
+
* **`%undo`**: ¿El modelo se equivocó? Deshaz la última acción.
|
|
106
|
+
* **`%compress`**: Resume el historial para ahorrar tokens manteniendo lo importante.
|
|
107
|
+
|
|
108
|
+
### Referencias Inteligentes (`@`)
|
|
109
|
+
|
|
110
|
+
Inyecta contexto de archivos directamente en tu prompt:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
(kogniterm) › ¿Qué hace la función process en @core/logic.py?
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
El autocompletado te ayudará a encontrar tus archivos al instante.
|
|
117
|
+
|
|
118
|
+
## 🧠 Indexado de Código (RAG)
|
|
119
|
+
|
|
120
|
+
Para preguntas sobre la arquitectura global de tu proyecto:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Indexar el directorio actual
|
|
124
|
+
kogniterm index .
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Esto permite a los agentes entender relaciones entre archivos que no han leído explícitamente.
|
|
128
|
+
|
|
129
|
+
## 📚 Documentación
|
|
130
|
+
|
|
131
|
+
Explora la documentación detallada para entender a fondo KogniTerm:
|
|
132
|
+
|
|
133
|
+
### 🤝 Colaboración
|
|
134
|
+
|
|
135
|
+
* [Guía de Contribución](CONTRIBUTING.md)
|
|
136
|
+
* [Código de Conducta](CODE_OF_CONDUCT.md)
|
|
137
|
+
|
|
138
|
+
### 🏗 Arquitectura y Diseño
|
|
139
|
+
|
|
140
|
+
* [Visión General](docs/overview.md)
|
|
141
|
+
* [Arquitectura del Sistema](docs/arquitectura_documentacion.md)
|
|
142
|
+
* [Módulos del Sistema](docs/modules.md)
|
|
143
|
+
* [Diagrama de Flujo](docs/flow_diagram.md)
|
|
144
|
+
|
|
145
|
+
### 🧩 Componentes y Herramientas
|
|
146
|
+
|
|
147
|
+
* [Gestor de Historial](docs/history_manager_documentation.md)
|
|
148
|
+
* [Herramienta de Creación de Planes](docs/plan_creation_tool.md)
|
|
149
|
+
* [Archivos CLI de Gemini](docs/gemini_cli_files.md)
|
|
150
|
+
|
|
151
|
+
### 🧠 Sistema RAG (Indexado)
|
|
152
|
+
|
|
153
|
+
* [Propuesta de RAG](docs/rag_codebase_proposal.md)
|
|
154
|
+
* [Plan de Implementación](docs/rag_implementation_plan.md)
|
|
155
|
+
* [Estado de Implementación](docs/rag_implementation_status.md)
|
|
156
|
+
|
|
157
|
+
### 📝 Registros
|
|
158
|
+
|
|
159
|
+
* [Registro de Cambios](docs/Cambios.md)
|
|
160
|
+
* [Registro de Errores y Soluciones](docs/registro_errores_soluciones.md)
|
|
161
|
+
* [Log de Desarrollo](docs/development_log.md)
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
*Desarrollado por Gatovillano*
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 💙 Apoya el Proyecto
|
|
169
|
+
|
|
170
|
+
Si encuentras útil este proyecto, considera hacer una donación para apoyar su desarrollo continuo. Cada contribución ayuda a mantener el proyecto activo y a agregar nuevas características.
|
|
171
|
+
|
|
172
|
+
[](https://www.paypal.com/donate?hosted_button_id=TU_ID_DE_BOTÓN)
|
|
173
|
+
|
|
174
|
+
O también puedes apoyar a través de:
|
|
175
|
+
- [GitHub Sponsors](https://github.com/sponsors/tu-usuario)
|
|
176
|
+
- [Patreon](https://www.patreon.com/tu-usuario)
|
|
177
|
+
|
|
178
|
+
¡Gracias por tu apoyo! 🙌
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
File without changes
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from collections import deque # Importar deque
|
|
5
|
+
from typing import List, Optional, Dict, Any, Union
|
|
6
|
+
from langchain_core.messages import BaseMessage, HumanMessage, AIMessage, ToolMessage, SystemMessage
|
|
7
|
+
# No necesitamos importar LLMService aquí para los métodos estáticos de historial
|
|
8
|
+
# from kogniterm.core.llm_service import LLMService
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class AgentState:
|
|
12
|
+
"""Define la estructura del estado que fluye a través del grafo."""
|
|
13
|
+
messages: List[BaseMessage] = field(default_factory=list)
|
|
14
|
+
command_to_confirm: Optional[str] = None # Nuevo campo para comandos que requieren confirmación
|
|
15
|
+
tool_call_id_to_confirm: Optional[str] = None # Nuevo campo para el tool_call_id asociado al comando
|
|
16
|
+
current_agent_mode: str = "bash" # Añadido para el modo del agente
|
|
17
|
+
history_for_api: Optional[List[BaseMessage]] = field(default=None, repr=False, compare=False) # Campo temporal para compatibilidad
|
|
18
|
+
|
|
19
|
+
# Nuevos campos para manejar la confirmación de herramientas
|
|
20
|
+
tool_pending_confirmation: Optional[str] = None
|
|
21
|
+
tool_args_pending_confirmation: Optional[Dict[str, Any]] = None
|
|
22
|
+
tool_code_to_confirm: Optional[str] = None # Nuevo campo para el código (diff) a confirmar
|
|
23
|
+
tool_code_tool_name: Optional[str] = None # Nuevo campo para el nombre de la herramienta que generó el código
|
|
24
|
+
tool_code_tool_args: Optional[Dict[str, Any]] = None # Nuevo campo para los args originales de la herramienta
|
|
25
|
+
file_update_diff_pending_confirmation: Optional[Union[str, Dict[str, Any]]] = None # Nuevo campo para el diff de file_update_tool
|
|
26
|
+
search_memory: List[Dict[str, Any]] = field(default_factory=list) # ¡Nuevo campo para la memoria de búsqueda!
|
|
27
|
+
tool_call_history: deque = field(default_factory=lambda: deque(maxlen=5)) # Historial de llamadas a herramientas para detección de bucles
|
|
28
|
+
|
|
29
|
+
# Añadir un campo para la ruta del archivo de historial
|
|
30
|
+
history_file_path: str = field(default_factory=lambda: os.path.join(os.getcwd(), ".kogniterm", "history.json"))
|
|
31
|
+
|
|
32
|
+
def reset_tool_confirmation(self):
|
|
33
|
+
"""Reinicia el estado de la confirmación de herramientas."""
|
|
34
|
+
self.tool_pending_confirmation = None
|
|
35
|
+
self.tool_args_pending_confirmation = None
|
|
36
|
+
self.tool_code_to_confirm = None
|
|
37
|
+
self.tool_code_tool_name = None
|
|
38
|
+
self.tool_code_tool_args = None
|
|
39
|
+
self.file_update_diff_pending_confirmation = None # Limpiar el diff también
|
|
40
|
+
|
|
41
|
+
def reset(self):
|
|
42
|
+
"""Reinicia completamente el estado del agente."""
|
|
43
|
+
self.messages = []
|
|
44
|
+
self.command_to_confirm = None
|
|
45
|
+
self.tool_call_id_to_confirm = None
|
|
46
|
+
self.reset_tool_confirmation()
|
|
47
|
+
self.file_update_diff_pending_confirmation = None # Limpiar el diff también
|
|
48
|
+
|
|
49
|
+
def reset_temporary_state(self):
|
|
50
|
+
"""Reinicia los campos de estado temporal del agente, manteniendo el historial de mensajes."""
|
|
51
|
+
self.command_to_confirm = None
|
|
52
|
+
self.reset_tool_confirmation()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def __post_init__(self):
|
|
56
|
+
# Si se pasó history_for_api pero no messages, sincronizar
|
|
57
|
+
if self.history_for_api is not None and not self.messages:
|
|
58
|
+
self.messages = self.history_for_api
|
|
59
|
+
|
|
60
|
+
def load_history(self, system_message: SystemMessage, llm_service: Any): # Añadir llm_service como parámetro
|
|
61
|
+
"""Carga el historial de conversación desde el archivo especificado y asegura el SYSTEM_MESSAGE."""
|
|
62
|
+
loaded_messages = llm_service.history_manager._load_history() # Usar la instancia de history_manager
|
|
63
|
+
|
|
64
|
+
# Asegurarse de que el SYSTEM_MESSAGE esté al principio
|
|
65
|
+
if not loaded_messages or not (isinstance(loaded_messages[0], SystemMessage) and loaded_messages[0].content == system_message.content):
|
|
66
|
+
self.messages.append(system_message)
|
|
67
|
+
|
|
68
|
+
# Añadir los mensajes cargados después del SYSTEM_MESSAGE
|
|
69
|
+
for msg in loaded_messages:
|
|
70
|
+
if not (isinstance(msg, SystemMessage) and msg.content == system_message.content):
|
|
71
|
+
self.messages.append(msg)
|
|
72
|
+
|
|
73
|
+
# Eliminar duplicados del SYSTEM_MESSAGE si se cargó desde el archivo y también se añadió manualmente
|
|
74
|
+
system_message_count = sum(1 for msg in self.messages if isinstance(msg, SystemMessage) and msg.content == system_message.content)
|
|
75
|
+
if system_message_count > 1:
|
|
76
|
+
first_system_message_index = -1
|
|
77
|
+
indices_to_remove = []
|
|
78
|
+
for i, msg in enumerate(self.messages):
|
|
79
|
+
if isinstance(msg, SystemMessage) and msg.content == system_message.content:
|
|
80
|
+
if first_system_message_index == -1:
|
|
81
|
+
first_system_message_index = i
|
|
82
|
+
else:
|
|
83
|
+
indices_to_remove.append(i)
|
|
84
|
+
|
|
85
|
+
# Eliminar los SYSTEM_MESSAGE duplicados, empezando por el final para no afectar los índices
|
|
86
|
+
for i in sorted(indices_to_remove, reverse=True):
|
|
87
|
+
self.messages.pop(i)
|
|
88
|
+
|
|
89
|
+
# Eliminar ToolMessages duplicados, manteniendo solo el último para cada tool_call_id
|
|
90
|
+
tool_messages_seen = {}
|
|
91
|
+
indices_to_remove = []
|
|
92
|
+
for i, msg in enumerate(self.messages):
|
|
93
|
+
if isinstance(msg, ToolMessage) and msg.tool_call_id:
|
|
94
|
+
if msg.tool_call_id in tool_messages_seen:
|
|
95
|
+
indices_to_remove.append(tool_messages_seen[msg.tool_call_id])
|
|
96
|
+
tool_messages_seen[msg.tool_call_id] = i
|
|
97
|
+
|
|
98
|
+
# Eliminar los ToolMessages duplicados anteriores, empezando por el final
|
|
99
|
+
for i in sorted(indices_to_remove, reverse=True):
|
|
100
|
+
self.messages.pop(i)
|
|
101
|
+
|
|
102
|
+
def save_history(self, llm_service: Any): # Añadir llm_service como parámetro
|
|
103
|
+
"""Guarda el historial de conversación actual en el archivo especificado."""
|
|
104
|
+
llm_service.history_manager._save_history(self.messages) # Usar la instancia de history_manager
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# KogniTerm Agents Package
|