seo 0.17.3 → 0.17.4

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { n as version, t as load } from "./esm-HKeFfXOD.js";
2
+ import { n as version, t as load } from "./esm-LhrUicGJ.js";
3
3
  import { SEO_PROVIDER_API_VERSION } from "./provider-sdk.js";
4
4
  import crypto$1, { createHash, randomUUID, sign } from "node:crypto";
5
5
  import { z } from "zod";
@@ -31243,6 +31243,17 @@ const PROSE = [
31243
31243
  "quote",
31244
31244
  "prop"
31245
31245
  ];
31246
+ const SENTENCE_KINDS = [
31247
+ "paragraph",
31248
+ "quote",
31249
+ "prop",
31250
+ "list"
31251
+ ];
31252
+ const RHYTHM_KINDS = [
31253
+ "paragraph",
31254
+ "quote",
31255
+ "prop"
31256
+ ];
31246
31257
  const ALL = [
31247
31258
  "paragraph",
31248
31259
  "list",
@@ -31496,7 +31507,7 @@ const PHRASE_RULES = [
31496
31507
  id: "significance-inflation",
31497
31508
  family: "ai",
31498
31509
  level: "error",
31499
- description: "Importance puffery: \"plays a crucial role\", \"marks a pivotal moment\", \"a testament to\".",
31510
+ description: "Importance puffery: \"plays a crucial role\", \"marks a pivotal moment\", \"a testament to\", \"the part that really matters\".",
31500
31511
  patterns: [
31501
31512
  /\bplays? an? (?:crucial|pivotal|vital|key|significant|critical|central|important|major) role\b/gi,
31502
31513
  /\b(?:marks?|marking|represents?|signals?) an? (?:pivotal|significant|important|major|defining|watershed|key) (?:moment|shift|turning point|milestone|step)\b/gi,
@@ -31515,8 +31526,11 @@ const PHRASE_RULES = [
31515
31526
  /\b(?:a|another) (?:major|key|significant|important|huge|big|proud) milestone\b/gi,
31516
31527
  /\bbuilding a better (?:future|world|tomorrow)\b/gi,
31517
31528
  /\bthe implications are (?:profound|significant|enormous|huge|far-reaching)\b/gi,
31518
- /\b(?:is|was) an (?:event|experience|attraction) in itself\b/gi
31529
+ /\b(?:is|was) an (?:event|experience|attraction) in itself\b/gi,
31530
+ /\b(?:answers|asks|addresses) the (?:actual|real) question\b/gi,
31531
+ /\bthe (?:one |only )?(?:part|bit|thing|piece|step|number|leg|detail|line|row) that (?:actually|really|truly) (?:matters|counts)\b/gi
31519
31532
  ],
31533
+ levelFor: (match) => /question|that (?:actually|really|truly)/i.test(match.text) ? "warning" : void 0,
31520
31534
  message: "It inflates importance without saying what changed.",
31521
31535
  fix: "Cut it, or name the concrete effect the text already states. Do not add a number that is not there."
31522
31536
  },
@@ -31524,9 +31538,9 @@ const PHRASE_RULES = [
31524
31538
  id: "participle-tail",
31525
31539
  family: "ai",
31526
31540
  level: "error",
31527
- description: "A sentence that ends on \", highlighting/underscoring/showcasing ...\" commentary.",
31541
+ description: "A sentence that ends on \", highlighting/underscoring/suggesting ...\" commentary.",
31528
31542
  kinds: PROSE,
31529
- patterns: [/,\s+(?:highlighting|underscoring|emphasi[sz]ing|showcasing|symboli[sz]ing|solidifying|cementing|signall?ing|reinforcing|fostering|cultivating|paving the way|setting the stage|demonstrating|illustrating|reflecting|ensuring|marking|contributing to)\b[^.!?]{0,120}[.!?]?/gi, /,\s+(?:giving (?:users|teams|customers|small teams|every \w+|people) (?:a|an|the|more)\b|freeing (?:you|them|up)\b|making it (?:easy|easier|simple|simpler|effortless|possible) (?:for|to)\b|creating an? (?:[\w-]+ )?(?:experience|panorama|atmosphere|sense)\b|delivering (?:real-time|accurate|predictions|reliable|a seamless|an intuitive)\b)[^.!?]{0,120}[.!?]?/gi],
31543
+ patterns: [/,\s+(?:highlighting|underscoring|emphasi[sz]ing|showcasing|symboli[sz]ing|solidifying|cementing|signall?ing|reinforcing|fostering|cultivating|paving the way|setting the stage|suggesting|demonstrating|illustrating|reflecting|ensuring|marking|contributing to)\b[^.!?]{0,120}[.!?]?/gi, /,\s+(?:giving (?:users|teams|customers|small teams|every \w+|people) (?:a|an|the|more)\b|freeing (?:you|them|up)\b|making it (?:easy|easier|simple|simpler|effortless|possible) (?:for|to)\b|creating an? (?:[\w-]+ )?(?:experience|panorama|atmosphere|sense)\b|delivering (?:real-time|accurate|predictions|reliable|a seamless|an intuitive)\b)[^.!?]{0,120}[.!?]?/gi],
31530
31544
  levelFor: (match) => /^,\s+(?:reflecting|ensuring|marking|contributing|demonstrating|illustrating|giving|freeing|making|creating|delivering)/i.test(match.text) ? "warning" : void 0,
31531
31545
  message: "The \", highlighting ...\" tail comments on the sentence instead of adding a fact.",
31532
31546
  fix: "End the sentence at the comma. If the tail holds a real fact, give it its own sentence with a subject and verb."
@@ -31639,6 +31653,7 @@ const PHRASE_RULES = [
31639
31653
  /\bpunch(?:es|ing)? (?:well )?above (?:its|their|his|her) weight\b/gi,
31640
31654
  /\b(?:thrilled|delighted) to (?:announce|share|introduce|unveil)\b/gi,
31641
31655
  /\bthe (?:whole|entire) point\b/gi,
31656
+ /\bthe only (?:[\w-]+ ){1,3}(?:I|we) (?:actually |really |still )?trust\b/gi,
31642
31657
  /,? which is (?:the (?:whole |real |entire )?point|exactly the point|kind of the point)\b/gi
31643
31658
  ],
31644
31659
  message: (match) => `"${match.text}" is a stock phrase that would fit any page.`,
@@ -31763,6 +31778,16 @@ const PHRASE_RULES = [
31763
31778
  message: "Two hedges where one, or none, would do.",
31764
31779
  fix: "Keep one qualifier, or state what the evidence shows."
31765
31780
  },
31781
+ {
31782
+ id: "false-range",
31783
+ family: "ai",
31784
+ level: "error",
31785
+ kinds: PROSE,
31786
+ description: "Stacked \"from X to Y\" ranges that sound broad but name no scale: \"from the Big Bang to the cosmic web, from stars to dark matter\".",
31787
+ patterns: [/\bfrom [^,.;:!?\n]{1,40} to [^,.;:!?\n]{1,40},\s+(?:and )?from [^,.;:!?\n]{1,40} to [^,.;:!?\n]{1,40}/gi],
31788
+ message: "Two \"from X to Y\" ranges in a row cover everything and say nothing.",
31789
+ fix: "Name the specific things the text covers, or cut the ranges."
31790
+ },
31766
31791
  {
31767
31792
  id: "colon-reveal",
31768
31793
  family: "ai",
@@ -31821,27 +31846,30 @@ const PHRASE_RULES = [
31821
31846
  family: "ai",
31822
31847
  level: "error",
31823
31848
  kinds: PROSE,
31824
- description: "A one-line denial used as a beat: \"It isn't.\" \"Not quite.\" \"But only part.\"",
31849
+ description: "A one-line denial used as a beat: \"It isn't.\" \"Not quite.\" \"The sixth is not.\" \"; the data didn't.\"",
31825
31850
  patterns: [
31826
31851
  /(?:^|[.!?:]\s+)(?:It|That|This|They|He|She|We) (?:isn't|wasn't|doesn't|didn't|won't|aren't|weren't|is not|was not|does not|did not)\.(?=\s|$)/g,
31827
31852
  /(?:^|[.!?:]\s+)(?:Not quite|Not even close|Not really|Not anymore|Not any more)\.(?=\s|$)/g,
31828
- /(?:^|[.!?:]\s+)(?:But|And) only (?:part|half|some|partly)\.(?=\s|$)/g
31853
+ /(?:^|[.!?:]\s+)(?:But|And) only (?:part|half|some|partly)\.(?=\s|$)/g,
31854
+ /(?:^|[.!?]\s+)The (?:[\w-]+ ){0,1}[\w-]+ (?:isn't|wasn't|doesn't|didn't|won't|aren't|weren't|hasn't|haven't|is not|was not|does not|did not|are not|were not|has not)\.(?=\s|$)/g,
31855
+ /;\s+(?:the|its|their|our|your) (?:[\w-]+ ){0,1}[\w-]+ (?:isn't|wasn't|doesn't|didn't|won't|aren't|weren't|hasn't|haven't|is not|was not|does not|did not|are not|were not|has not)\.(?=\s|$)/gi
31829
31856
  ],
31830
- message: "A two-word denial used for rhythm. It makes the reader wait.",
31831
- fix: "Join it to the sentence before, so the point is stated once."
31857
+ message: "A bare denial used for rhythm. It makes the reader wait.",
31858
+ fix: "Join it to the sentence before and name the thing, so the point is stated once."
31832
31859
  },
31833
31860
  {
31834
31861
  id: "strawman",
31835
31862
  family: "ai",
31836
31863
  level: "error",
31837
31864
  kinds: PROSE,
31838
- description: "An answer to an objection nobody raised: \"It isn't perfect.\", \"doesn't have to be stressful\", \"None of this means\", \"This isn't about\".",
31865
+ description: "An answer to an objection nobody raised: \"It isn't perfect.\", \"doesn't have to be stressful\", \"None of this means\", \"This isn't about\", \"is the obvious reading, and it is wrong\".",
31839
31866
  patterns: [
31840
31867
  /(?:^|[.!?:]\s+)(?:It|This|That|Nothing|No \w+)(?:'s| is|'s not| isn't| is not| wasn't| was not) (?:not )?perfect\.(?=\s|$)/g,
31841
31868
  /\b(?:doesn't|does not|don't|do not|needn't|need not) (?:have to |need to )?be (?:so )?(?:stressful|hard|complicated|difficult|painful|expensive|overwhelming|a chore|scary|intimidating|daunting|confusing|a headache)\b/gi,
31842
31869
  /(?:^|[.!?]\s)None of this means\b/g,
31843
31870
  /(?:^|[.!?]\s)(?:This|That|It)(?: isn't| is not|'s not) (?:just |really |only )?about\b/g,
31844
- /\b(?:isn't|is not|ain't) rocket science\b/gi
31871
+ /\b(?:isn't|is not|ain't) rocket science\b/gi,
31872
+ /\bis the (?:obvious|natural|easy|tempting|intuitive|common|usual|first) (?:reading|answer|interpretation|explanation|assumption|guess|conclusion|take)(?:,)? (?:and|but) (?:it(?:'s| is| was)|that(?:'s| is)) (?:wrong|mistaken|backwards|not (?:quite )?right)\b/gi
31845
31873
  ],
31846
31874
  message: "It answers a doubt the reader did not raise.",
31847
31875
  fix: "Cut it, or state the limit or the point plainly as a fact."
@@ -32102,7 +32130,7 @@ const SEO_RULES = {
32102
32130
  family: "copy",
32103
32131
  level: "error",
32104
32132
  presets: { docs: "warning" },
32105
- description: "Headings that label instead of telling: \"Overview\", \"Key takeaways\", \"Why it matters\", \"The ultimate guide\"."
32133
+ description: "Headings that label instead of telling, or tease: \"Overview\", \"Key takeaways\", \"Why it matters\", 'What \"exhausted\" means', \"X is dead\"."
32106
32134
  },
32107
32135
  emoji: {
32108
32136
  id: "emoji",
@@ -32174,6 +32202,7 @@ function lengths(ctx) {
32174
32202
  }
32175
32203
  }
32176
32204
  const HEADING_CLICHE = /^(?:a )?(?:deep dive|under the hood|demystifying\b|why (?:it|this|that) matters|a closer look|the ultimate guide|everything you need to know|mastering\b|unlocking\b|the power of\b|the future of\b|what you'll learn|key takeaways|final thoughts|wrapping up|conclusion|in conclusion|tl;?dr|overview|introduction|the road ahead|looking ahead|challenges and (?:legacy|opportunities|future)|future outlook|the bottom line|let's dive in|get started today|(?:the )?(?:challenge|solution|results?)$|at a glance$|first impressions$|a note of thanks$)/i;
32205
+ const HEADING_COY = /^(?:what "[^"]{1,40}" (?:really |actually )?means$|[^?]{1,60} is dead$|the one [\w-]+ (?:that|which|you|we)\b)/i;
32177
32206
  function headings(ctx) {
32178
32207
  const list = ctx.blocks(["heading"]);
32179
32208
  const h1s = list.filter((block) => block.level === 1);
@@ -32183,7 +32212,8 @@ function headings(ctx) {
32183
32212
  const level = block.level ?? 2;
32184
32213
  if (previous && level > previous + 1) ctx.hit(SEO_RULES.headingSkip, block, 0, block.text.length, `This H${level} follows an H${previous}.`, `Make it an H${previous + 1}, or add the missing level above it.`);
32185
32214
  previous = level;
32186
- if (HEADING_CLICHE.test(block.norm)) ctx.hit(SEO_RULES.headingCliche, block, 0, block.text.length, "A heading that labels the section instead of saying what is in it.", "Name what the section tells the reader, such as \"Check coverage before trusting the count\".");
32215
+ const coy = HEADING_COY.test(block.norm);
32216
+ if (coy || HEADING_CLICHE.test(block.norm)) ctx.hit(SEO_RULES.headingCliche, block, 0, block.text.length, coy ? "A heading that teases or announces a verdict instead of saying what is in the section." : "A heading that labels the section instead of saying what is in it.", "Name what the section tells the reader, such as \"Check coverage before trusting the count\".");
32187
32217
  }
32188
32218
  }
32189
32219
  const EMOJI = /^\p{Extended_Pictographic}/u;
@@ -32300,94 +32330,8 @@ function runSeoRules(ctx) {
32300
32330
  heroLength(ctx);
32301
32331
  reviews(ctx);
32302
32332
  }
32303
- // packages/core/src/lint/rules-structure.ts
32304
- const SENTENCE_KINDS = [
32305
- "paragraph",
32306
- "quote",
32307
- "prop",
32308
- "list"
32309
- ];
32310
- const RHYTHM_KINDS = [
32311
- "paragraph",
32312
- "quote",
32313
- "prop"
32314
- ];
32315
- const STRUCTURE_RULES = {
32316
- negativeParallelism: {
32317
- id: "negative-parallelism",
32318
- family: "ai",
32319
- level: "error",
32320
- description: "\"It isn't X, it's Y\" and \"isn't just X. It's Y.\" reframes."
32321
- },
32322
- contrastReframe: {
32323
- id: "contrast-reframe",
32324
- family: "ai",
32325
- level: "error",
32326
- presets: { docs: "warning" },
32327
- description: "A trailing \", not X\" or \"rather than X\" contrast added for drama: \"The fix is in the template, not in 600 posts.\""
32328
- },
32329
- heresAnnouncement: {
32330
- id: "heres-announcement",
32331
- family: "ai",
32332
- level: "error",
32333
- presets: { docs: "off" },
32334
- description: "A short \"Here's the X\" sentence that announces what comes next instead of saying it."
32335
- },
32336
- pithyFragment: {
32337
- id: "pithy-fragment",
32338
- family: "ai",
32339
- level: "error",
32340
- description: "Verbless slogan fragments: \"Same essay, two titles.\", \"Every month. No exceptions.\", \"$299 per month. That's it.\""
32341
- },
32342
- stockCloser: {
32343
- id: "stock-closer",
32344
- family: "ai",
32345
- level: "error",
32346
- description: "A stock kicker line: \"That's a real win.\" \"That is what makes this interesting.\""
32347
- },
32348
- negativeReframe: {
32349
- id: "negative-reframe",
32350
- family: "ai",
32351
- level: "warning",
32352
- description: "A short \"That's not how/what ...\" dismissal."
32353
- },
32354
- figurativeWorth: {
32355
- id: "figurative-worth",
32356
- family: "ai",
32357
- level: "error",
32358
- description: "A \"worth + -ing\" idiom that mixes its metaphor or points at the reader: \"a fight worth picking\", \"worth noting\"."
32359
- },
32360
- anaphora: {
32361
- id: "anaphora",
32362
- family: "ai",
32363
- level: "error",
32364
- description: "Short sentences in a row that start with the same word: two or more \"No ...\" sentences, or three or more starting \"It's\", \"They\", \"We\" or \"You\"."
32365
- },
32366
- vocabularyCluster: {
32367
- id: "ai-vocabulary-cluster",
32368
- family: "ai",
32369
- level: "warning",
32370
- description: "Two or more words such as crucial, pivotal, foster, landscape or journey in one paragraph."
32371
- },
32372
- triad: {
32373
- id: "triad",
32374
- family: "ai",
32375
- level: "warning",
32376
- presets: { docs: "off" },
32377
- description: "Formula triads: three parallel clauses (\"It is cheap, it is reversible, and it works\"), three items that open with the same word, three adjectives after \"is\", or three abstract nouns. Plain lists of three are left alone."
32378
- },
32379
- inventedLabel: {
32380
- id: "invented-label",
32381
- family: "ai",
32382
- level: "warning",
32383
- description: "Two or more coined labels such as \"the integration tax\" or \"the supervision paradox\"."
32384
- },
32385
- pseudoCleft: {
32386
- id: "pseudo-cleft",
32387
- family: "ai",
32388
- level: "warning",
32389
- description: "Repeated \"What makes this work is ...\" or \"The problem is that ...\" setups."
32390
- },
32333
+ // packages/core/src/lint/rules-bold.ts
32334
+ const BOLD_RULES = {
32391
32335
  boldEmphasis: {
32392
32336
  id: "bold-emphasis",
32393
32337
  family: "ai",
@@ -32403,7 +32347,87 @@ const STRUCTURE_RULES = {
32403
32347
  family: "ai",
32404
32348
  level: "warning",
32405
32349
  presets: { docs: "off" },
32406
- description: "Three or more list items in a row that open with a bold label."
32350
+ description: "Three or more list items in a row that open with a bold label, or one whose label the item then repeats: \"**Performance:** Performance has been improved.\""
32351
+ }
32352
+ };
32353
+ const RESTATED = /^\s*(?:[-*+]|\d{1,9}[.)])\s+(?:\*\*|__)(?:[^*_\n]{0,30}\s)?([a-z]{4})[^*_\s]*(?:\*\*|__)\s*[:.]?\s+\1/i;
32354
+ function boldLabels(ctx) {
32355
+ const rule = BOLD_RULES.boldLabels;
32356
+ if (ctx.level(rule) === "off") return;
32357
+ if (ctx.doc.format !== "md" && ctx.doc.format !== "mdx") return;
32358
+ const lists = ctx.blocks(["list"]);
32359
+ let run = [];
32360
+ const report = () => {
32361
+ if (run.length >= 3) {
32362
+ const first = run[0];
32363
+ ctx.hit(rule, first, 0, Math.min(first.text.length, 60), `${run.length} list items in a row open with a bold label.`, "Drop the bold labels and write each item as one plain sentence, or use a table if the items really are parallel.");
32364
+ }
32365
+ run = [];
32366
+ };
32367
+ let previous = null;
32368
+ for (const block of lists) {
32369
+ const offset = block.map[0] ?? 0;
32370
+ const line = ctx.doc.source.lastIndexOf("\n", offset) + 1;
32371
+ const raw = ctx.doc.source.slice(line, offset + 4);
32372
+ const bold = /^\s*(?:[-*+]|\d{1,9}[.)])\s+(?:\*\*|__)/.test(raw);
32373
+ if (bold && RESTATED.test(ctx.doc.source.slice(line, line + 200))) ctx.hit(rule, block, 0, Math.min(block.text.length, 60), "The item repeats its bold label.", "Drop the label and keep the sentence, or cut the repeat.");
32374
+ const adjacent = previous !== null && ctx.doc.blocks.indexOf(block) === ctx.doc.blocks.indexOf(previous) + 1;
32375
+ if (!bold || !adjacent) report();
32376
+ if (bold) run.push(block);
32377
+ previous = block;
32378
+ }
32379
+ report();
32380
+ }
32381
+ function boldEmphasis(ctx) {
32382
+ const rule = BOLD_RULES.boldEmphasis;
32383
+ if (ctx.level(rule) === "off") return;
32384
+ const markdown = ctx.doc.format === "md" || ctx.doc.format === "mdx";
32385
+ const re = markdown ? /(\*\*|__)(?=\S)[^*_\n]+?\1/g : /<(strong|b)\b[^>]*>[^<]{1,200}<\/\1>/gi;
32386
+ const prose = ctx.blocks([
32387
+ "paragraph",
32388
+ "list",
32389
+ "quote",
32390
+ "prop"
32391
+ ]);
32392
+ const spans = [];
32393
+ for (const found of ctx.doc.source.matchAll(re)) {
32394
+ const open = markdown ? 2 : found[0].indexOf(">") + 1;
32395
+ const from = (found.index ?? 0) + open;
32396
+ const to = (found.index ?? 0) + found[0].length - (markdown ? 2 : found[0].length - found[0].lastIndexOf("<"));
32397
+ for (const block of prose) {
32398
+ const first = block.map[0] ?? 0;
32399
+ const last = block.map[block.map.length - 1] ?? 0;
32400
+ if (from < first || from > last) continue;
32401
+ const start = block.map.indexOf(from);
32402
+ if (start <= 0 && block.kind === "list") break;
32403
+ if (start < 0) break;
32404
+ let end = start;
32405
+ while (end < block.map.length && (block.map[end] ?? 0) < to) end++;
32406
+ spans.push({
32407
+ block,
32408
+ start,
32409
+ end
32410
+ });
32411
+ break;
32412
+ }
32413
+ }
32414
+ if (spans.length < 3 || spans.length * 100 <= ctx.proseWords) return;
32415
+ for (const span of spans) ctx.hit(rule, span.block, span.start, span.end, `${spans.length} bold phrases in ${ctx.proseWords.toLocaleString("en-US")} words of prose. Bold this often stops meaning "important".`, "Remove the bold here. Keep bold, if any, for the one thing a skimming reader must not miss.");
32416
+ }
32417
+ // packages/core/src/lint/rules-contrast.ts
32418
+ const CONTRAST_RULES = {
32419
+ negativeParallelism: {
32420
+ id: "negative-parallelism",
32421
+ family: "ai",
32422
+ level: "error",
32423
+ description: "\"It isn't X, it's Y\" and \"isn't just X. It's Y.\" reframes."
32424
+ },
32425
+ contrastReframe: {
32426
+ id: "contrast-reframe",
32427
+ family: "ai",
32428
+ level: "error",
32429
+ presets: { docs: "warning" },
32430
+ description: "A trailing \", not X\" or \"rather than X\" contrast added for drama: \"The fix is in the template, not in 600 posts.\""
32407
32431
  }
32408
32432
  };
32409
32433
  const NEG = "(?:\\b(?:is|are|was|were)(?:n't|\\s+not)\\b|\\b(?:it|this|that|they|we|you)(?:'s|'re)\\s+not\\b)";
@@ -32431,7 +32455,7 @@ const PARALLEL = [
32431
32455
  ];
32432
32456
  const FRAMING = /^(?:the |this |that |our |my |your )?(?:real )?(?:problem|question|answer|issue|point|goal|story|bottleneck|fix|difference|trick|lesson|catch|risk|gap|win|work|job|key|opportunity|plan|idea|value)\b/i;
32433
32457
  function negativeParallelism(ctx) {
32434
- const rule = STRUCTURE_RULES.negativeParallelism;
32458
+ const rule = CONTRAST_RULES.negativeParallelism;
32435
32459
  for (const block of ctx.blocks(SENTENCE_KINDS)) {
32436
32460
  const sentences = ctx.sentences(block);
32437
32461
  const taken = [];
@@ -32495,7 +32519,7 @@ function gerund(word) {
32495
32519
  }
32496
32520
  const NOT_JUST = /,\s+not (?:just|merely|simply) [^,.;:!?]{1,50}[.!?]?$|\bnot (?:just|merely|simply) [^,.;:!?]{1,50},? but\b/i;
32497
32521
  function contrastReframe(ctx) {
32498
- const rule = STRUCTURE_RULES.contrastReframe;
32522
+ const rule = CONTRAST_RULES.contrastReframe;
32499
32523
  if (ctx.level(rule) === "off") return;
32500
32524
  for (const block of ctx.blocks([...SENTENCE_KINDS, "heading"])) for (const sentence of ctx.sentences(block)) {
32501
32525
  const text = sentence.text;
@@ -32539,8 +32563,227 @@ function contrastReframe(ctx) {
32539
32563
  }
32540
32564
  }
32541
32565
  }
32566
+ // packages/core/src/lint/rules-counted.ts
32567
+ const COUNTED_RULES = {
32568
+ vocabularyCluster: {
32569
+ id: "ai-vocabulary-cluster",
32570
+ family: "ai",
32571
+ level: "warning",
32572
+ description: "Two or more words such as crucial, pivotal, foster, landscape or journey in one paragraph."
32573
+ },
32574
+ triad: {
32575
+ id: "triad",
32576
+ family: "ai",
32577
+ level: "warning",
32578
+ presets: { docs: "off" },
32579
+ description: "Formula triads: three parallel clauses (\"It is cheap, it is reversible, and it works\"), three items that open with the same word, three adjectives after \"is\", or three abstract nouns. Plain lists of three are left alone."
32580
+ },
32581
+ inventedLabel: {
32582
+ id: "invented-label",
32583
+ family: "ai",
32584
+ level: "warning",
32585
+ description: "Two or more coined labels such as \"the integration tax\" or \"the supervision paradox\"."
32586
+ },
32587
+ colonDensity: {
32588
+ id: "colon-density",
32589
+ family: "ai",
32590
+ level: "warning",
32591
+ description: "Colons used mid-sentence as a pause or lead-in, three or more per 1,000 words. One is ordinary; a piece full of them reads as AI."
32592
+ },
32593
+ pseudoCleft: {
32594
+ id: "pseudo-cleft",
32595
+ family: "ai",
32596
+ level: "warning",
32597
+ description: "Repeated \"What makes this work is ...\" or \"The problem is that ...\" setups."
32598
+ }
32599
+ };
32600
+ const TIER2 = /\b(?:crucial(?:ly)?|pivotal|vibrant|comprehensive|enhanc(?:e|es|ed|ing|ement)|foster(?:s|ed|ing)?|harness(?:es|ed|ing)?|navigat(?:e|es|ed|ing)|streamlin(?:e|es|ed|ing)|empower(?:s|ed|ing|ment)?|elevat(?:e|es|ed|ing)|unleash(?:es|ed|ing)?|transformative|nuanced?|myriad|plethora|encompass(?:es|ed|ing)?|cultivat(?:e|es|ed|ing)|resonat(?:e|es|ed|ing)|cornerstone|poised|burgeoning|nascent|quintessential|overarching|actionable|impactful|landscape|ecosystem|journey|additionally|notably|moreover|furthermore|profound(?:ly)?|quietly|fundamentally|remarkabl[ey]|arguably|invaluable|deeply (?:rooted|committed|integrated|personal|meaningful))\b/gi;
32601
+ const TECHNICAL = /^(?:comprehensive|ecosystem|streamlin|navigat)/i;
32602
+ function vocabularyCluster(ctx) {
32603
+ const rule = COUNTED_RULES.vocabularyCluster;
32604
+ if (ctx.level(rule) === "off") return;
32605
+ for (const block of ctx.blocks([
32606
+ "paragraph",
32607
+ "list",
32608
+ "quote",
32609
+ "prop",
32610
+ "heading",
32611
+ "description",
32612
+ "title"
32613
+ ])) {
32614
+ const seen = /* @__PURE__ */ new Map();
32615
+ TIER2.lastIndex = 0;
32616
+ for (const found of block.norm.matchAll(TIER2)) {
32617
+ const word = found[0].toLowerCase();
32618
+ if (ctx.preset === "docs" && TECHNICAL.test(word)) continue;
32619
+ const stem = word.slice(0, 6);
32620
+ const start = found.index ?? 0;
32621
+ if (ctx.preset === "landing" || ctx.preset === "meta") {
32622
+ ctx.hit(rule, block, start, start + found[0].length, `"${found[0]}" is filler in short copy.`, "Use the plain word, or the concrete thing it stands for.");
32623
+ continue;
32624
+ }
32625
+ if (!seen.has(stem)) seen.set(stem, start);
32626
+ if (seen.size === 2 && !seen.has(`${stem}!`)) {
32627
+ seen.set(`${stem}!`, start);
32628
+ const listed = [...seen.keys()].filter((key) => !key.endsWith("!"));
32629
+ ctx.hit(rule, block, start, start + found[0].length, `This paragraph stacks words common in AI text (${listed.length} of them, ending with "${found[0]}").`, "Rewrite with plain words: \"important\" for crucial, \"help\" for foster, \"field\" for landscape, or cut them.");
32630
+ }
32631
+ }
32632
+ }
32633
+ }
32634
+ const SERIES = /\b[\w'$-]+(?: [\w'$-]+){0,5}(?:, [\w'$-]+(?: [\w'$-]+){0,5}){1,3},? (?:and|or) [\w'$-]+(?: [\w'$-]+){0,5}/g;
32635
+ const ABSTRACT_TRIAD = /\b[a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism), (?:and )?[a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism),? and [a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism)\b/gi;
32636
+ const ECHO = new Set("to our your their my his her its every each more less no it they we you".split(" "));
32637
+ const COPULA = /\b(?:is|are|was|were|'s|feels?|felt|looks?|stays?|remains?|seems?)\s+$/i;
32638
+ function formulaTriad(items, before) {
32639
+ const firsts = items.map((item) => words$2(item)[0]?.toLowerCase() ?? "");
32640
+ const echo = firsts[0] ?? "";
32641
+ if (ECHO.has(echo) && firsts.every((first) => first === echo)) return `Each item opens with "${echo}".`;
32642
+ if (items.every((item) => /^(?:the|their|our|your|its|it|they|we|you|he|she)\b/i.test(item) && words$2(item).length >= 3 && words$2(item).length <= 7 && !verbless(item))) return "Three parallel clauses in a row.";
32643
+ if (items.every((item) => /^[a-z]/.test(item) && words$2(item).length <= 2 && !PREPOSITIONS.has(words$2(item)[0] ?? "")) && COPULA.test(before)) return "A string of adjectives after \"is\".";
32644
+ if (items.every((item) => /^\w+ed\b/i.test(item) && words$2(item).length <= 3)) return "A string of past participles.";
32645
+ return null;
32646
+ }
32647
+ function triads(ctx) {
32648
+ const rule = COUNTED_RULES.triad;
32649
+ if (ctx.level(rule) === "off") return;
32650
+ for (const block of ctx.blocks([
32651
+ "paragraph",
32652
+ "quote",
32653
+ "prop",
32654
+ "list"
32655
+ ])) {
32656
+ const taken = [];
32657
+ ABSTRACT_TRIAD.lastIndex = 0;
32658
+ for (const match of block.norm.matchAll(ABSTRACT_TRIAD)) {
32659
+ const start = match.index ?? 0;
32660
+ taken.push([start, start + match[0].length]);
32661
+ ctx.hit(rule, block, start, start + match[0].length, "Three abstract nouns in a row sound weighty but say little.", "Keep the one that matters and give an example of it.");
32662
+ }
32663
+ for (const sentence of ctx.sentences(block)) {
32664
+ SERIES.lastIndex = 0;
32665
+ for (const match of sentence.text.matchAll(SERIES)) {
32666
+ let from = match.index ?? 0;
32667
+ const raw = match[0].split(/,\s*(?:(?:and|or)\s+)?|\s+(?:and|or)\s+(?=[^,]*$)/);
32668
+ if (raw.length < 3) continue;
32669
+ const items = [...raw];
32670
+ const head = raw[0] ?? "";
32671
+ const lead = /^.*\b(?:is|are|was|were|'s|feels?|looks?|stays?|remains?|seems?|of|for|to|with|by|from|on|in|like|including|as)\s+/i.exec(head);
32672
+ if (lead && words$2(head.slice(lead[0].length)).length) {
32673
+ items[0] = head.slice(lead[0].length);
32674
+ from += lead[0].length;
32675
+ }
32676
+ const end = sentence.start + (match.index ?? 0) + match[0].length;
32677
+ const before = block.norm.slice(sentence.start, sentence.start + from);
32678
+ const echo = words$2(raw[1] ?? "")[0]?.toLowerCase() ?? "";
32679
+ const inFirst = new RegExp(`\\b${echo}\\b(?!.*\\b${echo}\\b)`, "i").exec(head);
32680
+ if (ECHO.has(echo) && inFirst && inFirst.index > 0) {
32681
+ items[0] = head.slice(inFirst.index);
32682
+ from = (match.index ?? 0) + inFirst.index;
32683
+ }
32684
+ const plain = formulaTriad(raw, "");
32685
+ const why = plain ?? formulaTriad(items, before);
32686
+ if (!why) continue;
32687
+ if (plain) from = match.index ?? 0;
32688
+ const start = sentence.start + from;
32689
+ if (taken.some(([a, b]) => start < b && end > a)) continue;
32690
+ taken.push([start, end]);
32691
+ ctx.hit(rule, block, start, end, `A list of ${items.length} that reads as a formula. ${why}`, "Keep the items the reader needs. If all of them are needed, write them plainly or as two sentences; if one was added for rhythm, cut it.");
32692
+ }
32693
+ }
32694
+ }
32695
+ }
32696
+ function countedPatterns(ctx) {
32697
+ const labels = COUNTED_RULES.inventedLabel;
32698
+ const clefts = COUNTED_RULES.pseudoCleft;
32699
+ for (const [rule, re] of [[labels, /\bthe [a-z]+(?:-[a-z]+)? (?:paradox|trap|tax|creep|divide|vacuum|inversion|cliff|treadmill|illusion|fallacy|flywheel|moat)\b/gi], [clefts, /(?:^|[.!?]\s+)(?:What (?:makes|made|matters|changed|really|actually|you get|this means|I (?:like|love|learned|found))\b[^.!?]{0,40}\s+(?:is|was)\b|The (?:problem|difference|catch|key|trick|point|reason) is that\b)/g]]) {
32700
+ if (ctx.level(rule) === "off") continue;
32701
+ const found = [];
32702
+ for (const block of ctx.blocks(RHYTHM_KINDS)) {
32703
+ re.lastIndex = 0;
32704
+ for (const match of block.norm.matchAll(re)) {
32705
+ let start = match.index ?? 0;
32706
+ while (/[\s.!?]/.test(block.norm[start] ?? "")) start++;
32707
+ found.push({
32708
+ block,
32709
+ start,
32710
+ end: (match.index ?? 0) + match[0].length
32711
+ });
32712
+ }
32713
+ }
32714
+ if (found.length < 2) continue;
32715
+ for (const item of found) ctx.hit(rule, item.block, item.start, item.end, rule === labels ? `${found.length} coined labels in one piece. Each asks the reader to learn a term.` : `${found.length} "What X is" or "The problem is that" setups in one piece.`, rule === labels ? "Describe the thing in plain words instead of naming it." : "Start with the subject and say the thing directly.");
32716
+ }
32717
+ }
32718
+ function colonDensity(ctx) {
32719
+ const rule = COUNTED_RULES.colonDensity;
32720
+ if (ctx.level(rule) === "off") return;
32721
+ const found = [];
32722
+ for (const block of ctx.blocks(SENTENCE_KINDS)) {
32723
+ const sentences = ctx.sentences(block);
32724
+ for (const match of block.norm.matchAll(/:\s+(?=\S)/g)) {
32725
+ const at = match.index ?? 0;
32726
+ const after = block.norm.slice(at + match[0].length);
32727
+ if (/^["'(]/.test(after)) continue;
32728
+ const lead = block.norm.slice(sentenceAt(sentences, at).start, at);
32729
+ if (words$2(lead).length <= 4 && verbless(lead)) continue;
32730
+ const source = block.map[at] ?? -1;
32731
+ if (/^(?:\*\*|__)/.test(ctx.doc.source.slice(source + 1, source + 3)) || /(?:\*\*|__)$/.test(ctx.doc.source.slice(source - 2, source))) continue;
32732
+ if (block.links.some((link) => link.start <= at && link.end > at)) continue;
32733
+ if (insideQuotes(block.norm, at, at + 1)) continue;
32734
+ const clause = after.match(/^(?:[^.!?;]|[.!?](?=\S)){0,60}/)?.[0] ?? "";
32735
+ found.push({
32736
+ block,
32737
+ start: at,
32738
+ end: at + match[0].length + clause.trimEnd().length
32739
+ });
32740
+ }
32741
+ }
32742
+ if (found.length < 4 || found.length * 1e3 < 3 * ctx.proseWords) return;
32743
+ for (const item of found) ctx.hit(rule, item.block, item.start, item.end, `${found.length} mid-sentence colons in ${ctx.proseWords.toLocaleString("en-US")} words. A colon used as a pause in sentence after sentence is a common AI habit.`, "Use a full stop, or join the two parts with a plain word such as \"because\" or \"so\". Keep colons that introduce a list or a quotation.");
32744
+ }
32745
+ // packages/core/src/lint/rules-rhythm.ts
32746
+ const RHYTHM_RULES = {
32747
+ heresAnnouncement: {
32748
+ id: "heres-announcement",
32749
+ family: "ai",
32750
+ level: "error",
32751
+ presets: { docs: "off" },
32752
+ description: "A short \"Here's the X\" sentence that announces what comes next instead of saying it."
32753
+ },
32754
+ pithyFragment: {
32755
+ id: "pithy-fragment",
32756
+ family: "ai",
32757
+ level: "error",
32758
+ description: "Verbless slogan fragments: \"Same essay, two titles.\", \"Every month. No exceptions.\", \"$299 per month. That's it.\""
32759
+ },
32760
+ stockCloser: {
32761
+ id: "stock-closer",
32762
+ family: "ai",
32763
+ level: "error",
32764
+ description: "A stock kicker line: \"That's a real win.\" \"That is what makes this interesting.\" \"That's why X mattered.\""
32765
+ },
32766
+ negativeReframe: {
32767
+ id: "negative-reframe",
32768
+ family: "ai",
32769
+ level: "warning",
32770
+ description: "A short \"That's not how/what ...\" dismissal."
32771
+ },
32772
+ figurativeWorth: {
32773
+ id: "figurative-worth",
32774
+ family: "ai",
32775
+ level: "error",
32776
+ description: "A \"worth + -ing\" idiom that mixes its metaphor or points at the reader: \"a fight worth picking\", \"worth noting\"."
32777
+ },
32778
+ anaphora: {
32779
+ id: "anaphora",
32780
+ family: "ai",
32781
+ level: "error",
32782
+ description: "Short sentences in a row that start with the same word: two or more \"No ...\" sentences, or three or more starting \"It's\", \"They\", \"We\" or \"You\"."
32783
+ }
32784
+ };
32542
32785
  function heresAnnouncement(ctx) {
32543
- const rule = STRUCTURE_RULES.heresAnnouncement;
32786
+ const rule = RHYTHM_RULES.heresAnnouncement;
32544
32787
  if (ctx.level(rule) === "off") return;
32545
32788
  for (const block of ctx.blocks([
32546
32789
  "paragraph",
@@ -32595,7 +32838,7 @@ function fragmentRuns(ctx, rule) {
32595
32838
  }
32596
32839
  }
32597
32840
  function pithyFragment(ctx) {
32598
- const rule = STRUCTURE_RULES.pithyFragment;
32841
+ const rule = RHYTHM_RULES.pithyFragment;
32599
32842
  if (ctx.level(rule) === "off") return;
32600
32843
  fragmentRuns(ctx, rule);
32601
32844
  for (const block of ctx.blocks(RHYTHM_KINDS)) for (const sentence of ctx.sentences(block)) {
@@ -32618,11 +32861,12 @@ const CLOSERS = [
32618
32861
  /^(?:and |but |so )?(?:that|this)(?:'s| is| was) (?:exactly )?what makes [^.]{1,60}(?:interesting|special|different|powerful|unique|useful|valuable|effective|work|works|matter|compelling|worth \w+)\.$/i,
32619
32862
  /^(?:and |but |so )?(?:that|this)(?:'s| is) (?:why|where|how) (?:it|this|that) (?:matters|counts|works)\.$/i,
32620
32863
  /^(?:and |but )?that distinction matters\.$/i,
32864
+ /^(?:and |but |so )?(?:that|this)(?:'s| is| was) (?:why|what|how) [^.]{1,80} (?:mattered|made (?:all )?the difference|paid off)\.$/i,
32621
32865
  /^(?:and |but )?(?:that|this)(?:'s| is) (?:huge|everything|the whole thing|what matters|all that matters)\.$/i
32622
32866
  ];
32623
32867
  function stockCloser(ctx) {
32624
- const rule = STRUCTURE_RULES.stockCloser;
32625
- const reframe = STRUCTURE_RULES.negativeReframe;
32868
+ const rule = RHYTHM_RULES.stockCloser;
32869
+ const reframe = RHYTHM_RULES.negativeReframe;
32626
32870
  for (const block of ctx.blocks(RHYTHM_KINDS)) for (const sentence of ctx.sentences(block)) {
32627
32871
  const text = sentence.text;
32628
32872
  if (CLOSERS.some((re) => re.test(text))) {
@@ -32634,7 +32878,7 @@ function stockCloser(ctx) {
32634
32878
  }
32635
32879
  const FIGURATIVE_NOUNS = "fights?|battles?|hills?|wars?|bets?|gambles?|races?|risks?|horses?|roads?|bridges?|doors?|games?|ships?|cards?";
32636
32880
  function figurativeWorth(ctx) {
32637
- const rule = STRUCTURE_RULES.figurativeWorth;
32881
+ const rule = RHYTHM_RULES.figurativeWorth;
32638
32882
  const strong = new RegExp(`\\b(?:${FIGURATIVE_NOUNS}) worth \\w+ing\\b`, "gi");
32639
32883
  const reader = /\bworth (?:noting|mentioning|knowing|highlighting|calling out|pointing out|flagging|a (?:closer |second )?look)\b/gi;
32640
32884
  const any = /\b(\w+) worth (\w+ing)\b/gi;
@@ -32679,7 +32923,7 @@ function staccato(ctx) {
32679
32923
  }
32680
32924
  }
32681
32925
  function anaphora(ctx) {
32682
- const rule = STRUCTURE_RULES.anaphora;
32926
+ const rule = RHYTHM_RULES.anaphora;
32683
32927
  if (ctx.level(rule) === "off") return;
32684
32928
  for (const block of ctx.blocks(RHYTHM_KINDS)) {
32685
32929
  const sentences = ctx.sentences(block);
@@ -32708,186 +32952,24 @@ function anaphora(ctx) {
32708
32952
  }
32709
32953
  }
32710
32954
  }
32711
- const TIER2 = /\b(?:crucial(?:ly)?|pivotal|vibrant|comprehensive|enhanc(?:e|es|ed|ing|ement)|foster(?:s|ed|ing)?|harness(?:es|ed|ing)?|navigat(?:e|es|ed|ing)|streamlin(?:e|es|ed|ing)|empower(?:s|ed|ing|ment)?|elevat(?:e|es|ed|ing)|unleash(?:es|ed|ing)?|transformative|nuanced?|myriad|plethora|encompass(?:es|ed|ing)?|cultivat(?:e|es|ed|ing)|resonat(?:e|es|ed|ing)|cornerstone|poised|burgeoning|nascent|quintessential|overarching|actionable|impactful|landscape|ecosystem|journey|additionally|notably|moreover|furthermore|profound(?:ly)?|quietly|fundamentally|remarkabl[ey]|arguably|invaluable|deeply (?:rooted|committed|integrated|personal|meaningful))\b/gi;
32712
- const TECHNICAL = /^(?:comprehensive|ecosystem|streamlin|navigat)/i;
32713
- function vocabularyCluster(ctx) {
32714
- const rule = STRUCTURE_RULES.vocabularyCluster;
32715
- if (ctx.level(rule) === "off") return;
32716
- for (const block of ctx.blocks([
32717
- "paragraph",
32718
- "list",
32719
- "quote",
32720
- "prop",
32721
- "heading",
32722
- "description",
32723
- "title"
32724
- ])) {
32725
- const seen = /* @__PURE__ */ new Map();
32726
- TIER2.lastIndex = 0;
32727
- for (const found of block.norm.matchAll(TIER2)) {
32728
- const word = found[0].toLowerCase();
32729
- if (ctx.preset === "docs" && TECHNICAL.test(word)) continue;
32730
- const stem = word.slice(0, 6);
32731
- const start = found.index ?? 0;
32732
- if (ctx.preset === "landing" || ctx.preset === "meta") {
32733
- ctx.hit(rule, block, start, start + found[0].length, `"${found[0]}" is filler in short copy.`, "Use the plain word, or the concrete thing it stands for.");
32734
- continue;
32735
- }
32736
- if (!seen.has(stem)) seen.set(stem, start);
32737
- if (seen.size === 2 && !seen.has(`${stem}!`)) {
32738
- seen.set(`${stem}!`, start);
32739
- const listed = [...seen.keys()].filter((key) => !key.endsWith("!"));
32740
- ctx.hit(rule, block, start, start + found[0].length, `This paragraph stacks words common in AI text (${listed.length} of them, ending with "${found[0]}").`, "Rewrite with plain words: \"important\" for crucial, \"help\" for foster, \"field\" for landscape, or cut them.");
32741
- }
32742
- }
32743
- }
32744
- }
32745
- const SERIES = /\b[\w'$-]+(?: [\w'$-]+){0,5}(?:, [\w'$-]+(?: [\w'$-]+){0,5}){1,3},? (?:and|or) [\w'$-]+(?: [\w'$-]+){0,5}/g;
32746
- const ABSTRACT_TRIAD = /\b[a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism), (?:and )?[a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism),? and [a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism)\b/gi;
32747
- const ECHO = new Set("to our your their my his her its every each more less no it they we you".split(" "));
32748
- const COPULA = /\b(?:is|are|was|were|'s|feels?|felt|looks?|stays?|remains?|seems?)\s+$/i;
32749
- function formulaTriad(items, before) {
32750
- const firsts = items.map((item) => words$2(item)[0]?.toLowerCase() ?? "");
32751
- const echo = firsts[0] ?? "";
32752
- if (ECHO.has(echo) && firsts.every((first) => first === echo)) return `Each item opens with "${echo}".`;
32753
- if (items.every((item) => /^(?:the|their|our|your|its|it|they|we|you|he|she)\b/i.test(item) && words$2(item).length >= 3 && words$2(item).length <= 7 && !verbless(item))) return "Three parallel clauses in a row.";
32754
- if (items.every((item) => /^[a-z]/.test(item) && words$2(item).length <= 2 && !PREPOSITIONS.has(words$2(item)[0] ?? "")) && COPULA.test(before)) return "A string of adjectives after \"is\".";
32755
- if (items.every((item) => /^\w+ed\b/i.test(item) && words$2(item).length <= 3)) return "A string of past participles.";
32756
- return null;
32757
- }
32758
- function triads(ctx) {
32759
- const rule = STRUCTURE_RULES.triad;
32760
- if (ctx.level(rule) === "off") return;
32761
- for (const block of ctx.blocks([
32762
- "paragraph",
32763
- "quote",
32764
- "prop",
32765
- "list"
32766
- ])) {
32767
- const taken = [];
32768
- ABSTRACT_TRIAD.lastIndex = 0;
32769
- for (const match of block.norm.matchAll(ABSTRACT_TRIAD)) {
32770
- const start = match.index ?? 0;
32771
- taken.push([start, start + match[0].length]);
32772
- ctx.hit(rule, block, start, start + match[0].length, "Three abstract nouns in a row sound weighty but say little.", "Keep the one that matters and give an example of it.");
32773
- }
32774
- for (const sentence of ctx.sentences(block)) {
32775
- SERIES.lastIndex = 0;
32776
- for (const match of sentence.text.matchAll(SERIES)) {
32777
- let from = match.index ?? 0;
32778
- const raw = match[0].split(/,\s*(?:(?:and|or)\s+)?|\s+(?:and|or)\s+(?=[^,]*$)/);
32779
- if (raw.length < 3) continue;
32780
- const items = [...raw];
32781
- const head = raw[0] ?? "";
32782
- const lead = /^.*\b(?:is|are|was|were|'s|feels?|looks?|stays?|remains?|seems?|of|for|to|with|by|from|on|in|like|including|as)\s+/i.exec(head);
32783
- if (lead && words$2(head.slice(lead[0].length)).length) {
32784
- items[0] = head.slice(lead[0].length);
32785
- from += lead[0].length;
32786
- }
32787
- const end = sentence.start + (match.index ?? 0) + match[0].length;
32788
- const before = block.norm.slice(sentence.start, sentence.start + from);
32789
- const echo = words$2(raw[1] ?? "")[0]?.toLowerCase() ?? "";
32790
- const inFirst = new RegExp(`\\b${echo}\\b(?!.*\\b${echo}\\b)`, "i").exec(head);
32791
- if (ECHO.has(echo) && inFirst && inFirst.index > 0) {
32792
- items[0] = head.slice(inFirst.index);
32793
- from = (match.index ?? 0) + inFirst.index;
32794
- }
32795
- const plain = formulaTriad(raw, "");
32796
- const why = plain ?? formulaTriad(items, before);
32797
- if (!why) continue;
32798
- if (plain) from = match.index ?? 0;
32799
- const start = sentence.start + from;
32800
- if (taken.some(([a, b]) => start < b && end > a)) continue;
32801
- taken.push([start, end]);
32802
- ctx.hit(rule, block, start, end, `A list of ${items.length} that reads as a formula. ${why}`, "Keep the items the reader needs. If all of them are needed, write them plainly or as two sentences; if one was added for rhythm, cut it.");
32803
- }
32804
- }
32805
- }
32806
- }
32807
- function countedPatterns(ctx) {
32808
- const labels = STRUCTURE_RULES.inventedLabel;
32809
- const clefts = STRUCTURE_RULES.pseudoCleft;
32810
- for (const [rule, re] of [[labels, /\bthe [a-z]+(?:-[a-z]+)? (?:paradox|trap|tax|creep|divide|vacuum|inversion|cliff|treadmill|illusion|fallacy|flywheel|moat)\b/gi], [clefts, /(?:^|[.!?]\s+)(?:What (?:makes|made|matters|changed|really|actually|you get|this means|I (?:like|love|learned|found))\b[^.!?]{0,40}\s+(?:is|was)\b|The (?:problem|difference|catch|key|trick|point|reason) is that\b)/g]]) {
32811
- if (ctx.level(rule) === "off") continue;
32812
- const found = [];
32813
- for (const block of ctx.blocks(RHYTHM_KINDS)) {
32814
- re.lastIndex = 0;
32815
- for (const match of block.norm.matchAll(re)) {
32816
- let start = match.index ?? 0;
32817
- while (/[\s.!?]/.test(block.norm[start] ?? "")) start++;
32818
- found.push({
32819
- block,
32820
- start,
32821
- end: (match.index ?? 0) + match[0].length
32822
- });
32823
- }
32824
- }
32825
- if (found.length < 2) continue;
32826
- for (const item of found) ctx.hit(rule, item.block, item.start, item.end, rule === labels ? `${found.length} coined labels in one piece. Each asks the reader to learn a term.` : `${found.length} "What X is" or "The problem is that" setups in one piece.`, rule === labels ? "Describe the thing in plain words instead of naming it." : "Start with the subject and say the thing directly.");
32827
- }
32828
- }
32829
- function boldLabels(ctx) {
32830
- const rule = STRUCTURE_RULES.boldLabels;
32831
- if (ctx.level(rule) === "off") return;
32832
- if (ctx.doc.format !== "md" && ctx.doc.format !== "mdx") return;
32833
- const lists = ctx.blocks(["list"]);
32834
- let run = [];
32835
- const report = () => {
32836
- if (run.length >= 3) {
32837
- const first = run[0];
32838
- ctx.hit(rule, first, 0, Math.min(first.text.length, 60), `${run.length} list items in a row open with a bold label.`, "Drop the bold labels and write each item as one plain sentence, or use a table if the items really are parallel.");
32839
- }
32840
- run = [];
32841
- };
32842
- let previous = null;
32843
- for (const block of lists) {
32844
- const offset = block.map[0] ?? 0;
32845
- const line = ctx.doc.source.lastIndexOf("\n", offset) + 1;
32846
- const raw = ctx.doc.source.slice(line, offset + 4);
32847
- const bold = /^\s*(?:[-*+]|\d{1,9}[.)])\s+(?:\*\*|__)/.test(raw);
32848
- const adjacent = previous !== null && ctx.doc.blocks.indexOf(block) === ctx.doc.blocks.indexOf(previous) + 1;
32849
- if (!bold || !adjacent) report();
32850
- if (bold) run.push(block);
32851
- previous = block;
32852
- }
32853
- report();
32854
- }
32855
- function boldEmphasis(ctx) {
32856
- const rule = STRUCTURE_RULES.boldEmphasis;
32857
- if (ctx.level(rule) === "off") return;
32858
- const markdown = ctx.doc.format === "md" || ctx.doc.format === "mdx";
32859
- const re = markdown ? /(\*\*|__)(?=\S)[^*_\n]+?\1/g : /<(strong|b)\b[^>]*>[^<]{1,200}<\/\1>/gi;
32860
- const prose = ctx.blocks([
32861
- "paragraph",
32862
- "list",
32863
- "quote",
32864
- "prop"
32865
- ]);
32866
- const spans = [];
32867
- for (const found of ctx.doc.source.matchAll(re)) {
32868
- const open = markdown ? 2 : found[0].indexOf(">") + 1;
32869
- const from = (found.index ?? 0) + open;
32870
- const to = (found.index ?? 0) + found[0].length - (markdown ? 2 : found[0].length - found[0].lastIndexOf("<"));
32871
- for (const block of prose) {
32872
- const first = block.map[0] ?? 0;
32873
- const last = block.map[block.map.length - 1] ?? 0;
32874
- if (from < first || from > last) continue;
32875
- const start = block.map.indexOf(from);
32876
- if (start <= 0 && block.kind === "list") break;
32877
- if (start < 0) break;
32878
- let end = start;
32879
- while (end < block.map.length && (block.map[end] ?? 0) < to) end++;
32880
- spans.push({
32881
- block,
32882
- start,
32883
- end
32884
- });
32885
- break;
32886
- }
32887
- }
32888
- if (spans.length < 3 || spans.length * 100 <= ctx.proseWords) return;
32889
- for (const span of spans) ctx.hit(rule, span.block, span.start, span.end, `${spans.length} bold phrases in ${ctx.proseWords.toLocaleString("en-US")} words of prose. Bold this often stops meaning "important".`, "Remove the bold here. Keep bold, if any, for the one thing a skimming reader must not miss.");
32890
- }
32955
+ // packages/core/src/lint/rules-structure.ts
32956
+ const STRUCTURE_RULES = {
32957
+ negativeParallelism: CONTRAST_RULES.negativeParallelism,
32958
+ contrastReframe: CONTRAST_RULES.contrastReframe,
32959
+ heresAnnouncement: RHYTHM_RULES.heresAnnouncement,
32960
+ pithyFragment: RHYTHM_RULES.pithyFragment,
32961
+ stockCloser: RHYTHM_RULES.stockCloser,
32962
+ negativeReframe: RHYTHM_RULES.negativeReframe,
32963
+ figurativeWorth: RHYTHM_RULES.figurativeWorth,
32964
+ anaphora: RHYTHM_RULES.anaphora,
32965
+ vocabularyCluster: COUNTED_RULES.vocabularyCluster,
32966
+ triad: COUNTED_RULES.triad,
32967
+ inventedLabel: COUNTED_RULES.inventedLabel,
32968
+ colonDensity: COUNTED_RULES.colonDensity,
32969
+ pseudoCleft: COUNTED_RULES.pseudoCleft,
32970
+ boldEmphasis: BOLD_RULES.boldEmphasis,
32971
+ boldLabels: BOLD_RULES.boldLabels
32972
+ };
32891
32973
  function runStructureRules(ctx) {
32892
32974
  negativeParallelism(ctx);
32893
32975
  contrastReframe(ctx);
@@ -32900,6 +32982,7 @@ function runStructureRules(ctx) {
32900
32982
  vocabularyCluster(ctx);
32901
32983
  triads(ctx);
32902
32984
  countedPatterns(ctx);
32985
+ colonDensity(ctx);
32903
32986
  boldLabels(ctx);
32904
32987
  boldEmphasis(ctx);
32905
32988
  }
@@ -35143,7 +35226,7 @@ async function analyticsBeside(access, site, range, before, pages) {
35143
35226
  }
35144
35227
  // packages/core/src/commands/audit.ts
35145
35228
  const AUDIT_SECTION = "weekly-audit";
35146
- const AUDIT_SECTION_TEXT = "What the weekly crawl of the site found (broken and redirected internal links, missing, empty or duplicate titles and descriptions, missing H1s, noindex for Google, canonicals to another page, sitemap URLs that do not return 200, thin pages, tags that JavaScript changes), with what is new, back or resolved since the crawl before. Only for sites added to the weekly site audit beta.";
35229
+ const AUDIT_SECTION_TEXT = "What the weekly crawl of the site found (broken and redirected internal links, missing, empty or duplicate titles and descriptions, missing H1s, noindex for Google, canonicals to another page, sitemap URLs that do not return 200, thin pages, tags that JavaScript changes), with what is new, back or resolved since the crawl before. Only for sites in the weekly site audit.";
35147
35230
  const AUDIT_RULES = {
35148
35231
  link_to_error: "Internal links to a page that returns an error",
35149
35232
  link_to_redirect: "Internal links to a redirect",
@@ -39232,11 +39315,11 @@ async function runAllSites(deps, sites) {
39232
39315
  if (!data && sites) {
39233
39316
  const list = await sites();
39234
39317
  return {
39235
- text: `No site given. Pick one below and send it: ${deps.call("report", { site: "<site>" })}. The summary of every site is for accounts in the weekly site audit beta.\n\n${list.text}`,
39318
+ text: `No site given. Pick one below and send it: ${deps.call("report", { site: "<site>" })}. The summary of every site is for accounts with the weekly site audit.\n\n${list.text}`,
39236
39319
  data: list.data
39237
39320
  };
39238
39321
  }
39239
- if (!data) throw new CommandError("INVALID_INPUT", `No site given. Name one: ${deps.call("report", { site: "<site>" })}. The summary of every site is for accounts in the weekly site audit beta.`);
39322
+ if (!data) throw new CommandError("INVALID_INPUT", `No site given. Name one: ${deps.call("report", { site: "<site>" })}. The summary of every site is for accounts with the weekly site audit.`);
39240
39323
  const startMs = Date.parse(`${data.start}T00:00:00Z`);
39241
39324
  const endMs = Date.parse(`${data.end}T00:00:00Z`) + DAY_MS;
39242
39325
  const urgency = (site) => issues(site, startMs, endMs)[0]?.rank ?? Number.POSITIVE_INFINITY;
@@ -39331,9 +39414,9 @@ const SHARED_TOOLS = [
39331
39414
  name: "seo_report",
39332
39415
  command: "report",
39333
39416
  title: "Search Console report",
39334
- description: `Start here. Without site: a short summary of every site in the person's weekly site audit (beta) for last week, with each site's Google index, weekly crawl and search clicks, sites with changes first, ending with the site to ask about next; an account outside that beta gets its site list to pick from. With site: the main report for that Search Console property, the overview plus each section's row count and top rows. With site and section: that section's rows; page sections also check their top 20 URLs live. Sections:\n${Object.entries(SECTIONS).map(([id, text]) => `- ${id}: ${text}`).join("\n")}\n- ${ISSUES_SECTION}: ${ISSUES_SECTION_TEXT}\n- ${UPDATES_SECTION}: ${UPDATES_SECTION_TEXT}\nWith site, mark and issues: records what the person decided about those issue ids (fixed, ignored, or open to undo) and runs no checks.`,
39417
+ description: `Start here. Without site: a short summary of every site in the person's weekly site audit for last week, with each site's Google index, weekly crawl and search clicks, sites with changes first, ending with the site to ask about next; an account without the audit gets its site list to pick from. With site: the main report for that Search Console property, the overview plus each section's row count and top rows. With site and section: that section's rows; page sections also check their top 20 URLs live. Sections:\n${Object.entries(SECTIONS).map(([id, text]) => `- ${id}: ${text}`).join("\n")}\n- ${ISSUES_SECTION}: ${ISSUES_SECTION_TEXT}\n- ${UPDATES_SECTION}: ${UPDATES_SECTION_TEXT}\nWith site, mark and issues: records what the person decided about those issue ids (fixed, ignored, or open to undo) and runs no checks.`,
39335
39418
  input: z.object({
39336
- site: site.optional().describe("Leave it out for the summary of every audited site (weekly site audit beta). Otherwise a Search Console property or site, such as sc-domain:example.com, https://example.com/ or example.com."),
39419
+ site: site.optional().describe("Leave it out for the summary of every site in the weekly site audit. Otherwise a Search Console property or site, such as sc-domain:example.com, https://example.com/ or example.com."),
39337
39420
  section: z.enum([
39338
39421
  ...SECTION_IDS,
39339
39422
  ISSUES_SECTION,
@@ -39582,7 +39665,7 @@ function indexFromStore(shared) {
39582
39665
  const paged = "detail" in shared.input.shape;
39583
39666
  return {
39584
39667
  ...shared,
39585
- description: `${shared.description} For a site in the weekly site audit beta it answers at once from the URL Inspection results this server keeps for the site, checked in the background each day, and says how many URLs are covered, how many are queued and the time left.`,
39668
+ description: `${shared.description} For a site in the weekly site audit it answers at once from the URL Inspection results this server keeps for the site, checked in the background each day, and says how many URLs are covered, how many are queued and the time left.`,
39586
39669
  run: async (surface, parsed) => {
39587
39670
  const input = parsed;
39588
39671
  const audit = surface.deps.audit;