terra-hiven 3.2.0
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.
- package/LICENSE.md +20 -0
- package/README.md +233 -0
- package/assets/hiven_logo_v2.png +0 -0
- package/bin/hiven.js +225 -0
- package/console/.nojekyll +0 -0
- package/console/app.js +588 -0
- package/console/assets/hiven_logo_v2.png +0 -0
- package/console/data/swarms_history.json +38 -0
- package/console/index.html +694 -0
- package/console/style.css +1039 -0
- package/console/webbl.config.json +5 -0
- package/dist/api.d.ts +13 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +142 -0
- package/dist/api.js.map +1 -0
- package/dist/honeycombs.d.ts +30 -0
- package/dist/honeycombs.d.ts.map +1 -0
- package/dist/honeycombs.js +221 -0
- package/dist/honeycombs.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/inference.d.ts +33 -0
- package/dist/inference.d.ts.map +1 -0
- package/dist/inference.js +217 -0
- package/dist/inference.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +54 -0
- package/dist/server.js.map +1 -0
- package/dist/swarm.d.ts +30 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +196 -0
- package/dist/swarm.js.map +1 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/vault.d.ts +19 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +99 -0
- package/dist/vault.js.map +1 -0
- package/package.json +63 -0
- package/templates/.github/workflows/swarm.yml +229 -0
- package/templates/package.json +13 -0
- package/templates/swarm_runner.js +1594 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Hiven Public License (HPL) Version 1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hiven Authors. All rights reserved.
|
|
4
|
+
|
|
5
|
+
## 1. Definitions
|
|
6
|
+
* **"Software"** refers to the Hiven source code repositories, files, workflows, templates, and documentation (including the Queen, Drone, and Worker orchestrations).
|
|
7
|
+
* **"Licensor"** refers to the copyright owners of the Software.
|
|
8
|
+
* **"You"** (or **"Your"**) refers to the individual or legal entity exercising permissions granted by this License.
|
|
9
|
+
|
|
10
|
+
## 2. Grant of Rights
|
|
11
|
+
* **Use and Inspection:** You are granted a free, worldwide, non-exclusive, non-transferable license to run, install, inspect, and execute the Software for personal, educational, or internal corporate purposes.
|
|
12
|
+
* **Private Modifications:** You are permitted to modify the Software solely for Your own private, internal usage, provided that these modifications are not made available to any third party.
|
|
13
|
+
|
|
14
|
+
## 3. Strict Restrictions and Prohibitions
|
|
15
|
+
* **No Redistribution:** You may NOT redistribute, publish, share, sell, rent, lease, or sub-license the Software, or any modified or unmodified derivative works thereof, to any third party in source or binary format.
|
|
16
|
+
* **No SaaS/PaaS Commercialization:** You may NOT use the Software (or any portion or derivative of it) to offer a commercial software-as-a-service (SaaS), platform-as-a-service (PaaS), managed service, API service, or cloud-hosted platform that competes directly or indirectly with Hiven.
|
|
17
|
+
* **Notice Preservation:** You must retain all copyright, trademark, and proprietary notices of the Licensor in all copies of the Software.
|
|
18
|
+
|
|
19
|
+
## 4. Limitation of Liability and Disclaimer
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/hiven_logo_v2.png" alt="Hiven Logo" width="150" style="border-radius: 12px; box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">HIVEN</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Agente Cognitivo Autónomo, Mente Enjambre Multi-Agente & Memoria Colectiva Honeycombs a Coste $0</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://amglogicalis.github.io/hiven-repo-public/"><img src="https://img.shields.io/badge/Console-Online%20Web%20Studio-d7ed04?style=for-the-badge&logo=googlechrome&logoColor=white" alt="Live Console" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/terra-hiven"><img src="https://img.shields.io/badge/npm-terra--hiven-d7ed04?style=for-the-badge&logo=npm&logoColor=black" alt="npm package" /></a>
|
|
14
|
+
<img src="https://img.shields.io/badge/Version-3.0.0-d7ed04?style=for-the-badge" alt="Version 3.0.0" />
|
|
15
|
+
<img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="License MIT" />
|
|
16
|
+
<img src="https://img.shields.io/badge/Architecture-100%25%20Serverless%20$0-blueviolet?style=for-the-badge" alt="Cost $0" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="#-visión-general-y-arquitectura-0">Visión General</a> •
|
|
21
|
+
<a href="#-instalación-y-puesta-en-marcha">Instalación</a> •
|
|
22
|
+
<a href="#-pipeline-multi-fase-y-robustez-al-99">Pipeline & Robustez</a> •
|
|
23
|
+
<a href="#-hiven-honeycombs-memoria-global">Hiven Honeycombs</a> •
|
|
24
|
+
<a href="#-referencia-del-cli-y-sdk">CLI & SDK</a> •
|
|
25
|
+
<a href="#-preguntas-frecuentes-faq">FAQ</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🌟 Visión General y Arquitectura $0
|
|
31
|
+
|
|
32
|
+
**HIVEN** es el primer titán cognitivo del ecosistema **Terra**. Transforma la potencia de cómputo gratuita de los runners de GitHub Actions en un laboratorio de desarrollo neuronal distribuido, capaz de analizar bases de código complejas, diseñar arquitecturas, escribir código mediante diffs quirúrgicos y auto-sanar errores en un sandbox aislado previo a la creación de Pull Requests:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
🐝 HIVEN ENGINE V3
|
|
36
|
+
(Autonomous Multi-Agent Swarm)
|
|
37
|
+
│
|
|
38
|
+
┌────────────────────┬───────────────┴───────────────┬────────────────────┐
|
|
39
|
+
▼ ▼ ▼ ▼
|
|
40
|
+
🖥️ HIVEN STUDIO 💻 CLI & SDK (terra-hiven) 🤖 ISSUE BOT GATEWAY 🍯 HIVEN HONEYCOMBS
|
|
41
|
+
(Web SPA Pages $0) (Hiven Swarm API) (Menciones @hiven) (Memoria Global K/V)
|
|
42
|
+
│ │ │ │
|
|
43
|
+
└────────────────────┼───────────────────────────────┴────────────────────┘
|
|
44
|
+
▼
|
|
45
|
+
⚡ WORKER SWARM (GitHub Actions)
|
|
46
|
+
[Phase 0] ➔ [Phase 1] ➔ [Phase 2] ➔ [Phase 3] ➔ [🩹 Self-Heal 3-5x] ➔ [🚀 PR]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Principios Fundamentales:
|
|
50
|
+
* **🔒 100% Privado y Soberano:** Todo el código se procesa en runners efímeros bajo la cuenta de GitHub del usuario.
|
|
51
|
+
* **🍯 Memoria Colectiva Honeycombs:** Subsistema K/V nativo a coste \$0 que acumula patrones (`hive_patterns:{ext}`) de buenas prácticas aprendidas.
|
|
52
|
+
* **🩹 Garantía de Robustez del 99%:** Incorpora bucle de auto-corrección (Self-Healing Loop) reinyectando trazas de error de tests hasta lograr compilación limpia (`exit 0`).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 📦 Instalación y Puesta en Marcha
|
|
57
|
+
|
|
58
|
+
### 1. Instalación Global del CLI:
|
|
59
|
+
```bash
|
|
60
|
+
# Directamente desde el registro público de NPM:
|
|
61
|
+
npm install -g terra-hiven
|
|
62
|
+
|
|
63
|
+
# O instalando el paquete local generado (.tgz):
|
|
64
|
+
npm install -g ./terra-hiven-3.2.0.tgz
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Publicación del Paquete en NPM:
|
|
68
|
+
El paquete compilado y empaquetado está listo en `c:\mis-proyectos\Terra\hiven\hiven-komb-queen\terra-hiven-3.2.0.tgz`. Para publicarlo en tu cuenta de npm:
|
|
69
|
+
```bash
|
|
70
|
+
npm publish terra-hiven-3.2.0.tgz --access public
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Ejecución Instantánea sin Instalación previa con `npx`:
|
|
74
|
+
```bash
|
|
75
|
+
# Iniciar la Consola Web local:
|
|
76
|
+
npx terra-hiven console
|
|
77
|
+
|
|
78
|
+
# Despachar una misión:
|
|
79
|
+
npx terra-hiven run --repo usuario/mi-app --prompt "Implementar login OAuth"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. Instalación como Dependencia en tu Proyecto (SDK):
|
|
83
|
+
```bash
|
|
84
|
+
npm install terra-hiven
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 4. Levantar la Consola Web Local (Hiven Studio):
|
|
88
|
+
```bash
|
|
89
|
+
# Puerto por defecto (7460):
|
|
90
|
+
hiven console
|
|
91
|
+
|
|
92
|
+
# En un puerto y host personalizado:
|
|
93
|
+
hiven console --port 8080 --host 0.0.0.0
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🧪 Pipeline Multi-Fase y Robustez al 99%
|
|
99
|
+
|
|
100
|
+
El enjambre de Hiven ejecuta un ciclo estricto y determinista:
|
|
101
|
+
|
|
102
|
+
1. **Fase 0 (Deterministic Extractor):** Extrae dependencias, scripts de test y firmas AST sin alucinaciones de LLM.
|
|
103
|
+
2. **Fase 1 (Swarm Architect):** Descompone la misión en un grafo acíclico de tareas (Task DAG) y selecciona patrones de Honeycombs.
|
|
104
|
+
3. **Fase 2 (Parallel Coders):** Nodos Kōmbee concurrentes escriben código aplicando bloques de búsqueda y reemplazo (`SEARCH/REPLACE`) quirúrgicos para evitar truncamiento de archivos.
|
|
105
|
+
4. **Fase 3 (Shadow Sandbox):** Ejecuta la suite de pruebas unitarias (`npm test`, `pytest`, `cargo test`) en un contenedor aislado.
|
|
106
|
+
5. **🩹 Bucle de Auto-Sanación (Self-Healing Loop):** Si los tests fallan, Hiven reinyecta los stack traces a un sub-enjambre de corrección (hasta 3-5 intentos) hasta que la suite pase en verde.
|
|
107
|
+
6. **Fase 4 (Consolidator):** Consolida los cambios ganadores y publica la Pull Request en GitHub.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 🍯 Hiven Honeycombs: Memoria Global Colectiva
|
|
112
|
+
|
|
113
|
+
**Honeycombs** es el subsistema de almacenamiento K/V nativo de Hiven que sustituye cualquier servicio SaaS externo. Almacena:
|
|
114
|
+
* **Patrones Federados (`hive_patterns:{ext}`):** Convenciones, librerías óptimas y directivas *Do's & Don'ts*.
|
|
115
|
+
* **Historial & Telemetría:** Tiempos de ejecución, rondas de auto-sanación y enlaces de PRs en `.hiven-storage`.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 💻 Referencia del CLI y SDK
|
|
120
|
+
|
|
121
|
+
### Uso Programático con TypeScript / ES Modules:
|
|
122
|
+
```typescript
|
|
123
|
+
import { Hiven } from 'terra-hiven';
|
|
124
|
+
|
|
125
|
+
const hiven = new Hiven({
|
|
126
|
+
githubToken: process.env.GITHUB_TOKEN
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
await hiven.init();
|
|
130
|
+
|
|
131
|
+
// Despachar una misión autónoma
|
|
132
|
+
const result = await hiven.dispatchSwarm({
|
|
133
|
+
repo: 'mi-organizacion/mi-app',
|
|
134
|
+
instruction: 'Añadir endpoints de autenticación y tests unitarios',
|
|
135
|
+
workerCount: 6,
|
|
136
|
+
testCommand: 'npm test',
|
|
137
|
+
maxSelfHealingRetries: 3
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
console.log(`Swarm despachado con éxito: ${result.swarmId}`);
|
|
141
|
+
console.log(`Pull Request: ${result.pullRequestUrl}`);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## ⚙️ Referencia Completa de Parámetros del Despachador
|
|
145
|
+
|
|
146
|
+
Tanto en la Consola Web como en el CLI (`hiven run`), puedes configurar los siguientes parámetros:
|
|
147
|
+
|
|
148
|
+
| Parámetro CLI | Control Consola | Tipo / Rango | Por Defecto | Descripción & Mejores Prácticas |
|
|
149
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
150
|
+
| `--repo` | Repositorio Objetivo | `owner/repo` | *Requerido* | Repositorio de GitHub destino. Requiere permisos de `repo` y `workflow`. |
|
|
151
|
+
| `--prompt` | Instrucción / Misión | Texto libre | *Requerido* | Especificación detallada de la tarea. Debe incluir archivos, entradas, salidas y restricciones. |
|
|
152
|
+
| `--branch` | Rama de Trabajo | String | `hiven/patch-[id]` | Rama donde se subirá el commit. Si se omite, se genera con timestamp. |
|
|
153
|
+
| `--baseBranch` | Rama Base | String | `main` | Rama destino contra la cual se abrirá la Pull Request. |
|
|
154
|
+
| `--workers` | Kōmbees Concurrentes | 1 – 10 | `4` | Nodos en paralelo. **2** para utilidades simples, **4** para features estándar, **6-10** para refactors masivos. |
|
|
155
|
+
| `--test-cmd` | Comando de Test | String | *Opcional* | Comando que el Shadow Sandbox ejecuta para verificar cambios (ej. `npm test`). **Es la brújula del Self-Healing**. |
|
|
156
|
+
| `--retries` | Reintentos Self-Healing | 1, 3, 5 | `3` | Rondas máximas de auto-corrección ante fallos de tests. **3** es el balance óptimo para alcanzar el 99% de éxito. |
|
|
157
|
+
| `--dry-run` | Modo de Ejecución | Boolean | `false` | Si se activa, simula la descomposición y valida diffs en local sin tocar GitHub. |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 🎯 Manual de Buen Prompting para Enjambres
|
|
162
|
+
|
|
163
|
+
Hiven no es un chatbot conversacional; es un enjambre de síntesis determinista. **Los agentes prosperan cuando les proporcionas criterios de éxito verificables, no intenciones difusas.**
|
|
164
|
+
|
|
165
|
+
### La Fórmula en 4 Pasos:
|
|
166
|
+
1. **Ubicación & Módulo Objetivo:** Especifica el archivo o directorio a crear o editar (ej. `src/utils/math.ts`).
|
|
167
|
+
2. **Contrato de la Interfaz:** Nombres de funciones, parámetros, tipos esperados y estructura del retorno.
|
|
168
|
+
3. **Casos Límite & Restricciones:** Manejo de excepciones, timeouts, nulos o compatibilidad ESM.
|
|
169
|
+
4. **Criterio de Verificación:** Comando de test unitario o aserciones que deben validarse en el Shadow Sandbox.
|
|
170
|
+
|
|
171
|
+
### Ejemplos Comparativos:
|
|
172
|
+
|
|
173
|
+
#### ❌ Mal Prompt (Vago & Ambiguo)
|
|
174
|
+
```text
|
|
175
|
+
Crea un validador de emails y ponle pruebas.
|
|
176
|
+
```
|
|
177
|
+
> *Problema:* No define archivo, estándar regex, si lanza error o retorna boolean, ni casos edge.
|
|
178
|
+
|
|
179
|
+
#### ✅ Buen Prompt (Específico & Determinista)
|
|
180
|
+
```text
|
|
181
|
+
Crear en src/validators/email.js la función isWorkEmail(email).
|
|
182
|
+
- Debe validar formato RFC 5322 y rechazar dominios gratuitos (gmail, yahoo, hotmail).
|
|
183
|
+
- Retornar { valid: boolean, domain: string, reason?: string }.
|
|
184
|
+
- Si el input no es string, lanzar TypeError.
|
|
185
|
+
- Exportar en ESM y crear suite de tests con al menos 6 casos límite.
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 🔌 Hiven Swarm REST API (Compatibilidad con Sphexn)
|
|
191
|
+
|
|
192
|
+
Al ejecutar `hiven console` o `hiven serve`, se inicia un servidor HTTP con endpoints REST estándar en `http://localhost:7460`:
|
|
193
|
+
|
|
194
|
+
* **`POST /api/v1/swarm/dispatch`**: Despacha un enjambre autónomo.
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"repo": "amglogicalis/mi-app",
|
|
198
|
+
"instruction": "Implementar módulo de pagos con Stripe",
|
|
199
|
+
"workers": 4,
|
|
200
|
+
"testCommand": "npm test",
|
|
201
|
+
"retries": 3
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
* **`GET /api/v1/swarm/:id`**: Consulta en tiempo real el estado, logs de actividad y URL de la Pull Request.
|
|
205
|
+
* **`GET /api/v1/honeycombs/patterns?lang=ts`**: Recupera las directivas heurísticas Do's & Don'ts aprendidas.
|
|
206
|
+
* **`POST /api/v1/honeycombs/patterns`**: Alimenta la memoria colectiva con nuevos patrones validados.
|
|
207
|
+
* **`GET /api/v1/health`**: Estado operativo del motor Hiven y Honeycombs.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## ❓ Preguntas Frecuentes (FAQ)
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
<summary><strong>Q: ¿Cómo invoco a Hiven directamente en mis Issues de GitHub?</strong></summary>
|
|
215
|
+
<p>
|
|
216
|
+
Puedes instalar la GitHub App de Hiven en tu repositorio y simplemente comentar <code>@hiven /fix corrige el error de validación en auth.ts</code>. Hiven despertará automáticamente un runner efímero y abrirá una PR resolviendo el issue.
|
|
217
|
+
</p>
|
|
218
|
+
</details>
|
|
219
|
+
|
|
220
|
+
<details>
|
|
221
|
+
<summary><strong>Q: ¿Requiere una cuenta o suscripción externa?</strong></summary>
|
|
222
|
+
<p>
|
|
223
|
+
No. Hiven está construido bajo la estricta filosofía de <strong>Coste Marginal Cero ($0)</strong> de Terra. Todo el cómputo y persistencia se ejecutan en tu propia infraestructura gratuita de GitHub.
|
|
224
|
+
</p>
|
|
225
|
+
</details>
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
<p align="center">
|
|
230
|
+
<strong>HIVEN — Terra Ecosystem</strong><br>
|
|
231
|
+
Mente Enjambre & Agente Cognitivo Autónomo a Coste $0.<br>
|
|
232
|
+
<a href="https://amglogicalis.github.io/hiven-repo-public/">🌐 Abrir Consola Web Online</a> • <a href="https://github.com/amglogicalis/hiven-repo-public">Repositorio Público en GitHub</a>
|
|
233
|
+
</p>
|
|
Binary file
|
package/bin/hiven.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Hiven, SwarmEngine, startConsoleServer } from "../dist/index.js";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const command = args[0];
|
|
11
|
+
|
|
12
|
+
function printBanner() {
|
|
13
|
+
console.log(`
|
|
14
|
+
\x1b[38;5;214m 🐝 HIVEN CLI — Autonomous Swarm Intelligence Engine V3\x1b[0m
|
|
15
|
+
\x1b[90m Terra Ecosystem • Zero-Cost Cloud Compute & Collective Honeycombs\x1b[0m
|
|
16
|
+
`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function printHelp() {
|
|
20
|
+
printBanner();
|
|
21
|
+
console.log(`
|
|
22
|
+
\x1b[1mUso:\x1b[0m
|
|
23
|
+
hiven <comando> [opciones]
|
|
24
|
+
terra-hiven <comando> [opciones]
|
|
25
|
+
|
|
26
|
+
\x1b[1mComandos Disponibles:\x1b[0m
|
|
27
|
+
\x1b[33minit\x1b[0m Inicializa el entorno y valida la memoria Honeycombs
|
|
28
|
+
\x1b[33mrun\x1b[0m --repo <owner/repo> --prompt "..." Despacha un enjambre autónomo multi-agente
|
|
29
|
+
\x1b[33mstatus\x1b[0m <swarmId> Consulta el progreso y logs de un enjambre
|
|
30
|
+
\x1b[33mswarms\x1b[0m [list] Lista el historial de misiones y PRs generadas
|
|
31
|
+
\x1b[33mhoneycombs\x1b[0m [list|clear] Inspecciona o gestiona la memoria de patrones
|
|
32
|
+
\x1b[33mconsole\x1b[0m [--port 7460] [--host 0.0.0.0] Inicia la consola web interactiva local
|
|
33
|
+
\x1b[33mserve\x1b[0m Alias de 'console'
|
|
34
|
+
\x1b[33mstudio\x1b[0m Alias de 'console'
|
|
35
|
+
\x1b[33mworkflow\x1b[0m [--output <path>] Genera el archivo YAML del Swarm para GitHub Actions
|
|
36
|
+
|
|
37
|
+
\x1b[1mOpciones de 'run':\x1b[0m
|
|
38
|
+
--repo <owner/repo> Repositorio de destino (ej. usuario/proyecto)
|
|
39
|
+
--prompt "<instrucción>" Misión u objetivo en lenguaje natural
|
|
40
|
+
--branch <nombre> Rama de trabajo destino (opcional)
|
|
41
|
+
--workers <1-10> Número de Kōmbees concurrentes (defecto: 4) (opcional)
|
|
42
|
+
--test-cmd "<comando>" Comando de verificación en Shadow Sandbox (opcional)
|
|
43
|
+
--retries <1-5> Máximas rondas de Self-Healing (defecto: 3) (opcional)
|
|
44
|
+
--dry-run Simula la descomposición y ejecución local (opcional)
|
|
45
|
+
|
|
46
|
+
\x1b[1mEjemplos:\x1b[0m
|
|
47
|
+
hiven run --repo amglogicalis/mi-app --prompt "Implementar login OAuth con Google" --workers 6
|
|
48
|
+
hiven honeycombs list
|
|
49
|
+
hiven console --port 8080
|
|
50
|
+
`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function main() {
|
|
54
|
+
if (!command || command === "--help" || command === "-h" || command === "help") {
|
|
55
|
+
printHelp();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const hiven = new Hiven();
|
|
60
|
+
|
|
61
|
+
if (command === "init") {
|
|
62
|
+
printBanner();
|
|
63
|
+
console.log(" [*] Inicializando Hiven Engine y memoria Honeycombs...");
|
|
64
|
+
await hiven.init();
|
|
65
|
+
console.log(" \x1b[32m[✓] Hiven inicializado con éxito. Honeycombs listo en .hiven-storage\x1b[0m\n");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (command === "console" || command === "serve" || command === "studio") {
|
|
70
|
+
printBanner();
|
|
71
|
+
let port = 7460;
|
|
72
|
+
let host = "localhost";
|
|
73
|
+
const portIdx = args.indexOf("--port");
|
|
74
|
+
if (portIdx !== -1 && args[portIdx + 1]) {
|
|
75
|
+
port = parseInt(args[portIdx + 1], 10);
|
|
76
|
+
}
|
|
77
|
+
const hostIdx = args.indexOf("--host");
|
|
78
|
+
if (hostIdx !== -1 && args[hostIdx + 1]) {
|
|
79
|
+
host = args[hostIdx + 1];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const consoleDir = path.resolve(__dirname, "../console");
|
|
83
|
+
await startConsoleServer({ port, host, consoleDir });
|
|
84
|
+
console.log(` \x1b[32m[✓] Hiven Studio Web Console corriendo en:\x1b[0m`);
|
|
85
|
+
console.log(` \x1b[1m\x1b[36mhttp://${host}:${port}/\x1b[0m`);
|
|
86
|
+
console.log(` \x1b[90mPresiona Ctrl+C para detener el servidor.\x1b[0m\n`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (command === "run") {
|
|
91
|
+
printBanner();
|
|
92
|
+
const repoIdx = args.indexOf("--repo");
|
|
93
|
+
const promptIdx = args.indexOf("--prompt");
|
|
94
|
+
const branchIdx = args.indexOf("--branch");
|
|
95
|
+
const workersIdx = args.indexOf("--workers");
|
|
96
|
+
const testCmdIdx = args.indexOf("--test-cmd");
|
|
97
|
+
const retriesIdx = args.indexOf("--retries");
|
|
98
|
+
const dryRun = args.includes("--dry-run");
|
|
99
|
+
|
|
100
|
+
const repo = repoIdx !== -1 ? args[repoIdx + 1] : "";
|
|
101
|
+
const prompt = promptIdx !== -1 ? args[promptIdx + 1] : "";
|
|
102
|
+
const branch = branchIdx !== -1 ? args[branchIdx + 1] : undefined;
|
|
103
|
+
const workers = workersIdx !== -1 ? parseInt(args[workersIdx + 1], 10) : 4;
|
|
104
|
+
const testCommand = testCmdIdx !== -1 ? args[testCmdIdx + 1] : undefined;
|
|
105
|
+
const maxRetries = retriesIdx !== -1 ? parseInt(args[retriesIdx + 1], 10) : 3;
|
|
106
|
+
|
|
107
|
+
if (!repo || !prompt) {
|
|
108
|
+
console.error(" \x1b[31m[!] Error: Se requieren los parámetros --repo y --prompt\x1b[0m");
|
|
109
|
+
console.log(" Ejemplo: hiven run --repo usuario/repo --prompt 'Refactorizar módulo de pagos'");
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log(` [*] Despachando Enjambre Autónomo para \x1b[1m${repo}\x1b[0m...`);
|
|
114
|
+
console.log(` • Kōmbees: ${workers} en paralelo`);
|
|
115
|
+
console.log(` • Misión: "${prompt}"`);
|
|
116
|
+
console.log(` • Self-Healing: hasta ${maxRetries} reintentos\n`);
|
|
117
|
+
|
|
118
|
+
const result = await hiven.dispatchSwarm({
|
|
119
|
+
repo,
|
|
120
|
+
instruction: prompt,
|
|
121
|
+
branch,
|
|
122
|
+
workerCount: workers,
|
|
123
|
+
testCommand,
|
|
124
|
+
maxSelfHealingRetries: maxRetries,
|
|
125
|
+
dryRun
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
console.log(` \x1b[32m[✓] Swarm despachado con éxito (ID: ${result.swarmId})\x1b[0m`);
|
|
129
|
+
console.log(` • Estado: ${result.status}`);
|
|
130
|
+
console.log(` • Rama: ${result.branch}`);
|
|
131
|
+
console.log(` • Tareas planificadas (DAG): ${result.taskGraph?.nodes.length || 3} nodos`);
|
|
132
|
+
if (result.pullRequestUrl) {
|
|
133
|
+
console.log(` • Pull Request: \x1b[36m${result.pullRequestUrl}\x1b[0m`);
|
|
134
|
+
}
|
|
135
|
+
console.log("");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (command === "status") {
|
|
140
|
+
printBanner();
|
|
141
|
+
const swarmId = args[1];
|
|
142
|
+
if (!swarmId) {
|
|
143
|
+
console.error(" \x1b[31m[!] Error: Especifica el ID del enjambre: hiven status <swarmId>\x1b[0m");
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
const status = await hiven.getSwarmStatus(swarmId);
|
|
147
|
+
if (!status) {
|
|
148
|
+
console.log(` \x1b[33m[!] No se encontraron registros para el Swarm ID '${swarmId}'\x1b[0m\n`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
console.log(` \x1b[1mInformación del Swarm:\x1b[0m`);
|
|
152
|
+
console.log(` • ID: ${status.swarmId}`);
|
|
153
|
+
console.log(` • Repositorio: ${status.repo}`);
|
|
154
|
+
console.log(` • Estado: \x1b[32m${status.status}\x1b[0m`);
|
|
155
|
+
console.log(` • Fase Actual: ${status.currentPhase}`);
|
|
156
|
+
console.log(` • Progreso: ${status.progressPercent}%`);
|
|
157
|
+
console.log("\n \x1b[1mLogs de Actividad:\x1b[0m");
|
|
158
|
+
status.logs.forEach(l => console.log(` \x1b[90m›\x1b[0m ${l}`));
|
|
159
|
+
console.log("");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (command === "honeycombs") {
|
|
164
|
+
printBanner();
|
|
165
|
+
const sub = args[1] || "list";
|
|
166
|
+
if (sub === "list") {
|
|
167
|
+
const patterns = await hiven.getLearnedPatterns();
|
|
168
|
+
const langs = Object.keys(patterns);
|
|
169
|
+
console.log(` \x1b[1mMemoria Global Honeycombs (Celdas: ${langs.length}):\x1b[0m`);
|
|
170
|
+
if (langs.length === 0) {
|
|
171
|
+
console.log(" \x1b[90m(Aún no hay patrones registrados. Se aprenderán automáticamente con cada misión)\x1b[0m\n");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
for (const lang of langs) {
|
|
175
|
+
console.log(` \x1b[33m🐝 Lenguaje/Entorno: [${lang.toUpperCase()}]\x1b[0m (${patterns[lang].length} patrones)`);
|
|
176
|
+
patterns[lang].forEach(p => {
|
|
177
|
+
console.log(` • [${p.patternType}] \x1b[1m${p.summary}\x1b[0m (Usos: ${p.usageCount})`);
|
|
178
|
+
console.log(` \x1b[32mDo:\x1b[0m ${p.doDirective}`);
|
|
179
|
+
if (p.dontDirective) console.log(` \x1b[31mDon't:\x1b[0m ${p.dontDirective}`);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
console.log("");
|
|
183
|
+
return;
|
|
184
|
+
} else if (sub === "clear") {
|
|
185
|
+
await hiven.honeycombs.clearPatterns();
|
|
186
|
+
console.log(" \x1b[32m[✓] Memoria global Honeycombs purgada con éxito.\x1b[0m\n");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (command === "swarms") {
|
|
192
|
+
printBanner();
|
|
193
|
+
const list = await hiven.listSwarms();
|
|
194
|
+
console.log(` \x1b[1mHistorial de Misiones del Enjambre (${list.length}):\x1b[0m`);
|
|
195
|
+
if (list.length === 0) {
|
|
196
|
+
console.log(" \x1b[90m(No hay misiones registradas. Despacha una con 'hiven run')\x1b[0m\n");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
list.forEach((s, idx) => {
|
|
200
|
+
console.log(` ${idx + 1}. \x1b[1m${s.repo}\x1b[0m [\x1b[32m${s.status}\x1b[0m] (${s.swarmId})`);
|
|
201
|
+
console.log(` "${s.summary}"`);
|
|
202
|
+
console.log(` Iniciado: ${s.startedAt}`);
|
|
203
|
+
});
|
|
204
|
+
console.log("");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (command === "workflow") {
|
|
209
|
+
const yaml = SwarmEngine.generateWorkflowYaml({
|
|
210
|
+
repo: "user/project",
|
|
211
|
+
instruction: "Autonomous Task Execution",
|
|
212
|
+
workerCount: 4
|
|
213
|
+
});
|
|
214
|
+
console.log(yaml);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
console.log(` \x1b[31m[!] Comando desconocido: '${command}'\x1b[0m`);
|
|
219
|
+
printHelp();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
main().catch(err => {
|
|
223
|
+
console.error(`\x1b[31m[!] Error fatal:\x1b[0m ${err.message}`);
|
|
224
|
+
process.exit(1);
|
|
225
|
+
});
|
|
File without changes
|