primocode 1.0.0 → 1.0.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/README.md CHANGED
@@ -10,18 +10,39 @@ Assistente de engenharia com inteligencia artificial.
10
10
 
11
11
  ## Instalacao
12
12
 
13
+ ### Requisito
14
+
15
+ Node.js 18.17+ (instalado automaticamente nos scripts abaixo)
16
+
17
+ ### Windows
18
+
19
+ ```powershell
20
+ # PowerShell (como Administrador)
21
+ iwr -useb https://raw.githubusercontent.com/ConectaPrimoAI/primocode/main/install.cmd | iex
22
+
23
+ # Ou via npm (Node.js precisa estar instalado)
24
+ npm install -g primocode
25
+ ```
26
+
27
+ ### Linux / macOS / WSL
28
+
13
29
  ```bash
30
+ # Script automatico
31
+ curl -fsSL https://raw.githubusercontent.com/ConectaPrimoAI/primocode/main/install.sh | bash
32
+
33
+ # Ou via npm
14
34
  npm install -g primocode
15
35
  ```
16
36
 
17
- Ou via script:
37
+ ### Termux (Android)
18
38
 
19
39
  ```bash
20
- # Windows
21
- iwr -useb https://gist.githubusercontent.com/ConectaPrimoAI/primocode-install/raw/install.cmd | iex
40
+ # Script especifico para Termux
41
+ curl -fsSL https://raw.githubusercontent.com/ConectaPrimoAI/primocode/main/termux-install.sh | bash
22
42
 
23
- # Linux / macOS / WSL / Termux
24
- curl -fsSL https://gist.githubusercontent.com/ConectaPrimoAI/primocode-install/raw/install.sh | bash
43
+ # Ou manualmente
44
+ pkg install -y nodejs git
45
+ npm install -g primocode
25
46
  ```
26
47
 
27
48
  ## Uso
@@ -54,9 +75,13 @@ export PRIMOCODE_SERVER=https://seu-servidor.com
54
75
  export PRIMOCODE_MODEL=main
