@mostra/runtime 0.14.0 → 0.15.1
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/dist/bin.js +1 -1
- package/dist/child-protocol-CPXR6pMu.js +13 -0
- package/dist/child-protocol-CPXR6pMu.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{instance-CFTw3g-c.js → instance-Bw1BxctF.js} +2581 -189
- package/dist/instance-Bw1BxctF.js.map +1 -0
- package/dist/plugins/child/host.d.ts +1 -0
- package/dist/plugins/child/host.js +165 -0
- package/dist/plugins/child/host.js.map +1 -0
- package/dist/reference/cli.md +147 -5
- package/dist/reference/diagnostics.json +234 -0
- package/dist/reference/errors/MOSTRA_LICENSE_ACCEPT_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_MISMATCH.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_UNACCEPTED.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_UNDECLARED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ADDRESS_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_CSS_UNIMPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_FETCH_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_FILE_EXISTS.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ITEM_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ITEM_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_NOT_APPLIED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_OFFLINE.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_TARGET_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_CONTRACT_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_ENTRY_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_EXPORTER_UNKNOWN.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_MANIFEST_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_MANIFEST_WARNING.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_NOT_A_PLUGIN.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_NOT_INSTALLED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_OPTIONS_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_PLATFORM_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_SCOPE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_SHADOWED.md +23 -0
- package/dist/skill/SKILL.md +4 -2
- package/dist/skill/references/mcp.md +2 -2
- package/dist/skill/references/plugins.md +51 -0
- package/package.json +10 -7
- package/src/deps/index.ts +407 -90
- package/src/deps/installer.ts +53 -10
- package/src/deps/lock.ts +74 -2
- package/src/home/settings.ts +3 -0
- package/src/instance/index.ts +57 -0
- package/src/packs/index.ts +7 -0
- package/src/packs/methods.ts +49 -0
- package/src/packs/packs.ts +706 -0
- package/src/packs/read.ts +759 -0
- package/src/platform/index.ts +1 -0
- package/src/platform/shell.ts +14 -0
- package/src/plugins/child/host.ts +231 -0
- package/src/plugins/child-protocol.ts +68 -0
- package/src/plugins/index.ts +7 -0
- package/src/plugins/location.ts +109 -0
- package/src/plugins/methods.ts +269 -0
- package/src/plugins/plugins.ts +1396 -0
- package/src/publish/publisher.ts +71 -3
- package/dist/instance-CFTw3g-c.js.map +0 -1
package/src/deps/installer.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { writeFile } from "node:fs/promises";
|
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { createDiagnostic, type Diagnostic } from "@mostra/protocol";
|
|
13
|
+
import { PLUGIN_CONTRACTS } from "@mostra/protocol/plugin";
|
|
13
14
|
import type { Environment, Log } from "../log.ts";
|
|
14
15
|
import { artifactEnvironment, type ProcessManager } from "../processes/index.ts";
|
|
15
16
|
import { runtimeRoot } from "./warm.ts";
|
|
@@ -48,6 +49,12 @@ export interface InstallRun {
|
|
|
48
49
|
readonly releaseAge: { readonly exempt: readonly string[] } | false;
|
|
49
50
|
/** What the child serves, for `instance/status` and reaping. */
|
|
50
51
|
readonly ownerRef: string;
|
|
52
|
+
/**
|
|
53
|
+
* `false` installs without running any lifecycle script (`--config.ignore-scripts=true`), for a
|
|
54
|
+
* layout whose packages Mostra inspects before anything of them runs (a plugin's licenses,
|
|
55
|
+
* WP-16); {@link Installer.rebuild} runs them once it may.
|
|
56
|
+
*/
|
|
57
|
+
readonly scripts?: false;
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
/** What a run ended with. */
|
|
@@ -66,6 +73,16 @@ export interface Installer {
|
|
|
66
73
|
* resolution reads (D95), so it never sees that one. A store command takes no network flag.
|
|
67
74
|
*/
|
|
68
75
|
prune(input: { readonly dir: string; readonly ownerRef: string }): Promise<InstallOutcome>;
|
|
76
|
+
/**
|
|
77
|
+
* `pnpm rebuild` in an installed layout: runs the lifecycle scripts an install made with
|
|
78
|
+
* `scripts: false` skipped, from what the layout holds (it fetches nothing), in the install
|
|
79
|
+
* child (D95).
|
|
80
|
+
*/
|
|
81
|
+
rebuild(input: {
|
|
82
|
+
readonly dir: string;
|
|
83
|
+
readonly cwd: string;
|
|
84
|
+
readonly ownerRef: string;
|
|
85
|
+
}): Promise<InstallOutcome>;
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
/** Connection failures: the registry can't be reached at all, so Mostra is offline (D95). */
|
|
@@ -109,15 +126,24 @@ function locatePnpm(): { entry: string; version: string } {
|
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
|
|
112
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* The extension contracts' packages, which the release age never holds back (D173): Mostra's own
|
|
131
|
+
* release pipeline publishes them beside the runtime that runs them, so a plugin built on a
|
|
132
|
+
* contract released today installs today, wherever in its tree the contract is.
|
|
133
|
+
*/
|
|
134
|
+
export const RELEASE_AGE_EXEMPT: readonly string[] = Object.values(PLUGIN_CONTRACTS).map(
|
|
135
|
+
(contract) => contract.package,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The project settings of a run: the release age, the packages named exactly and the extension
|
|
140
|
+
* contracts' packages, which it doesn't hold back (D95, D173).
|
|
141
|
+
*/
|
|
113
142
|
export function workspaceSettings(releaseAge: InstallRun["releaseAge"]): string {
|
|
114
143
|
if (releaseAge === false) return "minimumReleaseAge: 0\n";
|
|
115
|
-
const lines = [`minimumReleaseAge: ${MINIMUM_RELEASE_AGE_MINUTES}
|
|
116
|
-
|
|
117
|
-
lines.push(
|
|
118
|
-
for (const name of [...new Set(releaseAge.exempt)].sort()) {
|
|
119
|
-
lines.push(` - ${JSON.stringify(name)}`);
|
|
120
|
-
}
|
|
144
|
+
const lines = [`minimumReleaseAge: ${MINIMUM_RELEASE_AGE_MINUTES}`, "minimumReleaseAgeExclude:"];
|
|
145
|
+
for (const name of [...new Set([...RELEASE_AGE_EXEMPT, ...releaseAge.exempt])].sort()) {
|
|
146
|
+
lines.push(` - ${JSON.stringify(name)}`);
|
|
121
147
|
}
|
|
122
148
|
return `${lines.join("\n")}\n`;
|
|
123
149
|
}
|
|
@@ -148,6 +174,7 @@ export function createInstaller(options: InstallerOptions): Installer {
|
|
|
148
174
|
readonly dir: string;
|
|
149
175
|
readonly cacheDir: string;
|
|
150
176
|
readonly network?: "--offline" | "--prefer-offline";
|
|
177
|
+
readonly scripts?: false;
|
|
151
178
|
}): string[] => [
|
|
152
179
|
// The install child connects to the supervisor and runs pnpm in its own process group.
|
|
153
180
|
entry,
|
|
@@ -167,9 +194,10 @@ export function createInstaller(options: InstallerOptions): Installer {
|
|
|
167
194
|
"--reporter=ndjson",
|
|
168
195
|
...(spec.network ? [spec.network] : []),
|
|
169
196
|
"--config.update-notifier=false",
|
|
170
|
-
// Every on-demand package's lifecycle scripts run, here in the install child (D95)
|
|
197
|
+
// Every on-demand package's lifecycle scripts run, here in the install child (D95), unless
|
|
198
|
+
// the run defers them until Mostra has inspected the packages (WP-16).
|
|
171
199
|
"--config.dangerously-allow-all-builds=true",
|
|
172
|
-
|
|
200
|
+
`--config.ignore-scripts=${spec.scripts === false ? "true" : "false"}`,
|
|
173
201
|
"--config.auto-install-peers=true",
|
|
174
202
|
"--config.strict-peer-dependencies=false",
|
|
175
203
|
"--config.node-linker=isolated",
|
|
@@ -255,12 +283,27 @@ export function createInstaller(options: InstallerOptions): Installer {
|
|
|
255
283
|
dir: run.dir,
|
|
256
284
|
cacheDir: options.dirs.cache,
|
|
257
285
|
network: run.offline ? "--offline" : "--prefer-offline",
|
|
286
|
+
...(run.scripts === false ? { scripts: false as const } : {}),
|
|
258
287
|
}),
|
|
259
288
|
dir: run.dir,
|
|
260
289
|
cwd: run.cwd,
|
|
261
290
|
releaseAge: run.releaseAge,
|
|
262
291
|
ownerRef: run.ownerRef,
|
|
263
292
|
}),
|
|
293
|
+
rebuild: (input) =>
|
|
294
|
+
execute({
|
|
295
|
+
args: argsFor({
|
|
296
|
+
command: ["rebuild"],
|
|
297
|
+
dir: input.dir,
|
|
298
|
+
cacheDir: options.dirs.cache,
|
|
299
|
+
// pnpm 10's rebuild refuses `--offline` (VERIFIED_FACTS, WP-16); it reads only the
|
|
300
|
+
// installed layout, and fetches nothing.
|
|
301
|
+
}),
|
|
302
|
+
dir: input.dir,
|
|
303
|
+
cwd: input.cwd,
|
|
304
|
+
releaseAge: false,
|
|
305
|
+
ownerRef: input.ownerRef,
|
|
306
|
+
}),
|
|
264
307
|
prune: (input) =>
|
|
265
308
|
execute({
|
|
266
309
|
args: argsFor({
|
|
@@ -310,7 +353,7 @@ function diagnose(
|
|
|
310
353
|
const mature =
|
|
311
354
|
first.code === "ERR_PNPM_FETCH_404"
|
|
312
355
|
? ""
|
|
313
|
-
: " Without an exact version, only releases at least a day old match
|
|
356
|
+
: " Without an exact version, only releases at least a day old match: a release less than a day old installs when it is named exactly, and, when it is a dependency of what was named, once it is a day old.";
|
|
314
357
|
return createDiagnostic("MOSTRA_DEP_NOT_FOUND", {
|
|
315
358
|
message: `The registry has no match for ${subject}: ${first.message}.${mature}`,
|
|
316
359
|
});
|
package/src/deps/lock.ts
CHANGED
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
* The lockfile (`lock.yaml`, D20, D95): what a version was built with, frozen at publish, and the
|
|
3
3
|
* form of every artifact's working lockfile. WP-03's form lists the warm set; an artifact with
|
|
4
4
|
* on-demand packages adds `packages` (each direct one at its exact version) and `pnpm` (the
|
|
5
|
-
* installer's lockfile, which pins the whole graph).
|
|
6
|
-
*
|
|
5
|
+
* installer's lockfile, which pins the whole graph). WP-16 adds, additively, `plugins` (the
|
|
6
|
+
* artifact's plugins in load order, ROUND-3 §6.4) and `licenses` (the licenses acknowledged for
|
|
7
|
+
* them and for packs, D31, each with its class, who accepted it and when). `lockDigest` is the
|
|
8
|
+
* SHA-256 of the text, so any change to any of them changes `envDigest` and the version (DP-03);
|
|
9
|
+
* a lockfile without plugins or acknowledgments keeps its earlier form byte for byte.
|
|
7
10
|
*/
|
|
8
11
|
import { createHash } from "node:crypto";
|
|
12
|
+
import type { LicenseClass } from "@mostra/protocol";
|
|
9
13
|
import { parse } from "yaml";
|
|
10
14
|
|
|
15
|
+
/** A license acknowledged for an artifact (or the home), as its lockfile records it (D31). */
|
|
16
|
+
export interface LockLicense {
|
|
17
|
+
/** Its class when it was accepted. */
|
|
18
|
+
readonly class: LicenseClass;
|
|
19
|
+
/** `flag` (`--accept-license`) or `host` (the home's license policy). */
|
|
20
|
+
readonly by: "flag" | "host";
|
|
21
|
+
// No time and no person (D172 item 6): `lockDigest` is part of the version's identity, so it
|
|
22
|
+
// stays a function of what the version is built from; the supervisor's log says when.
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
/** A lockfile's content. */
|
|
12
26
|
export interface Lock {
|
|
13
27
|
/** Every warm package and its version. */
|
|
@@ -16,6 +30,10 @@ export interface Lock {
|
|
|
16
30
|
readonly packages: Readonly<Record<string, string>>;
|
|
17
31
|
/** The installer's lockfile (pnpm's `pnpm-lock.yaml`), present exactly when `packages` isn't empty. */
|
|
18
32
|
readonly pnpm?: string;
|
|
33
|
+
/** The plugins' package names in load order (WP-16); each is also in `packages`. */
|
|
34
|
+
readonly plugins?: readonly string[];
|
|
35
|
+
/** The licenses acknowledged, by ID (WP-16). */
|
|
36
|
+
readonly licenses?: Readonly<Record<string, LockLicense>>;
|
|
19
37
|
}
|
|
20
38
|
|
|
21
39
|
const HEADER = "# Mostra lockfile: the packages this version was built with. Frozen at publish.";
|
|
@@ -41,6 +59,19 @@ export function lockText(lock: Lock): string {
|
|
|
41
59
|
const pnpm = lock.pnpm.replace(/\s+$/, "");
|
|
42
60
|
for (const line of pnpm.split("\n")) lines.push(line === "" ? "" : ` ${line}`);
|
|
43
61
|
}
|
|
62
|
+
if ((lock.plugins?.length ?? 0) > 0) {
|
|
63
|
+
lines.push("plugins:");
|
|
64
|
+
for (const name of lock.plugins ?? []) lines.push(` - ${JSON.stringify(name)}`);
|
|
65
|
+
}
|
|
66
|
+
const licenses = Object.entries(lock.licenses ?? {}).sort(([a], [b]) => (a < b ? -1 : 1));
|
|
67
|
+
if (licenses.length > 0) {
|
|
68
|
+
lines.push("licenses:");
|
|
69
|
+
for (const [id, license] of licenses) {
|
|
70
|
+
lines.push(` ${JSON.stringify(id)}:`);
|
|
71
|
+
lines.push(` class: ${JSON.stringify(license.class)}`);
|
|
72
|
+
lines.push(` by: ${JSON.stringify(license.by)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
44
75
|
const text = `${lines.join("\n")}\n`;
|
|
45
76
|
// The block scalar must hold the installer's lockfile exactly; anything else is a bug here.
|
|
46
77
|
const back = parseLock(text);
|
|
@@ -56,11 +87,24 @@ export function parseLock(text: string): Lock {
|
|
|
56
87
|
warm?: Record<string, string> | null;
|
|
57
88
|
packages?: Record<string, string> | null;
|
|
58
89
|
pnpm?: string;
|
|
90
|
+
plugins?: string[] | null;
|
|
91
|
+
licenses?: Record<string, LockLicense> | null;
|
|
59
92
|
};
|
|
60
93
|
return {
|
|
61
94
|
warm: data.warm ?? {},
|
|
62
95
|
packages: data.packages ?? {},
|
|
63
96
|
...(typeof data.pnpm === "string" ? { pnpm: data.pnpm } : {}),
|
|
97
|
+
...(Array.isArray(data.plugins) && data.plugins.length > 0 ? { plugins: data.plugins } : {}),
|
|
98
|
+
...(data.licenses && Object.keys(data.licenses).length > 0
|
|
99
|
+
? {
|
|
100
|
+
licenses: Object.fromEntries(
|
|
101
|
+
Object.entries(data.licenses).map(([id, license]) => [
|
|
102
|
+
id,
|
|
103
|
+
{ class: license.class, by: license.by === "host" ? "host" : "flag" } as LockLicense,
|
|
104
|
+
]),
|
|
105
|
+
),
|
|
106
|
+
}
|
|
107
|
+
: {}),
|
|
64
108
|
};
|
|
65
109
|
}
|
|
66
110
|
|
|
@@ -80,3 +124,31 @@ export function pinnedPackages(pnpm: string): { name: string; version: string }[
|
|
|
80
124
|
}
|
|
81
125
|
return result;
|
|
82
126
|
}
|
|
127
|
+
|
|
128
|
+
/** `lock` with the plugins and acknowledgments of `from` (a working lockfile), which a resolution keeps. */
|
|
129
|
+
export function withExtras(lock: Lock, from: Lock | undefined): Lock {
|
|
130
|
+
const { plugins: _plugins, licenses: _licenses, ...rest } = lock;
|
|
131
|
+
const plugins = from?.plugins ?? [];
|
|
132
|
+
const licenses = from?.licenses ?? {};
|
|
133
|
+
return {
|
|
134
|
+
...rest,
|
|
135
|
+
...(plugins.length > 0 ? { plugins } : {}),
|
|
136
|
+
...(Object.keys(licenses).length > 0 ? { licenses } : {}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The key of the layout a lockfile builds against (`deps/locks/<key>`): the digest of its
|
|
142
|
+
* packages alone, without its plugins and acknowledgments, which change what a version records
|
|
143
|
+
* but not what it installs. For a lockfile without either it is its `lockDigest`, so layouts made
|
|
144
|
+
* before WP-16 keep their names.
|
|
145
|
+
*/
|
|
146
|
+
export function layoutKey(lock: Lock): string {
|
|
147
|
+
return lockDigest(
|
|
148
|
+
lockText({
|
|
149
|
+
warm: lock.warm,
|
|
150
|
+
packages: lock.packages,
|
|
151
|
+
...(lock.pnpm ? { pnpm: lock.pnpm } : {}),
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
}
|
package/src/home/settings.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface HomeSettings {
|
|
|
31
31
|
* standalone CLI sends no telemetry for a home that carries it.
|
|
32
32
|
*/
|
|
33
33
|
readonly hostConfigured?: { readonly client: string; readonly at: string };
|
|
34
|
+
/** The licenses a host accepts for every plugin and pack install (D31, `HomeConfig.licenses`). */
|
|
35
|
+
readonly licenses?: { readonly accept: readonly string[] };
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const Settings = z.looseObject({
|
|
@@ -43,6 +45,7 @@ const Settings = z.looseObject({
|
|
|
43
45
|
.max(2)
|
|
44
46
|
.optional(),
|
|
45
47
|
hostConfigured: z.object({ client: z.string(), at: z.string() }).optional(),
|
|
48
|
+
licenses: z.object({ accept: z.array(z.string()) }).optional(),
|
|
46
49
|
});
|
|
47
50
|
|
|
48
51
|
/** The settings file of a home. */
|
package/src/instance/index.ts
CHANGED
|
@@ -90,7 +90,14 @@ import {
|
|
|
90
90
|
} from "../link/index.ts";
|
|
91
91
|
import { createLive, type LatestLive, liveMethods } from "../live/index.ts";
|
|
92
92
|
import type { Environment, Log } from "../log.ts";
|
|
93
|
+
import { createPacks, type Packs, packMethods } from "../packs/index.ts";
|
|
93
94
|
import { helperPath, type LaunchPipe, realPath } from "../platform/index.ts";
|
|
95
|
+
import {
|
|
96
|
+
createPlugins,
|
|
97
|
+
type Plugins,
|
|
98
|
+
pluginMethods,
|
|
99
|
+
testContractVersions,
|
|
100
|
+
} from "../plugins/index.ts";
|
|
94
101
|
import {
|
|
95
102
|
artifactEnvironment,
|
|
96
103
|
openProcessManager,
|
|
@@ -332,6 +339,8 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
332
339
|
warm: locateWarmSet(environment),
|
|
333
340
|
policy: () => readHomeSettings(home.path).dependencies ?? "auto",
|
|
334
341
|
faults,
|
|
342
|
+
// Every lockfile that names plugins passes their gate (WP-16, D172 item 5).
|
|
343
|
+
plugins: () => getPlugins(),
|
|
335
344
|
// Tests shorten the 300 s install limit to exercise MOSTRA_DEP_TIMEOUT.
|
|
336
345
|
...(Number(environment["MOSTRA_TEST_INSTALL_TIMEOUT_MS"]) > 0
|
|
337
346
|
? { installTimeoutMs: Number(environment["MOSTRA_TEST_INSTALL_TIMEOUT_MS"]) }
|
|
@@ -340,6 +349,39 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
340
349
|
// Suites of other features publish without verify's gate; the switch is loud (D138).
|
|
341
350
|
const unverifiedPublish = Boolean(environment["MOSTRA_TEST_UNVERIFIED_PUBLISH"]);
|
|
342
351
|
if (unverifiedPublish) log.warn("instance.test_unverified_publish", {});
|
|
352
|
+
// Plugins and packs (WP-16, D30, D31): made on first use, like the dependencies they change.
|
|
353
|
+
let plugins: Plugins | undefined;
|
|
354
|
+
const getPlugins = (): Plugins =>
|
|
355
|
+
(plugins ??= createPlugins({
|
|
356
|
+
home: home.path,
|
|
357
|
+
dependencies: getDependencies(),
|
|
358
|
+
processes: manager,
|
|
359
|
+
log,
|
|
360
|
+
env: environment,
|
|
361
|
+
policy: () => readHomeSettings(home.path).licenses,
|
|
362
|
+
runtimeVersion: runtimeVersion(),
|
|
363
|
+
// Tests stand in a runtime that serves other contract versions (plugins.test.ts).
|
|
364
|
+
...(environment["MOSTRA_TEST_CONTRACT_VERSIONS"]
|
|
365
|
+
? { implemented: testContractVersions(environment["MOSTRA_TEST_CONTRACT_VERSIONS"]) }
|
|
366
|
+
: {}),
|
|
367
|
+
}));
|
|
368
|
+
let packs: Packs | undefined;
|
|
369
|
+
const getPacks = (): Packs =>
|
|
370
|
+
(packs ??= createPacks({
|
|
371
|
+
dependencies: getDependencies(),
|
|
372
|
+
plugins: getPlugins(),
|
|
373
|
+
log,
|
|
374
|
+
env: environment,
|
|
375
|
+
// Tests point GitHub registries at a local fake (packs.test.ts).
|
|
376
|
+
...(environment["MOSTRA_TEST_GITHUB_API"] && environment["MOSTRA_TEST_GITHUB_RAW"]
|
|
377
|
+
? {
|
|
378
|
+
github: {
|
|
379
|
+
api: environment["MOSTRA_TEST_GITHUB_API"],
|
|
380
|
+
raw: environment["MOSTRA_TEST_GITHUB_RAW"],
|
|
381
|
+
},
|
|
382
|
+
}
|
|
383
|
+
: {}),
|
|
384
|
+
}));
|
|
343
385
|
let publisher: Publisher | undefined;
|
|
344
386
|
const getPublisher = (): Publisher => {
|
|
345
387
|
if (publisher) return publisher;
|
|
@@ -853,6 +895,9 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
853
895
|
...(config.submitChannels !== undefined
|
|
854
896
|
? { submitChannels: [...new Set(config.submitChannels)].sort() }
|
|
855
897
|
: {}),
|
|
898
|
+
...(config.licenses !== undefined
|
|
899
|
+
? { licenses: { accept: [...new Set(config.licenses.accept)].sort() } }
|
|
900
|
+
: {}),
|
|
856
901
|
};
|
|
857
902
|
if (Object.keys(change).length === 0) return;
|
|
858
903
|
writeHomeSettings(home.path, change);
|
|
@@ -862,6 +907,7 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
862
907
|
...(config.submission !== undefined ? { submission: config.submission } : {}),
|
|
863
908
|
...(config.ports !== undefined ? { ports: config.ports } : {}),
|
|
864
909
|
...(config.submitChannels !== undefined ? { submitChannels: config.submitChannels } : {}),
|
|
910
|
+
...(config.licenses !== undefined ? { licenses: config.licenses.accept } : {}),
|
|
865
911
|
});
|
|
866
912
|
},
|
|
867
913
|
// A host's home never sends the standalone CLI's telemetry (D140 item 4).
|
|
@@ -892,6 +938,17 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
892
938
|
},
|
|
893
939
|
dependenciesAdded: (artifact) => dev.dependenciesChanged(artifact),
|
|
894
940
|
}),
|
|
941
|
+
...pluginMethods({
|
|
942
|
+
plugins: getPlugins,
|
|
943
|
+
publisher: getPublisher,
|
|
944
|
+
log,
|
|
945
|
+
dependenciesChanged: (artifact) => dev.dependenciesChanged(artifact),
|
|
946
|
+
}),
|
|
947
|
+
...packMethods({
|
|
948
|
+
packs: getPacks,
|
|
949
|
+
publisher: getPublisher,
|
|
950
|
+
dependenciesChanged: (artifact) => dev.dependenciesChanged(artifact),
|
|
951
|
+
}),
|
|
895
952
|
...dev.methods(),
|
|
896
953
|
// A hosted artifact's roster is its hosted home's, like its state (D165 item 1, D168).
|
|
897
954
|
...forwardHosted(link, (ref) => registry.get(canonicalRef(ref)).id, gateway.methods()),
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pack/add` (INTERFACES §14, D172 item 10): shadcn registry items, and npm packages beside them,
|
|
3
|
+
* into an artifact, in its source path's queue as its publishes and `deps/add` run.
|
|
4
|
+
*/
|
|
5
|
+
import { isAbsolute, resolve } from "node:path";
|
|
6
|
+
import { type PackAddParams, packAddMethod, type SourceRef } from "@mostra/protocol";
|
|
7
|
+
import { parsePackAddress } from "@mostra/protocol/plugin";
|
|
8
|
+
import { requestKey } from "../ledger/index.ts";
|
|
9
|
+
import { handler, type MethodHandler } from "../protocol-server/index.ts";
|
|
10
|
+
import type { Publisher } from "../publish/index.ts";
|
|
11
|
+
import type { Packs } from "./packs.ts";
|
|
12
|
+
|
|
13
|
+
/** The handler of `pack/add`. */
|
|
14
|
+
export function packMethods(options: {
|
|
15
|
+
readonly packs: () => Packs;
|
|
16
|
+
readonly publisher: () => Publisher;
|
|
17
|
+
/** An artifact's dependencies changed (a dev session reloads, D140 item 12). */
|
|
18
|
+
readonly dependenciesChanged?: (artifact: SourceRef) => void;
|
|
19
|
+
}): MethodHandler[] {
|
|
20
|
+
return [
|
|
21
|
+
handler(packAddMethod, async (params: PackAddParams) => {
|
|
22
|
+
const result = await options.publisher().withArtifact(params.artifact, ({ target, source }) =>
|
|
23
|
+
options.packs().add({
|
|
24
|
+
target,
|
|
25
|
+
root: source.root,
|
|
26
|
+
kind: source.kind,
|
|
27
|
+
entry: source.entry,
|
|
28
|
+
// A relative item file is the caller's to resolve; one that arrives relative is read
|
|
29
|
+
// from the artifact's directory.
|
|
30
|
+
specs: params.specs.map((spec) => {
|
|
31
|
+
const address = parsePackAddress(spec);
|
|
32
|
+
return address?.kind === "file" && !isAbsolute(address.path)
|
|
33
|
+
? resolve(source.root, address.path)
|
|
34
|
+
: spec;
|
|
35
|
+
}),
|
|
36
|
+
overwrite: params.overwrite === true,
|
|
37
|
+
accept: params.acceptLicenses ?? [],
|
|
38
|
+
// The caller's variables are how the items are read, not what is asked for: a retry
|
|
39
|
+
// with a refreshed token is the same request, and no token enters the record.
|
|
40
|
+
request: requestKey("pack/add", { ...params, environment: undefined }),
|
|
41
|
+
cwd: source.root,
|
|
42
|
+
environment: params.environment ?? {},
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
options.dependenciesChanged?.(params.artifact);
|
|
46
|
+
return result;
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
}
|