bimmo-cli 2.1.0 → 2.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/interface.js +33 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimmo-cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "🌿 Plataforma de IA universal com Modo Normal, Agentes e Swarms. Suporte a Diffs coloridos, Auto-Edit (Auto/Manual) e Contexto Inteligente.",
5
5
  "bin": {
6
6
  "bimmo": "bin/bimmo"
package/src/interface.js CHANGED
@@ -8,6 +8,7 @@ import fs from 'fs';
8
8
  import path from 'path';
9
9
  import mime from 'mime-types';
10
10
  import readline from 'readline';
11
+ import { fileURLToPath } from 'url';
11
12
 
12
13
  import { getConfig, configure, updateActiveModel, switchProfile } from './config.js';
13
14
  import { createProvider } from './providers/factory.js';
@@ -15,6 +16,11 @@ import { getProjectContext } from './project-context.js';
15
16
  import { SwarmOrchestrator } from './orchestrator.js';
16
17
  import { editState } from './agent.js';
17
18
 
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = path.dirname(__filename);
21
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'));
22
+ const version = pkg.version;
23
+
18
24
  marked.use(new TerminalRenderer({
19
25
  heading: chalk.hex('#c084fc').bold,
20
26
  code: chalk.hex('#00ff9d'),
@@ -97,7 +103,7 @@ async function processInput(input) {
97
103
  }
98
104
 
99
105
  function getModeStyle() {
100
- const personaLabel = activePersona ? `[${activePersona.toUpperCase()}] ` : '';
106
+ const personaLabel = activePersona ? `[${activePersona.toUpperCase()}]` : '';
101
107
  switch (currentMode) {
102
108
  case 'plan': return yellow.bold(`${personaLabel}[PLAN] `);
103
109
  case 'edit':
@@ -137,7 +143,7 @@ export async function startInteractive() {
137
143
 
138
144
  console.clear();
139
145
  console.log(lavender(figlet.textSync('bimmo')));
140
- console.log(lavender('─'.repeat(60)));
146
+ console.log(lavender(` v${version} `.padStart(60, '─')));
141
147
  console.log(green(` Perfil: ${bold(config.activeProfile || 'Padrão')} • IA: ${bold(config.provider.toUpperCase())}`));
142
148
  console.log(green(` Modelo: ${bold(config.model)}`));
143
149
  console.log(gray(' /chat | /plan | /edit | /swarm | /use [agente] | /help'));
@@ -145,17 +151,19 @@ export async function startInteractive() {
145
151
 
146
152
  console.log(lavender('👋 Olá! Estou pronto. No que posso ajudar?\n'));
147
153
 
148
- process.on('SIGINT', () => {
154
+ const globalSigIntHandler = () => {
149
155
  exitCounter++;
150
156
  if (exitCounter === 1) {
151
- console.log(gray('\n(Pressione Ctrl+C novamente para sair)'));
157
+ process.stdout.write(gray('\n(Pressione Ctrl+C novamente para sair)\n'));
152
158
  if (exitTimer) clearTimeout(exitTimer);
153
159
  exitTimer = setTimeout(() => { exitCounter = 0; }, 2000);
154
160
  } else {
155
- console.log(lavender('\n👋 BIMMO encerrando sessão. Até logo!\n'));
161
+ process.stdout.write(lavender('\n👋 BIMMO encerrando sessão. Até logo!\n'));
156
162
  process.exit(0);
157
163
  }
158
- });
164
+ };
165
+
166
+ process.on('SIGINT', globalSigIntHandler);
159
167
 
160
168
  readline.emitKeypressEvents(process.stdin);
161
169
  if (process.stdin.isTTY) process.stdin.setRawMode(true);
@@ -178,6 +186,9 @@ export async function startInteractive() {
178
186
  continue;
179
187
  }
180
188
 
189
+ // Mostra o diretório atual logo abaixo do input do usuário
190
+ console.log(gray(` 📁 ${process.cwd()}`));
191
+
181
192
  const rawInput = input.trim();
182
193
  const cmd = rawInput.toLowerCase();
183
194
 
@@ -335,7 +346,9 @@ Gerenciamento:
335
346
 
336
347
  const controller = new AbortController();
337
348
  const localInterruptHandler = () => controller.abort();
338
- process.removeAllListeners('SIGINT');
349
+
350
+ // Switch de SIGINT para modo processamento
351
+ process.removeListener('SIGINT', globalSigIntHandler);
339
352
  process.on('SIGINT', localInterruptHandler);
340
353
 
341
354
  let modeInstr = "";
@@ -356,33 +369,31 @@ Gerenciamento:
356
369
  try {
357
370
  let responseText = await provider.sendMessage(messages, { signal: controller.signal });
358
371
  spinner.stop();
359
- const cleanedText = responseText.replace(/<\/?[^>]+(>|$)/g, "");
372
+
373
+ // LIMPEZA AGRESSIVA DE HTML
374
+ const cleanedText = responseText
375
+ .replace(/<br\s*\/?>/gi, '\n') // Converte <br> em newline real
376
+ .replace(/<p>/gi, '') // Remove tags <p> iniciais
377
+ .replace(/<\/p>/gi, '\n\n') // Converte </p> em double newline
378
+ .replace(/<\/?[^>]+(>|$)/g, ""); // Remove QUALQUER outra tag residual
379
+
360
380
  messages.push({ role: 'assistant', content: responseText });
361
- console.log('\n' + lavender('bimmo') + getModeStyle());
381
+ console.log('\n' + lavender('bimmo ') + getModeStyle());
362
382
  console.log(lavender('─'.repeat(50)));
363
- console.log(marked(cleanedText));
383
+ console.log(marked(cleanedText.trim()));
364
384
  console.log(gray('─'.repeat(50)) + '\n');
365
385
  } catch (err) {
366
386
  spinner.stop();
367
387
  if (controller.signal.aborted || err.name === 'AbortError') {
368
- console.log(yellow('\n\n⚠️ Interrompido.\n'));
388
+ console.log(yellow('\n\n⚠️ Operação interrompida pelo usuário.\n'));
369
389
  messages.pop();
370
390
  } else {
371
391
  console.error(chalk.red('\n✖ Erro:') + ' ' + err.message + '\n');
372
392
  }
373
393
  } finally {
394
+ // Restaura o modo global de saída
374
395
  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
- });
396
+ process.on('SIGINT', globalSigIntHandler);
386
397
  }
387
398
  }
388
399
  }