@semacode/cli 2.3.1 → 3.5.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 (281) hide show
  1. package/README.md +265 -217
  2. package/dist/agentContextPack.js +14 -10
  3. package/dist/agentEntryPoints.d.ts +5 -0
  4. package/dist/agentEntryPoints.js +592 -568
  5. package/dist/angular-consumer-standalone.js +1 -1
  6. package/dist/bin.d.ts +6 -0
  7. package/dist/bin.js +130 -0
  8. package/dist/cliArgs.js +4 -4
  9. package/dist/cliControlError.d.ts +12 -0
  10. package/dist/cliControlError.js +47 -0
  11. package/dist/cliGrammar.d.ts +11 -0
  12. package/dist/cliGrammar.js +551 -0
  13. package/dist/cliHelp.d.ts +13 -0
  14. package/dist/cliHelp.js +19 -0
  15. package/dist/cliHelpTexto.d.ts +3 -0
  16. package/dist/cliHelpTexto.js +168 -0
  17. package/dist/cliRuntime.d.ts +2 -0
  18. package/dist/cliRuntime.js +31 -0
  19. package/dist/comandos.js +9 -22
  20. package/dist/contexto.js +5 -5
  21. package/dist/dev/index.d.ts +1 -0
  22. package/dist/dev/index.js +51 -9
  23. package/dist/discovery/catalog.js +3 -3
  24. package/dist/distribuicao/filesystemGlobal.d.ts +63 -0
  25. package/dist/distribuicao/filesystemGlobal.js +701 -0
  26. package/dist/distribuicao/index.d.ts +7 -0
  27. package/dist/distribuicao/index.js +227 -0
  28. package/dist/distribuicao/launcherGlobal.d.ts +53 -0
  29. package/dist/distribuicao/launcherGlobal.js +643 -0
  30. package/dist/distribuicao/launcherWindows.d.ts +28 -0
  31. package/dist/distribuicao/launcherWindows.js +326 -0
  32. package/dist/distribuicao/lockContextGlobal.d.ts +10 -0
  33. package/dist/distribuicao/lockContextGlobal.js +17 -0
  34. package/dist/distribuicao/lockGlobal.d.ts +6 -0
  35. package/dist/distribuicao/lockGlobal.js +520 -0
  36. package/dist/distribuicao/skillGlobal.d.ts +48 -0
  37. package/dist/distribuicao/skillGlobal.js +652 -0
  38. package/dist/distribuicao/skillIntentPolicy.d.ts +21 -0
  39. package/dist/distribuicao/skillIntentPolicy.js +115 -0
  40. package/dist/distribuicao/tipos.d.ts +50 -0
  41. package/dist/distribuicao/tipos.js +10 -0
  42. package/dist/distribuicao/versaoSemantica.d.ts +3 -0
  43. package/dist/distribuicao/versaoSemantica.js +62 -0
  44. package/dist/docs.part01.d.ts +4 -1
  45. package/dist/docs.part01.js +8 -0
  46. package/dist/docs.part02.js +9 -1
  47. package/dist/drift.part01.d.ts +33 -25
  48. package/dist/drift.part01.js +2 -1
  49. package/dist/drift.part04.d.ts +26 -5
  50. package/dist/drift.part04.js +123 -19
  51. package/dist/drift.part05.d.ts +2 -2
  52. package/dist/drift.part05.js +8 -6
  53. package/dist/drift.part06.d.ts +2 -2
  54. package/dist/drift.part06.js +113 -26
  55. package/dist/drift.part07.d.ts +11 -11
  56. package/dist/drift.part07.js +261 -265
  57. package/dist/drift.part08.d.ts +2 -2
  58. package/dist/drift.part08.js +35 -26
  59. package/dist/drift.part09.d.ts +2 -2
  60. package/dist/drift.part09.js +10 -3
  61. package/dist/drift.part11.js +261 -58
  62. package/dist/drift.part12.d.ts +1 -1
  63. package/dist/drift.part12.js +193 -21
  64. package/dist/drift.part13.d.ts +20 -39
  65. package/dist/drift.part13.js +601 -647
  66. package/dist/drift.part14.js +23 -7
  67. package/dist/driftCacheCas.d.ts +43 -0
  68. package/dist/driftCacheCas.js +351 -0
  69. package/dist/driftCacheFilesystem.d.ts +64 -0
  70. package/dist/driftCacheFilesystem.js +313 -0
  71. package/dist/driftCacheModes.d.ts +38 -0
  72. package/dist/driftCacheModes.js +147 -0
  73. package/dist/driftCacheStore.d.ts +80 -0
  74. package/dist/driftCacheStore.js +603 -0
  75. package/dist/driftCatalogo.d.ts +2 -28
  76. package/dist/driftCatalogo.js +143 -284
  77. package/dist/driftEscopo.d.ts +1 -3
  78. package/dist/driftEscopo.js +235 -151
  79. package/dist/driftEscopoReferencias.d.ts +5 -1
  80. package/dist/driftEscopoReferencias.js +375 -28
  81. package/dist/driftOrcamento.d.ts +0 -6
  82. package/dist/driftOrcamento.js +2 -1
  83. package/dist/execucoesExternas.js +19 -5
  84. package/dist/exemplosOficiais.d.ts +2 -1
  85. package/dist/exemplosOficiais.js +9 -3
  86. package/dist/geracaoCore.d.ts +1 -0
  87. package/dist/geracaoCore.js +6 -6
  88. package/dist/iaPrompts.d.ts +3 -3
  89. package/dist/iaPrompts.js +312 -313
  90. package/dist/importador.part01.d.ts +1 -1
  91. package/dist/importador.part06.d.ts +2 -0
  92. package/dist/importador.part06.js +87 -1
  93. package/dist/importador.part09.js +7 -1
  94. package/dist/index.d.ts +4 -1
  95. package/dist/index.js +6 -25
  96. package/dist/index.part01.d.ts +20 -28
  97. package/dist/index.part01.js +16 -237
  98. package/dist/index.part02.js +36 -22
  99. package/dist/index.part03.d.ts +24 -2
  100. package/dist/index.part03.js +83 -19
  101. package/dist/index.part04.d.ts +10 -2
  102. package/dist/index.part04.js +152 -123
  103. package/dist/index.part05.js +80 -78
  104. package/dist/index.part06.js +34 -17
  105. package/dist/index.part07.d.ts +8 -2
  106. package/dist/index.part07.js +153 -7
  107. package/dist/index.part08.d.ts +1 -1
  108. package/dist/index.part08.js +25 -30
  109. package/dist/initCommand.d.ts +1 -0
  110. package/dist/initCommand.js +20 -4
  111. package/dist/initTemplatesBase.js +6 -4
  112. package/dist/pipelineConteudo/command.d.ts +1 -0
  113. package/dist/pipelineConteudo/command.js +9 -2
  114. package/dist/pipelineConteudo/help.d.ts +2 -0
  115. package/dist/pipelineConteudo/help.js +33 -0
  116. package/dist/profileAuthorCommand.js +3 -7
  117. package/dist/profileCommand.js +3 -7
  118. package/dist/projetoCarregar.js +35 -17
  119. package/dist/projetoCatalogo.d.ts +1 -0
  120. package/dist/projetoCatalogo.js +64 -25
  121. package/dist/projetoConfig.js +2 -0
  122. package/dist/projetoLegado.js +18 -0
  123. package/dist/projetoOrigens.d.ts +2 -0
  124. package/dist/projetoOrigens.js +65 -9
  125. package/dist/projetoTipos.d.ts +1 -0
  126. package/dist/resultadoCli.d.ts +20 -0
  127. package/dist/resultadoCli.js +57 -0
  128. package/dist/saidaCli.d.ts +35 -0
  129. package/dist/saidaCli.js +118 -0
  130. package/dist/sistemasInterativos/acceptanceEvidence.d.ts +22 -0
  131. package/dist/sistemasInterativos/acceptanceEvidence.js +345 -0
  132. package/dist/sistemasInterativos/engineObservation.d.ts +12 -0
  133. package/dist/sistemasInterativos/engineObservation.js +438 -0
  134. package/dist/sistemasInterativos/jobOrchestration.d.ts +2 -0
  135. package/dist/sistemasInterativos/jobOrchestration.js +204 -0
  136. package/dist/sistemasInterativos/operationPrimitives.d.ts +21 -0
  137. package/dist/sistemasInterativos/operationPrimitives.js +194 -0
  138. package/dist/sistemasInterativos/operations.d.ts +4 -39
  139. package/dist/sistemasInterativos/operations.js +5 -1164
  140. package/dist/skillCommand.d.ts +5 -0
  141. package/dist/skillCommand.js +88 -0
  142. package/dist/tipos.d.ts +1 -1
  143. package/dist/typescript-http-modelos.d.ts +1 -1
  144. package/dist/typescript-http-rotas.d.ts +1 -0
  145. package/dist/typescript-http-rotas.js +93 -0
  146. package/dist/typescript-http.d.ts +1 -1
  147. package/dist/typescript-http.js +1 -1
  148. package/dist/verificacaoCache.d.ts +25 -0
  149. package/dist/verificacaoCache.js +80 -0
  150. package/docs/README.md +34 -30
  151. package/docs/ai-integration.md +25 -12
  152. package/docs/ai-onboarding.md +37 -18
  153. package/docs/ai-workflow.md +9 -7
  154. package/docs/cli.md +125 -7
  155. package/docs/commands.md +41 -20
  156. package/docs/deploy.md +21 -8
  157. package/docs/descoberta-capacidades.md +106 -106
  158. package/docs/documentation.md +49 -39
  159. package/docs/drift-cache.md +108 -0
  160. package/docs/getting-started.md +43 -18
  161. package/docs/pipeline-conteudo.md +246 -246
  162. package/docs/profiles.md +54 -54
  163. package/docs/repositories.md +19 -2
  164. package/docs/rollback.md +15 -8
  165. package/docs/security.md +25 -3
  166. package/docs/sistemas-interativos.md +379 -374
  167. package/docs/syntax.md +14 -0
  168. package/docs/testing.md +139 -40
  169. package/exemplos/express_crud.sema +139 -0
  170. package/exemplos/fastify_crud.sema +146 -0
  171. package/exemplos/pipeline-conteudo/README.md +44 -44
  172. package/exemplos/pipeline-conteudo/alvos.json +23 -23
  173. package/exemplos/pipeline-conteudo/definicao.json +136 -136
  174. package/exemplos/profile_simulation.sema +211 -211
  175. package/exemplos/sistemas-interativos/README.md +100 -100
  176. package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -5
  177. package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -16
  178. package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -32
  179. package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -93
  180. package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -78
  181. package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -27
  182. package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -79
  183. package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -42
  184. package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -32
  185. package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -23
  186. package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -39
  187. package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -46
  188. package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -39
  189. package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -37
  190. package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -104
  191. package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -27
  192. package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -118
  193. package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -459
  194. package/exemplos/sistemas-interativos/game-2d.json +83 -83
  195. package/exemplos/sistemas-interativos/game-3d-human.json +81 -81
  196. package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -97
  197. package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -94
  198. package/exemplos/sistemas-interativos/game-xr-human.json +80 -80
  199. package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -108
  200. package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -75
  201. package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -58
  202. package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -97
  203. package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -141
  204. package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -112
  205. package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -103
  206. package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -95
  207. package/node_modules/@sema/gerador-cpp/package.json +1 -1
  208. package/node_modules/@sema/gerador-dotnet/package.json +1 -1
  209. package/node_modules/@sema/gerador-lua/dist/index.js +51 -51
  210. package/node_modules/@sema/gerador-php/dist/index.js +113 -113
  211. package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js +37 -38
  212. package/node_modules/@sema/nucleo/dist/ir/modelos.d.ts +1 -0
  213. package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +1 -0
  214. package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
  215. package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.d.ts +7 -0
  216. package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js +33 -10
  217. package/package.json +9 -4
  218. package/scripts/postinstall.mjs +148 -0
  219. package/skills/sema/SKILL.md +199 -0
  220. package/skills/sema/agents/openai.yaml +4 -0
  221. package/dist/driftCache.d.ts +0 -49
  222. package/dist/driftCache.js +0 -311
  223. package/dist/driftCacheIncremental.d.ts +0 -98
  224. package/dist/driftCacheIncremental.js +0 -596
  225. package/dist/driftCatalogoPersistente.d.ts +0 -8
  226. package/dist/driftCatalogoPersistente.js +0 -77
  227. package/node_modules/@sema/gerador-cpp/dist/index.js.map +0 -1
  228. package/node_modules/@sema/gerador-css/dist/index.js.map +0 -1
  229. package/node_modules/@sema/gerador-css/dist/index.part01.js.map +0 -1
  230. package/node_modules/@sema/gerador-css/dist/index.part02.js.map +0 -1
  231. package/node_modules/@sema/gerador-dart/dist/index.js.map +0 -1
  232. package/node_modules/@sema/gerador-dotnet/dist/index.js.map +0 -1
  233. package/node_modules/@sema/gerador-html/dist/index.js.map +0 -1
  234. package/node_modules/@sema/gerador-javascript/dist/index.js.map +0 -1
  235. package/node_modules/@sema/gerador-lua/dist/index.js.map +0 -1
  236. package/node_modules/@sema/gerador-php/dist/index.js.map +0 -1
  237. package/node_modules/@sema/gerador-python/dist/index.js.map +0 -1
  238. package/node_modules/@sema/gerador-python/dist/index.part01.js.map +0 -1
  239. package/node_modules/@sema/gerador-python/dist/index.part02.js.map +0 -1
  240. package/node_modules/@sema/gerador-typescript/dist/index.js.map +0 -1
  241. package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +0 -1
  242. package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +0 -1
  243. package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +0 -1
  244. package/node_modules/@sema/nucleo/dist/ast/tipos.js.map +0 -1
  245. package/node_modules/@sema/nucleo/dist/diagnosticos/index.js.map +0 -1
  246. package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +0 -1
  247. package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +0 -1
  248. package/node_modules/@sema/nucleo/dist/formatador/index.js.map +0 -1
  249. package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +0 -1
  250. package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +0 -1
  251. package/node_modules/@sema/nucleo/dist/index.js.map +0 -1
  252. package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +0 -1
  253. package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +0 -1
  254. package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +0 -1
  255. package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +0 -1
  256. package/node_modules/@sema/nucleo/dist/ir/modelos.js.map +0 -1
  257. package/node_modules/@sema/nucleo/dist/lexer/lexer.js.map +0 -1
  258. package/node_modules/@sema/nucleo/dist/lexer/tokens.js.map +0 -1
  259. package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +0 -1
  260. package/node_modules/@sema/nucleo/dist/parser/parser.js.map +0 -1
  261. package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +0 -1
  262. package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +0 -1
  263. package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +0 -1
  264. package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +0 -1
  265. package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +0 -1
  266. package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +0 -1
  267. package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +0 -1
  268. package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +0 -1
  269. package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +0 -1
  270. package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +0 -1
  271. package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +0 -1
  272. package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +0 -1
  273. package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +0 -1
  274. package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +0 -1
  275. package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +0 -1
  276. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +0 -1
  277. package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +0 -1
  278. package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +0 -1
  279. package/node_modules/@sema/nucleo/dist/semantico/seguranca.js.map +0 -1
  280. package/node_modules/@sema/nucleo/dist/util/arquivos.js.map +0 -1
  281. 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
