@sublang/spex 4.2.0 → 6.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 +438 -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 +12 -0
  6. package/dist/commands/auth-target.js +52 -0
  7. package/dist/commands/environment.d.ts +117 -0
  8. package/dist/commands/environment.js +399 -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 +312 -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 +71 -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 +39 -0
  38. package/dist/lib/environment/archive.js +122 -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 +23 -0
  64. package/dist/lib/environment/registries.js +48 -0
  65. package/dist/lib/environment/registry.d.ts +172 -0
  66. package/dist/lib/environment/registry.js +390 -0
  67. package/dist/lib/environment/requests.d.ts +109 -0
  68. package/dist/lib/environment/requests.js +401 -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,414 @@
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. This
74
+ example assumes your project uses the public registry.
94
75
 
95
76
  ```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
77
+ spex login --registry https://spex.sublang.ai
78
+ spex export my-org/my-skill --skill .claude/skills/my-skill
79
+ spex publish my-org/my-skill --dry-run
80
+ spex publish my-org/my-skill
100
81
  ```
101
82
 
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:
83
+ The login command signs you in to the public registry with a code in
84
+ your browser. Open the address it prints and enter the code it shows.
85
+ `spex export`
86
+ builds `spex-packages/my-org/my-skill/` by copying the skill, which
87
+ stays in `.claude/skills/` for your agent; it adds nothing to
88
+ `spex.yaml`. After you edit the skill, `spex export my-org/my-skill`
89
+ refreshes the copy. The dry run shows the registry, the version and the
90
+ files, and publishes nothing. Replace `my-org` with a namespace your
91
+ registry account can use; check
92
+ [Your orgs](https://spex.sublang.ai/account/orgs?scope=registry) when using
93
+ Spex Space. Your personal namespace may already be available after
94
+ sign-in, so creating a Space group or claiming an organization is not a
95
+ prerequisite.
96
+
97
+ ## spex.yaml and spex.lock
98
+
99
+ A folder's packages are listed in two files at its top, `spex.yaml` and
100
+ `spex.lock`, and installed under `.spex/`. Each package command acts on
101
+ the nearest folder holding `spex.yaml`, the current one included, else
102
+ the top level of the Git work tree, else the current folder.
103
+
104
+ | Path | Holds | In Git |
105
+ | --- | --- | --- |
106
+ | `spex.yaml` | the packages you add and the registry they come from | commit it |
107
+ | `spex.lock` | the exact version, source and file digests of every package installed | commit it |
108
+ | `.spex/` | the installed files and the skills made for your agents | ignored by its own `.gitignore` |
109
+ | `spex-packages/<org>/<pkg>/` | each package you develop here | commit it |
110
+ | `specs/packages/<pkg>.md` | the spec a package provides, placed in your `specs/` | commit it |
111
+ | `.gitattributes` | the lines keeping `spex.yaml`, `spex.lock` and placed specs at LF on every checkout | commit it |
112
+ | `.claude/skills/`, `.agents/skills/` | the skills placed for your agents | ignored through `.git/info/exclude` |
113
+
114
+ A `spex.yaml` looks like this:
115
+
116
+ ```yaml
117
+ format: 1
118
+ registry: https://spex.sublang.ai
119
+ space: https://your-space.example
120
+ language: en
121
+ packages:
122
+ my-org/toolkit:
123
+ version: ^1.2.0
124
+ my-org/my-skill:
125
+ path: spex-packages/my-org/my-skill
126
+ ```
127
+
128
+ - `registry` is where packages come from and the default destination
129
+ for `spex publish`. A new `spex.yaml` names the public registry, Spex Space
130
+ at `https://spex.sublang.ai`; that is also the default when `registry`
131
+ is absent.
132
+ - `space`, optional, is the Space this project's records sync with. It
133
+ changes nothing about where packages come from.
134
+ - `language`, optional, picks each package's files in that language
135
+ where the package has them, else its original.
136
+ - Each package has one source: `version` from the registry, `path` for a
137
+ folder in this project, used in place, or `git` with `rev` and an
138
+ optional `path` for a Git repository.
139
+ - A version is exact (`1.2.3`), caret (`^1.2.3`: any 1.x from 1.2.3) or
140
+ tilde (`~1.2.3`: any 1.2.x from 1.2.3).
141
+
142
+ To change the project registry, edit `registry` in `spex.yaml`, preserving
143
+ the other fields. `spex search` and `spex add` use that choice.
144
+ `spex publish --registry <url>` selects a destination for that command.
145
+ `spex login --registry <url>` signs in at an address without changing
146
+ the project's configuration.
147
+
148
+ `spex install` installs what `spex.lock` records, so every clone
149
+ installs the same files. It updates `spex.lock` first only where the
150
+ file is missing or out of date: `spex.yaml` changed since, or a folder
151
+ package's `meta.yaml` no longer matches it. `spex update` moves to the
152
+ newest versions `spex.yaml` allows, on purpose. Downloaded files are
153
+ checked against the digests in `spex.lock` and kept once in the home's
154
+ `store/`, then linked or copied into `.spex/packages/`.
155
+
156
+ Only what a package's `meta.yaml` `provides` is placed: a playbook's
157
+ source spec, or a skill the playbook requires, is installed but placed
158
+ nowhere. Installed skills reach every agent. Each one is placed in
159
+ `.claude/skills/<name>/` for Claude Code and `.agents/skills/<name>/` for
160
+ Codex, Gemini CLI, Kimi Code and OpenCode. A playbook's launch skill
161
+ goes to `.claude/skills/` only. A folder of yours under the same name
162
+ stays as it is, and the command says it left that skill out.
163
+
164
+ A package's spec is placed in your `specs/` as
165
+ `specs/packages/<pkg>.md`, its first line naming the package and
166
+ version, for you to commit with your code. Edit it and it is yours: Spex
167
+ leaves it standing and says which newer version waits. A file of that
168
+ name of your own keeps the spec out, and a folder without `specs/` gets
169
+ none until you run `spex scaffold`.
170
+
171
+ The Spex app reads the same files. Open the folder as a project in the
172
+ app, before or after you use the CLI, and its **Packages** tab shows the
173
+ same packages. What one writes, the other reads at its next use. Only
174
+ the app:
175
+
176
+ - runs an installed playbook in a session, with a default player for
177
+ each role and choices on the **Playbooks** tab;
178
+ - prepares each installed playbook to run on its engine;
179
+ - holds the built-in playbooks, `sublang/playbooks`, which come with
180
+ Spex as a global package. `spex install` uses a copy the app keeps in
181
+ the same home, or a registry, where it can; otherwise it leaves them
182
+ to the app and says so.
183
+
184
+ ## Commands
185
+
186
+ The tables follow `spex --help`. `spex <command> --help` prints a
187
+ command's lines and every option it takes; `spex --version` prints the
188
+ installed version.
189
+
190
+ ### Packages in this folder (spex.yaml, spex.lock, .spex/)
191
+
192
+ | Command | What it does |
193
+ | --- | --- |
194
+ | `spex add <org>/<pkg>[@<version>]` | Add a package (newest by default) |
195
+ | `spex add <org>/<pkg> --path <folder>` | Add a package from a folder in this project |
196
+ | `spex remove <org>/<pkg>`, alias `rm` | Remove a package |
197
+ | `spex install`, alias `i` | Install what `spex.lock` records |
198
+ | `spex update` | Update to the newest versions `spex.yaml` allows |
199
+ | `spex list`, alias `ls` | What is added, installed, and placed for your agents |
200
+ | `spex search <query>` | Find packages at the registry |
201
+
202
+ ### Your packages
203
+
204
+ | Command | What it does |
205
+ | --- | --- |
206
+ | `spex export <org>/<pkg> [--spec <file>] [--skill <folder>]…` | Build it in `spex-packages/<org>/<pkg>/` from your files |
207
+ | `spex publish [<org>/<pkg>] [--registry <url>] [--dry-run]` | Publish it to the registry |
208
+
209
+ ### Sign-in
210
+
211
+ | Command | What it does |
212
+ | --- | --- |
213
+ | `spex login [--registry <url> \| --space <url>]` | Sign in with a code in your browser |
214
+ | `spex logout [--registry <url> \| --space <url>]` | Sign out |
215
+ | `spex whoami [--registry <url> \| --space <url>]` | Who you are signed in as, and where |
216
+
217
+ ### Specs
218
+
219
+ | Command | What it does |
220
+ | --- | --- |
221
+ | `spex scaffold [<path> \| --update]` | Start `specs/` and point your agents at it |
222
+ | `spex lint [<path>]` | Check `specs/` for structure, IDs and citations |
223
+
224
+ [Scaffolding specs](#scaffolding-specs) and [Linting](#linting) describe
225
+ them in full.
226
+
227
+ ### `spex add`, `remove`, `update` and `list`
228
+
229
+ - `spex add <org>/<pkg>` adds the newest version the registry lists
230
+ that is no prerelease, as `^<version>`; `@<version>` adds the one you
231
+ write. `--path` adds a folder in this project instead, read in place.
232
+ It installs and places what each package provides, a spec in
233
+ `specs/packages/<pkg>.md`, and prints where each went, the spec's line
234
+ as `spex list` reads it. A malformed name or version, a version and
235
+ `--path` together, a folder outside this project or holding no
236
+ `meta.yaml` of that package, and a package the registry does not list
237
+ to you are each refused before anything is written.
238
+ - `spex remove` drops a package you added, with what only it needed,
239
+ and refuses one `spex.yaml` does not list. The built-in playbooks
240
+ cannot be removed: "sublang/playbooks comes with Spex".
241
+ - `spex update` updates every package at once and prints each one whose
242
+ version changed. It takes no package name.
243
+ - `spex list` heads with the folder and the registry, then lists what
244
+ is **Added** to `spex.yaml`, what is **Installed** with its version
245
+ and source — from the registry, from a folder, from Git or built in —
246
+ and the **Skills for agents** with the folders each is placed in. A
247
+ last line says what to do: `Not installed yet — spex install` after a
248
+ clone, or what changed with `spex update` once `spex.yaml` or a folder
249
+ package changed. In a folder with no packages, it says so and names
250
+ `spex add`.
251
+ - Beneath an installed package that provides a spec, `spex list` says
252
+ where the spec stands, and each package its links wait for:
253
+
254
+ ```text
255
+ Installed
256
+ my-org/rules 1.1.0 from the registry installed
257
+ spec edited in specs/ — left as yours, 1.1.0 waiting
258
+ my-org/toolkit 1.2.0 from the registry installed
259
+ spec in specs/packages/toolkit.md
260
+ 2 links wait for my-org/base — spex add my-org/base
261
+ ```
262
+
263
+ One link reads `1 link waits`. A spec a file of yours keeps out reads
264
+ `spec not placed — specs/ holds <pkg>.md already`, and one in a folder
265
+ with no `specs/` reads `spec needs specs/ — spex scaffold`.
266
+
267
+ ### `spex export`
268
+
269
+ - `<org>` and `<pkg>` are lowercase letters, digits and single hyphens,
270
+ at most 64 characters each.
271
+ - It copies: your skill folders and your spec stay where they are, and
272
+ nothing is added to `spex.yaml`.
273
+ - Each `--skill` folder needs a `SKILL.md` whose frontmatter `name` is an
274
+ Agent Skills name. It lands at `skills/<language>/<name>/`.
275
+ - The `--spec` file must be named `<pkg>.md`. It lands at
276
+ `specs/<language>/<pkg>.md`. A package holds at most one spec.
277
+ - The spec's citations are rewritten for the package: one of the spec of
278
+ a package in `spex-packages/`, or of a spec this folder's install
279
+ placed, becomes its address, `spex:<org>/<pkg>#<id>`; one of a spec of
280
+ no package is dropped, its words kept; a decision record's link keeps
281
+ its text. Each citation dropped or reduced is printed as a warning.
282
+ - `--language <tag>` sets `<language>`, else `en`.
283
+ - A first export writes `meta.yaml` at version `0.1.0`, with `provides`
284
+ listing the kinds you gave. Its description is `--description <text>`,
285
+ else the first skill's `description`, else the spec's first paragraph
286
+ under its Intent heading. Its license is `--license <id>`, else `MIT`
287
+ where the folder's `LICENSE` begins with "MIT License", else
288
+ `Apache-2.0`. The folder's `LICENSE` is copied in, and a README made.
289
+ - Run again, it refreshes the spec and each skill from your files: the
290
+ spec `<pkg>.md` wherever it stands under `specs/`, and each skill from
291
+ a folder of its name in `.claude/skills/` or `.agents/skills/` that
292
+ Spex did not place. `meta.yaml` stays as you left it; a `--skill` or
293
+ `--spec` naming something new adds its entry. A playbook stays as it
294
+ is, and anything not found is reported and left as it was.
295
+ - Every rule is checked before anything is written. A refusal writes
296
+ nothing.
297
+ - Export works without signing in or contacting a registry. Its
298
+ publishing-rights notice reminds you to check the namespace with the
299
+ registry; creating a local package grants no right to publish it.
300
+
301
+ ### `spex publish`
302
+
303
+ - With a name, it publishes the folder `spex.yaml` adds that package
304
+ from, else `spex-packages/<org>/<pkg>/`. With no name, it publishes the
305
+ one package under `spex-packages/`, and lists them where there are
306
+ several.
307
+ - It uses `--registry <url>` if given, otherwise the `registry` in
308
+ `spex.yaml`, or `https://spex.sublang.ai` if the project has no registry
309
+ setting. Use the same flag for the dry run and upload when overriding
310
+ the project registry. Sign in at the chosen registry with
311
+ `spex login --registry <url>`.
312
+ - The org is the namespace before `/` in the package's name. At Spex
313
+ Space, check [Your orgs](https://spex.sublang.ai/account/orgs?scope=registry)
314
+ in your registry account. A valid, available sign-in name becomes your
315
+ personal namespace automatically; you can also claim an organization
316
+ you own. A Space group grants no publishing namespace.
317
+ - Packages are public by default. **Private packages** restricts a
318
+ namespace's packages to its personal owner or organization members.
319
+ - A signed-in dry run and every publication check that the registry
320
+ authorizes your account to publish under the namespace. An unsigned
321
+ dry run still validates local files, and reports that publishing
322
+ rights are unchecked.
323
+ - `meta.yaml` needs a `description` and a `license`.
324
+ - `--dry-run` prints `Publishing <org>/<pkg>@<version> to <registry>`
325
+ and the files, and publishes nothing. A publish prints the same first
326
+ line, then the package's page at the registry.
327
+ - A release never changes. Raise `version` in `meta.yaml` before you
328
+ publish again.
329
+
330
+ ## Signing in
331
+
332
+ A registry sign-in and a Space sign-in are separate, even at one
333
+ address: the first reads private packages and publishes, the second
334
+ syncs a project's records.
105
335
 
106
336
  ```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
337
+ spex login
338
+ spex login --registry https://spex.sublang.ai
339
+ spex login --space https://your-space.example
340
+ spex whoami
341
+ spex logout --registry https://spex.sublang.ai
110
342
  ```
111
343
 
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
344
+ - With no flag, `login`, `logout` and `whoami` act on the registry
345
+ `spex.yaml` names, or the public registry when it names none.
346
+ `--registry <url>` or `--space <url>` picks another; the two cannot be
347
+ combined.
348
+ - These sign-in commands leave the project registry setting alone.
349
+ Edit `registry` in `spex.yaml` to change it, or pass `--registry <url>`
350
+ to `spex publish` for one invocation.
351
+ - `spex login` signs in with a code in your browser: it prints an
352
+ address and a code, and waits until you approve or deny there, or the
353
+ code expires. Ctrl-C stops it and saves nothing.
354
+ - A sign-in you already have is reported and kept; `--force` replaces
355
+ it. Signing in to a registry adds no Space.
356
+ - `spex whoami` prints only the selected registry account, with
357
+ `@<login>` or `signed out`. Use `spex whoami --space <url>` to inspect
358
+ a Space account separately; `(default)` marks the home's default Space.
359
+
360
+ ```text
361
+ Registry Spex Space @me
362
+ ```
363
+
364
+ - `spex logout` signs out of the one it acts on. Signing out of a
365
+ registry keeps your Space sign-ins, and signing out of a Space keeps
366
+ your registry sign-in. A Space you signed out of stays listed as
367
+ `signed out`.
368
+ - Public packages need no sign-in. Private packages and publishing need
369
+ a registry sign-in on the computer running the command, a team server
370
+ included; a Space sign-in gives none.
371
+ - A `<url>` is just the address, like `https://spex.sublang.ai`: the
372
+ host, with a port where it is not the default, and no path. `http` is
373
+ accepted only for a loopback address such as `localhost`.
374
+ - The home is `SPEX_HOME`, else `~/.spex`. The Spaces you signed in to
375
+ are listed in its `home.yaml`; sign-ins are kept in
376
+ `local/credentials.yaml`, readable by you alone. No command prints a
377
+ token.
378
+
379
+ ## Exit codes
380
+
381
+ The package commands exit with these codes. `scaffold` and `lint` keep
382
+ their own.
383
+
384
+ | Code | Meaning |
385
+ | --- | --- |
386
+ | `0` | the command succeeded |
387
+ | `1` | a refusal or a failure, its cause on standard error |
388
+ | `130` | interrupted, as by Ctrl-C |
389
+
390
+ A cause is one line naming the registry, the Space or the file by its
391
+ name, and ends in what to do where there is something to do:
392
+
393
+ ```text
394
+ acme/secret: not at Spex Space, or private — spex login, then retry
395
+ Spex Space could not be reached — check the connection, then retry
396
+ my-org is not yours at Spex Space — claim it at https://spex.sublang.ai/account/orgs?scope=registry
397
+ sign-in expired at Spex Space — spex login
398
+ spex.lock is from a newer Spex — update Spex
399
+ ```
400
+
401
+ An interrupted install leaves the last installed files and `spex.lock`
402
+ in place. An interrupted publish cannot take back a release the registry
403
+ already accepted.
404
+
405
+ ## Limits
406
+
407
+ - The CLI acts on a project folder's packages. Global packages, available
408
+ in every project of yours, are managed on **Playbooks** in the app.
409
+ - No command adds a Git source. A `git` package you write in `spex.yaml`
410
+ by hand is installed as written. The Space `spex.yaml` names, else your
411
+ default Space, lends its Git access to the repositories it holds while
412
+ you are signed in there; other repositories use this computer's Git
413
+ access. A registry sign-in gives no Git access.
414
+ - The built-in playbooks, `sublang/playbooks`, come with the Spex app as a
415
+ global package, removable there like any other package.
416
+ `spex install` installs them from the copy the app keeps in the same
417
+ home, where there is one, or from the registry, else leaves them to
418
+ the app.
419
+
420
+ ## Scaffolding specs
131
421
 
132
422
  ```sh
133
423
  spex scaffold
@@ -142,7 +432,7 @@ This creates:
142
432
  - Two starter packages (`git.md`, `licensing.md`) and a sample intent record seed the tree.
143
433
  - **`LICENSE`** — the verbatim Apache-2.0 text at the target root, written only when no `LICENSE` exists there.
144
434
  - **Agent instruction files** — a managed section that tells coding
145
- agents to read relevant specs, resolve conflicts there first, and keep
435
+ agents to read relevant specs, settle conflicts in them first, and keep
146
436
  specs and code aligned: `CLAUDE.md` for Claude Code, `AGENTS.md` for
147
437
  Codex, Kimi Code, and OpenCode, and `GEMINI.md` for Gemini CLI.
148
438
 
@@ -234,6 +524,65 @@ The command prints a per-file indicator for every framework and seed path, plus
234
524
 
235
525
  ## Upgrading from an earlier release
236
526
 
527
+ ### From a pre-release source build
528
+
529
+ If your source build used `spex new`, use `spex export <org>/<pkg>` in its
530
+ place. It builds the folder by copying your files and can be run again
531
+ to refresh it; it adds nothing to `spex.yaml` and has no `--move`.
532
+ A folder `spex new` made keeps working; a skill `--move` took into it is
533
+ edited there, since `spex export` refreshes a skill only from a folder
534
+ of yours.
535
+
536
+ Your next install places each package's spec in
537
+ `specs/packages/<pkg>.md`, where the folder holds `specs/`, in place of
538
+ its `<org>-<pkg>` skill; commit the new files. A skill that only
539
+ supports a playbook is no longer placed for your agents.
540
+
541
+ ### From 4.x
542
+
543
+ Spex 5.0 replaces the commands that attached to a running app with
544
+ top-level commands that need no app:
545
+
546
+ | 4.x | 5.0 |
547
+ | --- | --- |
548
+ | `spex package init <org>/<name> ...` | `spex export <org>/<pkg> ...`, building `spex-packages/<org>/<pkg>/` from your files |
549
+ | `spex package add <org>/<pkg> --version <requirement>` | `spex add <org>/<pkg>@<version>` |
550
+ | `spex package add <org>/<pkg> --path <folder>` | `spex add <org>/<pkg> --path <folder>` |
551
+ | `spex package install` | `spex install` |
552
+ | `spex package resolve` | `spex update` |
553
+ | `spex package remove <org>/<pkg>` | `spex remove <org>/<pkg>` |
554
+ | `spex package search <query>` | `spex search <query>` |
555
+ | `spex package status` | `spex list` |
556
+ | `spex package publish <folder> [--dry-run]` | `spex publish <org>/<pkg> [--dry-run]` |
557
+ | `spex auth login --instance <origin>` | `spex login --space <url>` |
558
+ | `spex auth status` | `spex whoami --space <url>` |
559
+ | none | `spex logout` |
560
+ | `spex project add <folder>`, `spex project list` | none: no project needs adding |
561
+ | `--server`, `SPEX_SERVER_URL`, `--project`, `--timeout` | none: no app is needed |
562
+
563
+ The package commands now run inside the CLI on the folder's own files,
564
+ and the Spex app runs the same code. `spex.yaml` and `spex.lock` stand
565
+ at the top of the project folder, with the installed files under
566
+ `.spex/`; the two files an earlier app kept in a project's records move
567
+ into its project folder at the app's next start.
568
+
569
+ - A `spex.yaml` without `registry` uses the public registry for search,
570
+ resolution and publishing. Name another package service in `registry`
571
+ or use `spex publish --registry <url>` for one publication.
572
+ - `spex whoami` shows the registry account. Use
573
+ `spex whoami --space <url>` for a Space account.
574
+ - `spex.lock` keeps each package's registry, version and checksum as
575
+ recorded. An install downloads only from the registry it records,
576
+ never from another Space you signed in to.
577
+ - A sign-in an earlier release saved stays a Space sign-in and never
578
+ counts at a registry: run `spex login --registry <url>` once for
579
+ private packages and publishing.
580
+
581
+ A folder `spex package init` made at `spex-packages/<name>/` still
582
+ publishes by name while `spex.yaml` adds it from that path. Exit code
583
+ `2` is gone. Deep imports such as `@sublang/spex/dist/cli.js` are no
584
+ longer importable; the `exports` of `package.json` name its modules.
585
+
237
586
  ### From 2.x
238
587
 
239
588
  Spex 3.0 makes intent records disposable planning artifacts: no other