@sublang/spex 4.2.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +433 -89
  2. package/dist/cli.js +80 -42
  3. package/dist/commands/add.d.ts +12 -0
  4. package/dist/commands/add.js +138 -0
  5. package/dist/commands/auth-target.d.ts +11 -0
  6. package/dist/commands/auth-target.js +50 -0
  7. package/dist/commands/environment.d.ts +123 -0
  8. package/dist/commands/environment.js +411 -0
  9. package/dist/commands/export.d.ts +21 -0
  10. package/dist/commands/export.js +663 -0
  11. package/dist/commands/home.d.ts +56 -0
  12. package/dist/commands/home.js +215 -0
  13. package/dist/commands/install.d.ts +2 -0
  14. package/dist/commands/install.js +48 -0
  15. package/dist/commands/list.d.ts +2 -0
  16. package/dist/commands/list.js +87 -0
  17. package/dist/commands/login.d.ts +2 -0
  18. package/dist/commands/login.js +211 -0
  19. package/dist/commands/logout.d.ts +2 -0
  20. package/dist/commands/logout.js +74 -0
  21. package/dist/commands/publish.d.ts +2 -0
  22. package/dist/commands/publish.js +120 -0
  23. package/dist/commands/remove.d.ts +2 -0
  24. package/dist/commands/remove.js +34 -0
  25. package/dist/commands/run.d.ts +50 -0
  26. package/dist/commands/run.js +309 -0
  27. package/dist/commands/search.d.ts +2 -0
  28. package/dist/commands/search.js +34 -0
  29. package/dist/commands/settle.d.ts +124 -0
  30. package/dist/commands/settle.js +475 -0
  31. package/dist/commands/update.d.ts +2 -0
  32. package/dist/commands/update.js +37 -0
  33. package/dist/commands/whoami.d.ts +2 -0
  34. package/dist/commands/whoami.js +75 -0
  35. package/dist/lib/environment/agent-folders.d.ts +14 -0
  36. package/dist/lib/environment/agent-folders.js +11 -0
  37. package/dist/lib/environment/archive.d.ts +26 -0
  38. package/dist/lib/environment/archive.js +91 -0
  39. package/dist/lib/environment/builtins.d.ts +112 -0
  40. package/dist/lib/environment/builtins.js +539 -0
  41. package/dist/lib/environment/citations.d.ts +75 -0
  42. package/dist/lib/environment/citations.js +267 -0
  43. package/dist/lib/environment/exports.d.ts +190 -0
  44. package/dist/lib/environment/exports.js +1029 -0
  45. package/dist/lib/environment/format.d.ts +133 -0
  46. package/dist/lib/environment/format.js +651 -0
  47. package/dist/lib/environment/git-source.d.ts +41 -0
  48. package/dist/lib/environment/git-source.js +159 -0
  49. package/dist/lib/environment/index.d.ts +20 -0
  50. package/dist/lib/environment/index.js +27 -0
  51. package/dist/lib/environment/install.d.ts +140 -0
  52. package/dist/lib/environment/install.js +694 -0
  53. package/dist/lib/environment/layout.d.ts +15 -0
  54. package/dist/lib/environment/layout.js +50 -0
  55. package/dist/lib/environment/lock.d.ts +87 -0
  56. package/dist/lib/environment/lock.js +305 -0
  57. package/dist/lib/environment/marker.d.ts +15 -0
  58. package/dist/lib/environment/marker.js +31 -0
  59. package/dist/lib/environment/own-paths.d.ts +59 -0
  60. package/dist/lib/environment/own-paths.js +174 -0
  61. package/dist/lib/environment/placed-record.d.ts +32 -0
  62. package/dist/lib/environment/placed-record.js +72 -0
  63. package/dist/lib/environment/registries.d.ts +25 -0
  64. package/dist/lib/environment/registries.js +75 -0
  65. package/dist/lib/environment/registry.d.ts +173 -0
  66. package/dist/lib/environment/registry.js +390 -0
  67. package/dist/lib/environment/requests.d.ts +108 -0
  68. package/dist/lib/environment/requests.js +403 -0
  69. package/dist/lib/environment/resolve.d.ts +70 -0
  70. package/dist/lib/environment/resolve.js +451 -0
  71. package/dist/lib/environment/semver.d.ts +30 -0
  72. package/dist/lib/environment/semver.js +130 -0
  73. package/dist/lib/environment/store.d.ts +23 -0
  74. package/dist/lib/environment/store.js +123 -0
  75. package/dist/lib/environment/tar.d.ts +27 -0
  76. package/dist/lib/environment/tar.js +219 -0
  77. package/dist/lib/files.d.ts +66 -0
  78. package/dist/lib/files.js +233 -0
  79. package/dist/lib/git-host.d.ts +579 -0
  80. package/dist/lib/git-host.js +1363 -0
  81. package/dist/lib/home-file.d.ts +124 -0
  82. package/dist/lib/home-file.js +288 -0
  83. package/dist/lib/instance.d.ts +63 -0
  84. package/dist/lib/instance.js +130 -0
  85. package/dist/lib/words.d.ts +32 -0
  86. package/dist/lib/words.js +27 -0
  87. package/dist/lint.js +8 -0
  88. package/dist/testing/index.d.ts +1 -0
  89. package/dist/testing/index.js +7 -0
  90. package/dist/testing/standin-registry.d.ts +94 -0
  91. package/dist/testing/standin-registry.js +449 -0
  92. package/package.json +37 -3
  93. package/dist/attached-cli.d.ts +0 -13
  94. package/dist/attached-cli.js +0 -249
  95. package/dist/attached-client.d.ts +0 -53
  96. package/dist/attached-client.js +0 -237
  97. package/dist/generated-protocol.d.ts +0 -2
  98. package/dist/generated-protocol.js +0 -6
  99. package/dist/package-init.d.ts +0 -21
  100. package/dist/package-init.js +0 -442
