nexakit 0.12.1 → 0.13.1
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/README.md +9 -5
- package/assets/runtime/package-lock.json +2 -2
- package/dist/fabrica/banco/ejecutar.js +16 -8
- package/dist/fabrica/cli.js +269 -25
- package/dist/fabrica/conectores/antigravity.js +511 -12
- package/dist/fabrica/conectores/codex.js +400 -18
- package/dist/fabrica/consolidar.js +64 -27
- package/dist/fabrica/decision.js +43 -21
- package/dist/fabrica/disco.js +220 -9
- package/dist/fabrica/ejecutor.js +138 -75
- package/dist/fabrica/encargo/candado.js +274 -0
- package/dist/fabrica/encargo/ejecutar.js +827 -0
- package/dist/fabrica/encargo/evidencia.js +308 -0
- package/dist/fabrica/encargo/parche.js +146 -0
- package/dist/fabrica/encargo/worktree.js +394 -0
- package/dist/fabrica/enrutador.js +76 -27
- package/dist/fabrica/esquemas.js +8 -1
- package/dist/fabrica/evidencia.js +6 -3
- package/dist/fabrica/jsonrpc.js +53 -5
- package/dist/fabrica/mcp.js +147 -12
- package/dist/fabrica/preferencias.js +56 -0
- package/dist/fabrica/rastro.js +70 -14
- package/dist/fabrica/sesion.js +7 -3
- package/dist/fabrica/tabla-modelos.json +4 -2
- package/dist/fabrica/veredictos.js +15 -11
- package/package.json +1 -1
- package/plugins/huellas.json +4 -4
- package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -1
- package/plugins/nexakit-modelo/hooks/barra.js +22 -1
- package/plugins/nexakit-modelo/hooks/decidir.js +2 -2
- package/plugins/nexakit-modelo/hooks/register.js +94 -6
- package/plugins/nexakit-modelo/tests/register.test.ts +253 -0
- package/plugins/niveles/.claude-plugin/plugin.json +1 -1
- package/plugins/niveles/agents/cazador-de-flakes.md +1 -0
- package/plugins/niveles/agents/cierre-de-memoria.md +1 -0
- package/plugins/niveles/agents/investigador.md +1 -0
- package/plugins/niveles/agents/nivel-alto.md +1 -0
- package/plugins/niveles/agents/nivel-exigente.md +1 -0
- package/plugins/niveles/agents/nivel-ligero.md +1 -0
- package/plugins/niveles/agents/nivel-normal.md +1 -0
- package/plugins/niveles/agents/revisor-de-calidad.md +1 -0
- package/plugins/niveles/agents/sincronizador-docs.md +1 -0
- package/plugins/niveles/agents/subir-al-repo.md +1 -0
- package/skills/elegir-modelo/SKILL.md +3 -3
- package/skills/elegir-modelo/modelos.mjs +1 -1
- package/skills/fabrica/SKILL.md +27 -8
- package/src/agent-models.js +1 -1
- package/src/antigravity-recommendation.js +14 -7
- package/src/codex-team.js +2 -1
- package/src/fabrica/banco/ejecutar.ts +20 -10
- package/src/fabrica/cli.ts +257 -24
- package/src/fabrica/conectores/antigravity.ts +508 -12
- package/src/fabrica/conectores/codex.ts +410 -17
- package/src/fabrica/conectores/tipos.ts +4 -0
- package/src/fabrica/consolidar.ts +92 -33
- package/src/fabrica/decision.ts +50 -22
- package/src/fabrica/disco.ts +237 -10
- package/src/fabrica/ejecutor.ts +144 -69
- package/src/fabrica/encargo/candado.ts +287 -0
- package/src/fabrica/encargo/ejecutar.ts +953 -0
- package/src/fabrica/encargo/evidencia.ts +301 -0
- package/src/fabrica/encargo/parche.ts +151 -0
- package/src/fabrica/encargo/worktree.ts +427 -0
- package/src/fabrica/enrutador.ts +71 -27
- package/src/fabrica/esquemas.ts +10 -1
- package/src/fabrica/evidencia.ts +7 -3
- package/src/fabrica/jsonrpc.ts +51 -5
- package/src/fabrica/mcp.ts +166 -12
- package/src/fabrica/preferencias.ts +66 -0
- package/src/fabrica/rastro.ts +69 -14
- package/src/fabrica/sesion.ts +7 -3
- package/src/fabrica/tabla-modelos.json +4 -2
- package/src/fabrica/veredictos.ts +18 -14
- package/src/gemini-tools.js +1 -1
- package/src/level-agents.js +2 -0
- package/src/model-command.d.ts +29 -0
- package/src/model-command.js +2 -2
- package/src/regla-ordenes-simples.d.ts +2 -0
- package/src/regla-ordenes-simples.js +4 -0
- package/src/review-instructions.js +39 -10
- package/src/toolkit-cli.js +7 -3
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { calcularHuella } from './enrutador.js';
|
|
5
5
|
import { actualizar, cargar, guardar, revertirReal } from './evidencia.js';
|
|
6
|
-
import { IA, NombreEstacion } from './esquemas.js';
|
|
6
|
+
import { claveEstacion, IA, IAExterna, NombreEstacion } from './esquemas.js';
|
|
7
7
|
import { esCategoriaValida, proponerPorFalsos, UMBRAL_FALSOS } from './lecciones.js';
|
|
8
8
|
import * as rastro from './rastro.js';
|
|
9
9
|
import { limpiar, mensajeDe } from './sesion.js';
|
|
@@ -33,10 +33,11 @@ const Origen = z.object({ verificado: z.enum(['real', 'falso']), fila: ClaveFila
|
|
|
33
33
|
const Registro = z.object({
|
|
34
34
|
version: z.literal(1),
|
|
35
35
|
origenes: z.record(z.string(), Origen),
|
|
36
|
-
tokens: z.array(NombreEstacion),
|
|
36
|
+
tokens: z.array(z.union([NombreEstacion, z.literal('codigo-codex'), z.literal('codigo-antigravity')])),
|
|
37
37
|
});
|
|
38
38
|
const EstacionDelRecorrido = z.object({
|
|
39
39
|
estacion: NombreEstacion,
|
|
40
|
+
revisionDe: IAExterna.optional(),
|
|
40
41
|
ia: IA.nullable(),
|
|
41
42
|
modelo: z.string().nullable(),
|
|
42
43
|
esfuerzo: z.string().nullable(),
|
|
@@ -71,7 +72,7 @@ function leerRecorrido(dir) {
|
|
|
71
72
|
}
|
|
72
73
|
if (huella !== r.data.huella)
|
|
73
74
|
return 'El rastro del recorrido no coincide con su huella: parece manipulado';
|
|
74
|
-
return new Map(r.data.estaciones.map((e) => [e.estacion, e]));
|
|
75
|
+
return new Map(r.data.estaciones.map((e) => [claveEstacion(e.estacion, e.revisionDe), e]));
|
|
75
76
|
}
|
|
76
77
|
function leerRegistro(dir) {
|
|
77
78
|
let dato;
|
|
@@ -93,8 +94,9 @@ const serializar = (r) => ({ version: 1, origenes: Object.fromEntries(r.origenes
|
|
|
93
94
|
* A qué fila de evidencia se atribuye un hallazgo de esta estación: la IA, el modelo y el esfuerzo del recorrido
|
|
94
95
|
* aprobado. Las estaciones de Claude llevan el agente como modelo y ningún esfuerzo. Devuelve el motivo si no se puede.
|
|
95
96
|
*/
|
|
96
|
-
function atribuir(dir,
|
|
97
|
-
const
|
|
97
|
+
function atribuir(dir, origen, recorrido) {
|
|
98
|
+
const { estacion, revisionDe } = origen;
|
|
99
|
+
const e = recorrido.get(claveEstacion(estacion, revisionDe));
|
|
98
100
|
if (e === undefined)
|
|
99
101
|
return `${estacion}: no consta en el recorrido`;
|
|
100
102
|
if (e.ia === null || e.modelo === null)
|
|
@@ -103,7 +105,7 @@ function atribuir(dir, estacion, recorrido) {
|
|
|
103
105
|
return { clave: { ia: 'claude', modelo: e.modelo, esfuerzo: null, estacion }, tokens: null };
|
|
104
106
|
let dato = null;
|
|
105
107
|
try {
|
|
106
|
-
dato = rastro.leerEstacion(dir, estacion);
|
|
108
|
+
dato = rastro.leerEstacion(dir, estacion, revisionDe);
|
|
107
109
|
}
|
|
108
110
|
catch {
|
|
109
111
|
return `${estacion}: su rastro no se puede leer`;
|
|
@@ -214,7 +216,8 @@ async function aprender(home, repo, raiz, estado, hallazgos, veredictos) {
|
|
|
214
216
|
resultado.revertidos += 1;
|
|
215
217
|
cambio = true;
|
|
216
218
|
}
|
|
217
|
-
const enEstacion = (
|
|
219
|
+
const enEstacion = (fila) => [...registro.origenes.values()]
|
|
220
|
+
.filter((o) => o.fila.estacion === fila.estacion && o.fila.ia === fila.ia).length;
|
|
218
221
|
for (const v of veredictos) {
|
|
219
222
|
const h = porClave.get(v.clave);
|
|
220
223
|
if (h === undefined) {
|
|
@@ -244,12 +247,12 @@ async function aprender(home, repo, raiz, estado, hallazgos, veredictos) {
|
|
|
244
247
|
atribuidos += 1;
|
|
245
248
|
continue;
|
|
246
249
|
}
|
|
247
|
-
const a = atribuir(estado.dir, origen
|
|
250
|
+
const a = atribuir(estado.dir, origen, recorrido);
|
|
248
251
|
if (typeof a === 'string') {
|
|
249
252
|
resultado.avisos.push(`Hallazgo ${claveParaAviso(v.clave)}, ${a}: no cuenta para esa estación.`);
|
|
250
253
|
continue;
|
|
251
254
|
}
|
|
252
|
-
if (o === undefined && enEstacion(
|
|
255
|
+
if (o === undefined && enEstacion(a.clave) >= MAX_VEREDICTOS_POR_ESTACION) {
|
|
253
256
|
resultado.avisos.push(`Hallazgo ${claveParaAviso(v.clave)}, ${origen.estacion}: ya hay ${MAX_VEREDICTOS_POR_ESTACION} veredictos de esta estación en el recorrido, no cuenta.`);
|
|
254
257
|
continue;
|
|
255
258
|
}
|
|
@@ -260,10 +263,11 @@ async function aprender(home, repo, raiz, estado, hallazgos, veredictos) {
|
|
|
260
263
|
resultado.revertidos += 1;
|
|
261
264
|
}
|
|
262
265
|
// Los tokens de la estación entran una sola vez en el recorrido, no una por veredicto.
|
|
263
|
-
const
|
|
266
|
+
const ejecucion = claveEstacion(origen.estacion, origen.revisionDe);
|
|
267
|
+
const conTokens = a.tokens !== null && !registro.tokens.has(ejecucion);
|
|
264
268
|
ev = sumar(ev, a.clave, v.verificado, conTokens ? (a.tokens ?? undefined) : undefined);
|
|
265
269
|
if (conTokens)
|
|
266
|
-
registro.tokens.add(
|
|
270
|
+
registro.tokens.add(ejecucion);
|
|
267
271
|
registro.origenes.set(origen.clave, { verificado: v.verificado, fila: a.clave, archivo: h.archivo, categoria: h.categoria });
|
|
268
272
|
if (v.verificado === 'falso' && a.clave.ia !== 'claude')
|
|
269
273
|
falsosNuevos.add(claveFalso(origen.estacion, h.categoria, h.archivo));
|
package/package.json
CHANGED
package/plugins/huellas.json
CHANGED
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"huella": "78c2110143433c40"
|
|
13
13
|
},
|
|
14
14
|
"nexakit-modelo": {
|
|
15
|
-
"version": "0.5.
|
|
16
|
-
"huella": "
|
|
15
|
+
"version": "0.5.9",
|
|
16
|
+
"huella": "4e579df1e4b61f6d"
|
|
17
17
|
},
|
|
18
18
|
"nexakit-sesion": {
|
|
19
19
|
"version": "0.2.1",
|
|
20
20
|
"huella": "0c05eb6c094a193a"
|
|
21
21
|
},
|
|
22
22
|
"niveles": {
|
|
23
|
-
"version": "0.3.
|
|
24
|
-
"huella": "
|
|
23
|
+
"version": "0.3.1",
|
|
24
|
+
"huella": "2c5c1751f5280180"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexakit-modelo",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Barra sobre el prompt con modelo, esfuerzo, recomendación por mensaje (delegar antes que cambiar de modelo), acierto de caché y uso de contexto y límites, sin cambiar nada; cada subagente muestra sus tokens nuevos y su porcentaje de caché.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juan Jaller"
|
|
@@ -98,7 +98,28 @@ function tramosDeTokens(tokens) {
|
|
|
98
98
|
function sugerencia(estado) {
|
|
99
99
|
const d = decidir(estado);
|
|
100
100
|
if (!d) return null;
|
|
101
|
-
|
|
101
|
+
if (d.accion === 'mantener') return { text: ' ✓', color: 'success' };
|
|
102
|
+
// Al delegar, el tramo lleva el nivel y el texto de la etiqueta para que el render pueda dibujar un botón.
|
|
103
|
+
if (d.accion === 'delegar' && d.nivel) return { text: ` → ${d.texto}`, color: 'suggestion', accion: 'delegar', nivel: d.nivel, etiqueta: `→ ${d.texto}` };
|
|
104
|
+
return { text: ` → ${d.texto}`, color: 'suggestion' };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Lo que el botón de delegar envía a la sesión. Los niveles ligero y normal pasan primero por un encargo a
|
|
108
|
+
// Codex o Antigravity; los exigentes y altos van directos al subagente de nivel.
|
|
109
|
+
export function instruccionDeDelegar(nivel) {
|
|
110
|
+
if (nivel === 'nivel-ligero' || nivel === 'nivel-normal') {
|
|
111
|
+
return `Delega la tarea de mi mensaje anterior: encárgala con fabrica_encargar en Codex o Antigravity, revisa el diff con una IA distinta, aplícalo, ejecuta las pruebas y dime qué IA lo hizo. Si no encaja en un encargo, pásala al subagente niveles:${nivel}.`;
|
|
112
|
+
}
|
|
113
|
+
return `Delega la tarea de mi mensaje anterior en el subagente niveles:${nivel} y comprueba su informe.`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Un turn.abort solo trae el id del turno (y agentId si lo trajera): es el de la sesión principal si no es de un
|
|
117
|
+
// subagente y coincide con el turno principal conocido (o aún no se conoce ninguno). Solo entonces el botón de
|
|
118
|
+
// delegar vuelve y se puede reintentar la delegación.
|
|
119
|
+
export function alAbortarTurno(estado, e) {
|
|
120
|
+
if (e?.agentId || (estado.turnoId !== null && e?.turnId !== estado.turnoId)) return false;
|
|
121
|
+
Object.assign(estado, { turnoActivo: false, turnoId: null, delegado: false });
|
|
122
|
+
return true;
|
|
102
123
|
}
|
|
103
124
|
|
|
104
125
|
// El límite de uso más alto de los que informa la API (5 horas o semanal).
|
|
@@ -39,7 +39,7 @@ function decidirCon(r, { model, effort, ctx, tokens, cacheFria = false, rutinaSe
|
|
|
39
39
|
if (r.delegar === 'nivel-ligero') {
|
|
40
40
|
return mismaFamilia && effort === r.effort
|
|
41
41
|
? { accion: 'mantener', texto: '✓' }
|
|
42
|
-
: { accion: 'delegar', texto: `delega: ${r.delegar}
|
|
42
|
+
: { accion: 'delegar', texto: `delega: ${r.delegar}`, nivel: r.delegar };
|
|
43
43
|
}
|
|
44
44
|
if (mismaFamilia) {
|
|
45
45
|
return effort === r.effort ? { accion: 'mantener', texto: '✓' } : { accion: 'esfuerzo', texto: etiqueta(r) };
|
|
@@ -48,7 +48,7 @@ function decidirCon(r, { model, effort, ctx, tokens, cacheFria = false, rutinaSe
|
|
|
48
48
|
const fria = cacheFria ? ' (caché fría: cambiar no cuesta)' : '';
|
|
49
49
|
if (rango(r.model) > rango(model)) {
|
|
50
50
|
if (barato) return { accion: 'cambiar', texto: `${etiqueta(r)}${fria}` };
|
|
51
|
-
if (r.delegar) return { accion: 'delegar', texto: `delega: ${r.delegar}
|
|
51
|
+
if (r.delegar) return { accion: 'delegar', texto: `delega: ${r.delegar}`, nivel: r.delegar };
|
|
52
52
|
const coste = esNumero(tokens) && tokens > 0 ? ` · relee ~${Math.round(tokens / 1000)}k` : '';
|
|
53
53
|
return { accion: 'cambiar', texto: `${etiqueta(r)}${coste}` };
|
|
54
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activoDeTexto, columnaDeAgentes, columnaDeFabrica, familia, filasDeAgentes, filasDeFabrica, segmentosDeBarra, sumarTokens, tokensVacios } from './barra.js';
|
|
1
|
+
import { activoDeTexto, alAbortarTurno, columnaDeAgentes, columnaDeFabrica, familia, filasDeAgentes, filasDeFabrica, instruccionDeDelegar, segmentosDeBarra, sumarTokens, tokensVacios } from './barra.js';
|
|
2
2
|
import { ajustarPorLimite } from './decidir.js';
|
|
3
3
|
import { recomendarPorTexto } from './recomendar.js';
|
|
4
4
|
|
|
@@ -84,10 +84,29 @@ async function activoDeLaFabrica($) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
const HERRAMIENTA_ENCARGO = 'mcp__nexakit-fabrica__fabrica_encargar';
|
|
88
|
+
const MARCA_SIN_ENCARGO = '[sin encargo]';
|
|
89
|
+
const MENSAJE_ENCARGO = 'Primero encarga esta implementación con fabrica_encargar (Codex o Antigravity): ahorra tokens de Claude. Si el encargo no es posible (repo sin commits, otro encargo en marcha, sin conector) o ya falló, vuelve a lanzar el subagente con [sin encargo] en la descripción.';
|
|
90
|
+
|
|
91
|
+
// Un subagente niveles:nivel-normal pedido por la sesión principal sin la marca [sin encargo].
|
|
92
|
+
function vetaSubagenteNormal(e) {
|
|
93
|
+
if (e.agentId || e.subagent_type !== 'niveles:nivel-normal') return false;
|
|
94
|
+
return !`${e.description ?? ''}\n${e.prompt ?? ''}`.toLowerCase().includes(MARCA_SIN_ENCARGO);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ¿Existe la herramienta de encargos? Si no se puede saber, se asume que sí.
|
|
98
|
+
async function hayEncargos($) {
|
|
99
|
+
try {
|
|
100
|
+
return (await $.tool.list()).some((t) => t.name === HERRAMIENTA_ENCARGO);
|
|
101
|
+
} catch {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
// Una sola barra sobre el prompt con modelo, esfuerzo, recomendación y uso. Solo muestra:
|
|
88
107
|
// nunca cambia el modelo ni el esfuerzo de la sesión.
|
|
89
108
|
export function register(on) {
|
|
90
|
-
const estado = { model: null, effort: null, modeloDelEsfuerzo: null, recommendation: null, enviada: null, usage: null, cache: cacheVacia(), ultimaActividad: null, cacheFria: false, rutinaSeguidas: 0 };
|
|
109
|
+
const estado = { model: null, effort: null, modeloDelEsfuerzo: null, recommendation: null, enviada: null, usage: null, cache: cacheVacia(), ultimaActividad: null, cacheFria: false, rutinaSeguidas: 0, turnoActivo: false, turnoId: null, delegado: false, enviando: false, ultimoTexto: null, borrador: '' };
|
|
91
110
|
// Subagentes de esta petición, por id, con el modelo y el esfuerzo que de verdad usaron.
|
|
92
111
|
const agentes = new Map();
|
|
93
112
|
|
|
@@ -113,11 +132,20 @@ export function register(on) {
|
|
|
113
132
|
return { result: 'Recomendación mostrada; no se cambió el modelo ni el esfuerzo.' };
|
|
114
133
|
});
|
|
115
134
|
|
|
135
|
+
// La implementación de nivel normal se encarga primero (fabrica_encargar en Codex o Antigravity, que ahorra tokens de
|
|
136
|
+
// Claude). Solo se veta el subagente niveles:nivel-normal lanzado por la sesión principal y sin la marca
|
|
137
|
+
// [sin encargo] (para cuando el encargo no es posible o ya falló); nada más se bloquea.
|
|
138
|
+
on('tool.call', { tool: 'Agent' }, async ($, e, next) => {
|
|
139
|
+
if (!vetaSubagenteNormal(e) || !(await hayEncargos($))) return next(e);
|
|
140
|
+
return { deny: MENSAJE_ENCARGO };
|
|
141
|
+
});
|
|
142
|
+
|
|
116
143
|
// Mientras se escribe: la recomendación aparece antes de pulsar Enter, cuando todavía se puede cambiar
|
|
117
144
|
// de modelo o delegar. Parte de la del último mensaje enviado, para que «ok, dale» la conserve.
|
|
118
145
|
on('prompt.edit', async ($, e, next) => {
|
|
119
146
|
const r = await next(e);
|
|
120
147
|
try {
|
|
148
|
+
estado.borrador = r?.text ?? '';
|
|
121
149
|
const nueva = recomendarPorTexto(r?.text ?? '', estado.enviada);
|
|
122
150
|
const cambioCache = await medirCacheFria($, estado);
|
|
123
151
|
if (cambioCache || !mismaRecomendacion(nueva, estado.recommendation)) {
|
|
@@ -131,6 +159,11 @@ export function register(on) {
|
|
|
131
159
|
});
|
|
132
160
|
|
|
133
161
|
on('prompt.submit', async ($, e, next) => {
|
|
162
|
+
// Lo que envía el propio botón no es un mensaje de la persona: no cambia la recomendación ni «el último mensaje».
|
|
163
|
+
if (estado.enviando && e.origin?.kind === 'plugin') return next(e);
|
|
164
|
+
estado.delegado = false;
|
|
165
|
+
estado.ultimoTexto = e.text;
|
|
166
|
+
estado.borrador = '';
|
|
134
167
|
estado.recommendation = recomendarPorTexto(e.text, estado.enviada);
|
|
135
168
|
estado.enviada = estado.recommendation;
|
|
136
169
|
await medirCacheFria($, estado);
|
|
@@ -143,6 +176,23 @@ export function register(on) {
|
|
|
143
176
|
return next(e);
|
|
144
177
|
});
|
|
145
178
|
|
|
179
|
+
// Solo un turno real de la sesión principal oculta el botón (un envío que no llega a empezar turno no lo deja bloqueado).
|
|
180
|
+
on('turn.start', async ($, e, next) => {
|
|
181
|
+
if (!e.agentId) {
|
|
182
|
+
estado.turnoActivo = true;
|
|
183
|
+
estado.turnoId = e.turnId ?? null;
|
|
184
|
+
$.ui.invalidate('ui.render');
|
|
185
|
+
}
|
|
186
|
+
return next(e);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// El turno de la sesión principal se interrumpió: el botón de delegar puede volver, y también reintentarse.
|
|
190
|
+
// turn.abort solo trae el id del turno: un subagente aborta el suyo, que no es el principal.
|
|
191
|
+
on('turn.abort', async ($, e, next) => {
|
|
192
|
+
if (alAbortarTurno(estado, e)) $.ui.invalidate('ui.render');
|
|
193
|
+
return next(e);
|
|
194
|
+
});
|
|
195
|
+
|
|
146
196
|
on('turn.step', async function* ($, e, next) {
|
|
147
197
|
if (!e.agentId) {
|
|
148
198
|
// El último esfuerzo visto se conserva entre turnos; el siguiente paso lo corrige si cambió.
|
|
@@ -177,6 +227,8 @@ export function register(on) {
|
|
|
177
227
|
on('turn.complete', async ($, e, next) => {
|
|
178
228
|
const r = await next(e);
|
|
179
229
|
if (!e.agentId) {
|
|
230
|
+
estado.turnoActivo = false;
|
|
231
|
+
estado.turnoId = null;
|
|
180
232
|
// Solo la sesión principal: cada subagente tiene su propia caché y no toca la de la sesión.
|
|
181
233
|
sumarCache(estado, r?.usage);
|
|
182
234
|
await marcarActividad($, estado);
|
|
@@ -188,9 +240,45 @@ export function register(on) {
|
|
|
188
240
|
|
|
189
241
|
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
|
|
190
242
|
if (e.props?.hasSurvey || !estado.model) return next(e);
|
|
191
|
-
const { Box, Text } = $.ui.resolve(e);
|
|
192
|
-
|
|
193
|
-
|
|
243
|
+
const { Box, Text, Button } = $.ui.resolve(e);
|
|
244
|
+
// El botón solo en la app de escritorio, sin turno en curso, sin pulsar ya y con la caja vacía o con el mismo
|
|
245
|
+
// texto del último mensaje: se delega «mi mensaje anterior», así que ni la recomendación ni el texto
|
|
246
|
+
// pueden ser de otro borrador.
|
|
247
|
+
const borrador = estado.borrador.trim();
|
|
248
|
+
const hayBoton = Boolean(Button) && e.surface === 'desktop' && !estado.turnoActivo && !estado.delegado
|
|
249
|
+
&& Boolean(estado.enviada) && (borrador === '' || borrador === estado.ultimoTexto?.trim())
|
|
250
|
+
&& (estado.recommendation === estado.enviada || mismaRecomendacion(estado.recommendation, estado.enviada));
|
|
251
|
+
const tramos = segmentosDeBarra(estado).map((s, i) => {
|
|
252
|
+
if (hayBoton && s.accion === 'delegar') {
|
|
253
|
+
const nivel = s.nivel;
|
|
254
|
+
return h(Button, {
|
|
255
|
+
key: 'delegar',
|
|
256
|
+
label: s.etiqueta,
|
|
257
|
+
variant: 'primary',
|
|
258
|
+
onPress: async () => {
|
|
259
|
+
if (estado.delegado || estado.turnoActivo || estado.enviando) return;
|
|
260
|
+
Object.assign(estado, { delegado: true, turnoActivo: true, enviando: true });
|
|
261
|
+
$.ui.invalidate('ui.render');
|
|
262
|
+
try {
|
|
263
|
+
const r = await $.prompt.submit({ text: instruccionDeDelegar(nivel) });
|
|
264
|
+
if (r?.drop !== undefined) throw new Error(r.drop);
|
|
265
|
+
} catch {
|
|
266
|
+
// El envío no empezó: se devuelve el botón y se avisa para poder reintentar.
|
|
267
|
+
Object.assign(estado, { delegado: false, turnoActivo: false });
|
|
268
|
+
try {
|
|
269
|
+
$.ui.toast('No se pudo enviar la delegación. Pulsa el botón de nuevo para reintentar.', { timeoutMs: 8000 });
|
|
270
|
+
} catch {
|
|
271
|
+
// Sin aviso, el botón vuelve igual.
|
|
272
|
+
}
|
|
273
|
+
} finally {
|
|
274
|
+
estado.enviando = false;
|
|
275
|
+
$.ui.invalidate('ui.render');
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return h(Text, { key: String(i), color: s.color, dimColor: s.dim, bold: s.bold }, s.text);
|
|
281
|
+
});
|
|
194
282
|
const linea = (partes, clave) => h(Box, { key: clave, flexDirection: 'row' },
|
|
195
283
|
...partes.map((s, i) => h(Text, { key: String(i), color: s.color, dimColor: s.dim, bold: s.bold }, s.text)));
|
|
196
284
|
const subagentes = [...agentes.values()];
|
|
@@ -211,7 +299,7 @@ export function register(on) {
|
|
|
211
299
|
|
|
212
300
|
on('session.end', async ($, e, next) => {
|
|
213
301
|
agentes.clear();
|
|
214
|
-
Object.assign(estado, { model: null, effort: null, modeloDelEsfuerzo: null, recommendation: null, enviada: null, usage: null, cache: cacheVacia(), ultimaActividad: null, cacheFria: false, rutinaSeguidas: 0 });
|
|
302
|
+
Object.assign(estado, { model: null, effort: null, modeloDelEsfuerzo: null, recommendation: null, enviada: null, usage: null, cache: cacheVacia(), ultimaActividad: null, cacheFria: false, rutinaSeguidas: 0, turnoActivo: false, turnoId: null, delegado: false, enviando: false, ultimoTexto: null, borrador: '' });
|
|
215
303
|
return next(e);
|
|
216
304
|
});
|
|
217
305
|
}
|
|
@@ -96,4 +96,257 @@ describe('nexakit-modelo API', () => {
|
|
|
96
96
|
await $.session.start({ surface: 'terminal', isInteractive: true, cwd: '/test' });
|
|
97
97
|
expect(await pintar($)).not.toContain('↳');
|
|
98
98
|
});
|
|
99
|
+
|
|
100
|
+
// Botón para delegar: la sesión tiene 50 % de contexto, así que un mensaje difícil desde Sonnet recomienda delegar
|
|
101
|
+
// en nivel-alto y uno mecánico desde Opus en nivel-ligero (sin cambiar de modelo, que costaría releer el contexto).
|
|
102
|
+
const prepararBoton = ($: any, on: any, modelo = 'claude-opus-5-5', extra: { avisos?: string[]; falla?: { valor: boolean } } = {}) => {
|
|
103
|
+
const enviados: { text: string; plugin: boolean }[] = [];
|
|
104
|
+
on('session.start', ($: any, e: any) => ({ cwd: e.cwd }));
|
|
105
|
+
on('session.model', () => ({ value: modelo }));
|
|
106
|
+
on('session.usage', () => ({ value: { context: { percent: 50, tokens: 100000 }, rateLimits: [] } }));
|
|
107
|
+
on('turn.start', ($: any, e: any) => ({ text: e.text, turnId: e.turnId }));
|
|
108
|
+
on('turn.complete', ($: any, e: any) => ({ text: e.answer }));
|
|
109
|
+
on('turn.abort', () => undefined);
|
|
110
|
+
on('clock.now', () => ({ value: Date.now() }));
|
|
111
|
+
on('tool.register', ($: any, e: any) => ({ value: { tool: e.name } }));
|
|
112
|
+
on('env.get', () => ({ value: undefined }));
|
|
113
|
+
on('ui.toast', (_: any, e: any) => {
|
|
114
|
+
extra.avisos?.push(e.text);
|
|
115
|
+
return { value: undefined };
|
|
116
|
+
});
|
|
117
|
+
on('prompt.edit', ($: any, e: any) => {
|
|
118
|
+
const text = e.text.slice(0, e.start) + e.inputText + e.text.slice(e.end);
|
|
119
|
+
return { text, cursor: e.start + e.inputText.length };
|
|
120
|
+
});
|
|
121
|
+
on('prompt.submit', ($: any, e: any) => {
|
|
122
|
+
if (extra.falla?.valor && e.origin?.kind === 'plugin') return { drop: 'bloqueado' };
|
|
123
|
+
enviados.push({ text: e.text, plugin: e.origin?.kind === 'plugin' });
|
|
124
|
+
return { text: e.text, origin: e.origin };
|
|
125
|
+
});
|
|
126
|
+
return enviados;
|
|
127
|
+
};
|
|
128
|
+
const MENSAJES = {
|
|
129
|
+
'nivel-ligero': 'haz commit y push',
|
|
130
|
+
'nivel-alto': 'el login sigue fallando y no sé por qué',
|
|
131
|
+
} as const;
|
|
132
|
+
const BARRA = (surface: string) => ({ plugin: 'nexakit-modelo', surface, component: 'AbovePrompt', props: { hasSurvey: false } }) as any;
|
|
133
|
+
const turno = async ($: any, sufijo: string) => {
|
|
134
|
+
await $.turn.start({ text: 'x', turnId: `t${sufijo}` });
|
|
135
|
+
await $.turn.complete({ answer: 'ok', durationMs: 1, isAborted: false, turnId: `t${sufijo}`, reason: 'answer' });
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
test('en el escritorio la sugerencia de delegar es un botón y envía la instrucción de su nivel', async ($, on) => {
|
|
139
|
+
const enviados = prepararBoton($, on);
|
|
140
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
141
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
142
|
+
await turno($, '1');
|
|
143
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
144
|
+
const boton = await ui.find({ type: 'Button' });
|
|
145
|
+
expect(boton?.props.label).toBe('→ delega: nivel-ligero');
|
|
146
|
+
await ui.press({ key: 'delegar' });
|
|
147
|
+
const enviado = enviados.at(-1)!;
|
|
148
|
+
expect(enviado.plugin).toBe(true);
|
|
149
|
+
expect(enviado.text).toContain('fabrica_encargar en Codex o Antigravity');
|
|
150
|
+
expect(enviado.text).toContain('niveles:nivel-ligero');
|
|
151
|
+
await ui.unmount();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('para nivel-alto el botón delega directo en el subagente', async ($, on) => {
|
|
155
|
+
// Desde Sonnet con contexto lleno, subir a Opus releería todo: se delega.
|
|
156
|
+
const enviados = prepararBoton($, on, 'claude-sonnet-5-5');
|
|
157
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
158
|
+
await $.prompt.submit({ text: MENSAJES['nivel-alto'] });
|
|
159
|
+
await turno($, '1');
|
|
160
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
161
|
+
expect((await ui.find({ type: 'Button' }))?.props.label).toBe('→ delega: nivel-alto');
|
|
162
|
+
await ui.press({ key: 'delegar' });
|
|
163
|
+
expect(enviados.at(-1)!.text).toBe('Delega la tarea de mi mensaje anterior en el subagente niveles:nivel-alto y comprueba su informe.');
|
|
164
|
+
await ui.unmount();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('en la terminal la sugerencia sigue siendo texto', async ($, on) => {
|
|
168
|
+
prepararBoton($, on);
|
|
169
|
+
await $.session.start({ surface: 'terminal', isInteractive: true, cwd: '/test' });
|
|
170
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
171
|
+
await turno($, '1');
|
|
172
|
+
const ui = await $.ui.mount(BARRA('terminal'));
|
|
173
|
+
expect(await ui.find({ type: 'Button' })).toBeUndefined();
|
|
174
|
+
expect(await pintar($)).toContain('→ delega: nivel-ligero');
|
|
175
|
+
await ui.unmount();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('durante un turno en curso de la sesión principal no hay botón; un envío que no empieza turno no lo oculta', async ($, on) => {
|
|
179
|
+
prepararBoton($, on);
|
|
180
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
181
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
182
|
+
// El envío por sí solo no es un turno: el botón sigue (si el envío fallara, no quedaría bloqueado).
|
|
183
|
+
const sinTurno = await $.ui.mount(BARRA('desktop'));
|
|
184
|
+
expect(await sinTurno.find({ type: 'Button' })).toBeDefined();
|
|
185
|
+
await sinTurno.unmount();
|
|
186
|
+
await $.turn.start({ text: 'x', turnId: 't1' });
|
|
187
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
188
|
+
expect(await ui.find({ type: 'Button' })).toBeUndefined();
|
|
189
|
+
await ui.unmount();
|
|
190
|
+
await $.turn.complete({ answer: 'ok', durationMs: 1, isAborted: false, turnId: 't1', reason: 'answer' });
|
|
191
|
+
const despues = await $.ui.mount(BARRA('desktop'));
|
|
192
|
+
expect(await despues.find({ type: 'Button' })).toBeDefined();
|
|
193
|
+
await despues.unmount();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('sin mensaje previo de la persona no hay botón', async ($, on) => {
|
|
197
|
+
prepararBoton($, on);
|
|
198
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
199
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
200
|
+
expect(await ui.find({ type: 'Button' })).toBeUndefined();
|
|
201
|
+
await ui.unmount();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('tras pulsar el botón no se puede enviar dos veces', async ($, on) => {
|
|
205
|
+
const enviados = prepararBoton($, on);
|
|
206
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
207
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
208
|
+
await turno($, '1');
|
|
209
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
210
|
+
await ui.press({ key: 'delegar' });
|
|
211
|
+
await ui.unmount();
|
|
212
|
+
const antes = enviados.length;
|
|
213
|
+
// El turno de la delegación termina y el botón sigue sin volver para el mismo mensaje.
|
|
214
|
+
await turno($, '2');
|
|
215
|
+
const otra = await $.ui.mount(BARRA('desktop'));
|
|
216
|
+
expect(await otra.find({ type: 'Button' })).toBeUndefined();
|
|
217
|
+
expect(enviados).toHaveLength(antes);
|
|
218
|
+
await otra.unmount();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('el envío del botón no cambia el último mensaje de la persona', async ($, on) => {
|
|
222
|
+
const enviados = prepararBoton($, on);
|
|
223
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
224
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
225
|
+
await turno($, '1');
|
|
226
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
227
|
+
await ui.press({ key: 'delegar' });
|
|
228
|
+
await ui.unmount();
|
|
229
|
+
// «ok, dale» hereda la recomendación del último mensaje: si la instrucción del botón la hubiera cambiado, no saldría ligero.
|
|
230
|
+
await $.prompt.submit({ text: 'ok, dale' });
|
|
231
|
+
await turno($, '2');
|
|
232
|
+
const otra = await $.ui.mount(BARRA('desktop'));
|
|
233
|
+
expect((await otra.find({ type: 'Button' }))?.props.label).toBe('→ delega: nivel-ligero');
|
|
234
|
+
expect(enviados.map((x) => x.plugin)).toEqual([false, true, false]);
|
|
235
|
+
await otra.unmount();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('si el envío del botón falla, avisa en español y el botón vuelve para reintentar', async ($, on) => {
|
|
239
|
+
const avisos: string[] = [];
|
|
240
|
+
const falla = { valor: true };
|
|
241
|
+
const enviados = prepararBoton($, on, 'claude-opus-5-5', { avisos, falla });
|
|
242
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
243
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
244
|
+
await turno($, '1');
|
|
245
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
246
|
+
await ui.press({ key: 'delegar' });
|
|
247
|
+
expect(avisos).toHaveLength(1);
|
|
248
|
+
expect(avisos[0]).toContain('reintentar');
|
|
249
|
+
expect(enviados).toHaveLength(1);
|
|
250
|
+
expect((await ui.find({ type: 'Button' }))?.props.label).toBe('→ delega: nivel-ligero');
|
|
251
|
+
falla.valor = false;
|
|
252
|
+
await ui.press({ key: 'delegar' });
|
|
253
|
+
expect(enviados).toHaveLength(2);
|
|
254
|
+
expect(enviados[1]!.plugin).toBe(true);
|
|
255
|
+
await ui.unmount();
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('un borrador con otro texto oculta el botón aunque la recomendación sea la misma; vacío o igual lo conserva', async ($, on) => {
|
|
259
|
+
prepararBoton($, on);
|
|
260
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
261
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
262
|
+
await turno($, '1');
|
|
263
|
+
const editar = (text: string, inputText: string) => $.prompt.edit({ origin: { kind: 'composer' }, text, cursor: text.length, start: 0, end: text.length, inputText });
|
|
264
|
+
const hayBoton = async () => {
|
|
265
|
+
const ui = await $.ui.mount(BARRA('desktop'));
|
|
266
|
+
const boton = await ui.find({ type: 'Button' });
|
|
267
|
+
await ui.unmount();
|
|
268
|
+
return boton !== undefined;
|
|
269
|
+
};
|
|
270
|
+
expect(await hayBoton()).toBe(true);
|
|
271
|
+
// «ok, dale» conserva la recomendación del último mensaje, pero es otro texto.
|
|
272
|
+
await editar('', 'ok, dale');
|
|
273
|
+
expect(await hayBoton()).toBe(false);
|
|
274
|
+
await editar('ok, dale', '');
|
|
275
|
+
expect(await hayBoton()).toBe(true);
|
|
276
|
+
await editar('', ` ${MENSAJES['nivel-ligero']} `);
|
|
277
|
+
expect(await hayBoton()).toBe(true);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('el botón solo aparece en la app de escritorio, no en otras superficies con botones', async ($, on) => {
|
|
281
|
+
prepararBoton($, on);
|
|
282
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
283
|
+
await $.prompt.submit({ text: MENSAJES['nivel-ligero'] });
|
|
284
|
+
await turno($, '1');
|
|
285
|
+
for (const surface of ['mobile', 'vscode', 'terminal'] as const) {
|
|
286
|
+
const ui = await $.ui.mount(BARRA(surface));
|
|
287
|
+
expect(await ui.find({ type: 'Button' })).toBeUndefined();
|
|
288
|
+
await ui.unmount();
|
|
289
|
+
}
|
|
290
|
+
const escritorio = await $.ui.mount(BARRA('desktop'));
|
|
291
|
+
expect(await escritorio.find({ type: 'Button' })).toBeDefined();
|
|
292
|
+
await escritorio.unmount();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Guarda de subagentes: la implementación de nivel normal se encarga primero con fabrica_encargar.
|
|
296
|
+
const prepararAgentes = ($: any, on: any, { conEncargos = true, listaFalla = false } = {}) => {
|
|
297
|
+
const lanzados: string[] = [];
|
|
298
|
+
on('session.start', ($: any, e: any) => ({ cwd: e.cwd }));
|
|
299
|
+
on('session.model', () => ({ value: 'claude-opus-5-5' }));
|
|
300
|
+
on('tool.register', ($: any, e: any) => ({ value: { tool: e.name } }));
|
|
301
|
+
on('tool.list', () => {
|
|
302
|
+
if (listaFalla) throw new Error('sin lista');
|
|
303
|
+
const base = [{ name: 'Agent', description: 'subagentes', mcp: false }];
|
|
304
|
+
return { value: conEncargos ? [...base, { name: 'mcp__nexakit-fabrica__fabrica_encargar', description: 'encargar', mcp: true }] : base };
|
|
305
|
+
});
|
|
306
|
+
on('tool.call', ($: any, e: any) => {
|
|
307
|
+
lanzados.push(`${e.agentId ?? 'main'}:${e.subagent_type}`);
|
|
308
|
+
return { result: 'lanzado' };
|
|
309
|
+
});
|
|
310
|
+
return lanzados;
|
|
311
|
+
};
|
|
312
|
+
const agente = (extra: object) => ({ tool: 'Agent', description: 'implementar exportación', prompt: 'Añade el botón de exportar.', subagent_type: 'niveles:nivel-normal', ...extra }) as any;
|
|
313
|
+
|
|
314
|
+
test('el subagente niveles:nivel-normal se veta con el mensaje de encargar primero', async ($, on) => {
|
|
315
|
+
const lanzados = prepararAgentes($, on);
|
|
316
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
317
|
+
const r: any = await $.tool.call(agente({}));
|
|
318
|
+
expect(r.deny).toContain('Primero encarga esta implementación con fabrica_encargar (Codex o Antigravity): ahorra tokens de Claude.');
|
|
319
|
+
expect(r.deny).toContain('[sin encargo]');
|
|
320
|
+
expect(lanzados).toHaveLength(0);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test('con la marca [sin encargo] en la descripción o en el prompt el subagente normal pasa', async ($, on) => {
|
|
324
|
+
const lanzados = prepararAgentes($, on);
|
|
325
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
326
|
+
expect((await $.tool.call(agente({ description: 'implementar [sin encargo]' }))).deny).toBeUndefined();
|
|
327
|
+
expect((await $.tool.call(agente({ prompt: 'Contexto. [Sin encargo] porque el encargo falló.' }))).deny).toBeUndefined();
|
|
328
|
+
expect(lanzados).toHaveLength(2);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test('no se veta nada más: ligero, exigente, alto, otros agentes, sin tipo ni subagentes de subagentes', async ($, on) => {
|
|
332
|
+
const lanzados = prepararAgentes($, on);
|
|
333
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
334
|
+
for (const subagent_type of ['niveles:nivel-ligero', 'niveles:nivel-exigente', 'niveles:nivel-alto', 'niveles:investigador', 'Explore', undefined])
|
|
335
|
+
expect((await $.tool.call(agente({ subagent_type }))).deny).toBeUndefined();
|
|
336
|
+
// Un subagente que lanza otro normal: el veto es solo de la sesión principal.
|
|
337
|
+
expect((await $.tool.call(agente({ agentId: 'a1' }))).deny).toBeUndefined();
|
|
338
|
+
expect(lanzados).toHaveLength(7);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
test('sin la herramienta fabrica_encargar no se veta; si no se puede saber, se veta igual', async ($, on) => {
|
|
342
|
+
prepararAgentes($, on, { conEncargos: false });
|
|
343
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
344
|
+
expect((await $.tool.call(agente({}))).deny).toBeUndefined();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test('si la lista de herramientas falla, se veta igual', async ($, on) => {
|
|
348
|
+
prepararAgentes($, on, { listaFalla: true });
|
|
349
|
+
await $.session.start({ surface: 'desktop', isInteractive: true, cwd: '/test' });
|
|
350
|
+
expect((await $.tool.call(agente({}))).deny).toContain('fabrica_encargar');
|
|
351
|
+
});
|
|
99
352
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "niveles",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Agentes por nivel (ligero, normal, exigente, alto) con modelo y esfuerzo fijos para delegar sin cambiar /model, y especialistas por tarea con tope de pasos: investigador, revisor de calidad, cierre de memoria, subir al repo, sincronizador de documentación y cazador de pruebas intermitentes.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juan Jaller"
|
|
@@ -16,3 +16,4 @@ Eres el cazador de pruebas intermitentes: la sesión principal te da un fallo de
|
|
|
16
16
|
- Lee solo la parte fallida del log (`--log-failed`, filtrando por el nombre de la prueba). Nunca vuelques un log entero.
|
|
17
17
|
- Termina con un veredicto: INTERMITENTE (falla y pasa con el mismo código), REGRESIÓN (falla siempre desde un commit concreto) o SIN DATOS. Añade la evidencia (ejecuciones con su enlace) y si relanzar una sola vez es razonable.
|
|
18
18
|
- Informe en español de máximo 200 palabras: el veredicto primero y después las cifras.
|
|
19
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|
|
@@ -14,3 +14,4 @@ Eres el cierre de memoria: la sesión principal te delega cerrar la memoria de u
|
|
|
14
14
|
- Registra los PR pendientes de uno en uno: la herramienta exige el registro limpio entre uno y otro. Haz un commit local de la bóveda entre ellos solo si el encargo lo autoriza; si no, registra el primero, detente y di cuáles quedan. No hagas push.
|
|
15
15
|
- Nunca sustituyas el registro por una fila a mano: si la herramienta bloquea, deja lo preparado y di el motivo exacto.
|
|
16
16
|
- Informe en español de máximo 200 palabras: notas editadas, PR registrados y pendientes, resultado de `doctor` y, al final, la línea `Memoria <proyecto>: <estado real>.`
|
|
17
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|
|
@@ -16,3 +16,4 @@ Eres el investigador: respondes una duda concreta que te delega la sesión princ
|
|
|
16
16
|
- Cuida el gasto: busca palabras clave en las páginas largas en vez de leerlas enteras y no repitas búsquedas. Si llegas al límite o se acaban los pasos, entrega lo que tengas y di qué quedó sin comprobar.
|
|
17
17
|
- En Bash entrecomilla los separadores (`echo "=="`): en zsh un `echo ====` sin comillas falla y oculta el resto de la salida.
|
|
18
18
|
- Informe en español de máximo 300 palabras: la respuesta primero, luego lo verificado y lo no verificado con sus enlaces. Si hace falta más detalle, guárdalo en un archivo del scratchpad y da su ruta completa.
|
|
19
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|
|
@@ -11,3 +11,4 @@ Ejecutas una tarea que te delega la sesión principal, con el nivel Alto (opus,
|
|
|
11
11
|
- Si la tarea es de código: cambio mínimo, pruebas que lo cubran, y ejecútalas junto con el lint o la compilación que correspondan.
|
|
12
12
|
- No hagas commit, push ni PR, y no envíes, apruebes ni reclames encargos de revisión.
|
|
13
13
|
- Responde breve, en menos de 200 palabras: cambios por archivo (sin pegar el diff), comprobaciones con su resultado real y lo que no comprobaste. En búsquedas, solo rutas con línea. No repitas el encargo.
|
|
14
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|
|
@@ -11,3 +11,4 @@ Ejecutas una tarea que te delega la sesión principal, con el nivel Exigente (so
|
|
|
11
11
|
- Si la tarea es de código: cambio mínimo, pruebas que lo cubran, y ejecútalas junto con el lint o la compilación que correspondan.
|
|
12
12
|
- No hagas commit, push ni PR, y no envíes, apruebes ni reclames encargos de revisión.
|
|
13
13
|
- Responde breve, en menos de 200 palabras: cambios por archivo (sin pegar el diff), comprobaciones con su resultado real y lo que no comprobaste. En búsquedas, solo rutas con línea. No repitas el encargo.
|
|
14
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|
|
@@ -11,3 +11,4 @@ Ejecutas una tarea que te delega la sesión principal, con el nivel Ligero (haik
|
|
|
11
11
|
- Si la tarea es de código: cambio mínimo, pruebas que lo cubran, y ejecútalas junto con el lint o la compilación que correspondan.
|
|
12
12
|
- No hagas commit, push ni PR, y no envíes, apruebes ni reclames encargos de revisión.
|
|
13
13
|
- Responde breve, en menos de 200 palabras: cambios por archivo (sin pegar el diff), comprobaciones con su resultado real y lo que no comprobaste. En búsquedas, solo rutas con línea. No repitas el encargo.
|
|
14
|
+
- Una orden por llamada al shell. Usa rutas absolutas en lugar de `cd`. No encadenes con `;`, `&&` ni `||`, y no uses paréntesis ni subshells `( … )`. Un `|` hacia `head`, `tail` o `grep` está permitido. Para leer y buscar, usa las herramientas de lectura y búsqueda en lugar de `cat`, `grep` o `ls` cuando existan. Las llamadas independientes se lanzan en paralelo, no encadenadas.
|