@semacode/cli 3.8.0 → 3.8.2

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.
@@ -1,5 +1,5 @@
1
1
  // SEMA-GOVERNED: sema.produto.cli_init_templates, sema.produto.governanca_ia.drift.cache.modos
2
- // Descrição: contrato base e dispatcher dos templates Codex-native de inicialização.
2
+ // Descrição: contrato base e dispatcher dos templates multi-agente de inicialização.
3
3
  import { arquivosInitTemplatesBackend } from "./initTemplatesBackend.js";
4
4
  import { arquivosInitTemplatesWeb } from "./initTemplatesWeb.js";
5
5
  import { arquivosInitTemplatesFlutter } from "./initTemplatesFlutter.js";
@@ -8,54 +8,54 @@ export function arquivosBaseIniciar() {
8
8
  return [
9
9
  {
10
10
  caminhoRelativo: "contratos/pedidos.sema",
11
- conteudo: `module app.pedidos {
12
- entity Pedido {
13
- fields {
14
- id: Id
15
- status: Texto
16
- total: Decimal
17
- }
18
- }
19
-
20
- task criar_pedido {
21
- input {
22
- cliente_id: Id required
23
- total: Decimal required
24
- }
25
- output {
26
- pedido_id: Id
27
- status: Texto
28
- }
29
- rules {
30
- total > 0
31
- }
32
- effects {
33
- persistencia Pedido criticidade=alta
34
- auditoria pedidos
35
- }
36
- guarantees {
37
- pedido_id existe
38
- status existe
39
- }
40
- tests {
41
- caso "pedido valido" {
42
- given {
43
- cliente_id: "cli-1"
44
- total: 10
45
- }
46
- expect {
47
- sucesso: verdadeiro
48
- }
49
- }
50
- }
51
- }
52
-
53
- route criar_pedido_publico {
54
- metodo: POST
55
- caminho: /pedidos
56
- task: criar_pedido
57
- }
58
- }
11
+ conteudo: `module app.pedidos {
12
+ entity Pedido {
13
+ fields {
14
+ id: Id
15
+ status: Texto
16
+ total: Decimal
17
+ }
18
+ }
19
+
20
+ task criar_pedido {
21
+ input {
22
+ cliente_id: Id required
23
+ total: Decimal required
24
+ }
25
+ output {
26
+ pedido_id: Id
27
+ status: Texto
28
+ }
29
+ rules {
30
+ total > 0
31
+ }
32
+ effects {
33
+ persistencia Pedido criticidade=alta
34
+ auditoria pedidos
35
+ }
36
+ guarantees {
37
+ pedido_id existe
38
+ status existe
39
+ }
40
+ tests {
41
+ caso "pedido valido" {
42
+ given {
43
+ cliente_id: "cli-1"
44
+ total: 10
45
+ }
46
+ expect {
47
+ sucesso: verdadeiro
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ route criar_pedido_publico {
54
+ metodo: POST
55
+ caminho: /pedidos
56
+ task: criar_pedido
57
+ }
58
+ }
59
59
  `,
60
60
  },
61
61
  ];
@@ -64,41 +64,41 @@ function arquivosApoioIaIniciar() {
64
64
  return [
65
65
  {
66
66
  caminhoRelativo: "README.md",
67
- conteudo: `# Projeto Sema
68
-
69
- Este projeto foi inicializado com Sema.
70
-
71
- ## Entrada oficial do Codex
72
-
73
- Antes de alterar codigo, contrato ou documentacao:
74
-
75
- 1. leia \`AGENTS.md\`;
76
- 2. rode \`sema --version\`; se o shell não localizar o comando, use \`$HOME/.sema/bin/sema\` no macOS/Linux; no Windows, PowerShell usa \`sema.ps1\` no PATH, cmd.exe usa \`sema.cmd\`, e o fallback absoluto é \`& "$env:SystemRoot\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\\.sema\\bin\\sema-managed.ps1" --version\`;
77
- 3. rode \`sema resumo --drift none\` para contexto contratual; score, confiança e implementação ficam não avaliados;
78
- 4. rode \`sema docs-impacto --intencao "<acao>" --json\`;
79
- 5. leia \`docs/commands.md\` antes de escolher comando ou interpretar \`--saida\`;
80
- 6. use \`sema descobrir recomendar --intencao "<objetivo>" --json\` quando não souber qual capacidade ou pipeline aplicar;
81
- 7. use \`exemplos/\` e \`docs/syntax.md\` antes de criar ou corrigir \`.sema\`.
82
-
83
- Quando precisar comprovar o código vivo, rode \`sema drift <contrato.sema> --escopo modulo --cache fresh --json\`. Cache acelera navegação, mas não é prova final de fechamento.
84
-
85
- ## Estrutura criada
86
-
87
- - \`contratos/\`: contratos semanticamente governados.
88
- - \`AGENTS.md\`: entrypoint oficial do Codex.
89
- - \`exemplos/\`: exemplos oficiais da DSL Sema.
90
- - \`docs/commands.md\`: catalogo de comandos, pipelines, gates e regra de \`--saida\`.
91
- - \`docs/syntax.md\`: referencia curta para escrever \`.sema\`.
92
- - \`docs/ai-workflow.md\`: fluxo minimo para agentes.
93
- - \`SEMA_BOOT.md\`, \`SEMA_SMALL_MODEL.md\`, \`AGENT_CONTEXT_PACK.json\` e \`SEMA_INDEX.json\`: contexto IA-first.
94
-
95
- ## Geracao
96
-
97
- O template base ja declara alvo JavaScript. Exemplo:
98
-
99
- \`\`\`bash
100
- sema compilar contratos/pedidos.sema --alvo javascript --saida ./generated/javascript
101
- \`\`\`
67
+ conteudo: `# Projeto Sema
68
+
69
+ Este projeto foi inicializado com Sema.
70
+
71
+ ## Entrada oficial do Codex
72
+
73
+ Antes de alterar codigo, contrato ou documentacao:
74
+
75
+ 1. leia \`AGENTS.md\`;
76
+ 2. rode \`sema --version\`; se o shell não localizar o comando, use \`$HOME/.sema/bin/sema\` no macOS/Linux; no Windows, PowerShell usa \`sema.ps1\` no PATH, cmd.exe usa \`sema.cmd\`, e o fallback absoluto é \`& "$env:SystemRoot\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\\.sema\\bin\\sema-managed.ps1" --version\`;
77
+ 3. rode \`sema resumo --drift none\` para contexto contratual; score, confiança e implementação ficam não avaliados;
78
+ 4. rode \`sema docs-impacto --intencao "<acao>" --json\`;
79
+ 5. leia \`docs/commands.md\` antes de escolher comando ou interpretar \`--saida\`;
80
+ 6. use \`sema descobrir recomendar --intencao "<objetivo>" --json\` quando não souber qual capacidade ou pipeline aplicar;
81
+ 7. use \`exemplos/\` e \`docs/syntax.md\` antes de criar ou corrigir \`.sema\`.
82
+
83
+ Quando precisar comprovar o código vivo, rode \`sema drift <contrato.sema> --escopo modulo --cache fresh --json\`. Cache acelera navegação, mas não é prova final de fechamento.
84
+
85
+ ## Estrutura criada
86
+
87
+ - \`contratos/\`: contratos semanticamente governados.
88
+ - \`AGENTS.md\`: entrypoint oficial do Codex.
89
+ - \`exemplos/\`: exemplos oficiais da DSL Sema.
90
+ - \`docs/commands.md\`: catalogo de comandos, pipelines, gates e regra de \`--saida\`.
91
+ - \`docs/syntax.md\`: referencia curta para escrever \`.sema\`.
92
+ - \`docs/ai-workflow.md\`: fluxo minimo para agentes.
93
+ - \`SEMA_BOOT.md\`, \`SEMA_SMALL_MODEL.md\`, \`AGENT_CONTEXT_PACK.json\` e \`SEMA_INDEX.json\`: contexto IA-first.
94
+
95
+ ## Geracao
96
+
97
+ O template base ja declara alvo JavaScript. Exemplo:
98
+
99
+ \`\`\`bash
100
+ sema compilar contratos/pedidos.sema --alvo javascript --saida ./generated/javascript
101
+ \`\`\`
102
102
  `,
103
103
  },
104
104
  ];
@@ -52,8 +52,14 @@ async function resolverDiretoriosConfiguradosConfinados(baseProjeto, baseConfigu
52
52
  let canonico = absoluto;
53
53
  try {
54
54
  const [real, informacao] = await Promise.all([realpath(absoluto), stat(absoluto)]);
55
- if (!informacao.isDirectory()) {
56
- throw new Error(`${identificadorSeguro} nao e diretorio`);
55
+ const ehContratoIndividual = campo === "origens"
56
+ && informacao.isFile()
57
+ && absoluto.toLowerCase().endsWith(".sema");
58
+ if (!informacao.isDirectory() && !ehContratoIndividual) {
59
+ const esperado = campo === "origens"
60
+ ? "um diretorio de contratos (ex.: ./contratos) ou um arquivo .sema individual"
61
+ : "um diretorio de codigo vivo";
62
+ throw new Error(`${identificadorSeguro} nao e ${esperado}. Corrija "${campo}" no sema.config.json; configuracoes geradas por versoes antigas da CLI podem listar arquivos direto.`);
57
63
  }
58
64
  if (!caminhoEstaDentro(baseReal, real)) {
59
65
  throw new Error(`${identificadorSeguro} resolve fora da base do projeto`);
package/docs/README.md CHANGED
@@ -1,25 +1,25 @@
1
1
  # Sema Documentation
2
2
 
3
- These docs describe the public Codex-native local CLI distribution of Sema.
3
+ These docs describe the public local-first CLI distribution of Sema, proven with Claude, Codex, zCode (GLM) and Kimi.
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. 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.
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.
12
12
 
13
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.
14
+ OpenAI. Proven compatibility with Claude, Codex, zCode (GLM) and Kimi describes
15
+ Sema's product direction, not an official OpenAI program.
16
16
 
17
17
  Start here:
18
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)
22
- - [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)
23
23
  - [Profiles](./profiles.md)
24
24
  - [Capability Discovery](./descoberta-capacidades.md) — one explainable catalog
25
25
  for governance flows, profiles, specialized workflows, pipelines, generators,
@@ -35,4 +35,4 @@ Start here:
35
35
  - [Security](./security.md)
36
36
  - [Codex Integration](./ai-integration.md)
37
37
 
38
- Official support: [suporte@otimitare.online](mailto:suporte@otimitare.online)
38
+ Official support: [suporte@otimitare.com](mailto:suporte@otimitare.com)
@@ -1,81 +1,81 @@
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
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.com