@semacode/cli 4.2.3 → 4.2.4
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/agentBootstrap.js +2 -1
- package/dist/agentContextPack.js +3 -27
- package/dist/agentContextTipos.d.ts +1 -1
- package/dist/agentContextTipos.js +0 -4
- package/dist/agentEntryPoints.js +24 -6
- package/dist/agentProtocol.js +1 -2
- package/dist/comandoSessao.js +9 -5
- package/dist/contextDelivery.d.ts +13 -0
- package/dist/contextDelivery.js +105 -0
- package/dist/iaPrompts.d.ts +2 -2
- package/dist/iaPrompts.js +17 -103
- package/dist/index.part02.js +1 -1
- package/dist/index.part03.d.ts +1 -1
- package/dist/index.part03.js +18 -34
- package/dist/index.part04.d.ts +1 -1
- package/dist/index.part04.js +28 -157
- package/dist/index.part06.js +24 -19
- package/dist/index.part07.js +26 -62
- package/dist/initTemplatesBase.js +2 -1
- package/docs/commands.md +18 -13
- package/docs/syntax.md +3 -3
- package/package.json +1 -1
- package/skills/sema/SKILL.md +3 -1
package/dist/index.part03.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.governanca_ia_contexto, sema.produto.escrita_segura_workspace, sema.produto.governanca_ia.drift.cache.modos
|
|
2
|
+
// Descricao: CLI particionada com saidas de contexto escritas por lote validado e troca atomica.
|
|
3
|
+
import { selecionarContextoAtivo, arquivarResumosLegados, ARQUIVOS_CONTEXTO_MODULO } from "./contextDelivery.js";
|
|
1
4
|
import path from "node:path";
|
|
2
5
|
import { temErros, } from "@sema/nucleo";
|
|
3
|
-
import { carregarProjeto, } from "./projeto.js";
|
|
6
|
+
import { carregarConfiguracaoProjeto, carregarProjeto, } from "./projeto.js";
|
|
4
7
|
import { analisarDriftLegado, } from "./drift.js";
|
|
5
|
-
import { ARQUIVO_AGENT_CONTEXT_PACK,
|
|
6
|
-
import {
|
|
8
|
+
import { ARQUIVO_AGENT_CONTEXT_PACK, CAPACIDADES_IA_OPERACIONAIS, } from './agentContextTipos.js';
|
|
9
|
+
import { criarGuiaCapacidadeIa } from './agentContextPack.js';
|
|
7
10
|
import { criarEntradaCanonicaProjeto } from './agentContext.js';
|
|
8
|
-
import { renderizarSemaBoot, renderizarSemaSmallModel, } from './agentEntryPoints.js';
|
|
9
11
|
import { escreverArquivoWorkspaceSeguro, validarDestinosEscritaWorkspace } from './workspaceWrite.js';
|
|
10
12
|
import { resumirListaTexto } from './textoListas.js';
|
|
11
|
-
import { coletarResumoSemanticoModulo,
|
|
13
|
+
import { coletarResumoSemanticoModulo, renderizarResumoModuloTexto } from "./index.part02.js";
|
|
12
14
|
export function renderizarResumoProjetoMarkdown(geradoEm, modulos, guiaPorCapacidade) {
|
|
13
15
|
const entradaCanonica = criarEntradaCanonicaProjeto(guiaPorCapacidade);
|
|
14
16
|
const agentContextPack = entradaCanonica.agentContextPack;
|
|
@@ -404,43 +406,25 @@ export async function carregarContextoModuloIa(arquivoEntrada, analiseDrift = AN
|
|
|
404
406
|
briefing,
|
|
405
407
|
};
|
|
406
408
|
}
|
|
407
|
-
export const ARQUIVOS_RESUMO_MODULO_IA = [
|
|
408
|
-
ARQUIVO_SEMA_BOOT,
|
|
409
|
-
ARQUIVO_SEMA_SMALL_MODEL,
|
|
410
|
-
"agent-context-pack.json",
|
|
411
|
-
"resumo.micro.txt",
|
|
412
|
-
"resumo.curto.txt",
|
|
413
|
-
"resumo.md",
|
|
414
|
-
"briefing.min.json",
|
|
415
|
-
"prompt-curto.txt",
|
|
416
|
-
];
|
|
409
|
+
export const ARQUIVOS_RESUMO_MODULO_IA = [...ARQUIVOS_CONTEXTO_MODULO];
|
|
417
410
|
export async function gerarArquivosResumoModuloIa(contexto, pastaBase) {
|
|
418
411
|
const guiaPorCapacidade = criarGuiaCapacidadeIa();
|
|
419
412
|
const resumoSemantico = coletarResumoSemanticoModulo(contexto);
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
const artefatos = [
|
|
429
|
-
{ caminhoRelativo: ARQUIVO_SEMA_BOOT, conteudo: semaBoot },
|
|
430
|
-
{ caminhoRelativo: ARQUIVO_SEMA_SMALL_MODEL, conteudo: semaSmallModel },
|
|
431
|
-
{ caminhoRelativo: "agent-context-pack.json", conteudo: `${JSON.stringify(agentContextPack, null, 2)}\n` },
|
|
432
|
-
{ caminhoRelativo: "resumo.micro.txt", conteudo: resumoMicro },
|
|
433
|
-
{ caminhoRelativo: "resumo.curto.txt", conteudo: resumoCurto },
|
|
434
|
-
{ caminhoRelativo: "resumo.md", conteudo: resumoMarkdown },
|
|
435
|
-
{ caminhoRelativo: "briefing.min.json", conteudo: `${JSON.stringify(briefingMinimo, null, 2)}\n` },
|
|
436
|
-
{ caminhoRelativo: "prompt-curto.txt", conteudo: promptCurto },
|
|
437
|
-
];
|
|
413
|
+
const configuracao = await carregarConfiguracaoProjeto(contexto.arquivo);
|
|
414
|
+
const baseProjeto = configuracao?.baseDiretorio ?? process.cwd();
|
|
415
|
+
const selecionado = await selecionarContextoAtivo(baseProjeto, {
|
|
416
|
+
micro: renderizarResumoModuloTexto(resumoSemantico, "micro", "resumo"),
|
|
417
|
+
curto: renderizarResumoModuloTexto(resumoSemantico, "curto", "resumo"),
|
|
418
|
+
medio: renderizarResumoModuloTexto(resumoSemantico, "medio", "resumo"),
|
|
419
|
+
}, "modulo");
|
|
420
|
+
const artefatos = selecionado ? [selecionado] : [];
|
|
438
421
|
await validarDestinosEscritaWorkspace(pastaBase, artefatos.map((artefato) => artefato.caminhoRelativo));
|
|
422
|
+
await arquivarResumosLegados(pastaBase);
|
|
439
423
|
for (const artefato of artefatos) {
|
|
440
424
|
await escreverArquivoWorkspaceSeguro(pastaBase, artefato.caminhoRelativo, artefato.conteudo, { sobrescrever: true });
|
|
441
425
|
}
|
|
442
426
|
return {
|
|
443
|
-
artefatosCompactos:
|
|
427
|
+
artefatosCompactos: artefatos.map(item => item.caminhoRelativo),
|
|
444
428
|
guiaPorCapacidade,
|
|
445
429
|
};
|
|
446
430
|
}
|
package/dist/index.part04.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type GuiaCapacidadeIaMap } from './agentContextTipos.js';
|
|
2
2
|
import { ContextoIaGerado, ResumoSemanticoModuloIa, type ResultadoDriftIa } from "./index.part01.js";
|
|
3
3
|
import type { ResolucaoModoCacheDrift } from "./driftCacheModes.js";
|
|
4
|
-
export declare const ARQUIVOS_RESUMO_PROJETO_IA: readonly ["SEMA_BOOT.md", "
|
|
4
|
+
export declare const ARQUIVOS_RESUMO_PROJETO_IA: readonly ["SEMA_BOOT.md", "SEMA_BRIEF.micro.txt", "SEMA_BRIEF.curto.txt", "SEMA_BRIEF.md", "SEMA_INDEX.json", "AGENT_CONTEXT_PACK.json", "docs/ai-integration.md"];
|
|
5
5
|
export declare function verificarFrescorArtefatos(baseProjeto: string): Promise<{
|
|
6
6
|
fresco: boolean;
|
|
7
7
|
hashArtefato: string | null;
|
package/dist/index.part04.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { lerPerfilContexto } from "./contextBudget.js";
|
|
2
|
+
import { selecionarContextoAtivo, arquivarResumosLegados, ARQUIVOS_CONTEXTO_PROJETO } from "./contextDelivery.js";
|
|
1
3
|
// SEMA-GOVERNED: sema.governanca_ia_contexto, sema.produto.escrita_segura_workspace, sema.produto.governanca_ia.drift.cache.modos
|
|
2
4
|
// Descrição: gera contexto local e grava artefatos somente dentro da base validada.
|
|
3
5
|
import { mkdir, readFile } from "node:fs/promises";
|
|
@@ -10,10 +12,10 @@ import { carregarProjeto, } from "./projeto.js";
|
|
|
10
12
|
import { analisarDriftLegado, } from "./drift.js";
|
|
11
13
|
import { compactarDocumentoObrigatorio, resolverDocumentacaoObrigatoria, verificarDocumentacaoMudanca, } from "./docs.js";
|
|
12
14
|
import { LIMITE_AVISO_LINHAS_CODIGO_GOVERNADO, LIMITE_AVISO_LINHAS_CONTRATO_SEMA, LIMITE_BLOQUEIO_LINHAS_CODIGO_GOVERNADO, LIMITE_BLOQUEIO_LINHAS_CONTRATO_SEMA, } from "./driftOrcamento.js";
|
|
13
|
-
import { ARQUIVO_AGENT_CONTEXT_PACK, ARQUIVO_DOC_AGENTES_CAPACIDADE, ARQUIVO_SEMA_BOOT,
|
|
15
|
+
import { ARQUIVO_AGENT_CONTEXT_PACK, ARQUIVO_DOC_AGENTES_CAPACIDADE, ARQUIVO_SEMA_BOOT, } from './agentContextTipos.js';
|
|
14
16
|
import { criarGuiaCapacidadeIa, LIMITE_CARACTERES_PAYLOAD_INLINE } from './agentContextPack.js';
|
|
15
17
|
import { criarEntradaCanonicaProjeto } from './agentContext.js';
|
|
16
|
-
import { renderizarDocumentoAgentesPorCapacidade, renderizarSemaBoot,
|
|
18
|
+
import { renderizarDocumentoAgentesPorCapacidade, renderizarSemaBoot, } from './agentEntryPoints.js';
|
|
17
19
|
import { escreverArquivoWorkspaceSeguro, validarDestinosEscritaWorkspace } from './workspaceWrite.js';
|
|
18
20
|
import { carregarModulos } from './carregarModulos.js';
|
|
19
21
|
import { obterOpcao, obterOpcoesRepetidas, possuiFlag } from './cliArgs.js';
|
|
@@ -21,13 +23,10 @@ import { resumirListaTexto, unicosOrdenados } from './textoListas.js';
|
|
|
21
23
|
import { EXTENSOES_CODIGO, listarArquivosRecursivosLimitado } from './projetoBusca.js';
|
|
22
24
|
import { VERSAO_CLI } from "./index.part01.js";
|
|
23
25
|
import { coletarResumoSemanticoModulo, descreverFontesConclusao, detectarFontesConclusaoSnapshot, detectarModoVerificacaoCodigo } from "./index.part02.js";
|
|
24
|
-
import { ARQUIVOS_RESUMO_MODULO_IA, carregarContextoModuloIa, criarBriefingAgente, criarBriefingAgenteContratos, gerarArquivosResumoModuloIa,
|
|
26
|
+
import { ARQUIVOS_RESUMO_MODULO_IA, carregarContextoModuloIa, criarBriefingAgente, criarBriefingAgenteContratos, gerarArquivosResumoModuloIa, resumirDriftPorModulo } from "./index.part03.js";
|
|
25
27
|
export const ARQUIVOS_RESUMO_PROJETO_IA = [
|
|
26
28
|
ARQUIVO_SEMA_BOOT,
|
|
27
|
-
|
|
28
|
-
"SEMA_BRIEF.md",
|
|
29
|
-
"SEMA_BRIEF.micro.txt",
|
|
30
|
-
"SEMA_BRIEF.curto.txt",
|
|
29
|
+
...ARQUIVOS_CONTEXTO_PROJETO,
|
|
31
30
|
"SEMA_INDEX.json",
|
|
32
31
|
ARQUIVO_AGENT_CONTEXT_PACK,
|
|
33
32
|
ARQUIVO_DOC_AGENTES_CAPACIDADE,
|
|
@@ -73,8 +72,10 @@ async function calcularHashContratos(caminhosContratos, baseProjeto) {
|
|
|
73
72
|
export async function verificarFrescorArtefatos(baseProjeto) {
|
|
74
73
|
const caminhoIndex = path.join(baseProjeto, "SEMA_INDEX.json");
|
|
75
74
|
let hashArtefato = null;
|
|
75
|
+
let perfilArtefato = undefined;
|
|
76
76
|
try {
|
|
77
77
|
const index = JSON.parse(await readFile(caminhoIndex, "utf8"));
|
|
78
|
+
perfilArtefato = index.perfilContexto;
|
|
78
79
|
hashArtefato = index.hashContratos ?? null;
|
|
79
80
|
}
|
|
80
81
|
catch {
|
|
@@ -86,6 +87,9 @@ export async function verificarFrescorArtefatos(baseProjeto) {
|
|
|
86
87
|
const hashAtual = await calcularHashContratos(contratos, baseProjeto);
|
|
87
88
|
const protocoloPendente = await arquivosProtocoloDesatualizados(baseProjeto);
|
|
88
89
|
const contratosMudaram = hashArtefato !== hashAtual;
|
|
90
|
+
const perfilMudou = perfilArtefato !== undefined && JSON.stringify(perfilArtefato) !== JSON.stringify(await lerPerfilContexto(baseProjeto) ?? null);
|
|
91
|
+
if (perfilMudou)
|
|
92
|
+
protocoloPendente.push(".sema/contexto-ia.json");
|
|
89
93
|
const fresco = !contratosMudaram && protocoloPendente.length === 0;
|
|
90
94
|
return {
|
|
91
95
|
fresco,
|
|
@@ -161,9 +165,7 @@ export async function gerarResumoProjetoIa(entrada, pastaSaidaOpcional, escrever
|
|
|
161
165
|
? path.resolve(pastaSaidaOpcional)
|
|
162
166
|
: path.resolve(baseProjeto, ".tmp", "sema-resumo");
|
|
163
167
|
await mkdir(pastaSaida, { recursive: true });
|
|
164
|
-
const semaBrief = renderizarResumoProjetoMarkdown(geradoEm, modulos, guiaPorCapacidade);
|
|
165
168
|
const semaBoot = renderizarSemaBoot(agentContextPack);
|
|
166
|
-
const semaSmallModel = renderizarSemaSmallModel(agentContextPack);
|
|
167
169
|
const docAgentesCapacidade = renderizarDocumentoAgentesPorCapacidade(agentContextPack);
|
|
168
170
|
const caminhosContratos = contextoProjeto.modulosSelecionados.map((item) => item.caminho);
|
|
169
171
|
const hashContratos = await calcularHashContratos(caminhosContratos, contextoProjeto.baseProjeto);
|
|
@@ -171,6 +173,7 @@ export async function gerarResumoProjetoIa(entrada, pastaSaidaOpcional, escrever
|
|
|
171
173
|
comando: "resumo-projeto",
|
|
172
174
|
geradoEm,
|
|
173
175
|
cliVersao: VERSAO_CLI,
|
|
176
|
+
perfilContexto: await lerPerfilContexto(baseProjeto) ?? null,
|
|
174
177
|
hashContratos,
|
|
175
178
|
baseProjeto,
|
|
176
179
|
modoVerificacaoCodigo,
|
|
@@ -215,44 +218,22 @@ export async function gerarResumoProjetoIa(entrada, pastaSaidaOpcional, escrever
|
|
|
215
218
|
`GERADO_EM: ${geradoEm}`,
|
|
216
219
|
"",
|
|
217
220
|
].join("\n");
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
? ["AVISO_CODIGO: somente contratos enviados; implementacao nao verificada neste modo"]
|
|
226
|
-
: modoVerificacaoCodigo === "codigo_selecionado"
|
|
227
|
-
? ["AVISO_CODIGO: codigo selecionado enviado; conclusoes valem apenas para o snapshot"]
|
|
228
|
-
: []),
|
|
229
|
-
`FONTES_CONCLUSAO: ${resumirListaTexto(fontesConclusao, 6)}`,
|
|
230
|
-
`ENTRADA_IA: ${entradaCanonica.porCapacidade.media.join(" -> ")}`,
|
|
231
|
-
`POLITICA_PLATAFORMA: ${agentContextPack.politicaPlataforma.regra} ${agentContextPack.politicaPlataforma.quandoHouverBloqueio}`,
|
|
232
|
-
`TIMEOUT_SEMA: ${agentContextPack.politicaTimeoutResumo.regra} Escale ${agentContextPack.politicaTimeoutResumo.escalonamentoSegundos.map((segundos) => `${segundos}s`).join(" -> ")} antes de declarar bloqueio.`,
|
|
233
|
-
`CODIGO_GOVERNADO: ${agentContextPack.politicaCodigoGovernado.marcador} -> docs-impacto e drift antes de alterar comportamento`,
|
|
234
|
-
`ORCAMENTO_SEMANTICO: codigo governado acima de ${LIMITE_AVISO_LINHAS_CODIGO_GOVERNADO} linhas exige refatoracao e acima de ${LIMITE_BLOQUEIO_LINHAS_CODIGO_GOVERNADO} bloqueia; .sema acima de ${LIMITE_AVISO_LINHAS_CONTRATO_SEMA} diagnostica e acima de ${LIMITE_BLOQUEIO_LINHAS_CONTRATO_SEMA} bloqueia criacao, edicao, drift, geracao e snapshot; varios .sema podem governar o mesmo arquivo via vinculos`,
|
|
235
|
-
`PAYLOAD_INLINE: conteudo inline acima de ${LIMITE_CARACTERES_PAYLOAD_INLINE} caracteres deve virar arquivos logicos, anexo, caminho de servidor autorizado ou manifesto; nao aumente timeout para empurrar o mesmo payload`,
|
|
236
|
-
`DESIGN_VISUAL: ${agentContextPack.politicaDesignVisual.regra} Fraca=${agentContextPack.politicaDesignVisual.porCapacidade.fraca} Media=${agentContextPack.politicaDesignVisual.porCapacidade.media} Forte=${agentContextPack.politicaDesignVisual.porCapacidade.forte}`,
|
|
237
|
-
`TOP_MODULOS: ${resumirListaTexto(modulos.map((modulo) => modulo.modulo), 6)}`,
|
|
238
|
-
`TOP_RISCOS: ${resumirListaTexto(unicosOrdenados(modulos.flatMap((modulo) => modulo.riscosPrincipais)), 6)}`,
|
|
239
|
-
`TOP_LACUNAS: ${resumirListaTexto(unicosOrdenados(modulos.flatMap((modulo) => modulo.lacunas)), 6)}`,
|
|
240
|
-
`TOP_ARQUIVOS: ${resumirListaTexto(topArquivosResumo.arquivos, 6)}`,
|
|
241
|
-
`TOP_ARQUIVOS_FONTE: ${topArquivosResumo.fonte}`,
|
|
242
|
-
`GERADO_EM: ${geradoEm}`,
|
|
243
|
-
"",
|
|
244
|
-
].join("\n");
|
|
221
|
+
const descreverModulo = (modulo) => `${modulo.modulo}: ${modulo.faz}\nContrato: ${modulo.arquivo}`;
|
|
222
|
+
const selecionado = await selecionarContextoAtivo(baseProjeto, {
|
|
223
|
+
micro,
|
|
224
|
+
curto: micro + "\nCONTRATOS (até 6):\n" + modulos.slice(0, 6).map(descreverModulo).join("\n"),
|
|
225
|
+
medio: micro + "\nCONTRATOS:\n" + modulos.map(descreverModulo).join("\n"),
|
|
226
|
+
});
|
|
227
|
+
Object.assign(indexJson, { contextoSelecionado: selecionado ? { arquivo: selecionado.caminhoRelativo, nivel: selecionado.nivel } : null });
|
|
245
228
|
const artefatosResumo = [
|
|
246
|
-
|
|
229
|
+
...(selecionado ? [selecionado] : []),
|
|
247
230
|
{ caminhoRelativo: ARQUIVO_SEMA_BOOT, conteudo: semaBoot },
|
|
248
|
-
{ caminhoRelativo: ARQUIVO_SEMA_SMALL_MODEL, conteudo: semaSmallModel },
|
|
249
|
-
{ caminhoRelativo: "SEMA_BRIEF.micro.txt", conteudo: micro },
|
|
250
|
-
{ caminhoRelativo: "SEMA_BRIEF.curto.txt", conteudo: curto },
|
|
251
231
|
{ caminhoRelativo: "SEMA_INDEX.json", conteudo: `${JSON.stringify(indexJson, null, 2)}\n` },
|
|
252
232
|
{ caminhoRelativo: ARQUIVO_AGENT_CONTEXT_PACK, conteudo: `${JSON.stringify(agentContextPack, null, 2)}\n` },
|
|
253
233
|
{ caminhoRelativo: ARQUIVO_DOC_AGENTES_CAPACIDADE, conteudo: docAgentesCapacidade },
|
|
254
234
|
];
|
|
255
235
|
await validarDestinosEscritaWorkspace(pastaSaida, artefatosResumo.map((artefato) => artefato.caminhoRelativo));
|
|
236
|
+
await arquivarResumosLegados(pastaSaida);
|
|
256
237
|
for (const artefato of artefatosResumo) {
|
|
257
238
|
await escreverArquivoWorkspaceSeguro(pastaSaida, artefato.caminhoRelativo, artefato.conteudo, { sobrescrever: true });
|
|
258
239
|
}
|
|
@@ -261,7 +242,7 @@ export async function gerarResumoProjetoIa(entrada, pastaSaidaOpcional, escrever
|
|
|
261
242
|
baseProjeto,
|
|
262
243
|
pastaSaida,
|
|
263
244
|
modoVerificacaoCodigo,
|
|
264
|
-
artefatos:
|
|
245
|
+
artefatos: artefatosResumo.map(item => item.caminhoRelativo),
|
|
265
246
|
modulos,
|
|
266
247
|
guiaPorCapacidade,
|
|
267
248
|
analiseDrift: indexJson.analiseDrift,
|
|
@@ -273,119 +254,15 @@ export async function gerarContextoIa(arquivoEntrada, pastaSaidaOpcional) {
|
|
|
273
254
|
? path.resolve(pastaSaidaOpcional)
|
|
274
255
|
: path.resolve(process.cwd(), ".tmp", "contexto-ia", path.basename(contexto.arquivo, ".sema"));
|
|
275
256
|
await mkdir(pastaBase, { recursive: true });
|
|
276
|
-
|
|
277
|
-
{ caminhoRelativo: "validar.json", conteudo: `${JSON.stringify(contexto.validar, null, 2)}\n` },
|
|
278
|
-
{ caminhoRelativo: "diagnosticos.json", conteudo: `${JSON.stringify(contexto.diagnosticosJson, null, 2)}\n` },
|
|
279
|
-
{ caminhoRelativo: "ast.json", conteudo: `${JSON.stringify(contexto.ast, null, 2)}\n` },
|
|
280
|
-
{ caminhoRelativo: "ir.json", conteudo: `${JSON.stringify(contexto.irJson, null, 2)}\n` },
|
|
281
|
-
{ caminhoRelativo: "drift.json", conteudo: `${JSON.stringify(contexto.drift, null, 2)}\n` },
|
|
282
|
-
{ caminhoRelativo: "briefing.json", conteudo: `${JSON.stringify(contexto.briefing, null, 2)}\n` },
|
|
283
|
-
];
|
|
284
|
-
await validarDestinosEscritaWorkspace(pastaBase, [
|
|
285
|
-
...artefatosContexto.map((artefato) => artefato.caminhoRelativo),
|
|
286
|
-
...ARQUIVOS_RESUMO_MODULO_IA,
|
|
287
|
-
"README.md",
|
|
288
|
-
]);
|
|
289
|
-
for (const artefato of artefatosContexto) {
|
|
290
|
-
await escreverArquivoWorkspaceSeguro(pastaBase, artefato.caminhoRelativo, artefato.conteudo, { sobrescrever: true });
|
|
291
|
-
}
|
|
257
|
+
await validarDestinosEscritaWorkspace(pastaBase, [...ARQUIVOS_RESUMO_MODULO_IA, "README.md"]);
|
|
292
258
|
const resumoGerado = await gerarArquivosResumoModuloIa(contexto, pastaBase);
|
|
293
259
|
const resumo = `# Contexto de IA para ${contexto.modulo}
|
|
294
260
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
## Arquivos gerados neste pacote
|
|
302
|
-
|
|
303
|
-
- \`agent-context-pack.json\`
|
|
304
|
-
- \`${ARQUIVO_SEMA_BOOT}\`
|
|
305
|
-
- \`${ARQUIVO_SEMA_SMALL_MODEL}\`
|
|
306
|
-
- \`resumo.micro.txt\`
|
|
307
|
-
- \`resumo.curto.txt\`
|
|
308
|
-
- \`resumo.md\`
|
|
309
|
-
- \`briefing.min.json\`
|
|
310
|
-
- \`prompt-curto.txt\`
|
|
311
|
-
- \`validar.json\`
|
|
312
|
-
- \`diagnosticos.json\`
|
|
313
|
-
- \`ast.json\`
|
|
314
|
-
- \`ir.json\`
|
|
315
|
-
- \`drift.json\`
|
|
316
|
-
- \`briefing.json\`
|
|
317
|
-
|
|
318
|
-
## Fluxo recomendado para o agente
|
|
319
|
-
|
|
320
|
-
Antes de escolher arquivo de código, leia \`${ARQUIVO_SEMA_BOOT}\` e \`agent-context-pack.json\`. Eles declaram regras obrigatórias, proibições, prioridades, idioma humano e quando abrir texto bruto como \`AGENTS.md\`, \`exemplos/\`, docs e contratos.
|
|
321
|
-
|
|
322
|
-
## Políticas da plataforma
|
|
323
|
-
|
|
324
|
-
- Sema governa contrato, escopo, drift, evidência e qualidade; não contorna políticas, termos, permissões, segurança ou leis.
|
|
325
|
-
- Se houver alerta externo, trate como bloqueio da plataforma ou falso positivo possível, explique de forma neutra e não tente burlar filtro.
|
|
326
|
-
|
|
327
|
-
### IA fraca, gratuita ou com pouca disciplina
|
|
328
|
-
|
|
329
|
-
1. Ler \`${ARQUIVO_SEMA_BOOT}\`.
|
|
330
|
-
2. Ler \`${ARQUIVO_SEMA_SMALL_MODEL}\`.
|
|
331
|
-
3. Ler \`agent-context-pack.json\`.
|
|
332
|
-
4. Ler \`resumo.micro.txt\`.
|
|
333
|
-
5. Ler \`briefing.min.json\`.
|
|
334
|
-
6. Se ainda couber contexto, ler \`resumo.curto.txt\`.
|
|
335
|
-
|
|
336
|
-
### IA média
|
|
337
|
-
|
|
338
|
-
1. Ler \`${ARQUIVO_SEMA_BOOT}\`.
|
|
339
|
-
2. Ler \`agent-context-pack.json\`.
|
|
340
|
-
3. Ler \`resumo.curto.txt\`.
|
|
341
|
-
4. Ler \`briefing.min.json\`.
|
|
342
|
-
5. Ler \`drift.json\`.
|
|
343
|
-
6. Se precisar, subir para \`resumo.md\`.
|
|
344
|
-
|
|
345
|
-
### IA forte ou com tool use
|
|
346
|
-
|
|
347
|
-
1. Ler \`${ARQUIVO_SEMA_BOOT}\`.
|
|
348
|
-
2. Ler \`agent-context-pack.json\`.
|
|
349
|
-
3. Ler \`README.md\`.
|
|
350
|
-
4. Ler \`resumo.md\`.
|
|
351
|
-
5. Ler \`briefing.json\`.
|
|
352
|
-
6. Ler \`drift.json\`.
|
|
353
|
-
7. Só depois abrir \`ir.json\` e \`ast.json\`.
|
|
354
|
-
|
|
355
|
-
## Idioma humano
|
|
356
|
-
|
|
357
|
-
- Responda no idioma do usuário.
|
|
358
|
-
- Em PT-BR, use acentos, cedilha, pontuação e símbolos normais.
|
|
359
|
-
- A DSL \`.sema\` pode ser ASCII; texto humano não precisa ser.
|
|
360
|
-
|
|
361
|
-
## Texto bruto sob demanda
|
|
362
|
-
|
|
363
|
-
- Abra \`AGENTS.md\` antes de editar código, contrato, docs operacionais, release ou deploy.
|
|
364
|
-
- Abra \`exemplos/\` antes de criar ou corrigir sintaxe \`.sema\`.
|
|
365
|
-
- Abra \`docs/syntax.md\` quando exemplos não bastarem para resolver a gramática.
|
|
366
|
-
- Abra \`contratos/\` antes de qualquer implementação ou mudança de comportamento.
|
|
367
|
-
|
|
368
|
-
## Timeout e retry
|
|
369
|
-
|
|
370
|
-
- Timeout local do agente não é falha do Sema.
|
|
371
|
-
- Se uma chamada Sema estourar, aumente o timeout e tente de novo.
|
|
372
|
-
- Se o projeto inteiro for lento, escopar para \`sema resumo "${contexto.arquivo}" --micro --para mudanca --drift none\`.
|
|
373
|
-
- Se o ambiente impedir continuar, pare bloqueado e não avance com código sem Sema.
|
|
374
|
-
|
|
375
|
-
## Fechamento
|
|
376
|
-
|
|
377
|
-
1. Editar o arquivo \`.sema\`.
|
|
378
|
-
2. Rodar \`sema formatar "${contexto.arquivo}"\`.
|
|
379
|
-
3. Rodar \`sema validar "${contexto.arquivo}" --json\`.
|
|
380
|
-
4. Rodar \`sema drift "${contexto.arquivo}" --cache fresh --json\`.
|
|
381
|
-
5. Fechar com \`sema verificar <arquivo-ou-pasta> --json --saida ./.tmp/verificacao-ia\`.
|
|
382
|
-
|
|
383
|
-
## Textos base para onboarding do agente
|
|
384
|
-
|
|
385
|
-
- \`sema starter-ia\`
|
|
386
|
-
- \`sema resumo "${contexto.arquivo}" --micro --para onboarding --drift none\`
|
|
387
|
-
- \`sema prompt-curto "${contexto.arquivo}" --para mudanca\`
|
|
388
|
-
- \`sema prompt-ia\`
|
|
261
|
+
Contrato: ${contexto.arquivo}. Validação: ${contexto.sucesso}.
|
|
262
|
+
Resumo selecionado: ${resumoGerado.artefatosCompactos.join(", ") || "nenhum: configure o perfil ou refine o orçamento"}. Consulte-o somente se a sessão ainda não entregou o contexto necessário.
|
|
263
|
+
Para evidências específicas, consulte validar, diagnosticos, drift --pacote, ast ou ir pela CLI. Não carregue todos os resultados de uma vez.
|
|
264
|
+
Use sema sessao com intenção e --arquivo para obter o recorte da tarefa.
|
|
265
|
+
Preserve os gates do AGENTS.md e SEMA_BOOT.md do projeto, sem relê-los quando já estiverem no contexto.
|
|
389
266
|
`;
|
|
390
267
|
await escreverArquivoWorkspaceSeguro(pastaBase, "README.md", resumo, {
|
|
391
268
|
sobrescrever: true,
|
|
@@ -396,12 +273,6 @@ Antes de escolher arquivo de código, leia \`${ARQUIVO_SEMA_BOOT}\` e \`agent-co
|
|
|
396
273
|
modulo: contexto.modulo,
|
|
397
274
|
pastaSaida: pastaBase,
|
|
398
275
|
artefatos: [
|
|
399
|
-
"validar.json",
|
|
400
|
-
"diagnosticos.json",
|
|
401
|
-
"ast.json",
|
|
402
|
-
"ir.json",
|
|
403
|
-
"drift.json",
|
|
404
|
-
"briefing.json",
|
|
405
276
|
"README.md",
|
|
406
277
|
...resumoGerado.artefatosCompactos,
|
|
407
278
|
],
|
package/dist/index.part06.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// SEMA-GOVERNED: sema.governanca_ia_contexto, sema.produto.governanca_ia.drift.cache.modos
|
|
2
2
|
// Descrição: resume contrato ou projeto com política explícita de análise de drift.
|
|
3
|
+
import { emitirContextoLimitado } from "./contextDelivery.js";
|
|
3
4
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import { diagnosticarEntradaContratos } from "./entradaContratos.js";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { compilarCodigo, formatarCodigo, formatarDiagnosticos, lerArquivoTexto, temErros, } from "@sema/nucleo";
|
|
7
|
-
import { carregarProjeto, } from "./projeto.js";
|
|
8
|
-
import { ARQUIVOS_CANONICOS_IA_RAIZ, } from './agentContextTipos.js';
|
|
8
|
+
import { carregarConfiguracaoProjeto, carregarProjeto, } from "./projeto.js";
|
|
9
9
|
import { criarGuiaCapacidadeIa } from './agentContextPack.js';
|
|
10
10
|
import { sincronizarEntrypointCodex, } from './agentEntryPoints.js';
|
|
11
11
|
import { escreverArquivos, formatarAvisoArtefatosGeradosAcimaDoLimite, } from './fsGovernado.js';
|
|
@@ -161,7 +161,6 @@ export async function comandoSyncCodex(emJson) {
|
|
|
161
161
|
const indexJson = JSON.parse(await readFile(path.join(resumoProjeto.pastaSaida, "SEMA_INDEX.json"), "utf8"));
|
|
162
162
|
const resultadosCodex = await sincronizarEntrypointCodex(resumoProjeto.baseProjeto, indexJson.agentContextPack);
|
|
163
163
|
const artefatos = [...new Set([
|
|
164
|
-
...ARQUIVOS_CANONICOS_IA_RAIZ,
|
|
165
164
|
...resumoProjeto.artefatos,
|
|
166
165
|
...resultadosCodex.arquivos.map((item) => item.caminho),
|
|
167
166
|
"exemplos",
|
|
@@ -175,9 +174,10 @@ export async function comandoSyncCodex(emJson) {
|
|
|
175
174
|
baseProjeto: resumoProjeto.baseProjeto,
|
|
176
175
|
pastaSaida: resumoProjeto.pastaSaida,
|
|
177
176
|
artefatos,
|
|
178
|
-
entradaCanonica:
|
|
177
|
+
entradaCanonica: ["AGENTS.md", "SEMA_BOOT.md", "sema sessao"],
|
|
178
|
+
contextoSelecionado: indexJson.contextoSelecionado,
|
|
179
179
|
resultadosCodex,
|
|
180
|
-
exemplos,
|
|
180
|
+
exemplos: { destino: exemplos.destino, criados: exemplos.criados.length, preservados: exemplos.preservados.length },
|
|
181
181
|
}, null, 2));
|
|
182
182
|
return sucesso ? 0 : 1;
|
|
183
183
|
}
|
|
@@ -192,9 +192,6 @@ export async function comandoSyncCodex(emJson) {
|
|
|
192
192
|
console.log("");
|
|
193
193
|
console.log(`Base do projeto: ${resumoProjeto.baseProjeto}`);
|
|
194
194
|
console.log(`Ordem canônica: ${indexJson.entradaCanonica.ordemLeitura.join(" -> ")}`);
|
|
195
|
-
console.log(`IA fraca: ${indexJson.entradaCanonica.porCapacidade.fraca.join(" -> ")}`);
|
|
196
|
-
console.log(`IA média: ${indexJson.entradaCanonica.porCapacidade.media.join(" -> ")}`);
|
|
197
|
-
console.log(`IA forte: ${indexJson.entradaCanonica.porCapacidade.forte.join(" -> ")}`);
|
|
198
195
|
console.log(`Codex: ${resultadosCodex.criados.length} criados, ${resultadosCodex.atualizados.length} atualizados, ${resultadosCodex.preservados.length} preservados`);
|
|
199
196
|
console.log(`Exemplos oficiais: ${exemplos.criados.length} criados, ${exemplos.preservados.length} preservados em ${exemplos.destino}`);
|
|
200
197
|
return 0;
|
|
@@ -238,7 +235,7 @@ export async function comandoAjudaIa() {
|
|
|
238
235
|
"Use `sema drift --cache fresh` para medir impls, vínculos, rotas, score e lacunas no fechamento; cache é aceleração, não prova final.",
|
|
239
236
|
"Use `sema docs-impacto --intencao <acao>` para ler ou criar docs obrigatorias antes de agir.",
|
|
240
237
|
"Use `sema finalizar-mudanca --intencao <acao>` para bloquear conclusao sem leitura documental comprovada.",
|
|
241
|
-
"Use `sema contexto-ia <arquivo.sema> --saida <diretorio> --json` para gerar AST, IR
|
|
238
|
+
"Use `sema contexto-ia <arquivo.sema> --saida <diretorio> --json` para gerar somente o resumo selecionado pelo perfil. Consulte AST, IR ou drift pela CLI quando necessário.",
|
|
242
239
|
"Use `sema compilar <arquivo-ou-pasta> --alvo <typescript|python|php|dart|lua|javascript|html|css|dotnet|cpp> --saida <diretorio>` quando a tarefa pedir codigo derivado.",
|
|
243
240
|
]));
|
|
244
241
|
console.log("");
|
|
@@ -251,7 +248,7 @@ export async function comandoAjudaIa() {
|
|
|
251
248
|
"Se o projeto ja existe, trate `importar` como rascunho e `drift` como juiz.",
|
|
252
249
|
"IA fraca comeca no menor artefato que resolve a tarefa; nao enfie `ast.json` inteiro nela de bobeira.",
|
|
253
250
|
"Timeout local e so limite do agente: escale e tente de novo antes de chamar Sema de inativo.",
|
|
254
|
-
"Antes de editar software vivo, rode os gates locais
|
|
251
|
+
"Antes de editar software vivo, rode os gates locais e consulte somente o contrato selecionado e suas dependências. A CLI materializa apenas os arquivos do perfil ativo.",
|
|
255
252
|
"Trate `route`, `worker`, `evento`, `fila`, `cron`, `webhook`, `cache`, `storage` e `policy` como superficies de primeira classe.",
|
|
256
253
|
]));
|
|
257
254
|
return 0;
|
|
@@ -312,6 +309,7 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
312
309
|
const alvo = entrada ? path.resolve(process.cwd(), entrada) : process.cwd();
|
|
313
310
|
const analiseDrift = resolverAnaliseDriftConsultaCli(args, "resumo");
|
|
314
311
|
const alvoEhArquivo = (await stat(alvo).catch(() => undefined))?.isFile() ?? false;
|
|
312
|
+
const baseEntrega = (await carregarConfiguracaoProjeto(alvo))?.baseDiretorio ?? (alvoEhArquivo ? process.cwd() : alvo);
|
|
315
313
|
if (alvoEhArquivo) {
|
|
316
314
|
const contexto = await carregarContextoModuloIa(alvo, analiseDrift);
|
|
317
315
|
const resumoSemantico = coletarResumoSemanticoModulo(contexto);
|
|
@@ -343,14 +341,16 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
343
341
|
}
|
|
344
342
|
if (emJson) {
|
|
345
343
|
if (somentePacote && contextPack) {
|
|
346
|
-
|
|
344
|
+
if (!(await emitirContextoLimitado(baseEntrega, contextPack)))
|
|
345
|
+
return 1;
|
|
347
346
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
348
347
|
}
|
|
349
348
|
if (somentePacote) {
|
|
350
|
-
|
|
349
|
+
if (!(await emitirContextoLimitado(baseEntrega, contextPack)))
|
|
350
|
+
return 1;
|
|
351
351
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
352
352
|
}
|
|
353
|
-
|
|
353
|
+
if (!(await emitirContextoLimitado(baseEntrega, {
|
|
354
354
|
comando: "resumo",
|
|
355
355
|
modo,
|
|
356
356
|
tamanho,
|
|
@@ -368,14 +368,16 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
368
368
|
cache: contexto.drift.drift?.escopo_aplicado.cache ?? null,
|
|
369
369
|
},
|
|
370
370
|
contextPack,
|
|
371
|
-
}
|
|
371
|
+
})))
|
|
372
|
+
return 1;
|
|
372
373
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
373
374
|
}
|
|
374
375
|
if (pastaResumo) {
|
|
375
376
|
console.log(`Resumo IA-first gerado em ${pastaResumo}`);
|
|
376
377
|
console.log("");
|
|
377
378
|
}
|
|
378
|
-
|
|
379
|
+
if (!(await emitirContextoLimitado(baseEntrega, contextPack)))
|
|
380
|
+
return 1;
|
|
379
381
|
return contexto.drift.sucesso === false ? 1 : 0;
|
|
380
382
|
}
|
|
381
383
|
const resumoProjeto = await gerarResumoProjetoIa(alvo, pastaSaida, escreverNaRaiz, analiseDrift);
|
|
@@ -391,10 +393,11 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
391
393
|
});
|
|
392
394
|
if (emJson) {
|
|
393
395
|
if (somentePacote) {
|
|
394
|
-
|
|
396
|
+
if (!(await emitirContextoLimitado(baseEntrega, indexPack)))
|
|
397
|
+
return 1;
|
|
395
398
|
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
396
399
|
}
|
|
397
|
-
|
|
400
|
+
if (!(await emitirContextoLimitado(baseEntrega, {
|
|
398
401
|
comando: "resumo",
|
|
399
402
|
modo,
|
|
400
403
|
tamanho,
|
|
@@ -407,12 +410,14 @@ export async function comandoResumo(entrada, args, emJson) {
|
|
|
407
410
|
avisos: analiseDrift.avisos,
|
|
408
411
|
},
|
|
409
412
|
indexPack,
|
|
410
|
-
}
|
|
413
|
+
})))
|
|
414
|
+
return 1;
|
|
411
415
|
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
412
416
|
}
|
|
413
417
|
console.log(`Resumo IA-first do projeto gerado em ${resumoProjeto.pastaSaida}`);
|
|
414
418
|
console.log("");
|
|
415
|
-
|
|
419
|
+
if (!(await emitirContextoLimitado(baseEntrega, indexPack)))
|
|
420
|
+
return 1;
|
|
416
421
|
return resumoProjeto.analiseDrift.sucesso === false ? 1 : 0;
|
|
417
422
|
}
|
|
418
423
|
//# sourceMappingURL=index.part06.js.map
|