@decocms/parity 0.35.34 → 0.35.35
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 +9 -0
- package/dist/cli.js +352 -24
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -22,6 +22,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
22
22
|
`favicon-parity`, `plp-sorting` and `plp-pagination` wait 60s on a local URL instead of aborting
|
|
23
23
|
after 8-15s, since an aborted request is what wedges a dev server's loader de-duplication.
|
|
24
24
|
|
|
25
|
+
* **`parity capacity`** answers "may one more heavy agent start on this machine now, and how many
|
|
26
|
+
more?" so the orchestrator admits parallel fixers/porters by what the machine can carry instead
|
|
27
|
+
of a fixed 5. Measures cores, 1-minute load, available memory (macOS `vm_stat`, because
|
|
28
|
+
`os.freemem()` reads 2.0 GB where 5.3 GB is available; Linux `MemAvailable`, cgroup-capped),
|
|
29
|
+
swap and free disk, then `slots = min(max, memory, cpu, swap, disk)`. An unreadable input caps at
|
|
30
|
+
1 and is named, never read as headroom. Read-only; exit 0 admit, 1 no headroom, 2 could not
|
|
31
|
+
measure enough. The orchestrator checks it before each additional agent and removes a fixer's
|
|
32
|
+
worktree once its PR is merged or closed (disk was the binding constraint).
|
|
33
|
+
|
|
25
34
|
* **`first-viewport-ssr` check (html module)** answers "is what the user sees in the first viewport
|
|
26
35
|
already in the server response, or does it arrive later?". A deferred header (a skeleton in the
|
|
27
36
|
server HTML that client JS fills in) passed `ssr-no-js` (the rest of the page carried the text)
|
package/dist/cli.js
CHANGED
|
@@ -75779,7 +75779,7 @@ import {
|
|
|
75779
75779
|
registerCommands as registerCatalogCommands
|
|
75780
75780
|
} from "@decocms/catalog";
|
|
75781
75781
|
import { DESCRIPTION, registerCommands } from "@decocms/vtex-cms";
|
|
75782
|
-
import
|
|
75782
|
+
import chalk50 from "chalk";
|
|
75783
75783
|
import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
75784
75784
|
|
|
75785
75785
|
// src/commands/ab-detect.ts
|
|
@@ -125542,11 +125542,336 @@ async function studioCommentCommand(opts, call = callTool2) {
|
|
|
125542
125542
|
}
|
|
125543
125543
|
}
|
|
125544
125544
|
|
|
125545
|
-
// src/commands/
|
|
125546
|
-
import {
|
|
125547
|
-
import {
|
|
125545
|
+
// src/commands/capacity.ts
|
|
125546
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
125547
|
+
import { readFileSync as readFileSync46, statfsSync } from "node:fs";
|
|
125548
|
+
import os from "node:os";
|
|
125548
125549
|
import { resolve as resolve24 } from "node:path";
|
|
125549
125550
|
import chalk46 from "chalk";
|
|
125551
|
+
|
|
125552
|
+
// src/commands/capacity-tolerances.ts
|
|
125553
|
+
var CAPACITY_DEFAULTS = {
|
|
125554
|
+
perAgentGB: {
|
|
125555
|
+
value: 1.5,
|
|
125556
|
+
unit: "GB",
|
|
125557
|
+
basis: "assumed",
|
|
125558
|
+
note: "Resident memory of one agent's dev server + headless Chromium + a gate run. Not measured per agent: derived from 3 agents tipping a 16 GB machine into swap."
|
|
125559
|
+
},
|
|
125560
|
+
reserveGB: {
|
|
125561
|
+
value: 2,
|
|
125562
|
+
unit: "GB",
|
|
125563
|
+
basis: "assumed",
|
|
125564
|
+
note: "Memory left for the OS, the editor and the orchestrator itself; never handed to an agent."
|
|
125565
|
+
},
|
|
125566
|
+
perAgentCores: {
|
|
125567
|
+
value: 2,
|
|
125568
|
+
unit: "cores",
|
|
125569
|
+
basis: "assumed",
|
|
125570
|
+
note: "A dev server plus a build or test run keep about two cores busy. Load 11.8 on 10 cores with three agents is ~4 per agent at the peak; 2 is the sustained figure."
|
|
125571
|
+
},
|
|
125572
|
+
reserveCores: {
|
|
125573
|
+
value: 0,
|
|
125574
|
+
unit: "cores",
|
|
125575
|
+
basis: "assumed",
|
|
125576
|
+
note: "The 1-minute load average already contains whatever else runs on the machine, so no extra reserve."
|
|
125577
|
+
},
|
|
125578
|
+
swapThreshold: {
|
|
125579
|
+
value: 0.75,
|
|
125580
|
+
unit: "ratio (0-1)",
|
|
125581
|
+
basis: "assumed",
|
|
125582
|
+
note: "Swap used / swap total above this means the machine is already paging: free RAM figures stop meaning what they say."
|
|
125583
|
+
},
|
|
125584
|
+
swapCap: {
|
|
125585
|
+
value: 2,
|
|
125586
|
+
unit: "agents",
|
|
125587
|
+
basis: "assumed",
|
|
125588
|
+
note: "Slots allowed while swap is above the threshold. At 90% swap the measured case still ran three agents, slowly."
|
|
125589
|
+
},
|
|
125590
|
+
perAgentDiskGB: {
|
|
125591
|
+
value: 1,
|
|
125592
|
+
unit: "GB",
|
|
125593
|
+
basis: "assumed",
|
|
125594
|
+
note: "One worktree (~540 MB measured) plus its node_modules churn and a capture (~180 MB measured)."
|
|
125595
|
+
},
|
|
125596
|
+
reserveDiskGB: {
|
|
125597
|
+
value: 3,
|
|
125598
|
+
unit: "GB",
|
|
125599
|
+
basis: "assumed",
|
|
125600
|
+
note: "Headroom so a full disk does not corrupt a git operation or a capture mid-write."
|
|
125601
|
+
},
|
|
125602
|
+
maxParallel: {
|
|
125603
|
+
value: 5,
|
|
125604
|
+
unit: "agents",
|
|
125605
|
+
basis: "assumed",
|
|
125606
|
+
note: "The orchestrator's ceiling ('up to 5 per round'); `budget.maxParallel` in the state file overrides it via --max."
|
|
125607
|
+
},
|
|
125608
|
+
unknownCap: {
|
|
125609
|
+
value: 1,
|
|
125610
|
+
unit: "agents",
|
|
125611
|
+
basis: "assumed",
|
|
125612
|
+
note: "What an input that could not be read contributes. Never headroom: the caller runs one agent at a time."
|
|
125613
|
+
}
|
|
125614
|
+
};
|
|
125615
|
+
|
|
125616
|
+
// src/commands/capacity.ts
|
|
125617
|
+
var GB = 2 ** 30;
|
|
125618
|
+
var defaultParams = () => ({
|
|
125619
|
+
perAgentGB: CAPACITY_DEFAULTS.perAgentGB.value,
|
|
125620
|
+
reserveGB: CAPACITY_DEFAULTS.reserveGB.value,
|
|
125621
|
+
perAgentCores: CAPACITY_DEFAULTS.perAgentCores.value,
|
|
125622
|
+
reserveCores: CAPACITY_DEFAULTS.reserveCores.value,
|
|
125623
|
+
swapThreshold: CAPACITY_DEFAULTS.swapThreshold.value,
|
|
125624
|
+
swapCap: CAPACITY_DEFAULTS.swapCap.value,
|
|
125625
|
+
perAgentDiskGB: CAPACITY_DEFAULTS.perAgentDiskGB.value,
|
|
125626
|
+
reserveDiskGB: CAPACITY_DEFAULTS.reserveDiskGB.value,
|
|
125627
|
+
maxParallel: CAPACITY_DEFAULTS.maxParallel.value
|
|
125628
|
+
});
|
|
125629
|
+
function decideCapacity(inputs, params = defaultParams(), running) {
|
|
125630
|
+
const p = params;
|
|
125631
|
+
const unknown = [];
|
|
125632
|
+
const cap = CAPACITY_DEFAULTS.unknownCap.value;
|
|
125633
|
+
const term = (names, f) => {
|
|
125634
|
+
const missing = names.filter((n) => inputs[n] === null);
|
|
125635
|
+
unknown.push(...missing);
|
|
125636
|
+
return missing.length ? cap : Math.floor(f());
|
|
125637
|
+
};
|
|
125638
|
+
const memSlots = term(["availableGB"], () => (inputs.availableGB - p.reserveGB) / p.perAgentGB);
|
|
125639
|
+
const cpuSlots = term(["cores", "load1"], () => (inputs.cores - inputs.load1 - p.reserveCores) / p.perAgentCores);
|
|
125640
|
+
const diskSlots = term(["freeDiskGB"], () => (inputs.freeDiskGB - p.reserveDiskGB) / p.perAgentDiskGB);
|
|
125641
|
+
let swapCap = null;
|
|
125642
|
+
if (inputs.swapUsedGB === null || inputs.swapTotalGB === null) {
|
|
125643
|
+
unknown.push(...["swapUsedGB", "swapTotalGB"].filter((n) => inputs[n] === null));
|
|
125644
|
+
swapCap = cap;
|
|
125645
|
+
} else if (inputs.swapTotalGB > 0 && inputs.swapUsedGB / inputs.swapTotalGB > p.swapThreshold) {
|
|
125646
|
+
swapCap = p.swapCap;
|
|
125647
|
+
}
|
|
125648
|
+
const swapU = inputs.swapUsedGB === null || inputs.swapTotalGB === null;
|
|
125649
|
+
const cands = [
|
|
125650
|
+
["swap", swapCap ?? Number.POSITIVE_INFINITY, swapU],
|
|
125651
|
+
["memory", memSlots, inputs.availableGB === null],
|
|
125652
|
+
["cpu", cpuSlots, inputs.cores === null || inputs.load1 === null],
|
|
125653
|
+
["disk", diskSlots, inputs.freeDiskGB === null],
|
|
125654
|
+
["max", p.maxParallel, false]
|
|
125655
|
+
];
|
|
125656
|
+
let limitedBy = "max";
|
|
125657
|
+
let best = Number.POSITIVE_INFINITY;
|
|
125658
|
+
let bestUnknown = false;
|
|
125659
|
+
for (const [name, v, isUnknown] of cands) {
|
|
125660
|
+
if (v < best || v === best && isUnknown && !bestUnknown) {
|
|
125661
|
+
[limitedBy, best, bestUnknown] = [isUnknown ? "unknown" : name, v, isUnknown];
|
|
125662
|
+
}
|
|
125663
|
+
}
|
|
125664
|
+
const slots = Math.max(0, best);
|
|
125665
|
+
const report = {
|
|
125666
|
+
slots,
|
|
125667
|
+
admit: slots >= 1,
|
|
125668
|
+
limitedBy,
|
|
125669
|
+
inputs,
|
|
125670
|
+
terms: { memSlots, cpuSlots, swapCap, diskSlots },
|
|
125671
|
+
unknown,
|
|
125672
|
+
advice: ""
|
|
125673
|
+
};
|
|
125674
|
+
if (running !== undefined)
|
|
125675
|
+
report.running = running;
|
|
125676
|
+
report.advice = adviceFor(report);
|
|
125677
|
+
return report;
|
|
125678
|
+
}
|
|
125679
|
+
function adviceFor(r) {
|
|
125680
|
+
if (r.slots === 0) {
|
|
125681
|
+
return `no headroom (${r.limitedBy}): wait for a running agent to finish, then re-check`;
|
|
125682
|
+
}
|
|
125683
|
+
if (r.unknown.length) {
|
|
125684
|
+
return `could not read ${r.unknown.join(", ")}: run one agent at a time`;
|
|
125685
|
+
}
|
|
125686
|
+
return `room for ${r.slots} more agent(s) now (limited by ${r.limitedBy}); re-check before each start`;
|
|
125687
|
+
}
|
|
125688
|
+
function capacityExitCode(r) {
|
|
125689
|
+
if (r.slots < 1)
|
|
125690
|
+
return 1;
|
|
125691
|
+
return r.unknown.length ? 2 : 0;
|
|
125692
|
+
}
|
|
125693
|
+
function parseVmStat(text) {
|
|
125694
|
+
const size = /page size of (\d+) bytes/.exec(text)?.[1];
|
|
125695
|
+
const pages = (label) => {
|
|
125696
|
+
const m = new RegExp(`^${label}:\\s+(\\d+)\\.`, "m").exec(text);
|
|
125697
|
+
return m ? Number(m[1]) : null;
|
|
125698
|
+
};
|
|
125699
|
+
const free = pages("Pages free");
|
|
125700
|
+
if (!size || free === null)
|
|
125701
|
+
return null;
|
|
125702
|
+
const purgeable = pages("Pages purgeable") ?? 0;
|
|
125703
|
+
const fileBacked = pages("File-backed pages");
|
|
125704
|
+
const reclaimable = fileBacked !== null ? fileBacked : (pages("Pages speculative") ?? 0) + (pages("Pages inactive") ?? 0);
|
|
125705
|
+
return (free + reclaimable + purgeable) * Number(size);
|
|
125706
|
+
}
|
|
125707
|
+
function parseSwapUsage(text) {
|
|
125708
|
+
const grab = (k) => {
|
|
125709
|
+
const m = new RegExp(`${k} = ([\\d.]+)([KMGT])`).exec(text);
|
|
125710
|
+
if (!m)
|
|
125711
|
+
return null;
|
|
125712
|
+
return Number(m[1]) * 1024 ** ("KMGT".indexOf(m[2]) + 1);
|
|
125713
|
+
};
|
|
125714
|
+
const total = grab("total");
|
|
125715
|
+
const used = grab("used");
|
|
125716
|
+
return total === null || used === null ? null : { usedBytes: used, totalBytes: total };
|
|
125717
|
+
}
|
|
125718
|
+
var kb = (text, key) => {
|
|
125719
|
+
const m = new RegExp(`^${key}:\\s+(\\d+) kB`, "m").exec(text);
|
|
125720
|
+
return m ? Number(m[1]) * 1024 : null;
|
|
125721
|
+
};
|
|
125722
|
+
function parseMeminfo(text, cgroup) {
|
|
125723
|
+
let available = kb(text, "MemAvailable");
|
|
125724
|
+
if (available !== null && cgroup?.limit != null && cgroup.current != null) {
|
|
125725
|
+
available = Math.min(available, Math.max(0, cgroup.limit - cgroup.current));
|
|
125726
|
+
}
|
|
125727
|
+
const total = kb(text, "SwapTotal");
|
|
125728
|
+
const free = kb(text, "SwapFree");
|
|
125729
|
+
return {
|
|
125730
|
+
availableBytes: available,
|
|
125731
|
+
swapTotalBytes: total,
|
|
125732
|
+
swapUsedBytes: total !== null && free !== null ? total - free : null
|
|
125733
|
+
};
|
|
125734
|
+
}
|
|
125735
|
+
var realProbe = {
|
|
125736
|
+
platform: process.platform,
|
|
125737
|
+
readFile: (p) => {
|
|
125738
|
+
try {
|
|
125739
|
+
return readFileSync46(p, "utf8");
|
|
125740
|
+
} catch {
|
|
125741
|
+
return null;
|
|
125742
|
+
}
|
|
125743
|
+
},
|
|
125744
|
+
run: (cmd, args) => {
|
|
125745
|
+
try {
|
|
125746
|
+
return execFileSync7(cmd, args, {
|
|
125747
|
+
encoding: "utf8",
|
|
125748
|
+
timeout: 5000,
|
|
125749
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
125750
|
+
});
|
|
125751
|
+
} catch {
|
|
125752
|
+
return null;
|
|
125753
|
+
}
|
|
125754
|
+
},
|
|
125755
|
+
freeDiskBytes: (dir) => {
|
|
125756
|
+
try {
|
|
125757
|
+
const s = statfsSync(dir);
|
|
125758
|
+
return s.bavail * s.bsize;
|
|
125759
|
+
} catch {
|
|
125760
|
+
return null;
|
|
125761
|
+
}
|
|
125762
|
+
},
|
|
125763
|
+
cores: () => os.availableParallelism(),
|
|
125764
|
+
loadavg: () => os.loadavg(),
|
|
125765
|
+
freemem: () => os.freemem()
|
|
125766
|
+
};
|
|
125767
|
+
var toGB = (b) => b === null ? null : b / GB;
|
|
125768
|
+
function measure(dir, probe = realProbe) {
|
|
125769
|
+
let availableBytes = null;
|
|
125770
|
+
let swapUsed = null;
|
|
125771
|
+
let swapTotal = null;
|
|
125772
|
+
if (probe.platform === "darwin") {
|
|
125773
|
+
const vm = probe.run("vm_stat", []);
|
|
125774
|
+
availableBytes = vm ? parseVmStat(vm) : null;
|
|
125775
|
+
const sw = probe.run("sysctl", ["vm.swapusage"]);
|
|
125776
|
+
const s = sw ? parseSwapUsage(sw) : null;
|
|
125777
|
+
swapUsed = s?.usedBytes ?? null;
|
|
125778
|
+
swapTotal = s?.totalBytes ?? null;
|
|
125779
|
+
} else if (probe.platform === "linux") {
|
|
125780
|
+
const mi = probe.readFile("/proc/meminfo");
|
|
125781
|
+
if (mi) {
|
|
125782
|
+
const num = (p) => {
|
|
125783
|
+
const t = probe.readFile(p)?.trim();
|
|
125784
|
+
return t && /^\d+$/.test(t) ? Number(t) : null;
|
|
125785
|
+
};
|
|
125786
|
+
const m = parseMeminfo(mi, {
|
|
125787
|
+
limit: num("/sys/fs/cgroup/memory.max"),
|
|
125788
|
+
current: num("/sys/fs/cgroup/memory.current")
|
|
125789
|
+
});
|
|
125790
|
+
availableBytes = m.availableBytes;
|
|
125791
|
+
swapUsed = m.swapUsedBytes;
|
|
125792
|
+
swapTotal = m.swapTotalBytes;
|
|
125793
|
+
}
|
|
125794
|
+
} else if (probe.platform === "win32") {
|
|
125795
|
+
availableBytes = probe.freemem();
|
|
125796
|
+
}
|
|
125797
|
+
const load1 = probe.platform === "win32" ? null : probe.loadavg()[0] ?? null;
|
|
125798
|
+
const disk = probe.freeDiskBytes(dir);
|
|
125799
|
+
return {
|
|
125800
|
+
cores: probe.cores() || null,
|
|
125801
|
+
load1,
|
|
125802
|
+
availableGB: toGB(availableBytes),
|
|
125803
|
+
swapUsedGB: toGB(swapUsed),
|
|
125804
|
+
swapTotalGB: toGB(swapTotal),
|
|
125805
|
+
freeDiskGB: toGB(disk)
|
|
125806
|
+
};
|
|
125807
|
+
}
|
|
125808
|
+
var FLAG_TO_PARAM = [
|
|
125809
|
+
["max", "maxParallel", 0],
|
|
125810
|
+
["perAgentGb", "perAgentGB", Number.MIN_VALUE],
|
|
125811
|
+
["reserveGb", "reserveGB", 0],
|
|
125812
|
+
["perAgentCores", "perAgentCores", Number.MIN_VALUE],
|
|
125813
|
+
["reserveCores", "reserveCores", 0],
|
|
125814
|
+
["swapThreshold", "swapThreshold", 0],
|
|
125815
|
+
["swapCap", "swapCap", 0],
|
|
125816
|
+
["perAgentDiskGb", "perAgentDiskGB", Number.MIN_VALUE],
|
|
125817
|
+
["reserveDiskGb", "reserveDiskGB", 0]
|
|
125818
|
+
];
|
|
125819
|
+
function paramsFromFlags(flags) {
|
|
125820
|
+
const params = defaultParams();
|
|
125821
|
+
for (const [flag, key, min] of FLAG_TO_PARAM) {
|
|
125822
|
+
const raw = flags[flag];
|
|
125823
|
+
if (raw === undefined)
|
|
125824
|
+
continue;
|
|
125825
|
+
const n = Number(raw);
|
|
125826
|
+
if (raw.trim() === "" || !Number.isFinite(n) || n < min) {
|
|
125827
|
+
return {
|
|
125828
|
+
error: `--${flag.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)} "${raw}" is not a valid number`
|
|
125829
|
+
};
|
|
125830
|
+
}
|
|
125831
|
+
params[key] = n;
|
|
125832
|
+
}
|
|
125833
|
+
return params;
|
|
125834
|
+
}
|
|
125835
|
+
function capacityCommand(flags, probe = realProbe) {
|
|
125836
|
+
const params = paramsFromFlags(flags);
|
|
125837
|
+
let running;
|
|
125838
|
+
if (flags.running !== undefined) {
|
|
125839
|
+
const n = Number(flags.running);
|
|
125840
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
125841
|
+
return fail3(flags, `--running "${flags.running}" is not a non-negative integer`);
|
|
125842
|
+
}
|
|
125843
|
+
running = n;
|
|
125844
|
+
}
|
|
125845
|
+
if ("error" in params)
|
|
125846
|
+
return fail3(flags, params.error);
|
|
125847
|
+
const r = decideCapacity(measure(resolve24(flags.dir ?? "."), probe), params, running);
|
|
125848
|
+
const code = capacityExitCode(r);
|
|
125849
|
+
if (flags.json) {
|
|
125850
|
+
console.log(JSON.stringify(r));
|
|
125851
|
+
} else {
|
|
125852
|
+
const f = (n, u) => n === null ? chalk46.yellow("unknown") : `${n.toFixed(1)} ${u}`.trim();
|
|
125853
|
+
const i = r.inputs;
|
|
125854
|
+
console.log(` machine ${f(i.cores, "cores")}, load1 ${f(i.load1, "")}, memory ${f(i.availableGB, "GB")} available, swap ${f(i.swapUsedGB, "")}/${f(i.swapTotalGB, "GB")}, disk ${f(i.freeDiskGB, "GB")} free`);
|
|
125855
|
+
console.log(` slots ${r.slots} (memory ${r.terms.memSlots}, cpu ${r.terms.cpuSlots}, swap ${r.terms.swapCap ?? "-"}, disk ${r.terms.diskSlots}, max ${params.maxParallel}; limited by ${r.limitedBy})`);
|
|
125856
|
+
if (r.running !== undefined)
|
|
125857
|
+
console.log(` running ${r.running} (already in the load; not subtracted)`);
|
|
125858
|
+
console.log(` ${code === 0 ? chalk46.green(r.advice) : code === 1 ? chalk46.red(r.advice) : chalk46.yellow(r.advice)}`);
|
|
125859
|
+
}
|
|
125860
|
+
return code;
|
|
125861
|
+
}
|
|
125862
|
+
function fail3(flags, message) {
|
|
125863
|
+
if (flags.json)
|
|
125864
|
+
console.log(JSON.stringify({ error: { code: "bad_flag", message } }));
|
|
125865
|
+
else
|
|
125866
|
+
console.error(chalk46.red(` ${message}`));
|
|
125867
|
+
return 2;
|
|
125868
|
+
}
|
|
125869
|
+
|
|
125870
|
+
// src/commands/drift.ts
|
|
125871
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
125872
|
+
import { existsSync as existsSync41, readFileSync as readFileSync47 } from "node:fs";
|
|
125873
|
+
import { resolve as resolve25 } from "node:path";
|
|
125874
|
+
import chalk47 from "chalk";
|
|
125550
125875
|
var DRIFT_EXCLUDES = [":!.deco"];
|
|
125551
125876
|
var SHA_RE = /^[0-9a-f]{7,64}$/i;
|
|
125552
125877
|
function resolveDriftInputs(state, flags) {
|
|
@@ -125735,7 +126060,7 @@ function loadState(path) {
|
|
|
125735
126060
|
if (!existsSync41(path))
|
|
125736
126061
|
return null;
|
|
125737
126062
|
try {
|
|
125738
|
-
return JSON.parse(
|
|
126063
|
+
return JSON.parse(readFileSync47(path, "utf8"));
|
|
125739
126064
|
} catch (err) {
|
|
125740
126065
|
return { error: { code: "state_unreadable", message: `${path}: ${err.message}` } };
|
|
125741
126066
|
}
|
|
@@ -125743,7 +126068,7 @@ function loadState(path) {
|
|
|
125743
126068
|
function runDrift(flags) {
|
|
125744
126069
|
let state = null;
|
|
125745
126070
|
if (!(flags.source && flags.base)) {
|
|
125746
|
-
const loaded = loadState(
|
|
126071
|
+
const loaded = loadState(resolve25(flags.state ?? ".parity/migration.json"));
|
|
125747
126072
|
if (loaded && "error" in loaded)
|
|
125748
126073
|
return loaded;
|
|
125749
126074
|
state = loaded;
|
|
@@ -125759,7 +126084,7 @@ function driftCommand(flags) {
|
|
|
125759
126084
|
if (flags.json)
|
|
125760
126085
|
console.log(JSON.stringify({ error: r.error }));
|
|
125761
126086
|
else
|
|
125762
|
-
console.error(
|
|
126087
|
+
console.error(chalk47.red(` could not measure drift [${r.error.code}]: ${r.error.message}`));
|
|
125763
126088
|
return 2;
|
|
125764
126089
|
}
|
|
125765
126090
|
if (flags.json) {
|
|
@@ -125778,7 +126103,7 @@ function driftCommand(flags) {
|
|
|
125778
126103
|
}
|
|
125779
126104
|
|
|
125780
126105
|
// src/commands/variance.ts
|
|
125781
|
-
import
|
|
126106
|
+
import chalk48 from "chalk";
|
|
125782
126107
|
|
|
125783
126108
|
// src/diff/variance.ts
|
|
125784
126109
|
var uniq2 = (xs) => [...new Set(xs)];
|
|
@@ -125882,7 +126207,7 @@ function formatVariance(report, opts = {}) {
|
|
|
125882
126207
|
// src/commands/variance.ts
|
|
125883
126208
|
function varianceCommand(opts) {
|
|
125884
126209
|
if (opts.runIds.length < 2) {
|
|
125885
|
-
console.error(
|
|
126210
|
+
console.error(chalk48.red(" informe pelo menos 2 runs: parity variance <runIdA> <runIdB> [...]"));
|
|
125886
126211
|
return 2;
|
|
125887
126212
|
}
|
|
125888
126213
|
const budget = Number.parseFloat(opts.scoreBudget ?? "1");
|
|
@@ -125891,7 +126216,7 @@ function varianceCommand(opts) {
|
|
|
125891
126216
|
try {
|
|
125892
126217
|
runs.push(loadRun(opts.output, id));
|
|
125893
126218
|
} catch (err) {
|
|
125894
|
-
console.error(
|
|
126219
|
+
console.error(chalk48.red(` ✖ ${err.message}`));
|
|
125895
126220
|
return 2;
|
|
125896
126221
|
}
|
|
125897
126222
|
}
|
|
@@ -125900,7 +126225,7 @@ function varianceCommand(opts) {
|
|
|
125900
126225
|
console.log(JSON.stringify({ ...report, stable: isStable(report, budget), scoreBudget: budget }));
|
|
125901
126226
|
} else {
|
|
125902
126227
|
console.log("");
|
|
125903
|
-
console.log(
|
|
126228
|
+
console.log(chalk48.bold(" Score variance"));
|
|
125904
126229
|
for (const line of formatVariance(report, { scoreBudget: budget }).split(`
|
|
125905
126230
|
`)) {
|
|
125906
126231
|
console.log(` ${line}`);
|
|
@@ -125912,10 +126237,10 @@ function varianceCommand(opts) {
|
|
|
125912
126237
|
}
|
|
125913
126238
|
|
|
125914
126239
|
// src/commands/vitals.ts
|
|
125915
|
-
import { existsSync as existsSync42, readFileSync as
|
|
126240
|
+
import { existsSync as existsSync42, readFileSync as readFileSync48, writeFileSync as writeFileSync39 } from "node:fs";
|
|
125916
126241
|
import { availableParallelism } from "node:os";
|
|
125917
126242
|
import { join as join55 } from "node:path";
|
|
125918
|
-
import
|
|
126243
|
+
import chalk49 from "chalk";
|
|
125919
126244
|
import ora9 from "ora";
|
|
125920
126245
|
|
|
125921
126246
|
// src/checks/agentic-nav.ts
|
|
@@ -126223,10 +126548,10 @@ async function vitalsCommand(opts) {
|
|
|
126223
126548
|
const runId = newRunId();
|
|
126224
126549
|
const paths = createRunDir(opts.output, runId);
|
|
126225
126550
|
const t0 = Date.now();
|
|
126226
|
-
console.log(
|
|
126551
|
+
console.log(chalk49.bold(`
|
|
126227
126552
|
parity vitals ${runId}`));
|
|
126228
|
-
console.log(
|
|
126229
|
-
console.log(
|
|
126553
|
+
console.log(chalk49.dim(` prod: ${opts.prod}`));
|
|
126554
|
+
console.log(chalk49.dim(` cand: ${opts.cand}`));
|
|
126230
126555
|
const discoverSpinner = ora9("Descobrindo páginas…").start();
|
|
126231
126556
|
const pagePaths = await discoverPagePaths2(opts.prod, opts);
|
|
126232
126557
|
if (pagePaths.length === 0) {
|
|
@@ -126258,7 +126583,7 @@ async function vitalsCommand(opts) {
|
|
|
126258
126583
|
completed++;
|
|
126259
126584
|
const elapsed = ((Date.now() - t0) / 1000).toFixed(0);
|
|
126260
126585
|
const etaSec = completed > 0 ? Math.round((Date.now() - t0) / completed * (total - completed) / 1000) : 0;
|
|
126261
|
-
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ?
|
|
126586
|
+
progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk49.cyan("prod") : chalk49.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
126262
126587
|
}
|
|
126263
126588
|
});
|
|
126264
126589
|
progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
|
|
@@ -126287,7 +126612,7 @@ async function vitalsCommand(opts) {
|
|
|
126287
126612
|
}
|
|
126288
126613
|
lhCompleted++;
|
|
126289
126614
|
const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
|
|
126290
|
-
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ?
|
|
126615
|
+
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk49.cyan("prod") : chalk49.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
126291
126616
|
});
|
|
126292
126617
|
lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
|
|
126293
126618
|
}
|
|
@@ -126365,8 +126690,8 @@ async function vitalsCommand(opts) {
|
|
|
126365
126690
|
`, "utf8");
|
|
126366
126691
|
printSummary9(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
|
|
126367
126692
|
console.log("");
|
|
126368
|
-
console.log(
|
|
126369
|
-
console.log(
|
|
126693
|
+
console.log(chalk49.dim(` → ${paths.reportHtml}`));
|
|
126694
|
+
console.log(chalk49.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
|
|
126370
126695
|
console.log("");
|
|
126371
126696
|
if (opts.open) {
|
|
126372
126697
|
const { default: open } = await import("open");
|
|
@@ -126459,14 +126784,14 @@ function parseUrlList(input) {
|
|
|
126459
126784
|
if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
|
|
126460
126785
|
const path = input.replace(/^file:\/\//, "");
|
|
126461
126786
|
if (existsSync42(path)) {
|
|
126462
|
-
return
|
|
126787
|
+
return readFileSync48(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
|
|
126463
126788
|
}
|
|
126464
126789
|
}
|
|
126465
126790
|
return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
|
|
126466
126791
|
}
|
|
126467
126792
|
function printSummary9(vitals, cache, scores, opportunities, agentic) {
|
|
126468
126793
|
console.log("");
|
|
126469
|
-
console.log(
|
|
126794
|
+
console.log(chalk49.bold(" Summary:"));
|
|
126470
126795
|
console.log(` ${vitals.summary}`);
|
|
126471
126796
|
console.log(` ${cache.summary}`);
|
|
126472
126797
|
if (scores.status !== "skipped")
|
|
@@ -126530,10 +126855,10 @@ sweep.addCommand(new Command("regress").description("Run only the store's tests/
|
|
|
126530
126855
|
if (opts.json)
|
|
126531
126856
|
console.log(JSON.stringify({ url: opts.url, issues }));
|
|
126532
126857
|
else if (!issues.length)
|
|
126533
|
-
console.log(
|
|
126858
|
+
console.log(chalk50.green(" regression suite: all passed"));
|
|
126534
126859
|
else
|
|
126535
126860
|
for (const i of issues)
|
|
126536
|
-
console.log((i.inconclusive ?
|
|
126861
|
+
console.log((i.inconclusive ? chalk50.yellow : chalk50.red)(` ${i.summary}`));
|
|
126537
126862
|
process.exit(regressed ? 1 : unverified ? 2 : 0);
|
|
126538
126863
|
}));
|
|
126539
126864
|
sweep.addCommand(new Command("file").description("File an existing sweep run's findings on the Studio board (default: the newest sweep run). Merges <run>/sweeper-issues.json written by the `sweeper` agent. Dry run unless --yes.").option("--run <runId>", "Sweep run id (default: newest sweep in --output)").option("--output <dir>", "Output directory", "./parity-output").option("--board <name>", "Board: studio", "studio").option("--yes", "Actually create/update cards", false).option("--allow-automation", "File even if the board's triage column starts an agent", false).option("--min-severity <sev>", "critical|high|medium|low", "medium").option("--repo <owner/name>", "Repository to put on the cards").option("--artifacts-url <url>", "Public base URL for this run's artifacts").option("--json", "Emit JSON", false).action(async (opts) => {
|
|
@@ -126887,6 +127212,9 @@ program.command("drift").description("How far has the SOURCE repo moved since th
|
|
|
126887
127212
|
json: opts.json
|
|
126888
127213
|
}));
|
|
126889
127214
|
});
|
|
127215
|
+
program.command("capacity").description("May one more heavy agent (dev server + headless Chromium + a gate run) start on this machine now, and how many more? Measures cores, 1-minute load, available memory, swap and free disk, then slots = min(--max, memory, cpu, swap, disk) floored at 0. The load already includes running agents, so --running is echoed, never subtracted: re-run before each start. Read-only. Exits 0 admit, 1 no headroom, 2 could not measure enough to decide (an unreadable input caps at 1, never counts as headroom).").option("--dir <path>", "Directory whose volume's free disk is measured", ".").option("--running <n>", "Agents the caller already has running (echoed back; not subtracted)").option("--max <n>", "Ceiling on parallel agents (default 5)").option("--per-agent-gb <n>", "Memory one agent needs, GB (default 1.5)").option("--reserve-gb <n>", "Memory never handed to agents, GB (default 2)").option("--per-agent-cores <n>", "Cores one agent keeps busy (default 2)").option("--reserve-cores <n>", "Cores never handed to agents (default 0)").option("--swap-threshold <ratio>", "Swap used/total above which the swap cap applies (default 0.75)").option("--swap-cap <n>", "Slots allowed while swap is above the threshold (default 2)").option("--per-agent-disk-gb <n>", "Disk one agent needs, GB (default 1)").option("--reserve-disk-gb <n>", "Disk never handed to agents, GB (default 3)").option("--json", "Emit one-line JSON instead of text", false).action((opts) => {
|
|
127216
|
+
process.exit(capacityCommand(opts));
|
|
127217
|
+
});
|
|
126890
127218
|
program.command("variance").description("Measure whether a score change is attributable to the code. Run `parity run` twice against UNCHANGED code, then pass both run ids: this reports the score spread and, more usefully, WHICH checks reported differently. A check whose status flips between two runs of the same code is not measuring the code, and every score it contributes to is unfalsifiable until it is named. Exits 1 when unstable, 2 when the runs are not comparable.").argument("<runIds...>", "Two or more saved run ids of the same host pair").option("--score-budget <points>", "Score spread tolerated before calling it unstable", "1").option("--output <dir>", "Output directory holding the runs", "./parity-output").option("--json", "Emit one-line JSON instead of pretty text", false).action((runIds, opts) => {
|
|
126891
127219
|
process.exit(varianceCommand({
|
|
126892
127220
|
runIds,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.35",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|