@ainyc/canonry 2.2.3 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  showFirstRunNotice,
37
37
  trackEvent,
38
38
  usageError
39
- } from "./chunk-MXUOJWNL.js";
39
+ } from "./chunk-JXOUZ6JH.js";
40
40
  import {
41
41
  apiKeys,
42
42
  competitors,
@@ -46,7 +46,7 @@ import {
46
46
  projects,
47
47
  querySnapshots,
48
48
  runs
49
- } from "./chunk-TAII35VC.js";
49
+ } from "./chunk-CW6CAPBQ.js";
50
50
 
51
51
  // src/cli.ts
52
52
  import { pathToFileURL } from "url";
@@ -293,7 +293,7 @@ async function backfillAnswerVisibilityCommand(opts) {
293
293
  console.log(` Errors: ${providerErrors}`);
294
294
  }
295
295
  async function backfillInsightsCommand(project, opts) {
296
- const { IntelligenceService } = await import("./intelligence-service-C5LAYDFM.js");
296
+ const { IntelligenceService } = await import("./intelligence-service-232P7625.js");
297
297
  const config = loadConfig();
298
298
  const db = createClient(config.database);
299
299
  migrate(db);
@@ -502,10 +502,308 @@ var BACKFILL_CLI_COMMANDS = [
502
502
  }
503
503
  ];
504
504
 
505
- // src/commands/bing.ts
505
+ // src/commands/backlinks.ts
506
506
  function getClient() {
507
507
  return createApiClient();
508
508
  }
509
+ function printJson(value) {
510
+ console.log(JSON.stringify(value, null, 2));
511
+ }
512
+ function formatInstallStatus(status) {
513
+ const lines = [];
514
+ lines.push(status.duckdbInstalled ? "DuckDB: installed" : "DuckDB: not installed");
515
+ if (status.duckdbVersion) lines.push(`Version: ${status.duckdbVersion}`);
516
+ lines.push(`Spec: ${status.duckdbSpec}`);
517
+ lines.push(`Plugin: ${status.pluginDir}`);
518
+ if (!status.duckdbInstalled) {
519
+ lines.push("");
520
+ lines.push("Run `canonry backlinks install` to enable backlinks.");
521
+ }
522
+ return lines.join("\n");
523
+ }
524
+ function formatSync(sync) {
525
+ const lines = [];
526
+ lines.push(`Release: ${sync.release}`);
527
+ lines.push(`Status: ${sync.status}`);
528
+ if (sync.phaseDetail) lines.push(`Phase: ${sync.phaseDetail}`);
529
+ if (typeof sync.projectsProcessed === "number") lines.push(`Projects: ${sync.projectsProcessed}`);
530
+ if (typeof sync.domainsDiscovered === "number") lines.push(`Domains: ${sync.domainsDiscovered}`);
531
+ if (sync.error) lines.push(`Error: ${sync.error}`);
532
+ return lines.join("\n");
533
+ }
534
+ function formatSummaryAndDomains(project, response) {
535
+ const lines = [];
536
+ lines.push(`Project: ${project}`);
537
+ if (!response.summary) {
538
+ lines.push("No ready release \u2014 run `canonry backlinks sync --release <id>` first.");
539
+ return lines.join("\n");
540
+ }
541
+ const s = response.summary;
542
+ lines.push(`Release: ${s.release}`);
543
+ lines.push(`Target: ${s.targetDomain}`);
544
+ lines.push(`Linking domains: ${s.totalLinkingDomains}`);
545
+ lines.push(`Total hosts: ${s.totalHosts}`);
546
+ lines.push(`Top-10 share: ${s.top10HostsShare}`);
547
+ if (response.rows.length > 0) {
548
+ lines.push("");
549
+ lines.push(`Top ${response.rows.length} linking domains (of ${response.total}):`);
550
+ for (const r of response.rows) {
551
+ lines.push(` ${String(r.numHosts).padStart(9)} ${r.linkingDomain}`);
552
+ }
553
+ }
554
+ return lines.join("\n");
555
+ }
556
+ function formatCachedReleases(rows) {
557
+ if (rows.length === 0) return "No cached releases.";
558
+ const lines = [];
559
+ lines.push("Release Status Bytes Last used");
560
+ for (const r of rows) {
561
+ const status = (r.syncStatus ?? "unknown").padEnd(12);
562
+ const bytes = String(r.bytes).padStart(12);
563
+ const lastUsed = r.lastUsedAt ?? "-";
564
+ lines.push(`${r.release.padEnd(30)} ${status} ${bytes} ${lastUsed}`);
565
+ }
566
+ return lines.join("\n");
567
+ }
568
+ function formatInstallResult(result) {
569
+ if (result.alreadyPresent) {
570
+ return `DuckDB already installed (${result.version}) at ${result.path}`;
571
+ }
572
+ return `DuckDB installed (${result.version}) at ${result.path}`;
573
+ }
574
+ async function pollSync(id, format) {
575
+ const client = getClient();
576
+ const terminal = /* @__PURE__ */ new Set(["ready", "failed"]);
577
+ while (true) {
578
+ const syncs = await client.backlinksListSyncs();
579
+ const row = syncs.find((s) => s.id === id);
580
+ if (!row) throw new Error(`Release sync ${id} not found`);
581
+ if (terminal.has(row.status)) return row;
582
+ if (format !== "json") {
583
+ process.stderr.write(`\r${row.status}${row.phaseDetail ? ": " + row.phaseDetail : ""}`.padEnd(80));
584
+ }
585
+ await new Promise((r) => setTimeout(r, 2e3));
586
+ }
587
+ }
588
+ async function pollRun(runId, format) {
589
+ const client = getClient();
590
+ const terminal = /* @__PURE__ */ new Set(["completed", "failed", "partial"]);
591
+ while (true) {
592
+ const run = await client.getRun(runId);
593
+ if (terminal.has(run.status)) return run;
594
+ if (format !== "json") {
595
+ process.stderr.write(`\r${run.status}`.padEnd(40));
596
+ }
597
+ await new Promise((r) => setTimeout(r, 2e3));
598
+ }
599
+ }
600
+ async function backlinksInstall(opts = {}) {
601
+ const result = await getClient().backlinksInstall();
602
+ if (opts.format === "json") {
603
+ printJson(result);
604
+ return;
605
+ }
606
+ console.log(formatInstallResult(result));
607
+ }
608
+ async function backlinksDoctor(opts = {}) {
609
+ const status = await getClient().backlinksStatus();
610
+ if (opts.format === "json") {
611
+ printJson(status);
612
+ return;
613
+ }
614
+ console.log(formatInstallStatus(status));
615
+ }
616
+ async function backlinksSync(opts) {
617
+ const client = getClient();
618
+ const sync = await client.backlinksTriggerSync(opts.release);
619
+ const final = opts.wait ? await pollSync(sync.id, opts.format) : sync;
620
+ if (opts.format === "json") {
621
+ printJson(final);
622
+ return;
623
+ }
624
+ if (opts.wait) process.stderr.write("\n");
625
+ console.log(formatSync(final));
626
+ }
627
+ async function backlinksStatus(opts = {}) {
628
+ const sync = await getClient().backlinksLatestSync();
629
+ if (opts.format === "json") {
630
+ printJson(sync);
631
+ return;
632
+ }
633
+ if (!sync) {
634
+ console.log("No release syncs yet.");
635
+ return;
636
+ }
637
+ console.log(formatSync(sync));
638
+ }
639
+ async function backlinksList(opts) {
640
+ const client = getClient();
641
+ const response = await client.backlinksDomains(opts.project, {
642
+ limit: opts.limit ?? 50,
643
+ release: opts.release
644
+ });
645
+ if (opts.format === "json") {
646
+ printJson(response);
647
+ return;
648
+ }
649
+ console.log(formatSummaryAndDomains(opts.project, response));
650
+ }
651
+ async function backlinksReleases(opts = {}) {
652
+ const rows = await getClient().backlinksCachedReleases();
653
+ if (opts.format === "json") {
654
+ printJson(rows);
655
+ return;
656
+ }
657
+ console.log(formatCachedReleases(rows));
658
+ }
659
+ async function backlinksExtract(opts) {
660
+ const client = getClient();
661
+ const run = await client.backlinksExtract(opts.project, opts.release);
662
+ const final = opts.wait ? await pollRun(run.id, opts.format) : run;
663
+ if (opts.format === "json") {
664
+ printJson(final);
665
+ return;
666
+ }
667
+ if (opts.wait) process.stderr.write("\n");
668
+ console.log(`Run ${final.id} (${final.status})${final.error ? " \u2014 " + final.error : ""}`);
669
+ }
670
+ async function backlinksCachePrune(opts) {
671
+ if (!opts.release) {
672
+ throw new Error("Usage: canonry backlinks cache prune --release <id>");
673
+ }
674
+ const result = await getClient().backlinksPruneCache(opts.release);
675
+ if (opts.format === "json") {
676
+ printJson({ pruned: opts.release, ...result });
677
+ return;
678
+ }
679
+ console.log(`Pruned cache for ${opts.release}`);
680
+ }
681
+
682
+ // src/cli-commands/backlinks.ts
683
+ var BACKLINKS_CLI_COMMANDS = [
684
+ {
685
+ path: ["backlinks", "install"],
686
+ usage: "canonry backlinks install [--format json]",
687
+ options: {},
688
+ run: async (input) => {
689
+ await backlinksInstall({ format: input.format });
690
+ }
691
+ },
692
+ {
693
+ path: ["backlinks", "doctor"],
694
+ usage: "canonry backlinks doctor [--format json]",
695
+ options: {},
696
+ run: async (input) => {
697
+ await backlinksDoctor({ format: input.format });
698
+ }
699
+ },
700
+ {
701
+ path: ["backlinks", "sync"],
702
+ usage: "canonry backlinks sync --release <id> [--wait] [--format json]",
703
+ options: {
704
+ release: stringOption(),
705
+ wait: { type: "boolean" }
706
+ },
707
+ run: async (input) => {
708
+ const release = requireStringOption(input, "release", {
709
+ message: "--release is required",
710
+ usage: "canonry backlinks sync --release <id> [--wait]",
711
+ command: "backlinks sync"
712
+ });
713
+ await backlinksSync({
714
+ release,
715
+ wait: getBoolean(input.values, "wait"),
716
+ format: input.format
717
+ });
718
+ }
719
+ },
720
+ {
721
+ path: ["backlinks", "status"],
722
+ usage: "canonry backlinks status [--format json]",
723
+ options: {},
724
+ run: async (input) => {
725
+ await backlinksStatus({ format: input.format });
726
+ }
727
+ },
728
+ {
729
+ path: ["backlinks", "list"],
730
+ usage: "canonry backlinks list <project> [--limit <n>] [--release <id>] [--format json]",
731
+ options: {
732
+ limit: stringOption(),
733
+ release: stringOption()
734
+ },
735
+ run: async (input) => {
736
+ const project = requireProject(
737
+ input,
738
+ "backlinks list",
739
+ "canonry backlinks list <project> [--limit <n>] [--release <id>]"
740
+ );
741
+ const limit = parseIntegerOption(input, "limit", {
742
+ message: "--limit must be an integer",
743
+ usage: "canonry backlinks list <project> --limit <n>",
744
+ command: "backlinks list"
745
+ });
746
+ await backlinksList({
747
+ project,
748
+ limit,
749
+ release: getString(input.values, "release"),
750
+ format: input.format
751
+ });
752
+ }
753
+ },
754
+ {
755
+ path: ["backlinks", "releases"],
756
+ usage: "canonry backlinks releases [--format json]",
757
+ options: {},
758
+ run: async (input) => {
759
+ await backlinksReleases({ format: input.format });
760
+ }
761
+ },
762
+ {
763
+ path: ["backlinks", "extract"],
764
+ usage: "canonry backlinks extract <project> [--release <id>] [--wait] [--format json]",
765
+ options: {
766
+ release: stringOption(),
767
+ wait: { type: "boolean" }
768
+ },
769
+ run: async (input) => {
770
+ const project = requireProject(
771
+ input,
772
+ "backlinks extract",
773
+ "canonry backlinks extract <project> [--release <id>] [--wait]"
774
+ );
775
+ await backlinksExtract({
776
+ project,
777
+ release: getString(input.values, "release"),
778
+ wait: getBoolean(input.values, "wait"),
779
+ format: input.format
780
+ });
781
+ }
782
+ },
783
+ {
784
+ path: ["backlinks", "cache", "prune"],
785
+ usage: "canonry backlinks cache prune --release <id> [--format json]",
786
+ options: {
787
+ release: stringOption()
788
+ },
789
+ run: async (input) => {
790
+ const release = requireStringOption(input, "release", {
791
+ message: "--release is required",
792
+ usage: "canonry backlinks cache prune --release <id>",
793
+ command: "backlinks cache prune"
794
+ });
795
+ await backlinksCachePrune({
796
+ release,
797
+ format: input.format
798
+ });
799
+ }
800
+ }
801
+ ];
802
+
803
+ // src/commands/bing.ts
804
+ function getClient2() {
805
+ return createApiClient();
806
+ }
509
807
  async function bingConnect(project, opts) {
510
808
  const apiKey = opts?.apiKey;
511
809
  if (!apiKey) {
@@ -518,7 +816,7 @@ async function bingConnect(project, opts) {
518
816
  }
519
817
  });
