@farming-labs/svelte 0.2.146 → 0.2.147

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/content.d.ts CHANGED
@@ -30,6 +30,8 @@ export interface ContentPage {
30
30
  slug: string;
31
31
  url: string;
32
32
  title: string;
33
+ /** `"agent"` pages are left out of navigation, human search, and HTML routes. */
34
+ audience?: "agent";
33
35
  description?: string;
34
36
  related?: ResolvedDocsRelatedLink[];
35
37
  agent?: PageAgentFrontmatter;
package/dist/content.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import fs from "node:fs";
9
9
  import path from "node:path";
10
10
  import matter from "gray-matter";
11
- import { normalizeDocsRelated, normalizePageAgentFrontmatter, normalizeDocsOkfTrustMetadataInput, resolveDocsAudienceMdxContent, resolvePageSidebarFolderIndexBehavior, } from "@farming-labs/docs";
11
+ import { normalizeDocsRelated, normalizePageAgentFrontmatter, normalizeDocsOkfTrustMetadataInput, resolveDocsAudienceMdxContent, resolveDocsPageAudience, resolvePageSidebarFolderIndexBehavior, } from "@farming-labs/docs";
12
12
  export function normalizeDocsFrontmatterLastmod(value) {
13
13
  if (typeof value === "string")
14
14
  return value;
@@ -57,6 +57,7 @@ export function loadDocsContent(contentDir, entry = "docs") {
57
57
  slug,
58
58
  url,
59
59
  title,
60
+ ...(resolveDocsPageAudience(data.audience) ? { audience: "agent" } : {}),
60
61
  description: data.description,
61
62
  ...(related.length > 0 ? { related } : {}),
62
63
  agent: normalizePageAgentFrontmatter(data.agent),
@@ -106,8 +107,10 @@ export function loadDocsNavTree(contentDir, entry = "docs", ordering) {
106
107
  const absDir = path.resolve(contentDir);
107
108
  const children = [];
108
109
  const indexPath = findIndex(absDir);
109
- if (indexPath) {
110
- const { data } = matter(fs.readFileSync(indexPath, "utf-8"));
110
+ const rootData = indexPath ? matter(fs.readFileSync(indexPath, "utf-8")).data : undefined;
111
+ // An agent-only root page has no human projection, so it has no sidebar entry.
112
+ if (rootData && !resolveDocsPageAudience(rootData.audience)) {
113
+ const data = rootData;
111
114
  children.push({
112
115
  type: "page",
113
116
  name: data.title ?? "Documentation",
@@ -135,6 +138,11 @@ function buildNavNode(dir, name, slugParts, entry, ordering, childSlugOrder) {
135
138
  const p = path.join(full, n);
136
139
  return fs.statSync(p).isDirectory() && findIndex(p) !== null;
137
140
  });
141
+ // An agent-only page has no human projection: keep visible children under a plain folder.
142
+ if (resolveDocsPageAudience(data.audience)) {
143
+ const children = childDirs.length > 0 ? scanDir(full, slug, entry, ordering, childSlugOrder) : [];
144
+ return children.length > 0 ? { type: "folder", name: displayName, icon, children } : null;
145
+ }
138
146
  if (childDirs.length > 0) {
139
147
  return {
140
148
  type: "folder",
package/dist/server.js CHANGED
@@ -31,7 +31,7 @@ import * as DocsRuntime from "@farming-labs/docs/runtime";
31
31
  import fs from "node:fs";
32
32
  import path from "node:path";
33
33
  import matter from "gray-matter";
34
- import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsSearchFacets, buildDocsAgentDiscoverySpec, compactDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsCacheableResponse, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, formatDocsLastModifiedDate, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsContentChangesRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, normalizeDocsOkfTrustMetadataInput, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsContentChangesConfig, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsPublishedAgentSkill, resolveDocsStandardsDiscoveryRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, withDocsOpenApiOperationCounts, } from "@farming-labs/docs";
34
+ import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsSearchFacets, buildDocsAgentDiscoverySpec, compactDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsCacheableResponse, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, formatDocsLastModifiedDate, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsContentChangesRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, normalizeDocsOkfTrustMetadataInput, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsContentChangesConfig, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsPublishedAgentSkill, resolveDocsStandardsDiscoveryRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, withDocsOpenApiOperationCounts, resolveDocsPageAudience, } from "@farming-labs/docs";
35
35
  import { buildApiReferenceOpenApiDocumentAsync, buildApiReferenceOperationPagesAsync, createApiReferenceOperationMarkdownResponse, createDocsCloudAskAIResponse, createDocsMcpHttpHandler, createDocsRootRouter, isDocsCloudAskAIProvider, readDocsSitemapManifest, resolveApiReferenceConfig, resolveApiReferenceOpenApiDiscovery, resolveDocsMcpConfig, resolveConfiguredAgentSkills, serializeDocsIconRegistry, serializeOpenDocsProviders, readDocsAppVersion, resolveDocsRoots, withVaryReferer, } from "@farming-labs/docs/server";
36
36
  import { loadDocsNavTree, loadDocsContent, flattenNavTree, normalizeDocsFrontmatterLastmod, } from "./content.js";
37
37
  import { renderMarkdown } from "./markdown.js";
@@ -186,6 +186,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
186
186
  icon: data.icon,
187
187
  folderIndexBehavior: resolvePageSidebarFolderIndexBehavior(data.sidebar),
188
188
  order: typeof data.order === "number" ? data.order : Infinity,
189
+ agentOnly: resolveDocsPageAudience(data.audience) !== undefined,
189
190
  });
190
191
  }
191
192
  // Default sort: depth first, then by ordering strategy
@@ -213,7 +214,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
213
214
  }
214
215
  const children = [];
215
216
  const rootInfo = dirs.find((d) => d.parts.length === 0);
216
- if (rootInfo) {
217
+ if (rootInfo && !rootInfo.agentOnly) {
217
218
  children.push({
218
219
  type: "page",
219
220
  name: rootInfo.title,
@@ -243,6 +244,29 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
243
244
  }
244
245
  return items;
245
246
  }
247
+ // An agent-only page has no human projection: its folder keeps visible children without a link.
248
+ function toNavNodes(child) {
249
+ const hasGrandChildren = parentsWithDescendants.has(JSON.stringify(child.parts));
250
+ if (child.agentOnly) {
251
+ const folderChildren = hasGrandChildren ? buildLevel(child.parts) : [];
252
+ return folderChildren.length > 0
253
+ ? [{ type: "folder", name: child.title, icon: child.icon, children: folderChildren }]
254
+ : [];
255
+ }
256
+ if (hasGrandChildren) {
257
+ return [
258
+ {
259
+ type: "folder",
260
+ name: child.title,
261
+ icon: child.icon,
262
+ index: { type: "page", name: child.title, url: child.url, icon: child.icon },
263
+ folderIndexBehavior: child.folderIndexBehavior,
264
+ children: buildLevel(child.parts),
265
+ },
266
+ ];
267
+ }
268
+ return [{ type: "page", name: child.title, url: child.url, icon: child.icon }];
269
+ }
246
270
  function buildLevel(parentParts) {
247
271
  const depth = parentParts.length;
248
272
  const directChildren = [...(childrenByParent.get(JSON.stringify(parentParts)) ?? [])];
@@ -266,24 +290,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
266
290
  if (!slugMap.has(child.parts[depth]))
267
291
  ordered.push(child);
268
292
  }
269
- const nodes = [];
270
- for (const child of ordered) {
271
- const hasGrandChildren = parentsWithDescendants.has(JSON.stringify(child.parts));
272
- if (hasGrandChildren) {
273
- nodes.push({
274
- type: "folder",
275
- name: child.title,
276
- icon: child.icon,
277
- index: { type: "page", name: child.title, url: child.url, icon: child.icon },
278
- folderIndexBehavior: child.folderIndexBehavior,
279
- children: buildLevel(child.parts),
280
- });
281
- }
282
- else {
283
- nodes.push({ type: "page", name: child.title, url: child.url, icon: child.icon });
284
- }
285
- }
286
- return nodes;
293
+ return ordered.flatMap((child) => toNavNodes(child));
287
294
  }
288
295
  if (ordering === "numeric") {
289
296
  directChildren.sort((a, b) => {
@@ -292,34 +299,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
292
299
  return a.order - b.order;
293
300
  });
294
301
  }
295
- const nodes = [];
296
- for (const child of directChildren) {
297
- const hasGrandChildren = parentsWithDescendants.has(JSON.stringify(child.parts));
298
- if (hasGrandChildren) {
299
- nodes.push({
300
- type: "folder",
301
- name: child.title,
302
- icon: child.icon,
303
- index: {
304
- type: "page",
305
- name: child.title,
306
- url: child.url,
307
- icon: child.icon,
308
- },
309
- folderIndexBehavior: child.folderIndexBehavior,
310
- children: buildLevel(child.parts),
311
- });
312
- }
313
- else {
314
- nodes.push({
315
- type: "page",
316
- name: child.title,
317
- url: child.url,
318
- icon: child.icon,
319
- });
320
- }
321
- }
322
- return nodes;
302
+ return directChildren.flatMap((child) => toNavNodes(child));
323
303
  }
324
304
  children.push(...buildLevel([]));
325
305
  return { name: "Docs", children };
@@ -351,6 +331,7 @@ function searchIndexFromMap(contentMap, dirPrefix, entry, locale, sitemapManifes
351
331
  slug,
352
332
  url,
353
333
  title,
334
+ ...(resolveDocsPageAudience(data.audience) ? { audience: "agent" } : {}),
354
335
  description: data.description,
355
336
  ...(related.length > 0 ? { related } : {}),
356
337
  agent: normalizePageAgentFrontmatter(data.agent),
@@ -612,6 +593,12 @@ function createDocsRootServer(config) {
612
593
  lastModified = formatDocsLastModifiedDate(stat.mtime);
613
594
  }
614
595
  const { data, content } = matter(raw);
596
+ // Agent-only pages have no HTML page; agents read them at `{page}.md`.
597
+ if (resolveDocsPageAudience(data.audience)) {
598
+ const error = new Error(`Page not found: /${entry}/${slug}`);
599
+ error.status = 404;
600
+ throw error;
601
+ }
615
602
  const humanRawContent = resolveDocsAudienceMdxContent(content, "human");
616
603
  const readingTime = resolvePageReadingTime(data, humanRawContent, {
617
604
  enabledByDefault: readingTimeOptions.enabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte",
3
- "version": "0.2.146",
3
+ "version": "0.2.147",
4
4
  "description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
5
5
  "keywords": [
6
6
  "docs",
@@ -9,6 +9,11 @@
9
9
  "sveltekit"
10
10
  ],
11
11
  "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/farming-labs/docs.git",
15
+ "directory": "packages/svelte"
16
+ },
12
17
  "author": "Farming Labs",
13
18
  "files": [
14
19
  "dist"
@@ -57,7 +62,7 @@
57
62
  "@types/node": "^22.10.0",
58
63
  "typescript": "^5.9.3",
59
64
  "vitest": "^4.1.8",
60
- "@farming-labs/docs": "0.2.146"
65
+ "@farming-labs/docs": "0.2.147"
61
66
  },
62
67
  "peerDependencies": {
63
68
  "@farming-labs/docs": ">=0.2.73 || ^0.2.133-perf.0"