@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
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.sistemas_interativos.cli
|
|
2
|
+
// Descricao: handler local read-only para catalogar, validar, planejar e verificar evidencias.
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { validarProtocoloAdapterSistemaInterativo } from "./adapterProtocol.js";
|
|
5
|
+
import { CATALOGO_ADAPTADORES_INTERATIVOS, CATALOGO_CAPABILITIES_INTERATIVAS, CATALOGO_PIPELINES_INTERATIVOS, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS, SCHEMA_DEFINICAO_SISTEMA_INTERATIVO, listarAdaptadoresSistemasInterativos, } from "./catalog.js";
|
|
6
|
+
import { derivarEstadoSistemaInterativo, validarBundleEvidenciasSistemaInterativo } from "./evidence.js";
|
|
7
|
+
import { CONTROL_RUN_SCHEMA_VERSION, validarControlRunInterativo, } from "./controlRun.js";
|
|
8
|
+
import { SCHEMA_EXTENSOES_CLI_INTERATIVAS, executarExtensaoCliInterativa, } from "./extensionCommand.js";
|
|
9
|
+
import { planejarSistemaInterativo } from "./planner.js";
|
|
10
|
+
import { renderizarResultadoSistemasInterativos } from "./render.js";
|
|
11
|
+
import { validarDefinicaoSistemaInterativo } from "./validator.js";
|
|
12
|
+
const ALIASES_SUBCOMANDO = Object.freeze({
|
|
13
|
+
capabilities: "capabilities",
|
|
14
|
+
capacidades: "capabilities",
|
|
15
|
+
schema: "schema",
|
|
16
|
+
esquema: "schema",
|
|
17
|
+
pipelines: "pipelines",
|
|
18
|
+
adapters: "adapters",
|
|
19
|
+
adaptadores: "adapters",
|
|
20
|
+
validar: "validar",
|
|
21
|
+
planejar: "planejar",
|
|
22
|
+
"validar-evidencias": "validar-evidencias",
|
|
23
|
+
status: "status",
|
|
24
|
+
"validar-protocolo": "validar-protocolo",
|
|
25
|
+
"validar-control-run": "validar-control-run",
|
|
26
|
+
});
|
|
27
|
+
const FILTROS_PIPELINE = Object.freeze({
|
|
28
|
+
"--kind": "kind",
|
|
29
|
+
"--spatial-model": "spatialModel",
|
|
30
|
+
"--render-mode": "renderMode",
|
|
31
|
+
"--visual-profile": "visualProfile",
|
|
32
|
+
"--control-mode": "controlMode",
|
|
33
|
+
"--fidelity": "fidelity",
|
|
34
|
+
});
|
|
35
|
+
const ESPECIFICACOES = Object.freeze({
|
|
36
|
+
capabilities: { opcoes: {}, flags: ["--json"], posicionais: 0 },
|
|
37
|
+
schema: { opcoes: {}, flags: ["--json"], posicionais: 0 },
|
|
38
|
+
pipelines: { opcoes: FILTROS_PIPELINE, flags: ["--json"], posicionais: 0 },
|
|
39
|
+
adapters: {
|
|
40
|
+
opcoes: {
|
|
41
|
+
...FILTROS_PIPELINE,
|
|
42
|
+
"--role": "role",
|
|
43
|
+
"--time-model": "timeModel",
|
|
44
|
+
},
|
|
45
|
+
flags: ["--json"],
|
|
46
|
+
posicionais: 0,
|
|
47
|
+
},
|
|
48
|
+
validar: { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
49
|
+
planejar: { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
50
|
+
"validar-evidencias": {
|
|
51
|
+
opcoes: {
|
|
52
|
+
"--plano-arquivo": "planFile",
|
|
53
|
+
"--bundle-arquivo": "bundleFile",
|
|
54
|
+
"--evidencias-arquivo": "bundleFile",
|
|
55
|
+
},
|
|
56
|
+
flags: ["--json"],
|
|
57
|
+
posicionais: 1,
|
|
58
|
+
},
|
|
59
|
+
status: {
|
|
60
|
+
opcoes: {
|
|
61
|
+
"--plano-arquivo": "planFile",
|
|
62
|
+
"--bundle-arquivo": "bundleFile",
|
|
63
|
+
"--evidencias-arquivo": "bundleFile",
|
|
64
|
+
},
|
|
65
|
+
flags: ["--json"],
|
|
66
|
+
posicionais: 1,
|
|
67
|
+
},
|
|
68
|
+
"validar-protocolo": { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
69
|
+
"validar-control-run": {
|
|
70
|
+
opcoes: {
|
|
71
|
+
"--definition-arquivo": "definitionFile",
|
|
72
|
+
"--plano-arquivo": "planFile",
|
|
73
|
+
"--contrato-arquivo": "contractFile",
|
|
74
|
+
"--entrada-arquivo": "inputFile",
|
|
75
|
+
"--entrada-auxiliar-arquivo": "secondaryInputFile",
|
|
76
|
+
"--evidencia-arquivo": "evidenceFile",
|
|
77
|
+
"--resultado-arquivo": "resultFile",
|
|
78
|
+
},
|
|
79
|
+
flags: ["--json"],
|
|
80
|
+
posicionais: 1,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const VOCABULARIOS_FILTRO = Object.freeze({
|
|
84
|
+
kind: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.kinds,
|
|
85
|
+
spatialModel: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.spatialModels,
|
|
86
|
+
renderMode: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.renderModes,
|
|
87
|
+
visualProfile: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.visualProfiles,
|
|
88
|
+
controlMode: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.controlModes,
|
|
89
|
+
fidelity: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.fidelities,
|
|
90
|
+
role: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.adapterRoles,
|
|
91
|
+
timeModel: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.timeModels,
|
|
92
|
+
});
|
|
93
|
+
function parsearArgumentos(args) {
|
|
94
|
+
const primeiro = args[0];
|
|
95
|
+
const usaPadrao = primeiro === undefined || primeiro.startsWith("--");
|
|
96
|
+
const nomeBruto = usaPadrao ? "capabilities" : primeiro.toLowerCase().replace(/_/g, "-");
|
|
97
|
+
const subcomando = ALIASES_SUBCOMANDO[nomeBruto];
|
|
98
|
+
if (!subcomando)
|
|
99
|
+
return { valido: false, subcomando: "desconhecido", errorCode: "INTERATIVO_SUBCOMANDO_DESCONHECIDO" };
|
|
100
|
+
const especificacao = ESPECIFICACOES[subcomando];
|
|
101
|
+
const tokens = usaPadrao ? args : args.slice(1);
|
|
102
|
+
const posicionais = [];
|
|
103
|
+
const opcoes = {};
|
|
104
|
+
const flags = new Set();
|
|
105
|
+
for (let indice = 0; indice < tokens.length; indice += 1) {
|
|
106
|
+
const token = tokens[indice];
|
|
107
|
+
if (!token.startsWith("--")) {
|
|
108
|
+
posicionais.push(token);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (especificacao.flags.includes(token)) {
|
|
112
|
+
if (flags.has(token))
|
|
113
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
114
|
+
flags.add(token);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const chave = especificacao.opcoes[token];
|
|
118
|
+
if (!chave || opcoes[chave] !== undefined) {
|
|
119
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
120
|
+
}
|
|
121
|
+
const valor = tokens[indice + 1];
|
|
122
|
+
if (valor === undefined || valor.startsWith("--")) {
|
|
123
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
124
|
+
}
|
|
125
|
+
opcoes[chave] = valor;
|
|
126
|
+
indice += 1;
|
|
127
|
+
}
|
|
128
|
+
if (posicionais.length !== especificacao.posicionais) {
|
|
129
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
130
|
+
}
|
|
131
|
+
for (const [chave, valor] of Object.entries(opcoes)) {
|
|
132
|
+
const vocabulario = VOCABULARIOS_FILTRO[chave];
|
|
133
|
+
if (vocabulario && !vocabulario.includes(valor)) {
|
|
134
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_FILTRO_INVALIDO" };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if ((subcomando === "validar-evidencias" || subcomando === "status") && !opcoes.bundleFile) {
|
|
138
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
139
|
+
}
|
|
140
|
+
if (subcomando === "validar-control-run" && [
|
|
141
|
+
"definitionFile", "planFile", "contractFile", "inputFile", "evidenceFile", "resultFile",
|
|
142
|
+
].some((chave) => opcoes[chave] === undefined)) {
|
|
143
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
144
|
+
}
|
|
145
|
+
return { valido: true, argumentos: { subcomando, posicionais, opcoes } };
|
|
146
|
+
}
|
|
147
|
+
async function lerJson(arquivo) {
|
|
148
|
+
return JSON.parse(await readFile(arquivo, "utf8"));
|
|
149
|
+
}
|
|
150
|
+
function basePayload(comando, sucesso) {
|
|
151
|
+
return {
|
|
152
|
+
sucesso,
|
|
153
|
+
comando,
|
|
154
|
+
readOnly: true,
|
|
155
|
+
executed: false,
|
|
156
|
+
workspaceMutated: false,
|
|
157
|
+
authoritative: false,
|
|
158
|
+
externalExecutionRequired: true,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function erro(comando, errorCode) {
|
|
162
|
+
return { exitCode: 1, payload: { ...basePayload(comando, false), errorCode } };
|
|
163
|
+
}
|
|
164
|
+
function filtrosAdapters(opcoes) {
|
|
165
|
+
return {
|
|
166
|
+
kind: opcoes.kind,
|
|
167
|
+
spatialModel: opcoes.spatialModel,
|
|
168
|
+
renderMode: opcoes.renderMode,
|
|
169
|
+
visualProfile: opcoes.visualProfile,
|
|
170
|
+
role: opcoes.role,
|
|
171
|
+
controlMode: opcoes.controlMode,
|
|
172
|
+
timeModel: opcoes.timeModel,
|
|
173
|
+
fidelity: opcoes.fidelity,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function limparIndefinidos(entrada) {
|
|
177
|
+
return Object.fromEntries(Object.entries(entrada).filter(([, valor]) => valor !== undefined));
|
|
178
|
+
}
|
|
179
|
+
export async function executarComandoSistemasInterativos(args) {
|
|
180
|
+
const extensao = await executarExtensaoCliInterativa(args);
|
|
181
|
+
if (extensao !== null)
|
|
182
|
+
return extensao;
|
|
183
|
+
const parse = parsearArgumentos(args);
|
|
184
|
+
if (!parse.valido)
|
|
185
|
+
return erro(parse.subcomando, parse.errorCode);
|
|
186
|
+
const { subcomando, posicionais, opcoes } = parse.argumentos;
|
|
187
|
+
try {
|
|
188
|
+
if (subcomando === "capabilities") {
|
|
189
|
+
return {
|
|
190
|
+
exitCode: 0,
|
|
191
|
+
payload: {
|
|
192
|
+
...basePayload("capabilities", true),
|
|
193
|
+
matrix: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS,
|
|
194
|
+
capabilities: CATALOGO_CAPABILITIES_INTERATIVAS,
|
|
195
|
+
pipelineIds: CATALOGO_PIPELINES_INTERATIVOS.map((item) => item.pipelineId),
|
|
196
|
+
adapterIds: CATALOGO_ADAPTADORES_INTERATIVOS.map((item) => item.adapterId),
|
|
197
|
+
extensionCommands: Object.keys(SCHEMA_EXTENSOES_CLI_INTERATIVAS.commands),
|
|
198
|
+
extensionSchemaVersion: SCHEMA_EXTENSOES_CLI_INTERATIVAS.schemaVersion,
|
|
199
|
+
runner: "external",
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (subcomando === "schema") {
|
|
204
|
+
return {
|
|
205
|
+
exitCode: 0,
|
|
206
|
+
payload: {
|
|
207
|
+
...basePayload("schema", true),
|
|
208
|
+
...SCHEMA_DEFINICAO_SISTEMA_INTERATIVO,
|
|
209
|
+
interactiveExtensions: SCHEMA_EXTENSOES_CLI_INTERATIVAS,
|
|
210
|
+
controlRun: {
|
|
211
|
+
schemaVersion: CONTROL_RUN_SCHEMA_VERSION,
|
|
212
|
+
command: "sema interativo validar-control-run <control-run.json> --definition-arquivo <definition.json> --plano-arquivo <plan.json> --contrato-arquivo <validation-contract.json> --entrada-arquivo <input.json> [--entrada-auxiliar-arquivo <supporting-input.json>] --evidencia-arquivo <evidence.json> --resultado-arquivo <result.json> --json",
|
|
213
|
+
requiredTopLevelFields: [
|
|
214
|
+
"schemaVersion", "runId", "systemId", "pipelineId", "validatorCommand",
|
|
215
|
+
"definitionDigest", "planDigest", "pipelineContractDigest", "validationContractDigest",
|
|
216
|
+
"producerId", "producerVersion", "producerConfigurationDigest",
|
|
217
|
+
"verifierId", "verifierVersion", "verifierConfigurationDigest",
|
|
218
|
+
"inputSchemaKeys", "inputDigests", "evidenceDigest", "resultDigest",
|
|
219
|
+
],
|
|
220
|
+
readOnly: true,
|
|
221
|
+
executed: false,
|
|
222
|
+
authoritative: false,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (subcomando === "pipelines") {
|
|
228
|
+
const pipelines = CATALOGO_PIPELINES_INTERATIVOS.filter((item) => ((opcoes.kind === undefined || item.kinds.includes(opcoes.kind))
|
|
229
|
+
&& (opcoes.spatialModel === undefined || item.spatialModels.includes(opcoes.spatialModel))
|
|
230
|
+
&& (opcoes.renderMode === undefined || item.renderModes.includes(opcoes.renderMode))
|
|
231
|
+
&& (opcoes.visualProfile === undefined || item.visualProfiles.includes(opcoes.visualProfile))
|
|
232
|
+
&& (opcoes.controlMode === undefined || item.controlModes.includes(opcoes.controlMode))
|
|
233
|
+
&& (opcoes.fidelity === undefined || item.fidelities.includes(opcoes.fidelity))));
|
|
234
|
+
return { exitCode: 0, payload: { ...basePayload("pipelines", true), pipelines } };
|
|
235
|
+
}
|
|
236
|
+
if (subcomando === "adapters") {
|
|
237
|
+
const filtros = limparIndefinidos(filtrosAdapters(opcoes));
|
|
238
|
+
const resultado = listarAdaptadoresSistemasInterativos(filtros);
|
|
239
|
+
return { exitCode: 0, payload: { ...basePayload("adapters", true), ...resultado } };
|
|
240
|
+
}
|
|
241
|
+
if (subcomando === "validar") {
|
|
242
|
+
const definicao = await lerJson(posicionais[0]);
|
|
243
|
+
const resultado = validarDefinicaoSistemaInterativo(definicao);
|
|
244
|
+
return { exitCode: resultado.valida ? 0 : 1, payload: { ...basePayload("validar", resultado.valida), ...resultado } };
|
|
245
|
+
}
|
|
246
|
+
if (subcomando === "planejar") {
|
|
247
|
+
const definicao = await lerJson(posicionais[0]);
|
|
248
|
+
const resultado = planejarSistemaInterativo(definicao);
|
|
249
|
+
const sucesso = resultado.bloqueios.length === 0;
|
|
250
|
+
return { exitCode: sucesso ? 0 : 1, payload: { ...basePayload("planejar", sucesso), ...resultado } };
|
|
251
|
+
}
|
|
252
|
+
if (subcomando === "validar-evidencias" || subcomando === "status") {
|
|
253
|
+
const definicao = await lerJson(posicionais[0]);
|
|
254
|
+
const [plano, bundle] = await Promise.all([
|
|
255
|
+
opcoes.planFile === undefined
|
|
256
|
+
? Promise.resolve(planejarSistemaInterativo(definicao).plano)
|
|
257
|
+
: lerJson(opcoes.planFile),
|
|
258
|
+
lerJson(opcoes.bundleFile),
|
|
259
|
+
]);
|
|
260
|
+
if (subcomando === "validar-evidencias") {
|
|
261
|
+
const resultado = validarBundleEvidenciasSistemaInterativo(definicao, plano, bundle);
|
|
262
|
+
return { exitCode: resultado.valido ? 0 : 1, payload: { ...basePayload("validar-evidencias", resultado.valido), ...resultado } };
|
|
263
|
+
}
|
|
264
|
+
const estado = derivarEstadoSistemaInterativo(definicao, plano, bundle);
|
|
265
|
+
const sucesso = estado.bloqueios.length === 0;
|
|
266
|
+
return { exitCode: sucesso ? 0 : 1, payload: { ...basePayload("status", sucesso), estado } };
|
|
267
|
+
}
|
|
268
|
+
if (subcomando === "validar-control-run") {
|
|
269
|
+
const [manifesto, definicao, plano, contrato, entrada, entradaAuxiliar, evidencia, resultado] = await Promise.all([
|
|
270
|
+
lerJson(posicionais[0]),
|
|
271
|
+
lerJson(opcoes.definitionFile),
|
|
272
|
+
lerJson(opcoes.planFile),
|
|
273
|
+
lerJson(opcoes.contractFile),
|
|
274
|
+
lerJson(opcoes.inputFile),
|
|
275
|
+
opcoes.secondaryInputFile === undefined ? Promise.resolve(undefined) : lerJson(opcoes.secondaryInputFile),
|
|
276
|
+
lerJson(opcoes.evidenceFile),
|
|
277
|
+
lerJson(opcoes.resultFile),
|
|
278
|
+
]);
|
|
279
|
+
const controlRun = validarControlRunInterativo(manifesto, {
|
|
280
|
+
definicao,
|
|
281
|
+
plano,
|
|
282
|
+
contrato,
|
|
283
|
+
entradas: entradaAuxiliar === undefined ? [entrada] : [entrada, entradaAuxiliar],
|
|
284
|
+
evidencia,
|
|
285
|
+
resultado,
|
|
286
|
+
});
|
|
287
|
+
return {
|
|
288
|
+
exitCode: controlRun.valid ? 0 : 1,
|
|
289
|
+
payload: { ...basePayload("validar-control-run", controlRun.valid), resultado: controlRun },
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const registro = await lerJson(posicionais[0]);
|
|
293
|
+
const resultado = validarProtocoloAdapterSistemaInterativo(registro);
|
|
294
|
+
return { exitCode: resultado.valido ? 0 : 1, payload: { ...basePayload("validar-protocolo", resultado.valido), ...resultado } };
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
return erro(subcomando, "INTERATIVO_ENTRADA_INVALIDA");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
export async function comandoSistemasInterativos(_posicionaisGlobais, args, emJson) {
|
|
301
|
+
const resultado = await executarComandoSistemasInterativos(args);
|
|
302
|
+
const saidaJson = emJson || args.includes("--json");
|
|
303
|
+
if (saidaJson)
|
|
304
|
+
console.log(JSON.stringify(resultado.payload, null, 2));
|
|
305
|
+
else if (resultado.exitCode === 0)
|
|
306
|
+
console.log(renderizarResultadoSistemasInterativos(resultado.payload));
|
|
307
|
+
else
|
|
308
|
+
console.error(renderizarResultadoSistemasInterativos(resultado.payload));
|
|
309
|
+
return resultado.exitCode;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const CONTROL_RUN_SCHEMA_VERSION: "sema.interactive.control-run/v1";
|
|
2
|
+
export interface ManifestoControlRunInterativo {
|
|
3
|
+
readonly schemaVersion: typeof CONTROL_RUN_SCHEMA_VERSION;
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
readonly systemId: string;
|
|
6
|
+
readonly pipelineId: string;
|
|
7
|
+
readonly validatorCommand: string;
|
|
8
|
+
readonly definitionDigest: string;
|
|
9
|
+
readonly planDigest: string;
|
|
10
|
+
readonly pipelineContractDigest: string;
|
|
11
|
+
readonly validationContractDigest: string;
|
|
12
|
+
readonly producerId: string;
|
|
13
|
+
readonly producerVersion: string;
|
|
14
|
+
readonly producerConfigurationDigest: string;
|
|
15
|
+
readonly verifierId: string;
|
|
16
|
+
readonly verifierVersion: string;
|
|
17
|
+
readonly verifierConfigurationDigest: string;
|
|
18
|
+
readonly inputSchemaKeys: readonly string[];
|
|
19
|
+
readonly inputDigests: readonly string[];
|
|
20
|
+
readonly evidenceDigest: string;
|
|
21
|
+
readonly resultDigest: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ArtefatosControlRunInterativo {
|
|
24
|
+
readonly definicao: unknown;
|
|
25
|
+
readonly plano: unknown;
|
|
26
|
+
readonly contrato: unknown;
|
|
27
|
+
readonly entradas: readonly unknown[];
|
|
28
|
+
readonly evidencia: unknown;
|
|
29
|
+
readonly resultado: unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface BindingControlRunInterativo {
|
|
32
|
+
readonly kind: "DEFINITION" | "PLAN" | "PIPELINE_CONTRACT" | "VALIDATION_CONTRACT" | "INPUT" | "EVIDENCE" | "RESULT";
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly digest: string;
|
|
35
|
+
readonly matched: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface ResultadoControlRunInterativo {
|
|
38
|
+
readonly valid: boolean;
|
|
39
|
+
readonly controlRunDigest: string;
|
|
40
|
+
readonly definitionDigest: string;
|
|
41
|
+
readonly planDigest: string;
|
|
42
|
+
readonly pipelineContractDigest: string;
|
|
43
|
+
readonly validationContractDigest: string;
|
|
44
|
+
readonly inputDigests: readonly string[];
|
|
45
|
+
readonly evidenceDigest: string;
|
|
46
|
+
readonly resultDigest: string;
|
|
47
|
+
readonly bindings: readonly BindingControlRunInterativo[];
|
|
48
|
+
readonly issues: readonly string[];
|
|
49
|
+
readonly completed: false;
|
|
50
|
+
readonly localCoverageComplete: boolean;
|
|
51
|
+
readonly awaitingExternalAttestation: true;
|
|
52
|
+
readonly executed: false;
|
|
53
|
+
readonly workspaceMutated: false;
|
|
54
|
+
readonly authoritative: false;
|
|
55
|
+
}
|
|
56
|
+
export declare function validarControlRunInterativo(manifestoEntrada: unknown, artefatos: ArtefatosControlRunInterativo): ResultadoControlRunInterativo;
|