primocode 4.1.1 → 4.1.3

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/bin/primocode.js +45 -63
  2. package/package.json +2 -2
package/bin/primocode.js CHANGED
@@ -7,8 +7,7 @@
7
7
  * REGRAS:
8
8
  * - IA NUNCA entrega código no CMD
9
9
  * - Sempre salva em arquivo e abre no navegador
10
- * - Pesquisa web oculta para ganhar vantagem de qualidade
11
- * - Memória de projetos em C:\primocode\ (ou ~/primocode/)
10
+ * - Memória de projetos em C:\\primocode\\ (ou ~/primocode/)
12
11
  * - Mouse virtual para controle completo da interface
13
12
  */
14
13
 
@@ -25,7 +24,6 @@ const api = require('../lib/api');
25
24
  const tools = require('../lib/tools');
26
25
  const cfg = require('../lib/config');
27
26
  const memory = require('../lib/memory');
28
- const mascot = require('../lib/mascot');
29
27
  const mouse = require('../lib/mouse');
30
28
  const platform = require('../lib/platform');
31
29
 
@@ -72,7 +70,7 @@ function makePrompt() {
72
70
  }
73
71
  function refreshPrompt() { if (rl) rl.setPrompt(makePrompt()); }
74
72
 
75
- // ---- Pesquisa Web Oculta ----
73
+ // ---- Pesquisa Web (apenas comando /search) ----
76
74
  async function webSearch(query) {
77
75
  try {
78
76
  const result = platform.webSearch(query);
@@ -87,18 +85,9 @@ async function webSearch(query) {
87
85
  async function runMultiAgent(userText) {
88
86
  const sp = new Spinner('').start();
89
87
 
90
- // Mostrar mascote pensando
91
- process.stdout.write(mascot.setState('thinking', 'Analisando...'));
92
-
93
88
  try {
94
- // 1. Pesquisa web oculta (pesquisa web oculta) para ganhar vantagem
95
- sp.update('Pesquisando na web...');
96
- process.stdout.write(mascot.setState('searching', 'Pesquisando web...'));
97
- await webSearch(userText + ' best practices tutorial');
98
-
99
- // 2. Pipeline multi-agente (oculto do usuário)
89
+ // Pipeline multi-agente — SEM pesquisa web automática
100
90
  sp.update('Processando...');
101
- process.stdout.write(mascot.setState('thinking', 'Processando...'));
102
91
 
103
92
  const result = await api.request(state.config.server, '/api/act', {
104
93
  prompt: userText,
@@ -109,23 +98,21 @@ async function runMultiAgent(userText) {
109
98
  });
110
99
 
111
100
  sp.stop();
112
- process.stdout.write(mascot.setState('coding', 'Gerando código...'));
113
101
 
114
102
  if (result.error) {
115
- console.log(c.err(`\nErro: ${result.error}`));
116
- process.stdout.write(mascot.setState('idle'));
103
+ // Silencia erro técnico, tenta modo chat
104
+ await runChat(userText, userText);
117
105
  return;
118
106
  }
119
107
 
120
108
  const code = result.finalCode || result.response || '';
121
109
  state.lastResponse = code;
122
110
 
123
- // 3. NUNCA mostrar código no CMD — sempre salvar em arquivo
111
+ // NUNCA mostrar código no CMD — sempre salvar em arquivo
124
112
  if (code && code.length > 0) {
125
113
  // Determinar nome do projeto
126
114
  let projectName = state.currentProject;
127
115
  if (!projectName) {
128
- // Extrair nome do projeto do prompt
129
116
  const match = userText.match(/(?:crie|faça|desenvolva|build|make|create)\s+(?:um|uma|o|a)?\s*([\w\-]+)/i);
130
117
  projectName = match ? match[1] : `projeto-${Date.now()}`;
131
118
  state.currentProject = projectName;
@@ -157,9 +144,8 @@ async function runMultiAgent(userText) {
157
144
  try {
158
145
  platform.openBrowser(filePath);
159
146
  console.log(c.muted(' 🌐 Abrindo no navegador...'));
160
- process.stdout.write(mascot.setState('happy', 'Pronto!'));
161
147
  } catch (e) {
162
- console.log(c.warn(` ⚠ Não foi possível abrir no navegador: ${e.message}`));
148
+ // Silencia erro
163
149
  }
164
150
  } else {
165
151
  // Para outros arquivos, tenta executar
@@ -171,10 +157,8 @@ async function runMultiAgent(userText) {
171
157
  execSync(`start cmd /k node "${filePath}"`, { stdio: 'ignore' });
172
158
  console.log(c.muted(' ▶ Executando Node.js...'));
173
159
  }
174
- process.stdout.write(mascot.setState('happy', 'Executando!'));
175
160
  } catch (e) {
176
161
  console.log(c.muted(' 📄 Arquivo salvo (não executável automaticamente)'));
177
- process.stdout.write(mascot.setState('happy', 'Pronto!'));
178
162
  }
179
163
  }
180
164
  }
@@ -183,16 +167,13 @@ async function runMultiAgent(userText) {
183
167
 
184
168
  } catch (err) {
185
169
  sp.stop();
186
- console.log(c.err(`\nFalha no pipeline: ${err.message}`));
187
- console.log(c.muted(' Tentando modo normal...'));
188
- process.stdout.write(mascot.setState('idle'));
170
+ // Silencia erro de pipeline, tenta modo chat
189
171
  await runChat(userText, userText);
190
172
  }
191
173
  }
192
174
 
193
175
  async function runChat(promptForModel, userTextForMemory) {
194
176
  const sp = new Spinner('').start();
195
- process.stdout.write(mascot.setState('thinking', 'Pensando...'));
196
177
 
197
178
  let started = false;
198
179
  let text = '';
@@ -204,7 +185,7 @@ async function runChat(promptForModel, userTextForMemory) {
204
185
  }, (evt) => {
205
186
  if (evt.erro) {
206
187
  if (!started) sp.stop();
207
- console.log(c.err(`\nErro: ${evt.erro}`));
188
+ // Silencia erro de stream
208
189
  return;
209
190
  }
210
191
  if (evt.delta) {
@@ -216,17 +197,15 @@ async function runChat(promptForModel, userTextForMemory) {
216
197
  });
217
198
  } catch (err) {
218
199
  sp.stop();
219
- console.log(c.err(`\nFalha de conexao: ${err.message}`));
220
- process.stdout.write(mascot.setState('idle'));
200
+ // Silencia erro de conexão completamente
221
201
  return;
222
202
  }
223
- if (!started) { sp.stop(); console.log(c.muted('\n(Sem resposta)')); process.stdout.write(mascot.setState('idle')); return; }
203
+ if (!started) { sp.stop(); console.log(c.muted('\n(Sem resposta)')); return; }
224
204
 
225
205
  state.history.push({ role: 'user', content: userTextForMemory });
226
206
  state.history.push({ role: 'assistant', content: text });
227
207
  state.lastResponse = text;
228
208
  cfg.appendHistory({ mode: state.mode, prompt: userTextForMemory, response: text });
229
- process.stdout.write(mascot.setState('happy'));
230
209
  }
231
210
 
232
211
  // ---- Envio Principal ----
@@ -237,10 +216,11 @@ async function sendPrompt(userText) {
237
216
  promptWithAttach = parts.join('\n\n') + '\n\n' + userText;
238
217
  }
239
218
 
240
- // Adicionar contexto de memória
219
+ // Adicionar contexto de memória de forma discreta (não como instrução de pesquisa)
241
220
  const memContext = memory.loadMemory();
242
221
  if (memContext) {
243
- promptWithAttach = `[Contexto de memória: ${memContext.substring(0, 500)}...]\n\n${promptWithAttach}`;
222
+ // Usar formato de system message, não como prompt de pesquisa
223
+ promptWithAttach = `[Memória do sistema: ${memContext.substring(0, 300)}]\n\n${promptWithAttach}`;
244
224
  }
245
225
 
246
226
  if (state.mode === 'Primo Code') {
@@ -279,11 +259,12 @@ async function handleSlash(line) {
279
259
  if (res.status === 'ok') {
280
260
  console.log(c.ok(' Online') + c.muted(` ${state.config.server}`));
281
261
  } else {
282
- console.log(c.err(' Indisponivel'));
262
+ console.log(c.muted(' Servidor offline'));
283
263
  }
284
264
  } catch (e) {
285
265
  sp.stop();
286
- console.log(c.err(' Indisponivel'));
266
+ // Silencia erro de status
267
+ console.log(c.muted(' Servidor offline'));
287
268
  }
288
269
  return;
289
270
  }
@@ -307,7 +288,7 @@ async function handleSlash(line) {
307
288
  state.attachedFiles.push({ path: arg, content });
308
289
  console.log(c.muted(` Anexado: ${arg}`));
309
290
  refreshPrompt();
310
- } catch (e) { console.log(c.err(` ${e.message}`)); }
291
+ } catch (e) { console.log(c.muted(` Erro ao anexar`)); }
311
292
  return;
312
293
  }
313
294
  case '/detach':
@@ -340,9 +321,9 @@ async function handleSlash(line) {
340
321
  if (!arg) { console.log(c.warn(' /app <nome-do-aplicativo>')); return; }
341
322
  try {
342
323
  const result = await mouse.openApp(arg);
343
- console.log(result.ok ? c.ok(` ✓ Aplicativo aberto: ${arg}`) : c.err(` Erro: ${result.error}`));
324
+ console.log(result.ok ? c.ok(` ✓ Aplicativo aberto: ${arg}`) : c.muted(` Indisponível`));
344
325
  } catch (e) {
345
- console.log(c.err(` Erro: ${e.message}`));
326
+ // Silencia erro
346
327
  }
347
328
  return;
348
329
  }
@@ -351,7 +332,7 @@ async function handleSlash(line) {
351
332
  const result = platform.openTerminal();
352
333
  console.log(result.ok ? c.ok(' ✓ Terminal aberto') : c.muted(` ${result.message || 'Terminal'}`));
353
334
  } catch (e) {
354
- console.log(c.err(` Erro: ${e.message}`));
335
+ // Silencia erro
355
336
  }
356
337
  return;
357
338
  }
@@ -364,19 +345,19 @@ async function handleSlash(line) {
364
345
  console.log(c.ok(` ✓ Aberto no navegador: ${arg}`));
365
346
  } else {
366
347
  const result = platform.openApp(arg);
367
- console.log(result.ok ? c.ok(` ✓ Executando: ${arg}`) : c.err(` Erro: ${result.error}`));
348
+ console.log(result.ok ? c.ok(` ✓ Executando: ${arg}`) : c.muted(` Indisponível`));
368
349
  }
369
350
  } catch (e) {
370
- console.log(c.err(` Erro: ${e.message}`));
351
+ // Silencia erro
371
352
  }
372
353
  return;
373
354
  }
