@semacode/cli 4.2.5 → 4.2.7
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 +5 -4
- package/dist/agentContextPack.js +9 -9
- package/dist/agentEntryPoints.js +37 -12
- package/dist/agentFlowHelp.d.ts +4 -0
- package/dist/agentFlowHelp.js +38 -0
- package/dist/bin.js +6 -2
- package/dist/changeCommands.d.ts +1 -0
- package/dist/changeCommands.js +79 -0
- package/dist/changeScope.d.ts +18 -0
- package/dist/changeScope.js +89 -0
- package/dist/cliArgs.js +1 -0
- package/dist/cliGrammar.js +5 -5
- package/dist/cliHelpTexto.js +5 -5
- package/dist/comandoSessao.js +27 -0
- package/dist/contexto.js +2 -2
- package/dist/discovery/catalog.js +1 -1
- package/dist/docs.part02.js +2 -2
- package/dist/drift.part01.d.ts +5 -1
- package/dist/drift.part06.js +4 -0
- package/dist/drift.part11.js +18 -0
- package/dist/drift.part13.js +1 -1
- package/dist/driftPack.d.ts +4 -0
- package/dist/driftPack.js +8 -2
- package/dist/iaPrompts.d.ts +3 -3
- package/dist/iaPrompts.js +10 -9
- package/dist/index.part01.js +0 -3
- package/dist/index.part03.js +2 -20
- package/dist/index.part04.js +4 -73
- package/dist/index.part06.js +3 -55
- package/dist/javascriptBindings.d.ts +2 -0
- package/dist/javascriptBindings.js +75 -0
- package/dist/saidaCli.js +4 -1
- package/docs/ai-integration.md +9 -5
- package/docs/ai-workflow.md +4 -4
- package/docs/cli.md +1 -1
- package/docs/commands.md +3 -3
- package/docs/documentation.md +19 -4
- package/docs/syntax.md +21 -0
- package/node_modules/@sema/gerador-cpp/dist/index.js +177 -177
- package/node_modules/@sema/gerador-css/dist/index.part01.js +24 -24
- package/node_modules/@sema/gerador-dart/dist/index.js +1 -1
- package/node_modules/@sema/gerador-dotnet/dist/index.js +170 -170
- package/node_modules/@sema/gerador-html/dist/index.js +100 -100
- package/node_modules/@sema/gerador-javascript/dist/index.js +93 -93
- package/node_modules/@sema/gerador-lua/dist/index.js +85 -85
- package/node_modules/@sema/gerador-php/dist/index.js +114 -114
- package/node_modules/@sema/gerador-python/dist/index.part02.js +97 -97
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +145 -145
- package/node_modules/@sema/nucleo/dist/index.d.ts +3 -0
- package/node_modules/@sema/nucleo/dist/index.js +4 -1
- package/node_modules/@sema/nucleo/dist/lexer/lexer.js +13 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js +14 -5
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js +7 -5
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.d.ts +3 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.js +60 -18
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.js +2 -2
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js +11 -2
- package/package.json +1 -1
- package/skills/sema/SKILL.md +15 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.
|
|
2
|
-
//
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.parser_integridade
|
|
2
|
+
// Descrição: parser com diagnóstico estrutural e recuperação sem sucesso parcial silencioso.
|
|
3
3
|
import { criarDiagnostico, } from "../diagnosticos/index.js";
|
|
4
4
|
import { PALAVRAS_BLOCO_NOMEADO_LIVRE, decodificarTextoLiteral } from "./parser.part01.js";
|
|
5
5
|
import { parseModuloParser } from "./parser.modulo.js";
|
|
@@ -14,11 +14,34 @@ export class Parser {
|
|
|
14
14
|
analisar() {
|
|
15
15
|
this.ignorarRuido();
|
|
16
16
|
const modulo = this.parseModulo();
|
|
17
|
+
this.ignorarRuido();
|
|
18
|
+
if (modulo && this.atual().tipo !== "fim_arquivo") {
|
|
19
|
+
this.registrarErro("PAR005", "Há conteúdo depois do fechamento do module.", this.atual().intervalo, undefined, "Mantenha as declarações dentro do único module do arquivo; confira as chaves anteriores. Separe outro módulo em outro .sema.");
|
|
20
|
+
while (this.atual().tipo !== "fim_arquivo")
|
|
21
|
+
this.avancar();
|
|
22
|
+
}
|
|
17
23
|
return { modulo, diagnosticos: this.diagnosticos };
|
|
18
24
|
}
|
|
19
25
|
atual() {
|
|
20
26
|
return this.tokens[this.indice];
|
|
21
27
|
}
|
|
28
|
+
temValor(valor) {
|
|
29
|
+
return !["texto", "comentario"].includes(this.atual().tipo) && this.atual().valor === valor;
|
|
30
|
+
}
|
|
31
|
+
descartarBlocoInvalido() {
|
|
32
|
+
if (!this.temValor("{"))
|
|
33
|
+
return;
|
|
34
|
+
let nivel = 0;
|
|
35
|
+
do {
|
|
36
|
+
if (this.temValor("{"))
|
|
37
|
+
nivel += 1;
|
|
38
|
+
if (this.temValor("}"))
|
|
39
|
+
nivel -= 1;
|
|
40
|
+
this.avancar();
|
|
41
|
+
} while (nivel > 0 && this.atual().tipo !== "fim_arquivo");
|
|
42
|
+
if (nivel > 0)
|
|
43
|
+
this.registrarErro("PAR001", "Bloco inválido não foi fechado.", this.atual().intervalo);
|
|
44
|
+
}
|
|
22
45
|
anterior() {
|
|
23
46
|
return this.tokens[Math.max(0, this.indice - 1)];
|
|
24
47
|
}
|
|
@@ -38,19 +61,19 @@ export class Parser {
|
|
|
38
61
|
return this.tokens[this.indice + distancia];
|
|
39
62
|
}
|
|
40
63
|
iniciaBlocoSimples(keyword) {
|
|
41
|
-
if (this.
|
|
64
|
+
if (!this.temValor(keyword)) {
|
|
42
65
|
return false;
|
|
43
66
|
}
|
|
44
67
|
return this.tokenNaFrente()?.valor === "{";
|
|
45
68
|
}
|
|
46
69
|
iniciaBlocoComNomeObrigatorio(keyword) {
|
|
47
|
-
if (this.
|
|
70
|
+
if (!this.temValor(keyword)) {
|
|
48
71
|
return false;
|
|
49
72
|
}
|
|
50
73
|
return this.tokenNaFrente()?.tipo === "identificador" && this.tokenNaFrente(2)?.valor === "{";
|
|
51
74
|
}
|
|
52
75
|
iniciaBlocoState() {
|
|
53
|
-
if (this.
|
|
76
|
+
if (!this.temValor("state")) {
|
|
54
77
|
return false;
|
|
55
78
|
}
|
|
56
79
|
return this.tokenNaFrente()?.valor === "{"
|
|
@@ -94,7 +117,7 @@ export class Parser {
|
|
|
94
117
|
}
|
|
95
118
|
consumirValor(valor, mensagem) {
|
|
96
119
|
const token = this.atual();
|
|
97
|
-
if (
|
|
120
|
+
if (this.temValor(valor)) {
|
|
98
121
|
this.avancar();
|
|
99
122
|
return token;
|
|
100
123
|
}
|
|
@@ -110,8 +133,8 @@ export class Parser {
|
|
|
110
133
|
this.registrarErro("PAR002", mensagem, token.intervalo, `Esperado token do tipo "${tipo}".`);
|
|
111
134
|
return token;
|
|
112
135
|
}
|
|
113
|
-
registrarErro(codigo, mensagem, intervalo, contexto) {
|
|
114
|
-
this.diagnosticos.push(criarDiagnostico(codigo, mensagem, "erro", intervalo, "Revise a sintaxe do bloco e a ordem das declaracoes.", contexto));
|
|
136
|
+
registrarErro(codigo, mensagem, intervalo, contexto, dica) {
|
|
137
|
+
this.diagnosticos.push(criarDiagnostico(codigo, mensagem, "erro", intervalo, dica ?? "Revise a sintaxe do bloco e a ordem das declaracoes.", contexto));
|
|
115
138
|
}
|
|
116
139
|
parseModulo() {
|
|
117
140
|
return parseModuloParser(this);
|
|
@@ -145,6 +168,12 @@ export class Parser {
|
|
|
145
168
|
return this.parseCorpoBloco(nomeBloco);
|
|
146
169
|
}
|
|
147
170
|
parseBlocoGenerico(palavraChave) {
|
|
171
|
+
if (palavraChave === "desconhecido") {
|
|
172
|
+
const token = this.atual();
|
|
173
|
+
this.registrarErro("PAR007", token.valor === "impl" ? "impl só pode ser declarado dentro de uma task." : `Declaração inválida no module: ${token.valor}.`, token.intervalo, undefined, token.valor === "impl"
|
|
174
|
+
? 'Declare impl { js: app.acao } dentro da task e vinculos { arquivo: "app.js" }. HTML/CSS são arquivos vinculados, não símbolos impl.'
|
|
175
|
+
: "Use uma declaração documentada com o nome obrigatório, como task cadastrar { ... } ou enum Filtro { todas, pendentes }. Consulte docs/syntax.md.");
|
|
176
|
+
}
|
|
148
177
|
const inicioToken = this.avancar();
|
|
149
178
|
let nome;
|
|
150
179
|
if (this.atual().tipo === "identificador") {
|
|
@@ -170,9 +199,9 @@ export class Parser {
|
|
|
170
199
|
const campos = [];
|
|
171
200
|
const linhas = [];
|
|
172
201
|
const blocos = [];
|
|
173
|
-
while (this.atual().tipo !== "fim_arquivo" && this.
|
|
202
|
+
while (this.atual().tipo !== "fim_arquivo" && !this.temValor("}")) {
|
|
174
203
|
this.ignorarRuido();
|
|
175
|
-
if (this.atual().
|
|
204
|
+
if (this.temValor("}") || this.atual().tipo === "fim_arquivo") {
|
|
176
205
|
break;
|
|
177
206
|
}
|
|
178
207
|
if (palavraChave === "tests" && this.atual().valor === "caso") {
|
|
@@ -180,6 +209,13 @@ export class Parser {
|
|
|
180
209
|
continue;
|
|
181
210
|
}
|
|
182
211
|
if (this.iniciaSubblocoConhecido()) {
|
|
212
|
+
const chave = this.atual().valor;
|
|
213
|
+
if (["impl", "vinculos"].includes(chave) && blocos.some((b) => b.tipo === "bloco_generico" && b.palavraChave === chave)) {
|
|
214
|
+
this.registrarErro("PAR008", `Bloco ${chave} repetido no mesmo escopo.`, this.atual().intervalo, undefined, `Reúna os campos em um único bloco ${chave}; blocos repetidos não são mesclados.`);
|
|
215
|
+
}
|
|
216
|
+
if (chave === "impl" && palavraChave !== "task") {
|
|
217
|
+
this.registrarErro("PAR007", "impl só pode ser declarado dentro de uma task.", this.atual().intervalo, undefined, 'Use task acao { impl { js: app.acao } vinculos { arquivo: "app.js" } } para ligar a operação ao código.');
|
|
218
|
+
}
|
|
183
219
|
blocos.push(this.parseBlocoGenerico(this.atual().valor));
|
|
184
220
|
continue;
|
|
185
221
|
}
|
|
@@ -195,7 +231,7 @@ export class Parser {
|
|
|
195
231
|
continue;
|
|
196
232
|
}
|
|
197
233
|
if (["identificador", "palavra_chave"].includes(this.atual().tipo) && this.tokens[this.indice + 1]?.valor === ":") {
|
|
198
|
-
campos.push(this.parseCampo());
|
|
234
|
+
campos.push(this.parseCampo(palavraChave));
|
|
199
235
|
continue;
|
|
200
236
|
}
|
|
201
237
|
const linha = this.parseLinhaDeclarativa();
|
|
@@ -214,13 +250,13 @@ export class Parser {
|
|
|
214
250
|
intervalo: { inicio, fim },
|
|
215
251
|
};
|
|
216
252
|
}
|
|
217
|
-
parseCampo() {
|
|
253
|
+
parseCampo(contexto) {
|
|
218
254
|
const inicio = this.atual().intervalo.inicio;
|
|
219
255
|
const nome = this.avancar().valor;
|
|
220
256
|
this.consumirValor(":", "Era esperado ':' depois do nome do campo.");
|
|
221
257
|
const partes = [];
|
|
222
258
|
let profundidade = 0;
|
|
223
|
-
while (
|
|
259
|
+
while (!["fim_arquivo", "nova_linha", "comentario"].includes(this.atual().tipo) && !this.temValor("}")) {
|
|
224
260
|
const proximoToken = this.tokens[this.indice + 1];
|
|
225
261
|
const iniciaNovoCampo = profundidade === 0
|
|
226
262
|
&& partes.length > 0
|
|
@@ -231,15 +267,18 @@ export class Parser {
|
|
|
231
267
|
}
|
|
232
268
|
const token = this.avancar();
|
|
233
269
|
partes.push(token);
|
|
234
|
-
if (["<", "[", "("].includes(token.valor)) {
|
|
270
|
+
if (token.tipo !== "texto" && ["<", "[", "("].includes(token.valor)) {
|
|
235
271
|
profundidade += 1;
|
|
236
272
|
}
|
|
237
|
-
else if ([">", "]", ")"].includes(token.valor)) {
|
|
273
|
+
else if (token.tipo !== "texto" && [">", "]", ")"].includes(token.valor)) {
|
|
238
274
|
profundidade = Math.max(0, profundidade - 1);
|
|
239
275
|
}
|
|
240
276
|
}
|
|
241
277
|
const segmentos = partes.filter((token) => token.valor.length > 0);
|
|
242
278
|
const possuiTextoLiteral = segmentos.some((token) => token.tipo === "texto");
|
|
279
|
+
if (contexto === "vinculos" && nome === "arquivo" && (partes.length !== 1 || partes[0]?.tipo !== "texto")) {
|
|
280
|
+
this.registrarErro("PAR004", "arquivo no vínculo exige um único caminho entre aspas.", { inicio, fim: this.anterior().intervalo.fim }, undefined, 'Use arquivo: "app.js". Repita arquivo: "outro.css" para outro arquivo.');
|
|
281
|
+
}
|
|
243
282
|
if (possuiTextoLiteral) {
|
|
244
283
|
const valorLiteral = segmentos.map((token) => token.tipo === "texto" ? decodificarTextoLiteral(token.valor) : token.valor).join(" ");
|
|
245
284
|
if (this.atual().tipo === "nova_linha") {
|
|
@@ -253,6 +292,9 @@ export class Parser {
|
|
|
253
292
|
intervalo: { inicio, fim: this.anterior().intervalo.fim },
|
|
254
293
|
};
|
|
255
294
|
}
|
|
295
|
+
if (nome === "arquivo" && segmentos.some((token) => /[\\/]/.test(token.valor))) {
|
|
296
|
+
this.diagnosticos.push(criarDiagnostico("PAR004", "Caminho de arquivo deve estar entre aspas para preservar separadores e espaços.", "erro", { inicio, fim: this.anterior().intervalo.fim }, `Use arquivo: ${JSON.stringify(segmentos.map((t) => t.valor).join(""))}`));
|
|
297
|
+
}
|
|
256
298
|
const tipoTokens = [];
|
|
257
299
|
const modificadores = [];
|
|
258
300
|
let profundidadeTipo = 0;
|
|
@@ -304,7 +346,7 @@ export class Parser {
|
|
|
304
346
|
parseLinhaDeclarativa() {
|
|
305
347
|
const inicio = this.atual().intervalo.inicio;
|
|
306
348
|
const partes = [];
|
|
307
|
-
while (
|
|
349
|
+
while (!["fim_arquivo", "nova_linha", "comentario"].includes(this.atual().tipo) && !this.temValor("}")) {
|
|
308
350
|
partes.push(this.avancar().valor);
|
|
309
351
|
}
|
|
310
352
|
if (this.atual().tipo === "nova_linha") {
|
|
@@ -329,9 +371,9 @@ export class Parser {
|
|
|
329
371
|
let error;
|
|
330
372
|
let docs;
|
|
331
373
|
let comments;
|
|
332
|
-
while (this.atual().tipo !== "fim_arquivo" && this.
|
|
374
|
+
while (this.atual().tipo !== "fim_arquivo" && !this.temValor("}")) {
|
|
333
375
|
this.ignorarRuido();
|
|
334
|
-
if (this.atual().
|
|
376
|
+
if (this.temValor("}") || this.atual().tipo === "fim_arquivo") {
|
|
335
377
|
break;
|
|
336
378
|
}
|
|
337
379
|
switch (this.atual().valor) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.
|
|
2
|
-
//
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.parser_integridade
|
|
2
|
+
// Descrição: entrada do parser governado por contratos/sema/parser_integridade.sema.
|
|
3
3
|
import { Parser } from "./parser.part02.js";
|
|
4
4
|
export { normalizarOrigemUse } from "./parser.declaracoes.js";
|
|
5
5
|
export function parsear(tokens) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.software
|
|
1
|
+
// SEMA-GOVERNED: sema.software, sema.produto.dsl_impl, sema.produto.parser_integridade
|
|
2
2
|
// Descricao: nucleo semantico particionado; consulte contratos/sema/software.sema antes de editar.
|
|
3
3
|
import { criarDiagnostico } from "../diagnosticos/index.js";
|
|
4
4
|
export function ehUseInterop(use) {
|
|
@@ -275,6 +275,9 @@ export function validarImplementacoesTask(task, diagnosticos) {
|
|
|
275
275
|
if (!task.impl) {
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
|
+
if (task.impl.campos.length === 0 || task.impl.linhas.length > 0 || task.impl.blocos.length > 0) {
|
|
279
|
+
diagnosticos.push(criarDiagnostico("SEM061", `Task "${task.nome}" exige campos de símbolo no bloco impl.`, "erro", task.impl.intervalo, 'Dentro da task, use impl { js: app.cadastrar }. O arquivo fica em vinculos { arquivo: "app.js" }; setas e subblocos não declaram implementações.'));
|
|
280
|
+
}
|
|
278
281
|
const chaves = new Set();
|
|
279
282
|
for (const campo of task.impl.campos) {
|
|
280
283
|
const nome = normalizarNomeCampoImplementacao(campo.nome);
|
|
@@ -289,7 +292,7 @@ export function validarImplementacoesTask(task, diagnosticos) {
|
|
|
289
292
|
continue;
|
|
290
293
|
}
|
|
291
294
|
chaves.add(chave);
|
|
292
|
-
if (!PADRAO_CAMINHO_INTEROP.test(campo.valor)) {
|
|
295
|
+
if (!PADRAO_CAMINHO_INTEROP.test(campo.valor) || campo.modificadores.length > 0) {
|
|
293
296
|
diagnosticos.push(criarDiagnostico("SEM061", `Task "${task.nome}" declarou caminho invalido para impl ${rotulo}: "${campo.valor}".`, "erro", campo.intervalo, "Use um identificador de implementacao como pacote.modulo.funcao ou app.servico.metodo."));
|
|
294
297
|
}
|
|
295
298
|
}
|
|
@@ -298,7 +301,13 @@ export function validarVinculos(bloco, diagnosticos, contexto) {
|
|
|
298
301
|
if (!bloco) {
|
|
299
302
|
return;
|
|
300
303
|
}
|
|
304
|
+
if (bloco.campos.length === 0 || bloco.linhas.length > 0 || bloco.blocos.length > 0) {
|
|
305
|
+
diagnosticos.push(criarDiagnostico("SEM126", `Vínculos em ${contexto} exigem campos, não setas ou subblocos.`, "erro", bloco.intervalo, 'Use vinculos { arquivo: "app.js" simbolo: app.cadastrar }. Coloque esse bloco na task correspondente; repita arquivo para outros arquivos.'));
|
|
306
|
+
}
|
|
301
307
|
for (const campo of bloco.campos) {
|
|
308
|
+
if (!campo.valor.trim()) {
|
|
309
|
+
diagnosticos.push(criarDiagnostico("SEM126", `Vínculo "${campo.nome}" vazio em ${contexto}.`, "erro", campo.intervalo, 'Informe uma referência concreta, por exemplo arquivo: "app.js" ou simbolo: app.cadastrar.'));
|
|
310
|
+
}
|
|
302
311
|
if (!CAMPOS_VINCULO_SUPORTADOS.has(campo.nome)) {
|
|
303
312
|
diagnosticos.push(criarDiagnostico("SEM064", `Campo de vinculo "${campo.nome}" nao e suportado em ${contexto}.`, "erro", campo.intervalo, "Use arquivo, simbolo, recurso, superficie, rota, teste, tabela, fila, job, policy, artefato, evento, cache, storage, worker, cron ou webhook."));
|
|
304
313
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semacode/cli",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.7",
|
|
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
|
@@ -45,6 +45,21 @@ it does not name Sema. Loading the skill is not consent to adopt it.
|
|
|
45
45
|
Follow the local gates and selected contract through implementation/testing.
|
|
46
46
|
Save a context profile only with `--salvar-perfil` as requested.
|
|
47
47
|
|
|
48
|
+
Run `docs-impacto --intencao "<intent>" --arquivo <contract> --json` and retain
|
|
49
|
+
`mudancaId`. After compaction, resume `sessao --mudanca-id <id> --json`.
|
|
50
|
+
Use the returned argument arrays for closure; repeat `--doc-lida` only for docs
|
|
51
|
+
actually read. Hashes reuse declarations until a file changes. Missing scope or
|
|
52
|
+
nonexistent files block closure. This gate checks declarations, not comprehension
|
|
53
|
+
or behavior: validation, fresh drift and application tests remain separate.
|
|
54
|
+
Use `drift <contract> --cache fresh --pacote --json` and inspect evidence gaps;
|
|
55
|
+
consume JSON without truncating lines or object depth. When creating a contract,
|
|
56
|
+
plan each task's `impl { js: app.cadastrar }` and
|
|
57
|
+
`vinculos { arquivo: "app.js" simbolo: app.cadastrar }` before implementation.
|
|
58
|
+
Confirm the planned files and symbols with fresh drift once they exist.
|
|
59
|
+
Link HTML/CSS as module files; they are not JavaScript implementations.
|
|
60
|
+
`SEMA-GOVERNED` headers identify ownership but do not replace task mappings.
|
|
61
|
+
Quote `arquivo` paths. Do not convert plain JavaScript to ES modules for Sema.
|
|
62
|
+
|
|
48
63
|
`sema formatar` formats .sema contracts and `sema validar` validates those
|
|
49
64
|
contracts. Neither adopts a project or proves that HTML, CSS, JavaScript or
|
|
50
65
|
the application works. Report what was actually checked, including no contracts
|