slop-lint 0.8.0 → 0.10.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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +115 -32
  3. package/package.json +6 -4
  4. package/slop-lint.mjs +946 -107
package/slop-lint.mjs CHANGED
@@ -12,33 +12,79 @@
12
12
  * node slop-lint.mjs --ignore drafts # skip paths containing a substring (repeatable)
13
13
  * node slop-lint.mjs --fail-on-warn . # exit 1 on warnings too (strict CI mode)
14
14
  * node slop-lint.mjs --quiet . # only print files that have hits
15
+ * node slop-lint.mjs --allow tapestry . # permit a word/phrase for this run (repeatable)
16
+ * node slop-lint.mjs --config team.json . # read the allow list from an explicit file
17
+ * node slop-lint.mjs --profile pr body.md # add an opt-in register group (repeatable)
18
+ * node slop-lint.mjs --code src/ # lint comments in code files (= --profile code)
19
+ * node slop-lint.mjs --no-rates . # skip the document-level rate advisories
15
20
  * node slop-lint.mjs --version # print the catalogue version
16
21
  * node slop-lint.mjs --list # print the catalogue with its sources
17
22
  * git ls-files '*.md' | xargs node slop-lint.mjs # lint tracked markdown
18
23
  *
19
24
  * Tells fade as models train against them and new ones appear with each release, so
20
- * the catalogue is sourced and versioned (see CHANGELOG.md). Find candidate new tells
21
- * empirically with --discover (see below).
25
+ * the catalogue is sourced, versioned, and labelled by era and evidence (see
26
+ * CHANGELOG.md). Find candidate new tells empirically with --discover (see below).
22
27
  *
23
- * Severity, deliberately conservative (these words also appear in good human
24
- * writing, so false positives are the main risk and almost everything is a warning):
25
- * FAIL (exit 1): the em-dash character (U+2014). The one near-decisive typographic tell.
26
- * WARN: everything else, flagged for a human look, never auto-removed.
28
+ * Allow list (optional): some content legitimately needs a catalogued word or phrase
29
+ * (a product named Tapestry, a doc that must say "robust"). Put those in a
30
+ * `.slop-lint.json` next to where you run the tool:
31
+ * { "allow": ["tapestry", "robust"], "profiles": ["pr"] }
32
+ * Each allow entry disables every word/phrase rule its text triggers, so you can paste
33
+ * the flagged text verbatim. Typographic tells (em-dash, "--", smart quotes, emoji) and
34
+ * machine artifacts are never suppressed.
35
+ *
36
+ * Severity, deliberately conservative (most of these words and shapes also appear in
37
+ * good human writing, so false positives are the main risk):
38
+ * FAIL (exit 1): the em-dash (U+2014), as a house-style rule. As an authorship signal
39
+ * it is strongest for Claude through Opus 5 and for older OpenAI output;
40
+ * newer models suppress it, so a clean result says nothing about
41
+ * authorship. Also FAIL: machine artifacts that people never type
42
+ * (chatbot citation residue, chatbot utm_source links, UI leakage).
43
+ * WARN: words, phrases, constructions, layout rules. Flagged for a look,
44
+ * never auto-removed.
45
+ * ADVISORY (i): document-level rates (sentence rhythm, participial tails,
46
+ * nominalizations, tricolons, ...) for prose of 15+ sentences. Printed,
47
+ * never counted toward the exit code. Structure moves slower than
48
+ * vocabulary between model releases, so these age better than word lists.
49
+ *
50
+ * Fenced code blocks and inline code spans are skipped by the word, phrase and layout
51
+ * rules (quote a tell in backticks to discuss it); typography and artifacts are
52
+ * checked everywhere.
27
53
  */
28
54
 
29
- import { readFileSync, readdirSync, statSync } from "node:fs";
55
+ import { readFileSync, readdirSync, statSync, existsSync, realpathSync } from "node:fs";
30
56
  import { join, sep, extname } from "node:path";
31
57
  import { pathToFileURL } from "node:url";
32
58
 
33
- export const VERSION = "0.6.0";
59
+ export const VERSION = "0.10.0";
60
+
61
+ // Opt-in register groups. A WORD_GROUPS / PHRASE_GROUPS entry with a `profile` only
62
+ // runs when that profile is enabled (--profile, or "profiles" in .slop-lint.json).
63
+ export const PROFILES = {
64
+ pr: "pull-request descriptions and commit text: template headings, boilerplate test claims, PR-era vocabulary",
65
+ email: "email: stock openers and closers",
66
+ social: "social posts (LinkedIn-style): announcement and engagement-bait formulas",
67
+ fiction: "fiction: creative-writing slop vocabulary (Antislop)",
68
+ wiki: "encyclopedic prose: notability padding, legacy puffery, stock sections",
69
+ review: "peer reviews: second-tier praise adjectives, bold tag headers",
70
+ academic: "papers: centrality-claim openers, gap formulas, citation clumps",
71
+ code: "code files: lint comments only, plus code-comment rules (chat leakage, step narration, history comments, placeholders)",
72
+ };
34
73
 
