Files
writing-agent/tools/st-request-diff/dump-ext.mjs
T
chenmoranzhi 1a5ef3b2bc 抓包对比工具补一批一次性脚本:拆预设、对请求、跑 A/B 与拒答抽样。
这些脚本都是我对着酒馆真实请求手工核对用的,留在仓库里方便下次重跑;跑出来的本地数据目录含接口 key,已经写进忽略规则。
2026-10-26 01:09:56 +08:00

23 lines
1.0 KiB
JavaScript

// 打印预设 extensions 子树的结构(键 + 类型/长度),找脚本挂在哪
// 用法: node dump-ext.mjs <preset.json>
import { readFileSync } from "node:fs";
const preset = JSON.parse(readFileSync(process.argv[2], "utf8"));
function show(node, pathParts, depth) {
if (node == null || depth > 4) return;
if (Array.isArray(node)) {
console.log(pathParts.join(".") + " [数组 " + node.length + "]");
node.slice(0, 4).forEach((v, i) => show(v, [...pathParts, String(i)], depth + 1));
return;
}
if (typeof node === "object") {
for (const [k, v] of Object.entries(node)) {
const p = [...pathParts, k];
if (v == null) { console.log(p.join(".") + " = null"); continue; }
if (typeof v === "string") { console.log(p.join(".") + " = 字符串(" + v.length + ") " + JSON.stringify(v.slice(0, 60))); continue; }
if (typeof v !== "object") { console.log(p.join(".") + " = " + JSON.stringify(v)); continue; }
show(v, p, depth + 1);
}
}
}
show(preset.extensions, ["extensions"], 0);