@mmerterden/multi-agent-pipeline 20.42.0 → 20.43.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +7 -5
  3. package/README.tr.md +7 -5
  4. package/docs/architecture.md +3 -3
  5. package/docs/ecosystem.md +6 -6
  6. package/docs/facts.json +5 -5
  7. package/manifest.json +45 -38
  8. package/package.json +1 -1
  9. package/pipeline/commands/multi-agent/clean-disk/SKILL.md +134 -0
  10. package/pipeline/commands/multi-agent/review-priority/SKILL.md +143 -0
  11. package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
  12. package/pipeline/commands/multi-agent/sync/SKILL.md +4 -4
  13. package/pipeline/commands/multi-agent/update/SKILL.md +21 -8
  14. package/pipeline/lib/low-disk.mjs +6 -5
  15. package/pipeline/multi-agent-refs/cross-cli-contract.md +5 -5
  16. package/pipeline/multi-agent-refs/features/doctor.md +17 -2
  17. package/pipeline/multi-agent-refs/features/review-priority.md +123 -0
  18. package/pipeline/multi-agent-refs/features/usage-reporting.md +45 -5
  19. package/pipeline/multi-agent-refs/help/en.md +2 -0
  20. package/pipeline/multi-agent-refs/help/tr.md +2 -0
  21. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +1 -1
  22. package/pipeline/multi-agent-refs/review-priority/rules/example.md +137 -0
  23. package/pipeline/office/toolkit.json +1 -1
  24. package/pipeline/schemas/prefs.schema.json +19 -1
  25. package/pipeline/schemas/toolkit-path-params.json +1 -1
  26. package/pipeline/scripts/capture-resume.sh +1 -1
  27. package/pipeline/scripts/disk-cleaner.mjs +77 -63
  28. package/pipeline/scripts/doctor.mjs +140 -10
  29. package/pipeline/scripts/priority-review.mjs +912 -0
  30. package/pipeline/scripts/usage-register.mjs +86 -9
  31. package/pipeline/skills/.skill-manifest.json +14 -6
  32. package/pipeline/skills/.skills-index.json +24 -2
  33. package/pipeline/skills/shared/README.md +6 -4
  34. package/pipeline/skills/shared/core/multi-agent-clean-disk/SKILL.md +34 -0
  35. package/pipeline/skills/shared/core/multi-agent-review-priority/SKILL.md +36 -0
  36. package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +1 -1
  37. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +4 -4
  38. package/pipeline/skills/shared/core/multi-agent-update/SKILL.md +11 -5
  39. package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +10 -4
  40. package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +6 -6
  41. package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +77 -63
  42. package/pipeline/skills/skills-index.md +4 -2
@@ -58,7 +58,7 @@ import {
58
58
  } from "node:fs";
59
59
  import { basename, join, dirname } from "node:path";
60
60
  import { homedir } from "node:os";
61
- import { execFileSync } from "node:child_process";
61
+ import { execFileSync, spawnSync } from "node:child_process";
62
62
  import { fileURLToPath, pathToFileURL } from "node:url";
63
63
  import { runMain } from "../lib/fatal.mjs";
64
64
  import { hostCommand } from "../lib/user-facing.mjs";
