@farming-labs/docs 0.2.69 → 0.2.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-D2SsSct2.mjs → agent-FIyl4-Oa.mjs} +510 -11
- package/dist/{agent-BIzynBvk.mjs → agent-bof3qzKZ.mjs} +2 -2
- package/dist/{agent-evals-DZR4J7Iz.mjs → agent-evals-Cr9TAkmB.mjs} +2 -1
- package/dist/{agent-export-C_zd18VF.mjs → agent-export-7Ws4KqDE.mjs} +11 -8
- package/dist/agent-skills-bundle.d.mts +1 -1
- package/dist/{agent-skills-server-iBfCLPOt.mjs → agent-skills-server-B4u3qy-1.mjs} +9 -5
- package/dist/{agent-skills-server-DJXdK_hS.d.mts → agent-skills-server-DTwblsLu.d.mts} +1 -1
- package/dist/agent-skills-spec.d.mts +51 -0
- package/dist/agent-skills-spec.mjs +284 -0
- package/dist/agent-skills-vite.d.mts +2 -2
- package/dist/agent-skills-vite.mjs +2 -2
- package/dist/{agents-BR5tSkbq.mjs → agents-Be2ntaFr.mjs} +6 -6
- package/dist/cli/index.mjs +14 -14
- package/dist/docs-cloud-server.d.mts +1 -1
- package/dist/{doctor-CVhU0YKo.mjs → doctor-DoPAofVP.mjs} +32 -15
- package/dist/{golden-evaluations-DK1uqjlo.mjs → golden-evaluations-CPGGnXOV.mjs} +1 -1
- package/dist/index.d.mts +84 -6
- package/dist/index.mjs +8 -7
- package/dist/{mcp-YWlNI2d4.mjs → mcp-BLynUzE7.mjs} +6 -6
- package/dist/mcp.d.mts +1 -1
- package/dist/mcp.mjs +3 -3
- package/dist/{metadata-CNjcFhQN.mjs → metadata-bw8k-9x-.mjs} +1 -1
- package/dist/{reading-time-O8mYgLvH.mjs → reading-time-DtNegNiq.mjs} +119 -7
- package/dist/{review-DdfvxMh2.mjs → review-NFnYbMRI.mjs} +6 -6
- package/dist/{robots-CD14j-mU.mjs → robots-B3e-aWPy.mjs} +3 -3
- package/dist/{robots-Dz5XeT8F.mjs → robots-DOqBwQw8.mjs} +2 -2
- package/dist/{search-BBVD0A7O.d.mts → search-CozHzW7v.d.mts} +1 -1
- package/dist/{search-DjN1Gfid.mjs → search-DOGUUZvs.mjs} +6 -6
- package/dist/{search-DBlw9h3P.mjs → search-x5O0-9X3.mjs} +2 -142
- package/dist/server.d.mts +3 -3
- package/dist/server.mjs +6 -6
- package/dist/{sitemap-B0hlAZ8o.mjs → sitemap-BpMKdDUd.mjs} +6 -6
- package/dist/{sitemap-server-DQp8qUKN.mjs → sitemap-server-D_hayOp6.mjs} +1 -1
- package/dist/{standards-discovery-DSVKdQrl.mjs → standards-discovery-CYfiQE13.mjs} +8 -31
- package/package.json +7 -1
- /package/dist/{cloud-ask-ai-BD1SeVZv.d.mts → cloud-ask-ai-BfnX18rI.d.mts} +0 -0
- /package/dist/{standards-discovery-CQjJ-M2y.d.mts → standards-discovery-C0CIC4QI.d.mts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as resolveDocsDiscoveryApiRoute, O as buildDocsApiCatalog, P as isDocsStandardsDiscoveryRequest, S as DOCS_AGENT_MANIFEST_FORMAT, _ as DEFAULT_API_CATALOG_FORMAT, a as DEFAULT_A2A_AGENT_CARD_ROUTE, b as DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, c as DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, d as DEFAULT_AGENT_SKILLS_ROUTE_PATTERN, j as createDocsStandardsResponse, l as DEFAULT_AGENT_SKILLS_INDEX_FORMAT, n as API_CATALOG_MEDIA_TYPE, r as API_CATALOG_PROFILE_URI, t as AGENT_SKILLS_DISCOVERY_SCHEMA_URI, u as DEFAULT_AGENT_SKILLS_INDEX_ROUTE, v as DEFAULT_API_CATALOG_ROUTE, w as DOCS_AGENT_MANIFEST_SCHEMA_URI } from "./standards-discovery-
|
|
1
|
+
import { F as resolveDocsDiscoveryApiRoute, O as buildDocsApiCatalog, P as isDocsStandardsDiscoveryRequest, S as DOCS_AGENT_MANIFEST_FORMAT, _ as DEFAULT_API_CATALOG_FORMAT, a as DEFAULT_A2A_AGENT_CARD_ROUTE, b as DEFAULT_LEGACY_SKILLS_INDEX_ROUTE, c as DEFAULT_AGENT_SKILLS_ARCHIVE_ROUTE_PATTERN, d as DEFAULT_AGENT_SKILLS_ROUTE_PATTERN, j as createDocsStandardsResponse, l as DEFAULT_AGENT_SKILLS_INDEX_FORMAT, n as API_CATALOG_MEDIA_TYPE, r as API_CATALOG_PROFILE_URI, t as AGENT_SKILLS_DISCOVERY_SCHEMA_URI, u as DEFAULT_AGENT_SKILLS_INDEX_ROUTE, v as DEFAULT_API_CATALOG_ROUTE, w as DOCS_AGENT_MANIFEST_SCHEMA_URI } from "./standards-discovery-CYfiQE13.mjs";
|
|
2
2
|
import { createProcessor } from "@mdx-js/mdx";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp-auth.ts
|
|
@@ -736,6 +736,148 @@ function normalizeInlineText(value) {
|
|
|
736
736
|
return value.replace(/\s+/g, " ").trim();
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/markdown-sections.ts
|
|
741
|
+
const HTML_ENTITIES = {
|
|
742
|
+
amp: "&",
|
|
743
|
+
apos: "'",
|
|
744
|
+
gt: ">",
|
|
745
|
+
lt: "<",
|
|
746
|
+
nbsp: " ",
|
|
747
|
+
quot: "\""
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Reduce inline Markdown in a heading to the visible label used by search and anchors.
|
|
751
|
+
* This intentionally covers the common inline constructs without adding a Markdown parser
|
|
752
|
+
* dependency to the runtime package.
|
|
753
|
+
*/
|
|
754
|
+
function cleanDocsMarkdownHeadingLabel(value) {
|
|
755
|
+
return value.replace(/!\[([^\]]*)\]\([^)]*\)/gu, "$1").replace(/\[([^\]]+)\]\([^)]*\)/gu, "$1").replace(/!\[([^\]]*)\]\[[^\]]*\]/gu, "$1").replace(/\[([^\]]+)\]\[[^\]]*\]/gu, "$1").replace(/<((?:https?:\/\/|mailto:)[^>]+)>/giu, "$1").replace(/<[^>]+>/gu, "").replace(/`+([^`]*?)`+/gu, "$1").replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/gu, "$1").replace(/[*_~]/gu, "").replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);/giu, (_match, entity) => {
|
|
756
|
+
if (entity.startsWith("#x") || entity.startsWith("#X")) {
|
|
757
|
+
const codePoint = Number.parseInt(entity.slice(2), 16);
|
|
758
|
+
return Number.isSafeInteger(codePoint) && codePoint >= 0 && codePoint <= 1114111 ? String.fromCodePoint(codePoint) : _match;
|
|
759
|
+
}
|
|
760
|
+
if (entity.startsWith("#")) {
|
|
761
|
+
const codePoint = Number.parseInt(entity.slice(1), 10);
|
|
762
|
+
return Number.isSafeInteger(codePoint) && codePoint >= 0 && codePoint <= 1114111 ? String.fromCodePoint(codePoint) : _match;
|
|
763
|
+
}
|
|
764
|
+
return HTML_ENTITIES[entity.toLowerCase()] ?? _match;
|
|
765
|
+
}).replace(/\s+/gu, " ").trim();
|
|
766
|
+
}
|
|
767
|
+
/** Keep anchors aligned with the framework's existing ASCII heading-slug behavior. */
|
|
768
|
+
function slugifyDocsMarkdownHeading(value) {
|
|
769
|
+
return cleanDocsMarkdownHeadingLabel(value).toLowerCase().replace(/[`'"‘’“”]/gu, "").replace(/&/gu, " and ").replace(/[^a-z0-9\s-]/gu, "").replace(/\s+/gu, "-").replace(/-+/gu, "-").replace(/^-|-$/gu, "");
|
|
770
|
+
}
|
|
771
|
+
function readOpeningFence(line) {
|
|
772
|
+
const match = line.match(/^ {0,3}(`{3,}|~{3,})/u);
|
|
773
|
+
if (!match) return void 0;
|
|
774
|
+
return {
|
|
775
|
+
marker: match[1][0],
|
|
776
|
+
length: match[1].length
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function isClosingFence(line, fence) {
|
|
780
|
+
const marker = fence.marker === "`" ? "`" : "~";
|
|
781
|
+
const match = line.match(new RegExp(`^ {0,3}(${marker}{${fence.length},})[\\t ]*$`, "u"));
|
|
782
|
+
return Boolean(match);
|
|
783
|
+
}
|
|
784
|
+
function readAtxHeading(line) {
|
|
785
|
+
const match = line.match(/^ {0,3}(#{1,6})(?:[\t ]+|$)(.*)$/u);
|
|
786
|
+
if (!match) return void 0;
|
|
787
|
+
return {
|
|
788
|
+
title: cleanDocsMarkdownHeadingLabel(match[2].replace(/[\t ]+#+[\t ]*$/u, "").trim()),
|
|
789
|
+
level: match[1].length
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function readSetextLevel(line) {
|
|
793
|
+
const match = line.match(/^ {0,3}(=+|-+)[\t ]*$/u);
|
|
794
|
+
if (!match) return void 0;
|
|
795
|
+
return match[1][0] === "=" ? 1 : 2;
|
|
796
|
+
}
|
|
797
|
+
function normalizeDocsSectionSelector(value) {
|
|
798
|
+
let selector = value.trim();
|
|
799
|
+
const hashIndex = selector.lastIndexOf("#");
|
|
800
|
+
if (hashIndex >= 0) selector = selector.slice(hashIndex + 1);
|
|
801
|
+
try {
|
|
802
|
+
selector = decodeURIComponent(selector);
|
|
803
|
+
} catch {}
|
|
804
|
+
return cleanDocsMarkdownHeadingLabel(selector.replace(/^#+/u, "")).toLowerCase();
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Parse heading sections once for search, Ask AI hydration, and MCP tools.
|
|
808
|
+
* Supports CommonMark ATX indentation, Setext headings, fenced-code exclusion,
|
|
809
|
+
* visible inline labels, and stable duplicate anchors.
|
|
810
|
+
*/
|
|
811
|
+
function parseDocsMarkdownSections(markdown) {
|
|
812
|
+
const lines = markdown.split(/\r?\n/u);
|
|
813
|
+
const headings = [];
|
|
814
|
+
const headingCounts = /* @__PURE__ */ new Map();
|
|
815
|
+
let openFence;
|
|
816
|
+
let setextCandidate;
|
|
817
|
+
const pushHeading = (title, level, start) => {
|
|
818
|
+
const baseAnchor = slugifyDocsMarkdownHeading(title) || `section-${headings.length}`;
|
|
819
|
+
const seen = headingCounts.get(baseAnchor) ?? 0;
|
|
820
|
+
headingCounts.set(baseAnchor, seen + 1);
|
|
821
|
+
headings.push({
|
|
822
|
+
title,
|
|
823
|
+
anchor: seen === 0 ? baseAnchor : `${baseAnchor}-${seen}`,
|
|
824
|
+
level,
|
|
825
|
+
start
|
|
826
|
+
});
|
|
827
|
+
};
|
|
828
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
829
|
+
const line = lines[index];
|
|
830
|
+
if (openFence) {
|
|
831
|
+
if (isClosingFence(line, openFence)) openFence = void 0;
|
|
832
|
+
setextCandidate = void 0;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
const openingFence = readOpeningFence(line);
|
|
836
|
+
if (openingFence) {
|
|
837
|
+
openFence = openingFence;
|
|
838
|
+
setextCandidate = void 0;
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
const setextLevel = readSetextLevel(line);
|
|
842
|
+
if (setextLevel && setextCandidate?.index === index - 1) {
|
|
843
|
+
const title = cleanDocsMarkdownHeadingLabel(setextCandidate.value.trim());
|
|
844
|
+
if (title) pushHeading(title, setextLevel, setextCandidate.index);
|
|
845
|
+
setextCandidate = void 0;
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
const atxHeading = readAtxHeading(line);
|
|
849
|
+
if (atxHeading) {
|
|
850
|
+
pushHeading(atxHeading.title, atxHeading.level, index);
|
|
851
|
+
setextCandidate = void 0;
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
if (!line.trim() || /^ {4}|^\t/u.test(line)) {
|
|
855
|
+
setextCandidate = void 0;
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
setextCandidate = {
|
|
859
|
+
index,
|
|
860
|
+
value: line
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
return headings.map((heading, index) => {
|
|
864
|
+
const end = headings.slice(index + 1).find((candidate) => candidate.level <= heading.level)?.start ?? lines.length;
|
|
865
|
+
return {
|
|
866
|
+
title: heading.title,
|
|
867
|
+
anchor: heading.anchor,
|
|
868
|
+
level: heading.level,
|
|
869
|
+
content: lines.slice(heading.start, end).join("\n").trim(),
|
|
870
|
+
startLine: heading.start + 1,
|
|
871
|
+
endLine: end
|
|
872
|
+
};
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
function findDocsMarkdownSection(markdown, requestedSection) {
|
|
876
|
+
const selector = normalizeDocsSectionSelector(requestedSection);
|
|
877
|
+
if (!selector) return void 0;
|
|
878
|
+
return parseDocsMarkdownSections(markdown).find((section) => normalizeDocsSectionSelector(section.title) === selector || section.anchor === selector);
|
|
879
|
+
}
|
|
880
|
+
|
|
739
881
|
//#endregion
|
|
740
882
|
//#region src/sitemap.ts
|
|
741
883
|
const DEFAULT_SITEMAP_XML_ROUTE = "/sitemap.xml";
|
|
@@ -2178,6 +2320,7 @@ const DEFAULT_DOCS_DIAGNOSTICS_MCP_TOOLS = {
|
|
|
2178
2320
|
getContext: true
|
|
2179
2321
|
};
|
|
2180
2322
|
const DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER = "Signature-Agent";
|
|
2323
|
+
const DOCS_MARKDOWN_SECTION_INDEX_FORMAT = "docs-markdown-sections.v1";
|
|
2181
2324
|
const DOCS_AI_AGENT_USER_AGENT_PATTERNS = [
|
|
2182
2325
|
"claudebot",
|
|
2183
2326
|
"claude-searchbot",
|
|
@@ -2307,6 +2450,7 @@ const DOCS_CONFIG_MAP_TOP_LEVEL_KEYS = [
|
|
|
2307
2450
|
"metadata",
|
|
2308
2451
|
"og"
|
|
2309
2452
|
];
|
|
2453
|
+
const DOCS_MARKDOWN_SECTION_MAX_BUDGET = 1e6;
|
|
2310
2454
|
function normalizeDocsPathSegment(value) {
|
|
2311
2455
|
return value.replace(/^\/+|\/+$/g, "");
|
|
2312
2456
|
}
|
|
@@ -3633,6 +3777,269 @@ function prependDocsMarkdownFrontmatter(markdown, metadata) {
|
|
|
3633
3777
|
if (hasDocsMarkdownFrontmatter(markdown)) return markdown;
|
|
3634
3778
|
return `${renderDocsMarkdownFrontmatter(metadata)}\n\n${markdown.replace(/^\r?\n+/, "")}`;
|
|
3635
3779
|
}
|
|
3780
|
+
function stripDocsMarkdownFrontmatter(markdown) {
|
|
3781
|
+
const match = markdown.match(/^(---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$))([\s\S]*)$/);
|
|
3782
|
+
if (!match) return {
|
|
3783
|
+
frontmatter: "",
|
|
3784
|
+
body: markdown
|
|
3785
|
+
};
|
|
3786
|
+
return {
|
|
3787
|
+
frontmatter: match[1] ?? "",
|
|
3788
|
+
body: match[2] ?? ""
|
|
3789
|
+
};
|
|
3790
|
+
}
|
|
3791
|
+
function slugifyPublicDocsMarkdownSectionId(value) {
|
|
3792
|
+
return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/`([^`]+)`/g, "$1").replace(/<[^>]*>/g, "").replace(/[^\p{L}\p{N}\s-]/gu, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
3793
|
+
}
|
|
3794
|
+
function resolveDocsMarkdownSectionBody(document) {
|
|
3795
|
+
const lines = stripDocsMarkdownFrontmatter(document).body.split(/\r?\n/u);
|
|
3796
|
+
let generatedPreambleStart = 0;
|
|
3797
|
+
while (generatedPreambleStart < lines.length && (lines[generatedPreambleStart] ?? "").trim() === "") generatedPreambleStart += 1;
|
|
3798
|
+
if (/^#(?:\s+|$)/u.test(lines[generatedPreambleStart] ?? "") && /^URL:\s+\S/u.test(lines[generatedPreambleStart + 1] ?? "")) {
|
|
3799
|
+
let metadataEnd = generatedPreambleStart + 2;
|
|
3800
|
+
while (/^(?:LLM index|Description|Related):\s*/u.test(lines[metadataEnd] ?? "")) metadataEnd += 1;
|
|
3801
|
+
for (let index = generatedPreambleStart + 1; index < metadataEnd; index += 1) lines[index] = "";
|
|
3802
|
+
}
|
|
3803
|
+
return {
|
|
3804
|
+
body: lines.join("\n").replace(/\n{2,}## Sitemap\n\n(?:(?:See the (?:full|XML) \[sitemap\]\()|Sitemap discovery is not enabled)[\s\S]*$/u, ""),
|
|
3805
|
+
lineOffset: 0
|
|
3806
|
+
};
|
|
3807
|
+
}
|
|
3808
|
+
function estimateDocsMarkdownTokens(value) {
|
|
3809
|
+
if (!value) return 0;
|
|
3810
|
+
return Math.max(1, Math.ceil(docsMarkdownUtf8Bytes(value) / 4));
|
|
3811
|
+
}
|
|
3812
|
+
function docsMarkdownUtf8Bytes(value) {
|
|
3813
|
+
return new TextEncoder().encode(value).byteLength;
|
|
3814
|
+
}
|
|
3815
|
+
function trimDocsMarkdownToByteBudget(value, byteBudget) {
|
|
3816
|
+
if (docsMarkdownUtf8Bytes(value) <= byteBudget) return value;
|
|
3817
|
+
let output = "";
|
|
3818
|
+
let bytes = 0;
|
|
3819
|
+
const encoder = new TextEncoder();
|
|
3820
|
+
for (const character of value) {
|
|
3821
|
+
const characterBytes = encoder.encode(character).byteLength;
|
|
3822
|
+
if (bytes + characterBytes > byteBudget) break;
|
|
3823
|
+
output += character;
|
|
3824
|
+
bytes += characterBytes;
|
|
3825
|
+
}
|
|
3826
|
+
return output.trimEnd();
|
|
3827
|
+
}
|
|
3828
|
+
function truncateDocsMarkdownSectionContent(content, request) {
|
|
3829
|
+
const budgets = [typeof request.byteBudget === "number" ? request.byteBudget : void 0, typeof request.tokenBudget === "number" ? request.tokenBudget * 4 : void 0].filter((budget) => budget !== void 0 && Number.isSafeInteger(budget) && budget > 0);
|
|
3830
|
+
const byteBudget = budgets.length > 0 ? Math.min(...budgets) : void 0;
|
|
3831
|
+
if (!byteBudget || docsMarkdownUtf8Bytes(content) <= byteBudget) return {
|
|
3832
|
+
document: content,
|
|
3833
|
+
truncated: false
|
|
3834
|
+
};
|
|
3835
|
+
const fullMarker = "\n\n<!-- section truncated: increase tokenBudget or byteBudget for more. -->";
|
|
3836
|
+
const marker = docsMarkdownUtf8Bytes(fullMarker) <= byteBudget ? fullMarker : "\n\n<!-- section truncated -->";
|
|
3837
|
+
if (docsMarkdownUtf8Bytes(marker) > byteBudget) return {
|
|
3838
|
+
document: trimDocsMarkdownToByteBudget(marker.trimStart(), byteBudget),
|
|
3839
|
+
truncated: true
|
|
3840
|
+
};
|
|
3841
|
+
let truncated = trimDocsMarkdownToByteBudget(content, Math.max(0, byteBudget - docsMarkdownUtf8Bytes(marker)));
|
|
3842
|
+
const paragraphBoundary = truncated.lastIndexOf("\n\n");
|
|
3843
|
+
if (paragraphBoundary > 0 && paragraphBoundary > truncated.length * .45) truncated = truncated.slice(0, paragraphBoundary).trimEnd();
|
|
3844
|
+
return {
|
|
3845
|
+
document: `${truncated}${marker}`,
|
|
3846
|
+
truncated: true
|
|
3847
|
+
};
|
|
3848
|
+
}
|
|
3849
|
+
function parsePositiveDocsMarkdownBudget(value) {
|
|
3850
|
+
if (!value) return null;
|
|
3851
|
+
const parsed = Number.parseInt(value.replace(/_/g, ""), 10);
|
|
3852
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) return null;
|
|
3853
|
+
return Math.min(parsed, DOCS_MARKDOWN_SECTION_MAX_BUDGET);
|
|
3854
|
+
}
|
|
3855
|
+
function resolveDocsMarkdownSectionRequest(url) {
|
|
3856
|
+
const section = url.searchParams.get("section")?.trim() || null;
|
|
3857
|
+
const tokenBudget = parsePositiveDocsMarkdownBudget(url.searchParams.get("tokenBudget")) ?? parsePositiveDocsMarkdownBudget(url.searchParams.get("tokens"));
|
|
3858
|
+
const byteBudget = parsePositiveDocsMarkdownBudget(url.searchParams.get("byteBudget")) ?? parsePositiveDocsMarkdownBudget(url.searchParams.get("bytes"));
|
|
3859
|
+
if (!section && tokenBudget === null && byteBudget === null) return null;
|
|
3860
|
+
return {
|
|
3861
|
+
section,
|
|
3862
|
+
tokenBudget,
|
|
3863
|
+
byteBudget
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
function isDocsMarkdownSectionIndexRequest(url) {
|
|
3867
|
+
if (!url.searchParams.has("sections")) return false;
|
|
3868
|
+
const value = url.searchParams.get("sections")?.trim().toLowerCase();
|
|
3869
|
+
return value === void 0 || ![
|
|
3870
|
+
"0",
|
|
3871
|
+
"false",
|
|
3872
|
+
"no",
|
|
3873
|
+
"off"
|
|
3874
|
+
].includes(value);
|
|
3875
|
+
}
|
|
3876
|
+
function collectDocsMarkdownSections(document) {
|
|
3877
|
+
const { body, lineOffset } = resolveDocsMarkdownSectionBody(document);
|
|
3878
|
+
const seen = /* @__PURE__ */ new Map();
|
|
3879
|
+
return parseDocsMarkdownSections(body).flatMap((section) => {
|
|
3880
|
+
const baseId = slugifyPublicDocsMarkdownSectionId(section.title);
|
|
3881
|
+
if (!baseId) return [];
|
|
3882
|
+
const count = seen.get(baseId) ?? 0;
|
|
3883
|
+
seen.set(baseId, count + 1);
|
|
3884
|
+
return [{
|
|
3885
|
+
id: count === 0 ? baseId : `${baseId}-${count + 1}`,
|
|
3886
|
+
heading: section.title,
|
|
3887
|
+
level: section.level,
|
|
3888
|
+
content: section.content,
|
|
3889
|
+
startLine: section.startLine + lineOffset,
|
|
3890
|
+
endLine: section.endLine + lineOffset
|
|
3891
|
+
}];
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3894
|
+
function updateDocsMarkdownUrl(value, update) {
|
|
3895
|
+
const isAbsolute = /^[a-z][a-z\d+.-]*:/iu.test(value);
|
|
3896
|
+
try {
|
|
3897
|
+
const url = new URL(value, "https://docs.invalid");
|
|
3898
|
+
update(url);
|
|
3899
|
+
return (isAbsolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`).replace(/([?&])sections=(?=&|$)/u, "$1sections");
|
|
3900
|
+
} catch {
|
|
3901
|
+
return value;
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
function resolveDocsMarkdownSectionCanonicalUrl(canonicalUrl, sectionId) {
|
|
3905
|
+
return updateDocsMarkdownUrl(canonicalUrl, (url) => {
|
|
3906
|
+
url.hash = sectionId;
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3909
|
+
function resolveDocsMarkdownSectionFetchUrl(markdownUrl, sectionId, request) {
|
|
3910
|
+
return updateDocsMarkdownUrl(markdownUrl, (url) => {
|
|
3911
|
+
url.searchParams.delete("sections");
|
|
3912
|
+
url.searchParams.delete("section");
|
|
3913
|
+
url.searchParams.delete("tokens");
|
|
3914
|
+
url.searchParams.delete("bytes");
|
|
3915
|
+
url.searchParams.delete("tokenBudget");
|
|
3916
|
+
url.searchParams.delete("byteBudget");
|
|
3917
|
+
url.searchParams.set("section", sectionId);
|
|
3918
|
+
if (request.tokenBudget) url.searchParams.set("tokenBudget", String(request.tokenBudget));
|
|
3919
|
+
if (request.byteBudget) url.searchParams.set("byteBudget", String(request.byteBudget));
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
function resolveDocsMarkdownSectionIndexUrl(markdownUrl, request) {
|
|
3923
|
+
return updateDocsMarkdownUrl(markdownUrl, (url) => {
|
|
3924
|
+
url.searchParams.delete("sections");
|
|
3925
|
+
url.searchParams.delete("section");
|
|
3926
|
+
url.searchParams.delete("tokens");
|
|
3927
|
+
url.searchParams.delete("bytes");
|
|
3928
|
+
url.searchParams.delete("tokenBudget");
|
|
3929
|
+
url.searchParams.delete("byteBudget");
|
|
3930
|
+
url.searchParams.set("sections", "");
|
|
3931
|
+
if (request.tokenBudget) url.searchParams.set("tokenBudget", String(request.tokenBudget));
|
|
3932
|
+
if (request.byteBudget) url.searchParams.set("byteBudget", String(request.byteBudget));
|
|
3933
|
+
});
|
|
3934
|
+
}
|
|
3935
|
+
function buildDocsMarkdownSectionIndex(document, options) {
|
|
3936
|
+
const request = {
|
|
3937
|
+
tokenBudget: options.tokenBudget ?? void 0,
|
|
3938
|
+
byteBudget: options.byteBudget ?? void 0
|
|
3939
|
+
};
|
|
3940
|
+
const sections = collectDocsMarkdownSections(document);
|
|
3941
|
+
const ancestors = [];
|
|
3942
|
+
const metadata = sections.map((section) => {
|
|
3943
|
+
while (ancestors.length > 0 && (ancestors[ancestors.length - 1]?.level ?? Number.NEGATIVE_INFINITY) >= section.level) ancestors.pop();
|
|
3944
|
+
const parentId = ancestors.at(-1)?.id;
|
|
3945
|
+
const item = {
|
|
3946
|
+
id: section.id,
|
|
3947
|
+
heading: section.heading,
|
|
3948
|
+
level: section.level,
|
|
3949
|
+
...parentId ? { parentId } : {},
|
|
3950
|
+
startLine: section.startLine,
|
|
3951
|
+
endLine: section.endLine,
|
|
3952
|
+
estimatedTokens: estimateDocsMarkdownTokens(section.content),
|
|
3953
|
+
utf8Bytes: docsMarkdownUtf8Bytes(section.content),
|
|
3954
|
+
canonicalUrl: resolveDocsMarkdownSectionCanonicalUrl(options.canonicalUrl, section.id),
|
|
3955
|
+
markdownUrl: resolveDocsMarkdownSectionFetchUrl(options.markdownUrl, section.id, request)
|
|
3956
|
+
};
|
|
3957
|
+
ancestors.push(section);
|
|
3958
|
+
return item;
|
|
3959
|
+
});
|
|
3960
|
+
const fetchBudget = request.tokenBudget || request.byteBudget ? {
|
|
3961
|
+
...request.tokenBudget ? { tokenBudget: request.tokenBudget } : {},
|
|
3962
|
+
...request.byteBudget ? { byteBudget: request.byteBudget } : {}
|
|
3963
|
+
} : void 0;
|
|
3964
|
+
return {
|
|
3965
|
+
schemaVersion: 1,
|
|
3966
|
+
format: DOCS_MARKDOWN_SECTION_INDEX_FORMAT,
|
|
3967
|
+
canonicalUrl: options.canonicalUrl,
|
|
3968
|
+
markdownUrl: options.markdownUrl,
|
|
3969
|
+
sectionIndexUrl: options.sectionIndexUrl ?? resolveDocsMarkdownSectionIndexUrl(options.markdownUrl, request),
|
|
3970
|
+
lineNumbering: "body",
|
|
3971
|
+
sectionCount: metadata.length,
|
|
3972
|
+
estimatedTokens: estimateDocsMarkdownTokens(document),
|
|
3973
|
+
utf8Bytes: docsMarkdownUtf8Bytes(document),
|
|
3974
|
+
...fetchBudget ? { fetchBudget } : {},
|
|
3975
|
+
sections: metadata
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
function normalizeRequestedDocsMarkdownSectionId(requestedSection) {
|
|
3979
|
+
let selector = requestedSection.trim();
|
|
3980
|
+
const hashIndex = selector.lastIndexOf("#");
|
|
3981
|
+
if (hashIndex >= 0) selector = selector.slice(hashIndex + 1);
|
|
3982
|
+
try {
|
|
3983
|
+
selector = decodeURIComponent(selector);
|
|
3984
|
+
} catch {}
|
|
3985
|
+
return selector.replace(/^#+/u, "").toLowerCase();
|
|
3986
|
+
}
|
|
3987
|
+
function selectDocsMarkdownSection(document, request) {
|
|
3988
|
+
const availableSections = collectDocsMarkdownSections(document);
|
|
3989
|
+
const requestedSection = request.section?.trim();
|
|
3990
|
+
if (!requestedSection) {
|
|
3991
|
+
const { document: budgetedDocument, truncated } = truncateDocsMarkdownSectionContent(document, request);
|
|
3992
|
+
return {
|
|
3993
|
+
found: true,
|
|
3994
|
+
document: budgetedDocument,
|
|
3995
|
+
truncated,
|
|
3996
|
+
tokenBudget: request.tokenBudget ?? void 0,
|
|
3997
|
+
byteBudget: request.byteBudget ?? void 0,
|
|
3998
|
+
estimatedTokens: estimateDocsMarkdownTokens(budgetedDocument),
|
|
3999
|
+
utf8Bytes: docsMarkdownUtf8Bytes(budgetedDocument),
|
|
4000
|
+
availableSections
|
|
4001
|
+
};
|
|
4002
|
+
}
|
|
4003
|
+
const requestedId = normalizeRequestedDocsMarkdownSectionId(requestedSection);
|
|
4004
|
+
const directSection = availableSections.find((candidate) => candidate.id === requestedId);
|
|
4005
|
+
const { body, lineOffset } = resolveDocsMarkdownSectionBody(document);
|
|
4006
|
+
const selectedSharedSection = directSection ? void 0 : findDocsMarkdownSection(body, requestedSection);
|
|
4007
|
+
const sharedAliasSection = selectedSharedSection ? availableSections.find((candidate) => candidate.startLine === selectedSharedSection.startLine + lineOffset) : void 0;
|
|
4008
|
+
const section = directSection ?? sharedAliasSection;
|
|
4009
|
+
if (!section) {
|
|
4010
|
+
const lines = [
|
|
4011
|
+
"# Markdown Section Not Found",
|
|
4012
|
+
"",
|
|
4013
|
+
requestedSection ? `Could not find section \`${requestedSection}\`.` : "No Markdown sections were available in this page."
|
|
4014
|
+
];
|
|
4015
|
+
if (availableSections.length > 0) lines.push("", "## Available Sections", "", ...availableSections.map((candidate) => `- ${candidate.heading} (#${candidate.id})`));
|
|
4016
|
+
const notFoundDocument = lines.join("\n");
|
|
4017
|
+
return {
|
|
4018
|
+
found: false,
|
|
4019
|
+
requestedSection,
|
|
4020
|
+
document: notFoundDocument,
|
|
4021
|
+
truncated: false,
|
|
4022
|
+
tokenBudget: request.tokenBudget ?? void 0,
|
|
4023
|
+
byteBudget: request.byteBudget ?? void 0,
|
|
4024
|
+
estimatedTokens: estimateDocsMarkdownTokens(notFoundDocument),
|
|
4025
|
+
utf8Bytes: docsMarkdownUtf8Bytes(notFoundDocument),
|
|
4026
|
+
availableSections
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
4029
|
+
const { document: selectedDocument, truncated } = truncateDocsMarkdownSectionContent(section.content, request);
|
|
4030
|
+
return {
|
|
4031
|
+
found: true,
|
|
4032
|
+
requestedSection,
|
|
4033
|
+
section,
|
|
4034
|
+
document: selectedDocument,
|
|
4035
|
+
truncated,
|
|
4036
|
+
tokenBudget: request.tokenBudget ?? void 0,
|
|
4037
|
+
byteBudget: request.byteBudget ?? void 0,
|
|
4038
|
+
estimatedTokens: estimateDocsMarkdownTokens(selectedDocument),
|
|
4039
|
+
utf8Bytes: docsMarkdownUtf8Bytes(selectedDocument),
|
|
4040
|
+
availableSections
|
|
4041
|
+
};
|
|
4042
|
+
}
|
|
3636
4043
|
function resolveDocsMarkdownPageMetadata(page, options) {
|
|
3637
4044
|
return {
|
|
3638
4045
|
title: page.title,
|
|
@@ -3737,6 +4144,17 @@ function resolveDocsMarkdownContentLocation(canonicalUrl) {
|
|
|
3737
4144
|
url.pathname = toDocsMarkdownUrl(url.pathname);
|
|
3738
4145
|
return url.toString();
|
|
3739
4146
|
}
|
|
4147
|
+
function appendDocsMarkdownSectionQuery(value, sectionRequest) {
|
|
4148
|
+
try {
|
|
4149
|
+
const url = new URL(value);
|
|
4150
|
+
if (sectionRequest.section) url.searchParams.set("section", sectionRequest.section);
|
|
4151
|
+
if (sectionRequest.tokenBudget) url.searchParams.set("tokenBudget", String(sectionRequest.tokenBudget));
|
|
4152
|
+
if (sectionRequest.byteBudget) url.searchParams.set("byteBudget", String(sectionRequest.byteBudget));
|
|
4153
|
+
return url.toString();
|
|
4154
|
+
} catch {
|
|
4155
|
+
return value;
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
3740
4158
|
/** Build one standards-aware Markdown response for every framework adapter. */
|
|
3741
4159
|
function createDocsMarkdownResponse(options) {
|
|
3742
4160
|
const { request, document, entry = "docs", requestedPath, origin = new URL(request.url).origin, pages, sitemap, locale } = options;
|
|
@@ -3748,9 +4166,7 @@ function createDocsMarkdownResponse(options) {
|
|
|
3748
4166
|
});
|
|
3749
4167
|
const contentLocation = options.contentLocation ?? resolveDocsMarkdownContentLocation(canonicalUrl);
|
|
3750
4168
|
const varyHeader = getDocsMarkdownVaryHeader(request);
|
|
3751
|
-
const
|
|
3752
|
-
"Content-Location": contentLocation,
|
|
3753
|
-
Link: `<${canonicalUrl}>; rel="canonical"`,
|
|
4169
|
+
const baseSharedHeaders = {
|
|
3754
4170
|
"X-Robots-Tag": "noindex",
|
|
3755
4171
|
...locale ? { "Content-Language": locale } : {},
|
|
3756
4172
|
...varyHeader ? { Vary: varyHeader } : {}
|
|
@@ -3765,7 +4181,9 @@ function createDocsMarkdownResponse(options) {
|
|
|
3765
4181
|
if (recovery.redirect) return new Response(null, {
|
|
3766
4182
|
status: 307,
|
|
3767
4183
|
headers: {
|
|
3768
|
-
...
|
|
4184
|
+
...baseSharedHeaders,
|
|
4185
|
+
"Content-Location": contentLocation,
|
|
4186
|
+
Link: `<${canonicalUrl}>; rel="canonical"`,
|
|
3769
4187
|
"Cache-Control": "no-store",
|
|
3770
4188
|
Location: new URL(recovery.redirect.markdownUrl, request.url).toString()
|
|
3771
4189
|
}
|
|
@@ -3780,19 +4198,81 @@ function createDocsMarkdownResponse(options) {
|
|
|
3780
4198
|
}), {
|
|
3781
4199
|
status: 404,
|
|
3782
4200
|
headers: {
|
|
3783
|
-
...
|
|
4201
|
+
...baseSharedHeaders,
|
|
4202
|
+
"Content-Location": contentLocation,
|
|
4203
|
+
Link: `<${canonicalUrl}>; rel="canonical"`,
|
|
3784
4204
|
"Cache-Control": "no-store",
|
|
3785
4205
|
"Content-Type": "text/markdown; charset=utf-8"
|
|
3786
4206
|
}
|
|
3787
4207
|
});
|
|
3788
4208
|
}
|
|
3789
|
-
const
|
|
4209
|
+
const requestUrl = new URL(request.url);
|
|
4210
|
+
const sectionRequest = resolveDocsMarkdownSectionRequest(requestUrl);
|
|
4211
|
+
if (isDocsMarkdownSectionIndexRequest(requestUrl)) {
|
|
4212
|
+
const sectionIndexRequest = sectionRequest ?? {};
|
|
4213
|
+
const sectionIndexContentLocation = resolveDocsMarkdownSectionIndexUrl(contentLocation, sectionIndexRequest);
|
|
4214
|
+
const sectionIndex = buildDocsMarkdownSectionIndex(document, {
|
|
4215
|
+
canonicalUrl,
|
|
4216
|
+
markdownUrl: contentLocation,
|
|
4217
|
+
sectionIndexUrl: sectionIndexContentLocation,
|
|
4218
|
+
tokenBudget: sectionIndexRequest.tokenBudget,
|
|
4219
|
+
byteBudget: sectionIndexRequest.byteBudget
|
|
4220
|
+
});
|
|
4221
|
+
const responseDocument = JSON.stringify(sectionIndex);
|
|
4222
|
+
const etag = createDocsMarkdownEtag(responseDocument);
|
|
4223
|
+
const lastModified = resolveDocsMarkdownHttpDate(options.lastModified ?? extractDocsMarkdownLastModified(document));
|
|
4224
|
+
const responseHeaders = {
|
|
4225
|
+
...baseSharedHeaders,
|
|
4226
|
+
"Content-Location": sectionIndexContentLocation,
|
|
4227
|
+
Link: `<${canonicalUrl}>; rel="canonical", <${contentLocation}>; rel="alternate"; type="text/markdown"`,
|
|
4228
|
+
"Cache-Control": options.cacheControl ?? "public, max-age=0, s-maxage=3600",
|
|
4229
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
4230
|
+
ETag: etag,
|
|
4231
|
+
"X-Docs-Markdown-Section-Index": DOCS_MARKDOWN_SECTION_INDEX_FORMAT,
|
|
4232
|
+
"X-Docs-Markdown-Section-Count": String(sectionIndex.sectionCount),
|
|
4233
|
+
"X-Docs-Markdown-Source-Estimated-Tokens": String(sectionIndex.estimatedTokens),
|
|
4234
|
+
"X-Docs-Markdown-Source-Utf8-Bytes": String(sectionIndex.utf8Bytes),
|
|
4235
|
+
"X-Docs-Markdown-Estimated-Tokens": String(estimateDocsMarkdownTokens(responseDocument)),
|
|
4236
|
+
"X-Docs-Markdown-Utf8-Bytes": String(docsMarkdownUtf8Bytes(responseDocument)),
|
|
4237
|
+
...sectionIndexRequest.tokenBudget ? { "X-Docs-Markdown-Token-Budget": String(sectionIndexRequest.tokenBudget) } : {},
|
|
4238
|
+
...sectionIndexRequest.byteBudget ? { "X-Docs-Markdown-Byte-Budget": String(sectionIndexRequest.byteBudget) } : {},
|
|
4239
|
+
...lastModified ? { "Last-Modified": lastModified } : {}
|
|
4240
|
+
};
|
|
4241
|
+
if (requestMatchesDocsMarkdownEtag(request, etag) || requestHasFreshDocsMarkdownDate(request, lastModified)) {
|
|
4242
|
+
const { "Content-Type": _contentType, ...notModifiedHeaders } = responseHeaders;
|
|
4243
|
+
return new Response(null, {
|
|
4244
|
+
status: 304,
|
|
4245
|
+
headers: notModifiedHeaders
|
|
4246
|
+
});
|
|
4247
|
+
}
|
|
4248
|
+
return new Response(request.method.toUpperCase() === "HEAD" ? null : responseDocument, {
|
|
4249
|
+
status: 200,
|
|
4250
|
+
headers: responseHeaders
|
|
4251
|
+
});
|
|
4252
|
+
}
|
|
4253
|
+
const sectionResult = sectionRequest ? selectDocsMarkdownSection(document, sectionRequest) : void 0;
|
|
4254
|
+
const responseDocument = sectionResult?.document ?? document;
|
|
4255
|
+
const sectionCanonicalUrl = sectionResult?.found && sectionResult.section ? `${canonicalUrl}#${sectionResult.section.id}` : canonicalUrl;
|
|
4256
|
+
const sectionContentLocation = sectionRequest ? appendDocsMarkdownSectionQuery(contentLocation, sectionRequest) : contentLocation;
|
|
4257
|
+
const sectionHeaders = sectionResult ? {
|
|
4258
|
+
"X-Docs-Markdown-Section": sectionResult.section?.id ?? "",
|
|
4259
|
+
"X-Docs-Markdown-Section-Found": sectionResult.found ? "true" : "false",
|
|
4260
|
+
"X-Docs-Markdown-Section-Truncated": sectionResult.truncated ? "true" : "false",
|
|
4261
|
+
"X-Docs-Markdown-Estimated-Tokens": String(sectionResult.estimatedTokens),
|
|
4262
|
+
"X-Docs-Markdown-Utf8-Bytes": String(sectionResult.utf8Bytes),
|
|
4263
|
+
...sectionResult.tokenBudget ? { "X-Docs-Markdown-Token-Budget": String(sectionResult.tokenBudget) } : {},
|
|
4264
|
+
...sectionResult.byteBudget ? { "X-Docs-Markdown-Byte-Budget": String(sectionResult.byteBudget) } : {}
|
|
4265
|
+
} : {};
|
|
4266
|
+
const etag = createDocsMarkdownEtag(responseDocument);
|
|
3790
4267
|
const lastModified = resolveDocsMarkdownHttpDate(options.lastModified ?? extractDocsMarkdownLastModified(document));
|
|
3791
4268
|
const responseHeaders = {
|
|
3792
|
-
...
|
|
3793
|
-
"
|
|
4269
|
+
...baseSharedHeaders,
|
|
4270
|
+
"Content-Location": sectionContentLocation,
|
|
4271
|
+
Link: `<${sectionCanonicalUrl}>; rel="canonical"`,
|
|
4272
|
+
"Cache-Control": sectionResult?.found === false ? "no-store" : options.cacheControl ?? "public, max-age=0, s-maxage=3600",
|
|
3794
4273
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
3795
4274
|
ETag: etag,
|
|
4275
|
+
...sectionHeaders,
|
|
3796
4276
|
...lastModified ? { "Last-Modified": lastModified } : {}
|
|
3797
4277
|
};
|
|
3798
4278
|
if (requestMatchesDocsMarkdownEtag(request, etag) || requestHasFreshDocsMarkdownDate(request, lastModified)) {
|
|
@@ -3802,7 +4282,10 @@ function createDocsMarkdownResponse(options) {
|
|
|
3802
4282
|
headers: notModifiedHeaders
|
|
3803
4283
|
});
|
|
3804
4284
|
}
|
|
3805
|
-
return new Response(
|
|
4285
|
+
return new Response(responseDocument, {
|
|
4286
|
+
status: sectionResult?.found === false ? 404 : 200,
|
|
4287
|
+
headers: responseHeaders
|
|
4288
|
+
});
|
|
3806
4289
|
}
|
|
3807
4290
|
function findDocsMarkdownPage(entry, pages, requestedPath) {
|
|
3808
4291
|
const normalizedRequest = normalizeRequestedMarkdownPath(entry, requestedPath);
|
|
@@ -3840,6 +4323,7 @@ function resolveDocsAgentDocumentContext({ entry = "docs", apiRoute, apiCatalog:
|
|
|
3840
4323
|
llmsSections: resolveDocsLlmsTxtSections(llms),
|
|
3841
4324
|
markdownAcceptHeader: markdown?.acceptHeader === false ? null : "text/markdown",
|
|
3842
4325
|
markdownSignatureAgentHeader: markdown?.signatureAgentHeader === false ? null : DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER,
|
|
4326
|
+
markdownSectionDiscoveryEnabled: markdown?.sectionDiscovery !== false,
|
|
3843
4327
|
apiCatalogEnabled: explicitApiCatalog ?? llms?.apiCatalog ?? true
|
|
3844
4328
|
};
|
|
3845
4329
|
}
|
|
@@ -3887,6 +4371,7 @@ function appendDocsAgentStartHereLines(lines, context, variant) {
|
|
|
3887
4371
|
lines.push(variant === "skill" ? `- Fetch ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}; fall back to ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE} or ${agentSpecFallback}.` : `- Read ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE} first; fall back to ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE} or ${agentSpecFallback}.`);
|
|
3888
4372
|
if (context.apiCatalogEnabled) lines.push(variant === "skill" ? `- Use ${DEFAULT_API_CATALOG_ROUTE} for standards-based API discovery.` : `- Use ${DEFAULT_API_CATALOG_ROUTE} for RFC 9727 API discovery.`);
|
|
3889
4373
|
lines.push(variant === "skill" ? `- Use ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} for hashed skill discovery.` : `- Use ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE} for integrity-checked skills.`, variant === "skill" ? `- Fetch /${context.normalizedEntry}.md for the root docs page.` : `- Read /${context.normalizedEntry}.md for the root docs page.`, variant === "skill" ? `- Fetch /${context.normalizedEntry}/{slug}.md for page-specific context.` : `- Read /${context.normalizedEntry}/{slug}.md for page-specific context.`);
|
|
4374
|
+
if (context.markdownSectionDiscoveryEnabled) lines.push(variant === "skill" ? `- Fetch /${context.normalizedEntry}/{slug}.md?sections to list section IDs and size estimates before requesting ?section={id}.` : `- Read /${context.normalizedEntry}/{slug}.md?sections before fetching ?section={id} when a full page is larger than needed.`);
|
|
3890
4375
|
if (variant === "skill") {
|
|
3891
4376
|
appendDocsMarkdownNegotiationStartLines(lines, context, variant);
|
|
3892
4377
|
appendDocsSearchStartLine(lines, context, variant);
|
|
@@ -3934,6 +4419,7 @@ function appendDocsAgentPublicRouteLines(lines, context, variant) {
|
|
|
3934
4419
|
lines.push(`- Agent instructions: ${DEFAULT_AGENTS_MD_ROUTE}`, `- Agent instructions well-known alias: ${DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE}`, `- Agent instructions API format: ${context.apiRoute}?format=agents`, `- Skill document: ${DEFAULT_SKILL_MD_ROUTE}`, `- Skill well-known alias: ${DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE}`, `- Skill API format: ${context.apiRoute}?format=skill`, `- Agent discovery: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}`, `- Agent discovery fallback: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE}`);
|
|
3935
4420
|
if (context.apiCatalogEnabled) lines.push(`- API catalog (RFC 9727): ${DEFAULT_API_CATALOG_ROUTE}`);
|
|
3936
4421
|
lines.push(`- Agent Skills index: ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE}`, `- Agent Skills artifacts: ${DEFAULT_AGENT_SKILLS_ROUTE_PATTERN}`, `- Markdown root: /${context.normalizedEntry}.md`, `- Markdown pages: /${context.normalizedEntry}/{slug}.md`);
|
|
4422
|
+
if (context.markdownSectionDiscoveryEnabled) lines.push(`- Markdown section index: /${context.normalizedEntry}/{slug}.md?sections`, `- Markdown section fetch: /${context.normalizedEntry}/{slug}.md?section={id}&tokenBudget={tokens}`);
|
|
3937
4423
|
if (context.robotsEnabled) lines.push(`- Robots policy: ${DEFAULT_AGENT_DISCOVERY_ROBOTS_TXT_ROUTE}`);
|
|
3938
4424
|
appendDocsLlmsRouteLines(lines, context);
|
|
3939
4425
|
appendDocsOpenApiRouteLines(lines, context);
|
|
@@ -3942,6 +4428,7 @@ function appendDocsAgentPublicRouteLines(lines, context, variant) {
|
|
|
3942
4428
|
return;
|
|
3943
4429
|
}
|
|
3944
4430
|
lines.push(`- Agent instructions: ${DEFAULT_AGENTS_MD_ROUTE}`, `- Agent instructions well-known alias: ${DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE}`, `- Agent instructions API format: ${context.apiRoute}?format=agents`, `- Agent instructions aliases: ${DEFAULT_AGENT_MD_ROUTE}, ${DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE}`, `- Site skill: ${DEFAULT_SKILL_MD_ROUTE}`, `- Site skill well-known alias: ${DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE}`, `- Site skill API format: ${context.apiRoute}?format=skill`, `- Markdown root: /${context.normalizedEntry}.md`, `- Markdown pages: /${context.normalizedEntry}/{slug}.md`, `- Agent discovery: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE}`, `- Agent discovery fallback: ${DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE}`);
|
|
4431
|
+
if (context.markdownSectionDiscoveryEnabled) lines.push(`- Markdown section index: /${context.normalizedEntry}/{slug}.md?sections`, `- Markdown section fetch: /${context.normalizedEntry}/{slug}.md?section={id}&tokenBudget={tokens}`);
|
|
3945
4432
|
if (context.apiCatalogEnabled) lines.push(`- API catalog (RFC 9727): ${DEFAULT_API_CATALOG_ROUTE}`);
|
|
3946
4433
|
lines.push(`- Agent Skills index: ${DEFAULT_AGENT_SKILLS_INDEX_ROUTE}`, `- Agent Skills artifacts: ${DEFAULT_AGENT_SKILLS_ROUTE_PATTERN}`);
|
|
3947
4434
|
appendDocsLlmsRouteLines(lines, context);
|
|
@@ -4024,6 +4511,7 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", apiRoute, apiCata
|
|
|
4024
4511
|
const openapiUrl = resolveDocsOpenApiDiscoveryUrl(openapiConfig, resolvedApiRoute);
|
|
4025
4512
|
const agentContractMcpTools = resolveDocsAgentContractMcpTools(mcp);
|
|
4026
4513
|
const apiCatalogEnabled = explicitApiCatalog ?? llms?.apiCatalog ?? true;
|
|
4514
|
+
const markdownSectionDiscoveryEnabled = markdown?.sectionDiscovery !== false;
|
|
4027
4515
|
const protectedResource = mcp.enabled && mcp.security?.authenticate ? mcp.security.protectedResource : void 0;
|
|
4028
4516
|
const protectedResourceMetadataRoutes = protectedResource ? getDocsMcpProtectedResourceMetadataRoutes(mcp.route) : [];
|
|
4029
4517
|
return {
|
|
@@ -4047,6 +4535,7 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", apiRoute, apiCata
|
|
|
4047
4535
|
},
|
|
4048
4536
|
capabilities: {
|
|
4049
4537
|
markdownRoutes: true,
|
|
4538
|
+
markdownSectionDiscovery: markdownSectionDiscoveryEnabled,
|
|
4050
4539
|
agentMdOverrides: true,
|
|
4051
4540
|
agentBlocks: true,
|
|
4052
4541
|
structuredAgentContracts: true,
|
|
@@ -4103,6 +4592,16 @@ function buildDocsAgentDiscoverySpec({ origin, entry = "docs", apiRoute, apiCata
|
|
|
4103
4592
|
pagePattern: `/${normalizedEntry}/{slug}.md`,
|
|
4104
4593
|
rootPage: `/${normalizedEntry}.md`,
|
|
4105
4594
|
apiPattern: apiQueryRoute("format=markdown&path={slug}"),
|
|
4595
|
+
sectionDiscovery: {
|
|
4596
|
+
enabled: markdownSectionDiscoveryEnabled,
|
|
4597
|
+
...markdownSectionDiscoveryEnabled ? {
|
|
4598
|
+
format: DOCS_MARKDOWN_SECTION_INDEX_FORMAT,
|
|
4599
|
+
indexParam: "sections",
|
|
4600
|
+
sectionParam: "section",
|
|
4601
|
+
tokenBudgetParam: "tokenBudget",
|
|
4602
|
+
byteBudgetParam: "byteBudget"
|
|
4603
|
+
} : {}
|
|
4604
|
+
},
|
|
4106
4605
|
resolutionOrder: [
|
|
4107
4606
|
"agent.md",
|
|
4108
4607
|
"agent audience projection",
|
|
@@ -4364,4 +4863,4 @@ function toYamlString(value) {
|
|
|
4364
4863
|
}
|
|
4365
4864
|
|
|
4366
4865
|
//#endregion
|
|
4367
|
-
export {
|
|
4866
|
+
export { matchesDocsLlmsTxtSection as $, PAGE_AGENT_STRUCTURED_CONTRACT_FIELDS as $t, buildDocsAgentDiscoverySpec as A, resolveDocsAudienceMdxContent as At, findDocsMarkdownPage as B, renderDocsSitemapXml as Bt, DOCS_AI_AGENT_USER_AGENT_HEADER_PATTERN as C, selectDocsMarkdownSection as Ct, DOCS_MARKDOWN_SIGNATURE_AGENT_HEADER as D, findDocsAudienceMdxTags as Dt, DOCS_MARKDOWN_SECTION_INDEX_FORMAT as E, findDocsAudienceMdxIssues as Et, buildDocsMcpEndpointCandidates as F, DEFAULT_SITEMAP_XML_ROUTE as Ft, isDocsAgentDiscoveryRequest as G, findDocsMarkdownSection as Gt, getDocsMarkdownCanonicalLinkHeader as H, resolveDocsSitemapPageLastmod as Ht, collectDocsMarkdownSections as I, buildDocsSitemapManifest as It, isDocsDiagnosticsRequest as J, renderDocsRelatedMarkdownLines as Jt, isDocsAgentsRequest as K, parseDocsMarkdownSections as Kt, createDocsMarkdownResponse as L, createDocsSitemapResponse as Lt, buildDocsConfigMap as M, DEFAULT_SITEMAP_MD_DOCS_ROUTE as Mt, buildDocsDiagnostics as N, DEFAULT_SITEMAP_MD_ROUTE as Nt, DOCS_TRADITIONAL_BOT_USER_AGENT_HEADER_PATTERN as O, resolveDocsAgentMdxContent as Ot, buildDocsMarkdownSectionIndex as P, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as Pt, isDocsSkillRequest as Q, PAGE_AGENT_CONTRACT_START_MARKER as Qt, createDocsStandardsDiscoveryResponse as R, readDocsSitemapManifestFromContentMap as Rt, DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE as S, resolveDocsMcpResourceLocation as Sn, selectDocsLlmsTxtContent as St, DOCS_CONFIG_MAP_TOP_LEVEL_KEYS as T, validateDocsAgentFeedbackPayload as Tt, getDocsMarkdownVaryHeader as U, resolveDocsSitemapRequest as Ut, getDocsLlmsTxtMaxCharsIssue as V, resolveDocsSitemapConfig as Vt, hasDocsMarkdownSignatureAgent as W, toDocsSitemapMarkdownUrl as Wt, isDocsMarkdownSectionIndexRequest as X, PAGE_AGENT_CONTRACT_FIELDS as Xt, isDocsLlmsTxtPublicRequest as Y, PAGE_AGENT_CONTRACT_END_MARKER as Yt, isDocsPublicGetRequest as Z, PAGE_AGENT_CONTRACT_FIELD_SCHEMA as Zt, DEFAULT_LLMS_TXT_MAX_CHARS as _, isDocsMcpRequest as _n, resolveDocsMarkdownRequest as _t, DEFAULT_AGENT_MD_ROUTE as a, stripGeneratedPageAgentContractMarkdown as an, renderDocsMarkdownDocument as at, DEFAULT_OPENAPI_SCHEMA_ROUTE as b, normalizeDocsMcpEndpointPath as bn, resolveDocsRequestApiRoute as bt, DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE as c, DEFAULT_MCP_PUBLIC_ROUTE as cn, resolveDocsAgentContractMcpTools as ct, DEFAULT_DOCS_CONFIG_FORMAT as d, buildDocsMcpProtectedResourceMetadataRoute as dn, resolveDocsAgentsFormat as dt, getPageAgentFrontmatterIssues as en, normalizeDocsPathSegment as et, DEFAULT_DOCS_CONFIG_ROUTE as f, getDocsMcpProtectedResourceMetadataRoutes as fn, resolveDocsLlmsTxtFormat as ft, DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE as g, isDocsMcpProtectedResourceMetadataPath as gn, resolveDocsMarkdownRecovery as gt, DEFAULT_LLMS_FULL_TXT_ROUTE as h, isDocsMcpOAuthScopeToken as hn, resolveDocsMarkdownCanonicalUrl as ht, DEFAULT_AGENT_FEEDBACK_ROUTE as i, renderPageAgentFrontmatterYamlLines as in, renderDocsLlmsTxt as it, buildDocsAgentFeedbackSchema as j, DEFAULT_SITEMAP_MANIFEST_PATH as jt, acceptsDocsMarkdown as k, resolveDocsAudienceExposure as kt, DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE as l, DEFAULT_MCP_ROUTE as ln, resolveDocsAgentFeedbackConfig as lt, DEFAULT_DOCS_DIAGNOSTICS_ROUTE as m, hasDocsMcpProtectedResourceConfig as mn, resolveDocsLlmsTxtSections as mt, DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE as n, normalizePageAgentFrontmatter as nn, parseDocsAgentFeedbackData as nt, DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE as o, upsertPageAgentContractMarkdown as on, renderDocsMarkdownNotFound as ot, DEFAULT_DOCS_DIAGNOSTICS_FORMAT as p, getDocsMcpResourcePaths as pn, resolveDocsLlmsTxtRequest as pt, isDocsConfigRequest as q, normalizeDocsRelated as qt, DEFAULT_AGENT_FEEDBACK_PAYLOAD_SCHEMA as r, renderPageAgentContractMarkdown as rn, renderDocsAgentsDocument as rt, DEFAULT_AGENT_SPEC_ROUTE as s, DEFAULT_MCP_PROTECTED_RESOURCE_METADATA_ROUTE as sn, renderDocsSkillDocument as st, DEFAULT_AGENTS_MD_ROUTE as t, hasStructuredPageAgentContract as tn, normalizeDocsUrlPath as tt, DEFAULT_DOCS_API_ROUTE as u, DEFAULT_MCP_WELL_KNOWN_ROUTE as un, resolveDocsAgentFeedbackRequest as ut, DEFAULT_LLMS_TXT_ROUTE as v, isDocsMcpResourcePath as vn, resolveDocsMarkdownSectionRequest as vt, DOCS_BOT_LIKE_USER_AGENT_HEADER_PATTERN as w, toDocsMarkdownUrl as wt, DEFAULT_SKILL_MD_ROUTE as x, resolveDocsMcpProtectedResourceMetadataLocation as xn, resolveDocsSkillFormat as xt, DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE as y, normalizeDocsMcpAuthorizationServerUrls as yn, resolveDocsOpenApiDiscoveryConfig as yt, detectDocsMarkdownAgentRequest as z, renderDocsSitemapMarkdown as zt };
|