iter(g194): 审计 json 输出命中明细

This commit is contained in:
HIsheR
2026-10-26 17:57:07 +08:00
parent 0ebd6da6a8
commit 1476a401ae
5 changed files with 13 additions and 7 deletions
+7 -1
View File
@@ -104,7 +104,13 @@ export function visualAudit(args, root) {
}
if (args.includes('--json')) {
const baseline = readBaseline(root);
console.log(JSON.stringify({ file: UI_CSS_REL, total, counts: result.counts, baseline: baseline?.counts ?? null }, null, 2));
// hits 是「哪一行踩了哪条规则」的机器可读明细:此前排查只能手写 node -e 调 scanSource,
// Agent 拿到计数却定位不到行,等于每轮都要重写一遍探针。
const hits = Object.fromEntries(KIND_META.map((meta) => [
meta.key,
(result.hits[meta.key] ?? []).map((hit) => ({ line: hit.line, prop: hit.prop, value: hit.value, hint: meta.hint })),
]));
console.log(JSON.stringify({ file: UI_CSS_REL, total, counts: result.counts, baseline: baseline?.counts ?? null, hits }, null, 2));
return 0;
}