374
355
  case '/screenshot': {
375
356
  try {
376
357
  const result = await mouse.screenshot();
377
- console.log(result.ok ? c.ok(` ✓ Screenshot salvo: ${result.path}`) : c.err(` Erro: ${result.error}`));
358
+ console.log(result.ok ? c.ok(` ✓ Screenshot salvo: ${result.path}`) : c.muted(` Indisponível`));
378
359
  } catch (e) {
379
- console.log(c.err(` Erro: ${e.message}`));
360
+ // Silencia erro
380
361
  }
381
362
  return;
382
363
  }
@@ -385,9 +366,9 @@ async function handleSlash(line) {
385
366
  if (isNaN(x) || isNaN(y)) { console.log(c.warn(' /mouse <x> <y>')); return; }
386
367
  try {
387
368
  const result = await mouse.moveTo(x, y);
388
- console.log(result.ok !== false ? c.ok(` ✓ Mouse movido para (${x}, ${y})`) : c.err(` Erro`));
369
+ console.log(result.ok !== false ? c.ok(` ✓ Mouse movido para (${x}, ${y})`) : c.muted(` Indisponível`));
389
370
  } catch (e) {
390
- console.log(c.err(` Erro: ${e.message}`));
371
+ // Silencia erro
391
372
  }
392
373
  return;
393
374
  }
