bimmo-cli 2.1.0 → 2.1.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/package.json +1 -1
- package/src/interface.js +23 -21
package/package.json
CHANGED
package/src/interface.js
CHANGED
|
@@ -97,7 +97,7 @@ async function processInput(input) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function getModeStyle() {
|
|
100
|
-
const personaLabel = activePersona ? `[${activePersona.toUpperCase()}]
|
|
100
|
+
const personaLabel = activePersona ? `[${activePersona.toUpperCase()}]` : '';
|
|
101
101
|
switch (currentMode) {
|
|
102
102
|
case 'plan': return yellow.bold(`${personaLabel}[PLAN] `);
|
|
103
103
|
case 'edit':
|
|
@@ -145,17 +145,19 @@ export async function startInteractive() {
|
|
|
145
145
|
|
|
146
146
|
console.log(lavender('👋 Olá! Estou pronto. No que posso ajudar?\n'));
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
const globalSigIntHandler = () => {
|
|
149
149
|
exitCounter++;
|
|
150
150
|
if (exitCounter === 1) {
|
|
151
|
-
|
|
151
|
+
process.stdout.write(gray('\n(Pressione Ctrl+C novamente para sair)\n'));
|
|
152
152
|
if (exitTimer) clearTimeout(exitTimer);
|
|
153
153
|
exitTimer = setTimeout(() => { exitCounter = 0; }, 2000);
|
|
154
154
|
} else {
|
|
155
|
-
|
|
155
|
+
process.stdout.write(lavender('\n👋 BIMMO encerrando sessão. Até logo!\n'));
|
|
156
156
|
process.exit(0);
|
|
157
157
|
}
|
|
158
|
-
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
process.on('SIGINT', globalSigIntHandler);
|
|
159
161
|
|
|
160
162
|
readline.emitKeypressEvents(process.stdin);
|
|
161
163
|
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
@@ -335,7 +337,9 @@ Gerenciamento:
|
|
|
335
337
|
|
|
336
338
|
const controller = new AbortController();
|
|
337
339
|
const localInterruptHandler = () => controller.abort();
|
|
338
|
-
|
|
340
|
+
|
|
341
|
+
// Switch de SIGINT para modo processamento
|
|
342
|
+
process.removeListener('SIGINT', globalSigIntHandler);
|
|
339
343
|
process.on('SIGINT', localInterruptHandler);
|
|
340
344
|
|
|
341
345
|
let modeInstr = "";
|
|
@@ -356,33 +360,31 @@ Gerenciamento:
|
|
|
356
360
|
try {
|
|
357
361
|
let responseText = await provider.sendMessage(messages, { signal: controller.signal });
|
|
358
362
|
spinner.stop();
|
|
359
|
-
|
|
363
|
+
|
|
364
|
+
// LIMPEZA AGRESSIVA DE HTML
|
|
365
|
+
const cleanedText = responseText
|
|
366
|
+
.replace(/<br\s*\/?>/gi, '\n') // Converte <br> em newline real
|
|
367
|
+
.replace(/<p>/gi, '') // Remove tags <p> iniciais
|
|
368
|
+
.replace(/<\/p>/gi, '\n\n') // Converte </p> em double newline
|
|
369
|
+
.replace(/<\/?[^>]+(>|$)/g, ""); // Remove QUALQUER outra tag residual
|
|
370
|
+
|
|
360
371
|
messages.push({ role: 'assistant', content: responseText });
|
|
361
|
-
console.log('\n' + lavender('bimmo') + getModeStyle());
|
|
372
|
+
console.log('\n' + lavender('bimmo ') + getModeStyle());
|
|
362
373
|
console.log(lavender('─'.repeat(50)));
|
|
363
|
-
console.log(marked(cleanedText));
|
|
374
|
+
console.log(marked(cleanedText.trim()));
|
|
364
375
|
console.log(gray('─'.repeat(50)) + '\n');
|
|
365
376
|
} catch (err) {
|
|
366
377
|
spinner.stop();
|
|
367
378
|
if (controller.signal.aborted || err.name === 'AbortError') {
|
|
368
|
-
console.log(yellow('\n\n⚠️
|
|
379
|
+
console.log(yellow('\n\n⚠️ Operação interrompida pelo usuário.\n'));
|
|
369
380
|
messages.pop();
|
|
370
381
|
} else {
|
|
371
382
|
console.error(chalk.red('\n✖ Erro:') + ' ' + err.message + '\n');
|
|
372
383
|
}
|
|
373
384
|
} finally {
|
|
385
|
+
// Restaura o modo global de saída
|
|
374
386
|
process.removeListener('SIGINT', localInterruptHandler);
|
|
375
|
-
process.on('SIGINT',
|
|
376
|
-
exitCounter++;
|
|
377
|
-
if (exitCounter === 1) {
|
|
378
|
-
console.log(gray('\n(Pressione Ctrl+C novamente para sair)'));
|
|
379
|
-
if (exitTimer) clearTimeout(exitTimer);
|
|
380
|
-
exitTimer = setTimeout(() => { exitCounter = 0; }, 2000);
|
|
381
|
-
} else {
|
|
382
|
-
console.log(lavender('\n👋 BIMMO encerrando sessão. Até logo!\n'));
|
|
383
|
-
process.exit(0);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
387
|
+
process.on('SIGINT', globalSigIntHandler);
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
390
|
}
|