seo 0.17.3 → 0.17.5

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 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,At as a,B as o,Bn as s,Bt as c,C as l,Cn as u,Cr as d,Ct as f,D as ee,Dn as p,Dt as te,E as m,En as h,Et as ne,F as re,Fn as ie,Ft as ae,G as oe,Gn as se,Gt as ce,H as le,Hn as ue,Ht as de,I as fe,In as pe,It as me,J as he,Jn as ge,Jt as _e,K as ve,Kn as ye,Kt as be,L as xe,Ln as Se,Lt as Ce,M as we,Mn as Te,Mt as Ee,N as De,Nn as Oe,Nt as ke,O as Ae,On as je,Ot as Me,P as Ne,Pn as Pe,Pt as Fe,Q as Ie,Qn as Le,Qt as Re,R as ze,Rn as Be,Rt as Ve,S as He,Sn as Ue,Sr as We,St as Ge,T as Ke,Tn as qe,Tr as Je,Tt as Ye,U as Xe,Un as Ze,Ut as Qe,V as $e,Vn as et,Vt as tt,W as nt,Wn as rt,Wt as it,X as at,Xn as ot,Xt as st,Y as ct,Yn as lt,Yt as ut,Z as dt,Zn as ft,Zt as pt,_ as mt,_n as ht,_r as gt,_t,a as vt,an as yt,ar as bt,at as xt,b as St,bn as Ct,br as wt,bt as Tt,c as Et,cn as Dt,cr as Ot,ct as kt,d as At,dn as jt,dr as Mt,dt as Nt,en as Pt,er as Ft,et as It,f as Lt,fn as Rt,fr as zt,ft as Bt,g as Vt,gn as Ht,gr as Ut,gt as Wt,h as Gt,hn as Kt,hr as qt,ht as Jt,i as Yt,in as Xt,ir as Zt,it as Qt,j as $t,jn as en,jt as tn,k as nn,kn as rn,kt as an,l as on,ln as sn,lr as cn,lt as ln,m as un,mn as dn,mr as fn,mt as pn,nn as mn,nr as hn,nt as gn,o as _n,on as vn,or as yn,ot as bn,p as xn,pn as Sn,pr as Cn,pt as wn,q as Tn,qn as En,qt as Dn,rn as On,rr as kn,rt as An,sn as jn,sr as Mn,st as Nn,t as Pn,tn as Fn,tr as In,tt as Ln,u as Rn,un as zn,ur as Bn,ut as Vn,v as Hn,vn as Un,vr as Wn,vt as Gn,w as Kn,wn as qn,wr as Jn,wt as Yn,x as Xn,xn as Zn,xr as g,y as Qn,yn as $n,yr as er,yt as tr,z as nr,zn as rr,zt as ir}from"./dist-CSPI6SOD.js";import{randomBytes as ar}from"node:crypto";import{arch as or,homedir as sr,platform as cr}from"node:os";import{basename as lr,dirname as _,join as v,posix as ur,relative as dr,resolve as fr,sep as pr,win32 as mr}from"node:path";import{constants as hr,copyFileSync as gr,createWriteStream as _r,existsSync as y,mkdirSync as vr,readFileSync as yr,readdirSync as br,realpathSync as xr,renameSync as Sr,rmSync as Cr,statSync as wr,writeFileSync as Tr}from"node:fs";import{fileURLToPath as Er}from"node:url";import{cp as Dr,mkdir as Or,open as kr,readFile as b,readdir as Ar,rename as jr,stat as Mr,writeFile as Nr}from"node:fs/promises";import{isDeepStrictEqual as Pr,stripVTControlCharacters as Fr}from"node:util";import{spawn as Ir,spawnSync as Lr}from"node:child_process";import{defineCommand as x,runCommand as Rr,runMain as zr}from"citty";import{cancel as Br,confirm as Vr,intro as Hr,isCancel as Ur,log as Wr,multiselect as Gr,note as S,outro as C,password as Kr,select as qr,text as Jr}from"@clack/prompts";import Yr from"picocolors";import Xr from"string-width";import Zr from"cli-table3";import{finished as Qr}from"node:stream/promises";import{applyEdits as $r,modify as ei,parse as ti,printParseErrorCode as ni}from"jsonc-parser";import ri from"update-notifier";const w={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 ii(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 ai(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 oi(e){return[{filename:`postmortem-summary.csv`,headers:[...w.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:[...w.steps],rows:e.steps.map((e,t)=>({rank:t+1,tool:e.tool,status:e.status,summary:e.summary}))},{filename:`workflow-actions.csv`,headers:[...w.actions],rows:e.actions.map((e,t)=>({rank:t+1,title:e.title,confidence:e.confidence,action:e.action}))},{filename:`postmortem-findings.csv`,headers:[...w.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:[...w.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:[...w.evidence],rows:e.output.update.evidence.map((e,t)=>({rank:t+1,evidence:e}))},{filename:`postmortem-confounders.csv`,headers:[...w.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:[...w.segment],rows:ii(e,t)})),...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}-unmatched.csv`,headers:[...w.unmatchedSegment],rows:ai(e,t)}))]}function si(e){return y(e)?br(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.log`)).map(t=>{let n=v(e,t.name),r=wr(n);return{path:n,size:r.size,modifiedAt:r.mtimeMs}}):[]}function ci(e,t){let n=_(e),r=lr(e,`.log`),i=0;for(;;){let e=v(n,`${r}.${t}${i?`-${i}`:``}.log`);if(!y(e))return e;i+=1}}function li(e={}){let t=e.directory??qt().logDir,n=e.now??Date.now(),r=e.maxFileBytes??8388608,i=e.maxTotalBytes??67108864,a=e.maxAgeMs??12096e5;vr(t,{recursive:!0,mode:448});let o=0,s=0;for(let e of si(t))e.size<=r||(Sr(e.path,ci(e.path,n)),o+=1);for(let e of si(t))e.modifiedAt>=n-a||(Cr(e.path,{force:!0}),s+=1);let c=si(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;Cr(e.path,{force:!0}),l-=e.size,s+=1}return{rotated:o,removed:s,sizeBytes:l}}function ui(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 di(e,t){return{type:`boolean`,default:!0,description:e,negativeDescription:t}}function T(e){return typeof e==`string`?e:void 0}function E(e){return typeof e==`boolean`?e:void 0}function fi(e){let t=T(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(E(e.js)===!0&&t&&t!==`on`)throw new g(`INVALID_INPUT`,`Use either --js or --rendering on, not both with different modes.`);return t??(E(e.js)?`on`:`auto`)}function D(e,t){let n=E(e[t]);if(n===!1)return!0;if(n===!0)return!1;let r=E(e[pi(t)]);if(r===!1)return!0;if(r===!0)return!1;if(E(e[`no-${t}`])===!0||E(e[`no${mi(t)}`])===!0)return!0}function pi(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function mi(e){let t=pi(e);return t?`${t[0]?.toUpperCase()}${t.slice(1)}`:``}function O(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 k(e,t){if(e===void 0||e===``)return;let n=O(e);if(n===void 0)throw new g(`INVALID_INPUT`,`${t} must be a number.`);return n}function A(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function hi(e){return A(e)??[]}function gi(e){let t={concurrency:O(e[`fetch-concurrency`]),intervalCap:O(e[`fetch-interval-cap`]),intervalMs:O(e[`fetch-interval-ms`])};return Object.values(t).some(e=>e!==void 0)?t:void 0}function j(e){return e.json===!0}async function _i(e,t){let n=T(e),r=T(t);if(n&&r)throw Error(`Use either --body or --body-file, not both.`);if(!n&&!r)return;let i=n??await b(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 M(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 vi(e,t={}){let n=M(e),r=(await Zn(t.refresh,t.account)).map(e=>e.siteUrl),i=gt(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 yi(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 bi(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 xi(e={}){let t=e.env??process.env,n=bi(e.columns)??bi(e.streamColumns)??bi(t.COLUMNS)??80;return Math.min(200,Math.max(40,n))}function N(e={}){let t=e.env??process.env,n=e.isTTY??!!process.stdout.isTTY,r=e.color??!!(n&&t.NO_COLOR===void 0);return{columns:xi({...e,env:t,streamColumns:e.streamColumns??process.stdout.columns}),colors:Yr.createColors(r),hasColor:r,isInteractive:n&&!t.CI}}function P(e){return Xr(Fr(e))}function Si(e,t){let n=[],r=``;for(let i of e)r&&P(`${r}${i}`)>t?(n.push(r),r=i):r+=i;return r&&n.push(r),n}function Ci(e,t){if(!e)return[``];let n=e.trim().split(/\s+/u),r=[],i=``;for(let e of n){let n=P(e)>t?Si(e,t):[e];for(let e of n)i?P(`${i} ${e}`)<=t?i+=` ${e}`:(r.push(i),i=e):i=e}return i&&r.push(i),r.length>0?r:[``]}function F(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,At as a,B as o,Bn as s,Bt as c,C as l,Cn as u,Cr as d,Ct as f,D as ee,Dn as p,Dt as te,E as m,En as h,Et as ne,F as re,Fn as ie,Ft as ae,G as oe,Gn as se,Gt as ce,H as le,Hn as ue,Ht as de,I as fe,In as pe,It as me,J as he,Jn as ge,Jt as _e,K as ve,Kn as ye,Kt as be,L as xe,Ln as Se,Lt as Ce,M as we,Mn as Te,Mt as Ee,N as De,Nn as Oe,Nt as ke,O as Ae,On as je,Ot as Me,P as Ne,Pn as Pe,Pt as Fe,Q as Ie,Qn as Le,Qt as Re,R as ze,Rn as Be,Rt as Ve,S as He,Sn as Ue,Sr as We,St as Ge,T as Ke,Tn as qe,Tr as Je,Tt as Ye,U as Xe,Un as Ze,Ut as Qe,V as $e,Vn as et,Vt as tt,W as nt,Wn as rt,Wt as it,X as at,Xn as ot,Xt as st,Y as ct,Yn as lt,Yt as ut,Z as dt,Zn as ft,Zt as pt,_ as mt,_n as ht,_r as gt,_t,a as vt,an as yt,ar as bt,at as xt,b as St,bn as Ct,br as wt,bt as Tt,c as Et,cn as Dt,cr as Ot,ct as kt,d as At,dn as jt,dr as Mt,dt as Nt,en as Pt,er as Ft,et as It,f as Lt,fn as Rt,fr as zt,ft as Bt,g as Vt,gn as Ht,gr as Ut,gt as Wt,h as Gt,hn as Kt,hr as qt,ht as Jt,i as Yt,in as Xt,ir as Zt,it as Qt,j as $t,jn as en,jt as tn,k as nn,kn as rn,kt as an,l as on,ln as sn,lr as cn,lt as ln,m as un,mn as dn,mr as fn,mt as pn,nn as mn,nr as hn,nt as gn,o as _n,on as vn,or as yn,ot as bn,p as xn,pn as Sn,pr as Cn,pt as wn,q as Tn,qn as En,qt as Dn,rn as On,rr as kn,rt as An,sn as jn,sr as Mn,st as Nn,t as Pn,tn as Fn,tr as In,tt as Ln,u as Rn,un as zn,ur as Bn,ut as Vn,v as Hn,vn as Un,vr as Wn,vt as Gn,w as Kn,wn as qn,wr as Jn,wt as Yn,x as Xn,xn as Zn,xr as g,y as Qn,yn as $n,yr as er,yt as tr,z as nr,zn as rr,zt as ir}from"./dist-B8nuX_b-.js";import{randomBytes as ar}from"node:crypto";import{arch as or,homedir as sr,platform as cr}from"node:os";import{basename as lr,dirname as _,join as v,posix as ur,relative as dr,resolve as fr,sep as pr,win32 as mr}from"node:path";import{constants as hr,copyFileSync as gr,createWriteStream as _r,existsSync as y,mkdirSync as vr,readFileSync as yr,readdirSync as br,realpathSync as xr,renameSync as Sr,rmSync as Cr,statSync as wr,writeFileSync as Tr}from"node:fs";import{fileURLToPath as Er}from"node:url";import{cp as Dr,mkdir as Or,open as kr,readFile as b,readdir as Ar,rename as jr,stat as Mr,writeFile as Nr}from"node:fs/promises";import{isDeepStrictEqual as Pr,stripVTControlCharacters as Fr}from"node:util";import{spawn as Ir,spawnSync as Lr}from"node:child_process";import{defineCommand as x,runCommand as Rr,runMain as zr}from"citty";import{cancel as Br,confirm as Vr,intro as Hr,isCancel as Ur,log as Wr,multiselect as Gr,note as S,outro as C,password as Kr,select as qr,text as Jr}from"@clack/prompts";import Yr from"picocolors";import Xr from"string-width";import Zr from"cli-table3";import{finished as Qr}from"node:stream/promises";import{applyEdits as $r,modify as ei,parse as ti,printParseErrorCode as ni}from"jsonc-parser";import ri from"update-notifier";const w={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 ii(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 ai(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 oi(e){return[{filename:`postmortem-summary.csv`,headers:[...w.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:[...w.steps],rows:e.steps.map((e,t)=>({rank:t+1,tool:e.tool,status:e.status,summary:e.summary}))},{filename:`workflow-actions.csv`,headers:[...w.actions],rows:e.actions.map((e,t)=>({rank:t+1,title:e.title,confidence:e.confidence,action:e.action}))},{filename:`postmortem-findings.csv`,headers:[...w.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:[...w.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:[...w.evidence],rows:e.output.update.evidence.map((e,t)=>({rank:t+1,evidence:e}))},{filename:`postmortem-confounders.csv`,headers:[...w.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:[...w.segment],rows:ii(e,t)})),...[`page`,`query`,`device`,`country`].map(t=>({filename:`postmortem-segment-${t}-unmatched.csv`,headers:[...w.unmatchedSegment],rows:ai(e,t)}))]}function si(e){return y(e)?br(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.log`)).map(t=>{let n=v(e,t.name),r=wr(n);return{path:n,size:r.size,modifiedAt:r.mtimeMs}}):[]}function ci(e,t){let n=_(e),r=lr(e,`.log`),i=0;for(;;){let e=v(n,`${r}.${t}${i?`-${i}`:``}.log`);if(!y(e))return e;i+=1}}function li(e={}){let t=e.directory??qt().logDir,n=e.now??Date.now(),r=e.maxFileBytes??8388608,i=e.maxTotalBytes??67108864,a=e.maxAgeMs??12096e5;vr(t,{recursive:!0,mode:448});let o=0,s=0;for(let e of si(t))e.size<=r||(Sr(e.path,ci(e.path,n)),o+=1);for(let e of si(t))e.modifiedAt>=n-a||(Cr(e.path,{force:!0}),s+=1);let c=si(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;Cr(e.path,{force:!0}),l-=e.size,s+=1}return{rotated:o,removed:s,sizeBytes:l}}function ui(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 di(e,t){return{type:`boolean`,default:!0,description:e,negativeDescription:t}}function T(e){return typeof e==`string`?e:void 0}function E(e){return typeof e==`boolean`?e:void 0}function fi(e){let t=T(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(E(e.js)===!0&&t&&t!==`on`)throw new g(`INVALID_INPUT`,`Use either --js or --rendering on, not both with different modes.`);return t??(E(e.js)?`on`:`auto`)}function D(e,t){let n=E(e[t]);if(n===!1)return!0;if(n===!0)return!1;let r=E(e[pi(t)]);if(r===!1)return!0;if(r===!0)return!1;if(E(e[`no-${t}`])===!0||E(e[`no${mi(t)}`])===!0)return!0}function pi(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function mi(e){let t=pi(e);return t?`${t[0]?.toUpperCase()}${t.slice(1)}`:``}function O(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 k(e,t){if(e===void 0||e===``)return;let n=O(e);if(n===void 0)throw new g(`INVALID_INPUT`,`${t} must be a number.`);return n}function A(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function hi(e){return A(e)??[]}function gi(e){let t={concurrency:O(e[`fetch-concurrency`]),intervalCap:O(e[`fetch-interval-cap`]),intervalMs:O(e[`fetch-interval-ms`])};return Object.values(t).some(e=>e!==void 0)?t:void 0}function j(e){return e.json===!0}async function _i(e,t){let n=T(e),r=T(t);if(n&&r)throw Error(`Use either --body or --body-file, not both.`);if(!n&&!r)return;let i=n??await b(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 M(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 vi(e,t={}){let n=M(e),r=(await Zn(t.refresh,t.account)).map(e=>e.siteUrl),i=gt(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 yi(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 bi(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 xi(e={}){let t=e.env??process.env,n=bi(e.columns)??bi(e.streamColumns)??bi(t.COLUMNS)??80;return Math.min(200,Math.max(40,n))}function N(e={}){let t=e.env??process.env,n=e.isTTY??!!process.stdout.isTTY,r=e.color??!!(n&&t.NO_COLOR===void 0);return{columns:xi({...e,env:t,streamColumns:e.streamColumns??process.stdout.columns}),colors:Yr.createColors(r),hasColor:r,isInteractive:n&&!t.CI}}function P(e){return Xr(Fr(e))}function Si(e,t){let n=[],r=``;for(let i of e)r&&P(`${r}${i}`)>t?(n.push(r),r=i):r+=i;return r&&n.push(r),n}function Ci(e,t){if(!e)return[``];let n=e.trim().split(/\s+/u),r=[],i=``;for(let e of n){let n=P(e)>t?Si(e,t):[e];for(let e of n)i?P(`${i} ${e}`)<=t?i+=` ${e}`:(r.push(i),i=e):i=e}return i&&r.push(i),r.length>0?r:[``]}function F(e,t){let n=Math.max(1,t);return e.replaceAll(`\r
4
4
  `,`
5
5
  `).split(`
6
6
  `).flatMap(e=>Ci(e,n))}function wi(e,t){if(P(e)<=t)return e;let n=Math.max(1,t-P(`...`)),r=``;for(let t of e){if(P(`${r}${t}`)>n)break;r+=t}return`${r}...`}const Ti={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 Ei(e){return e===void 0?``:String(e)}function Di(e,t){return e.map((e,n)=>{let r=t.map(e=>Ei(e[n]));return Math.min(42,Math.max(P(e),...r.map(P),4))})}function Oi(e,t,n){return e.length===0||e.length>4||!e.map((e,n)=>t.every(e=>/^-?(?:\d+(?:\.\d+)?|\d+(?:\.\d+)?%)$/u.test(Ei(e[n]).trim()))).some(Boolean)?!1:Di(e,t).reduce((e,t)=>e+t+2,0)<=n.columns}function ki(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 Ai(e,t,n){let r=Di(e,t).map(e=>e+2),i=new Zr({chars:Ti,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)=>F(ki(e,Ei(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,At as a,B as o,Bn as s,Bt as c,C as
29
29
 
30
30
  `)}function Zi(e,t,n){let r=t.filter(e=>e.trim().length>0).flatMap(e=>F(e,n.columns));return[n.colors.bold(e),...r].join(`
31
31
  `)}function Qi(e,t,n){let r=t.flatMap(e=>F(e,Math.max(1,n.columns-2)).map((e,t)=>`${t===0?`- `:` `}${e}`));return[n.colors.bold(e),...r].join(`
32
- `)}function $i(e,t){return e.length===0?t.colors.dim(`No parameters.`):Xi(e.map(e=>({title:e.name,description:e.description,meta:[e.type,e.required?`required`:`optional`]})),t,{empty:`No parameters.`})}function I(e={}){return!(e.json||!process.stdin.isTTY||!process.stdout.isTTY||process.env.CI)}function L(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?on():void 0,n=t?{...e,updateNotice:t}:e;process.stdout.write(`${JSON.stringify(n,null,2)}\n`)}function R(e){let t=Pi(e,N());t&&process.stdout.write(`${t}\n`)}function z(e,t){process.stdout.write(`${Ni(e,t,N())}\n`)}function ea(e){process.stdout.write(`${Fi(e,N())}\n`)}function ta(e,t){process.stdout.write(`${Wi(e,N(),t)}\n`)}function na(e){process.stdout.write(`${Gi(e,N())}\n`)}function ra(e){process.stdout.write(`${Vi(e,N())}\n`)}function ia(e,t){process.stdout.write(`${Yi(e,N(),t)}\n`)}function aa(e,t){process.stdout.write(`${Xi(e,N(),t)}\n`)}function oa(e,...t){process.stdout.write(`${Zi(e,t,N())}\n`)}function sa(e,t){process.stdout.write(`${Qi(e,t,N())}\n`)}function ca(e){process.stdout.write(`${$i(e,N())}\n`)}function la(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function B(e){return typeof e==`symbol`&&process.exit(1),e}function ua(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 da={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`},fa=e=>/^[\w:/.,<>@#?=&%+-]+$/.test(String(e))?String(e):`"${e}"`,pa=(e,t)=>[`seo ${e}`,...Object.entries(t??{}).filter(([,e])=>e!==void 0).map(([e,t])=>`${da[e]??`--${e}`} ${fa(t??``)}`)].join(` `),ma={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.`}},ha={"start-date":{type:`string`,description:`Optional YYYY-MM-DD.`},"end-date":{type:`string`,description:`Optional YYYY-MM-DD.`}},ga={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=T(e.detail)??`summary`;if(![`summary`,`rows`,`full`].includes(t))throw new g(`INVALID_INPUT`,`--detail is summary, rows or full.`);return t}function _a(e,t){return vi(t,{refresh:E(e.refresh),account:T(e.account)})}async function H(e,t){try{let n=await t({...we({call:pa,account:T(e.account),refresh:E(e.refresh)}),progress:ua(!j(e))});j(e)?L(n.data):process.stdout.write(`${n.text}\n`)}catch(e){throw ee(e)}}const va=x({meta:{name:`report`,description:"Start here. No --site: last week across your audited sites (beta, 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 (beta, after `seo login`)."},section:{type:`string`,description:`Optional, needs --site. One of ${[...It,xt,An].join(`, `)}. issues keeps a list of what was found for the site, on this machine. ${An} 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: ${bn.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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=T(e.section),n=[...It,xt,An];if(t&&!n.includes(t))throw new g(`INVALID_INPUT`,`--section is one of ${n.join(`, `)}.`);let r=T(e.site),i=T(e.mark),a=T(e.issues);if(i||a){if(i&&!bn.includes(i))throw new g(`INVALID_INPUT`,`--mark is one of ${bn.join(`, `)}.`);let n=await _a(e,M(r));await H(e,r=>gn({site:n,section:t,mark:i,issues:a?.split(`,`),note:T(e.note)},r));return}if(!r&&!t&&ge()){await H(e,e=>ve(e));return}let o=t===`bing`?await _a(e,r).catch(()=>M(r)):await _a(e,r).catch(async n=>{if(t||!r)throw n;return await H(e,t=>Ln({site:M(r),startDate:T(e[`start-date`]),endDate:T(e[`end-date`])},t).catch(()=>{throw n})),null});o!==null&&await H(e,n=>gn({site:o,section:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},n))}}),ya=x({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},...ha,...ga,...ma},run:async({args:e})=>{let t=T(e.url)??``;if(!/^https?:\/\/\S+$/.test(t))throw new g(`INVALID_INPUT`,`--url must be a full http(s) URL.`);let n=await _a(e,t);await H(e,r=>at({site:n,url:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},r))}}),ba=x({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/.`},...ma},run:async({args:e})=>{let t=await _a(e,T(e.site));await H(e,n=>he({site:t,date:T(e.date)??``,pages:T(e.pages)},n))}}),xa=x({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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=await _a(e,T(e.site)),n=O(e[`max-urls`]);if(n!==void 0&&(!Number.isInteger(n)||n<1||n>2e3))throw new g(`INVALID_INPUT`,`--max-urls is a whole number from 1 to ${kt}.`);await H(e,r=>ct({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset),maxUrls:n},r))}}),Sa=x({meta:{name:`data`,description:`Raw Search Console or Bing rows beside the previous period, or Clicky landing pages`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},source:{type:`string`,description:`search_console (default), bing or clicky. Bing takes the first dimension, query or page. Clicky takes the site or its Clicky site ID.`},dimensions:{type:`string`,description:`Comma-separated: ${Jt.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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=A(e.dimensions)??[`query`],n=t.filter(e=>!Jt.includes(e));if(n.length)throw new g(`INVALID_INPUT`,`Unknown dimensions: ${n.join(`, `)}. Use ${Jt.join(`, `)}.`);let i=T(e.source)??`search_console`;if(![`search_console`,`bing`,`clicky`].includes(i))throw new g(`INVALID_INPUT`,`--source is search_console, bing or clicky.`);if(i===`clicky`){let t=M(T(e.site));await H(e,async()=>Vn({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(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:nn,call:e=>pa(`data`,{source:`clicky`,site:t,detail:`rows`,offset:e})}));return}if(i===`bing`){let n=M(T(e.site));await H(e,r=>Nt({site:n,dimension:t[0]===`page`?`page`:`query`,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},r));return}let a=await _a(e,T(e.site)),o=T(e.page),s=T(e.query);await H(e,n=>Wt({site:a,dimensions:t,filters:[...o?[{dimension:`page`,operator:`contains`,expression:o}]:[],...s?[{dimension:`query`,operator:`contains`,expression:s}]:[]],startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},n))}}),Ca=x({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:dt.join(`, `)},provider:{type:`string`,description:`${Ie.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:`${Gn.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.`},...ga,account:ma.account,json:ma.json,refresh:{type:`boolean`,default:!1,description:`Ask the provider again instead of reading the result saved in the last day.`}},run:async({args:t})=>{let n=T(t.action);if(!dt.includes(n))throw new g(`INVALID_INPUT`,`The action is one of ${dt.join(`, `)}.`);let i=await r(),a=T(t.provider),o=T(t.scope);if(o&&!Gn.includes(o))throw new g(`INVALID_INPUT`,`--scope is one of ${Gn.join(`, `)}.`);let s=T(t.device);if(s&&!_t.includes(s))throw new g(`INVALID_INPUT`,`--device is one of ${_t.join(`, `)}.`);let c=A(t.keywords)??[],l=T(t.target),u=A(t.competitors)??[],d=T(t.country);if(n===`ai_answers`){if(a&&a!==`dataforseo`)throw new g(`INVALID_INPUT`,`ai_answers uses dataforseo.`);let e=A(t.tasks)??[],r=A(t.also),o=A(t.brand),s=c.length||e.length?l??``:await _a(t,l);await H(t,a=>pn({site:s,country:d??`us`,detail:V(t),offset:O(t.offset)??0,questions:c,tasks:e,also:r,brand:o,waitSeconds:240},i,a,(e,t)=>pa(`research`,{action:n,target:l,also:r?.join(`,`),brand:o?.join(`,`),tasks:t.join(`,`)||void 0,country:d,detail:`rows`,offset:e}).replace(`--action `,``)))}else await H(t,()=>e({provider:a,scope:o,depth:O(t.depth),device:s,action:n,keywords:c,target:l,competitors:u,country:d,detail:V(t),offset:O(t.offset)},i,{store:$t(E(t.refresh)),installedSerp:un,call:e=>pa(`research`,{action:n,provider:a,scope:o,depth:O(t.depth),device:s,keywords:c.join(`,`)||void 0,target:l,competitors:u.join(`,`)||void 0,country:d,detail:`rows`,offset:e}).replace(`--action `,``)}))}}),wa=x({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: ${tr.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:`${f.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:`${Tt.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:ma.json},run:async({args:e})=>{let t=T(e.preset);if(t&&!f.includes(t))throw new g(`INVALID_INPUT`,`--preset is one of ${f.join(`, `)}.`);let n=T(e[`meta-kind`]);if(n&&!Ge.includes(n))throw new g(`INVALID_INPUT`,`--meta-kind is ${Ge.join(` or `)}.`);let r=T(e.format);if(r&&!Tt.includes(r))throw new g(`INVALID_INPUT`,`--format is one of ${Tt.join(`, `)}.`);let i=T(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`),o=T(e.url),s=!o&&a.length===1&&a[0]===`rules`&&!y(`rules`);if(!s&&!!o==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 c=A(e.only);if(c?.filter(e=>!tr.includes(e))?.length)throw new g(`INVALID_INPUT`,`--only takes ${tr.join(`, `)}, comma-separated.`);let l=[].concat(e[`ignore-phrase`]??[]).filter(e=>typeof e==`string`);try{if(s){let t=await Qt({rules:!0,only:c});j(e)?L(t.data):process.stdout.write(`${t.text}\n`);return}let{pageMarkdown:u}=we({call:pa}),d=await Qt({paths:o?void 0:a,url:o,preset:t,format:r,ignoreRules:A(e.ignore),ignorePhrases:l,only:c,metaKind:n},e=>Kn(e),u&&(e=>u(e,2e5)));j(e)?L(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 ee(e)}}});function Ta(e){return e===`keychain`?`system keychain`:e===`file`?`private local file`:e===`environment`?mn:e??`missing`}function Ea(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 Da(e,t){return Ye({siteId:e,sitekey:t}).catch(e=>{throw new g(e instanceof Yn&&e.code===`auth`?`AUTH_REQUIRED`:`PROVIDER_UNAVAILABLE`,e instanceof Error?e.message:String(e))})}const Oa={type:`boolean`,default:!1,description:`Print machine-readable JSON.`},ka={type:`string`,description:`Numeric Clicky site ID.`},Aa=x({meta:{name:`connect`,description:`Check and save a Clicky site on this machine`},args:{"site-id":ka,json:Oa},run:async({args:e})=>{let t=j(e),n=I({json:t});n&&Hr(`Connect Clicky`);let r=Ea(T(e[`site-id`])??(n?B(await Jr({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?B(await Kr({message:`Clicky sitekey`,validate:e=>te(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 ${mn}.`);let a=await Da(r,i.trim()),o=await vn(r,i.trim()),s={siteId:r,domain:a,connected:!0,credentialSource:o};if(t){L(s);return}let c=`Clicky site ${r}${a?` (${a})`:``} saved in the ${Ta(o)}. Next: seo analytics clicky report --site ${r}`;n?C(c):process.stdout.write(`${c}\n`)}}),ja=x({meta:{name:`status`,description:`Show a Clicky site saved on this machine`},args:{"site-id":ka,check:{type:`boolean`,default:!1,description:`Check the saved sitekey with Clicky.`},json:Oa},run:async({args:e})=>{let t=Ea(T(e[`site-id`])),n=await yt(t),r=E(e.check);r&&n&&await Da(t,n.siteKey);let i={siteId:t,connected:!!n,credentialSource:n?.source,liveCheck:r?n?`passed`:`unavailable`:`not-requested`};j(e)?L(i):R([[`Site ID`,t],[`Connected`,i.connected?`yes`:`no`],[`Credential`,Ta(i.credentialSource)],[`Live check`,i.liveCheck]])}}),Ma=x({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.`},...ha,...ga,json:Oa},run:async({args:e})=>{let t=M(T(e.site));await H(e,async()=>Vn({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(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:nn,call:e=>`seo analytics clicky report --site ${t} --detail rows --offset ${e}`}))}}),Na=x({meta:{name:`disconnect`,description:`Remove a Clicky site saved on this machine`},args:{"site-id":ka,json:Oa},run:async({args:e})=>{let t=Ea(T(e[`site-id`]));await On(t);let n=!!process.env[mn],r={siteId:t,savedCredentialRemoved:!0,environmentCredential:n?`active`:`missing`};j(e)?L(r):process.stdout.write(n?`Saved sitekey removed. ${mn} is still active.\n`:`Clicky is disconnected for this site.
32
+ `)}function $i(e,t){return e.length===0?t.colors.dim(`No parameters.`):Xi(e.map(e=>({title:e.name,description:e.description,meta:[e.type,e.required?`required`:`optional`]})),t,{empty:`No parameters.`})}function I(e={}){return!(e.json||!process.stdin.isTTY||!process.stdout.isTTY||process.env.CI)}function L(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?on():void 0,n=t?{...e,updateNotice:t}:e;process.stdout.write(`${JSON.stringify(n,null,2)}\n`)}function R(e){let t=Pi(e,N());t&&process.stdout.write(`${t}\n`)}function z(e,t){process.stdout.write(`${Ni(e,t,N())}\n`)}function ea(e){process.stdout.write(`${Fi(e,N())}\n`)}function ta(e,t){process.stdout.write(`${Wi(e,N(),t)}\n`)}function na(e){process.stdout.write(`${Gi(e,N())}\n`)}function ra(e){process.stdout.write(`${Vi(e,N())}\n`)}function ia(e,t){process.stdout.write(`${Yi(e,N(),t)}\n`)}function aa(e,t){process.stdout.write(`${Xi(e,N(),t)}\n`)}function oa(e,...t){process.stdout.write(`${Zi(e,t,N())}\n`)}function sa(e,t){process.stdout.write(`${Qi(e,t,N())}\n`)}function ca(e){process.stdout.write(`${$i(e,N())}\n`)}function la(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function B(e){return typeof e==`symbol`&&process.exit(1),e}function ua(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 da={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`},fa=e=>/^[\w:/.,<>@#?=&%+-]+$/.test(String(e))?String(e):`"${e}"`,pa=(e,t)=>[`seo ${e}`,...Object.entries(t??{}).filter(([,e])=>e!==void 0).map(([e,t])=>`${da[e]??`--${e}`} ${fa(t??``)}`)].join(` `),ma={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.`}},ha={"start-date":{type:`string`,description:`Optional YYYY-MM-DD.`},"end-date":{type:`string`,description:`Optional YYYY-MM-DD.`}},ga={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=T(e.detail)??`summary`;if(![`summary`,`rows`,`full`].includes(t))throw new g(`INVALID_INPUT`,`--detail is summary, rows or full.`);return t}function _a(e,t){return vi(t,{refresh:E(e.refresh),account:T(e.account)})}async function H(e,t){try{let n=await t({...we({call:pa,account:T(e.account),refresh:E(e.refresh)}),progress:ua(!j(e))});j(e)?L(n.data):process.stdout.write(`${n.text}\n`)}catch(e){throw ee(e)}}const va=x({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 ${[...It,xt,An].join(`, `)}. issues keeps a list of what was found for the site, on this machine. ${An} 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: ${bn.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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=T(e.section),n=[...It,xt,An];if(t&&!n.includes(t))throw new g(`INVALID_INPUT`,`--section is one of ${n.join(`, `)}.`);let r=T(e.site),i=T(e.mark),a=T(e.issues);if(i||a){if(i&&!bn.includes(i))throw new g(`INVALID_INPUT`,`--mark is one of ${bn.join(`, `)}.`);let n=await _a(e,M(r));await H(e,r=>gn({site:n,section:t,mark:i,issues:a?.split(`,`),note:T(e.note)},r));return}if(!r&&!t&&ge()){await H(e,e=>ve(e));return}let o=t===`bing`?await _a(e,r).catch(()=>M(r)):await _a(e,r).catch(async n=>{if(t||!r)throw n;return await H(e,t=>Ln({site:M(r),startDate:T(e[`start-date`]),endDate:T(e[`end-date`])},t).catch(()=>{throw n})),null});o!==null&&await H(e,n=>gn({site:o,section:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},n))}}),ya=x({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},...ha,...ga,...ma},run:async({args:e})=>{let t=T(e.url)??``;if(!/^https?:\/\/\S+$/.test(t))throw new g(`INVALID_INPUT`,`--url must be a full http(s) URL.`);let n=await _a(e,t);await H(e,r=>at({site:n,url:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},r))}}),ba=x({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/.`},...ma},run:async({args:e})=>{let t=await _a(e,T(e.site));await H(e,n=>he({site:t,date:T(e.date)??``,pages:T(e.pages)},n))}}),xa=x({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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=await _a(e,T(e.site)),n=O(e[`max-urls`]);if(n!==void 0&&(!Number.isInteger(n)||n<1||n>2e3))throw new g(`INVALID_INPUT`,`--max-urls is a whole number from 1 to ${kt}.`);await H(e,r=>ct({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset),maxUrls:n},r))}}),Sa=x({meta:{name:`data`,description:`Raw Search Console or Bing rows beside the previous period, or Clicky landing pages`},args:{site:{type:`string`,description:`Site, URL or Search Console property.`},source:{type:`string`,description:`search_console (default), bing or clicky. Bing takes the first dimension, query or page. Clicky takes the site or its Clicky site ID.`},dimensions:{type:`string`,description:`Comma-separated: ${Jt.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.`},...ha,...ga,...ma},run:async({args:e})=>{let t=A(e.dimensions)??[`query`],n=t.filter(e=>!Jt.includes(e));if(n.length)throw new g(`INVALID_INPUT`,`Unknown dimensions: ${n.join(`, `)}. Use ${Jt.join(`, `)}.`);let i=T(e.source)??`search_console`;if(![`search_console`,`bing`,`clicky`].includes(i))throw new g(`INVALID_INPUT`,`--source is search_console, bing or clicky.`);if(i===`clicky`){let t=M(T(e.site));await H(e,async()=>Vn({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(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:nn,call:e=>pa(`data`,{source:`clicky`,site:t,detail:`rows`,offset:e})}));return}if(i===`bing`){let n=M(T(e.site));await H(e,r=>Nt({site:n,dimension:t[0]===`page`?`page`:`query`,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},r));return}let a=await _a(e,T(e.site)),o=T(e.page),s=T(e.query);await H(e,n=>Wt({site:a,dimensions:t,filters:[...o?[{dimension:`page`,operator:`contains`,expression:o}]:[],...s?[{dimension:`query`,operator:`contains`,expression:s}]:[]],startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},n))}}),Ca=x({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:dt.join(`, `)},provider:{type:`string`,description:`${Ie.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:`${Gn.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.`},...ga,account:ma.account,json:ma.json,refresh:{type:`boolean`,default:!1,description:`Ask the provider again instead of reading the result saved in the last day.`}},run:async({args:t})=>{let n=T(t.action);if(!dt.includes(n))throw new g(`INVALID_INPUT`,`The action is one of ${dt.join(`, `)}.`);let i=await r(),a=T(t.provider),o=T(t.scope);if(o&&!Gn.includes(o))throw new g(`INVALID_INPUT`,`--scope is one of ${Gn.join(`, `)}.`);let s=T(t.device);if(s&&!_t.includes(s))throw new g(`INVALID_INPUT`,`--device is one of ${_t.join(`, `)}.`);let c=A(t.keywords)??[],l=T(t.target),u=A(t.competitors)??[],d=T(t.country);if(n===`ai_answers`){if(a&&a!==`dataforseo`)throw new g(`INVALID_INPUT`,`ai_answers uses dataforseo.`);let e=A(t.tasks)??[],r=A(t.also),o=A(t.brand),s=c.length||e.length?l??``:await _a(t,l);await H(t,a=>pn({site:s,country:d??`us`,detail:V(t),offset:O(t.offset)??0,questions:c,tasks:e,also:r,brand:o,waitSeconds:240},i,a,(e,t)=>pa(`research`,{action:n,target:l,also:r?.join(`,`),brand:o?.join(`,`),tasks:t.join(`,`)||void 0,country:d,detail:`rows`,offset:e}).replace(`--action `,``)))}else await H(t,()=>e({provider:a,scope:o,depth:O(t.depth),device:s,action:n,keywords:c,target:l,competitors:u,country:d,detail:V(t),offset:O(t.offset)},i,{store:$t(E(t.refresh)),installedSerp:un,call:e=>pa(`research`,{action:n,provider:a,scope:o,depth:O(t.depth),device:s,keywords:c.join(`,`)||void 0,target:l,competitors:u.join(`,`)||void 0,country:d,detail:`rows`,offset:e}).replace(`--action `,``)}))}}),wa=x({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: ${tr.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:`${f.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:`${Tt.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:ma.json},run:async({args:e})=>{let t=T(e.preset);if(t&&!f.includes(t))throw new g(`INVALID_INPUT`,`--preset is one of ${f.join(`, `)}.`);let n=T(e[`meta-kind`]);if(n&&!Ge.includes(n))throw new g(`INVALID_INPUT`,`--meta-kind is ${Ge.join(` or `)}.`);let r=T(e.format);if(r&&!Tt.includes(r))throw new g(`INVALID_INPUT`,`--format is one of ${Tt.join(`, `)}.`);let i=T(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`),o=T(e.url),s=!o&&a.length===1&&a[0]===`rules`&&!y(`rules`);if(!s&&!!o==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 c=A(e.only);if(c?.filter(e=>!tr.includes(e))?.length)throw new g(`INVALID_INPUT`,`--only takes ${tr.join(`, `)}, comma-separated.`);let l=[].concat(e[`ignore-phrase`]??[]).filter(e=>typeof e==`string`);try{if(s){let t=await Qt({rules:!0,only:c});j(e)?L(t.data):process.stdout.write(`${t.text}\n`);return}let{pageMarkdown:u}=we({call:pa}),d=await Qt({paths:o?void 0:a,url:o,preset:t,format:r,ignoreRules:A(e.ignore),ignorePhrases:l,only:c,metaKind:n},e=>Kn(e),u&&(e=>u(e,2e5)));j(e)?L(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 ee(e)}}});function Ta(e){return e===`keychain`?`system keychain`:e===`file`?`private local file`:e===`environment`?mn:e??`missing`}function Ea(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 Da(e,t){return Ye({siteId:e,sitekey:t}).catch(e=>{throw new g(e instanceof Yn&&e.code===`auth`?`AUTH_REQUIRED`:`PROVIDER_UNAVAILABLE`,e instanceof Error?e.message:String(e))})}const Oa={type:`boolean`,default:!1,description:`Print machine-readable JSON.`},ka={type:`string`,description:`Numeric Clicky site ID.`},Aa=x({meta:{name:`connect`,description:`Check and save a Clicky site on this machine`},args:{"site-id":ka,json:Oa},run:async({args:e})=>{let t=j(e),n=I({json:t});n&&Hr(`Connect Clicky`);let r=Ea(T(e[`site-id`])??(n?B(await Jr({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?B(await Kr({message:`Clicky sitekey`,validate:e=>te(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 ${mn}.`);let a=await Da(r,i.trim()),o=await vn(r,i.trim()),s={siteId:r,domain:a,connected:!0,credentialSource:o};if(t){L(s);return}let c=`Clicky site ${r}${a?` (${a})`:``} saved in the ${Ta(o)}. Next: seo analytics clicky report --site ${r}`;n?C(c):process.stdout.write(`${c}\n`)}}),ja=x({meta:{name:`status`,description:`Show a Clicky site saved on this machine`},args:{"site-id":ka,check:{type:`boolean`,default:!1,description:`Check the saved sitekey with Clicky.`},json:Oa},run:async({args:e})=>{let t=Ea(T(e[`site-id`])),n=await yt(t),r=E(e.check);r&&n&&await Da(t,n.siteKey);let i={siteId:t,connected:!!n,credentialSource:n?.source,liveCheck:r?n?`passed`:`unavailable`:`not-requested`};j(e)?L(i):R([[`Site ID`,t],[`Connected`,i.connected?`yes`:`no`],[`Credential`,Ta(i.credentialSource)],[`Live check`,i.liveCheck]])}}),Ma=x({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.`},...ha,...ga,json:Oa},run:async({args:e})=>{let t=M(T(e.site));await H(e,async()=>Vn({site:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(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:nn,call:e=>`seo analytics clicky report --site ${t} --detail rows --offset ${e}`}))}}),Na=x({meta:{name:`disconnect`,description:`Remove a Clicky site saved on this machine`},args:{"site-id":ka,json:Oa},run:async({args:e})=>{let t=Ea(T(e[`site-id`]));await On(t);let n=!!process.env[mn],r={siteId:t,savedCredentialRemoved:!0,environmentCredential:n?`active`:`missing`};j(e)?L(r):process.stdout.write(n?`Saved sitekey removed. ${mn} is still active.\n`:`Clicky is disconnected for this site.
33
33
  `)}}),Pa=x({meta:{name:`clicky`,description:`Read Clicky, or save a Clicky site on this machine only`},subCommands:{connect:Aa,status:ja,report:Ma,disconnect:Na}}),Fa=x({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 en(T(e.account)),n=t.flatMap(e=>e.propertySummaries.map(t=>({account:e.displayName??e.account,property:i(t.property),displayName:t.displayName??t.property})));j(e)?L({accountSummaries:t,properties:n}):z([`Property`,`Name`,`Account`],n.map(e=>[e.property,e.displayName,e.account]))}}),Ia=x({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."},...ha,...ga,json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:async({args:e})=>{let t=yi(T(e.property));await H(e,async()=>wn({property:t,startDate:T(e[`start-date`]),endDate:T(e[`end-date`]),detail:V(e),offset:O(e.offset)},await Bt(await m(),t,Pe.signIn),{signIn:Pe.signIn,call:e=>`seo analytics google report --property ${t} --detail rows --offset ${e}`}))}}),La=x({meta:{name:`google`,description:`Read Google Analytics properties and reports`},subCommands:{properties:Fa,report:Ia}}),Ra=x({meta:{name:`analytics`,description:`Read analytics data from connected providers`},subCommands:{clicky:Pa,google:La}});function za(){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 Ba(){return S(za(),`Google sign-in`),ie()}function Va(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 Ha(e){return e.active===`keychain`?`system keychain`:e.configured===`keychain`?`private file fallback`:`private file`}function Ua(e){return e===`shared`?`SEO Skill app`:`Local OAuth config`}function Wa(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`,Ua(e.clientSource)],[`Expires`,ui(e.expiresAt)]),t}const Ga=x({meta:{name:`auth`,description:`Authentication commands`},subCommands:{login:x({meta:{name:`login`,description:`Run Google OAuth flow`},run:async()=>{if((await pe()).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 Ba();R(Wa({accountEmail:e.account_email,clientSource:e.client_source,expiresAt:e.expires_at,scope:e.scope}))}}),logout:x({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 pe(),n=T(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 Be(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:x({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 pe();if(t.activeMode===`service-account`){let n={mode:`service-account`,account:t.identity??null,source:Va(t.serviceAccount.source)};if(j(e)){L(n);return}R([[`Account type`,`Service account`],[`Account`,t.identity??`Invalid configuration`],[`Credentials`,n.source],[`Access`,`Search Console and Google Analytics, read only`]]);return}let n=T(e.account),r=n?await ue(n):t.tokens;if(n&&!r)throw new g(`AUTH_REQUIRED`,`Google account ${n} is not connected.`);if(r)j(e)?L({mode:`oauth`,account:r.account_email,scopes:r.scope.split(/\s+/u).filter(Boolean),clientSource:r.client_source,expiresAt:r.expires_at}):R(Wa({accountEmail:r.account_email,clientSource:r.client_source,expiresAt:r.expires_at,scope:r.scope}));else{if(j(e)){L({mode:`oauth`,account:null});return}process.stdout.write(`Not logged in.
34
34
  `)}}}),status:x({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 pe(),n=T(e.account),r=n?await ue(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 s():void 0;if(j(e)){L({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`,Va(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]),R(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 s();R([[`Account`,r.account_email],[`Connected accounts`,String(t.accounts.length)],[`Scopes`,r.scope],[`Client`,Ua(r.client_source)],[`Expires`,ui(r.expires_at)],[`Tokens file`,qt().tokensFile],[`Token storage`,Ha(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:x({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 rt(e.keychain?`keychain`:`file`):await s();j(e)?L(t):R([[`Configured storage`,t.configured],[`Active storage`,Ha(t)],...t.reason?[[`Note`,t.reason]]:[]])}}),refresh:x({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 pe()).activeMode===`service-account`){process.stdout.write(`Service accounts request short-lived Google tokens automatically. No local refresh token is stored.
35
35
  `);return}let t=await Se(T(e.account));process.stdout.write(`Refreshed. New expiry ${new Date(t.expires_at).toISOString()}.\n`)}}),accounts:x({meta:{name:`accounts`,description:`List saved Google accounts`},args:{json:{type:`boolean`,default:!1,description:`Print machine-readable JSON.`}},run:({args:e})=>{let t=et();j(e)?L({accounts:t}):t.length===0?process.stdout.write(`No Google accounts are connected.
@@ -61,7 +61,7 @@ Updates
61
61
  `),`Setup will`),S(Us.join(`
62
62
  `),`Then run`),C(`Dry run complete. Nothing was changed.`));return}fn();let n=I({json:t}),r=await Ls({interactive:n})??await Bs({interactive:n}),i=n?await Hs():[],a=n?await Vs():{status:`skipped`};if(t){L({auth:r,mcp:i,skill:a,next:Us});return}R([[`Sign-in`,Gs(r)],[`MCP server`,qs(i)],[`SEO skill`,Ks(a)]]);let o=i.filter(e=>e.error);o.length&&S(o.map(e=>`${e.client}: ${e.error}`).join(`
63
63
  `),`MCP setup skipped`),a.error&&S(a.error,`SEO skill install failed`),S(`seo sites list your Search Console properties
64
- seo report --site <site> run the main report for one of them`,`Try next`),C(`Setup complete.`),Js()}const Xs=x({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})=>Ys(e)}),Zs=x({...Xs,meta:{name:`start`,description:`Start here: sign in with Google, then add the MCP server and skill to your agents`}}),Qs=x({...Zs,meta:{name:`init`,description:"Legacy alias for `seo start`."}}),$s=x({meta:{name:`logs`,description:`Manage local log retention`},subCommands:{prune:x({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=li();j(e)?L(t):e.quiet||process.stdout.write(`Rotated ${t.rotated} and removed ${t.removed} log files. ${la(t.sizeBytes)} retained.\n`)}})}}),ec=[{client:`claude-desktop`,flag:`claude-desktop`},{client:`claude-code`,flag:`claude-code`},{client:`codex`,flag:`codex`},{client:`cursor`,flag:`cursor`}];function tc(e,t){return E(e.all)?t:ec.filter(({flag:t})=>E(e[t])).map(({client:e})=>e)}const nc=x({meta:{name:`mcp`,description:`MCP server helpers`},subCommands:{serve:x({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-BNTdDj1i.js`);await t({test:E(e.test)})}}),install:x({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(E(e.uninstall)&&E(e.reinstall))throw new g(`INVALID_INPUT`,`Use either --uninstall or --reinstall, not both.`);let t=es(),n=rs({targets:t}),r=j(e),i=tc(e,n.map(e=>e.client));if(i.length===0){if(!I({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=B(await Gr({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=>E(e.uninstall)?Ss(t):xs(t,{reinstall:E(e.reinstall)}));if(r)L({operation:E(e.uninstall)?`uninstall`:`install`,results:o});else for(let e of o)process.stdout.write(`${e.changed?`updated`:`skipped`} ${e.client} · ${e.path}\n`)}})}}),rc=x({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=j(e),n=M(T(e.site)),r=hi(e.sitemaps),i=await me({site:n,url:T(e.url),sitemaps:r.length?r:void 0,days:O(e.days),rowLimit:O(e[`row-limit`]),maxSitemapUrls:O(e[`max-sitemap-urls`]),itemsPerSection:O(e.limit),refresh:E(e.refresh)});t?L(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(`
64
+ seo report --site <site> run the main report for one of them`,`Try next`),C(`Setup complete.`),Js()}const Xs=x({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})=>Ys(e)}),Zs=x({...Xs,meta:{name:`start`,description:`Start here: sign in with Google, then add the MCP server and skill to your agents`}}),Qs=x({...Zs,meta:{name:`init`,description:"Legacy alias for `seo start`."}}),$s=x({meta:{name:`logs`,description:`Manage local log retention`},subCommands:{prune:x({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=li();j(e)?L(t):e.quiet||process.stdout.write(`Rotated ${t.rotated} and removed ${t.removed} log files. ${la(t.sizeBytes)} retained.\n`)}})}}),ec=[{client:`claude-desktop`,flag:`claude-desktop`},{client:`claude-code`,flag:`claude-code`},{client:`codex`,flag:`codex`},{client:`cursor`,flag:`cursor`}];function tc(e,t){return E(e.all)?t:ec.filter(({flag:t})=>E(e[t])).map(({client:e})=>e)}const nc=x({meta:{name:`mcp`,description:`MCP server helpers`},subCommands:{serve:x({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-BBn_q4HK.js`);await t({test:E(e.test)})}}),install:x({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(E(e.uninstall)&&E(e.reinstall))throw new g(`INVALID_INPUT`,`Use either --uninstall or --reinstall, not both.`);let t=es(),n=rs({targets:t}),r=j(e),i=tc(e,n.map(e=>e.client));if(i.length===0){if(!I({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=B(await Gr({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=>E(e.uninstall)?Ss(t):xs(t,{reinstall:E(e.reinstall)}));if(r)L({operation:E(e.uninstall)?`uninstall`:`install`,results:o});else for(let e of o)process.stdout.write(`${e.changed?`updated`:`skipped`} ${e.client} · ${e.path}\n`)}})}}),rc=x({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=j(e),n=M(T(e.site)),r=hi(e.sitemaps),i=await me({site:n,url:T(e.url),sitemaps:r.length?r:void 0,days:O(e.days),rowLimit:O(e[`row-limit`]),maxSitemapUrls:O(e[`max-sitemap-urls`]),itemsPerSection:O(e.limit),refresh:E(e.refresh)});t?L(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(`
65
65
  Representative URL Inspection candidates
66
66
  `),z([`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))}}),ic=x({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=j(e),n=await Fe({site:M(T(e.site)),days:O(e.days),limit:O(e.limit),minClicks:O(e[`min-clicks`]),minImpressions:O(e[`min-impressions`]),refresh:E(e.refresh),js:E(e.js)?!0:`auto`});t?L(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)))}}),ac=x({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 ${h.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=T(e.map);if(t){await lc(e,t);return}let n=T(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 ae({url:n,maxHops:O(e[`max-hops`]),refresh:E(e.refresh),js:E(e.js)?!0:`auto`});j(e)?L(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}]}),z([`#`,`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(`
67
67
  Final page
@@ -131,7 +131,7 @@ Free hosted MCP server, nothing to install: https://seoskill.dev/docs/mcp
131
131
  To stay on the old version: npm i -g seo@0.2.41
132
132
  What changed: https://github.com/iannuttall/seo/blob/main/CHANGELOG.md
133
133
 
134
- `),Tr(n,JSON.stringify([...r,`0.4`]),{mode:384})}catch{}}const ed={name:`seo`,version:Mt},td=[{title:`Start here`,commands:[[`seo start`,`Sign in with Google, then add the MCP server and skill`],[`seo report`,`Last week across your audited sites (beta, after seo login)`],[`seo report --site <site>`,`One site: overview and every section`],[`seo report --site <site> --section quick-wins`,`One section of the report, with live page checks`]]},{title:`Commands`,commands:[[`seo page --url <url>`,`One page: live facts, index status, queries`],[`seo compare --date <date>`,`Before and after a date`],[`seo index`,`Pages that lost most of their clicks`],[`seo research <action>`,`Keyword, SERP, competitor and backlink data from your key`],[`seo data`,`Raw Search Console, Bing or Clicky rows`],[`seo crawl`,`Crawl a site and list technical issues`],[`seo internal-links`,`Pages that could link to a target page`],[`seo lint <files>`,`Check copy for AI writing patterns and length`],[`seo site new <folder>`,`Start a data-driven site on Astro and Cloudflare`]]},{title:`Setup`,commands:[[`seo login`,`Use your seoskill.dev account on this machine`],[`seo sites`,`List Search Console properties`],[`seo mcp install`,`Add the local MCP server to your agents`],[`seo providers`,`Connect DataForSEO or Ahrefs`],[`seo doctor`,`Check local auth and config`]]}],nd=[...td,{title:`More commands`,commands:[[`seo crawl-queue`,`Run a crawl and rank the fix queue`],[`seo rules`,`List crawler rule ids`],[`seo explain --rule missing_title`,`Explain a crawler rule`],[`seo redirect-trace`,`Trace redirects`],[`seo perf audit`,`Run a page performance audit`],[`seo index-coverage`,`Choose pages for URL Inspection`],[`seo ai-referrals`,`AI referral traffic in Google Analytics`],[`seo analytics google report`,`Google Analytics landing pages for visits from search`],[`seo updates`,`List official Google ranking updates`],[`seo export`,`Export report data to CSV`],[`seo reports list`,`List every structured report`],[`seo skill list`,`Show the packaged SEO skill`],[`seo auth`,`Manage Google auth`],[`seo cache`,`Manage local cache`],[`seo privacy`,`Show local storage paths`],[`seo telemetry status`,`Check anonymous usage telemetry`],[`seo reset`,`Delete saved credentials and all local data`]]}];function rd(e){ta(`seo v${ed.version}`,`Your own Search Console, Google Analytics and Bing data, as facts for your agent.`),process.stdout.write(`
134
+ `),Tr(n,JSON.stringify([...r,`0.4`]),{mode:384})}catch{}}const ed={name:`seo`,version:Mt},td=[{title:`Start here`,commands:[[`seo start`,`Sign in with Google, then add the MCP server and skill`],[`seo report`,`Last week across your audited sites (after seo login)`],[`seo report --site <site>`,`One site: overview and every section`],[`seo report --site <site> --section quick-wins`,`One section of the report, with live page checks`]]},{title:`Commands`,commands:[[`seo page --url <url>`,`One page: live facts, index status, queries`],[`seo compare --date <date>`,`Before and after a date`],[`seo index`,`Pages that lost most of their clicks`],[`seo research <action>`,`Keyword, SERP, competitor and backlink data from your key`],[`seo data`,`Raw Search Console, Bing or Clicky rows`],[`seo crawl`,`Crawl a site and list technical issues`],[`seo internal-links`,`Pages that could link to a target page`],[`seo lint <files>`,`Check copy for AI writing patterns and length`],[`seo site new <folder>`,`Start a data-driven site on Astro and Cloudflare`]]},{title:`Setup`,commands:[[`seo login`,`Use your seoskill.dev account on this machine`],[`seo sites`,`List Search Console properties`],[`seo mcp install`,`Add the local MCP server to your agents`],[`seo providers`,`Connect DataForSEO or Ahrefs`],[`seo doctor`,`Check local auth and config`]]}],nd=[...td,{title:`More commands`,commands:[[`seo crawl-queue`,`Run a crawl and rank the fix queue`],[`seo rules`,`List crawler rule ids`],[`seo explain --rule missing_title`,`Explain a crawler rule`],[`seo redirect-trace`,`Trace redirects`],[`seo perf audit`,`Run a page performance audit`],[`seo index-coverage`,`Choose pages for URL Inspection`],[`seo ai-referrals`,`AI referral traffic in Google Analytics`],[`seo analytics google report`,`Google Analytics landing pages for visits from search`],[`seo updates`,`List official Google ranking updates`],[`seo export`,`Export report data to CSV`],[`seo reports list`,`List every structured report`],[`seo skill list`,`Show the packaged SEO skill`],[`seo auth`,`Manage Google auth`],[`seo cache`,`Manage local cache`],[`seo privacy`,`Show local storage paths`],[`seo telemetry status`,`Check anonymous usage telemetry`],[`seo reset`,`Delete saved credentials and all local data`]]}];function rd(e){ta(`seo v${ed.version}`,`Your own Search Console, Google Analytics and Bing data, as facts for your agent.`),process.stdout.write(`
135
135
  `),ia(e.flatMap(e=>e.commands.map(([t,n])=>({category:e.title,id:t,name:n}))),{noun:`command`,categoryLabels:Object.fromEntries(e.map(e=>[e.title,e.title]))}),process.stdout.write(`
136
136
  `),oa(`More help`,"Use `seo help <command>` or `seo <command> --help` for command help.","Use `seo help all` for the longer command list.")}const id=x({meta:{name:`seo`,version:ed.version,description:`Local-first SEO CLI and MCP server`},subCommands:{init:Qs,analytics:Ra,auth:Ga,mcp:nc,doctor:Tc,status:Tc,privacy:au,telemetry:pu,reset:ou,cache:Ja,logs:$s,crawl:Do,"crawl-queue":gu,content:eo,providers:Qc,export:Zo,"index-coverage":rc,"link-recover":ic,rules:cl,explain:ll,"refresh-priorities":xu,"redirect-trace":ac,skill:iu,start:Zs,setup:Xs,site:Ol,login:Ms,logout:Fs,report:va,page:ya,compare:ba,index:xa,data:Sa,research:Ca,lint:wa,reports:sl,"segment-impact":Dc,"striking-distance":kc,"update-postmortem":Du,sites:su,"gsc-query":Io,"url-inspect":Lo,updates:cu,"traffic-anomaly":Vo,"update-correlate":Ho,"ai-referrals":uc,"audit-page":bc,"second-page":yc,cannibal:dc,decaying:mc,"quick-wins":vc,"page-opportunities":gc,perf:wc,"internal-links":hc,"ctr-underperformers":fc,"query-cluster":_c},run:async()=>{process.argv.slice(2).length===0&&process.stdout.write("Use `seo start` to set up, then `seo report` for the main report.\n")}}),ad={cannibal:`cannibalisation`,crawl:`site-crawl`,"crawl-queue":`top-fixes`,decaying:`decaying-pages`,doctor:`setup-check`,status:`setup-check`,explain:`explain-crawl-issue`,"link-recover":`link-recovery`,"query-cluster":`query-clusters`,report:`search-performance-overview`,rules:`crawler-rules`,"update-correlate":`update-correlation`},od=/* @__PURE__ */ new Set([`ai-referrals`,`audit-page`,`ctr-underperformers`,`index-coverage`,`internal-links`,`page-opportunities`,`quick-wins`,`redirect-trace`,`refresh-priorities`,`second-page`,`segment-impact`,`striking-distance`,`traffic-anomaly`,`update-postmortem`]),sd=new Set(_n().map(e=>e.id));function cd(e,t){let n=e.indexOf(t);return n>=0?e[n+1]:e.find(e=>e.startsWith(`${t}=`))?.slice(t.length+1)}function ld(e){let[t,n,r]=e;if(t)return t in Wn?Tn(t,{section:cd(e,`--section`),action:n})??void 0:t===`reports`&&n===`run`?r&&sd.has(r)?r:void 0:t===`content`&&n===`optimize`?`content-optimization`:t===`perf`&&n===`audit`?`performance-audit`:ad[t]??(od.has(t)?t:void 0)}const ud=process.argv.slice(2);function dd(e){let t=e[1];return t&&[`list`,`describe`,`run`,`-h`,`--help`].includes(t)?e:t===void 0?[`reports`,`list`]:t.startsWith(`-`)?(process.stderr.write("Running `seo report`: `seo reports` lists reports.\n"),[`report`,...e.slice(1)]):[`reports`,`run`,...e.slice(1)]}const Q=ud[0]===`mcp`&&(ud[1]===void 0||/^-(?!h$|-help$)/.test(ud[1]))&&!process.stdin.isTTY?[`mcp`,`serve`,...ud.slice(1)]:ud[0]===`reports`?dd(ud):ud;$u(Q);const fd=Vu(Q)??Wu(Q);fd&&(process.stderr.write(`${fd}\n`),process.exit(2));const pd=Bu(Q[0]??``);pd&&!Q.some(e=>[`--help`,`-h`].includes(e))&&process.stderr.write(`${pd}\n`);const md={agent:In()},hd=Q[0]===`telemetry`,gd=Q[0]===`mcp`&&Q[1]===`serve`;!hd&&!gd&&kn(md),gd||on();const _d=await Qu(ed,{argv:Q});_d!==void 0&&process.exit(_d),(Q.length===0||Q.length===1&&[`help`,`--help`,`-h`].includes(Q[0]??``))&&(rd(td),process.exit(0)),Q[0]===`help`&&Q[1]===`all`&&(rd(nd),process.exit(0));const $=Q[0]===`help`&&Q.length>1?[...Q.slice(1),`--help`]:Q;$!==Q&&(process.argv=[process.argv[0]??`node`,process.argv[1]??`seo`,...$]);const vd=$.some(e=>[`--help`,`-h`].includes(e)),yd=Q.length===1&&[`--version`,`-v`].includes(Q[0]??``),bd=vd||yd?void 0:ld($);if(vd||yd)await zr(id);else{bd&&cn(bd,md);let e=Q.includes(`--json`);try{await Rr(id,{rawArgs:$}),bd&&Mn(bd,md),[`init`,`setup`,`start`].includes($[0]??``)&&!$.includes(`--dry-run`)&&Bn(md)}catch(t){if(t?.code===`E_NO_COMMAND`&&await zr(id,{rawArgs:[...$,`--help`]}),bd)Ot(bd,t,md);else if(!hd){let e=Au($);e&&yn(e,t,md)}let n=d(t);if(e){let e=on();process.stdout.write(`${JSON.stringify({...We(n),...e?{updateNotice:e}:{}},null,2)}\n`)}else{process.stderr.write(`Error: ${n.message}\n`);let e=Mu({args:$,error:t,report:bd});e&&process.stderr.write(`Report this bug: ${e}\n`)}process.exitCode=n.exitCode}let t=e||gd?void 0:on();t&&process.stderr.write(`\n${t}\n`)}export{};
137
137
  //# sourceMappingURL=cli.js.map