@semacode/cli 2.3.1 → 3.5.0
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 +265 -217
- package/dist/agentContextPack.js +14 -10
- package/dist/agentEntryPoints.d.ts +5 -0
- package/dist/agentEntryPoints.js +592 -568
- package/dist/angular-consumer-standalone.js +1 -1
- package/dist/bin.d.ts +6 -0
- package/dist/bin.js +130 -0
- package/dist/cliArgs.js +4 -4
- package/dist/cliControlError.d.ts +12 -0
- package/dist/cliControlError.js +47 -0
- package/dist/cliGrammar.d.ts +11 -0
- package/dist/cliGrammar.js +551 -0
- package/dist/cliHelp.d.ts +13 -0
- package/dist/cliHelp.js +19 -0
- package/dist/cliHelpTexto.d.ts +3 -0
- package/dist/cliHelpTexto.js +168 -0
- package/dist/cliRuntime.d.ts +2 -0
- package/dist/cliRuntime.js +31 -0
- package/dist/comandos.js +9 -22
- package/dist/contexto.js +5 -5
- package/dist/dev/index.d.ts +1 -0
- package/dist/dev/index.js +51 -9
- package/dist/discovery/catalog.js +3 -3
- package/dist/distribuicao/filesystemGlobal.d.ts +63 -0
- package/dist/distribuicao/filesystemGlobal.js +701 -0
- package/dist/distribuicao/index.d.ts +7 -0
- package/dist/distribuicao/index.js +227 -0
- package/dist/distribuicao/launcherGlobal.d.ts +53 -0
- package/dist/distribuicao/launcherGlobal.js +643 -0
- package/dist/distribuicao/launcherWindows.d.ts +28 -0
- package/dist/distribuicao/launcherWindows.js +326 -0
- package/dist/distribuicao/lockContextGlobal.d.ts +10 -0
- package/dist/distribuicao/lockContextGlobal.js +17 -0
- package/dist/distribuicao/lockGlobal.d.ts +6 -0
- package/dist/distribuicao/lockGlobal.js +520 -0
- package/dist/distribuicao/skillGlobal.d.ts +48 -0
- package/dist/distribuicao/skillGlobal.js +652 -0
- package/dist/distribuicao/skillIntentPolicy.d.ts +21 -0
- package/dist/distribuicao/skillIntentPolicy.js +115 -0
- package/dist/distribuicao/tipos.d.ts +50 -0
- package/dist/distribuicao/tipos.js +10 -0
- package/dist/distribuicao/versaoSemantica.d.ts +3 -0
- package/dist/distribuicao/versaoSemantica.js +62 -0
- package/dist/docs.part01.d.ts +4 -1
- package/dist/docs.part01.js +8 -0
- package/dist/docs.part02.js +9 -1
- package/dist/drift.part01.d.ts +33 -25
- package/dist/drift.part01.js +2 -1
- package/dist/drift.part04.d.ts +26 -5
- package/dist/drift.part04.js +123 -19
- package/dist/drift.part05.d.ts +2 -2
- package/dist/drift.part05.js +8 -6
- package/dist/drift.part06.d.ts +2 -2
- package/dist/drift.part06.js +113 -26
- package/dist/drift.part07.d.ts +11 -11
- package/dist/drift.part07.js +261 -265
- package/dist/drift.part08.d.ts +2 -2
- package/dist/drift.part08.js +35 -26
- package/dist/drift.part09.d.ts +2 -2
- package/dist/drift.part09.js +10 -3
- package/dist/drift.part11.js +261 -58
- package/dist/drift.part12.d.ts +1 -1
- package/dist/drift.part12.js +193 -21
- package/dist/drift.part13.d.ts +20 -39
- package/dist/drift.part13.js +601 -647
- package/dist/drift.part14.js +23 -7
- package/dist/driftCacheCas.d.ts +43 -0
- package/dist/driftCacheCas.js +351 -0
- package/dist/driftCacheFilesystem.d.ts +64 -0
- package/dist/driftCacheFilesystem.js +313 -0
- package/dist/driftCacheModes.d.ts +38 -0
- package/dist/driftCacheModes.js +147 -0
- package/dist/driftCacheStore.d.ts +80 -0
- package/dist/driftCacheStore.js +603 -0
- package/dist/driftCatalogo.d.ts +2 -28
- package/dist/driftCatalogo.js +143 -284
- package/dist/driftEscopo.d.ts +1 -3
- package/dist/driftEscopo.js +235 -151
- package/dist/driftEscopoReferencias.d.ts +5 -1
- package/dist/driftEscopoReferencias.js +375 -28
- package/dist/driftOrcamento.d.ts +0 -6
- package/dist/driftOrcamento.js +2 -1
- package/dist/execucoesExternas.js +19 -5
- package/dist/exemplosOficiais.d.ts +2 -1
- package/dist/exemplosOficiais.js +9 -3
- package/dist/geracaoCore.d.ts +1 -0
- package/dist/geracaoCore.js +6 -6
- package/dist/iaPrompts.d.ts +3 -3
- package/dist/iaPrompts.js +312 -313
- package/dist/importador.part01.d.ts +1 -1
- package/dist/importador.part06.d.ts +2 -0
- package/dist/importador.part06.js +87 -1
- package/dist/importador.part09.js +7 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +6 -25
- package/dist/index.part01.d.ts +20 -28
- package/dist/index.part01.js +16 -237
- package/dist/index.part02.js +36 -22
- package/dist/index.part03.d.ts +24 -2
- package/dist/index.part03.js +83 -19
- package/dist/index.part04.d.ts +10 -2
- package/dist/index.part04.js +152 -123
- package/dist/index.part05.js +80 -78
- package/dist/index.part06.js +34 -17
- package/dist/index.part07.d.ts +8 -2
- package/dist/index.part07.js +153 -7
- package/dist/index.part08.d.ts +1 -1
- package/dist/index.part08.js +25 -30
- package/dist/initCommand.d.ts +1 -0
- package/dist/initCommand.js +20 -4
- package/dist/initTemplatesBase.js +6 -4
- package/dist/pipelineConteudo/command.d.ts +1 -0
- package/dist/pipelineConteudo/command.js +9 -2
- package/dist/pipelineConteudo/help.d.ts +2 -0
- package/dist/pipelineConteudo/help.js +33 -0
- package/dist/profileAuthorCommand.js +3 -7
- package/dist/profileCommand.js +3 -7
- package/dist/projetoCarregar.js +35 -17
- package/dist/projetoCatalogo.d.ts +1 -0
- package/dist/projetoCatalogo.js +64 -25
- package/dist/projetoConfig.js +2 -0
- package/dist/projetoLegado.js +18 -0
- package/dist/projetoOrigens.d.ts +2 -0
- package/dist/projetoOrigens.js +65 -9
- package/dist/projetoTipos.d.ts +1 -0
- package/dist/resultadoCli.d.ts +20 -0
- package/dist/resultadoCli.js +57 -0
- package/dist/saidaCli.d.ts +35 -0
- package/dist/saidaCli.js +118 -0
- package/dist/sistemasInterativos/acceptanceEvidence.d.ts +22 -0
- package/dist/sistemasInterativos/acceptanceEvidence.js +345 -0
- package/dist/sistemasInterativos/engineObservation.d.ts +12 -0
- package/dist/sistemasInterativos/engineObservation.js +438 -0
- package/dist/sistemasInterativos/jobOrchestration.d.ts +2 -0
- package/dist/sistemasInterativos/jobOrchestration.js +204 -0
- package/dist/sistemasInterativos/operationPrimitives.d.ts +21 -0
- package/dist/sistemasInterativos/operationPrimitives.js +194 -0
- package/dist/sistemasInterativos/operations.d.ts +4 -39
- package/dist/sistemasInterativos/operations.js +5 -1164
- package/dist/skillCommand.d.ts +5 -0
- package/dist/skillCommand.js +88 -0
- package/dist/tipos.d.ts +1 -1
- package/dist/typescript-http-modelos.d.ts +1 -1
- package/dist/typescript-http-rotas.d.ts +1 -0
- package/dist/typescript-http-rotas.js +93 -0
- package/dist/typescript-http.d.ts +1 -1
- package/dist/typescript-http.js +1 -1
- package/dist/verificacaoCache.d.ts +25 -0
- package/dist/verificacaoCache.js +80 -0
- package/docs/README.md +34 -30
- package/docs/ai-integration.md +25 -12
- package/docs/ai-onboarding.md +37 -18
- package/docs/ai-workflow.md +9 -7
- package/docs/cli.md +125 -7
- package/docs/commands.md +41 -20
- package/docs/deploy.md +21 -8
- package/docs/descoberta-capacidades.md +106 -106
- package/docs/documentation.md +49 -39
- package/docs/drift-cache.md +108 -0
- package/docs/getting-started.md +43 -18
- package/docs/pipeline-conteudo.md +246 -246
- package/docs/profiles.md +54 -54
- package/docs/repositories.md +19 -2
- package/docs/rollback.md +15 -8
- package/docs/security.md +25 -3
- package/docs/sistemas-interativos.md +379 -374
- package/docs/syntax.md +14 -0
- package/docs/testing.md +139 -40
- package/exemplos/express_crud.sema +139 -0
- package/exemplos/fastify_crud.sema +146 -0
- 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_simulation.sema +211 -211
- package/exemplos/sistemas-interativos/README.md +100 -100
- package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -5
- package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -16
- package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -32
- package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -93
- package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -78
- package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -27
- package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -79
- package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -42
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -32
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -23
- package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -39
- package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -46
- package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -39
- package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -37
- package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -104
- package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -27
- package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -118
- package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -459
- package/exemplos/sistemas-interativos/game-2d.json +83 -83
- package/exemplos/sistemas-interativos/game-3d-human.json +81 -81
- package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -97
- package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -94
- package/exemplos/sistemas-interativos/game-xr-human.json +80 -80
- package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -108
- package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -75
- package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -58
- package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -97
- package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -141
- package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -112
- package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -103
- package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -95
- package/node_modules/@sema/gerador-cpp/package.json +1 -1
- package/node_modules/@sema/gerador-dotnet/package.json +1 -1
- package/node_modules/@sema/gerador-lua/dist/index.js +51 -51
- package/node_modules/@sema/gerador-php/dist/index.js +113 -113
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js +37 -38
- package/node_modules/@sema/nucleo/dist/ir/modelos.d.ts +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.d.ts +7 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js +33 -10
- package/package.json +9 -4
- package/scripts/postinstall.mjs +148 -0
- package/skills/sema/SKILL.md +199 -0
- package/skills/sema/agents/openai.yaml +4 -0
- package/dist/driftCache.d.ts +0 -49
- package/dist/driftCache.js +0 -311
- package/dist/driftCacheIncremental.d.ts +0 -98
- package/dist/driftCacheIncremental.js +0 -596
- package/dist/driftCatalogoPersistente.d.ts +0 -8
- package/dist/driftCatalogoPersistente.js +0 -77
- package/node_modules/@sema/gerador-cpp/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-dart/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-dotnet/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-html/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-javascript/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-lua/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-php/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ast/tipos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/modelos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/lexer/lexer.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/lexer/tokens.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/seguranca.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/util/arquivos.js.map +0 -1
- package/node_modules/@sema/padroes/dist/index.js.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.produto.pipeline_conteudo.cli
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.pipeline_conteudo.cli, sema.produto.cli_invocacao_publica
|
|
2
2
|
// Descrição: CLI declarativa do pipeline de conteúdo; não executa agentes, ferramentas ou publicação.
|
|
3
3
|
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { existsSync, realpathSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import { criarAjudaPipelineConteudo } from "./help.js";
|
|
7
|
+
export { criarAjudaPipelineConteudo } from "./help.js";
|
|
6
8
|
import { digestEnvelopeConteudo, hashCanonicoConteudo, } from "./canonical.js";
|
|
7
9
|
import { CAPABILITIES_CONTEUDO_PADRAO, } from "./adapters.js";
|
|
8
10
|
import { anexarEventoLedgerConteudo, HEAD_GENESIS_LEDGER_CONTEUDO, validarLedgerConteudo, validarPayloadEventoConteudo, } from "./ledger.js";
|
|
@@ -26,6 +28,7 @@ const OPCOES_COM_VALOR_CONTEUDO = new Set([
|
|
|
26
28
|
"--revocation-digest",
|
|
27
29
|
]);
|
|
28
30
|
const SUBCOMANDOS_CONTEUDO = new Set([
|
|
31
|
+
"ajuda",
|
|
29
32
|
"capabilities",
|
|
30
33
|
"validar",
|
|
31
34
|
"planejar",
|
|
@@ -363,11 +366,15 @@ async function registrarEnvelopeLocal(args, ledgerArquivo) {
|
|
|
363
366
|
}
|
|
364
367
|
export async function comandoPipelineConteudo(_posicionaisGlobais, args, emJson) {
|
|
365
368
|
const posicionais = posicionaisConteudo(args);
|
|
366
|
-
const
|
|
369
|
+
const solicitouAjuda = args.includes("--help") || args.includes("-h") || posicionais[0] === "help" || posicionais[0] === "ajuda";
|
|
370
|
+
const subcomando = solicitouAjuda ? "ajuda" : posicionais[0] ?? "capabilities";
|
|
367
371
|
const comandoPublico = SUBCOMANDOS_CONTEUDO.has(subcomando) ? subcomando : "desconhecido";
|
|
368
372
|
try {
|
|
369
373
|
let payload;
|
|
370
374
|
switch (subcomando) {
|
|
375
|
+
case "ajuda":
|
|
376
|
+
payload = criarAjudaPipelineConteudo();
|
|
377
|
+
break;
|
|
371
378
|
case "capabilities":
|
|
372
379
|
payload = {
|
|
373
380
|
sucesso: true,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const USOS_PIPELINE_CONTEUDO: readonly ["sema conteudo capabilities --json", "sema conteudo validar <definition.json> --json", "sema conteudo planejar <definition.json> --alvos-arquivo <targets.json> --json", "sema conteudo validar-envelope --envelope-arquivo <envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --payload-type <type> --json", "sema conteudo registrar <ledger.ndjson> --envelope-arquivo <envelope.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-id <id> --expected-head <sha256:...> --json", "sema conteudo status <definition.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-arquivo <ledger.ndjson> --expected-head <sha256:...> --json", "sema conteudo projetar <definition.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-arquivo <ledger.ndjson> --expected-head <sha256:...> --saida <manifest.json> --json"];
|
|
2
|
+
export declare function criarAjudaPipelineConteudo(): Record<string, unknown>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.pipeline_conteudo.cli, sema.produto.cli_invocacao_publica
|
|
2
|
+
// Descrição: renderiza a ajuda pública do pipeline de conteúdo sem carregar o runtime operacional.
|
|
3
|
+
export const USOS_PIPELINE_CONTEUDO = [
|
|
4
|
+
"sema conteudo capabilities --json",
|
|
5
|
+
"sema conteudo validar <definition.json> --json",
|
|
6
|
+
"sema conteudo planejar <definition.json> --alvos-arquivo <targets.json> --json",
|
|
7
|
+
"sema conteudo validar-envelope --envelope-arquivo <envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --payload-type <type> --json",
|
|
8
|
+
"sema conteudo registrar <ledger.ndjson> --envelope-arquivo <envelope.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-id <id> --expected-head <sha256:...> --json",
|
|
9
|
+
"sema conteudo status <definition.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-arquivo <ledger.ndjson> --expected-head <sha256:...> --json",
|
|
10
|
+
"sema conteudo projetar <definition.json> --politica-arquivo <policy-envelope.json> --confianca-arquivo <trust.json> --trust-root-digest <sha256:...> --revocation-digest <sha256:...> --ledger-arquivo <ledger.ndjson> --expected-head <sha256:...> --saida <manifest.json> --json",
|
|
11
|
+
];
|
|
12
|
+
export function criarAjudaPipelineConteudo() {
|
|
13
|
+
const mensagem = [
|
|
14
|
+
"Sema Content Pipeline — controle AI-native multicanal e multiformato.",
|
|
15
|
+
"",
|
|
16
|
+
"Uso:",
|
|
17
|
+
...USOS_PIPELINE_CONTEUDO.map((uso) => ` ${uso}`),
|
|
18
|
+
"",
|
|
19
|
+
"O runner é externo e avança somente pelos nextActions derivados pelo Sema.",
|
|
20
|
+
"Evidências entram como envelopes assinados; vereditos e transições não são escritos manualmente.",
|
|
21
|
+
"Não existe revisão humana nativa. Chaves privadas permanecem nos processos signatários independentes.",
|
|
22
|
+
].join("\n");
|
|
23
|
+
return {
|
|
24
|
+
sucesso: true,
|
|
25
|
+
comando: "ajuda",
|
|
26
|
+
mensagem,
|
|
27
|
+
usos: USOS_PIPELINE_CONTEUDO,
|
|
28
|
+
nativeHumanReview: false,
|
|
29
|
+
runner: "external",
|
|
30
|
+
canonicalState: "signed_hash_chained_ledger",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.governanca_ia_contexto
|
|
2
|
-
//
|
|
3
|
-
// SEMA-GOVERNED
|
|
4
|
-
// M?dulo: sema.produto.orcamento_semantico
|
|
5
|
-
// Contrato: contratos/sema/orcamento_semantico.sema
|
|
6
|
-
// Descricao: comandos de profiles semanticos e Author, com gates de score e decis?o de agente.
|
|
1
|
+
// SEMA-GOVERNED: sema.governanca_ia_contexto, sema.produto.governanca_ia.drift.cache.modos
|
|
2
|
+
// Descrição: comando Author com próximos passos explícitos de drift fresh.
|
|
7
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
4
|
import path from "node:path";
|
|
9
5
|
import { formatarDiagnosticos, temErros } from "@sema/nucleo";
|
|
@@ -123,7 +119,7 @@ export async function criarAuthorBriefing(entrada, preset = null) {
|
|
|
123
119
|
"sema author validar-narrativa <arquivo> --texto <texto> --json",
|
|
124
120
|
"sema author validar-proibicoes <arquivo> --texto <texto> --json",
|
|
125
121
|
"sema validar <arquivo> --json",
|
|
126
|
-
"sema drift <arquivo> --json",
|
|
122
|
+
"sema drift <arquivo> --cache fresh --json",
|
|
127
123
|
],
|
|
128
124
|
diagnosticos: escolhido.resultado.diagnosticos,
|
|
129
125
|
};
|
package/dist/profileCommand.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.
|
|
2
|
-
//
|
|
3
|
-
// SEMA-GOVERNED
|
|
4
|
-
// M?dulo: sema.produto.orcamento_semantico
|
|
5
|
-
// Contrato: contratos/sema/orcamento_semantico.sema
|
|
6
|
-
// Descricao: comando profile da CLI e renderiza??o de valida??o sem?ntica por profile.
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.orquestracao_profiles, sema.produto.governanca_ia.drift.cache.modos
|
|
2
|
+
// Descrição: comando de profiles com fechamento explícito por drift fresh.
|
|
7
3
|
import { readFile } from "node:fs/promises";
|
|
8
4
|
import path from "node:path";
|
|
9
5
|
import { temErros } from "@sema/nucleo";
|
|
@@ -98,7 +94,7 @@ export async function validarProfileSemantico(entrada, profile, opcoes) {
|
|
|
98
94
|
checks: [
|
|
99
95
|
`sema profile validar ${profile} <arquivo> --preset ${preset ?? "<opcional>"} --artefato-arquivo <artefato> --json`,
|
|
100
96
|
"sema validar <arquivo> --json",
|
|
101
|
-
"sema drift <arquivo> --escopo modulo --json",
|
|
97
|
+
"sema drift <arquivo> --escopo modulo --cache fresh --json",
|
|
102
98
|
"sema contexto-ia <arquivo>",
|
|
103
99
|
],
|
|
104
100
|
diagnosticos: escolhido.resultado.diagnosticos,
|
package/dist/projetoCarregar.js
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.produto.governanca_ia.contexto
|
|
2
|
-
// Descrição: orquestra leitura de contratos,
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.governanca_ia.contexto, sema.produto.governanca_ia.drift.cache.modos
|
|
2
|
+
// Descrição: orquestra leitura de contratos, compilação e seleção de módulos do projeto.
|
|
3
3
|
import { stat } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { compilarProjeto, listarArquivosSema } from '@sema/nucleo';
|
|
6
|
-
import { carregarFechamentoContratosSema, carregarFontesContratos } from './projetoCatalogo.js';
|
|
7
|
-
import { carregarConfiguracaoProjeto, normalizarModoAdocao } from './projetoConfig.js';
|
|
6
|
+
import { canonicalizarContratosNoProjeto, carregarFechamentoContratosSema, carregarFontesContratos, } from './projetoCatalogo.js';
|
|
7
|
+
import { carregarConfiguracaoProjeto, normalizarFonteLegado, normalizarModoAdocao } from './projetoConfig.js';
|
|
8
8
|
import { inferirFontesLegado } from './projetoLegado.js';
|
|
9
|
-
import { inferirDiretoriosCodigo, listarArquivosDeOrigens, resolverBaseProjeto, resolverEntradaPadrao, resolverOrigensProjeto, } from './projetoOrigens.js';
|
|
9
|
+
import { inferirDiretoriosCodigo, listarArquivosDeOrigens, resolverBaseProjeto, resolverDiretoriosCodigoConfigurados, resolverEntradaPadrao, resolverOrigensProjeto, resolverRaizesLogicasCodigoSemCaminhada, } from './projetoOrigens.js';
|
|
10
|
+
async function resolverDiretoriosCodigoSemCaminhada(baseProjeto, configCarregada) {
|
|
11
|
+
const declarados = await resolverDiretoriosCodigoConfigurados(baseProjeto, configCarregada);
|
|
12
|
+
return declarados.length > 0
|
|
13
|
+
? declarados
|
|
14
|
+
: resolverRaizesLogicasCodigoSemCaminhada(baseProjeto);
|
|
15
|
+
}
|
|
16
|
+
function resolverFontesLegadoDeclaradas(configCarregada) {
|
|
17
|
+
return [...new Set((configCarregada?.config.fontesLegado ?? [])
|
|
18
|
+
.map((fonte) => normalizarFonteLegado(fonte))
|
|
19
|
+
.filter((fonte) => Boolean(fonte)))]
|
|
20
|
+
.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
21
|
+
}
|
|
10
22
|
export async function carregarProjeto(entrada, cwd, opcoes = {}) {
|
|
11
23
|
const entradaBase = entrada ? path.resolve(cwd, entrada) : cwd;
|
|
12
24
|
const configCarregada = await carregarConfiguracaoProjeto(entradaBase);
|
|
13
25
|
const entradaResolvida = entrada ? path.resolve(cwd, entrada) : await resolverEntradaPadrao(cwd, configCarregada);
|
|
14
26
|
const baseProjeto = await resolverBaseProjeto(entradaResolvida, configCarregada);
|
|
15
27
|
const infoEntrada = await stat(entradaResolvida);
|
|
28
|
+
if (infoEntrada.isFile() && path.extname(entradaResolvida).toLowerCase() !== ".sema") {
|
|
29
|
+
throw new Error(`Entrada de contrato precisa terminar em .sema: ${entradaResolvida}`);
|
|
30
|
+
}
|
|
16
31
|
const escopo = opcoes.escopo ?? (infoEntrada.isFile() ? "modulo" : "projeto");
|
|
17
32
|
const carregarProjetoCompleto = !infoEntrada.isFile() || escopo === "projeto";
|
|
18
33
|
const origensBase = infoEntrada.isFile()
|
|
@@ -27,27 +42,30 @@ export async function carregarProjeto(entrada, cwd, opcoes = {}) {
|
|
|
27
42
|
if (infoEntrada.isFile()) {
|
|
28
43
|
arquivosDescobertosSet.add(path.resolve(entradaResolvida));
|
|
29
44
|
}
|
|
30
|
-
const arquivosDescobertos = [...arquivosDescobertosSet]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
? await
|
|
39
|
-
:
|
|
45
|
+
const arquivosDescobertos = await canonicalizarContratosNoProjeto(baseProjeto, [...arquivosDescobertosSet]);
|
|
46
|
+
const entradaContrato = infoEntrada.isFile()
|
|
47
|
+
? (await canonicalizarContratosNoProjeto(baseProjeto, [entradaResolvida]))[0]
|
|
48
|
+
: undefined;
|
|
49
|
+
// Escopos estreitos recebem apenas raizes logicas declaradas (ou a raiz local)
|
|
50
|
+
// para que o planner decida o que pode ser tocado antes de qualquer caminhada.
|
|
51
|
+
const adiarDescobertaCodigo = opcoes.adiarDescobertaCodigo === true;
|
|
52
|
+
const diretoriosCodigo = adiarDescobertaCodigo
|
|
53
|
+
? await resolverDiretoriosCodigoSemCaminhada(baseProjeto, configCarregada)
|
|
54
|
+
: await inferirDiretoriosCodigo(baseProjeto, configCarregada);
|
|
55
|
+
const fontesLegado = adiarDescobertaCodigo
|
|
56
|
+
? resolverFontesLegadoDeclaradas(configCarregada)
|
|
57
|
+
: await inferirFontesLegado(diretoriosCodigo, baseProjeto, configCarregada);
|
|
40
58
|
const modoAdocao = normalizarModoAdocao(configCarregada?.config.modoAdocao);
|
|
41
59
|
const arquivosSelecionados = carregarProjetoCompleto && escopo === "projeto"
|
|
42
60
|
? new Set(arquivosDescobertos.map((arquivo) => path.resolve(arquivo)))
|
|
43
61
|
: infoEntrada.isFile()
|
|
44
|
-
? new Set([
|
|
62
|
+
? new Set([entradaContrato])
|
|
45
63
|
: new Set((configCarregada && path.resolve(entradaResolvida) === path.resolve(configCarregada.baseDiretorio)
|
|
46
64
|
? arquivosDescobertos
|
|
47
65
|
: await listarArquivosSema(entradaResolvida)).map((arquivo) => path.resolve(arquivo)));
|
|
48
66
|
const fontes = carregarProjetoCompleto
|
|
49
67
|
? await carregarFontesContratos(arquivosDescobertos)
|
|
50
|
-
: (await carregarFechamentoContratosSema([
|
|
68
|
+
: (await carregarFechamentoContratosSema([entradaContrato], arquivosDescobertos)).fontes;
|
|
51
69
|
const resultadoProjeto = compilarProjeto(fontes);
|
|
52
70
|
const resultados = new Map(resultadoProjeto.modulos.map((modulo) => [path.resolve(modulo.caminho), modulo]));
|
|
53
71
|
const modulosCarregados = fontes.map((fonte) => ({
|
|
@@ -3,5 +3,6 @@ export interface FechamentoContratosSema {
|
|
|
3
3
|
fontes: FonteProjeto[];
|
|
4
4
|
dependenciasNaoResolvidas: string[];
|
|
5
5
|
}
|
|
6
|
+
export declare function canonicalizarContratosNoProjeto(baseProjeto: string, arquivos: string[]): Promise<string[]>;
|
|
6
7
|
export declare function carregarFontesContratos(arquivos: string[]): Promise<FonteProjeto[]>;
|
|
7
8
|
export declare function carregarFechamentoContratosSema(arquivosAlvo: string[], arquivosDescobertos: string[]): Promise<FechamentoContratosSema>;
|
package/dist/projetoCatalogo.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
// SEMA-GOVERNED: sema.produto.governanca_ia.contexto
|
|
2
2
|
// Descricao: descobre contratos por caminho e carrega apenas o fechamento transitivo de uses do alvo.
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { realpath } from "node:fs/promises";
|
|
5
|
+
import { listarCandidatosUseRelativo, lerArquivoTexto, parsear, tokenizar, } from "@sema/nucleo";
|
|
6
|
+
function caminhoEstaContido(base, alvo) {
|
|
7
|
+
const relativo = path.relative(base, alvo);
|
|
8
|
+
return relativo === "" || (relativo !== ".."
|
|
9
|
+
&& !relativo.startsWith(`..${path.sep}`)
|
|
10
|
+
&& !path.isAbsolute(relativo));
|
|
11
|
+
}
|
|
12
|
+
function chaveCaminhoReal(caminho) {
|
|
13
|
+
return process.platform === "win32" ? caminho.toLocaleLowerCase("en-US") : caminho;
|
|
14
|
+
}
|
|
15
|
+
export async function canonicalizarContratosNoProjeto(baseProjeto, arquivos) {
|
|
16
|
+
const baseReal = await realpath(path.resolve(baseProjeto));
|
|
17
|
+
const canonicos = new Map();
|
|
18
|
+
for (const arquivo of arquivos) {
|
|
19
|
+
const caminhoReal = await realpath(path.resolve(arquivo));
|
|
20
|
+
if (!caminhoEstaContido(baseReal, caminhoReal)) {
|
|
21
|
+
throw new Error(`Contrato resolve fora da base do projeto: ${arquivo}`);
|
|
22
|
+
}
|
|
23
|
+
if (path.extname(caminhoReal).toLowerCase() !== ".sema") {
|
|
24
|
+
throw new Error(`Entrada de contrato precisa terminar em .sema: ${arquivo}`);
|
|
25
|
+
}
|
|
26
|
+
canonicos.set(chaveCaminhoReal(caminhoReal), caminhoReal);
|
|
27
|
+
}
|
|
28
|
+
return [...canonicos.values()].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
29
|
+
}
|
|
5
30
|
function normalizarChaveArquivo(valor) {
|
|
6
31
|
return valor
|
|
7
32
|
.normalize("NFD")
|
|
@@ -40,7 +65,7 @@ export async function carregarFechamentoContratosSema(arquivosAlvo, arquivosDesc
|
|
|
40
65
|
.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
41
66
|
const indiceSufixos = criarIndiceSufixos(descobertos);
|
|
42
67
|
const leituras = new Map();
|
|
43
|
-
const
|
|
68
|
+
const caminhosPorModulo = new Map();
|
|
44
69
|
const lerContrato = (arquivo) => {
|
|
45
70
|
const caminho = path.resolve(arquivo);
|
|
46
71
|
const existente = leituras.get(caminho);
|
|
@@ -52,7 +77,9 @@ export async function carregarFechamentoContratosSema(arquivosAlvo, arquivosDesc
|
|
|
52
77
|
const resultadoLexer = tokenizar(codigo, caminho);
|
|
53
78
|
const resultadoParser = parsear(resultadoLexer.tokens);
|
|
54
79
|
if (resultadoParser.modulo) {
|
|
55
|
-
|
|
80
|
+
const caminhos = caminhosPorModulo.get(resultadoParser.modulo.nome) ?? new Set();
|
|
81
|
+
caminhos.add(caminho);
|
|
82
|
+
caminhosPorModulo.set(resultadoParser.modulo.nome, caminhos);
|
|
56
83
|
}
|
|
57
84
|
return {
|
|
58
85
|
fonte: { caminho, codigo },
|
|
@@ -62,30 +89,42 @@ export async function carregarFechamentoContratosSema(arquivosAlvo, arquivosDesc
|
|
|
62
89
|
leituras.set(caminho, leitura);
|
|
63
90
|
return leitura;
|
|
64
91
|
};
|
|
65
|
-
const resolverArquivoModulo = async (nomeModulo) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
const resolverArquivoModulo = async (nomeModulo, moduloAtual) => {
|
|
93
|
+
const nomesCandidatos = [
|
|
94
|
+
nomeModulo,
|
|
95
|
+
...listarCandidatosUseRelativo(moduloAtual, nomeModulo),
|
|
96
|
+
];
|
|
97
|
+
for (const nomeCandidato of nomesCandidatos) {
|
|
98
|
+
const tentados = new Set();
|
|
99
|
+
const encontrados = new Set(caminhosPorModulo.get(nomeCandidato) ?? []);
|
|
100
|
+
for (const chave of chavesSufixoModulo(nomeCandidato)) {
|
|
101
|
+
for (const candidato of indiceSufixos.get(chave) ?? []) {
|
|
102
|
+
tentados.add(candidato);
|
|
103
|
+
const contrato = await lerContrato(candidato);
|
|
104
|
+
if (contrato.modulo?.nome === nomeCandidato) {
|
|
105
|
+
encontrados.add(candidato);
|
|
106
|
+
}
|
|
77
107
|
}
|
|
78
108
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
// Fallback raro para workspaces que nao seguem a convencao modulo -> nome do arquivo.
|
|
110
|
+
// Ele so acontece quando o indice deterministico nao encontrou o modulo desta prioridade.
|
|
111
|
+
if (encontrados.size === 0) {
|
|
112
|
+
for (const candidato of descobertos) {
|
|
113
|
+
if (tentados.has(candidato)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const contrato = await lerContrato(candidato);
|
|
117
|
+
if (contrato.modulo?.nome === nomeCandidato) {
|
|
118
|
+
encontrados.add(candidato);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (encontrados.size > 1) {
|
|
123
|
+
const caminhos = [...encontrados].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
124
|
+
throw new Error(`Modulo Sema ambiguo "${nomeCandidato}" em: ${caminhos.join(", ")}`);
|
|
85
125
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return candidato;
|
|
126
|
+
if (encontrados.size === 1) {
|
|
127
|
+
return [...encontrados][0];
|
|
89
128
|
}
|
|
90
129
|
}
|
|
91
130
|
return undefined;
|
|
@@ -106,7 +145,7 @@ export async function carregarFechamentoContratosSema(arquivosAlvo, arquivosDesc
|
|
|
106
145
|
.filter((use) => use.origem === "sema")
|
|
107
146
|
.map((use) => use.caminho) ?? [];
|
|
108
147
|
for (const use of usesSema) {
|
|
109
|
-
const dependencia = await resolverArquivoModulo(use);
|
|
148
|
+
const dependencia = await resolverArquivoModulo(use, contrato.modulo.nome);
|
|
110
149
|
if (!dependencia) {
|
|
111
150
|
dependenciasNaoResolvidas.add(use);
|
|
112
151
|
continue;
|
package/dist/projetoConfig.js
CHANGED
package/dist/projetoLegado.js
CHANGED
|
@@ -17,6 +17,14 @@ export async function inferirFontesLegado(diretoriosCodigo, baseProjeto, configC
|
|
|
17
17
|
if (/@nestjs\/common|@nestjs\/core/.test(packageJsonRaiz)) {
|
|
18
18
|
encontrados.add("nestjs");
|
|
19
19
|
}
|
|
20
|
+
if (/"express"\s*:/.test(packageJsonRaiz)) {
|
|
21
|
+
encontrados.add("express");
|
|
22
|
+
encontrados.add("typescript");
|
|
23
|
+
}
|
|
24
|
+
if (/"fastify"\s*:/.test(packageJsonRaiz)) {
|
|
25
|
+
encontrados.add("fastify");
|
|
26
|
+
encontrados.add("typescript");
|
|
27
|
+
}
|
|
20
28
|
if (/typescript/.test(packageJsonRaiz)) {
|
|
21
29
|
encontrados.add("typescript");
|
|
22
30
|
}
|
|
@@ -64,6 +72,10 @@ export async function inferirFontesLegado(diretoriosCodigo, baseProjeto, configC
|
|
|
64
72
|
const relacoesTs = arquivosTsJs.map((arquivo) => path.relative(diretorio, arquivo).replace(/\\/g, "/"));
|
|
65
73
|
const temNest = textosPackage.some((texto) => /@nestjs\/common|@nestjs\/core/.test(texto ?? ""))
|
|
66
74
|
|| amostrasTs.some((texto) => /@nestjs\/common|@nestjs\/core|@Controller\(|@Get\(|@Post\(|@Put\(|@Patch\(|@Delete\(/.test(texto ?? ""));
|
|
75
|
+
const temExpress = textosPackage.some((texto) => /"express"\s*:/.test(texto ?? ""))
|
|
76
|
+
|| amostrasTs.some((texto) => /(?:from\s+["']express["']|require\(\s*["']express["']\s*\)|\bexpress\s*\(\s*\))/.test(texto ?? ""));
|
|
77
|
+
const temFastify = textosPackage.some((texto) => /"fastify"\s*:/.test(texto ?? ""))
|
|
78
|
+
|| amostrasTs.some((texto) => /(?:from\s+["']fastify["']|require\(\s*["']fastify["']\s*\)|\bfastify\s*\(\s*\{)/.test(texto ?? ""));
|
|
67
79
|
const temNext = textosPackage.some((texto) => /"next"\s*:/.test(texto ?? ""))
|
|
68
80
|
|| nextConfigs.length > 0
|
|
69
81
|
|| relacoesTs.some((relacao) => /(?:^|\/)(?:src\/)?app\/api\/.+\/route\.(?:ts|tsx|js|jsx)$/.test(relacao));
|
|
@@ -86,6 +98,12 @@ export async function inferirFontesLegado(diretoriosCodigo, baseProjeto, configC
|
|
|
86
98
|
if (temNest) {
|
|
87
99
|
encontrados.add("nestjs");
|
|
88
100
|
}
|
|
101
|
+
if (temExpress) {
|
|
102
|
+
encontrados.add("express");
|
|
103
|
+
}
|
|
104
|
+
if (temFastify) {
|
|
105
|
+
encontrados.add("fastify");
|
|
106
|
+
}
|
|
89
107
|
if (temNext) {
|
|
90
108
|
encontrados.add("nextjs");
|
|
91
109
|
}
|
package/dist/projetoOrigens.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ConfiguracaoProjetoCarregada } from './projetoTipos.js';
|
|
2
|
+
export declare function resolverRaizesLogicasCodigoSemCaminhada(baseProjeto: string): string[];
|
|
3
|
+
export declare function resolverDiretoriosCodigoConfigurados(baseProjeto: string, configCarregada?: ConfiguracaoProjetoCarregada): Promise<string[]>;
|
|
2
4
|
export declare function resolverEntradaPadrao(cwd: string, configCarregada?: ConfiguracaoProjetoCarregada): Promise<string>;
|
|
3
5
|
export declare function listarArquivosDeOrigens(origens: string[]): Promise<string[]>;
|
|
4
6
|
export declare function resolverBaseProjeto(entradaResolvida: string, configCarregada?: ConfiguracaoProjetoCarregada): Promise<string>;
|
package/dist/projetoOrigens.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SEMA-GOVERNED: sema.produto.governanca_ia.contexto
|
|
2
2
|
// Descrição: resolve base, origens de contratos e diret?rios de c?digo do projeto.
|
|
3
|
-
import { readdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { readdir, realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { listarArquivosSema } from '@sema/nucleo';
|
|
6
6
|
import { caminhoExiste, DIRETORIOS_CODIGO_IGNORADOS, EXTENSOES_CODIGO, listarDiretoriosFilhos, } from './projetoBusca.js';
|
|
@@ -10,7 +10,12 @@ const DIRETORIOS_CODIGO_FIXOS = [
|
|
|
10
10
|
"app",
|
|
11
11
|
"apps",
|
|
12
12
|
"backend",
|
|
13
|
+
"frontend",
|
|
14
|
+
"client",
|
|
15
|
+
"web",
|
|
13
16
|
"lib",
|
|
17
|
+
"packages",
|
|
18
|
+
"pacotes",
|
|
14
19
|
"api",
|
|
15
20
|
"server",
|
|
16
21
|
"services",
|
|
@@ -21,6 +26,59 @@ const DIRETORIOS_CODIGO_FIXOS = [
|
|
|
21
26
|
"functions",
|
|
22
27
|
"scripts",
|
|
23
28
|
];
|
|
29
|
+
export function resolverRaizesLogicasCodigoSemCaminhada(baseProjeto) {
|
|
30
|
+
return [path.resolve(baseProjeto), ...DIRETORIOS_CODIGO_FIXOS
|
|
31
|
+
.map((segmento) => path.resolve(baseProjeto, segmento))];
|
|
32
|
+
}
|
|
33
|
+
function caminhoEstaDentro(raiz, alvo) {
|
|
34
|
+
const relativo = path.relative(path.resolve(raiz), path.resolve(alvo));
|
|
35
|
+
return relativo === "" || (relativo !== ".."
|
|
36
|
+
&& !relativo.startsWith(`..${path.sep}`)
|
|
37
|
+
&& !path.isAbsolute(relativo));
|
|
38
|
+
}
|
|
39
|
+
function erroEhAusencia(erro) {
|
|
40
|
+
return ["ENOENT", "ENOTDIR"].includes(erro.code ?? "");
|
|
41
|
+
}
|
|
42
|
+
async function resolverDiretoriosConfiguradosConfinados(baseProjeto, baseConfiguracao, declarados, campo) {
|
|
43
|
+
const baseLogica = path.resolve(baseProjeto);
|
|
44
|
+
const baseReal = await realpath(baseLogica);
|
|
45
|
+
const resolvidos = new Map();
|
|
46
|
+
for (const [indice, declarado] of declarados.entries()) {
|
|
47
|
+
const identificadorSeguro = `${campo}[${indice}]`;
|
|
48
|
+
const absoluto = path.resolve(baseConfiguracao, declarado);
|
|
49
|
+
if (!caminhoEstaDentro(baseLogica, absoluto)) {
|
|
50
|
+
throw new Error(`${identificadorSeguro} aponta para fora da base do projeto`);
|
|
51
|
+
}
|
|
52
|
+
let canonico = absoluto;
|
|
53
|
+
try {
|
|
54
|
+
const [real, informacao] = await Promise.all([realpath(absoluto), stat(absoluto)]);
|
|
55
|
+
if (!informacao.isDirectory()) {
|
|
56
|
+
throw new Error(`${identificadorSeguro} nao e diretorio`);
|
|
57
|
+
}
|
|
58
|
+
if (!caminhoEstaDentro(baseReal, real)) {
|
|
59
|
+
throw new Error(`${identificadorSeguro} resolve fora da base do projeto`);
|
|
60
|
+
}
|
|
61
|
+
canonico = real;
|
|
62
|
+
}
|
|
63
|
+
catch (erro) {
|
|
64
|
+
if (!erroEhAusencia(erro)) {
|
|
65
|
+
throw erro;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const chave = process.platform === "win32" ? canonico.toLowerCase() : canonico;
|
|
69
|
+
if (!resolvidos.has(chave)) {
|
|
70
|
+
resolvidos.set(chave, canonico);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return [...resolvidos.values()].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
74
|
+
}
|
|
75
|
+
export async function resolverDiretoriosCodigoConfigurados(baseProjeto, configCarregada) {
|
|
76
|
+
const declarados = configCarregada?.config.diretoriosCodigo ?? [];
|
|
77
|
+
if (declarados.length === 0) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return resolverDiretoriosConfiguradosConfinados(baseProjeto, configCarregada.baseDiretorio, declarados, "diretoriosCodigo");
|
|
81
|
+
}
|
|
24
82
|
export async function resolverEntradaPadrao(cwd, configCarregada) {
|
|
25
83
|
if (configCarregada) {
|
|
26
84
|
return configCarregada.baseDiretorio;
|
|
@@ -100,18 +158,19 @@ async function descobrirOrigemPadrao(baseProjeto, entradaResolvida) {
|
|
|
100
158
|
}
|
|
101
159
|
export async function resolverOrigensProjeto(baseProjeto, entradaResolvida, configCarregada) {
|
|
102
160
|
if (configCarregada) {
|
|
161
|
+
const confinar = (origens) => resolverDiretoriosConfiguradosConfinados(baseProjeto, configCarregada.baseDiretorio, origens, "origens");
|
|
103
162
|
const infoEntrada = await stat(entradaResolvida);
|
|
104
163
|
if (infoEntrada.isFile()) {
|
|
105
|
-
return [path.
|
|
164
|
+
return confinar([path.dirname(entradaResolvida)]);
|
|
106
165
|
}
|
|
107
166
|
if (path.resolve(entradaResolvida) !== path.resolve(configCarregada.baseDiretorio)) {
|
|
108
|
-
return [
|
|
167
|
+
return confinar([entradaResolvida]);
|
|
109
168
|
}
|
|
110
169
|
const declaradas = configCarregada.config.origens ?? (configCarregada.config.origem ? [configCarregada.config.origem] : []);
|
|
111
170
|
if (declaradas.length > 0) {
|
|
112
|
-
return declaradas
|
|
171
|
+
return confinar(declaradas);
|
|
113
172
|
}
|
|
114
|
-
return [configCarregada.baseDiretorio];
|
|
173
|
+
return confinar([configCarregada.baseDiretorio]);
|
|
115
174
|
}
|
|
116
175
|
const infoEntrada = await stat(entradaResolvida);
|
|
117
176
|
if (infoEntrada.isFile()) {
|
|
@@ -149,10 +208,7 @@ async function diretorioTemArquivosCodigo(diretorioBase, profundidadeMaxima = 4)
|
|
|
149
208
|
}
|
|
150
209
|
export async function inferirDiretoriosCodigo(baseProjeto, configCarregada) {
|
|
151
210
|
if (configCarregada?.config.diretoriosCodigo?.length) {
|
|
152
|
-
return
|
|
153
|
-
.map((diretorio) => path.resolve(configCarregada.baseDiretorio, diretorio))
|
|
154
|
-
.filter(Boolean))]
|
|
155
|
-
.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
211
|
+
return resolverDiretoriosCodigoConfigurados(baseProjeto, configCarregada);
|
|
156
212
|
}
|
|
157
213
|
const candidatosFixos = DIRETORIOS_CODIGO_FIXOS
|
|
158
214
|
.map((segmento) => path.join(baseProjeto, segmento));
|
package/dist/projetoTipos.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { EstruturaSaida, FonteLegado, ModoAdocao } from './tipos.js';
|
|
|
4
4
|
export type EscopoCarregamentoProjeto = "arquivo" | "modulo" | "projeto";
|
|
5
5
|
export interface OpcoesCarregarProjeto {
|
|
6
6
|
escopo?: EscopoCarregamentoProjeto;
|
|
7
|
+
adiarDescobertaCodigo?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export interface ConfiguracaoPersistenciaProjeto {
|
|
9
10
|
enginesHabilitados?: EngineBanco[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SCHEMA_RESULTADO_CLI_V1: "sema.cli.result/v1";
|
|
2
|
+
export declare const CODIGO_SAIDA_FATAL_RUNTIME_CLI: 70;
|
|
3
|
+
export type TipoResultadoCliV1 = "SUCCESS" | "DOMAIN_ERROR";
|
|
4
|
+
export interface EnvelopeResultadoCliV1 {
|
|
5
|
+
readonly schemaVersion: typeof SCHEMA_RESULTADO_CLI_V1;
|
|
6
|
+
readonly ok: boolean;
|
|
7
|
+
readonly kind: TipoResultadoCliV1;
|
|
8
|
+
readonly command: string;
|
|
9
|
+
readonly code: "CLI_SUCCESS" | "CLI_DOMAIN_ERROR";
|
|
10
|
+
readonly message: string | null;
|
|
11
|
+
readonly exitCode: number;
|
|
12
|
+
readonly payload: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface EntradaEnvelopeResultadoCliV1 {
|
|
15
|
+
readonly comando: string;
|
|
16
|
+
readonly codigoSaida: number;
|
|
17
|
+
readonly stdout: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function interpretarPayloadRuntimeCli(stdout: string): unknown;
|
|
20
|
+
export declare function criarEnvelopeResultadoCliV1(entrada: EntradaEnvelopeResultadoCliV1): EnvelopeResultadoCliV1;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.cli_invocacao_publica.resultados
|
|
2
|
+
// Descrição: modela o envelope único de resultados JSON da CLI pública 3.0.
|
|
3
|
+
export const SCHEMA_RESULTADO_CLI_V1 = "sema.cli.result/v1";
|
|
4
|
+
export const CODIGO_SAIDA_FATAL_RUNTIME_CLI = 70;
|
|
5
|
+
const COMANDO_CANONICO_VALIDO = /^[a-z][a-z0-9-]{0,63}$/u;
|
|
6
|
+
const MENSAGEM_PUBLICA_ERRO_DOMINIO = "O comando Sema não foi concluído.";
|
|
7
|
+
const SCHEMAS_ENVELOPE_CLI = new Set([
|
|
8
|
+
SCHEMA_RESULTADO_CLI_V1,
|
|
9
|
+
"sema.cli.control/v1",
|
|
10
|
+
]);
|
|
11
|
+
function validarComandoCanonico(comando) {
|
|
12
|
+
if (!COMANDO_CANONICO_VALIDO.test(comando)) {
|
|
13
|
+
throw new TypeError("Comando canônico inválido.");
|
|
14
|
+
}
|
|
15
|
+
return comando;
|
|
16
|
+
}
|
|
17
|
+
function validarCodigoSaida(codigoSaida) {
|
|
18
|
+
if (!Number.isSafeInteger(codigoSaida) || codigoSaida < 0 || codigoSaida > 255) {
|
|
19
|
+
throw new TypeError("Código de saída inválido.");
|
|
20
|
+
}
|
|
21
|
+
return codigoSaida;
|
|
22
|
+
}
|
|
23
|
+
export function interpretarPayloadRuntimeCli(stdout) {
|
|
24
|
+
if (stdout.trim().length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
let payload;
|
|
27
|
+
try {
|
|
28
|
+
payload = JSON.parse(stdout);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return stdout;
|
|
32
|
+
}
|
|
33
|
+
if (payload !== null
|
|
34
|
+
&& typeof payload === "object"
|
|
35
|
+
&& !Array.isArray(payload)
|
|
36
|
+
&& Object.prototype.hasOwnProperty.call(payload, "schemaVersion")
|
|
37
|
+
&& SCHEMAS_ENVELOPE_CLI.has(payload.schemaVersion)) {
|
|
38
|
+
throw new TypeError("Payload não pode conter outro envelope público da CLI.");
|
|
39
|
+
}
|
|
40
|
+
return payload;
|
|
41
|
+
}
|
|
42
|
+
export function criarEnvelopeResultadoCliV1(entrada) {
|
|
43
|
+
const command = validarComandoCanonico(entrada.comando);
|
|
44
|
+
const exitCode = validarCodigoSaida(entrada.codigoSaida);
|
|
45
|
+
const sucesso = exitCode === 0;
|
|
46
|
+
return {
|
|
47
|
+
schemaVersion: SCHEMA_RESULTADO_CLI_V1,
|
|
48
|
+
ok: sucesso,
|
|
49
|
+
kind: sucesso ? "SUCCESS" : "DOMAIN_ERROR",
|
|
50
|
+
command,
|
|
51
|
+
code: sucesso ? "CLI_SUCCESS" : "CLI_DOMAIN_ERROR",
|
|
52
|
+
message: sucesso ? null : MENSAGEM_PUBLICA_ERRO_DOMINIO,
|
|
53
|
+
exitCode,
|
|
54
|
+
payload: interpretarPayloadRuntimeCli(entrada.stdout),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=resultadoCli.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type EntradaEnvelopeResultadoCliV1, type EnvelopeResultadoCliV1 } from "./resultadoCli.js";
|
|
2
|
+
export { CODIGO_SAIDA_FATAL_RUNTIME_CLI, SCHEMA_RESULTADO_CLI_V1, criarEnvelopeResultadoCliV1, interpretarPayloadRuntimeCli, type EntradaEnvelopeResultadoCliV1, type EnvelopeResultadoCliV1, type TipoResultadoCliV1, } from "./resultadoCli.js";
|
|
3
|
+
export declare const SCHEMA_CONTROLE_CLI_V1: "sema.cli.control/v1";
|
|
4
|
+
export type TipoControleCli = "HELP" | "UNKNOWN_COMMAND" | "ARGUMENT_ERROR" | "FATAL_ERROR";
|
|
5
|
+
export interface EnvelopeControleJsonV1 {
|
|
6
|
+
readonly schemaVersion: typeof SCHEMA_CONTROLE_CLI_V1;
|
|
7
|
+
readonly ok: boolean;
|
|
8
|
+
readonly kind: TipoControleCli;
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly exitCode: number;
|
|
12
|
+
}
|
|
13
|
+
export interface EntradaEnvelopeControleJsonV1 {
|
|
14
|
+
readonly categoria: TipoControleCli;
|
|
15
|
+
readonly codigoPublico: string;
|
|
16
|
+
readonly mensagemPublica: string;
|
|
17
|
+
readonly codigoSaida: number;
|
|
18
|
+
}
|
|
19
|
+
export interface OpcoesInvocacaoPublica {
|
|
20
|
+
readonly resultado: TipoControleCli;
|
|
21
|
+
readonly modoJson: boolean;
|
|
22
|
+
readonly envelopeControle?: EnvelopeControleJsonV1;
|
|
23
|
+
readonly mensagemTexto?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RelatorioInvocacaoPublica {
|
|
26
|
+
readonly codigoSaida: number;
|
|
27
|
+
readonly envelopeControleEmitido: boolean;
|
|
28
|
+
readonly stderrVazio: boolean;
|
|
29
|
+
readonly handlerExecutado: boolean;
|
|
30
|
+
readonly politicaControleJsonV1Respeitada: boolean;
|
|
31
|
+
readonly politicaHelpPuroRespeitada: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function criarEnvelopeControleJsonV1(entrada: EntradaEnvelopeControleJsonV1): EnvelopeControleJsonV1;
|
|
34
|
+
export declare function emitirResultadoCliJsonV1(entrada: EntradaEnvelopeResultadoCliV1): EnvelopeResultadoCliV1;
|
|
35
|
+
export declare function executarInvocacaoPublica(opcoes: OpcoesInvocacaoPublica): RelatorioInvocacaoPublica;
|