@farming-labs/docs 0.2.75 → 0.2.78

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 (39) hide show
  1. package/dist/{agent-BHqaZx-X.mjs → agent-Ba94vwM2.mjs} +4308 -340
  2. package/dist/{agent-cAPjC2jb.d.mts → agent-CHgWJcK_.d.mts} +60 -2
  3. package/dist/{agent-DxTa3PLB.mjs → agent-CM-hzhfh.mjs} +2 -2
  4. package/dist/{agent-evals-21LZ_uEl.mjs → agent-evals-C8dkgJMN.mjs} +1 -1
  5. package/dist/{agent-export-3VheegEK.mjs → agent-export-DdF-IVfg.mjs} +8 -7
  6. package/dist/agent-provenance-D8UBpnMc.mjs +463 -0
  7. package/dist/agent-skills-bundle.d.mts +1 -1
  8. package/dist/{agent-skills-server-noFn1l_p.mjs → agent-skills-server-B2EXn2QD.mjs} +1 -1
  9. package/dist/{agent-skills-server-Cix64aGB.d.mts → agent-skills-server-zvs0Yknt.d.mts} +2 -2
  10. package/dist/agent-skills-vite.d.mts +3 -3
  11. package/dist/agent-skills-vite.mjs +2 -2
  12. package/dist/{agents-ByTdP0Hl.mjs → agents-v0Em2KZo.mjs} +7 -16
  13. package/dist/cli/index.mjs +15 -15
  14. package/dist/client/react.d.mts +1 -1
  15. package/dist/{cloud-ask-ai-Bt0rzFbe.d.mts → cloud-ask-ai-BwsdF7AQ.d.mts} +1 -1
  16. package/dist/{dev-Cc1cFFj-.mjs → dev-kjaxOOla.mjs} +8 -2
  17. package/dist/docs-cloud-server.d.mts +2 -2
  18. package/dist/{doctor-C34VVF85.mjs → doctor-BbrN0rdC.mjs} +56 -24
  19. package/dist/{golden-evaluations-D_oDJwGv.mjs → golden-evaluations-Bk9t-HNq.mjs} +12 -3
  20. package/dist/index.d.mts +5 -5
  21. package/dist/index.mjs +6 -6
  22. package/dist/{mcp-Bnqfu8P5.mjs → mcp-DT-WNsA-.mjs} +6 -6
  23. package/dist/mcp.d.mts +28 -6
  24. package/dist/mcp.mjs +557 -62
  25. package/dist/{prompt-references-CfyYOa_W.mjs → prompt-references-CoDorsvS.mjs} +3 -3
  26. package/dist/{retrieval-digest-CFOcSKTo.d.mts → retrieval-digest-CO3wqeMk.d.mts} +105 -6
  27. package/dist/{review-Dw6oCQX3.mjs → review-DrCaaT7G.mjs} +5 -5
  28. package/dist/{robots-DaYBoy_A.mjs → robots-C_v2HK43.mjs} +2 -2
  29. package/dist/{robots-KWLujSLI.mjs → robots-izJbM9cv.mjs} +3 -3
  30. package/dist/{search-DBdmbUkc.mjs → search-YiZMZDfb.mjs} +6 -6
  31. package/dist/server.d.mts +9 -7
  32. package/dist/server.mjs +7 -7
  33. package/dist/{sitemap-CrzG5Wpf.mjs → sitemap-NO8UMO6Y.mjs} +6 -6
  34. package/dist/{sitemap-server-B9LZQ1FE.mjs → sitemap-server-Dgxs9V6S.mjs} +12 -3
  35. package/dist/{standards-discovery-BwL5ffGx.mjs → standards-discovery-BKlEnK_H.mjs} +32 -4
  36. package/dist/{standards-discovery-DBI1PD7m.d.mts → standards-discovery-BWyNgZSs.d.mts} +34 -7
  37. package/dist/{types-BDRwrExu.d.mts → types-CpLnwHak.d.mts} +190 -2
  38. package/package.json +1 -1
  39. package/dist/search-BmC8wVr0.mjs +0 -3490
