seo 0.17.5 → 0.17.7

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/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { i as __toESM, n as version, r as __commonJSMin, t as load } from "./esm-lrKCsK_C.js";
2
+ import { i as __toESM, n as version, r as __commonJSMin, t as load } from "./esm-D2vwEHEA.js";
3
3
  import { createHash, randomUUID, sign } from "node:crypto";
4
4
  import { ZodOptional, z } from "zod";
5
5
  import { arch, homedir, platform, tmpdir, totalmem } from "node:os";
@@ -22024,7 +22024,7 @@ const QUERY_FLAG_METHOD = {
22024
22024
  heuristic: true,
22025
22025
  ranking: "flagged_rows_after_unflagged_rows",
22026
22026
  flags: {
22027
- "likely-automated": "Snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.",
22027
+ "likely-automated": "A numbered prefix such as \"12264: \", snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.",
22028
22028
  "navigational-other": "Names a domain that is not the property's host, ends with a spoken domain suffix or a login/site/app word, starts with a large platform name and adds no topic word, or is one short ASCII word that is not a brand term. Such queries usually look for another site."
22029
22029
  }
22030
22030
  };
@@ -22088,8 +22088,10 @@ const FUNCTION_WORDS$1 = /* @__PURE__ */ new Set([
22088
22088
  "und"
22089
22089
  ]);
22090
22090
  const IDENTIFIER_TOKEN = /[\p{L}\p{N}]_[\p{L}\p{N}]/u;
22091
+ const NUMBERED_PREFIX = /^\d{4,}:\s+\S/u;
22091
22092
  /** Heuristic: the query looks machine-generated rather than typed by a person. */
22092
22093
  function isLikelyAutomatedQuery(query) {
22094
+ if (NUMBERED_PREFIX.test(query.trim())) return true;
22093
22095
  if (query.trim().split(/\s+/).filter(Boolean).some((token) => IDENTIFIER_TOKEN.test(token))) return true;
22094
22096
  const tokens = tokenize(query);
22095
22097
  if (tokens.length >= 20) return true;
@@ -33358,6 +33360,7 @@ function selectRows(input) {
33358
33360
  belowMinimumRows: 0,
33359
33361
  lowActionabilityRows: 0,
33360
33362
  brandRows: 0,
33363
+ sitelinkRows: 0,
33361
33364
  eligibleRows: 0,
33362
33365
  likelyAutomatedRows: 0,
33363
33366
  navigationalOtherRows: 0,
@@ -33378,16 +33381,23 @@ function selectRows(input) {
33378
33381
  brandTerms: input.brandTerms,
33379
33382
  includeBrand: input.includeBrand
33380
33383
  })) selection.brandRows++;
33381
- else {
33382
- rows.push(row);
33383
- selection.eligibleRows++;
33384
- }
33384
+ else rows.push(row);
33385
33385
  }
33386
+ const kept = withoutSitelinkRows(rows);
33387
+ selection.sitelinkRows = rows.length - kept.length;
33388
+ selection.eligibleRows = kept.length;
33386
33389
  return {
33387
- rows,
33390
+ rows: kept,
33388
33391
  selection
33389
33392
  };
33390
33393
  }
