@semacode/cli 2.3.0 → 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.
Files changed (267) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +112 -41
  3. package/dist/agentContextPack.js +14 -10
  4. package/dist/agentEntryPoints.d.ts +5 -0
  5. package/dist/agentEntryPoints.js +102 -91
  6. package/dist/angular-consumer-standalone.d.ts +3 -1
  7. package/dist/angular-consumer-standalone.js +12 -8
  8. package/dist/bin.d.ts +6 -0
  9. package/dist/bin.js +130 -0
  10. package/dist/cliArgs.js +4 -4
  11. package/dist/cliControlError.d.ts +12 -0
  12. package/dist/cliControlError.js +47 -0
  13. package/dist/cliGrammar.d.ts +11 -0
  14. package/dist/cliGrammar.js +551 -0
  15. package/dist/cliHelp.d.ts +13 -0
  16. package/dist/cliHelp.js +19 -0
  17. package/dist/cliHelpTexto.d.ts +3 -0
  18. package/dist/cliHelpTexto.js +168 -0
  19. package/dist/cliRuntime.d.ts +2 -0
  20. package/dist/cliRuntime.js +31 -0
  21. package/dist/comandos.js +9 -22
  22. package/dist/contexto.js +5 -5
  23. package/dist/dev/index.d.ts +1 -0
  24. package/dist/dev/index.js +51 -9
  25. package/dist/discovery/catalog.js +3 -3
  26. package/dist/distribuicao/filesystemGlobal.d.ts +63 -0
  27. package/dist/distribuicao/filesystemGlobal.js +701 -0
  28. package/dist/distribuicao/index.d.ts +7 -0
  29. package/dist/distribuicao/index.js +227 -0
  30. package/dist/distribuicao/launcherGlobal.d.ts +53 -0
  31. package/dist/distribuicao/launcherGlobal.js +643 -0
  32. package/dist/distribuicao/launcherWindows.d.ts +28 -0
  33. package/dist/distribuicao/launcherWindows.js +326 -0
  34. package/dist/distribuicao/lockContextGlobal.d.ts +10 -0
  35. package/dist/distribuicao/lockContextGlobal.js +17 -0
  36. package/dist/distribuicao/lockGlobal.d.ts +6 -0
  37. package/dist/distribuicao/lockGlobal.js +520 -0
  38. package/dist/distribuicao/skillGlobal.d.ts +48 -0
  39. package/dist/distribuicao/skillGlobal.js +652 -0
  40. package/dist/distribuicao/skillIntentPolicy.d.ts +21 -0
  41. package/dist/distribuicao/skillIntentPolicy.js +115 -0
  42. package/dist/distribuicao/tipos.d.ts +50 -0
  43. package/dist/distribuicao/tipos.js +10 -0
  44. package/dist/distribuicao/versaoSemantica.d.ts +3 -0
  45. package/dist/distribuicao/versaoSemantica.js +62 -0
  46. package/dist/drift.part01.d.ts +34 -2
  47. package/dist/drift.part01.js +3 -0
  48. package/dist/drift.part04.d.ts +12 -2
  49. package/dist/drift.part04.js +89 -15
  50. package/dist/drift.part05.d.ts +2 -1
  51. package/dist/drift.part05.js +9 -6
  52. package/dist/drift.part06.d.ts +2 -1
  53. package/dist/drift.part06.js +115 -24
  54. package/dist/drift.part07.d.ts +11 -10
  55. package/dist/drift.part07.js +261 -255
  56. package/dist/drift.part08.d.ts +2 -1
  57. package/dist/drift.part08.js +35 -25
  58. package/dist/drift.part11.js +279 -32
  59. package/dist/drift.part12.d.ts +1 -1
  60. package/dist/drift.part12.js +196 -11
  61. package/dist/drift.part13.d.ts +18 -2
  62. package/dist/drift.part13.js +654 -76
  63. package/dist/drift.part14.js +21 -7
  64. package/dist/driftCacheCas.d.ts +43 -0
  65. package/dist/driftCacheCas.js +351 -0
  66. package/dist/driftCacheFilesystem.d.ts +64 -0
  67. package/dist/driftCacheFilesystem.js +313 -0
  68. package/dist/driftCacheModes.d.ts +38 -0
  69. package/dist/driftCacheModes.js +147 -0
  70. package/dist/driftCacheStore.d.ts +80 -0
  71. package/dist/driftCacheStore.js +603 -0
  72. package/dist/driftCatalogo.d.ts +65 -0
  73. package/dist/driftCatalogo.js +516 -0
  74. package/dist/driftEscopo.d.ts +21 -0
  75. package/dist/driftEscopo.js +647 -0
  76. package/dist/driftEscopoReferencias.d.ts +8 -0
  77. package/dist/driftEscopoReferencias.js +612 -0
  78. package/dist/driftOrcamento.d.ts +6 -0
  79. package/dist/driftOrcamento.js +20 -3
  80. package/dist/geracaoCore.js +4 -6
  81. package/dist/iaPrompts.d.ts +3 -3
  82. package/dist/iaPrompts.js +13 -14
  83. package/dist/index.d.ts +4 -1
  84. package/dist/index.js +6 -25
  85. package/dist/index.part01.d.ts +21 -14
  86. package/dist/index.part01.js +20 -165
  87. package/dist/index.part02.js +57 -43
  88. package/dist/index.part03.d.ts +23 -1
  89. package/dist/index.part03.js +83 -8
  90. package/dist/index.part04.d.ts +10 -2
  91. package/dist/index.part04.js +48 -14
  92. package/dist/index.part05.d.ts +1 -1
  93. package/dist/index.part05.js +109 -30
  94. package/dist/index.part06.js +34 -16
  95. package/dist/index.part07.js +31 -27
  96. package/dist/index.part08.d.ts +1 -1
  97. package/dist/index.part08.js +23 -28
  98. package/dist/init/templates.part01.js +393 -393
  99. package/dist/init/templates.part02.js +189 -189
  100. package/dist/initCommand.js +5 -1
  101. package/dist/initTemplatesBackend.js +73 -73
  102. package/dist/initTemplatesBase.js +7 -5
  103. package/dist/initTemplatesFlutter.js +137 -137
  104. package/dist/initTemplatesRuntime.js +350 -350
  105. package/dist/initTemplatesWeb.js +309 -309
  106. package/dist/pipelineConteudo/command.d.ts +1 -0
  107. package/dist/pipelineConteudo/command.js +4 -32
  108. package/dist/pipelineConteudo/help.d.ts +2 -0
  109. package/dist/pipelineConteudo/help.js +33 -0
  110. package/dist/profileAuthorCommand.js +3 -7
  111. package/dist/profileCommand.js +3 -7
  112. package/dist/projeto.d.ts +1 -1
  113. package/dist/projetoCarregar.d.ts +2 -2
  114. package/dist/projetoCarregar.js +69 -28
  115. package/dist/projetoCatalogo.d.ts +8 -0
  116. package/dist/projetoCatalogo.js +164 -0
  117. package/dist/projetoOrigens.d.ts +2 -0
  118. package/dist/projetoOrigens.js +65 -9
  119. package/dist/projetoTipos.d.ts +15 -5
  120. package/dist/resultadoCli.d.ts +20 -0
  121. package/dist/resultadoCli.js +57 -0
  122. package/dist/saidaCli.d.ts +35 -0
  123. package/dist/saidaCli.js +118 -0
  124. package/dist/sistemasInterativos/acceptanceEvidence.d.ts +22 -0
  125. package/dist/sistemasInterativos/acceptanceEvidence.js +345 -0
  126. package/dist/sistemasInterativos/engineObservation.d.ts +12 -0
  127. package/dist/sistemasInterativos/engineObservation.js +438 -0
  128. package/dist/sistemasInterativos/jobOrchestration.d.ts +2 -0
  129. package/dist/sistemasInterativos/jobOrchestration.js +204 -0
  130. package/dist/sistemasInterativos/operationPrimitives.d.ts +21 -0
  131. package/dist/sistemasInterativos/operationPrimitives.js +194 -0
  132. package/dist/sistemasInterativos/operations.d.ts +4 -39
  133. package/dist/sistemasInterativos/operations.js +5 -1164
  134. package/dist/skillCommand.d.ts +5 -0
  135. package/dist/skillCommand.js +88 -0
  136. package/dist/sync/index.js +35 -35
  137. package/docs/README.md +11 -7
  138. package/docs/ai-integration.md +18 -11
  139. package/docs/ai-onboarding.md +81 -62
  140. package/docs/ai-workflow.md +10 -4
  141. package/docs/auth.md +26 -26
  142. package/docs/cli.md +197 -79
  143. package/docs/commands.md +30 -6
  144. package/docs/database.md +15 -15
  145. package/docs/deploy.md +54 -41
  146. package/docs/documentation.md +11 -10
  147. package/docs/drift-cache.md +108 -0
  148. package/docs/env.md +16 -16
  149. package/docs/frontend.md +41 -41
  150. package/docs/getting-started.md +82 -57
  151. package/docs/i18n.md +15 -15
  152. package/docs/repositories.md +60 -43
  153. package/docs/rollback.md +38 -31
  154. package/docs/security.md +54 -32
  155. package/docs/sistemas-interativos.md +27 -27
  156. package/docs/support.md +8 -8
  157. package/docs/testing.md +123 -17
  158. package/docs/vocabulary.md +29 -29
  159. package/exemplos/agendamento.sema +1 -1
  160. package/exemplos/assinatura.sema +1 -1
  161. package/exemplos/auditoria.sema +1 -1
  162. package/exemplos/autenticacao.sema +1 -1
  163. package/exemplos/author_obra_comum.sema +1 -1
  164. package/exemplos/author_tema_sensivel.sema +1 -1
  165. package/exemplos/automacao.sema +1 -1
  166. package/exemplos/cadastro_usuario.sema +1 -1
  167. package/exemplos/calculadora.sema +1 -1
  168. package/exemplos/crud_simples.sema +1 -1
  169. package/exemplos/estoque.sema +1 -1
  170. package/exemplos/exportacao.sema +1 -1
  171. package/exemplos/fila.sema +1 -1
  172. package/exemplos/integracao_externa.sema +1 -1
  173. package/exemplos/multi_tenant.sema +1 -1
  174. package/exemplos/notificacao.sema +1 -1
  175. package/exemplos/operacao_estrategia.sema +132 -132
  176. package/exemplos/operacao_estrategia_discovery.sema +220 -220
  177. package/exemplos/operacao_estrategia_fluxo.sema +114 -114
  178. package/exemplos/operacao_estrategia_gates.sema +106 -106
  179. package/exemplos/operacao_estrategia_quarentena.sema +133 -133
  180. package/exemplos/operacao_estrategia_rollout.sema +124 -124
  181. package/exemplos/pagamento.sema +1 -1
  182. package/exemplos/pagamento_dominio.sema +1 -1
  183. package/exemplos/pedido.sema +1 -1
  184. package/exemplos/permissao.sema +1 -1
  185. package/exemplos/persistencia_vendor_first.sema +1 -1
  186. package/exemplos/profile_conversas.sema +165 -165
  187. package/exemplos/profile_game.sema +1 -1
  188. package/exemplos/profile_legal.sema +1 -1
  189. package/exemplos/profile_ops.sema +1 -1
  190. package/exemplos/profile_research.sema +1 -1
  191. package/exemplos/profile_software.sema +1 -1
  192. package/exemplos/profile_workflow_n8n.sema +1 -1
  193. package/exemplos/relatorio.sema +1 -1
  194. package/exemplos/replica_analitica_erp.sema +1 -1
  195. package/exemplos/testes_embutidos.sema +1 -1
  196. package/exemplos/tratamento_erro.sema +1 -1
  197. package/exemplos/upload_arquivo.sema +1 -1
  198. package/exemplos/webhook.sema +1 -1
  199. package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
  200. package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
  201. package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
  202. package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
  203. package/node_modules/@sema/gerador-html/dist/index.js +17 -17
  204. package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
  205. package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
  206. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
  207. package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +1 -0
  208. package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
  209. package/package.json +7 -2
  210. package/scripts/postinstall.mjs +148 -0
  211. package/skills/sema/SKILL.md +199 -0
  212. package/skills/sema/agents/openai.yaml +4 -0
  213. package/node_modules/@sema/gerador-cpp/dist/index.js.map +0 -1
  214. package/node_modules/@sema/gerador-css/dist/index.js.map +0 -1
  215. package/node_modules/@sema/gerador-css/dist/index.part01.js.map +0 -1
  216. package/node_modules/@sema/gerador-css/dist/index.part02.js.map +0 -1
  217. package/node_modules/@sema/gerador-dart/dist/index.js.map +0 -1
  218. package/node_modules/@sema/gerador-dotnet/dist/index.js.map +0 -1
  219. package/node_modules/@sema/gerador-html/dist/index.js.map +0 -1
  220. package/node_modules/@sema/gerador-javascript/dist/index.js.map +0 -1
  221. package/node_modules/@sema/gerador-lua/dist/index.js.map +0 -1
  222. package/node_modules/@sema/gerador-php/dist/index.js.map +0 -1
  223. package/node_modules/@sema/gerador-python/dist/index.js.map +0 -1
  224. package/node_modules/@sema/gerador-python/dist/index.part01.js.map +0 -1
  225. package/node_modules/@sema/gerador-python/dist/index.part02.js.map +0 -1
  226. package/node_modules/@sema/gerador-typescript/dist/index.js.map +0 -1
  227. package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +0 -1
  228. package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +0 -1
  229. package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +0 -1
  230. package/node_modules/@sema/nucleo/dist/ast/tipos.js.map +0 -1
  231. package/node_modules/@sema/nucleo/dist/diagnosticos/index.js.map +0 -1
  232. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +0 -1
  233. package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +0 -1
  234. package/node_modules/@sema/nucleo/dist/formatador/index.js.map +0 -1
  235. package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +0 -1
  236. package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +0 -1
  237. package/node_modules/@sema/nucleo/dist/index.js.map +0 -1
  238. package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +0 -1
  239. package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +0 -1
  240. package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +0 -1
  241. package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +0 -1
  242. package/node_modules/@sema/nucleo/dist/ir/modelos.js.map +0 -1
  243. package/node_modules/@sema/nucleo/dist/lexer/lexer.js.map +0 -1
  244. package/node_modules/@sema/nucleo/dist/lexer/tokens.js.map +0 -1
  245. package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +0 -1
  246. package/node_modules/@sema/nucleo/dist/parser/parser.js.map +0 -1
  247. package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +0 -1
  248. package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +0 -1
  249. package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +0 -1
  250. package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +0 -1
  251. package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +0 -1
  252. package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +0 -1
  253. package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +0 -1
  254. package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +0 -1
  255. package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +0 -1
  256. package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +0 -1
  257. package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +0 -1
  258. package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +0 -1
  259. package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +0 -1
  260. package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +0 -1
  261. package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +0 -1
  262. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +0 -1
  263. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +0 -1
  264. package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +0 -1
  265. package/node_modules/@sema/nucleo/dist/semantico/seguranca.js.map +0 -1
  266. package/node_modules/@sema/nucleo/dist/util/arquivos.js.map +0 -1
  267. package/node_modules/@sema/padroes/dist/index.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { type ResultadoDistribuicaoGlobal } from "./distribuicao/index.js";
