@mmerterden/multi-agent-pipeline 24.1.1 → 24.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,256 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/version-report.schema.json",
4
+ "title": "Version report",
5
+ "description": "What `version-report.mjs --json` emits: the version of each separately published part of the ecosystem, how it compares with upstream, and the two dates that answer \"how fresh is this\". Every field is always present; null means not known or not applicable here. Added in contract 1.0.0.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "contractVersion",
10
+ "generatedAt",
11
+ "network",
12
+ "overall",
13
+ "newestRelease",
14
+ "pipeline",
15
+ "toolkit",
16
+ "plugins",
17
+ "findings"
18
+ ],
19
+ "properties": {
20
+ "contractVersion": { "$ref": "#/$defs/contractVersion" },
21
+ "generatedAt": { "type": "string", "format": "date-time" },
22
+ "network": {
23
+ "type": "object",
24
+ "description": "Whether upstream was read in this run. `current` is never reported without it.",
25
+ "additionalProperties": false,
26
+ "required": ["attempted", "reached", "reason"],
27
+ "properties": {
28
+ "attempted": { "type": "boolean" },
29
+ "reached": { "type": "boolean" },
30
+ "reason": { "$ref": "#/$defs/reason" }
31
+ }
32
+ },
33
+ "overall": { "$ref": "#/$defs/verdict" },
34
+ "newestRelease": {
35
+ "type": "object",
36
+ "description": "The most recently published release among the parts in use, over known dates only.",
37
+ "additionalProperties": false,
38
+ "required": ["part", "version", "releasedAt", "complete", "missing"],
39
+ "properties": {
40
+ "part": { "oneOf": [{ "$ref": "#/$defs/part" }, { "type": "null" }] },
41
+ "version": { "type": ["string", "null"] },
42
+ "releasedAt": { "$ref": "#/$defs/timestamp" },
43
+ "complete": {
44
+ "type": "boolean",
45
+ "description": "True when every part contributed a date, so nothing newer can be hiding in a part that was not dated."
46
+ },
47
+ "missing": { "type": "array", "items": { "$ref": "#/$defs/part" } }
48
+ }
49
+ },
50
+ "pipeline": {
51
+ "type": "object",
52
+ "additionalProperties": false,
53
+ "required": [
54
+ "hostId",
55
+ "version",
56
+ "releasedAt",
57
+ "installedAt",
58
+ "latest",
59
+ "latestReleasedAt",
60
+ "required",
61
+ "verdict",
62
+ "reason",
63
+ "hosts"
64
+ ],
65
+ "properties": {
66
+ "hostId": {
67
+ "type": ["string", "null"],
68
+ "description": "The host whose install the version, date and verdict describe: the invoking one when it carries a stamp, otherwise the first installed host in registry order."
69
+ },
70
+ "version": {
71
+ "type": ["string", "null"],
72
+ "description": "The version that host records."
73
+ },
74
+ "releasedAt": { "$ref": "#/$defs/timestamp" },
75
+ "installedAt": { "$ref": "#/$defs/timestamp" },
76
+ "latest": { "type": ["string", "null"] },
77
+ "latestReleasedAt": { "$ref": "#/$defs/timestamp" },
78
+ "required": {
79
+ "type": ["string", "null"],
80
+ "description": "The supported-version floor from the registry's `required` dist-tag, absent on most releases."
81
+ },
82
+ "verdict": { "$ref": "#/$defs/verdict" },
83
+ "reason": { "$ref": "#/$defs/reason" },
84
+ "hosts": {
85
+ "type": "array",
86
+ "description": "Every host in the registry, whether the pipeline is installed in it and at what version.",
87
+ "items": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "required": ["id", "name", "state", "version", "installedAt", "builtAgainstToolkit"],
91
+ "properties": {
92
+ "id": { "type": "string" },
93
+ "name": { "type": "string" },
94
+ "state": {
95
+ "description": "installed (a readable version stamp), no-marker (a stamp that does not read as a version), absent (no stamp: the host CLI may be installed, the pipeline is not).",
96
+ "enum": ["installed", "no-marker", "absent"]
97
+ },
98
+ "version": { "type": ["string", "null"] },
99
+ "installedAt": { "$ref": "#/$defs/timestamp" },
100
+ "builtAgainstToolkit": { "type": ["string", "null"] }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ },
106
+ "toolkit": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "required": [
110
+ "registered",
111
+ "spec",
112
+ "resolvedVersion",
113
+ "releasedAt",
114
+ "installedAt",
115
+ "builtAgainst",
116
+ "latest",
117
+ "latestReleasedAt",
118
+ "required",
119
+ "otherCopies",
120
+ "verdict",
121
+ "reason"
122
+ ],
123
+ "properties": {
124
+ "registered": { "type": "boolean" },
125
+ "spec": {
126
+ "type": ["string", "null"],
127
+ "description": "The package spec the registration asks for, e.g. `@scope/pkg@latest`. Null when it names a script instead."
128
+ },
129
+ "resolvedVersion": {
130
+ "type": ["string", "null"],
131
+ "description": "The version the host would run, never a claim about a server already running."
132
+ },
133
+ "releasedAt": { "$ref": "#/$defs/timestamp" },
134
+ "installedAt": { "$ref": "#/$defs/timestamp" },
135
+ "builtAgainst": {
136
+ "type": ["string", "null"],
137
+ "description": "The toolkit version this pipeline release was built against."
138
+ },
139
+ "latest": { "type": ["string", "null"] },
140
+ "latestReleasedAt": { "$ref": "#/$defs/timestamp" },
141
+ "required": { "type": ["string", "null"] },
142
+ "otherCopies": {
143
+ "type": "array",
144
+ "description": "Further copies npm cached for the same spec, newest first after the one in use.",
145
+ "items": {
146
+ "type": "object",
147
+ "additionalProperties": false,
148
+ "required": ["version", "installedAt"],
149
+ "properties": {
150
+ "version": { "type": ["string", "null"] },
151
+ "installedAt": { "$ref": "#/$defs/timestamp" }
152
+ }
153
+ }
154
+ },
155
+ "verdict": { "$ref": "#/$defs/verdict" },
156
+ "reason": { "$ref": "#/$defs/reason" }
157
+ }
158
+ },
159
+ "plugins": {
160
+ "type": "object",
161
+ "additionalProperties": false,
162
+ "required": ["marketplace", "verdict", "reason", "items"],
163
+ "properties": {
164
+ "marketplace": {
165
+ "type": "object",
166
+ "additionalProperties": false,
167
+ "required": ["present", "commit", "releasedAt", "installedAt", "remoteCommit"],
168
+ "properties": {
169
+ "present": { "type": "boolean" },
170
+ "commit": { "$ref": "#/$defs/shortCommit" },
171
+ "releasedAt": { "$ref": "#/$defs/timestamp" },
172
+ "installedAt": { "$ref": "#/$defs/timestamp" },
173
+ "remoteCommit": { "$ref": "#/$defs/shortCommit" }
174
+ }
175
+ },
176
+ "verdict": { "$ref": "#/$defs/verdict" },
177
+ "reason": { "$ref": "#/$defs/reason" },
178
+ "items": {
179
+ "type": "array",
180
+ "items": {
181
+ "type": "object",
182
+ "additionalProperties": false,
183
+ "required": [
184
+ "name",
185
+ "catalogVersion",
186
+ "installedVersion",
187
+ "installedCommit",
188
+ "installedAt",
189
+ "enabledHere",
190
+ "state"
191
+ ],
192
+ "properties": {
193
+ "name": { "type": "string" },
194
+ "catalogVersion": { "type": ["string", "null"] },
195
+ "installedVersion": { "type": ["string", "null"] },
196
+ "installedCommit": { "$ref": "#/$defs/shortCommit" },
197
+ "installedAt": { "$ref": "#/$defs/timestamp" },
198
+ "enabledHere": { "type": "boolean" },
199
+ "state": { "enum": ["installed", "not-installed", "not-in-catalog"] }
200
+ }
201
+ }
202
+ }
203
+ }
204
+ },
205
+ "findings": {
206
+ "type": "array",
207
+ "description": "Local-against-local observations. A verdict only ever compares local with upstream, so drift is reported here instead of borrowing a verdict word.",
208
+ "items": {
209
+ "type": "object",
210
+ "additionalProperties": false,
211
+ "required": ["code", "subject"],
212
+ "properties": {
213
+ "code": {
214
+ "enum": [
215
+ "host-version-mismatch",
216
+ "host-marker-unreadable",
217
+ "toolkit-older-than-built-against",
218
+ "toolkit-multiple-copies",
219
+ "toolkit-spec-pinned",
220
+ "plugin-enabled-not-installed",
221
+ "plugin-enabled-not-in-catalog",
222
+ "plugin-install-differs-from-catalog",
223
+ "version-not-in-registry"
224
+ ]
225
+ },
226
+ "subject": { "type": ["string", "null"] }
227
+ }
228
+ }
229
+ }
230
+ },
231
+ "$defs": {
232
+ "contractVersion": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" },
233
+ "timestamp": { "type": ["string", "null"], "format": "date-time" },
234
+ "shortCommit": { "type": ["string", "null"], "pattern": "^[0-9a-f]{7}$" },
235
+ "part": { "enum": ["pipeline", "toolkit", "plugins"] },
236
+ "verdict": {
237
+ "description": "Local against upstream, one meaning each: current (upstream read in this run and local equals latest), behind (local is lower), below-floor (behind, and under the required floor), ahead (local is higher), unknown (local exists, the comparison did not happen), absent (nothing local to compare).",
238
+ "enum": ["current", "behind", "below-floor", "ahead", "unknown", "absent"]
239
+ },
240
+ "reason": {
241
+ "type": ["string", "null"],
242
+ "enum": [
243
+ "offline-flag",
244
+ "timeout",
245
+ "dns",
246
+ "http-error",
247
+ "malformed",
248
+ "not-installed",
249
+ "not-registered",
250
+ "unreadable",
251
+ "remote-unreachable",
252
+ null
253
+ ]
254
+ }
255
+ }
256
+ }
@@ -27,7 +27,7 @@
27
27
  //
28
28
  // Exit: 0 sent (or dry run), 1 nothing to send / rejected, 2 usage error.
29
29
 
30
- import { readFileSync, existsSync } from "node:fs";
30
+ import { readFileSync } from "node:fs";
31
31
  import { homedir } from "node:os";
32
32
  import { join } from "node:path";
33
33
  import { hostCommand } from "../lib/user-facing.mjs";
@@ -37,6 +37,7 @@ import { nowMinute, releaseVersion } from "../lib/usage-vocab.mjs";
37
37
  import { postJson } from "./_http-post.mjs";
38
38
  import { registerUrlAllowed } from "../lib/usage-endpoint.mjs";
39
39
  import { resolveUsageToken } from "../lib/usage-token.mjs";
40
+ import { HOST_IDS, hostRoot, installedHostIds } from "../lib/host.mjs";
40
41
 
41
42
  exitOnHelp(import.meta.url);
42
43
 
@@ -55,13 +56,11 @@ function readPrefs() {
55
56
  }
56
57
 
57
58
  function packageVersion() {
58
- for (const p of [
59
- join(homedir(), ".claude", ".pipeline-version"),
60
- join(homedir(), ".copilot", ".pipeline-version"),
61
- join(homedir(), ".codex", ".pipeline-version"),
62
- ]) {
59
+ for (const id of HOST_IDS) {
63
60
  try {
64
- const v = releaseVersion(readFileSync(p, "utf-8"));
61
+ const v = releaseVersion(
62
+ readFileSync(join(hostRoot(homedir(), id), ".pipeline-version"), "utf-8"),
63
+ );
65
64
  if (v) return v;
66
65
  } catch {
67
66
  /* try the next host */
@@ -73,10 +72,7 @@ function packageVersion() {
73
72
  // Which CLI the person is running. Useful because a report that only reproduces
74
73
  // on one host is a different bug from one that reproduces everywhere.
75
74
  function host() {
76
- if (existsSync(join(homedir(), ".claude", ".pipeline-version"))) return "claude";
77
- if (existsSync(join(homedir(), ".copilot", ".pipeline-version"))) return "copilot";
78
- if (existsSync(join(homedir(), ".codex", ".pipeline-version"))) return "codex";
79
- return "unknown";
75
+ return installedHostIds(homedir())[0] ?? "unknown";
80
76
  }
81
77
 
82
78
  // The endpoint is passed in because it is the destination the token is about to
@@ -62,7 +62,8 @@ import { readRotatedText, rotatedExists } from "../lib/rotated-log.mjs";
62
62
  import { prefsPath as sharedPrefsPath } from "../lib/prefs-value.mjs";
63
63
  import { exitOnHelp } from "../lib/cli-help.mjs";
64
64
  import { parseArgs as parseArgv } from "../lib/args.mjs";
65
- import { MCP_SERVER_ID } from "../lib/mcp-rename.mjs";
65
+ import { HOST_IDS, host as hostEntry, hostRoot } from "../lib/host.mjs";
66
+ import { isToolkitDir, mcpRegistration, newestNpxCopy } from "../lib/toolkit-install.mjs";
66
67
 
67
68
  exitOnHelp(import.meta.url);
68
69
 
@@ -82,7 +83,6 @@ const TITLES = Object.fromEntries(SECTION_IDS.map((id) => [id, HEALTH_MESSAGES.e
82
83
  export const LANGUAGES = Object.keys(HEALTH_MESSAGES);
83
84
  const RANK = { green: 0, yellow: 1, red: 2 };
84
85
  const HERE = dirname(fileURLToPath(import.meta.url));
85
- const TOOLKIT_PACKAGE = "@mmerterden/multi-agent-mcp";
86
86
  const NAME = /^[a-z][a-z0-9_]{0,60}$/;
87
87
  const CHECK_ID = /^[a-z0-9][a-z0-9-]{0,60}$/;
88
88
  const TAG = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,79}$/;
@@ -199,46 +199,7 @@ export function servicesSection(inv) {
199
199
  // ---------------------------------------------------------------------------
200
200
  // toolkit
201
201
 
202
- function registration(home) {
203
- for (const file of [join(home, ".claude.json"), join(home, ".claude", "settings.json")]) {
204
- const json = readJson(file);
205
- if (!json) continue;
206
- const pools = [
207
- json.mcpServers,
208
- ...Object.values(json.projects ?? {}).map((p) => p?.mcpServers),
209
- ];
210
- for (const pool of pools) {
211
- for (const [name, cfg] of Object.entries(pool ?? {})) {
212
- if (name === MCP_SERVER_ID && cfg && typeof cfg === "object") return cfg;
213
- }
214
- }
215
- }
216
- return null;
217
- }
218
-
219
- const isToolkitDir = (d) => readJson(join(d, "package.json"))?.name === TOOLKIT_PACKAGE;
220
-
221
202
  /** The newest toolkit copy npx cached, by its package.json mtime. */
222
- function newestNpxCopy(home) {
223
- const cache = join(home, ".npm", "_npx");
224
- let best = null;
225
- let names;
226
- try {
227
- names = readdirSync(cache);
228
- } catch {
229
- return null;
230
- }
231
- for (const n of names) {
232
- const d = join(cache, n, "node_modules", ...TOOLKIT_PACKAGE.split("/"));
233
- try {
234
- const m = statSync(join(d, "package.json")).mtimeMs;
235
- if (isToolkitDir(d) && (!best || m > best.m)) best = { d, m };
236
- } catch {
237
- /* not this one */
238
- }
239
- }
240
- return best?.d ?? null;
241
- }
242
203
 
243
204
  function devToolkitPath(env, home) {
244
205
  const dt = readJson(prefsPath(env))?.global?.devToolkit;
@@ -317,7 +278,7 @@ export async function toolkitInfo({
317
278
  probe = false,
318
279
  timeoutMs = PROBE_TIMEOUT_MS,
319
280
  } = {}) {
320
- const reg = registration(home);
281
+ const reg = mcpRegistration(home);
321
282
  let dir = null;
322
283
  let source = null;
323
284
  if (reg) {
@@ -389,39 +350,55 @@ export function toolkitSection(info) {
389
350
  // ---------------------------------------------------------------------------
390
351
  // install
391
352
 
392
- /** The pipeline version each host directory records, null where none. */
353
+ /**
354
+ * The pipeline version each host records, null where none. Keyed by host id in
355
+ * registry order, so a host added to `schemas/hosts.json` is read here without
356
+ * another list to keep in step.
357
+ */
393
358
  export function hostVersions(home) {
394
- const read = (dir) => {
359
+ const read = (id) => {
395
360
  try {
396
- const v = readFileSync(join(home, dir, ".pipeline-version"), "utf8").trim();
361
+ const v = readFileSync(join(hostRoot(home, id), ".pipeline-version"), "utf8").trim();
397
362
  return VERSION.test(v) ? v : null;
398
363
  } catch {
399
364
  return null;
400
365
  }
401
366
  };
402
- return { claude: read(".claude"), copilot: read(".copilot"), codex: read(".codex") };
367
+ return Object.fromEntries(HOST_IDS.map((id) => [id, read(id)]));
368
+ }
369
+
370
+ /** The registry's name for a host id, the id itself when the registry has none. */
371
+ function hostLabel(id) {
372
+ return hostEntry(id)?.label ?? id;
403
373
  }
404
374
 
405
375
  export function installSection({ versions, doctor }) {
406
376
  const statuses = [];
407
377
  const parts = [];
408
378
  const decisive = [];
409
- if (!versions.claude) {
379
+ // Any host carrying a stamp is an install: a machine with only Copilot CLI or
380
+ // only the local host is installed, and the first stamped host in registry
381
+ // order is the one the other versions are compared against.
382
+ const installed = Object.keys(versions).filter((h) => versions[h]);
383
+ const primary = installed[0];
384
+ if (!primary) {
410
385
  statuses.push("red");
411
386
  parts.push(msg("install.none"));
412
387
  decisive.push(["red", "install.none"]);
413
388
  } else {
414
- const others = ["copilot", "codex"].filter((h) => versions[h]);
415
- const behind = others.filter((h) => versions[h] !== versions.claude);
416
- const hosts = others.map((h) => msg("install.hostVersion", { host: h, version: versions[h] }));
389
+ const others = installed.slice(1);
390
+ const behind = others.filter((h) => versions[h] !== versions[primary]);
391
+ const hosts = others.map((h) =>
392
+ msg("install.hostVersion", { host: hostLabel(h), version: versions[h] }),
393
+ );
417
394
  parts.push(
418
395
  others.length
419
- ? msg("install.versions", { version: versions.claude, hosts })
420
- : msg("install.version", { version: versions.claude }),
396
+ ? msg("install.versions", { version: versions[primary], hosts })
397
+ : msg("install.version", { version: versions[primary] }),
421
398
  );
422
399
  if (behind.length) {
423
400
  statuses.push("yellow");
424
- parts.push(msg("install.behind", { hosts: behind }));
401
+ parts.push(msg("install.behind", { hosts: behind.map(hostLabel) }));
425
402
  decisive.push(["yellow", "install.behind"]);
426
403
  }
427
404
  }