seo 0.17.7 → 0.17.9
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/PRIVACY.md +12 -3
- package/README.md +2 -2
- package/TERMS.md +1 -1
- package/dist/cli.js +90 -89
- package/dist/cli.js.map +1 -1
- package/dist/{dist--XpKpLek.js → dist-DiyyBCYL.js} +106 -106
- package/dist/dist-DiyyBCYL.js.map +1 -0
- package/dist/{dist-CeZ3yzNP.js → dist-DzcRsuc4.js} +1 -1
- package/dist/{esm-D2vwEHEA.js → esm-BByR3SEY.js} +2 -2
- package/dist/{esm-D2vwEHEA.js.map → esm-BByR3SEY.js.map} +1 -1
- package/dist/index.d.ts +69 -42
- package/dist/index.js +900 -296
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +895 -297
- package/dist/mcp.js.map +1 -1
- package/package.json +3 -3
- package/skills/seo/SKILL.md +5 -5
- package/dist/dist--XpKpLek.js.map +0 -1
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-
|
|
2
|
+
import { i as __toESM, n as version, r as __commonJSMin, t as load } from "./esm-BByR3SEY.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";
|
|
@@ -13844,7 +13844,7 @@ function bearerFetch(token) {
|
|
|
13844
13844
|
}
|
|
13845
13845
|
});
|
|
13846
13846
|
}
|
|
13847
|
-
async function failure(response, label, subject, options) {
|
|
13847
|
+
async function failure$1(response, label, subject, options) {
|
|
13848
13848
|
const detail = (await response.text().catch(() => "")).slice(0, 300);
|
|
13849
13849
|
const status = response.status;
|
|
13850
13850
|
const what = subject ? `${label} for ${subject}` : label;
|
|
@@ -13868,7 +13868,7 @@ async function googleJson(gfetch, url, input) {
|
|
|
13868
13868
|
body: input.body === void 0 ? void 0 : JSON.stringify(input.body),
|
|
13869
13869
|
signal
|
|
13870
13870
|
});
|
|
13871
|
-
if (!response.ok) throw await failure(response, input.label, input.subject, input);
|
|
13871
|
+
if (!response.ok) throw await failure$1(response, input.label, input.subject, input);
|
|
13872
13872
|
return readJson(response, input.label, { maxBytes: input.maxBytes });
|
|
13873
13873
|
});
|
|
13874
13874
|
}
|
|
@@ -13961,7 +13961,7 @@ async function runAnalyticsReport(gfetch, propertyId, body, options) {
|
|
|
13961
13961
|
}
|
|
13962
13962
|
// packages/core/dist/bing/api.js
|
|
13963
13963
|
const BASE = "https://ssl.bing.com/webmaster/api.svc/json";
|
|
13964
|
-
const MAX_BYTES$
|
|
13964
|
+
const MAX_BYTES$6 = 8e6;
|
|
13965
13965
|
function bingCall(auth, options) {
|
|
13966
13966
|
return async (method, params = {}) => {
|
|
13967
13967
|
const url = new URL(`${BASE}/${method}`);
|
|
@@ -13986,7 +13986,7 @@ function bingCall(auth, options) {
|
|
|
13986
13986
|
if (response.status === 429 || /throttle/i.test(detail)) throw new SeoError("RATE_LIMITED", "Bing Webmaster is limiting requests. Try again in a few minutes.");
|
|
13987
13987
|
throw new SeoError("OPTIONAL_PROVIDER_UNAVAILABLE", `Bing Webmaster answered ${response.status}. ${detail}`.trim());
|
|
13988
13988
|
}
|
|
13989
|
-
return (await readJson(response, "Bing Webmaster", { maxBytes: MAX_BYTES$
|
|
13989
|
+
return (await readJson(response, "Bing Webmaster", { maxBytes: MAX_BYTES$6 })).d;
|
|
13990
13990
|
};
|
|
13991
13991
|
}
|
|
13992
13992
|
function day$3(value) {
|
|
@@ -14688,6 +14688,7 @@ const ID_COLUMNS = [
|
|
|
14688
14688
|
"changeDate",
|
|
14689
14689
|
"query",
|
|
14690
14690
|
"queryFlags",
|
|
14691
|
+
"shape",
|
|
14691
14692
|
"keyword",
|
|
14692
14693
|
"url",
|
|
14693
14694
|
"page",
|
|
@@ -14980,6 +14981,7 @@ async function runSites(input) {
|
|
|
14980
14981
|
input.bing === void 0 ? null : bing === null ? "Bing Webmaster: not connected." : bing instanceof Error ? `Bing Webmaster: could not list sites. ${bing.message}` : bingOnly.length ? `Bing Webmaster sites with no Search Console property here (${bingOnly.length}): ${bingOnly.map((site) => site.url).join(", ")}.` : `Bing Webmaster: ${bingSites.length} verified sites; the bing column shows each one.`,
|
|
14981
14982
|
`Research keys: ${research.length ? research.join(", ") : "none"}.`,
|
|
14982
14983
|
input.clicky?.length ? `Clicky sites (seo_data with source "clicky"): ${input.clicky.join(", ")}.` : null,
|
|
14984
|
+
input.simpleAnalytics ? "Simple Analytics: API key saved; seo_data with source \"simple_analytics\" and the site's domain." : null,
|
|
14983
14985
|
`Add a Google account${input.bing === void 0 ? "" : ", Bing"} or a key: ${input.connect}`,
|
|
14984
14986
|
"Next: seo_report with a site."
|
|
14985
14987
|
].filter(Boolean).join("\n\n"),
|
|
@@ -14988,7 +14990,8 @@ async function runSites(input) {
|
|
|
14988
14990
|
googleAnalytics: analytics,
|
|
14989
14991
|
bing: Array.isArray(bing) ? bingSites : null,
|
|
14990
14992
|
research,
|
|
14991
|
-
clicky: input.clicky ?? []
|
|
14993
|
+
clicky: input.clicky ?? [],
|
|
14994
|
+
simpleAnalytics: Boolean(input.simpleAnalytics)
|
|
14992
14995
|
}
|
|
14993
14996
|
};
|
|
14994
14997
|
}
|
|
@@ -22713,10 +22716,251 @@ async function pageOpportunitiesReport(input, dependencies = defaultDependencies
|
|
|
22713
22716
|
recommendations: pageOpportunityRecommendations(analysis)
|
|
22714
22717
|
};
|
|
22715
22718
|
}
|
|
22719
|
+
// packages/core/dist/analyze/ai-queries.js
|
|
22720
|
+
const RULES = [
|
|
22721
|
+
["agent_prompt", "^(search the web for|browse the web|find sources)|do not invent|return the [0-9]+ most relevant|include source urls|context: location|do not include location|question: |reply only with|the model you are using"],
|
|
22722
|
+
["tracker", "\\. ?my location is |\\?\\. ?my( |$)|^evaluate the .+ on "],
|
|
22723
|
+
["reply", "^(yes|yeah|yep|ok|okay|sure|yes please|go on|continue|keep going|tell me more|why not|how so|really|exactly|show me|and then|thanks|thank you|got it|what else|anything else)[?!.,]*$"],
|
|
22724
|
+
["follow_up", "^(what|how) about .{1,40}$|^(and|so|ok so|okay so|but) (what|which|how|why) "],
|
|
22725
|
+
["operator", "(^|\\s)-?(site|before|after|intitle|inurl|intext|filetype):|\"[^\"]*\" or \""],
|
|
22726
|
+
["chat", "\\b(please|can you|could you|give me|show me|tell me|i want|i need|i have|i am|should i|do i need|is it worth|help me|walk me through)\\b|^(what|how|why|is|does|can|will|would) (it|that|this|they)\\b"],
|
|
22727
|
+
["long", "^(\\S+\\s+){9,}\\S+$"]
|
|
22728
|
+
];
|
|
22729
|
+
const AI_QUERY_KINDS = {
|
|
22730
|
+
agent_prompt: "text from an agent prompt, such as \"search the web for\"",
|
|
22731
|
+
tracker: "a visibility-tool probe, such as \"my location is\"",
|
|
22732
|
+
reply: "a bare reply, such as \"yes\" or \"tell me more\"",
|
|
22733
|
+
follow_up: "a follow-up, such as \"what about …\"",
|
|
22734
|
+
operator: "search operators, such as site:, before: or \"a\" or \"b\"",
|
|
22735
|
+
chat: "chat phrasing, such as \"can you\" or \"should i\"",
|
|
22736
|
+
long: "ten or more words with no other sign"
|
|
22737
|
+
};
|
|
22738
|
+
const MATCHERS = RULES.map(([kind, pattern]) => [kind, new RegExp(pattern)]);
|
|
22739
|
+
const AI_QUERY_PATTERN = RULES.map(([, pattern]) => `(?:${pattern})`).join("|");
|
|
22740
|
+
const NOISE = [
|
|
22741
|
+
["spaced_letters", /(^|\s)(\S\s){3,}\S(\s|$)/u],
|
|
22742
|
+
["broken_encoding", /^(яю|ÿþ|þÿ)|&#[0-9]+;?|&[a-z]+;|[âÃÂ][\u0080-\u00bf€™œ“”]|\ufffd/u],
|
|
22743
|
+
["pasted_text", /^(p [a-z]{3,} |here (are|is) (all )?the |here's the |done[,.!]? (you|here) |current state: )/u]
|
|
22744
|
+
];
|
|
22745
|
+
function aiQueryNoise(query) {
|
|
22746
|
+
const text = query.trim().toLowerCase();
|
|
22747
|
+
return NOISE.find(([, pattern]) => pattern.test(text))?.[0] ?? null;
|
|
22748
|
+
}
|
|
22749
|
+
const QUESTION = /^(how|what|what's|whats|which|why|when|where|who|is|are|can|could|does|do|should|would|will|i need|i want|i have|i'm looking|we need|we want)\b|\?$/u;
|
|
22750
|
+
const ASKABLE_KINDS = /* @__PURE__ */ new Set(["chat", "long"]);
|
|
22751
|
+
const PROMPT_CHARACTERS = 500;
|
|
22752
|
+
function askable(query, kind) {
|
|
22753
|
+
const text = query.trim().toLowerCase().replace(/^["'“]+/u, "");
|
|
22754
|
+
return Boolean(kind && ASKABLE_KINDS.has(kind)) && text.length <= PROMPT_CHARACTERS && QUESTION.test(text);
|
|
22755
|
+
}
|
|
22756
|
+
function aiQueryKind(query) {
|
|
22757
|
+
const text = query.trim().toLowerCase();
|
|
22758
|
+
return MATCHERS.find(([, pattern]) => pattern.test(text))?.[0] ?? null;
|
|
22759
|
+
}
|
|
22760
|
+
const STOP = new Set("the and for with that this what which who how why when where are is was can does do did you your our from about into than then them they their there have has had will would should could not but its it’s me my i am of to in on at by or an as be if so".split(" "));
|
|
22761
|
+
function words$3(query) {
|
|
22762
|
+
return new Set(query.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((word) => word.length >= 3 && !STOP.has(word)).map((word) => word.length > 4 && word.endsWith("s") ? word.slice(0, -1) : word));
|
|
22763
|
+
}
|
|
22764
|
+
const SAME_QUESTION = .6;
|
|
22765
|
+
const MAX_ROWS = 25e3;
|
|
22766
|
+
const EXAMPLES = 3;
|
|
22767
|
+
const CANDIDATES = 200;
|
|
22768
|
+
const overlap = (a, b, weight) => {
|
|
22769
|
+
let shared = 0;
|
|
22770
|
+
let union = 0;
|
|
22771
|
+
for (const word of a) {
|
|
22772
|
+
union += weight(word);
|
|
22773
|
+
if (b.has(word)) shared += weight(word);
|
|
22774
|
+
}
|
|
22775
|
+
for (const word of b) if (!a.has(word)) union += weight(word);
|
|
22776
|
+
return union ? shared / union : 0;
|
|
22777
|
+
};
|
|
22778
|
+
const round$2 = (value, places) => Math.round(value * 10 ** places) / 10 ** places;
|
|
22779
|
+
async function aiQueriesReport(input, searchAnalytics) {
|
|
22780
|
+
const range = {
|
|
22781
|
+
startDate: input.startDate,
|
|
22782
|
+
endDate: input.endDate
|
|
22783
|
+
};
|
|
22784
|
+
const [matched, site] = await Promise.all([searchAnalytics(input.site, {
|
|
22785
|
+
...range,
|
|
22786
|
+
dimensions: ["query", "page"],
|
|
22787
|
+
type: "web",
|
|
22788
|
+
dataState: "final",
|
|
22789
|
+
maxRows: MAX_ROWS,
|
|
22790
|
+
dimensionFilterGroups: [{ filters: [{
|
|
22791
|
+
dimension: "query",
|
|
22792
|
+
operator: "includingRegex",
|
|
22793
|
+
expression: AI_QUERY_PATTERN
|
|
22794
|
+
}] }]
|
|
22795
|
+
}), searchAnalytics(input.site, {
|
|
22796
|
+
...range,
|
|
22797
|
+
dimensions: [],
|
|
22798
|
+
type: "web",
|
|
22799
|
+
dataState: "final"
|
|
22800
|
+
})]);
|
|
22801
|
+
const rows = [...matched.rows].sort((a, b) => b.impressions - a.impressions || String(a.keys[0]).localeCompare(String(b.keys[0])) || String(a.keys[1]).localeCompare(String(b.keys[1])));
|
|
22802
|
+
const usage = /* @__PURE__ */ new Map();
|
|
22803
|
+
const unique = new Set(rows.map((row) => String(row.keys[0] ?? "")));
|
|
22804
|
+
for (const query of unique) for (const word of words$3(query)) usage.set(word, (usage.get(word) ?? 0) + 1);
|
|
22805
|
+
const weight = (word) => Math.log((unique.size + 1) / (usage.get(word) ?? 1));
|
|
22806
|
+
const groups = [];
|
|
22807
|
+
const byWord = /* @__PURE__ */ new Map();
|
|
22808
|
+
const byText = /* @__PURE__ */ new Map();
|
|
22809
|
+
const kindOf = /* @__PURE__ */ new Map();
|
|
22810
|
+
const noise = /* @__PURE__ */ new Map();
|
|
22811
|
+
for (const row of rows) {
|
|
22812
|
+
const query = String(row.keys[0] ?? "");
|
|
22813
|
+
const page = String(row.keys[1] ?? "");
|
|
22814
|
+
const kind = aiQueryKind(query);
|
|
22815
|
+
if (!kind) continue;
|
|
22816
|
+
const junk = aiQueryNoise(query);
|
|
22817
|
+
if (junk) {
|
|
22818
|
+
const seen = noise.get(junk) ?? /* @__PURE__ */ new Set();
|
|
22819
|
+
seen.add(query.trim().toLowerCase());
|
|
22820
|
+
noise.set(junk, seen);
|
|
22821
|
+
continue;
|
|
22822
|
+
}
|
|
22823
|
+
const text = query.trim().toLowerCase();
|
|
22824
|
+
const own = words$3(query);
|
|
22825
|
+
let group = byText.get(text);
|
|
22826
|
+
if (!group) {
|
|
22827
|
+
let checked = 0;
|
|
22828
|
+
for (const word of own) {
|
|
22829
|
+
for (const candidate of byWord.get(word) ?? []) {
|
|
22830
|
+
if (++checked > CANDIDATES) break;
|
|
22831
|
+
if (overlap(own, candidate.words, weight) >= SAME_QUESTION) {
|
|
22832
|
+
group = candidate;
|
|
22833
|
+
break;
|
|
22834
|
+
}
|
|
22835
|
+
}
|
|
22836
|
+
if (group || checked > CANDIDATES) break;
|
|
22837
|
+
}
|
|
22838
|
+
}
|
|
22839
|
+
if (!group) {
|
|
22840
|
+
group = {
|
|
22841
|
+
words: own,
|
|
22842
|
+
queries: /* @__PURE__ */ new Map(),
|
|
22843
|
+
pages: /* @__PURE__ */ new Map(),
|
|
22844
|
+
kinds: /* @__PURE__ */ new Map(),
|
|
22845
|
+
clicks: 0,
|
|
22846
|
+
impressions: 0,
|
|
22847
|
+
positionWeight: 0
|
|
22848
|
+
};
|
|
22849
|
+
groups.push(group);
|
|
22850
|
+
for (const word of own) {
|
|
22851
|
+
const list = byWord.get(word) ?? [];
|
|
22852
|
+
list.push(group);
|
|
22853
|
+
byWord.set(word, list);
|
|
22854
|
+
}
|
|
22855
|
+
}
|
|
22856
|
+
byText.set(text, group);
|
|
22857
|
+
if (!kindOf.has(text)) {
|
|
22858
|
+
kindOf.set(text, kind);
|
|
22859
|
+
group.kinds.set(kind, (group.kinds.get(kind) ?? 0) + 1);
|
|
22860
|
+
}
|
|
22861
|
+
group.queries.set(query, (group.queries.get(query) ?? 0) + row.impressions);
|
|
22862
|
+
group.pages.set(page, (group.pages.get(page) ?? 0) + row.impressions);
|
|
22863
|
+
group.clicks += row.clicks;
|
|
22864
|
+
group.impressions += row.impressions;
|
|
22865
|
+
group.positionWeight += row.position * row.impressions;
|
|
22866
|
+
}
|
|
22867
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
22868
|
+
for (const kind of kindOf.values()) {
|
|
22869
|
+
const entry = byKind.get(kind) ?? {
|
|
22870
|
+
queries: 0,
|
|
22871
|
+
impressions: 0
|
|
22872
|
+
};
|
|
22873
|
+
entry.queries += 1;
|
|
22874
|
+
byKind.set(kind, entry);
|
|
22875
|
+
}
|
|
22876
|
+
for (const row of rows) {
|
|
22877
|
+
const kind = kindOf.get(String(row.keys[0] ?? "").trim().toLowerCase());
|
|
22878
|
+
const entry = kind && byKind.get(kind);
|
|
22879
|
+
if (entry) entry.impressions += row.impressions;
|
|
22880
|
+
}
|
|
22881
|
+
const queries = kindOf.size;
|
|
22882
|
+
const impressions = groups.reduce((sum, g) => sum + g.impressions, 0);
|
|
22883
|
+
const clicks = groups.reduce((sum, g) => sum + g.clicks, 0);
|
|
22884
|
+
const total = site.rows[0] ?? {
|
|
22885
|
+
clicks: 0,
|
|
22886
|
+
impressions: 0
|
|
22887
|
+
};
|
|
22888
|
+
const items = groups.map((group) => {
|
|
22889
|
+
const most = (map) => [...map].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([name]) => name);
|
|
22890
|
+
const [first, ...rest] = most(group.queries);
|
|
22891
|
+
const kind = [...group.kinds].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0];
|
|
22892
|
+
return {
|
|
22893
|
+
query: first ?? "",
|
|
22894
|
+
page: most(group.pages)[0] ?? "",
|
|
22895
|
+
askable: askable(first ?? "", kind),
|
|
22896
|
+
pages: group.pages.size,
|
|
22897
|
+
kind,
|
|
22898
|
+
wordings: group.queries.size,
|
|
22899
|
+
impressions: group.impressions,
|
|
22900
|
+
clicks: group.clicks,
|
|
22901
|
+
ctr: group.impressions ? round$2(group.clicks / group.impressions, 4) : 0,
|
|
22902
|
+
position: group.impressions ? round$2(group.positionWeight / group.impressions, 1) : 0,
|
|
22903
|
+
otherWordings: rest.slice(0, EXAMPLES)
|
|
22904
|
+
};
|
|
22905
|
+
}).sort((a, b) => b.impressions - a.impressions || b.wordings - a.wordings || a.query.localeCompare(b.query) || a.page.localeCompare(b.page));
|
|
22906
|
+
const pct = (part, whole) => whole ? round$2(part / whole * 100, 1) : null;
|
|
22907
|
+
const kinds = [...byKind].sort((a, b) => b[1].impressions - a[1].impressions || a[0].localeCompare(b[0])).map(([kind, entry]) => `${kind} ${entry.queries}`).join(", ");
|
|
22908
|
+
const leftOut = [...noise].sort((a, b) => a[0].localeCompare(b[0])).map(([reason, seen]) => `${reason.replace("_", " ")} ${seen.size}`).join(", ");
|
|
22909
|
+
const asked = items.filter((item) => item.askable).length;
|
|
22910
|
+
const capped = matched.rowsFetched >= MAX_ROWS;
|
|
22911
|
+
return {
|
|
22912
|
+
range,
|
|
22913
|
+
verdict: queries ? `${queries} queries in ${groups.length} questions have the shape of AI conversations or agent searches.` : "No queries with the shape of AI conversations or agent searches.",
|
|
22914
|
+
summary: {
|
|
22915
|
+
queries,
|
|
22916
|
+
questions: groups.length,
|
|
22917
|
+
askable: asked,
|
|
22918
|
+
leftOut: leftOut || "none",
|
|
22919
|
+
impressions,
|
|
22920
|
+
clicks,
|
|
22921
|
+
shareOfImpressionsPct: pct(impressions, total.impressions),
|
|
22922
|
+
byKind: kinds || "none",
|
|
22923
|
+
ctr: impressions ? round$2(clicks / impressions, 4) : 0,
|
|
22924
|
+
siteCtr: total.impressions ? round$2(total.clicks / total.impressions, 4) : 0
|
|
22925
|
+
},
|
|
22926
|
+
kinds: AI_QUERY_KINDS,
|
|
22927
|
+
items,
|
|
22928
|
+
caveats: [
|
|
22929
|
+
"A heuristic: these queries match the patterns of AI conversations and agent searches. Search Console does not mark AI Mode or AI Overviews, and people type some of these too.",
|
|
22930
|
+
"A minimum: Search Console leaves out rare queries, and these are rare by nature.",
|
|
22931
|
+
"Rewordings of one question are grouped by their shared words; page is the page with the most impressions for it.",
|
|
22932
|
+
"Left out and counted, not shown: letters split by spaces, text broken by a wrong encoding, and text pasted from a tool or an agent’s output.",
|
|
22933
|
+
"askable: a chat or long question that opens with a question word or a request such as \"i need\", or ends with a question mark, so an AI engine can be asked it as it is. ai_answers checks the top askable questions only.",
|
|
22934
|
+
"Search Console’s Generative AI report is not in its API, so it is not here.",
|
|
22935
|
+
...capped ? [`Capped at the first ${MAX_ROWS} matching query and page rows.`] : []
|
|
22936
|
+
]
|
|
22937
|
+
};
|
|
22938
|
+
}
|
|
22939
|
+
// packages/core/dist/analyze/query-shape.js
|
|
22940
|
+
const COMPARISON = /\b(vs|versus|alternative|alternatives|compare|comparison|best)\b/;
|
|
22941
|
+
function queryShape(query) {
|
|
22942
|
+
const text = query.trim().toLowerCase();
|
|
22943
|
+
if (COMPARISON.test(text)) return "comparison";
|
|
22944
|
+
const kind = aiQueryKind(text);
|
|
22945
|
+
if (kind && kind !== "chat" && kind !== "long") return kind;
|
|
22946
|
+
if (QUESTION.test(text)) return "question";
|
|
22947
|
+
return kind;
|
|
22948
|
+
}
|
|
22949
|
+
function queryShapeLine(queries) {
|
|
22950
|
+
const counts = /* @__PURE__ */ new Map();
|
|
22951
|
+
for (const query of queries) {
|
|
22952
|
+
const shape = queryShape(query);
|
|
22953
|
+
if (shape) counts.set(shape, (counts.get(shape) ?? 0) + 1);
|
|
22954
|
+
}
|
|
22955
|
+
if (!counts.size) return null;
|
|
22956
|
+
const shaped = [...counts.values()].reduce((sum, n) => sum + n, 0);
|
|
22957
|
+
const parts = [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([shape, n]) => `${shape} ${n}`);
|
|
22958
|
+
return `Query shapes, ${shaped} of ${queries.length} queries: ${parts.join(", ")}.`;
|
|
22959
|
+
}
|
|
22716
22960
|
// packages/core/dist/analyze/content-optimization.js
|
|
22717
22961
|
function intentFor(query) {
|
|
22718
22962
|
const value = query.toLowerCase();
|
|
22719
|
-
if (
|
|
22963
|
+
if (COMPARISON.test(value)) return "comparison";
|
|
22720
22964
|
if (/\b(price|pricing|cost|buy|deal|coupon|review|reviews)\b/.test(value)) return "commercial";
|
|
22721
22965
|
if (/\b(how|steps|guide|tutorial|setup|fix|create|make)\b/.test(value)) return "how-to";
|
|
22722
22966
|
if (/\b(what is|meaning|definition|explained|why)\b/.test(value)) return "definition";
|
|
@@ -27403,7 +27647,8 @@ const PROVIDER_SECRET_NAMES = {
|
|
|
27403
27647
|
bingApiKey: "bing-api-key",
|
|
27404
27648
|
clickySiteKeys: "clicky-sitekeys",
|
|
27405
27649
|
dataForSeoCredentials: "dataforseo-credentials",
|
|
27406
|
-
providerExtensionCredentials: "provider-extension-credentials"
|
|
27650
|
+
providerExtensionCredentials: "provider-extension-credentials",
|
|
27651
|
+
simpleAnalyticsKey: "simple-analytics-key"
|
|
27407
27652
|
};
|
|
27408
27653
|
const REMOVED_PROVIDER_SECRET_NAMES = [
|
|
27409
27654
|
"indexnow-keys",
|
|
@@ -27999,7 +28244,7 @@ async function loadInstalledProviderExtensions(options = {}) {
|
|
|
27999
28244
|
const DEFAULT_MAX_REQUESTS = 8;
|
|
28000
28245
|
const MAX_RESPONSE_BYTES$1 = 10485760;
|
|
28001
28246
|
const MAX_REQUEST_BODY_BYTES = 65536;
|
|
28002
|
-
const TIMEOUT_MS$
|
|
28247
|
+
const TIMEOUT_MS$4 = 15e3;
|
|
28003
28248
|
function normalizeProviderExtensionAccount(provider, account) {
|
|
28004
28249
|
const fields = provider.connection.fields.filter((field) => field.kind === "account");
|
|
28005
28250
|
const allowed = new Set(fields.map((field) => field.id));
|
|
@@ -28046,7 +28291,7 @@ function runtimeForProvider(provider, options = {}) {
|
|
|
28046
28291
|
},
|
|
28047
28292
|
fetch: providerFetch,
|
|
28048
28293
|
maxResponseBytes: MAX_RESPONSE_BYTES$1,
|
|
28049
|
-
timeoutMs: TIMEOUT_MS$
|
|
28294
|
+
timeoutMs: TIMEOUT_MS$4,
|
|
28050
28295
|
retry: (input.method ?? "GET") === "GET" ? "safe" : "never",
|
|
28051
28296
|
schema: z.unknown()
|
|
28052
28297
|
});
|
|
@@ -29309,7 +29554,7 @@ const NAVIGATIONAL_STEM_THRESHOLDS = {
|
|
|
29309
29554
|
function compact(value) {
|
|
29310
29555
|
return normalizeBrandText(value).replace(/\s+/g, "");
|
|
29311
29556
|
}
|
|
29312
|
-
function round$
|
|
29557
|
+
function round$1(value, digits) {
|
|
29313
29558
|
return Number(value.toFixed(digits));
|
|
29314
29559
|
}
|
|
29315
29560
|
function stemQueryEvidence(rows, stem) {
|
|
@@ -29336,8 +29581,8 @@ function stemQueryEvidence(rows, stem) {
|
|
|
29336
29581
|
query,
|
|
29337
29582
|
clicks,
|
|
29338
29583
|
impressions,
|
|
29339
|
-
ctr: round$
|
|
29340
|
-
position: round$
|
|
29584
|
+
ctr: round$1(clicks / impressions, 4),
|
|
29585
|
+
position: round$1(weightedPosition / impressions, 2),
|
|
29341
29586
|
sourceRows
|
|
29342
29587
|
};
|
|
29343
29588
|
}
|
|
@@ -35072,7 +35317,7 @@ const GENERIC_ANCHORS = /^(click here|here|read more|learn more|more|this|this p
|
|
|
35072
35317
|
function normalise$1(value) {
|
|
35073
35318
|
return value.normalize("NFKD").replace(/\p{Diacritic}/gu, "").normalize("NFC").replace(/([\p{L}\p{N}])[’'`]([\p{L}\p{N}])/gu, "$1$2").toLowerCase().replace(/&/g, " and ").replace(/[^\p{L}\p{N}]+/gu, " ").replace(/\s+/g, " ").trim();
|
|
35074
35319
|
}
|
|
35075
|
-
const words$
|
|
35320
|
+
const words$2 = (value) => normalise$1(value).split(" ").filter(Boolean);
|
|
35076
35321
|
const FUNCTION_WORDS = new Set("a an and are as at be but by for from has have how if in into is it its of on or that the their then there these they this to was we were what when where which who why will with you your our can do does not just more most also than too very about after before over under again all any each other some such no nor only own same so up out off one two both every few several many much should would could because while since although though until unless whether however".split(" "));
|
|
35077
35322
|
const NOT_PLURAL = /* @__PURE__ */ new Set([
|
|
35078
35323
|
"always",
|
|
@@ -35133,7 +35378,7 @@ function stem(word) {
|
|
|
35133
35378
|
if (one.length > 6 && one.endsWith("ing")) return one.slice(0, -3);
|
|
35134
35379
|
return one;
|
|
35135
35380
|
}
|
|
35136
|
-
const terms = (text) => words$
|
|
35381
|
+
const terms = (text) => words$2(text).filter((word) => word.length > 1 && !FUNCTION_WORDS.has(word) && !/^\d+$/.test(word)).map(stem);
|
|
35137
35382
|
const slugWords = (url) => {
|
|
35138
35383
|
try {
|
|
35139
35384
|
return new URL(url).pathname.split(/[/._-]+/).filter(Boolean).join(" ");
|
|
@@ -35420,7 +35665,7 @@ function placementPage(input) {
|
|
|
35420
35665
|
};
|
|
35421
35666
|
}
|
|
35422
35667
|
// packages/core/dist/analyze/internal-links-report.js
|
|
35423
|
-
const DAY$
|
|
35668
|
+
const DAY$2 = 864e5;
|
|
35424
35669
|
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
35425
35670
|
function internalLinksReportRange(input, fallbackDays, now) {
|
|
35426
35671
|
if (!input.startDate && !input.endDate) return {
|
|
@@ -35432,7 +35677,7 @@ function internalLinksReportRange(input, fallbackDays, now) {
|
|
|
35432
35677
|
return {
|
|
35433
35678
|
startDate,
|
|
35434
35679
|
endDate,
|
|
35435
|
-
days: Math.round((Date.parse(`${endDate}T00:00:00Z`) - Date.parse(`${startDate}T00:00:00Z`)) / DAY$
|
|
35680
|
+
days: Math.round((Date.parse(`${endDate}T00:00:00Z`) - Date.parse(`${startDate}T00:00:00Z`)) / DAY$2) + 1
|
|
35436
35681
|
};
|
|
35437
35682
|
}
|
|
35438
35683
|
const plural$5 = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
@@ -35467,7 +35712,7 @@ function siteStartUrl(site) {
|
|
|
35467
35712
|
if (value.startsWith("sc-domain:")) return `https://${value.slice(10)}/`;
|
|
35468
35713
|
return `${new URL(/^https?:\/\//i.test(value) ? value : `https://${value}`).origin}/`;
|
|
35469
35714
|
}
|
|
35470
|
-
function round
|
|
35715
|
+
function round(value, places = 3) {
|
|
35471
35716
|
const factor = 10 ** places;
|
|
35472
35717
|
return Math.round(value * factor) / factor;
|
|
35473
35718
|
}
|
|
@@ -35823,7 +36068,7 @@ async function analyse(input, deps, crawl, context) {
|
|
|
35823
36068
|
sentence: decision.sentence?.text ?? null,
|
|
35824
36069
|
section: decision.sentence?.section || null,
|
|
35825
36070
|
sentenceMatch: decision.sentence?.match ?? null,
|
|
35826
|
-
similarity: round
|
|
36071
|
+
similarity: round(candidate.similarity),
|
|
35827
36072
|
sharedQueries: candidate.sharedQueries,
|
|
35828
36073
|
targetInboundLinks: inbound[candidate.target] ?? 0,
|
|
35829
36074
|
sourceType: types[candidate.source] ?? null,
|
|
@@ -39943,7 +40188,7 @@ async function updatePostmortemWorkflow(input, dependencies = {}) {
|
|
|
39943
40188
|
}
|
|
39944
40189
|
// packages/core/dist/clicky/api.js
|
|
39945
40190
|
const ENDPOINT$1 = "https://api.clicky.com/api/stats/4";
|
|
39946
|
-
const MAX_BYTES$
|
|
40191
|
+
const MAX_BYTES$5 = 5e6;
|
|
39947
40192
|
var ClickyError = class extends Error {
|
|
39948
40193
|
code;
|
|
39949
40194
|
constructor(code, message) {
|
|
@@ -39970,7 +40215,7 @@ async function clickyStats(site, types, options = {}) {
|
|
|
39970
40215
|
throw new ClickyError("remote", "Could not reach Clicky. Try again.");
|
|
39971
40216
|
});
|
|
39972
40217
|
if (!response.ok) throw new ClickyError("remote", `Clicky returned ${response.status}.`);
|
|
39973
|
-
const groups = await readJson(response, "Clicky", { maxBytes: MAX_BYTES$
|
|
40218
|
+
const groups = await readJson(response, "Clicky", { maxBytes: MAX_BYTES$5 });
|
|
39974
40219
|
if (!Array.isArray(groups)) throw new ClickyError("remote", "Clicky returned invalid data.");
|
|
39975
40220
|
const failed = groups.find((group) => typeof group?.error === "string");
|
|
39976
40221
|
if (failed?.error) throw /sitekey|site id|authenticat|permission/iu.test(failed.error) ? new ClickyError("auth", `Clicky rejected site ID ${site.siteId} or its sitekey.`) : new ClickyError("remote", `Clicky: ${failed.error.slice(0, 200)}`);
|
|
@@ -40997,7 +41242,7 @@ function push(result, text, from, to) {
|
|
|
40997
41242
|
text: text.slice(start, end)
|
|
40998
41243
|
});
|
|
40999
41244
|
}
|
|
41000
|
-
function words$
|
|
41245
|
+
function words$1(text) {
|
|
41001
41246
|
return text.match(/[A-Za-z0-9][A-Za-z0-9'\u2019-]*/g) ?? [];
|
|
41002
41247
|
}
|
|
41003
41248
|
const FINITE = new Set(`am is are was were be been being has have had do does did can could will would shall should may might must
|
|
@@ -41014,7 +41259,7 @@ const FINITE = new Set(`am is are was were be been being has have had do does di
|
|
|
41014
41259
|
happen happens happened leave leaves left bring brings brought live lives lived set sets love loves loved
|
|
41015
41260
|
like likes liked hate hates`.split(/\s+/));
|
|
41016
41261
|
function verbless(sentence) {
|
|
41017
|
-
for (const raw of words$
|
|
41262
|
+
for (const raw of words$1(sentence)) {
|
|
41018
41263
|
const word = raw.toLowerCase().replace(/\u2019/g, "'");
|
|
41019
41264
|
if (FINITE.has(word)) return false;
|
|
41020
41265
|
if (/(?:n't|'s|'re|'ve|'ll|'d|'m)$/.test(word)) return false;
|
|
@@ -41106,7 +41351,7 @@ var Context = class {
|
|
|
41106
41351
|
let total = 0;
|
|
41107
41352
|
let prose = 0;
|
|
41108
41353
|
for (const block of doc.blocks) {
|
|
41109
|
-
const count = words$
|
|
41354
|
+
const count = words$1(block.text).length;
|
|
41110
41355
|
total += count;
|
|
41111
41356
|
if (PROSE.includes(block.kind)) prose += count;
|
|
41112
41357
|
}
|
|
@@ -42081,7 +42326,7 @@ function heroLength(ctx) {
|
|
|
42081
42326
|
if (ctx.level(rule) === "off") return;
|
|
42082
42327
|
for (const block of ctx.blocks(["heading"])) {
|
|
42083
42328
|
if (block.level !== 1) continue;
|
|
42084
|
-
const count = words$
|
|
42329
|
+
const count = words$1(block.text).length;
|
|
42085
42330
|
if (count <= 12 && block.text.length <= 70) continue;
|
|
42086
42331
|
ctx.hit(rule, block, 0, block.text.length, `The H1 is ${count} words. A headline that long is hard to take in at a glance.`, "Keep the main promise in the H1 and move the rest to the line below it.");
|
|
42087
42332
|
}
|
|
@@ -42106,7 +42351,7 @@ function reviews(ctx) {
|
|
|
42106
42351
|
PROOF.lastIndex = 0;
|
|
42107
42352
|
for (const found of block.norm.matchAll(PROOF)) ctx.review("proof", block, found.index ?? 0, (found.index ?? 0) + found[0].length, `Is there a source for "${found[0]}" on the page? Link it or say where the number comes from.`);
|
|
42108
42353
|
}
|
|
42109
|
-
if (block.kind === "paragraph" && block.endsSection && sentences.length === 1 && words$
|
|
42354
|
+
if (block.kind === "paragraph" && block.endsSection && sentences.length === 1 && words$1(block.text).length <= 10 && words$1(block.text).filter((word) => /[a-z]/i.test(word)).length >= 3 && /[.!?]["')]?$/.test(block.text)) ctx.review("mic-drop", block, 0, block.text.length, "Does this closing line add a fact? If it only restates the paragraph above, cut it.");
|
|
42110
42355
|
}
|
|
42111
42356
|
if (ctx.preset === "landing" || ctx.preset === "meta") for (const block of ctx.blocks([
|
|
42112
42357
|
"title",
|
|
@@ -42115,7 +42360,7 @@ function reviews(ctx) {
|
|
|
42115
42360
|
])) {
|
|
42116
42361
|
if (block.kind === "heading" && block.level !== 1) continue;
|
|
42117
42362
|
if (!block.text) continue;
|
|
42118
|
-
const later = words$
|
|
42363
|
+
const later = words$1(block.text).slice(1);
|
|
42119
42364
|
if (/\d/.test(block.text) || later.some((word) => /^[A-Z]/.test(word))) continue;
|
|
42120
42365
|
ctx.review("swap-test", block, 0, block.text.length, "Would this line work unchanged on a competitor's page? If so, add the product, number or result only you can claim.");
|
|
42121
42366
|
}
|
|
@@ -42275,7 +42520,7 @@ function negativeParallelism(ctx) {
|
|
|
42275
42520
|
const sentence = sentenceAt(sentences, start);
|
|
42276
42521
|
const subject = block.norm.slice(sentence.start, start).trim();
|
|
42277
42522
|
const pronoun = /^(?:but |and |so )?(?:it|this|that|they)?$/i.test(subject.replace(/(?:'s|'re)$/, ""));
|
|
42278
|
-
const firstWords = words$
|
|
42523
|
+
const firstWords = words$1(block.norm.slice(sentence.start, end)).length;
|
|
42279
42524
|
let level = "warning";
|
|
42280
42525
|
if (kind === "reveal" || kind === "about" || kind === "repeated") level = "error";
|
|
42281
42526
|
else if (FRAMING.test(subject)) level = "error";
|
|
@@ -42329,7 +42574,7 @@ function contrastReframe(ctx) {
|
|
|
42329
42574
|
for (const block of ctx.blocks([...SENTENCE_KINDS, "heading"])) for (const sentence of ctx.sentences(block)) {
|
|
42330
42575
|
const text = sentence.text;
|
|
42331
42576
|
const just = NOT_JUST.exec(text);
|
|
42332
|
-
if (just && (just[0].startsWith(",") || words$
|
|
42577
|
+
if (just && (just[0].startsWith(",") || words$1(text).length <= 16) && !insideQuotes(block.norm, sentence.start + just.index, sentence.start + just.index + just[0].length)) {
|
|
42333
42578
|
ctx.hit(rule, block, sentence.start, sentence.end, "A \"not just X\" contrast inflates the claim instead of stating it.", "Say what it is or does in one plain clause, and drop the \"not just\" half.");
|
|
42334
42579
|
continue;
|
|
42335
42580
|
}
|
|
@@ -42342,8 +42587,8 @@ function contrastReframe(ctx) {
|
|
|
42342
42587
|
const right = rightAll.split(/[,;:.!?(]/)[0] ?? "";
|
|
42343
42588
|
if (!rather && SKIP_AFTER_NOT.test(right)) continue;
|
|
42344
42589
|
if (/\bor$/i.test(left.trim()) || /\bwhether\b/i.test(left)) continue;
|
|
42345
|
-
const leftWords = words$
|
|
42346
|
-
const rightWords = words$
|
|
42590
|
+
const leftWords = words$1(left);
|
|
42591
|
+
const rightWords = words$1(right);
|
|
42347
42592
|
if (leftWords.length < 3 || !rightWords.length) continue;
|
|
42348
42593
|
if (leftWords.length + rightWords.length <= 5 && verbless(text)) continue;
|
|
42349
42594
|
const lastLeft = leftWords[leftWords.length - 1];
|
|
@@ -42441,12 +42686,12 @@ const ABSTRACT_TRIAD = /\b[a-z]+(?:tion|sion|ity|ness|ment|ence|ance|ism), (?:an
|
|
|
42441
42686
|
const ECHO = new Set("to our your their my his her its every each more less no it they we you".split(" "));
|
|
42442
42687
|
const COPULA = /\b(?:is|are|was|were|'s|feels?|felt|looks?|stays?|remains?|seems?)\s+$/i;
|
|
42443
42688
|
function formulaTriad(items, before) {
|
|
42444
|
-
const firsts = items.map((item) => words$
|
|
42689
|
+
const firsts = items.map((item) => words$1(item)[0]?.toLowerCase() ?? "");
|
|
42445
42690
|
const echo = firsts[0] ?? "";
|
|
42446
42691
|
if (ECHO.has(echo) && firsts.every((first) => first === echo)) return `Each item opens with "${echo}".`;
|
|
42447
|
-
if (items.every((item) => /^(?:the|their|our|your|its|it|they|we|you|he|she)\b/i.test(item) && words$
|
|
42448
|
-
if (items.every((item) => /^[a-z]/.test(item) && words$
|
|
42449
|
-
if (items.every((item) => /^\w+ed\b/i.test(item) && words$
|
|
42692
|
+
if (items.every((item) => /^(?:the|their|our|your|its|it|they|we|you|he|she)\b/i.test(item) && words$1(item).length >= 3 && words$1(item).length <= 7 && !verbless(item))) return "Three parallel clauses in a row.";
|
|
42693
|
+
if (items.every((item) => /^[a-z]/.test(item) && words$1(item).length <= 2 && !PREPOSITIONS.has(words$1(item)[0] ?? "")) && COPULA.test(before)) return "A string of adjectives after \"is\".";
|
|
42694
|
+
if (items.every((item) => /^\w+ed\b/i.test(item) && words$1(item).length <= 3)) return "A string of past participles.";
|
|
42450
42695
|
return null;
|
|
42451
42696
|
}
|
|
42452
42697
|
function triads(ctx) {
|
|
@@ -42474,13 +42719,13 @@ function triads(ctx) {
|
|
|
42474
42719
|
const items = [...raw];
|
|
42475
42720
|
const head = raw[0] ?? "";
|
|
42476
42721
|
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);
|
|
42477
|
-
if (lead && words$
|
|
42722
|
+
if (lead && words$1(head.slice(lead[0].length)).length) {
|
|
42478
42723
|
items[0] = head.slice(lead[0].length);
|
|
42479
42724
|
from += lead[0].length;
|
|
42480
42725
|
}
|
|
42481
42726
|
const end = sentence.start + (match.index ?? 0) + match[0].length;
|
|
42482
42727
|
const before = block.norm.slice(sentence.start, sentence.start + from);
|
|
42483
|
-
const echo = words$
|
|
42728
|
+
const echo = words$1(raw[1] ?? "")[0]?.toLowerCase() ?? "";
|
|
42484
42729
|
const inFirst = new RegExp(`\\b${echo}\\b(?!.*\\b${echo}\\b)`, "i").exec(head);
|
|
42485
42730
|
if (ECHO.has(echo) && inFirst && inFirst.index > 0) {
|
|
42486
42731
|
items[0] = head.slice(inFirst.index);
|
|
@@ -42531,7 +42776,7 @@ function colonDensity(ctx) {
|
|
|
42531
42776
|
const after = block.norm.slice(at + match[0].length);
|
|
42532
42777
|
if (/^["'(]/.test(after)) continue;
|
|
42533
42778
|
const lead = block.norm.slice(sentenceAt(sentences, at).start, at);
|
|
42534
|
-
if (words$
|
|
42779
|
+
if (words$1(lead).length <= 4 && verbless(lead)) continue;
|
|
42535
42780
|
const source = block.map[at] ?? -1;
|
|
42536
42781
|
if (/^(?:\*\*|__)/.test(ctx.doc.source.slice(source + 1, source + 3)) || /(?:\*\*|__)$/.test(ctx.doc.source.slice(source - 2, source))) continue;
|
|
42537
42782
|
if (block.links.some((link) => link.start <= at && link.end > at)) continue;
|
|
@@ -42597,7 +42842,7 @@ function heresAnnouncement(ctx) {
|
|
|
42597
42842
|
])) for (const sentence of ctx.sentences(block)) {
|
|
42598
42843
|
const text = sentence.text;
|
|
42599
42844
|
if (!/^(?:And |So |But )?Here(?:'s| is| are) (?:the|what|why|how|who|where|when|a|an|my|our|some|two|three|four|five)\b/i.test(text) || /^(?:And |So |But )?Here's the (?:thing|deal|kicker|catch|twist|truth|secret|reality)\b/i.test(text)) continue;
|
|
42600
|
-
const count = words$
|
|
42845
|
+
const count = words$1(text).length;
|
|
42601
42846
|
const colon = text.endsWith(":");
|
|
42602
42847
|
const sentences = ctx.sentences(block);
|
|
42603
42848
|
if (sentence === sentences[sentences.length - 1]) {
|
|
@@ -42625,7 +42870,7 @@ const LEADING_CLAUSE = /^(?:without|with|for|in|on|at|after|before|if|when|once|
|
|
|
42625
42870
|
const MONTH = /\b(?:january|february|march|april|may|june|july|august|september|october|november|december|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i;
|
|
42626
42871
|
const KICKER = /^(?:That's it|That's all|No exceptions|No catch|No strings attached|No surprises|No asterisks|Period|Full stop|Simple as that|It's that simple|That simple|Nothing more|Nothing else)[.!]$/i;
|
|
42627
42872
|
function slogan(text) {
|
|
42628
|
-
const list = words$
|
|
42873
|
+
const list = words$1(text);
|
|
42629
42874
|
return /[.!]$/.test(text) && !/^Not\b/.test(text) && list.length >= 1 && list.length <= 4 && !GREETING.test(text) && !MONTH.test(text) && !list.every((word) => /^[A-Z0-9]/.test(word)) && verbless(text);
|
|
42630
42875
|
}
|
|
42631
42876
|
function fragmentRuns(ctx, rule) {
|
|
@@ -42634,7 +42879,7 @@ function fragmentRuns(ctx, rule) {
|
|
|
42634
42879
|
for (let i = 1; i < sentences.length; i++) {
|
|
42635
42880
|
const before = sentences[i - 1];
|
|
42636
42881
|
const sentence = sentences[i];
|
|
42637
|
-
const kicker = KICKER.test(sentence.text) && words$
|
|
42882
|
+
const kicker = KICKER.test(sentence.text) && words$1(before.text).length <= 8;
|
|
42638
42883
|
const pair = slogan(before.text) && slogan(sentence.text);
|
|
42639
42884
|
if (!kicker && !pair) continue;
|
|
42640
42885
|
ctx.hit(rule, block, before.start, sentence.end, kicker ? `"${sentence.text}" is a kicker added for rhythm after a short line.` : "Two verbless fragments in a row read as a slogan, not a sentence.", "Join them into one plain sentence with a verb, such as \"Books close within 48 hours of month end, every month,\" or cut the kicker.");
|
|
@@ -42649,14 +42894,14 @@ function pithyFragment(ctx) {
|
|
|
42649
42894
|
for (const block of ctx.blocks(RHYTHM_KINDS)) for (const sentence of ctx.sentences(block)) {
|
|
42650
42895
|
const text = sentence.text;
|
|
42651
42896
|
if (!/[.!]$/.test(text)) continue;
|
|
42652
|
-
const list = words$
|
|
42897
|
+
const list = words$1(text);
|
|
42653
42898
|
if (list.length < 2 || list.length > 6) continue;
|
|
42654
42899
|
if (GREETING.test(text) || MONTH.test(text)) continue;
|
|
42655
42900
|
if (list.every((word) => /^[A-Z0-9]/.test(word))) continue;
|
|
42656
42901
|
if (!verbless(text)) continue;
|
|
42657
42902
|
const strong = TWO_BEAT.some((re) => re.test(text));
|
|
42658
42903
|
const [left = "", right = ""] = text.split(",");
|
|
42659
|
-
const twoBeat = text.split(",").length === 2 && words$
|
|
42904
|
+
const twoBeat = text.split(",").length === 2 && words$1(left).length <= 3 && words$1(right).length <= 3 && !LEADING_CLAUSE.test(left.trim()) && !LEADING_CLAUSE.test(right.trim());
|
|
42660
42905
|
if (!strong && !twoBeat) continue;
|
|
42661
42906
|
ctx.hit(rule, block, sentence.start, sentence.end, "A verbless two-beat fragment reads as a slogan, not a sentence.", "Write a full sentence with a subject and a verb that says what happened, or join it to the sentence before.", strong ? void 0 : "warning");
|
|
42662
42907
|
}
|
|
@@ -42678,7 +42923,7 @@ function stockCloser(ctx) {
|
|
|
42678
42923
|
ctx.hit(rule, block, sentence.start, sentence.end, "A stock kicker that tells the reader how to feel about the last point.", "Cut it. If the text already has the number or fact that makes the point, end on that.");
|
|
42679
42924
|
continue;
|
|
42680
42925
|
}
|
|
42681
|
-
if (/^(?:but |and )?(?:that|this)(?:'s| is) not (?:how|what|why|where|a|an|the)\b/i.test(text) && words$
|
|
42926
|
+
if (/^(?:but |and )?(?:that|this)(?:'s| is) not (?:how|what|why|where|a|an|the)\b/i.test(text) && words$1(text).length <= 10) ctx.hit(reframe, block, sentence.start, sentence.end, "A short \"That's not ...\" line dismisses a view instead of stating one.", "Cut it, or say what is true with a fact the text already gives.");
|
|
42682
42927
|
}
|
|
42683
42928
|
}
|
|
42684
42929
|
const FIGURATIVE_NOUNS = "fights?|battles?|hills?|wars?|bets?|gambles?|races?|risks?|horses?|roads?|bridges?|doors?|games?|ships?|cards?";
|
|
@@ -42722,7 +42967,7 @@ function staccato(ctx) {
|
|
|
42722
42967
|
}
|
|
42723
42968
|
run = [];
|
|
42724
42969
|
};
|
|
42725
|
-
for (const sentence of sentences) if (words$
|
|
42970
|
+
for (const sentence of sentences) if (words$1(sentence.text).length <= 4) run.push(sentence);
|
|
42726
42971
|
else report();
|
|
42727
42972
|
report();
|
|
42728
42973
|
}
|
|
@@ -42775,11 +43020,11 @@ function anaphora(ctx) {
|
|
|
42775
43020
|
const sentences = ctx.sentences(block);
|
|
42776
43021
|
let i = 0;
|
|
42777
43022
|
while (i < sentences.length) {
|
|
42778
|
-
const first = words$
|
|
43023
|
+
const first = words$1(sentences[i].text)[0]?.toLowerCase();
|
|
42779
43024
|
let j = i + 1;
|
|
42780
|
-
while (j < sentences.length && first && words$
|
|
43025
|
+
while (j < sentences.length && first && words$1(sentences[j].text)[0]?.toLowerCase() === first) j++;
|
|
42781
43026
|
const run = sentences.slice(i, j);
|
|
42782
|
-
if (first === "no" && j - i >= 2 && run.every((sentence) => /^No (?!one\b|matter\b|doubt\b|longer\b|way\b|wonder\b)[a-z$\d]/.test(sentence.text) && words$
|
|
43027
|
+
if (first === "no" && j - i >= 2 && run.every((sentence) => /^No (?!one\b|matter\b|doubt\b|longer\b|way\b|wonder\b)[a-z$\d]/.test(sentence.text) && words$1(sentence.text).length <= 12)) ctx.hit(rule, block, sentences[i].start, sentences[j - 1].end, `${j - i} sentences in a row start with "No", a drumbeat of things the product is not.`, "Say what it is in one sentence, and keep only the one \"no\" a reader needs, such as \"One flat monthly fee with no tiers.\"");
|
|
42783
43028
|
else if (j - i >= 3 && first && ![
|
|
42784
43029
|
"the",
|
|
42785
43030
|
"a",
|
|
@@ -42791,7 +43036,7 @@ function anaphora(ctx) {
|
|
|
42791
43036
|
"it",
|
|
42792
43037
|
"this"
|
|
42793
43038
|
].includes(first)) {
|
|
42794
|
-
if (run.every((sentence) => words$
|
|
43039
|
+
if (run.every((sentence) => words$1(sentence.text).length <= 7) && /^(?:it's|they|we|you)$/.test(first)) ctx.hit(rule, block, sentences[i].start, sentences[j - 1].end, `${j - i} short sentences in a row start with "${first}".`, "Merge them into one sentence or a short list.");
|
|
42795
43040
|
else ctx.review("anaphora", block, sentences[i].start, sentences[j - 1].end, `${j - i} sentences in a row start with "${first}". Does the repeat help the reader follow a real list, or is it there for rhythm?`);
|
|
42796
43041
|
}
|
|
42797
43042
|
i = j;
|
|
@@ -43062,224 +43307,64 @@ function lintReportText(files) {
|
|
|
43062
43307
|
if (reviews) lines.push("Errors and warnings each come with a fix. Review items are judgement calls: change a line only when it fails the question.");
|
|
43063
43308
|
return lines.join("\n").trimEnd();
|
|
43064
43309
|
}
|
|
43065
|
-
// packages/core/dist/
|
|
43066
|
-
const
|
|
43067
|
-
|
|
43068
|
-
|
|
43069
|
-
|
|
43070
|
-
|
|
43071
|
-
|
|
43072
|
-
|
|
43073
|
-
|
|
43074
|
-
|
|
43075
|
-
const AI_QUERY_KINDS = {
|
|
43076
|
-
agent_prompt: "text from an agent prompt, such as \"search the web for\"",
|
|
43077
|
-
tracker: "a visibility-tool probe, such as \"my location is\"",
|
|
43078
|
-
reply: "a bare reply, such as \"yes\" or \"tell me more\"",
|
|
43079
|
-
follow_up: "a follow-up, such as \"what about …\"",
|
|
43080
|
-
operator: "search operators, such as site:, before: or \"a\" or \"b\"",
|
|
43081
|
-
chat: "chat phrasing, such as \"can you\" or \"should i\"",
|
|
43082
|
-
long: "ten or more words with no other sign"
|
|
43083
|
-
};
|
|
43084
|
-
const MATCHERS = RULES.map(([kind, pattern]) => [kind, new RegExp(pattern)]);
|
|
43085
|
-
const AI_QUERY_PATTERN = RULES.map(([, pattern]) => `(?:${pattern})`).join("|");
|
|
43086
|
-
const NOISE = [
|
|
43087
|
-
["spaced_letters", /(^|\s)(\S\s){3,}\S(\s|$)/u],
|
|
43088
|
-
["broken_encoding", /^(яю|ÿþ|þÿ)|&#[0-9]+;?|&[a-z]+;|[âÃÂ][\u0080-\u00bf€™œ“”]|\ufffd/u],
|
|
43089
|
-
["pasted_text", /^(p [a-z]{3,} |here (are|is) (all )?the |here's the |done[,.!]? (you|here) |current state: )/u]
|
|
43090
|
-
];
|
|
43091
|
-
function aiQueryNoise(query) {
|
|
43092
|
-
const text = query.trim().toLowerCase();
|
|
43093
|
-
return NOISE.find(([, pattern]) => pattern.test(text))?.[0] ?? null;
|
|
43094
|
-
}
|
|
43095
|
-
const QUESTION = /^(how|what|what's|whats|which|why|when|where|who|is|are|can|could|does|do|should|would|will|i need|i want|i have|i'm looking|we need|we want)\b|\?$/u;
|
|
43096
|
-
const ASKABLE_KINDS = /* @__PURE__ */ new Set(["chat", "long"]);
|
|
43097
|
-
const PROMPT_CHARACTERS = 500;
|
|
43098
|
-
function askable(query, kind) {
|
|
43099
|
-
const text = query.trim().toLowerCase().replace(/^["'“]+/u, "");
|
|
43100
|
-
return Boolean(kind && ASKABLE_KINDS.has(kind)) && text.length <= PROMPT_CHARACTERS && QUESTION.test(text);
|
|
43101
|
-
}
|
|
43102
|
-
function aiQueryKind(query) {
|
|
43103
|
-
const text = query.trim().toLowerCase();
|
|
43104
|
-
return MATCHERS.find(([, pattern]) => pattern.test(text))?.[0] ?? null;
|
|
43105
|
-
}
|
|
43106
|
-
const STOP = new Set("the and for with that this what which who how why when where are is was can does do did you your our from about into than then them they their there have has had will would should could not but its it’s me my i am of to in on at by or an as be if so".split(" "));
|
|
43107
|
-
function words$1(query) {
|
|
43108
|
-
return new Set(query.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((word) => word.length >= 3 && !STOP.has(word)).map((word) => word.length > 4 && word.endsWith("s") ? word.slice(0, -1) : word));
|
|
43109
|
-
}
|
|
43110
|
-
const SAME_QUESTION = .6;
|
|
43111
|
-
const MAX_ROWS = 25e3;
|
|
43112
|
-
const EXAMPLES = 3;
|
|
43113
|
-
const CANDIDATES = 200;
|
|
43114
|
-
const overlap = (a, b, weight) => {
|
|
43115
|
-
let shared = 0;
|
|
43116
|
-
let union = 0;
|
|
43117
|
-
for (const word of a) {
|
|
43118
|
-
union += weight(word);
|
|
43119
|
-
if (b.has(word)) shared += weight(word);
|
|
43310
|
+
// packages/core/dist/simple-analytics/api.js
|
|
43311
|
+
const ORIGIN = "https://simpleanalytics.com";
|
|
43312
|
+
const MAX_BYTES$4 = 5e6;
|
|
43313
|
+
const TIMEOUT_MS$3 = 2e4;
|
|
43314
|
+
const SIMPLE_ANALYTICS_LIMIT = 1e3;
|
|
43315
|
+
var SimpleAnalyticsError = class extends Error {
|
|
43316
|
+
code;
|
|
43317
|
+
constructor(code, message) {
|
|
43318
|
+
super(message);
|
|
43319
|
+
this.code = code;
|
|
43120
43320
|
}
|
|
43121
|
-
for (const word of b) if (!a.has(word)) union += weight(word);
|
|
43122
|
-
return union ? shared / union : 0;
|
|
43123
43321
|
};
|
|
43124
|
-
|
|
43125
|
-
|
|
43126
|
-
|
|
43127
|
-
|
|
43128
|
-
|
|
43129
|
-
|
|
43130
|
-
|
|
43131
|
-
|
|
43132
|
-
|
|
43133
|
-
|
|
43134
|
-
|
|
43135
|
-
|
|
43136
|
-
|
|
43137
|
-
|
|
43138
|
-
|
|
43139
|
-
|
|
43140
|
-
|
|
43141
|
-
|
|
43142
|
-
|
|
43143
|
-
|
|
43144
|
-
|
|
43145
|
-
|
|
43146
|
-
|
|
43147
|
-
|
|
43148
|
-
|
|
43149
|
-
|
|
43150
|
-
|
|
43151
|
-
|
|
43152
|
-
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
|
|
43158
|
-
const query = String(row.keys[0] ?? "");
|
|
43159
|
-
const page = String(row.keys[1] ?? "");
|
|
43160
|
-
const kind = aiQueryKind(query);
|
|
43161
|
-
if (!kind) continue;
|
|
43162
|
-
const junk = aiQueryNoise(query);
|
|
43163
|
-
if (junk) {
|
|
43164
|
-
const seen = noise.get(junk) ?? /* @__PURE__ */ new Set();
|
|
43165
|
-
seen.add(query.trim().toLowerCase());
|
|
43166
|
-
noise.set(junk, seen);
|
|
43167
|
-
continue;
|
|
43168
|
-
}
|
|
43169
|
-
const text = query.trim().toLowerCase();
|
|
43170
|
-
const own = words$1(query);
|
|
43171
|
-
let group = byText.get(text);
|
|
43172
|
-
if (!group) {
|
|
43173
|
-
let checked = 0;
|
|
43174
|
-
for (const word of own) {
|
|
43175
|
-
for (const candidate of byWord.get(word) ?? []) {
|
|
43176
|
-
if (++checked > CANDIDATES) break;
|
|
43177
|
-
if (overlap(own, candidate.words, weight) >= SAME_QUESTION) {
|
|
43178
|
-
group = candidate;
|
|
43179
|
-
break;
|
|
43180
|
-
}
|
|
43181
|
-
}
|
|
43182
|
-
if (group || checked > CANDIDATES) break;
|
|
43183
|
-
}
|
|
43184
|
-
}
|
|
43185
|
-
if (!group) {
|
|
43186
|
-
group = {
|
|
43187
|
-
words: own,
|
|
43188
|
-
queries: /* @__PURE__ */ new Map(),
|
|
43189
|
-
pages: /* @__PURE__ */ new Map(),
|
|
43190
|
-
kinds: /* @__PURE__ */ new Map(),
|
|
43191
|
-
clicks: 0,
|
|
43192
|
-
impressions: 0,
|
|
43193
|
-
positionWeight: 0
|
|
43194
|
-
};
|
|
43195
|
-
groups.push(group);
|
|
43196
|
-
for (const word of own) {
|
|
43197
|
-
const list = byWord.get(word) ?? [];
|
|
43198
|
-
list.push(group);
|
|
43199
|
-
byWord.set(word, list);
|
|
43200
|
-
}
|
|
43201
|
-
}
|
|
43202
|
-
byText.set(text, group);
|
|
43203
|
-
if (!kindOf.has(text)) {
|
|
43204
|
-
kindOf.set(text, kind);
|
|
43205
|
-
group.kinds.set(kind, (group.kinds.get(kind) ?? 0) + 1);
|
|
43206
|
-
}
|
|
43207
|
-
group.queries.set(query, (group.queries.get(query) ?? 0) + row.impressions);
|
|
43208
|
-
group.pages.set(page, (group.pages.get(page) ?? 0) + row.impressions);
|
|
43209
|
-
group.clicks += row.clicks;
|
|
43210
|
-
group.impressions += row.impressions;
|
|
43211
|
-
group.positionWeight += row.position * row.impressions;
|
|
43212
|
-
}
|
|
43213
|
-
const byKind = /* @__PURE__ */ new Map();
|
|
43214
|
-
for (const kind of kindOf.values()) {
|
|
43215
|
-
const entry = byKind.get(kind) ?? {
|
|
43216
|
-
queries: 0,
|
|
43217
|
-
impressions: 0
|
|
43218
|
-
};
|
|
43219
|
-
entry.queries += 1;
|
|
43220
|
-
byKind.set(kind, entry);
|
|
43221
|
-
}
|
|
43222
|
-
for (const row of rows) {
|
|
43223
|
-
const kind = kindOf.get(String(row.keys[0] ?? "").trim().toLowerCase());
|
|
43224
|
-
const entry = kind && byKind.get(kind);
|
|
43225
|
-
if (entry) entry.impressions += row.impressions;
|
|
43322
|
+
function isSimpleAnalyticsKey(value) {
|
|
43323
|
+
return /^sa_api_key_[A-Za-z0-9_-]{8,120}$/u.test(value.trim());
|
|
43324
|
+
}
|
|
43325
|
+
const number = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
43326
|
+
const rows$1 = (value) => Array.isArray(value) ? value.flatMap((row) => row && typeof row.value === "string" ? [{
|
|
43327
|
+
value: row.value,
|
|
43328
|
+
pageviews: number(row.pageviews) ?? 0,
|
|
43329
|
+
visitors: number(row.visitors) ?? 0
|
|
43330
|
+
}] : []) : [];
|
|
43331
|
+
async function simpleAnalyticsStats(key, hostname, range, fields, filters = {}) {
|
|
43332
|
+
const url = new URL(`${ORIGIN}/${encodeURIComponent(hostname)}.json`);
|
|
43333
|
+
url.searchParams.set("version", "6");
|
|
43334
|
+
url.searchParams.set("info", "false");
|
|
43335
|
+
url.searchParams.set("start", range.startDate);
|
|
43336
|
+
url.searchParams.set("end", range.endDate);
|
|
43337
|
+
url.searchParams.set("fields", fields.join(","));
|
|
43338
|
+
url.searchParams.set("limit", String(SIMPLE_ANALYTICS_LIMIT));
|
|
43339
|
+
for (const [name, value] of Object.entries(filters)) url.searchParams.set(name, value);
|
|
43340
|
+
const response = await fetch(url, {
|
|
43341
|
+
headers: {
|
|
43342
|
+
"Api-Key": key,
|
|
43343
|
+
accept: "application/json"
|
|
43344
|
+
},
|
|
43345
|
+
signal: AbortSignal.timeout(TIMEOUT_MS$3)
|
|
43346
|
+
}).catch(() => {
|
|
43347
|
+
throw new SimpleAnalyticsError("remote", "Could not reach Simple Analytics. Try again.");
|
|
43348
|
+
});
|
|
43349
|
+
if (response.status === 404) throw new SimpleAnalyticsError("not_found", `Simple Analytics has no website ${hostname} for this key.`);
|
|
43350
|
+
if (response.status === 401 || response.status === 403) throw new SimpleAnalyticsError("auth", `Simple Analytics rejected the API key for ${hostname}.`);
|
|
43351
|
+
if (response.status === 423) throw new SimpleAnalyticsError("auth", `Simple Analytics has no API access for ${hostname} on its plan.`);
|
|
43352
|
+
if (response.status === 400) {
|
|
43353
|
+
const reason = await readJson(response, "Simple Analytics", { maxBytes: 1e4 }).catch(() => null);
|
|
43354
|
+
const error = String(reason?.error ?? "");
|
|
43355
|
+
throw /api-key|authori[sz]/iu.test(error) ? new SimpleAnalyticsError("auth", `Simple Analytics rejected the API key for ${hostname}.`) : new SimpleAnalyticsError("remote", `Simple Analytics: ${error.slice(0, 200) || "returned 400"}.`);
|
|
43226
43356
|
}
|
|
43227
|
-
|
|
43228
|
-
const
|
|
43229
|
-
|
|
43230
|
-
const total = site.rows[0] ?? {
|
|
43231
|
-
clicks: 0,
|
|
43232
|
-
impressions: 0
|
|
43233
|
-
};
|
|
43234
|
-
const items = groups.map((group) => {
|
|
43235
|
-
const most = (map) => [...map].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([name]) => name);
|
|
43236
|
-
const [first, ...rest] = most(group.queries);
|
|
43237
|
-
const kind = [...group.kinds].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0]?.[0];
|
|
43238
|
-
return {
|
|
43239
|
-
query: first ?? "",
|
|
43240
|
-
page: most(group.pages)[0] ?? "",
|
|
43241
|
-
askable: askable(first ?? "", kind),
|
|
43242
|
-
pages: group.pages.size,
|
|
43243
|
-
kind,
|
|
43244
|
-
wordings: group.queries.size,
|
|
43245
|
-
impressions: group.impressions,
|
|
43246
|
-
clicks: group.clicks,
|
|
43247
|
-
ctr: group.impressions ? round(group.clicks / group.impressions, 4) : 0,
|
|
43248
|
-
position: group.impressions ? round(group.positionWeight / group.impressions, 1) : 0,
|
|
43249
|
-
otherWordings: rest.slice(0, EXAMPLES)
|
|
43250
|
-
};
|
|
43251
|
-
}).sort((a, b) => b.impressions - a.impressions || b.wordings - a.wordings || a.query.localeCompare(b.query) || a.page.localeCompare(b.page));
|
|
43252
|
-
const pct = (part, whole) => whole ? round(part / whole * 100, 1) : null;
|
|
43253
|
-
const kinds = [...byKind].sort((a, b) => b[1].impressions - a[1].impressions || a[0].localeCompare(b[0])).map(([kind, entry]) => `${kind} ${entry.queries}`).join(", ");
|
|
43254
|
-
const leftOut = [...noise].sort((a, b) => a[0].localeCompare(b[0])).map(([reason, seen]) => `${reason.replace("_", " ")} ${seen.size}`).join(", ");
|
|
43255
|
-
const asked = items.filter((item) => item.askable).length;
|
|
43256
|
-
const capped = matched.rowsFetched >= MAX_ROWS;
|
|
43357
|
+
if (!response.ok) throw new SimpleAnalyticsError("remote", `Simple Analytics returned ${response.status}.`);
|
|
43358
|
+
const body = await readJson(response, "Simple Analytics", { maxBytes: MAX_BYTES$4 });
|
|
43359
|
+
if (body?.ok !== true) throw new SimpleAnalyticsError("remote", `Simple Analytics: ${String(body?.error ?? "invalid data").slice(0, 200)}`);
|
|
43257
43360
|
return {
|
|
43258
|
-
|
|
43259
|
-
|
|
43260
|
-
|
|
43261
|
-
|
|
43262
|
-
|
|
43263
|
-
|
|
43264
|
-
|
|
43265
|
-
impressions,
|
|
43266
|
-
clicks,
|
|
43267
|
-
shareOfImpressionsPct: pct(impressions, total.impressions),
|
|
43268
|
-
byKind: kinds || "none",
|
|
43269
|
-
ctr: impressions ? round(clicks / impressions, 4) : 0,
|
|
43270
|
-
siteCtr: total.impressions ? round(total.clicks / total.impressions, 4) : 0
|
|
43271
|
-
},
|
|
43272
|
-
kinds: AI_QUERY_KINDS,
|
|
43273
|
-
items,
|
|
43274
|
-
caveats: [
|
|
43275
|
-
"A heuristic: these queries match the patterns of AI conversations and agent searches. Search Console does not mark AI Mode or AI Overviews, and people type some of these too.",
|
|
43276
|
-
"A minimum: Search Console leaves out rare queries, and these are rare by nature.",
|
|
43277
|
-
"Rewordings of one question are grouped by their shared words; page is the page with the most impressions for it.",
|
|
43278
|
-
"Left out and counted, not shown: letters split by spaces, text broken by a wrong encoding, and text pasted from a tool or an agent’s output.",
|
|
43279
|
-
"askable: a chat or long question that opens with a question word or a request such as \"i need\", or ends with a question mark, so an AI engine can be asked it as it is. ai_answers checks the top askable questions only.",
|
|
43280
|
-
"Search Console’s Generative AI report is not in its API, so it is not here.",
|
|
43281
|
-
...capped ? [`Capped at the first ${MAX_ROWS} matching query and page rows.`] : []
|
|
43282
|
-
]
|
|
43361
|
+
hostname: typeof body.hostname === "string" ? body.hostname : hostname,
|
|
43362
|
+
timezone: typeof body.timezone === "string" ? body.timezone : null,
|
|
43363
|
+
pageviews: number(body.pageviews),
|
|
43364
|
+
visitors: number(body.visitors),
|
|
43365
|
+
pages: rows$1(body.pages),
|
|
43366
|
+
referrers: rows$1(body.referrers),
|
|
43367
|
+
utm_sources: rows$1(body.utm_sources)
|
|
43283
43368
|
};
|
|
43284
43369
|
}
|
|
43285
43370
|
// packages/core/dist/commands/research-ahrefs.js
|
|
@@ -44073,12 +44158,6 @@ const DIMENSIONS = [
|
|
|
44073
44158
|
"searchAppearance"
|
|
44074
44159
|
];
|
|
44075
44160
|
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
44161
|
function rowTextFilters(input) {
|
|
44083
44162
|
return [
|
|
44084
44163
|
[
|
|
@@ -44101,11 +44180,6 @@ function rowTextFilters(input) {
|
|
|
44101
44180
|
"includingRegex",
|
|
44102
44181
|
input.queryRegex
|
|
44103
44182
|
],
|
|
44104
|
-
[
|
|
44105
|
-
"query",
|
|
44106
|
-
"includingRegex",
|
|
44107
|
-
input.queryPreset && QUERY_PRESETS[input.queryPreset]
|
|
44108
|
-
],
|
|
44109
44183
|
[
|
|
44110
44184
|
"query",
|
|
44111
44185
|
"excludingRegex",
|
|
@@ -44553,6 +44627,7 @@ async function runAiAnswers(input, headers, deps, more) {
|
|
|
44553
44627
|
] : []];
|
|
44554
44628
|
const shown = rows.map((row) => ({
|
|
44555
44629
|
question: row.question,
|
|
44630
|
+
shape: queryShape(row.question),
|
|
44556
44631
|
impressions: row.impressions,
|
|
44557
44632
|
engine: row.engine,
|
|
44558
44633
|
result: row.result,
|
|
@@ -45801,20 +45876,20 @@ async function pickClickySite(saved, target, connect, refresh) {
|
|
|
45801
45876
|
}
|
|
45802
45877
|
throw new CommandError("NO_ACCESS", `No saved Clicky site matches ${target}. Saved Clicky sites: ${sites.map(clickyLabel).join(", ")}. Pass one of these site IDs, or add the site: ${connect}`);
|
|
45803
45878
|
}
|
|
45804
|
-
const DAY = 864e5;
|
|
45805
|
-
const isoDay = (time) => new Date(time).toISOString().slice(0, 10);
|
|
45879
|
+
const DAY$1 = 864e5;
|
|
45880
|
+
const isoDay$1 = (time) => new Date(time).toISOString().slice(0, 10);
|
|
45806
45881
|
function clickyRange(input) {
|
|
45807
45882
|
if (!input.startDate && !input.endDate) {
|
|
45808
|
-
const end = Date.now() - DAY;
|
|
45883
|
+
const end = Date.now() - DAY$1;
|
|
45809
45884
|
return {
|
|
45810
|
-
startDate: isoDay(end - 27 * DAY),
|
|
45811
|
-
endDate: isoDay(end)
|
|
45885
|
+
startDate: isoDay$1(end - 27 * DAY$1),
|
|
45886
|
+
endDate: isoDay$1(end)
|
|
45812
45887
|
};
|
|
45813
45888
|
}
|
|
45814
45889
|
const start = Date.parse(`${input.startDate}T00:00:00Z`);
|
|
45815
45890
|
const end = Date.parse(`${input.endDate}T00:00:00Z`);
|
|
45816
45891
|
if (!input.startDate || !input.endDate || !(start <= end)) throw new CommandError("INVALID_INPUT", "Send a start date and an end date together, in order.");
|
|
45817
|
-
if ((end - start) / DAY + 1 > 31) throw new CommandError("INVALID_INPUT", "Clicky reads at most 31 days at a time. Send a shorter range.");
|
|
45892
|
+
if ((end - start) / DAY$1 + 1 > 31) throw new CommandError("INVALID_INPUT", "Clicky reads at most 31 days at a time. Send a shorter range.");
|
|
45818
45893
|
return {
|
|
45819
45894
|
startDate: input.startDate,
|
|
45820
45895
|
endDate: input.endDate
|
|
@@ -45903,6 +45978,143 @@ async function runClickyRows(input, keys, options) {
|
|
|
45903
45978
|
}
|
|
45904
45979
|
};
|
|
45905
45980
|
}
|
|
45981
|
+
const FREE_LIMIT = 100;
|
|
45982
|
+
const FREE_HISTORY_DAYS = 30;
|
|
45983
|
+
function compared(now, before) {
|
|
45984
|
+
const rows = /* @__PURE__ */ new Map();
|
|
45985
|
+
const add = (name, visits, key) => {
|
|
45986
|
+
const row = rows.get(name) ?? {
|
|
45987
|
+
visits: 0,
|
|
45988
|
+
previousVisits: 0
|
|
45989
|
+
};
|
|
45990
|
+
row[key] += visits;
|
|
45991
|
+
rows.set(name, row);
|
|
45992
|
+
};
|
|
45993
|
+
for (const item of now) add(item.name, item.visits, "visits");
|
|
45994
|
+
for (const item of before) add(item.name, item.visits, "previousVisits");
|
|
45995
|
+
return [...rows].map(([name, row]) => ({
|
|
45996
|
+
name,
|
|
45997
|
+
...row
|
|
45998
|
+
})).sort((left, right) => right.visits - left.visits || right.previousVisits - left.previousVisits || (left.name < right.name ? -1 : left.name > right.name ? 1 : 0));
|
|
45999
|
+
}
|
|
46000
|
+
const sum$1 = (rows) => ({
|
|
46001
|
+
visits: rows.reduce((total, row) => total + row.visits, 0),
|
|
46002
|
+
previousVisits: rows.reduce((total, row) => total + row.previousVisits, 0)
|
|
46003
|
+
});
|
|
46004
|
+
const was = (rows) => rows.slice(0, 10).map((row) => `${row.name} ${row.visits} (was ${row.previousVisits})`).join(", ");
|
|
46005
|
+
async function clickyBeside(keys, site, range, before, pages) {
|
|
46006
|
+
const saved = keys ? clickySites(keys) : [];
|
|
46007
|
+
if (!saved.length) return null;
|
|
46008
|
+
let found;
|
|
46009
|
+
try {
|
|
46010
|
+
found = await pickClickySite(saved, site, "");
|
|
46011
|
+
} catch {
|
|
46012
|
+
return null;
|
|
46013
|
+
}
|
|
46014
|
+
const types = [
|
|
46015
|
+
"visitors",
|
|
46016
|
+
"traffic-sources",
|
|
46017
|
+
"links-domains",
|
|
46018
|
+
...pages ? ["pages-entrance"] : []
|
|
46019
|
+
];
|
|
46020
|
+
try {
|
|
46021
|
+
const read = (dates) => clickyStats(found, types, {
|
|
46022
|
+
date: `${dates.startDate},${dates.endDate}`,
|
|
46023
|
+
limit: LIMIT
|
|
46024
|
+
});
|
|
46025
|
+
const now = await read(range);
|
|
46026
|
+
const then = await read(before);
|
|
46027
|
+
const tally = (items) => items.reduce((total, item) => total + (count$2(item) ?? 0), 0);
|
|
46028
|
+
const visits = {
|
|
46029
|
+
visits: tally(now.visitors ?? []),
|
|
46030
|
+
previousVisits: tally(then.visitors ?? [])
|
|
46031
|
+
};
|
|
46032
|
+
const sources = compared(totals(now["traffic-sources"] ?? []), totals(then["traffic-sources"] ?? []));
|
|
46033
|
+
const fromAi = (items) => totals(items).flatMap((item) => {
|
|
46034
|
+
const source = aiReferralSourceForValue(item.name);
|
|
46035
|
+
return source ? [{
|
|
46036
|
+
name: source.label,
|
|
46037
|
+
visits: item.visits
|
|
46038
|
+
}] : [];
|
|
46039
|
+
});
|
|
46040
|
+
const ai = compared(fromAi(now["links-domains"] ?? []), fromAi(then["links-domains"] ?? []));
|
|
46041
|
+
const aiTotal = sum$1(ai);
|
|
46042
|
+
const landed = (items) => {
|
|
46043
|
+
let total = 0;
|
|
46044
|
+
for (const item of items) {
|
|
46045
|
+
const value = count$2(item);
|
|
46046
|
+
if (value === null || !item.url) continue;
|
|
46047
|
+
try {
|
|
46048
|
+
if (new URL(item.url).pathname.includes(pages ?? "")) total += value;
|
|
46049
|
+
} catch {}
|
|
46050
|
+
}
|
|
46051
|
+
return total;
|
|
46052
|
+
};
|
|
46053
|
+
const onPages = pages ? {
|
|
46054
|
+
contains: pages,
|
|
46055
|
+
visits: landed(now["pages-entrance"] ?? []),
|
|
46056
|
+
previousVisits: landed(then["pages-entrance"] ?? [])
|
|
46057
|
+
} : null;
|
|
46058
|
+
const cut = (type) => [now, then].some((stats) => {
|
|
46059
|
+
const length = stats[type]?.length ?? 0;
|
|
46060
|
+
return length >= LIMIT || length === FREE_LIMIT;
|
|
46061
|
+
});
|
|
46062
|
+
const linksCut = cut("links-domains");
|
|
46063
|
+
const pagesCut = Boolean(pages) && cut("pages-entrance");
|
|
46064
|
+
const daysBack = Math.round((Date.now() - Date.parse(`${before.startDate}T00:00:00Z`)) / DAY$1);
|
|
46065
|
+
const notes = [
|
|
46066
|
+
"Visits are Clicky’s own count, in the Clicky site’s time zone; they are not Google Analytics sessions or Search Console clicks.",
|
|
46067
|
+
pagesCut ? "Clicky’s list of landing pages reached its row limit (100 on a free account, 1,000 otherwise), so the landing-page total can be higher than shown." : "",
|
|
46068
|
+
daysBack > FREE_HISTORY_DAYS ? `The earlier period starts ${daysBack} days ago; a free Clicky account keeps 30 days, so on one it can read as zero.` : ""
|
|
46069
|
+
].filter(Boolean);
|
|
46070
|
+
const total = `${visits.visits} (was ${visits.previousVisits}, ${change$2(pct(visits.visits, visits.previousVisits))})`;
|
|
46071
|
+
const text = [
|
|
46072
|
+
`Clicky site ${clickyLabel(found)}: visits ${total}${pages ? " on the whole site" : ""}.`,
|
|
46073
|
+
sources.length ? `Traffic sources (visits): ${was(sources)}.` : "",
|
|
46074
|
+
onPages ? `Visits that landed on pages whose path contains "${pages}", from every source: ${onPages.visits} (was ${onPages.previousVisits}, ${change$2(pct(onPages.visits, onPages.previousVisits))}). Clicky does not split landing pages by source.` : "",
|
|
46075
|
+
...notes
|
|
46076
|
+
].filter(Boolean).join(" ");
|
|
46077
|
+
const limit = "Clicky’s list of incoming link domains reached its row limit (100 on a free account, 1,000 otherwise)";
|
|
46078
|
+
return {
|
|
46079
|
+
text: `${text}\n\n${[
|
|
46080
|
+
aiTotal.visits || aiTotal.previousVisits ? `Visits from AI assistants in Clicky’s incoming links (whole site): ${aiTotal.visits} (was ${aiTotal.previousVisits}, ${change$2(pct(aiTotal.visits, aiTotal.previousVisits))}). By source: ${was(ai)}.` : linksCut ? `Visits from AI assistants in Clicky’s incoming links (whole site): none among the domains Clicky listed. ${limit}, so this is unknown, not zero.` : "Visits from AI assistants in Clicky’s incoming links (whole site): none in either period.",
|
|
46081
|
+
linksCut && (aiTotal.visits || aiTotal.previousVisits) ? `${limit}, so these can be higher.` : "",
|
|
46082
|
+
"Only visits that pass a referrer count; AI apps that send none show as direct."
|
|
46083
|
+
].filter(Boolean).join(" ")}`,
|
|
46084
|
+
data: {
|
|
46085
|
+
siteId: found.siteId,
|
|
46086
|
+
domain: found.domain,
|
|
46087
|
+
metric: "visits",
|
|
46088
|
+
...visits,
|
|
46089
|
+
visitsChangePct: pct(visits.visits, visits.previousVisits),
|
|
46090
|
+
trafficSources: sources.map(({ name, ...row }) => ({
|
|
46091
|
+
source: name,
|
|
46092
|
+
...row
|
|
46093
|
+
})),
|
|
46094
|
+
...onPages ? { landingPages: {
|
|
46095
|
+
...onPages,
|
|
46096
|
+
capped: pagesCut
|
|
46097
|
+
} } : {},
|
|
46098
|
+
aiAssistants: {
|
|
46099
|
+
...aiTotal,
|
|
46100
|
+
visitsChangePct: pct(aiTotal.visits, aiTotal.previousVisits),
|
|
46101
|
+
bySource: ai.map(({ name, ...row }) => ({
|
|
46102
|
+
source: name,
|
|
46103
|
+
...row
|
|
46104
|
+
})),
|
|
46105
|
+
capped: linksCut
|
|
46106
|
+
},
|
|
46107
|
+
notes
|
|
46108
|
+
}
|
|
46109
|
+
};
|
|
46110
|
+
} catch (error) {
|
|
46111
|
+
const message = error instanceof ClickyError ? error.message : error instanceof Error ? error.message : String(error);
|
|
46112
|
+
return {
|
|
46113
|
+
text: `Clicky: could not be read. ${message}`,
|
|
46114
|
+
data: { error: message }
|
|
46115
|
+
};
|
|
46116
|
+
}
|
|
46117
|
+
}
|
|
45906
46118
|
// packages/core/dist/commands/domain-rating.js
|
|
45907
46119
|
const DR_ATTRIBUTION = "domain_rating: Domain Rating by Ahrefs (https://ahrefs.com/).";
|
|
45908
46120
|
const ENDPOINT = "https://api.ahrefs.com/v3/public/domain-rating-free";
|
|
@@ -47762,6 +47974,33 @@ async function bingLead(overview, bing, origin, rowsPerList) {
|
|
|
47762
47974
|
return null;
|
|
47763
47975
|
}
|
|
47764
47976
|
}
|
|
47977
|
+
const SHAPED = /* @__PURE__ */ new Set([
|
|
47978
|
+
"quick-wins",
|
|
47979
|
+
"low-ctr",
|
|
47980
|
+
"striking-distance",
|
|
47981
|
+
"second-page",
|
|
47982
|
+
"ai-queries"
|
|
47983
|
+
]);
|
|
47984
|
+
function labelShapes(report, count) {
|
|
47985
|
+
const queries = [];
|
|
47986
|
+
const visit = (value, depth) => {
|
|
47987
|
+
if (depth > 3 || !value || typeof value !== "object") return;
|
|
47988
|
+
if (Array.isArray(value)) {
|
|
47989
|
+
for (const item of value) visit(item, depth + 1);
|
|
47990
|
+
return;
|
|
47991
|
+
}
|
|
47992
|
+
const row = value;
|
|
47993
|
+
if (typeof row.query === "string") {
|
|
47994
|
+
queries.push(row.query);
|
|
47995
|
+
const shape = queryShape(row.query);
|
|
47996
|
+
if (shape) row.shape = shape;
|
|
47997
|
+
}
|
|
47998
|
+
for (const [key, child] of Object.entries(row)) if (Array.isArray(child) && key !== "caveats") visit(child, depth + 1);
|
|
47999
|
+
};
|
|
48000
|
+
visit(report.items, 0);
|
|
48001
|
+
const line = count && queryShapeLine(queries);
|
|
48002
|
+
if (line) report.queryShapes = line;
|
|
48003
|
+
}
|
|
47765
48004
|
async function build(read, site, section, range, now, bing) {
|
|
47766
48005
|
const dependencies = {
|
|
47767
48006
|
searchAnalytics: read,
|
|
@@ -47829,7 +48068,9 @@ async function build(read, site, section, range, now, bing) {
|
|
|
47829
48068
|
}, read),
|
|
47830
48069
|
bing: async () => bingSection(await bing(), read, site, range)
|
|
47831
48070
|
}[section];
|
|
47832
|
-
|
|
48071
|
+
const report = factsOnly(await run());
|
|
48072
|
+
if (SHAPED.has(section)) labelShapes(report, section !== "ai-queries");
|
|
48073
|
+
return report;
|
|
47833
48074
|
}
|
|
47834
48075
|
function brandNote(report) {
|
|
47835
48076
|
const brand = report.brand;
|
|
@@ -47914,6 +48155,7 @@ async function allSections(input, deps) {
|
|
|
47914
48155
|
parts.push([
|
|
47915
48156
|
`## ${id}: ${shown.total} ${shown.total === 1 ? "row" : "rows"}`,
|
|
47916
48157
|
SECTIONS[id],
|
|
48158
|
+
typeof run.queryShapes === "string" ? run.queryShapes : null,
|
|
47917
48159
|
shown.text,
|
|
47918
48160
|
id === "traffic-drop" ? listOfUpdates(run.googleUpdates, run.updateWindow) : null
|
|
47919
48161
|
].filter(Boolean).join("\n"));
|
|
@@ -48006,6 +48248,7 @@ async function oneSection(input, deps) {
|
|
|
48006
48248
|
report.pageChecks = checked;
|
|
48007
48249
|
}
|
|
48008
48250
|
const notes = money ? [money] : [];
|
|
48251
|
+
if (typeof report.queryShapes === "string") notes.push(report.queryShapes);
|
|
48009
48252
|
const brand = brandNote(report);
|
|
48010
48253
|
if (brand) notes.push(brand);
|
|
48011
48254
|
const updates = listOfUpdates(report.googleUpdates, report.updateWindow);
|
|
@@ -48552,6 +48795,288 @@ async function sortedByDomainRating(rows, key) {
|
|
|
48552
48795
|
added: true
|
|
48553
48796
|
};
|
|
48554
48797
|
}
|
|
48798
|
+
// packages/core/dist/commands/simple-analytics.js
|
|
48799
|
+
const SIMPLE_ANALYTICS_KEY = "x-simpleanalytics-key";
|
|
48800
|
+
const simpleAnalyticsKey = (keys) => keys.get("x-simpleanalytics-key")?.trim() || null;
|
|
48801
|
+
const MAX_AI_TOOLS = 5;
|
|
48802
|
+
const MAX_AI_PAIRS = 4;
|
|
48803
|
+
const TOP = 10;
|
|
48804
|
+
const DAY = 864e5;
|
|
48805
|
+
const isoDay = (time) => new Date(time).toISOString().slice(0, 10);
|
|
48806
|
+
const BARE_AI = {
|
|
48807
|
+
chatgpt: "chatgpt",
|
|
48808
|
+
openai: "chatgpt",
|
|
48809
|
+
perplexity: "perplexity",
|
|
48810
|
+
claude: "claude",
|
|
48811
|
+
gemini: "gemini",
|
|
48812
|
+
copilot: "copilot",
|
|
48813
|
+
grok: "grok",
|
|
48814
|
+
deepseek: "deepseek"
|
|
48815
|
+
};
|
|
48816
|
+
const aiTool = (value) => aiReferralSourceForValue(value) ?? AI_REFERRAL_SOURCES.find((source) => source.id === BARE_AI[value.trim().toLowerCase()]);
|
|
48817
|
+
function hostsOf(site) {
|
|
48818
|
+
const text = site.trim().toLowerCase().replace(/^sc-domain:/u, "");
|
|
48819
|
+
let host;
|
|
48820
|
+
try {
|
|
48821
|
+
host = new URL(text.includes("://") ? text : `https://${text}`).hostname;
|
|
48822
|
+
} catch {
|
|
48823
|
+
host = text;
|
|
48824
|
+
}
|
|
48825
|
+
const bare = host.replace(/^www\./u, "");
|
|
48826
|
+
return [bare, `www.${bare}`];
|
|
48827
|
+
}
|
|
48828
|
+
const byVisitors = (a, b) => b.visitors - a.visitors || b.pageviews - a.pageviews || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0);
|
|
48829
|
+
async function readPeriod(key, hostname, range, filters, withPages) {
|
|
48830
|
+
const stats = await simpleAnalyticsStats(key, hostname, range, [
|
|
48831
|
+
"pageviews",
|
|
48832
|
+
"visitors",
|
|
48833
|
+
...withPages ? ["pages"] : [],
|
|
48834
|
+
"referrers",
|
|
48835
|
+
"utm_sources"
|
|
48836
|
+
], filters);
|
|
48837
|
+
const referrers = [...stats.referrers].sort(byVisitors);
|
|
48838
|
+
const utmSources = [...stats.utm_sources].sort(byVisitors);
|
|
48839
|
+
const tools = /* @__PURE__ */ new Map();
|
|
48840
|
+
const add = (rows, side) => {
|
|
48841
|
+
for (const row of rows) {
|
|
48842
|
+
const tool = aiTool(row.value);
|
|
48843
|
+
if (!tool || !row.visitors) continue;
|
|
48844
|
+
const entry = tools.get(tool.id) ?? {
|
|
48845
|
+
label: tool.label,
|
|
48846
|
+
refs: [],
|
|
48847
|
+
utms: []
|
|
48848
|
+
};
|
|
48849
|
+
entry[side].push(row);
|
|
48850
|
+
tools.set(tool.id, entry);
|
|
48851
|
+
}
|
|
48852
|
+
};
|
|
48853
|
+
add(referrers, "refs");
|
|
48854
|
+
add(utmSources, "utms");
|
|
48855
|
+
const sum = (rows) => rows.reduce((total, row) => total + row.visitors, 0);
|
|
48856
|
+
const ranked = [...tools.values()].map((tool) => ({
|
|
48857
|
+
...tool,
|
|
48858
|
+
total: sum(tool.refs) + sum(tool.utms)
|
|
48859
|
+
})).sort((a, b) => b.total - a.total || (a.label < b.label ? -1 : a.label > b.label ? 1 : 0));
|
|
48860
|
+
const counted = await Promise.all(ranked.slice(0, MAX_AI_TOOLS).map(async (tool) => {
|
|
48861
|
+
const pairs = tool.refs.flatMap((ref) => tool.utms.map((utm) => ({
|
|
48862
|
+
ref,
|
|
48863
|
+
utm
|
|
48864
|
+
}))).sort((a, b) => Math.min(b.ref.visitors, b.utm.visitors) - Math.min(a.ref.visitors, a.utm.visitors) || (a.ref.value + a.utm.value < b.ref.value + b.utm.value ? -1 : 1));
|
|
48865
|
+
const checked = pairs.slice(0, MAX_AI_PAIRS);
|
|
48866
|
+
const overlaps = await Promise.all(checked.map(async ({ ref, utm }) => (await simpleAnalyticsStats(key, hostname, range, ["visitors"], {
|
|
48867
|
+
...filters,
|
|
48868
|
+
referrer: ref.value,
|
|
48869
|
+
utm_source: utm.value
|
|
48870
|
+
})).visitors ?? 0));
|
|
48871
|
+
return {
|
|
48872
|
+
tool: tool.label,
|
|
48873
|
+
visitors: tool.total - overlaps.reduce((sum, n) => sum + n, 0),
|
|
48874
|
+
referrers: tool.refs.map((row) => row.value),
|
|
48875
|
+
utmSources: tool.utms.map((row) => row.value),
|
|
48876
|
+
exact: pairs.length <= MAX_AI_PAIRS
|
|
48877
|
+
};
|
|
48878
|
+
}));
|
|
48879
|
+
const full = (rows) => rows.length >= SIMPLE_ANALYTICS_LIMIT;
|
|
48880
|
+
return {
|
|
48881
|
+
hostname: stats.hostname,
|
|
48882
|
+
timezone: stats.timezone,
|
|
48883
|
+
range,
|
|
48884
|
+
visitors: stats.visitors ?? 0,
|
|
48885
|
+
pageviews: stats.pageviews ?? 0,
|
|
48886
|
+
pages: [...stats.pages].sort(byVisitors),
|
|
48887
|
+
referrers,
|
|
48888
|
+
utmSources,
|
|
48889
|
+
ai: {
|
|
48890
|
+
visitors: counted.reduce((total, tool) => total + tool.visitors, 0),
|
|
48891
|
+
tools: counted,
|
|
48892
|
+
notCounted: Math.max(0, ranked.length - MAX_AI_TOOLS)
|
|
48893
|
+
},
|
|
48894
|
+
capped: {
|
|
48895
|
+
pages: full(stats.pages),
|
|
48896
|
+
referrers: full(stats.referrers),
|
|
48897
|
+
utmSources: full(stats.utm_sources)
|
|
48898
|
+
}
|
|
48899
|
+
};
|
|
48900
|
+
}
|
|
48901
|
+
async function firstPeriod(site, read) {
|
|
48902
|
+
for (const hostname of hostsOf(site)) try {
|
|
48903
|
+
return await read(hostname);
|
|
48904
|
+
} catch (error) {
|
|
48905
|
+
if (error instanceof SimpleAnalyticsError && error.code === "not_found") continue;
|
|
48906
|
+
throw error;
|
|
48907
|
+
}
|
|
48908
|
+
return null;
|
|
48909
|
+
}
|
|
48910
|
+
function pageFilter(pages) {
|
|
48911
|
+
return pages?.startsWith("/") ? { pages: `${pages.replace(/\*+$/u, "")}*` } : {};
|
|
48912
|
+
}
|
|
48913
|
+
const top = (rows) => rows.slice(0, TOP).map((row) => `${row.value} ${row.visitors}`).join("; ");
|
|
48914
|
+
const aiNotes = (period) => [
|
|
48915
|
+
period.ai.tools.some((tool) => !tool.exact) ? `${period.ai.tools.filter((tool) => !tool.exact).map((tool) => tool.tool).join(", ")} came in more referrer and utm_source pairs than were checked, so a visitor with both can count twice there.` : "",
|
|
48916
|
+
period.ai.notCounted ? `${period.ai.notCounted} more AI ${period.ai.notCounted === 1 ? "tool is" : "tools are"} left out of this count.` : "",
|
|
48917
|
+
period.capped.referrers || period.capped.utmSources ? `A referrer or utm_source list reached Simple Analytics' ${SIMPLE_ANALYTICS_LIMIT}-row limit, so AI tools past it are missing, not zero.` : ""
|
|
48918
|
+
].filter(Boolean);
|
|
48919
|
+
const VISITORS_NOTE = "Visitors are Simple Analytics’ own count: a pageview with no referrer or one from another site, which it also counts as a visit. They are not Google Analytics sessions or users, or Search Console clicks.";
|
|
48920
|
+
const zoneNote = (period) => period.timezone ? `Days are in the website’s time zone, ${period.timezone}.` : "";
|
|
48921
|
+
const failure = (error) => error instanceof Error ? error.message : String(error);
|
|
48922
|
+
async function simpleAnalyticsBeside(keys, site, range, before, pages) {
|
|
48923
|
+
const key = keys ? simpleAnalyticsKey(keys) : null;
|
|
48924
|
+
if (!key) return null;
|
|
48925
|
+
const filters = pageFilter(pages);
|
|
48926
|
+
try {
|
|
48927
|
+
const now = await firstPeriod(site, (hostname) => readPeriod(key, hostname, range, filters, false));
|
|
48928
|
+
if (!now) return null;
|
|
48929
|
+
const then = await readPeriod(key, now.hostname, before, filters, false);
|
|
48930
|
+
const merged = (a, b, name) => {
|
|
48931
|
+
const rows = /* @__PURE__ */ new Map();
|
|
48932
|
+
for (const row of a) {
|
|
48933
|
+
const entry = rows.get(name(row)) ?? {
|
|
48934
|
+
visitors: 0,
|
|
48935
|
+
previousVisitors: 0
|
|
48936
|
+
};
|
|
48937
|
+
entry.visitors += row.visitors;
|
|
48938
|
+
rows.set(name(row), entry);
|
|
48939
|
+
}
|
|
48940
|
+
for (const row of b) {
|
|
48941
|
+
const entry = rows.get(name(row)) ?? {
|
|
48942
|
+
visitors: 0,
|
|
48943
|
+
previousVisitors: 0
|
|
48944
|
+
};
|
|
48945
|
+
entry.previousVisitors += row.visitors;
|
|
48946
|
+
rows.set(name(row), entry);
|
|
48947
|
+
}
|
|
48948
|
+
return [...rows].map(([key, entry]) => ({
|
|
48949
|
+
name: key,
|
|
48950
|
+
...entry
|
|
48951
|
+
})).sort((x, y) => y.visitors - x.visitors || y.previousVisitors - x.previousVisitors || (x.name < y.name ? -1 : x.name > y.name ? 1 : 0));
|
|
48952
|
+
};
|
|
48953
|
+
const was = (rows) => rows.slice(0, TOP).map((row) => `${row.name} ${row.visitors} (was ${row.previousVisitors})`).join(", ");
|
|
48954
|
+
const referrers = merged(now.referrers, then.referrers, (row) => row.value);
|
|
48955
|
+
const tools = merged(now.ai.tools, then.ai.tools, (row) => row.tool);
|
|
48956
|
+
const scope = filters.pages ? `, pages whose path starts with "${pages}"` : "";
|
|
48957
|
+
const notes = [
|
|
48958
|
+
VISITORS_NOTE,
|
|
48959
|
+
zoneNote(now),
|
|
48960
|
+
pages && !filters.pages ? `Simple Analytics narrows only to paths that start with some text, so these numbers cover the whole site, not pages containing "${pages}".` : "",
|
|
48961
|
+
now.capped.referrers || then.capped.referrers ? `The referrer list reached Simple Analytics' ${SIMPLE_ANALYTICS_LIMIT}-row limit, so referrers past it are missing, not zero.` : ""
|
|
48962
|
+
].filter(Boolean);
|
|
48963
|
+
return {
|
|
48964
|
+
text: `${[
|
|
48965
|
+
`Simple Analytics, website ${now.hostname}${scope}: visitors ${now.visitors} (was ${then.visitors}, ${change$2(pct(now.visitors, then.visitors))}), pageviews ${now.pageviews} (was ${then.pageviews}, ${change$2(pct(now.pageviews, then.pageviews))}).`,
|
|
48966
|
+
referrers.length ? `Top referrers (visitors): ${was(referrers)}.` : "",
|
|
48967
|
+
...notes
|
|
48968
|
+
].filter(Boolean).join(" ")}\n\n${[
|
|
48969
|
+
now.ai.visitors || then.ai.visitors ? `Visitors from AI assistants in Simple Analytics (referrers and utm_source tags, a visitor with both counted once): ${now.ai.visitors} (was ${then.ai.visitors}, ${change$2(pct(now.ai.visitors, then.ai.visitors))}). By tool: ${was(tools)}.` : now.capped.referrers || now.capped.utmSources ? "Visitors from AI assistants in Simple Analytics: none among the referrers and utm_source tags it listed, but a list reached its row limit, so this is unknown, not zero." : "Visitors from AI assistants in Simple Analytics: none in either period.",
|
|
48970
|
+
.../* @__PURE__ */ new Set([...aiNotes(now), ...aiNotes(then)]),
|
|
48971
|
+
"Only visits that pass a referrer or utm_source count; AI apps that send neither show as direct."
|
|
48972
|
+
].join(" ")}`,
|
|
48973
|
+
data: {
|
|
48974
|
+
hostname: now.hostname,
|
|
48975
|
+
timezone: now.timezone,
|
|
48976
|
+
...filters.pages ? { pathStartsWith: pages } : {},
|
|
48977
|
+
metric: "visitors",
|
|
48978
|
+
visitors: now.visitors,
|
|
48979
|
+
previousVisitors: then.visitors,
|
|
48980
|
+
visitorsChangePct: pct(now.visitors, then.visitors),
|
|
48981
|
+
pageviews: now.pageviews,
|
|
48982
|
+
previousPageviews: then.pageviews,
|
|
48983
|
+
referrers: referrers.map(({ name, ...row }) => ({
|
|
48984
|
+
referrer: name,
|
|
48985
|
+
...row
|
|
48986
|
+
})),
|
|
48987
|
+
aiAssistants: {
|
|
48988
|
+
visitors: now.ai.visitors,
|
|
48989
|
+
previousVisitors: then.ai.visitors,
|
|
48990
|
+
visitorsChangePct: pct(now.ai.visitors, then.ai.visitors),
|
|
48991
|
+
byTool: tools.map(({ name, ...row }) => ({
|
|
48992
|
+
tool: name,
|
|
48993
|
+
...row
|
|
48994
|
+
})),
|
|
48995
|
+
tools: now.ai.tools,
|
|
48996
|
+
previousTools: then.ai.tools
|
|
48997
|
+
},
|
|
48998
|
+
capped: {
|
|
48999
|
+
now: now.capped,
|
|
49000
|
+
before: then.capped
|
|
49001
|
+
},
|
|
49002
|
+
notes
|
|
49003
|
+
}
|
|
49004
|
+
};
|
|
49005
|
+
} catch (error) {
|
|
49006
|
+
return {
|
|
49007
|
+
text: `Simple Analytics: could not be read. ${failure(error)}`,
|
|
49008
|
+
data: { error: failure(error) }
|
|
49009
|
+
};
|
|
49010
|
+
}
|
|
49011
|
+
}
|
|
49012
|
+
async function runSimpleAnalyticsRows(input, keys, options) {
|
|
49013
|
+
const key = simpleAnalyticsKey(keys);
|
|
49014
|
+
if (!key) throw new CommandError("NO_KEY", `No Simple Analytics API key is saved. Add one: ${options.connect}`);
|
|
49015
|
+
let range;
|
|
49016
|
+
if (!input.startDate && !input.endDate) {
|
|
49017
|
+
const end = Date.now() - DAY;
|
|
49018
|
+
range = {
|
|
49019
|
+
startDate: isoDay(end - 27 * DAY),
|
|
49020
|
+
endDate: isoDay(end)
|
|
49021
|
+
};
|
|
49022
|
+
} else if (!input.startDate || !input.endDate || !(Date.parse(input.startDate) <= Date.parse(input.endDate))) throw new CommandError("INVALID_INPUT", "Send a start date and an end date together, in order.");
|
|
49023
|
+
else range = {
|
|
49024
|
+
startDate: input.startDate,
|
|
49025
|
+
endDate: input.endDate
|
|
49026
|
+
};
|
|
49027
|
+
let period;
|
|
49028
|
+
try {
|
|
49029
|
+
period = await firstPeriod(input.site, (hostname) => readPeriod(key, hostname, range, {}, true));
|
|
49030
|
+
} catch (error) {
|
|
49031
|
+
throw new CommandError(error instanceof SimpleAnalyticsError && error.code === "auth" ? "NO_ACCESS" : "PROVIDER_ERROR", error instanceof SimpleAnalyticsError && error.code === "auth" ? `${error.message} Save it again: ${options.connect}` : failure(error));
|
|
49032
|
+
}
|
|
49033
|
+
if (!period) throw new CommandError("NO_ACCESS", `Simple Analytics has no website ${hostsOf(input.site).join(" or ")} for this API key.`);
|
|
49034
|
+
const offset = input.offset ?? 0;
|
|
49035
|
+
const rows = period.pages.filter((row) => row.visitors > 0).map((row) => ({
|
|
49036
|
+
page: row.value,
|
|
49037
|
+
visitors: row.visitors,
|
|
49038
|
+
pageviews: row.pageviews
|
|
49039
|
+
}));
|
|
49040
|
+
const notes = [
|
|
49041
|
+
`Visitors ${period.visitors}, pageviews ${period.pageviews} in all. A page’s visitors are the visits that started on it; pages with pageviews but no visitors are left out.`,
|
|
49042
|
+
VISITORS_NOTE,
|
|
49043
|
+
zoneNote(period),
|
|
49044
|
+
period.referrers.length ? `Referrers (visitors): ${top(period.referrers)}.` : "Referrers: none in this range.",
|
|
49045
|
+
period.utmSources.length ? `utm_source tags (visitors): ${top(period.utmSources)}.` : "",
|
|
49046
|
+
period.ai.visitors ? `Visitors from AI assistants (referrers and utm_source tags, a visitor with both counted once): ${period.ai.visitors}. By tool: ${period.ai.tools.map((tool) => `${tool.tool} ${tool.visitors}`).join(", ")}.` : "Visitors from AI assistants: none among the referrers and utm_source tags listed.",
|
|
49047
|
+
...aiNotes(period),
|
|
49048
|
+
period.capped.pages ? `Simple Analytics returned its ${SIMPLE_ANALYTICS_LIMIT}-row limit of pages; pages past it are missing, not zero.` : ""
|
|
49049
|
+
].filter(Boolean);
|
|
49050
|
+
return {
|
|
49051
|
+
text: rowsText({
|
|
49052
|
+
title: `Simple Analytics website ${period.hostname}: landing pages, ${range.startDate} to ${range.endDate}.`,
|
|
49053
|
+
rows,
|
|
49054
|
+
offset,
|
|
49055
|
+
limit: 50,
|
|
49056
|
+
detail: input.detail ?? "summary",
|
|
49057
|
+
notes,
|
|
49058
|
+
more: options.call
|
|
49059
|
+
}),
|
|
49060
|
+
data: {
|
|
49061
|
+
hostname: period.hostname,
|
|
49062
|
+
timezone: period.timezone,
|
|
49063
|
+
range,
|
|
49064
|
+
metric: "visitors",
|
|
49065
|
+
visitors: period.visitors,
|
|
49066
|
+
pageviews: period.pageviews,
|
|
49067
|
+
referrers: period.referrers.slice(0, 50),
|
|
49068
|
+
utmSources: period.utmSources.slice(0, 50),
|
|
49069
|
+
aiAssistants: {
|
|
49070
|
+
visitors: period.ai.visitors,
|
|
49071
|
+
tools: period.ai.tools
|
|
49072
|
+
},
|
|
49073
|
+
capped: period.capped.pages,
|
|
49074
|
+
total: rows.length,
|
|
49075
|
+
offset,
|
|
49076
|
+
rows: rows.slice(offset, offset + 50)
|
|
49077
|
+
}
|
|
49078
|
+
};
|
|
49079
|
+
}
|
|
48555
49080
|
// packages/core/dist/commands/sitemap-urls.js
|
|
48556
49081
|
const MAX_FILES = 20;
|
|
48557
49082
|
const MAX_URLS = 5e4;
|
|
@@ -48768,6 +49293,12 @@ async function runPage(input, deps) {
|
|
|
48768
49293
|
});
|
|
48769
49294
|
}
|
|
48770
49295
|
rows.sort((a, b) => Number(b.clicks) - Number(a.clicks) || Number(b.impressions) - Number(a.impressions));
|
|
49296
|
+
const shaped = rows.map((row) => ({
|
|
49297
|
+
query: row.query,
|
|
49298
|
+
shape: queryShape(String(row.query ?? "")),
|
|
49299
|
+
...row
|
|
49300
|
+
}));
|
|
49301
|
+
const shapes = queryShapeLine(rows.map((row) => String(row.query ?? "")));
|
|
48771
49302
|
const sum = (list, key) => list.reduce((total, row) => total + row[key], 0);
|
|
48772
49303
|
const offset = input.offset ?? 0;
|
|
48773
49304
|
return {
|
|
@@ -48780,12 +49311,13 @@ async function runPage(input, deps) {
|
|
|
48780
49311
|
...reason ? [`Google's reason: ${reason.reason}. Label: ${reason.label}. ${reason.why} (Labels are rules over this evidence, not Google's; ${deps.call("index")} explains them.)`] : [],
|
|
48781
49312
|
...indexed && /^URL is unknown to Google$/i.test(indexed.coverage ?? "") ? [unknownNext(input, sitemap.urls.includes(input.url), deps)] : [],
|
|
48782
49313
|
`Query totals: clicks ${sum(now.rows, "clicks")} (was ${sum(then.rows, "clicks")}), impressions ${sum(now.rows, "impressions")} (was ${sum(then.rows, "impressions")}). Search Console hides rare queries, so these can be lower than the page total.`,
|
|
49314
|
+
...shapes ? [shapes] : [],
|
|
48783
49315
|
deps.pageMarkdown ? `Main content as Markdown: ${deps.call("page", {
|
|
48784
49316
|
url: input.url,
|
|
48785
49317
|
detail: "full"
|
|
48786
49318
|
})}.` : `Main content as Markdown: only in the CLI and the local MCP server, with \`npx -y seo page --url ${input.url} --detail full\`.`
|
|
48787
49319
|
],
|
|
48788
|
-
rows,
|
|
49320
|
+
rows: shaped,
|
|
48789
49321
|
offset,
|
|
48790
49322
|
limit: 50,
|
|
48791
49323
|
detail: input.detail ?? "summary",
|
|
@@ -48809,7 +49341,7 @@ async function runPage(input, deps) {
|
|
|
48809
49341
|
indexInspectedAt: savedAt,
|
|
48810
49342
|
reason,
|
|
48811
49343
|
totalQueries: rows.length,
|
|
48812
|
-
queries:
|
|
49344
|
+
queries: shaped.slice(offset, offset + 50),
|
|
48813
49345
|
...full ? { markdown } : {}
|
|
48814
49346
|
}
|
|
48815
49347
|
};
|
|
@@ -48886,7 +49418,7 @@ function markdownText(markdown, url) {
|
|
|
48886
49418
|
if (!markdown.markdown) return "Main content as Markdown: the page has no main content to read.";
|
|
48887
49419
|
return `Main content as Markdown (live page${markdown.truncated ? `, cut to ${markdown.markdown.length.toLocaleString("en-US")} of ${markdown.characters.toLocaleString("en-US")} characters` : ""}):\n\n${markdown.markdown}`;
|
|
48888
49420
|
}
|
|
48889
|
-
async function runCompare(input, deps) {
|
|
49421
|
+
async function runCompare(input, deps, keys) {
|
|
48890
49422
|
if (!realIsoDate(input.date)) throw new CommandError("INVALID_INPUT", "The date must be a real day as YYYY-MM-DD.");
|
|
48891
49423
|
const last = latestFinalGscDate(deps.now?.() ?? /* @__PURE__ */ new Date());
|
|
48892
49424
|
const daysAfter = Math.round((Date.parse(last) - Date.parse(input.date)) / 864e5) + 1;
|
|
@@ -48900,18 +49432,22 @@ async function runCompare(input, deps) {
|
|
|
48900
49432
|
startDate: shiftIsoDate(input.date, -days),
|
|
48901
49433
|
endDate: shiftIsoDate(input.date, -1)
|
|
48902
49434
|
};
|
|
48903
|
-
const [report, updates, analytics] = await Promise.all([
|
|
49435
|
+
const [report, updates, analytics, clicky, simpleAnalytics] = await Promise.all([
|
|
48904
49436
|
siteOverview(sharedReader(deps.searchAnalytics), input.site, after, before, input.pages),
|
|
48905
49437
|
googleUpdates({
|
|
48906
49438
|
start: before.startDate,
|
|
48907
49439
|
end: after.endDate
|
|
48908
49440
|
}),
|
|
48909
|
-
analyticsBeside(deps.analytics, input.site, after, before, input.pages)
|
|
49441
|
+
analyticsBeside(deps.analytics, input.site, after, before, input.pages),
|
|
49442
|
+
clickyBeside(keys, input.site, after, before, input.pages),
|
|
49443
|
+
simpleAnalyticsBeside(keys, input.site, after, before, input.pages)
|
|
48910
49444
|
]);
|
|
48911
49445
|
return {
|
|
48912
49446
|
text: [
|
|
48913
49447
|
overviewText(report, `Compare on ${input.site}: ${days} days after ${input.date}`, originOf(input.site), 10),
|
|
48914
49448
|
analytics?.text,
|
|
49449
|
+
clicky?.text,
|
|
49450
|
+
simpleAnalytics?.text,
|
|
48915
49451
|
listOfUpdates(updates),
|
|
48916
49452
|
`Next: ${deps.call("page")} for a page that moved.`,
|
|
48917
49453
|
FACTS_ONLY
|
|
@@ -48919,6 +49455,8 @@ async function runCompare(input, deps) {
|
|
|
48919
49455
|
data: {
|
|
48920
49456
|
...report,
|
|
48921
49457
|
...analytics ? { analytics: analytics.data } : {},
|
|
49458
|
+
...clicky ? { clicky: clicky.data } : {},
|
|
49459
|
+
...simpleAnalytics ? { simpleAnalytics: simpleAnalytics.data } : {},
|
|
48922
49460
|
googleUpdates: updates
|
|
48923
49461
|
}
|
|
48924
49462
|
};
|
|
@@ -49254,6 +49792,31 @@ function opportunityLines(site) {
|
|
|
49254
49792
|
" - Searches, CPC and intent are DataForSEO estimates, Domain Rating is by Ahrefs, fit with the site is a model classification and \"free tool\" is a guess from the words."
|
|
49255
49793
|
];
|
|
49256
49794
|
}
|
|
49795
|
+
const ENGINE_NAMES = {
|
|
49796
|
+
chatgpt: "ChatGPT search",
|
|
49797
|
+
google_ai_mode: "Google AI Mode",
|
|
49798
|
+
google_ai_overview: "AI Overviews"
|
|
49799
|
+
};
|
|
49800
|
+
function aiAnswerLines(site) {
|
|
49801
|
+
const found = site.ai_answers;
|
|
49802
|
+
if (!found) return [];
|
|
49803
|
+
if (found.blocked) return [`- AI answers: ${sentence(found.blocked)}`];
|
|
49804
|
+
if (!found.checked_at) return [];
|
|
49805
|
+
const day = (ms) => dayLabel(new Date(ms).toISOString().slice(0, 10));
|
|
49806
|
+
const { counts } = found;
|
|
49807
|
+
const answers = Object.values(counts).reduce((sum, n) => sum + n, 0);
|
|
49808
|
+
const unknown = [counts.unavailable ? `${count(counts.unavailable)} unavailable` : "", counts.pending ? `${count(counts.pending)} not ready yet` : ""].filter(Boolean);
|
|
49809
|
+
const engines = list(Object.values(ENGINE_NAMES));
|
|
49810
|
+
const lines = [`- AI answers, checked ${day(found.checked_at)}: ${plural(found.questions.length, "question")} from Search Console asked in ${engines}. Cited in ${count(counts.cited)} of ${plural(answers, "answer")}, mentioned by name in ${count(counts.mentioned)}, neither in ${count(counts.neither)}, no AI answer shown in ${count(counts.no_answer)}${unknown.length ? `, ${list(unknown)}` : ""}.`];
|
|
49811
|
+
if (found.previous_checked_at) {
|
|
49812
|
+
const shown = found.changes.slice(0, 10);
|
|
49813
|
+
const label = (result) => result.replace("_", " ");
|
|
49814
|
+
lines.push(shown.length ? ` - Changed since ${day(found.previous_checked_at)}:` : ` - No answer changed since ${day(found.previous_checked_at)}${counts.unavailable || counts.pending ? " among the ones known both weeks" : ""}.`, ...shown.map((change) => ` - "${change.question}" in ${ENGINE_NAMES[change.engine] ?? change.engine}: ${label(change.from)}, now ${label(change.to)}${change.cited_url ? ` (${change.cited_url})` : ""}.`), ...found.changes.length > shown.length ? [` - And ${plural(found.changes.length - shown.length, "more")}.`] : []);
|
|
49815
|
+
}
|
|
49816
|
+
if (found.cited_sites.length) lines.push(` - Sites cited instead: ${found.cited_sites.slice(0, 5).map((item) => `${item.host} (${item.answers})`).join(", ")}.`);
|
|
49817
|
+
lines.push(" - Each answer is one sample that can change from run to run, so one week’s change is not a trend.");
|
|
49818
|
+
return lines;
|
|
49819
|
+
}
|
|
49257
49820
|
function measuredLines(site) {
|
|
49258
49821
|
const found = site.measured;
|
|
49259
49822
|
if (!found?.total) return [];
|
|
@@ -49288,7 +49851,7 @@ function weekMarkdown(data) {
|
|
|
49288
49851
|
"",
|
|
49289
49852
|
attention.length ? total === 1 ? "Your site had changes worth a look this week." : `${attention.length} of your ${total} sites had changes worth a look this week.` : quiet.length ? total === 1 ? "Your site had a quiet week." : quiet.length === total ? `All ${total} of your sites had a quiet week.` : `${quiet.length} of your ${total} sites had a quiet week.` : "Your sites are still on their first checks."
|
|
49290
49853
|
];
|
|
49291
|
-
for (const { site, found } of rows) out.push("", `## ${siteName(site.property)}${found.length ? `: ${list(found.map((item) => item.heading))}` : ""}`, "", ...siteLines(site, startMs, endMs, data.first).map((line) => `- ${line}`), ...opportunityLines(site), ...measuredLines(site), ...updateLines(site), ...site.link ? [`- [View site](${site.link})`] : []);
|
|
49854
|
+
for (const { site, found } of rows) out.push("", `## ${siteName(site.property)}${found.length ? `: ${list(found.map((item) => item.heading))}` : ""}`, "", ...siteLines(site, startMs, endMs, data.first).map((line) => `- ${line}`), ...opportunityLines(site), ...aiAnswerLines(site), ...measuredLines(site), ...updateLines(site), ...site.link ? [`- [View site](${site.link})`] : []);
|
|
49292
49855
|
return out.join("\n");
|
|
49293
49856
|
}
|
|
49294
49857
|
async function runAllSites(deps, sites) {
|
|
@@ -49335,7 +49898,8 @@ const DATA_SOURCES = [
|
|
|
49335
49898
|
"search_console",
|
|
49336
49899
|
"google_analytics",
|
|
49337
49900
|
"bing",
|
|
49338
|
-
"clicky"
|
|
49901
|
+
"clicky",
|
|
49902
|
+
"simple_analytics"
|
|
49339
49903
|
];
|
|
49340
49904
|
function tool(spec) {
|
|
49341
49905
|
return spec;
|
|
@@ -49344,6 +49908,7 @@ const listSites = async (surface) => runSites({
|
|
|
49344
49908
|
accounts: await surface.accounts(),
|
|
49345
49909
|
keys: await surface.keys(),
|
|
49346
49910
|
clicky: clickySites(await surface.keys()).map(clickyLabel),
|
|
49911
|
+
simpleAnalytics: Boolean(simpleAnalyticsKey(await surface.keys())),
|
|
49347
49912
|
signIn: surface.signIn,
|
|
49348
49913
|
bing: surface.deps.bing ? await surface.deps.bing() : void 0,
|
|
49349
49914
|
connect: surface.connect
|
|
@@ -49472,7 +50037,7 @@ const SHARED_TOOLS = [
|
|
|
49472
50037
|
name: "seo_compare",
|
|
49473
50038
|
command: "compare",
|
|
49474
50039
|
title: "Before and after a date",
|
|
49475
|
-
description: "Compares equal periods before and after a date, such as a site change or a Google update: totals, devices, and the pages and queries that moved, Google Analytics sessions from the property whose web stream matches the site, and Google updates in the window. Optional pages narrows it to URLs that contain that text, such as /blog/.",
|
|
50040
|
+
description: "Compares equal periods before and after a date, such as a site change or a Google update: totals, devices, and the pages and queries that moved, Google Analytics sessions from the property whose web stream matches the site, Clicky visits from a saved Clicky site with the same domain, Simple Analytics visitors when an API key is saved and it has the site, and Google updates in the window. Optional pages narrows it to URLs that contain that text, such as /blog/.",
|
|
49476
50041
|
input: z.object({
|
|
49477
50042
|
site,
|
|
49478
50043
|
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("YYYY-MM-DD: the first day after the change."),
|
|
@@ -49482,7 +50047,7 @@ const SHARED_TOOLS = [
|
|
|
49482
50047
|
site: await surface.resolveSite(input.site),
|
|
49483
50048
|
date: input.date,
|
|
49484
50049
|
pages: input.pages
|
|
49485
|
-
}, surface.deps)
|
|
50050
|
+
}, surface.deps, await surface.keys())
|
|
49486
50051
|
}),
|
|
49487
50052
|
tool({
|
|
49488
50053
|
name: "seo_index",
|
|
@@ -49556,14 +50121,13 @@ const SHARED_TOOLS = [
|
|
|
49556
50121
|
name: "seo_data",
|
|
49557
50122
|
command: "data",
|
|
49558
50123
|
title: "Raw rows",
|
|
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;
|
|
50124
|
+
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; page_regex, query_regex and exclude_query_regex take RE2 regexes for custom cuts. 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). simple_analytics: landing-page visitors, referrers, utm_source tags and AI tools from Simple Analytics with the API key the person saved (site is its domain).`,
|
|
49560
50125
|
input: z.object({
|
|
49561
50126
|
source: z.enum(DATA_SOURCES).default("search_console"),
|
|
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."),
|
|
50127
|
+
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. simple_analytics: the site domain."),
|
|
49563
50128
|
dimensions: z.array(z.enum(DIMENSIONS)).max(4).default(["query"]).describe("search_console; bing uses the first, query or page."),
|
|
49564
50129
|
page: z.string().min(1).optional().describe("search_console only: URL text, such as /blog/."),
|
|
49565
50130
|
query: z.string().min(1).optional().describe("search_console only: query text."),
|
|
49566
|
-
query_preset: z.enum(QUERY_PRESET_NAMES).optional(),
|
|
49567
50131
|
page_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the page URL must match."),
|
|
49568
50132
|
query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the query must match."),
|
|
49569
50133
|
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."),
|
|
@@ -49571,6 +50135,16 @@ const SHARED_TOOLS = [
|
|
|
49571
50135
|
...detail
|
|
49572
50136
|
}),
|
|
49573
50137
|
run: async (surface, input) => {
|
|
50138
|
+
if (input.source === "simple_analytics") return runSimpleAnalyticsRows({
|
|
50139
|
+
site: input.site,
|
|
50140
|
+
startDate: input.start_date,
|
|
50141
|
+
endDate: input.end_date,
|
|
50142
|
+
detail: input.detail,
|
|
50143
|
+
offset: input.offset
|
|
50144
|
+
}, await surface.keys(), {
|
|
50145
|
+
connect: surface.connect,
|
|
50146
|
+
call: (offset) => `seo_data with source "simple_analytics", site "${input.site}", detail "rows", offset ${offset}`
|
|
50147
|
+
});
|
|
49574
50148
|
if (input.source === "clicky") return runClickyRows({
|
|
49575
50149
|
site: input.site,
|
|
49576
50150
|
startDate: input.start_date,
|
|
@@ -49608,7 +50182,6 @@ const SHARED_TOOLS = [
|
|
|
49608
50182
|
query: input.query,
|
|
49609
50183
|
pageRegex: input.page_regex,
|
|
49610
50184
|
queryRegex: input.query_regex,
|
|
49611
|
-
queryPreset: input.query_preset,
|
|
49612
50185
|
excludeQueryRegex: input.exclude_query_regex
|
|
49613
50186
|
}),
|
|
49614
50187
|
startDate: input.start_date,
|
|
@@ -49719,10 +50292,10 @@ const MCP_SERVER_INFO = {
|
|
|
49719
50292
|
}
|
|
49720
50293
|
]
|
|
49721
50294
|
};
|
|
49722
|
-
const MCP_INSTRUCTIONS = `SEO Skill reads the person's own Search Console, Google Analytics, Bing Webmaster Tools, Clicky and optional keyword accounts, and returns facts with their dates and limits. It gives no advice.
|
|
50295
|
+
const MCP_INSTRUCTIONS = `SEO Skill reads the person's own Search Console, Google Analytics, Bing Webmaster Tools, Clicky, Simple Analytics and optional keyword accounts, and returns facts with their dates and limits. It gives no advice.
|
|
49723
50296
|
1. seo_sites: the properties the connected accounts can read.
|
|
49724
50297
|
2. seo_report: start here. Without site it summarises last week across every site in the weekly site audit and names the site to ask about next. With site it shows that property's overview and every section's count and top rows; then ask for the one section you need. Section issues keeps a list of what it found for the site between sessions; mark records which the person fixed or wants ignored.
|
|
49725
|
-
3. seo_page for one URL, seo_compare for before and after a date, seo_index for Google's indexing reasons and pages that lost their clicks, seo_research for keyword, competitor and backlink data, and whether AI answers cite the site, from the DataForSEO or Ahrefs key the person saved, seo_data for raw rows, including Google Analytics, Bing and
|
|
50298
|
+
3. seo_page for one URL, seo_compare for before and after a date, seo_index for Google's indexing reasons and pages that lost their clicks, seo_research for keyword, competitor and backlink data, and whether AI answers cite the site, from the DataForSEO or Ahrefs key the person saved, seo_data for raw rows, including Google Analytics, Bing, Clicky and Simple Analytics.
|
|
49726
50299
|
4. seo_lint checks copy you are writing or editing (a landing page, blog post, title or meta description) for patterns common in AI-written text and for title and description length. It reads only the text or files you give it.`;
|
|
49727
50300
|
const mcpCall = (command, args) => {
|
|
49728
50301
|
const name = `seo_${command.replace("-", "_")}`;
|
|
@@ -49932,6 +50505,29 @@ async function readDataForSeoCredentials(input = {}) {
|
|
|
49932
50505
|
}
|
|
49933
50506
|
return migrateLegacyCredentials();
|
|
49934
50507
|
}
|
|
50508
|
+
// packages/core/dist/simple-analytics/credentials.js
|
|
50509
|
+
const SIMPLE_ANALYTICS_KEY_ENV = "SEO_SIMPLE_ANALYTICS_KEY";
|
|
50510
|
+
const SECRET = PROVIDER_SECRET_NAMES.simpleAnalyticsKey;
|
|
50511
|
+
function checked(value) {
|
|
50512
|
+
const key = value.trim();
|
|
50513
|
+
if (!isSimpleAnalyticsKey(key)) throw new ProviderError({
|
|
50514
|
+
provider: "simple-analytics",
|
|
50515
|
+
operation: "credentials",
|
|
50516
|
+
code: "configuration",
|
|
50517
|
+
message: "Simple Analytics needs an API key that starts with sa_api_key_ (Account settings, API keys)."
|
|
50518
|
+
});
|
|
50519
|
+
return key;
|
|
50520
|
+
}
|
|
50521
|
+
async function readSimpleAnalyticsKey() {
|
|
50522
|
+
const saved = await readProviderSecret({
|
|
50523
|
+
name: SECRET,
|
|
50524
|
+
envVar: SIMPLE_ANALYTICS_KEY_ENV
|
|
50525
|
+
});
|
|
50526
|
+
return saved ? {
|
|
50527
|
+
key: checked(saved.value),
|
|
50528
|
+
source: saved.source
|
|
50529
|
+
} : void 0;
|
|
50530
|
+
}
|
|
49935
50531
|
// packages/core/dist/storage/issues.js
|
|
49936
50532
|
const issuesFile = () => join(getSeoCliPaths().configDir, "issues.json");
|
|
49937
50533
|
function readFile$1() {
|
|
@@ -50030,10 +50626,11 @@ async function localAccounts() {
|
|
|
50030
50626
|
}));
|
|
50031
50627
|
}
|
|
50032
50628
|
async function localResearchKeys() {
|
|
50033
|
-
const [dataForSeo, ahrefs, clicky, saved] = await Promise.all([
|
|
50629
|
+
const [dataForSeo, ahrefs, clicky, simpleAnalytics, saved] = await Promise.all([
|
|
50034
50630
|
readDataForSeoCredentials().catch(() => void 0),
|
|
50035
50631
|
readAhrefsApiKey().catch(() => void 0),
|
|
50036
50632
|
readClickySiteKeys().catch(() => ({})),
|
|
50633
|
+
readSimpleAnalyticsKey().catch(() => void 0),
|
|
50037
50634
|
cloudLinked() ? cloudKeys().catch(() => ({})) : {}
|
|
50038
50635
|
]);
|
|
50039
50636
|
const keys = new Headers(saved);
|
|
@@ -50046,6 +50643,7 @@ async function localResearchKeys() {
|
|
|
50046
50643
|
keys.set("x-dataforseo-password", dataForSeo.password);
|
|
50047
50644
|
}
|
|
50048
50645
|
if (ahrefs?.apiKey) keys.set("x-ahrefs-key", ahrefs.apiKey);
|
|
50646
|
+
if (simpleAnalytics) keys.set(SIMPLE_ANALYTICS_KEY, simpleAnalytics.key);
|
|
50049
50647
|
return keys;
|
|
50050
50648
|
}
|
|
50051
50649
|
const TYPESAFE_API_KEY_ENV = "TYPESAFE_API_KEY";
|