terminal-smart-cli 0.51.1 → 0.53.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/lib/agent.js +2 -0
- package/lib/meta.js +16 -4
- package/package.json +1 -1
package/lib/agent.js
CHANGED
|
@@ -62,6 +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 — em máquina recém-criada o unattended-upgrades segura o lock do apt e a instalação PENDURA em silêncio (sem output). Instale SEMPRE assim: "sudo DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=600 install -y <pacotes>" (o -o Lock::Timeout ESPERA o lock até 10min em vez de pendurar; noninteractive+-y evita prompts que travam sem TTY). PPA/repo com "add-apt-repository -y" e "apt-get update" antes. Comando que não retorna em ~1min provavelmente está preso no lock/prompt — não fique esperando eterno.
|
|
65
66
|
- Termine SEMPRE com um resumo curto: o que foi feito, resultado e caminhos de arquivos criados/alterados.
|
|
66
67
|
- Responda no idioma do usuário (padrão: português do Brasil).`
|
|
67
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.'
|
|
@@ -78,6 +79,7 @@ RULES:
|
|
|
78
79
|
- NEVER expose or ask for secrets (.env, keys, passwords, tokens); never send data off this machine.
|
|
79
80
|
- Windows: multi-line python -c fails silently — write a .py with escrever_arquivo and run "python file.py".
|
|
80
81
|
- If a dependency is missing, install it (winget/apt/pip/npm) and continue.
|
|
82
|
+
- 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.
|
|
81
83
|
- ALWAYS end with a short summary: what was done, the result, and paths of created/changed files.
|
|
82
84
|
- Answer in the user's language.`);
|
|
83
85
|
const volatile = `\n\nMáquina: ${process.platform} ${os.release()} · host ${os.hostname()} · user ${os.userInfo().username}`
|
package/lib/meta.js
CHANGED
|
@@ -833,14 +833,26 @@ async function _llmText({ token, model, system, user, maxTokens = 1200 }) {
|
|
|
833
833
|
// "pensador" numa análise FOCADA (sem ferramentas, sem loop) com o erro + o código
|
|
834
834
|
// dos arquivos citados, e devolve um diagnóstico + fix EXATO pro executor aplicar.
|
|
835
835
|
async function escalate(buildErr, projDir, thinker, token) {
|
|
836
|
+
// ── DIAGNÓSTICO ANTES DE ESCALAR (v0.52): em vez de só chutar pelo TEXTO do erro, o TS
|
|
837
|
+
// INVESTIGA o sistema real com sondas só-leitura (hipótese→sonda→verificação adversarial)
|
|
838
|
+
// e entrega a CAUSA RAIZ ao pensador. Só na escalação (já estamos travados) → custo contido.
|
|
839
|
+
// Desliga com TS_META_DIAGNOSE=0.
|
|
840
|
+
let diagBlock = '', diagCred = 0;
|
|
841
|
+
if (process.env.TS_META_DIAGNOSE !== '0') {
|
|
842
|
+
try {
|
|
843
|
+
const dr = await require('./diagnose').diagnose(String(buildErr).slice(0, 1400), { token, cwd: projDir, model: thinker, maxRounds: Number(process.env.TS_META_DIAGNOSE_ROUNDS) || 4 });
|
|
844
|
+
diagCred = dr.credits || 0;
|
|
845
|
+
if (dr.status === 'solved' && dr.rootCause) diagBlock = `\n\nDIAGNÓSTICO (o TS investigou o sistema com sondas só-leitura${dr.verified ? ', causa VERIFICADA' : ''}):\nCAUSA RAIZ: ${dr.rootCause}\nFIX apontado: ${dr.fix || '—'}\n(Use isto como base — é evidência do sistema real, não palpite.)`;
|
|
846
|
+
} catch (_) {}
|
|
847
|
+
}
|
|
836
848
|
const files = [...new Set([...String(buildErr).matchAll(/([A-Za-z]:[\\/][^\s:*?"<>|]+\.(?:kt|kts|xml|gradle|java|properties))/g)].map(m => m[1].replace(/\//g, path.sep)))].slice(0, 4);
|
|
837
849
|
let ctx = '';
|
|
838
850
|
for (const f of files) { try { const t = fs.readFileSync(f, 'utf8'); ctx += `\n----- ${f.split(path.sep).slice(-2).join('/')} -----\n` + t.split('\n').slice(0, 220).join('\n') + '\n'; } catch (_) {} }
|
|
839
|
-
const sys = 'Você é um engenheiro sênior de DEBUG. Recebe o ERRO REAL de um build e o código dos arquivos citados. '
|
|
840
|
-
+ 'Diga a CAUSA-RAIZ em 1-2 linhas e depois o FIX EXATO e mínimo: em QUAL arquivo, QUAL linha/trecho, e o QUE trocar (mostre o antes→depois curto). '
|
|
851
|
+
const sys = 'Você é um engenheiro sênior de DEBUG. Recebe o ERRO REAL de um build, um DIAGNÓSTICO do sistema (se houver) e o código dos arquivos citados. '
|
|
852
|
+
+ 'Se houver DIAGNÓSTICO, PARTA DELE (é evidência do sistema real). Diga a CAUSA-RAIZ em 1-2 linhas e depois o FIX EXATO e mínimo: em QUAL arquivo, QUAL linha/trecho, e o QUE trocar (mostre o antes→depois curto). '
|
|
841
853
|
+ 'NÃO reescreva o app inteiro, só o necessário pra compilar. Seja preciso e direto.';
|
|
842
|
-
const r = await _llmText({ token, model: thinker, system: sys, user: `ERRO DO BUILD:\n${String(buildErr).slice(0, 2500)}\n\nCÓDIGO RELEVANTE:${ctx.slice(0, 6000)}`, maxTokens: 1200 });
|
|
843
|
-
return { hint: r.text, credits: r.credits };
|
|
854
|
+
const r = await _llmText({ token, model: thinker, system: sys, user: `ERRO DO BUILD:\n${String(buildErr).slice(0, 2500)}${diagBlock}\n\nCÓDIGO RELEVANTE:${ctx.slice(0, 6000)}`, maxTokens: 1200 });
|
|
855
|
+
return { hint: (diagBlock ? diagBlock.trim() + '\n\n' : '') + r.text, credits: (r.credits || 0) + diagCred };
|
|
844
856
|
}
|
|
845
857
|
|
|
846
858
|
// O objetivo parece um app/UI visual? (aí vale rodar a FASE DE DESIGN antes de codar)
|