@heyramzi/lint 2.6.0 → 2.7.0

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
@@ -34,6 +34,7 @@ deleted on 14 Sep 2026.
34
34
  | `no-em-dash` | Error. Em and en dashes in comments, strings, template text and Svelte text. A spaced hyphen (` - `) fails there too, except where it isn't a dash: a string whose whole value is one em or en dash (an empty-value placeholder), a string or template that is code judged on content (SQL keywords like `SELECT … FROM` or `WHERE`, CSS `calc(` or `var(--`, GLSL `gl_` or `vec2`, JS `function x(`, `=>` or `const x =`), a markdown bullet at the start of a template line or comment line, `<style>`, and `sql`/`css`/`gql`/`html`/`raw` templates. Test and fixture files (`*.test.*`, `*.spec.*`, `__fixtures__/`, `fixtures/`) pass a spaced hyphen because their strings are inputs under test. A real em or en dash fails everywhere except a bare placeholder and a tagged template. |
35
35
  | `no-svelte4-syntax` | Error. `export let` and `$:` in a `.svelte` file. Svelte 4 markup is the markup gate's job. |
36
36
  | `no-app-stores` | Error. An import from `$app/stores`; read `page` from `$app/state`. |
37
+ | `no-navigation-in-effect` | Error. A shallow `goto`, `pushState` or `replaceState` in an `$effect` that tracks `page.state`, or `invalidate*` in one that tracks `page.data`. The call writes what the effect reads and it reruns forever: getwavenote.com/download?auto fired 13 DMGs and hung (TSK-1648). Read it in `untrack()` or move it to `onMount`. |
37
38
  | `no-rune-outside-svelte-file` | Error. A rune in a file Svelte doesn't compile, which throws `rune_outside_svelte` at runtime. Rename it `.svelte.ts`. |
38
39
  | `no-rune-shadowing-binding` | Error. A top-level binding named `state`, `derived`, `effect`… in a file that calls that rune, which throws `store_invalid_shape`. |
39
40
  | `props-interface` | Error, with `--fix`. `type Props = {...}` in a component; write `interface Props`. A union, conditional or mapped type stays a type. |
@@ -327,13 +328,16 @@ Reddit bench below, because the humanizer checks refused 151 of 157 human replie
327
328
  - **AI signals** (`register.js`): no I, hedge or question; short even sentences; orders to the
328
329
  reader; chopped into short paragraphs; no question or aside. Three or more of the 5 fails a reply
329
330
  of 25 words or more. `aiSignalNames(text)` lists them.
331
+ - **Menu paths**: a written-out "System Settings > Keyboard > Text Replacements" fails.
330
332
  - **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.
333
+ - **Jev** asks whole-reply questions in place of the sentence shapes, and refuses at 0.75:
334
+ `FORUM_SHAPES` always, and `FORUM_THREAD_SHAPES` (a looked-up tool the post never mentioned,
335
+ refused at its own 0.7) when `--thread=<post.md>` passes the post's title and body. The forum
336
+ register always asks Jev, and when Jev can't answer the reply fails with `jev unscored`. A reply
337
+ under 25 words asks Jev nothing.
334
338
 
335
339
  `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" })`.
340
+ `auditShapesWith(text, { post: jevPost({ baseUrl, key, gatewayId }), block: FAIL, register: "forum", thread })`.
337
341
  `jev.js` wraps it for Node with the env, Proton Pass and a disk cache.
338
342
 
339
343
  #### The Reddit bench
