@heyramzi/lint 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -327,13 +327,16 @@ Reddit bench below, because the humanizer checks refused 151 of 157 human replie
327
327
  - **AI signals** (`register.js`): no I, hedge or question; short even sentences; orders to the
328
328
  reader; chopped into short paragraphs; no question or aside. Three or more of the 5 fails a reply
329
329
  of 25 words or more. `aiSignalNames(text)` lists them.
330
+ - **Menu paths**: a written-out "System Settings > Keyboard > Text Replacements" fails.
330
331
  - **Ramzi's two rules**: no em or en dash, and no single block over 95 words.
331
- - **Jev** asks one whole-reply question (`FORUM_SHAPES` in `jev-core.js`) in place of the sentence
332
- shapes, and refuses at 0.75. The forum register always asks it, and when Jev can't answer the
333
- reply fails with `jev unscored`. A reply under 25 words asks Jev nothing.
332
+ - **Jev** asks whole-reply questions in place of the sentence shapes, and refuses at 0.75:
333
+ `FORUM_SHAPES` always, and `FORUM_THREAD_SHAPES` (a looked-up tool the post never mentioned,
334
+ refused at its own 0.7) when `--thread=<post.md>` passes the post's title and body. The forum
335
+ register always asks Jev, and when Jev can't answer the reply fails with `jev unscored`. A reply
336
+ under 25 words asks Jev nothing.
334
337
 
335
338
  `jev-core.js` (`@heyramzi/lint/jev-core`) is the same Jev pass with no Node import, for a Worker:
336
- `auditShapesWith(text, { post: jevPost({ baseUrl, key, gatewayId }), block: FAIL, register: "forum" })`.
339
+ `auditShapesWith(text, { post: jevPost({ baseUrl, key, gatewayId }), block: FAIL, register: "forum", thread })`.
337
340
  `jev.js` wraps it for Node with the env, Proton Pass and a disk cache.
338
341
 
339
342
  #### The Reddit bench