520
818
  }
521
- const client = getClient();
819
+ const client = getClient2();
522
820
  const result = await client.bingConnect(project, { apiKey });
523
821
  if (opts?.format === "json") {
524
822
  console.log(JSON.stringify(result, null, 2));
@@ -539,7 +837,7 @@ Set the active site with: canonry bing set-site ${project} <url>`);
539
837
  }
540
838
  }
541
839
  async function bingDisconnect(project, format) {
542
- const client = getClient();
840
+ const client = getClient2();
543
841
  await client.bingDisconnect(project);
544
842
  if (format === "json") {
545
843
  console.log(JSON.stringify({ project, disconnected: true }, null, 2));
@@ -548,7 +846,7 @@ async function bingDisconnect(project, format) {
548
846
  console.log(`Bing Webmaster Tools disconnected from project "${project}".`);
549
847
  }
550
848
  async function bingStatus(project, format) {
551
- const client = getClient();
849
+ const client = getClient2();
552
850
  const result = await client.bingStatus(project);
553
851
  if (format === "json") {
554
852
  console.log(JSON.stringify(result, null, 2));
@@ -566,7 +864,7 @@ async function bingStatus(project, format) {
566
864
  console.log(` Updated: ${result.updatedAt}`);
567
865
  }
568
866
  async function bingSites(project, format) {
569
- const client = getClient();
867
+ const client = getClient2();
570
868
  const result = await client.bingSites(project);
571
869
  if (format === "json") {
572
870
  console.log(JSON.stringify(result, null, 2));
@@ -588,7 +886,7 @@ async function bingSites(project, format) {
588
886
  Use "canonry bing set-site <project> <url>" to select a site.`);
589
887
  }
