// 逐条盘点:预设里的每个 prompt 条目,最终有没有进到两边的请求体里。 // 用法: node account-entries.mjs import { readFileSync } from "node:fs"; const preset = JSON.parse(readFileSync(process.argv[2], "utf8")); const readSide = (f) => { const outer = JSON.parse(readFileSync(f, "utf8")); const body = JSON.parse(outer.body); return body.messages.map((m) => String(m.content ?? "")).join("\n"); }; const norm = (s) => String(s ?? "").replace(/\s+/g, " ").trim(); const stAll = norm(readSide(process.argv[3])); const waAll = norm(readSide(process.argv[4])); function candidates(content) { const t = norm(content); if (t.length < 20) return [t]; const out = [t.slice(0, 120), t.slice(Math.floor(t.length / 2), Math.floor(t.length / 2) + 120), t.slice(-120)]; return out.map((x) => norm(x)).filter((x) => x.length >= 12); } const hit = (pool, content) => candidates(content).some((c) => pool.includes(c)); console.log("=== prompt_order 块 ==="); for (const b of preset.prompt_order || []) { const on = (b.order || []).filter((o) => o.enabled !== false).length; console.log("character_id=" + b.character_id + " 条目=" + (b.order || []).length + " 开着=" + on); } const block = (preset.prompt_order || []).find((b) => b.character_id === 100001) || (preset.prompt_order || [])[0] || { order: [] }; const orderEnabled = new Map((block.order || []).map((o) => [o.identifier, o.enabled !== false])); console.log("\n条目名 | 字数 | order开 | prompt开 | role | 酒馆 | 本仓库"); let inSt = 0, inWa = 0, both = 0, onlyWa = 0, onlySt = 0; for (const p of preset.prompts || []) { const content = String(p.content ?? ""); if (!content.trim()) continue; const hs = hit(stAll, content); const hw = hit(waAll, content); if (hs) inSt++; if (hw) inWa++; if (hs && hw) both++; if (hs && !hw) onlySt++; if (!hs && hw) onlyWa++; const flag = hs === hw ? "" : " <<<"; console.log( String(p.name || p.identifier).slice(0, 38) + " | " + content.length + " | " + (orderEnabled.get(p.identifier) ? "开" : "关") + " | " + (p.enabled === false ? "关" : "开") + " | " + (p.role || "system") + " | " + (hs ? "有" : "—") + " | " + (hw ? "有" : "—") + flag, ); } console.log("\n合计 酒馆 " + inSt + " / 本仓库 " + inWa + ",两边都有 " + both + ",只有酒馆 " + onlySt + ",只有本仓库 " + onlyWa);