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;
}
+1 -1
View File
@@ -19,7 +19,7 @@
"ua style:注释规范门禁(导出必须 /*** ***/、接口字段行尾注释、行注释中文),违规退出码 1",
"ua verify:清单一致性门禁(id 唯一 / exports 对应 / props 必带 n t d / steps≥3 / demo 锚点存在 / 视觉回归抽查清单六组件各 ≥3 条且五维度齐全)",
"ua commit-lint <文件|message>:提交信息门禁(type 枚举 / scope 规则 / subject 中文祈使 ≤50 字符),规范见 COMMITTING.md,违规退出码 1",
"ua audit:visual [--json|--baseline]:视觉漂移门禁,统计皮肤包里各类硬编码视觉字面量(字号/动效时长/阴影/圆角/焦点环/内距/控件高度/字重/行高/层级/边框色)并与 .ua/visual-baseline.json 棘轮比对,超基线退出码 1;--baseline 重写基线,--json 出机器可读计数",
"ua audit:visual [--json|--baseline]:视觉漂移门禁,统计皮肤包里各类硬编码视觉字面量(字号/动效时长/阴影/圆角/焦点环/内距/控件高度/字重/行高/层级/边框色)并与 .ua/visual-baseline.json 棘轮比对,超基线退出码 1;--baseline 重写基线,--json 出机器可读计数与每类命中行号(line / prop / value / hint,Agent 可直接定位)",
"ua mcp:零依赖 stdio MCP server,暴露 list_components / get_component / search_components / get_tokens / list_recipes / get_recipe"
],
"keyTypes": [