@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
package/dist/drift.part12.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// SEMA-GOVERNED: sema.governanca_ia_contexto
|
|
2
2
|
// Descricao: CLI particionada; consulte contratos/sema/governanca_ia_contexto.sema antes de editar.
|
|
3
|
-
import {
|
|
3
|
+
import { lstat, open, readdir, realpath } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
import { definirDiretoriosIgnoradosAtivos, obterDiretoriosIgnoradosAtivos, normalizarFragmentoArquivo, quebrarTermosEscopo,
|
|
5
|
+
import { paraIdentificadorModulo } from "./drift.part04.js";
|
|
6
|
+
import { definirDiretoriosIgnoradosAtivos, obterDiretoriosIgnoradosAtivos, normalizarFragmentoArquivo, quebrarTermosEscopo, resolverDiretoriosIgnoradosAtivos, resolverOpcoesDrift } from "./drift.part01.js";
|
|
7
7
|
import { filtrarCaminhosEscopoReal, resolverDiretoriosCodigoEscopoReal, textoCombinaEscopo } from "./drift.part02.js";
|
|
8
8
|
import { analisarDriftLegado } from "./drift.part11.js";
|
|
9
|
-
import { planejarEscopoDrift } from "./driftEscopo.js";
|
|
10
9
|
export const EXTENSOES_BUSCA_IMPACTO = [
|
|
11
10
|
".sema",
|
|
12
11
|
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs",
|
|
@@ -98,23 +97,164 @@ export function registrarArquivoImpactado(mapa, arquivo, linhas, motivos) {
|
|
|
98
97
|
motivos: [...new Set(motivos)],
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
|
-
|
|
100
|
+
function chaveCaminhoImpacto(caminho) {
|
|
101
|
+
const absoluto = path.normalize(path.resolve(caminho));
|
|
102
|
+
return process.platform === "win32" ? absoluto.toLowerCase() : absoluto;
|
|
103
|
+
}
|
|
104
|
+
function caminhoImpactoEstaDentro(raiz, alvo) {
|
|
105
|
+
const relativo = path.relative(path.resolve(raiz), path.resolve(alvo));
|
|
106
|
+
return relativo === "" || (relativo !== ".."
|
|
107
|
+
&& !relativo.startsWith(`..${path.sep}`)
|
|
108
|
+
&& !path.isAbsolute(relativo));
|
|
109
|
+
}
|
|
110
|
+
function identidadeArquivoImpactoEstavel(a, b) {
|
|
111
|
+
return a.isFile()
|
|
112
|
+
&& b.isFile()
|
|
113
|
+
&& !a.isSymbolicLink()
|
|
114
|
+
&& !b.isSymbolicLink()
|
|
115
|
+
&& a.dev === b.dev
|
|
116
|
+
&& a.ino === b.ino
|
|
117
|
+
&& a.size === b.size
|
|
118
|
+
&& a.mtimeNs === b.mtimeNs
|
|
119
|
+
&& a.ctimeNs === b.ctimeNs;
|
|
120
|
+
}
|
|
121
|
+
function identidadeDiretorioImpactoEstavel(a, b) {
|
|
122
|
+
return a.isDirectory()
|
|
123
|
+
&& b.isDirectory()
|
|
124
|
+
&& !a.isSymbolicLink()
|
|
125
|
+
&& !b.isSymbolicLink()
|
|
126
|
+
&& a.dev === b.dev
|
|
127
|
+
&& a.ino === b.ino
|
|
128
|
+
&& a.mtimeNs === b.mtimeNs
|
|
129
|
+
&& a.ctimeNs === b.ctimeNs;
|
|
130
|
+
}
|
|
131
|
+
function erroImpactoConfinamento(codigo) {
|
|
132
|
+
return new Error(`impacto_confinamento:${codigo}`);
|
|
133
|
+
}
|
|
134
|
+
async function lerArquivoImpactoConfinado(baseProjeto, baseProjetoReal, arquivo) {
|
|
135
|
+
const absoluto = path.resolve(arquivo);
|
|
136
|
+
if (!caminhoImpactoEstaDentro(baseProjeto, absoluto)) {
|
|
137
|
+
throw erroImpactoConfinamento("fora_workspace");
|
|
138
|
+
}
|
|
139
|
+
const informacaoAntes = await lstat(absoluto, { bigint: true });
|
|
140
|
+
if (!informacaoAntes.isFile() || informacaoAntes.isSymbolicLink()) {
|
|
141
|
+
throw erroImpactoConfinamento("arquivo_irregular");
|
|
142
|
+
}
|
|
143
|
+
const caminhoRealAntes = await realpath(absoluto);
|
|
144
|
+
if (!caminhoImpactoEstaDentro(baseProjetoReal, caminhoRealAntes)) {
|
|
145
|
+
throw erroImpactoConfinamento("fora_workspace_real");
|
|
146
|
+
}
|
|
147
|
+
const handle = await open(absoluto, "r");
|
|
148
|
+
try {
|
|
149
|
+
const informacaoHandleAntes = await handle.stat({ bigint: true });
|
|
150
|
+
const [informacaoCaminhoAberto, caminhoRealAberto] = await Promise.all([
|
|
151
|
+
lstat(absoluto, { bigint: true }),
|
|
152
|
+
realpath(absoluto),
|
|
153
|
+
]);
|
|
154
|
+
if (!caminhoImpactoEstaDentro(baseProjetoReal, caminhoRealAberto)
|
|
155
|
+
|| !identidadeArquivoImpactoEstavel(informacaoAntes, informacaoHandleAntes)
|
|
156
|
+
|| !identidadeArquivoImpactoEstavel(informacaoHandleAntes, informacaoCaminhoAberto)) {
|
|
157
|
+
throw erroImpactoConfinamento("arquivo_alterado_antes_leitura");
|
|
158
|
+
}
|
|
159
|
+
const conteudo = await handle.readFile();
|
|
160
|
+
const [informacaoHandleDepois, informacaoCaminhoDepois, caminhoRealDepois] = await Promise.all([
|
|
161
|
+
handle.stat({ bigint: true }),
|
|
162
|
+
lstat(absoluto, { bigint: true }),
|
|
163
|
+
realpath(absoluto),
|
|
164
|
+
]);
|
|
165
|
+
if (!caminhoImpactoEstaDentro(baseProjetoReal, caminhoRealDepois)
|
|
166
|
+
|| !identidadeArquivoImpactoEstavel(informacaoHandleAntes, informacaoHandleDepois)
|
|
167
|
+
|| !identidadeArquivoImpactoEstavel(informacaoHandleDepois, informacaoCaminhoDepois)) {
|
|
168
|
+
throw erroImpactoConfinamento("arquivo_alterado_durante_leitura");
|
|
169
|
+
}
|
|
170
|
+
return conteudo.toString("utf8");
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
await handle.close().catch(() => undefined);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function listarDiretorioImpactoConfinado(diretorio, baseProjeto, baseProjetoReal, visitados) {
|
|
177
|
+
const absoluto = path.resolve(diretorio);
|
|
178
|
+
if (!caminhoImpactoEstaDentro(baseProjeto, absoluto)) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
let informacaoAntes;
|
|
182
|
+
try {
|
|
183
|
+
informacaoAntes = await lstat(absoluto, { bigint: true });
|
|
184
|
+
}
|
|
185
|
+
catch (erro) {
|
|
186
|
+
if (["ENOENT", "ENOTDIR"].includes(erro.code ?? "")) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
throw erro;
|
|
190
|
+
}
|
|
191
|
+
if (!informacaoAntes.isDirectory() || informacaoAntes.isSymbolicLink()) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
const caminhoRealAntes = await realpath(absoluto);
|
|
195
|
+
if (!caminhoImpactoEstaDentro(baseProjetoReal, caminhoRealAntes)) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const chaveReal = chaveCaminhoImpacto(caminhoRealAntes);
|
|
199
|
+
if (visitados.has(chaveReal)) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
visitados.add(chaveReal);
|
|
203
|
+
const entradas = await readdir(absoluto, { withFileTypes: true, encoding: "utf8" });
|
|
204
|
+
const [informacaoDepois, caminhoRealDepois] = await Promise.all([
|
|
205
|
+
lstat(absoluto, { bigint: true }),
|
|
206
|
+
realpath(absoluto),
|
|
207
|
+
]);
|
|
208
|
+
if (!caminhoImpactoEstaDentro(baseProjetoReal, caminhoRealDepois)
|
|
209
|
+
|| !identidadeDiretorioImpactoEstavel(informacaoAntes, informacaoDepois)) {
|
|
210
|
+
throw erroImpactoConfinamento("diretorio_alterado_durante_listagem");
|
|
211
|
+
}
|
|
212
|
+
const ignorados = obterDiretoriosIgnoradosAtivos();
|
|
213
|
+
const encontrados = [];
|
|
214
|
+
for (const entrada of entradas) {
|
|
215
|
+
if (ignorados.has(entrada.name.toLowerCase()) || entrada.isSymbolicLink()) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const caminhoAtual = path.join(absoluto, entrada.name);
|
|
219
|
+
if (entrada.isDirectory()) {
|
|
220
|
+
encontrados.push(...await listarDiretorioImpactoConfinado(caminhoAtual, baseProjeto, baseProjetoReal, visitados));
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (entrada.isFile() && EXTENSOES_BUSCA_IMPACTO.some((extensao) => entrada.name.toLowerCase().endsWith(extensao))) {
|
|
224
|
+
encontrados.push(caminhoAtual);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return encontrados;
|
|
228
|
+
}
|
|
229
|
+
export async function listarArquivosImpacto(contexto, opcoes, arquivosPlanejados = []) {
|
|
102
230
|
const opcoesResolvidas = resolverOpcoesDrift(opcoes);
|
|
103
|
-
const
|
|
231
|
+
const baseProjeto = path.resolve(contexto.baseProjeto);
|
|
232
|
+
const contratos = opcoesResolvidas.escopo === "projeto"
|
|
233
|
+
? contexto.arquivosProjeto
|
|
234
|
+
: contexto.modulosSelecionados.map((modulo) => modulo.caminho);
|
|
235
|
+
const arquivos = new Set();
|
|
236
|
+
for (const arquivo of filtrarCaminhosEscopoReal(contratos, contexto, opcoesResolvidas)) {
|
|
237
|
+
const absoluto = path.resolve(arquivo);
|
|
238
|
+
if (caminhoImpactoEstaDentro(baseProjeto, absoluto)) {
|
|
239
|
+
arquivos.add(absoluto);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
104
242
|
if (opcoesResolvidas.escopo !== "projeto") {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
243
|
+
for (const arquivo of arquivosPlanejados) {
|
|
244
|
+
if (arquivo.startsWith("[fora_do_workspace]/")) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const absoluto = path.resolve(baseProjeto, arquivo);
|
|
248
|
+
if (caminhoImpactoEstaDentro(baseProjeto, absoluto)) {
|
|
249
|
+
arquivos.add(absoluto);
|
|
250
|
+
}
|
|
113
251
|
}
|
|
114
252
|
return [...arquivos].sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
115
253
|
}
|
|
254
|
+
const baseProjetoReal = await realpath(baseProjeto);
|
|
255
|
+
const visitados = new Set();
|
|
116
256
|
for (const diretorio of resolverDiretoriosCodigoEscopoReal(contexto, opcoesResolvidas)) {
|
|
117
|
-
for (const arquivo of await
|
|
257
|
+
for (const arquivo of await listarDiretorioImpactoConfinado(diretorio, baseProjeto, baseProjetoReal, visitados)) {
|
|
118
258
|
arquivos.add(arquivo);
|
|
119
259
|
}
|
|
120
260
|
}
|
|
@@ -175,9 +315,11 @@ export async function gerarMapaImpactoSemantico(contexto, alvoSemantico, mudanca
|
|
|
175
315
|
const variantes = construirVariantesSemanticas(alvoSemantico);
|
|
176
316
|
const termos = [...new Set([...quebrarTermosEscopo(alvoSemantico), ...drift.escopo_aplicado.termosEscopo])];
|
|
177
317
|
const arquivosImpactados = new Map();
|
|
178
|
-
const arquivosBusca = await listarArquivosImpacto(contexto, opcoesResolvidas);
|
|
318
|
+
const arquivosBusca = await listarArquivosImpacto(contexto, opcoesResolvidas, drift.escopo_aplicado.arquivosPlanejados);
|
|
319
|
+
const arquivosBuscaPorChave = new Set(arquivosBusca.map(chaveCaminhoImpacto));
|
|
320
|
+
const baseProjetoReal = await realpath(path.resolve(contexto.baseProjeto));
|
|
179
321
|
for (const arquivo of arquivosBusca) {
|
|
180
|
-
const codigo = await
|
|
322
|
+
const codigo = await lerArquivoImpactoConfinado(contexto.baseProjeto, baseProjetoReal, arquivo);
|
|
181
323
|
const linhas = extrairLinhasComVariantes(codigo, variantes);
|
|
182
324
|
if (linhas.length > 0) {
|
|
183
325
|
registrarArquivoImpactado(arquivosImpactados, arquivo, linhas, ["token_semantico_encontrado"]);
|
|
@@ -210,21 +352,29 @@ export async function gerarMapaImpactoSemantico(contexto, alvoSemantico, mudanca
|
|
|
210
352
|
}
|
|
211
353
|
for (const task of drift.tasks.filter((item) => tasksAfetadas.has(`${item.modulo}.${item.task}`))) {
|
|
212
354
|
for (const arquivo of task.arquivosProvaveisEditar) {
|
|
213
|
-
|
|
355
|
+
if (arquivosBuscaPorChave.has(chaveCaminhoImpacto(arquivo))) {
|
|
356
|
+
registrarArquivoImpactado(arquivosImpactados, arquivo, [], ["arquivo_relacionado_por_drift"]);
|
|
357
|
+
}
|
|
214
358
|
}
|
|
215
359
|
}
|
|
216
360
|
for (const item of drift.persistencia_real) {
|
|
217
361
|
if (textoIrCombinaTermos(`${item.alvo} ${item.task} ${item.colunas.join(" ")}`, termos)) {
|
|
218
362
|
persistenciaAfetada.add(`${item.task}:${item.alvo}`);
|
|
219
363
|
for (const arquivo of [...item.arquivos, ...item.repositorios]) {
|
|
220
|
-
|
|
364
|
+
if (arquivosBuscaPorChave.has(chaveCaminhoImpacto(arquivo))) {
|
|
365
|
+
registrarArquivoImpactado(arquivosImpactados, arquivo, [], ["persistencia_relacionada"]);
|
|
366
|
+
}
|
|
221
367
|
}
|
|
222
368
|
}
|
|
223
369
|
}
|
|
224
370
|
const contratosAfetados = ordenarArquivosImpacto([...arquivosImpactados.values()].filter((arquivo) => arquivo.tipo === "contrato")).map((arquivo) => arquivo.arquivo);
|
|
371
|
+
const driftPermiteImpacto = (drift.escopo_aplicado.bloqueios?.length ?? 0) === 0
|
|
372
|
+
&& drift.escopo_aplicado.cobertura !== "parcial"
|
|
373
|
+
&& drift.vinculos_quebrados.length === 0;
|
|
225
374
|
return {
|
|
226
375
|
comando: "impacto",
|
|
227
|
-
sucesso:
|
|
376
|
+
sucesso: driftPermiteImpacto
|
|
377
|
+
&& (arquivosImpactados.size > 0 || tasksAfetadas.size > 0 || persistenciaAfetada.size > 0),
|
|
228
378
|
escopo: drift.escopo_aplicado.escopo,
|
|
229
379
|
alvoSemantico,
|
|
230
380
|
mudancaProposta,
|
|
@@ -253,6 +403,27 @@ export async function gerarMapaImpactoSemantico(contexto, alvoSemantico, mudanca
|
|
|
253
403
|
}
|
|
254
404
|
export async function assistirRenomeacaoSemantica(contexto, nomeAtual, nomeNovo, opcoes) {
|
|
255
405
|
const impacto = await gerarMapaImpactoSemantico(contexto, nomeAtual, `renomear ${nomeAtual} para ${nomeNovo}`, opcoes);
|
|
406
|
+
if (!impacto.sucesso) {
|
|
407
|
+
return {
|
|
408
|
+
comando: "renomear-semantico",
|
|
409
|
+
sucesso: false,
|
|
410
|
+
escopo: impacto.escopo,
|
|
411
|
+
de: nomeAtual,
|
|
412
|
+
para: nomeNovo,
|
|
413
|
+
arquivos: impacto.arquivos,
|
|
414
|
+
sugestoes: [],
|
|
415
|
+
ordemOperacional: [
|
|
416
|
+
"Renomear primeiro no contrato .sema e nos campos publicos derivados.",
|
|
417
|
+
"Ajustar repositorios, payloads e bridges que materializam o nome antigo.",
|
|
418
|
+
"Rodar sema drift e revisar sugestoes restantes antes de fechar a troca.",
|
|
419
|
+
],
|
|
420
|
+
validacoes: [
|
|
421
|
+
"Rodar sema validar no contrato renomeado.",
|
|
422
|
+
"Rodar sema drift para confirmar que payload e superficie nao ficaram misturados.",
|
|
423
|
+
"Reexecutar testes e checar snapshots ou fixtures afetados.",
|
|
424
|
+
],
|
|
425
|
+
};
|
|
426
|
+
}
|
|
256
427
|
const variantesAntigas = construirVariantesSemanticas(nomeAtual);
|
|
257
428
|
const variantesNovas = construirVariantesSemanticas(nomeNovo);
|
|
258
429
|
const mapaSubstituicao = new Map();
|
|
@@ -260,8 +431,9 @@ export async function assistirRenomeacaoSemantica(contexto, nomeAtual, nomeNovo,
|
|
|
260
431
|
mapaSubstituicao.set(antiga, variantesNovas[indice] ?? nomeNovo);
|
|
261
432
|
});
|
|
262
433
|
const sugestoes = [];
|
|
434
|
+
const baseProjetoReal = await realpath(path.resolve(contexto.baseProjeto));
|
|
263
435
|
for (const arquivo of impacto.arquivos) {
|
|
264
|
-
const codigo = await
|
|
436
|
+
const codigo = await lerArquivoImpactoConfinado(contexto.baseProjeto, baseProjetoReal, arquivo.arquivo);
|
|
265
437
|
const linhas = codigo.split(/\r?\n/);
|
|
266
438
|
for (let indice = 0; indice < linhas.length; indice += 1) {
|
|
267
439
|
const linha = linhas[indice];
|
package/dist/drift.part13.d.ts
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
1
|
import type { ContextoProjetoCarregado } from "./projeto.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ConfiguracaoEscopoDriftAplicada, type EstadoCacheDriftAplicado, type RecursoResolvido, type RotaResolvida, type SimboloResolvido } from "./drift.part01.js";
|
|
3
3
|
import { indexarTypeScript } from "./drift.part06.js";
|
|
4
4
|
import { indexarDart } from "./drift.part07.js";
|
|
5
5
|
import { indexarPersistenciaDetalhada } from "./drift.part08.js";
|
|
6
|
-
import { type
|
|
7
|
-
import { type CatalogoDrift, type MetricasCatalogoDrift, type ObservadorOperacaoDrift } from "./driftCatalogo.js";
|
|
8
|
-
import { type PoliticaCacheDrift } from "./driftCache.js";
|
|
9
|
-
import { type MetricasCacheIncrementalDrift } from "./driftCacheIncremental.js";
|
|
6
|
+
import { type MetricasCatalogoDrift, type ObservadorOperacaoDrift } from "./driftCatalogo.js";
|
|
10
7
|
import { type PlanoEscopoDrift } from "./driftEscopo.js";
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
arquivosOrcamentoAvaliados: string[];
|
|
16
|
-
detalhesPersistencia: DetalhesPersistenciaDrift;
|
|
17
|
-
diagnosticosOrcamento: DiagnosticoOrcamentoArquivo[];
|
|
18
|
-
indexDart: IndiceDartDrift;
|
|
19
|
-
indexTs: IndiceTypeScriptDrift;
|
|
20
|
-
todasRotasIndexadas: RotaResolvida[];
|
|
21
|
-
todosArquivosConhecidos: string[];
|
|
22
|
-
todosRecursos: RecursoResolvido[];
|
|
23
|
-
todosSimbolos: SimboloResolvido[];
|
|
8
|
+
import type { AvisoModoCacheDrift, ModoCacheDrift } from "./driftCacheModes.js";
|
|
9
|
+
export interface LeitorArquivosPlanejadosDrift {
|
|
10
|
+
contem(caminho: string): boolean;
|
|
11
|
+
lerTexto(caminho: string): Promise<string>;
|
|
24
12
|
}
|
|
25
|
-
export interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
incremental?: MetricasCacheIncrementalDrift;
|
|
30
|
-
fasesMs?: {
|
|
31
|
-
planejamento: number;
|
|
32
|
-
catalogacao: number;
|
|
33
|
-
dependencias: number;
|
|
34
|
-
assinaturas: number;
|
|
35
|
-
indexacao: number;
|
|
36
|
-
total: number;
|
|
37
|
-
};
|
|
13
|
+
export interface OpcoesPrepararIndicesDrift {
|
|
14
|
+
observador?: ObservadorOperacaoDrift;
|
|
15
|
+
modoCache?: ModoCacheDrift;
|
|
16
|
+
avisosModoCache?: readonly AvisoModoCacheDrift[];
|
|
38
17
|
}
|
|
39
|
-
export interface IndicesDriftPreparados
|
|
18
|
+
export interface IndicesDriftPreparados {
|
|
19
|
+
detalhesPersistencia: Awaited<ReturnType<typeof indexarPersistenciaDetalhada>>;
|
|
20
|
+
indexDart: Awaited<ReturnType<typeof indexarDart>>;
|
|
21
|
+
indexTs: Awaited<ReturnType<typeof indexarTypeScript>>;
|
|
40
22
|
mapaImpl: Map<string, SimboloResolvido>;
|
|
41
23
|
mapaRecursos: Map<string, RecursoResolvido[]>;
|
|
24
|
+
todasRotasIndexadas: RotaResolvida[];
|
|
25
|
+
todosArquivosConhecidos: string[];
|
|
26
|
+
todosRecursos: RecursoResolvido[];
|
|
27
|
+
todosSimbolos: SimboloResolvido[];
|
|
42
28
|
planoEscopo: PlanoEscopoDrift;
|
|
43
|
-
cache:
|
|
29
|
+
cache: EstadoCacheDriftAplicado;
|
|
44
30
|
catalogo: MetricasCatalogoDrift;
|
|
45
|
-
leitorArquivosPlanejados
|
|
46
|
-
}
|
|
47
|
-
export interface OpcoesPrepararIndicesDrift {
|
|
48
|
-
politicaCache?: PoliticaCacheDrift;
|
|
49
|
-
observador?: ObservadorOperacaoDrift;
|
|
31
|
+
leitorArquivosPlanejados: LeitorArquivosPlanejadosDrift;
|
|
50
32
|
}
|
|
51
33
|
export declare function prepararIndicesDrift(contexto: ContextoProjetoCarregado, configuracaoEscopo: ConfiguracaoEscopoDriftAplicada, opcoes?: OpcoesPrepararIndicesDrift): Promise<IndicesDriftPreparados>;
|
|
52
|
-
export {};
|