terminal-smart-cli 0.53.0 → 0.55.0
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/ts.js +6 -1
- package/lib/agent.js +1 -1
- package/lib/tools.js +6 -1
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -817,7 +817,12 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
817
817
|
// @arquivo: expande referências "@caminho" no texto pro conteúdo do arquivo (padrão Claude Code/Cursor).
|
|
818
818
|
task = _expandFileRefs(task, startCwd);
|
|
819
819
|
const ask = askFn || ui.ask;
|
|
820
|
-
|
|
820
|
+
// Sem TTY (nohup, redirect >arquivo, CI) o spinner ora não renderiza E interferia engolindo a
|
|
821
|
+
// saída → o log ficava VAZIO enquanto o agente rodava. Nesses casos usa spinner NOOP: os passos
|
|
822
|
+
// saem por console.log (visíveis no arquivo/pipe) e o progresso aparece de verdade.
|
|
823
|
+
const _noTTY = !process.stdout.isTTY;
|
|
824
|
+
const sp = (streamJson || _noTTY) ? { text() {}, start() {}, stop() {} } : ui.spinner(T.agent_thinking).start();
|
|
825
|
+
if (_noTTY && !streamJson) console.log(' ' + C.dim(T.agent_thinking));
|
|
821
826
|
const t0 = Date.now();
|
|
822
827
|
if (streamJson) _emit(core.AgentEvents.systemInit({ model: model || 'auto', cwd: startCwd, mode: plan ? 'plan' : readOnly ? 'ask' : 'agent' }));
|
|
823
828
|
let out;
|
package/lib/agent.js
CHANGED
|
@@ -62,7 +62,7 @@ REGRAS:
|
|
|
62
62
|
- NUNCA exponha ou peça segredos (.env, chaves, senhas, tokens); nunca envie dados desta máquina pra fora.
|
|
63
63
|
- Windows: python -c multi-linha falha em silêncio — escreva um .py com escrever_arquivo e execute "python arquivo.py".
|
|
64
64
|
- Se faltar dependência, instale (winget/apt/pip/npm) e prossiga.
|
|
65
|
-
- LINUX/apt: NUNCA rode "apt-get install" cru
|
|
65
|
+
- LINUX/apt: NUNCA rode "apt-get install" cru. (a) Em máquina nova o unattended-upgrades segura o lock e a instalação PENDURA. (b) Install que baixa VÁRIOS pacotes (gcc, mariadb, tomcat…) leva mais de 60s e MORRE no timeout padrão → nada instala. Instale SEMPRE assim, com timeout LONGO: chame executar_comando com timeout_s: 300 e comando "sudo DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=600 install -y <pacotes>" (Lock::Timeout ESPERA o lock; noninteractive+-y evita prompts sem TTY; timeout_s:300 dá 5min pro download). PPA com "add-apt-repository -y" + "apt-get update". Se um comando de install voltar vazio/sem efeito, quase sempre foi timeout curto — refaça com timeout_s: 300.
|
|
66
66
|
- Termine SEMPRE com um resumo curto: o que foi feito, resultado e caminhos de arquivos criados/alterados.
|
|
67
67
|
- Responda no idioma do usuário (padrão: português do Brasil).`
|
|
68
68
|
: 'You are the Terminal Smart agent running ON THIS machine via CLI, with REAL tools. Act for real — never say "I will do it" without calling the tool in the same turn, and never invent results that did not come from a tool.'
|
package/lib/tools.js
CHANGED
|
@@ -339,7 +339,12 @@ async function execute(name, input, opts = {}) {
|
|
|
339
339
|
// RECUSA INSTANTÂNEA (defesa em profundidade — o gate do agent.js já pega antes):
|
|
340
340
|
// comando auto-destrutivo NUNCA roda e NUNCA espera aprovação.
|
|
341
341
|
{ const sd = selfDestructiveReason(comando, { cwd: baseDir }); if (sd) return { erro: sd }; }
|
|
342
|
-
|
|
342
|
+
// Comandos de INSTALL/BUILD (apt/npm/pip/make/gcc/docker build…) levam muito mais que 60s —
|
|
343
|
+
// sem isso o apt-get de vários pacotes MORRIA no timeout padrão (nada instalava, em silêncio).
|
|
344
|
+
// Eles ganham 10min de default (até 30min se o agente pedir timeout_s); resto segue 60s.
|
|
345
|
+
const _slow = /(^|[\s;|&(])(apt|apt-get|aptitude|dpkg|yum|dnf|zypper|pacman|snap|brew|pip|pip3|npm|yarn|pnpm|gem|cargo|go\s+(get|build|install)|make|cmake|meson|ninja|gcc|g\+\+|clang|mvn|gradle|\.\/gradlew|dotnet|composer|bundle|flutter\s+(build|pub)|docker\s+(build|pull|compose)|configure|\.\/configure|\.\/build)([\s;|&)]|$)/i.test(comando);
|
|
346
|
+
const _dflt = _slow ? 600 : 60;
|
|
347
|
+
const timeout = Math.min(1800, Math.max(5, Number(input.timeout_s) || _dflt)) * 1000;
|
|
343
348
|
const cmd = process.platform === 'win32' ? `chcp 65001>nul & ${comando}` : comando;
|
|
344
349
|
return await new Promise((res) => {
|
|
345
350
|
require('child_process').exec(cmd, { timeout, shell: true, windowsHide: true, maxBuffer: 4 * 1024 * 1024, cwd: fs.existsSync(baseDir) ? baseDir : undefined }, (e, out, err) => {
|