35
- // Catalogue, grouped by provenance. Each group carries the version it was added in
36
- // and its source, so the list can be pruned with confidence as tells fade. Edit a
37
- // group's `words`, record the change in CHANGELOG.md, and bump the version.
74
+ // Catalogue, grouped by provenance. Each group carries the version it was added in,
75
+ // its source, an evidence grade, and (where the record shows one) the era in which the
76
+ // tell peaked, so the list can be pruned or demoted with confidence as tells fade.
77
+ // Evidence: M1 = large corpus or controlled study; M2 = measured but weaker (one corpus,
78
+ // vendor counts, unlabelled clusters); P = independent practitioner reports; A = anecdote.
79
+ // `screened` records the date a group last passed the false-positive screen (zero hits on
80
+ // corpus/baseline/**/*.txt); a test re-runs it, so a baseline rebuild re-screens them.
81
+ // Edit a group, record the change in CHANGELOG.md, and bump the version.
38
82
  export const WORD_GROUPS = [
39
83
  {
40
84
  since: "0.1.0",
41
85
  source: "FSU 'delve' focal-word study; PubMed 135-term analysis",
86
+ evidence: "M1",
87
+ era: "GPT-3.5/4 (peak 2023-2024; declining on arXiv since spring 2024, Geng & Trotta)",
42
88
  words: [
43
89
  "delve", "delves", "delving", "intricate", "intricately", "commendable",
44
90
  "meticulous", "meticulously", "underscore", "underscores", "underscoring",
@@ -51,6 +97,8 @@ export const WORD_GROUPS = [
51
97
  {
52
98
  since: "0.1.0",
53
99
  source: "Pangram / Grammarly / practitioner marketing-buzzword blacklists",
100
+ evidence: "P",
101
+ era: "GPT-4 (2023-2025; the GPT-4-era PR cluster fell from 11.4% to 1.5% of PR descriptions by Nov 2026)",
54
102
  words: [
55
103
  "leverage", "leveraging", "synergy", "robust", "seamless", "seamlessly",
56
104
  "transformative", "scalable", "cutting-edge", "game-changer", "game changer",
@@ -62,6 +110,7 @@ export const WORD_GROUPS = [
62
110
  {
63
111
  since: "0.1.0",
64
112
  source: "practitioner blacklists (vague metaphors / meta-discourse nouns)",
113
+ evidence: "P",
65
114
  words: [
66
115
  "landscape", "journey", "roadmap", "ecosystem", "beacon", "symphony", "myriad",
67
116
  "plethora", "facet", "illuminate", "navigate", "navigating",
@@ -70,6 +119,8 @@ export const WORD_GROUPS = [
70
119
  {
71
120
  since: "0.1.0",
72
121
  source: "practitioner blacklists (booster adverbs / filler transitions)",
122
+ evidence: "P",
123
+ note: "weak alone: Wikipedia lists transitions as an ineffective indicator, though 'additionally' and 'notably' are in Kobak's estimator",
73
124
  words: [
74
125
  "furthermore", "moreover", "additionally", "nonetheless", "nevertheless",
75
126
  "undoubtedly", "notably", "strategically",
@@ -80,6 +131,8 @@ export const WORD_GROUPS = [
80
131
  // positives (crucial, such as, overall, rich, featuring, align with) were rejected.
81
132
  since: "0.3.0",
82
133
  source: "Wikipedia: Signs of AI writing (Words to watch) + practitioner blacklists",
134
+ evidence: "P",
135
+ era: "promotional words ('boasts', 'nestled') are 'historical (2023-2025)' on Wikipedia",
83
136
  words: [
84
137
  "bolster", "bolsters", "bolstered", "bolstering", "groundbreaking", "renowned",
85
138
  "exemplifies", "encompassing", "enhance", "enhances", "enhancing", "enhanced",
@@ -93,97 +146,843 @@ export const WORD_GROUPS = [
93
146
  // identical prompts. A booster adverb in the same family as the 0.1.0 set.
94
147
  since: "0.5.0",
95
148
  source: "empirical: cross-model corpus discovery (--discover)",
149
+ evidence: "M2",
96
150
  words: ["incredibly"],
97
151
  },
152
+ {
153
+ // Inflection completion: 0.1.0 has resonate/resonates, but the reply-register
154
+ // validate-open is past tense ("this really resonated").
155
+ since: "0.9.0",
156
+ source: "empirical: reply-bot specimens (validate-open 'this really resonated')",
157
+ evidence: "P",
158
+ words: ["resonated", "resonating"],
159
+ },
160
+ {
161
+ // Matching is whole-word, so inflections of catalogued stems passed until now.
162
+ // These forms are on the Kobak et al. excess-word list by name (berenslab
163
+ // llm-excess-vocab, results/excess_words.csv). Held despite being on the list:
164
+ // "elevated" (routine clinical wording) and "garnered", "surpassed", "utilized",
165
+ // "utilizing" (each above 0.64 per 100k words in pre-2023 human registers, the 75th
166
+ // percentile of the established catalogue, with no excess in corpus/samples).
167
+ since: "0.10.0",
168
+ source: "Kobak et al. 2025 (Science Advances) excess-vocabulary list: inflections of catalogued stems",
169
+ evidence: "M1",
170
+ era: "GPT-3.5/4 (2023-2025)",
171
+ words: [
172
+ "delved", "showcased", "underscored", "fosters", "fostering", "garnering",
173
+ "leverages", "harnesses", "harnessing", "empowers", "unlocking", "revolutionizing",
174
+ "realms", "encompass", "encompasses", "encompassed", "surpassing", "illuminates",
175
+ "illuminating", "utilizes", "intricacies",
176
+ ],
177
+ },
178
+ {
179
+ // Inflection completion for stems in the practitioner groups; graded like the stem.
180
+ since: "0.10.0",
181
+ source: "inflection completion of catalogued stems (graded by the stem's group)",
182
+ evidence: "P",
183
+ words: [
184
+ "fostered", "garners", "leveraged", "harnessed", "empowering", "empowered",
185
+ "unlocks", "unleashing", "unleashed", "unleashes", "revolutionized", "utilization",
186
+ "boasting", "boasted", "exemplify", "exemplified", "exemplifying", "navigates",
187
+ "navigated", "testaments", "facets", "tapestries", "journeys", "landscapes",
188
+ "supercharged", "supercharging",
189
+ ],
190
+ },
191
+ {
192
+ // Screened to zero hits on corpus/baseline (2026-11-25). "potent", "amidst" and
193
+ // "unprecedented" hit human oratory/journalism and are held; "unveiled", "akin" and
194
+ // "revolutionary" are held after the pre-2023 register screen (screen-registers.mjs).
195
+ since: "0.10.0",
196
+ source: "Kobak et al. 2025 excess style words (Fig. S6); Liang et al. 2024 peer-review adverbs; Yakura et al. 2024; Batalo et al. 2025 hype annotation ('unparalleled')",
197
+ screened: "2026-11-25",
198
+ evidence: "M1",
199
+ words: [
200
+ "elucidate", "elucidates", "elucidating", "unveil", "unveils", "unveiling", "burgeoning", "unparalleled", "uncharted", "underexplored",
201
+ "surmount", "interconnectedness", "interplay", "nuanced", "poised",
202
+ "adept", "pinpoint", "groundwork", "juxtaposed", "emphasizing", "lucidly",
203
+ "aptly", "methodically", "innovatively", "compellingly", "impressively",
204
+ "excellently",
205
+ ],
206
+ },
207
+ {
208
+ // The 2025-2026 "staging" vocabulary. load-bearing: one user measured 0.5 -> 12.0
209
+ // hits per 10k words across three Opus 4.6/4.7 sessions (claude-code #53454; a
210
+ // separate method put Opus 5 near 2 per 10k, so not one trend). Lifts in the
211
+ // Abraham PR-description corpus (544,271 docs, fit of 2026-11-25; it refits daily):
212
+ // load-bearing 12.3, quietly 7.5, genuinely 7.2. "quietly" is also on Wikipedia's
213
+ // GPT-6 list. Not screened: the baseline has one human "quietly" (oratory).
214
+ // "frankly" (one practitioner list plus a secondhand Arena figure) is held, and bare
215
+ // "honestly" hits human oratory, so only the "Honestly?" fragment ships.
216
+ since: "0.10.0",
217
+ source: "claude-code #53454; Abraham PR-description corpus (2025-2026); Wikipedia GPT-6 list ('quietly'); practitioner lists",
218
+ evidence: "M2",
219
+ era: "Claude Opus 4.7-5.x, GPT-5.x/6 (2025-2026)",
220
+ words: ["load-bearing", "quietly", "genuinely"],
221
+ },
222
+ {
223
+ // Creative-writing slop that leaks into general prose (GPT-4o "camaraderie" 162x,
224
+ // "palpable" 95x vs human, Reinhart et al. Table 1). Screened to zero baseline hits.
225
+ since: "0.10.0",
226
+ source: "Reinhart et al. 2025 (PNAS), Table 1, GPT-4o",
227
+ screened: "2026-11-25",
228
+ evidence: "M1",
229
+ words: ["camaraderie", "palpable"],
230
+ },
231
+ // -- opt-in register groups --------------------------------------------------
232
+ {
233
+ since: "0.10.0",
234
+ profile: "review",
235
+ source: "Liang et al. 2024 (ICLR/NeurIPS review vocabulary, top-100 appendix)",
236
+ evidence: "M1",
237
+ words: ["laudable", "cogent", "ingenious", "admirable", "refreshing", "intriguing", "insightful"],
238
+ },
239
+ {
240
+ since: "0.10.0",
241
+ profile: "pr",
242
+ source: "Abraham PR-description corpus, rising 2025-2026 clusters (unlabelled; attribution inferred)",
243
+ evidence: "M2",
244
+ era: "2025-2026",
245
+ note: "testing jargon overlaps ('vacuous truth', 'fail loudly'); run --discover on your own PR text before trusting",
246
+ words: [
247
+ "plainly", "vacuous", "vacuously", "provably", "wedged", "chokepoint", "tripwire",
248
+ "carve-out", "backstop", "papered", "structurally", "loudly",
249
+ ],
250
+ },
251
+ {
252
+ since: "0.10.0",
253
+ profile: "pr",
254
+ source: "Abraham PR-description corpus, GPT-4-era cluster (fell from 11.4% to 1.5% of descriptions)",
255
+ evidence: "M2",
256
+ era: "2023-2025",
257
+ words: ["enterprise-grade", "production-ready", "ai-powered"],
258
+ },
259
+ {
260
+ since: "0.10.0",
261
+ profile: "fiction",
262
+ source: "Antislop / slop-score (Paech 2025: 'flickered' in the top list of 98.5% of 67 models)",
263
+ evidence: "M1",
264
+ words: ["flickered", "shimmered", "unease", "newfound", "unspoken", "etched", "unsettlingly", "elara", "kael"],
265
+ },
266
+ ];
267
+
268
+ // Flat list of the always-on words (derived from the sourced groups above).
269
+ export const WORDS = WORD_GROUPS.filter((g) => !g.profile).flatMap((g) => g.words);
270
+ // Every word including opt-in profile groups.
271
+ export const ALL_WORDS = WORD_GROUPS.flatMap((g) => g.words);
272
+
273
+ // Phrases and constructions, grouped like the words. Rule fields:
274
+ // re the pattern (tested per line, and across the lines of a paragraph)
275
+ // msg what the report prints
276
+ // lineOnly ^ means "start of the line" (in social text, the start of a reply), so
277
+ // the rule is not re-run on joined paragraphs
278
+ // position "first" = first sentence of the prose only; "last" = last two sentences
279
+ // family "contrast" rules also feed the negative-contrast density advisory
280
+ // unless skip the rule when the line (or joined paragraph) also matches this
281
+ // anchor "sentence": ^ means "start of a sentence"; on joined paragraphs the rule
282
+ // is tried from each sentence start, so the two-sentence shape is caught
283
+ // when a soft line break splits it
284
+ export const PHRASE_GROUPS = [
285
+ {
286
+ since: "0.1.0",
287
+ source: "Wikipedia 'Signs of AI writing' essay; practitioner blacklists",
288
+ evidence: "P",
289
+ rules: [
290
+ // intro / scene-setting cliches
291
+ { re: /\bin today'?s (fast[- ]paced )?(world|digital age|digital landscape)\b/i, msg: '"in today\'s ... world" intro' },
292
+ { re: /\bin the (ever[- ]evolving|dynamic) (landscape|world) of\b/i, msg: '"ever-evolving landscape" intro' },
293
+ { re: /\bas the world continues to evolve\b/i, msg: '"as the world continues to evolve"' },
294
+ { re: /\bimagine a world where\b/i, msg: '"imagine a world where"' },
295
+ { re: /\bat its core\b/i, msg: '"at its core"' },
296
+ // expository cliches
297
+ { re: /\bplays? an? (crucial|important|key|vital|pivotal|significant) role\b/i, msg: '"plays a crucial role"' },
298
+ { re: /\bis a testament to\b/i, msg: '"is a testament to"' },
299
+ { re: /\bserves? as a (powerful|valuable|vital) tool\b/i, msg: '"serves as a powerful tool"' },
300
+ { re: /\bcannot be overstated\b/i, msg: '"cannot be overstated"' },
301
+ { re: /\bhas become increasingly (important|popular|common)\b/i, msg: '"has become increasingly ..."' },
302
+ // reader framing
303
+ { re: /\bwhen it comes to\b/i, msg: '"when it comes to"' },
304
+ { re: /\bwhether you'?re (a |an )?.+ or (a |an )?.+/i, msg: '"whether you\'re X or Y" framing' },
305
+ { re: /\bno matter where you are (on|in) your journey\b/i, msg: '"no matter where you are on your journey"' },
306
+ { re: /\bif you'?re looking to\b/i, msg: '"if you\'re looking to"' },
307
+ // vague filler
308
+ { re: /\bat the end of the day\b/i, msg: '"at the end of the day"' },
309
+ { re: /\bfor all intents and purposes\b/i, msg: '"for all intents and purposes"' },
310
+ { re: /\bwith that in mind\b/i, msg: '"with that in mind"' },
311
+ { re: /\bthe fact of the matter is\b/i, msg: '"the fact of the matter is"' },
312
+ { re: /\bin a nutshell\b/i, msg: '"in a nutshell"' },
313
+ { re: /\bneedless to say\b/i, msg: '"needless to say"' },
314
+ { re: /\bthat being said\b/i, msg: '"that being said"' },
315
+ { re: /\bdeep dive\b/i, msg: '"deep dive"' },
316
+ // hedging / throat-clearing
317
+ { re: /\bit'?s (important|worth|essential) (to note|noting|to consider|considering|to recognize) that\b/i, msg: "hedge: \"it's worth noting that ...\"", family: "hedge" },
318
+ { re: /\bwhile it is true that\b/i, msg: '"while it is true that"', family: "hedge" },
319
+ { re: /\bit could be argued that\b/i, msg: '"it could be argued that"', family: "hedge" },
320
+ { re: /\bgenerally speaking\b/i, msg: '"generally speaking"', family: "hedge" },
321
+ // meta-structure
322
+ { re: /\bthis (article|post|paper|piece) will (explore|examine|cover|delve into|look at)\b/i, msg: '"this article will explore"' },
323
+ { re: /\blet'?s (take a closer look|dive in|explore|unpack)\b/i, msg: '"let\'s dive in / take a closer look"' },
324
+ { re: /\bhere'?s (the thing|why)\b/i, msg: '"here\'s the thing/why"' },
325
+ // closing tics
326
+ { re: /\b(in conclusion|in summary|to sum up|to wrap up|to conclude)\b/i, msg: "conclusion ritual" },
327
+ { re: /\bthe possibilities are endless\b/i, msg: '"the possibilities are endless"' },
328
+ { re: /\bthe future (is|looks) (bright|promising)\b/i, msg: '"the future is bright"' },
329
+ { re: /\bonly time will tell\b/i, msg: '"only time will tell"' },
330
+ { re: /\bthe journey (is just beginning|doesn'?t end here)\b/i, msg: '"the journey is just beginning"' },
331
+ // syntactic constructions
332
+ { re: /\b(not|don'?t|doesn'?t|didn'?t) (just|only)\b[^.?!]{0,60}\b(but|it'?s|they'?re|its)\b/i, msg: '"not just X, but Y"', family: "contrast" },
333
+ { re: /\b(it'?s|we'?re|they'?re)\s+(not|never)(\s+just)?\b[^.?!]{1,80}?\b(it'?s|we'?re|they'?re)\b/i, msg: '"it\'s not X, it\'s Y" negated contrast', family: "contrast" },
334
+ ],
335
+ },
336
+ {
337
+ since: "0.3.0",
338
+ source: "Wikipedia: Signs of AI writing (assistant leakage + high-signal cliches)",
339
+ evidence: "P",
340
+ rules: [
341
+ { re: /\bas an? (ai|large) language model\b/i, msg: '"as an AI/large language model" (assistant leakage)' },
342
+ { re: /\bi hope this helps\b/i, msg: '"I hope this helps" (assistant sign-off)' },
343
+ { re: /\bin the heart of\b/i, msg: '"in the heart of"' },
344
+ { re: /\ba diverse array of\b/i, msg: '"a diverse array of"' },
345
+ { re: /\bvaluable insights\b/i, msg: '"valuable insights"' },
346
+ { re: /\b(stands|serves) as a testament\b/i, msg: '"stands/serves as a testament"' },
347
+ { re: /\bsetting the stage for\b/i, msg: '"setting the stage for"' },
348
+ { re: /\bindelible mark\b/i, msg: '"indelible mark"' },
349
+ { re: /\bdeeply rooted in\b/i, msg: '"deeply rooted in"' },
350
+ { re: /\brich (cultural )?(tapestry|heritage)\b/i, msg: '"rich cultural heritage/tapestry"' },
351
+ ],
352
+ },
353
+ {
354
+ // AI comment-reply rhetoric, sourced from reply-bot specimens collected off social
355
+ // threads. The reply register favors validate-then-restate openers and standalone
356
+ // aphorism molds that long-form corpus discovery can't see. Every rule was
357
+ // FP-screened against corpus/baseline (0 hits); the uncontracted negated contrast is
358
+ // also corroborated in corpus/samples. The ^ anchors mean "starts the line", which
359
+ // in social text is the start of the reply.
360
+ since: "0.9.0",
361
+ source: "empirical: reply-bot specimens (corpus/specimens), two independent sightings each",
362
+ screened: "2026-11-25",
363
+ evidence: "P",
364
+ rules: [
365
+ { re: /^\s*that('?s| is) the [^.?!]{1,40}\.(\s|$)/i, msg: 'validate-then-restate opener ("That is/That\'s the ...")', lineOnly: true },
366
+ { re: /\b(you'?re describing|what you (just )?described)\b/i, msg: 'validate-then-restate ("what you\'re describing")' },
367
+ { re: /\byou'?re (absolutely right|right that)\b/i, msg: 'concessive validation ("you\'re right that ...")' },
368
+ { re: /\b(such )?a sharp (addition|point|observation|framing|distinction|question|way)\b/i, msg: '"a sharp addition/point" compliment-open' },
369
+ { re: /^[^.?!]{1,45}\b(isn'?t|is not|aren'?t|are not) (the|an?|about|just)\b[^.?!]{1,100}[.?!]\s+it(?:'?s| is)\b/i, msg: '"A isn\'t the X. It is the Y." negated contrast (uncontracted)', anchor: "sentence", family: "contrast" },
370
+ { re: /\b(doesn'?t|does not) [^.?!]{1,60}, it (just|only|simply|actually)\b/i, msg: '"doesn\'t X, it just Y" contrast', family: "contrast" },
371
+ { re: /\bcan (\w{3,})\b[^.?!]{0,80}[.?!]\s+(?!if |when |unless )(?:\w+ ){0,2}can(?:'t|not)\b (?:\w+ )?\1\b/i, msg: '"can X ... can\'t X" modal antithesis (verb echo)', family: "contrast" },
372
+ { re: /\bthe real (open )?(question|test) (of|is|isn'?t|will be)\b/i, msg: '"the real question/test" pivot' },
373
+ { re: /^\s*which (means|might|may|is why|is where|is what)\b/i, msg: '"Which means/might ..." fragment opener', lineOnly: true },
374
+ { re: /(^|[.?!]\s+)worth noting\b/i, msg: 'hedge: "worth noting ..." (clause-initial)', family: "hedge" },
375
+ { re: /\bthe (uncomfortable|deeper|harder|honest|quiet) (question|truth|answer|reality|tension)\b/i, msg: '"the uncomfortable question/truth" framing' },
376
+ { re: /\bthe most (important|powerful|dangerous) form of\b/i, msg: '"the most important form of X" hedged superlative' },
377
+ { re: /\bis what keeps [^.?!]{1,50}from (becoming|turning into)\b/i, msg: '"X is what keeps A from becoming B" aphorism mold' },
378
+ { re: /\bis measured by how\b/i, msg: '"is measured by how" aphorism mold' },
379
+ { re: /\b(\w{3,}?)e?s\b[^.?!]{1,50}\bwithout \1ing\b/i, msg: '"lowers X without lowering Y" parallel antithesis', family: "contrast" },
380
+ { re: /\bas an? \w+, not an? \w+[.!]/i, msg: '"as a hypothesis, not a promise" antithesis close', family: "contrast" },
381
+ { re: /\bnobody (\w{3,}?)e?s\b[^.?!]{1,60}\bthey \1/i, msg: 'corrective anaphora ("nobody polices X, they police Y")', family: "contrast" },
382
+ ],
383
+ },
384
+ {
385
+ // Second collection pass (feed mining, 2026-07): same screen, two independent
386
+ // sightings each. "as ... rather than" is also corroborated in corpus/samples.
387
+ since: "0.9.0",
388
+ source: "empirical: reply-bot feed mining (2026-07), two independent sightings each",
389
+ screened: "2026-11-25",
390
+ evidence: "P",
391
+ rules: [
392
+ { re: /\b\w+ isn'?t (really )?(the|an?) [^.?!]{1,60}, it'?s\b/i, msg: '"X isn\'t the A, it\'s B" negated contrast (noun subject)', family: "contrast" },
393
+ { re: /\b(will|are going to) be (those|the ones) who\b/i, msg: '"will be those who ..." superlative prediction' },
394
+ { re: /\bas an? [\w-]+( [\w-]+){0,3} rather than an?\b/i, msg: '"as an X rather than a Y" reframe', family: "contrast" },
395
+ { re: /\ban? [\w-]+( [\w-]+)? (problem|failure|issue|question)\b[^.?!]{0,40}\ban? [\w-]+( [\w-]+)? one\b/i, msg: '"a tech problem, a change-management one" echo', family: "contrast" },
396
+ { re: /\btrue \w+ (requires|lies in|demands|means)\b/i, msg: '"True X requires/lies in ..." aphorism open' },
397
+ { re: /\b(don'?t|doesn'?t) (\w{3,})\b[^.?!]{1,60},\s*(they|it|we) \2/i, msg: 'corrective anaphora ("don\'t mark X, they mark Y")', family: "contrast" },
398
+ ],
399
+ },
400
+ // -- 0.10.0 additions. Every always-on rule below was screened to zero hits on the
401
+ // paragraph-preserving corpus/baseline (2026-11-25); a test re-runs the screen. --
402
+ {
403
+ since: "0.10.0",
404
+ source: "Pangram phrase rates; Sun et al. 2025 (Idiosyncrasies in LLMs); Academ-AI (768 cases); Wikipedia",
405
+ screened: "2026-11-25",
406
+ evidence: "M2",
407
+ rules: [
408
+ { re: /^\s*(certainly|absolutely|of course|sure)!/i, msg: 'assistant opener ("Certainly!")', lineOnly: true },
409
+ { re: /\bcertainly,? here (is|are)\b/i, msg: 'assistant leakage ("Certainly, here is")' },
410
+ { re: /(^|[.!?]\s+)(great|good|excellent) (question|point|catch)[!.]/i, msg: 'praise-before-answer ("Great question!")' },
411
+ { re: /\bi'?d be (more than )?happy to (help|assist)\b|\bi am happy to (help|assist)\b/i, msg: 'assistant voice ("I\'d be happy to help")' },
412
+ { re: /\b(let me know if you('d| would)? (like|want|need)|would you like me to|is there anything else (i|we) can)\b/i, msg: 'offer-of-help close ("let me know if you\'d like")', position: "last" },
413
+ { re: /\b(happy to (help|walk you through|go deeper|dig (in|deeper)|elaborate|expand)|feel free to (ask|reach out|let me know))\b/i, msg: 'offer-of-help close ("Happy to ...", "feel free to ask")', position: "last" },
414
+ { re: /\b(as of|up to|until) my (last|latest) (knowledge|training)( (update|cutoff|cut-off|data))?\b|\bmy knowledge cut-?off\b/i, msg: 'knowledge-cutoff disclaimer (assistant leakage)' },
415
+ { re: /\bi (don'?t|do not) have (access to real-time|real-time|personal (opinions|experiences|feelings))\b/i, msg: 'capability disclaimer (assistant leakage)' },
416
+ { re: /\bhere is (a|the) revised version\b|\bimproved (the )?(clarity|readability|flow)(,? (and )?(clarity|readability|flow|structure|consistency|concision))+\b|\bpreserv(ed|ing) (the )?existing (behaviou?r|structure|formatting|content|wording)\b/i, msg: 'revision-request leakage ("Here is a revised version", "improved clarity and flow")' },
417
+ ],
418
+ },
419
+ {
420
+ since: "0.10.0",
421
+ source: "Pangram phrase ratios (21,000x-49,000x); Wikipedia AILEGACY / FACESCHALLENGES; slop-score",
422
+ screened: "2026-11-25",
423
+ evidence: "M2",
424
+ rules: [
425
+ { re: /\bas a (poignant|powerful|stark|sobering) reminder\b|\breminder of the (enduring|potential)\b/i, msg: 'puffery ("a poignant reminder")' },
426
+ { re: /\bfaced numerous challenges\b|\bdespite these challenges\b|\bfaces (several|numerous|significant) challenges\b/i, msg: '"despite these challenges" formula' },
427
+ { re: /\bthe (complex|intricate|delicate) interplay\b/i, msg: '"the complex interplay"' },
428
+ { re: /\b(newfound|renewed) sense of (purpose|hope|belonging)\b/i, msg: '"a newfound sense of purpose"' },
429
+ { re: /\bbec(ome|ame|omes|oming) a focal point\b/i, msg: '"become a focal point"' },
430
+ { re: /\bexperts (argue|say|agree|note)\b|\bobservers (note|say)\b|\ba growing body of (research|literature|evidence)\b/i, msg: 'vague attribution ("experts argue"): name the source' },
431
+ ],
432
+ },
433
+ {
434
+ // Contributed in PR #9 (malcollmhollmes, issue #8): Wikipedia "Words to watch",
435
+ // re-checked against the live page 2026-11-08. Screened here against
436
+ // corpus/baseline and the pre-2023 register corpora (2.3M words): 0 hits, after
437
+ // dropping "not widely available" (ordinary English: "not widely available in
438
+ // translation"). Chat and search-answer leakage, so long-form samples rarely show it.
439
+ since: "0.10.0",
440
+ source: "Wikipedia: Signs of AI writing (Words to watch); contributed in PR #9",
441
+ screened: "2026-11-25",
442
+ evidence: "P",
443
+ rules: [
444
+ { re: /\bi can(no|')?t (offer|provide|give) (medical|legal|financial|professional) advice\b/i, msg: 'advice disclaimer (assistant leakage)' },
445
+ { re: /\bin the (provided|available) (sources|search results|documents|context)\b/i, msg: '"in the provided sources" (retrieval leakage)' },
446
+ { re: /\bbased on (the )?available information\b/i, msg: '"based on available information" hedge' },
447
+ { re: /\bwhile (specific )?details (are|remain) (limited|scarce)\b/i, msg: '"while specific details are limited" hedge' },
448
+ { re: /\bnot widely (documented|disclosed|reported)\b/i, msg: '"not widely documented" hedge' },
449
+ { re: /\b(represents|marks|reflects|signals) a (broader |wider |fundamental )?shift\b/i, msg: '"marks a broader shift" significance inflation' },
450
+ ],
451
+ },
452
+ {
453
+ // Also from PR #9. Held out of always-on and academic: careful papers size claims
454
+ // this way (serious-writing commandment 12). In wiki prose it is the notability hedge.
455
+ since: "0.10.0",
456
+ source: "Wikipedia: Signs of AI writing (Words to watch, AIDISCLAIMER); contributed in PR #9",
457
+ screened: "2026-11-25",
458
+ evidence: "P",
459
+ profile: "wiki",
460
+ rules: [
461
+ { re: /\bdoes not (by itself|in itself) establish\b/i, msg: '"does not by itself establish" hedge' },
462
+ ],
463
+ },
464
+ {
465
+ // The 2025-2026 staging register: salience flags, gotcha signposts, verdict
466
+ // intensifiers, mannered metaphors. Practitioner consensus with 2-10+ independent
467
+ // sightings each; Bennett (Arize, 2026) gives per-1k rates for several in Opus 5.
468
+ since: "0.10.0",
469
+ source: "Bennett/Arize Opus 5 vs 5.5 study; Anthropic Fable 5.1 prompting guide (platform.claude.com); Wikipedia GPT-6 list; tropes.fyi; deslop; humanizer; practitioner lists",
470
+ screened: "2026-11-25",
471
+ evidence: "P",
472
+ era: "2025-2026",
473
+ rules: [
474
+ { re: /\blet (that|this|it) sink in\b/i, msg: 'staging: "let that sink in"' },
475
+ { re: /\bread (that|this|it) again\b|\bfor (the people|those) in the back\b|\bsay it louder\b/i, msg: 'staging: "read that again"' },
476
+ { re: /\bhere'?s (the kicker|the twist|the catch|the deal|the best part|the part|where it gets|what (nobody|no one))\b/i, msg: 'staging: "here\'s the kicker"' },
477
+ { re: /(^|[.!?]\s+)[Tt]he (result|catch|kicker|twist|best part|reason|answer|problem|truth|secret)\?\s+[A-Z]/, msg: 'staging: self-answered fragment question ("The result? ...")' },
478
+ { re: /(^|[.!?]\s+)honestly\?/i, msg: 'staging: "Honestly?" fragment' },
479
+ { re: /\bearn(s|ed|ing)? (its|their|his|her) (keep|place|spot|seat)\b/i, msg: 'mannered prose: "earns its keep"' },
480
+ { re: /\b(is |are )?doing a lot of (the )?(work|heavy lifting)\b|\bdoes (the |a lot of the )?heavy lifting\b|\bdoes real work\b/i, msg: 'mannered prose: "doing a lot of work"' },
481
+ { re: /(^|[.!?]\s+)(this|that|it) (really |still |genuinely )?matters\.(\s|$)/i, msg: 'salience flag: "This matters."' },
482
+ { re: /\b(that'?s|that is|which is) (exactly |precisely )?the (whole )?point\b|\b(that|this)( i|')s not an accident\b|\bthis is not an accident\b/i, msg: 'verdict intensifier ("that\'s the whole point")' },
483
+ { re: /(^|[.!?]\s+)full stop\.(\s|$)/i, msg: 'verdict intensifier: "Full stop."' },
484
+ { re: /\blet'?s (break (this|it) down|be real|be honest|get real)\b/i, msg: '"let\'s break this down / be real"' },
485
+ { re: /\bthe real (unlock|story|issue|win|work|problem|risk|cost|lesson)\b|\bthe tension is real\b/i, msg: '"the real unlock/story" pivot' },
486
+ { re: /\bthe (hard|tricky|surprising|interesting) part is\b|\bthe part (nobody|no one)\b/i, msg: 'signpost: "the hard part is"' },
487
+ { re: /\bi'?m not saying [^.?!]{1,60}, but\b|\ba tempting (approach|answer|move) would be\b/i, msg: 'arguing with no one ("I\'m not saying X, but")' },
488
+ { re: /\ba (dial|knob|lever) worth (turning|pulling)\b/i, msg: 'stock metaphor: "a dial worth turning"' },
489
+ ],
490
+ },
491
+ {
492
+ since: "0.10.0",
493
+ source: "Antislop 2025 ('It's not X, it's Y' ~6.3x human in some models' creative writing); tropes.fyi; remove-ai-slop; Wikipedia; PENDING.md specimen",
494
+ screened: "2026-11-25",
495
+ evidence: "P",
496
+ rules: [
497
+ { re: /\bnot because\b[^.?!]{1,60}[.,]\s+(but )?because\b/i, msg: '"Not because X. Because Y." contrast', family: "contrast" },
498
+ { re: /(^|[.!?]\s+)(Not|No) [^.?!,]{1,30}\.\s+(Not|No) [^.?!,]{1,30}\.\s+(Just |Only )?[A-Z]/, msg: 'countdown "Not X. Not Y. Z."', family: "contrast" },
499
+ { re: /\bno [^.?!,]{1,25}, no [^.?!,]{1,25}, (just|only)\b/i, msg: 'countdown "no X, no Y, just Z"', family: "contrast" },
500
+ { re: /\bthe (question|problem|issue|answer) (isn'?t|is not) [^.?!]{1,60}[.?!]\s+the \1 is\b/i, msg: 'noun-echo contrast ("The question isn\'t X. The question is Y.")', family: "contrast" },
501
+ { re: /\bis no longer (a|an|the|about|just) [^.?!]{1,60}[.?!]\s+it(?:'s| is)\b/i, msg: '"is no longer X. It is Y." contrast', family: "contrast" },
502
+ { re: /\byou'?re not [^.?!]{1,60}[.?!,]\s+you'?re\b/i, msg: '"You\'re not X. You\'re Y." contrast', family: "contrast" },
503
+ { re: /,\s+(ensuring|highlighting|reflecting|underscoring|emphasizing|showcasing|fostering|paving)\b[^.?!]{3,}[.!]/i, msg: 'participial tail (", ensuring ...")' },
504
+ ],
505
+ },
506
+ // -- opt-in register groups --------------------------------------------------
507
+ {
508
+ since: "0.10.0",
509
+ profile: "pr",
510
+ source: "ACM agentic-PR study (boilerplate in 18.8% of high-inconsistency PRs); HN; practitioner reports",
511
+ evidence: "P",
512
+ rules: [
513
+ { re: /\b(comprehensive|extensive|thorough) (unit |integration )?tests?( coverage| suite)?\b[^.?!]{0,60}\bto ensure\b/i, msg: 'boilerplate test claim ("comprehensive tests ... to ensure")' },
514
+ { re: /\bto ensure (correct|proper|expected) (functionality|behaviou?r)\b/i, msg: 'boilerplate: "to ensure correct functionality"' },
515
+ ],
516
+ },
517
+ {
518
+ since: "0.10.0",
519
+ profile: "email",
520
+ source: "Presend; TextSight; Iro (detector-vendor guides, 1-5 sightings each; 'don't hesitate to reach out' has 1)",
521
+ evidence: "P",
522
+ rules: [
523
+ { re: /\bi hope (this|my) (email|message|note) finds you well\b/i, msg: 'email opener: "I hope this email finds you well"' },
524
+ { re: /\bi wanted to reach out\b|\bi am writing to (provide|inform|follow up)\b/i, msg: 'email opener: "I wanted to reach out"' },
525
+ { re: /\bdon'?t hesitate to (reach out|contact)\b/i, msg: 'email closer: "don\'t hesitate to reach out"' },
526
+ { re: /\bi came across your profile\b/i, msg: 'cold-email opener: "I came across your profile"' },
527
+ { re: /\bquick \d+[- ]minute (call|chat)\b/i, msg: 'cold-email ask: "quick 15-minute call"' },
528
+ { re: /\bi look forward to hearing from you\b/i, msg: 'email closer: "I look forward to hearing from you"' },
529
+ ],
530
+ },
531
+ {
532
+ since: "0.10.0",
533
+ profile: "social",
534
+ source: "newsreel; Taplio; plain-language-editor (LinkedIn slop lists)",
535
+ evidence: "P",
536
+ rules: [
537
+ { re: /\bi'?m (thrilled|humbled|excited|honored) to (announce|share)\b/i, msg: 'announcement formula ("I\'m thrilled to announce")' },
538
+ { re: /\bunpopular opinion:|\bhot take:/i, msg: '"Unpopular opinion:" / "Hot take:"' },
539
+ { re: /(^|[.!?]\s+)(agree|thoughts|what do you think)\?\s*$/i, msg: 'engagement-bait closer ("Agree?")', position: "last" },
540
+ { re: /\brepost if\b|\bfollow (me )?for more\b/i, msg: 'engagement bait ("repost if", "follow for more")' },
541
+ ],
542
+ },
543
+ {
544
+ since: "0.10.0",
545
+ profile: "fiction",
546
+ source: "Antislop / slop-score phrase lists",
547
+ evidence: "M1",
548
+ rules: [
549
+ { re: /\bvoice (barely|little more than) (above )?a whisper\b/i, msg: 'fiction slop: "voice barely above a whisper"' },
550
+ { re: /\bheart (hammered|pounded) (against )?(his|her|their|my) ribs\b/i, msg: 'fiction slop: "heart hammered against her ribs"' },
551
+ ],
552
+ },
553
+ {
554
+ since: "0.10.0",
555
+ profile: "wiki",
556
+ source: "Wikipedia: Signs of AI writing (AILEGACY, ITSHAPESDISCUSSIONS, AIATTR, AIIDENTIFY), 2026 examples",
557
+ evidence: "P",
558
+ rules: [
559
+ { re: /\b(marks?|represents?) a (pivotal|significant|major) (shift|turning point|moment|milestone)\b/i, msg: 'significance inflation ("marks a pivotal shift")' },
560
+ { re: /\breflects the (broader|growing|wider)\b|\bforms part of the (wider|broader)\b|\benduring legacy\b/i, msg: 'legacy puffery ("reflects the broader ...")' },
561
+ { re: /\bhas (shaped|sparked|fueled|informed) (broader )?(discussions|debates|conversations) (about|on|around)\b/i, msg: '"has shaped discussions about"' },
562
+ { re: /\bmaintains an active (online|digital|social media) presence\b|\bholds the distinction of\b/i, msg: 'notability padding ("maintains an active online presence")' },
563
+ { re: /\bhas been (featured|profiled|documented) (in|by)\b|\bindependent coverage\b/i, msg: 'notability padding ("has been featured in")' },
564
+ { re: /\b(his|her|their) (personal |official )?website (identifies|describes) (him|her|them) as\b/i, msg: '"his website identifies him as"' },
565
+ ],
566
+ },
567
+ {
568
+ since: "0.10.0",
569
+ profile: "academic",
570
+ source: "CARS introduction study (arXiv 2610.01353: centrality openers 58-84% models vs 46% humans); Pangram; serious-writing S7/S16",
571
+ evidence: "M2",
572
+ rules: [
573
+ { re: /\bin recent (years|decades),? [^.?!]{1,60}\b(has|have) (garnered|attracted|received|gained|drawn) (significant|increasing|growing|considerable|much) (attention|interest)\b/i, msg: 'centrality-claim opener ("In recent years, X has attracted increasing attention")' },
574
+ { re: /\b(provides?|offers?|yields?) (new|novel|valuable|deeper) insights? into\b/i, msg: '"provides new insights into"' },
575
+ { re: /\bto (address|fill|bridge) (this|the|these) gaps?\b/i, msg: 'gap formula ("To address this gap")' },
576
+ // general prose fails the screen here (MedlinePlus: "some research has shown"), so academic only
577
+ { re: /\b(studies|research) (have|has) (shown|demonstrated|found)\b/i, msg: 'vague attribution ("studies have shown"): name the study' },
578
+ { re: /\[\d+\s*[-\u2013]\s*\d+\]/, msg: 'citation clump ("[3-9]"): name the two or three studies that matter' },
579
+ ],
580
+ },
581
+ {
582
+ since: "0.10.0",
583
+ profile: "review",
584
+ source: "practitioner reports of AI-written reviews (bold tag headers)",
585
+ evidence: "A",
586
+ rules: [
587
+ { re: /^\s*(\*\*|__)[A-Z][\w-]*( [\w-]+){0,2}:?(\*\*|__):?\s/, msg: 'bold tag header ("**Strengths:**")', lineOnly: true },
588
+ ],
589
+ },
590
+ {
591
+ // Only run on comment text in code files (--code / --profile code).
592
+ since: "0.10.0",
593
+ profile: "code",
594
+ codeOnly: true,
595
+ source: "JCarterJohnson Reddit mining (11,906 posts, 11,306 comments); AI-SIGNALS; SynthScan; agent-failure-modes",
596
+ evidence: "P",
597
+ rules: [
598
+ { re: /\b(here'?s the (updated|revised|modified|corrected|fixed)|as (you )?requested|i'?ve (added|updated|modified|changed|fixed|refactored|implemented))\b/i, msg: "code comment: chat leakage (\"Here's the updated ...\", \"I've added\")" },
599
+ { re: /^\s*(step \d+[:.)]|now we\b|first,? we\b|next,? we\b|finally,? we\b)/i, msg: 'code comment: step narration ("Step 1:", "Now we")', lineOnly: true },
600
+ { re: /\bthis (function|method|class|component|module|code|file|helper) (was|has been|is now) (added|changed|updated|modified|refactored|introduced|moved|renamed)\b|\b(was|were) (added|changed|updated|modified|refactored) (to|in order to) (replace|fix|support|handle|address)\b|^\s*(added|updated|changed|fixed|removed|new):\s/i, msg: "code comment: history narration (describe the code, not its change; that belongs in the commit)", unless: /versionchanged|versionadded|deprecat|backwards?[- ]compat|for compatibility/i },
601
+ { re: /\b(rest of (your|the) (code|implementation|logic)|(your|existing) (code|logic|implementation) goes here|implementation goes here|add your [\w ]{1,30} here)\b/i, msg: 'code comment: placeholder ("rest of your code here")' },
602
+ { re: /^\s*this (function|method|class|component|module|helper) (handles|is responsible for|serves to|ensures|provides a (way|mechanism))\b/i, msg: 'code comment: "This function handles ..." (name what it does)', lineOnly: true },
603
+ ],
604
+ },
98
605
  ];
99
606
 
100
- // Flat list for matching (derived from the sourced groups above).
101
- export const WORDS = WORD_GROUPS.flatMap((g) => g.words);
102
-
103
- // Phrases / constructions. Sources: corpus studies above plus the Wikipedia
104
- // "Signs of AI writing" essay and practitioner blacklists. Added in 0.1.0 unless noted.
105
- export const PHRASES = [
106
- // intro / scene-setting cliches
107
- { re: /\bin today'?s (fast[- ]paced )?(world|digital age|digital landscape)\b/i, msg: '"in today\'s ... world" intro' },
108
- { re: /\bin the (ever[- ]evolving|dynamic) (landscape|world) of\b/i, msg: '"ever-evolving landscape" intro' },
109
- { re: /\bas the world continues to evolve\b/i, msg: '"as the world continues to evolve"' },
110
- { re: /\bimagine a world where\b/i, msg: '"imagine a world where"' },
111
- { re: /\bat its core\b/i, msg: '"at its core"' },
112
- // expository cliches
113
- { re: /\bplays? an? (crucial|important|key|vital|pivotal|significant) role\b/i, msg: '"plays a crucial role"' },
114
- { re: /\bis a testament to\b/i, msg: '"is a testament to"' },
115
- { re: /\bserves? as a (powerful|valuable|vital) tool\b/i, msg: '"serves as a powerful tool"' },
116
- { re: /\bcannot be overstated\b/i, msg: '"cannot be overstated"' },
117
- { re: /\bhas become increasingly (important|popular|common)\b/i, msg: '"has become increasingly ..."' },
118
- // reader framing
119
- { re: /\bwhen it comes to\b/i, msg: '"when it comes to"' },
120
- { re: /\bwhether you'?re (a |an )?.+ or (a |an )?.+/i, msg: '"whether you\'re X or Y" framing' },
121
- { re: /\bno matter where you are (on|in) your journey\b/i, msg: '"no matter where you are on your journey"' },
122
- { re: /\bif you'?re looking to\b/i, msg: '"if you\'re looking to"' },
123
- // vague filler
124
- { re: /\bat the end of the day\b/i, msg: '"at the end of the day"' },
125
- { re: /\bfor all intents and purposes\b/i, msg: '"for all intents and purposes"' },
126
- { re: /\bwith that in mind\b/i, msg: '"with that in mind"' },
127
- { re: /\bthe fact of the matter is\b/i, msg: '"the fact of the matter is"' },
128
- { re: /\bin a nutshell\b/i, msg: '"in a nutshell"' },
129
- { re: /\bneedless to say\b/i, msg: '"needless to say"' },
130
- { re: /\bthat being said\b/i, msg: '"that being said"' },
131
- { re: /\bdeep dive\b/i, msg: '"deep dive"' },
132
- // hedging / throat-clearing
133
- { re: /\bit'?s (important|worth|essential) (to note|noting|to consider|considering|to recognize) that\b/i, msg: "hedge: \"it's worth noting that ...\"" },
134
- { re: /\bwhile it is true that\b/i, msg: '"while it is true that"' },
135
- { re: /\bit could be argued that\b/i, msg: '"it could be argued that"' },
136
- { re: /\bgenerally speaking\b/i, msg: '"generally speaking"' },
137
- // meta-structure
138
- { re: /\bthis (article|post|paper|piece) will (explore|examine|cover|delve into|look at)\b/i, msg: '"this article will explore"' },
139
- { re: /\blet'?s (take a closer look|dive in|explore|unpack)\b/i, msg: '"let\'s dive in / take a closer look"' },
140
- { re: /\bhere'?s (the thing|why)\b/i, msg: '"here\'s the thing/why"' },
141
- // closing tics
142
- { re: /\b(in conclusion|in summary|to sum up|to wrap up|to conclude)\b/i, msg: "conclusion ritual" },
143
- { re: /\bthe possibilities are endless\b/i, msg: '"the possibilities are endless"' },
144
- { re: /\bthe future (is|looks) (bright|promising)\b/i, msg: '"the future is bright"' },
145
- { re: /\bonly time will tell\b/i, msg: '"only time will tell"' },
146
- { re: /\bthe journey (is just beginning|doesn'?t end here)\b/i, msg: '"the journey is just beginning"' },
147
- // syntactic constructions
148
- { re: /\bnot (just|only)\b[^.?!]{0,60}\b(but|it'?s|they'?re|its)\b/i, msg: '"not just X, but Y"' },
149
- { re: /\b(it'?s|we'?re|they'?re)\s+(not|never)(\s+just)?\b[^.?!]{1,80}?\b(it'?s|we'?re|they'?re)\b/i, msg: '"it\'s not X, it\'s Y" negated contrast' },
150
- // added 0.3.0 — Wikipedia: Signs of AI writing (assistant leakage + high-signal cliches)
151
- { re: /\bas an? (ai|large) language model\b/i, msg: '"as an AI/large language model" (assistant leakage)' },
152
- { re: /\bi hope this helps\b/i, msg: '"I hope this helps" (assistant sign-off)' },
153
- { re: /\bin the heart of\b/i, msg: '"in the heart of"' },
154
- { re: /\ba diverse array of\b/i, msg: '"a diverse array of"' },
155
- { re: /\bvaluable insights\b/i, msg: '"valuable insights"' },
156
- { re: /\b(stands|serves) as a testament\b/i, msg: '"stands/serves as a testament"' },
157
- { re: /\bsetting the stage for\b/i, msg: '"setting the stage for"' },
158
- { re: /\bindelible mark\b/i, msg: '"indelible mark"' },
159
- { re: /\bdeeply rooted in\b/i, msg: '"deeply rooted in"' },
160
- { re: /\brich (cultural )?(tapestry|heritage)\b/i, msg: '"rich cultural heritage/tapestry"' },
607
+ // Flat list of every phrase rule, each tagged with its group's profile (if any).
608
+ export const PHRASES = PHRASE_GROUPS.flatMap((g) => g.rules.map((r) => ({ ...r, profile: g.profile, codeOnly: g.codeOnly, since: g.since })));
609
+
610
+ // Machine artifacts: residue that people never type (chatbot citation markup, chatbot
611
+ // referral parameters, UI text pasted along with an answer). FAIL, never suppressible.
612
+ // One documented sighting plus zero baseline hits is the bar here, not two: these are
613
+ // tokens, not style. A utm_source hit proves a chatbot found the link, not that it
614
+ // wrote the prose.
615
+ export const ARTIFACTS = [
616
+ // search/image/news/file are documented (Wikipedia Markup subpage); view, forecast,
617
+ // finance and sports are inferred variants. The image form runs together ("i" then
618
+ // repeated turnNimageN), so no word boundaries between markers.
619
+ { re: /contentReference\[oaicite:\d+\]|\boai_citation\b|(?<![A-Za-z])(cite|i)?(turn\d+(search|image|news|file|view|forecast|finance|sports)\d+)+(?![A-Za-z])|"attributableIndex"/, msg: "ChatGPT citation residue (oaicite / turn0search0)" },
620
+ { re: /[\uE200-\uE202\uEA01\uEA02]/, msg: "ChatGPT citation delimiter (Private Use Area U+E200-E202, U+EA01-EA02)" },
621
+ { re: /[?&](utm_source=(chatgpt\.com|openai|copilot\.com|perplexity|claude\.ai|gemini)|referrer=grok\.com)\b/, msg: "chatbot referral parameter in a link (utm_source=chatgpt.com)" },
622
+ { re: /\[cite:\s*\d+(,\s*\d+)*\]|\[span_\d+\]\((start|end)_span\)/, msg: "Gemini citation residue ([cite: N] / start_span)" },
623
+ { re: /\bgrok[-_](card|render_citation_card_json)\b/, msg: "Grok citation-card residue" },
624
+ { re: /\bppl-ai-file-upload\b/, msg: "Perplexity upload residue" },
625
+ { re: /\u3010[^\u3011]{0,40}\u2020[^\u3011]{0,40}\u3011/, msg: "chatbot source marker (\u3010N\u2020source\u3011)" },
626
+ { re: /\bregenerate response\b/i, msg: '"Regenerate response" (chat UI text pasted along with an answer)' },
161
627
  ];
162
628
 
163
629
  export const EMOJI = /[\u{1F300}-\u{1FAFF}\u{2600}-\u{27BF}\u{2190}-\u{21FF}\u{2B00}-\u{2BFF}]/u;
164
630
  const DOUBLEDASH = /(^|\s)--(\s|$)|\w--\w/; // em-dash approximation
165
- const SMARTQUOTE = /[“”‘’]/; // curly quotes/apostrophes: a generator/word-processor tell in plaintext or markdown
631
+ const SMARTQUOTE = /[\u201C\u201D\u2018\u2019]/; // curly quotes/apostrophes: a generator/word-processor tell in plaintext or markdown
632
+ const NNBSP = /\u202F/; // narrow no-break space: documented in o3/o4-mini output (Apr 2025)
166
633
  const reWord = (w) => new RegExp(`\\b${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`, "i");
167
634
 
168
635
  const DEFAULT_EXTS = [".md", ".markdown", ".mdx", ".txt"];
169
636
  const IGNORE_DIRS = new Set(["node_modules", ".git", "dist", "build", ".next", "out", "vendor", "coverage"]);
637
+ const DEFAULT_CONFIG = ".slop-lint.json";
638
+
639
+ // Code files for --code: extension -> comment syntax.
640
+ const C_STYLE = { line: ["//"], block: [["/*", "*/"]] };
641
+ const HASH = { line: ["#"], block: [] };
642
+ const PY = { line: ["#"], block: [['"""', '"""'], ["'''", "'''"]] };
643
+ const DASH = { line: ["--"], block: [] };
644
+ export const CODE_EXTS = {
645
+ ".js": C_STYLE, ".mjs": C_STYLE, ".cjs": C_STYLE, ".ts": C_STYLE, ".tsx": C_STYLE, ".jsx": C_STYLE,
646
+ ".java": C_STYLE, ".kt": C_STYLE, ".swift": C_STYLE, ".go": C_STYLE, ".rs": C_STYLE, ".c": C_STYLE,
647
+ ".h": C_STYLE, ".cc": C_STYLE, ".cpp": C_STYLE, ".hpp": C_STYLE, ".cs": C_STYLE, ".scala": C_STYLE,
648
+ ".php": C_STYLE, ".dart": C_STYLE, ".bicep": C_STYLE,
649
+ ".py": PY, ".rb": HASH, ".sh": HASH, ".bash": HASH, ".zsh": HASH, ".yaml": HASH, ".yml": HASH,
650
+ ".toml": HASH, ".r": HASH, ".ps1": HASH, ".sql": DASH, ".lua": DASH,
651
+ };
170
652
 
171
- // Lint one document. Returns { em, hits } where em is the em-dash count (the only
172
- // failure) and hits are preformatted " <line>: <symbol> ..." report lines.
173
- export function lintText(text) {
174
- let em = 0;
653
+ // Read a config file: { "allow": ["word or phrase", ...], "profiles": ["pr", ...],
654
+ // "ignore": ["path substring", ...] }. "ignore" works like --ignore: directory walks skip
655
+ // any path containing an entry (files named explicitly are still linted).
656
+ // Throws (with the path in the message) on unreadable, unparsable, or malformed content;
657
+ // a broken config should stop the run, not silently lint without it.
658
+ export function readConfig(path) {
659
+ let raw;
660
+ try { raw = readFileSync(path, "utf8"); } catch (e) { throw new Error(`config ${path}: ${e.message}`); }
661
+ let cfg;
662
+ try { cfg = JSON.parse(raw); } catch (e) { throw new Error(`config ${path}: invalid JSON (${e.message})`); }
663
+ const allow = cfg.allow ?? [];
664
+ if (!Array.isArray(allow) || allow.some((a) => typeof a !== "string" || !a.trim())) {
665
+ throw new Error(`config ${path}: "allow" must be an array of non-empty strings`);
666
+ }
667
+ const out = { allow };
668
+ if (cfg.profiles !== undefined) {
669
+ const profiles = cfg.profiles;
670
+ if (!Array.isArray(profiles) || profiles.some((p) => !Object.hasOwn(PROFILES, p))) {
671
+ throw new Error(`config ${path}: "profiles" must be an array of: ${Object.keys(PROFILES).join(", ")}`);
672
+ }
673
+ out.profiles = profiles;
674
+ }
675
+ if (cfg.ignore !== undefined) {
676
+ if (!Array.isArray(cfg.ignore) || cfg.ignore.some((a) => typeof a !== "string" || !a.trim())) {
677
+ throw new Error(`config ${path}: "ignore" must be an array of non-empty strings`);
678
+ }
679
+ out.ignore = cfg.ignore;
680
+ }
681
+ return out;
682
+ }
683
+
684
+ // -- Document model -------------------------------------------------------------
685
+ // Classify each line so rules can scope to prose, headings, list items, or code.
686
+ function classify(lines) {
687
+ const kinds = [];
688
+ let fence = null, front = lines[0]?.replace(/^\uFEFF/, "") === "---";
689
+ for (let i = 0; i < lines.length; i++) {
690
+ const l = lines[i];
691
+ if (front) { kinds.push("front"); if (i > 0 && l === "---") front = false; continue; }
692
+ const f = l.match(/^\s*(```|~~~)/);
693
+ if (fence) { kinds.push("code"); if (f && f[1] === fence) fence = null; continue; }
694
+ if (f) { fence = f[1]; kinds.push("code"); continue; }
695
+ if (!l.trim()) kinds.push("blank");
696
+ else if (/^\s{0,3}#{1,6}\s/.test(l)) kinds.push("heading");
697
+ else if (/^\s*([-*+]|\d+[.)])\s+/.test(l)) kinds.push("list");
698
+ else if (/^\s*\|/.test(l)) kinds.push("table");
699
+ else if (/^\s*>/.test(l)) kinds.push("quote");
700
+ else if (/^ {4,}\S/.test(l) && (i === 0 || kinds[i - 1] === "blank" || kinds[i - 1] === "indent")) kinds.push("indent");
701
+ else if (/^\s*<\/?[a-z][^>]*>\s*$/i.test(l)) kinds.push("html");
702
+ else kinds.push("prose");
703
+ }
704
+ return kinds;
705
+ }
706
+
707
+ // Blank out inline code spans so tells quoted in backticks are not flagged.
708
+ const maskInline = (l) => l.replace(/`[^`]*`/g, (m) => " ".repeat(m.length));
709
+
710
+ // Paragraphs: runs of consecutive prose lines (or a list item and its continuation).
711
+ function paragraphs(lines, kinds) {
712
+ const out = [];
713
+ let cur = null;
714
+ for (let i = 0; i < lines.length; i++) {
715
+ const k = kinds[i];
716
+ const cont = cur && k === "prose" && (cur.kind === "prose" || /^\s+\S/.test(lines[i]));
717
+ if (cont) { cur.lines.push(i); continue; }
718
+ if (cur) out.push(cur);
719
+ cur = k === "prose" || k === "list" || k === "quote" ? { kind: k, lines: [i] } : null;
720
+ }
721
+ if (cur) out.push(cur);
722
+ return out;
723
+ }
724
+
725
+ const ABBR = /\b(e\.g|i\.e|etc|vs|cf|Mr|Mrs|Ms|Dr|Prof|Inc|Ltd|Jr|Sr|St|No|Fig|Figs|Eq|al|approx|U\.S|U\.K)\.$/i;
726
+ export function splitSentences(text) {
727
+ const parts = text.split(/(?<=[.!?]["')\]]?)\s+(?=["'(\[]?[A-Z0-9])/);
728
+ const out = [];
729
+ for (const p of parts) {
730
+ if (out.length && ABBR.test(out[out.length - 1])) out[out.length - 1] += " " + p;
731
+ else out.push(p);
732
+ }
733
+ return out.map((s) => s.trim()).filter(Boolean);
734
+ }
735
+
736
+ // Strip inline markdown for prose statistics.
737
+ const plain = (s) => s
738
+ .replace(/`[^`]*`/g, "x")
739
+ .replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1")
740
+ .replace(/https?:\/\/\S+/g, "x")
741
+ .replace(/(\*\*|__|\*|_)(?=\S)([^*_]+?)\1/g, "$2")
742
+ .replace(/<[^>]+>/g, " ");
743
+
744
+ // -- Document-level rates (advisories) ------------------------------------------
745
+ // Thresholds were set on the repo's own corpora (corpus/baseline vs corpus/samples,
746
+ // 2026-11-25) so that a rate trips on few human documents. They are prompts to look,
747
+ // not verdicts: syntax-only features reach AUROC 0.64-0.68 against a human slop label
748
+ // (Shaib et al. 2025). Sources: Reinhart et al. PNAS 2025 (participial clauses 5.3x,
749
+ // nominalizations 2.1x in GPT-4o); Bakhshi 2026 (tricolons 1.9x per document, ~1.7x per
750
+ // sentence after a length adjustment, performed hedges 2x); Lanzo & Angelo 2026 (flatter sentence-length rhythm in 8 of 9
751
+ // models); Pangram (bold 65 vs 2 per 10k words); Antislop (negative parallelism).
752
+ // Reinhart per 1k words, recomputed from hap-e-biber.csv.gz: participial human 1.73 vs GPT-4o 9.09, nominalizations 14.6 vs 31.3.
753
+ export const RATE_THRESHOLDS = {
754
+ // Calibration (2026-11-25, docs of 15+ sentences): human = 53 corpus/baseline docs,
755
+ // models = 96 corpus/samples answers (Claude, Gemini, GPT, Grok). Each threshold sits
756
+ // at or beyond the human extreme, so a trip means "outside what the human baseline did".
757
+ minSentences: 15,
758
+ sentenceCV: 0.45, // below: human p10 0.47, model medians 0.40-0.47
759
+ participial: 10, // per 100 sentences, above: human max 8.1, model medians 7-19
760
+ nominalization: 0.06, // share of words, above: human p90 0.037 (max 0.071); register-relative
761
+ tricolon: 0.27, // per sentence, above: human max 0.27, model medians 0.20-0.32
762
+ hedge: 0.03, // performed hedges per sentence, above: human max 0.015
763
+ contrast: 2.6, // negative-contrast hits per 1k words, above: human max 2.5
764
+ copula: 2, // "serves/stands/acts as a" count, at or above: human max 0
765
+ bold: 4, // bold spans per 1k words (and 4+ spans), above: human max 0
766
+ oneSentencePars: 0.85, // one-sentence paragraph share (8+ paragraphs): human oratory runs to 0.83
767
+ intensifier: 4, // per 1k words, above: human max 3.6, model p90 3.4-7.3
768
+ };
769
+ const NOMINAL = /^[a-z]{3,}(?:tion|tions|ment|ments|ness|nesses|ity|ities|ance|ances|ence|ences|ization|izations|isation|isations)$/;
770
+ const NOT_NOMINAL = new Set(("government governments president moment moments nation nations city cities community " +
771
+ "communities element elements comment comments apartment department departments document documents equipment " +
772
+ "environment environments instrument instruments segment segments parliament station stations question questions " +
773
+ "section sections fiction caution mention ration portion portions lotion motion potion notion ocean audience " +
774
+ "evidence science sciences experience experiences sentence sentences difference differences conference conferences " +
775
+ "university universities quality quantity identity entity entities activity activities facility facilities business " +
776
+ "witness illness sickness darkness fitness wilderness").split(" "));
777
+ const PARTICIPIAL = /,\s+(?!(?:including|during|according|regarding|concerning|following|considering|excluding|involving|notwithstanding|something|nothing|anything|everything|morning|evening|thing|things|king|string|spring|bring|being)\b)[a-z]{3,}ing\b/g;
778
+ const TRICOLON = /\b[\w'-]+(?: [\w'-]+){0,3}, [\w'-]+(?: [\w'-]+){0,3},? (?:and|or) [\w'-]+/g;
779
+ const PERFORMED_HEDGE = /\b(it'?s (important|worth|essential|crucial) to (note|remember|consider|recognize|acknowledge)|worth noting|it should be noted|generally speaking|in many ways|to some extent|to a certain (extent|degree)|it could be argued|arguably|(could|might|may) (potentially|possibly)|it is (possible|likely) that)\b/gi;
780
+ const COPULA = /\b(serves|stands|functions|acts) as (a|an|the)\b/gi;
781
+ const INTENSIFIER = /\b(actually|really|truly|deeply|fundamentally|genuinely|honestly|incredibly|quietly|simply|absolutely|incredibly|remarkably)\b/gi;
782
+ const count = (s, re) => (s.match(re) || []).length;
783
+
784
+ export function docRates(text, { contrastHits = null } = {}) {
785
+ const lines = text.split("\n");
786
+ const kinds = classify(lines);
787
+ const pars = paragraphs(lines, kinds).filter((p) => p.kind === "prose")
788
+ .map((p) => plain(p.lines.map((i) => lines[i].trim()).join(" ")));
789
+ const sents = pars.flatMap(splitSentences).filter((s) => /[a-z]/i.test(s));
790
+ const words = sents.join(" ").match(/[A-Za-z][A-Za-z'-]*/g) || [];
791
+ const nW = words.length || 1, nS = sents.length || 1;
792
+ const lens = sents.map((s) => (s.match(/\S+/g) || []).length);
793
+ const mean = lens.reduce((a, b) => a + b, 0) / nS;
794
+ const sd = Math.sqrt(lens.reduce((a, b) => a + (b - mean) ** 2, 0) / nS);
795
+ const prose = sents.join(" ");
796
+ const rawBody = lines.filter((_, i) => kinds[i] !== "code" && kinds[i] !== "front").join("\n");
797
+ const bold = Math.floor(count(rawBody, /\*\*/g) / 2);
798
+ const oneSent = pars.filter((p) => splitSentences(p).length === 1).length;
799
+ return {
800
+ sentences: sents.length,
801
+ words: words.length,
802
+ paragraphs: pars.length,
803
+ sentenceCV: mean ? sd / mean : 0,
804
+ participial: (100 * count(prose, PARTICIPIAL)) / nS,
805
+ nominalization: words.filter((w) => NOMINAL.test(w.toLowerCase()) && !NOT_NOMINAL.has(w.toLowerCase())).length / nW,
806
+ tricolon: count(prose, TRICOLON) / nS,
807
+ hedge: count(prose, PERFORMED_HEDGE) / nS,
808
+ contrast: contrastHits === null ? null : (1000 * contrastHits) / nW,
809
+ copula: count(prose, COPULA),
810
+ bold,
811
+ boldPer1k: (1000 * bold) / nW,
812
+ oneSentencePars: pars.length ? oneSent / pars.length : 0,
813
+ intensifier: (1000 * count(prose, INTENSIFIER)) / nW,
814
+ };
815
+ }
816
+
817
+ // Turn rates into advisory lines.
818
+ export function rateAdvisories(r, T = RATE_THRESHOLDS) {
819
+ if (r.sentences < T.minSentences) return [];
820
+ const out = [];
821
+ const f = (n, d = 2) => Number(n).toFixed(d);
822
+ if (r.sentenceCV < T.sentenceCV) out.push(`sentence lengths are uniform (variation ${f(r.sentenceCV)}, human docs usually >= ${T.sentenceCV}); vary by content, not as a device`);
823
+ if (r.participial > T.participial) out.push(`participial clauses at ${f(r.participial, 0)} per 100 sentences (> ${T.participial}); cut ", ensuring/highlighting ..." tails`);
824
+ if (r.nominalization > T.nominalization) out.push(`nominalizations are ${f(100 * r.nominalization, 1)}% of words (> ${f(100 * T.nominalization, 1)}%); put actions in verbs, actors in subjects`);
825
+ if (r.tricolon > T.tricolon) out.push(`three-item lists in ${f(100 * r.tricolon, 0)}% of sentences (> ${f(100 * T.tricolon, 0)}%); use the count the facts have`);
826
+ if (r.hedge > T.hedge) out.push(`performed hedges in ${f(100 * r.hedge, 0)}% of sentences (> ${f(100 * T.hedge, 0)}%); hedge only real uncertainty`);
827
+ if (r.contrast !== null && r.contrast > T.contrast) out.push(`negative-contrast constructions at ${f(r.contrast, 1)} per 1k words (> ${T.contrast}); state the positive claim`);
828
+ if (r.copula >= T.copula) out.push(`${r.copula} "serves/stands/acts as a" (>= ${T.copula}); write "is"`);
829
+ if (r.bold >= 4 && r.boldPer1k > T.bold) out.push(`${r.bold} bold spans, ${f(r.boldPer1k, 1)} per 1k words (> ${T.bold}); bold only what a scanner must find`);
830
+ if (r.paragraphs >= 8 && r.oneSentencePars > T.oneSentencePars) out.push(`${f(100 * r.oneSentencePars, 0)}% of paragraphs are one sentence (> ${f(100 * T.oneSentencePars, 0)}%); join related sentences`);
831
+ if (r.intensifier > T.intensifier) out.push(`intensifiers at ${f(r.intensifier, 1)} per 1k words (> ${T.intensifier}); delete them`);
832
+ return out;
833
+ }
834
+
835
+ // -- Code comments --------------------------------------------------------------
836
+ // Return the source with everything but comment text blanked, line count preserved.
837
+ export function extractComments(src, syntax) {
838
+ const lines = src.split("\n");
839
+ const out = [];
840
+ let inBlock = null;
841
+ for (let n = 0; n < lines.length; n++) {
842
+ const l = lines[n];
843
+ if (n === 0 && l.startsWith("#!")) { out.push(""); continue; }
844
+ let text = "", i = 0, quote = null;
845
+ while (i < l.length) {
846
+ if (inBlock) {
847
+ const end = l.indexOf(inBlock, i);
848
+ if (end < 0) { text += " " + l.slice(i); i = l.length; break; }
849
+ text += " " + l.slice(i, end); i = end + inBlock.length; inBlock = null; continue;
850
+ }
851
+ const c = l[i];
852
+ if (quote) { if (c === "\\") i += 2; else { if (c === quote) quote = null; i++; } continue; }
853
+ const blk = syntax.block.find(([s]) => l.startsWith(s, i));
854
+ if (blk) { inBlock = blk[1]; i += blk[0].length; continue; }
855
+ if (syntax.line.some((t) => l.startsWith(t, i))) { text += " " + l.slice(i).replace(/^(\/\/+|#+|--+)!?/, ""); break; }
856
+ if (c === '"' || c === "'" || c === "`") quote = c;
857
+ i++;
858
+ }
859
+ out.push(text.replace(/^\s*\*+\s?/, " ").replace(/\s+$/, ""));
860
+ }
861
+ return out.join("\n");
862
+ }
863
+
864
+ // -- Lint -----------------------------------------------------------------------
865
+ const TITLE_SMALL = new Set("a an the and or but nor of to in on at for with by vs via from as into per than".split(" "));
866
+ function isTitleCase(h) {
867
+ const words = h.replace(/[^\w\s'-]/g, " ").split(/\s+/).filter(Boolean);
868
+ const sig = words.slice(1).filter((w) => !TITLE_SMALL.has(w.toLowerCase()) && /^[a-z]/i.test(w));
869
+ return sig.length >= 2 && sig.every((w) => /^[A-Z]/.test(w)) && !sig.every((w) => /^[A-Z0-9]+$/.test(w));
870
+ }
871
+ const STOCK_HEADING = /^(challenges and (future )?(directions|prospects|outlook)|future (outlook|prospects|directions)|key takeaways|why (it|this) matters)$/i;
872
+ const WIKI_HEADING = /^(awards and recognition|legacy and impact|impact and legacy)$/i;
873
+ const PR_HEADING = /^(summary|changes|what changed|changes made|key changes|testing|test plan|tests|motivation|overview|why|how|context)$/i;
874
+ const BOLD_LEAD = /^\s*([-*+]|\d+[.)])\s+\*\*[^*\n]{1,60}\*\*/;
875
+
876
+ // Lint one document. Returns { em, artifacts, hits, advisories }: em is the em-dash
877
+ // count and artifacts the machine-artifact count (both failures); hits are
878
+ // preformatted " <line>: <symbol> ..." report lines (failures and warnings);
879
+ // advisories are document-level rate notes (never failures).
880
+ // Options: allow (see readConfig), profiles (opt-in groups), rates (default true),
881
+ // code (a CODE_EXTS syntax: lint only comment text).
882
+ // Each `allow` entry is a word or phrase as it would appear in prose; it disables every
883
+ // word/phrase rule its text triggers (case-insensitive), so flagged text can be pasted
884
+ // verbatim. Typography and artifacts are never suppressed.
885
+ export function lintText(text, { allow = [], profiles = [], rates = true, code = null } = {}) {
886
+ const on = new Set(profiles);
887
+ const words = WORD_GROUPS.filter((g) => !g.profile || on.has(g.profile)).flatMap((g) => g.words);
888
+ const phrases = PHRASES.filter((p) => (!p.profile || on.has(p.profile)) && (!p.codeOnly || code));
889
+ const okWords = new Set(), okPhrases = new Set();
890
+ for (const a of allow) {
891
+ for (const w of words) if (reWord(w).test(a)) okWords.add(w);
892
+ for (const p of phrases) if (p.re.test(a)) okPhrases.add(p);
893
+ }
894
+ const src = code ? extractComments(text, code) : text;
895
+ const lines = src.split("\n");
896
+ const kinds = code ? lines.map((l) => (l.trim() ? "prose" : "blank")) : classify(lines);
897
+ let em = 0, artifacts = 0, contrastHits = 0;
175
898
  const hits = [];
176
- text.split("\n").forEach((line, i) => {
899
+ const add = (n, s) => hits.push({ n, s });
900
+ const free = phrases.filter((p) => !p.position);
901
+ const paras = paragraphs(lines, kinds);
902
+ // For `unless` rules: the paragraph text around each line.
903
+ const paraText = new Map();
904
+ for (const par of paras) { const t = par.lines.map((i) => lines[i]).join(" "); for (const i of par.lines) paraText.set(i, t); }
905
+
906
+ lines.forEach((line, i) => {
177
907
  const n = i + 1;
178
- const dash = (line.match(/—/g) || []).length;
179
- if (dash) { em += dash; hits.push(` ${n}: ✗ em-dash ×${dash} ${line.trim().slice(0, 64)}`); }
180
- if (DOUBLEDASH.test(line)) hits.push(` ${n}: ⚠ "--" (em-dash approximation)`);
181
- for (const w of WORDS) if (reWord(w).test(line)) hits.push(` ${n}: ⚠ word "${w}"`);
182
- for (const p of PHRASES) if (p.re.test(line)) hits.push(` ${n}: ⚠ ${p.msg}`);
183
- if (SMARTQUOTE.test(line)) hits.push(` ${n}: ⚠ smart/curly quote`);
184
- if (EMOJI.test(line)) hits.push(` ${n}: ⚠ emoji`);
908
+ const dash = (line.match(/\u2014/g) || []).length;
909
+ if (dash) { em += dash; add(n, `✗ em-dash ×${dash} ${line.trim().slice(0, 64)}`); }
910
+ for (const a of ARTIFACTS) if (a.re.test(line)) { artifacts++; add(n, `✗ artifact: ${a.msg}`); }
911
+ if (SMARTQUOTE.test(line)) add(n, "⚠ smart/curly quote (weak alone: mail clients and word processors autocorrect to curly)");
912
+ if (EMOJI.test(line)) add(n, "⚠ emoji");
913
+ if (NNBSP.test(line)) add(n, "⚠ narrow no-break space (U+202F)");
914
+ if (kinds[i] === "code" || kinds[i] === "front") return;
915
+ const m = maskInline(line);
916
+ if (DOUBLEDASH.test(m)) add(n, '⚠ "--" (em-dash approximation)');
917
+ for (const w of words) if (!okWords.has(w) && reWord(w).test(m)) add(n, `⚠ word "${w}"`);
918
+ for (const p of free) if (!okPhrases.has(p) && p.re.test(m) && !(p.unless && p.unless.test(paraText.get(i) ?? m))) { add(n, `⚠ ${p.msg}`); if (p.family === "contrast") contrastHits++; }
185
919
  });
186
- return { em, hits };
920
+
921
+ // Cross-line matches: a construction split over a soft line break inside a paragraph.
922
+ for (const par of paras) {
923
+ if (par.lines.length < 2) continue;
924
+ const joined = par.lines.map((i) => maskInline(lines[i]).trim()).join(" ");
925
+ const starts = p0 => p0.anchor === "sentence"
926
+ ? splitSentences(joined).map((_, k, all) => all.slice(k).join(" ")) : [joined];
927
+ for (const p of free) {
928
+ if (p.lineOnly || okPhrases.has(p) || !starts(p).some((t) => p.re.test(t)) || (p.unless && p.unless.test(joined))) continue;
929
+ if (par.lines.some((i) => p.re.test(maskInline(lines[i])))) continue;
930
+ add(par.lines[0] + 1, `⚠ ${p.msg} (across lines)`);
931
+ if (p.family === "contrast") contrastHits++;
932
+ }
933
+ }
934
+
935
+ // Position-scoped rules: first sentence / last two sentences of the prose.
936
+ const prosePars = paras.filter((p) => p.kind === "prose" || (code && p.kind));
937
+ const positional = phrases.filter((p) => p.position && !okPhrases.has(p));
938
+ if (prosePars.length && positional.length) {
939
+ const last = prosePars[prosePars.length - 1];
940
+ const lastText = splitSentences(last.lines.map((i) => maskInline(lines[i]).trim()).join(" ")).slice(-2).join(" ");
941
+ const first = prosePars[0];
942
+ const firstText = splitSentences(first.lines.map((i) => maskInline(lines[i]).trim()).join(" "))[0] || "";
943
+ for (const p of positional) {
944
+ if (p.position === "last" && p.re.test(lastText)) add(last.lines[last.lines.length - 1] + 1, `⚠ ${p.msg}`);
945
+ if (p.position === "first" && p.re.test(firstText)) add(first.lines[0] + 1, `⚠ ${p.msg}`);
946
+ }
947
+ }
948
+
949
+ if (!code) {
950
+ // Headings: stock section names per hit; Title Case and colon subtitles by share.
951
+ const heads = lines.map((l, i) => [i, l]).filter(([i]) => kinds[i] === "heading")
952
+ .map(([i, l]) => ({ i, level: l.match(/#+/)[0].length, text: maskInline(l).replace(/^\s*#+\s*/, "").replace(/\s*#*\s*$/, "") }));
953
+ for (const h of heads) {
954
+ const t = h.text.replace(/[:.]$/, "").trim();
955
+ if (STOCK_HEADING.test(t)) add(h.i + 1, `⚠ stock heading "${t}"`);
956
+ if (on.has("wiki") && WIKI_HEADING.test(t)) add(h.i + 1, `⚠ stock heading "${t}" (wiki)`);
957
+ }
958
+ const sub = heads.filter((h) => h.level > 1);
959
+ if (sub.length >= 3) {
960
+ const tc = sub.filter((h) => isTitleCase(h.text));
961
+ if (tc.length / sub.length >= 0.6) add(tc[0].i + 1, `⚠ Title Case headings (${tc.length} of ${sub.length}); use sentence case`);
962
+ const colon = sub.filter((h) => /^[^:]{2,40}:\s+\S/.test(h.text));
963
+ if (colon.length / sub.length >= 0.4) add(colon[0].i + 1, `⚠ colon-subtitle headings (${colon.length} of ${sub.length}, "X: The Y of Z")`);
964
+ }
965
+ if (on.has("pr")) {
966
+ const pr = heads.filter((h) => PR_HEADING.test(h.text.trim()));
967
+ if (pr.length >= 4) add(pr[0].i + 1, `⚠ PR template headings (${pr.map((h) => h.text.trim()).join(" / ")}); write what changed and why`);
968
+ }
969
+ // List runs: 3+ consecutive "- **Label**: text" items.
970
+ let run = [];
971
+ const flush = () => { if (run.length >= 3) add(run[0] + 1, `⚠ bold lead-in bullets (${run.length} in a row)`); run = []; };
972
+ lines.forEach((l, i) => {
973
+ if (kinds[i] === "list" && BOLD_LEAD.test(l)) run.push(i);
974
+ else if (!(kinds[i] === "blank" || (kinds[i] === "prose" && /^\s+\S/.test(l) && run.length))) flush();
975
+ });
976
+ flush();
977
+ }
978
+
979
+ const advisories = rates && !code ? rateAdvisories(docRates(text, { contrastHits })) : [];
980
+ hits.sort((a, b) => a.n - b.n);
981
+ return {
982
+ em, artifacts,
983
+ hits: hits.map((h) => ` ${h.n}: ${h.s}`),
984
+ advisories: advisories.map((a) => ` ℹ ${a}`),
985
+ };
187
986
  }
188
987
 
189
988
  // Expand paths to a file list. Explicit files are always included; directories are
@@ -209,7 +1008,7 @@ export function walkFiles(paths, { exts = DEFAULT_EXTS, ignore = [] } = {}) {
209
1008
  return [...new Set(out)];
210
1009
  }
211
1010
 
212
- // ── Discover: find candidate NEW tells empirically ────────────────────────────
1011
+ // -- Discover: find candidate NEW tells empirically ----------------------------
213
1012
  // Compare word/bigram frequency in model-output samples against a human baseline.
214
1013
  // Tokens that are massively over-represented in the samples, and not already in the
215
1014
  // catalogue, are ranked as candidates for human review. This is how the original
@@ -223,7 +1022,7 @@ const STOP = new Set((
223
1022
  ).split(" "));
224
1023
 
225
1024
  function tokenize(text) {
226
- return (text.toLowerCase().match(/[a-z][a-z'’-]{2,}/g) || []).filter((w) => !STOP.has(w));
1025
+ return (text.toLowerCase().match(/[a-z][a-z'\u2019-]{2,}/g) || []).filter((w) => !STOP.has(w));
227
1026
  }
228
1027
  // Per-text frequency + document frequency (how many texts a token appears in). Doc
229
1028
  // frequency lets us drop one-off artifacts (an invented product name repeated within a
@@ -246,7 +1045,7 @@ function freqMap(texts, { bigrams = true } = {}) {
246
1045
  }
247
1046
  export function discover(sampleTexts, baselineTexts, { top = 30, minCount = 3, minDocs = 3 } = {}) {
248
1047
  const S = freqMap(sampleTexts), B = freqMap(baselineTexts);
249
- const known = new Set(WORDS.map((w) => w.toLowerCase()));
1048
+ const known = new Set(ALL_WORDS.map((w) => w.toLowerCase()));
250
1049
  const smoothing = 1 / (B.total * 10);
251
1050
  const effMinDocs = Math.min(minDocs, sampleTexts.length); // small corpora still return something
252
1051
  const out = [];
@@ -260,7 +1059,7 @@ export function discover(sampleTexts, baselineTexts, { top = 30, minCount = 3, m
260
1059
  return out.slice(0, top);
261
1060
  }
262
1061
 
263
- const stripFrontmatter = (t) => t.replace(/^?---\r?\n[\s\S]*?\r?\n---\r?\n/, "");
1062
+ const stripFrontmatter = (t) => t.replace(/^\uFEFF?---\r?\n[\s\S]*?\r?\n---\r?\n/, "");
264
1063
  function readAll(paths) {
265
1064
  return walkFiles(paths, { exts: [".md", ".markdown", ".mdx", ".txt"] })
266
1065
  .map((f) => { try { return stripFrontmatter(readFileSync(f, "utf8")); } catch { return ""; } });
@@ -290,47 +1089,87 @@ function runDiscover(argv) {
290
1089
  return 0;
291
1090
  }
292
1091
 
1092
+ function printList() {
1093
+ const meta = (g) => [`since ${g.since}`, g.evidence && `evidence ${g.evidence}`, g.profile && `profile ${g.profile}`, g.era && `era: ${g.era}`]
1094
+ .filter(Boolean).join("; ");
1095
+ console.log("# WORDS");
1096
+ for (const g of WORD_GROUPS) console.log(`\n## ${g.source} (${meta(g)})${g.note ? `\n note: ${g.note}` : ""}\n${g.words.join(", ")}`);
1097
+ console.log("\n# PHRASES");
1098
+ for (const g of PHRASE_GROUPS) console.log(`\n## ${g.source} (${meta(g)})\n${g.rules.map((r) => ` - ${r.msg}${r.position ? ` [${r.position} sentences]` : ""}`).join("\n")}`);
1099
+ console.log(`\n# ARTIFACTS (fail)\n${ARTIFACTS.map((a) => ` - ${a.msg}`).join("\n")}`);
1100
+ console.log(`\n# PROFILES (opt-in: --profile <name>)\n${Object.entries(PROFILES).map(([k, v]) => ` ${k.padEnd(9)} ${v}`).join("\n")}`);
1101
+ console.log(`\n${ALL_WORDS.length} words, ${PHRASES.length} phrase rules, ${ARTIFACTS.length} artifact rules. Catalogue version ${VERSION}.`);
1102
+ }
1103
+
293
1104
  function main(argv) {
294
1105
  if (argv.includes("--version") || argv.includes("-v")) { console.log(VERSION); return 0; }
295
1106
  if (argv.includes("--discover")) return runDiscover(argv);
296
- if (argv.includes("--list")) {
297
- for (const g of WORD_GROUPS) console.log(`\n# ${g.source} (since ${g.since})\n${g.words.join(", ")}`);
298
- console.log(`\n# phrases: ${PHRASES.length} patterns. Catalogue version ${VERSION}.`);
299
- return 0;
300
- }
1107
+ if (argv.includes("--list")) { printList(); return 0; }
301
1108
  const paths = [];
302
- let exts = DEFAULT_EXTS, ignore = [], failOnWarn = false, quiet = false;
1109
+ let exts = null, ignore = [], failOnWarn = false, quiet = false, configPath = null, allow = [], profiles = [], rates = true;
303
1110
  for (let i = 0; i < argv.length; i++) {
304
1111
  const a = argv[i];
305
1112
  if (a === "--help" || a === "-h") {
306
- console.log("slop-lint - flag LLM tells in prose. FAIL on em-dash, WARN on the rest.\n" +
1113
+ console.log("slop-lint - flag LLM tells in prose. FAIL on em-dash and machine artifacts, WARN on the rest.\n" +
307
1114
  " node slop-lint.mjs [paths...] [--ext .md,.txt] [--ignore <substr>]... [--fail-on-warn] [--quiet]\n" +
1115
+ " [--allow <word/phrase>]... [--config <file>] [--profile <name>]... [--code] [--no-rates]\n" +
308
1116
  " node slop-lint.mjs --discover --samples <dir> --baseline <dir> [--top N] [--json]\n" +
309
- " --version --list (no paths: scans the current directory recursively)");
1117
+ " --version --list (no paths: scans the current directory recursively)\n" +
1118
+ ` Profiles: ${Object.keys(PROFILES).join(", ")}\n` +
1119
+ ` Config: ${DEFAULT_CONFIG} in the cwd ({"allow": [...], "profiles": [...]}) is read automatically.`);
310
1120
  return 0;
311
1121
  }
312
1122
  if (a === "--ext") { exts = argv[++i].split(",").map((e) => (e.startsWith(".") ? e : `.${e}`).toLowerCase()); continue; }
313
1123
  if (a === "--ignore") { ignore.push(argv[++i]); continue; }
314
1124
  if (a === "--fail-on-warn") { failOnWarn = true; continue; }
315
1125
  if (a === "--quiet") { quiet = true; continue; }
1126
+ if (a === "--allow") { allow.push(argv[++i]); continue; }
1127
+ if (a === "--config") { configPath = argv[++i]; continue; }
1128
+ if (a === "--profile") { profiles.push(...(argv[++i] || "").split(",").filter(Boolean)); continue; }
1129
+ if (a === "--code") { profiles.push("code"); continue; }
1130
+ if (a === "--no-rates") { rates = false; continue; }
316
1131
  paths.push(a);
317
1132
  }
318
- const files = walkFiles(paths.length ? paths : ["."], { exts, ignore });
1133
+ const bad = profiles.filter((p) => !Object.hasOwn(PROFILES, p));
1134
+ if (bad.length) { console.error(`slop-lint: unknown profile ${bad.join(", ")} (known: ${Object.keys(PROFILES).join(", ")})`); return 2; }
1135
+ try {
1136
+ const cfg = configPath ? readConfig(configPath) : existsSync(DEFAULT_CONFIG) ? readConfig(DEFAULT_CONFIG) : { allow: [] };
1137
+ allow.push(...cfg.allow);
1138
+ profiles.push(...(cfg.profiles || []));
1139
+ ignore.push(...(cfg.ignore || []));
1140
+ } catch (e) { console.error(`slop-lint: ${e.message}`); return 2; }
1141
+ const codeMode = profiles.includes("code");
1142
+ const walkExts = exts || (codeMode ? [...DEFAULT_EXTS, ...Object.keys(CODE_EXTS)] : DEFAULT_EXTS);
1143
+ const files = walkFiles(paths.length ? paths : ["."], { exts: walkExts, ignore });
319
1144
  if (!files.length) { console.log("slop-lint: no files found."); return 0; }
320
1145
 
321
- let emTotal = 0, warnTotal = 0;
1146
+ let emTotal = 0, artTotal = 0, warnTotal = 0, advTotal = 0;
322
1147
  for (const file of files) {
323
1148
  let text; try { text = readFileSync(file, "utf8"); } catch (e) { console.log(`skip ${file}: ${e.message}`); continue; }
324
- const { em, hits } = lintText(text);
325
- emTotal += em; warnTotal += hits.filter((h) => h.includes("⚠")).length;
326
- if (hits.length || !quiet) console.log(`\n${file}\n${hits.length ? hits.join("\n") : " clean ✓"}`);
1149
+ const code = codeMode ? CODE_EXTS[extname(file).toLowerCase()] || null : null;
1150
+ const { em, artifacts, hits, advisories } = lintText(text, { allow, profiles, rates, code });
1151
+ emTotal += em; artTotal += artifacts;
1152
+ warnTotal += hits.filter((h) => h.includes("⚠")).length;
1153
+ advTotal += advisories.length;
1154
+ const body = [...hits, ...advisories];
1155
+ if (body.length || !quiet) console.log(`\n${file}\n${body.length ? body.join("\n") : " clean ✓"}`);
327
1156
  }
328
- console.log(`\n${emTotal} em-dash failure(s), ${warnTotal} warning(s) across ${files.length} file(s).`);
329
- console.log("FAIL on em-dash; warnings are prompts to review, not bans.");
330
- return emTotal || (failOnWarn && warnTotal) ? 1 : 0;
1157
+ const fails = emTotal + artTotal;
1158
+ console.log(`\n${emTotal} em-dash failure(s), ${artTotal} artifact failure(s), ${warnTotal} warning(s), ${advTotal} advisory note(s) across ${files.length} file(s).`);
1159
+ console.log("FAIL on em-dash and machine artifacts; warnings are prompts to review, not bans; advisories never fail.");
1160
+ return fails || (failOnWarn && warnTotal) ? 1 : 0;
331
1161
  }
332
1162
 
333
1163
  // Run as a CLI when invoked directly; stay importable when required elsewhere.
334
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
1164
+ // argv[1] may be a symlink (npx and package `bin` install a node_modules/.bin
1165
+ // shim), so resolve it to its real path before comparing against this module.
1166
+ function invokedAsCli() {
1167
+ const entry = process.argv[1];
1168
+ if (!entry) return false;
1169
+ let real = entry;
1170
+ try { real = realpathSync(entry); } catch { /* keep the raw path */ }
1171
+ return import.meta.url === pathToFileURL(real).href;
1172
+ }
1173
+ if (invokedAsCli()) {
335
1174
  process.exit(main(process.argv.slice(2)));
336
1175
  }