nexakit 0.13.1 → 0.14.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/.claude-plugin/marketplace.json +3 -3
- package/README.md +9 -8
- package/assets/runtime/package-lock.json +2 -2
- package/dist/fabrica/cli.js +69 -6
- package/dist/fabrica/conectores/codex.js +68 -1
- package/dist/fabrica/cuotas.js +299 -0
- package/dist/fabrica/decision.js +1 -3
- package/dist/fabrica/ejecutor.js +3 -0
- package/dist/fabrica/encargo/ejecutar.js +19 -6
- package/dist/fabrica/enrutador.js +77 -34
- package/dist/fabrica/mcp.js +2 -2
- package/dist/fabrica/rastro.js +2 -2
- package/dist/fabrica/sesion.js +5 -5
- package/dist/fabrica/tabla-modelos.json +4 -4
- package/package.json +1 -1
- package/plugins/huellas.json +8 -8
- package/plugins/nexakit-ahorro/.claude-plugin/plugin.json +2 -2
- package/plugins/nexakit-ahorro/README.md +9 -3
- package/plugins/nexakit-ahorro/hooks/register.js +17 -0
- package/plugins/nexakit-ahorro/tests/register.test.ts +40 -6
- package/plugins/nexakit-modelo/.claude-plugin/plugin.json +2 -2
- package/plugins/nexakit-modelo/hooks/barra.js +4 -27
- package/plugins/nexakit-modelo/hooks/decidir.js +15 -46
- package/plugins/nexakit-modelo/hooks/recomendar.js +8 -13
- package/plugins/nexakit-modelo/hooks/register.js +13 -134
- package/plugins/nexakit-modelo/tests/register.test.ts +31 -230
- package/plugins/nexakit-sesion/.claude-plugin/plugin.json +1 -1
- package/plugins/nexakit-sesion/hooks/aviso.js +5 -6
- package/plugins/nexakit-sesion/hooks/register.js +1 -1
- package/plugins/niveles/.claude-plugin/plugin.json +2 -2
- package/plugins/niveles/agents/cazador-de-flakes.md +2 -5
- package/plugins/niveles/agents/cierre-de-memoria.md +2 -4
- package/plugins/niveles/agents/investigador.md +6 -9
- package/plugins/niveles/agents/nivel-alto.md +6 -7
- package/plugins/niveles/agents/nivel-exigente.md +6 -7
- package/plugins/niveles/agents/nivel-ligero.md +7 -8
- package/plugins/niveles/agents/nivel-normal.md +6 -7
- package/plugins/niveles/agents/revisor-de-calidad.md +2 -4
- package/plugins/niveles/agents/sincronizador-docs.md +2 -4
- package/plugins/niveles/agents/subir-al-repo.md +2 -4
- package/skills/elegir-modelo/SKILL.md +13 -14
- package/skills/elegir-modelo/modelos.mjs +1 -0
- package/skills/fabrica/SKILL.md +6 -7
- package/src/agent-models.js +21 -7
- package/src/ahorro-command.js +26 -4
- package/src/antigravity-agents.js +10 -8
- package/src/antigravity-barra.js +89 -24
- package/src/antigravity-command.js +11 -3
- package/src/antigravity-hook.js +1 -1
- package/src/antigravity-pre-tool.js +3 -1
- package/src/antigravity-recommendation.js +49 -51
- package/src/codex-audit.js +2 -2
- package/src/codex-auto-output.js +3 -0
- package/src/codex-hook.js +1 -1
- package/src/codex-output.js +6 -1
- package/src/codex-pre-tool.js +7 -0
- package/src/codex-recommendation.js +6 -10
- package/src/codex-routing.js +1 -1
- package/src/codex-setup.js +4 -3
- package/src/codex-team.js +20 -19
- package/src/fabrica/cli.ts +63 -6
- package/src/fabrica/conectores/codex.ts +65 -2
- package/src/fabrica/conectores/tipos.ts +2 -0
- package/src/fabrica/cuotas.ts +294 -0
- package/src/fabrica/decision.ts +1 -3
- package/src/fabrica/ejecutor.ts +2 -0
- package/src/fabrica/encargo/ejecutar.ts +17 -6
- package/src/fabrica/enrutador.ts +67 -31
- package/src/fabrica/mcp.ts +2 -2
- package/src/fabrica/rastro.ts +2 -2
- package/src/fabrica/sesion.ts +6 -6
- package/src/fabrica/tabla-modelos.json +4 -4
- package/src/gemini-tools.js +1 -1
- package/src/level-agents.js +9 -7
- package/src/model-command.js +16 -7
- package/src/mods.js +2 -2
- package/src/preferencias-globales.js +80 -0
- package/src/review-instructions.js +27 -37
- package/src/toolkit-cli.js +5 -4
- package/src/regla-ordenes-simples.d.ts +0 -2
- package/src/regla-ordenes-simples.js +0 -4
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { constants, closeSync, fstatSync, lstatSync, openSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { setTimeout as esperar } from 'node:timers/promises';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { ErrorCandadoOcupado, tomarCandadoArchivo } from './encargo/candado.js';
|
|
6
|
+
import { escribirReemplazando, prepararBase } from './rastro.js';
|
|
7
|
+
import { IAExterna } from './esquemas.js';
|
|
8
|
+
const HORA_MS = 60 * 60 * 1000;
|
|
9
|
+
const CADUCIDAD_BARRA_MS = 6 * HORA_MS;
|
|
10
|
+
const ARCHIVO = 'cuotas.json';
|
|
11
|
+
const CADUCIDAD_CANDADO_MS = 10_000;
|
|
12
|
+
const ESPERA_CANDADO_MS = 2_000;
|
|
13
|
+
const UMBRAL_AGOTADA = 95;
|
|
14
|
+
export const UMBRAL_CUOTA_BAJA = 80;
|
|
15
|
+
export const TOPE_CUOTA_MS = 5_000;
|
|
16
|
+
const fecha = z.iso.datetime();
|
|
17
|
+
const porcentaje = z.number().min(0).max(100);
|
|
18
|
+
const Ventana = z.object({ porcentajeUsado: porcentaje, reinicio: fecha.optional(), fecha: fecha.optional() });
|
|
19
|
+
const Ventanas = z.object({ cincoHoras: Ventana.optional(), semanal: Ventana.optional() });
|
|
20
|
+
const Bloqueo = z.object({ hasta: fecha, motivo: z.string(), fecha });
|
|
21
|
+
const Estado = Ventana.partial().extend({
|
|
22
|
+
ventanas: Ventanas.optional(),
|
|
23
|
+
porcentajeMinimoUsado: porcentaje.optional(),
|
|
24
|
+
bloqueo: Bloqueo.optional(),
|
|
25
|
+
fuente: z.enum(['consulta', 'notificación', 'barra']).optional(),
|
|
26
|
+
});
|
|
27
|
+
const EstadoEnDisco = Estado.extend({
|
|
28
|
+
agotadaHasta: fecha.optional(),
|
|
29
|
+
fuente: z.enum(['consulta', 'notificación', 'barra', 'error']).optional(),
|
|
30
|
+
});
|
|
31
|
+
export const NOMBRES_VENTANA = { cincoHoras: '5 h', semanal: 'semanal' };
|
|
32
|
+
export const CLAVES_VENTANA = ['cincoHoras', 'semanal'];
|
|
33
|
+
export function leerCuotas(home) {
|
|
34
|
+
try {
|
|
35
|
+
const nexakit = path.join(home, '.nexakit');
|
|
36
|
+
const base = path.join(nexakit, 'fabrica');
|
|
37
|
+
if (![nexakit, base].every((ruta) => lstatSync(ruta, { throwIfNoEntry: false })?.isDirectory()))
|
|
38
|
+
return {};
|
|
39
|
+
const ruta = path.join(base, ARCHIVO);
|
|
40
|
+
if (!lstatSync(ruta, { throwIfNoEntry: false })?.isFile())
|
|
41
|
+
return {};
|
|
42
|
+
const fd = openSync(ruta, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
43
|
+
try {
|
|
44
|
+
const info = fstatSync(fd);
|
|
45
|
+
if (!info.isFile() || info.size > 16_384)
|
|
46
|
+
return {};
|
|
47
|
+
const valor = JSON.parse(readFileSync(fd, 'utf8'));
|
|
48
|
+
const cuotas = z.object({ codex: z.unknown().optional(), antigravity: z.unknown().optional() }).safeParse(valor);
|
|
49
|
+
if (!cuotas.success)
|
|
50
|
+
return {};
|
|
51
|
+
const datos = {};
|
|
52
|
+
for (const ia of IAExterna.options) {
|
|
53
|
+
const guardado = EstadoEnDisco.safeParse(cuotas.data[ia]);
|
|
54
|
+
if (!guardado.success)
|
|
55
|
+
continue;
|
|
56
|
+
const { agotadaHasta, fuente, fecha: medida, ...estado } = guardado.data;
|
|
57
|
+
const tieneMedicion = estado.ventanas !== undefined || estado.porcentajeUsado !== undefined;
|
|
58
|
+
const fuentePredeterminada = ia === 'codex' ? 'consulta' : 'barra';
|
|
59
|
+
const fuenteMedicion = fuente === 'error' ? (tieneMedicion ? fuentePredeterminada : undefined) : fuente;
|
|
60
|
+
const bloqueo = estado.bloqueo ?? (agotadaHasta === undefined ? undefined : {
|
|
61
|
+
hasta: agotadaHasta, motivo: 'Límite informado por el proveedor', fecha: medida ?? agotadaHasta,
|
|
62
|
+
});
|
|
63
|
+
datos[ia] = {
|
|
64
|
+
...estado,
|
|
65
|
+
...(fuenteMedicion === undefined ? {} : { fuente: fuenteMedicion }),
|
|
66
|
+
...(medida === undefined || fuenteMedicion === undefined ? {} : { fecha: medida }),
|
|
67
|
+
...(bloqueo === undefined ? {} : { bloqueo }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return datos;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
closeSync(fd);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Las consultas de la CLI y las notificaciones de otros procesos pueden coincidir. */
|
|
81
|
+
async function actualizar(home, ia, cambiar) {
|
|
82
|
+
try {
|
|
83
|
+
const base = await prepararBase(home);
|
|
84
|
+
const ruta = path.join(base, ARCHIVO);
|
|
85
|
+
const candado = `${ruta}.candado`;
|
|
86
|
+
const limite = performance.now() + ESPERA_CANDADO_MS;
|
|
87
|
+
for (;;) {
|
|
88
|
+
try {
|
|
89
|
+
const propio = await tomarCandadoArchivo(candado, { caducidadMs: CADUCIDAD_CANDADO_MS });
|
|
90
|
+
try {
|
|
91
|
+
const cuotas = leerCuotas(home);
|
|
92
|
+
cuotas[ia] = cambiar(cuotas[ia]);
|
|
93
|
+
await escribirReemplazando(ruta, `${JSON.stringify(cuotas, null, 2)}\n`, () => {
|
|
94
|
+
if (!propio.vigente())
|
|
95
|
+
throw new ErrorCandadoOcupado('El candado de cuotas caducó');
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
await propio.liberar();
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (!(error instanceof ErrorCandadoOcupado))
|
|
105
|
+
throw error;
|
|
106
|
+
const restante = limite - performance.now();
|
|
107
|
+
if (restante <= 0)
|
|
108
|
+
return;
|
|
109
|
+
await esperar(Math.min(20, restante));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// La cuota es informativa si el estado local no se puede guardar.
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export async function guardarVentanasCodex(home, ventanas, fuente) {
|
|
118
|
+
if (!CLAVES_VENTANA.some((clave) => ventanas[clave] !== undefined))
|
|
119
|
+
return;
|
|
120
|
+
const ahora = Date.now();
|
|
121
|
+
await actualizar(home, 'codex', (anterior) => {
|
|
122
|
+
const fusionadas = { ...ventanas };
|
|
123
|
+
if (fuente === 'notificación') {
|
|
124
|
+
for (const clave of CLAVES_VENTANA) {
|
|
125
|
+
const previa = anterior?.ventanas?.[clave];
|
|
126
|
+
if (fusionadas[clave] === undefined && previa !== undefined) {
|
|
127
|
+
// Si no hay reinicio conocido, la vigencia depende de cuándo se recibió esta ventana.
|
|
128
|
+
fusionadas[clave] = previa.reinicio === undefined ? { ...previa, fecha: previa.fecha ?? anterior?.fecha } : previa;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const medidas = Object.values(fusionadas).filter((v) => v !== undefined);
|
|
133
|
+
const mayor = medidas.sort((a, b) => b.porcentajeUsado - a.porcentajeUsado)[0];
|
|
134
|
+
const bloqueo = medidas.some((v) => v.porcentajeUsado >= UMBRAL_AGOTADA) ? bloqueoVigente(anterior, ahora) : undefined;
|
|
135
|
+
return {
|
|
136
|
+
porcentajeUsado: mayor?.porcentajeUsado,
|
|
137
|
+
reinicio: mayor?.reinicio,
|
|
138
|
+
ventanas: fusionadas,
|
|
139
|
+
fuente,
|
|
140
|
+
fecha: new Date(ahora).toISOString(),
|
|
141
|
+
bloqueo,
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export async function guardarCuotaAntigravity(home, cuota, ahora = Date.now()) {
|
|
146
|
+
if (!Number.isFinite(cuota.porcentajeUsado))
|
|
147
|
+
return;
|
|
148
|
+
const porcentajeUsado = Math.min(100, Math.max(0, Math.round(cuota.porcentajeUsado)));
|
|
149
|
+
const minimo = cuota.porcentajeMinimoUsado;
|
|
150
|
+
const porcentajeMinimoUsado = minimo !== undefined && Number.isFinite(minimo)
|
|
151
|
+
? Math.min(Math.max(0, cuota.porcentajeUsado), Math.max(0, minimo), 100)
|
|
152
|
+
: undefined;
|
|
153
|
+
const reinicioMs = typeof cuota.reinicio === 'string' ? Date.parse(cuota.reinicio) : Number.NaN;
|
|
154
|
+
const reinicio = Number.isFinite(reinicioMs) ? new Date(reinicioMs).toISOString() : undefined;
|
|
155
|
+
await actualizar(home, 'antigravity', (anterior) => ({
|
|
156
|
+
porcentajeUsado,
|
|
157
|
+
porcentajeMinimoUsado,
|
|
158
|
+
reinicio,
|
|
159
|
+
fuente: 'barra',
|
|
160
|
+
fecha: new Date(ahora).toISOString(),
|
|
161
|
+
bloqueo: bloqueoVigente(anterior, ahora),
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
const vigente = (hasta, ahora) => Date.parse(hasta ?? '') > ahora;
|
|
165
|
+
const enUnaHora = (ahora) => new Date(ahora + HORA_MS).toISOString();
|
|
166
|
+
export function bloqueoVigente(estado, ahora = Date.now()) {
|
|
167
|
+
return vigente(estado?.bloqueo?.hasta, ahora) ? estado?.bloqueo : undefined;
|
|
168
|
+
}
|
|
169
|
+
function limiteMedicion(estado, ventana, ahora) {
|
|
170
|
+
const medida = Date.parse(ventana.fecha ?? estado.fecha ?? '');
|
|
171
|
+
if (!Number.isFinite(medida) || ventana.porcentajeUsado === undefined)
|
|
172
|
+
return undefined;
|
|
173
|
+
const duracion = estado.fuente === 'barra' ? CADUCIDAD_BARRA_MS : HORA_MS;
|
|
174
|
+
if (estado.fuente === 'barra' && ahora - medida >= duracion)
|
|
175
|
+
return undefined;
|
|
176
|
+
const hasta = ventana.reinicio ?? new Date(medida + duracion).toISOString();
|
|
177
|
+
return vigente(hasta, ahora) ? hasta : undefined;
|
|
178
|
+
}
|
|
179
|
+
export function ventanasCuota(estado, ahora) {
|
|
180
|
+
const ventanas = estado?.ventanas;
|
|
181
|
+
if (estado === undefined || ventanas === undefined)
|
|
182
|
+
return undefined;
|
|
183
|
+
const resultado = {};
|
|
184
|
+
for (const clave of CLAVES_VENTANA) {
|
|
185
|
+
const ventana = ventanas[clave];
|
|
186
|
+
if (ventana !== undefined)
|
|
187
|
+
resultado[clave] = { ...ventana, vigente: limiteMedicion(estado, ventana, ahora) !== undefined };
|
|
188
|
+
}
|
|
189
|
+
return resultado;
|
|
190
|
+
}
|
|
191
|
+
/** Devuelve el límite de uso efectivo de las ventanas que todavía siguen abiertas. */
|
|
192
|
+
export function estadoCuota(estado, ahora = Date.now()) {
|
|
193
|
+
if (estado === undefined)
|
|
194
|
+
return {};
|
|
195
|
+
const ventanas = estado.ventanas === undefined
|
|
196
|
+
? [[undefined, estado]]
|
|
197
|
+
: CLAVES_VENTANA.map((clave) => [clave, estado.ventanas?.[clave]]);
|
|
198
|
+
const efectivo = {};
|
|
199
|
+
const bloqueo = bloqueoVigente(estado, ahora);
|
|
200
|
+
if (bloqueo !== undefined)
|
|
201
|
+
efectivo.agotadaHasta = bloqueo.hasta;
|
|
202
|
+
for (const [clave, ventana] of ventanas) {
|
|
203
|
+
if (ventana?.porcentajeUsado === undefined)
|
|
204
|
+
continue;
|
|
205
|
+
const hasta = limiteMedicion(estado, ventana, ahora);
|
|
206
|
+
if (hasta === undefined)
|
|
207
|
+
continue;
|
|
208
|
+
if (efectivo.porcentajeUsado === undefined || ventana.porcentajeUsado > efectivo.porcentajeUsado) {
|
|
209
|
+
efectivo.porcentajeUsado = ventana.porcentajeUsado;
|
|
210
|
+
if (ventana.reinicio === undefined)
|
|
211
|
+
delete efectivo.reinicio;
|
|
212
|
+
else
|
|
213
|
+
efectivo.reinicio = ventana.reinicio;
|
|
214
|
+
}
|
|
215
|
+
const umbral = estado.fuente === 'barra' ? estado.porcentajeMinimoUsado : ventana.porcentajeUsado;
|
|
216
|
+
if (umbral !== undefined && umbral >= UMBRAL_AGOTADA &&
|
|
217
|
+
(efectivo.agotadaHasta === undefined || Date.parse(hasta) >= Date.parse(efectivo.agotadaHasta))) {
|
|
218
|
+
efectivo.agotadaHasta = hasta;
|
|
219
|
+
if (clave !== undefined)
|
|
220
|
+
efectivo.ventanaAgotada = clave;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return efectivo;
|
|
224
|
+
}
|
|
225
|
+
export function fechaCuota(fecha, ahora = Date.now()) {
|
|
226
|
+
const dia = new Date(fecha);
|
|
227
|
+
const hoy = new Date(ahora);
|
|
228
|
+
const mañana = new Date(ahora);
|
|
229
|
+
mañana.setDate(mañana.getDate() + 1);
|
|
230
|
+
const etiqueta = dia.toDateString() === hoy.toDateString() ? 'hoy'
|
|
231
|
+
: dia.toDateString() === mañana.toDateString() ? 'mañana' : `${dia.getDate()}/${dia.getMonth() + 1}`;
|
|
232
|
+
return `${etiqueta} ${dia.toLocaleTimeString('es', { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })}`;
|
|
233
|
+
}
|
|
234
|
+
export const nombreCuota = (ia) => ia === 'codex' ? 'Codex' : 'Antigravity';
|
|
235
|
+
export const sinCuota = (ia, hasta, ventana, ahora) => `${nombreCuota(ia)} sin cuota hasta ${fechaCuota(hasta, ahora)}${ventana === undefined ? '' : ` (ventana ${NOMBRES_VENTANA[ventana]})`}`;
|
|
236
|
+
export const pocaCuota = (ia, porcentaje, reinicio, ahora) => `${nombreCuota(ia)} tiene poca cuota (${porcentaje} % usado${reinicio === undefined ? '' : `, reinicio ${fechaCuota(reinicio, ahora)}`})`;
|
|
237
|
+
// Solo se examina el motivo del fallo, con los prefijos que agregan los conectores y el ejecutor.
|
|
238
|
+
const PREFIJO = /^(?:(?:el conector falló|(?:Codex|Antigravity) (?:falló|no completó la revisión|interrumpió la revisión)|salida de error|(?:api )?error(?: \d{3})?):\s*|\[?429\]?(?:\s*:\s*|\s+))/iu;
|
|
239
|
+
const LIMITE = /^(?:(?:you(?:['’]ve| have) )?hit (?:your |the )?usage limit|usage[_ ]limit[_ ](?:exceeded|reached)|(?:api )?rate[- ]limit(?:ed|s? (?:exceeded|reached|hit))|(?:you(?:['’]ve| have)? )?exceeded (?:your |the )?(?:current )?quota|(?:your |the )?(?:api |usage |model )?quota (?:has been |is )?(?:exceeded|exhausted|reached)|insufficient_quota|resource[ _-]exhausted|too many requests)\b/iu;
|
|
240
|
+
const LIMITE_BREVE = /^(?:(?:api )?rate[- ]limit|usage limit|quota)(?:[.:,;!]?(?:\s*try again\b|\s*$))/iu;
|
|
241
|
+
const TRANSITORIO = /^(?:(?:api )?rate[- ]limit|too many requests)/iu;
|
|
242
|
+
const REINTENTO = /\btry again at\s+(?:(?<mes>[a-z]+)\.?\s+(?<dia>\d{1,2})(?:st|nd|rd|th)?,?\s+(?:(?<año>\d{4}),?\s+)?)?(?<hora>\d{1,2}):(?<minuto>\d{2})(?:\s*(?<periodo>[ap]m)\b)?(?![\w:])/iu;
|
|
243
|
+
const MESES = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
|
|
244
|
+
function fechaReintento(linea, ahora) {
|
|
245
|
+
const grupos = REINTENTO.exec(linea)?.groups;
|
|
246
|
+
if (grupos === undefined)
|
|
247
|
+
return undefined;
|
|
248
|
+
const { mes, dia, año, hora, minuto, periodo } = grupos;
|
|
249
|
+
const h = Number(hora);
|
|
250
|
+
const m = Number(minuto);
|
|
251
|
+
if (m >= 60 || (periodo === undefined ? h >= 24 : h < 1 || h > 12))
|
|
252
|
+
return undefined;
|
|
253
|
+
const reinicio = new Date(ahora);
|
|
254
|
+
reinicio.setHours(periodo === undefined ? h : h % 12 + (periodo.toLowerCase() === 'pm' ? 12 : 0), m, 0, 0);
|
|
255
|
+
if (mes === undefined) {
|
|
256
|
+
if (reinicio.getTime() <= ahora)
|
|
257
|
+
reinicio.setDate(reinicio.getDate() + 1);
|
|
258
|
+
return reinicio.toISOString();
|
|
259
|
+
}
|
|
260
|
+
const nombre = mes.toLowerCase();
|
|
261
|
+
const indice = MESES.findIndex((mes) => mes === nombre || mes.slice(0, 3) === nombre);
|
|
262
|
+
if (indice === -1)
|
|
263
|
+
return undefined;
|
|
264
|
+
const diaDelMes = Number(dia);
|
|
265
|
+
reinicio.setFullYear(año === undefined ? reinicio.getFullYear() : Number(año), indice, diaDelMes);
|
|
266
|
+
if (año === undefined && reinicio.getTime() <= ahora) {
|
|
267
|
+
reinicio.setFullYear(reinicio.getFullYear() + 1, indice, diaDelMes);
|
|
268
|
+
}
|
|
269
|
+
return reinicio.getMonth() === indice && reinicio.getDate() === diaDelMes && reinicio.getTime() > ahora
|
|
270
|
+
? reinicio.toISOString() : undefined;
|
|
271
|
+
}
|
|
272
|
+
/** Interpreta la hora local del proveedor. Una hora anterior se refiere al día siguiente. */
|
|
273
|
+
export function detectarAgotamiento(motivo, ahora = Date.now()) {
|
|
274
|
+
const lineas = motivo.slice(-8192).split(/\r?\n|(?<=\. )(?=Salida de error:)/iu);
|
|
275
|
+
for (let linea of lineas) {
|
|
276
|
+
linea = linea.trim();
|
|
277
|
+
while (PREFIJO.test(linea))
|
|
278
|
+
linea = linea.replace(PREFIJO, '');
|
|
279
|
+
if (!LIMITE.test(linea) && !LIMITE_BREVE.test(linea))
|
|
280
|
+
continue;
|
|
281
|
+
return fechaReintento(linea, ahora) ??
|
|
282
|
+
(TRANSITORIO.test(linea) ? new Date(ahora + 10 * 60_000).toISOString() : enUnaHora(ahora));
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
export async function registrarFalloDeCuota(home, ia, motivo) {
|
|
287
|
+
const ahora = Date.now();
|
|
288
|
+
if (motivo === undefined)
|
|
289
|
+
return;
|
|
290
|
+
const hasta = detectarAgotamiento(motivo, ahora);
|
|
291
|
+
if (hasta === undefined)
|
|
292
|
+
return;
|
|
293
|
+
await actualizar(home, ia, (anterior) => ({
|
|
294
|
+
...anterior,
|
|
295
|
+
bloqueo: bloqueoVigente(anterior, Date.parse(hasta)) ?? {
|
|
296
|
+
hasta, motivo: motivo.trim().slice(-1024), fecha: new Date(ahora).toISOString(),
|
|
297
|
+
},
|
|
298
|
+
}));
|
|
299
|
+
}
|
package/dist/fabrica/decision.js
CHANGED
|
@@ -19,14 +19,12 @@ export function riesgoDe(categorias, estacion) {
|
|
|
19
19
|
// ---------------------------------------------------------------------------------------------------------------
|
|
20
20
|
// Orden de coste sin datos medidos
|
|
21
21
|
// ---------------------------------------------------------------------------------------------------------------
|
|
22
|
-
/** Sin rango de coste en las listas por nivel, Neon usa el mismo rango que una familia desconocida. */
|
|
23
22
|
const FAMILIA_DESCONOCIDA = 99;
|
|
24
23
|
const FAMILIAS = [
|
|
25
24
|
[/\b(luna|flash|haiku)\b/u, 0],
|
|
26
25
|
[/\b(hydrogen|terra|sonnet)\b/u, 1],
|
|
27
|
-
[/\b(sol|argon|opus)\b/u, 2],
|
|
26
|
+
[/\b(neon|sol|argon|opus)\b/u, 2],
|
|
28
27
|
[/\b(astra|carbon|fable)\b/u, 3],
|
|
29
|
-
[/\bneon\b/u, FAMILIA_DESCONOCIDA],
|
|
30
28
|
];
|
|
31
29
|
const ESFUERZOS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
32
30
|
function rangoFamilia(modelo) {
|
package/dist/fabrica/ejecutor.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
import os from 'node:os';
|
|
3
|
+
import { registrarFalloDeCuota } from './cuotas.js';
|
|
3
4
|
import { leerDiff } from './diff.js';
|
|
4
5
|
import { clasificarCambios, instantanea } from './disco.js';
|
|
5
6
|
import { calcularCoste, comprobarHuella, descarte } from './enrutador.js';
|
|
@@ -348,6 +349,8 @@ async function correrConPlaza(ej, trabajo, timeoutMs, graciaMs) {
|
|
|
348
349
|
final = { ...resultado, estado: 'cancelada', motivo: CANCELADA };
|
|
349
350
|
else
|
|
350
351
|
final = resultado;
|
|
352
|
+
if (final.estado === 'fallida' && trabajo.ia !== 'claude')
|
|
353
|
+
await registrarFalloDeCuota(ej.home, trabajo.ia, final.motivo);
|
|
351
354
|
// Primero el archivo de la estación, para que un estado terminado siempre tenga su resultado.
|
|
352
355
|
try {
|
|
353
356
|
await rastro.guardarEstacion(ej.estado.dir, trabajo.fila.estacion, trabajo.encargoRastro, final, trabajo.fila.revisionDe);
|
|
@@ -3,9 +3,9 @@ import { chmod, lstat, mkdir, readFile, rm } from 'node:fs/promises';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { inspectModels, recommendAntigravity } from '../../../src/model-command.js';
|
|
6
|
-
import { REGLA_ORDENES_SIMPLES } from '../../../src/regla-ordenes-simples.js';
|
|
7
6
|
import { crearConectorAntigravity, esComponenteProtegido, ORDENES_ACTIVAS } from '../conectores/antigravity.js';
|
|
8
7
|
import { crearConectorCodex } from '../conectores/codex.js';
|
|
8
|
+
import { bloqueoVigente, estadoCuota, leerCuotas, pocaCuota, registrarFalloDeCuota, sinCuota, UMBRAL_CUOTA_BAJA } from '../cuotas.js';
|
|
9
9
|
import { clasificarCambios, instantanea } from '../disco.js';
|
|
10
10
|
import { descarte } from '../enrutador.js';
|
|
11
11
|
import { AGOTADO, avisoIgnorados, bloqueLecciones, conGracia, conTope, GRACIA_MS, INTERVALO_ACTIVO_MS, TOPE_CATALOGO_MS } from '../ejecutor.js';
|
|
@@ -100,9 +100,8 @@ function instruccionesDelEncargo(texto, lecciones, reglaOrdenes) {
|
|
|
100
100
|
const lecc = bloqueLecciones(lecciones);
|
|
101
101
|
if (lecc !== '')
|
|
102
102
|
partes.push('', lecc);
|
|
103
|
-
partes.push('', 'Reglas de trabajo:',
|
|
104
|
-
partes.push(
|
|
105
|
-
partes.push('', 'Al terminar, responde con un resumen breve en texto (qué cambiaste y qué queda pendiente), sin pegar el diff.');
|
|
103
|
+
partes.push('', 'Reglas de trabajo:', reglaOrdenes);
|
|
104
|
+
partes.push('', 'Al terminar, responde con un resumen en texto (qué cambiaste, qué comprobaste y qué queda pendiente), sin pegar el diff.');
|
|
106
105
|
return `${partes.join('\n')}\n`;
|
|
107
106
|
}
|
|
108
107
|
// ---------------------------------------------------------------------------------------------
|
|
@@ -390,6 +389,10 @@ export async function ejecutarEncargo(opciones) {
|
|
|
390
389
|
b.avisos.push(`No se usa el modelo normal de ${quien}: ${texto}`);
|
|
391
390
|
}
|
|
392
391
|
const { ia: iaElegida, conector, modelo, esfuerzo } = elegida;
|
|
392
|
+
const { porcentajeUsado, reinicio } = estadoCuota(leerCuotas(home)[iaElegida]);
|
|
393
|
+
if (porcentajeUsado !== undefined && porcentajeUsado >= UMBRAL_CUOTA_BAJA) {
|
|
394
|
+
b.avisos.push(pocaCuota(iaElegida, porcentajeUsado, reinicio));
|
|
395
|
+
}
|
|
393
396
|
b.ia = iaElegida;
|
|
394
397
|
b.modelo = modelo;
|
|
395
398
|
b.esfuerzo = esfuerzo;
|
|
@@ -499,6 +502,7 @@ export async function ejecutarEncargo(opciones) {
|
|
|
499
502
|
else if (resultado.estado === 'fallida') {
|
|
500
503
|
b.estado = 'fallido';
|
|
501
504
|
b.motivo = limpiar(resultado.motivo ?? 'la IA no completó el encargo');
|
|
505
|
+
await registrarFalloDeCuota(home, elegida.ia, resultado.motivo);
|
|
502
506
|
}
|
|
503
507
|
else {
|
|
504
508
|
b.estado = 'ok';
|
|
@@ -631,17 +635,26 @@ export async function ejecutarEncargo(opciones) {
|
|
|
631
635
|
/** Abre el conector, valida el modelo normal y reúne las alternativas compatibles con el esfuerzo. */
|
|
632
636
|
async function preparar(quien, ordenes, reunirCandidatos) {
|
|
633
637
|
const sinModelo = (motivo) => ({ candidatos: [], motivo });
|
|
638
|
+
const previa = leerCuotas(home)[quien];
|
|
639
|
+
const agotada = estadoCuota(previa);
|
|
640
|
+
const aviso = agotada.agotadaHasta === undefined ? undefined : sinCuota(quien, agotada.agotadaHasta, agotada.ventanaAgotada);
|
|
641
|
+
if (aviso !== undefined && (quien !== 'codex' || bloqueoVigente(previa) === undefined))
|
|
642
|
+
return sinModelo(aviso);
|
|
634
643
|
const fabrica = fabricas[quien];
|
|
635
644
|
if (fabrica === undefined)
|
|
636
|
-
return sinModelo(`${quien} no está disponible`);
|
|
645
|
+
return sinModelo(aviso ?? `${quien} no está disponible`);
|
|
637
646
|
let conector;
|
|
638
647
|
try {
|
|
639
648
|
conector = await fabrica({ raiz: w.dir, ordenesPermitidas: ordenes, ...(tmpCreado ? { tmp } : {}) });
|
|
640
649
|
}
|
|
641
650
|
catch (error) {
|
|
642
|
-
return sinModelo(`${quien} no está disponible: ${datosDe(error)}`);
|
|
651
|
+
return sinModelo(aviso ?? `${quien} no está disponible: ${datosDe(error)}`);
|
|
643
652
|
}
|
|
644
653
|
abiertos[quien] = conector;
|
|
654
|
+
await conector.consultarCuota?.().catch(() => undefined);
|
|
655
|
+
const { agotadaHasta, ventanaAgotada } = estadoCuota(leerCuotas(home)[quien]);
|
|
656
|
+
if (agotadaHasta !== undefined)
|
|
657
|
+
return sinModelo(sinCuota(quien, agotadaHasta, ventanaAgotada));
|
|
645
658
|
let catalogo;
|
|
646
659
|
try {
|
|
647
660
|
catalogo = await conTope(Promise.resolve().then(() => conector.catalogo()), topeCatalogoMs);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import { cargarConfig } from './config.js';
|
|
4
|
+
import { estadoCuota, leerCuotas, nombreCuota, pocaCuota, sinCuota, UMBRAL_CUOTA_BAJA } from './cuotas.js';
|
|
4
5
|
import { elegir, riesgoDe, UMBRALES } from './decision.js';
|
|
5
6
|
import { clasificar, leerDiff } from './diff.js';
|
|
6
7
|
import { ErrorFabrica } from './errores.js';
|
|
@@ -186,6 +187,17 @@ export async function proponer(entrada) {
|
|
|
186
187
|
leerPreferencias(home),
|
|
187
188
|
]);
|
|
188
189
|
const avisosEstaciones = [];
|
|
190
|
+
const cuotas = leerCuotas(home);
|
|
191
|
+
const agotadas = new Map();
|
|
192
|
+
const instante = ahora.getTime();
|
|
193
|
+
for (const ia of IAExterna.options) {
|
|
194
|
+
const { agotadaHasta, ventanaAgotada, porcentajeUsado, reinicio } = estadoCuota(cuotas[ia], instante);
|
|
195
|
+
if (agotadaHasta !== undefined)
|
|
196
|
+
agotadas.set(ia, sinCuota(ia, agotadaHasta, ventanaAgotada, instante));
|
|
197
|
+
else if (porcentajeUsado !== undefined && porcentajeUsado >= UMBRAL_CUOTA_BAJA) {
|
|
198
|
+
avisosEstaciones.push(pocaCuota(ia, porcentajeUsado, reinicio, instante));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
189
201
|
let usoEvidencia = false;
|
|
190
202
|
function proponerEstacion(estacion, revisionDe) {
|
|
191
203
|
const cfg = config.estaciones?.[estacion];
|
|
@@ -210,32 +222,60 @@ export async function proponer(entrada) {
|
|
|
210
222
|
return omitida(regla.sinActivar);
|
|
211
223
|
const motivo = revisionDe !== undefined ? 'revisión cruzada de código' : porDiff ? regla.motivo : 'activada en la configuración';
|
|
212
224
|
const descartes = [];
|
|
225
|
+
const descartesCuota = new Set();
|
|
226
|
+
function descartar(c) {
|
|
227
|
+
const agotada = agotadas.get(c.ia);
|
|
228
|
+
if (agotada === undefined)
|
|
229
|
+
return descarte(c, catalogos);
|
|
230
|
+
descartesCuota.add(agotada);
|
|
231
|
+
return agotada;
|
|
232
|
+
}
|
|
213
233
|
const manual = candidatosDe(estacion, revisionDe === undefined ? cfg : undefined, descartes, revisionDe);
|
|
214
|
-
const propuesta = (c, explicacion, calidad) =>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
const propuesta = (c, explicacion, calidad) => {
|
|
235
|
+
for (const aviso of descartesCuota)
|
|
236
|
+
avisosEstaciones.push(`${aviso}. En ${nombre} se usa ${c.ia} (${nombreDe(c)})`);
|
|
237
|
+
return {
|
|
238
|
+
estacion,
|
|
239
|
+
...(revisionDe === undefined ? {} : { revisionDe }),
|
|
240
|
+
ia: c.ia,
|
|
241
|
+
modelo: c.modelo,
|
|
242
|
+
// Antigravity lleva el esfuerzo dentro del id del modelo.
|
|
243
|
+
esfuerzo: c.ia === 'antigravity' ? null : c.esfuerzo,
|
|
244
|
+
motivo,
|
|
245
|
+
descartes,
|
|
246
|
+
explicacion,
|
|
247
|
+
calidad,
|
|
248
|
+
ordenesPermitidas: ordenesDe(estacion, c.ia, cfg),
|
|
249
|
+
estado: 'propuesta',
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
const sinModelo = () => {
|
|
253
|
+
for (const aviso of descartesCuota)
|
|
254
|
+
avisosEstaciones.push(`${aviso}. En ${nombre} no hay otro candidato disponible`);
|
|
255
|
+
return { ...omitida(motivo), descartes, explicacion: 'ningún candidato está disponible en el catálogo', estado: 'sin-modelo' };
|
|
256
|
+
};
|
|
257
|
+
function delCatalogo() {
|
|
258
|
+
const candidatos = [];
|
|
259
|
+
for (const ia of revisionDe === undefined ? IAExterna.options : [revisionDe]) {
|
|
260
|
+
if (agotadas.has(ia))
|
|
261
|
+
continue;
|
|
262
|
+
for (const { modelo, esfuerzos } of catalogos[ia] ?? []) {
|
|
263
|
+
if (ia === 'antigravity')
|
|
264
|
+
candidatos.push({ ia, modelo, esfuerzo: null });
|
|
265
|
+
else
|
|
266
|
+
for (const esfuerzo of esfuerzos) {
|
|
267
|
+
if (cfg?.esfuerzo === undefined || esfuerzo === cfg.esfuerzo)
|
|
268
|
+
candidatos.push({ ia, modelo, esfuerzo });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return candidatos;
|
|
273
|
+
}
|
|
234
274
|
const fijada = cfg?.ia !== undefined || cfg?.modelo !== undefined;
|
|
235
275
|
if (revisionDe === undefined && (fijada || manual[0]?.ia === 'claude')) {
|
|
236
276
|
// Lo fijado en la configuración y las estaciones de Claude no se deciden por evidencia: manda la tabla.
|
|
237
277
|
for (const c of manual) {
|
|
238
|
-
const razon =
|
|
278
|
+
const razon = descartar(c);
|
|
239
279
|
if (razon !== null) {
|
|
240
280
|
descartes.push(razon);
|
|
241
281
|
continue;
|
|
@@ -245,29 +285,27 @@ export async function proponer(entrada) {
|
|
|
245
285
|
const cumple = (cfg?.ia === undefined || c.ia === cfg.ia) && (cfg?.modelo === undefined || c.modelo === cfg.modelo);
|
|
246
286
|
return propuesta(c, cumple ? NOTA_FIJADA : `${NOTA_FIJADA} no está disponible; se usa ${nombreDe(c)} de la tabla`, null);
|
|
247
287
|
}
|
|
288
|
+
if (descartesCuota.size > 0) {
|
|
289
|
+
const alternativa = delCatalogo()[0];
|
|
290
|
+
if (alternativa !== undefined)
|
|
291
|
+
return propuesta(alternativa, 'se usa el orden del catálogo por falta de cuota', null);
|
|
292
|
+
}
|
|
248
293
|
return sinModelo();
|
|
249
294
|
}
|
|
250
295
|
const disponibles = [];
|
|
251
296
|
for (const c of candidatosConEvidencia(estacion, manual, revisionDe === undefined ? cfg : undefined, catalogos, evidencia)) {
|
|
252
297
|
if (revisionDe !== undefined && c.ia !== revisionDe)
|
|
253
298
|
continue;
|
|
254
|
-
const razon =
|
|
299
|
+
const razon = descartar(c);
|
|
255
300
|
if (razon === null)
|
|
256
301
|
disponibles.push(c);
|
|
257
302
|
else
|
|
258
303
|
descartes.push(razon);
|
|
259
304
|
}
|
|
260
|
-
//
|
|
261
|
-
const porCatalogo = revisionDe !== undefined
|
|
262
|
-
if (porCatalogo)
|
|
263
|
-
|
|
264
|
-
if (revisionDe === 'antigravity')
|
|
265
|
-
disponibles.push({ ia: revisionDe, modelo, esfuerzo: null });
|
|
266
|
-
else
|
|
267
|
-
for (const esfuerzo of esfuerzos)
|
|
268
|
-
disponibles.push({ ia: revisionDe, modelo, esfuerzo });
|
|
269
|
-
}
|
|
270
|
-
}
|
|
305
|
+
// Una revisión cruzada o una estación que perdió sus candidatos por cuota puede recurrir al catálogo.
|
|
306
|
+
const porCatalogo = disponibles.length === 0 && (revisionDe !== undefined || descartesCuota.size > 0);
|
|
307
|
+
if (porCatalogo)
|
|
308
|
+
disponibles.push(...delCatalogo());
|
|
271
309
|
if (disponibles.length === 0)
|
|
272
310
|
return sinModelo();
|
|
273
311
|
usoEvidencia = true;
|
|
@@ -292,11 +330,16 @@ export async function proponer(entrada) {
|
|
|
292
330
|
for (const ia of IAExterna.options) {
|
|
293
331
|
if (principal.ia === ia)
|
|
294
332
|
continue;
|
|
333
|
+
const agotada = agotadas.get(ia);
|
|
334
|
+
if (agotada !== undefined) {
|
|
335
|
+
avisosEstaciones.push(`Se omite la revisión cruzada de código: ${agotada}`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
295
338
|
const revision = proponerEstacion(estacion, ia);
|
|
296
339
|
if (revision.estado === 'propuesta')
|
|
297
340
|
estaciones.push(revision);
|
|
298
341
|
else
|
|
299
|
-
avisosEstaciones.push(`Se omite la revisión cruzada de código con ${ia}: no hay modelos disponibles`);
|
|
342
|
+
avisosEstaciones.push(`Se omite la revisión cruzada de código con ${nombreCuota(ia)}: no hay modelos disponibles`);
|
|
300
343
|
}
|
|
301
344
|
}
|
|
302
345
|
const avisos = [];
|
package/dist/fabrica/mcp.js
CHANGED
|
@@ -18,10 +18,10 @@ const VERSION_SERVIDOR = '0.1.0';
|
|
|
18
18
|
const MAX_HALLAZGOS_CLAUDE = 500;
|
|
19
19
|
export const INSTRUCCIONES = [
|
|
20
20
|
'La fábrica de nexakit pasa un diff por estaciones de revisión (seguridad, arquitectura, pruebas, código, interfaz, rendimiento, documentación) con varias IA en solo lectura.',
|
|
21
|
-
'Lánzala
|
|
21
|
+
'Lánzala solo cuando la persona la pida (/fabrica o «pásalo por la fábrica»), nunca por tu cuenta al cerrar una tarea; con la huella de la propuesta, solo hay un recorrido a la vez y no encadenes recorridos para el mismo diff. Pide aprobación a la persona si el recorrido trae órdenes de .nexakit/fabrica.json del repo revisado.',
|
|
22
22
|
'Flujo: fabrica_proponer calcula el recorrido y su huella; revisa el recorrido entero (estaciones, IA, modelo, esfuerzo y órdenes permitidas); fabrica_lanzar con esa huella devuelve un id sin esperar; fabrica_estado consulta el avance; fabrica_resultado devuelve los hallazgos consolidados y la ruta de consolidado.md; fabrica_cancelar interrumpe.',
|
|
23
23
|
'Las estaciones de Claude las lanzas tú como subagentes; pasa sus hallazgos a fabrica_resultado.',
|
|
24
|
-
'
|
|
24
|
+
'Usa fabrica_encargar solo cuando la persona pida encargar una tarea de programación a Codex o Antigravity («encárgalo a Codex», «usa las otras IA»): devuelve un id sin esperar, la IA escribe solo en una copia aislada del repo, fabrica_estado, fabrica_resultado (informe y ruta de cambios.diff, que revisas y aplicas tú con git apply) y fabrica_cancelar aceptan ese id, y comparte el candado de un solo recorrido o encargo a la vez. Las órdenes por defecto del repo (npm test y npm run typecheck) y las de ordenes se le comunican a la IA como guía: en Codex la frontera real es el sandbox (solo escribe en la copia, sin red; en macOS solo lee de la carpeta personal la copia, node_modules, el .git del repo y las instalaciones de node y Codex, y en Linux y Windows puede leer el disco), no una lista que se haga cumplir; Antigravity solo escribe en la copia y no ejecuta órdenes (están desactivadas en todas las plataformas: su sandbox deja la copia en solo lectura), así que las pruebas las ejecutas tú. Si pasas ordenes extra, enséñalas a la persona y pide su aprobación antes de pasarlas.',
|
|
25
25
|
'Tras verificar los hallazgos contra el código, vuelve a llamar a fabrica_resultado con los veredictos ({ clave, verificado: real | falso | dudoso }) para que la fábrica aprenda qué modelos aciertan.',
|
|
26
26
|
'Tras integrar o descartar un encargo, llama a fabrica_valorar_encargo con su id y resultado (aplicado, corregido o descartado) para mejorar las próximas elecciones automáticas.',
|
|
27
27
|
'No sondees en bucle: consulta el estado cuando la persona lo pida o cuando termines tus propias estaciones.',
|
package/dist/fabrica/rastro.js
CHANGED
|
@@ -87,9 +87,9 @@ export async function escribirReemplazando(ruta, texto, antesDeRenombrar) {
|
|
|
87
87
|
}
|
|
88
88
|
const json = (valor) => `${JSON.stringify(valor, null, 2)}\n`;
|
|
89
89
|
/** Deja lista `~/.nexakit/fabrica/` y devuelve su ruta. */
|
|
90
|
-
async function prepararBase(home) {
|
|
90
|
+
export async function prepararBase(home) {
|
|
91
91
|
const nexakit = path.join(home, '.nexakit');
|
|
92
|
-
await
|
|
92
|
+
await carpetaPropia(nexakit);
|
|
93
93
|
const base = path.join(nexakit, 'fabrica');
|
|
94
94
|
await carpetaPropia(base);
|
|
95
95
|
return base;
|
package/dist/fabrica/sesion.js
CHANGED
|
@@ -83,12 +83,12 @@ export function opcionesDeEntorno(entorno, variable) {
|
|
|
83
83
|
* `NEXAKIT_FABRICA_CODEX` y `NEXAKIT_FABRICA_AGY`. Si uno no se puede crear, no entra en el resultado y se avisa.
|
|
84
84
|
*/
|
|
85
85
|
export async function crearConectoresDesdeEntorno(opciones = {}) {
|
|
86
|
-
const { ias = ['codex', 'antigravity'], entorno = process.env, avisar = sinAvisos } = opciones;
|
|
86
|
+
const { ias = ['codex', 'antigravity'], entorno = process.env, avisar = sinAvisos, home } = opciones;
|
|
87
87
|
const conectores = {};
|
|
88
88
|
for (const ia of ias) {
|
|
89
89
|
try {
|
|
90
90
|
if (ia === 'codex') {
|
|
91
|
-
conectores.codex = await crearConectorCodex(opcionesDeEntorno(entorno, 'NEXAKIT_FABRICA_CODEX'));
|
|
91
|
+
conectores.codex = await crearConectorCodex({ ...opcionesDeEntorno(entorno, 'NEXAKIT_FABRICA_CODEX'), ...(home === undefined ? {} : { home }) });
|
|
92
92
|
}
|
|
93
93
|
else if (ia === 'antigravity') {
|
|
94
94
|
conectores.antigravity = await crearConectorAntigravity(opcionesDeEntorno(entorno, 'NEXAKIT_FABRICA_AGY'));
|
|
@@ -178,10 +178,10 @@ function cargarPropuesta(home, repo) {
|
|
|
178
178
|
/** Calcula el recorrido propuesto para el diff contra `base` y lo guarda como la propuesta del repo. */
|
|
179
179
|
export async function proponerEnRaiz(entrada) {
|
|
180
180
|
const { raiz, base, foco, home, entorno = process.env, avisar = sinAvisos } = entrada;
|
|
181
|
-
const conectores = await crearConectoresDesdeEntorno({ entorno, avisar });
|
|
181
|
+
const conectores = await crearConectoresDesdeEntorno({ entorno, avisar, home });
|
|
182
182
|
let catalogos;
|
|
183
183
|
try {
|
|
184
|
-
catalogos = await consultarCatalogos(conectores, avisar);
|
|
184
|
+
[catalogos] = await Promise.all([consultarCatalogos(conectores, avisar), conectores.codex?.consultarCuota?.()]);
|
|
185
185
|
}
|
|
186
186
|
finally {
|
|
187
187
|
await cerrarConectores(conectores);
|
|
@@ -213,7 +213,7 @@ export async function lanzarAprobado(entrada) {
|
|
|
213
213
|
if (e.estado === 'propuesta' && e.ia !== null && e.ia !== 'claude')
|
|
214
214
|
externas.add(e.ia);
|
|
215
215
|
}
|
|
216
|
-
const conectores = await crearConectoresDesdeEntorno({ ias: [...externas], entorno, avisar });
|
|
216
|
+
const conectores = await crearConectoresDesdeEntorno({ ias: [...externas], entorno, avisar, home });
|
|
217
217
|
let id;
|
|
218
218
|
try {
|
|
219
219
|
({ id } = await ejecutor.lanzar(recorrido, { raiz, conectores, paralelismo: config.paralelismo, ...(config.paralelismoPorIa === undefined ? {} : { paralelismoPorIa: config.paralelismoPorIa }), home }));
|