@intentius/chant 0.124.100 → 0.124.101
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/action-pins.d.ts +2 -0
- package/dist/action-pins.js +3 -0
- package/dist/ci-detect.d.ts +13 -0
- package/dist/ci-detect.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/handlers/build.js +27 -0
- package/dist/cli/handlers/release-doctor.d.ts +12 -0
- package/dist/cli/handlers/release-doctor.js +118 -0
- package/dist/cli/handlers/release-init.d.ts +10 -0
- package/dist/cli/handlers/release-init.js +342 -0
- package/dist/cli/handlers/release.d.ts +42 -1
- package/dist/cli/handlers/release.js +656 -31
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +44 -101
- package/dist/cli/parse-args.js +48 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/release-commands/artifacts.d.ts +3 -0
- package/dist/cli/release-commands/artifacts.js +14 -0
- package/dist/cli/release-commands/candidates.d.ts +3 -0
- package/dist/cli/release-commands/candidates.js +16 -0
- package/dist/cli/release-commands/changed.d.ts +3 -0
- package/dist/cli/release-commands/changed.js +14 -0
- package/dist/cli/release-commands/compose.d.ts +3 -0
- package/dist/cli/release-commands/compose.js +16 -0
- package/dist/cli/release-commands/cut.d.ts +3 -0
- package/dist/cli/release-commands/cut.js +49 -0
- package/dist/cli/release-commands/doctor.d.ts +3 -0
- package/dist/cli/release-commands/doctor.js +14 -0
- package/dist/cli/release-commands/export.d.ts +3 -0
- package/dist/cli/release-commands/export.js +12 -0
- package/dist/cli/release-commands/images.d.ts +3 -0
- package/dist/cli/release-commands/images.js +13 -0
- package/dist/cli/release-commands/index.d.ts +8 -0
- package/dist/cli/release-commands/index.js +52 -0
- package/dist/cli/release-commands/init.d.ts +3 -0
- package/dist/cli/release-commands/init.js +16 -0
- package/dist/cli/release-commands/list.d.ts +3 -0
- package/dist/cli/release-commands/list.js +10 -0
- package/dist/cli/release-commands/next.d.ts +3 -0
- package/dist/cli/release-commands/next.js +13 -0
- package/dist/cli/release-commands/publish.d.ts +3 -0
- package/dist/cli/release-commands/publish.js +22 -0
- package/dist/cli/release-commands/stamp.d.ts +3 -0
- package/dist/cli/release-commands/stamp.js +15 -0
- package/dist/cli/release-commands/status.d.ts +3 -0
- package/dist/cli/release-commands/status.js +17 -0
- package/dist/cli/release-commands/tag.d.ts +3 -0
- package/dist/cli/release-commands/tag.js +12 -0
- package/dist/cli/release-commands/types.d.ts +20 -0
- package/dist/cli/release-commands/types.js +1 -0
- package/dist/cli/release-commands/verify.d.ts +3 -0
- package/dist/cli/release-commands/verify.js +15 -0
- package/dist/cli/release-commands/workflow.d.ts +3 -0
- package/dist/cli/release-commands/workflow.js +13 -0
- package/dist/components/cli-support.d.ts +1 -1
- package/dist/components/cli-support.js +1 -1
- package/dist/config-environments.d.ts +8 -1
- package/dist/config-environments.js +2 -0
- package/dist/config.d.ts +294 -9
- package/dist/config.js +100 -5
- package/dist/floor-table.data.js +15 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +41 -2
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
- package/dist/lifecycle/publish-attachments.d.ts +2 -1
- package/dist/lifecycle/publish-attachments.js +19 -2
- package/dist/lifecycle/publish-cargo.d.ts +99 -0
- package/dist/lifecycle/publish-cargo.js +412 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +8 -0
- package/dist/lifecycle/publish-declaration.d.ts +199 -4
- package/dist/lifecycle/publish-declaration.js +200 -9
- package/dist/lifecycle/publish-forge.d.ts +45 -2
- package/dist/lifecycle/publish-forge.js +434 -34
- package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
- package/dist/lifecycle/publish-git-ssh.js +30 -4
- package/dist/lifecycle/publish-github.d.ts +40 -2
- package/dist/lifecycle/publish-github.js +100 -3
- package/dist/lifecycle/publish-homebrew.d.ts +7 -9
- package/dist/lifecycle/publish-homebrew.js +34 -197
- package/dist/lifecycle/publish-index.d.ts +141 -0
- package/dist/lifecycle/publish-index.js +719 -0
- package/dist/lifecycle/publish-marketplace.js +77 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +306 -0
- package/dist/lifecycle/publish-npm.js +165 -2
- package/dist/lifecycle/publish-oci.d.ts +34 -1
- package/dist/lifecycle/publish-oci.js +246 -7
- package/dist/lifecycle/publish-pypi.d.ts +136 -0
- package/dist/lifecycle/publish-pypi.js +657 -0
- package/dist/lifecycle/publish-record.d.ts +6 -3
- package/dist/lifecycle/publish-record.js +6 -3
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +27 -1
- package/dist/lifecycle/publish-targets.js +80 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +54 -0
- package/dist/lifecycle/publish-train-names.js +118 -0
- package/dist/lifecycle/publish-verify.d.ts +121 -0
- package/dist/lifecycle/publish-verify.js +130 -0
- package/dist/lifecycle/query.js +8 -0
- package/dist/lifecycle/release-artifacts.d.ts +212 -0
- package/dist/lifecycle/release-artifacts.js +571 -0
- package/dist/lifecycle/release-changelog.d.ts +13 -1
- package/dist/lifecycle/release-changelog.js +35 -2
- package/dist/lifecycle/release-cut.d.ts +58 -3
- package/dist/lifecycle/release-cut.js +132 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +996 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init.d.ts +255 -0
- package/dist/lifecycle/release-init.js +859 -0
- package/dist/lifecycle/release-intents.d.ts +73 -0
- package/dist/lifecycle/release-intents.js +128 -0
- package/dist/lifecycle/release-next.d.ts +111 -0
- package/dist/lifecycle/release-next.js +252 -0
- package/dist/lifecycle/release-prerelease.d.ts +19 -0
- package/dist/lifecycle/release-prerelease.js +30 -0
- package/dist/lifecycle/release-publish.d.ts +256 -10
- package/dist/lifecycle/release-publish.js +246 -34
- package/dist/lifecycle/release-status-change.d.ts +226 -0
- package/dist/lifecycle/release-status-change.js +478 -0
- package/dist/lifecycle/release-status.d.ts +11 -0
- package/dist/lifecycle/release-status.js +1 -1
- package/dist/lifecycle/release-store.d.ts +73 -2
- package/dist/lifecycle/release-store.js +32 -1
- package/dist/lifecycle/release-tag.d.ts +142 -0
- package/dist/lifecycle/release-tag.js +323 -0
- package/dist/lifecycle/release-verify.d.ts +73 -1
- package/dist/lifecycle/release-verify.js +117 -2
- package/dist/lifecycle/release-version-formats.d.ts +73 -0
- package/dist/lifecycle/release-version-formats.js +570 -0
- package/dist/lifecycle/release-version.d.ts +58 -10
- package/dist/lifecycle/release-version.js +164 -36
- package/dist/lifecycle/release-workstation.d.ts +3 -2
- package/dist/lifecycle/release-workstation.js +3 -2
- package/dist/op/generate-pipeline.js +1 -1
- package/dist/pr-forge-base.js +4 -2
- package/dist/pr-forge.d.ts +20 -2
- package/dist/pr-forge.js +46 -10
- package/dist/release-floors.d.ts +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/wave-runtime.mjs +337 -334
- package/dist/workspace/ci-forge.d.ts +17 -0
- package/dist/workspace/ci-forge.js +17 -0
- package/dist/workspace/ci-init.js +1 -1
- package/dist/workspace/composites.schema.json +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.js +12 -0
- package/dist/workspace/declaration.schema.json +8 -0
- package/dist/workspace/environments.d.ts +2 -0
- package/dist/workspace/environments.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +61 -5
- package/dist/workspace/identity-gate-rule.js +81 -12
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +2 -0
- package/dist/workspace/reason-codes.js +3 -1
- package/dist/workspace/release-changed.d.ts +75 -4
- package/dist/workspace/release-changed.js +205 -34
- package/dist/workspace/release-changed.schema.json +20 -2
- package/dist/workspace/release-steps/artifacts.d.ts +7 -0
- package/dist/workspace/release-steps/artifacts.js +45 -0
- package/dist/workspace/release-steps/builds.d.ts +12 -0
- package/dist/workspace/release-steps/builds.js +38 -0
- package/dist/workspace/release-steps/doctor.d.ts +8 -0
- package/dist/workspace/release-steps/doctor.js +14 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
- package/dist/workspace/release-steps/goreleaser.js +36 -0
- package/dist/workspace/release-steps/green.d.ts +3 -0
- package/dist/workspace/release-steps/green.js +6 -0
- package/dist/workspace/release-steps/images.d.ts +22 -0
- package/dist/workspace/release-steps/images.js +59 -0
- package/dist/workspace/release-steps/index.d.ts +9 -0
- package/dist/workspace/release-steps/index.js +46 -0
- package/dist/workspace/release-steps/pypi.d.ts +15 -0
- package/dist/workspace/release-steps/pypi.js +21 -0
- package/dist/workspace/release-steps/qemu.d.ts +21 -0
- package/dist/workspace/release-steps/qemu.js +35 -0
- package/dist/workspace/release-steps/signing.d.ts +18 -0
- package/dist/workspace/release-steps/signing.js +30 -0
- package/dist/workspace/release-steps/stamp.d.ts +3 -0
- package/dist/workspace/release-steps/stamp.js +4 -0
- package/dist/workspace/release-steps/targets.d.ts +31 -0
- package/dist/workspace/release-steps/targets.js +40 -0
- package/dist/workspace/release-steps/types.d.ts +104 -0
- package/dist/workspace/release-steps/types.js +2 -0
- package/dist/workspace/release-steps/verify.d.ts +3 -0
- package/dist/workspace/release-steps/verify.js +4 -0
- package/dist/workspace/release-toolchains.d.ts +59 -0
- package/dist/workspace/release-toolchains.js +133 -0
- package/dist/workspace/release-train-workflow.d.ts +29 -0
- package/dist/workspace/release-train-workflow.js +85 -0
- package/dist/workspace/release-train.d.ts +3 -1
- package/dist/workspace/release-train.js +20 -3
- package/dist/workspace/release-workflow.d.ts +160 -61
- package/dist/workspace/release-workflow.js +539 -193
- package/dist/workspace/releases.schema.json +70 -1
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/security.js +9 -2
- package/dist/workspace/train-cut.d.ts +182 -0
- package/dist/workspace/train-cut.js +482 -0
- package/dist/workspace/train-prepare.d.ts +61 -0
- package/dist/workspace/train-prepare.js +267 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +575 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- package/dist/workspace/trust/seal.d.ts +13 -3
- package/dist/workspace/trust/seal.js +14 -4
- package/dist/workspace/work-cli.d.ts +3 -2
- package/dist/workspace/work-cli.js +3 -2
- package/dist/workspace/workspace-ledger.d.ts +14 -1
- package/dist/workspace/workspace-ledger.js +33 -7
- package/package.json +1 -1
|
@@ -61,6 +61,8 @@ import { readFileSync } from "node:fs";
|
|
|
61
61
|
import { inflateRawSync } from "node:zlib";
|
|
62
62
|
import { readCredential } from "./publish-credentials.js";
|
|
63
63
|
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
64
|
+
import { releaseVersion } from "./publish-index.js";
|
|
65
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
64
66
|
import { PublishTargetError, } from "./release-publish.js";
|
|
65
67
|
/** The first chant that publishes a `marketplace` target (#4676). */
|
|
66
68
|
export const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
|
|
@@ -281,12 +283,87 @@ export function marketplaceTarget(decl, deps) {
|
|
|
281
283
|
const body = JSON.parse(res.text);
|
|
282
284
|
return (body.results?.[0]?.extensions?.[0]?.versions ?? []).some((v) => v.version === id.version);
|
|
283
285
|
};
|
|
286
|
+
/** #5165: the extension's manifest: from the `.vsix` when the checkout has it, else the member's package.json. */
|
|
287
|
+
const manifestOf = (ctx) => {
|
|
288
|
+
try {
|
|
289
|
+
const entry = readZipEntry(readFileSync(memberFile(ctx.cwd, decl.vsix)), "extension/package.json");
|
|
290
|
+
if (entry)
|
|
291
|
+
return JSON.parse(entry.toString("utf-8"));
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
// No .vsix here: the member's own manifest names the extension.
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
return JSON.parse(readFileSync(memberFile(ctx.cwd, "package.json"), "utf-8"));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
/** Whether the marketplace lists the version, read without downloading it. */
|
|
304
|
+
const has = async (ctx, id) => {
|
|
305
|
+
if (decl.marketplace === "vscode")
|
|
306
|
+
return galleryHas(ctx, id);
|
|
307
|
+
const meta = await get(`${registry}/api/${encodeURIComponent(id.publisher)}/${encodeURIComponent(id.name)}/${encodeURIComponent(id.version)}`);
|
|
308
|
+
if (meta.status === 404)
|
|
309
|
+
return false;
|
|
310
|
+
if (meta.status !== 200)
|
|
311
|
+
fail(ctx, `reading ${id.publisher}.${id.name}@${id.version}`, meta.status, meta.text);
|
|
312
|
+
return true;
|
|
313
|
+
};
|
|
284
314
|
const target = {
|
|
285
315
|
kind: "marketplace",
|
|
286
316
|
name: `${label} ${decl.vsix}`,
|
|
287
317
|
destination: label,
|
|
288
318
|
credentialEnv: tokenNames,
|
|
289
319
|
key: publishTargetKey(decl),
|
|
320
|
+
uploadsAtReveal: true,
|
|
321
|
+
/** #5165: the extension, and the extensions its `extensionDependencies` and `extensionPack` name. */
|
|
322
|
+
async names(ctx) {
|
|
323
|
+
const m = manifestOf(ctx);
|
|
324
|
+
if (!m || typeof m.publisher !== "string" || typeof m.name !== "string")
|
|
325
|
+
return { provides: [], needs: [] };
|
|
326
|
+
const self = trainName("marketplace", `${m.publisher}.${m.name}`);
|
|
327
|
+
const needs = new Set();
|
|
328
|
+
for (const field of ["extensionDependencies", "extensionPack"]) {
|
|
329
|
+
const list = m[field];
|
|
330
|
+
if (Array.isArray(list))
|
|
331
|
+
for (const n of list)
|
|
332
|
+
if (typeof n === "string" && n.includes("."))
|
|
333
|
+
needs.add(trainName("marketplace", n));
|
|
334
|
+
}
|
|
335
|
+
needs.delete(self);
|
|
336
|
+
return { provides: [self], needs: [...needs] };
|
|
337
|
+
},
|
|
338
|
+
/** #5165: whether the marketplace lists the release's version of the extension. */
|
|
339
|
+
async published(ctx) {
|
|
340
|
+
const m = manifestOf(ctx);
|
|
341
|
+
const version = releaseVersion(ctx.label);
|
|
342
|
+
if (!m || typeof m.publisher !== "string" || typeof m.name !== "string" || !version)
|
|
343
|
+
return null;
|
|
344
|
+
return has(ctx, { publisher: m.publisher, name: m.name, version });
|
|
345
|
+
},
|
|
346
|
+
/** #5165: wait until the marketplace lists the version the reveal uploaded. */
|
|
347
|
+
async visible(ctx, published) {
|
|
348
|
+
const ids = published.items
|
|
349
|
+
.filter((i) => !i.refused)
|
|
350
|
+
.map((i) => /^([^.@]+)\.([^@]+)@(.+)$/.exec(i.name))
|
|
351
|
+
.filter((m) => m !== null)
|
|
352
|
+
.map((m) => ({ publisher: m[1], name: m[2], version: m[3] }));
|
|
353
|
+
if (ids.length === 0)
|
|
354
|
+
return;
|
|
355
|
+
await waitUntilServed(ctx, deps, {
|
|
356
|
+
what: label,
|
|
357
|
+
code: "publish-marketplace-not-served",
|
|
358
|
+
check: async () => {
|
|
359
|
+
const missing = [];
|
|
360
|
+
for (const id of ids)
|
|
361
|
+
if (!(await has(ctx, id)))
|
|
362
|
+
missing.push(`${id.publisher}.${id.name}@${id.version}`);
|
|
363
|
+
return missing;
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
},
|
|
290
367
|
async plan(ctx) {
|
|
291
368
|
return [setup(ctx).item];
|
|
292
369
|
},
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP Registry target (#5162): a `server.json` published to the official
|
|
3
|
+
* MCP Registry, https://registry.modelcontextprotocol.io, so MCP clients find
|
|
4
|
+
* the server. A `server.json` names the npm packages, PyPI packages or OCI
|
|
5
|
+
* images that run the server, and the registry checks they exist, so this
|
|
6
|
+
* target reveals after every other target (`revealsLast`).
|
|
7
|
+
*
|
|
8
|
+
* It speaks the registry's HTTP API directly, the requests `mcp-publisher
|
|
9
|
+
* login github-oidc` and `mcp-publisher publish` make, so no tool is
|
|
10
|
+
* downloaded or run:
|
|
11
|
+
*
|
|
12
|
+
* - `POST /v0.1/auth/github-oidc` with `{ "oidc_token": ... }` exchanges the
|
|
13
|
+
* GitHub Actions OIDC token, requested with the registry's origin
|
|
14
|
+
* (`https://registry.modelcontextprotocol.io`) as its audience, for a
|
|
15
|
+
* registry token that lasts minutes. `POST /v0.1/auth/github-at` does the
|
|
16
|
+
* same for a GitHub token (`{ "github_token": ... }`).
|
|
17
|
+
* - `GET /v0.1/servers/{name}/versions/{version}` says whether a version is
|
|
18
|
+
* already published.
|
|
19
|
+
* - `POST /v0.1/publish` with the `server.json` as the body and the registry
|
|
20
|
+
* token as a bearer credential publishes it.
|
|
21
|
+
*
|
|
22
|
+
* The registry has no draft and refuses a version it already holds, and it
|
|
23
|
+
* does not let a version be replaced. So the stage sends nothing: it checks
|
|
24
|
+
* the `server.json` against the release, exchanges for a token to prove the
|
|
25
|
+
* credentials work, and reads whether the version is there. The reveal
|
|
26
|
+
* publishes.
|
|
27
|
+
*
|
|
28
|
+
* The `server.json` must belong to this release: its `version` is the
|
|
29
|
+
* release's label (from its first digit), and each package that names a
|
|
30
|
+
* version, and each OCI image's tag, is the same. Anything else is refused in
|
|
31
|
+
* the plan (`publish-mcp-registry-version-mismatch`,
|
|
32
|
+
* `publish-mcp-registry-package-mismatch`), so a release can't publish a
|
|
33
|
+
* listing for another version. `release.version.files` stamps the label into
|
|
34
|
+
* the file.
|
|
35
|
+
*/
|
|
36
|
+
import type { McpRegistryPublishDeclaration } from "./publish-declaration.js";
|
|
37
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
38
|
+
/** The first chant with the `mcp-registry` publish target: a `server.json` published to the MCP Registry after the packages it names, with GitHub OIDC, and the `mcp-registry-*` checks of `chant release doctor` (#5162). */
|
|
39
|
+
export declare const PUBLISH_MCP_REGISTRY_FLOOR = "0.124.101";
|
|
40
|
+
export declare const MCP_REGISTRY = "https://registry.modelcontextprotocol.io";
|
|
41
|
+
/** The variable a `github-token` target reads by default. */
|
|
42
|
+
export declare const MCP_GITHUB_TOKEN_ENV = "MCP_GITHUB_TOKEN";
|
|
43
|
+
/** The variable a `registry-token` target reads by default. */
|
|
44
|
+
export declare const MCP_REGISTRY_TOKEN_ENV = "MCP_REGISTRY_TOKEN";
|
|
45
|
+
export type McpRegistryAuth = NonNullable<McpRegistryPublishDeclaration["auth"]>;
|
|
46
|
+
/** The declaration's `auth`, refused when `tokenEnv` is set beside the OIDC exchange, which reads none. */
|
|
47
|
+
export declare function mcpRegistryAuth(decl: Pick<McpRegistryPublishDeclaration, "auth" | "tokenEnv">): McpRegistryAuth;
|
|
48
|
+
/** The variables the target's credential is read from, whose values are masked. */
|
|
49
|
+
export declare function mcpRegistryTokenEnv(decl: Pick<McpRegistryPublishDeclaration, "auth" | "tokenEnv">): string[];
|
|
50
|
+
/** The registry's origin, which is the audience of the OIDC token: scheme and lowercased host. */
|
|
51
|
+
export declare function mcpRegistryAudience(registry: string): string;
|
|
52
|
+
export interface ServerJson {
|
|
53
|
+
name: string;
|
|
54
|
+
version: string;
|
|
55
|
+
packages: Array<{
|
|
56
|
+
registryType?: string;
|
|
57
|
+
identifier?: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Read `text` as a `server.json` and check it is the release's: `label` is
|
|
63
|
+
* the release's label. Throws {@link PublishTargetError}.
|
|
64
|
+
*/
|
|
65
|
+
export declare function checkServerJson(text: string, path: string, label: string | null): ServerJson;
|
|
66
|
+
export declare function mcpRegistryTarget(decl: McpRegistryPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP Registry target (#5162): a `server.json` published to the official
|
|
3
|
+
* MCP Registry, https://registry.modelcontextprotocol.io, so MCP clients find
|
|
4
|
+
* the server. A `server.json` names the npm packages, PyPI packages or OCI
|
|
5
|
+
* images that run the server, and the registry checks they exist, so this
|
|
6
|
+
* target reveals after every other target (`revealsLast`).
|
|
7
|
+
*
|
|
8
|
+
* It speaks the registry's HTTP API directly, the requests `mcp-publisher
|
|
9
|
+
* login github-oidc` and `mcp-publisher publish` make, so no tool is
|
|
10
|
+
* downloaded or run:
|
|
11
|
+
*
|
|
12
|
+
* - `POST /v0.1/auth/github-oidc` with `{ "oidc_token": ... }` exchanges the
|
|
13
|
+
* GitHub Actions OIDC token, requested with the registry's origin
|
|
14
|
+
* (`https://registry.modelcontextprotocol.io`) as its audience, for a
|
|
15
|
+
* registry token that lasts minutes. `POST /v0.1/auth/github-at` does the
|
|
16
|
+
* same for a GitHub token (`{ "github_token": ... }`).
|
|
17
|
+
* - `GET /v0.1/servers/{name}/versions/{version}` says whether a version is
|
|
18
|
+
* already published.
|
|
19
|
+
* - `POST /v0.1/publish` with the `server.json` as the body and the registry
|
|
20
|
+
* token as a bearer credential publishes it.
|
|
21
|
+
*
|
|
22
|
+
* The registry has no draft and refuses a version it already holds, and it
|
|
23
|
+
* does not let a version be replaced. So the stage sends nothing: it checks
|
|
24
|
+
* the `server.json` against the release, exchanges for a token to prove the
|
|
25
|
+
* credentials work, and reads whether the version is there. The reveal
|
|
26
|
+
* publishes.
|
|
27
|
+
*
|
|
28
|
+
* The `server.json` must belong to this release: its `version` is the
|
|
29
|
+
* release's label (from its first digit), and each package that names a
|
|
30
|
+
* version, and each OCI image's tag, is the same. Anything else is refused in
|
|
31
|
+
* the plan (`publish-mcp-registry-version-mismatch`,
|
|
32
|
+
* `publish-mcp-registry-package-mismatch`), so a release can't publish a
|
|
33
|
+
* listing for another version. `release.version.files` stamps the label into
|
|
34
|
+
* the file.
|
|
35
|
+
*/
|
|
36
|
+
import { readFileSync } from "node:fs";
|
|
37
|
+
import { NEXT_RELEASE } from "../release-floors.js";
|
|
38
|
+
import { readCredential } from "./publish-credentials.js";
|
|
39
|
+
import { releaseVersion } from "./publish-homebrew.js";
|
|
40
|
+
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
41
|
+
import { trainName, waitUntilServed } from "./publish-train-names.js";
|
|
42
|
+
import { PublishTargetError } from "./release-publish.js";
|
|
43
|
+
/** The first chant with the `mcp-registry` publish target: a `server.json` published to the MCP Registry after the packages it names, with GitHub OIDC, and the `mcp-registry-*` checks of `chant release doctor` (#5162). */
|
|
44
|
+
export const PUBLISH_MCP_REGISTRY_FLOOR = NEXT_RELEASE;
|
|
45
|
+
export const MCP_REGISTRY = "https://registry.modelcontextprotocol.io";
|
|
46
|
+
/** The variable a `github-token` target reads by default. */
|
|
47
|
+
export const MCP_GITHUB_TOKEN_ENV = "MCP_GITHUB_TOKEN";
|
|
48
|
+
/** The variable a `registry-token` target reads by default. */
|
|
49
|
+
export const MCP_REGISTRY_TOKEN_ENV = "MCP_REGISTRY_TOKEN";
|
|
50
|
+
/** The declaration's `auth`, refused when `tokenEnv` is set beside the OIDC exchange, which reads none. */
|
|
51
|
+
export function mcpRegistryAuth(decl) {
|
|
52
|
+
const auth = decl.auth ?? "github-oidc";
|
|
53
|
+
if (auth === "github-oidc" && decl.tokenEnv !== undefined) {
|
|
54
|
+
throw new PublishTargetError("publish-mcp-registry-auth-invalid", "tokenEnv names a token, and auth: github-oidc reads none", "Leave tokenEnv out, or set auth to github-token or registry-token in release.publish.");
|
|
55
|
+
}
|
|
56
|
+
return auth;
|
|
57
|
+
}
|
|
58
|
+
/** The variables the target's credential is read from, whose values are masked. */
|
|
59
|
+
export function mcpRegistryTokenEnv(decl) {
|
|
60
|
+
const auth = decl.auth ?? "github-oidc";
|
|
61
|
+
if (auth === "github-oidc")
|
|
62
|
+
return ["ACTIONS_ID_TOKEN_REQUEST_TOKEN"];
|
|
63
|
+
return [decl.tokenEnv ?? (auth === "github-token" ? MCP_GITHUB_TOKEN_ENV : MCP_REGISTRY_TOKEN_ENV)];
|
|
64
|
+
}
|
|
65
|
+
/** The registry's origin, which is the audience of the OIDC token: scheme and lowercased host. */
|
|
66
|
+
export function mcpRegistryAudience(registry) {
|
|
67
|
+
const u = new URL(registry);
|
|
68
|
+
return `${u.protocol}//${u.host.toLowerCase()}`;
|
|
69
|
+
}
|
|
70
|
+
/** The tag of an OCI image reference, `null` for one with a digest or no tag. */
|
|
71
|
+
function ociTag(identifier) {
|
|
72
|
+
if (identifier.includes("@"))
|
|
73
|
+
return null;
|
|
74
|
+
const last = identifier.slice(identifier.lastIndexOf("/") + 1);
|
|
75
|
+
const colon = last.indexOf(":");
|
|
76
|
+
return colon < 0 ? "" : last.slice(colon + 1);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Read `text` as a `server.json` and check it is the release's: `label` is
|
|
80
|
+
* the release's label. Throws {@link PublishTargetError}.
|
|
81
|
+
*/
|
|
82
|
+
export function checkServerJson(text, path, label) {
|
|
83
|
+
let raw;
|
|
84
|
+
try {
|
|
85
|
+
raw = JSON.parse(text);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
throw new PublishTargetError("publish-mcp-registry-server-invalid", `${path} is not JSON: ${err instanceof Error ? err.message : String(err)}`, "Fix the file, or check it with: mcp-publisher validate");
|
|
89
|
+
}
|
|
90
|
+
const o = raw;
|
|
91
|
+
if (typeof raw !== "object" || raw === null || typeof o.name !== "string" || !o.name || typeof o.version !== "string" || !o.version) {
|
|
92
|
+
throw new PublishTargetError("publish-mcp-registry-server-invalid", `${path} needs a name and a version`, "A server.json names the server as io.github.<owner>/<name> or <reversed domain>/<name>.");
|
|
93
|
+
}
|
|
94
|
+
if (o.packages !== undefined && !Array.isArray(o.packages)) {
|
|
95
|
+
throw new PublishTargetError("publish-mcp-registry-server-invalid", `${path}'s packages is not a list`);
|
|
96
|
+
}
|
|
97
|
+
const version = releaseVersion(label);
|
|
98
|
+
if (label === null || version === null) {
|
|
99
|
+
throw new PublishTargetError("publish-mcp-registry-version-mismatch", `${path} can't be matched to this release: it has no label with a version in it`, "Cut the release with a label such as 1.4.0.");
|
|
100
|
+
}
|
|
101
|
+
const fix = `Stamp the label into the file with release.version.files in chant.config.ts, or set the version to ${version}.`;
|
|
102
|
+
if (o.version !== version && o.version !== label) {
|
|
103
|
+
throw new PublishTargetError("publish-mcp-registry-version-mismatch", `${path} has version ${o.version}, and this release is ${label}`, fix);
|
|
104
|
+
}
|
|
105
|
+
const packages = (o.packages ?? []).map((p) => (typeof p === "object" && p !== null ? p : {}));
|
|
106
|
+
packages.forEach((p, i) => {
|
|
107
|
+
const where = `${path}'s packages[${i}]${p.identifier ? ` (${p.identifier})` : ""}`;
|
|
108
|
+
if (p.registryType === "oci") {
|
|
109
|
+
const tag = typeof p.identifier === "string" ? ociTag(p.identifier) : null;
|
|
110
|
+
if (typeof p.identifier === "string" && tag !== null && tag !== version && tag !== label) {
|
|
111
|
+
throw new PublishTargetError("publish-mcp-registry-package-mismatch", `${where} names the tag ${tag || "(none)"}, and this release is ${label}`, `Name the image as <image>:${version}, or by digest.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (p.registryType === "mcpb") {
|
|
115
|
+
// An mcpb package is a file at a URL; its version, when it has one, is checked below.
|
|
116
|
+
if (p.version !== undefined && p.version !== version && p.version !== label) {
|
|
117
|
+
throw new PublishTargetError("publish-mcp-registry-package-mismatch", `${where} has version ${p.version}, and this release is ${label}`, fix);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (p.version !== version && p.version !== label) {
|
|
121
|
+
throw new PublishTargetError("publish-mcp-registry-package-mismatch", `${where} has version ${p.version ?? "(none)"}, and this release is ${label}`, fix);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return { name: o.name, version: o.version, packages };
|
|
125
|
+
}
|
|
126
|
+
const packageKey = (p) => `${p.registryType ?? ""}:${p.identifier ?? ""}:${p.version ?? ""}`;
|
|
127
|
+
export function mcpRegistryTarget(decl, deps) {
|
|
128
|
+
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
129
|
+
const auth = mcpRegistryAuth(decl);
|
|
130
|
+
const tokenNames = mcpRegistryTokenEnv(decl);
|
|
131
|
+
const path = decl.server ?? "server.json";
|
|
132
|
+
const registry = (decl.registry ?? MCP_REGISTRY).replace(/\/+$/, "");
|
|
133
|
+
const setup = (ctx) => {
|
|
134
|
+
const abs = memberFile(ctx.cwd, path);
|
|
135
|
+
const bytes = readFileSync(abs);
|
|
136
|
+
const digest = bytesDigest(new Uint8Array(bytes));
|
|
137
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, path, [digest]);
|
|
138
|
+
const server = checkServerJson(bytes.toString("utf-8"), path, ctx.label);
|
|
139
|
+
let token = null;
|
|
140
|
+
if (auth === "github-oidc") {
|
|
141
|
+
if (!(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL && ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)) {
|
|
142
|
+
throw new PublishTargetError("publish-credentials-missing", "the MCP Registry target publishes with GitHub OIDC, and this run has no OIDC token: not a GitHub Actions job with id-token: write", "Give the job permissions: id-token: write, or set auth to github-token or registry-token.");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
token = readCredential(ctx.env, tokenNames, ctx.redactor);
|
|
147
|
+
if (!token) {
|
|
148
|
+
throw new PublishTargetError("publish-credentials-missing", `the MCP Registry target reads its token from ${tokenNames[0]}, and it is not set`, `Set ${tokenNames[0]} in the job's or the shell's environment.`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const item = { name: `${server.name}@${server.version}`, destination: `${registry}/v0.1/servers/${encodeURIComponent(server.name)}/versions/${encodeURIComponent(server.version)}`, digest };
|
|
152
|
+
return { bytes, server, token, item };
|
|
153
|
+
};
|
|
154
|
+
const call = async (url, init) => {
|
|
155
|
+
const res = await fetchImpl(url, { ...init, headers: { "user-agent": "chant", accept: "application/json", ...init.headers } });
|
|
156
|
+
const text = await res.text().catch(() => "");
|
|
157
|
+
let json = null;
|
|
158
|
+
try {
|
|
159
|
+
json = text ? JSON.parse(text) : null;
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
json = null;
|
|
163
|
+
}
|
|
164
|
+
return { status: res.status, text, json };
|
|
165
|
+
};
|
|
166
|
+
const why = (ctx, r) => {
|
|
167
|
+
const j = r.json;
|
|
168
|
+
const said = typeof j?.detail === "string" ? j.detail : typeof j?.title === "string" ? j.title : r.text.slice(0, 300);
|
|
169
|
+
return ctx.redactor.redact(`it answered ${r.status}${said ? `: ${said}` : ""}`);
|
|
170
|
+
};
|
|
171
|
+
/** The OIDC token for the registry's origin, from GitHub Actions' token service. */
|
|
172
|
+
const oidcToken = async (ctx) => {
|
|
173
|
+
const url = new URL(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL ?? "");
|
|
174
|
+
url.searchParams.set("audience", mcpRegistryAudience(registry));
|
|
175
|
+
const res = await call(url.toString(), { method: "GET", headers: { authorization: `Bearer ${ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN ?? ""}` } });
|
|
176
|
+
const value = res.json?.value;
|
|
177
|
+
if (res.status !== 200 || typeof value !== "string" || !value) {
|
|
178
|
+
throw new PublishTargetError("publish-mcp-registry-auth", ctx.redactor.redact(`GitHub Actions gave no OIDC token for ${mcpRegistryAudience(registry)}: it answered ${res.status}`), "Give the job permissions: id-token: write.");
|
|
179
|
+
}
|
|
180
|
+
ctx.redactor.add(value);
|
|
181
|
+
return value;
|
|
182
|
+
};
|
|
183
|
+
/** A registry token: exchanged for the OIDC or GitHub token, or the one the variable holds. It lasts minutes, so each step gets its own. */
|
|
184
|
+
const registryToken = async (ctx, token) => {
|
|
185
|
+
if (auth === "registry-token")
|
|
186
|
+
return token.value;
|
|
187
|
+
const exchange = auth === "github-oidc"
|
|
188
|
+
? { path: "/v0.1/auth/github-oidc", body: { oidc_token: await oidcToken(ctx) } }
|
|
189
|
+
: { path: "/v0.1/auth/github-at", body: { github_token: token.value } };
|
|
190
|
+
const res = await call(`${registry}${exchange.path}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(exchange.body) });
|
|
191
|
+
const value = res.json?.registry_token;
|
|
192
|
+
if (res.status !== 200 || typeof value !== "string" || !value) {
|
|
193
|
+
throw new PublishTargetError("publish-mcp-registry-auth", `the MCP Registry at ${registry} gave no registry token: ${why(ctx, res)}`, auth === "github-oidc" ? "The registry takes a GitHub Actions run as the owner of io.github.<owner>/*. Name the server io.github.<owner>/<name> for the repository's owner." : "Check the token, and that its owner may publish the server's namespace.");
|
|
194
|
+
}
|
|
195
|
+
ctx.redactor.add(value);
|
|
196
|
+
return value;
|
|
197
|
+
};
|
|
198
|
+
/** The packages the registry holds for the version, or null when it holds none. */
|
|
199
|
+
const served = async (ctx, server) => {
|
|
200
|
+
const res = await call(`${registry}/v0.1/servers/${encodeURIComponent(server.name)}/versions/${encodeURIComponent(server.version)}`, { method: "GET", headers: {} });
|
|
201
|
+
if (res.status === 404)
|
|
202
|
+
return null;
|
|
203
|
+
if (res.status !== 200)
|
|
204
|
+
throw new PublishTargetError("publish-mcp-registry-failed", `reading ${server.name}@${server.version} on the MCP Registry: ${why(ctx, res)}`);
|
|
205
|
+
const held = res.json?.server?.packages;
|
|
206
|
+
return (Array.isArray(held) ? held : []).map(packageKey).sort();
|
|
207
|
+
};
|
|
208
|
+
const target = {
|
|
209
|
+
kind: "mcp-registry",
|
|
210
|
+
name: `mcp-registry ${path}`,
|
|
211
|
+
destination: registry,
|
|
212
|
+
credentialEnv: tokenNames,
|
|
213
|
+
key: publishTargetKey(decl),
|
|
214
|
+
// Its stage sends nothing (the registry has no draft), so the verify commands can't see it.
|
|
215
|
+
uploadsAtReveal: true,
|
|
216
|
+
revealsLast: true,
|
|
217
|
+
/** #5165: the server, and each package its `server.json` lists: npm, PyPI, Cargo, NuGet, and OCI images. */
|
|
218
|
+
async names(ctx) {
|
|
219
|
+
const raw = JSON.parse(readFileSync(memberFile(ctx.cwd, path), "utf-8"));
|
|
220
|
+
const needs = new Set();
|
|
221
|
+
for (const p of Array.isArray(raw.packages) ? raw.packages : []) {
|
|
222
|
+
if (typeof p?.identifier !== "string" || !p.identifier)
|
|
223
|
+
continue;
|
|
224
|
+
if (p.registryType === "npm")
|
|
225
|
+
needs.add(trainName("npm", p.identifier));
|
|
226
|
+
else if (p.registryType === "pypi")
|
|
227
|
+
needs.add(trainName("pypi", p.identifier));
|
|
228
|
+
else if (p.registryType === "oci")
|
|
229
|
+
needs.add(trainName("oci", p.identifier));
|
|
230
|
+
else if (p.registryType === "cargo")
|
|
231
|
+
needs.add(trainName("cargo", p.identifier));
|
|
232
|
+
else if (p.registryType === "nuget")
|
|
233
|
+
needs.add(`nuget:${p.identifier.toLowerCase()}`);
|
|
234
|
+
}
|
|
235
|
+
return { provides: typeof raw.name === "string" ? [trainName("mcp", raw.name)] : [], needs: [...needs] };
|
|
236
|
+
},
|
|
237
|
+
/** #5165: whether the registry holds the release's version of the server `server.json` names. */
|
|
238
|
+
async published(ctx) {
|
|
239
|
+
const raw = JSON.parse(readFileSync(memberFile(ctx.cwd, path), "utf-8"));
|
|
240
|
+
const version = releaseVersion(ctx.label);
|
|
241
|
+
if (typeof raw.name !== "string" || !version)
|
|
242
|
+
return null;
|
|
243
|
+
return (await served(ctx, { name: raw.name, version, packages: [] })) !== null;
|
|
244
|
+
},
|
|
245
|
+
/** #5165: wait until the registry serves the version the reveal published. */
|
|
246
|
+
async visible(ctx, published) {
|
|
247
|
+
const ids = published.items.map((i) => /^(.+)@([^@]+)$/.exec(i.name)).filter((m) => m !== null);
|
|
248
|
+
if (ids.length === 0)
|
|
249
|
+
return;
|
|
250
|
+
await waitUntilServed(ctx, deps, {
|
|
251
|
+
what: "the MCP Registry",
|
|
252
|
+
code: "publish-mcp-registry-not-served",
|
|
253
|
+
check: async () => {
|
|
254
|
+
const missing = [];
|
|
255
|
+
for (const m of ids)
|
|
256
|
+
if ((await served(ctx, { name: m[1], version: m[2], packages: [] })) === null)
|
|
257
|
+
missing.push(m[0]);
|
|
258
|
+
return missing;
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
async plan(ctx) {
|
|
263
|
+
return [setup(ctx).item];
|
|
264
|
+
},
|
|
265
|
+
async stage(ctx) {
|
|
266
|
+
const { server, token, item } = setup(ctx);
|
|
267
|
+
if (token)
|
|
268
|
+
ctx.log(`using the token from ${token.from}`);
|
|
269
|
+
await registryToken(ctx, token);
|
|
270
|
+
ctx.log(`the MCP Registry at ${registry} takes the credentials for ${server.name}; the reveal asks for a new token, since one lasts minutes`);
|
|
271
|
+
const held = await served(ctx, server);
|
|
272
|
+
if (held === null) {
|
|
273
|
+
ctx.log(`${item.name} is not on the MCP Registry yet; it is published at the reveal, after the targets that publish its packages`);
|
|
274
|
+
return { target: target.name, destination: target.destination, items: [item], state: {} };
|
|
275
|
+
}
|
|
276
|
+
const mine = server.packages.map(packageKey).sort();
|
|
277
|
+
if (held.join("\n") !== mine.join("\n")) {
|
|
278
|
+
throw new PublishTargetError("publish-mcp-registry-version-exists", `the MCP Registry already has ${item.name} with other packages than ${path} names`, "A registry version can't be replaced: cut a release with a new version.");
|
|
279
|
+
}
|
|
280
|
+
ctx.log(`${item.name} is already on the MCP Registry with the same packages`);
|
|
281
|
+
return { target: target.name, destination: target.destination, items: [{ ...item, present: true }], state: { present: "true" } };
|
|
282
|
+
},
|
|
283
|
+
async reveal(ctx, staged) {
|
|
284
|
+
const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
|
|
285
|
+
if (staged.state.present === "true")
|
|
286
|
+
return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
|
|
287
|
+
const { bytes, server, token, item } = setup(ctx);
|
|
288
|
+
// After an upload whose record was lost the version is there already: check it rather than send it twice.
|
|
289
|
+
if ((await served(ctx, server)) !== null) {
|
|
290
|
+
ctx.log(`${item.name} is already on the MCP Registry`);
|
|
291
|
+
return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
|
|
292
|
+
}
|
|
293
|
+
const bearer = await registryToken(ctx, token);
|
|
294
|
+
ctx.log(`publishing ${item.name} to the MCP Registry`);
|
|
295
|
+
const res = await call(`${registry}/v0.1/publish`, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${bearer}` }, body: bytes.toString("utf-8") });
|
|
296
|
+
if (res.status < 200 || res.status > 299) {
|
|
297
|
+
throw new PublishTargetError("publish-mcp-registry-failed", `publishing ${item.name} to the MCP Registry: ${why(ctx, res)}`, res.status === 401 || res.status === 403 ? `The token does not cover the namespace of ${server.name}. With GitHub OIDC the name must be io.github.<owner>/<name> for the repository's owner.` : undefined);
|
|
298
|
+
}
|
|
299
|
+
if ((await served(ctx, server)) === null) {
|
|
300
|
+
throw new PublishTargetError("publish-mcp-registry-not-served", `the MCP Registry accepted ${item.name} and does not serve it`);
|
|
301
|
+
}
|
|
302
|
+
return { target: target.name, destination: target.destination, items };
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
return target;
|
|
306
|
+
}
|