@sublang/spex 5.0.0 → 7.0.0-beta.2
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 +453 -41
- package/dist/cli.js +12 -1
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +3 -3
- package/dist/commands/auth-target.d.ts +1 -0
- package/dist/commands/auth-target.js +4 -2
- package/dist/commands/environment.d.ts +15 -21
- package/dist/commands/environment.js +43 -57
- package/dist/commands/export.js +2 -2
- package/dist/commands/home.d.ts +2 -2
- package/dist/commands/home.js +3 -3
- package/dist/commands/list.js +1 -1
- package/dist/commands/login.js +12 -7
- package/dist/commands/logout.js +2 -3
- package/dist/commands/publish.js +16 -16
- package/dist/commands/remove.js +1 -1
- package/dist/commands/run.d.ts +1 -1
- package/dist/commands/run.js +22 -3
- package/dist/commands/search.js +1 -1
- package/dist/commands/settle.d.ts +1 -1
- package/dist/commands/settle.js +3 -3
- package/dist/commands/whoami.js +2 -6
- package/dist/guards/approval.d.ts +56 -0
- package/dist/guards/approval.js +158 -0
- package/dist/guards/checks.d.ts +207 -0
- package/dist/guards/checks.js +681 -0
- package/dist/guards/commands.d.ts +15 -0
- package/dist/guards/commands.js +313 -0
- package/dist/guards/copy.d.ts +67 -0
- package/dist/guards/copy.js +306 -0
- package/dist/guards/declaration.d.ts +45 -0
- package/dist/guards/declaration.js +224 -0
- package/dist/guards/files.d.ts +137 -0
- package/dist/guards/files.js +544 -0
- package/dist/guards/harness.d.ts +58 -0
- package/dist/guards/harness.js +420 -0
- package/dist/guards/items.d.ts +61 -0
- package/dist/guards/items.js +161 -0
- package/dist/guards/patch.d.ts +55 -0
- package/dist/guards/patch.js +258 -0
- package/dist/guards/processes.d.ts +49 -0
- package/dist/guards/processes.js +233 -0
- package/dist/guards/proofs.d.ts +88 -0
- package/dist/guards/proofs.js +503 -0
- package/dist/guards/records.d.ts +176 -0
- package/dist/guards/records.js +513 -0
- package/dist/guards/report.d.ts +26 -0
- package/dist/guards/report.js +492 -0
- package/dist/guards/runner.d.ts +42 -0
- package/dist/guards/runner.js +167 -0
- package/dist/guards/tla.d.ts +51 -0
- package/dist/guards/tla.js +352 -0
- package/dist/guards/tlapm.d.ts +81 -0
- package/dist/guards/tlapm.js +172 -0
- package/dist/guards/tlc.d.ts +191 -0
- package/dist/guards/tlc.js +457 -0
- package/dist/guards/translation.d.ts +66 -0
- package/dist/guards/translation.js +202 -0
- package/dist/guards/types.d.ts +185 -0
- package/dist/guards/types.js +437 -0
- package/dist/guards/verify.d.ts +290 -0
- package/dist/guards/verify.js +1191 -0
- package/dist/guards/xml.d.ts +18 -0
- package/dist/guards/xml.js +105 -0
- package/dist/lib/environment/archive.d.ts +16 -3
- package/dist/lib/environment/archive.js +39 -8
- package/dist/lib/environment/builtins.d.ts +10 -12
- package/dist/lib/environment/builtins.js +18 -20
- package/dist/lib/environment/exports.d.ts +14 -13
- package/dist/lib/environment/exports.js +31 -16
- package/dist/lib/environment/format.d.ts +2 -2
- package/dist/lib/environment/format.js +3 -3
- package/dist/lib/environment/git-source.js +6 -3
- package/dist/lib/environment/install.d.ts +14 -16
- package/dist/lib/environment/install.js +66 -61
- package/dist/lib/environment/lock.d.ts +4 -3
- package/dist/lib/environment/lock.js +6 -5
- package/dist/lib/environment/marker.js +1 -2
- package/dist/lib/environment/own-paths.d.ts +7 -10
- package/dist/lib/environment/own-paths.js +10 -13
- package/dist/lib/environment/placed-record.d.ts +3 -2
- package/dist/lib/environment/placed-record.js +5 -4
- package/dist/lib/environment/registries.d.ts +7 -9
- package/dist/lib/environment/registries.js +9 -36
- package/dist/lib/environment/registry.d.ts +6 -7
- package/dist/lib/environment/registry.js +12 -12
- package/dist/lib/environment/requests.d.ts +6 -5
- package/dist/lib/environment/requests.js +6 -8
- package/dist/lib/environment/resolve.d.ts +4 -4
- package/dist/lib/environment/resolve.js +3 -4
- package/dist/lib/environment/store.d.ts +34 -8
- package/dist/lib/environment/store.js +138 -43
- package/dist/lib/files.d.ts +72 -12
- package/dist/lib/files.js +200 -65
- package/dist/lib/git-host.d.ts +52 -258
- package/dist/lib/git-host.js +52 -265
- package/dist/lib/home-file.d.ts +13 -10
- package/dist/lib/home-file.js +28 -18
- package/dist/lib/instance.d.ts +1 -1
- package/dist/lib/instance.js +1 -1
- package/dist/lint.d.ts +22 -0
- package/dist/lint.js +36 -0
- package/dist/testing/standin-registry.js +1 -1
- package/package.json +7 -3
- package/scaffold/.file-history.json +14 -7
- package/scaffold/i18n/zh/source-pins.json +41 -0
- package/scaffold/i18n/zh/specs/decisions/000-spec-structure-format.md +0 -1
- package/scaffold/i18n/zh/specs/intents/000-spdx-headers.md +0 -1
- package/scaffold/i18n/zh/specs/map.md +0 -1
- package/scaffold/i18n/zh/specs/meta.md +18 -35
- package/scaffold/i18n/zh/specs/packages/git.md +0 -1
- package/scaffold/i18n/zh/specs/packages/licensing.md +0 -1
- package/scaffold/specs/meta.md +18 -3
- package/scripts/test-exit-guard.mjs +28 -0
package/dist/commands/add.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Request } from "../lib/environment/index.js";
|
|
|
2
2
|
import { Environment } from "./environment.js";
|
|
3
3
|
import { type Command } from "./run.js";
|
|
4
4
|
/** Write one package into the environment's `spex.yaml`
|
|
5
|
-
* (environments-
|
|
5
|
+
* (environments-65): a file made new explicitly names the public
|
|
6
6
|
* registry (environments-2); comments and key order stay; a file changed
|
|
7
7
|
* meanwhile is refused. */
|
|
8
8
|
export declare function writeRequest(env: Environment, name: string, request: Request, made: boolean): Promise<void>;
|
package/dist/commands/add.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
// `spex add <org>/<pkg>[@<version>]` and `spex add <org>/<pkg> --path
|
|
4
|
-
// <folder>` (cli-2, environments-
|
|
4
|
+
// <folder>` (cli-2, environments-65): write the package into
|
|
5
5
|
// `spex.yaml` — made explicitly naming the public registry where the
|
|
6
6
|
// root holds none — then resolve, install and export, printing each
|
|
7
7
|
// package added or updated, where its spec stands in `specs/` with the
|
|
@@ -24,7 +24,7 @@ function editRefusal(env, error) {
|
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
/** Write one package into the environment's `spex.yaml`
|
|
27
|
-
* (environments-
|
|
27
|
+
* (environments-65): a file made new explicitly names the public
|
|
28
28
|
* registry (environments-2); comments and key order stay; a file changed
|
|
29
29
|
* meanwhile is refused. */
|
|
30
30
|
export async function writeRequest(env, name, request, made) {
|
|
@@ -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
|
|
@@ -8,8 +8,8 @@ import { Refusal } from "./run.js";
|
|
|
8
8
|
* name made long, and the rest as written. */
|
|
9
9
|
export declare function actualPath(path: string): string;
|
|
10
10
|
/** Why a folder cannot be an environment's root (cli-1), or null: the
|
|
11
|
-
* user's home folder, a folder inside the Spex home
|
|
12
|
-
*
|
|
11
|
+
* user's home folder, a folder inside the Spex home, and a folder whose
|
|
12
|
+
* `.spex` holds the home. */
|
|
13
13
|
export declare function refusedRoot(dir: string, home: string): string | null;
|
|
14
14
|
/** The environment root of a command run in `cwd` (cli-1), spelled as
|
|
15
15
|
* `cwd` is, so a path given from `cwd` compares with it as text. A
|
|
@@ -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
|
-
* (environments-7
|
|
103
|
+
* (environments-7): 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;
|
|
@@ -9,16 +9,15 @@
|
|
|
9
9
|
// no folder check; the store and the cache are the ones the app's core
|
|
10
10
|
// uses under it, so both hosts share one store (environments-7). No
|
|
11
11
|
// clone, lease, session or record of the home is read or written: a
|
|
12
|
-
// root inside the home,
|
|
13
|
-
// is refused, as is the user's home folder, whose agent folders are the
|
|
14
|
-
// user-level ones your own group's export writes (environments-8).
|
|
12
|
+
// root inside the Spex home is refused, as is the user's home folder.
|
|
15
13
|
import { spawnSync } from "node:child_process";
|
|
16
14
|
import { realpathSync, statSync } from "node:fs";
|
|
17
15
|
import { homedir } from "node:os";
|
|
18
16
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
19
17
|
import { builtinRegistrySource, compositeRegistry, ContentStore, environmentInstance, environmentRegistry, FormatError, gitSource, installRegistryOrder, LockError, parseLock, parseRequests, RegistryClient, RegistryError, RequestsError, unaskedRegistry, } from "../lib/environment/index.js";
|
|
20
18
|
import { readVersioned } from "../lib/files.js";
|
|
21
|
-
import {
|
|
19
|
+
import { CredentialChanged } from "../lib/git-host.js";
|
|
20
|
+
import { accountAt, instanceAt } from "../lib/home-file.js";
|
|
22
21
|
import { canonicalOrigin } from "../lib/instance.js";
|
|
23
22
|
import { clientOf, credentialsOf, defaultInstance, homeDir, hostCause, nameOf, readHome, registryName } from "./home.js";
|
|
24
23
|
import { Refusal } from "./run.js";
|
|
@@ -44,14 +43,14 @@ function within(outer, inner) {
|
|
|
44
43
|
return path === "" || (path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path));
|
|
45
44
|
}
|
|
46
45
|
/** Why a folder cannot be an environment's root (cli-1), or null: the
|
|
47
|
-
* user's home folder, a folder inside the Spex home
|
|
48
|
-
*
|
|
46
|
+
* user's home folder, a folder inside the Spex home, and a folder whose
|
|
47
|
+
* `.spex` holds the home. */
|
|
49
48
|
export function refusedRoot(dir, home) {
|
|
50
49
|
const at = actualPath(dir);
|
|
51
50
|
const spexHome = actualPath(home);
|
|
52
51
|
if (at === actualPath(homedir()))
|
|
53
52
|
return "is your home folder, where spex manages no packages";
|
|
54
|
-
if (within(spexHome, at)
|
|
53
|
+
if (within(spexHome, at)) {
|
|
55
54
|
return `lies in the Spex home ${home}, which the app keeps`;
|
|
56
55
|
}
|
|
57
56
|
if (within(join(at, ".spex"), spexHome))
|
|
@@ -209,10 +208,8 @@ export class Environment {
|
|
|
209
208
|
* purpose there; undefined where it holds one whose login cannot be
|
|
210
209
|
* read now. A Space's login is its home entry's; a registry's is read
|
|
211
210
|
* 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);
|
|
211
|
+
async loginAt(origin) {
|
|
212
|
+
const credentials = credentialsOf(this.homeDir, origin, "registry");
|
|
216
213
|
try {
|
|
217
214
|
if (!(await credentials.read()))
|
|
218
215
|
return null;
|
|
@@ -221,7 +218,7 @@ export class Environment {
|
|
|
221
218
|
return undefined;
|
|
222
219
|
}
|
|
223
220
|
try {
|
|
224
|
-
return (await clientOf(origin, credentials, undefined,
|
|
221
|
+
return (await clientOf(origin, credentials, undefined, "registry").me()).login;
|
|
225
222
|
}
|
|
226
223
|
catch {
|
|
227
224
|
try {
|
|
@@ -252,17 +249,19 @@ export class Environment {
|
|
|
252
249
|
catch { /* the registry asked */ }
|
|
253
250
|
const name = await this.registryName(origin);
|
|
254
251
|
const pkg = error.packageName;
|
|
255
|
-
// `spex login`
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
// `spex login` selects this folder's package registry (cli-10).
|
|
253
|
+
// An exact locked source at another registry names that target.
|
|
254
|
+
const login = context.operation !== "publish" && origin === context.origin
|
|
255
|
+
? "spex login"
|
|
256
|
+
: `spex login --registry ${origin}`;
|
|
260
257
|
const about = pkg ? `${pkg}: ` : "";
|
|
258
|
+
if (error.cause instanceof CredentialChanged)
|
|
259
|
+
return new Refusal(`your sign-in at ${name} changed meanwhile — retry`);
|
|
261
260
|
switch (error.kind) {
|
|
262
261
|
case "not_found": {
|
|
263
262
|
if (error.code === "suppressed")
|
|
264
263
|
return new Refusal(`${about}withdrawn at ${name} — spex update picks another version`);
|
|
265
|
-
const who = await this.loginAt(origin
|
|
264
|
+
const who = await this.loginAt(origin);
|
|
266
265
|
if (who === null)
|
|
267
266
|
return new Refusal(`${about}not at ${name}, or private — ${login}, then retry`);
|
|
268
267
|
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 +271,7 @@ export class Environment {
|
|
|
272
271
|
const org = pkg?.split("/")[0] ?? "this org";
|
|
273
272
|
return new Refusal(`${org} is not yours at ${name} — claim it at ${origin}/account/orgs?scope=registry`);
|
|
274
273
|
}
|
|
275
|
-
const who = await this.loginAt(origin
|
|
274
|
+
const who = await this.loginAt(origin);
|
|
276
275
|
return new Refusal(`${about}not shared with ${typeof who === "string" ? `@${who}` : "this account"} at ${name} — ask its owner`);
|
|
277
276
|
}
|
|
278
277
|
case "unauthenticated":
|
|
@@ -321,64 +320,51 @@ export class Environment {
|
|
|
321
320
|
signedIn() {
|
|
322
321
|
return (this.home?.instances ?? []).filter((entry) => this.signedInAt(entry.origin)).map((entry) => entry.origin);
|
|
323
322
|
}
|
|
324
|
-
/** The
|
|
325
|
-
* (environments-12)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (scope === "space" ? !this.signedInAt(origin) : !(await credentialsOf(this.homeDir, origin, scope).read()))
|
|
323
|
+
/** The package registry's access secret, kept current by its scoped
|
|
324
|
+
* client (environments-12), independent of any Space sign-in. */
|
|
325
|
+
async tokenAt(origin) {
|
|
326
|
+
if (!(await credentialsOf(this.homeDir, origin, "registry").read()))
|
|
329
327
|
return null;
|
|
330
328
|
try {
|
|
331
|
-
return await this.clientAt(origin
|
|
329
|
+
return await this.clientAt(origin).accessSecret();
|
|
332
330
|
}
|
|
333
331
|
catch (error) {
|
|
334
332
|
throw new Error(hostCause(error, await this.registryName(origin)));
|
|
335
333
|
}
|
|
336
334
|
}
|
|
337
|
-
/**
|
|
338
|
-
*
|
|
339
|
-
|
|
340
|
-
clientAt(origin, scope = "space") {
|
|
335
|
+
/** One registry-purpose client per origin. A refused refresh affects
|
|
336
|
+
* only its registry slot and never the Space's home entry. */
|
|
337
|
+
clientAt(origin) {
|
|
341
338
|
const at = canonicalOrigin(origin);
|
|
342
|
-
const key =
|
|
339
|
+
const key = at;
|
|
343
340
|
let client = this.clients.get(key);
|
|
344
341
|
if (!client) {
|
|
345
|
-
client = clientOf(at, credentialsOf(this.homeDir, at,
|
|
342
|
+
client = clientOf(at, credentialsOf(this.homeDir, at, "registry"), undefined, "registry");
|
|
346
343
|
this.clients.set(key, client);
|
|
347
344
|
}
|
|
348
345
|
return client;
|
|
349
346
|
}
|
|
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
347
|
/** The built-in spec package as this device's seed holds it
|
|
357
|
-
* (environments-7
|
|
348
|
+
* (environments-7): what the app seeded into the
|
|
358
349
|
* shared store, read from `cache/builtins/`; the command line ships
|
|
359
350
|
* none of its own. */
|
|
360
351
|
seed() {
|
|
361
352
|
this.builtin ??= builtinRegistrySource({ store: this.store, cacheDir: this.cache });
|
|
362
353
|
return this.builtin;
|
|
363
354
|
}
|
|
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) {
|
|
355
|
+
/** One package registry and its independent grant, composed with the
|
|
356
|
+
* device's built-in seed (environments-12). */
|
|
357
|
+
registry(origin) {
|
|
370
358
|
const at = canonicalOrigin(origin);
|
|
371
|
-
const key =
|
|
359
|
+
const key = at;
|
|
372
360
|
let registry = this.registries.get(key);
|
|
373
361
|
if (!registry) {
|
|
374
362
|
const remote = new RegistryClient({
|
|
375
363
|
url: at,
|
|
376
|
-
token: () => this.tokenAt(at
|
|
364
|
+
token: () => this.tokenAt(at),
|
|
377
365
|
refused: async (token) => {
|
|
378
|
-
if (!(await this.clientAt(at
|
|
379
|
-
throw new
|
|
380
|
-
if (scope === "space")
|
|
381
|
-
this.markSignedOut(at);
|
|
366
|
+
if (!(await this.clientAt(at).signOutRefused(token)))
|
|
367
|
+
throw new CredentialChanged();
|
|
382
368
|
},
|
|
383
369
|
});
|
|
384
370
|
registry = { remote, source: compositeRegistry(this.seed(), remote) };
|
|
@@ -386,17 +372,17 @@ export class Environment {
|
|
|
386
372
|
}
|
|
387
373
|
return registry;
|
|
388
374
|
}
|
|
389
|
-
registryAt(origin
|
|
390
|
-
return this.registry(origin
|
|
375
|
+
registryAt(origin) {
|
|
376
|
+
return this.registry(origin).source;
|
|
391
377
|
}
|
|
392
|
-
registryClientAt(origin
|
|
393
|
-
return this.registry(origin
|
|
378
|
+
registryClientAt(origin) {
|
|
379
|
+
return this.registry(origin).remote;
|
|
394
380
|
}
|
|
395
381
|
/** The registries an install asks for a registry package's files, in
|
|
396
382
|
* 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
|
|
383
|
+
installRegistries(instance, source) {
|
|
384
|
+
return installRegistryOrder(instance, source.registry, [])
|
|
385
|
+
.map((entry) => ("origin" in entry ? this.registryAt(entry.origin) : compositeRegistry(this.seed(), unaskedRegistry(entry.unasked))));
|
|
400
386
|
}
|
|
401
387
|
}
|
|
402
388
|
/** Whether a folder stands at a path. */
|
package/dist/commands/export.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex export <org>/<pkg>` (cli-23, environments-
|
|
3
|
+
// `spex export <org>/<pkg>` (cli-23, environments-59, environments-42,
|
|
4
4
|
// DR-174): a spec package under development built at
|
|
5
5
|
// `spex-packages/<org>/<pkg>/` under the environment's root, in the
|
|
6
6
|
// release layout the library reads, by copying the project's own files,
|
|
@@ -439,7 +439,7 @@ export const exportPackage = async (args) => {
|
|
|
439
439
|
const root = env.root;
|
|
440
440
|
const registry = env.registryOf(env.readRequests()?.requests ?? null);
|
|
441
441
|
// The org is a folder, as npm's scopes are, so two orgs' packages of
|
|
442
|
-
// one name stand apart (environments-
|
|
442
|
+
// one name stand apart (environments-59, DR-165).
|
|
443
443
|
const packages = join(root, "spex-packages");
|
|
444
444
|
const parent = join(packages, org);
|
|
445
445
|
const destination = join(parent, name);
|
package/dist/commands/home.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ export declare function hostOf(origin: string): string;
|
|
|
33
33
|
export declare function nameOf(instance: HomeInstance): string;
|
|
34
34
|
/** The credential store of one instance under the home (storage-19). */
|
|
35
35
|
export declare function credentialsOf(dir: string, origin: string, scope?: AuthScope): CredentialStore;
|
|
36
|
-
/** The client of one instance, signing in as this device (git-host-
|
|
36
|
+
/** The client of one instance, signing in as this device (git-host-40). */
|
|
37
37
|
export declare function clientOf(origin: string, credentials: CredentialStore, onSignedOut?: () => void, scope?: AuthScope): GitHostClient;
|
|
38
|
-
/** A host's answer in the CLI's words (
|
|
38
|
+
/** A host's answer in the CLI's words (cli-13): what the
|
|
39
39
|
* Space or registry said, its own words as the detail, and what to do —
|
|
40
40
|
* `again`, the command that tries once more — never a secret. An answer
|
|
41
41
|
* of no known kind, such as a page that is not there, comes from an
|
package/dist/commands/home.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// The home the package commands act on (cli-1, storage-
|
|
3
|
+
// The home the package commands act on (cli-1, storage-63, storage-2):
|
|
4
4
|
// `SPEX_HOME` where set, else `~/.spex`. The CLI reads `home.yaml` with
|
|
5
5
|
// the library, checking no pairing — the app checks its own — and
|
|
6
6
|
// writes it only where a command records something; it never reads or
|
|
@@ -113,7 +113,7 @@ export function nameOf(instance) {
|
|
|
113
113
|
export function credentialsOf(dir, origin, scope = "space") {
|
|
114
114
|
return fileCredentialStore(dir, origin, scope);
|
|
115
115
|
}
|
|
116
|
-
/** The client of one instance, signing in as this device (git-host-
|
|
116
|
+
/** The client of one instance, signing in as this device (git-host-40). */
|
|
117
117
|
export function clientOf(origin, credentials, onSignedOut, scope = "space") {
|
|
118
118
|
let device = "this device";
|
|
119
119
|
try {
|
|
@@ -122,7 +122,7 @@ export function clientOf(origin, credentials, onSignedOut, scope = "space") {
|
|
|
122
122
|
catch { /* the label's fallback */ }
|
|
123
123
|
return new GitHostClient({ url: origin, scope, label: `spex on ${device}`, credentials, ...(onSignedOut ? { onSignedOut } : {}) });
|
|
124
124
|
}
|
|
125
|
-
/** A host's answer in the CLI's words (
|
|
125
|
+
/** A host's answer in the CLI's words (cli-13): what the
|
|
126
126
|
* Space or registry said, its own words as the detail, and what to do —
|
|
127
127
|
* `again`, the command that tries once more — never a secret. An answer
|
|
128
128
|
* of no known kind, such as a page that is not there, comes from an
|
package/dist/commands/list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex list`, or `spex ls` (cli-6, environments-
|
|
3
|
+
// `spex list`, or `spex ls` (cli-6, environments-64): the packages of
|
|
4
4
|
// this folder as its files stand, in a project's Packages tab's words
|
|
5
5
|
// (DR-172) — the folder and its registry by name; each package added,
|
|
6
6
|
// with its version or folder; each package installed, with its version,
|
package/dist/commands/login.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex login [--registry <url> | --space <url>] [--force]` (cli-10,
|
|
4
|
-
// git-host-3, DR-168): sign this computer in by the device flow at this
|
|
3
|
+
// `spex login [--registry <url> | --space <url>] [--force]` (cli-10, git-host-40, DR-168): sign this computer in by the device flow at this
|
|
5
4
|
// folder's registry for its packages, or at the registry or Space named.
|
|
6
5
|
// A registry sign-in keeps its app token alone and caches the registry's
|
|
7
6
|
// display name (cli-22); a Space sign-in records the Space in
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
// default — while the library's client keeps its app token in
|
|
10
9
|
// `local/credentials.yaml` (storage-19).
|
|
11
10
|
import { anotherAccountError, HostError, } from "../lib/git-host.js";
|
|
12
|
-
import { homeFilePath, instanceAt, readHomeFile, updateHomeFile, withDisplayName, withSignIn } from "../lib/home-file.js";
|
|
11
|
+
import { homeFilePath, instanceAt, isSpaceGitOrigin, readHomeFile, updateHomeFile, withDisplayName, withSignIn } from "../lib/home-file.js";
|
|
13
12
|
import { authTarget } from "./auth-target.js";
|
|
14
13
|
import { instanceFolder } from "../lib/instance.js";
|
|
15
14
|
import { cacheRegistryName, clientOf, credentialsOf, describedRegistryName, homeDir, hostCause, hostOf, listed, nameOf, readHome, registryName, signedIn } from "./home.js";
|
|
@@ -91,8 +90,10 @@ export const login = async (args, interrupt) => {
|
|
|
91
90
|
const client = clientOf(origin, credentials, undefined, scope);
|
|
92
91
|
// The registry's or Space's display name, read while the person
|
|
93
92
|
// approves; a sign-in goes on where it does not answer.
|
|
94
|
-
const described = scope === "registry"
|
|
95
|
-
|
|
93
|
+
const described = scope === "registry"
|
|
94
|
+
? describedRegistryName(origin).then((displayName) => ({ displayName }))
|
|
95
|
+
: client.describe().catch(() => null);
|
|
96
|
+
// At a listed instance, only its entry's account: read in
|
|
96
97
|
// the turn that would store the token, so another stores nothing.
|
|
97
98
|
const admit = (account) => {
|
|
98
99
|
if (scope === "registry")
|
|
@@ -160,7 +161,9 @@ export const login = async (args, interrupt) => {
|
|
|
160
161
|
const nameSkipped = new Promise((resolve) => { skipName = () => resolve(null); });
|
|
161
162
|
const deferred = interrupt.hold(() => skipName());
|
|
162
163
|
try {
|
|
163
|
-
const
|
|
164
|
+
const description = await Promise.race([described, nameSkipped]);
|
|
165
|
+
const displayName = description?.displayName || null;
|
|
166
|
+
const gitOrigin = description && "gitOrigin" in description && isSpaceGitOrigin(description.gitOrigin) ? description.gitOrigin : undefined;
|
|
164
167
|
if (scope === "registry") {
|
|
165
168
|
if (held)
|
|
166
169
|
await clientOf(origin, heldOnly(held), undefined, scope).signOut().catch(() => undefined);
|
|
@@ -178,7 +181,9 @@ export const login = async (args, interrupt) => {
|
|
|
178
181
|
try {
|
|
179
182
|
recorded = updateHomeFile(dir, (current) => {
|
|
180
183
|
const next = withSignIn(current, origin, account, homeFilePath(dir));
|
|
181
|
-
|
|
184
|
+
if (displayName === null && gitOrigin === undefined)
|
|
185
|
+
return next;
|
|
186
|
+
return withDisplayName(next, origin, displayName ?? instanceAt(next, origin)?.displayName ?? null, gitOrigin) ?? next;
|
|
182
187
|
});
|
|
183
188
|
}
|
|
184
189
|
catch (error) {
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex logout [--registry <url> | --space <url>]` (cli-11, git-host-
|
|
4
|
-
// DR-168): revoke this computer's sign-in for one purpose alone — this
|
|
3
|
+
// `spex logout [--registry <url> | --space <url>]` (cli-11, git-host-31, DR-168): revoke this computer's sign-in for one purpose alone — this
|
|
5
4
|
// folder's registry for its packages by default, or the registry or
|
|
6
5
|
// Space named — and, for a Space, in the turn its pair is removed, mark
|
|
7
6
|
// its entry signed out in `home.yaml`, keeping the entry and every other
|
|
@@ -52,7 +51,7 @@ export const logout = async (args) => {
|
|
|
52
51
|
const client = clientOf(entry.origin, credentialsOf(dir, entry.origin));
|
|
53
52
|
let marked = null;
|
|
54
53
|
try {
|
|
55
|
-
// The pair's removal and the entry's mark are one step (git-host-
|
|
54
|
+
// The pair's removal and the entry's mark are one step (git-host-31).
|
|
56
55
|
await client.signOut(() => {
|
|
57
56
|
try {
|
|
58
57
|
updateHomeFile(dir, (current) => withSignOut(current, entry.origin));
|
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);
|
|
@@ -53,7 +60,7 @@ export const publish = async (args) => {
|
|
|
53
60
|
if (!isPackageName(name))
|
|
54
61
|
throw new Refusal(packageNameRefusal(name));
|
|
55
62
|
// The folder: the one spex.yaml adds that name from, else
|
|
56
|
-
// spex-packages/<org>/<pkg>/ under the root (environments-
|
|
63
|
+
// spex-packages/<org>/<pkg>/ under the root (environments-59).
|
|
57
64
|
const request = read?.requests.packages[name];
|
|
58
65
|
const path = request !== undefined && isPathRequest(request) ? request.path : `spex-packages/${name}`;
|
|
59
66
|
const folder = resolve(env.root, path);
|
|
@@ -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/remove.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
-
// `spex remove <org>/<pkg>`, or `spex rm` (cli-3, environments-
|
|
3
|
+
// `spex remove <org>/<pkg>`, or `spex rm` (cli-3, environments-65): take
|
|
4
4
|
// the package out of `spex.yaml`, resolve, install and export what
|
|
5
5
|
// remains, and print each package removed, an edited copy of its spec
|
|
6
6
|
// left in `specs/` as the project's own and read as edited, in the words
|
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\nGuards\n verify [<guard>\u2026] Check that each guard's protected behavior still holds\n approve <guard> Record your approval of a guard's items and files\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;
|