@semacode/cli 4.1.3 → 4.2.1

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 (47) hide show
  1. package/dist/agentBootstrap.d.ts +4 -0
  2. package/dist/agentBootstrap.js +45 -0
  3. package/dist/agentContext.d.ts +1 -1
  4. package/dist/agentContext.js +5 -5
  5. package/dist/agentContextPack.js +22 -31
  6. package/dist/agentEntryPoints.d.ts +1 -3
  7. package/dist/agentEntryPoints.js +16 -262
  8. package/dist/agentProtocol.d.ts +1 -0
  9. package/dist/agentProtocol.js +41 -0
  10. package/dist/cliArgs.js +1 -0
  11. package/dist/cliGrammar.js +7 -3
  12. package/dist/cliHelpTexto.js +2 -2
  13. package/dist/comandoSessao.d.ts +0 -33
  14. package/dist/comandoSessao.js +71 -70
  15. package/dist/contextBudget.d.ts +15 -0
  16. package/dist/contextBudget.js +64 -0
  17. package/dist/distribuicao/skillIntentPolicy.d.ts +1 -1
  18. package/dist/distribuicao/skillIntentPolicy.js +1 -0
  19. package/dist/docs.part01.js +0 -1
  20. package/dist/docs.part02.js +11 -23
  21. package/dist/docsRelations.d.ts +2 -0
  22. package/dist/docsRelations.js +83 -0
  23. package/dist/driftPack.js +19 -6
  24. package/dist/entradaContratos.d.ts +2 -0
  25. package/dist/entradaContratos.js +20 -0
  26. package/dist/index.part04.d.ts +2 -0
  27. package/dist/index.part04.js +13 -5
  28. package/dist/index.part05.js +1 -1
  29. package/dist/index.part06.js +15 -0
  30. package/dist/index.part08.js +1 -1
  31. package/dist/indexPack.d.ts +1 -0
  32. package/dist/indexPack.js +1 -1
  33. package/dist/initCommand.d.ts +1 -0
  34. package/dist/initCommand.js +10 -1
  35. package/dist/sessionContext.d.ts +13 -0
  36. package/dist/sessionContext.js +41 -0
  37. package/docs/ai-integration.md +5 -13
  38. package/docs/ai-workflow.md +8 -6
  39. package/docs/commands.md +14 -1
  40. package/docs/documentation.md +33 -0
  41. package/docs/drift-cache.md +7 -0
  42. package/exemplos/python_verificacao.sema +68 -68
  43. package/node_modules/@sema/gerador-python/dist/runtime.js +65 -65
  44. package/package.json +1 -1
  45. package/skills/sema/SKILL.md +57 -182
  46. package/skills/sema/agents/openai.yaml +4 -2
  47. package/skills/sema/references/distribution.md +70 -0
@@ -1,199 +1,74 @@
1
1
  ---
2
2
  name: sema
3
- description: Required Sema bootstrap for Codex and compatible coding agents when a local project does not yet contain its generated AGENTS.md protocol. Use when the user asks to install, update, repair, introduce, initialize, or adopt Sema, or mentions Sema in a workspace without that protocol. Treat global install or update, distribution repair, informational use, and explicit workspace adoption as separate intents; never infer adoption from distribution work. Resolve the managed PATH-independent launcher before declaring the CLI unavailable; after AGENTS.md exists, read it and delegate project governance to it and the local CLI.
3
+ description: Use before creating or editing software in a workspace, including small fixes, plain HTML/CSS/JavaScript apps, and empty projects. Ask about first-time Sema adoption, confirm the effective context window, then follow local contracts before implementation. Also handles Sema installation, updates and repair. The user need not mention Sema.
4
4
  ---
5
5
 
