terminal-smart-cli 0.84.0 → 0.86.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 +1 -1
- package/lib/agent.js +2 -0
- package/lib/i18n.js +2 -2
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -947,7 +947,7 @@ async function agentCmd(words, { askFn, cwd: cwdIn = null, onCwd = null } = {})
|
|
|
947
947
|
if (onCwd && !_wt && effCwd !== startCwd) onCwd(effCwd);
|
|
948
948
|
const persistCwd = _wt ? _wt.base : effCwd;
|
|
949
949
|
try { _fs.mkdirSync(_p.dirname(sessFile), { recursive: true }); _fs.writeFileSync(sessFile, JSON.stringify({ cwd: persistCwd, at: new Date().toISOString(), messages: (out.messages || []).slice(-60) })); } catch (_) {}
|
|
950
|
-
const secs = (
|
|
950
|
+
const secs = _fmtTime(Date.now() - t0); // tempo total já em min+seg (ex: 12m44s), não segundos crus
|
|
951
951
|
// WORKTREE: commita o que mudou e prepara o resumo (merge/descarte).
|
|
952
952
|
const _wtInfo = _wt ? _worktreeFinish(_wt) : null;
|
|
953
953
|
const _printWt = () => {
|
package/lib/agent.js
CHANGED
|
@@ -63,6 +63,7 @@ REGRAS:
|
|
|
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
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
|
+
- SUBIR DAEMON/SERVIÇO em background numa VPS (via executar_remoto): NUNCA rode o binário direto nem use só "nohup cmd &" — o canal SSH fica ESPERANDO o processo (que não termina, é um serviço) e dá TIMEOUT; aí você acha que travou e REPETE (loop). Use SEMPRE este padrão, que desconecta o processo do SSH e RETORNA na hora: "setsid nohup ./daemon args >log 2>&1 </dev/null & echo iniciado" (o setsid + redirecionar TODOS os fds, INCLUSIVE stdin com </dev/null, é o que solta o canal). Depois confirme que subiu com pgrep/ss numa chamada SEPARADA. Se mesmo assim o comando de start der timeout, o daemon provavelmente está falhando na inicialização (rode-o em FOREGROUND com timeout curto pra ver o erro real e conserte) — NÃO repita o mesmo start.
|
|
66
67
|
- FONTE AUTÊNTICA antes de improvisar: antes de GERAR do zero um arquivo estruturado (config, schema SQL, .conf, dados, manifesto), PROCURE se já existe a versão real — no projeto atual, no pack/instalação de referência que o usuário citou, ou numa instalação funcionante. Se existir, USE-A (copie/adapte o mínimo). A versão inventada de memória quase sempre sai sutilmente errada/incompleta (falta uma linha, uma procedure, um valor). Só improvise se comprovadamente não existir — e nesse caso AVISE que é uma reconstrução (pode ter erro) e peça pra validar.
|
|
67
68
|
- PRIVILÉGIO MÍNIMO em infra: pra dar acesso de uma aplicação a um serviço (banco, broker), crie uma CREDENCIAL DEDICADA com o mínimo de permissão (ex: CREATE USER 'app' + GRANT só no schema necessário) e aponte a app pra ela. NUNCA altere a autenticação/config GLOBAL existente (root/admin) só pra uma app conectar — isso afeta TUDO que já usa aquele acesso (backups, outros serviços, seu próprio acesso). Se precisar MESMO mudar algo global, AVISE explicitamente o que mais será afetado e por quê.
|
|
68
69
|
- NUNCA peça segredo ao usuário: jamais peça senha/chave/token/credencial no chat. Se uma operação remota (ssh/scp) falhar por autenticação, REUSE a conexão/chave que JÁ funcionou nesta sessão (mesmo host/user/chave — não reconstrua o comando do zero esquecendo o -i da chave). Se ainda assim não conectar, peça pro usuário EXECUTAR a ação — nunca entregar o segredo.
|
|
@@ -87,6 +88,7 @@ RULES:
|
|
|
87
88
|
- Windows: multi-line python -c fails silently — write a .py with escrever_arquivo and run "python file.py".
|
|
88
89
|
- If a dependency is missing, install it (winget/apt/pip/npm) and continue.
|
|
89
90
|
- LINUX/apt: NEVER run a bare "apt-get install" — on a freshly-created machine unattended-upgrades holds the apt lock and the install HANGS silently (no output). ALWAYS install like this: "sudo DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=600 install -y <packages>" (the -o Lock::Timeout WAITS for the lock up to 10min instead of hanging; noninteractive+-y avoids prompts that block without a TTY). Use "add-apt-repository -y" + "apt-get update" for PPAs. A command that doesn't return in ~1min is likely stuck on the lock/prompt — don't wait forever.
|
|
91
|
+
- STARTING A DAEMON/SERVICE in the background on a VPS (via executar_remoto): NEVER run the binary directly or use just "nohup cmd &" — the SSH channel WAITS on the process (a service never exits) and TIMES OUT; then you think it hung and RETRY (loop). ALWAYS use this pattern, which detaches the process from SSH and RETURNS immediately: "setsid nohup ./daemon args >log 2>&1 </dev/null & echo started" (setsid + redirecting ALL fds, INCLUDING stdin with </dev/null, is what frees the channel). Then confirm it's up with pgrep/ss in a SEPARATE call. If the start still times out, the daemon is likely failing at init (run it in the FOREGROUND with a short timeout to see the real error and fix it) — do NOT repeat the same start.
|
|
90
92
|
- AUTHENTIC SOURCE before improvising: before GENERATING a structured file from scratch (config, SQL schema, .conf, data, manifest), SEARCH for whether a real version already exists — in the current project, in the reference pack/install the user mentioned, or in a working install. If it exists, USE IT (copy/adapt minimally). A version invented from memory almost always comes out subtly wrong/incomplete (a missing line, a missing procedure, a wrong value). Only improvise if it truly doesn't exist — and then WARN that it's a reconstruction (may have errors) and ask to validate.
|
|
91
93
|
- LEAST PRIVILEGE in infra: to give an app access to a service (DB, broker), create a DEDICATED credential with minimal permission (e.g. CREATE USER 'app' + GRANT on the needed schema only) and point the app at it. NEVER alter the existing GLOBAL auth/config (root/admin) just to make an app connect — that affects EVERYTHING already using that access (backups, other services, your own access). If you truly must change something global, explicitly WARN what else will be affected and why.
|
|
92
94
|
- NEVER ask the user for a secret: never ask for a password/key/token/credential in chat. If a remote op (ssh/scp) fails on auth, REUSE the connection/key that ALREADY worked this session (same host/user/key — don't rebuild the command dropping the -i key flag). If it still won't connect, ask the user to PERFORM the action — never to hand over the secret.
|
package/lib/i18n.js
CHANGED
|
@@ -145,7 +145,7 @@ const STR = {
|
|
|
145
145
|
agent_thinking: 'agente pensando',
|
|
146
146
|
agent_blocked: 'bloqueado (destrutivo)',
|
|
147
147
|
agent_approve: (cmd) => `O agente quer rodar um comando DESTRUTIVO:\n\n ${cmd}\n\n Permitir? (s/N) `,
|
|
148
|
-
agent_footer: (st, cr, s) => `${st} passo(s) · ${cr} créditos · ${s}
|
|
148
|
+
agent_footer: (st, cr, s) => `${st} passo(s) · ${cr} créditos · ${s}`,
|
|
149
149
|
agent_remote_wait: (ttl) => `comando destrutivo — pedido de aprovação enviado no seu Telegram (responda em até ${Math.round(ttl / 60)} min; sem resposta = negado)`,
|
|
150
150
|
meta_need: 'Descreva o objetivo. Ex.: ts meta "monte um site de portfólio completo nesta pasta" --budget 300',
|
|
151
151
|
meta_title: 'MISSÃO',
|
|
@@ -297,7 +297,7 @@ const STR = {
|
|
|
297
297
|
agent_thinking: 'agent thinking',
|
|
298
298
|
agent_blocked: 'blocked (destructive)',
|
|
299
299
|
agent_approve: (cmd) => `The agent wants to run a DESTRUCTIVE command:\n\n ${cmd}\n\n Allow? (y/N) `,
|
|
300
|
-
agent_footer: (st, cr, s) => `${st} step(s) · ${cr} credits · ${s}
|
|
300
|
+
agent_footer: (st, cr, s) => `${st} step(s) · ${cr} credits · ${s}`,
|
|
301
301
|
agent_remote_wait: (ttl) => `destructive command — approval request sent to your Telegram (answer within ${Math.round(ttl / 60)} min; no answer = denied)`,
|
|
302
302
|
meta_need: 'Describe the goal. E.g.: ts meta "build a complete portfolio site in this folder" --budget 300',
|
|
303
303
|
meta_title: 'MISSION',
|