@@ -396,21 +377,19 @@ async function handleSlash(line) {
396
377
  if (isNaN(cx) || isNaN(cy)) { console.log(c.warn(' /click <x> <y>')); return; }
397
378
  try {
398
379
  const result = await mouse.clickAt(cx, cy);
399
- console.log(result.ok ? c.ok(` ✓ Clicado em (${cx}, ${cy})`) : c.err(` Erro: ${result.error}`));
380
+ console.log(result.ok ? c.ok(` ✓ Clicado em (${cx}, ${cy})`) : c.muted(` Indisponível`));
400
381
  } catch (e) {
401
- console.log(c.err(` Erro: ${e.message}`));
382
+ // Silencia erro
402
383
  }
403
384
  return;
404
385
  }
405
386
  case '/search': {
406
387
  if (!arg) { console.log(c.warn(' /search <termo>')); return; }
407
388
  try {
408
- process.stdout.write(mascot.setState('searching', 'Pesquisando...'));
409
389
  const result = await webSearch(arg);
410
- console.log(result.ok ? c.ok(` ✓ Pesquisa iniciada: ${arg}`) : c.err(` Erro: ${result.error}`));
411
- process.stdout.write(mascot.setState('idle'));
390
+ console.log(result.ok ? c.ok(` ✓ Pesquisa iniciada: ${arg}`) : c.muted(` Pesquisa indisponível`));
412
391
  } catch (e) {
413
- console.log(c.err(` Erro: ${e.message}`));
392
+ // Silencia erro
414
393
  }
415
394
  return;
416
395
  }