6
- # Sema Bootstrap
7
-
8
- This skill is required for the first contact, before a project can explain Sema
9
- to Codex through `AGENTS.md`. It does not replace or duplicate workspace
10
- governance.
11
-
12
- ## Classify the request
13
-
14
- Separate these intents before running a command:
15
-
16
- - **Install or update the global distribution**: install a requested exact
17
- version, or `latest` when no version is specified. This changes the global
18
- package, launcher, and managed skill only.
19
- - **Repair the current distribution**: diagnose and synchronize the launcher
20
- and managed skill without selecting or installing another package version.
21
- - **Adopt the current workspace**: introduce Sema governance into this project.
22
- Require an explicit request to introduce, initialize, or adopt Sema here.
23
- - **Informational use**: explain or inspect without initializing the workspace.
24
-
25
- Never treat a request to install, update, or repair the global CLI or skill as
26
- permission to adopt the current workspace. If a request explicitly asks for
27
- both distribution work and workspace adoption, execute them as two distinct
28
- authorized intents. If wording such as "install Sema in this project" leaves
29
- the workspace scope ambiguous, ask one scoped question before mutating the
30
- workspace.
31
-
32
- ## Install or update the global distribution
33
-
34
- When the user explicitly requests a global install or update:
35
-
36
- 1. Accept only an exact SemVer requested by the user or the literal `latest`.
37
- Treat an omitted version as `latest`. For `latest`, resolve the registry tag
38
- before installation:
39
-
40
- ```bash
41
- npm view @semacode/cli@latest version --json
42
- ```
43
-
44
- Require the result to be one JSON string containing an exact SemVer: no
45
- leading `v`, tag, range, whitespace, command syntax, or array. Stop if npm
46
- fails or the result is not an exact SemVer. For an exact user request, use
47
- that already-validated version. In both cases install only the resulting
48
- exact version; substitute it and never pass the placeholder literally:
49
-
50
- ```bash
51
- npm install --global @semacode/cli@<resolved-exact-semver>
6
+ # Sema
7
+
8
+ Load this skill before the first project write for creation or editing tasks.
9
+ Sema applies to simple static apps as well as larger systems. A request to
10
+ create an app, fix a bug or change a feature enters this workflow even when
11
+ it does not name Sema. Loading the skill is not consent to adopt it.
12
+
13
+ ## Create or edit a project
14
+
15
+ 1. In the current workspace, run `sema --version`. If PATH fails, use the
16
+ fallback below. Look for `AGENTS.md`, `SEMA_BOOT.md` and applicable contracts
17
+ without reading the whole project.
18
+ 2. **First use in a project without Sema:** before implementation, ask whether
19
+ the user wants to adopt Sema in this project and wait for the answer. This
20
+ applies both to an empty project and to editing existing ungoverned code.
21
+ Do not infer consent from installation, automatic skill activation or a
22
+ generic request to create/edit software. An explicit adoption request or
23
+ previous acceptance for this same project already answers the question;
24
+ do not ask again. If declined, do not initialize Sema or claim its validation;
25
+ follow the remaining user and project instructions.
26
+ 3. **After acceptance, or in an existing Sema project:** obtain the model's
27
+ effective configured context window in tokens from the client or user.
28
+ If unknown, ask and wait before loading project context or implementing.
29
+ Parameter count (4B, 9B), advertised maximum and output-token limit are not
30
+ the configured context window. Recheck when the model/configuration changes.
31
+ 4. **Adopting this project:** preserve existing files and run:
32
+
33
+ ```text
34
+ sema descobrir explicar flow.project-adoption --json
35
+ sema iniciar --template base --janela-contexto <confirmed-tokens>
36
+ sema sync-codex --json
52
37
  ```
53
38
 
54
- 2. Run that `npm install --global` even when an older `sema --version` already
55
- works. Never run `npm install ...@latest`; the mutable tag is resolved and
56
- frozen first. `sema skill sync` repairs files from the installed package; it
57
- does not install the version the user requested.
39
+ Read the generated `AGENTS.md` and `SEMA_BOOT.md`. Model the requested
40
+ behavior in an applicable contract before implementing. Never add `--force`
41
+ without an explicit overwrite decision.
42
+ 5. **Existing Sema project:** read its `AGENTS.md` and `SEMA_BOOT.md`, then run
43
+ `sema sessao "<task intention>" --janela-contexto <confirmed-tokens> --json`.
44
+ Follow the local gates and selected contract through implementation/testing.
45
+ Save a context profile only with `--salvar-perfil` as requested.
58
46
 
59
- 3. Probe both CLI candidates as described below. Require the selected candidate
60
- to report the exact installed version and support `sema skill status --json`.
61
- A stale command found through `PATH` must not hide a valid managed launcher.
47
+ `sema formatar` formats .sema contracts and `sema validar` validates those
48
+ contracts. Neither adopts a project or proves that HTML, CSS, JavaScript or
49
+ the application works. Report what was actually checked, including no contracts
50
+ found. If the user corrects a missed Sema workflow, resume it before more writes.
62
51
 
63
- 4. Run `sema skill status --json`, validate its public result envelope, and
64
- unwrap `payload`. If any managed component in that command payload is not
65
- `READY`, run `sema skill sync --json`, validate and unwrap its result, then
66
- run status again. Require a final `READY` state; do not report a successful
67
- install or update from npm's exit code alone.
52
+ Read only the selected contract, declared dependencies and blocking docs.
53
+ `SEMA_INDEX.json` and `AGENT_CONTEXT_PACK.json` are internal CLI databases,
54
+ not files to preload. Resolve stale indexes or ambiguous targets before editing.
55
+ The session budget estimates its response, not the whole chat.
68
56
 
69
- 5. Stop without touching the current workspace unless workspace adoption was
70
- also requested explicitly. Report that an already-open agent may need the
71
- host's skill reload action or a new task to load changed skill files.
57
+ ## CLI fallback and results
72
58
 
73
- ## Resolve the installed CLI
74
-
75
- For install, repair, or workspace bootstrap, probe the regular command from the
76
- project root:
77
-
78
- ```bash
79
- sema --version
80
- ```
81
-
82
- Also probe the PATH-independent managed fallback. On Windows PowerShell:
59
+ On Windows PowerShell, use this directly if PATH fails:
83
60
 
84
61
  ```powershell
