@semacode/cli 3.13.1 → 4.0.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/dist/cliGrammar.js +17 -5
- package/dist/cliHelpTexto.js +4 -3
- package/dist/contextPack.d.ts +75 -0
- package/dist/contextPack.js +130 -0
- package/dist/driftPack.d.ts +65 -0
- package/dist/driftPack.js +96 -0
- package/dist/entrypointPack.d.ts +47 -0
- package/dist/entrypointPack.js +79 -0
- package/dist/index.part05.js +7 -1
- package/dist/index.part06.js +51 -0
- package/dist/index.part07.d.ts +1 -1
- package/dist/index.part07.js +16 -2
- package/dist/index.part08.js +1 -1
- package/dist/indexPack.d.ts +54 -0
- package/dist/indexPack.js +140 -0
- package/dist/init/templates.part01.js +393 -393
- package/dist/init/templates.part02.js +189 -189
- package/dist/initTemplatesBackend.js +73 -73
- package/dist/initTemplatesFlutter.js +137 -137
- package/dist/initTemplatesRuntime.js +350 -350
- package/dist/initTemplatesWeb.js +309 -309
- package/dist/sync/index.js +35 -35
- package/docs/auth.md +26 -26
- package/docs/database.md +15 -15
- package/docs/env.md +16 -16
- package/docs/frontend.md +41 -41
- package/docs/i18n.md +15 -15
- package/exemplos/agendamento.sema +1 -1
- package/exemplos/assinatura.sema +1 -1
- package/exemplos/auditoria.sema +1 -1
- package/exemplos/autenticacao.sema +1 -1
- package/exemplos/author_obra_comum.sema +1 -1
- package/exemplos/author_tema_sensivel.sema +1 -1
- package/exemplos/automacao.sema +1 -1
- package/exemplos/cadastro_usuario.sema +1 -1
- package/exemplos/calculadora.sema +1 -1
- package/exemplos/crud_simples.sema +1 -1
- package/exemplos/estoque.sema +1 -1
- package/exemplos/exportacao.sema +1 -1
- package/exemplos/fila.sema +1 -1
- package/exemplos/integracao_externa.sema +1 -1
- package/exemplos/multi_tenant.sema +1 -1
- package/exemplos/notificacao.sema +1 -1
- package/exemplos/operacao_estrategia.sema +132 -132
- package/exemplos/operacao_estrategia_discovery.sema +220 -220
- package/exemplos/operacao_estrategia_fluxo.sema +114 -114
- package/exemplos/operacao_estrategia_gates.sema +106 -106
- package/exemplos/operacao_estrategia_quarentena.sema +133 -133
- package/exemplos/operacao_estrategia_rollout.sema +124 -124
- package/exemplos/pagamento.sema +1 -1
- package/exemplos/pagamento_dominio.sema +1 -1
- package/exemplos/pedido.sema +1 -1
- package/exemplos/permissao.sema +1 -1
- package/exemplos/persistencia_vendor_first.sema +1 -1
- package/exemplos/php_crud.sema +170 -170
- package/exemplos/profile_conversas.sema +165 -165
- package/exemplos/profile_game.sema +1 -1
- package/exemplos/profile_legal.sema +1 -1
- package/exemplos/profile_ops.sema +1 -1
- package/exemplos/profile_research.sema +1 -1
- package/exemplos/profile_software.sema +1 -1
- package/exemplos/profile_workflow_n8n.sema +1 -1
- package/exemplos/relatorio.sema +1 -1
- package/exemplos/replica_analitica_erp.sema +1 -1
- package/exemplos/testes_embutidos.sema +1 -1
- package/exemplos/tratamento_erro.sema +1 -1
- package/exemplos/upload_arquivo.sema +1 -1
- package/exemplos/webhook.sema +1 -1
- package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
- package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
- package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
- package/node_modules/@sema/gerador-html/dist/index.js +17 -17
- package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
- package/package.json +1 -1
package/dist/index.part06.js
CHANGED
|
@@ -17,6 +17,8 @@ import { descobrirDocsIa, normalizarModoResumo, normalizarTamanhoResumo, renderi
|
|
|
17
17
|
import { gerarResumoProjetoIa } from "./index.part04.js";
|
|
18
18
|
import { carregarContextoModuloIa, gerarArquivosResumoModuloIa } from "./index.part03.js";
|
|
19
19
|
import { coletarResumoSemanticoModulo, renderizarResumoModuloMarkdown, renderizarResumoModuloTexto } from "./index.part02.js";
|
|
20
|
+
import { criarContextPackAPartirDoResumo } from "./contextPack.js";
|
|
21
|
+
import { selecionarIndiceContexto } from "./indexPack.js";
|
|
20
22
|
export async function comandoCompilar(entrada, alvo, saida, estrutura, framework, cwd = process.cwd()) {
|
|
21
23
|
const incompatibilidade = validarCompatibilidadeFramework(alvo, framework);
|
|
22
24
|
if (incompatibilidade) {
|
|
@@ -287,6 +289,9 @@ export async function comandoExemplosPromptIa() {
|
|
|
287
289
|
export async function comandoResumo(entrada, args, emJson) {
|
|
288
290
|
const tamanho = normalizarTamanhoResumo(args);
|
|
289
291
|
const modo = normalizarModoResumo(obterOpcao(args, "--para"));
|
|
292
|
+
const pedido = obterOpcao(args, "--pedido");
|
|
293
|
+
const pacoteSolicitado = possuiFlag(args, "--pacote");
|
|
294
|
+
const somentePacote = possuiFlag(args, "--somente-pacote");
|
|
290
295
|
const pastaSaida = obterOpcao(args, "--saida");
|
|
291
296
|
const escreverNaRaiz = possuiFlag(args, "--raiz");
|
|
292
297
|
const alvo = entrada ? path.resolve(process.cwd(), entrada) : process.cwd();
|
|
@@ -299,6 +304,22 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
299
304
|
const texto = tamanho === "medio"
|
|
300
305
|
? renderizarResumoModuloMarkdown(resumoSemantico, modo, guiaPorCapacidade)
|
|
301
306
|
: renderizarResumoModuloTexto(resumoSemantico, tamanho, modo);
|
|
307
|
+
const contextPack = pacoteSolicitado && pedido
|
|
308
|
+
? criarContextPackAPartirDoResumo({
|
|
309
|
+
resumo: resumoSemantico,
|
|
310
|
+
pedido,
|
|
311
|
+
modo,
|
|
312
|
+
tamanho,
|
|
313
|
+
analiseDrift: {
|
|
314
|
+
modo: contexto.drift.modo,
|
|
315
|
+
executada: contexto.drift.executada,
|
|
316
|
+
sucesso: contexto.drift.sucesso,
|
|
317
|
+
aviso: contexto.drift.aviso,
|
|
318
|
+
},
|
|
319
|
+
guiaPorCapacidade,
|
|
320
|
+
texto,
|
|
321
|
+
})
|
|
322
|
+
: null;
|
|
302
323
|
let pastaResumo;
|
|
303
324
|
let artefatosCompactos = [];
|
|
304
325
|
if (pastaSaida) {
|
|
@@ -308,6 +329,10 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
308
329
|
artefatosCompactos = gerado.artefatosCompactos;
|
|
309
330
|
}
|
|
310
331
|
if (emJson) {
|
|
332
|
+
if (somentePacote && contextPack) {
|
|
333
|
+
console.log(JSON.stringify(contextPack, null, 2));
|
|
334
|
+
return contexto.drift.sucesso === false ? 1 : 0;
|
|
335
|
+
}
|
|
311
336
|
console.log(JSON.stringify({
|
|
312
337
|
comando: "resumo",
|
|
313
338
|
modo,
|
|
@@ -328,6 +353,7 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
328
353
|
guiaPorCapacidade,
|
|
329
354
|
resumo: resumoSemantico,
|
|
330
355
|
texto,
|
|
356
|
+
...(contextPack ? { contextPack } : {}),
|
|
331
357
|
}, null, 2));
|
|
332
358
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
333
359
|
}
|
|
@@ -335,6 +361,10 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
335
361
|
console.log(`Resumo IA-first gerado em ${pastaResumo}`);
|
|
336
362
|
console.log("");
|
|
337
363
|
}
|
|
364
|
+
if (contextPack) {
|
|
365
|
+
console.log(JSON.stringify(contextPack, null, 2));
|
|
366
|
+
return contexto.drift.sucesso === false ? 1 : 0;
|
|
367
|
+
}
|
|
338
368
|
console.log(texto);
|
|
339
369
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
340
370
|
}
|
|
@@ -345,7 +375,23 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
345
375
|
? "SEMA_BRIEF.curto.txt"
|
|
346
376
|
: "SEMA_BRIEF.md";
|
|
347
377
|
const texto = await readFile(path.join(resumoProjeto.pastaSaida, arquivoResumo), "utf8");
|
|
378
|
+
const indexTexto = await readFile(path.join(resumoProjeto.pastaSaida, "SEMA_INDEX.json"), "utf8").catch(() => "");
|
|
379
|
+
const indexPack = pacoteSolicitado && pedido
|
|
380
|
+
? selecionarIndiceContexto({
|
|
381
|
+
modulos: resumoProjeto.modulos,
|
|
382
|
+
request: pedido,
|
|
383
|
+
baseProject: resumoProjeto.baseProjeto,
|
|
384
|
+
generatedAt: resumoProjeto.geradoEm,
|
|
385
|
+
mode: modo,
|
|
386
|
+
drift: resumoProjeto.analiseDrift.modo,
|
|
387
|
+
sourceIndexChars: indexTexto.length,
|
|
388
|
+
})
|
|
389
|
+
: null;
|
|
348
390
|
if (emJson) {
|
|
391
|
+
if (somentePacote && indexPack) {
|
|
392
|
+
console.log(JSON.stringify(indexPack, null, 2));
|
|
393
|
+
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
394
|
+
}
|
|
349
395
|
console.log(JSON.stringify({
|
|
350
396
|
comando: "resumo",
|
|
351
397
|
modo,
|
|
@@ -361,11 +407,16 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
361
407
|
guiaPorCapacidade: resumoProjeto.guiaPorCapacidade,
|
|
362
408
|
modulos: resumoProjeto.modulos,
|
|
363
409
|
texto,
|
|
410
|
+
...(indexPack ? { indexPack } : {}),
|
|
364
411
|
}, null, 2));
|
|
365
412
|
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
366
413
|
}
|
|
367
414
|
console.log(`Resumo IA-first do projeto gerado em ${resumoProjeto.pastaSaida}`);
|
|
368
415
|
console.log("");
|
|
416
|
+
if (indexPack) {
|
|
417
|
+
console.log(JSON.stringify(indexPack, null, 2));
|
|
418
|
+
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
419
|
+
}
|
|
369
420
|
console.log(texto);
|
|
370
421
|
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
371
422
|
}
|
package/dist/index.part07.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function alvosSuportadosPelaStack(fontesLegado: string[] | undefi
|
|
|
8
8
|
export declare function avisoEscopoStackVerificacao(fontesLegado: string[] | undefined, alvosEfetivos: AlvoGeracao[]): string | undefined;
|
|
9
9
|
import { type ResumoModuloVerificacao } from './geracaoCore.js';
|
|
10
10
|
export declare function comandoPromptCurto(entrada: string | undefined, args: string[], emJson: boolean): Promise<number>;
|
|
11
|
-
export declare function comandoContextoIa(arquivo: string, pastaSaida: string | undefined, emJson: boolean): Promise<number>;
|
|
11
|
+
export declare function comandoContextoIa(arquivo: string, pastaSaida: string | undefined, emJson: boolean, args?: string[]): Promise<number>;
|
|
12
12
|
export declare function comandoTestar(arquivo: string, alvo: AlvoGeracao, saida: string, estrutura: EstruturaSaida, framework: FrameworkGeracao): Promise<number>;
|
|
13
13
|
export declare function imprimirResumoVerificacao(resumos: ResumoModuloVerificacao[]): void;
|
|
14
14
|
export declare function comandoVerificar(entrada: string | undefined, baseSaida: string, cwd?: string, opcoes?: OpcoesVerificar): Promise<number>;
|
package/dist/index.part07.js
CHANGED
|
@@ -51,8 +51,10 @@ export function avisoEscopoStackVerificacao(fontesLegado, alvosEfetivos) {
|
|
|
51
51
|
}
|
|
52
52
|
return `Alvos fora da stack detectada (${(fontesLegado ?? []).join(", ")}): ${foraDaStack.join(", ")}. Considere reduzir "alvos" no sema.config.json, remover "fontesLegado" auto-declaradas ou usar --alvo unico.`;
|
|
53
53
|
}
|
|
54
|
+
import { criarAgentContextPack } from './agentContextPack.js';
|
|
55
|
+
import { criarEntrypointPack } from './entrypointPack.js';
|
|
54
56
|
import { escreverArquivos, formatarAvisoArtefatosGeradosAcimaDoLimite, } from './fsGovernado.js';
|
|
55
|
-
import { obterOpcao } from './cliArgs.js';
|
|
57
|
+
import { obterOpcao, possuiFlag } from './cliArgs.js';
|
|
56
58
|
import { avaliarDependenciasVerificacao, imprimirFalhaDependenciasVerificacao } from './doctorCommand.js';
|
|
57
59
|
import { aplicarEstruturaSaida, executarTestesGerados, executarTestesParaVerificacao, gerarArquivosPorAlvo, garantirIr, nomeSubpastaModulo, resolverConfiguracaoVerificacaoPorAlvo, validarCompatibilidadeFramework, } from './geracaoCore.js';
|
|
58
60
|
import { normalizarModoResumo, normalizarTamanhoResumo } from "./index.part01.js";
|
|
@@ -137,8 +139,20 @@ ${contextoProjeto.trim()}
|
|
|
137
139
|
console.log(prompt);
|
|
138
140
|
return 0;
|
|
139
141
|
}
|
|
140
|
-
export async function comandoContextoIa(arquivo, pastaSaida, emJson) {
|
|
142
|
+
export async function comandoContextoIa(arquivo, pastaSaida, emJson, args = []) {
|
|
141
143
|
const resultado = await gerarContextoIa(arquivo, pastaSaida);
|
|
144
|
+
const capacidadeValor = obterOpcao(args, "--capacidade") ?? "media";
|
|
145
|
+
const capacidade = capacidadeValor === "fraca" || capacidadeValor === "forte" ? capacidadeValor : "media";
|
|
146
|
+
if (possuiFlag(args, "--pacote")) {
|
|
147
|
+
const agentContextPack = criarAgentContextPack(resultado.guiaPorCapacidade);
|
|
148
|
+
const pacote = criarEntrypointPack({
|
|
149
|
+
agentContextPack,
|
|
150
|
+
capacity: capacidade,
|
|
151
|
+
rawAgentContextChars: JSON.stringify(agentContextPack).length,
|
|
152
|
+
});
|
|
153
|
+
console.log(JSON.stringify(pacote, null, 2));
|
|
154
|
+
return resultado.sucesso ? 0 : 1;
|
|
155
|
+
}
|
|
142
156
|
if (emJson) {
|
|
143
157
|
console.log(JSON.stringify(resultado, null, 2));
|
|
144
158
|
return 0;
|
package/dist/index.part08.js
CHANGED
|
@@ -175,7 +175,7 @@ export async function principal() {
|
|
|
175
175
|
codigoSaida = await comandoExemplosPromptIa();
|
|
176
176
|
break;
|
|
177
177
|
case "contexto-ia":
|
|
178
|
-
codigoSaida = await comandoContextoIa(posicionais[0] ?? "", obterOpcao(resto, "--saida"), possuiFlag(resto, "--json"));
|
|
178
|
+
codigoSaida = await comandoContextoIa(posicionais[0] ?? "", obterOpcao(resto, "--saida"), possuiFlag(resto, "--json"), resto);
|
|
179
179
|
break;
|
|
180
180
|
default:
|
|
181
181
|
throw erroComandoDesconhecido();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ResumoSemanticoModuloIa } from "./index.part01.js";
|
|
2
|
+
type EntradaIndice = Pick<ResumoSemanticoModuloIa, "arquivo" | "modulo" | "faz" | "tarefasPrincipais" | "regrasCriticas" | "efeitos" | "riscosPrincipais" | "lacunas" | "arquivosProvaveis" | "checksSugeridos" | "testesMinimos" | "arquivosProvaveisEditar">;
|
|
3
|
+
export type IndexPack = {
|
|
4
|
+
schema: "sema.ai.index-pack/v1";
|
|
5
|
+
selection: "deterministic_weighted_match";
|
|
6
|
+
request: string;
|
|
7
|
+
source: {
|
|
8
|
+
command: "resumo-projeto";
|
|
9
|
+
baseProject: string;
|
|
10
|
+
generatedAt: string | null;
|
|
11
|
+
totalModules: number;
|
|
12
|
+
mode: string;
|
|
13
|
+
drift: string;
|
|
14
|
+
};
|
|
15
|
+
matches: Array<{
|
|
16
|
+
module: string;
|
|
17
|
+
contract: string;
|
|
18
|
+
relevanceScore: number;
|
|
19
|
+
purpose: string;
|
|
20
|
+
relevantTasks: string[];
|
|
21
|
+
criticalRules: string[];
|
|
22
|
+
effects: string[];
|
|
23
|
+
risks: string[];
|
|
24
|
+
knownGaps: string[];
|
|
25
|
+
likelyFiles: string[];
|
|
26
|
+
filesToEdit: string[];
|
|
27
|
+
requiredChecks: string[];
|
|
28
|
+
minimumTests: string[];
|
|
29
|
+
}>;
|
|
30
|
+
authority: {
|
|
31
|
+
semaRemainsAuthority: true;
|
|
32
|
+
rawIndexForwarded: false;
|
|
33
|
+
executionRequiresFreshValidation: true;
|
|
34
|
+
omitted: string[];
|
|
35
|
+
};
|
|
36
|
+
telemetry: {
|
|
37
|
+
packChars: number;
|
|
38
|
+
packEstimatedTokens: number;
|
|
39
|
+
estimateMethod: "chars_div_4";
|
|
40
|
+
sourceIndexEstimatedTokens: number;
|
|
41
|
+
reductionPercent: number;
|
|
42
|
+
selectedFields: string[];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare function selecionarIndiceContexto(input: {
|
|
46
|
+
modulos: readonly EntradaIndice[];
|
|
47
|
+
request: string;
|
|
48
|
+
baseProject: string;
|
|
49
|
+
generatedAt?: string | null;
|
|
50
|
+
mode?: string;
|
|
51
|
+
drift?: string;
|
|
52
|
+
sourceIndexChars?: number;
|
|
53
|
+
}): IndexPack;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
function texto(value) {
|
|
2
|
+
return typeof value === "string" ? value : "";
|
|
3
|
+
}
|
|
4
|
+
function lista(value) {
|
|
5
|
+
return Array.isArray(value)
|
|
6
|
+
? value.filter((item) => typeof item === "string" && item.length > 0)
|
|
7
|
+
: [];
|
|
8
|
+
}
|
|
9
|
+
function tokens(value) {
|
|
10
|
+
return value
|
|
11
|
+
.toLocaleLowerCase("pt-BR")
|
|
12
|
+
.normalize("NFD")
|
|
13
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
14
|
+
.split(/[^a-z0-9_]+/)
|
|
15
|
+
.filter((item) => item.length >= 3);
|
|
16
|
+
}
|
|
17
|
+
function correspondeToken(campo, pedido) {
|
|
18
|
+
return tokens(campo).some((token) => [...pedido].some((alvo) => token.startsWith(alvo) || alvo.startsWith(token)));
|
|
19
|
+
}
|
|
20
|
+
function selecionarValores(values, requestTokens, maximo) {
|
|
21
|
+
return values
|
|
22
|
+
.map((value, index) => ({
|
|
23
|
+
value,
|
|
24
|
+
index,
|
|
25
|
+
score: correspondeToken(value, requestTokens) ? 1 : 0,
|
|
26
|
+
}))
|
|
27
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
28
|
+
.filter((item) => item.score > 0)
|
|
29
|
+
.slice(0, maximo)
|
|
30
|
+
.map((item) => item.value);
|
|
31
|
+
}
|
|
32
|
+
function estimarTokens(chars) {
|
|
33
|
+
return Math.ceil(chars / 4);
|
|
34
|
+
}
|
|
35
|
+
function compactarModulo(modulo, requestTokens) {
|
|
36
|
+
const tarefas = lista(modulo.tarefasPrincipais);
|
|
37
|
+
const regras = lista(modulo.regrasCriticas);
|
|
38
|
+
const efeitos = lista(modulo.efeitos);
|
|
39
|
+
const riscos = lista(modulo.riscosPrincipais);
|
|
40
|
+
const lacunas = lista(modulo.lacunas);
|
|
41
|
+
const arquivos = lista(modulo.arquivosProvaveis);
|
|
42
|
+
const arquivosEditar = lista(modulo.arquivosProvaveisEditar);
|
|
43
|
+
const checks = lista(modulo.checksSugeridos);
|
|
44
|
+
const testes = lista(modulo.testesMinimos);
|
|
45
|
+
const camposComPeso = [
|
|
46
|
+
[texto(modulo.modulo), [texto(modulo.modulo)], 5],
|
|
47
|
+
[texto(modulo.faz), [texto(modulo.faz)], 3],
|
|
48
|
+
["tarefas", tarefas, 4],
|
|
49
|
+
["regras", regras, 2],
|
|
50
|
+
["efeitos", efeitos, 1],
|
|
51
|
+
["riscos", riscos, 2],
|
|
52
|
+
["lacunas", lacunas, 1],
|
|
53
|
+
["arquivos", [...arquivos, ...arquivosEditar], 1],
|
|
54
|
+
];
|
|
55
|
+
const relevanceScore = camposComPeso.reduce((total, [, values, weight]) => total + values.reduce((subtotal, value) => subtotal + (correspondeToken(value, requestTokens) ? weight : 0), 0), 0);
|
|
56
|
+
if (relevanceScore === 0)
|
|
57
|
+
return null;
|
|
58
|
+
return {
|
|
59
|
+
module: texto(modulo.modulo),
|
|
60
|
+
contract: texto(modulo.arquivo),
|
|
61
|
+
relevanceScore,
|
|
62
|
+
purpose: texto(modulo.faz),
|
|
63
|
+
relevantTasks: selecionarValores(tarefas, requestTokens, 8),
|
|
64
|
+
criticalRules: selecionarValores(regras, requestTokens, 8),
|
|
65
|
+
effects: selecionarValores(efeitos, requestTokens, 6),
|
|
66
|
+
risks: selecionarValores(riscos, requestTokens, 6),
|
|
67
|
+
knownGaps: selecionarValores(lacunas, requestTokens, 6),
|
|
68
|
+
likelyFiles: selecionarValores(arquivos, requestTokens, 8),
|
|
69
|
+
filesToEdit: selecionarValores(arquivosEditar, requestTokens, 8),
|
|
70
|
+
requiredChecks: selecionarValores(checks, requestTokens, 6),
|
|
71
|
+
minimumTests: selecionarValores(testes, requestTokens, 6),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function selecionarIndiceContexto(input) {
|
|
75
|
+
const request = input.request.trim();
|
|
76
|
+
const requestTokens = new Set(tokens(request));
|
|
77
|
+
const matches = input.modulos
|
|
78
|
+
.map((modulo) => compactarModulo(modulo, requestTokens))
|
|
79
|
+
.filter((item) => item !== null)
|
|
80
|
+
.sort((a, b) => b.relevanceScore - a.relevanceScore || a.module.localeCompare(b.module, "pt-BR"))
|
|
81
|
+
.slice(0, 8);
|
|
82
|
+
const base = {
|
|
83
|
+
schema: "sema.ai.index-pack/v1",
|
|
84
|
+
selection: "deterministic_weighted_match",
|
|
85
|
+
request,
|
|
86
|
+
source: {
|
|
87
|
+
command: "resumo-projeto",
|
|
88
|
+
baseProject: input.baseProject,
|
|
89
|
+
generatedAt: input.generatedAt ?? null,
|
|
90
|
+
totalModules: input.modulos.length,
|
|
91
|
+
mode: input.mode ?? "mudanca",
|
|
92
|
+
drift: input.drift ?? "none",
|
|
93
|
+
},
|
|
94
|
+
matches,
|
|
95
|
+
authority: {
|
|
96
|
+
semaRemainsAuthority: true,
|
|
97
|
+
rawIndexForwarded: false,
|
|
98
|
+
executionRequiresFreshValidation: true,
|
|
99
|
+
omitted: [
|
|
100
|
+
"SEMA_INDEX.json completo",
|
|
101
|
+
"agentContextPack duplicado",
|
|
102
|
+
"módulos sem correspondência literal ou estrutural no pedido",
|
|
103
|
+
"catálogo e arquivos não relacionados ao pedido",
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const packChars = JSON.stringify(base).length;
|
|
108
|
+
const sourceIndexChars = input.sourceIndexChars ?? 0;
|
|
109
|
+
const sourceTokens = estimarTokens(sourceIndexChars);
|
|
110
|
+
return {
|
|
111
|
+
...base,
|
|
112
|
+
telemetry: {
|
|
113
|
+
packChars,
|
|
114
|
+
packEstimatedTokens: estimarTokens(packChars),
|
|
115
|
+
estimateMethod: "chars_div_4",
|
|
116
|
+
sourceIndexEstimatedTokens: sourceTokens,
|
|
117
|
+
reductionPercent: sourceIndexChars === 0 ? 0 : Math.round((1 - packChars / sourceIndexChars) * 10000) / 100,
|
|
118
|
+
selectedFields: [
|
|
119
|
+
"request",
|
|
120
|
+
"source.baseProject",
|
|
121
|
+
"source.generatedAt",
|
|
122
|
+
"matches.module",
|
|
123
|
+
"matches.contract",
|
|
124
|
+
"matches.relevanceScore",
|
|
125
|
+
"matches.purpose",
|
|
126
|
+
"matches.relevantTasks",
|
|
127
|
+
"matches.criticalRules",
|
|
128
|
+
"matches.effects",
|
|
129
|
+
"matches.risks",
|
|
130
|
+
"matches.knownGaps",
|
|
131
|
+
"matches.likelyFiles",
|
|
132
|
+
"matches.filesToEdit",
|
|
133
|
+
"matches.requiredChecks",
|
|
134
|
+
"matches.minimumTests",
|
|
135
|
+
"authority",
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=indexPack.js.map
|