seo-supervisor 1.2.0 → 2.0.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.
Files changed (207) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +16 -3
  4. package/CHANGELOG.md +430 -0
  5. package/NOTICE +7 -0
  6. package/README.md +230 -25
  7. package/agents/seo-auditor.md +16 -0
  8. package/agents/seo-reviewer.md +16 -0
  9. package/bin/agents.mjs +194 -29
  10. package/bin/extras.mjs +422 -0
  11. package/bin/prompt.mjs +34 -14
  12. package/bin/seo-supervisor.mjs +386 -53
  13. package/commands/seo-audit.md +29 -3
  14. package/commands/seo-brief.md +28 -0
  15. package/commands/seo-connect.md +27 -0
  16. package/commands/seo-fix.md +24 -3
  17. package/commands/seo-grow.md +26 -0
  18. package/commands/seo-launch.md +17 -3
  19. package/commands/seo-review.md +13 -1
  20. package/commands/seo-rewrite.md +25 -0
  21. package/commands/seo-setup.md +17 -1
  22. package/commands/seo-watch.md +28 -0
  23. package/hooks/hooks.json +117 -0
  24. package/package.json +20 -7
  25. package/skills/seo-supervisor/NOTICE +7 -0
  26. package/skills/seo-supervisor/SKILL.md +302 -21
  27. package/skills/seo-supervisor/audience.md +61 -0
  28. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  29. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  30. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  31. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  32. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  33. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  34. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  35. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  36. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  37. package/skills/seo-supervisor/examples/sample-audit.json +94 -2
  38. package/skills/seo-supervisor/examples/sample-report.html +111 -61
  39. package/skills/seo-supervisor/examples/sample-report.md +147 -44
  40. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  41. package/skills/seo-supervisor/examples/snippets.md +648 -1
  42. package/skills/seo-supervisor/grow.md +342 -0
  43. package/skills/seo-supervisor/og-images.md +85 -0
  44. package/skills/seo-supervisor/page-types.md +124 -0
  45. package/skills/seo-supervisor/planning.md +19 -7
  46. package/skills/seo-supervisor/profile-template.md +41 -0
  47. package/skills/seo-supervisor/report-format.md +177 -10
  48. package/skills/seo-supervisor/rewrite.md +59 -0
  49. package/skills/seo-supervisor/rules/ai-search.md +65 -12
  50. package/skills/seo-supervisor/rules/content.md +33 -9
  51. package/skills/seo-supervisor/rules/crawl-index.md +33 -6
  52. package/skills/seo-supervisor/rules/internal-linking.md +49 -6
  53. package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
  54. package/skills/seo-supervisor/rules/media.md +13 -1
  55. package/skills/seo-supervisor/rules/metadata.md +41 -9
  56. package/skills/seo-supervisor/rules/performance.md +50 -5
  57. package/skills/seo-supervisor/rules/rendering.md +39 -2
  58. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  59. package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
  60. package/skills/seo-supervisor/rules/structured-data.md +37 -14
  61. package/skills/seo-supervisor/rules/trust-security.md +25 -2
  62. package/skills/seo-supervisor/rules/urls.md +10 -2
  63. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  64. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  65. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  66. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  67. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  68. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  69. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  70. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  71. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  72. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  73. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  74. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  75. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  76. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  77. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  78. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  79. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  80. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  81. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  82. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  83. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  84. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  85. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  86. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  87. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  88. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  89. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  90. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  91. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  92. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  93. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  94. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  95. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  96. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  97. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  98. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  99. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  100. package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
  101. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  102. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  103. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  104. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  105. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  106. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  107. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  108. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  109. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  110. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  111. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  112. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  113. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  114. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  115. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  116. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  117. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  118. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  119. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  120. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  121. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  122. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  123. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  124. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  125. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  126. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  127. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  128. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  129. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  130. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  131. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  132. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  133. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  134. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  135. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  136. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  137. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  138. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  139. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  140. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  141. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  142. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  143. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  144. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  145. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  146. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  147. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  148. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  149. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  150. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  151. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  152. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  153. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  154. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  155. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  156. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  157. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  158. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  159. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  160. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  161. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  162. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  163. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  164. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  165. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  166. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  167. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  168. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  169. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  170. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  171. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  172. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  173. package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
  174. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  175. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  176. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  177. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  178. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  179. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  180. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  181. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  182. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  183. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  184. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  185. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  186. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  187. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  188. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  189. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  190. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  191. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  192. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  193. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  194. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  195. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  196. package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
  197. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  198. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
  199. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  200. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  201. package/skills/seo-supervisor/site-types/content.md +34 -1
  202. package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
  203. package/skills/seo-supervisor/site-types/local-business.md +96 -6
  204. package/skills/seo-supervisor/site-types/services.md +46 -0
  205. package/skills/seo-supervisor/site-types/tools.md +3 -3
  206. package/skills/seo-supervisor/strategy.md +232 -0
  207. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -0,0 +1,78 @@