@@ -342,11 +346,15 @@ Reddit bench below, because the humanizer checks refused 151 of 157 human replie
342
346
  replies in the same threads (`bad: false`). A comment is bad when it was reported (`reported`, by
343
347
  id), removed (a mod-team, AutoModerator or BotBouncer notice, or the app's removal record), scored
344
348
  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.
349
+ `badDays`, or Ramzi read it and called it AI (`flagged: true`). A row, once bad, stays bad. Each
350
+ thread's title and body sit in `threadText`. The file stays out of the npm tarball.
351
+
352
+ - `node packages/lint/scripts/reddit-bench-flag.mjs --file <reply.md> --note "<his words>"
353
+ [--thread <id or URL>] [--sub <sub>]` (from vibe-kit) files his verdict on a reply, posted or not.
354
+ Run it the moment he calls a draft AI; the next harvest reads the thread.
346
355
 
347
356
  - `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
357
+ 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
358
  refused. After a gate change you've reviewed, `--accept` writes today's misses to `knownMisses`.
351
359
  - `scripts/reddit-bench-harvest.mjs` pulls new bad comments and fresh human replies through the
352
360
  logged-in Orca tab, one read every 6 seconds, writes them to the bench, then runs the bench and
@@ -48,7 +48,11 @@
48
48
  */
49
49
 
50
50
  /*
51
- * With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs. `--register=forum` is the exception: it always asks Jev and fails when Jev can't answer.
51
+ * With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs.
52
+ */
53
+
54
+ /*
55
+ * `--register=forum` is the exception: it always asks Jev and fails when Jev can't answer.
52
56
  */
53
57
 
54
58
  import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
@@ -58,6 +62,7 @@ import { patterns } from "#lint/data/slop/patterns.js";
58
62
  import { titleTells } from "#lint/data/slop/title-tells.js";
59
63
  import { FAIL, REVIEW, isUnavailable, proseOf } from "#lint/jev-core.js";
60
64
  import { auditShapes, jevKey as readJevKey } from "#lint/jev.js";
65
+ import { declaredLanguage } from "#lint/slop-language.js";
61
66
  import { slopGate } from "#lint/slop.js";
62
67
 
63
68
  // =========================
@@ -97,7 +102,9 @@ function gate(file, register) {
97
102
  const code = /\.(m?[jt]sx?|json)$/i.test(file);
98
103
  if (/\.board\.json$/i.test(file)) return { raw, result: gateBoard(raw, register) };
99
104
  const text = /\.mdx?$/i.test(file) ? proseOfMarkdown(raw) : raw;
100
- return { raw, result: slopGate(text, { markup, code, register }) };
105
+ // Read from the raw file, because `proseOfMarkdown` blanks the frontmatter that carries `lang`.
106
+ const language = declaredLanguage(raw, file);
107
+ return { raw, result: slopGate(text, { markup, code, register, language }) };
101
108
  }
102
109
 
103
110
  /**
@@ -150,7 +157,7 @@ async function modelShapes(file, raw) {
150
157
  try {
151
158
  jevKey ??= readJevKey();
152
159
  const text = /\.(html?|svelte|vue)$/i.test(file) ? proseOf(raw) : raw;
153
- return await auditShapes(text, { key: jevKey, block: shapeBlock, register });
160
+ return await auditShapes(text, { key: jevKey, block: shapeBlock, register, thread });
154
161
  } catch (err) {
155
162
  if (!isUnavailable(err)) throw err;
156
163
  jevDown = err.message;
@@ -188,7 +195,7 @@ const paths = args.filter((a) => !a.startsWith("--"));
188
195
 
189
196
  if (paths.length === 0) {
190
197
  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",
198
+ "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
199
  );
193
200
  process.exit(2);
194
201
  }
@@ -215,6 +222,16 @@ const only = onlyFlag ? new Set(onlyFlag.split("=")[1].split(",").filter(Boolean
215
222
  // The reply BotBouncer reported on 30 Oct 2026 passed every exact pattern. So forum always asks
216
223
  // Jev, refuses at FAIL, and fails a reply Jev couldn't score.
217
224
  const forum = register === "forum";
225
+
226
+ // `--thread=<file>` is the post's title and body. Without it, FORUM_THREAD_SHAPES isn't asked.
227
+ const threadFlag = args.find((a) => a.startsWith("--thread"));
228
+ if (threadFlag && (!threadFlag.includes("=") || !forum)) {
229
+ process.stderr.write("--thread takes a file and needs --register=forum: --thread=post.md\n");
230
+ process.exit(2);
231
+ }
232
+ const thread = threadFlag
233
+ ? readFileSync(threadFlag.split("=").slice(1).join("="), "utf8")
234
+ : undefined;
218
235
  const askJev = flags.has("--jev") || forum;
219
236
 
220
237
  // The opt-in bar. Below REVIEW would promise to block scores the model check never keeps.
@@ -47,6 +47,7 @@
47
47
  "@heyramzi/lint/no-hardcoded-models": "error",
48
48
  "@heyramzi/lint/no-redundant-prop-fallback": "error",
49
49
  "@heyramzi/lint/no-app-stores": "error",
50
+ "@heyramzi/lint/no-navigation-in-effect": "error",
50
51
  "@heyramzi/lint/no-rune-outside-svelte-file": "error",
51
52
  "@heyramzi/lint/no-rune-shadowing-binding": "error",
52
53
  "@heyramzi/lint/no-svelte4-syntax": "error",
@@ -11,6 +11,8 @@ export const patternsHeadingsAndLaws = [
11
11
 
12
12
  // not in the outline.
13
13
  view: "faqless",
14
+ // The `?` is the whole signature, so it reads the same in German as in English.
15
+ anyLanguage: true,
14
16
  test: /^#{1,6}\s+[^\n?]{5,90}\?\s*$/m,
15
17
  rule: "A section heading written as a question the writer then answers. It buys a beat of suspense the reader did not ask for and it makes the outline unscannable. Name the answer in the heading.",
16
18
  example: '"## Why does this matter?" / "## Qu\'est-ce que le pilotage ?"',
@@ -21,6 +23,7 @@ export const patternsHeadingsAndLaws = [
21
23
  // WP:AILIST. A bullet or a number, a bold run, then a colon, on either side of the closing stars because a chatbot writes it both ways.
22
24
 
23
25
  // The colon is required: a list of bold link labels with no colon is ordinary markdown.
26
+ anyLanguage: true,
24
27
  test: /^[ \t]*(?:[-*+•–—]|\d+[.)])\s+\*\*[^*\n]{2,60}(?:[::]\*\*|\*\*\s*[::])/m,
25
28
  rule: "The bullet, bold label, colon, sentence shape a chatbot renders by default. It turns prose into a specification nobody asked for and the bold adds no emphasis because every line has it. Write the paragraph, or drop the bold and the colon.",
26
29
  example:
@@ -44,6 +44,10 @@ import { patternsDiagramAndScriptTells } from "#lint/data/slop/patterns/diagram-
44
44
  /*
45
45
  * `view` is optional and names which reading of the draft the regex judges: the whole draft by default, or `faqless` for the one check an FAQ is allowed to fail.
46
46
  */
47
+
48
+ /*
49
+ * `anyLanguage` is optional. A pattern runs only on English and French drafts, the languages its words are written in, unless it reads markdown shape alone and says so here.
50
+ */
47
51
  export const patterns = [
48
52
  ...patternsSubjectVoice,
49
53
  ...patternsRevealsAndTallies,
package/index.js CHANGED
@@ -41,6 +41,7 @@ import svelteSectionOrder from "#lint/rules/svelte-section-order.js";
41
41
 
42
42
  // Svelte and SvelteKit house rules
43
43
  import noAppStores from "#lint/rules/no-app-stores.js";
44
+ import noNavigationInEffect from "#lint/rules/no-navigation-in-effect.js";
44
45
  import noRuneOutsideSvelteFile from "#lint/rules/no-rune-outside-svelte-file.js";
45
46
  import noRuneShadowingBinding from "#lint/rules/no-rune-shadowing-binding.js";
46
47
  import noSkippedOrFocusedTests from "#lint/rules/no-skipped-or-focused-tests.js";
@@ -100,6 +101,7 @@ export default {
100
101
 
101
102
  // Svelte and SvelteKit
102
103
  "no-app-stores": noAppStores,
104
+ "no-navigation-in-effect": noNavigationInEffect,
103
105
  "no-rune-outside-svelte-file": noRuneOutsideSvelteFile,
104
106
  "no-rune-shadowing-binding": noRuneShadowingBinding,
105
107
  "no-skipped-or-focused-tests": noSkippedOrFocusedTests,
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.7.0",
4
4
  "description": "Shared oxlint rules, base config and gates for Studio projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,6 +43,7 @@
43
43
  "push-diff.js",
44
44
  "slop.d.ts",
45
45
  "slop.js",
46
+ "slop-language.js",
46
47
  "slop-views.js",
47
48
  "ui-rules.js",
48
49
  "ui-rules-css.js",
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,114 @@
1
+ /**
2
+ * Ban a shallow navigation in an `$effect` that tracks `page.state`, and `invalidate*` in one that tracks `page.data`.
3
+ */
4
+
5
+ /*
6
+ * The call writes the field the effect tracks, so it reruns forever: getwavenote.com/download?auto fired 13 DMGs and hung (TSK-1648). `untrack()` the read or run it in `onMount`.
7
+ */
8
+
9
+ /** The `page` field each call writes. A plain `goto` leaves the page instead, so it never loops. */
10
+ const WRITES = {
11
+ goto: "state",
12
+ pushState: "state",
13
+ replaceState: "state",
14
+ invalidate: "data",
15
+ invalidateAll: "data",
16
+ };
17
+
18
+ const message =
19
+ "`{{name}}` writes `page.{{field}}`, which this `$effect` tracks, so it reruns forever. Read it in `untrack()` or move the call to `onMount`.";
20
+
21
+ function isEffectCall(node) {
22
+ if (node?.type !== "CallExpression") return false;
23
+ const { callee } = node;
24
+ if (callee.type === "Identifier") return callee.name === "$effect";
25
+ return (
26
+ callee.type === "MemberExpression" &&
27
+ callee.object.type === "Identifier" &&
28
+ callee.object.name === "$effect" &&
29
+ callee.property.type === "Identifier" &&
30
+ callee.property.name === "pre"
31
+ );
32
+ }
33
+
34
+ /** The `$effect` call whose callback holds `node`, or null when an `untrack()` sits between them. */
35
+ function enclosingEffect(node) {
36
+ for (let child = node, parent = node.parent; parent; child = parent, parent = parent.parent) {
37
+ if (parent.type === "CallExpression" && parent.callee.type === "Identifier") {
38
+ if (parent.callee.name === "untrack" && parent.arguments[0] === child) return null;
39
+ }
40
+ if (isEffectCall(parent) && parent.arguments[0] === child) return parent;
41
+ }
42
+ return null;
43
+ }
44
+
45
+ function isInPlace(name, call) {
46
+ if (name !== "goto") return true;
47
+ const options = call.arguments[1];
48
+ return (
49
+ options?.type === "ObjectExpression" &&
50
+ options.properties.some(
51
+ (prop) =>
52
+ prop.type === "Property" &&
53
+ (prop.key.name ?? prop.key.value) === "shallow" &&
54
+ prop.value.type === "Literal" &&
55
+ prop.value.value === true,
56
+ )
57
+ );
58
+ }
59
+
60
+ export default {
61
+ meta: {
62
+ type: "problem",
63
+ docs: { description: "Disallow a navigation that writes the page field its $effect tracks." },
64
+ messages: { navigationInEffect: message },
65
+ schema: [],
66
+ },
67
+ create(context) {
68
+ const local = new Map();
69
+ const pageNames = new Set();
70
+ const pending = [];
71
+ const tracked = new Map();
72
+ return {
73
+ ImportDeclaration(node) {
74
+ if (node.source?.value === "$app/state") {
75
+ for (const specifier of node.specifiers) {
76
+ const imported = specifier.imported?.name ?? specifier.imported?.value;
77
+ if (imported === "page") pageNames.add(specifier.local.name);
78
+ }
79
+ return;
80
+ }
81
+ if (node.source?.value !== "$app/navigation") return;
82
+ for (const specifier of node.specifiers) {
83
+ if (specifier.type !== "ImportSpecifier") continue;
84
+ const imported = specifier.imported.name ?? specifier.imported.value;
85
+ if (imported in WRITES) local.set(specifier.local.name, imported);
86
+ }
87
+ },
88
+ CallExpression(node) {
89
+ if (node.callee.type !== "Identifier" || !local.has(node.callee.name)) return;
90
+ if (!isInPlace(local.get(node.callee.name), node)) return;
91
+ const effect = enclosingEffect(node);
92
+ if (effect) pending.push({ node, effect });
93
+ },
94
+ Identifier(node) {
95
+ if (!pageNames.has(node.name)) return;
96
+ const { parent } = node;
97
+ if (parent?.type !== "MemberExpression" || parent.object !== node || parent.computed)
98
+ return;
99
+ const effect = enclosingEffect(node);
100
+ if (!effect) return;
101
+ if (!tracked.has(effect)) tracked.set(effect, new Set());
102
+ tracked.get(effect).add(parent.property.name);
103
+ },
104
+ "Program:exit"() {
105
+ for (const { node, effect } of pending) {
106
+ const field = WRITES[local.get(node.callee.name)];
107
+ if (!tracked.get(effect)?.has(field)) continue;
108
+ const data = { name: node.callee.name, field };
109
+ context.report({ node, messageId: "navigationInEffect", data });
110
+ }
111
+ },
112
+ };
113
+ },
114
+ };
@@ -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
+ );
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Which language the draft is in, so the checks that only work in one of them pick the right list.
3
+ */
4
+
5
+ /*
6
+ * Stopword counting, not a library.
7
+ */
8
+
9
+ /*
10
+ * The two sets share almost nothing, a draft of any length separates them by a wide margin, and the only caller that can be hurt by a wrong answer is
11
+ */
12
+
13
+ /*
14
+ * the pronoun ledger, which reports rather than rewrites. English is the default on a tie, including on an empty string.
15
+ */
16
+ const FR_STOPWORDS =
17
+ /(?<![\p{L}\p{N}_])(?:le|la|les|des|une|un|et|est|dans|pour|que|qui|pas|avec|sur|plus|cette|vous|nous|aux|mais|sont|être|ce|se|son|ses|leur|par|au|du|elle|il)(?![\p{L}\p{N}_])/giu;
18
+ const EN_STOPWORDS =
19
+ /(?<![\p{L}\p{N}_])(?:the|and|is|of|to|in|that|it|for|with|you|this|are|on|but|not|have|from|as|was|they|be|at|by|or|an|its|their)(?![\p{L}\p{N}_])/giu;
20
+ // None of these is an English or French word, so an English draft quoting one German phrase stays English.
21
+ const DE_STOPWORDS =
22
+ /(?<![\p{L}\p{N}_])(?:der|das|und|ist|nicht|mit|ein|eine|einen|einem|für|auf|sich|dem|auch|zu|von|wird|sind|oder|aber|wenn|nur|bei|nach|noch|wie|über|kann|ich|wir|Sie|zum|zur|dass|werden|haben)(?![\p{L}\p{N}_])/giu;
23
+
24
+ export function detectLanguage(text) {
25
+ // Japanese first, and by script rather than by stopword.
26
+
27
+ // A Japanese draft has no English or French stopwords of its own, so the count is decided by whatever it quotes, and every Japanese page on the Wavenote site came
28
+
29
+ // back "en" and was then graded on English pronouns it does not use.
30
+ const cjk = (text.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/g) ?? []).length;
31
+ const letters = (text.match(/[\p{L}]/gu) ?? []).length;
32
+ if (letters > 0 && cjk / letters > 0.2) return "ja";
33
+ const en = (text.match(EN_STOPWORDS) ?? []).length;
34
+ const fr = (text.match(FR_STOPWORDS) ?? []).length;
35
+ const de = (text.match(DE_STOPWORDS) ?? []).length;
36
+ if (fr > en && fr >= de) return "fr";
37
+ if (de > en && de > fr) return "de";
38
+ return "en";
39
+ }
40
+
41
+ /**
42
+ * The language a file declares: frontmatter `lang`, `locale` or `language`, then the nearest folder named for one (`/de/`, `/ja-JP/`). Undefined when neither says.
43
+ */
44
+
45
+ /*
46
+ * Seam's German posts said it only by folder and were graded as English, 3 Nov 2026. `it` is left out: that folder is usually a department.
47
+ */
48
+ const LANGUAGE_FOLDERS = new Set([
49
+ "en",
50
+ "fr",
51
+ "de",
52
+ "ja",
53
+ "es",
54
+ "pt",
55
+ "nl",
56
+ "zh",
57
+ "ko",
58
+ "pl",
59
+ "sv",
60
+ "da",
61
+ "fi",
62
+ "ru",
63
+ "tr",
64
+ ]);
65
+ export function declaredLanguage(source = "", path = "") {
66
+ const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(source)?.[1] ?? "";
67
+ const tag = /^(?:lang|locale|language)[ \t]*:[ \t]*["']?([A-Za-z]{2})(?![A-Za-z])/m.exec(front);
68
+ if (tag) return tag[1].toLowerCase();
69
+ const folder = path
70
+ .split(/[\\/]/)
71
+ .slice(0, -1)
72
+ .toReversed()
73
+ .find((s) => /^[a-z]{2}(?:[-_][A-Za-z]{2})?$/.test(s) && LANGUAGE_FOLDERS.has(s.slice(0, 2)));
74
+ return folder?.slice(0, 2);
75
+ }
76
+
77
+ /**
78
+ * The word lists, phrases, sentence patterns, title case and pronoun ledger are written for these. German needs a comma before every relative clause, which `comma-run` read as a list.
79
+ */
80
+
81
+ /*
82
+ * The outline, dashes, emoji, hashtags, chatbot markup and any pattern marked `anyLanguage` still run in every language.
83
+ */
84
+ export const LISTED_LANGUAGES = new Set(["en", "fr"]);
85
+
86
+ /**
87
+ * The first person against the second, per language.
88
+ */
89
+
90
+ /*
91
+ * The English-only sets were the whole check until 5 Sep 2026, so every French draft counted 0 against 0 and failed `selfish-framing` by construction.
92
+ */
93
+
94
+ /*
95
+ * The check now runs on the detected language and only fires when the writer actually used the first person: copy with no pronouns at all is a reference page,
96
+ */
97
+
98
+ /*
99
+ * not a page about its author.
100
+ */
101
+ export const PRONOUNS = {
102
+ en: {
103
+ // Case-sensitive: a lone `i` is a loop index, `US` a country, and `Annex I` a numeral.
104
+ first:
105
+ /(?<![\p{L}\p{N}_])(?:(?<!(?:Annex|Article|Title|Chapter|Part|Section|Phase|Tier) )I|[Ww]e|WE|[Mm]y|[Oo]urs?|OUR|[Mm]ine|[Uu]s)(?![\p{L}\p{N}_])/gu,
106
+ second: /(?<![\p{L}\p{N}_])(?:you|your|yours)(?![\p{L}\p{N}_])/giu,
107
+ },
108
+ fr: {
109
+ first: /(?<![\p{L}\p{N}_])(?:je|j'|nous|mon|ma|mes|notre|nos|moi|me)(?![\p{L}\p{N}_])/giu,
110
+ second: /(?<![\p{L}\p{N}_])(?:vous|votre|vos|tu|ton|ta|tes|toi)(?![\p{L}\p{N}_])/giu,
111
+ },
112
+ };
package/slop-views.js CHANGED
@@ -79,7 +79,33 @@ export function withStringStarts(text) {
79
79
  * and it holds its own subheadings by design. `question-heading` and `empty-section` skip it rather than asking a page to hide the question it answers.
80
80
  */
81
81
  export const FAQ_TITLE =
82
- /^(?:FAQ|F\.A\.Q\.?|Frequently asked questions|よくある質問|Questions? fréquentes?)$/i;
82
+ /^(?:FAQ|F\.A\.Q\.?|Frequently asked questions|よくある質問|Questions? fréquentes?|Häufig gestellte Fragen|Häufige Fragen)$/i;
83
+
84
+ /**
85
+ * A link's address is not copy: the `/us/` in an App Store link counted as the English "us" on Seam's German brain-fm page, 3 Nov 2026.
86
+ */
87
+
88
+ /*
89
+ * Letters and digits become `x` while length and punctuation stay, so every other check reads the same shape. Emptied, it moved 5 English hits.
90
+ */
91
+
92
+ /*
93
+ * The chatbot `artifacts` read the raw address, because `utm_source=chatgpt.com` is the sign.
94
+ */
95
+ const WEB_TLD = "(?:com|org|net|io|co|fm|app|dev|ai|eu|uk|de|fr|jp|me|so|gg|tv|ly|sh|xyz)";
96
+ const mask = (address) => address.replace(/[\p{L}\p{N}]/gu, "x");
97
+ export function withoutUrls(text) {
98
+ return text
99
+ .replace(
100
+ /(\]\()((?:[^()\s]|\([^()\s]*\))*)(?=(?:\s+"[^"\n]*")?\))/g,
101
+ (_, open, address) => open + mask(address),
102
+ )
103
+ .replace(/\b(?:https?:\/\/|www\.)[^\s<>"'`)\]]+/gi, mask)
104
+ .replace(
105
+ new RegExp(`(?<![\\p{L}\\p{N}@./-])(?:[a-z0-9-]+\\.)+${WEB_TLD}\\/[^\\s<>"'\`)\\]]*`, "gu"),
106
+ mask,
107
+ );
108
+ }
83
109
 