package/README.md CHANGED
@@ -10,124 +10,408 @@
10
10
  *The essential spec layer AI agents need to build software reliably.*
11
11
 
12
12
  Scaffolds a `specs/` directory so AI coding agents can read and follow
13
- your project's requirements and design. It makes a spec package folder from
14
- a skill or a spec you already have, and attaches to the running Spex app for
15
- project, Space sign-in and package operations.
13
+ your project's requirements and design. It also manages spec packages:
14
+ it adds, installs and publishes specs, skills and playbooks in a
15
+ folder, with no running app. Requires Node.js 22 or later.
16
16
 
17
17
  ## Install
18
18
 
19
+ Install Spex CLI 5.0 with Node.js 22 or later:
20
+
19
21
  ```sh
20
22
  npm install -g @sublang/spex
23
+ spex --version
21
24
  ```
22
25
 
23
- Or run once without installing:
26
+ This installs the CLI without building or starting the IDE. The package
27
+ commands below need no running app. To scaffold specs without installing
28
+ the CLI globally:
24
29
 
25
30
  ```sh
26
31
  npx @sublang/spex scaffold
27
32
  ```
28
33
 
29
- ## Make a package folder
34
+ ### Install current source CLI
30
35
 
31
- `spex package init` turns a skill folder or a spec file you already have into
32
- a spec package folder ready to add and publish. It needs no running app.
33
- From your project's root:
36
+ For development, use Git and Node.js 22.19 or later. From a new checkout,
37
+ install only the CLI workspace's dependencies, build it, and install its
38
+ packaged artifact:
34
39
 
35
40
  ```sh
36
- spex package init my-org/my-skill --skill .claude/skills/my-skill --move
37
- spex package init my-org/my-spec --spec specs/packages/my-spec.md
41
+ git clone --depth=1 https://github.com/sublang-ai/spex.git
42
+ cd spex
43
+ npm ci --workspace @sublang/spex --include-workspace-root=false
44
+ npm run build --workspace @sublang/spex
45
+ npm install --global "$(npm pack --workspace @sublang/spex --silent)"
46
+ spex --version
38
47
  ```
39
48
 
40
- It writes `spex-packages/<name>/` holding `meta.yaml` (format 2, version
41
- `0.1.0`), a `README.md`, the project's `LICENSE` where there is one, each
42
- `--skill` folder under `skills/<language>/<id>/` — `<id>` being the `name`
43
- its `SKILL.md` declares — and the `--spec` file under
44
- `specs/<language>/<name>.md`. Give `--skill` once per skill; a package holds
45
- at most one spec, whose file must be named `<name>.md`.
46
- `--move` moves the skill folders instead of copying them: once the package is
47
- added, Spex exports the skills back to your agents.
49
+ Check `spex --version` and `spex export --help` before continuing with a
50
+ development build.
48
51
 
