bots-garden/mini-mepublic Fork
⑂ v1.0.7
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
🛟 Updated. cd2a817 · on v1.0.7 · k33g · Oct 24, 2026
moderate-comments.js · 68 lines · 2.5 KBJavaScript Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
// Moderates every comment of comments/ with the decision model of agent.yaml
// (or of the config file given as the first argument) and prints them grouped
// by the action the model chose: publish, review, reject. Each answer is
// checked against expected.json: a "✗" marks a flag or an action the model got
// wrong. No chat model is involved: each comment is one `mm -config <file> -p`
// call, whose stdout is the /v1/systemone JSON.
//
//   node moderate-comments.js              # agent.yaml
//   node moderate-comments.js omni.yaml    # another model, same questions
//
// MM_BIN names the mm binary, "mm" by default.

const { execFileSync } = require("child_process");
const fs = require("fs");
const path = require("path");

const here = __dirname;
const config = path.resolve(process.argv[2] || path.join(here, "agent.yaml"));
const expected = JSON.parse(fs.readFileSync(path.join(here, "expected.json"), "utf8"));
const folder = path.join(here, "comments");
const flags = ["toxic", "spam", "off_topic"];
const actions = ["publish", "review", "reject"];

const mark = (ok) => (ok ? " " : "✗");
const rows = [];
let right = 0;
let asked = 0;

function check(ok) {
  asked++;
  if (ok) right++;
  return ok;
}

for (const file of fs.readdirSync(folder).filter((f) => f.endsWith(".txt")).sort()) {
  const comment = fs.readFileSync(path.join(folder, file), "utf8").trim();
  const started = Date.now();
  const out = execFileSync(process.env.MM_BIN || "mm", ["-config", config, "-p", comment], {
    encoding: "utf8",
    stdio: ["ignore", "pipe", "inherit"],
  });
  const ms = Date.now() - started;
  const a = JSON.parse(out).answers;
  const want = expected[file];
  const shown = flags.map((flag) => {
    const yes = a[flag].noul >= 0.5;
    return `${yes ? flag : "-"}${mark(check(yes === want[flag]))}`;
  });
  rows.push({
    file,
    action: a.action.choice,
    confidence: `${a.action.confidence.toFixed(2)}${mark(check(want.action.includes(a.action.choice)))}`,
    flags: shown.join(" "),
    comment: comment.length > 50 ? `${comment.slice(0, 47)}...` : comment,
    ms,
  });
}

for (const action of actions) {
  const group = rows.filter((r) => r.action === action);
  if (group.length === 0) continue;
  console.log(`\n${action.toUpperCase()}`);
  for (const r of group) {
    console.log(`  ${r.file.padEnd(8)}${r.confidence.padEnd(7)}${r.flags.padEnd(28)}${`${r.ms} ms`.padEnd(9)}${r.comment}`);
  }
}
console.log(`\n${right}/${asked} answers as expected (three flags and the action per comment)`);