@semacode/cli 2.3.1 → 3.0.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 +567 -557
- 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/drift.part01.d.ts +26 -24
- package/dist/drift.part01.js +2 -1
- package/dist/drift.part04.d.ts +12 -3
- package/dist/drift.part04.js +88 -17
- 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.part11.js +238 -56
- 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 +21 -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/geracaoCore.js +4 -6
- package/dist/iaPrompts.d.ts +3 -3
- package/dist/iaPrompts.js +312 -313
- 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 +142 -120
- package/dist/index.part05.js +80 -78
- package/dist/index.part06.js +34 -17
- package/dist/index.part07.js +7 -3
- package/dist/index.part08.d.ts +1 -1
- package/dist/index.part08.js +22 -27
- package/dist/initCommand.js +5 -1
- package/dist/initTemplatesBase.js +81 -79
- 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/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/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/testing.md +139 -40
- 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/semantico/analisador.d.ts +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
- 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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.distribuicao_global.skill.intencoes
|
|
2
|
+
// Descrição: materializa a matriz de intenção da skill sem executar mutações.
|
|
3
|
+
import { versaoSemanticaValida } from "./versaoSemantica.js";
|
|
4
|
+
export const INTENCOES_SKILL_SEMA = [
|
|
5
|
+
"INFORMAR",
|
|
6
|
+
"INSTALAR_GLOBAL",
|
|
7
|
+
"ATUALIZAR_GLOBAL",
|
|
8
|
+
"REPARAR_GLOBAL",
|
|
9
|
+
"ADOTAR_WORKSPACE",
|
|
10
|
+
];
|
|
11
|
+
function versaoGlobalValidada(versao) {
|
|
12
|
+
if (versao === undefined || versao === "latest") {
|
|
13
|
+
return { solicitada: "latest", resolverLatest: true };
|
|
14
|
+
}
|
|
15
|
+
if (versaoSemanticaValida(versao)) {
|
|
16
|
+
return { solicitada: versao, resolverLatest: false };
|
|
17
|
+
}
|
|
18
|
+
throw new Error("VERSAO_GLOBAL_DEVE_SER_SEMVER_EXATA_OU_LATEST");
|
|
19
|
+
}
|
|
20
|
+
const ACOES_RESOLVER_CLI_INSTALADA = [
|
|
21
|
+
"provar_cli_path_com_versao_e_skill",
|
|
22
|
+
"provar_launcher_gerenciado_com_versao_e_skill",
|
|
23
|
+
"preferir_launcher_gerenciado_se_path_stale_ou_sem_skill",
|
|
24
|
+
];
|
|
25
|
+
const ACOES_PROVAR_AMBAS_CLI = [
|
|
26
|
+
"provar_cli_path_com_versao_e_skill",
|
|
27
|
+
"provar_launcher_gerenciado_com_versao_e_skill",
|
|
28
|
+
];
|
|
29
|
+
export function planejarIntencaoSkillSema(entrada) {
|
|
30
|
+
if (["INSTALAR_GLOBAL", "ATUALIZAR_GLOBAL"].includes(entrada.intencao)) {
|
|
31
|
+
const versao = versaoGlobalValidada(entrada.versaoSolicitada);
|
|
32
|
+
const acoesInstalacao = versao.resolverLatest
|
|
33
|
+
? [
|
|
34
|
+
"npm_view_version:@semacode/cli@latest",
|
|
35
|
+
"validar_semver_exata_resolvida",
|
|
36
|
+
"npm_install_global:@semacode/cli@SEMVER_EXATA_RESOLVIDA",
|
|
37
|
+
]
|
|
38
|
+
: [`npm_install_global:@semacode/cli@${versao.solicitada}`];
|
|
39
|
+
return {
|
|
40
|
+
instalar_pacote_global: true,
|
|
41
|
+
sincronizar_distribuicao_se_necessario: true,
|
|
42
|
+
mutar_workspace: false,
|
|
43
|
+
bloqueado_por_autorizacao_adocao: false,
|
|
44
|
+
resolver_latest_para_semver_exata: versao.resolverLatest,
|
|
45
|
+
provar_path_e_launcher_gerenciado: true,
|
|
46
|
+
exigir_prova_versao: true,
|
|
47
|
+
exigir_status_final_ready: true,
|
|
48
|
+
acoes_ordenadas: [
|
|
49
|
+
...acoesInstalacao,
|
|
50
|
+
...ACOES_RESOLVER_CLI_INSTALADA,
|
|
51
|
+
"provar_versao_instalada",
|
|
52
|
+
"consultar_status_distribuicao",
|
|
53
|
+
"sincronizar_distribuicao_se_necessario",
|
|
54
|
+
"consultar_status_final_ready",
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (entrada.intencao === "REPARAR_GLOBAL") {
|
|
59
|
+
const cliDisponivel = entrada.cliDisponivel;
|
|
60
|
+
return {
|
|
61
|
+
instalar_pacote_global: false,
|
|
62
|
+
sincronizar_distribuicao_se_necessario: cliDisponivel,
|
|
63
|
+
mutar_workspace: false,
|
|
64
|
+
bloqueado_por_autorizacao_adocao: false,
|
|
65
|
+
resolver_latest_para_semver_exata: false,
|
|
66
|
+
provar_path_e_launcher_gerenciado: true,
|
|
67
|
+
exigir_prova_versao: false,
|
|
68
|
+
exigir_status_final_ready: cliDisponivel,
|
|
69
|
+
acoes_ordenadas: cliDisponivel
|
|
70
|
+
? [
|
|
71
|
+
...ACOES_RESOLVER_CLI_INSTALADA,
|
|
72
|
+
"consultar_status_distribuicao",
|
|
73
|
+
"sincronizar_distribuicao_se_necessario",
|
|
74
|
+
"consultar_status_final_ready",
|
|
75
|
+
]
|
|
76
|
+
: [
|
|
77
|
+
...ACOES_PROVAR_AMBAS_CLI,
|
|
78
|
+
"declarar_cli_indisponivel_apos_path_e_launcher_gerenciado_invalidos",
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (entrada.intencao === "ADOTAR_WORKSPACE") {
|
|
83
|
+
const autorizado = entrada.adocaoAutorizada;
|
|
84
|
+
return {
|
|
85
|
+
instalar_pacote_global: false,
|
|
86
|
+
sincronizar_distribuicao_se_necessario: false,
|
|
87
|
+
mutar_workspace: autorizado,
|
|
88
|
+
bloqueado_por_autorizacao_adocao: !autorizado,
|
|
89
|
+
resolver_latest_para_semver_exata: false,
|
|
90
|
+
provar_path_e_launcher_gerenciado: false,
|
|
91
|
+
exigir_prova_versao: false,
|
|
92
|
+
exigir_status_final_ready: false,
|
|
93
|
+
acoes_ordenadas: autorizado
|
|
94
|
+
? [
|
|
95
|
+
"descobrir_explicar_flow_project_adoption",
|
|
96
|
+
"iniciar_template_base",
|
|
97
|
+
"sync_codex",
|
|
98
|
+
"ler_agents_e_boot",
|
|
99
|
+
]
|
|
100
|
+
: ["pedir_autorizacao_adocao"],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
instalar_pacote_global: false,
|
|
105
|
+
sincronizar_distribuicao_se_necessario: false,
|
|
106
|
+
mutar_workspace: false,
|
|
107
|
+
bloqueado_por_autorizacao_adocao: false,
|
|
108
|
+
resolver_latest_para_semver_exata: false,
|
|
109
|
+
provar_path_e_launcher_gerenciado: false,
|
|
110
|
+
exigir_prova_versao: false,
|
|
111
|
+
exigir_status_final_ready: false,
|
|
112
|
+
acoes_ordenadas: ["responder_sem_mutar"],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=skillIntentPolicy.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const ESTADOS_DISTRIBUICAO_GLOBAL: readonly ["READY", "MISSING", "STALE", "BROKEN_TARGET", "PERMISSION_DENIED"];
|
|
2
|
+
export type EstadoDistribuicaoGlobal = typeof ESTADOS_DISTRIBUICAO_GLOBAL[number];
|
|
3
|
+
export interface OpcoesAmbienteDistribuicaoGlobal {
|
|
4
|
+
/** Plataforma usada para escolher o formato do launcher. */
|
|
5
|
+
plataforma?: NodeJS.Platform;
|
|
6
|
+
/** Home explícita. A implementação nunca consulta outro diretório quando este valor é informado. */
|
|
7
|
+
diretorioUsuario?: string;
|
|
8
|
+
/** Executável absoluto do Node que será embutido no launcher. */
|
|
9
|
+
executavelNode?: string;
|
|
10
|
+
/** Raiz absoluta do pacote @semacode/cli instalado. */
|
|
11
|
+
raizPacote?: string;
|
|
12
|
+
}
|
|
13
|
+
export type CodigoDiagnosticoDistribuicaoGlobal = "AMBIENTE_INVALIDO" | "CAMINHO_FORA_DA_HOME" | "COMPONENTE_NAO_DIRETORIO" | "CONTEUDO_NAO_GERENCIADO" | "DESTINO_ALTERADO" | "DESTINO_AUSENTE" | "DESTINO_DESATUALIZADO" | "DESTINO_PRONTO" | "ERRO_PERMISSAO" | "EXECUTAVEL_NODE_INVALIDO" | "LIMPEZA_PENDENTE" | "LOCK_PERDIDO" | "LOCK_TIMEOUT" | "PACOTE_INVALIDO" | "PERMISSAO_EXECUCAO_INVALIDA" | "RECIBO_INVALIDO" | "ROLLBACK_FALHOU" | "SYMLINK_OU_JUNCTION" | "TARGET_CLI_INVALIDO";
|
|
14
|
+
export interface ResultadoLauncherGlobal {
|
|
15
|
+
estado: EstadoDistribuicaoGlobal;
|
|
16
|
+
alterado: boolean;
|
|
17
|
+
destino_simbolico: "$HOME/.sema/bin/sema" | "$HOME/.sema/bin/sema.cmd";
|
|
18
|
+
codigo: CodigoDiagnosticoDistribuicaoGlobal;
|
|
19
|
+
node_absoluto: boolean;
|
|
20
|
+
entrypoint_absoluto: boolean;
|
|
21
|
+
recibo_valido: boolean;
|
|
22
|
+
independente_path: boolean;
|
|
23
|
+
fallback_simbolico: "$HOME/.sema/bin/sema-managed.ps1" | null;
|
|
24
|
+
}
|
|
25
|
+
export type IdentificadorDestinoSkillGlobal = "agents" | "claude";
|
|
26
|
+
export interface ResultadoDestinoSkillGlobal {
|
|
27
|
+
id: IdentificadorDestinoSkillGlobal;
|
|
28
|
+
estado: EstadoDistribuicaoGlobal;
|
|
29
|
+
alterado: boolean;
|
|
30
|
+
destino_simbolico: "$HOME/.agents/skills/sema" | "$HOME/.claude/skills/sema";
|
|
31
|
+
codigo: CodigoDiagnosticoDistribuicaoGlobal;
|
|
32
|
+
}
|
|
33
|
+
export interface ResultadoSkillGlobal {
|
|
34
|
+
estado: EstadoDistribuicaoGlobal;
|
|
35
|
+
alterado: boolean;
|
|
36
|
+
origem_simbolica: "$PACKAGE_ROOT/skills/sema";
|
|
37
|
+
destino_agents: EstadoDistribuicaoGlobal;
|
|
38
|
+
destino_claude: EstadoDistribuicaoGlobal | "NOT_DETECTED";
|
|
39
|
+
espelho_claude_detectado: boolean;
|
|
40
|
+
ownership_valido: boolean;
|
|
41
|
+
digest_alinhado: boolean;
|
|
42
|
+
cache_plugin_intocado: true;
|
|
43
|
+
destinos: ResultadoDestinoSkillGlobal[];
|
|
44
|
+
}
|
|
45
|
+
export interface ResultadoDistribuicaoGlobal {
|
|
46
|
+
estado: EstadoDistribuicaoGlobal;
|
|
47
|
+
alterado: boolean;
|
|
48
|
+
launcher: ResultadoLauncherGlobal;
|
|
49
|
+
skill: ResultadoSkillGlobal;
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.distribuicao_global
|
|
2
|
+
// Descrição: define o contrato público e injetável da distribuição local global da CLI e da skill Sema.
|
|
3
|
+
export const ESTADOS_DISTRIBUICAO_GLOBAL = [
|
|
4
|
+
"READY",
|
|
5
|
+
"MISSING",
|
|
6
|
+
"STALE",
|
|
7
|
+
"BROKEN_TARGET",
|
|
8
|
+
"PERMISSION_DENIED",
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=tipos.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.distribuicao_global
|
|
2
|
+
// Descrição: valida versões SemVer de pacotes e recibos sem rede ou dependência externa.
|
|
3
|
+
const PADRAO_SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/u;
|
|
4
|
+
function analisar(valor) {
|
|
5
|
+
if (valor.length > 256)
|
|
6
|
+
return null;
|
|
7
|
+
const match = valor.match(PADRAO_SEMVER);
|
|
8
|
+
if (!match)
|
|
9
|
+
return null;
|
|
10
|
+
return {
|
|
11
|
+
major: BigInt(match[1] ?? "0"),
|
|
12
|
+
minor: BigInt(match[2] ?? "0"),
|
|
13
|
+
patch: BigInt(match[3] ?? "0"),
|
|
14
|
+
prerelease: match[4]?.split(".") ?? null,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function versaoSemanticaValida(valor) {
|
|
18
|
+
return typeof valor === "string" && analisar(valor) !== null;
|
|
19
|
+
}
|
|
20
|
+
function compararIdentificador(a, b) {
|
|
21
|
+
const numericoA = /^\d+$/u.test(a);
|
|
22
|
+
const numericoB = /^\d+$/u.test(b);
|
|
23
|
+
if (numericoA && numericoB) {
|
|
24
|
+
const inteiroA = BigInt(a);
|
|
25
|
+
const inteiroB = BigInt(b);
|
|
26
|
+
return inteiroA === inteiroB ? 0 : inteiroA > inteiroB ? 1 : -1;
|
|
27
|
+
}
|
|
28
|
+
if (numericoA !== numericoB)
|
|
29
|
+
return numericoA ? -1 : 1;
|
|
30
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
31
|
+
}
|
|
32
|
+
/** Retorna -1, 0 ou 1. Build metadata não participa da precedência SemVer. */
|
|
33
|
+
export function compararVersoesSemanticas(a, b) {
|
|
34
|
+
const versaoA = analisar(a);
|
|
35
|
+
const versaoB = analisar(b);
|
|
36
|
+
if (!versaoA || !versaoB)
|
|
37
|
+
throw new Error("VERSAO_SEMANTICA_INVALIDA");
|
|
38
|
+
for (const chave of ["major", "minor", "patch"]) {
|
|
39
|
+
if (versaoA[chave] !== versaoB[chave])
|
|
40
|
+
return versaoA[chave] > versaoB[chave] ? 1 : -1;
|
|
41
|
+
}
|
|
42
|
+
if (versaoA.prerelease === null || versaoB.prerelease === null) {
|
|
43
|
+
if (versaoA.prerelease === versaoB.prerelease)
|
|
44
|
+
return 0;
|
|
45
|
+
return versaoA.prerelease === null ? 1 : -1;
|
|
46
|
+
}
|
|
47
|
+
const limite = Math.max(versaoA.prerelease.length, versaoB.prerelease.length);
|
|
48
|
+
for (let indice = 0; indice < limite; indice += 1) {
|
|
49
|
+
const itemA = versaoA.prerelease[indice];
|
|
50
|
+
const itemB = versaoB.prerelease[indice];
|
|
51
|
+
if (itemA === undefined || itemB === undefined) {
|
|
52
|
+
if (itemA === itemB)
|
|
53
|
+
return 0;
|
|
54
|
+
return itemA === undefined ? -1 : 1;
|
|
55
|
+
}
|
|
56
|
+
const comparacao = compararIdentificador(itemA, itemB);
|
|
57
|
+
if (comparacao !== 0)
|
|
58
|
+
return comparacao;
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=versaoSemantica.js.map
|
package/dist/drift.part01.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EngineBanco, NivelConfiancaSemantica, NivelRiscoSemantico, TipoRecursoPersistencia } from "@sema/nucleo";
|
|
2
2
|
import type { ContextoProjetoCarregado } from "./projeto.js";
|
|
3
|
-
import type { PoliticaCacheDrift } from "./driftCache.js";
|
|
4
|
-
import type { MetricasCacheIncrementalDrift } from "./driftCacheIncremental.js";
|
|
5
3
|
import type { MetricasCatalogoDrift, ObservadorOperacaoDrift } from "./driftCatalogo.js";
|
|
4
|
+
import type { CoberturaEscopoDrift, EstrategiaEscopoDrift } from "./driftEscopo.js";
|
|
5
|
+
import type { AvisoModoCacheDrift, ModoCacheDrift } from "./driftCacheModes.js";
|
|
6
6
|
export type OrigemCodigoDrift = "ts" | "js" | "py" | "dart" | "lua" | "cs" | "java" | "go" | "rust" | "cpp" | "php";
|
|
7
7
|
export type OrigemSimboloDrift = OrigemCodigoDrift | "sql";
|
|
8
8
|
export interface SimboloResolvido {
|
|
@@ -34,11 +34,12 @@ export interface OpcoesDriftLegado {
|
|
|
34
34
|
escopo?: EscopoDriftReal;
|
|
35
35
|
ignorarWorktrees?: boolean;
|
|
36
36
|
ignorarConsumidoresLaterais?: boolean;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
modoCache?: ModoCacheDrift;
|
|
38
|
+
avisosModoCache?: readonly AvisoModoCacheDrift[];
|
|
39
|
+
observador?: ObservadorOperacaoDrift | undefined;
|
|
39
40
|
}
|
|
40
41
|
export interface DiagnosticoDrift {
|
|
41
|
-
tipo: "impl_quebrado" | "task_sem_impl" | "rota_divergente" | "recurso_divergente" | "vinculo_quebrado" | "seguranca_frouxa" | "pontuacao_semantica_insuficiente" | "contrato_monolitico" | "codigo_monolitico" | "codigo_governado_sem_cabecalho" | "escopo_estreito_sem_vinculos";
|
|
42
|
+
tipo: "impl_quebrado" | "task_sem_impl" | "rota_divergente" | "recurso_divergente" | "vinculo_quebrado" | "seguranca_frouxa" | "pontuacao_semantica_insuficiente" | "contrato_monolitico" | "codigo_monolitico" | "codigo_governado_sem_cabecalho" | "escopo_estreito_sem_vinculos" | "escopo_estreito_ambiguo";
|
|
42
43
|
modulo: string;
|
|
43
44
|
task?: string;
|
|
44
45
|
route?: string;
|
|
@@ -164,28 +165,30 @@ export interface ConfiguracaoEscopoDriftAplicada {
|
|
|
164
165
|
ignorarWorktrees: boolean;
|
|
165
166
|
ignorarConsumidoresLaterais: boolean;
|
|
166
167
|
termosEscopo: string[];
|
|
167
|
-
estrategia?:
|
|
168
|
-
cobertura?:
|
|
168
|
+
estrategia?: EstrategiaEscopoDrift;
|
|
169
|
+
cobertura?: CoberturaEscopoDrift;
|
|
169
170
|
arquivosPlanejados?: string[];
|
|
170
171
|
arquivosDeclarados?: string[];
|
|
171
172
|
arquivosInferidos?: string[];
|
|
172
173
|
arquivosAusentes?: string[];
|
|
173
174
|
bloqueios?: string[];
|
|
174
|
-
cache?: {
|
|
175
|
-
politica: PoliticaCacheDrift;
|
|
176
|
-
origem: "cache" | "calculado" | "nao_aplicavel";
|
|
177
|
-
chave?: string;
|
|
178
|
-
incremental?: MetricasCacheIncrementalDrift;
|
|
179
|
-
fasesMs?: {
|
|
180
|
-
planejamento: number;
|
|
181
|
-
catalogacao: number;
|
|
182
|
-
dependencias: number;
|
|
183
|
-
assinaturas: number;
|
|
184
|
-
indexacao: number;
|
|
185
|
-
total: number;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
175
|
catalogo?: MetricasCatalogoDrift;
|
|
176
|
+
cache?: EstadoCacheDriftAplicado;
|
|
177
|
+
}
|
|
178
|
+
export interface MetricasCacheDriftAplicado {
|
|
179
|
+
hits: number;
|
|
180
|
+
misses: number;
|
|
181
|
+
corruptos: number;
|
|
182
|
+
gravacoes: number;
|
|
183
|
+
errosGravacao: number;
|
|
184
|
+
}
|
|
185
|
+
export interface EstadoCacheDriftAplicado {
|
|
186
|
+
modo: ModoCacheDrift;
|
|
187
|
+
origem: "cache" | "calculado" | "indisponivel" | "nao_aplicavel";
|
|
188
|
+
schema: string;
|
|
189
|
+
workspaceId?: string;
|
|
190
|
+
metricas: MetricasCacheDriftAplicado;
|
|
191
|
+
avisos: readonly AvisoModoCacheDrift[];
|
|
189
192
|
}
|
|
190
193
|
export interface RegistroImpactoSemanticoArquivo {
|
|
191
194
|
arquivo: string;
|
|
@@ -278,10 +281,9 @@ export declare function obterDiretoriosIgnoradosAtivos(): Set<string>;
|
|
|
278
281
|
export declare function definirDiretoriosIgnoradosAtivos(diretorios: Set<string>): void;
|
|
279
282
|
export declare function normalizarFragmentoArquivo(valor: string): string;
|
|
280
283
|
export declare function normalizarEscopoDrift(valor?: string): EscopoDriftReal;
|
|
281
|
-
export
|
|
282
|
-
observador
|
|
284
|
+
export declare function resolverOpcoesDrift(opcoes?: OpcoesDriftLegado): Omit<Required<OpcoesDriftLegado>, "observador"> & {
|
|
285
|
+
observador: ObservadorOperacaoDrift | undefined;
|
|
283
286
|
};
|
|
284
|
-
export declare function resolverOpcoesDrift(opcoes?: OpcoesDriftLegado): OpcoesDriftLegadoResolvidas;
|
|
285
287
|
export declare function resolverDiretoriosIgnoradosAtivos(opcoes?: OpcoesDriftLegado): Set<string>;
|
|
286
288
|
export declare function quebrarTermosEscopo(valor: string): string[];
|
|
287
289
|
export declare function quebrarTermosModuloEscopo(nomeModulo: string): string[];
|
package/dist/drift.part01.js
CHANGED
|
@@ -91,7 +91,8 @@ export function resolverOpcoesDrift(opcoes) {
|
|
|
91
91
|
escopo: normalizarEscopoDrift(opcoes?.escopo),
|
|
92
92
|
ignorarWorktrees: opcoes?.ignorarWorktrees !== false,
|
|
93
93
|
ignorarConsumidoresLaterais: opcoes?.ignorarConsumidoresLaterais !== false,
|
|
94
|
-
|
|
94
|
+
modoCache: opcoes?.modoCache ?? "none",
|
|
95
|
+
avisosModoCache: opcoes?.avisosModoCache ?? [],
|
|
95
96
|
observador: opcoes?.observador,
|
|
96
97
|
};
|
|
97
98
|
}
|
package/dist/drift.part04.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import type { IrModulo, IrSuperficie, IrTask, IrVinculo, NivelConfiancaSemantica, NivelRiscoSemantico } from "@sema/nucleo";
|
|
3
3
|
import { ResultadoDrift, SimboloResolvido } from "./drift.part01.js";
|
|
4
|
+
import type { OrigemCodigoDrift } from "./drift.part01.js";
|
|
4
5
|
import { type PoliticaPontuacaoSemantica } from "./driftScore.js";
|
|
5
|
-
|
|
6
|
+
export type EventoLeituraCompartilhadaDrift = "extractor.run" | "ast.create";
|
|
7
|
+
export interface AdaptadorLeituraCompartilhadaDrift {
|
|
8
|
+
listarPorRaiz(raiz: string, extensoes: readonly string[]): readonly string[] | Promise<readonly string[]>;
|
|
9
|
+
lerTexto(arquivo: string): Promise<string>;
|
|
10
|
+
emitir?(tipo: EventoLeituraCompartilhadaDrift, arquivo?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function chaveCaminhoCanonicoDrift(caminho: string): string;
|
|
13
|
+
export declare function deduplicarRaizesSobrepostasDrift(diretorios: readonly string[]): string[];
|
|
14
|
+
export declare function encontrarCandidatosFisicosImplementacaoDrift(simbolos: readonly SimboloResolvido[], origem: OrigemCodigoDrift, caminhoDeclarado: string): SimboloResolvido[];
|
|
6
15
|
export declare function resolverArquivoOuSimboloAncora(vinculos: IrVinculo[], simbolos: SimboloResolvido[], mapaImpl: Map<string, SimboloResolvido>, arquivos: string[]): {
|
|
7
16
|
arquivo?: string;
|
|
8
17
|
simbolo?: string;
|
|
@@ -38,9 +47,9 @@ export declare function lerDecorator(node: ts.Node, nomes: string[]): {
|
|
|
38
47
|
argumentos: ts.NodeArray<ts.Expression>;
|
|
39
48
|
} | undefined;
|
|
40
49
|
export declare function juntarCaminhoHttp(base: string | undefined, sufixo: string | undefined): string;
|
|
41
|
-
export declare function listarArquivosRecursivos(diretorio: string, extensoes: string[],
|
|
50
|
+
export declare function listarArquivosRecursivos(diretorio: string, extensoes: string[], adaptadorLeitura?: AdaptadorLeituraCompartilhadaDrift): Promise<string[]>;
|
|
42
51
|
export declare const EXTENSOES_ARQUIVOS_RASTREAVEIS_DRIFT: string[];
|
|
43
|
-
export declare function indexarArquivosRastreaveis(diretorios: string[],
|
|
52
|
+
export declare function indexarArquivosRastreaveis(diretorios: string[], adaptadorLeitura?: AdaptadorLeituraCompartilhadaDrift): Promise<string[]>;
|
|
44
53
|
export declare function caminhosSimbolicos(baseDiretorio: string, arquivo: string): string[];
|
|
45
54
|
export declare function registrarSimboloTypeScript(simbolos: Map<string, SimboloResolvido>, basesSimbolicas: string[], arquivo: string, nome: string, nomeClasse?: string, origem?: "ts" | "js"): void;
|
|
46
55
|
export declare function desembrulharExpressaoTypeScript(expr: ts.Expression): ts.Expression;
|
package/dist/drift.part04.js
CHANGED
|
@@ -1,11 +1,71 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.
|
|
2
|
-
// Descricao:
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.governanca_ia.drift
|
|
2
|
+
// Descricao: compartilha primitivas de indexacao e leitura do drift entre linguagens.
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
4
|
import { readdir } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import ts from "typescript";
|
|
6
7
|
import { diretoriosIgnoradosAtivos } from "./drift.part01.js";
|
|
7
8
|
import { escolherArquivoPorVinculo, escolherSimboloPorVinculo } from "./drift.part03.js";
|
|
8
9
|
import { avaliarPontuacaoSemantica, resolverPoliticaPontuacaoSemantica } from "./driftScore.js";
|
|
10
|
+
export function chaveCaminhoCanonicoDrift(caminho) {
|
|
11
|
+
const resolvido = path.resolve(caminho);
|
|
12
|
+
return process.platform === "win32" ? resolvido.toLowerCase() : resolvido;
|
|
13
|
+
}
|
|
14
|
+
function caminhoEstaDentroDaRaizDrift(raiz, candidato) {
|
|
15
|
+
const relativo = path.relative(path.resolve(raiz), path.resolve(candidato));
|
|
16
|
+
return relativo === "" || (!relativo.startsWith("..") && !path.isAbsolute(relativo));
|
|
17
|
+
}
|
|
18
|
+
const contextoRaizesSobrepostasDrift = new AsyncLocalStorage();
|
|
19
|
+
export function deduplicarRaizesSobrepostasDrift(diretorios) {
|
|
20
|
+
const unicas = new Map();
|
|
21
|
+
for (const diretorio of diretorios) {
|
|
22
|
+
const chave = chaveCaminhoCanonicoDrift(diretorio);
|
|
23
|
+
if (!unicas.has(chave)) {
|
|
24
|
+
unicas.set(chave, diretorio);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const candidatas = [...unicas.values()];
|
|
28
|
+
const raizesFisicas = candidatas.filter((candidata, indice) => !candidatas.some((outra, outroIndice) => indice !== outroIndice
|
|
29
|
+
&& chaveCaminhoCanonicoDrift(candidata) !== chaveCaminhoCanonicoDrift(outra)
|
|
30
|
+
&& caminhoEstaDentroDaRaizDrift(outra, candidata)));
|
|
31
|
+
const aliasesPorRaiz = new Map();
|
|
32
|
+
for (const raizFisica of raizesFisicas) {
|
|
33
|
+
aliasesPorRaiz.set(chaveCaminhoCanonicoDrift(raizFisica), candidatas.filter((candidata) => chaveCaminhoCanonicoDrift(candidata) !== chaveCaminhoCanonicoDrift(raizFisica)
|
|
34
|
+
&& caminhoEstaDentroDaRaizDrift(raizFisica, candidata)));
|
|
35
|
+
}
|
|
36
|
+
contextoRaizesSobrepostasDrift.enterWith(aliasesPorRaiz);
|
|
37
|
+
return raizesFisicas;
|
|
38
|
+
}
|
|
39
|
+
export function encontrarCandidatosFisicosImplementacaoDrift(simbolos, origem, caminhoDeclarado) {
|
|
40
|
+
const caminhoNormalizado = caminhoDeclarado.trim().toLowerCase();
|
|
41
|
+
if (!caminhoNormalizado) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const mesmaFamilia = (candidato) => candidato.origem === origem
|
|
45
|
+
|| ((origem === "ts" || origem === "js") && (candidato.origem === "ts" || candidato.origem === "js"));
|
|
46
|
+
const porArquivo = new Map();
|
|
47
|
+
for (const candidato of simbolos) {
|
|
48
|
+
const caminhoCandidato = candidato.caminho.toLowerCase();
|
|
49
|
+
if (!mesmaFamilia(candidato)
|
|
50
|
+
|| (caminhoCandidato !== caminhoNormalizado && !caminhoCandidato.endsWith(`.${caminhoNormalizado}`))) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const chaveArquivo = chaveCaminhoCanonicoDrift(candidato.arquivo);
|
|
54
|
+
const anterior = porArquivo.get(chaveArquivo);
|
|
55
|
+
const candidatoExato = caminhoCandidato === caminhoNormalizado;
|
|
56
|
+
const anteriorExato = anterior?.caminho.toLowerCase() === caminhoNormalizado;
|
|
57
|
+
if (!anterior
|
|
58
|
+
|| (candidatoExato && !anteriorExato)
|
|
59
|
+
|| (candidatoExato === anteriorExato
|
|
60
|
+
&& (candidato.caminho.length < anterior.caminho.length
|
|
61
|
+
|| (candidato.caminho.length === anterior.caminho.length
|
|
62
|
+
&& candidato.caminho.localeCompare(anterior.caminho, "pt-BR") < 0)))) {
|
|
63
|
+
porArquivo.set(chaveArquivo, candidato);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return [...porArquivo.values()].sort((a, b) => a.arquivo.localeCompare(b.arquivo, "pt-BR")
|
|
67
|
+
|| a.caminho.localeCompare(b.caminho, "pt-BR"));
|
|
68
|
+
}
|
|
9
69
|
export function resolverArquivoOuSimboloAncora(vinculos, simbolos, mapaImpl, arquivos) {
|
|
10
70
|
for (const vinculo of vinculos) {
|
|
11
71
|
if (vinculo.simbolo) {
|
|
@@ -258,9 +318,11 @@ export function juntarCaminhoHttp(base, sufixo) {
|
|
|
258
318
|
const caminho = `/${partes.join("/")}`.replace(/\/+/g, "/");
|
|
259
319
|
return caminho === "//" ? "/" : caminho;
|
|
260
320
|
}
|
|
261
|
-
export async function listarArquivosRecursivos(diretorio, extensoes,
|
|
262
|
-
if (
|
|
263
|
-
|
|
321
|
+
export async function listarArquivosRecursivos(diretorio, extensoes, adaptadorLeitura) {
|
|
322
|
+
if (adaptadorLeitura) {
|
|
323
|
+
const arquivos = await adaptadorLeitura.listarPorRaiz(diretorio, extensoes);
|
|
324
|
+
return [...new Map(arquivos.map((arquivo) => [chaveCaminhoCanonicoDrift(arquivo), arquivo])).values()]
|
|
325
|
+
.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
264
326
|
}
|
|
265
327
|
let entradas;
|
|
266
328
|
try {
|
|
@@ -294,16 +356,19 @@ export const EXTENSOES_ARQUIVOS_RASTREAVEIS_DRIFT = [
|
|
|
294
356
|
".yml", ".yaml", ".toml", ".xml", ".html", ".htm", ".css",
|
|
295
357
|
".Caddyfile", ".caddyfile",
|
|
296
358
|
];
|
|
297
|
-
export async function indexarArquivosRastreaveis(diretorios,
|
|
298
|
-
const arquivos = new
|
|
299
|
-
for (const diretorio of diretorios) {
|
|
300
|
-
for (const arquivo of await listarArquivosRecursivos(diretorio, EXTENSOES_ARQUIVOS_RASTREAVEIS_DRIFT,
|
|
301
|
-
|
|
359
|
+
export async function indexarArquivosRastreaveis(diretorios, adaptadorLeitura) {
|
|
360
|
+
const arquivos = new Map();
|
|
361
|
+
for (const diretorio of deduplicarRaizesSobrepostasDrift(diretorios)) {
|
|
362
|
+
for (const arquivo of await listarArquivosRecursivos(diretorio, EXTENSOES_ARQUIVOS_RASTREAVEIS_DRIFT, adaptadorLeitura)) {
|
|
363
|
+
const chave = chaveCaminhoCanonicoDrift(arquivo);
|
|
364
|
+
if (!arquivos.has(chave)) {
|
|
365
|
+
arquivos.set(chave, arquivo);
|
|
366
|
+
}
|
|
302
367
|
}
|
|
303
368
|
}
|
|
304
|
-
return [...arquivos].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
369
|
+
return [...arquivos.values()].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
305
370
|
}
|
|
306
|
-
|
|
371
|
+
function caminhosSimbolicosParaBaseDrift(baseDiretorio, arquivo) {
|
|
307
372
|
const relativo = path.relative(baseDiretorio, arquivo).replace(/\.[^.]+$/, "");
|
|
308
373
|
const semPrefixo = relativo
|
|
309
374
|
.split(path.sep)
|
|
@@ -312,13 +377,19 @@ export function caminhosSimbolicos(baseDiretorio, arquivo) {
|
|
|
312
377
|
.join(".");
|
|
313
378
|
const prefixo = paraIdentificadorModulo(path.basename(baseDiretorio));
|
|
314
379
|
const comPrefixo = prefixo ? [prefixo, semPrefixo].filter(Boolean).join(".") : semPrefixo;
|
|
380
|
+
const aliasesBase = [semPrefixo, comPrefixo].filter(Boolean);
|
|
315
381
|
const aliasesIndex = path.basename(relativo) === "index"
|
|
316
|
-
?
|
|
317
|
-
semPrefixo.replace(/(?:^|\.)index$/, ""),
|
|
318
|
-
comPrefixo.replace(/(?:^|\.)index$/, ""),
|
|
319
|
-
]
|
|
382
|
+
? aliasesBase.map((alias) => alias.replace(/(?:^|\.)index$/, ""))
|
|
320
383
|
: [];
|
|
321
|
-
return [...new Set([
|
|
384
|
+
return [...new Set([...aliasesBase, ...aliasesIndex].filter(Boolean))];
|
|
385
|
+
}
|
|
386
|
+
export function caminhosSimbolicos(baseDiretorio, arquivo) {
|
|
387
|
+
const aliasesConfigurados = contextoRaizesSobrepostasDrift.getStore()
|
|
388
|
+
?.get(chaveCaminhoCanonicoDrift(baseDiretorio))
|
|
389
|
+
?.filter((raiz) => caminhoEstaDentroDaRaizDrift(raiz, arquivo))
|
|
390
|
+
?? [];
|
|
391
|
+
return [...new Set([baseDiretorio, ...aliasesConfigurados]
|
|
392
|
+
.flatMap((base) => caminhosSimbolicosParaBaseDrift(base, arquivo)))];
|
|
322
393
|
}
|
|
323
394
|
export function registrarSimboloTypeScript(simbolos, basesSimbolicas, arquivo, nome, nomeClasse, origem = "ts") {
|
|
324
395
|
for (const baseSimbolica of basesSimbolicas) {
|
package/dist/drift.part05.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { RegistroConsumerSurfaceDrift, SimboloResolvido } from "./drift.part01.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type AdaptadorLeituraCompartilhadaDrift } from "./drift.part04.js";
|
|
4
4
|
export declare function registrarMetodoTypeScriptProtoOuObjeto(simbolos: Map<string, SimboloResolvido>, basesSimbolicas: string[], arquivo: string, nomeMetodo: string, nomeClasse?: string, origem?: "ts" | "js"): void;
|
|
5
5
|
export declare function registrarMetodosObjectAssignTypeScript(simbolos: Map<string, SimboloResolvido>, basesSimbolicas: string[], arquivo: string, objeto: ts.ObjectLiteralExpression, sourceFile: ts.SourceFile, nomeClasse?: string, origem?: "ts" | "js"): void;
|
|
6
6
|
export declare function registrarAtribuicaoPrototypeTypeScript(simbolos: Map<string, SimboloResolvido>, basesSimbolicas: string[], arquivo: string, sourceFile: ts.SourceFile, esquerda: ts.Expression, direita: ts.Expression, origem?: "ts" | "js"): void;
|
|
@@ -44,5 +44,5 @@ export declare function extrairRotasReactViteConsumer(relacaoArquivo: string, co
|
|
|
44
44
|
export declare function normalizarRotaDeclaradaFlutter(caminhoCru: string): string;
|
|
45
45
|
export declare function extrairRotasFlutterConsumer(relacaoArquivo: string, codigo: string): RotaFlutterConsumerDrift[];
|
|
46
46
|
export declare function extrairRotasAngularConsumerDiretas(relacaoArquivo: string, codigo: string, prefixo?: string): RotaAngularConsumerDrift[];
|
|
47
|
-
export declare function extrairRotasAngularConsumer(diretorioBase: string, relacaoArquivo: string, prefixo?: string, visitados?: Set<string>,
|
|
47
|
+
export declare function extrairRotasAngularConsumer(diretorioBase: string, relacaoArquivo: string, prefixo?: string, visitados?: Set<string>, adaptadorLeitura?: AdaptadorLeituraCompartilhadaDrift): Promise<RotaAngularConsumerDrift[]>;
|
|
48
48
|
export declare function simboloEhBridgeConsumer(caminho: string, arquivo: string): boolean;
|
package/dist/drift.part05.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// SEMA-GOVERNED: sema.
|
|
2
|
-
// Descricao:
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.governanca_ia.drift
|
|
2
|
+
// Descricao: extrai rotas e superficies consumidoras dentro do escopo fisico planejado.
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import ts from "typescript";
|
|
6
|
-
import { desembrulharExpressaoTypeScript, extrairNomePropriedadeTypeScript, registrarSimboloTypeScript } from "./drift.part04.js";
|
|
6
|
+
import { desembrulharExpressaoTypeScript, extrairNomePropriedadeTypeScript, registrarSimboloTypeScript, } from "./drift.part04.js";
|
|
7
7
|
export function registrarMetodoTypeScriptProtoOuObjeto(simbolos, basesSimbolicas, arquivo, nomeMetodo, nomeClasse, origem = "ts") {
|
|
8
8
|
if (!nomeMetodo) {
|
|
9
9
|
return;
|
|
@@ -318,7 +318,7 @@ export function extrairRotasAngularConsumerDiretas(relacaoArquivo, codigo, prefi
|
|
|
318
318
|
}
|
|
319
319
|
return rotas;
|
|
320
320
|
}
|
|
321
|
-
export async function extrairRotasAngularConsumer(diretorioBase, relacaoArquivo, prefixo = "/", visitados = new Set(),
|
|
321
|
+
export async function extrairRotasAngularConsumer(diretorioBase, relacaoArquivo, prefixo = "/", visitados = new Set(), adaptadorLeitura) {
|
|
322
322
|
const relacaoNormalizada = normalizarRelacaoConsumer(relacaoArquivo);
|
|
323
323
|
if (visitados.has(relacaoNormalizada)) {
|
|
324
324
|
return [];
|
|
@@ -327,7 +327,9 @@ export async function extrairRotasAngularConsumer(diretorioBase, relacaoArquivo,
|
|
|
327
327
|
let codigo = "";
|
|
328
328
|
try {
|
|
329
329
|
const arquivo = path.join(diretorioBase, relacaoNormalizada);
|
|
330
|
-
codigo =
|
|
330
|
+
codigo = adaptadorLeitura
|
|
331
|
+
? await adaptadorLeitura.lerTexto(arquivo)
|
|
332
|
+
: await readFile(arquivo, "utf8");
|
|
331
333
|
}
|
|
332
334
|
catch {
|
|
333
335
|
return [];
|
|
@@ -338,7 +340,7 @@ export async function extrairRotasAngularConsumer(diretorioBase, relacaoArquivo,
|
|
|
338
340
|
if (!rota.arquivoRotasFilhas) {
|
|
339
341
|
continue;
|
|
340
342
|
}
|
|
341
|
-
filhas.push(...await extrairRotasAngularConsumer(diretorioBase, rota.arquivoRotasFilhas, rota.rota, visitados,
|
|
343
|
+
filhas.push(...await extrairRotasAngularConsumer(diretorioBase, rota.arquivoRotasFilhas, rota.rota, visitados, adaptadorLeitura));
|
|
342
344
|
}
|
|
343
345
|
return [...rotas, ...filhas];
|
|
344
346
|
}
|
package/dist/drift.part06.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { FonteLegado } from "./tipos.js";
|
|
2
2
|
import { ConsumerFramework, RecursoResolvido, RegistroConsumerBridgeDrift, RegistroConsumerSurfaceDrift, RotaResolvida, SimboloResolvido } from "./drift.part01.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type AdaptadorLeituraCompartilhadaDrift } from "./drift.part04.js";
|
|
4
4
|
export declare function inferirConsumerFrameworkPrincipal(fontesLegado: FonteLegado[], consumerSurfaces: RegistroConsumerSurfaceDrift[], consumerBridges: RegistroConsumerBridgeDrift[]): ConsumerFramework | null;
|
|
5
5
|
export declare function extrairColecoesFirebase(arquivo: string, codigo: string): RecursoResolvido[];
|
|
6
|
-
export declare function indexarTypeScript(diretorios: string[],
|
|
6
|
+
export declare function indexarTypeScript(diretorios: string[], adaptadorLeitura?: AdaptadorLeituraCompartilhadaDrift): Promise<{
|
|
7
7
|
simbolos: SimboloResolvido[];
|
|
8
8
|
rotas: RotaResolvida[];
|
|
9
9
|
recursos: RecursoResolvido[];
|