primocode 4.3.0 → 4.3.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/bin/primocode.js +23 -5
- package/package.json +1 -1
package/bin/primocode.js
CHANGED
|
@@ -83,7 +83,7 @@ async function webSearch(query) {
|
|
|
83
83
|
|
|
84
84
|
// ---- Pipeline Multi-Agente Oculto ----
|
|
85
85
|
async function runMultiAgent(userText) {
|
|
86
|
-
console.log(c.muted(' 🚀 Gerando código...
|
|
86
|
+
console.log(c.muted(' 🚀 Gerando código...'));
|
|
87
87
|
const sp = new Spinner('').start();
|
|
88
88
|
|
|
89
89
|
try {
|
|
@@ -201,7 +201,7 @@ async function runChat(promptForModel, userTextForMemory) {
|
|
|
201
201
|
// Silencia erro de conexão completamente
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
if (!started) { sp.stop(); console.log(c.muted('\n
|
|
204
|
+
if (!started) { sp.stop(); console.log(c.muted('\n ⚡ Resposta rápida indisponível. Use /mode Chat para conversar.')); return; }
|
|
205
205
|
|
|
206
206
|
state.history.push({ role: 'user', content: userTextForMemory });
|
|
207
207
|
state.history.push({ role: 'assistant', content: text });
|
|
@@ -209,6 +209,20 @@ async function runChat(promptForModel, userTextForMemory) {
|
|
|
209
209
|
cfg.appendHistory({ mode: state.mode, prompt: userTextForMemory, response: text });
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
// ---- Detectar se é pedido de código ----
|
|
213
|
+
function isCodeRequest(text) {
|
|
214
|
+
const codeKeywords = [
|
|
215
|
+
'crie', 'criar', 'faça', 'fazer', 'desenvolva', 'desenvolver',
|
|
216
|
+
'build', 'make', 'create', 'generate', 'code', 'codigo',
|
|
217
|
+
'site', 'web', 'app', 'aplicativo', 'programa', 'script',
|
|
218
|
+
'calculadora', 'jogo', 'game', 'pagina', 'website',
|
|
219
|
+
'html', 'css', 'js', 'python', 'react', 'vue', 'angular',
|
|
220
|
+
'api', 'backend', 'frontend', 'database', 'banco de dados'
|
|
221
|
+
];
|
|
222
|
+
const lower = text.toLowerCase();
|
|
223
|
+
return codeKeywords.some(kw => lower.includes(kw));
|
|
224
|
+
}
|
|
225
|
+
|
|
212
226
|
// ---- Envio Principal ----
|
|
213
227
|
async function sendPrompt(userText) {
|
|
214
228
|
let promptWithAttach = userText;
|
|
@@ -217,15 +231,19 @@ async function sendPrompt(userText) {
|
|
|
217
231
|
promptWithAttach = parts.join('\n\n') + '\n\n' + userText;
|
|
218
232
|
}
|
|
219
233
|
|
|
220
|
-
// Adicionar contexto de memória
|
|
234
|
+
// Adicionar contexto de memória
|
|
221
235
|
const memContext = memory.loadMemory();
|
|
222
236
|
if (memContext) {
|
|
223
|
-
// Usar formato de system message, não como prompt de pesquisa
|
|
224
237
|
promptWithAttach = `[Memória do sistema: ${memContext.substring(0, 300)}]\n\n${promptWithAttach}`;
|
|
225
238
|
}
|
|
226
239
|
|
|
227
240
|
if (state.mode === 'Primo Code') {
|
|
228
|
-
|
|
241
|
+
// Se for conversa simples (oi, tudo bem, etc.), usar Chat direto
|
|
242
|
+
if (!isCodeRequest(userText)) {
|
|
243
|
+
await runChat(promptWithAttach, userText);
|
|
244
|
+
} else {
|
|
245
|
+
await runMultiAgent(promptWithAttach);
|
|
246
|
+
}
|
|
229
247
|
} else {
|
|
230
248
|
await runChat(promptWithAttach, userText);
|
|
231
249
|
}
|
package/package.json
CHANGED