seo 0.2.16 → 0.2.18
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 +24 -24
- package/dist/cli.js.map +1 -1
- package/dist/{dist-Hd0YW5ui.js → dist-B7Sb0jRt.js} +1 -1
- package/dist/{dist-BeDz2qIL.js → dist-e8x4JREt.js} +228 -52
- package/dist/dist-e8x4JREt.js.map +1 -0
- package/dist/index.d.ts +355 -2
- package/dist/index.js +1819 -502
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +1772 -382
- package/dist/mcp.js.map +1 -1
- package/dist/{package-D_ix15KL.js → package-DLnOXW-d.js} +2 -2
- package/dist/{package-D_ix15KL.js.map → package-DLnOXW-d.js.map} +1 -1
- package/evals/rank-tracking.json +40 -0
- package/package.json +10 -9
- package/skills/seo/SKILL.md +1 -0
- package/dist/dist-BeDz2qIL.js.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":["statusLabel","readConfig","readConfig","truncate","shellArg","setupCommand","truncate","urlListArgs","crawlUrlArg","crawlModeArg","writeOrPrint","parseUrlList","truncate","formatNumber","today","changeScope","slug","writeOrPrint","statusCommand","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","connectCommand","statusCommand","disconnectCommand","sitesCommand","truncate","listCommand","runCommand","truncate","truncate","setupCommand"],"sources":["../packages/core/dist/export/report-html.js","../packages/core/dist/export/update-postmortem.js","../packages/core/dist/ga4/matching.js","../packages/core/dist/utils/time.js","../packages/cli/src/args.ts","../packages/cli/src/presentation/context.ts","../packages/cli/src/presentation/render.ts","../packages/cli/src/presentation/report.ts","../packages/cli/src/presentation/views.ts","../packages/cli/src/utils.ts","../packages/cli/src/selection.ts","../packages/cli/src/commands/readiness.ts","../packages/cli/src/commands/agent-readiness.ts","../packages/cli/src/commands/analytics/google/properties.ts","../packages/cli/src/commands/output.ts","../packages/cli/src/commands/analytics/google/report.ts","../packages/cli/src/commands/analytics/google/index.ts","../packages/cli/src/commands/analytics/index.ts","../packages/cli/src/commands/auth.ts","../packages/cli/src/commands/cache.ts","../packages/cli/src/commands/shared.ts","../packages/cli/src/commands/mcp-clients.ts","../packages/cli/src/commands/mcp-config.ts","../packages/cli/src/commands/skill-install.ts","../packages/cli/src/commands/setup/prompts.ts","../packages/cli/src/commands/setup/flow.ts","../packages/cli/src/commands/setup/index.ts","../packages/cli/src/commands/clients/brand.ts","../packages/cli/src/commands/clients/keyword-sets/shared.ts","../packages/cli/src/commands/clients/keyword-sets/add.ts","../packages/cli/src/commands/clients/keyword-sets/create.ts","../packages/cli/src/commands/clients/keyword-sets/delete.ts","../packages/cli/src/commands/clients/keyword-sets/export.ts","../packages/cli/src/commands/clients/keyword-sets/output.ts","../packages/cli/src/commands/clients/keyword-sets/list.ts","../packages/cli/src/commands/clients/keyword-sets/refresh.ts","../packages/cli/src/commands/clients/keyword-sets/remove.ts","../packages/cli/src/commands/clients/keyword-sets/show.ts","../packages/cli/src/commands/clients/keyword-sets/index.ts","../packages/cli/src/commands/clients/profiles/output.ts","../packages/cli/src/commands/clients/profiles/add.ts","../packages/cli/src/commands/clients/profiles/default.ts","../packages/cli/src/commands/clients/profiles/delete.ts","../packages/cli/src/commands/clients/profiles/list.ts","../packages/cli/src/commands/clients/profiles/show.ts","../packages/cli/src/commands/clients/profiles.ts","../packages/cli/src/commands/clients/index.ts","../packages/cli/src/commands/content.ts","../packages/cli/src/json-output.ts","../packages/cli/src/presentation/crawl-report.ts","../packages/cli/src/commands/crawl.ts","../packages/cli/src/commands/crawl-reports.ts","../packages/cli/src/commands/data.ts","../packages/cli/src/commands/report-options.ts","../packages/cli/src/commands/diagnosis-reports.ts","../packages/cli/src/commands/entity-readiness.ts","../packages/cli/src/commands/experiments/change-log.ts","../packages/cli/src/commands/experiments/content-groups.ts","../packages/cli/src/commands/experiments/tests.ts","../packages/cli/src/progress.ts","../packages/cli/src/commands/reports/args.ts","../packages/cli/src/commands/export/shared.ts","../packages/cli/src/commands/export/diagnose.ts","../packages/cli/src/commands/okf-files.ts","../packages/cli/src/commands/export/knowledge.ts","../packages/cli/src/commands/export/monthly.ts","../packages/cli/src/commands/export/narrative.ts","../packages/cli/src/commands/pseo/options.ts","../packages/cli/src/commands/export/pseo.ts","../packages/cli/src/commands/export/refresh-priorities.ts","../packages/cli/src/commands/export/update-postmortem.ts","../packages/cli/src/commands/export/index.ts","../packages/cli/src/commands/indexnow.ts","../packages/cli/src/commands/init.ts","../packages/cli/src/commands/links.ts","../packages/cli/src/commands/llms.ts","../packages/cli/src/commands/logs.ts","../packages/cli/src/commands/mcp.ts","../packages/cli/src/commands/monitoring/crawl-diff.ts","../packages/cli/src/commands/monitoring/args.ts","../packages/cli/src/commands/workflows/output.ts","../packages/cli/src/commands/monitoring/output.ts","../packages/cli/src/commands/monitoring/index.ts","../packages/cli/src/commands/monitoring/index-coverage.ts","../packages/cli/src/commands/monitoring/index-watch.ts","../packages/cli/src/commands/monitoring/link-recover.ts","../packages/cli/src/commands/monitoring/redirect-trace.ts","../packages/cli/src/commands/okf.ts","../packages/cli/src/commands/opportunities/ai-referrals.ts","../packages/cli/src/commands/opportunities/cannibal.ts","../packages/cli/src/commands/opportunities/community-intent.ts","../packages/cli/src/commands/opportunities/ctr.ts","../packages/cli/src/commands/opportunities/decaying.ts","../packages/cli/src/commands/opportunities/internal-links.ts","../packages/cli/src/commands/opportunities/page-opportunities.ts","../packages/cli/src/commands/opportunities/query-cluster.ts","../packages/cli/src/commands/opportunities/quick-wins.ts","../packages/cli/src/commands/opportunities/second-page.ts","../packages/cli/src/commands/opportunities/seo-to-ai-query.ts","../packages/cli/src/commands/page-audit.ts","../packages/cli/src/commands/performance.ts","../packages/cli/src/commands/product/diagnose.ts","../packages/cli/src/commands/product/doctor.ts","../packages/cli/src/commands/product/segment-impact.ts","../packages/cli/src/commands/product/striking-distance.ts","../packages/cli/src/commands/providers/bing.ts","../packages/cli/src/commands/providers/dataforseo.ts","../packages/cli/src/commands/providers/index.ts","../packages/cli/src/commands/pseo/audit.ts","../packages/cli/src/commands/pseo/index.ts","../packages/cli/src/commands/report-catalog.ts","../packages/cli/src/commands/report-html.ts","../packages/cli/src/commands/reports/monthly.ts","../packages/cli/src/commands/reports/narrative.ts","../packages/cli/src/commands/rules.ts","../packages/cli/src/commands/schedule.ts","../packages/cli/src/commands/server-logs.ts","../packages/cli/src/commands/skill-paths.ts","../packages/cli/src/commands/skills-eval.ts","../packages/cli/src/commands/skills.ts","../packages/cli/src/commands/system.ts","../packages/cli/src/commands/telemetry.ts","../packages/cli/src/commands/workflows/crawl-queue.ts","../packages/cli/src/commands/workflows/diagnose-property.ts","../packages/cli/src/commands/workflows/refresh-priorities.ts","../packages/cli/src/commands/workflows/technical-watch.ts","../packages/cli/src/commands/workflows/update-postmortem.ts","../packages/cli/src/self-update.ts","../packages/cli/src/index.ts"],"sourcesContent":["function escapeHtml(value) {\n return value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n}\nfunction safeHttpUrl(value) {\n try {\n const url = new URL(value);\n return url.protocol === 'http:' || url.protocol === 'https:'\n ? url.toString()\n : undefined;\n }\n catch {\n return undefined;\n }\n}\nfunction siteMarkup(site) {\n const safeUrl = safeHttpUrl(site);\n const label = escapeHtml(site);\n return safeUrl\n ? `<a href=\"${escapeHtml(safeUrl)}\" rel=\"noreferrer\">${label}</a>`\n : label;\n}\nfunction list(items) {\n if (items.length === 0)\n return '<p class=\"empty\">No items to report.</p>';\n return `<ul>${items.map((item) => `<li>${escapeHtml(item)}</li>`).join('')}</ul>`;\n}\nfunction reportSections(report) {\n return report.sections\n .map((section) => `<section class=\"panel\">\n <h2>${escapeHtml(section.title)}</h2>\n ${list(section.bullets)}\n </section>`)\n .join('');\n}\nfunction additionalSections(sections) {\n return sections\n .map((section) => `<section class=\"panel\">\n <h2>${escapeHtml(section.title)}</h2>\n ${section.summary ? `<p>${escapeHtml(section.summary)}</p>` : ''}\n ${list(section.items)}\n </section>`)\n .join('');\n}\nfunction priorities(report) {\n if (report.priorities.length === 0) {\n return '<p class=\"empty\">No evidence-backed priorities were found.</p>';\n }\n return `<ol class=\"priorities\">${report.priorities\n .map((priority) => `<li>\n <div class=\"priority-heading\">\n <strong>${escapeHtml(priority.title)}</strong>\n <span class=\"confidence\">${escapeHtml(priority.confidence)} confidence</span>\n </div>\n <p>${escapeHtml(priority.action)}</p>\n </li>`)\n .join('')}</ol>`;\n}\nfunction analystEvidence(report) {\n const skipped = report.diagnosis.skippedSections ?? [];\n const attempts = report.changeMeasurementAttempts;\n return `<section class=\"panel analyst-only\">\n <h2>Evidence coverage</h2>\n <dl class=\"facts\">\n <div><dt>Data status</dt><dd>${escapeHtml(report.dataStatus)}</dd></div>\n <div><dt>Generated</dt><dd>${escapeHtml(report.generatedAt)}</dd></div>\n <div><dt>Saved changes checked</dt><dd>${attempts.length}</dd></div>\n <div><dt>Unavailable sections</dt><dd>${skipped.length}</dd></div>\n </dl>\n ${skipped.length\n ? `<h3>Unavailable sections</h3>${list(skipped.map((section) => 'reason' in section && typeof section.reason === 'string'\n ? `${section.section}: ${section.reason}`\n : section.section))}`\n : ''}\n </section>`;\n}\nconst styles = `\n :root { color-scheme: light; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; color: #17211b; background: #f2f4ef; }\n * { box-sizing: border-box; }\n body { margin: 0; line-height: 1.55; }\n a { color: inherit; text-decoration-color: #ff5b35; text-underline-offset: 0.18em; }\n main { width: min(980px, calc(100% - 32px)); margin: 32px auto 64px; }\n header { padding: clamp(28px, 6vw, 64px); color: #f9fbf7; background: #17211b; border-radius: 20px; }\n .eyebrow { margin: 0 0 12px; color: #ff7958; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }\n h1 { max-width: 760px; margin: 0; font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; letter-spacing: -0.04em; }\n header .headline { max-width: 760px; margin: 24px 0 0; font-size: clamp(1.05rem, 2vw, 1.3rem); color: #d9e1d9; }\n .meta { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 28px; color: #b9c5ba; font-size: 0.9rem; }\n .status { display: inline-flex; width: fit-content; margin-top: 22px; padding: 6px 10px; border: 1px solid #4f6153; border-radius: 999px; font-size: 0.8rem; font-weight: 700; text-transform: capitalize; }\n .panel { margin-top: 20px; padding: clamp(22px, 4vw, 38px); background: #fff; border: 1px solid #dfe4dc; border-radius: 16px; box-shadow: 0 8px 30px rgba(23, 33, 27, 0.05); }\n h2 { margin: 0 0 16px; font-size: clamp(1.25rem, 3vw, 1.65rem); letter-spacing: -0.02em; }\n h3 { margin: 26px 0 10px; font-size: 1rem; }\n p { margin: 0 0 14px; }\n ul, ol { margin: 0; padding-left: 1.25rem; }\n li + li { margin-top: 10px; }\n .priorities { list-style: none; padding: 0; counter-reset: priority; }\n .priorities > li { counter-increment: priority; padding: 18px 0 18px 52px; position: relative; border-top: 1px solid #e6eae4; }\n .priorities > li:first-child { border-top: 0; padding-top: 4px; }\n .priorities > li::before { content: counter(priority); position: absolute; left: 0; top: 16px; display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #17211b; background: #ff7958; font-weight: 800; }\n .priorities > li:first-child::before { top: 2px; }\n .priority-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }\n .confidence { color: #647067; font-size: 0.82rem; text-transform: capitalize; }\n .priorities p { margin: 8px 0 0; color: #3e4941; }\n .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }\n .facts div { padding: 14px; background: #f5f7f3; border-radius: 10px; }\n dt { color: #647067; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }\n dd { margin: 4px 0 0; font-weight: 700; }\n details summary { cursor: pointer; font-weight: 750; }\n details ul { margin-top: 14px; }\n .empty { color: #647067; font-style: italic; }\n footer { margin-top: 26px; color: #647067; font-size: 0.8rem; text-align: center; }\n @media print { :root { background: #fff; } main { width: 100%; margin: 0; } header, .panel { break-inside: avoid; box-shadow: none; } header { border-radius: 0; } }\n`;\nexport function renderReportHtml(input) {\n const report = input.report;\n const view = input.view ?? 'client';\n const title = input.title ?? 'SEO report';\n const evidenceNotesOpen = report.dataStatus !== 'complete' ? ' open' : '';\n const analyst = view === 'analyst' ? analystEvidence(report) : '';\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"robots\" content=\"noindex,nofollow\">\n <title>${escapeHtml(title)}: ${escapeHtml(report.site)}</title>\n <style>${styles}</style>\n</head>\n<body>\n <main>\n <header>\n <p class=\"eyebrow\">${escapeHtml(title)}</p>\n <h1>${siteMarkup(report.site)}</h1>\n <p class=\"headline\">${escapeHtml(report.headline)}</p>\n <div class=\"meta\">\n <span>${escapeHtml(report.period.startDate)} to ${escapeHtml(report.period.endDate)}</span>\n <span>Generated ${escapeHtml(report.generatedAt.slice(0, 10))}</span>\n <span>${escapeHtml(view)} view</span>\n </div>\n <span class=\"status\">${escapeHtml(report.dataStatus)} data</span>\n </header>\n\n <section class=\"panel\">\n <h2>Priorities</h2>\n ${priorities(report)}\n </section>\n\n ${reportSections(report)}\n ${additionalSections(input.additionalSections ?? [])}\n ${analyst}\n\n <section class=\"panel\">\n <details${evidenceNotesOpen}>\n <summary>Evidence notes and limitations</summary>\n ${list(report.caveats)}\n </details>\n </section>\n\n <footer>Generated locally from observed report evidence.</footer>\n </main>\n</body>\n</html>`;\n}\n//# sourceMappingURL=report-html.js.map","const HEADERS = {\n summary: [\n 'workflow',\n 'site',\n 'generated_at',\n 'summary',\n 'attribution',\n 'confidence',\n 'classification',\n 'updates_matched',\n 'known_confounders',\n 'page_segment_status',\n 'page_segment_eligible_rows',\n 'page_segment_returned_rows',\n 'page_segment_limited_rows',\n 'page_segment_result_limit',\n 'page_segment_source_row_limit',\n 'page_segment_source_possibly_truncated',\n 'page_segment_warnings',\n 'query_segment_status',\n 'query_segment_eligible_rows',\n 'query_segment_returned_rows',\n 'query_segment_limited_rows',\n 'query_segment_result_limit',\n 'query_segment_source_row_limit',\n 'query_segment_source_possibly_truncated',\n 'query_segment_warnings',\n 'device_segment_status',\n 'device_segment_eligible_rows',\n 'device_segment_returned_rows',\n 'device_segment_limited_rows',\n 'device_segment_result_limit',\n 'device_segment_source_row_limit',\n 'device_segment_source_possibly_truncated',\n 'device_segment_warnings',\n 'country_segment_status',\n 'country_segment_eligible_rows',\n 'country_segment_returned_rows',\n 'country_segment_limited_rows',\n 'country_segment_result_limit',\n 'country_segment_source_row_limit',\n 'country_segment_source_possibly_truncated',\n 'country_segment_warnings',\n ],\n steps: ['rank', 'tool', 'status', 'summary'],\n actions: ['rank', 'title', 'confidence', 'action'],\n findings: [\n 'dimension',\n 'data_status',\n 'eligible_rows',\n 'returned_rows',\n 'limited_rows',\n 'result_limit',\n 'unmatched_rows',\n 'summary',\n 'winner_key',\n 'winner_click_delta',\n 'winner_impression_delta',\n 'winner_position_delta',\n 'loser_key',\n 'loser_click_delta',\n 'loser_impression_delta',\n 'loser_position_delta',\n ],\n templates: [\n 'rank',\n 'direction',\n 'template',\n 'confidence',\n 'url_count',\n 'click_delta',\n 'impression_delta',\n 'movement_share',\n 'movement_share_scope',\n 'confidence_scope',\n 'eligible_rows',\n 'returned_rows',\n 'limited_rows',\n 'result_limit',\n 'source_possibly_truncated',\n 'common_terms',\n 'sample_urls',\n 'summary',\n ],\n evidence: ['rank', 'evidence'],\n confounders: [\n 'rank',\n 'source',\n 'title',\n 'date',\n 'scope',\n 'target',\n 'description',\n ],\n segment: [\n 'rank',\n 'dimension',\n 'data_status',\n 'evidence_scope',\n 'key',\n 'before_clicks',\n 'after_clicks',\n 'click_delta',\n 'before_impressions',\n 'after_impressions',\n 'impression_delta',\n 'before_position',\n 'after_position',\n 'position_delta',\n ],\n unmatchedSegment: [\n 'rank',\n 'dimension',\n 'data_status',\n 'key',\n 'retained_in',\n 'clicks',\n 'impressions',\n 'position',\n 'reason',\n ],\n};\nfunction postmortemSegmentRows(report, dimension) {\n return [\n ...report.output.segments[dimension].winners,\n ...report.output.segments[dimension].losers,\n ].map((item, index) => ({\n rank: index + 1,\n dimension,\n data_status: report.output.segments[dimension].dataStatus,\n evidence_scope: item.evidenceScope,\n key: item.key,\n before_clicks: item.beforeClicks,\n after_clicks: item.afterClicks,\n click_delta: item.clickDelta,\n before_impressions: item.beforeImpressions,\n after_impressions: item.afterImpressions,\n impression_delta: item.impressionDelta,\n before_position: item.beforePosition,\n after_position: item.afterPosition,\n position_delta: item.positionDelta,\n }));\n}\nfunction postmortemUnmatchedSegmentRows(report, dimension) {\n return report.output.segments[dimension].unmatchedSegments.map((item, index) => ({\n rank: index + 1,\n dimension,\n data_status: report.output.segments[dimension].dataStatus,\n key: item.key,\n retained_in: item.retainedIn,\n clicks: item.clicks,\n impressions: item.impressions,\n position: item.position,\n reason: item.reason,\n }));\n}\nexport function updatePostmortemCsvFiles(report) {\n return [\n {\n filename: 'postmortem-summary.csv',\n headers: [...HEADERS.summary],\n rows: [\n {\n workflow: report.workflow,\n site: report.site,\n generated_at: report.generatedAt,\n summary: report.summary,\n attribution: report.output.update.attribution,\n confidence: report.output.update.confidence,\n classification: report.output.update.classification,\n updates_matched: report.output.update.overlappingUpdates.length,\n known_confounders: report.output.update.confounders.length,\n page_segment_status: report.output.segments.page.dataStatus,\n page_segment_eligible_rows: report.output.segments.page.coverage.eligibleRows,\n page_segment_returned_rows: report.output.segments.page.coverage.returnedRows,\n page_segment_limited_rows: report.output.segments.page.coverage.limitedRows,\n page_segment_result_limit: report.output.segments.page.coverage.resultLimit,\n page_segment_source_row_limit: report.output.segments.page.coverage.sourceRowLimit,\n page_segment_source_possibly_truncated: report.output.segments.page.coverage.sourcePossiblyTruncated,\n page_segment_warnings: report.output.segments.page.warnings.join('; '),\n query_segment_status: report.output.segments.query.dataStatus,\n query_segment_eligible_rows: report.output.segments.query.coverage.eligibleRows,\n query_segment_returned_rows: report.output.segments.query.coverage.returnedRows,\n query_segment_limited_rows: report.output.segments.query.coverage.limitedRows,\n query_segment_result_limit: report.output.segments.query.coverage.resultLimit,\n query_segment_source_row_limit: report.output.segments.query.coverage.sourceRowLimit,\n query_segment_source_possibly_truncated: report.output.segments.query.coverage.sourcePossiblyTruncated,\n query_segment_warnings: report.output.segments.query.warnings.join('; '),\n device_segment_status: report.output.segments.device.dataStatus,\n device_segment_eligible_rows: report.output.segments.device.coverage.eligibleRows,\n device_segment_returned_rows: report.output.segments.device.coverage.returnedRows,\n device_segment_limited_rows: report.output.segments.device.coverage.limitedRows,\n device_segment_result_limit: report.output.segments.device.coverage.resultLimit,\n device_segment_source_row_limit: report.output.segments.device.coverage.sourceRowLimit,\n device_segment_source_possibly_truncated: report.output.segments.device.coverage.sourcePossiblyTruncated,\n device_segment_warnings: report.output.segments.device.warnings.join('; '),\n country_segment_status: report.output.segments.country.dataStatus,\n country_segment_eligible_rows: report.output.segments.country.coverage.eligibleRows,\n country_segment_returned_rows: report.output.segments.country.coverage.returnedRows,\n country_segment_limited_rows: report.output.segments.country.coverage.limitedRows,\n country_segment_result_limit: report.output.segments.country.coverage.resultLimit,\n country_segment_source_row_limit: report.output.segments.country.coverage.sourceRowLimit,\n country_segment_source_possibly_truncated: report.output.segments.country.coverage.sourcePossiblyTruncated,\n country_segment_warnings: report.output.segments.country.warnings.join('; '),\n },\n ],\n },\n {\n filename: 'workflow-steps.csv',\n headers: [...HEADERS.steps],\n rows: report.steps.map((step, index) => ({\n rank: index + 1,\n tool: step.tool,\n status: step.status,\n summary: step.summary,\n })),\n },\n {\n filename: 'workflow-actions.csv',\n headers: [...HEADERS.actions],\n rows: report.actions.map((action, index) => ({\n rank: index + 1,\n title: action.title,\n confidence: action.confidence,\n action: action.action,\n })),\n },\n {\n filename: 'postmortem-findings.csv',\n headers: [...HEADERS.findings],\n rows: report.output.insights.map((item) => ({\n dimension: item.dimension,\n data_status: item.dataStatus,\n eligible_rows: item.coverage.eligibleRows,\n returned_rows: item.coverage.returnedRows,\n limited_rows: item.coverage.limitedRows,\n result_limit: item.coverage.resultLimit,\n unmatched_rows: item.unmatchedRows,\n summary: item.summary,\n winner_key: item.winner?.key,\n winner_click_delta: item.winner?.clickDelta,\n winner_impression_delta: item.winner?.impressionDelta,\n winner_position_delta: item.winner?.positionDelta,\n loser_key: item.loser?.key,\n loser_click_delta: item.loser?.clickDelta,\n loser_impression_delta: item.loser?.impressionDelta,\n loser_position_delta: item.loser?.positionDelta,\n })),\n },\n {\n filename: 'postmortem-template-movement.csv',\n headers: [...HEADERS.templates],\n rows: report.output.templateMovement.map((item, index) => ({\n rank: index + 1,\n direction: item.direction,\n template: item.signature,\n confidence: item.confidence,\n url_count: item.urlCount,\n click_delta: item.clickDelta,\n impression_delta: item.impressionDelta,\n movement_share: item.movementShare,\n movement_share_scope: item.movementShareScope,\n confidence_scope: item.confidenceScope,\n eligible_rows: item.segmentCoverage.eligibleRows,\n returned_rows: item.segmentCoverage.returnedRows,\n limited_rows: item.segmentCoverage.limitedRows,\n result_limit: item.segmentCoverage.resultLimit,\n source_possibly_truncated: item.segmentCoverage.sourcePossiblyTruncated,\n common_terms: item.commonTerms.join('; '),\n sample_urls: item.sampleUrls.join('; '),\n summary: item.summary,\n })),\n },\n {\n filename: 'postmortem-update-evidence.csv',\n headers: [...HEADERS.evidence],\n rows: report.output.update.evidence.map((evidence, index) => ({\n rank: index + 1,\n evidence,\n })),\n },\n {\n filename: 'postmortem-confounders.csv',\n headers: [...HEADERS.confounders],\n rows: report.output.update.confounders.map((item, index) => ({\n rank: index + 1,\n source: item.source,\n title: item.title,\n date: item.date,\n scope: item.scope,\n target: item.target,\n description: item.description,\n })),\n },\n ...['page', 'query', 'device', 'country'].map((dimension) => ({\n filename: `postmortem-segment-${dimension}.csv`,\n headers: [...HEADERS.segment],\n rows: postmortemSegmentRows(report, dimension),\n })),\n ...['page', 'query', 'device', 'country'].map((dimension) => ({\n filename: `postmortem-segment-${dimension}-unmatched.csv`,\n headers: [...HEADERS.unmatchedSegment],\n rows: postmortemUnmatchedSegmentRows(report, dimension),\n })),\n ];\n}\n//# sourceMappingURL=update-postmortem.js.map","function hostnameFromUrl(value) {\n try {\n const url = new URL(value);\n if (url.protocol !== 'http:' && url.protocol !== 'https:')\n return undefined;\n return url.hostname.toLowerCase().replace(/\\.$/, '') || undefined;\n }\n catch {\n return undefined;\n }\n}\nfunction domainFromProperty(value) {\n if (!value.startsWith('sc-domain:'))\n return undefined;\n const domain = value.slice('sc-domain:'.length).trim().toLowerCase();\n if (!domain || /[/:]/.test(domain))\n return undefined;\n return domain.replace(/\\.$/, '') || undefined;\n}\nfunction matchForSite(site, streamHostname) {\n const domain = domainFromProperty(site);\n if (domain) {\n return streamHostname === domain || streamHostname.endsWith(`.${domain}`)\n ? 'domain'\n : undefined;\n }\n return hostnameFromUrl(site) === streamHostname ? 'hostname' : undefined;\n}\nexport function matchGa4WebStreams(site, candidates) {\n return candidates.flatMap((candidate) => {\n const defaultUri = candidate.stream.webStreamData?.defaultUri;\n if (!defaultUri)\n return [];\n const hostname = hostnameFromUrl(defaultUri);\n if (!hostname)\n return [];\n const match = matchForSite(site, hostname);\n if (!match)\n return [];\n return [{ ...candidate, defaultUri, hostname, match }];\n });\n}\nexport function ga4MatchReason(match, site) {\n const stream = match.stream.displayName ?? match.defaultUri;\n const location = match.match === 'domain' ? 'is inside' : 'matches';\n return `Matched Google Analytics web stream ${stream} (${match.defaultUri}): its hostname ${location} ${site}.`;\n}\n//# sourceMappingURL=matching.js.map","export function parseOlderThan(input) {\n if (!input) {\n return undefined;\n }\n const match = input.trim().match(/^(\\d+)([smhdw])$/i);\n if (!match) {\n throw new Error(`Invalid duration \"${input}\". Use values like 7d, 12h, 30m.`);\n }\n const valuePart = match[1];\n const unitPart = match[2];\n if (!valuePart || !unitPart) {\n throw new Error(`Invalid duration \"${input}\".`);\n }\n const value = Number.parseInt(valuePart, 10);\n const unit = unitPart.toLowerCase();\n const multipliers = {\n s: 1_000,\n m: 60_000,\n h: 3_600_000,\n d: 86_400_000,\n w: 604_800_000,\n };\n const multiplier = multipliers[unit];\n if (!multiplier) {\n throw new Error(`Unsupported duration unit in \"${input}\".`);\n }\n return value * multiplier;\n}\nexport function formatRelativeExpiry(expiresAt) {\n const delta = expiresAt - Date.now();\n if (delta <= 0) {\n return 'expired';\n }\n const minutes = Math.round(delta / 60_000);\n if (minutes < 60) {\n return `in ${minutes}m`;\n }\n const hours = Math.floor(minutes / 60);\n const remMinutes = minutes % 60;\n return remMinutes ? `in ${hours}h ${remMinutes}m` : `in ${hours}h`;\n}\nexport function isoDate(daysAgo = 0) {\n const date = new Date();\n date.setUTCDate(date.getUTCDate() - daysAgo);\n return date.toISOString().slice(0, 10);\n}\n//# sourceMappingURL=time.js.map","import { readFile } from 'node:fs/promises'\nimport { type JavaScriptRenderingMode, SeoError } from '@seo/core'\nimport type { BooleanArgDef } from 'citty'\n\nexport function defaultTrueBooleanArg(\n description: string,\n negativeDescription: string,\n): BooleanArgDef {\n return {\n type: 'boolean',\n default: true,\n description,\n negativeDescription,\n }\n}\n\nexport function stringArg(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined\n}\n\nexport function projectArg(args: Record<string, unknown>): string | undefined {\n const project = stringArg(args.project)\n const client = stringArg(args.client)\n if (project && client && project !== client) {\n throw new Error('Use either --project or --client, not both.')\n }\n return project ?? client\n}\n\nexport function booleanArg(value: unknown): boolean | undefined {\n return typeof value === 'boolean' ? value : undefined\n}\n\n/**\n * `--js` remains an alias for `--rendering on` while callers move to the\n * explicit modes. A mode is returned even when neither flag was supplied so\n * commands can pass it straight to the core API.\n */\nexport function renderingModeArg(\n args: Record<string, unknown>,\n): JavaScriptRenderingMode {\n const rendering = stringArg(args.rendering)\n if (\n rendering !== undefined &&\n rendering !== 'auto' &&\n rendering !== 'on' &&\n rendering !== 'off'\n ) {\n throw new SeoError('INVALID_INPUT', '--rendering must be auto, on, or off.')\n }\n if (booleanArg(args.js) === true && rendering && rendering !== 'on') {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --js or --rendering on, not both with different modes.',\n )\n }\n return rendering ?? (booleanArg(args.js) ? 'on' : 'auto')\n}\n\nexport function negatedBooleanArg(\n args: Record<string, unknown>,\n name: string,\n): boolean | undefined {\n const positive = booleanArg(args[name])\n if (positive === false) return true\n if (positive === true) return false\n const camelPositive = booleanArg(args[toCamelCase(name)])\n if (camelPositive === false) return true\n if (camelPositive === true) return false\n const explicitNo = booleanArg(args[`no-${name}`])\n if (explicitNo === true) return true\n const camelNo = booleanArg(args[`no${toPascalCase(name)}`])\n if (camelNo === true) return true\n return undefined\n}\n\nfunction toCamelCase(value: string): string {\n return value.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase())\n}\n\nfunction toPascalCase(value: string): string {\n const camel = toCamelCase(value)\n return camel ? `${camel[0]?.toUpperCase()}${camel.slice(1)}` : ''\n}\n\nexport function numberArg(value: unknown): number | undefined {\n if (typeof value === 'number') return value\n if (typeof value !== 'string' || !value.trim()) return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nexport function strictNumberArg(\n value: unknown,\n label: string,\n): number | undefined {\n if (value === undefined || value === '') return undefined\n const parsed = numberArg(value)\n if (parsed === undefined)\n throw new SeoError('INVALID_INPUT', `${label} must be a number.`)\n return parsed\n}\n\nexport function csvArg(value: unknown): string[] | undefined {\n if (typeof value !== 'string') return undefined\n const items = value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean)\n return items.length ? items : undefined\n}\n\nexport function listArg(value: unknown): string[] {\n return csvArg(value) ?? []\n}\n\nexport function fetchRateArg(args: Record<string, unknown>):\n | {\n concurrency?: number\n intervalCap?: number\n intervalMs?: number\n }\n | undefined {\n const rate = {\n concurrency: numberArg(args['fetch-concurrency']),\n intervalCap: numberArg(args['fetch-interval-cap']),\n intervalMs: numberArg(args['fetch-interval-ms']),\n }\n return Object.values(rate).some((value) => value !== undefined)\n ? rate\n : undefined\n}\n\nexport function strictFetchRateArg(args: Record<string, unknown>):\n | {\n concurrency?: number\n intervalCap?: number\n intervalMs?: number\n }\n | undefined {\n const rate = {\n concurrency: strictNumberArg(\n args['fetch-concurrency'],\n '--fetch-concurrency',\n ),\n intervalCap: strictNumberArg(\n args['fetch-interval-cap'],\n '--fetch-interval-cap',\n ),\n intervalMs: strictNumberArg(\n args['fetch-interval-ms'],\n '--fetch-interval-ms',\n ),\n }\n return Object.values(rate).some((value) => value !== undefined)\n ? rate\n : undefined\n}\n\nexport function jsonFlag(args: Record<string, unknown>): boolean {\n return args.json === true\n}\n\nexport async function jsonBodyArg(\n value: unknown,\n fileValue: unknown,\n): Promise<Record<string, unknown> | undefined> {\n const inline = stringArg(value)\n const file = stringArg(fileValue)\n if (inline && file) {\n throw new Error('Use either --body or --body-file, not both.')\n }\n if (!inline && !file) return undefined\n const source = inline ?? (await readFile(file ?? '', 'utf8'))\n const parsed = JSON.parse(source) as unknown\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new Error('JSON body must be an object.')\n }\n return parsed as Record<string, unknown>\n}\n","import { stripVTControlCharacters } from 'node:util'\nimport pc from 'picocolors'\nimport stringWidth from 'string-width'\n\nconst DEFAULT_COLUMNS = 80\nconst MIN_COLUMNS = 40\nconst MAX_COLUMNS = 200\n\nexport type TerminalContext = {\n columns: number\n colors: ReturnType<typeof pc.createColors>\n hasColor: boolean\n isInteractive: boolean\n}\n\nexport type TerminalContextOptions = {\n columns?: number\n color?: boolean\n env?: NodeJS.ProcessEnv\n isTTY?: boolean\n streamColumns?: number\n}\n\nfunction parsedColumns(value: number | string | undefined): number | undefined {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? Math.round(value) : undefined\n }\n if (!value) return undefined\n const parsed = Number.parseInt(value, 10)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nexport function resolveTerminalColumns(\n options: TerminalContextOptions = {},\n): number {\n const env = options.env ?? process.env\n const requested =\n parsedColumns(options.columns) ??\n parsedColumns(options.streamColumns) ??\n parsedColumns(env.COLUMNS) ??\n DEFAULT_COLUMNS\n return Math.min(MAX_COLUMNS, Math.max(MIN_COLUMNS, requested))\n}\n\nexport function createTerminalContext(\n options: TerminalContextOptions = {},\n): TerminalContext {\n const env = options.env ?? process.env\n const isTTY = options.isTTY ?? Boolean(process.stdout.isTTY)\n const hasColor = options.color ?? Boolean(isTTY && env.NO_COLOR === undefined)\n return {\n columns: resolveTerminalColumns({\n ...options,\n env,\n streamColumns: options.streamColumns ?? process.stdout.columns,\n }),\n colors: pc.createColors(hasColor),\n hasColor,\n isInteractive: isTTY && !env.CI,\n }\n}\n\nexport function visibleWidth(value: string): number {\n return stringWidth(stripVTControlCharacters(value))\n}\n\nfunction splitToken(token: string, width: number): string[] {\n const chunks: string[] = []\n let chunk = ''\n for (const character of token) {\n if (chunk && visibleWidth(`${chunk}${character}`) > width) {\n chunks.push(chunk)\n chunk = character\n } else {\n chunk += character\n }\n }\n if (chunk) chunks.push(chunk)\n return chunks\n}\n\nfunction wrapLine(value: string, width: number): string[] {\n if (!value) return ['']\n const words = value.trim().split(/\\s+/u)\n const lines: string[] = []\n let line = ''\n\n for (const word of words) {\n const pieces = visibleWidth(word) > width ? splitToken(word, width) : [word]\n for (const piece of pieces) {\n if (!line) {\n line = piece\n } else if (visibleWidth(`${line} ${piece}`) <= width) {\n line += ` ${piece}`\n } else {\n lines.push(line)\n line = piece\n }\n }\n }\n if (line) lines.push(line)\n return lines.length > 0 ? lines : ['']\n}\n\nexport function wrapText(value: string, width: number): string[] {\n const safeWidth = Math.max(1, width)\n return value\n .replaceAll('\\r\\n', '\\n')\n .split('\\n')\n .flatMap((line) => wrapLine(line, safeWidth))\n}\n\nexport function truncateText(value: string, width: number): string {\n if (visibleWidth(value) <= width) return value\n const suffix = '...'\n const available = Math.max(1, width - visibleWidth(suffix))\n let result = ''\n for (const character of value) {\n if (visibleWidth(`${result}${character}`) > available) break\n result += character\n }\n return `${result}${suffix}`\n}\n","import Table from 'cli-table3'\nimport {\n type TerminalContext,\n truncateText,\n visibleWidth,\n wrapText,\n} from './context.js'\n\nexport type TerminalCell = string | number\nexport type TerminalRow = TerminalCell[]\n\ntype TableOptions = {\n layout?: 'auto' | 'records' | 'table'\n rowNumbers?: boolean\n}\n\ntype Callout = {\n body?: string\n command?: string\n title: string\n}\n\nconst borderlessChars = {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n middle: '',\n}\n\nfunction stringCell(value: TerminalCell | undefined): string {\n return value === undefined ? '' : String(value)\n}\n\nfunction naturalColumnWidths(head: string[], rows: TerminalRow[]): number[] {\n return head.map((label, column) => {\n const values = rows.map((row) => stringCell(row[column]))\n return Math.min(\n 42,\n Math.max(visibleWidth(label), ...values.map(visibleWidth), 4),\n )\n })\n}\n\nfunction canRenderTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n): boolean {\n if (head.length === 0 || head.length > 4) return false\n const numericColumns = head.map((_, column) =>\n rows.every((row) =>\n /^-?(?:\\d+(?:\\.\\d+)?|\\d+(?:\\.\\d+)?%)$/u.test(\n stringCell(row[column]).trim(),\n ),\n ),\n )\n if (!numericColumns.some(Boolean)) return false\n const widths = naturalColumnWidths(head, rows)\n const tableWidth = widths.reduce((total, width) => total + width + 2, 0)\n return tableWidth <= context.columns\n}\n\nfunction styledValue(\n label: string,\n value: string,\n context: TerminalContext,\n): string {\n if (!/(?:status|state|assessment|data|allowed)/iu.test(label)) return value\n const normalized = value.trim().toLowerCase()\n if (['pass', 'passed', 'completed', 'allowed', 'yes'].includes(normalized)) {\n return context.colors.green(value)\n }\n if (['warn', 'warning', 'review', 'partial'].includes(normalized)) {\n return context.colors.yellow(value)\n }\n if (['fail', 'failed', 'blocked', 'no'].includes(normalized)) {\n return context.colors.red(value)\n }\n if (['unknown', 'unavailable'].includes(normalized)) {\n return context.colors.blue(value)\n }\n return value\n}\n\nfunction renderDenseTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n): string {\n const widths = naturalColumnWidths(head, rows).map((width) => width + 2)\n const table = new Table({\n chars: borderlessChars,\n colWidths: widths,\n head: head.map((label) => context.colors.bold(label)),\n style: {\n border: [],\n head: [],\n 'padding-left': 0,\n 'padding-right': 2,\n },\n wordWrap: false,\n })\n for (const row of rows) {\n table.push(\n head.map((label, column) =>\n wrapText(\n styledValue(label, stringCell(row[column]), context),\n Math.max(1, (widths[column] ?? 3) - 2),\n ).join('\\n'),\n ),\n )\n }\n return table.toString()\n}\n\nfunction renderRecordValue(\n label: string,\n value: string,\n labelWidth: number,\n context: TerminalContext,\n): string[] {\n const gap = 2\n const valueWidth = context.columns - labelWidth - gap\n if (valueWidth < 24) {\n return [\n context.colors.dim(label),\n ...wrapText(value, context.columns - 2).map((line) => ` ${line}`),\n ]\n }\n const wrapped = wrapText(value, valueWidth)\n return wrapped.map((line, index) => {\n const prefix =\n index === 0 ? label.padEnd(labelWidth) : ''.padEnd(labelWidth)\n return `${context.colors.dim(prefix)}${' '.repeat(gap)}${line}`\n })\n}\n\nexport function renderRecords(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n options: { rowNumbers?: boolean } = {},\n): string {\n const labelWidth = Math.min(\n 28,\n Math.max(...head.map((label) => visibleWidth(label)), 0),\n )\n const showNumbers = options.rowNumbers ?? false\n const digits = String(rows.length).length\n const blocks = rows.map((row, index) => {\n const lines: string[] = []\n if (showNumbers) {\n lines.push(context.colors.bold(String(index + 1).padStart(digits, '0')))\n }\n for (const [column, label] of head.entries()) {\n lines.push(\n ...renderRecordValue(\n label,\n styledValue(label, stringCell(row[column]), context),\n labelWidth,\n context,\n ),\n )\n }\n return lines.join('\\n')\n })\n return blocks.join('\\n\\n')\n}\n\nexport function renderTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n options: TableOptions = {},\n): string {\n if (rows.length === 0) return context.colors.dim('No results.')\n const useTable =\n options.layout === 'table' ||\n (options.layout !== 'records' && canRenderTable(head, rows, context))\n return useTable\n ? renderDenseTable(head, rows, context)\n : renderRecords(head, rows, context, options)\n}\n\nexport function renderKeyValues(\n rows: Array<[string, string]>,\n context: TerminalContext,\n): string {\n if (rows.length === 0) return ''\n const labelWidth = Math.min(\n 28,\n Math.max(...rows.map(([label]) => visibleWidth(label))),\n )\n return rows\n .flatMap(([label, value]) => {\n const lines = renderRecordValue(label, value, labelWidth, context)\n if (lines.length > 0) {\n const first = lines[0] ?? ''\n lines[0] = first.replace(label, context.colors.bold(label))\n }\n return lines\n })\n .join('\\n')\n}\n\nexport function renderCallout(\n callout: Callout,\n context: TerminalContext,\n): string {\n const lines = [context.colors.bold(callout.title)]\n if (callout.body) lines.push(...wrapText(callout.body, context.columns))\n if (callout.command) {\n lines.push(\n context.colors.cyan(truncateText(callout.command, context.columns)),\n )\n }\n return lines.join('\\n')\n}\n","import { type TerminalContext, wrapText } from './context.js'\n\nexport type SemanticStatus =\n | 'pass'\n | 'warning'\n | 'fail'\n | 'unknown'\n | 'info'\n | 'notApplicable'\n\nexport type SemanticDiagnostic = {\n status: SemanticStatus\n title: string\n explanation: string\n fix?: string\n evidence?: string[]\n}\n\nexport type SemanticReportSection = {\n title: string\n diagnostics: SemanticDiagnostic[]\n}\n\nexport type SemanticReportView = {\n title: string\n target?: string\n status: SemanticStatus\n summary: string\n metrics?: Array<{\n label: string\n value: string | number\n status?: SemanticStatus\n }>\n sections: SemanticReportSection[]\n notes?: string[]\n}\n\nfunction statusStyle(status: SemanticStatus, context: TerminalContext) {\n if (status === 'pass') return context.colors.green\n if (status === 'warning') return context.colors.yellow\n if (status === 'fail') return context.colors.red\n if (status === 'unknown') return context.colors.blue\n if (status === 'info') return context.colors.cyan\n return context.colors.dim\n}\n\nfunction statusLabel(status: SemanticStatus): string {\n if (status === 'warning') return 'WARN'\n if (status === 'notApplicable') return 'N/A'\n return status.toUpperCase()\n}\n\nfunction indent(value: string, spaces: number, width: number): string[] {\n const prefix = ' '.repeat(spaces)\n return wrapText(value, Math.max(1, width - spaces)).map(\n (line) => `${prefix}${line}`,\n )\n}\n\nfunction renderDiagnostic(\n diagnostic: SemanticDiagnostic,\n context: TerminalContext,\n): string {\n const style = statusStyle(diagnostic.status, context)\n const label = style(`[${statusLabel(diagnostic.status)}]`.padEnd(10))\n const titleWidth = Math.max(1, context.columns - 10)\n const titles = wrapText(diagnostic.title, titleWidth)\n const lines = titles.map(\n (line, index) =>\n `${index === 0 ? label : ' '.repeat(10)}${context.colors.bold(line)}`,\n )\n lines.push(...indent(diagnostic.explanation, 10, context.columns))\n for (const item of diagnostic.evidence ?? []) {\n const wrapped = wrapText(item, Math.max(1, context.columns - 20))\n lines.push(\n ...wrapped.map(\n (line, index) =>\n `${' '.repeat(10)}${index === 0 ? `${context.colors.dim('Evidence')} ` : ' '}${line}`,\n ),\n )\n }\n if (diagnostic.fix) {\n const wrapped = wrapText(diagnostic.fix, Math.max(1, context.columns - 15))\n lines.push(\n ...wrapped.map(\n (line, index) =>\n `${' '.repeat(10)}${index === 0 ? `${context.colors.cyan(context.colors.bold('Fix'))} ` : ' '}${line}`,\n ),\n )\n }\n return lines.join('\\n')\n}\n\nfunction renderMetrics(\n metrics: NonNullable<SemanticReportView['metrics']>,\n context: TerminalContext,\n): string {\n const line = metrics\n .map((metric) => {\n const value = String(metric.value)\n const rendered = metric.status\n ? statusStyle(metric.status, context)(value)\n : context.colors.bold(value)\n return `${metric.label} ${rendered}`\n })\n .join(context.colors.dim(' · '))\n return wrapText(line, context.columns).join('\\n')\n}\n\nexport function renderSemanticReport(\n report: SemanticReportView,\n context: TerminalContext,\n): string {\n const style = statusStyle(report.status, context)\n const output = [context.colors.bold(report.title)]\n if (report.target) output.push(context.colors.dim(report.target))\n output.push('')\n output.push(\n `${style(statusLabel(report.status))} ${wrapText(report.summary, Math.max(1, context.columns - 6)).join('\\n ')}`,\n )\n if (report.metrics?.length)\n output.push(renderMetrics(report.metrics, context))\n\n for (const section of report.sections.filter(\n (item) => item.diagnostics.length > 0,\n )) {\n output.push('', context.colors.bold(section.title))\n output.push(\n section.diagnostics\n .map((diagnostic) => renderDiagnostic(diagnostic, context))\n .join('\\n\\n'),\n )\n }\n\n if (report.notes?.length) {\n output.push('', context.colors.bold('Notes'))\n for (const note of report.notes) {\n const lines = wrapText(note, Math.max(1, context.columns - 2))\n output.push(\n ...lines.map((line, index) => `${index === 0 ? '- ' : ' '}${line}`),\n )\n }\n }\n return output.join('\\n')\n}\n","import { type TerminalContext, visibleWidth, wrapText } from './context.js'\n\nexport type CheckView = {\n detail: string\n fix?: string\n label: string\n status: 'pass' | 'warn' | 'fail'\n}\n\nexport type CatalogItemView = {\n category: string\n id: string\n name: string\n}\n\nexport type SummaryItemView = {\n description?: string\n meta?: string[]\n title: string\n}\n\nexport type ParameterView = {\n description?: string\n name: string\n required: boolean\n type: string\n}\n\nfunction plural(count: number, singular: string, multiple = `${singular}s`) {\n return count === 1 ? singular : multiple\n}\n\nfunction indented(value: string, indent: number, width: number): string[] {\n const prefix = ' '.repeat(indent)\n return wrapText(value, Math.max(1, width - indent)).map(\n (line) => `${prefix}${line}`,\n )\n}\n\nexport function renderHeading(\n title: string,\n context: TerminalContext,\n summary?: string,\n): string {\n return [\n context.colors.bold(title),\n ...(summary ? wrapText(summary, context.columns) : []),\n ].join('\\n')\n}\n\nexport function renderChecks(\n checks: CheckView[],\n context: TerminalContext,\n): string {\n const styles = {\n pass: context.colors.green,\n warn: context.colors.yellow,\n fail: context.colors.red,\n }\n return checks\n .map((check) => {\n const status = styles[check.status](check.status.toUpperCase().padEnd(4))\n const lines = [`${status} ${context.colors.bold(check.label)}`]\n lines.push(...indented(check.detail, 6, context.columns))\n if (check.fix) {\n const fixLines = wrapText(check.fix, Math.max(1, context.columns - 11))\n lines.push(\n ...fixLines.map(\n (line, index) =>\n `${' '.repeat(6)}${index === 0 ? `${context.colors.bold('Fix')} ` : ' '}${line}`,\n ),\n )\n }\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nexport function checkSummary(checks: CheckView[]): string {\n const passed = checks.filter((check) => check.status === 'pass').length\n const warnings = checks.filter((check) => check.status === 'warn').length\n const failed = checks.filter((check) => check.status === 'fail').length\n return `${passed} ${plural(passed, 'check')} passed, ${warnings} ${plural(warnings, 'warning')}, ${failed} failed.`\n}\n\nfunction renderCatalogItem(\n item: CatalogItemView,\n idWidth: number,\n context: TerminalContext,\n): string {\n const gap = 2\n const nameWidth = context.columns - idWidth - gap - 2\n if (nameWidth < 24 || visibleWidth(item.id) > idWidth) {\n return [\n ...indented(item.id, 2, context.columns).map((line) =>\n context.colors.cyan(line),\n ),\n ...indented(item.name, 4, context.columns),\n ].join('\\n')\n }\n const names = wrapText(item.name, nameWidth)\n return names\n .map((name, index) => {\n const id = index === 0 ? item.id.padEnd(idWidth) : ''.padEnd(idWidth)\n return ` ${context.colors.cyan(id)}${' '.repeat(gap)}${name}`\n })\n .join('\\n')\n}\n\nfunction categoryLabel(category: string): string {\n const value = category.replaceAll('-', ' ')\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nexport function renderCatalog(\n items: CatalogItemView[],\n context: TerminalContext,\n options: {\n categoryLabels?: Record<string, string>\n noun: string\n },\n): string {\n const groups = new Map<string, CatalogItemView[]>()\n for (const item of items) {\n const group = groups.get(item.category) ?? []\n group.push(item)\n groups.set(item.category, group)\n }\n const intro = `${items.length} ${plural(items.length, options.noun)} across ${groups.size} ${plural(groups.size, 'category', 'categories')}.`\n const idWidth = Math.min(\n 30,\n Math.max(...items.map((item) => visibleWidth(item.id)), 0),\n )\n const labelledCategories = Object.keys(options.categoryLabels ?? {}).filter(\n (category) => groups.has(category),\n )\n const remainingCategories = [...groups.keys()].filter(\n (category) => !labelledCategories.includes(category),\n )\n const sections = [...labelledCategories, ...remainingCategories].map(\n (category) => {\n const entries = groups.get(category) ?? []\n const label =\n options.categoryLabels?.[category] ?? categoryLabel(category)\n return [\n context.colors.bold(`${label} (${entries.length})`),\n ...entries.map((item) => renderCatalogItem(item, idWidth, context)),\n ].join('\\n')\n },\n )\n return [intro, ...sections].join('\\n\\n')\n}\n\nexport function renderSummaryList(\n items: SummaryItemView[],\n context: TerminalContext,\n options: { empty: string },\n): string {\n if (items.length === 0) return context.colors.dim(options.empty)\n\n return items\n .map((item) => {\n const lines = [context.colors.bold(item.title)]\n if (item.description) {\n lines.push(...indented(item.description, 2, context.columns))\n }\n const meta = item.meta?.filter(Boolean).join(' · ')\n if (meta) {\n lines.push(\n ...indented(meta, 2, context.columns).map((line) =>\n context.colors.dim(line),\n ),\n )\n }\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nexport function renderSection(\n title: string,\n paragraphs: readonly string[],\n context: TerminalContext,\n): string {\n const body = paragraphs\n .filter((paragraph) => paragraph.trim().length > 0)\n .flatMap((paragraph) => wrapText(paragraph, context.columns))\n return [context.colors.bold(title), ...body].join('\\n')\n}\n\nexport function renderBulletSection(\n title: string,\n items: readonly string[],\n context: TerminalContext,\n): string {\n const body = items.flatMap((item) => {\n const wrapped = wrapText(item, Math.max(1, context.columns - 2))\n return wrapped.map((line, index) => `${index === 0 ? '- ' : ' '}${line}`)\n })\n return [context.colors.bold(title), ...body].join('\\n')\n}\n\nexport function renderParameters(\n parameters: ParameterView[],\n context: TerminalContext,\n): string {\n if (parameters.length === 0) {\n return context.colors.dim('No parameters.')\n }\n\n return renderSummaryList(\n parameters.map((parameter) => ({\n title: parameter.name,\n description: parameter.description,\n meta: [parameter.type, parameter.required ? 'required' : 'optional'],\n })),\n context,\n { empty: 'No parameters.' },\n )\n}\n","import { createTerminalContext } from './presentation/context.js'\nimport {\n renderCallout,\n renderKeyValues,\n renderTable,\n} from './presentation/render.js'\nimport {\n renderSemanticReport,\n type SemanticReportView,\n} from './presentation/report.js'\nimport {\n type CatalogItemView,\n type CheckView,\n type ParameterView,\n renderBulletSection,\n renderCatalog,\n renderChecks,\n renderHeading,\n renderParameters,\n renderSection,\n renderSummaryList,\n type SummaryItemView,\n} from './presentation/views.js'\n\nexport function canPrompt(options: { json?: boolean } = {}): boolean {\n return Boolean(\n !options.json &&\n process.stdin.isTTY &&\n process.stdout.isTTY &&\n !process.env.CI,\n )\n}\n\nexport function printJson(data: unknown): void {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n}\n\nexport function printKeyValue(rows: Array<[string, string]>): void {\n const output = renderKeyValues(rows, createTerminalContext())\n if (output) process.stdout.write(`${output}\\n`)\n}\n\nexport function printTable(\n head: string[],\n rows: Array<Array<string | number>>,\n): void {\n process.stdout.write(`${renderTable(head, rows, createTerminalContext())}\\n`)\n}\n\nexport function printCallout(callout: {\n body?: string\n command?: string\n title: string\n}): void {\n process.stdout.write(`${renderCallout(callout, createTerminalContext())}\\n`)\n}\n\nexport function printHeading(title: string, summary?: string): void {\n process.stdout.write(\n `${renderHeading(title, createTerminalContext(), summary)}\\n`,\n )\n}\n\nexport function printChecks(checks: CheckView[]): void {\n process.stdout.write(`${renderChecks(checks, createTerminalContext())}\\n`)\n}\n\nexport function printSemanticReport(report: SemanticReportView): void {\n process.stdout.write(\n `${renderSemanticReport(report, createTerminalContext())}\\n`,\n )\n}\n\nexport function printCatalog(\n items: CatalogItemView[],\n options: {\n categoryLabels?: Record<string, string>\n noun: string\n },\n): void {\n process.stdout.write(\n `${renderCatalog(items, createTerminalContext(), options)}\\n`,\n )\n}\n\nexport function printSummaryList(\n items: SummaryItemView[],\n options: { empty: string },\n): void {\n process.stdout.write(\n `${renderSummaryList(items, createTerminalContext(), options)}\\n`,\n )\n}\n\nexport function printSection(title: string, ...paragraphs: string[]): void {\n process.stdout.write(\n `${renderSection(title, paragraphs, createTerminalContext())}\\n`,\n )\n}\n\nexport function printBulletSection(\n title: string,\n items: readonly string[],\n): void {\n process.stdout.write(\n `${renderBulletSection(title, items, createTerminalContext())}\\n`,\n )\n}\n\nexport function printParameters(parameters: ParameterView[]): void {\n process.stdout.write(\n `${renderParameters(parameters, createTerminalContext())}\\n`,\n )\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`\n }\n if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`\n }\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`\n}\n\nexport function maybeExitCancelled<T>(value: T | symbol): T {\n if (typeof value === 'symbol') {\n process.exit(1)\n }\n return value\n}\n","import { type Option, select, text } from '@clack/prompts'\nimport {\n type ClientProfile,\n ga4PropertyIdFromName,\n getClient,\n listClients,\n listGa4AccountSummaries,\n listSites,\n readConfig,\n SeoError,\n} from '@seo/core'\nimport { canPrompt, maybeExitCancelled } from './utils.js'\n\ntype ResolveOptions = {\n json?: boolean\n refresh?: boolean\n}\n\ntype SiteChoice = {\n siteUrl: string\n permissionLevel?: string\n}\n\ntype GoogleAnalyticsPropertyChoice = {\n property: string\n displayName: string\n account: string\n}\n\nexport type ClientSelection = {\n client?: ClientProfile\n site: string\n}\n\nfunction includesQuery(values: string[], query: string): boolean {\n const normalized = query.trim().toLowerCase()\n if (!normalized) return true\n return values.some((value) => value.toLowerCase().includes(normalized))\n}\n\nasync function chooseFromSearch<T>(input: {\n message: string\n searchMessage: string\n emptyMessage: string\n choices: T[]\n label: (choice: T) => string\n hint?: (choice: T) => string | undefined\n searchValues: (choice: T) => string[]\n}): Promise<T> {\n let visible = input.choices\n\n if (input.choices.length > 8) {\n const query = maybeExitCancelled(\n await text({\n message: input.searchMessage,\n placeholder: 'Type part of the name or URL, or leave blank',\n }),\n )\n visible = input.choices.filter((choice) =>\n includesQuery(input.searchValues(choice), query),\n )\n\n if (!visible.length) {\n throw new SeoError('INVALID_INPUT', input.emptyMessage)\n }\n }\n\n return maybeExitCancelled(\n await select({\n message: input.message,\n options: visible.map((choice) => {\n const hint = input.hint?.(choice)\n return {\n value: choice,\n label: input.label(choice),\n ...(hint ? { hint } : {}),\n }\n }) as Option<T>[],\n }),\n )\n}\n\nexport async function resolveSite(input: {\n site?: string\n options?: ResolveOptions\n}): Promise<string> {\n if (input.site) return input.site\n\n const config = readConfig()\n const defaultSiteKnown =\n Boolean(config.defaultSite) &&\n (config.clients.some((client) => client.siteUrl === config.defaultSite) ||\n config.sites.some((site) => site.siteUrl === config.defaultSite))\n if (config.defaultSite && defaultSiteKnown) return config.defaultSite\n\n if (input.options?.json || !canPrompt()) {\n throw new SeoError(\n 'INVALID_INPUT',\n config.defaultSite\n ? `Saved default site ${config.defaultSite} does not match any saved project. Pass --site or --project, or run \\`seo start\\` to save a new default.`\n : 'No site selected. Pass --site, use --project on supported commands, or run `seo start` in a terminal.',\n )\n }\n\n const sites = await listSites(input.options?.refresh)\n if (!sites.length) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No Search Console properties found for this Google login.',\n )\n }\n if (sites.length === 1) {\n return sites[0]?.siteUrl ?? ''\n }\n\n const choice = await chooseFromSearch<SiteChoice>({\n message: 'Choose a Search Console property',\n searchMessage: 'Search Search Console properties',\n emptyMessage: 'No Search Console properties matched that search.',\n choices: sites,\n label: (site) => site.siteUrl,\n hint: (site) => site.permissionLevel,\n searchValues: (site) => [site.siteUrl, site.permissionLevel ?? ''],\n })\n\n return choice.siteUrl\n}\n\nexport async function resolveClientSelection(input: {\n client?: string\n project?: string\n site?: string\n options?: ResolveOptions\n}): Promise<ClientSelection> {\n if (input.client && input.project && input.client !== input.project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --project or --client, not both.',\n )\n }\n const project = input.project ?? input.client\n if (project) {\n const client = getClient(project)\n if (!client) {\n throw new SeoError('INVALID_INPUT', `Project not found: ${project}`)\n }\n return { client, site: client.siteUrl }\n }\n\n const defaultClient = getClient()\n if (!input.site && defaultClient) {\n return { client: defaultClient, site: defaultClient.siteUrl }\n }\n\n return {\n site: await resolveSite({ site: input.site, options: input.options }),\n }\n}\n\nexport async function resolveClient(input: {\n client?: string\n project?: string\n options?: ResolveOptions\n}): Promise<ClientProfile | undefined> {\n if (input.client && input.project && input.client !== input.project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --project or --client, not both.',\n )\n }\n const project = input.project ?? input.client\n if (project) {\n const client = getClient(project)\n if (!client) {\n throw new SeoError('INVALID_INPUT', `Project not found: ${project}`)\n }\n return client\n }\n\n const clients = listClients()\n if (!clients.length) return undefined\n const defaultClient = getClient()\n if (defaultClient) return defaultClient\n\n if (input.options?.json || !canPrompt()) return undefined\n\n return chooseFromSearch<ClientProfile>({\n message: 'Choose a project',\n searchMessage: 'Search projects',\n emptyMessage: 'No projects matched that search.',\n choices: clients,\n label: (client) => client.name,\n hint: (client) => client.siteUrl,\n searchValues: (client) => [client.id, client.name, client.siteUrl],\n })\n}\n\nexport async function resolveGoogleAnalyticsProperty(input: {\n property?: string\n options?: ResolveOptions\n}): Promise<string> {\n if (input.property) return input.property\n\n const config = readConfig()\n if (config.analytics.google.defaultPropertyId) {\n return config.analytics.google.defaultPropertyId\n }\n\n if (input.options?.json || !canPrompt()) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'No Google Analytics property selected. Pass --property or run this command in a terminal to choose one.',\n )\n }\n\n const accountSummaries = await listGa4AccountSummaries()\n const choices = accountSummaries.flatMap((account) =>\n account.propertySummaries.map((property) => ({\n property: ga4PropertyIdFromName(property.property),\n displayName: property.displayName ?? property.property,\n account: account.displayName ?? account.account,\n })),\n )\n\n if (!choices.length) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No Google Analytics properties found for this Google login.',\n )\n }\n if (choices.length === 1) {\n return choices[0]?.property ?? ''\n }\n\n const choice = await chooseFromSearch<GoogleAnalyticsPropertyChoice>({\n message: 'Choose a Google Analytics property',\n searchMessage: 'Search Google Analytics properties',\n emptyMessage: 'No Google Analytics properties matched that search.',\n choices,\n label: (property) => `${property.displayName} (${property.property})`,\n hint: (property) => property.account,\n searchValues: (property) => [\n property.property,\n property.displayName,\n property.account,\n ],\n })\n\n return choice.property\n}\n","import {\n type AiReadinessReport,\n aiReadiness,\n type CrawlReport,\n latestCrawlReport,\n loadCrawlReport,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSemanticReport } from '../utils.js'\n\nexport async function resolveSavedCrawlReport(\n args: Record<string, unknown>,\n options: { json?: boolean } = {},\n): Promise<CrawlReport> {\n const reportId = stringArg(args['report-id'])\n if (reportId) {\n const report = loadCrawlReport(reportId)\n if (!report) throw new Error(`No saved crawl report found for ${reportId}.`)\n return report\n }\n\n const project = projectArg(args)\n const site = stringArg(args.site)\n const selection =\n project || site\n ? await resolveClientSelection({\n client: project,\n site,\n options,\n })\n : undefined\n const report = latestCrawlReport(selection?.site)\n if (!report) {\n throw new Error(\n selection?.site\n ? `No saved crawl report found for ${selection.site}. Run \\`seo crawl --project ${selection.client?.id ?? selection.site} --save\\` first.`\n : 'No saved crawl report found. Run `seo crawl <url> --save` first, or pass --report-id.',\n )\n }\n return report\n}\n\nfunction printAiReadiness(report: AiReadinessReport): void {\n const count = (status: string) =>\n report.checks.filter((check) => check.status === status).length\n const failed = count('fail')\n const warnings = count('warning')\n const unknown = count('unknown')\n const passed = count('pass')\n const status = failed\n ? 'fail'\n : warnings\n ? 'warning'\n : unknown\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: 'AI search evidence',\n target: report.url,\n status,\n summary: report.headline,\n metrics: [\n { label: 'Passed', value: passed, status: 'pass' },\n { label: 'Review', value: warnings, status: 'warning' },\n { label: 'Failed', value: failed, status: 'fail' },\n { label: 'Unknown', value: unknown, status: 'unknown' },\n ],\n sections: report.sections.map((section) => ({\n title: section.title,\n diagnostics: section.checks.map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.status === 'pass' ? undefined : check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n })),\n notes: [\n `Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const aiReadinessCommand = defineCommand({\n meta: {\n name: 'ai-readiness',\n description:\n 'Review AI-search technical evidence and optional observations',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const readiness = aiReadiness(report)\n if (json) {\n printJson(readiness)\n return\n }\n printAiReadiness(readiness)\n },\n})\n","import { type AgentReadinessReport, agentReadiness, crawlSite } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSemanticReport } from '../utils.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction inputUrl(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.agentReadinessUrl)\n const flagged = stringArg(args.url)\n if (positional && flagged && positional !== flagged) {\n throw new Error('Use either the positional URL or --url, not both.')\n }\n return positional ?? flagged\n}\n\nfunction printAgentReadiness(report: AgentReadinessReport): void {\n const status =\n report.summary.failed > 0\n ? 'fail'\n : report.summary.warnings > 0\n ? 'warning'\n : report.summary.unknown > 0\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: 'AI agent readiness',\n target: report.url,\n status,\n summary: report.headline,\n metrics: [\n { label: 'Passed', value: report.summary.passed, status: 'pass' },\n {\n label: 'Review',\n value: report.summary.warnings,\n status: 'warning',\n },\n { label: 'Failed', value: report.summary.failed, status: 'fail' },\n { label: 'Unknown', value: report.summary.unknown, status: 'unknown' },\n ],\n sections: report.sections.map((section) => ({\n title: section.title,\n diagnostics: section.checks\n .filter((check) => !['info', 'notApplicable'].includes(check.status))\n .map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.status === 'pass' ? undefined : check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n })),\n notes: [\n `Profile: ${report.profile}. Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const agentReadinessCommand = defineCommand({\n meta: {\n name: 'agent-readiness',\n description:\n 'Check content-site access, Markdown alternatives, discovery, and identity for AI agents',\n },\n args: {\n agentReadinessUrl: {\n type: 'positional',\n required: false,\n description: 'Public site URL to check.',\n },\n url: {\n type: 'string',\n description: 'Public site URL to check.',\n },\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze without fetching again.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum public HTML pages to crawl.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const url = inputUrl(args)\n const reportId = stringArg(args['report-id'])\n if (url && reportId) {\n throw new Error('Use either a URL or --report-id, not both.')\n }\n\n const crawl = url\n ? await (async () => {\n const project = projectArg(args)\n const site = stringArg(args.site)\n const selection =\n project || site\n ? await resolveClientSelection({\n client: project,\n site,\n options: { json },\n })\n : undefined\n return crawlSite({\n url,\n projectId: selection?.client?.id,\n site: selection?.site,\n maxPages: numberArg(args['max-pages']),\n fetchRate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n checkAgentDiscovery: true,\n useSitemap: true,\n checkExternal: false,\n })\n })()\n : await resolveSavedCrawlReport(args, { json })\n const readiness = agentReadiness(crawl)\n if (json) {\n printJson(readiness)\n return\n }\n printAgentReadiness(readiness)\n },\n})\n","import {\n ga4PropertyIdFromName,\n listGa4AccountSummaries,\n readConfig,\n writeConfig,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson, printTable } from '../../../utils.js'\n\nexport const googleAnalyticsPropertiesCommand = defineCommand({\n meta: {\n name: 'properties',\n description: 'List Google Analytics accounts and properties',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n save: {\n type: 'string',\n description:\n 'Save this numeric Google Analytics property ID as the default.',\n },\n },\n run: async ({ args }) => {\n const summaries = await listGa4AccountSummaries()\n const rows = summaries.flatMap((account) =>\n account.propertySummaries.map((property) => ({\n account: account.displayName ?? account.account,\n property: ga4PropertyIdFromName(property.property),\n displayName: property.displayName ?? property.property,\n })),\n )\n\n const save = stringArg(args.save)\n if (save) {\n const config = readConfig()\n config.analytics.google.defaultPropertyId = save\n writeConfig(config)\n }\n\n if (jsonFlag(args)) {\n printJson({ accountSummaries: summaries, properties: rows, saved: save })\n return\n }\n if (save) {\n process.stdout.write(`Saved default Google Analytics property ${save}.\\n`)\n }\n printTable(\n ['Property', 'Name', 'Account'],\n rows.map((row) => [row.property, row.displayName, row.account]),\n )\n },\n})\n","import { truncateText } from '../presentation/context.js'\nimport type {\n SemanticDiagnostic,\n SemanticReportView,\n SemanticStatus,\n} from '../presentation/report.js'\nimport { printSemanticReport, printTable } from '../utils.js'\n\nconst HUMAN_ROW_LIMIT = 25\ntype TableRow = Array<string | number>\ntype ActionDetail = {\n label: string\n action: string\n context?: string\n}\n\ntype ReportMetric = {\n label: string\n value: string | number\n status?: SemanticStatus\n}\n\ntype ReportSummary = {\n title: string\n target?: string\n status: SemanticStatus\n summary: string\n metrics?: ReportMetric[]\n diagnostics?: {\n title: string\n items: SemanticDiagnostic[]\n }[]\n notes?: string[]\n}\n\nexport function formatCount(value: number): string {\n return Math.round(value).toLocaleString('en-GB')\n}\n\nexport function formatPosition(value: number): string {\n return value.toFixed(1)\n}\n\nexport function formatPercent(value: number): string {\n return `${(value * 100).toFixed(1)}%`\n}\n\nexport function truncate(value: string, maxLength = 72): string {\n return truncateText(value, maxLength)\n}\n\nexport function verificationSummary(report: {\n verification?: { requested: boolean; verified: number; failed: number }\n}): string {\n if (!report.verification?.requested) return 'off'\n return `${report.verification.verified} checked, ${report.verification.failed} failed`\n}\n\nexport function reportSummaryView(summary: ReportSummary): SemanticReportView {\n return {\n title: summary.title,\n target: summary.target,\n status: summary.status,\n summary: summary.summary,\n metrics: summary.metrics,\n sections: (summary.diagnostics ?? []).map((section) => ({\n title: section.title,\n diagnostics: section.items,\n })),\n notes: summary.notes,\n }\n}\n\nexport function printReportSummary(summary: ReportSummary): void {\n printSemanticReport(reportSummaryView(summary))\n}\n\nexport function printLimitedTable(head: string[], rows: TableRow[]): void {\n printTable(head, rows.slice(0, HUMAN_ROW_LIMIT))\n if (rows.length > HUMAN_ROW_LIMIT) {\n process.stdout.write(\n `Showing ${HUMAN_ROW_LIMIT} of ${rows.length}. Use --json for full data.\\n`,\n )\n }\n}\n\nexport function printActionDetails(\n title: string,\n actions: ActionDetail[],\n limit = 5,\n): void {\n const visible = actions\n .filter((item) => item.action.trim().length > 0)\n .slice(0, limit)\n const report = actionDetailsView(title, visible)\n if (!report) return\n\n process.stdout.write('\\n')\n printSemanticReport(report)\n if (actions.length > visible.length) {\n process.stdout.write(\n `Showing ${visible.length} of ${actions.length}. Use --json for full data.\\n`,\n )\n }\n}\n\nexport function actionDetailsView(\n title: string,\n actions: ActionDetail[],\n): SemanticReportView | undefined {\n if (!actions.length) return undefined\n return {\n title,\n status: 'info',\n summary: `${actions.length} ${actions.length === 1 ? 'action' : 'actions'} shown.`,\n sections: [\n {\n title: 'Actions',\n diagnostics: actions.map((item) => ({\n status: 'info',\n title: item.label,\n explanation:\n item.context ?? 'Review the evidence before making changes.',\n fix: item.action,\n })),\n },\n ],\n }\n}\n\nexport function printNextCommand(command: string): void {\n process.stdout.write(`\\nNext: ${command}\\n`)\n}\n\nexport function printNotes(title: string, notes: string[]): void {\n const visible = notes.filter((note) => note.trim().length > 0)\n if (!visible.length) return\n process.stdout.write(`\\n${title}\\n`)\n for (const note of visible) {\n process.stdout.write(`- ${note}\\n`)\n }\n}\n","import {\n ga4RowsToObjects,\n googleAnalyticsPropertyId,\n runGa4Report,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonBodyArg,\n jsonFlag,\n projectArg,\n stringArg,\n} from '../../../args.js'\nimport {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n} from '../../../selection.js'\nimport { printJson, printTable } from '../../../utils.js'\nimport { printReportSummary } from '../../output.js'\n\ntype GoogleAnalyticsPropertySelectionDependencies = {\n resolveClient: typeof resolveClient\n resolveGoogleAnalyticsProperty: typeof resolveGoogleAnalyticsProperty\n}\n\nexport async function resolveGoogleAnalyticsReportProperty(\n input: {\n property?: string\n project?: string\n options?: { json?: boolean }\n },\n dependencies: GoogleAnalyticsPropertySelectionDependencies = {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n },\n): Promise<string> {\n if (input.property) {\n return dependencies.resolveGoogleAnalyticsProperty({\n property: input.property,\n options: input.options,\n })\n }\n\n const client = await dependencies.resolveClient({\n client: input.project,\n options: input.options,\n })\n return dependencies.resolveGoogleAnalyticsProperty({\n property: googleAnalyticsPropertyId(client),\n options: input.options,\n })\n}\n\nexport const googleAnalyticsReportCommand = defineCommand({\n meta: {\n name: 'report',\n description: 'Run a Google Analytics report',\n },\n args: {\n property: {\n type: 'string',\n description:\n 'Google Analytics property ID. If omitted in a terminal, choose one.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name with an optional Google Analytics property.',\n },\n 'start-date': { type: 'string', default: '28daysAgo' },\n 'end-date': { type: 'string', default: 'yesterday' },\n dimensions: { type: 'string', default: 'landingPage' },\n metrics: { type: 'string', default: 'sessions,totalUsers,eventCount' },\n limit: { type: 'string', default: '25' },\n body: { type: 'string' },\n 'body-file': { type: 'string' },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local Google Analytics cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const property = await resolveGoogleAnalyticsReportProperty({\n property: stringArg(args.property),\n project: projectArg(args),\n options: { json },\n })\n const body =\n (await jsonBodyArg(args.body, args['body-file'])) ??\n ({\n dateRanges: [\n {\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n },\n ],\n dimensions: (csvArg(args.dimensions) ?? []).map((name) => ({ name })),\n metrics: (csvArg(args.metrics) ?? []).map((name) => ({ name })),\n limit: stringArg(args.limit),\n } as Record<string, unknown>)\n const result = await runGa4Report(property, body as never, {\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(result)\n return\n }\n const rows = ga4RowsToObjects(result)\n printReportSummary({\n title: 'Google Analytics report',\n target: property,\n status: 'info',\n summary: `${result.rowCount ?? rows.length} rows returned for the requested dimensions and metrics.`,\n metrics: [\n { label: 'Rows', value: result.rowCount ?? rows.length },\n { label: 'Displayed', value: Math.min(rows.length, 25) },\n ],\n })\n if (rows.length) {\n const headings = Object.keys(rows[0] ?? {})\n printTable(\n headings,\n rows\n .slice(0, 25)\n .map((row) => headings.map((heading) => row[heading] ?? '')),\n )\n }\n },\n})\n","import { defineCommand } from 'citty'\nimport { googleAnalyticsPropertiesCommand } from './properties.js'\nimport { googleAnalyticsReportCommand } from './report.js'\n\nexport const googleAnalyticsCommand = defineCommand({\n meta: {\n name: 'google',\n description: 'Read Google Analytics properties and reports',\n },\n subCommands: {\n properties: googleAnalyticsPropertiesCommand,\n report: googleAnalyticsReportCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { googleAnalyticsCommand } from './google/index.js'\n\nexport const analyticsCommand = defineCommand({\n meta: {\n name: 'analytics',\n description: 'Read analytics data from connected providers',\n },\n subCommands: {\n google: googleAnalyticsCommand,\n },\n})\n","import { intro, note, outro, password, text } from '@clack/prompts'\nimport {\n authStatus,\n deleteTokens,\n formatRelativeExpiry,\n getSeoCliPaths,\n getTokenStorageStatus,\n loginWithLoopback,\n refreshAuthToken,\n SeoError,\n setTokenStorageMode,\n writeOauthClient,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n} from '../utils.js'\n\nfunction serviceAccountSource(source?: string): string {\n if (!source) return 'invalid or conflicting configuration'\n if (source === 'environment-json') {\n return 'SEO_GOOGLE_SERVICE_ACCOUNT_JSON'\n }\n if (source === 'environment-file') {\n return 'SEO_GOOGLE_SERVICE_ACCOUNT_FILE'\n }\n return 'GOOGLE_APPLICATION_CREDENTIALS'\n}\n\nfunction tokenStorageLabel(input: {\n configured: 'keychain' | 'file'\n active: 'keychain' | 'file'\n reason?: string\n}): string {\n if (input.active === 'keychain') return 'system keychain'\n return input.configured === 'keychain'\n ? 'private file fallback'\n : 'private file'\n}\n\nfunction oauthClientLabel(source: 'shared' | 'byo'): string {\n return source === 'shared' ? 'SEO Skill app' : 'Local OAuth config'\n}\n\nfunction oauthIdentityRows(input: {\n accountEmail: string\n clientSource: 'shared' | 'byo'\n expiresAt: number\n scope: string\n}): Array<[string, string]> {\n const rows: Array<[string, string]> = [['Account', input.accountEmail]]\n const scopes = new Set(input.scope.split(/\\s+/u).filter(Boolean))\n\n if (scopes.has('https://www.googleapis.com/auth/webmasters.readonly')) {\n rows.push(['Search Console', 'Read only'])\n } else {\n rows.push(['Search Console', 'Not granted'])\n }\n if (scopes.has('https://www.googleapis.com/auth/analytics.readonly')) {\n rows.push(['Google Analytics', 'Read only'])\n } else {\n rows.push(['Google Analytics', 'Not granted'])\n }\n rows.push(\n ['OAuth app', oauthClientLabel(input.clientSource)],\n ['Expires', formatRelativeExpiry(input.expiresAt)],\n )\n return rows\n}\n\nexport const authCommand = defineCommand({\n meta: {\n name: 'auth',\n description: 'Authentication commands',\n },\n subCommands: {\n login: defineCommand({\n meta: { name: 'login', description: 'Run Google OAuth flow' },\n run: async () => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n throw new SeoError(\n 'AUTH_CONFIG_REQUIRED',\n 'A service account is active from the environment. Unset its credential variable before running browser OAuth.',\n )\n }\n const tokens = await loginWithLoopback()\n printKeyValue(\n oauthIdentityRows({\n accountEmail: tokens.account_email,\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n scope: tokens.scope,\n }),\n )\n },\n }),\n logout: defineCommand({\n meta: { name: 'logout', description: 'Delete locally stored tokens' },\n run: async () => {\n const status = await authStatus()\n await deleteTokens()\n if (status.activeMode === 'service-account') {\n process.stdout.write(\n 'Deleted local OAuth tokens. Service account credentials remain available through the environment.\\n',\n )\n return\n }\n process.stdout.write(\n 'Deleted local OAuth tokens.\\nRevoke at https://myaccount.google.com/permissions if you also want Google to forget the grant.\\n',\n )\n },\n }),\n whoami: defineCommand({\n meta: {\n name: 'whoami',\n description: 'Show the signed-in Google account',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n const result = {\n mode: 'service-account',\n account: status.identity ?? null,\n source: serviceAccountSource(status.serviceAccount.source),\n }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n ['Account type', 'Service account'],\n ['Account', status.identity ?? 'Invalid configuration'],\n ['Credentials', result.source],\n ['Access', 'Search Console and Google Analytics, read only'],\n ])\n return\n }\n const tokens = status.tokens\n if (!tokens) {\n if (jsonFlag(args)) {\n printJson({ mode: 'oauth', account: null })\n return\n }\n process.stdout.write('Not logged in.\\n')\n return\n }\n if (jsonFlag(args)) {\n printJson({\n mode: 'oauth',\n account: tokens.account_email,\n scopes: tokens.scope.split(/\\s+/u).filter(Boolean),\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n })\n return\n }\n printKeyValue(\n oauthIdentityRows({\n accountEmail: tokens.account_email,\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n scope: tokens.scope,\n }),\n )\n },\n }),\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show local Google auth status',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const status = await authStatus()\n const storage =\n status.activeMode === 'oauth'\n ? await getTokenStorageStatus()\n : undefined\n if (jsonFlag(args)) {\n printJson({\n authenticated:\n status.activeMode === 'oauth'\n ? Boolean(status.tokens)\n : status.serviceAccount.configured,\n mode: status.activeMode,\n identity: status.identity,\n account:\n status.activeMode === 'oauth'\n ? status.tokens?.account_email\n : undefined,\n scopes:\n status.activeMode === 'oauth' ? status.tokens?.scope : undefined,\n clientSource:\n status.activeMode === 'oauth'\n ? status.tokens?.client_source\n : undefined,\n expiresAt:\n status.activeMode === 'oauth'\n ? status.tokens?.expires_at\n : undefined,\n sharedConfigured: status.sharedConfigured,\n byoConfigured: status.byoConfigured,\n serviceAccount: {\n configured: status.serviceAccount.configured,\n identity: status.serviceAccount.identity,\n source: status.serviceAccount.source,\n error: status.serviceAccount.error,\n },\n ...(storage ? { tokenStorage: storage } : {}),\n })\n return\n }\n if (status.activeMode === 'service-account') {\n const rows: Array<[string, string]> = [\n ['Mode', 'service account'],\n ['Identity', status.identity ?? 'unavailable'],\n ['Source', serviceAccountSource(status.serviceAccount.source)],\n ['Scopes', 'Search Console readonly, Google Analytics readonly'],\n ['Storage', 'credentials stay in the environment'],\n ]\n if (status.serviceAccount.error) {\n rows.push(['Status', status.serviceAccount.error])\n }\n printKeyValue(rows)\n return\n }\n if (!status.tokens) {\n const authMode = status.serviceAccount.error\n ? status.serviceAccount.error\n : status.sharedConfigured\n ? 'Shared seo app available'\n : status.byoConfigured\n ? 'Local OAuth config available'\n : 'No OAuth client configured'\n process.stdout.write(\n `Not logged in. ${authMode}. Run \\`seo auth login\\` to connect Google.\\n`,\n )\n return\n }\n const tokenStorage = storage ?? (await getTokenStorageStatus())\n printKeyValue([\n ['Account', status.tokens.account_email],\n ['Scopes', status.tokens.scope],\n ['Client', oauthClientLabel(status.tokens.client_source)],\n ['Expires', formatRelativeExpiry(status.tokens.expires_at)],\n ['Tokens file', getSeoCliPaths().tokensFile],\n ['Token storage', tokenStorageLabel(tokenStorage)],\n ...(tokenStorage.reason\n ? [['Storage note', tokenStorage.reason] as [string, string]]\n : []),\n [\n 'OAuth mode',\n status.sharedConfigured\n ? 'SEO Skill app available'\n : status.byoConfigured\n ? 'Local OAuth config available'\n : 'missing',\n ],\n ['Revoke at', 'https://myaccount.google.com/permissions'],\n ])\n },\n }),\n storage: defineCommand({\n meta: {\n name: 'storage',\n description: 'Show or change local OAuth token storage',\n },\n args: {\n keychain: {\n type: 'boolean',\n default: false,\n description:\n 'Store OAuth tokens in the system keychain when available.',\n },\n file: {\n type: 'boolean',\n default: false,\n description: 'Store OAuth tokens in the private local file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n if (args.keychain && args.file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Choose either --keychain or --file, not both.',\n )\n }\n const storage =\n args.keychain || args.file\n ? await setTokenStorageMode(args.keychain ? 'keychain' : 'file')\n : await getTokenStorageStatus()\n\n if (jsonFlag(args)) {\n printJson(storage)\n return\n }\n\n printKeyValue([\n ['Configured storage', storage.configured],\n ['Active storage', tokenStorageLabel(storage)],\n ...(storage.reason\n ? [['Note', storage.reason] as [string, string]]\n : []),\n ])\n },\n }),\n refresh: defineCommand({\n meta: {\n name: 'refresh',\n description: 'Refresh the Google OAuth token',\n },\n run: async () => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n process.stdout.write(\n 'Service accounts request short-lived Google tokens automatically. No local refresh token is stored.\\n',\n )\n return\n }\n const tokens = await refreshAuthToken()\n process.stdout.write(\n `Refreshed. New expiry ${new Date(tokens.expires_at).toISOString()}.\\n`,\n )\n },\n }),\n 'setup-client': defineCommand({\n meta: {\n name: 'setup-client',\n description: 'Save your own Google Desktop OAuth client',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Return a structured error instead of prompting.',\n },\n },\n run: async ({ args }) => {\n if (!canPrompt({ json: jsonFlag(args) })) {\n throw new SeoError(\n 'INVALID_INPUT',\n '`seo auth setup-client` needs an interactive terminal. Run it without --json, or set SEO_GOOGLE_CLIENT_ID and SEO_GOOGLE_CLIENT_SECRET.',\n )\n }\n intro('Local Google OAuth client')\n note(\n [\n 'This is the advanced path.',\n 'Most users should use the shared seo Google app.',\n 'Your actual sensitive data is the local refresh token, not the desktop app client secret.',\n ].join('\\n'),\n 'Advanced',\n )\n const clientId = maybeExitCancelled(\n await text({\n message: 'Google Desktop OAuth client ID',\n validate: (value) => (value ? undefined : 'Client ID is required'),\n }),\n )\n const clientSecret = maybeExitCancelled(\n await password({\n message: 'Google Desktop OAuth client secret',\n validate: (value) =>\n value ? undefined : 'Client secret is required',\n }),\n )\n writeOauthClient({ clientId, clientSecret })\n outro(`Saved local OAuth config to ${getSeoCliPaths().oauthClientFile}`)\n },\n }),\n },\n})\n","import { clearCache, getCacheStats, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { formatBytes, printKeyValue } from '../utils.js'\n\nconst CACHE_PROVIDERS = [\n 'gsc',\n 'google-analytics',\n 'semrush',\n 'dataforseo',\n 'http',\n] as const\n\nfunction cacheProvider(\n value: unknown,\n): (typeof CACHE_PROVIDERS)[number] | undefined {\n if (value === undefined) return undefined\n if (\n typeof value === 'string' &&\n CACHE_PROVIDERS.includes(value as (typeof CACHE_PROVIDERS)[number])\n ) {\n return value as (typeof CACHE_PROVIDERS)[number]\n }\n throw new SeoError(\n 'INVALID_INPUT',\n `--provider must be one of: ${CACHE_PROVIDERS.join(', ')}.`,\n )\n}\n\nexport const cacheCommand = defineCommand({\n meta: { name: 'cache', description: 'Cache helpers' },\n subCommands: {\n stats: defineCommand({\n meta: {\n name: 'stats',\n description: 'Show local cache size and row counts',\n },\n run: async () => {\n const stats = getCacheStats()\n printKeyValue([\n ['DB', stats.dbPath],\n ['Size', formatBytes(stats.sizeBytes)],\n [\n 'Cached data',\n `${formatBytes(stats.logicalSizeBytes)} of ${formatBytes(stats.maxSizeBytes)} automatic limit`,\n ],\n ['Sites', String(stats.counts.sites ?? 0)],\n ['Search Console', String(stats.counts.gsc_cache ?? 0)],\n [\n 'Google Analytics',\n String(stats.counts.google_analytics_cache ?? 0),\n ],\n ['Semrush', String(stats.counts.semrush_cache ?? 0)],\n ['DataForSEO', String(stats.counts.provider_cache ?? 0)],\n ['HTTP', String(stats.counts.http_cache ?? 0)],\n ])\n },\n }),\n clear: defineCommand({\n meta: {\n name: 'clear',\n description: 'Clear cached API and HTTP data',\n },\n args: {\n provider: {\n type: 'string',\n description:\n 'Optional cache provider: gsc, google-analytics, semrush, dataforseo, or http',\n },\n },\n run: async ({ args }) => {\n const removed = clearCache(cacheProvider(args.provider))\n process.stdout.write(`Removed ${removed} cached rows.\\n`)\n },\n }),\n },\n})\n","import type {\n PageFetchDiagnostics,\n QueryContentClassification,\n} from '@seo/core'\nimport { resolveClientSelection } from '../selection.js'\n\nexport async function selectedSiteOrThrow(\n input: {\n client?: string\n project?: string\n site?: string\n },\n options: { json?: boolean; refresh?: boolean } = {},\n): Promise<string> {\n return (\n await resolveClientSelection({\n client: input.client,\n project: input.project,\n site: input.site,\n options,\n })\n ).site\n}\n\nexport function startUrlForSite(site: string): string | undefined {\n if (site.startsWith('http://') || site.startsWith('https://')) return site\n if (site.startsWith('sc-domain:')) return `https://${site.slice(10)}/`\n return undefined\n}\n\nexport function suggestedClientName(site: string): string {\n return site.replace(/^sc-domain:/, '').replace(/^https?:\\/\\//, '')\n}\n\nexport function slugId(value: string): string {\n return value\n .toLowerCase()\n .replace(/^https?:\\/\\//, '')\n .replace(/^sc-domain:/, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n}\n\nexport function formatFetchDiagnostics(\n diagnostics?: PageFetchDiagnostics,\n): string {\n if (!diagnostics) return '-'\n if (diagnostics.backpressure?.status === 'stopped') {\n return `stopped: ${diagnostics.backpressure.reason ?? 'origin cooldown'}`\n }\n if (diagnostics.backpressure?.status === 'slowed') {\n return `slowed ${diagnostics.backpressure.delayMs}ms`\n }\n if (diagnostics.rendering?.status === 'unavailable') {\n return 'raw HTML; rendering unavailable'\n }\n if (diagnostics.rendering?.status === 'failed') {\n return 'raw HTML; rendering failed'\n }\n if (diagnostics.blocked) return 'blocked'\n if (diagnostics.rendered) return 'rendered'\n if (diagnostics.cache === 'hit') return 'cached'\n if (diagnostics.fetched) return 'fetched'\n return diagnostics.source\n}\n\nexport function formatContentCheck(\n classification?: QueryContentClassification,\n): string {\n if (!classification) return '-'\n if (classification === 'serp-framing') return 'wording gap'\n if (classification === 'content-gap') return 'content gap'\n if (classification === 'technical-check') return 'technical check'\n return 'covered'\n}\n","import { existsSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, posix, win32 } from 'node:path'\n\nexport type SupportedClient =\n | 'claude-desktop'\n | 'claude-code'\n | 'codex'\n | 'cursor'\n\ninterface BaseClientTarget {\n client: SupportedClient\n label: string\n path: string\n commandNames: string[]\n detectionPaths: string[]\n}\n\nexport interface JsonClientConfigTarget extends BaseClientTarget {\n kind: 'json'\n includeType?: boolean\n}\n\nexport interface NativeClientConfigTarget extends BaseClientTarget {\n kind: 'native'\n executable: 'codex'\n}\n\nexport type ClientConfigTarget =\n | JsonClientConfigTarget\n | NativeClientConfigTarget\n\nfunction platformConfigRoot(input: {\n home: string\n platform: NodeJS.Platform\n env: NodeJS.ProcessEnv\n}): string {\n const path = input.platform === 'win32' ? win32 : posix\n if (input.platform === 'win32') {\n return input.env.APPDATA ?? path.resolve(input.home, 'AppData/Roaming')\n }\n if (input.platform === 'darwin') {\n return path.resolve(input.home, 'Library/Application Support')\n }\n return input.env.XDG_CONFIG_HOME ?? path.resolve(input.home, '.config')\n}\n\nexport function mcpClientTargets(\n input: {\n home?: string\n platform?: NodeJS.Platform\n env?: NodeJS.ProcessEnv\n } = {},\n): ClientConfigTarget[] {\n const home = input.home ?? homedir()\n const platform = input.platform ?? process.platform\n const env = input.env ?? process.env\n const configRoot = platformConfigRoot({ home, platform, env })\n const path = platform === 'win32' ? win32 : posix\n const targets: ClientConfigTarget[] = []\n\n if (platform === 'darwin' || platform === 'win32') {\n const claudeRoot = path.resolve(configRoot, 'Claude')\n targets.push({\n kind: 'json',\n client: 'claude-desktop',\n label: 'Claude Desktop',\n path: path.resolve(claudeRoot, 'claude_desktop_config.json'),\n commandNames: [],\n detectionPaths:\n platform === 'darwin'\n ? [claudeRoot, '/Applications/Claude.app']\n : [claudeRoot],\n })\n }\n\n targets.push(\n {\n kind: 'json',\n client: 'claude-code',\n label: 'Claude Code',\n path: path.resolve(home, '.claude.json'),\n includeType: true,\n commandNames: ['claude'],\n detectionPaths: [path.resolve(home, '.claude')],\n },\n {\n kind: 'native',\n client: 'codex',\n label: 'Codex',\n path: path.resolve(home, '.codex/config.toml'),\n executable: 'codex',\n commandNames: ['codex'],\n detectionPaths: [path.resolve(home, '.codex')],\n },\n {\n kind: 'json',\n client: 'cursor',\n label: 'Cursor',\n path: path.resolve(home, '.cursor/mcp.json'),\n commandNames: ['cursor', 'cursor-agent'],\n detectionPaths: [\n path.resolve(home, '.cursor'),\n ...(platform === 'darwin' ? ['/Applications/Cursor.app'] : []),\n ],\n },\n )\n\n return targets\n}\n\nexport function resolveMcpClientExecutable(\n command: string,\n input: {\n exists?: (path: string) => boolean\n nodePath?: string\n path?: string\n platform?: NodeJS.Platform\n } = {},\n): string {\n const platform = input.platform ?? process.platform\n const exists = input.exists ?? existsSync\n const nodePath = input.nodePath ?? process.execPath\n const names =\n platform === 'win32'\n ? [`${command}.cmd`, `${command}.exe`, command]\n : [command]\n\n const pathEntries = (input.path ?? process.env.PATH ?? '')\n .split(platform === 'win32' ? ';' : ':')\n .filter(Boolean)\n for (const directory of pathEntries) {\n for (const name of names) {\n const candidate = join(directory, name)\n if (exists(candidate)) return candidate\n }\n }\n\n for (const name of names) {\n const candidate = join(dirname(nodePath), name)\n if (exists(candidate)) return candidate\n }\n return command\n}\n\nfunction commandExists(command: string): boolean {\n return resolveMcpClientExecutable(command) !== command\n}\n\nexport function detectMcpClients(\n input: {\n targets?: ClientConfigTarget[]\n hasCommand?: (command: string) => boolean\n hasPath?: (path: string) => boolean\n } = {},\n): ClientConfigTarget[] {\n const targets = input.targets ?? mcpClientTargets()\n const hasCommand = input.hasCommand ?? commandExists\n const hasPath = input.hasPath ?? existsSync\n return targets.filter((target) => {\n if (target.kind === 'native') {\n return target.commandNames.some(hasCommand)\n }\n return (\n hasPath(target.path) ||\n target.detectionPaths.some(hasPath) ||\n target.commandNames.some(hasCommand)\n )\n })\n}\n","import { spawnSync } from 'node:child_process'\nimport {\n constants,\n copyFileSync,\n existsSync,\n mkdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { dirname } from 'node:path'\nimport { isDeepStrictEqual } from 'node:util'\nimport { getSeoCliPaths, SEO_VERSION } from '@seo/core'\nimport {\n applyEdits,\n modify,\n type ParseError,\n parse,\n printParseErrorCode,\n} from 'jsonc-parser'\nimport type {\n ClientConfigTarget,\n JsonClientConfigTarget,\n NativeClientConfigTarget,\n SupportedClient,\n} from './mcp-clients.js'\nimport { resolveMcpClientExecutable } from './mcp-clients.js'\n\ninterface CommandResult {\n status: number | null\n stdout: string\n stderr: string\n error?: Error\n}\n\ntype CommandRunner = (command: string, args: string[]) => CommandResult\n\nexport interface McpServerCommand {\n command: string\n args: string[]\n}\n\nexport interface McpConfigOptions {\n runCommand?: CommandRunner\n reinstall?: boolean\n serverCommand?: McpServerCommand\n}\n\nconst formattingOptions = {\n insertSpaces: true,\n tabSize: 2,\n eol: '\\n',\n}\n\nfunction timestamp(): string {\n return new Date().toISOString().replace(/[:.]/g, '-')\n}\n\nfunction writeAtomic(path: string, value: string): void {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 })\n const tmp = `${path}.${process.pid}.${Date.now()}.tmp`\n const mode = existsSync(path) ? statSync(path).mode & 0o777 : 0o600\n writeFileSync(tmp, value, { encoding: 'utf8', mode })\n renameSync(tmp, path)\n}\n\nfunction backup(path: string): void {\n const base = `${path}.bak-${timestamp()}`\n let candidate = base\n let suffix = 2\n while (existsSync(candidate)) {\n candidate = `${base}-${suffix}`\n suffix += 1\n }\n copyFileSync(path, candidate, constants.COPYFILE_EXCL)\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction readConfig(target: JsonClientConfigTarget): {\n source: string\n config: Record<string, unknown>\n} {\n if (!existsSync(target.path)) return { source: '{}\\n', config: {} }\n\n const source = readFileSync(target.path, 'utf8')\n const errors: ParseError[] = []\n const config = parse(source, errors, { allowTrailingComma: true })\n if (errors.length > 0) {\n const first = errors[0]\n const detail = first\n ? `${printParseErrorCode(first.error)} at offset ${first.offset}`\n : 'unknown parse error'\n throw new Error(`Cannot update ${target.path}: invalid JSONC (${detail}).`)\n }\n if (!isRecord(config)) {\n throw new Error(\n `Cannot update ${target.path}: config root must be an object.`,\n )\n }\n if (config.mcpServers !== undefined && !isRecord(config.mcpServers)) {\n throw new Error(\n `Cannot update ${target.path}: mcpServers must be an object.`,\n )\n }\n return { source, config }\n}\n\nfunction isSeoPackageCommand(args: string[]): boolean {\n return (\n args.includes('mcp') &&\n args.includes('serve') &&\n args.some(\n (item) =>\n item === 'seo' || item.startsWith('seo@') || item === '@seo/cli',\n )\n )\n}\n\nfunction isManagedNodeCommand(\n value: Record<string, unknown>,\n args: string[],\n): boolean {\n if (\n typeof value.command !== 'string' ||\n args.length !== 3 ||\n args[1] !== 'mcp' ||\n args[2] !== 'serve' ||\n !isRecord(value.env)\n ) {\n return false\n }\n return value.env.SEO_MCP_CONFIGURED_BY === 'seo'\n}\n\nfunction managedServer(value: unknown): boolean {\n if (!isRecord(value) || !Array.isArray(value.args)) return false\n const args = value.args.filter(\n (item): item is string => typeof item === 'string',\n )\n return isSeoPackageCommand(args) || isManagedNodeCommand(value, args)\n}\n\nfunction writeConfigEdit(input: {\n target: JsonClientConfigTarget\n source: string\n value: unknown\n}): void {\n const next = applyEdits(\n input.source,\n modify(input.source, ['mcpServers', 'seo'], input.value, {\n formattingOptions,\n }),\n )\n if (existsSync(input.target.path)) backup(input.target.path)\n writeAtomic(input.target.path, next)\n}\n\nfunction defaultCommandRunner(command: string, args: string[]): CommandResult {\n const result = spawnSync(command, args, { encoding: 'utf8' })\n return {\n status: result.status,\n stdout: result.stdout ?? '',\n stderr: result.stderr ?? '',\n error: result.error,\n }\n}\n\nfunction isTemporaryNpxPath(path: string): boolean {\n const normalized = path.replaceAll('\\\\', '/').toLowerCase()\n return (\n normalized.includes('/_npx/') ||\n normalized.includes('/.npm/_npx/') ||\n normalized.includes('/.cache/pnpm/dlx/')\n )\n}\n\nfunction installedCliPath(cliPath: string | undefined): string | undefined {\n if (!cliPath || !existsSync(cliPath)) return undefined\n const resolved = realpathSync(cliPath)\n return isTemporaryNpxPath(resolved) ? undefined : resolved\n}\n\nexport function resolveMcpServerCommand(\n input: {\n cliPath?: string\n nodePath?: string\n platform?: NodeJS.Platform\n version?: string\n } = {},\n): McpServerCommand {\n const cliPath = installedCliPath(input.cliPath ?? process.argv[1])\n if (cliPath) {\n return {\n command: input.nodePath ?? process.execPath,\n args: [cliPath, 'mcp', 'serve'],\n }\n }\n\n const packageName = `seo@${input.version ?? SEO_VERSION}`\n if ((input.platform ?? process.platform) === 'win32') {\n return {\n command: 'cmd',\n args: ['/c', 'npx', '-y', packageName, 'mcp', 'serve'],\n }\n }\n return { command: 'npx', args: ['-y', packageName, 'mcp', 'serve'] }\n}\n\nfunction serverConfig(\n includeType = false,\n command = resolveMcpServerCommand(),\n): Record<string, unknown> {\n const paths = getSeoCliPaths()\n const config: Record<string, unknown> = {\n command: command.command,\n args: command.args,\n env: {\n SEO_CONFIG_DIR: paths.configDir,\n SEO_MCP_CONFIGURED_BY: 'seo',\n },\n }\n if (includeType) config.type = 'stdio'\n return config\n}\n\nfunction codexManaged(output: string): boolean {\n return (\n output.includes('SEO_MCP_CONFIGURED_BY') ||\n /args:\\s+-y\\s+(?:seo(?:@\\S+)?|@seo\\/cli)\\s+mcp\\s+serve\\b/.test(output)\n )\n}\n\nfunction codexCommand(\n target: NativeClientConfigTarget,\n operation: 'install' | 'uninstall',\n options: Required<\n Pick<McpConfigOptions, 'runCommand' | 'reinstall' | 'serverCommand'>\n >,\n): { client: SupportedClient; path: string; changed: boolean } {\n const executable = resolveMcpClientExecutable(target.executable)\n const current = options.runCommand(executable, ['mcp', 'get', 'seo'])\n if ((current.error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT') {\n throw new Error(\n 'Cannot install SEO MCP for Codex: the `codex` command is not available on PATH. Install Codex CLI or choose another MCP client.',\n )\n }\n const exists = current.status === 0\n if (exists && !codexManaged(current.stdout)) {\n throw new Error(\n `Cannot ${operation} SEO MCP: ${target.path} already has an unmanaged mcp_servers.seo entry.`,\n )\n }\n if (operation === 'install' && exists && !options.reinstall) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (operation === 'uninstall' && !exists) {\n return { client: target.client, path: target.path, changed: false }\n }\n\n if (operation === 'install' && exists) {\n const removed = options.runCommand(executable, ['mcp', 'remove', 'seo'])\n if (removed.error || removed.status !== 0) {\n const detail =\n removed.error?.message ?? removed.stderr.trim() ?? 'unknown error'\n throw new Error(`Cannot reinstall SEO MCP for Codex: ${detail}`)\n }\n }\n\n const paths = getSeoCliPaths()\n const args =\n operation === 'install'\n ? [\n 'mcp',\n 'add',\n 'seo',\n '--env',\n `SEO_CONFIG_DIR=${paths.configDir}`,\n '--env',\n 'SEO_MCP_CONFIGURED_BY=seo',\n '--',\n options.serverCommand.command,\n ...options.serverCommand.args,\n ]\n : ['mcp', 'remove', 'seo']\n const result = options.runCommand(executable, args)\n if (result.error || result.status !== 0) {\n const detail =\n result.error?.message ?? result.stderr.trim() ?? 'unknown error'\n throw new Error(`Cannot ${operation} SEO MCP for Codex: ${detail}`)\n }\n return { client: target.client, path: target.path, changed: true }\n}\n\nexport function installMcpConfig(\n target: ClientConfigTarget,\n options: McpConfigOptions = {},\n): { client: SupportedClient; path: string; changed: boolean } {\n const resolved = {\n runCommand: options.runCommand ?? defaultCommandRunner,\n reinstall: options.reinstall ?? false,\n serverCommand: options.serverCommand ?? resolveMcpServerCommand(),\n }\n if (target.kind === 'native') {\n return codexCommand(target, 'install', resolved)\n }\n\n const { source, config } = readConfig(target)\n const servers = config.mcpServers as Record<string, unknown> | undefined\n const current = servers?.seo\n const desired = serverConfig(target.includeType, resolved.serverCommand)\n if (isDeepStrictEqual(current, desired) && !resolved.reinstall) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (current !== undefined && !managedServer(current)) {\n throw new Error(\n `Cannot install SEO MCP: ${target.path} already has an unmanaged mcpServers.seo entry.`,\n )\n }\n\n writeConfigEdit({ target, source, value: desired })\n return { client: target.client, path: target.path, changed: true }\n}\n\nexport function uninstallMcpConfig(\n target: ClientConfigTarget,\n options: Pick<McpConfigOptions, 'runCommand'> = {},\n): { client: SupportedClient; path: string; changed: boolean } {\n if (target.kind === 'native') {\n return codexCommand(target, 'uninstall', {\n runCommand: options.runCommand ?? defaultCommandRunner,\n reinstall: false,\n serverCommand: resolveMcpServerCommand(),\n })\n }\n if (!existsSync(target.path)) {\n return { client: target.client, path: target.path, changed: false }\n }\n\n const { source, config } = readConfig(target)\n const servers = config.mcpServers as Record<string, unknown> | undefined\n if (servers?.seo === undefined) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (!managedServer(servers.seo)) {\n throw new Error(\n `Cannot uninstall SEO MCP: ${target.path} has an unmanaged mcpServers.seo entry.`,\n )\n }\n\n writeConfigEdit({ target, source, value: undefined })\n return { client: target.client, path: target.path, changed: true }\n}\n","import { spawnSync } from 'node:child_process'\n\nexport type SkillInstallOutcome =\n | { status: 'installed' }\n | { status: 'failed'; error: string }\n\n/**\n * Install the packaged router skill for coding agents through the skills\n * ecosystem. Used by guided setup and by `seo skill install`.\n */\nexport function installSeoSkill(\n options: { quiet?: boolean } = {},\n): SkillInstallOutcome {\n const result = spawnSync('npx', ['-y', 'skills', 'add', 'iannuttall/seo'], {\n stdio: options.quiet ? 'ignore' : 'inherit',\n })\n if (result.error) {\n return { status: 'failed', error: result.error.message }\n }\n if (result.status !== 0) {\n return {\n status: 'failed',\n error: `npx skills add exited with status ${result.status ?? 'unknown'}.`,\n }\n }\n return { status: 'installed' }\n}\n","import {\n confirm,\n multiselect,\n note,\n password,\n select,\n text,\n} from '@clack/prompts'\nimport {\n authStatus,\n type Ga4WebStreamCandidate,\n type Ga4WebStreamMatch,\n ga4MatchReason,\n ga4PropertyIdFromName,\n listGa4AccountSummaries,\n listGa4DataStreams,\n loginWithLoopback,\n matchGa4WebStreams,\n SeoError,\n writeOauthClient,\n} from '@seo/core'\nimport { canPrompt, maybeExitCancelled } from '../../utils.js'\nimport { detectMcpClients } from '../mcp-clients.js'\nimport { installMcpConfig } from '../mcp-config.js'\nimport { installSeoSkill } from '../skill-install.js'\n\nexport type SetupAuthStatus =\n | 'connected'\n | 'already-connected'\n | 'service-account'\n | 'skipped'\nexport type SetupMcpInstall = {\n client: string\n path: string\n changed: boolean\n error?: string\n}\nexport type SetupGoogleAnalyticsSelection = {\n propertyId: string\n selection: 'explicit' | 'matched' | 'manual'\n reason: string\n}\nexport type SetupSkillInstall = {\n status: 'installed' | 'declined' | 'skipped' | 'failed'\n error?: string\n}\n\ntype GoogleAnalyticsPropertyChoice = {\n property: string\n label: string\n account: string\n}\n\ntype GoogleAnalyticsSetupChoice = GoogleAnalyticsPropertyChoice & {\n match?: Ga4WebStreamMatch\n}\n\ntype AuthSetupChoice = 'login' | 'setup' | 'skip'\n\nexport function authSetupOptions(input: {\n sharedConfigured: boolean\n byoConfigured: boolean\n canSkip: boolean\n}): Array<{\n value: AuthSetupChoice\n label: string\n hint?: string\n}> {\n const skipOption = input.canSkip\n ? [{ value: 'skip' as const, label: 'Skip for now' }]\n : []\n const hasOauthClient = input.sharedConfigured || input.byoConfigured\n\n return hasOauthClient\n ? [\n {\n value: 'login',\n label: 'Connect Google',\n hint: 'Opens your browser for read-only Search Console and Google Analytics access',\n },\n ...skipOption,\n ]\n : [\n {\n value: 'setup',\n label: 'Set up Google login for local development',\n hint: 'This source checkout does not include the public app credentials',\n },\n ...skipOption,\n ]\n}\n\nasync function findGoogleAnalyticsWebStreamCandidates(\n properties: GoogleAnalyticsPropertyChoice[],\n): Promise<{ candidates: Ga4WebStreamCandidate[]; complete: boolean }> {\n const candidates: Ga4WebStreamCandidate[] = []\n let complete = true\n let nextIndex = 0\n\n async function worker(): Promise<void> {\n while (nextIndex < properties.length) {\n const property = properties[nextIndex]\n nextIndex += 1\n if (!property) continue\n\n try {\n const streams = await listGa4DataStreams(property.property)\n candidates.push(\n ...streams\n .filter((stream) => stream.webStreamData)\n .map((stream) => ({\n account: property.account,\n property: property.property,\n propertyName: property.label,\n stream,\n })),\n )\n } catch {\n complete = false\n }\n }\n }\n\n await Promise.all(\n Array.from({ length: Math.min(properties.length, 4) }, () => worker()),\n )\n return { candidates, complete }\n}\n\nexport async function maybeConnectAuth(\n args: Record<string, unknown>,\n): Promise<SetupAuthStatus> {\n const status = await authStatus()\n if (status.activeMode === 'service-account') return 'service-account'\n if (status.tokens) return 'already-connected'\n if (args['skip-auth']) return 'skipped'\n if (!canPrompt({ json: args.json === true })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n 'Not logged in. Run `seo auth login`, or pass --skip-auth to save a project profile without connecting Google.',\n )\n }\n\n const choice = maybeExitCancelled(\n await select<AuthSetupChoice>({\n message: 'Connect Google now?',\n options: authSetupOptions({\n sharedConfigured: status.sharedConfigured,\n byoConfigured: status.byoConfigured,\n canSkip: typeof args.site === 'string' && args.site.length > 0,\n }),\n }),\n )\n\n if (choice === 'skip') return 'skipped'\n if (choice === 'setup') {\n const clientId = maybeExitCancelled(\n await text({\n message: 'Google Desktop OAuth client ID',\n validate: (value) => (value ? undefined : 'Client ID is required'),\n }),\n )\n const clientSecret = maybeExitCancelled(\n await password({\n message: 'Google Desktop OAuth client secret',\n validate: (value) => (value ? undefined : 'Client secret is required'),\n }),\n )\n writeOauthClient({ clientId, clientSecret })\n }\n\n const tokens = await loginWithLoopback()\n note(\n `Connected as ${tokens.account_email}. seo has read-only access and cannot change your site.`,\n 'Google connected',\n )\n return 'connected'\n}\n\nexport async function chooseGoogleAnalyticsProperty(input: {\n property?: string\n site: string\n interactive?: boolean\n}): Promise<SetupGoogleAnalyticsSelection | undefined> {\n if (input.property) {\n return {\n propertyId: input.property,\n selection: 'explicit',\n reason: 'Set with --google-analytics-property.',\n }\n }\n const interactive = input.interactive ?? canPrompt()\n if (!interactive) return undefined\n\n const summaries = await listGa4AccountSummaries().catch(() => [])\n const properties: GoogleAnalyticsPropertyChoice[] = summaries.flatMap(\n (account) =>\n account.propertySummaries.map((property) => ({\n property: ga4PropertyIdFromName(property.property),\n label: property.displayName ?? property.property,\n account: account.displayName ?? account.account,\n })),\n )\n if (!properties.length) return undefined\n\n const { candidates, complete: streamsComplete } =\n await findGoogleAnalyticsWebStreamCandidates(properties)\n const matches = streamsComplete\n ? matchGa4WebStreams(input.site, candidates)\n : []\n const matchesByProperty = new Map<string, Ga4WebStreamMatch>()\n for (const match of matches) {\n matchesByProperty.set(match.property, match)\n }\n const matchedProperties = [...matchesByProperty.values()]\n\n if (matchedProperties.length === 1) {\n const match = matchedProperties[0]\n if (!match) return undefined\n return {\n propertyId: match.property,\n selection: 'matched',\n reason: ga4MatchReason(match, input.site),\n }\n }\n\n const choices: GoogleAnalyticsSetupChoice[] = matchedProperties.length\n ? matchedProperties.map((match) => ({\n property: match.property,\n label: match.propertyName,\n account: match.account,\n match,\n }))\n : properties\n\n const choice = maybeExitCancelled(\n await select<GoogleAnalyticsSetupChoice | ''>({\n message: matchedProperties.length\n ? 'Several Google Analytics properties match this site. Which property should seo use?'\n : streamsComplete\n ? 'No Google Analytics web stream clearly matches this site. Attach a property?'\n : 'Some Google Analytics web streams could not be read. Attach a property?',\n options: [\n { value: '', label: 'Skip Google Analytics for now' },\n ...choices.map((property) => ({\n value: property,\n label: `${property.label} (${property.property})`,\n hint: property.match\n ? ga4MatchReason(property.match, input.site)\n : property.account,\n })),\n ],\n }),\n )\n if (!choice) return undefined\n\n return {\n propertyId: choice.property,\n selection: 'manual',\n reason: choice.match\n ? ga4MatchReason(choice.match, input.site)\n : streamsComplete\n ? `Selected ${choice.label} during setup. Its web stream did not clearly match ${input.site}.`\n : `Selected ${choice.label} during setup. seo could not read every Google Analytics web stream, so it did not guess a match.`,\n }\n}\n\nexport async function maybeInstallSkill(\n args: Record<string, unknown>,\n): Promise<SetupSkillInstall> {\n if (args['skip-skill'] || !canPrompt({ json: args.json === true })) {\n return { status: 'skipped' }\n }\n const shouldInstall = maybeExitCancelled(\n await confirm({\n message:\n 'Install the SEO skill so coding agents know how to run reports?',\n initialValue: true,\n }),\n )\n if (!shouldInstall) return { status: 'declined' }\n\n return installSeoSkill()\n}\n\nexport async function maybeInstallMcp(\n args: Record<string, unknown>,\n): Promise<SetupMcpInstall[]> {\n if (args['skip-mcp'] || !canPrompt({ json: args.json === true })) return []\n const detected = detectMcpClients()\n if (detected.length === 0) return []\n const shouldInstall = maybeExitCancelled(\n await confirm({\n message: 'Install seo as an MCP server too?',\n initialValue: true,\n }),\n )\n if (!shouldInstall) return []\n\n const selected = maybeExitCancelled(\n await multiselect({\n message: 'Which MCP clients?',\n options: detected.map((target) => ({\n value: target.client,\n label: target.label,\n hint: target.path,\n })),\n initialValues: detected.map((target) => target.client),\n }),\n )\n\n return detected\n .filter((target) => selected.includes(target.client))\n .map((target) => {\n try {\n return installMcpConfig(target)\n } catch (error) {\n return {\n client: target.client,\n path: target.path,\n changed: false,\n error: error instanceof Error ? error.message : String(error),\n }\n }\n })\n}\n","import { confirm, intro, note, outro, text } from '@clack/prompts'\nimport {\n type ClientProfile,\n deriveBrandTerms,\n ensureSeoCliDirs,\n listClients,\n saveClient,\n} from '@seo/core'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printCallout,\n printJson,\n printKeyValue,\n} from '../../utils.js'\nimport { slugId, startUrlForSite, suggestedClientName } from '../shared.js'\nimport {\n chooseGoogleAnalyticsProperty,\n maybeConnectAuth,\n maybeInstallMcp,\n maybeInstallSkill,\n type SetupAuthStatus,\n type SetupGoogleAnalyticsSelection,\n type SetupMcpInstall,\n type SetupSkillInstall,\n} from './prompts.js'\n\ntype SetupResult = {\n client?: ClientProfile\n site: string\n auth: SetupAuthStatus\n googleAnalytics?: SetupGoogleAnalyticsSelection\n mcp: SetupMcpInstall[]\n skill?: SetupSkillInstall\n next: string[]\n}\n\nfunction skillInstallLabel(skill: SetupSkillInstall): string {\n if (skill.status === 'installed') return 'installed'\n if (skill.status === 'failed') return 'install failed'\n return 'not installed'\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_./:@-]+$/.test(value)) {\n return value\n }\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\nfunction printStarAsk(): void {\n process.stdout.write('\\n')\n printCallout({\n title: 'Help other people find SEO Skill',\n body: 'If SEO Skill saved you time, a GitHub star helps other people find it.',\n command: 'https://github.com/iannuttall/seo',\n })\n}\n\nfunction mcpInstallLabel(installs: SetupMcpInstall[]): string {\n const failed = installs.filter((install) => install.error).length\n const installed = installs.length - failed\n if (installs.length === 0) return 'not installed'\n if (failed === 0) return `${installed} installed`\n if (installed === 0) return `${failed} skipped`\n return `${installed} installed, ${failed} skipped`\n}\n\nfunction mcpFailureMessage(installs: SetupMcpInstall[]): string | undefined {\n const failures = installs.filter(\n (install): install is SetupMcpInstall & { error: string } =>\n Boolean(install.error),\n )\n if (failures.length === 0) return undefined\n return failures\n .map((install) => `${install.client}: ${install.error}`)\n .join('\\n')\n}\n\nfunction existingProfileForSetup(\n site: string,\n name: string,\n requestedId: string | undefined,\n): ClientProfile | undefined {\n if (requestedId) return undefined\n const matches = listClients().filter((client) => client.siteUrl === site)\n if (matches.length === 1) return matches[0]\n return (\n matches.find((client) => client.isDefault) ??\n matches.find(\n (client) => client.name.toLocaleLowerCase() === name.toLocaleLowerCase(),\n )\n )\n}\n\nexport async function runGuidedSetup(\n args: Record<string, unknown>,\n): Promise<void> {\n const json = jsonFlag(args)\n if (!json) intro(process.argv[2] === 'start' ? 'seo start' : 'seo setup')\n\n if (args['dry-run']) {\n const next = [\n 'seo auth login',\n 'seo start',\n 'seo report --project acme',\n 'seo refresh-priorities --project acme --verify-content',\n 'seo technical-watch --project acme',\n ]\n if (json) {\n printJson({ dryRun: true, next })\n } else {\n note(next.join('\\n'), 'This setup will guide you through')\n outro('Dry run complete.')\n }\n return\n }\n\n ensureSeoCliDirs()\n const siteInput = {\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n }\n const selectedSite = json ? await resolveSite(siteInput) : undefined\n const auth = await maybeConnectAuth(args)\n const site = selectedSite ?? (await resolveSite(siteInput))\n const defaultName = suggestedClientName(site)\n if (canPrompt({ json })) {\n note(\n 'A project profile remembers the site and report defaults so future commands stay short.',\n 'Project profile',\n )\n }\n const shouldSaveProfile =\n booleanArg(args['skip-profile']) === true\n ? false\n : canPrompt({ json })\n ? maybeExitCancelled(\n await confirm({\n message: 'Save this site as a project profile?',\n initialValue: true,\n }),\n )\n : true\n\n if (!shouldSaveProfile) {\n const mcp = await maybeInstallMcp(args)\n const skill = await maybeInstallSkill(args)\n const siteArg = `--site ${shellArg(site)}`\n const next = [\n `seo report ${siteArg}`,\n `seo refresh-priorities ${siteArg} --verify-content`,\n `seo technical-watch ${siteArg}`,\n ]\n const result: SetupResult = { site, auth, mcp, skill, next }\n\n if (json) {\n printJson(result)\n return\n }\n\n printKeyValue([\n ['Project profile', 'not saved'],\n ['GSC property', site],\n ['Auth', auth],\n ['MCP', mcpInstallLabel(mcp)],\n ['SEO skill', skillInstallLabel(skill)],\n ])\n const mcpFailure = mcpFailureMessage(mcp)\n if (mcpFailure) note(mcpFailure, 'MCP setup skipped')\n if (skill.error) note(skill.error, 'SEO skill install failed')\n note(next.join('\\n'), 'Try next')\n outro('Setup complete.')\n printStarAsk()\n return\n }\n\n const name =\n stringArg(args.name) ??\n (canPrompt({ json })\n ? maybeExitCancelled(\n await text({\n message: 'Project name',\n placeholder: defaultName,\n defaultValue: defaultName,\n }),\n )\n : defaultName)\n const requestedId = stringArg(args.id)\n const id =\n requestedId ??\n existingProfileForSetup(site, name, requestedId)?.id ??\n slugId(name)\n const defaultStartUrl = startUrlForSite(site) ?? ''\n const startUrl =\n stringArg(args.url) ??\n (canPrompt({ json })\n ? maybeExitCancelled(\n await text({\n message: 'Website URL to crawl',\n placeholder: defaultStartUrl || 'https://example.com',\n defaultValue: defaultStartUrl,\n }),\n )\n : defaultStartUrl || undefined)\n const watchUrls = listArg(args.urls).length > 0 ? listArg(args.urls) : []\n const googleAnalytics = await chooseGoogleAnalyticsProperty({\n property: stringArg(args['google-analytics-property']),\n site,\n interactive: canPrompt({ json }),\n })\n const googleAnalyticsPropertyId = googleAnalytics?.propertyId\n const derivedBrandTerms = deriveBrandTerms({ id, name, siteUrl: site })\n const brandTerms =\n listArg(args.brand).length > 0 ? listArg(args.brand) : derivedBrandTerms\n const reportDay = numberArg(args['report-day']) ?? 1\n const technicalWeekday = numberArg(args.weekday) ?? 1\n const isDefault = booleanArg(args.default) ?? true\n\n const client = saveClient({\n id,\n name,\n siteUrl: site,\n startUrl,\n watchUrls,\n brandTerms,\n analytics: googleAnalyticsPropertyId\n ? { google: { propertyId: googleAnalyticsPropertyId } }\n : undefined,\n reportDay,\n technicalWeekday,\n isDefault,\n })\n const mcp = await maybeInstallMcp(args)\n const skill = await maybeInstallSkill(args)\n const next = [\n `seo report --project ${client.id}`,\n `seo refresh-priorities --project ${client.id} --verify-content`,\n `seo technical-watch --project ${client.id}`,\n ]\n const result: SetupResult = {\n client,\n site,\n auth,\n googleAnalytics,\n mcp,\n skill,\n next,\n }\n\n if (json) {\n printJson(result)\n return\n }\n\n printKeyValue([\n ['Project profile', `${client.name} (${client.id})`],\n ['GSC property', client.siteUrl],\n ['Crawl URL', client.startUrl ?? 'not set'],\n ['Watch URLs', String(client.watchUrls.length)],\n ['Brand terms', client.brandTerms.join(', ') || 'not set'],\n [\n 'Google Analytics property',\n client.analytics.google?.propertyId ?? 'not connected (optional)',\n ],\n ...(googleAnalytics\n ? [\n ['Google Analytics selection', googleAnalytics.reason] as [\n string,\n string,\n ],\n ]\n : []),\n ['Auth', auth],\n ['MCP', mcpInstallLabel(mcp)],\n ['SEO skill', skillInstallLabel(skill)],\n ])\n const mcpFailure = mcpFailureMessage(mcp)\n if (mcpFailure) note(mcpFailure, 'MCP setup skipped')\n if (skill.error) note(skill.error, 'SEO skill install failed')\n note(next.join('\\n'), 'Try next')\n outro('Setup complete.')\n printStarAsk()\n}\n","import { defineCommand } from 'citty'\nimport { runGuidedSetup } from './flow.js'\n\nexport const setupCommand = defineCommand({\n meta: {\n name: 'setup',\n description:\n 'Guided setup for auth, one project profile, MCP, and next commands',\n },\n args: {\n id: { type: 'string', description: 'Short stable project id.' },\n name: { type: 'string', description: 'Human project name.' },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n url: { type: 'string', description: 'Default technical crawl start URL.' },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to watch with URL Inspection.',\n },\n 'google-analytics-property': {\n type: 'string',\n description: 'Optional Google Analytics property ID.',\n },\n brand: {\n type: 'string',\n description: 'Comma-separated branded query terms to exclude by default.',\n },\n 'report-day': {\n type: 'string',\n description: 'Preferred monthly report day. Defaults to 1.',\n },\n weekday: {\n type: 'string',\n description: 'Preferred technical-watch weekday. Defaults to Monday.',\n },\n default: {\n type: 'boolean',\n description: 'Make this the default project.',\n },\n 'skip-profile': {\n type: 'boolean',\n default: false,\n description: 'Do not save a project profile during setup.',\n },\n 'skip-auth': {\n type: 'boolean',\n default: false,\n description: 'Skip Google sign-in during setup.',\n },\n 'skip-mcp': {\n type: 'boolean',\n default: false,\n description: 'Skip MCP install prompts.',\n },\n 'skip-skill': {\n type: 'boolean',\n default: false,\n description: 'Skip the SEO skill install prompt.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Refresh GSC property discovery.',\n },\n 'dry-run': {\n type: 'boolean',\n default: false,\n description: 'Show what setup does without changing files.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => runGuidedSetup(args),\n})\n\nexport const startCommand = defineCommand({\n ...setupCommand,\n meta: {\n name: 'start',\n description:\n 'Start here: connect Google, save a profile, and get the first report commands',\n },\n})\n\nexport const clientSetupCommand = defineCommand({\n ...setupCommand,\n meta: {\n name: 'setup',\n description: 'Guided setup for one saved project profile',\n },\n})\n","import { detectBrandTerms, getClient, saveClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\n\nexport const clientBrandCommand = defineCommand({\n meta: {\n name: 'brand',\n description: 'Detect and manage project brand query terms',\n },\n subCommands: {\n detect: defineCommand({\n meta: {\n name: 'detect',\n description:\n 'Suggest branded query terms from GSC navigational queries',\n },\n args: {\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name. Defaults to default.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n days: {\n type: 'string',\n description: 'Detection window length in days. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum candidate terms. Defaults to 10.',\n },\n 'min-impressions': {\n type: 'string',\n description: 'Minimum query impressions. Defaults to 10.',\n },\n save: {\n type: 'boolean',\n default: false,\n description: 'Save suggested terms to the selected project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local GSC cache.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = getClient(projectArg(args))\n const siteUrl = await resolveSite({\n site: stringArg(args.site) ?? client?.siteUrl,\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const detection = await detectBrandTerms({\n site: siteUrl,\n id: client?.id,\n name: client?.name,\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n refresh: booleanArg(args.refresh),\n })\n const saved =\n booleanArg(args.save) && client\n ? saveClient({\n id: client.id,\n name: client.name,\n siteUrl: client.siteUrl,\n startUrl: client.startUrl,\n watchUrls: client.watchUrls,\n analytics: client.analytics,\n brandTerms: detection.suggestedTerms,\n reportDay: client.reportDay,\n technicalWeekday: client.technicalWeekday,\n isDefault: client.isDefault,\n })\n : undefined\n\n if (booleanArg(args.save) && !client) {\n throw new Error('Pass --project to save detected brand terms.')\n }\n if (json) {\n printJson({ ...detection, saved })\n return\n }\n\n printKeyValue([\n ['Property', detection.site],\n ['Derived terms', detection.derivedTerms.join(', ')],\n ['Suggested terms', detection.suggestedTerms.join(', ')],\n ['Saved', saved ? saved.id : 'no'],\n ])\n printTable(\n ['Term', 'Score', 'Evidence'],\n detection.candidates.map((candidate) => [\n candidate.term,\n candidate.score,\n candidate.evidence\n .map(\n (item) => `${item.query} (${Math.round(item.clicks)} clicks)`,\n )\n .join(', '),\n ]),\n )\n },\n }),\n },\n})\n","import { readFile, stat } from 'node:fs/promises'\nimport { type ClientProfile, SeoError } from '@seo/core'\nimport { jsonFlag, projectArg, stringArg } from '../../../args.js'\nimport { resolveClient } from '../../../selection.js'\n\nexport const keywordSetProjectArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n} as const\n\nexport const keywordSetJsonArg = {\n type: 'boolean' as const,\n default: false,\n description: 'Print machine-readable JSON.',\n}\n\nexport async function selectedProject(\n args: Record<string, unknown>,\n): Promise<ClientProfile> {\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n if (!project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Select a saved project with --project or make one the default.',\n )\n }\n return project\n}\n\nconst MAX_KEYWORD_FILE_BYTES = 100_000\n\nexport async function keywordInputs(\n args: Record<string, unknown>,\n): Promise<string[]> {\n const keyword = stringArg(args.keyword)\n const keywords = stringArg(args.keywords)\n ?.split(',')\n .map((value) => value.trim())\n .filter(Boolean)\n const file = stringArg(args.file)\n const values = [...(keyword ? [keyword] : []), ...(keywords ?? [])]\n if (file) {\n const info = await stat(file).catch(() => undefined)\n if (!info?.isFile() || info.size > MAX_KEYWORD_FILE_BYTES) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Keyword files must be regular files no larger than 100 KB.',\n )\n }\n values.push(\n ...(await readFile(file, 'utf8'))\n .split(/\\r?\\n/u)\n .map((value) => value.trim())\n .filter(Boolean),\n )\n }\n if (values.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --keyword, comma-separated --keywords, or a newline-delimited --file.',\n )\n }\n return values\n}\n","import { addKeywordsToSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, listArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordInputs,\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetAddCommand = defineCommand({\n meta: { name: 'add', description: 'Add or update keywords in a saved set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n keyword: { type: 'string', description: 'One keyword.' },\n keywords: { type: 'string', description: 'Comma-separated keywords.' },\n file: { type: 'string', description: 'Newline-delimited keyword file.' },\n tags: {\n type: 'string',\n description: 'Comma-separated tags applied to every keyword.',\n },\n 'target-url': {\n type: 'string',\n description: 'Existing target page for every keyword.',\n },\n 'proposed-url': {\n type: 'string',\n description: 'Proposed page for every keyword.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const targetUrl = stringArg(args['target-url'])\n const proposedUrl = stringArg(args['proposed-url'])\n if (targetUrl && proposedUrl) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --target-url or --proposed-url.',\n )\n }\n const project = await selectedProject(args)\n const result = addKeywordsToSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n items: (await keywordInputs(args)).map((keyword) => ({\n keyword,\n tags: listArg(args.tags),\n ...(targetUrl || proposedUrl\n ? {\n page: {\n kind: targetUrl ? ('target' as const) : ('proposed' as const),\n url: targetUrl ?? proposedUrl ?? '',\n },\n }\n : {}),\n })),\n })\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Set', result.setId],\n ['Added', String(result.added)],\n ['Updated', String(result.updated)],\n ['Keywords', String(result.keywordCount)],\n ])\n },\n})\n","import { createKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetCreateCommand = defineCommand({\n meta: { name: 'create', description: 'Create an empty saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n name: { type: 'string', description: 'Keyword set name.', required: true },\n country: {\n type: 'string',\n description: 'Two-letter country code.',\n required: true,\n },\n language: {\n type: 'string',\n description: 'Search language code.',\n required: true,\n },\n 'search-engine': {\n type: 'string',\n default: 'google',\n description: 'Search engine: google or bing.',\n },\n 'location-code': {\n type: 'string',\n description: 'Optional provider location code.',\n },\n location: {\n type: 'string',\n description: 'Optional canonical location name.',\n },\n device: {\n type: 'string',\n description: 'Optional device: desktop or mobile.',\n },\n provider: { type: 'string', description: 'Optional preferred provider.' },\n 'source-report': {\n type: 'string',\n description: 'Report that produced the initial research.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const locationCode = numberArg(args['location-code'])\n if (locationCode !== undefined && !Number.isSafeInteger(locationCode)) {\n throw new SeoError('INVALID_INPUT', '--location-code must be an integer.')\n }\n const project = await selectedProject(args)\n const set = createKeywordSet({\n projectId: project.id,\n name: stringArg(args.name) ?? '',\n market: {\n searchEngine: stringArg(args['search-engine']),\n countryCode: stringArg(args.country),\n languageCode: stringArg(args.language),\n ...(locationCode !== undefined || stringArg(args.location)\n ? { location: { code: locationCode, name: stringArg(args.location) } }\n : {}),\n device: stringArg(args.device),\n },\n provider: stringArg(args.provider),\n sourceReport: stringArg(args['source-report']),\n })\n if (jsonFlag(args)) printJson(set)\n else\n printKeyValue([\n ['Created', set.name],\n ['Project', project.name],\n ['Keywords', '0'],\n ['Id', set.id],\n ])\n },\n})\n","import { deleteKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetDeleteCommand = defineCommand({\n meta: { name: 'delete', description: 'Delete a saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n yes: {\n type: 'boolean',\n default: false,\n description: 'Confirm permanent deletion.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n if (!booleanArg(args.yes)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --yes to delete the keyword set.',\n )\n }\n const project = await selectedProject(args)\n const idOrName = stringArg(args.set) ?? ''\n const deleted = deleteKeywordSet({ projectId: project.id, idOrName })\n if (!deleted)\n throw new SeoError('INVALID_INPUT', `Keyword set not found: ${idOrName}`)\n const result = { deleted: true, projectId: project.id, set: idOrName }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`Deleted keyword set ${idOrName}.\\n`)\n },\n})\n","import { writeFile } from 'node:fs/promises'\nimport {\n getKeywordSet,\n type ProviderValue,\n renderCsv,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { numberArg, stringArg } from '../../../args.js'\nimport { keywordSetProjectArgs, selectedProject } from './shared.js'\n\nexport const keywordSetExportCommand = defineCommand({\n meta: { name: 'export', description: 'Export a bounded saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n format: {\n type: 'string',\n default: 'csv',\n description: 'Output format: csv or json.',\n },\n output: {\n type: 'string',\n description: 'Output file, or - for stdout.',\n required: true,\n },\n tag: { type: 'string', description: 'Only export keywords with this tag.' },\n limit: {\n type: 'string',\n default: '1000',\n description: 'Rows to export, from 1 to 1000.',\n },\n offset: { type: 'string', default: '0', description: 'Rows to skip.' },\n },\n run: async ({ args }) => {\n const format = stringArg(args.format)\n if (format !== 'csv' && format !== 'json') {\n throw new SeoError('INVALID_INPUT', '--format must be csv or json.')\n }\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit) || !Number.isSafeInteger(offset)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--limit and --offset must be integers.',\n )\n }\n const project = await selectedProject(args)\n const detail = getKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n tag: stringArg(args.tag),\n limit,\n offset,\n })\n const body =\n format === 'json'\n ? `${JSON.stringify(detail, null, 2)}\\n`\n : keywordSetCsv(detail)\n const output = stringArg(args.output) ?? ''\n if (output === '-') process.stdout.write(body)\n else {\n try {\n await writeFile(output, body, {\n encoding: 'utf8',\n flag: 'wx',\n mode: 0o600,\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EEXIST') {\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to overwrite the existing file at ${output}.`,\n )\n }\n throw error\n }\n process.stdout.write(\n `Wrote ${detail.items.length} keywords to ${output}.\\n`,\n )\n }\n },\n})\n\nfunction keywordSetCsv(detail: ReturnType<typeof getKeywordSet>): string {\n return renderCsv(\n detail.items.map((item) => {\n const metric = item.latestMetric?.metric\n return {\n keyword: item.keyword,\n normalized_keyword: item.normalizedKeyword,\n tags: item.tags.join('; '),\n page_kind: item.page?.kind,\n page_url: item.page?.url,\n metric_provider: item.latestMetric?.provider,\n metric_observed_at: item.latestMetric?.observedAt,\n monthly_search_volume: observedMetricValue(metric?.monthlySearchVolume),\n cpc_usd: observedMetricValue(metric?.cpcUsd),\n paid_competition: observedMetricValue(metric?.paidCompetition),\n keyword_difficulty: observedMetricValue(metric?.keywordDifficulty),\n intent:\n metric?.intent.state === 'observed' ? metric.intent.value : null,\n result_count: observedMetricValue(metric?.resultCount),\n }\n }),\n [\n 'keyword',\n 'normalized_keyword',\n 'tags',\n 'page_kind',\n 'page_url',\n 'metric_provider',\n 'metric_observed_at',\n 'monthly_search_volume',\n 'cpc_usd',\n 'paid_competition',\n 'keyword_difficulty',\n 'intent',\n 'result_count',\n ],\n )\n}\n\nfunction observedMetricValue<T>(value: ProviderValue<T> | undefined): T | null {\n return value?.state === 'observed' ? value.value : null\n}\n","import type { KeywordSet, KeywordSetDetail } from '@seo/core'\nimport { printKeyValue, printTable } from '../../../utils.js'\n\nexport function printKeywordSetList(sets: KeywordSet[]): void {\n if (sets.length === 0) {\n process.stdout.write('No keyword sets saved for this project.\\n')\n return\n }\n printTable(\n ['Name', 'Keywords', 'Market', 'Provider', 'Updated'],\n sets.map((set) => [\n set.name,\n set.keywordCount,\n `${set.market.countryCode}/${set.market.languageCode}`,\n set.provider ?? 'automatic',\n set.updatedAt,\n ]),\n )\n}\n\nexport function printKeywordSet(detail: KeywordSetDetail): void {\n printKeyValue([\n ['Name', detail.set.name],\n ['Project', detail.set.projectId],\n ['Keywords', String(detail.set.keywordCount)],\n [\n 'Market',\n `${detail.set.market.searchEngine} ${detail.set.market.countryCode}/${detail.set.market.languageCode}`,\n ],\n ['Provider', detail.set.provider ?? 'automatic'],\n ['Last refreshed', detail.set.lastRefreshedAt ?? 'never'],\n ])\n if (detail.items.length === 0) {\n process.stdout.write('\\nNo keywords matched this view.\\n')\n return\n }\n process.stdout.write('\\n')\n printTable(\n ['Keyword', 'Tags', 'Volume', 'Page'],\n detail.items.map((item) => [\n item.keyword,\n item.tags.join(', ') || '-',\n item.latestMetric?.metric.monthlySearchVolume.state === 'observed'\n ? item.latestMetric.metric.monthlySearchVolume.value\n : '-',\n item.page?.url ?? '-',\n ]),\n )\n if (detail.pagination.nextOffset !== null) {\n process.stdout.write(\n `\\nMore rows are available. Continue with --offset ${detail.pagination.nextOffset}.\\n`,\n )\n }\n}\n","import { listKeywordSets } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printKeywordSetList } from './output.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetListCommand = defineCommand({\n meta: { name: 'list', description: 'List saved keyword sets for a project' },\n args: { ...keywordSetProjectArgs, json: keywordSetJsonArg },\n run: async ({ args }) => {\n const project = await selectedProject(args)\n const sets = listKeywordSets({ projectId: project.id })\n if (jsonFlag(args)) printJson({ projectId: project.id, sets })\n else printKeywordSetList(sets)\n },\n})\n","import { refreshKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetRefreshCommand = defineCommand({\n meta: {\n name: 'refresh',\n description: 'Preview or refresh saved keyword metrics',\n },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n provider: { type: 'string', description: 'Optional keyword provider.' },\n limit: {\n type: 'string',\n default: '1000',\n description: 'Keywords to refresh, from 1 to 1000.',\n },\n offset: {\n type: 'string',\n default: '0',\n description: 'Saved keyword offset, from 0 to 100000.',\n },\n yes: {\n type: 'boolean',\n default: false,\n description: 'Run the paid refresh after estimating its cost.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit)) {\n throw new SeoError('INVALID_INPUT', '--limit must be an integer.')\n }\n if (!Number.isSafeInteger(offset)) {\n throw new SeoError('INVALID_INPUT', '--offset must be an integer.')\n }\n const project = await selectedProject(args)\n const report = await refreshKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n provider: stringArg(args.provider) as\n | 'dataforseo'\n | 'semrush'\n | 'ahrefs'\n | undefined,\n limit,\n offset,\n execute: booleanArg(args.yes),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printKeyValue([\n ['Set', report.set.name],\n ['Mode', report.mode],\n ['Keywords', String(report.selection.selectedKeywords)],\n ['Offset', String(report.selection.offset)],\n ['Requests', String(report.cost.requestCount)],\n [\n 'Estimated cost',\n report.cost.estimatedMicros === null\n ? 'unavailable'\n : `$${(report.cost.estimatedMicros / 1_000_000).toFixed(4)}`,\n ],\n ...(report.execution\n ? ([\n ['Saved snapshots', String(report.execution.savedSnapshots)],\n ['Partial batches', String(report.execution.partialBatches)],\n ['Failed batches', String(report.execution.failedBatches)],\n [\n 'Actual cost',\n report.execution.actualMicros === null\n ? 'unavailable'\n : `$${(report.execution.actualMicros / 1_000_000).toFixed(4)}`,\n ],\n ] satisfies Array<[string, string]>)\n : []),\n ])\n if (report.mode === 'preview') {\n process.stdout.write(\n `\\nRun again with --yes to refresh these ${report.selection.selectedKeywords} keywords.\\n`,\n )\n }\n },\n})\n","import { removeKeywordsFromSet } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordInputs,\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetRemoveCommand = defineCommand({\n meta: { name: 'remove', description: 'Remove keywords from a saved set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n keyword: { type: 'string', description: 'One keyword.' },\n keywords: { type: 'string', description: 'Comma-separated keywords.' },\n file: { type: 'string', description: 'Newline-delimited keyword file.' },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const project = await selectedProject(args)\n const result = removeKeywordsFromSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n keywords: await keywordInputs(args),\n })\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Set', result.setId],\n ['Removed', String(result.removed)],\n ['Keywords', String(result.keywordCount)],\n ])\n },\n})\n","import { getKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printKeywordSet } from './output.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetShowCommand = defineCommand({\n meta: { name: 'show', description: 'Show a bounded saved keyword set view' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n tag: { type: 'string', description: 'Only return keywords with this tag.' },\n limit: {\n type: 'string',\n default: '100',\n description: 'Rows to return, from 1 to 1000.',\n },\n offset: { type: 'string', default: '0', description: 'Rows to skip.' },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit) || !Number.isSafeInteger(offset)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--limit and --offset must be integers.',\n )\n }\n const project = await selectedProject(args)\n const detail = getKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n tag: stringArg(args.tag),\n limit,\n offset,\n })\n if (jsonFlag(args)) printJson(detail)\n else printKeywordSet(detail)\n },\n})\n","import { defineCommand } from 'citty'\nimport { keywordSetAddCommand } from './add.js'\nimport { keywordSetCreateCommand } from './create.js'\nimport { keywordSetDeleteCommand } from './delete.js'\nimport { keywordSetExportCommand } from './export.js'\nimport { keywordSetListCommand } from './list.js'\nimport { keywordSetRefreshCommand } from './refresh.js'\nimport { keywordSetRemoveCommand } from './remove.js'\nimport { keywordSetShowCommand } from './show.js'\n\nexport const keywordSetsCommand = defineCommand({\n meta: {\n name: 'keyword-sets',\n description: 'Manage project keyword research sets',\n },\n subCommands: {\n create: keywordSetCreateCommand,\n list: keywordSetListCommand,\n show: keywordSetShowCommand,\n add: keywordSetAddCommand,\n remove: keywordSetRemoveCommand,\n refresh: keywordSetRefreshCommand,\n export: keywordSetExportCommand,\n delete: keywordSetDeleteCommand,\n },\n})\n","import type { ClientProfile } from '@seo/core'\nimport { printKeyValue, printSummaryList } from '../../../utils.js'\n\nexport function printClientList(clients: ClientProfile[]): void {\n printSummaryList(\n clients.map((client) => ({\n title: `${client.name}${client.isDefault ? ' (default)' : ''}`,\n description: client.siteUrl,\n meta: [\n client.id,\n client.startUrl ? `crawl ${client.startUrl}` : '',\n client.watchUrls.length\n ? `${client.watchUrls.length} watched URL${client.watchUrls.length === 1 ? '' : 's'}`\n : '',\n client.brandTerms.length\n ? `${client.brandTerms.length} brand term${client.brandTerms.length === 1 ? '' : 's'}`\n : '',\n ],\n })),\n { empty: 'No saved projects.' },\n )\n}\n\nexport function printClientProfile(client: ClientProfile): void {\n printKeyValue([\n ['ID', client.id],\n ['Name', client.name],\n ['GSC property', client.siteUrl],\n ['Crawl URL', client.startUrl ?? 'not set'],\n ['Watch URLs', client.watchUrls.join(', ') || 'not set'],\n ['Brand terms', client.brandTerms.join(', ') || 'not set'],\n [\n 'Google Analytics property',\n client.analytics.google?.propertyId ?? 'not set',\n ],\n ['Report day', client.reportDay ? String(client.reportDay) : 'not set'],\n [\n 'Technical weekday',\n client.technicalWeekday === undefined\n ? 'not set'\n : String(client.technicalWeekday),\n ],\n ['Default', client.isDefault ? 'yes' : 'no'],\n ])\n}\n","import { saveClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../../args.js'\nimport { resolveSite } from '../../../selection.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientProfile } from './output.js'\n\nexport const clientAddCommand = defineCommand({\n meta: {\n name: 'add',\n description: 'Create or update a project profile',\n },\n args: {\n id: {\n type: 'string',\n description: 'Short stable project id, for example acme.',\n },\n name: {\n type: 'string',\n description: 'Human project name.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n url: {\n type: 'string',\n description: 'Default technical crawl start URL.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to watch with URL Inspection.',\n },\n 'google-analytics-property': {\n type: 'string',\n description: 'Optional Google Analytics property ID for this project.',\n },\n brand: {\n type: 'string',\n description: 'Comma-separated branded query terms to exclude by default.',\n },\n 'report-day': {\n type: 'string',\n description: 'Preferred monthly report day, 1-31.',\n },\n weekday: {\n type: 'string',\n description: 'Preferred technical-watch weekday, 0-7.',\n },\n default: {\n type: 'boolean',\n description: 'Make this the default project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = saveClient({\n id: stringArg(args.id),\n name: stringArg(args.name),\n siteUrl: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n startUrl: stringArg(args.url),\n watchUrls: listArg(args.urls),\n brandTerms: listArg(args.brand),\n analytics: stringArg(args['google-analytics-property'])\n ? {\n google: {\n propertyId: stringArg(args['google-analytics-property']) ?? '',\n },\n }\n : undefined,\n reportDay: numberArg(args['report-day']),\n technicalWeekday: numberArg(args.weekday),\n isDefault: booleanArg(args.default),\n })\n if (json) {\n printJson(client)\n return\n }\n printClientProfile(client)\n },\n})\n","import { setDefaultClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\n\nexport const clientDefaultCommand = defineCommand({\n meta: {\n name: 'default',\n description: 'Set the default project',\n },\n args: {\n id: {\n type: 'string',\n required: true,\n description: 'Project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const client = setDefaultClient(stringArg(args.id) ?? '')\n if (jsonFlag(args)) {\n printJson(client)\n return\n }\n process.stdout.write(`Default project set to ${client.id}.\\n`)\n },\n})\n","import { deleteClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\n\nexport const clientDeleteCommand = defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a project profile',\n },\n args: {\n id: {\n type: 'string',\n required: true,\n description: 'Project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteClient(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n})\n","import { listClients } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientList } from './output.js'\n\nexport const clientListCommand = defineCommand({\n meta: {\n name: 'list',\n description: 'List saved project profiles',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const clients = listClients()\n if (jsonFlag(args)) {\n printJson({ clients })\n return\n }\n printClientList(clients)\n },\n})\n","import { getClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientProfile } from './output.js'\n\nexport const clientShowCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Show one project profile',\n },\n args: {\n id: {\n type: 'string',\n description: 'Project id or name. Defaults to the default project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const client = getClient(stringArg(args.id))\n if (!client) throw new Error('Project not found.')\n if (jsonFlag(args)) {\n printJson(client)\n return\n }\n printClientProfile(client)\n },\n})\n","import { clientAddCommand } from './profiles/add.js'\nimport { clientDefaultCommand } from './profiles/default.js'\nimport { clientDeleteCommand } from './profiles/delete.js'\nimport { clientListCommand } from './profiles/list.js'\nimport { clientShowCommand } from './profiles/show.js'\n\nexport const clientProfileCommands = {\n list: clientListCommand,\n add: clientAddCommand,\n show: clientShowCommand,\n default: clientDefaultCommand,\n delete: clientDeleteCommand,\n}\n","import { defineCommand } from 'citty'\nimport { clientSetupCommand } from '../setup/index.js'\nimport { clientBrandCommand } from './brand.js'\nimport { keywordSetsCommand } from './keyword-sets/index.js'\nimport { clientProfileCommands } from './profiles.js'\n\nexport const clientCommand = defineCommand({\n meta: {\n name: 'client',\n description: 'Manage saved project profiles',\n },\n subCommands: {\n setup: clientSetupCommand,\n brand: clientBrandCommand,\n 'keyword-sets': keywordSetsCommand,\n ...clientProfileCommands,\n },\n})\n\nexport const projectCommand = defineCommand({\n ...clientCommand,\n meta: {\n name: 'projects',\n description: 'Manage saved project profiles',\n },\n})\n","import { contentOptimizationReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nexport const contentCommand = defineCommand({\n meta: {\n name: 'content',\n description: 'Optimize page content from real GSC queries',\n },\n subCommands: {\n optimize: defineCommand({\n meta: {\n name: 'optimize',\n description: 'Build a content optimization report for one URL',\n },\n args: {\n site: { type: 'string' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n url: { type: 'string', required: true },\n days: {\n type: 'string',\n description: 'GSC lookback days. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum GSC queries to inspect. Defaults to 25.',\n },\n 'min-impressions': {\n type: 'string',\n description: 'Minimum query impressions. Defaults to 10.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Fetch the page for content checks. Defaults to true.',\n 'Skip fetching the page for content checks.',\n ),\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for page extraction.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local GSC and HTTP cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await contentOptimizationReport({\n site: selection.site,\n url: stringArg(args.url) ?? '',\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']) !== false,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Content optimization',\n target: report.url,\n status: 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Score', value: `${report.summary.score}/100` },\n { label: 'Primary intent', value: report.summary.primaryIntent },\n {\n label: 'Primary query',\n value: report.summary.primaryQuery ?? 'None',\n },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Opportunities',\n value: formatCount(report.summary.opportunities),\n },\n {\n label: 'Estimated lift',\n value: formatCount(report.summary.estimatedClickLift),\n },\n ],\n })\n\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n action: action.action,\n context: action.plainEnglish,\n })),\n )\n\n if (report.brief.sections.length) {\n process.stdout.write('\\nSuggested sections\\n')\n printLimitedTable(\n ['Heading', 'Queries'],\n report.brief.sections.map((section) => [\n truncate(section.heading, 48),\n truncate(section.queries.join(', '), 80),\n ]),\n )\n }\n\n if (report.intentMix.length) {\n process.stdout.write('\\nIntent mix\\n')\n printLimitedTable(\n ['Intent', 'Queries', 'Impressions', 'Clicks'],\n report.intentMix.map((intent) => [\n intent.intent,\n formatCount(intent.queries),\n formatCount(intent.impressions),\n formatCount(intent.clicks),\n ]),\n )\n }\n\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import { createWriteStream } from 'node:fs'\nimport { mkdir } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport type { Writable } from 'node:stream'\nimport { finished } from 'node:stream/promises'\n\nconst BUFFER_SIZE = 64 * 1024\n\nclass BufferedWriter {\n private buffer = ''\n\n constructor(private readonly stream: Writable) {}\n\n async write(value: string): Promise<void> {\n this.buffer += value\n if (this.buffer.length >= BUFFER_SIZE) await this.flush()\n }\n\n async flush(): Promise<void> {\n if (!this.buffer) return\n const chunk = this.buffer\n this.buffer = ''\n if (!this.stream.write(chunk)) {\n await new Promise<void>((resolve, reject) => {\n const onDrain = () => {\n cleanup()\n resolve()\n }\n const onError = (error: Error) => {\n cleanup()\n reject(error)\n }\n const cleanup = () => {\n this.stream.off('drain', onDrain)\n this.stream.off('error', onError)\n }\n this.stream.once('drain', onDrain)\n this.stream.once('error', onError)\n })\n }\n }\n}\n\nfunction indentation(depth: number): string {\n return ' '.repeat(depth)\n}\n\nfunction jsonValue(value: unknown): unknown {\n if (\n value &&\n typeof value === 'object' &&\n 'toJSON' in value &&\n typeof value.toJSON === 'function'\n ) {\n return value.toJSON()\n }\n return value\n}\n\nasync function writeValue(\n writer: BufferedWriter,\n input: unknown,\n depth: number,\n ancestors: Set<object>,\n arrayItem = false,\n): Promise<boolean> {\n const value = jsonValue(input)\n if (value === null) {\n await writer.write('null')\n return true\n }\n if (typeof value === 'string' || typeof value === 'boolean') {\n await writer.write(JSON.stringify(value))\n return true\n }\n if (typeof value === 'number') {\n await writer.write(Number.isFinite(value) ? String(value) : 'null')\n return true\n }\n if (typeof value === 'bigint') {\n JSON.stringify(value)\n }\n if (\n value === undefined ||\n typeof value === 'function' ||\n typeof value === 'symbol'\n ) {\n if (arrayItem) await writer.write('null')\n return arrayItem\n }\n if (!value || typeof value !== 'object') return false\n if (ancestors.has(value)) {\n throw new TypeError('Converting circular structure to JSON')\n }\n ancestors.add(value)\n try {\n if (Array.isArray(value)) {\n if (value.length === 0) {\n await writer.write('[]')\n return true\n }\n await writer.write('[\\n')\n for (let index = 0; index < value.length; index += 1) {\n if (index > 0) await writer.write(',\\n')\n await writer.write(indentation(depth + 1))\n await writeValue(writer, value[index], depth + 1, ancestors, true)\n }\n await writer.write(`\\n${indentation(depth)}]`)\n return true\n }\n\n const entries = Object.entries(value).filter(([, item]) => {\n const normalized = jsonValue(item)\n return !['undefined', 'function', 'symbol'].includes(typeof normalized)\n })\n if (entries.length === 0) {\n await writer.write('{}')\n return true\n }\n await writer.write('{\\n')\n for (let index = 0; index < entries.length; index += 1) {\n const [key, item] = entries[index] as [string, unknown]\n if (index > 0) await writer.write(',\\n')\n await writer.write(`${indentation(depth + 1)}${JSON.stringify(key)}: `)\n await writeValue(writer, item, depth + 1, ancestors)\n }\n await writer.write(`\\n${indentation(depth)}}`)\n return true\n } finally {\n ancestors.delete(value)\n }\n}\n\nexport async function writeJsonStream(\n stream: Writable,\n value: unknown,\n): Promise<void> {\n const writer = new BufferedWriter(stream)\n const written = await writeValue(writer, value, 0, new Set())\n if (!written) await writer.write('undefined')\n await writer.write('\\n')\n await writer.flush()\n}\n\nexport async function writeJsonOutput(\n path: string | undefined,\n value: unknown,\n): Promise<void> {\n if (!path) {\n await writeJsonStream(process.stdout, value)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n const stream = createWriteStream(path)\n try {\n await writeJsonStream(stream, value)\n stream.end()\n await finished(stream)\n } catch (error) {\n stream.destroy()\n throw error\n }\n process.stdout.write(`Wrote ${path}\\n`)\n}\n","import {\n type CrawlReport,\n explainRule,\n reviewObservations,\n type TopFix,\n topFixes,\n} from '@seo/core'\nimport { printSemanticReport } from '../utils.js'\n\nfunction issueStatus(severity: TopFix['severity']): 'fail' | 'warning' {\n return severity === 'high' ? 'fail' : 'warning'\n}\n\nexport function printCrawlHuman(\n report: CrawlReport,\n fixes: TopFix[] = topFixes(report),\n): void {\n const reviews = reviewObservations(report)\n const status =\n report.status === 'failed' || report.summary.highIssues > 0\n ? 'fail'\n : report.status === 'partial'\n ? 'unknown'\n : report.summary.mediumIssues > 0 || report.summary.lowIssues > 0\n ? 'warning'\n : 'pass'\n const accessDiagnostics = report.access.samples.slice(0, 5).map((sample) => ({\n status: 'fail' as const,\n title: sample.evidence.guidance.summary,\n explanation: `${sample.evidence.provider} returned ${sample.evidence.kind} evidence for the crawler request.`,\n evidence: [sample.url],\n fix: sample.evidence.guidance.recommendedAction,\n }))\n const fixDiagnostics = fixes.slice(0, 10).map((fix) => ({\n status: issueStatus(fix.severity),\n title: `${fix.title} on ${fix.count} ${fix.count === 1 ? 'URL' : 'URLs'}`,\n explanation: explainRule(fix.ruleId)?.whyItMatters ?? fix.whyThisRanks,\n evidence: fix.sampleUrls.slice(0, 5),\n fix: fix.howToFix,\n }))\n const reviewDiagnostics = reviews.slice(0, 10).map((review) => ({\n status: 'warning' as const,\n title: `${review.title} on ${review.count} ${review.count === 1 ? 'URL' : 'URLs'}`,\n explanation:\n explainRule(review.ruleId)?.whyItMatters ?? review.whyThisRanks,\n evidence: review.sampleUrls.slice(0, 5),\n fix: review.howToFix,\n }))\n\n printSemanticReport({\n title:\n report.config.strategy === 'health'\n ? 'Sitemap health pass'\n : 'Site crawl',\n target: report.config.url,\n status,\n summary:\n report.status === 'partial'\n ? `Partial evidence from ${report.summary.totalPages} retained pages. Review the caveats before treating missing findings as an all-clear.`\n : `${report.summary.totalPages} pages retained with ${report.issues.length} findings.`,\n metrics: [\n { label: 'Pages', value: report.summary.totalPages },\n {\n label: 'High',\n value: report.summary.highIssues,\n status: 'fail',\n },\n {\n label: 'Medium',\n value: report.summary.mediumIssues,\n status: 'warning',\n },\n { label: 'Low', value: report.summary.lowIssues, status: 'info' },\n { label: 'Failed fetches', value: report.summary.failedUrls },\n ],\n sections: [\n { title: 'Access diagnostics', diagnostics: accessDiagnostics },\n { title: 'Prioritised fixes', diagnostics: fixDiagnostics },\n {\n title: 'Review before changing anything',\n diagnostics: reviewDiagnostics,\n },\n ...(!accessDiagnostics.length &&\n !fixDiagnostics.length &&\n !reviewDiagnostics.length\n ? [\n {\n title: 'Checks',\n diagnostics: [\n {\n status: 'pass' as const,\n title: 'No prioritised findings were observed',\n explanation:\n 'The evaluated crawl evidence did not produce a prioritised fix or review item.',\n },\n ],\n },\n ]\n : []),\n ],\n notes: [\n `Strategy: ${report.config.strategy}. Data: ${report.status}. Report: ${report.id}.`,\n ...report.warnings,\n ...report.caveats,\n ],\n })\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport {\n type CrawlOutputFormat,\n crawlSite,\n renderCrawlCsv,\n renderCrawlHtml,\n renderCrawlJunit,\n renderCrawlMarkdownTickets,\n renderCrawlPagesCsv,\n renderCrawlPretty,\n reviewObservations,\n saveCrawlReport,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n renderingModeArg,\n stringArg,\n} from '../args.js'\nimport { writeJsonOutput } from '../json-output.js'\nimport { printCrawlHuman } from '../presentation/crawl-report.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printKeyValue } from '../utils.js'\nimport { startUrlForSite } from './shared.js'\n\ntype Severity = 'low' | 'medium' | 'high'\n\nconst severityRank: Record<Severity, number> = {\n high: 3,\n medium: 2,\n low: 1,\n}\n\nexport const crawlCommand = defineCommand({\n meta: {\n name: 'crawl',\n description: 'Run a fast sitemap health pass or a full technical crawl',\n },\n args: {\n crawlUrl: {\n type: 'positional',\n required: false,\n description: 'Site start URL. Optional with --sitemap-url.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Optional when --project has a saved crawl URL.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for joining page metrics.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID for landing-page sessions. Defaults from --project when saved.',\n },\n mode: {\n type: 'string',\n description:\n 'Crawl mode: site, page, list, or sitemap. Start with sitemap --health for large sites.',\n },\n health: {\n type: 'boolean',\n default: false,\n description:\n 'Run the uncached sitemap status and redirect pass before a full audit. No page-body analysis.',\n },\n 'sitemap-url': {\n type: 'string',\n description:\n 'Explicit sitemap URL. Selects sitemap mode when --mode is omitted.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for list mode.',\n },\n 'urls-file': {\n type: 'string',\n description: 'File with one URL per line for list mode.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum pages to crawl, up to 10,000. Defaults to 500.',\n },\n 'max-depth': {\n type: 'string',\n description: 'Maximum click depth, up to 64. Defaults to 16.',\n },\n concurrency: {\n type: 'string',\n description:\n 'Parallel page fetches, up to 16. Defaults to 8, or progressively up to 4 with --health.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n include: {\n type: 'string',\n description: 'Comma-separated URL patterns to include.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n 'no-sitemap': {\n type: 'boolean',\n default: false,\n description: 'Do not seed URLs from sitemap.xml.',\n },\n 'no-robots': {\n type: 'boolean',\n default: false,\n description: 'Do not skip URLs disallowed by robots.txt.',\n },\n 'no-external': {\n type: 'boolean',\n default: false,\n description:\n 'Do not check external links. Reserved for full link checks.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Legacy alias for --rendering on.',\n },\n rendering: {\n type: 'string',\n description:\n 'JavaScript rendering mode: auto, on, or off. Defaults to auto.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON. Alias for --format json.',\n },\n format: {\n type: 'string',\n description:\n 'Output format: pretty, json, csv, html, markdown, or junit. JUnit requires --health.',\n },\n output: {\n type: 'string',\n description: 'Write output to this path instead of stdout.',\n },\n csv: {\n type: 'string',\n description: 'CSV table to render: issues or pages. Defaults to issues.',\n },\n save: {\n type: 'boolean',\n default: false,\n description: 'Save the crawl report locally.',\n },\n severity: {\n type: 'string',\n description: 'Only show top fixes at this severity.',\n },\n 'fail-on': {\n type: 'string',\n description: 'Exit non-zero when issues exist at this severity or above.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const format = crawlFormatArg(args.format, json)\n const output = stringArg(args.output)\n const csv = crawlCsvArg(args.csv)\n const severity = severityArg(args.severity)\n const failOn = severityArg(args['fail-on'])\n const project = projectArg(args)\n const urls = await urlListArgs(args)\n const explicitUrl = crawlUrlArg(args)\n const sitemapUrl = stringArg(args['sitemap-url'])\n const health = booleanArg(args.health)\n const explicitMode = crawlModeArg(args.mode)\n if (format === 'junit' && !health) {\n throw new Error('--format junit requires --health.')\n }\n if ((health || sitemapUrl) && explicitMode && explicitMode !== 'sitemap') {\n throw new Error('--health and --sitemap-url require sitemap mode.')\n }\n if (health && negatedBooleanArg(args, 'sitemap')) {\n throw new Error('--health cannot be combined with --no-sitemap.')\n }\n if ((health || sitemapUrl) && urls.length) {\n throw new Error(\n '--health and --sitemap-url cannot be combined with URL list input.',\n )\n }\n const selection =\n stringArg(args.site) ||\n project ||\n (!explicitUrl && !urls.length && !sitemapUrl)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const crawlUrl =\n explicitUrl ??\n selection?.client?.startUrl ??\n (selection?.site ? startUrlForSite(selection.site) : undefined) ??\n (sitemapUrl ? new URL('/', sitemapUrl).toString() : undefined) ??\n urls[0]\n if (!crawlUrl) {\n throw new Error(\n 'No crawl URL selected. Pass a URL, --url, or use --project with a saved crawl URL.',\n )\n }\n\n const report = await crawlSite({\n url: crawlUrl,\n projectId: selection?.client?.id,\n site: selection?.site,\n mode:\n explicitMode ??\n (health || sitemapUrl ? 'sitemap' : urls.length ? 'list' : undefined),\n strategy: health ? 'health' : 'full',\n sitemapUrl,\n urls,\n maxPages: numberArg(args['max-pages']),\n maxDepth: numberArg(args['max-depth']),\n concurrency: numberArg(args.concurrency),\n refresh: booleanArg(args.refresh),\n fetchRate: fetchRateArg({\n ...args,\n 'fetch-concurrency': args.concurrency,\n }),\n include: csvArg(args.include),\n exclude: csvArg(args.exclude),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection?.client?.analytics.google?.propertyId,\n useSitemap: !negatedBooleanArg(args, 'sitemap'),\n respectRobots: !negatedBooleanArg(args, 'robots'),\n checkExternal: !negatedBooleanArg(args, 'external'),\n js: renderingModeArg(args),\n })\n const saved = booleanArg(args.save) ? saveCrawlReport(report) : undefined\n const rankedFixes = topFixes(report, { severity })\n const failedThreshold = failOn\n ? report.issues.some(\n (issue) => severityRank[issue.severity] >= severityRank[failOn],\n )\n : false\n const failedRun = report.status === 'failed'\n\n const payload = {\n ...report,\n topFixes: rankedFixes,\n reviewObservations: reviewObservations(report, { severity }),\n ...(failOn ? { failOn, failedThreshold } : {}),\n ...(saved ? { saved } : {}),\n }\n\n if (format === 'json') {\n await writeJsonOutput(output, payload)\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'csv') {\n await writeOrPrint(\n output,\n csv === 'pages' ? renderCrawlPagesCsv(report) : renderCrawlCsv(report),\n )\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'html') {\n await writeOrPrint(output, renderCrawlHtml(report, rankedFixes))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'junit') {\n await writeOrPrint(output, renderCrawlJunit(report))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'markdown') {\n await writeOrPrint(\n output,\n renderCrawlMarkdownTickets(report, rankedFixes),\n )\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (output) {\n await writeOrPrint(output, renderCrawlPretty(report, rankedFixes))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n printCrawlHuman(report, rankedFixes)\n if (saved || failOn) {\n process.stdout.write('\\nRun metadata\\n')\n printKeyValue([\n ['Saved report', saved?.id ?? 'no'],\n ['Fail threshold', failOn ?? 'off'],\n ])\n }\n if (failedRun || failedThreshold) {\n process.exitCode = 1\n }\n },\n})\n\nfunction crawlModeArg(value: unknown) {\n const mode = stringArg(value)\n if (!mode) return undefined\n if (['site', 'page', 'list', 'sitemap'].includes(mode)) {\n return mode as 'site' | 'page' | 'list' | 'sitemap'\n }\n throw new Error('Mode must be one of: site, page, list, sitemap.')\n}\n\nfunction severityArg(value: unknown): Severity | undefined {\n const severity = stringArg(value)\n if (!severity) return undefined\n if (['low', 'medium', 'high'].includes(severity)) {\n return severity as Severity\n }\n throw new Error('Severity must be one of: low, medium, high.')\n}\n\nfunction crawlUrlArg(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.crawlUrl)\n const flag = stringArg(args.url)\n if (positional && flag && positional !== flag) {\n throw new Error('Use either a URL argument or --url, not both.')\n }\n return positional ?? flag\n}\n\nfunction crawlFormatArg(value: unknown, json: boolean): CrawlOutputFormat {\n const format = stringArg(value)\n if (json && format && format !== 'json') {\n throw new Error('Use either --json or --format, not both.')\n }\n if (!format) return json ? 'json' : 'pretty'\n if (['pretty', 'json', 'csv', 'html', 'markdown', 'junit'].includes(format)) {\n return format as CrawlOutputFormat\n }\n throw new Error(\n 'Format must be one of: pretty, json, csv, html, markdown, junit.',\n )\n}\n\nfunction crawlCsvArg(value: unknown): 'issues' | 'pages' {\n const csv = stringArg(value)\n if (!csv) return 'issues'\n if (['issues', 'pages'].includes(csv)) return csv as 'issues' | 'pages'\n throw new Error('CSV table must be one of: issues, pages.')\n}\n\nasync function urlListArgs(args: Record<string, unknown>): Promise<string[]> {\n const urls = csvArg(args.urls) ?? []\n const file = stringArg(args['urls-file'])\n if (file) {\n urls.push(...parseUrlList(await readFile(file, 'utf8')))\n }\n return [...new Set(urls)]\n}\n\nfunction parseUrlList(value: string): string[] {\n return value\n .split(/[\\n,]/)\n .map((item) => item.trim())\n .filter((item) => item && !item.startsWith('#'))\n}\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n","import {\n type CrawlReport,\n type CrawlReportMeta,\n compareCrawlReports,\n crawlSite,\n deleteCrawlReport,\n latestCrawlReport,\n listCrawlReports,\n loadCrawlReport,\n reviewObservations,\n saveCrawlReport,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printCrawlHuman } from '../presentation/crawl-report.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSummaryList, printTable } from '../utils.js'\nimport {\n printActionDetails,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nasync function reportSiteFilter(args: Record<string, unknown>, json: boolean) {\n const project = projectArg(args)\n const site = stringArg(args.site)\n if (!project && !site) return undefined\n return (\n await resolveClientSelection({\n client: project,\n site,\n options: { json },\n })\n ).site\n}\n\nfunction printReportList(reports: CrawlReportMeta[]): void {\n printSummaryList(\n reports.map((report) => ({\n title: report.id,\n description: report.site ?? report.url,\n meta: [\n report.status,\n `${report.totalPages} page${report.totalPages === 1 ? '' : 's'}`,\n `${report.issueCount} issue${report.issueCount === 1 ? '' : 's'}`,\n report.createdAt,\n ],\n })),\n { empty: 'No saved crawl reports.' },\n )\n}\n\nfunction printReport(report: CrawlReport): void {\n printCrawlHuman(report)\n}\n\nfunction printReportDiff(report: ReturnType<typeof compareCrawlReports>): void {\n printReportSummary({\n title: 'Crawl report comparison',\n target: report.after.url,\n status:\n report.comparability.status !== 'comparable' ||\n report.completeness.status !== 'complete'\n ? 'unknown'\n : report.summary.newStatusErrors > 0 ||\n report.summary.issueGroupsWorse > 0\n ? 'warning'\n : 'pass',\n summary: report.headline,\n metrics: [\n {\n label: 'Before',\n value: `${report.before.id} (${report.before.generatedAt})`,\n },\n {\n label: 'After',\n value: `${report.after.id} (${report.after.generatedAt})`,\n },\n { label: 'Comparability', value: report.comparability.status },\n { label: 'Completeness', value: report.completeness.status },\n {\n label: 'Pages',\n value: `${report.after.summary.totalPages} (${report.summary.pageDelta >= 0 ? '+' : ''}${report.summary.pageDelta})`,\n },\n {\n label: 'Issues',\n value: `${report.after.summary.highIssues + report.after.summary.mediumIssues + report.after.summary.lowIssues} (${report.summary.issueDelta >= 0 ? '+' : ''}${report.summary.issueDelta})`,\n },\n { label: 'New status errors', value: report.summary.newStatusErrors },\n { label: 'Fixed status errors', value: report.summary.fixedStatusErrors },\n { label: 'Issue groups worse', value: report.summary.issueGroupsWorse },\n { label: 'Issue groups better', value: report.summary.issueGroupsBetter },\n { label: 'Changed pages', value: report.summary.changedPages },\n { label: 'Added pages', value: report.summary.addedPages },\n { label: 'Removed pages', value: report.summary.removedPages },\n ],\n })\n\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n context: action.plainEnglish,\n action: action.action,\n })),\n report.topActions.length,\n )\n\n if (report.pageChanges.length) {\n process.stdout.write('\\nChanged pages\\n')\n printTable(\n ['Kind', 'Changes', 'URL'],\n report.pageChanges\n .slice(0, 15)\n .map((item) => [\n item.kind,\n item.changes.join(', '),\n truncate(item.url, 80),\n ]),\n )\n if (report.pageChanges.length > 15) {\n process.stdout.write(\n `Showing 15 of ${report.pageChanges.length}. Use --json for all changes.\\n`,\n )\n }\n }\n\n if (report.issueChanges.length) {\n process.stdout.write('\\nIssue movement\\n')\n printTable(\n ['Rule', 'Before', 'After', 'Delta'],\n report.issueChanges\n .slice(0, 10)\n .map((item) => [\n item.ruleId,\n String(item.before),\n String(item.after),\n `${item.delta >= 0 ? '+' : ''}${item.delta}`,\n ]),\n )\n }\n\n printNotes('Caveats', report.caveats)\n}\n\nfunction selectReportAliasMeta(\n reports: CrawlReportMeta[],\n input: {\n value: 'latest' | 'previous'\n skipId?: string\n },\n): CrawlReportMeta | undefined {\n if (input.value === 'latest') {\n return reports.find((item) => item.id !== input.skipId)\n }\n\n if (input.skipId) {\n const skippedIndex = reports.findIndex((item) => item.id === input.skipId)\n const older = skippedIndex >= 0 ? reports.slice(skippedIndex + 1) : reports\n return older.find((item) => item.id !== input.skipId)\n }\n\n return reports[1]\n}\n\nfunction resolveReportAlias(input: {\n value: string\n site?: string\n skipId?: string\n}): CrawlReport | undefined {\n if (input.value !== 'latest' && input.value !== 'previous') {\n return loadCrawlReport(input.value)\n }\n const reports = listCrawlReports({ site: input.site, limit: 20 })\n const meta = selectReportAliasMeta(reports, {\n value: input.value,\n skipId: input.skipId,\n })\n return meta ? loadCrawlReport(meta.id) : undefined\n}\n\nexport const crawlReportsCommand = defineCommand({\n meta: {\n name: 'crawl-reports',\n description: 'List, show, or delete saved crawl reports',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL for filtering reports.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n id: {\n type: 'string',\n description: 'Saved crawl report id to show.',\n },\n latest: {\n type: 'boolean',\n default: false,\n description: 'Show the latest saved crawl report.',\n },\n delete: {\n type: 'string',\n description: 'Delete a saved crawl report by id.',\n },\n rerun: {\n type: 'string',\n description: 'Rerun a saved crawl report by id, or pass latest.',\n },\n compare: {\n type: 'string',\n description: 'Compare a saved report id, latest, or previous.',\n },\n against: {\n type: 'string',\n description: 'Baseline report id. Defaults to previous.',\n },\n limit: {\n type: 'string',\n description: 'Maximum reports to list. Defaults to 20.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const site = await reportSiteFilter(args, json)\n const deleteId = stringArg(args.delete)\n const rerunId = stringArg(args.rerun)\n const compareId = stringArg(args.compare)\n const id = stringArg(args.id)\n\n if (deleteId) {\n const deleted = deleteCrawlReport(deleteId)\n if (json) {\n printJson({ id: deleteId, deleted })\n return\n }\n process.stdout.write(\n deleted\n ? `Deleted crawl report ${deleteId}.\\n`\n : `No saved crawl report found for ${deleteId}.\\n`,\n )\n return\n }\n\n if (rerunId) {\n const previous =\n rerunId === 'latest'\n ? latestCrawlReport(site)\n : loadCrawlReport(rerunId)\n if (!previous) {\n throw new Error(\n rerunId === 'latest'\n ? 'No saved crawl reports found.'\n : `No saved crawl report found for ${rerunId}.`,\n )\n }\n const report = await crawlSite({\n ...previous.config,\n projectId: previous.projectId,\n site: previous.site,\n googleAnalyticsPropertyId: previous.googleAnalyticsPropertyId,\n })\n const saved = saveCrawlReport(report)\n if (json) {\n printJson({\n ...report,\n rerunOf: previous.id,\n saved,\n topFixes: topFixes(report),\n reviewObservations: reviewObservations(report),\n })\n return\n }\n process.stdout.write(`Reran crawl report ${previous.id}.\\n\\n`)\n printReport(report)\n return\n }\n\n if (compareId) {\n const after = resolveReportAlias({ value: compareId, site })\n if (!after) {\n throw new Error(`No saved crawl report found for ${compareId}.`)\n }\n const beforeAlias = stringArg(args.against) ?? 'previous'\n const before = resolveReportAlias({\n value: beforeAlias,\n site: after.site ?? site,\n skipId: after.id,\n })\n if (!before) {\n throw new Error(\n `No baseline crawl report found for ${beforeAlias}. Save at least two reports or pass --against <id>.`,\n )\n }\n const diff = compareCrawlReports({ before, after })\n if (json) {\n printJson(diff)\n return\n }\n printReportDiff(diff)\n return\n }\n\n if (id || booleanArg(args.latest)) {\n const report = id ? loadCrawlReport(id) : latestCrawlReport(site)\n if (!report) {\n throw new Error(\n id\n ? `No saved crawl report found for ${id}.`\n : 'No saved crawl reports found.',\n )\n }\n if (json) {\n printJson(report)\n return\n }\n printReport(report)\n return\n }\n\n const reports = listCrawlReports({\n site,\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson({ reports })\n return\n }\n printReportList(reports)\n },\n})\n","import { inspectUrl, querySearchAnalytics } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonBodyArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printJson, printTable } from '../utils.js'\nimport { printReportSummary } from './output.js'\nimport { selectedSiteOrThrow } from './shared.js'\n\nexport const gscQueryCommand = defineCommand({\n meta: {\n name: 'gsc-query',\n description: 'Run a raw Search Console Search Analytics query',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'start-date': { type: 'string', description: 'Start date YYYY-MM-DD.' },\n 'end-date': { type: 'string', description: 'End date YYYY-MM-DD.' },\n dimensions: {\n type: 'string',\n description: 'Comma-separated GSC dimensions, for example query,page.',\n },\n type: { type: 'string', description: 'Search type. Defaults to web.' },\n limit: {\n type: 'string',\n description: 'Maximum rows to request and print.',\n },\n body: { type: 'string', description: 'Raw Search Analytics JSON body.' },\n 'body-file': {\n type: 'string',\n description: 'Path to a Search Analytics JSON body file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n },\n run: async ({ args }) => {\n const body =\n (await jsonBodyArg(args.body, args['body-file'])) ??\n ({\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n dimensions: csvArg(args.dimensions) ?? ['query', 'page'],\n type: stringArg(args.type) ?? 'web',\n rowLimit: numberArg(args.limit),\n dataState: 'final',\n } as Record<string, unknown>)\n const json = jsonFlag(args)\n const site = await selectedSiteOrThrow(\n {\n client: projectArg(args),\n site: stringArg(args.site) ?? stringArg(body.siteUrl),\n },\n { json, refresh: booleanArg(args.refresh) },\n )\n delete body.siteUrl\n const result = await querySearchAnalytics(site, body as never, {\n refresh: booleanArg(args.refresh),\n })\n const limit = numberArg(args.limit)\n const rows = limit ? result.rows.slice(0, limit) : result.rows\n if (json) {\n printJson({\n site,\n request: body,\n ...result,\n rows,\n rowsReturned: rows.length,\n })\n return\n }\n printReportSummary({\n title: 'Search Console query',\n target: site,\n status: result.rowsFetched > rows.length ? 'unknown' : 'info',\n summary: `${rows.length} rows returned from ${result.rowsFetched} fetched rows.`,\n metrics: [\n { label: 'Rows returned', value: rows.length },\n { label: 'Rows fetched', value: result.rowsFetched },\n { label: 'API calls', value: result.calls },\n ],\n })\n printTable(\n ['Keys', 'Clicks', 'Impr', 'CTR', 'Pos'],\n rows\n .slice(0, 25)\n .map((row) => [\n row.keys.join(' | '),\n Math.round(row.clicks),\n Math.round(row.impressions),\n row.ctr.toFixed(3),\n row.position.toFixed(1),\n ]),\n )\n },\n})\n\nexport const urlInspectCommand = defineCommand({\n meta: {\n name: 'url-inspect',\n description: 'Inspect a URL with the Search Console URL Inspection API',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: { type: 'string', description: 'URL to inspect.' },\n language: {\n type: 'string',\n description: 'Optional inspection language code.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const siteUrl = await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n { json },\n )\n const inspectionUrl = stringArg(args.url)\n if (!inspectionUrl) throw new Error('Pass --url.')\n const result = await inspectUrl({\n siteUrl,\n inspectionUrl,\n languageCode: stringArg(args.language),\n })\n if (json) {\n printJson(result)\n return\n }\n const indexStatus = result.inspectionResult?.indexStatusResult\n printReportSummary({\n title: 'URL Inspection',\n target: inspectionUrl,\n status:\n indexStatus === undefined\n ? 'unknown'\n : indexStatus.verdict === 'PASS'\n ? 'pass'\n : 'warning',\n summary:\n indexStatus === undefined\n ? 'Google did not return index status evidence for this URL.'\n : `${indexStatus.verdict ?? 'Unknown'}: ${indexStatus.coverageState ?? 'Coverage state unavailable'}.`,\n metrics: [\n { label: 'Property', value: siteUrl },\n { label: 'Robots', value: indexStatus?.robotsTxtState ?? 'Unknown' },\n { label: 'Last crawl', value: indexStatus?.lastCrawlTime ?? 'Unknown' },\n {\n label: 'Google canonical',\n value: indexStatus?.googleCanonical ?? 'Unknown',\n },\n ],\n })\n },\n})\n","import type { ArgDef } from 'citty'\n\n// Shared report option metadata used by CLI commands. The parity check keeps\n// this aligned with scripts/report-surface-catalog.mjs.\ntype CliReportOption = {\n cli: string\n arg: ArgDef\n}\n\nconst REPORT_OPTIONS = {\n days: {\n cli: 'days',\n arg: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n },\n recentDays: {\n cli: 'recent',\n arg: {\n type: 'string',\n description: 'Recent anomaly window in days. Defaults to 14.',\n },\n },\n range: {\n cli: 'days',\n arg: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n },\n limit: {\n cli: 'limit',\n arg: {\n type: 'string',\n description: 'Maximum rows to return.',\n },\n },\n checkLimit: {\n cli: 'check-limit',\n arg: {\n type: 'string',\n description: 'Maximum candidate pages to fetch and check.',\n },\n },\n minImpressions: {\n cli: 'min-impressions',\n arg: {\n type: 'string',\n description: 'Minimum query impressions.',\n },\n },\n includeBrand: {\n cli: 'include-brand',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in opportunity reports.',\n },\n },\n verifyContent: {\n cli: 'verify-content',\n arg: {\n type: 'boolean',\n default: false,\n description:\n 'Verify top opportunities against page title, meta, and content.',\n },\n },\n verifyLimit: {\n cli: 'verify-limit',\n arg: {\n type: 'string',\n description: 'Maximum opportunity URLs to verify.',\n },\n },\n js: {\n cli: 'js',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for verified pages.',\n },\n },\n fetchConcurrency: {\n cli: 'fetch-concurrency',\n arg: {\n type: 'string',\n description:\n 'Maximum concurrent page fetches per host, up to 16. Defaults to 4.',\n },\n },\n fetchIntervalCap: {\n cli: 'fetch-interval-cap',\n arg: {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n },\n fetchIntervalMs: {\n cli: 'fetch-interval-ms',\n arg: {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n },\n refresh: {\n cli: 'refresh',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n} as const satisfies Record<string, CliReportOption>\n\ntype ReportOptionKey = keyof typeof REPORT_OPTIONS\n\nexport function cliReportArgs<const T extends readonly ReportOptionKey[]>(\n keys: T,\n overrides: Partial<Record<ReportOptionKey, Partial<ArgDef>>> = {},\n): Record<(typeof REPORT_OPTIONS)[T[number]]['cli'], ArgDef> {\n return Object.fromEntries(\n keys.map((key) => {\n const option = REPORT_OPTIONS[key]\n return [option.cli, { ...option.arg, ...overrides[key] }]\n }),\n ) as Record<(typeof REPORT_OPTIONS)[T[number]]['cli'], ArgDef>\n}\n","import { trafficAnomaly, updateCorrelation } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printJson, printTable } from '../utils.js'\nimport {\n printLimitedTable,\n printNextCommand,\n printNotes,\n printReportSummary,\n} from './output.js'\nimport { cliReportArgs } from './report-options.js'\nimport { selectedSiteOrThrow } from './shared.js'\n\nfunction formatNumber(value: number): string {\n return value.toLocaleString('en-GB', {\n maximumFractionDigits: value >= 100 ? 0 : 1,\n })\n}\n\nfunction formatChange(value: number | null): string {\n if (value === null) return 'n/a'\n const rounded = Math.abs(value) >= 10 ? value.toFixed(0) : value.toFixed(1)\n return `${value > 0 ? '+' : ''}${rounded}%`\n}\n\nexport const trafficAnomalyCommand = defineCommand({\n meta: {\n name: 'traffic-anomaly',\n description: 'Detect unusual recent GSC traffic movement',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'recentDays', 'refresh'], {\n days: { description: 'Baseline window length in days. Defaults to 90.' },\n recentDays: {\n description: 'Recent anomaly window in days. Defaults to 7.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await trafficAnomaly({\n site: await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n {\n json,\n refresh: booleanArg(args.refresh),\n },\n ),\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Traffic anomaly report',\n target: report.site,\n status:\n report.coverage?.status !== 'complete'\n ? 'unknown'\n : report.anomalies.some((anomaly) => anomaly.significant)\n ? 'warning'\n : 'pass',\n summary: report.anomalies.some((anomaly) => anomaly.significant)\n ? 'At least one recent metric moved beyond the report threshold.'\n : 'No significant recent movement was found in the retained evidence.',\n metrics: [\n { label: 'Metrics checked', value: report.anomalies.length },\n {\n label: 'Significant',\n value: report.anomalies.filter((anomaly) => anomaly.significant)\n .length,\n },\n {\n label: 'Observed days',\n value: report.coverage?.observedDays ?? 'Unavailable',\n },\n {\n label: 'Expected days',\n value: report.coverage?.expectedDays ?? 'Unavailable',\n },\n ],\n })\n printLimitedTable(\n [\n 'Metric',\n 'Direction',\n 'Baseline/day',\n 'Recent/day',\n 'Change',\n 'z',\n 'Significant',\n ],\n report.anomalies.map((anomaly) => [\n anomaly.metric,\n anomaly.direction,\n formatNumber(anomaly.baselineMean),\n formatNumber(anomaly.comparisonMean),\n formatChange(anomaly.percentChange),\n anomaly.zScore ?? 'n/a',\n anomaly.significant ? 'yes' : 'no',\n ]),\n )\n if (report.coverage) {\n printNotes('Evidence coverage', [\n `${report.coverage.observedDays} of ${report.coverage.expectedDays} requested calendar days returned date aggregates.`,\n ...report.coverage.caveats,\n ])\n }\n },\n})\n\nexport const updateCorrelateCommand = defineCommand({\n meta: {\n name: 'update-correlate',\n description: 'Compare traffic movement with official Google update windows',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'recentDays', 'refresh'], {\n days: { description: 'Baseline window length in days. Defaults to 90.' },\n recentDays: {\n description: 'Recent anomaly window in days. Defaults to 7.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n 'padding-days': {\n type: 'string',\n description: 'Days around update windows to count as overlap.',\n },\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = projectArg(args)\n const site = await selectedSiteOrThrow(\n { client, site: stringArg(args.site) },\n {\n json,\n refresh: booleanArg(args.refresh),\n },\n )\n const report = await updateCorrelation({\n site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n paddingDays: numberArg(args['padding-days']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Google update correlation',\n target: report.site,\n status: 'unknown',\n summary: report.summary,\n metrics: [\n {\n label: 'Classification',\n value: report.classification.replaceAll('-', ' '),\n },\n {\n label: 'Attribution',\n value: report.attribution.replaceAll('-', ' '),\n },\n { label: 'Confidence', value: report.confidence },\n { label: 'Updates matched', value: report.overlappingUpdates.length },\n { label: 'Known confounders', value: report.confounders.length },\n { label: 'Source', value: report.source.name },\n ],\n })\n printNotes('Evidence', report.evidence)\n printNotes('Report caveats', report.caveats)\n printNotes('Recommended next checks', report.actions)\n printLimitedTable(\n ['Metric', 'Direction', 'Baseline/day', 'Recent/day', 'Change', 'z'],\n report.anomalies.map((anomaly) => [\n anomaly.metric,\n anomaly.direction,\n formatNumber(anomaly.baselineMean),\n formatNumber(anomaly.comparisonMean),\n formatChange(anomaly.percentChange),\n anomaly.zScore ?? 'n/a',\n ]),\n )\n if (report.overlappingUpdates.length) {\n process.stdout.write('\\nUpdates\\n')\n printTable(\n ['Start', 'End', 'Type', 'Name'],\n report.overlappingUpdates.map((update) => [\n update.start.slice(0, 10),\n update.end?.slice(0, 10) ?? 'open',\n update.type,\n update.name,\n ]),\n )\n }\n const target = client\n ? `--project ${JSON.stringify(client)}`\n : `--site ${JSON.stringify(site)}`\n printNextCommand(`seo segment-impact ${target} --dimension page`)\n },\n})\n","import { type EntityReadinessReport, entityReadiness } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { printJson, printSemanticReport } from '../utils.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction printEntityReadiness(report: EntityReadinessReport): void {\n printSemanticReport({\n title: 'Entity evidence',\n target: report.url,\n status: report.dataStatus === 'partial' ? 'unknown' : 'info',\n summary: report.headline,\n metrics: [\n {\n label: 'Pages',\n value: `${report.evaluatedPages}/${report.crawlPages}`,\n },\n { label: 'sameAs', value: report.entities.sameAs.length },\n { label: 'Social', value: report.entities.socialProfiles.length },\n { label: 'Authors', value: report.entities.authors.length },\n ],\n sections: [\n {\n title: 'Observed entity signals',\n diagnostics: report.checks.map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n },\n ],\n notes: [\n `Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const entityReadinessCommand = defineCommand({\n meta: {\n name: 'entity-readiness',\n description:\n 'Check schema, sameAs, social, author, and naming signals from a saved crawl',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const readiness = entityReadiness(report)\n if (json) {\n printJson(readiness)\n return\n }\n printEntityReadiness(readiness)\n },\n})\n","import {\n type ChangeScope,\n deleteChange,\n listChanges,\n measureChange,\n recordChange,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction changeScope(value: unknown): ChangeScope {\n const scope = stringArg(value) ?? 'page'\n if (\n scope !== 'site' &&\n scope !== 'page' &&\n scope !== 'query' &&\n scope !== 'group'\n ) {\n throw new Error('Invalid --scope. Use site, page, query, or group.')\n }\n return scope\n}\n\nexport const changeLogCommand = defineCommand({\n meta: {\n name: 'change-log',\n description: 'Annotate SEO changes and measure before/after impact',\n },\n subCommands: {\n list: defineCommand({\n meta: {\n name: 'list',\n description: 'List recorded SEO changes',\n },\n args: {\n site: { type: 'string' },\n limit: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const changes = listChanges({\n site: stringArg(args.site),\n limit: numberArg(args.limit),\n })\n if (jsonFlag(args)) {\n printJson({ changes })\n return\n }\n printTable(\n ['ID', 'Date', 'Site', 'Scope', 'Target', 'Title'],\n changes.map((change) => [\n change.id,\n change.changedAt,\n change.site,\n change.scope,\n change.target,\n change.title,\n ]),\n )\n },\n }),\n add: defineCommand({\n meta: {\n name: 'add',\n description: 'Record an SEO change',\n },\n args: {\n site: { type: 'string' },\n scope: { type: 'string', default: 'page' },\n target: { type: 'string', required: true },\n title: { type: 'string', required: true },\n description: { type: 'string' },\n date: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const change = recordChange({\n site: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n scope: changeScope(args.scope),\n target: stringArg(args.target) ?? '',\n title: stringArg(args.title) ?? '',\n description: stringArg(args.description),\n changedAt: stringArg(args.date) ?? today(),\n })\n if (json) {\n printJson(change)\n return\n }\n printKeyValue([\n ['ID', change.id],\n ['Date', change.changedAt],\n ['Site', change.site],\n ['Scope', change.scope],\n ['Target', change.target],\n ['Title', change.title],\n ])\n },\n }),\n delete: defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a recorded SEO change',\n },\n args: {\n id: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteChange(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n }),\n measure: defineCommand({\n meta: {\n name: 'measure',\n description:\n 'Measure a change with equal finalized before/after windows',\n },\n args: {\n id: { type: 'string' },\n site: { type: 'string' },\n scope: { type: 'string' },\n target: { type: 'string' },\n title: { type: 'string' },\n date: { type: 'string' },\n before: { type: 'string' },\n after: { type: 'string' },\n json: { type: 'boolean', default: false },\n refresh: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const id = stringArg(args.id)\n if (\n !id &&\n (!stringArg(args.site) ||\n !stringArg(args.scope) ||\n !stringArg(args.target) ||\n !stringArg(args.date))\n ) {\n throw new Error(\n 'Pass --id, or pass --site, --scope, --target, and --date for an ad hoc measurement.',\n )\n }\n const report = await measureChange({\n id,\n site: id\n ? undefined\n : await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n scope: id ? undefined : changeScope(args.scope),\n target: id ? undefined : stringArg(args.target),\n title: stringArg(args.title),\n changedAt: id ? undefined : stringArg(args.date),\n beforeDays: strictNumberArg(args.before, '--before'),\n afterDays: strictNumberArg(args.after, '--after'),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Change measurement',\n target: report.change.title,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.note,\n metrics: [\n { label: 'Verdict', value: report.verdict },\n { label: 'Confidence', value: report.confidence },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n {\n label: 'Window',\n value: `${report.window.effectiveDays}/${report.window.requestedDays} finalized days`,\n },\n ],\n })\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'Clicks',\n report.before.metrics?.clicks ?? 'unavailable',\n report.after.metrics?.clicks ?? 'unavailable',\n report.delta.clicks === null\n ? 'unavailable'\n : report.delta.clickPct === null\n ? `${report.delta.clicks}`\n : `${report.delta.clicks} (${report.delta.clickPct}%)`,\n ],\n [\n 'Impressions',\n report.before.metrics?.impressions ?? 'unavailable',\n report.after.metrics?.impressions ?? 'unavailable',\n report.delta.impressions === null\n ? 'unavailable'\n : report.delta.impressionPct === null\n ? `${report.delta.impressions}`\n : `${report.delta.impressions} (${report.delta.impressionPct}%)`,\n ],\n [\n 'CTR',\n report.before.metrics?.ctr ?? 'unavailable',\n report.after.metrics?.ctr ?? 'unavailable',\n report.delta.ctr ?? 'unavailable',\n ],\n [\n 'Position',\n report.before.metrics?.position ?? 'unavailable',\n report.after.metrics?.position ?? 'unavailable',\n report.delta.position ?? 'unavailable',\n ],\n ],\n )\n printNotes('Warnings', report.warnings)\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import {\n type ContentGroupDimension,\n type ContentGroupMatchType,\n createContentGroup,\n deleteContentGroup,\n listContentGroups,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\n\nfunction groupDimension(value: unknown): ContentGroupDimension {\n const dimension = stringArg(value) ?? 'page'\n if (dimension !== 'page' && dimension !== 'query') {\n throw new Error('Invalid --dimension. Use page or query.')\n }\n return dimension\n}\n\nfunction matchType(value: unknown): ContentGroupMatchType {\n const type = stringArg(value) ?? 'contains'\n if (type !== 'equals' && type !== 'contains' && type !== 'regex') {\n throw new Error('Invalid --match. Use equals, contains, or regex.')\n }\n return type\n}\n\nexport const contentGroupsCommand = defineCommand({\n meta: {\n name: 'content-groups',\n description: 'Create and manage reusable page/query groups',\n },\n subCommands: {\n list: defineCommand({\n meta: {\n name: 'list',\n description: 'List saved content groups',\n },\n args: {\n site: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const groups = listContentGroups(stringArg(args.site))\n if (jsonFlag(args)) {\n printJson({ groups })\n return\n }\n printTable(\n ['ID', 'Site', 'Name', 'Dimension', 'Match', 'Pattern'],\n groups.map((group) => [\n group.id,\n group.site,\n group.name,\n group.dimension,\n group.matchType,\n group.pattern,\n ]),\n )\n },\n }),\n add: defineCommand({\n meta: {\n name: 'add',\n description: 'Create a reusable page or query group',\n },\n args: {\n site: { type: 'string' },\n name: { type: 'string', required: true },\n dimension: { type: 'string', default: 'page' },\n match: { type: 'string', default: 'contains' },\n pattern: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const group = createContentGroup({\n site: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n name: stringArg(args.name) ?? '',\n dimension: groupDimension(args.dimension),\n matchType: matchType(args.match),\n pattern: stringArg(args.pattern) ?? '',\n })\n if (json) {\n printJson(group)\n return\n }\n printKeyValue([\n ['ID', group.id],\n ['Site', group.site],\n ['Name', group.name],\n ['Filter', `${group.dimension} ${group.matchType} ${group.pattern}`],\n ])\n },\n }),\n delete: defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a content group',\n },\n args: {\n id: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteContentGroup(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n }),\n },\n})\n","import {\n type ChangeMeasurement,\n type ChangeScope,\n listChanges,\n measureChange,\n recordChange,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { formatCount, printNotes, printReportSummary } from '../output.js'\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction changeScope(value: unknown): ChangeScope {\n const scope = stringArg(value) ?? 'page'\n if (\n scope !== 'site' &&\n scope !== 'page' &&\n scope !== 'query' &&\n scope !== 'group'\n ) {\n throw new Error('Invalid --scope. Use site, page, query, or group.')\n }\n return scope\n}\n\nfunction maybeScope(value: unknown): ChangeScope | undefined {\n return value ? changeScope(value) : undefined\n}\n\nfunction pct(value: number | null): string {\n return value === null ? 'n/a' : `${value.toFixed(1)}%`\n}\n\nfunction countMetric(value: number | null | undefined): string {\n return value === null || value === undefined\n ? 'unavailable'\n : formatCount(value)\n}\n\nfunction countDelta(value: number | null, percentage: number | null): string {\n return value === null\n ? 'unavailable'\n : `${formatCount(value)} (${pct(percentage)})`\n}\n\nfunction decimalMetric(value: number | null | undefined, digits = 1): string {\n return value === null || value === undefined\n ? 'unavailable'\n : value.toFixed(digits)\n}\n\nfunction printMeasurement(report: ChangeMeasurement): void {\n printReportSummary({\n title: 'SEO test report',\n target: report.change.title,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.note,\n metrics: [\n { label: 'Verdict', value: report.verdict },\n { label: 'Confidence', value: report.confidence },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n {\n label: 'Window',\n value: `${report.window.effectiveDays}/${report.window.requestedDays} finalized days`,\n },\n ],\n })\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'GSC clicks',\n countMetric(report.before.metrics?.clicks),\n countMetric(report.after.metrics?.clicks),\n countDelta(report.delta.clicks, report.delta.clickPct),\n ],\n [\n 'GSC impressions',\n countMetric(report.before.metrics?.impressions),\n countMetric(report.after.metrics?.impressions),\n countDelta(report.delta.impressions, report.delta.impressionPct),\n ],\n [\n 'GSC CTR',\n report.before.metrics\n ? `${(report.before.metrics.ctr * 100).toFixed(1)}%`\n : 'unavailable',\n report.after.metrics\n ? `${(report.after.metrics.ctr * 100).toFixed(1)}%`\n : 'unavailable',\n report.delta.ctr === null\n ? 'unavailable'\n : `${(report.delta.ctr * 100).toFixed(1)} pts`,\n ],\n [\n 'GSC position',\n decimalMetric(report.before.metrics?.position),\n decimalMetric(report.after.metrics?.position),\n decimalMetric(report.delta.position),\n ],\n ],\n )\n\n if (report.analytics) {\n process.stdout.write('\\nGoogle Analytics impact\\n')\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'Sessions',\n formatCount(report.analytics.before.metrics.sessions),\n formatCount(report.analytics.after.metrics.sessions),\n `${formatCount(report.analytics.delta.sessions)} (${pct(report.analytics.delta.sessionPct)})`,\n ],\n [\n 'Conversions',\n formatCount(report.analytics.before.metrics.conversions),\n formatCount(report.analytics.after.metrics.conversions),\n `${formatCount(report.analytics.delta.conversions)} (${pct(report.analytics.delta.conversionPct)})`,\n ],\n [\n 'Revenue',\n report.analytics.before.metrics.totalRevenue.toFixed(2),\n report.analytics.after.metrics.totalRevenue.toFixed(2),\n `${report.analytics.delta.totalRevenue.toFixed(2)} (${pct(report.analytics.delta.revenuePct)})`,\n ],\n ],\n )\n }\n\n if (report.control) {\n process.stdout.write('\\nControl comparison\\n')\n printKeyValue([\n ['Control', report.control.change.title],\n [\n 'Adjusted clicks',\n report.control.adjusted.clickDelta === null\n ? 'n/a'\n : formatCount(report.control.adjusted.clickDelta),\n ],\n [\n 'Adjusted click %',\n report.control.adjusted.clickPctPoints === null\n ? 'n/a'\n : `${report.control.adjusted.clickPctPoints.toFixed(1)} pts`,\n ],\n ['Note', report.control.note],\n ])\n }\n printNotes('Warnings', report.warnings)\n printNotes('Caveats', report.caveats)\n}\n\nexport const testsCommand = defineCommand({\n meta: {\n name: 'tests',\n description:\n 'Create and report local SEO tests from Search Console and Google Analytics data',\n },\n subCommands: {\n list: defineCommand({\n meta: { name: 'list', description: 'List saved SEO tests' },\n args: {\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n limit: {\n type: 'string',\n description: 'Maximum tests to list. Defaults to 20.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = projectArg(args)\n const selection =\n project || stringArg(args.site)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const changes = listChanges({\n site: selection?.site,\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson({ tests: changes })\n return\n }\n printTable(\n ['ID', 'Date', 'Scope', 'Target', 'Title'],\n changes.map((change) => [\n change.id,\n change.changedAt,\n change.scope,\n change.target,\n change.title,\n ]),\n )\n },\n }),\n create: defineCommand({\n meta: { name: 'create', description: 'Create a local SEO test' },\n args: {\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n scope: {\n type: 'string',\n default: 'page',\n description: 'Change scope: site, page, query, or group.',\n },\n target: {\n type: 'string',\n required: true,\n description: 'Changed URL, query, group pattern, or site marker.',\n },\n title: {\n type: 'string',\n required: true,\n description: 'Plain-English name for the test.',\n },\n description: {\n type: 'string',\n description: 'Optional note about what changed.',\n },\n date: {\n type: 'string',\n description: 'Change date in YYYY-MM-DD. Defaults to today.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const change = recordChange({\n site: selection.site,\n scope: changeScope(args.scope),\n target: stringArg(args.target) ?? '',\n title: stringArg(args.title) ?? '',\n description: stringArg(args.description),\n changedAt: stringArg(args.date) ?? today(),\n })\n if (json) {\n printJson(change)\n return\n }\n printKeyValue([\n ['ID', change.id],\n ['Date', change.changedAt],\n ['Project', selection.client?.name ?? selection.site],\n ['Scope', change.scope],\n ['Target', change.target],\n ['Title', change.title],\n ])\n },\n }),\n report: defineCommand({\n meta: {\n name: 'report',\n description:\n 'Report an SEO test with equal finalized before/after windows',\n },\n args: {\n id: { type: 'string', description: 'Saved SEO test id.' },\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n scope: {\n type: 'string',\n description: 'Ad-hoc change scope: site, page, query, or group.',\n },\n target: {\n type: 'string',\n description:\n 'Ad-hoc changed URL, query, group pattern, or site marker.',\n },\n title: { type: 'string', description: 'Ad-hoc test title.' },\n date: {\n type: 'string',\n description: 'Ad-hoc change date in YYYY-MM-DD.',\n },\n property: {\n type: 'string',\n description: 'Google Analytics property ID.',\n },\n 'control-scope': {\n type: 'string',\n description: 'Control scope: site, page, query, or group.',\n },\n 'control-target': {\n type: 'string',\n description: 'Control URL, query, group pattern, or site marker.',\n },\n 'control-title': {\n type: 'string',\n description: 'Plain-English name for the control group.',\n },\n before: {\n type: 'string',\n description: 'Days before the change date. Defaults to 28.',\n },\n after: {\n type: 'string',\n description: 'Days after the change date. Defaults to 28.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description:\n 'Bypass the local Search Console and Google Analytics cache.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const id = stringArg(args.id)\n const needsSelection =\n !id || Boolean(projectArg(args) || stringArg(args.site))\n const selection = needsSelection\n ? await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n : undefined\n const report = await measureChange({\n id,\n site: id ? undefined : selection?.site,\n scope: id ? undefined : maybeScope(args.scope),\n target: id ? undefined : stringArg(args.target),\n title: stringArg(args.title),\n changedAt: id ? undefined : stringArg(args.date),\n googleAnalyticsPropertyId:\n stringArg(args.property) ??\n selection?.client?.analytics.google?.propertyId,\n controlScope: maybeScope(args['control-scope']),\n controlTarget: stringArg(args['control-target']),\n controlTitle: stringArg(args['control-title']),\n beforeDays: strictNumberArg(args.before, '--before'),\n afterDays: strictNumberArg(args.after, '--after'),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printMeasurement(report)\n },\n }),\n },\n})\n","import type { ProgressReporter } from '@seo/core'\n\nexport function createProgressReporter(\n enabled: boolean,\n): ProgressReporter | undefined {\n if (!enabled) return undefined\n const startedAt = Date.now()\n return (message) => {\n const elapsed = ((Date.now() - startedAt) / 1000).toFixed(1)\n process.stderr.write(`[seo ${elapsed}s] ${message}\\n`)\n }\n}\n","import {\n booleanArg,\n fetchRateArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const reportSelectionArgs = {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n} as const\n\nexport const reportFetchArgs = {\n ...cliReportArgs([\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n} as const\n\nexport function reportFetchOptions(args: Record<string, unknown>) {\n return {\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']) ?? 3,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n }\n}\n\nexport function reportSelectionInput(args: Record<string, unknown>) {\n return {\n client: projectArg(args),\n site: stringArg(args.site),\n refresh: booleanArg(args.refresh),\n }\n}\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { type CsvFile, countLabel, renderCsv } from '@seo/core'\nimport { reportFetchArgs } from '../reports/args.js'\n\nconst { json: _json, ...reportFetchArgsWithoutJson } = reportFetchArgs\n\nexport const exportReportFetchArgs = reportFetchArgsWithoutJson\n\nexport const exportSelectionArgs = {\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name. Defaults to the configured default.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL/id when not using a saved project.',\n },\n} as const\n\nexport function outArg(report: string) {\n return {\n type: 'string',\n description: `Output folder. Defaults to ./seo-export/<project>-${report}-YYYY-MM-DD.`,\n } as const\n}\n\nfunction slug(value: string): string {\n return value\n .toLowerCase()\n .replace(/^sc-domain:/, '')\n .replace(/^https?:\\/\\//, '')\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\nexport function defaultOutDir(input: {\n report: string\n clientId?: string\n site: string\n}) {\n const day = new Date().toISOString().slice(0, 10)\n const id = slug(input.clientId ?? input.site)\n return resolve(process.cwd(), 'seo-export', `${id}-${input.report}-${day}`)\n}\n\nexport async function writeCsvFiles(outDir: string, files: CsvFile[]) {\n await mkdir(outDir, { recursive: true })\n const written: string[] = []\n for (const file of files) {\n const path = resolve(outDir, file.filename)\n await writeFile(path, renderCsv(file.rows, file.headers), 'utf8')\n written.push(path)\n }\n return written\n}\n\nexport function printWritten(outDir: string, files: string[]) {\n process.stdout.write(\n `Wrote ${countLabel(files.length, 'CSV file')} to ${outDir}\\n`,\n )\n for (const file of files) {\n process.stdout.write(`- ${file}\\n`)\n }\n}\n","import { diagnoseCsvFiles, diagnoseProperty } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportDiagnoseCommand = defineCommand({\n meta: {\n name: 'diagnose',\n description:\n 'Export diagnosis tables: priorities, anomalies, movement, decay, cannibalisation, striking-distance, and quick wins.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('diagnose'),\n days: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 90.',\n },\n recent: {\n type: 'string',\n description: 'Recent anomaly window in days.',\n },\n limit: {\n type: 'string',\n description: 'Maximum rows per movement/opportunity table.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in opportunity reports.',\n },\n 'verify-content': {\n type: 'boolean',\n default: false,\n description:\n 'Verify top opportunities against page title, meta, and content.',\n },\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for verified pages.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n })\n const report = await diagnoseProperty({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n js: booleanArg(args.js) ? true : 'auto',\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'diagnose',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, diagnoseCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { randomUUID } from 'node:crypto'\nimport {\n lstat,\n mkdir,\n mkdtemp,\n readdir,\n readFile,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises'\nimport {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} from 'node:path'\nimport {\n type OkfFile,\n type OkfValidationReport,\n SeoError,\n validateOkfFiles,\n} from '@seo/core'\n\nconst markerName = '.seo-okf.json'\nconst marker = `${JSON.stringify({ generator: 'seo', format: 'okf', version: 1 })}\\n`\n\nfunction safeFilePath(root: string, filePath: string): string {\n const path = resolve(root, filePath)\n const fromRoot = relative(resolve(root), path)\n if (!fromRoot || fromRoot.startsWith('..') || isAbsolute(fromRoot)) {\n throw new SeoError('INVALID_INPUT', `Unsafe OKF file path: ${filePath}`)\n }\n return path\n}\n\nasync function writeFiles(root: string, files: OkfFile[]): Promise<void> {\n for (const file of files) {\n const path = safeFilePath(root, file.path)\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, file.content)\n }\n await writeFile(join(root, markerName), marker)\n}\n\nexport async function readOkfMarkdownFiles(root: string): Promise<OkfFile[]> {\n const files: OkfFile[] = []\n async function walk(dir: string, prefix = ''): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true })\n for (const entry of entries) {\n const relative = prefix ? `${prefix}/${entry.name}` : entry.name\n const fullPath = join(dir, entry.name)\n if (entry.isDirectory()) {\n await walk(fullPath, relative)\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n files.push({\n path: relative,\n content: await readFile(fullPath, 'utf8'),\n })\n }\n }\n }\n await walk(root)\n return files.sort((left, right) =>\n left.path < right.path ? -1 : left.path > right.path ? 1 : 0,\n )\n}\n\nasync function assertReplaceable(path: string): Promise<boolean> {\n try {\n const stats = await lstat(path)\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new SeoError(\n 'INVALID_INPUT',\n `OKF output must be a real directory: ${path}`,\n )\n }\n const entries = await readdir(path)\n if (!entries.length) return true\n try {\n const value = await readFile(join(path, markerName), 'utf8')\n if (value === marker) return true\n } catch {\n // The directory is not managed by seo.\n }\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to replace non-empty unmanaged directory: ${path}`,\n )\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n}\n\nexport async function writeOkfDirectory(\n output: string,\n files: OkfFile[],\n): Promise<OkfValidationReport> {\n const validation = validateOkfFiles(files)\n if (!validation.valid) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Generated bundle did not pass seo OKF checks and was not written.',\n )\n }\n const target = resolve(output)\n const parent = dirname(target)\n await mkdir(parent, { recursive: true })\n const existed = await assertReplaceable(target)\n const staging = await mkdtemp(join(parent, `.${basename(target)}-staging-`))\n const backup = join(parent, `.${basename(target)}-backup-${randomUUID()}`)\n let movedExisting = false\n try {\n await writeFiles(staging, files)\n const diskValidation = validateOkfFiles(await readOkfMarkdownFiles(staging))\n if (!diskValidation.valid) {\n throw new SeoError(\n 'INTERNAL_ERROR',\n 'Staged OKF files failed validation after writing.',\n )\n }\n if (existed) {\n await rename(target, backup)\n movedExisting = true\n }\n await rename(staging, target)\n if (movedExisting) await rm(backup, { recursive: true, force: true })\n return diskValidation\n } catch (error) {\n await rm(staging, { recursive: true, force: true })\n if (movedExisting) {\n await rm(target, { recursive: true, force: true })\n await rename(backup, target)\n }\n throw error\n }\n}\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport {\n aiReadiness,\n auditLlmsTxt,\n buildOkfBundle,\n type CrawlReport,\n entityReadiness,\n okfConceptLimit,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../../args.js'\nimport { printJson, printKeyValue } from '../../utils.js'\nimport { writeOkfDirectory } from '../okf-files.js'\nimport { resolveSavedCrawlReport } from '../readiness.js'\n\ntype KnowledgeFormat = 'okf' | 'markdown' | 'json'\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n\nfunction formatArg(value: unknown): KnowledgeFormat {\n const format = stringArg(value) ?? 'okf'\n if (['okf', 'markdown', 'json'].includes(format)) {\n return format as KnowledgeFormat\n }\n throw new Error('Format must be one of: okf, markdown, json.')\n}\n\nexport function knowledgePayload(report: CrawlReport) {\n return {\n reportId: report.id,\n url: report.config.url,\n generatedAt: report.generatedAt,\n crawl: {\n summary: report.summary,\n caveats: report.caveats,\n warnings: report.warnings,\n pages: report.pages.map((page) => ({\n url: page.finalUrl,\n title: page.title,\n metaDescription: page.metaDescription,\n status: page.status,\n indexable: page.indexable,\n wordCount: page.wordCount,\n schemaTypes: page.schemaTypes,\n sameAs: page.schemaSameAs,\n internalInlinks: page.internalInlinkCount,\n contentSample: page.contentSample,\n })),\n },\n aiReadiness: aiReadiness(report),\n entityReadiness: entityReadiness(report),\n llmsTxt: auditLlmsTxt(report),\n }\n}\n\nfunction renderKnowledgeMarkdown(report: CrawlReport): string {\n const payload = knowledgePayload(report)\n const lines = [\n `# Site Knowledge Export`,\n '',\n `Source: ${report.config.url}`,\n `Crawl report: ${report.id}`,\n `Generated: ${payload.generatedAt}`,\n '',\n '## Summary',\n '',\n `- Documents: ${report.summary.totalPages}${report.requestEvidenceStatus === 'available' ? ` from ${report.requests.length} URL requests` : report.requestEvidenceStatus === 'partial' ? ` from ${report.requests.length} observed URL requests (request evidence is partial)` : ' (request evidence unavailable for this legacy report)'}`,\n `- Indexable pages: ${report.summary.indexablePages}`,\n `- Crawl findings: ${report.issues.length} (${report.summary.highIssues} high, ${report.summary.mediumIssues} medium, ${report.summary.lowIssues} low)`,\n `- AI-search evidence: ${payload.aiReadiness.dataStatus} (${payload.aiReadiness.assessment})`,\n `- Entity evidence: ${payload.entityReadiness.dataStatus} (${payload.entityReadiness.assessment})`,\n '',\n '## Top AI Readiness Actions',\n '',\n ...(payload.aiReadiness.topActions.length\n ? payload.aiReadiness.topActions.map(\n (action) => `- ${action.title}: ${action.action}`,\n )\n : ['- No AI-search technical actions in this crawl.']),\n '',\n '## Entity Signals',\n '',\n `- sameAs profiles: ${payload.entityReadiness.entities.sameAs.length}`,\n `- Social profiles: ${payload.entityReadiness.entities.socialProfiles.length}`,\n `- Authors: ${payload.entityReadiness.entities.authors.length}`,\n '',\n '## Important Pages',\n '',\n ...report.pages\n .filter((page) => page.indexable && page.status < 400)\n .slice(0, 100)\n .map(\n (page) =>\n `- [${page.title ?? page.finalUrl}](${page.finalUrl}) - ${page.metaDescription ?? page.contentSample ?? 'No summary available.'}`,\n ),\n '',\n '# Citations',\n '',\n `- [Crawl start URL](${report.config.url})`,\n '',\n ]\n return `${lines.join('\\n')}\\n`\n}\n\nexport const exportKnowledgeCommand = defineCommand({\n meta: {\n name: 'knowledge',\n description:\n 'Export site knowledge from a saved crawl as OKF, Markdown, or JSON',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to export.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n format: {\n type: 'string',\n description: 'Output format: okf, markdown, or json. Defaults to okf.',\n },\n output: {\n type: 'string',\n description:\n 'Output directory for OKF, or output file for Markdown/JSON.',\n },\n 'max-concepts': {\n type: 'string',\n description: 'Maximum OKF concept files. Defaults to 500.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print command metadata as JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const format = formatArg(args.format)\n const maxConcepts =\n format === 'okf'\n ? okfConceptLimit(\n strictNumberArg(args['max-concepts'], '--max-concepts'),\n )\n : undefined\n const report = await resolveSavedCrawlReport(args, { json })\n const output = stringArg(args.output)\n\n if (format === 'okf') {\n const bundle = buildOkfBundle(report, {\n maxConcepts,\n })\n const outDir = output ?? './okf'\n const validation = await writeOkfDirectory(outDir, bundle.files)\n if (json) {\n printJson({ format, output: outDir, bundle, validation })\n return\n }\n process.stdout.write(`Wrote OKF bundle to ${outDir}\\n\\n`)\n printKeyValue([\n ['Files', String(bundle.files.length)],\n ['Concepts', String(bundle.conceptCount)],\n ['Valid', validation.valid ? 'yes' : 'no'],\n ])\n return\n }\n\n if (format === 'json') {\n const content = `${JSON.stringify(knowledgePayload(report), null, 2)}\\n`\n await writeOrPrint(output, content)\n return\n }\n\n await writeOrPrint(output, renderKnowledgeMarkdown(report))\n },\n})\n","import { monthlyReport, narrativeCsvFiles } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { reportFetchOptions } from '../reports/args.js'\nimport {\n defaultOutDir,\n exportReportFetchArgs,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportMonthlyCommand = defineCommand({\n meta: {\n name: 'monthly',\n description:\n 'Export monthly report tables plus the underlying diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('monthly'),\n month: {\n type: 'string',\n description:\n 'Report month as YYYY-MM. Defaults to the latest month with final GSC data.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n ...exportReportFetchArgs,\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await monthlyReport({\n site: selection.site,\n month: stringArg(args.month),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'monthly',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, narrativeCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { narrativeCsvFiles, reportNarrative } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { reportFetchOptions } from '../reports/args.js'\nimport {\n defaultOutDir,\n exportReportFetchArgs,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportNarrativeCommand = defineCommand({\n meta: {\n name: 'narrative',\n description:\n 'Export report narrative tables plus the underlying diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('narrative'),\n ...cliReportArgs(['days', 'recentDays'], {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n }),\n 'start-date': {\n type: 'string',\n description: 'Optional report start date as YYYY-MM-DD.',\n },\n 'end-date': {\n type: 'string',\n description: 'Optional report end date as YYYY-MM-DD.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n 'change-limit': {\n type: 'string',\n description: 'Maximum saved changes to measure. Defaults to 5.',\n },\n ...exportReportFetchArgs,\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await reportNarrative({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: numberArg(args.limit),\n changeLimit: numberArg(args['change-limit']),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'narrative',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, narrativeCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { pseoAuditOptions } from '@seo/core'\nimport {\n booleanArg,\n csvArg,\n strictFetchRateArg,\n strictNumberArg,\n} from '../../args.js'\n\nexport function pseoOptions(args: Record<string, unknown>) {\n return pseoAuditOptions({\n days: strictNumberArg(args.days, '--days'),\n sitemaps: csvArg(args.sitemap),\n maxSitemapUrls: strictNumberArg(\n args['max-sitemap-urls'],\n '--max-sitemap-urls',\n ),\n templateLimit: strictNumberArg(args.limit, '--limit'),\n minimumTemplateUrls: strictNumberArg(\n args['minimum-template-urls'],\n '--minimum-template-urls',\n ),\n minimumTemplateShare: strictNumberArg(\n args['minimum-template-share'],\n '--minimum-template-share',\n ),\n minimumTemplateImpressions: strictNumberArg(\n args['minimum-template-impressions'],\n '--minimum-template-impressions',\n ),\n crawlSamples: strictNumberArg(args['crawl-samples'], '--crawl-samples'),\n inspectSamples: strictNumberArg(\n args['inspect-samples'],\n '--inspect-samples',\n ),\n brandTerms: csvArg(args['brand-terms']),\n includeBrand: booleanArg(args['include-brand']),\n js: booleanArg(args.js) ? true : ('auto' as const),\n refresh: booleanArg(args.refresh),\n rate: strictFetchRateArg(args),\n })\n}\n","import { pseoAuditReport, pseoCsvFiles } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { pseoOptions } from '../pseo/options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportPseoCommand = defineCommand({\n meta: {\n name: 'pseo',\n description:\n 'Export pSEO audit tables: templates, demand patterns, top queries, sample coverage, crawl samples, and inspection samples.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('pseo'),\n days: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pSEO templates to export.',\n },\n sitemap: {\n type: 'string',\n description: 'Comma-separated sitemap URLs. Can be passed once.',\n },\n 'crawl-samples': {\n type: 'string',\n description:\n 'Number of representative URLs to fetch per template. Defaults to 0.',\n },\n 'inspect-samples': {\n type: 'string',\n description:\n 'Number of representative URLs to inspect in GSC per template. Defaults to 0.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum discovered URLs per sitemap. Defaults to 50000.',\n },\n 'minimum-template-urls': {\n type: 'string',\n description:\n 'Minimum repeated URLs required for a template. Defaults to 3.',\n },\n 'minimum-template-share': {\n type: 'string',\n description:\n 'Minimum share of discovered URLs from 0 to 1. Defaults to 0.',\n },\n 'minimum-template-impressions': {\n type: 'string',\n description:\n 'Minimum retained page impressions for a template. Defaults to 0.',\n },\n 'brand-terms': {\n type: 'string',\n description:\n 'Comma-separated brand terms to exclude from query evidence.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in pSEO demand analysis.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for crawled samples.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n run: async ({ args }) => {\n const options = pseoOptions(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n })\n const report = await pseoAuditReport({\n site: selection.site,\n ...options,\n brandTerms: options.brandTerms ?? selection.client?.brandTerms,\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'pseo',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, pseoCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { refreshPrioritiesCsvFiles, refreshPrioritiesWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportRefreshPrioritiesCommand = defineCommand({\n meta: {\n name: 'refresh-priorities',\n description:\n 'Export the ranked SEO priority queue, score breakdowns, grouped findings, and diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('refresh-priorities'),\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum queue items to export. Defaults to 25.',\n },\n },\n ),\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID to use for analytics value. Defaults from the selected project.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Verify top opportunities against page title, meta, and content. Defaults to true.',\n 'Skip page content verification.',\n ),\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify. Defaults to 5.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await refreshPrioritiesWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection.client?.analytics.google?.propertyId,\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n refresh: booleanArg(args.refresh),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'refresh-priorities',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(\n outDir,\n refreshPrioritiesCsvFiles(report),\n )\n printWritten(outDir, written)\n },\n})\n","import { updatePostmortemCsvFiles, updatePostmortemWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportUpdatePostmortemCommand = defineCommand({\n meta: {\n name: 'update-postmortem',\n description:\n 'Export update postmortem attribution, findings, template movement, and segment movers.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('update-postmortem'),\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum winners/losers per segment. Defaults to 20.',\n },\n },\n ),\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await updatePostmortemWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'update-postmortem',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(\n outDir,\n updatePostmortemCsvFiles(report),\n )\n printWritten(outDir, written)\n },\n})\n","import { defineCommand } from 'citty'\nimport { exportDiagnoseCommand } from './diagnose.js'\nimport { exportKnowledgeCommand } from './knowledge.js'\nimport { exportMonthlyCommand } from './monthly.js'\nimport { exportNarrativeCommand } from './narrative.js'\nimport { exportPseoCommand } from './pseo.js'\nimport { exportRefreshPrioritiesCommand } from './refresh-priorities.js'\nimport { exportUpdatePostmortemCommand } from './update-postmortem.js'\n\nexport const exportCommand = defineCommand({\n meta: {\n name: 'export',\n description: 'Export full report data to CSV files',\n },\n subCommands: {\n diagnose: exportDiagnoseCommand,\n knowledge: exportKnowledgeCommand,\n narrative: exportNarrativeCommand,\n monthly: exportMonthlyCommand,\n 'update-postmortem': exportUpdatePostmortemCommand,\n 'refresh-priorities': exportRefreshPrioritiesCommand,\n pseo: exportPseoCommand,\n },\n})\n","import { mkdir, readFile, stat, unlink, writeFile } from 'node:fs/promises'\nimport { join, resolve } from 'node:path'\nimport {\n createIndexNowKeyRecord,\n listIndexNowKeys,\n removeIndexNowKey,\n resolveIndexNowKey,\n SeoError,\n saveIndexNowKey,\n submitIndexNow,\n verifyIndexNowKey,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, csvArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson, printKeyValue, printTable } from '../utils.js'\n\nconst MAX_URL_FILE_BYTES = 2_100_000\n\nconst projectArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Site URL.' },\n} as const\n\nasync function selectedSite(args: Record<string, unknown>): Promise<string> {\n const explicit = stringArg(args.site)\n if (explicit) return explicit\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n if (!project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site or select a saved project.',\n )\n }\n return project.siteUrl\n}\n\nasync function urlsFromArgs(args: Record<string, unknown>): Promise<string[]> {\n const single = stringArg(args.url)\n const inline = csvArg(args.urls) ?? []\n const file = stringArg(args.file)\n if (!single && inline.length === 0 && !file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --url, comma-separated --urls, or a newline-delimited --file.',\n )\n }\n const values = [...(single ? [single] : []), ...inline]\n if (file) {\n const info = await stat(file).catch(() => undefined)\n if (!info) {\n throw new SeoError(\n 'INVALID_INPUT',\n `IndexNow URL file not found: ${file}`,\n )\n }\n if (!info.isFile() || info.size > MAX_URL_FILE_BYTES) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'IndexNow URL files must be regular files no larger than 2.1 MB.',\n )\n }\n values.push(\n ...(await readFile(file, 'utf8'))\n .split(/\\r?\\n/)\n .map((value) => value.trim())\n .filter(Boolean),\n )\n }\n return values\n}\n\nconst setupCommand = defineCommand({\n meta: {\n name: 'setup',\n description: 'Generate an IndexNow key file for one site',\n },\n args: {\n ...projectArgs,\n output: {\n type: 'string',\n description: 'Public asset directory for the generated key file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const output = stringArg(args.output)\n if (!output) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --output with the public asset directory that deploys at the site root.',\n )\n }\n const record = createIndexNowKeyRecord({ site: await selectedSite(args) })\n const directory = resolve(output)\n const path = join(directory, `${record.key}.txt`)\n await mkdir(directory, { recursive: true })\n try {\n await writeFile(path, `${record.key}\\n`, {\n encoding: 'utf8',\n flag: 'wx',\n mode: 0o600,\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EEXIST') {\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to overwrite the existing file at ${path}.`,\n )\n }\n throw error\n }\n let credentialSource: Awaited<ReturnType<typeof saveIndexNowKey>>\n try {\n credentialSource = await saveIndexNowKey(record)\n } catch (error) {\n await unlink(path).catch(() => undefined)\n throw error\n }\n const result = {\n configured: true,\n host: record.host,\n keyLocation: record.keyLocation,\n keyFile: path,\n credentialSource,\n nextStep: `Deploy ${path}, then run seo indexnow verify --site ${new URL(record.keyLocation).origin}`,\n }\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Host', result.host],\n ['Key file', result.keyFile],\n ['Public URL', result.keyLocation],\n ['Saved in', result.credentialSource],\n ['Next', result.nextStep],\n ])\n },\n})\n\nconst statusCommand = defineCommand({\n meta: { name: 'status', description: 'Show saved IndexNow hosts' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const sites = await listIndexNowKeys()\n const result = { configuredSites: sites.length, sites }\n if (jsonFlag(args)) printJson(result)\n else\n printTable(\n ['Host', 'Key location', 'Created'],\n sites.map((site) => [site.host, site.keyLocation, site.createdAt]),\n )\n },\n})\n\nconst verifyCommand = defineCommand({\n meta: {\n name: 'verify',\n description: 'Check the public IndexNow key file',\n },\n args: {\n ...projectArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const resolved = await resolveIndexNowKey({\n site: await selectedSite(args),\n })\n const result = {\n ...(await verifyIndexNowKey({ record: resolved.record })),\n credentialSource: resolved.source,\n }\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Verified', result.verified ? 'yes' : 'no'],\n ['HTTP status', String(result.status)],\n ['Key location', result.keyLocation],\n ['Credential', result.credentialSource],\n ])\n if (!result.verified) process.exitCode = 4\n },\n})\n\nconst submitCommand = defineCommand({\n meta: {\n name: 'submit',\n description: 'Notify IndexNow about changed URLs',\n },\n args: {\n ...projectArgs,\n url: { type: 'string', description: 'One changed URL.' },\n urls: { type: 'string', description: 'Comma-separated changed URLs.' },\n file: {\n type: 'string',\n description: 'Newline-delimited changed URL file.',\n },\n 'dry-run': {\n type: 'boolean',\n default: false,\n description: 'Validate without notifying IndexNow.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const site = await selectedSite(args)\n const resolved = await resolveIndexNowKey({ site })\n const result = await submitIndexNow({\n record: resolved.record,\n urls: await urlsFromArgs(args),\n dryRun: booleanArg(args['dry-run']),\n })\n const output = { ...result, credentialSource: resolved.source }\n if (jsonFlag(args)) {\n printJson(output)\n return\n }\n printKeyValue([\n ['Host', result.host],\n ['Status', result.status],\n ['URLs', String(result.submittedUrls)],\n ['Dry run', result.dryRun ? 'yes' : 'no'],\n ['Key location', result.keyLocation],\n ])\n for (const caveat of result.caveats) process.stdout.write(`\\n${caveat}\\n`)\n },\n})\n\nconst removeCommand = defineCommand({\n meta: { name: 'remove', description: 'Remove a saved IndexNow key' },\n args: {\n ...projectArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const site = await selectedSite(args)\n const removed = await removeIndexNowKey(site)\n const result = {\n removed,\n note: 'The deployed key file was not removed.',\n }\n if (jsonFlag(args)) printJson(result)\n else\n process.stdout.write(\n `${removed ? 'Saved key removed.' : 'No saved key found.'} ${result.note}\\n`,\n )\n },\n})\n\nexport const indexNowCommand = defineCommand({\n meta: {\n name: 'indexnow',\n description: 'Set up and submit changed URLs with IndexNow',\n },\n subCommands: {\n setup: setupCommand,\n status: statusCommand,\n verify: verifyCommand,\n submit: submitCommand,\n remove: removeCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { startCommand } from './setup/index.js'\n\n/**\n * Kept for existing scripts. New users should start with `seo start`.\n *\n * Do not let this become a second onboarding flow. A person should see the\n * same calm Google, project-profile, and MCP setup whichever entry they use.\n */\nexport const initCommand = defineCommand({\n ...startCommand,\n meta: {\n name: 'init',\n description: 'Legacy alias for `seo start`.',\n },\n})\n","import {\n bingWebmasterSiteUrl,\n type CollectedLinkEvidence,\n collectBingLinkEvidence,\n importLinkEvidence,\n linkEvidenceReport,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, strictNumberArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nexport const linksCommand = defineCommand({\n meta: {\n name: 'links',\n description: 'Review bounded referring-link evidence from Bing or a file',\n },\n args: {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Verified Bing Webmaster site URL.' },\n file: {\n type: 'string',\n description: 'Local CSV, JSON, JSONL, or NDJSON link export.',\n },\n format: {\n type: 'string',\n description: 'Import format override: csv, json, or jsonl.',\n },\n 'row-limit': {\n type: 'string',\n description:\n 'Maximum imported or Bing link rows. Defaults to 500 for Bing and 10000 for files.',\n },\n 'target-limit': {\n type: 'string',\n description: 'Maximum Bing target pages to inspect. Defaults to 20.',\n },\n 'detail-pages': {\n type: 'string',\n description: 'Maximum Bing result pages per target. Defaults to 1.',\n },\n limit: {\n type: 'string',\n description: 'Maximum link rows returned. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const file = stringArg(args.file)\n const format = stringArg(args.format)\n if (format && !['csv', 'json', 'jsonl'].includes(format)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--format must be csv, json, or jsonl.',\n )\n }\n const rowLimit = strictNumberArg(args['row-limit'], '--row-limit')\n let evidence: CollectedLinkEvidence\n if (file) {\n evidence = await importLinkEvidence({\n file,\n format: format as 'csv' | 'json' | 'jsonl' | undefined,\n rowLimit,\n })\n } else {\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = stringArg(args.site) ?? bingWebmasterSiteUrl(project)\n if (!site) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site, connect Bing to a saved project, or import a link file with --file.',\n )\n }\n evidence = await collectBingLinkEvidence({\n site,\n rowLimit,\n targetLimit: strictNumberArg(args['target-limit'], '--target-limit'),\n detailPagesPerTarget: strictNumberArg(\n args['detail-pages'],\n '--detail-pages',\n ),\n })\n }\n const report = linkEvidenceReport({\n evidence,\n limit: strictNumberArg(args.limit, '--limit'),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Inbound link evidence',\n target: report.provenance.provider,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: `${formatCount(report.summary.observedLinks)} observed links from ${formatCount(report.summary.referringDomains)} referring domains.`,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Observed links',\n value: formatCount(report.summary.observedLinks),\n },\n {\n label: 'Referring domains',\n value: formatCount(report.summary.referringDomains),\n },\n {\n label: 'Target pages',\n value: formatCount(report.summary.targetPages),\n },\n {\n label: 'Returned rows',\n value: `${formatCount(report.selection.returnedRows)} of ${formatCount(report.selection.availableRows)}`,\n },\n ],\n })\n if (report.links.length) {\n printLimitedTable(\n ['Source', 'Target', 'Anchor'],\n report.links.map((link) => [\n truncate(link.sourceUrl, 58),\n truncate(link.targetUrl, 58),\n truncate(link.anchorText ?? '', 36),\n ]),\n )\n }\n printNotes('Warnings', report.warnings)\n printNotes('Report caveats', report.caveats)\n },\n})\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { auditLlmsTxt, generateLlmsTxt } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { csvArg, jsonFlag, numberArg, stringArg } from '../args.js'\nimport { printJson, printKeyValue } from '../utils.js'\nimport { printNotes, printReportSummary } from './output.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n\nconst sharedArgs = {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to use.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n} as const\n\nexport const llmsAuditCommand = defineCommand({\n meta: {\n name: 'audit',\n description: 'Inspect optional llms.txt presence from a saved crawl',\n },\n args: sharedArgs,\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const audit = auditLlmsTxt(report)\n if (json) {\n printJson(audit)\n return\n }\n\n printReportSummary({\n title: 'llms.txt audit',\n target: audit.url,\n status: audit.issues.length > 0 ? 'warning' : 'pass',\n summary: audit.headline,\n metrics: [\n { label: 'SEO impact', value: audit.googleSearchImpact },\n { label: 'Optional', value: audit.optional ? 'Yes' : 'No' },\n { label: 'Found', value: audit.exists ? 'Yes' : 'No' },\n { label: 'URL', value: audit.llmsTxtUrl },\n {\n label: 'HTTP status',\n value: audit.status ? String(audit.status) : 'Unavailable',\n },\n ],\n diagnostics: [\n {\n title: 'Issues',\n items: audit.issues.map((issue) => ({\n status: issue.severity === 'high' ? 'fail' : 'warning',\n title: issue.title,\n explanation: issue.plainEnglish,\n fix: issue.action,\n })),\n },\n ],\n })\n printNotes(\n 'Recommended pages',\n audit.recommendedPages\n .slice(0, 10)\n .map((page) => `${page.section}: ${page.url}`),\n )\n },\n})\n\nexport const llmsGenerateCommand = defineCommand({\n meta: {\n name: 'generate',\n description: 'Generate an llms.txt draft from a saved crawl',\n },\n args: {\n ...sharedArgs,\n output: {\n type: 'string',\n description: 'Write llms.txt to this path instead of stdout.',\n },\n 'max-urls': {\n type: 'string',\n description: 'Maximum URLs to include. Defaults to 250.',\n },\n 'token-budget': {\n type: 'string',\n description: 'Approximate token budget. Defaults to 12000.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n title: {\n type: 'string',\n description: 'Override the llms.txt title.',\n },\n description: {\n type: 'string',\n description: 'Override the llms.txt description.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const generated = generateLlmsTxt(report, {\n maxUrls: numberArg(args['max-urls']),\n tokenBudget: numberArg(args['token-budget']),\n exclude: csvArg(args.exclude),\n title: stringArg(args.title),\n description: stringArg(args.description),\n })\n\n if (json) {\n printJson(generated)\n return\n }\n await writeOrPrint(stringArg(args.output), generated.content)\n if (stringArg(args.output)) {\n printKeyValue([\n ['URLs', String(generated.includedUrls)],\n ['Estimated tokens', String(generated.estimatedTokens)],\n ])\n }\n },\n})\n\nexport const llmsCommand = defineCommand({\n meta: {\n name: 'llms',\n description: 'Inspect or generate optional llms.txt from saved crawl data',\n },\n subCommands: {\n audit: llmsAuditCommand,\n generate: llmsGenerateCommand,\n },\n})\n","import { pruneLogs } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { formatBytes, printJson } from '../utils.js'\n\nexport const logsCommand = defineCommand({\n meta: { name: 'logs', description: 'Manage local log retention' },\n subCommands: {\n prune: defineCommand({\n meta: {\n name: 'prune',\n description: 'Rotate large logs and remove old local logs',\n },\n args: {\n quiet: {\n type: 'boolean',\n default: false,\n description: 'Do not print a result.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const result = pruneLogs()\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n if (!args.quiet) {\n process.stdout.write(\n `Rotated ${result.rotated} and removed ${result.removed} log files. ${formatBytes(result.sizeBytes)} retained.\\n`,\n )\n }\n },\n }),\n },\n})\n","import { multiselect } from '@clack/prompts'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag } from '../args.js'\nimport { canPrompt, maybeExitCancelled, printJson } from '../utils.js'\nimport {\n detectMcpClients,\n mcpClientTargets,\n type SupportedClient,\n} from './mcp-clients.js'\nimport { installMcpConfig, uninstallMcpConfig } from './mcp-config.js'\n\nconst targetFlags: Array<{\n client: SupportedClient\n flag: 'claude-desktop' | 'claude-code' | 'codex' | 'cursor'\n}> = [\n {\n client: 'claude-desktop',\n flag: 'claude-desktop',\n },\n { client: 'claude-code', flag: 'claude-code' },\n { client: 'codex', flag: 'codex' },\n { client: 'cursor', flag: 'cursor' },\n]\n\nfunction selectedClients(\n args: Record<string, unknown>,\n available: SupportedClient[],\n): SupportedClient[] {\n if (booleanArg(args.all)) return available\n return targetFlags\n .filter(({ flag }) => booleanArg(args[flag]))\n .map(({ client }) => client)\n}\n\nexport const mcpCommand = defineCommand({\n meta: { name: 'mcp', description: 'MCP server helpers' },\n subCommands: {\n serve: defineCommand({\n meta: {\n name: 'serve',\n description: 'Run the SEO MCP server',\n },\n args: {\n test: {\n type: 'boolean',\n default: false,\n description: 'Start in test mode',\n },\n },\n run: async ({ args }) => {\n const { startMcpServer } = await import('@seo/mcp')\n await startMcpServer({ test: booleanArg(args.test) })\n },\n }),\n install: defineCommand({\n meta: {\n name: 'install',\n description: 'Install or remove SEO MCP config for local clients',\n },\n args: {\n uninstall: {\n type: 'boolean',\n default: false,\n description: 'Remove the SEO MCP config instead of adding it',\n },\n reinstall: {\n type: 'boolean',\n default: false,\n description: 'Rewrite an existing managed SEO MCP config',\n },\n 'claude-desktop': {\n type: 'boolean',\n default: false,\n description: 'Update Claude Desktop',\n },\n 'claude-code': {\n type: 'boolean',\n default: false,\n description: 'Update Claude Code',\n },\n codex: {\n type: 'boolean',\n default: false,\n description: 'Update Codex CLI, app, and IDE extension',\n },\n cursor: {\n type: 'boolean',\n default: false,\n description: 'Update Cursor',\n },\n all: {\n type: 'boolean',\n default: false,\n description: 'Update every detected MCP client',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print structured JSON output',\n },\n },\n run: async ({ args }) => {\n if (booleanArg(args.uninstall) && booleanArg(args.reinstall)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --uninstall or --reinstall, not both.',\n )\n }\n const targets = mcpClientTargets()\n const detected = detectMcpClients({ targets })\n const json = jsonFlag(args)\n let selected = selectedClients(\n args,\n detected.map((target) => target.client),\n )\n\n if (selected.length === 0) {\n if (!canPrompt({ json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Choose an MCP client with --claude-desktop, --claude-code, --codex, --cursor, or --all.',\n )\n }\n const choices = detected.length > 0 ? detected : targets\n selected = maybeExitCancelled(\n await multiselect({\n message: args.uninstall\n ? 'Remove seo from which MCP clients?'\n : 'Install seo into which MCP clients?',\n options: choices.map((target) => ({\n value: target.client,\n label: target.label,\n hint: target.path,\n })),\n initialValues: detected.map((target) => target.client),\n required: true,\n }),\n )\n }\n\n const unavailable = selected.filter(\n (client) => !targets.some((target) => target.client === client),\n )\n if (unavailable.length > 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `MCP setup is not supported for ${unavailable.join(', ')} on ${process.platform}.`,\n )\n }\n\n const results = targets\n .filter((entry) => selected.includes(entry.client))\n .map((target) =>\n booleanArg(args.uninstall)\n ? uninstallMcpConfig(target)\n : installMcpConfig(target, {\n reinstall: booleanArg(args.reinstall),\n }),\n )\n\n if (json) {\n printJson({\n operation: booleanArg(args.uninstall) ? 'uninstall' : 'install',\n results,\n })\n return\n }\n\n for (const result of results) {\n process.stdout.write(\n `${result.changed ? 'updated' : 'skipped'} ${result.client} · ${result.path}\\n`,\n )\n }\n },\n }),\n },\n})\n","import { crawlDiff } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails, printReportSummary, truncate } from '../output.js'\n\nexport const crawlDiffCommand = defineCommand({\n meta: {\n name: 'crawl-diff',\n description: 'Crawl a site and diff technical/page changes vs last run',\n },\n args: {\n url: {\n type: 'string',\n required: true,\n description: 'Start URL to crawl.',\n },\n site: {\n type: 'string',\n description: 'Optional GSC property to associate with the crawl.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n },\n run: async ({ args }) => {\n const report = await crawlDiff({\n startUrl: stringArg(args.url) ?? '',\n site: stringArg(args.site),\n limit: numberArg(args.limit),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Crawl history comparison',\n target: report.run.startUrl,\n status:\n report.previousRun === undefined\n ? 'unknown'\n : report.summary.newErrors > 0 || report.summary.indexabilityFlips > 0\n ? 'warning'\n : 'pass',\n summary:\n report.previousRun === undefined\n ? 'No previous crawl was available for comparison.'\n : `${report.summary.changed} changed, ${report.summary.added} added, and ${report.summary.removed} removed URLs.`,\n metrics: [\n { label: 'Run', value: report.run.id },\n { label: 'Crawled', value: report.summary.crawled },\n { label: 'Previous run', value: report.previousRun?.id ?? 'None' },\n { label: 'Added', value: report.summary.added },\n { label: 'Removed', value: report.summary.removed },\n { label: 'Changed', value: report.summary.changed },\n { label: 'New errors', value: report.summary.newErrors },\n {\n label: 'Indexability flips',\n value: report.summary.indexabilityFlips,\n },\n {\n label: 'High priority',\n value: report.summary.highPriorityRecommendations,\n },\n ],\n })\n if (report.recommendations.length) {\n process.stdout.write('\\nRecommended actions\\n')\n printTable(\n ['Severity', 'Category', 'URL', 'Action'],\n report.recommendations\n .slice(0, 10)\n .map((item) => [\n item.severity,\n item.category,\n truncate(item.url, 56),\n truncate(item.action, 72),\n ]),\n )\n printActionDetails(\n 'Top crawl actions',\n report.recommendations.map((item) => ({\n label: item.category,\n context: `${item.severity}, ${truncate(item.url, 96)}`,\n action: item.action,\n })),\n )\n }\n if (report.items.length) {\n process.stdout.write('\\nChanged URLs\\n')\n printTable(\n ['Kind', 'URL', 'Changes', 'Recommendation'],\n report.items\n .slice(0, 50)\n .map((item) => [\n item.kind,\n truncate(item.url, 56),\n item.changes.join(', '),\n item.recommendation?.title ?? '-',\n ]),\n )\n }\n if (report.warnings.length) {\n process.stdout.write('\\nWarnings\\n')\n for (const warning of report.warnings.slice(0, 10)) {\n process.stdout.write(`- ${warning}\\n`)\n }\n }\n },\n})\n","import { defaultTrueBooleanArg } from '../../args.js'\n\nexport function monitoringRunArgs() {\n return {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Defaults from the project or GSC property.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect with URL Inspection.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs for quota-aware index monitoring.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties for sitemap index monitoring.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to inspect in this run. Defaults to 100.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for monitoring. Defaults to 50000.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n 'recover-links': defaultTrueBooleanArg(\n 'Check search-value GSC pages for broken, blocked, or poorly redirected URLs.',\n 'Skip link recovery checks.',\n ),\n 'recover-days': {\n type: 'string',\n description: 'GSC lookback window for link recovery. Defaults to 90.',\n },\n 'recover-limit': {\n type: 'string',\n description:\n 'Maximum search-value pages to check for link recovery. Defaults to 10.',\n },\n 'recover-min-clicks': {\n type: 'string',\n description:\n 'Minimum clicks for link recovery candidates. Defaults to 1.',\n },\n 'recover-min-impressions': {\n type: 'string',\n description:\n 'Minimum impressions for link recovery candidates. Defaults to 100.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP/GSC cache where supported.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n } as const\n}\n\nexport function monitoringStatusArgs() {\n return {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'stale-days': {\n type: 'string',\n description: 'Mark checks stale after this many days. Defaults to 8.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Refresh property selection data when prompting.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n } as const\n}\n","import { printSemanticReport } from '../../utils.js'\n\nfunction stepStatus(\n value: string,\n): 'pass' | 'warning' | 'fail' | 'unknown' | 'info' {\n const status = value.toLowerCase()\n if (['pass', 'passed', 'complete', 'completed', 'joined'].includes(status)) {\n return 'pass'\n }\n if (['warn', 'warning', 'partial', 'review'].includes(status)) {\n return 'warning'\n }\n if (['fail', 'failed', 'error'].includes(status)) return 'fail'\n if (['unknown', 'unavailable'].includes(status)) return 'unknown'\n return 'info'\n}\n\nexport function printWorkflow(report: {\n workflow: string\n site: string\n summary: string\n steps: Array<{ tool: string; status: string; summary: string }>\n actions: Array<{ title: string; confidence: string; action: string }>\n}): void {\n const statuses = report.steps.map((step) => stepStatus(step.status))\n const status = statuses.includes('fail')\n ? 'fail'\n : statuses.includes('warning')\n ? 'warning'\n : statuses.includes('unknown')\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: report.workflow,\n target: report.site,\n status,\n summary: report.summary,\n metrics: [\n {\n label: 'Completed',\n value: statuses.filter((value) => value === 'pass').length,\n status: 'pass',\n },\n {\n label: 'Review',\n value: statuses.filter((value) => value === 'warning').length,\n status: 'warning',\n },\n {\n label: 'Unknown',\n value: statuses.filter((value) => value === 'unknown').length,\n status: 'unknown',\n },\n ],\n sections: [\n {\n title: 'Evidence collection',\n diagnostics: report.steps.map((step) => ({\n status: stepStatus(step.status),\n title: step.tool,\n explanation: step.summary,\n evidence: [`Status: ${step.status}`],\n })),\n },\n {\n title: 'Priority actions',\n diagnostics: report.actions.map((action) => ({\n status: 'warning' as const,\n title: action.title,\n explanation: `Confidence: ${action.confidence}.`,\n fix: action.action,\n })),\n },\n ],\n })\n}\n","import type { MonitoringStatusReport, technicalWatchWorkflow } from '@seo/core'\nimport { printTable } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { printWorkflow } from '../workflows/output.js'\n\ntype TechnicalWatchReport = Awaited<ReturnType<typeof technicalWatchWorkflow>>\n\nexport function printMonitoringRun(report: TechnicalWatchReport): void {\n printWorkflow(report)\n\n if (report.output.crawl?.recommendations.length) {\n process.stdout.write('\\nCrawl actions\\n')\n printTable(\n ['Severity', 'URL', 'Action'],\n report.output.crawl.recommendations\n .slice(0, 10)\n .map((item) => [\n item.severity,\n truncate(item.url, 56),\n truncate(item.action, 72),\n ]),\n )\n printActionDetails(\n 'Top crawl actions',\n report.output.crawl.recommendations.map((item) => ({\n label: item.severity,\n context: truncate(item.url, 96),\n action: item.action,\n })),\n )\n }\n\n if (report.output.index?.items.length) {\n const items = report.output.index.items\n .filter(\n (item) =>\n item.currentIssue ||\n item.changed ||\n item.inspectionStatus !== 'succeeded',\n )\n .slice(0, 25)\n if (items.length) {\n process.stdout.write('\\nIndex reviews, changes, and failed checks\\n')\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n items.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n truncate(\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n 40,\n ),\n truncate(item.url, 64),\n ]),\n )\n }\n }\n\n if (report.output.recovery?.items.length) {\n process.stdout.write('\\nRecoverable URLs\\n')\n printTable(\n ['Severity', 'Issue', 'Clicks', 'Impr', 'URL', 'Action'],\n report.output.recovery.items\n .slice(0, 10)\n .map((item) => [\n item.severity,\n item.issue,\n formatCount(item.clicks),\n formatCount(item.impressions),\n truncate(item.url, 56),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top recovery actions',\n report.output.recovery.items.map((item) => ({\n label: truncate(item.url, 96),\n context: `${item.severity}, ${formatCount(item.clicks)} clicks at risk`,\n action: item.recommendation.action,\n })),\n )\n }\n}\n\nexport function printMonitoringStatus(report: MonitoringStatusReport): void {\n printReportSummary({\n title: 'Technical monitoring status',\n target: report.site,\n status:\n report.health === 'clear'\n ? 'pass'\n : report.health === 'attention'\n ? 'warning'\n : 'unknown',\n summary:\n report.summary.attention > 0\n ? `${report.summary.attention} checks need attention.`\n : report.summary.stale > 0 || report.summary.notRun > 0\n ? `${report.summary.stale} checks are stale and ${report.summary.notRun} have not run.`\n : 'No monitoring checks currently need attention.',\n metrics: [\n { label: 'Health', value: report.health },\n { label: 'Attention', value: report.summary.attention },\n { label: 'Stale', value: report.summary.stale },\n { label: 'Not run', value: report.summary.notRun },\n ],\n })\n\n printTable(\n ['Check', 'Status', 'Last run', 'Summary'],\n report.checks.map((check) => [\n check.name,\n check.status,\n check.lastRunAt ?? '-',\n check.summary,\n ]),\n )\n\n const actions = report.checks.filter((check) => check.action)\n if (actions.length) {\n process.stdout.write('\\nNext actions\\n')\n printTable(\n ['Check', 'Action'],\n actions.map((check) => [check.name, truncate(check.action ?? '', 96)]),\n )\n printActionDetails(\n 'Next action details',\n actions.map((check) => ({\n label: check.name,\n action: check.action ?? '',\n })),\n )\n }\n}\n","import { monitoringStatus, technicalWatchWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printKeyValue } from '../../utils.js'\nimport { startUrlForSite } from '../shared.js'\nimport { monitoringRunArgs, monitoringStatusArgs } from './args.js'\nimport { printMonitoringRun, printMonitoringStatus } from './output.js'\n\nfunction quotedFlag(name: string, value: unknown): string | undefined {\n const text = stringArg(value)\n return text ? `--${name} ${JSON.stringify(text)}` : undefined\n}\n\nfunction booleanFlag(name: string, value: unknown): string | undefined {\n return booleanArg(value) ? `--${name}` : undefined\n}\n\nfunction recoverLinksFlag(value: unknown): string | undefined {\n return booleanArg(value) === false ? '--recover-links=false' : undefined\n}\n\nexport const monitoringCommand = defineCommand({\n meta: {\n name: 'monitoring',\n description: 'Run and review recurring technical SEO monitoring',\n },\n subCommands: {\n run: defineCommand({\n meta: {\n name: 'run',\n description:\n 'Run crawl, index, and link recovery monitoring for a property',\n },\n args: monitoringRunArgs(),\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const urls = listArg(args.urls)\n const sitemaps = listArg(args.sitemaps)\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const report = await technicalWatchWorkflow({\n site: selection.site,\n startUrl,\n urls: urls.length ? urls : selection.client?.watchUrls,\n sitemaps: sitemaps.length ? sitemaps : undefined,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n limit: numberArg(args.limit),\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n recoverLinks: booleanArg(args['recover-links']),\n recoverDays: numberArg(args['recover-days']),\n recoverLimit: numberArg(args['recover-limit']),\n recoverMinClicks: numberArg(args['recover-min-clicks']),\n recoverMinImpressions: numberArg(args['recover-min-impressions']),\n })\n\n if (json) {\n printJson(report)\n return\n }\n printMonitoringRun(report)\n },\n }),\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show the latest saved monitoring state for a property',\n },\n args: monitoringStatusArgs(),\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = monitoringStatus({\n site: selection.site,\n staleAfterDays: numberArg(args['stale-days']),\n })\n if (json) {\n printJson(report)\n return\n }\n printMonitoringStatus(report)\n },\n }),\n cron: defineCommand({\n meta: {\n name: 'cron',\n description: 'Print a local cron line for recurring monitoring',\n },\n args: {\n ...monitoringRunArgs(),\n hour: {\n type: 'string',\n default: '9',\n description: 'Hour in local cron time. Defaults to 9.',\n },\n minute: {\n type: 'string',\n default: '0',\n description: 'Minute in local cron time. Defaults to 0.',\n },\n weekday: {\n type: 'string',\n description:\n 'Weekly monitoring day. Defaults to client setting, then Monday.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const hour = numberArg(args.hour) ?? 9\n const minute = numberArg(args.minute) ?? 0\n const weekday =\n numberArg(args.weekday) ?? selection.client?.technicalWeekday ?? 1\n const identityArg = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n const command = [\n 'seo monitoring run',\n identityArg,\n quotedFlag('url', args.url),\n quotedFlag('urls', args.urls),\n quotedFlag('sitemaps', args.sitemaps),\n quotedFlag('properties', args.properties),\n quotedFlag('limit', args.limit),\n quotedFlag('daily-limit', args['daily-limit']),\n quotedFlag('inspect-limit', args['inspect-limit']),\n quotedFlag('max-urls', args['max-urls']),\n quotedFlag('language', args.language),\n quotedFlag('recover-days', args['recover-days']),\n quotedFlag('recover-limit', args['recover-limit']),\n quotedFlag('recover-min-clicks', args['recover-min-clicks']),\n quotedFlag(\n 'recover-min-impressions',\n args['recover-min-impressions'],\n ),\n recoverLinksFlag(args['recover-links']),\n booleanFlag('refresh', args.refresh),\n booleanFlag('js', args.js),\n '--json',\n ]\n .filter(Boolean)\n .join(' ')\n const line = {\n name: 'monitoring',\n cron: `${minute} ${hour} * * ${weekday}`,\n command,\n }\n\n if (json) {\n printJson({ site: selection.site, line })\n return\n }\n printKeyValue([\n ['Property', selection.site],\n ['Install', 'crontab -e'],\n ])\n process.stdout.write(`${line.cron} ${line.command}\\n`)\n },\n }),\n },\n})\n","import { indexCoverageSignals } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary, truncate } from '../output.js'\n\nexport const indexCoverageCommand = defineCommand({\n meta: {\n name: 'index-coverage',\n description:\n 'Find crawlable pages that deserve a closer Google index check',\n },\n args: {\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n 'crawl-report-id': {\n type: 'string',\n description:\n 'Saved crawl report id. Defaults to the latest for the site.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs. Defaults to declarations captured by the crawl.',\n },\n days: {\n type: 'string',\n description: 'Finalized Search Console date range. Defaults to 90 days.',\n },\n 'row-limit': {\n type: 'string',\n description: 'Maximum Search Console page rows. Defaults to 100000.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum sitemap inventory URLs. Defaults to 100000.',\n },\n limit: {\n type: 'string',\n description:\n 'Maximum URLs returned in each evidence group. Defaults to 100.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local Search Console cache.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const sitemapValues = listArg(args.sitemaps)\n const report = await indexCoverageSignals({\n site: selection.site,\n crawlReportId: stringArg(args['crawl-report-id']),\n sitemaps: sitemapValues.length ? sitemapValues : undefined,\n days: numberArg(args.days),\n rowLimit: numberArg(args['row-limit']),\n maxSitemapUrls: numberArg(args['max-sitemap-urls']),\n itemsPerSection: numberArg(args.limit),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Index coverage',\n target: report.site,\n status:\n report.sources.crawl.completeness === 'complete' &&\n report.sources.searchConsole.completeness === 'complete'\n ? report.summary.crawlableCandidatesWithoutRetainedSearchVisibility >\n 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary: `${report.summary.crawlableCandidatesWithoutRetainedSearchVisibility} crawlable pages need URL Inspection review.`,\n metrics: [\n { label: 'Crawl report', value: report.input.crawlReport.id },\n { label: 'Crawl evidence', value: report.sources.crawl.completeness },\n {\n label: 'Sitemap evidence',\n value: report.sources.sitemap.completeness,\n },\n {\n label: 'Search evidence',\n value: report.sources.searchConsole.completeness,\n },\n {\n label: 'Search window',\n value: `${report.sources.searchConsole.startDate} to ${report.sources.searchConsole.endDate}`,\n },\n {\n label: 'Search-visible pages',\n value: report.summary.retainedSearchVisibleUrls,\n },\n {\n label: 'Blocked/non-indexable',\n value: report.summary.blockedOrNonIndexableCrawlUrls,\n },\n { label: 'Sitemap only', value: report.summary.sitemapOnlyUrls },\n {\n label: 'Search Console only',\n value: report.summary.searchConsoleOnlyUrls,\n },\n ],\n })\n\n if (report.crawlableWithoutRetainedSearchVisibility.items.length) {\n process.stdout.write('\\nRepresentative URL Inspection candidates\\n')\n printTable(\n ['URL', 'Status', 'In sitemap'],\n report.crawlableWithoutRetainedSearchVisibility.items.map((item) => [\n truncate(item.url, 80),\n item.status,\n item.inSitemap ? 'yes' : 'no',\n ]),\n )\n }\n\n printNotes('How to read this report', report.caveats)\n },\n})\n","import {\n countLabel,\n indexCoveragePlan,\n indexMonitor,\n indexWatch,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\n\nexport const indexWatchCommand = defineCommand({\n meta: {\n name: 'index-watch',\n description: 'Inspect URLs with GSC and alert on index status changes',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs to plan quota-aware monitoring.',\n },\n plan: {\n type: 'boolean',\n default: false,\n description:\n 'Plan sitemap URL allocation across GSC properties without inspecting URLs.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties to use for planning. Defaults to account properties.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'target-days': {\n type: 'string',\n description:\n 'Target number of days to inspect all monitored URLs. Defaults to 1.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for planning. Defaults to 50000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum URLs to inspect in this run from sitemap mode. Defaults to 100.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const urls = listArg(args.urls)\n const site = await resolveSite({\n site: stringArg(args.site),\n options: { json },\n })\n\n const sitemaps = listArg(args.sitemaps)\n\n if (booleanArg(args.plan)) {\n if (!sitemaps.length) {\n throw new Error('Pass at least one sitemap with --sitemaps.')\n }\n const report = await indexCoveragePlan({\n site,\n sitemaps,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n dailyLimit: numberArg(args['daily-limit']),\n targetCycleDays: numberArg(args['target-days']),\n maxUrls: numberArg(args['max-urls']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index monitoring plan',\n target: report.site,\n status: report.warnings.length > 0 ? 'warning' : 'info',\n summary: `${report.summary.urlCount} sitemap URLs can be checked in an estimated ${countLabel(report.summary.estimatedCycleDays, 'day')}.`,\n metrics: [\n { label: 'Sitemap URLs', value: report.summary.urlCount },\n { label: 'Properties', value: report.summary.properties },\n { label: 'Daily capacity', value: report.summary.dailyCapacity },\n {\n label: 'Target cycle',\n value: countLabel(report.summary.targetCycleDays, 'day'),\n },\n {\n label: 'Suggested properties',\n value: report.summary.suggestedProperties,\n },\n ],\n })\n if (report.properties.length) {\n printTable(\n ['Property', 'URLs', 'Cycle', 'Sample URL'],\n report.properties.map((property) => [\n property.property,\n property.urlCount,\n countLabel(property.cycleDays, 'day'),\n property.sampleUrls[0] ?? '-',\n ]),\n )\n }\n if (report.suggestions.length) {\n process.stdout.write('\\nSuggested URL-prefix properties\\n')\n printTable(\n ['Property', 'URLs', 'Current property', 'Cycle', 'Reason'],\n report.suggestions.map((suggestion) => [\n suggestion.property,\n suggestion.urlCount,\n suggestion.currentProperty,\n countLabel(suggestion.estimatedCycleDays, 'day'),\n suggestion.reason,\n ]),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n return\n }\n\n if (sitemaps.length) {\n const report = await indexMonitor({\n site,\n sitemaps,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n languageCode: stringArg(args.language),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index monitoring run',\n target: report.site,\n status:\n report.summary.failed > 0 || report.summary.quotaBlocked > 0\n ? 'unknown'\n : report.summary.alerts > 0 || report.summary.regressions > 0\n ? 'warning'\n : report.summary.attempted > 0\n ? 'pass'\n : 'info',\n summary: `${report.summary.inspected} URLs inspected, with ${report.summary.alerts} new alerts and ${report.summary.regressions} regressions.`,\n metrics: [\n { label: 'Inventory URLs', value: report.summary.inventoryUrls },\n { label: 'Selected', value: report.summary.selected },\n { label: 'Inspected', value: report.summary.inspected },\n { label: 'Failed', value: report.summary.failed },\n { label: 'Quota blocked', value: report.summary.quotaBlocked },\n { label: 'Current reviews', value: report.summary.currentIssues },\n { label: 'Regressions', value: report.summary.regressions },\n { label: 'Recoveries', value: report.summary.recoveries },\n { label: 'New alerts', value: report.summary.alerts },\n ],\n })\n if (report.properties.length) {\n printTable(\n [\n 'Property',\n 'Inventory',\n 'Selected',\n 'Inspected',\n 'Failed',\n 'Current',\n 'Alerts',\n ],\n report.properties.map((property) => [\n property.property,\n property.inventoryUrls,\n property.selectedUrls,\n property.inspected,\n property.failed + property.quotaBlocked,\n property.currentIssues,\n property.alerts,\n ]),\n )\n }\n const issueItems = report.items\n .filter(\n (item) =>\n item.currentIssue ||\n item.changed ||\n item.inspectionStatus !== 'succeeded',\n )\n .slice(0, 50)\n if (issueItems.length) {\n process.stdout.write('\\nIndex reviews, changes, and failed checks\\n')\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n issueItems.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n item.url,\n ]),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n return\n }\n\n if (!urls.length) throw new Error('Pass at least one URL with --urls.')\n\n const report = await indexWatch({\n site,\n urls,\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index watch',\n target: report.site,\n status:\n report.summary.failed > 0 || report.summary.quotaBlocked > 0\n ? 'unknown'\n : report.summary.alerts > 0 || report.summary.regressions > 0\n ? 'warning'\n : report.summary.attempted > 0\n ? 'pass'\n : 'info',\n summary: `${report.summary.inspected} URLs inspected, with ${report.summary.alerts} new alerts.`,\n metrics: [\n { label: 'Property', value: report.source.property },\n { label: 'Attempted', value: report.summary.attempted },\n { label: 'Inspected', value: report.summary.inspected },\n { label: 'Failed', value: report.summary.failed },\n { label: 'Quota blocked', value: report.summary.quotaBlocked },\n { label: 'Current reviews', value: report.summary.currentIssues },\n { label: 'Regressions', value: report.summary.regressions },\n { label: 'Recoveries', value: report.summary.recoveries },\n { label: 'New alerts', value: report.summary.alerts },\n ],\n })\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n report.items.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n item.url,\n ]),\n )\n },\n})\n","import { linkRecover } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { selectedSiteOrThrow } from '../shared.js'\n\nexport const linkRecoverCommand = defineCommand({\n meta: {\n name: 'link-recover',\n description:\n 'Find search-value URLs that are now broken, blocked, or poorly redirected',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'minImpressions', 'refresh', 'js'], {\n days: {\n description: 'GSC lookback window. Defaults to 90.',\n },\n limit: {\n description: 'Maximum GSC pages to check. Defaults to 50.',\n },\n minImpressions: {\n description: 'Minimum impressions to check a page. Defaults to 100.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP caches.',\n },\n js: {\n description: 'Force JavaScript rendering for final page extraction.',\n },\n }),\n 'min-clicks': {\n type: 'string',\n description: 'Minimum clicks to check a page. Defaults to 1.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await linkRecover({\n site: await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n { json },\n ),\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minClicks: numberArg(args['min-clicks']),\n minImpressions: numberArg(args['min-impressions']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Link recovery',\n target: report.site,\n status:\n report.warnings.length > 0\n ? 'unknown'\n : report.summary.recoverable > 0\n ? 'warning'\n : 'pass',\n summary:\n report.summary.recoverable > 0\n ? `${formatCount(report.summary.recoverable)} previously visible URLs need recovery review.`\n : 'No recoverable URLs were found in the retained evidence.',\n metrics: [\n {\n label: 'Range',\n value: `${report.range.startDate} to ${report.range.endDate}`,\n },\n { label: 'Checked', value: formatCount(report.summary.checked) },\n {\n label: 'Recoverable',\n value: formatCount(report.summary.recoverable),\n },\n { label: 'High severity', value: formatCount(report.summary.high) },\n {\n label: 'Clicks at risk',\n value: formatCount(report.summary.clicksAtRisk),\n },\n {\n label: 'Impressions at risk',\n value: formatCount(report.summary.impressionsAtRisk),\n },\n ],\n })\n if (report.items.length) {\n printLimitedTable(\n ['Severity', 'Issue', 'Clicks', 'Impr', 'URL', 'Action'],\n report.items.map((item) => [\n item.severity,\n item.issue,\n formatCount(item.clicks),\n formatCount(item.impressions),\n truncate(item.url, 56),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top recovery actions',\n report.items.map((item) => ({\n label: truncate(item.url, 96),\n context: `${item.severity}, ${formatCount(item.clicks)} clicks at risk`,\n action: item.recommendation.action,\n })),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n },\n})\n","import { redirectTrace } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary, truncate } from '../output.js'\n\nexport const redirectTraceCommand = defineCommand({\n meta: {\n name: 'redirect-trace',\n description:\n 'Trace redirects and report final indexability/canonical issues',\n },\n args: {\n url: {\n type: 'string',\n required: true,\n description: 'URL to trace.',\n },\n 'max-hops': {\n type: 'string',\n description: 'Maximum redirect hops to follow. Defaults to 10.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache for final page extraction.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for final page extraction.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const report = await redirectTrace({\n url: stringArg(args.url) ?? '',\n maxHops: numberArg(args['max-hops']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Redirect trace',\n target: report.url,\n status:\n report.summary.issues.length > 0\n ? 'warning'\n : report.summary.finalIndexable === undefined\n ? 'unknown'\n : 'pass',\n summary:\n report.summary.issues.length > 0\n ? report.summary.issues.join(', ')\n : `${report.summary.hops} redirect hops ended at HTTP ${report.summary.finalStatus}.`,\n metrics: [\n { label: 'Final URL', value: report.finalUrl },\n { label: 'Final status', value: report.summary.finalStatus },\n {\n label: 'Indexable',\n value:\n report.summary.finalIndexable === undefined\n ? 'Unknown'\n : report.summary.finalIndexable\n ? 'Yes'\n : 'No',\n },\n { label: 'Hops', value: report.summary.hops },\n ],\n })\n printTable(\n ['#', 'Status', 'URL', 'Next'],\n report.chain.map((step, index) => [\n index + 1,\n step.status,\n truncate(step.url, 72),\n truncate(step.nextUrl ?? '-', 72),\n ]),\n )\n if (report.finalPage) {\n process.stdout.write('\\nFinal page\\n')\n printKeyValue([\n ['Title', report.finalPage.title ?? '-'],\n ['Canonical', report.finalPage.canonical ?? '-'],\n ['Meta robots', report.finalPage.metaRobots ?? '-'],\n ])\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n },\n})\n","import {\n buildOkfBundle,\n explainOkfValidation,\n okfConceptLimit,\n validateOkfFiles,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../args.js'\nimport { printJson, printKeyValue, printTable } from '../utils.js'\nimport { readOkfMarkdownFiles, writeOkfDirectory } from './okf-files.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction printValidation(\n filesPath: string,\n validation: ReturnType<typeof validateOkfFiles>,\n) {\n process.stdout.write(`OKF validation for ${filesPath}\\n\\n`)\n printKeyValue([\n ['Valid', validation.valid ? 'yes' : 'no'],\n ['Files', String(validation.files)],\n ['Concepts', String(validation.concepts)],\n [\n 'Errors',\n String(\n validation.issues.filter((issue) => issue.severity === 'error').length,\n ),\n ],\n [\n 'Warnings',\n String(\n validation.issues.filter((issue) => issue.severity === 'warning')\n .length,\n ),\n ],\n ])\n if (validation.issues.length) {\n process.stdout.write('\\nIssues\\n')\n printTable(\n ['Severity', 'Path', 'Message'],\n validation.issues\n .slice(0, 25)\n .map((issue) => [issue.severity, issue.path, issue.message]),\n )\n }\n}\n\nexport const okfExportCommand = defineCommand({\n meta: {\n name: 'export',\n description: 'Export a saved crawl as an OKF bundle',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to export.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n output: {\n type: 'string',\n description: 'Output directory. Defaults to ./okf.',\n },\n 'max-concepts': {\n type: 'string',\n description: 'Maximum concept files to export. Defaults to 500.',\n },\n title: {\n type: 'string',\n description: 'Override the root bundle title.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const maxConcepts = okfConceptLimit(\n strictNumberArg(args['max-concepts'], '--max-concepts'),\n )\n const report = await resolveSavedCrawlReport(args, { json })\n const bundle = buildOkfBundle(report, {\n maxConcepts,\n title: stringArg(args.title),\n })\n const output = stringArg(args.output) ?? './okf'\n const validation = await writeOkfDirectory(output, bundle.files)\n if (json) {\n printJson({ output, bundle, validation })\n return\n }\n process.stdout.write(`Wrote OKF bundle to ${output}\\n\\n`)\n printKeyValue([\n ['Files', String(bundle.files.length)],\n ['Concepts', String(bundle.conceptCount)],\n ['Valid', validation.valid ? 'yes' : 'no'],\n ])\n },\n})\n\nexport const okfValidateCommand = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate an OKF bundle directory',\n },\n args: {\n path: {\n type: 'positional',\n required: true,\n description: 'OKF bundle directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const path = stringArg(args.path)\n if (!path) throw new Error('Pass an OKF bundle directory.')\n const files = await readOkfMarkdownFiles(path)\n const validation = validateOkfFiles(files)\n if (!validation.valid) process.exitCode = 1\n if (jsonFlag(args)) {\n printJson(validation)\n return\n }\n printValidation(path, validation)\n },\n})\n\nexport const okfExplainCommand = defineCommand({\n meta: {\n name: 'explain',\n description: 'Explain OKF validation results in plain English',\n },\n args: {\n path: {\n type: 'positional',\n required: true,\n description: 'OKF bundle directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const path = stringArg(args.path)\n if (!path) throw new Error('Pass an OKF bundle directory.')\n const validation = validateOkfFiles(await readOkfMarkdownFiles(path))\n const explanation = explainOkfValidation(validation)\n if (!explanation.valid) process.exitCode = 1\n if (jsonFlag(args)) {\n printJson(explanation)\n return\n }\n process.stdout.write(`${explanation.summary}\\n\\n`)\n printKeyValue([\n ['Valid', explanation.valid ? 'yes' : 'no'],\n ['Files', String(explanation.files)],\n ['Concepts', String(explanation.concepts)],\n ['Errors', String(explanation.errors)],\n ['Warnings', String(explanation.warnings)],\n ])\n if (explanation.nextActions.length) {\n process.stdout.write('\\nNext actions\\n')\n for (const action of explanation.nextActions) {\n process.stdout.write(`- ${action}\\n`)\n }\n }\n },\n})\n\nexport const okfCommand = defineCommand({\n meta: {\n name: 'okf',\n description: 'Export, validate, and explain OKF site knowledge bundles',\n },\n subCommands: {\n export: okfExportCommand,\n validate: okfValidateCommand,\n explain: okfExplainCommand,\n },\n})\n","import { aiReferralsReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, strictNumberArg, stringArg } from '../../args.js'\nimport {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n} from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printLimitedTable,\n printReportSummary,\n truncate,\n} from '../output.js'\n\nexport const aiReferralsCommand = defineCommand({\n meta: {\n name: 'ai-referrals',\n description: 'Find AI referral traffic detected in Google Analytics',\n },\n args: {\n property: {\n type: 'string',\n description:\n 'Google Analytics property ID. If omitted in a terminal, choose one.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name with an optional Google Analytics property.',\n },\n 'start-date': { type: 'string', default: '28daysAgo' },\n 'end-date': { type: 'string', default: 'yesterday' },\n 'max-rows': {\n type: 'string',\n description:\n 'Maximum Google Analytics rows per query. Defaults to 100000.',\n },\n 'result-limit': {\n type: 'string',\n description: 'Maximum ranked landing pages returned. Defaults to 25.',\n },\n limit: {\n type: 'string',\n description: 'Legacy alias for --max-rows.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass cached Google Analytics responses.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = await resolveClient({\n client: projectArg(args),\n options: { json },\n })\n const property = await resolveGoogleAnalyticsProperty({\n property:\n stringArg(args.property) ?? client?.analytics.google?.propertyId,\n options: { json },\n })\n const report = await aiReferralsReport({\n property,\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n resultLimit: strictNumberArg(args['result-limit'], '--result-limit'),\n limit: strictNumberArg(args.limit, '--limit'),\n refresh: args.refresh === true,\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'AI referral report',\n target: report.property,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Evidence',\n value: report.dataStatus === 'complete' ? 'Complete' : 'Partial',\n status: report.dataStatus === 'complete' ? 'pass' : 'unknown',\n },\n { label: 'AI sessions', value: formatCount(report.summary.sessions) },\n {\n label: 'AI users',\n value:\n report.summary.totalUsers === null\n ? 'Unavailable'\n : formatCount(report.summary.totalUsers),\n },\n { label: 'Sources', value: formatCount(report.summary.sources) },\n {\n label: 'Landing pages',\n value: formatCount(report.summary.landingPages),\n },\n {\n label: 'Landing-page output',\n value: `${formatCount(report.selection.landingPages.returnedRows)} returned / ${formatCount(report.selection.landingPages.retainedRows)} retained`,\n },\n {\n label: 'Source rows',\n value: formatCount(report.dataSource.sourceDiscovery.returnedRows),\n },\n ],\n })\n\n if (report.sources.length) {\n process.stdout.write('\\nAI sources\\n')\n printLimitedTable(\n ['Source', 'Sessions', 'Events', 'Share of AI sessions'],\n report.sources.map((source) => [\n source.label,\n formatCount(source.sessions),\n formatCount(source.eventCount),\n formatPercent(source.shareOfAiSessions),\n ]),\n )\n }\n\n if (report.landingPages.length) {\n process.stdout.write('\\nLanding pages\\n')\n printLimitedTable(\n ['Landing page', 'Sessions', 'Events', 'Top source'],\n report.landingPages.map((page) => [\n truncate(page.landingPage, 64),\n formatCount(page.sessions),\n formatCount(page.eventCount),\n page.topSourceDetails.label,\n ]),\n )\n }\n\n if (report.dataSource.partialReasons.length) {\n process.stdout.write('\\nEvidence warnings\\n')\n for (const warning of report.dataSource.partialReasons) {\n process.stdout.write(`- ${warning}\\n`)\n }\n }\n\n process.stdout.write(`\\nNote: ${report.summary.caveat}\\n`)\n },\n})\n","import { cannibalReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const cannibalCommand = defineCommand({\n meta: {\n name: 'cannibal',\n description: 'Find queries with material exposure across multiple URLs',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(\n ['days', 'limit', 'includeBrand', 'minImpressions', 'refresh'],\n {\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 50.',\n },\n },\n ),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await cannibalReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Cannibalisation report',\n target: report.site,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Range',\n value: `${report.range.startDate} to ${report.range.endDate}`,\n },\n {\n label: 'Eligible',\n value: formatCount(report.summary.eligibleClusters),\n },\n {\n label: 'Returned',\n value: formatCount(report.summary.returnedClusters),\n },\n {\n label: 'Suppressed brand queries',\n value: formatCount(report.summary.suppressedQueries),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n {\n label: 'Brand queries',\n value: booleanArg(args['include-brand']) ? 'included' : 'excluded',\n },\n ],\n })\n printLimitedTable(\n ['Query', 'URLs', 'Property impr', 'Exposure', 'HHI', 'Review first'],\n report.items.map((item) => [\n truncate(item.query, 42),\n item.pages.length,\n item.propertyImpressions === undefined\n ? 'n/a'\n : formatCount(item.propertyImpressions),\n formatCount(item.pageExposureImpressions),\n item.hhi.toFixed(2),\n truncate(item.suggestedOwnerUrl, 56),\n ]),\n )\n printActionDetails(\n 'Top cannibalisation actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.pages.length} material URLs; first review ${truncate(item.suggestedOwnerUrl, 64)}`,\n action: item.recommendation.action,\n })),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Provider usage', [report.ledgerSummary])\n },\n})\n","import { communityIntentReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const communityIntentCommand = defineCommand({\n meta: {\n name: 'community-intent',\n description: 'Find GSC queries with forum, review, and comparison intent',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n 'start-date': {\n type: 'string',\n description: 'Exact GSC start date (YYYY-MM-DD). Use with --end-date.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact GSC end date (YYYY-MM-DD). Use with --start-date.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC query rows. Defaults to 50000.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'GSC lookback within the current 16-month retention.',\n },\n limit: {\n description: 'Maximum intent queries to print. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 20.',\n },\n includeBrand: {\n description: 'Include branded queries in community-intent reports.',\n },\n refresh: { description: 'Bypass local GSC cache.' },\n },\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await communityIntentReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Community intent report',\n target: report.site,\n status:\n report.dataStatus === 'available' || report.dataStatus === 'empty'\n ? 'info'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Classified queries',\n value: formatCount(report.summary.classifiedQueries),\n },\n {\n label: 'Returned queries',\n value: formatCount(report.summary.returnedQueries),\n },\n {\n label: 'Impressions',\n value: formatCount(report.summary.returnedImpressions),\n },\n { label: 'Clicks', value: formatCount(report.summary.returnedClicks) },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n\n printLimitedTable(\n ['Intent', 'Query', 'Impr', 'Clicks', 'Confidence', 'Action'],\n report.items.map((item) => [\n item.intent,\n truncate(item.query, 42),\n formatCount(item.impressions),\n formatCount(item.clicks),\n item.confidence,\n truncate(item.action, 76),\n ]),\n )\n printActionDetails(\n 'Top community-intent actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.intent}, ${formatCount(item.impressions)} impressions`,\n action: item.action,\n })),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n },\n})\n","import { ctrUnderperformersReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const ctrUnderperformersCommand = defineCommand({\n meta: {\n name: 'ctr-underperformers',\n description:\n 'Find high-impression queries with weak CTR for their position',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['includeBrand', 'minImpressions'], {\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 200.',\n },\n }),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await ctrUnderperformersReport({\n site: selection.site,\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'CTR underperformers',\n target: report.site,\n status: report.dataStatus === 'partial' ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Underperformers',\n value: formatCount(report.summary.underperformers),\n },\n {\n label: 'Estimated click gap',\n value: formatCount(report.summary.estimatedClickShortfall),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n printNotes('Why this matters', [\n 'These queries already have visibility; the fastest win is usually better SERP framing, not new content.',\n 'Start with high-impression rows where actual CTR is far below the expected CTR for that ranking position.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printLimitedTable(\n ['Query', 'URL', 'Pos', 'Impr', 'CTR', 'Expected', 'Gap', 'Action'],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.url, 48),\n formatPosition(item.position),\n formatCount(item.impressions),\n formatPercent(item.actualCtr),\n formatPercent(item.expectedCtr),\n formatCount(item.clickShortfall),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top CTR actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${formatCount(item.clickShortfall)} click gap, ${formatPercent(item.actualCtr)} CTR`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { decayingReport, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nfunction formatMaybePosition(value: number): string {\n return value > 0 ? formatPosition(value) : 'n/a'\n}\n\nexport const decayingCommand = defineCommand({\n meta: {\n name: 'decaying',\n description: 'Find query/page rows losing clicks between two GSC windows',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'includeBrand', 'refresh']),\n comparison: {\n type: 'string',\n description: 'Comparison: previous-period or year-over-year.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n 'min-drop-pct': {\n type: 'string',\n description: 'Minimum click drop percentage. Defaults to 20.',\n },\n 'min-previous-clicks': {\n type: 'string',\n description:\n 'Minimum previous-window clicks for a query/page row. Defaults to 2.',\n },\n 'min-click-loss': {\n type: 'string',\n description: 'Minimum absolute click loss. Defaults to 1.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const comparison = stringArg(args.comparison)\n const days = strictNumberArg(args.days, '--days')\n const limit = strictNumberArg(args.limit, '--limit')\n const minDropPct = strictNumberArg(args['min-drop-pct'], '--min-drop-pct')\n const minPreviousClicks = strictNumberArg(\n args['min-previous-clicks'],\n '--min-previous-clicks',\n )\n const minClickLoss = strictNumberArg(\n args['min-click-loss'],\n '--min-click-loss',\n )\n if (\n comparison !== undefined &&\n comparison !== 'previous-period' &&\n comparison !== 'year-over-year'\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--comparison must be previous-period or year-over-year.',\n )\n }\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await decayingReport({\n site: selection.site,\n days,\n limit,\n comparison,\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n minDropPct,\n minPreviousClicks,\n minClickLoss,\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Decaying pages',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.summary.returnedRows > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Comparison', value: report.comparison },\n {\n label: 'Observed declines',\n value: formatCount(report.summary.returnedRows),\n },\n {\n label: 'Eligible declines',\n value: formatCount(report.summary.eligibleRows),\n },\n { label: 'Decay clusters', value: formatCount(report.summary.groups) },\n {\n label: 'Observed click decline',\n value: formatCount(\n report.summary.returnedObservedRetainedQueryClickLoss,\n ),\n },\n {\n label: 'Eligible click decline',\n value: formatCount(report.summary.observedRetainedQueryClickLoss),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Minimum drop', value: `${report.filters.minDropPct}%` },\n {\n label: 'Minimum previous clicks',\n value: formatCount(report.filters.minPreviousClicks),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n printNotes('Why this matters', [\n 'This report compares retained query/page rows and only counts declines observed in both windows.',\n 'Position, CTR, and impression movements are signals for investigation, not proof of cause.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n\n if (!report.items.length) {\n return\n }\n\n if (report.groups.length) {\n printLimitedTable(\n ['Cluster', 'Rows', 'Observed loss', 'Drop', 'Sample query', 'Action'],\n report.groups.map((group) => [\n truncate(group.label, 42),\n formatCount(group.count),\n formatCount(group.totalClickLoss),\n `${group.averageDropPct.toFixed(1)}%`,\n truncate(group.sampleQueries[0] ?? '-', 40),\n truncate(group.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top decay cluster actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${formatCount(group.count)} retained rows, ${formatCount(group.totalClickLoss)} observed click decline`,\n action: group.recommendation,\n })),\n )\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Signals',\n 'Decline',\n 'Clicks',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 32),\n truncate(item.template.label, 26),\n truncate(item.url, 44),\n item.signals.join(', '),\n formatCount(item.clickLoss),\n `${formatCount(item.previous.clicks)} -> ${formatCount(item.current.clicks)}`,\n `${formatCount(item.previous.impressions)} -> ${formatCount(item.current.impressions)}`,\n `${formatPercent(item.previous.ctr)} -> ${formatPercent(item.current.ctr)}`,\n `${formatMaybePosition(item.previous.position)} -> ${formatMaybePosition(item.current.position)}`,\n truncate(item.recommendation.action, 64),\n ]),\n )\n printActionDetails(\n 'Top decay actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, ${formatCount(item.clickLoss)} fewer observed clicks`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { internalLinksReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictFetchRateArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const internalLinksCommand = defineCommand({\n meta: {\n name: 'internal-links',\n description: 'Find verified internal-link review candidates for one URL',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n url: {\n type: 'string',\n required: true,\n description: 'Target page that should receive relevant internal links.',\n },\n ...cliReportArgs([\n 'days',\n 'limit',\n 'checkLimit',\n 'minImpressions',\n 'includeBrand',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const days = strictNumberArg(args.days, '--days')\n const limit = strictNumberArg(args.limit, '--limit')\n const checkLimit = strictNumberArg(args['check-limit'], '--check-limit')\n const minImpressions = strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n )\n const rate = strictFetchRateArg(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await internalLinksReport({\n site: selection.site,\n targetUrl: stringArg(args.url) ?? '',\n days,\n limit,\n checkLimit,\n minImpressions,\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n js: booleanArg(args.js) ? true : undefined,\n rate,\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Internal link opportunities',\n target: report.targetUrl,\n status:\n report.summary.failedChecks > 0 ||\n report.summary.uncheckedCandidates > 0\n ? 'unknown'\n : 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Target state', value: report.target.verification },\n { label: 'Preferred target', value: report.target.preferredUrl },\n {\n label: 'Target queries',\n value: formatCount(report.summary.targetQueries),\n },\n {\n label: 'Matched sources',\n value: formatCount(report.summary.candidateSources),\n },\n {\n label: 'Checked sources',\n value: formatCount(report.summary.checkedSources),\n },\n {\n label: 'Attempted sources',\n value: formatCount(report.summary.attemptedSources),\n },\n {\n label: 'Review candidates',\n value: formatCount(report.summary.returnedSources),\n },\n {\n label: 'Technical exclusions',\n value: formatCount(report.summary.technicalExclusions),\n },\n {\n label: 'Existing links',\n value: formatCount(report.summary.existingLinksObserved),\n },\n {\n label: 'Failed checks',\n value: formatCount(report.summary.failedChecks),\n },\n {\n label: 'Unchecked sources',\n value: formatCount(report.summary.uncheckedCandidates),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n ],\n })\n printNotes('Why this matters', [\n 'Exact-query overlap is useful affinity evidence; precision lexical matches are review evidence only.',\n 'Source and target pages are checked for redirects, indexability, canonicals, and existing link placement before an action is returned.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n if (!report.items.length) return\n\n printLimitedTable(\n ['Source URL', 'Matched impr', 'Match', 'Link evidence', 'Action'],\n report.items.map((item) => [\n truncate(item.sourceUrl, 52),\n formatCount(item.matchedQueryImpressions),\n item.bestMatchKind,\n item.linkEvidence.status,\n item.actionType,\n ]),\n )\n printActionDetails(\n 'Top internal-link reviews',\n report.items.map((item) => ({\n label: truncate(item.sourceUrl, 96),\n context: `${formatCount(item.matchedQueryImpressions)} matched-query impressions; ${item.bestMatchKind}`,\n action: item.recommendation.action,\n })),\n )\n printNotes('Provider usage', [report.ledgerSummary])\n },\n})\n","import { pageOpportunitiesReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatFetchDiagnostics } from '../shared.js'\n\nexport const pageOpportunitiesCommand = defineCommand({\n meta: {\n name: 'page-opportunities',\n description: 'Find first-party traffic growth opportunities for one URL',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n url: { type: 'string', required: true },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'js', 'refresh'],\n {\n limit: {\n description: 'Maximum page queries to inspect. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 10.',\n },\n includeBrand: {\n description: 'Include branded queries in page opportunity reports.',\n },\n js: {\n description: 'Force JavaScript rendering for page extraction.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP cache.',\n },\n },\n ),\n 'verify-content': defaultTrueBooleanArg(\n 'Fetch the page for title/H1/body checks. Defaults to true.',\n 'Skip fetching the page for title/H1/body checks.',\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await pageOpportunitiesReport({\n site: selection.site,\n url: stringArg(args.url) ?? '',\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']) !== false,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Page opportunities',\n target: report.url,\n status: report.verification.status === 'failed' ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Title', value: report.page?.title ?? 'Not fetched' },\n {\n label: 'Fetch',\n value: formatFetchDiagnostics(report.page?.fetchDiagnostics),\n },\n { label: 'Verification', value: report.verification.status },\n {\n label: 'Rows',\n value: `${formatCount(report.selection.returnedRows)} returned / ${formatCount(report.selection.eligibleRows)} eligible / ${formatCount(report.selection.sourceRows)} source`,\n },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n {\n label: 'Opportunities',\n value: formatCount(report.summary.opportunities),\n },\n {\n label: 'CTR shortfall',\n value: formatCount(report.summary.estimatedCtrClickShortfall),\n },\n { label: 'Focus', value: report.summary.focus },\n { label: 'Evidence', value: report.dataStatus },\n ],\n })\n printNotes('Why this matters', [\n 'This report starts from queries where this exact URL already has impressions, so recommendations stay tied to first-party demand.',\n 'Content verification separates body gaps from title/meta framing issues, which helps avoid adding copy when the page already covers the query.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (!report.items.length) {\n process.stdout.write(\n report.dataStatus === 'empty'\n ? 'No GSC query rows found for this exact URL.\\n'\n : 'GSC rows were found, but none met the report criteria.\\n',\n )\n return\n }\n\n printLimitedTable(\n [\n 'Type',\n 'Query',\n 'Evidence',\n 'Pos',\n 'CTR',\n 'Expected',\n 'Impr',\n 'Shortfall',\n 'Action',\n ],\n report.items.map((item) => [\n item.opportunityType,\n truncate(item.query, 38),\n item.verification.signals.length\n ? item.verification.signals.join(', ')\n : item.verification.status,\n item.position.toFixed(1),\n formatPercent(item.ctr),\n item.expectedCtr === undefined\n ? 'n/a'\n : formatPercent(item.expectedCtr),\n formatCount(item.impressions),\n item.estimatedCtrClickShortfall === undefined\n ? 'n/a'\n : formatCount(item.estimatedCtrClickShortfall),\n truncate(item.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top page actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.opportunityType}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation,\n })),\n )\n },\n})\n","import { queryClusterReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const queryClusterCommand = defineCommand({\n meta: {\n name: 'query-cluster',\n description: 'Cluster GSC queries into repeated demand themes',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n scope: { type: 'string' },\n ...cliReportArgs(['includeBrand', 'minImpressions', 'limit'], {\n includeBrand: {\n description: 'Include branded queries in query clustering.',\n },\n minImpressions: {\n description: 'Minimum impressions per query. Defaults to 25.',\n },\n limit: {\n description: 'Maximum clusters to return. Defaults to 25; max 100.',\n },\n }),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await queryClusterReport({\n site: selection.site,\n scope: stringArg(args.scope),\n brand: selection.client?.brandTerms?.[0],\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n minImpressions: numberArg(args['min-impressions']),\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Query clusters',\n target: report.site,\n status: 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Scope', value: report.scope ?? 'All pages' },\n { label: 'Clusters', value: formatCount(report.summary.clusters) },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n { label: 'Clicks', value: formatCount(report.summary.clicks) },\n {\n label: 'Minimum impressions',\n value: formatCount(report.summary.minImpressions),\n },\n { label: 'Result limit', value: formatCount(report.summary.limit) },\n {\n label: 'High opportunity',\n value: formatCount(report.summary.highOpportunityClusters),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n ],\n })\n printNotes('Why this matters', [\n 'Clusters show repeated demand themes, so they are better inputs for page sections, hubs, and templates than one-off query exports.',\n 'Prioritise clusters with high impressions and low clicks; they usually reveal unclear intent coverage or weak SERP framing.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printLimitedTable(\n [\n 'Cluster',\n 'Intent',\n 'Queries',\n 'Impr',\n 'CTR',\n 'Expected',\n 'Lift',\n 'Action',\n ],\n report.clusters.map((cluster) => {\n return [\n truncate(cluster.label, 32),\n cluster.intent,\n cluster.queries.length,\n formatCount(cluster.totals?.impressions ?? 0),\n formatPercent(cluster.totals?.ctr ?? 0),\n formatPercent(cluster.benchmark?.expectedCtr ?? 0),\n cluster.estimatedClickLift === undefined\n ? '-'\n : formatCount(cluster.estimatedClickLift),\n truncate(cluster.recommendation ?? '', 72),\n ]\n }),\n )\n printActionDetails(\n 'Top cluster actions',\n report.clusters.map((cluster) => ({\n label: cluster.label,\n context: `${formatCount(cluster.totals?.impressions ?? 0)} impressions, ${cluster.estimatedClickLift === undefined ? 'ranking opportunity' : `${formatCount(cluster.estimatedClickLift)} estimated click lift`}`,\n action: cluster.recommendation ?? '',\n })),\n )\n },\n})\n","import { quickWinsReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n verificationSummary,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nexport const quickWinsCommand = defineCommand({\n meta: {\n name: 'quick-wins',\n description: 'Find high-ranking low-CTR query/page opportunities',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs([\n 'days',\n 'limit',\n 'includeBrand',\n 'minImpressions',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await quickWinsReport({\n site: selection.site,\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Quick wins',\n target: report.site,\n status: report.source.possiblyTruncated ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible rows',\n value: formatCount(report.summary.eligibleRows),\n },\n {\n label: 'Returned rows',\n value: formatCount(report.summary.returnedRows),\n },\n {\n label: 'Query clusters',\n value: formatCount(report.summary.repeatedQueryGroups),\n },\n {\n label: 'Template patterns',\n value: formatCount(report.summary.templatePatterns),\n },\n {\n label: 'CTR click shortfall',\n value: formatCount(report.summary.returnedEstimatedCtrClickShortfall),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Verification', value: verificationSummary(report) },\n ],\n })\n printNotes('Why this matters', [\n 'These rows have GSC average positions from 4 to 10 and observed CTR below a site-peer or versioned fallback target.',\n 'Page evidence is needed before treating a CTR shortfall as a title, content, or technical finding.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (!report.items.length) {\n return\n }\n\n if (report.templateRecommendations.length) {\n printLimitedTable(\n ['Template', 'URLs', 'Rows', 'Shortfall', 'Impr', 'Action'],\n report.templateRecommendations.map((template) => [\n truncate(template.templateLabel, 34),\n formatCount(template.urlCount),\n formatCount(template.rowCount),\n formatCount(template.totalEstimatedCtrClickShortfall),\n formatCount(template.totalImpressions),\n truncate(template.action, 72),\n ]),\n )\n printActionDetails(\n 'Top template actions',\n report.templateRecommendations.map((template) => ({\n label: template.templateLabel,\n context: `${formatCount(template.urlCount)} URLs, ${formatCount(template.totalEstimatedCtrClickShortfall)} heuristic CTR click shortfall`,\n action: `${template.action} ${template.evidence}`,\n })),\n )\n }\n\n if (report.groups.length) {\n printLimitedTable(\n [\n 'Cluster',\n 'URLs',\n 'Rows',\n 'Shortfall',\n 'Impr',\n 'Sample URL',\n 'Action',\n ],\n report.groups.map((group) => [\n truncate(group.label, 44),\n formatCount(group.urlCount),\n formatCount(group.rowCount),\n formatCount(group.totalEstimatedCtrClickShortfall),\n formatCount(group.totalImpressions),\n truncate(group.sampleUrls[0] ?? '-', 46),\n truncate(group.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top cluster actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${formatCount(group.urlCount)} URLs, ${formatCount(group.totalEstimatedCtrClickShortfall)} heuristic CTR click shortfall`,\n action: group.recommendation,\n })),\n )\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Pos',\n 'Impr',\n 'CTR / target',\n 'Shortfall',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.template.label, 24),\n truncate(item.url, 48),\n formatPosition(item.position),\n formatCount(item.impressions),\n `${formatPercent(item.ctr)} / ${formatPercent(item.targetCtr)}`,\n formatCount(item.estimatedCtrClickShortfall),\n formatFetchDiagnostics(item.contentVerification?.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n truncate(item.recommendation.action, 64),\n ]),\n )\n printActionDetails(\n 'Top opportunity actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { secondPage } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n verificationSummary,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nexport const secondPageCommand = defineCommand({\n meta: {\n name: 'second-page',\n description: 'Find URLs averaging positions above 10 through 20 in GSC',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs([\n 'range',\n 'minImpressions',\n 'limit',\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await secondPage({\n site: selection.site,\n range: numberArg(args.days),\n minImpressions: numberArg(args['min-impressions']),\n limit: stringArg(args.limit) ? Number(stringArg(args.limit)) : 10,\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Second-page opportunities',\n target: report.site,\n status:\n report.source.possiblyTruncated || report.summary.fetchFailures > 0\n ? 'unknown'\n : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible pages',\n value: formatCount(report.summary.eligiblePages),\n },\n {\n label: 'Returned pages',\n value: formatCount(report.summary.returnedPages),\n },\n {\n label: 'Eligible queries',\n value: formatCount(report.summary.eligibleQueries),\n },\n {\n label: 'Impressions',\n value: formatCount(report.summary.eligibleImpressions),\n },\n {\n label: 'Content issues',\n value: formatCount(report.summary.contentIssues),\n },\n {\n label: 'Technical issues',\n value: formatCount(report.summary.technicalIssues),\n },\n {\n label: 'Fetch failures',\n value: formatCount(report.summary.fetchFailures),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Verification', value: verificationSummary(report) },\n ],\n })\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n if (!report.items.length) {\n process.stdout.write(\n 'No average-position candidates matched this report.\\n',\n )\n process.stdout.write(`${report.ledgerSummary}\\n`)\n return\n }\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'Pos',\n 'Impr',\n 'CTR',\n 'Queries',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n item.primaryQuery,\n item.template.label,\n item.position.toFixed(1),\n Math.round(item.impressions),\n item.ctr.toFixed(3),\n formatCount(item.queryCount),\n formatFetchDiagnostics(item.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n item.recommendation.action,\n ]),\n )\n printActionDetails(\n 'Top second-page actions',\n report.items.map((item) => ({\n label: item.primaryQuery,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n process.stdout.write(`${report.ledgerSummary}\\n`)\n },\n})\n","import { seoToAiQueryReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const seoToAiQueryCommand = defineCommand({\n meta: {\n name: 'seo-to-ai-query',\n description: 'Convert GSC search queries into AI-style monitoring prompts',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n 'start-date': {\n type: 'string',\n description: 'Exact GSC start date (YYYY-MM-DD). Use with --end-date.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact GSC end date (YYYY-MM-DD). Use with --start-date.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC query rows. Defaults to 50000.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'GSC lookback within the current 16-month retention.',\n },\n limit: {\n description: 'Maximum source queries to convert. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 20.',\n },\n includeBrand: {\n description: 'Include branded queries in prompt generation.',\n },\n refresh: { description: 'Bypass local GSC cache.' },\n },\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await seoToAiQueryReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'SEO to AI query prompts',\n target: report.site,\n status:\n report.dataStatus === 'available' || report.dataStatus === 'empty'\n ? 'info'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Eligible queries',\n value: formatCount(report.summary.eligibleQueries),\n },\n {\n label: 'Returned queries',\n value: formatCount(report.summary.returnedQueries),\n },\n { label: 'Prompts', value: formatCount(report.summary.prompts) },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n\n printLimitedTable(\n ['Query', 'Impr', 'Prompt'],\n report.items.flatMap((item) =>\n item.prompts.map((prompt) => [\n truncate(item.query, 42),\n formatCount(item.impressions),\n truncate(prompt, 86),\n ]),\n ),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n },\n})\n","import { auditPage } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport { printReportSummary } from './output.js'\nimport { formatFetchDiagnostics } from './shared.js'\n\nexport const auditPageCommand = defineCommand({\n meta: {\n name: 'audit-page',\n description:\n 'Fetch one page and audit title, metadata, content, links, and schema',\n },\n args: {\n url: { type: 'string', required: true, description: 'URL to audit.' },\n site: {\n type: 'string',\n description:\n 'Optional GSC property for page search metrics, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for extraction.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache.',\n },\n },\n run: async ({ args }) => {\n const project = projectArg(args)\n const explicitSite = stringArg(args.site)\n const selectedProject = project\n ? await resolveClient({ project, options: { json: jsonFlag(args) } })\n : undefined\n const defaultProject =\n project || explicitSite\n ? undefined\n : await resolveClient({ options: { json: jsonFlag(args) } })\n const report = await auditPage({\n url: stringArg(args.url) ?? '',\n site: selectedProject?.siteUrl ?? explicitSite ?? defaultProject?.siteUrl,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Page audit',\n target: report.url,\n status: report.issues.some((issue) => issue.severity === 'high')\n ? 'fail'\n : report.issues.length > 0\n ? 'warning'\n : 'pass',\n summary:\n report.issues.length > 0\n ? `${report.issues.length} ${report.issues.length === 1 ? 'issue needs' : 'issues need'} review.`\n : 'No page issues were found by the available checks.',\n metrics: [\n { label: 'Final URL', value: report.page.finalUrl },\n { label: 'Title', value: report.page.title ?? 'Missing' },\n {\n label: 'Meta description',\n value: report.page.metaDescription ?? 'Missing',\n },\n { label: 'Words', value: report.page.wordCount },\n {\n label: 'Fetch',\n value: formatFetchDiagnostics(report.fetchDiagnostics),\n },\n ],\n diagnostics: [\n {\n title: 'Issues',\n items: report.issues.map((issue) => ({\n status: issue.severity === 'high' ? 'fail' : 'warning',\n title: `${issue.code}: ${issue.principle}`,\n explanation: issue.detail,\n })),\n },\n ],\n })\n },\n})\n","import { performanceAudit, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport { printActionDetails, printNotes, printReportSummary } from './output.js'\n\nfunction strategy(value: unknown): 'mobile' | 'desktop' {\n const selected = stringArg(value) ?? 'mobile'\n if (selected !== 'mobile' && selected !== 'desktop') {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Invalid --strategy. Use mobile or desktop.',\n )\n }\n return selected\n}\n\nfunction metric(value?: { displayValue?: string; value?: number }): string {\n if (!value) return 'not measured'\n return value.displayValue ?? String(value.value ?? 'not measured')\n}\n\nfunction fieldMetric(value?: {\n p75: number\n rating: string\n unit: 'milliseconds' | 'score'\n}): string {\n if (!value) return 'not available'\n const suffix = value.unit === 'milliseconds' ? 'ms' : ''\n return `${value.p75}${suffix} (${value.rating})`\n}\n\nexport const performanceCommand = defineCommand({\n meta: {\n name: 'perf',\n description: 'Audit lab performance and field Core Web Vitals',\n },\n subCommands: {\n audit: defineCommand({\n meta: {\n name: 'audit',\n description: 'Run a Lighthouse/Core Web Vitals performance audit',\n },\n args: {\n url: {\n type: 'string',\n description:\n 'URL to audit. Defaults to the selected project crawl URL.',\n },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n strategy: {\n type: 'string',\n default: 'mobile',\n description: 'Audit strategy: mobile or desktop.',\n },\n 'lighthouse-bin': {\n type: 'string',\n description:\n 'Custom Lighthouse binary path. Defaults to the bundled version.',\n },\n 'crux-key': {\n type: 'string',\n description:\n 'CrUX API key. Prefer SEO_CRUX_API_KEY to avoid shell history.',\n },\n raw: {\n type: 'boolean',\n default: false,\n description: 'Include the full Lighthouse JSON in JSON output.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local performance report cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = await resolveClient({\n client: projectArg(args),\n options: { json },\n })\n const url = stringArg(args.url) ?? project?.startUrl\n if (!url) {\n throw new Error(\n 'No URL selected. Pass --url or use --project with a crawl URL.',\n )\n }\n const report = await performanceAudit({\n url,\n strategy: strategy(args.strategy),\n lighthouseBin: stringArg(args['lighthouse-bin']),\n cruxApiKey: stringArg(args['crux-key']),\n refresh: booleanArg(args.refresh),\n includeRaw: json && booleanArg(args.raw),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Performance report',\n target: report.url,\n status:\n report.dataStatus === 'partial'\n ? 'unknown'\n : report.grade === 'good'\n ? 'pass'\n : 'warning',\n summary: report.headline,\n metrics: [\n { label: 'Source', value: report.source },\n { label: 'Strategy', value: report.strategy },\n {\n label: 'Lab score',\n value:\n report.score === undefined ? 'Unknown' : `${report.score}/100`,\n },\n { label: 'Lab grade', value: report.grade },\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'FCP',\n value: metric(report.metrics.firstContentfulPaint),\n },\n {\n label: 'LCP',\n value: metric(report.metrics.largestContentfulPaint),\n },\n { label: 'TBT', value: metric(report.metrics.totalBlockingTime) },\n {\n label: 'CLS',\n value: metric(report.metrics.cumulativeLayoutShift),\n },\n {\n label: 'INP',\n value: metric(report.metrics.interactionToNextPaint),\n },\n {\n label: 'Server response',\n value: metric(report.metrics.serverResponseTime),\n },\n {\n label: 'Fallback fetch',\n value: metric(report.metrics.fallbackFetchDuration),\n },\n {\n label: 'Field data',\n value: report.fieldData\n ? `${report.fieldData.scope} ${report.fieldData.formFactor.toLowerCase()} (${report.fieldData.assessment.status})`\n : report.fieldDataStatus.status,\n },\n {\n label: 'Field LCP p75',\n value: fieldMetric(\n report.fieldData?.metrics.largestContentfulPaint,\n ),\n },\n {\n label: 'Field INP p75',\n value: fieldMetric(\n report.fieldData?.metrics.interactionToNextPaint,\n ),\n },\n {\n label: 'Field CLS p75',\n value: fieldMetric(\n report.fieldData?.metrics.cumulativeLayoutShift,\n ),\n },\n {\n label: 'Field period',\n value:\n report.fieldData?.collectionPeriod?.firstDate &&\n report.fieldData.collectionPeriod.lastDate\n ? `${report.fieldData.collectionPeriod.firstDate} to ${report.fieldData.collectionPeriod.lastDate}`\n : 'Unavailable',\n },\n ],\n })\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n action: action.action,\n context: action.plainEnglish,\n })),\n )\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import { diagnoseProperty } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const diagnoseCommand = defineCommand({\n meta: {\n name: 'diagnose',\n description: 'Find where Google Search performance changed',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Baseline window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n },\n ),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await diagnoseProperty({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n progress: createProgressReporter(!json),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'SEO diagnosis',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.priorities.length > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary:\n report.priorities.length > 0\n ? `${report.priorities.length} priorities need review.`\n : 'No priorities were returned by the available evidence.',\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Update overlap',\n value: report.summary.updateAttribution.replaceAll('-', ' '),\n },\n {\n label: 'Significant anomalies',\n value: report.summary.significantAnomalies,\n },\n { label: 'Update matches', value: report.summary.updateMatches },\n { label: 'Decay items', value: report.summary.decayItems },\n { label: 'Cannibal items', value: report.summary.cannibalItems },\n {\n label: 'Striking distance',\n value: report.summary.strikingDistanceItems,\n },\n { label: 'Quick wins', value: report.summary.quickWinItems },\n ],\n })\n printTable(\n ['Priority', 'Confidence', 'Reason', 'Action'],\n report.priorities.map((priority) => [\n priority.label,\n priority.confidence,\n priority.reason,\n priority.action,\n ]),\n )\n if (report.skippedSections?.length) {\n printTable(\n ['Skipped section', 'Reason'],\n report.skippedSections.map((section) => [\n section.section,\n section.reason,\n ]),\n )\n }\n printActionDetails(\n 'Priority action details',\n report.priorities.map((priority) => ({\n label: priority.label,\n context: priority.confidence,\n action: priority.action,\n })),\n )\n },\n})\n","import { runDoctor } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../args.js'\nimport { checkSummary } from '../../presentation/views.js'\nimport { printChecks, printHeading, printJson } from '../../utils.js'\n\nexport const doctorCommand = defineCommand({\n meta: {\n name: 'doctor',\n description: 'Check local auth, scopes, config, and defaults',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const report = await runDoctor()\n if (jsonFlag(args)) {\n printJson(report)\n if (!report.ok) process.exitCode = 1\n return\n }\n printHeading('SEO doctor', checkSummary(report.checks))\n process.stdout.write('\\n')\n printChecks(report.checks)\n process.stdout.write(`\\nChecked ${report.generatedAt}\\n`)\n if (!report.ok) process.exitCode = 1\n },\n})\n","import { type SegmentDimension, segmentImpact } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nconst segmentDimension = (value: unknown): SegmentDimension => {\n const dimension = stringArg(value) ?? 'page'\n if (\n dimension !== 'page' &&\n dimension !== 'query' &&\n dimension !== 'country' &&\n dimension !== 'device'\n ) {\n throw new Error('Invalid --dimension. Use page, query, country, or device.')\n }\n return dimension\n}\n\nexport const segmentImpactCommand = defineCommand({\n meta: {\n name: 'segment-impact',\n description: 'Compare GSC movement by page, query, device, or country',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n dimension: {\n type: 'string',\n default: 'page',\n description: 'Segment by page, query, country, or device.',\n },\n ...cliReportArgs(['days', 'limit', 'refresh'], {\n days: {\n description: 'Recent window length from 1 to 240 days. Defaults to 28.',\n },\n limit: {\n description: 'Maximum segment rows to print. Defaults to 25.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n compare: {\n type: 'string',\n description:\n 'Legacy 1-240 day comparison length. Must equal the current window.',\n },\n 'start-date': {\n type: 'string',\n description: 'Exact current-window start date in YYYY-MM-DD format.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact current-window end date in YYYY-MM-DD format.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC rows per window. Defaults to 100000.',\n },\n 'unmatched-limit': {\n type: 'string',\n description:\n 'Maximum one-window evidence rows to return. Defaults to 25.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const dimension = segmentDimension(args.dimension)\n const days = strictNumberArg(args.days, '--days')\n const compareDays = strictNumberArg(args.compare, '--compare')\n const limit = strictNumberArg(args.limit, '--limit')\n const unmatchedLimit = strictNumberArg(\n args['unmatched-limit'],\n '--unmatched-limit',\n )\n const maxRows = strictNumberArg(args['max-rows'], '--max-rows')\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await segmentImpact({\n site: selection.site,\n dimension,\n days,\n compareDays,\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit,\n unmatchedLimit,\n maxRows,\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Segment impact',\n target: report.site,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Dimension', value: report.dimension },\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n ],\n })\n printTable(\n ['Segment', 'Clicks before', 'Clicks after', 'Delta', 'Pos delta'],\n report.items.map((item) => [\n item.key,\n item.beforeClicks,\n item.afterClicks,\n item.clickDelta,\n item.positionDelta ?? '-',\n ]),\n )\n if (report.unmatchedSegments.length) {\n process.stdout.write('\\nOne-window evidence (not treated as zero)\\n')\n printTable(\n ['Segment', 'Retained in', 'Clicks', 'Impressions'],\n report.unmatchedSegments.map((item) => [\n item.key,\n item.retainedIn,\n item.clicks,\n item.impressions,\n ]),\n )\n }\n printNotes('Warnings', report.warnings)\n },\n})\n","import { strikingDistance } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nfunction rowCountLabel(count: number): string {\n return `${formatCount(count)} ${count === 1 ? 'row' : 'rows'}`\n}\n\nexport const strikingDistanceCommand = defineCommand({\n meta: {\n name: 'striking-distance',\n description: 'Find query/page rows averaging positions above 10 through 20',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs([\n 'days',\n 'minImpressions',\n 'limit',\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await strikingDistance({\n site: selection.site,\n days: numberArg(args.days),\n minImpressions: numberArg(args['min-impressions']),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Striking-distance opportunities',\n target: report.site,\n status: report.source.possiblyTruncated ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible rows',\n value: formatCount(report.summary.eligibleRows),\n },\n {\n label: 'Returned rows',\n value: formatCount(report.summary.returnedRows),\n },\n { label: 'Template groups', value: formatCount(report.summary.groups) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.eligibleImpressions),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n {\n label: 'Verification',\n value: report.verification.requested ? 'Requested' : 'Off',\n },\n { label: 'Evidence', value: report.dataStatus },\n ],\n })\n printNotes('Why this matters', [\n 'These rows have a GSC average position above 10 and at most 20. Treat them as candidates for investigation, not guaranteed page-two rankings.',\n 'Groups use all eligible rows. A shared-template label is only a candidate until recurring evidence is verified across distinct URLs.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (report.groups.length) {\n printLimitedTable(\n ['Group', 'Rows', 'URLs', 'Impr', 'Avg pos', 'Scope', 'Action'],\n report.groups.map((group) => [\n truncate(group.label, 36),\n formatCount(group.rowCount),\n formatCount(group.uniqueUrls),\n formatCount(group.totalImpressions),\n formatPosition(group.impressionWeightedPosition),\n group.actionScope,\n truncate(group.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top striking-distance group actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${rowCountLabel(group.rowCount)}, ${formatCount(group.totalImpressions)} impressions`,\n action: group.recommendation.action,\n })),\n )\n }\n\n if (!report.items.length) {\n process.stdout.write(\n 'No striking-distance opportunities matched these filters.\\n',\n )\n return\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Score',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.template.label, 24),\n truncate(item.url, 48),\n formatCount(item.impressions),\n formatPercent(item.ctr),\n formatPosition(item.position),\n item.priority.score,\n formatFetchDiagnostics(item.contentVerification?.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top striking-distance actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { intro, note, outro, password, select } from '@clack/prompts'\nimport {\n BING_API_KEY_ENV,\n BING_API_KEY_SECRET,\n BingWebmasterClient,\n type BingWebmasterSite,\n bingWebmasterOverview,\n bingWebmasterSiteUrl,\n createBingWebmasterClient,\n deleteProviderSecret,\n readProviderSecret,\n SeoError,\n setClientBingSite,\n writeProviderSecret,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, stringArg } from '../../args.js'\nimport { resolveClient } from '../../selection.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n printTable,\n} from '../../utils.js'\nimport { printReportSummary } from '../output.js'\n\nfunction verifiedSites(sites: BingWebmasterSite[]): BingWebmasterSite[] {\n return sites.filter((site) => site.isVerified)\n}\n\nfunction host(value: string): string | undefined {\n if (value.startsWith('sc-domain:')) {\n return value\n .slice('sc-domain:'.length)\n .replace(/^www\\./, '')\n .toLowerCase()\n }\n try {\n return new URL(value).hostname.replace(/^www\\./, '').toLowerCase()\n } catch {\n return undefined\n }\n}\n\nexport function matchBingSite(\n projectSite: string,\n sites: BingWebmasterSite[],\n): BingWebmasterSite | undefined {\n const projectHost = host(projectSite)\n if (!projectHost) return undefined\n const matches = verifiedSites(sites).filter(\n (site) => host(site.url) === projectHost,\n )\n return matches.length === 1 ? matches[0] : undefined\n}\n\nasync function chooseSite(input: {\n explicitSite?: string\n projectSite?: string\n savedSite?: string\n sites: BingWebmasterSite[]\n json?: boolean\n}): Promise<string | undefined> {\n const verified = verifiedSites(input.sites)\n const explicit = input.explicitSite ?? input.savedSite\n if (explicit) {\n const match = verified.find((site) => site.url === explicit)\n if (!match) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n `Bing Webmaster did not return a verified site matching ${explicit}.`,\n )\n }\n return match.url\n }\n const matched = input.projectSite\n ? matchBingSite(input.projectSite, verified)\n : undefined\n if (matched) return matched.url\n if (verified.length === 1) return verified[0]?.url\n if (verified.length === 0) return undefined\n if (!canPrompt({ json: input.json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Several verified Bing sites are available. Pass --site to choose one.',\n )\n }\n return maybeExitCancelled(\n await select({\n message: 'Choose a verified Bing Webmaster site',\n options: verified.map((site) => ({ value: site.url, label: site.url })),\n }),\n )\n}\n\nconst selectionArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Verified Bing Webmaster site URL.' },\n} as const\n\nconst connectCommand = defineCommand({\n meta: {\n name: 'connect',\n description: 'Connect Bing Webmaster and attach a verified site',\n },\n args: {\n ...selectionArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n if (!canPrompt({ json })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n 'Run `seo providers bing connect` in a terminal. Agents and CI can set SEO_BING_API_KEY and run the report directly.',\n )\n }\n\n intro('Connect Bing Webmaster')\n note(\n 'Paste the API key from Bing Webmaster Tools Settings, then API Access. The key stays on this machine.',\n 'API key',\n )\n const apiKey = maybeExitCancelled(\n await password({\n message: 'Bing Webmaster API key',\n validate: (value) =>\n value?.trim() ? undefined : 'API key is required',\n }),\n )\n const client = new BingWebmasterClient({ apiKey })\n const discovered = await client.listSites()\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = await chooseSite({\n explicitSite: stringArg(args.site),\n projectSite: project?.siteUrl,\n savedSite: bingWebmasterSiteUrl(project),\n sites: discovered.sites,\n json,\n })\n if (!site) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No verified Bing Webmaster sites were found for this API key.',\n )\n }\n\n await writeProviderSecret(BING_API_KEY_SECRET, apiKey)\n const savedProject = project\n ? setClientBingSite(project.id, site)\n : undefined\n note(\n `${site}${savedProject ? ` is attached to ${savedProject.name}.` : ' is ready for direct reports.'}`,\n 'Bing connected',\n )\n outro(\n savedProject\n ? `Run seo providers bing report --project ${savedProject.id}`\n : `Run seo providers bing report --site ${site}`,\n )\n },\n})\n\nconst statusCommand = defineCommand({\n meta: { name: 'status', description: 'Show the local Bing connection' },\n args: {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const credential = await readProviderSecret({\n name: BING_API_KEY_SECRET,\n envVar: BING_API_KEY_ENV,\n })\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n const status = {\n connected: Boolean(credential),\n credentialSource: credential?.source,\n project: project\n ? {\n id: project.id,\n name: project.name,\n site: bingWebmasterSiteUrl(project),\n }\n : undefined,\n }\n if (jsonFlag(args)) {\n printJson(status)\n return\n }\n printKeyValue([\n ['Connected', status.connected ? 'yes' : 'no'],\n ['Credential', status.credentialSource ?? 'missing'],\n ['Project', status.project?.name ?? 'not selected'],\n ['Bing site', status.project?.site ?? 'not attached'],\n ])\n },\n})\n\nconst disconnectCommand = defineCommand({\n meta: {\n name: 'disconnect',\n description: 'Remove the saved Bing Webmaster credential',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n await deleteProviderSecret(BING_API_KEY_SECRET)\n const result = {\n disconnected: true,\n note: 'Saved project site mappings were kept for a later reconnect.',\n }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`${result.note}\\n`)\n },\n})\n\nconst sitesCommand = defineCommand({\n meta: { name: 'sites', description: 'List Bing Webmaster sites' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const { client, credentialSource } = await createBingWebmasterClient()\n const result = await client.listSites()\n const output = { ...result, credentialSource }\n if (jsonFlag(args)) {\n printJson(output)\n return\n }\n printTable(\n ['Site', 'Verified'],\n result.sites.map((site) => [site.url, site.isVerified ? 'yes' : 'no']),\n )\n },\n})\n\nconst reportCommand = defineCommand({\n meta: {\n name: 'report',\n description: 'Find Bing traffic, crawl, query, and page insights',\n },\n args: {\n ...selectionArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = stringArg(args.site) ?? bingWebmasterSiteUrl(project)\n if (!site) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site or connect Bing Webmaster to a saved project first.',\n )\n }\n const report = await bingWebmasterOverview({ site })\n if (json) {\n printJson(report)\n return\n }\n const traffic =\n report.traffic.status === 'unavailable' ? undefined : report.traffic.data\n const crawl =\n report.crawl.status === 'unavailable' ? undefined : report.crawl.data\n const comparison = traffic?.analysis\n printReportSummary({\n title: 'Bing Webmaster report',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.summary.warnings > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary:\n report.summary.findings > 0\n ? `${report.summary.findings} findings need review across Bing traffic and crawl evidence.`\n : 'No findings were returned by the available Bing evidence.',\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: '28-day clicks',\n value: comparison?.current.clicks ?? 'Unavailable',\n },\n {\n label: 'Click change',\n value:\n comparison?.changes.clicksPercent === null ||\n comparison?.changes.clicksPercent === undefined\n ? 'Unavailable'\n : `${comparison.changes.clicksPercent.toFixed(1)}%`,\n },\n {\n label: '28-day impressions',\n value: comparison?.current.impressions ?? 'Unavailable',\n },\n {\n label: 'Impression change',\n value:\n comparison?.changes.impressionsPercent === null ||\n comparison?.changes.impressionsPercent === undefined\n ? 'Unavailable'\n : `${comparison.changes.impressionsPercent.toFixed(1)}%`,\n },\n {\n label: 'Crawled pages',\n value: crawl?.latest?.crawledPages ?? 'Unavailable',\n },\n {\n label: '4xx responses',\n value: crawl?.latest?.code4xx ?? 'Unavailable',\n },\n { label: 'Findings', value: report.summary.findings },\n ],\n diagnostics: [\n {\n title: 'Review first',\n items: report.findings.slice(0, 5).map((finding) => ({\n status: finding.severity === 'warning' ? 'warning' : 'info',\n title: finding.title,\n explanation: finding.interpretation,\n evidence: [finding.verification],\n })),\n },\n ],\n notes: report.caveats,\n })\n },\n})\n\nexport const bingProviderCommand = defineCommand({\n meta: { name: 'bing', description: 'Connect and report on Bing Webmaster' },\n subCommands: {\n connect: connectCommand,\n status: statusCommand,\n disconnect: disconnectCommand,\n sites: sitesCommand,\n report: reportCommand,\n },\n})\n","import { intro, note, outro, password, text } from '@clack/prompts'\nimport {\n DATAFORSEO_LOGIN_ENV,\n DATAFORSEO_PASSWORD_ENV,\n DataForSeoClient,\n deleteDataForSeoCredentials,\n getProviderSpendLimits,\n getProviderSpendSummary,\n readDataForSeoCredentials,\n SeoError,\n setProviderSpendLimits,\n writeDataForSeoCredentials,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n} from '../../utils.js'\n\nfunction credentialSourceLabel(\n source: 'environment' | 'keychain' | 'file' | undefined,\n): string {\n if (source === 'keychain') return 'system keychain'\n if (source === 'file') return 'private local file'\n return source ?? 'missing'\n}\n\nfunction formatUsd(micros: number | null): string {\n return micros === null ? 'unavailable' : `$${(micros / 1_000_000).toFixed(2)}`\n}\n\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options: { notice: true },\n): number | undefined\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options?: { notice?: false },\n): number | null | undefined\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options: { notice?: boolean } = {},\n): number | null | undefined {\n if (value === undefined) return undefined\n const raw = stringArg(value)?.trim().toLowerCase()\n if (raw === 'off') return options.notice ? 0 : null\n const dollars = numberArg(value)\n if (dollars === undefined || dollars < 0 || dollars > 1_000_000) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label} must be a USD amount from 0 to 1000000, or off.`,\n )\n }\n const micros = Math.round(dollars * 1_000_000)\n if (!Number.isSafeInteger(micros)) {\n throw new SeoError('INVALID_INPUT', `${label} is too precise.`)\n }\n return micros\n}\n\nfunction boundedIntegerArg(\n value: unknown,\n label: string,\n minimum: number,\n maximum: number,\n): number | undefined {\n if (value === undefined) return undefined\n const parsed = numberArg(value)\n if (\n parsed === undefined ||\n !Number.isInteger(parsed) ||\n parsed < minimum ||\n parsed > maximum\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label} must be an integer from ${minimum} to ${maximum}.`,\n )\n }\n return parsed\n}\n\nconst connectCommand = defineCommand({\n meta: {\n name: 'connect',\n description: 'Validate and save DataForSEO API credentials',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n if (!canPrompt({ json: jsonFlag(args) })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n `Run \\`seo providers dataforseo connect\\` in a terminal. Agents and CI can set ${DATAFORSEO_LOGIN_ENV} and ${DATAFORSEO_PASSWORD_ENV}.`,\n )\n }\n\n intro('Connect DataForSEO')\n note(\n 'Use the API login and API password from DataForSEO API Access. The validation call is free; later research reports can make charged requests.',\n 'API credentials',\n )\n const login = maybeExitCancelled(\n await text({\n message: 'DataForSEO API login',\n validate: (value) =>\n value?.trim() ? undefined : 'API login is required',\n }),\n )\n const apiPassword = maybeExitCancelled(\n await password({\n message: 'DataForSEO API password',\n validate: (value) => (value ? undefined : 'API password is required'),\n }),\n )\n const credentials = { login: login.trim(), password: apiPassword }\n const account = await new DataForSeoClient({\n credentials: () => credentials,\n }).userData()\n const source = await writeDataForSeoCredentials(credentials)\n\n note(\n `${account.login} is connected with an account balance of ${formatUsd(account.balanceMicros)}.`,\n 'Connection verified',\n )\n outro(\n `Saved in the ${credentialSourceLabel(source)}. Run seo providers dataforseo status --check to verify it again.`,\n )\n },\n})\n\nconst statusCommand = defineCommand({\n meta: {\n name: 'status',\n description: 'Show the local DataForSEO connection',\n },\n args: {\n check: {\n type: 'boolean',\n default: false,\n description: 'Verify credentials with the free account endpoint.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const credentials = await readDataForSeoCredentials()\n const shouldCheck = Boolean(args.check)\n const account =\n shouldCheck && credentials\n ? await new DataForSeoClient().userData()\n : undefined\n const result = {\n connected: Boolean(credentials),\n credentialSource: credentials?.source,\n migratedLegacyCredentials: credentials?.migrated ?? false,\n liveCheck: account\n ? {\n status: 'passed' as const,\n account: account.login,\n timezone: account.timezone,\n balanceMicros: account.balanceMicros,\n observedAt: account.observedAt,\n requestCostMicros: account.requestCostMicros,\n }\n : {\n status: (shouldCheck ? 'unavailable' : 'not-requested') as\n | 'unavailable'\n | 'not-requested',\n },\n }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n ['Connected', result.connected ? 'yes' : 'no'],\n ['Credential', credentialSourceLabel(result.credentialSource)],\n [\n 'Live check',\n result.liveCheck.status === 'passed'\n ? `passed at ${result.liveCheck.observedAt}`\n : result.liveCheck.status === 'unavailable'\n ? 'not available without credentials'\n : 'not requested; pass --check to verify',\n ],\n ...(account\n ? ([\n ['Account', account.login],\n ['Balance', formatUsd(account.balanceMicros)],\n ] satisfies Array<[string, string]>)\n : []),\n ])\n },\n})\n\nconst disconnectCommand = defineCommand({\n meta: {\n name: 'disconnect',\n description: 'Remove saved DataForSEO credentials',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n await deleteDataForSeoCredentials()\n const hasEnvironmentLogin = Boolean(\n process.env[DATAFORSEO_LOGIN_ENV]?.trim(),\n )\n const hasEnvironmentPassword = Boolean(process.env[DATAFORSEO_PASSWORD_ENV])\n const result = {\n savedCredentialsRemoved: true,\n environmentCredentials:\n hasEnvironmentLogin && hasEnvironmentPassword\n ? ('active' as const)\n : hasEnvironmentLogin || hasEnvironmentPassword\n ? ('partial' as const)\n : ('missing' as const),\n note:\n hasEnvironmentLogin || hasEnvironmentPassword\n ? `Environment variables were not changed. Clear ${DATAFORSEO_LOGIN_ENV} and ${DATAFORSEO_PASSWORD_ENV} to fully disconnect.`\n : 'DataForSEO is disconnected.',\n }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`${result.note}\\n`)\n },\n})\n\nconst limitsCommand = defineCommand({\n meta: {\n name: 'limits',\n description: 'Show or change local DataForSEO spend limits',\n },\n args: {\n 'daily-notice': {\n type: 'string',\n description: 'UTC daily notice in USD, or off.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'UTC daily hard limit in USD, or off.',\n },\n 'monthly-limit': {\n type: 'string',\n description: 'UTC monthly hard limit in USD, or off.',\n },\n requests: {\n type: 'string',\n description: 'Maximum provider requests in one report run.',\n },\n rows: {\n type: 'string',\n description: 'Maximum requested provider rows in one report run.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const current = getProviderSpendLimits('dataforseo')\n const dailyNoticeMicros = usdMicrosArg(\n args['daily-notice'],\n '--daily-notice',\n { notice: true },\n )\n const dailyHardLimitMicros = usdMicrosArg(\n args['daily-limit'],\n '--daily-limit',\n )\n const monthlyHardLimitMicros = usdMicrosArg(\n args['monthly-limit'],\n '--monthly-limit',\n )\n const maxRequestsPerReport = boundedIntegerArg(\n args.requests,\n '--requests',\n 1,\n 100,\n )\n const maxRowsPerReport = boundedIntegerArg(args.rows, '--rows', 1, 100_000)\n const changed = [\n dailyNoticeMicros,\n dailyHardLimitMicros,\n monthlyHardLimitMicros,\n maxRequestsPerReport,\n maxRowsPerReport,\n ].some((value) => value !== undefined)\n const limits = changed\n ? setProviderSpendLimits('dataforseo', {\n dailyNoticeMicros:\n dailyNoticeMicros === undefined\n ? current.dailyNoticeMicros\n : dailyNoticeMicros,\n dailyHardLimitMicros:\n dailyHardLimitMicros === undefined\n ? current.dailyHardLimitMicros\n : dailyHardLimitMicros,\n monthlyHardLimitMicros:\n monthlyHardLimitMicros === undefined\n ? current.monthlyHardLimitMicros\n : monthlyHardLimitMicros,\n maxRequestsPerReport:\n maxRequestsPerReport ?? current.maxRequestsPerReport,\n maxRowsPerReport: maxRowsPerReport ?? current.maxRowsPerReport,\n })\n : current\n const result = { provider: 'dataforseo' as const, changed, limits }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n [\n 'UTC daily notice',\n limits.dailyNoticeMicros === 0\n ? 'off'\n : formatUsd(limits.dailyNoticeMicros),\n ],\n [\n 'UTC daily hard limit',\n limits.dailyHardLimitMicros === null\n ? 'off'\n : formatUsd(limits.dailyHardLimitMicros),\n ],\n [\n 'UTC monthly hard limit',\n limits.monthlyHardLimitMicros === null\n ? 'off'\n : formatUsd(limits.monthlyHardLimitMicros),\n ],\n ['Requests per report', String(limits.maxRequestsPerReport)],\n ['Rows per report', String(limits.maxRowsPerReport)],\n ])\n },\n})\n\nconst spendCommand = defineCommand({\n meta: {\n name: 'spend',\n description: 'Show local DataForSEO spend and account context',\n },\n args: {\n account: defaultTrueBooleanArg(\n 'Read account-wide context from the free endpoint.',\n 'Show only the local spend ledger.',\n ),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const local = getProviderSpendSummary('dataforseo')\n const credentials = args.account\n ? await readDataForSeoCredentials()\n : undefined\n let account:\n | {\n status: 'observed'\n account: string\n balanceMicros: number | null\n dailySpendMicros: number | null\n dailySpendPeriod: string | null\n dailyLimitMicros: number | null\n observedAt: string\n requestCostMicros: number\n semantics: string\n }\n | { status: 'unavailable'; reason: string }\n | { status: 'not-requested' }\n if (!args.account) {\n account = { status: 'not-requested' }\n } else if (!credentials) {\n account = {\n status: 'unavailable',\n reason:\n 'DataForSEO is not connected. Local spend remains available without account context.',\n }\n } else {\n try {\n const snapshot = await new DataForSeoClient().userData()\n account = {\n status: 'observed',\n account: snapshot.login,\n balanceMicros: snapshot.balanceMicros,\n dailySpendMicros: snapshot.accountDailySpendMicros,\n dailySpendPeriod: snapshot.accountDailySpendPeriod,\n dailyLimitMicros: snapshot.accountDailyLimitMicros,\n observedAt: snapshot.observedAt,\n requestCostMicros: snapshot.requestCostMicros,\n semantics:\n 'Account values include every client using these credentials. Local values include only requests recorded by this installation.',\n }\n } catch (error) {\n account = {\n status: 'unavailable',\n reason:\n error instanceof Error\n ? error.message\n : 'DataForSEO account context is unavailable.',\n }\n }\n }\n const result = { local, account }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n [\n 'Local today (UTC)',\n `${formatUsd(local.today.effectiveCostMicros)} across ${local.today.requests} requests`,\n ],\n [\n 'Local month (UTC)',\n `${formatUsd(local.month.effectiveCostMicros)} across ${local.month.requests} requests`,\n ],\n [\n 'Unknown local cost',\n formatUsd(local.month.estimatedOrUnknownCostMicros),\n ],\n [\n 'Account today',\n account.status === 'observed'\n ? formatUsd(account.dailySpendMicros)\n : account.status === 'unavailable'\n ? account.reason\n : 'not requested',\n ],\n [\n 'Account balance',\n account.status === 'observed'\n ? formatUsd(account.balanceMicros)\n : 'unavailable',\n ],\n ])\n if (account.status === 'observed')\n process.stdout.write(`${account.semantics}\\n`)\n },\n})\n\nexport const dataForSeoProviderCommand = defineCommand({\n meta: {\n name: 'dataforseo',\n description: 'Connect DataForSEO for optional search data',\n },\n subCommands: {\n connect: connectCommand,\n status: statusCommand,\n limits: limitsCommand,\n spend: spendCommand,\n disconnect: disconnectCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { bingProviderCommand } from './bing.js'\nimport { dataForSeoProviderCommand } from './dataforseo.js'\n\nexport const providersCommand = defineCommand({\n meta: { name: 'providers', description: 'Connect optional data providers' },\n subCommands: {\n bing: bingProviderCommand,\n dataforseo: dataForSeoProviderCommand,\n },\n})\n","import { countLabel, pseoAuditReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printLimitedTable,\n printNextCommand,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { pseoOptions } from './options.js'\n\nfunction formatInspection(input: {\n indexed: number\n notIndexed: number\n unknown: number\n warnings: number\n}): string {\n const total =\n input.indexed + input.notIndexed + input.unknown + input.warnings\n if (!total) return '-'\n return `${input.indexed}/${total} indexed`\n}\n\nfunction formatCrawl(input: {\n samples: unknown[]\n blockedOrFailed: number\n usable: number\n medianWordCount?: number\n weakQueryCoverage?: number\n}): string {\n if (!input.samples.length) return '-'\n const words =\n input.medianWordCount === undefined\n ? 'words ?'\n : `${formatCount(input.medianWordCount)} words`\n const weak = input.weakQueryCoverage\n ? `; ${input.weakQueryCoverage} weak coverage`\n : ''\n return `${words}; ${input.usable}/${input.samples.length} usable${weak}`\n}\n\nfunction formatCoverage(classification: string): string {\n if (classification === 'serp-framing-review') return 'wording review'\n if (classification === 'body-term-review') return 'literal term review'\n return 'covered terms'\n}\n\nfunction formatTemplateShape(\n shape: Awaited<\n ReturnType<typeof pseoAuditReport>\n >['templates'][number]['shape'],\n): string {\n const staticPath = shape.staticSegments\n .map((segment) => `/${segment.value}`)\n .join('')\n const variables = shape.variableSegments.slice(0, 3).map((segment) => {\n const examples = segment.examples.slice(0, 3).join(', ')\n return `${segment.placeholder}@${segment.index + 1}${examples ? ` (${examples})` : ''}`\n })\n return [\n staticPath ? `static ${staticPath}` : 'no fixed path prefix',\n variables.length ? `variables ${variables.join('; ')}` : 'no variables',\n ].join('; ')\n}\n\nfunction formatEntityFit(\n fit: Awaited<\n ReturnType<typeof pseoAuditReport>\n >['templates'][number]['metrics']['entityFit'],\n): string | undefined {\n if (!fit.checkedQueries) return undefined\n return `${Math.round(fit.impressionShare * 100)}% impression fit across ${countLabel(fit.checkedQueries, 'checked query/page row')}`\n}\n\nfunction formatDemandLabel(label: string): string {\n if (label.startsWith('theme: ')) {\n return `${label.slice('theme: '.length)}-related`\n }\n if (label === 'general') return 'broad'\n return label\n}\n\nfunction printTemplateDetails(\n templates: Awaited<ReturnType<typeof pseoAuditReport>>['templates'],\n): void {\n for (const template of templates.slice(0, 5)) {\n process.stdout.write(`\\n${template.signature}\\n`)\n if (template.evidence.length) {\n process.stdout.write(` Evidence: ${template.evidence.join('; ')}.\\n`)\n }\n process.stdout.write(` Shape: ${formatTemplateShape(template.shape)}\\n`)\n const entityFit = formatEntityFit(template.metrics.entityFit)\n if (entityFit) {\n process.stdout.write(` Entity fit: ${entityFit}\\n`)\n }\n const patterns = template.metrics.queryPatterns\n .slice(0, 3)\n .map(\n (pattern) =>\n `${formatDemandLabel(pattern.label)} (${formatCount(pattern.impressions)} impr: ${pattern.examples\n .slice(0, 2)\n .join('; ')})`,\n )\n if (patterns.length) {\n process.stdout.write(` Demand: ${patterns.join(' | ')}\\n`)\n }\n const topQueries = template.metrics.topQueries.slice(0, 3)\n if (topQueries.length) {\n process.stdout.write(' Top queries:\\n')\n for (const query of topQueries) {\n process.stdout.write(\n ` - ${truncate(query.query, 72)} (${formatCount(query.impressions)} impr, pos ${formatPosition(query.position)})\\n`,\n )\n }\n }\n const coverage = template.crawl.samples\n .map((sample) => sample.queryCoverage)\n .filter((item): item is NonNullable<typeof item> => Boolean(item))\n .slice(0, 3)\n if (coverage.length) {\n process.stdout.write(' Sample coverage:\\n')\n for (const item of coverage) {\n const missing = item.missingTerms.length\n ? ` missing ${item.missingTerms.slice(0, 4).join(', ')}`\n : ''\n process.stdout.write(\n ` - ${formatCoverage(item.classification)}: ${truncate(item.query, 64)} (body ${(item.bodyCoverage * 100).toFixed(0)}%${missing})\\n`,\n )\n }\n }\n const weakEntityExamples = template.metrics.entityFit.weakExamples.slice(\n 0,\n 2,\n )\n if (weakEntityExamples.length) {\n process.stdout.write(' Weak entity-fit examples:\\n')\n for (const item of weakEntityExamples) {\n const terms = item.pathTerms.slice(0, 4)\n process.stdout.write(\n ` - ${truncate(item.query, 64)} -> expected ${countLabel(terms.length, 'path term')}: ${terms.join(', ')}\\n`,\n )\n }\n }\n process.stdout.write(` Action: ${template.recommendation}\\n`)\n }\n}\n\nexport const pseoAuditCommand = defineCommand({\n meta: {\n name: 'audit',\n description:\n 'Group GSC/sitemap URLs into pSEO templates, then sample pages for crawl and index evidence',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'includeBrand', 'js', 'refresh'], {\n limit: {\n description: 'Maximum templates to show. Defaults to 25.',\n },\n includeBrand: {\n description: 'Include branded queries in template metrics.',\n },\n js: {\n description: 'Force JavaScript rendering for crawl samples.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP cache.',\n },\n }),\n sitemap: {\n type: 'string',\n description:\n 'Comma-separated sitemap URLs to include in template counts.',\n },\n 'crawl-samples': {\n type: 'string',\n description:\n 'Sample URLs to fetch per detected template. This is not crawl depth.',\n },\n 'inspect-samples': {\n type: 'string',\n description:\n 'Sample URLs to check per detected template with URL Inspection.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum discovered URLs per sitemap. Defaults to 50000.',\n },\n 'minimum-template-urls': {\n type: 'string',\n description:\n 'Minimum repeated URLs required for a template. Defaults to 3.',\n },\n 'minimum-template-share': {\n type: 'string',\n description:\n 'Minimum share of discovered URLs from 0 to 1. Defaults to 0.',\n },\n 'minimum-template-impressions': {\n type: 'string',\n description:\n 'Minimum retained page impressions for a template. Defaults to 0.',\n },\n 'brand-terms': {\n type: 'string',\n description:\n 'Comma-separated brand terms to exclude from query evidence.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const options = pseoOptions(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await pseoAuditReport({\n site: selection.site,\n ...options,\n brandTerms: options.brandTerms ?? selection.client?.brandTerms,\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Programmatic SEO audit',\n target: report.site,\n status: report.templates.length > 0 ? 'info' : 'unknown',\n summary:\n report.templates.length > 0\n ? `${formatCount(report.summary.templates)} page templates were analysed.`\n : 'No page templates could be established from the available evidence.',\n metrics: [\n { label: 'Templates', value: formatCount(report.summary.templates) },\n { label: 'GSC pages', value: formatCount(report.summary.gscPages) },\n {\n label: 'Sitemap URLs',\n value: formatCount(report.summary.sitemapUrls),\n },\n { label: 'Clicks', value: formatCount(report.summary.clicks) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n {\n label: 'Usable crawls',\n value: `${formatCount(report.summary.crawledUrls)}/${formatCount(report.summary.crawlAttempts)}`,\n },\n {\n label: 'Inspections',\n value: `${formatCount(report.summary.inspectedUrls)}/${formatCount(report.summary.inspectionAttempts)}`,\n },\n ],\n })\n printNotes('Report caveats', report.caveats)\n\n if (!report.templates.length) {\n process.stdout.write('No pSEO templates found from GSC/sitemap data.\\n')\n return\n }\n\n printLimitedTable(\n [\n 'Verdict',\n 'Template',\n 'URLs',\n 'Clicks',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Index',\n 'Crawl',\n 'Action',\n ],\n report.templates.map((template) => [\n `${template.verdict} (${template.confidence})`,\n truncate(template.signature, 28),\n formatCount(template.urlCount),\n formatCount(template.metrics.clicks),\n formatCount(template.metrics.impressions),\n formatPercent(template.metrics.ctr),\n template.metrics.position.toFixed(1),\n formatInspection(template.inspection),\n formatCrawl(template.crawl),\n truncate(template.recommendation, 72),\n ]),\n )\n\n printTemplateDetails(report.templates)\n\n if (report.warnings.length) {\n process.stdout.write(`Warnings: ${report.warnings.join('; ')}\\n`)\n }\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n printNextCommand(`seo export pseo ${target}`)\n },\n})\n","import { defineCommand } from 'citty'\nimport { pseoAuditCommand } from './audit.js'\n\nexport const pseoCommand = defineCommand({\n meta: {\n name: 'pseo',\n description:\n 'Programmatic SEO audits that cluster URL patterns and sample template pages',\n },\n subCommands: {\n audit: pseoAuditCommand,\n },\n})\n","import { readFile } from 'node:fs/promises'\nimport { SeoError, type SeoErrorCode } from '@seo/core'\nimport {\n describeReport,\n describeReportCheck,\n executeReport,\n listReports,\n REPORT_CATEGORIES,\n type ReportCategory,\n} from '@seo/mcp'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printBulletSection,\n printCallout,\n printCatalog,\n printHeading,\n printJson,\n printKeyValue,\n printParameters,\n printSection,\n} from '../utils.js'\n\nconst CATEGORY_LABELS: Record<ReportCategory, string> = {\n 'ai-search': 'AI search',\n crawl: 'Crawling and technical checks',\n diagnosis: 'Diagnosis',\n experiments: 'Experiments',\n monitoring: 'Monitoring',\n opportunities: 'Opportunities',\n reporting: 'Reporting',\n setup: 'Setup',\n workflows: 'Workflows',\n}\n\nfunction categoryArg(value: unknown): ReportCategory | undefined {\n const category = stringArg(value)\n if (!category) return undefined\n if (!REPORT_CATEGORIES.includes(category as ReportCategory)) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Unknown report category: ${category}. Choose ${REPORT_CATEGORIES.join(', ')}.`,\n )\n }\n return category as ReportCategory\n}\n\nasync function paramsArg(\n inlineValue: unknown,\n fileValue: unknown,\n): Promise<Record<string, unknown>> {\n const inline = stringArg(inlineValue)\n const file = stringArg(fileValue)\n if (inline && file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --params or --params-file, not both.',\n )\n }\n if (!inline && !file) return {}\n\n const source = inline ?? (await readFile(file ?? '', 'utf8'))\n let parsed: unknown\n try {\n parsed = JSON.parse(source)\n } catch {\n throw new SeoError('INVALID_INPUT', 'Report parameters must be valid JSON.')\n }\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new SeoError('INVALID_INPUT', 'Report parameters must be an object.')\n }\n return parsed as Record<string, unknown>\n}\n\nfunction throwToolError(result: {\n isError?: boolean\n structuredContent?: Record<string, unknown>\n}): void {\n if (!result.isError) return\n const envelope = result.structuredContent as\n | { error?: { code?: SeoErrorCode; message?: string } }\n | undefined\n throw new SeoError(\n envelope?.error?.code ?? 'INTERNAL_ERROR',\n envelope?.error?.message ?? 'The report could not be completed.',\n )\n}\n\ntype JsonSchemaProperty = {\n description?: string\n format?: string\n items?: { type?: string }\n type?: string | string[]\n}\n\nfunction reportParameters(inputSchema: unknown) {\n if (!inputSchema || typeof inputSchema !== 'object') return []\n const schema = inputSchema as {\n properties?: Record<string, JsonSchemaProperty>\n required?: string[]\n }\n const required = new Set(schema.required ?? [])\n return Object.entries(schema.properties ?? {}).map(([name, property]) => {\n const rawType = Array.isArray(property.type)\n ? property.type.join(' | ')\n : (property.type ?? 'any')\n const type =\n rawType === 'array' && property.items?.type\n ? `${property.items.type}[]`\n : property.format\n ? `${rawType} (${property.format})`\n : rawType\n return {\n name,\n type,\n required: required.has(name),\n description: property.description,\n }\n })\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: 'list',\n description: 'List report ids available to the CLI and MCP server',\n },\n args: {\n category: {\n type: 'string',\n description: `Filter by category: ${REPORT_CATEGORIES.join(', ')}.`,\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const category = categoryArg(args.category)\n const reports = listReports(category)\n if (jsonFlag(args)) {\n printJson({ reports, categories: REPORT_CATEGORIES })\n return\n }\n printCatalog(reports, {\n noun: 'report',\n categoryLabels: CATEGORY_LABELS,\n })\n process.stdout.write('\\n')\n printCallout({\n title: 'Need the detail?',\n body: 'Describe one report to see when to use it, what it needs, and what the result can prove.',\n command: 'seo reports describe <id>',\n })\n },\n})\n\nconst describeCommand = defineCommand({\n meta: {\n name: 'describe',\n description: 'Show the purpose and parameter schema for one report',\n },\n args: {\n id: {\n type: 'positional',\n required: true,\n description: 'Report id from `seo reports list`.',\n },\n check: {\n type: 'string',\n description: 'Show fix guidance for one check id from the report output.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const check = stringArg(args.check)\n if (check) {\n const report = describeReportCheck(stringArg(args.id) ?? '', check)\n if (jsonFlag(args)) {\n printJson({ report })\n return\n }\n printHeading(`${report.name}: ${report.check}`, report.checkFix.goal)\n process.stdout.write('\\n')\n printSection('Fix', report.checkFix.fix)\n process.stdout.write('\\n')\n printSection('Agent prompt', report.checkFix.prompt)\n process.stdout.write('\\n')\n printSection('Verify', report.checkFix.verify)\n if (report.checkFix.resources.length > 0) {\n process.stdout.write('\\n')\n printBulletSection(\n 'Resources',\n report.checkFix.resources.map(\n (resource) => `${resource.title}: ${resource.url}`,\n ),\n )\n }\n process.stdout.write('\\n')\n return\n }\n const report = describeReport(stringArg(args.id) ?? '')\n if (jsonFlag(args)) {\n printJson({ report })\n return\n }\n printHeading(report.name, report.description)\n process.stdout.write('\\n')\n printKeyValue([\n ['ID', report.id],\n ['Category', report.category],\n ['Outcome', report.outcome],\n ])\n process.stdout.write('\\n')\n printBulletSection('Use when', report.useWhen)\n process.stdout.write('\\n')\n printBulletSection('Avoid when', report.avoidWhen)\n process.stdout.write('\\n')\n printBulletSection('Read in order', report.readOrder)\n process.stdout.write('\\n')\n printBulletSection('Do not claim', report.doNotClaim)\n process.stdout.write('\\n')\n printSection('Verify', report.verify)\n if (report.related.length > 0) {\n process.stdout.write('\\n')\n printBulletSection(\n 'Related reports',\n report.related.map((item) => `${item.id}: ${item.reason}`),\n )\n }\n process.stdout.write('\\nParameters\\n')\n printParameters(reportParameters(report.inputSchema))\n if (report.fixableChecks) {\n process.stdout.write('\\n')\n printCallout({\n title: 'Fix a failed check',\n body: 'Get the fix steps, an agent prompt, and spec links for one check id from the report output.',\n command: `seo reports describe ${report.id} --check <check-id>`,\n })\n }\n process.stdout.write('\\n')\n printCallout({\n title: 'Need the exact schema?',\n command: `seo reports describe ${report.id} --json`,\n })\n },\n})\n\nconst runCommand = defineCommand({\n meta: {\n name: 'run',\n description: 'Run one report with JSON parameters',\n },\n args: {\n id: {\n type: 'positional',\n required: true,\n description: 'Report id from `seo reports list`.',\n },\n params: {\n type: 'string',\n description: 'Report parameters as a JSON object.',\n },\n 'params-file': {\n type: 'string',\n description: 'Read report parameters from a JSON file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const params = await paramsArg(args.params, args['params-file'])\n const result = await executeReport(id, params)\n throwToolError(result)\n\n if (jsonFlag(args)) {\n printJson(result.structuredContent ?? {})\n return\n }\n for (const item of result.content) {\n process.stdout.write(`${item.text}\\n`)\n }\n },\n})\n\nexport const reportCatalogCommand = defineCommand({\n meta: {\n name: 'reports',\n description: 'Discover and run the complete report catalog',\n },\n subCommands: {\n list: listCommand,\n describe: describeCommand,\n run: runCommand,\n },\n})\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport {\n type ReportHtmlSection,\n type ReportHtmlView,\n type ReportNarrative,\n renderReportHtml,\n SeoError,\n} from '@seo/core'\nimport { booleanArg, stringArg } from '../args.js'\n\nexport const reportHtmlArgs = {\n format: {\n type: 'string',\n description: 'Output format: terminal or html. Defaults to terminal.',\n },\n output: {\n type: 'string',\n description: 'HTML output file. A dated filename is used by default.',\n },\n view: {\n type: 'string',\n description: 'HTML detail level: client or analyst. Defaults to client.',\n },\n} as const\n\nexport type ReportHtmlOptions = {\n output?: string\n view: ReportHtmlView\n}\n\nexport function reportHtmlOptions(\n args: Record<string, unknown>,\n): ReportHtmlOptions | undefined {\n const format = stringArg(args.format) ?? 'terminal'\n if (format !== 'terminal' && format !== 'html') {\n throw new SeoError('INVALID_INPUT', 'Choose terminal or html for --format.')\n }\n if (format === 'terminal') {\n if (stringArg(args.output) || stringArg(args.view)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use --output and --view with --format html.',\n )\n }\n return undefined\n }\n if (booleanArg(args.json)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --json or --format html, not both.',\n )\n }\n\n const view = stringArg(args.view) ?? 'client'\n if (view !== 'client' && view !== 'analyst') {\n throw new SeoError('INVALID_INPUT', 'Choose client or analyst for --view.')\n }\n return { output: stringArg(args.output), view }\n}\n\nfunction slug(value: string): string {\n return value\n .toLowerCase()\n .replace(/^sc-domain:/, '')\n .replace(/^https?:\\/\\//, '')\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80)\n}\n\nexport function defaultReportHtmlPath(input: {\n reportName: string\n projectId?: string\n site: string\n date?: Date\n}): string {\n const day = (input.date ?? new Date()).toISOString().slice(0, 10)\n const identity = slug(input.projectId ?? input.site) || 'site'\n return resolve(\n process.cwd(),\n `${identity}-${slug(input.reportName)}-${day}.html`,\n )\n}\n\nexport async function writeReportHtml(input: {\n report: ReportNarrative\n reportName: string\n title: string\n options: ReportHtmlOptions\n projectId?: string\n additionalSections?: ReportHtmlSection[]\n}): Promise<string> {\n const path = resolve(\n input.options.output ??\n defaultReportHtmlPath({\n reportName: input.reportName,\n projectId: input.projectId,\n site: input.report.site,\n }),\n )\n await mkdir(dirname(path), { recursive: true })\n await writeFile(\n path,\n renderReportHtml({\n report: input.report,\n title: input.title,\n view: input.options.view,\n additionalSections: input.additionalSections,\n }),\n 'utf8',\n )\n return path\n}\n\nexport function printReportHtmlPath(path: string): void {\n process.stdout.write(`Wrote HTML report to ${path}\\n`)\n}\n","import { monthlyReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printNextCommand } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n reportFetchArgs,\n reportFetchOptions,\n reportSelectionArgs,\n reportSelectionInput,\n} from './args.js'\n\nexport const monthlyReportCommand = defineCommand({\n meta: {\n name: 'monthly-report',\n description: 'Generate a monthly SEO report narrative',\n },\n args: {\n ...reportSelectionArgs,\n month: {\n type: 'string',\n description:\n 'Report month as YYYY-MM. Defaults to the latest month with final GSC data.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n ...reportFetchArgs,\n ...reportHtmlArgs,\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = reportHtmlOptions(args)\n const selectionInput = reportSelectionInput(args)\n const selection = await resolveClientSelection({\n client: selectionInput.client,\n site: selectionInput.site,\n options: { json, refresh: selectionInput.refresh },\n })\n const report = await monthlyReport({\n site: selection.site,\n month: stringArg(args.month),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report,\n reportName: 'monthly-report',\n title: `Monthly SEO report for ${report.month}`,\n options: html,\n projectId: selection.client?.id,\n })\n printReportHtmlPath(path)\n return\n }\n process.stdout.write(`${report.markdown}\\n`)\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n const month = stringArg(args.month)\n process.stdout.write('\\n')\n printNextCommand(\n `seo export monthly ${target}${month ? ` --month ${JSON.stringify(month)}` : ''}`,\n )\n },\n})\n","import { reportNarrative } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printNextCommand } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n reportFetchArgs,\n reportFetchOptions,\n reportSelectionArgs,\n reportSelectionInput,\n} from './args.js'\n\nexport const reportNarrativeCommand = defineCommand({\n meta: {\n name: 'report-narrative',\n description: 'Generate a client-ready SEO narrative from diagnosis data',\n },\n args: {\n ...reportSelectionArgs,\n ...cliReportArgs(['days', 'recentDays'], {\n days: { description: 'Diagnosis window length in days. Defaults to 90.' },\n }),\n 'start-date': {\n type: 'string',\n description: 'Optional report start date as YYYY-MM-DD.',\n },\n 'end-date': {\n type: 'string',\n description: 'Optional report end date as YYYY-MM-DD.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n 'change-limit': {\n type: 'string',\n description: 'Maximum saved changes to measure. Defaults to 5.',\n },\n ...reportFetchArgs,\n ...reportHtmlArgs,\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = reportHtmlOptions(args)\n const selectionInput = reportSelectionInput(args)\n const selection = await resolveClientSelection({\n client: selectionInput.client,\n site: selectionInput.site,\n options: { json, refresh: selectionInput.refresh },\n })\n const report = await reportNarrative({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: numberArg(args.limit),\n changeLimit: numberArg(args['change-limit']),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report,\n reportName: 'narrative-report',\n title: 'SEO narrative report',\n options: html,\n projectId: selection.client?.id,\n })\n printReportHtmlPath(path)\n return\n }\n process.stdout.write(`${report.markdown}\\n`)\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n process.stdout.write('\\n')\n printNextCommand(`seo export narrative ${target}`)\n },\n})\n","import { explainRule, listRules } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printCatalog,\n printJson,\n printKeyValue,\n printSection,\n} from '../utils.js'\n\nexport const rulesCommand = defineCommand({\n meta: {\n name: 'rules',\n description: 'List crawler rule ids and default guidance',\n },\n args: {\n category: {\n type: 'string',\n description: 'Filter rules by category.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const category = stringArg(args.category)\n const rules = listRules().filter((rule) =>\n category ? rule.category === category : true,\n )\n\n if (jsonFlag(args)) {\n printJson({ rules })\n return\n }\n\n printCatalog(\n rules.map((rule) => ({\n id: rule.id,\n category: rule.category,\n name: `${rule.title} · ${rule.defaultSeverity}`,\n })),\n { noun: 'rule' },\n )\n },\n})\n\nexport const explainCommand = defineCommand({\n meta: {\n name: 'explain',\n description: 'Explain one crawler rule in plain English',\n },\n args: {\n rule: {\n type: 'string',\n required: true,\n description: 'Rule id to explain, for example missing_title.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const ruleId = stringArg(args.rule) ?? ''\n const rule = explainRule(ruleId)\n if (!rule) {\n throw new Error(`Unknown rule: ${ruleId}`)\n }\n\n if (jsonFlag(args)) {\n printJson(rule)\n return\n }\n\n printKeyValue([\n ['Rule', rule.id],\n ['Title', rule.title],\n ['Category', rule.category],\n ['Severity', rule.defaultSeverity],\n ])\n process.stdout.write('\\n')\n printSection('Why it matters', rule.whyItMatters)\n process.stdout.write('\\n')\n printSection('How to fix', rule.howToFix)\n process.stdout.write('\\n')\n printSection('Impact if ignored', rule.impactIfIgnored)\n process.stdout.write('\\n')\n printSection('How to verify', rule.howToVerify)\n },\n})\n","import { ensureSeoCliDirs } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, projectArg, stringArg } from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printKeyValue } from '../utils.js'\nimport { startUrlForSite } from './shared.js'\n\nfunction quote(value: string): string {\n return JSON.stringify(value)\n}\n\nexport const scheduleCommand = defineCommand({\n meta: {\n name: 'schedule',\n description: 'Print local cron entries for recurring SEO workflows',\n },\n subCommands: {\n cron: defineCommand({\n meta: {\n name: 'cron',\n description: 'Print crontab lines for local recurring SEO workflows',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL for technical-watch. Defaults from the GSC property when possible.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for index-watch.',\n },\n hour: {\n type: 'string',\n default: '9',\n description: 'Hour in local cron time. Defaults to 9.',\n },\n minute: {\n type: 'string',\n default: '0',\n description: 'Minute in local cron time. Defaults to 0.',\n },\n weekday: {\n type: 'string',\n description:\n 'Weekly technical-watch day. Defaults to client setting, then Monday.',\n },\n day: {\n type: 'string',\n description:\n 'Monthly report day. Defaults to client setting, then 1.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const site = selection.site\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const hour = numberArg(args.hour) ?? 9\n const minute = numberArg(args.minute) ?? 0\n const weekday =\n numberArg(args.weekday) ?? selection.client?.technicalWeekday ?? 1\n const day = numberArg(args.day) ?? selection.client?.reportDay ?? 1\n const identityArg = selection.client\n ? `--project ${quote(selection.client.id)}`\n : `--site ${quote(site)}`\n const watchUrls =\n stringArg(args.urls) ?? selection.client?.watchUrls.join(',')\n\n const lines = [\n {\n name: 'technical-watch',\n cron: `${minute} ${hour} * * ${weekday}`,\n command: [\n 'seo technical-watch',\n identityArg,\n startUrl ? `--url ${quote(startUrl)}` : undefined,\n watchUrls ? `--urls ${quote(watchUrls)}` : undefined,\n '--json',\n ]\n .filter(Boolean)\n .join(' '),\n },\n {\n name: 'monthly-report',\n cron: `${minute} ${hour} ${day} * *`,\n command: ['seo monthly-report', identityArg, '--json'].join(' '),\n },\n ]\n\n if (json) {\n printJson({ site, lines })\n return\n }\n\n const paths = ensureSeoCliDirs()\n printKeyValue([\n ['Property', site],\n ['Install', 'crontab -e'],\n ])\n for (const line of lines) {\n process.stdout.write(\n `${line.cron} seo logs prune --quiet; ${line.command} >> ${quote(`${paths.logDir}/${line.name}.log`)} 2>&1\\n`,\n )\n }\n },\n }),\n },\n})\n","import { importServerLog, SeoError, serverLogReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../args.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printReportSummary,\n truncate,\n} from './output.js'\n\nconst analyzeCommand = defineCommand({\n meta: {\n name: 'analyze',\n description: 'Stream a local access log into bounded crawler evidence',\n },\n args: {\n file: {\n type: 'string',\n description: 'Local combined, JSONL, or NDJSON access log.',\n required: true,\n },\n format: {\n type: 'string',\n description: 'Input format override: combined or jsonl.',\n },\n 'row-limit': {\n type: 'string',\n description: 'Maximum rows to parse. Defaults to 1000000.',\n },\n 'path-limit': {\n type: 'string',\n description:\n 'Maximum crawler and path aggregates to retain. Defaults to 25000.',\n },\n limit: {\n type: 'string',\n description: 'Maximum crawler path rows returned. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const file = stringArg(args.file)\n if (!file) throw new SeoError('INVALID_INPUT', 'Pass --file.')\n const format = stringArg(args.format)\n if (format && !['combined', 'jsonl'].includes(format)) {\n throw new SeoError('INVALID_INPUT', '--format must be combined or jsonl.')\n }\n const evidence = await importServerLog({\n file,\n format: format as 'combined' | 'jsonl' | undefined,\n rowLimit: strictNumberArg(args['row-limit'], '--row-limit'),\n pathLimit: strictNumberArg(args['path-limit'], '--path-limit'),\n })\n const report = serverLogReport({\n evidence,\n limit: strictNumberArg(args.limit, '--limit'),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Server log report',\n status:\n report.dataStatus === 'complete'\n ? report.summary.invalidRows > 0\n ? 'warning'\n : 'info'\n : 'unknown',\n summary: `${formatCount(report.summary.crawlerRows)} crawler requests found in ${formatCount(report.summary.parsedRows)} parsed requests.`,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Parsed requests',\n value: formatCount(report.summary.parsedRows),\n },\n {\n label: 'Crawler requests',\n value: formatCount(report.summary.crawlerRows),\n },\n {\n label: 'Crawler families',\n value: formatCount(report.crawlers.length),\n },\n {\n label: 'Invalid rows',\n value: formatCount(report.summary.invalidRows),\n },\n {\n label: 'Returned paths',\n value: `${formatCount(report.selection.returnedCrawlerPaths)} of ${formatCount(report.selection.availableCrawlerPaths)}`,\n },\n ],\n })\n if (report.crawlers.length) {\n process.stdout.write('\\nCrawler activity\\n')\n printLimitedTable(\n ['Crawler', 'Type', 'Requests', '4xx', '5xx'],\n report.crawlers.map((crawler) => [\n crawler.family,\n crawler.category,\n String(crawler.requests),\n String(crawler.clientError),\n String(crawler.serverError),\n ]),\n )\n }\n if (report.crawlerPaths.length) {\n process.stdout.write('\\nCrawler paths\\n')\n printLimitedTable(\n ['Crawler', 'Path', 'Requests', '4xx', '5xx'],\n report.crawlerPaths.map((row) => [\n row.family,\n truncate(row.path, 72),\n String(row.requests),\n String(row.clientError),\n String(row.serverError),\n ]),\n )\n }\n for (const warning of report.warnings) {\n process.stdout.write(`\\nWarning: ${warning}\\n`)\n }\n process.stdout.write(`\\nNote: ${report.caveats[0]}\\n`)\n },\n})\n\nexport const serverLogsCommand = defineCommand({\n meta: {\n name: 'server-logs',\n description: 'Analyze local web server access logs',\n },\n subCommands: { analyze: analyzeCommand },\n})\n","import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { SeoError } from '@seo/core'\n\n// Skills and evals ship at the package root. Both resolvers honour an explicit\n// override, otherwise walk up from the bundled CLI until the directory and its\n// README appear. Kept in its own module so the skills command and the eval\n// command can share it without importing each other.\nexport function skillsDirectory(): string {\n return resolvePackagedDirectory('skills', process.env.SEO_SKILLS_DIR)\n}\n\nexport function evalsDirectory(): string {\n return resolvePackagedDirectory('evals', process.env.SEO_EVALS_DIR)\n}\n\nfunction resolvePackagedDirectory(name: string, override?: string): string {\n if (override) return resolve(override)\n\n let current = dirname(fileURLToPath(import.meta.url))\n for (let depth = 0; depth < 6; depth += 1) {\n const candidate = join(current, name)\n if (existsSync(join(candidate, 'README.md'))) return candidate\n current = dirname(current)\n }\n\n throw new SeoError(\n 'INTERNAL_ERROR',\n `Packaged ${name} could not be found. Reinstall \\`seo\\` and try again.`,\n )\n}\n\nexport function readSkillDescription(path: string): string {\n const source = readFileSync(join(path, 'SKILL.md'), 'utf8')\n return source.match(/^description:\\s*(.+)$/m)?.[1]?.trim() ?? ''\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { basename, join } from 'node:path'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n stringArg,\n} from '../args.js'\nimport { printJson } from '../utils.js'\nimport { evalsDirectory, skillsDirectory } from './skill-paths.js'\n\nconst SCHEMA_VERSION = 1\nconst DEFAULT_AGENT = 'claude -p'\nconst DEFAULT_TIMEOUT_SECONDS = 300\nconst MAX_CONCURRENCY = 4\nconst ROUTER_SKILL = 'seo'\n\ntype EvalItem = {\n id: number\n prompt: string\n expected_output: string\n assertions: string[]\n files: string[]\n}\n\ntype EvalFile = {\n subject: string\n evals: EvalItem[]\n}\n\ntype AssertionVerdict = {\n assertion: string\n verdict: 'pass' | 'fail' | 'unjudged'\n reason?: string\n source?: 'judge verdict'\n}\n\ntype EvalStatus = 'passed' | 'failed' | 'errored' | 'unjudged'\n\ntype EvalResult = {\n id: number\n prompt: string\n status: EvalStatus\n reply: string\n error?: string\n agentDurationMs: number\n judgeDurationMs?: number\n durationMs: number\n assertions: AssertionVerdict[]\n}\n\ntype SubjectResult = {\n subject: string\n passed: number\n failed: number\n errored: number\n unjudged: number\n evals: EvalResult[]\n}\n\nfunction listSubjectFiles(): Array<{ subject: string; path: string }> {\n const root = evalsDirectory()\n return readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isFile() && entry.name.endsWith('.json'))\n .map((entry) => ({\n subject: basename(entry.name, '.json'),\n path: join(root, entry.name),\n }))\n .sort((a, b) =>\n a.subject < b.subject ? -1 : a.subject > b.subject ? 1 : 0,\n )\n}\n\nexport function loadEvalFile(subject: string, path: string): EvalFile {\n let raw: string\n try {\n raw = readFileSync(path, 'utf8')\n } catch {\n throw new SeoError('INVALID_INPUT', `Cannot read eval file for ${subject}.`)\n }\n let doc: unknown\n try {\n doc = JSON.parse(raw)\n } catch {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json is not valid JSON.`,\n )\n }\n if (!doc || typeof doc !== 'object' || Array.isArray(doc)) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must be an object.`,\n )\n }\n const record = doc as Record<string, unknown>\n if (record.subject !== subject) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must set subject to \"${subject}\".`,\n )\n }\n if (!Array.isArray(record.evals) || record.evals.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must have a non-empty evals array.`,\n )\n }\n const seen = new Set<number>()\n const evals: EvalItem[] = record.evals.map((entry, index) => {\n const item = entry as Record<string, unknown>\n const label = `${subject}.json eval ${index + 1}`\n if (!Number.isInteger(item?.id)) {\n throw new SeoError('INVALID_INPUT', `${label}: id must be an integer.`)\n }\n const id = item.id as number\n if (seen.has(id)) {\n throw new SeoError('INVALID_INPUT', `${label}: duplicate id ${id}.`)\n }\n seen.add(id)\n if (typeof item.prompt !== 'string' || item.prompt.trim().length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: prompt must be a non-empty string.`,\n )\n }\n if (\n typeof item.expected_output !== 'string' ||\n item.expected_output.trim().length === 0\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: expected_output must be a non-empty string.`,\n )\n }\n if (\n !Array.isArray(item.assertions) ||\n item.assertions.length === 0 ||\n item.assertions.some(\n (value) => typeof value !== 'string' || value.trim().length === 0,\n )\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: assertions must be a non-empty array of non-empty strings.`,\n )\n }\n if (item.files !== undefined && !Array.isArray(item.files)) {\n throw new SeoError('INVALID_INPUT', `${label}: files must be an array.`)\n }\n return {\n id,\n prompt: item.prompt,\n expected_output: item.expected_output,\n assertions: item.assertions as string[],\n files: (item.files as string[] | undefined) ?? [],\n }\n })\n return { subject, evals }\n}\n\nfunction routerSkillBody(): string {\n const path = join(skillsDirectory(), ROUTER_SKILL, 'SKILL.md')\n if (!existsSync(path)) {\n throw new SeoError(\n 'INTERNAL_ERROR',\n 'The seo router skill could not be found. Reinstall `seo` or use --no-skill.',\n )\n }\n return readFileSync(path, 'utf8')\n}\n\n// Split a command template into argv tokens without a shell. Single quotes,\n// double quotes, and backslash escapes group tokens; nothing is expanded, so a\n// substituted prompt can never break out into extra arguments or shell syntax.\nexport function tokenizeCommand(command: string): string[] {\n const tokens: string[] = []\n let current = ''\n let started = false\n let inSingle = false\n let inDouble = false\n for (let i = 0; i < command.length; i += 1) {\n const ch = command[i] as string\n if (inSingle) {\n if (ch === \"'\") inSingle = false\n else current += ch\n started = true\n continue\n }\n if (inDouble) {\n if (ch === '\"') {\n inDouble = false\n } else if (\n ch === '\\\\' &&\n (command[i + 1] === '\"' || command[i + 1] === '\\\\')\n ) {\n current += command[i + 1]\n i += 1\n } else {\n current += ch\n }\n started = true\n continue\n }\n if (ch === \"'\") {\n inSingle = true\n started = true\n continue\n }\n if (ch === '\"') {\n inDouble = true\n started = true\n continue\n }\n if (ch === '\\\\') {\n if (i + 1 < command.length) {\n current += command[i + 1]\n i += 1\n started = true\n }\n continue\n }\n if (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '\\r') {\n if (started) {\n tokens.push(current)\n current = ''\n started = false\n }\n continue\n }\n current += ch\n started = true\n }\n if (inSingle || inDouble) {\n throw new SeoError('INVALID_INPUT', 'Unbalanced quote in agent command.')\n }\n if (started) tokens.push(current)\n return tokens\n}\n\nexport function buildArgv(\n template: string,\n prompt: string,\n): { argv: string[]; usesPlaceholder: boolean } {\n const tokens = tokenizeCommand(template)\n if (tokens.length === 0) {\n throw new SeoError('INVALID_INPUT', 'Agent command must not be empty.')\n }\n const usesPlaceholder = tokens.some((token) => token.includes('{prompt}'))\n const argv = usesPlaceholder\n ? tokens.map((token) => token.split('{prompt}').join(prompt))\n : tokens\n return { argv, usesPlaceholder }\n}\n\nexport function assembleAgentPrompt(\n skillBody: string | null,\n prompt: string,\n): string {\n if (!skillBody) return prompt\n return `${skillBody.trim()}\\n\\n---\\n\\nUser request:\\n${prompt}`\n}\n\nconst JUDGE_CORRECTION =\n 'Your previous reply could not be parsed as the required JSON with one result per assertion. Reply again with STRICT JSON only, in the exact shape shown, and nothing else.'\n\nexport function buildJudgePrompt(\n prompt: string,\n reply: string,\n assertions: string[],\n corrective = false,\n): string {\n const list = assertions\n .map((entry, index) => `${index + 1}. ${entry}`)\n .join('\\n')\n const base = [\n 'You are judging whether an AI agent response satisfies a list of assertions.',\n 'Judge only against the assertions. Be strict but fair.',\n '',\n 'Original request:',\n prompt,\n '',\n 'Agent response:',\n reply,\n '',\n 'Assertions to evaluate, in this exact order:',\n '<assertions>',\n list,\n '</assertions>',\n '',\n 'Judge outcomes, not narration. An assertion about reading, checking, or',\n 'following fields or steps passes when the reply demonstrably used that',\n 'information or produced the result it protects, even if the reply never',\n 'names the field or step. Fail it only when the reply contradicts it or',\n 'shows the work was not done.',\n '',\n 'Reply with STRICT JSON only. No prose, no markdown, no code fence:',\n '{\"results\":[{\"assertion\":\"<assertion text>\",\"pass\":true,\"reason\":\"<short reason>\"}]}',\n `Return exactly ${assertions.length} result${assertions.length === 1 ? '' : 's'}, one per assertion, in the same order.`,\n ].join('\\n')\n return corrective ? `${base}\\n\\n${JUDGE_CORRECTION}` : base\n}\n\n// Pull the first complete JSON object out of a larger reply. Judges wrap JSON\n// in prose or code fences, so scan for the first balanced `{...}` and parse it.\nexport function extractJsonObject(text: string): unknown | undefined {\n const start = text.indexOf('{')\n if (start === -1) return undefined\n let depth = 0\n let inString = false\n let escaped = false\n for (let i = start; i < text.length; i += 1) {\n const ch = text[i]\n if (inString) {\n if (escaped) escaped = false\n else if (ch === '\\\\') escaped = true\n else if (ch === '\"') inString = false\n continue\n }\n if (ch === '\"') inString = true\n else if (ch === '{') depth += 1\n else if (ch === '}') {\n depth -= 1\n if (depth === 0) {\n try {\n return JSON.parse(text.slice(start, i + 1))\n } catch {\n return undefined\n }\n }\n }\n }\n return undefined\n}\n\ntype ParsedVerdicts = { verdicts: AssertionVerdict[] } | { error: string }\n\nexport function parseJudgeVerdicts(\n output: string,\n assertions: string[],\n): ParsedVerdicts {\n const parsed = extractJsonObject(output)\n if (!parsed || typeof parsed !== 'object') {\n return { error: 'Judge reply did not contain a JSON object.' }\n }\n const results = (parsed as Record<string, unknown>).results\n if (!Array.isArray(results)) {\n return { error: 'Judge reply had no results array.' }\n }\n if (results.length !== assertions.length) {\n return {\n error: `Judge returned ${results.length} results for ${assertions.length} assertions.`,\n }\n }\n const verdicts = assertions.map((assertion, index) => {\n const entry = results[index] as Record<string, unknown>\n return {\n assertion,\n verdict: entry?.pass === true ? 'pass' : 'fail',\n reason:\n typeof entry?.reason === 'string' && entry.reason.trim().length > 0\n ? entry.reason.trim()\n : 'No reason given.',\n source: 'judge verdict' as const,\n } satisfies AssertionVerdict\n })\n return { verdicts }\n}\n\ntype ProcessResult = {\n stdout: string\n stderr: string\n code: number | null\n timedOut: boolean\n spawnError?: string\n durationMs: number\n}\n\nfunction runProcess(\n argv: string[],\n options: { input?: string; timeoutMs: number },\n): Promise<ProcessResult> {\n return new Promise((resolvePromise) => {\n const start = Date.now()\n const [command, ...rest] = argv\n let child: ReturnType<typeof spawn>\n try {\n child = spawn(command as string, rest, {\n stdio: ['pipe', 'pipe', 'pipe'],\n })\n } catch (error) {\n resolvePromise({\n stdout: '',\n stderr: '',\n code: null,\n timedOut: false,\n spawnError: error instanceof Error ? error.message : String(error),\n durationMs: Date.now() - start,\n })\n return\n }\n let stdout = ''\n let stderr = ''\n let settled = false\n let timedOut = false\n let killTimer: NodeJS.Timeout | undefined\n const timer = setTimeout(() => {\n timedOut = true\n child.kill('SIGTERM')\n killTimer = setTimeout(() => {\n try {\n child.kill('SIGKILL')\n } catch {\n // process already gone\n }\n }, 2000)\n killTimer.unref()\n }, options.timeoutMs)\n const finish = (result: Omit<ProcessResult, 'durationMs'>) => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n if (killTimer) clearTimeout(killTimer)\n resolvePromise({ ...result, durationMs: Date.now() - start })\n }\n child.stdout?.on('data', (chunk) => {\n stdout += chunk\n })\n child.stderr?.on('data', (chunk) => {\n stderr += chunk\n })\n child.on('error', (error) => {\n finish({\n stdout,\n stderr,\n code: null,\n timedOut,\n spawnError: error.message,\n })\n })\n child.on('close', (code) => {\n finish({ stdout, stderr, code, timedOut })\n })\n if (child.stdin) {\n if (options.input !== undefined) child.stdin.end(options.input)\n else child.stdin.end()\n }\n })\n}\n\nasync function runCommandTemplate(\n template: string,\n prompt: string,\n timeoutMs: number,\n): Promise<ProcessResult> {\n const { argv, usesPlaceholder } = buildArgv(template, prompt)\n return runProcess(argv, {\n input: usesPlaceholder ? undefined : prompt,\n timeoutMs,\n })\n}\n\ntype RunOptions = {\n agent: string\n judge: string | null\n skillBody: string | null\n timeoutMs: number\n}\n\nasync function runSingleEval(\n item: EvalItem,\n options: RunOptions,\n): Promise<EvalResult> {\n const start = Date.now()\n const agentPrompt = assembleAgentPrompt(options.skillBody, item.prompt)\n const agentRun = await runCommandTemplate(\n options.agent,\n agentPrompt,\n options.timeoutMs,\n )\n const reply = agentRun.stdout.trim()\n\n const base = {\n id: item.id,\n prompt: item.prompt,\n reply,\n agentDurationMs: agentRun.durationMs,\n }\n\n if (agentRun.spawnError) {\n return {\n ...base,\n status: 'errored',\n error: `Agent command failed to start: ${agentRun.spawnError}`,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (agentRun.timedOut) {\n return {\n ...base,\n status: 'errored',\n error: `Agent timed out after ${Math.round(options.timeoutMs / 1000)}s.`,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (reply.length === 0) {\n return {\n ...base,\n status: 'errored',\n error: 'Agent returned no output on stdout.',\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n\n if (!options.judge) {\n return {\n ...base,\n status: 'unjudged',\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n\n let judgeDurationMs = 0\n let parseError = ''\n for (let attempt = 0; attempt < 2; attempt += 1) {\n const judgePrompt = buildJudgePrompt(\n item.prompt,\n reply,\n item.assertions,\n attempt > 0,\n )\n const judgeRun = await runCommandTemplate(\n options.judge,\n judgePrompt,\n options.timeoutMs,\n )\n judgeDurationMs += judgeRun.durationMs\n if (judgeRun.spawnError) {\n return {\n ...base,\n status: 'errored',\n error: `Judge command failed to start: ${judgeRun.spawnError}`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (judgeRun.timedOut) {\n return {\n ...base,\n status: 'errored',\n error: `Judge timed out after ${Math.round(options.timeoutMs / 1000)}s.`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n const parsed = parseJudgeVerdicts(judgeRun.stdout, item.assertions)\n if ('verdicts' in parsed) {\n const failed = parsed.verdicts.some((entry) => entry.verdict === 'fail')\n return {\n ...base,\n status: failed ? 'failed' : 'passed',\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: parsed.verdicts,\n }\n }\n parseError = parsed.error\n }\n\n return {\n ...base,\n status: 'errored',\n error: `Judge output could not be parsed after a retry: ${parseError}`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n}\n\nfunction unjudgedAssertions(assertions: string[]): AssertionVerdict[] {\n return assertions.map((assertion) => ({ assertion, verdict: 'unjudged' }))\n}\n\nasync function mapWithConcurrency<T, R>(\n items: T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n let next = 0\n const worker = async () => {\n while (true) {\n const index = next\n next += 1\n if (index >= items.length) return\n results[index] = await fn(items[index] as T, index)\n }\n }\n const size = Math.max(1, Math.min(limit, items.length))\n await Promise.all(Array.from({ length: size }, () => worker()))\n return results\n}\n\nfunction tally(evals: EvalResult[]): {\n passed: number\n failed: number\n errored: number\n unjudged: number\n} {\n const counts = { passed: 0, failed: 0, errored: 0, unjudged: 0 }\n for (const item of evals) counts[item.status] += 1\n return counts\n}\n\nfunction collectSubjects(args: Record<string, unknown>): string[] {\n const raw: string[] = []\n const first = stringArg(args.subject)\n if (first) raw.push(first)\n const rest = args._\n if (Array.isArray(rest)) {\n for (const value of rest) {\n if (typeof value === 'string' && value.length > 0) raw.push(value)\n }\n }\n return [...new Set(raw)]\n}\n\nfunction resolveSelectedSubjects(requested: string[]): Array<{\n subject: string\n path: string\n}> {\n const available = listSubjectFiles()\n if (requested.length === 0) return available\n const byName = new Map(available.map((entry) => [entry.subject, entry]))\n return requested.map((subject) => {\n const match = byName.get(subject)\n if (!match) {\n const known = available.map((entry) => entry.subject).join(', ')\n throw new SeoError(\n 'INVALID_INPUT',\n `Unknown eval subject: ${subject}.${known ? ` Known subjects: ${known}.` : ''}`,\n )\n }\n return match\n })\n}\n\nfunction renderList(json: boolean): void {\n const subjects = listSubjectFiles().map((entry) => {\n const doc = loadEvalFile(entry.subject, entry.path)\n return { subject: entry.subject, evals: doc.evals.length }\n })\n if (json) {\n printJson({ schemaVersion: SCHEMA_VERSION, subjects })\n return\n }\n if (subjects.length === 0) {\n process.stdout.write('No eval subjects found.\\n')\n return\n }\n const width = Math.max(...subjects.map((entry) => entry.subject.length))\n process.stdout.write('Eval subjects\\n')\n for (const entry of subjects) {\n const label = entry.evals === 1 ? 'eval' : 'evals'\n process.stdout.write(\n ` ${entry.subject.padEnd(width)} ${entry.evals} ${label}\\n`,\n )\n }\n}\n\nfunction statusLabel(status: EvalStatus): string {\n if (status === 'passed') return 'PASS'\n if (status === 'failed') return 'FAIL'\n if (status === 'errored') return 'ERROR'\n return 'UNJUDGED'\n}\n\nfunction renderHuman(\n subjects: SubjectResult[],\n options: { judged: boolean; agent: string; judge: string | null },\n): void {\n if (options.judged) {\n process.stdout.write(\n 'Assertion verdicts below are judge verdicts, model judgments from the judge agent, not ground truth.\\n\\n',\n )\n } else {\n process.stdout.write(\n 'Judging was skipped. Review each agent reply against the assertion checklist by hand.\\n\\n',\n )\n }\n for (const subject of subjects) {\n process.stdout.write(`# ${subject.subject}\\n`)\n for (const item of subject.evals) {\n process.stdout.write(\n `\\n[${statusLabel(item.status)}] eval ${item.id} (${item.durationMs}ms)\\n`,\n )\n process.stdout.write(` prompt: ${truncate(item.prompt, 100)}\\n`)\n if (item.error) {\n process.stdout.write(` error: ${item.error}\\n`)\n }\n if (!options.judged) {\n process.stdout.write(` reply: ${truncate(item.reply, 200)}\\n`)\n process.stdout.write(' assertions to review:\\n')\n for (const verdict of item.assertions) {\n process.stdout.write(` - [ ] ${verdict.assertion}\\n`)\n }\n continue\n }\n for (const verdict of item.assertions) {\n const mark =\n verdict.verdict === 'pass'\n ? 'pass'\n : verdict.verdict === 'fail'\n ? 'fail'\n : 'unjudged'\n process.stdout.write(` - ${mark}: ${verdict.assertion}\\n`)\n if (verdict.reason) {\n process.stdout.write(` judge verdict: ${verdict.reason}\\n`)\n }\n }\n }\n const counts = tally(subject.evals)\n process.stdout.write(\n `\\nSubject ${subject.subject}: ${counts.passed} passed, ${counts.failed} failed, ${counts.errored} errored${counts.unjudged ? `, ${counts.unjudged} unjudged` : ''}.\\n\\n`,\n )\n }\n const totals = totalCounts(subjects)\n process.stdout.write(\n `Totals: ${totals.passed} passed, ${totals.failed} failed, ${totals.errored} errored${totals.unjudged ? `, ${totals.unjudged} unjudged` : ''} across ${totals.evals} evals.\\n`,\n )\n}\n\nfunction totalCounts(subjects: SubjectResult[]): {\n passed: number\n failed: number\n errored: number\n unjudged: number\n evals: number\n} {\n const totals = { passed: 0, failed: 0, errored: 0, unjudged: 0, evals: 0 }\n for (const subject of subjects) {\n totals.passed += subject.passed\n totals.failed += subject.failed\n totals.errored += subject.errored\n totals.unjudged += subject.unjudged\n totals.evals += subject.evals.length\n }\n return totals\n}\n\nfunction truncate(value: string, max: number): string {\n const collapsed = value.replace(/\\s+/g, ' ').trim()\n return collapsed.length > max ? `${collapsed.slice(0, max - 1)}…` : collapsed\n}\n\nexport const skillsEvalCommand = defineCommand({\n meta: {\n name: 'eval',\n description:\n 'Run behaviour evals for the seo skill against a local agent and judge the results',\n },\n args: {\n subject: {\n type: 'positional',\n required: false,\n description:\n 'Eval subject (report id or job). Omit to run every subject.',\n },\n list: {\n type: 'boolean',\n default: false,\n description: 'List eval subjects with their eval counts and exit.',\n },\n id: {\n type: 'string',\n description: 'Run one eval id within a single subject.',\n },\n agent: {\n type: 'string',\n default: DEFAULT_AGENT,\n description:\n 'Agent command. Use {prompt} to place the prompt in argv, otherwise it is sent on stdin.',\n },\n 'judge-agent': {\n type: 'string',\n description: 'Judge command. Defaults to the same command as --agent.',\n },\n judge: defaultTrueBooleanArg(\n 'Judge assertions with an agent.',\n 'Skip judging and print replies with an assertion checklist.',\n ),\n skill: defaultTrueBooleanArg(\n 'Send the seo router skill as context before the prompt.',\n 'Omit the seo router skill context.',\n ),\n timeout: {\n type: 'string',\n default: String(DEFAULT_TIMEOUT_SECONDS),\n description: 'Timeout in seconds per agent or judge call.',\n },\n concurrency: {\n type: 'string',\n default: '1',\n description: `Evals to run in parallel (max ${MAX_CONCURRENCY}).`,\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n\n if (args.list === true) {\n renderList(json)\n return\n }\n\n const requested = collectSubjects(args)\n const selected = resolveSelectedSubjects(requested)\n\n const idFilter = numberArg(args.id)\n if (idFilter !== undefined && selected.length !== 1) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--id needs exactly one subject. Name the subject to filter.',\n )\n }\n\n const timeoutSeconds = numberArg(args.timeout) ?? DEFAULT_TIMEOUT_SECONDS\n if (!(timeoutSeconds > 0)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--timeout must be a positive number of seconds.',\n )\n }\n const concurrency = Math.max(\n 1,\n Math.min(MAX_CONCURRENCY, numberArg(args.concurrency) ?? 1),\n )\n\n const agent = stringArg(args.agent) ?? DEFAULT_AGENT\n const judgeEnabled = args.judge !== false\n const judge = judgeEnabled\n ? (stringArg(args['judge-agent']) ?? agent)\n : null\n const skillBody = args.skill === false ? null : routerSkillBody()\n\n const runOptions: RunOptions = {\n agent,\n judge,\n skillBody,\n timeoutMs: timeoutSeconds * 1000,\n }\n\n const subjectResults: SubjectResult[] = []\n for (const entry of selected) {\n const doc = loadEvalFile(entry.subject, entry.path)\n let items = doc.evals\n if (idFilter !== undefined) {\n items = items.filter((item) => item.id === idFilter)\n if (items.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `No eval with id ${idFilter} in subject ${entry.subject}.`,\n )\n }\n }\n if (!json) {\n process.stderr.write(\n `Running ${items.length} eval${items.length === 1 ? '' : 's'} for ${entry.subject}...\\n`,\n )\n }\n const evals = await mapWithConcurrency(items, concurrency, (item) =>\n runSingleEval(item, runOptions),\n )\n const counts = tally(evals)\n subjectResults.push({ subject: entry.subject, ...counts, evals })\n }\n\n const totals = totalCounts(subjectResults)\n const failed = totals.failed > 0 || totals.errored > 0\n\n if (json) {\n printJson({\n schemaVersion: SCHEMA_VERSION,\n agent,\n judge,\n judged: judge !== null,\n skillContext: skillBody !== null,\n timeoutSeconds,\n concurrency,\n subjects: subjectResults,\n totals,\n })\n } else {\n renderHuman(subjectResults, { judged: judge !== null, agent, judge })\n }\n\n if (failed) process.exitCode = 1\n },\n})\n","import { existsSync, readdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printCallout,\n printHeading,\n printJson,\n printKeyValue,\n} from '../utils.js'\nimport { installSeoSkill } from './skill-install.js'\nimport { readSkillDescription, skillsDirectory } from './skill-paths.js'\nimport { skillsEvalCommand } from './skills-eval.js'\n\ntype SkillInfo = {\n name: string\n description: string\n path: string\n}\n\nfunction listSkills(): SkillInfo[] {\n const root = skillsDirectory()\n return readdirSync(root, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(root, entry.name, 'SKILL.md')),\n )\n .map((entry) => ({\n name: entry.name,\n description: readSkillDescription(join(root, entry.name)),\n path: join(root, entry.name),\n }))\n .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n}\n\nfunction selectedSkill(name?: string): SkillInfo[] {\n const skills = listSkills()\n if (!name) return skills\n const skill = skills.find((entry) => entry.name === name)\n if (!skill) {\n throw new SeoError('INVALID_INPUT', `Unknown skill: ${name}.`)\n }\n return [skill]\n}\n\nconst listCommand = defineCommand({\n meta: { name: 'list', description: 'Show the packaged SEO skill' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const skills = listSkills()\n if (jsonFlag(args)) {\n printJson({ skills })\n return\n }\n printHeading('SEO skill', 'Packaged with this CLI.')\n process.stdout.write('\\n')\n for (const skill of skills) {\n printKeyValue([\n ['Name', skill.name],\n [\n 'Purpose',\n 'Helps agents choose and run the right SEO audit or report.',\n ],\n ['Path', skill.path],\n ])\n }\n process.stdout.write('\\n')\n printCallout({\n title: 'Add it to an agent',\n body: 'Run setup to install the skill and connect your first site.',\n command: 'seo start',\n })\n },\n})\n\nconst pathCommand = defineCommand({\n meta: { name: 'path', description: 'Print a packaged agent skill path' },\n args: {\n name: {\n type: 'positional',\n description: 'Skill name. Omit it for the skill directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const name = stringArg(args.name)\n const path = name ? selectedSkill(name)[0]?.path : skillsDirectory()\n if (jsonFlag(args)) {\n printJson({ name, path })\n } else {\n process.stdout.write(`${path}\\n`)\n }\n },\n})\n\nconst installCommand = defineCommand({\n meta: {\n name: 'install',\n description: 'Install the SEO skill for coding agents',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const json = jsonFlag(args)\n const result = installSeoSkill({ quiet: json })\n if (json) {\n printJson(result)\n if (result.status === 'failed') process.exitCode = 1\n return\n }\n if (result.status === 'failed') {\n throw new SeoError(\n 'INTERNAL_ERROR',\n `Skill install failed: ${result.error}`,\n )\n }\n process.stdout.write(\n 'SEO skill installed. Agents that support skills can discover it now.\\n',\n )\n },\n})\n\nexport const skillsCommand = defineCommand({\n meta: {\n name: 'skill',\n description: 'Inspect the packaged SEO skill and run its evals',\n },\n subCommands: {\n list: listCommand,\n path: pathCommand,\n install: installCommand,\n eval: skillsEvalCommand,\n },\n})\n","import { rmSync } from 'node:fs'\nimport { cancel, confirm } from '@clack/prompts'\nimport {\n deleteTokens,\n getCacheStats,\n getPrivacySnapshot,\n getSeoCliPaths,\n listSearchUpdates,\n listSites,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../args.js'\nimport {\n canPrompt,\n formatBytes,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n printSummaryList,\n printTable,\n} from '../utils.js'\n\nexport const privacyCommand = defineCommand({\n meta: {\n name: 'privacy',\n description: 'Show local config, token, cache, and log storage paths',\n },\n run: async () => {\n const snapshot = getPrivacySnapshot()\n const stats = getCacheStats()\n printKeyValue(\n snapshot.map((item) => [\n item.label,\n `${item.path} · ${formatBytes(item.sizeBytes)} · ${item.mode}`,\n ]),\n )\n process.stdout.write('\\n')\n printKeyValue(\n Object.entries(stats.counts).map(([key, value]) => [key, String(value)]),\n )\n },\n})\n\nexport const resetCommand = defineCommand({\n meta: {\n name: 'reset',\n description: 'Delete local seo config, tokens, cache, and logs',\n },\n args: {\n yes: {\n type: 'boolean',\n default: false,\n description: 'Confirm deletion without prompting.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const paths = getSeoCliPaths()\n const json = jsonFlag(args)\n if (!args.yes && !canPrompt({ json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Cannot prompt here. Pass --yes to confirm reset.',\n )\n }\n const approved = args.yes\n ? true\n : maybeExitCancelled(\n await confirm({\n message: 'Delete config, tokens, cache, and logs?',\n initialValue: false,\n }),\n )\n if (!approved) {\n cancel('Reset aborted.')\n return\n }\n await deleteTokens()\n rmSync(paths.configDir, { recursive: true, force: true })\n rmSync(paths.cacheDir, { recursive: true, force: true })\n rmSync(paths.logDir, { recursive: true, force: true })\n if (json) {\n printJson({ reset: true })\n } else {\n process.stdout.write('Reset complete.\\n')\n }\n },\n})\n\nexport const sitesCommand = defineCommand({\n meta: {\n name: 'sites',\n description:\n 'List Search Console properties available to this Google login',\n },\n args: {\n json: { type: 'boolean', default: false },\n refresh: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const sites = await listSites(booleanArg(args.refresh))\n if (jsonFlag(args)) {\n printJson({ sites })\n return\n }\n printTable(\n ['Property', 'Permission'],\n sites.map((site) => [site.siteUrl, site.permissionLevel ?? 'unknown']),\n )\n },\n})\n\nexport const updatesCommand = defineCommand({\n meta: {\n name: 'updates',\n description: 'List official Google Search Status ranking updates',\n },\n args: {\n product: { type: 'string', default: 'Ranking' },\n limit: { type: 'string', default: '10' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const updates = await listSearchUpdates({\n product: stringArg(args.product),\n limit: numberArg(args.limit),\n })\n if (jsonFlag(args)) {\n printJson({ updates })\n return\n }\n printSummaryList(\n updates.map((update) => ({\n title: update.name,\n meta: [\n update.type,\n update.status,\n `${update.start.slice(0, 10)} to ${update.end?.slice(0, 10) ?? 'present'}`,\n ],\n })),\n { empty: 'No matching Google Search updates.' },\n )\n },\n})\n","import {\n getTelemetryStatus,\n setTelemetryEnabled,\n type TelemetryDisableReason,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { printJson, printKeyValue } from '../utils.js'\n\nconst reasonLabels: Record<TelemetryDisableReason, string> = {\n ci: 'disabled automatically in CI or tests',\n do_not_track: 'disabled by DO_NOT_TRACK',\n environment: 'disabled by a telemetry environment variable',\n local_setting: 'disabled in local settings',\n invalid_state: 'disabled because the local state file is invalid',\n}\n\nfunction statusOutput(status: ReturnType<typeof getTelemetryStatus>) {\n return {\n enabled: status.enabled,\n ...(status.reason ? { reason: status.reason } : {}),\n stateFile: status.stateFile,\n ...(status.state\n ? {\n firstRunAt: status.state.firstRunAt,\n cohort: status.state.cohort,\n sentMilestones: status.state.sentMilestones,\n }\n : {}),\n }\n}\n\nfunction printStatus(\n status: ReturnType<typeof getTelemetryStatus>,\n json: boolean,\n): void {\n const output = statusOutput(status)\n if (json) {\n printJson(output)\n return\n }\n printKeyValue([\n ['Anonymous telemetry', status.enabled ? 'enabled' : 'disabled'],\n ['Reason', status.reason ? reasonLabels[status.reason] : 'local setting'],\n ['State file', status.stateFile],\n ['Install cohort', status.state?.cohort ?? 'not created'],\n ])\n process.stdout.write(\n '\\nOnly tool usage is sent. URLs, report data, Google data, and identifiers are never sent.\\n',\n )\n process.stdout.write('Details: https://seoskill.dev/telemetry\\n')\n}\n\nconst jsonArg = {\n type: 'boolean' as const,\n default: false,\n description: 'Print machine-readable JSON.',\n}\n\nexport const telemetryCommand = defineCommand({\n meta: {\n name: 'telemetry',\n description: 'Check or change anonymous usage telemetry',\n },\n subCommands: {\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show whether anonymous usage telemetry is enabled',\n },\n args: { json: jsonArg },\n run: async ({ args }) =>\n printStatus(getTelemetryStatus(), jsonFlag(args)),\n }),\n enable: defineCommand({\n meta: {\n name: 'enable',\n description: 'Enable anonymous usage telemetry in local settings',\n },\n args: { json: jsonArg },\n run: async ({ args }) => {\n printStatus(setTelemetryEnabled(true), jsonFlag(args))\n },\n }),\n disable: defineCommand({\n meta: {\n name: 'disable',\n description: 'Disable anonymous usage telemetry in local settings',\n },\n args: { json: jsonArg },\n run: async ({ args }) => {\n printStatus(setTelemetryEnabled(false), jsonFlag(args))\n },\n }),\n },\n})\n","import { readFile } from 'node:fs/promises'\nimport { crawlImplementationQueueWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails } from '../output.js'\nimport { startUrlForSite } from '../shared.js'\nimport { printWorkflow } from './output.js'\n\nexport const crawlQueueCommand = defineCommand({\n meta: {\n name: 'crawl-queue',\n description: 'Run a crawl and return a ranked implementation queue',\n },\n args: {\n crawlUrl: {\n type: 'positional',\n required: false,\n description: 'Start URL to crawl.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Optional when --project has a saved crawl URL.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for joining page metrics.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID for landing-page sessions. Defaults from --project when saved.',\n },\n mode: {\n type: 'string',\n description:\n 'Crawl mode: site, page, list, or sitemap. Defaults to site.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for list mode.',\n },\n 'urls-file': {\n type: 'string',\n description: 'File with one URL per line for list mode.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 500.',\n },\n 'max-depth': {\n type: 'string',\n description: 'Maximum click depth. Defaults to 16.',\n },\n concurrency: {\n type: 'string',\n description: 'Parallel page fetches. Defaults to 8.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n include: {\n type: 'string',\n description: 'Comma-separated URL patterns to include.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n limit: {\n type: 'string',\n description: 'Maximum queue items to print. Defaults to 25.',\n },\n 'no-sitemap': {\n type: 'boolean',\n default: false,\n description: 'Do not seed URLs from sitemap.xml.',\n },\n 'no-robots': {\n type: 'boolean',\n default: false,\n description: 'Do not skip URLs disallowed by robots.txt.',\n },\n 'no-external': {\n type: 'boolean',\n default: false,\n description: 'Do not check external links.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = projectArg(args)\n const urls = await urlListArgs(args)\n const explicitUrl = crawlUrlArg(args)\n const selection =\n stringArg(args.site) || project || (!explicitUrl && !urls.length)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const crawlUrl =\n explicitUrl ??\n selection?.client?.startUrl ??\n (selection?.site ? startUrlForSite(selection.site) : undefined) ??\n urls[0]\n if (!crawlUrl) {\n throw new Error(\n 'No crawl URL selected. Pass a URL, --url, or use --project with a saved crawl URL.',\n )\n }\n\n const report = await crawlImplementationQueueWorkflow({\n url: crawlUrl,\n projectId: selection?.client?.id,\n site: selection?.site,\n mode: crawlModeArg(args.mode) ?? (urls.length ? 'list' : undefined),\n urls,\n maxPages: numberArg(args['max-pages']),\n maxDepth: numberArg(args['max-depth']),\n concurrency: numberArg(args.concurrency),\n refresh: booleanArg(args.refresh),\n fetchRate: fetchRateArg({\n ...args,\n 'fetch-concurrency': args.concurrency,\n }),\n include: csvArg(args.include),\n exclude: csvArg(args.exclude),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection?.client?.analytics.google?.propertyId,\n useSitemap: !negatedBooleanArg(args, 'sitemap'),\n respectRobots: !negatedBooleanArg(args, 'robots'),\n checkExternal: !negatedBooleanArg(args, 'external'),\n js: Boolean(booleanArg(args.js)),\n limit: numberArg(args.limit),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printWorkflow(report)\n printTable(\n ['Rank', 'Score', 'Rule', 'Severity', 'Affected', 'Target', 'Action'],\n report.output.queue.map((item, index) => [\n index + 1,\n item.score,\n item.ruleId,\n item.severity,\n item.affectedUrls,\n item.target,\n item.action,\n ]),\n )\n printActionDetails(\n 'Implementation queue details',\n report.output.queue.map((item) => ({\n label: `${item.ruleId} (${item.affectedUrls} URLs)`,\n context: `${item.severity}, score ${item.score}`,\n action: `${item.action} Verify with: ${item.verification.command}`,\n })),\n )\n },\n})\n\nfunction crawlModeArg(value: unknown) {\n const mode = stringArg(value)\n if (!mode) return undefined\n if (['site', 'page', 'list', 'sitemap'].includes(mode)) {\n return mode as 'site' | 'page' | 'list' | 'sitemap'\n }\n throw new Error('Mode must be one of: site, page, list, sitemap.')\n}\n\nfunction crawlUrlArg(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.crawlUrl)\n const flag = stringArg(args.url)\n if (positional && flag && positional !== flag) {\n throw new Error('Use either a URL argument or --url, not both.')\n }\n return positional ?? flag\n}\n\nasync function urlListArgs(args: Record<string, unknown>): Promise<string[]> {\n const urls = csvArg(args.urls) ?? []\n const file = stringArg(args['urls-file'])\n if (file) urls.push(...parseUrlList(await readFile(file, 'utf8')))\n return [...new Set(urls)]\n}\n\nfunction parseUrlList(value: string): string[] {\n return value\n .split(/[\\n,]/)\n .map((item) => item.trim())\n .filter((item) => item && !item.startsWith('#'))\n}\n","import {\n type CrawlReport,\n diagnosePropertyWorkflow,\n type ReportHtmlSection,\n resolveTechnicalBaseline,\n reviewObservations,\n SeoError,\n type TechnicalBaseline,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { truncate } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { startUrlForSite } from '../shared.js'\nimport { printWorkflow } from './output.js'\n\ntype DiagnoseWorkflowReport = Awaited<\n ReturnType<typeof diagnosePropertyWorkflow>\n>\n\nfunction compactMainReportJson(\n report: DiagnoseWorkflowReport,\n workflowName?: string,\n) {\n const { narrative } = report.output\n const { diagnosis } = narrative\n\n return {\n ...report,\n ...(workflowName ? { workflow: workflowName } : {}),\n output: {\n narrative: {\n site: narrative.site,\n generatedAt: narrative.generatedAt,\n dataStatus: narrative.dataStatus,\n periodDays: narrative.periodDays,\n period: narrative.period,\n headline: narrative.headline,\n caveats: narrative.caveats,\n sections: narrative.sections,\n priorities: narrative.priorities,\n diagnosis: {\n site: diagnosis.site,\n generatedAt: diagnosis.generatedAt,\n dataStatus: diagnosis.dataStatus,\n summary: diagnosis.summary,\n skippedSections: diagnosis.skippedSections,\n partialReasons: diagnosis.partialReasons,\n priorities: diagnosis.priorities,\n },\n },\n },\n }\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_./:@-]+$/.test(value)) {\n return value\n }\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\nfunction siteForDirectUrl(url: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new SeoError('INVALID_INPUT', 'Pass a valid absolute URL with --url.')\n }\n}\n\nfunction addFollowup(\n commands: Array<{ command: string; why: string }>,\n command: string,\n why: string,\n): void {\n if (commands.some((item) => item.command === command)) {\n return\n }\n commands.push({ command, why })\n}\n\nfunction crawlDataSourceLines(\n dataSources: CrawlReport['dataSources'],\n): string[] {\n if (!dataSources) return []\n\n const sourceLine = (input: {\n label: string\n status: string\n joinedPages: number\n totalPages: number\n window?: { days: number }\n warning?: string\n }): string => {\n const range = input.window ? ` in the last ${input.window.days} days` : ''\n const coverage = `for ${input.joinedPages} of ${input.totalPages} crawled URLs`\n\n if (input.status === 'skipped') return `${input.label}: not connected.`\n if (input.status === 'unavailable') {\n return `${input.label}: unavailable. ${input.warning ?? 'No data was joined.'}`\n }\n if (input.status === 'partial') {\n return `${input.label}: partial data ${coverage}${range}. ${input.warning ?? ''}`.trim()\n }\n if (input.status === 'none') {\n return `${input.label}: no matching crawled URLs${range}.`\n }\n return `${input.label}: joined ${coverage}${range}.`\n }\n\n return [\n sourceLine({\n label: 'Search Console',\n status: dataSources.searchConsole.status,\n joinedPages: Math.max(\n dataSources.searchConsole.joinedMetricPages,\n dataSources.searchConsole.joinedQueryPages,\n ),\n totalPages: dataSources.searchConsole.totalPages,\n window: dataSources.searchConsole.window,\n warning: dataSources.searchConsole.warning,\n }),\n sourceLine({\n label: 'Google Analytics',\n status: dataSources.analytics.status,\n joinedPages: dataSources.analytics.joinedPages,\n totalPages: dataSources.analytics.totalPages,\n window: dataSources.analytics.window,\n warning: dataSources.analytics.warning,\n }),\n ]\n}\n\nfunction technicalSection(baseline: TechnicalBaseline) {\n const report = baseline.report\n if (!report) {\n return {\n status: baseline.status,\n ...(baseline.reason ? { reason: baseline.reason } : {}),\n }\n }\n return {\n status: baseline.status,\n ...(baseline.reason ? { reason: baseline.reason } : {}),\n reportId: report.id,\n generatedAt: report.generatedAt,\n crawlStatus: report.status,\n capped: report.summary.pageLimitReached,\n maxPages: report.config.maxPages,\n searchDataJoined:\n (report.dataSources?.searchConsole.joinedMetricPages ?? 0) > 0 ||\n (report.dataSources?.searchConsole.joinedQueryPages ?? 0) > 0,\n dataSources: report.dataSources,\n summary: report.summary,\n topFixes: topFixes(report, { limit: 5 }),\n reviewObservations: reviewObservations(report, { limit: 5 }),\n }\n}\n\nfunction compactTechnicalFinding(finding: ReturnType<typeof topFixes>[number]) {\n return {\n ruleId: finding.ruleId,\n title: finding.title,\n category: finding.category,\n severity: finding.severity,\n recommendation: finding.recommendation,\n count: finding.count,\n sampleUrls: finding.sampleUrls.slice(0, 3),\n score: finding.score,\n scoreFactors: finding.scoreFactors,\n whyThisRanks: finding.whyThisRanks,\n detailsCommand: `seo explain --rule ${finding.ruleId}`,\n }\n}\n\nfunction compactTechnicalSection(section: ReturnType<typeof technicalSection>) {\n if (!('topFixes' in section)) return section\n\n return {\n ...section,\n topFixes: section.topFixes.slice(0, 3).map(compactTechnicalFinding),\n reviewObservations: section.reviewObservations\n .slice(0, 3)\n .map(compactTechnicalFinding),\n }\n}\n\nfunction printTechnicalSection(\n section: ReturnType<typeof technicalSection>,\n options: { providerFree?: boolean } = {},\n): void {\n if (!('topFixes' in section)) {\n process.stdout.write(\n `\\nTechnical crawl evidence: ${section.reason ?? section.status}\\n`,\n )\n return\n }\n\n const coverage = section.status === 'reused' ? 'saved' : 'new'\n process.stdout.write(`\\nTechnical crawl evidence (${coverage})\\n`)\n if (section.reason) process.stdout.write(`${section.reason}\\n`)\n if (section.capped) {\n process.stdout.write(\n `Coverage is capped at ${section.maxPages} pages. Run \\`seo crawl\\` for a broader investigation.\\n`,\n )\n }\n if (!options.providerFree) {\n for (const line of crawlDataSourceLines(section.dataSources)) {\n process.stdout.write(`${line}\\n`)\n }\n }\n if (!section.topFixes.length) {\n process.stdout.write('No prioritised technical fixes were found.\\n')\n if (section.reviewObservations.length) {\n process.stdout.write(\n `${section.reviewObservations.length} review observation${section.reviewObservations.length === 1 ? '' : 's'} need confirmation before they become implementation work.\\n`,\n )\n }\n return\n }\n process.stdout.write(\n options.providerFree\n ? '\\nPrioritised technical fixes\\n'\n : section.searchDataJoined\n ? '\\nTechnical fixes with search value\\n'\n : '\\nTechnical fixes (no Search Console data joined)\\n',\n )\n if (!section.searchDataJoined) {\n printTable(\n ['#', 'Rule', 'Severity', 'Affected URLs', 'Verify'],\n section.topFixes.map((fix, index) => [\n index + 1,\n fix.ruleId,\n fix.severity,\n fix.count,\n truncate(fix.howToVerify, 72),\n ]),\n )\n } else {\n printTable(\n ['Score', 'Rule', 'Severity', 'Search value', 'Verify'],\n section.topFixes.map((fix) => [\n fix.score,\n fix.ruleId,\n fix.severity,\n `${fix.scoreFactors.clicks} clicks / ${fix.scoreFactors.sessions} sessions / ${fix.scoreFactors.conversions} conv.`,\n truncate(fix.howToVerify, 72),\n ]),\n )\n }\n if (section.reviewObservations.length) {\n process.stdout.write(\n `\\n${section.reviewObservations.length} review observation${section.reviewObservations.length === 1 ? '' : 's'} were kept out of this action queue.\\n`,\n )\n }\n}\n\nfunction printSkippedProviderSections(\n section: ReturnType<typeof technicalSection>,\n): void {\n process.stdout.write('\\nProvider-backed sections skipped\\n')\n const observedLines =\n 'dataSources' in section ? crawlDataSourceLines(section.dataSources) : []\n const lines = observedLines.length\n ? observedLines\n : ['Search Console: not connected.', 'Google Analytics: not connected.']\n for (const line of lines) {\n process.stdout.write(`${line}\\n`)\n }\n process.stdout.write(\n 'Run `seo start` when you want traffic, query, ranking, and analytics evidence added to the report.\\n',\n )\n}\n\nfunction mainReportHtmlSections(input: {\n technicalCrawl?: ReturnType<typeof technicalSection>\n followups?: Array<{ command: string; why: string }>\n}): ReportHtmlSection[] {\n const sections: ReportHtmlSection[] = []\n const technical = input.technicalCrawl\n if (technical) {\n if ('topFixes' in technical) {\n sections.push({\n title: 'Technical crawl evidence',\n summary: `${technical.summary.crawledUrls} pages were included in the ${technical.status === 'reused' ? 'saved' : 'new'} crawl evidence.`,\n items: [\n ...technical.topFixes.map(\n (fix) =>\n `${fix.ruleId}: ${fix.title}. ${fix.count} affected URLs. ${fix.recommendation}`,\n ),\n ...crawlDataSourceLines(technical.dataSources),\n ],\n })\n } else {\n sections.push({\n title: 'Technical crawl evidence',\n summary:\n technical.reason ?? `Technical evidence was ${technical.status}.`,\n items: [],\n })\n }\n }\n if (input.followups?.length) {\n sections.push({\n title: 'Recommended next commands',\n items: input.followups.map((item) => `${item.command}: ${item.why}`),\n })\n }\n return sections\n}\n\nfunction technicalFirstSummary(\n section: ReturnType<typeof technicalSection>,\n): string {\n if (!('topFixes' in section)) {\n return `Technical crawl evidence was ${section.status}. Search Console and Google Analytics sections were skipped because they are not connected.`\n }\n\n const source = section.status === 'reused' ? 'Loaded' : 'Completed'\n const pages = section.summary.crawledUrls\n return `${source} a technical crawl of ${pages} ${pages === 1 ? 'page' : 'pages'}. Search Console and Google Analytics sections were skipped because they are not connected.`\n}\n\nfunction technicalWorkflowStep(section: ReturnType<typeof technicalSection>): {\n tool: string\n status: 'completed' | 'skipped'\n summary: string\n} {\n if (!('topFixes' in section)) {\n return {\n tool: 'seo_crawl',\n status: 'skipped',\n summary:\n section.reason ?? `Technical crawl evidence was ${section.status}.`,\n }\n }\n\n const pages = section.summary.crawledUrls\n return {\n tool: 'seo_crawl',\n status: 'completed',\n summary: `${section.status === 'reused' ? 'Loaded' : 'Completed'} technical evidence for ${pages} crawled ${pages === 1 ? 'page' : 'pages'}.`,\n }\n}\n\nexport function reportFollowups(\n report: DiagnoseWorkflowReport,\n input: {\n crawlStartUrl?: string\n projectId?: string\n technicalBaselineStatus?: TechnicalBaseline['status']\n searchDataAvailable?: boolean\n } = {},\n) {\n if (input.searchDataAvailable === false) {\n const commands: Array<{ command: string; why: string }> = []\n if (\n input.crawlStartUrl &&\n input.technicalBaselineStatus !== 'created' &&\n input.technicalBaselineStatus !== 'refreshed' &&\n input.technicalBaselineStatus !== 'reused'\n ) {\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --health`,\n 'Run the fast sitemap response and access gate before fetching page bodies.',\n )\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --save`,\n 'Create the technical crawl that this report needs before opening a page-level follow-up.',\n )\n } else if (input.crawlStartUrl) {\n addFollowup(\n commands,\n `seo audit-page --url ${shellArg(input.crawlStartUrl)}`,\n 'Inspect one important page in detail after the site-level crawl.',\n )\n }\n addFollowup(\n commands,\n 'seo start',\n 'Connect Search Console when you want traffic, query, and ranking evidence alongside the crawl.',\n )\n return commands\n }\n\n const identity = input.projectId\n ? `--project ${shellArg(input.projectId)}`\n : `--site ${shellArg(report.site)}`\n const diagnosis = report.output.narrative.diagnosis\n const days = diagnosis.decay.rangeDays\n const commands: Array<{ command: string; why: string }> = []\n const skippedNames = new Set(\n (diagnosis.skippedSections ?? []).map((section) => section.section),\n )\n\n addFollowup(\n commands,\n `seo refresh-priorities ${identity} --days ${days} --verify-content --limit 25`,\n 'Turn the report into a ranked action queue with content checks.',\n )\n\n if (diagnosis.decay.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo decaying ${identity} --days ${days} --limit 25`,\n 'Inspect query/page declines observed in both retained-row windows.',\n )\n }\n\n if (diagnosis.cannibalization.items.length > 0) {\n addFollowup(\n commands,\n `seo cannibal ${identity} --days ${days} --limit 25`,\n 'Find queries split across competing URLs.',\n )\n }\n\n if (diagnosis.quickWins.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo quick-wins ${identity} --days ${days} --verify-content --verify-limit 5`,\n 'Review average-position rows below their heuristic CTR target with optional page evidence.',\n )\n }\n\n if (diagnosis.strikingDistance.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo second-page ${identity} --days ${days} --verify-content --verify-limit 5`,\n 'Work pages sitting just outside page-one rankings.',\n )\n }\n\n if (\n skippedNames.has('traffic anomaly') ||\n skippedNames.has('update correlation')\n ) {\n addFollowup(\n commands,\n `seo quick-wins ${identity} --days ${days} --min-impressions 10 --verify-content --verify-limit 5`,\n 'Sparse GSC data: lower thresholds and look for early content wins.',\n )\n addFollowup(\n commands,\n `seo second-page ${identity} --days ${days} --min-impressions 10 --verify-content --verify-limit 5`,\n 'Sparse GSC data: inspect early second-page opportunities.',\n )\n }\n\n const topMovedPage = diagnosis.segments.page.items.find((item) =>\n item.key.startsWith('http'),\n )\n if (topMovedPage) {\n addFollowup(\n commands,\n `seo audit-page --url ${shellArg(topMovedPage.key)}`,\n 'Audit the biggest moved URL for title, metadata, links, and schema.',\n )\n }\n\n if (\n input.crawlStartUrl &&\n input.technicalBaselineStatus !== 'created' &&\n input.technicalBaselineStatus !== 'refreshed' &&\n input.technicalBaselineStatus !== 'reused'\n ) {\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --health`,\n 'Run the fast sitemap response and access gate before fetching page bodies.',\n )\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} ${identity} --save`,\n 'Create the first technical crawler baseline with plain-English fixes and JSON-ready issue data.',\n )\n }\n\n addFollowup(\n commands,\n `seo technical-watch ${identity} --limit 50`,\n 'Save a crawl/index baseline so future reports can flag technical drift.',\n )\n\n return commands.slice(0, 6)\n}\n\nfunction printReportFollowups(\n commands: Array<{ command: string; why: string }>,\n): void {\n if (!commands.length) {\n return\n }\n process.stdout.write('\\nRecommended next commands\\n')\n printTable(\n ['Command', 'Why'],\n commands.map((item) => [item.command, item.why]),\n )\n}\n\nfunction printTechnicalOnlyIntro(site: string): void {\n process.stdout.write(`# Technical SEO report: ${site}\\n\\n`)\n}\n\nfunction workflowCommandMeta(input: {\n name: string\n description: string\n workflowName?: string\n printFollowups?: boolean\n}) {\n return defineCommand({\n meta: input,\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n ...(input.printFollowups\n ? {\n url: {\n type: 'string' as const,\n description:\n 'Crawl URL for a technical-only report. Search Console analyses are skipped unless you also pass --site or --project.',\n },\n }\n : {}),\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Search performance window in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum rows per section. Defaults to 10.',\n },\n },\n ),\n ...(input.printFollowups\n ? {\n crawl: defaultTrueBooleanArg(\n 'Create or reuse a bounded technical crawl before the report.',\n 'Skip technical crawl evidence for this report.',\n ),\n 'crawl-max-pages': {\n type: 'string' as const,\n description:\n 'Maximum pages for the report crawl. Defaults to 100.',\n },\n 'crawl-max-depth': {\n type: 'string' as const,\n description:\n 'Maximum link depth for the report crawl. Defaults to 4.',\n },\n full: {\n type: 'boolean' as const,\n default: false,\n description:\n 'Include the full report in JSON output. Default JSON is a compact summary for agents.',\n },\n ...reportHtmlArgs,\n }\n : {}),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = input.printFollowups ? reportHtmlOptions(args) : undefined\n const full = input.printFollowups && booleanArg(args.full)\n const project = projectArg(args)\n const explicitSite = stringArg(args.site)\n const directUrl = input.printFollowups ? stringArg(args.url) : undefined\n const useSearchData = Boolean(project || explicitSite || !directUrl)\n const selection = useSearchData\n ? await resolveClientSelection({\n client: project,\n site: explicitSite,\n options: { json, refresh: booleanArg(args.refresh) },\n })\n : undefined\n const site = selection?.site ?? siteForDirectUrl(directUrl ?? '')\n const report = await diagnosePropertyWorkflow({\n site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection?.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n skipSearchData: !useSearchData,\n })\n const outputReport = input.workflowName\n ? { ...report, workflow: input.workflowName }\n : report\n const technicalBaseline = input.printFollowups\n ? await resolveTechnicalBaseline({\n site,\n searchSite: selection?.site,\n url:\n directUrl ?? selection?.client?.startUrl ?? startUrlForSite(site),\n projectId: selection?.client?.id,\n googleAnalyticsPropertyId:\n selection?.client?.analytics.google?.propertyId,\n crawl: !negatedBooleanArg(args, 'crawl'),\n refresh: booleanArg(args.refresh),\n maxPages: numberArg(args['crawl-max-pages']),\n maxDepth: numberArg(args['crawl-max-depth']),\n })\n : undefined\n const technicalCrawl = technicalBaseline\n ? technicalSection(technicalBaseline)\n : undefined\n const followups = input.printFollowups\n ? reportFollowups(outputReport, {\n crawlStartUrl:\n directUrl ?? selection?.client?.startUrl ?? startUrlForSite(site),\n projectId: selection?.client?.id,\n technicalBaselineStatus: technicalBaseline?.status,\n searchDataAvailable: useSearchData,\n })\n : undefined\n if (json) {\n const jsonReport =\n input.printFollowups && !full\n ? compactMainReportJson(report, input.workflowName)\n : outputReport\n const reportWithTechnicalEvidence =\n !useSearchData && technicalCrawl\n ? {\n ...jsonReport,\n summary: technicalFirstSummary(technicalCrawl),\n steps: [\n technicalWorkflowStep(technicalCrawl),\n ...jsonReport.steps,\n ],\n }\n : jsonReport\n printJson(\n technicalCrawl || followups\n ? {\n ...reportWithTechnicalEvidence,\n ...(input.printFollowups\n ? { detail: full ? 'full' : 'summary' }\n : {}),\n ...(technicalCrawl\n ? {\n technicalCrawl:\n input.printFollowups && !full\n ? compactTechnicalSection(technicalCrawl)\n : technicalCrawl,\n }\n : {}),\n ...(followups ? { nextCommands: followups } : {}),\n }\n : jsonReport,\n )\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report: outputReport.output.narrative,\n reportName: 'report',\n title: useSearchData ? 'SEO report' : 'Technical SEO report',\n options: html,\n projectId: selection?.client?.id,\n additionalSections: mainReportHtmlSections({\n technicalCrawl,\n followups,\n }),\n })\n printReportHtmlPath(path)\n return\n }\n if (useSearchData) {\n process.stdout.write(`${outputReport.output.narrative.markdown}\\n\\n`)\n printWorkflow(outputReport)\n } else {\n printTechnicalOnlyIntro(site)\n }\n if (technicalCrawl) {\n printTechnicalSection(technicalCrawl, { providerFree: !useSearchData })\n if (!useSearchData) printSkippedProviderSections(technicalCrawl)\n }\n if (followups) printReportFollowups(followups)\n },\n })\n}\n\nexport const diagnosePropertyWorkflowCommand = workflowCommandMeta({\n name: 'diagnose-property',\n description: 'Find what changed in Google Search and what to inspect next',\n})\n\nexport const mainReportCommand = workflowCommandMeta({\n name: 'report',\n workflowName: 'report',\n printFollowups: true,\n description:\n 'Run the main SEO report and recommend the next best follow-up commands',\n})\n","import { refreshPrioritiesWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { printWorkflow } from './output.js'\n\nexport const refreshPrioritiesCommand = defineCommand({\n meta: {\n name: 'refresh-priorities',\n description: 'Agent workflow for a ranked SEO action queue',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum queue items to print. Defaults to 25.',\n },\n },\n ),\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID to use for analytics value. Defaults from the selected project.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Verify top opportunities against page title, meta, and content. Defaults to true.',\n 'Skip page content verification.',\n ),\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify. Defaults to 5.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await refreshPrioritiesWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection.client?.analytics.google?.propertyId,\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printWorkflow(report)\n printTable(\n [\n 'Source',\n 'Category',\n 'Score',\n 'Findings',\n 'Template',\n 'Analytics',\n 'Target',\n 'Action',\n ],\n report.output.queue.map((item) => [\n item.source,\n item.category,\n item.score,\n item.grouped?.count ?? 1,\n item.template?.label ?? '-',\n item.analytics?.sessions ?? '-',\n item.target,\n item.action,\n ]),\n )\n printActionDetails(\n 'Queue action details',\n report.output.queue.map((item) => ({\n label: item.target,\n context: `${item.category}, score ${item.score}`,\n action: item.action,\n })),\n )\n },\n})\n","import { technicalWatchWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printMonitoringRun } from '../monitoring/output.js'\nimport { startUrlForSite } from '../shared.js'\n\nexport const technicalWatchCommand = defineCommand({\n meta: {\n name: 'technical-watch',\n description: 'Agent workflow for crawl-diff and index-watch monitoring',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Defaults from the GSC property when possible.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect with URL Inspection.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs for quota-aware index monitoring.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties for sitemap index monitoring.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to inspect in this run. Defaults to 100.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for monitoring. Defaults to 50000.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n 'recover-links': defaultTrueBooleanArg(\n 'Check search-value GSC pages for broken, blocked, or poorly redirected URLs. Defaults to true.',\n 'Skip link recovery checks.',\n ),\n 'recover-days': {\n type: 'string',\n description: 'GSC lookback window for link recovery. Defaults to 90.',\n },\n 'recover-limit': {\n type: 'string',\n description:\n 'Maximum search-value pages to check for link recovery. Defaults to 10.',\n },\n 'recover-min-clicks': {\n type: 'string',\n description:\n 'Minimum clicks for link recovery candidates. Defaults to 1.',\n },\n 'recover-min-impressions': {\n type: 'string',\n description:\n 'Minimum impressions for link recovery candidates. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP/GSC cache where supported.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const watchUrls = listArg(args.urls)\n const sitemaps = listArg(args.sitemaps)\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const report = await technicalWatchWorkflow({\n site: selection.site,\n startUrl,\n urls: watchUrls.length ? watchUrls : selection.client?.watchUrls,\n sitemaps: sitemaps.length ? sitemaps : undefined,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n limit: numberArg(args.limit),\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n recoverLinks: booleanArg(args['recover-links']),\n recoverDays: numberArg(args['recover-days']),\n recoverLimit: numberArg(args['recover-limit']),\n recoverMinClicks: numberArg(args['recover-min-clicks']),\n recoverMinImpressions: numberArg(args['recover-min-impressions']),\n })\n if (json) {\n printJson(report)\n return\n }\n printMonitoringRun(report)\n },\n})\n","import { updatePostmortemWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNextCommand, printNotes, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\ntype SegmentSplit = Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n>['output']['segments']['page']\n\nfunction formatNumber(value: number | null): string {\n if (value === null) return '-'\n return value.toLocaleString('en-GB', {\n maximumFractionDigits: value >= 100 ? 0 : 1,\n })\n}\n\nfunction segmentRows(split: SegmentSplit) {\n return [\n ...split.winners.map((item) => ({ direction: 'winner', item })),\n ...split.losers.map((item) => ({ direction: 'loser', item })),\n ]\n}\n\nfunction printSegmentTable(label: string, split: SegmentSplit): void {\n const rows = segmentRows(split)\n if (!rows.length) return\n process.stdout.write(`\\n${label}\\n`)\n printTable(\n ['Direction', 'Key', 'Clicks', 'Impr.', 'Position'],\n rows.map(({ direction, item }) => [\n direction,\n item.key,\n formatNumber(item.clickDelta),\n formatNumber(item.impressionDelta),\n formatNumber(item.positionDelta),\n ]),\n )\n}\n\nfunction printSegmentCoverage(\n segments: Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n >['output']['segments'],\n): void {\n process.stdout.write('\\nSegment coverage\\n')\n printTable(\n [\n 'Dimension',\n 'Eligible',\n 'Returned',\n 'Limited',\n 'Result cap',\n 'Source cap',\n 'Source capped',\n ],\n (['page', 'query', 'device', 'country'] as const).map((dimension) => {\n const coverage = segments[dimension].coverage\n return [\n dimension,\n coverage.eligibleRows,\n coverage.returnedRows,\n coverage.limitedRows,\n coverage.resultLimit,\n coverage.sourceRowLimit,\n coverage.sourcePossiblyTruncated ? 'yes' : 'no',\n ]\n }),\n )\n}\n\ntype TemplateMovement = Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n>['output']['templateMovement'][number]\n\nfunction printTemplateMovement(items: TemplateMovement[]): void {\n if (!items.length) return\n process.stdout.write('\\nTemplate movement\\n')\n printTable(\n [\n 'Direction',\n 'Template',\n 'Pattern confidence',\n 'URLs',\n 'Clicks',\n 'Returned share',\n 'Common terms',\n ],\n items.map((item) => [\n item.direction,\n item.signature,\n item.confidence,\n item.urlCount,\n formatNumber(item.clickDelta),\n `${Math.round(item.movementShare * 100)}%`,\n item.commonTerms.join(', ') || '-',\n ]),\n )\n printNotes(\n 'Template actions',\n items.map((item) => item.summary),\n )\n printNotes('Template evidence scope', [\n 'Shares use returned directional page click movement. Pattern confidence applies only to returned matched-retained page segments.',\n ])\n}\n\nexport const updatePostmortemCommand = defineCommand({\n meta: {\n name: 'update-postmortem',\n description: 'Agent workflow for Google update winner/loser analysis',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum winners/losers per segment. Defaults to 20.',\n },\n },\n ),\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await updatePostmortemWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Update postmortem',\n target: report.site,\n status: 'unknown',\n summary: report.summary,\n metrics: [\n {\n label: 'Attribution',\n value: report.output.update.attribution.replaceAll('-', ' '),\n },\n { label: 'Confidence', value: report.output.update.confidence },\n {\n label: 'Known confounders',\n value: report.output.update.confounders.length,\n },\n ],\n })\n printNotes(\n 'Recommended actions',\n report.actions.map(\n (action) => `${action.title} (${action.confidence}): ${action.action}`,\n ),\n )\n printNotes(\n 'Postmortem findings',\n report.output.insights.map((insight) => insight.summary),\n )\n printNotes(\n 'Segment evidence warnings',\n [\n ...report.output.segments.page.warnings,\n ...report.output.segments.query.warnings,\n ...report.output.segments.device.warnings,\n ...report.output.segments.country.warnings,\n ].filter(\n (warning, index, warnings) => warnings.indexOf(warning) === index,\n ),\n )\n printTemplateMovement(report.output.templateMovement)\n printNotes('Update evidence', report.output.update.evidence)\n printSegmentCoverage(report.output.segments)\n printSegmentTable('Page winners and losers', report.output.segments.page)\n printSegmentTable('Query winners and losers', report.output.segments.query)\n printSegmentTable(\n 'Device winners and losers',\n report.output.segments.device,\n )\n printSegmentTable(\n 'Country winners and losers',\n report.output.segments.country,\n )\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n printNextCommand(`seo export update-postmortem ${target}`)\n },\n})\n","import { spawnSync } from 'node:child_process'\nimport { realpathSync } from 'node:fs'\nimport { isCancel, log, select } from '@clack/prompts'\nimport updateNotifier from 'update-notifier'\n\ntype PackageInfo = {\n name: string\n version: string\n}\n\ntype UpdateInfo = {\n current: string\n latest: string\n}\n\ntype UpdateNotifier = {\n update?: UpdateInfo\n}\n\nexport type SelfUpdateCommand = {\n args: string[]\n command: string\n}\n\ntype OfferUpdateOptions = {\n argv?: string[]\n cliPath?: string\n createNotifier?: (pkg: PackageInfo) => UpdateNotifier\n env?: NodeJS.ProcessEnv\n platform?: NodeJS.Platform\n prompt?: (input: {\n command: SelfUpdateCommand\n update: UpdateInfo\n }) => Promise<'later' | 'update'>\n run?: (command: SelfUpdateCommand) => number | null\n stdinIsTty?: boolean\n stdoutIsTty?: boolean\n}\n\nfunction normalizedPath(value: string): string {\n return value.replaceAll('\\\\', '/').toLowerCase()\n}\n\nfunction packageManagerCommand(\n manager: 'bun' | 'npm' | 'pnpm' | 'yarn',\n platform: NodeJS.Platform,\n): string {\n if (platform !== 'win32') return manager\n return `${manager}.cmd`\n}\n\nexport function inferSelfUpdateCommand(\n resolvedCliPath: string,\n platform: NodeJS.Platform = process.platform,\n): SelfUpdateCommand | undefined {\n const path = normalizedPath(resolvedCliPath)\n\n if (\n path.includes('/_npx/') ||\n path.includes('/.npm/_npx/') ||\n path.includes('/.cache/pnpm/dlx/') ||\n path.includes('/.volta/')\n ) {\n return undefined\n }\n\n if (path.includes('/.pnpm/') || path.includes('/pnpm/global/')) {\n return {\n command: packageManagerCommand('pnpm', platform),\n args: ['add', '--global', 'seo@latest'],\n }\n }\n\n if (path.includes('/.bun/install/global/')) {\n return {\n command: packageManagerCommand('bun', platform),\n args: ['add', '--global', 'seo@latest'],\n }\n }\n\n if (path.includes('/.config/yarn/global/')) {\n return {\n command: packageManagerCommand('yarn', platform),\n args: ['global', 'add', 'seo@latest'],\n }\n }\n\n if (path.includes('/node_modules/seo/')) {\n return {\n command: packageManagerCommand('npm', platform),\n args: ['install', '--global', 'seo@latest'],\n }\n }\n\n return undefined\n}\n\nfunction isNewerVersion(current: string, latest: string): boolean {\n const parse = (value: string) =>\n value\n .replace(/^v/, '')\n .split('-')[0]\n ?.split('.')\n .map((part) => Number.parseInt(part, 10)) ?? []\n const currentParts = parse(current)\n const latestParts = parse(latest)\n\n for (let index = 0; index < 3; index += 1) {\n const currentPart = currentParts[index] ?? 0\n const latestPart = latestParts[index] ?? 0\n if (!Number.isFinite(currentPart) || !Number.isFinite(latestPart)) {\n return false\n }\n if (latestPart > currentPart) return true\n if (latestPart < currentPart) return false\n }\n\n return false\n}\n\nexport function canOfferInteractiveUpdate(input: {\n argv: string[]\n env: NodeJS.ProcessEnv\n stdinIsTty: boolean\n stdoutIsTty: boolean\n}): boolean {\n if (!input.stdinIsTty || !input.stdoutIsTty) return false\n if (\n input.env.CI ||\n input.env.NO_UPDATE_NOTIFIER ||\n input.env.NODE_ENV === 'test' ||\n input.env.npm_lifecycle_event ||\n input.env.npm_execpath ||\n input.env.TERM === 'dumb'\n ) {\n return false\n }\n if (input.argv.includes('--json')) return false\n if (\n input.argv.some((arg) => ['--help', '-h', '--version', '-v'].includes(arg))\n ) {\n return false\n }\n if (['help', 'mcp'].includes(input.argv[0] ?? '')) return false\n return true\n}\n\nfunction resolvedCliPath(cliPath: string | undefined): string | undefined {\n if (!cliPath) return undefined\n try {\n return realpathSync(cliPath)\n } catch {\n return cliPath\n }\n}\n\nasync function promptForUpdate(input: {\n command: SelfUpdateCommand\n update: UpdateInfo\n}): Promise<'later' | 'update'> {\n const choice = await select<'later' | 'update'>({\n message: `seo ${input.update.latest} is available. You have ${input.update.current}.`,\n options: [\n {\n value: 'update',\n label: 'Update now',\n hint: [input.command.command, ...input.command.args].join(' '),\n },\n { value: 'later', label: 'Later' },\n ],\n initialValue: 'later',\n })\n return isCancel(choice) ? 'later' : choice\n}\n\nfunction runUpdate(command: SelfUpdateCommand): number | null {\n return spawnSync(command.command, command.args, { stdio: 'inherit' }).status\n}\n\nexport async function maybeOfferSelfUpdate(\n pkg: PackageInfo,\n options: OfferUpdateOptions = {},\n): Promise<number | undefined> {\n const argv = options.argv ?? process.argv.slice(2)\n const env = options.env ?? process.env\n if (\n !canOfferInteractiveUpdate({\n argv,\n env,\n stdinIsTty: options.stdinIsTty ?? Boolean(process.stdin.isTTY),\n stdoutIsTty: options.stdoutIsTty ?? Boolean(process.stdout.isTTY),\n })\n ) {\n return undefined\n }\n\n const path = resolvedCliPath(options.cliPath ?? process.argv[1])\n const command = path\n ? inferSelfUpdateCommand(path, options.platform ?? process.platform)\n : undefined\n if (!command) return undefined\n\n const notifier = (\n options.createNotifier ??\n ((value) =>\n updateNotifier({\n pkg: value,\n shouldNotifyInNpmScript: false,\n }))\n )(pkg)\n const update = notifier.update\n if (!update || !isNewerVersion(update.current, update.latest)) {\n return undefined\n }\n\n const choice = await (options.prompt ?? promptForUpdate)({ command, update })\n if (choice === 'later') return undefined\n\n const status = (options.run ?? runUpdate)(command)\n if (status === 0) {\n log.success(`Updated seo to ${update.latest}. Run your command again.`)\n return 0\n }\n\n log.error('The update failed. Your current version is unchanged.')\n return 1\n}\n","import {\n detectTelemetryAgent,\n initializeTelemetry,\n SEO_VERSION,\n seoErrorEnvelope,\n telemetryErrorCategory,\n toSeoError,\n trackTelemetryReportComplete,\n trackTelemetryReportFailed,\n trackTelemetryReportStart,\n trackTelemetrySetupComplete,\n} from '@seo/core'\nimport { listReports } from '@seo/mcp'\nimport { defineCommand, runCommand, runMain } from 'citty'\nimport { agentReadinessCommand } from './commands/agent-readiness.js'\nimport { analyticsCommand } from './commands/analytics/index.js'\nimport { authCommand } from './commands/auth.js'\nimport { cacheCommand } from './commands/cache.js'\nimport { clientCommand, projectCommand } from './commands/clients/index.js'\nimport { contentCommand } from './commands/content.js'\nimport { crawlCommand } from './commands/crawl.js'\nimport { crawlReportsCommand } from './commands/crawl-reports.js'\nimport { gscQueryCommand, urlInspectCommand } from './commands/data.js'\nimport {\n trafficAnomalyCommand,\n updateCorrelateCommand,\n} from './commands/diagnosis-reports.js'\nimport { entityReadinessCommand } from './commands/entity-readiness.js'\nimport {\n changeLogCommand,\n contentGroupsCommand,\n testsCommand,\n} from './commands/experiments/index.js'\nimport { exportCommand } from './commands/export/index.js'\nimport { indexNowCommand } from './commands/indexnow.js'\nimport { initCommand } from './commands/init.js'\nimport { linksCommand } from './commands/links.js'\nimport { llmsCommand } from './commands/llms.js'\nimport { logsCommand } from './commands/logs.js'\nimport { mcpCommand } from './commands/mcp.js'\nimport {\n crawlDiffCommand,\n indexCoverageCommand,\n indexWatchCommand,\n linkRecoverCommand,\n monitoringCommand,\n redirectTraceCommand,\n} from './commands/monitoring.js'\nimport { okfCommand } from './commands/okf.js'\nimport {\n aiReferralsCommand,\n cannibalCommand,\n communityIntentCommand,\n ctrUnderperformersCommand,\n decayingCommand,\n internalLinksCommand,\n pageOpportunitiesCommand,\n queryClusterCommand,\n quickWinsCommand,\n secondPageCommand,\n seoToAiQueryCommand,\n} from './commands/opportunities/index.js'\nimport { auditPageCommand } from './commands/page-audit.js'\nimport { performanceCommand } from './commands/performance.js'\nimport {\n diagnoseCommand,\n doctorCommand,\n segmentImpactCommand,\n strikingDistanceCommand,\n} from './commands/product/index.js'\nimport { providersCommand } from './commands/providers/index.js'\nimport { pseoCommand } from './commands/pseo/index.js'\nimport { aiReadinessCommand } from './commands/readiness.js'\nimport { reportCatalogCommand } from './commands/report-catalog.js'\nimport {\n monthlyReportCommand,\n reportNarrativeCommand,\n} from './commands/reports.js'\nimport { explainCommand, rulesCommand } from './commands/rules.js'\nimport { scheduleCommand } from './commands/schedule.js'\nimport { serverLogsCommand } from './commands/server-logs.js'\nimport { setupCommand, startCommand } from './commands/setup/index.js'\nimport { skillsCommand } from './commands/skills.js'\nimport {\n privacyCommand,\n resetCommand,\n sitesCommand,\n updatesCommand,\n} from './commands/system.js'\nimport { telemetryCommand } from './commands/telemetry.js'\nimport {\n crawlQueueCommand,\n diagnosePropertyWorkflowCommand,\n mainReportCommand,\n refreshPrioritiesCommand,\n technicalWatchCommand,\n updatePostmortemCommand,\n} from './commands/workflows/index.js'\nimport { maybeOfferSelfUpdate } from './self-update.js'\nimport { printCatalog, printHeading, printSection } from './utils.js'\n\nconst pkg = {\n name: 'seo',\n version: SEO_VERSION,\n}\n\ntype HelpSection = {\n title: string\n commands: Array<[command: string, description: string]>\n}\n\nconst helpSections: HelpSection[] = [\n {\n title: 'Start here',\n commands: [\n ['seo start', 'Connect Google and save a project profile'],\n ['seo report', 'Run the main SEO report for the default project'],\n ['seo report --site sc-domain:example.com', 'Run without a profile'],\n [\n 'seo report --url https://example.com',\n 'Start with a local technical report',\n ],\n ],\n },\n {\n title: 'Projects',\n commands: [\n ['seo projects list', 'List saved project profiles'],\n ['seo projects add', 'Create or update a project profile'],\n ['seo sites', 'List Search Console properties'],\n ['seo doctor', 'Check local auth and config'],\n ],\n },\n {\n title: 'Act on a report',\n commands: [\n ['seo refresh-priorities', 'Rank the next best SEO actions'],\n ['seo quick-wins', 'Find ranking 4-10 low-CTR wins'],\n ['seo second-page', 'Investigate URLs averaging positions 10-20'],\n ['seo technical-watch', 'Crawl and index-monitor a site'],\n ],\n },\n {\n title: 'Agent and power tools',\n commands: [\n ['seo report --json', 'Run the main report as structured JSON'],\n ['seo export diagnose', 'Export report data to CSV'],\n ['seo mcp install', 'Install SEO tools into MCP clients'],\n ['seo skill list', 'Show the packaged SEO skill'],\n ['seo reports list', 'Discover every structured report'],\n ],\n },\n]\n\nconst allHelpSections: HelpSection[] = [\n ...helpSections,\n {\n title: 'Deeper analysis',\n commands: [\n ['seo decaying', 'Find pages and queries losing clicks'],\n ['seo cannibal', 'Review queries exposed across multiple URLs'],\n ['seo ctr-underperformers', 'Find weak CTR by ranking position'],\n ['seo query-cluster', 'Cluster repeated demand themes'],\n ['seo page-opportunities', 'Analyze one URL for growth ideas'],\n ['seo content optimize', 'Build a content optimization report'],\n ['seo perf audit', 'Run a page performance audit'],\n ['seo internal-links', 'Find internal link opportunities'],\n ['seo community-intent', 'Find forum, review, and comparison intent'],\n ['seo ai-referrals', 'Find AI referral traffic in Google Analytics'],\n ['seo seo-to-ai-query', 'Convert searches into AI-monitor prompts'],\n ],\n },\n {\n title: 'Technical and data',\n commands: [\n ['seo audit-page', 'Audit one page'],\n [\n 'seo crawl --sitemap-url <url> --health',\n 'Run the fast sitemap gate before a full crawl',\n ],\n ['seo crawl', 'Run a full crawl for page and content evidence'],\n ['seo agent-readiness', 'Check content-site readiness for AI agents'],\n ['seo ai-readiness', 'Review AI-search technical evidence'],\n ['seo llms audit', 'Inspect optional llms.txt presence'],\n ['seo entity-readiness', 'Check brand/entity signals from a saved crawl'],\n ['seo okf export', 'Export a saved crawl as an OKF knowledge bundle'],\n ['seo crawl-queue', 'Run a crawl and rank the implementation queue'],\n ['seo crawl-reports', 'List saved crawl reports'],\n ['seo rules', 'List crawler rule ids'],\n ['seo explain --rule missing_title', 'Explain a crawler rule'],\n ['seo crawl-diff', 'Compare crawl changes'],\n ['seo index-coverage', 'Choose pages for URL Inspection'],\n ['seo index-watch', 'Check URL Inspection status'],\n ['seo indexnow submit', 'Notify IndexNow about changed URLs'],\n ['seo link-recover', 'Find broken search-value URLs'],\n ['seo links', 'Review bounded referring-link evidence'],\n ['seo server-logs analyze', 'Review crawler requests in an access log'],\n ['seo redirect-trace', 'Trace redirects'],\n ['seo gsc-query', 'Run a raw GSC query'],\n ['seo url-inspect', 'Run URL Inspection'],\n ['seo analytics google properties', 'List Google Analytics properties'],\n ['seo analytics google report', 'Run a Google Analytics report'],\n ['seo updates', 'List official Google ranking updates'],\n ],\n },\n {\n title: 'Reports and ops',\n commands: [\n ['seo monthly-report', 'Generate a monthly narrative'],\n ['seo report-narrative', 'Generate a client-ready narrative'],\n ['seo update-postmortem', 'Analyze update winners and losers'],\n ['seo schedule cron', 'Print cron entries'],\n ['seo monitoring', 'Run and review monitoring'],\n ['seo change-log', 'Track SEO changes'],\n ['seo tests', 'Create and report local SEO tests'],\n ['seo content-groups', 'Manage reusable page/query groups'],\n ['seo pseo', 'Audit programmatic SEO templates'],\n ['seo auth', 'Manage Google auth'],\n ['seo providers bing', 'Connect and report on Bing Webmaster'],\n ['seo providers dataforseo', 'Connect optional search data'],\n ['seo cache', 'Manage local cache'],\n ['seo privacy', 'Show local storage paths'],\n ['seo telemetry status', 'Check anonymous usage telemetry'],\n ['seo reset', 'Delete local SEO data'],\n ],\n },\n]\n\nfunction printHelpSections(sections: HelpSection[]): void {\n printHeading(\n `seo v${pkg.version}`,\n 'Run SEO audits, find what needs fixing, and ship the changes with your agent.',\n )\n process.stdout.write('\\n')\n printCatalog(\n sections.flatMap((section) =>\n section.commands.map(([command, description]) => ({\n category: section.title,\n id: command,\n name: description,\n })),\n ),\n {\n noun: 'command',\n categoryLabels: Object.fromEntries(\n sections.map((section) => [section.title, section.title]),\n ),\n },\n )\n process.stdout.write('\\n')\n printSection(\n 'More help',\n 'Use `seo help <command>` or `seo <command> --help` for command help.',\n 'Use `seo help all` for the longer command list.',\n )\n}\n\nconst main = defineCommand({\n meta: {\n name: 'seo',\n version: pkg.version,\n description: 'Local-first SEO CLI and MCP server',\n },\n subCommands: {\n init: initCommand,\n indexnow: indexNowCommand,\n analytics: analyticsCommand,\n llms: llmsCommand,\n auth: authCommand,\n mcp: mcpCommand,\n okf: okfCommand,\n doctor: doctorCommand,\n privacy: privacyCommand,\n telemetry: telemetryCommand,\n reset: resetCommand,\n cache: cacheCommand,\n logs: logsCommand,\n crawl: crawlCommand,\n 'crawl-queue': crawlQueueCommand,\n 'crawl-reports': crawlReportsCommand,\n client: clientCommand,\n content: contentCommand,\n project: projectCommand,\n projects: projectCommand,\n providers: providersCommand,\n 'change-log': changeLogCommand,\n tests: testsCommand,\n 'content-groups': contentGroupsCommand,\n 'crawl-diff': crawlDiffCommand,\n diagnose: diagnoseCommand,\n 'diagnose-property': diagnosePropertyWorkflowCommand,\n export: exportCommand,\n 'index-coverage': indexCoverageCommand,\n 'index-watch': indexWatchCommand,\n 'link-recover': linkRecoverCommand,\n links: linksCommand,\n 'monthly-report': monthlyReportCommand,\n monitoring: monitoringCommand,\n 'report-narrative': reportNarrativeCommand,\n rules: rulesCommand,\n explain: explainCommand,\n 'refresh-priorities': refreshPrioritiesCommand,\n 'redirect-trace': redirectTraceCommand,\n schedule: scheduleCommand,\n 'server-logs': serverLogsCommand,\n skill: skillsCommand,\n start: startCommand,\n setup: setupCommand,\n report: mainReportCommand,\n reports: reportCatalogCommand,\n 'segment-impact': segmentImpactCommand,\n 'striking-distance': strikingDistanceCommand,\n 'technical-watch': technicalWatchCommand,\n 'update-postmortem': updatePostmortemCommand,\n sites: sitesCommand,\n 'gsc-query': gscQueryCommand,\n 'url-inspect': urlInspectCommand,\n updates: updatesCommand,\n 'traffic-anomaly': trafficAnomalyCommand,\n 'update-correlate': updateCorrelateCommand,\n 'ai-referrals': aiReferralsCommand,\n 'agent-readiness': agentReadinessCommand,\n 'ai-readiness': aiReadinessCommand,\n 'entity-readiness': entityReadinessCommand,\n 'audit-page': auditPageCommand,\n 'second-page': secondPageCommand,\n cannibal: cannibalCommand,\n 'community-intent': communityIntentCommand,\n decaying: decayingCommand,\n 'quick-wins': quickWinsCommand,\n 'page-opportunities': pageOpportunitiesCommand,\n perf: performanceCommand,\n 'internal-links': internalLinksCommand,\n 'ctr-underperformers': ctrUnderperformersCommand,\n 'query-cluster': queryClusterCommand,\n 'seo-to-ai-query': seoToAiQueryCommand,\n pseo: pseoCommand,\n },\n run: async () => {\n if (process.argv.slice(2).length === 0) {\n process.stdout.write(\n 'Use `seo start` to set up, then `seo report` for the main report.\\n',\n )\n }\n },\n})\n\nconst reportAliases: Record<string, string> = {\n cannibal: 'cannibalisation',\n crawl: 'site-crawl',\n 'crawl-queue': 'top-fixes',\n decaying: 'decaying-pages',\n 'diagnose-property': 'search-performance-overview',\n doctor: 'setup-check',\n explain: 'explain-crawl-issue',\n 'link-recover': 'link-recovery',\n 'monthly-report': 'monthly-report',\n 'query-cluster': 'query-clusters',\n report: 'search-performance-overview',\n 'report-narrative': 'narrative-report',\n rules: 'crawler-rules',\n 'update-correlate': 'update-correlation',\n}\n\nconst directReportIds = new Set([\n 'agent-readiness',\n 'ai-readiness',\n 'ai-referrals',\n 'audit-page',\n 'community-intent',\n 'crawl-diff',\n 'ctr-underperformers',\n 'entity-readiness',\n 'index-coverage',\n 'index-watch',\n 'internal-links',\n 'link-evidence',\n 'page-opportunities',\n 'quick-wins',\n 'redirect-trace',\n 'refresh-priorities',\n 'second-page',\n 'segment-impact',\n 'seo-to-ai-query',\n 'striking-distance',\n 'technical-watch',\n 'traffic-anomaly',\n 'update-postmortem',\n])\nconst knownReportIds = new Set(listReports().map((report) => report.id))\n\nfunction telemetryReportId(args: string[]): string | undefined {\n const [command, subcommand, id] = args\n if (!command) return undefined\n if (command === 'reports' && subcommand === 'run') {\n return id && knownReportIds.has(id) ? id : undefined\n }\n if (command === 'content' && subcommand === 'optimize') {\n return 'content-optimization'\n }\n if (command === 'change-log' && subcommand === 'measure') {\n return 'measure-change'\n }\n if (command === 'llms' && subcommand === 'audit') return 'llms-txt-audit'\n if (command === 'links') return 'link-evidence'\n if (command === 'llms' && subcommand === 'generate') {\n return 'generate-llms-txt'\n }\n if (command === 'okf' && subcommand === 'export') return 'okf-build'\n if (command === 'okf' && subcommand === 'validate') return 'okf-validate'\n if (command === 'monitoring' && subcommand === 'run') {\n return 'technical-watch'\n }\n if (command === 'perf' && subcommand === 'audit') return 'performance-audit'\n if (command === 'pseo' && subcommand === 'audit') return 'pseo-audit'\n if (command === 'tests' && subcommand === 'report') return 'measure-change'\n return (\n reportAliases[command] ??\n (directReportIds.has(command) ? command : undefined)\n )\n}\n\nconst argv = process.argv.slice(2)\nconst telemetryOptions = { agent: detectTelemetryAgent() }\nconst isTelemetryControl = argv[0] === 'telemetry'\nconst isMcpServer = argv[0] === 'mcp' && argv[1] === 'serve'\nif (!isTelemetryControl && !isMcpServer) {\n initializeTelemetry(telemetryOptions)\n}\nconst updateExitCode = await maybeOfferSelfUpdate(pkg, { argv })\nif (updateExitCode !== undefined) {\n process.exit(updateExitCode)\n}\nif (\n argv.length === 0 ||\n (argv.length === 1 && ['help', '--help', '-h'].includes(argv[0] ?? ''))\n) {\n printHelpSections(helpSections)\n process.exit(0)\n}\nif (argv[0] === 'help' && argv[1] === 'all') {\n printHelpSections(allHelpSections)\n process.exit(0)\n}\nconst commandArgs =\n argv[0] === 'help' && argv.length > 1 ? [...argv.slice(1), '--help'] : argv\nif (commandArgs !== argv) {\n process.argv = [\n process.argv[0] ?? 'node',\n process.argv[1] ?? 'seo',\n ...commandArgs,\n ]\n}\nconst helpRequested = commandArgs.some((arg) => ['--help', '-h'].includes(arg))\nconst versionRequested =\n argv.length === 1 && ['--version', '-v'].includes(argv[0] ?? '')\nconst trackedReport =\n helpRequested || versionRequested ? undefined : telemetryReportId(commandArgs)\n\nif (helpRequested || versionRequested) {\n await runMain(main)\n} else {\n if (trackedReport) {\n trackTelemetryReportStart(trackedReport, telemetryOptions)\n }\n try {\n await runCommand(main, { rawArgs: commandArgs })\n if (trackedReport) {\n trackTelemetryReportComplete(trackedReport, telemetryOptions)\n }\n if (\n ['init', 'setup', 'start'].includes(commandArgs[0] ?? '') &&\n !commandArgs.includes('--dry-run')\n ) {\n trackTelemetrySetupComplete(telemetryOptions)\n }\n } catch (error) {\n if (trackedReport) {\n trackTelemetryReportFailed(\n trackedReport,\n telemetryErrorCategory(error),\n telemetryOptions,\n )\n }\n const normalized = toSeoError(error)\n if (argv.includes('--json')) {\n process.stdout.write(\n `${JSON.stringify(seoErrorEnvelope(normalized), null, 2)}\\n`,\n )\n } else {\n process.stderr.write(`Error: ${normalized.message}\\n`)\n }\n process.exitCode = normalized.exitCode\n }\n}\n"],"mappings":";;uqFAAA,SAAS,EAAW,EAAO,CACvB,OAAO,EACF,WAAW,IAAK,OAAO,CAAC,CACxB,WAAW,IAAK,MAAM,CAAC,CACvB,WAAW,IAAK,MAAM,CAAC,CACvB,WAAW,IAAK,QAAQ,CAAC,CACzB,WAAW,IAAK,OAAO,CAChC,CACA,SAAS,GAAY,EAAO,CACxB,GAAI,CACA,IAAM,EAAM,IAAI,IAAI,CAAK,EACzB,OAAO,EAAI,WAAa,SAAW,EAAI,WAAa,SAC9C,EAAI,SAAS,EACb,IAAA,EACV,MACM,CACF,MACJ,CACJ,CACA,SAAS,GAAW,EAAM,CACtB,IAAM,EAAU,GAAY,CAAI,EAC1B,EAAQ,EAAW,CAAI,EAC7B,OAAO,EACD,YAAY,EAAW,CAAO,EAAE,qBAAqB,EAAM,MAC3D,CACV,CACA,SAAS,GAAK,EAAO,CAGjB,OAFI,EAAM,SAAW,EACV,2CACJ,OAAO,EAAM,IAAK,GAAS,OAAO,EAAW,CAAI,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,MAC/E,CACA,SAAS,GAAe,EAAQ,CAC5B,OAAO,EAAO,SACT,IAAK,GAAY;cACZ,EAAW,EAAQ,KAAK,EAAE;UAC9B,GAAK,EAAQ,OAAO,EA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CACF,CAAC,EC9HD,SAAgB,IAAoB,CAClC,MAAO,CACL,KAAM,CACJ,KAAM,SACN,YAAa,sDACf,EACA,OAAQ,CACN,KAAM,SACN,YAAa,6BACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,2BACf,EACA,IAAK,CACH,KAAM,SACN,YACE,gEACJ,EACA,KAAM,CACJ,KAAM,SACN,YAAa,sDACf,EACA,SAAU,CACR,KAAM,SACN,YACE,oEACJ,EACA,WAAY,CACV,KAAM,SACN,YACE,8DACJ,EACA,MAAO,CACL,KAAM,SACN,YAAa,yCACf,EACA,cAAe,CACb,KAAM,SACN,YAAa,4DACf,EACA,gBAAiB,CACf,KAAM,SACN,YACE,+DACJ,EACA,WAAY,CACV,KAAM,SACN,YACE,iEACJ,EACA,SAAU,CACR,KAAM,SACN,YAAa,wCACf,EACA,gBAAiB,EACf,+EACA,4BACF,EACA,eAAgB,CACd,KAAM,SACN,YAAa,wDACf,EACA,gBAAiB,CACf,KAAM,SACN,YACE,wEACJ,EACA,qBAAsB,CACpB,KAAM,SACN,YACE,6DACJ,EACA,0BAA2B,CACzB,KAAM,SACN,YACE,oEACJ,EACA,QAAS,CACP,KAAM,UACN,QAAS,GACT,YAAa,8CACf,EACA,GAAI,CACF,KAAM,UACN,QAAS,GACT,YAAa,0DACf,EACA,KAAM,CACJ,KAAM,UACN,QAAS,GACT,YAAa,8BACf,CACF,CACF,CAEA,SAAgB,IAAuB,CACrC,MAAO,CACL,KAAM,CACJ,KAAM,SACN,YAAa,sDACf,EACA,OAAQ,CACN,KAAM,SACN,YAAa,6BACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,2BACf,EACA,aAAc,CACZ,KAAM,SACN,YAAa,wDACf,EACA,QAAS,CACP,KAAM,UACN,QAAS,GACT,YAAa,iDACf,EACA,KAAM,CACJ,KAAM,UACN,QAAS,GACT,YAAa,8BACf,CACF,CACF,CC7HA,SAAS,GACP,EACkD,CAClD,IAAM,EAAS,EAAM,YAAY,EASjC,MARI,C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shellArg","setupCommand","truncate","urlListArgs","crawlUrlArg","crawlModeArg","writeOrPrint","parseUrlList","truncate","formatNumber","today","changeScope","slug","writeOrPrint","statusCommand","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","truncate","connectCommand","statusCommand","disconnectCommand","sitesCommand","truncate","listCommand","runCommand","truncate","truncate","setupCommand"],"sources":["../packages/core/dist/export/report-html.js","../packages/core/dist/export/update-postmortem.js","../packages/core/dist/ga4/matching.js","../packages/core/dist/utils/time.js","../packages/cli/src/args.ts","../packages/cli/src/presentation/context.ts","../packages/cli/src/presentation/render.ts","../packages/cli/src/presentation/report.ts","../packages/cli/src/presentation/views.ts","../packages/cli/src/utils.ts","../packages/cli/src/selection.ts","../packages/cli/src/commands/readiness.ts","../packages/cli/src/commands/agent-readiness.ts","../packages/cli/src/commands/analytics/google/properties.ts","../packages/cli/src/commands/output.ts","../packages/cli/src/commands/analytics/google/report.ts","../packages/cli/src/commands/analytics/google/index.ts","../packages/cli/src/commands/analytics/index.ts","../packages/cli/src/commands/auth.ts","../packages/cli/src/commands/cache.ts","../packages/cli/src/commands/shared.ts","../packages/cli/src/commands/mcp-clients.ts","../packages/cli/src/commands/mcp-config.ts","../packages/cli/src/commands/skill-install.ts","../packages/cli/src/commands/setup/prompts.ts","../packages/cli/src/commands/setup/flow.ts","../packages/cli/src/commands/setup/index.ts","../packages/cli/src/commands/clients/brand.ts","../packages/cli/src/commands/clients/keyword-sets/shared.ts","../packages/cli/src/commands/clients/keyword-sets/add.ts","../packages/cli/src/commands/clients/keyword-sets/create.ts","../packages/cli/src/commands/clients/keyword-sets/delete.ts","../packages/cli/src/commands/clients/keyword-sets/export.ts","../packages/cli/src/commands/clients/keyword-sets/output.ts","../packages/cli/src/commands/clients/keyword-sets/list.ts","../packages/cli/src/commands/clients/keyword-sets/refresh.ts","../packages/cli/src/commands/clients/keyword-sets/remove.ts","../packages/cli/src/commands/clients/keyword-sets/show.ts","../packages/cli/src/commands/clients/keyword-sets/index.ts","../packages/cli/src/commands/clients/profiles/output.ts","../packages/cli/src/commands/clients/profiles/add.ts","../packages/cli/src/commands/clients/profiles/default.ts","../packages/cli/src/commands/clients/profiles/delete.ts","../packages/cli/src/commands/clients/profiles/list.ts","../packages/cli/src/commands/clients/profiles/show.ts","../packages/cli/src/commands/clients/profiles.ts","../packages/cli/src/commands/clients/index.ts","../packages/cli/src/commands/content.ts","../packages/cli/src/json-output.ts","../packages/cli/src/presentation/crawl-report.ts","../packages/cli/src/commands/crawl.ts","../packages/cli/src/commands/crawl-reports.ts","../packages/cli/src/commands/data.ts","../packages/cli/src/commands/report-options.ts","../packages/cli/src/commands/diagnosis-reports.ts","../packages/cli/src/commands/entity-readiness.ts","../packages/cli/src/commands/experiments/change-log.ts","../packages/cli/src/commands/experiments/content-groups.ts","../packages/cli/src/commands/experiments/tests.ts","../packages/cli/src/progress.ts","../packages/cli/src/commands/reports/args.ts","../packages/cli/src/commands/export/shared.ts","../packages/cli/src/commands/export/diagnose.ts","../packages/cli/src/commands/okf-files.ts","../packages/cli/src/commands/export/knowledge.ts","../packages/cli/src/commands/export/monthly.ts","../packages/cli/src/commands/export/narrative.ts","../packages/cli/src/commands/pseo/options.ts","../packages/cli/src/commands/export/pseo.ts","../packages/cli/src/commands/export/refresh-priorities.ts","../packages/cli/src/commands/export/update-postmortem.ts","../packages/cli/src/commands/export/index.ts","../packages/cli/src/commands/indexnow.ts","../packages/cli/src/commands/init.ts","../packages/cli/src/commands/links.ts","../packages/cli/src/commands/llms.ts","../packages/cli/src/commands/logs.ts","../packages/cli/src/commands/mcp.ts","../packages/cli/src/commands/monitoring/crawl-diff.ts","../packages/cli/src/commands/monitoring/args.ts","../packages/cli/src/commands/workflows/output.ts","../packages/cli/src/commands/monitoring/output.ts","../packages/cli/src/commands/monitoring/index.ts","../packages/cli/src/commands/monitoring/index-coverage.ts","../packages/cli/src/commands/monitoring/index-watch.ts","../packages/cli/src/commands/monitoring/link-recover.ts","../packages/cli/src/commands/monitoring/redirect-trace.ts","../packages/cli/src/commands/okf.ts","../packages/cli/src/commands/opportunities/ai-referrals.ts","../packages/cli/src/commands/opportunities/cannibal.ts","../packages/cli/src/commands/opportunities/community-intent.ts","../packages/cli/src/commands/opportunities/ctr.ts","../packages/cli/src/commands/opportunities/decaying.ts","../packages/cli/src/commands/opportunities/internal-links.ts","../packages/cli/src/commands/opportunities/page-opportunities.ts","../packages/cli/src/commands/opportunities/query-cluster.ts","../packages/cli/src/commands/opportunities/quick-wins.ts","../packages/cli/src/commands/opportunities/second-page.ts","../packages/cli/src/commands/opportunities/seo-to-ai-query.ts","../packages/cli/src/commands/page-audit.ts","../packages/cli/src/commands/performance.ts","../packages/cli/src/commands/product/diagnose.ts","../packages/cli/src/commands/product/doctor.ts","../packages/cli/src/commands/product/segment-impact.ts","../packages/cli/src/commands/product/striking-distance.ts","../packages/cli/src/commands/providers/bing.ts","../packages/cli/src/commands/providers/dataforseo.ts","../packages/cli/src/commands/providers/index.ts","../packages/cli/src/commands/pseo/audit.ts","../packages/cli/src/commands/pseo/index.ts","../packages/cli/src/commands/report-catalog.ts","../packages/cli/src/commands/report-html.ts","../packages/cli/src/commands/reports/monthly.ts","../packages/cli/src/commands/reports/narrative.ts","../packages/cli/src/commands/rules.ts","../packages/cli/src/commands/schedule.ts","../packages/cli/src/commands/server-logs.ts","../packages/cli/src/commands/skill-paths.ts","../packages/cli/src/commands/skills-eval.ts","../packages/cli/src/commands/skills.ts","../packages/cli/src/commands/system.ts","../packages/cli/src/commands/telemetry.ts","../packages/cli/src/commands/workflows/crawl-queue.ts","../packages/cli/src/commands/workflows/diagnose-property.ts","../packages/cli/src/commands/workflows/refresh-priorities.ts","../packages/cli/src/commands/workflows/technical-watch.ts","../packages/cli/src/commands/workflows/update-postmortem.ts","../packages/cli/src/self-update.ts","../packages/cli/src/index.ts"],"sourcesContent":["function escapeHtml(value) {\n return value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n}\nfunction safeHttpUrl(value) {\n try {\n const url = new URL(value);\n return url.protocol === 'http:' || url.protocol === 'https:'\n ? url.toString()\n : undefined;\n }\n catch {\n return undefined;\n }\n}\nfunction siteMarkup(site) {\n const safeUrl = safeHttpUrl(site);\n const label = escapeHtml(site);\n return safeUrl\n ? `<a href=\"${escapeHtml(safeUrl)}\" rel=\"noreferrer\">${label}</a>`\n : label;\n}\nfunction list(items) {\n if (items.length === 0)\n return '<p class=\"empty\">No items to report.</p>';\n return `<ul>${items.map((item) => `<li>${escapeHtml(item)}</li>`).join('')}</ul>`;\n}\nfunction reportSections(report) {\n return report.sections\n .map((section) => `<section class=\"panel\">\n <h2>${escapeHtml(section.title)}</h2>\n ${list(section.bullets)}\n </section>`)\n .join('');\n}\nfunction additionalSections(sections) {\n return sections\n .map((section) => `<section class=\"panel\">\n <h2>${escapeHtml(section.title)}</h2>\n ${section.summary ? `<p>${escapeHtml(section.summary)}</p>` : ''}\n ${list(section.items)}\n </section>`)\n .join('');\n}\nfunction priorities(report) {\n if (report.priorities.length === 0) {\n return '<p class=\"empty\">No evidence-backed priorities were found.</p>';\n }\n return `<ol class=\"priorities\">${report.priorities\n .map((priority) => `<li>\n <div class=\"priority-heading\">\n <strong>${escapeHtml(priority.title)}</strong>\n <span class=\"confidence\">${escapeHtml(priority.confidence)} confidence</span>\n </div>\n <p>${escapeHtml(priority.action)}</p>\n </li>`)\n .join('')}</ol>`;\n}\nfunction analystEvidence(report) {\n const skipped = report.diagnosis.skippedSections ?? [];\n const attempts = report.changeMeasurementAttempts;\n return `<section class=\"panel analyst-only\">\n <h2>Evidence coverage</h2>\n <dl class=\"facts\">\n <div><dt>Data status</dt><dd>${escapeHtml(report.dataStatus)}</dd></div>\n <div><dt>Generated</dt><dd>${escapeHtml(report.generatedAt)}</dd></div>\n <div><dt>Saved changes checked</dt><dd>${attempts.length}</dd></div>\n <div><dt>Unavailable sections</dt><dd>${skipped.length}</dd></div>\n </dl>\n ${skipped.length\n ? `<h3>Unavailable sections</h3>${list(skipped.map((section) => 'reason' in section && typeof section.reason === 'string'\n ? `${section.section}: ${section.reason}`\n : section.section))}`\n : ''}\n </section>`;\n}\nconst styles = `\n :root { color-scheme: light; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; color: #17211b; background: #f2f4ef; }\n * { box-sizing: border-box; }\n body { margin: 0; line-height: 1.55; }\n a { color: inherit; text-decoration-color: #ff5b35; text-underline-offset: 0.18em; }\n main { width: min(980px, calc(100% - 32px)); margin: 32px auto 64px; }\n header { padding: clamp(28px, 6vw, 64px); color: #f9fbf7; background: #17211b; border-radius: 20px; }\n .eyebrow { margin: 0 0 12px; color: #ff7958; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }\n h1 { max-width: 760px; margin: 0; font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; letter-spacing: -0.04em; }\n header .headline { max-width: 760px; margin: 24px 0 0; font-size: clamp(1.05rem, 2vw, 1.3rem); color: #d9e1d9; }\n .meta { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 28px; color: #b9c5ba; font-size: 0.9rem; }\n .status { display: inline-flex; width: fit-content; margin-top: 22px; padding: 6px 10px; border: 1px solid #4f6153; border-radius: 999px; font-size: 0.8rem; font-weight: 700; text-transform: capitalize; }\n .panel { margin-top: 20px; padding: clamp(22px, 4vw, 38px); background: #fff; border: 1px solid #dfe4dc; border-radius: 16px; box-shadow: 0 8px 30px rgba(23, 33, 27, 0.05); }\n h2 { margin: 0 0 16px; font-size: clamp(1.25rem, 3vw, 1.65rem); letter-spacing: -0.02em; }\n h3 { margin: 26px 0 10px; font-size: 1rem; }\n p { margin: 0 0 14px; }\n ul, ol { margin: 0; padding-left: 1.25rem; }\n li + li { margin-top: 10px; }\n .priorities { list-style: none; padding: 0; counter-reset: priority; }\n .priorities > li { counter-increment: priority; padding: 18px 0 18px 52px; position: relative; border-top: 1px solid #e6eae4; }\n .priorities > li:first-child { border-top: 0; padding-top: 4px; }\n .priorities > li::before { content: counter(priority); position: absolute; left: 0; top: 16px; display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #17211b; background: #ff7958; font-weight: 800; }\n .priorities > li:first-child::before { top: 2px; }\n .priority-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }\n .confidence { color: #647067; font-size: 0.82rem; text-transform: capitalize; }\n .priorities p { margin: 8px 0 0; color: #3e4941; }\n .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }\n .facts div { padding: 14px; background: #f5f7f3; border-radius: 10px; }\n dt { color: #647067; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }\n dd { margin: 4px 0 0; font-weight: 700; }\n details summary { cursor: pointer; font-weight: 750; }\n details ul { margin-top: 14px; }\n .empty { color: #647067; font-style: italic; }\n footer { margin-top: 26px; color: #647067; font-size: 0.8rem; text-align: center; }\n @media print { :root { background: #fff; } main { width: 100%; margin: 0; } header, .panel { break-inside: avoid; box-shadow: none; } header { border-radius: 0; } }\n`;\nexport function renderReportHtml(input) {\n const report = input.report;\n const view = input.view ?? 'client';\n const title = input.title ?? 'SEO report';\n const evidenceNotesOpen = report.dataStatus !== 'complete' ? ' open' : '';\n const analyst = view === 'analyst' ? analystEvidence(report) : '';\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"robots\" content=\"noindex,nofollow\">\n <title>${escapeHtml(title)}: ${escapeHtml(report.site)}</title>\n <style>${styles}</style>\n</head>\n<body>\n <main>\n <header>\n <p class=\"eyebrow\">${escapeHtml(title)}</p>\n <h1>${siteMarkup(report.site)}</h1>\n <p class=\"headline\">${escapeHtml(report.headline)}</p>\n <div class=\"meta\">\n <span>${escapeHtml(report.period.startDate)} to ${escapeHtml(report.period.endDate)}</span>\n <span>Generated ${escapeHtml(report.generatedAt.slice(0, 10))}</span>\n <span>${escapeHtml(view)} view</span>\n </div>\n <span class=\"status\">${escapeHtml(report.dataStatus)} data</span>\n </header>\n\n <section class=\"panel\">\n <h2>Priorities</h2>\n ${priorities(report)}\n </section>\n\n ${reportSections(report)}\n ${additionalSections(input.additionalSections ?? [])}\n ${analyst}\n\n <section class=\"panel\">\n <details${evidenceNotesOpen}>\n <summary>Evidence notes and limitations</summary>\n ${list(report.caveats)}\n </details>\n </section>\n\n <footer>Generated locally from observed report evidence.</footer>\n </main>\n</body>\n</html>`;\n}\n//# sourceMappingURL=report-html.js.map","const HEADERS = {\n summary: [\n 'workflow',\n 'site',\n 'generated_at',\n 'summary',\n 'attribution',\n 'confidence',\n 'classification',\n 'updates_matched',\n 'known_confounders',\n 'page_segment_status',\n 'page_segment_eligible_rows',\n 'page_segment_returned_rows',\n 'page_segment_limited_rows',\n 'page_segment_result_limit',\n 'page_segment_source_row_limit',\n 'page_segment_source_possibly_truncated',\n 'page_segment_warnings',\n 'query_segment_status',\n 'query_segment_eligible_rows',\n 'query_segment_returned_rows',\n 'query_segment_limited_rows',\n 'query_segment_result_limit',\n 'query_segment_source_row_limit',\n 'query_segment_source_possibly_truncated',\n 'query_segment_warnings',\n 'device_segment_status',\n 'device_segment_eligible_rows',\n 'device_segment_returned_rows',\n 'device_segment_limited_rows',\n 'device_segment_result_limit',\n 'device_segment_source_row_limit',\n 'device_segment_source_possibly_truncated',\n 'device_segment_warnings',\n 'country_segment_status',\n 'country_segment_eligible_rows',\n 'country_segment_returned_rows',\n 'country_segment_limited_rows',\n 'country_segment_result_limit',\n 'country_segment_source_row_limit',\n 'country_segment_source_possibly_truncated',\n 'country_segment_warnings',\n ],\n steps: ['rank', 'tool', 'status', 'summary'],\n actions: ['rank', 'title', 'confidence', 'action'],\n findings: [\n 'dimension',\n 'data_status',\n 'eligible_rows',\n 'returned_rows',\n 'limited_rows',\n 'result_limit',\n 'unmatched_rows',\n 'summary',\n 'winner_key',\n 'winner_click_delta',\n 'winner_impression_delta',\n 'winner_position_delta',\n 'loser_key',\n 'loser_click_delta',\n 'loser_impression_delta',\n 'loser_position_delta',\n ],\n templates: [\n 'rank',\n 'direction',\n 'template',\n 'confidence',\n 'url_count',\n 'click_delta',\n 'impression_delta',\n 'movement_share',\n 'movement_share_scope',\n 'confidence_scope',\n 'eligible_rows',\n 'returned_rows',\n 'limited_rows',\n 'result_limit',\n 'source_possibly_truncated',\n 'common_terms',\n 'sample_urls',\n 'summary',\n ],\n evidence: ['rank', 'evidence'],\n confounders: [\n 'rank',\n 'source',\n 'title',\n 'date',\n 'scope',\n 'target',\n 'description',\n ],\n segment: [\n 'rank',\n 'dimension',\n 'data_status',\n 'evidence_scope',\n 'key',\n 'before_clicks',\n 'after_clicks',\n 'click_delta',\n 'before_impressions',\n 'after_impressions',\n 'impression_delta',\n 'before_position',\n 'after_position',\n 'position_delta',\n ],\n unmatchedSegment: [\n 'rank',\n 'dimension',\n 'data_status',\n 'key',\n 'retained_in',\n 'clicks',\n 'impressions',\n 'position',\n 'reason',\n ],\n};\nfunction postmortemSegmentRows(report, dimension) {\n return [\n ...report.output.segments[dimension].winners,\n ...report.output.segments[dimension].losers,\n ].map((item, index) => ({\n rank: index + 1,\n dimension,\n data_status: report.output.segments[dimension].dataStatus,\n evidence_scope: item.evidenceScope,\n key: item.key,\n before_clicks: item.beforeClicks,\n after_clicks: item.afterClicks,\n click_delta: item.clickDelta,\n before_impressions: item.beforeImpressions,\n after_impressions: item.afterImpressions,\n impression_delta: item.impressionDelta,\n before_position: item.beforePosition,\n after_position: item.afterPosition,\n position_delta: item.positionDelta,\n }));\n}\nfunction postmortemUnmatchedSegmentRows(report, dimension) {\n return report.output.segments[dimension].unmatchedSegments.map((item, index) => ({\n rank: index + 1,\n dimension,\n data_status: report.output.segments[dimension].dataStatus,\n key: item.key,\n retained_in: item.retainedIn,\n clicks: item.clicks,\n impressions: item.impressions,\n position: item.position,\n reason: item.reason,\n }));\n}\nexport function updatePostmortemCsvFiles(report) {\n return [\n {\n filename: 'postmortem-summary.csv',\n headers: [...HEADERS.summary],\n rows: [\n {\n workflow: report.workflow,\n site: report.site,\n generated_at: report.generatedAt,\n summary: report.summary,\n attribution: report.output.update.attribution,\n confidence: report.output.update.confidence,\n classification: report.output.update.classification,\n updates_matched: report.output.update.overlappingUpdates.length,\n known_confounders: report.output.update.confounders.length,\n page_segment_status: report.output.segments.page.dataStatus,\n page_segment_eligible_rows: report.output.segments.page.coverage.eligibleRows,\n page_segment_returned_rows: report.output.segments.page.coverage.returnedRows,\n page_segment_limited_rows: report.output.segments.page.coverage.limitedRows,\n page_segment_result_limit: report.output.segments.page.coverage.resultLimit,\n page_segment_source_row_limit: report.output.segments.page.coverage.sourceRowLimit,\n page_segment_source_possibly_truncated: report.output.segments.page.coverage.sourcePossiblyTruncated,\n page_segment_warnings: report.output.segments.page.warnings.join('; '),\n query_segment_status: report.output.segments.query.dataStatus,\n query_segment_eligible_rows: report.output.segments.query.coverage.eligibleRows,\n query_segment_returned_rows: report.output.segments.query.coverage.returnedRows,\n query_segment_limited_rows: report.output.segments.query.coverage.limitedRows,\n query_segment_result_limit: report.output.segments.query.coverage.resultLimit,\n query_segment_source_row_limit: report.output.segments.query.coverage.sourceRowLimit,\n query_segment_source_possibly_truncated: report.output.segments.query.coverage.sourcePossiblyTruncated,\n query_segment_warnings: report.output.segments.query.warnings.join('; '),\n device_segment_status: report.output.segments.device.dataStatus,\n device_segment_eligible_rows: report.output.segments.device.coverage.eligibleRows,\n device_segment_returned_rows: report.output.segments.device.coverage.returnedRows,\n device_segment_limited_rows: report.output.segments.device.coverage.limitedRows,\n device_segment_result_limit: report.output.segments.device.coverage.resultLimit,\n device_segment_source_row_limit: report.output.segments.device.coverage.sourceRowLimit,\n device_segment_source_possibly_truncated: report.output.segments.device.coverage.sourcePossiblyTruncated,\n device_segment_warnings: report.output.segments.device.warnings.join('; '),\n country_segment_status: report.output.segments.country.dataStatus,\n country_segment_eligible_rows: report.output.segments.country.coverage.eligibleRows,\n country_segment_returned_rows: report.output.segments.country.coverage.returnedRows,\n country_segment_limited_rows: report.output.segments.country.coverage.limitedRows,\n country_segment_result_limit: report.output.segments.country.coverage.resultLimit,\n country_segment_source_row_limit: report.output.segments.country.coverage.sourceRowLimit,\n country_segment_source_possibly_truncated: report.output.segments.country.coverage.sourcePossiblyTruncated,\n country_segment_warnings: report.output.segments.country.warnings.join('; '),\n },\n ],\n },\n {\n filename: 'workflow-steps.csv',\n headers: [...HEADERS.steps],\n rows: report.steps.map((step, index) => ({\n rank: index + 1,\n tool: step.tool,\n status: step.status,\n summary: step.summary,\n })),\n },\n {\n filename: 'workflow-actions.csv',\n headers: [...HEADERS.actions],\n rows: report.actions.map((action, index) => ({\n rank: index + 1,\n title: action.title,\n confidence: action.confidence,\n action: action.action,\n })),\n },\n {\n filename: 'postmortem-findings.csv',\n headers: [...HEADERS.findings],\n rows: report.output.insights.map((item) => ({\n dimension: item.dimension,\n data_status: item.dataStatus,\n eligible_rows: item.coverage.eligibleRows,\n returned_rows: item.coverage.returnedRows,\n limited_rows: item.coverage.limitedRows,\n result_limit: item.coverage.resultLimit,\n unmatched_rows: item.unmatchedRows,\n summary: item.summary,\n winner_key: item.winner?.key,\n winner_click_delta: item.winner?.clickDelta,\n winner_impression_delta: item.winner?.impressionDelta,\n winner_position_delta: item.winner?.positionDelta,\n loser_key: item.loser?.key,\n loser_click_delta: item.loser?.clickDelta,\n loser_impression_delta: item.loser?.impressionDelta,\n loser_position_delta: item.loser?.positionDelta,\n })),\n },\n {\n filename: 'postmortem-template-movement.csv',\n headers: [...HEADERS.templates],\n rows: report.output.templateMovement.map((item, index) => ({\n rank: index + 1,\n direction: item.direction,\n template: item.signature,\n confidence: item.confidence,\n url_count: item.urlCount,\n click_delta: item.clickDelta,\n impression_delta: item.impressionDelta,\n movement_share: item.movementShare,\n movement_share_scope: item.movementShareScope,\n confidence_scope: item.confidenceScope,\n eligible_rows: item.segmentCoverage.eligibleRows,\n returned_rows: item.segmentCoverage.returnedRows,\n limited_rows: item.segmentCoverage.limitedRows,\n result_limit: item.segmentCoverage.resultLimit,\n source_possibly_truncated: item.segmentCoverage.sourcePossiblyTruncated,\n common_terms: item.commonTerms.join('; '),\n sample_urls: item.sampleUrls.join('; '),\n summary: item.summary,\n })),\n },\n {\n filename: 'postmortem-update-evidence.csv',\n headers: [...HEADERS.evidence],\n rows: report.output.update.evidence.map((evidence, index) => ({\n rank: index + 1,\n evidence,\n })),\n },\n {\n filename: 'postmortem-confounders.csv',\n headers: [...HEADERS.confounders],\n rows: report.output.update.confounders.map((item, index) => ({\n rank: index + 1,\n source: item.source,\n title: item.title,\n date: item.date,\n scope: item.scope,\n target: item.target,\n description: item.description,\n })),\n },\n ...['page', 'query', 'device', 'country'].map((dimension) => ({\n filename: `postmortem-segment-${dimension}.csv`,\n headers: [...HEADERS.segment],\n rows: postmortemSegmentRows(report, dimension),\n })),\n ...['page', 'query', 'device', 'country'].map((dimension) => ({\n filename: `postmortem-segment-${dimension}-unmatched.csv`,\n headers: [...HEADERS.unmatchedSegment],\n rows: postmortemUnmatchedSegmentRows(report, dimension),\n })),\n ];\n}\n//# sourceMappingURL=update-postmortem.js.map","function hostnameFromUrl(value) {\n try {\n const url = new URL(value);\n if (url.protocol !== 'http:' && url.protocol !== 'https:')\n return undefined;\n return url.hostname.toLowerCase().replace(/\\.$/, '') || undefined;\n }\n catch {\n return undefined;\n }\n}\nfunction domainFromProperty(value) {\n if (!value.startsWith('sc-domain:'))\n return undefined;\n const domain = value.slice('sc-domain:'.length).trim().toLowerCase();\n if (!domain || /[/:]/.test(domain))\n return undefined;\n return domain.replace(/\\.$/, '') || undefined;\n}\nfunction matchForSite(site, streamHostname) {\n const domain = domainFromProperty(site);\n if (domain) {\n return streamHostname === domain || streamHostname.endsWith(`.${domain}`)\n ? 'domain'\n : undefined;\n }\n return hostnameFromUrl(site) === streamHostname ? 'hostname' : undefined;\n}\nexport function matchGa4WebStreams(site, candidates) {\n return candidates.flatMap((candidate) => {\n const defaultUri = candidate.stream.webStreamData?.defaultUri;\n if (!defaultUri)\n return [];\n const hostname = hostnameFromUrl(defaultUri);\n if (!hostname)\n return [];\n const match = matchForSite(site, hostname);\n if (!match)\n return [];\n return [{ ...candidate, defaultUri, hostname, match }];\n });\n}\nexport function ga4MatchReason(match, site) {\n const stream = match.stream.displayName ?? match.defaultUri;\n const location = match.match === 'domain' ? 'is inside' : 'matches';\n return `Matched Google Analytics web stream ${stream} (${match.defaultUri}): its hostname ${location} ${site}.`;\n}\n//# sourceMappingURL=matching.js.map","export function parseOlderThan(input) {\n if (!input) {\n return undefined;\n }\n const match = input.trim().match(/^(\\d+)([smhdw])$/i);\n if (!match) {\n throw new Error(`Invalid duration \"${input}\". Use values like 7d, 12h, 30m.`);\n }\n const valuePart = match[1];\n const unitPart = match[2];\n if (!valuePart || !unitPart) {\n throw new Error(`Invalid duration \"${input}\".`);\n }\n const value = Number.parseInt(valuePart, 10);\n const unit = unitPart.toLowerCase();\n const multipliers = {\n s: 1_000,\n m: 60_000,\n h: 3_600_000,\n d: 86_400_000,\n w: 604_800_000,\n };\n const multiplier = multipliers[unit];\n if (!multiplier) {\n throw new Error(`Unsupported duration unit in \"${input}\".`);\n }\n return value * multiplier;\n}\nexport function formatRelativeExpiry(expiresAt) {\n const delta = expiresAt - Date.now();\n if (delta <= 0) {\n return 'expired';\n }\n const minutes = Math.round(delta / 60_000);\n if (minutes < 60) {\n return `in ${minutes}m`;\n }\n const hours = Math.floor(minutes / 60);\n const remMinutes = minutes % 60;\n return remMinutes ? `in ${hours}h ${remMinutes}m` : `in ${hours}h`;\n}\nexport function isoDate(daysAgo = 0) {\n const date = new Date();\n date.setUTCDate(date.getUTCDate() - daysAgo);\n return date.toISOString().slice(0, 10);\n}\n//# sourceMappingURL=time.js.map","import { readFile } from 'node:fs/promises'\nimport { type JavaScriptRenderingMode, SeoError } from '@seo/core'\nimport type { BooleanArgDef } from 'citty'\n\nexport function defaultTrueBooleanArg(\n description: string,\n negativeDescription: string,\n): BooleanArgDef {\n return {\n type: 'boolean',\n default: true,\n description,\n negativeDescription,\n }\n}\n\nexport function stringArg(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined\n}\n\nexport function projectArg(args: Record<string, unknown>): string | undefined {\n const project = stringArg(args.project)\n const client = stringArg(args.client)\n if (project && client && project !== client) {\n throw new Error('Use either --project or --client, not both.')\n }\n return project ?? client\n}\n\nexport function booleanArg(value: unknown): boolean | undefined {\n return typeof value === 'boolean' ? value : undefined\n}\n\n/**\n * `--js` remains an alias for `--rendering on` while callers move to the\n * explicit modes. A mode is returned even when neither flag was supplied so\n * commands can pass it straight to the core API.\n */\nexport function renderingModeArg(\n args: Record<string, unknown>,\n): JavaScriptRenderingMode {\n const rendering = stringArg(args.rendering)\n if (\n rendering !== undefined &&\n rendering !== 'auto' &&\n rendering !== 'on' &&\n rendering !== 'off'\n ) {\n throw new SeoError('INVALID_INPUT', '--rendering must be auto, on, or off.')\n }\n if (booleanArg(args.js) === true && rendering && rendering !== 'on') {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --js or --rendering on, not both with different modes.',\n )\n }\n return rendering ?? (booleanArg(args.js) ? 'on' : 'auto')\n}\n\nexport function negatedBooleanArg(\n args: Record<string, unknown>,\n name: string,\n): boolean | undefined {\n const positive = booleanArg(args[name])\n if (positive === false) return true\n if (positive === true) return false\n const camelPositive = booleanArg(args[toCamelCase(name)])\n if (camelPositive === false) return true\n if (camelPositive === true) return false\n const explicitNo = booleanArg(args[`no-${name}`])\n if (explicitNo === true) return true\n const camelNo = booleanArg(args[`no${toPascalCase(name)}`])\n if (camelNo === true) return true\n return undefined\n}\n\nfunction toCamelCase(value: string): string {\n return value.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase())\n}\n\nfunction toPascalCase(value: string): string {\n const camel = toCamelCase(value)\n return camel ? `${camel[0]?.toUpperCase()}${camel.slice(1)}` : ''\n}\n\nexport function numberArg(value: unknown): number | undefined {\n if (typeof value === 'number') return value\n if (typeof value !== 'string' || !value.trim()) return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nexport function strictNumberArg(\n value: unknown,\n label: string,\n): number | undefined {\n if (value === undefined || value === '') return undefined\n const parsed = numberArg(value)\n if (parsed === undefined)\n throw new SeoError('INVALID_INPUT', `${label} must be a number.`)\n return parsed\n}\n\nexport function csvArg(value: unknown): string[] | undefined {\n if (typeof value !== 'string') return undefined\n const items = value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean)\n return items.length ? items : undefined\n}\n\nexport function listArg(value: unknown): string[] {\n return csvArg(value) ?? []\n}\n\nexport function fetchRateArg(args: Record<string, unknown>):\n | {\n concurrency?: number\n intervalCap?: number\n intervalMs?: number\n }\n | undefined {\n const rate = {\n concurrency: numberArg(args['fetch-concurrency']),\n intervalCap: numberArg(args['fetch-interval-cap']),\n intervalMs: numberArg(args['fetch-interval-ms']),\n }\n return Object.values(rate).some((value) => value !== undefined)\n ? rate\n : undefined\n}\n\nexport function strictFetchRateArg(args: Record<string, unknown>):\n | {\n concurrency?: number\n intervalCap?: number\n intervalMs?: number\n }\n | undefined {\n const rate = {\n concurrency: strictNumberArg(\n args['fetch-concurrency'],\n '--fetch-concurrency',\n ),\n intervalCap: strictNumberArg(\n args['fetch-interval-cap'],\n '--fetch-interval-cap',\n ),\n intervalMs: strictNumberArg(\n args['fetch-interval-ms'],\n '--fetch-interval-ms',\n ),\n }\n return Object.values(rate).some((value) => value !== undefined)\n ? rate\n : undefined\n}\n\nexport function jsonFlag(args: Record<string, unknown>): boolean {\n return args.json === true\n}\n\nexport async function jsonBodyArg(\n value: unknown,\n fileValue: unknown,\n): Promise<Record<string, unknown> | undefined> {\n const inline = stringArg(value)\n const file = stringArg(fileValue)\n if (inline && file) {\n throw new Error('Use either --body or --body-file, not both.')\n }\n if (!inline && !file) return undefined\n const source = inline ?? (await readFile(file ?? '', 'utf8'))\n const parsed = JSON.parse(source) as unknown\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new Error('JSON body must be an object.')\n }\n return parsed as Record<string, unknown>\n}\n","import { stripVTControlCharacters } from 'node:util'\nimport pc from 'picocolors'\nimport stringWidth from 'string-width'\n\nconst DEFAULT_COLUMNS = 80\nconst MIN_COLUMNS = 40\nconst MAX_COLUMNS = 200\n\nexport type TerminalContext = {\n columns: number\n colors: ReturnType<typeof pc.createColors>\n hasColor: boolean\n isInteractive: boolean\n}\n\nexport type TerminalContextOptions = {\n columns?: number\n color?: boolean\n env?: NodeJS.ProcessEnv\n isTTY?: boolean\n streamColumns?: number\n}\n\nfunction parsedColumns(value: number | string | undefined): number | undefined {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? Math.round(value) : undefined\n }\n if (!value) return undefined\n const parsed = Number.parseInt(value, 10)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nexport function resolveTerminalColumns(\n options: TerminalContextOptions = {},\n): number {\n const env = options.env ?? process.env\n const requested =\n parsedColumns(options.columns) ??\n parsedColumns(options.streamColumns) ??\n parsedColumns(env.COLUMNS) ??\n DEFAULT_COLUMNS\n return Math.min(MAX_COLUMNS, Math.max(MIN_COLUMNS, requested))\n}\n\nexport function createTerminalContext(\n options: TerminalContextOptions = {},\n): TerminalContext {\n const env = options.env ?? process.env\n const isTTY = options.isTTY ?? Boolean(process.stdout.isTTY)\n const hasColor = options.color ?? Boolean(isTTY && env.NO_COLOR === undefined)\n return {\n columns: resolveTerminalColumns({\n ...options,\n env,\n streamColumns: options.streamColumns ?? process.stdout.columns,\n }),\n colors: pc.createColors(hasColor),\n hasColor,\n isInteractive: isTTY && !env.CI,\n }\n}\n\nexport function visibleWidth(value: string): number {\n return stringWidth(stripVTControlCharacters(value))\n}\n\nfunction splitToken(token: string, width: number): string[] {\n const chunks: string[] = []\n let chunk = ''\n for (const character of token) {\n if (chunk && visibleWidth(`${chunk}${character}`) > width) {\n chunks.push(chunk)\n chunk = character\n } else {\n chunk += character\n }\n }\n if (chunk) chunks.push(chunk)\n return chunks\n}\n\nfunction wrapLine(value: string, width: number): string[] {\n if (!value) return ['']\n const words = value.trim().split(/\\s+/u)\n const lines: string[] = []\n let line = ''\n\n for (const word of words) {\n const pieces = visibleWidth(word) > width ? splitToken(word, width) : [word]\n for (const piece of pieces) {\n if (!line) {\n line = piece\n } else if (visibleWidth(`${line} ${piece}`) <= width) {\n line += ` ${piece}`\n } else {\n lines.push(line)\n line = piece\n }\n }\n }\n if (line) lines.push(line)\n return lines.length > 0 ? lines : ['']\n}\n\nexport function wrapText(value: string, width: number): string[] {\n const safeWidth = Math.max(1, width)\n return value\n .replaceAll('\\r\\n', '\\n')\n .split('\\n')\n .flatMap((line) => wrapLine(line, safeWidth))\n}\n\nexport function truncateText(value: string, width: number): string {\n if (visibleWidth(value) <= width) return value\n const suffix = '...'\n const available = Math.max(1, width - visibleWidth(suffix))\n let result = ''\n for (const character of value) {\n if (visibleWidth(`${result}${character}`) > available) break\n result += character\n }\n return `${result}${suffix}`\n}\n","import Table from 'cli-table3'\nimport {\n type TerminalContext,\n truncateText,\n visibleWidth,\n wrapText,\n} from './context.js'\n\nexport type TerminalCell = string | number\nexport type TerminalRow = TerminalCell[]\n\ntype TableOptions = {\n layout?: 'auto' | 'records' | 'table'\n rowNumbers?: boolean\n}\n\ntype Callout = {\n body?: string\n command?: string\n title: string\n}\n\nconst borderlessChars = {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n middle: '',\n}\n\nfunction stringCell(value: TerminalCell | undefined): string {\n return value === undefined ? '' : String(value)\n}\n\nfunction naturalColumnWidths(head: string[], rows: TerminalRow[]): number[] {\n return head.map((label, column) => {\n const values = rows.map((row) => stringCell(row[column]))\n return Math.min(\n 42,\n Math.max(visibleWidth(label), ...values.map(visibleWidth), 4),\n )\n })\n}\n\nfunction canRenderTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n): boolean {\n if (head.length === 0 || head.length > 4) return false\n const numericColumns = head.map((_, column) =>\n rows.every((row) =>\n /^-?(?:\\d+(?:\\.\\d+)?|\\d+(?:\\.\\d+)?%)$/u.test(\n stringCell(row[column]).trim(),\n ),\n ),\n )\n if (!numericColumns.some(Boolean)) return false\n const widths = naturalColumnWidths(head, rows)\n const tableWidth = widths.reduce((total, width) => total + width + 2, 0)\n return tableWidth <= context.columns\n}\n\nfunction styledValue(\n label: string,\n value: string,\n context: TerminalContext,\n): string {\n if (!/(?:status|state|assessment|data|allowed)/iu.test(label)) return value\n const normalized = value.trim().toLowerCase()\n if (['pass', 'passed', 'completed', 'allowed', 'yes'].includes(normalized)) {\n return context.colors.green(value)\n }\n if (['warn', 'warning', 'review', 'partial'].includes(normalized)) {\n return context.colors.yellow(value)\n }\n if (['fail', 'failed', 'blocked', 'no'].includes(normalized)) {\n return context.colors.red(value)\n }\n if (['unknown', 'unavailable'].includes(normalized)) {\n return context.colors.blue(value)\n }\n return value\n}\n\nfunction renderDenseTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n): string {\n const widths = naturalColumnWidths(head, rows).map((width) => width + 2)\n const table = new Table({\n chars: borderlessChars,\n colWidths: widths,\n head: head.map((label) => context.colors.bold(label)),\n style: {\n border: [],\n head: [],\n 'padding-left': 0,\n 'padding-right': 2,\n },\n wordWrap: false,\n })\n for (const row of rows) {\n table.push(\n head.map((label, column) =>\n wrapText(\n styledValue(label, stringCell(row[column]), context),\n Math.max(1, (widths[column] ?? 3) - 2),\n ).join('\\n'),\n ),\n )\n }\n return table.toString()\n}\n\nfunction renderRecordValue(\n label: string,\n value: string,\n labelWidth: number,\n context: TerminalContext,\n): string[] {\n const gap = 2\n const valueWidth = context.columns - labelWidth - gap\n if (valueWidth < 24) {\n return [\n context.colors.dim(label),\n ...wrapText(value, context.columns - 2).map((line) => ` ${line}`),\n ]\n }\n const wrapped = wrapText(value, valueWidth)\n return wrapped.map((line, index) => {\n const prefix =\n index === 0 ? label.padEnd(labelWidth) : ''.padEnd(labelWidth)\n return `${context.colors.dim(prefix)}${' '.repeat(gap)}${line}`\n })\n}\n\nexport function renderRecords(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n options: { rowNumbers?: boolean } = {},\n): string {\n const labelWidth = Math.min(\n 28,\n Math.max(...head.map((label) => visibleWidth(label)), 0),\n )\n const showNumbers = options.rowNumbers ?? false\n const digits = String(rows.length).length\n const blocks = rows.map((row, index) => {\n const lines: string[] = []\n if (showNumbers) {\n lines.push(context.colors.bold(String(index + 1).padStart(digits, '0')))\n }\n for (const [column, label] of head.entries()) {\n lines.push(\n ...renderRecordValue(\n label,\n styledValue(label, stringCell(row[column]), context),\n labelWidth,\n context,\n ),\n )\n }\n return lines.join('\\n')\n })\n return blocks.join('\\n\\n')\n}\n\nexport function renderTable(\n head: string[],\n rows: TerminalRow[],\n context: TerminalContext,\n options: TableOptions = {},\n): string {\n if (rows.length === 0) return context.colors.dim('No results.')\n const useTable =\n options.layout === 'table' ||\n (options.layout !== 'records' && canRenderTable(head, rows, context))\n return useTable\n ? renderDenseTable(head, rows, context)\n : renderRecords(head, rows, context, options)\n}\n\nexport function renderKeyValues(\n rows: Array<[string, string]>,\n context: TerminalContext,\n): string {\n if (rows.length === 0) return ''\n const labelWidth = Math.min(\n 28,\n Math.max(...rows.map(([label]) => visibleWidth(label))),\n )\n return rows\n .flatMap(([label, value]) => {\n const lines = renderRecordValue(label, value, labelWidth, context)\n if (lines.length > 0) {\n const first = lines[0] ?? ''\n lines[0] = first.replace(label, context.colors.bold(label))\n }\n return lines\n })\n .join('\\n')\n}\n\nexport function renderCallout(\n callout: Callout,\n context: TerminalContext,\n): string {\n const lines = [context.colors.bold(callout.title)]\n if (callout.body) lines.push(...wrapText(callout.body, context.columns))\n if (callout.command) {\n lines.push(\n context.colors.cyan(truncateText(callout.command, context.columns)),\n )\n }\n return lines.join('\\n')\n}\n","import { type TerminalContext, wrapText } from './context.js'\n\nexport type SemanticStatus =\n | 'pass'\n | 'warning'\n | 'fail'\n | 'unknown'\n | 'info'\n | 'notApplicable'\n\nexport type SemanticDiagnostic = {\n status: SemanticStatus\n title: string\n explanation: string\n fix?: string\n evidence?: string[]\n}\n\nexport type SemanticReportSection = {\n title: string\n diagnostics: SemanticDiagnostic[]\n}\n\nexport type SemanticReportView = {\n title: string\n target?: string\n status: SemanticStatus\n summary: string\n metrics?: Array<{\n label: string\n value: string | number\n status?: SemanticStatus\n }>\n sections: SemanticReportSection[]\n notes?: string[]\n}\n\nfunction statusStyle(status: SemanticStatus, context: TerminalContext) {\n if (status === 'pass') return context.colors.green\n if (status === 'warning') return context.colors.yellow\n if (status === 'fail') return context.colors.red\n if (status === 'unknown') return context.colors.blue\n if (status === 'info') return context.colors.cyan\n return context.colors.dim\n}\n\nfunction statusLabel(status: SemanticStatus): string {\n if (status === 'warning') return 'WARN'\n if (status === 'notApplicable') return 'N/A'\n return status.toUpperCase()\n}\n\nfunction indent(value: string, spaces: number, width: number): string[] {\n const prefix = ' '.repeat(spaces)\n return wrapText(value, Math.max(1, width - spaces)).map(\n (line) => `${prefix}${line}`,\n )\n}\n\nfunction renderDiagnostic(\n diagnostic: SemanticDiagnostic,\n context: TerminalContext,\n): string {\n const style = statusStyle(diagnostic.status, context)\n const label = style(`[${statusLabel(diagnostic.status)}]`.padEnd(10))\n const titleWidth = Math.max(1, context.columns - 10)\n const titles = wrapText(diagnostic.title, titleWidth)\n const lines = titles.map(\n (line, index) =>\n `${index === 0 ? label : ' '.repeat(10)}${context.colors.bold(line)}`,\n )\n lines.push(...indent(diagnostic.explanation, 10, context.columns))\n for (const item of diagnostic.evidence ?? []) {\n const wrapped = wrapText(item, Math.max(1, context.columns - 20))\n lines.push(\n ...wrapped.map(\n (line, index) =>\n `${' '.repeat(10)}${index === 0 ? `${context.colors.dim('Evidence')} ` : ' '}${line}`,\n ),\n )\n }\n if (diagnostic.fix) {\n const wrapped = wrapText(diagnostic.fix, Math.max(1, context.columns - 15))\n lines.push(\n ...wrapped.map(\n (line, index) =>\n `${' '.repeat(10)}${index === 0 ? `${context.colors.cyan(context.colors.bold('Fix'))} ` : ' '}${line}`,\n ),\n )\n }\n return lines.join('\\n')\n}\n\nfunction renderMetrics(\n metrics: NonNullable<SemanticReportView['metrics']>,\n context: TerminalContext,\n): string {\n const line = metrics\n .map((metric) => {\n const value = String(metric.value)\n const rendered = metric.status\n ? statusStyle(metric.status, context)(value)\n : context.colors.bold(value)\n return `${metric.label} ${rendered}`\n })\n .join(context.colors.dim(' · '))\n return wrapText(line, context.columns).join('\\n')\n}\n\nexport function renderSemanticReport(\n report: SemanticReportView,\n context: TerminalContext,\n): string {\n const style = statusStyle(report.status, context)\n const output = [context.colors.bold(report.title)]\n if (report.target) output.push(context.colors.dim(report.target))\n output.push('')\n output.push(\n `${style(statusLabel(report.status))} ${wrapText(report.summary, Math.max(1, context.columns - 6)).join('\\n ')}`,\n )\n if (report.metrics?.length)\n output.push(renderMetrics(report.metrics, context))\n\n for (const section of report.sections.filter(\n (item) => item.diagnostics.length > 0,\n )) {\n output.push('', context.colors.bold(section.title))\n output.push(\n section.diagnostics\n .map((diagnostic) => renderDiagnostic(diagnostic, context))\n .join('\\n\\n'),\n )\n }\n\n if (report.notes?.length) {\n output.push('', context.colors.bold('Notes'))\n for (const note of report.notes) {\n const lines = wrapText(note, Math.max(1, context.columns - 2))\n output.push(\n ...lines.map((line, index) => `${index === 0 ? '- ' : ' '}${line}`),\n )\n }\n }\n return output.join('\\n')\n}\n","import { type TerminalContext, visibleWidth, wrapText } from './context.js'\n\nexport type CheckView = {\n detail: string\n fix?: string\n label: string\n status: 'pass' | 'warn' | 'fail'\n}\n\nexport type CatalogItemView = {\n category: string\n id: string\n name: string\n}\n\nexport type SummaryItemView = {\n description?: string\n meta?: string[]\n title: string\n}\n\nexport type ParameterView = {\n description?: string\n name: string\n required: boolean\n type: string\n}\n\nfunction plural(count: number, singular: string, multiple = `${singular}s`) {\n return count === 1 ? singular : multiple\n}\n\nfunction indented(value: string, indent: number, width: number): string[] {\n const prefix = ' '.repeat(indent)\n return wrapText(value, Math.max(1, width - indent)).map(\n (line) => `${prefix}${line}`,\n )\n}\n\nexport function renderHeading(\n title: string,\n context: TerminalContext,\n summary?: string,\n): string {\n return [\n context.colors.bold(title),\n ...(summary ? wrapText(summary, context.columns) : []),\n ].join('\\n')\n}\n\nexport function renderChecks(\n checks: CheckView[],\n context: TerminalContext,\n): string {\n const styles = {\n pass: context.colors.green,\n warn: context.colors.yellow,\n fail: context.colors.red,\n }\n return checks\n .map((check) => {\n const status = styles[check.status](check.status.toUpperCase().padEnd(4))\n const lines = [`${status} ${context.colors.bold(check.label)}`]\n lines.push(...indented(check.detail, 6, context.columns))\n if (check.fix) {\n const fixLines = wrapText(check.fix, Math.max(1, context.columns - 11))\n lines.push(\n ...fixLines.map(\n (line, index) =>\n `${' '.repeat(6)}${index === 0 ? `${context.colors.bold('Fix')} ` : ' '}${line}`,\n ),\n )\n }\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nexport function checkSummary(checks: CheckView[]): string {\n const passed = checks.filter((check) => check.status === 'pass').length\n const warnings = checks.filter((check) => check.status === 'warn').length\n const failed = checks.filter((check) => check.status === 'fail').length\n return `${passed} ${plural(passed, 'check')} passed, ${warnings} ${plural(warnings, 'warning')}, ${failed} failed.`\n}\n\nfunction renderCatalogItem(\n item: CatalogItemView,\n idWidth: number,\n context: TerminalContext,\n): string {\n const gap = 2\n const nameWidth = context.columns - idWidth - gap - 2\n if (nameWidth < 24 || visibleWidth(item.id) > idWidth) {\n return [\n ...indented(item.id, 2, context.columns).map((line) =>\n context.colors.cyan(line),\n ),\n ...indented(item.name, 4, context.columns),\n ].join('\\n')\n }\n const names = wrapText(item.name, nameWidth)\n return names\n .map((name, index) => {\n const id = index === 0 ? item.id.padEnd(idWidth) : ''.padEnd(idWidth)\n return ` ${context.colors.cyan(id)}${' '.repeat(gap)}${name}`\n })\n .join('\\n')\n}\n\nfunction categoryLabel(category: string): string {\n const value = category.replaceAll('-', ' ')\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nexport function renderCatalog(\n items: CatalogItemView[],\n context: TerminalContext,\n options: {\n categoryLabels?: Record<string, string>\n noun: string\n },\n): string {\n const groups = new Map<string, CatalogItemView[]>()\n for (const item of items) {\n const group = groups.get(item.category) ?? []\n group.push(item)\n groups.set(item.category, group)\n }\n const intro = `${items.length} ${plural(items.length, options.noun)} across ${groups.size} ${plural(groups.size, 'category', 'categories')}.`\n const idWidth = Math.min(\n 30,\n Math.max(...items.map((item) => visibleWidth(item.id)), 0),\n )\n const labelledCategories = Object.keys(options.categoryLabels ?? {}).filter(\n (category) => groups.has(category),\n )\n const remainingCategories = [...groups.keys()].filter(\n (category) => !labelledCategories.includes(category),\n )\n const sections = [...labelledCategories, ...remainingCategories].map(\n (category) => {\n const entries = groups.get(category) ?? []\n const label =\n options.categoryLabels?.[category] ?? categoryLabel(category)\n return [\n context.colors.bold(`${label} (${entries.length})`),\n ...entries.map((item) => renderCatalogItem(item, idWidth, context)),\n ].join('\\n')\n },\n )\n return [intro, ...sections].join('\\n\\n')\n}\n\nexport function renderSummaryList(\n items: SummaryItemView[],\n context: TerminalContext,\n options: { empty: string },\n): string {\n if (items.length === 0) return context.colors.dim(options.empty)\n\n return items\n .map((item) => {\n const lines = [context.colors.bold(item.title)]\n if (item.description) {\n lines.push(...indented(item.description, 2, context.columns))\n }\n const meta = item.meta?.filter(Boolean).join(' · ')\n if (meta) {\n lines.push(\n ...indented(meta, 2, context.columns).map((line) =>\n context.colors.dim(line),\n ),\n )\n }\n return lines.join('\\n')\n })\n .join('\\n\\n')\n}\n\nexport function renderSection(\n title: string,\n paragraphs: readonly string[],\n context: TerminalContext,\n): string {\n const body = paragraphs\n .filter((paragraph) => paragraph.trim().length > 0)\n .flatMap((paragraph) => wrapText(paragraph, context.columns))\n return [context.colors.bold(title), ...body].join('\\n')\n}\n\nexport function renderBulletSection(\n title: string,\n items: readonly string[],\n context: TerminalContext,\n): string {\n const body = items.flatMap((item) => {\n const wrapped = wrapText(item, Math.max(1, context.columns - 2))\n return wrapped.map((line, index) => `${index === 0 ? '- ' : ' '}${line}`)\n })\n return [context.colors.bold(title), ...body].join('\\n')\n}\n\nexport function renderParameters(\n parameters: ParameterView[],\n context: TerminalContext,\n): string {\n if (parameters.length === 0) {\n return context.colors.dim('No parameters.')\n }\n\n return renderSummaryList(\n parameters.map((parameter) => ({\n title: parameter.name,\n description: parameter.description,\n meta: [parameter.type, parameter.required ? 'required' : 'optional'],\n })),\n context,\n { empty: 'No parameters.' },\n )\n}\n","import { createTerminalContext } from './presentation/context.js'\nimport {\n renderCallout,\n renderKeyValues,\n renderTable,\n} from './presentation/render.js'\nimport {\n renderSemanticReport,\n type SemanticReportView,\n} from './presentation/report.js'\nimport {\n type CatalogItemView,\n type CheckView,\n type ParameterView,\n renderBulletSection,\n renderCatalog,\n renderChecks,\n renderHeading,\n renderParameters,\n renderSection,\n renderSummaryList,\n type SummaryItemView,\n} from './presentation/views.js'\n\nexport function canPrompt(options: { json?: boolean } = {}): boolean {\n return Boolean(\n !options.json &&\n process.stdin.isTTY &&\n process.stdout.isTTY &&\n !process.env.CI,\n )\n}\n\nexport function printJson(data: unknown): void {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n}\n\nexport function printKeyValue(rows: Array<[string, string]>): void {\n const output = renderKeyValues(rows, createTerminalContext())\n if (output) process.stdout.write(`${output}\\n`)\n}\n\nexport function printTable(\n head: string[],\n rows: Array<Array<string | number>>,\n): void {\n process.stdout.write(`${renderTable(head, rows, createTerminalContext())}\\n`)\n}\n\nexport function printCallout(callout: {\n body?: string\n command?: string\n title: string\n}): void {\n process.stdout.write(`${renderCallout(callout, createTerminalContext())}\\n`)\n}\n\nexport function printHeading(title: string, summary?: string): void {\n process.stdout.write(\n `${renderHeading(title, createTerminalContext(), summary)}\\n`,\n )\n}\n\nexport function printChecks(checks: CheckView[]): void {\n process.stdout.write(`${renderChecks(checks, createTerminalContext())}\\n`)\n}\n\nexport function printSemanticReport(report: SemanticReportView): void {\n process.stdout.write(\n `${renderSemanticReport(report, createTerminalContext())}\\n`,\n )\n}\n\nexport function printCatalog(\n items: CatalogItemView[],\n options: {\n categoryLabels?: Record<string, string>\n noun: string\n },\n): void {\n process.stdout.write(\n `${renderCatalog(items, createTerminalContext(), options)}\\n`,\n )\n}\n\nexport function printSummaryList(\n items: SummaryItemView[],\n options: { empty: string },\n): void {\n process.stdout.write(\n `${renderSummaryList(items, createTerminalContext(), options)}\\n`,\n )\n}\n\nexport function printSection(title: string, ...paragraphs: string[]): void {\n process.stdout.write(\n `${renderSection(title, paragraphs, createTerminalContext())}\\n`,\n )\n}\n\nexport function printBulletSection(\n title: string,\n items: readonly string[],\n): void {\n process.stdout.write(\n `${renderBulletSection(title, items, createTerminalContext())}\\n`,\n )\n}\n\nexport function printParameters(parameters: ParameterView[]): void {\n process.stdout.write(\n `${renderParameters(parameters, createTerminalContext())}\\n`,\n )\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`\n }\n if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`\n }\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`\n}\n\nexport function maybeExitCancelled<T>(value: T | symbol): T {\n if (typeof value === 'symbol') {\n process.exit(1)\n }\n return value\n}\n","import { type Option, select, text } from '@clack/prompts'\nimport {\n type ClientProfile,\n ga4PropertyIdFromName,\n getClient,\n listClients,\n listGa4AccountSummaries,\n listSites,\n readConfig,\n SeoError,\n} from '@seo/core'\nimport { canPrompt, maybeExitCancelled } from './utils.js'\n\ntype ResolveOptions = {\n json?: boolean\n refresh?: boolean\n}\n\ntype SiteChoice = {\n siteUrl: string\n permissionLevel?: string\n}\n\ntype GoogleAnalyticsPropertyChoice = {\n property: string\n displayName: string\n account: string\n}\n\nexport type ClientSelection = {\n client?: ClientProfile\n site: string\n}\n\nfunction includesQuery(values: string[], query: string): boolean {\n const normalized = query.trim().toLowerCase()\n if (!normalized) return true\n return values.some((value) => value.toLowerCase().includes(normalized))\n}\n\nasync function chooseFromSearch<T>(input: {\n message: string\n searchMessage: string\n emptyMessage: string\n choices: T[]\n label: (choice: T) => string\n hint?: (choice: T) => string | undefined\n searchValues: (choice: T) => string[]\n}): Promise<T> {\n let visible = input.choices\n\n if (input.choices.length > 8) {\n const query = maybeExitCancelled(\n await text({\n message: input.searchMessage,\n placeholder: 'Type part of the name or URL, or leave blank',\n }),\n )\n visible = input.choices.filter((choice) =>\n includesQuery(input.searchValues(choice), query),\n )\n\n if (!visible.length) {\n throw new SeoError('INVALID_INPUT', input.emptyMessage)\n }\n }\n\n return maybeExitCancelled(\n await select({\n message: input.message,\n options: visible.map((choice) => {\n const hint = input.hint?.(choice)\n return {\n value: choice,\n label: input.label(choice),\n ...(hint ? { hint } : {}),\n }\n }) as Option<T>[],\n }),\n )\n}\n\nexport async function resolveSite(input: {\n site?: string\n options?: ResolveOptions\n}): Promise<string> {\n if (input.site) return input.site\n\n const config = readConfig()\n const defaultSiteKnown =\n Boolean(config.defaultSite) &&\n (config.clients.some((client) => client.siteUrl === config.defaultSite) ||\n config.sites.some((site) => site.siteUrl === config.defaultSite))\n if (config.defaultSite && defaultSiteKnown) return config.defaultSite\n\n if (input.options?.json || !canPrompt()) {\n throw new SeoError(\n 'INVALID_INPUT',\n config.defaultSite\n ? `Saved default site ${config.defaultSite} does not match any saved project. Pass --site or --project, or run \\`seo start\\` to save a new default.`\n : 'No site selected. Pass --site, use --project on supported commands, or run `seo start` in a terminal.',\n )\n }\n\n const sites = await listSites(input.options?.refresh)\n if (!sites.length) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No Search Console properties found for this Google login.',\n )\n }\n if (sites.length === 1) {\n return sites[0]?.siteUrl ?? ''\n }\n\n const choice = await chooseFromSearch<SiteChoice>({\n message: 'Choose a Search Console property',\n searchMessage: 'Search Search Console properties',\n emptyMessage: 'No Search Console properties matched that search.',\n choices: sites,\n label: (site) => site.siteUrl,\n hint: (site) => site.permissionLevel,\n searchValues: (site) => [site.siteUrl, site.permissionLevel ?? ''],\n })\n\n return choice.siteUrl\n}\n\nexport async function resolveClientSelection(input: {\n client?: string\n project?: string\n site?: string\n options?: ResolveOptions\n}): Promise<ClientSelection> {\n if (input.client && input.project && input.client !== input.project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --project or --client, not both.',\n )\n }\n const project = input.project ?? input.client\n if (project) {\n const client = getClient(project)\n if (!client) {\n throw new SeoError('INVALID_INPUT', `Project not found: ${project}`)\n }\n return { client, site: client.siteUrl }\n }\n\n const defaultClient = getClient()\n if (!input.site && defaultClient) {\n return { client: defaultClient, site: defaultClient.siteUrl }\n }\n\n return {\n site: await resolveSite({ site: input.site, options: input.options }),\n }\n}\n\nexport async function resolveClient(input: {\n client?: string\n project?: string\n options?: ResolveOptions\n}): Promise<ClientProfile | undefined> {\n if (input.client && input.project && input.client !== input.project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --project or --client, not both.',\n )\n }\n const project = input.project ?? input.client\n if (project) {\n const client = getClient(project)\n if (!client) {\n throw new SeoError('INVALID_INPUT', `Project not found: ${project}`)\n }\n return client\n }\n\n const clients = listClients()\n if (!clients.length) return undefined\n const defaultClient = getClient()\n if (defaultClient) return defaultClient\n\n if (input.options?.json || !canPrompt()) return undefined\n\n return chooseFromSearch<ClientProfile>({\n message: 'Choose a project',\n searchMessage: 'Search projects',\n emptyMessage: 'No projects matched that search.',\n choices: clients,\n label: (client) => client.name,\n hint: (client) => client.siteUrl,\n searchValues: (client) => [client.id, client.name, client.siteUrl],\n })\n}\n\nexport async function resolveGoogleAnalyticsProperty(input: {\n property?: string\n options?: ResolveOptions\n}): Promise<string> {\n if (input.property) return input.property\n\n const config = readConfig()\n if (config.analytics.google.defaultPropertyId) {\n return config.analytics.google.defaultPropertyId\n }\n\n if (input.options?.json || !canPrompt()) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'No Google Analytics property selected. Pass --property or run this command in a terminal to choose one.',\n )\n }\n\n const accountSummaries = await listGa4AccountSummaries()\n const choices = accountSummaries.flatMap((account) =>\n account.propertySummaries.map((property) => ({\n property: ga4PropertyIdFromName(property.property),\n displayName: property.displayName ?? property.property,\n account: account.displayName ?? account.account,\n })),\n )\n\n if (!choices.length) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No Google Analytics properties found for this Google login.',\n )\n }\n if (choices.length === 1) {\n return choices[0]?.property ?? ''\n }\n\n const choice = await chooseFromSearch<GoogleAnalyticsPropertyChoice>({\n message: 'Choose a Google Analytics property',\n searchMessage: 'Search Google Analytics properties',\n emptyMessage: 'No Google Analytics properties matched that search.',\n choices,\n label: (property) => `${property.displayName} (${property.property})`,\n hint: (property) => property.account,\n searchValues: (property) => [\n property.property,\n property.displayName,\n property.account,\n ],\n })\n\n return choice.property\n}\n","import {\n type AiReadinessReport,\n aiReadiness,\n type CrawlReport,\n latestCrawlReport,\n loadCrawlReport,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSemanticReport } from '../utils.js'\n\nexport async function resolveSavedCrawlReport(\n args: Record<string, unknown>,\n options: { json?: boolean } = {},\n): Promise<CrawlReport> {\n const reportId = stringArg(args['report-id'])\n if (reportId) {\n const report = loadCrawlReport(reportId)\n if (!report) throw new Error(`No saved crawl report found for ${reportId}.`)\n return report\n }\n\n const project = projectArg(args)\n const site = stringArg(args.site)\n const selection =\n project || site\n ? await resolveClientSelection({\n client: project,\n site,\n options,\n })\n : undefined\n const report = latestCrawlReport(selection?.site)\n if (!report) {\n throw new Error(\n selection?.site\n ? `No saved crawl report found for ${selection.site}. Run \\`seo crawl --project ${selection.client?.id ?? selection.site} --save\\` first.`\n : 'No saved crawl report found. Run `seo crawl <url> --save` first, or pass --report-id.',\n )\n }\n return report\n}\n\nfunction printAiReadiness(report: AiReadinessReport): void {\n const count = (status: string) =>\n report.checks.filter((check) => check.status === status).length\n const failed = count('fail')\n const warnings = count('warning')\n const unknown = count('unknown')\n const passed = count('pass')\n const status = failed\n ? 'fail'\n : warnings\n ? 'warning'\n : unknown\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: 'AI search evidence',\n target: report.url,\n status,\n summary: report.headline,\n metrics: [\n { label: 'Passed', value: passed, status: 'pass' },\n { label: 'Review', value: warnings, status: 'warning' },\n { label: 'Failed', value: failed, status: 'fail' },\n { label: 'Unknown', value: unknown, status: 'unknown' },\n ],\n sections: report.sections.map((section) => ({\n title: section.title,\n diagnostics: section.checks.map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.status === 'pass' ? undefined : check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n })),\n notes: [\n `Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const aiReadinessCommand = defineCommand({\n meta: {\n name: 'ai-readiness',\n description:\n 'Review AI-search technical evidence and optional observations',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const readiness = aiReadiness(report)\n if (json) {\n printJson(readiness)\n return\n }\n printAiReadiness(readiness)\n },\n})\n","import { type AgentReadinessReport, agentReadiness, crawlSite } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSemanticReport } from '../utils.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction inputUrl(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.agentReadinessUrl)\n const flagged = stringArg(args.url)\n if (positional && flagged && positional !== flagged) {\n throw new Error('Use either the positional URL or --url, not both.')\n }\n return positional ?? flagged\n}\n\nfunction printAgentReadiness(report: AgentReadinessReport): void {\n const status =\n report.summary.failed > 0\n ? 'fail'\n : report.summary.warnings > 0\n ? 'warning'\n : report.summary.unknown > 0\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: 'AI agent readiness',\n target: report.url,\n status,\n summary: report.headline,\n metrics: [\n { label: 'Passed', value: report.summary.passed, status: 'pass' },\n {\n label: 'Review',\n value: report.summary.warnings,\n status: 'warning',\n },\n { label: 'Failed', value: report.summary.failed, status: 'fail' },\n { label: 'Unknown', value: report.summary.unknown, status: 'unknown' },\n ],\n sections: report.sections.map((section) => ({\n title: section.title,\n diagnostics: section.checks\n .filter((check) => !['info', 'notApplicable'].includes(check.status))\n .map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.status === 'pass' ? undefined : check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n })),\n notes: [\n `Profile: ${report.profile}. Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const agentReadinessCommand = defineCommand({\n meta: {\n name: 'agent-readiness',\n description:\n 'Check content-site access, Markdown alternatives, discovery, and identity for AI agents',\n },\n args: {\n agentReadinessUrl: {\n type: 'positional',\n required: false,\n description: 'Public site URL to check.',\n },\n url: {\n type: 'string',\n description: 'Public site URL to check.',\n },\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze without fetching again.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum public HTML pages to crawl.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const url = inputUrl(args)\n const reportId = stringArg(args['report-id'])\n if (url && reportId) {\n throw new Error('Use either a URL or --report-id, not both.')\n }\n\n const crawl = url\n ? await (async () => {\n const project = projectArg(args)\n const site = stringArg(args.site)\n const selection =\n project || site\n ? await resolveClientSelection({\n client: project,\n site,\n options: { json },\n })\n : undefined\n return crawlSite({\n url,\n projectId: selection?.client?.id,\n site: selection?.site,\n maxPages: numberArg(args['max-pages']),\n fetchRate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n checkAgentDiscovery: true,\n useSitemap: true,\n checkExternal: false,\n })\n })()\n : await resolveSavedCrawlReport(args, { json })\n const readiness = agentReadiness(crawl)\n if (json) {\n printJson(readiness)\n return\n }\n printAgentReadiness(readiness)\n },\n})\n","import {\n ga4PropertyIdFromName,\n listGa4AccountSummaries,\n readConfig,\n writeConfig,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson, printTable } from '../../../utils.js'\n\nexport const googleAnalyticsPropertiesCommand = defineCommand({\n meta: {\n name: 'properties',\n description: 'List Google Analytics accounts and properties',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n save: {\n type: 'string',\n description:\n 'Save this numeric Google Analytics property ID as the default.',\n },\n },\n run: async ({ args }) => {\n const summaries = await listGa4AccountSummaries()\n const rows = summaries.flatMap((account) =>\n account.propertySummaries.map((property) => ({\n account: account.displayName ?? account.account,\n property: ga4PropertyIdFromName(property.property),\n displayName: property.displayName ?? property.property,\n })),\n )\n\n const save = stringArg(args.save)\n if (save) {\n const config = readConfig()\n config.analytics.google.defaultPropertyId = save\n writeConfig(config)\n }\n\n if (jsonFlag(args)) {\n printJson({ accountSummaries: summaries, properties: rows, saved: save })\n return\n }\n if (save) {\n process.stdout.write(`Saved default Google Analytics property ${save}.\\n`)\n }\n printTable(\n ['Property', 'Name', 'Account'],\n rows.map((row) => [row.property, row.displayName, row.account]),\n )\n },\n})\n","import { truncateText } from '../presentation/context.js'\nimport type {\n SemanticDiagnostic,\n SemanticReportView,\n SemanticStatus,\n} from '../presentation/report.js'\nimport { printSemanticReport, printTable } from '../utils.js'\n\nconst HUMAN_ROW_LIMIT = 25\ntype TableRow = Array<string | number>\ntype ActionDetail = {\n label: string\n action: string\n context?: string\n}\n\ntype ReportMetric = {\n label: string\n value: string | number\n status?: SemanticStatus\n}\n\ntype ReportSummary = {\n title: string\n target?: string\n status: SemanticStatus\n summary: string\n metrics?: ReportMetric[]\n diagnostics?: {\n title: string\n items: SemanticDiagnostic[]\n }[]\n notes?: string[]\n}\n\nexport function formatCount(value: number): string {\n return Math.round(value).toLocaleString('en-GB')\n}\n\nexport function formatPosition(value: number): string {\n return value.toFixed(1)\n}\n\nexport function formatPercent(value: number): string {\n return `${(value * 100).toFixed(1)}%`\n}\n\nexport function truncate(value: string, maxLength = 72): string {\n return truncateText(value, maxLength)\n}\n\nexport function verificationSummary(report: {\n verification?: { requested: boolean; verified: number; failed: number }\n}): string {\n if (!report.verification?.requested) return 'off'\n return `${report.verification.verified} checked, ${report.verification.failed} failed`\n}\n\nexport function reportSummaryView(summary: ReportSummary): SemanticReportView {\n return {\n title: summary.title,\n target: summary.target,\n status: summary.status,\n summary: summary.summary,\n metrics: summary.metrics,\n sections: (summary.diagnostics ?? []).map((section) => ({\n title: section.title,\n diagnostics: section.items,\n })),\n notes: summary.notes,\n }\n}\n\nexport function printReportSummary(summary: ReportSummary): void {\n printSemanticReport(reportSummaryView(summary))\n}\n\nexport function printLimitedTable(head: string[], rows: TableRow[]): void {\n printTable(head, rows.slice(0, HUMAN_ROW_LIMIT))\n if (rows.length > HUMAN_ROW_LIMIT) {\n process.stdout.write(\n `Showing ${HUMAN_ROW_LIMIT} of ${rows.length}. Use --json for full data.\\n`,\n )\n }\n}\n\nexport function printActionDetails(\n title: string,\n actions: ActionDetail[],\n limit = 5,\n): void {\n const visible = actions\n .filter((item) => item.action.trim().length > 0)\n .slice(0, limit)\n const report = actionDetailsView(title, visible)\n if (!report) return\n\n process.stdout.write('\\n')\n printSemanticReport(report)\n if (actions.length > visible.length) {\n process.stdout.write(\n `Showing ${visible.length} of ${actions.length}. Use --json for full data.\\n`,\n )\n }\n}\n\nexport function actionDetailsView(\n title: string,\n actions: ActionDetail[],\n): SemanticReportView | undefined {\n if (!actions.length) return undefined\n return {\n title,\n status: 'info',\n summary: `${actions.length} ${actions.length === 1 ? 'action' : 'actions'} shown.`,\n sections: [\n {\n title: 'Actions',\n diagnostics: actions.map((item) => ({\n status: 'info',\n title: item.label,\n explanation:\n item.context ?? 'Review the evidence before making changes.',\n fix: item.action,\n })),\n },\n ],\n }\n}\n\nexport function printNextCommand(command: string): void {\n process.stdout.write(`\\nNext: ${command}\\n`)\n}\n\nexport function printNotes(title: string, notes: string[]): void {\n const visible = notes.filter((note) => note.trim().length > 0)\n if (!visible.length) return\n process.stdout.write(`\\n${title}\\n`)\n for (const note of visible) {\n process.stdout.write(`- ${note}\\n`)\n }\n}\n","import {\n ga4RowsToObjects,\n googleAnalyticsPropertyId,\n runGa4Report,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonBodyArg,\n jsonFlag,\n projectArg,\n stringArg,\n} from '../../../args.js'\nimport {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n} from '../../../selection.js'\nimport { printJson, printTable } from '../../../utils.js'\nimport { printReportSummary } from '../../output.js'\n\ntype GoogleAnalyticsPropertySelectionDependencies = {\n resolveClient: typeof resolveClient\n resolveGoogleAnalyticsProperty: typeof resolveGoogleAnalyticsProperty\n}\n\nexport async function resolveGoogleAnalyticsReportProperty(\n input: {\n property?: string\n project?: string\n options?: { json?: boolean }\n },\n dependencies: GoogleAnalyticsPropertySelectionDependencies = {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n },\n): Promise<string> {\n if (input.property) {\n return dependencies.resolveGoogleAnalyticsProperty({\n property: input.property,\n options: input.options,\n })\n }\n\n const client = await dependencies.resolveClient({\n client: input.project,\n options: input.options,\n })\n return dependencies.resolveGoogleAnalyticsProperty({\n property: googleAnalyticsPropertyId(client),\n options: input.options,\n })\n}\n\nexport const googleAnalyticsReportCommand = defineCommand({\n meta: {\n name: 'report',\n description: 'Run a Google Analytics report',\n },\n args: {\n property: {\n type: 'string',\n description:\n 'Google Analytics property ID. If omitted in a terminal, choose one.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name with an optional Google Analytics property.',\n },\n 'start-date': { type: 'string', default: '28daysAgo' },\n 'end-date': { type: 'string', default: 'yesterday' },\n dimensions: { type: 'string', default: 'landingPage' },\n metrics: { type: 'string', default: 'sessions,totalUsers,eventCount' },\n limit: { type: 'string', default: '25' },\n body: { type: 'string' },\n 'body-file': { type: 'string' },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local Google Analytics cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const property = await resolveGoogleAnalyticsReportProperty({\n property: stringArg(args.property),\n project: projectArg(args),\n options: { json },\n })\n const body =\n (await jsonBodyArg(args.body, args['body-file'])) ??\n ({\n dateRanges: [\n {\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n },\n ],\n dimensions: (csvArg(args.dimensions) ?? []).map((name) => ({ name })),\n metrics: (csvArg(args.metrics) ?? []).map((name) => ({ name })),\n limit: stringArg(args.limit),\n } as Record<string, unknown>)\n const result = await runGa4Report(property, body as never, {\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(result)\n return\n }\n const rows = ga4RowsToObjects(result)\n printReportSummary({\n title: 'Google Analytics report',\n target: property,\n status: 'info',\n summary: `${result.rowCount ?? rows.length} rows returned for the requested dimensions and metrics.`,\n metrics: [\n { label: 'Rows', value: result.rowCount ?? rows.length },\n { label: 'Displayed', value: Math.min(rows.length, 25) },\n ],\n })\n if (rows.length) {\n const headings = Object.keys(rows[0] ?? {})\n printTable(\n headings,\n rows\n .slice(0, 25)\n .map((row) => headings.map((heading) => row[heading] ?? '')),\n )\n }\n },\n})\n","import { defineCommand } from 'citty'\nimport { googleAnalyticsPropertiesCommand } from './properties.js'\nimport { googleAnalyticsReportCommand } from './report.js'\n\nexport const googleAnalyticsCommand = defineCommand({\n meta: {\n name: 'google',\n description: 'Read Google Analytics properties and reports',\n },\n subCommands: {\n properties: googleAnalyticsPropertiesCommand,\n report: googleAnalyticsReportCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { googleAnalyticsCommand } from './google/index.js'\n\nexport const analyticsCommand = defineCommand({\n meta: {\n name: 'analytics',\n description: 'Read analytics data from connected providers',\n },\n subCommands: {\n google: googleAnalyticsCommand,\n },\n})\n","import { intro, note, outro, password, text } from '@clack/prompts'\nimport {\n authStatus,\n deleteTokens,\n formatRelativeExpiry,\n getSeoCliPaths,\n getTokenStorageStatus,\n loginWithLoopback,\n refreshAuthToken,\n SeoError,\n setTokenStorageMode,\n writeOauthClient,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n} from '../utils.js'\n\nfunction serviceAccountSource(source?: string): string {\n if (!source) return 'invalid or conflicting configuration'\n if (source === 'environment-json') {\n return 'SEO_GOOGLE_SERVICE_ACCOUNT_JSON'\n }\n if (source === 'environment-file') {\n return 'SEO_GOOGLE_SERVICE_ACCOUNT_FILE'\n }\n return 'GOOGLE_APPLICATION_CREDENTIALS'\n}\n\nfunction tokenStorageLabel(input: {\n configured: 'keychain' | 'file'\n active: 'keychain' | 'file'\n reason?: string\n}): string {\n if (input.active === 'keychain') return 'system keychain'\n return input.configured === 'keychain'\n ? 'private file fallback'\n : 'private file'\n}\n\nfunction oauthClientLabel(source: 'shared' | 'byo'): string {\n return source === 'shared' ? 'SEO Skill app' : 'Local OAuth config'\n}\n\nfunction oauthIdentityRows(input: {\n accountEmail: string\n clientSource: 'shared' | 'byo'\n expiresAt: number\n scope: string\n}): Array<[string, string]> {\n const rows: Array<[string, string]> = [['Account', input.accountEmail]]\n const scopes = new Set(input.scope.split(/\\s+/u).filter(Boolean))\n\n if (scopes.has('https://www.googleapis.com/auth/webmasters.readonly')) {\n rows.push(['Search Console', 'Read only'])\n } else {\n rows.push(['Search Console', 'Not granted'])\n }\n if (scopes.has('https://www.googleapis.com/auth/analytics.readonly')) {\n rows.push(['Google Analytics', 'Read only'])\n } else {\n rows.push(['Google Analytics', 'Not granted'])\n }\n rows.push(\n ['OAuth app', oauthClientLabel(input.clientSource)],\n ['Expires', formatRelativeExpiry(input.expiresAt)],\n )\n return rows\n}\n\nexport const authCommand = defineCommand({\n meta: {\n name: 'auth',\n description: 'Authentication commands',\n },\n subCommands: {\n login: defineCommand({\n meta: { name: 'login', description: 'Run Google OAuth flow' },\n run: async () => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n throw new SeoError(\n 'AUTH_CONFIG_REQUIRED',\n 'A service account is active from the environment. Unset its credential variable before running browser OAuth.',\n )\n }\n const tokens = await loginWithLoopback()\n printKeyValue(\n oauthIdentityRows({\n accountEmail: tokens.account_email,\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n scope: tokens.scope,\n }),\n )\n },\n }),\n logout: defineCommand({\n meta: { name: 'logout', description: 'Delete locally stored tokens' },\n run: async () => {\n const status = await authStatus()\n await deleteTokens()\n if (status.activeMode === 'service-account') {\n process.stdout.write(\n 'Deleted local OAuth tokens. Service account credentials remain available through the environment.\\n',\n )\n return\n }\n process.stdout.write(\n 'Deleted local OAuth tokens.\\nRevoke at https://myaccount.google.com/permissions if you also want Google to forget the grant.\\n',\n )\n },\n }),\n whoami: defineCommand({\n meta: {\n name: 'whoami',\n description: 'Show the signed-in Google account',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n const result = {\n mode: 'service-account',\n account: status.identity ?? null,\n source: serviceAccountSource(status.serviceAccount.source),\n }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n ['Account type', 'Service account'],\n ['Account', status.identity ?? 'Invalid configuration'],\n ['Credentials', result.source],\n ['Access', 'Search Console and Google Analytics, read only'],\n ])\n return\n }\n const tokens = status.tokens\n if (!tokens) {\n if (jsonFlag(args)) {\n printJson({ mode: 'oauth', account: null })\n return\n }\n process.stdout.write('Not logged in.\\n')\n return\n }\n if (jsonFlag(args)) {\n printJson({\n mode: 'oauth',\n account: tokens.account_email,\n scopes: tokens.scope.split(/\\s+/u).filter(Boolean),\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n })\n return\n }\n printKeyValue(\n oauthIdentityRows({\n accountEmail: tokens.account_email,\n clientSource: tokens.client_source,\n expiresAt: tokens.expires_at,\n scope: tokens.scope,\n }),\n )\n },\n }),\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show local Google auth status',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const status = await authStatus()\n const storage =\n status.activeMode === 'oauth'\n ? await getTokenStorageStatus()\n : undefined\n if (jsonFlag(args)) {\n printJson({\n authenticated:\n status.activeMode === 'oauth'\n ? Boolean(status.tokens)\n : status.serviceAccount.configured,\n mode: status.activeMode,\n identity: status.identity,\n account:\n status.activeMode === 'oauth'\n ? status.tokens?.account_email\n : undefined,\n scopes:\n status.activeMode === 'oauth' ? status.tokens?.scope : undefined,\n clientSource:\n status.activeMode === 'oauth'\n ? status.tokens?.client_source\n : undefined,\n expiresAt:\n status.activeMode === 'oauth'\n ? status.tokens?.expires_at\n : undefined,\n sharedConfigured: status.sharedConfigured,\n byoConfigured: status.byoConfigured,\n serviceAccount: {\n configured: status.serviceAccount.configured,\n identity: status.serviceAccount.identity,\n source: status.serviceAccount.source,\n error: status.serviceAccount.error,\n },\n ...(storage ? { tokenStorage: storage } : {}),\n })\n return\n }\n if (status.activeMode === 'service-account') {\n const rows: Array<[string, string]> = [\n ['Mode', 'service account'],\n ['Identity', status.identity ?? 'unavailable'],\n ['Source', serviceAccountSource(status.serviceAccount.source)],\n ['Scopes', 'Search Console readonly, Google Analytics readonly'],\n ['Storage', 'credentials stay in the environment'],\n ]\n if (status.serviceAccount.error) {\n rows.push(['Status', status.serviceAccount.error])\n }\n printKeyValue(rows)\n return\n }\n if (!status.tokens) {\n const authMode = status.serviceAccount.error\n ? status.serviceAccount.error\n : status.sharedConfigured\n ? 'Shared seo app available'\n : status.byoConfigured\n ? 'Local OAuth config available'\n : 'No OAuth client configured'\n process.stdout.write(\n `Not logged in. ${authMode}. Run \\`seo auth login\\` to connect Google.\\n`,\n )\n return\n }\n const tokenStorage = storage ?? (await getTokenStorageStatus())\n printKeyValue([\n ['Account', status.tokens.account_email],\n ['Scopes', status.tokens.scope],\n ['Client', oauthClientLabel(status.tokens.client_source)],\n ['Expires', formatRelativeExpiry(status.tokens.expires_at)],\n ['Tokens file', getSeoCliPaths().tokensFile],\n ['Token storage', tokenStorageLabel(tokenStorage)],\n ...(tokenStorage.reason\n ? [['Storage note', tokenStorage.reason] as [string, string]]\n : []),\n [\n 'OAuth mode',\n status.sharedConfigured\n ? 'SEO Skill app available'\n : status.byoConfigured\n ? 'Local OAuth config available'\n : 'missing',\n ],\n ['Revoke at', 'https://myaccount.google.com/permissions'],\n ])\n },\n }),\n storage: defineCommand({\n meta: {\n name: 'storage',\n description: 'Show or change local OAuth token storage',\n },\n args: {\n keychain: {\n type: 'boolean',\n default: false,\n description:\n 'Store OAuth tokens in the system keychain when available.',\n },\n file: {\n type: 'boolean',\n default: false,\n description: 'Store OAuth tokens in the private local file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n if (args.keychain && args.file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Choose either --keychain or --file, not both.',\n )\n }\n const storage =\n args.keychain || args.file\n ? await setTokenStorageMode(args.keychain ? 'keychain' : 'file')\n : await getTokenStorageStatus()\n\n if (jsonFlag(args)) {\n printJson(storage)\n return\n }\n\n printKeyValue([\n ['Configured storage', storage.configured],\n ['Active storage', tokenStorageLabel(storage)],\n ...(storage.reason\n ? [['Note', storage.reason] as [string, string]]\n : []),\n ])\n },\n }),\n refresh: defineCommand({\n meta: {\n name: 'refresh',\n description: 'Refresh the Google OAuth token',\n },\n run: async () => {\n const status = await authStatus()\n if (status.activeMode === 'service-account') {\n process.stdout.write(\n 'Service accounts request short-lived Google tokens automatically. No local refresh token is stored.\\n',\n )\n return\n }\n const tokens = await refreshAuthToken()\n process.stdout.write(\n `Refreshed. New expiry ${new Date(tokens.expires_at).toISOString()}.\\n`,\n )\n },\n }),\n 'setup-client': defineCommand({\n meta: {\n name: 'setup-client',\n description: 'Save your own Google Desktop OAuth client',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Return a structured error instead of prompting.',\n },\n },\n run: async ({ args }) => {\n if (!canPrompt({ json: jsonFlag(args) })) {\n throw new SeoError(\n 'INVALID_INPUT',\n '`seo auth setup-client` needs an interactive terminal. Run it without --json, or set SEO_GOOGLE_CLIENT_ID and SEO_GOOGLE_CLIENT_SECRET.',\n )\n }\n intro('Local Google OAuth client')\n note(\n [\n 'This is the advanced path.',\n 'Most users should use the shared seo Google app.',\n 'Your actual sensitive data is the local refresh token, not the desktop app client secret.',\n ].join('\\n'),\n 'Advanced',\n )\n const clientId = maybeExitCancelled(\n await text({\n message: 'Google Desktop OAuth client ID',\n validate: (value) => (value ? undefined : 'Client ID is required'),\n }),\n )\n const clientSecret = maybeExitCancelled(\n await password({\n message: 'Google Desktop OAuth client secret',\n validate: (value) =>\n value ? undefined : 'Client secret is required',\n }),\n )\n writeOauthClient({ clientId, clientSecret })\n outro(`Saved local OAuth config to ${getSeoCliPaths().oauthClientFile}`)\n },\n }),\n },\n})\n","import { clearCache, getCacheStats, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { formatBytes, printKeyValue } from '../utils.js'\n\nconst CACHE_PROVIDERS = [\n 'gsc',\n 'google-analytics',\n 'semrush',\n 'dataforseo',\n 'http',\n] as const\n\nfunction cacheProvider(\n value: unknown,\n): (typeof CACHE_PROVIDERS)[number] | undefined {\n if (value === undefined) return undefined\n if (\n typeof value === 'string' &&\n CACHE_PROVIDERS.includes(value as (typeof CACHE_PROVIDERS)[number])\n ) {\n return value as (typeof CACHE_PROVIDERS)[number]\n }\n throw new SeoError(\n 'INVALID_INPUT',\n `--provider must be one of: ${CACHE_PROVIDERS.join(', ')}.`,\n )\n}\n\nexport const cacheCommand = defineCommand({\n meta: { name: 'cache', description: 'Cache helpers' },\n subCommands: {\n stats: defineCommand({\n meta: {\n name: 'stats',\n description: 'Show local cache size and row counts',\n },\n run: async () => {\n const stats = getCacheStats()\n printKeyValue([\n ['DB', stats.dbPath],\n ['Size', formatBytes(stats.sizeBytes)],\n [\n 'Cached data',\n `${formatBytes(stats.logicalSizeBytes)} of ${formatBytes(stats.maxSizeBytes)} automatic limit`,\n ],\n ['Sites', String(stats.counts.sites ?? 0)],\n ['Search Console', String(stats.counts.gsc_cache ?? 0)],\n [\n 'Google Analytics',\n String(stats.counts.google_analytics_cache ?? 0),\n ],\n ['Semrush', String(stats.counts.semrush_cache ?? 0)],\n ['DataForSEO', String(stats.counts.provider_cache ?? 0)],\n ['HTTP', String(stats.counts.http_cache ?? 0)],\n ])\n },\n }),\n clear: defineCommand({\n meta: {\n name: 'clear',\n description: 'Clear cached API and HTTP data',\n },\n args: {\n provider: {\n type: 'string',\n description:\n 'Optional cache provider: gsc, google-analytics, semrush, dataforseo, or http',\n },\n },\n run: async ({ args }) => {\n const removed = clearCache(cacheProvider(args.provider))\n process.stdout.write(`Removed ${removed} cached rows.\\n`)\n },\n }),\n },\n})\n","import type {\n PageFetchDiagnostics,\n QueryContentClassification,\n} from '@seo/core'\nimport { resolveClientSelection } from '../selection.js'\n\nexport async function selectedSiteOrThrow(\n input: {\n client?: string\n project?: string\n site?: string\n },\n options: { json?: boolean; refresh?: boolean } = {},\n): Promise<string> {\n return (\n await resolveClientSelection({\n client: input.client,\n project: input.project,\n site: input.site,\n options,\n })\n ).site\n}\n\nexport function startUrlForSite(site: string): string | undefined {\n if (site.startsWith('http://') || site.startsWith('https://')) return site\n if (site.startsWith('sc-domain:')) return `https://${site.slice(10)}/`\n return undefined\n}\n\nexport function suggestedClientName(site: string): string {\n return site.replace(/^sc-domain:/, '').replace(/^https?:\\/\\//, '')\n}\n\nexport function slugId(value: string): string {\n return value\n .toLowerCase()\n .replace(/^https?:\\/\\//, '')\n .replace(/^sc-domain:/, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n}\n\nexport function formatFetchDiagnostics(\n diagnostics?: PageFetchDiagnostics,\n): string {\n if (!diagnostics) return '-'\n if (diagnostics.backpressure?.status === 'stopped') {\n return `stopped: ${diagnostics.backpressure.reason ?? 'origin cooldown'}`\n }\n if (diagnostics.backpressure?.status === 'slowed') {\n return `slowed ${diagnostics.backpressure.delayMs}ms`\n }\n if (diagnostics.rendering?.status === 'unavailable') {\n return 'raw HTML; rendering unavailable'\n }\n if (diagnostics.rendering?.status === 'failed') {\n return 'raw HTML; rendering failed'\n }\n if (diagnostics.blocked) return 'blocked'\n if (diagnostics.rendered) return 'rendered'\n if (diagnostics.cache === 'hit') return 'cached'\n if (diagnostics.fetched) return 'fetched'\n return diagnostics.source\n}\n\nexport function formatContentCheck(\n classification?: QueryContentClassification,\n): string {\n if (!classification) return '-'\n if (classification === 'serp-framing') return 'wording gap'\n if (classification === 'content-gap') return 'content gap'\n if (classification === 'technical-check') return 'technical check'\n return 'covered'\n}\n","import { existsSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, posix, win32 } from 'node:path'\n\nexport type SupportedClient =\n | 'claude-desktop'\n | 'claude-code'\n | 'codex'\n | 'cursor'\n\ninterface BaseClientTarget {\n client: SupportedClient\n label: string\n path: string\n commandNames: string[]\n detectionPaths: string[]\n}\n\nexport interface JsonClientConfigTarget extends BaseClientTarget {\n kind: 'json'\n includeType?: boolean\n}\n\nexport interface NativeClientConfigTarget extends BaseClientTarget {\n kind: 'native'\n executable: 'codex'\n}\n\nexport type ClientConfigTarget =\n | JsonClientConfigTarget\n | NativeClientConfigTarget\n\nfunction platformConfigRoot(input: {\n home: string\n platform: NodeJS.Platform\n env: NodeJS.ProcessEnv\n}): string {\n const path = input.platform === 'win32' ? win32 : posix\n if (input.platform === 'win32') {\n return input.env.APPDATA ?? path.resolve(input.home, 'AppData/Roaming')\n }\n if (input.platform === 'darwin') {\n return path.resolve(input.home, 'Library/Application Support')\n }\n return input.env.XDG_CONFIG_HOME ?? path.resolve(input.home, '.config')\n}\n\nexport function mcpClientTargets(\n input: {\n home?: string\n platform?: NodeJS.Platform\n env?: NodeJS.ProcessEnv\n } = {},\n): ClientConfigTarget[] {\n const home = input.home ?? homedir()\n const platform = input.platform ?? process.platform\n const env = input.env ?? process.env\n const configRoot = platformConfigRoot({ home, platform, env })\n const path = platform === 'win32' ? win32 : posix\n const targets: ClientConfigTarget[] = []\n\n if (platform === 'darwin' || platform === 'win32') {\n const claudeRoot = path.resolve(configRoot, 'Claude')\n targets.push({\n kind: 'json',\n client: 'claude-desktop',\n label: 'Claude Desktop',\n path: path.resolve(claudeRoot, 'claude_desktop_config.json'),\n commandNames: [],\n detectionPaths:\n platform === 'darwin'\n ? [claudeRoot, '/Applications/Claude.app']\n : [claudeRoot],\n })\n }\n\n targets.push(\n {\n kind: 'json',\n client: 'claude-code',\n label: 'Claude Code',\n path: path.resolve(home, '.claude.json'),\n includeType: true,\n commandNames: ['claude'],\n detectionPaths: [path.resolve(home, '.claude')],\n },\n {\n kind: 'native',\n client: 'codex',\n label: 'Codex',\n path: path.resolve(home, '.codex/config.toml'),\n executable: 'codex',\n commandNames: ['codex'],\n detectionPaths: [path.resolve(home, '.codex')],\n },\n {\n kind: 'json',\n client: 'cursor',\n label: 'Cursor',\n path: path.resolve(home, '.cursor/mcp.json'),\n commandNames: ['cursor', 'cursor-agent'],\n detectionPaths: [\n path.resolve(home, '.cursor'),\n ...(platform === 'darwin' ? ['/Applications/Cursor.app'] : []),\n ],\n },\n )\n\n return targets\n}\n\nexport function resolveMcpClientExecutable(\n command: string,\n input: {\n exists?: (path: string) => boolean\n nodePath?: string\n path?: string\n platform?: NodeJS.Platform\n } = {},\n): string {\n const platform = input.platform ?? process.platform\n const exists = input.exists ?? existsSync\n const nodePath = input.nodePath ?? process.execPath\n const names =\n platform === 'win32'\n ? [`${command}.cmd`, `${command}.exe`, command]\n : [command]\n\n const pathEntries = (input.path ?? process.env.PATH ?? '')\n .split(platform === 'win32' ? ';' : ':')\n .filter(Boolean)\n for (const directory of pathEntries) {\n for (const name of names) {\n const candidate = join(directory, name)\n if (exists(candidate)) return candidate\n }\n }\n\n for (const name of names) {\n const candidate = join(dirname(nodePath), name)\n if (exists(candidate)) return candidate\n }\n return command\n}\n\nfunction commandExists(command: string): boolean {\n return resolveMcpClientExecutable(command) !== command\n}\n\nexport function detectMcpClients(\n input: {\n targets?: ClientConfigTarget[]\n hasCommand?: (command: string) => boolean\n hasPath?: (path: string) => boolean\n } = {},\n): ClientConfigTarget[] {\n const targets = input.targets ?? mcpClientTargets()\n const hasCommand = input.hasCommand ?? commandExists\n const hasPath = input.hasPath ?? existsSync\n return targets.filter((target) => {\n if (target.kind === 'native') {\n return target.commandNames.some(hasCommand)\n }\n return (\n hasPath(target.path) ||\n target.detectionPaths.some(hasPath) ||\n target.commandNames.some(hasCommand)\n )\n })\n}\n","import { spawnSync } from 'node:child_process'\nimport {\n constants,\n copyFileSync,\n existsSync,\n mkdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { dirname } from 'node:path'\nimport { isDeepStrictEqual } from 'node:util'\nimport { getSeoCliPaths, SEO_VERSION } from '@seo/core'\nimport {\n applyEdits,\n modify,\n type ParseError,\n parse,\n printParseErrorCode,\n} from 'jsonc-parser'\nimport type {\n ClientConfigTarget,\n JsonClientConfigTarget,\n NativeClientConfigTarget,\n SupportedClient,\n} from './mcp-clients.js'\nimport { resolveMcpClientExecutable } from './mcp-clients.js'\n\ninterface CommandResult {\n status: number | null\n stdout: string\n stderr: string\n error?: Error\n}\n\ntype CommandRunner = (command: string, args: string[]) => CommandResult\n\nexport interface McpServerCommand {\n command: string\n args: string[]\n}\n\nexport interface McpConfigOptions {\n runCommand?: CommandRunner\n reinstall?: boolean\n serverCommand?: McpServerCommand\n}\n\nconst formattingOptions = {\n insertSpaces: true,\n tabSize: 2,\n eol: '\\n',\n}\n\nfunction timestamp(): string {\n return new Date().toISOString().replace(/[:.]/g, '-')\n}\n\nfunction writeAtomic(path: string, value: string): void {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 })\n const tmp = `${path}.${process.pid}.${Date.now()}.tmp`\n const mode = existsSync(path) ? statSync(path).mode & 0o777 : 0o600\n writeFileSync(tmp, value, { encoding: 'utf8', mode })\n renameSync(tmp, path)\n}\n\nfunction backup(path: string): void {\n const base = `${path}.bak-${timestamp()}`\n let candidate = base\n let suffix = 2\n while (existsSync(candidate)) {\n candidate = `${base}-${suffix}`\n suffix += 1\n }\n copyFileSync(path, candidate, constants.COPYFILE_EXCL)\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction readConfig(target: JsonClientConfigTarget): {\n source: string\n config: Record<string, unknown>\n} {\n if (!existsSync(target.path)) return { source: '{}\\n', config: {} }\n\n const source = readFileSync(target.path, 'utf8')\n const errors: ParseError[] = []\n const config = parse(source, errors, { allowTrailingComma: true })\n if (errors.length > 0) {\n const first = errors[0]\n const detail = first\n ? `${printParseErrorCode(first.error)} at offset ${first.offset}`\n : 'unknown parse error'\n throw new Error(`Cannot update ${target.path}: invalid JSONC (${detail}).`)\n }\n if (!isRecord(config)) {\n throw new Error(\n `Cannot update ${target.path}: config root must be an object.`,\n )\n }\n if (config.mcpServers !== undefined && !isRecord(config.mcpServers)) {\n throw new Error(\n `Cannot update ${target.path}: mcpServers must be an object.`,\n )\n }\n return { source, config }\n}\n\nfunction isSeoPackageCommand(args: string[]): boolean {\n return (\n args.includes('mcp') &&\n args.includes('serve') &&\n args.some(\n (item) =>\n item === 'seo' || item.startsWith('seo@') || item === '@seo/cli',\n )\n )\n}\n\nfunction isManagedNodeCommand(\n value: Record<string, unknown>,\n args: string[],\n): boolean {\n if (\n typeof value.command !== 'string' ||\n args.length !== 3 ||\n args[1] !== 'mcp' ||\n args[2] !== 'serve' ||\n !isRecord(value.env)\n ) {\n return false\n }\n return value.env.SEO_MCP_CONFIGURED_BY === 'seo'\n}\n\nfunction managedServer(value: unknown): boolean {\n if (!isRecord(value) || !Array.isArray(value.args)) return false\n const args = value.args.filter(\n (item): item is string => typeof item === 'string',\n )\n return isSeoPackageCommand(args) || isManagedNodeCommand(value, args)\n}\n\nfunction writeConfigEdit(input: {\n target: JsonClientConfigTarget\n source: string\n value: unknown\n}): void {\n const next = applyEdits(\n input.source,\n modify(input.source, ['mcpServers', 'seo'], input.value, {\n formattingOptions,\n }),\n )\n if (existsSync(input.target.path)) backup(input.target.path)\n writeAtomic(input.target.path, next)\n}\n\nfunction defaultCommandRunner(command: string, args: string[]): CommandResult {\n const result = spawnSync(command, args, { encoding: 'utf8' })\n return {\n status: result.status,\n stdout: result.stdout ?? '',\n stderr: result.stderr ?? '',\n error: result.error,\n }\n}\n\nfunction isTemporaryNpxPath(path: string): boolean {\n const normalized = path.replaceAll('\\\\', '/').toLowerCase()\n return (\n normalized.includes('/_npx/') ||\n normalized.includes('/.npm/_npx/') ||\n normalized.includes('/.cache/pnpm/dlx/')\n )\n}\n\nfunction installedCliPath(cliPath: string | undefined): string | undefined {\n if (!cliPath || !existsSync(cliPath)) return undefined\n const resolved = realpathSync(cliPath)\n return isTemporaryNpxPath(resolved) ? undefined : resolved\n}\n\nexport function resolveMcpServerCommand(\n input: {\n cliPath?: string\n nodePath?: string\n platform?: NodeJS.Platform\n version?: string\n } = {},\n): McpServerCommand {\n const cliPath = installedCliPath(input.cliPath ?? process.argv[1])\n if (cliPath) {\n return {\n command: input.nodePath ?? process.execPath,\n args: [cliPath, 'mcp', 'serve'],\n }\n }\n\n const packageName = `seo@${input.version ?? SEO_VERSION}`\n if ((input.platform ?? process.platform) === 'win32') {\n return {\n command: 'cmd',\n args: ['/c', 'npx', '-y', packageName, 'mcp', 'serve'],\n }\n }\n return { command: 'npx', args: ['-y', packageName, 'mcp', 'serve'] }\n}\n\nfunction serverConfig(\n includeType = false,\n command = resolveMcpServerCommand(),\n): Record<string, unknown> {\n const paths = getSeoCliPaths()\n const config: Record<string, unknown> = {\n command: command.command,\n args: command.args,\n env: {\n SEO_CONFIG_DIR: paths.configDir,\n SEO_MCP_CONFIGURED_BY: 'seo',\n },\n }\n if (includeType) config.type = 'stdio'\n return config\n}\n\nfunction codexManaged(output: string): boolean {\n return (\n output.includes('SEO_MCP_CONFIGURED_BY') ||\n /args:\\s+-y\\s+(?:seo(?:@\\S+)?|@seo\\/cli)\\s+mcp\\s+serve\\b/.test(output)\n )\n}\n\nfunction codexCommand(\n target: NativeClientConfigTarget,\n operation: 'install' | 'uninstall',\n options: Required<\n Pick<McpConfigOptions, 'runCommand' | 'reinstall' | 'serverCommand'>\n >,\n): { client: SupportedClient; path: string; changed: boolean } {\n const executable = resolveMcpClientExecutable(target.executable)\n const current = options.runCommand(executable, ['mcp', 'get', 'seo'])\n if ((current.error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT') {\n throw new Error(\n 'Cannot install SEO MCP for Codex: the `codex` command is not available on PATH. Install Codex CLI or choose another MCP client.',\n )\n }\n const exists = current.status === 0\n if (exists && !codexManaged(current.stdout)) {\n throw new Error(\n `Cannot ${operation} SEO MCP: ${target.path} already has an unmanaged mcp_servers.seo entry.`,\n )\n }\n if (operation === 'install' && exists && !options.reinstall) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (operation === 'uninstall' && !exists) {\n return { client: target.client, path: target.path, changed: false }\n }\n\n if (operation === 'install' && exists) {\n const removed = options.runCommand(executable, ['mcp', 'remove', 'seo'])\n if (removed.error || removed.status !== 0) {\n const detail =\n removed.error?.message ?? removed.stderr.trim() ?? 'unknown error'\n throw new Error(`Cannot reinstall SEO MCP for Codex: ${detail}`)\n }\n }\n\n const paths = getSeoCliPaths()\n const args =\n operation === 'install'\n ? [\n 'mcp',\n 'add',\n 'seo',\n '--env',\n `SEO_CONFIG_DIR=${paths.configDir}`,\n '--env',\n 'SEO_MCP_CONFIGURED_BY=seo',\n '--',\n options.serverCommand.command,\n ...options.serverCommand.args,\n ]\n : ['mcp', 'remove', 'seo']\n const result = options.runCommand(executable, args)\n if (result.error || result.status !== 0) {\n const detail =\n result.error?.message ?? result.stderr.trim() ?? 'unknown error'\n throw new Error(`Cannot ${operation} SEO MCP for Codex: ${detail}`)\n }\n return { client: target.client, path: target.path, changed: true }\n}\n\nexport function installMcpConfig(\n target: ClientConfigTarget,\n options: McpConfigOptions = {},\n): { client: SupportedClient; path: string; changed: boolean } {\n const resolved = {\n runCommand: options.runCommand ?? defaultCommandRunner,\n reinstall: options.reinstall ?? false,\n serverCommand: options.serverCommand ?? resolveMcpServerCommand(),\n }\n if (target.kind === 'native') {\n return codexCommand(target, 'install', resolved)\n }\n\n const { source, config } = readConfig(target)\n const servers = config.mcpServers as Record<string, unknown> | undefined\n const current = servers?.seo\n const desired = serverConfig(target.includeType, resolved.serverCommand)\n if (isDeepStrictEqual(current, desired) && !resolved.reinstall) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (current !== undefined && !managedServer(current)) {\n throw new Error(\n `Cannot install SEO MCP: ${target.path} already has an unmanaged mcpServers.seo entry.`,\n )\n }\n\n writeConfigEdit({ target, source, value: desired })\n return { client: target.client, path: target.path, changed: true }\n}\n\nexport function uninstallMcpConfig(\n target: ClientConfigTarget,\n options: Pick<McpConfigOptions, 'runCommand'> = {},\n): { client: SupportedClient; path: string; changed: boolean } {\n if (target.kind === 'native') {\n return codexCommand(target, 'uninstall', {\n runCommand: options.runCommand ?? defaultCommandRunner,\n reinstall: false,\n serverCommand: resolveMcpServerCommand(),\n })\n }\n if (!existsSync(target.path)) {\n return { client: target.client, path: target.path, changed: false }\n }\n\n const { source, config } = readConfig(target)\n const servers = config.mcpServers as Record<string, unknown> | undefined\n if (servers?.seo === undefined) {\n return { client: target.client, path: target.path, changed: false }\n }\n if (!managedServer(servers.seo)) {\n throw new Error(\n `Cannot uninstall SEO MCP: ${target.path} has an unmanaged mcpServers.seo entry.`,\n )\n }\n\n writeConfigEdit({ target, source, value: undefined })\n return { client: target.client, path: target.path, changed: true }\n}\n","import { spawnSync } from 'node:child_process'\n\nexport type SkillInstallOutcome =\n | { status: 'installed' }\n | { status: 'failed'; error: string }\n\n/**\n * Install the packaged router skill for coding agents through the skills\n * ecosystem. Used by guided setup and by `seo skill install`.\n */\nexport function installSeoSkill(\n options: { quiet?: boolean } = {},\n): SkillInstallOutcome {\n const result = spawnSync('npx', ['-y', 'skills', 'add', 'iannuttall/seo'], {\n stdio: options.quiet ? 'ignore' : 'inherit',\n })\n if (result.error) {\n return { status: 'failed', error: result.error.message }\n }\n if (result.status !== 0) {\n return {\n status: 'failed',\n error: `npx skills add exited with status ${result.status ?? 'unknown'}.`,\n }\n }\n return { status: 'installed' }\n}\n","import {\n confirm,\n multiselect,\n note,\n password,\n select,\n text,\n} from '@clack/prompts'\nimport {\n authStatus,\n type Ga4WebStreamCandidate,\n type Ga4WebStreamMatch,\n ga4MatchReason,\n ga4PropertyIdFromName,\n listGa4AccountSummaries,\n listGa4DataStreams,\n loginWithLoopback,\n matchGa4WebStreams,\n SeoError,\n writeOauthClient,\n} from '@seo/core'\nimport { canPrompt, maybeExitCancelled } from '../../utils.js'\nimport { detectMcpClients } from '../mcp-clients.js'\nimport { installMcpConfig } from '../mcp-config.js'\nimport { installSeoSkill } from '../skill-install.js'\n\nexport type SetupAuthStatus =\n | 'connected'\n | 'already-connected'\n | 'service-account'\n | 'skipped'\nexport type SetupMcpInstall = {\n client: string\n path: string\n changed: boolean\n error?: string\n}\nexport type SetupGoogleAnalyticsSelection = {\n propertyId: string\n selection: 'explicit' | 'matched' | 'manual'\n reason: string\n}\nexport type SetupSkillInstall = {\n status: 'installed' | 'declined' | 'skipped' | 'failed'\n error?: string\n}\n\ntype GoogleAnalyticsPropertyChoice = {\n property: string\n label: string\n account: string\n}\n\ntype GoogleAnalyticsSetupChoice = GoogleAnalyticsPropertyChoice & {\n match?: Ga4WebStreamMatch\n}\n\ntype AuthSetupChoice = 'login' | 'setup' | 'skip'\n\nexport function authSetupOptions(input: {\n sharedConfigured: boolean\n byoConfigured: boolean\n canSkip: boolean\n}): Array<{\n value: AuthSetupChoice\n label: string\n hint?: string\n}> {\n const skipOption = input.canSkip\n ? [{ value: 'skip' as const, label: 'Skip for now' }]\n : []\n const hasOauthClient = input.sharedConfigured || input.byoConfigured\n\n return hasOauthClient\n ? [\n {\n value: 'login',\n label: 'Connect Google',\n hint: 'Opens your browser for read-only Search Console and Google Analytics access',\n },\n ...skipOption,\n ]\n : [\n {\n value: 'setup',\n label: 'Set up Google login for local development',\n hint: 'This source checkout does not include the public app credentials',\n },\n ...skipOption,\n ]\n}\n\nasync function findGoogleAnalyticsWebStreamCandidates(\n properties: GoogleAnalyticsPropertyChoice[],\n): Promise<{ candidates: Ga4WebStreamCandidate[]; complete: boolean }> {\n const candidates: Ga4WebStreamCandidate[] = []\n let complete = true\n let nextIndex = 0\n\n async function worker(): Promise<void> {\n while (nextIndex < properties.length) {\n const property = properties[nextIndex]\n nextIndex += 1\n if (!property) continue\n\n try {\n const streams = await listGa4DataStreams(property.property)\n candidates.push(\n ...streams\n .filter((stream) => stream.webStreamData)\n .map((stream) => ({\n account: property.account,\n property: property.property,\n propertyName: property.label,\n stream,\n })),\n )\n } catch {\n complete = false\n }\n }\n }\n\n await Promise.all(\n Array.from({ length: Math.min(properties.length, 4) }, () => worker()),\n )\n return { candidates, complete }\n}\n\nexport async function maybeConnectAuth(\n args: Record<string, unknown>,\n): Promise<SetupAuthStatus> {\n const status = await authStatus()\n if (status.activeMode === 'service-account') return 'service-account'\n if (status.tokens) return 'already-connected'\n if (args['skip-auth']) return 'skipped'\n if (!canPrompt({ json: args.json === true })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n 'Not logged in. Run `seo auth login`, or pass --skip-auth to save a project profile without connecting Google.',\n )\n }\n\n const choice = maybeExitCancelled(\n await select<AuthSetupChoice>({\n message: 'Connect Google now?',\n options: authSetupOptions({\n sharedConfigured: status.sharedConfigured,\n byoConfigured: status.byoConfigured,\n canSkip: typeof args.site === 'string' && args.site.length > 0,\n }),\n }),\n )\n\n if (choice === 'skip') return 'skipped'\n if (choice === 'setup') {\n const clientId = maybeExitCancelled(\n await text({\n message: 'Google Desktop OAuth client ID',\n validate: (value) => (value ? undefined : 'Client ID is required'),\n }),\n )\n const clientSecret = maybeExitCancelled(\n await password({\n message: 'Google Desktop OAuth client secret',\n validate: (value) => (value ? undefined : 'Client secret is required'),\n }),\n )\n writeOauthClient({ clientId, clientSecret })\n }\n\n const tokens = await loginWithLoopback()\n note(\n `Connected as ${tokens.account_email}. seo has read-only access and cannot change your site.`,\n 'Google connected',\n )\n return 'connected'\n}\n\nexport async function chooseGoogleAnalyticsProperty(input: {\n property?: string\n site: string\n interactive?: boolean\n}): Promise<SetupGoogleAnalyticsSelection | undefined> {\n if (input.property) {\n return {\n propertyId: input.property,\n selection: 'explicit',\n reason: 'Set with --google-analytics-property.',\n }\n }\n const interactive = input.interactive ?? canPrompt()\n if (!interactive) return undefined\n\n const summaries = await listGa4AccountSummaries().catch(() => [])\n const properties: GoogleAnalyticsPropertyChoice[] = summaries.flatMap(\n (account) =>\n account.propertySummaries.map((property) => ({\n property: ga4PropertyIdFromName(property.property),\n label: property.displayName ?? property.property,\n account: account.displayName ?? account.account,\n })),\n )\n if (!properties.length) return undefined\n\n const { candidates, complete: streamsComplete } =\n await findGoogleAnalyticsWebStreamCandidates(properties)\n const matches = streamsComplete\n ? matchGa4WebStreams(input.site, candidates)\n : []\n const matchesByProperty = new Map<string, Ga4WebStreamMatch>()\n for (const match of matches) {\n matchesByProperty.set(match.property, match)\n }\n const matchedProperties = [...matchesByProperty.values()]\n\n if (matchedProperties.length === 1) {\n const match = matchedProperties[0]\n if (!match) return undefined\n return {\n propertyId: match.property,\n selection: 'matched',\n reason: ga4MatchReason(match, input.site),\n }\n }\n\n const choices: GoogleAnalyticsSetupChoice[] = matchedProperties.length\n ? matchedProperties.map((match) => ({\n property: match.property,\n label: match.propertyName,\n account: match.account,\n match,\n }))\n : properties\n\n const choice = maybeExitCancelled(\n await select<GoogleAnalyticsSetupChoice | ''>({\n message: matchedProperties.length\n ? 'Several Google Analytics properties match this site. Which property should seo use?'\n : streamsComplete\n ? 'No Google Analytics web stream clearly matches this site. Attach a property?'\n : 'Some Google Analytics web streams could not be read. Attach a property?',\n options: [\n { value: '', label: 'Skip Google Analytics for now' },\n ...choices.map((property) => ({\n value: property,\n label: `${property.label} (${property.property})`,\n hint: property.match\n ? ga4MatchReason(property.match, input.site)\n : property.account,\n })),\n ],\n }),\n )\n if (!choice) return undefined\n\n return {\n propertyId: choice.property,\n selection: 'manual',\n reason: choice.match\n ? ga4MatchReason(choice.match, input.site)\n : streamsComplete\n ? `Selected ${choice.label} during setup. Its web stream did not clearly match ${input.site}.`\n : `Selected ${choice.label} during setup. seo could not read every Google Analytics web stream, so it did not guess a match.`,\n }\n}\n\nexport async function maybeInstallSkill(\n args: Record<string, unknown>,\n): Promise<SetupSkillInstall> {\n if (args['skip-skill'] || !canPrompt({ json: args.json === true })) {\n return { status: 'skipped' }\n }\n const shouldInstall = maybeExitCancelled(\n await confirm({\n message:\n 'Install the SEO skill so coding agents know how to run reports?',\n initialValue: true,\n }),\n )\n if (!shouldInstall) return { status: 'declined' }\n\n return installSeoSkill()\n}\n\nexport async function maybeInstallMcp(\n args: Record<string, unknown>,\n): Promise<SetupMcpInstall[]> {\n if (args['skip-mcp'] || !canPrompt({ json: args.json === true })) return []\n const detected = detectMcpClients()\n if (detected.length === 0) return []\n const shouldInstall = maybeExitCancelled(\n await confirm({\n message: 'Install seo as an MCP server too?',\n initialValue: true,\n }),\n )\n if (!shouldInstall) return []\n\n const selected = maybeExitCancelled(\n await multiselect({\n message: 'Which MCP clients?',\n options: detected.map((target) => ({\n value: target.client,\n label: target.label,\n hint: target.path,\n })),\n initialValues: detected.map((target) => target.client),\n }),\n )\n\n return detected\n .filter((target) => selected.includes(target.client))\n .map((target) => {\n try {\n return installMcpConfig(target)\n } catch (error) {\n return {\n client: target.client,\n path: target.path,\n changed: false,\n error: error instanceof Error ? error.message : String(error),\n }\n }\n })\n}\n","import { confirm, intro, note, outro, text } from '@clack/prompts'\nimport {\n type ClientProfile,\n deriveBrandTerms,\n ensureSeoCliDirs,\n listClients,\n saveClient,\n} from '@seo/core'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printCallout,\n printJson,\n printKeyValue,\n} from '../../utils.js'\nimport { slugId, startUrlForSite, suggestedClientName } from '../shared.js'\nimport {\n chooseGoogleAnalyticsProperty,\n maybeConnectAuth,\n maybeInstallMcp,\n maybeInstallSkill,\n type SetupAuthStatus,\n type SetupGoogleAnalyticsSelection,\n type SetupMcpInstall,\n type SetupSkillInstall,\n} from './prompts.js'\n\ntype SetupResult = {\n client?: ClientProfile\n site: string\n auth: SetupAuthStatus\n googleAnalytics?: SetupGoogleAnalyticsSelection\n mcp: SetupMcpInstall[]\n skill?: SetupSkillInstall\n next: string[]\n}\n\nfunction skillInstallLabel(skill: SetupSkillInstall): string {\n if (skill.status === 'installed') return 'installed'\n if (skill.status === 'failed') return 'install failed'\n return 'not installed'\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_./:@-]+$/.test(value)) {\n return value\n }\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\nfunction printStarAsk(): void {\n process.stdout.write('\\n')\n printCallout({\n title: 'Help other people find SEO Skill',\n body: 'If SEO Skill saved you time, a GitHub star helps other people find it.',\n command: 'https://github.com/iannuttall/seo',\n })\n}\n\nfunction mcpInstallLabel(installs: SetupMcpInstall[]): string {\n const failed = installs.filter((install) => install.error).length\n const installed = installs.length - failed\n if (installs.length === 0) return 'not installed'\n if (failed === 0) return `${installed} installed`\n if (installed === 0) return `${failed} skipped`\n return `${installed} installed, ${failed} skipped`\n}\n\nfunction mcpFailureMessage(installs: SetupMcpInstall[]): string | undefined {\n const failures = installs.filter(\n (install): install is SetupMcpInstall & { error: string } =>\n Boolean(install.error),\n )\n if (failures.length === 0) return undefined\n return failures\n .map((install) => `${install.client}: ${install.error}`)\n .join('\\n')\n}\n\nfunction existingProfileForSetup(\n site: string,\n name: string,\n requestedId: string | undefined,\n): ClientProfile | undefined {\n if (requestedId) return undefined\n const matches = listClients().filter((client) => client.siteUrl === site)\n if (matches.length === 1) return matches[0]\n return (\n matches.find((client) => client.isDefault) ??\n matches.find(\n (client) => client.name.toLocaleLowerCase() === name.toLocaleLowerCase(),\n )\n )\n}\n\nexport async function runGuidedSetup(\n args: Record<string, unknown>,\n): Promise<void> {\n const json = jsonFlag(args)\n if (!json) intro(process.argv[2] === 'start' ? 'seo start' : 'seo setup')\n\n if (args['dry-run']) {\n const next = [\n 'seo auth login',\n 'seo start',\n 'seo report --project acme',\n 'seo refresh-priorities --project acme --verify-content',\n 'seo technical-watch --project acme',\n ]\n if (json) {\n printJson({ dryRun: true, next })\n } else {\n note(next.join('\\n'), 'This setup will guide you through')\n outro('Dry run complete.')\n }\n return\n }\n\n ensureSeoCliDirs()\n const siteInput = {\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n }\n const selectedSite = json ? await resolveSite(siteInput) : undefined\n const auth = await maybeConnectAuth(args)\n const site = selectedSite ?? (await resolveSite(siteInput))\n const defaultName = suggestedClientName(site)\n if (canPrompt({ json })) {\n note(\n 'A project profile remembers the site and report defaults so future commands stay short.',\n 'Project profile',\n )\n }\n const shouldSaveProfile =\n booleanArg(args['skip-profile']) === true\n ? false\n : canPrompt({ json })\n ? maybeExitCancelled(\n await confirm({\n message: 'Save this site as a project profile?',\n initialValue: true,\n }),\n )\n : true\n\n if (!shouldSaveProfile) {\n const mcp = await maybeInstallMcp(args)\n const skill = await maybeInstallSkill(args)\n const siteArg = `--site ${shellArg(site)}`\n const next = [\n `seo report ${siteArg}`,\n `seo refresh-priorities ${siteArg} --verify-content`,\n `seo technical-watch ${siteArg}`,\n ]\n const result: SetupResult = { site, auth, mcp, skill, next }\n\n if (json) {\n printJson(result)\n return\n }\n\n printKeyValue([\n ['Project profile', 'not saved'],\n ['GSC property', site],\n ['Auth', auth],\n ['MCP', mcpInstallLabel(mcp)],\n ['SEO skill', skillInstallLabel(skill)],\n ])\n const mcpFailure = mcpFailureMessage(mcp)\n if (mcpFailure) note(mcpFailure, 'MCP setup skipped')\n if (skill.error) note(skill.error, 'SEO skill install failed')\n note(next.join('\\n'), 'Try next')\n outro('Setup complete.')\n printStarAsk()\n return\n }\n\n const name =\n stringArg(args.name) ??\n (canPrompt({ json })\n ? maybeExitCancelled(\n await text({\n message: 'Project name',\n placeholder: defaultName,\n defaultValue: defaultName,\n }),\n )\n : defaultName)\n const requestedId = stringArg(args.id)\n const id =\n requestedId ??\n existingProfileForSetup(site, name, requestedId)?.id ??\n slugId(name)\n const defaultStartUrl = startUrlForSite(site) ?? ''\n const startUrl =\n stringArg(args.url) ??\n (canPrompt({ json })\n ? maybeExitCancelled(\n await text({\n message: 'Website URL to crawl',\n placeholder: defaultStartUrl || 'https://example.com',\n defaultValue: defaultStartUrl,\n }),\n )\n : defaultStartUrl || undefined)\n const watchUrls = listArg(args.urls).length > 0 ? listArg(args.urls) : []\n const googleAnalytics = await chooseGoogleAnalyticsProperty({\n property: stringArg(args['google-analytics-property']),\n site,\n interactive: canPrompt({ json }),\n })\n const googleAnalyticsPropertyId = googleAnalytics?.propertyId\n const derivedBrandTerms = deriveBrandTerms({ id, name, siteUrl: site })\n const brandTerms =\n listArg(args.brand).length > 0 ? listArg(args.brand) : derivedBrandTerms\n const reportDay = numberArg(args['report-day']) ?? 1\n const technicalWeekday = numberArg(args.weekday) ?? 1\n const isDefault = booleanArg(args.default) ?? true\n\n const client = saveClient({\n id,\n name,\n siteUrl: site,\n startUrl,\n watchUrls,\n brandTerms,\n analytics: googleAnalyticsPropertyId\n ? { google: { propertyId: googleAnalyticsPropertyId } }\n : undefined,\n reportDay,\n technicalWeekday,\n isDefault,\n })\n const mcp = await maybeInstallMcp(args)\n const skill = await maybeInstallSkill(args)\n const next = [\n `seo report --project ${client.id}`,\n `seo refresh-priorities --project ${client.id} --verify-content`,\n `seo technical-watch --project ${client.id}`,\n ]\n const result: SetupResult = {\n client,\n site,\n auth,\n googleAnalytics,\n mcp,\n skill,\n next,\n }\n\n if (json) {\n printJson(result)\n return\n }\n\n printKeyValue([\n ['Project profile', `${client.name} (${client.id})`],\n ['GSC property', client.siteUrl],\n ['Crawl URL', client.startUrl ?? 'not set'],\n ['Watch URLs', String(client.watchUrls.length)],\n ['Brand terms', client.brandTerms.join(', ') || 'not set'],\n [\n 'Google Analytics property',\n client.analytics.google?.propertyId ?? 'not connected (optional)',\n ],\n ...(googleAnalytics\n ? [\n ['Google Analytics selection', googleAnalytics.reason] as [\n string,\n string,\n ],\n ]\n : []),\n ['Auth', auth],\n ['MCP', mcpInstallLabel(mcp)],\n ['SEO skill', skillInstallLabel(skill)],\n ])\n const mcpFailure = mcpFailureMessage(mcp)\n if (mcpFailure) note(mcpFailure, 'MCP setup skipped')\n if (skill.error) note(skill.error, 'SEO skill install failed')\n note(next.join('\\n'), 'Try next')\n outro('Setup complete.')\n printStarAsk()\n}\n","import { defineCommand } from 'citty'\nimport { runGuidedSetup } from './flow.js'\n\nexport const setupCommand = defineCommand({\n meta: {\n name: 'setup',\n description:\n 'Guided setup for auth, one project profile, MCP, and next commands',\n },\n args: {\n id: { type: 'string', description: 'Short stable project id.' },\n name: { type: 'string', description: 'Human project name.' },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n url: { type: 'string', description: 'Default technical crawl start URL.' },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to watch with URL Inspection.',\n },\n 'google-analytics-property': {\n type: 'string',\n description: 'Optional Google Analytics property ID.',\n },\n brand: {\n type: 'string',\n description: 'Comma-separated branded query terms to exclude by default.',\n },\n 'report-day': {\n type: 'string',\n description: 'Preferred monthly report day. Defaults to 1.',\n },\n weekday: {\n type: 'string',\n description: 'Preferred technical-watch weekday. Defaults to Monday.',\n },\n default: {\n type: 'boolean',\n description: 'Make this the default project.',\n },\n 'skip-profile': {\n type: 'boolean',\n default: false,\n description: 'Do not save a project profile during setup.',\n },\n 'skip-auth': {\n type: 'boolean',\n default: false,\n description: 'Skip Google sign-in during setup.',\n },\n 'skip-mcp': {\n type: 'boolean',\n default: false,\n description: 'Skip MCP install prompts.',\n },\n 'skip-skill': {\n type: 'boolean',\n default: false,\n description: 'Skip the SEO skill install prompt.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Refresh GSC property discovery.',\n },\n 'dry-run': {\n type: 'boolean',\n default: false,\n description: 'Show what setup does without changing files.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => runGuidedSetup(args),\n})\n\nexport const startCommand = defineCommand({\n ...setupCommand,\n meta: {\n name: 'start',\n description:\n 'Start here: connect Google, save a profile, and get the first report commands',\n },\n})\n\nexport const clientSetupCommand = defineCommand({\n ...setupCommand,\n meta: {\n name: 'setup',\n description: 'Guided setup for one saved project profile',\n },\n})\n","import { detectBrandTerms, getClient, saveClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\n\nexport const clientBrandCommand = defineCommand({\n meta: {\n name: 'brand',\n description: 'Detect and manage project brand query terms',\n },\n subCommands: {\n detect: defineCommand({\n meta: {\n name: 'detect',\n description:\n 'Suggest branded query terms from GSC navigational queries',\n },\n args: {\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name. Defaults to default.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n days: {\n type: 'string',\n description: 'Detection window length in days. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum candidate terms. Defaults to 10.',\n },\n 'min-impressions': {\n type: 'string',\n description: 'Minimum query impressions. Defaults to 10.',\n },\n save: {\n type: 'boolean',\n default: false,\n description: 'Save suggested terms to the selected project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local GSC cache.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = getClient(projectArg(args))\n const siteUrl = await resolveSite({\n site: stringArg(args.site) ?? client?.siteUrl,\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const detection = await detectBrandTerms({\n site: siteUrl,\n id: client?.id,\n name: client?.name,\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n refresh: booleanArg(args.refresh),\n })\n const saved =\n booleanArg(args.save) && client\n ? saveClient({\n id: client.id,\n name: client.name,\n siteUrl: client.siteUrl,\n startUrl: client.startUrl,\n watchUrls: client.watchUrls,\n analytics: client.analytics,\n brandTerms: detection.suggestedTerms,\n reportDay: client.reportDay,\n technicalWeekday: client.technicalWeekday,\n isDefault: client.isDefault,\n })\n : undefined\n\n if (booleanArg(args.save) && !client) {\n throw new Error('Pass --project to save detected brand terms.')\n }\n if (json) {\n printJson({ ...detection, saved })\n return\n }\n\n printKeyValue([\n ['Property', detection.site],\n ['Derived terms', detection.derivedTerms.join(', ')],\n ['Suggested terms', detection.suggestedTerms.join(', ')],\n ['Saved', saved ? saved.id : 'no'],\n ])\n printTable(\n ['Term', 'Score', 'Evidence'],\n detection.candidates.map((candidate) => [\n candidate.term,\n candidate.score,\n candidate.evidence\n .map(\n (item) => `${item.query} (${Math.round(item.clicks)} clicks)`,\n )\n .join(', '),\n ]),\n )\n },\n }),\n },\n})\n","import { readFile, stat } from 'node:fs/promises'\nimport { type ClientProfile, SeoError } from '@seo/core'\nimport { jsonFlag, projectArg, stringArg } from '../../../args.js'\nimport { resolveClient } from '../../../selection.js'\n\nexport const keywordSetProjectArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n} as const\n\nexport const keywordSetJsonArg = {\n type: 'boolean' as const,\n default: false,\n description: 'Print machine-readable JSON.',\n}\n\nexport async function selectedProject(\n args: Record<string, unknown>,\n): Promise<ClientProfile> {\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n if (!project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Select a saved project with --project or make one the default.',\n )\n }\n return project\n}\n\nconst MAX_KEYWORD_FILE_BYTES = 100_000\n\nexport async function keywordInputs(\n args: Record<string, unknown>,\n): Promise<string[]> {\n const keyword = stringArg(args.keyword)\n const keywords = stringArg(args.keywords)\n ?.split(',')\n .map((value) => value.trim())\n .filter(Boolean)\n const file = stringArg(args.file)\n const values = [...(keyword ? [keyword] : []), ...(keywords ?? [])]\n if (file) {\n const info = await stat(file).catch(() => undefined)\n if (!info?.isFile() || info.size > MAX_KEYWORD_FILE_BYTES) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Keyword files must be regular files no larger than 100 KB.',\n )\n }\n values.push(\n ...(await readFile(file, 'utf8'))\n .split(/\\r?\\n/u)\n .map((value) => value.trim())\n .filter(Boolean),\n )\n }\n if (values.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --keyword, comma-separated --keywords, or a newline-delimited --file.',\n )\n }\n return values\n}\n","import { addKeywordsToSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, listArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordInputs,\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetAddCommand = defineCommand({\n meta: { name: 'add', description: 'Add or update keywords in a saved set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n keyword: { type: 'string', description: 'One keyword.' },\n keywords: { type: 'string', description: 'Comma-separated keywords.' },\n file: { type: 'string', description: 'Newline-delimited keyword file.' },\n tags: {\n type: 'string',\n description: 'Comma-separated tags applied to every keyword.',\n },\n 'target-url': {\n type: 'string',\n description: 'Existing target page for every keyword.',\n },\n 'proposed-url': {\n type: 'string',\n description: 'Proposed page for every keyword.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const targetUrl = stringArg(args['target-url'])\n const proposedUrl = stringArg(args['proposed-url'])\n if (targetUrl && proposedUrl) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --target-url or --proposed-url.',\n )\n }\n const project = await selectedProject(args)\n const result = addKeywordsToSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n items: (await keywordInputs(args)).map((keyword) => ({\n keyword,\n tags: listArg(args.tags),\n ...(targetUrl || proposedUrl\n ? {\n page: {\n kind: targetUrl ? ('target' as const) : ('proposed' as const),\n url: targetUrl ?? proposedUrl ?? '',\n },\n }\n : {}),\n })),\n })\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Set', result.setId],\n ['Added', String(result.added)],\n ['Updated', String(result.updated)],\n ['Keywords', String(result.keywordCount)],\n ])\n },\n})\n","import { createKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetCreateCommand = defineCommand({\n meta: { name: 'create', description: 'Create an empty saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n name: { type: 'string', description: 'Keyword set name.', required: true },\n country: {\n type: 'string',\n description: 'Two-letter country code.',\n required: true,\n },\n language: {\n type: 'string',\n description: 'Search language code.',\n required: true,\n },\n 'search-engine': {\n type: 'string',\n default: 'google',\n description: 'Search engine: google or bing.',\n },\n 'location-code': {\n type: 'string',\n description: 'Optional provider location code.',\n },\n location: {\n type: 'string',\n description: 'Optional canonical location name.',\n },\n device: {\n type: 'string',\n description: 'Optional device: desktop or mobile.',\n },\n provider: { type: 'string', description: 'Optional preferred provider.' },\n 'source-report': {\n type: 'string',\n description: 'Report that produced the initial research.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const locationCode = numberArg(args['location-code'])\n if (locationCode !== undefined && !Number.isSafeInteger(locationCode)) {\n throw new SeoError('INVALID_INPUT', '--location-code must be an integer.')\n }\n const project = await selectedProject(args)\n const set = createKeywordSet({\n projectId: project.id,\n name: stringArg(args.name) ?? '',\n market: {\n searchEngine: stringArg(args['search-engine']),\n countryCode: stringArg(args.country),\n languageCode: stringArg(args.language),\n ...(locationCode !== undefined || stringArg(args.location)\n ? { location: { code: locationCode, name: stringArg(args.location) } }\n : {}),\n device: stringArg(args.device),\n },\n provider: stringArg(args.provider),\n sourceReport: stringArg(args['source-report']),\n })\n if (jsonFlag(args)) printJson(set)\n else\n printKeyValue([\n ['Created', set.name],\n ['Project', project.name],\n ['Keywords', '0'],\n ['Id', set.id],\n ])\n },\n})\n","import { deleteKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetDeleteCommand = defineCommand({\n meta: { name: 'delete', description: 'Delete a saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n yes: {\n type: 'boolean',\n default: false,\n description: 'Confirm permanent deletion.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n if (!booleanArg(args.yes)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --yes to delete the keyword set.',\n )\n }\n const project = await selectedProject(args)\n const idOrName = stringArg(args.set) ?? ''\n const deleted = deleteKeywordSet({ projectId: project.id, idOrName })\n if (!deleted)\n throw new SeoError('INVALID_INPUT', `Keyword set not found: ${idOrName}`)\n const result = { deleted: true, projectId: project.id, set: idOrName }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`Deleted keyword set ${idOrName}.\\n`)\n },\n})\n","import { writeFile } from 'node:fs/promises'\nimport {\n getKeywordSet,\n type ProviderValue,\n renderCsv,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { numberArg, stringArg } from '../../../args.js'\nimport { keywordSetProjectArgs, selectedProject } from './shared.js'\n\nexport const keywordSetExportCommand = defineCommand({\n meta: { name: 'export', description: 'Export a bounded saved keyword set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n format: {\n type: 'string',\n default: 'csv',\n description: 'Output format: csv or json.',\n },\n output: {\n type: 'string',\n description: 'Output file, or - for stdout.',\n required: true,\n },\n tag: { type: 'string', description: 'Only export keywords with this tag.' },\n limit: {\n type: 'string',\n default: '1000',\n description: 'Rows to export, from 1 to 1000.',\n },\n offset: { type: 'string', default: '0', description: 'Rows to skip.' },\n },\n run: async ({ args }) => {\n const format = stringArg(args.format)\n if (format !== 'csv' && format !== 'json') {\n throw new SeoError('INVALID_INPUT', '--format must be csv or json.')\n }\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit) || !Number.isSafeInteger(offset)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--limit and --offset must be integers.',\n )\n }\n const project = await selectedProject(args)\n const detail = getKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n tag: stringArg(args.tag),\n limit,\n offset,\n })\n const body =\n format === 'json'\n ? `${JSON.stringify(detail, null, 2)}\\n`\n : keywordSetCsv(detail)\n const output = stringArg(args.output) ?? ''\n if (output === '-') process.stdout.write(body)\n else {\n try {\n await writeFile(output, body, {\n encoding: 'utf8',\n flag: 'wx',\n mode: 0o600,\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EEXIST') {\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to overwrite the existing file at ${output}.`,\n )\n }\n throw error\n }\n process.stdout.write(\n `Wrote ${detail.items.length} keywords to ${output}.\\n`,\n )\n }\n },\n})\n\nfunction keywordSetCsv(detail: ReturnType<typeof getKeywordSet>): string {\n return renderCsv(\n detail.items.map((item) => {\n const metric = item.latestMetric?.metric\n return {\n keyword: item.keyword,\n normalized_keyword: item.normalizedKeyword,\n tags: item.tags.join('; '),\n page_kind: item.page?.kind,\n page_url: item.page?.url,\n metric_provider: item.latestMetric?.provider,\n metric_observed_at: item.latestMetric?.observedAt,\n monthly_search_volume: observedMetricValue(metric?.monthlySearchVolume),\n cpc_usd: observedMetricValue(metric?.cpcUsd),\n paid_competition: observedMetricValue(metric?.paidCompetition),\n keyword_difficulty: observedMetricValue(metric?.keywordDifficulty),\n intent:\n metric?.intent.state === 'observed' ? metric.intent.value : null,\n result_count: observedMetricValue(metric?.resultCount),\n }\n }),\n [\n 'keyword',\n 'normalized_keyword',\n 'tags',\n 'page_kind',\n 'page_url',\n 'metric_provider',\n 'metric_observed_at',\n 'monthly_search_volume',\n 'cpc_usd',\n 'paid_competition',\n 'keyword_difficulty',\n 'intent',\n 'result_count',\n ],\n )\n}\n\nfunction observedMetricValue<T>(value: ProviderValue<T> | undefined): T | null {\n return value?.state === 'observed' ? value.value : null\n}\n","import type { KeywordSet, KeywordSetDetail } from '@seo/core'\nimport { printKeyValue, printTable } from '../../../utils.js'\n\nexport function printKeywordSetList(sets: KeywordSet[]): void {\n if (sets.length === 0) {\n process.stdout.write('No keyword sets saved for this project.\\n')\n return\n }\n printTable(\n ['Name', 'Keywords', 'Market', 'Provider', 'Updated'],\n sets.map((set) => [\n set.name,\n set.keywordCount,\n `${set.market.countryCode}/${set.market.languageCode}`,\n set.provider ?? 'automatic',\n set.updatedAt,\n ]),\n )\n}\n\nexport function printKeywordSet(detail: KeywordSetDetail): void {\n printKeyValue([\n ['Name', detail.set.name],\n ['Project', detail.set.projectId],\n ['Keywords', String(detail.set.keywordCount)],\n [\n 'Market',\n `${detail.set.market.searchEngine} ${detail.set.market.countryCode}/${detail.set.market.languageCode}`,\n ],\n ['Provider', detail.set.provider ?? 'automatic'],\n ['Last refreshed', detail.set.lastRefreshedAt ?? 'never'],\n ])\n if (detail.items.length === 0) {\n process.stdout.write('\\nNo keywords matched this view.\\n')\n return\n }\n process.stdout.write('\\n')\n printTable(\n ['Keyword', 'Tags', 'Volume', 'Page'],\n detail.items.map((item) => [\n item.keyword,\n item.tags.join(', ') || '-',\n item.latestMetric?.metric.monthlySearchVolume.state === 'observed'\n ? item.latestMetric.metric.monthlySearchVolume.value\n : '-',\n item.page?.url ?? '-',\n ]),\n )\n if (detail.pagination.nextOffset !== null) {\n process.stdout.write(\n `\\nMore rows are available. Continue with --offset ${detail.pagination.nextOffset}.\\n`,\n )\n }\n}\n","import { listKeywordSets } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printKeywordSetList } from './output.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetListCommand = defineCommand({\n meta: { name: 'list', description: 'List saved keyword sets for a project' },\n args: { ...keywordSetProjectArgs, json: keywordSetJsonArg },\n run: async ({ args }) => {\n const project = await selectedProject(args)\n const sets = listKeywordSets({ projectId: project.id })\n if (jsonFlag(args)) printJson({ projectId: project.id, sets })\n else printKeywordSetList(sets)\n },\n})\n","import { refreshKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetRefreshCommand = defineCommand({\n meta: {\n name: 'refresh',\n description: 'Preview or refresh saved keyword metrics',\n },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n provider: { type: 'string', description: 'Optional keyword provider.' },\n limit: {\n type: 'string',\n default: '1000',\n description: 'Keywords to refresh, from 1 to 1000.',\n },\n offset: {\n type: 'string',\n default: '0',\n description: 'Saved keyword offset, from 0 to 100000.',\n },\n yes: {\n type: 'boolean',\n default: false,\n description: 'Run the paid refresh after estimating its cost.',\n },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit)) {\n throw new SeoError('INVALID_INPUT', '--limit must be an integer.')\n }\n if (!Number.isSafeInteger(offset)) {\n throw new SeoError('INVALID_INPUT', '--offset must be an integer.')\n }\n const project = await selectedProject(args)\n const report = await refreshKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n provider: stringArg(args.provider) as\n | 'dataforseo'\n | 'semrush'\n | 'ahrefs'\n | undefined,\n limit,\n offset,\n execute: booleanArg(args.yes),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printKeyValue([\n ['Set', report.set.name],\n ['Mode', report.mode],\n ['Keywords', String(report.selection.selectedKeywords)],\n ['Offset', String(report.selection.offset)],\n ['Requests', String(report.cost.requestCount)],\n [\n 'Estimated cost',\n report.cost.estimatedMicros === null\n ? 'unavailable'\n : `$${(report.cost.estimatedMicros / 1_000_000).toFixed(4)}`,\n ],\n ...(report.execution\n ? ([\n ['Saved snapshots', String(report.execution.savedSnapshots)],\n ['Partial batches', String(report.execution.partialBatches)],\n ['Failed batches', String(report.execution.failedBatches)],\n [\n 'Actual cost',\n report.execution.actualMicros === null\n ? 'unavailable'\n : `$${(report.execution.actualMicros / 1_000_000).toFixed(4)}`,\n ],\n ] satisfies Array<[string, string]>)\n : []),\n ])\n if (report.mode === 'preview') {\n process.stdout.write(\n `\\nRun again with --yes to refresh these ${report.selection.selectedKeywords} keywords.\\n`,\n )\n }\n },\n})\n","import { removeKeywordsFromSet } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson, printKeyValue } from '../../../utils.js'\nimport {\n keywordInputs,\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetRemoveCommand = defineCommand({\n meta: { name: 'remove', description: 'Remove keywords from a saved set' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n keyword: { type: 'string', description: 'One keyword.' },\n keywords: { type: 'string', description: 'Comma-separated keywords.' },\n file: { type: 'string', description: 'Newline-delimited keyword file.' },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const project = await selectedProject(args)\n const result = removeKeywordsFromSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n keywords: await keywordInputs(args),\n })\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Set', result.setId],\n ['Removed', String(result.removed)],\n ['Keywords', String(result.keywordCount)],\n ])\n },\n})\n","import { getKeywordSet, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printKeywordSet } from './output.js'\nimport {\n keywordSetJsonArg,\n keywordSetProjectArgs,\n selectedProject,\n} from './shared.js'\n\nexport const keywordSetShowCommand = defineCommand({\n meta: { name: 'show', description: 'Show a bounded saved keyword set view' },\n args: {\n ...keywordSetProjectArgs,\n set: {\n type: 'string',\n description: 'Keyword set id or name.',\n required: true,\n },\n tag: { type: 'string', description: 'Only return keywords with this tag.' },\n limit: {\n type: 'string',\n default: '100',\n description: 'Rows to return, from 1 to 1000.',\n },\n offset: { type: 'string', default: '0', description: 'Rows to skip.' },\n json: keywordSetJsonArg,\n },\n run: async ({ args }) => {\n const limit = numberArg(args.limit)\n const offset = numberArg(args.offset)\n if (!Number.isSafeInteger(limit) || !Number.isSafeInteger(offset)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--limit and --offset must be integers.',\n )\n }\n const project = await selectedProject(args)\n const detail = getKeywordSet({\n projectId: project.id,\n idOrName: stringArg(args.set) ?? '',\n tag: stringArg(args.tag),\n limit,\n offset,\n })\n if (jsonFlag(args)) printJson(detail)\n else printKeywordSet(detail)\n },\n})\n","import { defineCommand } from 'citty'\nimport { keywordSetAddCommand } from './add.js'\nimport { keywordSetCreateCommand } from './create.js'\nimport { keywordSetDeleteCommand } from './delete.js'\nimport { keywordSetExportCommand } from './export.js'\nimport { keywordSetListCommand } from './list.js'\nimport { keywordSetRefreshCommand } from './refresh.js'\nimport { keywordSetRemoveCommand } from './remove.js'\nimport { keywordSetShowCommand } from './show.js'\n\nexport const keywordSetsCommand = defineCommand({\n meta: {\n name: 'keyword-sets',\n description: 'Manage project keyword research sets',\n },\n subCommands: {\n create: keywordSetCreateCommand,\n list: keywordSetListCommand,\n show: keywordSetShowCommand,\n add: keywordSetAddCommand,\n remove: keywordSetRemoveCommand,\n refresh: keywordSetRefreshCommand,\n export: keywordSetExportCommand,\n delete: keywordSetDeleteCommand,\n },\n})\n","import type { ClientProfile } from '@seo/core'\nimport { printKeyValue, printSummaryList } from '../../../utils.js'\n\nexport function printClientList(clients: ClientProfile[]): void {\n printSummaryList(\n clients.map((client) => ({\n title: `${client.name}${client.isDefault ? ' (default)' : ''}`,\n description: client.siteUrl,\n meta: [\n client.id,\n client.startUrl ? `crawl ${client.startUrl}` : '',\n client.watchUrls.length\n ? `${client.watchUrls.length} watched URL${client.watchUrls.length === 1 ? '' : 's'}`\n : '',\n client.brandTerms.length\n ? `${client.brandTerms.length} brand term${client.brandTerms.length === 1 ? '' : 's'}`\n : '',\n ],\n })),\n { empty: 'No saved projects.' },\n )\n}\n\nexport function printClientProfile(client: ClientProfile): void {\n printKeyValue([\n ['ID', client.id],\n ['Name', client.name],\n ['GSC property', client.siteUrl],\n ['Crawl URL', client.startUrl ?? 'not set'],\n ['Watch URLs', client.watchUrls.join(', ') || 'not set'],\n ['Brand terms', client.brandTerms.join(', ') || 'not set'],\n [\n 'Google Analytics property',\n client.analytics.google?.propertyId ?? 'not set',\n ],\n ['Report day', client.reportDay ? String(client.reportDay) : 'not set'],\n [\n 'Technical weekday',\n client.technicalWeekday === undefined\n ? 'not set'\n : String(client.technicalWeekday),\n ],\n ['Default', client.isDefault ? 'yes' : 'no'],\n ])\n}\n","import { saveClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../../args.js'\nimport { resolveSite } from '../../../selection.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientProfile } from './output.js'\n\nexport const clientAddCommand = defineCommand({\n meta: {\n name: 'add',\n description: 'Create or update a project profile',\n },\n args: {\n id: {\n type: 'string',\n description: 'Short stable project id, for example acme.',\n },\n name: {\n type: 'string',\n description: 'Human project name.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n url: {\n type: 'string',\n description: 'Default technical crawl start URL.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to watch with URL Inspection.',\n },\n 'google-analytics-property': {\n type: 'string',\n description: 'Optional Google Analytics property ID for this project.',\n },\n brand: {\n type: 'string',\n description: 'Comma-separated branded query terms to exclude by default.',\n },\n 'report-day': {\n type: 'string',\n description: 'Preferred monthly report day, 1-31.',\n },\n weekday: {\n type: 'string',\n description: 'Preferred technical-watch weekday, 0-7.',\n },\n default: {\n type: 'boolean',\n description: 'Make this the default project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = saveClient({\n id: stringArg(args.id),\n name: stringArg(args.name),\n siteUrl: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n startUrl: stringArg(args.url),\n watchUrls: listArg(args.urls),\n brandTerms: listArg(args.brand),\n analytics: stringArg(args['google-analytics-property'])\n ? {\n google: {\n propertyId: stringArg(args['google-analytics-property']) ?? '',\n },\n }\n : undefined,\n reportDay: numberArg(args['report-day']),\n technicalWeekday: numberArg(args.weekday),\n isDefault: booleanArg(args.default),\n })\n if (json) {\n printJson(client)\n return\n }\n printClientProfile(client)\n },\n})\n","import { setDefaultClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\n\nexport const clientDefaultCommand = defineCommand({\n meta: {\n name: 'default',\n description: 'Set the default project',\n },\n args: {\n id: {\n type: 'string',\n required: true,\n description: 'Project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const client = setDefaultClient(stringArg(args.id) ?? '')\n if (jsonFlag(args)) {\n printJson(client)\n return\n }\n process.stdout.write(`Default project set to ${client.id}.\\n`)\n },\n})\n","import { deleteClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\n\nexport const clientDeleteCommand = defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a project profile',\n },\n args: {\n id: {\n type: 'string',\n required: true,\n description: 'Project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteClient(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n})\n","import { listClients } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientList } from './output.js'\n\nexport const clientListCommand = defineCommand({\n meta: {\n name: 'list',\n description: 'List saved project profiles',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const clients = listClients()\n if (jsonFlag(args)) {\n printJson({ clients })\n return\n }\n printClientList(clients)\n },\n})\n","import { getClient } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../../args.js'\nimport { printJson } from '../../../utils.js'\nimport { printClientProfile } from './output.js'\n\nexport const clientShowCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Show one project profile',\n },\n args: {\n id: {\n type: 'string',\n description: 'Project id or name. Defaults to the default project.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const client = getClient(stringArg(args.id))\n if (!client) throw new Error('Project not found.')\n if (jsonFlag(args)) {\n printJson(client)\n return\n }\n printClientProfile(client)\n },\n})\n","import { clientAddCommand } from './profiles/add.js'\nimport { clientDefaultCommand } from './profiles/default.js'\nimport { clientDeleteCommand } from './profiles/delete.js'\nimport { clientListCommand } from './profiles/list.js'\nimport { clientShowCommand } from './profiles/show.js'\n\nexport const clientProfileCommands = {\n list: clientListCommand,\n add: clientAddCommand,\n show: clientShowCommand,\n default: clientDefaultCommand,\n delete: clientDeleteCommand,\n}\n","import { defineCommand } from 'citty'\nimport { clientSetupCommand } from '../setup/index.js'\nimport { clientBrandCommand } from './brand.js'\nimport { keywordSetsCommand } from './keyword-sets/index.js'\nimport { clientProfileCommands } from './profiles.js'\n\nexport const clientCommand = defineCommand({\n meta: {\n name: 'client',\n description: 'Manage saved project profiles',\n },\n subCommands: {\n setup: clientSetupCommand,\n brand: clientBrandCommand,\n 'keyword-sets': keywordSetsCommand,\n ...clientProfileCommands,\n },\n})\n\nexport const projectCommand = defineCommand({\n ...clientCommand,\n meta: {\n name: 'projects',\n description: 'Manage saved project profiles',\n },\n})\n","import { contentOptimizationReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nexport const contentCommand = defineCommand({\n meta: {\n name: 'content',\n description: 'Optimize page content from real GSC queries',\n },\n subCommands: {\n optimize: defineCommand({\n meta: {\n name: 'optimize',\n description: 'Build a content optimization report for one URL',\n },\n args: {\n site: { type: 'string' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n url: { type: 'string', required: true },\n days: {\n type: 'string',\n description: 'GSC lookback days. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum GSC queries to inspect. Defaults to 25.',\n },\n 'min-impressions': {\n type: 'string',\n description: 'Minimum query impressions. Defaults to 10.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Fetch the page for content checks. Defaults to true.',\n 'Skip fetching the page for content checks.',\n ),\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for page extraction.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local GSC and HTTP cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await contentOptimizationReport({\n site: selection.site,\n url: stringArg(args.url) ?? '',\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']) !== false,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Content optimization',\n target: report.url,\n status: 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Score', value: `${report.summary.score}/100` },\n { label: 'Primary intent', value: report.summary.primaryIntent },\n {\n label: 'Primary query',\n value: report.summary.primaryQuery ?? 'None',\n },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Opportunities',\n value: formatCount(report.summary.opportunities),\n },\n {\n label: 'Estimated lift',\n value: formatCount(report.summary.estimatedClickLift),\n },\n ],\n })\n\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n action: action.action,\n context: action.plainEnglish,\n })),\n )\n\n if (report.brief.sections.length) {\n process.stdout.write('\\nSuggested sections\\n')\n printLimitedTable(\n ['Heading', 'Queries'],\n report.brief.sections.map((section) => [\n truncate(section.heading, 48),\n truncate(section.queries.join(', '), 80),\n ]),\n )\n }\n\n if (report.intentMix.length) {\n process.stdout.write('\\nIntent mix\\n')\n printLimitedTable(\n ['Intent', 'Queries', 'Impressions', 'Clicks'],\n report.intentMix.map((intent) => [\n intent.intent,\n formatCount(intent.queries),\n formatCount(intent.impressions),\n formatCount(intent.clicks),\n ]),\n )\n }\n\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import { createWriteStream } from 'node:fs'\nimport { mkdir } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport type { Writable } from 'node:stream'\nimport { finished } from 'node:stream/promises'\n\nconst BUFFER_SIZE = 64 * 1024\n\nclass BufferedWriter {\n private buffer = ''\n\n constructor(private readonly stream: Writable) {}\n\n async write(value: string): Promise<void> {\n this.buffer += value\n if (this.buffer.length >= BUFFER_SIZE) await this.flush()\n }\n\n async flush(): Promise<void> {\n if (!this.buffer) return\n const chunk = this.buffer\n this.buffer = ''\n if (!this.stream.write(chunk)) {\n await new Promise<void>((resolve, reject) => {\n const onDrain = () => {\n cleanup()\n resolve()\n }\n const onError = (error: Error) => {\n cleanup()\n reject(error)\n }\n const cleanup = () => {\n this.stream.off('drain', onDrain)\n this.stream.off('error', onError)\n }\n this.stream.once('drain', onDrain)\n this.stream.once('error', onError)\n })\n }\n }\n}\n\nfunction indentation(depth: number): string {\n return ' '.repeat(depth)\n}\n\nfunction jsonValue(value: unknown): unknown {\n if (\n value &&\n typeof value === 'object' &&\n 'toJSON' in value &&\n typeof value.toJSON === 'function'\n ) {\n return value.toJSON()\n }\n return value\n}\n\nasync function writeValue(\n writer: BufferedWriter,\n input: unknown,\n depth: number,\n ancestors: Set<object>,\n arrayItem = false,\n): Promise<boolean> {\n const value = jsonValue(input)\n if (value === null) {\n await writer.write('null')\n return true\n }\n if (typeof value === 'string' || typeof value === 'boolean') {\n await writer.write(JSON.stringify(value))\n return true\n }\n if (typeof value === 'number') {\n await writer.write(Number.isFinite(value) ? String(value) : 'null')\n return true\n }\n if (typeof value === 'bigint') {\n JSON.stringify(value)\n }\n if (\n value === undefined ||\n typeof value === 'function' ||\n typeof value === 'symbol'\n ) {\n if (arrayItem) await writer.write('null')\n return arrayItem\n }\n if (!value || typeof value !== 'object') return false\n if (ancestors.has(value)) {\n throw new TypeError('Converting circular structure to JSON')\n }\n ancestors.add(value)\n try {\n if (Array.isArray(value)) {\n if (value.length === 0) {\n await writer.write('[]')\n return true\n }\n await writer.write('[\\n')\n for (let index = 0; index < value.length; index += 1) {\n if (index > 0) await writer.write(',\\n')\n await writer.write(indentation(depth + 1))\n await writeValue(writer, value[index], depth + 1, ancestors, true)\n }\n await writer.write(`\\n${indentation(depth)}]`)\n return true\n }\n\n const entries = Object.entries(value).filter(([, item]) => {\n const normalized = jsonValue(item)\n return !['undefined', 'function', 'symbol'].includes(typeof normalized)\n })\n if (entries.length === 0) {\n await writer.write('{}')\n return true\n }\n await writer.write('{\\n')\n for (let index = 0; index < entries.length; index += 1) {\n const [key, item] = entries[index] as [string, unknown]\n if (index > 0) await writer.write(',\\n')\n await writer.write(`${indentation(depth + 1)}${JSON.stringify(key)}: `)\n await writeValue(writer, item, depth + 1, ancestors)\n }\n await writer.write(`\\n${indentation(depth)}}`)\n return true\n } finally {\n ancestors.delete(value)\n }\n}\n\nexport async function writeJsonStream(\n stream: Writable,\n value: unknown,\n): Promise<void> {\n const writer = new BufferedWriter(stream)\n const written = await writeValue(writer, value, 0, new Set())\n if (!written) await writer.write('undefined')\n await writer.write('\\n')\n await writer.flush()\n}\n\nexport async function writeJsonOutput(\n path: string | undefined,\n value: unknown,\n): Promise<void> {\n if (!path) {\n await writeJsonStream(process.stdout, value)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n const stream = createWriteStream(path)\n try {\n await writeJsonStream(stream, value)\n stream.end()\n await finished(stream)\n } catch (error) {\n stream.destroy()\n throw error\n }\n process.stdout.write(`Wrote ${path}\\n`)\n}\n","import {\n type CrawlReport,\n explainRule,\n reviewObservations,\n type TopFix,\n topFixes,\n} from '@seo/core'\nimport { printSemanticReport } from '../utils.js'\n\nfunction issueStatus(severity: TopFix['severity']): 'fail' | 'warning' {\n return severity === 'high' ? 'fail' : 'warning'\n}\n\nexport function printCrawlHuman(\n report: CrawlReport,\n fixes: TopFix[] = topFixes(report),\n): void {\n const reviews = reviewObservations(report)\n const status =\n report.status === 'failed' || report.summary.highIssues > 0\n ? 'fail'\n : report.status === 'partial'\n ? 'unknown'\n : report.summary.mediumIssues > 0 || report.summary.lowIssues > 0\n ? 'warning'\n : 'pass'\n const accessDiagnostics = report.access.samples.slice(0, 5).map((sample) => ({\n status: 'fail' as const,\n title: sample.evidence.guidance.summary,\n explanation: `${sample.evidence.provider} returned ${sample.evidence.kind} evidence for the crawler request.`,\n evidence: [sample.url],\n fix: sample.evidence.guidance.recommendedAction,\n }))\n const fixDiagnostics = fixes.slice(0, 10).map((fix) => ({\n status: issueStatus(fix.severity),\n title: `${fix.title} on ${fix.count} ${fix.count === 1 ? 'URL' : 'URLs'}`,\n explanation: explainRule(fix.ruleId)?.whyItMatters ?? fix.whyThisRanks,\n evidence: fix.sampleUrls.slice(0, 5),\n fix: fix.howToFix,\n }))\n const reviewDiagnostics = reviews.slice(0, 10).map((review) => ({\n status: 'warning' as const,\n title: `${review.title} on ${review.count} ${review.count === 1 ? 'URL' : 'URLs'}`,\n explanation:\n explainRule(review.ruleId)?.whyItMatters ?? review.whyThisRanks,\n evidence: review.sampleUrls.slice(0, 5),\n fix: review.howToFix,\n }))\n\n printSemanticReport({\n title:\n report.config.strategy === 'health'\n ? 'Sitemap health pass'\n : 'Site crawl',\n target: report.config.url,\n status,\n summary:\n report.status === 'partial'\n ? `Partial evidence from ${report.summary.totalPages} retained pages. Review the caveats before treating missing findings as an all-clear.`\n : `${report.summary.totalPages} pages retained with ${report.issues.length} findings.`,\n metrics: [\n { label: 'Pages', value: report.summary.totalPages },\n {\n label: 'High',\n value: report.summary.highIssues,\n status: 'fail',\n },\n {\n label: 'Medium',\n value: report.summary.mediumIssues,\n status: 'warning',\n },\n { label: 'Low', value: report.summary.lowIssues, status: 'info' },\n { label: 'Failed fetches', value: report.summary.failedUrls },\n ],\n sections: [\n { title: 'Access diagnostics', diagnostics: accessDiagnostics },\n { title: 'Prioritised fixes', diagnostics: fixDiagnostics },\n {\n title: 'Review before changing anything',\n diagnostics: reviewDiagnostics,\n },\n ...(!accessDiagnostics.length &&\n !fixDiagnostics.length &&\n !reviewDiagnostics.length\n ? [\n {\n title: 'Checks',\n diagnostics: [\n {\n status: 'pass' as const,\n title: 'No prioritised findings were observed',\n explanation:\n 'The evaluated crawl evidence did not produce a prioritised fix or review item.',\n },\n ],\n },\n ]\n : []),\n ],\n notes: [\n `Strategy: ${report.config.strategy}. Data: ${report.status}. Report: ${report.id}.`,\n ...report.warnings,\n ...report.caveats,\n ],\n })\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport {\n type CrawlOutputFormat,\n crawlSite,\n renderCrawlCsv,\n renderCrawlHtml,\n renderCrawlJunit,\n renderCrawlMarkdownTickets,\n renderCrawlPagesCsv,\n renderCrawlPretty,\n reviewObservations,\n saveCrawlReport,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n renderingModeArg,\n stringArg,\n} from '../args.js'\nimport { writeJsonOutput } from '../json-output.js'\nimport { printCrawlHuman } from '../presentation/crawl-report.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printKeyValue } from '../utils.js'\nimport { startUrlForSite } from './shared.js'\n\ntype Severity = 'low' | 'medium' | 'high'\n\nconst severityRank: Record<Severity, number> = {\n high: 3,\n medium: 2,\n low: 1,\n}\n\nexport const crawlCommand = defineCommand({\n meta: {\n name: 'crawl',\n description: 'Run a fast sitemap health pass or a full technical crawl',\n },\n args: {\n crawlUrl: {\n type: 'positional',\n required: false,\n description: 'Site start URL. Optional with --sitemap-url.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Optional when --project has a saved crawl URL.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for joining page metrics.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID for landing-page sessions. Defaults from --project when saved.',\n },\n mode: {\n type: 'string',\n description:\n 'Crawl mode: site, page, list, or sitemap. Start with sitemap --health for large sites.',\n },\n health: {\n type: 'boolean',\n default: false,\n description:\n 'Run the uncached sitemap status and redirect pass before a full audit. No page-body analysis.',\n },\n 'sitemap-url': {\n type: 'string',\n description:\n 'Explicit sitemap URL. Selects sitemap mode when --mode is omitted.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for list mode.',\n },\n 'urls-file': {\n type: 'string',\n description: 'File with one URL per line for list mode.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum pages to crawl, up to 10,000. Defaults to 500.',\n },\n 'max-depth': {\n type: 'string',\n description: 'Maximum click depth, up to 64. Defaults to 16.',\n },\n concurrency: {\n type: 'string',\n description:\n 'Parallel page fetches, up to 16. Defaults to 8, or progressively up to 4 with --health.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n include: {\n type: 'string',\n description: 'Comma-separated URL patterns to include.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n 'no-sitemap': {\n type: 'boolean',\n default: false,\n description: 'Do not seed URLs from sitemap.xml.',\n },\n 'no-robots': {\n type: 'boolean',\n default: false,\n description: 'Do not skip URLs disallowed by robots.txt.',\n },\n 'no-external': {\n type: 'boolean',\n default: false,\n description:\n 'Do not check external links. Reserved for full link checks.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Legacy alias for --rendering on.',\n },\n rendering: {\n type: 'string',\n description:\n 'JavaScript rendering mode: auto, on, or off. Defaults to auto.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON. Alias for --format json.',\n },\n format: {\n type: 'string',\n description:\n 'Output format: pretty, json, csv, html, markdown, or junit. JUnit requires --health.',\n },\n output: {\n type: 'string',\n description: 'Write output to this path instead of stdout.',\n },\n csv: {\n type: 'string',\n description: 'CSV table to render: issues or pages. Defaults to issues.',\n },\n save: {\n type: 'boolean',\n default: false,\n description: 'Save the crawl report locally.',\n },\n severity: {\n type: 'string',\n description: 'Only show top fixes at this severity.',\n },\n 'fail-on': {\n type: 'string',\n description: 'Exit non-zero when issues exist at this severity or above.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const format = crawlFormatArg(args.format, json)\n const output = stringArg(args.output)\n const csv = crawlCsvArg(args.csv)\n const severity = severityArg(args.severity)\n const failOn = severityArg(args['fail-on'])\n const project = projectArg(args)\n const urls = await urlListArgs(args)\n const explicitUrl = crawlUrlArg(args)\n const sitemapUrl = stringArg(args['sitemap-url'])\n const health = booleanArg(args.health)\n const explicitMode = crawlModeArg(args.mode)\n if (format === 'junit' && !health) {\n throw new Error('--format junit requires --health.')\n }\n if ((health || sitemapUrl) && explicitMode && explicitMode !== 'sitemap') {\n throw new Error('--health and --sitemap-url require sitemap mode.')\n }\n if (health && negatedBooleanArg(args, 'sitemap')) {\n throw new Error('--health cannot be combined with --no-sitemap.')\n }\n if ((health || sitemapUrl) && urls.length) {\n throw new Error(\n '--health and --sitemap-url cannot be combined with URL list input.',\n )\n }\n const selection =\n stringArg(args.site) ||\n project ||\n (!explicitUrl && !urls.length && !sitemapUrl)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const crawlUrl =\n explicitUrl ??\n selection?.client?.startUrl ??\n (selection?.site ? startUrlForSite(selection.site) : undefined) ??\n (sitemapUrl ? new URL('/', sitemapUrl).toString() : undefined) ??\n urls[0]\n if (!crawlUrl) {\n throw new Error(\n 'No crawl URL selected. Pass a URL, --url, or use --project with a saved crawl URL.',\n )\n }\n\n const report = await crawlSite({\n url: crawlUrl,\n projectId: selection?.client?.id,\n site: selection?.site,\n mode:\n explicitMode ??\n (health || sitemapUrl ? 'sitemap' : urls.length ? 'list' : undefined),\n strategy: health ? 'health' : 'full',\n sitemapUrl,\n urls,\n maxPages: numberArg(args['max-pages']),\n maxDepth: numberArg(args['max-depth']),\n concurrency: numberArg(args.concurrency),\n refresh: booleanArg(args.refresh),\n fetchRate: fetchRateArg({\n ...args,\n 'fetch-concurrency': args.concurrency,\n }),\n include: csvArg(args.include),\n exclude: csvArg(args.exclude),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection?.client?.analytics.google?.propertyId,\n useSitemap: !negatedBooleanArg(args, 'sitemap'),\n respectRobots: !negatedBooleanArg(args, 'robots'),\n checkExternal: !negatedBooleanArg(args, 'external'),\n js: renderingModeArg(args),\n })\n const saved = booleanArg(args.save) ? saveCrawlReport(report) : undefined\n const rankedFixes = topFixes(report, { severity })\n const failedThreshold = failOn\n ? report.issues.some(\n (issue) => severityRank[issue.severity] >= severityRank[failOn],\n )\n : false\n const failedRun = report.status === 'failed'\n\n const payload = {\n ...report,\n topFixes: rankedFixes,\n reviewObservations: reviewObservations(report, { severity }),\n ...(failOn ? { failOn, failedThreshold } : {}),\n ...(saved ? { saved } : {}),\n }\n\n if (format === 'json') {\n await writeJsonOutput(output, payload)\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'csv') {\n await writeOrPrint(\n output,\n csv === 'pages' ? renderCrawlPagesCsv(report) : renderCrawlCsv(report),\n )\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'html') {\n await writeOrPrint(output, renderCrawlHtml(report, rankedFixes))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'junit') {\n await writeOrPrint(output, renderCrawlJunit(report))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (format === 'markdown') {\n await writeOrPrint(\n output,\n renderCrawlMarkdownTickets(report, rankedFixes),\n )\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n if (output) {\n await writeOrPrint(output, renderCrawlPretty(report, rankedFixes))\n if (failedRun || failedThreshold) process.exitCode = 1\n return\n }\n\n printCrawlHuman(report, rankedFixes)\n if (saved || failOn) {\n process.stdout.write('\\nRun metadata\\n')\n printKeyValue([\n ['Saved report', saved?.id ?? 'no'],\n ['Fail threshold', failOn ?? 'off'],\n ])\n }\n if (failedRun || failedThreshold) {\n process.exitCode = 1\n }\n },\n})\n\nfunction crawlModeArg(value: unknown) {\n const mode = stringArg(value)\n if (!mode) return undefined\n if (['site', 'page', 'list', 'sitemap'].includes(mode)) {\n return mode as 'site' | 'page' | 'list' | 'sitemap'\n }\n throw new Error('Mode must be one of: site, page, list, sitemap.')\n}\n\nfunction severityArg(value: unknown): Severity | undefined {\n const severity = stringArg(value)\n if (!severity) return undefined\n if (['low', 'medium', 'high'].includes(severity)) {\n return severity as Severity\n }\n throw new Error('Severity must be one of: low, medium, high.')\n}\n\nfunction crawlUrlArg(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.crawlUrl)\n const flag = stringArg(args.url)\n if (positional && flag && positional !== flag) {\n throw new Error('Use either a URL argument or --url, not both.')\n }\n return positional ?? flag\n}\n\nfunction crawlFormatArg(value: unknown, json: boolean): CrawlOutputFormat {\n const format = stringArg(value)\n if (json && format && format !== 'json') {\n throw new Error('Use either --json or --format, not both.')\n }\n if (!format) return json ? 'json' : 'pretty'\n if (['pretty', 'json', 'csv', 'html', 'markdown', 'junit'].includes(format)) {\n return format as CrawlOutputFormat\n }\n throw new Error(\n 'Format must be one of: pretty, json, csv, html, markdown, junit.',\n )\n}\n\nfunction crawlCsvArg(value: unknown): 'issues' | 'pages' {\n const csv = stringArg(value)\n if (!csv) return 'issues'\n if (['issues', 'pages'].includes(csv)) return csv as 'issues' | 'pages'\n throw new Error('CSV table must be one of: issues, pages.')\n}\n\nasync function urlListArgs(args: Record<string, unknown>): Promise<string[]> {\n const urls = csvArg(args.urls) ?? []\n const file = stringArg(args['urls-file'])\n if (file) {\n urls.push(...parseUrlList(await readFile(file, 'utf8')))\n }\n return [...new Set(urls)]\n}\n\nfunction parseUrlList(value: string): string[] {\n return value\n .split(/[\\n,]/)\n .map((item) => item.trim())\n .filter((item) => item && !item.startsWith('#'))\n}\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n","import {\n type CrawlReport,\n type CrawlReportMeta,\n compareCrawlReports,\n crawlSite,\n deleteCrawlReport,\n latestCrawlReport,\n listCrawlReports,\n loadCrawlReport,\n reviewObservations,\n saveCrawlReport,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printCrawlHuman } from '../presentation/crawl-report.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printSummaryList, printTable } from '../utils.js'\nimport {\n printActionDetails,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nasync function reportSiteFilter(args: Record<string, unknown>, json: boolean) {\n const project = projectArg(args)\n const site = stringArg(args.site)\n if (!project && !site) return undefined\n return (\n await resolveClientSelection({\n client: project,\n site,\n options: { json },\n })\n ).site\n}\n\nfunction printReportList(reports: CrawlReportMeta[]): void {\n printSummaryList(\n reports.map((report) => ({\n title: report.id,\n description: report.site ?? report.url,\n meta: [\n report.status,\n `${report.totalPages} page${report.totalPages === 1 ? '' : 's'}`,\n `${report.issueCount} issue${report.issueCount === 1 ? '' : 's'}`,\n report.createdAt,\n ],\n })),\n { empty: 'No saved crawl reports.' },\n )\n}\n\nfunction printReport(report: CrawlReport): void {\n printCrawlHuman(report)\n}\n\nfunction printReportDiff(report: ReturnType<typeof compareCrawlReports>): void {\n printReportSummary({\n title: 'Crawl report comparison',\n target: report.after.url,\n status:\n report.comparability.status !== 'comparable' ||\n report.completeness.status !== 'complete'\n ? 'unknown'\n : report.summary.newStatusErrors > 0 ||\n report.summary.issueGroupsWorse > 0\n ? 'warning'\n : 'pass',\n summary: report.headline,\n metrics: [\n {\n label: 'Before',\n value: `${report.before.id} (${report.before.generatedAt})`,\n },\n {\n label: 'After',\n value: `${report.after.id} (${report.after.generatedAt})`,\n },\n { label: 'Comparability', value: report.comparability.status },\n { label: 'Completeness', value: report.completeness.status },\n {\n label: 'Pages',\n value: `${report.after.summary.totalPages} (${report.summary.pageDelta >= 0 ? '+' : ''}${report.summary.pageDelta})`,\n },\n {\n label: 'Issues',\n value: `${report.after.summary.highIssues + report.after.summary.mediumIssues + report.after.summary.lowIssues} (${report.summary.issueDelta >= 0 ? '+' : ''}${report.summary.issueDelta})`,\n },\n { label: 'New status errors', value: report.summary.newStatusErrors },\n { label: 'Fixed status errors', value: report.summary.fixedStatusErrors },\n { label: 'Issue groups worse', value: report.summary.issueGroupsWorse },\n { label: 'Issue groups better', value: report.summary.issueGroupsBetter },\n { label: 'Changed pages', value: report.summary.changedPages },\n { label: 'Added pages', value: report.summary.addedPages },\n { label: 'Removed pages', value: report.summary.removedPages },\n ],\n })\n\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n context: action.plainEnglish,\n action: action.action,\n })),\n report.topActions.length,\n )\n\n if (report.pageChanges.length) {\n process.stdout.write('\\nChanged pages\\n')\n printTable(\n ['Kind', 'Changes', 'URL'],\n report.pageChanges\n .slice(0, 15)\n .map((item) => [\n item.kind,\n item.changes.join(', '),\n truncate(item.url, 80),\n ]),\n )\n if (report.pageChanges.length > 15) {\n process.stdout.write(\n `Showing 15 of ${report.pageChanges.length}. Use --json for all changes.\\n`,\n )\n }\n }\n\n if (report.issueChanges.length) {\n process.stdout.write('\\nIssue movement\\n')\n printTable(\n ['Rule', 'Before', 'After', 'Delta'],\n report.issueChanges\n .slice(0, 10)\n .map((item) => [\n item.ruleId,\n String(item.before),\n String(item.after),\n `${item.delta >= 0 ? '+' : ''}${item.delta}`,\n ]),\n )\n }\n\n printNotes('Caveats', report.caveats)\n}\n\nfunction selectReportAliasMeta(\n reports: CrawlReportMeta[],\n input: {\n value: 'latest' | 'previous'\n skipId?: string\n },\n): CrawlReportMeta | undefined {\n if (input.value === 'latest') {\n return reports.find((item) => item.id !== input.skipId)\n }\n\n if (input.skipId) {\n const skippedIndex = reports.findIndex((item) => item.id === input.skipId)\n const older = skippedIndex >= 0 ? reports.slice(skippedIndex + 1) : reports\n return older.find((item) => item.id !== input.skipId)\n }\n\n return reports[1]\n}\n\nfunction resolveReportAlias(input: {\n value: string\n site?: string\n skipId?: string\n}): CrawlReport | undefined {\n if (input.value !== 'latest' && input.value !== 'previous') {\n return loadCrawlReport(input.value)\n }\n const reports = listCrawlReports({ site: input.site, limit: 20 })\n const meta = selectReportAliasMeta(reports, {\n value: input.value,\n skipId: input.skipId,\n })\n return meta ? loadCrawlReport(meta.id) : undefined\n}\n\nexport const crawlReportsCommand = defineCommand({\n meta: {\n name: 'crawl-reports',\n description: 'List, show, or delete saved crawl reports',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL for filtering reports.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n id: {\n type: 'string',\n description: 'Saved crawl report id to show.',\n },\n latest: {\n type: 'boolean',\n default: false,\n description: 'Show the latest saved crawl report.',\n },\n delete: {\n type: 'string',\n description: 'Delete a saved crawl report by id.',\n },\n rerun: {\n type: 'string',\n description: 'Rerun a saved crawl report by id, or pass latest.',\n },\n compare: {\n type: 'string',\n description: 'Compare a saved report id, latest, or previous.',\n },\n against: {\n type: 'string',\n description: 'Baseline report id. Defaults to previous.',\n },\n limit: {\n type: 'string',\n description: 'Maximum reports to list. Defaults to 20.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const site = await reportSiteFilter(args, json)\n const deleteId = stringArg(args.delete)\n const rerunId = stringArg(args.rerun)\n const compareId = stringArg(args.compare)\n const id = stringArg(args.id)\n\n if (deleteId) {\n const deleted = deleteCrawlReport(deleteId)\n if (json) {\n printJson({ id: deleteId, deleted })\n return\n }\n process.stdout.write(\n deleted\n ? `Deleted crawl report ${deleteId}.\\n`\n : `No saved crawl report found for ${deleteId}.\\n`,\n )\n return\n }\n\n if (rerunId) {\n const previous =\n rerunId === 'latest'\n ? latestCrawlReport(site)\n : loadCrawlReport(rerunId)\n if (!previous) {\n throw new Error(\n rerunId === 'latest'\n ? 'No saved crawl reports found.'\n : `No saved crawl report found for ${rerunId}.`,\n )\n }\n const report = await crawlSite({\n ...previous.config,\n projectId: previous.projectId,\n site: previous.site,\n googleAnalyticsPropertyId: previous.googleAnalyticsPropertyId,\n })\n const saved = saveCrawlReport(report)\n if (json) {\n printJson({\n ...report,\n rerunOf: previous.id,\n saved,\n topFixes: topFixes(report),\n reviewObservations: reviewObservations(report),\n })\n return\n }\n process.stdout.write(`Reran crawl report ${previous.id}.\\n\\n`)\n printReport(report)\n return\n }\n\n if (compareId) {\n const after = resolveReportAlias({ value: compareId, site })\n if (!after) {\n throw new Error(`No saved crawl report found for ${compareId}.`)\n }\n const beforeAlias = stringArg(args.against) ?? 'previous'\n const before = resolveReportAlias({\n value: beforeAlias,\n site: after.site ?? site,\n skipId: after.id,\n })\n if (!before) {\n throw new Error(\n `No baseline crawl report found for ${beforeAlias}. Save at least two reports or pass --against <id>.`,\n )\n }\n const diff = compareCrawlReports({ before, after })\n if (json) {\n printJson(diff)\n return\n }\n printReportDiff(diff)\n return\n }\n\n if (id || booleanArg(args.latest)) {\n const report = id ? loadCrawlReport(id) : latestCrawlReport(site)\n if (!report) {\n throw new Error(\n id\n ? `No saved crawl report found for ${id}.`\n : 'No saved crawl reports found.',\n )\n }\n if (json) {\n printJson(report)\n return\n }\n printReport(report)\n return\n }\n\n const reports = listCrawlReports({\n site,\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson({ reports })\n return\n }\n printReportList(reports)\n },\n})\n","import { inspectUrl, querySearchAnalytics } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonBodyArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printJson, printTable } from '../utils.js'\nimport { printReportSummary } from './output.js'\nimport { selectedSiteOrThrow } from './shared.js'\n\nexport const gscQueryCommand = defineCommand({\n meta: {\n name: 'gsc-query',\n description: 'Run a raw Search Console Search Analytics query',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'start-date': { type: 'string', description: 'Start date YYYY-MM-DD.' },\n 'end-date': { type: 'string', description: 'End date YYYY-MM-DD.' },\n dimensions: {\n type: 'string',\n description: 'Comma-separated GSC dimensions, for example query,page.',\n },\n type: { type: 'string', description: 'Search type. Defaults to web.' },\n limit: {\n type: 'string',\n description: 'Maximum rows to request and print.',\n },\n body: { type: 'string', description: 'Raw Search Analytics JSON body.' },\n 'body-file': {\n type: 'string',\n description: 'Path to a Search Analytics JSON body file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n },\n run: async ({ args }) => {\n const body =\n (await jsonBodyArg(args.body, args['body-file'])) ??\n ({\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n dimensions: csvArg(args.dimensions) ?? ['query', 'page'],\n type: stringArg(args.type) ?? 'web',\n rowLimit: numberArg(args.limit),\n dataState: 'final',\n } as Record<string, unknown>)\n const json = jsonFlag(args)\n const site = await selectedSiteOrThrow(\n {\n client: projectArg(args),\n site: stringArg(args.site) ?? stringArg(body.siteUrl),\n },\n { json, refresh: booleanArg(args.refresh) },\n )\n delete body.siteUrl\n const result = await querySearchAnalytics(site, body as never, {\n refresh: booleanArg(args.refresh),\n })\n const limit = numberArg(args.limit)\n const rows = limit ? result.rows.slice(0, limit) : result.rows\n if (json) {\n printJson({\n site,\n request: body,\n ...result,\n rows,\n rowsReturned: rows.length,\n })\n return\n }\n printReportSummary({\n title: 'Search Console query',\n target: site,\n status: result.rowsFetched > rows.length ? 'unknown' : 'info',\n summary: `${rows.length} rows returned from ${result.rowsFetched} fetched rows.`,\n metrics: [\n { label: 'Rows returned', value: rows.length },\n { label: 'Rows fetched', value: result.rowsFetched },\n { label: 'API calls', value: result.calls },\n ],\n })\n printTable(\n ['Keys', 'Clicks', 'Impr', 'CTR', 'Pos'],\n rows\n .slice(0, 25)\n .map((row) => [\n row.keys.join(' | '),\n Math.round(row.clicks),\n Math.round(row.impressions),\n row.ctr.toFixed(3),\n row.position.toFixed(1),\n ]),\n )\n },\n})\n\nexport const urlInspectCommand = defineCommand({\n meta: {\n name: 'url-inspect',\n description: 'Inspect a URL with the Search Console URL Inspection API',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: { type: 'string', description: 'URL to inspect.' },\n language: {\n type: 'string',\n description: 'Optional inspection language code.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const siteUrl = await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n { json },\n )\n const inspectionUrl = stringArg(args.url)\n if (!inspectionUrl) throw new Error('Pass --url.')\n const result = await inspectUrl({\n siteUrl,\n inspectionUrl,\n languageCode: stringArg(args.language),\n })\n if (json) {\n printJson(result)\n return\n }\n const indexStatus = result.inspectionResult?.indexStatusResult\n printReportSummary({\n title: 'URL Inspection',\n target: inspectionUrl,\n status:\n indexStatus === undefined\n ? 'unknown'\n : indexStatus.verdict === 'PASS'\n ? 'pass'\n : 'warning',\n summary:\n indexStatus === undefined\n ? 'Google did not return index status evidence for this URL.'\n : `${indexStatus.verdict ?? 'Unknown'}: ${indexStatus.coverageState ?? 'Coverage state unavailable'}.`,\n metrics: [\n { label: 'Property', value: siteUrl },\n { label: 'Robots', value: indexStatus?.robotsTxtState ?? 'Unknown' },\n { label: 'Last crawl', value: indexStatus?.lastCrawlTime ?? 'Unknown' },\n {\n label: 'Google canonical',\n value: indexStatus?.googleCanonical ?? 'Unknown',\n },\n ],\n })\n },\n})\n","import type { ArgDef } from 'citty'\n\n// Shared report option metadata used by CLI commands. The parity check keeps\n// this aligned with scripts/report-surface-catalog.mjs.\ntype CliReportOption = {\n cli: string\n arg: ArgDef\n}\n\nconst REPORT_OPTIONS = {\n days: {\n cli: 'days',\n arg: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n },\n recentDays: {\n cli: 'recent',\n arg: {\n type: 'string',\n description: 'Recent anomaly window in days. Defaults to 14.',\n },\n },\n range: {\n cli: 'days',\n arg: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n },\n limit: {\n cli: 'limit',\n arg: {\n type: 'string',\n description: 'Maximum rows to return.',\n },\n },\n checkLimit: {\n cli: 'check-limit',\n arg: {\n type: 'string',\n description: 'Maximum candidate pages to fetch and check.',\n },\n },\n minImpressions: {\n cli: 'min-impressions',\n arg: {\n type: 'string',\n description: 'Minimum query impressions.',\n },\n },\n includeBrand: {\n cli: 'include-brand',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in opportunity reports.',\n },\n },\n verifyContent: {\n cli: 'verify-content',\n arg: {\n type: 'boolean',\n default: false,\n description:\n 'Verify top opportunities against page title, meta, and content.',\n },\n },\n verifyLimit: {\n cli: 'verify-limit',\n arg: {\n type: 'string',\n description: 'Maximum opportunity URLs to verify.',\n },\n },\n js: {\n cli: 'js',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for verified pages.',\n },\n },\n fetchConcurrency: {\n cli: 'fetch-concurrency',\n arg: {\n type: 'string',\n description:\n 'Maximum concurrent page fetches per host, up to 16. Defaults to 4.',\n },\n },\n fetchIntervalCap: {\n cli: 'fetch-interval-cap',\n arg: {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n },\n fetchIntervalMs: {\n cli: 'fetch-interval-ms',\n arg: {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n },\n refresh: {\n cli: 'refresh',\n arg: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n} as const satisfies Record<string, CliReportOption>\n\ntype ReportOptionKey = keyof typeof REPORT_OPTIONS\n\nexport function cliReportArgs<const T extends readonly ReportOptionKey[]>(\n keys: T,\n overrides: Partial<Record<ReportOptionKey, Partial<ArgDef>>> = {},\n): Record<(typeof REPORT_OPTIONS)[T[number]]['cli'], ArgDef> {\n return Object.fromEntries(\n keys.map((key) => {\n const option = REPORT_OPTIONS[key]\n return [option.cli, { ...option.arg, ...overrides[key] }]\n }),\n ) as Record<(typeof REPORT_OPTIONS)[T[number]]['cli'], ArgDef>\n}\n","import { trafficAnomaly, updateCorrelation } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../args.js'\nimport { printJson, printTable } from '../utils.js'\nimport {\n printLimitedTable,\n printNextCommand,\n printNotes,\n printReportSummary,\n} from './output.js'\nimport { cliReportArgs } from './report-options.js'\nimport { selectedSiteOrThrow } from './shared.js'\n\nfunction formatNumber(value: number): string {\n return value.toLocaleString('en-GB', {\n maximumFractionDigits: value >= 100 ? 0 : 1,\n })\n}\n\nfunction formatChange(value: number | null): string {\n if (value === null) return 'n/a'\n const rounded = Math.abs(value) >= 10 ? value.toFixed(0) : value.toFixed(1)\n return `${value > 0 ? '+' : ''}${rounded}%`\n}\n\nexport const trafficAnomalyCommand = defineCommand({\n meta: {\n name: 'traffic-anomaly',\n description: 'Detect unusual recent GSC traffic movement',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'recentDays', 'refresh'], {\n days: { description: 'Baseline window length in days. Defaults to 90.' },\n recentDays: {\n description: 'Recent anomaly window in days. Defaults to 7.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await trafficAnomaly({\n site: await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n {\n json,\n refresh: booleanArg(args.refresh),\n },\n ),\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Traffic anomaly report',\n target: report.site,\n status:\n report.coverage?.status !== 'complete'\n ? 'unknown'\n : report.anomalies.some((anomaly) => anomaly.significant)\n ? 'warning'\n : 'pass',\n summary: report.anomalies.some((anomaly) => anomaly.significant)\n ? 'At least one recent metric moved beyond the report threshold.'\n : 'No significant recent movement was found in the retained evidence.',\n metrics: [\n { label: 'Metrics checked', value: report.anomalies.length },\n {\n label: 'Significant',\n value: report.anomalies.filter((anomaly) => anomaly.significant)\n .length,\n },\n {\n label: 'Observed days',\n value: report.coverage?.observedDays ?? 'Unavailable',\n },\n {\n label: 'Expected days',\n value: report.coverage?.expectedDays ?? 'Unavailable',\n },\n ],\n })\n printLimitedTable(\n [\n 'Metric',\n 'Direction',\n 'Baseline/day',\n 'Recent/day',\n 'Change',\n 'z',\n 'Significant',\n ],\n report.anomalies.map((anomaly) => [\n anomaly.metric,\n anomaly.direction,\n formatNumber(anomaly.baselineMean),\n formatNumber(anomaly.comparisonMean),\n formatChange(anomaly.percentChange),\n anomaly.zScore ?? 'n/a',\n anomaly.significant ? 'yes' : 'no',\n ]),\n )\n if (report.coverage) {\n printNotes('Evidence coverage', [\n `${report.coverage.observedDays} of ${report.coverage.expectedDays} requested calendar days returned date aggregates.`,\n ...report.coverage.caveats,\n ])\n }\n },\n})\n\nexport const updateCorrelateCommand = defineCommand({\n meta: {\n name: 'update-correlate',\n description: 'Compare traffic movement with official Google update windows',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'recentDays', 'refresh'], {\n days: { description: 'Baseline window length in days. Defaults to 90.' },\n recentDays: {\n description: 'Recent anomaly window in days. Defaults to 7.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n 'padding-days': {\n type: 'string',\n description: 'Days around update windows to count as overlap.',\n },\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = projectArg(args)\n const site = await selectedSiteOrThrow(\n { client, site: stringArg(args.site) },\n {\n json,\n refresh: booleanArg(args.refresh),\n },\n )\n const report = await updateCorrelation({\n site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n paddingDays: numberArg(args['padding-days']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Google update correlation',\n target: report.site,\n status: 'unknown',\n summary: report.summary,\n metrics: [\n {\n label: 'Classification',\n value: report.classification.replaceAll('-', ' '),\n },\n {\n label: 'Attribution',\n value: report.attribution.replaceAll('-', ' '),\n },\n { label: 'Confidence', value: report.confidence },\n { label: 'Updates matched', value: report.overlappingUpdates.length },\n { label: 'Known confounders', value: report.confounders.length },\n { label: 'Source', value: report.source.name },\n ],\n })\n printNotes('Evidence', report.evidence)\n printNotes('Report caveats', report.caveats)\n printNotes('Recommended next checks', report.actions)\n printLimitedTable(\n ['Metric', 'Direction', 'Baseline/day', 'Recent/day', 'Change', 'z'],\n report.anomalies.map((anomaly) => [\n anomaly.metric,\n anomaly.direction,\n formatNumber(anomaly.baselineMean),\n formatNumber(anomaly.comparisonMean),\n formatChange(anomaly.percentChange),\n anomaly.zScore ?? 'n/a',\n ]),\n )\n if (report.overlappingUpdates.length) {\n process.stdout.write('\\nUpdates\\n')\n printTable(\n ['Start', 'End', 'Type', 'Name'],\n report.overlappingUpdates.map((update) => [\n update.start.slice(0, 10),\n update.end?.slice(0, 10) ?? 'open',\n update.type,\n update.name,\n ]),\n )\n }\n const target = client\n ? `--project ${JSON.stringify(client)}`\n : `--site ${JSON.stringify(site)}`\n printNextCommand(`seo segment-impact ${target} --dimension page`)\n },\n})\n","import { type EntityReadinessReport, entityReadiness } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { printJson, printSemanticReport } from '../utils.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction printEntityReadiness(report: EntityReadinessReport): void {\n printSemanticReport({\n title: 'Entity evidence',\n target: report.url,\n status: report.dataStatus === 'partial' ? 'unknown' : 'info',\n summary: report.headline,\n metrics: [\n {\n label: 'Pages',\n value: `${report.evaluatedPages}/${report.crawlPages}`,\n },\n { label: 'sameAs', value: report.entities.sameAs.length },\n { label: 'Social', value: report.entities.socialProfiles.length },\n { label: 'Authors', value: report.entities.authors.length },\n ],\n sections: [\n {\n title: 'Observed entity signals',\n diagnostics: report.checks.map((check) => ({\n status: check.status,\n title: check.title,\n explanation: check.plainEnglish,\n fix: check.action,\n evidence: (check.urls ?? []).slice(0, 5),\n })),\n },\n ],\n notes: [\n `Data: ${report.dataStatus}. Report: ${report.reportId}.`,\n ...report.caveats,\n ],\n })\n}\n\nexport const entityReadinessCommand = defineCommand({\n meta: {\n name: 'entity-readiness',\n description:\n 'Check schema, sameAs, social, author, and naming signals from a saved crawl',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to analyze.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const readiness = entityReadiness(report)\n if (json) {\n printJson(readiness)\n return\n }\n printEntityReadiness(readiness)\n },\n})\n","import {\n type ChangeScope,\n deleteChange,\n listChanges,\n measureChange,\n recordChange,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction changeScope(value: unknown): ChangeScope {\n const scope = stringArg(value) ?? 'page'\n if (\n scope !== 'site' &&\n scope !== 'page' &&\n scope !== 'query' &&\n scope !== 'group'\n ) {\n throw new Error('Invalid --scope. Use site, page, query, or group.')\n }\n return scope\n}\n\nexport const changeLogCommand = defineCommand({\n meta: {\n name: 'change-log',\n description: 'Annotate SEO changes and measure before/after impact',\n },\n subCommands: {\n list: defineCommand({\n meta: {\n name: 'list',\n description: 'List recorded SEO changes',\n },\n args: {\n site: { type: 'string' },\n limit: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const changes = listChanges({\n site: stringArg(args.site),\n limit: numberArg(args.limit),\n })\n if (jsonFlag(args)) {\n printJson({ changes })\n return\n }\n printTable(\n ['ID', 'Date', 'Site', 'Scope', 'Target', 'Title'],\n changes.map((change) => [\n change.id,\n change.changedAt,\n change.site,\n change.scope,\n change.target,\n change.title,\n ]),\n )\n },\n }),\n add: defineCommand({\n meta: {\n name: 'add',\n description: 'Record an SEO change',\n },\n args: {\n site: { type: 'string' },\n scope: { type: 'string', default: 'page' },\n target: { type: 'string', required: true },\n title: { type: 'string', required: true },\n description: { type: 'string' },\n date: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const change = recordChange({\n site: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n scope: changeScope(args.scope),\n target: stringArg(args.target) ?? '',\n title: stringArg(args.title) ?? '',\n description: stringArg(args.description),\n changedAt: stringArg(args.date) ?? today(),\n })\n if (json) {\n printJson(change)\n return\n }\n printKeyValue([\n ['ID', change.id],\n ['Date', change.changedAt],\n ['Site', change.site],\n ['Scope', change.scope],\n ['Target', change.target],\n ['Title', change.title],\n ])\n },\n }),\n delete: defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a recorded SEO change',\n },\n args: {\n id: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteChange(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n }),\n measure: defineCommand({\n meta: {\n name: 'measure',\n description:\n 'Measure a change with equal finalized before/after windows',\n },\n args: {\n id: { type: 'string' },\n site: { type: 'string' },\n scope: { type: 'string' },\n target: { type: 'string' },\n title: { type: 'string' },\n date: { type: 'string' },\n before: { type: 'string' },\n after: { type: 'string' },\n json: { type: 'boolean', default: false },\n refresh: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const id = stringArg(args.id)\n if (\n !id &&\n (!stringArg(args.site) ||\n !stringArg(args.scope) ||\n !stringArg(args.target) ||\n !stringArg(args.date))\n ) {\n throw new Error(\n 'Pass --id, or pass --site, --scope, --target, and --date for an ad hoc measurement.',\n )\n }\n const report = await measureChange({\n id,\n site: id\n ? undefined\n : await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n scope: id ? undefined : changeScope(args.scope),\n target: id ? undefined : stringArg(args.target),\n title: stringArg(args.title),\n changedAt: id ? undefined : stringArg(args.date),\n beforeDays: strictNumberArg(args.before, '--before'),\n afterDays: strictNumberArg(args.after, '--after'),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Change measurement',\n target: report.change.title,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.note,\n metrics: [\n { label: 'Verdict', value: report.verdict },\n { label: 'Confidence', value: report.confidence },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n {\n label: 'Window',\n value: `${report.window.effectiveDays}/${report.window.requestedDays} finalized days`,\n },\n ],\n })\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'Clicks',\n report.before.metrics?.clicks ?? 'unavailable',\n report.after.metrics?.clicks ?? 'unavailable',\n report.delta.clicks === null\n ? 'unavailable'\n : report.delta.clickPct === null\n ? `${report.delta.clicks}`\n : `${report.delta.clicks} (${report.delta.clickPct}%)`,\n ],\n [\n 'Impressions',\n report.before.metrics?.impressions ?? 'unavailable',\n report.after.metrics?.impressions ?? 'unavailable',\n report.delta.impressions === null\n ? 'unavailable'\n : report.delta.impressionPct === null\n ? `${report.delta.impressions}`\n : `${report.delta.impressions} (${report.delta.impressionPct}%)`,\n ],\n [\n 'CTR',\n report.before.metrics?.ctr ?? 'unavailable',\n report.after.metrics?.ctr ?? 'unavailable',\n report.delta.ctr ?? 'unavailable',\n ],\n [\n 'Position',\n report.before.metrics?.position ?? 'unavailable',\n report.after.metrics?.position ?? 'unavailable',\n report.delta.position ?? 'unavailable',\n ],\n ],\n )\n printNotes('Warnings', report.warnings)\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import {\n type ContentGroupDimension,\n type ContentGroupMatchType,\n createContentGroup,\n deleteContentGroup,\n listContentGroups,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\n\nfunction groupDimension(value: unknown): ContentGroupDimension {\n const dimension = stringArg(value) ?? 'page'\n if (dimension !== 'page' && dimension !== 'query') {\n throw new Error('Invalid --dimension. Use page or query.')\n }\n return dimension\n}\n\nfunction matchType(value: unknown): ContentGroupMatchType {\n const type = stringArg(value) ?? 'contains'\n if (type !== 'equals' && type !== 'contains' && type !== 'regex') {\n throw new Error('Invalid --match. Use equals, contains, or regex.')\n }\n return type\n}\n\nexport const contentGroupsCommand = defineCommand({\n meta: {\n name: 'content-groups',\n description: 'Create and manage reusable page/query groups',\n },\n subCommands: {\n list: defineCommand({\n meta: {\n name: 'list',\n description: 'List saved content groups',\n },\n args: {\n site: { type: 'string' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const groups = listContentGroups(stringArg(args.site))\n if (jsonFlag(args)) {\n printJson({ groups })\n return\n }\n printTable(\n ['ID', 'Site', 'Name', 'Dimension', 'Match', 'Pattern'],\n groups.map((group) => [\n group.id,\n group.site,\n group.name,\n group.dimension,\n group.matchType,\n group.pattern,\n ]),\n )\n },\n }),\n add: defineCommand({\n meta: {\n name: 'add',\n description: 'Create a reusable page or query group',\n },\n args: {\n site: { type: 'string' },\n name: { type: 'string', required: true },\n dimension: { type: 'string', default: 'page' },\n match: { type: 'string', default: 'contains' },\n pattern: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const group = createContentGroup({\n site: await resolveSite({\n site: stringArg(args.site),\n options: { json },\n }),\n name: stringArg(args.name) ?? '',\n dimension: groupDimension(args.dimension),\n matchType: matchType(args.match),\n pattern: stringArg(args.pattern) ?? '',\n })\n if (json) {\n printJson(group)\n return\n }\n printKeyValue([\n ['ID', group.id],\n ['Site', group.site],\n ['Name', group.name],\n ['Filter', `${group.dimension} ${group.matchType} ${group.pattern}`],\n ])\n },\n }),\n delete: defineCommand({\n meta: {\n name: 'delete',\n description: 'Delete a content group',\n },\n args: {\n id: { type: 'string', required: true },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const deleted = deleteContentGroup(id)\n if (jsonFlag(args)) {\n printJson({ id, deleted })\n return\n }\n process.stdout.write(`${deleted ? 'Deleted' : 'Not found'} ${id}.\\n`)\n },\n }),\n },\n})\n","import {\n type ChangeMeasurement,\n type ChangeScope,\n listChanges,\n measureChange,\n recordChange,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { formatCount, printNotes, printReportSummary } from '../output.js'\n\nfunction today(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction changeScope(value: unknown): ChangeScope {\n const scope = stringArg(value) ?? 'page'\n if (\n scope !== 'site' &&\n scope !== 'page' &&\n scope !== 'query' &&\n scope !== 'group'\n ) {\n throw new Error('Invalid --scope. Use site, page, query, or group.')\n }\n return scope\n}\n\nfunction maybeScope(value: unknown): ChangeScope | undefined {\n return value ? changeScope(value) : undefined\n}\n\nfunction pct(value: number | null): string {\n return value === null ? 'n/a' : `${value.toFixed(1)}%`\n}\n\nfunction countMetric(value: number | null | undefined): string {\n return value === null || value === undefined\n ? 'unavailable'\n : formatCount(value)\n}\n\nfunction countDelta(value: number | null, percentage: number | null): string {\n return value === null\n ? 'unavailable'\n : `${formatCount(value)} (${pct(percentage)})`\n}\n\nfunction decimalMetric(value: number | null | undefined, digits = 1): string {\n return value === null || value === undefined\n ? 'unavailable'\n : value.toFixed(digits)\n}\n\nfunction printMeasurement(report: ChangeMeasurement): void {\n printReportSummary({\n title: 'SEO test report',\n target: report.change.title,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.note,\n metrics: [\n { label: 'Verdict', value: report.verdict },\n { label: 'Confidence', value: report.confidence },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n {\n label: 'Window',\n value: `${report.window.effectiveDays}/${report.window.requestedDays} finalized days`,\n },\n ],\n })\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'GSC clicks',\n countMetric(report.before.metrics?.clicks),\n countMetric(report.after.metrics?.clicks),\n countDelta(report.delta.clicks, report.delta.clickPct),\n ],\n [\n 'GSC impressions',\n countMetric(report.before.metrics?.impressions),\n countMetric(report.after.metrics?.impressions),\n countDelta(report.delta.impressions, report.delta.impressionPct),\n ],\n [\n 'GSC CTR',\n report.before.metrics\n ? `${(report.before.metrics.ctr * 100).toFixed(1)}%`\n : 'unavailable',\n report.after.metrics\n ? `${(report.after.metrics.ctr * 100).toFixed(1)}%`\n : 'unavailable',\n report.delta.ctr === null\n ? 'unavailable'\n : `${(report.delta.ctr * 100).toFixed(1)} pts`,\n ],\n [\n 'GSC position',\n decimalMetric(report.before.metrics?.position),\n decimalMetric(report.after.metrics?.position),\n decimalMetric(report.delta.position),\n ],\n ],\n )\n\n if (report.analytics) {\n process.stdout.write('\\nGoogle Analytics impact\\n')\n printTable(\n ['Metric', 'Before', 'After', 'Delta'],\n [\n [\n 'Sessions',\n formatCount(report.analytics.before.metrics.sessions),\n formatCount(report.analytics.after.metrics.sessions),\n `${formatCount(report.analytics.delta.sessions)} (${pct(report.analytics.delta.sessionPct)})`,\n ],\n [\n 'Conversions',\n formatCount(report.analytics.before.metrics.conversions),\n formatCount(report.analytics.after.metrics.conversions),\n `${formatCount(report.analytics.delta.conversions)} (${pct(report.analytics.delta.conversionPct)})`,\n ],\n [\n 'Revenue',\n report.analytics.before.metrics.totalRevenue.toFixed(2),\n report.analytics.after.metrics.totalRevenue.toFixed(2),\n `${report.analytics.delta.totalRevenue.toFixed(2)} (${pct(report.analytics.delta.revenuePct)})`,\n ],\n ],\n )\n }\n\n if (report.control) {\n process.stdout.write('\\nControl comparison\\n')\n printKeyValue([\n ['Control', report.control.change.title],\n [\n 'Adjusted clicks',\n report.control.adjusted.clickDelta === null\n ? 'n/a'\n : formatCount(report.control.adjusted.clickDelta),\n ],\n [\n 'Adjusted click %',\n report.control.adjusted.clickPctPoints === null\n ? 'n/a'\n : `${report.control.adjusted.clickPctPoints.toFixed(1)} pts`,\n ],\n ['Note', report.control.note],\n ])\n }\n printNotes('Warnings', report.warnings)\n printNotes('Caveats', report.caveats)\n}\n\nexport const testsCommand = defineCommand({\n meta: {\n name: 'tests',\n description:\n 'Create and report local SEO tests from Search Console and Google Analytics data',\n },\n subCommands: {\n list: defineCommand({\n meta: { name: 'list', description: 'List saved SEO tests' },\n args: {\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n limit: {\n type: 'string',\n description: 'Maximum tests to list. Defaults to 20.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = projectArg(args)\n const selection =\n project || stringArg(args.site)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const changes = listChanges({\n site: selection?.site,\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson({ tests: changes })\n return\n }\n printTable(\n ['ID', 'Date', 'Scope', 'Target', 'Title'],\n changes.map((change) => [\n change.id,\n change.changedAt,\n change.scope,\n change.target,\n change.title,\n ]),\n )\n },\n }),\n create: defineCommand({\n meta: { name: 'create', description: 'Create a local SEO test' },\n args: {\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n scope: {\n type: 'string',\n default: 'page',\n description: 'Change scope: site, page, query, or group.',\n },\n target: {\n type: 'string',\n required: true,\n description: 'Changed URL, query, group pattern, or site marker.',\n },\n title: {\n type: 'string',\n required: true,\n description: 'Plain-English name for the test.',\n },\n description: {\n type: 'string',\n description: 'Optional note about what changed.',\n },\n date: {\n type: 'string',\n description: 'Change date in YYYY-MM-DD. Defaults to today.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const change = recordChange({\n site: selection.site,\n scope: changeScope(args.scope),\n target: stringArg(args.target) ?? '',\n title: stringArg(args.title) ?? '',\n description: stringArg(args.description),\n changedAt: stringArg(args.date) ?? today(),\n })\n if (json) {\n printJson(change)\n return\n }\n printKeyValue([\n ['ID', change.id],\n ['Date', change.changedAt],\n ['Project', selection.client?.name ?? selection.site],\n ['Scope', change.scope],\n ['Target', change.target],\n ['Title', change.title],\n ])\n },\n }),\n report: defineCommand({\n meta: {\n name: 'report',\n description:\n 'Report an SEO test with equal finalized before/after windows',\n },\n args: {\n id: { type: 'string', description: 'Saved SEO test id.' },\n site: { type: 'string', description: 'GSC property URL.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n scope: {\n type: 'string',\n description: 'Ad-hoc change scope: site, page, query, or group.',\n },\n target: {\n type: 'string',\n description:\n 'Ad-hoc changed URL, query, group pattern, or site marker.',\n },\n title: { type: 'string', description: 'Ad-hoc test title.' },\n date: {\n type: 'string',\n description: 'Ad-hoc change date in YYYY-MM-DD.',\n },\n property: {\n type: 'string',\n description: 'Google Analytics property ID.',\n },\n 'control-scope': {\n type: 'string',\n description: 'Control scope: site, page, query, or group.',\n },\n 'control-target': {\n type: 'string',\n description: 'Control URL, query, group pattern, or site marker.',\n },\n 'control-title': {\n type: 'string',\n description: 'Plain-English name for the control group.',\n },\n before: {\n type: 'string',\n description: 'Days before the change date. Defaults to 28.',\n },\n after: {\n type: 'string',\n description: 'Days after the change date. Defaults to 28.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description:\n 'Bypass the local Search Console and Google Analytics cache.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const id = stringArg(args.id)\n const needsSelection =\n !id || Boolean(projectArg(args) || stringArg(args.site))\n const selection = needsSelection\n ? await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n : undefined\n const report = await measureChange({\n id,\n site: id ? undefined : selection?.site,\n scope: id ? undefined : maybeScope(args.scope),\n target: id ? undefined : stringArg(args.target),\n title: stringArg(args.title),\n changedAt: id ? undefined : stringArg(args.date),\n googleAnalyticsPropertyId:\n stringArg(args.property) ??\n selection?.client?.analytics.google?.propertyId,\n controlScope: maybeScope(args['control-scope']),\n controlTarget: stringArg(args['control-target']),\n controlTitle: stringArg(args['control-title']),\n beforeDays: strictNumberArg(args.before, '--before'),\n afterDays: strictNumberArg(args.after, '--after'),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printMeasurement(report)\n },\n }),\n },\n})\n","import type { ProgressReporter } from '@seo/core'\n\nexport function createProgressReporter(\n enabled: boolean,\n): ProgressReporter | undefined {\n if (!enabled) return undefined\n const startedAt = Date.now()\n return (message) => {\n const elapsed = ((Date.now() - startedAt) / 1000).toFixed(1)\n process.stderr.write(`[seo ${elapsed}s] ${message}\\n`)\n }\n}\n","import {\n booleanArg,\n fetchRateArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const reportSelectionArgs = {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n} as const\n\nexport const reportFetchArgs = {\n ...cliReportArgs([\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n} as const\n\nexport function reportFetchOptions(args: Record<string, unknown>) {\n return {\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']) ?? 3,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n }\n}\n\nexport function reportSelectionInput(args: Record<string, unknown>) {\n return {\n client: projectArg(args),\n site: stringArg(args.site),\n refresh: booleanArg(args.refresh),\n }\n}\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { type CsvFile, countLabel, renderCsv } from '@seo/core'\nimport { reportFetchArgs } from '../reports/args.js'\n\nconst { json: _json, ...reportFetchArgsWithoutJson } = reportFetchArgs\n\nexport const exportReportFetchArgs = reportFetchArgsWithoutJson\n\nexport const exportSelectionArgs = {\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name. Defaults to the configured default.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL/id when not using a saved project.',\n },\n} as const\n\nexport function outArg(report: string) {\n return {\n type: 'string',\n description: `Output folder. Defaults to ./seo-export/<project>-${report}-YYYY-MM-DD.`,\n } as const\n}\n\nfunction slug(value: string): string {\n return value\n .toLowerCase()\n .replace(/^sc-domain:/, '')\n .replace(/^https?:\\/\\//, '')\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\nexport function defaultOutDir(input: {\n report: string\n clientId?: string\n site: string\n}) {\n const day = new Date().toISOString().slice(0, 10)\n const id = slug(input.clientId ?? input.site)\n return resolve(process.cwd(), 'seo-export', `${id}-${input.report}-${day}`)\n}\n\nexport async function writeCsvFiles(outDir: string, files: CsvFile[]) {\n await mkdir(outDir, { recursive: true })\n const written: string[] = []\n for (const file of files) {\n const path = resolve(outDir, file.filename)\n await writeFile(path, renderCsv(file.rows, file.headers), 'utf8')\n written.push(path)\n }\n return written\n}\n\nexport function printWritten(outDir: string, files: string[]) {\n process.stdout.write(\n `Wrote ${countLabel(files.length, 'CSV file')} to ${outDir}\\n`,\n )\n for (const file of files) {\n process.stdout.write(`- ${file}\\n`)\n }\n}\n","import { diagnoseCsvFiles, diagnoseProperty } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportDiagnoseCommand = defineCommand({\n meta: {\n name: 'diagnose',\n description:\n 'Export diagnosis tables: priorities, anomalies, movement, decay, cannibalisation, striking-distance, and quick wins.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('diagnose'),\n days: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 90.',\n },\n recent: {\n type: 'string',\n description: 'Recent anomaly window in days.',\n },\n limit: {\n type: 'string',\n description: 'Maximum rows per movement/opportunity table.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in opportunity reports.',\n },\n 'verify-content': {\n type: 'boolean',\n default: false,\n description:\n 'Verify top opportunities against page title, meta, and content.',\n },\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for verified pages.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n })\n const report = await diagnoseProperty({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n js: booleanArg(args.js) ? true : 'auto',\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'diagnose',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, diagnoseCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { randomUUID } from 'node:crypto'\nimport {\n lstat,\n mkdir,\n mkdtemp,\n readdir,\n readFile,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises'\nimport {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} from 'node:path'\nimport {\n type OkfFile,\n type OkfValidationReport,\n SeoError,\n validateOkfFiles,\n} from '@seo/core'\n\nconst markerName = '.seo-okf.json'\nconst marker = `${JSON.stringify({ generator: 'seo', format: 'okf', version: 1 })}\\n`\n\nfunction safeFilePath(root: string, filePath: string): string {\n const path = resolve(root, filePath)\n const fromRoot = relative(resolve(root), path)\n if (!fromRoot || fromRoot.startsWith('..') || isAbsolute(fromRoot)) {\n throw new SeoError('INVALID_INPUT', `Unsafe OKF file path: ${filePath}`)\n }\n return path\n}\n\nasync function writeFiles(root: string, files: OkfFile[]): Promise<void> {\n for (const file of files) {\n const path = safeFilePath(root, file.path)\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, file.content)\n }\n await writeFile(join(root, markerName), marker)\n}\n\nexport async function readOkfMarkdownFiles(root: string): Promise<OkfFile[]> {\n const files: OkfFile[] = []\n async function walk(dir: string, prefix = ''): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true })\n for (const entry of entries) {\n const relative = prefix ? `${prefix}/${entry.name}` : entry.name\n const fullPath = join(dir, entry.name)\n if (entry.isDirectory()) {\n await walk(fullPath, relative)\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n files.push({\n path: relative,\n content: await readFile(fullPath, 'utf8'),\n })\n }\n }\n }\n await walk(root)\n return files.sort((left, right) =>\n left.path < right.path ? -1 : left.path > right.path ? 1 : 0,\n )\n}\n\nasync function assertReplaceable(path: string): Promise<boolean> {\n try {\n const stats = await lstat(path)\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new SeoError(\n 'INVALID_INPUT',\n `OKF output must be a real directory: ${path}`,\n )\n }\n const entries = await readdir(path)\n if (!entries.length) return true\n try {\n const value = await readFile(join(path, markerName), 'utf8')\n if (value === marker) return true\n } catch {\n // The directory is not managed by seo.\n }\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to replace non-empty unmanaged directory: ${path}`,\n )\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n}\n\nexport async function writeOkfDirectory(\n output: string,\n files: OkfFile[],\n): Promise<OkfValidationReport> {\n const validation = validateOkfFiles(files)\n if (!validation.valid) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Generated bundle did not pass seo OKF checks and was not written.',\n )\n }\n const target = resolve(output)\n const parent = dirname(target)\n await mkdir(parent, { recursive: true })\n const existed = await assertReplaceable(target)\n const staging = await mkdtemp(join(parent, `.${basename(target)}-staging-`))\n const backup = join(parent, `.${basename(target)}-backup-${randomUUID()}`)\n let movedExisting = false\n try {\n await writeFiles(staging, files)\n const diskValidation = validateOkfFiles(await readOkfMarkdownFiles(staging))\n if (!diskValidation.valid) {\n throw new SeoError(\n 'INTERNAL_ERROR',\n 'Staged OKF files failed validation after writing.',\n )\n }\n if (existed) {\n await rename(target, backup)\n movedExisting = true\n }\n await rename(staging, target)\n if (movedExisting) await rm(backup, { recursive: true, force: true })\n return diskValidation\n } catch (error) {\n await rm(staging, { recursive: true, force: true })\n if (movedExisting) {\n await rm(target, { recursive: true, force: true })\n await rename(backup, target)\n }\n throw error\n }\n}\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport {\n aiReadiness,\n auditLlmsTxt,\n buildOkfBundle,\n type CrawlReport,\n entityReadiness,\n okfConceptLimit,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../../args.js'\nimport { printJson, printKeyValue } from '../../utils.js'\nimport { writeOkfDirectory } from '../okf-files.js'\nimport { resolveSavedCrawlReport } from '../readiness.js'\n\ntype KnowledgeFormat = 'okf' | 'markdown' | 'json'\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n\nfunction formatArg(value: unknown): KnowledgeFormat {\n const format = stringArg(value) ?? 'okf'\n if (['okf', 'markdown', 'json'].includes(format)) {\n return format as KnowledgeFormat\n }\n throw new Error('Format must be one of: okf, markdown, json.')\n}\n\nexport function knowledgePayload(report: CrawlReport) {\n return {\n reportId: report.id,\n url: report.config.url,\n generatedAt: report.generatedAt,\n crawl: {\n summary: report.summary,\n caveats: report.caveats,\n warnings: report.warnings,\n pages: report.pages.map((page) => ({\n url: page.finalUrl,\n title: page.title,\n metaDescription: page.metaDescription,\n status: page.status,\n indexable: page.indexable,\n wordCount: page.wordCount,\n schemaTypes: page.schemaTypes,\n sameAs: page.schemaSameAs,\n internalInlinks: page.internalInlinkCount,\n contentSample: page.contentSample,\n })),\n },\n aiReadiness: aiReadiness(report),\n entityReadiness: entityReadiness(report),\n llmsTxt: auditLlmsTxt(report),\n }\n}\n\nfunction renderKnowledgeMarkdown(report: CrawlReport): string {\n const payload = knowledgePayload(report)\n const lines = [\n `# Site Knowledge Export`,\n '',\n `Source: ${report.config.url}`,\n `Crawl report: ${report.id}`,\n `Generated: ${payload.generatedAt}`,\n '',\n '## Summary',\n '',\n `- Documents: ${report.summary.totalPages}${report.requestEvidenceStatus === 'available' ? ` from ${report.requests.length} URL requests` : report.requestEvidenceStatus === 'partial' ? ` from ${report.requests.length} observed URL requests (request evidence is partial)` : ' (request evidence unavailable for this legacy report)'}`,\n `- Indexable pages: ${report.summary.indexablePages}`,\n `- Crawl findings: ${report.issues.length} (${report.summary.highIssues} high, ${report.summary.mediumIssues} medium, ${report.summary.lowIssues} low)`,\n `- AI-search evidence: ${payload.aiReadiness.dataStatus} (${payload.aiReadiness.assessment})`,\n `- Entity evidence: ${payload.entityReadiness.dataStatus} (${payload.entityReadiness.assessment})`,\n '',\n '## Top AI Readiness Actions',\n '',\n ...(payload.aiReadiness.topActions.length\n ? payload.aiReadiness.topActions.map(\n (action) => `- ${action.title}: ${action.action}`,\n )\n : ['- No AI-search technical actions in this crawl.']),\n '',\n '## Entity Signals',\n '',\n `- sameAs profiles: ${payload.entityReadiness.entities.sameAs.length}`,\n `- Social profiles: ${payload.entityReadiness.entities.socialProfiles.length}`,\n `- Authors: ${payload.entityReadiness.entities.authors.length}`,\n '',\n '## Important Pages',\n '',\n ...report.pages\n .filter((page) => page.indexable && page.status < 400)\n .slice(0, 100)\n .map(\n (page) =>\n `- [${page.title ?? page.finalUrl}](${page.finalUrl}) - ${page.metaDescription ?? page.contentSample ?? 'No summary available.'}`,\n ),\n '',\n '# Citations',\n '',\n `- [Crawl start URL](${report.config.url})`,\n '',\n ]\n return `${lines.join('\\n')}\\n`\n}\n\nexport const exportKnowledgeCommand = defineCommand({\n meta: {\n name: 'knowledge',\n description:\n 'Export site knowledge from a saved crawl as OKF, Markdown, or JSON',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to export.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n format: {\n type: 'string',\n description: 'Output format: okf, markdown, or json. Defaults to okf.',\n },\n output: {\n type: 'string',\n description:\n 'Output directory for OKF, or output file for Markdown/JSON.',\n },\n 'max-concepts': {\n type: 'string',\n description: 'Maximum OKF concept files. Defaults to 500.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print command metadata as JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const format = formatArg(args.format)\n const maxConcepts =\n format === 'okf'\n ? okfConceptLimit(\n strictNumberArg(args['max-concepts'], '--max-concepts'),\n )\n : undefined\n const report = await resolveSavedCrawlReport(args, { json })\n const output = stringArg(args.output)\n\n if (format === 'okf') {\n const bundle = buildOkfBundle(report, {\n maxConcepts,\n })\n const outDir = output ?? './okf'\n const validation = await writeOkfDirectory(outDir, bundle.files)\n if (json) {\n printJson({ format, output: outDir, bundle, validation })\n return\n }\n process.stdout.write(`Wrote OKF bundle to ${outDir}\\n\\n`)\n printKeyValue([\n ['Files', String(bundle.files.length)],\n ['Concepts', String(bundle.conceptCount)],\n ['Valid', validation.valid ? 'yes' : 'no'],\n ])\n return\n }\n\n if (format === 'json') {\n const content = `${JSON.stringify(knowledgePayload(report), null, 2)}\\n`\n await writeOrPrint(output, content)\n return\n }\n\n await writeOrPrint(output, renderKnowledgeMarkdown(report))\n },\n})\n","import { monthlyReport, narrativeCsvFiles } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { reportFetchOptions } from '../reports/args.js'\nimport {\n defaultOutDir,\n exportReportFetchArgs,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportMonthlyCommand = defineCommand({\n meta: {\n name: 'monthly',\n description:\n 'Export monthly report tables plus the underlying diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('monthly'),\n month: {\n type: 'string',\n description:\n 'Report month as YYYY-MM. Defaults to the latest month with final GSC data.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n ...exportReportFetchArgs,\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await monthlyReport({\n site: selection.site,\n month: stringArg(args.month),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'monthly',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, narrativeCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { narrativeCsvFiles, reportNarrative } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { reportFetchOptions } from '../reports/args.js'\nimport {\n defaultOutDir,\n exportReportFetchArgs,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportNarrativeCommand = defineCommand({\n meta: {\n name: 'narrative',\n description:\n 'Export report narrative tables plus the underlying diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('narrative'),\n ...cliReportArgs(['days', 'recentDays'], {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n }),\n 'start-date': {\n type: 'string',\n description: 'Optional report start date as YYYY-MM-DD.',\n },\n 'end-date': {\n type: 'string',\n description: 'Optional report end date as YYYY-MM-DD.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n 'change-limit': {\n type: 'string',\n description: 'Maximum saved changes to measure. Defaults to 5.',\n },\n ...exportReportFetchArgs,\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await reportNarrative({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: numberArg(args.limit),\n changeLimit: numberArg(args['change-limit']),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'narrative',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, narrativeCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { pseoAuditOptions } from '@seo/core'\nimport {\n booleanArg,\n csvArg,\n strictFetchRateArg,\n strictNumberArg,\n} from '../../args.js'\n\nexport function pseoOptions(args: Record<string, unknown>) {\n return pseoAuditOptions({\n days: strictNumberArg(args.days, '--days'),\n sitemaps: csvArg(args.sitemap),\n maxSitemapUrls: strictNumberArg(\n args['max-sitemap-urls'],\n '--max-sitemap-urls',\n ),\n templateLimit: strictNumberArg(args.limit, '--limit'),\n minimumTemplateUrls: strictNumberArg(\n args['minimum-template-urls'],\n '--minimum-template-urls',\n ),\n minimumTemplateShare: strictNumberArg(\n args['minimum-template-share'],\n '--minimum-template-share',\n ),\n minimumTemplateImpressions: strictNumberArg(\n args['minimum-template-impressions'],\n '--minimum-template-impressions',\n ),\n crawlSamples: strictNumberArg(args['crawl-samples'], '--crawl-samples'),\n inspectSamples: strictNumberArg(\n args['inspect-samples'],\n '--inspect-samples',\n ),\n brandTerms: csvArg(args['brand-terms']),\n includeBrand: booleanArg(args['include-brand']),\n js: booleanArg(args.js) ? true : ('auto' as const),\n refresh: booleanArg(args.refresh),\n rate: strictFetchRateArg(args),\n })\n}\n","import { pseoAuditReport, pseoCsvFiles } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { pseoOptions } from '../pseo/options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportPseoCommand = defineCommand({\n meta: {\n name: 'pseo',\n description:\n 'Export pSEO audit tables: templates, demand patterns, top queries, sample coverage, crawl samples, and inspection samples.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('pseo'),\n days: {\n type: 'string',\n description: 'GSC lookback window. Defaults to 28.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pSEO templates to export.',\n },\n sitemap: {\n type: 'string',\n description: 'Comma-separated sitemap URLs. Can be passed once.',\n },\n 'crawl-samples': {\n type: 'string',\n description:\n 'Number of representative URLs to fetch per template. Defaults to 0.',\n },\n 'inspect-samples': {\n type: 'string',\n description:\n 'Number of representative URLs to inspect in GSC per template. Defaults to 0.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum discovered URLs per sitemap. Defaults to 50000.',\n },\n 'minimum-template-urls': {\n type: 'string',\n description:\n 'Minimum repeated URLs required for a template. Defaults to 3.',\n },\n 'minimum-template-share': {\n type: 'string',\n description:\n 'Minimum share of discovered URLs from 0 to 1. Defaults to 0.',\n },\n 'minimum-template-impressions': {\n type: 'string',\n description:\n 'Minimum retained page impressions for a template. Defaults to 0.',\n },\n 'brand-terms': {\n type: 'string',\n description:\n 'Comma-separated brand terms to exclude from query evidence.',\n },\n 'include-brand': {\n type: 'boolean',\n default: false,\n description: 'Include branded queries in pSEO demand analysis.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for crawled samples.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local cache and fetch fresh data.',\n },\n },\n run: async ({ args }) => {\n const options = pseoOptions(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n })\n const report = await pseoAuditReport({\n site: selection.site,\n ...options,\n brandTerms: options.brandTerms ?? selection.client?.brandTerms,\n progress: createProgressReporter(true),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'pseo',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(outDir, pseoCsvFiles(report))\n printWritten(outDir, written)\n },\n})\n","import { refreshPrioritiesCsvFiles, refreshPrioritiesWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportRefreshPrioritiesCommand = defineCommand({\n meta: {\n name: 'refresh-priorities',\n description:\n 'Export the ranked SEO priority queue, score breakdowns, grouped findings, and diagnosis detail CSVs.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('refresh-priorities'),\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum queue items to export. Defaults to 25.',\n },\n },\n ),\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID to use for analytics value. Defaults from the selected project.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Verify top opportunities against page title, meta, and content. Defaults to true.',\n 'Skip page content verification.',\n ),\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify. Defaults to 5.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await refreshPrioritiesWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection.client?.analytics.google?.propertyId,\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n refresh: booleanArg(args.refresh),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'refresh-priorities',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(\n outDir,\n refreshPrioritiesCsvFiles(report),\n )\n printWritten(outDir, written)\n },\n})\n","import { updatePostmortemCsvFiles, updatePostmortemWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, numberArg, projectArg, stringArg } from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n defaultOutDir,\n exportSelectionArgs,\n outArg,\n printWritten,\n writeCsvFiles,\n} from './shared.js'\n\nexport const exportUpdatePostmortemCommand = defineCommand({\n meta: {\n name: 'update-postmortem',\n description:\n 'Export update postmortem attribution, findings, template movement, and segment movers.',\n },\n args: {\n ...exportSelectionArgs,\n out: outArg('update-postmortem'),\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum winners/losers per segment. Defaults to 20.',\n },\n },\n ),\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n },\n run: async ({ args }) => {\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { refresh: booleanArg(args.refresh) },\n })\n const report = await updatePostmortemWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n const outDir =\n stringArg(args.out) ??\n defaultOutDir({\n report: 'update-postmortem',\n clientId: selection.client?.id,\n site: selection.site,\n })\n const written = await writeCsvFiles(\n outDir,\n updatePostmortemCsvFiles(report),\n )\n printWritten(outDir, written)\n },\n})\n","import { defineCommand } from 'citty'\nimport { exportDiagnoseCommand } from './diagnose.js'\nimport { exportKnowledgeCommand } from './knowledge.js'\nimport { exportMonthlyCommand } from './monthly.js'\nimport { exportNarrativeCommand } from './narrative.js'\nimport { exportPseoCommand } from './pseo.js'\nimport { exportRefreshPrioritiesCommand } from './refresh-priorities.js'\nimport { exportUpdatePostmortemCommand } from './update-postmortem.js'\n\nexport const exportCommand = defineCommand({\n meta: {\n name: 'export',\n description: 'Export full report data to CSV files',\n },\n subCommands: {\n diagnose: exportDiagnoseCommand,\n knowledge: exportKnowledgeCommand,\n narrative: exportNarrativeCommand,\n monthly: exportMonthlyCommand,\n 'update-postmortem': exportUpdatePostmortemCommand,\n 'refresh-priorities': exportRefreshPrioritiesCommand,\n pseo: exportPseoCommand,\n },\n})\n","import { mkdir, readFile, stat, unlink, writeFile } from 'node:fs/promises'\nimport { join, resolve } from 'node:path'\nimport {\n createIndexNowKeyRecord,\n listIndexNowKeys,\n removeIndexNowKey,\n resolveIndexNowKey,\n SeoError,\n saveIndexNowKey,\n submitIndexNow,\n verifyIndexNowKey,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, csvArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson, printKeyValue, printTable } from '../utils.js'\n\nconst MAX_URL_FILE_BYTES = 2_100_000\n\nconst projectArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Site URL.' },\n} as const\n\nasync function selectedSite(args: Record<string, unknown>): Promise<string> {\n const explicit = stringArg(args.site)\n if (explicit) return explicit\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n if (!project) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site or select a saved project.',\n )\n }\n return project.siteUrl\n}\n\nasync function urlsFromArgs(args: Record<string, unknown>): Promise<string[]> {\n const single = stringArg(args.url)\n const inline = csvArg(args.urls) ?? []\n const file = stringArg(args.file)\n if (!single && inline.length === 0 && !file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --url, comma-separated --urls, or a newline-delimited --file.',\n )\n }\n const values = [...(single ? [single] : []), ...inline]\n if (file) {\n const info = await stat(file).catch(() => undefined)\n if (!info) {\n throw new SeoError(\n 'INVALID_INPUT',\n `IndexNow URL file not found: ${file}`,\n )\n }\n if (!info.isFile() || info.size > MAX_URL_FILE_BYTES) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'IndexNow URL files must be regular files no larger than 2.1 MB.',\n )\n }\n values.push(\n ...(await readFile(file, 'utf8'))\n .split(/\\r?\\n/)\n .map((value) => value.trim())\n .filter(Boolean),\n )\n }\n return values\n}\n\nconst setupCommand = defineCommand({\n meta: {\n name: 'setup',\n description: 'Generate an IndexNow key file for one site',\n },\n args: {\n ...projectArgs,\n output: {\n type: 'string',\n description: 'Public asset directory for the generated key file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const output = stringArg(args.output)\n if (!output) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --output with the public asset directory that deploys at the site root.',\n )\n }\n const record = createIndexNowKeyRecord({ site: await selectedSite(args) })\n const directory = resolve(output)\n const path = join(directory, `${record.key}.txt`)\n await mkdir(directory, { recursive: true })\n try {\n await writeFile(path, `${record.key}\\n`, {\n encoding: 'utf8',\n flag: 'wx',\n mode: 0o600,\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EEXIST') {\n throw new SeoError(\n 'INVALID_INPUT',\n `Refusing to overwrite the existing file at ${path}.`,\n )\n }\n throw error\n }\n let credentialSource: Awaited<ReturnType<typeof saveIndexNowKey>>\n try {\n credentialSource = await saveIndexNowKey(record)\n } catch (error) {\n await unlink(path).catch(() => undefined)\n throw error\n }\n const result = {\n configured: true,\n host: record.host,\n keyLocation: record.keyLocation,\n keyFile: path,\n credentialSource,\n nextStep: `Deploy ${path}, then run seo indexnow verify --site ${new URL(record.keyLocation).origin}`,\n }\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Host', result.host],\n ['Key file', result.keyFile],\n ['Public URL', result.keyLocation],\n ['Saved in', result.credentialSource],\n ['Next', result.nextStep],\n ])\n },\n})\n\nconst statusCommand = defineCommand({\n meta: { name: 'status', description: 'Show saved IndexNow hosts' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const sites = await listIndexNowKeys()\n const result = { configuredSites: sites.length, sites }\n if (jsonFlag(args)) printJson(result)\n else\n printTable(\n ['Host', 'Key location', 'Created'],\n sites.map((site) => [site.host, site.keyLocation, site.createdAt]),\n )\n },\n})\n\nconst verifyCommand = defineCommand({\n meta: {\n name: 'verify',\n description: 'Check the public IndexNow key file',\n },\n args: {\n ...projectArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const resolved = await resolveIndexNowKey({\n site: await selectedSite(args),\n })\n const result = {\n ...(await verifyIndexNowKey({ record: resolved.record })),\n credentialSource: resolved.source,\n }\n if (jsonFlag(args)) printJson(result)\n else\n printKeyValue([\n ['Verified', result.verified ? 'yes' : 'no'],\n ['HTTP status', String(result.status)],\n ['Key location', result.keyLocation],\n ['Credential', result.credentialSource],\n ])\n if (!result.verified) process.exitCode = 4\n },\n})\n\nconst submitCommand = defineCommand({\n meta: {\n name: 'submit',\n description: 'Notify IndexNow about changed URLs',\n },\n args: {\n ...projectArgs,\n url: { type: 'string', description: 'One changed URL.' },\n urls: { type: 'string', description: 'Comma-separated changed URLs.' },\n file: {\n type: 'string',\n description: 'Newline-delimited changed URL file.',\n },\n 'dry-run': {\n type: 'boolean',\n default: false,\n description: 'Validate without notifying IndexNow.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const site = await selectedSite(args)\n const resolved = await resolveIndexNowKey({ site })\n const result = await submitIndexNow({\n record: resolved.record,\n urls: await urlsFromArgs(args),\n dryRun: booleanArg(args['dry-run']),\n })\n const output = { ...result, credentialSource: resolved.source }\n if (jsonFlag(args)) {\n printJson(output)\n return\n }\n printKeyValue([\n ['Host', result.host],\n ['Status', result.status],\n ['URLs', String(result.submittedUrls)],\n ['Dry run', result.dryRun ? 'yes' : 'no'],\n ['Key location', result.keyLocation],\n ])\n for (const caveat of result.caveats) process.stdout.write(`\\n${caveat}\\n`)\n },\n})\n\nconst removeCommand = defineCommand({\n meta: { name: 'remove', description: 'Remove a saved IndexNow key' },\n args: {\n ...projectArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const site = await selectedSite(args)\n const removed = await removeIndexNowKey(site)\n const result = {\n removed,\n note: 'The deployed key file was not removed.',\n }\n if (jsonFlag(args)) printJson(result)\n else\n process.stdout.write(\n `${removed ? 'Saved key removed.' : 'No saved key found.'} ${result.note}\\n`,\n )\n },\n})\n\nexport const indexNowCommand = defineCommand({\n meta: {\n name: 'indexnow',\n description: 'Set up and submit changed URLs with IndexNow',\n },\n subCommands: {\n setup: setupCommand,\n status: statusCommand,\n verify: verifyCommand,\n submit: submitCommand,\n remove: removeCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { startCommand } from './setup/index.js'\n\n/**\n * Kept for existing scripts. New users should start with `seo start`.\n *\n * Do not let this become a second onboarding flow. A person should see the\n * same calm Google, project-profile, and MCP setup whichever entry they use.\n */\nexport const initCommand = defineCommand({\n ...startCommand,\n meta: {\n name: 'init',\n description: 'Legacy alias for `seo start`.',\n },\n})\n","import {\n bingWebmasterSiteUrl,\n type CollectedLinkEvidence,\n collectBingLinkEvidence,\n importLinkEvidence,\n linkEvidenceReport,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, strictNumberArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from './output.js'\n\nexport const linksCommand = defineCommand({\n meta: {\n name: 'links',\n description: 'Review bounded referring-link evidence from Bing or a file',\n },\n args: {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Verified Bing Webmaster site URL.' },\n file: {\n type: 'string',\n description: 'Local CSV, JSON, JSONL, or NDJSON link export.',\n },\n format: {\n type: 'string',\n description: 'Import format override: csv, json, or jsonl.',\n },\n 'row-limit': {\n type: 'string',\n description:\n 'Maximum imported or Bing link rows. Defaults to 500 for Bing and 10000 for files.',\n },\n 'target-limit': {\n type: 'string',\n description: 'Maximum Bing target pages to inspect. Defaults to 20.',\n },\n 'detail-pages': {\n type: 'string',\n description: 'Maximum Bing result pages per target. Defaults to 1.',\n },\n limit: {\n type: 'string',\n description: 'Maximum link rows returned. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const file = stringArg(args.file)\n const format = stringArg(args.format)\n if (format && !['csv', 'json', 'jsonl'].includes(format)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--format must be csv, json, or jsonl.',\n )\n }\n const rowLimit = strictNumberArg(args['row-limit'], '--row-limit')\n let evidence: CollectedLinkEvidence\n if (file) {\n evidence = await importLinkEvidence({\n file,\n format: format as 'csv' | 'json' | 'jsonl' | undefined,\n rowLimit,\n })\n } else {\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = stringArg(args.site) ?? bingWebmasterSiteUrl(project)\n if (!site) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site, connect Bing to a saved project, or import a link file with --file.',\n )\n }\n evidence = await collectBingLinkEvidence({\n site,\n rowLimit,\n targetLimit: strictNumberArg(args['target-limit'], '--target-limit'),\n detailPagesPerTarget: strictNumberArg(\n args['detail-pages'],\n '--detail-pages',\n ),\n })\n }\n const report = linkEvidenceReport({\n evidence,\n limit: strictNumberArg(args.limit, '--limit'),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Inbound link evidence',\n target: report.provenance.provider,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: `${formatCount(report.summary.observedLinks)} observed links from ${formatCount(report.summary.referringDomains)} referring domains.`,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Observed links',\n value: formatCount(report.summary.observedLinks),\n },\n {\n label: 'Referring domains',\n value: formatCount(report.summary.referringDomains),\n },\n {\n label: 'Target pages',\n value: formatCount(report.summary.targetPages),\n },\n {\n label: 'Returned rows',\n value: `${formatCount(report.selection.returnedRows)} of ${formatCount(report.selection.availableRows)}`,\n },\n ],\n })\n if (report.links.length) {\n printLimitedTable(\n ['Source', 'Target', 'Anchor'],\n report.links.map((link) => [\n truncate(link.sourceUrl, 58),\n truncate(link.targetUrl, 58),\n truncate(link.anchorText ?? '', 36),\n ]),\n )\n }\n printNotes('Warnings', report.warnings)\n printNotes('Report caveats', report.caveats)\n },\n})\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { auditLlmsTxt, generateLlmsTxt } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { csvArg, jsonFlag, numberArg, stringArg } from '../args.js'\nimport { printJson, printKeyValue } from '../utils.js'\nimport { printNotes, printReportSummary } from './output.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nasync function writeOrPrint(path: string | undefined, content: string) {\n if (!path) {\n process.stdout.write(content)\n return\n }\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n process.stdout.write(`Wrote ${path}\\n`)\n}\n\nconst sharedArgs = {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to use.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n} as const\n\nexport const llmsAuditCommand = defineCommand({\n meta: {\n name: 'audit',\n description: 'Inspect optional llms.txt presence from a saved crawl',\n },\n args: sharedArgs,\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const audit = auditLlmsTxt(report)\n if (json) {\n printJson(audit)\n return\n }\n\n printReportSummary({\n title: 'llms.txt audit',\n target: audit.url,\n status: audit.issues.length > 0 ? 'warning' : 'pass',\n summary: audit.headline,\n metrics: [\n { label: 'SEO impact', value: audit.googleSearchImpact },\n { label: 'Optional', value: audit.optional ? 'Yes' : 'No' },\n { label: 'Found', value: audit.exists ? 'Yes' : 'No' },\n { label: 'URL', value: audit.llmsTxtUrl },\n {\n label: 'HTTP status',\n value: audit.status ? String(audit.status) : 'Unavailable',\n },\n ],\n diagnostics: [\n {\n title: 'Issues',\n items: audit.issues.map((issue) => ({\n status: issue.severity === 'high' ? 'fail' : 'warning',\n title: issue.title,\n explanation: issue.plainEnglish,\n fix: issue.action,\n })),\n },\n ],\n })\n printNotes(\n 'Recommended pages',\n audit.recommendedPages\n .slice(0, 10)\n .map((page) => `${page.section}: ${page.url}`),\n )\n },\n})\n\nexport const llmsGenerateCommand = defineCommand({\n meta: {\n name: 'generate',\n description: 'Generate an llms.txt draft from a saved crawl',\n },\n args: {\n ...sharedArgs,\n output: {\n type: 'string',\n description: 'Write llms.txt to this path instead of stdout.',\n },\n 'max-urls': {\n type: 'string',\n description: 'Maximum URLs to include. Defaults to 250.',\n },\n 'token-budget': {\n type: 'string',\n description: 'Approximate token budget. Defaults to 12000.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n title: {\n type: 'string',\n description: 'Override the llms.txt title.',\n },\n description: {\n type: 'string',\n description: 'Override the llms.txt description.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await resolveSavedCrawlReport(args, { json })\n const generated = generateLlmsTxt(report, {\n maxUrls: numberArg(args['max-urls']),\n tokenBudget: numberArg(args['token-budget']),\n exclude: csvArg(args.exclude),\n title: stringArg(args.title),\n description: stringArg(args.description),\n })\n\n if (json) {\n printJson(generated)\n return\n }\n await writeOrPrint(stringArg(args.output), generated.content)\n if (stringArg(args.output)) {\n printKeyValue([\n ['URLs', String(generated.includedUrls)],\n ['Estimated tokens', String(generated.estimatedTokens)],\n ])\n }\n },\n})\n\nexport const llmsCommand = defineCommand({\n meta: {\n name: 'llms',\n description: 'Inspect or generate optional llms.txt from saved crawl data',\n },\n subCommands: {\n audit: llmsAuditCommand,\n generate: llmsGenerateCommand,\n },\n})\n","import { pruneLogs } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { formatBytes, printJson } from '../utils.js'\n\nexport const logsCommand = defineCommand({\n meta: { name: 'logs', description: 'Manage local log retention' },\n subCommands: {\n prune: defineCommand({\n meta: {\n name: 'prune',\n description: 'Rotate large logs and remove old local logs',\n },\n args: {\n quiet: {\n type: 'boolean',\n default: false,\n description: 'Do not print a result.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const result = pruneLogs()\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n if (!args.quiet) {\n process.stdout.write(\n `Rotated ${result.rotated} and removed ${result.removed} log files. ${formatBytes(result.sizeBytes)} retained.\\n`,\n )\n }\n },\n }),\n },\n})\n","import { multiselect } from '@clack/prompts'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag } from '../args.js'\nimport { canPrompt, maybeExitCancelled, printJson } from '../utils.js'\nimport {\n detectMcpClients,\n mcpClientTargets,\n type SupportedClient,\n} from './mcp-clients.js'\nimport { installMcpConfig, uninstallMcpConfig } from './mcp-config.js'\n\nconst targetFlags: Array<{\n client: SupportedClient\n flag: 'claude-desktop' | 'claude-code' | 'codex' | 'cursor'\n}> = [\n {\n client: 'claude-desktop',\n flag: 'claude-desktop',\n },\n { client: 'claude-code', flag: 'claude-code' },\n { client: 'codex', flag: 'codex' },\n { client: 'cursor', flag: 'cursor' },\n]\n\nfunction selectedClients(\n args: Record<string, unknown>,\n available: SupportedClient[],\n): SupportedClient[] {\n if (booleanArg(args.all)) return available\n return targetFlags\n .filter(({ flag }) => booleanArg(args[flag]))\n .map(({ client }) => client)\n}\n\nexport const mcpCommand = defineCommand({\n meta: { name: 'mcp', description: 'MCP server helpers' },\n subCommands: {\n serve: defineCommand({\n meta: {\n name: 'serve',\n description: 'Run the SEO MCP server',\n },\n args: {\n test: {\n type: 'boolean',\n default: false,\n description: 'Start in test mode',\n },\n },\n run: async ({ args }) => {\n const { startMcpServer } = await import('@seo/mcp')\n await startMcpServer({ test: booleanArg(args.test) })\n },\n }),\n install: defineCommand({\n meta: {\n name: 'install',\n description: 'Install or remove SEO MCP config for local clients',\n },\n args: {\n uninstall: {\n type: 'boolean',\n default: false,\n description: 'Remove the SEO MCP config instead of adding it',\n },\n reinstall: {\n type: 'boolean',\n default: false,\n description: 'Rewrite an existing managed SEO MCP config',\n },\n 'claude-desktop': {\n type: 'boolean',\n default: false,\n description: 'Update Claude Desktop',\n },\n 'claude-code': {\n type: 'boolean',\n default: false,\n description: 'Update Claude Code',\n },\n codex: {\n type: 'boolean',\n default: false,\n description: 'Update Codex CLI, app, and IDE extension',\n },\n cursor: {\n type: 'boolean',\n default: false,\n description: 'Update Cursor',\n },\n all: {\n type: 'boolean',\n default: false,\n description: 'Update every detected MCP client',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print structured JSON output',\n },\n },\n run: async ({ args }) => {\n if (booleanArg(args.uninstall) && booleanArg(args.reinstall)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --uninstall or --reinstall, not both.',\n )\n }\n const targets = mcpClientTargets()\n const detected = detectMcpClients({ targets })\n const json = jsonFlag(args)\n let selected = selectedClients(\n args,\n detected.map((target) => target.client),\n )\n\n if (selected.length === 0) {\n if (!canPrompt({ json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Choose an MCP client with --claude-desktop, --claude-code, --codex, --cursor, or --all.',\n )\n }\n const choices = detected.length > 0 ? detected : targets\n selected = maybeExitCancelled(\n await multiselect({\n message: args.uninstall\n ? 'Remove seo from which MCP clients?'\n : 'Install seo into which MCP clients?',\n options: choices.map((target) => ({\n value: target.client,\n label: target.label,\n hint: target.path,\n })),\n initialValues: detected.map((target) => target.client),\n required: true,\n }),\n )\n }\n\n const unavailable = selected.filter(\n (client) => !targets.some((target) => target.client === client),\n )\n if (unavailable.length > 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `MCP setup is not supported for ${unavailable.join(', ')} on ${process.platform}.`,\n )\n }\n\n const results = targets\n .filter((entry) => selected.includes(entry.client))\n .map((target) =>\n booleanArg(args.uninstall)\n ? uninstallMcpConfig(target)\n : installMcpConfig(target, {\n reinstall: booleanArg(args.reinstall),\n }),\n )\n\n if (json) {\n printJson({\n operation: booleanArg(args.uninstall) ? 'uninstall' : 'install',\n results,\n })\n return\n }\n\n for (const result of results) {\n process.stdout.write(\n `${result.changed ? 'updated' : 'skipped'} ${result.client} · ${result.path}\\n`,\n )\n }\n },\n }),\n },\n})\n","import { crawlDiff } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails, printReportSummary, truncate } from '../output.js'\n\nexport const crawlDiffCommand = defineCommand({\n meta: {\n name: 'crawl-diff',\n description: 'Crawl a site and diff technical/page changes vs last run',\n },\n args: {\n url: {\n type: 'string',\n required: true,\n description: 'Start URL to crawl.',\n },\n site: {\n type: 'string',\n description: 'Optional GSC property to associate with the crawl.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n },\n run: async ({ args }) => {\n const report = await crawlDiff({\n startUrl: stringArg(args.url) ?? '',\n site: stringArg(args.site),\n limit: numberArg(args.limit),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Crawl history comparison',\n target: report.run.startUrl,\n status:\n report.previousRun === undefined\n ? 'unknown'\n : report.summary.newErrors > 0 || report.summary.indexabilityFlips > 0\n ? 'warning'\n : 'pass',\n summary:\n report.previousRun === undefined\n ? 'No previous crawl was available for comparison.'\n : `${report.summary.changed} changed, ${report.summary.added} added, and ${report.summary.removed} removed URLs.`,\n metrics: [\n { label: 'Run', value: report.run.id },\n { label: 'Crawled', value: report.summary.crawled },\n { label: 'Previous run', value: report.previousRun?.id ?? 'None' },\n { label: 'Added', value: report.summary.added },\n { label: 'Removed', value: report.summary.removed },\n { label: 'Changed', value: report.summary.changed },\n { label: 'New errors', value: report.summary.newErrors },\n {\n label: 'Indexability flips',\n value: report.summary.indexabilityFlips,\n },\n {\n label: 'High priority',\n value: report.summary.highPriorityRecommendations,\n },\n ],\n })\n if (report.recommendations.length) {\n process.stdout.write('\\nRecommended actions\\n')\n printTable(\n ['Severity', 'Category', 'URL', 'Action'],\n report.recommendations\n .slice(0, 10)\n .map((item) => [\n item.severity,\n item.category,\n truncate(item.url, 56),\n truncate(item.action, 72),\n ]),\n )\n printActionDetails(\n 'Top crawl actions',\n report.recommendations.map((item) => ({\n label: item.category,\n context: `${item.severity}, ${truncate(item.url, 96)}`,\n action: item.action,\n })),\n )\n }\n if (report.items.length) {\n process.stdout.write('\\nChanged URLs\\n')\n printTable(\n ['Kind', 'URL', 'Changes', 'Recommendation'],\n report.items\n .slice(0, 50)\n .map((item) => [\n item.kind,\n truncate(item.url, 56),\n item.changes.join(', '),\n item.recommendation?.title ?? '-',\n ]),\n )\n }\n if (report.warnings.length) {\n process.stdout.write('\\nWarnings\\n')\n for (const warning of report.warnings.slice(0, 10)) {\n process.stdout.write(`- ${warning}\\n`)\n }\n }\n },\n})\n","import { defaultTrueBooleanArg } from '../../args.js'\n\nexport function monitoringRunArgs() {\n return {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Defaults from the project or GSC property.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect with URL Inspection.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs for quota-aware index monitoring.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties for sitemap index monitoring.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to inspect in this run. Defaults to 100.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for monitoring. Defaults to 50000.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n 'recover-links': defaultTrueBooleanArg(\n 'Check search-value GSC pages for broken, blocked, or poorly redirected URLs.',\n 'Skip link recovery checks.',\n ),\n 'recover-days': {\n type: 'string',\n description: 'GSC lookback window for link recovery. Defaults to 90.',\n },\n 'recover-limit': {\n type: 'string',\n description:\n 'Maximum search-value pages to check for link recovery. Defaults to 10.',\n },\n 'recover-min-clicks': {\n type: 'string',\n description:\n 'Minimum clicks for link recovery candidates. Defaults to 1.',\n },\n 'recover-min-impressions': {\n type: 'string',\n description:\n 'Minimum impressions for link recovery candidates. Defaults to 100.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP/GSC cache where supported.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n } as const\n}\n\nexport function monitoringStatusArgs() {\n return {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'stale-days': {\n type: 'string',\n description: 'Mark checks stale after this many days. Defaults to 8.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Refresh property selection data when prompting.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n } as const\n}\n","import { printSemanticReport } from '../../utils.js'\n\nfunction stepStatus(\n value: string,\n): 'pass' | 'warning' | 'fail' | 'unknown' | 'info' {\n const status = value.toLowerCase()\n if (['pass', 'passed', 'complete', 'completed', 'joined'].includes(status)) {\n return 'pass'\n }\n if (['warn', 'warning', 'partial', 'review'].includes(status)) {\n return 'warning'\n }\n if (['fail', 'failed', 'error'].includes(status)) return 'fail'\n if (['unknown', 'unavailable'].includes(status)) return 'unknown'\n return 'info'\n}\n\nexport function printWorkflow(report: {\n workflow: string\n site: string\n summary: string\n steps: Array<{ tool: string; status: string; summary: string }>\n actions: Array<{ title: string; confidence: string; action: string }>\n}): void {\n const statuses = report.steps.map((step) => stepStatus(step.status))\n const status = statuses.includes('fail')\n ? 'fail'\n : statuses.includes('warning')\n ? 'warning'\n : statuses.includes('unknown')\n ? 'unknown'\n : 'pass'\n printSemanticReport({\n title: report.workflow,\n target: report.site,\n status,\n summary: report.summary,\n metrics: [\n {\n label: 'Completed',\n value: statuses.filter((value) => value === 'pass').length,\n status: 'pass',\n },\n {\n label: 'Review',\n value: statuses.filter((value) => value === 'warning').length,\n status: 'warning',\n },\n {\n label: 'Unknown',\n value: statuses.filter((value) => value === 'unknown').length,\n status: 'unknown',\n },\n ],\n sections: [\n {\n title: 'Evidence collection',\n diagnostics: report.steps.map((step) => ({\n status: stepStatus(step.status),\n title: step.tool,\n explanation: step.summary,\n evidence: [`Status: ${step.status}`],\n })),\n },\n {\n title: 'Priority actions',\n diagnostics: report.actions.map((action) => ({\n status: 'warning' as const,\n title: action.title,\n explanation: `Confidence: ${action.confidence}.`,\n fix: action.action,\n })),\n },\n ],\n })\n}\n","import type { MonitoringStatusReport, technicalWatchWorkflow } from '@seo/core'\nimport { printTable } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { printWorkflow } from '../workflows/output.js'\n\ntype TechnicalWatchReport = Awaited<ReturnType<typeof technicalWatchWorkflow>>\n\nexport function printMonitoringRun(report: TechnicalWatchReport): void {\n printWorkflow(report)\n\n if (report.output.crawl?.recommendations.length) {\n process.stdout.write('\\nCrawl actions\\n')\n printTable(\n ['Severity', 'URL', 'Action'],\n report.output.crawl.recommendations\n .slice(0, 10)\n .map((item) => [\n item.severity,\n truncate(item.url, 56),\n truncate(item.action, 72),\n ]),\n )\n printActionDetails(\n 'Top crawl actions',\n report.output.crawl.recommendations.map((item) => ({\n label: item.severity,\n context: truncate(item.url, 96),\n action: item.action,\n })),\n )\n }\n\n if (report.output.index?.items.length) {\n const items = report.output.index.items\n .filter(\n (item) =>\n item.currentIssue ||\n item.changed ||\n item.inspectionStatus !== 'succeeded',\n )\n .slice(0, 25)\n if (items.length) {\n process.stdout.write('\\nIndex reviews, changes, and failed checks\\n')\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n items.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n truncate(\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n 40,\n ),\n truncate(item.url, 64),\n ]),\n )\n }\n }\n\n if (report.output.recovery?.items.length) {\n process.stdout.write('\\nRecoverable URLs\\n')\n printTable(\n ['Severity', 'Issue', 'Clicks', 'Impr', 'URL', 'Action'],\n report.output.recovery.items\n .slice(0, 10)\n .map((item) => [\n item.severity,\n item.issue,\n formatCount(item.clicks),\n formatCount(item.impressions),\n truncate(item.url, 56),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top recovery actions',\n report.output.recovery.items.map((item) => ({\n label: truncate(item.url, 96),\n context: `${item.severity}, ${formatCount(item.clicks)} clicks at risk`,\n action: item.recommendation.action,\n })),\n )\n }\n}\n\nexport function printMonitoringStatus(report: MonitoringStatusReport): void {\n printReportSummary({\n title: 'Technical monitoring status',\n target: report.site,\n status:\n report.health === 'clear'\n ? 'pass'\n : report.health === 'attention'\n ? 'warning'\n : 'unknown',\n summary:\n report.summary.attention > 0\n ? `${report.summary.attention} checks need attention.`\n : report.summary.stale > 0 || report.summary.notRun > 0\n ? `${report.summary.stale} checks are stale and ${report.summary.notRun} have not run.`\n : 'No monitoring checks currently need attention.',\n metrics: [\n { label: 'Health', value: report.health },\n { label: 'Attention', value: report.summary.attention },\n { label: 'Stale', value: report.summary.stale },\n { label: 'Not run', value: report.summary.notRun },\n ],\n })\n\n printTable(\n ['Check', 'Status', 'Last run', 'Summary'],\n report.checks.map((check) => [\n check.name,\n check.status,\n check.lastRunAt ?? '-',\n check.summary,\n ]),\n )\n\n const actions = report.checks.filter((check) => check.action)\n if (actions.length) {\n process.stdout.write('\\nNext actions\\n')\n printTable(\n ['Check', 'Action'],\n actions.map((check) => [check.name, truncate(check.action ?? '', 96)]),\n )\n printActionDetails(\n 'Next action details',\n actions.map((check) => ({\n label: check.name,\n action: check.action ?? '',\n })),\n )\n }\n}\n","import { monitoringStatus, technicalWatchWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printKeyValue } from '../../utils.js'\nimport { startUrlForSite } from '../shared.js'\nimport { monitoringRunArgs, monitoringStatusArgs } from './args.js'\nimport { printMonitoringRun, printMonitoringStatus } from './output.js'\n\nfunction quotedFlag(name: string, value: unknown): string | undefined {\n const text = stringArg(value)\n return text ? `--${name} ${JSON.stringify(text)}` : undefined\n}\n\nfunction booleanFlag(name: string, value: unknown): string | undefined {\n return booleanArg(value) ? `--${name}` : undefined\n}\n\nfunction recoverLinksFlag(value: unknown): string | undefined {\n return booleanArg(value) === false ? '--recover-links=false' : undefined\n}\n\nexport const monitoringCommand = defineCommand({\n meta: {\n name: 'monitoring',\n description: 'Run and review recurring technical SEO monitoring',\n },\n subCommands: {\n run: defineCommand({\n meta: {\n name: 'run',\n description:\n 'Run crawl, index, and link recovery monitoring for a property',\n },\n args: monitoringRunArgs(),\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const urls = listArg(args.urls)\n const sitemaps = listArg(args.sitemaps)\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const report = await technicalWatchWorkflow({\n site: selection.site,\n startUrl,\n urls: urls.length ? urls : selection.client?.watchUrls,\n sitemaps: sitemaps.length ? sitemaps : undefined,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n limit: numberArg(args.limit),\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n recoverLinks: booleanArg(args['recover-links']),\n recoverDays: numberArg(args['recover-days']),\n recoverLimit: numberArg(args['recover-limit']),\n recoverMinClicks: numberArg(args['recover-min-clicks']),\n recoverMinImpressions: numberArg(args['recover-min-impressions']),\n })\n\n if (json) {\n printJson(report)\n return\n }\n printMonitoringRun(report)\n },\n }),\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show the latest saved monitoring state for a property',\n },\n args: monitoringStatusArgs(),\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = monitoringStatus({\n site: selection.site,\n staleAfterDays: numberArg(args['stale-days']),\n })\n if (json) {\n printJson(report)\n return\n }\n printMonitoringStatus(report)\n },\n }),\n cron: defineCommand({\n meta: {\n name: 'cron',\n description: 'Print a local cron line for recurring monitoring',\n },\n args: {\n ...monitoringRunArgs(),\n hour: {\n type: 'string',\n default: '9',\n description: 'Hour in local cron time. Defaults to 9.',\n },\n minute: {\n type: 'string',\n default: '0',\n description: 'Minute in local cron time. Defaults to 0.',\n },\n weekday: {\n type: 'string',\n description:\n 'Weekly monitoring day. Defaults to client setting, then Monday.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const hour = numberArg(args.hour) ?? 9\n const minute = numberArg(args.minute) ?? 0\n const weekday =\n numberArg(args.weekday) ?? selection.client?.technicalWeekday ?? 1\n const identityArg = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n const command = [\n 'seo monitoring run',\n identityArg,\n quotedFlag('url', args.url),\n quotedFlag('urls', args.urls),\n quotedFlag('sitemaps', args.sitemaps),\n quotedFlag('properties', args.properties),\n quotedFlag('limit', args.limit),\n quotedFlag('daily-limit', args['daily-limit']),\n quotedFlag('inspect-limit', args['inspect-limit']),\n quotedFlag('max-urls', args['max-urls']),\n quotedFlag('language', args.language),\n quotedFlag('recover-days', args['recover-days']),\n quotedFlag('recover-limit', args['recover-limit']),\n quotedFlag('recover-min-clicks', args['recover-min-clicks']),\n quotedFlag(\n 'recover-min-impressions',\n args['recover-min-impressions'],\n ),\n recoverLinksFlag(args['recover-links']),\n booleanFlag('refresh', args.refresh),\n booleanFlag('js', args.js),\n '--json',\n ]\n .filter(Boolean)\n .join(' ')\n const line = {\n name: 'monitoring',\n cron: `${minute} ${hour} * * ${weekday}`,\n command,\n }\n\n if (json) {\n printJson({ site: selection.site, line })\n return\n }\n printKeyValue([\n ['Property', selection.site],\n ['Install', 'crontab -e'],\n ])\n process.stdout.write(`${line.cron} ${line.command}\\n`)\n },\n }),\n },\n})\n","import { indexCoverageSignals } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary, truncate } from '../output.js'\n\nexport const indexCoverageCommand = defineCommand({\n meta: {\n name: 'index-coverage',\n description:\n 'Find crawlable pages that deserve a closer Google index check',\n },\n args: {\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n 'crawl-report-id': {\n type: 'string',\n description:\n 'Saved crawl report id. Defaults to the latest for the site.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs. Defaults to declarations captured by the crawl.',\n },\n days: {\n type: 'string',\n description: 'Finalized Search Console date range. Defaults to 90 days.',\n },\n 'row-limit': {\n type: 'string',\n description: 'Maximum Search Console page rows. Defaults to 100000.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum sitemap inventory URLs. Defaults to 100000.',\n },\n limit: {\n type: 'string',\n description:\n 'Maximum URLs returned in each evidence group. Defaults to 100.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local Search Console cache.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const sitemapValues = listArg(args.sitemaps)\n const report = await indexCoverageSignals({\n site: selection.site,\n crawlReportId: stringArg(args['crawl-report-id']),\n sitemaps: sitemapValues.length ? sitemapValues : undefined,\n days: numberArg(args.days),\n rowLimit: numberArg(args['row-limit']),\n maxSitemapUrls: numberArg(args['max-sitemap-urls']),\n itemsPerSection: numberArg(args.limit),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Index coverage',\n target: report.site,\n status:\n report.sources.crawl.completeness === 'complete' &&\n report.sources.searchConsole.completeness === 'complete'\n ? report.summary.crawlableCandidatesWithoutRetainedSearchVisibility >\n 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary: `${report.summary.crawlableCandidatesWithoutRetainedSearchVisibility} crawlable pages need URL Inspection review.`,\n metrics: [\n { label: 'Crawl report', value: report.input.crawlReport.id },\n { label: 'Crawl evidence', value: report.sources.crawl.completeness },\n {\n label: 'Sitemap evidence',\n value: report.sources.sitemap.completeness,\n },\n {\n label: 'Search evidence',\n value: report.sources.searchConsole.completeness,\n },\n {\n label: 'Search window',\n value: `${report.sources.searchConsole.startDate} to ${report.sources.searchConsole.endDate}`,\n },\n {\n label: 'Search-visible pages',\n value: report.summary.retainedSearchVisibleUrls,\n },\n {\n label: 'Blocked/non-indexable',\n value: report.summary.blockedOrNonIndexableCrawlUrls,\n },\n { label: 'Sitemap only', value: report.summary.sitemapOnlyUrls },\n {\n label: 'Search Console only',\n value: report.summary.searchConsoleOnlyUrls,\n },\n ],\n })\n\n if (report.crawlableWithoutRetainedSearchVisibility.items.length) {\n process.stdout.write('\\nRepresentative URL Inspection candidates\\n')\n printTable(\n ['URL', 'Status', 'In sitemap'],\n report.crawlableWithoutRetainedSearchVisibility.items.map((item) => [\n truncate(item.url, 80),\n item.status,\n item.inSitemap ? 'yes' : 'no',\n ]),\n )\n }\n\n printNotes('How to read this report', report.caveats)\n },\n})\n","import {\n countLabel,\n indexCoveragePlan,\n indexMonitor,\n indexWatch,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n listArg,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveSite } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\n\nexport const indexWatchCommand = defineCommand({\n meta: {\n name: 'index-watch',\n description: 'Inspect URLs with GSC and alert on index status changes',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs to plan quota-aware monitoring.',\n },\n plan: {\n type: 'boolean',\n default: false,\n description:\n 'Plan sitemap URL allocation across GSC properties without inspecting URLs.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties to use for planning. Defaults to account properties.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'target-days': {\n type: 'string',\n description:\n 'Target number of days to inspect all monitored URLs. Defaults to 1.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for planning. Defaults to 50000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum URLs to inspect in this run from sitemap mode. Defaults to 100.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const urls = listArg(args.urls)\n const site = await resolveSite({\n site: stringArg(args.site),\n options: { json },\n })\n\n const sitemaps = listArg(args.sitemaps)\n\n if (booleanArg(args.plan)) {\n if (!sitemaps.length) {\n throw new Error('Pass at least one sitemap with --sitemaps.')\n }\n const report = await indexCoveragePlan({\n site,\n sitemaps,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n dailyLimit: numberArg(args['daily-limit']),\n targetCycleDays: numberArg(args['target-days']),\n maxUrls: numberArg(args['max-urls']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index monitoring plan',\n target: report.site,\n status: report.warnings.length > 0 ? 'warning' : 'info',\n summary: `${report.summary.urlCount} sitemap URLs can be checked in an estimated ${countLabel(report.summary.estimatedCycleDays, 'day')}.`,\n metrics: [\n { label: 'Sitemap URLs', value: report.summary.urlCount },\n { label: 'Properties', value: report.summary.properties },\n { label: 'Daily capacity', value: report.summary.dailyCapacity },\n {\n label: 'Target cycle',\n value: countLabel(report.summary.targetCycleDays, 'day'),\n },\n {\n label: 'Suggested properties',\n value: report.summary.suggestedProperties,\n },\n ],\n })\n if (report.properties.length) {\n printTable(\n ['Property', 'URLs', 'Cycle', 'Sample URL'],\n report.properties.map((property) => [\n property.property,\n property.urlCount,\n countLabel(property.cycleDays, 'day'),\n property.sampleUrls[0] ?? '-',\n ]),\n )\n }\n if (report.suggestions.length) {\n process.stdout.write('\\nSuggested URL-prefix properties\\n')\n printTable(\n ['Property', 'URLs', 'Current property', 'Cycle', 'Reason'],\n report.suggestions.map((suggestion) => [\n suggestion.property,\n suggestion.urlCount,\n suggestion.currentProperty,\n countLabel(suggestion.estimatedCycleDays, 'day'),\n suggestion.reason,\n ]),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n return\n }\n\n if (sitemaps.length) {\n const report = await indexMonitor({\n site,\n sitemaps,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n languageCode: stringArg(args.language),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index monitoring run',\n target: report.site,\n status:\n report.summary.failed > 0 || report.summary.quotaBlocked > 0\n ? 'unknown'\n : report.summary.alerts > 0 || report.summary.regressions > 0\n ? 'warning'\n : report.summary.attempted > 0\n ? 'pass'\n : 'info',\n summary: `${report.summary.inspected} URLs inspected, with ${report.summary.alerts} new alerts and ${report.summary.regressions} regressions.`,\n metrics: [\n { label: 'Inventory URLs', value: report.summary.inventoryUrls },\n { label: 'Selected', value: report.summary.selected },\n { label: 'Inspected', value: report.summary.inspected },\n { label: 'Failed', value: report.summary.failed },\n { label: 'Quota blocked', value: report.summary.quotaBlocked },\n { label: 'Current reviews', value: report.summary.currentIssues },\n { label: 'Regressions', value: report.summary.regressions },\n { label: 'Recoveries', value: report.summary.recoveries },\n { label: 'New alerts', value: report.summary.alerts },\n ],\n })\n if (report.properties.length) {\n printTable(\n [\n 'Property',\n 'Inventory',\n 'Selected',\n 'Inspected',\n 'Failed',\n 'Current',\n 'Alerts',\n ],\n report.properties.map((property) => [\n property.property,\n property.inventoryUrls,\n property.selectedUrls,\n property.inspected,\n property.failed + property.quotaBlocked,\n property.currentIssues,\n property.alerts,\n ]),\n )\n }\n const issueItems = report.items\n .filter(\n (item) =>\n item.currentIssue ||\n item.changed ||\n item.inspectionStatus !== 'succeeded',\n )\n .slice(0, 50)\n if (issueItems.length) {\n process.stdout.write('\\nIndex reviews, changes, and failed checks\\n')\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n issueItems.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n item.url,\n ]),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n return\n }\n\n if (!urls.length) throw new Error('Pass at least one URL with --urls.')\n\n const report = await indexWatch({\n site,\n urls,\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Index watch',\n target: report.site,\n status:\n report.summary.failed > 0 || report.summary.quotaBlocked > 0\n ? 'unknown'\n : report.summary.alerts > 0 || report.summary.regressions > 0\n ? 'warning'\n : report.summary.attempted > 0\n ? 'pass'\n : 'info',\n summary: `${report.summary.inspected} URLs inspected, with ${report.summary.alerts} new alerts.`,\n metrics: [\n { label: 'Property', value: report.source.property },\n { label: 'Attempted', value: report.summary.attempted },\n { label: 'Inspected', value: report.summary.inspected },\n { label: 'Failed', value: report.summary.failed },\n { label: 'Quota blocked', value: report.summary.quotaBlocked },\n { label: 'Current reviews', value: report.summary.currentIssues },\n { label: 'Regressions', value: report.summary.regressions },\n { label: 'Recoveries', value: report.summary.recoveries },\n { label: 'New alerts', value: report.summary.alerts },\n ],\n })\n printTable(\n ['Check', 'Change', 'Index state', 'Evidence', 'URL'],\n report.items.map((item) => [\n item.inspectionStatus,\n item.changeKind,\n item.indexStatus,\n (item.errorCode ?? item.issueCodes.join(', ')) || 'none',\n item.url,\n ]),\n )\n },\n})\n","import { linkRecover } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { selectedSiteOrThrow } from '../shared.js'\n\nexport const linkRecoverCommand = defineCommand({\n meta: {\n name: 'link-recover',\n description:\n 'Find search-value URLs that are now broken, blocked, or poorly redirected',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'minImpressions', 'refresh', 'js'], {\n days: {\n description: 'GSC lookback window. Defaults to 90.',\n },\n limit: {\n description: 'Maximum GSC pages to check. Defaults to 50.',\n },\n minImpressions: {\n description: 'Minimum impressions to check a page. Defaults to 100.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP caches.',\n },\n js: {\n description: 'Force JavaScript rendering for final page extraction.',\n },\n }),\n 'min-clicks': {\n type: 'string',\n description: 'Minimum clicks to check a page. Defaults to 1.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const report = await linkRecover({\n site: await selectedSiteOrThrow(\n { client: projectArg(args), site: stringArg(args.site) },\n { json },\n ),\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minClicks: numberArg(args['min-clicks']),\n minImpressions: numberArg(args['min-impressions']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Link recovery',\n target: report.site,\n status:\n report.warnings.length > 0\n ? 'unknown'\n : report.summary.recoverable > 0\n ? 'warning'\n : 'pass',\n summary:\n report.summary.recoverable > 0\n ? `${formatCount(report.summary.recoverable)} previously visible URLs need recovery review.`\n : 'No recoverable URLs were found in the retained evidence.',\n metrics: [\n {\n label: 'Range',\n value: `${report.range.startDate} to ${report.range.endDate}`,\n },\n { label: 'Checked', value: formatCount(report.summary.checked) },\n {\n label: 'Recoverable',\n value: formatCount(report.summary.recoverable),\n },\n { label: 'High severity', value: formatCount(report.summary.high) },\n {\n label: 'Clicks at risk',\n value: formatCount(report.summary.clicksAtRisk),\n },\n {\n label: 'Impressions at risk',\n value: formatCount(report.summary.impressionsAtRisk),\n },\n ],\n })\n if (report.items.length) {\n printLimitedTable(\n ['Severity', 'Issue', 'Clicks', 'Impr', 'URL', 'Action'],\n report.items.map((item) => [\n item.severity,\n item.issue,\n formatCount(item.clicks),\n formatCount(item.impressions),\n truncate(item.url, 56),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top recovery actions',\n report.items.map((item) => ({\n label: truncate(item.url, 96),\n context: `${item.severity}, ${formatCount(item.clicks)} clicks at risk`,\n action: item.recommendation.action,\n })),\n )\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n },\n})\n","import { redirectTrace } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { printJson, printKeyValue, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary, truncate } from '../output.js'\n\nexport const redirectTraceCommand = defineCommand({\n meta: {\n name: 'redirect-trace',\n description:\n 'Trace redirects and report final indexability/canonical issues',\n },\n args: {\n url: {\n type: 'string',\n required: true,\n description: 'URL to trace.',\n },\n 'max-hops': {\n type: 'string',\n description: 'Maximum redirect hops to follow. Defaults to 10.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache for final page extraction.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for final page extraction.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const report = await redirectTrace({\n url: stringArg(args.url) ?? '',\n maxHops: numberArg(args['max-hops']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Redirect trace',\n target: report.url,\n status:\n report.summary.issues.length > 0\n ? 'warning'\n : report.summary.finalIndexable === undefined\n ? 'unknown'\n : 'pass',\n summary:\n report.summary.issues.length > 0\n ? report.summary.issues.join(', ')\n : `${report.summary.hops} redirect hops ended at HTTP ${report.summary.finalStatus}.`,\n metrics: [\n { label: 'Final URL', value: report.finalUrl },\n { label: 'Final status', value: report.summary.finalStatus },\n {\n label: 'Indexable',\n value:\n report.summary.finalIndexable === undefined\n ? 'Unknown'\n : report.summary.finalIndexable\n ? 'Yes'\n : 'No',\n },\n { label: 'Hops', value: report.summary.hops },\n ],\n })\n printTable(\n ['#', 'Status', 'URL', 'Next'],\n report.chain.map((step, index) => [\n index + 1,\n step.status,\n truncate(step.url, 72),\n truncate(step.nextUrl ?? '-', 72),\n ]),\n )\n if (report.finalPage) {\n process.stdout.write('\\nFinal page\\n')\n printKeyValue([\n ['Title', report.finalPage.title ?? '-'],\n ['Canonical', report.finalPage.canonical ?? '-'],\n ['Meta robots', report.finalPage.metaRobots ?? '-'],\n ])\n }\n printNotes('Warnings', report.warnings.slice(0, 10))\n },\n})\n","import {\n buildOkfBundle,\n explainOkfValidation,\n okfConceptLimit,\n validateOkfFiles,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../args.js'\nimport { printJson, printKeyValue, printTable } from '../utils.js'\nimport { readOkfMarkdownFiles, writeOkfDirectory } from './okf-files.js'\nimport { resolveSavedCrawlReport } from './readiness.js'\n\nfunction printValidation(\n filesPath: string,\n validation: ReturnType<typeof validateOkfFiles>,\n) {\n process.stdout.write(`OKF validation for ${filesPath}\\n\\n`)\n printKeyValue([\n ['Valid', validation.valid ? 'yes' : 'no'],\n ['Files', String(validation.files)],\n ['Concepts', String(validation.concepts)],\n [\n 'Errors',\n String(\n validation.issues.filter((issue) => issue.severity === 'error').length,\n ),\n ],\n [\n 'Warnings',\n String(\n validation.issues.filter((issue) => issue.severity === 'warning')\n .length,\n ),\n ],\n ])\n if (validation.issues.length) {\n process.stdout.write('\\nIssues\\n')\n printTable(\n ['Severity', 'Path', 'Message'],\n validation.issues\n .slice(0, 25)\n .map((issue) => [issue.severity, issue.path, issue.message]),\n )\n }\n}\n\nexport const okfExportCommand = defineCommand({\n meta: {\n name: 'export',\n description: 'Export a saved crawl as an OKF bundle',\n },\n args: {\n 'report-id': {\n type: 'string',\n description: 'Saved crawl report id to export.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for selecting the latest saved crawl.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n output: {\n type: 'string',\n description: 'Output directory. Defaults to ./okf.',\n },\n 'max-concepts': {\n type: 'string',\n description: 'Maximum concept files to export. Defaults to 500.',\n },\n title: {\n type: 'string',\n description: 'Override the root bundle title.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const maxConcepts = okfConceptLimit(\n strictNumberArg(args['max-concepts'], '--max-concepts'),\n )\n const report = await resolveSavedCrawlReport(args, { json })\n const bundle = buildOkfBundle(report, {\n maxConcepts,\n title: stringArg(args.title),\n })\n const output = stringArg(args.output) ?? './okf'\n const validation = await writeOkfDirectory(output, bundle.files)\n if (json) {\n printJson({ output, bundle, validation })\n return\n }\n process.stdout.write(`Wrote OKF bundle to ${output}\\n\\n`)\n printKeyValue([\n ['Files', String(bundle.files.length)],\n ['Concepts', String(bundle.conceptCount)],\n ['Valid', validation.valid ? 'yes' : 'no'],\n ])\n },\n})\n\nexport const okfValidateCommand = defineCommand({\n meta: {\n name: 'validate',\n description: 'Validate an OKF bundle directory',\n },\n args: {\n path: {\n type: 'positional',\n required: true,\n description: 'OKF bundle directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const path = stringArg(args.path)\n if (!path) throw new Error('Pass an OKF bundle directory.')\n const files = await readOkfMarkdownFiles(path)\n const validation = validateOkfFiles(files)\n if (!validation.valid) process.exitCode = 1\n if (jsonFlag(args)) {\n printJson(validation)\n return\n }\n printValidation(path, validation)\n },\n})\n\nexport const okfExplainCommand = defineCommand({\n meta: {\n name: 'explain',\n description: 'Explain OKF validation results in plain English',\n },\n args: {\n path: {\n type: 'positional',\n required: true,\n description: 'OKF bundle directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const path = stringArg(args.path)\n if (!path) throw new Error('Pass an OKF bundle directory.')\n const validation = validateOkfFiles(await readOkfMarkdownFiles(path))\n const explanation = explainOkfValidation(validation)\n if (!explanation.valid) process.exitCode = 1\n if (jsonFlag(args)) {\n printJson(explanation)\n return\n }\n process.stdout.write(`${explanation.summary}\\n\\n`)\n printKeyValue([\n ['Valid', explanation.valid ? 'yes' : 'no'],\n ['Files', String(explanation.files)],\n ['Concepts', String(explanation.concepts)],\n ['Errors', String(explanation.errors)],\n ['Warnings', String(explanation.warnings)],\n ])\n if (explanation.nextActions.length) {\n process.stdout.write('\\nNext actions\\n')\n for (const action of explanation.nextActions) {\n process.stdout.write(`- ${action}\\n`)\n }\n }\n },\n})\n\nexport const okfCommand = defineCommand({\n meta: {\n name: 'okf',\n description: 'Export, validate, and explain OKF site knowledge bundles',\n },\n subCommands: {\n export: okfExportCommand,\n validate: okfValidateCommand,\n explain: okfExplainCommand,\n },\n})\n","import { aiReferralsReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, strictNumberArg, stringArg } from '../../args.js'\nimport {\n resolveClient,\n resolveGoogleAnalyticsProperty,\n} from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printLimitedTable,\n printReportSummary,\n truncate,\n} from '../output.js'\n\nexport const aiReferralsCommand = defineCommand({\n meta: {\n name: 'ai-referrals',\n description: 'Find AI referral traffic detected in Google Analytics',\n },\n args: {\n property: {\n type: 'string',\n description:\n 'Google Analytics property ID. If omitted in a terminal, choose one.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description:\n 'Saved project id or name with an optional Google Analytics property.',\n },\n 'start-date': { type: 'string', default: '28daysAgo' },\n 'end-date': { type: 'string', default: 'yesterday' },\n 'max-rows': {\n type: 'string',\n description:\n 'Maximum Google Analytics rows per query. Defaults to 100000.',\n },\n 'result-limit': {\n type: 'string',\n description: 'Maximum ranked landing pages returned. Defaults to 25.',\n },\n limit: {\n type: 'string',\n description: 'Legacy alias for --max-rows.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass cached Google Analytics responses.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const client = await resolveClient({\n client: projectArg(args),\n options: { json },\n })\n const property = await resolveGoogleAnalyticsProperty({\n property:\n stringArg(args.property) ?? client?.analytics.google?.propertyId,\n options: { json },\n })\n const report = await aiReferralsReport({\n property,\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n resultLimit: strictNumberArg(args['result-limit'], '--result-limit'),\n limit: strictNumberArg(args.limit, '--limit'),\n refresh: args.refresh === true,\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'AI referral report',\n target: report.property,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Evidence',\n value: report.dataStatus === 'complete' ? 'Complete' : 'Partial',\n status: report.dataStatus === 'complete' ? 'pass' : 'unknown',\n },\n { label: 'AI sessions', value: formatCount(report.summary.sessions) },\n {\n label: 'AI users',\n value:\n report.summary.totalUsers === null\n ? 'Unavailable'\n : formatCount(report.summary.totalUsers),\n },\n { label: 'Sources', value: formatCount(report.summary.sources) },\n {\n label: 'Landing pages',\n value: formatCount(report.summary.landingPages),\n },\n {\n label: 'Landing-page output',\n value: `${formatCount(report.selection.landingPages.returnedRows)} returned / ${formatCount(report.selection.landingPages.retainedRows)} retained`,\n },\n {\n label: 'Source rows',\n value: formatCount(report.dataSource.sourceDiscovery.returnedRows),\n },\n ],\n })\n\n if (report.sources.length) {\n process.stdout.write('\\nAI sources\\n')\n printLimitedTable(\n ['Source', 'Sessions', 'Events', 'Share of AI sessions'],\n report.sources.map((source) => [\n source.label,\n formatCount(source.sessions),\n formatCount(source.eventCount),\n formatPercent(source.shareOfAiSessions),\n ]),\n )\n }\n\n if (report.landingPages.length) {\n process.stdout.write('\\nLanding pages\\n')\n printLimitedTable(\n ['Landing page', 'Sessions', 'Events', 'Top source'],\n report.landingPages.map((page) => [\n truncate(page.landingPage, 64),\n formatCount(page.sessions),\n formatCount(page.eventCount),\n page.topSourceDetails.label,\n ]),\n )\n }\n\n if (report.dataSource.partialReasons.length) {\n process.stdout.write('\\nEvidence warnings\\n')\n for (const warning of report.dataSource.partialReasons) {\n process.stdout.write(`- ${warning}\\n`)\n }\n }\n\n process.stdout.write(`\\nNote: ${report.summary.caveat}\\n`)\n },\n})\n","import { cannibalReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const cannibalCommand = defineCommand({\n meta: {\n name: 'cannibal',\n description: 'Find queries with material exposure across multiple URLs',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(\n ['days', 'limit', 'includeBrand', 'minImpressions', 'refresh'],\n {\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 50.',\n },\n },\n ),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await cannibalReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Cannibalisation report',\n target: report.site,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Range',\n value: `${report.range.startDate} to ${report.range.endDate}`,\n },\n {\n label: 'Eligible',\n value: formatCount(report.summary.eligibleClusters),\n },\n {\n label: 'Returned',\n value: formatCount(report.summary.returnedClusters),\n },\n {\n label: 'Suppressed brand queries',\n value: formatCount(report.summary.suppressedQueries),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n {\n label: 'Brand queries',\n value: booleanArg(args['include-brand']) ? 'included' : 'excluded',\n },\n ],\n })\n printLimitedTable(\n ['Query', 'URLs', 'Property impr', 'Exposure', 'HHI', 'Review first'],\n report.items.map((item) => [\n truncate(item.query, 42),\n item.pages.length,\n item.propertyImpressions === undefined\n ? 'n/a'\n : formatCount(item.propertyImpressions),\n formatCount(item.pageExposureImpressions),\n item.hhi.toFixed(2),\n truncate(item.suggestedOwnerUrl, 56),\n ]),\n )\n printActionDetails(\n 'Top cannibalisation actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.pages.length} material URLs; first review ${truncate(item.suggestedOwnerUrl, 64)}`,\n action: item.recommendation.action,\n })),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Provider usage', [report.ledgerSummary])\n },\n})\n","import { communityIntentReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const communityIntentCommand = defineCommand({\n meta: {\n name: 'community-intent',\n description: 'Find GSC queries with forum, review, and comparison intent',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n 'start-date': {\n type: 'string',\n description: 'Exact GSC start date (YYYY-MM-DD). Use with --end-date.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact GSC end date (YYYY-MM-DD). Use with --start-date.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC query rows. Defaults to 50000.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'GSC lookback within the current 16-month retention.',\n },\n limit: {\n description: 'Maximum intent queries to print. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 20.',\n },\n includeBrand: {\n description: 'Include branded queries in community-intent reports.',\n },\n refresh: { description: 'Bypass local GSC cache.' },\n },\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await communityIntentReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Community intent report',\n target: report.site,\n status:\n report.dataStatus === 'available' || report.dataStatus === 'empty'\n ? 'info'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Classified queries',\n value: formatCount(report.summary.classifiedQueries),\n },\n {\n label: 'Returned queries',\n value: formatCount(report.summary.returnedQueries),\n },\n {\n label: 'Impressions',\n value: formatCount(report.summary.returnedImpressions),\n },\n { label: 'Clicks', value: formatCount(report.summary.returnedClicks) },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n\n printLimitedTable(\n ['Intent', 'Query', 'Impr', 'Clicks', 'Confidence', 'Action'],\n report.items.map((item) => [\n item.intent,\n truncate(item.query, 42),\n formatCount(item.impressions),\n formatCount(item.clicks),\n item.confidence,\n truncate(item.action, 76),\n ]),\n )\n printActionDetails(\n 'Top community-intent actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.intent}, ${formatCount(item.impressions)} impressions`,\n action: item.action,\n })),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n },\n})\n","import { ctrUnderperformersReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const ctrUnderperformersCommand = defineCommand({\n meta: {\n name: 'ctr-underperformers',\n description:\n 'Find high-impression queries with weak CTR for their position',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['includeBrand', 'minImpressions'], {\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 200.',\n },\n }),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await ctrUnderperformersReport({\n site: selection.site,\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'CTR underperformers',\n target: report.site,\n status: report.dataStatus === 'partial' ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Underperformers',\n value: formatCount(report.summary.underperformers),\n },\n {\n label: 'Estimated click gap',\n value: formatCount(report.summary.estimatedClickShortfall),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n printNotes('Why this matters', [\n 'These queries already have visibility; the fastest win is usually better SERP framing, not new content.',\n 'Start with high-impression rows where actual CTR is far below the expected CTR for that ranking position.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printLimitedTable(\n ['Query', 'URL', 'Pos', 'Impr', 'CTR', 'Expected', 'Gap', 'Action'],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.url, 48),\n formatPosition(item.position),\n formatCount(item.impressions),\n formatPercent(item.actualCtr),\n formatPercent(item.expectedCtr),\n formatCount(item.clickShortfall),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top CTR actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${formatCount(item.clickShortfall)} click gap, ${formatPercent(item.actualCtr)} CTR`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { decayingReport, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nfunction formatMaybePosition(value: number): string {\n return value > 0 ? formatPosition(value) : 'n/a'\n}\n\nexport const decayingCommand = defineCommand({\n meta: {\n name: 'decaying',\n description: 'Find query/page rows losing clicks between two GSC windows',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'includeBrand', 'refresh']),\n comparison: {\n type: 'string',\n description: 'Comparison: previous-period or year-over-year.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n 'min-drop-pct': {\n type: 'string',\n description: 'Minimum click drop percentage. Defaults to 20.',\n },\n 'min-previous-clicks': {\n type: 'string',\n description:\n 'Minimum previous-window clicks for a query/page row. Defaults to 2.',\n },\n 'min-click-loss': {\n type: 'string',\n description: 'Minimum absolute click loss. Defaults to 1.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const comparison = stringArg(args.comparison)\n const days = strictNumberArg(args.days, '--days')\n const limit = strictNumberArg(args.limit, '--limit')\n const minDropPct = strictNumberArg(args['min-drop-pct'], '--min-drop-pct')\n const minPreviousClicks = strictNumberArg(\n args['min-previous-clicks'],\n '--min-previous-clicks',\n )\n const minClickLoss = strictNumberArg(\n args['min-click-loss'],\n '--min-click-loss',\n )\n if (\n comparison !== undefined &&\n comparison !== 'previous-period' &&\n comparison !== 'year-over-year'\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--comparison must be previous-period or year-over-year.',\n )\n }\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await decayingReport({\n site: selection.site,\n days,\n limit,\n comparison,\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n minDropPct,\n minPreviousClicks,\n minClickLoss,\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Decaying pages',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.summary.returnedRows > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Comparison', value: report.comparison },\n {\n label: 'Observed declines',\n value: formatCount(report.summary.returnedRows),\n },\n {\n label: 'Eligible declines',\n value: formatCount(report.summary.eligibleRows),\n },\n { label: 'Decay clusters', value: formatCount(report.summary.groups) },\n {\n label: 'Observed click decline',\n value: formatCount(\n report.summary.returnedObservedRetainedQueryClickLoss,\n ),\n },\n {\n label: 'Eligible click decline',\n value: formatCount(report.summary.observedRetainedQueryClickLoss),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Minimum drop', value: `${report.filters.minDropPct}%` },\n {\n label: 'Minimum previous clicks',\n value: formatCount(report.filters.minPreviousClicks),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n printNotes('Why this matters', [\n 'This report compares retained query/page rows and only counts declines observed in both windows.',\n 'Position, CTR, and impression movements are signals for investigation, not proof of cause.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n\n if (!report.items.length) {\n return\n }\n\n if (report.groups.length) {\n printLimitedTable(\n ['Cluster', 'Rows', 'Observed loss', 'Drop', 'Sample query', 'Action'],\n report.groups.map((group) => [\n truncate(group.label, 42),\n formatCount(group.count),\n formatCount(group.totalClickLoss),\n `${group.averageDropPct.toFixed(1)}%`,\n truncate(group.sampleQueries[0] ?? '-', 40),\n truncate(group.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top decay cluster actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${formatCount(group.count)} retained rows, ${formatCount(group.totalClickLoss)} observed click decline`,\n action: group.recommendation,\n })),\n )\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Signals',\n 'Decline',\n 'Clicks',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 32),\n truncate(item.template.label, 26),\n truncate(item.url, 44),\n item.signals.join(', '),\n formatCount(item.clickLoss),\n `${formatCount(item.previous.clicks)} -> ${formatCount(item.current.clicks)}`,\n `${formatCount(item.previous.impressions)} -> ${formatCount(item.current.impressions)}`,\n `${formatPercent(item.previous.ctr)} -> ${formatPercent(item.current.ctr)}`,\n `${formatMaybePosition(item.previous.position)} -> ${formatMaybePosition(item.current.position)}`,\n truncate(item.recommendation.action, 64),\n ]),\n )\n printActionDetails(\n 'Top decay actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, ${formatCount(item.clickLoss)} fewer observed clicks`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { internalLinksReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictFetchRateArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const internalLinksCommand = defineCommand({\n meta: {\n name: 'internal-links',\n description: 'Find verified internal-link review candidates for one URL',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n url: {\n type: 'string',\n required: true,\n description: 'Target page that should receive relevant internal links.',\n },\n ...cliReportArgs([\n 'days',\n 'limit',\n 'checkLimit',\n 'minImpressions',\n 'includeBrand',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const refresh = booleanArg(args.refresh)\n const days = strictNumberArg(args.days, '--days')\n const limit = strictNumberArg(args.limit, '--limit')\n const checkLimit = strictNumberArg(args['check-limit'], '--check-limit')\n const minImpressions = strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n )\n const rate = strictFetchRateArg(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh },\n })\n const report = await internalLinksReport({\n site: selection.site,\n targetUrl: stringArg(args.url) ?? '',\n days,\n limit,\n checkLimit,\n minImpressions,\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n js: booleanArg(args.js) ? true : undefined,\n rate,\n refresh,\n })\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Internal link opportunities',\n target: report.targetUrl,\n status:\n report.summary.failedChecks > 0 ||\n report.summary.uncheckedCandidates > 0\n ? 'unknown'\n : 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Target state', value: report.target.verification },\n { label: 'Preferred target', value: report.target.preferredUrl },\n {\n label: 'Target queries',\n value: formatCount(report.summary.targetQueries),\n },\n {\n label: 'Matched sources',\n value: formatCount(report.summary.candidateSources),\n },\n {\n label: 'Checked sources',\n value: formatCount(report.summary.checkedSources),\n },\n {\n label: 'Attempted sources',\n value: formatCount(report.summary.attemptedSources),\n },\n {\n label: 'Review candidates',\n value: formatCount(report.summary.returnedSources),\n },\n {\n label: 'Technical exclusions',\n value: formatCount(report.summary.technicalExclusions),\n },\n {\n label: 'Existing links',\n value: formatCount(report.summary.existingLinksObserved),\n },\n {\n label: 'Failed checks',\n value: formatCount(report.summary.failedChecks),\n },\n {\n label: 'Unchecked sources',\n value: formatCount(report.summary.uncheckedCandidates),\n },\n { label: 'GSC completeness', value: report.source.completeness },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n ],\n })\n printNotes('Why this matters', [\n 'Exact-query overlap is useful affinity evidence; precision lexical matches are review evidence only.',\n 'Source and target pages are checked for redirects, indexability, canonicals, and existing link placement before an action is returned.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n if (!report.items.length) return\n\n printLimitedTable(\n ['Source URL', 'Matched impr', 'Match', 'Link evidence', 'Action'],\n report.items.map((item) => [\n truncate(item.sourceUrl, 52),\n formatCount(item.matchedQueryImpressions),\n item.bestMatchKind,\n item.linkEvidence.status,\n item.actionType,\n ]),\n )\n printActionDetails(\n 'Top internal-link reviews',\n report.items.map((item) => ({\n label: truncate(item.sourceUrl, 96),\n context: `${formatCount(item.matchedQueryImpressions)} matched-query impressions; ${item.bestMatchKind}`,\n action: item.recommendation.action,\n })),\n )\n printNotes('Provider usage', [report.ledgerSummary])\n },\n})\n","import { pageOpportunitiesReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatFetchDiagnostics } from '../shared.js'\n\nexport const pageOpportunitiesCommand = defineCommand({\n meta: {\n name: 'page-opportunities',\n description: 'Find first-party traffic growth opportunities for one URL',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n url: { type: 'string', required: true },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'js', 'refresh'],\n {\n limit: {\n description: 'Maximum page queries to inspect. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 10.',\n },\n includeBrand: {\n description: 'Include branded queries in page opportunity reports.',\n },\n js: {\n description: 'Force JavaScript rendering for page extraction.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP cache.',\n },\n },\n ),\n 'verify-content': defaultTrueBooleanArg(\n 'Fetch the page for title/H1/body checks. Defaults to true.',\n 'Skip fetching the page for title/H1/body checks.',\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await pageOpportunitiesReport({\n site: selection.site,\n url: stringArg(args.url) ?? '',\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent: booleanArg(args['verify-content']) !== false,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Page opportunities',\n target: report.url,\n status: report.verification.status === 'failed' ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Title', value: report.page?.title ?? 'Not fetched' },\n {\n label: 'Fetch',\n value: formatFetchDiagnostics(report.page?.fetchDiagnostics),\n },\n { label: 'Verification', value: report.verification.status },\n {\n label: 'Rows',\n value: `${formatCount(report.selection.returnedRows)} returned / ${formatCount(report.selection.eligibleRows)} eligible / ${formatCount(report.selection.sourceRows)} source`,\n },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n {\n label: 'Opportunities',\n value: formatCount(report.summary.opportunities),\n },\n {\n label: 'CTR shortfall',\n value: formatCount(report.summary.estimatedCtrClickShortfall),\n },\n { label: 'Focus', value: report.summary.focus },\n { label: 'Evidence', value: report.dataStatus },\n ],\n })\n printNotes('Why this matters', [\n 'This report starts from queries where this exact URL already has impressions, so recommendations stay tied to first-party demand.',\n 'Content verification separates body gaps from title/meta framing issues, which helps avoid adding copy when the page already covers the query.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (!report.items.length) {\n process.stdout.write(\n report.dataStatus === 'empty'\n ? 'No GSC query rows found for this exact URL.\\n'\n : 'GSC rows were found, but none met the report criteria.\\n',\n )\n return\n }\n\n printLimitedTable(\n [\n 'Type',\n 'Query',\n 'Evidence',\n 'Pos',\n 'CTR',\n 'Expected',\n 'Impr',\n 'Shortfall',\n 'Action',\n ],\n report.items.map((item) => [\n item.opportunityType,\n truncate(item.query, 38),\n item.verification.signals.length\n ? item.verification.signals.join(', ')\n : item.verification.status,\n item.position.toFixed(1),\n formatPercent(item.ctr),\n item.expectedCtr === undefined\n ? 'n/a'\n : formatPercent(item.expectedCtr),\n formatCount(item.impressions),\n item.estimatedCtrClickShortfall === undefined\n ? 'n/a'\n : formatCount(item.estimatedCtrClickShortfall),\n truncate(item.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top page actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.opportunityType}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation,\n })),\n )\n },\n})\n","import { queryClusterReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const queryClusterCommand = defineCommand({\n meta: {\n name: 'query-cluster',\n description: 'Cluster GSC queries into repeated demand themes',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n scope: { type: 'string' },\n ...cliReportArgs(['includeBrand', 'minImpressions', 'limit'], {\n includeBrand: {\n description: 'Include branded queries in query clustering.',\n },\n minImpressions: {\n description: 'Minimum impressions per query. Defaults to 25.',\n },\n limit: {\n description: 'Maximum clusters to return. Defaults to 25; max 100.',\n },\n }),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await queryClusterReport({\n site: selection.site,\n scope: stringArg(args.scope),\n brand: selection.client?.brandTerms?.[0],\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n minImpressions: numberArg(args['min-impressions']),\n limit: numberArg(args.limit),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Query clusters',\n target: report.site,\n status: 'info',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Scope', value: report.scope ?? 'All pages' },\n { label: 'Clusters', value: formatCount(report.summary.clusters) },\n { label: 'Queries', value: formatCount(report.summary.queries) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n { label: 'Clicks', value: formatCount(report.summary.clicks) },\n {\n label: 'Minimum impressions',\n value: formatCount(report.summary.minImpressions),\n },\n { label: 'Result limit', value: formatCount(report.summary.limit) },\n {\n label: 'High opportunity',\n value: formatCount(report.summary.highOpportunityClusters),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n ],\n })\n printNotes('Why this matters', [\n 'Clusters show repeated demand themes, so they are better inputs for page sections, hubs, and templates than one-off query exports.',\n 'Prioritise clusters with high impressions and low clicks; they usually reveal unclear intent coverage or weak SERP framing.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n printLimitedTable(\n [\n 'Cluster',\n 'Intent',\n 'Queries',\n 'Impr',\n 'CTR',\n 'Expected',\n 'Lift',\n 'Action',\n ],\n report.clusters.map((cluster) => {\n return [\n truncate(cluster.label, 32),\n cluster.intent,\n cluster.queries.length,\n formatCount(cluster.totals?.impressions ?? 0),\n formatPercent(cluster.totals?.ctr ?? 0),\n formatPercent(cluster.benchmark?.expectedCtr ?? 0),\n cluster.estimatedClickLift === undefined\n ? '-'\n : formatCount(cluster.estimatedClickLift),\n truncate(cluster.recommendation ?? '', 72),\n ]\n }),\n )\n printActionDetails(\n 'Top cluster actions',\n report.clusters.map((cluster) => ({\n label: cluster.label,\n context: `${formatCount(cluster.totals?.impressions ?? 0)} impressions, ${cluster.estimatedClickLift === undefined ? 'ranking opportunity' : `${formatCount(cluster.estimatedClickLift)} estimated click lift`}`,\n action: cluster.recommendation ?? '',\n })),\n )\n },\n})\n","import { quickWinsReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n verificationSummary,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nexport const quickWinsCommand = defineCommand({\n meta: {\n name: 'quick-wins',\n description: 'Find high-ranking low-CTR query/page opportunities',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs([\n 'days',\n 'limit',\n 'includeBrand',\n 'minImpressions',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const report = await quickWinsReport({\n site: selection.site,\n days: numberArg(args.days),\n limit: numberArg(args.limit),\n minImpressions: numberArg(args['min-impressions']),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Quick wins',\n target: report.site,\n status: report.source.possiblyTruncated ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible rows',\n value: formatCount(report.summary.eligibleRows),\n },\n {\n label: 'Returned rows',\n value: formatCount(report.summary.returnedRows),\n },\n {\n label: 'Query clusters',\n value: formatCount(report.summary.repeatedQueryGroups),\n },\n {\n label: 'Template patterns',\n value: formatCount(report.summary.templatePatterns),\n },\n {\n label: 'CTR click shortfall',\n value: formatCount(report.summary.returnedEstimatedCtrClickShortfall),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Verification', value: verificationSummary(report) },\n ],\n })\n printNotes('Why this matters', [\n 'These rows have GSC average positions from 4 to 10 and observed CTR below a site-peer or versioned fallback target.',\n 'Page evidence is needed before treating a CTR shortfall as a title, content, or technical finding.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (!report.items.length) {\n return\n }\n\n if (report.templateRecommendations.length) {\n printLimitedTable(\n ['Template', 'URLs', 'Rows', 'Shortfall', 'Impr', 'Action'],\n report.templateRecommendations.map((template) => [\n truncate(template.templateLabel, 34),\n formatCount(template.urlCount),\n formatCount(template.rowCount),\n formatCount(template.totalEstimatedCtrClickShortfall),\n formatCount(template.totalImpressions),\n truncate(template.action, 72),\n ]),\n )\n printActionDetails(\n 'Top template actions',\n report.templateRecommendations.map((template) => ({\n label: template.templateLabel,\n context: `${formatCount(template.urlCount)} URLs, ${formatCount(template.totalEstimatedCtrClickShortfall)} heuristic CTR click shortfall`,\n action: `${template.action} ${template.evidence}`,\n })),\n )\n }\n\n if (report.groups.length) {\n printLimitedTable(\n [\n 'Cluster',\n 'URLs',\n 'Rows',\n 'Shortfall',\n 'Impr',\n 'Sample URL',\n 'Action',\n ],\n report.groups.map((group) => [\n truncate(group.label, 44),\n formatCount(group.urlCount),\n formatCount(group.rowCount),\n formatCount(group.totalEstimatedCtrClickShortfall),\n formatCount(group.totalImpressions),\n truncate(group.sampleUrls[0] ?? '-', 46),\n truncate(group.recommendation, 72),\n ]),\n )\n printActionDetails(\n 'Top cluster actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${formatCount(group.urlCount)} URLs, ${formatCount(group.totalEstimatedCtrClickShortfall)} heuristic CTR click shortfall`,\n action: group.recommendation,\n })),\n )\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Pos',\n 'Impr',\n 'CTR / target',\n 'Shortfall',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.template.label, 24),\n truncate(item.url, 48),\n formatPosition(item.position),\n formatCount(item.impressions),\n `${formatPercent(item.ctr)} / ${formatPercent(item.targetCtr)}`,\n formatCount(item.estimatedCtrClickShortfall),\n formatFetchDiagnostics(item.contentVerification?.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n truncate(item.recommendation.action, 64),\n ]),\n )\n printActionDetails(\n 'Top opportunity actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { secondPage } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n verificationSummary,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nexport const secondPageCommand = defineCommand({\n meta: {\n name: 'second-page',\n description: 'Find URLs averaging positions above 10 through 20 in GSC',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs([\n 'range',\n 'minImpressions',\n 'limit',\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await secondPage({\n site: selection.site,\n range: numberArg(args.days),\n minImpressions: numberArg(args['min-impressions']),\n limit: stringArg(args.limit) ? Number(stringArg(args.limit)) : 10,\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Second-page opportunities',\n target: report.site,\n status:\n report.source.possiblyTruncated || report.summary.fetchFailures > 0\n ? 'unknown'\n : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible pages',\n value: formatCount(report.summary.eligiblePages),\n },\n {\n label: 'Returned pages',\n value: formatCount(report.summary.returnedPages),\n },\n {\n label: 'Eligible queries',\n value: formatCount(report.summary.eligibleQueries),\n },\n {\n label: 'Impressions',\n value: formatCount(report.summary.eligibleImpressions),\n },\n {\n label: 'Content issues',\n value: formatCount(report.summary.contentIssues),\n },\n {\n label: 'Technical issues',\n value: formatCount(report.summary.technicalIssues),\n },\n {\n label: 'Fetch failures',\n value: formatCount(report.summary.fetchFailures),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n { label: 'Evidence', value: report.dataStatus },\n { label: 'Verification', value: verificationSummary(report) },\n ],\n })\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n if (!report.items.length) {\n process.stdout.write(\n 'No average-position candidates matched this report.\\n',\n )\n process.stdout.write(`${report.ledgerSummary}\\n`)\n return\n }\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'Pos',\n 'Impr',\n 'CTR',\n 'Queries',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n item.primaryQuery,\n item.template.label,\n item.position.toFixed(1),\n Math.round(item.impressions),\n item.ctr.toFixed(3),\n formatCount(item.queryCount),\n formatFetchDiagnostics(item.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n item.recommendation.action,\n ]),\n )\n printActionDetails(\n 'Top second-page actions',\n report.items.map((item) => ({\n label: item.primaryQuery,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n process.stdout.write(`${report.ledgerSummary}\\n`)\n },\n})\n","import { seoToAiQueryReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const seoToAiQueryCommand = defineCommand({\n meta: {\n name: 'seo-to-ai-query',\n description: 'Convert GSC search queries into AI-style monitoring prompts',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n 'start-date': {\n type: 'string',\n description: 'Exact GSC start date (YYYY-MM-DD). Use with --end-date.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact GSC end date (YYYY-MM-DD). Use with --start-date.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC query rows. Defaults to 50000.',\n },\n 'brand-terms': {\n type: 'string',\n description: 'Comma-separated brand terms to exclude.',\n },\n ...cliReportArgs(\n ['days', 'limit', 'minImpressions', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'GSC lookback within the current 16-month retention.',\n },\n limit: {\n description: 'Maximum source queries to convert. Defaults to 25.',\n },\n minImpressions: {\n description: 'Minimum query impressions. Defaults to 20.',\n },\n includeBrand: {\n description: 'Include branded queries in prompt generation.',\n },\n refresh: { description: 'Bypass local GSC cache.' },\n },\n ),\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await seoToAiQueryReport({\n site: selection.site,\n days: strictNumberArg(args.days, '--days'),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: strictNumberArg(args.limit, '--limit'),\n minImpressions: strictNumberArg(\n args['min-impressions'],\n '--min-impressions',\n ),\n maxRows: strictNumberArg(args['max-rows'], '--max-rows'),\n brandTerms: [\n ...(selection.client?.brandTerms ?? []),\n ...(csvArg(args['brand-terms']) ?? []),\n ],\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'SEO to AI query prompts',\n target: report.site,\n status:\n report.dataStatus === 'available' || report.dataStatus === 'empty'\n ? 'info'\n : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Eligible queries',\n value: formatCount(report.summary.eligibleQueries),\n },\n {\n label: 'Returned queries',\n value: formatCount(report.summary.returnedQueries),\n },\n { label: 'Prompts', value: formatCount(report.summary.prompts) },\n { label: 'GSC completeness', value: report.source.completeness },\n ],\n })\n\n printLimitedTable(\n ['Query', 'Impr', 'Prompt'],\n report.items.flatMap((item) =>\n item.prompts.map((prompt) => [\n truncate(item.query, 42),\n formatCount(item.impressions),\n truncate(prompt, 86),\n ]),\n ),\n )\n printNotes('Report caveats', report.caveats)\n printNotes('Warnings', report.warnings)\n },\n})\n","import { auditPage } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport { printReportSummary } from './output.js'\nimport { formatFetchDiagnostics } from './shared.js'\n\nexport const auditPageCommand = defineCommand({\n meta: {\n name: 'audit-page',\n description:\n 'Fetch one page and audit title, metadata, content, links, and schema',\n },\n args: {\n url: { type: 'string', required: true, description: 'URL to audit.' },\n site: {\n type: 'string',\n description:\n 'Optional GSC property for page search metrics, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering for extraction.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache.',\n },\n },\n run: async ({ args }) => {\n const project = projectArg(args)\n const explicitSite = stringArg(args.site)\n const selectedProject = project\n ? await resolveClient({ project, options: { json: jsonFlag(args) } })\n : undefined\n const defaultProject =\n project || explicitSite\n ? undefined\n : await resolveClient({ options: { json: jsonFlag(args) } })\n const report = await auditPage({\n url: stringArg(args.url) ?? '',\n site: selectedProject?.siteUrl ?? explicitSite ?? defaultProject?.siteUrl,\n js: booleanArg(args.js) ? true : 'auto',\n refresh: booleanArg(args.refresh),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Page audit',\n target: report.url,\n status: report.issues.some((issue) => issue.severity === 'high')\n ? 'fail'\n : report.issues.length > 0\n ? 'warning'\n : 'pass',\n summary:\n report.issues.length > 0\n ? `${report.issues.length} ${report.issues.length === 1 ? 'issue needs' : 'issues need'} review.`\n : 'No page issues were found by the available checks.',\n metrics: [\n { label: 'Final URL', value: report.page.finalUrl },\n { label: 'Title', value: report.page.title ?? 'Missing' },\n {\n label: 'Meta description',\n value: report.page.metaDescription ?? 'Missing',\n },\n { label: 'Words', value: report.page.wordCount },\n {\n label: 'Fetch',\n value: formatFetchDiagnostics(report.fetchDiagnostics),\n },\n ],\n diagnostics: [\n {\n title: 'Issues',\n items: report.issues.map((issue) => ({\n status: issue.severity === 'high' ? 'fail' : 'warning',\n title: `${issue.code}: ${issue.principle}`,\n explanation: issue.detail,\n })),\n },\n ],\n })\n },\n})\n","import { performanceAudit, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../args.js'\nimport { resolveClient } from '../selection.js'\nimport { printJson } from '../utils.js'\nimport { printActionDetails, printNotes, printReportSummary } from './output.js'\n\nfunction strategy(value: unknown): 'mobile' | 'desktop' {\n const selected = stringArg(value) ?? 'mobile'\n if (selected !== 'mobile' && selected !== 'desktop') {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Invalid --strategy. Use mobile or desktop.',\n )\n }\n return selected\n}\n\nfunction metric(value?: { displayValue?: string; value?: number }): string {\n if (!value) return 'not measured'\n return value.displayValue ?? String(value.value ?? 'not measured')\n}\n\nfunction fieldMetric(value?: {\n p75: number\n rating: string\n unit: 'milliseconds' | 'score'\n}): string {\n if (!value) return 'not available'\n const suffix = value.unit === 'milliseconds' ? 'ms' : ''\n return `${value.p75}${suffix} (${value.rating})`\n}\n\nexport const performanceCommand = defineCommand({\n meta: {\n name: 'perf',\n description: 'Audit lab performance and field Core Web Vitals',\n },\n subCommands: {\n audit: defineCommand({\n meta: {\n name: 'audit',\n description: 'Run a Lighthouse/Core Web Vitals performance audit',\n },\n args: {\n url: {\n type: 'string',\n description:\n 'URL to audit. Defaults to the selected project crawl URL.',\n },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n project: { type: 'string', description: 'Saved project id or name.' },\n strategy: {\n type: 'string',\n default: 'mobile',\n description: 'Audit strategy: mobile or desktop.',\n },\n 'lighthouse-bin': {\n type: 'string',\n description:\n 'Custom Lighthouse binary path. Defaults to the bundled version.',\n },\n 'crux-key': {\n type: 'string',\n description:\n 'CrUX API key. Prefer SEO_CRUX_API_KEY to avoid shell history.',\n },\n raw: {\n type: 'boolean',\n default: false,\n description: 'Include the full Lighthouse JSON in JSON output.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass the local performance report cache.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = await resolveClient({\n client: projectArg(args),\n options: { json },\n })\n const url = stringArg(args.url) ?? project?.startUrl\n if (!url) {\n throw new Error(\n 'No URL selected. Pass --url or use --project with a crawl URL.',\n )\n }\n const report = await performanceAudit({\n url,\n strategy: strategy(args.strategy),\n lighthouseBin: stringArg(args['lighthouse-bin']),\n cruxApiKey: stringArg(args['crux-key']),\n refresh: booleanArg(args.refresh),\n includeRaw: json && booleanArg(args.raw),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Performance report',\n target: report.url,\n status:\n report.dataStatus === 'partial'\n ? 'unknown'\n : report.grade === 'good'\n ? 'pass'\n : 'warning',\n summary: report.headline,\n metrics: [\n { label: 'Source', value: report.source },\n { label: 'Strategy', value: report.strategy },\n {\n label: 'Lab score',\n value:\n report.score === undefined ? 'Unknown' : `${report.score}/100`,\n },\n { label: 'Lab grade', value: report.grade },\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'FCP',\n value: metric(report.metrics.firstContentfulPaint),\n },\n {\n label: 'LCP',\n value: metric(report.metrics.largestContentfulPaint),\n },\n { label: 'TBT', value: metric(report.metrics.totalBlockingTime) },\n {\n label: 'CLS',\n value: metric(report.metrics.cumulativeLayoutShift),\n },\n {\n label: 'INP',\n value: metric(report.metrics.interactionToNextPaint),\n },\n {\n label: 'Server response',\n value: metric(report.metrics.serverResponseTime),\n },\n {\n label: 'Fallback fetch',\n value: metric(report.metrics.fallbackFetchDuration),\n },\n {\n label: 'Field data',\n value: report.fieldData\n ? `${report.fieldData.scope} ${report.fieldData.formFactor.toLowerCase()} (${report.fieldData.assessment.status})`\n : report.fieldDataStatus.status,\n },\n {\n label: 'Field LCP p75',\n value: fieldMetric(\n report.fieldData?.metrics.largestContentfulPaint,\n ),\n },\n {\n label: 'Field INP p75',\n value: fieldMetric(\n report.fieldData?.metrics.interactionToNextPaint,\n ),\n },\n {\n label: 'Field CLS p75',\n value: fieldMetric(\n report.fieldData?.metrics.cumulativeLayoutShift,\n ),\n },\n {\n label: 'Field period',\n value:\n report.fieldData?.collectionPeriod?.firstDate &&\n report.fieldData.collectionPeriod.lastDate\n ? `${report.fieldData.collectionPeriod.firstDate} to ${report.fieldData.collectionPeriod.lastDate}`\n : 'Unavailable',\n },\n ],\n })\n printActionDetails(\n 'Top actions',\n report.topActions.map((action) => ({\n label: action.title,\n action: action.action,\n context: action.plainEnglish,\n })),\n )\n printNotes('Caveats', report.caveats)\n },\n }),\n },\n})\n","import { diagnoseProperty } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nexport const diagnoseCommand = defineCommand({\n meta: {\n name: 'diagnose',\n description: 'Find where Google Search performance changed',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Baseline window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n },\n ),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await diagnoseProperty({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n progress: createProgressReporter(!json),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'SEO diagnosis',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.priorities.length > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary:\n report.priorities.length > 0\n ? `${report.priorities.length} priorities need review.`\n : 'No priorities were returned by the available evidence.',\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Update overlap',\n value: report.summary.updateAttribution.replaceAll('-', ' '),\n },\n {\n label: 'Significant anomalies',\n value: report.summary.significantAnomalies,\n },\n { label: 'Update matches', value: report.summary.updateMatches },\n { label: 'Decay items', value: report.summary.decayItems },\n { label: 'Cannibal items', value: report.summary.cannibalItems },\n {\n label: 'Striking distance',\n value: report.summary.strikingDistanceItems,\n },\n { label: 'Quick wins', value: report.summary.quickWinItems },\n ],\n })\n printTable(\n ['Priority', 'Confidence', 'Reason', 'Action'],\n report.priorities.map((priority) => [\n priority.label,\n priority.confidence,\n priority.reason,\n priority.action,\n ]),\n )\n if (report.skippedSections?.length) {\n printTable(\n ['Skipped section', 'Reason'],\n report.skippedSections.map((section) => [\n section.section,\n section.reason,\n ]),\n )\n }\n printActionDetails(\n 'Priority action details',\n report.priorities.map((priority) => ({\n label: priority.label,\n context: priority.confidence,\n action: priority.action,\n })),\n )\n },\n})\n","import { runDoctor } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../../args.js'\nimport { checkSummary } from '../../presentation/views.js'\nimport { printChecks, printHeading, printJson } from '../../utils.js'\n\nexport const doctorCommand = defineCommand({\n meta: {\n name: 'doctor',\n description: 'Check local auth, scopes, config, and defaults',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const report = await runDoctor()\n if (jsonFlag(args)) {\n printJson(report)\n if (!report.ok) process.exitCode = 1\n return\n }\n printHeading('SEO doctor', checkSummary(report.checks))\n process.stdout.write('\\n')\n printChecks(report.checks)\n process.stdout.write(`\\nChecked ${report.generatedAt}\\n`)\n if (!report.ok) process.exitCode = 1\n },\n})\n","import { type SegmentDimension, segmentImpact } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n projectArg,\n strictNumberArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNotes, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\nconst segmentDimension = (value: unknown): SegmentDimension => {\n const dimension = stringArg(value) ?? 'page'\n if (\n dimension !== 'page' &&\n dimension !== 'query' &&\n dimension !== 'country' &&\n dimension !== 'device'\n ) {\n throw new Error('Invalid --dimension. Use page, query, country, or device.')\n }\n return dimension\n}\n\nexport const segmentImpactCommand = defineCommand({\n meta: {\n name: 'segment-impact',\n description: 'Compare GSC movement by page, query, device, or country',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n dimension: {\n type: 'string',\n default: 'page',\n description: 'Segment by page, query, country, or device.',\n },\n ...cliReportArgs(['days', 'limit', 'refresh'], {\n days: {\n description: 'Recent window length from 1 to 240 days. Defaults to 28.',\n },\n limit: {\n description: 'Maximum segment rows to print. Defaults to 25.',\n },\n refresh: {\n description: 'Bypass local cache and fetch fresh GSC data.',\n },\n }),\n compare: {\n type: 'string',\n description:\n 'Legacy 1-240 day comparison length. Must equal the current window.',\n },\n 'start-date': {\n type: 'string',\n description: 'Exact current-window start date in YYYY-MM-DD format.',\n },\n 'end-date': {\n type: 'string',\n description: 'Exact current-window end date in YYYY-MM-DD format.',\n },\n 'max-rows': {\n type: 'string',\n description: 'Maximum retained GSC rows per window. Defaults to 100000.',\n },\n 'unmatched-limit': {\n type: 'string',\n description:\n 'Maximum one-window evidence rows to return. Defaults to 25.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const dimension = segmentDimension(args.dimension)\n const days = strictNumberArg(args.days, '--days')\n const compareDays = strictNumberArg(args.compare, '--compare')\n const limit = strictNumberArg(args.limit, '--limit')\n const unmatchedLimit = strictNumberArg(\n args['unmatched-limit'],\n '--unmatched-limit',\n )\n const maxRows = strictNumberArg(args['max-rows'], '--max-rows')\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await segmentImpact({\n site: selection.site,\n dimension,\n days,\n compareDays,\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit,\n unmatchedLimit,\n maxRows,\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Segment impact',\n target: report.site,\n status: report.dataStatus === 'complete' ? 'info' : 'unknown',\n summary: report.summary.verdict,\n metrics: [\n { label: 'Dimension', value: report.dimension },\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Before',\n value: `${report.before.startDate} to ${report.before.endDate}`,\n },\n {\n label: 'After',\n value: `${report.after.startDate} to ${report.after.endDate}`,\n },\n ],\n })\n printTable(\n ['Segment', 'Clicks before', 'Clicks after', 'Delta', 'Pos delta'],\n report.items.map((item) => [\n item.key,\n item.beforeClicks,\n item.afterClicks,\n item.clickDelta,\n item.positionDelta ?? '-',\n ]),\n )\n if (report.unmatchedSegments.length) {\n process.stdout.write('\\nOne-window evidence (not treated as zero)\\n')\n printTable(\n ['Segment', 'Retained in', 'Clicks', 'Impressions'],\n report.unmatchedSegments.map((item) => [\n item.key,\n item.retainedIn,\n item.clicks,\n item.impressions,\n ]),\n )\n }\n printNotes('Warnings', report.warnings)\n },\n})\n","import { strikingDistance } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n fetchRateArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printActionDetails,\n printLimitedTable,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { formatContentCheck, formatFetchDiagnostics } from '../shared.js'\n\nfunction rowCountLabel(count: number): string {\n return `${formatCount(count)} ${count === 1 ? 'row' : 'rows'}`\n}\n\nexport const strikingDistanceCommand = defineCommand({\n meta: {\n name: 'striking-distance',\n description: 'Find query/page rows averaging positions above 10 through 20',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs([\n 'days',\n 'minImpressions',\n 'limit',\n 'includeBrand',\n 'verifyContent',\n 'verifyLimit',\n 'js',\n 'fetchConcurrency',\n 'fetchIntervalCap',\n 'fetchIntervalMs',\n 'refresh',\n ]),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const verifyLimit = numberArg(args['verify-limit'])\n const verifyContent =\n booleanArg(args['verify-content']) === true || verifyLimit !== undefined\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await strikingDistance({\n site: selection.site,\n days: numberArg(args.days),\n minImpressions: numberArg(args['min-impressions']),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n verifyContent,\n verifyLimit,\n js: booleanArg(args.js) ? true : undefined,\n rate: fetchRateArg(args),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Striking-distance opportunities',\n target: report.site,\n status: report.source.possiblyTruncated ? 'unknown' : 'info',\n summary: report.summary.verdict,\n metrics: [\n {\n label: 'Eligible rows',\n value: formatCount(report.summary.eligibleRows),\n },\n {\n label: 'Returned rows',\n value: formatCount(report.summary.returnedRows),\n },\n { label: 'Template groups', value: formatCount(report.summary.groups) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.eligibleImpressions),\n },\n { label: 'Brand queries', value: report.summary.brandFiltering },\n {\n label: 'Verification',\n value: report.verification.requested ? 'Requested' : 'Off',\n },\n { label: 'Evidence', value: report.dataStatus },\n ],\n })\n printNotes('Why this matters', [\n 'These rows have a GSC average position above 10 and at most 20. Treat them as candidates for investigation, not guaranteed page-two rankings.',\n 'Groups use all eligible rows. A shared-template label is only a candidate until recurring evidence is verified across distinct URLs.',\n ])\n printNotes('Recommended actions', report.recommendations)\n printNotes('Report caveats', report.caveats)\n\n if (report.groups.length) {\n printLimitedTable(\n ['Group', 'Rows', 'URLs', 'Impr', 'Avg pos', 'Scope', 'Action'],\n report.groups.map((group) => [\n truncate(group.label, 36),\n formatCount(group.rowCount),\n formatCount(group.uniqueUrls),\n formatCount(group.totalImpressions),\n formatPosition(group.impressionWeightedPosition),\n group.actionScope,\n truncate(group.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top striking-distance group actions',\n report.groups.map((group) => ({\n label: group.label,\n context: `${rowCountLabel(group.rowCount)}, ${formatCount(group.totalImpressions)} impressions`,\n action: group.recommendation.action,\n })),\n )\n }\n\n if (!report.items.length) {\n process.stdout.write(\n 'No striking-distance opportunities matched these filters.\\n',\n )\n return\n }\n\n printLimitedTable(\n [\n 'Query',\n 'Template',\n 'URL',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Score',\n 'Fetch',\n 'Check',\n 'Action',\n ],\n report.items.map((item) => [\n truncate(item.query, 36),\n truncate(item.template.label, 24),\n truncate(item.url, 48),\n formatCount(item.impressions),\n formatPercent(item.ctr),\n formatPosition(item.position),\n item.priority.score,\n formatFetchDiagnostics(item.contentVerification?.fetchDiagnostics),\n formatContentCheck(item.contentVerification?.classification),\n truncate(item.recommendation.action, 72),\n ]),\n )\n printActionDetails(\n 'Top striking-distance actions',\n report.items.map((item) => ({\n label: item.query,\n context: `${item.template.label}, pos ${formatPosition(item.position)}, ${formatCount(item.impressions)} impressions`,\n action: item.recommendation.action,\n })),\n )\n },\n})\n","import { intro, note, outro, password, select } from '@clack/prompts'\nimport {\n BING_API_KEY_ENV,\n BING_API_KEY_SECRET,\n BingWebmasterClient,\n type BingWebmasterSite,\n bingWebmasterOverview,\n bingWebmasterSiteUrl,\n createBingWebmasterClient,\n deleteProviderSecret,\n readProviderSecret,\n SeoError,\n setClientBingSite,\n writeProviderSecret,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, projectArg, stringArg } from '../../args.js'\nimport { resolveClient } from '../../selection.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n printTable,\n} from '../../utils.js'\nimport { printReportSummary } from '../output.js'\n\nfunction verifiedSites(sites: BingWebmasterSite[]): BingWebmasterSite[] {\n return sites.filter((site) => site.isVerified)\n}\n\nfunction host(value: string): string | undefined {\n if (value.startsWith('sc-domain:')) {\n return value\n .slice('sc-domain:'.length)\n .replace(/^www\\./, '')\n .toLowerCase()\n }\n try {\n return new URL(value).hostname.replace(/^www\\./, '').toLowerCase()\n } catch {\n return undefined\n }\n}\n\nexport function matchBingSite(\n projectSite: string,\n sites: BingWebmasterSite[],\n): BingWebmasterSite | undefined {\n const projectHost = host(projectSite)\n if (!projectHost) return undefined\n const matches = verifiedSites(sites).filter(\n (site) => host(site.url) === projectHost,\n )\n return matches.length === 1 ? matches[0] : undefined\n}\n\nasync function chooseSite(input: {\n explicitSite?: string\n projectSite?: string\n savedSite?: string\n sites: BingWebmasterSite[]\n json?: boolean\n}): Promise<string | undefined> {\n const verified = verifiedSites(input.sites)\n const explicit = input.explicitSite ?? input.savedSite\n if (explicit) {\n const match = verified.find((site) => site.url === explicit)\n if (!match) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n `Bing Webmaster did not return a verified site matching ${explicit}.`,\n )\n }\n return match.url\n }\n const matched = input.projectSite\n ? matchBingSite(input.projectSite, verified)\n : undefined\n if (matched) return matched.url\n if (verified.length === 1) return verified[0]?.url\n if (verified.length === 0) return undefined\n if (!canPrompt({ json: input.json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Several verified Bing sites are available. Pass --site to choose one.',\n )\n }\n return maybeExitCancelled(\n await select({\n message: 'Choose a verified Bing Webmaster site',\n options: verified.map((site) => ({ value: site.url, label: site.url })),\n }),\n )\n}\n\nconst selectionArgs = {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n site: { type: 'string', description: 'Verified Bing Webmaster site URL.' },\n} as const\n\nconst connectCommand = defineCommand({\n meta: {\n name: 'connect',\n description: 'Connect Bing Webmaster and attach a verified site',\n },\n args: {\n ...selectionArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n if (!canPrompt({ json })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n 'Run `seo providers bing connect` in a terminal. Agents and CI can set SEO_BING_API_KEY and run the report directly.',\n )\n }\n\n intro('Connect Bing Webmaster')\n note(\n 'Paste the API key from Bing Webmaster Tools Settings, then API Access. The key stays on this machine.',\n 'API key',\n )\n const apiKey = maybeExitCancelled(\n await password({\n message: 'Bing Webmaster API key',\n validate: (value) =>\n value?.trim() ? undefined : 'API key is required',\n }),\n )\n const client = new BingWebmasterClient({ apiKey })\n const discovered = await client.listSites()\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = await chooseSite({\n explicitSite: stringArg(args.site),\n projectSite: project?.siteUrl,\n savedSite: bingWebmasterSiteUrl(project),\n sites: discovered.sites,\n json,\n })\n if (!site) {\n throw new SeoError(\n 'PROPERTY_NOT_FOUND',\n 'No verified Bing Webmaster sites were found for this API key.',\n )\n }\n\n await writeProviderSecret(BING_API_KEY_SECRET, apiKey)\n const savedProject = project\n ? setClientBingSite(project.id, site)\n : undefined\n note(\n `${site}${savedProject ? ` is attached to ${savedProject.name}.` : ' is ready for direct reports.'}`,\n 'Bing connected',\n )\n outro(\n savedProject\n ? `Run seo providers bing report --project ${savedProject.id}`\n : `Run seo providers bing report --site ${site}`,\n )\n },\n})\n\nconst statusCommand = defineCommand({\n meta: { name: 'status', description: 'Show the local Bing connection' },\n args: {\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const credential = await readProviderSecret({\n name: BING_API_KEY_SECRET,\n envVar: BING_API_KEY_ENV,\n })\n const project = await resolveClient({\n project: projectArg(args),\n options: { json: jsonFlag(args) },\n })\n const status = {\n connected: Boolean(credential),\n credentialSource: credential?.source,\n project: project\n ? {\n id: project.id,\n name: project.name,\n site: bingWebmasterSiteUrl(project),\n }\n : undefined,\n }\n if (jsonFlag(args)) {\n printJson(status)\n return\n }\n printKeyValue([\n ['Connected', status.connected ? 'yes' : 'no'],\n ['Credential', status.credentialSource ?? 'missing'],\n ['Project', status.project?.name ?? 'not selected'],\n ['Bing site', status.project?.site ?? 'not attached'],\n ])\n },\n})\n\nconst disconnectCommand = defineCommand({\n meta: {\n name: 'disconnect',\n description: 'Remove the saved Bing Webmaster credential',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n await deleteProviderSecret(BING_API_KEY_SECRET)\n const result = {\n disconnected: true,\n note: 'Saved project site mappings were kept for a later reconnect.',\n }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`${result.note}\\n`)\n },\n})\n\nconst sitesCommand = defineCommand({\n meta: { name: 'sites', description: 'List Bing Webmaster sites' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const { client, credentialSource } = await createBingWebmasterClient()\n const result = await client.listSites()\n const output = { ...result, credentialSource }\n if (jsonFlag(args)) {\n printJson(output)\n return\n }\n printTable(\n ['Site', 'Verified'],\n result.sites.map((site) => [site.url, site.isVerified ? 'yes' : 'no']),\n )\n },\n})\n\nconst reportCommand = defineCommand({\n meta: {\n name: 'report',\n description: 'Find Bing traffic, crawl, query, and page insights',\n },\n args: {\n ...selectionArgs,\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = await resolveClient({\n project: projectArg(args),\n options: { json },\n })\n const site = stringArg(args.site) ?? bingWebmasterSiteUrl(project)\n if (!site) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass --site or connect Bing Webmaster to a saved project first.',\n )\n }\n const report = await bingWebmasterOverview({ site })\n if (json) {\n printJson(report)\n return\n }\n const traffic =\n report.traffic.status === 'unavailable' ? undefined : report.traffic.data\n const crawl =\n report.crawl.status === 'unavailable' ? undefined : report.crawl.data\n const comparison = traffic?.analysis\n printReportSummary({\n title: 'Bing Webmaster report',\n target: report.site,\n status:\n report.dataStatus === 'complete'\n ? report.summary.warnings > 0\n ? 'warning'\n : 'pass'\n : 'unknown',\n summary:\n report.summary.findings > 0\n ? `${report.summary.findings} findings need review across Bing traffic and crawl evidence.`\n : 'No findings were returned by the available Bing evidence.',\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: '28-day clicks',\n value: comparison?.current.clicks ?? 'Unavailable',\n },\n {\n label: 'Click change',\n value:\n comparison?.changes.clicksPercent === null ||\n comparison?.changes.clicksPercent === undefined\n ? 'Unavailable'\n : `${comparison.changes.clicksPercent.toFixed(1)}%`,\n },\n {\n label: '28-day impressions',\n value: comparison?.current.impressions ?? 'Unavailable',\n },\n {\n label: 'Impression change',\n value:\n comparison?.changes.impressionsPercent === null ||\n comparison?.changes.impressionsPercent === undefined\n ? 'Unavailable'\n : `${comparison.changes.impressionsPercent.toFixed(1)}%`,\n },\n {\n label: 'Crawled pages',\n value: crawl?.latest?.crawledPages ?? 'Unavailable',\n },\n {\n label: '4xx responses',\n value: crawl?.latest?.code4xx ?? 'Unavailable',\n },\n { label: 'Findings', value: report.summary.findings },\n ],\n diagnostics: [\n {\n title: 'Review first',\n items: report.findings.slice(0, 5).map((finding) => ({\n status: finding.severity === 'warning' ? 'warning' : 'info',\n title: finding.title,\n explanation: finding.interpretation,\n evidence: [finding.verification],\n })),\n },\n ],\n notes: report.caveats,\n })\n },\n})\n\nexport const bingProviderCommand = defineCommand({\n meta: { name: 'bing', description: 'Connect and report on Bing Webmaster' },\n subCommands: {\n connect: connectCommand,\n status: statusCommand,\n disconnect: disconnectCommand,\n sites: sitesCommand,\n report: reportCommand,\n },\n})\n","import { intro, note, outro, password, text } from '@clack/prompts'\nimport {\n DATAFORSEO_LOGIN_ENV,\n DATAFORSEO_PASSWORD_ENV,\n DataForSeoClient,\n deleteDataForSeoCredentials,\n getProviderSpendLimits,\n getProviderSpendSummary,\n readDataForSeoCredentials,\n SeoError,\n setProviderSpendLimits,\n writeDataForSeoCredentials,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n stringArg,\n} from '../../args.js'\nimport {\n canPrompt,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n} from '../../utils.js'\n\nfunction credentialSourceLabel(\n source: 'environment' | 'keychain' | 'file' | undefined,\n): string {\n if (source === 'keychain') return 'system keychain'\n if (source === 'file') return 'private local file'\n return source ?? 'missing'\n}\n\nfunction formatUsd(micros: number | null): string {\n return micros === null ? 'unavailable' : `$${(micros / 1_000_000).toFixed(2)}`\n}\n\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options: { notice: true },\n): number | undefined\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options?: { notice?: false },\n): number | null | undefined\nfunction usdMicrosArg(\n value: unknown,\n label: string,\n options: { notice?: boolean } = {},\n): number | null | undefined {\n if (value === undefined) return undefined\n const raw = stringArg(value)?.trim().toLowerCase()\n if (raw === 'off') return options.notice ? 0 : null\n const dollars = numberArg(value)\n if (dollars === undefined || dollars < 0 || dollars > 1_000_000) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label} must be a USD amount from 0 to 1000000, or off.`,\n )\n }\n const micros = Math.round(dollars * 1_000_000)\n if (!Number.isSafeInteger(micros)) {\n throw new SeoError('INVALID_INPUT', `${label} is too precise.`)\n }\n return micros\n}\n\nfunction boundedIntegerArg(\n value: unknown,\n label: string,\n minimum: number,\n maximum: number,\n): number | undefined {\n if (value === undefined) return undefined\n const parsed = numberArg(value)\n if (\n parsed === undefined ||\n !Number.isInteger(parsed) ||\n parsed < minimum ||\n parsed > maximum\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label} must be an integer from ${minimum} to ${maximum}.`,\n )\n }\n return parsed\n}\n\nconst connectCommand = defineCommand({\n meta: {\n name: 'connect',\n description: 'Validate and save DataForSEO API credentials',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n if (!canPrompt({ json: jsonFlag(args) })) {\n throw new SeoError(\n 'AUTH_REQUIRED',\n `Run \\`seo providers dataforseo connect\\` in a terminal. Agents and CI can set ${DATAFORSEO_LOGIN_ENV} and ${DATAFORSEO_PASSWORD_ENV}.`,\n )\n }\n\n intro('Connect DataForSEO')\n note(\n 'Use the API login and API password from DataForSEO API Access. The validation call is free; later research reports can make charged requests.',\n 'API credentials',\n )\n const login = maybeExitCancelled(\n await text({\n message: 'DataForSEO API login',\n validate: (value) =>\n value?.trim() ? undefined : 'API login is required',\n }),\n )\n const apiPassword = maybeExitCancelled(\n await password({\n message: 'DataForSEO API password',\n validate: (value) => (value ? undefined : 'API password is required'),\n }),\n )\n const credentials = { login: login.trim(), password: apiPassword }\n const account = await new DataForSeoClient({\n credentials: () => credentials,\n }).userData()\n const source = await writeDataForSeoCredentials(credentials)\n\n note(\n `${account.login} is connected with an account balance of ${formatUsd(account.balanceMicros)}.`,\n 'Connection verified',\n )\n outro(\n `Saved in the ${credentialSourceLabel(source)}. Run seo providers dataforseo status --check to verify it again.`,\n )\n },\n})\n\nconst statusCommand = defineCommand({\n meta: {\n name: 'status',\n description: 'Show the local DataForSEO connection',\n },\n args: {\n check: {\n type: 'boolean',\n default: false,\n description: 'Verify credentials with the free account endpoint.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const credentials = await readDataForSeoCredentials()\n const shouldCheck = Boolean(args.check)\n const account =\n shouldCheck && credentials\n ? await new DataForSeoClient().userData()\n : undefined\n const result = {\n connected: Boolean(credentials),\n credentialSource: credentials?.source,\n migratedLegacyCredentials: credentials?.migrated ?? false,\n liveCheck: account\n ? {\n status: 'passed' as const,\n account: account.login,\n timezone: account.timezone,\n balanceMicros: account.balanceMicros,\n observedAt: account.observedAt,\n requestCostMicros: account.requestCostMicros,\n }\n : {\n status: (shouldCheck ? 'unavailable' : 'not-requested') as\n | 'unavailable'\n | 'not-requested',\n },\n }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n ['Connected', result.connected ? 'yes' : 'no'],\n ['Credential', credentialSourceLabel(result.credentialSource)],\n [\n 'Live check',\n result.liveCheck.status === 'passed'\n ? `passed at ${result.liveCheck.observedAt}`\n : result.liveCheck.status === 'unavailable'\n ? 'not available without credentials'\n : 'not requested; pass --check to verify',\n ],\n ...(account\n ? ([\n ['Account', account.login],\n ['Balance', formatUsd(account.balanceMicros)],\n ] satisfies Array<[string, string]>)\n : []),\n ])\n },\n})\n\nconst disconnectCommand = defineCommand({\n meta: {\n name: 'disconnect',\n description: 'Remove saved DataForSEO credentials',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n await deleteDataForSeoCredentials()\n const hasEnvironmentLogin = Boolean(\n process.env[DATAFORSEO_LOGIN_ENV]?.trim(),\n )\n const hasEnvironmentPassword = Boolean(process.env[DATAFORSEO_PASSWORD_ENV])\n const result = {\n savedCredentialsRemoved: true,\n environmentCredentials:\n hasEnvironmentLogin && hasEnvironmentPassword\n ? ('active' as const)\n : hasEnvironmentLogin || hasEnvironmentPassword\n ? ('partial' as const)\n : ('missing' as const),\n note:\n hasEnvironmentLogin || hasEnvironmentPassword\n ? `Environment variables were not changed. Clear ${DATAFORSEO_LOGIN_ENV} and ${DATAFORSEO_PASSWORD_ENV} to fully disconnect.`\n : 'DataForSEO is disconnected.',\n }\n if (jsonFlag(args)) printJson(result)\n else process.stdout.write(`${result.note}\\n`)\n },\n})\n\nconst limitsCommand = defineCommand({\n meta: {\n name: 'limits',\n description: 'Show or change local DataForSEO spend limits',\n },\n args: {\n 'daily-notice': {\n type: 'string',\n description: 'UTC daily notice in USD, or off.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'UTC daily hard limit in USD, or off.',\n },\n 'monthly-limit': {\n type: 'string',\n description: 'UTC monthly hard limit in USD, or off.',\n },\n requests: {\n type: 'string',\n description: 'Maximum provider requests in one report run.',\n },\n rows: {\n type: 'string',\n description: 'Maximum requested provider rows in one report run.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const current = getProviderSpendLimits('dataforseo')\n const dailyNoticeMicros = usdMicrosArg(\n args['daily-notice'],\n '--daily-notice',\n { notice: true },\n )\n const dailyHardLimitMicros = usdMicrosArg(\n args['daily-limit'],\n '--daily-limit',\n )\n const monthlyHardLimitMicros = usdMicrosArg(\n args['monthly-limit'],\n '--monthly-limit',\n )\n const maxRequestsPerReport = boundedIntegerArg(\n args.requests,\n '--requests',\n 1,\n 100,\n )\n const maxRowsPerReport = boundedIntegerArg(args.rows, '--rows', 1, 100_000)\n const changed = [\n dailyNoticeMicros,\n dailyHardLimitMicros,\n monthlyHardLimitMicros,\n maxRequestsPerReport,\n maxRowsPerReport,\n ].some((value) => value !== undefined)\n const limits = changed\n ? setProviderSpendLimits('dataforseo', {\n dailyNoticeMicros:\n dailyNoticeMicros === undefined\n ? current.dailyNoticeMicros\n : dailyNoticeMicros,\n dailyHardLimitMicros:\n dailyHardLimitMicros === undefined\n ? current.dailyHardLimitMicros\n : dailyHardLimitMicros,\n monthlyHardLimitMicros:\n monthlyHardLimitMicros === undefined\n ? current.monthlyHardLimitMicros\n : monthlyHardLimitMicros,\n maxRequestsPerReport:\n maxRequestsPerReport ?? current.maxRequestsPerReport,\n maxRowsPerReport: maxRowsPerReport ?? current.maxRowsPerReport,\n })\n : current\n const result = { provider: 'dataforseo' as const, changed, limits }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n [\n 'UTC daily notice',\n limits.dailyNoticeMicros === 0\n ? 'off'\n : formatUsd(limits.dailyNoticeMicros),\n ],\n [\n 'UTC daily hard limit',\n limits.dailyHardLimitMicros === null\n ? 'off'\n : formatUsd(limits.dailyHardLimitMicros),\n ],\n [\n 'UTC monthly hard limit',\n limits.monthlyHardLimitMicros === null\n ? 'off'\n : formatUsd(limits.monthlyHardLimitMicros),\n ],\n ['Requests per report', String(limits.maxRequestsPerReport)],\n ['Rows per report', String(limits.maxRowsPerReport)],\n ])\n },\n})\n\nconst spendCommand = defineCommand({\n meta: {\n name: 'spend',\n description: 'Show local DataForSEO spend and account context',\n },\n args: {\n account: defaultTrueBooleanArg(\n 'Read account-wide context from the free endpoint.',\n 'Show only the local spend ledger.',\n ),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const local = getProviderSpendSummary('dataforseo')\n const credentials = args.account\n ? await readDataForSeoCredentials()\n : undefined\n let account:\n | {\n status: 'observed'\n account: string\n balanceMicros: number | null\n dailySpendMicros: number | null\n dailySpendPeriod: string | null\n dailyLimitMicros: number | null\n observedAt: string\n requestCostMicros: number\n semantics: string\n }\n | { status: 'unavailable'; reason: string }\n | { status: 'not-requested' }\n if (!args.account) {\n account = { status: 'not-requested' }\n } else if (!credentials) {\n account = {\n status: 'unavailable',\n reason:\n 'DataForSEO is not connected. Local spend remains available without account context.',\n }\n } else {\n try {\n const snapshot = await new DataForSeoClient().userData()\n account = {\n status: 'observed',\n account: snapshot.login,\n balanceMicros: snapshot.balanceMicros,\n dailySpendMicros: snapshot.accountDailySpendMicros,\n dailySpendPeriod: snapshot.accountDailySpendPeriod,\n dailyLimitMicros: snapshot.accountDailyLimitMicros,\n observedAt: snapshot.observedAt,\n requestCostMicros: snapshot.requestCostMicros,\n semantics:\n 'Account values include every client using these credentials. Local values include only requests recorded by this installation.',\n }\n } catch (error) {\n account = {\n status: 'unavailable',\n reason:\n error instanceof Error\n ? error.message\n : 'DataForSEO account context is unavailable.',\n }\n }\n }\n const result = { local, account }\n if (jsonFlag(args)) {\n printJson(result)\n return\n }\n printKeyValue([\n [\n 'Local today (UTC)',\n `${formatUsd(local.today.effectiveCostMicros)} across ${local.today.requests} requests`,\n ],\n [\n 'Local month (UTC)',\n `${formatUsd(local.month.effectiveCostMicros)} across ${local.month.requests} requests`,\n ],\n [\n 'Unknown local cost',\n formatUsd(local.month.estimatedOrUnknownCostMicros),\n ],\n [\n 'Account today',\n account.status === 'observed'\n ? formatUsd(account.dailySpendMicros)\n : account.status === 'unavailable'\n ? account.reason\n : 'not requested',\n ],\n [\n 'Account balance',\n account.status === 'observed'\n ? formatUsd(account.balanceMicros)\n : 'unavailable',\n ],\n ])\n if (account.status === 'observed')\n process.stdout.write(`${account.semantics}\\n`)\n },\n})\n\nexport const dataForSeoProviderCommand = defineCommand({\n meta: {\n name: 'dataforseo',\n description: 'Connect DataForSEO for optional search data',\n },\n subCommands: {\n connect: connectCommand,\n status: statusCommand,\n limits: limitsCommand,\n spend: spendCommand,\n disconnect: disconnectCommand,\n },\n})\n","import { defineCommand } from 'citty'\nimport { bingProviderCommand } from './bing.js'\nimport { dataForSeoProviderCommand } from './dataforseo.js'\n\nexport const providersCommand = defineCommand({\n meta: { name: 'providers', description: 'Connect optional data providers' },\n subCommands: {\n bing: bingProviderCommand,\n dataforseo: dataForSeoProviderCommand,\n },\n})\n","import { countLabel, pseoAuditReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, projectArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport {\n formatCount,\n formatPercent,\n formatPosition,\n printLimitedTable,\n printNextCommand,\n printNotes,\n printReportSummary,\n truncate,\n} from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { pseoOptions } from './options.js'\n\nfunction formatInspection(input: {\n indexed: number\n notIndexed: number\n unknown: number\n warnings: number\n}): string {\n const total =\n input.indexed + input.notIndexed + input.unknown + input.warnings\n if (!total) return '-'\n return `${input.indexed}/${total} indexed`\n}\n\nfunction formatCrawl(input: {\n samples: unknown[]\n blockedOrFailed: number\n usable: number\n medianWordCount?: number\n weakQueryCoverage?: number\n}): string {\n if (!input.samples.length) return '-'\n const words =\n input.medianWordCount === undefined\n ? 'words ?'\n : `${formatCount(input.medianWordCount)} words`\n const weak = input.weakQueryCoverage\n ? `; ${input.weakQueryCoverage} weak coverage`\n : ''\n return `${words}; ${input.usable}/${input.samples.length} usable${weak}`\n}\n\nfunction formatCoverage(classification: string): string {\n if (classification === 'serp-framing-review') return 'wording review'\n if (classification === 'body-term-review') return 'literal term review'\n return 'covered terms'\n}\n\nfunction formatTemplateShape(\n shape: Awaited<\n ReturnType<typeof pseoAuditReport>\n >['templates'][number]['shape'],\n): string {\n const staticPath = shape.staticSegments\n .map((segment) => `/${segment.value}`)\n .join('')\n const variables = shape.variableSegments.slice(0, 3).map((segment) => {\n const examples = segment.examples.slice(0, 3).join(', ')\n return `${segment.placeholder}@${segment.index + 1}${examples ? ` (${examples})` : ''}`\n })\n return [\n staticPath ? `static ${staticPath}` : 'no fixed path prefix',\n variables.length ? `variables ${variables.join('; ')}` : 'no variables',\n ].join('; ')\n}\n\nfunction formatEntityFit(\n fit: Awaited<\n ReturnType<typeof pseoAuditReport>\n >['templates'][number]['metrics']['entityFit'],\n): string | undefined {\n if (!fit.checkedQueries) return undefined\n return `${Math.round(fit.impressionShare * 100)}% impression fit across ${countLabel(fit.checkedQueries, 'checked query/page row')}`\n}\n\nfunction formatDemandLabel(label: string): string {\n if (label.startsWith('theme: ')) {\n return `${label.slice('theme: '.length)}-related`\n }\n if (label === 'general') return 'broad'\n return label\n}\n\nfunction printTemplateDetails(\n templates: Awaited<ReturnType<typeof pseoAuditReport>>['templates'],\n): void {\n for (const template of templates.slice(0, 5)) {\n process.stdout.write(`\\n${template.signature}\\n`)\n if (template.evidence.length) {\n process.stdout.write(` Evidence: ${template.evidence.join('; ')}.\\n`)\n }\n process.stdout.write(` Shape: ${formatTemplateShape(template.shape)}\\n`)\n const entityFit = formatEntityFit(template.metrics.entityFit)\n if (entityFit) {\n process.stdout.write(` Entity fit: ${entityFit}\\n`)\n }\n const patterns = template.metrics.queryPatterns\n .slice(0, 3)\n .map(\n (pattern) =>\n `${formatDemandLabel(pattern.label)} (${formatCount(pattern.impressions)} impr: ${pattern.examples\n .slice(0, 2)\n .join('; ')})`,\n )\n if (patterns.length) {\n process.stdout.write(` Demand: ${patterns.join(' | ')}\\n`)\n }\n const topQueries = template.metrics.topQueries.slice(0, 3)\n if (topQueries.length) {\n process.stdout.write(' Top queries:\\n')\n for (const query of topQueries) {\n process.stdout.write(\n ` - ${truncate(query.query, 72)} (${formatCount(query.impressions)} impr, pos ${formatPosition(query.position)})\\n`,\n )\n }\n }\n const coverage = template.crawl.samples\n .map((sample) => sample.queryCoverage)\n .filter((item): item is NonNullable<typeof item> => Boolean(item))\n .slice(0, 3)\n if (coverage.length) {\n process.stdout.write(' Sample coverage:\\n')\n for (const item of coverage) {\n const missing = item.missingTerms.length\n ? ` missing ${item.missingTerms.slice(0, 4).join(', ')}`\n : ''\n process.stdout.write(\n ` - ${formatCoverage(item.classification)}: ${truncate(item.query, 64)} (body ${(item.bodyCoverage * 100).toFixed(0)}%${missing})\\n`,\n )\n }\n }\n const weakEntityExamples = template.metrics.entityFit.weakExamples.slice(\n 0,\n 2,\n )\n if (weakEntityExamples.length) {\n process.stdout.write(' Weak entity-fit examples:\\n')\n for (const item of weakEntityExamples) {\n const terms = item.pathTerms.slice(0, 4)\n process.stdout.write(\n ` - ${truncate(item.query, 64)} -> expected ${countLabel(terms.length, 'path term')}: ${terms.join(', ')}\\n`,\n )\n }\n }\n process.stdout.write(` Action: ${template.recommendation}\\n`)\n }\n}\n\nexport const pseoAuditCommand = defineCommand({\n meta: {\n name: 'audit',\n description:\n 'Group GSC/sitemap URLs into pSEO templates, then sample pages for crawl and index evidence',\n },\n args: {\n site: { type: 'string' },\n project: { type: 'string', description: 'Saved project id or name.' },\n client: { type: 'string', description: 'Legacy alias for --project.' },\n ...cliReportArgs(['days', 'limit', 'includeBrand', 'js', 'refresh'], {\n limit: {\n description: 'Maximum templates to show. Defaults to 25.',\n },\n includeBrand: {\n description: 'Include branded queries in template metrics.',\n },\n js: {\n description: 'Force JavaScript rendering for crawl samples.',\n },\n refresh: {\n description: 'Bypass local GSC and HTTP cache.',\n },\n }),\n sitemap: {\n type: 'string',\n description:\n 'Comma-separated sitemap URLs to include in template counts.',\n },\n 'crawl-samples': {\n type: 'string',\n description:\n 'Sample URLs to fetch per detected template. This is not crawl depth.',\n },\n 'inspect-samples': {\n type: 'string',\n description:\n 'Sample URLs to check per detected template with URL Inspection.',\n },\n 'max-sitemap-urls': {\n type: 'string',\n description: 'Maximum discovered URLs per sitemap. Defaults to 50000.',\n },\n 'minimum-template-urls': {\n type: 'string',\n description:\n 'Minimum repeated URLs required for a template. Defaults to 3.',\n },\n 'minimum-template-share': {\n type: 'string',\n description:\n 'Minimum share of discovered URLs from 0 to 1. Defaults to 0.',\n },\n 'minimum-template-impressions': {\n type: 'string',\n description:\n 'Minimum retained page impressions for a template. Defaults to 0.',\n },\n 'brand-terms': {\n type: 'string',\n description:\n 'Comma-separated brand terms to exclude from query evidence.',\n },\n 'fetch-concurrency': {\n type: 'string',\n description: 'Maximum concurrent page fetches per host. Defaults to 4.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host. Defaults to 4.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds. Defaults to 1000.',\n },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const options = pseoOptions(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await pseoAuditReport({\n site: selection.site,\n ...options,\n brandTerms: options.brandTerms ?? selection.client?.brandTerms,\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printReportSummary({\n title: 'Programmatic SEO audit',\n target: report.site,\n status: report.templates.length > 0 ? 'info' : 'unknown',\n summary:\n report.templates.length > 0\n ? `${formatCount(report.summary.templates)} page templates were analysed.`\n : 'No page templates could be established from the available evidence.',\n metrics: [\n { label: 'Templates', value: formatCount(report.summary.templates) },\n { label: 'GSC pages', value: formatCount(report.summary.gscPages) },\n {\n label: 'Sitemap URLs',\n value: formatCount(report.summary.sitemapUrls),\n },\n { label: 'Clicks', value: formatCount(report.summary.clicks) },\n {\n label: 'Impressions',\n value: formatCount(report.summary.impressions),\n },\n {\n label: 'Usable crawls',\n value: `${formatCount(report.summary.crawledUrls)}/${formatCount(report.summary.crawlAttempts)}`,\n },\n {\n label: 'Inspections',\n value: `${formatCount(report.summary.inspectedUrls)}/${formatCount(report.summary.inspectionAttempts)}`,\n },\n ],\n })\n printNotes('Report caveats', report.caveats)\n\n if (!report.templates.length) {\n process.stdout.write('No pSEO templates found from GSC/sitemap data.\\n')\n return\n }\n\n printLimitedTable(\n [\n 'Verdict',\n 'Template',\n 'URLs',\n 'Clicks',\n 'Impr',\n 'CTR',\n 'Pos',\n 'Index',\n 'Crawl',\n 'Action',\n ],\n report.templates.map((template) => [\n `${template.verdict} (${template.confidence})`,\n truncate(template.signature, 28),\n formatCount(template.urlCount),\n formatCount(template.metrics.clicks),\n formatCount(template.metrics.impressions),\n formatPercent(template.metrics.ctr),\n template.metrics.position.toFixed(1),\n formatInspection(template.inspection),\n formatCrawl(template.crawl),\n truncate(template.recommendation, 72),\n ]),\n )\n\n printTemplateDetails(report.templates)\n\n if (report.warnings.length) {\n process.stdout.write(`Warnings: ${report.warnings.join('; ')}\\n`)\n }\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n printNextCommand(`seo export pseo ${target}`)\n },\n})\n","import { defineCommand } from 'citty'\nimport { pseoAuditCommand } from './audit.js'\n\nexport const pseoCommand = defineCommand({\n meta: {\n name: 'pseo',\n description:\n 'Programmatic SEO audits that cluster URL patterns and sample template pages',\n },\n subCommands: {\n audit: pseoAuditCommand,\n },\n})\n","import { readFile } from 'node:fs/promises'\nimport { SeoError, type SeoErrorCode } from '@seo/core'\nimport {\n describeReport,\n describeReportCheck,\n executeReport,\n listReports,\n REPORT_CATEGORIES,\n type ReportCategory,\n} from '@seo/mcp'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printBulletSection,\n printCallout,\n printCatalog,\n printHeading,\n printJson,\n printKeyValue,\n printParameters,\n printSection,\n} from '../utils.js'\n\nconst CATEGORY_LABELS: Record<ReportCategory, string> = {\n 'ai-search': 'AI search',\n crawl: 'Crawling and technical checks',\n diagnosis: 'Diagnosis',\n experiments: 'Experiments',\n monitoring: 'Monitoring',\n opportunities: 'Opportunities',\n reporting: 'Reporting',\n setup: 'Setup',\n workflows: 'Workflows',\n}\n\nfunction categoryArg(value: unknown): ReportCategory | undefined {\n const category = stringArg(value)\n if (!category) return undefined\n if (!REPORT_CATEGORIES.includes(category as ReportCategory)) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Unknown report category: ${category}. Choose ${REPORT_CATEGORIES.join(', ')}.`,\n )\n }\n return category as ReportCategory\n}\n\nasync function paramsArg(\n inlineValue: unknown,\n fileValue: unknown,\n): Promise<Record<string, unknown>> {\n const inline = stringArg(inlineValue)\n const file = stringArg(fileValue)\n if (inline && file) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --params or --params-file, not both.',\n )\n }\n if (!inline && !file) return {}\n\n const source = inline ?? (await readFile(file ?? '', 'utf8'))\n let parsed: unknown\n try {\n parsed = JSON.parse(source)\n } catch {\n throw new SeoError('INVALID_INPUT', 'Report parameters must be valid JSON.')\n }\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new SeoError('INVALID_INPUT', 'Report parameters must be an object.')\n }\n return parsed as Record<string, unknown>\n}\n\nfunction throwToolError(result: {\n isError?: boolean\n structuredContent?: Record<string, unknown>\n}): void {\n if (!result.isError) return\n const envelope = result.structuredContent as\n | { error?: { code?: SeoErrorCode; message?: string } }\n | undefined\n throw new SeoError(\n envelope?.error?.code ?? 'INTERNAL_ERROR',\n envelope?.error?.message ?? 'The report could not be completed.',\n )\n}\n\ntype JsonSchemaProperty = {\n description?: string\n format?: string\n items?: { type?: string }\n type?: string | string[]\n}\n\nfunction reportParameters(inputSchema: unknown) {\n if (!inputSchema || typeof inputSchema !== 'object') return []\n const schema = inputSchema as {\n properties?: Record<string, JsonSchemaProperty>\n required?: string[]\n }\n const required = new Set(schema.required ?? [])\n return Object.entries(schema.properties ?? {}).map(([name, property]) => {\n const rawType = Array.isArray(property.type)\n ? property.type.join(' | ')\n : (property.type ?? 'any')\n const type =\n rawType === 'array' && property.items?.type\n ? `${property.items.type}[]`\n : property.format\n ? `${rawType} (${property.format})`\n : rawType\n return {\n name,\n type,\n required: required.has(name),\n description: property.description,\n }\n })\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: 'list',\n description: 'List report ids available to the CLI and MCP server',\n },\n args: {\n category: {\n type: 'string',\n description: `Filter by category: ${REPORT_CATEGORIES.join(', ')}.`,\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const category = categoryArg(args.category)\n const reports = listReports(category)\n if (jsonFlag(args)) {\n printJson({ reports, categories: REPORT_CATEGORIES })\n return\n }\n printCatalog(reports, {\n noun: 'report',\n categoryLabels: CATEGORY_LABELS,\n })\n process.stdout.write('\\n')\n printCallout({\n title: 'Need the detail?',\n body: 'Describe one report to see when to use it, what it needs, and what the result can prove.',\n command: 'seo reports describe <id>',\n })\n },\n})\n\nconst describeCommand = defineCommand({\n meta: {\n name: 'describe',\n description: 'Show the purpose and parameter schema for one report',\n },\n args: {\n id: {\n type: 'positional',\n required: true,\n description: 'Report id from `seo reports list`.',\n },\n check: {\n type: 'string',\n description: 'Show fix guidance for one check id from the report output.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const check = stringArg(args.check)\n if (check) {\n const report = describeReportCheck(stringArg(args.id) ?? '', check)\n if (jsonFlag(args)) {\n printJson({ report })\n return\n }\n printHeading(`${report.name}: ${report.check}`, report.checkFix.goal)\n process.stdout.write('\\n')\n printSection('Fix', report.checkFix.fix)\n process.stdout.write('\\n')\n printSection('Agent prompt', report.checkFix.prompt)\n process.stdout.write('\\n')\n printSection('Verify', report.checkFix.verify)\n if (report.checkFix.resources.length > 0) {\n process.stdout.write('\\n')\n printBulletSection(\n 'Resources',\n report.checkFix.resources.map(\n (resource) => `${resource.title}: ${resource.url}`,\n ),\n )\n }\n process.stdout.write('\\n')\n return\n }\n const report = describeReport(stringArg(args.id) ?? '')\n if (jsonFlag(args)) {\n printJson({ report })\n return\n }\n printHeading(report.name, report.description)\n process.stdout.write('\\n')\n printKeyValue([\n ['ID', report.id],\n ['Category', report.category],\n ['Outcome', report.outcome],\n ])\n process.stdout.write('\\n')\n printBulletSection('Use when', report.useWhen)\n process.stdout.write('\\n')\n printBulletSection('Avoid when', report.avoidWhen)\n process.stdout.write('\\n')\n printBulletSection('Read in order', report.readOrder)\n process.stdout.write('\\n')\n printBulletSection('Do not claim', report.doNotClaim)\n process.stdout.write('\\n')\n printSection('Verify', report.verify)\n if (report.related.length > 0) {\n process.stdout.write('\\n')\n printBulletSection(\n 'Related reports',\n report.related.map((item) => `${item.id}: ${item.reason}`),\n )\n }\n process.stdout.write('\\nParameters\\n')\n printParameters(reportParameters(report.inputSchema))\n if (report.fixableChecks) {\n process.stdout.write('\\n')\n printCallout({\n title: 'Fix a failed check',\n body: 'Get the fix steps, an agent prompt, and spec links for one check id from the report output.',\n command: `seo reports describe ${report.id} --check <check-id>`,\n })\n }\n process.stdout.write('\\n')\n printCallout({\n title: 'Need the exact schema?',\n command: `seo reports describe ${report.id} --json`,\n })\n },\n})\n\nconst runCommand = defineCommand({\n meta: {\n name: 'run',\n description: 'Run one report with JSON parameters',\n },\n args: {\n id: {\n type: 'positional',\n required: true,\n description: 'Report id from `seo reports list`.',\n },\n params: {\n type: 'string',\n description: 'Report parameters as a JSON object.',\n },\n 'params-file': {\n type: 'string',\n description: 'Read report parameters from a JSON file.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const id = stringArg(args.id) ?? ''\n const params = await paramsArg(args.params, args['params-file'])\n const result = await executeReport(id, params)\n throwToolError(result)\n\n if (jsonFlag(args)) {\n printJson(result.structuredContent ?? {})\n return\n }\n for (const item of result.content) {\n process.stdout.write(`${item.text}\\n`)\n }\n },\n})\n\nexport const reportCatalogCommand = defineCommand({\n meta: {\n name: 'reports',\n description: 'Discover and run the complete report catalog',\n },\n subCommands: {\n list: listCommand,\n describe: describeCommand,\n run: runCommand,\n },\n})\n","import { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\nimport {\n type ReportHtmlSection,\n type ReportHtmlView,\n type ReportNarrative,\n renderReportHtml,\n SeoError,\n} from '@seo/core'\nimport { booleanArg, stringArg } from '../args.js'\n\nexport const reportHtmlArgs = {\n format: {\n type: 'string',\n description: 'Output format: terminal or html. Defaults to terminal.',\n },\n output: {\n type: 'string',\n description: 'HTML output file. A dated filename is used by default.',\n },\n view: {\n type: 'string',\n description: 'HTML detail level: client or analyst. Defaults to client.',\n },\n} as const\n\nexport type ReportHtmlOptions = {\n output?: string\n view: ReportHtmlView\n}\n\nexport function reportHtmlOptions(\n args: Record<string, unknown>,\n): ReportHtmlOptions | undefined {\n const format = stringArg(args.format) ?? 'terminal'\n if (format !== 'terminal' && format !== 'html') {\n throw new SeoError('INVALID_INPUT', 'Choose terminal or html for --format.')\n }\n if (format === 'terminal') {\n if (stringArg(args.output) || stringArg(args.view)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use --output and --view with --format html.',\n )\n }\n return undefined\n }\n if (booleanArg(args.json)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Use either --json or --format html, not both.',\n )\n }\n\n const view = stringArg(args.view) ?? 'client'\n if (view !== 'client' && view !== 'analyst') {\n throw new SeoError('INVALID_INPUT', 'Choose client or analyst for --view.')\n }\n return { output: stringArg(args.output), view }\n}\n\nfunction slug(value: string): string {\n return value\n .toLowerCase()\n .replace(/^sc-domain:/, '')\n .replace(/^https?:\\/\\//, '')\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80)\n}\n\nexport function defaultReportHtmlPath(input: {\n reportName: string\n projectId?: string\n site: string\n date?: Date\n}): string {\n const day = (input.date ?? new Date()).toISOString().slice(0, 10)\n const identity = slug(input.projectId ?? input.site) || 'site'\n return resolve(\n process.cwd(),\n `${identity}-${slug(input.reportName)}-${day}.html`,\n )\n}\n\nexport async function writeReportHtml(input: {\n report: ReportNarrative\n reportName: string\n title: string\n options: ReportHtmlOptions\n projectId?: string\n additionalSections?: ReportHtmlSection[]\n}): Promise<string> {\n const path = resolve(\n input.options.output ??\n defaultReportHtmlPath({\n reportName: input.reportName,\n projectId: input.projectId,\n site: input.report.site,\n }),\n )\n await mkdir(dirname(path), { recursive: true })\n await writeFile(\n path,\n renderReportHtml({\n report: input.report,\n title: input.title,\n view: input.options.view,\n additionalSections: input.additionalSections,\n }),\n 'utf8',\n )\n return path\n}\n\nexport function printReportHtmlPath(path: string): void {\n process.stdout.write(`Wrote HTML report to ${path}\\n`)\n}\n","import { monthlyReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printNextCommand } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n reportFetchArgs,\n reportFetchOptions,\n reportSelectionArgs,\n reportSelectionInput,\n} from './args.js'\n\nexport const monthlyReportCommand = defineCommand({\n meta: {\n name: 'monthly-report',\n description: 'Generate a monthly SEO report narrative',\n },\n args: {\n ...reportSelectionArgs,\n month: {\n type: 'string',\n description:\n 'Report month as YYYY-MM. Defaults to the latest month with final GSC data.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n ...reportFetchArgs,\n ...reportHtmlArgs,\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = reportHtmlOptions(args)\n const selectionInput = reportSelectionInput(args)\n const selection = await resolveClientSelection({\n client: selectionInput.client,\n site: selectionInput.site,\n options: { json, refresh: selectionInput.refresh },\n })\n const report = await monthlyReport({\n site: selection.site,\n month: stringArg(args.month),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report,\n reportName: 'monthly-report',\n title: `Monthly SEO report for ${report.month}`,\n options: html,\n projectId: selection.client?.id,\n })\n printReportHtmlPath(path)\n return\n }\n process.stdout.write(`${report.markdown}\\n`)\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n const month = stringArg(args.month)\n process.stdout.write('\\n')\n printNextCommand(\n `seo export monthly ${target}${month ? ` --month ${JSON.stringify(month)}` : ''}`,\n )\n },\n})\n","import { reportNarrative } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, numberArg, stringArg } from '../../args.js'\nimport { createProgressReporter } from '../../progress.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printNextCommand } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport {\n reportFetchArgs,\n reportFetchOptions,\n reportSelectionArgs,\n reportSelectionInput,\n} from './args.js'\n\nexport const reportNarrativeCommand = defineCommand({\n meta: {\n name: 'report-narrative',\n description: 'Generate a client-ready SEO narrative from diagnosis data',\n },\n args: {\n ...reportSelectionArgs,\n ...cliReportArgs(['days', 'recentDays'], {\n days: { description: 'Diagnosis window length in days. Defaults to 90.' },\n }),\n 'start-date': {\n type: 'string',\n description: 'Optional report start date as YYYY-MM-DD.',\n },\n 'end-date': {\n type: 'string',\n description: 'Optional report end date as YYYY-MM-DD.',\n },\n ...cliReportArgs(['limit'], {\n limit: {\n description: 'Maximum rows per diagnostic section. Defaults to 10.',\n },\n }),\n 'change-limit': {\n type: 'string',\n description: 'Maximum saved changes to measure. Defaults to 5.',\n },\n ...reportFetchArgs,\n ...reportHtmlArgs,\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = reportHtmlOptions(args)\n const selectionInput = reportSelectionInput(args)\n const selection = await resolveClientSelection({\n client: selectionInput.client,\n site: selectionInput.site,\n options: { json, refresh: selectionInput.refresh },\n })\n const report = await reportNarrative({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n startDate: stringArg(args['start-date']),\n endDate: stringArg(args['end-date']),\n limit: numberArg(args.limit),\n changeLimit: numberArg(args['change-limit']),\n brandTerms: selection.client?.brandTerms,\n ...reportFetchOptions(args),\n progress: createProgressReporter(!json),\n })\n\n if (json) {\n printJson(report)\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report,\n reportName: 'narrative-report',\n title: 'SEO narrative report',\n options: html,\n projectId: selection.client?.id,\n })\n printReportHtmlPath(path)\n return\n }\n process.stdout.write(`${report.markdown}\\n`)\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n process.stdout.write('\\n')\n printNextCommand(`seo export narrative ${target}`)\n },\n})\n","import { explainRule, listRules } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printCatalog,\n printJson,\n printKeyValue,\n printSection,\n} from '../utils.js'\n\nexport const rulesCommand = defineCommand({\n meta: {\n name: 'rules',\n description: 'List crawler rule ids and default guidance',\n },\n args: {\n category: {\n type: 'string',\n description: 'Filter rules by category.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const category = stringArg(args.category)\n const rules = listRules().filter((rule) =>\n category ? rule.category === category : true,\n )\n\n if (jsonFlag(args)) {\n printJson({ rules })\n return\n }\n\n printCatalog(\n rules.map((rule) => ({\n id: rule.id,\n category: rule.category,\n name: `${rule.title} · ${rule.defaultSeverity}`,\n })),\n { noun: 'rule' },\n )\n },\n})\n\nexport const explainCommand = defineCommand({\n meta: {\n name: 'explain',\n description: 'Explain one crawler rule in plain English',\n },\n args: {\n rule: {\n type: 'string',\n required: true,\n description: 'Rule id to explain, for example missing_title.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const ruleId = stringArg(args.rule) ?? ''\n const rule = explainRule(ruleId)\n if (!rule) {\n throw new Error(`Unknown rule: ${ruleId}`)\n }\n\n if (jsonFlag(args)) {\n printJson(rule)\n return\n }\n\n printKeyValue([\n ['Rule', rule.id],\n ['Title', rule.title],\n ['Category', rule.category],\n ['Severity', rule.defaultSeverity],\n ])\n process.stdout.write('\\n')\n printSection('Why it matters', rule.whyItMatters)\n process.stdout.write('\\n')\n printSection('How to fix', rule.howToFix)\n process.stdout.write('\\n')\n printSection('Impact if ignored', rule.impactIfIgnored)\n process.stdout.write('\\n')\n printSection('How to verify', rule.howToVerify)\n },\n})\n","import { ensureSeoCliDirs, SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, listArg, numberArg, projectArg, stringArg } from '../args.js'\nimport { resolveClientSelection } from '../selection.js'\nimport { printJson, printKeyValue } from '../utils.js'\nimport { startUrlForSite } from './shared.js'\n\nfunction quote(value: string): string {\n return JSON.stringify(value)\n}\n\ntype RankCronCadence = 'daily' | 'weekly' | 'monthly'\n\nexport function rankTrackingCronLine(input: {\n projectId: string\n set: string\n targetDomain: string\n tag?: string\n devices?: string[]\n depth?: number\n keywordLimit?: number\n provider?: string\n cadence?: string\n hour: number\n minute: number\n weekday: number\n day: number\n}) {\n const cadence = (input.cadence ?? 'weekly') as RankCronCadence\n if (!['daily', 'weekly', 'monthly'].includes(cadence)) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Rank tracking cron cadence must be daily, weekly, or monthly.',\n )\n }\n const devices = input.devices?.length\n ? [...new Set(input.devices)]\n : undefined\n if (\n devices?.some((device) => !['desktop', 'mobile'].includes(device)) ||\n (devices?.length ?? 0) > 2\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Rank tracking devices must be desktop, mobile, or both.',\n )\n }\n if (\n input.depth !== undefined &&\n (!Number.isSafeInteger(input.depth) || input.depth < 1 || input.depth > 100)\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Rank tracking depth must be from 1 to 100.',\n )\n }\n if (\n input.keywordLimit !== undefined &&\n (!Number.isSafeInteger(input.keywordLimit) ||\n input.keywordLimit < 1 ||\n input.keywordLimit > 1_000)\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Queued rank tracking can collect 1 to 1000 keywords per run.',\n )\n }\n const params = {\n projectId: input.projectId,\n set: input.set,\n targetDomain: input.targetDomain,\n ...(input.tag ? { tag: input.tag } : {}),\n ...(devices ? { devices } : {}),\n ...(input.provider ? { provider: input.provider } : {}),\n collectionMethod: 'queued',\n cadence,\n ...(input.depth === undefined ? {} : { depth: input.depth }),\n ...(input.keywordLimit === undefined\n ? {}\n : { keywordLimit: input.keywordLimit }),\n start: true,\n }\n return {\n name: 'rank-tracking',\n cron: `${input.minute} ${input.hour} * * *`,\n command: [\n 'seo reports run rank-tracking',\n `--params ${quote(JSON.stringify(params))}`,\n '--json',\n ].join(' '),\n }\n}\n\nexport const scheduleCommand = defineCommand({\n meta: {\n name: 'schedule',\n description: 'Print local cron entries for recurring SEO workflows',\n },\n subCommands: {\n cron: defineCommand({\n meta: {\n name: 'cron',\n description: 'Print crontab lines for local recurring SEO workflows',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL for technical-watch. Defaults from the GSC property when possible.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for index-watch.',\n },\n hour: {\n type: 'string',\n default: '9',\n description: 'Hour in local cron time. Defaults to 9.',\n },\n minute: {\n type: 'string',\n default: '0',\n description: 'Minute in local cron time. Defaults to 0.',\n },\n weekday: {\n type: 'string',\n description:\n 'Weekly technical-watch day. Defaults to client setting, then Monday.',\n },\n day: {\n type: 'string',\n description:\n 'Monthly report day. Defaults to client setting, then 1.',\n },\n 'rank-set': {\n type: 'string',\n description:\n 'Saved keyword set to collect with the rank-tracking report.',\n },\n 'rank-domain': {\n type: 'string',\n description: 'Target domain for exact rank matching.',\n },\n 'rank-tag': {\n type: 'string',\n description: 'Optional saved keyword tag to track.',\n },\n 'rank-devices': {\n type: 'string',\n description: 'Comma-separated desktop and mobile devices.',\n },\n 'rank-depth': {\n type: 'string',\n description: 'Organic result depth from 1 to 100.',\n },\n 'rank-limit': {\n type: 'string',\n description: 'Maximum saved keywords from 1 to 1000.',\n },\n 'rank-provider': {\n type: 'string',\n description: 'Connected provider for exact rank collection.',\n },\n 'rank-cadence': {\n type: 'string',\n description: 'Rank collection cadence: daily, weekly, or monthly.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json },\n })\n const site = selection.site\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const hour = numberArg(args.hour) ?? 9\n const minute = numberArg(args.minute) ?? 0\n const weekday =\n numberArg(args.weekday) ?? selection.client?.technicalWeekday ?? 1\n const day = numberArg(args.day) ?? selection.client?.reportDay ?? 1\n const identityArg = selection.client\n ? `--project ${quote(selection.client.id)}`\n : `--site ${quote(site)}`\n const watchUrls =\n stringArg(args.urls) ?? selection.client?.watchUrls.join(',')\n\n const lines = [\n {\n name: 'technical-watch',\n cron: `${minute} ${hour} * * ${weekday}`,\n command: [\n 'seo technical-watch',\n identityArg,\n startUrl ? `--url ${quote(startUrl)}` : undefined,\n watchUrls ? `--urls ${quote(watchUrls)}` : undefined,\n '--json',\n ]\n .filter(Boolean)\n .join(' '),\n },\n {\n name: 'monthly-report',\n cron: `${minute} ${hour} ${day} * *`,\n command: ['seo monthly-report', identityArg, '--json'].join(' '),\n },\n ]\n const rankSet = stringArg(args['rank-set'])\n const rankDomain = stringArg(args['rank-domain'])\n if (rankSet || rankDomain) {\n if (!rankSet || !rankDomain) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Pass both --rank-set and --rank-domain for scheduled rank tracking.',\n )\n }\n if (!selection.client) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Scheduled rank tracking needs a saved project profile.',\n )\n }\n lines.push(\n rankTrackingCronLine({\n projectId: selection.client.id,\n set: rankSet,\n targetDomain: rankDomain,\n tag: stringArg(args['rank-tag']),\n devices: listArg(args['rank-devices']),\n depth: numberArg(args['rank-depth']),\n keywordLimit: numberArg(args['rank-limit']),\n provider: stringArg(args['rank-provider']),\n cadence: stringArg(args['rank-cadence']),\n hour,\n minute,\n weekday,\n day,\n }),\n )\n }\n\n if (json) {\n printJson({ site, lines })\n return\n }\n\n const paths = ensureSeoCliDirs()\n printKeyValue([\n ['Property', site],\n ['Install', 'crontab -e'],\n ])\n for (const line of lines) {\n process.stdout.write(\n `${line.cron} seo logs prune --quiet; ${line.command} >> ${quote(`${paths.logDir}/${line.name}.log`)} 2>&1\\n`,\n )\n }\n },\n }),\n },\n})\n","import { importServerLog, SeoError, serverLogReport } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, strictNumberArg, stringArg } from '../args.js'\nimport { printJson } from '../utils.js'\nimport {\n formatCount,\n printLimitedTable,\n printReportSummary,\n truncate,\n} from './output.js'\n\nconst analyzeCommand = defineCommand({\n meta: {\n name: 'analyze',\n description: 'Stream a local access log into bounded crawler evidence',\n },\n args: {\n file: {\n type: 'string',\n description: 'Local combined, JSONL, or NDJSON access log.',\n required: true,\n },\n format: {\n type: 'string',\n description: 'Input format override: combined or jsonl.',\n },\n 'row-limit': {\n type: 'string',\n description: 'Maximum rows to parse. Defaults to 1000000.',\n },\n 'path-limit': {\n type: 'string',\n description:\n 'Maximum crawler and path aggregates to retain. Defaults to 25000.',\n },\n limit: {\n type: 'string',\n description: 'Maximum crawler path rows returned. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const file = stringArg(args.file)\n if (!file) throw new SeoError('INVALID_INPUT', 'Pass --file.')\n const format = stringArg(args.format)\n if (format && !['combined', 'jsonl'].includes(format)) {\n throw new SeoError('INVALID_INPUT', '--format must be combined or jsonl.')\n }\n const evidence = await importServerLog({\n file,\n format: format as 'combined' | 'jsonl' | undefined,\n rowLimit: strictNumberArg(args['row-limit'], '--row-limit'),\n pathLimit: strictNumberArg(args['path-limit'], '--path-limit'),\n })\n const report = serverLogReport({\n evidence,\n limit: strictNumberArg(args.limit, '--limit'),\n })\n if (jsonFlag(args)) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Server log report',\n status:\n report.dataStatus === 'complete'\n ? report.summary.invalidRows > 0\n ? 'warning'\n : 'info'\n : 'unknown',\n summary: `${formatCount(report.summary.crawlerRows)} crawler requests found in ${formatCount(report.summary.parsedRows)} parsed requests.`,\n metrics: [\n { label: 'Evidence', value: report.dataStatus },\n {\n label: 'Parsed requests',\n value: formatCount(report.summary.parsedRows),\n },\n {\n label: 'Crawler requests',\n value: formatCount(report.summary.crawlerRows),\n },\n {\n label: 'Crawler families',\n value: formatCount(report.crawlers.length),\n },\n {\n label: 'Invalid rows',\n value: formatCount(report.summary.invalidRows),\n },\n {\n label: 'Returned paths',\n value: `${formatCount(report.selection.returnedCrawlerPaths)} of ${formatCount(report.selection.availableCrawlerPaths)}`,\n },\n ],\n })\n if (report.crawlers.length) {\n process.stdout.write('\\nCrawler activity\\n')\n printLimitedTable(\n ['Crawler', 'Type', 'Requests', '4xx', '5xx'],\n report.crawlers.map((crawler) => [\n crawler.family,\n crawler.category,\n String(crawler.requests),\n String(crawler.clientError),\n String(crawler.serverError),\n ]),\n )\n }\n if (report.crawlerPaths.length) {\n process.stdout.write('\\nCrawler paths\\n')\n printLimitedTable(\n ['Crawler', 'Path', 'Requests', '4xx', '5xx'],\n report.crawlerPaths.map((row) => [\n row.family,\n truncate(row.path, 72),\n String(row.requests),\n String(row.clientError),\n String(row.serverError),\n ]),\n )\n }\n for (const warning of report.warnings) {\n process.stdout.write(`\\nWarning: ${warning}\\n`)\n }\n process.stdout.write(`\\nNote: ${report.caveats[0]}\\n`)\n },\n})\n\nexport const serverLogsCommand = defineCommand({\n meta: {\n name: 'server-logs',\n description: 'Analyze local web server access logs',\n },\n subCommands: { analyze: analyzeCommand },\n})\n","import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { SeoError } from '@seo/core'\n\n// Skills and evals ship at the package root. Both resolvers honour an explicit\n// override, otherwise walk up from the bundled CLI until the directory and its\n// README appear. Kept in its own module so the skills command and the eval\n// command can share it without importing each other.\nexport function skillsDirectory(): string {\n return resolvePackagedDirectory('skills', process.env.SEO_SKILLS_DIR)\n}\n\nexport function evalsDirectory(): string {\n return resolvePackagedDirectory('evals', process.env.SEO_EVALS_DIR)\n}\n\nfunction resolvePackagedDirectory(name: string, override?: string): string {\n if (override) return resolve(override)\n\n let current = dirname(fileURLToPath(import.meta.url))\n for (let depth = 0; depth < 6; depth += 1) {\n const candidate = join(current, name)\n if (existsSync(join(candidate, 'README.md'))) return candidate\n current = dirname(current)\n }\n\n throw new SeoError(\n 'INTERNAL_ERROR',\n `Packaged ${name} could not be found. Reinstall \\`seo\\` and try again.`,\n )\n}\n\nexport function readSkillDescription(path: string): string {\n const source = readFileSync(join(path, 'SKILL.md'), 'utf8')\n return source.match(/^description:\\s*(.+)$/m)?.[1]?.trim() ?? ''\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { basename, join } from 'node:path'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n stringArg,\n} from '../args.js'\nimport { printJson } from '../utils.js'\nimport { evalsDirectory, skillsDirectory } from './skill-paths.js'\n\nconst SCHEMA_VERSION = 1\nconst DEFAULT_AGENT = 'claude -p'\nconst DEFAULT_TIMEOUT_SECONDS = 300\nconst MAX_CONCURRENCY = 4\nconst ROUTER_SKILL = 'seo'\n\ntype EvalItem = {\n id: number\n prompt: string\n expected_output: string\n assertions: string[]\n files: string[]\n}\n\ntype EvalFile = {\n subject: string\n evals: EvalItem[]\n}\n\ntype AssertionVerdict = {\n assertion: string\n verdict: 'pass' | 'fail' | 'unjudged'\n reason?: string\n source?: 'judge verdict'\n}\n\ntype EvalStatus = 'passed' | 'failed' | 'errored' | 'unjudged'\n\ntype EvalResult = {\n id: number\n prompt: string\n status: EvalStatus\n reply: string\n error?: string\n agentDurationMs: number\n judgeDurationMs?: number\n durationMs: number\n assertions: AssertionVerdict[]\n}\n\ntype SubjectResult = {\n subject: string\n passed: number\n failed: number\n errored: number\n unjudged: number\n evals: EvalResult[]\n}\n\nfunction listSubjectFiles(): Array<{ subject: string; path: string }> {\n const root = evalsDirectory()\n return readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isFile() && entry.name.endsWith('.json'))\n .map((entry) => ({\n subject: basename(entry.name, '.json'),\n path: join(root, entry.name),\n }))\n .sort((a, b) =>\n a.subject < b.subject ? -1 : a.subject > b.subject ? 1 : 0,\n )\n}\n\nexport function loadEvalFile(subject: string, path: string): EvalFile {\n let raw: string\n try {\n raw = readFileSync(path, 'utf8')\n } catch {\n throw new SeoError('INVALID_INPUT', `Cannot read eval file for ${subject}.`)\n }\n let doc: unknown\n try {\n doc = JSON.parse(raw)\n } catch {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json is not valid JSON.`,\n )\n }\n if (!doc || typeof doc !== 'object' || Array.isArray(doc)) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must be an object.`,\n )\n }\n const record = doc as Record<string, unknown>\n if (record.subject !== subject) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must set subject to \"${subject}\".`,\n )\n }\n if (!Array.isArray(record.evals) || record.evals.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `Eval file ${subject}.json must have a non-empty evals array.`,\n )\n }\n const seen = new Set<number>()\n const evals: EvalItem[] = record.evals.map((entry, index) => {\n const item = entry as Record<string, unknown>\n const label = `${subject}.json eval ${index + 1}`\n if (!Number.isInteger(item?.id)) {\n throw new SeoError('INVALID_INPUT', `${label}: id must be an integer.`)\n }\n const id = item.id as number\n if (seen.has(id)) {\n throw new SeoError('INVALID_INPUT', `${label}: duplicate id ${id}.`)\n }\n seen.add(id)\n if (typeof item.prompt !== 'string' || item.prompt.trim().length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: prompt must be a non-empty string.`,\n )\n }\n if (\n typeof item.expected_output !== 'string' ||\n item.expected_output.trim().length === 0\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: expected_output must be a non-empty string.`,\n )\n }\n if (\n !Array.isArray(item.assertions) ||\n item.assertions.length === 0 ||\n item.assertions.some(\n (value) => typeof value !== 'string' || value.trim().length === 0,\n )\n ) {\n throw new SeoError(\n 'INVALID_INPUT',\n `${label}: assertions must be a non-empty array of non-empty strings.`,\n )\n }\n if (item.files !== undefined && !Array.isArray(item.files)) {\n throw new SeoError('INVALID_INPUT', `${label}: files must be an array.`)\n }\n return {\n id,\n prompt: item.prompt,\n expected_output: item.expected_output,\n assertions: item.assertions as string[],\n files: (item.files as string[] | undefined) ?? [],\n }\n })\n return { subject, evals }\n}\n\nfunction routerSkillBody(): string {\n const path = join(skillsDirectory(), ROUTER_SKILL, 'SKILL.md')\n if (!existsSync(path)) {\n throw new SeoError(\n 'INTERNAL_ERROR',\n 'The seo router skill could not be found. Reinstall `seo` or use --no-skill.',\n )\n }\n return readFileSync(path, 'utf8')\n}\n\n// Split a command template into argv tokens without a shell. Single quotes,\n// double quotes, and backslash escapes group tokens; nothing is expanded, so a\n// substituted prompt can never break out into extra arguments or shell syntax.\nexport function tokenizeCommand(command: string): string[] {\n const tokens: string[] = []\n let current = ''\n let started = false\n let inSingle = false\n let inDouble = false\n for (let i = 0; i < command.length; i += 1) {\n const ch = command[i] as string\n if (inSingle) {\n if (ch === \"'\") inSingle = false\n else current += ch\n started = true\n continue\n }\n if (inDouble) {\n if (ch === '\"') {\n inDouble = false\n } else if (\n ch === '\\\\' &&\n (command[i + 1] === '\"' || command[i + 1] === '\\\\')\n ) {\n current += command[i + 1]\n i += 1\n } else {\n current += ch\n }\n started = true\n continue\n }\n if (ch === \"'\") {\n inSingle = true\n started = true\n continue\n }\n if (ch === '\"') {\n inDouble = true\n started = true\n continue\n }\n if (ch === '\\\\') {\n if (i + 1 < command.length) {\n current += command[i + 1]\n i += 1\n started = true\n }\n continue\n }\n if (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '\\r') {\n if (started) {\n tokens.push(current)\n current = ''\n started = false\n }\n continue\n }\n current += ch\n started = true\n }\n if (inSingle || inDouble) {\n throw new SeoError('INVALID_INPUT', 'Unbalanced quote in agent command.')\n }\n if (started) tokens.push(current)\n return tokens\n}\n\nexport function buildArgv(\n template: string,\n prompt: string,\n): { argv: string[]; usesPlaceholder: boolean } {\n const tokens = tokenizeCommand(template)\n if (tokens.length === 0) {\n throw new SeoError('INVALID_INPUT', 'Agent command must not be empty.')\n }\n const usesPlaceholder = tokens.some((token) => token.includes('{prompt}'))\n const argv = usesPlaceholder\n ? tokens.map((token) => token.split('{prompt}').join(prompt))\n : tokens\n return { argv, usesPlaceholder }\n}\n\nexport function assembleAgentPrompt(\n skillBody: string | null,\n prompt: string,\n): string {\n if (!skillBody) return prompt\n return `${skillBody.trim()}\\n\\n---\\n\\nUser request:\\n${prompt}`\n}\n\nconst JUDGE_CORRECTION =\n 'Your previous reply could not be parsed as the required JSON with one result per assertion. Reply again with STRICT JSON only, in the exact shape shown, and nothing else.'\n\nexport function buildJudgePrompt(\n prompt: string,\n reply: string,\n assertions: string[],\n corrective = false,\n): string {\n const list = assertions\n .map((entry, index) => `${index + 1}. ${entry}`)\n .join('\\n')\n const base = [\n 'You are judging whether an AI agent response satisfies a list of assertions.',\n 'Judge only against the assertions. Be strict but fair.',\n '',\n 'Original request:',\n prompt,\n '',\n 'Agent response:',\n reply,\n '',\n 'Assertions to evaluate, in this exact order:',\n '<assertions>',\n list,\n '</assertions>',\n '',\n 'Judge outcomes, not narration. An assertion about reading, checking, or',\n 'following fields or steps passes when the reply demonstrably used that',\n 'information or produced the result it protects, even if the reply never',\n 'names the field or step. Fail it only when the reply contradicts it or',\n 'shows the work was not done.',\n '',\n 'Reply with STRICT JSON only. No prose, no markdown, no code fence:',\n '{\"results\":[{\"assertion\":\"<assertion text>\",\"pass\":true,\"reason\":\"<short reason>\"}]}',\n `Return exactly ${assertions.length} result${assertions.length === 1 ? '' : 's'}, one per assertion, in the same order.`,\n ].join('\\n')\n return corrective ? `${base}\\n\\n${JUDGE_CORRECTION}` : base\n}\n\n// Pull the first complete JSON object out of a larger reply. Judges wrap JSON\n// in prose or code fences, so scan for the first balanced `{...}` and parse it.\nexport function extractJsonObject(text: string): unknown | undefined {\n const start = text.indexOf('{')\n if (start === -1) return undefined\n let depth = 0\n let inString = false\n let escaped = false\n for (let i = start; i < text.length; i += 1) {\n const ch = text[i]\n if (inString) {\n if (escaped) escaped = false\n else if (ch === '\\\\') escaped = true\n else if (ch === '\"') inString = false\n continue\n }\n if (ch === '\"') inString = true\n else if (ch === '{') depth += 1\n else if (ch === '}') {\n depth -= 1\n if (depth === 0) {\n try {\n return JSON.parse(text.slice(start, i + 1))\n } catch {\n return undefined\n }\n }\n }\n }\n return undefined\n}\n\ntype ParsedVerdicts = { verdicts: AssertionVerdict[] } | { error: string }\n\nexport function parseJudgeVerdicts(\n output: string,\n assertions: string[],\n): ParsedVerdicts {\n const parsed = extractJsonObject(output)\n if (!parsed || typeof parsed !== 'object') {\n return { error: 'Judge reply did not contain a JSON object.' }\n }\n const results = (parsed as Record<string, unknown>).results\n if (!Array.isArray(results)) {\n return { error: 'Judge reply had no results array.' }\n }\n if (results.length !== assertions.length) {\n return {\n error: `Judge returned ${results.length} results for ${assertions.length} assertions.`,\n }\n }\n const verdicts = assertions.map((assertion, index) => {\n const entry = results[index] as Record<string, unknown>\n return {\n assertion,\n verdict: entry?.pass === true ? 'pass' : 'fail',\n reason:\n typeof entry?.reason === 'string' && entry.reason.trim().length > 0\n ? entry.reason.trim()\n : 'No reason given.',\n source: 'judge verdict' as const,\n } satisfies AssertionVerdict\n })\n return { verdicts }\n}\n\ntype ProcessResult = {\n stdout: string\n stderr: string\n code: number | null\n timedOut: boolean\n spawnError?: string\n durationMs: number\n}\n\nfunction runProcess(\n argv: string[],\n options: { input?: string; timeoutMs: number },\n): Promise<ProcessResult> {\n return new Promise((resolvePromise) => {\n const start = Date.now()\n const [command, ...rest] = argv\n let child: ReturnType<typeof spawn>\n try {\n child = spawn(command as string, rest, {\n stdio: ['pipe', 'pipe', 'pipe'],\n })\n } catch (error) {\n resolvePromise({\n stdout: '',\n stderr: '',\n code: null,\n timedOut: false,\n spawnError: error instanceof Error ? error.message : String(error),\n durationMs: Date.now() - start,\n })\n return\n }\n let stdout = ''\n let stderr = ''\n let settled = false\n let timedOut = false\n let killTimer: NodeJS.Timeout | undefined\n const timer = setTimeout(() => {\n timedOut = true\n child.kill('SIGTERM')\n killTimer = setTimeout(() => {\n try {\n child.kill('SIGKILL')\n } catch {\n // process already gone\n }\n }, 2000)\n killTimer.unref()\n }, options.timeoutMs)\n const finish = (result: Omit<ProcessResult, 'durationMs'>) => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n if (killTimer) clearTimeout(killTimer)\n resolvePromise({ ...result, durationMs: Date.now() - start })\n }\n child.stdout?.on('data', (chunk) => {\n stdout += chunk\n })\n child.stderr?.on('data', (chunk) => {\n stderr += chunk\n })\n child.on('error', (error) => {\n finish({\n stdout,\n stderr,\n code: null,\n timedOut,\n spawnError: error.message,\n })\n })\n child.on('close', (code) => {\n finish({ stdout, stderr, code, timedOut })\n })\n if (child.stdin) {\n if (options.input !== undefined) child.stdin.end(options.input)\n else child.stdin.end()\n }\n })\n}\n\nasync function runCommandTemplate(\n template: string,\n prompt: string,\n timeoutMs: number,\n): Promise<ProcessResult> {\n const { argv, usesPlaceholder } = buildArgv(template, prompt)\n return runProcess(argv, {\n input: usesPlaceholder ? undefined : prompt,\n timeoutMs,\n })\n}\n\ntype RunOptions = {\n agent: string\n judge: string | null\n skillBody: string | null\n timeoutMs: number\n}\n\nasync function runSingleEval(\n item: EvalItem,\n options: RunOptions,\n): Promise<EvalResult> {\n const start = Date.now()\n const agentPrompt = assembleAgentPrompt(options.skillBody, item.prompt)\n const agentRun = await runCommandTemplate(\n options.agent,\n agentPrompt,\n options.timeoutMs,\n )\n const reply = agentRun.stdout.trim()\n\n const base = {\n id: item.id,\n prompt: item.prompt,\n reply,\n agentDurationMs: agentRun.durationMs,\n }\n\n if (agentRun.spawnError) {\n return {\n ...base,\n status: 'errored',\n error: `Agent command failed to start: ${agentRun.spawnError}`,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (agentRun.timedOut) {\n return {\n ...base,\n status: 'errored',\n error: `Agent timed out after ${Math.round(options.timeoutMs / 1000)}s.`,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (reply.length === 0) {\n return {\n ...base,\n status: 'errored',\n error: 'Agent returned no output on stdout.',\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n\n if (!options.judge) {\n return {\n ...base,\n status: 'unjudged',\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n\n let judgeDurationMs = 0\n let parseError = ''\n for (let attempt = 0; attempt < 2; attempt += 1) {\n const judgePrompt = buildJudgePrompt(\n item.prompt,\n reply,\n item.assertions,\n attempt > 0,\n )\n const judgeRun = await runCommandTemplate(\n options.judge,\n judgePrompt,\n options.timeoutMs,\n )\n judgeDurationMs += judgeRun.durationMs\n if (judgeRun.spawnError) {\n return {\n ...base,\n status: 'errored',\n error: `Judge command failed to start: ${judgeRun.spawnError}`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n if (judgeRun.timedOut) {\n return {\n ...base,\n status: 'errored',\n error: `Judge timed out after ${Math.round(options.timeoutMs / 1000)}s.`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n }\n const parsed = parseJudgeVerdicts(judgeRun.stdout, item.assertions)\n if ('verdicts' in parsed) {\n const failed = parsed.verdicts.some((entry) => entry.verdict === 'fail')\n return {\n ...base,\n status: failed ? 'failed' : 'passed',\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: parsed.verdicts,\n }\n }\n parseError = parsed.error\n }\n\n return {\n ...base,\n status: 'errored',\n error: `Judge output could not be parsed after a retry: ${parseError}`,\n judgeDurationMs,\n durationMs: Date.now() - start,\n assertions: unjudgedAssertions(item.assertions),\n }\n}\n\nfunction unjudgedAssertions(assertions: string[]): AssertionVerdict[] {\n return assertions.map((assertion) => ({ assertion, verdict: 'unjudged' }))\n}\n\nasync function mapWithConcurrency<T, R>(\n items: T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n let next = 0\n const worker = async () => {\n while (true) {\n const index = next\n next += 1\n if (index >= items.length) return\n results[index] = await fn(items[index] as T, index)\n }\n }\n const size = Math.max(1, Math.min(limit, items.length))\n await Promise.all(Array.from({ length: size }, () => worker()))\n return results\n}\n\nfunction tally(evals: EvalResult[]): {\n passed: number\n failed: number\n errored: number\n unjudged: number\n} {\n const counts = { passed: 0, failed: 0, errored: 0, unjudged: 0 }\n for (const item of evals) counts[item.status] += 1\n return counts\n}\n\nfunction collectSubjects(args: Record<string, unknown>): string[] {\n const raw: string[] = []\n const first = stringArg(args.subject)\n if (first) raw.push(first)\n const rest = args._\n if (Array.isArray(rest)) {\n for (const value of rest) {\n if (typeof value === 'string' && value.length > 0) raw.push(value)\n }\n }\n return [...new Set(raw)]\n}\n\nfunction resolveSelectedSubjects(requested: string[]): Array<{\n subject: string\n path: string\n}> {\n const available = listSubjectFiles()\n if (requested.length === 0) return available\n const byName = new Map(available.map((entry) => [entry.subject, entry]))\n return requested.map((subject) => {\n const match = byName.get(subject)\n if (!match) {\n const known = available.map((entry) => entry.subject).join(', ')\n throw new SeoError(\n 'INVALID_INPUT',\n `Unknown eval subject: ${subject}.${known ? ` Known subjects: ${known}.` : ''}`,\n )\n }\n return match\n })\n}\n\nfunction renderList(json: boolean): void {\n const subjects = listSubjectFiles().map((entry) => {\n const doc = loadEvalFile(entry.subject, entry.path)\n return { subject: entry.subject, evals: doc.evals.length }\n })\n if (json) {\n printJson({ schemaVersion: SCHEMA_VERSION, subjects })\n return\n }\n if (subjects.length === 0) {\n process.stdout.write('No eval subjects found.\\n')\n return\n }\n const width = Math.max(...subjects.map((entry) => entry.subject.length))\n process.stdout.write('Eval subjects\\n')\n for (const entry of subjects) {\n const label = entry.evals === 1 ? 'eval' : 'evals'\n process.stdout.write(\n ` ${entry.subject.padEnd(width)} ${entry.evals} ${label}\\n`,\n )\n }\n}\n\nfunction statusLabel(status: EvalStatus): string {\n if (status === 'passed') return 'PASS'\n if (status === 'failed') return 'FAIL'\n if (status === 'errored') return 'ERROR'\n return 'UNJUDGED'\n}\n\nfunction renderHuman(\n subjects: SubjectResult[],\n options: { judged: boolean; agent: string; judge: string | null },\n): void {\n if (options.judged) {\n process.stdout.write(\n 'Assertion verdicts below are judge verdicts, model judgments from the judge agent, not ground truth.\\n\\n',\n )\n } else {\n process.stdout.write(\n 'Judging was skipped. Review each agent reply against the assertion checklist by hand.\\n\\n',\n )\n }\n for (const subject of subjects) {\n process.stdout.write(`# ${subject.subject}\\n`)\n for (const item of subject.evals) {\n process.stdout.write(\n `\\n[${statusLabel(item.status)}] eval ${item.id} (${item.durationMs}ms)\\n`,\n )\n process.stdout.write(` prompt: ${truncate(item.prompt, 100)}\\n`)\n if (item.error) {\n process.stdout.write(` error: ${item.error}\\n`)\n }\n if (!options.judged) {\n process.stdout.write(` reply: ${truncate(item.reply, 200)}\\n`)\n process.stdout.write(' assertions to review:\\n')\n for (const verdict of item.assertions) {\n process.stdout.write(` - [ ] ${verdict.assertion}\\n`)\n }\n continue\n }\n for (const verdict of item.assertions) {\n const mark =\n verdict.verdict === 'pass'\n ? 'pass'\n : verdict.verdict === 'fail'\n ? 'fail'\n : 'unjudged'\n process.stdout.write(` - ${mark}: ${verdict.assertion}\\n`)\n if (verdict.reason) {\n process.stdout.write(` judge verdict: ${verdict.reason}\\n`)\n }\n }\n }\n const counts = tally(subject.evals)\n process.stdout.write(\n `\\nSubject ${subject.subject}: ${counts.passed} passed, ${counts.failed} failed, ${counts.errored} errored${counts.unjudged ? `, ${counts.unjudged} unjudged` : ''}.\\n\\n`,\n )\n }\n const totals = totalCounts(subjects)\n process.stdout.write(\n `Totals: ${totals.passed} passed, ${totals.failed} failed, ${totals.errored} errored${totals.unjudged ? `, ${totals.unjudged} unjudged` : ''} across ${totals.evals} evals.\\n`,\n )\n}\n\nfunction totalCounts(subjects: SubjectResult[]): {\n passed: number\n failed: number\n errored: number\n unjudged: number\n evals: number\n} {\n const totals = { passed: 0, failed: 0, errored: 0, unjudged: 0, evals: 0 }\n for (const subject of subjects) {\n totals.passed += subject.passed\n totals.failed += subject.failed\n totals.errored += subject.errored\n totals.unjudged += subject.unjudged\n totals.evals += subject.evals.length\n }\n return totals\n}\n\nfunction truncate(value: string, max: number): string {\n const collapsed = value.replace(/\\s+/g, ' ').trim()\n return collapsed.length > max ? `${collapsed.slice(0, max - 1)}…` : collapsed\n}\n\nexport const skillsEvalCommand = defineCommand({\n meta: {\n name: 'eval',\n description:\n 'Run behaviour evals for the seo skill against a local agent and judge the results',\n },\n args: {\n subject: {\n type: 'positional',\n required: false,\n description:\n 'Eval subject (report id or job). Omit to run every subject.',\n },\n list: {\n type: 'boolean',\n default: false,\n description: 'List eval subjects with their eval counts and exit.',\n },\n id: {\n type: 'string',\n description: 'Run one eval id within a single subject.',\n },\n agent: {\n type: 'string',\n default: DEFAULT_AGENT,\n description:\n 'Agent command. Use {prompt} to place the prompt in argv, otherwise it is sent on stdin.',\n },\n 'judge-agent': {\n type: 'string',\n description: 'Judge command. Defaults to the same command as --agent.',\n },\n judge: defaultTrueBooleanArg(\n 'Judge assertions with an agent.',\n 'Skip judging and print replies with an assertion checklist.',\n ),\n skill: defaultTrueBooleanArg(\n 'Send the seo router skill as context before the prompt.',\n 'Omit the seo router skill context.',\n ),\n timeout: {\n type: 'string',\n default: String(DEFAULT_TIMEOUT_SECONDS),\n description: 'Timeout in seconds per agent or judge call.',\n },\n concurrency: {\n type: 'string',\n default: '1',\n description: `Evals to run in parallel (max ${MAX_CONCURRENCY}).`,\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n\n if (args.list === true) {\n renderList(json)\n return\n }\n\n const requested = collectSubjects(args)\n const selected = resolveSelectedSubjects(requested)\n\n const idFilter = numberArg(args.id)\n if (idFilter !== undefined && selected.length !== 1) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--id needs exactly one subject. Name the subject to filter.',\n )\n }\n\n const timeoutSeconds = numberArg(args.timeout) ?? DEFAULT_TIMEOUT_SECONDS\n if (!(timeoutSeconds > 0)) {\n throw new SeoError(\n 'INVALID_INPUT',\n '--timeout must be a positive number of seconds.',\n )\n }\n const concurrency = Math.max(\n 1,\n Math.min(MAX_CONCURRENCY, numberArg(args.concurrency) ?? 1),\n )\n\n const agent = stringArg(args.agent) ?? DEFAULT_AGENT\n const judgeEnabled = args.judge !== false\n const judge = judgeEnabled\n ? (stringArg(args['judge-agent']) ?? agent)\n : null\n const skillBody = args.skill === false ? null : routerSkillBody()\n\n const runOptions: RunOptions = {\n agent,\n judge,\n skillBody,\n timeoutMs: timeoutSeconds * 1000,\n }\n\n const subjectResults: SubjectResult[] = []\n for (const entry of selected) {\n const doc = loadEvalFile(entry.subject, entry.path)\n let items = doc.evals\n if (idFilter !== undefined) {\n items = items.filter((item) => item.id === idFilter)\n if (items.length === 0) {\n throw new SeoError(\n 'INVALID_INPUT',\n `No eval with id ${idFilter} in subject ${entry.subject}.`,\n )\n }\n }\n if (!json) {\n process.stderr.write(\n `Running ${items.length} eval${items.length === 1 ? '' : 's'} for ${entry.subject}...\\n`,\n )\n }\n const evals = await mapWithConcurrency(items, concurrency, (item) =>\n runSingleEval(item, runOptions),\n )\n const counts = tally(evals)\n subjectResults.push({ subject: entry.subject, ...counts, evals })\n }\n\n const totals = totalCounts(subjectResults)\n const failed = totals.failed > 0 || totals.errored > 0\n\n if (json) {\n printJson({\n schemaVersion: SCHEMA_VERSION,\n agent,\n judge,\n judged: judge !== null,\n skillContext: skillBody !== null,\n timeoutSeconds,\n concurrency,\n subjects: subjectResults,\n totals,\n })\n } else {\n renderHuman(subjectResults, { judged: judge !== null, agent, judge })\n }\n\n if (failed) process.exitCode = 1\n },\n})\n","import { existsSync, readdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { SeoError } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag, stringArg } from '../args.js'\nimport {\n printCallout,\n printHeading,\n printJson,\n printKeyValue,\n} from '../utils.js'\nimport { installSeoSkill } from './skill-install.js'\nimport { readSkillDescription, skillsDirectory } from './skill-paths.js'\nimport { skillsEvalCommand } from './skills-eval.js'\n\ntype SkillInfo = {\n name: string\n description: string\n path: string\n}\n\nfunction listSkills(): SkillInfo[] {\n const root = skillsDirectory()\n return readdirSync(root, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && existsSync(join(root, entry.name, 'SKILL.md')),\n )\n .map((entry) => ({\n name: entry.name,\n description: readSkillDescription(join(root, entry.name)),\n path: join(root, entry.name),\n }))\n .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n}\n\nfunction selectedSkill(name?: string): SkillInfo[] {\n const skills = listSkills()\n if (!name) return skills\n const skill = skills.find((entry) => entry.name === name)\n if (!skill) {\n throw new SeoError('INVALID_INPUT', `Unknown skill: ${name}.`)\n }\n return [skill]\n}\n\nconst listCommand = defineCommand({\n meta: { name: 'list', description: 'Show the packaged SEO skill' },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const skills = listSkills()\n if (jsonFlag(args)) {\n printJson({ skills })\n return\n }\n printHeading('SEO skill', 'Packaged with this CLI.')\n process.stdout.write('\\n')\n for (const skill of skills) {\n printKeyValue([\n ['Name', skill.name],\n [\n 'Purpose',\n 'Helps agents choose and run the right SEO audit or report.',\n ],\n ['Path', skill.path],\n ])\n }\n process.stdout.write('\\n')\n printCallout({\n title: 'Add it to an agent',\n body: 'Run setup to install the skill and connect your first site.',\n command: 'seo start',\n })\n },\n})\n\nconst pathCommand = defineCommand({\n meta: { name: 'path', description: 'Print a packaged agent skill path' },\n args: {\n name: {\n type: 'positional',\n description: 'Skill name. Omit it for the skill directory.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const name = stringArg(args.name)\n const path = name ? selectedSkill(name)[0]?.path : skillsDirectory()\n if (jsonFlag(args)) {\n printJson({ name, path })\n } else {\n process.stdout.write(`${path}\\n`)\n }\n },\n})\n\nconst installCommand = defineCommand({\n meta: {\n name: 'install',\n description: 'Install the SEO skill for coding agents',\n },\n args: {\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: ({ args }) => {\n const json = jsonFlag(args)\n const result = installSeoSkill({ quiet: json })\n if (json) {\n printJson(result)\n if (result.status === 'failed') process.exitCode = 1\n return\n }\n if (result.status === 'failed') {\n throw new SeoError(\n 'INTERNAL_ERROR',\n `Skill install failed: ${result.error}`,\n )\n }\n process.stdout.write(\n 'SEO skill installed. Agents that support skills can discover it now.\\n',\n )\n },\n})\n\nexport const skillsCommand = defineCommand({\n meta: {\n name: 'skill',\n description: 'Inspect the packaged SEO skill and run its evals',\n },\n subCommands: {\n list: listCommand,\n path: pathCommand,\n install: installCommand,\n eval: skillsEvalCommand,\n },\n})\n","import { rmSync } from 'node:fs'\nimport { cancel, confirm } from '@clack/prompts'\nimport {\n deleteTokens,\n getCacheStats,\n getPrivacySnapshot,\n getSeoCliPaths,\n listSearchUpdates,\n listSites,\n SeoError,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { booleanArg, jsonFlag, numberArg, stringArg } from '../args.js'\nimport {\n canPrompt,\n formatBytes,\n maybeExitCancelled,\n printJson,\n printKeyValue,\n printSummaryList,\n printTable,\n} from '../utils.js'\n\nexport const privacyCommand = defineCommand({\n meta: {\n name: 'privacy',\n description: 'Show local config, token, cache, and log storage paths',\n },\n run: async () => {\n const snapshot = getPrivacySnapshot()\n const stats = getCacheStats()\n printKeyValue(\n snapshot.map((item) => [\n item.label,\n `${item.path} · ${formatBytes(item.sizeBytes)} · ${item.mode}`,\n ]),\n )\n process.stdout.write('\\n')\n printKeyValue(\n Object.entries(stats.counts).map(([key, value]) => [key, String(value)]),\n )\n },\n})\n\nexport const resetCommand = defineCommand({\n meta: {\n name: 'reset',\n description: 'Delete local seo config, tokens, cache, and logs',\n },\n args: {\n yes: {\n type: 'boolean',\n default: false,\n description: 'Confirm deletion without prompting.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const paths = getSeoCliPaths()\n const json = jsonFlag(args)\n if (!args.yes && !canPrompt({ json })) {\n throw new SeoError(\n 'INVALID_INPUT',\n 'Cannot prompt here. Pass --yes to confirm reset.',\n )\n }\n const approved = args.yes\n ? true\n : maybeExitCancelled(\n await confirm({\n message: 'Delete config, tokens, cache, and logs?',\n initialValue: false,\n }),\n )\n if (!approved) {\n cancel('Reset aborted.')\n return\n }\n await deleteTokens()\n rmSync(paths.configDir, { recursive: true, force: true })\n rmSync(paths.cacheDir, { recursive: true, force: true })\n rmSync(paths.logDir, { recursive: true, force: true })\n if (json) {\n printJson({ reset: true })\n } else {\n process.stdout.write('Reset complete.\\n')\n }\n },\n})\n\nexport const sitesCommand = defineCommand({\n meta: {\n name: 'sites',\n description:\n 'List Search Console properties available to this Google login',\n },\n args: {\n json: { type: 'boolean', default: false },\n refresh: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const sites = await listSites(booleanArg(args.refresh))\n if (jsonFlag(args)) {\n printJson({ sites })\n return\n }\n printTable(\n ['Property', 'Permission'],\n sites.map((site) => [site.siteUrl, site.permissionLevel ?? 'unknown']),\n )\n },\n})\n\nexport const updatesCommand = defineCommand({\n meta: {\n name: 'updates',\n description: 'List official Google Search Status ranking updates',\n },\n args: {\n product: { type: 'string', default: 'Ranking' },\n limit: { type: 'string', default: '10' },\n json: { type: 'boolean', default: false },\n },\n run: async ({ args }) => {\n const updates = await listSearchUpdates({\n product: stringArg(args.product),\n limit: numberArg(args.limit),\n })\n if (jsonFlag(args)) {\n printJson({ updates })\n return\n }\n printSummaryList(\n updates.map((update) => ({\n title: update.name,\n meta: [\n update.type,\n update.status,\n `${update.start.slice(0, 10)} to ${update.end?.slice(0, 10) ?? 'present'}`,\n ],\n })),\n { empty: 'No matching Google Search updates.' },\n )\n },\n})\n","import {\n getTelemetryStatus,\n setTelemetryEnabled,\n type TelemetryDisableReason,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport { jsonFlag } from '../args.js'\nimport { printJson, printKeyValue } from '../utils.js'\n\nconst reasonLabels: Record<TelemetryDisableReason, string> = {\n ci: 'disabled automatically in CI or tests',\n do_not_track: 'disabled by DO_NOT_TRACK',\n environment: 'disabled by a telemetry environment variable',\n local_setting: 'disabled in local settings',\n invalid_state: 'disabled because the local state file is invalid',\n}\n\nfunction statusOutput(status: ReturnType<typeof getTelemetryStatus>) {\n return {\n enabled: status.enabled,\n ...(status.reason ? { reason: status.reason } : {}),\n stateFile: status.stateFile,\n ...(status.state\n ? {\n firstRunAt: status.state.firstRunAt,\n cohort: status.state.cohort,\n sentMilestones: status.state.sentMilestones,\n }\n : {}),\n }\n}\n\nfunction printStatus(\n status: ReturnType<typeof getTelemetryStatus>,\n json: boolean,\n): void {\n const output = statusOutput(status)\n if (json) {\n printJson(output)\n return\n }\n printKeyValue([\n ['Anonymous telemetry', status.enabled ? 'enabled' : 'disabled'],\n ['Reason', status.reason ? reasonLabels[status.reason] : 'local setting'],\n ['State file', status.stateFile],\n ['Install cohort', status.state?.cohort ?? 'not created'],\n ])\n process.stdout.write(\n '\\nOnly tool usage is sent. URLs, report data, Google data, and identifiers are never sent.\\n',\n )\n process.stdout.write('Details: https://seoskill.dev/telemetry\\n')\n}\n\nconst jsonArg = {\n type: 'boolean' as const,\n default: false,\n description: 'Print machine-readable JSON.',\n}\n\nexport const telemetryCommand = defineCommand({\n meta: {\n name: 'telemetry',\n description: 'Check or change anonymous usage telemetry',\n },\n subCommands: {\n status: defineCommand({\n meta: {\n name: 'status',\n description: 'Show whether anonymous usage telemetry is enabled',\n },\n args: { json: jsonArg },\n run: async ({ args }) =>\n printStatus(getTelemetryStatus(), jsonFlag(args)),\n }),\n enable: defineCommand({\n meta: {\n name: 'enable',\n description: 'Enable anonymous usage telemetry in local settings',\n },\n args: { json: jsonArg },\n run: async ({ args }) => {\n printStatus(setTelemetryEnabled(true), jsonFlag(args))\n },\n }),\n disable: defineCommand({\n meta: {\n name: 'disable',\n description: 'Disable anonymous usage telemetry in local settings',\n },\n args: { json: jsonArg },\n run: async ({ args }) => {\n printStatus(setTelemetryEnabled(false), jsonFlag(args))\n },\n }),\n },\n})\n","import { readFile } from 'node:fs/promises'\nimport { crawlImplementationQueueWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n csvArg,\n fetchRateArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails } from '../output.js'\nimport { startUrlForSite } from '../shared.js'\nimport { printWorkflow } from './output.js'\n\nexport const crawlQueueCommand = defineCommand({\n meta: {\n name: 'crawl-queue',\n description: 'Run a crawl and return a ranked implementation queue',\n },\n args: {\n crawlUrl: {\n type: 'positional',\n required: false,\n description: 'Start URL to crawl.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Optional when --project has a saved crawl URL.',\n },\n site: {\n type: 'string',\n description: 'GSC property URL for joining page metrics.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID for landing-page sessions. Defaults from --project when saved.',\n },\n mode: {\n type: 'string',\n description:\n 'Crawl mode: site, page, list, or sitemap. Defaults to site.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs for list mode.',\n },\n 'urls-file': {\n type: 'string',\n description: 'File with one URL per line for list mode.',\n },\n 'max-pages': {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 500.',\n },\n 'max-depth': {\n type: 'string',\n description: 'Maximum click depth. Defaults to 16.',\n },\n concurrency: {\n type: 'string',\n description: 'Parallel page fetches. Defaults to 8.',\n },\n 'fetch-interval-cap': {\n type: 'string',\n description: 'Maximum page fetches per interval per host.',\n },\n 'fetch-interval-ms': {\n type: 'string',\n description: 'Fetch rate interval in milliseconds.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP cache and fetch fresh pages.',\n },\n include: {\n type: 'string',\n description: 'Comma-separated URL patterns to include.',\n },\n exclude: {\n type: 'string',\n description: 'Comma-separated URL patterns to exclude.',\n },\n limit: {\n type: 'string',\n description: 'Maximum queue items to print. Defaults to 25.',\n },\n 'no-sitemap': {\n type: 'boolean',\n default: false,\n description: 'Do not seed URLs from sitemap.xml.',\n },\n 'no-robots': {\n type: 'boolean',\n default: false,\n description: 'Do not skip URLs disallowed by robots.txt.',\n },\n 'no-external': {\n type: 'boolean',\n default: false,\n description: 'Do not check external links.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const project = projectArg(args)\n const urls = await urlListArgs(args)\n const explicitUrl = crawlUrlArg(args)\n const selection =\n stringArg(args.site) || project || (!explicitUrl && !urls.length)\n ? await resolveClientSelection({\n client: project,\n site: stringArg(args.site),\n options: { json },\n })\n : undefined\n const crawlUrl =\n explicitUrl ??\n selection?.client?.startUrl ??\n (selection?.site ? startUrlForSite(selection.site) : undefined) ??\n urls[0]\n if (!crawlUrl) {\n throw new Error(\n 'No crawl URL selected. Pass a URL, --url, or use --project with a saved crawl URL.',\n )\n }\n\n const report = await crawlImplementationQueueWorkflow({\n url: crawlUrl,\n projectId: selection?.client?.id,\n site: selection?.site,\n mode: crawlModeArg(args.mode) ?? (urls.length ? 'list' : undefined),\n urls,\n maxPages: numberArg(args['max-pages']),\n maxDepth: numberArg(args['max-depth']),\n concurrency: numberArg(args.concurrency),\n refresh: booleanArg(args.refresh),\n fetchRate: fetchRateArg({\n ...args,\n 'fetch-concurrency': args.concurrency,\n }),\n include: csvArg(args.include),\n exclude: csvArg(args.exclude),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection?.client?.analytics.google?.propertyId,\n useSitemap: !negatedBooleanArg(args, 'sitemap'),\n respectRobots: !negatedBooleanArg(args, 'robots'),\n checkExternal: !negatedBooleanArg(args, 'external'),\n js: Boolean(booleanArg(args.js)),\n limit: numberArg(args.limit),\n })\n\n if (json) {\n printJson(report)\n return\n }\n\n printWorkflow(report)\n printTable(\n ['Rank', 'Score', 'Rule', 'Severity', 'Affected', 'Target', 'Action'],\n report.output.queue.map((item, index) => [\n index + 1,\n item.score,\n item.ruleId,\n item.severity,\n item.affectedUrls,\n item.target,\n item.action,\n ]),\n )\n printActionDetails(\n 'Implementation queue details',\n report.output.queue.map((item) => ({\n label: `${item.ruleId} (${item.affectedUrls} URLs)`,\n context: `${item.severity}, score ${item.score}`,\n action: `${item.action} Verify with: ${item.verification.command}`,\n })),\n )\n },\n})\n\nfunction crawlModeArg(value: unknown) {\n const mode = stringArg(value)\n if (!mode) return undefined\n if (['site', 'page', 'list', 'sitemap'].includes(mode)) {\n return mode as 'site' | 'page' | 'list' | 'sitemap'\n }\n throw new Error('Mode must be one of: site, page, list, sitemap.')\n}\n\nfunction crawlUrlArg(args: Record<string, unknown>): string | undefined {\n const positional = stringArg(args.crawlUrl)\n const flag = stringArg(args.url)\n if (positional && flag && positional !== flag) {\n throw new Error('Use either a URL argument or --url, not both.')\n }\n return positional ?? flag\n}\n\nasync function urlListArgs(args: Record<string, unknown>): Promise<string[]> {\n const urls = csvArg(args.urls) ?? []\n const file = stringArg(args['urls-file'])\n if (file) urls.push(...parseUrlList(await readFile(file, 'utf8')))\n return [...new Set(urls)]\n}\n\nfunction parseUrlList(value: string): string[] {\n return value\n .split(/[\\n,]/)\n .map((item) => item.trim())\n .filter((item) => item && !item.startsWith('#'))\n}\n","import {\n type CrawlReport,\n diagnosePropertyWorkflow,\n type ReportHtmlSection,\n resolveTechnicalBaseline,\n reviewObservations,\n SeoError,\n type TechnicalBaseline,\n topFixes,\n} from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n negatedBooleanArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { truncate } from '../output.js'\nimport {\n printReportHtmlPath,\n reportHtmlArgs,\n reportHtmlOptions,\n writeReportHtml,\n} from '../report-html.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { startUrlForSite } from '../shared.js'\nimport { printWorkflow } from './output.js'\n\ntype DiagnoseWorkflowReport = Awaited<\n ReturnType<typeof diagnosePropertyWorkflow>\n>\n\nfunction compactMainReportJson(\n report: DiagnoseWorkflowReport,\n workflowName?: string,\n) {\n const { narrative } = report.output\n const { diagnosis } = narrative\n\n return {\n ...report,\n ...(workflowName ? { workflow: workflowName } : {}),\n output: {\n narrative: {\n site: narrative.site,\n generatedAt: narrative.generatedAt,\n dataStatus: narrative.dataStatus,\n periodDays: narrative.periodDays,\n period: narrative.period,\n headline: narrative.headline,\n caveats: narrative.caveats,\n sections: narrative.sections,\n priorities: narrative.priorities,\n diagnosis: {\n site: diagnosis.site,\n generatedAt: diagnosis.generatedAt,\n dataStatus: diagnosis.dataStatus,\n summary: diagnosis.summary,\n skippedSections: diagnosis.skippedSections,\n partialReasons: diagnosis.partialReasons,\n priorities: diagnosis.priorities,\n },\n },\n },\n }\n}\n\nfunction shellArg(value: string): string {\n if (/^[A-Za-z0-9_./:@-]+$/.test(value)) {\n return value\n }\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\nfunction siteForDirectUrl(url: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new SeoError('INVALID_INPUT', 'Pass a valid absolute URL with --url.')\n }\n}\n\nfunction addFollowup(\n commands: Array<{ command: string; why: string }>,\n command: string,\n why: string,\n): void {\n if (commands.some((item) => item.command === command)) {\n return\n }\n commands.push({ command, why })\n}\n\nfunction crawlDataSourceLines(\n dataSources: CrawlReport['dataSources'],\n): string[] {\n if (!dataSources) return []\n\n const sourceLine = (input: {\n label: string\n status: string\n joinedPages: number\n totalPages: number\n window?: { days: number }\n warning?: string\n }): string => {\n const range = input.window ? ` in the last ${input.window.days} days` : ''\n const coverage = `for ${input.joinedPages} of ${input.totalPages} crawled URLs`\n\n if (input.status === 'skipped') return `${input.label}: not connected.`\n if (input.status === 'unavailable') {\n return `${input.label}: unavailable. ${input.warning ?? 'No data was joined.'}`\n }\n if (input.status === 'partial') {\n return `${input.label}: partial data ${coverage}${range}. ${input.warning ?? ''}`.trim()\n }\n if (input.status === 'none') {\n return `${input.label}: no matching crawled URLs${range}.`\n }\n return `${input.label}: joined ${coverage}${range}.`\n }\n\n return [\n sourceLine({\n label: 'Search Console',\n status: dataSources.searchConsole.status,\n joinedPages: Math.max(\n dataSources.searchConsole.joinedMetricPages,\n dataSources.searchConsole.joinedQueryPages,\n ),\n totalPages: dataSources.searchConsole.totalPages,\n window: dataSources.searchConsole.window,\n warning: dataSources.searchConsole.warning,\n }),\n sourceLine({\n label: 'Google Analytics',\n status: dataSources.analytics.status,\n joinedPages: dataSources.analytics.joinedPages,\n totalPages: dataSources.analytics.totalPages,\n window: dataSources.analytics.window,\n warning: dataSources.analytics.warning,\n }),\n ]\n}\n\nfunction technicalSection(baseline: TechnicalBaseline) {\n const report = baseline.report\n if (!report) {\n return {\n status: baseline.status,\n ...(baseline.reason ? { reason: baseline.reason } : {}),\n }\n }\n return {\n status: baseline.status,\n ...(baseline.reason ? { reason: baseline.reason } : {}),\n reportId: report.id,\n generatedAt: report.generatedAt,\n crawlStatus: report.status,\n capped: report.summary.pageLimitReached,\n maxPages: report.config.maxPages,\n searchDataJoined:\n (report.dataSources?.searchConsole.joinedMetricPages ?? 0) > 0 ||\n (report.dataSources?.searchConsole.joinedQueryPages ?? 0) > 0,\n dataSources: report.dataSources,\n summary: report.summary,\n topFixes: topFixes(report, { limit: 5 }),\n reviewObservations: reviewObservations(report, { limit: 5 }),\n }\n}\n\nfunction compactTechnicalFinding(finding: ReturnType<typeof topFixes>[number]) {\n return {\n ruleId: finding.ruleId,\n title: finding.title,\n category: finding.category,\n severity: finding.severity,\n recommendation: finding.recommendation,\n count: finding.count,\n sampleUrls: finding.sampleUrls.slice(0, 3),\n score: finding.score,\n scoreFactors: finding.scoreFactors,\n whyThisRanks: finding.whyThisRanks,\n detailsCommand: `seo explain --rule ${finding.ruleId}`,\n }\n}\n\nfunction compactTechnicalSection(section: ReturnType<typeof technicalSection>) {\n if (!('topFixes' in section)) return section\n\n return {\n ...section,\n topFixes: section.topFixes.slice(0, 3).map(compactTechnicalFinding),\n reviewObservations: section.reviewObservations\n .slice(0, 3)\n .map(compactTechnicalFinding),\n }\n}\n\nfunction printTechnicalSection(\n section: ReturnType<typeof technicalSection>,\n options: { providerFree?: boolean } = {},\n): void {\n if (!('topFixes' in section)) {\n process.stdout.write(\n `\\nTechnical crawl evidence: ${section.reason ?? section.status}\\n`,\n )\n return\n }\n\n const coverage = section.status === 'reused' ? 'saved' : 'new'\n process.stdout.write(`\\nTechnical crawl evidence (${coverage})\\n`)\n if (section.reason) process.stdout.write(`${section.reason}\\n`)\n if (section.capped) {\n process.stdout.write(\n `Coverage is capped at ${section.maxPages} pages. Run \\`seo crawl\\` for a broader investigation.\\n`,\n )\n }\n if (!options.providerFree) {\n for (const line of crawlDataSourceLines(section.dataSources)) {\n process.stdout.write(`${line}\\n`)\n }\n }\n if (!section.topFixes.length) {\n process.stdout.write('No prioritised technical fixes were found.\\n')\n if (section.reviewObservations.length) {\n process.stdout.write(\n `${section.reviewObservations.length} review observation${section.reviewObservations.length === 1 ? '' : 's'} need confirmation before they become implementation work.\\n`,\n )\n }\n return\n }\n process.stdout.write(\n options.providerFree\n ? '\\nPrioritised technical fixes\\n'\n : section.searchDataJoined\n ? '\\nTechnical fixes with search value\\n'\n : '\\nTechnical fixes (no Search Console data joined)\\n',\n )\n if (!section.searchDataJoined) {\n printTable(\n ['#', 'Rule', 'Severity', 'Affected URLs', 'Verify'],\n section.topFixes.map((fix, index) => [\n index + 1,\n fix.ruleId,\n fix.severity,\n fix.count,\n truncate(fix.howToVerify, 72),\n ]),\n )\n } else {\n printTable(\n ['Score', 'Rule', 'Severity', 'Search value', 'Verify'],\n section.topFixes.map((fix) => [\n fix.score,\n fix.ruleId,\n fix.severity,\n `${fix.scoreFactors.clicks} clicks / ${fix.scoreFactors.sessions} sessions / ${fix.scoreFactors.conversions} conv.`,\n truncate(fix.howToVerify, 72),\n ]),\n )\n }\n if (section.reviewObservations.length) {\n process.stdout.write(\n `\\n${section.reviewObservations.length} review observation${section.reviewObservations.length === 1 ? '' : 's'} were kept out of this action queue.\\n`,\n )\n }\n}\n\nfunction printSkippedProviderSections(\n section: ReturnType<typeof technicalSection>,\n): void {\n process.stdout.write('\\nProvider-backed sections skipped\\n')\n const observedLines =\n 'dataSources' in section ? crawlDataSourceLines(section.dataSources) : []\n const lines = observedLines.length\n ? observedLines\n : ['Search Console: not connected.', 'Google Analytics: not connected.']\n for (const line of lines) {\n process.stdout.write(`${line}\\n`)\n }\n process.stdout.write(\n 'Run `seo start` when you want traffic, query, ranking, and analytics evidence added to the report.\\n',\n )\n}\n\nfunction mainReportHtmlSections(input: {\n technicalCrawl?: ReturnType<typeof technicalSection>\n followups?: Array<{ command: string; why: string }>\n}): ReportHtmlSection[] {\n const sections: ReportHtmlSection[] = []\n const technical = input.technicalCrawl\n if (technical) {\n if ('topFixes' in technical) {\n sections.push({\n title: 'Technical crawl evidence',\n summary: `${technical.summary.crawledUrls} pages were included in the ${technical.status === 'reused' ? 'saved' : 'new'} crawl evidence.`,\n items: [\n ...technical.topFixes.map(\n (fix) =>\n `${fix.ruleId}: ${fix.title}. ${fix.count} affected URLs. ${fix.recommendation}`,\n ),\n ...crawlDataSourceLines(technical.dataSources),\n ],\n })\n } else {\n sections.push({\n title: 'Technical crawl evidence',\n summary:\n technical.reason ?? `Technical evidence was ${technical.status}.`,\n items: [],\n })\n }\n }\n if (input.followups?.length) {\n sections.push({\n title: 'Recommended next commands',\n items: input.followups.map((item) => `${item.command}: ${item.why}`),\n })\n }\n return sections\n}\n\nfunction technicalFirstSummary(\n section: ReturnType<typeof technicalSection>,\n): string {\n if (!('topFixes' in section)) {\n return `Technical crawl evidence was ${section.status}. Search Console and Google Analytics sections were skipped because they are not connected.`\n }\n\n const source = section.status === 'reused' ? 'Loaded' : 'Completed'\n const pages = section.summary.crawledUrls\n return `${source} a technical crawl of ${pages} ${pages === 1 ? 'page' : 'pages'}. Search Console and Google Analytics sections were skipped because they are not connected.`\n}\n\nfunction technicalWorkflowStep(section: ReturnType<typeof technicalSection>): {\n tool: string\n status: 'completed' | 'skipped'\n summary: string\n} {\n if (!('topFixes' in section)) {\n return {\n tool: 'seo_crawl',\n status: 'skipped',\n summary:\n section.reason ?? `Technical crawl evidence was ${section.status}.`,\n }\n }\n\n const pages = section.summary.crawledUrls\n return {\n tool: 'seo_crawl',\n status: 'completed',\n summary: `${section.status === 'reused' ? 'Loaded' : 'Completed'} technical evidence for ${pages} crawled ${pages === 1 ? 'page' : 'pages'}.`,\n }\n}\n\nexport function reportFollowups(\n report: DiagnoseWorkflowReport,\n input: {\n crawlStartUrl?: string\n projectId?: string\n technicalBaselineStatus?: TechnicalBaseline['status']\n searchDataAvailable?: boolean\n } = {},\n) {\n if (input.searchDataAvailable === false) {\n const commands: Array<{ command: string; why: string }> = []\n if (\n input.crawlStartUrl &&\n input.technicalBaselineStatus !== 'created' &&\n input.technicalBaselineStatus !== 'refreshed' &&\n input.technicalBaselineStatus !== 'reused'\n ) {\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --health`,\n 'Run the fast sitemap response and access gate before fetching page bodies.',\n )\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --save`,\n 'Create the technical crawl that this report needs before opening a page-level follow-up.',\n )\n } else if (input.crawlStartUrl) {\n addFollowup(\n commands,\n `seo audit-page --url ${shellArg(input.crawlStartUrl)}`,\n 'Inspect one important page in detail after the site-level crawl.',\n )\n }\n addFollowup(\n commands,\n 'seo start',\n 'Connect Search Console when you want traffic, query, and ranking evidence alongside the crawl.',\n )\n return commands\n }\n\n const identity = input.projectId\n ? `--project ${shellArg(input.projectId)}`\n : `--site ${shellArg(report.site)}`\n const diagnosis = report.output.narrative.diagnosis\n const days = diagnosis.decay.rangeDays\n const commands: Array<{ command: string; why: string }> = []\n const skippedNames = new Set(\n (diagnosis.skippedSections ?? []).map((section) => section.section),\n )\n\n addFollowup(\n commands,\n `seo refresh-priorities ${identity} --days ${days} --verify-content --limit 25`,\n 'Turn the report into a ranked action queue with content checks.',\n )\n\n if (diagnosis.decay.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo decaying ${identity} --days ${days} --limit 25`,\n 'Inspect query/page declines observed in both retained-row windows.',\n )\n }\n\n if (diagnosis.cannibalization.items.length > 0) {\n addFollowup(\n commands,\n `seo cannibal ${identity} --days ${days} --limit 25`,\n 'Find queries split across competing URLs.',\n )\n }\n\n if (diagnosis.quickWins.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo quick-wins ${identity} --days ${days} --verify-content --verify-limit 5`,\n 'Review average-position rows below their heuristic CTR target with optional page evidence.',\n )\n }\n\n if (diagnosis.strikingDistance.summary.eligibleRows > 0) {\n addFollowup(\n commands,\n `seo second-page ${identity} --days ${days} --verify-content --verify-limit 5`,\n 'Work pages sitting just outside page-one rankings.',\n )\n }\n\n if (\n skippedNames.has('traffic anomaly') ||\n skippedNames.has('update correlation')\n ) {\n addFollowup(\n commands,\n `seo quick-wins ${identity} --days ${days} --min-impressions 10 --verify-content --verify-limit 5`,\n 'Sparse GSC data: lower thresholds and look for early content wins.',\n )\n addFollowup(\n commands,\n `seo second-page ${identity} --days ${days} --min-impressions 10 --verify-content --verify-limit 5`,\n 'Sparse GSC data: inspect early second-page opportunities.',\n )\n }\n\n const topMovedPage = diagnosis.segments.page.items.find((item) =>\n item.key.startsWith('http'),\n )\n if (topMovedPage) {\n addFollowup(\n commands,\n `seo audit-page --url ${shellArg(topMovedPage.key)}`,\n 'Audit the biggest moved URL for title, metadata, links, and schema.',\n )\n }\n\n if (\n input.crawlStartUrl &&\n input.technicalBaselineStatus !== 'created' &&\n input.technicalBaselineStatus !== 'refreshed' &&\n input.technicalBaselineStatus !== 'reused'\n ) {\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} --health`,\n 'Run the fast sitemap response and access gate before fetching page bodies.',\n )\n addFollowup(\n commands,\n `seo crawl --url ${shellArg(input.crawlStartUrl)} ${identity} --save`,\n 'Create the first technical crawler baseline with plain-English fixes and JSON-ready issue data.',\n )\n }\n\n addFollowup(\n commands,\n `seo technical-watch ${identity} --limit 50`,\n 'Save a crawl/index baseline so future reports can flag technical drift.',\n )\n\n return commands.slice(0, 6)\n}\n\nfunction printReportFollowups(\n commands: Array<{ command: string; why: string }>,\n): void {\n if (!commands.length) {\n return\n }\n process.stdout.write('\\nRecommended next commands\\n')\n printTable(\n ['Command', 'Why'],\n commands.map((item) => [item.command, item.why]),\n )\n}\n\nfunction printTechnicalOnlyIntro(site: string): void {\n process.stdout.write(`# Technical SEO report: ${site}\\n\\n`)\n}\n\nfunction workflowCommandMeta(input: {\n name: string\n description: string\n workflowName?: string\n printFollowups?: boolean\n}) {\n return defineCommand({\n meta: input,\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n ...(input.printFollowups\n ? {\n url: {\n type: 'string' as const,\n description:\n 'Crawl URL for a technical-only report. Search Console analyses are skipped unless you also pass --site or --project.',\n },\n }\n : {}),\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Search performance window in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum rows per section. Defaults to 10.',\n },\n },\n ),\n ...(input.printFollowups\n ? {\n crawl: defaultTrueBooleanArg(\n 'Create or reuse a bounded technical crawl before the report.',\n 'Skip technical crawl evidence for this report.',\n ),\n 'crawl-max-pages': {\n type: 'string' as const,\n description:\n 'Maximum pages for the report crawl. Defaults to 100.',\n },\n 'crawl-max-depth': {\n type: 'string' as const,\n description:\n 'Maximum link depth for the report crawl. Defaults to 4.',\n },\n full: {\n type: 'boolean' as const,\n default: false,\n description:\n 'Include the full report in JSON output. Default JSON is a compact summary for agents.',\n },\n ...reportHtmlArgs,\n }\n : {}),\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const html = input.printFollowups ? reportHtmlOptions(args) : undefined\n const full = input.printFollowups && booleanArg(args.full)\n const project = projectArg(args)\n const explicitSite = stringArg(args.site)\n const directUrl = input.printFollowups ? stringArg(args.url) : undefined\n const useSearchData = Boolean(project || explicitSite || !directUrl)\n const selection = useSearchData\n ? await resolveClientSelection({\n client: project,\n site: explicitSite,\n options: { json, refresh: booleanArg(args.refresh) },\n })\n : undefined\n const site = selection?.site ?? siteForDirectUrl(directUrl ?? '')\n const report = await diagnosePropertyWorkflow({\n site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection?.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n refresh: booleanArg(args.refresh),\n skipSearchData: !useSearchData,\n })\n const outputReport = input.workflowName\n ? { ...report, workflow: input.workflowName }\n : report\n const technicalBaseline = input.printFollowups\n ? await resolveTechnicalBaseline({\n site,\n searchSite: selection?.site,\n url:\n directUrl ?? selection?.client?.startUrl ?? startUrlForSite(site),\n projectId: selection?.client?.id,\n googleAnalyticsPropertyId:\n selection?.client?.analytics.google?.propertyId,\n crawl: !negatedBooleanArg(args, 'crawl'),\n refresh: booleanArg(args.refresh),\n maxPages: numberArg(args['crawl-max-pages']),\n maxDepth: numberArg(args['crawl-max-depth']),\n })\n : undefined\n const technicalCrawl = technicalBaseline\n ? technicalSection(technicalBaseline)\n : undefined\n const followups = input.printFollowups\n ? reportFollowups(outputReport, {\n crawlStartUrl:\n directUrl ?? selection?.client?.startUrl ?? startUrlForSite(site),\n projectId: selection?.client?.id,\n technicalBaselineStatus: technicalBaseline?.status,\n searchDataAvailable: useSearchData,\n })\n : undefined\n if (json) {\n const jsonReport =\n input.printFollowups && !full\n ? compactMainReportJson(report, input.workflowName)\n : outputReport\n const reportWithTechnicalEvidence =\n !useSearchData && technicalCrawl\n ? {\n ...jsonReport,\n summary: technicalFirstSummary(technicalCrawl),\n steps: [\n technicalWorkflowStep(technicalCrawl),\n ...jsonReport.steps,\n ],\n }\n : jsonReport\n printJson(\n technicalCrawl || followups\n ? {\n ...reportWithTechnicalEvidence,\n ...(input.printFollowups\n ? { detail: full ? 'full' : 'summary' }\n : {}),\n ...(technicalCrawl\n ? {\n technicalCrawl:\n input.printFollowups && !full\n ? compactTechnicalSection(technicalCrawl)\n : technicalCrawl,\n }\n : {}),\n ...(followups ? { nextCommands: followups } : {}),\n }\n : jsonReport,\n )\n return\n }\n if (html) {\n const path = await writeReportHtml({\n report: outputReport.output.narrative,\n reportName: 'report',\n title: useSearchData ? 'SEO report' : 'Technical SEO report',\n options: html,\n projectId: selection?.client?.id,\n additionalSections: mainReportHtmlSections({\n technicalCrawl,\n followups,\n }),\n })\n printReportHtmlPath(path)\n return\n }\n if (useSearchData) {\n process.stdout.write(`${outputReport.output.narrative.markdown}\\n\\n`)\n printWorkflow(outputReport)\n } else {\n printTechnicalOnlyIntro(site)\n }\n if (technicalCrawl) {\n printTechnicalSection(technicalCrawl, { providerFree: !useSearchData })\n if (!useSearchData) printSkippedProviderSections(technicalCrawl)\n }\n if (followups) printReportFollowups(followups)\n },\n })\n}\n\nexport const diagnosePropertyWorkflowCommand = workflowCommandMeta({\n name: 'diagnose-property',\n description: 'Find what changed in Google Search and what to inspect next',\n})\n\nexport const mainReportCommand = workflowCommandMeta({\n name: 'report',\n workflowName: 'report',\n printFollowups: true,\n description:\n 'Run the main SEO report and recommend the next best follow-up commands',\n})\n","import { refreshPrioritiesWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printActionDetails } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\nimport { printWorkflow } from './output.js'\n\nexport const refreshPrioritiesCommand = defineCommand({\n meta: {\n name: 'refresh-priorities',\n description: 'Agent workflow for a ranked SEO action queue',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum queue items to print. Defaults to 25.',\n },\n },\n ),\n 'google-analytics-property': {\n type: 'string',\n description:\n 'Google Analytics property ID to use for analytics value. Defaults from the selected project.',\n },\n 'verify-content': defaultTrueBooleanArg(\n 'Verify top opportunities against page title, meta, and content. Defaults to true.',\n 'Skip page content verification.',\n ),\n 'verify-limit': {\n type: 'string',\n description: 'Maximum opportunity URLs to verify. Defaults to 5.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await refreshPrioritiesWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n googleAnalyticsPropertyId:\n stringArg(args['google-analytics-property']) ??\n selection.client?.analytics.google?.propertyId,\n verifyContent: booleanArg(args['verify-content']),\n verifyLimit: numberArg(args['verify-limit']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printWorkflow(report)\n printTable(\n [\n 'Source',\n 'Category',\n 'Score',\n 'Findings',\n 'Template',\n 'Analytics',\n 'Target',\n 'Action',\n ],\n report.output.queue.map((item) => [\n item.source,\n item.category,\n item.score,\n item.grouped?.count ?? 1,\n item.template?.label ?? '-',\n item.analytics?.sessions ?? '-',\n item.target,\n item.action,\n ]),\n )\n printActionDetails(\n 'Queue action details',\n report.output.queue.map((item) => ({\n label: item.target,\n context: `${item.category}, score ${item.score}`,\n action: item.action,\n })),\n )\n },\n})\n","import { technicalWatchWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n defaultTrueBooleanArg,\n jsonFlag,\n listArg,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson } from '../../utils.js'\nimport { printMonitoringRun } from '../monitoring/output.js'\nimport { startUrlForSite } from '../shared.js'\n\nexport const technicalWatchCommand = defineCommand({\n meta: {\n name: 'technical-watch',\n description: 'Agent workflow for crawl-diff and index-watch monitoring',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n url: {\n type: 'string',\n description:\n 'Start URL to crawl. Defaults from the GSC property when possible.',\n },\n urls: {\n type: 'string',\n description: 'Comma-separated URLs to inspect with URL Inspection.',\n },\n sitemaps: {\n type: 'string',\n description:\n 'Comma-separated XML sitemap URLs for quota-aware index monitoring.',\n },\n properties: {\n type: 'string',\n description:\n 'Comma-separated GSC properties for sitemap index monitoring.',\n },\n limit: {\n type: 'string',\n description: 'Maximum pages to crawl. Defaults to 50.',\n },\n 'daily-limit': {\n type: 'string',\n description: 'URL Inspection daily limit per property. Defaults to 2000.',\n },\n 'inspect-limit': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to inspect in this run. Defaults to 100.',\n },\n 'max-urls': {\n type: 'string',\n description:\n 'Maximum sitemap URLs to load for monitoring. Defaults to 50000.',\n },\n language: {\n type: 'string',\n description: 'Optional URL Inspection language code.',\n },\n 'recover-links': defaultTrueBooleanArg(\n 'Check search-value GSC pages for broken, blocked, or poorly redirected URLs. Defaults to true.',\n 'Skip link recovery checks.',\n ),\n 'recover-days': {\n type: 'string',\n description: 'GSC lookback window for link recovery. Defaults to 90.',\n },\n 'recover-limit': {\n type: 'string',\n description:\n 'Maximum search-value pages to check for link recovery. Defaults to 10.',\n },\n 'recover-min-clicks': {\n type: 'string',\n description:\n 'Minimum clicks for link recovery candidates. Defaults to 1.',\n },\n 'recover-min-impressions': {\n type: 'string',\n description:\n 'Minimum impressions for link recovery candidates. Defaults to 100.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n refresh: {\n type: 'boolean',\n default: false,\n description: 'Bypass local HTTP/GSC cache where supported.',\n },\n js: {\n type: 'boolean',\n default: false,\n description: 'Force JavaScript rendering when Playwright is installed.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const watchUrls = listArg(args.urls)\n const sitemaps = listArg(args.sitemaps)\n const startUrl =\n stringArg(args.url) ??\n selection.client?.startUrl ??\n startUrlForSite(selection.site)\n const report = await technicalWatchWorkflow({\n site: selection.site,\n startUrl,\n urls: watchUrls.length ? watchUrls : selection.client?.watchUrls,\n sitemaps: sitemaps.length ? sitemaps : undefined,\n properties: listArg(args.properties).length\n ? listArg(args.properties)\n : undefined,\n limit: numberArg(args.limit),\n languageCode: stringArg(args.language),\n dailyLimit: numberArg(args['daily-limit']),\n inspectLimit: numberArg(args['inspect-limit']),\n maxUrls: numberArg(args['max-urls']),\n refresh: booleanArg(args.refresh),\n js: booleanArg(args.js) ? true : 'auto',\n recoverLinks: booleanArg(args['recover-links']),\n recoverDays: numberArg(args['recover-days']),\n recoverLimit: numberArg(args['recover-limit']),\n recoverMinClicks: numberArg(args['recover-min-clicks']),\n recoverMinImpressions: numberArg(args['recover-min-impressions']),\n })\n if (json) {\n printJson(report)\n return\n }\n printMonitoringRun(report)\n },\n})\n","import { updatePostmortemWorkflow } from '@seo/core'\nimport { defineCommand } from 'citty'\nimport {\n booleanArg,\n jsonFlag,\n numberArg,\n projectArg,\n stringArg,\n} from '../../args.js'\nimport { resolveClientSelection } from '../../selection.js'\nimport { printJson, printTable } from '../../utils.js'\nimport { printNextCommand, printNotes, printReportSummary } from '../output.js'\nimport { cliReportArgs } from '../report-options.js'\n\ntype SegmentSplit = Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n>['output']['segments']['page']\n\nfunction formatNumber(value: number | null): string {\n if (value === null) return '-'\n return value.toLocaleString('en-GB', {\n maximumFractionDigits: value >= 100 ? 0 : 1,\n })\n}\n\nfunction segmentRows(split: SegmentSplit) {\n return [\n ...split.winners.map((item) => ({ direction: 'winner', item })),\n ...split.losers.map((item) => ({ direction: 'loser', item })),\n ]\n}\n\nfunction printSegmentTable(label: string, split: SegmentSplit): void {\n const rows = segmentRows(split)\n if (!rows.length) return\n process.stdout.write(`\\n${label}\\n`)\n printTable(\n ['Direction', 'Key', 'Clicks', 'Impr.', 'Position'],\n rows.map(({ direction, item }) => [\n direction,\n item.key,\n formatNumber(item.clickDelta),\n formatNumber(item.impressionDelta),\n formatNumber(item.positionDelta),\n ]),\n )\n}\n\nfunction printSegmentCoverage(\n segments: Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n >['output']['segments'],\n): void {\n process.stdout.write('\\nSegment coverage\\n')\n printTable(\n [\n 'Dimension',\n 'Eligible',\n 'Returned',\n 'Limited',\n 'Result cap',\n 'Source cap',\n 'Source capped',\n ],\n (['page', 'query', 'device', 'country'] as const).map((dimension) => {\n const coverage = segments[dimension].coverage\n return [\n dimension,\n coverage.eligibleRows,\n coverage.returnedRows,\n coverage.limitedRows,\n coverage.resultLimit,\n coverage.sourceRowLimit,\n coverage.sourcePossiblyTruncated ? 'yes' : 'no',\n ]\n }),\n )\n}\n\ntype TemplateMovement = Awaited<\n ReturnType<typeof updatePostmortemWorkflow>\n>['output']['templateMovement'][number]\n\nfunction printTemplateMovement(items: TemplateMovement[]): void {\n if (!items.length) return\n process.stdout.write('\\nTemplate movement\\n')\n printTable(\n [\n 'Direction',\n 'Template',\n 'Pattern confidence',\n 'URLs',\n 'Clicks',\n 'Returned share',\n 'Common terms',\n ],\n items.map((item) => [\n item.direction,\n item.signature,\n item.confidence,\n item.urlCount,\n formatNumber(item.clickDelta),\n `${Math.round(item.movementShare * 100)}%`,\n item.commonTerms.join(', ') || '-',\n ]),\n )\n printNotes(\n 'Template actions',\n items.map((item) => item.summary),\n )\n printNotes('Template evidence scope', [\n 'Shares use returned directional page click movement. Pattern confidence applies only to returned matched-retained page segments.',\n ])\n}\n\nexport const updatePostmortemCommand = defineCommand({\n meta: {\n name: 'update-postmortem',\n description: 'Agent workflow for Google update winner/loser analysis',\n },\n args: {\n site: {\n type: 'string',\n description: 'GSC property URL, for example sc-domain:example.com.',\n },\n client: {\n type: 'string',\n description: 'Legacy alias for --project.',\n },\n project: {\n type: 'string',\n description: 'Saved project id or name.',\n },\n ...cliReportArgs(\n ['days', 'recentDays', 'limit', 'includeBrand', 'refresh'],\n {\n days: {\n description: 'Diagnosis window length in days. Defaults to 90.',\n },\n limit: {\n description: 'Maximum winners/losers per segment. Defaults to 20.',\n },\n },\n ),\n 'known-change': {\n type: 'string',\n description:\n 'Manual site-side change to treat as a confounder, for example pruning pages or blocking traffic.',\n },\n 'ignore-change-log': {\n type: 'boolean',\n default: false,\n description: 'Do not use saved change-log entries as confounders.',\n },\n json: {\n type: 'boolean',\n default: false,\n description: 'Print machine-readable JSON.',\n },\n },\n run: async ({ args }) => {\n const json = jsonFlag(args)\n const selection = await resolveClientSelection({\n client: projectArg(args),\n site: stringArg(args.site),\n options: { json, refresh: booleanArg(args.refresh) },\n })\n const report = await updatePostmortemWorkflow({\n site: selection.site,\n days: numberArg(args.days),\n recentDays: numberArg(args.recent),\n limit: numberArg(args.limit),\n brandTerms: selection.client?.brandTerms,\n includeBrand: booleanArg(args['include-brand']),\n knownConfounders: stringArg(args['known-change'])\n ? [stringArg(args['known-change']) ?? '']\n : undefined,\n includeChangeLog: !booleanArg(args['ignore-change-log']),\n refresh: booleanArg(args.refresh),\n })\n if (json) {\n printJson(report)\n return\n }\n printReportSummary({\n title: 'Update postmortem',\n target: report.site,\n status: 'unknown',\n summary: report.summary,\n metrics: [\n {\n label: 'Attribution',\n value: report.output.update.attribution.replaceAll('-', ' '),\n },\n { label: 'Confidence', value: report.output.update.confidence },\n {\n label: 'Known confounders',\n value: report.output.update.confounders.length,\n },\n ],\n })\n printNotes(\n 'Recommended actions',\n report.actions.map(\n (action) => `${action.title} (${action.confidence}): ${action.action}`,\n ),\n )\n printNotes(\n 'Postmortem findings',\n report.output.insights.map((insight) => insight.summary),\n )\n printNotes(\n 'Segment evidence warnings',\n [\n ...report.output.segments.page.warnings,\n ...report.output.segments.query.warnings,\n ...report.output.segments.device.warnings,\n ...report.output.segments.country.warnings,\n ].filter(\n (warning, index, warnings) => warnings.indexOf(warning) === index,\n ),\n )\n printTemplateMovement(report.output.templateMovement)\n printNotes('Update evidence', report.output.update.evidence)\n printSegmentCoverage(report.output.segments)\n printSegmentTable('Page winners and losers', report.output.segments.page)\n printSegmentTable('Query winners and losers', report.output.segments.query)\n printSegmentTable(\n 'Device winners and losers',\n report.output.segments.device,\n )\n printSegmentTable(\n 'Country winners and losers',\n report.output.segments.country,\n )\n const target = selection.client\n ? `--project ${JSON.stringify(selection.client.id)}`\n : `--site ${JSON.stringify(selection.site)}`\n printNextCommand(`seo export update-postmortem ${target}`)\n },\n})\n","import { spawnSync } from 'node:child_process'\nimport { realpathSync } from 'node:fs'\nimport { isCancel, log, select } from '@clack/prompts'\nimport updateNotifier from 'update-notifier'\n\ntype PackageInfo = {\n name: string\n version: string\n}\n\ntype UpdateInfo = {\n current: string\n latest: string\n}\n\ntype UpdateNotifier = {\n update?: UpdateInfo\n}\n\nexport type SelfUpdateCommand = {\n args: string[]\n command: string\n}\n\ntype OfferUpdateOptions = {\n argv?: string[]\n cliPath?: string\n createNotifier?: (pkg: PackageInfo) => UpdateNotifier\n env?: NodeJS.ProcessEnv\n platform?: NodeJS.Platform\n prompt?: (input: {\n command: SelfUpdateCommand\n update: UpdateInfo\n }) => Promise<'later' | 'update'>\n run?: (command: SelfUpdateCommand) => number | null\n stdinIsTty?: boolean\n stdoutIsTty?: boolean\n}\n\nfunction normalizedPath(value: string): string {\n return value.replaceAll('\\\\', '/').toLowerCase()\n}\n\nfunction packageManagerCommand(\n manager: 'bun' | 'npm' | 'pnpm' | 'yarn',\n platform: NodeJS.Platform,\n): string {\n if (platform !== 'win32') return manager\n return `${manager}.cmd`\n}\n\nexport function inferSelfUpdateCommand(\n resolvedCliPath: string,\n platform: NodeJS.Platform = process.platform,\n): SelfUpdateCommand | undefined {\n const path = normalizedPath(resolvedCliPath)\n\n if (\n path.includes('/_npx/') ||\n path.includes('/.npm/_npx/') ||\n path.includes('/.cache/pnpm/dlx/') ||\n path.includes('/.volta/')\n ) {\n return undefined\n }\n\n if (path.includes('/.pnpm/') || path.includes('/pnpm/global/')) {\n return {\n command: packageManagerCommand('pnpm', platform),\n args: ['add', '--global', 'seo@latest'],\n }\n }\n\n if (path.includes('/.bun/install/global/')) {\n return {\n command: packageManagerCommand('bun', platform),\n args: ['add', '--global', 'seo@latest'],\n }\n }\n\n if (path.includes('/.config/yarn/global/')) {\n return {\n command: packageManagerCommand('yarn', platform),\n args: ['global', 'add', 'seo@latest'],\n }\n }\n\n if (path.includes('/node_modules/seo/')) {\n return {\n command: packageManagerCommand('npm', platform),\n args: ['install', '--global', 'seo@latest'],\n }\n }\n\n return undefined\n}\n\nfunction isNewerVersion(current: string, latest: string): boolean {\n const parse = (value: string) =>\n value\n .replace(/^v/, '')\n .split('-')[0]\n ?.split('.')\n .map((part) => Number.parseInt(part, 10)) ?? []\n const currentParts = parse(current)\n const latestParts = parse(latest)\n\n for (let index = 0; index < 3; index += 1) {\n const currentPart = currentParts[index] ?? 0\n const latestPart = latestParts[index] ?? 0\n if (!Number.isFinite(currentPart) || !Number.isFinite(latestPart)) {\n return false\n }\n if (latestPart > currentPart) return true\n if (latestPart < currentPart) return false\n }\n\n return false\n}\n\nexport function canOfferInteractiveUpdate(input: {\n argv: string[]\n env: NodeJS.ProcessEnv\n stdinIsTty: boolean\n stdoutIsTty: boolean\n}): boolean {\n if (!input.stdinIsTty || !input.stdoutIsTty) return false\n if (\n input.env.CI ||\n input.env.NO_UPDATE_NOTIFIER ||\n input.env.NODE_ENV === 'test' ||\n input.env.npm_lifecycle_event ||\n input.env.npm_execpath ||\n input.env.TERM === 'dumb'\n ) {\n return false\n }\n if (input.argv.includes('--json')) return false\n if (\n input.argv.some((arg) => ['--help', '-h', '--version', '-v'].includes(arg))\n ) {\n return false\n }\n if (['help', 'mcp'].includes(input.argv[0] ?? '')) return false\n return true\n}\n\nfunction resolvedCliPath(cliPath: string | undefined): string | undefined {\n if (!cliPath) return undefined\n try {\n return realpathSync(cliPath)\n } catch {\n return cliPath\n }\n}\n\nasync function promptForUpdate(input: {\n command: SelfUpdateCommand\n update: UpdateInfo\n}): Promise<'later' | 'update'> {\n const choice = await select<'later' | 'update'>({\n message: `seo ${input.update.latest} is available. You have ${input.update.current}.`,\n options: [\n {\n value: 'update',\n label: 'Update now',\n hint: [input.command.command, ...input.command.args].join(' '),\n },\n { value: 'later', label: 'Later' },\n ],\n initialValue: 'later',\n })\n return isCancel(choice) ? 'later' : choice\n}\n\nfunction runUpdate(command: SelfUpdateCommand): number | null {\n return spawnSync(command.command, command.args, { stdio: 'inherit' }).status\n}\n\nexport async function maybeOfferSelfUpdate(\n pkg: PackageInfo,\n options: OfferUpdateOptions = {},\n): Promise<number | undefined> {\n const argv = options.argv ?? process.argv.slice(2)\n const env = options.env ?? process.env\n if (\n !canOfferInteractiveUpdate({\n argv,\n env,\n stdinIsTty: options.stdinIsTty ?? Boolean(process.stdin.isTTY),\n stdoutIsTty: options.stdoutIsTty ?? Boolean(process.stdout.isTTY),\n })\n ) {\n return undefined\n }\n\n const path = resolvedCliPath(options.cliPath ?? process.argv[1])\n const command = path\n ? inferSelfUpdateCommand(path, options.platform ?? process.platform)\n : undefined\n if (!command) return undefined\n\n const notifier = (\n options.createNotifier ??\n ((value) =>\n updateNotifier({\n pkg: value,\n shouldNotifyInNpmScript: false,\n }))\n )(pkg)\n const update = notifier.update\n if (!update || !isNewerVersion(update.current, update.latest)) {\n return undefined\n }\n\n const choice = await (options.prompt ?? promptForUpdate)({ command, update })\n if (choice === 'later') return undefined\n\n const status = (options.run ?? runUpdate)(command)\n if (status === 0) {\n log.success(`Updated seo to ${update.latest}. Run your command again.`)\n return 0\n }\n\n log.error('The update failed. Your current version is unchanged.')\n return 1\n}\n","import {\n detectTelemetryAgent,\n initializeTelemetry,\n SEO_VERSION,\n seoErrorEnvelope,\n telemetryErrorCategory,\n toSeoError,\n trackTelemetryReportComplete,\n trackTelemetryReportFailed,\n trackTelemetryReportStart,\n trackTelemetrySetupComplete,\n} from '@seo/core'\nimport { listReports } from '@seo/mcp'\nimport { defineCommand, runCommand, runMain } from 'citty'\nimport { agentReadinessCommand } from './commands/agent-readiness.js'\nimport { analyticsCommand } from './commands/analytics/index.js'\nimport { authCommand } from './commands/auth.js'\nimport { cacheCommand } from './commands/cache.js'\nimport { clientCommand, projectCommand } from './commands/clients/index.js'\nimport { contentCommand } from './commands/content.js'\nimport { crawlCommand } from './commands/crawl.js'\nimport { crawlReportsCommand } from './commands/crawl-reports.js'\nimport { gscQueryCommand, urlInspectCommand } from './commands/data.js'\nimport {\n trafficAnomalyCommand,\n updateCorrelateCommand,\n} from './commands/diagnosis-reports.js'\nimport { entityReadinessCommand } from './commands/entity-readiness.js'\nimport {\n changeLogCommand,\n contentGroupsCommand,\n testsCommand,\n} from './commands/experiments/index.js'\nimport { exportCommand } from './commands/export/index.js'\nimport { indexNowCommand } from './commands/indexnow.js'\nimport { initCommand } from './commands/init.js'\nimport { linksCommand } from './commands/links.js'\nimport { llmsCommand } from './commands/llms.js'\nimport { logsCommand } from './commands/logs.js'\nimport { mcpCommand } from './commands/mcp.js'\nimport {\n crawlDiffCommand,\n indexCoverageCommand,\n indexWatchCommand,\n linkRecoverCommand,\n monitoringCommand,\n redirectTraceCommand,\n} from './commands/monitoring.js'\nimport { okfCommand } from './commands/okf.js'\nimport {\n aiReferralsCommand,\n cannibalCommand,\n communityIntentCommand,\n ctrUnderperformersCommand,\n decayingCommand,\n internalLinksCommand,\n pageOpportunitiesCommand,\n queryClusterCommand,\n quickWinsCommand,\n secondPageCommand,\n seoToAiQueryCommand,\n} from './commands/opportunities/index.js'\nimport { auditPageCommand } from './commands/page-audit.js'\nimport { performanceCommand } from './commands/performance.js'\nimport {\n diagnoseCommand,\n doctorCommand,\n segmentImpactCommand,\n strikingDistanceCommand,\n} from './commands/product/index.js'\nimport { providersCommand } from './commands/providers/index.js'\nimport { pseoCommand } from './commands/pseo/index.js'\nimport { aiReadinessCommand } from './commands/readiness.js'\nimport { reportCatalogCommand } from './commands/report-catalog.js'\nimport {\n monthlyReportCommand,\n reportNarrativeCommand,\n} from './commands/reports.js'\nimport { explainCommand, rulesCommand } from './commands/rules.js'\nimport { scheduleCommand } from './commands/schedule.js'\nimport { serverLogsCommand } from './commands/server-logs.js'\nimport { setupCommand, startCommand } from './commands/setup/index.js'\nimport { skillsCommand } from './commands/skills.js'\nimport {\n privacyCommand,\n resetCommand,\n sitesCommand,\n updatesCommand,\n} from './commands/system.js'\nimport { telemetryCommand } from './commands/telemetry.js'\nimport {\n crawlQueueCommand,\n diagnosePropertyWorkflowCommand,\n mainReportCommand,\n refreshPrioritiesCommand,\n technicalWatchCommand,\n updatePostmortemCommand,\n} from './commands/workflows/index.js'\nimport { maybeOfferSelfUpdate } from './self-update.js'\nimport { printCatalog, printHeading, printSection } from './utils.js'\n\nconst pkg = {\n name: 'seo',\n version: SEO_VERSION,\n}\n\ntype HelpSection = {\n title: string\n commands: Array<[command: string, description: string]>\n}\n\nconst helpSections: HelpSection[] = [\n {\n title: 'Start here',\n commands: [\n ['seo start', 'Connect Google and save a project profile'],\n ['seo report', 'Run the main SEO report for the default project'],\n ['seo report --site sc-domain:example.com', 'Run without a profile'],\n [\n 'seo report --url https://example.com',\n 'Start with a local technical report',\n ],\n ],\n },\n {\n title: 'Projects',\n commands: [\n ['seo projects list', 'List saved project profiles'],\n ['seo projects add', 'Create or update a project profile'],\n ['seo sites', 'List Search Console properties'],\n ['seo doctor', 'Check local auth and config'],\n ],\n },\n {\n title: 'Act on a report',\n commands: [\n ['seo refresh-priorities', 'Rank the next best SEO actions'],\n ['seo quick-wins', 'Find ranking 4-10 low-CTR wins'],\n ['seo second-page', 'Investigate URLs averaging positions 10-20'],\n ['seo technical-watch', 'Crawl and index-monitor a site'],\n ],\n },\n {\n title: 'Agent and power tools',\n commands: [\n ['seo report --json', 'Run the main report as structured JSON'],\n ['seo export diagnose', 'Export report data to CSV'],\n ['seo mcp install', 'Install SEO tools into MCP clients'],\n ['seo skill list', 'Show the packaged SEO skill'],\n ['seo reports list', 'Discover every structured report'],\n ],\n },\n]\n\nconst allHelpSections: HelpSection[] = [\n ...helpSections,\n {\n title: 'Deeper analysis',\n commands: [\n ['seo decaying', 'Find pages and queries losing clicks'],\n ['seo cannibal', 'Review queries exposed across multiple URLs'],\n ['seo ctr-underperformers', 'Find weak CTR by ranking position'],\n ['seo query-cluster', 'Cluster repeated demand themes'],\n ['seo page-opportunities', 'Analyze one URL for growth ideas'],\n ['seo content optimize', 'Build a content optimization report'],\n ['seo perf audit', 'Run a page performance audit'],\n ['seo internal-links', 'Find internal link opportunities'],\n ['seo community-intent', 'Find forum, review, and comparison intent'],\n ['seo ai-referrals', 'Find AI referral traffic in Google Analytics'],\n ['seo seo-to-ai-query', 'Convert searches into AI-monitor prompts'],\n ],\n },\n {\n title: 'Technical and data',\n commands: [\n ['seo audit-page', 'Audit one page'],\n [\n 'seo crawl --sitemap-url <url> --health',\n 'Run the fast sitemap gate before a full crawl',\n ],\n ['seo crawl', 'Run a full crawl for page and content evidence'],\n ['seo agent-readiness', 'Check content-site readiness for AI agents'],\n ['seo ai-readiness', 'Review AI-search technical evidence'],\n ['seo llms audit', 'Inspect optional llms.txt presence'],\n ['seo entity-readiness', 'Check brand/entity signals from a saved crawl'],\n ['seo okf export', 'Export a saved crawl as an OKF knowledge bundle'],\n ['seo crawl-queue', 'Run a crawl and rank the implementation queue'],\n ['seo crawl-reports', 'List saved crawl reports'],\n ['seo rules', 'List crawler rule ids'],\n ['seo explain --rule missing_title', 'Explain a crawler rule'],\n ['seo crawl-diff', 'Compare crawl changes'],\n ['seo index-coverage', 'Choose pages for URL Inspection'],\n ['seo index-watch', 'Check URL Inspection status'],\n ['seo indexnow submit', 'Notify IndexNow about changed URLs'],\n ['seo link-recover', 'Find broken search-value URLs'],\n ['seo links', 'Review bounded referring-link evidence'],\n ['seo server-logs analyze', 'Review crawler requests in an access log'],\n ['seo redirect-trace', 'Trace redirects'],\n ['seo gsc-query', 'Run a raw GSC query'],\n ['seo url-inspect', 'Run URL Inspection'],\n ['seo analytics google properties', 'List Google Analytics properties'],\n ['seo analytics google report', 'Run a Google Analytics report'],\n ['seo updates', 'List official Google ranking updates'],\n ],\n },\n {\n title: 'Reports and ops',\n commands: [\n ['seo monthly-report', 'Generate a monthly narrative'],\n ['seo report-narrative', 'Generate a client-ready narrative'],\n ['seo update-postmortem', 'Analyze update winners and losers'],\n ['seo schedule cron', 'Print cron entries'],\n ['seo monitoring', 'Run and review monitoring'],\n ['seo change-log', 'Track SEO changes'],\n ['seo tests', 'Create and report local SEO tests'],\n ['seo content-groups', 'Manage reusable page/query groups'],\n ['seo pseo', 'Audit programmatic SEO templates'],\n ['seo auth', 'Manage Google auth'],\n ['seo providers bing', 'Connect and report on Bing Webmaster'],\n ['seo providers dataforseo', 'Connect optional search data'],\n ['seo cache', 'Manage local cache'],\n ['seo privacy', 'Show local storage paths'],\n ['seo telemetry status', 'Check anonymous usage telemetry'],\n ['seo reset', 'Delete local SEO data'],\n ],\n },\n]\n\nfunction printHelpSections(sections: HelpSection[]): void {\n printHeading(\n `seo v${pkg.version}`,\n 'Run SEO audits, find what needs fixing, and ship the changes with your agent.',\n )\n process.stdout.write('\\n')\n printCatalog(\n sections.flatMap((section) =>\n section.commands.map(([command, description]) => ({\n category: section.title,\n id: command,\n name: description,\n })),\n ),\n {\n noun: 'command',\n categoryLabels: Object.fromEntries(\n sections.map((section) => [section.title, section.title]),\n ),\n },\n )\n process.stdout.write('\\n')\n printSection(\n 'More help',\n 'Use `seo help <command>` or `seo <command> --help` for command help.',\n 'Use `seo help all` for the longer command list.',\n )\n}\n\nconst main = defineCommand({\n meta: {\n name: 'seo',\n version: pkg.version,\n description: 'Local-first SEO CLI and MCP server',\n },\n subCommands: {\n init: initCommand,\n indexnow: indexNowCommand,\n analytics: analyticsCommand,\n llms: llmsCommand,\n auth: authCommand,\n mcp: mcpCommand,\n okf: okfCommand,\n doctor: doctorCommand,\n privacy: privacyCommand,\n telemetry: telemetryCommand,\n reset: resetCommand,\n cache: cacheCommand,\n logs: logsCommand,\n crawl: crawlCommand,\n 'crawl-queue': crawlQueueCommand,\n 'crawl-reports': crawlReportsCommand,\n client: clientCommand,\n content: contentCommand,\n project: projectCommand,\n projects: projectCommand,\n providers: providersCommand,\n 'change-log': changeLogCommand,\n tests: testsCommand,\n 'content-groups': contentGroupsCommand,\n 'crawl-diff': crawlDiffCommand,\n diagnose: diagnoseCommand,\n 'diagnose-property': diagnosePropertyWorkflowCommand,\n export: exportCommand,\n 'index-coverage': indexCoverageCommand,\n 'index-watch': indexWatchCommand,\n 'link-recover': linkRecoverCommand,\n links: linksCommand,\n 'monthly-report': monthlyReportCommand,\n monitoring: monitoringCommand,\n 'report-narrative': reportNarrativeCommand,\n rules: rulesCommand,\n explain: explainCommand,\n 'refresh-priorities': refreshPrioritiesCommand,\n 'redirect-trace': redirectTraceCommand,\n schedule: scheduleCommand,\n 'server-logs': serverLogsCommand,\n skill: skillsCommand,\n start: startCommand,\n setup: setupCommand,\n report: mainReportCommand,\n reports: reportCatalogCommand,\n 'segment-impact': segmentImpactCommand,\n 'striking-distance': strikingDistanceCommand,\n 'technical-watch': technicalWatchCommand,\n 'update-postmortem': updatePostmortemCommand,\n sites: sitesCommand,\n 'gsc-query': gscQueryCommand,\n 'url-inspect': urlInspectCommand,\n updates: updatesCommand,\n 'traffic-anomaly': trafficAnomalyCommand,\n 'update-correlate': updateCorrelateCommand,\n 'ai-referrals': aiReferralsCommand,\n 'agent-readiness': agentReadinessCommand,\n 'ai-readiness': aiReadinessCommand,\n 'entity-readiness': entityReadinessCommand,\n 'audit-page': auditPageCommand,\n 'second-page': secondPageCommand,\n cannibal: cannibalCommand,\n 'community-intent': communityIntentCommand,\n decaying: decayingCommand,\n 'quick-wins': quickWinsCommand,\n 'page-opportunities': pageOpportunitiesCommand,\n perf: performanceCommand,\n 'internal-links': internalLinksCommand,\n 'ctr-underperformers': ctrUnderperformersCommand,\n 'query-cluster': queryClusterCommand,\n 'seo-to-ai-query': seoToAiQueryCommand,\n pseo: pseoCommand,\n },\n run: async () => {\n if (process.argv.slice(2).length === 0) {\n process.stdout.write(\n 'Use `seo start` to set up, then `seo report` for the main report.\\n',\n )\n }\n },\n})\n\nconst reportAliases: Record<string, string> = {\n cannibal: 'cannibalisation',\n crawl: 'site-crawl',\n 'crawl-queue': 'top-fixes',\n decaying: 'decaying-pages',\n 'diagnose-property': 'search-performance-overview',\n doctor: 'setup-check',\n explain: 'explain-crawl-issue',\n 'link-recover': 'link-recovery',\n 'monthly-report': 'monthly-report',\n 'query-cluster': 'query-clusters',\n report: 'search-performance-overview',\n 'report-narrative': 'narrative-report',\n rules: 'crawler-rules',\n 'update-correlate': 'update-correlation',\n}\n\nconst directReportIds = new Set([\n 'agent-readiness',\n 'ai-readiness',\n 'ai-referrals',\n 'audit-page',\n 'community-intent',\n 'crawl-diff',\n 'ctr-underperformers',\n 'entity-readiness',\n 'index-coverage',\n 'index-watch',\n 'internal-links',\n 'link-evidence',\n 'page-opportunities',\n 'quick-wins',\n 'redirect-trace',\n 'refresh-priorities',\n 'second-page',\n 'segment-impact',\n 'seo-to-ai-query',\n 'striking-distance',\n 'technical-watch',\n 'traffic-anomaly',\n 'update-postmortem',\n])\nconst knownReportIds = new Set(listReports().map((report) => report.id))\n\nfunction telemetryReportId(args: string[]): string | undefined {\n const [command, subcommand, id] = args\n if (!command) return undefined\n if (command === 'reports' && subcommand === 'run') {\n return id && knownReportIds.has(id) ? id : undefined\n }\n if (command === 'content' && subcommand === 'optimize') {\n return 'content-optimization'\n }\n if (command === 'change-log' && subcommand === 'measure') {\n return 'measure-change'\n }\n if (command === 'llms' && subcommand === 'audit') return 'llms-txt-audit'\n if (command === 'links') return 'link-evidence'\n if (command === 'llms' && subcommand === 'generate') {\n return 'generate-llms-txt'\n }\n if (command === 'okf' && subcommand === 'export') return 'okf-build'\n if (command === 'okf' && subcommand === 'validate') return 'okf-validate'\n if (command === 'monitoring' && subcommand === 'run') {\n return 'technical-watch'\n }\n if (command === 'perf' && subcommand === 'audit') return 'performance-audit'\n if (command === 'pseo' && subcommand === 'audit') return 'pseo-audit'\n if (command === 'tests' && subcommand === 'report') return 'measure-change'\n return (\n reportAliases[command] ??\n (directReportIds.has(command) ? command : undefined)\n )\n}\n\nconst argv = process.argv.slice(2)\nconst telemetryOptions = { agent: detectTelemetryAgent() }\nconst isTelemetryControl = argv[0] === 'telemetry'\nconst isMcpServer = argv[0] === 'mcp' && argv[1] === 'serve'\nif (!isTelemetryControl && !isMcpServer) {\n initializeTelemetry(telemetryOptions)\n}\nconst updateExitCode = await maybeOfferSelfUpdate(pkg, { argv })\nif (updateExitCode !== undefined) {\n process.exit(updateExitCode)\n}\nif (\n argv.length === 0 ||\n (argv.length === 1 && ['help', '--help', '-h'].includes(argv[0] ?? ''))\n) {\n printHelpSections(helpSections)\n process.exit(0)\n}\nif (argv[0] === 'help' && argv[1] === 'all') {\n printHelpSections(allHelpSections)\n process.exit(0)\n}\nconst commandArgs =\n argv[0] === 'help' && argv.length > 1 ? [...argv.slice(1), '--help'] : argv\nif (commandArgs !== argv) {\n process.argv = [\n process.argv[0] ?? 'node',\n process.argv[1] ?? 'seo',\n ...commandArgs,\n ]\n}\nconst helpRequested = commandArgs.some((arg) => ['--help', '-h'].includes(arg))\nconst versionRequested =\n argv.length === 1 && ['--version', '-v'].includes(argv[0] ?? '')\nconst trackedReport =\n helpRequested || versionRequested ? undefined : telemetryReportId(commandArgs)\n\nif (helpRequested || versionRequested) {\n await runMain(main)\n} else {\n if (trackedReport) {\n trackTelemetryReportStart(trackedReport, telemetryOptions)\n }\n try {\n await runCommand(main, { rawArgs: commandArgs })\n if (trackedReport) {\n trackTelemetryReportComplete(trackedReport, telemetryOptions)\n }\n if (\n ['init', 'setup', 'start'].includes(commandArgs[0] ?? '') &&\n !commandArgs.includes('--dry-run')\n ) {\n trackTelemetrySetupComplete(telemetryOptions)\n }\n } catch (error) {\n if (trackedReport) {\n trackTelemetryReportFailed(\n trackedReport,\n telemetryErrorCategory(error),\n telemetryOptions,\n )\n }\n const normalized = toSeoError(error)\n if (argv.includes('--json')) {\n process.stdout.write(\n `${JSON.stringify(seoErrorEnvelope(normalized), null, 2)}\\n`,\n )\n } else {\n process.stderr.write(`Error: ${normalized.message}\\n`)\n }\n process.exitCode = normalized.exitCode\n }\n}\n"],"mappings":";;uqFAAA,SAAS,EAAW,EAAO,CACvB,OAAO,EACF,WAAW,IAAK,OAAO,CAAC,CACxB,WAAW,IAAK,MAAM,CAAC,CACvB,WAAW,IAAK,MAAM,CAAC,CACvB,WAAW,IAAK,QAAQ,CAAC,CACzB,WAAW,IAAK,OAAO,CAChC,CACA,SAAS,GAAY,EAAO,CACxB,GAAI,CACA,IAAM,EAAM,IAAI,IAAI,CAAK,EACzB,OAAO,EAAI,WAAa,SAAW,EAAI,WAAa,SAC9C,EAAI,SAAS,EACb,IAAA,EACV,MACM,CACF,MACJ,CACJ,CACA,SAAS,GAAW,EAAM,CACtB,IAAM,EAAU,GAAY,CAAI,EAC1B,EAAQ,EAAW,CAAI,EAC7B,OAAO,EACD,YAAY,EAAW,CAAO,EAAE,qBAAqB,EAAM,MAC3D,CACV,CACA,SAAS,GAAK,EAAO,CAGjB,OAFI,EAAM,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ACf,EACA,4BAA6B,CAC3B,KAAM,SACN,YACE,6FACJ,EACA,KAAM,CACJ,KAAM,SACN,YACE,wFACJ,EACA,OAAQ,CACN,KAAM,UACN,QAAS,GACT,YACE,+FACJ,EACA,cAAe,CACb,KAAM,SACN,YACE,oEACJ,EACA,KAAM,CACJ,KAAM,SACN,YAAa,qCACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,2CACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,wDACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,gDACf,EACA,YAAa,CACX,KAAM,SACN,YACE,yFACJ,EACA,qBAAsB,CACpB,KAAM,SACN,YAAa,6CACf,EACA,oBAAqB,CACnB,KAAM,SACN,YAAa,sCACf,EACA,QAAS,CACP,KAAM,UACN,QAAS,GACT,YAAa,gDACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,0CACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,0CACf,EACA,aAAc,CACZ,KAAM,UACN,QAAS,GACT,YAAa,oCACf,EACA,YAAa,CACX,KAAM,UACN,QAAS,GACT,YAAa,4CACf,EACA,cAAe,CACb,KAAM,UACN,QAAS,GACT,YACE,6DACJ,EACA,GAAI,CACF,KAAM,UACN,QAAS,GACT,YAAa,kCACf,EACA,UAAW,CACT,KAAM,SACN,YACE,gEACJ,EACA,KAAM,CACJ,KAAM,UACN,QAAS,GACT,YAAa,uDACf,EACA,OAAQ,CACN,KAAM,SACN,YACE,sFACJ,EACA,OAAQ,CACN,KAAM,SACN,YAAa,8CACf,EACA,IAAK,CACH,KAAM,SACN,YAAa,2DACf,EACA,KAAM,CACJ,KAAM,UACN,QAAS,GACT,YAAa,gCACf,EACA,SAAU,CACR,KAAM,SACN,YAAa,uCACf,EACA,UAAW,CACT,KAAM,SACN,YAAa,4DACf,CACF,EACA,IAAK,MAAO,CAAE,UAAW,CACvB,IAAM,EAAO,EAAS,CAAI,EACpB,EAAS,GAAe,EAAK,OAAQ,CAAI,EACzC,EAAS,EAAU,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S,CAAI,CAAC,CACxD,CACF,CAAC,CACH,CACF,CAAC,EC5EY,GAAoB,EAAc,CAC7C,KAAM,CACJ,KAAM,cACN,YAAa,sDACf,EACA,KAAM,CACJ,SAAU,CACR,KAAM,aACN,SAAU,GACV,YAAa,qBACf,EACA,IAAK,CACH,KAAM,SACN,YACE,oEACJ,EACA,KAAM,CACJ,KAAM,SACN,YAAa,4CACf,EACA,OAAQ,CACN,KAAM,SACN,YAAa,6BACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,2BACf,EACA,4BAA6B,CAC3B,KAAM,SACN,YACE,6FACJ,EACA,KAAM,CACJ,KAAM,SACN,YACE,6DACJ,EACA,KAAM,CACJ,KAAM,SACN,YAAa,qCACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,2CACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,0CACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,sCACf,EACA,YAAa,CACX,KAAM,SACN,YAAa,uCACf,EACA,qBAAsB,CACpB,KAAM,SACN,YAAa,6CACf,EACA,oBAAqB,CACnB,KAAM,SACN,YAAa,sCACf,EACA,QAAS,CACP,KAAM,UACN,QAAS,GACT,YAAa,gDACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,0CACf,EACA,QAAS,CACP,KAAM,SACN,YAAa,0CACf,EACA,MAAO,CACL,KAAM,SACN,YAAa,+CACf,EACA,aAAc,CACZ,KAAM,UACN,QAAS,GACT,YAAa,oCACf,EACA,YAAa,CACX,KAAM,UACN,QAAS,GACT,YAAa,4CACf,EACA,cAAe,CACb,KAAM,UACN,QAAS,GACT,YAAa,8BACf,EACA,GAAI,CACF,KAAM,UACN,QAAS,GACT,YAAa,0DACf,EACA,KAAM,CACJ,KAAM,UACN,QAAS,GACT,YAAa,8BACf,CACF,EACA,IAAK,MAAO,CAAE,UAAW,CACvB,IAAM,EAAO,EAAS,CAAI,EACpB,EAAU,EAAW,CAAI,EACzB,EAAO,MAAM,GAAY,CAAI,EAC7B,EAAc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