33394
+ const SITELINK_MINIMUM_PAGES = 3;
33395
+ function withoutSitelinkRows(rows) {
33396
+ const counts = /* @__PURE__ */ new Map();
33397
+ const key = (row) => `${row.keys[0]?.trim()}\n${row.impressions}\n${row.position}`;
33398
+ for (const row of rows) counts.set(key(row), (counts.get(key(row)) ?? 0) + 1);
33399
+ return rows.filter((row) => (counts.get(key(row)) ?? 0) < SITELINK_MINIMUM_PAGES);
33400
+ }
33391
33401
  function analyzeStrikingDistanceRows(input) {
33392
33402
  const collapsed = collapseFragmentPageRows(input.rows, { pageKeyIndex: 1 });
33393
33403
  const minImpressionsPolicy = resolveMinImpressionsPolicy({
@@ -33462,6 +33472,7 @@ function analyzeStrikingDistanceRows(input) {
33462
33472
  "minimum_impressions",
33463
33473
  "query_quality",
33464
33474
  "brand",
33475
+ "sitelinks",
33465
33476
  "query_flag_ranking"
33466
33477
  ],
33467
33478
  selection: selected.selection
@@ -33625,6 +33636,7 @@ async function strikingDistanceWith(input, dependencies) {
33625
33636
  `Brand queries: ${analysis.brand.filtering}. Brand terms used: ${analysis.brand.terms.join(", ") || "none"} (${analysis.brand.source === "provided" ? "provided" : "host forms, plus the bare domain stem only when Search Console shows the site is its navigational answer"}).`,
33626
33637
  analysis.selection.fragmentRows ? `${countLabel(analysis.selection.fragmentRows, "source row")} with a #fragment URL merged into the base URL.` : "",
33627
33638
  analysis.selection.flaggedRows ? `${countLabel(analysis.selection.flaggedRows, "eligible row")} carry heuristic query flags (likely-automated or navigational-other) and rank after unflagged rows.` : "",
33639
+ analysis.selection.sitelinkRows ? `${countLabel(analysis.selection.sitelinkRows, "row")} left out as sitelinks: three or more pages for the same query with the same impressions and average position, which is one result shown with its sitelinks. A heuristic.` : "",
33628
33640
  "Position is GSC average position for the property's topmost result per impression; it does not prove a URL ranked on a literal second results page every time.",
33629
33641
  "Search Analytics exposes retained query rows only. Anonymized and lower-value queries can be absent even when pagination is exhausted.",
33630
33642
  "Priority is a demand-and-position heuristic, not an estimated click lift or proof that a change will improve rankings.",
@@ -44060,6 +44072,59 @@ const DIMENSIONS = [
44060
44072
  "device",
44061
44073
  "searchAppearance"
44062
44074
  ];
44075
+ const REGEX_MAX_CHARS = 4096;
44076
+ const QUERY_PRESETS = {
44077
+ questions: "^(who|what|where|when|why|how|is|are|can|does|do|should)\\b",
44078
+ long_tail: "^(\\S+\\s+){7,}\\S+$",
44079
+ comparisons: "\\b(vs|versus|alternatives?)\\b"
44080
+ };
44081
+ const QUERY_PRESET_NAMES = Object.keys(QUERY_PRESETS);
44082
+ function rowTextFilters(input) {
44083
+ return [
44084
+ [
44085
+ "page",
44086
+ "contains",
44087
+ input.page
44088
+ ],
44089
+ [
44090
+ "query",
44091
+ "contains",
44092
+ input.query
44093
+ ],
44094
+ [
44095
+ "page",
44096
+ "includingRegex",
44097
+ input.pageRegex
44098
+ ],
44099
+ [
44100
+ "query",
44101
+ "includingRegex",
44102
+ input.queryRegex
44103
+ ],
44104
+ [
44105
+ "query",
44106
+ "includingRegex",
44107
+ input.queryPreset && QUERY_PRESETS[input.queryPreset]
44108
+ ],
44109
+ [
44110
+ "query",
44111
+ "excludingRegex",
44112
+ input.excludeQueryRegex
44113
+ ]
44114
+ ].flatMap(([dimension, operator, expression]) => {
44115
+ if (!expression) return [];
44116
+ if (operator !== "contains") checkRegex(expression);
44117
+ return [{
44118
+ dimension,
44119
+ operator,
44120
+ expression
44121
+ }];
44122
+ });
44123
+ }
44124
+ function checkRegex(expression) {
44125
+ if (expression.length > 4096) throw new SeoError("INVALID_INPUT", `Search Console takes regular expressions of at most ${REGEX_MAX_CHARS} characters.`);
44126
+ if (/\(\?<?[=!]|\\[1-9]/.test(expression)) throw new SeoError("INVALID_INPUT", `Search Console uses RE2, which has no lookarounds such as (?=...) or (?!...) and no backreferences such as \\1. Use an exclude filter instead of a negative lookahead: ${expression}`);
44127
+ }
44063
44128
  const ROWS$1 = 25e3;
44064
44129
  async function runRows(input, deps) {
44065
44130
  const dimensions = input.dimensions?.length ? input.dimensions : ["query"];
@@ -49491,13 +49556,17 @@ const SHARED_TOOLS = [
49491
49556
  name: "seo_data",
49492
49557
  command: "data",
49493
49558
  title: "Raw rows",
49494
- description: `Raw rows for questions the report does not answer. search_console (default): rows for any dimensions, each with the previous period and the change; page and query narrow to rows whose URL or query contains that text. google_analytics: landing pages for visits from search, with Google Analytics’ own metric names. bing: Bing Webmaster query or page rows (first dimension) for the same site, by week. clicky: landing-page visits, traffic sources and search engines from a Clicky site the person saved (site is its domain or Clicky site ID; at most 31 days).`,
49559
+ description: `Raw rows for questions the report does not answer. search_console (default): rows for any dimensions, each with the previous period and the change; page and query narrow to rows whose URL or query contains that text; query_preset picks questions, long_tail (8+ words) or comparisons; *_regex take RE2 (no lookarounds). google_analytics: landing pages for visits from search, with Google Analytics’ own metric names. bing: Bing Webmaster query or page rows (first dimension) for the same site, by week. clicky: landing-page visits, traffic sources and search engines from a Clicky site the person saved (site is its domain or Clicky site ID; at most 31 days).`,
49495
49560
  input: z.object({
49496
49561
  source: z.enum(DATA_SOURCES).default("search_console"),
49497
49562
  site: z.string().min(1).describe("search_console and bing: the property or site. google_analytics: numeric property id from seo_sites. clicky: the site or its Clicky site ID."),
49498
49563
  dimensions: z.array(z.enum(DIMENSIONS)).max(4).default(["query"]).describe("search_console; bing uses the first, query or page."),
49499
49564
  page: z.string().min(1).optional().describe("search_console only: URL text, such as /blog/."),
49500
49565
  query: z.string().min(1).optional().describe("search_console only: query text."),
49566
+ query_preset: z.enum(QUERY_PRESET_NAMES).optional(),
49567
+ page_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the page URL must match."),
49568
+ query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the query must match."),
49569
+ exclude_query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 for queries to leave out, such as the brand."),
49501
49570
  ...dates,
49502
49571
  ...detail
49503
49572
  }),
@@ -49534,15 +49603,14 @@ const SHARED_TOOLS = [
49534
49603
  return runRows({
49535
49604
  site: await surface.resolveSite(input.site),
49536
49605
  dimensions: input.dimensions,
49537
- filters: [...input.page ? [{
49538
- dimension: "page",
49539
- operator: "contains",
49540
- expression: input.page
49541
- }] : [], ...input.query ? [{
49542
- dimension: "query",
49543
- operator: "contains",
49544
- expression: input.query
49545
- }] : []],
49606
+ filters: rowTextFilters({
49607
+ page: input.page,
49608
+ query: input.query,
49609
+ pageRegex: input.page_regex,
49610
+ queryRegex: input.query_regex,
49611
+ queryPreset: input.query_preset,
49612
+ excludeQueryRegex: input.exclude_query_regex
49613
+ }),
49546
49614
  startDate: input.start_date,
49547
49615
  endDate: input.end_date,
49548
49616
  detail: input.detail,