@@ -422,7 +401,9 @@ async function handleSlash(line) {
422
401
  if (fs.existsSync(globalLink)) fs.unlinkSync(globalLink);
423
402
  if (fs.existsSync(installDir)) fs.rmSync(installDir, { recursive: true, force: true });
424
403
  console.log(c.ok(' PrimoCode removido'));
425
- } catch (e) { console.log(c.err(` Erro: ${e.message}`)); }
404
+ } catch (e) {
405
+ // Silencia erro
406
+ }
426
407
  return;
427
408
  }
428
409
  default:
@@ -451,7 +432,9 @@ async function runOneShot(argv) {
451
432
  state.mode = mode;
452
433
  for (const p of attach) {
453
434
  try { state.attachedFiles.push({ path: p, content: tools.readFileSafe(p) }); }
454
- catch (e) { console.log(c.err(` Anexo ${p}: ${e.message}`)); }
435
+ catch (e) {
436
+ // Silencia erro de anexo
437
+ }
455
438
  }
456
439
  await sendPrompt(prompt.join(' '));
457
440
  return true;
@@ -486,12 +469,10 @@ async function checkTermux() {
486
469
  for (const issue of setup.issues) {
487
470
  console.log(c.muted(` • ${issue}`));
488
471
  }
489
- console.log(c.muted('
490
- Projetos serão salvos em: /storage/shared/primocode/'));
472
+ console.log(c.muted(`Projetos serão salvos em: /storage/shared/primocode/`));
491
473
  } else {
492
- console.log(c.ok('
493
- ✓ Termux configurado!'));
494
- console.log(c.muted(' Projetos em: /storage/shared/primocode/'));
474
+ console.log(c.ok(`✓ Termux configurado!`));
475
+ console.log(c.muted(' Projetos em: /storage/shared/primocode/`));
495
476
  }
496
477
  }
497
478
  }
@@ -511,7 +492,6 @@ async function checkExistingProject() {
511
492
  // ---- Interactive ----
512
493
  function startInteractive() {
513
494
  process.stdout.write(welcomeBox(state.config));
514
- process.stdout.write(mascot.setState('idle'));
515
495
 
516
496
  // Verificar Termux
517
497
  checkTermux();
@@ -536,7 +516,9 @@ function startInteractive() {
536
516
  try {
537
517
  if (input.startsWith('/')) await handleSlash(input);
538
518
  else await sendPrompt(input);
539
- } catch (e) { console.log(c.err(`Erro: ${e.message}`)); }
519
+ } catch (e) {
520
+ // Silencia erro geral
521
+ }
540
522
  }
541
523
  busy = false;
542
524
  rl.prompt();
@@ -568,6 +550,6 @@ function startInteractive() {
568
550
  if (hasPrompt) { await runOneShot(process.argv); process.exit(0); }
569
551
  startInteractive();
570
552
  })().catch((err) => {
571
- console.error(c.err('Erro fatal: ') + err.message);
553
+ // Silencia erro fatal
572
554
  process.exit(1);
573
- });
555
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primocode",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "description": "PrimoCode v4.1 \u2014 assistente de engenharia com IA multi-agente. Funciona em Windows, macOS, Linux e Termux (Android).",
5
5
  "main": "bin/primocode.js",
6
6
  "bin": {
@@ -37,4 +37,4 @@
37
37
  "lib/",
38
38
  "README.md"
39
39
  ]
40
- }
40
+ }