1
+ // @ts-check
2
+ // Pixel size from the first bytes of a PNG, JPEG, GIF, WebP or ICO file: { type, width, height }, or null when the
3
+ // bytes aren't one of those formats or the header is cut off. Headers only, so the first 64 KB is plenty.
4
+ export function imageSize(b) {
5
+ const at = (s, i) => b.length >= i + s.length && b.toString("latin1", i, i + s.length) === s;
6
+ const size = (type, width, height) => (width > 0 && height > 0 ? { type, width, height } : null);
7
+ if (at("\x89PNG\r\n\x1a\n", 0) && at("IHDR", 12) && b.length >= 24)
8
+ return size("png", b.readUInt32BE(16), b.readUInt32BE(20));
9
+ if ((at("GIF87a", 0) || at("GIF89a", 0)) && b.length >= 10) return size("gif", b.readUInt16LE(6), b.readUInt16LE(8));
10
+ // ICO: a directory of 16-byte entries, width and height one byte each (0 is 256); the largest entry counts.
11
+ if (at("\0\0\x01\0", 0) && b.length >= 22 && b.length >= 6 + 16 * b.readUInt16LE(4)) {
12
+ const e = Array.from({ length: b.readUInt16LE(4) }, (_, i) => [b[6 + 16 * i] || 256, b[7 + 16 * i] || 256]).sort(
13
+ (x, y) => y[0] - x[0],
14
+ )[0];
15
+ return e ? size("ico", e[0], e[1]) : null;
16
+ }
17
+ if (at("RIFF", 0) && at("WEBP", 8)) {
18
+ if (at("VP8X", 12) && b.length >= 30) return size("webp", 1 + b.readUIntLE(24, 3), 1 + b.readUIntLE(27, 3));
19
+ if (at("VP8 ", 12) && b.length >= 30 && b[23] === 0x9d && b[24] === 0x01 && b[25] === 0x2a)
20
+ return size("webp", b.readUInt16LE(26) & 0x3fff, b.readUInt16LE(28) & 0x3fff);
21
+ if (at("VP8L", 12) && b.length >= 25 && b[20] === 0x2f) {
22
+ const v = b.readUInt32LE(21);
23
+ return size("webp", (v & 0x3fff) + 1, ((v >>> 14) & 0x3fff) + 1);
24
+ }
25
+ return null;
26
+ }
27
+ if (b[0] === 0xff && b[1] === 0xd8) {
28
+ // JPEG: walk the segments to the first start-of-frame marker (C0–CF, except DHT C4, JPG C8 and DAC CC).
29
+ for (let i = 2; i + 9 <= b.length;) {
30
+ if (b[i] !== 0xff) return null;
31
+ const m = b[i + 1];
32
+ if (m === 0xff) {
33
+ i++;
34
+ continue;
35
+ } // fill byte
36
+ if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc)
37
+ return size("jpeg", b.readUInt16BE(i + 7), b.readUInt16BE(i + 5));
38
+ if (m === 0x01 || (m >= 0xd0 && m <= 0xd8)) {
39
+ i += 2;
40
+ continue;
41
+ } // markers without a length
42
+ if (m === 0xd9 || m === 0xda) return null; // end of image or scan data before any frame header
43
+ i += 2 + b.readUInt16BE(i + 2);
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+
49
+ // Who made an image and how, from the first bytes of a JPEG, PNG or AVIF file: { creator, sourceType, ai, c2pa }.
50
+ // creator is XMP's dc:creator, else IIM's 2:80 By-line; sourceType is the term ending XMP's
51
+ // Iptc4xmpExt:DigitalSourceType URI (IPTC Photo Metadata Standard 2025.1). ai: one of the four terms Google reads as
52
+ // made by an algorithm. c2pa: a JUMBF box labelled "c2pa" in JPEG's APP11 segments or PNG's caBX chunk (C2PA 2.2,
53
+ // appendix A.3). WebP keeps XMP and C2PA at the end of the file, so they're rarely in the first bytes.
54
+ // https://developers.google.com/search/docs/appearance/structured-data/image-license-metadata
55
+ export const AI_SOURCES = [
56
+ "trainedAlgorithmicMedia",
57
+ "compositeWithTrainedAlgorithmicMedia",
58
+ "compositeSynthetic",
59
+ "algorithmicMedia",
60
+ ];
61
+ export function imageMeta(b) {
62
+ const s = b.toString("latin1"),
63
+ x0 = s.indexOf("<x:xmpmeta"),
64
+ x1 = s.indexOf("</x:xmpmeta>", x0);
65
+ const xmp = x0 >= 0 && x1 > x0 ? b.toString("utf8", x0, x1) : "";
66
+ const dst =
67
+ /:DigitalSourceType\s*=\s*"([^"]+)"|:DigitalSourceType\b[^>]*?rdf:resource\s*=\s*"([^"]+)"|:DigitalSourceType\s*>\s*([^<\s]+)\s*</.exec(
68
+ xmp,
69
+ );
70
+ const sourceType = dst ? (dst[1] || dst[2] || dst[3]).replace(/^.*\//, "") : null;
71
+ const i = s.indexOf("\x1c\x02\x50"),
72
+ byline =
73
+ i >= 0 && i + 5 <= b.length
74
+ ? b.toString("utf8", i + 5, Math.min(b.length, i + 5 + b.readUInt16BE(i + 3))).trim()
75
+ : "";
76
+ const creator = /<dc:creator\b[^>]*>[\s\S]*?<rdf:li\b[^>]*>([^<]+)</.exec(xmp)?.[1].trim() || byline || null;
77
+ return { creator, sourceType, ai: AI_SOURCES.includes(sourceType), c2pa: /jumd[\s\S]{17}c2pa/.test(s) };
78
+ }
@@ -0,0 +1,13 @@
1
+ // @ts-check
2
+ // True when the module at importMetaUrl is the script node was started with, also when it was started through a
3
+ // symlink or a Windows junction (node runs the real file, process.argv[1] keeps the typed path).
4
+ import { realpathSync } from "node:fs";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ export function isMain(importMetaUrl) {
8
+ try {
9
+ return !!process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(importMetaUrl));
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
@@ -0,0 +1,116 @@
1
+ // @ts-check
2
+ // The one private-address guard, and a request that keeps to it.
3
+ import { lookup } from "node:dns";
4
+ import { request as httpRequest } from "node:http";
5
+ import { request as httpsRequest } from "node:https";
6
+ import { BlockList, isIP } from "node:net";
7
+
8
+ // Private, local and reserved addresses: what seo-crawl.mjs's isPublic refuses, plus benchmarking, multicast, reserved
9
+ // and broadcast, NAT64 and IPv4 inside IPv6 (BlockList reads ::ffff:127.0.0.1 as 127.0.0.1). A non-IP counts too.
10
+ const PRIVATE = new BlockList();
11
+ for (const s of [
12
+ "0.0.0.0/8",
13
+ "10.0.0.0/8",
14
+ "100.64.0.0/10",
15
+ "127.0.0.0/8",
16
+ "169.254.0.0/16",
17
+ "172.16.0.0/12",
18
+ "192.168.0.0/16",
19
+ "198.18.0.0/15",
20
+ "224.0.0.0/3",
21
+ "::/96",
22
+ "fc00::/7",
23
+ "fe80::/10",
24
+ "ff00::/8",
25
+ "64:ff9b::/96",
26
+ "64:ff9b:1::/48",
27
+ ]) {
28
+ const [a, n] = s.split("/");
29
+ PRIVATE.addSubnet(a, +n, isIP(a) === 6 ? "ipv6" : "ipv4");
30
+ }
31
+ export const privateIp = a => !isIP(a) || PRIVATE.check(a, isIP(a) === 6 ? "ipv6" : "ipv4");
32
+ // The address: no private IP, no intranet or reserved name. The name's own answer is checked when connecting (guarded).
33
+ export const isPublic = u => {
34
+ try {
35
+ const { protocol, hostname: h } = new URL(u);
36
+ return (
37
+ /^https?:$/.test(protocol) &&
38
+ h.includes(".") &&
39
+ !(/^[\d.]+$/.test(h) && privateIp(h)) &&
40
+ !/\.(local|internal|lan|localhost|test|home\.arpa)$/i.test(h)
41
+ );
42
+ } catch {
43
+ return false;
44
+ }
45
+ };
46
+ // The lookup every request connects with, so the address checked is the one used: a name can't pass a check and then
47
+ // answer differently (DNS rebinding). A name that doesn't resolve fails the visit.
48
+ export const guarded = dns => (name, opts, cb) =>
49
+ dns(name, opts, (err, addr, family) => {
50
+ const bad = !err && (Array.isArray(addr) ? addr.map(a => a.address) : [addr]).find(privateIp);
51
+ bad
52
+ ? cb(
53
+ Object.assign(new Error(`${name} points at a private or local address (${bad}), so it wasn't visited`), {
54
+ code: "ENOTPUBLIC",
55
+ }),
56
+ )
57
+ : cb(err, addr, family);
58
+ });
59
+ // This machine, by name or address (0.0.0.0: what Django and Rails print).
60
+ export const loopback = h => /^(localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|\[::1\])$/i.test(h);
61
+
62
+ const open = (u, opts) =>
63
+ new Promise((ok, ko) => (u.startsWith("https:") ? httpsRequest : httpRequest)(u, opts, ok).on("error", ko).end());
64
+
65
+ /** One request that connects only where the guard allows: redirects are followed by hand, allow(url) is asked before
66
+ * each hop, and every connection goes through guarded(dns), so the address checked is the one used. read(res, url) gets
67
+ * the first answer that isn't a redirect and its result is returned (by default the status, the body unread); the
68
+ * timeout covers read too. { reason } in plain words when a hop isn't allowed, there are more than hops redirects,
69
+ * nothing answers in time or the connection fails.
70
+ * @param {string} url
71
+ * @param {{ method?: string, headers?: Record<string, string>, allow?: (u: string) => boolean | Promise<boolean>, dns?: any, timeout?: number, hops?: number, read?: (res: import("node:http").IncomingMessage, url: string) => any }} [o] */
72
+ export async function pinnedGet(
73
+ url,
74
+ {
75
+ method = "GET",
76
+ headers = {},
77
+ allow = isPublic,
78
+ dns = lookup,
79
+ timeout = 15000,
80
+ hops = 5,
81
+ read = r => (r.destroy(), { status: r.statusCode }),
82
+ } = {},
83
+ ) {
84
+ const signal = AbortSignal.timeout(timeout),
85
+ connect = guarded(dns);
86
+ let u = url;
87
+ try {
88
+ for (let hop = 0; hop <= hops; hop++) {
89
+ if (!(await allow(u)))
90
+ return {
91
+ reason: hop
92
+ ? `it redirects to ${u}, which isn't a public web address, so that wasn't visited`
93
+ : "it isn't a public web address, so it wasn't visited",
94
+ };
95
+ const r = /** @type {import("node:http").IncomingMessage} */ (
96
+ await open(u, { method, signal, lookup: connect, headers })
97
+ );
98
+ const to = r.statusCode >= 300 && r.statusCode < 400 && r.headers.location;
99
+ if (to) {
100
+ r.destroy();
101
+ u = new URL(to, u).href;
102
+ continue;
103
+ }
104
+ return await read(r, u);
105
+ }
106
+ return { reason: `it redirects more than ${hops} times` };
107
+ } catch (e) {
108
+ return {
109
+ reason: signal.aborted
110
+ ? `no answer within ${timeout / 1000} seconds`
111
+ : e.code === "ENOTPUBLIC"
112
+ ? e.message
113
+ : `couldn't connect (${e.code || e.cause?.code || e.message})`,
114
+ };
115
+ }
116
+ }
@@ -0,0 +1,47 @@
1
+ // @ts-check
2
+ // Company proxies. Node honours HTTP_PROXY / HTTPS_PROXY (minus NO_PROXY; lowercase names win) only with
3
+ // NODE_USE_ENV_PROXY=1: fetch() from Node 22.21 and 24.0, http(s).request() and --use-env-proxy from 22.21 and 24.5.
4
+ // Chrome over CDP gets the same proxy as flags.
5
+ // https://nodejs.org/api/cli.html#node_use_env_proxy1
6
+
7
+ const pick = (env, name) => env[name.toLowerCase()] || env[name];
8
+ const since = (version, v24) => {
9
+ const [a, b] = version.split(".").map(Number);
10
+ return a > 24 || (a === 24 && b >= v24) || (a === 22 && b >= 21);
11
+ };
12
+
13
+ // One plain line when a proxy is set but this Node won't use it for fetch(), else null.
14
+ export function proxyNote(env = process.env, { execArgv = process.execArgv, version = process.versions.node } = {}) {
15
+ if (!pick(env, "HTTPS_PROXY") && !pick(env, "HTTP_PROXY")) return null;
16
+ const on =
17
+ env.NODE_USE_ENV_PROXY === "1" ||
18
+ [...execArgv, ...(env.NODE_OPTIONS || "").split(/\s+/)].includes("--use-env-proxy");
19
+ if (!since(version, 0))
20
+ return `A proxy is set (HTTPS_PROXY or HTTP_PROXY), but Node ${version} can't send requests through it, so requests to other sites may fail. Node 22.21 or 24.0 and later can, when NODE_USE_ENV_PROXY=1 is set.`;
21
+ return on
22
+ ? null
23
+ : `A proxy is set (HTTPS_PROXY or HTTP_PROXY), but Node uses it only when started with NODE_USE_ENV_PROXY=1${since(version, 5) ? " (or --use-env-proxy)" : ""}, so requests to other sites may fail. Set it and run this again.`;
24
+ }
25
+
26
+ // Chrome's --proxy-server (scheme=proxy pairs when http and https differ) and --proxy-bypass-list from NO_PROXY; Chrome
27
+ // bypasses localhost itself. Credentials are dropped, since other users can read a command line. A value without a
28
+ // scheme (curl's user:pass@host:port) is read as http://; one with no host gets no argument, never the raw value.
29
+ // https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md
30
+ const server = u => {
31
+ try {
32
+ const x = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(u) ? u : "http://" + u);
33
+ if (x.host) return `${x.protocol}//${x.host}`;
34
+ } catch {}
35
+ return null;
36
+ };
37
+ export function chromeProxyArgs(env = process.env) {
38
+ const bypass = (pick(env, "NO_PROXY") || "").replace(/\s+/g, "");
39
+ const http = pick(env, "HTTP_PROXY") && server(pick(env, "HTTP_PROXY")),
40
+ https = pick(env, "HTTPS_PROXY") && server(pick(env, "HTTPS_PROXY"));
41
+ if ((!http && !https) || bypass === "*") return [];
42
+ const to = http === https ? http : [http && `http=${http}`, https && `https=${https}`].filter(Boolean).join(";");
43
+ return [
44
+ `--proxy-server=${to}`,
45
+ ...(bypass ? [`--proxy-bypass-list=${bypass.split(",").filter(Boolean).join(";")}`] : []),
46
+ ];
47
+ }
@@ -0,0 +1,106 @@
1
+ // @ts-check
2
+ // A command the user can paste into a terminal to confirm a fix, for checks a one-liner can prove; no script runs it.
3
+ // The finding's first evidence URL may come from a crawled page, so it goes in only when plain: http(s), printable
4
+ // ASCII, and none of ' " ` $ \ (which could end the quotes or start code in sh, bash, zsh or PowerShell) or { } [ ]
5
+ // (curl's URL globbing). Single quotes then keep every shell from reading any of it; anything else gets no command.
6
+ // Windows PowerShell aliases "curl" to Invoke-WebRequest, so Windows gets curl.exe, which ships with Windows 10 and 11.
7
+ // The grep commands need a POSIX shell.
8
+ // https://curl.se/windows/microsoft.html
9
+ const KINDS = /** @type {[(u: string) => string, string, string[]][]} */ ([
10
+ [
11
+ u => `curl -sI '${u}'`,
12
+ "It prints the status and the response headers. After the fix, the header or status this finding names is right.",
13
+ [
14
+ "no-hsts",
15
+ "hsts-short",
16
+ "hsts-invalid",
17
+ "hsts-no-subdomains",
18
+ "sec-headers",
19
+ "csp-weak",
20
+ "referrer-unsafe",
21
+ "cookie-flags",
22
+ "soft-404",
23
+ "soft-404-noindex",
24
+ "soft-404-page",
25
+ "sitemap-unreachable",
26
+ "sitemap-empty",
27
+ "server-error",
28
+ ],
29
+ ],
30
+ [
31
+ u => `curl -sIL '${u}'`,
32
+ "It prints each redirect in turn. After the fix, one permanent redirect (301 or 308) goes straight to the final address, which answers 200.",
33
+ [
34
+ "redirect-chain",
35
+ "slash-redirect-temporary",
36
+ "old-url-temporary",
37
+ "http-not-redirected",
38
+ "http-redirect-hops",
39
+ "host-not-redirected",
40
+ "host-redirect-hops",
41
+ "host-redirect-drops-path",
42
+ "redirect-temporary",
43
+ ],
44
+ ],
45
+ [
46
+ u => `curl -si '${new URL(u).origin}/robots.txt'`,
47
+ "It prints robots.txt with its status. After the fix, it answers 200 and its rules say what you meant.",
48
+ [
49
+ "robots-blocks-all",
50
+ "robots-server-error",
51
+ "robots-missing",
52
+ "robots-blocks-assets",
53
+ "sitemap-not-in-robots",
54
+ "content-signal-invalid",
55
+ "content-signal-placement",
56
+ "ai-robots-conflict",
57
+ ],
58
+ ],
59
+ [
60
+ u => `curl -s -D - '${u}' | grep -ioE -e '^link:.*canonical.*' -e '<link[^>]*canonical[^>]*>'`,
61
+ "It prints the page's canonical. After the fix, there's exactly one, naming the URL you want in search.",
62
+ [
63
+ "canonical-missing",
64
+ "canonical-multiple",
65
+ "canonical-not-self",
66
+ "canonical-query",
67
+ "canonical-origin",
68
+ "canonical-missing-sitewide",
69
+ ],
70
+ ],
71
+ [
72
+ u => `curl -s -D - '${u}' | grep -ioE -e '^x-robots-tag:.*' -e '<meta[^>]*(robots|googlebot)[^>]*>'`,
73
+ "It prints the robots meta tags and any X-Robots-Tag header. After the fix, none of them carries the rule this finding names.",
74
+ [
75
+ "home-noindex",
76
+ "noindex-in-sitemap",
77
+ "noindex-review",
78
+ "robots-conflict",
79
+ "page-nofollow",
80
+ "nosnippet",
81
+ "ai-legacy-noarchive",
82
+ ],
83
+ ],
84
+ ]);
85
+ const BY_CHECK = new Map(KINDS.flatMap(([cmd, hint, ids]) => ids.map(id => [id, { cmd, hint }])));
86
+
87
+ export const safeUrl = u => {
88
+ try {
89
+ return typeof u === "string" &&
90
+ /^https?:\/\/[\x21-\x7e]+$/i.test(u) &&
91
+ !/['"`$\\{}[\]]/.test(u) &&
92
+ /^https?:$/.test(new URL(u).protocol)
93
+ ? u
94
+ : null;
95
+ } catch {
96
+ return null;
97
+ }
98
+ };
99
+ // The finding's command and what to look for, or null.
100
+ export function recheckOf(f) {
101
+ const k = BY_CHECK.get(f?.check),
102
+ url = k && safeUrl((Array.isArray(f.evidence) ? f.evidence : []).find(e => e?.url)?.url);
103
+ return url ? { command: k.cmd(url), hint: k.hint } : null;
104
+ }
105
+ export const RECHECK_NOTE =
106
+ "Some findings show a command to check the fix yourself, once it's live. They're for a terminal: macOS, Linux, Git Bash or WSL. Windows 10 and 11 have curl built in: in PowerShell, type curl.exe instead of curl (plain curl there is a different command), and run the ones with grep in Git Bash or WSL. Nothing runs them for you.";
@@ -0,0 +1,78 @@
1
+ // @ts-check
2
+ // Masks what a saved or shared report must not carry: secret query values in URLs, well-known token
3
+ // formats, home-folder paths and, in error text, email addresses.
4
+ import { homedir } from "node:os";
5
+
6
+ // Query parameters whose value is a secret: a token, key, password, signature or credential (X-Amz-Signature,
7
+ // X-Goog-Credential) as a whole word of the name, so "keyword" or "monkey" aren't. Session IDs stay: the sitemap check
8
+ // shows them as evidence. "key" and "pass" alone are often filters (?key=blue), so they need a prefix (api_key,
9
+ // access-key); a bare auth= is a token (Firebase's REST API). After a # too: OAuth's implicit flow puts
10
+ // #access_token= there.
11
+ const SECRET_PARAM =
12
+ /([?&;#](?:(?:[\w.-]*[-_.])?(?:token|apikey|secret|password|passwd|pwd|signature|sig|credential|auth)|[\w.-]*[-_.](?:key|pass))=)[^&#\s"'<>;,]*/gi;
13
+ // Tokens recognisable on their own: bearer tokens and Basic logins, Google API keys (AIza…), OAuth access and refresh
14
+ // tokens (ya29., 1//) and client secrets (GOCSPX-), JWTs, GitHub token prefixes, Slack tokens and webhook URLs, Stripe
15
+ // secret and restricted keys, AWS access key IDs (AKIA, temporary ASIA), PostHog personal keys and Perplexity keys.
16
+ // OpenAI documents no key format, so the sk- pattern is a heuristic: sk- and 20+ letters and digits with no hyphen
17
+ // after, or sk-proj-, sk-admin- or Anthropic's sk-ant-api03- and 20+ key characters, never right after / or a word
18
+ // (/blog/sk-guide-internationalization1 isn't one). The minimum lengths match checks/hygiene.mjs, so the short form it
19
+ // shows on purpose (sk_live_51Hq…) stays readable.
20
+ // https://docs.slack.dev/authentication/tokens
21
+ // https://docs.stripe.com/keys
22
+ // https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html
23
+ // https://posthog.com/docs/api
24
+ // https://docs.perplexity.ai/guides/api-key-management
25
+ const TOKENS = [
26
+ /\b(Bearer\s+)[\w.~+/-]+=*/gi,
27
+ /\b(Authorization:\s*Basic\s+)[A-Za-z0-9+/]+=*/gi,
28
+ /\bAIza[\w-]{35}\b/g,
29
+ /\bya29\.[\w.-]+/g,
30
+ /(?<![\w/])1\/\/[\w-]{20,}/g,
31
+ /\bGOCSPX-[\w-]+/g,
32
+ /\beyJ[\w-]+\.eyJ[\w-]+\.[\w-]+/g,
33
+ /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_\w{40,})/g,
34
+ /\b(?:xox[abeprs]|xapp|xwfp)-[A-Za-z0-9-]{20,}/g,
35
+ /(hooks\.slack\.com\/)[\w/-]+/g,
36
+ /\b[sr]k_(?:live|test)_[A-Za-z0-9]{20,}/g,
37
+ /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
38
+ /\bphx_\w{16,}/g,
39
+ /\bpplx-[A-Za-z0-9]{16,}/g,
40
+ /(?<![\w/-])sk-(?:(?:proj|admin|ant-api03)-[\w-]{20,}|[A-Za-z0-9]{20,}(?![\w-]))/g,
41
+ ];
42
+ // A login in a web address (https://user:password@host): the user name and password go.
43
+ const USERINFO = /\b([a-z][a-z0-9+.-]*:\/\/)[^\s/?#@"'<>]+@/gi;
44
+ // A home folder's name ends at the next \ or /. One with spaces (C:\Users\Jane Doe\…, also written C:/Users/…)
45
+ // counts only up to 4 words, and only when a separator, a quote or the end of the text follows.
46
+ // Under /home/ the name is one word, so "/home/bob says hi" keeps "says hi".
47
+ const HOMES =
48
+ /(?:\b[A-Za-z]:\\Users\\|\/Users\/)(?:[^\\/\s"':]+(?: [^\\/\s"':]+){1,3}(?=[\\/"'`]|$)|[^\\/\s"':]+)|\/home\/[^\\/\s"':]+/g;
49
+ // An address standing on its own, not a path segment such as logo@2x.png.
50
+ const EMAIL = /(?<![^\s<("':=,;[])[\w.+-]+@[\w-]+(?:\.[\w-]+)*\.[a-z]{2,}\b/gi;
51
+
52
+ /** Secret query values and token formats replaced with [hidden]; the rest of the text as it was. */
53
+ export const hideSecrets = s =>
54
+ TOKENS.reduce(
55
+ (t, re) => t.replace(re, (m, keep) => (typeof keep === "string" ? keep : "") + "[hidden]"),
56
+ String(s).replace(SECRET_PARAM, "$1[hidden]").replace(USERINFO, "$1[hidden]@"),
57
+ );
58
+
59
+ // Web addresses: a site's own /home/ or /Users/ path is a page, not a home folder, so folder masking skips them.
60
+ const URL_RE = /https?:\/\/[^\s"'<>]+/gi;
61
+
62
+ /** hideSecrets, plus home folders as ~ outside web addresses and, unless emails: false, email addresses as [email]. */
63
+ export function redact(s, { home = homedir(), emails = true } = {}) {
64
+ const t = hideSecrets(s);
65
+ const folders = part => {
66
+ let x = part;
67
+ if (home && home.length > 3) for (const h of new Set([home, home.replace(/\\/g, "/")])) x = x.split(h).join("~");
68
+ x = x.replace(HOMES, "~");
69
+ return emails ? x.replace(EMAIL, "[email]") : x;
70
+ };
71
+ let out = "",
72
+ at = 0;
73
+ for (const m of t.matchAll(URL_RE)) {
74
+ out += folders(t.slice(at, m.index)) + m[0];
75
+ at = m.index + m[0].length;
76
+ }
77
+ return out + folders(t.slice(at));
78
+ }
@@ -0,0 +1,73 @@
1
+ // @ts-check
2
+ // robots.txt parsing and matching, shared by every script that reads one.
3
+
4
+ // A user-agent counts by its name up to the first character other than a letter, "_" or "-", so "GPTBot/1.1" is
5
+ // GPTBot, as in Google's open-source parser and RFC 9309. agents: those names, lowercased; names: the lines as written;
6
+ // versioned: the lines that carried more, for a note. Content-Signal and aipref Content-Usage lines (rules inside a
7
+ // group, draft-ietf-aipref-attach-05) go on their group's signals and usage, or on loose before the first User-agent
8
+ // line; line is 1-based.
9
+ // https://github.com/google/robotstxt
10
+ // https://www.rfc-editor.org/rfc/rfc9309#section-2.2.1
11
+ /** @param {string} txt */
12
+ export function parseRobots(txt) {
13
+ /** @type {{ agents: string[], names: string[], rules: { allow: boolean, path: string }[], signals: { line: number, k: string, v: string }[], usage: { line: number, k: string, v: string }[] }[]} */
14
+ const groups = [];
15
+ const sitemaps = [],
16
+ versioned = [],
17
+ loose = [];
18
+ let cur = null;
19
+ String(txt || "")
20
+ .split(/\r?\n/)
21
+ .forEach((raw, i) => {
22
+ const line = raw.replace(/#.*/, "").trim(),
23
+ c = line.indexOf(":");
24
+ if (c < 0) return;
25
+ const k = line.slice(0, c).trim().toLowerCase(),
26
+ v = line.slice(c + 1).trim();
27
+ if (k === "sitemap") {
28
+ if (v) sitemaps.push(v);
29
+ } else if (k === "user-agent") {
30
+ if (!cur || cur.rules.length) groups.push((cur = { agents: [], names: [], rules: [], signals: [], usage: [] }));
31
+ const name = v.startsWith("*") ? "*" : /^[A-Za-z_-]+/.exec(v)?.[0] || v;
32
+ if (name !== v && name !== "*") versioned.push(v);
33
+ cur.agents.push(name.toLowerCase());
34
+ cur.names.push(v);
35
+ } else if (k === "content-signal" || k === "content-usage")
36
+ (cur ? cur[k === "content-signal" ? "signals" : "usage"] : loose).push({ line: i + 1, k, v });
37
+ else if ((k === "allow" || k === "disallow") && cur) cur.rules.push({ allow: k === "allow", path: v });
38
+ });
39
+ return { groups, sitemaps, versioned, loose };
40
+ }
41
+ // "*" matches anything, a "$" at the end anchors the path, and a "$" anywhere else is a plain character.
42
+ export const ruleRe = p =>
43
+ new RegExp(
44
+ "^" +
45
+ p
46
+ .replace(/[.+?^${}()|[\]\\]/g, "\\$&")
47
+ .replace(/\*/g, ".*")
48
+ .replace(/\\\$$/, "$"),
49
+ );
50
+ // The longest rule matching the path wins, an allow on a tie; rules with no path are ignored. No group: allowed.
51
+ export function allowedBy(group, path) {
52
+ if (!group) return true;
53
+ let best = null;
54
+ for (const r of group.rules) {
55
+ if (!r.path) continue;
56
+ if (
57
+ ruleRe(r.path).test(path) &&
58
+ (!best || r.path.length > best.path.length || (r.path.length === best.path.length && r.allow))
59
+ )
60
+ best = r;
61
+ }
62
+ return !best || best.allow;
63
+ }
64
+ // Every group naming the crawler, combined into one, as RFC 9309 2.2.1 requires, or null.
65
+ export const groupFor = (robots, agent) => {
66
+ const a = agent.toLowerCase(),
67
+ gs = robots.groups.filter(g => g.agents.includes(a));
68
+ return gs.length ? { agents: [a], rules: gs.flatMap(g => g.rules) } : null;
69
+ };
70
+ // The one group a crawler obeys: its own groups combined, else the `User-agent: *` groups. Google never merges
71
+ // agent-specific and global groups.
72
+ // https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt#order-of-precedence-for-user-agents
73
+ export const groupOf = (robots, agent) => groupFor(robots, agent) || groupFor(robots, "*");