85
62
  & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version
86
63
  ```
87
64
 
88
- PowerShell resolves `sema.ps1` for a normal `sema` lookup; `cmd.exe` resolves
89
- `sema.cmd`. Do not invoke the batch entrypoint with PowerShell's call operator
90
- as the absolute fallback. `sema-managed.ps1` is the managed fallback.
91
-
92
- On macOS or Linux:
93
-
94
- ```bash
95
- "$HOME/.sema/bin/sema" --version
96
- ```
97
-
98
- For each candidate, run `--version` and the read-only `skill status --json`
99
- probe. During install or update, a candidate is valid only when its version
100
- equals the exact version installed. During repair or bootstrap, if both are
101
- valid but report different versions, prefer the managed candidate. Also prefer
102
- the managed candidate when the regular command from `PATH` is stale, fails, or
103
- does not support `sema skill status --json`. Use the selected invocation for
104
- every remaining command.
105
-
106
- Interpret Sema CLI output as follows:
107
-
108
- - Treat `--version` as plain exact SemVer text, never as a JSON envelope.
109
- - For help or a command-control failure with `--json`, accept only the exact
110
- six-field `sema.cli.control/v1` envelope.
111
- - For every syntactically valid command with `--json`, accept only the exact
112
- eight-field `sema.cli.result/v1` envelope containing `schemaVersion`, `ok`,
113
- `kind`, `command`, `code`, `message`, `exitCode`, and `payload`.
114
- - Unwrap `payload` before reading command-specific state. Do not accept `data`
115
- as an alias, do not read domain fields from the envelope top level, and do
116
- not treat transport `ok` as a replacement for `payload.sucesso` or another
117
- command-specific verdict.
118
-
119
- Do not declare Sema unavailable until both candidates have failed validation.
120
- Do not treat a missing npm shim, stale `PATH`, or an old command without the
121
- `skill` subcommand as proof that Sema is absent.
122
-
123
- If neither invocation works, stop. For a bootstrap request, ask the user to
124
- authorize a global CLI install explicitly, then follow the install flow above:
125
- resolve `latest` to an exact SemVer and install that immutable version. Do not
126
- issue a direct install against the mutable `latest` tag.
127
-
128
- For a repair-only request, explain that synchronization requires a working
129
- installed CLI. Do not silently choose `latest` or another version as a repair.
130
-
131
- ## Repair the current distribution
132
-
133
- When the user explicitly requests repair without an update, resolve the CLI by
134
- probing both candidates above. Run `sema skill sync --json` only when the
135
- selected candidate reports a managed component that is not `READY`, then prove
136
- the result with a second status call. Repair may synchronize the current
137
- launcher and skill, but must not run `npm install`, select another version, or
138
- mutate the workspace.
139
-
140
- ## Follow or create workspace governance
141
-
142
- 1. If the project already has a generated Sema `AGENTS.md`, read it and
143
- `SEMA_BOOT.md`, then delegate project work to that protocol. Do not run
144
- `sema iniciar` or `sema sync-codex` merely because this skill was invoked or
145
- because global distribution work completed.
146
-
147
- 2. If the project has no Sema contract and no generated Sema `AGENTS.md`, do
148
- not treat invocation of this skill as permission to mutate the workspace:
149
-
150
- - for an informational request, answer without initializing Sema;
151
- - before implementing or changing the project, ask for explicit adoption
152
- authorization and stop until it is granted;
153
- - an explicit request to introduce, initialize, or adopt Sema in this
154
- project is that authorization;
155
- - global install, update, repair, or skill synchronization authorizes
156
- distribution changes only and must not initialize the current workspace.
157
-
158
- 3. After adoption is explicitly authorized, inspect the official adoption
159
- flow and then initialize the project:
160
-
161
- ```bash
162
- sema descobrir explicar flow.project-adoption --json
163
- sema iniciar --template base
164
- ```
165
-
166
- This command preserves existing project files. Never add `--force`
167
- automatically; an overwrite must be an explicit user decision.
168
-
169
- 4. Generate the official Codex handshake for the newly initialized or adopted
170
- workspace:
171
-
172
- ```bash
173
- sema sync-codex --json
174
- ```
175
-
176
- 5. Read the generated `AGENTS.md` and `SEMA_BOOT.md`. From this point onward,
177
- follow those workspace instructions and execute the local CLI directly.
65
+ On macOS/Linux: `"$HOME/.sema/bin/sema" --version`. Do not declare the CLI
66
+ unavailable before trying the managed fallback. If both fail, stop governed
67
+ edits. JSON results nest domain state in `payload`; `ok` alone is not proof
68
+ of success. Respect `payload.sucesso`, `valido`, blockers and scope.
178
69
 
179
- ## Boundary
70
+ ## Install, update or repair Sema
180
71
 
181
- - The CLI is the engine and source of truth.
182
- - `AGENTS.md` is the automatic, continuous workspace protocol for Codex.
183
- - The launchers are managed only at `~/.sema/bin`; on Windows, `sema.ps1` is
184
- the PowerShell PATH entrypoint, `sema.cmd` is the cmd.exe entrypoint, and
185
- `sema-managed.ps1` is the absolute fallback. The canonical skill copy is
186
- managed only at `~/.agents/skills/sema`; a Claude mirror is managed only at
187
- `~/.claude/skills/sema` when Claude is already detected.
188
- - Never write into a host-managed plugin cache or create duplicate copies in
189
- every vendor-specific skill directory.
190
- - This skill is mandatory while that protocol is absent.
191
- - This skill only bridges the absence of that protocol during first contact.
192
- - Bootstrap must preserve existing files and stop on symlink or junction
193
- escapes; it must never choose overwrite on the user's behalf.
194
- - Do not introduce runtime access gates for executing the local CLI: no Sema
195
- login, product-license check, activation key, token, credits, billing panel,
196
- or remote workspace mirror. This runtime rule does not waive explicit human
197
- authorization for workspace adoption or overwrite.
198
- - Do not continue with a second copy of the governed workflow after
199
- `AGENTS.md` exists.
72
+ Only for distribution work, read [references/distribution.md](references/distribution.md).
73
+ Do not load it for ordinary project creation or editing. Informational requests
74
+ do not mutate a workspace. Installation and repair remain separate from adoption.
@@ -1,4 +1,6 @@
1
1
  interface:
2
2
  display_name: "Sema"
3
- short_description: "Separate Sema install, repair, and adoption"
4
- default_prompt: "Use $sema to classify global install or update, distribution repair, informational use, and explicit workspace adoption before running the correct isolated flow."
3
+ short_description: "Use Sema before creating or editing software"
4
+ default_prompt: "Use $sema before creating or editing this project: ask about first-time adoption, confirm the effective context window, and follow local contracts; route install, update or repair separately."
5
+ policy:
6
+ allow_implicit_invocation: true
@@ -0,0 +1,70 @@
1
+ # Sema distribution
2
+
3
+ Read only for installation, updates or repair. Never treat a request to install, update, or repair the global distribution as permission to adopt the current workspace.
4
+
5
+ ## Install or update globally
6
+
7
+ 1. Accept an exact SemVer, or resolve an omitted version / `latest` once:
8
+ `npm view @semacode/cli@latest version --json`.
9
+ Require one exact SemVer JSON string; stop on failure, range or malformed
10
+ output. Freeze that version before installing:
11
+ `npm install --global @semacode/cli@<resolved-exact-semver>`.
12
+ Substitute the validated version; never pass the placeholder literally.
13
+ 2. Run that `npm install --global` even when an older `sema --version` already
14
+ works. Synchronizing a skill does not upgrade the package.
15
+ 3. Probe both CLI candidates below. Require the selected candidate to report
16
+ the exact installed version and support the skill status command.
17
+ 4. Run `sema skill status --json`. If a managed component is not `READY`, run
18
+ `sema skill sync --json`, then status again. Require the final `READY`
19
+ state and version match; npm exit code alone is insufficient proof.
20
+ 5. Report the installed version. Existing chats may need a skill reload or
21
+ a new chat. Do not initialize a workspace unless adoption was also requested.
22
+
23
+ ## Resolve the CLI and its results
24
+
25
+ Probe `sema --version` and `sema skill status --json` from the workspace root.
26
+ Also probe the PATH-independent fallback with the same two arguments.
27
+ Windows PowerShell fallback:
28
+
29
+ ```powershell
30
+ & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version
31
+ ```
32
+
33
+ On macOS/Linux: `"$HOME/.sema/bin/sema" --version`.
34
+ Windows PATH uses `sema.ps1` in PowerShell and `sema.cmd` in cmd.exe. Do not
35
+ invoke the batch shim as the absolute PowerShell fallback.
36
+
37
+ If valid candidates disagree, prefer the managed candidate. Use it when PATH
38
+ is stale, fails, or does not support `sema skill status --json`. During an
39
+ update, any selected candidate must match the installed exact version.
40
+ Do not declare Sema unavailable until both candidates have failed validation.
41
+ If unavailable, stop before governed edits; install only within an authorized
42
+ global install/update request. Repair alone does not authorize a new version.
43
+
44
+ `--version` is plain SemVer. JSON help/control failures use the six-field
45
+ `sema.cli.control/v1` envelope. Valid commands use the eight-field
46
+ `sema.cli.result/v1`: schemaVersion, ok, kind, command, code, message, exitCode,
47
+ payload. Read domain state inside `payload`; `data` is not an alias and `ok`
48
+ does not replace `payload.sucesso` or another domain verdict.
49
+
50
+ ## Repair without upgrading
51
+
52
+ Resolve the current CLI, inspect status, and synchronize only non-READY
53
+ managed components. Prove the result with status again. Repair may synchronize the current
54
+ launcher and skill, but must not run `npm install`, choose a new version or
55
+ mutate the workspace.
56
+
57
+ ## Distribution boundaries
58
+
59
+ - `AGENTS.md` is the automatic, continuous workspace protocol for Codex.
60
+ Compatible clients follow the same local protocol; do not duplicate it here.
61
+ - Launchers are managed at `~/.sema/bin`. The canonical skill is managed at
62
+ `~/.agents/skills/sema`; the mirror at `~/.claude/skills/sema` is managed
63
+ when Claude is detected. Client-specific copies require an explicit request
64
+ and the client's supported discovery location; preserve unrelated skills.
65
+ - Never write into a host-managed plugin cache or overwrite an unmanaged or
66
+ modified skill silently. Preserve files and stop on symlink/junction escapes.
67
+ - Do not introduce runtime access gates: no Sema login, activation key,
68
+ license check, tokens, credits, billing or remote workspace mirror. This
69
+ does not waive explicit human
70
+ authorization for workspace adoption or overwrite.