@nodii/dev 0.6.122 → 0.6.123
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/core.js +1 -1
- package/dist/lanes.js +3 -2
- package/dist/review.js +133 -33
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.123";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/lanes.js
CHANGED
|
@@ -812,6 +812,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
812
812
|
const run = await runLaneCheck(ref, flags, {
|
|
813
813
|
request, lane, freeze, current, cwd: context.worktree, store,
|
|
814
814
|
...(checkDeps.exceptions ? { exceptions: checkDeps.exceptions } : {}),
|
|
815
|
+
...(checkDeps.templates ? { templates: checkDeps.templates } : {}),
|
|
815
816
|
diff,
|
|
816
817
|
deltaGather: checkDeps.deltaGather ?? ((key, paths, pick) => laneCommand("gather", [key], deltaGatherFlags(paths, pick), deps)),
|
|
817
818
|
catalog: checkDeps.catalog ?? catalog,
|
|
@@ -1105,7 +1106,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1105
1106
|
if (missing.length) throw new CliError("REVIEW_FINDING_NOT_FOUND", `${ref}: the last lane check round (head ${last.head}) has no finding ${missing.map((x) => x.id).join(", ")}; nothing was treated.`, 1);
|
|
1106
1107
|
// MW2-41: Dev refuses these too; saying so here saves a round trip.
|
|
1107
1108
|
const fixOnly = items.filter((x) => !treatable(found.get(x.id)));
|
|
1108
|
-
if (fixOnly.length) throw new CliError("REVIEW_TREATMENT_FORBIDDEN", `${ref}: ${fixOnly.map((x) => x.id).join(", ")} ${fixOnly.length === 1 ? "is a code-check finding or
|
|
1109
|
+
if (fixOnly.length) throw new CliError("REVIEW_TREATMENT_FORBIDDEN", `${ref}: ${fixOnly.map((x) => x.id).join(", ")} ${fixOnly.length === 1 ? "is a code-check finding, a blocker or file debt" : "are code-check findings, blockers or file debt"}: the first two may only be fixed (MW2-41), and file debt is not counted for CLEAN, so it needs no treatment; nothing was treated.`, 1);
|
|
1109
1110
|
const generatedPaths = await repoGeneratedPaths(request, context.repo);
|
|
1110
1111
|
const committed = await (checkDeps.committed ?? worktreeCommitted)(context.worktree);
|
|
1111
1112
|
const digest = diffDigest((await (checkDeps.diff ?? laneDiff)(context.worktree, { generatedPaths })).text);
|
|
@@ -1160,7 +1161,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1160
1161
|
...(run.checks ?? []).map((check) => ` check ${check.check}\t${check.outcome}\t${check.iterationCount} iteration(s)${check.reviewerErrors?.length ? `\t${check.reviewerErrors.length} reviewer error(s)` : ""}`),
|
|
1161
1162
|
...run.findings.map(
|
|
1162
1163
|
(finding) =>
|
|
1163
|
-
` ${finding.severity}\t${finding.perspective}\t${finding.perspective === "figma" ? `${finding.frameUrl ?? "-"} [${finding.state ?? "-"}]` : finding.clauseId ?? "-"}\t${finding.summary}${finding.missedTrigger ? "\tMISSED_TRIGGER" : ""}${finding.disposition && finding.disposition !== "unresolved" ? `\t${finding.disposition}` : ""}${finding.treatmentKind ? ` (${finding.treatmentKind} ${finding.treatmentRef}, by ${finding.treatedByLabel})` : ""}`,
|
|
1164
|
+
` ${finding.severity}\t${finding.perspective}\t${finding.perspective === "figma" ? `${finding.frameUrl ?? "-"} [${finding.state ?? "-"}]` : finding.clauseId ?? "-"}\t${finding.summary}${finding.missedTrigger ? "\tMISSED_TRIGGER" : ""}${finding.scope === "context" ? "\tfile debt" : ""}${finding.disposition && finding.disposition !== "unresolved" ? `\t${finding.disposition}` : ""}${finding.treatmentKind ? ` (${finding.treatmentKind} ${finding.treatmentRef}, by ${finding.treatedByLabel})` : ""}`,
|
|
1164
1165
|
),
|
|
1165
1166
|
].join("\n");
|
|
1166
1167
|
})
|
package/dist/review.js
CHANGED
|
@@ -531,13 +531,13 @@ export async function boundaryFrames(figma, { catalog, lookupSet = designCatalog
|
|
|
531
531
|
* lane withdrew are left out; rejected items stay in until withdrawn. A
|
|
532
532
|
* removed item's node is gone from Figma, so there is nothing to check.
|
|
533
533
|
*/
|
|
534
|
-
export async function laneChangeSetNodes(request, agentId, fileKeys) {
|
|
535
|
-
if (!
|
|
534
|
+
export async function laneChangeSetNodes(request, agentId, fileKeys, templates = []) {
|
|
535
|
+
if (!fileKeys.length || (!agentId && !templates.length)) return {};
|
|
536
536
|
const files = (await request("GET", "/api/v1/design/files")).data ?? [];
|
|
537
537
|
const ds = new Set(files.filter((file) => file.kind === "design-system").map((file) => file.fileKey));
|
|
538
538
|
const scoped = {};
|
|
539
539
|
for (const fileKey of [...new Set(fileKeys)].filter((key) => ds.has(key))) {
|
|
540
|
-
const rows = (await request("GET", `/api/v1/design/change-sets?holderAgentId=${encodeURIComponent(agentId)}&fileKey=${encodeURIComponent(fileKey)}&limit=500`)).data ?? [];
|
|
540
|
+
const rows = agentId ? (await request("GET", `/api/v1/design/change-sets?holderAgentId=${encodeURIComponent(agentId)}&fileKey=${encodeURIComponent(fileKey)}&limit=500`)).data ?? [] : [];
|
|
541
541
|
const held = rows.filter((row) => row.holder?.agent?.id === agentId && row.fileKey === fileKey && row.state !== "abandoned");
|
|
542
542
|
const nodes = new Set();
|
|
543
543
|
const changeSets = [];
|
|
@@ -552,11 +552,68 @@ export async function laneChangeSetNodes(request, agentId, fileKeys) {
|
|
|
552
552
|
nodes.add(item.figmaNodeId);
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
// hub-324: a Code Connect template the change touches is a unit too.
|
|
556
|
+
const touched = templates.filter((unit) => unit.fileKey === fileKey);
|
|
557
|
+
for (const unit of touched) {
|
|
558
|
+
if (!nodes.has(unit.nodeId)) items.push({ nodeId: unit.nodeId, template: unit.template });
|
|
559
|
+
nodes.add(unit.nodeId);
|
|
560
|
+
}
|
|
561
|
+
if (nodes.size) scoped[fileKey] = { changeSets, nodes: [...nodes], items, templates: [...new Set(touched.map((unit) => unit.template))] };
|
|
556
562
|
}
|
|
557
563
|
return scoped;
|
|
558
564
|
}
|
|
559
565
|
|
|
566
|
+
/** A Figma link's file key and node id (`1-2` in a link, `1:2` in the API), or null. */
|
|
567
|
+
export function figmaLinkNode(url) {
|
|
568
|
+
let parsed;
|
|
569
|
+
try { parsed = new URL(url); } catch { return null; }
|
|
570
|
+
const fileKey = /^\/(?:design|file|proto)\/([^/]+)/.exec(parsed.pathname)?.[1];
|
|
571
|
+
const nodeId = parsed.searchParams.get("node-id")?.replace(/-/g, ":");
|
|
572
|
+
return fileKey && nodeId ? { fileKey, nodeId } : null;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** The repository path a template's `// source=` header names: a GitHub blob link or a plain path. */
|
|
576
|
+
const sourcePath = (source) => {
|
|
577
|
+
const blob = /^https:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[^/]+\/(.+)$/.exec(source);
|
|
578
|
+
if (blob) return decodeURIComponent(blob[1]);
|
|
579
|
+
return /^[a-z]+:/i.test(source) ? null : source.replace(/^\.\//, "");
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* hub-324: the Figma nodes the change's Code Connect templates point
|
|
584
|
+
* at, as [{ fileKey, nodeId, template }]. A template (`*.figma.ts(x)`) is
|
|
585
|
+
* touched when its own file changed or when the file its `// source=` header
|
|
586
|
+
* names changed. Its `// url=` header is resolved through the repository's
|
|
587
|
+
* figma.config.json documentUrlSubstitutions. The template is the stable
|
|
588
|
+
* reference (MW8-20): the node id is read from it now, never declared. A
|
|
589
|
+
* repository without figma.config.json has no templates.
|
|
590
|
+
*/
|
|
591
|
+
export async function codeConnectUnits(cwd, paths, { exec = execFileAsync, read = (path) => readFile(join(cwd, path), "utf8") } = {}) {
|
|
592
|
+
let config;
|
|
593
|
+
try { config = JSON.parse(await read("figma.config.json")); }
|
|
594
|
+
catch (error) { if (error?.code === "ENOENT") return []; throw error; }
|
|
595
|
+
const substitutions = Object.entries(config?.codeConnect?.documentUrlSubstitutions ?? {});
|
|
596
|
+
const changed = new Set(paths);
|
|
597
|
+
const listed = (await exec("git", ["-C", cwd, "ls-files", "-z", "--", "*.figma.ts", "*.figma.tsx"], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 })).stdout.split("\0").filter(Boolean);
|
|
598
|
+
const templates = [...new Set([...listed, ...paths.filter((path) => /\.figma\.tsx?$/.test(path))])].sort();
|
|
599
|
+
const units = [];
|
|
600
|
+
const seen = new Set();
|
|
601
|
+
for (const template of templates) {
|
|
602
|
+
const text = await read(template).catch((error) => { if (error?.code === "ENOENT") return null; throw error; });
|
|
603
|
+
if (text === null) continue;
|
|
604
|
+
const header = (name) => new RegExp(`^//\\s*${name}=(\\S+)`, "m").exec(text)?.[1] ?? null;
|
|
605
|
+
const source = header("source");
|
|
606
|
+
if (!changed.has(template) && !(source && changed.has(sourcePath(source)))) continue;
|
|
607
|
+
const url = header("url");
|
|
608
|
+
if (!url) continue;
|
|
609
|
+
const node = figmaLinkNode(substitutions.reduce((link, [from, to]) => link.split(from).join(to), url));
|
|
610
|
+
if (!node || seen.has(`${node.fileKey}|${node.nodeId}`)) continue;
|
|
611
|
+
seen.add(`${node.fileKey}|${node.nodeId}`);
|
|
612
|
+
units.push({ ...node, template });
|
|
613
|
+
}
|
|
614
|
+
return units;
|
|
615
|
+
}
|
|
616
|
+
|
|
560
617
|
/**
|
|
561
618
|
* MW8-5: the Swaps in Dev, each as { ref, from, to, text }. A Swap is a Dev
|
|
562
619
|
* Swap record, or an issue titled "Swap" that carries one in its From and To
|
|
@@ -635,6 +692,17 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
635
692
|
known ??= await swaps().catch(() => []);
|
|
636
693
|
return swapFor(known, frame, cachedSet);
|
|
637
694
|
};
|
|
695
|
+
const finding = (severity, found, frame, extra = {}) => ({
|
|
696
|
+
perspective: "figma",
|
|
697
|
+
severity,
|
|
698
|
+
summary: `${found.check} at ${found.nodeId}`.slice(0, 500),
|
|
699
|
+
detail: (found.detail || found.check).slice(0, 10_000),
|
|
700
|
+
frameUrl: frameUrl(frame.fileKey, frame.nodeId ?? found.nodeId),
|
|
701
|
+
state: frame.state,
|
|
702
|
+
...extra,
|
|
703
|
+
});
|
|
704
|
+
// What each unit check returned, by file, so file debt is only what they did not.
|
|
705
|
+
const unitFound = new Map();
|
|
638
706
|
for (const frame of frames) {
|
|
639
707
|
const result = await check(frame.fileKey, frame.nodeId ? { nodes: frame.nodeId } : {});
|
|
640
708
|
const data = result.payload.data;
|
|
@@ -644,28 +712,41 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
644
712
|
removed.push({ frame, nodeId: frame.nodeId, changeSet: swap.changeSet, swap: swap.ref, url: frameUrl(frame.fileKey, frame.nodeId) });
|
|
645
713
|
continue;
|
|
646
714
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
severity: "major",
|
|
651
|
-
summary: `${finding.check} at ${finding.nodeId}`.slice(0, 500),
|
|
652
|
-
detail: (finding.detail || finding.check).slice(0, 10_000),
|
|
653
|
-
frameUrl: frameUrl(frame.fileKey, frame.nodeId ?? finding.nodeId),
|
|
654
|
-
state: frame.state,
|
|
655
|
-
});
|
|
656
|
-
}
|
|
715
|
+
if (!unitFound.has(frame.fileKey)) unitFound.set(frame.fileKey, new Set());
|
|
716
|
+
for (const found of [...(data.findings ?? []), ...(data.warnings ?? [])]) unitFound.get(frame.fileKey).add(`${found.check}|${found.nodeId}`);
|
|
717
|
+
for (const found of data.findings ?? []) findings.push(finding("major", found, frame));
|
|
657
718
|
// A component key Figma can't resolve is a finding, never a frame without
|
|
658
719
|
// its url (NODII-DEV-CLI-66). Minor: nothing was checked against a main.
|
|
659
|
-
for (const warning of data.warnings ?? [])
|
|
660
|
-
findings.push({
|
|
661
|
-
perspective: "figma",
|
|
662
|
-
severity: "minor",
|
|
663
|
-
summary: `${warning.check} at ${warning.nodeId}`.slice(0, 500),
|
|
664
|
-
detail: (warning.detail || warning.check).slice(0, 10_000),
|
|
665
|
-
frameUrl: frameUrl(frame.fileKey, frame.nodeId ?? warning.nodeId),
|
|
666
|
-
state: frame.state,
|
|
667
|
-
});
|
|
720
|
+
for (const warning of data.warnings ?? []) findings.push(finding("minor", warning, frame));
|
|
668
721
|
}
|
|
722
|
+
// hub-324: a DS file checked on its units is also read whole, once.
|
|
723
|
+
// A finding there that no unit check returned is file debt (scope context):
|
|
724
|
+
// recorded, never counted for CLEAN. One on a unit's own node stays a unit
|
|
725
|
+
// finding, so it still blocks (MW2-41). A failed read leaves the unit
|
|
726
|
+
// verdict as it is (a whole-file DS check is never required, MW2-38.3).
|
|
727
|
+
const fileDebt = [];
|
|
728
|
+
for (const [fileKey, scoped] of Object.entries(changeSets)) {
|
|
729
|
+
const units = new Set(scoped.nodes);
|
|
730
|
+
let data;
|
|
731
|
+
try { data = (await check(fileKey, {})).payload.data; }
|
|
732
|
+
catch (error) {
|
|
733
|
+
fileDebt.push({ fileKey, checked: false, reason: `${error?.code ?? "ERROR"}: ${error?.message ?? error}`.slice(0, 500) });
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const seen = unitFound.get(fileKey) ?? new Set();
|
|
737
|
+
let count = 0;
|
|
738
|
+
for (const [severity, list] of [["major", data.findings ?? []], ["minor", data.warnings ?? []]])
|
|
739
|
+
for (const found of list) {
|
|
740
|
+
if (seen.has(`${found.check}|${found.nodeId}`)) continue;
|
|
741
|
+
seen.add(`${found.check}|${found.nodeId}`);
|
|
742
|
+
const frame = { fileKey, nodeId: found.nodeId, state: "default" };
|
|
743
|
+
if (units.has(found.nodeId)) { findings.push(finding(severity, found, frame)); continue; }
|
|
744
|
+
findings.push(finding(severity, found, frame, { scope: "context" }));
|
|
745
|
+
count += 1;
|
|
746
|
+
}
|
|
747
|
+
fileDebt.push({ fileKey, checked: true, findings: count });
|
|
748
|
+
}
|
|
749
|
+
const scopedFiles = Object.entries(changeSets);
|
|
669
750
|
return {
|
|
670
751
|
findings,
|
|
671
752
|
inputs: {
|
|
@@ -674,7 +755,10 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
674
755
|
libraryVersions: [...versions],
|
|
675
756
|
frameComparison: "not_built",
|
|
676
757
|
...(removed.length ? { removed: removed.map(({ frame: _frame, ...entry }) => entry) } : {}),
|
|
677
|
-
...(scopedFrames.length ? {
|
|
758
|
+
...(scopedFrames.length ? { rule: "MW2-38.3" } : {}),
|
|
759
|
+
...(scopedFiles.some(([, scoped]) => scoped.changeSets.length) ? { changeSets: scopedFiles.filter(([, scoped]) => scoped.changeSets.length).map(([fileKey, scoped]) => ({ fileKey, ids: scoped.changeSets, nodes: (scoped.items ?? []).filter((x) => x.changeSet).length || scoped.nodes.length })) } : {}),
|
|
760
|
+
...(scopedFiles.some(([, scoped]) => scoped.templates?.length) ? { templates: scopedFiles.filter(([, scoped]) => scoped.templates?.length).map(([fileKey, scoped]) => ({ fileKey, paths: scoped.templates, nodes: (scoped.items ?? []).filter((x) => x.template).map((x) => x.nodeId) })) } : {}),
|
|
761
|
+
...(fileDebt.length ? { fileDebt } : {}),
|
|
678
762
|
},
|
|
679
763
|
};
|
|
680
764
|
}
|
|
@@ -684,15 +768,18 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
684
768
|
// way each time: the clause (and frame and state) it cites, or for code the file.
|
|
685
769
|
// Never the wording, which changes between rounds.
|
|
686
770
|
export const findingKey = (finding) => (finding.perspective === "code" ? ["code", finding.path ?? ""] : [finding.perspective, finding.clauseId ?? "", finding.frameUrl ?? "", finding.state ?? ""]).join("|");
|
|
687
|
-
|
|
771
|
+
/** hub-324: file debt, elsewhere in a boundary file the change does not touch. */
|
|
772
|
+
export const isFileDebt = (finding) => finding.scope === "context";
|
|
773
|
+
// File debt never blocks: Dev leaves it out of CLEAN too.
|
|
774
|
+
const blockingOf = (findings) => findings.filter((finding) => finding.severity !== "minor" && !isFileDebt(finding));
|
|
688
775
|
/**
|
|
689
776
|
* NODII-DEV-CLI-74: the id lane check prints for a finding, the same in every
|
|
690
777
|
* round. Finer than the loop's key: the clause (or frame and state) and the
|
|
691
778
|
* file, so a treatment covers that finding, not every finding on its clause.
|
|
692
779
|
*/
|
|
693
780
|
export const findingId = (finding) => `f-${createHash("sha256").update(`${findingKey(finding)}|${finding.path ?? ""}`).digest("hex").slice(0, 8)}`;
|
|
694
|
-
/** MW2-41: a code-check finding and a blocker are only ever fixed (Dev refuses the same). */
|
|
695
|
-
export const treatable = (finding) => finding.perspective !== "code" && finding.severity !== "blocker";
|
|
781
|
+
/** MW2-41: a code-check finding and a blocker are only ever fixed (Dev refuses the same). File debt is left as found. */
|
|
782
|
+
export const treatable = (finding) => finding.perspective !== "code" && finding.severity !== "blocker" && !isFileDebt(finding);
|
|
696
783
|
/** A finding with a P-21 treatment applied when one names it and it may be treated; else as it was. */
|
|
697
784
|
export function treatFinding(finding, treatments = {}) {
|
|
698
785
|
const treated = treatments[findingId(finding)];
|
|
@@ -745,7 +832,8 @@ export function runBody(checks, current) {
|
|
|
745
832
|
appliedPatches: [],
|
|
746
833
|
unresolvedProposals: [],
|
|
747
834
|
reviewerErrors: checks.flatMap((x) => x.reviewerErrors),
|
|
748
|
-
|
|
835
|
+
// File debt last, so a cap never drops a finding that counts.
|
|
836
|
+
findings: [...checks.flatMap((x) => x.findings.filter((f) => !isFileDebt(f))), ...checks.flatMap((x) => x.findings.filter(isFileDebt))].slice(0, 500),
|
|
749
837
|
checks: checks.map(({ check, outcome, iterationCount, reviewerErrors: errors, inputs, notRequired }) => ({ check, outcome, iterationCount, reviewerErrors: errors, inputs, ...(notRequired ? { notRequired } : {}) })),
|
|
750
838
|
via: "nodii-dev",
|
|
751
839
|
};
|
|
@@ -760,7 +848,7 @@ const errorCheck = (check, error, iterationCount, inputs) => ({ check, outcome:
|
|
|
760
848
|
* caller saves the round (saveLoop) once it is kept: still looping, or
|
|
761
849
|
* recorded; a run that records nothing leaves the loop where it was.
|
|
762
850
|
*/
|
|
763
|
-
export async function runLaneCheck(ref, flags, { request, lane, freeze, current, cwd, store, diff, deltaGather, catalog, designCheck, gate, reviewer = runReviewer, picker = pickByAgent, now, exceptions = exceptionFiles }) {
|
|
851
|
+
export async function runLaneCheck(ref, flags, { request, lane, freeze, current, cwd, store, diff, deltaGather, catalog, designCheck, gate, reviewer = runReviewer, picker = pickByAgent, now, exceptions = exceptionFiles, templates = codeConnectUnits }) {
|
|
764
852
|
const critical = flags.critical === true;
|
|
765
853
|
const maxIterations = flags["max-iterations"] === undefined ? MAX_ITERATIONS : Number(flags["max-iterations"]);
|
|
766
854
|
if (!Number.isInteger(maxIterations) || maxIterations < 1 || maxIterations > 100)
|
|
@@ -822,8 +910,13 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
|
|
|
822
910
|
} else {
|
|
823
911
|
const boundary = freeze.boundaries.figma;
|
|
824
912
|
try {
|
|
913
|
+
let touched;
|
|
914
|
+
try { touched = await templates(cwd, changed.paths); }
|
|
915
|
+
catch (error) {
|
|
916
|
+
throw new ReviewerError(UNAVAILABLE, `the Code Connect templates this change touches could not be read (${error?.code ?? "ERROR"}: ${error?.message ?? error}), so the Figma check cannot be scoped to their nodes (hub-324)`);
|
|
917
|
+
}
|
|
825
918
|
let changeSets;
|
|
826
|
-
try { changeSets = await laneChangeSetNodes(request, lane.agentId, boundary.map((file) => file.fileKey)); }
|
|
919
|
+
try { changeSets = await laneChangeSetNodes(request, lane.agentId, boundary.map((file) => file.fileKey), touched); }
|
|
827
920
|
catch (error) {
|
|
828
921
|
throw new ReviewerError(UNAVAILABLE, `the lane's change sets could not be read from Dev (${error?.code ?? "ERROR"}: ${error?.message ?? error}), so the Figma check cannot be scoped to their nodes (MW2-38.3) and did not fall back to the whole file`);
|
|
829
922
|
}
|
|
@@ -886,9 +979,15 @@ export function checkReviewChecks(body) {
|
|
|
886
979
|
}
|
|
887
980
|
|
|
888
981
|
const counts = (findings) => {
|
|
889
|
-
const n = (severity) => findings.filter((x) => x.severity === severity && x.disposition === "unresolved").length;
|
|
890
|
-
|
|
982
|
+
const n = (severity) => findings.filter((x) => x.severity === severity && x.disposition === "unresolved" && !isFileDebt(x)).length;
|
|
983
|
+
const debt = findings.filter(isFileDebt).length;
|
|
984
|
+
return `${n("blocker")} blocker, ${n("major")} major, ${n("minor")} minor${debt ? `, ${debt} file debt` : ""}`;
|
|
891
985
|
};
|
|
986
|
+
const debtLines = (x) => [
|
|
987
|
+
...(x.inputs?.fileDebt ?? []).map((file) => (file.checked
|
|
988
|
+
? ` file debt: ${file.findings} finding(s) elsewhere in ${file.fileKey}, outside the units this change touches; recorded, not counted for CLEAN`
|
|
989
|
+
: ` file debt: ${file.fileKey} could not be read whole (${file.reason}); the units' verdict stands`)),
|
|
990
|
+
];
|
|
892
991
|
/** A treatment's citation as one phrase: DEC-0085 or issue KEY. */
|
|
893
992
|
export const citationText = (cite) => (!cite ? "-" : cite.decision ?? `issue ${cite.issue}`);
|
|
894
993
|
const findingLine = (x) => ` ${x.severity}\t${x.clauseId ?? (x.frameUrl ? `${x.frameUrl} [${x.state}]` : "-")}\t${x.path ? `${x.path}${x.line ? `:${x.line}` : ""}\t` : ""}${x.summary}\t${findingId(x)}${TREATED.includes(x.disposition) ? `\t${x.disposition}: ${citationText(x.treatment)}` : ""}`;
|
|
@@ -898,6 +997,7 @@ export function checkLines(checks, maxIterations) {
|
|
|
898
997
|
return checks.flatMap((x) => [
|
|
899
998
|
`${x.check}\t${x.outcome ?? `NOT CLEAN, round ${x.iterationCount} of ${maxIterations}`}\t${x.iterationCount} iteration(s)\t${counts(x.findings)}`,
|
|
900
999
|
...x.reviewerErrors.map((error) => ` error: ${error}`),
|
|
901
|
-
...x.findings.filter((f) => f.disposition !== "fixed").map(findingLine),
|
|
1000
|
+
...x.findings.filter((f) => f.disposition !== "fixed" && !isFileDebt(f)).map(findingLine),
|
|
1001
|
+
...debtLines(x),
|
|
902
1002
|
]);
|
|
903
1003
|
}
|