55
76
  ```
56
77
 
57
- ## Requisitos
78
+ ## Mobile (Termux)
58
79
 
59
- - Node.js 18.17+
80
+ PrimoCode funciona perfeitamente no Termux:
81
+ - Instale o Termux da F-Droid (versao atualizada)
82
+ - Execute o script de instalacao acima
83
+ - Use todos os modos: Conecta Primo AI, Chat e JARVIS
84
+ - JARVIS abre no navegador do dispositivo
60
85
 
61
86
  ---
62
87
 
package/bin/primocode.js CHANGED
@@ -18,6 +18,9 @@ const { c, welcomeBox, Spinner } = require('../lib/ui');
18
18
  const api = require('../lib/api');
19
19
  const tools = require('../lib/tools');
20
20
  const cfg = require('../lib/config');
21
+
22
+ // Garante modelo correto baseado no modo atual
23
+ function getModel() { return cfg.resolveModel(state.mode); }
21
24
  const { runAct } = require('../lib/act');
22
25
 
23
26
  // ---- Estado ----
@@ -66,7 +69,7 @@ async function sendPrompt(userText) {
66
69
  if (state.mode === 'Conecta Primo AI') {
67
70
  const r = await runAct(promptWithAttach, {
68
71
  server: state.config.server,
69
- model: state.config.model,
72
+ model: getModel(),
70
73
  history: state.history,
71
74
  });
72
75
  state.history.push({ role: 'user', content: userText });
@@ -90,7 +93,7 @@ async function runChat(promptForModel, userTextForMemory) {
90
93
  await api.requestStream(state.config.server, '/api/normal/stream', {
91
94
  prompt: promptForModel,
92
95
  history: state.history.slice(-20),
93
- model: state.config.model,
96
+ model: getModel(),
94
97
  }, (evt) => {
95
98
  if (evt.erro) {
96
99
  if (!started) sp.stop();
@@ -166,6 +169,7 @@ async function handleSlash(line) {
166
169
  }
167
170
  if (!valid.includes(target)) { console.log(c.warn(' /mode Conecta Primo AI | Chat | JARVIS')); return; }
168
171
  state.mode = target;
172
+ state.config.model = getModel();
169
173
  console.log(c.muted(` Modo: ${target}`));
170
174
  refreshPrompt();
171
175
  return;
@@ -263,7 +267,7 @@ async function handleSlash(line) {
263
267
  if (!arg) { console.log(c.warn(' /act <tarefa>')); return; }
264
268
  const r = await runAct(arg, {
265
269
  server: state.config.server,
266
- model: state.config.model,
270
+ model: getModel(),
267
271
  history: state.history,
268
272
  });
269
273
  state.history.push({ role: 'user', content: arg });
package/lib/config.js CHANGED
@@ -15,13 +15,20 @@ function ensureDir() {
15
15
  try { fs.mkdirSync(CONFIG_DIR, { recursive: true }); } catch {}
16
16
  }
17
17
 
18
- // Mapeamento de nomes de produto para modelos do servidor
18
+ // Mapeamento de modos para modelos do servidor
19
19
  const MODEL_MAP = {
20
20
  'Conecta Primo AI': 'main',
21
21
  'Chat': 'fast',
22
22
  'JARVIS': 'main',
23
+ 'primocode': 'main',
24
+ 'chat': 'fast',
23
25
  };
24
26
 
27
+ // Resolve o modelo correto baseado no modo
28
+ function resolveModel(mode) {
29
+ return MODEL_MAP[mode] || MODEL_MAP['Conecta Primo AI'];
30
+ }
31
+
25
32
  function loadConfig() {
26
33
  ensureDir();
27
34
  let file = {};
@@ -30,11 +37,12 @@ function loadConfig() {
30
37
  } catch { file = {}; }
31
38
 
32
39
  const mode = process.env.PRIMOCODE_MODE || file.mode || 'Conecta Primo AI';
33
- const modelKey = MODEL_MAP[mode] || 'main';
40
+ // Modelo SEMPRE derivado do modo — nunca usa file.model diretamente
41
+ const model = resolveModel(mode);
34
42
 
35
43
  return {
36
44
  server: process.env.PRIMOCODE_SERVER || file.server || 'https://primocode-server.onrender.com',
37
- model: process.env.PRIMOCODE_MODEL || file.model || modelKey,
45
+ model: model,
38
46
  mode: mode,
39
47
  autoApply: file.autoApply === true,
40
48
  _file: file,
@@ -45,6 +53,10 @@ function saveConfig(partial) {
45
53
  ensureDir();
46
54
  const cur = (() => { try { return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); } catch { return {}; } })();
47
55
  const next = { ...cur, ...partial };
56
+ // Se salvou um modo novo, atualiza o modelo tambem
57
+ if (partial.mode && MODEL_MAP[partial.mode]) {
58
+ next.model = MODEL_MAP[partial.mode];
59
+ }
48
60
  fs.writeFileSync(CONFIG_FILE, JSON.stringify(next, null, 2), 'utf8');
49
61
  return next;
50
62
  }
@@ -56,4 +68,4 @@ function appendHistory(entry) {
56
68
  } catch {}
57
69
  }
58
70
 
59
- module.exports = { loadConfig, saveConfig, appendHistory, CONFIG_DIR, CONFIG_FILE, HISTORY_FILE, MODEL_MAP };
71
+ module.exports = { loadConfig, saveConfig, appendHistory, resolveModel, CONFIG_DIR, CONFIG_FILE, HISTORY_FILE, MODEL_MAP };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "primocode",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "PrimoCode — assistente de engenharia com IA. Conecta Primo AI para engenharia completa, Chat para conversa direta, JARVIS para voz e visao.",
5
5
  "main": "bin/primocode.js",
6
6
  "bin": {
7
- "primocode": "./bin/primocode.js"
7
+ "primocode": "bin/primocode.js"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node bin/primocode.js"
@@ -23,7 +23,6 @@
23
23
  "url": "https://github.com/ConectaPrimoAI/primocode/issues"
24
24
  },
25
25
  "homepage": "https://github.com/ConectaPrimoAI/primocode#readme",
26
- "dependencies": {},
27
26
  "files": [
28
27
  "bin/",
29
28
  "lib/",