@@ -342,11 +345,15 @@ Reddit bench below, because the humanizer checks refused 151 of 157 human replie
342
345
  replies in the same threads (`bad: false`). A comment is bad when it was reported (`reported`, by
343
346
  id), removed (a mod-team, AutoModerator or BotBouncer notice, or the app's removal record), scored
344
347
  0 or less, sits in a sub that banned us or that the app marked cold, or was posted on a day in
345
- `badDays`. A row, once bad, stays bad. The file stays out of the npm tarball.
348
+ `badDays`, or Ramzi read it and called it AI (`flagged: true`). A row, once bad, stays bad. Each
349
+ thread's title and body sit in `threadText`. The file stays out of the npm tarball.
350
+
351
+ - `node packages/lint/scripts/reddit-bench-flag.mjs --file <reply.md> --note "<his words>"
352
+ [--thread <id or URL>] [--sub <sub>]` (from vibe-kit) files his verdict on a reply, posted or not.
353
+ Run it the moment he calls a draft AI; the next harvest reads the thread.
346
354
 
347
355
  - `node scripts/reddit-bench.mjs` runs the CLI exactly as `reddit lint` does on every row. It prints
348
- recall (bad comments refused), the false positive rate (humans refused) and which check caught
349
- what. It exits 1 when a bad comment outside `knownMisses` passes, or more than 17% of humans are
356
+ bad comments caught, Ramzi-flagged replies caught, humans refused, and which check caught what. It exits 1 when a bad comment outside `knownMisses` passes, or more than 17% of humans are
350
357
  refused. After a gate change you've reviewed, `--accept` writes today's misses to `knownMisses`.
351
358
  - `scripts/reddit-bench-harvest.mjs` pulls new bad comments and fresh human replies through the
352
359
  logged-in Orca tab, one read every 6 seconds, writes them to the bench, then runs the bench and
@@ -150,7 +150,7 @@ async function modelShapes(file, raw) {
150
150
  try {
151
151
  jevKey ??= readJevKey();
152
152
  const text = /\.(html?|svelte|vue)$/i.test(file) ? proseOf(raw) : raw;
153
- return await auditShapes(text, { key: jevKey, block: shapeBlock, register });
153
+ return await auditShapes(text, { key: jevKey, block: shapeBlock, register, thread });
154
154
  } catch (err) {
155
155
  if (!isUnavailable(err)) throw err;
156
156
  jevDown = err.message;
@@ -188,7 +188,7 @@ const paths = args.filter((a) => !a.startsWith("--"));
188
188
 
189
189
  if (paths.length === 0) {
190
190
  process.stderr.write(
191
- "usage: heyramzi-slop <file|dir|-> [more...] [--fix] [--json] [--jev [--shape-block=0.6-1]] [--quiet] [--register=spoken|shorts|written|forum] [--only=kind|id,...]\n",
191
+ "usage: heyramzi-slop <file|dir|-> [more...] [--fix] [--json] [--jev [--shape-block=0.6-1]] [--quiet] [--register=spoken|shorts|written|forum [--thread=post.md]] [--only=kind|id,...]\n",
192
192
  );
193
193
  process.exit(2);
194
194
  }
@@ -215,6 +215,16 @@ const only = onlyFlag ? new Set(onlyFlag.split("=")[1].split(",").filter(Boolean
215
215
  // The reply BotBouncer reported on 30 Oct 2026 passed every exact pattern. So forum always asks
216
216
  // Jev, refuses at FAIL, and fails a reply Jev couldn't score.
217
217
  const forum = register === "forum";
218
+
219
+ // `--thread=<file>` is the post's title and body. Without it, FORUM_THREAD_SHAPES isn't asked.
220
+ const threadFlag = args.find((a) => a.startsWith("--thread"));
221
+ if (threadFlag && (!threadFlag.includes("=") || !forum)) {
222
+ process.stderr.write("--thread takes a file and needs --register=forum: --thread=post.md\n");
223
+ process.exit(2);
224
+ }
225
+ const thread = threadFlag
226
+ ? readFileSync(threadFlag.split("=").slice(1).join("="), "utf8")
227
+ : undefined;
218
228
  const askJev = flags.has("--jev") || forum;
219
229
 
220
230
  // The opt-in bar. Below REVIEW would promise to block scores the model check never keeps.
package/jev-core.d.ts CHANGED
@@ -3,6 +3,8 @@ export type JevQuestion = {
3
3
  type: "noul";
4
4
  instructions: string;
5
5
  criteria: { true: string; false: string };
6
+ /** A bar of its own, below the caller's `block`. Never sent to Jev. */
7
+ bar?: number;
6
8
  };
7
9
 
8
10
  /** What a caller's `post` sends to Jev: items keyed `i<n>`, questions keyed `i<n>_<shape>`. */
@@ -67,10 +69,12 @@ export const SHAPES: Record<string, JevQuestion>;
67
69
  export const PARAGRAPH_SHAPES: Record<string, JevQuestion>;
68
70
  /** Asked once of a whole forum reply (`reply`) under `register: "forum"`, in place of the other two. */
69
71
  export const FORUM_SHAPES: Record<string, JevQuestion>;
72
+ /** Asked of a forum reply beside its thread (`reply`, `thread`), only when `thread` is passed. */
73
+ export const FORUM_THREAD_SHAPES: Record<string, JevQuestion>;
70
74
 
71
75
  export function sentences(text: string): { sentence: string; context: string }[];
72
76
  export function paragraphs(text: string): { paragraph: string }[];
73
- export function replies(text: string): { reply: string }[];
77
+ export function replies(text: string, thread?: string): { reply: string; thread?: string }[];
74
78
  export function proseOf(html: string): string;
75
79
 
76
80
  export function unavailable(message: string): Error;
@@ -85,9 +89,16 @@ export function judgeWith(
85
89
 
86
90
  /**
87
91
  * The CLI's Jev pass with your transport. `block: FAIL` and `register: "forum"` is the Reddit gate;
88
- * a finding means refuse. Throws when `post` throws.
92
+ * a finding means refuse. `thread` is the post's title and body: pass it, or the forum pass skips
93
+ * FORUM_THREAD_SHAPES. Throws when `post` throws.
89
94
  */
90
95
  export function auditShapesWith(
91
96
  text: string,
92
- options: { post: JevPost; cache?: JevCache; block?: number; register?: string },
97
+ options: {
98
+ post: JevPost;
99
+ cache?: JevCache;
100
+ block?: number;
101
+ register?: string;
102
+ thread?: string;
103
+ },
93
104
  ): Promise<ShapeResult>;
package/jev-core.js CHANGED
@@ -127,6 +127,23 @@ export const FORUM_SHAPES = {
127
127
  ),
128
128
  };
129
129
 
130
+ /**
131
+ * Asked of a forum reply beside its thread's title and body, only when the caller passes the thread.
132
+ * Ramzi, 2 Nov 2026, on an Espanso reply that passed 2.6.0: "Who the fuck knows about this app?"
133
+ * At its 0.7 `bar` it refused 2 more of his 6 flagged replies and 2 of 265 humans; 4 other wordings
134
+ * cost 6 to 26 humans for the same catch (TECHLOG.md).
135
+ */
136
+ export const FORUM_THREAD_SHAPES = {
137
+ lookedup: {
138
+ ...q(
139
+ "`reply` answers the Reddit post in `thread`. Does `reply` recommend a specific tool, feature or setting that `thread` never mentions, described with looked-up precision (its exact name, where it lives, how it behaves), while nothing shows the writer has used it themselves?",
140
+ "A researched pointer: names an app, feature or setting the poster never raised, says exactly where it is or what it does, and the writer's own use of it is nowhere in the reply.",
141
+ "The writer works with what the poster named, or says they use the thing ('I use', 'we switched to', 'mine does'), or the names are loose and from memory.",
142
+ ),
143
+ bar: 0.7,
144
+ },
145
+ };
146
+
130
147
  // =========================
131
148
  // FUNCTIONS
132
149
  // =========================
@@ -179,9 +196,10 @@ export function paragraphs(text) {
179
196
  }
180
197
 
181
198
  /** A forum reply as one item. Under FORUM_MIN_WORDS it's a quick answer, which humans give bare too. */
182
- export function replies(text) {
199
+ export function replies(text, thread) {
183
200
  const reply = text.replace(/\s+/g, " ").trim();
184
- return reply.split(" ").length >= FORUM_MIN_WORDS ? [{ reply }] : [];
201
+ if (reply.split(" ").length < FORUM_MIN_WORDS) return [];
202
+ return [thread?.trim() ? { reply, thread: thread.trim() } : { reply }];
185
203
  }
186
204
 
187
205
  /** The model check could not run: network, key, credits, timeout or a bad answer. Callers skip it, not crash. */
@@ -245,16 +263,18 @@ export function jevPost({
245
263
  };
246
264
  }
247
265
 
248
- /** One request for every shape of up to BATCH items; item `i` is `i<n>` in state, so `field` becomes `i<n>.field`. */
249
- async function askBatch(items, post, shapes, field) {
266
+ /** One request for every shape of up to BATCH items; item `n` is `i<n>` in state, `reply` becomes `i<n>.reply`. */
267
+ async function askBatch(items, post, shapes) {
250
268
  const state = Object.fromEntries(items.map((it, n) => [`i${n}`, it]));
251
269
  const questions = {};
252
270
  items.forEach((_, n) => {
253
- for (const [id, q] of Object.entries(shapes)) {
254
- questions[`i${n}_${id}`] = {
255
- ...q,
256
- instructions: q.instructions.replaceAll(`\`${field}\``, `\`i${n}.${field}\``),
257
- };
271
+ for (const [id, { bar: _bar, ...q }] of Object.entries(shapes)) {
272
+ // Every field of the item the question names (`reply`, `thread`) points at this item's copy.
273
+ const instructions = Object.keys(items[n]).reduce(
274
+ (text, key) => text.replaceAll(`\`${key}\``, `\`i${n}.${key}\``),
275
+ q.instructions,
276
+ );
277
+ questions[`i${n}_${id}`] = { ...q, instructions };
258
278
  }
259
279
  });
260
280
  const answers = await post({ state, questions });
@@ -291,7 +311,6 @@ async function askAll(items, shapes, field, { post, cache }) {
291
311
  chunk.map((i) => items[i]),
292
312
  post,
293
313
  shapes,
294
- field,
295
314
  ),
296
315
  })),
297
316
  ),
@@ -317,18 +336,27 @@ async function askAll(items, shapes, field, { post, cache }) {
317
336
  */
318
337
  export async function judgeWith(items, shapes, field, { post, cache, block = FAIL }) {
319
338
  const hits = await askAll(items, shapes, field, { post, cache });
320
- return { findings: hits.filter((h) => h.p >= block), review: hits.filter((h) => h.p < block) };
339
+ // A question's own `bar` refuses below the caller's bar, and a report (no bar) refuses nothing.
340
+ const refuses = (h) =>
341
+ Number.isFinite(block) && h.p >= Math.min(block, shapes[h.id].bar ?? block);
342
+ return { findings: hits.filter(refuses), review: hits.filter((h) => !refuses(h)) };
321
343
  }
322
344
 
323
345
  /**
324
346
  * Shapes Jev reads in a text: each sentence and each paragraph of 3 or more, or under the forum
325
- * register the whole reply alone. A report (`review`) unless `block` names a bar; a hit at or above it is
347
+ * register the whole reply, and with `thread` (the post's title and body) the reply beside it. A report (`review`) unless `block` names a bar; a hit at or above it is
326
348
  * a `finding`. Throws JevUnavailable when `post` can't get an answer.
327
349
  */
328
- export async function auditShapesWith(text, { post, cache, block = Infinity, register } = {}) {
350
+ export async function auditShapesWith(
351
+ text,
352
+ { post, cache, block = Infinity, register, thread } = {},
353
+ ) {
329
354
  const passes =
330
355
  register === "forum"
331
- ? [[replies(text), FORUM_SHAPES, "reply"]]
356
+ ? [
357
+ [replies(text), FORUM_SHAPES, "reply"],
358
+ ...(thread?.trim() ? [[replies(text, thread), FORUM_THREAD_SHAPES, "reply"]] : []),
359
+ ]
332
360
  : [
333
361
  [sentences(text), SHAPES, "sentence"],
334
362
  [paragraphs(text), PARAGRAPH_SHAPES, "paragraph"],
package/jev.js CHANGED
@@ -88,7 +88,11 @@ const digest = (value) => createHash("sha256").update(value).digest("hex");
88
88
  const diskCache = {
89
89
  file(item, field, shapes) {
90
90
  const shapesKey = digest(JSON.stringify(shapes));
91
- const name = digest(JSON.stringify([modelOf(), field, shapesKey, normalize(item[field])]));
91
+ // A thread joins the key only when there is one, so earlier keys still read.
92
+ const text = item.thread
93
+ ? [normalize(item[field]), normalize(item.thread)]
94
+ : normalize(item[field]);
95
+ const name = digest(JSON.stringify([modelOf(), field, shapesKey, text]));
92
96
  return join(cacheRoot(), modelOf().replace(/[^\w.-]/g, "_"), `${name.slice(0, 40)}.json`);
93
97
  },
94
98
  read(item, field, shapes) {
@@ -130,12 +134,16 @@ export function judge(items, shapes, field, key, block = FAIL) {
130
134
  * Shapes Jev reads in a text, as jev-core.js `auditShapesWith` describes. Throws JevUnavailable when
131
135
  * the model can't answer, a blank key included.
132
136
  */
133
- export async function auditShapes(text, { key = jevKey(), block = Infinity, register } = {}) {
137
+ export async function auditShapes(
138
+ text,
139
+ { key = jevKey(), block = Infinity, register, thread } = {},
140
+ ) {
134
141
  if (!key) throw unavailable(JEV_OFF);
135
142
  return auditShapesWith(text, {
136
143
  post: (body) => post(body, key),
137
144
  cache: diskCache,
138
145
  block,
139
146
  register,
147
+ thread,
140
148
  });
141
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyramzi/lint",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "Shared oxlint rules, base config and gates for Studio projects",
5
5
  "license": "MIT",
6
6
  "repository": {
package/register.d.ts CHANGED
@@ -36,6 +36,8 @@ export type RegisterMeasurement = {
36
36
  speakerMarks: number;
37
37
  /** How many of the 5 AI signals `aiSignalNames` lists. 0 under 25 words. The forum band is at most 2. */
38
38
  aiSignals: number;
39
+ /** "A > B" menu or breadcrumb steps outside quotes and code. The forum band allows none. */
40
+ menuPaths: number;
39
41
  };
40
42
 
41
43
  export type RegisterAudit = {
package/register.js CHANGED
@@ -29,6 +29,8 @@ const CONTRACTION = /\b[\w]+['’](?:s|t|re|ve|ll|d|m)\b/gi;
29
29
  const SECOND_PERSON = /\b(?:you|your|yours|you're|you've|you'll|you'd|yourself)\b/gi;
30
30
  const FIRST_PERSON = /\b(?:i|me|my|mine|myself|i'm|i've|i'll|i'd)\b/gi;
31
31
  const CHAINING = /\b(?:and|so|because|but)\b/gi;
32
+ /** A menu or breadcrumb step: a capitalised label, " > ", another capitalised label. */
33
+ const MENU_PATH = /\b[A-Z][\w&'-]*(?: [\w&'-]+){0,3} > [A-Z]/g;
32
34
  // A person in the reply: an I, a hedge or a question. "we" and "our" don't count, because the company voice is the tell.
33
35
  const HEDGE =
34
36
  /\b(?:think|probably|maybe|might|not sure|depends|depending|could be wrong|imo|imho|afaik|iirc|ymmv|guess|usually|pretty|kinda|sort of|honestly|tbh|seems|suspect)\b/gi;
@@ -106,6 +108,9 @@ export function measureRegister(copy) {
106
108
  })(),
107
109
  // Nobody speaking: no I, no hedge, no question. 15 of our last 19 replies over 40 words, 2 of 22 humans beside them.
108
110
  speakerMarks: count(FIRST_PERSON) + count(HEDGE) + (text.match(/\?/g) ?? []).length,
111
+ // "System Settings > Keyboard > Text Replacements": 4 of 6 replies Ramzi flagged on 2 Nov 2026,
112
+ // 1 of 265 human Reddit replies. A quoted line (`> ...`) is not a path.
113
+ menuPaths: (text.replace(/^\s*>.*$/gm, "").match(MENU_PATH) ?? []).length,
109
114
  };
110
115
  measured.aiSignals = aiSignalNames(text, measured).length;
111
116
  return measured;
@@ -279,6 +284,7 @@ REGISTERS.forum = {
279
284
  "57 bad u/heyramzi comments and 157 human replies in their threads, data/reddit-bench.json",
280
285
  bands: {
281
286
  aiSignals: { max: 2 },
287
+ menuPaths: { max: 0 },
282
288
  // Ramzi, 21 Oct 2026: our replies shipped as one block of text.
283
289
  unbrokenWords: { max: 95 },
284
290
  },
@@ -305,6 +311,7 @@ const DIRECTION = {
305
311
  commandShare: "% of sentences that open on an order",
306
312
  speakerMarks: "I/me/my, hedges and questions, together",
307
313
  aiSignals: "of 5 AI signals",
314
+ menuPaths: "menu paths written out (A > B)",
308
315
  };
309
316
 
310
317
  /**
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Files Ramzi's verdict on a reply, posted or not, as a bad row in data/reddit-bench.json.
4
+ *
5
+ * node packages/lint/scripts/reddit-bench-flag.mjs --file <reply.md> --note "<his words>" \
6
+ * [--thread <reddit id or URL>] [--sub <sub>]
7
+ *
8
+ * A text already in the bench gets the note added. The next harvest reads the thread's text.
9
+ */
10
+
11
+ import { createHash } from "node:crypto";
12
+ import { readFileSync, writeFileSync } from "node:fs";
13
+ import { join } from "node:path";
14
+ import { parseArgs } from "node:util";
15
+
16
+ const BENCH = join(import.meta.dirname, "../data/reddit-bench.json");
17
+
18
+ const { values } = parseArgs({
19
+ options: {
20
+ file: { type: "string" },
21
+ note: { type: "string" },
22
+ thread: { type: "string" },
23
+ sub: { type: "string" },
24
+ },
25
+ });
26
+ if (!values.file || !values.note) {
27
+ process.stderr.write(
28
+ 'usage: reddit-bench-flag.mjs --file <reply.md> --note "<his words>" [--thread <id|url>] [--sub <sub>]\n',
29
+ );
30
+ process.exit(2);
31
+ }
32
+
33
+ /** The id out of a thread URL (`/comments/<id>/`), or the id as given. */
34
+ const threadId = (value) => value?.match(/comments\/(\w+)/)?.[1] ?? value?.replace(/^t3_/, "");
35
+ const normalize = (text) => text.normalize("NFC").replace(/\s+/g, " ").trim();
36
+
37
+ const text = readFileSync(values.file, "utf8").trim();
38
+ const bench = JSON.parse(readFileSync(BENCH, "utf8"));
39
+ const why = `ramzi-flagged: ${values.note}`;
40
+ const known = bench.rows.find((row) => normalize(row.text) === normalize(text));
41
+
42
+ if (known) {
43
+ known.bad = true;
44
+ known.flagged = true;
45
+ known.why = [...new Set([...known.why, why])];
46
+ } else {
47
+ const thread = threadId(values.thread);
48
+ bench.rows.push({
49
+ id: `flag-${createHash("sha256").update(normalize(text)).digest("hex").slice(0, 10)}`,
50
+ bad: true,
51
+ flagged: true,
52
+ why: [why],
53
+ sub: values.sub?.replace(/^r\//, "") ?? "",
54
+ thread: thread ?? "",
55
+ score: null,
56
+ created: new Date().toISOString().slice(0, 10),
57
+ permalink: thread ? `https://www.reddit.com/comments/${thread}/` : "",
58
+ text,
59
+ });
60
+ }
61
+ writeFileSync(BENCH, `${JSON.stringify(bench, null, 2)}\n`);
62
+ console.log(`${known ? "noted on" : "added"} ${known?.id ?? bench.rows.at(-1).id}: ${why}`);
@@ -191,6 +191,9 @@ function isHuman(c) {
191
191
  // =========================
192
192
  const bench = JSON.parse(readFileSync(BENCH, "utf8"));
193
193
  const rows = new Map(bench.rows.map((row) => [row.id, row]));
194
+ const normalize = (text) => text.normalize("NFC").replace(/\s+/g, " ").trim();
195
+ /** A reply Ramzi flagged before it posted shows up later under its Reddit id: same row. */
196
+ const byText = new Map(bench.rows.map((row) => [normalize(row.text), row]));
194
197
 
195
198
  const ours = await listing(`/user/${ACCOUNT}/comments`);
196
199
  const subs = [...new Set(ours.map((c) => c.subreddit))];
@@ -213,7 +216,7 @@ for (const c of ours) {
213
216
  cold.includes(sub) && "sub cold",
214
217
  badDays.has(day(c.created_utc)) && `posted ${day(c.created_utc)}`,
215
218
  ].filter(Boolean);
216
- const known = rows.get(c.id);
219
+ const known = rows.get(c.id) ?? byText.get(normalize(c.body));
217
220
  if (known) {
218
221
  // A reason, once seen, stays: a sub coming off cold doesn't make the comment read human.
219
222
  known.why = [...new Set([...known.why, ...why])];
@@ -249,18 +252,29 @@ function save() {
249
252
  coldSubs: cold,
250
253
  bannedSubs: [...new Set([...bench.bannedSubs, ...banned])].toSorted(),
251
254
  threads: [...threads].toSorted(),
255
+ threadText,
252
256
  rows: sorted,
253
257
  };
254
258
  writeFileSync(BENCH, `${JSON.stringify(next, null, 2)}\n`);
255
259
  return sorted;
256
260
  }
257
261
 
258
- // Human negatives from every thread a bad comment sits in, read once per thread.
262
+ // Human negatives from every thread a bad comment sits in, read once per thread, with the thread's
263
+ // own words: a check on what a reply brings that the thread never said needs them.
259
264
  const threads = new Set(bench.threads);
265
+ const threadText = bench.threadText ?? {};
260
266
  save();
261
- for (const thread of new Set([...rows.values()].filter((r) => r.bad).map((r) => r.thread))) {
262
- if (threads.has(thread)) continue;
263
- const [, comments] = await get(`/comments/${thread}`, { sort: "top", limit: 200 });
267
+ for (const thread of new Set(
268
+ [...rows.values()].filter((r) => r.bad && r.thread).map((r) => r.thread),
269
+ )) {
270
+ if (threads.has(thread) && threadText[thread]) continue;
271
+ const [post, comments] = await get(`/comments/${thread}`, { sort: "top", limit: 200 });
272
+ const op = post.data.children[0]?.data ?? {};
273
+ threadText[thread] = { title: op.title ?? "", body: (op.selftext ?? "").slice(0, 4000) };
274
+ if (threads.has(thread)) {
275
+ save();
276
+ continue;
277
+ }
264
278
  const humans = flatten(comments.data.children)
265
279
  .filter(isHuman)
266
280
  .toSorted((a, b) => b.score - a.score)
@@ -38,7 +38,13 @@ const run = promisify(execFile);
38
38
  async function verdict(row, dir) {
39
39
  const file = join(dir, `${row.id}.md`);
40
40
  writeFileSync(file, row.text);
41
- const out = await run(process.execPath, [CLI, file, ...FLAGS], {
41
+ const thread = threadText[row.thread];
42
+ const args = [CLI, file, ...FLAGS];
43
+ if (thread) {
44
+ writeFileSync(`${file}.thread`, `${thread.title}\n\n${thread.body}`.trim());
45
+ args.push(`--thread=${file}.thread`);
46
+ }
47
+ const out = await run(process.execPath, args, {
42
48
  maxBuffer: 8 * 1024 * 1024,
43
49
  }).catch((err) => err);
44
50
  const result = JSON.parse(out.stdout);
@@ -60,7 +66,7 @@ const head = (text) => text.replace(/\s+/g, " ").slice(0, 90);
60
66
  // MAIN
61
67
  // =========================
62
68
  const bench = JSON.parse(readFileSync(BENCH, "utf8"));
63
- const { rows } = bench;
69
+ const { rows, threadText = {} } = bench;
64
70
  const known = new Set(bench.knownMisses);
65
71
  const dir = mkdtempSync(join(tmpdir(), "reddit-bench-"));
66
72
  let judged;
@@ -70,34 +76,38 @@ try {
70
76
  rmSync(dir, { recursive: true, force: true });
71
77
  }
72
78
 
73
- const bad = judged.filter((r) => r.bad);
79
+ const bad = judged.filter((r) => r.bad && !r.flagged);
80
+ const ramzi = judged.filter((r) => r.flagged);
74
81
  const human = judged.filter((r) => !r.bad);
75
- const missed = bad.filter((r) => !r.refused);
76
- const flagged = human.filter((r) => r.refused);
82
+ const missed = judged.filter((r) => r.bad && !r.refused);
83
+ const refusedHumans = human.filter((r) => r.refused);
77
84
 
78
85
  // Which check carries the load, and which one costs the humans.
79
86
  const byHit = {};
80
87
  for (const r of judged)
81
88
  for (const hit of new Set(r.hits)) {
82
- byHit[hit] ??= { bad: 0, human: 0 };
83
- byHit[hit][r.bad ? "bad" : "human"] += 1;
89
+ byHit[hit] ??= { bad: 0, flagged: 0, human: 0 };
90
+ byHit[hit][r.flagged ? "flagged" : r.bad ? "bad" : "human"] += 1;
84
91
  }
85
- console.log("check bad human");
92
+ console.log("check bad flagged human");
86
93
  for (const [hit, n] of Object.entries(byHit).toSorted((a, b) => b[1].bad - a[1].bad))
87
- console.log(`${hit.padEnd(30)} ${String(n.bad).padStart(4)} ${String(n.human).padStart(6)}`);
94
+ console.log(
95
+ `${hit.padEnd(30)} ${String(n.bad).padStart(4)} ${String(n.flagged).padStart(7)} ${String(n.human).padStart(6)}`,
96
+ );
88
97
 
89
98
  const fresh = missed.filter((r) => !known.has(r.id));
90
99
  for (const r of missed)
91
100
  console.log(
92
101
  `\n${known.has(r.id) ? "miss" : "MISS"} ${r.id} r/${r.sub} (${r.why.join(", ")})\n ${head(r.text)}`,
93
102
  );
94
- for (const r of flagged)
103
+ for (const r of refusedHumans)
95
104
  console.log(`\nHUMAN REFUSED ${r.id} r/${r.sub} ${r.hits.join(" ")}\n ${head(r.text)}`);
96
105
 
97
- const recall = bad.length - missed.length;
106
+ const caught = (rs) => rs.filter((r) => r.refused).length;
98
107
  console.log(
99
- `\nrecall ${recall}/${bad.length} (${pct(recall, bad.length)}), ` +
100
- `false positives ${flagged.length}/${human.length} (${pct(flagged.length, human.length)}), ` +
108
+ `\nbad caught ${caught(bad)}/${bad.length} (${pct(caught(bad), bad.length)}), ` +
109
+ `flagged caught ${caught(ramzi)}/${ramzi.length} (${pct(caught(ramzi), ramzi.length)}), ` +
110
+ `humans refused ${refusedHumans.length}/${human.length} (${pct(refusedHumans.length, human.length)}), ` +
101
111
  `bar ${pct(MAX_FPR, 1)}`,
102
112
  );
103
113
 
@@ -111,4 +121,6 @@ if (process.argv.includes("--accept")) {
111
121
  console.log(`knownMisses: ${knownMisses.length}`);
112
122
  process.exit(0);
113
123
  }
114
- process.exit(fresh.length > 0 || flagged.length / Math.max(1, human.length) > MAX_FPR ? 1 : 0);
124
+ process.exit(
125
+ fresh.length > 0 || refusedHumans.length / Math.max(1, human.length) > MAX_FPR ? 1 : 0,
126
+ );
package/slop.d.ts CHANGED
@@ -49,5 +49,10 @@ export declare function auditSlop(text: string): SlopAudit;
49
49
  /** Clean, then audit. The one call a publishing path makes. */
50
50
  export declare function slopGate(
51
51
  raw: string,
52
- options?: { markup?: boolean; normalizeSpaces?: boolean },
52
+ options?: {
53
+ markup?: boolean;
54
+ code?: boolean;
55
+ normalizeSpaces?: boolean;
56
+ register?: import("./register.js").RegisterName;
57
+ },
53
58
  ): SlopLint;