@semacode/cli 3.8.1 → 3.8.3
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 +119 -119
- package/dist/driftEscopo.js +35 -0
- package/dist/iaPrompts.js +11 -11
- package/dist/index.part02.js +21 -21
- package/dist/index.part07.js +24 -24
- package/dist/initCommand.js +1 -1
- package/dist/initTemplatesBase.js +84 -84
- package/docs/README.md +15 -15
- package/docs/ai-onboarding.md +81 -81
- package/docs/cli.md +197 -197
- package/docs/deploy.md +54 -54
- package/docs/documentation.md +11 -11
- package/docs/drift-cache.md +108 -108
- package/docs/getting-started.md +82 -82
- package/docs/repositories.md +60 -60
- package/docs/rollback.md +38 -38
- package/docs/security.md +54 -54
- package/docs/sistemas-interativos.md +27 -27
- package/docs/support.md +8 -8
- package/docs/testing.md +123 -123
- package/docs/vocabulary.md +29 -29
- package/exemplos/express_crud.sema +139 -139
- package/exemplos/fastify_crud.sema +146 -146
- package/exemplos/koa_crud.sema +95 -95
- package/package.json +4 -4
- package/scripts/postinstall.mjs +148 -148
- package/skills/sema/SKILL.md +199 -199
package/exemplos/koa_crud.sema
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
module exemplos.koa.crud {
|
|
2
|
-
entity Tarefa {
|
|
3
|
-
fields {
|
|
4
|
-
id: Id
|
|
5
|
-
titulo: Texto
|
|
6
|
-
concluida: Booleano
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
task criar_tarefa {
|
|
11
|
-
input {
|
|
12
|
-
titulo: Texto required
|
|
13
|
-
}
|
|
14
|
-
output {
|
|
15
|
-
tarefa: Tarefa
|
|
16
|
-
}
|
|
17
|
-
rules {
|
|
18
|
-
titulo deve_ser preenchido
|
|
19
|
-
}
|
|
20
|
-
effects {
|
|
21
|
-
persistencia Tarefa
|
|
22
|
-
auditoria tarefa_criada
|
|
23
|
-
}
|
|
24
|
-
guarantees {
|
|
25
|
-
tarefa existe
|
|
26
|
-
}
|
|
27
|
-
tests {
|
|
28
|
-
caso "cria tarefa" {
|
|
29
|
-
given {
|
|
30
|
-
titulo: "Revisar contrato"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
expect {
|
|
34
|
-
sucesso: verdadeiro
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
task concluir_tarefa {
|
|
41
|
-
input {
|
|
42
|
-
id: Id required
|
|
43
|
-
}
|
|
44
|
-
output {
|
|
45
|
-
tarefa: Tarefa
|
|
46
|
-
}
|
|
47
|
-
rules {
|
|
48
|
-
id deve_ser valido
|
|
49
|
-
}
|
|
50
|
-
effects {
|
|
51
|
-
persistencia Tarefa
|
|
52
|
-
auditoria tarefa_concluida
|
|
53
|
-
}
|
|
54
|
-
guarantees {
|
|
55
|
-
tarefa existe
|
|
56
|
-
}
|
|
57
|
-
tests {
|
|
58
|
-
caso "conclui tarefa por id" {
|
|
59
|
-
given {
|
|
60
|
-
id: "tar_1"
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
expect {
|
|
64
|
-
sucesso: verdadeiro
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
route tarefas_criar {
|
|
71
|
-
metodo: POST
|
|
72
|
-
caminho: /api/tarefas
|
|
73
|
-
task: criar_tarefa
|
|
74
|
-
finalidade: cadastro_tarefa
|
|
75
|
-
input {
|
|
76
|
-
titulo: Texto
|
|
77
|
-
}
|
|
78
|
-
output {
|
|
79
|
-
tarefa: Tarefa
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
route tarefas_concluir {
|
|
84
|
-
metodo: PATCH
|
|
85
|
-
caminho: "/api/tarefas/{id}"
|
|
86
|
-
task: concluir_tarefa
|
|
87
|
-
finalidade: alteracao_tarefa
|
|
88
|
-
input {
|
|
89
|
-
id: Id
|
|
90
|
-
}
|
|
91
|
-
output {
|
|
92
|
-
tarefa: Tarefa
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
module exemplos.koa.crud {
|
|
2
|
+
entity Tarefa {
|
|
3
|
+
fields {
|
|
4
|
+
id: Id
|
|
5
|
+
titulo: Texto
|
|
6
|
+
concluida: Booleano
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
task criar_tarefa {
|
|
11
|
+
input {
|
|
12
|
+
titulo: Texto required
|
|
13
|
+
}
|
|
14
|
+
output {
|
|
15
|
+
tarefa: Tarefa
|
|
16
|
+
}
|
|
17
|
+
rules {
|
|
18
|
+
titulo deve_ser preenchido
|
|
19
|
+
}
|
|
20
|
+
effects {
|
|
21
|
+
persistencia Tarefa
|
|
22
|
+
auditoria tarefa_criada
|
|
23
|
+
}
|
|
24
|
+
guarantees {
|
|
25
|
+
tarefa existe
|
|
26
|
+
}
|
|
27
|
+
tests {
|
|
28
|
+
caso "cria tarefa" {
|
|
29
|
+
given {
|
|
30
|
+
titulo: "Revisar contrato"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
expect {
|
|
34
|
+
sucesso: verdadeiro
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
task concluir_tarefa {
|
|
41
|
+
input {
|
|
42
|
+
id: Id required
|
|
43
|
+
}
|
|
44
|
+
output {
|
|
45
|
+
tarefa: Tarefa
|
|
46
|
+
}
|
|
47
|
+
rules {
|
|
48
|
+
id deve_ser valido
|
|
49
|
+
}
|
|
50
|
+
effects {
|
|
51
|
+
persistencia Tarefa
|
|
52
|
+
auditoria tarefa_concluida
|
|
53
|
+
}
|
|
54
|
+
guarantees {
|
|
55
|
+
tarefa existe
|
|
56
|
+
}
|
|
57
|
+
tests {
|
|
58
|
+
caso "conclui tarefa por id" {
|
|
59
|
+
given {
|
|
60
|
+
id: "tar_1"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
expect {
|
|
64
|
+
sucesso: verdadeiro
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
route tarefas_criar {
|
|
71
|
+
metodo: POST
|
|
72
|
+
caminho: /api/tarefas
|
|
73
|
+
task: criar_tarefa
|
|
74
|
+
finalidade: cadastro_tarefa
|
|
75
|
+
input {
|
|
76
|
+
titulo: Texto
|
|
77
|
+
}
|
|
78
|
+
output {
|
|
79
|
+
tarefa: Tarefa
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
route tarefas_concluir {
|
|
84
|
+
metodo: PATCH
|
|
85
|
+
caminho: "/api/tarefas/{id}"
|
|
86
|
+
task: concluir_tarefa
|
|
87
|
+
finalidade: alteracao_tarefa
|
|
88
|
+
input {
|
|
89
|
+
id: Id
|
|
90
|
+
}
|
|
91
|
+
output {
|
|
92
|
+
tarefa: Tarefa
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semacode/cli",
|
|
3
|
-
"version": "3.8.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.8.3",
|
|
4
|
+
"description": "Local-first semantic governance CLI for AI agents, proven with Claude, Codex, zCode (GLM) and Kimi: contracts, drift, impact, docs gates, and code generation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "logo.png",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/gerlanss/Sema.git"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://otimitare.
|
|
12
|
+
"homepage": "https://otimitare.com",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/gerlanss/Sema/issues",
|
|
15
|
-
"email": "suporte@otimitare.
|
|
15
|
+
"email": "suporte@otimitare.com"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"sema",
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SEMA-GOVERNED: sema.produto.fronteira_repositorios.empacotamento, sema.produto.fronteira_repositorios.empacotamento.postinstall
|
|
3
|
-
// Consulte contratos/sema/fronteira_repositorios_empacotamento_postinstall.sema antes de editar.
|
|
4
|
-
// Descricao: sincroniza launcher e skill globais somente no lifecycle npm --global.
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
const raizPacotePadrao = path.resolve(fileURLToPath(new URL("../", import.meta.url)));
|
|
10
|
-
const moduloDistribuicao = new URL("../dist/distribuicao/index.js", import.meta.url);
|
|
11
|
-
const ERROS_PUBLICOS = {
|
|
12
|
-
FALHA_CARREGAR_DISTRIBUICAO: "não foi possível carregar a distribuição global Sema",
|
|
13
|
-
API_DISTRIBUICAO_INVALIDA: "a API compilada de distribuição global Sema é inválida",
|
|
14
|
-
DIRETORIO_USUARIO_INVALIDO: "o diretório de usuário da distribuição global Sema é inválido",
|
|
15
|
-
RAIZ_PACOTE_INVALIDA: "a raiz do pacote da distribuição global Sema é inválida",
|
|
16
|
-
FALHA_SINCRONIZAR_DISTRIBUICAO: "não foi possível sincronizar a distribuição global Sema",
|
|
17
|
-
DISTRIBUICAO_NAO_PRONTA: "a distribuição global Sema não atingiu o estado READY",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function erroPublico(codigo) {
|
|
21
|
-
return new Error(`${codigo}: ${ERROS_PUBLICOS[codigo]}.`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function mensagemErroPostinstallPublica(erro) {
|
|
25
|
-
const mensagem = erro instanceof Error ? erro.message : "";
|
|
26
|
-
return Object.keys(ERROS_PUBLICOS).some((codigo) => mensagem.startsWith(`${codigo}:`))
|
|
27
|
-
? mensagem
|
|
28
|
-
: "FALHA_POSTINSTALL_GLOBAL: a distribuição global Sema não foi concluída.";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function instalacaoGlobalSolicitada(ambiente = process.env) {
|
|
32
|
-
const valor = ambiente.npm_config_global ?? ambiente.NPM_CONFIG_GLOBAL;
|
|
33
|
-
return /^(?:1|true)$/iu.test(String(valor ?? "").trim());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function caminhoAbsolutoOuErro(valor) {
|
|
37
|
-
const candidato = valor?.trim();
|
|
38
|
-
if (!candidato) return undefined;
|
|
39
|
-
if (!path.isAbsolute(candidato)) {
|
|
40
|
-
throw erroPublico("DIRETORIO_USUARIO_INVALIDO");
|
|
41
|
-
}
|
|
42
|
-
return path.resolve(candidato);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function resolverDiretorioUsuario(ambiente, plataforma) {
|
|
46
|
-
if (plataforma === "win32") {
|
|
47
|
-
const perfil = caminhoAbsolutoOuErro(ambiente.USERPROFILE);
|
|
48
|
-
if (perfil) {
|
|
49
|
-
return perfil;
|
|
50
|
-
}
|
|
51
|
-
const unidade = ambiente.HOMEDRIVE?.trim();
|
|
52
|
-
const caminho = ambiente.HOMEPATH?.trim();
|
|
53
|
-
if (unidade && caminho) {
|
|
54
|
-
return caminhoAbsolutoOuErro(`${unidade}${caminho}`);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
const diretorio = caminhoAbsolutoOuErro(ambiente.HOME);
|
|
58
|
-
if (diretorio) {
|
|
59
|
-
return diretorio;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const fallback = caminhoAbsolutoOuErro(os.homedir());
|
|
63
|
-
if (!fallback) throw erroPublico("DIRETORIO_USUARIO_INVALIDO");
|
|
64
|
-
return fallback;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function resolverRaizPacote(valor) {
|
|
68
|
-
if (typeof valor !== "string" || !valor.trim() || !path.isAbsolute(valor)) {
|
|
69
|
-
throw erroPublico("RAIZ_PACOTE_INVALIDA");
|
|
70
|
-
}
|
|
71
|
-
return path.resolve(valor);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function executarPostinstall({
|
|
75
|
-
ambiente = process.env,
|
|
76
|
-
plataforma = process.platform,
|
|
77
|
-
executavelNode = process.execPath,
|
|
78
|
-
raizPacote = raizPacotePadrao,
|
|
79
|
-
importar = (referencia) => import(referencia),
|
|
80
|
-
} = {}) {
|
|
81
|
-
if (!instalacaoGlobalSolicitada(ambiente)) {
|
|
82
|
-
return {
|
|
83
|
-
estado: "no_op",
|
|
84
|
-
motivo: "install_scope_local",
|
|
85
|
-
instalacao_local_no_op: true,
|
|
86
|
-
distribuicao_pronta: false,
|
|
87
|
-
alterado: false,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const diretorioUsuario = resolverDiretorioUsuario(ambiente, plataforma);
|
|
92
|
-
const raizPacoteAbsoluta = resolverRaizPacote(raizPacote);
|
|
93
|
-
|
|
94
|
-
let api;
|
|
95
|
-
try {
|
|
96
|
-
api = await importar(moduloDistribuicao.href);
|
|
97
|
-
} catch {
|
|
98
|
-
throw erroPublico("FALHA_CARREGAR_DISTRIBUICAO");
|
|
99
|
-
}
|
|
100
|
-
if (typeof api.sincronizarDistribuicaoGlobal !== "function") {
|
|
101
|
-
throw erroPublico("API_DISTRIBUICAO_INVALIDA");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let resultado;
|
|
105
|
-
try {
|
|
106
|
-
resultado = await api.sincronizarDistribuicaoGlobal({
|
|
107
|
-
plataforma,
|
|
108
|
-
diretorioUsuario,
|
|
109
|
-
executavelNode,
|
|
110
|
-
raizPacote: raizPacoteAbsoluta,
|
|
111
|
-
});
|
|
112
|
-
} catch {
|
|
113
|
-
throw erroPublico("FALHA_SINCRONIZAR_DISTRIBUICAO");
|
|
114
|
-
}
|
|
115
|
-
if (
|
|
116
|
-
resultado?.estado !== "READY" ||
|
|
117
|
-
resultado.launcher?.estado !== "READY" ||
|
|
118
|
-
resultado.skill?.estado !== "READY" ||
|
|
119
|
-
typeof resultado.alterado !== "boolean"
|
|
120
|
-
) {
|
|
121
|
-
throw erroPublico("DISTRIBUICAO_NAO_PRONTA");
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
estado: "READY",
|
|
125
|
-
motivo: "distribution_ready",
|
|
126
|
-
instalacao_local_no_op: false,
|
|
127
|
-
distribuicao_pronta: true,
|
|
128
|
-
alterado: resultado.alterado,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function executadoDiretamente() {
|
|
133
|
-
return Boolean(process.argv[1]) && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (executadoDiretamente()) {
|
|
137
|
-
executarPostinstall()
|
|
138
|
-
.then((resultado) => {
|
|
139
|
-
if (resultado?.estado !== "no_op") {
|
|
140
|
-
console.log("Sema global launcher and AI skill synchronized.");
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
.catch((erro) => {
|
|
144
|
-
console.error("Failed to synchronize the global Sema distribution.");
|
|
145
|
-
console.error(mensagemErroPostinstallPublica(erro));
|
|
146
|
-
process.exitCode = 1;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SEMA-GOVERNED: sema.produto.fronteira_repositorios.empacotamento, sema.produto.fronteira_repositorios.empacotamento.postinstall
|
|
3
|
+
// Consulte contratos/sema/fronteira_repositorios_empacotamento_postinstall.sema antes de editar.
|
|
4
|
+
// Descricao: sincroniza launcher e skill globais somente no lifecycle npm --global.
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const raizPacotePadrao = path.resolve(fileURLToPath(new URL("../", import.meta.url)));
|
|
10
|
+
const moduloDistribuicao = new URL("../dist/distribuicao/index.js", import.meta.url);
|
|
11
|
+
const ERROS_PUBLICOS = {
|
|
12
|
+
FALHA_CARREGAR_DISTRIBUICAO: "não foi possível carregar a distribuição global Sema",
|
|
13
|
+
API_DISTRIBUICAO_INVALIDA: "a API compilada de distribuição global Sema é inválida",
|
|
14
|
+
DIRETORIO_USUARIO_INVALIDO: "o diretório de usuário da distribuição global Sema é inválido",
|
|
15
|
+
RAIZ_PACOTE_INVALIDA: "a raiz do pacote da distribuição global Sema é inválida",
|
|
16
|
+
FALHA_SINCRONIZAR_DISTRIBUICAO: "não foi possível sincronizar a distribuição global Sema",
|
|
17
|
+
DISTRIBUICAO_NAO_PRONTA: "a distribuição global Sema não atingiu o estado READY",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function erroPublico(codigo) {
|
|
21
|
+
return new Error(`${codigo}: ${ERROS_PUBLICOS[codigo]}.`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function mensagemErroPostinstallPublica(erro) {
|
|
25
|
+
const mensagem = erro instanceof Error ? erro.message : "";
|
|
26
|
+
return Object.keys(ERROS_PUBLICOS).some((codigo) => mensagem.startsWith(`${codigo}:`))
|
|
27
|
+
? mensagem
|
|
28
|
+
: "FALHA_POSTINSTALL_GLOBAL: a distribuição global Sema não foi concluída.";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function instalacaoGlobalSolicitada(ambiente = process.env) {
|
|
32
|
+
const valor = ambiente.npm_config_global ?? ambiente.NPM_CONFIG_GLOBAL;
|
|
33
|
+
return /^(?:1|true)$/iu.test(String(valor ?? "").trim());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function caminhoAbsolutoOuErro(valor) {
|
|
37
|
+
const candidato = valor?.trim();
|
|
38
|
+
if (!candidato) return undefined;
|
|
39
|
+
if (!path.isAbsolute(candidato)) {
|
|
40
|
+
throw erroPublico("DIRETORIO_USUARIO_INVALIDO");
|
|
41
|
+
}
|
|
42
|
+
return path.resolve(candidato);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function resolverDiretorioUsuario(ambiente, plataforma) {
|
|
46
|
+
if (plataforma === "win32") {
|
|
47
|
+
const perfil = caminhoAbsolutoOuErro(ambiente.USERPROFILE);
|
|
48
|
+
if (perfil) {
|
|
49
|
+
return perfil;
|
|
50
|
+
}
|
|
51
|
+
const unidade = ambiente.HOMEDRIVE?.trim();
|
|
52
|
+
const caminho = ambiente.HOMEPATH?.trim();
|
|
53
|
+
if (unidade && caminho) {
|
|
54
|
+
return caminhoAbsolutoOuErro(`${unidade}${caminho}`);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
const diretorio = caminhoAbsolutoOuErro(ambiente.HOME);
|
|
58
|
+
if (diretorio) {
|
|
59
|
+
return diretorio;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const fallback = caminhoAbsolutoOuErro(os.homedir());
|
|
63
|
+
if (!fallback) throw erroPublico("DIRETORIO_USUARIO_INVALIDO");
|
|
64
|
+
return fallback;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolverRaizPacote(valor) {
|
|
68
|
+
if (typeof valor !== "string" || !valor.trim() || !path.isAbsolute(valor)) {
|
|
69
|
+
throw erroPublico("RAIZ_PACOTE_INVALIDA");
|
|
70
|
+
}
|
|
71
|
+
return path.resolve(valor);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function executarPostinstall({
|
|
75
|
+
ambiente = process.env,
|
|
76
|
+
plataforma = process.platform,
|
|
77
|
+
executavelNode = process.execPath,
|
|
78
|
+
raizPacote = raizPacotePadrao,
|
|
79
|
+
importar = (referencia) => import(referencia),
|
|
80
|
+
} = {}) {
|
|
81
|
+
if (!instalacaoGlobalSolicitada(ambiente)) {
|
|
82
|
+
return {
|
|
83
|
+
estado: "no_op",
|
|
84
|
+
motivo: "install_scope_local",
|
|
85
|
+
instalacao_local_no_op: true,
|
|
86
|
+
distribuicao_pronta: false,
|
|
87
|
+
alterado: false,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const diretorioUsuario = resolverDiretorioUsuario(ambiente, plataforma);
|
|
92
|
+
const raizPacoteAbsoluta = resolverRaizPacote(raizPacote);
|
|
93
|
+
|
|
94
|
+
let api;
|
|
95
|
+
try {
|
|
96
|
+
api = await importar(moduloDistribuicao.href);
|
|
97
|
+
} catch {
|
|
98
|
+
throw erroPublico("FALHA_CARREGAR_DISTRIBUICAO");
|
|
99
|
+
}
|
|
100
|
+
if (typeof api.sincronizarDistribuicaoGlobal !== "function") {
|
|
101
|
+
throw erroPublico("API_DISTRIBUICAO_INVALIDA");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let resultado;
|
|
105
|
+
try {
|
|
106
|
+
resultado = await api.sincronizarDistribuicaoGlobal({
|
|
107
|
+
plataforma,
|
|
108
|
+
diretorioUsuario,
|
|
109
|
+
executavelNode,
|
|
110
|
+
raizPacote: raizPacoteAbsoluta,
|
|
111
|
+
});
|
|
112
|
+
} catch {
|
|
113
|
+
throw erroPublico("FALHA_SINCRONIZAR_DISTRIBUICAO");
|
|
114
|
+
}
|
|
115
|
+
if (
|
|
116
|
+
resultado?.estado !== "READY" ||
|
|
117
|
+
resultado.launcher?.estado !== "READY" ||
|
|
118
|
+
resultado.skill?.estado !== "READY" ||
|
|
119
|
+
typeof resultado.alterado !== "boolean"
|
|
120
|
+
) {
|
|
121
|
+
throw erroPublico("DISTRIBUICAO_NAO_PRONTA");
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
estado: "READY",
|
|
125
|
+
motivo: "distribution_ready",
|
|
126
|
+
instalacao_local_no_op: false,
|
|
127
|
+
distribuicao_pronta: true,
|
|
128
|
+
alterado: resultado.alterado,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function executadoDiretamente() {
|
|
133
|
+
return Boolean(process.argv[1]) && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (executadoDiretamente()) {
|
|
137
|
+
executarPostinstall()
|
|
138
|
+
.then((resultado) => {
|
|
139
|
+
if (resultado?.estado !== "no_op") {
|
|
140
|
+
console.log("Sema global launcher and AI skill synchronized.");
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.catch((erro) => {
|
|
144
|
+
console.error("Failed to synchronize the global Sema distribution.");
|
|
145
|
+
console.error(mensagemErroPostinstallPublica(erro));
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
});
|
|
148
|
+
}
|