@semacode/cli 3.13.1 → 4.1.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.
Files changed (76) hide show
  1. package/dist/cliGrammar.js +16 -5
  2. package/dist/cliHelpTexto.js +4 -3
  3. package/dist/contextPack.d.ts +75 -0
  4. package/dist/contextPack.js +133 -0
  5. package/dist/driftPack.d.ts +65 -0
  6. package/dist/driftPack.js +96 -0
  7. package/dist/entrypointPack.d.ts +47 -0
  8. package/dist/entrypointPack.js +79 -0
  9. package/dist/index.part05.js +7 -1
  10. package/dist/index.part06.js +48 -17
  11. package/dist/index.part07.d.ts +1 -1
  12. package/dist/index.part07.js +16 -2
  13. package/dist/index.part08.js +1 -1
  14. package/dist/indexPack.d.ts +54 -0
  15. package/dist/indexPack.js +146 -0
  16. package/dist/init/templates.part01.js +393 -393
  17. package/dist/init/templates.part02.js +189 -189
  18. package/dist/initTemplatesBackend.js +73 -73
  19. package/dist/initTemplatesFlutter.js +137 -137
  20. package/dist/initTemplatesRuntime.js +350 -350
  21. package/dist/initTemplatesWeb.js +309 -309
  22. package/dist/sync/index.js +35 -35
  23. package/docs/auth.md +26 -26
  24. package/docs/database.md +15 -15
  25. package/docs/env.md +16 -16
  26. package/docs/frontend.md +41 -41
  27. package/docs/i18n.md +15 -15
  28. package/exemplos/agendamento.sema +1 -1
  29. package/exemplos/assinatura.sema +1 -1
  30. package/exemplos/auditoria.sema +1 -1
  31. package/exemplos/autenticacao.sema +1 -1
  32. package/exemplos/author_obra_comum.sema +1 -1
  33. package/exemplos/author_tema_sensivel.sema +1 -1
  34. package/exemplos/automacao.sema +1 -1
  35. package/exemplos/cadastro_usuario.sema +1 -1
  36. package/exemplos/calculadora.sema +1 -1
  37. package/exemplos/crud_simples.sema +1 -1
  38. package/exemplos/estoque.sema +1 -1
  39. package/exemplos/exportacao.sema +1 -1
  40. package/exemplos/fila.sema +1 -1
  41. package/exemplos/integracao_externa.sema +1 -1
  42. package/exemplos/multi_tenant.sema +1 -1
  43. package/exemplos/notificacao.sema +1 -1
  44. package/exemplos/operacao_estrategia.sema +132 -132
  45. package/exemplos/operacao_estrategia_discovery.sema +220 -220
  46. package/exemplos/operacao_estrategia_fluxo.sema +114 -114
  47. package/exemplos/operacao_estrategia_gates.sema +106 -106
  48. package/exemplos/operacao_estrategia_quarentena.sema +133 -133
  49. package/exemplos/operacao_estrategia_rollout.sema +124 -124
  50. package/exemplos/pagamento.sema +1 -1
  51. package/exemplos/pagamento_dominio.sema +1 -1
  52. package/exemplos/pedido.sema +1 -1
  53. package/exemplos/permissao.sema +1 -1
  54. package/exemplos/persistencia_vendor_first.sema +1 -1
  55. package/exemplos/php_crud.sema +170 -170
  56. package/exemplos/profile_conversas.sema +165 -165
  57. package/exemplos/profile_game.sema +1 -1
  58. package/exemplos/profile_legal.sema +1 -1
  59. package/exemplos/profile_ops.sema +1 -1
  60. package/exemplos/profile_research.sema +1 -1
  61. package/exemplos/profile_software.sema +1 -1
  62. package/exemplos/profile_workflow_n8n.sema +1 -1
  63. package/exemplos/relatorio.sema +1 -1
  64. package/exemplos/replica_analitica_erp.sema +1 -1
  65. package/exemplos/testes_embutidos.sema +1 -1
  66. package/exemplos/tratamento_erro.sema +1 -1
  67. package/exemplos/upload_arquivo.sema +1 -1
  68. package/exemplos/webhook.sema +1 -1
  69. package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
  70. package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
  71. package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
  72. package/node_modules/@sema/gerador-html/dist/index.js +17 -17
  73. package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
  74. package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
  75. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
  76. package/package.json +1 -1
