terminal-smart-cli 0.97.0 → 0.97.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.
Files changed (2) hide show
  1. package/lib/skill-index.js +18 -2
  2. package/package.json +1 -1
@@ -202,8 +202,24 @@ function buscar(skills, consulta, { k = 3, limiar = LIMIAR, destaque = 0, idx =
202
202
  if (!texto) return [];
203
203
  const _idx = idx || montarIndice(skills);
204
204
  if (!_idx.N) return [];
205
- const brutos = indice.search('', _normalizar(texto), Math.max(k * 3, 9), _idx) || [];
206
- const acima = brutos.filter(r => r.score >= limiar);
205
+ const consultaNorm = _normalizar(texto);
206
+ const brutos = indice.search('', consultaNorm, Math.max(k * 3, 9), _idx) || [];
207
+
208
+ // BÔNUS DE COBERTURA: o BM25 soma IDF×tf, então UM termo raro pode ganhar de dois termos
209
+ // certeiros. Medido: "criar componente react" ranqueava `pdf` (cobre só "criar") junto de
210
+ // `web-artifacts-builder` (cobre "componente"+"react"). Cobrir mais da pergunta é sinal
211
+ // forte de aderência. É BÔNUS e não filtro: como filtro, eliminaria `xlsx` em "gerar
212
+ // planilha de custos", onde o match legítimo cobre um termo só.
213
+ const termosQuery = [...new Set(indice.tokenize(consultaNorm))];
214
+ const porChunk = new Map(_idx.chunks.map(c => [c.file, c]));
215
+ const comBonus = brutos.map(r => {
216
+ const c = porChunk.get(r.file);
217
+ const cobertos = c ? termosQuery.filter(t => c.tf[t]).length : 0;
218
+ const cobertura = termosQuery.length ? cobertos / termosQuery.length : 0;
219
+ return Object.assign({}, r, { score: r.score * (1 + 0.6 * cobertura), cobertura });
220
+ }).sort((a, b) => b.score - a.score);
221
+
222
+ const acima = comBonus.filter(r => r.score >= limiar);
207
223
  if (!acima.length) return [];
208
224
  if (destaque > 1 && acima.length > 1 && acima[0].score < acima[1].score * destaque) return [];
209
225
  const porSlug = new Map(_idx.chunks.map(c => [c.file, c._skill]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-smart-cli",
3
- "version": "0.97.0",
3
+ "version": "0.97.1",
4
4
  "description": "Terminal Smart no seu terminal — pergunte, analise logs por pipe e orquestre agentes de IA. Comando: ts",
5
5
  "bin": {
6
6
  "ts": "bin/ts.js"