@semacode/cli 2.2.0 → 2.3.1
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/LICENSE +39 -39
- package/README.md +251 -141
- package/dist/agentContext.d.ts +1 -1
- package/dist/agentContextPack.js +6 -1
- package/dist/agentContextTipos.d.ts +4 -2
- package/dist/agentContextTipos.js +7 -0
- package/dist/agentEntryPoints.js +551 -499
- package/dist/angular-consumer-standalone.d.ts +3 -1
- package/dist/angular-consumer-standalone.js +12 -8
- package/dist/comandos.js +4 -0
- package/dist/discovery/catalog.d.ts +11 -0
- package/dist/discovery/catalog.js +521 -0
- package/dist/discovery/command.d.ts +11 -0
- package/dist/discovery/command.js +226 -0
- package/dist/discovery/index.d.ts +5 -0
- package/dist/discovery/index.js +8 -0
- package/dist/discovery/ranker.d.ts +3 -0
- package/dist/discovery/ranker.js +310 -0
- package/dist/discovery/redaction.d.ts +2 -0
- package/dist/discovery/redaction.js +21 -0
- package/dist/discovery/render.d.ts +2 -0
- package/dist/discovery/render.js +100 -0
- package/dist/discovery/types.d.ts +119 -0
- package/dist/discovery/types.js +13 -0
- package/dist/drift.part01.d.ts +32 -2
- package/dist/drift.part01.js +2 -0
- package/dist/drift.part04.d.ts +3 -2
- package/dist/drift.part04.js +6 -3
- package/dist/drift.part05.d.ts +2 -1
- package/dist/drift.part05.js +4 -3
- package/dist/drift.part06.d.ts +2 -1
- package/dist/drift.part06.js +9 -5
- package/dist/drift.part07.d.ts +11 -10
- package/dist/drift.part07.js +40 -30
- package/dist/drift.part08.d.ts +2 -1
- package/dist/drift.part08.js +4 -3
- package/dist/drift.part11.js +71 -6
- package/dist/drift.part12.js +14 -1
- package/dist/drift.part13.d.ts +42 -7
- package/dist/drift.part13.js +660 -36
- package/dist/driftCache.d.ts +49 -0
- package/dist/driftCache.js +311 -0
- package/dist/driftCacheIncremental.d.ts +98 -0
- package/dist/driftCacheIncremental.js +596 -0
- package/dist/driftCatalogo.d.ts +91 -0
- package/dist/driftCatalogo.js +657 -0
- package/dist/driftCatalogoPersistente.d.ts +8 -0
- package/dist/driftCatalogoPersistente.js +77 -0
- package/dist/driftEscopo.d.ts +23 -0
- package/dist/driftEscopo.js +563 -0
- package/dist/driftEscopoReferencias.d.ts +4 -0
- package/dist/driftEscopoReferencias.js +265 -0
- package/dist/driftOrcamento.d.ts +12 -0
- package/dist/driftOrcamento.js +19 -3
- package/dist/execucoesExternas.js +5 -19
- package/dist/exemplosOficiais.js +29 -8
- package/dist/iaPrompts.d.ts +1 -1
- package/dist/iaPrompts.js +310 -307
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -5
- package/dist/index.part01.d.ts +17 -2
- package/dist/index.part01.js +119 -8
- package/dist/index.part02.js +21 -21
- package/dist/index.part03.d.ts +2 -2
- package/dist/index.part03.js +14 -3
- package/dist/index.part04.d.ts +2 -2
- package/dist/index.part04.js +113 -101
- package/dist/index.part05.d.ts +1 -1
- package/dist/index.part05.js +99 -22
- package/dist/index.part06.js +6 -2
- package/dist/index.part07.js +24 -24
- package/dist/index.part08.js +1 -1
- package/dist/init/templates.part01.js +393 -393
- package/dist/init/templates.part02.js +189 -189
- package/dist/initTemplatesBackend.js +73 -73
- package/dist/initTemplatesBase.js +81 -80
- package/dist/initTemplatesFlutter.js +137 -137
- package/dist/initTemplatesRuntime.js +350 -350
- package/dist/initTemplatesWeb.js +309 -309
- package/dist/pipelineConteudo/command.js +1 -36
- package/dist/profileArtefatoValidadores.d.ts +3 -2
- package/dist/profileArtefatoValidadores.js +81 -0
- package/dist/profileAuthorTipos.d.ts +4 -3
- package/dist/profileCatalogo.d.ts +5 -5
- package/dist/profileCatalogo.js +30 -0
- package/dist/profileCommand.d.ts +8 -2
- package/dist/profileCommand.js +15 -5
- package/dist/profileRegras.d.ts +5 -5
- package/dist/profileRegras.js +13 -1
- package/dist/profileRulePacks.js +68 -0
- package/dist/projeto.d.ts +1 -1
- package/dist/projetoCarregar.d.ts +2 -2
- package/dist/projetoCarregar.js +47 -24
- package/dist/projetoCatalogo.d.ts +7 -0
- package/dist/projetoCatalogo.js +125 -0
- package/dist/projetoTipos.d.ts +14 -5
- package/dist/sistemasInterativos/adapterProtocol.d.ts +3 -0
- package/dist/sistemasInterativos/adapterProtocol.js +240 -0
- package/dist/sistemasInterativos/advancedCatalog.d.ts +5 -0
- package/dist/sistemasInterativos/advancedCatalog.js +442 -0
- package/dist/sistemasInterativos/autonomy.d.ts +230 -0
- package/dist/sistemasInterativos/autonomy.js +753 -0
- package/dist/sistemasInterativos/canonical.d.ts +3 -0
- package/dist/sistemasInterativos/canonical.js +43 -0
- package/dist/sistemasInterativos/catalog.d.ts +116 -0
- package/dist/sistemasInterativos/catalog.js +543 -0
- package/dist/sistemasInterativos/command.d.ts +7 -0
- package/dist/sistemasInterativos/command.js +311 -0
- package/dist/sistemasInterativos/controlRun.d.ts +56 -0
- package/dist/sistemasInterativos/controlRun.js +391 -0
- package/dist/sistemasInterativos/evidence.d.ts +5 -0
- package/dist/sistemasInterativos/evidence.js +306 -0
- package/dist/sistemasInterativos/experienceIr.d.ts +12 -0
- package/dist/sistemasInterativos/experienceIr.js +895 -0
- package/dist/sistemasInterativos/experienceIrSemantics.d.ts +30 -0
- package/dist/sistemasInterativos/experienceIrSemantics.js +368 -0
- package/dist/sistemasInterativos/experienceIrTypes.d.ts +370 -0
- package/dist/sistemasInterativos/experienceIrTypes.js +5 -0
- package/dist/sistemasInterativos/extensionCommand.d.ts +391 -0
- package/dist/sistemasInterativos/extensionCommand.js +383 -0
- package/dist/sistemasInterativos/index.d.ts +19 -0
- package/dist/sistemasInterativos/index.js +22 -0
- package/dist/sistemasInterativos/operations.d.ts +40 -0
- package/dist/sistemasInterativos/operations.js +1167 -0
- package/dist/sistemasInterativos/operationsTypes.d.ts +297 -0
- package/dist/sistemasInterativos/operationsTypes.js +11 -0
- package/dist/sistemasInterativos/planner.d.ts +2 -0
- package/dist/sistemasInterativos/planner.js +159 -0
- package/dist/sistemasInterativos/portability.d.ts +164 -0
- package/dist/sistemasInterativos/portability.js +539 -0
- package/dist/sistemasInterativos/render.d.ts +3 -0
- package/dist/sistemasInterativos/render.js +179 -0
- package/dist/sistemasInterativos/temporal.d.ts +183 -0
- package/dist/sistemasInterativos/temporal.js +543 -0
- package/dist/sistemasInterativos/types.d.ts +215 -0
- package/dist/sistemasInterativos/types.js +4 -0
- package/dist/sistemasInterativos/validator.d.ts +2 -0
- package/dist/sistemasInterativos/validator.js +305 -0
- package/dist/sync/index.js +35 -35
- package/docs/README.md +34 -28
- package/docs/ai-onboarding.md +62 -62
- package/docs/ai-workflow.md +9 -4
- package/docs/auth.md +26 -26
- package/docs/cli.md +79 -79
- package/docs/commands.md +47 -2
- package/docs/database.md +15 -15
- package/docs/deploy.md +41 -41
- package/docs/descoberta-capacidades.md +106 -0
- package/docs/documentation.md +39 -39
- package/docs/env.md +16 -16
- package/docs/frontend.md +41 -41
- package/docs/getting-started.md +57 -57
- package/docs/i18n.md +15 -15
- package/docs/pipeline-conteudo.md +246 -246
- package/docs/profiles.md +54 -45
- package/docs/repositories.md +43 -43
- package/docs/rollback.md +31 -31
- package/docs/security.md +32 -32
- package/docs/sistemas-interativos.md +376 -0
- package/docs/support.md +8 -8
- package/docs/testing.md +51 -35
- package/docs/vocabulary.md +29 -29
- package/exemplos/agendamento.sema +1 -1
- package/exemplos/assinatura.sema +1 -1
- package/exemplos/auditoria.sema +1 -1
- package/exemplos/autenticacao.sema +1 -1
- package/exemplos/author_obra_comum.sema +1 -1
- package/exemplos/author_tema_sensivel.sema +1 -1
- package/exemplos/automacao.sema +1 -1
- package/exemplos/cadastro_usuario.sema +1 -1
- package/exemplos/calculadora.sema +1 -1
- package/exemplos/crud_simples.sema +1 -1
- package/exemplos/estoque.sema +1 -1
- package/exemplos/exportacao.sema +1 -1
- package/exemplos/fila.sema +1 -1
- package/exemplos/integracao_externa.sema +1 -1
- package/exemplos/multi_tenant.sema +1 -1
- package/exemplos/notificacao.sema +1 -1
- package/exemplos/operacao_estrategia.sema +132 -132
- package/exemplos/operacao_estrategia_discovery.sema +220 -220
- package/exemplos/operacao_estrategia_fluxo.sema +114 -114
- package/exemplos/operacao_estrategia_gates.sema +106 -106
- package/exemplos/operacao_estrategia_quarentena.sema +133 -133
- package/exemplos/operacao_estrategia_rollout.sema +124 -124
- package/exemplos/pagamento.sema +1 -1
- package/exemplos/pagamento_dominio.sema +1 -1
- package/exemplos/pedido.sema +1 -1
- package/exemplos/permissao.sema +1 -1
- package/exemplos/persistencia_vendor_first.sema +1 -1
- package/exemplos/pipeline-conteudo/README.md +44 -44
- package/exemplos/pipeline-conteudo/alvos.json +23 -23
- package/exemplos/pipeline-conteudo/definicao.json +136 -136
- package/exemplos/profile_conversas.sema +165 -165
- package/exemplos/profile_game.sema +1 -1
- package/exemplos/profile_legal.sema +1 -1
- package/exemplos/profile_ops.sema +1 -1
- package/exemplos/profile_research.sema +1 -1
- package/exemplos/profile_simulation.sema +211 -0
- package/exemplos/profile_software.sema +1 -1
- package/exemplos/profile_workflow_n8n.sema +1 -1
- package/exemplos/relatorio.sema +1 -1
- package/exemplos/replica_analitica_erp.sema +1 -1
- package/exemplos/sistemas-interativos/README.md +100 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -0
- package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -0
- package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -0
- package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -0
- package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -0
- package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -0
- package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -0
- package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -0
- package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -0
- package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -0
- package/exemplos/sistemas-interativos/game-2d.json +83 -0
- package/exemplos/sistemas-interativos/game-3d-human.json +81 -0
- package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -0
- package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -0
- package/exemplos/sistemas-interativos/game-xr-human.json +80 -0
- package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -0
- package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -0
- package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -0
- package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -0
- package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -0
- package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -0
- package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -0
- package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -0
- package/exemplos/testes_embutidos.sema +1 -1
- package/exemplos/tratamento_erro.sema +1 -1
- package/exemplos/upload_arquivo.sema +1 -1
- package/exemplos/webhook.sema +1 -1
- package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
- package/node_modules/@sema/gerador-cpp/package.json +1 -1
- package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
- package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
- package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
- package/node_modules/@sema/gerador-dotnet/package.json +1 -1
- package/node_modules/@sema/gerador-html/dist/index.js +17 -17
- package/node_modules/@sema/gerador-lua/dist/index.js +76 -47
- package/node_modules/@sema/gerador-lua/dist/index.js.map +1 -1
- package/node_modules/@sema/gerador-php/dist/index.js +113 -113
- package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
- package/package.json +3 -3
|
@@ -278,15 +278,15 @@ function ordenarModelos(modulo) {
|
|
|
278
278
|
}
|
|
279
279
|
function gerarStruct(nome, campos, modulo, modo) {
|
|
280
280
|
const linhas = campos.map((campo) => ` ${tipoCampoCpp(campo)} ${identificadorCpp(campo.nome)} = ${valorInicialCpp(campo, modulo, modo)};`);
|
|
281
|
-
return `struct ${paraPascalCase(nome)} final {
|
|
282
|
-
${linhas.length > 0 ? linhas.join("\n") : " // Estrutura intencionalmente vazia."}
|
|
283
|
-
bool operator==(const ${paraPascalCase(nome)}&) const = default;
|
|
281
|
+
return `struct ${paraPascalCase(nome)} final {
|
|
282
|
+
${linhas.length > 0 ? linhas.join("\n") : " // Estrutura intencionalmente vazia."}
|
|
283
|
+
bool operator==(const ${paraPascalCase(nome)}&) const = default;
|
|
284
284
|
};`;
|
|
285
285
|
}
|
|
286
286
|
function gerarEnum(nome, valores) {
|
|
287
287
|
const itens = (valores.length > 0 ? valores : ["VAZIO"]).map((valor) => ` ${paraConstanteCpp(valor)}`).join(",\n");
|
|
288
|
-
return `enum class ${paraPascalCase(nome)} {
|
|
289
|
-
${itens}
|
|
288
|
+
return `enum class ${paraPascalCase(nome)} {
|
|
289
|
+
${itens}
|
|
290
290
|
};`;
|
|
291
291
|
}
|
|
292
292
|
function camposPorNome(campos) {
|
|
@@ -453,10 +453,10 @@ function nomeClasseErro(task, codigo) {
|
|
|
453
453
|
return `${paraPascalCase(task.nome)}${paraPascalCase(codigo)}Erro`;
|
|
454
454
|
}
|
|
455
455
|
function gerarErrosTask(task) {
|
|
456
|
-
return [...coletarErrosTask(task).entries()].map(([codigo, mensagem]) => `class ${nomeClasseErro(task, codigo)} final : public std::runtime_error {
|
|
457
|
-
public:
|
|
458
|
-
inline static constexpr std::string_view codigo = ${literalStringCpp(codigo)};
|
|
459
|
-
${nomeClasseErro(task, codigo)}() : std::runtime_error(${literalStringCpp(mensagem)}) {}
|
|
456
|
+
return [...coletarErrosTask(task).entries()].map(([codigo, mensagem]) => `class ${nomeClasseErro(task, codigo)} final : public std::runtime_error {
|
|
457
|
+
public:
|
|
458
|
+
inline static constexpr std::string_view codigo = ${literalStringCpp(codigo)};
|
|
459
|
+
${nomeClasseErro(task, codigo)}() : std::runtime_error(${literalStringCpp(mensagem)}) {}
|
|
460
460
|
};`).join("\n\n");
|
|
461
461
|
}
|
|
462
462
|
function literalCamposContrato(campos) {
|
|
@@ -471,13 +471,13 @@ function gerarDeclaracoesTask(task, modulo) {
|
|
|
471
471
|
const nome = identificadorCpp(task.nome);
|
|
472
472
|
const entrada = paraPascalCase(`${task.nome}_entrada`);
|
|
473
473
|
const saida = paraPascalCase(`${task.nome}_saida`);
|
|
474
|
-
return `${gerarStruct(`${task.nome}_entrada`, task.input, modulo, "entrada")}
|
|
475
|
-
|
|
476
|
-
${gerarStruct(`${task.nome}_saida`, task.output, modulo, "saida")}
|
|
477
|
-
|
|
478
|
-
${gerarErrosTask(task)}${coletarErrosTask(task).size > 0 ? "\n\n" : ""}TaskContract contrato_${nome}();
|
|
479
|
-
void validar_${nome}(const ${entrada}& entrada);
|
|
480
|
-
void verificar_garantias_${nome}(const ${saida}& saida);
|
|
474
|
+
return `${gerarStruct(`${task.nome}_entrada`, task.input, modulo, "entrada")}
|
|
475
|
+
|
|
476
|
+
${gerarStruct(`${task.nome}_saida`, task.output, modulo, "saida")}
|
|
477
|
+
|
|
478
|
+
${gerarErrosTask(task)}${coletarErrosTask(task).size > 0 ? "\n\n" : ""}TaskContract contrato_${nome}();
|
|
479
|
+
void validar_${nome}(const ${entrada}& entrada);
|
|
480
|
+
void verificar_garantias_${nome}(const ${saida}& saida);
|
|
481
481
|
${saida} executar_${nome}(const ${entrada}& entrada, const ExecutionContext& contexto = {});`;
|
|
482
482
|
}
|
|
483
483
|
function valorExistenteCpp(campo, modulo) {
|
|
@@ -575,32 +575,32 @@ function gerarImplementacaoTask(task, modulo) {
|
|
|
575
575
|
? task.efeitosEstruturados.map((efeito) => ` // Efeito estruturado: categoria=${comentarioCpp(efeito.categoria)} alvo=${comentarioCpp(efeito.alvo)}${efeito.detalhe ? ` detalhe=${comentarioCpp(efeito.detalhe)}` : ""}${efeito.criticidade ? ` criticidade=${efeito.criticidade}` : ""}`).join("\n")
|
|
576
576
|
: task.effects.map((efeito) => ` // Efeito declarado: ${comentarioCpp(efeito)}`).join("\n");
|
|
577
577
|
const metadadosEfeitos = task.efeitosEstruturados.map((efeito) => `${efeito.categoria}:${efeito.alvo}${efeito.detalhe ? `:${efeito.detalhe}` : ""}`);
|
|
578
|
-
return `TaskContract contrato_${nome}() {
|
|
579
|
-
return TaskContract{
|
|
580
|
-
${literalStringCpp(task.nome)},
|
|
581
|
-
${literalCamposContrato(task.input)},
|
|
582
|
-
${literalCamposContrato(task.output)},
|
|
583
|
-
${literalStringsCpp(task.rules)},
|
|
584
|
-
${literalStringsCpp(task.guarantees)},
|
|
585
|
-
${literalStringsCpp(metadadosEfeitos.length > 0 ? metadadosEfeitos : task.effects)}
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
void validar_${nome}(const ${entrada}& entrada) {
|
|
590
|
-
${gerarValidacoes(task, modulo)}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
void verificar_garantias_${nome}(const ${saida}& saida) {
|
|
594
|
-
${gerarGarantias(task, modulo)}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
${saida} executar_${nome}(const ${entrada}& entrada, const ExecutionContext& contexto) {
|
|
598
|
-
(void)contexto;
|
|
599
|
-
${falhas ? `${falhas}\n` : ""} validar_${nome}(entrada);
|
|
600
|
-
${task.stateContract ? ` // Vínculo de estado: ${comentarioCpp(task.stateContract.nomeEstado ?? "não definido")}\n // Transições: ${comentarioCpp(task.stateContract.transicoes.map((item) => `${item.origem}->${item.destino}`).join(", ") || "nenhuma")}\n` : ""}${task.implementacoesExternas.map((item) => ` // Implementação externa: origem=${item.origem} caminho=${comentarioCpp(item.caminho)} status=${item.statusImpl ?? "não verificado"}`).join("\n")}${task.implementacoesExternas.length > 0 ? "\n" : ""}${efeitos || " // Nenhum efeito declarado."}
|
|
601
|
-
${saida} saida{};
|
|
602
|
-
${gerarAjustesSaida(task, modulo).join("\n")}${gerarAjustesSaida(task, modulo).length > 0 ? "\n" : ""} verificar_garantias_${nome}(saida);
|
|
603
|
-
return saida;
|
|
578
|
+
return `TaskContract contrato_${nome}() {
|
|
579
|
+
return TaskContract{
|
|
580
|
+
${literalStringCpp(task.nome)},
|
|
581
|
+
${literalCamposContrato(task.input)},
|
|
582
|
+
${literalCamposContrato(task.output)},
|
|
583
|
+
${literalStringsCpp(task.rules)},
|
|
584
|
+
${literalStringsCpp(task.guarantees)},
|
|
585
|
+
${literalStringsCpp(metadadosEfeitos.length > 0 ? metadadosEfeitos : task.effects)}
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
void validar_${nome}(const ${entrada}& entrada) {
|
|
590
|
+
${gerarValidacoes(task, modulo)}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
void verificar_garantias_${nome}(const ${saida}& saida) {
|
|
594
|
+
${gerarGarantias(task, modulo)}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
${saida} executar_${nome}(const ${entrada}& entrada, const ExecutionContext& contexto) {
|
|
598
|
+
(void)contexto;
|
|
599
|
+
${falhas ? `${falhas}\n` : ""} validar_${nome}(entrada);
|
|
600
|
+
${task.stateContract ? ` // Vínculo de estado: ${comentarioCpp(task.stateContract.nomeEstado ?? "não definido")}\n // Transições: ${comentarioCpp(task.stateContract.transicoes.map((item) => `${item.origem}->${item.destino}`).join(", ") || "nenhuma")}\n` : ""}${task.implementacoesExternas.map((item) => ` // Implementação externa: origem=${item.origem} caminho=${comentarioCpp(item.caminho)} status=${item.statusImpl ?? "não verificado"}`).join("\n")}${task.implementacoesExternas.length > 0 ? "\n" : ""}${efeitos || " // Nenhum efeito declarado."}
|
|
601
|
+
${saida} saida{};
|
|
602
|
+
${gerarAjustesSaida(task, modulo).join("\n")}${gerarAjustesSaida(task, modulo).length > 0 ? "\n" : ""} verificar_garantias_${nome}(saida);
|
|
603
|
+
return saida;
|
|
604
604
|
}`;
|
|
605
605
|
}
|
|
606
606
|
function formatarValorTesteCpp(valor, campo, modulo) {
|
|
@@ -636,18 +636,18 @@ function gerarFuncaoTeste(task, indice, modulo) {
|
|
|
636
636
|
return {
|
|
637
637
|
nome,
|
|
638
638
|
rotulo: caso.nome,
|
|
639
|
-
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
640
|
-
void ${nome}() {
|
|
641
|
-
${entrada} entrada{};
|
|
642
|
-
${atribuicoes ? `${atribuicoes}\n` : ""} ExecutionContext contexto{};
|
|
643
|
-
contexto.erro_esperado = ${literalStringCpp(tipoErro)};
|
|
644
|
-
try {
|
|
645
|
-
(void)executar_${identificadorCpp(task.nome)}(entrada, contexto);
|
|
646
|
-
} catch (const ${nomeClasseErro(task, tipoErro)}& erro) {
|
|
647
|
-
assert_sema(erro.codigo == ${literalStringCpp(tipoErro)}, "Código de erro inesperado");
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
throw std::runtime_error(${literalStringCpp(`Caso ${caso.nome} deveria falhar com ${tipoErro}`)});
|
|
639
|
+
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
640
|
+
void ${nome}() {
|
|
641
|
+
${entrada} entrada{};
|
|
642
|
+
${atribuicoes ? `${atribuicoes}\n` : ""} ExecutionContext contexto{};
|
|
643
|
+
contexto.erro_esperado = ${literalStringCpp(tipoErro)};
|
|
644
|
+
try {
|
|
645
|
+
(void)executar_${identificadorCpp(task.nome)}(entrada, contexto);
|
|
646
|
+
} catch (const ${nomeClasseErro(task, tipoErro)}& erro) {
|
|
647
|
+
assert_sema(erro.codigo == ${literalStringCpp(tipoErro)}, "Código de erro inesperado");
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
throw std::runtime_error(${literalStringCpp(`Caso ${caso.nome} deveria falhar com ${tipoErro}`)});
|
|
651
651
|
}`,
|
|
652
652
|
};
|
|
653
653
|
}
|
|
@@ -657,27 +657,27 @@ ${atribuicoes ? `${atribuicoes}\n` : ""} ExecutionContext contexto{};
|
|
|
657
657
|
return {
|
|
658
658
|
nome,
|
|
659
659
|
rotulo: caso.nome,
|
|
660
|
-
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
661
|
-
void ${nome}() {
|
|
662
|
-
${entrada} entrada{};
|
|
663
|
-
${atribuicoes ? `${atribuicoes}\n` : ""} try {
|
|
664
|
-
(void)executar_${identificadorCpp(task.nome)}(entrada);
|
|
665
|
-
} catch (const std::exception&) {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
throw std::runtime_error(${literalStringCpp(`Caso ${caso.nome} esperava sucesso falso`)});
|
|
660
|
+
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
661
|
+
void ${nome}() {
|
|
662
|
+
${entrada} entrada{};
|
|
663
|
+
${atribuicoes ? `${atribuicoes}\n` : ""} try {
|
|
664
|
+
(void)executar_${identificadorCpp(task.nome)}(entrada);
|
|
665
|
+
} catch (const std::exception&) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
throw std::runtime_error(${literalStringCpp(`Caso ${caso.nome} esperava sucesso falso`)});
|
|
669
669
|
}`,
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
672
|
return {
|
|
673
673
|
nome,
|
|
674
674
|
rotulo: caso.nome,
|
|
675
|
-
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
676
|
-
void ${nome}() {
|
|
677
|
-
${entrada} entrada{};
|
|
678
|
-
${atribuicoes ? `${atribuicoes}\n` : ""} const auto resultado = executar_${identificadorCpp(task.nome)}(entrada);
|
|
679
|
-
(void)resultado;
|
|
680
|
-
${assercoes || ` assert_sema(true, ${literalStringCpp(`Caso ${caso.nome} executado`)});`}
|
|
675
|
+
conteudo: `// SEMA-TEST: ${comentarioCpp(task.nome)} :: ${comentarioCpp(caso.nome)}
|
|
676
|
+
void ${nome}() {
|
|
677
|
+
${entrada} entrada{};
|
|
678
|
+
${atribuicoes ? `${atribuicoes}\n` : ""} const auto resultado = executar_${identificadorCpp(task.nome)}(entrada);
|
|
679
|
+
(void)resultado;
|
|
680
|
+
${assercoes || ` assert_sema(true, ${literalStringCpp(`Caso ${caso.nome} executado`)});`}
|
|
681
681
|
}`,
|
|
682
682
|
};
|
|
683
683
|
}
|
|
@@ -702,8 +702,8 @@ function gerarCabecalhoSemaCpp(modulo, tipo) {
|
|
|
702
702
|
function gerarHeader(modulo) {
|
|
703
703
|
const namespace = nomeNamespace(modulo);
|
|
704
704
|
const enums = modulo.enums.map((item) => gerarEnum(item.nome, item.valores));
|
|
705
|
-
const externos = coletarTiposExternos(modulo).map((item) => `struct ${paraPascalCase(item)} final {
|
|
706
|
-
bool operator==(const ${paraPascalCase(item)}&) const = default;
|
|
705
|
+
const externos = coletarTiposExternos(modulo).map((item) => `struct ${paraPascalCase(item)} final {
|
|
706
|
+
bool operator==(const ${paraPascalCase(item)}&) const = default;
|
|
707
707
|
};`);
|
|
708
708
|
const modelos = ordenarModelos(modulo).map((item) => `${gerarStruct(item.nome, item.campos, modulo, "modelo")}\n// Origem Sema: ${item.origem} ${comentarioCpp(item.nome)}`);
|
|
709
709
|
const tasks = modulo.tasks.map((task) => gerarDeclaracoesTask(task, modulo));
|
|
@@ -712,56 +712,56 @@ function gerarHeader(modulo) {
|
|
|
712
712
|
const flows = modulo.flows.map((item) => `// Flow ${comentarioCpp(item.nome)}: etapas=${item.etapasEstruturadas.length} tasks=${comentarioCpp(item.tasksReferenciadas.join(", ") || "nenhuma")}`);
|
|
713
713
|
const routes = modulo.routes.map((item) => `// Route ${comentarioCpp(item.nome)}: método=${item.metodo ?? "não definido"} caminho=${comentarioCpp(item.caminho ?? "não definido")} task=${comentarioCpp(item.task ?? "não definida")}`);
|
|
714
714
|
const secoes = [...interops, ...enums, ...externos, ...modelos, ...tasks, ...estados, ...flows, ...routes].filter(Boolean).join("\n\n");
|
|
715
|
-
return `${gerarCabecalhoSemaCpp(modulo, "cabecalho")}#pragma once
|
|
716
|
-
|
|
717
|
-
#include <cmath>
|
|
718
|
-
#include <cstdint>
|
|
719
|
-
#include <map>
|
|
720
|
-
#include <optional>
|
|
721
|
-
#include <stdexcept>
|
|
722
|
-
#include <string>
|
|
723
|
-
#include <string_view>
|
|
724
|
-
#include <variant>
|
|
725
|
-
#include <vector>
|
|
726
|
-
|
|
727
|
-
namespace ${namespace} {
|
|
728
|
-
|
|
729
|
-
using JsonValue = std::string;
|
|
730
|
-
|
|
731
|
-
struct CampoContrato final {
|
|
732
|
-
std::string_view nome;
|
|
733
|
-
std::string_view tipo;
|
|
734
|
-
bool obrigatorio;
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
struct TaskContract final {
|
|
738
|
-
std::string_view nome;
|
|
739
|
-
std::vector<CampoContrato> input;
|
|
740
|
-
std::vector<CampoContrato> output;
|
|
741
|
-
std::vector<std::string_view> regras;
|
|
742
|
-
std::vector<std::string_view> garantias;
|
|
743
|
-
std::vector<std::string_view> efeitos;
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
struct ExecutionContext final {
|
|
747
|
-
std::string erro_esperado{};
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
${secoes}
|
|
751
|
-
|
|
752
|
-
} // namespace ${namespace}
|
|
715
|
+
return `${gerarCabecalhoSemaCpp(modulo, "cabecalho")}#pragma once
|
|
716
|
+
|
|
717
|
+
#include <cmath>
|
|
718
|
+
#include <cstdint>
|
|
719
|
+
#include <map>
|
|
720
|
+
#include <optional>
|
|
721
|
+
#include <stdexcept>
|
|
722
|
+
#include <string>
|
|
723
|
+
#include <string_view>
|
|
724
|
+
#include <variant>
|
|
725
|
+
#include <vector>
|
|
726
|
+
|
|
727
|
+
namespace ${namespace} {
|
|
728
|
+
|
|
729
|
+
using JsonValue = std::string;
|
|
730
|
+
|
|
731
|
+
struct CampoContrato final {
|
|
732
|
+
std::string_view nome;
|
|
733
|
+
std::string_view tipo;
|
|
734
|
+
bool obrigatorio;
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
struct TaskContract final {
|
|
738
|
+
std::string_view nome;
|
|
739
|
+
std::vector<CampoContrato> input;
|
|
740
|
+
std::vector<CampoContrato> output;
|
|
741
|
+
std::vector<std::string_view> regras;
|
|
742
|
+
std::vector<std::string_view> garantias;
|
|
743
|
+
std::vector<std::string_view> efeitos;
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
struct ExecutionContext final {
|
|
747
|
+
std::string erro_esperado{};
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
${secoes}
|
|
751
|
+
|
|
752
|
+
} // namespace ${namespace}
|
|
753
753
|
`;
|
|
754
754
|
}
|
|
755
755
|
function gerarSource(modulo, arquivoHeader) {
|
|
756
756
|
const namespace = nomeNamespace(modulo);
|
|
757
757
|
const implementacoes = modulo.tasks.map((task) => gerarImplementacaoTask(task, modulo)).join("\n\n");
|
|
758
|
-
return `${gerarCabecalhoSemaCpp(modulo, "implementacao")}#include ${literalStringCpp(path.posix.basename(arquivoHeader))}
|
|
759
|
-
|
|
760
|
-
namespace ${namespace} {
|
|
761
|
-
|
|
762
|
-
${implementacoes || "// Nenhuma task declarada no módulo."}
|
|
763
|
-
|
|
764
|
-
} // namespace ${namespace}
|
|
758
|
+
return `${gerarCabecalhoSemaCpp(modulo, "implementacao")}#include ${literalStringCpp(path.posix.basename(arquivoHeader))}
|
|
759
|
+
|
|
760
|
+
namespace ${namespace} {
|
|
761
|
+
|
|
762
|
+
${implementacoes || "// Nenhuma task declarada no módulo."}
|
|
763
|
+
|
|
764
|
+
} // namespace ${namespace}
|
|
765
765
|
`;
|
|
766
766
|
}
|
|
767
767
|
function gerarTestes(modulo, arquivoHeader) {
|
|
@@ -771,75 +771,75 @@ function gerarTestes(modulo, arquivoHeader) {
|
|
|
771
771
|
const funcoes = funcoesDeclaradas.length > 0 ? funcoesDeclaradas : [{
|
|
772
772
|
nome: "test_smoke_modulo",
|
|
773
773
|
rotulo: "smoke do módulo sem casos declarados",
|
|
774
|
-
conteudo: `// SEMA-TEST: smoke :: módulo sem casos declarados
|
|
775
|
-
void test_smoke_modulo() {
|
|
776
|
-
assert_sema(true, "Runner C++ autocontido disponível");
|
|
774
|
+
conteudo: `// SEMA-TEST: smoke :: módulo sem casos declarados
|
|
775
|
+
void test_smoke_modulo() {
|
|
776
|
+
assert_sema(true, "Runner C++ autocontido disponível");
|
|
777
777
|
}`,
|
|
778
778
|
}];
|
|
779
779
|
const registros = funcoes.map((item) => ` {${literalStringCpp(item.rotulo)}, &${item.nome}}`).join(",\n");
|
|
780
|
-
return `${gerarCabecalhoSemaCpp(modulo, "teste")}#include ${literalStringCpp(path.posix.basename(arquivoHeader))}
|
|
781
|
-
|
|
782
|
-
#include <iostream>
|
|
783
|
-
#include <stdexcept>
|
|
784
|
-
#include <string_view>
|
|
785
|
-
#include <utility>
|
|
786
|
-
#include <vector>
|
|
787
|
-
|
|
788
|
-
using namespace ${namespace};
|
|
789
|
-
|
|
790
|
-
namespace {
|
|
791
|
-
|
|
792
|
-
void assert_sema(bool condicao, std::string_view mensagem) {
|
|
793
|
-
if (!condicao) throw std::runtime_error(std::string{mensagem});
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
${funcoes.map((item) => item.conteudo).join("\n\n")}
|
|
797
|
-
|
|
798
|
-
} // namespace
|
|
799
|
-
|
|
800
|
-
int main() {
|
|
801
|
-
const std::vector<std::pair<std::string_view, void (*)()>> testes{
|
|
802
|
-
${registros}
|
|
803
|
-
};
|
|
804
|
-
for (const auto& [nome, executar] : testes) {
|
|
805
|
-
std::cout << "test " << nome << '\\n';
|
|
806
|
-
executar();
|
|
807
|
-
}
|
|
808
|
-
std::cout << "ok " << testes.size() << " testes\\n";
|
|
809
|
-
return 0;
|
|
810
|
-
}
|
|
780
|
+
return `${gerarCabecalhoSemaCpp(modulo, "teste")}#include ${literalStringCpp(path.posix.basename(arquivoHeader))}
|
|
781
|
+
|
|
782
|
+
#include <iostream>
|
|
783
|
+
#include <stdexcept>
|
|
784
|
+
#include <string_view>
|
|
785
|
+
#include <utility>
|
|
786
|
+
#include <vector>
|
|
787
|
+
|
|
788
|
+
using namespace ${namespace};
|
|
789
|
+
|
|
790
|
+
namespace {
|
|
791
|
+
|
|
792
|
+
void assert_sema(bool condicao, std::string_view mensagem) {
|
|
793
|
+
if (!condicao) throw std::runtime_error(std::string{mensagem});
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
${funcoes.map((item) => item.conteudo).join("\n\n")}
|
|
797
|
+
|
|
798
|
+
} // namespace
|
|
799
|
+
|
|
800
|
+
int main() {
|
|
801
|
+
const std::vector<std::pair<std::string_view, void (*)()>> testes{
|
|
802
|
+
${registros}
|
|
803
|
+
};
|
|
804
|
+
for (const auto& [nome, executar] : testes) {
|
|
805
|
+
std::cout << "test " << nome << '\\n';
|
|
806
|
+
executar();
|
|
807
|
+
}
|
|
808
|
+
std::cout << "ok " << testes.size() << " testes\\n";
|
|
809
|
+
return 0;
|
|
810
|
+
}
|
|
811
811
|
`;
|
|
812
812
|
}
|
|
813
813
|
function gerarCmake(modulo, arquivoSource, arquivoTeste) {
|
|
814
814
|
const nomeProjeto = `sema_${identificadorCpp(normalizarNomeModulo(modulo.nome).replace(/\./g, "_").toLowerCase())}`;
|
|
815
815
|
const alvoBiblioteca = `${nomeProjeto}_lib`;
|
|
816
816
|
const alvoTeste = `test_${nomeProjeto}`;
|
|
817
|
-
return `${gerarCabecalhoSemaCpp(modulo, "cmake")}cmake_minimum_required(VERSION 3.16)
|
|
818
|
-
project(${nomeProjeto} LANGUAGES CXX)
|
|
819
|
-
|
|
820
|
-
set(CMAKE_CXX_STANDARD 20)
|
|
821
|
-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
822
|
-
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
823
|
-
|
|
824
|
-
add_library(${alvoBiblioteca} STATIC ${path.posix.basename(arquivoSource)})
|
|
825
|
-
target_include_directories(${alvoBiblioteca} PUBLIC "\${CMAKE_CURRENT_SOURCE_DIR}")
|
|
826
|
-
target_compile_features(${alvoBiblioteca} PUBLIC cxx_std_20)
|
|
827
|
-
|
|
828
|
-
add_executable(${alvoTeste} ${path.posix.basename(arquivoTeste)})
|
|
829
|
-
target_link_libraries(${alvoTeste} PRIVATE ${alvoBiblioteca})
|
|
830
|
-
|
|
831
|
-
if(MSVC)
|
|
832
|
-
target_compile_options(${alvoBiblioteca} PRIVATE /W4 /permissive-)
|
|
833
|
-
target_compile_options(${alvoTeste} PRIVATE /W4 /permissive-)
|
|
834
|
-
else()
|
|
835
|
-
target_compile_options(${alvoBiblioteca} PRIVATE -Wall -Wextra -Wpedantic)
|
|
836
|
-
target_compile_options(${alvoTeste} PRIVATE -Wall -Wextra -Wpedantic)
|
|
837
|
-
endif()
|
|
838
|
-
|
|
839
|
-
include(CTest)
|
|
840
|
-
if(BUILD_TESTING)
|
|
841
|
-
add_test(NAME ${alvoTeste} COMMAND ${alvoTeste})
|
|
842
|
-
endif()
|
|
817
|
+
return `${gerarCabecalhoSemaCpp(modulo, "cmake")}cmake_minimum_required(VERSION 3.16)
|
|
818
|
+
project(${nomeProjeto} LANGUAGES CXX)
|
|
819
|
+
|
|
820
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
821
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
822
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
823
|
+
|
|
824
|
+
add_library(${alvoBiblioteca} STATIC ${path.posix.basename(arquivoSource)})
|
|
825
|
+
target_include_directories(${alvoBiblioteca} PUBLIC "\${CMAKE_CURRENT_SOURCE_DIR}")
|
|
826
|
+
target_compile_features(${alvoBiblioteca} PUBLIC cxx_std_20)
|
|
827
|
+
|
|
828
|
+
add_executable(${alvoTeste} ${path.posix.basename(arquivoTeste)})
|
|
829
|
+
target_link_libraries(${alvoTeste} PRIVATE ${alvoBiblioteca})
|
|
830
|
+
|
|
831
|
+
if(MSVC)
|
|
832
|
+
target_compile_options(${alvoBiblioteca} PRIVATE /W4 /permissive-)
|
|
833
|
+
target_compile_options(${alvoTeste} PRIVATE /W4 /permissive-)
|
|
834
|
+
else()
|
|
835
|
+
target_compile_options(${alvoBiblioteca} PRIVATE -Wall -Wextra -Wpedantic)
|
|
836
|
+
target_compile_options(${alvoTeste} PRIVATE -Wall -Wextra -Wpedantic)
|
|
837
|
+
endif()
|
|
838
|
+
|
|
839
|
+
include(CTest)
|
|
840
|
+
if(BUILD_TESTING)
|
|
841
|
+
add_test(NAME ${alvoTeste} COMMAND ${alvoTeste})
|
|
842
|
+
endif()
|
|
843
843
|
`;
|
|
844
844
|
}
|
|
845
845
|
export function gerarCpp(modulo) {
|
|
@@ -32,19 +32,19 @@ export function gerarEstilosState(state) {
|
|
|
32
32
|
return estilos.join("\n");
|
|
33
33
|
}
|
|
34
34
|
export function gerarEstilosEnum(enumeracao) {
|
|
35
|
-
return enumeracao.valores.map((valor) => `.sema-select option[value="${valor}"] {
|
|
36
|
-
color: var(--sema-cor-texto);
|
|
37
|
-
}
|
|
35
|
+
return enumeracao.valores.map((valor) => `.sema-select option[value="${valor}"] {
|
|
36
|
+
color: var(--sema-cor-texto);
|
|
37
|
+
}
|
|
38
38
|
`).join("");
|
|
39
39
|
}
|
|
40
40
|
export function gerarCabecalhoSemaCss(modulo) {
|
|
41
|
-
return `/* SEMA-GOVERNED
|
|
42
|
-
* Módulo de origem: ${modulo.nome}
|
|
43
|
-
* Consulte o contrato .sema aplicável antes de editar este arquivo.
|
|
44
|
-
* Rastreabilidade: outros contratos .sema podem governar este mesmo arquivo via vinculos.
|
|
45
|
-
* Para IA fraca/média/forte: chame Sema, rode docs-impacto e drift antes de alterar código.
|
|
46
|
-
* Descrição: CSS gerado para materializar o design system do contrato Sema.
|
|
47
|
-
*/
|
|
41
|
+
return `/* SEMA-GOVERNED
|
|
42
|
+
* Módulo de origem: ${modulo.nome}
|
|
43
|
+
* Consulte o contrato .sema aplicável antes de editar este arquivo.
|
|
44
|
+
* Rastreabilidade: outros contratos .sema podem governar este mesmo arquivo via vinculos.
|
|
45
|
+
* Para IA fraca/média/forte: chame Sema, rode docs-impacto e drift antes de alterar código.
|
|
46
|
+
* Descrição: CSS gerado para materializar o design system do contrato Sema.
|
|
47
|
+
*/
|
|
48
48
|
`;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=index.part01.js.map
|