@@ -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,21 @@ 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
- return tamanhos.length <= 1 && (!modo || MODOS_RESUMO.has(modo)) && (promptCurto || validarModoCache(parsed, "--drift"));
428
+ const pacote = parsed.flags.has("--pacote");
429
+ const somentePacote = parsed.flags.has("--somente-pacote");
430
+ const pedido = valorOpcao(parsed, "--pedido");
431
+ return tamanhos.length <= 1
432
+ && (!modo || MODOS_RESUMO.has(modo))
433
+ && (promptCurto || validarModoCache(parsed, "--drift"))
434
+ && (promptCurto ? !pacote && !pedido && !somentePacote : true);
428
435
  }
429
436
  function validarComandoBasico(comando, args) {
430
437
  const aliasesGeracao = { "-a": "--alvo", "-s": "--saida" };
@@ -433,7 +440,11 @@ function validarComandoBasico(comando, args) {
433
440
  case "ast":
434
441
  case "ir":
435
442
  case "diagnosticos": return parsearArgumentos(args, { minPosicionais: 1, maxPosicionais: 1 }) !== null;
436
- case "contexto-ia": return parsearArgumentos(args, { opcoes: ["--saida"], minPosicionais: 1, maxPosicionais: 1 }) !== null;
443
+ case "contexto-ia": {
444
+ const parsed = parsearArgumentos(args, { opcoes: ["--saida", "--capacidade"], flags: ["--pacote"], minPosicionais: 1, maxPosicionais: 1 });
445
+ const capacidade = parsed ? valorOpcao(parsed, "--capacidade") : undefined;
446
+ return parsed !== null && (!capacidade || CAPACIDADES_IA.has(capacidade));
447
+ }
437
448
  case "compilar":
438
449
  case "testar": {
439
450
  const parsed = parsearArgumentos(args, { opcoes: ["--alvo", "--saida", "--estrutura", "--framework"], aliases: aliasesGeracao, minPosicionais: comando === "testar" ? 1 : 0, maxPosicionais: 1 });
@@ -458,7 +469,7 @@ function validarComandoBasico(comando, args) {
458
469
  return parsed !== null && validarModoCache(parsed, "--drift");
459
470
  }
460
471
  case "drift": {
461
- const parsed = parsearArgumentos(args, { opcoes: ["--escopo", "--cache", "--drift"], flags: ["--incluir-worktrees", "--incluir-consumidores-laterais"], maxPosicionais: 1 });
472
+ const parsed = parsearArgumentos(args, { opcoes: ["--escopo", "--cache", "--drift"], flags: ["--incluir-worktrees", "--incluir-consumidores-laterais", "--pacote"], maxPosicionais: 1 });
462
473
  const escopo = parsed ? valorOpcao(parsed, "--escopo") : undefined;
463
474
  return parsed !== null && (!escopo || ESCOPOS.has(escopo)) && validarModoCache(parsed, "--cache");
464
475
  }
@@ -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 --json (compactação determinística automática; use --pedido para focar a seleção)",
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] [--pedido <intencao>] [--somente-pacote] [--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,133 @@
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
+ if (request.startsWith("resumo:"))
19
+ return tasks.slice(0, 8);
20
+ const requestTokens = new Set(normalizedTokens(request));
21
+ const intentRoots = ["cancel", "notific", "export", "reagend", "registr", "consult"];
22
+ const rootedMatches = intentRoots
23
+ .filter((root) => [...requestTokens].some((token) => token.startsWith(root)))
24
+ .flatMap((root) => tasks.filter((task) => normalizedTokens(task).some((token) => token.startsWith(root))));
25
+ if (rootedMatches.length > 0)
26
+ return [...new Set(rootedMatches)];
27
+ const scored = tasks.map((task, index) => {
28
+ const taskTokens = normalizedTokens(task);
29
+ const score = taskTokens.reduce((total, token) => total + (requestTokens.has(token) ? 1 : 0), 0);
30
+ return { task, index, score };
31
+ });
32
+ const selected = scored
33
+ .filter((item) => item.score > 0)
34
+ .sort((a, b) => b.score - a.score || a.index - b.index)
35
+ .map((item) => item.task);
36
+ return selected.length > 0 ? selected : tasks.slice(0, 3);
37
+ }
38
+ function estimateTokens(chars) {
39
+ return Math.ceil(chars / 4);
40
+ }
41
+ export function selecionarContexto(payload, request) {
42
+ const resumo = payload.resumo ?? {};
43
+ const context = {
44
+ module: text(resumo.modulo) ?? text(payload.modulo),
45
+ purpose: text(resumo.faz),
46
+ relevantTasks: selectRelevantTasks(list(resumo.tarefasPrincipais), request),
47
+ criticalRules: list(resumo.regrasCriticas),
48
+ effects: list(resumo.efeitos),
49
+ entities: list(resumo.entidadesAfetadas),
50
+ risks: list(resumo.riscosPrincipais),
51
+ likelyFiles: list(resumo.arquivosProvaveis),
52
+ requiredChecks: list(resumo.checksSugeridos),
53
+ minimumTests: list(resumo.testesMinimos),
54
+ compatibilityProfile: text(resumo.perfilCompatibilidade),
55
+ knownGaps: list(resumo.lacunas),
56
+ };
57
+ const packWithoutTelemetry = {
58
+ schema: "sema.ai.context-pack/v1",
59
+ selection: "deterministic_allowlist",
60
+ request,
61
+ source: {
62
+ command: "resumo",
63
+ mode: text(payload.modo) ?? "mudanca",
64
+ size: text(payload.tamanho) ?? "micro",
65
+ drift: text(payload.analiseDrift?.modo) ?? "none",
66
+ generatedAt: text(resumo.geradoEm) ?? text(payload.geradoEm),
67
+ contract: text(resumo.arquivo) ?? text(payload.arquivo),
68
+ },
69
+ context,
70
+ authority: {
71
+ semaRemainsAuthority: true,
72
+ rawSummaryForwarded: false,
73
+ executionRequiresFreshValidation: true,
74
+ omitted: [
75
+ "cli_result_envelope",
76
+ "guiaPorCapacidade",
77
+ "texto_bruto_do_resumo",
78
+ "metadados_fora_do_escopo",
79
+ ],
80
+ },
81
+ };
82
+ const packChars = JSON.stringify(packWithoutTelemetry).length;
83
+ const selectedFields = [
84
+ "request",
85
+ "source.module",
86
+ "source.contract",
87
+ "context.module",
88
+ "context.purpose",
89
+ "context.relevantTasks",
90
+ "context.criticalRules",
91
+ "context.effects",
92
+ "context.entities",
93
+ "context.risks",
94
+ "context.likelyFiles",
95
+ "context.requiredChecks",
96
+ "context.minimumTests",
97
+ "context.compatibilityProfile",
98
+ "context.knownGaps",
99
+ "authority",
100
+ ];
101
+ const pack = {
102
+ ...packWithoutTelemetry,
103
+ telemetry: {
104
+ packChars,
105
+ packEstimatedTokens: estimateTokens(packChars),
106
+ estimateMethod: "chars_div_4",
107
+ selectedFields,
108
+ },
109
+ };
110
+ const rawSummaryChars = JSON.stringify(payload).length;
111
+ return {
112
+ pack,
113
+ rawSummaryChars,
114
+ rawSummaryEstimatedTokens: estimateTokens(rawSummaryChars),
115
+ rawSummaryEstimateMethod: "chars_div_4",
116
+ reductionPercent: rawSummaryChars === 0 ? 0 : Math.round((1 - packChars / rawSummaryChars) * 10000) / 100,
117
+ };
118
+ }
119
+ export function criarContextPackAPartirDoResumo(input) {
120
+ const pedido = input.pedido?.trim() || `resumo:${input.tamanho}`;
121
+ return selecionarContexto({
122
+ geradoEm: input.resumo.geradoEm,
123
+ arquivo: input.resumo.arquivo,
124
+ modulo: input.resumo.modulo,
125
+ modo: input.modo,
126
+ tamanho: input.tamanho,
127
+ analiseDrift: input.analiseDrift,
128
+ guiaPorCapacidade: input.guiaPorCapacidade,
129
+ texto: input.texto,
130
+ resumo: input.resumo,
131
+ }, pedido);
132
+ }
133
+ //# 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
@@ -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;