49
- | Option | Default |
50
- | --- | --- |
51
- | `--language <tag>` | `en` |
52
- | `--description <text>` | the first skill's `SKILL.md` description, else the first paragraph under the spec's Intent heading |
53
- | `--license <id>` | `MIT` where `./LICENSE` begins with "MIT License", else `Apache-2.0` |
54
-
55
- Every rule is checked before anything is written; a refusal writes nothing
56
- and names the rule. It ends with the next steps: in the app, **Playbooks →
57
- Add from folder** with the name and `spex-packages/<name>`, then **Publish**
58
- on its row; or with the CLI, as below,
59
- `spex package add <org>/<name> --path spex-packages/<name>` and
60
- `spex package publish spex-packages/<name> --dry-run`.
61
-
62
- ## Use the running Spex app
63
-
64
- These commands require Node.js 22 or later and the Spex app from
65
- 0.9.0-beta.18 or later — the desktop app or the server shell — with attached
66
- CLI version 1 support and a matching protocol.
67
- Keep the app running on this computer: the CLI finds it through the
68
- `local/endpoint.json` file the app keeps in its home, `SPEX_HOME` or
69
- `~/.spex`, while it serves on a loopback address. Pass
70
- `--server <access-url>` or set `SPEX_SERVER_URL` only to use another
71
- server; either wins over the file. App 0.9.0-beta.18 keeps no such file and
72
- needs that URL, which its server shell started with `npm run start:server`
73
- prints. Keep the URL private: it grants access to that server's home.
74
- The CLI connects only to literal loopback addresses; it starts no server and
75
- stores no separate credentials or package state. Without a running app it
76
- says so and exits 1.
52
+ ## Quick start
53
+
54
+ The package commands act on the folder you run them in. They need no
55
+ running Spex app.
56
+
57
+ Use published packages in a project:
77
58
 
78
59
  ```sh
79
- spex project add /absolute/path/to/project
80
- cd /absolute/path/to/project
81
- spex project list
82
- spex auth login --instance https://spex.sublang.ai
83
- spex auth status
84
- spex package search toolkit
85
- spex package status
60
+ cd my-project
61
+ spex search toolkit
62
+ spex add my-org/toolkit
63
+ spex list
64
+ git add spex.yaml spex.lock
86
65
  ```
87
66
 
88
- Open the displayed sign-in URL and approve with the displayed code when asked.
89
- The CLI waits for that sign-in's result. Sign-in success does not mean the
90
- later catalog read or records Sync succeeded.
91
- Package commands select the registered project at the exact current working
92
- directory; run from its root, or pass `--project <registered-folder>`.
93
- An unmatched folder is an error, never an implicit project registration.
67
+ `spex add` adds the newest version as `^<version>`. To choose the
68
+ version, write it after the name: `spex add my-org/toolkit@~1.2.0`.
69
+ After a clone, `spex install` installs what `spex.lock` records. Public
70
+ packages need no sign-in; private ones need `spex login` first. Put real
71
+ names in place of the examples.
72
+
73
+ Build a package from a skill you already have, then publish it:
94
74
 
95
75
  ```sh
96
- spex package add my-org/toolkit --version '^1.0.0'
97
- spex package install
98
- spex package resolve
99
- spex package remove my-org/toolkit
76
+ spex login
77
+ spex export my-org/my-skill --skill .claude/skills/my-skill
78
+ spex publish my-org/my-skill --dry-run
79
+ spex publish my-org/my-skill
100
80
  ```
101
81
 
