@arcadialdev/arcality 2.6.3 → 2.6.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcadialdev/arcality",
3
- "version": "2.6.3",
3
+ "version": "2.6.6",
4
4
  "description": "El primer ingeniero QA Autónomo integrado al CI/CD. Creado por Arcadial.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -70,4 +70,4 @@
70
70
  "terminal-image": "^1.1.0",
71
71
  "tsx": "^4.21.0"
72
72
  }
73
- }
73
+ }
@@ -795,6 +795,17 @@ async function main() {
795
795
  _origProcessExit(code);
796
796
  };
797
797
 
798
+ // ── RESTORE RAW MODE FOR WINDOWS FIX ──
799
+ // @clack/prompts pausea stdin y desactiva raw mode al terminar un menú.
800
+ // Debemos reactivarlo aquí para que nuestro interceptor global de Ctrl+C
801
+ // siga funcionando durante toda la misión.
802
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
803
+ try {
804
+ process.stdin.setRawMode(true);
805
+ process.stdin.resume();
806
+ } catch(e) {}
807
+ }
808
+
798
809
  const cancelHandler = () => {
799
810
  sigintCount++;
800
811
  if (sigintCount > 3) {
@@ -1192,12 +1203,31 @@ async function main() {
1192
1203
  console.log(chalk.gray('\n Press Enter to return to menu...'));
1193
1204
  await new Promise(resolve => {
1194
1205
  const onKey = (key) => {
1195
- if (key === '\r' || key === '\n' || key === '\u0003') {
1206
+ const keyStr = String(key);
1207
+ if (keyStr.includes('\r') || keyStr.includes('\n') || keyStr === '\u0003') {
1196
1208
  process.stdin.off('data', onKey);
1197
- if (key === '\u0003') process.emit('SIGINT'); // Ctrl+C = salir
1209
+
1210
+ // Restaurar stdin en modo normal para @clack/prompts
1211
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
1212
+ process.stdin.setRawMode(false);
1213
+ }
1214
+ process.stdin.pause();
1215
+
1216
+ if (keyStr === '\u0003') process.emit('SIGINT'); // Ctrl+C = salir
1198
1217
  else resolve();
1199
1218
  }
1200
1219
  };
1220
+
1221
+ // ── BUGFIX: @clack/prompts llama explícitamente a process.stdin.pause()
1222
+ // al terminar cada select()/text(). En Node.js, agregar un listener 'data'
1223
+ // a un stream EXPLÍCITAMENTE pausado NO lo reactiva automáticamente.
1224
+ // Resultado: el event loop queda vacío y el proceso termina antes de que
1225
+ // el usuario pueda presionar Enter.
1226
+ // Solución: llamar resume() explícitamente antes de registrar el listener.
1227
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
1228
+ process.stdin.setRawMode(true); // raw mode para capturar Enter inmediatamente
1229
+ }
1230
+ process.stdin.resume(); // ← CRÍTICO: reactiva stdin para mantener el event loop vivo
1201
1231
  process.stdin.on('data', onKey);
1202
1232
  });
1203
1233
 
@@ -3068,8 +3068,8 @@ function captureValidationRule(errorMessage, context) {
3068
3068
  const promptKeywords = normalize(prompt);
3069
3069
  const patternKeywords = normalize(bestMatch.prompt || bestMatch.original_prompt || bestMatch.originalPrompt || bestMatch.name || "");
3070
3070
  const matches = promptKeywords.filter((kw) => patternKeywords.some((pkw) => pkw.includes(kw) || kw.includes(pkw))).length;
3071
- const matchRatio = matches / Math.max(promptKeywords.length, 1);
3072
- if (matchRatio >= 0.85) {
3071
+ const isVectorMatch = true;
3072
+ if (isVectorMatch) {
3073
3073
  console.log(`>>ARCALITY_STATUS>> \u{1F9E0} Memoria Colectiva detectada (id: ${bestMatch.id}). Descargando a memoria local...`);
3074
3074
  reusedPatternId = bestMatch.id || "unknown";
3075
3075
  let patternJsonObj = {};
@@ -3119,7 +3119,7 @@ function captureValidationRule(errorMessage, context) {
3119
3119
  } catch (err) {
3120
3120
  console.warn(`Error al sincronizar memoria local: ${err}`);
3121
3121
  }
3122
- } else if (matchRatio >= 0.5) {
3122
+ } else if (!isVectorMatch) {
3123
3123
  let patternJsonObj = {};
3124
3124
  try {
3125
3125
  patternJsonObj = typeof bestMatch.pattern_json === "string" ? JSON.parse(bestMatch.pattern_json) : bestMatch.pattern_json || bestMatch.patternJson || {};
@@ -3131,7 +3131,7 @@ function captureValidationRule(errorMessage, context) {
3131
3131
  patternContext = `Existe un patr\xF3n similar previamente aprobado que logr\xF3 el \xE9xito. \xDAsalo como referencia para tu estrategia:
3132
3132
  ${readableHistory}`;
3133
3133
  } else {
3134
- console.log(`>>ARCALITY_STATUS>> \u2139\uFE0F Patr\xF3n de BD descartado por baja similitud (${matchRatio.toFixed(2)}).`);
3134
+ console.log(`>>ARCALITY_STATUS>> \u2139\uFE0F Patr\xF3n de BD descartado por baja similitud.`);
3135
3135
  }
3136
3136
  } else {
3137
3137
  console.log(`>>ARCALITY_STATUS>> \u2139\uFE0F No se encontraron patrones previos (no_match: true).`);
@@ -3949,13 +3949,14 @@ Acci\xF3n bloqueada: Bucle de tipo ${loopType} sobre los elementos ${Array.from(
3949
3949
  if (aiMarkedSuccess) {
3950
3950
  hasCriticalError = false;
3951
3951
  await persistCollectiveMemory();
3952
- if (!usedDirectReuse && stepsData.length > 0) {
3952
+ const finalUsedDirectReuse = reusedPatternId !== null && guideIdx !== 999999;
3953
+ if (!finalUsedDirectReuse && stepsData.length > 0) {
3953
3954
  const normalizedPrompt = prompt.toLowerCase().trim();
3954
3955
  const patternKey = crypto2.createHash("sha256").update(normalizedPrompt).digest("hex");
3955
3956
  if (!hasCriticalError) {
3956
- const isDuplicate = patternContext !== "" || usedDirectReuse;
3957
+ const isDuplicate = finalUsedDirectReuse;
3957
3958
  if (isDuplicate) {
3958
- console.log(`>>ARCALITY_STATUS>> \u2139\uFE0F No se guardar\xE1 el patr\xF3n. duplicate_skipped: true (ya existe uno similar o se us\xF3 directamente)`);
3959
+ console.log(`>>ARCALITY_STATUS>> \u2139\uFE0F No se guardar\xE1 el patr\xF3n. duplicate_skipped: true (se us\xF3 directamente con \xE9xito)`);
3959
3960
  }
3960
3961
  const stepsToSave = stepsData.length > 0 ? stepsData : stepsDataBackup;
3961
3962
  const hasCompleteSteps = stepsToSave.length >= stepsDataBackup.length;