package/dist/tipos.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export type EstruturaSaida = "flat" | "modulos" | "backend";
2
- export type FonteLegado = "nestjs" | "fastapi" | "flask" | "nextjs" | "nextjs-consumer" | "react-vite-consumer" | "angular-consumer" | "flutter-consumer" | "firebase" | "typescript" | "javascript" | "python" | "dart" | "lua" | "dotnet" | "java" | "go" | "rust" | "cpp" | "php";
2
+ export type FonteLegado = "nestjs" | "express" | "fastify" | "fastapi" | "flask" | "nextjs" | "nextjs-consumer" | "react-vite-consumer" | "angular-consumer" | "flutter-consumer" | "firebase" | "typescript" | "javascript" | "python" | "dart" | "lua" | "dotnet" | "java" | "go" | "rust" | "cpp" | "php";
3
3
  export type ModoAdocao = "incremental";
@@ -4,7 +4,7 @@ export interface ParametroRotaTypeScript {
4
4
  tipoSema: "Texto" | "Inteiro" | "Decimal" | "Id";
5
5
  }
6
6
  export interface RotaTypeScriptExtraida {
7
- origem: "nextjs" | "firebase";
7
+ origem: "nextjs" | "firebase" | "express" | "fastify";
8
8
  metodo: string;
9
9
  caminho: string;
10
10
  simbolo: string;
@@ -6,4 +6,5 @@ export declare function inferirCaminhoNext(relacaoArquivo: string): {
6
6
  } | undefined;
7
7
  export declare function identificarRotasNodeHttp(sourceFile: ts.SourceFile, nomeSimbolo: string, corpo: ts.Block): RotaTypeScriptExtraida[];
8
8
  export declare function extrairRotasNodeWorker(sourceFile: ts.SourceFile, relacaoArquivo: string): RotaTypeScriptExtraida[];
9
+ export declare function extrairRotasExpressFastify(sourceFile: ts.SourceFile): RotaTypeScriptExtraida[];
9
10
  export declare function extrairRotasTypeScriptHttp(sourceFile: ts.SourceFile, relacaoArquivo: string): RotaTypeScriptExtraida[];
@@ -109,6 +109,98 @@ export function extrairRotasNodeWorker(sourceFile, relacaoArquivo) {
109
109
  }
110
110
  return deduplicarRotas(rotas);
111
111
  }
