@mmerterden/multi-agent-pipeline 24.1.1 → 24.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +6 -5
- package/README.tr.md +6 -5
- package/docs/architecture.md +3 -3
- package/docs/ecosystem.md +5 -5
- package/docs/facts.json +4 -4
- package/install/_common.mjs +65 -0
- package/install/_plugin-skills.mjs +76 -18
- package/install/claude.mjs +7 -0
- package/install/codex.mjs +15 -1
- package/install/copilot.mjs +7 -0
- package/manifest.json +48 -43
- package/package.json +1 -1
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/commands/multi-agent/version/SKILL.md +67 -0
- package/pipeline/contract/CHANGELOG.md +10 -0
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/manifest.json +4 -3
- package/pipeline/contract/types/index.d.ts +7 -5
- package/pipeline/lib/toolkit-install.mjs +147 -0
- package/pipeline/lib/usage-names.generated.mjs +2 -0
- package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
- package/pipeline/multi-agent-refs/help/en.md +2 -1
- package/pipeline/multi-agent-refs/help/tr.md +2 -1
- package/pipeline/office/index.html +2 -2
- package/pipeline/schemas/disk-clean-request.schema.json +8 -2
- package/pipeline/schemas/disk-clean.schema.json +3 -2
- package/pipeline/schemas/hosts.json +7 -0
- package/pipeline/schemas/hosts.schema.json +17 -0
- package/pipeline/schemas/office-jobs.json +8 -0
- package/pipeline/schemas/version-report.schema.json +256 -0
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/disk-cleaner.mjs +232 -5
- package/pipeline/scripts/feedback-send.mjs +7 -11
- package/pipeline/scripts/health-report.mjs +30 -53
- package/pipeline/scripts/version-report.mjs +868 -0
- package/pipeline/skills/.skill-manifest.json +8 -4
- package/pipeline/skills/.skills-index.json +12 -1
- package/pipeline/skills/shared/README.md +4 -3
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/shared/core/multi-agent-version/SKILL.md +27 -0
- package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +2 -1
- package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +232 -5
- package/pipeline/skills/skills-index.md +2 -1
|
@@ -42,11 +42,14 @@
|
|
|
42
42
|
*
|
|
43
43
|
* Usage:
|
|
44
44
|
* disk-cleaner.mjs [--dry-run] [--apply] [--only=a,b] [--skip=a,b]
|
|
45
|
-
* [--trash] [--transcripts] [--
|
|
45
|
+
* [--trash] [--transcripts] [--test-artifacts] [--unattended]
|
|
46
|
+
* [--include-recent]
|
|
46
47
|
* [--log-days=N] [--archive-days=N] [--transcript-days=N]
|
|
48
|
+
* [--artifact-days=N]
|
|
47
49
|
* [--scratch-hours=N] [--build-hours=N] [--orphan-minutes=N]
|
|
48
50
|
* [--runtime-days=N] [--depth=N] [--exclude=PATH]...
|
|
49
|
-
* [--root=DIR]... [--tmp-root=DIR]... [--
|
|
51
|
+
* [--root=DIR]... [--tmp-root=DIR]... [--artifact-root=DIR]...
|
|
52
|
+
* [--home=DIR]
|
|
50
53
|
* [--report=FILE] [--json] [--list] [--top=N]
|
|
51
54
|
*
|
|
52
55
|
* --root and --depth (defaults: the git repos under the usual dev folders,
|
|
@@ -54,6 +57,11 @@
|
|
|
54
57
|
* DISK_CLEANER_DEPTH; --exclude from DISK_CLEANER_EXCLUDE (colon-separated).
|
|
55
58
|
* An excluded path, and any candidate that holds it, is kept.
|
|
56
59
|
*
|
|
60
|
+
* --artifact-root, also DISK_CLEANER_ARTIFACT_ROOTS (colon-separated), adds a
|
|
61
|
+
* tree to search for test run output beside the dev roots. It is where a
|
|
62
|
+
* harness that keeps its results outside a repository is named, so no product's
|
|
63
|
+
* paths live in this file.
|
|
64
|
+
*
|
|
57
65
|
* Every category in the JSON report carries `top` (its largest items, real
|
|
58
66
|
* paths and sizes, 5 unless --top says otherwise), `more` (how many items
|
|
59
67
|
* `top` leaves out) and `kept` (how many items were kept, per reason). The
|
|
@@ -70,12 +78,15 @@
|
|
|
70
78
|
|
|
71
79
|
import { spawnSync } from "node:child_process";
|
|
72
80
|
import {
|
|
81
|
+
closeSync,
|
|
73
82
|
existsSync,
|
|
74
83
|
lstatSync,
|
|
75
84
|
mkdirSync,
|
|
85
|
+
openSync,
|
|
76
86
|
readdirSync,
|
|
77
87
|
realpathSync,
|
|
78
88
|
readFileSync,
|
|
89
|
+
readSync,
|
|
79
90
|
rmSync,
|
|
80
91
|
statfsSync,
|
|
81
92
|
writeFileSync,
|
|
@@ -312,12 +323,14 @@ export function makeContext(o = {}) {
|
|
|
312
323
|
now: o.now ?? Date.now(),
|
|
313
324
|
tmpRoots,
|
|
314
325
|
devRoots: o.devRoots || defaultDevRoots(home),
|
|
326
|
+
artifactRoots: (o.artifactRoots || []).filter(Boolean).map((r) => nativeReal(r) || r),
|
|
315
327
|
scriptsDir: o.scriptsDir || defaultScriptsDir(home),
|
|
316
328
|
sessionId: o.sessionId ?? process.env.CLAUDE_CODE_SESSION_ID ?? "",
|
|
317
329
|
days: {
|
|
318
330
|
logs: o.logDays ?? 30,
|
|
319
331
|
archives: o.archiveDays ?? 90,
|
|
320
332
|
transcripts: o.transcriptDays ?? 90,
|
|
333
|
+
artifacts: o.artifactDays ?? 7,
|
|
321
334
|
},
|
|
322
335
|
includeRecent: Boolean(o.includeRecent),
|
|
323
336
|
scratchHours: o.scratchHours ?? 48,
|
|
@@ -328,6 +341,7 @@ export function makeContext(o = {}) {
|
|
|
328
341
|
maxDepth: o.maxDepth ?? MAX_WALK_DEPTH,
|
|
329
342
|
excludes: (o.excludes || []).filter(Boolean).map((p) => nativeReal(p) || p),
|
|
330
343
|
denied: new Set(),
|
|
344
|
+
trackedCache: new Map(),
|
|
331
345
|
run: o.run || realRun,
|
|
332
346
|
du: o.du || duBytes,
|
|
333
347
|
ps: () => (psCache ??= (o.ps || realPs)()),
|
|
@@ -669,6 +683,54 @@ const BUILD_SHAPE = {
|
|
|
669
683
|
};
|
|
670
684
|
BUILD_SHAPE[".DerivedData"] = BUILD_SHAPE.DerivedData;
|
|
671
685
|
|
|
686
|
+
// Build output under a name nobody can enumerate.
|
|
687
|
+
//
|
|
688
|
+
// Matching on the folder's NAME finds the default layouts and nothing else. A
|
|
689
|
+
// tool that points `-derivedDataPath` somewhere of its own choosing - a test
|
|
690
|
+
// harness giving each lane its own copy, a CI script, a wrapper that keeps one
|
|
691
|
+
// per scheme - writes the same tree under a name this file has never heard of.
|
|
692
|
+
// Measured on one machine: four such copies beside a repository's worktrees
|
|
693
|
+
// held 104 GB, the walk descended through all of it looking for a folder called
|
|
694
|
+
// DerivedData, and the report came back with 11 GB.
|
|
695
|
+
//
|
|
696
|
+
// So the shape decides, not the name. Both tools write a signature no source
|
|
697
|
+
// tree carries: Xcode writes `Build` beside its `.noindex` caches, SwiftPM a
|
|
698
|
+
// `build.db` beside its manifest and checkouts. `Build` or `build.db` is tested
|
|
699
|
+
// first, one stat, and the rest only when that hits - so an ordinary directory
|
|
700
|
+
// costs a single extra stat.
|
|
701
|
+
const SHAPE_SIGNATURES = Object.freeze([
|
|
702
|
+
{
|
|
703
|
+
kind: "DerivedData",
|
|
704
|
+
lead: "Build",
|
|
705
|
+
others: ["Index.noindex", "ModuleCache.noindex", "SourcePackages", "Logs", "info.plist"],
|
|
706
|
+
least: 2,
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
kind: ".build",
|
|
710
|
+
lead: "build.db",
|
|
711
|
+
others: ["manifest.db", "checkouts", "artifacts", "repositories", "index-build"],
|
|
712
|
+
least: 1,
|
|
713
|
+
},
|
|
714
|
+
]);
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* What a directory is, read from what it holds rather than what it is called.
|
|
718
|
+
*
|
|
719
|
+
* @param {string} dir
|
|
720
|
+
* @returns {"DerivedData"|".build"|null}
|
|
721
|
+
*/
|
|
722
|
+
function shapeOf(dir) {
|
|
723
|
+
for (const sig of SHAPE_SIGNATURES) {
|
|
724
|
+
if (!existsSync(join(dir, sig.lead))) continue;
|
|
725
|
+
let found = 0;
|
|
726
|
+
for (const n of sig.others) {
|
|
727
|
+
if (existsSync(join(dir, n))) found++;
|
|
728
|
+
if (found >= sig.least) return sig.kind;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
|
|
672
734
|
function repoBuildCandidates(ctx, out) {
|
|
673
735
|
const maxAge = ctx.repoBuildHours * HOUR_MS;
|
|
674
736
|
const visit = (root, dir, depth) => {
|
|
@@ -684,9 +746,14 @@ function repoBuildCandidates(ctx, out) {
|
|
|
684
746
|
if (!e.isDirectory() || e.isSymbolicLink()) continue;
|
|
685
747
|
const p = join(dir, e.name);
|
|
686
748
|
if (devPruned(ctx, p, e.name)) continue;
|
|
687
|
-
|
|
749
|
+
// A folder with a build tool's NAME is a candidate when it also holds what
|
|
750
|
+
// that tool writes; one that does not is somebody's own directory, and the
|
|
751
|
+
// report says it was kept. A folder with any OTHER name is a candidate only
|
|
752
|
+
// when its shape says so, and then there is nothing to report about it.
|
|
753
|
+
const named = Boolean(BUILD_SHAPE[e.name]);
|
|
754
|
+
const shape = named ? BUILD_SHAPE[e.name] : BUILD_SHAPE[shapeOf(p) ?? ""];
|
|
688
755
|
if (shape) {
|
|
689
|
-
if (!shape.some((n) => existsSync(join(p, n)))) {
|
|
756
|
+
if (named && !shape.some((n) => existsSync(join(p, n)))) {
|
|
690
757
|
out.skipped.push({ path: p, reason: "does not look like build output" });
|
|
691
758
|
} else if (inUse(ctx, realOrNull(p) || p)) {
|
|
692
759
|
hold(out, p, "in use by a running process", "live");
|
|
@@ -784,6 +851,146 @@ function claudeScratchCandidates(ctx, out) {
|
|
|
784
851
|
}
|
|
785
852
|
}
|
|
786
853
|
|
|
854
|
+
// What a test run leaves behind, found by shape.
|
|
855
|
+
//
|
|
856
|
+
// A run writes three kinds of output and all three are regenerable by running
|
|
857
|
+
// it again: the result bundle, the recordings and screenshots taken while it
|
|
858
|
+
// ran, and the report files. They are also the biggest thing on a machine that
|
|
859
|
+
// runs a suite every night, and nothing deleted them.
|
|
860
|
+
//
|
|
861
|
+
// The shape is the only safe way to find them. Naming the directories one
|
|
862
|
+
// harness happens to use would tie this file to that harness, and this
|
|
863
|
+
// repository carries no product's paths - an extra root belongs in preferences
|
|
864
|
+
// (DISK_CLEANER_ARTIFACT_ROOTS, --artifact-root), not here. So a run is
|
|
865
|
+
// recognised by what every harness writes: a result bundle, or a report file
|
|
866
|
+
// shaped like a test report. Media and report files count only inside such a
|
|
867
|
+
// directory, so a recording somebody saved among their own files is never a
|
|
868
|
+
// candidate.
|
|
869
|
+
//
|
|
870
|
+
// Opt-in, never unattended: a recording can be the only evidence of a failure
|
|
871
|
+
// anybody still has.
|
|
872
|
+
const RESULT_BUNDLE = /\.xcresult$/i;
|
|
873
|
+
const RUN_MEDIA = /\.(?:mp4|mov|m4v|png|jpe?g|heic)$/i;
|
|
874
|
+
const RUN_REPORT = /\.(?:html?|json|xml|junit|txt|log)$/i;
|
|
875
|
+
const JUNIT_HEAD = /<testsuites?[\s>]/i;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* The names git tracks in one directory, cached per directory.
|
|
879
|
+
*
|
|
880
|
+
* A run's output is not in version control; a test fixture is. Without this the
|
|
881
|
+
* shape rules read a committed `TEST-*.xml` as a run's report and offer to
|
|
882
|
+
* delete the repository's own fixtures - found on the first real run, against
|
|
883
|
+
* this repository's test tree.
|
|
884
|
+
*
|
|
885
|
+
* `ls-files` is asked once per directory and only for that directory, so a
|
|
886
|
+
* directory of run output, which is normally ignored, costs one call that
|
|
887
|
+
* returns nothing.
|
|
888
|
+
*
|
|
889
|
+
* @returns {Set<string>} basenames; empty when the directory is not in a repository
|
|
890
|
+
*/
|
|
891
|
+
function trackedNames(dir, ctx) {
|
|
892
|
+
const cached = ctx.trackedCache.get(dir);
|
|
893
|
+
if (cached) return cached;
|
|
894
|
+
const names = new Set();
|
|
895
|
+
const r = ctx.run("git", ["-C", dir, "ls-files", "-z", "--", "."], { timeout: 20_000 });
|
|
896
|
+
if (r.status === 0 && r.stdout) {
|
|
897
|
+
for (const rel of r.stdout.split("\0")) {
|
|
898
|
+
if (!rel) continue;
|
|
899
|
+
// `.` is this directory, so a path with a separator names something below
|
|
900
|
+
// it - and the first segment is what sits here.
|
|
901
|
+
names.add(rel.split("/")[0]);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
ctx.trackedCache.set(dir, names);
|
|
905
|
+
return names;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** Does this directory hold a test run's output? */
|
|
909
|
+
function holdsRunOutput(dir, ctx) {
|
|
910
|
+
let names;
|
|
911
|
+
try {
|
|
912
|
+
names = listDir(dir, ctx).map((p) => basename(p));
|
|
913
|
+
} catch {
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
if (names.some((n) => RESULT_BUNDLE.test(n))) return true;
|
|
917
|
+
for (const n of names) {
|
|
918
|
+
if (!/\.xml$/i.test(n)) continue;
|
|
919
|
+
try {
|
|
920
|
+
// The head of the file, not the whole of it: a junit file can be large and
|
|
921
|
+
// the element that identifies it is the first one.
|
|
922
|
+
const fd = openSync(join(dir, n), "r");
|
|
923
|
+
try {
|
|
924
|
+
const buf = Buffer.alloc(512);
|
|
925
|
+
const read = readSync(fd, buf, 0, 512, 0);
|
|
926
|
+
if (JUNIT_HEAD.test(buf.subarray(0, read).toString("utf8"))) return true;
|
|
927
|
+
} finally {
|
|
928
|
+
closeSync(fd);
|
|
929
|
+
}
|
|
930
|
+
} catch {
|
|
931
|
+
/* unreadable; it decides nothing */
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function testArtifactCandidates(ctx, out) {
|
|
938
|
+
const maxAge = ctx.days.artifacts * DAY_MS;
|
|
939
|
+
const roots = [...ctx.devRoots, ...ctx.artifactRoots];
|
|
940
|
+
const seen = new Set();
|
|
941
|
+
for (const root of roots) {
|
|
942
|
+
if (seen.has(root) || !rootUsable(root, ctx, out)) continue;
|
|
943
|
+
seen.add(root);
|
|
944
|
+
const visit = (dir, depth) => {
|
|
945
|
+
if (depth > ctx.maxDepth) return;
|
|
946
|
+
let entries;
|
|
947
|
+
try {
|
|
948
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
949
|
+
} catch (e) {
|
|
950
|
+
noteDenied(ctx, dir, e);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
// A result bundle is a directory. Take it whole and do not walk into it.
|
|
954
|
+
for (const e of entries) {
|
|
955
|
+
if (e.isSymbolicLink()) continue;
|
|
956
|
+
const path = join(dir, e.name);
|
|
957
|
+
if (e.isDirectory() && RESULT_BUNDLE.test(e.name)) {
|
|
958
|
+
take(path);
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
if (e.isDirectory()) {
|
|
962
|
+
if (WALK_SKIP.has(e.name) || devPruned(ctx, path, e.name)) continue;
|
|
963
|
+
if (e.name === ".git" || e.name === "node_modules" || e.name === "Pods") continue;
|
|
964
|
+
visit(path, depth + 1);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
// Media and reports, only where a run's output is.
|
|
968
|
+
if (!holdsRunOutput(dir, ctx)) return;
|
|
969
|
+
for (const e of entries) {
|
|
970
|
+
if (!e.isFile() || e.isSymbolicLink()) continue;
|
|
971
|
+
if (!RUN_MEDIA.test(e.name) && !RUN_REPORT.test(e.name)) continue;
|
|
972
|
+
take(join(dir, e.name));
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
const take = (path) => {
|
|
976
|
+
if (trackedNames(dirname(path), ctx).has(basename(path))) {
|
|
977
|
+
out.skipped.push({ path, reason: "tracked by git" });
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (!olderThan(path, maxAge, ctx)) {
|
|
981
|
+
hold(out, path, "touched recently", "age");
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
if (inUse(ctx, realOrNull(path) || path)) {
|
|
985
|
+
hold(out, path, "in use by a running process", "live");
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
addPath(out, ctx, path, [root]);
|
|
989
|
+
};
|
|
990
|
+
visit(root, 0);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
787
994
|
function transcriptCandidates(ctx, out) {
|
|
788
995
|
const maxAge = ctx.days.transcripts * DAY_MS;
|
|
789
996
|
const roots = [H(ctx, ".claude", "projects"), H(ctx, ".codex", "sessions")];
|
|
@@ -1240,6 +1447,14 @@ export const CATEGORIES = [
|
|
|
1240
1447
|
optIn: "trash",
|
|
1241
1448
|
discover: (ctx, out) => childrenOf(ctx, out, [H(ctx, ".Trash")]),
|
|
1242
1449
|
},
|
|
1450
|
+
{
|
|
1451
|
+
id: "test-artifacts",
|
|
1452
|
+
label:
|
|
1453
|
+
"test run output under the dev and artifact roots, older than the artifact age: result bundles, recordings, screenshots and report files",
|
|
1454
|
+
unattended: false,
|
|
1455
|
+
optIn: "test-artifacts",
|
|
1456
|
+
discover: testArtifactCandidates,
|
|
1457
|
+
},
|
|
1243
1458
|
{
|
|
1244
1459
|
id: "transcripts",
|
|
1245
1460
|
label: "Claude Code and Codex session transcripts older than the transcript age",
|
|
@@ -1427,7 +1642,7 @@ export function applyPlan(ctx, planned) {
|
|
|
1427
1642
|
// ---------------------------------------------------------------- CLI
|
|
1428
1643
|
|
|
1429
1644
|
function parseCli(argv) {
|
|
1430
|
-
const o = { only: [], skip: [], tmpRoots: [], devRoots: [], excludes: [] };
|
|
1645
|
+
const o = { only: [], skip: [], tmpRoots: [], devRoots: [], artifactRoots: [], excludes: [] };
|
|
1431
1646
|
const num = (k, v) => {
|
|
1432
1647
|
if (!/^\d+$/.test(v)) throw new Error(`${k} needs a whole number, got "${v}"`);
|
|
1433
1648
|
return Number(v);
|
|
@@ -1445,6 +1660,7 @@ function parseCli(argv) {
|
|
|
1445
1660
|
break;
|
|
1446
1661
|
case "--trash":
|
|
1447
1662
|
case "--transcripts":
|
|
1663
|
+
case "--test-artifacts":
|
|
1448
1664
|
case "--unattended":
|
|
1449
1665
|
case "--json":
|
|
1450
1666
|
case "--list":
|
|
@@ -1457,6 +1673,13 @@ function parseCli(argv) {
|
|
|
1457
1673
|
if (!v) throw new Error("--exclude needs a path");
|
|
1458
1674
|
o.excludes.push(v);
|
|
1459
1675
|
break;
|
|
1676
|
+
case "--artifact-root":
|
|
1677
|
+
if (!v) throw new Error("--artifact-root needs a path");
|
|
1678
|
+
o.artifactRoots.push(v);
|
|
1679
|
+
break;
|
|
1680
|
+
case "--artifact-days":
|
|
1681
|
+
o.artifactDays = num(k, v);
|
|
1682
|
+
break;
|
|
1460
1683
|
case "--depth":
|
|
1461
1684
|
o.depth = num(k, v);
|
|
1462
1685
|
break;
|
|
@@ -1670,6 +1893,9 @@ export function main(argv, env = process.env) {
|
|
|
1670
1893
|
home: o.home,
|
|
1671
1894
|
tmpRoots: o.tmpRoots.length ? o.tmpRoots : undefined,
|
|
1672
1895
|
devRoots: o.devRoots.length ? o.devRoots : env.DISK_CLEANER_ROOTS?.split(":").filter(Boolean),
|
|
1896
|
+
artifactRoots: o.artifactRoots.length
|
|
1897
|
+
? o.artifactRoots
|
|
1898
|
+
: (env.DISK_CLEANER_ARTIFACT_ROOTS?.split(":").filter(Boolean) ?? []),
|
|
1673
1899
|
logDays: o.logDays,
|
|
1674
1900
|
archiveDays: o.archiveDays,
|
|
1675
1901
|
transcriptDays: o.transcriptDays,
|
|
@@ -1690,6 +1916,7 @@ export function main(argv, env = process.env) {
|
|
|
1690
1916
|
unattended,
|
|
1691
1917
|
trash: unattended ? false : o.trash,
|
|
1692
1918
|
transcripts: unattended ? false : o.transcripts,
|
|
1919
|
+
"test-artifacts": unattended ? false : o["test-artifacts"],
|
|
1693
1920
|
};
|
|
1694
1921
|
const before = diskStatus(ctx.home);
|
|
1695
1922
|
const planned = plan(ctx, sel);
|
|
@@ -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
|
|
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
|
|
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(
|
|
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
|
-
|
|
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 {
|
|
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 =
|
|
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
|
-
/**
|
|
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 = (
|
|
359
|
+
const read = (id) => {
|
|
395
360
|
try {
|
|
396
|
-
const v = readFileSync(join(home,
|
|
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
|
|
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
|
-
|
|
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 =
|
|
415
|
-
const behind = others.filter((h) => versions[h] !== versions
|
|
416
|
-
const hosts = others.map((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
|
|
420
|
-
: msg("install.version", { version: versions
|
|
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
|
}
|