@@ -69,7 +69,7 @@ import {
69
69
  import { prefsHosts, profileGaps } from "../lib/unattended-profile-check.mjs";
70
70
  import { xcodeSkillsStatus } from "../lib/xcode-plugin.mjs";
71
71
  import { hookReport, registrationGaps } from "../lib/hook-registration.mjs";
72
- import { PREFS_ENV, prefsFileIn } from "../lib/prefs-value.mjs";
72
+ import { PREFS_ENV, globalPref, prefsFileIn } from "../lib/prefs-value.mjs";
73
73
  import { check as lowDiskCheck } from "../lib/low-disk.mjs";
74
74
  import { exitOnHelp } from "../lib/cli-help.mjs";
75
75
  import { didYouMean } from "../lib/args.mjs";
@@ -1197,7 +1197,7 @@ function checkMcpFailures() {
1197
1197
  "mcp-failures",
1198
1198
  "INFO",
1199
1199
  `${n} MCP call(s) failed with disk-full in the last ${summary.hours} hours (${diskFull.map((s) => s.server).join(", ")})`,
1200
- "run the disk-cleaner skill: node ~/.claude/scripts/disk-cleaner.mjs --dry-run, then --apply for the categories you choose",
1200
+ `run ${hostCommand("clean-disk", HERE)}: it measures every category first and deletes only the ones you choose`,
1201
1201
  diskFull.map((s) => ({ server: s.server, diskFull: s.classes["disk-full"] })),
1202
1202
  );
1203
1203
  return;
@@ -1454,25 +1454,154 @@ function checkXcodeSkills() {
1454
1454
 
1455
1455
  // One statfs call against the volume holding $HOME. Low means below
1456
1456
  // prefs.global.diskCleaner.lowDiskGb or lowDiskPercent (lib/low-disk.mjs owns
1457
- // both defaults); the step names the disk-cleaner skill, which measures before
1458
- // it deletes anything.
1457
+ // both defaults). What could be freed comes from the newest disk-cleaner dry
1458
+ // run under ~/.claude/logs/disk-cleaner, never from a fresh measurement: a
1459
+ // full measurement walks every cache and would make doctor slow. --probe runs
1460
+ // one under a time cap; a timeout is reported, never a failure. Nothing here
1461
+ // deletes anything.
1462
+ const DISK_REPORT_MAX_AGE_MS = 24 * 3_600_000;
1463
+ const DISK_PROBE_TIMEOUT_MS = 60_000;
1464
+ const DISK_TOP = 3;
1465
+ const GB = 1e9;
1466
+ const gb = (bytes) => `${(bytes / GB).toFixed(1)} GB`;
1467
+
1468
+ function newestDiskReport(dir) {
1469
+ let names;
1470
+ try {
1471
+ names = readdirSync(dir)
1472
+ .filter((n) => /^report-.*\.json$/.test(n))
1473
+ .sort()
1474
+ .reverse();
1475
+ } catch {
1476
+ return null;
1477
+ }
1478
+ for (const n of names) {
1479
+ const data = readJson(join(dir, n));
1480
+ if (data && data.mode === "dry-run" && Array.isArray(data.categories)) {
1481
+ return { file: join(dir, n), data };
1482
+ }
1483
+ }
1484
+ return null;
1485
+ }
1486
+
1487
+ function probeDiskReport() {
1488
+ const timeout = Number(process.env.DOCTOR_DISK_PROBE_TIMEOUT_MS) || DISK_PROBE_TIMEOUT_MS;
1489
+ const r = spawnSync(
1490
+ process.execPath,
1491
+ [join(HERE, "disk-cleaner.mjs"), "--dry-run", "--json", `--top=${DISK_TOP}`],
1492
+ { encoding: "utf8", timeout, maxBuffer: 256 * 1024 * 1024 },
1493
+ );
1494
+ if (r.error?.code === "ETIMEDOUT" || r.signal) {
1495
+ return { timedOut: true, seconds: Math.round(timeout / 1000) };
1496
+ }
1497
+ try {
1498
+ return { data: JSON.parse(r.stdout) };
1499
+ } catch {
1500
+ return { error: (r.stderr || "no JSON on stdout").trim().split("\n")[0] };
1501
+ }
1502
+ }
1503
+
1504
+ function reclaimSummary(data, source, file) {
1505
+ const measuredAt = Date.parse(data.startedAt);
1506
+ const ageMs = Number.isFinite(measuredAt) ? Date.now() - measuredAt : null;
1507
+ const top = [...data.categories]
1508
+ .filter((c) => c.bytes > 0)
1509
+ .sort((a, b) => b.bytes - a.bytes)
1510
+ .slice(0, DISK_TOP)
1511
+ .map((c) => ({ id: c.id, bytes: c.bytes }));
1512
+ return {
1513
+ source,
1514
+ file,
1515
+ measuredAt: data.startedAt || null,
1516
+ ageHours: ageMs == null ? null : Math.round((ageMs / 3_600_000) * 10) / 10,
1517
+ stale: ageMs == null || ageMs > DISK_REPORT_MAX_AGE_MS,
1518
+ totalBytes: data.reclaimableBytes ?? data.totalBytes ?? 0,
1519
+ top,
1520
+ };
1521
+ }
1522
+
1523
+ function ageText(hours) {
1524
+ if (hours == null) return "at an unknown time";
1525
+ if (hours < 1) return `${Math.max(1, Math.round(hours * 60))} min ago`;
1526
+ if (hours < 48) return `${Math.round(hours)} h ago`;
1527
+ return `${Math.round(hours / 24)} days ago`;
1528
+ }
1529
+
1459
1530
  function checkDiskSpace() {
1460
1531
  const r = lowDiskCheck({ path: HOME });
1461
1532
  if (r.freeBytes == null) {
1462
1533
  skip("disk-space", "statfs did not report a usable figure on this host");
1463
1534
  return;
1464
1535
  }
1536
+ const cmd = hostCommand("clean-disk", HERE);
1537
+ const pct = r.totalBytes ? (r.freeBytes / r.totalBytes) * 100 : null;
1538
+ const freeText = `${gb(r.freeBytes)} (${pct == null ? "?" : pct.toFixed(1)}%) free on the volume holding $HOME`;
1539
+ const threshold = Number(globalPref("diskCleaner.reclaimableGb", 10));
1540
+ const reclaimGb = Number.isFinite(threshold) && threshold >= 0 ? threshold : 10;
1541
+
1542
+ let reclaim = null;
1543
+ let probe = null;
1544
+ if (PROBE) {
1545
+ const p = probeDiskReport();
1546
+ probe = p.data
1547
+ ? { ok: true }
1548
+ : p.timedOut
1549
+ ? { timedOut: true, seconds: p.seconds }
1550
+ : { error: p.error };
1551
+ if (p.data) reclaim = reclaimSummary(p.data, "probe", null);
1552
+ }
1553
+ if (!reclaim) {
1554
+ const found = newestDiskReport(join(CLAUDE, "logs", "disk-cleaner"));
1555
+ if (found) reclaim = reclaimSummary(found.data, "report", found.file);
1556
+ }
1557
+
1558
+ let measured;
1559
+ if (probe?.timedOut) {
1560
+ measured = `the measurement timed out after ${probe.seconds} s`;
1561
+ if (reclaim && !reclaim.stale) measured += `; the last one, ${ageText(reclaim.ageHours)}`;
1562
+ } else if (probe?.error) {
1563
+ measured = `the measurement failed (${probe.error})`;
1564
+ } else if (!reclaim) {
1565
+ measured = `nothing measured yet; ${cmd} measures what can be freed`;
1566
+ } else if (reclaim.stale) {
1567
+ measured = `the last measurement is ${ageText(reclaim.ageHours).replace(/ ago$/, " old")}; ${cmd} measures again`;
1568
+ } else {
1569
+ measured = `measured ${ageText(reclaim.ageHours)}`;
1570
+ }
1571
+ const fresh = reclaim && !reclaim.stale;
1572
+ const reclaimText = fresh
1573
+ ? `${gb(reclaim.totalBytes)} can be freed${reclaim.top.length ? ` (${reclaim.top.map((c) => `${c.id} ${gb(c.bytes)}`).join(", ")})` : ""}, ${measured}`
1574
+ : measured;
1575
+ const detail = {
1576
+ freeBytes: r.freeBytes,
1577
+ totalBytes: r.totalBytes,
1578
+ freePercent: pct == null ? null : Math.round(pct * 10) / 10,
1579
+ lowGb: r.lowGb,
1580
+ lowPercent: r.lowPercent,
1581
+ reclaimableGb: reclaimGb,
1582
+ reclaimable: reclaim,
1583
+ probe,
1584
+ summary: `${freeText}; ${reclaimText}`,
1585
+ };
1586
+ const freeStep = fresh
1587
+ ? `run ${cmd}: ${gb(reclaim.totalBytes)} can be freed`
1588
+ : `run ${cmd} to measure what can be freed; it deletes only what you choose`;
1589
+
1465
1590
  if (r.low) {
1466
- const pct = r.totalBytes ? ((r.freeBytes / r.totalBytes) * 100).toFixed(1) : "?";
1467
1591
  report(
1468
1592
  "disk-space",
1469
1593
  "WARN",
1470
- `${(r.freeBytes / 1e9).toFixed(1)} GB (${pct}%) free on the volume holding $HOME, under the ${r.lowGb} GB / ${r.lowPercent}% floor; a worktree plus a build needs more`,
1471
- "run the disk-cleaner skill: node ~/.claude/scripts/disk-cleaner.mjs --dry-run, then --apply for the categories you choose",
1594
+ `${freeText}, under the ${r.lowGb} GB / ${r.lowPercent}% floor; a worktree plus a build needs more; ${reclaimText}`,
1595
+ freeStep,
1596
+ detail,
1472
1597
  );
1473
1598
  return;
1474
1599
  }
1475
- ok("disk-space");
1600
+ if (fresh && reclaim.totalBytes >= reclaimGb * GB) {
1601
+ report("disk-space", "INFO", `${freeText}; ${reclaimText}`, freeStep, detail);
1602
+ return;
1603
+ }
1604
+ report("disk-space", "OK", null, null, detail);
1476
1605
  }
1477
1606
 
1478
1607
  // A finished task removes its own worktree at PR time, but a run that dies
@@ -1806,7 +1935,8 @@ function main() {
1806
1935
  const r = results.find((x) => x.id === id);
1807
1936
  if (!r) continue;
1808
1937
  if (r.severity === "OK") {
1809
- process.stdout.write(`OK ${id}\n`);
1938
+ const note = typeof r.detail?.summary === "string" ? ` - ${r.detail.summary}` : "";
1939
+ process.stdout.write(`OK ${id}${note}\n`);
1810
1940
  } else if (r.severity === "SKIP") {
1811
1941
  process.stdout.write(`SKIP ${id} - ${r.problem}\n`);
1812
1942
  } else {