terminal-smart-cli 0.51.1 → 0.52.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/meta.js +16 -4
- package/package.json +1 -1
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)
|