@semacode/cli 4.1.3 → 4.2.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.
@@ -1,199 +1,112 @@
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: Install, update or repair the local Sema CLI, or adopt Sema in a project. Separate distribution work from workspace adoption. In an existing Sema project, delegate to AGENTS.md and the local CLI with progressive context.
4
4
  ---
5
5
 
6
6
  # Sema Bootstrap
7
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>
52
- ```
53
-
8
+ The local CLI is the source of truth for Codex and compatible coding agents,
9
+ including Harness, OpenCode and Bionic. In an existing Sema workspace, read
10
+ `AGENTS.md` and `SEMA_BOOT.md`, then use its session navigation. Do not preload
11
+ `SEMA_INDEX.json`, `AGENT_CONTEXT_PACK.json`, all contracts or the whole project.
12
+ This skill only bridges the absence of that protocol during first contact;
13
+ installation and repair use the separate flows below.
14
+
15
+ ## Choose the authorized scope
16
+
17
+ Never treat a request to install, update, or repair the global distribution as
18
+ permission to adopt the current workspace. Informational use does not mutate
19
+ it. Explicit adoption already authorizes bootstrap; do not ask again. Clarify
20
+ only an unresolved scope. Preserve existing files and never add `--force`
21
+ without an explicit human overwrite decision.
22
+
23
+ ## Install or update globally
24
+
25
+ 1. Accept an exact SemVer, or resolve an omitted version / `latest` once:
26
+ `npm view @semacode/cli@latest version --json`.
27
+ Require one exact SemVer JSON string; stop on failure, range or malformed
28
+ output. Freeze that version before installing:
29
+ `npm install --global @semacode/cli@<resolved-exact-semver>`.
30
+ Substitute the validated version; never pass the placeholder literally.
54
31
  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.
58
-
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.
62
-
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.
32
+ works. Synchronizing a skill does not upgrade the package.
33
+ 3. Probe both CLI candidates below. Require the selected candidate to report
34
+ the exact installed version and support the skill status command.
35
+ 4. Run `sema skill status --json`. If a managed component is not `READY`, run
36
+ `sema skill sync --json`, then status again. Require the final `READY`
37
+ state and version match; npm exit code alone is insufficient proof.
38
+ 5. Report the installed version. Existing chats may need a skill reload or
39
+ a new chat. Do not initialize a workspace unless adoption was also requested.
68
40
 
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.
41
+ ## Resolve the CLI and its results
72
42
 
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:
43
+ Probe `sema --version` and `sema skill status --json` from the workspace root.
44
+ Also probe the PATH-independent fallback with the same two arguments.
45
+ Windows PowerShell fallback:
83
46
 
84
47
  ```powershell
85
48
  & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$HOME\.sema\bin\sema-managed.ps1" --version
86
49
  ```
87
50
 
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.
51
+ On macOS/Linux: `"$HOME/.sema/bin/sema" --version`.
52
+ Windows PATH uses `sema.ps1` in PowerShell and `sema.cmd` in cmd.exe. Do not
53
+ invoke the batch shim as the absolute PowerShell fallback.
118
54
 
55
+ If valid candidates disagree, prefer the managed candidate. Use it when PATH
56
+ is stale, fails, or does not support `sema skill status --json`. During an
57
+ update, any selected candidate must match the installed exact version.
119
58
  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.
59
+ If unavailable, stop before governed edits; install only within an authorized
60
+ global install/update request. Repair alone does not authorize a new version.
127
61
 
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.
62
+ `--version` is plain SemVer. JSON help/control failures use the six-field
63
+ `sema.cli.control/v1` envelope. Valid commands use the eight-field
64
+ `sema.cli.result/v1`: schemaVersion, ok, kind, command, code, message, exitCode,
65
+ payload. Read domain state inside `payload`; `data` is not an alias and `ok`
66
+ does not replace `payload.sucesso` or another domain verdict.
130
67
 
131
- ## Repair the current distribution
68
+ ## Repair without upgrading
132
69
 
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
70
+ Resolve the current CLI, inspect status, and synchronize only non-READY
71
+ managed components. Prove the result with status again. Repair may synchronize the current
72
+ launcher and skill, but must not run `npm install`, choose a new version or
138
73
  mutate the workspace.
139
74
 
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:
75
+ ## Adopt a workspace with a bounded context
160
76
 
161
- ```bash
162
- sema descobrir explicar flow.project-adoption --json
163
- sema iniciar --template base
164
- ```
77
+ If no contract/protocol exists, obtain explicit adoption authorization before
78
+ implementation. A request to adopt or initialize this project already grants
79
+ it. After authorization, inspect the official flow:
165
80
 
166
- This command preserves existing project files. Never add `--force`
167
- automatically; an overwrite must be an explicit user decision.
81
+ `sema descobrir explicar flow.project-adoption --json`
168
82
 
169
- 4. Generate the official Codex handshake for the newly initialized or adopted
170
- workspace:
83
+ Before creating files, obtain the model's **effective configured context
84
+ window in tokens** from the client or user. Model size, advertised capacity
85
+ and names such as 9B do not prove that value. Do not invent a default.
86
+ Initialize with the confirmed value:
171
87
 
172
- ```bash
173
- sema sync-codex --json
174
- ```
88
+ `sema iniciar --template base --janela-contexto <tokens>`
175
89
 
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.
90
+ Then run `sema sync-codex --json`. Read the generated `AGENTS.md` and
91
+ `SEMA_BOOT.md`, and delegate the governed workflow to them. For an existing
92
+ workspace, the session requests a missing profile; persist it only when
93
+ requested with `--salvar-perfil`, and reconfigure after changing models.
94
+ The context budget estimates a session response, not the entire conversation
95
+ or exact tokenizer usage. Expand through the selected contract and declared
96
+ links, leaving recommended documents available on demand. A stale index or
97
+ ambiguous target requires correction or refinement before acting.
178
98
 
179
- ## Boundary
99
+ ## Distribution boundaries
180
100
 
181
- - The CLI is the engine and source of truth.
182
101
  - `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
102
+ Compatible clients follow the same local protocol; do not duplicate it here.
103
+ - Launchers are managed at `~/.sema/bin`. The canonical skill is managed at
104
+ `~/.agents/skills/sema`; the mirror at `~/.claude/skills/sema` is managed
105
+ when Claude is detected. Client-specific copies require an explicit request
106
+ and the client's supported discovery location; preserve unrelated skills.
107
+ - Never write into a host-managed plugin cache or overwrite an unmanaged or
108
+ modified skill silently. Preserve files and stop on symlink/junction escapes.
109
+ - Do not introduce runtime access gates: no Sema login, activation key,
110
+ license check, tokens, credits, billing or remote workspace mirror. This
111
+ does not waive explicit human
197
112
  authorization for workspace adoption or overwrite.
198
- - Do not continue with a second copy of the governed workflow after
199
- `AGENTS.md` exists.