@semacode/cli 1.5.9 → 1.5.10
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/README.md +2 -0
- package/SEMA_INDEX.json +1 -1
- package/dist/drift.d.ts +3 -3
- package/dist/drift.js +47 -4
- package/dist/drift.js.map +1 -1
- package/dist/importador.d.ts +1 -1
- package/dist/importador.js +56 -0
- package/dist/importador.js.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/lua-symbols.d.ts +6 -4
- package/dist/lua-symbols.js +74 -54
- package/dist/lua-symbols.js.map +1 -1
- package/dist/projeto.js +6 -0
- package/dist/projeto.js.map +1 -1
- package/dist/tipos.d.ts +1 -1
- package/docs/AGENT_STARTER.md +3 -3
- package/docs/cli.md +2 -0
- package/docs/env.md +3 -3
- package/docs/fluxo-pratico-ia-sema.md +1 -1
- package/docs/integracao-com-ia.md +2 -0
- package/docs/mcp.md +2 -0
- package/docs/sintaxe.md +39 -0
- package/node_modules/@sema/gerador-css/package.json +1 -1
- package/node_modules/@sema/gerador-dart/package.json +1 -1
- package/node_modules/@sema/gerador-html/package.json +1 -1
- package/node_modules/@sema/gerador-javascript/package.json +1 -1
- package/node_modules/@sema/gerador-lua/package.json +1 -1
- package/node_modules/@sema/gerador-python/package.json +1 -1
- package/node_modules/@sema/gerador-typescript/package.json +1 -1
- package/node_modules/@sema/nucleo/dist/ast/tipos.d.ts +1 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.js +4 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/ir/modelos.d.ts +3 -3
- package/node_modules/@sema/nucleo/dist/parser/parser.js +2 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +2 -2
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js +3 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +1 -1
- package/node_modules/@sema/nucleo/package.json +1 -1
- package/node_modules/@sema/padroes/package.json +1 -1
- package/package.json +10 -10
package/dist/importador.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Diagnostico } from "@sema/nucleo";
|
|
2
|
-
export type FonteImportacao = "nestjs" | "fastapi" | "flask" | "nextjs" | "nextjs-consumer" | "react-vite-consumer" | "angular-consumer" | "flutter-consumer" | "firebase" | "typescript" | "python" | "dart" | "dotnet" | "java" | "go" | "rust" | "cpp";
|
|
2
|
+
export type FonteImportacao = "nestjs" | "fastapi" | "flask" | "nextjs" | "nextjs-consumer" | "react-vite-consumer" | "angular-consumer" | "flutter-consumer" | "firebase" | "typescript" | "python" | "dart" | "lua" | "dotnet" | "java" | "go" | "rust" | "cpp";
|
|
3
3
|
export interface ArquivoImportado {
|
|
4
4
|
caminhoRelativo: string;
|
|
5
5
|
conteudo: string;
|
package/dist/importador.js
CHANGED
|
@@ -7,6 +7,7 @@ import { extrairSimbolosCpp } from "./cpp-symbols.js";
|
|
|
7
7
|
import { extrairRotasDotnet, extrairSimbolosDotnet } from "./dotnet-http.js";
|
|
8
8
|
import { extrairRotasGo, extrairSimbolosGo } from "./go-http.js";
|
|
9
9
|
import { extrairRotasJava, extrairSimbolosJava } from "./java-http.js";
|
|
10
|
+
import { extrairSimbolosLua } from "./lua-symbols.js";
|
|
10
11
|
import { extrairParametrosCaminhoFlask, extrairRotasFlaskDecoradas } from "./python-http.js";
|
|
11
12
|
import { extrairRotasRust, extrairSimbolosRust } from "./rust-http.js";
|
|
12
13
|
import { extrairRotasTypeScriptHttp, inferirSemanticaHandlerTypeScriptHttp, localizarExportacaoTypeScriptHttp, } from "./typescript-http.js";
|
|
@@ -1464,6 +1465,7 @@ function renderizarImpl(impl, indentacao = " ") {
|
|
|
1464
1465
|
...(impl.ts ? [`${indentacao} ts: ${impl.ts}`] : []),
|
|
1465
1466
|
...(impl.py ? [`${indentacao} py: ${impl.py}`] : []),
|
|
1466
1467
|
...(impl.dart ? [`${indentacao} dart: ${impl.dart}`] : []),
|
|
1468
|
+
...(impl.lua ? [`${indentacao} lua: ${impl.lua}`] : []),
|
|
1467
1469
|
...(impl.cs ? [`${indentacao} cs: ${impl.cs}`] : []),
|
|
1468
1470
|
...(impl.java ? [`${indentacao} java: ${impl.java}`] : []),
|
|
1469
1471
|
...(impl.go ? [`${indentacao} go: ${impl.go}`] : []),
|
|
@@ -2183,6 +2185,14 @@ function extrairErrosPython(texto) {
|
|
|
2183
2185
|
}
|
|
2184
2186
|
return [...erros.entries()].map(([nome, mensagem]) => ({ nome, mensagem }));
|
|
2185
2187
|
}
|
|
2188
|
+
function extrairErrosLua(texto) {
|
|
2189
|
+
const erros = new Map();
|
|
2190
|
+
for (const match of texto.matchAll(/\berror\s*\(\s*(?:(["'])(.*?)\1|([A-Za-z_]\w*))/g)) {
|
|
2191
|
+
const mensagem = match[2] ?? `Erro importado automaticamente de ${match[3] ?? "error"}.`;
|
|
2192
|
+
erros.set(normalizarNomeErroBruto(mensagem), mensagem);
|
|
2193
|
+
}
|
|
2194
|
+
return [...erros.entries()].map(([nome, mensagem]) => ({ nome, mensagem }));
|
|
2195
|
+
}
|
|
2186
2196
|
function caminhoImplGenerico(diretorioBase, arquivo, simbolo, opcoes) {
|
|
2187
2197
|
const relativo = path.relative(diretorioBase, arquivo).replace(/\.[^.]+$/, "");
|
|
2188
2198
|
const segmentos = relativo.split(path.sep).map((segmento, indice, lista) => opcoes?.snakeCaseUltimoArquivo && indice === lista.length - 1
|
|
@@ -2500,6 +2510,49 @@ async function importarDartBase(diretorio, namespaceBase) {
|
|
|
2500
2510
|
}
|
|
2501
2511
|
return modulos;
|
|
2502
2512
|
}
|
|
2513
|
+
async function importarLuaBase(diretorio, namespaceBase) {
|
|
2514
|
+
const arquivos = (await listarArquivosRecursivos(diretorio, [".lua"]))
|
|
2515
|
+
.filter((arquivo) => !/(^|[\\/])tests?([\\/]|$)|(?:^|[\\/])spec([\\/]|$)|(?:_spec|_test)\.lua$/i.test(arquivo));
|
|
2516
|
+
const modulos = [];
|
|
2517
|
+
for (const arquivo of arquivos) {
|
|
2518
|
+
const texto = await readFile(arquivo, "utf8");
|
|
2519
|
+
const relacao = path.relative(diretorio, arquivo);
|
|
2520
|
+
const contextoSegmentos = inferirContextoPorArquivo(relacao);
|
|
2521
|
+
const nomeModulo = [namespaceBase, ...contextoSegmentos].join(".");
|
|
2522
|
+
const tasks = [];
|
|
2523
|
+
for (const simbolo of selecionarSimbolosPreferidos(extrairSimbolosLua(texto))) {
|
|
2524
|
+
const nomeBase = simbolo.simbolo.split(".").at(-1) ?? simbolo.simbolo;
|
|
2525
|
+
tasks.push({
|
|
2526
|
+
nome: paraSnakeCase(nomeBase),
|
|
2527
|
+
resumo: `Task importada automaticamente de ${relacao}#${simbolo.simbolo}.`,
|
|
2528
|
+
input: simbolo.parametros.map((parametro) => ({
|
|
2529
|
+
nome: normalizarNomeCampoImportado(parametro.nome),
|
|
2530
|
+
tipo: mapearTipoPrimitivo(parametro.tipoTexto ?? "Json"),
|
|
2531
|
+
obrigatorio: parametro.obrigatorio,
|
|
2532
|
+
})),
|
|
2533
|
+
output: [{ nome: "resultado", tipo: "Json", obrigatorio: false }],
|
|
2534
|
+
errors: extrairErrosLua(texto),
|
|
2535
|
+
effects: descreverEfeitosPorHeuristica(texto),
|
|
2536
|
+
impl: { lua: caminhoImplGenerico(diretorio, arquivo, simbolo.simbolo) },
|
|
2537
|
+
origemArquivo: relacao,
|
|
2538
|
+
origemSimbolo: simbolo.simbolo,
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
if (tasks.length === 0) {
|
|
2542
|
+
continue;
|
|
2543
|
+
}
|
|
2544
|
+
modulos.push({
|
|
2545
|
+
nome: nomeModulo,
|
|
2546
|
+
resumo: `Rascunho Sema importado automaticamente de ${relacao}.`,
|
|
2547
|
+
tasks: deduplicarTarefas(tasks),
|
|
2548
|
+
routes: [],
|
|
2549
|
+
entities: [],
|
|
2550
|
+
enums: [],
|
|
2551
|
+
databases: inferirDatabasesPorHeuristica(texto, relacao),
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
return modulos;
|
|
2555
|
+
}
|
|
2503
2556
|
function criarModuloImportadoSimples(nome, resumo, tasks, routes = [], vinculos = [], databases = []) {
|
|
2504
2557
|
sincronizarRotasComTasks(routes, tasks);
|
|
2505
2558
|
return {
|
|
@@ -2891,6 +2944,9 @@ export async function importarProjetoLegado(fonte, diretorio, namespaceBase) {
|
|
|
2891
2944
|
else if (fonte === "dart") {
|
|
2892
2945
|
modulos = await importarDartBase(base, namespace);
|
|
2893
2946
|
}
|
|
2947
|
+
else if (fonte === "lua") {
|
|
2948
|
+
modulos = await importarLuaBase(base, namespace);
|
|
2949
|
+
}
|
|
2894
2950
|
else if (fonte === "dotnet") {
|
|
2895
2951
|
modulos = await importarDotnetBase(base, namespace);
|
|
2896
2952
|
}
|