112
+ export function extrairRotasExpressFastify(sourceFile) {
113
+ const textoArquivo = sourceFile.getFullText();
114
+ const importouExpress = /(?:from\s+["']express["']|require\(\s*["']express["']\s*\))/.test(textoArquivo);
115
+ const importouFastify = /(?:from\s+["']fastify["']|require\(\s*["']fastify["']\s*\))/.test(textoArquivo);
116
+ if (!importouExpress && !importouFastify) {
117
+ return [];
118
+ }
119
+ const rotas = [];
120
+ const escolherOrigemChamada = (receptor) => {
121
+ if (/fastify/i.test(receptor)) {
122
+ return "fastify";
123
+ }
124
+ if (importouExpress) {
125
+ return "express";
126
+ }
127
+ if (importouFastify) {
128
+ return "fastify";
129
+ }
130
+ return undefined;
131
+ };
132
+ const visitar = (node) => {
133
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression)) {
134
+ const receptor = node.expression.expression.text;
135
+ const nomeMetodo = node.expression.name.text.toLowerCase();
136
+ if (nomeMetodo === "route" && node.arguments[0] && ts.isObjectLiteralExpression(node.arguments[0]) && importouFastify) {
137
+ let metodo;
138
+ let caminho;
139
+ for (const propriedade of node.arguments[0].properties) {
140
+ if (!ts.isPropertyAssignment(propriedade) || !ts.isIdentifier(propriedade.name)) {
141
+ continue;
142
+ }
143
+ const valor = propriedade.initializer && ts.isStringLiteralLike(propriedade.initializer)
144
+ ? propriedade.initializer.text
145
+ : undefined;
146
+ if (propriedade.name.text === "method" && valor) {
147
+ metodo = valor.toUpperCase();
148
+ }
149
+ if (propriedade.name.text === "url" && valor) {
150
+ caminho = valor;
151
+ }
152
+ }
153
+ if (metodo && caminho?.startsWith("/") && METODOS_HTTP.has(metodo)) {
154
+ rotas.push({
155
+ origem: "fastify",
156
+ metodo,
157
+ caminho: converterCaminhoParametros(caminho),
158
+ simbolo: receptor,
159
+ parametros: extrairParametrosCaminhoDoisPontos(caminho),
160
+ });
161
+ }
162
+ }
163
+ else if (nomeMetodo === "all" || METODOS_HTTP.has(nomeMetodo.toUpperCase())) {
164
+ const caminho = node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])
165
+ ? node.arguments[0].text
166
+ : undefined;
167
+ const origem = escolherOrigemChamada(receptor);
168
+ const handler = node.arguments[1] && ts.isIdentifier(node.arguments[1]) ? node.arguments[1].text : undefined;
169
+ if (caminho?.startsWith("/") && origem) {
170
+ const metodos = nomeMetodo === "all"
171
+ ? ["GET", "POST", "PUT", "PATCH", "DELETE"]
172
+ : [nomeMetodo.toUpperCase()];
173
+ for (const metodo of metodos) {
174
+ rotas.push({
175
+ origem,
176
+ metodo,
177
+ caminho: converterCaminhoParametros(caminho),
178
+ simbolo: handler ?? receptor,
179
+ parametros: extrairParametrosCaminhoDoisPontos(caminho),
180
+ });
181
+ }
182
+ }
183
+ }
184
+ }
185
+ node.forEachChild(visitar);
186
+ };
187
+ visitar(sourceFile);
188
+ return deduplicarRotas(rotas);
189
+ }
190
+ function converterCaminhoParametros(caminho) {
191
+ return caminho.replace(/:([A-Za-z_]\w*)/g, "{$1}");
192
+ }
193
+ function extrairParametrosCaminhoDoisPontos(caminho) {
194
+ const parametros = [];
195
+ for (const correspondencia of caminho.matchAll(/:([A-Za-z_]\w*)/g)) {
196
+ const nome = correspondencia[1];
197
+ parametros.push({
198
+ nome,
199
+ tipoSema: /(^|_)id$/i.test(nome) ? "Id" : "Texto",
200
+ });
201
+ }
202
+ return parametros;
203
+ }
112
204
  export function extrairRotasTypeScriptHttp(sourceFile, relacaoArquivo) {
113
205
  const rotas = [];
114
206
  const caminhoNext = inferirCaminhoNext(relacaoArquivo);
@@ -124,6 +216,7 @@ export function extrairRotasTypeScriptHttp(sourceFile, relacaoArquivo) {
124
216
  }
125
217
  }
