@canonry/canonry 7.51.5 → 7.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +8 -0
- package/assets/assets/{AccessControls-B5TqDgeq.js → AccessControls-CteIuEGI.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-DgxiizOW.js → AuditHistoryPanel-DqJGiLsf.js} +1 -1
- package/assets/assets/{BacklinksPage-Ay6pdphx.js → BacklinksPage-DotWEPQt.js} +1 -1
- package/assets/assets/{HistoryPage-B11eFH21.js → HistoryPage-aOd198dT.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-CuaKVK8x.js +4 -0
- package/assets/assets/{ProjectPage-DoY0hftd.js → ProjectPage-O9oufMgi.js} +4 -4
- package/assets/assets/{RunsPage-BPBmuQAS.js → RunsPage-DIXMrc-N.js} +1 -1
- package/assets/assets/{SettingsPage-ClKnP8xy.js → SettingsPage-BuGb6AGa.js} +1 -1
- package/assets/assets/SiteHealthSection-CweaKjCo.js +2 -0
- package/assets/assets/TrafficPage-B7MaQalp.js +40 -0
- package/assets/assets/{TrafficSourceDetailPage-DQu0YNt2.js → TrafficSourceDetailPage-BPtjnF9s.js} +1 -1
- package/assets/assets/{card-DYMyvhB9.js → card-DoV-8Txo.js} +1 -1
- package/assets/assets/{extract-error-message-BRM1I_3L.js → extract-error-message-DKQJJlZ-.js} +1 -1
- package/assets/assets/{format-helpers-DrkFERj3.js → format-helpers-BWnMmkiO.js} +1 -1
- package/assets/assets/index-Z63c4PeO.js +39 -0
- package/assets/assets/{query-client-gRFnU4VF.js → query-client-vB35tVTz.js} +1 -1
- package/assets/assets/{react-query-lH82FULK.js → react-query-BI0567qs.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-D09H4byP.js → react-sigma_core.esm.min-hGyOC4V_.js} +1 -1
- package/assets/assets/{service-Cx0HSnE9.js → service-c4YvpVKX.js} +1 -1
- package/assets/index.html +6 -6
- package/dist/ads-MREK2AGL.js +544 -0
- package/dist/agent-4RUZ3MC4.js +70 -0
- package/dist/agent-ask-YLTYBEYH.js +139 -0
- package/dist/agent-conversations-QA6IKDGR.js +52 -0
- package/dist/agent-memory-MEQAJOB3.js +92 -0
- package/dist/agent-providers-AXYPDJHL.js +55 -0
- package/dist/agent-transcript-SMNQNYCD.js +77 -0
- package/dist/analytics-4OR64IGV.js +240 -0
- package/dist/apply-CQXCFXAH.js +175 -0
- package/dist/backfill-TMXCNVOB.js +41 -0
- package/dist/backlinks-6KFAQGYV.js +303 -0
- package/dist/bing-HFCACTAC.js +418 -0
- package/dist/bootstrap-SQVQXOJC.js +326 -0
- package/dist/cdp-IACL7EXU.js +162 -0
- package/dist/chunk-4MJYGB56.js +124 -0
- package/dist/chunk-5N6245R7.js +1160 -0
- package/dist/chunk-6BPZHNDC.js +617 -0
- package/dist/chunk-6GO5VVAC.js +15 -0
- package/dist/chunk-7244X3K6.js +609 -0
- package/dist/chunk-7XE2IRBG.js +204 -0
- package/dist/chunk-AOJU5LKX.js +8 -0
- package/dist/chunk-AWCWIQAU.js +2686 -0
- package/dist/{chunk-JBZZEIM2.js → chunk-BBOHY2DQ.js} +2 -13
- package/dist/{chunk-AZFPA7JV.js → chunk-BU3VAG5J.js} +6 -4
- package/dist/{chunk-4YCGZGA3.js → chunk-BYOK6Z4F.js} +2 -2
- package/dist/chunk-DSNSD5J3.js +971 -0
- package/dist/chunk-EGIZNSDA.js +94 -0
- package/dist/chunk-ELCLGWUT.js +83 -0
- package/dist/chunk-FC4XND45.js +38 -0
- package/dist/chunk-GNKOBKPW.js +58 -0
- package/dist/chunk-HEGXGCGL.js +524 -0
- package/dist/chunk-I6KNMZ77.js +232 -0
- package/dist/{chunk-HLVEB5TB.js → chunk-IIOEAJTV.js} +7 -5
- package/dist/chunk-ILDT4LPB.js +1273 -0
- package/dist/chunk-JY3RLZGB.js +30 -0
- package/dist/{chunk-PLYJX67A.js → chunk-K5I45PZI.js} +8084 -13939
- package/dist/chunk-KXAOMTXN.js +1034 -0
- package/dist/chunk-LK2BG6EX.js +145 -0
- package/dist/chunk-MJNUSPO4.js +15 -0
- package/dist/chunk-MKAC7HKH.js +9178 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/{chunk-SFMWHPMX.js → chunk-O4RMPA6H.js} +13765 -13737
- package/dist/chunk-O77IBNVO.js +8264 -0
- package/dist/chunk-OFL4PTYU.js +644 -0
- package/dist/chunk-QLPLENDT.js +133 -0
- package/dist/chunk-R2J4SNKF.js +78 -0
- package/dist/{chunk-KEATAHXH.js → chunk-RVUCY4ZV.js} +358 -581
- package/dist/chunk-SNFBJKAW.js +530 -0
- package/dist/chunk-TALC5DX5.js +420 -0
- package/dist/chunk-TSENU4GG.js +18 -0
- package/dist/{chunk-HAHXPJQ5.js → chunk-V5D4XNWV.js} +16 -1684
- package/dist/chunk-VJWDBFSL.js +69 -0
- package/dist/chunk-XEBKF4N5.js +8 -0
- package/dist/chunk-Y4GK7GCV.js +15376 -0
- package/dist/{chunk-A3WSAAQS.js → chunk-YSEC6TIB.js} +7917 -33199
- package/dist/chunk-Z7IUAJOF.js +13 -0
- package/dist/citations-NSBBWRZ4.js +106 -0
- package/dist/{cli-catalog-MO6Z2CIZ.js → cli-catalog-OFWJMNMD.js} +5 -3
- package/dist/cli-commands-WVBL337U.js +19 -0
- package/dist/cli.js +35 -29
- package/dist/competitor-V4OHORBC.js +561 -0
- package/dist/content-RUXRI5IC.js +257 -0
- package/dist/dashboard-JXB2YAQJ.js +71 -0
- package/dist/demo-55ZNUOXU.js +75 -0
- package/dist/{demo-server-GIWDJGJX.js → demo-server-XO7PHM4I.js} +22 -9
- package/dist/discover-JJQ564HS.js +372 -0
- package/dist/discover-eval-KLEKZ6U4.js +282 -0
- package/dist/doctor-JAMQZCMZ.js +152 -0
- package/dist/evidence-YRSB7GFE.js +57 -0
- package/dist/export-cmd-MHML4OYU.js +49 -0
- package/dist/ga-LSXPE2MN.js +911 -0
- package/dist/gbp-RMKMLOC7.js +370 -0
- package/dist/google-JQ4T6JTQ.js +946 -0
- package/dist/google-marketing-J6SEODYC.js +403 -0
- package/dist/health-cmd-MV2JM2C3.js +64 -0
- package/dist/history-SRRH7A2E.js +90 -0
- package/dist/index.d.ts +43 -4
- package/dist/index.js +29 -6
- package/dist/init-ZJZFUERV.js +432 -0
- package/dist/insights-PMMGNWZH.js +63 -0
- package/dist/intelligence-service-KCSU6ZUJ.js +15 -0
- package/dist/keys-TS7NZANS.js +116 -0
- package/dist/keyword-VNCKDUGC.js +164 -0
- package/dist/logs-VH3WOTZJ.js +30 -0
- package/dist/mcp-DG2RROB3.js +14 -0
- package/dist/mcp.js +14 -5
- package/dist/measurement-plan-4T35TUGG.js +42 -0
- package/dist/notify-BWHUSKL7.js +125 -0
- package/dist/organic-evidence-QX4SXXJP.js +53 -0
- package/dist/overview-7IHUTKUV.js +213 -0
- package/dist/project-JXLSWDE2.js +460 -0
- package/dist/query-S75EL25H.js +211 -0
- package/dist/research-KFTV3IP4.js +200 -0
- package/dist/results-export-GTKVBU34.js +27 -0
- package/dist/run-26HDIRHF.js +31 -0
- package/dist/schedule-N6G4SVHQ.js +177 -0
- package/dist/search-MI32EPYM.js +42 -0
- package/dist/serve-XLGE42AG.js +598 -0
- package/dist/session-W5DXWIYM.js +47 -0
- package/dist/settings-T7WI2UVE.js +107 -0
- package/dist/skills-F3WPKPTK.js +33 -0
- package/dist/snapshot-PD3EAVEX.js +538 -0
- package/dist/src-XDUXMJC3.js +316 -0
- package/dist/status-PUH7JFZ4.js +126 -0
- package/dist/support-ARF4HER7.js +24 -0
- package/dist/technical-aeo-AUFWWJIP.js +625 -0
- package/dist/telemetry-XBYT7G2K.js +118 -0
- package/dist/tools-GVHIRWSN.js +41 -0
- package/dist/traffic-B3HW2ZWG.js +1295 -0
- package/dist/users-M5HNQZYI.js +170 -0
- package/dist/visibility-stats-Y7GJKMHN.js +241 -0
- package/dist/wordpress-GCIURYPN.js +600 -0
- package/package.json +1 -1
- package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +0 -4
- package/assets/assets/SiteHealthSection-PWjKMmEn.js +0 -2
- package/assets/assets/TrafficPage-DkfGiJXR.js +0 -40
- package/assets/assets/index-CG1Jox52.js +0 -39
- package/dist/chunk-4QQYYRHV.js +0 -23082
- package/dist/cli-commands-FOJR3HHU.js +0 -15
- package/dist/intelligence-service-XQCNWAPL.js +0 -9
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setGoogleAuthConfig
|
|
3
|
+
} from "./chunk-ELCLGWUT.js";
|
|
4
|
+
import {
|
|
5
|
+
createApiClient
|
|
6
|
+
} from "./chunk-V5D4XNWV.js";
|
|
7
|
+
import {
|
|
8
|
+
getConfigPath,
|
|
9
|
+
loadConfig,
|
|
10
|
+
saveConfigPatch
|
|
11
|
+
} from "./chunk-OFL4PTYU.js";
|
|
12
|
+
import "./chunk-AOJU5LKX.js";
|
|
13
|
+
import {
|
|
14
|
+
isMachineFormat
|
|
15
|
+
} from "./chunk-HGMYEDAQ.js";
|
|
16
|
+
import "./chunk-O4RMPA6H.js";
|
|
17
|
+
import "./chunk-MLKGABMK.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/settings.ts
|
|
20
|
+
function getClient() {
|
|
21
|
+
return createApiClient();
|
|
22
|
+
}
|
|
23
|
+
async function setProvider(name, opts) {
|
|
24
|
+
const client = getClient();
|
|
25
|
+
const { format, ...payload } = opts;
|
|
26
|
+
const result = await client.updateProvider(name, payload);
|
|
27
|
+
if (isMachineFormat(format)) {
|
|
28
|
+
console.log(JSON.stringify(result, null, 2));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.log(`Provider ${result.name} updated successfully.`);
|
|
32
|
+
if (result.model) {
|
|
33
|
+
console.log(` Model: ${result.model}`);
|
|
34
|
+
}
|
|
35
|
+
if (result.quota) {
|
|
36
|
+
console.log(` Quota: ${result.quota.maxConcurrency} concurrent \xB7 ${result.quota.maxRequestsPerMinute}/min \xB7 ${result.quota.maxRequestsPerDay}/day`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function showSettings(format) {
|
|
40
|
+
const client = getClient();
|
|
41
|
+
const settings = await client.getSettings();
|
|
42
|
+
if (isMachineFormat(format)) {
|
|
43
|
+
console.log(JSON.stringify(settings, null, 2));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.log("Provider settings:\n");
|
|
47
|
+
for (const provider of settings.providers) {
|
|
48
|
+
const status = provider.configured ? "configured" : "not configured";
|
|
49
|
+
console.log(` ${provider.name.padEnd(10)} ${status}`);
|
|
50
|
+
if (provider.configured) {
|
|
51
|
+
const modelLabel = provider.model ? provider.model : provider.defaultModel ? `${provider.defaultModel} (default)` : "(default)";
|
|
52
|
+
console.log(` Model: ${modelLabel}`);
|
|
53
|
+
if (provider.quota) {
|
|
54
|
+
console.log(` Quota: ${provider.quota.maxConcurrency} concurrent \xB7 ${provider.quota.maxRequestsPerMinute}/min \xB7 ${provider.quota.maxRequestsPerDay}/day`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log("\nGoogle OAuth:\n");
|
|
59
|
+
console.log(` ${settings.google.configured ? "configured" : "not configured"}`);
|
|
60
|
+
}
|
|
61
|
+
async function reloadProviders(format) {
|
|
62
|
+
const result = await getClient().reloadProviders();
|
|
63
|
+
if (isMachineFormat(format)) {
|
|
64
|
+
console.log(JSON.stringify(result, null, 2));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.log("Saved provider configuration is now active on the server.");
|
|
68
|
+
for (const provider of result.providers) {
|
|
69
|
+
console.log(` ${provider.name}: ${provider.configured ? "configured" : "not configured"}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function setGoogleAuth(opts) {
|
|
73
|
+
if (opts.target === "server") {
|
|
74
|
+
const result = await getClient().updateGoogleSettings({
|
|
75
|
+
clientId: opts.clientId,
|
|
76
|
+
clientSecret: opts.clientSecret
|
|
77
|
+
});
|
|
78
|
+
if (isMachineFormat(opts.format)) {
|
|
79
|
+
console.log(JSON.stringify(result, null, 2));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
console.log("Google OAuth credentials updated on the server.");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const config = loadConfig();
|
|
86
|
+
setGoogleAuthConfig(config, {
|
|
87
|
+
clientId: opts.clientId,
|
|
88
|
+
clientSecret: opts.clientSecret
|
|
89
|
+
});
|
|
90
|
+
saveConfigPatch(config);
|
|
91
|
+
if (isMachineFormat(opts.format)) {
|
|
92
|
+
console.log(JSON.stringify({
|
|
93
|
+
configured: true,
|
|
94
|
+
configPath: getConfigPath(),
|
|
95
|
+
restartRequired: true
|
|
96
|
+
}, null, 2));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
console.log(`Google OAuth credentials saved to ${getConfigPath()}.`);
|
|
100
|
+
console.log("Restart the local server if it is already running.");
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
reloadProviders,
|
|
104
|
+
setGoogleAuth,
|
|
105
|
+
setProvider,
|
|
106
|
+
showSettings
|
|
107
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUNDLED_SKILL_NAMES,
|
|
3
|
+
emitInstallSummary,
|
|
4
|
+
getBundledSkillSnapshots,
|
|
5
|
+
getBundledSkills,
|
|
6
|
+
getMissingUserSkillsNudge,
|
|
7
|
+
installSkills,
|
|
8
|
+
listSkills,
|
|
9
|
+
parseSkillsClient,
|
|
10
|
+
resolveBundledSkillsRoot,
|
|
11
|
+
shouldPrintServeSkillsNudge
|
|
12
|
+
} from "./chunk-TALC5DX5.js";
|
|
13
|
+
import "./chunk-AOJU5LKX.js";
|
|
14
|
+
import "./chunk-HGMYEDAQ.js";
|
|
15
|
+
import {
|
|
16
|
+
CodingAgents,
|
|
17
|
+
SkillsClients
|
|
18
|
+
} from "./chunk-O4RMPA6H.js";
|
|
19
|
+
import "./chunk-MLKGABMK.js";
|
|
20
|
+
export {
|
|
21
|
+
BUNDLED_SKILL_NAMES,
|
|
22
|
+
CodingAgents,
|
|
23
|
+
SkillsClients,
|
|
24
|
+
emitInstallSummary,
|
|
25
|
+
getBundledSkillSnapshots,
|
|
26
|
+
getBundledSkills,
|
|
27
|
+
getMissingUserSkillsNudge,
|
|
28
|
+
installSkills,
|
|
29
|
+
listSkills,
|
|
30
|
+
parseSkillsClient,
|
|
31
|
+
resolveBundledSkillsRoot,
|
|
32
|
+
shouldPrintServeSkillsNudge
|
|
33
|
+
};
|
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatAuditFactorScore
|
|
3
|
+
} from "./chunk-XEBKF4N5.js";
|
|
4
|
+
import {
|
|
5
|
+
createApiClient
|
|
6
|
+
} from "./chunk-V5D4XNWV.js";
|
|
7
|
+
import "./chunk-OFL4PTYU.js";
|
|
8
|
+
import "./chunk-AOJU5LKX.js";
|
|
9
|
+
import {
|
|
10
|
+
isMachineFormat
|
|
11
|
+
} from "./chunk-HGMYEDAQ.js";
|
|
12
|
+
import {
|
|
13
|
+
factorStatusFromScore
|
|
14
|
+
} from "./chunk-O4RMPA6H.js";
|
|
15
|
+
import "./chunk-MLKGABMK.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/snapshot.ts
|
|
18
|
+
import fs2 from "fs";
|
|
19
|
+
import path2 from "path";
|
|
20
|
+
|
|
21
|
+
// src/snapshot-pdf.ts
|
|
22
|
+
import fs from "fs";
|
|
23
|
+
import path from "path";
|
|
24
|
+
import { PDFDocument, StandardFonts, rgb } from "pdf-lib";
|
|
25
|
+
var PAGE_WIDTH = 612;
|
|
26
|
+
var PAGE_HEIGHT = 792;
|
|
27
|
+
var MARGIN = 48;
|
|
28
|
+
var BRAND = rgb(0.58, 0, 0);
|
|
29
|
+
var INK = rgb(0.1, 0.1, 0.1);
|
|
30
|
+
var MUTED = rgb(0.38, 0.38, 0.38);
|
|
31
|
+
var LINE = rgb(0.82, 0.8, 0.76);
|
|
32
|
+
var PASS = rgb(0.18, 0.49, 0.31);
|
|
33
|
+
var CAUTION = rgb(0.72, 0.45, 0.2);
|
|
34
|
+
var FAIL = rgb(0.7, 0.15, 0.15);
|
|
35
|
+
var PdfWriter = class {
|
|
36
|
+
constructor(doc, regular, bold) {
|
|
37
|
+
this.doc = doc;
|
|
38
|
+
this.regular = regular;
|
|
39
|
+
this.bold = bold;
|
|
40
|
+
this.addPage();
|
|
41
|
+
}
|
|
42
|
+
doc;
|
|
43
|
+
regular;
|
|
44
|
+
bold;
|
|
45
|
+
usableWidth = PAGE_WIDTH - MARGIN * 2;
|
|
46
|
+
page;
|
|
47
|
+
y = 0;
|
|
48
|
+
addPage() {
|
|
49
|
+
this.page = this.doc.addPage([PAGE_WIDTH, PAGE_HEIGHT]);
|
|
50
|
+
this.y = PAGE_HEIGHT - MARGIN;
|
|
51
|
+
}
|
|
52
|
+
ensureSpace(height) {
|
|
53
|
+
if (this.y - height < MARGIN) {
|
|
54
|
+
this.addPage();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
heading(text, size = 18) {
|
|
58
|
+
this.ensureSpace(size + 12);
|
|
59
|
+
this.page.drawText(text, {
|
|
60
|
+
x: MARGIN,
|
|
61
|
+
y: this.y,
|
|
62
|
+
size,
|
|
63
|
+
font: this.bold,
|
|
64
|
+
color: BRAND
|
|
65
|
+
});
|
|
66
|
+
this.y -= size + 8;
|
|
67
|
+
}
|
|
68
|
+
subheading(text, size = 12) {
|
|
69
|
+
this.ensureSpace(size + 8);
|
|
70
|
+
this.page.drawText(text, {
|
|
71
|
+
x: MARGIN,
|
|
72
|
+
y: this.y,
|
|
73
|
+
size,
|
|
74
|
+
font: this.bold,
|
|
75
|
+
color: INK
|
|
76
|
+
});
|
|
77
|
+
this.y -= size + 6;
|
|
78
|
+
}
|
|
79
|
+
paragraph(text, opts) {
|
|
80
|
+
const size = opts?.size ?? 10;
|
|
81
|
+
const color = opts?.color ?? INK;
|
|
82
|
+
const lineHeight = opts?.lineHeight ?? size + 4;
|
|
83
|
+
const lines = wrapText(this.regular, text, size, this.usableWidth);
|
|
84
|
+
this.ensureSpace(lines.length * lineHeight + 4);
|
|
85
|
+
for (const line of lines) {
|
|
86
|
+
this.page.drawText(line, {
|
|
87
|
+
x: MARGIN,
|
|
88
|
+
y: this.y,
|
|
89
|
+
size,
|
|
90
|
+
font: this.regular,
|
|
91
|
+
color
|
|
92
|
+
});
|
|
93
|
+
this.y -= lineHeight;
|
|
94
|
+
}
|
|
95
|
+
this.y -= 2;
|
|
96
|
+
}
|
|
97
|
+
bullet(text) {
|
|
98
|
+
const lines = wrapText(this.regular, text, 10, this.usableWidth - 14);
|
|
99
|
+
this.ensureSpace(lines.length * 14 + 2);
|
|
100
|
+
this.page.drawText("-", {
|
|
101
|
+
x: MARGIN,
|
|
102
|
+
y: this.y,
|
|
103
|
+
size: 10,
|
|
104
|
+
font: this.bold,
|
|
105
|
+
color: BRAND
|
|
106
|
+
});
|
|
107
|
+
let first = true;
|
|
108
|
+
for (const line of lines) {
|
|
109
|
+
this.page.drawText(line, {
|
|
110
|
+
x: MARGIN + 14,
|
|
111
|
+
y: this.y,
|
|
112
|
+
size: 10,
|
|
113
|
+
font: this.regular,
|
|
114
|
+
color: INK
|
|
115
|
+
});
|
|
116
|
+
this.y -= 14;
|
|
117
|
+
if (first) first = false;
|
|
118
|
+
}
|
|
119
|
+
this.y -= 2;
|
|
120
|
+
}
|
|
121
|
+
rule() {
|
|
122
|
+
this.ensureSpace(8);
|
|
123
|
+
this.page.drawLine({
|
|
124
|
+
start: { x: MARGIN, y: this.y },
|
|
125
|
+
end: { x: PAGE_WIDTH - MARGIN, y: this.y },
|
|
126
|
+
thickness: 1,
|
|
127
|
+
color: LINE
|
|
128
|
+
});
|
|
129
|
+
this.y -= 10;
|
|
130
|
+
}
|
|
131
|
+
keyValue(label, value) {
|
|
132
|
+
const size = 10;
|
|
133
|
+
const labelWidth = this.bold.widthOfTextAtSize(`${label}: `, size);
|
|
134
|
+
this.ensureSpace(16);
|
|
135
|
+
this.page.drawText(`${label}:`, {
|
|
136
|
+
x: MARGIN,
|
|
137
|
+
y: this.y,
|
|
138
|
+
size,
|
|
139
|
+
font: this.bold,
|
|
140
|
+
color: INK
|
|
141
|
+
});
|
|
142
|
+
const lines = wrapText(this.regular, value, size, this.usableWidth - labelWidth - 4);
|
|
143
|
+
let currentY = this.y;
|
|
144
|
+
for (const line of lines) {
|
|
145
|
+
this.page.drawText(line, {
|
|
146
|
+
x: MARGIN + labelWidth + 4,
|
|
147
|
+
y: currentY,
|
|
148
|
+
size,
|
|
149
|
+
font: this.regular,
|
|
150
|
+
color: INK
|
|
151
|
+
});
|
|
152
|
+
currentY -= 14;
|
|
153
|
+
}
|
|
154
|
+
this.y = currentY - 2;
|
|
155
|
+
}
|
|
156
|
+
table(headers, rows, widths) {
|
|
157
|
+
const columnWidths = widths ?? headers.map(() => this.usableWidth / headers.length);
|
|
158
|
+
const headerHeight = 20;
|
|
159
|
+
this.ensureSpace(headerHeight + 10);
|
|
160
|
+
let x = MARGIN;
|
|
161
|
+
for (let i = 0; i < headers.length; i++) {
|
|
162
|
+
const width = columnWidths[i];
|
|
163
|
+
this.page.drawRectangle({
|
|
164
|
+
x,
|
|
165
|
+
y: this.y - headerHeight + 4,
|
|
166
|
+
width,
|
|
167
|
+
height: headerHeight,
|
|
168
|
+
color: BRAND
|
|
169
|
+
});
|
|
170
|
+
const lines = wrapText(this.bold, headers[i], 9, width - 8);
|
|
171
|
+
let lineY = this.y - 10;
|
|
172
|
+
for (const line of lines) {
|
|
173
|
+
this.page.drawText(line, {
|
|
174
|
+
x: x + 4,
|
|
175
|
+
y: lineY,
|
|
176
|
+
size: 9,
|
|
177
|
+
font: this.bold,
|
|
178
|
+
color: rgb(1, 0.98, 0.93)
|
|
179
|
+
});
|
|
180
|
+
lineY -= 10;
|
|
181
|
+
}
|
|
182
|
+
x += width;
|
|
183
|
+
}
|
|
184
|
+
this.y -= headerHeight + 4;
|
|
185
|
+
for (const row of rows) {
|
|
186
|
+
const lineCounts = row.map((cell, index) => wrapText(this.regular, cell, 9, columnWidths[index] - 8).length);
|
|
187
|
+
const rowHeight = Math.max(18, Math.max(...lineCounts) * 11 + 6);
|
|
188
|
+
this.ensureSpace(rowHeight + 4);
|
|
189
|
+
let cellX = MARGIN;
|
|
190
|
+
for (let i = 0; i < row.length; i++) {
|
|
191
|
+
const width = columnWidths[i];
|
|
192
|
+
this.page.drawRectangle({
|
|
193
|
+
x: cellX,
|
|
194
|
+
y: this.y - rowHeight + 4,
|
|
195
|
+
width,
|
|
196
|
+
height: rowHeight,
|
|
197
|
+
borderColor: LINE,
|
|
198
|
+
borderWidth: 0.5
|
|
199
|
+
});
|
|
200
|
+
const lines = wrapText(this.regular, row[i], 9, width - 8);
|
|
201
|
+
let lineY = this.y - 10;
|
|
202
|
+
for (const line of lines) {
|
|
203
|
+
this.page.drawText(line, {
|
|
204
|
+
x: cellX + 4,
|
|
205
|
+
y: lineY,
|
|
206
|
+
size: 9,
|
|
207
|
+
font: this.regular,
|
|
208
|
+
color: INK
|
|
209
|
+
});
|
|
210
|
+
lineY -= 11;
|
|
211
|
+
}
|
|
212
|
+
cellX += width;
|
|
213
|
+
}
|
|
214
|
+
this.y -= rowHeight + 2;
|
|
215
|
+
}
|
|
216
|
+
this.y -= 4;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
async function writeSnapshotPdf(report, outputPath) {
|
|
220
|
+
const doc = await PDFDocument.create();
|
|
221
|
+
doc.setTitle(`${report.companyName} AI Perception Snapshot`);
|
|
222
|
+
doc.setAuthor("Canonry");
|
|
223
|
+
doc.setSubject("AEO snapshot report");
|
|
224
|
+
doc.setProducer("Canonry");
|
|
225
|
+
doc.setCreator("Canonry");
|
|
226
|
+
const regular = await doc.embedFont(StandardFonts.Helvetica);
|
|
227
|
+
const bold = await doc.embedFont(StandardFonts.HelveticaBold);
|
|
228
|
+
const pdf = new PdfWriter(doc, regular, bold);
|
|
229
|
+
renderCover(pdf, report);
|
|
230
|
+
renderSummary(pdf, report);
|
|
231
|
+
renderAudit(pdf, report);
|
|
232
|
+
renderCompetitors(pdf, report);
|
|
233
|
+
renderQueries(pdf, report);
|
|
234
|
+
const bytes = await doc.save();
|
|
235
|
+
const resolvedPath = path.resolve(outputPath);
|
|
236
|
+
fs.mkdirSync(path.dirname(resolvedPath), { recursive: true });
|
|
237
|
+
fs.writeFileSync(resolvedPath, bytes);
|
|
238
|
+
return resolvedPath;
|
|
239
|
+
}
|
|
240
|
+
function renderCover(pdf, report) {
|
|
241
|
+
pdf.heading("AI Perception Snapshot", 24);
|
|
242
|
+
pdf.paragraph(report.companyName, { size: 15, color: INK, lineHeight: 18 });
|
|
243
|
+
pdf.paragraph(report.domain, { size: 11, color: MUTED, lineHeight: 14 });
|
|
244
|
+
pdf.rule();
|
|
245
|
+
pdf.keyValue("Generated", new Date(report.generatedAt).toLocaleString("en-US", {
|
|
246
|
+
year: "numeric",
|
|
247
|
+
month: "long",
|
|
248
|
+
day: "numeric",
|
|
249
|
+
hour: "numeric",
|
|
250
|
+
minute: "2-digit"
|
|
251
|
+
}));
|
|
252
|
+
pdf.keyValue("AEO Audit", `${report.audit.overallScore}/100`);
|
|
253
|
+
pdf.keyValue("Visibility Gap (Citations + Mentions)", report.summary.visibilityGap);
|
|
254
|
+
pdf.paragraph(report.profile.summary, { size: 11, color: INK, lineHeight: 16 });
|
|
255
|
+
pdf.rule();
|
|
256
|
+
}
|
|
257
|
+
function renderSummary(pdf, report) {
|
|
258
|
+
pdf.heading("What This Means");
|
|
259
|
+
for (const line of report.summary.whatThisMeans) {
|
|
260
|
+
pdf.bullet(line);
|
|
261
|
+
}
|
|
262
|
+
pdf.subheading("Recommended Actions");
|
|
263
|
+
for (const action of report.summary.recommendedActions) {
|
|
264
|
+
pdf.bullet(action);
|
|
265
|
+
}
|
|
266
|
+
pdf.rule();
|
|
267
|
+
}
|
|
268
|
+
function renderAudit(pdf, report) {
|
|
269
|
+
pdf.heading("Audit Snapshot");
|
|
270
|
+
pdf.paragraph(report.audit.summary, { size: 10, color: MUTED, lineHeight: 14 });
|
|
271
|
+
const factorRows = [...report.audit.factors].sort((a, b) => a.score - b.score || a.name.localeCompare(b.name)).slice(0, 5).map((factor) => [
|
|
272
|
+
factor.name,
|
|
273
|
+
formatAuditFactorScore(factor),
|
|
274
|
+
factorStatusFromScore(factor.score)
|
|
275
|
+
]);
|
|
276
|
+
if (factorRows.length > 0) {
|
|
277
|
+
pdf.table(["Weakest factor", "Score / Weight", "Status"], factorRows, [270, 120, 126]);
|
|
278
|
+
}
|
|
279
|
+
pdf.rule();
|
|
280
|
+
}
|
|
281
|
+
function renderCompetitors(pdf, report) {
|
|
282
|
+
pdf.heading("Recommended Instead");
|
|
283
|
+
if (report.summary.topCompetitors.length === 0) {
|
|
284
|
+
pdf.paragraph("No clear competitor cluster was extracted from the responses.", {
|
|
285
|
+
size: 10,
|
|
286
|
+
color: MUTED
|
|
287
|
+
});
|
|
288
|
+
pdf.rule();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
pdf.table(
|
|
292
|
+
["Competitor", "Mentions"],
|
|
293
|
+
report.summary.topCompetitors.map((entry) => [entry.name, String(entry.count)]),
|
|
294
|
+
[420, 96]
|
|
295
|
+
);
|
|
296
|
+
pdf.rule();
|
|
297
|
+
}
|
|
298
|
+
function renderQueries(pdf, report) {
|
|
299
|
+
pdf.heading("Provider Comparison");
|
|
300
|
+
for (const queryResult of report.queryResults) {
|
|
301
|
+
pdf.subheading(queryResult.query, 11);
|
|
302
|
+
for (const result of queryResult.providerResults) {
|
|
303
|
+
const status = result.error ? "error" : result.mentioned ? result.cited ? "mentioned and cited" : "mentioned" : "not mentioned";
|
|
304
|
+
const accuracy = result.describedAccurately === "not-mentioned" ? "" : `; accuracy: ${result.describedAccurately}`;
|
|
305
|
+
const competitors = result.recommendedCompetitors.length > 0 ? `; recommended instead: ${result.recommendedCompetitors.join(", ")}` : "";
|
|
306
|
+
const line = `${result.displayName}: ${status}${accuracy}${competitors}`;
|
|
307
|
+
pdf.bullet(line);
|
|
308
|
+
if (result.error) {
|
|
309
|
+
pdf.paragraph(`Error: ${result.error}`, { size: 9, color: FAIL, lineHeight: 12 });
|
|
310
|
+
} else if (result.accuracyNotes) {
|
|
311
|
+
const color = result.describedAccurately === "yes" ? PASS : result.describedAccurately === "no" ? FAIL : CAUTION;
|
|
312
|
+
pdf.paragraph(result.accuracyNotes, { size: 9, color, lineHeight: 12 });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
pdf.rule();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function wrapText(font, text, size, maxWidth) {
|
|
319
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
320
|
+
if (!normalized) return [""];
|
|
321
|
+
const words = normalized.split(" ");
|
|
322
|
+
const lines = [];
|
|
323
|
+
let current = "";
|
|
324
|
+
for (const word of words) {
|
|
325
|
+
const next = current ? `${current} ${word}` : word;
|
|
326
|
+
if (font.widthOfTextAtSize(next, size) <= maxWidth) {
|
|
327
|
+
current = next;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (current) {
|
|
331
|
+
lines.push(current);
|
|
332
|
+
current = word;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
let chunk = "";
|
|
336
|
+
for (const char of word) {
|
|
337
|
+
const candidate = `${chunk}${char}`;
|
|
338
|
+
if (font.widthOfTextAtSize(candidate, size) <= maxWidth) {
|
|
339
|
+
chunk = candidate;
|
|
340
|
+
} else {
|
|
341
|
+
if (chunk) lines.push(chunk);
|
|
342
|
+
chunk = char;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
current = chunk;
|
|
346
|
+
}
|
|
347
|
+
if (current) lines.push(current);
|
|
348
|
+
return lines;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/commands/snapshot.ts
|
|
352
|
+
function getClient() {
|
|
353
|
+
return createApiClient();
|
|
354
|
+
}
|
|
355
|
+
function slugify(value) {
|
|
356
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
357
|
+
}
|
|
358
|
+
function autoOutputPath(companyName, ext) {
|
|
359
|
+
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
360
|
+
return `${slugify(companyName)}-snapshot-${date}.${ext}`;
|
|
361
|
+
}
|
|
362
|
+
async function createSnapshotReport(companyName, opts) {
|
|
363
|
+
const client = getClient();
|
|
364
|
+
const report = await client.createSnapshot({
|
|
365
|
+
companyName,
|
|
366
|
+
domain: opts.domain,
|
|
367
|
+
...opts.providers !== void 0 ? { providers: opts.providers } : {},
|
|
368
|
+
...opts.providerMode !== void 0 ? { providerMode: opts.providerMode } : {},
|
|
369
|
+
...opts.queries && opts.queries.length > 0 ? { queries: opts.queries } : {},
|
|
370
|
+
...opts.competitors && opts.competitors.length > 0 ? { competitors: opts.competitors } : {}
|
|
371
|
+
});
|
|
372
|
+
let savedMdPath;
|
|
373
|
+
if (opts.md) {
|
|
374
|
+
const mdPath = opts.outputPath ?? autoOutputPath(companyName, "md");
|
|
375
|
+
savedMdPath = writeSnapshotMarkdown(report, mdPath);
|
|
376
|
+
}
|
|
377
|
+
let savedPdfPath;
|
|
378
|
+
if (opts.pdf) {
|
|
379
|
+
const pdfPath = opts.outputPath && !opts.md ? opts.outputPath : autoOutputPath(companyName, "pdf");
|
|
380
|
+
savedPdfPath = await writeSnapshotPdf(report, pdfPath);
|
|
381
|
+
}
|
|
382
|
+
if (isMachineFormat(opts.format)) {
|
|
383
|
+
console.log(JSON.stringify(report, null, 2));
|
|
384
|
+
if (savedMdPath) process.stderr.write(`Saved markdown: ${savedMdPath}
|
|
385
|
+
`);
|
|
386
|
+
if (savedPdfPath) process.stderr.write(`Saved PDF: ${savedPdfPath}
|
|
387
|
+
`);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
console.log(formatSnapshotText(report));
|
|
391
|
+
if (savedMdPath) console.log(`
|
|
392
|
+
Markdown saved: ${savedMdPath}`);
|
|
393
|
+
if (savedPdfPath) console.log(`
|
|
394
|
+
PDF saved: ${savedPdfPath}`);
|
|
395
|
+
}
|
|
396
|
+
function writeSnapshotMarkdown(report, outputPath) {
|
|
397
|
+
const resolvedPath = path2.resolve(outputPath);
|
|
398
|
+
fs2.mkdirSync(path2.dirname(resolvedPath), { recursive: true });
|
|
399
|
+
fs2.writeFileSync(resolvedPath, formatSnapshotMarkdown(report), "utf-8");
|
|
400
|
+
return resolvedPath;
|
|
401
|
+
}
|
|
402
|
+
function formatSnapshotMarkdown(report) {
|
|
403
|
+
const lines = [];
|
|
404
|
+
lines.push(`# AI Perception Snapshot: ${report.companyName}`);
|
|
405
|
+
lines.push("");
|
|
406
|
+
lines.push(`**Domain:** ${report.domain}`);
|
|
407
|
+
lines.push(`**Generated:** ${new Date(report.generatedAt).toLocaleString("en-US", { year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "2-digit" })}`);
|
|
408
|
+
lines.push(`**AEO Audit Score:** ${report.audit.overallScore}/100`);
|
|
409
|
+
lines.push("");
|
|
410
|
+
lines.push("## Visibility Gap (Citations + Mentions)");
|
|
411
|
+
lines.push("");
|
|
412
|
+
lines.push(report.summary.visibilityGap);
|
|
413
|
+
lines.push("");
|
|
414
|
+
if (report.summary.whatThisMeans.length > 0) {
|
|
415
|
+
lines.push("## What This Means");
|
|
416
|
+
lines.push("");
|
|
417
|
+
for (const item of report.summary.whatThisMeans) {
|
|
418
|
+
lines.push(`- ${item}`);
|
|
419
|
+
}
|
|
420
|
+
lines.push("");
|
|
421
|
+
}
|
|
422
|
+
if (report.summary.recommendedActions.length > 0) {
|
|
423
|
+
lines.push("## Recommended Actions");
|
|
424
|
+
lines.push("");
|
|
425
|
+
for (const action of report.summary.recommendedActions) {
|
|
426
|
+
lines.push(`- ${action}`);
|
|
427
|
+
}
|
|
428
|
+
lines.push("");
|
|
429
|
+
}
|
|
430
|
+
if (report.summary.topCompetitors.length > 0) {
|
|
431
|
+
lines.push("## Competitors AI Recommends Instead");
|
|
432
|
+
lines.push("");
|
|
433
|
+
lines.push("| Competitor | Mentions |");
|
|
434
|
+
lines.push("|------------|----------|");
|
|
435
|
+
for (const entry of report.summary.topCompetitors) {
|
|
436
|
+
lines.push(`| ${entry.name} | ${entry.count} |`);
|
|
437
|
+
}
|
|
438
|
+
lines.push("");
|
|
439
|
+
}
|
|
440
|
+
lines.push("## Provider Comparison");
|
|
441
|
+
lines.push("");
|
|
442
|
+
for (const queryResult of report.queryResults) {
|
|
443
|
+
lines.push(`### "${queryResult.query}"`);
|
|
444
|
+
lines.push("");
|
|
445
|
+
lines.push("| Provider | Mentioned | Cited | Accuracy | Competitors Recommended |");
|
|
446
|
+
lines.push("|----------|-----------|-------|----------|------------------------|");
|
|
447
|
+
for (const result of queryResult.providerResults) {
|
|
448
|
+
if (result.error) {
|
|
449
|
+
lines.push(`| ${result.displayName} | ERROR | - | - | ${result.error} |`);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
const mentioned = result.mentioned ? "Yes" : "No";
|
|
453
|
+
const cited = result.cited ? "Yes" : "No";
|
|
454
|
+
const accuracy = result.describedAccurately === "not-mentioned" ? "-" : result.describedAccurately;
|
|
455
|
+
const competitors = result.recommendedCompetitors.length > 0 ? result.recommendedCompetitors.join(", ") : "-";
|
|
456
|
+
lines.push(`| ${result.displayName} | ${mentioned} | ${cited} | ${accuracy} | ${competitors} |`);
|
|
457
|
+
}
|
|
458
|
+
lines.push("");
|
|
459
|
+
}
|
|
460
|
+
if (report.audit.factors.length > 0) {
|
|
461
|
+
lines.push("## Audit Factors");
|
|
462
|
+
lines.push("");
|
|
463
|
+
lines.push(report.audit.summary);
|
|
464
|
+
lines.push("");
|
|
465
|
+
lines.push("| Factor | Score | Weight | Status |");
|
|
466
|
+
lines.push("|--------|-------|--------|--------|");
|
|
467
|
+
const sorted = [...report.audit.factors].sort((a, b) => a.score - b.score);
|
|
468
|
+
for (const factor of sorted) {
|
|
469
|
+
lines.push(`| ${factor.name} | ${factor.score} | ${factor.weight} | ${factorStatusFromScore(factor.score)} |`);
|
|
470
|
+
}
|
|
471
|
+
lines.push("");
|
|
472
|
+
}
|
|
473
|
+
lines.push("---");
|
|
474
|
+
lines.push(`*Generated by [Canonry](https://github.com/Canonry/canonry)*`);
|
|
475
|
+
return lines.join("\n");
|
|
476
|
+
}
|
|
477
|
+
function formatSnapshotText(report) {
|
|
478
|
+
const lines = [];
|
|
479
|
+
lines.push(`Snapshot: ${report.companyName} (${report.domain})`);
|
|
480
|
+
lines.push(`AEO audit: ${report.audit.overallScore}/100`);
|
|
481
|
+
lines.push(report.summary.visibilityGap);
|
|
482
|
+
lines.push("");
|
|
483
|
+
if (report.summary.topCompetitors.length > 0) {
|
|
484
|
+
lines.push(
|
|
485
|
+
`Top competitors AI recommended instead: ${report.summary.topCompetitors.map((entry) => `${entry.name} (${entry.count})`).join(", ")}`
|
|
486
|
+
);
|
|
487
|
+
lines.push("");
|
|
488
|
+
}
|
|
489
|
+
if (report.summary.whatThisMeans.length > 0) {
|
|
490
|
+
lines.push("What this means:");
|
|
491
|
+
for (const item of report.summary.whatThisMeans) {
|
|
492
|
+
lines.push(` - ${item}`);
|
|
493
|
+
}
|
|
494
|
+
lines.push("");
|
|
495
|
+
}
|
|
496
|
+
const providerWidth = Math.max(
|
|
497
|
+
8,
|
|
498
|
+
...report.queryResults.flatMap((queryResult) => queryResult.providerResults.map((result) => result.displayName.length))
|
|
499
|
+
);
|
|
500
|
+
for (const queryResult of report.queryResults) {
|
|
501
|
+
lines.push(`"${queryResult.query}"`);
|
|
502
|
+
for (const result of queryResult.providerResults) {
|
|
503
|
+
lines.push(` ${result.displayName.padEnd(providerWidth)} ${formatProviderLine(result)}`);
|
|
504
|
+
}
|
|
505
|
+
lines.push("");
|
|
506
|
+
}
|
|
507
|
+
if (report.summary.recommendedActions.length > 0) {
|
|
508
|
+
lines.push("Recommended actions:");
|
|
509
|
+
for (const action of report.summary.recommendedActions) {
|
|
510
|
+
lines.push(` - ${action}`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return lines.join("\n").trimEnd();
|
|
514
|
+
}
|
|
515
|
+
function formatProviderLine(result) {
|
|
516
|
+
if (result.error) {
|
|
517
|
+
return `ERROR: ${result.error}`;
|
|
518
|
+
}
|
|
519
|
+
const bits = [];
|
|
520
|
+
bits.push(result.mentioned ? "YES mentioned" : "NO mention");
|
|
521
|
+
if (result.cited) bits.push("cited");
|
|
522
|
+
if (result.describedAccurately !== "not-mentioned") {
|
|
523
|
+
bits.push(`accuracy=${result.describedAccurately}`);
|
|
524
|
+
}
|
|
525
|
+
if (result.recommendedCompetitors.length > 0) {
|
|
526
|
+
bits.push(`recommended instead: ${result.recommendedCompetitors.join(", ")}`);
|
|
527
|
+
}
|
|
528
|
+
if (result.incorrectClaims.length > 0) {
|
|
529
|
+
bits.push(`incorrect: ${result.incorrectClaims.join("; ")}`);
|
|
530
|
+
}
|
|
531
|
+
return bits.join(" | ");
|
|
532
|
+
}
|
|
533
|
+
export {
|
|
534
|
+
createSnapshotReport,
|
|
535
|
+
formatSnapshotMarkdown,
|
|
536
|
+
formatSnapshotText,
|
|
537
|
+
writeSnapshotMarkdown
|
|
538
|
+
};
|