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

17 lines
915 B
JavaScript

// 精确判断:preset 条目中段(避开样板头)是否出现在 tool description 里
import { readFileSync } from "node:fs";
const body = JSON.parse(JSON.parse(readFileSync(process.argv[2], "utf8")).body);
const d = (body.tools || []).map((t) => String((t.function || t).description || "")).join("\n") + "\n" +
JSON.stringify((body.tools || []).map((t) => (t.function || t).parameters || {}));
const norm = (s) => String(s || "").replace(/\s+/g, " ").trim();
const pool = norm(d);
const preset = JSON.parse(readFileSync(process.argv[3], "utf8"));
for (const p of preset.prompts || []) {
const c = norm(p.content);
if (c.length < 200) continue;
const mid = c.slice(Math.floor(c.length / 2), Math.floor(c.length / 2) + 60);
const hit = pool.includes(mid);
if (!hit) continue;
console.log("✅ " + String(p.name || p.identifier).slice(0, 40) + " (" + String(p.content).length + " 字)");
}