@@ -0,0 +1,463 @@
1
+ import { G as isDocsAgentDiscoveryRequest, K as isDocsAgentsRequest, Kt as isDocsContentChangesRequest, Q as isDocsSkillRequest, _t as resolveDocsMarkdownRequest, dt as resolveDocsAgentsFormat, lt as resolveDocsAgentFeedbackConfig, pt as resolveDocsLlmsTxtRequest, qt as resolveDocsContentChangesConfig, ut as resolveDocsAgentFeedbackRequest, xt as resolveDocsSkillFormat } from "./agent-Ba94vwM2.mjs";
2
+
3
+ //#region src/telemetry.ts
4
+ const DOCS_PACKAGE_NAME = "@farming-labs/docs";
5
+ const DOCS_PACKAGE_VERSION = "0.2.25";
6
+ const DEFAULT_DOCS_TELEMETRY_ENDPOINT = "https://docs.farming-labs.dev/api/telemetry/events";
7
+ const PROJECT_TELEMETRY_CACHE_TTL_MS = 1440 * 60 * 1e3;
8
+ const PROJECT_TELEMETRY_CACHE_MAX_KEYS = 256;
9
+ function getRuntimeEnv() {
10
+ if (typeof process === "undefined" || !process.env) return;
11
+ return process.env;
12
+ }
13
+ function readRuntimeEnv(name) {
14
+ const value = getRuntimeEnv()?.[name]?.trim();
15
+ return value ? value : void 0;
16
+ }
17
+ function isTruthyEnv(value) {
18
+ return /^(1|true|yes|on)$/i.test(value ?? "");
19
+ }
20
+ function isFalsyEnv(value) {
21
+ return /^(0|false|no|off)$/i.test(value ?? "");
22
+ }
23
+ function isBrowserRuntime() {
24
+ return typeof window !== "undefined" && typeof document !== "undefined";
25
+ }
26
+ function isProductionTelemetryRuntime() {
27
+ if (isBrowserRuntime()) return false;
28
+ const env = getRuntimeEnv();
29
+ if (!env) return true;
30
+ if (env.NODE_ENV === "test") return false;
31
+ if (env.VERCEL_ENV === "production") return true;
32
+ if (env.CONTEXT === "production" && isTruthyEnv(env.NETLIFY)) return true;
33
+ if (isTruthyEnv(env.CF_PAGES)) return true;
34
+ if (env.RENDER_SERVICE_ID || env.FLY_APP_NAME || env.RAILWAY_ENVIRONMENT) return true;
35
+ return env.NODE_ENV === "production";
36
+ }
37
+ function resolveDocsTelemetryConfig(telemetry) {
38
+ const envToggle = readRuntimeEnv("DOCS_TELEMETRY");
39
+ const envDisabled = readRuntimeEnv("DOCS_TELEMETRY_DISABLED");
40
+ if (isFalsyEnv(envToggle) || isTruthyEnv(envDisabled) || telemetry === false) return { enabled: false };
41
+ const objectConfig = telemetry && typeof telemetry === "object" ? telemetry : void 0;
42
+ if (objectConfig?.enabled === false) return { enabled: false };
43
+ return {
44
+ enabled: telemetry === true || objectConfig?.enabled === true || isTruthyEnv(envToggle) || isProductionTelemetryRuntime(),
45
+ endpoint: objectConfig?.endpoint?.trim() || readRuntimeEnv("DOCS_TELEMETRY_ENDPOINT") || DEFAULT_DOCS_TELEMETRY_ENDPOINT
46
+ };
47
+ }
48
+ function readRequestOrigin(request) {
49
+ if (!request?.url) return void 0;
50
+ try {
51
+ return new URL(request.url).origin;
52
+ } catch {
53
+ return;
54
+ }
55
+ }
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;
61
+ try {
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;
66
+ } catch {
67
+ return;
68
+ }
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
+ }
92
+ function readDeploymentOrigin() {
93
+ const candidates = [
94
+ readRuntimeEnv("DOCS_SITE_URL"),
95
+ readRuntimeEnv("NEXT_PUBLIC_BASE_URL"),
96
+ readRuntimeEnv("NEXT_PUBLIC_SITE_URL"),
97
+ readRuntimeEnv("SITE_URL"),
98
+ readRuntimeEnv("URL"),
99
+ readRuntimeEnv("CF_PAGES_URL"),
100
+ readRuntimeEnv("VERCEL_PROJECT_PRODUCTION_URL"),
101
+ readRuntimeEnv("VERCEL_URL"),
102
+ readRuntimeEnv("DEPLOY_PRIME_URL")
103
+ ];
104
+ for (const candidate of candidates) {
105
+ const origin = normalizeDocsTelemetryOrigin(candidate);
106
+ if (origin) return origin;
107
+ }
108
+ }
109
+ function detectDeployment() {
110
+ const env = getRuntimeEnv();
111
+ if (!env) return void 0;
112
+ if (env.VERCEL || env.VERCEL_ENV) return {
113
+ provider: "vercel",
114
+ environment: env.VERCEL_ENV,
115
+ id: env.VERCEL_DEPLOYMENT_ID ?? env.VERCEL_GIT_COMMIT_SHA,
116
+ region: env.VERCEL_REGION
117
+ };
118
+ if (env.NETLIFY) return {
119
+ provider: "netlify",
120
+ environment: env.CONTEXT,
121
+ id: env.DEPLOY_ID ?? env.COMMIT_REF
122
+ };
123
+ if (env.CF_PAGES) return {
124
+ provider: "cloudflare-pages",
125
+ environment: env.CF_PAGES_BRANCH,
126
+ id: env.CF_PAGES_COMMIT_SHA
127
+ };
128
+ if (env.RENDER_SERVICE_ID) return {
129
+ provider: "render",
130
+ environment: env.RENDER_ENV,
131
+ id: env.RENDER_SERVICE_ID
132
+ };
133
+ if (env.FLY_APP_NAME) return {
134
+ provider: "fly",
135
+ environment: env.FLY_APP_NAME,
136
+ id: env.FLY_ALLOC_ID,
137
+ region: env.FLY_REGION
138
+ };
139
+ if (env.RAILWAY_ENVIRONMENT) return {
140
+ provider: "railway",
141
+ environment: env.RAILWAY_ENVIRONMENT,
142
+ id: env.RAILWAY_DEPLOYMENT_ID
143
+ };
144
+ return env.NODE_ENV === "production" ? { environment: "production" } : void 0;
145
+ }
146
+ function detectRuntime() {
147
+ if (typeof process !== "undefined" && process.versions?.node) return {
148
+ name: "node",
149
+ version: process.versions.node
150
+ };
151
+ if (typeof navigator !== "undefined" && navigator.userAgent) return { name: "web-standard" };
152
+ }
153
+ function isObjectConfigEnabled(value, defaultEnabled) {
154
+ if (value === false) return false;
155
+ if (value === true) return true;
156
+ if (value && typeof value === "object" && !Array.isArray(value)) {
157
+ const enabled = value.enabled;
158
+ return enabled === false ? false : defaultEnabled || enabled === true;
159
+ }
160
+ return defaultEnabled;
161
+ }
162
+ function hasObjectConfig(value) {
163
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
164
+ }
165
+ function getDocsTelemetryFeatures(config) {
166
+ const pageActions = config.pageActions;
167
+ const feedback = config.feedback;
168
+ return {
169
+ search: isObjectConfigEnabled(config.search, true),
170
+ contentChanges: resolveDocsContentChangesConfig(config.agent?.contentChanges, { staticExport: config.staticExport === true }).enabled,
171
+ ai: isObjectConfigEnabled(config.ai, false),
172
+ mcp: isObjectConfigEnabled(config.mcp, true),
173
+ llmsTxt: isObjectConfigEnabled(config.llmsTxt, true),
174
+ pageActions: hasObjectConfig(pageActions),
175
+ feedback: feedback === true || hasObjectConfig(feedback) && feedback.enabled !== false,
176
+ agentFeedback: feedback !== false && !(hasObjectConfig(feedback) && feedback.agent === false) && !(hasObjectConfig(feedback) && hasObjectConfig(feedback.agent) && feedback.agent.enabled === false),
177
+ sitemap: isObjectConfigEnabled(config.sitemap, true),
178
+ robots: isObjectConfigEnabled(config.robots, true),
179
+ apiReference: isObjectConfigEnabled(config.apiReference, false),
180
+ staticExport: config.staticExport === true,
181
+ changelog: isObjectConfigEnabled(config.changelog, false),
182
+ cloud: typeof config.cloud !== "undefined" && isObjectConfigEnabled(config.cloud, true),
183
+ review: isObjectConfigEnabled(config.review, true),
184
+ codeBlocksValidate: hasObjectConfig(config.codeBlocks) && Boolean(config.codeBlocks.validate)
185
+ };
186
+ }
187
+ function createDocsTelemetryEvent(config, input, context = {}) {
188
+ const telemetryConfig = config.telemetry && typeof config.telemetry === "object" ? config.telemetry : void 0;
189
+ const siteOriginCandidates = [
190
+ context.siteOrigin,
191
+ input.site?.origin,
192
+ telemetryConfig?.siteOrigin,
193
+ readRequestOrigin(context.request),
194
+ readDeploymentOrigin()
195
+ ];
196
+ if (siteOriginCandidates.some(isBlockedDocsTelemetryOrigin)) return void 0;
197
+ const siteOrigin = siteOriginCandidates.map(normalizeDocsTelemetryOrigin).find((origin) => Boolean(origin));
198
+ const deployment = input.deployment ?? detectDeployment();
199
+ const properties = context.properties || input.properties ? {
200
+ ...input.properties,
201
+ ...context.properties
202
+ } : void 0;
203
+ return {
204
+ ...input,
205
+ timestamp: input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
206
+ package: {
207
+ name: DOCS_PACKAGE_NAME,
208
+ version: DOCS_PACKAGE_VERSION,
209
+ ...input.package
210
+ },
211
+ framework: input.framework ?? context.framework,
212
+ runtime: input.runtime ?? detectRuntime(),
213
+ site: siteOrigin ? { origin: siteOrigin } : input.site,
214
+ deployment,
215
+ features: input.features ?? getDocsTelemetryFeatures(config),
216
+ properties
217
+ };
218
+ }
219
+ function projectEventKey(event) {
220
+ return [
221
+ event.package.name,
222
+ event.package.version,
223
+ event.framework ?? "",
224
+ event.site?.origin ?? "",
225
+ event.deployment?.provider ?? "",
226
+ event.deployment?.environment ?? "",
227
+ event.deployment?.id ?? ""
228
+ ].join("|");
229
+ }
230
+ function getSentProjectKeys() {
231
+ const globalValue = globalThis;
232
+ globalValue.__farmingLabsDocsTelemetryProjectKeys__ ??= /* @__PURE__ */ new Map();
233
+ return globalValue.__farmingLabsDocsTelemetryProjectKeys__;
234
+ }
235
+ function pruneSentProjectKeys(sent, now) {
236
+ for (const [key, expiresAt] of sent) if (expiresAt <= now) sent.delete(key);
237
+ while (sent.size >= PROJECT_TELEMETRY_CACHE_MAX_KEYS) {
238
+ const oldestKey = sent.keys().next().value;
239
+ if (!oldestKey) return;
240
+ sent.delete(oldestKey);
241
+ }
242
+ }
243
+ async function emitDocsTelemetryEvent(telemetry, event) {
244
+ const resolved = resolveDocsTelemetryConfig(telemetry);
245
+ const eventSiteOrigin = event.site?.origin;
246
+ const normalizedSiteOrigin = normalizeDocsTelemetryOrigin(eventSiteOrigin);
247
+ if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function" || eventSiteOrigin !== void 0 && (!normalizedSiteOrigin || isLocalDocsTelemetryOrigin(eventSiteOrigin))) return;
248
+ const eventToSend = normalizedSiteOrigin ? {
249
+ ...event,
250
+ site: { origin: normalizedSiteOrigin }
251
+ } : event;
252
+ try {
253
+ const ingestKey = readRuntimeEnv("DOCS_TELEMETRY_INGEST_KEY");
254
+ const headers = { "content-type": "application/json" };
255
+ if (ingestKey) headers["x-docs-telemetry-key"] = ingestKey;
256
+ await fetch(resolved.endpoint, {
257
+ method: "POST",
258
+ headers,
259
+ body: JSON.stringify({ event: eventToSend }),
260
+ keepalive: true
261
+ });
262
+ } catch {}
263
+ }
264
+ function emitDocsTelemetryProjectEvent(config, context = {}) {
265
+ const event = createDocsTelemetryEvent(config, { type: "project_detected" }, context);
266
+ if (!event) return;
267
+ const key = projectEventKey(event);
268
+ const sent = getSentProjectKeys();
269
+ const now = Date.now();
270
+ const expiresAt = sent.get(key);
271
+ if (expiresAt && expiresAt > now) return;
272
+ if (typeof expiresAt === "number") sent.delete(key);
273
+ pruneSentProjectKeys(sent, now);
274
+ sent.set(key, now + PROJECT_TELEMETRY_CACHE_TTL_MS);
275
+ emitDocsTelemetryEvent(config.telemetry, event);
276
+ }
277
+ function emitDocsTelemetryAgentSurfaceEvent(config, context) {
278
+ const event = createDocsTelemetryEvent(config, {
279
+ type: context.surface === "mcp" ? "mcp_request" : "agent_surface_used",
280
+ properties: { surface: context.surface }
281
+ }, context);
282
+ if (!event) return;
283
+ emitDocsTelemetryEvent(config.telemetry, event);
284
+ }
285
+ function emitDocsTelemetryMcpToolEvent(config, context) {
286
+ const event = createDocsTelemetryEvent(config, {
287
+ type: "mcp_tool_used",
288
+ properties: {
289
+ tool: context.tool,
290
+ locale: context.locale,
291
+ resultCount: context.resultCount
292
+ }
293
+ }, context);
294
+ if (!event) return;
295
+ emitDocsTelemetryEvent(config.telemetry, event);
296
+ }
297
+ function inferDocsTelemetryAgentSurface(request, options) {
298
+ const url = new URL(request.url);
299
+ const method = request.method.toUpperCase();
300
+ const feedbackRequest = resolveDocsAgentFeedbackRequest(url, resolveDocsAgentFeedbackConfig(options.feedback));
301
+ if ((method === "GET" || method === "HEAD") && isDocsAgentDiscoveryRequest(url)) return "agent_spec";
302
+ if ((method === "GET" || method === "HEAD") && feedbackRequest?.kind === "schema") return "agent_feedback_schema";
303
+ if (method === "POST" && feedbackRequest?.kind === "submit") return "agent_feedback_submit";
304
+ if (method === "GET" || method === "HEAD") {
305
+ if (isDocsContentChangesRequest(url)) return "content_changes";
306
+ if (isDocsAgentsRequest(url) || resolveDocsAgentsFormat(url) === "agents") return "agents";
307
+ if (isDocsSkillRequest(url) || resolveDocsSkillFormat(url) === "skill") return "skill";
308
+ if (resolveDocsMarkdownRequest(options.entry, url, request)) return "markdown";
309
+ if (resolveDocsLlmsTxtRequest(url, options.llmsTxt, options.entry)) return "llms";
310
+ }
311
+ if (method === "POST") return "ask_ai";
312
+ }
313
+
314
+ //#endregion
315
+ //#region src/sidebar.ts
316
+ function resolvePageSidebarFolderIndexBehavior(sidebar) {
317
+ if (!sidebar || typeof sidebar !== "object") return void 0;
318
+ const value = sidebar.folderIndexBehavior;
319
+ return value === "link" || value === "toggle" || value === "hidden" ? value : void 0;
320
+ }
321
+ function normalizeSidebarFolderBehaviorPath(path) {
322
+ if (!path) return void 0;
323
+ let value = path.trim();
324
+ if (!value) return void 0;
325
+ if (/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(value)) try {
326
+ value = new URL(value).pathname;
327
+ } catch {
328
+ return;
329
+ }
330
+ else value = value.split("#", 1)[0]?.split("?", 1)[0] ?? value;
331
+ if (!value.startsWith("/")) value = `/${value}`;
332
+ return value.replace(/\/$/, "") || "/";
333
+ }
334
+ function resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior = "link") {
335
+ if (sidebar === void 0 || sidebar === true || sidebar === false) return defaultBehavior;
336
+ if (sidebar.folderIndexBehavior === "toggle") return "toggle";
337
+ if (sidebar.folderIndexBehavior === "hidden") return "hidden";
338
+ if (sidebar.folderIndexBehavior === "link") return "link";
339
+ return defaultBehavior;
340
+ }
341
+ function resolveSidebarFolderIndexBehaviorForPath(sidebar, folderPath, defaultBehavior = "link") {
342
+ const fallback = resolveSidebarFolderIndexBehavior(sidebar, defaultBehavior);
343
+ if (!sidebar || typeof sidebar !== "object") return fallback;
344
+ const normalizedPath = normalizeSidebarFolderBehaviorPath(folderPath);
345
+ if (!normalizedPath) return fallback;
346
+ for (const [rawPath, override] of Object.entries(sidebar.folderIndexBehaviorOverrides ?? {})) if (normalizeSidebarFolderBehaviorPath(rawPath) === normalizedPath) return override === "link" || override === "toggle" || override === "hidden" ? override : fallback;
347
+ return fallback;
348
+ }
349
+ function applySidebarFolderIndexBehavior(tree, behaviorOrOptions) {
350
+ const resolveBehavior = typeof behaviorOrOptions === "string" ? () => behaviorOrOptions : (folderPath) => resolveSidebarFolderIndexBehaviorForPath(behaviorOrOptions.sidebar, folderPath, behaviorOrOptions.defaultBehavior);
351
+ function mapNode(node) {
352
+ if (!node || typeof node !== "object") return node;
353
+ const candidate = node;
354
+ if (candidate.type !== "folder" || !Array.isArray(candidate.children)) return node;
355
+ const children = candidate.children.map(mapNode);
356
+ const index = candidate.index ? mapNode(candidate.index) : void 0;
357
+ const folderPath = (typeof candidate.url === "string" ? candidate.url : void 0) || (candidate.index && typeof candidate.index === "object" && "url" in candidate.index && typeof candidate.index.url === "string" ? candidate.index.url ?? void 0 : void 0);
358
+ const behavior = (candidate.folderIndexBehavior === "link" || candidate.folderIndexBehavior === "toggle" || candidate.folderIndexBehavior === "hidden" ? candidate.folderIndexBehavior : void 0) ?? resolveBehavior(folderPath);
359
+ if (behavior === "link") return {
360
+ ...candidate,
361
+ folderIndexBehavior: void 0,
362
+ index,
363
+ children
364
+ };
365
+ if (behavior === "hidden") return {
366
+ ...candidate,
367
+ folderIndexBehavior: void 0,
368
+ index: void 0,
369
+ url: void 0,
370
+ children
371
+ };
372
+ return {
373
+ ...candidate,
374
+ folderIndexBehavior: void 0,
375
+ index: void 0,
376
+ url: void 0,
377
+ children: index ? [index, ...children] : children
378
+ };
379
+ }
380
+ return {
381
+ ...tree,
382
+ children: tree.children.map(mapNode)
383
+ };
384
+ }
385
+
386
+ //#endregion
387
+ //#region src/agent-provenance.ts
388
+ const GENERATED_AGENT_PROVENANCE_MARKER = "@farming-labs/docs:generated";
389
+ const GENERATED_AGENT_PROVENANCE_VERSION = 1;
390
+ function normalizeLineEndings(value) {
391
+ return value.replace(/\r\n?/g, "\n").replace(/^\uFEFF/, "");
392
+ }
393
+ function normalizeGeneratedAgentContent(value) {
394
+ return normalizeLineEndings(value).trimEnd();
395
+ }
396
+ function hashGeneratedAgentContent(value) {
397
+ const normalized = normalizeGeneratedAgentContent(value);
398
+ const bytes = new TextEncoder().encode(normalized);
399
+ let hash = 14695981039346656037n;
400
+ for (const byte of bytes) {
401
+ hash ^= BigInt(byte);
402
+ hash = BigInt.asUintN(64, hash * 1099511628211n);
403
+ }
404
+ return `fnv1a64:${hash.toString(16).padStart(16, "0")}`;
405
+ }
406
+ function parseProvenanceBlock(rawBlock) {
407
+ const entries = /* @__PURE__ */ new Map();
408
+ for (const line of rawBlock.split("\n")) {
409
+ const trimmed = line.trim();
410
+ if (!trimmed) continue;
411
+ const separatorIndex = trimmed.indexOf("=");
412
+ if (separatorIndex <= 0) continue;
413
+ const key = trimmed.slice(0, separatorIndex).trim();
414
+ const value = trimmed.slice(separatorIndex + 1).trim();
415
+ if (!key || !value) continue;
416
+ entries.set(key, value);
417
+ }
418
+ const version = Number.parseInt(entries.get("version") ?? "", 10);
419
+ const sourceKind = entries.get("sourceKind");
420
+ const sourceHash = entries.get("sourceHash");
421
+ const settingsHash = entries.get("settingsHash");
422
+ const outputHash = entries.get("outputHash");
423
+ const generatedAt = entries.get("generatedAt");
424
+ if (!Number.isFinite(version) || sourceKind !== "resolved-page" && sourceKind !== "agent-md" || !sourceHash || !settingsHash || !outputHash || !generatedAt) return;
425
+ return {
426
+ version,
427
+ sourceKind,
428
+ sourceHash,
429
+ settingsHash,
430
+ outputHash,
431
+ generatedAt
432
+ };
433
+ }
434
+ function parseGeneratedAgentDocument(raw) {
435
+ const normalized = normalizeLineEndings(raw);
436
+ const headerPattern = new RegExp(`^<!-- ${GENERATED_AGENT_PROVENANCE_MARKER}\\n([\\s\\S]*?)\\n-->\\n?`);
437
+ const match = normalized.match(headerPattern);
438
+ if (!match) return { content: normalized };
439
+ return {
440
+ provenance: parseProvenanceBlock(match[1]),
441
+ content: normalized.slice(match[0].length)
442
+ };
443
+ }
444
+ function stripGeneratedAgentProvenance(raw) {
445
+ return parseGeneratedAgentDocument(raw).content;
446
+ }
447
+ function serializeGeneratedAgentDocument(content, provenance) {
448
+ const normalizedContent = normalizeGeneratedAgentContent(content);
449
+ return `${[
450
+ `<!-- ${GENERATED_AGENT_PROVENANCE_MARKER}`,
451
+ `version=${provenance.version}`,
452
+ `sourceKind=${provenance.sourceKind}`,
453
+ `sourceHash=${provenance.sourceHash}`,
454
+ `settingsHash=${provenance.settingsHash}`,
455
+ `outputHash=${provenance.outputHash}`,
456
+ `generatedAt=${provenance.generatedAt}`,
457
+ "-->",
458
+ normalizedContent
459
+ ].join("\n")}\n`;
460
+ }
461
+
462
+ //#endregion
463
+ export { inferDocsTelemetryAgentSurface as _, parseGeneratedAgentDocument as a, resolveDocsTelemetryConfig as b, applySidebarFolderIndexBehavior as c, resolveSidebarFolderIndexBehaviorForPath as d, emitDocsTelemetryAgentSurfaceEvent as f, getDocsTelemetryFeatures as g, emitDocsTelemetryProjectEvent as h, normalizeGeneratedAgentContent as i, resolvePageSidebarFolderIndexBehavior as l, emitDocsTelemetryMcpToolEvent as m, GENERATED_AGENT_PROVENANCE_VERSION as n, serializeGeneratedAgentDocument as o, emitDocsTelemetryEvent as p, hashGeneratedAgentContent as r, stripGeneratedAgentProvenance as s, GENERATED_AGENT_PROVENANCE_MARKER as t, resolveSidebarFolderIndexBehavior as u, isLocalDocsTelemetryOrigin as v, normalizeDocsTelemetryOrigin as y };
@@ -1,4 +1,4 @@
1
- import { L as DocsPublishedAgentSkill } from "./standards-discovery-DBI1PD7m.mjs";
1
+ import { z as DocsPublishedAgentSkill } from "./standards-discovery-BWyNgZSs.mjs";
2
2
 
