seo 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/{dist-CzkHnL0G.js → dist-BjyKh54_.js} +1 -1
- package/dist/{dist-B-aQj-Q6.js → dist-DVNomFxR.js} +62 -62
- package/dist/dist-DVNomFxR.js.map +1 -0
- package/dist/{esm-X4uq3k2w.js → esm-vb8HxBFD.js} +2 -2
- package/dist/{esm-X4uq3k2w.js.map → esm-vb8HxBFD.js.map} +1 -1
- package/dist/index.d.ts +47 -46
- package/dist/index.js +184 -56
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +184 -56
- package/dist/mcp.js.map +1 -1
- package/package.json +2 -30
- package/dist/dist-B-aQj-Q6.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
|
|
3
|
-
import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Bt as l,C as u,Cn as d,Cr as f,Ct as ee,D as p,Dn as te,Dr as m,Dt as h,E as ne,En as re,Er as ie,Et as ae,F as oe,Fn as se,Ft as ce,G as le,Gn as ue,Gt as de,H as fe,Hn as pe,Ht as me,I as he,In as ge,It as _e,J as ve,Jn as ye,Jt as be,K as xe,Kn as Se,Kt as Ce,L as we,Ln as Te,Lt as Ee,M as De,Mn as Oe,Mr as ke,Mt as Ae,N as je,Nn as Me,Nt as Ne,O as Pe,On as Fe,Or as g,P as Ie,Pn as Le,Pt as Re,Q as ze,Qn as Be,Qt as Ve,R as He,Rn as Ue,Rt as We,S as Ge,Sn as Ke,Sr as qe,St as Je,T as Ye,Tn as Xe,Tr as Ze,Tt as Qe,U as $e,Un as et,Ut as tt,V as nt,Vn as rt,Vt as it,W as at,Wn as ot,Wt as st,X as ct,Xn as lt,Xt as ut,Y as dt,Yn as ft,Yt as pt,Z as mt,Zn as ht,Zt as gt,_ as _t,_n as vt,_r as yt,_t as bt,a as xt,an as St,ar as Ct,at as wt,b as Tt,bn as Et,br as Dt,bt as Ot,c as kt,cn as At,cr as jt,ct as Mt,d as Nt,dn as Pt,dr as Ft,dt as It,en as Lt,er as Rt,et as zt,f as Bt,fn as Vt,fr as Ht,ft as Ut,g as Wt,gn as Gt,gr as Kt,gt as qt,h as Jt,hn as Yt,hr as Xt,ht as Zt,i as Qt,in as $t,ir as en,it as tn,j as nn,jn as rn,jr as an,jt as on,k as sn,kn as cn,kr as ln,kt as un,l as dn,ln as fn,lr as pn,lt as mn,m as hn,mn as gn,mr as _n,mt as vn,nn as yn,nr as bn,nt as xn,o as Sn,on as Cn,or as wn,ot as Tn,p as En,pn as Dn,pr as On,pt as kn,q as An,qn as jn,qt as Mn,rn as Nn,rr as Pn,rt as Fn,sn as In,sr as Ln,st as Rn,t as zn,tn as Bn,tr as Vn,tt as Hn,u as Un,un as Wn,ur as Gn,ut as Kn,v as qn,vn as Jn,vr as Yn,vt as Xn,w as Zn,wn as Qn,wr as $n,wt as er,x as tr,xn as nr,xr as rr,xt as ir,y as ar,yn as or,yr as sr,yt as cr,z as lr,zn as ur,zt as dr}from"./dist-B-aQj-Q6.js";import{randomBytes as fr}from"node:crypto";import{arch as pr,homedir as mr,platform as hr}from"node:os";import{basename as gr,dirname as _r,join as _,posix as vr,relative as yr,resolve as br,sep as xr,win32 as Sr}from"node:path";import{constants as Cr,copyFileSync as wr,createWriteStream as Tr,existsSync as v,mkdirSync as Er,readFileSync as Dr,readdirSync as Or,realpathSync as kr,renameSync as Ar,rmSync as jr,statSync as Mr,writeFileSync as Nr}from"node:fs";import{fileURLToPath as Pr}from"node:url";import{cp as Fr,mkdir as Ir,open as Lr,readFile as y,readdir as Rr,rename as zr,stat as Br,writeFile as Vr}from"node:fs/promises";import{isDeepStrictEqual as Hr,stripVTControlCharacters as Ur}from"node:util";import{spawn as Wr,spawnSync as Gr}from"node:child_process";import{defineCommand as b,runCommand as Kr,runMain as qr}from"citty";import{cancel as Jr,confirm as Yr,intro as Xr,isCancel as Zr,log as Qr,multiselect as $r,note as x,outro as S,password as ei,select as ti,text as ni}from"@clack/prompts";import ri from"picocolors";import ii from"string-width";import ai from"cli-table3";import{finished as oi}from"node:stream/promises";import{applyEdits as si,modify as ci,parse as li,printParseErrorCode as ui}from"jsonc-parser";import di from"update-notifier";const C={summary:/* @__PURE__ */ `workflow.site.generated_at.summary.attribution.confidence.classification.updates_matched.known_confounders.page_segment_status.page_segment_eligible_rows.page_segment_returned_rows.page_segment_limited_rows.page_segment_result_limit.page_segment_source_row_limit.page_segment_source_possibly_truncated.page_segment_warnings.query_segment_status.query_segment_eligible_rows.query_segment_returned_rows.query_segment_limited_rows.query_segment_result_limit.query_segment_source_row_limit.query_segment_source_possibly_truncated.query_segment_warnings.device_segment_status.device_segment_eligible_rows.device_segment_returned_rows.device_segment_limited_rows.device_segment_result_limit.device_segment_source_row_limit.device_segment_source_possibly_truncated.device_segment_warnings.country_segment_status.country_segment_eligible_rows.country_segment_returned_rows.country_segment_limited_rows.country_segment_result_limit.country_segment_source_row_limit.country_segment_source_possibly_truncated.country_segment_warnings`.split(`.`),steps:[`rank`,`tool`,`status`,`summary`],actions:[`rank`,`title`,`confidence`,`action`],findings:[`dimension`,`data_status`,`eligible_rows`,`returned_rows`,`limited_rows`,`result_limit`,`unmatched_rows`,`summary`,`winner_key`,`winner_click_delta`,`winner_impression_delta`,`winner_position_delta`,`loser_key`,`loser_click_delta`,`loser_impression_delta`,`loser_position_delta`],templates:[`rank`,`direction`,`template`,`confidence`,`url_count`,`click_delta`,`impression_delta`,`movement_share`,`movement_share_scope`,`confidence_scope`,`eligible_rows`,`returned_rows`,`limited_rows`,`result_limit`,`source_possibly_truncated`,`common_terms`,`sample_urls`,`summary`],evidence:[`rank`,`evidence`],confounders:[`rank`,`source`,`title`,`date`,`scope`,`target`,`description`],segment:[`rank`,`dimension`,`data_status`,`evidence_scope`,`key`,`before_clicks`,`after_clicks`,`click_delta`,`before_impressions`,`after_impressions`,`impression_delta`,`before_position`,`after_position`,`position_delta`],unmatchedSegment:[`rank`,`dimension`,`data_status`,`key`,`retained_in`,`clicks`,`impressions`,`position`,`reason`]};function fi(e,t){return[...e.output.segments[t].winners,...e.output.segments[t].losers].map((n,r)=>({rank:r+1,dimension:t,data_status:e.output.segments[t].dataStatus,evidence_scope:n.evidenceScope,key:n.key,before_clicks:n.beforeClicks,after_clicks:n.afterClicks,click_delta:n.clickDelta,before_impressions:n.beforeImpressions,after_impressions:n.afterImpressions,impression_delta:n.impressionDelta,before_position:n.beforePosition,after_position:n.afterPosition,position_delta:n.positionDelta}))}function pi(e,t){return e.output.segments[t].unmatchedSegments.map((n,r)=>({rank:r+1,dimension:t,data_status:e.output.segments[t].dataStatus,key:n.key,retained_in:n.retainedIn,clicks:n.clicks,impressions:n.impressions,position:n.position,reason:n.reason}))}function mi(e){return[{filename:`postmortem-summary.csv`,headers:[...C.summary],rows:[{workflow:e.workflow,site:e.site,generated_at:e.generatedAt,summary:e.summary,attribution:e.output.update.attribution,confidence:e.output.update.confidence,classification:e.output.update.classification,updates_matched:e.output.update.overlappingUpdates.length,known_confounders:e.output.update.confounders.length,page_segment_status:e.output.segments.page.dataStatus,page_segment_eligible_rows:e.output.segments.page.coverage.eligibleRows,page_segment_returned_rows:e.output.segments.page.coverage.returnedRows,page_segment_limited_rows:e.output.segments.page.coverage.limitedRows,page_segment_result_limit:e.output.segments.page.coverage.resultLimit,page_segment_source_row_limit:e.output.segments.page.coverage.sourceRowLimit,page_segment_source_possibly_truncated:e.output.segments.page.coverage.sourcePossiblyTruncated,page_segment_warnings:e.output.segments.page.warnings.join(`; `),query_segment_status:e.output.segments.query.dataStatus,query_segment_eligible_rows:e.output.segments.query.coverage.eligibleRows,query_segment_returned_rows:e.output.segments.query.coverage.returnedRows,query_segment_limited_rows:e.output.segments.query.coverage.limitedRows,query_segment_result_limit:e.output.segments.query.coverage.resultLimit,query_segment_source_row_limit:e.output.segments.query.coverage.sourceRowLimit,query_segment_source_possibly_truncated:e.output.segments.query.coverage.sourcePossiblyTruncated,query_segment_warnings:e.output.segments.query.warnings.join(`; `),device_segment_status:e.output.segments.device.dataStatus,device_segment_eligible_rows:e.output.segments.device.coverage.eligibleRows,device_segment_returned_rows:e.output.segments.device.coverage.returnedRows,device_segment_limited_rows:e.output.segments.device.coverage.limitedRows,device_segment_result_limit:e.output.segments.device.coverage.resultLimit,device_segment_source_row_limit:e.output.segments.device.coverage.sourceRowLimit,device_segment_source_possibly_truncated:e.output.segments.device.coverage.sourcePossiblyTruncated,device_segment_warnings:e.output.segments.device.warnings.join(`; `),country_segment_status:e.output.segments.country.dataStatus,country_segment_eligible_rows:e.output.segments.country.coverage.eligibleRows,country_segment_returned_rows:e.output.segments.country.coverage.returnedRows,country_segment_limited_rows:e.output.segments.country.coverage.limitedRows,country_segment_result_limit:e.output.segments.country.coverage.resultLimit,country_segment_source_row_limit:e.output.segments.country.coverage.sourceRowLimit,country_segment_source_possibly_truncated:e.output.segments.country.coverage.sourcePossiblyTruncated,country_segment_warnings:e.output.segments.country.warnings.join(`; `)}]},{filename:`workflow-steps.csv`,headers:[...C.steps],rows:e.steps.map((e,t)=>({rank:t+1,tool:e.tool,status:e.status,summary:e.summary}))},{filename:`workflow-actions.csv`,headers:[...C.actions],rows:e.actions.map((e,t)=>({rank:t+1,title:e.title,confidence:e.confidence,action:e.action}))},{filename:`postmortem-findings.csv`,headers:[...C.findings],rows:e.output.insights.map(e=>({dimension:e.dimension,data_status:e.dataStatus,eligible_rows:e.coverage.eligibleRows,returned_rows:e.coverage.returnedRows,limited_rows:e.coverage.limitedRows,result_limit:e.coverage.resultLimit,unmatched_rows:e.unmatchedRows,summary:e.summary,winner_key:e.winner?.key,winner_click_delta:e.winner?.clickDelta,winner_impression_delta:e.winner?.impressionDelta,winner_position_delta:e.winner?.positionDelta,loser_key:e.loser?.key,loser_click_delta:e.loser?.clickDelta,loser_impression_delta:e.loser?.impressionDelta,loser_position_delta:e.loser?.positionDelta}))},{filename:`postmortem-template-movement.csv`,headers:[...C.templates],rows:e.output.templateMovement.map((e,t)=>({rank:t+1,direction:e.direction,template:e.signature,confidence:e.confidence,url_count:e.urlCount,click_delta:e.clickDelta,impression_delta:e.impressionDelta,movement_share:e.movementShare,movement_share_scope:e.movementShareScope,confidence_scope:e.confidenceScope,eligible_rows:e.segmentCoverage.eligibleRows,returned_rows:e.segmentCoverage.returnedRows,limited_rows:e.segmentCoverage.limitedRows,result_limit:e.segmentCoverage.resultLimit,source_possibly_truncated:e.segmentCoverage.sourcePossiblyTruncated,common_terms:e.commonTerms.join(`; `),sample_urls:e.sampleUrls.join(`; `),summary:e.summary}))},{filename:`postmortem-update-evidence.csv`,headers:[...C.evidence],rows:e.output.update.evidence.map((e,t)=>({rank:t+1,evidence:e}))},{filename:`postmortem-confounders.csv`,headers:[...C.confounders],rows:e.output.update.confounders.map((e,t)=>({rank:t+1,source:e.source,title:e.title,date:e.date,scope:e.scope,target:e.target,description:e.description}))},...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}.csv`,headers:[...C.segment],rows:fi(e,t)})),...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}-unmatched.csv`,headers:[...C.unmatchedSegment],rows:pi(e,t)}))]}function hi(e){return v(e)?Or(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.log`)).map(t=>{let n=_(e,t.name),r=Mr(n);return{path:n,size:r.size,modifiedAt:r.mtimeMs}}):[]}function gi(e,t){let n=_r(e),r=gr(e,`.log`),i=0;for(;;){let e=_(n,`${r}.${t}${i?`-${i}`:``}.log`);if(!v(e))return e;i+=1}}function _i(e={}){let t=e.directory??qe().logDir,n=e.now??Date.now(),r=e.maxFileBytes??8388608,i=e.maxTotalBytes??67108864,a=e.maxAgeMs??12096e5;Er(t,{recursive:!0,mode:448});let o=0,s=0;for(let e of hi(t))e.size<=r||(Ar(e.path,gi(e.path,n)),o+=1);for(let e of hi(t))e.modifiedAt>=n-a||(jr(e.path,{force:!0}),s+=1);let c=hi(t).sort((e,t)=>e.modifiedAt-t.modifiedAt||(e.path<t.path?-1:+(e.path>t.path))),l=c.reduce((e,t)=>e+t.size,0);for(let e of c){if(l<=i)break;jr(e.path,{force:!0}),l-=e.size,s+=1}return{rotated:o,removed:s,sizeBytes:l}}function vi(e){let t=e-Date.now();if(t<=0)return`expired`;let n=Math.round(t/6e4);if(n<60)return`in ${n}m`;let r=Math.floor(n/60),i=n%60;return i?`in ${r}h ${i}m`:`in ${r}h`}function yi(e,t){return{type:`boolean`,default:!0,description:e,negativeDescription:t}}function w(e){return typeof e==`string`?e:void 0}function T(e){return typeof e==`boolean`?e:void 0}function bi(e){let t=w(e.rendering);if(t!==void 0&&t!==`auto`&&t!==`on`&&t!==`off`)throw new g(`INVALID_INPUT`,`--rendering must be auto, on, or off.`);if(T(e.js)===!0&&t&&t!==`on`)throw new g(`INVALID_INPUT`,`Use either --js or --rendering on, not both with different modes.`);return t??(T(e.js)?`on`:`auto`)}function E(e,t){let n=T(e[t]);if(n===!1)return!0;if(n===!0)return!1;let r=T(e[xi(t)]);if(r===!1)return!0;if(r===!0)return!1;if(T(e[`no-${t}`])===!0||T(e[`no${Si(t)}`])===!0)return!0}function xi(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Si(e){let t=xi(e);return t?`${t[0]?.toUpperCase()}${t.slice(1)}`:``}function D(e){if(typeof e==`number`)return e;if(typeof e!=`string`||!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function O(e,t){if(e===void 0||e===``)return;let n=D(e);if(n===void 0)throw new g(`INVALID_INPUT`,`${t} must be a number.`);return n}function k(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function Ci(e){return k(e)??[]}function wi(e){let t={concurrency:D(e[`fetch-concurrency`]),intervalCap:D(e[`fetch-interval-cap`]),intervalMs:D(e[`fetch-interval-ms`])};return Object.values(t).some(e=>e!==void 0)?t:void 0}function A(e){return e.json===!0}async function Ti(e,t){let n=w(e),r=w(t);if(n&&r)throw Error(`Use either --body or --body-file, not both.`);if(!n&&!r)return;let i=n??await y(r??``,`utf8`),a=JSON.parse(i);if(!a||typeof a!=`object`||Array.isArray(a))throw Error(`JSON body must be an object.`);return a}function j(e){if(e)return e;throw new g(`INVALID_INPUT`,"No site given. Pass --site with a domain, URL or sc-domain: property. Run `seo sites` to list your Search Console properties.")}async function Ei(e,t={}){let n=j(e),r=(await Fe(t.refresh,t.account)).map(e=>e.siteUrl),i=$n(r,n);if(!i)throw new g(`PROPERTY_NOT_FOUND`,`This Google login has no Search Console property for ${n}. Run \`seo sites\` to list the properties it can read.`);return i}function Di(e){if(e)return e;throw new g(`INVALID_INPUT`,"No Google Analytics property given. Pass --property with the numeric property id. Run `seo analytics google properties` to list them.")}function Oi(e){if(typeof e==`number`)return Number.isFinite(e)?Math.round(e):void 0;if(!e)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function ki(e={}){let t=e.env??process.env,n=Oi(e.columns)??Oi(e.streamColumns)??Oi(t.COLUMNS)??80;return Math.min(200,Math.max(40,n))}function M(e={}){let t=e.env??process.env,n=e.isTTY??!!process.stdout.isTTY,r=e.color??!!(n&&t.NO_COLOR===void 0);return{columns:ki({...e,env:t,streamColumns:e.streamColumns??process.stdout.columns}),colors:ri.createColors(r),hasColor:r,isInteractive:n&&!t.CI}}function N(e){return ii(Ur(e))}function Ai(e,t){let n=[],r=``;for(let i of e)r&&N(`${r}${i}`)>t?(n.push(r),r=i):r+=i;return r&&n.push(r),n}function ji(e,t){if(!e)return[``];let n=e.trim().split(/\s+/u),r=[],i=``;for(let e of n){let n=N(e)>t?Ai(e,t):[e];for(let e of n)i?N(`${i} ${e}`)<=t?i+=` ${e}`:(r.push(i),i=e):i=e}return i&&r.push(i),r.length>0?r:[``]}function P(e,t){let n=Math.max(1,t);return e.replaceAll(`\r
|
|
3
|
+
import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Bt as l,C as u,Cn as d,Cr as f,Ct as ee,D as p,Dn as te,Dr as m,Dt as h,E as ne,En as re,Er as ie,Et as ae,F as oe,Fn as se,Ft as ce,G as le,Gn as ue,Gt as de,H as fe,Hn as pe,Ht as me,I as he,In as ge,It as _e,J as ve,Jn as ye,Jt as be,K as xe,Kn as Se,Kt as Ce,L as we,Ln as Te,Lt as Ee,M as De,Mn as Oe,Mr as ke,Mt as Ae,N as je,Nn as Me,Nt as Ne,O as Pe,On as Fe,Or as g,P as Ie,Pn as Le,Pt as Re,Q as ze,Qn as Be,Qt as Ve,R as He,Rn as Ue,Rt as We,S as Ge,Sn as Ke,Sr as qe,St as Je,T as Ye,Tn as Xe,Tr as Ze,Tt as Qe,U as $e,Un as et,Ut as tt,V as nt,Vn as rt,Vt as it,W as at,Wn as ot,Wt as st,X as ct,Xn as lt,Xt as ut,Y as dt,Yn as ft,Yt as pt,Z as mt,Zn as ht,Zt as gt,_ as _t,_n as vt,_r as yt,_t as bt,a as xt,an as St,ar as Ct,at as wt,b as Tt,bn as Et,br as Dt,bt as Ot,c as kt,cn as At,cr as jt,ct as Mt,d as Nt,dn as Pt,dr as Ft,dt as It,en as Lt,er as Rt,et as zt,f as Bt,fn as Vt,fr as Ht,ft as Ut,g as Wt,gn as Gt,gr as Kt,gt as qt,h as Jt,hn as Yt,hr as Xt,ht as Zt,i as Qt,in as $t,ir as en,it as tn,j as nn,jn as rn,jr as an,jt as on,k as sn,kn as cn,kr as ln,kt as un,l as dn,ln as fn,lr as pn,lt as mn,m as hn,mn as gn,mr as _n,mt as vn,nn as yn,nr as bn,nt as xn,o as Sn,on as Cn,or as wn,ot as Tn,p as En,pn as Dn,pr as On,pt as kn,q as An,qn as jn,qt as Mn,rn as Nn,rr as Pn,rt as Fn,sn as In,sr as Ln,st as Rn,t as zn,tn as Bn,tr as Vn,tt as Hn,u as Un,un as Wn,ur as Gn,ut as Kn,v as qn,vn as Jn,vr as Yn,vt as Xn,w as Zn,wn as Qn,wr as $n,wt as er,x as tr,xn as nr,xr as rr,xt as ir,y as ar,yn as or,yr as sr,yt as cr,z as lr,zn as ur,zt as dr}from"./dist-DVNomFxR.js";import{randomBytes as fr}from"node:crypto";import{arch as pr,homedir as mr,platform as hr}from"node:os";import{basename as gr,dirname as _r,join as _,posix as vr,relative as yr,resolve as br,sep as xr,win32 as Sr}from"node:path";import{constants as Cr,copyFileSync as wr,createWriteStream as Tr,existsSync as v,mkdirSync as Er,readFileSync as Dr,readdirSync as Or,realpathSync as kr,renameSync as Ar,rmSync as jr,statSync as Mr,writeFileSync as Nr}from"node:fs";import{fileURLToPath as Pr}from"node:url";import{cp as Fr,mkdir as Ir,open as Lr,readFile as y,readdir as Rr,rename as zr,stat as Br,writeFile as Vr}from"node:fs/promises";import{isDeepStrictEqual as Hr,stripVTControlCharacters as Ur}from"node:util";import{spawn as Wr,spawnSync as Gr}from"node:child_process";import{defineCommand as b,runCommand as Kr,runMain as qr}from"citty";import{cancel as Jr,confirm as Yr,intro as Xr,isCancel as Zr,log as Qr,multiselect as $r,note as x,outro as S,password as ei,select as ti,text as ni}from"@clack/prompts";import ri from"picocolors";import ii from"string-width";import ai from"cli-table3";import{finished as oi}from"node:stream/promises";import{applyEdits as si,modify as ci,parse as li,printParseErrorCode as ui}from"jsonc-parser";import di from"update-notifier";const C={summary:/* @__PURE__ */ `workflow.site.generated_at.summary.attribution.confidence.classification.updates_matched.known_confounders.page_segment_status.page_segment_eligible_rows.page_segment_returned_rows.page_segment_limited_rows.page_segment_result_limit.page_segment_source_row_limit.page_segment_source_possibly_truncated.page_segment_warnings.query_segment_status.query_segment_eligible_rows.query_segment_returned_rows.query_segment_limited_rows.query_segment_result_limit.query_segment_source_row_limit.query_segment_source_possibly_truncated.query_segment_warnings.device_segment_status.device_segment_eligible_rows.device_segment_returned_rows.device_segment_limited_rows.device_segment_result_limit.device_segment_source_row_limit.device_segment_source_possibly_truncated.device_segment_warnings.country_segment_status.country_segment_eligible_rows.country_segment_returned_rows.country_segment_limited_rows.country_segment_result_limit.country_segment_source_row_limit.country_segment_source_possibly_truncated.country_segment_warnings`.split(`.`),steps:[`rank`,`tool`,`status`,`summary`],actions:[`rank`,`title`,`confidence`,`action`],findings:[`dimension`,`data_status`,`eligible_rows`,`returned_rows`,`limited_rows`,`result_limit`,`unmatched_rows`,`summary`,`winner_key`,`winner_click_delta`,`winner_impression_delta`,`winner_position_delta`,`loser_key`,`loser_click_delta`,`loser_impression_delta`,`loser_position_delta`],templates:[`rank`,`direction`,`template`,`confidence`,`url_count`,`click_delta`,`impression_delta`,`movement_share`,`movement_share_scope`,`confidence_scope`,`eligible_rows`,`returned_rows`,`limited_rows`,`result_limit`,`source_possibly_truncated`,`common_terms`,`sample_urls`,`summary`],evidence:[`rank`,`evidence`],confounders:[`rank`,`source`,`title`,`date`,`scope`,`target`,`description`],segment:[`rank`,`dimension`,`data_status`,`evidence_scope`,`key`,`before_clicks`,`after_clicks`,`click_delta`,`before_impressions`,`after_impressions`,`impression_delta`,`before_position`,`after_position`,`position_delta`],unmatchedSegment:[`rank`,`dimension`,`data_status`,`key`,`retained_in`,`clicks`,`impressions`,`position`,`reason`]};function fi(e,t){return[...e.output.segments[t].winners,...e.output.segments[t].losers].map((n,r)=>({rank:r+1,dimension:t,data_status:e.output.segments[t].dataStatus,evidence_scope:n.evidenceScope,key:n.key,before_clicks:n.beforeClicks,after_clicks:n.afterClicks,click_delta:n.clickDelta,before_impressions:n.beforeImpressions,after_impressions:n.afterImpressions,impression_delta:n.impressionDelta,before_position:n.beforePosition,after_position:n.afterPosition,position_delta:n.positionDelta}))}function pi(e,t){return e.output.segments[t].unmatchedSegments.map((n,r)=>({rank:r+1,dimension:t,data_status:e.output.segments[t].dataStatus,key:n.key,retained_in:n.retainedIn,clicks:n.clicks,impressions:n.impressions,position:n.position,reason:n.reason}))}function mi(e){return[{filename:`postmortem-summary.csv`,headers:[...C.summary],rows:[{workflow:e.workflow,site:e.site,generated_at:e.generatedAt,summary:e.summary,attribution:e.output.update.attribution,confidence:e.output.update.confidence,classification:e.output.update.classification,updates_matched:e.output.update.overlappingUpdates.length,known_confounders:e.output.update.confounders.length,page_segment_status:e.output.segments.page.dataStatus,page_segment_eligible_rows:e.output.segments.page.coverage.eligibleRows,page_segment_returned_rows:e.output.segments.page.coverage.returnedRows,page_segment_limited_rows:e.output.segments.page.coverage.limitedRows,page_segment_result_limit:e.output.segments.page.coverage.resultLimit,page_segment_source_row_limit:e.output.segments.page.coverage.sourceRowLimit,page_segment_source_possibly_truncated:e.output.segments.page.coverage.sourcePossiblyTruncated,page_segment_warnings:e.output.segments.page.warnings.join(`; `),query_segment_status:e.output.segments.query.dataStatus,query_segment_eligible_rows:e.output.segments.query.coverage.eligibleRows,query_segment_returned_rows:e.output.segments.query.coverage.returnedRows,query_segment_limited_rows:e.output.segments.query.coverage.limitedRows,query_segment_result_limit:e.output.segments.query.coverage.resultLimit,query_segment_source_row_limit:e.output.segments.query.coverage.sourceRowLimit,query_segment_source_possibly_truncated:e.output.segments.query.coverage.sourcePossiblyTruncated,query_segment_warnings:e.output.segments.query.warnings.join(`; `),device_segment_status:e.output.segments.device.dataStatus,device_segment_eligible_rows:e.output.segments.device.coverage.eligibleRows,device_segment_returned_rows:e.output.segments.device.coverage.returnedRows,device_segment_limited_rows:e.output.segments.device.coverage.limitedRows,device_segment_result_limit:e.output.segments.device.coverage.resultLimit,device_segment_source_row_limit:e.output.segments.device.coverage.sourceRowLimit,device_segment_source_possibly_truncated:e.output.segments.device.coverage.sourcePossiblyTruncated,device_segment_warnings:e.output.segments.device.warnings.join(`; `),country_segment_status:e.output.segments.country.dataStatus,country_segment_eligible_rows:e.output.segments.country.coverage.eligibleRows,country_segment_returned_rows:e.output.segments.country.coverage.returnedRows,country_segment_limited_rows:e.output.segments.country.coverage.limitedRows,country_segment_result_limit:e.output.segments.country.coverage.resultLimit,country_segment_source_row_limit:e.output.segments.country.coverage.sourceRowLimit,country_segment_source_possibly_truncated:e.output.segments.country.coverage.sourcePossiblyTruncated,country_segment_warnings:e.output.segments.country.warnings.join(`; `)}]},{filename:`workflow-steps.csv`,headers:[...C.steps],rows:e.steps.map((e,t)=>({rank:t+1,tool:e.tool,status:e.status,summary:e.summary}))},{filename:`workflow-actions.csv`,headers:[...C.actions],rows:e.actions.map((e,t)=>({rank:t+1,title:e.title,confidence:e.confidence,action:e.action}))},{filename:`postmortem-findings.csv`,headers:[...C.findings],rows:e.output.insights.map(e=>({dimension:e.dimension,data_status:e.dataStatus,eligible_rows:e.coverage.eligibleRows,returned_rows:e.coverage.returnedRows,limited_rows:e.coverage.limitedRows,result_limit:e.coverage.resultLimit,unmatched_rows:e.unmatchedRows,summary:e.summary,winner_key:e.winner?.key,winner_click_delta:e.winner?.clickDelta,winner_impression_delta:e.winner?.impressionDelta,winner_position_delta:e.winner?.positionDelta,loser_key:e.loser?.key,loser_click_delta:e.loser?.clickDelta,loser_impression_delta:e.loser?.impressionDelta,loser_position_delta:e.loser?.positionDelta}))},{filename:`postmortem-template-movement.csv`,headers:[...C.templates],rows:e.output.templateMovement.map((e,t)=>({rank:t+1,direction:e.direction,template:e.signature,confidence:e.confidence,url_count:e.urlCount,click_delta:e.clickDelta,impression_delta:e.impressionDelta,movement_share:e.movementShare,movement_share_scope:e.movementShareScope,confidence_scope:e.confidenceScope,eligible_rows:e.segmentCoverage.eligibleRows,returned_rows:e.segmentCoverage.returnedRows,limited_rows:e.segmentCoverage.limitedRows,result_limit:e.segmentCoverage.resultLimit,source_possibly_truncated:e.segmentCoverage.sourcePossiblyTruncated,common_terms:e.commonTerms.join(`; `),sample_urls:e.sampleUrls.join(`; `),summary:e.summary}))},{filename:`postmortem-update-evidence.csv`,headers:[...C.evidence],rows:e.output.update.evidence.map((e,t)=>({rank:t+1,evidence:e}))},{filename:`postmortem-confounders.csv`,headers:[...C.confounders],rows:e.output.update.confounders.map((e,t)=>({rank:t+1,source:e.source,title:e.title,date:e.date,scope:e.scope,target:e.target,description:e.description}))},...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}.csv`,headers:[...C.segment],rows:fi(e,t)})),...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}-unmatched.csv`,headers:[...C.unmatchedSegment],rows:pi(e,t)}))]}function hi(e){return v(e)?Or(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.log`)).map(t=>{let n=_(e,t.name),r=Mr(n);return{path:n,size:r.size,modifiedAt:r.mtimeMs}}):[]}function gi(e,t){let n=_r(e),r=gr(e,`.log`),i=0;for(;;){let e=_(n,`${r}.${t}${i?`-${i}`:``}.log`);if(!v(e))return e;i+=1}}function _i(e={}){let t=e.directory??qe().logDir,n=e.now??Date.now(),r=e.maxFileBytes??8388608,i=e.maxTotalBytes??67108864,a=e.maxAgeMs??12096e5;Er(t,{recursive:!0,mode:448});let o=0,s=0;for(let e of hi(t))e.size<=r||(Ar(e.path,gi(e.path,n)),o+=1);for(let e of hi(t))e.modifiedAt>=n-a||(jr(e.path,{force:!0}),s+=1);let c=hi(t).sort((e,t)=>e.modifiedAt-t.modifiedAt||(e.path<t.path?-1:+(e.path>t.path))),l=c.reduce((e,t)=>e+t.size,0);for(let e of c){if(l<=i)break;jr(e.path,{force:!0}),l-=e.size,s+=1}return{rotated:o,removed:s,sizeBytes:l}}function vi(e){let t=e-Date.now();if(t<=0)return`expired`;let n=Math.round(t/6e4);if(n<60)return`in ${n}m`;let r=Math.floor(n/60),i=n%60;return i?`in ${r}h ${i}m`:`in ${r}h`}function yi(e,t){return{type:`boolean`,default:!0,description:e,negativeDescription:t}}function w(e){return typeof e==`string`?e:void 0}function T(e){return typeof e==`boolean`?e:void 0}function bi(e){let t=w(e.rendering);if(t!==void 0&&t!==`auto`&&t!==`on`&&t!==`off`)throw new g(`INVALID_INPUT`,`--rendering must be auto, on, or off.`);if(T(e.js)===!0&&t&&t!==`on`)throw new g(`INVALID_INPUT`,`Use either --js or --rendering on, not both with different modes.`);return t??(T(e.js)?`on`:`auto`)}function E(e,t){let n=T(e[t]);if(n===!1)return!0;if(n===!0)return!1;let r=T(e[xi(t)]);if(r===!1)return!0;if(r===!0)return!1;if(T(e[`no-${t}`])===!0||T(e[`no${Si(t)}`])===!0)return!0}function xi(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Si(e){let t=xi(e);return t?`${t[0]?.toUpperCase()}${t.slice(1)}`:``}function D(e){if(typeof e==`number`)return e;if(typeof e!=`string`||!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function O(e,t){if(e===void 0||e===``)return;let n=D(e);if(n===void 0)throw new g(`INVALID_INPUT`,`${t} must be a number.`);return n}function k(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function Ci(e){return k(e)??[]}function wi(e){let t={concurrency:D(e[`fetch-concurrency`]),intervalCap:D(e[`fetch-interval-cap`]),intervalMs:D(e[`fetch-interval-ms`])};return Object.values(t).some(e=>e!==void 0)?t:void 0}function A(e){return e.json===!0}async function Ti(e,t){let n=w(e),r=w(t);if(n&&r)throw Error(`Use either --body or --body-file, not both.`);if(!n&&!r)return;let i=n??await y(r??``,`utf8`),a=JSON.parse(i);if(!a||typeof a!=`object`||Array.isArray(a))throw Error(`JSON body must be an object.`);return a}function j(e){if(e)return e;throw new g(`INVALID_INPUT`,"No site given. Pass --site with a domain, URL or sc-domain: property. Run `seo sites` to list your Search Console properties.")}async function Ei(e,t={}){let n=j(e),r=(await Fe(t.refresh,t.account)).map(e=>e.siteUrl),i=$n(r,n);if(!i)throw new g(`PROPERTY_NOT_FOUND`,`This Google login has no Search Console property for ${n}. Run \`seo sites\` to list the properties it can read.`);return i}function Di(e){if(e)return e;throw new g(`INVALID_INPUT`,"No Google Analytics property given. Pass --property with the numeric property id. Run `seo analytics google properties` to list them.")}function Oi(e){if(typeof e==`number`)return Number.isFinite(e)?Math.round(e):void 0;if(!e)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function ki(e={}){let t=e.env??process.env,n=Oi(e.columns)??Oi(e.streamColumns)??Oi(t.COLUMNS)??80;return Math.min(200,Math.max(40,n))}function M(e={}){let t=e.env??process.env,n=e.isTTY??!!process.stdout.isTTY,r=e.color??!!(n&&t.NO_COLOR===void 0);return{columns:ki({...e,env:t,streamColumns:e.streamColumns??process.stdout.columns}),colors:ri.createColors(r),hasColor:r,isInteractive:n&&!t.CI}}function N(e){return ii(Ur(e))}function Ai(e,t){let n=[],r=``;for(let i of e)r&&N(`${r}${i}`)>t?(n.push(r),r=i):r+=i;return r&&n.push(r),n}function ji(e,t){if(!e)return[``];let n=e.trim().split(/\s+/u),r=[],i=``;for(let e of n){let n=N(e)>t?Ai(e,t):[e];for(let e of n)i?N(`${i} ${e}`)<=t?i+=` ${e}`:(r.push(i),i=e):i=e}return i&&r.push(i),r.length>0?r:[``]}function P(e,t){let n=Math.max(1,t);return e.replaceAll(`\r
|
|
4
4
|
`,`
|
|
5
5
|
`).split(`
|
|
6
6
|
`).flatMap(e=>ji(e,n))}function Mi(e,t){if(N(e)<=t)return e;let n=Math.max(1,t-N(`...`)),r=``;for(let t of e){if(N(`${r}${t}`)>n)break;r+=t}return`${r}...`}const Ni={top:``,"top-mid":``,"top-left":``,"top-right":``,bottom:``,"bottom-mid":``,"bottom-left":``,"bottom-right":``,left:``,"left-mid":``,mid:``,"mid-mid":``,right:``,"right-mid":``,middle:``};function Pi(e){return e===void 0?``:String(e)}function Fi(e,t){return e.map((e,n)=>{let r=t.map(e=>Pi(e[n]));return Math.min(42,Math.max(N(e),...r.map(N),4))})}function Ii(e,t,n){return e.length===0||e.length>4||!e.map((e,n)=>t.every(e=>/^-?(?:\d+(?:\.\d+)?|\d+(?:\.\d+)?%)$/u.test(Pi(e[n]).trim()))).some(Boolean)?!1:Fi(e,t).reduce((e,t)=>e+t+2,0)<=n.columns}function Li(e,t,n){if(!/(?:status|state|assessment|data|allowed)/iu.test(e))return t;let r=t.trim().toLowerCase();return[`pass`,`passed`,`completed`,`allowed`,`yes`].includes(r)?n.colors.green(t):[`warn`,`warning`,`review`,`partial`].includes(r)?n.colors.yellow(t):[`fail`,`failed`,`blocked`,`no`].includes(r)?n.colors.red(t):[`unknown`,`unavailable`].includes(r)?n.colors.blue(t):t}function Ri(e,t,n){let r=Fi(e,t).map(e=>e+2),i=new ai({chars:Ni,colWidths:r,head:e.map(e=>n.colors.bold(e)),style:{border:[],head:[],"padding-left":0,"padding-right":2},wordWrap:!1});for(let a of t)i.push(e.map((e,t)=>P(Li(e,Pi(a[t]),n),Math.max(1,(r[t]??3)-2)).join(`
|
|
@@ -29,7 +29,7 @@ import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Bt a
|
|
|
29
29
|
|
|
30
30
|
`)}function aa(e,t,n){let r=t.filter(e=>e.trim().length>0).flatMap(e=>P(e,n.columns));return[n.colors.bold(e),...r].join(`
|
|
31
31
|
`)}function oa(e,t,n){let r=t.flatMap(e=>P(e,Math.max(1,n.columns-2)).map((e,t)=>`${t===0?`- `:` `}${e}`));return[n.colors.bold(e),...r].join(`
|
|
32
|
-
`)}function sa(e,t){return e.length===0?t.colors.dim(`No parameters.`):ia(e.map(e=>({title:e.name,description:e.description,meta:[e.type,e.required?`required`:`optional`]})),t,{empty:`No parameters.`})}function F(e={}){return!(e.json||!process.stdin.isTTY||!process.stdout.isTTY||process.env.CI)}function I(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?dn():void 0,n=t?{...e,updateNotice:t}:e;process.stdout.write(`${JSON.stringify(n,null,2)}\n`)}function L(e){let t=Hi(e,M());t&&process.stdout.write(`${t}\n`)}function R(e,t){process.stdout.write(`${Vi(e,t,M())}\n`)}function ca(e){process.stdout.write(`${Ui(e,M())}\n`)}function la(e,t){process.stdout.write(`${Qi(e,M(),t)}\n`)}function ua(e){process.stdout.write(`${$i(e,M())}\n`)}function da(e){process.stdout.write(`${Yi(e,M())}\n`)}function fa(e,t){process.stdout.write(`${ra(e,M(),t)}\n`)}function pa(e,t){process.stdout.write(`${ia(e,M(),t)}\n`)}function ma(e,...t){process.stdout.write(`${aa(e,t,M())}\n`)}function ha(e,t){process.stdout.write(`${oa(e,t,M())}\n`)}function ga(e){process.stdout.write(`${sa(e,M())}\n`)}function _a(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function z(e){return typeof e==`symbol`&&process.exit(1),e}function va(e){if(!e)return;let t=Date.now();return e=>{let n=((Date.now()-t)/1e3).toFixed(1);process.stderr.write(`[seo ${n}s] ${e}\n`)}}const ya={site:`--site`,url:`--url`,section:`--section`,date:`--date`,pages:`--pages`,dimensions:`--dimensions`,detail:`--detail`,offset:`--offset`,max_urls:`--max-urls`,mark:`--mark`,issues:`--issues`,note:`--note`,end_date:`--end-date`},ba=e=>/^[\w:/.,<>@#?=&%+-]+$/.test(String(e))?String(e):`"${e}"`,xa=(e,t)=>[`seo ${e}`,...Object.entries(t??{}).filter(([,e])=>e!==void 0).map(([e,t])=>`${ya[e]??`--${e}`} ${ba(t??``)}`)].join(` `),Sa={account:{type:`string`,description:`Saved Google account email.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`},refresh:{type:`boolean`,default:!1,description:`Bypass the local cache and fetch fresh data.`}},Ca={"start-date":{type:`string`,description:`Optional YYYY-MM-DD.`},"end-date":{type:`string`,description:`Optional YYYY-MM-DD.`}},B={detail:{type:`string`,description:`summary (default), rows for the next page, or full.`},offset:{type:`string`,description:`rows only: the first row.`}};function V(e){let t=w(e.detail)??`summary`;if(![`summary`,`rows`,`full`].includes(t))throw new g(`INVALID_INPUT`,`--detail is summary, rows or full.`);return t}function wa(e,t){return Ei(t,{refresh:T(e.refresh),account:w(e.account)})}async function H(e,t){try{let n=await t({...De({call:xa,account:w(e.account),refresh:T(e.refresh)}),progress:va(!A(e))});A(e)?I(n.data):process.stdout.write(`${n.text}\n`)}catch(e){throw p(e)}}const Ta=b({meta:{name:`report`,description:"Start here. No --site: last week across your audited sites (weekly site audit, after `seo login`). --site: overview and every section. Add --section for one"},args:{site:{type:`string`,description:"Site, URL or Search Console property. Leave it out for the summary of every audited site (weekly site audit, after `seo login`)."},section:{type:`string`,description:`Optional, needs --site. One of ${[...wt,Kn,Mt].join(`, `)}. issues keeps a list of what was found for the site, on this machine. ${Mt} lays the latest Google ranking update (or the latest that started by --end-date) over the site.`},mark:{type:`string`,description:`With --site and --issues: ${It.join(`, `)}. Records what the person decided; runs no checks.`},issues:{type:`string`,description:`With --mark: issue ids from --section issues, comma-separated.`},note:{type:`string`,description:`Optional, with --mark: why.`},...Ca,...B,...Sa},run:async({args:e})=>{let t=w(e.section),n=[...wt,Kn,Mt];if(t&&!n.includes(t))throw new g(`INVALID_INPUT`,`--section is one of ${n.join(`, `)}.`);let r=w(e.site),i=w(e.mark),a=w(e.issues);if(i||a){if(i&&!It.includes(i))throw new g(`INVALID_INPUT`,`--mark is one of ${It.join(`, `)}.`);let n=await wa(e,j(r));await H(e,r=>Rn({site:n,section:t,mark:i,issues:a?.split(`,`),note:w(e.note)},r));return}if(!r&&!t&&Vn()){await H(e,e=>ct(e));return}let o=t===`bing`?await wa(e,r).catch(()=>j(r)):await wa(e,r).catch(async n=>{if(t||!r)throw n;return await H(e,t=>Tn({site:j(r),startDate:w(e[`start-date`]),endDate:w(e[`end-date`])},t).catch(()=>{throw n})),null});o!==null&&await H(e,n=>Rn({site:o,section:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},n))}}),Ea=b({meta:{name:`page`,description:`One URL: live page facts, Google index status and its queries`},args:{url:{type:`string`,description:`The page URL.`,required:!0},...Ca,...B,...Sa},run:async({args:e})=>{let t=w(e.url)??``;if(!/^https?:\/\/\S+$/.test(t))throw new g(`INVALID_INPUT`,`--url must be a full http(s) URL.`);let n=await wa(e,t);await H(e,r=>zt({site:n,url:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},r))}}),Da="save it at https://seoskill.dev/account#simple-analytics and run `seo login`, or run `seo analytics simple-analytics connect` to keep it on this machine only.",Oa=b({meta:{name:`compare`,description:`Equal periods before and after a date, with the pages and queries that moved`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},date:{type:`string`,description:`YYYY-MM-DD: the first day after the change.`,required:!0},pages:{type:`string`,description:`Optional URL text, such as /blog/.`},...Sa},run:async({args:e})=>{let t=await wa(e,w(e.site));await H(e,async n=>ze({site:t,date:w(e.date)??``,pages:w(e.pages)},n,await r().catch(()=>void 0)))}}),ka=b({meta:{name:`index`,description:`Google indexing reasons for known URLs, checked live, and pages that lost most of their clicks`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},"max-urls":{type:`string`,description:`How many URLs to ask Google about, 100 by default. Ask for more when you want a fuller picture; it stops at the URL Inspection quota left today.`},...Ca,...B,...Sa},run:async({args:t})=>{let n=await wa(t,w(t.site)),r=D(t[`max-urls`]);if(r!==void 0&&(!Number.isInteger(r)||r<1||r>2e3))throw new g(`INVALID_INPUT`,`--max-urls is a whole number from 1 to ${kn}.`);await H(t,i=>e({site:n,startDate:w(t[`start-date`]),endDate:w(t[`end-date`]),detail:V(t),offset:D(t.offset),maxUrls:r},i))}}),Aa=b({meta:{name:`data`,description:`Raw Search Console or Bing rows beside the previous period, or Clicky or Simple Analytics landing pages`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},source:{type:`string`,description:`search_console (default), bing, clicky or simple_analytics. Bing takes the first dimension, query or page. Clicky takes the site or its Clicky site ID. Simple Analytics takes the site.`},dimensions:{type:`string`,description:`Comma-separated: ${Ot.join(`, `)}. Default query.`},page:{type:`string`,description:`Optional: only rows for pages whose URL contains this.`},query:{type:`string`,description:`Optional: only rows for queries that contain this.`},"page-regex":{type:`string`,description:`Optional: only rows for pages whose URL matches this RE2 regular expression.`},"query-regex":{type:`string`,description:`Optional: only rows for queries that match this RE2 regular expression.`},"exclude-query-regex":{type:`string`,description:`Optional: leave out queries that match this RE2 regular expression, such as your brand.`},...Ca,...B,...Sa},run:async({args:e})=>{let t=k(e.dimensions)??[`query`],n=t.filter(e=>!Ot.includes(e));if(n.length)throw new g(`INVALID_INPUT`,`Unknown dimensions: ${n.join(`, `)}. Use ${Ot.join(`, `)}.`);let i=w(e.source)??`search_console`;if(![`search_console`,`bing`,`clicky`,`simple_analytics`].includes(i))throw new g(`INVALID_INPUT`,`--source is search_console, bing, clicky or simple_analytics.`);if(i===`simple_analytics`){let t=j(w(e.site));await H(e,async()=>Hn({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:Da,call:e=>xa(`data`,{source:`simple_analytics`,site:t,detail:`rows`,offset:e})}));return}if(i===`clicky`){let t=j(w(e.site));await H(e,async()=>Zt({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:"save it at https://seoskill.dev/account#keys and run `seo login`, or run `seo analytics clicky connect` to keep it on this machine only.",refresh:sn,call:e=>xa(`data`,{source:`clicky`,site:t,detail:`rows`,offset:e})}));return}if(i===`bing`){let n=j(w(e.site));await H(e,r=>qt({site:n,dimension:t[0]===`page`?`page`:`query`,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},r));return}let a=await wa(e,w(e.site)),o=ir({page:w(e.page),query:w(e.query),pageRegex:w(e[`page-regex`]),queryRegex:w(e[`query-regex`]),excludeQueryRegex:w(e[`exclude-query-regex`])});await H(e,n=>Je({site:a,dimensions:t,filters:o,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},n))}}),ja=b({meta:{name:`research`,description:`Keyword, SERP, competitor, backlink and AI answer data from your DataForSEO or Ahrefs key`},args:{action:{type:`positional`,required:!0,description:xn.join(`, `)},provider:{type:`string`,description:`${Fn.join(`, `)}, or for serp an installed provider package with live search results. Default: the saved key, DataForSEO when both are saved.`},scope:{type:`string`,description:`${er.join(`, `)}. Default: from the target. A domain is the whole site, a path ending in / is every URL under it (example.com/blog/), any other path is one page.`},keywords:{type:`string`,description:`Comma-separated keywords.`},tasks:{type:`string`,description:`ai_answers only: comma-separated tasks an earlier run returned as not ready.`},also:{type:`string`,description:`ai_answers only: the brand's other domains, comma-separated, such as claude.ai beside claude.com. A citation to any of them counts as citing the target.`},brand:{type:`string`,description:`ai_answers only: comma-separated brand names that count as a mention, such as Datadog for datadoghq.com. Default: each domain's name.`},target:{type:`string`,description:`Domain, subfolder ending in / or page URL.`},competitors:{type:`string`,description:`link_gap only: 2 to 5 comma-separated competitor domains.`},country:{type:`string`,description:`Two-letter country code. Default us.`},depth:{type:`string`,description:`serp only: results per keyword, 1 to 100. Default 20. Deeper costs more.`},device:{type:`string`,description:`serp only: desktop (default) or mobile. Google ranks pages differently on each. DataForSEO only.`},...B,account:Sa.account,json:Sa.json,refresh:{type:`boolean`,default:!1,description:`Ask the provider again instead of reading the result saved in the last day.`}},run:async({args:e})=>{let t=w(e.action);if(!xn.includes(t))throw new g(`INVALID_INPUT`,`The action is one of ${xn.join(`, `)}.`);let n=await r(),i=w(e.provider),a=w(e.scope);if(a&&!er.includes(a))throw new g(`INVALID_INPUT`,`--scope is one of ${er.join(`, `)}.`);let o=w(e.device);if(o&&!ee.includes(o))throw new g(`INVALID_INPUT`,`--device is one of ${ee.join(`, `)}.`);let s=k(e.keywords)??[],c=w(e.target),l=k(e.competitors)??[],u=w(e.country);if(t===`ai_answers`){if(i&&i!==`dataforseo`)throw new g(`INVALID_INPUT`,`ai_answers uses dataforseo.`);let r=k(e.tasks)??[],a=k(e.also),o=k(e.brand),l=s.length||r.length?c??``:await wa(e,c);await H(e,i=>cr({site:l,country:u??`us`,detail:V(e),offset:D(e.offset)??0,questions:s,tasks:r,also:a,brand:o,waitSeconds:240},n,i,(e,n)=>xa(`research`,{action:t,target:c,also:a?.join(`,`),brand:o?.join(`,`),tasks:n.join(`,`)||void 0,country:u,detail:`rows`,offset:e}).replace(`--action `,``)));return}let d=t===`keyword_metrics`&&!s.length&&c,f=d?await wa(e,c):c;await H(e,r=>tn({provider:i,scope:a,depth:D(e.depth),device:o,action:t,keywords:s,target:f,competitors:l,country:u,detail:V(e),offset:D(e.offset)},n,{searchAnalytics:d?r.searchAnalytics:void 0,store:nn(T(e.refresh)),installedSerp:hn,call:n=>xa(`research`,{action:t,provider:i,scope:a,depth:D(e.depth),device:o,keywords:s.join(`,`)||void 0,target:c,competitors:l.join(`,`)||void 0,country:u,detail:`rows`,offset:n}).replace(`--action `,``)}))}}),Ma=b({meta:{name:`lint`,description:`Check copy for patterns common in AI-written text, weak copy and title and description length`},args:{paths:{type:`positional`,required:!1,description:"Files, folders or globs: .md, .mdx, .html, .astro or .txt. Up to 100 files. `seo lint rules` lists the rules instead (add --only ai for the AI-pattern rules)."},url:{type:`string`,description:`Instead of files: a live page. Checks its main content as Markdown (what seo page --detail full shows), with the blog preset unless you set one.`},only:{type:`string`,description:`Check only these categories, comma-separated: ${ae.join(`, `)}. ai is patterns common in AI-written text; copy is weak copy and house style such as dashes; seo is titles, descriptions and headings.`},preset:{type:`string`,description:`${o.join(`, `)}. Default blog for Markdown and text, landing for HTML and Astro. meta reads one title or description per line of a .txt file; start a line with "title:" or "description:" to say which.`},"meta-kind":{type:`string`,description:`With --preset meta: title or description, what a line with no "title:" or "description:" label is. Default: a line up to 70 characters is a title, a longer one a description.`},format:{type:`string`,description:`${h.join(`, `)}. Default: from each file name.`},"fail-on":{type:`string`,description:`error (default) or warning: exit with code 1 when a finding at that level or above is found. A file or page that could not be checked in full also exits with code 1.`},ignore:{type:`string`,description:`Rule ids or review lenses to skip, comma-separated.`},"ignore-phrase":{type:`string`,description:`A phrase to allow, such as a product name a rule keeps matching. Repeat it for more.`},json:Sa.json},run:async({args:e})=>{let t=w(e.preset);if(t&&!o.includes(t))throw new g(`INVALID_INPUT`,`--preset is one of ${o.join(`, `)}.`);let n=w(e[`meta-kind`]);if(n&&!un.includes(n))throw new g(`INVALID_INPUT`,`--meta-kind is ${un.join(` or `)}.`);let r=w(e.format);if(r&&!h.includes(r))throw new g(`INVALID_INPUT`,`--format is one of ${h.join(`, `)}.`);let i=w(e[`fail-on`])??`error`;if(i!==`error`&&i!==`warning`)throw new g(`INVALID_INPUT`,`--fail-on is error or warning.`);let a=(e._??[]).filter(e=>typeof e==`string`),s=w(e.url),c=!s&&a.length===1&&a[0]===`rules`&&!v(`rules`);if(!c&&!!s==a.length>0)throw new g(`INVALID_INPUT`,`Give files, folders or globs to check, or --url with a live page, but not both.`);let l=k(e.only);if(l?.filter(e=>!ae.includes(e))?.length)throw new g(`INVALID_INPUT`,`--only takes ${ae.join(`, `)}, comma-separated.`);let u=[].concat(e[`ignore-phrase`]??[]).filter(e=>typeof e==`string`);try{if(c){let t=await mn({rules:!0,only:l});A(e)?I(t.data):process.stdout.write(`${t.text}\n`);return}let{pageMarkdown:o}=De({call:xa}),d=await mn({paths:s?void 0:a,url:s,preset:t,format:r,ignoreRules:k(e.ignore),ignorePhrases:u,only:l,metaKind:n},e=>Zn(e),o&&(e=>o(e,2e5)));A(e)?I(d.data):process.stdout.write(`${d.text}\n`);let{errors:f,warnings:ee,skipped:p,partial:te}=d.data;(f>0||i===`warning`&&ee>0||p>0||te>0)&&(process.exitCode=1)}catch(e){throw p(e)}}});function Na(e){return e===`keychain`?`system keychain`:e===`file`?`private local file`:e===`environment`?fn:e??`missing`}function Pa(e){if(e&&Ne(e))return e.trim();throw new g(`INVALID_INPUT`,`No Clicky site given. Pass --site-id with the numeric Clicky site ID.`)}async function Fa(e,t){return Ae({siteId:e,sitekey:t}).catch(e=>{throw new g(e instanceof on&&e.code===`auth`?`AUTH_REQUIRED`:`PROVIDER_UNAVAILABLE`,e instanceof Error?e.message:String(e))})}const Ia={type:`boolean`,default:!1,description:`Print machine-readable JSON.`},La={type:`string`,description:`Numeric Clicky site ID.`},Ra=b({meta:{name:`connect`,description:`Check and save a Clicky site on this machine`},args:{"site-id":La,json:Ia},run:async({args:e})=>{let t=A(e),n=F({json:t});n&&Xr(`Connect Clicky`);let r=Pa(w(e[`site-id`])??(n?z(await ni({message:`Clicky site ID`,validate:e=>Ne(e??``)?void 0:`Enter the numeric site ID from Clicky`})):void 0)),i=process.env.SEO_CLICKY_SITEKEY?.trim()||(n?z(await ei({message:`Clicky sitekey`,validate:e=>Re(e??``)?void 0:`Enter the sitekey from Clicky (Preferences, Info)`})):void 0);if(!i)throw new g(`AUTH_REQUIRED`,`Run this command in a terminal or set ${fn}.`);let a=await Fa(r,i.trim()),o=await Dn(r,i.trim()),s={siteId:r,domain:a,connected:!0,credentialSource:o};if(t){I(s);return}let c=`Clicky site ${r}${a?` (${a})`:``} saved in the ${Na(o)}. Next: seo analytics clicky report --site ${r}`;n?S(c):process.stdout.write(`${c}\n`)}}),za=b({meta:{name:`status`,description:`Show a Clicky site saved on this machine`},args:{"site-id":La,check:{type:`boolean`,default:!1,description:`Check the saved sitekey with Clicky.`},json:Ia},run:async({args:e})=>{let t=Pa(w(e[`site-id`])),n=await Vt(t),r=T(e.check);r&&n&&await Fa(t,n.siteKey);let i={siteId:t,connected:!!n,credentialSource:n?.source,liveCheck:r?n?`passed`:`unavailable`:`not-requested`};A(e)?I(i):L([[`Site ID`,t],[`Connected`,i.connected?`yes`:`no`],[`Credential`,Na(i.credentialSource)],[`Live check`,i.liveCheck]])}}),Ba=b({meta:{name:`report`,description:`Clicky landing pages, traffic sources and search engines`},args:{site:{type:`string`,description:`The site, or its numeric Clicky site ID.`},...Ca,...B,json:Ia},run:async({args:e})=>{let t=j(w(e.site));await H(e,async()=>Zt({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:"save it at https://seoskill.dev/account#keys and run `seo login`, or run `seo analytics clicky connect` to keep it on this machine only.",refresh:sn,call:e=>`seo analytics clicky report --site ${t} --detail rows --offset ${e}`}))}}),Va=b({meta:{name:`disconnect`,description:`Remove a Clicky site saved on this machine`},args:{"site-id":La,json:Ia},run:async({args:e})=>{let t=Pa(w(e[`site-id`]));await Wn(t);let n=!!process.env[fn],r={siteId:t,savedCredentialRemoved:!0,environmentCredential:n?`active`:`missing`};A(e)?I(r):process.stdout.write(n?`Saved sitekey removed. ${fn} is still active.\n`:`Clicky is disconnected for this site.
|
|
32
|
+
`)}function sa(e,t){return e.length===0?t.colors.dim(`No parameters.`):ia(e.map(e=>({title:e.name,description:e.description,meta:[e.type,e.required?`required`:`optional`]})),t,{empty:`No parameters.`})}function F(e={}){return!(e.json||!process.stdin.isTTY||!process.stdout.isTTY||process.env.CI)}function I(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?dn():void 0,n=t?{...e,updateNotice:t}:e;process.stdout.write(`${JSON.stringify(n,null,2)}\n`)}function L(e){let t=Hi(e,M());t&&process.stdout.write(`${t}\n`)}function R(e,t){process.stdout.write(`${Vi(e,t,M())}\n`)}function ca(e){process.stdout.write(`${Ui(e,M())}\n`)}function la(e,t){process.stdout.write(`${Qi(e,M(),t)}\n`)}function ua(e){process.stdout.write(`${$i(e,M())}\n`)}function da(e){process.stdout.write(`${Yi(e,M())}\n`)}function fa(e,t){process.stdout.write(`${ra(e,M(),t)}\n`)}function pa(e,t){process.stdout.write(`${ia(e,M(),t)}\n`)}function ma(e,...t){process.stdout.write(`${aa(e,t,M())}\n`)}function ha(e,t){process.stdout.write(`${oa(e,t,M())}\n`)}function ga(e){process.stdout.write(`${sa(e,M())}\n`)}function _a(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function z(e){return typeof e==`symbol`&&process.exit(1),e}function va(e){if(!e)return;let t=Date.now();return e=>{let n=((Date.now()-t)/1e3).toFixed(1);process.stderr.write(`[seo ${n}s] ${e}\n`)}}const ya={site:`--site`,url:`--url`,section:`--section`,date:`--date`,pages:`--pages`,dimensions:`--dimensions`,detail:`--detail`,offset:`--offset`,max_urls:`--max-urls`,mark:`--mark`,issues:`--issues`,note:`--note`,end_date:`--end-date`},ba=e=>/^[\w:/.,<>@#?=&%+-]+$/.test(String(e))?String(e):`"${e}"`,xa=(e,t)=>[`seo ${e}`,...Object.entries(t??{}).filter(([,e])=>e!==void 0).map(([e,t])=>`${ya[e]??`--${e}`} ${ba(t??``)}`)].join(` `),Sa={account:{type:`string`,description:`Saved Google account email.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`},refresh:{type:`boolean`,default:!1,description:`Bypass the local cache and fetch fresh data.`}},Ca={"start-date":{type:`string`,description:`Optional YYYY-MM-DD.`},"end-date":{type:`string`,description:`Optional YYYY-MM-DD.`}},B={detail:{type:`string`,description:`summary (default), rows for the next page, or full.`},offset:{type:`string`,description:`rows only: the first row.`}};function V(e){let t=w(e.detail)??`summary`;if(![`summary`,`rows`,`full`].includes(t))throw new g(`INVALID_INPUT`,`--detail is summary, rows or full.`);return t}function wa(e,t){return Ei(t,{refresh:T(e.refresh),account:w(e.account)})}async function H(e,t){try{let n=await t({...De({call:xa,account:w(e.account),refresh:T(e.refresh)}),progress:va(!A(e))});A(e)?I(n.data):process.stdout.write(`${n.text}\n`)}catch(e){throw p(e)}}const Ta=b({meta:{name:`report`,description:"Start here. No --site: last week across your audited sites (weekly site audit, after `seo login`). --site: overview and every section. Add --section for one"},args:{site:{type:`string`,description:"Site, URL or Search Console property. Leave it out for the summary of every audited site (weekly site audit, after `seo login`)."},section:{type:`string`,description:`Optional, needs --site. One of ${[...wt,Kn,Mt].join(`, `)}. issues keeps a list of what was found for the site, on this machine. ${Mt} lays the latest Google ranking update (or the latest that started by --end-date) over the site.`},mark:{type:`string`,description:`With --site and --issues: ${It.join(`, `)}. Records what the person decided; runs no checks.`},issues:{type:`string`,description:`With --mark: issue ids from --section issues, comma-separated.`},note:{type:`string`,description:`Optional, with --mark: why.`},...Ca,...B,...Sa},run:async({args:e})=>{let t=w(e.section),n=[...wt,Kn,Mt];if(t&&!n.includes(t))throw new g(`INVALID_INPUT`,`--section is one of ${n.join(`, `)}.`);let r=w(e.site),i=w(e.mark),a=w(e.issues);if(i||a){if(i&&!It.includes(i))throw new g(`INVALID_INPUT`,`--mark is one of ${It.join(`, `)}.`);let n=await wa(e,j(r));await H(e,r=>Rn({site:n,section:t,mark:i,issues:a?.split(`,`),note:w(e.note)},r));return}if(!r&&!t&&Vn()){await H(e,e=>ct(e));return}let o=t===`bing`?await wa(e,r).catch(()=>j(r)):await wa(e,r).catch(async n=>{if(t||!r)throw n;return await H(e,t=>Tn({site:j(r),startDate:w(e[`start-date`]),endDate:w(e[`end-date`])},t).catch(()=>{throw n})),null});o!==null&&await H(e,n=>Rn({site:o,section:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},n))}}),Ea=b({meta:{name:`page`,description:`One URL: live page facts, Google index status and its queries`},args:{url:{type:`string`,description:`The page URL.`,required:!0},...Ca,...B,...Sa},run:async({args:e})=>{let t=w(e.url)??``;if(!/^https?:\/\/\S+$/.test(t))throw new g(`INVALID_INPUT`,`--url must be a full http(s) URL.`);let n=await wa(e,t);await H(e,r=>zt({site:n,url:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},r))}}),Da="save it at https://seoskill.dev/account#simple-analytics and run `seo login`, or run `seo analytics simple-analytics connect` to keep it on this machine only.",Oa=b({meta:{name:`compare`,description:`Equal periods before and after a date, with the pages and queries that moved`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},date:{type:`string`,description:`YYYY-MM-DD: the first day after the change.`,required:!0},pages:{type:`string`,description:`Optional URL text, such as /blog/.`},...Sa},run:async({args:e})=>{let t=await wa(e,w(e.site));await H(e,async n=>ze({site:t,date:w(e.date)??``,pages:w(e.pages)},n,await r().catch(()=>void 0)))}}),ka=b({meta:{name:`index`,description:`Google indexing reasons for known URLs, checked live, and pages that lost most of their clicks`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},"max-urls":{type:`string`,description:`How many URLs to ask Google about, 100 by default. Ask for more when you want a fuller picture; it stops at the URL Inspection quota left today.`},...Ca,...B,...Sa},run:async({args:t})=>{let n=await wa(t,w(t.site)),r=D(t[`max-urls`]);if(r!==void 0&&(!Number.isInteger(r)||r<1||r>2e3))throw new g(`INVALID_INPUT`,`--max-urls is a whole number from 1 to ${kn}.`);await H(t,i=>e({site:n,startDate:w(t[`start-date`]),endDate:w(t[`end-date`]),detail:V(t),offset:D(t.offset),maxUrls:r},i))}}),Aa=b({meta:{name:`data`,description:`Raw Search Console or Bing rows beside the previous period, or Clicky or Simple Analytics landing pages`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},source:{type:`string`,description:`search_console (default), bing, clicky or simple_analytics. Bing takes the first dimension, query or page. Clicky takes the site or its Clicky site ID. Simple Analytics takes the site.`},dimensions:{type:`string`,description:`Comma-separated: ${Ot.join(`, `)}. Default query.`},page:{type:`string`,description:`Optional: only rows for pages whose URL contains this.`},query:{type:`string`,description:`Optional: only rows for queries that contain this.`},"page-regex":{type:`string`,description:`Optional: only rows for pages whose URL matches this RE2 regular expression.`},"query-regex":{type:`string`,description:`Optional: only rows for queries that match this RE2 regular expression.`},"exclude-query-regex":{type:`string`,description:`Optional: leave out queries that match this RE2 regular expression, such as your brand.`},...Ca,...B,...Sa},run:async({args:e})=>{let t=k(e.dimensions)??[`query`],n=t.filter(e=>!Ot.includes(e));if(n.length)throw new g(`INVALID_INPUT`,`Unknown dimensions: ${n.join(`, `)}. Use ${Ot.join(`, `)}.`);let i=w(e.source)??`search_console`;if(![`search_console`,`bing`,`clicky`,`simple_analytics`].includes(i))throw new g(`INVALID_INPUT`,`--source is search_console, bing, clicky or simple_analytics.`);if(i===`simple_analytics`){let t=j(w(e.site));await H(e,async()=>Hn({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:Da,call:e=>xa(`data`,{source:`simple_analytics`,site:t,detail:`rows`,offset:e})}));return}if(i===`clicky`){let t=j(w(e.site));await H(e,async()=>Zt({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:"save it at https://seoskill.dev/account#keys and run `seo login`, or run `seo analytics clicky connect` to keep it on this machine only.",refresh:sn,call:e=>xa(`data`,{source:`clicky`,site:t,detail:`rows`,offset:e})}));return}if(i===`bing`){let n=j(w(e.site));await H(e,r=>qt({site:n,dimension:t[0]===`page`?`page`:`query`,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},r));return}let a=await wa(e,w(e.site)),o=ir({page:w(e.page),query:w(e.query),pageRegex:w(e[`page-regex`]),queryRegex:w(e[`query-regex`]),excludeQueryRegex:w(e[`exclude-query-regex`])});await H(e,n=>Je({site:a,dimensions:t,filters:o,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},n))}}),ja=b({meta:{name:`research`,description:`Keyword, SERP, competitor, backlink and AI answer data from your DataForSEO or Ahrefs key`},args:{action:{type:`positional`,required:!0,description:xn.join(`, `)},provider:{type:`string`,description:`${Fn.join(`, `)}, or for serp an installed provider package with live search results. Default: the saved key, DataForSEO when both are saved.`},scope:{type:`string`,description:`${er.join(`, `)}. Default: from the target. A domain is the whole site, a path ending in / is every URL under it (example.com/blog/), any other path is one page.`},keywords:{type:`string`,description:`Comma-separated keywords.`},tasks:{type:`string`,description:`ai_answers only: comma-separated tasks an earlier run returned as not ready.`},also:{type:`string`,description:`ai_answers only: the brand's other domains, comma-separated, such as claude.ai beside claude.com. A citation to any of them counts as citing the target.`},brand:{type:`string`,description:`ai_answers and mentions: comma-separated brand names, such as Datadog for datadoghq.com. ai_answers counts them as a mention (default: each domain's name); mentions searches for them beside the domain.`},target:{type:`string`,description:`Domain, subfolder ending in / or page URL.`},competitors:{type:`string`,description:`link_gap only: 2 to 5 comma-separated competitor domains.`},country:{type:`string`,description:`Two-letter country code. Default us.`},depth:{type:`string`,description:`serp only: results per keyword, 1 to 100. Default 20. Deeper costs more.`},device:{type:`string`,description:`serp only: desktop (default) or mobile. Google ranks pages differently on each. DataForSEO only.`},...B,account:Sa.account,json:Sa.json,refresh:{type:`boolean`,default:!1,description:`Ask the provider again instead of reading the result saved in the last day.`}},run:async({args:e})=>{let t=w(e.action);if(!xn.includes(t))throw new g(`INVALID_INPUT`,`The action is one of ${xn.join(`, `)}.`);let n=await r(),i=w(e.provider),a=w(e.scope);if(a&&!er.includes(a))throw new g(`INVALID_INPUT`,`--scope is one of ${er.join(`, `)}.`);let o=w(e.device);if(o&&!ee.includes(o))throw new g(`INVALID_INPUT`,`--device is one of ${ee.join(`, `)}.`);let s=k(e.keywords)??[],c=w(e.target),l=k(e.competitors)??[],u=w(e.country);if(t===`ai_answers`){if(i&&i!==`dataforseo`)throw new g(`INVALID_INPUT`,`ai_answers uses dataforseo.`);let r=k(e.tasks)??[],a=k(e.also),o=k(e.brand),l=s.length||r.length?c??``:await wa(e,c);await H(e,i=>cr({site:l,country:u??`us`,detail:V(e),offset:D(e.offset)??0,questions:s,tasks:r,also:a,brand:o,waitSeconds:240},n,i,(e,n)=>xa(`research`,{action:t,target:c,also:a?.join(`,`),brand:o?.join(`,`),tasks:n.join(`,`)||void 0,country:u,detail:`rows`,offset:e}).replace(`--action `,``)));return}let d=t===`keyword_metrics`&&!s.length&&c,f=d?await wa(e,c):c;await H(e,r=>tn({provider:i,scope:a,depth:D(e.depth),device:o,action:t,keywords:s,target:f,competitors:l,brand:k(e.brand),country:u,detail:V(e),offset:D(e.offset)},n,{searchAnalytics:d?r.searchAnalytics:void 0,store:nn(T(e.refresh)),installedSerp:hn,call:n=>xa(`research`,{action:t,provider:i,scope:a,depth:D(e.depth),device:o,keywords:s.join(`,`)||void 0,target:c,competitors:l.join(`,`)||void 0,country:u,detail:`rows`,offset:n}).replace(`--action `,``)}))}}),Ma=b({meta:{name:`lint`,description:`Check copy for patterns common in AI-written text, weak copy and title and description length`},args:{paths:{type:`positional`,required:!1,description:"Files, folders or globs: .md, .mdx, .html, .astro or .txt. Up to 100 files. `seo lint rules` lists the rules instead (add --only ai for the AI-pattern rules)."},url:{type:`string`,description:`Instead of files: a live page. Checks its main content as Markdown (what seo page --detail full shows), with the blog preset unless you set one.`},only:{type:`string`,description:`Check only these categories, comma-separated: ${ae.join(`, `)}. ai is patterns common in AI-written text; copy is weak copy and house style such as dashes; seo is titles, descriptions and headings.`},preset:{type:`string`,description:`${o.join(`, `)}. Default blog for Markdown and text, landing for HTML and Astro. meta reads one title or description per line of a .txt file; start a line with "title:" or "description:" to say which.`},"meta-kind":{type:`string`,description:`With --preset meta: title or description, what a line with no "title:" or "description:" label is. Default: a line up to 70 characters is a title, a longer one a description.`},format:{type:`string`,description:`${h.join(`, `)}. Default: from each file name.`},"fail-on":{type:`string`,description:`error (default) or warning: exit with code 1 when a finding at that level or above is found. A file or page that could not be checked in full also exits with code 1.`},ignore:{type:`string`,description:`Rule ids or review lenses to skip, comma-separated.`},"ignore-phrase":{type:`string`,description:`A phrase to allow, such as a product name a rule keeps matching. Repeat it for more.`},json:Sa.json},run:async({args:e})=>{let t=w(e.preset);if(t&&!o.includes(t))throw new g(`INVALID_INPUT`,`--preset is one of ${o.join(`, `)}.`);let n=w(e[`meta-kind`]);if(n&&!un.includes(n))throw new g(`INVALID_INPUT`,`--meta-kind is ${un.join(` or `)}.`);let r=w(e.format);if(r&&!h.includes(r))throw new g(`INVALID_INPUT`,`--format is one of ${h.join(`, `)}.`);let i=w(e[`fail-on`])??`error`;if(i!==`error`&&i!==`warning`)throw new g(`INVALID_INPUT`,`--fail-on is error or warning.`);let a=(e._??[]).filter(e=>typeof e==`string`),s=w(e.url),c=!s&&a.length===1&&a[0]===`rules`&&!v(`rules`);if(!c&&!!s==a.length>0)throw new g(`INVALID_INPUT`,`Give files, folders or globs to check, or --url with a live page, but not both.`);let l=k(e.only);if(l?.filter(e=>!ae.includes(e))?.length)throw new g(`INVALID_INPUT`,`--only takes ${ae.join(`, `)}, comma-separated.`);let u=[].concat(e[`ignore-phrase`]??[]).filter(e=>typeof e==`string`);try{if(c){let t=await mn({rules:!0,only:l});A(e)?I(t.data):process.stdout.write(`${t.text}\n`);return}let{pageMarkdown:o}=De({call:xa}),d=await mn({paths:s?void 0:a,url:s,preset:t,format:r,ignoreRules:k(e.ignore),ignorePhrases:u,only:l,metaKind:n},e=>Zn(e),o&&(e=>o(e,2e5)));A(e)?I(d.data):process.stdout.write(`${d.text}\n`);let{errors:f,warnings:ee,skipped:p,partial:te}=d.data;(f>0||i===`warning`&&ee>0||p>0||te>0)&&(process.exitCode=1)}catch(e){throw p(e)}}});function Na(e){return e===`keychain`?`system keychain`:e===`file`?`private local file`:e===`environment`?fn:e??`missing`}function Pa(e){if(e&&Ne(e))return e.trim();throw new g(`INVALID_INPUT`,`No Clicky site given. Pass --site-id with the numeric Clicky site ID.`)}async function Fa(e,t){return Ae({siteId:e,sitekey:t}).catch(e=>{throw new g(e instanceof on&&e.code===`auth`?`AUTH_REQUIRED`:`PROVIDER_UNAVAILABLE`,e instanceof Error?e.message:String(e))})}const Ia={type:`boolean`,default:!1,description:`Print machine-readable JSON.`},La={type:`string`,description:`Numeric Clicky site ID.`},Ra=b({meta:{name:`connect`,description:`Check and save a Clicky site on this machine`},args:{"site-id":La,json:Ia},run:async({args:e})=>{let t=A(e),n=F({json:t});n&&Xr(`Connect Clicky`);let r=Pa(w(e[`site-id`])??(n?z(await ni({message:`Clicky site ID`,validate:e=>Ne(e??``)?void 0:`Enter the numeric site ID from Clicky`})):void 0)),i=process.env.SEO_CLICKY_SITEKEY?.trim()||(n?z(await ei({message:`Clicky sitekey`,validate:e=>Re(e??``)?void 0:`Enter the sitekey from Clicky (Preferences, Info)`})):void 0);if(!i)throw new g(`AUTH_REQUIRED`,`Run this command in a terminal or set ${fn}.`);let a=await Fa(r,i.trim()),o=await Dn(r,i.trim()),s={siteId:r,domain:a,connected:!0,credentialSource:o};if(t){I(s);return}let c=`Clicky site ${r}${a?` (${a})`:``} saved in the ${Na(o)}. Next: seo analytics clicky report --site ${r}`;n?S(c):process.stdout.write(`${c}\n`)}}),za=b({meta:{name:`status`,description:`Show a Clicky site saved on this machine`},args:{"site-id":La,check:{type:`boolean`,default:!1,description:`Check the saved sitekey with Clicky.`},json:Ia},run:async({args:e})=>{let t=Pa(w(e[`site-id`])),n=await Vt(t),r=T(e.check);r&&n&&await Fa(t,n.siteKey);let i={siteId:t,connected:!!n,credentialSource:n?.source,liveCheck:r?n?`passed`:`unavailable`:`not-requested`};A(e)?I(i):L([[`Site ID`,t],[`Connected`,i.connected?`yes`:`no`],[`Credential`,Na(i.credentialSource)],[`Live check`,i.liveCheck]])}}),Ba=b({meta:{name:`report`,description:`Clicky landing pages, traffic sources and search engines`},args:{site:{type:`string`,description:`The site, or its numeric Clicky site ID.`},...Ca,...B,json:Ia},run:async({args:e})=>{let t=j(w(e.site));await H(e,async()=>Zt({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:"save it at https://seoskill.dev/account#keys and run `seo login`, or run `seo analytics clicky connect` to keep it on this machine only.",refresh:sn,call:e=>`seo analytics clicky report --site ${t} --detail rows --offset ${e}`}))}}),Va=b({meta:{name:`disconnect`,description:`Remove a Clicky site saved on this machine`},args:{"site-id":La,json:Ia},run:async({args:e})=>{let t=Pa(w(e[`site-id`]));await Wn(t);let n=!!process.env[fn],r={siteId:t,savedCredentialRemoved:!0,environmentCredential:n?`active`:`missing`};A(e)?I(r):process.stdout.write(n?`Saved sitekey removed. ${fn} is still active.\n`:`Clicky is disconnected for this site.
|
|
33
33
|
`)}}),Ha=b({meta:{name:`clicky`,description:`Read Clicky, or save a Clicky site on this machine only`},subCommands:{connect:Ra,status:za,report:Ba,disconnect:Va}}),Ua=b({meta:{name:`properties`,description:`List Google Analytics accounts and properties`},args:{json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`},account:{type:`string`,description:`Saved Google account email.`}},run:async({args:e})=>{let t=await Ue(w(e.account)),n=t.flatMap(e=>e.propertySummaries.map(t=>({account:e.displayName??e.account,property:Te(t.property),displayName:t.displayName??t.property})));A(e)?I({accountSummaries:t,properties:n}):R([`Property`,`Name`,`Account`],n.map(e=>[e.property,e.displayName,e.account]))}}),Wa=b({meta:{name:`report`,description:`Google Analytics landing pages for visits from search`},args:{property:{type:`string`,description:"Numeric Google Analytics property ID. Run `seo analytics google properties` to list them."},...Ca,...B,json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=Di(w(e.property));await H(e,async()=>Xn({property:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await bt(await ne(),t,rt.signIn),{signIn:rt.signIn,call:e=>`seo analytics google report --property ${t} --detail rows --offset ${e}`}))}}),Ga=b({meta:{name:`google`,description:`Read Google Analytics properties and reports`},subCommands:{properties:Ua,report:Wa}});function Ka(e){return e===`keychain`?`system keychain`:e===`file`?`private local file`:e===`environment`?je:e??`missing`}const qa={type:`boolean`,default:!1,description:`Print machine-readable JSON.`},Ja=b({meta:{name:`connect`,description:`Save a Simple Analytics API key on this machine`},args:{json:qa},run:async({args:e})=>{let t=A(e),n=F({json:t});n&&Xr(`Connect Simple Analytics`);let r=process.env.SEO_SIMPLE_ANALYTICS_KEY?.trim()||(n?z(await ei({message:`Simple Analytics API key`,validate:e=>Qe(e??``)?void 0:`Enter an API key that starts with sa_api_key_ (Account settings, API keys)`})):void 0);if(!r)throw new g(`AUTH_REQUIRED`,`Run this command in a terminal or set ${je}.`);let i=await he(r);if(t){I({connected:!0,credentialSource:i});return}let a=`Simple Analytics API key saved in the ${Ka(i)}. Next: seo analytics simple-analytics report --site example.com`;n?S(a):process.stdout.write(`${a}\n`)}}),Ya=b({meta:{name:`status`,description:`Show whether a Simple Analytics API key is saved here`},args:{json:qa},run:async({args:e})=>{let t=await oe(),n={connected:!!t,credentialSource:t?.source};A(e)?I(n):L([[`Connected`,n.connected?`yes`:`no`],[`Credential`,Ka(n.credentialSource)]])}}),Xa=b({meta:{name:`report`,description:`Simple Analytics landing pages, referrers, utm_source tags and AI tools`},args:{site:{type:`string`,description:`The site, such as example.com.`},...Ca,...B,json:qa},run:async({args:e})=>{let t=j(w(e.site));await H(e,async()=>Hn({site:t,startDate:w(e[`start-date`]),endDate:w(e[`end-date`]),detail:V(e),offset:D(e.offset)},await r(),{connect:Da,call:e=>`seo analytics simple-analytics report --site ${t} --detail rows --offset ${e}`}))}}),Za=b({meta:{name:`disconnect`,description:`Remove the Simple Analytics API key saved on this machine`},args:{json:qa},run:async({args:e})=>{await Ie();let t=!!process.env[je];A(e)?I({savedCredentialRemoved:!0,environmentCredential:t?`active`:`missing`}):process.stdout.write(t?`Saved key removed. ${je} is still active.\n`:`Simple Analytics is disconnected on this machine.
|
|
34
34
|
`)}}),Qa=b({meta:{name:`simple-analytics`,description:`Read Simple Analytics, or save its API key on this machine only`},subCommands:{connect:Ja,status:Ya,report:Xa,disconnect:Za}}),$a=b({meta:{name:`analytics`,description:`Read analytics data from connected providers`},subCommands:{clicky:Ha,google:Ga,"simple-analytics":Qa}});function eo(){return`Your browser will open. Choose your Google account and select all permission boxes for read-only access. Keep this terminal open and finish the browser steps within five minutes.`}async function to(){return x(eo(),`Google sign-in`),pe()}function no(e){return e?e===`environment-json`?`SEO_GOOGLE_SERVICE_ACCOUNT_JSON`:e===`environment-file`?`SEO_GOOGLE_SERVICE_ACCOUNT_FILE`:`GOOGLE_APPLICATION_CREDENTIALS`:`invalid or conflicting configuration`}function ro(e){return e.active===`keychain`?`system keychain`:e.configured===`keychain`?`private file fallback`:`private file`}function io(e){return e===`shared`?`SEO Skill app`:`Local OAuth config`}function ao(e){let t=[[`Account`,e.accountEmail]],n=new Set(e.scope.split(/\s+/u).filter(Boolean));return n.has(`https://www.googleapis.com/auth/webmasters.readonly`)?t.push([`Search Console`,`Read only`]):t.push([`Search Console`,`Not granted`]),n.has(`https://www.googleapis.com/auth/analytics.readonly`)?t.push([`Google Analytics`,`Read only`]):t.push([`Google Analytics`,`Not granted`]),t.push([`OAuth app`,io(e.clientSource)],[`Expires`,vi(e.expiresAt)]),t}const oo=b({meta:{name:`auth`,description:`Authentication commands`},subCommands:{login:b({meta:{name:`login`,description:`Run Google OAuth flow`},run:async()=>{if((await et()).activeMode===`service-account`)throw new g(`AUTH_CONFIG_REQUIRED`,`A service account is active from the environment. Unset its credential variable before running browser OAuth.`);let e=await to();L(ao({accountEmail:e.account_email,clientSource:e.client_source,expiresAt:e.expires_at,scope:e.scope}))}}),logout:b({meta:{name:`logout`,description:`Delete a local Google login`},args:{account:{type:`string`,description:`Delete the login for this Google account.`},all:{type:`boolean`,default:!1,description:`Delete every saved Google login.`}},run:async({args:e})=>{let t=await et(),n=w(e.account);if(n&&e.all)throw new g(`INVALID_INPUT`,`Use either --account or --all, not both.`);let r=e.all?void 0:n??t.accounts.find(e=>e.active)?.accountEmail;await ue(r),t.activeMode===`service-account`?process.stdout.write(`${e.all?`Deleted all local Google logins.`:r?`Deleted the local login for ${r}.`:`No local Google login was found.`} Service account credentials remain available through the environment.\n`):process.stdout.write(`${e.all?`Deleted all local Google logins.`:r?`Deleted the local login for ${r}.`:`No local Google login was found.`}\nRevoke at https://myaccount.google.com/permissions if you also want Google to forget the grant.\n`)}}),whoami:b({meta:{name:`whoami`,description:`Show the signed-in Google account`},args:{account:{type:`string`,description:`Show this saved Google account.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=await et();if(t.activeMode===`service-account`){let n={mode:`service-account`,account:t.identity??null,source:no(t.serviceAccount.source)};if(A(e)){I(n);return}L([[`Account type`,`Service account`],[`Account`,t.identity??`Invalid configuration`],[`Credentials`,n.source],[`Access`,`Search Console and Google Analytics, read only`]]);return}let n=w(e.account),r=n?await ft(n):t.tokens;if(n&&!r)throw new g(`AUTH_REQUIRED`,`Google account ${n} is not connected.`);if(r)A(e)?I({mode:`oauth`,account:r.account_email,scopes:r.scope.split(/\s+/u).filter(Boolean),clientSource:r.client_source,expiresAt:r.expires_at}):L(ao({accountEmail:r.account_email,clientSource:r.client_source,expiresAt:r.expires_at,scope:r.scope}));else{if(A(e)){I({mode:`oauth`,account:null});return}process.stdout.write(`Not logged in.
|
|
35
35
|
`)}}}),status:b({meta:{name:`status`,description:`Show local Google auth status`},args:{account:{type:`string`,description:`Show status for this saved Google account.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=await et(),n=w(e.account),r=n?await ft(n):t.tokens;if(n&&!r&&t.activeMode!==`service-account`)throw new g(`AUTH_REQUIRED`,`Google account ${n} is not connected.`);let i=t.activeMode===`oauth`?await jn():void 0;if(A(e)){I({authenticated:t.activeMode===`oauth`?!!r:t.serviceAccount.configured,mode:t.activeMode,identity:t.identity,account:t.activeMode===`oauth`?r?.account_email:void 0,scopes:t.activeMode===`oauth`?r?.scope:void 0,clientSource:t.activeMode===`oauth`?r?.client_source:void 0,expiresAt:t.activeMode===`oauth`?r?.expires_at:void 0,sharedConfigured:t.sharedConfigured,byoConfigured:t.byoConfigured,serviceAccount:{configured:t.serviceAccount.configured,identity:t.serviceAccount.identity,source:t.serviceAccount.source,error:t.serviceAccount.error},accounts:t.accounts,...i?{tokenStorage:i}:{}});return}if(t.activeMode===`service-account`){let e=[[`Mode`,`service account`],[`Identity`,t.identity??`unavailable`],[`Source`,no(t.serviceAccount.source)],[`Scopes`,`Search Console readonly, Google Analytics readonly`],[`Storage`,`credentials stay in the environment`]];t.serviceAccount.error&&e.push([`Status`,t.serviceAccount.error]),L(e);return}if(!r){let e=t.serviceAccount.error?t.serviceAccount.error:t.sharedConfigured?`Shared seo app available`:t.byoConfigured?`Local OAuth config available`:`No OAuth client configured`;process.stdout.write(`Not logged in. ${e}. Run \`seo auth login\` to connect Google.\n`);return}let a=i??await jn();L([[`Account`,r.account_email],[`Connected accounts`,String(t.accounts.length)],[`Scopes`,r.scope],[`Client`,io(r.client_source)],[`Expires`,vi(r.expires_at)],[`Tokens file`,qe().tokensFile],[`Token storage`,ro(a)],...a.reason?[[`Storage note`,a.reason]]:[],[`OAuth mode`,t.sharedConfigured?`SEO Skill app available`:t.byoConfigured?`Local OAuth config available`:`missing`],[`Revoke at`,`https://myaccount.google.com/permissions`]])}}),storage:b({meta:{name:`storage`,description:`Show or change local OAuth token storage`},args:{keychain:{type:`boolean`,default:!1,description:`Store OAuth tokens in the system keychain when available.`},file:{type:`boolean`,default:!1,description:`Store OAuth tokens in the private local file.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{if(e.keychain&&e.file)throw new g(`INVALID_INPUT`,`Choose either --keychain or --file, not both.`);let t=e.keychain||e.file?await ht(e.keychain?`keychain`:`file`):await jn();A(e)?I(t):L([[`Configured storage`,t.configured],[`Active storage`,ro(t)],...t.reason?[[`Note`,t.reason]]:[]])}}),refresh:b({meta:{name:`refresh`,description:`Refresh the Google OAuth token`},args:{account:{type:`string`,description:`Refresh this saved Google account.`}},run:async({args:e})=>{if((await et()).activeMode===`service-account`){process.stdout.write(`Service accounts request short-lived Google tokens automatically. No local refresh token is stored.
|
|
@@ -62,7 +62,7 @@ Updates
|
|
|
62
62
|
`),`Setup will`),x(ic.join(`
|
|
63
63
|
`),`Then run`),S(`Dry run complete. Nothing was changed.`));return}rr();let n=F({json:t}),r=await Qs({interactive:n})??await tc({interactive:n}),i=n?await rc():[],a=n?await nc():{status:`skipped`};if(t){I({auth:r,mcp:i,skill:a,next:ic});return}L([[`Sign-in`,oc(r)],[`MCP server`,cc(i)],[`SEO skill`,sc(a)]]);let o=i.filter(e=>e.error);o.length&&x(o.map(e=>`${e.client}: ${e.error}`).join(`
|
|
64
64
|
`),`MCP setup skipped`),a.error&&x(a.error,`SEO skill install failed`),x(`seo sites list your Search Console properties
|
|
65
|
-
seo report --site <site> run the main report for one of them`,`Try next`),S(`Setup complete.`),lc()}const dc=b({meta:{name:`setup`,description:`Sign in with Google, then add the MCP server and skill`},args:{"dry-run":{type:`boolean`,default:!1,description:`Show what setup does without changing anything.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON. Never prompts.`}},run:async({args:e})=>uc(e)}),fc=b({...dc,meta:{name:`start`,description:`Start here: sign in with Google, then add the MCP server and skill to your agents`}}),pc=b({...fc,meta:{name:`init`,description:"Legacy alias for `seo start`."}}),mc=b({meta:{name:`logs`,description:`Manage local log retention`},subCommands:{prune:b({meta:{name:`prune`,description:`Rotate large logs and remove old local logs`},args:{quiet:{type:`boolean`,default:!1,description:`Do not print a result.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=_i();A(e)?I(t):e.quiet||process.stdout.write(`Rotated ${t.rotated} and removed ${t.removed} log files. ${_a(t.sizeBytes)} retained.\n`)}})}}),hc=[{client:`claude-desktop`,flag:`claude-desktop`},{client:`claude-code`,flag:`claude-code`},{client:`codex`,flag:`codex`},{client:`cursor`,flag:`cursor`}];function gc(e,t){return T(e.all)?t:hc.filter(({flag:t})=>T(e[t])).map(({client:e})=>e)}const _c=b({meta:{name:`mcp`,description:`MCP server helpers`},subCommands:{serve:b({meta:{name:`serve`,description:`Run the SEO MCP server`},args:{test:{type:`boolean`,default:!1,description:`Start in test mode`}},run:async({args:e})=>{let{startMcpServer:t}=await import(`./dist-
|
|
65
|
+
seo report --site <site> run the main report for one of them`,`Try next`),S(`Setup complete.`),lc()}const dc=b({meta:{name:`setup`,description:`Sign in with Google, then add the MCP server and skill`},args:{"dry-run":{type:`boolean`,default:!1,description:`Show what setup does without changing anything.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON. Never prompts.`}},run:async({args:e})=>uc(e)}),fc=b({...dc,meta:{name:`start`,description:`Start here: sign in with Google, then add the MCP server and skill to your agents`}}),pc=b({...fc,meta:{name:`init`,description:"Legacy alias for `seo start`."}}),mc=b({meta:{name:`logs`,description:`Manage local log retention`},subCommands:{prune:b({meta:{name:`prune`,description:`Rotate large logs and remove old local logs`},args:{quiet:{type:`boolean`,default:!1,description:`Do not print a result.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=_i();A(e)?I(t):e.quiet||process.stdout.write(`Rotated ${t.rotated} and removed ${t.removed} log files. ${_a(t.sizeBytes)} retained.\n`)}})}}),hc=[{client:`claude-desktop`,flag:`claude-desktop`},{client:`claude-code`,flag:`claude-code`},{client:`codex`,flag:`codex`},{client:`cursor`,flag:`cursor`}];function gc(e,t){return T(e.all)?t:hc.filter(({flag:t})=>T(e[t])).map(({client:e})=>e)}const _c=b({meta:{name:`mcp`,description:`MCP server helpers`},subCommands:{serve:b({meta:{name:`serve`,description:`Run the SEO MCP server`},args:{test:{type:`boolean`,default:!1,description:`Start in test mode`}},run:async({args:e})=>{let{startMcpServer:t}=await import(`./dist-BjyKh54_.js`);await t({test:T(e.test)})}}),install:b({meta:{name:`install`,description:`Install or remove SEO MCP config for local clients`},args:{uninstall:{type:`boolean`,default:!1,description:`Remove the SEO MCP config instead of adding it`},reinstall:{type:`boolean`,default:!1,description:`Rewrite an existing managed SEO MCP config`},"claude-desktop":{type:`boolean`,default:!1,description:`Update Claude Desktop`},"claude-code":{type:`boolean`,default:!1,description:`Update Claude Code`},codex:{type:`boolean`,default:!1,description:`Update Codex CLI, app, and IDE extension`},cursor:{type:`boolean`,default:!1,description:`Update Cursor`},all:{type:`boolean`,default:!1,description:`Update every detected MCP client`},json:{type:`boolean`,default:!1,description:`Print structured JSON output`}},run:async({args:e})=>{if(T(e.uninstall)&&T(e.reinstall))throw new g(`INVALID_INPUT`,`Use either --uninstall or --reinstall, not both.`);let t=hs(),n=vs({targets:t}),r=A(e),i=gc(e,n.map(e=>e.client));if(i.length===0){if(!F({json:r}))throw new g(`INVALID_INPUT`,`Choose an MCP client with --claude-desktop, --claude-code, --codex, --cursor, or --all.`);let a=n.length>0?n:t;i=z(await $r({message:e.uninstall?`Remove seo from which MCP clients?`:`Install seo into which MCP clients?`,options:a.map(e=>({value:e.client,label:e.label,hint:e.path})),initialValues:n.map(e=>e.client),required:!0}))}let a=i.filter(e=>!t.some(t=>t.client===e));if(a.length>0)throw new g(`INVALID_INPUT`,`MCP setup is not supported for ${a.join(`, `)} on ${process.platform}.`);let o=t.filter(e=>i.includes(e.client)).map(t=>T(e.uninstall)?Ls(t):Is(t,{reinstall:T(e.reinstall)}));if(r)I({operation:T(e.uninstall)?`uninstall`:`install`,results:o});else for(let e of o)process.stdout.write(`${e.changed?`updated`:`skipped`} ${e.client} · ${e.path}\n`)}})}}),vc=b({meta:{name:`index-coverage`,description:`Find crawlable pages that deserve a closer Google index check`},args:{site:{type:`string`,description:`GSC property URL, for example sc-domain:example.com.`},url:{type:`string`,description:`Start URL to crawl. Defaults to the home page.`},sitemaps:{type:`string`,description:`Comma-separated XML sitemap URLs. Defaults to declarations captured by the crawl.`},days:{type:`string`,description:`Finalized Search Console date range. Defaults to 90 days.`},"row-limit":{type:`string`,description:`Maximum Search Console page rows. Defaults to 100000.`},"max-sitemap-urls":{type:`string`,description:`Maximum sitemap inventory URLs. Defaults to 100000.`},limit:{type:`string`,description:`Maximum URLs returned in each evidence group. Defaults to 100.`},refresh:{type:`boolean`,default:!1,description:`Bypass the local Search Console cache.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=A(e),n=j(w(e.site)),r=Ci(e.sitemaps),i=await tt({site:n,url:w(e.url),sitemaps:r.length?r:void 0,days:D(e.days),rowLimit:D(e[`row-limit`]),maxSitemapUrls:D(e[`max-sitemap-urls`]),itemsPerSection:D(e.limit),refresh:T(e.refresh)});t?I(i):(K({title:`Index coverage`,target:i.site,status:i.sources.crawl.completeness===`complete`&&i.sources.searchConsole.completeness===`complete`?i.summary.crawlableCandidatesWithoutRetainedSearchVisibility>0?`warning`:`pass`:`unknown`,summary:`${i.summary.crawlableCandidatesWithoutRetainedSearchVisibility} crawlable pages need URL Inspection review.`,metrics:[{label:`Crawl report`,value:i.input.crawlReport.id},{label:`Crawl evidence`,value:i.sources.crawl.completeness},{label:`Sitemap evidence`,value:i.sources.sitemap.completeness},{label:`Search evidence`,value:i.sources.searchConsole.completeness},{label:`Search window`,value:`${i.sources.searchConsole.startDate} to ${i.sources.searchConsole.endDate}`},{label:`Search-visible pages`,value:i.summary.retainedSearchVisibleUrls},{label:`Blocked/non-indexable`,value:i.summary.blockedOrNonIndexableCrawlUrls},{label:`Sitemap only`,value:i.summary.sitemapOnlyUrls},{label:`Search Console only`,value:i.summary.searchConsoleOnlyUrls}]}),i.crawlableWithoutRetainedSearchVisibility.items.length&&(process.stdout.write(`
|
|
66
66
|
Representative URL Inspection candidates
|
|
67
67
|
`),R([`URL`,`Status`,`In sitemap`],i.crawlableWithoutRetainedSearchVisibility.items.map(e=>[G(e.url,80),e.status,e.inSitemap?`yes`:`no`]))),Y(`How to read this report`,i.caveats))}}),yc=b({meta:{name:`link-recover`,description:`Find search-value URLs that are now broken, blocked, or poorly redirected`},args:{site:{type:`string`},...X([`days`,`limit`,`minImpressions`,`refresh`,`js`],{days:{description:`GSC lookback window. Defaults to 90.`},limit:{description:`Maximum GSC pages to check. Defaults to 50.`},minImpressions:{description:`Minimum impressions to check a page. Defaults to 100.`},refresh:{description:`Bypass local GSC and HTTP caches.`},js:{description:`Force JavaScript rendering for final page extraction.`}}),"min-clicks":{type:`string`,description:`Minimum clicks to check a page. Defaults to 1.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=A(e),n=await it({site:j(w(e.site)),days:D(e.days),limit:D(e.limit),minClicks:D(e[`min-clicks`]),minImpressions:D(e[`min-impressions`]),refresh:T(e.refresh),js:T(e.js)?!0:`auto`});t?I(n):(K({title:`Link recovery`,target:n.site,status:n.warnings.length>0?`unknown`:n.summary.recoverable>0?`warning`:`pass`,summary:n.summary.recoverable>0?`${U(n.summary.recoverable)} previously visible URLs need recovery review.`:`No recoverable URLs were found in the retained evidence.`,metrics:[{label:`Range`,value:`${n.range.startDate} to ${n.range.endDate}`},{label:`Checked`,value:U(n.summary.checked)},{label:`Recoverable`,value:U(n.summary.recoverable)},{label:`High severity`,value:U(n.summary.high)},{label:`Clicks at risk`,value:U(n.summary.clicksAtRisk)},{label:`Impressions at risk`,value:U(n.summary.impressionsAtRisk)}]}),n.items.length&&(q([`Severity`,`Issue`,`Clicks`,`Impr`,`URL`,`Action`],n.items.map(e=>[e.severity,e.issue,U(e.clicks),U(e.impressions),G(e.url,56),G(e.recommendation.action,72)])),J(`Top recovery actions`,n.items.map(e=>({label:G(e.url,96),context:`${e.severity}, ${U(e.clicks)} clicks at risk`,action:e.recommendation.action})))),Y(`Warnings`,n.warnings.slice(0,10)))}}),bc=b({meta:{name:`redirect-trace`,description:`Trace redirects and report final indexability/canonical issues, or check a redirect map`},args:{url:{type:`string`,description:`URL to trace.`},map:{type:`string`,description:`CSV of old_url,expected_new_url lines (header optional), or one URL per line. Traces up to ${Me.toLocaleString(`en-US`)} rows, 5 at a time.`},"max-hops":{type:`string`,description:`Maximum redirect hops to follow, up to 10. Defaults to 10.`},refresh:{type:`boolean`,default:!1,description:`Bypass local HTTP cache for final page extraction.`},js:{type:`boolean`,default:!1,description:`Force JavaScript rendering for final page extraction.`},json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=w(e.map);if(t){await wc(e,t);return}let n=w(e.url);if(!n)throw new g(`INVALID_INPUT`,`Pass --url to trace one URL, or --map with a CSV of old and expected URLs.`);let r=await me({url:n,maxHops:D(e[`max-hops`]),refresh:T(e.refresh),js:T(e.js)?!0:`auto`});A(e)?I(r):(K({title:`Redirect trace`,target:r.url,status:r.summary.issues.length>0||r.summary.error?`warning`:r.summary.finalIndexable===void 0?`unknown`:`pass`,summary:[r.summary.error?`${r.summary.outcome===`timeout`?`Timed out`:`Failed`} at ${r.finalUrl}: ${r.summary.error}`:r.summary.issues.length>0?``:`${r.summary.hops} redirect ${r.summary.hops===1?`hop`:`hops`} ended at HTTP ${r.summary.finalStatus}.`,r.summary.issues.join(`, `)].filter(Boolean).join(` `),metrics:[{label:`Final URL`,value:r.finalUrl},{label:`Final status`,value:r.summary.finalStatus??`No response`},{label:`Indexable`,value:r.summary.finalIndexable===void 0?`Unknown`:r.summary.finalIndexable?`Yes`:`No`},{label:`Hops`,value:r.summary.hops}]}),R([`#`,`Status`,`URL`,`Next`],r.chain.map((e,t)=>[t+1,e.status,G(e.url,72),G(e.nextUrl??`-`,72)])),r.finalPage&&(process.stdout.write(`
|
|
68
68
|
Final page
|