@nodii/dev 0.6.122 → 0.6.124
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 +140 -38
- 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.124";
|
|
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
|
@@ -525,19 +525,21 @@ export async function boundaryFrames(figma, { catalog, lookupSet = designCatalog
|
|
|
525
525
|
/**
|
|
526
526
|
* MW2-38.3: the nodes of the change sets a lane's agent holds in each
|
|
527
527
|
* boundary file Dev registers as the design system. Returns
|
|
528
|
-
* { fileKey: { changeSets: [id], nodes: [nodeId] } } for
|
|
529
|
-
*
|
|
528
|
+
* { fileKey: { changeSets: [id], nodes: [nodeId] } } for every such file.
|
|
529
|
+
* hub-364: a DS file the change touches no unit of is still listed, with no
|
|
530
|
+
* nodes, so it is never checked whole for CLEAN: all of it is file debt
|
|
531
|
+
* (MW2-38.3: a whole-file DS check is never required). Dev's holderAgentId filter is checked again here, because a Dev
|
|
530
532
|
* without it ignores the parameter and lists every set on the file. Items the
|
|
531
533
|
* lane withdrew are left out; rejected items stay in until withdrawn. A
|
|
532
534
|
* removed item's node is gone from Figma, so there is nothing to check.
|
|
533
535
|
*/
|
|
534
|
-
export async function laneChangeSetNodes(request, agentId, fileKeys) {
|
|
535
|
-
if (!
|
|
536
|
+
export async function laneChangeSetNodes(request, agentId, fileKeys, templates = []) {
|
|
537
|
+
if (!fileKeys.length) return {};
|
|
536
538
|
const files = (await request("GET", "/api/v1/design/files")).data ?? [];
|
|
537
539
|
const ds = new Set(files.filter((file) => file.kind === "design-system").map((file) => file.fileKey));
|
|
538
540
|
const scoped = {};
|
|
539
541
|
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 ?? [];
|
|
542
|
+
const rows = agentId ? (await request("GET", `/api/v1/design/change-sets?holderAgentId=${encodeURIComponent(agentId)}&fileKey=${encodeURIComponent(fileKey)}&limit=500`)).data ?? [] : [];
|
|
541
543
|
const held = rows.filter((row) => row.holder?.agent?.id === agentId && row.fileKey === fileKey && row.state !== "abandoned");
|
|
542
544
|
const nodes = new Set();
|
|
543
545
|
const changeSets = [];
|
|
@@ -552,11 +554,68 @@ export async function laneChangeSetNodes(request, agentId, fileKeys) {
|
|
|
552
554
|
nodes.add(item.figmaNodeId);
|
|
553
555
|
}
|
|
554
556
|
}
|
|
555
|
-
|
|
557
|
+
// hub-324: a Code Connect template the change touches is a unit too.
|
|
558
|
+
const touched = templates.filter((unit) => unit.fileKey === fileKey);
|
|
559
|
+
for (const unit of touched) {
|
|
560
|
+
if (!nodes.has(unit.nodeId)) items.push({ nodeId: unit.nodeId, template: unit.template });
|
|
561
|
+
nodes.add(unit.nodeId);
|
|
562
|
+
}
|
|
563
|
+
scoped[fileKey] = { changeSets, nodes: [...nodes], items, templates: [...new Set(touched.map((unit) => unit.template))] };
|
|
556
564
|
}
|
|
557
565
|
return scoped;
|
|
558
566
|
}
|
|
559
567
|
|
|
568
|
+
/** A Figma link's file key and node id (`1-2` in a link, `1:2` in the API), or null. */
|
|
569
|
+
export function figmaLinkNode(url) {
|
|
570
|
+
let parsed;
|
|
571
|
+
try { parsed = new URL(url); } catch { return null; }
|
|
572
|
+
const fileKey = /^\/(?:design|file|proto)\/([^/]+)/.exec(parsed.pathname)?.[1];
|
|
573
|
+
const nodeId = parsed.searchParams.get("node-id")?.replace(/-/g, ":");
|
|
574
|
+
return fileKey && nodeId ? { fileKey, nodeId } : null;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** The repository path a template's `// source=` header names: a GitHub blob link or a plain path. */
|
|
578
|
+
const sourcePath = (source) => {
|
|
579
|
+
const blob = /^https:\/\/github\.com\/[^/]+\/[^/]+\/blob\/[^/]+\/(.+)$/.exec(source);
|
|
580
|
+
if (blob) return decodeURIComponent(blob[1]);
|
|
581
|
+
return /^[a-z]+:/i.test(source) ? null : source.replace(/^\.\//, "");
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* hub-324: the Figma nodes the change's Code Connect templates point
|
|
586
|
+
* at, as [{ fileKey, nodeId, template }]. A template (`*.figma.ts(x)`) is
|
|
587
|
+
* touched when its own file changed or when the file its `// source=` header
|
|
588
|
+
* names changed. Its `// url=` header is resolved through the repository's
|
|
589
|
+
* figma.config.json documentUrlSubstitutions. The template is the stable
|
|
590
|
+
* reference (MW8-20): the node id is read from it now, never declared. A
|
|
591
|
+
* repository without figma.config.json has no templates.
|
|
592
|
+
*/
|
|
593
|
+
export async function codeConnectUnits(cwd, paths, { exec = execFileAsync, read = (path) => readFile(join(cwd, path), "utf8") } = {}) {
|
|
594
|
+
let config;
|
|
595
|
+
try { config = JSON.parse(await read("figma.config.json")); }
|
|
596
|
+
catch (error) { if (error?.code === "ENOENT") return []; throw error; }
|
|
597
|
+
const substitutions = Object.entries(config?.codeConnect?.documentUrlSubstitutions ?? {});
|
|
598
|
+
const changed = new Set(paths);
|
|
599
|
+
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);
|
|
600
|
+
const templates = [...new Set([...listed, ...paths.filter((path) => /\.figma\.tsx?$/.test(path))])].sort();
|
|
601
|
+
const units = [];
|
|
602
|
+
const seen = new Set();
|
|
603
|
+
for (const template of templates) {
|
|
604
|
+
const text = await read(template).catch((error) => { if (error?.code === "ENOENT") return null; throw error; });
|
|
605
|
+
if (text === null) continue;
|
|
606
|
+
const header = (name) => new RegExp(`^//\\s*${name}=(\\S+)`, "m").exec(text)?.[1] ?? null;
|
|
607
|
+
const source = header("source");
|
|
608
|
+
if (!changed.has(template) && !(source && changed.has(sourcePath(source)))) continue;
|
|
609
|
+
const url = header("url");
|
|
610
|
+
if (!url) continue;
|
|
611
|
+
const node = figmaLinkNode(substitutions.reduce((link, [from, to]) => link.split(from).join(to), url));
|
|
612
|
+
if (!node || seen.has(`${node.fileKey}|${node.nodeId}`)) continue;
|
|
613
|
+
seen.add(`${node.fileKey}|${node.nodeId}`);
|
|
614
|
+
units.push({ ...node, template });
|
|
615
|
+
}
|
|
616
|
+
return units;
|
|
617
|
+
}
|
|
618
|
+
|
|
560
619
|
/**
|
|
561
620
|
* MW8-5: the Swaps in Dev, each as { ref, from, to, text }. A Swap is a Dev
|
|
562
621
|
* Swap record, or an issue titled "Swap" that carries one in its From and To
|
|
@@ -605,9 +664,9 @@ export async function swapFor(swaps, { fileKey, nodeId }, readSet) {
|
|
|
605
664
|
|
|
606
665
|
/**
|
|
607
666
|
* DEV-REV-9, design-check part: designCheck on every boundary frame; per-state
|
|
608
|
-
* frame comparison is Q-162. A boundary file
|
|
609
|
-
*
|
|
610
|
-
* as the whole file. A change-set node Figma no longer has, which a Swap in
|
|
667
|
+
* frame comparison is Q-162. A DS boundary file (MW2-38.3, from
|
|
668
|
+
* laneChangeSetNodes) is checked on the units the change touches only, never
|
|
669
|
+
* as the whole file for CLEAN; with no unit touched, nothing in it counts. A change-set node Figma no longer has, which a Swap in
|
|
611
670
|
* Dev removes (MW8-5), is not a frame: like an item recorded as removed
|
|
612
671
|
* (laneChangeSetNodes), there is nothing in Figma to check. It is left out of
|
|
613
672
|
* the frames and listed in inputs.removed with its Swap (NODII-DEV-CLI-67).
|
|
@@ -635,6 +694,17 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
635
694
|
known ??= await swaps().catch(() => []);
|
|
636
695
|
return swapFor(known, frame, cachedSet);
|
|
637
696
|
};
|
|
697
|
+
const finding = (severity, found, frame, extra = {}) => ({
|
|
698
|
+
perspective: "figma",
|
|
699
|
+
severity,
|
|
700
|
+
summary: `${found.check} at ${found.nodeId}`.slice(0, 500),
|
|
701
|
+
detail: (found.detail || found.check).slice(0, 10_000),
|
|
702
|
+
frameUrl: frameUrl(frame.fileKey, frame.nodeId ?? found.nodeId),
|
|
703
|
+
state: frame.state,
|
|
704
|
+
...extra,
|
|
705
|
+
});
|
|
706
|
+
// What each unit check returned, by file, so file debt is only what they did not.
|
|
707
|
+
const unitFound = new Map();
|
|
638
708
|
for (const frame of frames) {
|
|
639
709
|
const result = await check(frame.fileKey, frame.nodeId ? { nodes: frame.nodeId } : {});
|
|
640
710
|
const data = result.payload.data;
|
|
@@ -644,28 +714,41 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
644
714
|
removed.push({ frame, nodeId: frame.nodeId, changeSet: swap.changeSet, swap: swap.ref, url: frameUrl(frame.fileKey, frame.nodeId) });
|
|
645
715
|
continue;
|
|
646
716
|
}
|
|
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
|
-
}
|
|
717
|
+
if (!unitFound.has(frame.fileKey)) unitFound.set(frame.fileKey, new Set());
|
|
718
|
+
for (const found of [...(data.findings ?? []), ...(data.warnings ?? [])]) unitFound.get(frame.fileKey).add(`${found.check}|${found.nodeId}`);
|
|
719
|
+
for (const found of data.findings ?? []) findings.push(finding("major", found, frame));
|
|
657
720
|
// A component key Figma can't resolve is a finding, never a frame without
|
|
658
721
|
// 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
|
-
});
|
|
722
|
+
for (const warning of data.warnings ?? []) findings.push(finding("minor", warning, frame));
|
|
668
723
|
}
|
|
724
|
+
// hub-324: a DS file checked on its units is also read whole, once.
|
|
725
|
+
// A finding there that no unit check returned is file debt (scope context):
|
|
726
|
+
// recorded, never counted for CLEAN. One on a unit's own node stays a unit
|
|
727
|
+
// finding, so it still blocks (MW2-41). A failed read leaves the unit
|
|
728
|
+
// verdict as it is (a whole-file DS check is never required, MW2-38.3).
|
|
729
|
+
const fileDebt = [];
|
|
730
|
+
for (const [fileKey, scoped] of Object.entries(changeSets)) {
|
|
731
|
+
const units = new Set(scoped.nodes);
|
|
732
|
+
let data;
|
|
733
|
+
try { data = (await check(fileKey, {})).payload.data; }
|
|
734
|
+
catch (error) {
|
|
735
|
+
fileDebt.push({ fileKey, checked: false, reason: `${error?.code ?? "ERROR"}: ${error?.message ?? error}`.slice(0, 500) });
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
const seen = unitFound.get(fileKey) ?? new Set();
|
|
739
|
+
let count = 0;
|
|
740
|
+
for (const [severity, list] of [["major", data.findings ?? []], ["minor", data.warnings ?? []]])
|
|
741
|
+
for (const found of list) {
|
|
742
|
+
if (seen.has(`${found.check}|${found.nodeId}`)) continue;
|
|
743
|
+
seen.add(`${found.check}|${found.nodeId}`);
|
|
744
|
+
const frame = { fileKey, nodeId: found.nodeId, state: "default" };
|
|
745
|
+
if (units.has(found.nodeId)) { findings.push(finding(severity, found, frame)); continue; }
|
|
746
|
+
findings.push(finding(severity, found, frame, { scope: "context" }));
|
|
747
|
+
count += 1;
|
|
748
|
+
}
|
|
749
|
+
fileDebt.push({ fileKey, checked: true, findings: count });
|
|
750
|
+
}
|
|
751
|
+
const scopedFiles = Object.entries(changeSets);
|
|
669
752
|
return {
|
|
670
753
|
findings,
|
|
671
754
|
inputs: {
|
|
@@ -674,7 +757,10 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
674
757
|
libraryVersions: [...versions],
|
|
675
758
|
frameComparison: "not_built",
|
|
676
759
|
...(removed.length ? { removed: removed.map(({ frame: _frame, ...entry }) => entry) } : {}),
|
|
677
|
-
...(scopedFrames.length ? {
|
|
760
|
+
...(scopedFrames.length ? { rule: "MW2-38.3" } : {}),
|
|
761
|
+
...(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 })) } : {}),
|
|
762
|
+
...(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) })) } : {}),
|
|
763
|
+
...(fileDebt.length ? { fileDebt } : {}),
|
|
678
764
|
},
|
|
679
765
|
};
|
|
680
766
|
}
|
|
@@ -684,15 +770,18 @@ export async function figmaFindings(figma, { catalog, check, changeSets = {}, sw
|
|
|
684
770
|
// way each time: the clause (and frame and state) it cites, or for code the file.
|
|
685
771
|
// Never the wording, which changes between rounds.
|
|
686
772
|
export const findingKey = (finding) => (finding.perspective === "code" ? ["code", finding.path ?? ""] : [finding.perspective, finding.clauseId ?? "", finding.frameUrl ?? "", finding.state ?? ""]).join("|");
|
|
687
|
-
|
|
773
|
+
/** hub-324: file debt, elsewhere in a boundary file the change does not touch. */
|
|
774
|
+
export const isFileDebt = (finding) => finding.scope === "context";
|
|
775
|
+
// File debt never blocks: Dev leaves it out of CLEAN too.
|
|
776
|
+
const blockingOf = (findings) => findings.filter((finding) => finding.severity !== "minor" && !isFileDebt(finding));
|
|
688
777
|
/**
|
|
689
778
|
* NODII-DEV-CLI-74: the id lane check prints for a finding, the same in every
|
|
690
779
|
* round. Finer than the loop's key: the clause (or frame and state) and the
|
|
691
780
|
* file, so a treatment covers that finding, not every finding on its clause.
|
|
692
781
|
*/
|
|
693
782
|
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";
|
|
783
|
+
/** MW2-41: a code-check finding and a blocker are only ever fixed (Dev refuses the same). File debt is left as found. */
|
|
784
|
+
export const treatable = (finding) => finding.perspective !== "code" && finding.severity !== "blocker" && !isFileDebt(finding);
|
|
696
785
|
/** A finding with a P-21 treatment applied when one names it and it may be treated; else as it was. */
|
|
697
786
|
export function treatFinding(finding, treatments = {}) {
|
|
698
787
|
const treated = treatments[findingId(finding)];
|
|
@@ -745,7 +834,8 @@ export function runBody(checks, current) {
|
|
|
745
834
|
appliedPatches: [],
|
|
746
835
|
unresolvedProposals: [],
|
|
747
836
|
reviewerErrors: checks.flatMap((x) => x.reviewerErrors),
|
|
748
|
-
|
|
837
|
+
// File debt last, so a cap never drops a finding that counts.
|
|
838
|
+
findings: [...checks.flatMap((x) => x.findings.filter((f) => !isFileDebt(f))), ...checks.flatMap((x) => x.findings.filter(isFileDebt))].slice(0, 500),
|
|
749
839
|
checks: checks.map(({ check, outcome, iterationCount, reviewerErrors: errors, inputs, notRequired }) => ({ check, outcome, iterationCount, reviewerErrors: errors, inputs, ...(notRequired ? { notRequired } : {}) })),
|
|
750
840
|
via: "nodii-dev",
|
|
751
841
|
};
|
|
@@ -760,7 +850,7 @@ const errorCheck = (check, error, iterationCount, inputs) => ({ check, outcome:
|
|
|
760
850
|
* caller saves the round (saveLoop) once it is kept: still looping, or
|
|
761
851
|
* recorded; a run that records nothing leaves the loop where it was.
|
|
762
852
|
*/
|
|
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 }) {
|
|
853
|
+
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
854
|
const critical = flags.critical === true;
|
|
765
855
|
const maxIterations = flags["max-iterations"] === undefined ? MAX_ITERATIONS : Number(flags["max-iterations"]);
|
|
766
856
|
if (!Number.isInteger(maxIterations) || maxIterations < 1 || maxIterations > 100)
|
|
@@ -822,8 +912,13 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
|
|
|
822
912
|
} else {
|
|
823
913
|
const boundary = freeze.boundaries.figma;
|
|
824
914
|
try {
|
|
915
|
+
let touched;
|
|
916
|
+
try { touched = await templates(cwd, changed.paths); }
|
|
917
|
+
catch (error) {
|
|
918
|
+
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)`);
|
|
919
|
+
}
|
|
825
920
|
let changeSets;
|
|
826
|
-
try { changeSets = await laneChangeSetNodes(request, lane.agentId, boundary.map((file) => file.fileKey)); }
|
|
921
|
+
try { changeSets = await laneChangeSetNodes(request, lane.agentId, boundary.map((file) => file.fileKey), touched); }
|
|
827
922
|
catch (error) {
|
|
828
923
|
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
924
|
}
|
|
@@ -886,9 +981,15 @@ export function checkReviewChecks(body) {
|
|
|
886
981
|
}
|
|
887
982
|
|
|
888
983
|
const counts = (findings) => {
|
|
889
|
-
const n = (severity) => findings.filter((x) => x.severity === severity && x.disposition === "unresolved").length;
|
|
890
|
-
|
|
984
|
+
const n = (severity) => findings.filter((x) => x.severity === severity && x.disposition === "unresolved" && !isFileDebt(x)).length;
|
|
985
|
+
const debt = findings.filter(isFileDebt).length;
|
|
986
|
+
return `${n("blocker")} blocker, ${n("major")} major, ${n("minor")} minor${debt ? `, ${debt} file debt` : ""}`;
|
|
891
987
|
};
|
|
988
|
+
const debtLines = (x) => [
|
|
989
|
+
...(x.inputs?.fileDebt ?? []).map((file) => (file.checked
|
|
990
|
+
? ` file debt: ${file.findings} finding(s) elsewhere in ${file.fileKey}, outside the units this change touches; recorded, not counted for CLEAN`
|
|
991
|
+
: ` file debt: ${file.fileKey} could not be read whole (${file.reason}); the units' verdict stands`)),
|
|
992
|
+
];
|
|
892
993
|
/** A treatment's citation as one phrase: DEC-0085 or issue KEY. */
|
|
893
994
|
export const citationText = (cite) => (!cite ? "-" : cite.decision ?? `issue ${cite.issue}`);
|
|
894
995
|
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 +999,7 @@ export function checkLines(checks, maxIterations) {
|
|
|
898
999
|
return checks.flatMap((x) => [
|
|
899
1000
|
`${x.check}\t${x.outcome ?? `NOT CLEAN, round ${x.iterationCount} of ${maxIterations}`}\t${x.iterationCount} iteration(s)\t${counts(x.findings)}`,
|
|
900
1001
|
...x.reviewerErrors.map((error) => ` error: ${error}`),
|
|
901
|
-
...x.findings.filter((f) => f.disposition !== "fixed").map(findingLine),
|
|
1002
|
+
...x.findings.filter((f) => f.disposition !== "fixed" && !isFileDebt(f)).map(findingLine),
|
|
1003
|
+
...debtLines(x),
|
|
902
1004
|
]);
|
|
903
1005
|
}
|