@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/cliGrammar.js
CHANGED
|
@@ -35,6 +35,7 @@ const ESTRUTURAS = new Set(["flat", "modulos", "backend"]);
|
|
|
35
35
|
const ESCOPOS = new Set(["arquivo", "modulo", "projeto"]);
|
|
36
36
|
const MODOS_CACHE = new Set(["none", "cache", "fresh", "off", "auto", "refresh"]);
|
|
37
37
|
const MODOS_RESUMO = new Set(["resumo", "onboarding", "review", "mudanca", "bug", "arquitetura"]);
|
|
38
|
+
const CAPACIDADES_IA = new Set(["fraca", "media", "forte"]);
|
|
38
39
|
const MATURIDADES = new Set([
|
|
39
40
|
"draft", "rascunho", "prototype", "prototipo", "production", "producao",
|
|
40
41
|
"critical", "critico", "critica",
|
|
@@ -416,15 +417,22 @@ function validarInterativo(args) {
|
|
|
416
417
|
}
|
|
417
418
|
function validarResumo(args, promptCurto) {
|
|
418
419
|
const parsed = parsearArgumentos(args, {
|
|
419
|
-
opcoes: promptCurto ? ["--para"] : ["--para", "--saida", "--drift", "--cache"],
|
|
420
|
-
flags: promptCurto ? ["--micro", "--curto", "--medio"] : ["--micro", "--curto", "--medio", "--raiz", "--com-drift"],
|
|
420
|
+
opcoes: promptCurto ? ["--para"] : ["--para", "--saida", "--drift", "--cache", "--pedido"],
|
|
421
|
+
flags: promptCurto ? ["--micro", "--curto", "--medio"] : ["--micro", "--curto", "--medio", "--raiz", "--com-drift", "--pacote", "--somente-pacote"],
|
|
421
422
|
maxPosicionais: 1,
|
|
422
423
|
});
|
|
423
424
|
if (!parsed)
|
|
424
425
|
return false;
|
|
425
426
|
const tamanhos = ["--micro", "--curto", "--medio"].filter((flag) => parsed.flags.has(flag));
|
|
426
427
|
const modo = valorOpcao(parsed, "--para");
|
|
427
|
-
|
|
428
|
+
const pacote = parsed.flags.has("--pacote");
|
|
429
|
+
const somentePacote = parsed.flags.has("--somente-pacote");
|
|
430
|
+
const pedido = valorOpcao(parsed, "--pedido");
|
|
431
|
+
const combinacaoPacoteValida = pacote === Boolean(pedido);
|
|
432
|
+
return tamanhos.length <= 1
|
|
433
|
+
&& (!modo || MODOS_RESUMO.has(modo))
|
|
434
|
+
&& (promptCurto || validarModoCache(parsed, "--drift"))
|
|
435
|
+
&& (promptCurto ? !pacote && !pedido && !somentePacote : combinacaoPacoteValida && (!somentePacote || pacote));
|
|
428
436
|
}
|
|
429
437
|
function validarComandoBasico(comando, args) {
|
|
430
438
|
const aliasesGeracao = { "-a": "--alvo", "-s": "--saida" };
|
|
@@ -433,7 +441,11 @@ function validarComandoBasico(comando, args) {
|
|
|
433
441
|
case "ast":
|
|
434
442
|
case "ir":
|
|
435
443
|
case "diagnosticos": return parsearArgumentos(args, { minPosicionais: 1, maxPosicionais: 1 }) !== null;
|
|
436
|
-
case "contexto-ia":
|
|
444
|
+
case "contexto-ia": {
|
|
445
|
+
const parsed = parsearArgumentos(args, { opcoes: ["--saida", "--capacidade"], flags: ["--pacote"], minPosicionais: 1, maxPosicionais: 1 });
|
|
446
|
+
const capacidade = parsed ? valorOpcao(parsed, "--capacidade") : undefined;
|
|
447
|
+
return parsed !== null && (!capacidade || CAPACIDADES_IA.has(capacidade));
|
|
448
|
+
}
|
|
437
449
|
case "compilar":
|
|
438
450
|
case "testar": {
|
|
439
451
|
const parsed = parsearArgumentos(args, { opcoes: ["--alvo", "--saida", "--estrutura", "--framework"], aliases: aliasesGeracao, minPosicionais: comando === "testar" ? 1 : 0, maxPosicionais: 1 });
|
|
@@ -458,7 +470,7 @@ function validarComandoBasico(comando, args) {
|
|
|
458
470
|
return parsed !== null && validarModoCache(parsed, "--drift");
|
|
459
471
|
}
|
|
460
472
|
case "drift": {
|
|
461
|
-
const parsed = parsearArgumentos(args, { opcoes: ["--escopo", "--cache", "--drift"], flags: ["--incluir-worktrees", "--incluir-consumidores-laterais"], maxPosicionais: 1 });
|
|
473
|
+
const parsed = parsearArgumentos(args, { opcoes: ["--escopo", "--cache", "--drift"], flags: ["--incluir-worktrees", "--incluir-consumidores-laterais", "--pacote"], maxPosicionais: 1 });
|
|
462
474
|
const escopo = parsed ? valorOpcao(parsed, "--escopo") : undefined;
|
|
463
475
|
return parsed !== null && (!escopo || ESCOPOS.has(escopo)) && validarModoCache(parsed, "--cache");
|
|
464
476
|
}
|
package/dist/cliHelpTexto.js
CHANGED
|
@@ -102,6 +102,7 @@ export function criarAjudaRaiz(versao) {
|
|
|
102
102
|
"fraca: sema resumo <arquivo> --micro --drift none --json (contrato compacto; implementação não avaliada)",
|
|
103
103
|
"média: sema resumo <arquivo> --curto --drift none --json + sema drift <arquivo> --cache fresh --json",
|
|
104
104
|
"forte: sema contexto-ia <arquivo.sema> --saida <diretorio> --json",
|
|
105
|
+
"context-pack: sema resumo <arquivo.sema> --micro --para mudanca --drift none --pacote --pedido \"<intenção>\" --json (seleção determinística para a IA)",
|
|
105
106
|
]),
|
|
106
107
|
"",
|
|
107
108
|
renderizarSecaoAscii("Comandos principais", [
|
|
@@ -110,7 +111,7 @@ export function criarAjudaRaiz(versao) {
|
|
|
110
111
|
"pipelines: sema pipeline <listar|descrever> [id] [--json]",
|
|
111
112
|
"todas as capacidades: sema capabilities [--json]",
|
|
112
113
|
"distribuição global: sema skill <status|sync> [--json] (status é somente leitura; sync repara launcher e skill)",
|
|
113
|
-
"auditoria: sema drift <arquivo-ou-pasta> [--escopo <arquivo|modulo|projeto>] [--cache <none|cache|fresh>] [--incluir-worktrees] [--incluir-consumidores-laterais] [--json]",
|
|
114
|
+
"auditoria: sema drift <arquivo-ou-pasta> [--escopo <arquivo|modulo|projeto>] [--cache <none|cache|fresh>] [--incluir-worktrees] [--incluir-consumidores-laterais] [--pacote] [--json]",
|
|
114
115
|
"modos: drift direto usa fresh por padrão; --cache none ainda executa sem cache persistente; resumo/inspecionar usam --drift none por padrão e não fabricam evidência",
|
|
115
116
|
"impacto: sema impacto <arquivo-ou-pasta> --alvo <token> [--mudanca <descricao>] [--escopo <arquivo|modulo|projeto>] [--json]",
|
|
116
117
|
"renomeação: sema renomear-semantico <arquivo-ou-pasta> --de <nome-atual> --para <nome-novo> [--escopo <arquivo|modulo|projeto>] [--json]",
|
|
@@ -133,14 +134,14 @@ export function criarAjudaRaiz(versao) {
|
|
|
133
134
|
renderizarSecaoAscii("Ajuda IA-first", [
|
|
134
135
|
"sema ajuda-ia",
|
|
135
136
|
"sema starter-ia",
|
|
136
|
-
"sema resumo <arquivo-ou-pasta> [--micro|--curto|--medio] [--para <resumo|onboarding|review|mudanca|bug|arquitetura>] [--drift <none|cache|fresh>] [--saida <diretorio>] [--raiz] [--json]",
|
|
137
|
+
"sema resumo <arquivo-ou-pasta> [--micro|--curto|--medio] [--para <resumo|onboarding|review|mudanca|bug|arquitetura>] [--drift <none|cache|fresh>] [--saida <diretorio>] [--raiz] [--pacote --somente-pacote --pedido <intencao>] [--json]",
|
|
137
138
|
"sema prompt-curto <arquivo-ou-pasta> [--micro|--curto|--medio] [--para <resumo|onboarding|review|mudanca|bug|arquitetura>] [--json]",
|
|
138
139
|
"sema prompt-ia",
|
|
139
140
|
"sema prompt-ia-ui",
|
|
140
141
|
"sema prompt-ia-react",
|
|
141
142
|
"sema prompt-ia-sema-primeiro",
|
|
142
143
|
"sema exemplos-prompt-ia",
|
|
143
|
-
"sema contexto-ia <arquivo.sema> [--saida <diretorio>] [--json]",
|
|
144
|
+
"sema contexto-ia <arquivo.sema> [--saida <diretorio>] [--capacidade <fraca|media|forte>] [--pacote] [--json]",
|
|
144
145
|
"sema sync-codex [--json]",
|
|
145
146
|
"sema instalar-exemplos [--json]",
|
|
146
147
|
"sema sessao [intencao] [entrada] [--json]",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ResumoSemanticoModuloIa, TamanhoResumoIa } from "./index.part01.js";
|
|
2
|
+
type ResumoEntrada = Partial<ResumoSemanticoModuloIa>;
|
|
3
|
+
export type ContextPackPayload = {
|
|
4
|
+
geradoEm?: string;
|
|
5
|
+
arquivo?: string;
|
|
6
|
+
modulo?: string;
|
|
7
|
+
modo?: string;
|
|
8
|
+
tamanho?: string;
|
|
9
|
+
analiseDrift?: {
|
|
10
|
+
modo?: string;
|
|
11
|
+
executada?: boolean;
|
|
12
|
+
sucesso?: boolean | null;
|
|
13
|
+
aviso?: string | null;
|
|
14
|
+
};
|
|
15
|
+
guiaPorCapacidade?: unknown;
|
|
16
|
+
texto?: string;
|
|
17
|
+
resumo?: ResumoEntrada;
|
|
18
|
+
};
|
|
19
|
+
export type ContextPack = {
|
|
20
|
+
schema: "sema.ai.context-pack/v1";
|
|
21
|
+
selection: "deterministic_allowlist";
|
|
22
|
+
request: string;
|
|
23
|
+
source: {
|
|
24
|
+
command: "resumo";
|
|
25
|
+
mode: string;
|
|
26
|
+
size: string;
|
|
27
|
+
drift: string;
|
|
28
|
+
generatedAt: string | null;
|
|
29
|
+
contract: string | null;
|
|
30
|
+
};
|
|
31
|
+
context: {
|
|
32
|
+
module: string | null;
|
|
33
|
+
purpose: string | null;
|
|
34
|
+
relevantTasks: string[];
|
|
35
|
+
criticalRules: string[];
|
|
36
|
+
effects: string[];
|
|
37
|
+
entities: string[];
|
|
38
|
+
risks: string[];
|
|
39
|
+
likelyFiles: string[];
|
|
40
|
+
requiredChecks: string[];
|
|
41
|
+
minimumTests: string[];
|
|
42
|
+
compatibilityProfile: string | null;
|
|
43
|
+
knownGaps: string[];
|
|
44
|
+
};
|
|
45
|
+
authority: {
|
|
46
|
+
semaRemainsAuthority: true;
|
|
47
|
+
rawSummaryForwarded: false;
|
|
48
|
+
executionRequiresFreshValidation: true;
|
|
49
|
+
omitted: string[];
|
|
50
|
+
};
|
|
51
|
+
telemetry: {
|
|
52
|
+
packChars: number;
|
|
53
|
+
packEstimatedTokens: number;
|
|
54
|
+
estimateMethod: "chars_div_4";
|
|
55
|
+
selectedFields: string[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type ContextPackResult = {
|
|
59
|
+
pack: ContextPack;
|
|
60
|
+
rawSummaryChars: number;
|
|
61
|
+
rawSummaryEstimatedTokens: number;
|
|
62
|
+
rawSummaryEstimateMethod: "chars_div_4";
|
|
63
|
+
reductionPercent: number;
|
|
64
|
+
};
|
|
65
|
+
export declare function selecionarContexto(payload: ContextPackPayload, request: string): ContextPackResult;
|
|
66
|
+
export declare function criarContextPackAPartirDoResumo(input: {
|
|
67
|
+
resumo: ResumoSemanticoModuloIa;
|
|
68
|
+
pedido: string;
|
|
69
|
+
modo: string;
|
|
70
|
+
tamanho: TamanhoResumoIa;
|
|
71
|
+
analiseDrift: ContextPackPayload["analiseDrift"];
|
|
72
|
+
guiaPorCapacidade: unknown;
|
|
73
|
+
texto: string;
|
|
74
|
+
}): ContextPackResult;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
function list(value) {
|
|
2
|
+
return Array.isArray(value)
|
|
3
|
+
? value.filter((item) => typeof item === "string" && item.length > 0)
|
|
4
|
+
: [];
|
|
5
|
+
}
|
|
6
|
+
function text(value) {
|
|
7
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
8
|
+
}
|
|
9
|
+
function normalizedTokens(value) {
|
|
10
|
+
return value
|
|
11
|
+
.toLocaleLowerCase("pt-BR")
|
|
12
|
+
.normalize("NFD")
|
|
13
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
14
|
+
.split(/[^a-z0-9_]+/)
|
|
15
|
+
.filter((token) => token.length >= 4);
|
|
16
|
+
}
|
|
17
|
+
function selectRelevantTasks(tasks, request) {
|
|
18
|
+
const requestTokens = new Set(normalizedTokens(request));
|
|
19
|
+
const intentRoots = ["cancel", "notific", "export", "reagend", "registr", "consult"];
|
|
20
|
+
const rootedMatches = intentRoots
|
|
21
|
+
.filter((root) => [...requestTokens].some((token) => token.startsWith(root)))
|
|
22
|
+
.flatMap((root) => tasks.filter((task) => normalizedTokens(task).some((token) => token.startsWith(root))));
|
|
23
|
+
if (rootedMatches.length > 0)
|
|
24
|
+
return [...new Set(rootedMatches)];
|
|
25
|
+
const scored = tasks.map((task, index) => {
|
|
26
|
+
const taskTokens = normalizedTokens(task);
|
|
27
|
+
const score = taskTokens.reduce((total, token) => total + (requestTokens.has(token) ? 1 : 0), 0);
|
|
28
|
+
return { task, index, score };
|
|
29
|
+
});
|
|
30
|
+
const selected = scored
|
|
31
|
+
.filter((item) => item.score > 0)
|
|
32
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
33
|
+
.map((item) => item.task);
|
|
34
|
+
return selected.length > 0 ? selected : tasks.slice(0, 3);
|
|
35
|
+
}
|
|
36
|
+
function estimateTokens(chars) {
|
|
37
|
+
return Math.ceil(chars / 4);
|
|
38
|
+
}
|
|
39
|
+
export function selecionarContexto(payload, request) {
|
|
40
|
+
const resumo = payload.resumo ?? {};
|
|
41
|
+
const context = {
|
|
42
|
+
module: text(resumo.modulo) ?? text(payload.modulo),
|
|
43
|
+
purpose: text(resumo.faz),
|
|
44
|
+
relevantTasks: selectRelevantTasks(list(resumo.tarefasPrincipais), request),
|
|
45
|
+
criticalRules: list(resumo.regrasCriticas),
|
|
46
|
+
effects: list(resumo.efeitos),
|
|
47
|
+
entities: list(resumo.entidadesAfetadas),
|
|
48
|
+
risks: list(resumo.riscosPrincipais),
|
|
49
|
+
likelyFiles: list(resumo.arquivosProvaveis),
|
|
50
|
+
requiredChecks: list(resumo.checksSugeridos),
|
|
51
|
+
minimumTests: list(resumo.testesMinimos),
|
|
52
|
+
compatibilityProfile: text(resumo.perfilCompatibilidade),
|
|
53
|
+
knownGaps: list(resumo.lacunas),
|
|
54
|
+
};
|
|
55
|
+
const packWithoutTelemetry = {
|
|
56
|
+
schema: "sema.ai.context-pack/v1",
|
|
57
|
+
selection: "deterministic_allowlist",
|
|
58
|
+
request,
|
|
59
|
+
source: {
|
|
60
|
+
command: "resumo",
|
|
61
|
+
mode: text(payload.modo) ?? "mudanca",
|
|
62
|
+
size: text(payload.tamanho) ?? "micro",
|
|
63
|
+
drift: text(payload.analiseDrift?.modo) ?? "none",
|
|
64
|
+
generatedAt: text(resumo.geradoEm) ?? text(payload.geradoEm),
|
|
65
|
+
contract: text(resumo.arquivo) ?? text(payload.arquivo),
|
|
66
|
+
},
|
|
67
|
+
context,
|
|
68
|
+
authority: {
|
|
69
|
+
semaRemainsAuthority: true,
|
|
70
|
+
rawSummaryForwarded: false,
|
|
71
|
+
executionRequiresFreshValidation: true,
|
|
72
|
+
omitted: [
|
|
73
|
+
"cli_result_envelope",
|
|
74
|
+
"guiaPorCapacidade",
|
|
75
|
+
"texto_bruto_do_resumo",
|
|
76
|
+
"metadados_fora_do_escopo",
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
const packChars = JSON.stringify(packWithoutTelemetry).length;
|
|
81
|
+
const selectedFields = [
|
|
82
|
+
"request",
|
|
83
|
+
"source.module",
|
|
84
|
+
"source.contract",
|
|
85
|
+
"context.module",
|
|
86
|
+
"context.purpose",
|
|
87
|
+
"context.relevantTasks",
|
|
88
|
+
"context.criticalRules",
|
|
89
|
+
"context.effects",
|
|
90
|
+
"context.entities",
|
|
91
|
+
"context.risks",
|
|
92
|
+
"context.likelyFiles",
|
|
93
|
+
"context.requiredChecks",
|
|
94
|
+
"context.minimumTests",
|
|
95
|
+
"context.compatibilityProfile",
|
|
96
|
+
"context.knownGaps",
|
|
97
|
+
"authority",
|
|
98
|
+
];
|
|
99
|
+
const pack = {
|
|
100
|
+
...packWithoutTelemetry,
|
|
101
|
+
telemetry: {
|
|
102
|
+
packChars,
|
|
103
|
+
packEstimatedTokens: estimateTokens(packChars),
|
|
104
|
+
estimateMethod: "chars_div_4",
|
|
105
|
+
selectedFields,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
const rawSummaryChars = JSON.stringify(payload).length;
|
|
109
|
+
return {
|
|
110
|
+
pack,
|
|
111
|
+
rawSummaryChars,
|
|
112
|
+
rawSummaryEstimatedTokens: estimateTokens(rawSummaryChars),
|
|
113
|
+
rawSummaryEstimateMethod: "chars_div_4",
|
|
114
|
+
reductionPercent: rawSummaryChars === 0 ? 0 : Math.round((1 - packChars / rawSummaryChars) * 10000) / 100,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export function criarContextPackAPartirDoResumo(input) {
|
|
118
|
+
return selecionarContexto({
|
|
119
|
+
geradoEm: input.resumo.geradoEm,
|
|
120
|
+
arquivo: input.resumo.arquivo,
|
|
121
|
+
modulo: input.resumo.modulo,
|
|
122
|
+
modo: input.modo,
|
|
123
|
+
tamanho: input.tamanho,
|
|
124
|
+
analiseDrift: input.analiseDrift,
|
|
125
|
+
guiaPorCapacidade: input.guiaPorCapacidade,
|
|
126
|
+
texto: input.texto,
|
|
127
|
+
resumo: input.resumo,
|
|
128
|
+
}, input.pedido);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=contextPack.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ResultadoDrift } from "./drift.part01.js";
|
|
2
|
+
export type DriftPack = {
|
|
3
|
+
schema: "sema.ai.drift-pack/v1";
|
|
4
|
+
selection: "deterministic_evidence_compaction";
|
|
5
|
+
source: {
|
|
6
|
+
command: "drift";
|
|
7
|
+
scope: string;
|
|
8
|
+
cache: string;
|
|
9
|
+
targetModule: string | null;
|
|
10
|
+
};
|
|
11
|
+
status: {
|
|
12
|
+
success: boolean;
|
|
13
|
+
score: number;
|
|
14
|
+
confidence: string;
|
|
15
|
+
belowFloor: boolean;
|
|
16
|
+
belowTarget: boolean;
|
|
17
|
+
blocks: string[];
|
|
18
|
+
};
|
|
19
|
+
counts: {
|
|
20
|
+
modules: number;
|
|
21
|
+
tasks: number;
|
|
22
|
+
validImplementations: number;
|
|
23
|
+
brokenImplementations: number;
|
|
24
|
+
validLinks: number;
|
|
25
|
+
brokenLinks: number;
|
|
26
|
+
outOfScopeLinks: number;
|
|
27
|
+
divergentRoutes: number;
|
|
28
|
+
validResources: number;
|
|
29
|
+
divergentResources: number;
|
|
30
|
+
realPersistence: number;
|
|
31
|
+
};
|
|
32
|
+
blockers: {
|
|
33
|
+
implementations: Array<Record<string, unknown>>;
|
|
34
|
+
links: Array<Record<string, unknown>>;
|
|
35
|
+
routes: Array<Record<string, unknown>>;
|
|
36
|
+
resources: Array<Record<string, unknown>>;
|
|
37
|
+
diagnostics: Array<Record<string, unknown>>;
|
|
38
|
+
tasksWithoutImplementation: Array<Record<string, unknown>>;
|
|
39
|
+
};
|
|
40
|
+
guidance: {
|
|
41
|
+
touchFirst: string[];
|
|
42
|
+
validate: string[];
|
|
43
|
+
loose: string[];
|
|
44
|
+
inferred: string[];
|
|
45
|
+
risks: string[];
|
|
46
|
+
};
|
|
47
|
+
authority: {
|
|
48
|
+
semaRemainsAuthority: true;
|
|
49
|
+
rawDriftForwarded: false;
|
|
50
|
+
freshValidationRequired: true;
|
|
51
|
+
omitted: string[];
|
|
52
|
+
};
|
|
53
|
+
telemetry: {
|
|
54
|
+
packChars: number;
|
|
55
|
+
packEstimatedTokens: number;
|
|
56
|
+
estimateMethod: "chars_div_4";
|
|
57
|
+
rawDriftEstimatedTokens: number;
|
|
58
|
+
reductionPercent: number;
|
|
59
|
+
selectedFields: string[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare function criarDriftPack(resultado: ResultadoDrift, options?: {
|
|
63
|
+
targetModule?: string;
|
|
64
|
+
rawDriftChars?: number;
|
|
65
|
+
}): DriftPack;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function estimarTokens(chars) {
|
|
2
|
+
return Math.ceil(chars / 4);
|
|
3
|
+
}
|
|
4
|
+
function compactarRegistro(registro, campos) {
|
|
5
|
+
return Object.fromEntries(campos
|
|
6
|
+
.filter((campo) => registro[campo] !== undefined && registro[campo] !== null)
|
|
7
|
+
.map((campo) => [campo, registro[campo]]));
|
|
8
|
+
}
|
|
9
|
+
export function criarDriftPack(resultado, options = {}) {
|
|
10
|
+
const targetModule = options.targetModule ?? null;
|
|
11
|
+
const tarefas = resultado.tasks
|
|
12
|
+
.filter((task) => !targetModule || task.modulo === targetModule)
|
|
13
|
+
.filter((task) => task.semImplementacao || task.implsQuebrados > 0 || task.lacunas.length > 0)
|
|
14
|
+
.map((task) => compactarRegistro(task, [
|
|
15
|
+
"modulo", "task", "impls", "implsValidos", "implsQuebrados", "semImplementacao", "scoreSemantico",
|
|
16
|
+
"confiancaVinculo", "riscoOperacional", "lacunas", "arquivosProvaveisEditar", "checksSugeridos",
|
|
17
|
+
]));
|
|
18
|
+
const base = {
|
|
19
|
+
schema: "sema.ai.drift-pack/v1",
|
|
20
|
+
selection: "deterministic_evidence_compaction",
|
|
21
|
+
source: {
|
|
22
|
+
command: "drift",
|
|
23
|
+
scope: resultado.escopo_aplicado.escopo,
|
|
24
|
+
cache: resultado.escopo_aplicado.cache?.modo ?? "unknown",
|
|
25
|
+
targetModule,
|
|
26
|
+
},
|
|
27
|
+
status: {
|
|
28
|
+
success: resultado.sucesso,
|
|
29
|
+
score: resultado.resumo_operacional.scoreMedio,
|
|
30
|
+
confidence: resultado.resumo_operacional.confiancaGeral,
|
|
31
|
+
belowFloor: resultado.resumo_operacional.pontuacaoAbaixoDoPiso,
|
|
32
|
+
belowTarget: resultado.resumo_operacional.pontuacaoAbaixoDoAlvo,
|
|
33
|
+
blocks: resultado.resumo_operacional.travasPontuacao,
|
|
34
|
+
},
|
|
35
|
+
counts: {
|
|
36
|
+
modules: resultado.modulos.length,
|
|
37
|
+
tasks: resultado.tasks.length,
|
|
38
|
+
validImplementations: resultado.impls_validos.length,
|
|
39
|
+
brokenImplementations: resultado.impls_quebrados.length,
|
|
40
|
+
validLinks: resultado.vinculos_validos.length,
|
|
41
|
+
brokenLinks: resultado.vinculos_quebrados.length,
|
|
42
|
+
outOfScopeLinks: resultado.vinculos_fora_do_escopo.length,
|
|
43
|
+
divergentRoutes: resultado.rotas_divergentes.length,
|
|
44
|
+
validResources: resultado.recursos_validos.length,
|
|
45
|
+
divergentResources: resultado.recursos_divergentes.length,
|
|
46
|
+
realPersistence: resultado.persistencia_real.length,
|
|
47
|
+
},
|
|
48
|
+
blockers: {
|
|
49
|
+
implementations: resultado.impls_quebrados.map((item) => compactarRegistro(item, ["modulo", "task", "origem", "caminho", "arquivo", "simbolo", "caminhoResolvido", "candidatos"])),
|
|
50
|
+
links: resultado.vinculos_quebrados.map((item) => compactarRegistro(item, ["modulo", "donoTipo", "dono", "tipo", "valor", "arquivo", "simbolo", "status", "confianca"])),
|
|
51
|
+
routes: resultado.rotas_divergentes.map((item) => compactarRegistro(item, ["modulo", "route", "metodo", "caminho", "motivo"])),
|
|
52
|
+
resources: resultado.recursos_divergentes.map((item) => compactarRegistro(item, ["modulo", "task", "categoria", "alvo", "arquivo", "origem", "tipo", "status"])),
|
|
53
|
+
diagnostics: resultado.diagnosticos.map((item) => compactarRegistro(item, ["tipo", "modulo", "task", "route", "arquivo", "severidade", "mensagem"])),
|
|
54
|
+
tasksWithoutImplementation: tarefas,
|
|
55
|
+
},
|
|
56
|
+
guidance: {
|
|
57
|
+
touchFirst: resultado.resumo_operacional.oQueTocar,
|
|
58
|
+
validate: resultado.resumo_operacional.oQueValidar,
|
|
59
|
+
loose: resultado.resumo_operacional.oQueEstaFrouxo,
|
|
60
|
+
inferred: resultado.resumo_operacional.oQueFoiInferido,
|
|
61
|
+
risks: resultado.resumo_operacional.riscosPrincipais,
|
|
62
|
+
},
|
|
63
|
+
authority: {
|
|
64
|
+
semaRemainsAuthority: true,
|
|
65
|
+
rawDriftForwarded: false,
|
|
66
|
+
freshValidationRequired: true,
|
|
67
|
+
omitted: [
|
|
68
|
+
"implementações válidas detalhadas",
|
|
69
|
+
"vínculos válidos detalhados",
|
|
70
|
+
"catálogo de arquivos e bytes lidos",
|
|
71
|
+
"cache interno e candidatos não bloqueantes",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const packChars = JSON.stringify(base).length;
|
|
76
|
+
const rawDriftChars = options.rawDriftChars ?? 0;
|
|
77
|
+
return {
|
|
78
|
+
...base,
|
|
79
|
+
telemetry: {
|
|
80
|
+
packChars,
|
|
81
|
+
packEstimatedTokens: estimarTokens(packChars),
|
|
82
|
+
estimateMethod: "chars_div_4",
|
|
83
|
+
rawDriftEstimatedTokens: estimarTokens(rawDriftChars),
|
|
84
|
+
reductionPercent: rawDriftChars === 0 ? 0 : Math.round((1 - packChars / rawDriftChars) * 10000) / 100,
|
|
85
|
+
selectedFields: [
|
|
86
|
+
"source",
|
|
87
|
+
"status",
|
|
88
|
+
"counts",
|
|
89
|
+
"blockers",
|
|
90
|
+
"guidance",
|
|
91
|
+
"authority",
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=driftPack.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AgentContextPack, CapacidadeIa } from "./agentContextTipos.js";
|
|
2
|
+
export type EntrypointPack = {
|
|
3
|
+
schema: "sema.ai.entrypoint-pack/v1";
|
|
4
|
+
selection: "deterministic_capacity_allowlist";
|
|
5
|
+
capacity: CapacidadeIa;
|
|
6
|
+
source: {
|
|
7
|
+
command: "contexto-ia";
|
|
8
|
+
entrypoint: string;
|
|
9
|
+
version: number;
|
|
10
|
+
};
|
|
11
|
+
context: {
|
|
12
|
+
objective: string;
|
|
13
|
+
readingOrder: string[];
|
|
14
|
+
capacityGuide: string[];
|
|
15
|
+
mandatoryRules: string[];
|
|
16
|
+
prohibitions: string[];
|
|
17
|
+
priorities: string[];
|
|
18
|
+
failClosed: string[];
|
|
19
|
+
policies: {
|
|
20
|
+
language: string;
|
|
21
|
+
governedCode: string;
|
|
22
|
+
timeout: string;
|
|
23
|
+
platform: string;
|
|
24
|
+
design: string;
|
|
25
|
+
};
|
|
26
|
+
onDemand: string[];
|
|
27
|
+
};
|
|
28
|
+
authority: {
|
|
29
|
+
semaRemainsAuthority: true;
|
|
30
|
+
rawAgentContextForwarded: false;
|
|
31
|
+
freshValidationRequired: true;
|
|
32
|
+
omitted: string[];
|
|
33
|
+
};
|
|
34
|
+
telemetry: {
|
|
35
|
+
packChars: number;
|
|
36
|
+
packEstimatedTokens: number;
|
|
37
|
+
estimateMethod: "chars_div_4";
|
|
38
|
+
rawAgentContextEstimatedTokens: number;
|
|
39
|
+
reductionPercent: number;
|
|
40
|
+
selectedFields: string[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function criarEntrypointPack(input: {
|
|
44
|
+
agentContextPack: AgentContextPack;
|
|
45
|
+
capacity: CapacidadeIa;
|
|
46
|
+
rawAgentContextChars?: number;
|
|
47
|
+
}): EntrypointPack;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function estimarTokens(chars) {
|
|
2
|
+
return Math.ceil(chars / 4);
|
|
3
|
+
}
|
|
4
|
+
export function criarEntrypointPack(input) {
|
|
5
|
+
const source = input.agentContextPack;
|
|
6
|
+
const base = {
|
|
7
|
+
schema: "sema.ai.entrypoint-pack/v1",
|
|
8
|
+
selection: "deterministic_capacity_allowlist",
|
|
9
|
+
capacity: input.capacity,
|
|
10
|
+
source: {
|
|
11
|
+
command: "contexto-ia",
|
|
12
|
+
entrypoint: source.entrypointCodex,
|
|
13
|
+
version: source.versao,
|
|
14
|
+
},
|
|
15
|
+
context: {
|
|
16
|
+
objective: source.objetivo,
|
|
17
|
+
readingOrder: source.ordemLeitura,
|
|
18
|
+
capacityGuide: source.guiaPorCapacidade[input.capacity],
|
|
19
|
+
mandatoryRules: source.regrasObrigatorias,
|
|
20
|
+
prohibitions: source.proibicoes,
|
|
21
|
+
priorities: source.prioridades,
|
|
22
|
+
failClosed: source.failClosed,
|
|
23
|
+
policies: {
|
|
24
|
+
language: source.politicaIdioma.regra,
|
|
25
|
+
governedCode: source.politicaCodigoGovernado.porCapacidade[input.capacity],
|
|
26
|
+
timeout: source.politicaTimeoutResumo.porCapacidade[input.capacity],
|
|
27
|
+
platform: source.politicaPlataforma.porCapacidade[input.capacity],
|
|
28
|
+
design: source.politicaDesignVisual.porCapacidade[input.capacity],
|
|
29
|
+
},
|
|
30
|
+
onDemand: [
|
|
31
|
+
"AGENTS.md",
|
|
32
|
+
"SEMA_BOOT.md",
|
|
33
|
+
"AGENT_CONTEXT_PACK.json",
|
|
34
|
+
"SEMA_INDEX.json",
|
|
35
|
+
"exemplos/",
|
|
36
|
+
"contratos/",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
authority: {
|
|
40
|
+
semaRemainsAuthority: true,
|
|
41
|
+
rawAgentContextForwarded: false,
|
|
42
|
+
freshValidationRequired: true,
|
|
43
|
+
omitted: [
|
|
44
|
+
"fontes e descoberta completas",
|
|
45
|
+
"exemplos oficiais completos",
|
|
46
|
+
"texto bruto sob demanda",
|
|
47
|
+
"guias e aliases de outras capacidades",
|
|
48
|
+
"políticas duplicadas fora da capacidade selecionada",
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const packChars = JSON.stringify(base).length;
|
|
53
|
+
const rawAgentContextChars = input.rawAgentContextChars ?? 0;
|
|
54
|
+
return {
|
|
55
|
+
...base,
|
|
56
|
+
telemetry: {
|
|
57
|
+
packChars,
|
|
58
|
+
packEstimatedTokens: estimarTokens(packChars),
|
|
59
|
+
estimateMethod: "chars_div_4",
|
|
60
|
+
rawAgentContextEstimatedTokens: estimarTokens(rawAgentContextChars),
|
|
61
|
+
reductionPercent: rawAgentContextChars === 0 ? 0 : Math.round((1 - packChars / rawAgentContextChars) * 10000) / 100,
|
|
62
|
+
selectedFields: [
|
|
63
|
+
"capacity",
|
|
64
|
+
"source",
|
|
65
|
+
"context.objective",
|
|
66
|
+
"context.readingOrder",
|
|
67
|
+
"context.capacityGuide",
|
|
68
|
+
"context.mandatoryRules",
|
|
69
|
+
"context.prohibitions",
|
|
70
|
+
"context.priorities",
|
|
71
|
+
"context.failClosed",
|
|
72
|
+
"context.policies",
|
|
73
|
+
"context.onDemand",
|
|
74
|
+
"authority",
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=entrypointPack.js.map
|
package/dist/index.part05.js
CHANGED
|
@@ -8,9 +8,10 @@ import { importarProjetoLegado, resumoImportacao } from "./importador.js";
|
|
|
8
8
|
import { analisarDriftLegado, assistirRenomeacaoSemantica, gerarMapaImpactoSemantico, } from "./drift.js";
|
|
9
9
|
import { escreverArquivos, formatarAvisoArtefatosGeradosAcimaDoLimite, } from './fsGovernado.js';
|
|
10
10
|
import { carregarModulos } from './carregarModulos.js';
|
|
11
|
-
import { obterOpcao } from './cliArgs.js';
|
|
11
|
+
import { obterOpcao, possuiFlag } from './cliArgs.js';
|
|
12
12
|
import { resumirDriftPorModulo } from "./index.part03.js";
|
|
13
13
|
import { resolverAnaliseDriftConsultaCli, resolverOpcoesDriftCli } from "./index.part01.js";
|
|
14
|
+
import { criarDriftPack } from "./driftPack.js";
|
|
14
15
|
export async function comandoInspecionar(entrada, emJson, cwd = process.cwd(), args = []) {
|
|
15
16
|
const analiseDrift = resolverAnaliseDriftConsultaCli(args, "inspecionar");
|
|
16
17
|
const alvo = entrada ? path.resolve(cwd, entrada) : cwd;
|
|
@@ -135,6 +136,11 @@ export async function comandoDrift(entrada, args, emJson, cwd = process.cwd()) {
|
|
|
135
136
|
adiarDescobertaCodigo: opcoes.escopo !== "projeto",
|
|
136
137
|
});
|
|
137
138
|
const resultado = await analisarDriftLegado(contextoProjeto, opcoes);
|
|
139
|
+
if (possuiFlag(args, "--pacote")) {
|
|
140
|
+
const pacote = criarDriftPack(resultado, { rawDriftChars: JSON.stringify(resultado).length });
|
|
141
|
+
console.log(JSON.stringify(pacote, null, 2));
|
|
142
|
+
return resultado.sucesso ? 0 : 1;
|
|
143
|
+
}
|
|
138
144
|
if (emJson) {
|
|
139
145
|
console.log(JSON.stringify(resultado, null, 2));
|
|
140
146
|
return resultado.sucesso ? 0 : 1;
|