590
888
  async function bingSetSite(project, siteUrl, format) {
591
- const client = getClient();
889
+ const client = getClient2();
592
890
  await client.bingSetSite(project, siteUrl);
593
891
  if (format === "json") {
594
892
  console.log(JSON.stringify({ project, siteUrl }, null, 2));
@@ -597,7 +895,7 @@ async function bingSetSite(project, siteUrl, format) {
597
895
  console.log(`Bing site set to "${siteUrl}" for project "${project}".`);
598
896
  }
599
897
  async function bingCoverage(project, format) {
600
- const client = getClient();
898
+ const client = getClient2();
601
899
  const result = await client.bingCoverage(project);
602
900
  if (format === "json") {
603
901
  console.log(JSON.stringify(result, null, 2));
@@ -645,7 +943,7 @@ Bing Index Coverage for "${project}"
645
943
  }
646
944
  }
647
945
  async function bingCoverageHistory(project, opts) {
648
- const client = getClient();
946
+ const client = getClient2();
649
947
  const rows = await client.bingCoverageHistory(project, { limit: opts.limit });
650
948
  if (opts.format === "json") {
651
949
  console.log(JSON.stringify(rows, null, 2));
@@ -665,7 +963,7 @@ Bing Coverage History for "${project}" (${rows.length} snapshots):
665
963
  }
666
964
  }
667
965
  async function bingInspect(project, url, format) {
668
- const client = getClient();
966
+ const client = getClient2();
669
967
  const result = await client.bingInspectUrl(project, url);
670
968
  if (format === "json") {
671
969
  console.log(JSON.stringify(result, null, 2));
@@ -684,7 +982,7 @@ Bing URL Inspection: ${result.url}
684
982
  console.log(` Inspected At: ${result.inspectedAt}`);
685
983
  }
686
984
  async function bingInspections(project, opts) {
687
- const client = getClient();
985
+ const client = getClient2();
688
986
  const params = {};
689
987
  if (opts.url) params.url = opts.url;
690
988
  const rows = await client.bingInspections(project, Object.keys(params).length > 0 ? params : void 0);
@@ -710,7 +1008,7 @@ async function bingInspections(project, opts) {
710
1008
  }
711
1009
  }
712
1010
  async function bingRefresh(project, format) {
713
- const client = getClient();
1011
+ const client = getClient2();
714
1012
  const rows = await client.bingInspections(project);
715
1013
  const uniqueUrls = [...new Set(rows.map((r) => r.url))];
716
1014
  if (uniqueUrls.length === 0) {
@@ -750,7 +1048,7 @@ async function bingRefresh(project, format) {
750
1048
  await bingCoverage(project, format);
751
1049
  }
752
1050
  async function bingRequestIndexing(project, opts) {
753
- const client = getClient();
1051
+ const client = getClient2();
754
1052
  const body = {};
755
1053
  if (opts.allUnindexed) {
756
1054
  body.allUnindexed = true;
@@ -785,7 +1083,7 @@ async function bingRequestIndexing(project, opts) {
785
1083
  }
786
1084
  }
787
1085
  async function bingPerformance(project, format) {
788
- const client = getClient();
1086
+ const client = getClient2();
789
1087
  const rows = await client.bingPerformance(project);
790
1088
  if (format === "json") {
791
1089
  console.log(JSON.stringify(rows, null, 2));
@@ -971,7 +1269,7 @@ var BING_CLI_COMMANDS = [
971
1269
  ];
972
1270
 
973
1271
  // src/commands/cdp.ts
974
- function getClient2() {
1272
+ function getClient3() {
975
1273
  return createApiClient();
976
1274
  }
977
1275
  async function cdpConnect(opts) {
@@ -997,7 +1295,7 @@ async function cdpConnect(opts) {
997
1295
  console.log("Restart canonry server for changes to take effect.");
998
1296
  }
999
1297
  async function cdpStatus(format) {
1000
- const client = getClient2();
1298
+ const client = getClient3();
1001
1299
  try {
1002
1300
  const status = await client.getCdpStatus();
1003
1301
  if (format === "json") {
@@ -1055,7 +1353,7 @@ async function cdpScreenshot(query, opts) {
1055
1353
  }
1056
1354
  });
1057
1355
  }
1058
- const client = getClient2();
1356
+ const client = getClient3();
1059
1357
  const body = { query };
1060
1358
  if (opts?.targets) {
1061
1359
  body.targets = opts.targets.split(",").map((s) => s.trim());
@@ -1162,7 +1460,7 @@ var CDP_CLI_COMMANDS = [
1162
1460
  ];
1163
1461
 
1164
1462
  // src/commands/ga.ts
1165
- function getClient3() {
1463
+ function getClient4() {
1166
1464
  return createApiClient();
1167
1465
  }
1168
1466
  async function gaConnect(project, opts) {
@@ -1195,7 +1493,7 @@ async function gaConnect(project, opts) {
1195
1493
  } else if (opts.keyJson) {
1196
1494
  body.keyJson = opts.keyJson;
1197
1495
  }
1198
- const client = getClient3();
1496
+ const client = getClient4();
1199
1497
  const result = await client.gaConnect(project, body);
1200
1498
  if (opts.format === "json") {
1201
1499
  console.log(JSON.stringify(result, null, 2));
@@ -1210,7 +1508,7 @@ async function gaConnect(project, opts) {
1210
1508
  }
1211
1509
  }
1212
1510
  async function gaDisconnect(project, format) {
1213
- const client = getClient3();
1511
+ const client = getClient4();
1214
1512
  await client.gaDisconnect(project);
1215
1513
  if (format === "json") {
1216
1514
  console.log(JSON.stringify({ project, disconnected: true }, null, 2));
@@ -1219,7 +1517,7 @@ async function gaDisconnect(project, format) {
1219
1517
  console.log(`GA4 disconnected from project "${project}".`);
1220
1518
  }
1221
1519
  async function gaStatus(project, format) {
1222
- const client = getClient3();
1520
+ const client = getClient4();
1223
1521
  const result = await client.gaStatus(project);
1224
1522
  if (format === "json") {
1225
1523
  console.log(JSON.stringify(result, null, 2));
@@ -1245,7 +1543,7 @@ async function gaStatus(project, format) {
1245
1543
  console.log(` Connected: ${result.createdAt ?? "unknown"}`);
1246
1544
  }
1247
1545
  async function gaSync(project, opts) {
1248
- const client = getClient3();
1546
+ const client = getClient4();
1249
1547
  const body = {};
1250
1548
  if (opts?.days) body.days = opts.days;
1251
1549
  if (opts?.only) body.only = opts.only;
@@ -1265,7 +1563,7 @@ async function gaSync(project, opts) {
1265
1563
  console.log(` Synced at: ${result.syncedAt}`);
1266
1564
  }
1267
1565
  async function gaTraffic(project, opts) {
1268
- const client = getClient3();
1566
+ const client = getClient4();
1269
1567
  const params = {};
1270
1568
  if (opts?.limit) params.limit = String(opts.limit);
1271
1569
  if (opts?.window) params.window = opts.window;
@@ -1340,7 +1638,7 @@ async function gaTraffic(project, opts) {
1340
1638
  }
1341
1639
  }
1342
1640
  async function gaAiReferralHistory(project, opts) {
1343
- const client = getClient3();
1641
+ const client = getClient4();
1344
1642
  const result = await client.gaAiReferralHistory(project, opts?.window ? { window: opts.window } : void 0);
1345
1643
  if (opts?.format === "json") {
1346
1644
  console.log(JSON.stringify(result, null, 2));
@@ -1365,7 +1663,7 @@ async function gaAiReferralHistory(project, opts) {
1365
1663
  }
1366
1664
  }
1367
1665
  async function gaSocialReferralHistory(project, opts) {
1368
- const client = getClient3();
1666
+ const client = getClient4();
1369
1667
  const result = await client.gaSocialReferralHistory(project, opts?.window ? { window: opts.window } : void 0);
1370
1668
  if (opts?.format === "json") {
1371
1669
  console.log(JSON.stringify(result, null, 2));
@@ -1390,7 +1688,7 @@ async function gaSocialReferralHistory(project, opts) {
1390
1688
  }
1391
1689
  }
1392
1690
  async function gaSessionHistory(project, opts) {
1393
- const client = getClient3();
1691
+ const client = getClient4();
1394
1692
  const result = await client.gaSessionHistory(project, opts?.window ? { window: opts.window } : void 0);
1395
1693
  if (opts?.format === "json") {
1396
1694
  console.log(JSON.stringify(result, null, 2));
@@ -1412,7 +1710,7 @@ async function gaSessionHistory(project, opts) {
1412
1710
  }
1413
1711
  }
1414
1712
  async function gaCoverage(project, format) {
1415
- const client = getClient3();
1713
+ const client = getClient4();
1416
1714
  const result = await client.gaCoverage(project);
1417
1715
  if (format === "json") {
1418
1716
  console.log(JSON.stringify(result, null, 2));
@@ -1435,7 +1733,7 @@ async function gaCoverage(project, format) {
1435
1733
  }
1436
1734
  }
1437
1735
  async function gaSocialReferralSummary(project, opts) {
1438
- const client = getClient3();
1736
+ const client = getClient4();
1439
1737
  const traffic = await client.gaTraffic(project);
1440
1738
  if (opts?.trend) {
1441
1739
  const trend = await client.gaSocialReferralTrend(project);
@@ -1496,7 +1794,7 @@ async function gaSocialReferralSummary(project, opts) {
1496
1794
  }
1497
1795
  }
1498
1796
  async function gaAttribution(project, opts) {
1499
- const client = getClient3();
1797
+ const client = getClient4();
1500
1798
  const traffic = await client.gaTraffic(project);
1501
1799
  const fmtTrend = (pct) => pct === null ? "n/a" : `${pct >= 0 ? "+" : ""}${pct}%`;
1502
1800
  if (opts?.trend) {
@@ -1789,11 +2087,11 @@ var GA_CLI_COMMANDS = [
1789
2087
  ];
1790
2088
 
1791
2089
  // src/commands/competitor.ts
1792
- function getClient4() {
2090
+ function getClient5() {
1793
2091
  return createApiClient();
1794
2092
  }
1795
2093
  async function addCompetitors(project, domains, format) {
1796
- const client = getClient4();
2094
+ const client = getClient5();
1797
2095
  const existing = await client.listCompetitors(project);
1798
2096
  const existingDomains = existing.map((c) => c.domain);
1799
2097
  const addedDomains = domains.filter((domain) => !existingDomains.includes(domain));
@@ -1815,7 +2113,7 @@ async function addCompetitors(project, domains, format) {
1815
2113
  }
1816
2114
  }
1817
2115
  async function listCompetitors(project, format) {
1818
- const client = getClient4();
2116
+ const client = getClient5();
1819
2117
  const comps = await client.listCompetitors(project);
1820
2118
  if (format === "json") {
1821
2119
  console.log(JSON.stringify(comps, null, 2));
@@ -1874,7 +2172,7 @@ var COMPETITOR_CLI_COMMANDS = [
1874
2172
  ];
1875
2173
 
1876
2174
  // src/commands/google.ts
1877
- function getClient5() {
2175
+ function getClient6() {
1878
2176
  return createApiClient();
1879
2177
  }
1880
2178
  async function waitForRunStatus(client, runId, config) {
@@ -1914,7 +2212,7 @@ async function waitForRunStatus(client, runId, config) {
1914
2212
  });
1915
2213
  }
1916
2214
  async function googleConnect(project, opts) {
1917
- const client = getClient5();
2215
+ const client = getClient6();
1918
2216
  const { authUrl, redirectUri } = await client.googleConnect(project, {
1919
2217
  type: opts.type,
1920
2218
  publicUrl: opts.publicUrl
@@ -1948,7 +2246,7 @@ Open this URL in your browser to authorize Google ${opts.type.toUpperCase()} acc
1948
2246
  }
1949
2247
  }
1950
2248
  async function googleDisconnect(project, opts) {
1951
- const client = getClient5();
2249
+ const client = getClient6();
1952
2250
  await client.googleDisconnect(project, opts.type);
1953
2251
  if (opts.format === "json") {
1954
2252
  console.log(JSON.stringify({ project, type: opts.type, disconnected: true }, null, 2));
@@ -1957,7 +2255,7 @@ async function googleDisconnect(project, opts) {
1957
2255
  console.log(`Disconnected Google ${opts.type.toUpperCase()} from project "${project}".`);
1958
2256
  }
1959
2257
  async function googleStatus(project, format) {
1960
- const client = getClient5();
2258
+ const client = getClient6();
1961
2259
  const connections = await client.googleConnections(project);
1962
2260
  if (format === "json") {
1963
2261
  console.log(JSON.stringify({ connections }, null, 2));
@@ -1981,7 +2279,7 @@ async function googleStatus(project, format) {
1981
2279
  }
1982
2280
  }
1983
2281
  async function googleProperties(project, format) {
1984
- const client = getClient5();
2282
+ const client = getClient6();
1985
2283
  const { sites } = await client.googleProperties(project);
1986
2284
  if (format === "json") {
1987
2285
  console.log(JSON.stringify({ sites }, null, 2));
@@ -2002,7 +2300,7 @@ async function googleProperties(project, format) {
2002
2300
  Use "canonry google set-property <project> <siteUrl>" to select a property.`);
2003
2301
  }
2004
2302
  async function googleSetProperty(project, propertyUrl, format) {
2005
- const client = getClient5();
2303
+ const client = getClient6();
2006
2304
  await client.googleSetProperty(project, "gsc", propertyUrl);
2007
2305
  if (format === "json") {
2008
2306
  console.log(JSON.stringify({ project, type: "gsc", propertyUrl }, null, 2));
@@ -2011,7 +2309,7 @@ async function googleSetProperty(project, propertyUrl, format) {
2011
2309
  console.log(`GSC property set to "${propertyUrl}" for project "${project}".`);
2012
2310
  }
2013
2311
  async function googleSync(project, opts) {
2014
- const client = getClient5();
2312
+ const client = getClient6();
2015
2313
  const run = await client.gscSync(project, { days: opts.days, full: opts.full });
2016
2314
  if (!opts.wait && opts.format === "json") {
2017
2315
  console.log(JSON.stringify(run, null, 2));
@@ -2041,7 +2339,7 @@ async function googleSync(project, opts) {
2041
2339
  }
2042
2340
  }
2043
2341
  async function googlePerformance(project, opts) {
2044
- const client = getClient5();
2342
+ const client = getClient6();
2045
2343
  const params = {};
2046
2344
  if (opts.days) {
2047
2345
  const end = /* @__PURE__ */ new Date();
@@ -2077,7 +2375,7 @@ async function googlePerformance(project, opts) {
2077
2375
  }
2078
2376
  }
2079
2377
  async function googleInspect(project, url, format) {
2080
- const client = getClient5();
2378
+ const client = getClient6();
2081
2379
  const result = await client.gscInspect(project, url);
2082
2380
  if (format === "json") {
2083
2381
  console.log(JSON.stringify(result, null, 2));
@@ -2097,7 +2395,7 @@ URL Inspection: ${result.url}
2097
2395
  console.log(` Inspected At: ${result.inspectedAt}`);
2098
2396
  }
2099
2397
  async function googleInspections(project, opts) {
2100
- const client = getClient5();
2398
+ const client = getClient6();
2101
2399
  const params = {};
2102
2400
  if (opts.url) params.url = opts.url;
2103
2401
  const rows = await client.gscInspections(project, Object.keys(params).length > 0 ? params : void 0);
@@ -2122,7 +2420,7 @@ async function googleInspections(project, opts) {
2122
2420
  }
2123
2421
  }
2124
2422
  async function googleCoverage(project, format) {
2125
- const client = getClient5();
2423
+ const client = getClient6();
2126
2424
  const result = await client.gscCoverage(project);
2127
2425
  if (format === "json") {
2128
2426
  console.log(JSON.stringify(result, null, 2));
@@ -2168,7 +2466,7 @@ Index Coverage for "${project}"
2168
2466
  }
2169
2467
  }
2170
2468
  async function googleSetSitemap(project, sitemapUrl, format) {
2171
- const client = getClient5();
2469
+ const client = getClient6();
2172
2470
  await client.googleSetSitemap(project, "gsc", sitemapUrl);
2173
2471
  if (format === "json") {
2174
2472
  console.log(JSON.stringify({ project, type: "gsc", sitemapUrl }, null, 2));
@@ -2177,7 +2475,7 @@ async function googleSetSitemap(project, sitemapUrl, format) {
2177
2475
  console.log(`GSC sitemap URL set to "${sitemapUrl}" for project "${project}".`);
2178
2476
  }
2179
2477
  async function googleListSitemaps(project, opts) {
2180
- const client = getClient5();
2478
+ const client = getClient6();
2181
2479
  const result = await client.gscSitemaps(project);
2182
2480
  if (opts.format === "json") {
2183
2481
  console.log(JSON.stringify(result, null, 2));
@@ -2199,7 +2497,7 @@ Sitemaps for project "${project}":
2199
2497
  }
2200
2498
  }
2201
2499
  async function googleInspectSitemap(project, opts) {
2202
- const client = getClient5();
2500
+ const client = getClient6();
2203
2501
  const run = await client.gscInspectSitemap(project, {
2204
2502
  sitemapUrl: opts.sitemapUrl
2205
2503
  });
@@ -2235,7 +2533,7 @@ async function googleInspectSitemap(project, opts) {
2235
2533
  }
2236
2534
  }
2237
2535
  async function googleCoverageHistory(project, opts) {
2238
- const client = getClient5();
2536
+ const client = getClient6();
2239
2537
  const rows = await client.gscCoverageHistory(project, { limit: opts.limit });
2240
2538
  if (opts.format === "json") {
2241
2539
  console.log(JSON.stringify(rows, null, 2));
@@ -2257,7 +2555,7 @@ GSC Coverage History for "${project}" (${rows.length} snapshots):
2257
2555
  }
2258
2556
  }
2259
2557
  async function googleDiscoverSitemaps(project, opts) {
2260
- const client = getClient5();
2558
+ const client = getClient6();
2261
2559
  const result = await client.gscDiscoverSitemaps(project);
2262
2560
  if (!opts.wait && opts.format === "json") {
2263
2561
  console.log(JSON.stringify(result, null, 2));
@@ -2309,7 +2607,7 @@ Primary sitemap: ${result.primarySitemapUrl}`);
2309
2607
  }
2310
2608
  }
2311
2609
  async function googleRequestIndexing(project, opts) {
2312
- const client = getClient5();
2610
+ const client = getClient6();
2313
2611
  const body = { urls: [] };
2314
2612
  if (opts.allUnindexed) {
2315
2613
  body.allUnindexed = true;
@@ -2389,7 +2687,7 @@ async function googleRequestIndexing(project, opts) {
2389
2687
  }
2390
2688
  }
2391
2689
  async function googleRefresh(project, format) {
2392
- const client = getClient5();
2690
+ const client = getClient6();
2393
2691
  const run = await client.gscSync(project, {});
2394
2692
  if (format !== "json") {
2395
2693
  process.stderr.write("Refreshing GSC coverage data");
@@ -2412,7 +2710,7 @@ async function googleRefresh(project, format) {
2412
2710
  await googleCoverage(project, format);
2413
2711
  }
2414
2712
  async function googleDeindexed(project, format) {
2415
- const client = getClient5();
2713
+ const client = getClient6();
2416
2714
  const rows = await client.gscDeindexed(project);
2417
2715
  if (format === "json") {
2418
2716
  console.log(JSON.stringify(rows, null, 2));
@@ -2701,11 +2999,11 @@ var GOOGLE_CLI_COMMANDS = [
2701
2999
 
2702
3000
  // src/commands/keyword.ts
2703
3001
  import fs from "fs";
2704
- function getClient6() {
3002
+ function getClient7() {
2705
3003
  return createApiClient();
2706
3004
  }
2707
3005
  async function addKeywords(project, keywords, format) {
2708
- const client = getClient6();
3006
+ const client = getClient7();
2709
3007
  await client.appendKeywords(project, keywords);
2710
3008
  if (format === "json") {
2711
3009
  console.log(JSON.stringify({
@@ -2718,7 +3016,7 @@ async function addKeywords(project, keywords, format) {
2718
3016
  console.log(`Added ${keywords.length} key phrase(s) to "${project}".`);
2719
3017
  }
2720
3018
  async function removeKeywords(project, keywords, format) {
2721
- const client = getClient6();
3019
+ const client = getClient7();
2722
3020
  const existing = await client.listKeywords(project);
2723
3021
  const existingSet = new Set(existing.map((k) => k.keyword));
2724
3022
  const removedKeywords = keywords.filter((k) => existingSet.has(k));
@@ -2735,7 +3033,7 @@ async function removeKeywords(project, keywords, format) {
2735
3033
  console.log(`Removed ${removedKeywords.length} key phrase(s) from "${project}".`);
2736
3034
  }
2737
3035
  async function listKeywords(project, format) {
2738
- const client = getClient6();
3036
+ const client = getClient7();
2739
3037
  const kws = await client.listKeywords(project);
2740
3038
  if (format === "json") {
2741
3039
  console.log(JSON.stringify(kws, null, 2));
@@ -2778,7 +3076,7 @@ async function importKeywords(project, filePath, format) {
2778
3076
  console.log("No key phrases found in file.");
2779
3077
  return;
2780
3078
  }
2781
- const client = getClient6();
3079
+ const client = getClient7();
2782
3080
  await client.appendKeywords(project, keywords);
2783
3081
  if (format === "json") {
2784
3082
  console.log(JSON.stringify({
@@ -2792,7 +3090,7 @@ async function importKeywords(project, filePath, format) {
2792
3090
  console.log(`Imported ${keywords.length} key phrase(s) to "${project}".`);
2793
3091
  }
2794
3092
  async function generateKeywords(project, provider, opts) {
2795
- const client = getClient6();
3093
+ const client = getClient7();
2796
3094
  const result = await client.generateKeywords(project, provider, opts.count);
2797
3095
  const saved = Boolean(opts.save && result.keywords.length > 0);
2798
3096
  if (opts.format !== "json") {
@@ -2946,11 +3244,11 @@ var KEYWORD_CLI_COMMANDS = [
2946
3244
  ];
2947
3245
 
2948
3246
  // src/commands/notify.ts
2949
- function getClient7() {
3247
+ function getClient8() {
2950
3248
  return createApiClient();
2951
3249
  }
2952
3250
  async function addNotification(project, opts) {
2953
- const client = getClient7();
3251
+ const client = getClient8();
2954
3252
  const result = await client.createNotification(project, {
2955
3253
  channel: "webhook",
2956
3254
  url: opts.webhook,
@@ -2964,7 +3262,7 @@ async function addNotification(project, opts) {
2964
3262
  printNotification(result);
2965
3263
  }
2966
3264
  async function listNotifications(project, format) {
2967
- const client = getClient7();
3265
+ const client = getClient8();
2968
3266
  const results = await client.listNotifications(project);
2969
3267
  if (format === "json") {
2970
3268
  console.log(JSON.stringify(results, null, 2));
@@ -2982,7 +3280,7 @@ async function listNotifications(project, format) {
2982
3280
  }
2983
3281
  }
2984
3282
  async function removeNotification(project, id, format) {
2985
- const client = getClient7();
3283
+ const client = getClient8();
2986
3284
  await client.deleteNotification(project, id);
2987
3285
  if (format === "json") {
2988
3286
  console.log(JSON.stringify({ project, id, removed: true }, null, 2));
@@ -2991,7 +3289,7 @@ async function removeNotification(project, id, format) {
2991
3289
  console.log(`Notification ${id} removed from "${project}"`);
2992
3290
  }
2993
3291
  async function testNotification(project, id, format) {
2994
- const client = getClient7();
3292
+ const client = getClient8();
2995
3293
  const result = await client.testNotification(project, id);
2996
3294
  if (format === "json") {
2997
3295
  console.log(JSON.stringify({ project, id, ...result }, null, 2));
@@ -3182,11 +3480,11 @@ async function applyConfigs(filePaths, format) {
3182
3480
  }
3183
3481
 
3184
3482
  // src/commands/analytics.ts
3185
- function getClient8() {
3483
+ function getClient9() {
3186
3484
  return createApiClient();
3187
3485
  }
3188
3486
  async function showAnalytics(project, options) {
3189
- const client = getClient8();
3487
+ const client = getClient9();
3190
3488
  const features = options.feature ? [options.feature] : ["metrics", "gaps", "sources"];
3191
3489
  const results = {};
3192
3490
  for (const feature of features) {
@@ -3289,11 +3587,11 @@ Source Origin Breakdown`);
3289
3587
  }
3290
3588
 
3291
3589
  // src/commands/evidence.ts
3292
- function getClient9() {
3590
+ function getClient10() {
3293
3591
  return createApiClient();
3294
3592
  }
3295
3593
  async function showEvidence(project, format) {
3296
- const client = getClient9();
3594
+ const client = getClient10();
3297
3595
  const timeline = await client.getTimeline(project);
3298
3596
  if (format === "json") {
3299
3597
  const enriched = timeline.map((entry) => ({
@@ -3353,11 +3651,11 @@ async function loadLatestRunForExport(client, project) {
3353
3651
  }
3354
3652
 
3355
3653
  // src/commands/history.ts
3356
- function getClient10() {
3654
+ function getClient11() {
3357
3655
  return createApiClient();
3358
3656
  }
3359
3657
  async function showHistory(project, format) {
3360
- const client = getClient10();
3658
+ const client = getClient11();
3361
3659
  try {
3362
3660
  const entries = await client.getHistory(project);
3363
3661
  if (format === "json") {
@@ -3392,11 +3690,11 @@ async function showHistory(project, format) {
3392
3690
  }
3393
3691
 
3394
3692
  // src/commands/status.ts
3395
- function getClient11() {
3693
+ function getClient12() {
3396
3694
  return createApiClient();
3397
3695
  }
3398
3696
  async function showStatus(project, format) {
3399
- const client = getClient11();
3697
+ const client = getClient12();
3400
3698
  const projectData = await client.getProject(project);
3401
3699
  const latest = await getLatestRunSummary(client, project);
3402
3700
  if (format === "json") {
@@ -3527,11 +3825,11 @@ var OPERATOR_CLI_COMMANDS = [
3527
3825
  ];
3528
3826
 
3529
3827
  // src/commands/project.ts
3530
- function getClient12() {
3828
+ function getClient13() {
3531
3829
  return createApiClient();
3532
3830
  }
3533
3831
  async function createProject(name, opts) {
3534
- const client = getClient12();
3832
+ const client = getClient13();
3535
3833
  const result = await client.putProject(name, {
3536
3834
  displayName: opts.displayName,
3537
3835
  canonicalDomain: opts.domain,
@@ -3546,7 +3844,7 @@ async function createProject(name, opts) {
3546
3844
  console.log(`Project created: ${result.name} (${result.id})`);
3547
3845
  }
3548
3846
  async function listProjects(format) {
3549
- const client = getClient12();
3847
+ const client = getClient13();
3550
3848
  const projects2 = await client.listProjects();
3551
3849
  if (format === "json") {
3552
3850
  console.log(JSON.stringify(projects2, null, 2));
@@ -3574,7 +3872,7 @@ async function listProjects(format) {
3574
3872
  }
3575
3873
  }
3576
3874
  async function showProject(name, format) {
3577
- const client = getClient12();
3875
+ const client = getClient13();
3578
3876
  const project = await client.getProject(name);
3579
3877
  if (format === "json") {
3580
3878
  console.log(JSON.stringify(project, null, 2));
@@ -3600,7 +3898,7 @@ async function showProject(name, format) {
3600
3898
  if (project.updatedAt) console.log(` Updated: ${project.updatedAt}`);
3601
3899
  }
3602
3900
  async function updateProjectSettings(name, opts) {
3603
- const client = getClient12();
3901
+ const client = getClient13();
3604
3902
  const project = await client.getProject(name);
3605
3903
  let ownedDomains = opts.ownedDomains ?? project.ownedDomains ?? [];
3606
3904
  if (opts.addOwnedDomain) {
@@ -3625,7 +3923,7 @@ async function updateProjectSettings(name, opts) {
3625
3923
  console.log(`Project updated: ${result.name}`);
3626
3924
  }
3627
3925
  async function deleteProject(name, format) {
3628
- const client = getClient12();
3926
+ const client = getClient13();
3629
3927
  await client.deleteProject(name);
3630
3928
  if (format === "json") {
3631
3929
  console.log(JSON.stringify({ name, deleted: true }, null, 2));
@@ -3634,7 +3932,7 @@ async function deleteProject(name, format) {
3634
3932
  console.log(`Project deleted: ${name}`);
3635
3933
  }
3636
3934
  async function addLocation(project, opts) {
3637
- const client = getClient12();
3935
+ const client = getClient13();
3638
3936
  const location = await client.addLocation(project, {
3639
3937
  label: opts.label,
3640
3938
  city: opts.city,
@@ -3649,7 +3947,7 @@ async function addLocation(project, opts) {
3649
3947
  console.log(`Location added: ${opts.label} (${opts.city}, ${opts.region}, ${opts.country})`);
3650
3948
  }
3651
3949
  async function listLocations(project, format) {
3652
- const client = getClient12();
3950
+ const client = getClient13();
3653
3951
  const result = await client.listLocations(project);
3654
3952
  if (format === "json") {
3655
3953
  console.log(JSON.stringify(result, null, 2));
@@ -3675,7 +3973,7 @@ async function listLocations(project, format) {
3675
3973
  }
3676
3974
  }
3677
3975
  async function removeLocation(project, label, format) {
3678
- const client = getClient12();
3976
+ const client = getClient13();
3679
3977
  await client.removeLocation(project, label);
3680
3978
  if (format === "json") {
3681
3979
  console.log(JSON.stringify({ project, label, removed: true }, null, 2));
@@ -3684,7 +3982,7 @@ async function removeLocation(project, label, format) {
3684
3982
  console.log(`Location removed: ${label}`);
3685
3983
  }
3686
3984
  async function setDefaultLocation(project, label, format) {
3687
- const client = getClient12();
3985
+ const client = getClient13();
3688
3986
  const result = await client.setDefaultLocation(project, label);
3689
3987
  if (format === "json") {
3690
3988
  console.log(JSON.stringify({ project, ...result }, null, 2));
@@ -3863,12 +4161,12 @@ var PROJECT_CLI_COMMANDS = [
3863
4161
  ];
3864
4162
 
3865
4163
  // src/commands/run.ts
3866
- function getClient13() {
4164
+ function getClient14() {
3867
4165
  return createApiClient();
3868
4166
  }
3869
4167
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "partial", "failed", "cancelled"]);
3870
4168
  async function triggerRun(project, opts) {
3871
- const client = getClient13();
4169
+ const client = getClient14();
3872
4170
  const body = {};
3873
4171
  if (opts?.provider) {
3874
4172
  const providerInputs = opts.provider.split(",").map((s) => s.trim()).filter(Boolean);
@@ -3892,7 +4190,7 @@ async function triggerRun(project, opts) {
3892
4190
  const settled = await Promise.all(
3893
4191
  locationRuns.map(async (r) => {
3894
4192
  if (!r.id || r.status === "conflict") return r;
3895
- const final = await pollRun(client, r.id);
4193
+ const final = await pollRun2(client, r.id);
3896
4194
  return { ...r, ...final };
3897
4195
  })
3898
4196
  );
@@ -3917,7 +4215,7 @@ async function triggerRun(project, opts) {
3917
4215
  process.stderr.write(`Waiting for ${pending.length} run(s)`);
3918
4216
  await Promise.all(
3919
4217
  pending.map(async (r) => {
3920
- const final = await pollRun(client, r.id);
4218
+ const final = await pollRun2(client, r.id);
3921
4219
  r.status = final.status;
3922
4220
  })
3923
4221
  );
@@ -3934,7 +4232,7 @@ async function triggerRun(project, opts) {
3934
4232
  const run = response;
3935
4233
  if (opts?.wait && run.id && !TERMINAL_STATUSES.has(run.status)) {
3936
4234
  process.stderr.write(`Run ${run.id} started`);
3937
- const result = await pollRun(client, run.id);
4235
+ const result = await pollRun2(client, run.id);
3938
4236
  if (opts?.format === "json") {
3939
4237
  console.log(JSON.stringify(result, null, 2));
3940
4238
  } else {
@@ -3964,7 +4262,7 @@ async function triggerRun(project, opts) {
3964
4262
  }
3965
4263
  }
3966
4264
  async function triggerRunAll(opts) {
3967
- const client = getClient13();
4265
+ const client = getClient14();
3968
4266
  const projects2 = await client.listProjects();
3969
4267
  if (projects2.length === 0) {
3970
4268
  if (opts?.format === "json") {
@@ -4001,7 +4299,7 @@ async function triggerRunAll(opts) {
4001
4299
  if (pending.length > 0) {
4002
4300
  process.stderr.write(`Waiting for ${pending.length} run(s)`);
4003
4301
  await Promise.all(pending.map(async (r) => {
4004
- const final = await pollRun(client, r.runId);
4302
+ const final = await pollRun2(client, r.runId);
4005
4303
  r.status = final.status;
4006
4304
  }));
4007
4305
  process.stderr.write("\n");
@@ -4022,7 +4320,7 @@ async function triggerRunAll(opts) {
4022
4320
  }
4023
4321
  }
4024
4322
  async function cancelRun(project, runId, format) {
4025
- const client = getClient13();
4323
+ const client = getClient14();
4026
4324
  let targetId = runId;
4027
4325
  if (!targetId) {
4028
4326
  const runs2 = await client.listRuns(project);
@@ -4054,7 +4352,7 @@ To cancel by ID : canonry run cancel ${project} <run-id>`,
4054
4352
  console.log(`Run ${result.id} cancelled.`);
4055
4353
  }
4056
4354
  async function showRun(id, format) {
4057
- const client = getClient13();
4355
+ const client = getClient14();
4058
4356
  const run = await client.getRun(id);
4059
4357
  if (format === "json") {
4060
4358
  console.log(JSON.stringify(run, null, 2));
@@ -4063,7 +4361,7 @@ async function showRun(id, format) {
4063
4361
  printRunDetail(run);
4064
4362
  }
4065
4363
  async function listRuns(project, opts) {
4066
- const client = getClient13();
4364
+ const client = getClient14();
4067
4365
  const runs2 = await client.listRuns(project, opts?.limit);
4068
4366
  if (opts?.format === "json") {
4069
4367
  console.log(JSON.stringify(runs2, null, 2));
@@ -4084,7 +4382,7 @@ async function listRuns(project, opts) {
4084
4382
  }
4085
4383
  }
4086
4384
  var POLL_TIMEOUT_MS = 10 * 60 * 1e3;
4087
- async function pollRun(client, runId) {
4385
+ async function pollRun2(client, runId) {
4088
4386
  const deadline = Date.now() + POLL_TIMEOUT_MS;
4089
4387
  for (; ; ) {
4090
4388
  await new Promise((r) => setTimeout(r, 2e3));
@@ -4208,11 +4506,11 @@ var RUN_CLI_COMMANDS = [
4208
4506
  ];
4209
4507
 
4210
4508
  // src/commands/schedule.ts
4211
- function getClient14() {
4509
+ function getClient15() {
4212
4510
  return createApiClient();
4213
4511
  }
4214
4512
  async function setSchedule(project, opts) {
4215
- const client = getClient14();
4513
+ const client = getClient15();
4216
4514
  const body = {};
4217
4515
  if (opts.preset) body.preset = opts.preset;
4218
4516
  if (opts.cron) body.cron = opts.cron;
@@ -4227,7 +4525,7 @@ async function setSchedule(project, opts) {
4227
4525
  printSchedule(result);
4228
4526
  }
4229
4527
  async function showSchedule(project, format) {
4230
- const client = getClient14();
4528
+ const client = getClient15();
4231
4529
  const result = await client.getSchedule(project);
4232
4530
  if (format === "json") {
4233
4531
  console.log(JSON.stringify(result, null, 2));
@@ -4236,7 +4534,7 @@ async function showSchedule(project, format) {
4236
4534
  printSchedule(result);
4237
4535
  }
4238
4536
  async function enableSchedule(project, format) {
4239
- const client = getClient14();
4537
+ const client = getClient15();
4240
4538
  const current = await client.getSchedule(project);
4241
4539
  const body = { timezone: current.timezone, enabled: true };
4242
4540
  if (current.preset) body.preset = current.preset;
@@ -4250,7 +4548,7 @@ async function enableSchedule(project, format) {
4250
4548
  console.log(`Schedule enabled for "${project}"`);
4251
4549
  }
4252
4550
  async function disableSchedule(project, format) {
4253
- const client = getClient14();
4551
+ const client = getClient15();
4254
4552
  const current = await client.getSchedule(project);
4255
4553
  const body = { timezone: current.timezone, enabled: false };
4256
4554
  if (current.preset) body.preset = current.preset;
@@ -4264,7 +4562,7 @@ async function disableSchedule(project, format) {
4264
4562
  console.log(`Schedule disabled for "${project}"`);
4265
4563
  }
4266
4564
  async function removeSchedule(project, format) {
4267
- const client = getClient14();
4565
+ const client = getClient15();
4268
4566
  await client.deleteSchedule(project);
4269
4567
  if (format === "json") {
4270
4568
  console.log(JSON.stringify({ project, removed: true }, null, 2));
@@ -4371,11 +4669,11 @@ var SCHEDULE_CLI_COMMANDS = [
4371
4669
  ];
4372
4670
 
4373
4671
  // src/commands/settings.ts
4374
- function getClient15() {
4672
+ function getClient16() {
4375
4673
  return createApiClient();
4376
4674
  }
4377
4675
  async function setProvider(name, opts) {
4378
- const client = getClient15();
4676
+ const client = getClient16();
4379
4677
  const { format, ...payload } = opts;
4380
4678
  const result = await client.updateProvider(name, payload);
4381
4679
  if (format === "json") {
@@ -4391,7 +4689,7 @@ async function setProvider(name, opts) {
4391
4689
  }
4392
4690
  }
4393
4691
  async function showSettings(format) {
4394
- const client = getClient15();
4692
+ const client = getClient16();
4395
4693
  const config = loadConfig();
4396
4694
  const settings = await client.getSettings();
4397
4695
  if (format === "json") {
@@ -4894,7 +5192,7 @@ function wrapText(font, text, size, maxWidth) {
4894
5192
  }
4895
5193
 
4896
5194
  // src/commands/snapshot.ts
4897
- function getClient16() {
5195
+ function getClient17() {
4898
5196
  return createApiClient();
4899
5197
  }
4900
5198
  function slugify(value) {
@@ -4905,7 +5203,7 @@ function autoOutputPath(companyName, ext) {
4905
5203
  return `${slugify(companyName)}-snapshot-${date}.${ext}`;
4906
5204
  }
4907
5205
  async function createSnapshotReport(companyName, opts) {
4908
- const client = getClient16();
5206
+ const client = getClient17();
4909
5207
  const report = await client.createSnapshot({
4910
5208
  companyName,
4911
5209
  domain: opts.domain,
@@ -6198,10 +6496,10 @@ var SYSTEM_CLI_COMMANDS = [
6198
6496
  import fs7 from "fs";
6199
6497
 
6200
6498
  // src/commands/wordpress.ts
6201
- function getClient17() {
6499
+ function getClient18() {
6202
6500
  return createApiClient();
6203
6501
  }
6204
- function printJson(value) {
6502
+ function printJson2(value) {
6205
6503
  console.log(JSON.stringify(value, null, 2));
6206
6504
  }
6207
6505
  function printSiteStatus(label, status) {
@@ -6345,7 +6643,7 @@ async function wordpressConnect(project, opts) {
6345
6643
  details: { project }
6346
6644
  });
6347
6645
  }
6348
- const client = getClient17();
6646
+ const client = getClient18();
6349
6647
  const result = await client.wordpressConnect(project, {
6350
6648
  url: opts.url,
6351
6649
  stagingUrl: opts.stagingUrl,
@@ -6354,7 +6652,7 @@ async function wordpressConnect(project, opts) {
6354
6652
  defaultEnv: opts.defaultEnv
6355
6653
  });
6356
6654
  if (opts.format === "json") {
6357
- printJson(result);
6655
+ printJson2(result);
6358
6656
  return;
6359
6657
  }
6360
6658
  console.log(`WordPress connected for project "${project}".
@@ -6362,46 +6660,46 @@ async function wordpressConnect(project, opts) {
6362
6660
  printWordpressStatus(project, result);
6363
6661
  }
6364
6662
  async function wordpressDisconnect(project, format) {
6365
- const client = getClient17();
6663
+ const client = getClient18();
6366
6664
  await client.wordpressDisconnect(project);
6367
6665
  if (format === "json") {
6368
- printJson({ project, disconnected: true });
6666
+ printJson2({ project, disconnected: true });
6369
6667
  return;
6370
6668
  }
6371
6669
  console.log(`WordPress disconnected from project "${project}".`);
6372
6670
  }
6373
6671
  async function wordpressStatus(project, format) {
6374
- const client = getClient17();
6672
+ const client = getClient18();
6375
6673
  const result = await client.wordpressStatus(project);
6376
6674
  if (format === "json") {
6377
- printJson(result);
6675
+ printJson2(result);
6378
6676
  return;
6379
6677
  }
6380
6678
  printWordpressStatus(project, result);
6381
6679
  }
6382
6680
  async function wordpressPages(project, opts) {
6383
- const client = getClient17();
6681
+ const client = getClient18();
6384
6682
  const result = await client.wordpressPages(project, opts.env);
6385
6683
  if (opts.format === "json") {
6386
- printJson(result);
6684
+ printJson2(result);
6387
6685
  return;
6388
6686
  }
6389
6687
  printPages(project, result.env, result.pages);
6390
6688
  }
6391
6689
  async function wordpressPage(project, slug, opts) {
6392
- const client = getClient17();
6690
+ const client = getClient18();
6393
6691
  const result = await client.wordpressPage(project, slug, opts.env);
6394
6692
  if (opts.format === "json") {
6395
- printJson(result);
6693
+ printJson2(result);
6396
6694
  return;
6397
6695
  }
6398
6696
  printPageDetail(result);
6399
6697
  }
6400
6698
  async function wordpressCreatePage(project, body) {
6401
- const client = getClient17();
6699
+ const client = getClient18();
6402
6700
  const result = await client.wordpressCreatePage(project, body);
6403
6701
  if (body.format === "json") {
6404
- printJson(result);
6702
+ printJson2(result);
6405
6703
  return;
6406
6704
  }
6407
6705
  console.log(`Created WordPress page "${result.slug}" in ${result.env}.
@@ -6409,10 +6707,10 @@ async function wordpressCreatePage(project, body) {
6409
6707
  printPageDetail(result);
6410
6708
  }
6411
6709
  async function wordpressUpdatePage(project, body) {
6412
- const client = getClient17();
6710
+ const client = getClient18();
6413
6711
  const result = await client.wordpressUpdatePage(project, body);
6414
6712
  if (body.format === "json") {
6415
- printJson(result);
6713
+ printJson2(result);
6416
6714
  return;
6417
6715
  }
6418
6716
  console.log(`Updated WordPress page "${body.currentSlug}" in ${result.env}.
@@ -6420,10 +6718,10 @@ async function wordpressUpdatePage(project, body) {
6420
6718
  printPageDetail(result);
6421
6719
  }
6422
6720
  async function wordpressSetMeta(project, body) {
6423
- const client = getClient17();
6721
+ const client = getClient18();
6424
6722
  const result = await client.wordpressSetMeta(project, body);
6425
6723
  if (body.format === "json") {
6426
- printJson(result);
6724
+ printJson2(result);
6427
6725
  return;
6428
6726
  }
6429
6727
  console.log(`Updated SEO meta for "${body.slug}" in ${result.env}.
@@ -6470,10 +6768,10 @@ async function wordpressBulkSetMeta(project, opts) {
6470
6768
  details: { path: filePath }
6471
6769
  });
6472
6770
  }
6473
- const client = getClient17();
6771
+ const client = getClient18();
6474
6772
  const result = await client.wordpressBulkSetMeta(project, { entries, env: opts.env });
6475
6773
  if (opts.format === "json") {
6476
- printJson(result);
6774
+ printJson2(result);
6477
6775
  return;
6478
6776
  }
6479
6777
  const applied = result.results.filter((r) => r.status === "applied");
@@ -6513,10 +6811,10 @@ async function wordpressBulkSetMeta(project, opts) {
6513
6811
  Total: ${applied.length} applied, ${skipped.length} skipped, ${manual.length} manual`);
6514
6812
  }
6515
6813
  async function wordpressSchema(project, slug, opts) {
6516
- const client = getClient17();
6814
+ const client = getClient18();
6517
6815
  const result = await client.wordpressSchema(project, slug, opts.env);
6518
6816
  if (opts.format === "json") {
6519
- printJson(result);
6817
+ printJson2(result);
6520
6818
  return;
6521
6819
  }
6522
6820
  console.log(`Schema for "${slug}" (${result.env}):
@@ -6524,10 +6822,10 @@ async function wordpressSchema(project, slug, opts) {
6524
6822
  printSchemaBlocks(result.blocks);
6525
6823
  }
6526
6824
  async function wordpressSetSchema(project, body) {
6527
- const client = getClient17();
6825
+ const client = getClient18();
6528
6826
  const result = await client.wordpressSetSchema(project, body);
6529
6827
  if (body.format === "json") {
6530
- printJson(result);
6828
+ printJson2(result);
6531
6829
  return;
6532
6830
  }
6533
6831
  printManualAssist(`Schema update for "${body.slug}"`, result);
@@ -6572,10 +6870,10 @@ async function wordpressSchemaDeploy(project, opts) {
6572
6870
  details: { path: filePath }
6573
6871
  });
6574
6872
  }
6575
- const client = getClient17();
6873
+ const client = getClient18();
6576
6874
  const result = await client.wordpressSchemaDeploy(project, { profile: parsed, env: opts.env });
6577
6875
  if (opts.format === "json") {
6578
- printJson(result);
6876
+ printJson2(result);
6579
6877
  return;
6580
6878
  }
6581
6879
  console.log(`Schema deploy (${result.env}):
@@ -6611,10 +6909,10 @@ async function wordpressSchemaDeploy(project, opts) {
6611
6909
  Total: ${deployed} deployed, ${stripped} stripped, ${skipped} skipped, ${failed} failed`);
6612
6910
  }
6613
6911
  async function wordpressSchemaStatus(project, opts) {
6614
- const client = getClient17();
6912
+ const client = getClient18();
6615
6913
  const result = await client.wordpressSchemaStatus(project, opts.env);
6616
6914
  if (opts.format === "json") {
6617
- printJson(result);
6915
+ printJson2(result);
6618
6916
  return;
6619
6917
  }
6620
6918
  console.log(`Schema status (${result.env}):
@@ -6670,7 +6968,7 @@ async function wordpressOnboard(project, opts) {
6670
6968
  });
6671
6969
  }
6672
6970
  }
6673
- const client = getClient17();
6971
+ const client = getClient18();
6674
6972
  const result = await client.wordpressOnboard(project, {
6675
6973
  url: opts.url,
6676
6974
  username: opts.user,
@@ -6682,7 +6980,7 @@ async function wordpressOnboard(project, opts) {
6682
6980
  skipSubmit: opts.skipSubmit
6683
6981
  });
6684
6982
  if (opts.format === "json") {
6685
- printJson(result);
6983
+ printJson2(result);
6686
6984
  return;
6687
6985
  }
6688
6986
  console.log(`WordPress onboarding for "${project}":
@@ -6695,10 +6993,10 @@ async function wordpressOnboard(project, opts) {
6695
6993
  }
6696
6994
  }
6697
6995
  async function wordpressLlmsTxt(project, opts) {
6698
- const client = getClient17();
6996
+ const client = getClient18();
6699
6997
  const result = await client.wordpressLlmsTxt(project, opts.env);
6700
6998
  if (opts.format === "json") {
6701
- printJson(result);
6999
+ printJson2(result);
6702
7000
  return;
6703
7001
  }
6704
7002
  console.log(`llms.txt for "${project}" (${result.env}): ${result.url}
@@ -6706,19 +7004,19 @@ async function wordpressLlmsTxt(project, opts) {
6706
7004
  console.log(result.content ?? "(not found)");
6707
7005
  }
6708
7006
  async function wordpressSetLlmsTxt(project, body) {
6709
- const client = getClient17();
7007
+ const client = getClient18();
6710
7008
  const result = await client.wordpressSetLlmsTxt(project, body);
6711
7009
  if (body.format === "json") {
6712
- printJson(result);
7010
+ printJson2(result);
6713
7011
  return;
6714
7012
  }
6715
7013
  printManualAssist(`llms.txt update for "${project}"`, result);
6716
7014
  }
6717
7015
  async function wordpressAudit(project, opts) {
6718
- const client = getClient17();
7016
+ const client = getClient18();
6719
7017
  const result = await client.wordpressAudit(project, opts.env);
6720
7018
  if (opts.format === "json") {
6721
- printJson(result);
7019
+ printJson2(result);
6722
7020
  return;
6723
7021
  }
6724
7022
  console.log(`WordPress audit for "${project}" (${result.env}):
@@ -6729,19 +7027,19 @@ async function wordpressAudit(project, opts) {
6729
7027
  printAuditIssues(result.issues);
6730
7028
  }
6731
7029
  async function wordpressDiff(project, slug, format) {
6732
- const client = getClient17();
7030
+ const client = getClient18();
6733
7031
  const result = await client.wordpressDiff(project, slug);
6734
7032
  if (format === "json") {
6735
- printJson(result);
7033
+ printJson2(result);
6736
7034
  return;
6737
7035
  }
6738
7036
  printDiff(result);
6739
7037
  }
6740
7038
  async function wordpressStagingStatus(project, format) {
6741
- const client = getClient17();
7039
+ const client = getClient18();
6742
7040
  const result = await client.wordpressStagingStatus(project);
6743
7041
  if (format === "json") {
6744
- printJson(result);
7042
+ printJson2(result);
6745
7043
  return;
6746
7044
  }
6747
7045
  console.log(`WordPress staging status for "${project}":
@@ -6752,10 +7050,10 @@ async function wordpressStagingStatus(project, format) {
6752
7050
  console.log(` Admin URL: ${result.adminUrl}`);
6753
7051
  }
6754
7052
  async function wordpressStagingPush(project, format) {
6755
- const client = getClient17();
7053
+ const client = getClient18();
6756
7054
  const result = await client.wordpressStagingPush(project);
6757
7055
  if (format === "json") {
6758
- printJson(result);
7056
+ printJson2(result);
6759
7057
  return;
6760
7058
  }
6761
7059
  printManualAssist(`Staging push for "${project}"`, result);
@@ -7718,6 +8016,7 @@ Usage: ${usage}`, {
7718
8016
  // src/cli-commands.ts
7719
8017
  var REGISTERED_CLI_COMMANDS = [
7720
8018
  ...BACKFILL_CLI_COMMANDS,
8019
+ ...BACKLINKS_CLI_COMMANDS,
7721
8020
  ...SYSTEM_CLI_COMMANDS,
7722
8021
  ...PROJECT_CLI_COMMANDS,
7723
8022
  ...KEYWORD_CLI_COMMANDS,