@farming-labs/docs 0.2.53 → 0.2.55

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 (51) hide show
  1. package/dist/agent-BOOcHVDL.mjs +623 -0
  2. package/dist/{agent-BMxMpEa0.mjs → agent-DXkXi-pS.mjs} +590 -19
  3. package/dist/agent-evals-BD17jOqL.mjs +1166 -0
  4. package/dist/{agent-export--X9Go-wj.mjs → agent-export-BYznnYed.mjs} +9 -8
  5. package/dist/agent-scope-B8lptqCd.mjs +283 -0
  6. package/dist/agent-surface-drift-LS8zQgbq.mjs +1429 -0
  7. package/dist/{agents-CW-zTNKP.mjs → agents-BHzeeY45.mjs} +7 -6
  8. package/dist/{analytics-BZEwTK-8.mjs → analytics-Bx44lg6d.mjs} +1 -1
  9. package/dist/cli/index.mjs +29 -29
  10. package/dist/client/react.d.mts +1 -1
  11. package/dist/client/react.mjs +1 -1
  12. package/dist/{cloud-zs0qAnKJ.mjs → cloud-HWFlbfLJ.mjs} +4 -4
  13. package/dist/{cloud-ask-ai-BFlx8VMO.mjs → cloud-ask-ai-1k0q6OAH.mjs} +1 -1
  14. package/dist/{cloud-ask-ai-CMzYVzVX.d.mts → cloud-ask-ai-CvRVnwdK.d.mts} +1 -1
  15. package/dist/code-blocks-C9awWzEQ.mjs +871 -0
  16. package/dist/codeblocks-BzfkREEC.mjs +250 -0
  17. package/dist/{config-DhIyFsy9.mjs → config-CydaZ5PB.mjs} +52 -11
  18. package/dist/{dev-DFeVU2Ui.mjs → dev-BA2kRuCn.mjs} +3 -3
  19. package/dist/docs-cloud-server.d.mts +2 -2
  20. package/dist/docs-cloud-server.mjs +2 -2
  21. package/dist/{doctor-CkM5tKdD.mjs → doctor-CNIPJdxN.mjs} +150 -32
  22. package/dist/{downgrade-Dj_KXV11.mjs → downgrade-BStNhyCc.mjs} +2 -2
  23. package/dist/index.d.mts +40 -17
  24. package/dist/index.mjs +6 -7
  25. package/dist/{init-Cmz-oqnp.mjs → init-gnHQ_Pz9.mjs} +3 -3
  26. package/dist/{mcp-B4Q1PN93.mjs → mcp-F9zkBHrU.mjs} +6 -5
  27. package/dist/mcp.d.mts +22 -4
  28. package/dist/mcp.mjs +521 -43
  29. package/dist/{package-version-DxnTZH4m.mjs → package-version-DRIc08EU.mjs} +1 -1
  30. package/dist/{reading-time-BuK2YL23.mjs → reading-time-BrTd3DIh.mjs} +2 -3
  31. package/dist/{review-BEsbm0l2.mjs → review-Dlb8dRRx.mjs} +149 -14
  32. package/dist/{robots-BOwkq9du.mjs → robots-4BUJxlvV.mjs} +4 -5
  33. package/dist/{robots-C6uQG-fS.mjs → robots-DAptQnkx.mjs} +1 -1
  34. package/dist/{search-CtAXkk_J.mjs → search-B8cF77_i.mjs} +6 -5
  35. package/dist/{search-CTu6Bvq-.d.mts → search-BnQKgDbk.d.mts} +1 -1
  36. package/dist/{search-CJNLkdjX.mjs → search-CEg1omHv.mjs} +54 -11
  37. package/dist/server.d.mts +108 -5
  38. package/dist/server.mjs +9 -9
  39. package/dist/{sitemap-OPb8EdNe.mjs → sitemap-D9ivTLm8.mjs} +8 -7
  40. package/dist/{sitemap-server-DnilMEiZ.mjs → sitemap-server-wsNLyVkb.mjs} +1 -1
  41. package/dist/{types-CdKu8KmO.d.mts → types-R-DN23yw.d.mts} +79 -2
  42. package/dist/{upgrade-BNdBB9tQ.mjs → upgrade-CXYRNV0C.mjs} +2 -2
  43. package/package.json +2 -2
  44. package/dist/agent-2t4kZLGo.mjs +0 -10
  45. package/dist/agent-contract-b0akaPcg.mjs +0 -573
  46. package/dist/codeblocks-DWM4IJPL.mjs +0 -1710
  47. package/dist/review-BHdy75TE.mjs +0 -541
  48. /package/dist/{cloud-analytics-Dlk_byos.mjs → cloud-analytics-CSyFE6SS.mjs} +0 -0
  49. /package/dist/{errors-BxfYhp1L.mjs → errors-BFUtdZfC.mjs} +0 -0
  50. /package/dist/{templates-Bty9M6lA.mjs → templates-1Cod8KrJ.mjs} +0 -0
  51. /package/dist/{utils-CMZTjRQT.mjs → utils-DBCCkkJS.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import { i as detectPackageManagerFromProject, l as formatPackageManagerDetection, t as detectFramework, u as installCommand } from "./utils-CMZTjRQT.mjs";
1
+ import { i as detectPackageManagerFromProject, l as formatPackageManagerDetection, t as detectFramework, u as installCommand } from "./utils-DBCCkkJS.mjs";
2
2
  import pc from "picocolors";
3
3
  import * as p from "@clack/prompts";
4
4
 
@@ -1,6 +1,5 @@
1
- import { a as normalizePageAgentFrontmatter, i as hasStructuredPageAgentContract } from "./agent-contract-b0akaPcg.mjs";
2
- import { Et as DEFAULT_SITEMAP_XML_ROUTE, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, f as DEFAULT_DOCS_CONFIG_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, i as DEFAULT_AGENT_FEEDBACK_ROUTE, m as DEFAULT_DOCS_DIAGNOSTICS_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, wt as DEFAULT_SITEMAP_MD_ROUTE } from "./agent-BMxMpEa0.mjs";
3
- import { n as DEFAULT_ROBOTS_TXT_ROUTE } from "./robots-C6uQG-fS.mjs";
1
+ import { Dt as DEFAULT_SITEMAP_XML_ROUTE, Gt as hasStructuredPageAgentContract, Kt as normalizePageAgentFrontmatter, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, Tt as DEFAULT_SITEMAP_MD_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, f as DEFAULT_DOCS_CONFIG_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, i as DEFAULT_AGENT_FEEDBACK_ROUTE, m as DEFAULT_DOCS_DIAGNOSTICS_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE } from "./agent-DXkXi-pS.mjs";
2
+ import { n as DEFAULT_ROBOTS_TXT_ROUTE } from "./robots-DAptQnkx.mjs";
4
3
  import matter from "gray-matter";
5
4
 
6
5
  //#region src/define-docs.ts
@@ -1,14 +1,19 @@
1
- import { a as normalizePageAgentFrontmatter, i as hasStructuredPageAgentContract, r as getPageAgentFrontmatterIssues } from "./agent-contract-b0akaPcg.mjs";
2
- import { a as ensureDocsReviewWorkflow, o as readDocsReviewConfigFromSource, s as resolveDocsReviewConfig } from "./review-BHdy75TE.mjs";
3
- import { f as readTopLevelStringProperty, i as loadDocsConfigModule, m as resolveDocsContentDir, p as resolveDocsConfigPath } from "./config-DhIyFsy9.mjs";
1
+ import { Bt as PAGE_AGENT_CONTRACT_FIELDS, Gt as hasStructuredPageAgentContract, Kt as normalizePageAgentFrontmatter, M as buildDocsAgentDiscoverySpec, O as DOCS_CONFIG_MAP_TOP_LEVEL_KEYS, P as buildDocsConfigMap, Wt as getPageAgentFrontmatterIssues, f as DEFAULT_DOCS_CONFIG_ROUTE, u as DEFAULT_DOCS_API_ROUTE } from "./agent-DXkXi-pS.mjs";
2
+ import "./search-CEg1omHv.mjs";
3
+ import { c as resolveDocsReviewConfig, o as ensureDocsReviewWorkflow, s as readDocsReviewConfigFromSource, t as runDocsGoldenTasks } from "./agent-evals-BD17jOqL.mjs";
4
+ import { createFilesystemDocsMcpSource, getDocsConfigSchema, resolveDocsMcpConfig } from "./mcp.mjs";
5
+ import "./code-blocks-C9awWzEQ.mjs";
6
+ import { a as loadDocsConfigModuleResultWithProjectEnv, h as resolveDocsContentDir, m as resolveDocsConfigPath, p as readTopLevelStringProperty } from "./config-CydaZ5PB.mjs";
7
+ import { t as detectFramework } from "./utils-DBCCkkJS.mjs";
8
+ import { n as analyzeAgentUsefulness, r as createAgentUsefulnessPagesFromMcp, t as analyzeAgentSurfaceDrift } from "./agent-surface-drift-LS8zQgbq.mjs";
4
9
  import matter from "gray-matter";
5
10
  import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
6
11
  import path from "node:path";
7
- import pc from "picocolors";
8
12
  import { execFileSync } from "node:child_process";
13
+ import pc from "picocolors";
9
14
 
10
15
  //#region src/cli/review.ts
11
- const DOCS_FILE_PATTERN = /\.(?:md|mdx)$/;
16
+ const DOCS_FILE_PATTERN = /\.(?:md|mdx|svx)$/;
12
17
  const IGNORED_DIRS = new Set([
13
18
  ".git",
14
19
  ".next",
@@ -20,6 +25,26 @@ const IGNORED_DIRS = new Set([
20
25
  "node_modules",
21
26
  "out"
22
27
  ]);
28
+ function isPlainRecord(value) {
29
+ return typeof value === "object" && value !== null && !Array.isArray(value);
30
+ }
31
+ function resolveGoldenEvaluationTasks(evaluationInput) {
32
+ if (evaluationInput === void 0 || typeof evaluationInput === "boolean") return void 0;
33
+ if (!isPlainRecord(evaluationInput)) return { evaluationConfig: evaluationInput };
34
+ if (evaluationInput.enabled === false) return void 0;
35
+ if ("enabled" in evaluationInput && typeof evaluationInput.enabled !== "boolean") return evaluationInput;
36
+ if (!("tasks" in evaluationInput)) return void 0;
37
+ const runtimeTasks = evaluationInput.tasks;
38
+ if (!Array.isArray(runtimeTasks)) return runtimeTasks;
39
+ return runtimeTasks.map((task) => {
40
+ if (!isPlainRecord(task)) return task;
41
+ return {
42
+ ...task,
43
+ tokenBudget: task.tokenBudget ?? evaluationInput.tokenBudget,
44
+ topK: task.topK ?? evaluationInput.topK
45
+ };
46
+ });
47
+ }
23
48
  function parseReviewArgs(argv) {
24
49
  const parsed = {};
25
50
  for (let index = 0; index < argv.length; index += 1) {
@@ -85,7 +110,8 @@ async function runReview(options = {}) {
85
110
  const rootDir = process.cwd();
86
111
  const configPath = resolveDocsConfigPath(rootDir, options.configPath);
87
112
  const configContent = readFileSync(configPath, "utf-8");
88
- const config = (await loadDocsConfigModule(rootDir, options.configPath))?.config;
113
+ const configLoad = await loadDocsConfigModuleResultWithProjectEnv(rootDir, options.configPath);
114
+ const config = configLoad.status === "evaluated" ? configLoad.config : void 0;
89
115
  const review = withReviewOptionOverrides(resolveDocsReviewConfig(config?.review ?? readDocsReviewConfigFromSource(configContent)), options.mode, options.scoreThreshold);
90
116
  if (options.setup) {
91
117
  const result = ensureDocsReviewWorkflow({
@@ -101,7 +127,8 @@ async function runReview(options = {}) {
101
127
  }
102
128
  if (!review.enabled) {
103
129
  const report = {
104
- score: 100,
130
+ status: "disabled",
131
+ score: null,
105
132
  threshold: review.score.threshold,
106
133
  mode: options.ci ? review.ci.mode : "local",
107
134
  reviewedFiles: [],
@@ -123,6 +150,18 @@ async function runReview(options = {}) {
123
150
  rootDir,
124
151
  contentDir
125
152
  });
153
+ const mcpSource = createFilesystemDocsMcpSource({
154
+ rootDir,
155
+ entry,
156
+ contentDir,
157
+ siteTitle: typeof config?.nav?.title === "string" ? config.nav.title : "Documentation"
158
+ });
159
+ const corpusPages = await Promise.resolve(mcpSource.getPages());
160
+ const usefulness = analyzeAgentUsefulness({
161
+ rootDir,
162
+ pages: createAgentUsefulnessPagesFromMcp(rootDir, corpusPages),
163
+ projectFramework: detectFramework(rootDir) ?? void 0
164
+ });
126
165
  const findings = collectReviewFindings({
127
166
  rootDir,
128
167
  entry,
@@ -130,15 +169,95 @@ async function runReview(options = {}) {
130
169
  files: relevantFiles,
131
170
  review
132
171
  });
172
+ const relevantSet = new Set(relevantFiles);
173
+ for (const issue of usefulness.findings) {
174
+ if (!relevantSet.has(issue.file)) continue;
175
+ pushFinding(findings, review, {
176
+ rule: issue.category === "command" ? "commandHealth" : issue.category === "related" ? "relatedCoverage" : "agentContext",
177
+ code: issue.code,
178
+ severity: issue.severity === "warning" ? "warn" : issue.severity === "error" ? "error" : "suggestion",
179
+ file: issue.file,
180
+ line: issue.line,
181
+ message: issue.message
182
+ });
183
+ }
184
+ const evaluationInput = config?.agent?.evaluations;
185
+ const evaluations = await runDocsGoldenTasks(corpusPages, resolveGoldenEvaluationTasks(evaluationInput));
186
+ if (relevantFiles.length > 0 && evaluations.status === "unmeasured") pushFinding(findings, review, {
187
+ rule: "goldenTasks",
188
+ code: "golden-tasks-unmeasured",
189
+ severity: "warn",
190
+ file: toPosixPath(path.relative(rootDir, configPath)),
191
+ message: evaluationInput === false || typeof evaluationInput === "object" && evaluationInput.enabled === false ? "Golden agent tasks are disabled, so retrieval usefulness is unmeasured." : "No golden agent tasks are configured; retrieval, citations, version selection, executable examples, and token usage are unmeasured."
192
+ });
193
+ for (const task of evaluations.tasks.filter((task) => !task.passed)) pushFinding(findings, review, {
194
+ rule: "goldenTasks",
195
+ code: "golden-task-failed",
196
+ severity: "warn",
197
+ file: toPosixPath(path.relative(rootDir, configPath)),
198
+ message: `Golden task ${JSON.stringify(task.id)} scored ${task.score}/100: ${task.issues.join(" ")}`
199
+ });
200
+ if (configLoad.status === "static-fallback") pushFinding(findings, review, {
201
+ rule: "configConfidence",
202
+ code: "config-static-fallback",
203
+ severity: "warn",
204
+ file: toPosixPath(path.relative(rootDir, configPath)),
205
+ message: `docs.config could not be evaluated; review used partial static parsing. ${configLoad.error}`
206
+ });
207
+ else {
208
+ const evaluatedConfig = configLoad.config;
209
+ const searchEnabled = evaluatedConfig.search !== false && !(typeof evaluatedConfig.search === "object" && evaluatedConfig.search?.enabled === false);
210
+ const mcp = resolveDocsMcpConfig(evaluatedConfig.mcp, { defaultName: typeof evaluatedConfig.nav?.title === "string" ? evaluatedConfig.nav.title : void 0 });
211
+ const discovery = buildDocsAgentDiscoverySpec({
212
+ origin: "http://localhost",
213
+ entry,
214
+ search: evaluatedConfig.search,
215
+ mcp
216
+ });
217
+ const configuredAgentReviewPaths = Object.values(buildDocsConfigMap(evaluatedConfig).pointers).map((pointer) => pointer.path).filter((optionPath) => optionPath === "agent" || optionPath.startsWith("agent.") || optionPath === "review" || optionPath.startsWith("review."));
218
+ const drift = analyzeAgentSurfaceDrift({
219
+ configOptionPaths: [...new Set([...DOCS_CONFIG_MAP_TOP_LEVEL_KEYS, ...configuredAgentReviewPaths])],
220
+ schemaOptions: getDocsConfigSchema().options,
221
+ agentContractFields: PAGE_AGENT_CONTRACT_FIELDS,
222
+ discovery,
223
+ expected: {
224
+ entry,
225
+ search: {
226
+ enabled: searchEnabled,
227
+ endpoint: `${DEFAULT_DOCS_API_ROUTE}?query={query}`
228
+ },
229
+ mcp: {
230
+ enabled: mcp.enabled,
231
+ endpoint: mcp.route,
232
+ tools: mcp.tools
233
+ },
234
+ routes: {
235
+ "api.docs": DEFAULT_DOCS_API_ROUTE,
236
+ "api.config": DEFAULT_DOCS_CONFIG_ROUTE,
237
+ "config.endpoint": DEFAULT_DOCS_CONFIG_ROUTE
238
+ }
239
+ }
240
+ });
241
+ for (const issue of drift) pushFinding(findings, review, {
242
+ rule: "agentSurfaceDrift",
243
+ code: issue.code,
244
+ severity: "error",
245
+ file: toPosixPath(path.relative(rootDir, configPath)),
246
+ message: issue.message
247
+ });
248
+ }
133
249
  const score = calculateReviewScore(findings, review);
134
250
  const mode = options.ci ? review.ci.mode : "local";
135
251
  const report = {
252
+ status: "measured",
136
253
  score,
137
254
  threshold: review.score.threshold,
138
255
  mode,
139
256
  reviewedFiles: relevantFiles,
140
257
  changedFiles,
141
- findings
258
+ findings,
259
+ usefulness: usefulness.metrics,
260
+ evaluations
142
261
  };
143
262
  if (options.json) console.log(JSON.stringify(report, null, 2));
144
263
  else printReviewReport(report);
@@ -367,11 +486,17 @@ function printReviewReport(report) {
367
486
  console.log(`Changed files: ${report.changedFiles.length}`);
368
487
  console.log(`Reviewed docs files: ${report.reviewedFiles.length}`);
369
488
  console.log(`Findings: ${counts.error} error${counts.error === 1 ? "" : "s"}, ${counts.warn} warning${counts.warn === 1 ? "" : "s"}, ${counts.suggestion} suggestion${counts.suggestion === 1 ? "" : "s"}`);
370
- if (report.reviewedFiles.length === 0) {
489
+ if (report.usefulness) console.log(`Useful Agent blocks: ${report.usefulness.agentBlocks.useful}/${report.usefulness.agentBlocks.total}; task-complete pages: ${report.usefulness.taskCompleteness.completePages}/${report.usefulness.actionablePages}`);
490
+ if (report.evaluations) console.log(`Golden tasks: ${report.evaluations.status === "unmeasured" ? "unmeasured" : `${report.evaluations.passedTaskCount}/${report.evaluations.taskCount} passed (${report.evaluations.score}/100)`}`);
491
+ if (report.reviewedFiles.length === 0 && report.findings.length === 0) {
371
492
  console.log("");
372
493
  console.log(pc.green("No docs changes detected. Skipping review."));
373
494
  return;
374
495
  }
496
+ if (report.reviewedFiles.length === 0) {
497
+ console.log("");
498
+ console.log(pc.yellow("No docs files changed; reporting project-wide findings."));
499
+ }
375
500
  if (report.findings.length === 0) {
376
501
  console.log("");
377
502
  console.log(pc.green("No docs review findings."));
@@ -411,7 +536,17 @@ function selectReviewFiles(options) {
411
536
  const pageFiles = new Set(options.pages.map((page) => page.relativePath));
412
537
  const normalizedConfigPath = toPosixPath(options.configPath);
413
538
  if (options.changedFiles.includes(normalizedConfigPath)) return Array.from(pageFiles).sort();
414
- return options.changedFiles.map(toPosixPath).filter((file) => pageFiles.has(file)).sort();
539
+ const selected = /* @__PURE__ */ new Set();
540
+ for (const changedFile of options.changedFiles.map(toPosixPath)) {
541
+ if (pageFiles.has(changedFile)) {
542
+ selected.add(changedFile);
543
+ continue;
544
+ }
545
+ if (!changedFile.endsWith("/agent.md") && changedFile !== "agent.md") continue;
546
+ const sibling = options.pages.find((page) => path.posix.dirname(page.relativePath) === path.posix.dirname(changedFile));
547
+ if (sibling) selected.add(sibling.relativePath);
548
+ }
549
+ return Array.from(selected).sort();
415
550
  }
416
551
  function getChangedFiles(rootDir, options) {
417
552
  const ranges = [
@@ -439,7 +574,7 @@ function getChangedFiles(rootDir, options) {
439
574
  function scanDocsPages(rootDir, contentDir, entry) {
440
575
  const contentRoot = path.isAbsolute(contentDir) ? contentDir : path.join(rootDir, contentDir);
441
576
  if (!existsSync(contentRoot)) return [];
442
- return listFiles(contentRoot).filter((file) => DOCS_FILE_PATTERN.test(file)).map((absolutePath) => {
577
+ return listFiles(contentRoot).filter((file) => DOCS_FILE_PATTERN.test(file) && path.basename(file) !== "agent.md").map((absolutePath) => {
443
578
  const relativeToContent = toPosixPath(path.relative(contentRoot, absolutePath));
444
579
  const relativePath = toPosixPath(path.relative(rootDir, absolutePath));
445
580
  const slug = docsSlugFromFile(relativeToContent);
@@ -469,9 +604,9 @@ function listFiles(dir) {
469
604
  return files;
470
605
  }
471
606
  function docsSlugFromFile(relativePath) {
472
- const withoutExt = relativePath.replace(/\.(?:md|mdx)$/, "");
473
- if (withoutExt === "page" || withoutExt === "index") return "";
474
- if (withoutExt.endsWith("/page") || withoutExt.endsWith("/index")) return withoutExt.replace(/\/(?:page|index)$/, "");
607
+ const withoutExt = relativePath.replace(/\.(?:md|mdx|svx)$/, "");
608
+ if (withoutExt === "page" || withoutExt === "+page" || withoutExt === "index") return "";
609
+ if (withoutExt.endsWith("/page") || withoutExt.endsWith("/+page") || withoutExt.endsWith("/index")) return withoutExt.replace(/\/(?:\+?page|index)$/, "");
475
610
  return withoutExt;
476
611
  }
477
612
  function normalizeInternalHref(href) {
@@ -1,8 +1,7 @@
1
- import "./agent-contract-b0akaPcg.mjs";
2
- import "./agent-BMxMpEa0.mjs";
3
- import { c as renderDocsRobotsGeneratedBlock, f as upsertDocsRobotsGeneratedBlock, i as DOCS_ROBOTS_GENERATED_BLOCK_START, r as DOCS_ROBOTS_GENERATED_BLOCK_END, u as resolveDocsRobotsConfig } from "./robots-C6uQG-fS.mjs";
4
- import { f as readTopLevelStringProperty, i as loadDocsConfigModule, o as readBooleanProperty, p as resolveDocsConfigPath, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-DhIyFsy9.mjs";
5
- import { t as detectFramework } from "./utils-CMZTjRQT.mjs";
1
+ import "./agent-DXkXi-pS.mjs";
2
+ import { c as renderDocsRobotsGeneratedBlock, f as upsertDocsRobotsGeneratedBlock, i as DOCS_ROBOTS_GENERATED_BLOCK_START, r as DOCS_ROBOTS_GENERATED_BLOCK_END, u as resolveDocsRobotsConfig } from "./robots-DAptQnkx.mjs";
3
+ import { d as readStringProperty, i as loadDocsConfigModule, m as resolveDocsConfigPath, p as readTopLevelStringProperty, s as readBooleanProperty, t as extractNestedObjectLiteral } from "./config-CydaZ5PB.mjs";
4
+ import { t as detectFramework } from "./utils-DBCCkkJS.mjs";
6
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
7
6
  import path from "node:path";
8
7
  import pc from "picocolors";
@@ -1,4 +1,4 @@
1
- import { Mt as resolveDocsSitemapConfig, Q as normalizeDocsPathSegment, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, b as DEFAULT_MCP_PUBLIC_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, g as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, l as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, y as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE } from "./agent-BMxMpEa0.mjs";
1
+ import { $ as normalizeDocsPathSegment, Nt as resolveDocsSitemapConfig, S as DEFAULT_MCP_WELL_KNOWN_ROUTE, T as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, b as DEFAULT_MCP_PUBLIC_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, g as DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE, h as DEFAULT_LLMS_FULL_TXT_ROUTE, l as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, w as DEFAULT_SKILL_MD_ROUTE, y as DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE } from "./agent-DXkXi-pS.mjs";
2
2
 
3
3
  //#region src/robots.ts
4
4
  const DEFAULT_ROBOTS_TXT_ROUTE = "/robots.txt";
@@ -1,10 +1,11 @@
1
- import "./agent-contract-b0akaPcg.mjs";
2
- import "./agent-BMxMpEa0.mjs";
3
- import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-CJNLkdjX.mjs";
4
- import "./sitemap-server-DnilMEiZ.mjs";
1
+ import "./agent-DXkXi-pS.mjs";
2
+ import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-CEg1omHv.mjs";
3
+ import "./sitemap-server-wsNLyVkb.mjs";
4
+ import "./agent-evals-BD17jOqL.mjs";
5
5
  import { createFilesystemDocsMcpSource } from "./mcp.mjs";
6
+ import "./code-blocks-C9awWzEQ.mjs";
6
7
  import "./server.mjs";
7
- import { a as loadProjectEnv, f as readTopLevelStringProperty, m as resolveDocsContentDir, p as resolveDocsConfigPath } from "./config-DhIyFsy9.mjs";
8
+ import { h as resolveDocsContentDir, m as resolveDocsConfigPath, o as loadProjectEnv, p as readTopLevelStringProperty } from "./config-CydaZ5PB.mjs";
8
9
  import { readFileSync } from "node:fs";
9
10
  import pc from "picocolors";
10
11
 
@@ -1,4 +1,4 @@
1
- import { A as DocsAskAIMcpConfig, Cn as TypesenseDocsSearchConfig, Ct as DocsSearchDocument, Et as DocsSearchResult, Kt as McpDocsSearchConfig, Ot as DocsSearchSourcePage, Qt as OpenDocsTarget, St as DocsSearchConfig, Yt as OpenDocsProvider, b as DocsAnalyticsEventInput, bt as DocsSearchAdapterFactory, ct as DocsObservabilityEventInput, f as CustomDocsSearchConfig, h as DocsAgentTraceEventInput, kt as DocsSitemapConfig, ot as DocsObservabilityConfig, pn as ResolvedDocsRelatedLink, r as AlgoliaDocsSearchConfig, st as DocsObservabilityEvent, v as DocsAnalyticsConfig, vt as DocsSearchAdapter, xt as DocsSearchChunkingConfig, y as DocsAnalyticsEvent } from "./types-CdKu8KmO.mjs";
1
+ import { $t as McpDocsSearchConfig, An as TypesenseDocsSearchConfig, At as DocsSearchDocument, D as DocsAnalyticsEventInput, Dt as DocsSearchAdapterFactory, E as DocsAnalyticsEvent, Ft as DocsSearchSourcePage, It as DocsSitemapConfig, L as DocsAskAIMcpConfig, Nt as DocsSearchResult, Ot as DocsSearchChunkingConfig, S as DocsAgentTraceEventInput, T as DocsAnalyticsConfig, Tt as DocsSearchAdapter, an as OpenDocsTarget, bn as ResolvedDocsRelatedLink, f as CustomDocsSearchConfig, ht as DocsObservabilityEventInput, kt as DocsSearchConfig, mt as DocsObservabilityEvent, nn as OpenDocsProvider, pt as DocsObservabilityConfig, r as AlgoliaDocsSearchConfig } from "./types-R-DN23yw.mjs";
2
2
 
3
3
  //#region src/analytics.d.ts
4
4
  declare const DOCS_AGENT_TRACE_EVENT_TYPES: readonly ["run.start", "run.end", "run.error", "user.input", "prompt.build", "retrieval.query", "retrieval.result", "retrieval.error", "model.call", "model.response", "model.stream", "model.error", "tool.call", "tool.result", "tool.error", "retry", "timeout", "error", "agent.final"];
@@ -1,5 +1,4 @@
1
- import { l as upsertPageAgentContractMarkdown, n as PAGE_AGENT_CONTRACT_START_MARKER, o as renderPageAgentContractMarkdown, t as PAGE_AGENT_CONTRACT_END_MARKER } from "./agent-contract-b0akaPcg.mjs";
2
- import { U as isDocsAgentDiscoveryRequest, W as isDocsAgentsRequest, X as isDocsSkillRequest, ct as resolveDocsAgentFeedbackRequest, ft as resolveDocsLlmsTxtRequest, gt as resolveDocsMarkdownRequest, st as resolveDocsAgentFeedbackConfig, ut as resolveDocsAgentsFormat, vt as resolveDocsSkillFormat } from "./agent-BMxMpEa0.mjs";
1
+ import { G as isDocsAgentsRequest, Ht as PAGE_AGENT_CONTRACT_START_MARKER, W as isDocsAgentDiscoveryRequest, Xt as upsertPageAgentContractMarkdown, Z as isDocsSkillRequest, _t as resolveDocsMarkdownRequest, ct as resolveDocsAgentFeedbackConfig, dt as resolveDocsAgentsFormat, lt as resolveDocsAgentFeedbackRequest, pt as resolveDocsLlmsTxtRequest, qt as renderPageAgentContractMarkdown, yt as resolveDocsSkillFormat, zt as PAGE_AGENT_CONTRACT_END_MARKER } from "./agent-DXkXi-pS.mjs";
3
2
 
4
3
  //#region src/telemetry.ts
5
4
  const DOCS_PACKAGE_NAME = "@farming-labs/docs";
@@ -54,15 +53,42 @@ function readRequestOrigin(request) {
54
53
  return;
55
54
  }
56
55
  }
57
- function normalizeTelemetryOrigin(candidate) {
58
- if (!candidate) return void 0;
56
+ /** Normalize an HTTP(S) telemetry site value to its origin. */
57
+ function normalizeDocsTelemetryOrigin(candidate) {
58
+ if (typeof candidate !== "string") return void 0;
59
+ const trimmed = candidate.trim();
60
+ if (!trimmed) return void 0;
59
61
  try {
60
- const withProtocol = /^https?:\/\//i.test(candidate) ? candidate : `https://${candidate}`;
61
- return new URL(withProtocol).origin;
62
+ const hasScheme = /^[a-z][a-z\d+.-]*:(?!\d)/i.test(trimmed);
63
+ const url = new URL(hasScheme ? trimmed : `https://${trimmed}`);
64
+ if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
65
+ return url.origin;
62
66
  } catch {
63
67
  return;
64
68
  }
65
69
  }
70
+ /** Return whether a telemetry origin points at a local development server. */
71
+ function isLocalDocsTelemetryOrigin(candidate) {
72
+ const origin = normalizeDocsTelemetryOrigin(candidate);
73
+ if (!origin) return false;
74
+ const hostname = new URL(origin).hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
75
+ if ([
76
+ "localhost",
77
+ "localhost.localdomain",
78
+ "localhost6",
79
+ "localhost6.localdomain6",
80
+ "ip6-localhost",
81
+ "ip6-loopback"
82
+ ].includes(hostname) || hostname.endsWith(".localhost")) return true;
83
+ if (hostname === "::" || hostname === "::1") return true;
84
+ const ipv4 = hostname.split(".").map((part) => Number(part));
85
+ if (ipv4.length === 4 && ipv4.every((part) => Number.isInteger(part) && part >= 0 && part <= 255)) return ipv4[0] === 127 || ipv4.every((part) => part === 0);
86
+ return /^::ffff:7f[0-9a-f]{2}:/.test(hostname) || hostname === "::ffff:0:0";
87
+ }
88
+ function isBlockedDocsTelemetryOrigin(candidate) {
89
+ if (candidate === void 0) return false;
90
+ return !normalizeDocsTelemetryOrigin(candidate) || isLocalDocsTelemetryOrigin(candidate);
91
+ }
66
92
  function readDeploymentOrigin() {
67
93
  const candidates = [
68
94
  readRuntimeEnv("DOCS_SITE_URL"),
@@ -76,7 +102,7 @@ function readDeploymentOrigin() {
76
102
  readRuntimeEnv("DEPLOY_PRIME_URL")
77
103
  ];
78
104
  for (const candidate of candidates) {
79
- const origin = normalizeTelemetryOrigin(candidate);
105
+ const origin = normalizeDocsTelemetryOrigin(candidate);
80
106
  if (origin) return origin;
81
107
  }
82
108
  }
@@ -159,7 +185,15 @@ function getDocsTelemetryFeatures(config) {
159
185
  }
160
186
  function createDocsTelemetryEvent(config, input, context = {}) {
161
187
  const telemetryConfig = config.telemetry && typeof config.telemetry === "object" ? config.telemetry : void 0;
162
- const siteOrigin = context.siteOrigin ?? input.site?.origin ?? normalizeTelemetryOrigin(telemetryConfig?.siteOrigin) ?? readRequestOrigin(context.request) ?? readDeploymentOrigin();
188
+ const siteOriginCandidates = [
189
+ context.siteOrigin,
190
+ input.site?.origin,
191
+ telemetryConfig?.siteOrigin,
192
+ readRequestOrigin(context.request),
193
+ readDeploymentOrigin()
194
+ ];
195
+ if (siteOriginCandidates.some(isBlockedDocsTelemetryOrigin)) return void 0;
196
+ const siteOrigin = siteOriginCandidates.map(normalizeDocsTelemetryOrigin).find((origin) => Boolean(origin));
163
197
  const deployment = input.deployment ?? detectDeployment();
164
198
  const properties = context.properties || input.properties ? {
165
199
  ...input.properties,
@@ -207,7 +241,13 @@ function pruneSentProjectKeys(sent, now) {
207
241
  }
208
242
  async function emitDocsTelemetryEvent(telemetry, event) {
209
243
  const resolved = resolveDocsTelemetryConfig(telemetry);
210
- if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function") return;
244
+ const eventSiteOrigin = event.site?.origin;
245
+ const normalizedSiteOrigin = normalizeDocsTelemetryOrigin(eventSiteOrigin);
246
+ if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function" || eventSiteOrigin !== void 0 && (!normalizedSiteOrigin || isLocalDocsTelemetryOrigin(eventSiteOrigin))) return;
247
+ const eventToSend = normalizedSiteOrigin ? {
248
+ ...event,
249
+ site: { origin: normalizedSiteOrigin }
250
+ } : event;
211
251
  try {
212
252
  const ingestKey = readRuntimeEnv("DOCS_TELEMETRY_INGEST_KEY");
213
253
  const headers = { "content-type": "application/json" };
@@ -215,13 +255,14 @@ async function emitDocsTelemetryEvent(telemetry, event) {
215
255
  await fetch(resolved.endpoint, {
216
256
  method: "POST",
217
257
  headers,
218
- body: JSON.stringify({ event }),
258
+ body: JSON.stringify({ event: eventToSend }),
219
259
  keepalive: true
220
260
  });
221
261
  } catch {}
222
262
  }
223
263
  function emitDocsTelemetryProjectEvent(config, context = {}) {
224
264
  const event = createDocsTelemetryEvent(config, { type: "project_detected" }, context);
265
+ if (!event) return;
225
266
  const key = projectEventKey(event);
226
267
  const sent = getSentProjectKeys();
227
268
  const now = Date.now();
@@ -237,6 +278,7 @@ function emitDocsTelemetryAgentSurfaceEvent(config, context) {
237
278
  type: context.surface === "mcp" ? "mcp_request" : "agent_surface_used",
238
279
  properties: { surface: context.surface }
239
280
  }, context);
281
+ if (!event) return;
240
282
  emitDocsTelemetryEvent(config.telemetry, event);
241
283
  }
242
284
  function emitDocsTelemetryMcpToolEvent(config, context) {
@@ -248,6 +290,7 @@ function emitDocsTelemetryMcpToolEvent(config, context) {
248
290
  resultCount: context.resultCount
249
291
  }
250
292
  }, context);
293
+ if (!event) return;
251
294
  emitDocsTelemetryEvent(config.telemetry, event);
252
295
  }
253
296
  function inferDocsTelemetryAgentSurface(request, options) {
@@ -1585,4 +1628,4 @@ function createCustomSearchAdapter(adapter) {
1585
1628
  }
1586
1629
 
1587
1630
  //#endregion
1588
- export { getDocsTelemetryFeatures as A, resolvePageSidebarFolderIndexBehavior as C, emitDocsTelemetryEvent as D, emitDocsTelemetryAgentSurfaceEvent as E, resolveDocsTelemetryConfig as M, emitDocsTelemetryMcpToolEvent as O, applySidebarFolderIndexBehavior as S, resolveSidebarFolderIndexBehaviorForPath as T, hashGeneratedAgentContent as _, createMcpSearchAdapter as a, serializeGeneratedAgentDocument as b, formatDocsAskAIPackageHints as c, resolveAskAISearchRequestConfig as d, resolveSearchRequestConfig as f, GENERATED_AGENT_PROVENANCE_VERSION as g, GENERATED_AGENT_PROVENANCE_MARKER as h, createCustomSearchAdapter as i, inferDocsTelemetryAgentSurface as j, emitDocsTelemetryProjectEvent as k, inferDocsAskAIPackageHints as l, parseDocsMarkdownSections as m, buildDocsSearchDocuments as n, createSimpleSearchAdapter as o, findDocsMarkdownSection as p, createAlgoliaSearchAdapter as r, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, performDocsSearch as u, normalizeGeneratedAgentContent as v, resolveSidebarFolderIndexBehavior as w, stripGeneratedAgentProvenance as x, parseGeneratedAgentDocument as y };
1631
+ export { getDocsTelemetryFeatures as A, resolvePageSidebarFolderIndexBehavior as C, emitDocsTelemetryEvent as D, emitDocsTelemetryAgentSurfaceEvent as E, isLocalDocsTelemetryOrigin as M, normalizeDocsTelemetryOrigin as N, emitDocsTelemetryMcpToolEvent as O, resolveDocsTelemetryConfig as P, applySidebarFolderIndexBehavior as S, resolveSidebarFolderIndexBehaviorForPath as T, hashGeneratedAgentContent as _, createMcpSearchAdapter as a, serializeGeneratedAgentDocument as b, formatDocsAskAIPackageHints as c, resolveAskAISearchRequestConfig as d, resolveSearchRequestConfig as f, GENERATED_AGENT_PROVENANCE_VERSION as g, GENERATED_AGENT_PROVENANCE_MARKER as h, createCustomSearchAdapter as i, inferDocsTelemetryAgentSurface as j, emitDocsTelemetryProjectEvent as k, inferDocsAskAIPackageHints as l, parseDocsMarkdownSections as m, buildDocsSearchDocuments as n, createSimpleSearchAdapter as o, findDocsMarkdownSection as p, createAlgoliaSearchAdapter as r, createTypesenseSearchAdapter as s, buildDocsAskAIContext as t, performDocsSearch as u, normalizeGeneratedAgentContent as v, resolveSidebarFolderIndexBehavior as w, stripGeneratedAgentProvenance as x, parseGeneratedAgentDocument as y };
package/dist/server.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { A as DocsAskAIMcpConfig, Ct as DocsSearchDocument, D as DocsAskAIFeedbackData, E as DocsAskAIFeedbackConfig, Et as DocsSearchResult, Kt as McpDocsSearchConfig, O as DocsAskAIFeedbackMessage, Ot as DocsSearchSourcePage, St as DocsSearchConfig, Tt as DocsSearchQuery, W as DocsConfig, _ as DocsAgentTraceStatus, a as ApiReferenceRenderer, b as DocsAnalyticsEventInput, bt as DocsSearchAdapterFactory, ct as DocsObservabilityEventInput, dt as DocsReviewCiMode, ft as DocsReviewConfig, g as DocsAgentTraceEventType, h as DocsAgentTraceEventInput, k as DocsAskAIFeedbackValue, kt as DocsSitemapConfig, ot as DocsObservabilityConfig, pt as DocsReviewRulesConfig, st as DocsObservabilityEvent, v as DocsAnalyticsConfig, vt as DocsSearchAdapter, y as DocsAnalyticsEvent, yt as DocsSearchAdapterContext } from "./types-CdKu8KmO.mjs";
2
- import { i as isDocsCloudAskAIProvider, n as DocsCloudAskAIResponseOptions, r as createDocsCloudAskAIResponse, t as DocsCloudAskAIConfig } from "./cloud-ask-ai-CMzYVzVX.mjs";
1
+ import { $t as McpDocsSearchConfig, At as DocsSearchDocument, C as DocsAgentTraceEventType, D as DocsAnalyticsEventInput, Dt as DocsSearchAdapterFactory, E as DocsAnalyticsEvent, Et as DocsSearchAdapterContext, F as DocsAskAIFeedbackMessage, Ft as DocsSearchSourcePage, I as DocsAskAIFeedbackValue, It as DocsSitemapConfig, L as DocsAskAIMcpConfig, Mt as DocsSearchQuery, N as DocsAskAIFeedbackConfig, Nt as DocsSearchResult, P as DocsAskAIFeedbackData, S as DocsAgentTraceEventInput, T as DocsAnalyticsConfig, Tt as DocsSearchAdapter, Z as DocsConfig, a as ApiReferenceRenderer, b as DocsAgentGoldenTaskExpectation, bt as DocsReviewRulesConfig, ht as DocsObservabilityEventInput, kt as DocsSearchConfig, mt as DocsObservabilityEvent, pt as DocsObservabilityConfig, v as DocsAgentGoldenExpectedExample, vt as DocsReviewCiMode, w as DocsAgentTraceStatus, x as DocsAgentGoldenTaskFilters, y as DocsAgentGoldenTask, yt as DocsReviewConfig } from "./types-R-DN23yw.mjs";
2
+ import { i as isDocsCloudAskAIProvider, n as DocsCloudAskAIResponseOptions, r as createDocsCloudAskAIResponse, t as DocsCloudAskAIConfig } from "./cloud-ask-ai-CvRVnwdK.mjs";
3
3
  import { DocsCloudAskAIOptions, DocsCloudPublicConfig, DocsCloudRouteHandlerOptions, DocsCloudRouteHandlers, DocsCloudRuntimeEnv, DocsCloudRuntimeValue, DocsCloudServer, DocsCloudServerOptions, DocsCloudTrackEventOptions, createDocsCloudRouteHandler, createDocsCloudServer } from "./docs-cloud-server.mjs";
4
- import { $ as createDocsAgentTraceId, A as resolveDocsSitemapRequest, B as normalizePromptProviderName, C as buildDocsSitemapManifest, D as renderDocsSitemapXml, E as renderDocsSitemapMarkdown, F as DEFAULT_PROMPT_PROVIDER_TEMPLATES, G as serializeDocsIconRegistry, H as resolvePromptProviderChoices, I as PromptAction, J as DOCS_AGENT_TRACE_EVENT_TYPES, K as serializeOpenDocsProvider, L as PromptProviderChoice, M as DEFAULT_OPEN_DOCS_PROMPT, N as DEFAULT_OPEN_DOCS_PROVIDER_IDS, O as resolveDocsSitemapConfig, P as DEFAULT_OPEN_DOCS_TARGET, Q as createDocsAgentTraceContext, R as SerializeOpenDocsProviderOptions, S as DocsSitemapResolvedConfig, T as readDocsSitemapManifestFromContentMap, U as sanitizePromptText, V as parsePromptStringArray, W as serializeDocsIcon, X as ResolvedDocsAnalyticsConfig, Y as DocsAgentTraceContext, Z as ResolvedDocsObservabilityConfig, _ as DEFAULT_SITEMAP_XML_ROUTE, a as createMcpSearchAdapter, at as resolveDocsObservabilityConfig, b as DocsSitemapManifestPage, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAgentTraceEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, h as DEFAULT_SITEMAP_MD_ROUTE, i as createCustomSearchAdapter, it as resolveDocsAnalyticsConfig, j as toDocsSitemapMarkdownUrl, k as resolveDocsSitemapPageLastmod, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_DOCS_ROUTE, n as buildDocsSearchDocuments, nt as emitDocsObservabilityEvent, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as serializeOpenDocsProviders, r as createAlgoliaSearchAdapter, rt as getDocsRequestAnalyticsProperties, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsAnalyticsEvent, u as performDocsSearch, v as DocsSitemapFormat, w as createDocsSitemapResponse, x as DocsSitemapPageInput, y as DocsSitemapManifest, z as SerializedOpenDocsProvider } from "./search-CTu6Bvq-.mjs";
5
- import { CreateDocsMcpServerOptions, DEFAULT_DOCS_MCP_CORS_ALLOWED_HEADERS, DEFAULT_DOCS_MCP_CORS_EXPOSED_HEADERS, DEFAULT_DOCS_MCP_CORS_MAX_AGE_SECONDS, DEFAULT_DOCS_MCP_MAX_BODY_BYTES, DocsMcpAgentContractSummary, DocsMcpCodeExample, DocsMcpConfigSchema, DocsMcpConfigSchemaOption, DocsMcpContextResult, DocsMcpContextSource, DocsMcpDocsList, DocsMcpDocsPageSummary, DocsMcpDocsSection, DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpRequestContext, DocsMcpResolvedConfig, DocsMcpResolvedCorsConfig, DocsMcpResolvedSecurityConfig, DocsMcpSource, DocsMcpTaskSummary, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
4
+ import { $ as createDocsAgentTraceId, A as resolveDocsSitemapRequest, B as normalizePromptProviderName, C as buildDocsSitemapManifest, D as renderDocsSitemapXml, E as renderDocsSitemapMarkdown, F as DEFAULT_PROMPT_PROVIDER_TEMPLATES, G as serializeDocsIconRegistry, H as resolvePromptProviderChoices, I as PromptAction, J as DOCS_AGENT_TRACE_EVENT_TYPES, K as serializeOpenDocsProvider, L as PromptProviderChoice, M as DEFAULT_OPEN_DOCS_PROMPT, N as DEFAULT_OPEN_DOCS_PROVIDER_IDS, O as resolveDocsSitemapConfig, P as DEFAULT_OPEN_DOCS_TARGET, Q as createDocsAgentTraceContext, R as SerializeOpenDocsProviderOptions, S as DocsSitemapResolvedConfig, T as readDocsSitemapManifestFromContentMap, U as sanitizePromptText, V as parsePromptStringArray, W as serializeDocsIcon, X as ResolvedDocsAnalyticsConfig, Y as DocsAgentTraceContext, Z as ResolvedDocsObservabilityConfig, _ as DEFAULT_SITEMAP_XML_ROUTE, a as createMcpSearchAdapter, at as resolveDocsObservabilityConfig, b as DocsSitemapManifestPage, c as formatDocsAskAIPackageHints, d as resolveAskAISearchRequestConfig, et as emitDocsAgentTraceEvent, f as resolveSearchRequestConfig, g as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, h as DEFAULT_SITEMAP_MD_ROUTE, i as createCustomSearchAdapter, it as resolveDocsAnalyticsConfig, j as toDocsSitemapMarkdownUrl, k as resolveDocsSitemapPageLastmod, l as inferDocsAskAIPackageHints, m as DEFAULT_SITEMAP_MD_DOCS_ROUTE, n as buildDocsSearchDocuments, nt as emitDocsObservabilityEvent, o as createSimpleSearchAdapter, p as DEFAULT_SITEMAP_MANIFEST_PATH, q as serializeOpenDocsProviders, r as createAlgoliaSearchAdapter, rt as getDocsRequestAnalyticsProperties, s as createTypesenseSearchAdapter, t as buildDocsAskAIContext, tt as emitDocsAnalyticsEvent, u as performDocsSearch, v as DocsSitemapFormat, w as createDocsSitemapResponse, x as DocsSitemapPageInput, y as DocsSitemapManifest, z as SerializedOpenDocsProvider } from "./search-BnQKgDbk.mjs";
5
+ import { CreateDocsMcpServerOptions, DEFAULT_DOCS_MCP_CORS_ALLOWED_HEADERS, DEFAULT_DOCS_MCP_CORS_EXPOSED_HEADERS, DEFAULT_DOCS_MCP_CORS_MAX_AGE_SECONDS, DEFAULT_DOCS_MCP_MAX_BODY_BYTES, DOCS_CONFIG_SCHEMA_OPTIONS, DocsMcpAgentContractSummary, DocsMcpCodeExample, DocsMcpConfigSchema, DocsMcpConfigSchemaOption, DocsMcpContextResult, DocsMcpContextSource, DocsMcpDocsList, DocsMcpDocsPageSummary, DocsMcpDocsSection, DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpRequestContext, DocsMcpResolvedConfig, DocsMcpResolvedCorsConfig, DocsMcpResolvedSecurityConfig, DocsMcpSource, DocsMcpTaskSummary, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, getDocsConfigSchema, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
6
6
 
7
7
  //#region src/code-group-mdx.d.ts
8
8
  interface MarkdownNode {
@@ -130,7 +130,110 @@ declare function buildDocsReviewWorkflowPathFilters(options: {
130
130
  configContent?: string;
131
131
  }): string[];
132
132
  //#endregion
133
+ //#region src/agent-evals.d.ts
134
+ type DocsGoldenEvaluationStatus = "unmeasured" | "passed" | "failed";
135
+ type DocsGoldenTaskFilters = DocsAgentGoldenTaskFilters;
136
+ type DocsGoldenExpectedExample = DocsAgentGoldenExpectedExample;
137
+ type DocsGoldenTaskExpectation = DocsAgentGoldenTaskExpectation;
138
+ type DocsGoldenTask = DocsAgentGoldenTask;
139
+ interface DocsGoldenRetrievedSource {
140
+ rank: number;
141
+ url: string;
142
+ title: string;
143
+ framework?: string;
144
+ version?: string;
145
+ utf8Bytes: number;
146
+ relevant: boolean;
147
+ truncated: boolean;
148
+ }
149
+ interface DocsGoldenRetrievalMetrics {
150
+ expectedRelevant: number;
151
+ retrievedRelevant: number;
152
+ recallAtK: number;
153
+ firstRelevantRank: number | null;
154
+ reciprocalRank: number;
155
+ forbiddenSources: string[];
156
+ passed: boolean;
157
+ }
158
+ interface DocsGoldenCitationMetrics {
159
+ expected: string[];
160
+ actual: string[];
161
+ missing: string[];
162
+ unexpected: string[];
163
+ precision: number;
164
+ recall: number;
165
+ /** True when every rendered Source line maps one-to-one to a returned source record. */
166
+ integrity: boolean;
167
+ passed: boolean;
168
+ }
169
+ interface DocsGoldenSelectionMetrics {
170
+ requestedFramework?: string;
171
+ requestedVersion?: string;
172
+ firstFrameworkMatchRank: number | null;
173
+ firstVersionMatchRank: number | null;
174
+ conflictingSources: string[];
175
+ ambiguousSources: string[];
176
+ passed: boolean;
177
+ }
178
+ interface DocsGoldenExampleResult {
179
+ expected: DocsGoldenExpectedExample;
180
+ matchedId?: string;
181
+ source?: string;
182
+ executable: boolean;
183
+ passed: boolean;
184
+ }
185
+ interface DocsGoldenExampleMetrics {
186
+ expected: number;
187
+ matched: number;
188
+ executable: number;
189
+ results: DocsGoldenExampleResult[];
190
+ passed: boolean;
191
+ }
192
+ interface DocsGoldenUsageMetrics {
193
+ budgetUnit: "utf8-bytes";
194
+ tokenBudget: number;
195
+ usedUtf8Bytes: number;
196
+ remainingUtf8Bytes: number;
197
+ estimatedTokens: number;
198
+ /** Exact conservative upper bound: one token per UTF-8 byte. */
199
+ conservativeTokenUpperBound: number;
200
+ usefulUtf8Bytes: number;
201
+ usefulByteRatio: number;
202
+ truncated: boolean;
203
+ withinBudget: boolean;
204
+ passed: boolean;
205
+ }
206
+ interface DocsGoldenTaskReport {
207
+ id: string;
208
+ query: string;
209
+ status: "passed" | "failed";
210
+ passed: boolean;
211
+ score: number;
212
+ context: string;
213
+ sources: DocsGoldenRetrievedSource[];
214
+ retrieval: DocsGoldenRetrievalMetrics;
215
+ citations: DocsGoldenCitationMetrics;
216
+ selection: DocsGoldenSelectionMetrics;
217
+ examples: DocsGoldenExampleMetrics;
218
+ usage: DocsGoldenUsageMetrics;
219
+ issues: string[];
220
+ }
221
+ interface DocsGoldenTasksReport {
222
+ status: DocsGoldenEvaluationStatus;
223
+ passed: boolean | null;
224
+ score: number | null;
225
+ taskCount: number;
226
+ passedTaskCount: number;
227
+ failedTaskCount: number;
228
+ tasks: DocsGoldenTaskReport[];
229
+ }
230
+ /**
231
+ * Run deterministic, offline golden-task evaluations against MCP-ready docs pages.
232
+ * An empty task list is intentionally unmeasured so CI cannot turn absent coverage into a pass.
233
+ */
234
+ declare function runDocsGoldenTasks(pages: readonly DocsMcpPage[], tasks: readonly DocsGoldenTask[] | undefined): Promise<DocsGoldenTasksReport>;
235
+ //#endregion
133
236
  //#region src/sitemap-server.d.ts
134
237
  declare function readDocsSitemapManifest(rootDir: string, sitemap?: boolean | DocsSitemapConfig): DocsSitemapManifest | null;
135
238
  //#endregion
136
- export { type ApiReferenceFramework, type ApiReferenceOpenApiDiscovery, type ApiReferenceRenderer, type ApiReferenceRoute, type CreateDocsMcpServerOptions, DEFAULT_API_REFERENCE_OPENAPI_ROUTE, DEFAULT_DOCS_MCP_CORS_ALLOWED_HEADERS, DEFAULT_DOCS_MCP_CORS_EXPOSED_HEADERS, DEFAULT_DOCS_MCP_CORS_MAX_AGE_SECONDS, DEFAULT_DOCS_MCP_MAX_BODY_BYTES, DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD, DEFAULT_DOCS_REVIEW_WORKFLOW_PATH, DEFAULT_OPEN_DOCS_PROMPT, DEFAULT_OPEN_DOCS_PROVIDER_IDS, DEFAULT_OPEN_DOCS_TARGET, DEFAULT_PROMPT_PROVIDER_TEMPLATES, DEFAULT_SITEMAP_MANIFEST_PATH, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DEFAULT_SITEMAP_MD_ROUTE, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, DEFAULT_SITEMAP_XML_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAskAIFeedbackConfig, type DocsAskAIFeedbackData, type DocsAskAIFeedbackMessage, type DocsAskAIFeedbackValue, type DocsAskAIMcpConfig, type DocsCloudAskAIConfig, type DocsCloudAskAIOptions, type DocsCloudAskAIResponseOptions, type DocsCloudPublicConfig, type DocsCloudRouteHandlerOptions, type DocsCloudRouteHandlers, type DocsCloudRuntimeEnv, type DocsCloudRuntimeValue, type DocsCloudServer, type DocsCloudServerOptions, type DocsCloudTrackEventOptions, type DocsMcpAgentContractSummary, type DocsMcpCodeExample, type DocsMcpConfigSchema, type DocsMcpConfigSchemaOption, type DocsMcpContextResult, type DocsMcpContextSource, type DocsMcpDocsList, type DocsMcpDocsPageSummary, type DocsMcpDocsSection, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpRequestContext, type DocsMcpResolvedConfig, type DocsMcpResolvedCorsConfig, type DocsMcpResolvedSecurityConfig, type DocsMcpSource, type DocsMcpTaskSummary, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type DocsSitemapFormat, type DocsSitemapManifest, type DocsSitemapManifestPage, type DocsSitemapPageInput, type DocsSitemapResolvedConfig, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsObservabilityConfig, type ResolvedDocsReviewConfig, type SerializeOpenDocsProviderOptions, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsAskAIContext, buildDocsReviewWorkflow, buildDocsReviewWorkflowPathFilters, buildDocsSearchDocuments, buildDocsSitemapManifest, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAskAIResponse, createDocsCloudRouteHandler, createDocsCloudServer, createDocsMcpHttpHandler, createDocsMcpServer, createDocsSitemapResponse, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, ensureDocsReviewWorkflow, formatDocsAskAIPackageHints, getDocsRequestAnalyticsProperties, inferDocsAskAIPackageHints, isApiReferenceOpenApiRequest, isDocsCloudAskAIProvider, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, readDocsReviewConfigFromSource, readDocsSitemapManifest, readDocsSitemapManifestFromContentMap, remarkCodeGroup, renderDocsSitemapMarkdown, renderDocsSitemapXml, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveApiReferenceRenderer, resolveAskAISearchRequestConfig, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolveDocsReviewConfig, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsSitemapRequest, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProvider, serializeOpenDocsProviders, toDocsSitemapMarkdownUrl };
239
+ export { type ApiReferenceFramework, type ApiReferenceOpenApiDiscovery, type ApiReferenceRenderer, type ApiReferenceRoute, type CreateDocsMcpServerOptions, DEFAULT_API_REFERENCE_OPENAPI_ROUTE, DEFAULT_DOCS_MCP_CORS_ALLOWED_HEADERS, DEFAULT_DOCS_MCP_CORS_EXPOSED_HEADERS, DEFAULT_DOCS_MCP_CORS_MAX_AGE_SECONDS, DEFAULT_DOCS_MCP_MAX_BODY_BYTES, DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD, DEFAULT_DOCS_REVIEW_WORKFLOW_PATH, DEFAULT_OPEN_DOCS_PROMPT, DEFAULT_OPEN_DOCS_PROVIDER_IDS, DEFAULT_OPEN_DOCS_TARGET, DEFAULT_PROMPT_PROVIDER_TEMPLATES, DEFAULT_SITEMAP_MANIFEST_PATH, DEFAULT_SITEMAP_MD_DOCS_ROUTE, DEFAULT_SITEMAP_MD_ROUTE, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, DEFAULT_SITEMAP_XML_ROUTE, DOCS_AGENT_TRACE_EVENT_TYPES, DOCS_CONFIG_SCHEMA_OPTIONS, type DocsAgentTraceContext, type DocsAgentTraceEventInput, type DocsAgentTraceEventType, type DocsAgentTraceStatus, type DocsAnalyticsConfig, type DocsAnalyticsEvent, type DocsAnalyticsEventInput, type DocsAskAIFeedbackConfig, type DocsAskAIFeedbackData, type DocsAskAIFeedbackMessage, type DocsAskAIFeedbackValue, type DocsAskAIMcpConfig, type DocsCloudAskAIConfig, type DocsCloudAskAIOptions, type DocsCloudAskAIResponseOptions, type DocsCloudPublicConfig, type DocsCloudRouteHandlerOptions, type DocsCloudRouteHandlers, type DocsCloudRuntimeEnv, type DocsCloudRuntimeValue, type DocsCloudServer, type DocsCloudServerOptions, type DocsCloudTrackEventOptions, type DocsGoldenCitationMetrics, type DocsGoldenEvaluationStatus, type DocsGoldenExampleMetrics, type DocsGoldenExampleResult, type DocsGoldenExpectedExample, type DocsGoldenRetrievalMetrics, type DocsGoldenRetrievedSource, type DocsGoldenSelectionMetrics, type DocsGoldenTask, type DocsGoldenTaskExpectation, type DocsGoldenTaskFilters, type DocsGoldenTaskReport, type DocsGoldenTasksReport, type DocsGoldenUsageMetrics, type DocsMcpAgentContractSummary, type DocsMcpCodeExample, type DocsMcpConfigSchema, type DocsMcpConfigSchemaOption, type DocsMcpContextResult, type DocsMcpContextSource, type DocsMcpDocsList, type DocsMcpDocsPageSummary, type DocsMcpDocsSection, type DocsMcpHttpHandlers, type DocsMcpNavigationNode, type DocsMcpNavigationTree, type DocsMcpPage, type DocsMcpRequestContext, type DocsMcpResolvedConfig, type DocsMcpResolvedCorsConfig, type DocsMcpResolvedSecurityConfig, type DocsMcpSource, type DocsMcpTaskSummary, type DocsObservabilityConfig, type DocsObservabilityEvent, type DocsObservabilityEventInput, type DocsSearchAdapter, type DocsSearchAdapterContext, type DocsSearchAdapterFactory, type DocsSearchConfig, type DocsSearchDocument, type DocsSearchQuery, type DocsSearchResult, type DocsSearchSourcePage, type DocsSitemapFormat, type DocsSitemapManifest, type DocsSitemapManifestPage, type DocsSitemapPageInput, type DocsSitemapResolvedConfig, type McpDocsSearchConfig, type PromptAction, type PromptProviderChoice, type ResolvedApiReferenceConfig, type ResolvedDocsAnalyticsConfig, type ResolvedDocsObservabilityConfig, type ResolvedDocsReviewConfig, type SerializeOpenDocsProviderOptions, type SerializedOpenDocsProvider, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, buildDocsAskAIContext, buildDocsReviewWorkflow, buildDocsReviewWorkflowPathFilters, buildDocsSearchDocuments, buildDocsSitemapManifest, createAlgoliaSearchAdapter, createCustomSearchAdapter, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsCloudAskAIResponse, createDocsCloudRouteHandler, createDocsCloudServer, createDocsMcpHttpHandler, createDocsMcpServer, createDocsSitemapResponse, createFilesystemDocsMcpSource, createMcpSearchAdapter, createSimpleSearchAdapter, createTypesenseSearchAdapter, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsObservabilityEvent, ensureDocsReviewWorkflow, formatDocsAskAIPackageHints, getDocsConfigSchema, getDocsRequestAnalyticsProperties, inferDocsAskAIPackageHints, isApiReferenceOpenApiRequest, isDocsCloudAskAIProvider, normalizeDocsMcpRoute, normalizePromptProviderName, parsePromptStringArray, performDocsSearch, readDocsReviewConfigFromSource, readDocsSitemapManifest, readDocsSitemapManifestFromContentMap, remarkCodeGroup, renderDocsSitemapMarkdown, renderDocsSitemapXml, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveApiReferenceRenderer, resolveAskAISearchRequestConfig, resolveDocsAnalyticsConfig, resolveDocsMcpConfig, resolveDocsObservabilityConfig, resolveDocsReviewConfig, resolveDocsSitemapConfig, resolveDocsSitemapPageLastmod, resolveDocsSitemapRequest, resolvePromptProviderChoices, resolveSearchRequestConfig, runDocsGoldenTasks, runDocsMcpStdio, sanitizePromptText, serializeDocsIcon, serializeDocsIconRegistry, serializeOpenDocsProvider, serializeOpenDocsProviders, toDocsSitemapMarkdownUrl };