3
3
  //#region src/agent-skills-bundle.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { f as DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, j as buildDocsPublishedAgentSkill } from "./standards-discovery-BwL5ffGx.mjs";
1
+ import { f as DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, j as buildDocsPublishedAgentSkill } from "./standards-discovery-BKlEnK_H.mjs";
2
2
  import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { createHash } from "node:crypto";
@@ -1,5 +1,5 @@
1
- import { $ as DocsAgentSkillsInput } from "./types-BDRwrExu.mjs";
2
- import { L as DocsPublishedAgentSkill } from "./standards-discovery-DBI1PD7m.mjs";
1
+ import { et as DocsAgentSkillsInput } from "./types-CpLnwHak.mjs";
2
+ import { z as DocsPublishedAgentSkill } from "./standards-discovery-BWyNgZSs.mjs";
3
3
 
4
4
  //#region src/agent-skills-server.d.ts
5
5
  interface ResolveConfiguredAgentSkillsOptions {
@@ -1,6 +1,6 @@
1
- import { $ as DocsAgentSkillsInput } from "./types-BDRwrExu.mjs";
2
- import { L as DocsPublishedAgentSkill } from "./standards-discovery-DBI1PD7m.mjs";
3
- import { t as ResolveConfiguredAgentSkillsOptions } from "./agent-skills-server-Cix64aGB.mjs";
1
+ import { et as DocsAgentSkillsInput } from "./types-CpLnwHak.mjs";
2
+ import { z as DocsPublishedAgentSkill } from "./standards-discovery-BWyNgZSs.mjs";
3
+ import { t as ResolveConfiguredAgentSkillsOptions } from "./agent-skills-server-zvs0Yknt.mjs";
4
4
 
5
5
  //#region src/agent-skills-vite.d.ts
6
6
  declare const DOCS_AGENT_SKILLS_BUNDLE_MODULE = "@farming-labs/docs/agent-skills-bundle";
@@ -1,5 +1,5 @@
1
- import "./standards-discovery-BwL5ffGx.mjs";
2
- import { t as resolveConfiguredAgentSkills } from "./agent-skills-server-noFn1l_p.mjs";
1
+ import "./standards-discovery-BKlEnK_H.mjs";
2
+ import { t as resolveConfiguredAgentSkills } from "./agent-skills-server-B2EXn2QD.mjs";
3
3
 
4
4
  //#region src/agent-skills-vite.ts
5
5
  const DOCS_AGENT_SKILLS_BUNDLE_MODULE = "@farming-labs/docs/agent-skills-bundle";
@@ -1,12 +1,12 @@
1
- import { a as DEFAULT_AGENT_MD_ROUTE, b as DEFAULT_OPENAPI_SCHEMA_ROUTE, lt as resolveDocsAgentFeedbackConfig, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, rt as renderDocsAgentsDocument, t as DEFAULT_AGENTS_MD_ROUTE } from "./agent-BHqaZx-X.mjs";
1
+ import { a as DEFAULT_AGENT_MD_ROUTE, lt as resolveDocsAgentFeedbackConfig, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, rt as renderDocsAgentsDocument, t as DEFAULT_AGENTS_MD_ROUTE } from "./agent-Ba94vwM2.mjs";
2
2
  import "./markdown-sections-7OoA7ylx.mjs";
3
- import "./standards-discovery-BwL5ffGx.mjs";
4
- import "./search-BmC8wVr0.mjs";
5
- import { S as resolveApiReferenceConfig } from "./sitemap-server-B9LZQ1FE.mjs";
6
- import "./agent-evals-21LZ_uEl.mjs";
3
+ import "./standards-discovery-BKlEnK_H.mjs";
4
+ import "./agent-provenance-D8UBpnMc.mjs";
5
+ import { C as resolveApiReferenceOpenApiDiscovery } from "./sitemap-server-Dgxs9V6S.mjs";
6
+ import "./agent-evals-C8dkgJMN.mjs";
7
7
  import { resolveDocsMcpConfig } from "./mcp.mjs";
8
8
  import "./code-blocks-DnNVNK2M.mjs";
9
- import "./agent-skills-server-noFn1l_p.mjs";
9
+ import "./agent-skills-server-B2EXn2QD.mjs";
10
10
  import "./server.mjs";
11
11
  import { a as loadDocsConfigModule, d as readNavTitle, g as resolveDocsConfigPath, h as readTopLevelStringProperty, l as readBooleanProperty, p as readStringProperty, t as extractNestedObjectLiteral } from "./config-Wcdj-D0a.mjs";
12
12
  import { t as detectFramework } from "./utils-DpiIioYb.mjs";
@@ -129,16 +129,7 @@ function writeIfNeeded(filePath, content, options) {
129
129
  return "changed";
130
130
  }
131
131
  function resolveOpenApiDiscovery(config) {
132
- const apiReference = resolveApiReferenceConfig(config?.apiReference);
133
- if (!apiReference.enabled) return { enabled: false };
134
- return {
135
- enabled: true,
136
- url: DEFAULT_OPENAPI_SCHEMA_ROUTE,
137
- urlSource: "default",
138
- source: apiReference.specUrl ? "configured" : "generated",
139
- specUrl: apiReference.specUrl,
140
- apiReferencePath: `/${apiReference.path}`
141
- };
132
+ return resolveApiReferenceOpenApiDiscovery(config?.apiReference);
142
133
  }
143
134
  async function generateAgents(options = {}) {
144
135
  const rootDir = process.cwd();
@@ -111,7 +111,7 @@ async function main() {
111
111
  const { init } = await import("../init-DAkI0Lkf.mjs");
112
112
  await init(initOptions);
113
113
  } else if (parsedCommand.command === "dev") {
114
- const { dev } = await import("../dev-Cc1cFFj-.mjs");
114
+ const { dev } = await import("../dev-kjaxOOla.mjs");
115
115
  await dev(devOptions);
116
116
  } else if (parsedCommand.command === "deploy") {
117
117
  const { runCloudDeploy } = await import("../cloud-pdNC-tyj.mjs");
@@ -141,10 +141,10 @@ async function main() {
141
141
  printCloudHelp();
142
142
  process.exit(1);
143
143
  } else if (parsedCommand.command === "mcp") {
144
- const { runMcp } = await import("../mcp-Bnqfu8P5.mjs");
144
+ const { runMcp } = await import("../mcp-DT-WNsA-.mjs");
145
145
  await runMcp(mcpOptions);
146
146
  } else if (parsedCommand.command === "agent" && subcommand === "compact") {
147
- const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-DxTa3PLB.mjs").then((n) => n.t);
147
+ const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-CM-hzhfh.mjs").then((n) => n.t);
148
148
  const agentCompactOptions = parseAgentCompactArgs(args.slice(2));
149
149
  if (agentCompactOptions.help) {
150
150
  printAgentCompactHelp();
@@ -152,7 +152,7 @@ async function main() {
152
152
  }
153
153
  await compactAgentDocs(agentCompactOptions);
154
154
  } else if (parsedCommand.command === "agent" && subcommand === "export") {
155
- const { exportAgentBundle, parseAgentExportArgs, printAgentExportHelp } = await import("../agent-export-3VheegEK.mjs");
155
+ const { exportAgentBundle, parseAgentExportArgs, printAgentExportHelp } = await import("../agent-export-DdF-IVfg.mjs");
156
156
  const agentExportOptions = parseAgentExportArgs(args.slice(2));
157
157
  if (agentExportOptions.help) {
158
158
  printAgentExportHelp();
@@ -162,13 +162,13 @@ async function main() {
162
162
  } else if (parsedCommand.command === "agent") {
163
163
  console.error(pc.red(`Unknown agent subcommand: ${subcommand ?? "(missing)"}`));
164
164
  console.error();
165
- const { printAgentCompactHelp } = await import("../agent-DxTa3PLB.mjs").then((n) => n.t);
166
- const { printAgentExportHelp } = await import("../agent-export-3VheegEK.mjs");
165
+ const { printAgentCompactHelp } = await import("../agent-CM-hzhfh.mjs").then((n) => n.t);
166
+ const { printAgentExportHelp } = await import("../agent-export-DdF-IVfg.mjs");
167
167
  printAgentCompactHelp();
168
168
  printAgentExportHelp();
169
169
  process.exit(1);
170
170
  } else if (parsedCommand.command === "agents" && subcommand === "generate") {
171
- const { generateAgents, parseAgentsGenerateArgs, printAgentsGenerateHelp } = await import("../agents-ByTdP0Hl.mjs");
171
+ const { generateAgents, parseAgentsGenerateArgs, printAgentsGenerateHelp } = await import("../agents-v0Em2KZo.mjs");
172
172
  const agentsOptions = parseAgentsGenerateArgs(args.slice(2));
173
173
  if (agentsOptions.help) {
174
174
  printAgentsGenerateHelp();
@@ -178,11 +178,11 @@ async function main() {
178
178
  } else if (parsedCommand.command === "agents") {
179
179
  console.error(pc.red(`Unknown agents subcommand: ${subcommand ?? "(missing)"}`));
180
180
  console.error();
181
- const { printAgentsGenerateHelp } = await import("../agents-ByTdP0Hl.mjs");
181
+ const { printAgentsGenerateHelp } = await import("../agents-v0Em2KZo.mjs");
182
182
  printAgentsGenerateHelp();
183
183
  process.exit(1);
184
184
  } else if (parsedCommand.command === "doctor") {
185
- const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-C34VVF85.mjs");
185
+ const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-BbrN0rdC.mjs");
186
186
  const doctorOptions = parseDoctorArgs(args.slice(1));
187
187
  if (doctorOptions.help) {
188
188
  printDoctorHelp();
@@ -190,7 +190,7 @@ async function main() {
190
190
  }
191
191
  await runDoctor(doctorOptions);
192
192
  } else if (parsedCommand.command === "review") {
193
- const { parseReviewArgs, printReviewHelp, runReview } = await import("../review-Dw6oCQX3.mjs");
193
+ const { parseReviewArgs, printReviewHelp, runReview } = await import("../review-DrCaaT7G.mjs");
194
194
  const reviewOptions = parseReviewArgs(args.slice(1));
195
195
  if (reviewOptions.help) {
196
196
  printReviewHelp();
@@ -212,7 +212,7 @@ async function main() {
212
212
  printCodeBlocksValidateHelp();
213
213
  process.exit(1);
214
214
  } else if (parsedCommand.command === "search" && subcommand === "sync") {
215
- const { syncSearch } = await import("../search-DBdmbUkc.mjs");
215
+ const { syncSearch } = await import("../search-YiZMZDfb.mjs");
216
216
  await syncSearch(searchSyncOptions);
217
217
  } else if (parsedCommand.command === "search") {
218
218
  console.error(pc.red(`Unknown search subcommand: ${subcommand ?? "(missing)"}`));
@@ -220,7 +220,7 @@ async function main() {
220
220
  printHelp();
221
221
  process.exit(1);
222
222
  } else if (parsedCommand.command === "sitemap" && subcommand === "generate") {
223
- const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-CrzG5Wpf.mjs");
223
+ const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-NO8UMO6Y.mjs");
224
224
  const sitemapOptions = parseSitemapGenerateArgs(args.slice(2));
225
225
  if (sitemapOptions.help) {
226
226
  printSitemapGenerateHelp();
@@ -230,11 +230,11 @@ async function main() {
230
230
  } else if (parsedCommand.command === "sitemap") {
231
231
  console.error(pc.red(`Unknown sitemap subcommand: ${subcommand ?? "(missing)"}`));
232
232
  console.error();
233
- const { printSitemapGenerateHelp } = await import("../sitemap-CrzG5Wpf.mjs");
233
+ const { printSitemapGenerateHelp } = await import("../sitemap-NO8UMO6Y.mjs");
234
234
  printSitemapGenerateHelp();
235
235
  process.exit(1);
236
236
  } else if (parsedCommand.command === "robots" && subcommand === "generate") {
237
- const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-KWLujSLI.mjs");
237
+ const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-izJbM9cv.mjs");
238
238
  const robotsOptions = parseRobotsGenerateArgs(args.slice(2));
239
239
  if (robotsOptions.help) {
240
240
  printRobotsGenerateHelp();
@@ -244,7 +244,7 @@ async function main() {
244
244
  } else if (parsedCommand.command === "robots") {
245
245
  console.error(pc.red(`Unknown robots subcommand: ${subcommand ?? "(missing)"}`));
246
246
  console.error();
247
- const { printRobotsGenerateHelp } = await import("../robots-KWLujSLI.mjs");
247
+ const { printRobotsGenerateHelp } = await import("../robots-izJbM9cv.mjs");
248
248
  printRobotsGenerateHelp();
249
249
  process.exit(1);
250
250
  } else if (parsedCommand.command === "downgrade") {
@@ -1,4 +1,4 @@
1
- import { rt as DocsAnalyticsConfig } from "../types-BDRwrExu.mjs";
1
+ import { it as DocsAnalyticsConfig } from "../types-CpLnwHak.mjs";
2
2
  import { ReactNode } from "react";
3
3
 
4
4
  //#region src/docs-cloud-client.d.ts
@@ -1,4 +1,4 @@
1
- import { _t as DocsCloudConfig, rt as DocsAnalyticsConfig, t as AIConfig } from "./types-BDRwrExu.mjs";
1
+ import { it as DocsAnalyticsConfig, t as AIConfig, vt as DocsCloudConfig } from "./types-CpLnwHak.mjs";
2
2
 
3
3
  //#region src/cloud-ask-ai.d.ts
4
4
  interface DocsCloudAskAIConfig {