84
110
  export function withoutFaqSections(text) {
85
111
  let depth = 0;
package/slop.d.ts CHANGED
@@ -12,8 +12,8 @@ export type SlopAudit = {
12
12
  findings: SlopFinding[];
13
13
  /** Shapes a regex cannot judge. Reported, never failed. */
14
14
  review: SlopFinding[];
15
- /** The language the checks ran in. English on a tie. */
16
- language: "en" | "fr";
15
+ /** The language the checks ran in, as a 2-letter code: declared, else counted. English on a tie. */
16
+ language: string;
17
17
  /** First-person against second-person word counts, in that language. */
18
18
  ledger: { first: number; second: number };
19
19
  words: number;
@@ -40,14 +40,27 @@ export declare function stripInvisibles(
40
40
  /** True when the text carries nothing invisible. */
41
41
  export declare function isClean(text: string): boolean;
42
42
 
43
- /** Which language the draft is in, by stopword count. English on a tie. */
44
- export declare function detectLanguage(text: string): "en" | "fr";
43
+ /** Which language the draft is in: `ja` by script, else `en`, `fr` or `de` by stopword count. English on a tie. */
44
+ export declare function detectLanguage(text: string): "en" | "fr" | "de" | "ja";
45
+
46
+ /** The language a file declares: frontmatter `lang`, `locale` or `language`, then a `/de/`-style folder in its path. */
47
+ export declare function declaredLanguage(source?: string, path?: string): string | undefined;
45
48
 
46
49
  /** The enumerable half of the humanizer, over one string. Never rewrites. */
47
- export declare function auditSlop(text: string): SlopAudit;
50
+ export declare function auditSlop(
51
+ text: string,
52
+ options?: { code?: boolean; language?: string },
53
+ ): SlopAudit;
48
54
 
49
55
  /** Clean, then audit. The one call a publishing path makes. */
50
56
  export declare function slopGate(
51
57
  raw: string,
52
- options?: { markup?: boolean; normalizeSpaces?: boolean },
58
+ options?: {
59
+ markup?: boolean;
60
+ code?: boolean;
61
+ normalizeSpaces?: boolean;
62
+ register?: import("./register.js").RegisterName;
63
+ /** A 2-letter code the caller already knows. The word, phrase and sentence lists run only on `en` and `fr`. */
64
+ language?: string;
65
+ },
53
66
  ): SlopLint;
package/slop.js CHANGED
@@ -50,6 +50,12 @@ import { phrases, words } from "#lint/data/slop-words.js";
50
50
  import { artifacts } from "#lint/data/slop/artifacts.js";
51
51
  import { patterns } from "#lint/data/slop/patterns.js";
52
52
  import { REGISTERS, auditRegister } from "#lint/register.js";
53
+ import {
54
+ LISTED_LANGUAGES,
55
+ PRONOUNS,
56
+ declaredLanguage,
57
+ detectLanguage,
58
+ } from "#lint/slop-language.js";
53
59
  import {
54
60
  FAQ_TITLE,
55
61
  copyStrings,
@@ -58,9 +64,13 @@ import {
58
64
  withoutCode,
59
65
  withoutComments,
60
66
  withoutFaqSections,
67
+ withoutUrls,
61
68
  } from "#lint/slop-views.js";
62
69
  import { auditShorts } from "@heyramzi/social/shorts";
63
70
 
71
+ // Part of the `@heyramzi/lint/slop` API that `slop.d.ts` declares.
72
+ export { declaredLanguage, detectLanguage };
73
+
64
74
  const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
65
75
 
66
76
  /**
@@ -89,7 +99,7 @@ export function stripMarkup(raw) {
89
99
  .replace(/<(script|style)[\s\S]*?<\/\1>/gi, " ")
90
100
  // A markup comment is a note to the next developer, not copy.
91
101
 
92
- // It goes with the script block, for the same reason: the CBAM pages rule their sections with `<!-- name -->` wrapped in rows of em dashes, which reported 8 dashes nobody reads.
102
+ // It goes with the script block: the CBAM pages rule their sections with `<!-- name -->` in rows of em dashes, which reported 8 dashes nobody reads.
93
103
  .replace(/<!--[\s\S]*?-->/g, " ")
94
104
  .replace(/&[a-z]+;|&#\d+;/gi, " ")
95
105
  .replace(/<[^>]+>/g, " ");
@@ -253,68 +263,6 @@ const EMOJI =
253
263
  */
254
264
  const HASHTAG = /(?<=[^\n#]\s|^\s*\S[^\n]*?\s)#(?![0-9a-fA-F]{3,8}\b)(?!\d+\b)[A-Za-z][\w-]*/g;
255
265
 
256
- /**
257
- * Which language the draft is in, so the checks that only work in one of them pick the right list.
258
- */
259
-
260
- /*
261
- * Stopword counting, not a library.
262
- */
263
-
264
- /*
265
- * The two sets share almost nothing, a draft of any length separates them by a wide margin, and the only caller that can be hurt by a wrong answer is
266
- */
267
-
268
- /*
269
- * the pronoun ledger, which reports rather than rewrites. English is the default on a tie, including on an empty string.
270
- */
271
- const FR_STOPWORDS =
272
- /(?<![\p{L}\p{N}_])(?:le|la|les|des|une|un|et|est|dans|pour|que|qui|pas|avec|sur|plus|cette|vous|nous|aux|mais|sont|être|ce|se|son|ses|leur|par|au|du|elle|il)(?![\p{L}\p{N}_])/giu;
273
- const EN_STOPWORDS =
274
- /(?<![\p{L}\p{N}_])(?:the|and|is|of|to|in|that|it|for|with|you|this|are|on|but|not|have|from|as|was|they|be|at|by|or|an|its|their)(?![\p{L}\p{N}_])/giu;
275
-
276
- export function detectLanguage(text) {
277
- // Japanese first, and by script rather than by stopword.
278
-
279
- // A Japanese draft has no English or French stopwords of its own, so the count is decided by whatever it quotes, and every Japanese page on the Wavenote site came
280
-
281
- // back "en" and was then graded on English pronouns it does not use.
282
- const cjk = (text.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/g) ?? []).length;
283
- const letters = (text.match(/[\p{L}]/gu) ?? []).length;
284
- if (letters > 0 && cjk / letters > 0.2) return "ja";
285
- const fr = (text.match(FR_STOPWORDS) ?? []).length;
286
- const en = (text.match(EN_STOPWORDS) ?? []).length;
287
- return fr > en ? "fr" : "en";
288
- }
289
-
290
- /**
291
- * The first person against the second, per language.
292
- */
293
-
294
- /*
295
- * The English-only sets were the whole check until 5 Sep 2026, so every French draft counted 0 against 0 and failed `selfish-framing` by construction.
296
- */
297
-
298
- /*
299
- * The check now runs on the detected language and only fires when the writer actually used the first person: copy with no pronouns at all is a reference page,
300
- */
301
-
302
- /*
303
- * not a page about its author.
304
- */
305
- const PRONOUNS = {
306
- en: {
307
- // Case-sensitive: a lone `i` is a loop index, `US` a country, and `Annex I` a numeral.
308
- first:
309
- /(?<![\p{L}\p{N}_])(?:(?<!(?:Annex|Article|Title|Chapter|Part|Section|Phase|Tier) )I|[Ww]e|WE|[Mm]y|[Oo]urs?|OUR|[Mm]ine|[Uu]s)(?![\p{L}\p{N}_])/gu,
310
- second: /(?<![\p{L}\p{N}_])(?:you|your|yours)(?![\p{L}\p{N}_])/giu,
311
- },
312
- fr: {
313
- first: /(?<![\p{L}\p{N}_])(?:je|j'|nous|mon|ma|mes|notre|nos|moi|me)(?![\p{L}\p{N}_])/giu,
314
- second: /(?<![\p{L}\p{N}_])(?:vous|votre|vos|tu|ton|ta|tes|toi)(?![\p{L}\p{N}_])/giu,
315
- },
316
- };
317
-
318
266
  /**
319
267
  * The signs that are only visible across a whole document, so no regex over one sentence finds them: Wikipedia's title case, heading levels,
320
268
  */
@@ -326,7 +274,7 @@ const PRONOUNS = {
326
274
  /*
327
275
  * Markdown only. HTML is stripped to prose before it reaches here, so a page audits on its words and an `.md` draft audits on its words and its outline.
328
276
  */
329
- function auditStructure(text) {
277
+ function auditStructure(text, language) {
330
278
  const found = [];
331
279
  const hit = (id, detail) => found.push({ kind: "structure", id, detail });
332
280
 
@@ -342,7 +290,7 @@ function auditStructure(text) {
342
290
 
343
291
  // and 2 of them capitalised is the threshold: "Awards and Recognition" hits, "the ClickUp API" does not.
344
292
  const names = properNouns(body);
345
- for (const heading of headings) {
293
+ for (const heading of LISTED_LANGUAGES.has(language) ? headings : []) {
346
294
  const rest = heading.title
347
295
  .split(/\s+/)
348
296
  .slice(1)
@@ -423,10 +371,14 @@ function auditStructure(text) {
423
371
  /*
424
372
  * Those are claims about the world, and a string is all this function gets.
425
373
  */
426
- export function auditSlop(draft, { code = false } = {}) {
427
- const text = code ? withoutComments(draft) : draft;
374
+ export function auditSlop(draft, { code = false, language: declared } = {}) {
375
+ const source = code ? withoutComments(draft) : draft;
376
+ // Every layer but `artifacts` reads the draft with its link addresses masked: `withoutUrls` carries why.
377
+ const text = withoutUrls(source);
428
378
  const findings = [];
429
379
  const add = (kind, id, detail) => findings.push({ kind, id, detail });
380
+ const language = declared ?? declaredLanguage(draft) ?? detectLanguage(text);
381
+ const listed = LISTED_LANGUAGES.has(language);
430
382
 
431
383
  // The ban lists read the draft with its code spans removed, because an identifier is not a word somebody chose: `enhance` is a Worker directory and `enable` is an API
432
384
 
@@ -434,11 +386,11 @@ export function auditSlop(draft, { code = false } = {}) {
434
386
 
435
387
  // The `patterns` below still read the whole text, where the surrounding sentence is what they are judging.
436
388
  const prose = withoutCode(text);
437
- for (const word of words) {
389
+ for (const word of listed ? words : []) {
438
390
  const m = prose.match(bounded(word));
439
391
  if (m) add("word", word, m[0]);
440
392
  }
441
- for (const phrase of phrases) {
393
+ for (const phrase of listed ? phrases : []) {
442
394
  // Bounded like a word, not `includes`. A substring test read "En sommeil" as the banned "en somme" and failed a dormant-status label on the UpSys site, 6 Sep 2026.
443
395
 
444
396
  // Every phrase here is whole words.
@@ -456,19 +408,24 @@ export function auditSlop(draft, { code = false } = {}) {
456
408
  prose: code ? copyStrings(text) : prose,
457
409
  };
458
410
  for (const pattern of patterns) {
459
- const m = views[pattern.view ?? "anchored"].match(pattern.test);
460
- if (m) add("pattern", pattern.id, m[0].slice(0, 90));
411
+ if (!listed && !pattern.anyLanguage) continue;
412
+ const view = views[pattern.view ?? "anchored"];
413
+ const m = view.match(pattern.test);
414
+ if (!m) continue;
415
+ // Masking keeps every index, so a hit on the masked text is shown as the writer typed it.
416
+ const hit = view === text ? source.slice(m.index, m.index + m[0].length) : m[0];
417
+ add("pattern", pattern.id, hit.slice(0, 90));
461
418
  }
462
419
  for (const artifact of artifacts) {
463
- const m = text.match(artifact.test);
420
+ const m = source.match(artifact.test);
464
421
  if (m) add("artifact", artifact.id, m[0].slice(0, 90));
465
422
  }
466
- for (const finding of auditStructure(text)) findings.push(finding);
423
+ for (const finding of auditStructure(text, language)) findings.push(finding);
467
424
  for (const m of text.matchAll(/[—–]/g)) {
468
- add("dash", "em-or-en-dash", text.slice(Math.max(0, m.index - 30), m.index + 30));
425
+ add("dash", "em-or-en-dash", source.slice(Math.max(0, m.index - 30), m.index + 30));
469
426
  }
470
427
  for (const m of text.matchAll(EMOJI)) {
471
- add("emoji", "emoji", text.slice(Math.max(0, m.index - 30), m.index + 30));
428
+ add("emoji", "emoji", source.slice(Math.max(0, m.index - 30), m.index + 30));
472
429
  }
473
430
  for (const m of withoutCode(text).matchAll(HASHTAG)) {
474
431
  add("hashtag", "hashtag", m[0]);
@@ -476,7 +433,6 @@ export function auditSlop(draft, { code = false } = {}) {
476
433
 
477
434
  const ledgerText = code ? copyStrings(text) : text;
478
435
  const count = (re) => (ledgerText.match(re) ?? []).length;
479
- const language = detectLanguage(text);
480
436
  // Only the languages with pronoun sets are graded.
481
437
 
482
438
  // Japanese marks the same distinction with particles and by leaving the subject out, so a regex over `we` and `you` says nothing about a Japanese draft.
@@ -489,13 +445,13 @@ export function auditSlop(draft, { code = false } = {}) {
489
445
  add("ledger", "selfish-framing", `first ${first}, second ${second}`);
490
446
 
491
447
  const review = [];
492
- for (const grep of PIVOT_GREPS) {
448
+ for (const grep of listed ? PIVOT_GREPS : []) {
493
449
  for (const m of text.matchAll(grep)) {
494
450
  const from = Math.max(0, m.index - 45);
495
451
  review.push({
496
452
  kind: "review-pivot",
497
453
  id: m[0].toLowerCase(),
498
- detail: `...${text.slice(from, m.index + 55)}...`,
454
+ detail: `...${source.slice(from, m.index + 55)}...`,
499
455
  });
500
456
  }
501
457
  }
@@ -537,11 +493,11 @@ export function auditSlop(draft, { code = false } = {}) {
537
493
  */
538
494
  export function slopGate(
539
495
  raw,
540
- { markup = false, code = false, normalizeSpaces = true, register } = {},
496
+ { markup = false, code = false, normalizeSpaces = true, register, language } = {},
541
497
  ) {
542
498
  const source = markup ? stripMarkup(raw) : raw;
543
499
  const cleaned = stripInvisibles(source, { normalizeSpaces });
544
- const audit = auditSlop(cleaned.text, { code });
500
+ const audit = auditSlop(cleaned.text, { code, language });
545
501
  // A ban list cannot see the fault that produced the 9 Sep 2026 Shorts batch: every script passed the words and still read as somebody else,
546
502
 
547
503
  // because the register was written and the delivery was spoken. `register.js` carries why.