@farming-labs/docs 0.1.49 → 0.1.50

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.
@@ -5,6 +5,7 @@ import "./api-reference-y7cqtq4w.mjs";
5
5
  import { createFilesystemDocsMcpSource } from "./mcp.mjs";
6
6
  import "./server.mjs";
7
7
  import { a as loadProjectEnv, c as readNavTitle, d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, l as readNumberProperty, o as readBooleanProperty, p as resolveDocsContentDir, s as readEnvReferenceProperty, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-C7sUsMkm.mjs";
8
+ import matter from "gray-matter";
8
9
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
9
10
  import path from "node:path";
10
11
  import pc from "picocolors";
@@ -212,6 +213,14 @@ function mergeAgentCompactOptions(defaults, overrides) {
212
213
  ...Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== void 0))
213
214
  };
214
215
  }
216
+ function normalizeTokenBudget(value) {
217
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
218
+ return Math.max(1, Math.ceil(value));
219
+ }
220
+ function readPageTokenBudget(pagePath) {
221
+ const { data } = matter(readFileSync(pagePath, "utf-8"));
222
+ return normalizeTokenBudget(data.agent?.tokenBudget);
223
+ }
215
224
  function protectForCompression(input) {
216
225
  const segments = [];
217
226
  const stash = (value) => {
@@ -316,7 +325,10 @@ async function compactAgentDocs(options = {}) {
316
325
  let created = 0;
317
326
  let overwritten = 0;
318
327
  for (const { page, target } of selectedPages) {
319
- const compressed = await compressDocument(renderDocsMarkdownDocument(page), resolvedOptions);
328
+ const sourceDocument = renderDocsMarkdownDocument(page);
329
+ const pageOptions = mergeAgentCompactOptions(resolvedOptions, { maxOutputTokens: readPageTokenBudget(target.pagePath) });
330
+ if (pageOptions.minOutputTokens !== void 0 && pageOptions.maxOutputTokens !== void 0 && pageOptions.minOutputTokens > pageOptions.maxOutputTokens) pageOptions.minOutputTokens = pageOptions.maxOutputTokens;
331
+ const compressed = await compressDocument(sourceDocument, pageOptions);
320
332
  const nextContent = compressed.output.trimEnd();
321
333
  console.log(pc.dim(`Compacting ${page.url} (${compressed.original_input_tokens ?? "?"} -> ${compressed.output_tokens ?? "?"} tokens)...`));
322
334
  if (resolvedOptions.dryRun) continue;
@@ -341,6 +353,9 @@ ${pc.dim("Examples:")}
341
353
  ${pc.cyan("npx @farming-labs/docs@latest agent compact --page installation --page configuration")}
342
354
  ${pc.cyan("npx @farming-labs/docs@latest agent compact --all")}
343
355
 
356
+ ${pc.dim("Per-page override:")}
357
+ Add ${pc.cyan("agent.tokenBudget")} to a page frontmatter block to override the compact output target for that page.
358
+
344
359
  ${pc.dim("Options:")}
345
360
  ${pc.cyan("--all")} Compact every folder-based docs page under the configured contentDir
346
361
  ${pc.cyan("--page <slug|path>")} Add a page explicitly (repeatable); positional page args work too
@@ -75,7 +75,7 @@ async function main() {
75
75
  const { runMcp } = await import("../mcp-CYpMeMfi.mjs");
76
76
  await runMcp(mcpOptions);
77
77
  } else if (parsedCommand.command === "agent" && subcommand === "compact") {
78
- const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-D6Fa41gs.mjs");
78
+ const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-CuYI2Nji.mjs");
79
79
  const agentCompactOptions = parseAgentCompactArgs(args.slice(2));
80
80
  if (agentCompactOptions.help) {
81
81
  printAgentCompactHelp();
@@ -85,7 +85,7 @@ async function main() {
85
85
  } else if (parsedCommand.command === "agent") {
86
86
  console.error(pc.red(`Unknown agent subcommand: ${subcommand ?? "(missing)"}`));
87
87
  console.error();
88
- const { printAgentCompactHelp } = await import("../agent-D6Fa41gs.mjs");
88
+ const { printAgentCompactHelp } = await import("../agent-CuYI2Nji.mjs");
89
89
  printAgentCompactHelp();
90
90
  process.exit(1);
91
91
  } else if (parsedCommand.command === "doctor") {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as SidebarConfig, A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, F as FeedbackConfig, G as OrderingItem, H as OpenDocsConfig, I as FontStyle, J as PageOpenGraph, K as PageActionsConfig, L as GithubConfig, M as DocsSearchResultType, N as DocsSearchSourcePage, O as DocsSearchDocument, P as DocsTheme, Q as SidebarComponentProps, R as LastUpdatedConfig, S as DocsRelatedItem, T as DocsSearchAdapterFactory, U as OpenDocsProvider, V as OGConfig, W as OpenGraphImage, X as ReadingTimeConfig, Y as PageTwitter, Z as ResolvedDocsRelatedLink, _ as DocsI18nConfig, a as ApiReferenceRenderer, at as ThemeToggleConfig, b as DocsMetadata, c as ChangelogFrontmatter, ct as UIConfig, d as CustomDocsSearchConfig, et as SidebarFolderNode, f as DocsAgentFeedbackContext, g as DocsFeedbackValue, h as DocsFeedbackData, i as ApiReferenceConfig, it as SimpleDocsSearchConfig, j as DocsSearchResult, k as DocsSearchEmbeddingsConfig, l as CodeBlockCopyData, m as DocsConfig, n as AgentFeedbackConfig, nt as SidebarPageNode, o as BreadcrumbConfig, ot as TypesenseDocsSearchConfig, p as DocsAgentFeedbackData, q as PageFrontmatter, r as AlgoliaDocsSearchConfig, rt as SidebarTree, s as ChangelogConfig, st as TypographyConfig, t as AIConfig, tt as SidebarNode, u as CopyMarkdownConfig, v as DocsMcpConfig, w as DocsSearchAdapterContext, x as DocsNav, y as DocsMcpToolsConfig, z as LlmsTxtConfig } from "./types-Boobvv2I.mjs";
1
+ import { $ as SidebarConfig, A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, F as FeedbackConfig, G as OrderingItem, H as OpenDocsConfig, I as FontStyle, J as PageOpenGraph, K as PageActionsConfig, L as GithubConfig, M as DocsSearchResultType, N as DocsSearchSourcePage, O as DocsSearchDocument, P as DocsTheme, Q as SidebarComponentProps, R as LastUpdatedConfig, S as DocsRelatedItem, T as DocsSearchAdapterFactory, U as OpenDocsProvider, V as OGConfig, W as OpenGraphImage, X as ReadingTimeConfig, Y as PageTwitter, Z as ResolvedDocsRelatedLink, _ as DocsI18nConfig, a as ApiReferenceRenderer, at as ThemeToggleConfig, b as DocsMetadata, c as ChangelogFrontmatter, ct as UIConfig, d as CustomDocsSearchConfig, et as SidebarFolderNode, f as DocsAgentFeedbackContext, g as DocsFeedbackValue, h as DocsFeedbackData, i as ApiReferenceConfig, it as SimpleDocsSearchConfig, j as DocsSearchResult, k as DocsSearchEmbeddingsConfig, l as CodeBlockCopyData, m as DocsConfig, n as AgentFeedbackConfig, nt as SidebarPageNode, o as BreadcrumbConfig, ot as TypesenseDocsSearchConfig, p as DocsAgentFeedbackData, q as PageFrontmatter, r as AlgoliaDocsSearchConfig, rt as SidebarTree, s as ChangelogConfig, st as TypographyConfig, t as AIConfig, tt as SidebarNode, u as CopyMarkdownConfig, v as DocsMcpConfig, w as DocsSearchAdapterContext, x as DocsNav, y as DocsMcpToolsConfig, z as LlmsTxtConfig } from "./types-Agkn2EQE.mjs";
2
2
  import { DocsMcpPage, DocsMcpResolvedConfig } from "./mcp.mjs";
3
- import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-BxJywXXB.mjs";
3
+ import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-DcI00OQT.mjs";
4
4
 
5
5
  //#region src/define-docs.d.ts
6
6
  /**
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { D as DocsSearchConfig, G as OrderingItem, N as DocsSearchSourcePage, v as DocsMcpConfig } from "./types-Boobvv2I.mjs";
1
+ import { D as DocsSearchConfig, G as OrderingItem, N as DocsSearchSourcePage, v as DocsMcpConfig } from "./types-Agkn2EQE.mjs";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
4
  //#region src/mcp.d.ts
@@ -1,4 +1,4 @@
1
- import { B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, d as CustomDocsSearchConfig, j as DocsSearchResult, ot as TypesenseDocsSearchConfig, r as AlgoliaDocsSearchConfig } from "./types-Boobvv2I.mjs";
1
+ import { B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, E as DocsSearchChunkingConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, d as CustomDocsSearchConfig, j as DocsSearchResult, ot as TypesenseDocsSearchConfig, r as AlgoliaDocsSearchConfig } from "./types-Agkn2EQE.mjs";
2
2
 
3
3
  //#region src/search.d.ts
4
4
  declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig): DocsSearchDocument[];
package/dist/server.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, a as ApiReferenceRenderer, j as DocsSearchResult, m as DocsConfig, w as DocsSearchAdapterContext } from "./types-Boobvv2I.mjs";
1
+ import { A as DocsSearchQuery, B as McpDocsSearchConfig, C as DocsSearchAdapter, D as DocsSearchConfig, N as DocsSearchSourcePage, O as DocsSearchDocument, T as DocsSearchAdapterFactory, a as ApiReferenceRenderer, j as DocsSearchResult, m as DocsConfig, w as DocsSearchAdapterContext } from "./types-Agkn2EQE.mjs";
2
2
  import { DocsMcpHttpHandlers, DocsMcpNavigationNode, DocsMcpNavigationTree, DocsMcpPage, DocsMcpResolvedConfig, DocsMcpSource, createDocsMcpHttpHandler, createDocsMcpServer, createFilesystemDocsMcpSource, normalizeDocsMcpRoute, resolveDocsMcpConfig, runDocsMcpStdio } from "./mcp.mjs";
3
- import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-BxJywXXB.mjs";
3
+ import { a as createSimpleSearchAdapter, c as resolveSearchRequestConfig, i as createMcpSearchAdapter, n as createAlgoliaSearchAdapter, o as createTypesenseSearchAdapter, r as createCustomSearchAdapter, s as performDocsSearch, t as buildDocsSearchDocuments } from "./search-DcI00OQT.mjs";
4
4
 
5
5
  //#region src/api-reference.d.ts
6
6
  type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
@@ -246,11 +246,20 @@ type DocsRelatedItem = string;
246
246
  interface ResolvedDocsRelatedLink {
247
247
  href: string;
248
248
  }
249
+ interface PageAgentFrontmatter {
250
+ /**
251
+ * Approximate output token target for machine-readable compaction on this page.
252
+ * Used by `docs agent compact` as a per-page override.
253
+ */
254
+ tokenBudget?: number;
255
+ }
249
256
  interface PageFrontmatter {
250
257
  title: string;
251
258
  description?: string;
252
259
  /** Related doc URLs rendered into machine-readable markdown routes and MCP page output. */
253
260
  related?: DocsRelatedItem[];
261
+ /** Per-page agent-oriented metadata used by machine-readable docs features. */
262
+ agent?: PageAgentFrontmatter;
254
263
  /** Override or disable the estimated reading time for this page. */
255
264
  readingTime?: boolean | number;
256
265
  tags?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",