126
218
  rotas.push(...extrairRotasNodeWorker(sourceFile, relacaoArquivo));
219
+ rotas.push(...extrairRotasExpressFastify(sourceFile));
127
220
  return deduplicarRotas(rotas);
128
221
  }
129
222
  //# sourceMappingURL=typescript-http-rotas.js.map
@@ -1,3 +1,3 @@
1
1
  export type { CampoInferidoTypeScriptHttp, ExportacaoTypeScriptHttp, ParametroRotaTypeScript, RotaTypeScriptExtraida, SemanticaHandlerTypeScriptHttp, } from "./typescript-http-modelos.js";
2
- export { extrairRotasTypeScriptHttp } from "./typescript-http-rotas.js";
2
+ export { extrairRotasExpressFastify, extrairRotasTypeScriptHttp } from "./typescript-http-rotas.js";
3
3
  export { inferirSemanticaHandlerTypeScriptHttp, localizarExportacaoTypeScriptHttp, } from "./typescript-http-semantica.js";
@@ -1,5 +1,5 @@
1
1
  // SEMA-GOVERNED: sema.governanca_ia_contexto
2
2
  // Descricao: fachada de extracao HTTP TypeScript; consulte contratos/sema/governanca_ia_contexto.sema antes de editar.
3
- export { extrairRotasTypeScriptHttp } from "./typescript-http-rotas.js";
3
+ export { extrairRotasExpressFastify, extrairRotasTypeScriptHttp } from "./typescript-http-rotas.js";
4
4
  export { inferirSemanticaHandlerTypeScriptHttp, localizarExportacaoTypeScriptHttp, } from "./typescript-http-semantica.js";
