@semacode/cli 4.2.3 → 4.2.5
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 +28 -6
- package/dist/agentProtocol.js +1 -2
- package/dist/comandoSessao.js +12 -7
- package/dist/contextDelivery.d.ts +13 -0
- package/dist/contextDelivery.js +105 -0
- package/dist/discovery/catalog.js +1 -1
- 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 +38 -166
- package/dist/index.part06.js +24 -19
- package/dist/index.part07.js +26 -62
- package/dist/initCommand.js +1 -0
- package/dist/initProjectPlan.d.ts +2 -0
- package/dist/initProjectPlan.js +30 -0
- package/dist/initTemplatesBase.js +16 -82
- package/dist/projetoBusca.js +2 -0
- package/dist/sessionContext.js +1 -1
- package/docs/commands.md +22 -13
- package/docs/getting-started.md +10 -2
- package/docs/syntax.md +3 -3
- package/package.json +1 -1
- package/skills/sema/SKILL.md +6 -3
package/dist/index.part07.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { emitirContextoLimitado, ARQUIVOS_CONTEXTO_PROJETO } from "./contextDelivery.js";
|
|
1
2
|
// SEMA-GOVERNED: sema.governanca_ia_contexto, sema.produto.governanca_ia.drift.cache.modos
|
|
2
3
|
// Descrição: preserva modos explícitos nas superfícies auxiliares de contexto.
|
|
3
4
|
import { readFile } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import pacoteCli from "../package.json" with { type: "json" };
|
|
6
7
|
import { compilarCodigo, formatarDiagnosticos, lerArquivoTexto, temErros, } from "@sema/nucleo";
|
|
7
|
-
import { carregarProjeto, resolverAlvosVerificacao, } from "./projeto.js";
|
|
8
|
+
import { carregarConfiguracaoProjeto, carregarProjeto, resolverAlvosVerificacao, } from "./projeto.js";
|
|
8
9
|
import { SCHEMA_CACHE_VERIFICACAO, calcularChaveVerificacao, carregarCacheVerificacao, gravarCacheVerificacao, } from "./verificacaoCache.js";
|
|
9
10
|
import { erroModoPreservacao, prepararImplementacaoPythonLocal, evidenciaPython } from "./verificacaoPythonLocal.js";
|
|
10
11
|
const FONTES_POR_ALVO_SUPORTADO = {
|
|
@@ -52,10 +53,8 @@ export function avisoEscopoStackVerificacao(fontesLegado, alvosEfetivos) {
|
|
|
52
53
|
}
|
|
53
54
|
return `Alvos fora da stack detectada (${(fontesLegado ?? []).join(", ")}): ${foraDaStack.join(", ")}. Considere reduzir "alvos" no sema.config.json, remover "fontesLegado" auto-declaradas ou usar --alvo unico.`;
|
|
54
55
|
}
|
|
55
|
-
import { criarAgentContextPack } from './agentContextPack.js';
|
|
56
|
-
import { criarEntrypointPack } from './entrypointPack.js';
|
|
57
56
|
import { escreverArquivos, formatarAvisoArtefatosGeradosAcimaDoLimite, } from './fsGovernado.js';
|
|
58
|
-
import { obterOpcao
|
|
57
|
+
import { obterOpcao } from './cliArgs.js';
|
|
59
58
|
import { avaliarDependenciasVerificacao, imprimirFalhaDependenciasVerificacao } from './doctorCommand.js';
|
|
60
59
|
import { aplicarEstruturaSaida, executarTestesGerados, executarTestesParaVerificacao, gerarArquivosPorAlvo, garantirIr, nomeSubpastaModulo, resolverConfiguracaoVerificacaoPorAlvo, validarCompatibilidadeFramework, } from './geracaoCore.js';
|
|
61
60
|
import { normalizarModoResumo, normalizarTamanhoResumo } from "./index.part01.js";
|
|
@@ -66,6 +65,7 @@ export async function comandoPromptCurto(entrada, args, emJson) {
|
|
|
66
65
|
const tamanho = normalizarTamanhoResumo(args);
|
|
67
66
|
const modo = normalizarModoResumo(obterOpcao(args, "--para"));
|
|
68
67
|
const alvo = entrada ? path.resolve(process.cwd(), entrada) : process.cwd();
|
|
68
|
+
const baseEntrega = (await carregarConfiguracaoProjeto(alvo))?.baseDiretorio ?? process.cwd();
|
|
69
69
|
if (entrada && entrada.toLowerCase().endsWith(".sema")) {
|
|
70
70
|
const contexto = await carregarContextoModuloIa(alvo, {
|
|
71
71
|
modo: "none",
|
|
@@ -76,7 +76,7 @@ export async function comandoPromptCurto(entrada, args, emJson) {
|
|
|
76
76
|
const capacidade = tamanho === "micro" ? "fraca" : tamanho === "curto" ? "media" : "forte";
|
|
77
77
|
const prompt = criarPromptCurtoModulo(resumoSemantico, modo, tamanho, capacidade);
|
|
78
78
|
if (emJson) {
|
|
79
|
-
|
|
79
|
+
if (!(await emitirContextoLimitado(baseEntrega, {
|
|
80
80
|
comando: "prompt-curto",
|
|
81
81
|
modo,
|
|
82
82
|
tamanho,
|
|
@@ -85,47 +85,21 @@ export async function comandoPromptCurto(entrada, args, emJson) {
|
|
|
85
85
|
arquivo: contexto.arquivo,
|
|
86
86
|
modulo: contexto.modulo,
|
|
87
87
|
prompt,
|
|
88
|
-
}
|
|
88
|
+
})))
|
|
89
|
+
return 1;
|
|
89
90
|
return 0;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
if (!(await emitirContextoLimitado(baseEntrega, { prompt })))
|
|
93
|
+
return 1;
|
|
92
94
|
return 0;
|
|
93
95
|
}
|
|
94
96
|
const resumoProjeto = await gerarResumoProjetoIa(alvo);
|
|
95
|
-
const arquivoResumo =
|
|
96
|
-
|
|
97
|
-
: tamanho === "curto"
|
|
98
|
-
? "SEMA_BRIEF.curto.txt"
|
|
99
|
-
: "SEMA_BRIEF.md";
|
|
100
|
-
const contextoProjeto = await readFile(path.join(resumoProjeto.pastaSaida, arquivoResumo), "utf8");
|
|
97
|
+
const arquivoResumo = resumoProjeto.artefatos.find(nome => ARQUIVOS_CONTEXTO_PROJETO.includes(nome));
|
|
98
|
+
const contextoProjeto = arquivoResumo ? await readFile(path.join(resumoProjeto.pastaSaida, arquivoResumo), "utf8") : "Resumo não gerado: confirme o perfil e o orçamento na sessão.";
|
|
101
99
|
const capacidade = tamanho === "micro" ? "fraca" : tamanho === "curto" ? "media" : "forte";
|
|
102
|
-
const prompt =
|
|
103
|
-
|
|
104
|
-
ANTES DE QUALQUER AÇÃO (editar, criar, deletar, executar, consultar ou modificar):
|
|
105
|
-
1. Rode \`sema docs-impacto --intencao "<ação>" --json\` com sua intenção declarada.
|
|
106
|
-
2. Aguarde a resposta com as docs obrigatórias.
|
|
107
|
-
3. Leia as docs antes de agir.
|
|
108
|
-
4. Antes de concluir, rode \`sema finalizar-mudanca --intencao "<ação>" --doc-lida <arquivo> --json\` com todas as docs lidas.
|
|
109
|
-
|
|
110
|
-
Você está operando Sema em modo IA-first.
|
|
111
|
-
|
|
112
|
-
Isto é contexto comprimido para IA operar contrato semântico antes de tocar código vivo.
|
|
113
|
-
|
|
114
|
-
Capacidade alvo: ${capacidade}
|
|
115
|
-
Modo da tarefa: ${modo}
|
|
116
|
-
|
|
117
|
-
Regras:
|
|
118
|
-
- ANTES DE TUDO: rode \`sema docs-impacto --intencao "<ação>" --json\`.
|
|
119
|
-
- Comece pelo resumo compacto abaixo.
|
|
120
|
-
- Se a tarefa pedir mais contexto, abra \`AGENT_CONTEXT_PACK.json\` e depois \`SEMA_INDEX.json\`.
|
|
121
|
-
- Não tente ler o repositório inteiro se o resumo já disser onde tocar.
|
|
122
|
-
- Preserve contrato, risco, lacuna e checks sugeridos.
|
|
123
|
-
|
|
124
|
-
Contexto do projeto:
|
|
125
|
-
${contextoProjeto.trim()}
|
|
126
|
-
`;
|
|
100
|
+
const prompt = contextoProjeto.trim();
|
|
127
101
|
if (emJson) {
|
|
128
|
-
|
|
102
|
+
if (!(await emitirContextoLimitado(baseEntrega, {
|
|
129
103
|
comando: "prompt-curto",
|
|
130
104
|
modo,
|
|
131
105
|
tamanho,
|
|
@@ -134,35 +108,25 @@ ${contextoProjeto.trim()}
|
|
|
134
108
|
baseProjeto: resumoProjeto.baseProjeto,
|
|
135
109
|
pastaSaida: resumoProjeto.pastaSaida,
|
|
136
110
|
prompt,
|
|
137
|
-
}
|
|
111
|
+
})))
|
|
112
|
+
return 1;
|
|
138
113
|
return 0;
|
|
139
114
|
}
|
|
140
|
-
|
|
115
|
+
if (!(await emitirContextoLimitado(baseEntrega, { prompt })))
|
|
116
|
+
return 1;
|
|
141
117
|
return 0;
|
|
142
118
|
}
|
|
143
119
|
export async function comandoContextoIa(arquivo, pastaSaida, emJson, args = []) {
|
|
144
120
|
const resultado = await gerarContextoIa(arquivo, pastaSaida);
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
console.log(JSON.stringify(pacote, null, 2));
|
|
155
|
-
return resultado.sucesso ? 0 : 1;
|
|
156
|
-
}
|
|
157
|
-
if (emJson) {
|
|
158
|
-
console.log(JSON.stringify(resultado, null, 2));
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
const resumoGerado = await readFile(path.join(resultado.pastaSaida, "README.md"), "utf8");
|
|
162
|
-
console.log(`Pacote de contexto gerado em ${resultado.pastaSaida}`);
|
|
163
|
-
console.log("");
|
|
164
|
-
console.log(resumoGerado);
|
|
165
|
-
return 0;
|
|
121
|
+
const base = (await carregarConfiguracaoProjeto(arquivo))?.baseDiretorio ?? process.cwd();
|
|
122
|
+
const resumo = resultado.artefatosCompactos[0];
|
|
123
|
+
const contexto = resumo ? await readFile(path.join(resultado.pastaSaida, resumo), "utf8") : "Resumo não gerado: confirme o perfil e o orçamento na sessão.";
|
|
124
|
+
const entregue = await emitirContextoLimitado(base, {
|
|
125
|
+
comando: "contexto-ia", sucesso: resultado.sucesso, arquivo: resultado.arquivo,
|
|
126
|
+
pastaSaida: resultado.pastaSaida, arquivoContexto: resumo ?? null, contexto,
|
|
127
|
+
evidenciasSobDemanda: ["validar", "diagnosticos", "drift --pacote", "ast", "ir"],
|
|
128
|
+
});
|
|
129
|
+
return entregue && resultado.sucesso ? 0 : 1;
|
|
166
130
|
}
|
|
167
131
|
export async function comandoTestar(arquivo, alvo, saida, estrutura, framework) {
|
|
168
132
|
const incompatibilidade = validarCompatibilidadeFramework(alvo, framework);
|
package/dist/initCommand.js
CHANGED
|
@@ -119,6 +119,7 @@ export async function comandoIniciar(cwd, template, opcoes = {}) {
|
|
|
119
119
|
return 1;
|
|
120
120
|
}
|
|
121
121
|
console.log(`Projeto Sema inicializado com template ${template}.`);
|
|
122
|
+
console.log("A inicialização não cria contratos de negócio. Modele o pedido do usuário em contratos/ antes de implementar; demonstrações ficam em exemplos/.");
|
|
122
123
|
console.log(`Arquivos do projeto: ${arquivosParaEscrever.length} escritos, ${opcoes.force ? 0 : existentes.size} preservados.`);
|
|
123
124
|
console.log(`Exemplos oficiais sincronizados em ${exemplos.destino} (${exemplos.criados.length} criados, ${exemplos.preservados.length} preservados).`);
|
|
124
125
|
if (!opcoes.exemplosCompletos) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.cli_init_templates
|
|
2
|
+
// Descrição: separa configuração do projeto de demonstrações, mantendo exemplos fora dos contratos ativos.
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export function separarDemonstracoesTemplate(template, arquivos) {
|
|
5
|
+
const config = arquivos.find(item => item.caminhoRelativo === "sema.config.json");
|
|
6
|
+
if (!config)
|
|
7
|
+
throw new Error(`Template ${template} sem configuração de projeto.`);
|
|
8
|
+
const projeto = [config, { caminhoRelativo: "contratos/.gitkeep", conteudo: "" }];
|
|
9
|
+
const configuracao = JSON.parse(config.conteudo);
|
|
10
|
+
for (const diretorio of configuracao.diretoriosCodigo ?? []) {
|
|
11
|
+
const relativo = path.posix.normalize(diretorio.replace(/\\/g, "/"));
|
|
12
|
+
if (path.posix.isAbsolute(relativo) || relativo === ".." || relativo.startsWith("../")) {
|
|
13
|
+
throw new Error(`Diretório de código fora do template: ${diretorio}`);
|
|
14
|
+
}
|
|
15
|
+
projeto.push({ caminhoRelativo: `${relativo}/.gitkeep`, conteudo: "" });
|
|
16
|
+
}
|
|
17
|
+
for (const arquivo of arquivos) {
|
|
18
|
+
if (arquivo.caminhoRelativo.endsWith("/.gitkeep") && !projeto.some(item => item.caminhoRelativo === arquivo.caminhoRelativo))
|
|
19
|
+
projeto.push(arquivo);
|
|
20
|
+
}
|
|
21
|
+
const demonstracoes = arquivos.filter(item => item.caminhoRelativo !== "sema.config.json" && !item.caminhoRelativo.endsWith("/.gitkeep"));
|
|
22
|
+
if (!demonstracoes.length)
|
|
23
|
+
return projeto;
|
|
24
|
+
const prefixo = `exemplos/templates/${template}/`;
|
|
25
|
+
return [...projeto, config, ...demonstracoes].map((item, indice) => indice < projeto.length ? item : {
|
|
26
|
+
caminhoRelativo: prefixo + item.caminhoRelativo,
|
|
27
|
+
conteudo: item.conteudo,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=initProjectPlan.js.map
|
|
@@ -1,64 +1,12 @@
|
|
|
1
1
|
// SEMA-GOVERNED: sema.produto.cli_init_templates, sema.produto.governanca_ia.drift.cache.modos
|
|
2
2
|
// Descrição: contrato base e dispatcher dos templates multi-agente de inicialização.
|
|
3
|
+
import { separarDemonstracoesTemplate } from "./initProjectPlan.js";
|
|
3
4
|
import { arquivosInitTemplatesBackend } from "./initTemplatesBackend.js";
|
|
4
5
|
import { arquivosInitTemplatesWeb } from "./initTemplatesWeb.js";
|
|
5
6
|
import { arquivosInitTemplatesFlutter } from "./initTemplatesFlutter.js";
|
|
6
7
|
import { arquivosInitTemplatesRuntime } from "./initTemplatesRuntime.js";
|
|
7
8
|
export function arquivosBaseIniciar() {
|
|
8
|
-
return [
|
|
9
|
-
{
|
|
10
|
-
caminhoRelativo: "contratos/pedidos.sema",
|
|
11
|
-
conteudo: `module app.pedidos {
|
|
12
|
-
entity Pedido {
|
|
13
|
-
fields {
|
|
14
|
-
id: Id
|
|
15
|
-
status: Texto
|
|
16
|
-
total: Decimal
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
task criar_pedido {
|
|
21
|
-
input {
|
|
22
|
-
cliente_id: Id required
|
|
23
|
-
total: Decimal required
|
|
24
|
-
}
|
|
25
|
-
output {
|
|
26
|
-
pedido_id: Id
|
|
27
|
-
status: Texto
|
|
28
|
-
}
|
|
29
|
-
rules {
|
|
30
|
-
total > 0
|
|
31
|
-
}
|
|
32
|
-
effects {
|
|
33
|
-
persistencia Pedido criticidade=alta
|
|
34
|
-
auditoria pedidos
|
|
35
|
-
}
|
|
36
|
-
guarantees {
|
|
37
|
-
pedido_id existe
|
|
38
|
-
status existe
|
|
39
|
-
}
|
|
40
|
-
tests {
|
|
41
|
-
caso "pedido valido" {
|
|
42
|
-
given {
|
|
43
|
-
cliente_id: "cli-1"
|
|
44
|
-
total: 10
|
|
45
|
-
}
|
|
46
|
-
expect {
|
|
47
|
-
sucesso: verdadeiro
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
route criar_pedido_publico {
|
|
54
|
-
metodo: POST
|
|
55
|
-
caminho: /pedidos
|
|
56
|
-
task: criar_pedido
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
},
|
|
61
|
-
];
|
|
9
|
+
return [{ caminhoRelativo: "contratos/.gitkeep", conteudo: "" }];
|
|
62
10
|
}
|
|
63
11
|
function arquivosApoioIaIniciar() {
|
|
64
12
|
return [
|
|
@@ -66,39 +14,25 @@ function arquivosApoioIaIniciar() {
|
|
|
66
14
|
caminhoRelativo: "README.md",
|
|
67
15
|
conteudo: `# Projeto Sema
|
|
68
16
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Entrada oficial do Codex
|
|
72
|
-
|
|
73
|
-
Antes de alterar codigo, contrato ou documentacao:
|
|
74
|
-
|
|
75
|
-
1. leia \`AGENTS.md\`;
|
|
76
|
-
2. rode \`sema --version\`; se o shell não localizar o comando, use \`$HOME/.sema/bin/sema\` no macOS/Linux; no Windows, PowerShell usa \`sema.ps1\` no PATH, cmd.exe usa \`sema.cmd\`, e o fallback absoluto é \`& "$env:SystemRoot\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\\.sema\\bin\\sema-managed.ps1" --version\`;
|
|
77
|
-
3. rode \`sema resumo --drift none\` para contexto contratual; score, confiança e implementação ficam não avaliados;
|
|
78
|
-
4. rode \`sema docs-impacto --intencao "<acao>" --json\`;
|
|
79
|
-
5. leia \`docs/commands.md\` antes de escolher comando ou interpretar \`--saida\`;
|
|
80
|
-
6. use \`sema descobrir recomendar --intencao "<objetivo>" --json\` quando não souber qual capacidade ou pipeline aplicar;
|
|
81
|
-
7. use \`exemplos/\` e \`docs/syntax.md\` antes de criar ou corrigir \`.sema\`.
|
|
17
|
+
Sema foi adotado neste projeto. A inicialização prepara configuração, protocolo e exemplos; o contrato de negócio deve representar o pedido do usuário.
|
|
82
18
|
|
|
83
|
-
|
|
19
|
+
1. Use AGENTS.md, SEMA_BOOT.md e sema sessao "<intenção>" --json.
|
|
20
|
+
2. Se ainda não houver contrato aplicável, modele o comportamento solicitado em contratos/ antes de implementar. Consulte somente exemplos pertinentes em exemplos/ para sintaxe.
|
|
21
|
+
3. Valide o contrato e siga os gates locais antes de alterar o código da aplicação.
|
|
84
22
|
|
|
85
|
-
|
|
23
|
+
Contratos já existentes são preservados. Não trate exemplos como funcionalidades solicitadas nem como evidência de implementação.
|
|
86
24
|
|
|
87
|
-
|
|
88
|
-
- \`AGENTS.md\`: entrypoint oficial do Codex.
|
|
89
|
-
- \`exemplos/\`: exemplos oficiais da DSL Sema.
|
|
90
|
-
- \`docs/commands.md\`: catalogo de comandos, pipelines, gates e regra de \`--saida\`.
|
|
91
|
-
- \`docs/syntax.md\`: referencia curta para escrever \`.sema\`.
|
|
92
|
-
- \`docs/ai-workflow.md\`: fluxo minimo para agentes.
|
|
93
|
-
- \`SEMA_BOOT.md\`, \`SEMA_SMALL_MODEL.md\`, \`AGENT_CONTEXT_PACK.json\` e \`SEMA_INDEX.json\`: contexto IA-first.
|
|
25
|
+
## Estrutura
|
|
94
26
|
|
|
95
|
-
|
|
27
|
+
- contratos/: contratos reais do projeto; a inicialização não inventa um domínio.
|
|
28
|
+
- exemplos/: referências da DSL e demonstrações de templates. Não são origens de contratos ativos.
|
|
29
|
+
- AGENTS.md e SEMA_BOOT.md: protocolo de operação.
|
|
30
|
+
- sema.config.json: configuração do projeto.
|
|
31
|
+
- SEMA_INDEX.json e AGENT_CONTEXT_PACK.json: bases internas da CLI, sem leitura integral obrigatória.
|
|
32
|
+
- docs/: referências sob demanda.
|
|
96
33
|
|
|
97
|
-
|
|
34
|
+
Depois de modelar e validar o contrato solicitado, gere o suporte necessário com sema compilar <contrato.sema> --alvo <alvo-configurado> --saida <diretório> e implemente o comportamento real.
|
|
98
35
|
|
|
99
|
-
\`\`\`bash
|
|
100
|
-
sema compilar contratos/pedidos.sema --alvo javascript --saida ./generated/javascript
|
|
101
|
-
\`\`\`
|
|
102
36
|
`,
|
|
103
37
|
},
|
|
104
38
|
];
|
|
@@ -123,6 +57,6 @@ export function arquivosTemplateIniciar(template) {
|
|
|
123
57
|
},
|
|
124
58
|
...arquivosBase,
|
|
125
59
|
];
|
|
126
|
-
return anexarApoioIaSemDuplicar(arquivosTemplate);
|
|
60
|
+
return anexarApoioIaSemDuplicar(separarDemonstracoesTemplate(template, arquivosTemplate));
|
|
127
61
|
}
|
|
128
62
|
//# sourceMappingURL=initTemplatesBase.js.map
|
package/dist/projetoBusca.js
CHANGED
package/dist/sessionContext.js
CHANGED
|
@@ -34,7 +34,7 @@ export async function navegarContextoSessao(base, pedido, arquivo) {
|
|
|
34
34
|
resumo: m.purpose,
|
|
35
35
|
arquivos: (m.likelyFiles ?? []).map(relativo),
|
|
36
36
|
})),
|
|
37
|
-
status: encontrados.length === 0 ? "sem_correspondencia" : encontrados.length === 1 ? "contrato_localizado" : "selecionar_contrato",
|
|
37
|
+
status: indice.modulos.length === 0 ? "contrato_necessario" : encontrados.length === 0 ? "sem_correspondencia" : encontrados.length === 1 ? "contrato_localizado" : "selecionar_contrato",
|
|
38
38
|
execucaoAutorizada: false,
|
|
39
39
|
};
|
|
40
40
|
}
|
package/docs/commands.md
CHANGED
|
@@ -18,7 +18,7 @@ Then read every required doc returned by `docs-impacto`.
|
|
|
18
18
|
|
|
19
19
|
## Session Opening
|
|
20
20
|
|
|
21
|
-
- `sema sessao "<intencao>" [--arquivo <contrato-ou-codigo>] [--janela-contexto <tokens>] [--orcamento-contexto <tokens>] [--reserva-saida <tokens>] [--salvar-perfil] --json`: asks for the effective window when absent and stores the profile only on explicit request. The compact response contains workspace identity, artifact freshness, matching contracts and linked files, mandatory document paths, scoped gates and next steps. The index stays inside the CLI. The budget estimates the
|
|
21
|
+
- `sema sessao "<intencao>" [--arquivo <contrato-ou-codigo>] [--janela-contexto <tokens>] [--orcamento-contexto <tokens>] [--reserva-saida <tokens>] [--salvar-perfil] --json`: asks for the effective window when absent and stores the profile only on explicit request. The compact response contains workspace identity, artifact freshness, matching contracts and linked files, mandatory document paths, scoped gates and next steps. The index stays inside the CLI. The budget estimates local entry instructions plus the current delivery using characters/4; it does not measure the conversation or the model's exact tokenizer. Omitted candidates are counted and require scope refinement; mandatory readings are never silently waived. Treat `frescor.fresco:false` as a pre-action blocker and run the suggested `sema sync-codex --json`. Navigation never authorizes execution.
|
|
22
22
|
|
|
23
23
|
## Public JSON output
|
|
24
24
|
|
|
@@ -91,22 +91,31 @@ Ready UI rule: if the task generates an app, site, dashboard, form, or static HT
|
|
|
91
91
|
|
|
92
92
|
## Codex and Context
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
contract changed. Synchronization preserves manual rules outside the managed
|
|
98
|
-
block. The generated workflow uses `drift --cache fresh --pacote --json`; omit
|
|
99
|
-
`--pacote` only when full evidence is needed. A session budget limits that
|
|
100
|
-
session response, not subsequent commands, file reads or the full conversation.
|
|
94
|
+
Project initialization creates configuration and agent rules without inventing a business contract.
|
|
95
|
+
Demonstrations stay under exemplos/; active contracts are authored in contratos/ for the actual request.
|
|
96
|
+
An adopted workspace with no contracts returns contrato_necessario and does not validate an application.
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
The CLI selects context files before generation: micro up to 32,768 tokens,
|
|
99
|
+
short up to 131,072, expanded above that. The budget may lower the selected
|
|
100
|
+
level further. Only the matching summary is materialized; other variants
|
|
101
|
+
are removed from active entry files, with existing edits preserved in
|
|
102
|
+
.sema/contexto-legado/. Internal indexes are not required readings.
|
|
103
|
+
A session already supplying the needed task context does not require another summary.
|
|
104
|
+
|
|
105
|
+
Freshness checks managed instructions, contract hashes and changes to the
|
|
106
|
+
materialized context profile. Synchronization preserves manual AGENTS rules.
|
|
107
|
+
The budget counts AGENTS.md, SEMA_BOOT.md and the current delivery, using
|
|
108
|
+
characters / 4. It does not measure chat history, host instructions or
|
|
109
|
+
cumulative future file reads and tool results. Oversized requests must refine
|
|
110
|
+
the scope; no blocking rule is silently waived.
|
|
111
|
+
|
|
112
|
+
validar and formatar require selected .sema contracts. Empty scope returns
|
|
113
|
+
SEM_CLI_SEM_CONTRATOS and does not validate an application or adopt a project.
|
|
114
|
+
First-time adoption requires consent and the configured context window.
|
|
106
115
|
|
|
107
116
|
- `sema ajuda-ia`: short guidance for Codex.
|
|
108
117
|
- `sema starter-ia`: operational starter.
|
|
109
|
-
- `sema contexto-ia <arquivo.sema> --saida <dir> --json`:
|
|
118
|
+
- `sema contexto-ia <arquivo.sema> --saida <dir> --json`: profile-selected context files; raw AST/IR/drift are consulted separately only when needed.
|
|
110
119
|
- `sema resumo <arquivo-ou-pasta> [--drift <none|cache|fresh>] --json`: compact context; drift is not executed unless requested.
|
|
111
120
|
- `sema prompt-curto <arquivo-ou-pasta> --json`: compact prompt.
|
|
112
121
|
- `sema sync-codex --json`: synchronizes the official Codex entrypoint and local support docs.
|
package/docs/getting-started.md
CHANGED
|
@@ -48,12 +48,20 @@ depend on `PATH`.
|
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
sema descobrir explicar flow.project-adoption --json
|
|
51
|
-
sema iniciar --template base
|
|
51
|
+
sema iniciar --template base --janela-contexto 32768 # example: confirmed window
|
|
52
52
|
sema sync-codex --json
|
|
53
|
-
sema
|
|
53
|
+
sema sessao "describe the requested application" --json
|
|
54
|
+
# Model the actual request in contratos/app.sema before implementation.
|
|
55
|
+
sema validar contratos/app.sema --json
|
|
54
56
|
sema resumo --drift none
|
|
55
57
|
```
|
|
56
58
|
|
|
59
|
+
Initialization creates no business contracts. Examples and template demonstrations
|
|
60
|
+
stay under `exemplos/`, outside the active contract origins. Existing contracts are
|
|
61
|
+
preserved. An empty adopted project asks for the actual requested contract and
|
|
62
|
+
does not claim that an application has been validated. Confirm the configured
|
|
63
|
+
context window; 32,768 above is only an example.
|
|
64
|
+
|
|
57
65
|
Run this sequence only after explicit project-adoption authorization. The
|
|
58
66
|
`sema iniciar` command preserves existing project files and refuses symlink or
|
|
59
67
|
junction escapes. The bootstrap skill never uses `--force`; explicit overwrite
|
package/docs/syntax.md
CHANGED
|
@@ -149,9 +149,9 @@ The project can also generate TypeScript, Python, PHP, Dart, Lua, HTML, CSS, C#/
|
|
|
149
149
|
|
|
150
150
|
- `AGENTS.md`: official Codex repository rules, loaded automatically.
|
|
151
151
|
- `SEMA_BOOT.md`: first Sema read for Codex.
|
|
152
|
-
-
|
|
153
|
-
- `AGENT_CONTEXT_PACK.json`:
|
|
154
|
-
- `SEMA_INDEX.json`: project index.
|
|
152
|
+
- Profile-selected summary: the CLI materializes only the matching file within the configured budget. Skip it if the session already supplied the needed context.
|
|
153
|
+
- `AGENT_CONTEXT_PACK.json`: internal CLI policy database, not an initial read.
|
|
154
|
+
- `SEMA_INDEX.json`: internal CLI project index, not an initial read.
|
|
155
155
|
- `docs/commands.md`: command catalog, gates, and `--saida` rule.
|
|
156
156
|
- `exemplos/`: official DSL examples.
|
|
157
157
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semacode/cli",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5",
|
|
4
4
|
"description": "Local-first semantic governance CLI for AI agents, proven with Claude, Codex, zCode (GLM) and Kimi: contracts, drift, impact, docs gates, and code generation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "logo.png",
|
package/skills/sema/SKILL.md
CHANGED
|
@@ -36,8 +36,9 @@ it does not name Sema. Loading the skill is not consent to adopt it.
|
|
|
36
36
|
sema sync-codex --json
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Read the generated `AGENTS.md` and `SEMA_BOOT.md`.
|
|
40
|
-
|
|
39
|
+
Read the generated `AGENTS.md` and `SEMA_BOOT.md`. Initialization does not
|
|
40
|
+
invent a business contract: examples stay under `exemplos/`. Model the actual
|
|
41
|
+
requested behavior in `contratos/` before implementing; preserve existing contracts. Never add `--force`
|
|
41
42
|
without an explicit overwrite decision.
|
|
42
43
|
5. **Existing Sema project:** read its `AGENTS.md` and `SEMA_BOOT.md`, then run
|
|
43
44
|
`sema sessao "<task intention>" --janela-contexto <confirmed-tokens> --json`.
|
|
@@ -52,7 +53,9 @@ found. If the user corrects a missed Sema workflow, resume it before more writes
|
|
|
52
53
|
Read only the selected contract, declared dependencies and blocking docs.
|
|
53
54
|
`SEMA_INDEX.json` and `AGENT_CONTEXT_PACK.json` are internal CLI databases,
|
|
54
55
|
not files to preload. Resolve stale indexes or ambiguous targets before editing.
|
|
55
|
-
The
|
|
56
|
+
The profile-selected summary is optional: skip it when the session already supplies the needed context.
|
|
57
|
+
The budget counts local entry instructions plus the current delivery, not the whole chat.
|
|
58
|
+
Do not load multiple summaries or choose context size from labels such as small/strong.
|
|
56
59
|
|
|
57
60
|
## CLI fallback and results
|
|
58
61
|
|