2
+ type OperacaoSkill = "status" | "sync";
3
+ export declare function renderizarResultadoSkill(operacao: OperacaoSkill, resultado: ResultadoDistribuicaoGlobal): string;
4
+ export declare function comandoSkill(posicionais: string[], args: string[], emJson: boolean): Promise<number>;
5
+ export {};
@@ -0,0 +1,88 @@
1
+ // SEMA-GOVERNED: sema.produto.distribuicao_global, sema.produto.distribuicao_global.skill
2
+ // Descrição: expõe diagnóstico read-only e reparo explícito da distribuição global gerenciada.
3
+ import { sincronizarDistribuicaoGlobal, statusDistribuicaoGlobal, } from "./distribuicao/index.js";
4
+ export function renderizarResultadoSkill(operacao, resultado) {
5
+ const linhas = [
6
+ `Distribuição global Sema (${operacao}): ${resultado.estado}`,
7
+ ` Alterada: ${resultado.alterado ? "sim" : "não"}`,
8
+ ` Launcher: ${resultado.launcher.estado} (${resultado.launcher.destino_simbolico})`,
9
+ ...(resultado.launcher.fallback_simbolico
10
+ ? [` Fallback PowerShell: ${resultado.launcher.fallback_simbolico}`]
11
+ : []),
12
+ ` Diagnóstico launcher: ${resultado.launcher.codigo}`,
13
+ ` Skill: ${resultado.skill.estado} (${resultado.skill.origem_simbolica})`,
14
+ ` Destino .agents: ${resultado.skill.destino_agents}`,
15
+ ` Destino Claude: ${resultado.skill.destino_claude}`,
16
+ ` Diagnósticos skill: ${resultado.skill.destinos
17
+ .map((destino) => `${destino.id}=${destino.codigo}`)
18
+ .join(", ") || "nenhum"}`,
19
+ ];
20
+ return linhas.join("\n");
21
+ }
22
+ function imprimirSubcomandoInvalido(emJson) {
23
+ const mensagem = "Use `sema skill status` ou `sema skill sync`.";
24
+ if (emJson) {
25
+ console.log(JSON.stringify({
26
+ schema: "sema.skill-distribution/v1",
27
+ comando: "skill",
28
+ sucesso: false,
29
+ erro: {
30
+ codigo: "SUBCOMANDO_SKILL_INVALIDO",
31
+ mensagem,
32
+ },
33
+ }, null, 2));
34
+ return;
35
+ }
36
+ console.error(mensagem);
37
+ }
38
+ export async function comandoSkill(posicionais, args, emJson) {
39
+ const operacao = (posicionais[0] ?? "status").toLocaleLowerCase("en-US");
40
+ const possuiArgumentoExtra = posicionais.length > 1;
41
+ const possuiFlagDesconhecida = args.some((arg) => arg.startsWith("-") && arg !== "--json");
42
+ if ((operacao !== "status" && operacao !== "sync")
43
+ || possuiArgumentoExtra
44
+ || possuiFlagDesconhecida) {
45
+ imprimirSubcomandoInvalido(emJson);
46
+ return 1;
47
+ }
48
+ try {
49
+ const resultado = operacao === "sync"
50
+ ? await sincronizarDistribuicaoGlobal()
51
+ : await statusDistribuicaoGlobal();
52
+ const sucesso = resultado.estado === "READY";
53
+ if (emJson) {
54
+ const payload = {
55
+ schema: "sema.skill-distribution/v1",
56
+ comando: "skill",
57
+ operacao,
58
+ sucesso,
59
+ resultado,
60
+ };
61
+ console.log(JSON.stringify(payload, null, 2));
62
+ }
63
+ else {
64
+ console.log(renderizarResultadoSkill(operacao, resultado));
65
+ }
66
+ return sucesso ? 0 : 1;
67
+ }
68
+ catch {
69
+ const mensagem = "Falha ao consultar ou sincronizar a distribuição global Sema.";
70
+ if (emJson) {
71
+ console.log(JSON.stringify({
72
+ schema: "sema.skill-distribution/v1",
73
+ comando: "skill",
74
+ operacao,
75
+ sucesso: false,
76
+ erro: {
77
+ codigo: "FALHA_DISTRIBUICAO_GLOBAL",
78
+ mensagem,
79
+ },
80
+ }, null, 2));
81
+ }
82
+ else {
83
+ console.error(mensagem);
84
+ }
85
+ return 1;
86
+ }
87
+ }
88
+ //# sourceMappingURL=skillCommand.js.map
@@ -46,25 +46,25 @@ export async function gerarSchemaPrisma(pastaContratos, saidaSchema, datasourceP
46
46
  for (const contrato of contratos) {
47
47
  const nomeModel = path.basename(contrato, '.sema').replace(/\./g, '_');
48
48
  // Schema simplificado - em producao, fazer parsing real do contrato
49
- models += `\nmodel ${nomeModel.charAt(0).toUpperCase() + nomeModel.slice(1)} {
50
- id String @id @default(uuid())
51
- criadoEm DateTime @default(now())
52
- // Gerado a partir de: ${contrato}
53
- // TODO: Adicionar campos do contrato Sema
49
+ models += `\nmodel ${nomeModel.charAt(0).toUpperCase() + nomeModel.slice(1)} {
50
+ id String @id @default(uuid())
51
+ criadoEm DateTime @default(now())
52
+ // Gerado a partir de: ${contrato}
53
+ // TODO: Adicionar campos do contrato Sema
54
54
  }\n`;
55
55
  modelCount++;
56
56
  }
57
- const schema = `// Gerado automaticamente pelo Sema
58
- // Fonte: ${pastaContratos}
59
-
60
- generator client {
61
- provider = "prisma-client-js"
62
- }
63
-
64
- datasource db {
65
- provider = "${datasourceProvider}"
66
- url = env("SEMA_PRISMA_URL")
67
- }
57
+ const schema = `// Gerado automaticamente pelo Sema
58
+ // Fonte: ${pastaContratos}
59
+
60
+ generator client {
61
+ provider = "prisma-client-js"
62
+ }
63
+
64
+ datasource db {
65
+ provider = "${datasourceProvider}"
66
+ url = env("SEMA_PRISMA_URL")
67
+ }
68
68
  ${models}`;
69
69
  // Salvar
70
70
  fs.writeFileSync(saidaSchema, schema, 'utf-8');
@@ -90,25 +90,25 @@ export async function importarSchemaPrisma(caminhoSchema, pastaSaida, nomeModulo
90
90
  const nomeContrato = `${nomeModel.toLowerCase()}.sema`;
91
91
  const caminhoContrato = path.join(pastaSaida, nomeContrato);
92
92
  // Gerar contrato basico
93
- const conteudo = `module ${nomeModulo}.${nomeModel.toLowerCase()} {
94
- entity ${nomeModel} {
95
- fields {
96
- id: Id
97
- // TODO: Mapear campos do schema Prisma
98
- }
99
- }
100
-
101
- task criar_${nomeModel.toLowerCase()} {
102
- input {
103
- // TODO: Definir inputs
104
- }
105
- output {
106
- ${nomeModel.toLowerCase()}: ${nomeModel}
107
- }
108
- effects {
109
- persistencia ${nomeModel}
110
- }
111
- }
93
+ const conteudo = `module ${nomeModulo}.${nomeModel.toLowerCase()} {
94
+ entity ${nomeModel} {
95
+ fields {
96
+ id: Id
97
+ // TODO: Mapear campos do schema Prisma
98
+ }
99
+ }
100
+
101
+ task criar_${nomeModel.toLowerCase()} {
102
+ input {
103
+ // TODO: Definir inputs
104
+ }
105
+ output {
106
+ ${nomeModel.toLowerCase()}: ${nomeModel}
107
+ }
108
+ effects {
109
+ persistencia ${nomeModel}
110
+ }
111
+ }
112
112
  }`;
113
113
  fs.writeFileSync(caminhoContrato, conteudo, 'utf-8');
114
114
  contratos.push(caminhoContrato);
package/docs/README.md CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  These docs describe the public Codex-native local CLI distribution of Sema.
4
4
 
5
- Sema is local-first: Codex runs the CLI inside a project folder, reads `.sema`
6
- contracts, checks drift, maps impact, and closes changes with documentation
7
- evidence. `AGENTS.md` is the official Codex entrypoint. Public docs are written
8
- in English.
5
+ Sema is local-first: Codex runs the CLI inside a project folder, reads `.sema`
6
+ contracts, checks drift, maps impact, and closes changes with documentation
7
+ evidence. In 3.0.0, valid commands using `--json` return the exact
8
+ `sema.cli.result/v1` envelope with command data nested under `payload`, while
9
+ help and command-control failures keep the separate `sema.cli.control/v1`
10
+ envelope. `AGENTS.md` is the official Codex entrypoint. Public docs are written
11
+ in English.
9
12
 
10
13
  Sema is an independent product and is not affiliated with or endorsed by
11
14
  OpenAI. Codex-native describes Sema's product direction, not an official OpenAI
@@ -13,9 +16,10 @@ program or submission.
13
16
 
14
17
  Start here:
15
18
 
16
- - [CLI](./cli.md)
17
- - [Commands](./commands.md)
18
- - [Syntax](./syntax.md)
19
+ - [CLI](./cli.md) — installation and the public JSON output contract
20
+ - [Commands](./commands.md) — command catalog and envelope-consumption rules
21
+ - [Drift Cache And Query Evidence](./drift-cache.md)
22
+ - [Syntax](./syntax.md)
19
23
  - [Profiles](./profiles.md)
20
24
  - [Capability Discovery](./descoberta-capacidades.md) — one explainable catalog
21
25
  for governance flows, profiles, specialized workflows, pipelines, generators,
@@ -11,18 +11,22 @@ https://learn.chatgpt.com/docs/agent-configuration/agents-md.
11
11
 
12
12
  ## Before AGENTS.md Exists
13
13
 
14
- The official Sema skill is the required first-contact bootstrap for Codex in a
15
- project that does not have Sema yet. Install it explicitly:
14
+ The official Sema skill is the first-contact bootstrap for a project that does
15
+ not have Sema yet. A global CLI install bundles and synchronizes it:
16
16
 
17
17
  ```bash
18
- codex plugin marketplace add gerlanss/Sema
19
- codex plugin add sema@sema
18
+ npm install -g @semacode/cli
19
+ sema skill status --json
20
20
  ```
21
21
 
22
- The skill locates the local CLI, runs `sema iniciar`, generates `AGENTS.md`, and
23
- then delegates all ongoing workspace governance to that file. It contains no
22
+ The package creates an absolute launcher under `~/.sema/bin`, synchronizes the
23
+ canonical skill under `~/.agents/skills/sema`, and mirrors Claude only when
24
+ detected. Informational requests stay read-only; before implementation the skill asks
25
+ for explicit project-adoption authorization, then generates `AGENTS.md` and delegates
26
+ ongoing governance. Installing or updating the global CLI authorizes distribution only.
27
+ Already-open tasks may need a reload. The distribution contains no
24
28
  MCP server, remote workspace bridge, login, license, billing, token, credit,
25
- panel, or authorization gate.
29
+ panel, or runtime authorization gate.
26
30
 
27
31
  Supported capacity labels: fraca, pequena, media, forte, grande.
28
32
 
@@ -32,10 +36,11 @@ For a local workspace, use the local CLI:
32
36
 
33
37
  ```bash
34
38
  sema --version
35
- sema resumo
39
+ sema resumo --drift none
36
40
  ```
37
41
 
38
- A successful `sema --version` is enough to use the local CLI directly. Local
42
+ If the shell cannot resolve `sema`, use `~/.sema/bin/sema` on macOS/Linux. On Windows, PowerShell uses `sema.ps1` from PATH and cmd.exe uses `sema.cmd`; use `& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version` as the absolute fallback
43
+ before declaring the CLI unavailable. A successful version check is enough. Local
39
44
  commands require no login, activation key, license check, token, credits, billing
40
45
  service, control panel, or external authorization request.
41
46
 
@@ -43,13 +48,15 @@ service, control panel, or external authorization request.
43
48
 
44
49
  ```bash
45
50
  sema docs-impacto --intencao "describe the change" --json
46
- sema inspecionar contratos/example.sema --json
47
- sema drift contratos/example.sema --escopo modulo --json
51
+ sema inspecionar contratos/example.sema --drift none --json
52
+ sema drift contratos/example.sema --escopo modulo --cache fresh --json
48
53
  sema impacto contratos/example.sema --alvo app.example --mudanca "describe the change" --json
49
54
  ```
50
55
 
51
56
  Read every document listed by `docs-impacto` before changing code, contracts,
52
57
  operational docs, generated artifacts, workflows, profiles, or release material.
58
+ A cache hit is acceleration, not evidence: closing requires `--cache fresh`,
59
+ while contract-only queries keep unobserved implementation fields null inside the command payload.
53
60
 
54
61
  ## Codex Context Tiers
55
62
 
@@ -1,62 +1,81 @@
1
- # Codex Onboarding
2
-
3
- The official Sema skill is required for Codex to recognize and initialize Sema
4
- before a project has its own protocol:
5
-
6
- ```bash
7
- codex plugin marketplace add gerlanss/Sema
8
- codex plugin add sema@sema
9
- ```
10
-
11
- Open a new Codex task in the target repository after installation. Codex loads
12
- the plugin/skill catalog at task start, so `$sema` is not added retroactively to
13
- an already-open task. Invoke `$sema` in the new task; it bootstraps the project,
14
- reads the generated `AGENTS.md`, and later tasks load that protocol
15
- automatically.
16
-
17
- `AGENTS.md` is the official Sema entrypoint for Codex. It gives Codex the durable
18
- repository rule that contracts come first and the local CLI is the source of
19
- truth. Once the file exists, the skill delegates to it instead of carrying a
20
- second copy of the governed workflow.
21
-
22
- Create or refresh the entrypoint with:
23
-
24
- ```bash
25
- sema sync-codex --json
26
- ```
27
-
28
- ## Minimal Prompt
29
-
30
- ```text
31
- This workspace is governed by Sema. Before editing code, contracts, docs,
32
- workflows, profiles, or release scripts, run:
33
-
34
- 1. sema --version
35
- 2. sema resumo
36
- 3. sema docs-impacto --intencao "<change>" --json
37
- 4. sema inspecionar on the applicable .sema contract
38
- 5. sema drift before editing existing code
39
- 6. sema impacto before changing behavior
40
- 7. sema finalizar-mudanca before closing
41
-
42
- If the CLI is unavailable, stop and install or repair @semacode/cli. There is
43
- no separate Sema login, license activation, or authorization gate. Do not
44
- replace Sema with manual search or guessed contracts.
45
- ```
46
-
47
- ## What Codex Should Not Do
48
-
49
- - Do not invent `.sema` contracts.
50
- - Do not implement code without an applicable contract.
51
- - Do not ignore severity 4+ warnings.
52
- - Do not publish private or sensitive operational material.
53
- - Do not replace the local CLI when the local workspace is available.
54
-
55
- Other AI clients can invoke the public CLI manually, but Sema does not ship or
56
- manage an official repository entrypoint for them. The supported product path
57
- is Codex plus `AGENTS.md`.
58
-
59
- Sema is an independent product and is not affiliated with or endorsed by
60
- OpenAI.
61
-
62
- Support: suporte@otimitare.online
1
+ # Codex Onboarding
2
+
3
+ The official Sema skill lets Codex and compatible agents recognize and
4
+ initialize Sema before a project has its own protocol:
5
+
6
+ ```bash
7
+ npm install -g @semacode/cli
8
+ sema skill status --json
9
+ ```
10
+
11
+ The install maintains the canonical copy in `~/.agents/skills/sema` and a Claude
12
+ mirror in `~/.claude/skills/sema` only when Claude is detected. Open a new task
13
+ after installation or update because an already-open task does not reload its
14
+ skill catalog. Invoking `$sema` for information does not initialize the
15
+ workspace. Before implementation, the skill asks for explicit adoption
16
+ authorization; installing or updating the global CLI authorizes distribution
17
+ changes only. After authorized adoption, it reads the generated `AGENTS.md`,
18
+ and later tasks load that protocol automatically.
19
+
20
+ The optional Codex plugin remains available as a separate namespaced channel;
21
+ the npm lifecycle never writes into its cache.
22
+
23
+ `AGENTS.md` is the official Sema entrypoint for Codex. It gives Codex the durable
24
+ repository rule that contracts come first and the local CLI is the source of
25
+ truth. Once the file exists, the skill delegates to it instead of carrying a
26
+ second copy of the governed workflow.
27
+
28
+ Create or refresh the entrypoint with:
29
+
30
+ ```bash
31
+ sema sync-codex --json
32
+ ```
33
+
34
+ ## Minimal Prompt
35
+
36
+ ```text
37
+ This workspace is governed by Sema. Before editing code, contracts, docs,
38
+ workflows, profiles, or release scripts, run:
39
+
40
+ 1. sema --version
41
+ 2. sema resumo --drift none
42
+ 3. sema docs-impacto --intencao "<change>" --json
43
+ 4. sema inspecionar <contract.sema> --drift none --json
44
+ 5. sema drift <contract.sema> --escopo modulo --cache fresh --json before
45
+ editing existing code
46
+ 6. sema impacto before changing behavior
47
+ 7. sema finalizar-mudanca before closing
48
+
49
+ If `sema --version` is unavailable, try the managed absolute launcher at
50
+ `~/.sema/bin/sema` on macOS/Linux. On Windows, PowerShell uses `sema.ps1` from
51
+ `PATH`, `cmd.exe` uses `sema.cmd`, and the absolute PowerShell fallback is:
52
+ & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version
53
+ If that also fails, stop and install or repair @semacode/cli. There is no
54
+ separate Sema login or license-activation gate. Distribution installation does
55
+ not authorize workspace adoption. Do not replace Sema with manual search or
56
+ guessed contracts.
57
+ ```
58
+
59
+ Query commands default to `--drift none`, so their `analiseDrift` envelope marks
60
+ the analysis as not executed and keeps drift-derived evidence `null`. Direct
61
+ `sema drift` defaults to `--cache fresh`; `--cache none` still executes drift
62
+ without persistent cache access. The cache is non-authoritative, lives outside
63
+ the workspace, and safely falls back to recalculation when unavailable or
64
+ corrupt. See [Drift Cache And Query Evidence](./drift-cache.md).
65
+
66
+ ## What Codex Should Not Do
67
+
68
+ - Do not invent `.sema` contracts.
69
+ - Do not implement code without an applicable contract.
70
+ - Do not ignore severity 4+ warnings.
71
+ - Do not publish private or sensitive operational material.
72
+ - Do not replace the local CLI when the local workspace is available.
73
+
74
+ Compatible AI clients can discover the same portable skill through the
75
+ canonical global `.agents/skills` root. Sema does not create client-specific
76
+ repository rules: `AGENTS.md` remains the only official workspace entrypoint.
77
+
78
+ Sema is an independent product and is not affiliated with or endorsed by
79
+ OpenAI.
80
+
81
+ Support: suporte@otimitare.online
@@ -4,20 +4,26 @@
4
4
  This is the minimum workflow for Codex in a local workspace.
5
5
 
6
6
  1. Read `SEMA_BOOT.md`.
7
- 2. Run `sema --version`. Success enables direct local execution; there is no login, license, token, billing, panel, or authorization gate.
8
- 3. Run `sema resumo`.
7
+ 2. Run `sema --version`. If the shell cannot find it, use `$HOME/.sema/bin/sema` on macOS/Linux. On Windows, PowerShell resolves `sema.ps1` from PATH and cmd.exe resolves `sema.cmd`; use `& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version` as the absolute fallback. Only then declare the CLI unavailable.
8
+ 3. Run `sema resumo --drift none` for contract-only orientation; request `--drift cache` or `--drift fresh` only when code evidence is needed.
9
9
  4. Run `sema docs-impacto --intencao "<change>" --json`.
10
10
  5. Read every required document returned by the command.
11
11
  6. Read `docs/commands.md` before selecting a command or interpreting `--saida`.
12
12
  7. If the right capability is unclear, run `sema descobrir recomendar --intencao "<goal>" --json`; do not auto-run ambiguous recommendations.
13
13
  8. Use `exemplos/` and `docs/syntax.md` before creating or editing a contract.
14
- 9. Run `sema drift` and `sema impacto` before editing existing code.
14
+ 9. Run `sema drift --cache fresh` and `sema impacto` before editing existing code.
15
15
  10. Run `sema formatar` and `sema validar` after changing a `.sema` contract.
16
16
  11. Run `sema finalizar-mudanca` with the documents read before closure.
17
17
 
18
18
  Contract edit rule: `.sema` has its own size budget. Above 300 lines, plan a split by domain/capability; above 500, do not create or edit before splitting. Do not use parte_1/parte_2 and do not force a 1:1 contract-to-file relationship; several contracts can govern the same file through `vinculos`.
19
19
 
20
- Closing rule: `sema drift --json` must return `sucesso:true`. If it reports `sucesso:false`, `vinculos_quebrados`, `rotas_divergentes`, or broken impls, the task is still blocked. Passing unit tests do not replace green drift.
20
+ Closing rule: the `payload` of `sema drift --cache fresh --json` must return `sucesso:true`. If it reports `sucesso:false`, `vinculos_quebrados`, `rotas_divergentes`, or `impls_quebrados`, the task is still blocked. Passing unit tests or a cache hit do not replace fresh green drift. In 3.0.0, `ok` describes the CLI result path and never replaces a command-specific domain verdict.
21
+
22
+ Focused drift rule: file and module scopes plan their physical file set before cataloging. They never fall back to a whole-project walk when no safe anchor exists. All indexers and semantic-budget checks reuse the same in-memory source read; a global walk is reserved for explicit `--escopo projeto`. Code discovery is deferred until that plan exists, homonymous candidates fail as ambiguous, and configured contract origins or code roots resolving outside the workspace are rejected before enumeration. `inspecionar`, `impacto`, and `renomear-semantico` preserve the same directed boundary. Missing local dependencies make coverage partial and block success.
23
+
24
+ Cache rule: a closure gate should use `sema drift <contrato> --escopo modulo --cache fresh --json`. `--cache none` executes the same analysis without persistent-cache I/O, while `--cache cache` may reuse only extraction data whose schema, workspace identity, Git HEAD, plan, configuration, contracts, member paths, and strong content digests all match. Cache objects are stored in the operating system's user-cache directory, never below the workspace. A hit is acceleration, not evidence: final links, diagnostics, score, and success are always recalculated. Corruption or an unavailable cache degrades to an in-memory calculation.
25
+
26
+ Query honesty rule: `resumo` and `inspecionar` default to `--drift none`. When analysis is skipped, score, confidence, implementation, routes, and other unobserved code claims inside the command payload must be `null` or explicitly marked not evaluated; zero is not a substitute for absent evidence.
21
27
 
22
28
  UI rule: if the task involves an interface, minimum evidence includes desktop and mobile. On a narrow viewport such as 390px, `document.documentElement.scrollWidth <= document.documentElement.clientWidth` must pass; horizontal scroll blocks closure.
23
29
 
package/docs/auth.md CHANGED
@@ -1,26 +1,26 @@
1
- # Local Runtime Boundary
2
-
3
- The public Sema CLI executes directly against the local workspace. It does not
4
- require a Sema login, user authentication, product authorization, license
5
- activation, install key, token, credits, billing service, control panel, or an
6
- external request.
7
-
8
- Use local commands:
9
-
10
- ```bash
11
- sema --version
12
- sema resumo
13
- sema validar contratos/example.sema --json
14
- ```
15
-
16
- The repository license governs use and redistribution. It is not checked as a
17
- runtime activation mechanism.
18
-
19
- An `authz` block inside a `.sema` contract describes authorization in the
20
- application being governed. It does not authenticate a person before the Sema
21
- CLI can run.
22
-
23
- Do not put private or sensitive operational material in this repository.
24
-
25
- Application-specific authentication belongs in the application repository that
26
- owns it.
1
+ # Local Runtime Boundary
2
+
3
+ The public Sema CLI executes directly against the local workspace. It does not
4
+ require a Sema login, user authentication, product authorization, license
5
+ activation, install key, token, credits, billing service, control panel, or an
6
+ external request.
7
+
8
+ Use local commands:
9
+
10
+ ```bash
11
+ sema --version
12
+ sema resumo
13
+ sema validar contratos/example.sema --json
14
+ ```
15
+
16
+ The repository license governs use and redistribution. It is not checked as a
17
+ runtime activation mechanism.
18
+
19
+ An `authz` block inside a `.sema` contract describes authorization in the
20
+ application being governed. It does not authenticate a person before the Sema
21
+ CLI can run.
22
+
23
+ Do not put private or sensitive operational material in this repository.
24
+
25
+ Application-specific authentication belongs in the application repository that
26
+ owns it.