@sublang/spex 5.0.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.
- package/README.md +34 -29
- package/dist/commands/add.js +1 -1
- package/dist/commands/auth-target.d.ts +1 -0
- package/dist/commands/auth-target.js +4 -2
- package/dist/commands/environment.d.ts +12 -18
- package/dist/commands/environment.js +38 -50
- package/dist/commands/publish.js +15 -15
- package/dist/commands/run.d.ts +1 -1
- package/dist/commands/run.js +6 -3
- package/dist/commands/search.js +1 -1
- package/dist/commands/settle.js +2 -2
- package/dist/commands/whoami.js +2 -6
- package/dist/lib/environment/archive.d.ts +16 -3
- package/dist/lib/environment/archive.js +39 -8
- package/dist/lib/environment/builtins.js +1 -1
- package/dist/lib/environment/registries.d.ts +7 -9
- package/dist/lib/environment/registries.js +9 -36
- package/dist/lib/environment/registry.d.ts +5 -6
- package/dist/lib/environment/registry.js +11 -11
- package/dist/lib/environment/requests.d.ts +4 -3
- package/dist/lib/environment/requests.js +4 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,17 +70,19 @@ After a clone, `spex install` installs what `spex.lock` records. Public
|
|
|
70
70
|
packages need no sign-in; private ones need `spex login` first. Put real
|
|
71
71
|
names in place of the examples.
|
|
72
72
|
|
|
73
|
-
Build a package from a skill you already have, then publish it
|
|
73
|
+
Build a package from a skill you already have, then publish it. This
|
|
74
|
+
example assumes your project uses the public registry.
|
|
74
75
|
|
|
75
76
|
```sh
|
|
76
|
-
spex login
|
|
77
|
+
spex login --registry https://spex.sublang.ai
|
|
77
78
|
spex export my-org/my-skill --skill .claude/skills/my-skill
|
|
78
79
|
spex publish my-org/my-skill --dry-run
|
|
79
80
|
spex publish my-org/my-skill
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
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`
|
|
84
86
|
builds `spex-packages/my-org/my-skill/` by copying the skill, which
|
|
85
87
|
stays in `.claude/skills/` for your agent; it adds nothing to
|
|
86
88
|
`spex.yaml`. After you edit the skill, `spex export my-org/my-skill`
|
|
@@ -123,9 +125,10 @@ packages:
|
|
|
123
125
|
path: spex-packages/my-org/my-skill
|
|
124
126
|
```
|
|
125
127
|
|
|
126
|
-
- `registry` is where packages come from
|
|
127
|
-
|
|
128
|
-
at `https://spex.sublang.ai
|
|
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.
|
|
129
132
|
- `space`, optional, is the Space this project's records sync with. It
|
|
130
133
|
changes nothing about where packages come from.
|
|
131
134
|
- `language`, optional, picks each package's files in that language
|
|
@@ -136,10 +139,11 @@ packages:
|
|
|
136
139
|
- A version is exact (`1.2.3`), caret (`^1.2.3`: any 1.x from 1.2.3) or
|
|
137
140
|
tilde (`~1.2.3`: any 1.2.x from 1.2.3).
|
|
138
141
|
|
|
139
|
-
To
|
|
140
|
-
the other fields. `spex search
|
|
141
|
-
|
|
142
|
-
signs in at an address without changing
|
|
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.
|
|
143
147
|
|
|
144
148
|
`spex install` installs what `spex.lock` records, so every clone
|
|
145
149
|
installs the same files. It updates `spex.lock` first only where the
|
|
@@ -200,7 +204,7 @@ installed version.
|
|
|
200
204
|
| Command | What it does |
|
|
201
205
|
| --- | --- |
|
|
202
206
|
| `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 |
|
|
207
|
+
| `spex publish [<org>/<pkg>] [--registry <url>] [--dry-run]` | Publish it to the registry |
|
|
204
208
|
|
|
205
209
|
### Sign-in
|
|
206
210
|
|
|
@@ -300,8 +304,11 @@ them in full.
|
|
|
300
304
|
from, else `spex-packages/<org>/<pkg>/`. With no name, it publishes the
|
|
301
305
|
one package under `spex-packages/`, and lists them where there are
|
|
302
306
|
several.
|
|
303
|
-
- It
|
|
304
|
-
|
|
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>`.
|
|
305
312
|
- The org is the namespace before `/` in the package's name. At Spex
|
|
306
313
|
Space, check [Your orgs](https://spex.sublang.ai/account/orgs?scope=registry)
|
|
307
314
|
in your registry account. A valid, available sign-in name becomes your
|
|
@@ -334,25 +341,24 @@ spex whoami
|
|
|
334
341
|
spex logout --registry https://spex.sublang.ai
|
|
335
342
|
```
|
|
336
343
|
|
|
337
|
-
- With no flag, `login` and `
|
|
338
|
-
names, or
|
|
344
|
+
- With no flag, `login`, `logout` and `whoami` act on the registry
|
|
345
|
+
`spex.yaml` names, or the public registry when it names none.
|
|
339
346
|
`--registry <url>` or `--space <url>` picks another; the two cannot be
|
|
340
347
|
combined.
|
|
341
|
-
- These
|
|
342
|
-
|
|
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.
|
|
343
351
|
- `spex login` signs in with a code in your browser: it prints an
|
|
344
352
|
address and a code, and waits until you approve or deny there, or the
|
|
345
353
|
code expires. Ctrl-C stops it and saves nothing.
|
|
346
354
|
- A sign-in you already have is reported and kept; `--force` replaces
|
|
347
355
|
it. Signing in to a registry adds no Space.
|
|
348
|
-
- `spex whoami` prints
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
`space` uses; with a flag, it prints that line alone:
|
|
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.
|
|
352
359
|
|
|
353
360
|
```text
|
|
354
361
|
Registry Spex Space @me
|
|
355
|
-
Space Spex Space @me (default)
|
|
356
362
|
```
|
|
357
363
|
|
|
358
364
|
- `spex logout` signs out of the one it acts on. Signing out of a
|
|
@@ -560,12 +566,11 @@ at the top of the project folder, with the installed files under
|
|
|
560
566
|
`.spex/`; the two files an earlier app kept in a project's records move
|
|
561
567
|
into its project folder at the app's next start.
|
|
562
568
|
|
|
563
|
-
- A `spex.yaml` without `registry`
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
`spex.yaml` needs a registry sign-in at that same address.
|
|
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.
|
|
569
574
|
- `spex.lock` keeps each package's registry, version and checksum as
|
|
570
575
|
recorded. An install downloads only from the registry it records,
|
|
571
576
|
never from another Space you signed in to.
|
package/dist/commands/add.js
CHANGED
|
@@ -114,7 +114,7 @@ export const add = async (args) => {
|
|
|
114
114
|
const target = env.registryOf(read?.requests ?? null);
|
|
115
115
|
let versions;
|
|
116
116
|
try {
|
|
117
|
-
versions = (await env.registryAt(target.origin
|
|
117
|
+
versions = (await env.registryAt(target.origin).index(name)).versions;
|
|
118
118
|
}
|
|
119
119
|
catch (error) {
|
|
120
120
|
throw await env.registryRefusal(error, { origin: target.origin, scope: target.scope });
|
|
@@ -37,14 +37,16 @@ export function authTarget(home, values) {
|
|
|
37
37
|
if (origin === undefined) {
|
|
38
38
|
origin = environmentRegistry(nearestRequests(), { origin: defaultInstance(home).origin, instances: home?.instances ?? [] }).origin;
|
|
39
39
|
}
|
|
40
|
+
return { target: { origin: registryOption(origin), clientId: "spex" }, scope: "registry" };
|
|
41
|
+
}
|
|
42
|
+
export function registryOption(origin) {
|
|
40
43
|
try {
|
|
41
|
-
|
|
44
|
+
return canonicalOrigin(origin);
|
|
42
45
|
}
|
|
43
46
|
catch (error) {
|
|
44
47
|
if (error instanceof OriginRefused)
|
|
45
48
|
throw addressRefusal("--registry", origin, error);
|
|
46
49
|
throw error;
|
|
47
50
|
}
|
|
48
|
-
return { target: { origin, clientId: "spex" }, scope: "registry" };
|
|
49
51
|
}
|
|
50
52
|
//# sourceMappingURL=auth-target.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContentStore, type EnvironmentRegistry, RegistryClient, type GitSource, type Lock, type RegistrySource, type RegistrySourceLock, type Requests } from "../lib/environment/index.js";
|
|
2
2
|
import { type FileVersion } from "../lib/files.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type AuthScope } from "../lib/git-host.js";
|
|
4
4
|
import { type HomeFile } from "../lib/home-file.js";
|
|
5
5
|
import { Refusal } from "./run.js";
|
|
6
6
|
/** Where a path is on disk, spelled as the file system spells it: its
|
|
@@ -75,7 +75,7 @@ export declare class Environment {
|
|
|
75
75
|
* purpose there; undefined where it holds one whose login cannot be
|
|
76
76
|
* read now. A Space's login is its home entry's; a registry's is read
|
|
77
77
|
* from its account API. */
|
|
78
|
-
loginAt(origin: string
|
|
78
|
+
loginAt(origin: string): Promise<string | null | undefined>;
|
|
79
79
|
/** A registry's refusal or failure as one phrase ending in what to do
|
|
80
80
|
* (cli-13): the registry named as cli-22 names it, a private package by
|
|
81
81
|
* the sign-in state, a 403 by the operation refused. */
|
|
@@ -93,31 +93,25 @@ export declare class Environment {
|
|
|
93
93
|
signedInAt(origin: string): boolean;
|
|
94
94
|
/** Every instance the home is signed in to, in its order. */
|
|
95
95
|
signedIn(): string[];
|
|
96
|
-
/** The
|
|
97
|
-
* (environments-12)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* refuses removes its token and marks it signed out in `home.yaml` in
|
|
102
|
-
* one step, as the app's sign-out does (git-host-4). */
|
|
96
|
+
/** The package registry's access secret, kept current by its scoped
|
|
97
|
+
* client (environments-12), independent of any Space sign-in. */
|
|
98
|
+
tokenAt(origin: string): Promise<string | null>;
|
|
99
|
+
/** One registry-purpose client per origin. A refused refresh affects
|
|
100
|
+
* only its registry slot and never the Space's home entry. */
|
|
103
101
|
private clientAt;
|
|
104
|
-
private markSignedOut;
|
|
105
102
|
/** The built-in spec package as this device's seed holds it
|
|
106
103
|
* (environments-7, environments-11): what the app seeded into the
|
|
107
104
|
* shared store, read from `cache/builtins/`; the command line ships
|
|
108
105
|
* none of its own. */
|
|
109
106
|
seed(): RegistrySource;
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
* the device out there marks it signed out in `home.yaml`
|
|
113
|
-
* (environments-12, git-host-4). The built-in spec package is answered
|
|
114
|
-
* from this device's seed first, as the app answers it. */
|
|
107
|
+
/** One package registry and its independent grant, composed with the
|
|
108
|
+
* device's built-in seed (environments-12). */
|
|
115
109
|
private registry;
|
|
116
|
-
registryAt(origin: string
|
|
117
|
-
registryClientAt(origin: string
|
|
110
|
+
registryAt(origin: string): RegistrySource;
|
|
111
|
+
registryClientAt(origin: string): RegistryClient;
|
|
118
112
|
/** The registries an install asks for a registry package's files, in
|
|
119
113
|
* the library's order (environments-7). */
|
|
120
|
-
installRegistries(instance: string, source: RegistrySourceLock
|
|
114
|
+
installRegistries(instance: string, source: RegistrySourceLock): RegistrySource[];
|
|
121
115
|
}
|
|
122
116
|
/** Whether a folder stands at a path. */
|
|
123
117
|
export declare function isDirectory(path: string): boolean;
|
|
@@ -18,7 +18,8 @@ import { homedir } from "node:os";
|
|
|
18
18
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
19
19
|
import { builtinRegistrySource, compositeRegistry, ContentStore, environmentInstance, environmentRegistry, FormatError, gitSource, installRegistryOrder, LockError, parseLock, parseRequests, RegistryClient, RegistryError, RequestsError, unaskedRegistry, } from "../lib/environment/index.js";
|
|
20
20
|
import { readVersioned } from "../lib/files.js";
|
|
21
|
-
import {
|
|
21
|
+
import { CredentialChanged } from "../lib/git-host.js";
|
|
22
|
+
import { accountAt, instanceAt } from "../lib/home-file.js";
|
|
22
23
|
import { canonicalOrigin } from "../lib/instance.js";
|
|
23
24
|
import { clientOf, credentialsOf, defaultInstance, homeDir, hostCause, nameOf, readHome, registryName } from "./home.js";
|
|
24
25
|
import { Refusal } from "./run.js";
|
|
@@ -209,10 +210,8 @@ export class Environment {
|
|
|
209
210
|
* purpose there; undefined where it holds one whose login cannot be
|
|
210
211
|
* read now. A Space's login is its home entry's; a registry's is read
|
|
211
212
|
* from its account API. */
|
|
212
|
-
async loginAt(origin
|
|
213
|
-
|
|
214
|
-
return this.home ? accountAt(this.home, origin)?.login ?? null : null;
|
|
215
|
-
const credentials = credentialsOf(this.homeDir, origin, scope);
|
|
213
|
+
async loginAt(origin) {
|
|
214
|
+
const credentials = credentialsOf(this.homeDir, origin, "registry");
|
|
216
215
|
try {
|
|
217
216
|
if (!(await credentials.read()))
|
|
218
217
|
return null;
|
|
@@ -221,7 +220,7 @@ export class Environment {
|
|
|
221
220
|
return undefined;
|
|
222
221
|
}
|
|
223
222
|
try {
|
|
224
|
-
return (await clientOf(origin, credentials, undefined,
|
|
223
|
+
return (await clientOf(origin, credentials, undefined, "registry").me()).login;
|
|
225
224
|
}
|
|
226
225
|
catch {
|
|
227
226
|
try {
|
|
@@ -252,17 +251,19 @@ export class Environment {
|
|
|
252
251
|
catch { /* the registry asked */ }
|
|
253
252
|
const name = await this.registryName(origin);
|
|
254
253
|
const pkg = error.packageName;
|
|
255
|
-
// `spex login`
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
254
|
+
// `spex login` selects this folder's package registry (cli-10).
|
|
255
|
+
// An exact locked source at another registry names that target.
|
|
256
|
+
const login = context.operation !== "publish" && origin === context.origin
|
|
257
|
+
? "spex login"
|
|
258
|
+
: `spex login --registry ${origin}`;
|
|
260
259
|
const about = pkg ? `${pkg}: ` : "";
|
|
260
|
+
if (error.cause instanceof CredentialChanged)
|
|
261
|
+
return new Refusal(`your sign-in at ${name} changed meanwhile — retry`);
|
|
261
262
|
switch (error.kind) {
|
|
262
263
|
case "not_found": {
|
|
263
264
|
if (error.code === "suppressed")
|
|
264
265
|
return new Refusal(`${about}withdrawn at ${name} — spex update picks another version`);
|
|
265
|
-
const who = await this.loginAt(origin
|
|
266
|
+
const who = await this.loginAt(origin);
|
|
266
267
|
if (who === null)
|
|
267
268
|
return new Refusal(`${about}not at ${name}, or private — ${login}, then retry`);
|
|
268
269
|
return new Refusal(`${about}not at ${name}, or not shared with ${who === undefined ? "this account" : `@${who}`} — check the name, or ask its owner`);
|
|
@@ -272,7 +273,7 @@ export class Environment {
|
|
|
272
273
|
const org = pkg?.split("/")[0] ?? "this org";
|
|
273
274
|
return new Refusal(`${org} is not yours at ${name} — claim it at ${origin}/account/orgs?scope=registry`);
|
|
274
275
|
}
|
|
275
|
-
const who = await this.loginAt(origin
|
|
276
|
+
const who = await this.loginAt(origin);
|
|
276
277
|
return new Refusal(`${about}not shared with ${typeof who === "string" ? `@${who}` : "this account"} at ${name} — ask its owner`);
|
|
277
278
|
}
|
|
278
279
|
case "unauthenticated":
|
|
@@ -321,38 +322,30 @@ export class Environment {
|
|
|
321
322
|
signedIn() {
|
|
322
323
|
return (this.home?.instances ?? []).filter((entry) => this.signedInAt(entry.origin)).map((entry) => entry.origin);
|
|
323
324
|
}
|
|
324
|
-
/** The
|
|
325
|
-
* (environments-12)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (scope === "space" ? !this.signedInAt(origin) : !(await credentialsOf(this.homeDir, origin, scope).read()))
|
|
325
|
+
/** The package registry's access secret, kept current by its scoped
|
|
326
|
+
* client (environments-12), independent of any Space sign-in. */
|
|
327
|
+
async tokenAt(origin) {
|
|
328
|
+
if (!(await credentialsOf(this.homeDir, origin, "registry").read()))
|
|
329
329
|
return null;
|
|
330
330
|
try {
|
|
331
|
-
return await this.clientAt(origin
|
|
331
|
+
return await this.clientAt(origin).accessSecret();
|
|
332
332
|
}
|
|
333
333
|
catch (error) {
|
|
334
334
|
throw new Error(hostCause(error, await this.registryName(origin)));
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
/**
|
|
338
|
-
*
|
|
339
|
-
|
|
340
|
-
clientAt(origin, scope = "space") {
|
|
337
|
+
/** One registry-purpose client per origin. A refused refresh affects
|
|
338
|
+
* only its registry slot and never the Space's home entry. */
|
|
339
|
+
clientAt(origin) {
|
|
341
340
|
const at = canonicalOrigin(origin);
|
|
342
|
-
const key =
|
|
341
|
+
const key = at;
|
|
343
342
|
let client = this.clients.get(key);
|
|
344
343
|
if (!client) {
|
|
345
|
-
client = clientOf(at, credentialsOf(this.homeDir, at,
|
|
344
|
+
client = clientOf(at, credentialsOf(this.homeDir, at, "registry"), undefined, "registry");
|
|
346
345
|
this.clients.set(key, client);
|
|
347
346
|
}
|
|
348
347
|
return client;
|
|
349
348
|
}
|
|
350
|
-
markSignedOut(origin) {
|
|
351
|
-
try {
|
|
352
|
-
updateHomeFile(this.homeDir, (current) => withSignOut(current, origin));
|
|
353
|
-
}
|
|
354
|
-
catch { /* the token is gone; whoami may still list it */ }
|
|
355
|
-
}
|
|
356
349
|
/** The built-in spec package as this device's seed holds it
|
|
357
350
|
* (environments-7, environments-11): what the app seeded into the
|
|
358
351
|
* shared store, read from `cache/builtins/`; the command line ships
|
|
@@ -361,24 +354,19 @@ export class Environment {
|
|
|
361
354
|
this.builtin ??= builtinRegistrySource({ store: this.store, cacheDir: this.cache });
|
|
362
355
|
return this.builtin;
|
|
363
356
|
}
|
|
364
|
-
/**
|
|
365
|
-
*
|
|
366
|
-
|
|
367
|
-
* (environments-12, git-host-4). The built-in spec package is answered
|
|
368
|
-
* from this device's seed first, as the app answers it. */
|
|
369
|
-
registry(origin, scope) {
|
|
357
|
+
/** One package registry and its independent grant, composed with the
|
|
358
|
+
* device's built-in seed (environments-12). */
|
|
359
|
+
registry(origin) {
|
|
370
360
|
const at = canonicalOrigin(origin);
|
|
371
|
-
const key =
|
|
361
|
+
const key = at;
|
|
372
362
|
let registry = this.registries.get(key);
|
|
373
363
|
if (!registry) {
|
|
374
364
|
const remote = new RegistryClient({
|
|
375
365
|
url: at,
|
|
376
|
-
token: () => this.tokenAt(at
|
|
366
|
+
token: () => this.tokenAt(at),
|
|
377
367
|
refused: async (token) => {
|
|
378
|
-
if (!(await this.clientAt(at
|
|
379
|
-
throw new
|
|
380
|
-
if (scope === "space")
|
|
381
|
-
this.markSignedOut(at);
|
|
368
|
+
if (!(await this.clientAt(at).signOutRefused(token)))
|
|
369
|
+
throw new CredentialChanged();
|
|
382
370
|
},
|
|
383
371
|
});
|
|
384
372
|
registry = { remote, source: compositeRegistry(this.seed(), remote) };
|
|
@@ -386,17 +374,17 @@ export class Environment {
|
|
|
386
374
|
}
|
|
387
375
|
return registry;
|
|
388
376
|
}
|
|
389
|
-
registryAt(origin
|
|
390
|
-
return this.registry(origin
|
|
377
|
+
registryAt(origin) {
|
|
378
|
+
return this.registry(origin).source;
|
|
391
379
|
}
|
|
392
|
-
registryClientAt(origin
|
|
393
|
-
return this.registry(origin
|
|
380
|
+
registryClientAt(origin) {
|
|
381
|
+
return this.registry(origin).remote;
|
|
394
382
|
}
|
|
395
383
|
/** The registries an install asks for a registry package's files, in
|
|
396
384
|
* the library's order (environments-7). */
|
|
397
|
-
installRegistries(instance, source
|
|
398
|
-
return installRegistryOrder(instance, source.registry,
|
|
399
|
-
.map((entry) => ("origin" in entry ? this.registryAt(entry.origin
|
|
385
|
+
installRegistries(instance, source) {
|
|
386
|
+
return installRegistryOrder(instance, source.registry, [])
|
|
387
|
+
.map((entry) => ("origin" in entry ? this.registryAt(entry.origin) : compositeRegistry(this.seed(), unaskedRegistry(entry.unasked))));
|
|
400
388
|
}
|
|
401
389
|
}
|
|
402
390
|
/** Whether a folder stands at a path. */
|
package/dist/commands/publish.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex publish [<org>/<pkg>] [--dry-run]` (cli-9
|
|
3
|
+
// `spex publish [<org>/<pkg>] [--registry <url>] [--dry-run]` (cli-9):
|
|
4
4
|
// publish a package's folder — the folder `spex.yaml` adds that name
|
|
5
5
|
// from, else `spex-packages/<org>/<pkg>/` under the root, and with no
|
|
6
|
-
// name the one package under `spex-packages/` — to
|
|
7
|
-
//
|
|
6
|
+
// name the one package under `spex-packages/` — to the registry selected
|
|
7
|
+
// for this command as the account signed in there for publishing. It says what
|
|
8
8
|
// it publishes to which registry, by the registry's name (cli-22); a dry
|
|
9
9
|
// run lists the declared files and publishes nothing; a publish prints
|
|
10
10
|
// the package's page at the registry. Every refusal comes before
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { readdirSync } from "node:fs";
|
|
13
13
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
14
14
|
import { FormatError, isPackageName, isPathRequest, packageNameRefusal, publishIssues, publishRelease, readRelease, } from "../lib/environment/index.js";
|
|
15
|
+
import { registryOption } from "./auth-target.js";
|
|
15
16
|
import { Environment, isDirectory } from "./environment.js";
|
|
16
17
|
import { parsed, Refusal } from "./run.js";
|
|
17
18
|
/** Every package folder under `spex-packages/`: `<org>/<pkg>` names of
|
|
@@ -37,10 +38,16 @@ function developed(root) {
|
|
|
37
38
|
}
|
|
38
39
|
const issuesText = (issues) => issues.map((issue) => (issue.path ? `${issue.path}: ${issue.message}` : issue.message)).join("; ");
|
|
39
40
|
export const publish = async (args) => {
|
|
40
|
-
const { values, positionals } = parsed("publish", args, {
|
|
41
|
+
const { values, positionals } = parsed("publish", args, {
|
|
42
|
+
registry: { type: "string" },
|
|
43
|
+
"dry-run": { type: "boolean" },
|
|
44
|
+
}, { min: 0, max: 1 });
|
|
41
45
|
const dryRun = values["dry-run"] === true;
|
|
46
|
+
const override = values.registry === undefined ? undefined : registryOption(values.registry);
|
|
42
47
|
const env = new Environment();
|
|
43
48
|
const read = env.readRequests();
|
|
49
|
+
const instance = override ?? env.registryOf(read?.requests ?? null).origin;
|
|
50
|
+
const login = `spex login --registry ${instance}`;
|
|
44
51
|
let name = positionals[0];
|
|
45
52
|
if (name === undefined) {
|
|
46
53
|
const found = developed(env.root);
|
|
@@ -62,17 +69,10 @@ export const publish = async (args) => {
|
|
|
62
69
|
throw new Refusal(`${path} lies outside this project folder, ${env.root} — keep the package inside it`);
|
|
63
70
|
if (!isDirectory(folder))
|
|
64
71
|
throw new Refusal(`no folder for ${name} at ${path} — spex export ${name} --spec <file> | --skill <folder> builds one`);
|
|
65
|
-
// The registry: this folder's, as the account signed in
|
|
66
|
-
// there for publishing (environments-10, DR-168), named by its own
|
|
67
|
-
// display name, never a Space entry's (cli-22).
|
|
68
|
-
const target = env.registryOf(read?.requests ?? null);
|
|
69
|
-
const instance = target.origin;
|
|
70
72
|
const registryName = await env.registryName(instance);
|
|
71
|
-
const signedIn = (await env.tokenAt(instance
|
|
73
|
+
const signedIn = (await env.tokenAt(instance).catch(() => "")) !== null;
|
|
72
74
|
if (!dryRun && !signedIn) {
|
|
73
|
-
|
|
74
|
-
// publishing (cli-10).
|
|
75
|
-
throw new Refusal(`not signed in at ${registryName} to publish — spex login, then retry`);
|
|
75
|
+
throw new Refusal(`not signed in at ${registryName} to publish — ${login}, then retry`);
|
|
76
76
|
}
|
|
77
77
|
let manifest;
|
|
78
78
|
let files;
|
|
@@ -103,11 +103,11 @@ export const publish = async (args) => {
|
|
|
103
103
|
console.log(`Publishing ${held}@${manifest.version} to ${registryName}`);
|
|
104
104
|
if (dryRun) {
|
|
105
105
|
if (!signedIn)
|
|
106
|
-
console.log(`Org not checked — sign in to ${registryName} with
|
|
106
|
+
console.log(`Org not checked — sign in to ${registryName} with ${login} to check publishing rights`);
|
|
107
107
|
console.log(["Files (dry run, nothing published):", ...files.map((file) => ` ${file}`)].join("\n"));
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const registry = env.registryAt(instance
|
|
110
|
+
const registry = env.registryAt(instance);
|
|
111
111
|
try {
|
|
112
112
|
await publishRelease(registry, folder);
|
|
113
113
|
}
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ParseArgsConfig } from "node:util";
|
|
2
2
|
/** The usage, as cli-21 writes it. */
|
|
3
|
-
export declare const USAGE = "Usage: spex <command> [options]\n\nPackages in this folder (spex.yaml, spex.lock, .spex/)\n add <org>/<pkg>[@<version>] Add a package (newest by default)\n add <org>/<pkg> --path <folder> Add a package from a folder in this project\n remove, rm <org>/<pkg> Remove a package\n install, i Install what spex.lock records\n update Update to the newest versions spex.yaml allows\n list, ls What is added, installed, and placed for your agents\n search <query> Find packages at the registry\n\nYour packages\n export <org>/<pkg> [--spec <file>] [--skill <folder>]\u2026 Build it in spex-packages/<org>/<pkg>/ from your files\n publish [<org>/<pkg>] [--dry-run]
|
|
3
|
+
export declare const USAGE = "Usage: spex <command> [options]\n\nPackages in this folder (spex.yaml, spex.lock, .spex/)\n add <org>/<pkg>[@<version>] Add a package (newest by default)\n add <org>/<pkg> --path <folder> Add a package from a folder in this project\n remove, rm <org>/<pkg> Remove a package\n install, i Install what spex.lock records\n update Update to the newest versions spex.yaml allows\n list, ls What is added, installed, and placed for your agents\n search <query> Find packages at the registry\n\nYour packages\n export <org>/<pkg> [--spec <file>] [--skill <folder>]\u2026 Build it in spex-packages/<org>/<pkg>/ from your files\n publish [<org>/<pkg>] [--registry <url>] [--dry-run] Publish it to the registry\n\nSign-in\n login [--registry <url> | --space <url>] Sign in with a code in your browser\n logout [--registry <url> | --space <url>] Sign out\n whoami [--registry <url> | --space <url>] Who you are signed in as, and where\n\nSpecs\n scaffold [<path> | --update] Start specs/ and point your agents at it\n lint [<path>] Check specs/ for structure, IDs and citations\n\nspex --version \u00B7 spex <command> --help \u00B7 Home: $SPEX_HOME or ~/.spex";
|
|
4
4
|
/** The command a word of the command line names, by its own name or an
|
|
5
5
|
* alias, if any. */
|
|
6
6
|
export declare function commandNamed(word: string): string | undefined;
|
package/dist/commands/run.js
CHANGED
|
@@ -27,7 +27,7 @@ Packages in this folder (spex.yaml, spex.lock, .spex/)
|
|
|
27
27
|
|
|
28
28
|
Your packages
|
|
29
29
|
export <org>/<pkg> [--spec <file>] [--skill <folder>]… Build it in spex-packages/<org>/<pkg>/ from your files
|
|
30
|
-
publish [<org>/<pkg>] [--dry-run]
|
|
30
|
+
publish [<org>/<pkg>] [--registry <url>] [--dry-run] Publish it to the registry
|
|
31
31
|
|
|
32
32
|
Sign-in
|
|
33
33
|
login [--registry <url> | --space <url>] Sign in with a code in your browser
|
|
@@ -68,8 +68,11 @@ const HELP = {
|
|
|
68
68
|
],
|
|
69
69
|
},
|
|
70
70
|
publish: {
|
|
71
|
-
usage: "spex publish [<org>/<pkg>] [--dry-run]",
|
|
72
|
-
options: [
|
|
71
|
+
usage: "spex publish [<org>/<pkg>] [--registry <url>] [--dry-run]",
|
|
72
|
+
options: [
|
|
73
|
+
["--registry <url>", "Publish at this registry instead of the one configured for the project", "a URL"],
|
|
74
|
+
["--dry-run", "List the files it would publish, and publish nothing"],
|
|
75
|
+
],
|
|
73
76
|
},
|
|
74
77
|
login: {
|
|
75
78
|
usage: "spex login [--registry <url> | --space <url>] [--force]",
|
package/dist/commands/search.js
CHANGED
|
@@ -14,7 +14,7 @@ export const search = async (args) => {
|
|
|
14
14
|
const target = env.registryOf(env.readRequests()?.requests ?? null);
|
|
15
15
|
let found;
|
|
16
16
|
try {
|
|
17
|
-
found = await env.registryAt(target.origin
|
|
17
|
+
found = await env.registryAt(target.origin).search(query);
|
|
18
18
|
}
|
|
19
19
|
catch (error) {
|
|
20
20
|
throw await env.registryRefusal(error, { origin: target.origin, scope: target.scope });
|
package/dist/commands/settle.js
CHANGED
|
@@ -149,7 +149,7 @@ export async function settle(env, mode) {
|
|
|
149
149
|
const target = env.registryOf(read?.requests ?? null);
|
|
150
150
|
const context = { origin: target.origin, scope: target.scope };
|
|
151
151
|
const instance = target.origin;
|
|
152
|
-
const registry = env.registryAt(instance
|
|
152
|
+
const registry = env.registryAt(instance);
|
|
153
153
|
const locators = gitLocators(read?.requests ?? null, locked?.lock ?? null);
|
|
154
154
|
let lock = locked?.lock ?? null;
|
|
155
155
|
let lockVersion = locked?.version ?? null;
|
|
@@ -202,7 +202,7 @@ export async function settle(env, mode) {
|
|
|
202
202
|
store: env.store,
|
|
203
203
|
cache: env.cache,
|
|
204
204
|
registry,
|
|
205
|
-
registries: (source) => env.installRegistries(instance, source
|
|
205
|
+
registries: (source) => env.installRegistries(instance, source),
|
|
206
206
|
// The built-in spec package from this computer's seed, by its
|
|
207
207
|
// files' digests; where no seed and no registry serves it, left
|
|
208
208
|
// out as not installed for the app's next use to install, the rest
|
package/dist/commands/whoami.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
// `spex whoami [--registry <url> | --space <url>]` (cli-12, DR-168,
|
|
4
|
-
// DR-172): this
|
|
5
|
-
//
|
|
6
|
-
// the line of the registry or Space named alone: its kind, its name as
|
|
4
|
+
// DR-172): this folder's registry account, or the explicitly selected
|
|
5
|
+
// registry or Space account alone: its kind, its name as
|
|
7
6
|
// cli-22 names it, and `@<login>` or `signed out`, the home's default
|
|
8
7
|
// Space marked `(default)`. A registry's login is read from its account
|
|
9
8
|
// API; a Space's from its home entry, asking no Space. No secret is
|
|
@@ -62,9 +61,6 @@ export const whoami = async (args) => {
|
|
|
62
61
|
const line = await registryLine(dir, target.origin);
|
|
63
62
|
rows.push(line.row);
|
|
64
63
|
cause = line.cause;
|
|
65
|
-
if (values.registry === undefined)
|
|
66
|
-
for (const entry of home?.instances ?? [])
|
|
67
|
-
rows.push(spaceLine(home, entry, defaultOrigin));
|
|
68
64
|
}
|
|
69
65
|
// Columns aligned, two spaces apart.
|
|
70
66
|
const widths = rows.reduce((out, row) => row.map((cell, at) => Math.max(out[at] ?? 0, cell.length)), []);
|
|
@@ -16,9 +16,22 @@ export interface UnpackedRelease {
|
|
|
16
16
|
}
|
|
17
17
|
/** Unpack and check a release archive as the registry does. */
|
|
18
18
|
export declare function unpackRelease(tgz: Uint8Array, pkg: string): UnpackedRelease;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
19
|
+
/** Explicit metadata for a publication snapshot; the local package keeps
|
|
20
|
+
* its own identity and license (environments-10). */
|
|
21
|
+
export interface PublicationFields {
|
|
22
|
+
org: string;
|
|
23
|
+
license: string;
|
|
24
|
+
}
|
|
25
|
+
/** Capture and validate the exact bytes a publication will upload. No file
|
|
26
|
+
* is written, including when publication metadata changes the snapshot. */
|
|
27
|
+
export declare function preparePublication(dir: string, publication?: PublicationFields): Promise<{
|
|
28
|
+
source: Manifest;
|
|
29
|
+
manifest: Manifest;
|
|
30
|
+
files: ReleaseFile[];
|
|
31
|
+
archive: Uint8Array;
|
|
32
|
+
}>;
|
|
33
|
+
/** Publish a release folder as it is (environments-10), uploading the
|
|
34
|
+
* same captured bytes that passed validation. */
|
|
22
35
|
export declare function publishRelease(registry: RegistrySource, dir: string): Promise<{
|
|
23
36
|
name: string;
|
|
24
37
|
version: string;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
// special entry and anything outside the root.
|
|
8
8
|
import { readFileSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
-
import {
|
|
10
|
+
import { parseDocument } from "yaml";
|
|
11
|
+
import { checkRelease, FormatError, parseManifestText, portablePathIssues, publishIssues, readRelease, sha256Hex } from "./format.js";
|
|
11
12
|
import { gunzip, gzip, readTar, writeTar } from "./tar.js";
|
|
12
13
|
/** Pack files into a release archive rooted at `<pkg>/`. */
|
|
13
14
|
export function packFiles(pkg, files) {
|
|
@@ -78,14 +79,44 @@ export function unpackRelease(tgz, pkg) {
|
|
|
78
79
|
issues.push(...checkRelease((path) => data.get(path), parsed.manifest, files));
|
|
79
80
|
return { manifest: parsed.manifest, files, data, issues };
|
|
80
81
|
}
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
|
|
82
|
+
/** Capture and validate the exact bytes a publication will upload. No file
|
|
83
|
+
* is written, including when publication metadata changes the snapshot. */
|
|
84
|
+
export async function preparePublication(dir, publication) {
|
|
85
|
+
const release = await readRelease(dir);
|
|
86
|
+
const captured = release.files.map((file) => {
|
|
87
|
+
const data = readFileSync(join(dir, ...file.path.split("/")));
|
|
88
|
+
if (sha256Hex(data) !== file.sha256) {
|
|
89
|
+
throw new FormatError([{ path: file.path, rule: "changed", message: "changed while preparing publication; retry" }]);
|
|
90
|
+
}
|
|
91
|
+
return { path: file.path, executable: file.executable, data };
|
|
92
|
+
});
|
|
93
|
+
const meta = captured.find((file) => file.path === "meta.yaml");
|
|
94
|
+
const parsed = parseManifestText(meta.data.toString("utf8"));
|
|
95
|
+
if (!parsed.manifest || parsed.issues.length)
|
|
96
|
+
throw new FormatError(parsed.issues);
|
|
97
|
+
const source = parsed.manifest;
|
|
98
|
+
if (publication) {
|
|
99
|
+
if (!publication.license || publication.license.trim() !== publication.license || /[\r\n]/.test(publication.license)) {
|
|
100
|
+
throw new FormatError([{ path: "meta.yaml", rule: "field", message: "license must be a nonempty trimmed line" }], "publishing");
|
|
101
|
+
}
|
|
102
|
+
const doc = parseDocument(meta.data.toString("utf8"));
|
|
103
|
+
doc.set("org", publication.org);
|
|
104
|
+
doc.set("license", publication.license);
|
|
105
|
+
meta.data = Buffer.from(doc.toString({ lineWidth: 0 }));
|
|
106
|
+
}
|
|
107
|
+
const archive = packFiles(source.name, captured);
|
|
108
|
+
const checked = unpackRelease(archive, source.name);
|
|
109
|
+
const issues = [...checked.issues, ...(checked.manifest ? publishIssues(checked.manifest) : [])];
|
|
110
|
+
if (!checked.manifest || issues.length)
|
|
111
|
+
throw new FormatError(issues, "publishing");
|
|
112
|
+
return { source, manifest: checked.manifest, files: checked.files, archive };
|
|
113
|
+
}
|
|
114
|
+
/** Publish a release folder as it is (environments-10), uploading the
|
|
115
|
+
* same captured bytes that passed validation. */
|
|
84
116
|
export async function publishRelease(registry, dir) {
|
|
85
|
-
const { manifest,
|
|
86
|
-
const tgz = packRelease(dir, manifest, files);
|
|
117
|
+
const { manifest, archive } = await preparePublication(dir);
|
|
87
118
|
const name = `${manifest.org}/${manifest.name}`;
|
|
88
|
-
await registry.publish(name, manifest.version,
|
|
89
|
-
return { name, version: manifest.version, checksum: sha256Hex(
|
|
119
|
+
await registry.publish(name, manifest.version, archive);
|
|
120
|
+
return { name, version: manifest.version, checksum: sha256Hex(archive) };
|
|
90
121
|
}
|
|
91
122
|
//# sourceMappingURL=archive.js.map
|
|
@@ -342,7 +342,7 @@ export function prepareBuiltinEnvironment(root, pkg, registryUrl, space = null)
|
|
|
342
342
|
return wrote;
|
|
343
343
|
try {
|
|
344
344
|
// Written only where no lock stands yet (DR-111).
|
|
345
|
-
writeVersionedBytes(lockFile, serializeLock(builtinLock(pkg, parseRequests(text).registry ??
|
|
345
|
+
writeVersionedBytes(lockFile, serializeLock(builtinLock(pkg, parseRequests(text).registry ?? PUBLIC_REGISTRY_ORIGIN, text)), null);
|
|
346
346
|
}
|
|
347
347
|
catch (error) {
|
|
348
348
|
// The first resolve writes it instead.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type RegistrySource } from "./registry.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* origin and so is never asked. */
|
|
2
|
+
/** A pinned package registry, or an invalid address kept for an honest
|
|
3
|
+
* failure report without making a request. */
|
|
5
4
|
export type InstallRegistry = {
|
|
6
5
|
origin: string;
|
|
7
6
|
} | {
|
|
@@ -9,13 +8,12 @@ export type InstallRegistry = {
|
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* The order an install asks registries for a registry package's files
|
|
12
|
-
* (environments-7):
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* trusted equivalents, keeping sign-in separate from package trust.
|
|
11
|
+
* (environments-7): the registry its lock records and explicitly trusted
|
|
12
|
+
* equivalents. The former instance, signed-in list and independent
|
|
13
|
+
* option remain accepted for published API compatibility but confer no
|
|
14
|
+
* package trust or account authority.
|
|
17
15
|
*/
|
|
18
|
-
export declare function installRegistryOrder(
|
|
16
|
+
export declare function installRegistryOrder(_instance: string, recorded: string, _signedIn: readonly string[], options?: {
|
|
19
17
|
independent?: boolean;
|
|
20
18
|
trusted?: readonly string[];
|
|
21
19
|
}): InstallRegistry[];
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
// Registry installs retain the exact source in the lock (DR-168).
|
|
4
|
-
//
|
|
5
|
-
// independent manifests never scan unrelated signed-in Spaces.
|
|
4
|
+
// Package trust never follows the list of signed-in Spaces.
|
|
6
5
|
import { canonicalOrigin } from "../instance.js";
|
|
7
6
|
import { RegistryError } from "./registry.js";
|
|
8
7
|
/**
|
|
9
8
|
* The order an install asks registries for a registry package's files
|
|
10
|
-
* (environments-7):
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* trusted equivalents, keeping sign-in separate from package trust.
|
|
9
|
+
* (environments-7): the registry its lock records and explicitly trusted
|
|
10
|
+
* equivalents. The former instance, signed-in list and independent
|
|
11
|
+
* option remain accepted for published API compatibility but confer no
|
|
12
|
+
* package trust or account authority.
|
|
15
13
|
*/
|
|
16
|
-
export function installRegistryOrder(
|
|
14
|
+
export function installRegistryOrder(_instance, recorded, _signedIn, options = {}) {
|
|
17
15
|
const out = [];
|
|
18
16
|
const asked = new Set();
|
|
19
17
|
const add = (origin) => {
|
|
@@ -22,39 +20,14 @@ export function installRegistryOrder(instance, recorded, signedIn, options = {})
|
|
|
22
20
|
asked.add(origin);
|
|
23
21
|
out.push({ origin });
|
|
24
22
|
};
|
|
25
|
-
if (options.independent) {
|
|
26
|
-
try {
|
|
27
|
-
add(canonicalOrigin(recorded));
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
out.push({ unasked: recorded });
|
|
31
|
-
}
|
|
32
|
-
for (const origin of options.trusted ?? [])
|
|
33
|
-
add(canonicalOrigin(origin));
|
|
34
|
-
return out;
|
|
35
|
-
}
|
|
36
|
-
add(canonicalOrigin(instance));
|
|
37
|
-
let origin;
|
|
38
23
|
try {
|
|
39
|
-
|
|
24
|
+
add(canonicalOrigin(recorded));
|
|
40
25
|
}
|
|
41
26
|
catch {
|
|
42
|
-
origin = null;
|
|
43
|
-
}
|
|
44
|
-
if (origin !== null)
|
|
45
|
-
add(origin);
|
|
46
|
-
else
|
|
47
27
|
out.push({ unasked: recorded });
|
|
48
|
-
for (const entry of signedIn) {
|
|
49
|
-
let at;
|
|
50
|
-
try {
|
|
51
|
-
at = canonicalOrigin(entry);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
add(at);
|
|
57
28
|
}
|
|
29
|
+
for (const origin of options.trusted ?? [])
|
|
30
|
+
add(canonicalOrigin(origin));
|
|
58
31
|
return out;
|
|
59
32
|
}
|
|
60
33
|
/** A registry a lock records under no instance's origin
|
|
@@ -112,8 +112,8 @@ export declare function readVersionIndex(name: string, raw: unknown): VersionInd
|
|
|
112
112
|
/** Validate a version resource answer: a format this client does not
|
|
113
113
|
* know is refused naming it (environments-12). */
|
|
114
114
|
export declare function readVersionResource(name: string, version: string, raw: unknown): VersionResource;
|
|
115
|
-
/** The codes
|
|
116
|
-
*
|
|
115
|
+
/** The codes that invalidate only the presented registry grant
|
|
116
|
+
* (environments-12); `token_expired` is not one
|
|
117
117
|
* of them, an expired access secret being a failure of its call. */
|
|
118
118
|
export declare const SIGN_OUT_CODES: readonly string[];
|
|
119
119
|
export interface RegistryDescriptor {
|
|
@@ -128,19 +128,18 @@ export interface SpaceDirectoryEntry {
|
|
|
128
128
|
}
|
|
129
129
|
export interface RegistryClientOptions {
|
|
130
130
|
url: string;
|
|
131
|
-
/** The
|
|
132
|
-
* home is signed in there; a getter that throws fails the call as
|
|
131
|
+
/** The independent registry grant; a getter that throws fails the call as
|
|
133
132
|
* `unavailable`. */
|
|
134
133
|
token?: () => Promise<string | null>;
|
|
135
134
|
/** Told the token a call presented when the registry refused it with
|
|
136
135
|
* one of `SIGN_OUT_CODES`, before that call fails (environments-12):
|
|
137
|
-
* awaited; where it throws — the token no longer the
|
|
136
|
+
* awaited; where it throws — the token no longer the registry's stored
|
|
138
137
|
* one (git-host-4) — the call fails with what it threw in place of the
|
|
139
138
|
* registry's words, still `unauthenticated`. */
|
|
140
139
|
refused?: (token: string, code: string) => void | Promise<void>;
|
|
141
140
|
fetch?: typeof fetch;
|
|
142
141
|
}
|
|
143
|
-
/**
|
|
142
|
+
/** The package service over HTTP (environments-12). */
|
|
144
143
|
export declare class RegistryClient implements RegistrySource {
|
|
145
144
|
readonly url: string;
|
|
146
145
|
private readonly token?;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// The registry source (environments-12)
|
|
4
|
-
//
|
|
3
|
+
// The package registry source (environments-12), using its independent
|
|
4
|
+
// registry account. The version index carries every
|
|
5
5
|
// version with its dependencies and artifacts, so a dependency graph
|
|
6
6
|
// resolves from indexes alone; a version resource is read only for a
|
|
7
7
|
// version picked; files come by raw URL or the release archive, each
|
|
8
|
-
// verified by its digest elsewhere.
|
|
9
|
-
//
|
|
10
|
-
// in there; an answer refusing it as the instance's sign-out is reported
|
|
11
|
-
// with the token it refused (environments-12, DR-127).
|
|
8
|
+
// verified by its digest elsewhere. Registry-grant refusals are reported
|
|
9
|
+
// with the token refused and never affect Space grants.
|
|
12
10
|
import { canonicalOrigin } from "../instance.js";
|
|
13
11
|
import { isPackageName } from "./format.js";
|
|
14
12
|
export class RegistryError extends Error {
|
|
@@ -157,11 +155,11 @@ export function readVersionResource(name, version, raw) {
|
|
|
157
155
|
...(isPlainObject(raw.dist) && typeof raw.dist.tarball === "string" ? { dist: { tarball: raw.dist.tarball, sha256: String(raw.dist.sha256 ?? raw.checksum) } } : {}),
|
|
158
156
|
};
|
|
159
157
|
}
|
|
160
|
-
/** The codes
|
|
161
|
-
*
|
|
158
|
+
/** The codes that invalidate only the presented registry grant
|
|
159
|
+
* (environments-12); `token_expired` is not one
|
|
162
160
|
* of them, an expired access secret being a failure of its call. */
|
|
163
161
|
export const SIGN_OUT_CODES = ["invalid_token", "token_revoked", "reauth_required"];
|
|
164
|
-
/**
|
|
162
|
+
/** The package service over HTTP (environments-12). */
|
|
165
163
|
export class RegistryClient {
|
|
166
164
|
url;
|
|
167
165
|
token;
|
|
@@ -256,7 +254,9 @@ export class RegistryClient {
|
|
|
256
254
|
await this.refused(token, code);
|
|
257
255
|
}
|
|
258
256
|
catch (error) {
|
|
259
|
-
|
|
257
|
+
const refusal = new RegistryError("unauthenticated", name, `${about}${error instanceof Error ? error.message : String(error)}`, code, undefined, answered);
|
|
258
|
+
refusal.cause = error;
|
|
259
|
+
throw refusal;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
throw new RegistryError("unauthenticated", name, `${about}sign-in expired at ${host}`, code, undefined, answered);
|
|
@@ -347,7 +347,7 @@ export class RegistryClient {
|
|
|
347
347
|
return null;
|
|
348
348
|
orgs.push({ name: org.name, path: org.path, role: org.role, ...(typeof org.provider === "string" ? { provider: org.provider } : {}) });
|
|
349
349
|
}
|
|
350
|
-
return orgs;
|
|
350
|
+
return orgs.sort((a, b) => a.name.localeCompare(b.name));
|
|
351
351
|
})();
|
|
352
352
|
return Promise.race([asked, late]);
|
|
353
353
|
}
|
|
@@ -67,9 +67,10 @@ export interface EnvironmentRegistry {
|
|
|
67
67
|
scope: AuthScope;
|
|
68
68
|
legacy: boolean;
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
70
|
+
/** Package routing never inherits collaboration settings or grants.
|
|
71
|
+
* Existing locked sources keep their provenance when installed. The
|
|
72
|
+
* home argument remains for compatibility with published callers. */
|
|
73
|
+
export declare function environmentRegistry(requests: Pick<Requests, "space" | "registry"> | null, _home: Pick<HomeFile, "origin" | "instances">): EnvironmentRegistry;
|
|
73
74
|
/** Name a package registry without changing the Space binding. */
|
|
74
75
|
export declare function setRegistryIn(doc: Document, origin: string): void;
|
|
75
76
|
/** Parse `spex.yaml` text, or throw. */
|
|
@@ -227,12 +227,10 @@ export function environmentInstance(requests, home) {
|
|
|
227
227
|
}
|
|
228
228
|
/** The public package service used explicitly by new environments. */
|
|
229
229
|
export const PUBLIC_REGISTRY_ORIGIN = "https://spex.sublang.ai";
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return { origin: environmentInstance(requests, home), scope: "space", legacy: true };
|
|
235
|
-
}
|
|
230
|
+
/** Package routing never inherits collaboration settings or grants.
|
|
231
|
+
* Existing locked sources keep their provenance when installed. The
|
|
232
|
+
* home argument remains for compatibility with published callers. */
|
|
233
|
+
export function environmentRegistry(requests, _home) {
|
|
236
234
|
return { origin: canonicalOrigin(requests?.registry ?? PUBLIC_REGISTRY_ORIGIN), scope: "registry", legacy: false };
|
|
237
235
|
}
|
|
238
236
|
/** Name a package registry without changing the Space binding. */
|