@se-studio/site-check 0.0.0-next16-20260822103555

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 (199) hide show
  1. package/CHANGELOG.md +948 -0
  2. package/README.md +220 -0
  3. package/check-no-context-workarounds.mjs +235 -0
  4. package/develop-sites-timing.mjs +609 -0
  5. package/dist/check-pages-exist.d.ts +19 -0
  6. package/dist/check-pages-exist.d.ts.map +1 -0
  7. package/dist/check-pages-exist.js +25 -0
  8. package/dist/check-pages-exist.js.map +1 -0
  9. package/dist/check-rewrites.d.ts +21 -0
  10. package/dist/check-rewrites.d.ts.map +1 -0
  11. package/dist/check-rewrites.js +69 -0
  12. package/dist/check-rewrites.js.map +1 -0
  13. package/dist/cli.d.ts +4 -0
  14. package/dist/cli.d.ts.map +1 -0
  15. package/dist/cli.js +231 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/cms-integrity/article-link-integrity.d.ts +4 -0
  18. package/dist/cms-integrity/article-link-integrity.d.ts.map +1 -0
  19. package/dist/cms-integrity/article-link-integrity.js +8 -0
  20. package/dist/cms-integrity/article-link-integrity.js.map +1 -0
  21. package/dist/cms-integrity/evaluate-article-link-integrity.d.ts +11 -0
  22. package/dist/cms-integrity/evaluate-article-link-integrity.d.ts.map +1 -0
  23. package/dist/cms-integrity/evaluate-article-link-integrity.js +49 -0
  24. package/dist/cms-integrity/evaluate-article-link-integrity.js.map +1 -0
  25. package/dist/cms-integrity/fetch-article-links.d.ts +8 -0
  26. package/dist/cms-integrity/fetch-article-links.d.ts.map +1 -0
  27. package/dist/cms-integrity/fetch-article-links.js +27 -0
  28. package/dist/cms-integrity/fetch-article-links.js.map +1 -0
  29. package/dist/cms-integrity/index.d.ts +7 -0
  30. package/dist/cms-integrity/index.d.ts.map +1 -0
  31. package/dist/cms-integrity/index.js +6 -0
  32. package/dist/cms-integrity/index.js.map +1 -0
  33. package/dist/cms-integrity/report.d.ts +4 -0
  34. package/dist/cms-integrity/report.d.ts.map +1 -0
  35. package/dist/cms-integrity/report.js +42 -0
  36. package/dist/cms-integrity/report.js.map +1 -0
  37. package/dist/cms-integrity/routing-config.d.ts +3 -0
  38. package/dist/cms-integrity/routing-config.d.ts.map +1 -0
  39. package/dist/cms-integrity/routing-config.js +5 -0
  40. package/dist/cms-integrity/routing-config.js.map +1 -0
  41. package/dist/cms-integrity/types.d.ts +32 -0
  42. package/dist/cms-integrity/types.d.ts.map +1 -0
  43. package/dist/cms-integrity/types.js +2 -0
  44. package/dist/cms-integrity/types.js.map +1 -0
  45. package/dist/collect-markdown-urls.d.ts +29 -0
  46. package/dist/collect-markdown-urls.d.ts.map +1 -0
  47. package/dist/collect-markdown-urls.js +144 -0
  48. package/dist/collect-markdown-urls.js.map +1 -0
  49. package/dist/discovery/endpoints.d.ts +4 -0
  50. package/dist/discovery/endpoints.d.ts.map +1 -0
  51. package/dist/discovery/endpoints.js +34 -0
  52. package/dist/discovery/endpoints.js.map +1 -0
  53. package/dist/discovery/index.d.ts +6 -0
  54. package/dist/discovery/index.d.ts.map +1 -0
  55. package/dist/discovery/index.js +5 -0
  56. package/dist/discovery/index.js.map +1 -0
  57. package/dist/discovery/resolve-config.d.ts +5 -0
  58. package/dist/discovery/resolve-config.d.ts.map +1 -0
  59. package/dist/discovery/resolve-config.js +21 -0
  60. package/dist/discovery/resolve-config.js.map +1 -0
  61. package/dist/discovery/types.d.ts +60 -0
  62. package/dist/discovery/types.d.ts.map +1 -0
  63. package/dist/discovery/types.js +2 -0
  64. package/dist/discovery/types.js.map +1 -0
  65. package/dist/discovery/validate-content.d.ts +30 -0
  66. package/dist/discovery/validate-content.d.ts.map +1 -0
  67. package/dist/discovery/validate-content.js +244 -0
  68. package/dist/discovery/validate-content.js.map +1 -0
  69. package/dist/discovery/validate-endpoints.d.ts +4 -0
  70. package/dist/discovery/validate-endpoints.d.ts.map +1 -0
  71. package/dist/discovery/validate-endpoints.js +143 -0
  72. package/dist/discovery/validate-endpoints.js.map +1 -0
  73. package/dist/download.d.ts +19 -0
  74. package/dist/download.d.ts.map +1 -0
  75. package/dist/download.js +48 -0
  76. package/dist/download.js.map +1 -0
  77. package/dist/fetch-options.d.ts +19 -0
  78. package/dist/fetch-options.d.ts.map +1 -0
  79. package/dist/fetch-options.js +48 -0
  80. package/dist/fetch-options.js.map +1 -0
  81. package/dist/production-audit/index.d.ts +96 -0
  82. package/dist/production-audit/index.d.ts.map +1 -0
  83. package/dist/production-audit/index.js +855 -0
  84. package/dist/production-audit/index.js.map +1 -0
  85. package/dist/screaming-frog/audit.d.ts +9 -0
  86. package/dist/screaming-frog/audit.d.ts.map +1 -0
  87. package/dist/screaming-frog/audit.js +254 -0
  88. package/dist/screaming-frog/audit.js.map +1 -0
  89. package/dist/screaming-frog/compare-report.d.ts +22 -0
  90. package/dist/screaming-frog/compare-report.d.ts.map +1 -0
  91. package/dist/screaming-frog/compare-report.js +142 -0
  92. package/dist/screaming-frog/compare-report.js.map +1 -0
  93. package/dist/screaming-frog/compare.d.ts +5 -0
  94. package/dist/screaming-frog/compare.d.ts.map +1 -0
  95. package/dist/screaming-frog/compare.js +42 -0
  96. package/dist/screaming-frog/compare.js.map +1 -0
  97. package/dist/screaming-frog/crawl-state.d.ts +19 -0
  98. package/dist/screaming-frog/crawl-state.d.ts.map +1 -0
  99. package/dist/screaming-frog/crawl-state.js +30 -0
  100. package/dist/screaming-frog/crawl-state.js.map +1 -0
  101. package/dist/screaming-frog/crawl.d.ts +12 -0
  102. package/dist/screaming-frog/crawl.d.ts.map +1 -0
  103. package/dist/screaming-frog/crawl.js +93 -0
  104. package/dist/screaming-frog/crawl.js.map +1 -0
  105. package/dist/screaming-frog/csv.d.ts +6 -0
  106. package/dist/screaming-frog/csv.d.ts.map +1 -0
  107. package/dist/screaming-frog/csv.js +71 -0
  108. package/dist/screaming-frog/csv.js.map +1 -0
  109. package/dist/screaming-frog/env.d.ts +4 -0
  110. package/dist/screaming-frog/env.d.ts.map +1 -0
  111. package/dist/screaming-frog/env.js +53 -0
  112. package/dist/screaming-frog/env.js.map +1 -0
  113. package/dist/screaming-frog/index.d.ts +15 -0
  114. package/dist/screaming-frog/index.d.ts.map +1 -0
  115. package/dist/screaming-frog/index.js +15 -0
  116. package/dist/screaming-frog/index.js.map +1 -0
  117. package/dist/screaming-frog/list-crawls.d.ts +22 -0
  118. package/dist/screaming-frog/list-crawls.d.ts.map +1 -0
  119. package/dist/screaming-frog/list-crawls.js +107 -0
  120. package/dist/screaming-frog/list-crawls.js.map +1 -0
  121. package/dist/screaming-frog/load-config.d.ts +9 -0
  122. package/dist/screaming-frog/load-config.d.ts.map +1 -0
  123. package/dist/screaming-frog/load-config.js +86 -0
  124. package/dist/screaming-frog/load-config.js.map +1 -0
  125. package/dist/screaming-frog/load-profile.d.ts +9 -0
  126. package/dist/screaming-frog/load-profile.d.ts.map +1 -0
  127. package/dist/screaming-frog/load-profile.js +32 -0
  128. package/dist/screaming-frog/load-profile.js.map +1 -0
  129. package/dist/screaming-frog/paths.d.ts +5 -0
  130. package/dist/screaming-frog/paths.d.ts.map +1 -0
  131. package/dist/screaming-frog/paths.js +34 -0
  132. package/dist/screaming-frog/paths.js.map +1 -0
  133. package/dist/screaming-frog/rules.d.ts +14 -0
  134. package/dist/screaming-frog/rules.d.ts.map +1 -0
  135. package/dist/screaming-frog/rules.js +211 -0
  136. package/dist/screaming-frog/rules.js.map +1 -0
  137. package/dist/screaming-frog/sf-runner.d.ts +12 -0
  138. package/dist/screaming-frog/sf-runner.d.ts.map +1 -0
  139. package/dist/screaming-frog/sf-runner.js +37 -0
  140. package/dist/screaming-frog/sf-runner.js.map +1 -0
  141. package/dist/screaming-frog/types.d.ts +136 -0
  142. package/dist/screaming-frog/types.d.ts.map +1 -0
  143. package/dist/screaming-frog/types.js +2 -0
  144. package/dist/screaming-frog/types.js.map +1 -0
  145. package/dist/screaming-frog-cli.d.ts +4 -0
  146. package/dist/screaming-frog-cli.d.ts.map +1 -0
  147. package/dist/screaming-frog-cli.js +326 -0
  148. package/dist/screaming-frog-cli.js.map +1 -0
  149. package/dist/smoke-test/analytics-context-bundle.d.ts +30 -0
  150. package/dist/smoke-test/analytics-context-bundle.d.ts.map +1 -0
  151. package/dist/smoke-test/analytics-context-bundle.js +148 -0
  152. package/dist/smoke-test/analytics-context-bundle.js.map +1 -0
  153. package/dist/smoke-test/build-route-policy.d.ts +39 -0
  154. package/dist/smoke-test/build-route-policy.d.ts.map +1 -0
  155. package/dist/smoke-test/build-route-policy.js +121 -0
  156. package/dist/smoke-test/build-route-policy.js.map +1 -0
  157. package/dist/smoke-test/cache-log-audit.d.ts +22 -0
  158. package/dist/smoke-test/cache-log-audit.d.ts.map +1 -0
  159. package/dist/smoke-test/cache-log-audit.js +85 -0
  160. package/dist/smoke-test/cache-log-audit.js.map +1 -0
  161. package/dist/smoke-test/config.d.ts +7 -0
  162. package/dist/smoke-test/config.d.ts.map +1 -0
  163. package/dist/smoke-test/config.js +61 -0
  164. package/dist/smoke-test/config.js.map +1 -0
  165. package/dist/smoke-test/index.d.ts +15 -0
  166. package/dist/smoke-test/index.d.ts.map +1 -0
  167. package/dist/smoke-test/index.js +9 -0
  168. package/dist/smoke-test/index.js.map +1 -0
  169. package/dist/smoke-test/runner.d.ts +9 -0
  170. package/dist/smoke-test/runner.d.ts.map +1 -0
  171. package/dist/smoke-test/runner.js +340 -0
  172. package/dist/smoke-test/runner.js.map +1 -0
  173. package/dist/smoke-test/static.d.ts +23 -0
  174. package/dist/smoke-test/static.d.ts.map +1 -0
  175. package/dist/smoke-test/static.js +126 -0
  176. package/dist/smoke-test/static.js.map +1 -0
  177. package/dist/smoke-test/types.d.ts +89 -0
  178. package/dist/smoke-test/types.d.ts.map +1 -0
  179. package/dist/smoke-test/types.js +2 -0
  180. package/dist/smoke-test/types.js.map +1 -0
  181. package/dist/validate.d.ts +48 -0
  182. package/dist/validate.d.ts.map +1 -0
  183. package/dist/validate.js +140 -0
  184. package/dist/validate.js.map +1 -0
  185. package/dist/vercel-env.d.ts +13 -0
  186. package/dist/vercel-env.d.ts.map +1 -0
  187. package/dist/vercel-env.js +93 -0
  188. package/dist/vercel-env.js.map +1 -0
  189. package/docs/llms.md +137 -0
  190. package/fixtures/revalidation/entry-publish.json +10 -0
  191. package/markdown-accuracy-audit.mjs +432 -0
  192. package/package.json +102 -0
  193. package/revalidation-matrix-test.mjs +467 -0
  194. package/smoke-test-deploy-check.mjs +70 -0
  195. package/smoke-test-live.mjs +63 -0
  196. package/smoke-test-one.mjs +442 -0
  197. package/templates/biome-ssg-guardrails.override.json +27 -0
  198. package/templates/route-build-policy.example.json +18 -0
  199. package/validate-build-routes.mjs +74 -0
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Collect markdown URLs from sitemap.xml and sitemap-unindexed.xml (Option B).
3
+ * Every <loc> in both sitemaps is converted to a .md URL; we then check each returns 200.
4
+ * Download paths and static assets (e.g. PDFs) are excluded — they have no markdown version.
5
+ */
6
+ import type { ValidationResult } from './validate.js';
7
+ /**
8
+ * True if this sitemap URL should not be requested as markdown (download path or static file).
9
+ */
10
+ export declare function isNonPageAssetUrl(url: string): boolean;
11
+ /**
12
+ * Collect all page URLs from sitemap.xml and sitemap-unindexed.xml (raw <loc> values).
13
+ * Uses resolved page URL lists when present (e.g. after following sitemap index links).
14
+ * Used for rewrite checks so every sitemap URL is verified to not rewrite to a different path.
15
+ */
16
+ export declare function pageUrlsFromSitemaps(validationResult: ValidationResult): string[];
17
+ /**
18
+ * Collect all markdown URLs from sitemap.xml and sitemap-unindexed.xml (Option B).
19
+ * Uses resolved page URL lists when present (e.g. after following sitemap index links).
20
+ * Ensures every sitemap page has a corresponding markdown URL to validate.
21
+ */
22
+ export declare function collectMarkdownUrlsFromSitemaps(baseUrl: string, validationResult: ValidationResult): string[];
23
+ /**
24
+ * Map production page URLs to development page URLs (same path, dev origin).
25
+ * Excludes non-page assets (download paths, static file extensions).
26
+ * Used in compare mode: sitemap from prod, check existence on dev.
27
+ */
28
+ export declare function mapProdPageUrlsToDev(prodPageUrls: string[], devBaseUrl: string): string[];
29
+ //# sourceMappingURL=collect-markdown-urls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-markdown-urls.d.ts","sourceRoot":"","sources":["../src/collect-markdown-urls.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAsBtD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWtD;AAWD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAajF;AAiCD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,EAAE,CAGV;AAiBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAQzF"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Collect markdown URLs from sitemap.xml and sitemap-unindexed.xml (Option B).
3
+ * Every <loc> in both sitemaps is converted to a .md URL; we then check each returns 200.
4
+ * Download paths and static assets (e.g. PDFs) are excluded — they have no markdown version.
5
+ */
6
+ /** Path segment extensions for static assets; these URLs are excluded from markdown checks. */
7
+ const STATIC_EXTENSIONS = new Set([
8
+ '.pdf',
9
+ '.zip',
10
+ '.doc',
11
+ '.docx',
12
+ '.xls',
13
+ '.xlsx',
14
+ '.ppt',
15
+ '.pptx',
16
+ '.csv',
17
+ '.txt',
18
+ '.rtf',
19
+ '.odt',
20
+ '.ods',
21
+ '.odp',
22
+ '.epub',
23
+ '.mobi',
24
+ ]);
25
+ /**
26
+ * True if this sitemap URL should not be requested as markdown (download path or static file).
27
+ */
28
+ export function isNonPageAssetUrl(url) {
29
+ try {
30
+ const u = new URL(url);
31
+ const path = u.pathname.replace(/\/$/, '') || '/';
32
+ if (path.startsWith('/download/'))
33
+ return true;
34
+ const lastDot = path.lastIndexOf('.');
35
+ if (lastDot === -1)
36
+ return false;
37
+ return STATIC_EXTENSIONS.has(path.slice(lastDot).toLowerCase());
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ function extractLocUrls(xmlBody) {
44
+ const urls = [];
45
+ const re = /<loc>([^<]+)<\/loc>/g;
46
+ for (let m = re.exec(xmlBody); m !== null; m = re.exec(xmlBody)) {
47
+ urls.push(m[1]?.trim() ?? '');
48
+ }
49
+ return urls.filter(Boolean);
50
+ }
51
+ /**
52
+ * Collect all page URLs from sitemap.xml and sitemap-unindexed.xml (raw <loc> values).
53
+ * Uses resolved page URL lists when present (e.g. after following sitemap index links).
54
+ * Used for rewrite checks so every sitemap URL is verified to not rewrite to a different path.
55
+ */
56
+ export function pageUrlsFromSitemaps(validationResult) {
57
+ const pageUrls = new Set();
58
+ const sitemapUrls = validationResult.sitemapPageUrls ??
59
+ (validationResult.sitemapXml.body ? extractLocUrls(validationResult.sitemapXml.body) : []);
60
+ const unindexedUrls = validationResult.sitemapUnindexedPageUrls ??
61
+ (validationResult.sitemapUnindexedXml.body
62
+ ? extractLocUrls(validationResult.sitemapUnindexedXml.body)
63
+ : []);
64
+ for (const url of sitemapUrls)
65
+ pageUrls.add(url);
66
+ for (const url of unindexedUrls)
67
+ pageUrls.add(url);
68
+ return [...pageUrls];
69
+ }
70
+ /**
71
+ * Convert a page URL (e.g. https://example.com/about/) to markdown URL (https://example.com/about.md).
72
+ */
73
+ function pageUrlToMarkdownUrl(pageUrl, baseUrl) {
74
+ const base = baseUrl.replace(/\/$/, '');
75
+ try {
76
+ const u = new URL(pageUrl);
77
+ if (u.origin !== new URL(base).origin)
78
+ return '';
79
+ const path = u.pathname.replace(/\/$/, '') || '/';
80
+ if (path === '/')
81
+ return `${base}/index.md`;
82
+ return `${base}${path}.md`;
83
+ }
84
+ catch {
85
+ return '';
86
+ }
87
+ }
88
+ /**
89
+ * Build markdown URL list from a list of page URLs (e.g. resolved from sitemaps).
90
+ * Excludes non-page assets and converts each page URL to its .md equivalent.
91
+ */
92
+ function markdownUrlsFromPageUrls(baseUrl, pageUrls) {
93
+ const base = baseUrl.replace(/\/$/, '');
94
+ const markdownUrls = [];
95
+ for (const pageUrl of pageUrls) {
96
+ if (isNonPageAssetUrl(pageUrl))
97
+ continue;
98
+ const mdUrl = pageUrlToMarkdownUrl(pageUrl, base);
99
+ if (mdUrl)
100
+ markdownUrls.push(mdUrl);
101
+ }
102
+ return markdownUrls;
103
+ }
104
+ /**
105
+ * Collect all markdown URLs from sitemap.xml and sitemap-unindexed.xml (Option B).
106
+ * Uses resolved page URL lists when present (e.g. after following sitemap index links).
107
+ * Ensures every sitemap page has a corresponding markdown URL to validate.
108
+ */
109
+ export function collectMarkdownUrlsFromSitemaps(baseUrl, validationResult) {
110
+ const pageUrls = pageUrlsFromSitemaps(validationResult);
111
+ return markdownUrlsFromPageUrls(baseUrl, pageUrls);
112
+ }
113
+ /**
114
+ * Convert a production page URL to the same path on a development base URL.
115
+ * Keeps pathname (and search/hash); only the origin is replaced.
116
+ */
117
+ function toDevPageUrl(prodPageUrl, devBaseUrl) {
118
+ const devBase = devBaseUrl.replace(/\/$/, '');
119
+ try {
120
+ const u = new URL(prodPageUrl);
121
+ const devOrigin = new URL(devBase).origin;
122
+ return `${devOrigin}${u.pathname}${u.search}${u.hash}`;
123
+ }
124
+ catch {
125
+ return '';
126
+ }
127
+ }
128
+ /**
129
+ * Map production page URLs to development page URLs (same path, dev origin).
130
+ * Excludes non-page assets (download paths, static file extensions).
131
+ * Used in compare mode: sitemap from prod, check existence on dev.
132
+ */
133
+ export function mapProdPageUrlsToDev(prodPageUrls, devBaseUrl) {
134
+ const devUrls = [];
135
+ for (const prodUrl of prodPageUrls) {
136
+ if (isNonPageAssetUrl(prodUrl))
137
+ continue;
138
+ const devUrl = toDevPageUrl(prodUrl, devBaseUrl);
139
+ if (devUrl)
140
+ devUrls.push(devUrl);
141
+ }
142
+ return devUrls;
143
+ }
144
+ //# sourceMappingURL=collect-markdown-urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-markdown-urls.js","sourceRoot":"","sources":["../src/collect-markdown-urls.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,+FAA+F;AAC/F,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAClD,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,OAAO,IAAI,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,OAAO,KAAK,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QACjC,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,sBAAsB,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,C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CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAC1C,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAsB,EAAE,UAAkB;IAC7E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;QACnC,IAAI,iBAAiB,CAAC,OAAO,CAAC;YAAE,SAAS;QACzC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjD,IAAI,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DiscoveryEndpointDefinition, DiscoveryEndpointKey } from './types.js';
2
+ export declare const DISCOVERY_ENDPOINTS: DiscoveryEndpointDefinition[];
3
+ export declare function discoveryEndpointByKey(key: DiscoveryEndpointKey): DiscoveryEndpointDefinition | undefined;
4
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/discovery/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,mBAAmB,EAAE,2BAA2B,EA6B5D,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,oBAAoB,GACxB,2BAA2B,GAAG,SAAS,CAEzC"}
@@ -0,0 +1,34 @@
1
+ export const DISCOVERY_ENDPOINTS = [
2
+ {
3
+ key: 'llmsTxt',
4
+ path: '/llms.txt',
5
+ label: 'llms.txt',
6
+ expectedContentType: 'text/plain',
7
+ validator: 'llms-txt',
8
+ },
9
+ {
10
+ key: 'markdownIndexTxt',
11
+ path: '/markdown-index.txt',
12
+ label: 'markdown-index.txt',
13
+ expectedContentType: 'text/plain',
14
+ validator: 'markdown-index',
15
+ },
16
+ {
17
+ key: 'cmsTxt',
18
+ path: '/cms.txt',
19
+ label: 'cms.txt',
20
+ expectedContentType: 'text/markdown',
21
+ validator: 'cms-txt',
22
+ },
23
+ {
24
+ key: 'siteInfoMd',
25
+ path: '/site-info.md',
26
+ label: 'site-info.md',
27
+ expectedContentType: 'text/markdown',
28
+ validator: 'site-info-md',
29
+ },
30
+ ];
31
+ export function discoveryEndpointByKey(key) {
32
+ return DISCOVERY_ENDPOINTS.find((entry) => entry.key === key);
33
+ }
34
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../src/discovery/endpoints.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAkC;IAChE;QACE,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,UAAU;QACjB,mBAAmB,EAAE,YAAY;QACjC,SAAS,EAAE,UAAU;KACtB;IACD;QACE,GAAG,EAAE,kBAAkB;QACvB,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,oBAAoB;QAC3B,mBAAmB,EAAE,YAAY;QACjC,SAAS,EAAE,gBAAgB;KAC5B;IACD;QACE,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,SAAS;QAChB,mBAAmB,EAAE,eAAe;QACpC,SAAS,EAAE,SAAS;KACrB;IACD;QACE,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,cAAc;QACrB,mBAAmB,EAAE,eAAe;QACpC,SAAS,EAAE,cAAc;KAC1B;CACF,CAAC;AAEF,MAAM,UAAU,sBAAsB,CACpC,GAAyB;IAEzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { DISCOVERY_ENDPOINTS, discoveryEndpointByKey } from './endpoints.js';
2
+ export { hasEnabledDiscoveryEndpoint, resolveDiscoveryConfig } from './resolve-config.js';
3
+ export type { DiscoveryContentValidator, DiscoveryEndpointKey, DiscoveryEndpointResult, DiscoveryFailureReason, DiscoverySmokeConfig, DiscoveryUrlOriginMode, DiscoveryValidationOptions, DiscoveryValidationResult, ResolvedDiscoveryConfig, } from './types.js';
4
+ export { contentTypeMatches, extractLlmsTxtKeyPageMarkdownUrls, extractMarkdownLinks, mapSpotCheckUrls, resolveDiscoveryContentBaseUrl, rewriteUrlsToBase, validateDiscoveryContent, } from './validate-content.js';
5
+ export { discoveryValidationFailed, validateDiscoveryEndpoints, } from './validate-endpoints.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC1F,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,oBAAoB,EACpB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { DISCOVERY_ENDPOINTS, discoveryEndpointByKey } from './endpoints.js';
2
+ export { hasEnabledDiscoveryEndpoint, resolveDiscoveryConfig } from './resolve-config.js';
3
+ export { contentTypeMatches, extractLlmsTxtKeyPageMarkdownUrls, extractMarkdownLinks, mapSpotCheckUrls, resolveDiscoveryContentBaseUrl, rewriteUrlsToBase, validateDiscoveryContent, } from './validate-content.js';
4
+ export { discoveryValidationFailed, validateDiscoveryEndpoints, } from './validate-endpoints.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAY1F,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,oBAAoB,EACpB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DiscoverySmokeConfig, ResolvedDiscoveryConfig } from './types.js';
2
+ /** Omitted keys default to true; explicit false skips the endpoint in smoke tests. */
3
+ export declare function resolveDiscoveryConfig(config?: DiscoverySmokeConfig | null): ResolvedDiscoveryConfig;
4
+ export declare function hasEnabledDiscoveryEndpoint(config: ResolvedDiscoveryConfig): boolean;
5
+ //# sourceMappingURL=resolve-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/discovery/resolve-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAMhF,sFAAsF;AACtF,wBAAgB,sBAAsB,CACpC,MAAM,CAAC,EAAE,oBAAoB,GAAG,IAAI,GACnC,uBAAuB,CAYzB;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAEpF"}
@@ -0,0 +1,21 @@
1
+ function normalizeBaseUrl(baseUrl) {
2
+ return baseUrl.replace(/\/$/, '');
3
+ }
4
+ /** Omitted keys default to true; explicit false skips the endpoint in smoke tests. */
5
+ export function resolveDiscoveryConfig(config) {
6
+ const resolved = {
7
+ llmsTxt: config?.llmsTxt !== false,
8
+ markdownIndexTxt: config?.markdownIndexTxt !== false,
9
+ cmsTxt: config?.cmsTxt !== false,
10
+ siteInfoMd: config?.siteInfoMd !== false,
11
+ urlOrigin: config?.urlOrigin ?? 'auto',
12
+ };
13
+ if (config?.canonicalBaseUrl) {
14
+ resolved.canonicalBaseUrl = normalizeBaseUrl(config.canonicalBaseUrl);
15
+ }
16
+ return resolved;
17
+ }
18
+ export function hasEnabledDiscoveryEndpoint(config) {
19
+ return config.llmsTxt || config.markdownIndexTxt || config.cmsTxt || config.siteInfoMd;
20
+ }
21
+ //# sourceMappingURL=resolve-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/discovery/resolve-config.ts"],"names":[],"mappings":"AAEA,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,sBAAsB,CACpC,MAAoC;IAEpC,MAAM,QAAQ,GAA4B;QACxC,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK;QAClC,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,KAAK,KAAK;QACpD,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK;QAChC,UAAU,EAAE,MAAM,EAAE,UAAU,KAAK,KAAK;QACxC,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,MAAM;KACvC,CAAC;IACF,IAAI,MAAM,EAAE,gBAAgB,EAAE,CAAC;QAC7B,QAAQ,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAA+B;IACzE,OAAO,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC;AACzF,CAAC"}
@@ -0,0 +1,60 @@
1
+ export type DiscoveryEndpointKey = 'llmsTxt' | 'markdownIndexTxt' | 'cmsTxt' | 'siteInfoMd';
2
+ export type DiscoveryContentValidator = 'llms-txt' | 'markdown-index' | 'cms-txt' | 'site-info-md';
3
+ export type DiscoveryFailureReason = 'discovery_missing' | 'discovery_wrong_content_type' | 'discovery_invalid_content' | 'discovery_broken_link';
4
+ /** How discovery URL origins are validated against the smoke deployment base URL. */
5
+ export type DiscoveryUrlOriginMode = 'deployment' | 'auto';
6
+ /** Per-app smoke.cases.json — omit a key or set true to require; false to skip. */
7
+ export interface DiscoverySmokeConfig {
8
+ llmsTxt?: boolean;
9
+ markdownIndexTxt?: boolean;
10
+ cmsTxt?: boolean;
11
+ siteInfoMd?: boolean;
12
+ /**
13
+ * `auto` (default): accept a single consistent HTTPS origin in llms.txt / markdown-index.txt
14
+ * when it differs from the deployment URL (production pre-alias deploys).
15
+ * `deployment`: require all URLs to match the smoke base URL.
16
+ */
17
+ urlOrigin?: DiscoveryUrlOriginMode;
18
+ /** Explicit canonical origin for discovery URL checks; skips inference when set. */
19
+ canonicalBaseUrl?: string;
20
+ }
21
+ export interface ResolvedDiscoveryConfig {
22
+ llmsTxt: boolean;
23
+ markdownIndexTxt: boolean;
24
+ cmsTxt: boolean;
25
+ siteInfoMd: boolean;
26
+ urlOrigin: DiscoveryUrlOriginMode;
27
+ canonicalBaseUrl?: string;
28
+ }
29
+ export interface DiscoveryEndpointDefinition {
30
+ key: DiscoveryEndpointKey;
31
+ path: string;
32
+ label: string;
33
+ expectedContentType: string;
34
+ validator: DiscoveryContentValidator;
35
+ }
36
+ export interface DiscoveryEndpointResult {
37
+ key: DiscoveryEndpointKey;
38
+ path: string;
39
+ label: string;
40
+ enabled: boolean;
41
+ skipped: boolean;
42
+ status: number;
43
+ contentType: string | null;
44
+ body: string | null;
45
+ failures: DiscoveryFailureReason[];
46
+ contentErrors: string[];
47
+ spotCheckFailures: string[];
48
+ }
49
+ export interface DiscoveryValidationOptions {
50
+ config: ResolvedDiscoveryConfig;
51
+ spotCheckLinks?: number;
52
+ fetch?: typeof fetch;
53
+ }
54
+ export interface DiscoveryValidationResult {
55
+ baseUrl: string;
56
+ endpoints: DiscoveryEndpointResult[];
57
+ errorCount: number;
58
+ skippedCount: number;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/discovery/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,kBAAkB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE5F,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,GAAG,cAAc,CAAC;AAEnG,MAAM,MAAM,sBAAsB,GAC9B,mBAAmB,GACnB,8BAA8B,GAC9B,2BAA2B,GAC3B,uBAAuB,CAAC;AAE5B,qFAAqF;AACrF,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,MAAM,CAAC;AAE3D,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAA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rC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/discovery/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { DiscoveryContentValidator, DiscoveryUrlOriginMode } from './types.js';
2
+ export interface ValidateDiscoveryContentOptions {
3
+ urlOrigin?: DiscoveryUrlOriginMode;
4
+ canonicalBaseUrl?: string;
5
+ }
6
+ export declare function extractMarkdownLinks(content: string): Array<{
7
+ title: string;
8
+ url: string;
9
+ }>;
10
+ export declare function extractLlmsTxtKeyPageMarkdownUrls(content: string, baseUrl: string): string[];
11
+ /**
12
+ * Rewrite absolute URLs onto `targetBaseUrl` (same path + query + hash).
13
+ * Used when discovery content lists a canonical origin but Deployment Checks smoke a pre-alias host.
14
+ * Preserves array length/order; unparseable entries are left unchanged.
15
+ */
16
+ export declare function rewriteUrlsToBase(urls: string[], targetBaseUrl: string): string[];
17
+ /**
18
+ * Map extracted Key pages URLs to the host that live smoke should actually fetch.
19
+ * When content is accepted under a canonical origin that differs from the deployment base,
20
+ * spot-check the deployment under test (not live CDN/www still serving the previous alias).
21
+ */
22
+ export declare function mapSpotCheckUrls(urls: string[], contentBaseUrl: string, deploymentBaseUrl: string): string[];
23
+ /**
24
+ * Base URL used for URL-origin checks and extracting Key pages links from llms.txt.
25
+ * Spot-checks rewrite those URLs onto the deployment host when this differs (see mapSpotCheckUrls).
26
+ */
27
+ export declare function resolveDiscoveryContentBaseUrl(validator: DiscoveryContentValidator, content: string, deploymentBaseUrl: string, options?: ValidateDiscoveryContentOptions): string;
28
+ export declare function validateDiscoveryContent(validator: DiscoveryContentValidator, content: string, deploymentBaseUrl: string, options?: ValidateDiscoveryContentOptions): string[];
29
+ export declare function contentTypeMatches(expected: string, actual: string | null): boolean;
30
+ //# sourceMappingURL=validate-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-content.d.ts","sourceRoot":"","sources":["../../src/discovery/validate-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAMpF,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAU3F;AAMD,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAS5F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAUjF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,GACxB,MAAM,EAAE,CAOV;AAsLD;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,yBAAyB,EACpC,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,+BAA+B,GACxC,MAAM,CAcR;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,yBAAyB,EACpC,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,+BAA+B,GACxC,MAAM,EAAE,CAcV;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGnF"}
@@ -0,0 +1,244 @@
1
+ const MIN_SITE_INFO_LENGTH = 50;
2
+ const MARKDOWN_LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
3
+ export function extractMarkdownLinks(content) {
4
+ const links = [];
5
+ for (const match of content.matchAll(MARKDOWN_LINK_RE)) {
6
+ const title = match[1]?.trim();
7
+ const url = match[2]?.trim();
8
+ if (title && url) {
9
+ links.push({ title, url });
10
+ }
11
+ }
12
+ return links;
13
+ }
14
+ function normalizeBaseUrl(baseUrl) {
15
+ return baseUrl.replace(/\/$/, '');
16
+ }
17
+ export function extractLlmsTxtKeyPageMarkdownUrls(content, baseUrl) {
18
+ const base = normalizeBaseUrl(baseUrl);
19
+ const sectionMatch = content.match(/## Key pages[\s\S]*?(?=## |$)/i);
20
+ if (!sectionMatch) {
21
+ return [];
22
+ }
23
+ return extractMarkdownLinks(sectionMatch[0])
24
+ .map((link) => link.url)
25
+ .filter((url) => url.startsWith(base) && url.endsWith('.md'));
26
+ }
27
+ /**
28
+ * Rewrite absolute URLs onto `targetBaseUrl` (same path + query + hash).
29
+ * Used when discovery content lists a canonical origin but Deployment Checks smoke a pre-alias host.
30
+ * Preserves array length/order; unparseable entries are left unchanged.
31
+ */
32
+ export function rewriteUrlsToBase(urls, targetBaseUrl) {
33
+ const base = normalizeBaseUrl(targetBaseUrl);
34
+ return urls.map((url) => {
35
+ try {
36
+ const parsed = new URL(url);
37
+ return `${base}${parsed.pathname}${parsed.search}${parsed.hash}`;
38
+ }
39
+ catch {
40
+ return url;
41
+ }
42
+ });
43
+ }
44
+ /**
45
+ * Map extracted Key pages URLs to the host that live smoke should actually fetch.
46
+ * When content is accepted under a canonical origin that differs from the deployment base,
47
+ * spot-check the deployment under test (not live CDN/www still serving the previous alias).
48
+ */
49
+ export function mapSpotCheckUrls(urls, contentBaseUrl, deploymentBaseUrl) {
50
+ const contentBase = normalizeBaseUrl(contentBaseUrl);
51
+ const deploymentBase = normalizeBaseUrl(deploymentBaseUrl);
52
+ if (contentBase === deploymentBase) {
53
+ return urls;
54
+ }
55
+ return rewriteUrlsToBase(urls, deploymentBase);
56
+ }
57
+ function extractLlmsTxtKeyPageHttpsUrls(content) {
58
+ const sectionMatch = content.match(/## Key pages[\s\S]*?(?=## |$)/i);
59
+ if (!sectionMatch) {
60
+ return [];
61
+ }
62
+ return extractMarkdownLinks(sectionMatch[0])
63
+ .map((link) => link.url)
64
+ .filter((url) => url.startsWith('https://') && url.endsWith('.md'));
65
+ }
66
+ function extractMarkdownIndexHttpsUrls(content) {
67
+ return content
68
+ .split('\n')
69
+ .map((line) => line.trim())
70
+ .filter((line) => line.startsWith('https://'));
71
+ }
72
+ function inferConsistentHttpsOrigin(urls) {
73
+ if (urls.length === 0) {
74
+ return null;
75
+ }
76
+ const origins = new Set();
77
+ for (const url of urls) {
78
+ try {
79
+ origins.add(new URL(url).origin);
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ }
85
+ if (origins.size !== 1) {
86
+ return null;
87
+ }
88
+ return [...origins][0] ?? null;
89
+ }
90
+ function inferContentOrigin(validator, content) {
91
+ switch (validator) {
92
+ case 'llms-txt':
93
+ return inferConsistentHttpsOrigin(extractLlmsTxtKeyPageHttpsUrls(content));
94
+ case 'markdown-index':
95
+ return inferConsistentHttpsOrigin(extractMarkdownIndexHttpsUrls(content));
96
+ default:
97
+ return null;
98
+ }
99
+ }
100
+ function validateLlmsTxtContent(content, baseUrl) {
101
+ const errors = [];
102
+ const base = normalizeBaseUrl(baseUrl);
103
+ if (!/^#\s+.+/m.test(content)) {
104
+ errors.push('missing H1 title (# Site name)');
105
+ }
106
+ if (!/^>\s+.+/m.test(content)) {
107
+ errors.push('missing blockquote summary (> …)');
108
+ }
109
+ if (!/##\s+Markdown access/i.test(content)) {
110
+ errors.push('missing "## Markdown access" section');
111
+ }
112
+ if (!/##\s+Key pages/i.test(content)) {
113
+ errors.push('missing "## Key pages" section');
114
+ }
115
+ const keyPageUrls = extractLlmsTxtKeyPageMarkdownUrls(content, base);
116
+ if (!/##\s+Key pages/i.test(content)) {
117
+ return errors;
118
+ }
119
+ if (keyPageUrls.length === 0) {
120
+ errors.push('Key pages section has no same-origin .md links');
121
+ }
122
+ if (!keyPageUrls.some((url) => url === `${base}/index.md`)) {
123
+ errors.push('Key pages should include home markdown URL (/index.md)');
124
+ }
125
+ return errors;
126
+ }
127
+ function validateMarkdownIndexContent(content, baseUrl) {
128
+ const errors = [];
129
+ const base = normalizeBaseUrl(baseUrl);
130
+ const lines = content
131
+ .split('\n')
132
+ .map((line) => line.trim())
133
+ .filter(Boolean);
134
+ if (lines.length === 0) {
135
+ errors.push('markdown-index.txt is empty');
136
+ return errors;
137
+ }
138
+ for (const line of lines) {
139
+ if (!line.startsWith('http://') && !line.startsWith('https://')) {
140
+ errors.push(`line is not an absolute URL: ${line.slice(0, 80)}`);
141
+ continue;
142
+ }
143
+ if (!line.startsWith(base)) {
144
+ errors.push(`line is not on site origin (${base}): ${line.slice(0, 80)}`);
145
+ }
146
+ if (!line.endsWith('.md')) {
147
+ errors.push(`line does not end with .md: ${line.slice(0, 80)}`);
148
+ }
149
+ }
150
+ return errors.slice(0, 5);
151
+ }
152
+ function validateCmsTxtContent(content) {
153
+ const errors = [];
154
+ const lower = content.toLowerCase();
155
+ if (!lower.includes('llms.txt')) {
156
+ errors.push('cms.txt should mention /llms.txt');
157
+ }
158
+ if (!lower.includes('markdown-index.txt')) {
159
+ errors.push('cms.txt should mention /markdown-index.txt');
160
+ }
161
+ if (content.trim().length < MIN_SITE_INFO_LENGTH) {
162
+ errors.push('cms.txt body is too short');
163
+ }
164
+ return errors;
165
+ }
166
+ function validateSiteInfoMdContent(content) {
167
+ const errors = [];
168
+ const trimmed = content.trim();
169
+ if (trimmed.length < MIN_SITE_INFO_LENGTH) {
170
+ errors.push('site-info.md body is too short');
171
+ }
172
+ if (!/^#\s+.+/m.test(trimmed) && !/^title:\s*.+/im.test(trimmed)) {
173
+ errors.push('site-info.md should have a # heading or title frontmatter');
174
+ }
175
+ return errors;
176
+ }
177
+ function validateDiscoveryContentForBase(validator, content, baseUrl) {
178
+ switch (validator) {
179
+ case 'llms-txt':
180
+ return validateLlmsTxtContent(content, baseUrl);
181
+ case 'markdown-index':
182
+ return validateMarkdownIndexContent(content, baseUrl);
183
+ case 'cms-txt':
184
+ return validateCmsTxtContent(content);
185
+ case 'site-info-md':
186
+ return validateSiteInfoMdContent(content);
187
+ default:
188
+ return [];
189
+ }
190
+ }
191
+ function resolveAlternateContentBaseUrl(validator, content, deploymentBaseUrl, options) {
192
+ const urlOrigin = options?.urlOrigin ?? 'auto';
193
+ if (urlOrigin === 'deployment') {
194
+ return null;
195
+ }
196
+ if (options?.canonicalBaseUrl) {
197
+ const canonicalBaseUrl = normalizeBaseUrl(options.canonicalBaseUrl);
198
+ return canonicalBaseUrl === deploymentBaseUrl ? null : canonicalBaseUrl;
199
+ }
200
+ if (validator !== 'llms-txt' && validator !== 'markdown-index') {
201
+ return null;
202
+ }
203
+ const inferredOrigin = inferContentOrigin(validator, content);
204
+ if (!inferredOrigin || inferredOrigin === deploymentBaseUrl) {
205
+ return null;
206
+ }
207
+ return inferredOrigin;
208
+ }
209
+ /**
210
+ * Base URL used for URL-origin checks and extracting Key pages links from llms.txt.
211
+ * Spot-checks rewrite those URLs onto the deployment host when this differs (see mapSpotCheckUrls).
212
+ */
213
+ export function resolveDiscoveryContentBaseUrl(validator, content, deploymentBaseUrl, options) {
214
+ const deploymentBase = normalizeBaseUrl(deploymentBaseUrl);
215
+ const deploymentErrors = validateDiscoveryContentForBase(validator, content, deploymentBase);
216
+ if (deploymentErrors.length === 0) {
217
+ return deploymentBase;
218
+ }
219
+ const alternateBase = resolveAlternateContentBaseUrl(validator, content, deploymentBase, options);
220
+ if (!alternateBase) {
221
+ return deploymentBase;
222
+ }
223
+ const alternateErrors = validateDiscoveryContentForBase(validator, content, alternateBase);
224
+ return alternateErrors.length === 0 ? alternateBase : deploymentBase;
225
+ }
226
+ export function validateDiscoveryContent(validator, content, deploymentBaseUrl, options) {
227
+ const deploymentBase = normalizeBaseUrl(deploymentBaseUrl);
228
+ const deploymentErrors = validateDiscoveryContentForBase(validator, content, deploymentBase);
229
+ if (deploymentErrors.length === 0) {
230
+ return [];
231
+ }
232
+ const alternateBase = resolveAlternateContentBaseUrl(validator, content, deploymentBase, options);
233
+ if (!alternateBase) {
234
+ return deploymentErrors;
235
+ }
236
+ const alternateErrors = validateDiscoveryContentForBase(validator, content, alternateBase);
237
+ return alternateErrors.length === 0 ? [] : deploymentErrors;
238
+ }
239
+ export function contentTypeMatches(expected, actual) {
240
+ if (!actual)
241
+ return false;
242
+ return actual.toLowerCase().includes(expected.toLowerCase());
243
+ }
244
+ //# sourceMappingURL=validate-content.js.map