5
5
  //# sourceMappingURL=typescript-http.js.map
@@ -0,0 +1,25 @@
1
+ export declare const SCHEMA_CACHE_VERIFICACAO = "sema.verificacao-cache/v1";
2
+ export interface EntradaCacheVerificacao {
3
+ schemaVersion: typeof SCHEMA_CACHE_VERIFICACAO;
4
+ chave: string;
5
+ versaoCli: string;
6
+ alvo: string;
7
+ modulo: string;
8
+ sucesso: boolean;
9
+ quantidadeTestes: number;
10
+ testesExecutados: boolean;
11
+ arquivosGerados: string[];
12
+ geradoEm: string;
13
+ }
14
+ export declare function calcularChaveVerificacao(entradas: {
15
+ versaoCli: string;
16
+ versaoNode: string;
17
+ modulo: string;
18
+ alvo: string;
19
+ framework: string;
20
+ estrutura: string;
21
+ conteudoContrato: string;
22
+ }): string;
23
+ export declare function carregarCacheVerificacao(chave: string, pastaAlvo: string, raizCache?: string): Promise<EntradaCacheVerificacao | undefined>;
24
+ export declare function carregarManifestoVerificacao(chave: string, raizCache?: string): Promise<EntradaCacheVerificacao | undefined>;
25
+ export declare function gravarCacheVerificacao(entrada: EntradaCacheVerificacao, raizCache?: string): Promise<void>;
@@ -0,0 +1,80 @@
1
+ // SEMA-GOVERNED: sema.produto.cli_verificacao
2
+ // Descrição: cache incremental de verificação fora do workspace, endereçado por conteúdo do contrato.
3
+ import { createHash } from "node:crypto";
4
+ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
5
+ import path from "node:path";
6
+ import { resolverRaizCacheSema } from "./driftCacheFilesystem.js";
7
+ export const SCHEMA_CACHE_VERIFICACAO = "sema.verificacao-cache/v1";
8
+ export function calcularChaveVerificacao(entradas) {
9
+ return createHash("sha256")
10
+ .update(JSON.stringify({
11
+ schemaVersion: SCHEMA_CACHE_VERIFICACAO,
12
+ versaoCli: entradas.versaoCli,
13
+ versaoNode: entradas.versaoNode,
14
+ modulo: entradas.modulo,
15
+ alvo: entradas.alvo,
16
+ framework: entradas.framework,
17
+ estrutura: entradas.estrutura,
18
+ conteudoContrato: entradas.conteudoContrato,
19
+ }))
20
+ .digest("hex");
21
+ }
22
+ function resolverPastaCacheVerificacao(raizCache) {
23
+ const resolucao = resolverRaizCacheSema(raizCache ? { raizCache } : {});
24
+ return resolucao.disponivel ? path.join(resolucao.raiz, "verificacao") : undefined;
25
+ }
26
+ export async function carregarCacheVerificacao(chave, pastaAlvo, raizCache) {
27
+ const pasta = resolverPastaCacheVerificacao(raizCache);
28
+ if (!pasta) {
29
+ return undefined;
30
+ }
31
+ let entrada;
32
+ try {
33
+ entrada = JSON.parse(await readFile(path.join(pasta, `${chave}.json`), "utf8"));
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ if (entrada.schemaVersion !== SCHEMA_CACHE_VERIFICACAO || entrada.chave !== chave) {
39
+ return undefined;
40
+ }
41
+ for (const relativo of entrada.arquivosGerados) {
42
+ try {
43
+ await stat(path.join(pastaAlvo, relativo));
44
+ }
45
+ catch {
46
+ return undefined;
47
+ }
48
+ }
49
+ return entrada;
50
+ }
51
+ export async function carregarManifestoVerificacao(chave, raizCache) {
52
+ const pasta = resolverPastaCacheVerificacao(raizCache);
53
+ if (!pasta) {
54
+ return undefined;
55
+ }
56
+ try {
57
+ const entrada = JSON.parse(await readFile(path.join(pasta, `${chave}.json`), "utf8"));
58
+ if (entrada.schemaVersion !== SCHEMA_CACHE_VERIFICACAO || entrada.chave !== chave) {
59
+ return undefined;
60
+ }
61
+ return entrada;
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ export async function gravarCacheVerificacao(entrada, raizCache) {
68
+ const pasta = resolverPastaCacheVerificacao(raizCache);
69
+ if (!pasta) {
70
+ return;
71
+ }
72
+ try {
73
+ await mkdir(pasta, { recursive: true });
74
+ await writeFile(path.join(pasta, `${entrada.chave}.json`), `${JSON.stringify(entrada, null, 2)}\n`, "utf8");
75
+ }
76
+ catch {
77
+ // Cache é aceleração: falha de gravação nunca derruba a verificação.
78
+ }
79
+ }
80
+ //# sourceMappingURL=verificacaoCache.js.map
package/docs/README.md CHANGED
@@ -1,34 +1,38 @@
1
- # Sema Documentation
2
-
3
- These docs describe the public Codex-native local CLI distribution of Sema.
4
-
1
+ # Sema Documentation
2
+
3
+ These docs describe the public Codex-native local CLI distribution of Sema.
4
+
5
5
  Sema is local-first: Codex runs the CLI inside a project folder, reads `.sema`
6
6
  contracts, checks drift, maps impact, and closes changes with documentation
7
- evidence. `AGENTS.md` is the official Codex entrypoint. Public docs are written
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
8
11
  in English.
9
-
10
- Sema is an independent product and is not affiliated with or endorsed by
11
- OpenAI. Codex-native describes Sema's product direction, not an official OpenAI
12
- program or submission.
13
-
14
- Start here:
15
-
16
- - [CLI](./cli.md)
17
- - [Commands](./commands.md)
12
+
13
+ Sema is an independent product and is not affiliated with or endorsed by
14
+ OpenAI. Codex-native describes Sema's product direction, not an official OpenAI
15
+ program or submission.
16
+
17
+ Start here:
18
+
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)
18
22
  - [Syntax](./syntax.md)
19
- - [Profiles](./profiles.md)
20
- - [Capability Discovery](./descoberta-capacidades.md) — one explainable catalog
21
- for governance flows, profiles, specialized workflows, pipelines, generators,
22
- capability tokens, and adapters.
23
- - [AI-native Interactive Systems](./sistemas-interativos.md) — declarative
24
- control plane for games, simulations, and hybrids across 3D, 2D, retro,
25
- text, XR, and headless execution.
26
- - [AI-native Content Pipeline](./pipeline-conteudo.md) — signed-policy,
27
- multi-channel and multi-format orchestration for external AI runners, with
28
- canonical ledger replay and no native human-review path.
29
- - [Documentation Governance](./documentation.md)
30
- - [Repository Boundary](./repositories.md)
31
- - [Security](./security.md)
32
- - [Codex Integration](./ai-integration.md)
33
-
34
- Official support: [suporte@otimitare.online](mailto:suporte@otimitare.online)
23
+ - [Profiles](./profiles.md)
24
+ - [Capability Discovery](./descoberta-capacidades.md) — one explainable catalog
25
+ for governance flows, profiles, specialized workflows, pipelines, generators,
26
+ capability tokens, and adapters.
27
+ - [AI-native Interactive Systems](./sistemas-interativos.md) — declarative
28
+ control plane for games, simulations, and hybrids across 3D, 2D, retro,
29
+ text, XR, and headless execution.
30
+ - [AI-native Content Pipeline](./pipeline-conteudo.md) — signed-policy,
31
+ multi-channel and multi-format orchestration for external AI runners, with
32
+ canonical ledger replay and no native human-review path.
33
+ - [Documentation Governance](./documentation.md)
34
+ - [Repository Boundary](./repositories.md)
35
+ - [Security](./security.md)
36
+ - [Codex Integration](./ai-integration.md)
37
+
38
+ Official support: [suporte@otimitare.online](mailto:suporte@otimitare.online)
@@ -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
 
@@ -73,6 +80,12 @@ Generated or governed code should keep a short `SEMA-GOVERNED` marker that
73
80
  points back to the applicable contract. The marker is not a substitute for
74
81
  validation, drift, impact, or finalization gates.
75
82
 
83
+ Generated Lua tests preserve the contract's failure shape. A case whose only
84
+ expectation is `sucesso: falso` may terminate without an output, while a case
85
+ that also declares observable output fields must return a structured failure
86
+ result. The generator keeps these paths distinct instead of forcing every
87
+ failure into one representation.
88
+
76
89
  Governed code above 1000 lines requires a
77
90
  split plan. Governed code above 2000
78
91
  lines blocks closure. Markdown documentation is not counted as governed code
@@ -106,4 +119,4 @@ user-facing experience, closure requires evidence:
106
119
  ## Platform Policy
107
120
 
108
121
  Sema governs contract, scope, drift, evidence, and quality. It does not bypass
109
- platform policies, terms of use, permissions, security controls, or laws.
122
+ platform policies, terms of use, permissions, security controls, or laws.
@@ -1,18 +1,24 @@
1
1
  # Codex Onboarding
2
2
 
3
- The official Sema skill is required for Codex to recognize and initialize Sema
4
- before a project has its own protocol:
3
+ The official Sema skill lets Codex and compatible agents recognize and
4
+ initialize Sema before a project has its own protocol:
5
5
 
6
6
  ```bash
7
- codex plugin marketplace add gerlanss/Sema
8
- codex plugin add sema@sema
7
+ npm install -g @semacode/cli
8
+ sema skill status --json
9
9
  ```
10
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.
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.
16
22
 
17
23
  `AGENTS.md` is the official Sema entrypoint for Codex. It gives Codex the durable
18
24
  repository rule that contracts come first and the local CLI is the source of
@@ -32,18 +38,31 @@ This workspace is governed by Sema. Before editing code, contracts, docs,
32
38
  workflows, profiles, or release scripts, run:
33
39
 
34
40
  1. sema --version
35
- 2. sema resumo
41
+ 2. sema resumo --drift none
36
42
  3. sema docs-impacto --intencao "<change>" --json
37
- 4. sema inspecionar on the applicable .sema contract
38
- 5. sema drift before editing existing code
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
39
46
  6. sema impacto before changing behavior
40
47
  7. sema finalizar-mudanca before closing
41
48
 
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.
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.
45
57
  ```
46
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
+
47
66
  ## What Codex Should Not Do
48
67
 
49
68
  - Do not invent `.sema` contracts.
@@ -52,9 +71,9 @@ replace Sema with manual search or guessed contracts.
52
71
  - Do not publish private or sensitive operational material.
53
72
  - Do not replace the local CLI when the local workspace is available.
54
73
 
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`.
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.
58
77
 
59
78
  Sema is an independent product and is not affiliated with or endorsed by
60
79
  OpenAI.
@@ -4,26 +4,28 @@
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
21
 
22
- 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.
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.
23
25
 
24
- Focused inspection rule: `sema inspecionar <contrato.sema>` and `sema resumo <contrato.sema> --micro` default to `--drift none`. They load the target plus its transitive `use` closure and must state that live code was not verified. Use `--drift cache`, `--drift fresh`, or `--com-drift` only when implementation evidence is required.
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.
25
27
 
26
- Drift scope rule: a file/module run plans its physical file set before cataloging and never falls back to a whole-project walk when no safe anchor exists. `--cache auto` reuses validated catalog, file, and semantic-group entries; `--cache refresh` recalculates them; `--cache off` disables persistent cache I/O. Inspect `escopo_aplicado.catalogo`, `escopo_aplicado.cache.incremental`, and `escopo_aplicado.cache.fasesMs` for the work actually performed.
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.
27
29
 
28
30
  ## Codex Context Capacity
29
31