102
- `install` uses the existing lock. `resolve` selects versions again and installs.
103
- For a package you are authoring inside the project, such as one
104
- `spex package init` made, request its relative folder:
82
+ `spex login` signs you in to the registry with a code in your browser:
83
+ open the address it prints and enter the code it shows. `spex export`
84
+ builds `spex-packages/my-org/my-skill/` by copying the skill, which
85
+ stays in `.claude/skills/` for your agent; it adds nothing to
86
+ `spex.yaml`. After you edit the skill, `spex export my-org/my-skill`
87
+ refreshes the copy. The dry run shows the registry, the version and the
88
+ files, and publishes nothing. Replace `my-org` with a namespace your
89
+ registry account can use; check
90
+ [Your orgs](https://spex.sublang.ai/account/orgs?scope=registry) when using
91
+ Spex Space. Your personal namespace may already be available after
92
+ sign-in, so creating a Space group or claiming an organization is not a
93
+ prerequisite.
94
+
95
+ ## spex.yaml and spex.lock
96
+
97
+ A folder's packages are listed in two files at its top, `spex.yaml` and
98
+ `spex.lock`, and installed under `.spex/`. Each package command acts on
99
+ the nearest folder holding `spex.yaml`, the current one included, else
100
+ the top level of the Git work tree, else the current folder.
101
+
102
+ | Path | Holds | In Git |
103
+ | --- | --- | --- |
104
+ | `spex.yaml` | the packages you add and the registry they come from | commit it |
105
+ | `spex.lock` | the exact version, source and file digests of every package installed | commit it |
106
+ | `.spex/` | the installed files and the skills made for your agents | ignored by its own `.gitignore` |
107
+ | `spex-packages/<org>/<pkg>/` | each package you develop here | commit it |
108
+ | `specs/packages/<pkg>.md` | the spec a package provides, placed in your `specs/` | commit it |
109
+ | `.gitattributes` | the lines keeping `spex.yaml`, `spex.lock` and placed specs at LF on every checkout | commit it |
110
+ | `.claude/skills/`, `.agents/skills/` | the skills placed for your agents | ignored through `.git/info/exclude` |
111
+
112
+ A `spex.yaml` looks like this:
113
+
114
+ ```yaml
115
+ format: 1
116
+ registry: https://spex.sublang.ai
117
+ space: https://your-space.example
118
+ language: en
119
+ packages:
120
+ my-org/toolkit:
121
+ version: ^1.2.0
122
+ my-org/my-skill:
123
+ path: spex-packages/my-org/my-skill
124
+ ```
125
+
126
+ - `registry` is where packages come from, and where `spex publish`
127
+ sends yours. A new `spex.yaml` names the public registry, Spex Space
128
+ at `https://spex.sublang.ai`.
129
+ - `space`, optional, is the Space this project's records sync with. It
130
+ changes nothing about where packages come from.
131
+ - `language`, optional, picks each package's files in that language
132
+ where the package has them, else its original.
133
+ - Each package has one source: `version` from the registry, `path` for a
134
+ folder in this project, used in place, or `git` with `rev` and an
135
+ optional `path` for a Git repository.
136
+ - A version is exact (`1.2.3`), caret (`^1.2.3`: any 1.x from 1.2.3) or
137
+ tilde (`~1.2.3`: any 1.2.x from 1.2.3).
138
+
139
+ To choose another registry, edit `registry` in `spex.yaml`, preserving
140
+ the other fields. `spex search`, `spex add` and `spex publish` use that
141
+ choice and take no `--registry` option. `spex login --registry <url>`
142
+ signs in at an address without changing the project's configuration.
143
+
144
+ `spex install` installs what `spex.lock` records, so every clone
145
+ installs the same files. It updates `spex.lock` first only where the
146
+ file is missing or out of date: `spex.yaml` changed since, or a folder
147
+ package's `meta.yaml` no longer matches it. `spex update` moves to the
148
+ newest versions `spex.yaml` allows, on purpose. Downloaded files are
149
+ checked against the digests in `spex.lock` and kept once in the home's
150
+ `store/`, then linked or copied into `.spex/packages/`.
151
+
152
+ Only what a package's `meta.yaml` `provides` is placed: a playbook's
153
+ source spec, or a skill the playbook requires, is installed but placed
154
+ nowhere. Installed skills reach every agent. Each one is placed in
155
+ `.claude/skills/<name>/` for Claude Code and `.agents/skills/<name>/` for
156
+ Codex, Gemini CLI, Kimi Code and OpenCode. A playbook's launch skill
157
+ goes to `.claude/skills/` only. A folder of yours under the same name
158
+ stays as it is, and the command says it left that skill out.
159
+
160
+ A package's spec is placed in your `specs/` as
161
+ `specs/packages/<pkg>.md`, its first line naming the package and
162
+ version, for you to commit with your code. Edit it and it is yours: Spex
163
+ leaves it standing and says which newer version waits. A file of that
164
+ name of your own keeps the spec out, and a folder without `specs/` gets
165
+ none until you run `spex scaffold`.
166
+
167
+ The Spex app reads the same files. Open the folder as a project in the
168
+ app, before or after you use the CLI, and its **Packages** tab shows the
169
+ same packages. What one writes, the other reads at its next use. Only
170
+ the app:
171
+
172
+ - runs an installed playbook in a session, with a default player for
173
+ each role and choices on the **Playbooks** tab;
174
+ - prepares each installed playbook to run on its engine;
175
+ - holds the built-in playbooks, `sublang/playbooks`, which come with
176
+ Spex as a global package. `spex install` uses a copy the app keeps in
177
+ the same home, or a registry, where it can; otherwise it leaves them
178
+ to the app and says so.
179
+
180
+ ## Commands
181
+
182
+ The tables follow `spex --help`. `spex <command> --help` prints a
183
+ command's lines and every option it takes; `spex --version` prints the
184
+ installed version.
185
+
186
+ ### Packages in this folder (spex.yaml, spex.lock, .spex/)
187
+
188
+ | Command | What it does |
189
+ | --- | --- |
190
+ | `spex add <org>/<pkg>[@<version>]` | Add a package (newest by default) |
191
+ | `spex add <org>/<pkg> --path <folder>` | Add a package from a folder in this project |
192
+ | `spex remove <org>/<pkg>`, alias `rm` | Remove a package |
193
+ | `spex install`, alias `i` | Install what `spex.lock` records |
194
+ | `spex update` | Update to the newest versions `spex.yaml` allows |
195
+ | `spex list`, alias `ls` | What is added, installed, and placed for your agents |
196
+ | `spex search <query>` | Find packages at the registry |
197
+
198
+ ### Your packages
199
+
200
+ | Command | What it does |
201
+ | --- | --- |
202
+ | `spex export <org>/<pkg> [--spec <file>] [--skill <folder>]…` | Build it in `spex-packages/<org>/<pkg>/` from your files |
203
+ | `spex publish [<org>/<pkg>] [--dry-run]` | Publish it to the registry |
204
+
205
+ ### Sign-in
206
+
207
+ | Command | What it does |
208
+ | --- | --- |
209
+ | `spex login [--registry <url> \| --space <url>]` | Sign in with a code in your browser |
210
+ | `spex logout [--registry <url> \| --space <url>]` | Sign out |
211
+ | `spex whoami [--registry <url> \| --space <url>]` | Who you are signed in as, and where |
212
+
213
+ ### Specs
214
+
215
+ | Command | What it does |
216
+ | --- | --- |
217
+ | `spex scaffold [<path> \| --update]` | Start `specs/` and point your agents at it |
218
+ | `spex lint [<path>]` | Check `specs/` for structure, IDs and citations |
219
+
220
+ [Scaffolding specs](#scaffolding-specs) and [Linting](#linting) describe
221
+ them in full.
222
+
223
+ ### `spex add`, `remove`, `update` and `list`
224
+
225
+ - `spex add <org>/<pkg>` adds the newest version the registry lists
226
+ that is no prerelease, as `^<version>`; `@<version>` adds the one you
227
+ write. `--path` adds a folder in this project instead, read in place.
228
+ It installs and places what each package provides, a spec in
229
+ `specs/packages/<pkg>.md`, and prints where each went, the spec's line
230
+ as `spex list` reads it. A malformed name or version, a version and
231
+ `--path` together, a folder outside this project or holding no
232
+ `meta.yaml` of that package, and a package the registry does not list
233
+ to you are each refused before anything is written.
234
+ - `spex remove` drops a package you added, with what only it needed,
235
+ and refuses one `spex.yaml` does not list. The built-in playbooks
236
+ cannot be removed: "sublang/playbooks comes with Spex".
237
+ - `spex update` updates every package at once and prints each one whose
238
+ version changed. It takes no package name.
239
+ - `spex list` heads with the folder and the registry, then lists what
240
+ is **Added** to `spex.yaml`, what is **Installed** with its version
241
+ and source — from the registry, from a folder, from Git or built in —
242
+ and the **Skills for agents** with the folders each is placed in. A
243
+ last line says what to do: `Not installed yet — spex install` after a
244
+ clone, or what changed with `spex update` once `spex.yaml` or a folder
245
+ package changed. In a folder with no packages, it says so and names
246
+ `spex add`.
247
+ - Beneath an installed package that provides a spec, `spex list` says
248
+ where the spec stands, and each package its links wait for:
249
+
250
+ ```text
251
+ Installed
252
+ my-org/rules 1.1.0 from the registry installed
253
+ spec edited in specs/ — left as yours, 1.1.0 waiting
254
+ my-org/toolkit 1.2.0 from the registry installed
255
+ spec in specs/packages/toolkit.md
256
+ 2 links wait for my-org/base — spex add my-org/base
257
+ ```
258
+
259
+ One link reads `1 link waits`. A spec a file of yours keeps out reads
260
+ `spec not placed — specs/ holds <pkg>.md already`, and one in a folder
261
+ with no `specs/` reads `spec needs specs/ — spex scaffold`.
262
+
263
+ ### `spex export`
264
+
265
+ - `<org>` and `<pkg>` are lowercase letters, digits and single hyphens,
266
+ at most 64 characters each.
267
+ - It copies: your skill folders and your spec stay where they are, and
268
+ nothing is added to `spex.yaml`.
269
+ - Each `--skill` folder needs a `SKILL.md` whose frontmatter `name` is an
270
+ Agent Skills name. It lands at `skills/<language>/<name>/`.
271
+ - The `--spec` file must be named `<pkg>.md`. It lands at
272
+ `specs/<language>/<pkg>.md`. A package holds at most one spec.
273
+ - The spec's citations are rewritten for the package: one of the spec of
274
+ a package in `spex-packages/`, or of a spec this folder's install
275
+ placed, becomes its address, `spex:<org>/<pkg>#<id>`; one of a spec of
276
+ no package is dropped, its words kept; a decision record's link keeps
277
+ its text. Each citation dropped or reduced is printed as a warning.
278
+ - `--language <tag>` sets `<language>`, else `en`.
279
+ - A first export writes `meta.yaml` at version `0.1.0`, with `provides`
280
+ listing the kinds you gave. Its description is `--description <text>`,
281
+ else the first skill's `description`, else the spec's first paragraph
282
+ under its Intent heading. Its license is `--license <id>`, else `MIT`
283
+ where the folder's `LICENSE` begins with "MIT License", else
284
+ `Apache-2.0`. The folder's `LICENSE` is copied in, and a README made.
285
+ - Run again, it refreshes the spec and each skill from your files: the
286
+ spec `<pkg>.md` wherever it stands under `specs/`, and each skill from
287
+ a folder of its name in `.claude/skills/` or `.agents/skills/` that
288
+ Spex did not place. `meta.yaml` stays as you left it; a `--skill` or
289
+ `--spec` naming something new adds its entry. A playbook stays as it
290
+ is, and anything not found is reported and left as it was.
291
+ - Every rule is checked before anything is written. A refusal writes
292
+ nothing.
293
+ - Export works without signing in or contacting a registry. Its
294
+ publishing-rights notice reminds you to check the namespace with the
295
+ registry; creating a local package grants no right to publish it.
296
+
297
+ ### `spex publish`
298
+
299
+ - With a name, it publishes the folder `spex.yaml` adds that package
300
+ from, else `spex-packages/<org>/<pkg>/`. With no name, it publishes the
301
+ one package under `spex-packages/`, and lists them where there are
302
+ several.
303
+ - It publishes to the registry `spex.yaml` names, as the account you
304
+ signed in with there. Signed out, it refuses and names `spex login`.
305
+ - The org is the namespace before `/` in the package's name. At Spex
306
+ Space, check [Your orgs](https://spex.sublang.ai/account/orgs?scope=registry)
307
+ in your registry account. A valid, available sign-in name becomes your
308
+ personal namespace automatically; you can also claim an organization
309
+ you own. A Space group grants no publishing namespace.
310
+ - Packages are public by default. **Private packages** restricts a
311
+ namespace's packages to its personal owner or organization members.
312
+ - A signed-in dry run and every publication check that the registry
313
+ authorizes your account to publish under the namespace. An unsigned
314
+ dry run still validates local files, and reports that publishing
315
+ rights are unchecked.
316
+ - `meta.yaml` needs a `description` and a `license`.
317
+ - `--dry-run` prints `Publishing <org>/<pkg>@<version> to <registry>`
318
+ and the files, and publishes nothing. A publish prints the same first
319
+ line, then the package's page at the registry.
320
+ - A release never changes. Raise `version` in `meta.yaml` before you
321
+ publish again.
322
+
323
+ ## Signing in
324
+
325
+ A registry sign-in and a Space sign-in are separate, even at one
326
+ address: the first reads private packages and publishes, the second
327
+ syncs a project's records.
105
328
 
106
329
  ```sh
107
- spex package add my-org/toolkit --path spex-packages/toolkit
108
- spex package publish spex-packages/toolkit --dry-run
109
- spex package publish spex-packages/toolkit
330
+ spex login
331
+ spex login --registry https://spex.sublang.ai
332
+ spex login --space https://your-space.example
333
+ spex whoami
334
+ spex logout --registry https://spex.sublang.ai
110
335
  ```
111
336
 
112
- `add` requires exactly one of `--version` or `--path`. Core validates package
113
- folders and performs resolution, installation and native exports.
114
- Publishing requires the server's Space sign-in and an eligible claimed org.
115
- The dry run shows the actual destination, identity, version and declared files
116
- without uploading; a later direct publish performs its own current checks.
117
- The explicit publish command uploads without an interactive confirmation.
118
- It reports the server's actual publication receipt.
119
-
120
- Commands wait for their own terminal result, normally for up to ten minutes.
121
- Use `--timeout <positive-seconds>` to change that observation limit.
122
- A rejection exits 1. A lost connection or timeout after dispatch exits 2 with
123
- an unknown result: the operation may still complete. Inspect its state before
124
- manually retrying; the CLI never reconnects or resends mutations.
125
- Ctrl+C exits 130: package work may continue, while sign-in requests cancellation
126
- of its own attempt where still connected. Neither promises rollback.
127
- Use `spex --help` for command forms. Scaffold, lint and `package init` remain
128
- usable without a server.
129
-
130
- ## Usage
337
+ - With no flag, `login` and `logout` act on the registry `spex.yaml`
338
+ names, or on the public registry where there is no `spex.yaml`.
339
+ `--registry <url>` or `--space <url>` picks another; the two cannot be
340
+ combined.
341
+ - These flags choose where to sign in or out, not the registry used by
342
+ package commands. Set `registry` in `spex.yaml` to change that.
343
+ - `spex login` signs in with a code in your browser: it prints an
344
+ address and a code, and waits until you approve or deny there, or the
345
+ code expires. Ctrl-C stops it and saves nothing.
346
+ - A sign-in you already have is reported and kept; `--force` replaces
347
+ it. Signing in to a registry adds no Space.
348
+ - `spex whoami` prints one line for the registry and one for each Space
349
+ you have signed in to on this computer, each with `@<login>` or
350
+ `signed out`, marking `(default)` the Space a `spex.yaml` without
351
+ `space` uses; with a flag, it prints that line alone:
352
+
353
+ ```text
354
+ Registry Spex Space @me
355
+ Space Spex Space @me (default)
356
+ ```
357
+
358
+ - `spex logout` signs out of the one it acts on. Signing out of a
359
+ registry keeps your Space sign-ins, and signing out of a Space keeps
360
+ your registry sign-in. A Space you signed out of stays listed as
361
+ `signed out`.
362
+ - Public packages need no sign-in. Private packages and publishing need
363
+ a registry sign-in on the computer running the command, a team server
364
+ included; a Space sign-in gives none.
365
+ - A `<url>` is just the address, like `https://spex.sublang.ai`: the
366
+ host, with a port where it is not the default, and no path. `http` is
367
+ accepted only for a loopback address such as `localhost`.
368
+ - The home is `SPEX_HOME`, else `~/.spex`. The Spaces you signed in to
369
+ are listed in its `home.yaml`; sign-ins are kept in
370
+ `local/credentials.yaml`, readable by you alone. No command prints a
371
+ token.
372
+
373
+ ## Exit codes
374
+
375
+ The package commands exit with these codes. `scaffold` and `lint` keep
376
+ their own.
377
+
378
+ | Code | Meaning |
379
+ | --- | --- |
380
+ | `0` | the command succeeded |
381
+ | `1` | a refusal or a failure, its cause on standard error |
382
+ | `130` | interrupted, as by Ctrl-C |
383
+
384
+ A cause is one line naming the registry, the Space or the file by its
385
+ name, and ends in what to do where there is something to do:
386
+
387
+ ```text
388
+ acme/secret: not at Spex Space, or private — spex login, then retry
389
+ Spex Space could not be reached — check the connection, then retry
390
+ my-org is not yours at Spex Space — claim it at https://spex.sublang.ai/account/orgs?scope=registry
391
+ sign-in expired at Spex Space — spex login
392
+ spex.lock is from a newer Spex — update Spex
393
+ ```
394
+
395
+ An interrupted install leaves the last installed files and `spex.lock`
396
+ in place. An interrupted publish cannot take back a release the registry
397
+ already accepted.
398
+
399
+ ## Limits
400
+
401
+ - The CLI acts on a project folder's packages. Global packages, available
402
+ in every project of yours, are managed on **Playbooks** in the app.
403
+ - No command adds a Git source. A `git` package you write in `spex.yaml`
404
+ by hand is installed as written. The Space `spex.yaml` names, else your
405
+ default Space, lends its Git access to the repositories it holds while
406
+ you are signed in there; other repositories use this computer's Git
407
+ access. A registry sign-in gives no Git access.
408
+ - The built-in playbooks, `sublang/playbooks`, come with the Spex app as a
409
+ global package, removable there like any other package.
410
+ `spex install` installs them from the copy the app keeps in the same
411
+ home, where there is one, or from the registry, else leaves them to
412
+ the app.
413
+
414
+ ## Scaffolding specs
131
415
 
132
416
  ```sh
133
417
  spex scaffold
@@ -142,7 +426,7 @@ This creates:
142
426
  - Two starter packages (`git.md`, `licensing.md`) and a sample intent record seed the tree.
143
427
  - **`LICENSE`** — the verbatim Apache-2.0 text at the target root, written only when no `LICENSE` exists there.
144
428
  - **Agent instruction files** — a managed section that tells coding
145
- agents to read relevant specs, resolve conflicts there first, and keep
429
+ agents to read relevant specs, settle conflicts in them first, and keep
146
430
  specs and code aligned: `CLAUDE.md` for Claude Code, `AGENTS.md` for
147
431
  Codex, Kimi Code, and OpenCode, and `GEMINI.md` for Gemini CLI.
148
432
 
@@ -234,6 +518,66 @@ The command prints a per-file indicator for every framework and seed path, plus
234
518
 
235
519
  ## Upgrading from an earlier release
236
520
 
521
+ ### From a pre-release source build
522
+
523
+ If your source build used `spex new`, use `spex export <org>/<pkg>` in its
524
+ place. It builds the folder by copying your files and can be run again
525
+ to refresh it; it adds nothing to `spex.yaml` and has no `--move`.
526
+ A folder `spex new` made keeps working; a skill `--move` took into it is
527
+ edited there, since `spex export` refreshes a skill only from a folder
528
+ of yours.
529
+
530
+ Your next install places each package's spec in
531
+ `specs/packages/<pkg>.md`, where the folder holds `specs/`, in place of
532
+ its `<org>-<pkg>` skill; commit the new files. A skill that only
533
+ supports a playbook is no longer placed for your agents.
534
+
535
+ ### From 4.x
536
+
537
+ Spex 5.0 replaces the commands that attached to a running app with
538
+ top-level commands that need no app:
539
+
540
+ | 4.x | 5.0 |
541
+ | --- | --- |
542
+ | `spex package init <org>/<name> ...` | `spex export <org>/<pkg> ...`, building `spex-packages/<org>/<pkg>/` from your files |
543
+ | `spex package add <org>/<pkg> --version <requirement>` | `spex add <org>/<pkg>@<version>` |
544
+ | `spex package add <org>/<pkg> --path <folder>` | `spex add <org>/<pkg> --path <folder>` |
545
+ | `spex package install` | `spex install` |
546
+ | `spex package resolve` | `spex update` |
547
+ | `spex package remove <org>/<pkg>` | `spex remove <org>/<pkg>` |
548
+ | `spex package search <query>` | `spex search <query>` |
549
+ | `spex package status` | `spex list` |
550
+ | `spex package publish <folder> [--dry-run]` | `spex publish <org>/<pkg> [--dry-run]` |
551
+ | `spex auth login --instance <origin>` | `spex login --space <url>` |
552
+ | `spex auth status` | `spex whoami --space <url>` |
553
+ | none | `spex logout` |
554
+ | `spex project add <folder>`, `spex project list` | none: no project needs adding |
555
+ | `--server`, `SPEX_SERVER_URL`, `--project`, `--timeout` | none: no app is needed |
556
+
557
+ The package commands now run inside the CLI on the folder's own files,
558
+ and the Spex app runs the same code. `spex.yaml` and `spex.lock` stand
559
+ at the top of the project folder, with the installed files under
560
+ `.spex/`; the two files an earlier app kept in a project's records move
561
+ into its project folder at the app's next start.
562
+
563
+ - A `spex.yaml` without `registry` keeps the package source it had, a
564
+ Space or the default, until you add `registry` yourself. Before you
565
+ add it, check where its packages came from, above all before you
566
+ publish a private package: nothing moves a private package or a
567
+ publish to another registry for you. Publishing from such a
568
+ `spex.yaml` needs a registry sign-in at that same address.
569
+ - `spex.lock` keeps each package's registry, version and checksum as
570
+ recorded. An install downloads only from the registry it records,
571
+ never from another Space you signed in to.
572
+ - A sign-in an earlier release saved stays a Space sign-in and never
573
+ counts at a registry: run `spex login --registry <url>` once for
574
+ private packages and publishing.
575
+
576
+ A folder `spex package init` made at `spex-packages/<name>/` still
577
+ publishes by name while `spex.yaml` adds it from that path. Exit code
578
+ `2` is gone. Deep imports such as `@sublang/spex/dist/cli.js` are no
579
+ longer importable; the `exports` of `package.json` name its modules.
580
+
237
581
  ### From 2.x
238
582
 
239
583
  Spex 3.0 makes intent records disposable planning artifacts: no other