@farming-labs/docs 0.2.62 → 0.2.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-CQTH7NFu.mjs +624 -0
- package/dist/agent-DKKptIgy.mjs +4365 -0
- package/dist/agent-evals-B7MIxuEX.mjs +2144 -0
- package/dist/agent-export-CBgWgPvH.mjs +910 -0
- package/dist/agent-scope-C_U--OZ7.mjs +283 -0
- package/dist/agent-skills-bundle.d.mts +13 -0
- package/dist/agent-skills-bundle.mjs +12 -0
- package/dist/agent-skills-server-CPja6Syt.d.mts +14 -0
- package/dist/agent-skills-server-DraIb6FV.mjs +415 -0
- package/dist/agent-skills-vite.d.mts +31 -0
- package/dist/agent-skills-vite.mjs +70 -0
- package/dist/agents-XWZBub6f.mjs +221 -0
- package/dist/analytics-Bx44lg6d.mjs +177 -0
- package/dist/cli/index.d.mts +15 -0
- package/dist/cli/index.mjs +452 -0
- package/dist/client/react.d.mts +45 -0
- package/dist/client/react.mjs +223 -0
- package/dist/cloud-analytics-CSyFE6SS.mjs +132 -0
- package/dist/cloud-ask-ai-sbpjOR2K.mjs +382 -0
- package/dist/cloud-ask-ai-zpwkdwnF.d.mts +23 -0
- package/dist/cloud-pdNC-tyj.mjs +1615 -0
- package/dist/code-blocks-DnNVNK2M.mjs +871 -0
- package/dist/codeblocks-CFuurVIH.mjs +250 -0
- package/dist/config-Wcdj-D0a.mjs +369 -0
- package/dist/dev-Cmy6DtdF.mjs +1333 -0
- package/dist/docs-cloud-server.d.mts +70 -0
- package/dist/docs-cloud-server.mjs +310 -0
- package/dist/doctor-DtGYZ41i.mjs +2036 -0
- package/dist/downgrade-w7e6Se0L.mjs +184 -0
- package/dist/errors-DbOhkE1h.mjs +20 -0
- package/dist/golden-evaluations-Dj-9Eo3v.mjs +1785 -0
- package/dist/i18n-CCaFUnAN.mjs +40 -0
- package/dist/index.d.mts +1150 -0
- package/dist/index.mjs +10 -0
- package/dist/init-CQY0Woe3.mjs +1264 -0
- package/dist/mcp-B9dcsivk.mjs +156 -0
- package/dist/mcp.d.mts +298 -0
- package/dist/mcp.mjs +4430 -0
- package/dist/metadata-DWExHQnx.mjs +237 -0
- package/dist/package-version-n5AFur8a.mjs +128 -0
- package/dist/reading-time-CYZ5VvKU.mjs +742 -0
- package/dist/review-CLoHTywU.mjs +673 -0
- package/dist/robots-BIpC4j4P.mjs +201 -0
- package/dist/robots-CUTahhoY.mjs +179 -0
- package/dist/search-B6V6qtiI.mjs +1826 -0
- package/dist/search-CaSyi6H6.d.mts +279 -0
- package/dist/search-DSjCeOk7.mjs +104 -0
- package/dist/server.d.mts +343 -0
- package/dist/server.mjs +14 -0
- package/dist/sitemap-Cykpe3Tz.mjs +249 -0
- package/dist/sitemap-server-C_6Wes83.mjs +1137 -0
- package/dist/standards-discovery-C4HUqMd2.d.mts +227 -0
- package/dist/standards-discovery-jkykaXq1.mjs +519 -0
- package/dist/templates-Bq_P7ctv.mjs +2465 -0
- package/dist/types-lMBIdZg0.d.mts +3315 -0
- package/dist/upgrade-oz-GChgt.mjs +56 -0
- package/dist/utils-DpiIioYb.mjs +225 -0
- package/package.json +1 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { k as DocsDiscoveryApiRouteOptions } from "./standards-discovery-C4HUqMd2.mjs";
|
|
2
|
+
import { B as DocsAnalyticsEventInput, Dt as DocsObservabilityConfig, F as DocsAgentTraceEventInput, Ht as DocsSearchChunkingConfig, Ot as DocsObservabilityEvent, Pn as ResolvedDocsRelatedLink, R as DocsAnalyticsConfig, Ut as DocsSearchConfig, Vt as DocsSearchAdapterFactory, Wn as TypesenseDocsSearchConfig, Wt as DocsSearchDocument, X as DocsAskAIMcpConfig, Xt as DocsSitemapConfig, Yt as DocsSearchSourcePage, f as CustomDocsSearchConfig, gn as OpenDocsProvider, kt as DocsObservabilityEventInput, pn as McpDocsSearchConfig, qt as DocsSearchResult, r as AlgoliaDocsSearchConfig, yn as OpenDocsTarget, z as DocsAnalyticsEvent, zt as DocsSearchAdapter } from "./types-lMBIdZg0.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/analytics.d.ts
|
|
5
|
+
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"];
|
|
6
|
+
interface DocsAgentTraceContext {
|
|
7
|
+
traceId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
startedMs: number;
|
|
11
|
+
}
|
|
12
|
+
interface ResolvedDocsAnalyticsConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
console: false | "log" | "info" | "debug";
|
|
15
|
+
includeInputs: boolean;
|
|
16
|
+
onEvent?: (event: DocsAnalyticsEvent) => void | Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
interface ResolvedDocsObservabilityConfig {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
console: false | "log" | "info" | "debug";
|
|
21
|
+
includeInputs: boolean;
|
|
22
|
+
onEvent?: (event: DocsObservabilityEvent) => void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
declare function createDocsAgentTraceId(prefix?: string): string;
|
|
25
|
+
declare function createDocsAgentTraceContext(name?: string): DocsAgentTraceContext;
|
|
26
|
+
declare function getDocsRequestAnalyticsProperties(request: Request): Record<string, unknown>;
|
|
27
|
+
declare function resolveDocsAnalyticsConfig(analytics?: boolean | DocsAnalyticsConfig): ResolvedDocsAnalyticsConfig;
|
|
28
|
+
declare function resolveDocsObservabilityConfig(observability?: boolean | DocsObservabilityConfig): ResolvedDocsObservabilityConfig;
|
|
29
|
+
declare function emitDocsAnalyticsEvent(analytics: boolean | DocsAnalyticsConfig | undefined, event: DocsAnalyticsEventInput): Promise<void>;
|
|
30
|
+
declare function emitDocsObservabilityEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsObservabilityEventInput): Promise<void>;
|
|
31
|
+
declare function emitDocsAgentTraceEvent(observability: boolean | DocsObservabilityConfig | undefined, event: DocsAgentTraceEventInput): Promise<void>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/audience.d.ts
|
|
34
|
+
/** The two content projections emitted by the docs framework. */
|
|
35
|
+
type DocsContentAudience = "human" | "agent";
|
|
36
|
+
/** Resolve whether content with an optional audience restriction is visible. */
|
|
37
|
+
declare function resolveDocsAudienceExposure(only: unknown, audience: DocsContentAudience): boolean;
|
|
38
|
+
interface DocsAudienceMdxIssue {
|
|
39
|
+
code: "missing-only" | "invalid-only" | "dynamic-only" | "ignored-agent-only" | "ignored-human-only";
|
|
40
|
+
index: number;
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
/** Find audience declarations that cannot be projected consistently at build time. */
|
|
44
|
+
declare function findDocsAudienceMdxIssues(content: string): DocsAudienceMdxIssue[];
|
|
45
|
+
/**
|
|
46
|
+
* Resolve MDX into its human or agent projection.
|
|
47
|
+
*
|
|
48
|
+
* `<Agent>` is shorthand for `<Audience only="agent">`, while `<Human>` is
|
|
49
|
+
* shorthand for `<Audience only="human">`. Unknown `Audience.only` values are
|
|
50
|
+
* treated as shared content so an authoring typo never silently deletes content.
|
|
51
|
+
* These primitives shape content for each surface; they are not an access-control boundary.
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveDocsAudienceMdxContent(content: string, audience: DocsContentAudience): string;
|
|
54
|
+
/** Backwards-compatible name retained for existing integrations. */
|
|
55
|
+
declare function resolveDocsAgentMdxContent(content: string, audience: DocsContentAudience): string;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/prompt-utils.d.ts
|
|
58
|
+
type PromptAction = "copy" | "open";
|
|
59
|
+
interface SerializedOpenDocsProvider {
|
|
60
|
+
name: string;
|
|
61
|
+
iconHtml?: string;
|
|
62
|
+
urlTemplate: string;
|
|
63
|
+
promptUrlTemplate?: string;
|
|
64
|
+
target?: OpenDocsTarget;
|
|
65
|
+
prompt?: string;
|
|
66
|
+
}
|
|
67
|
+
interface PromptProviderChoice {
|
|
68
|
+
name: string;
|
|
69
|
+
iconHtml?: string;
|
|
70
|
+
urlTemplate: string;
|
|
71
|
+
}
|
|
72
|
+
type PromptProviderInput = Pick<SerializedOpenDocsProvider, "name" | "iconHtml"> & Partial<Pick<SerializedOpenDocsProvider, "promptUrlTemplate" | "urlTemplate">>;
|
|
73
|
+
interface SerializeOpenDocsProviderOptions {
|
|
74
|
+
target?: OpenDocsTarget;
|
|
75
|
+
prompt?: string;
|
|
76
|
+
}
|
|
77
|
+
declare const DEFAULT_PROMPT_PROVIDER_TEMPLATES: Record<string, string>;
|
|
78
|
+
declare const DEFAULT_OPEN_DOCS_TARGET: OpenDocsTarget;
|
|
79
|
+
declare const DEFAULT_OPEN_DOCS_PROMPT = "Read this documentation: {url}";
|
|
80
|
+
declare const DEFAULT_OPEN_DOCS_PROVIDER_IDS: readonly ["chatgpt", "claude"];
|
|
81
|
+
declare function normalizePromptProviderName(name: string): string;
|
|
82
|
+
declare function serializeDocsIcon(icon: unknown): string | undefined;
|
|
83
|
+
declare function serializeDocsIconRegistry(icons?: Record<string, unknown>): Record<string, string> | undefined;
|
|
84
|
+
declare function serializeOpenDocsProviders(providers?: OpenDocsProvider[], options?: SerializeOpenDocsProviderOptions): SerializedOpenDocsProvider[] | undefined;
|
|
85
|
+
declare function serializeOpenDocsProvider(provider: OpenDocsProvider, options?: SerializeOpenDocsProviderOptions): SerializedOpenDocsProvider | undefined;
|
|
86
|
+
declare function parsePromptStringArray(value: unknown): string[] | undefined;
|
|
87
|
+
declare function resolvePromptProviderChoices(availableProviders?: PromptProviderInput[], preferredNames?: string[]): PromptProviderChoice[];
|
|
88
|
+
declare function sanitizePromptText(text: string): string;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/sitemap.d.ts
|
|
91
|
+
declare const DEFAULT_SITEMAP_XML_ROUTE = "/sitemap.xml";
|
|
92
|
+
declare const DEFAULT_SITEMAP_MD_ROUTE = "/sitemap.md";
|
|
93
|
+
declare const DEFAULT_SITEMAP_MD_DOCS_ROUTE = "/docs/sitemap.md";
|
|
94
|
+
declare const DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE = "/.well-known/sitemap.md";
|
|
95
|
+
declare const DEFAULT_SITEMAP_MANIFEST_PATH = ".farming-labs/sitemap-manifest.json";
|
|
96
|
+
type DocsSitemapFormat = "xml" | "markdown";
|
|
97
|
+
interface DocsSitemapPageInput {
|
|
98
|
+
slug?: string;
|
|
99
|
+
url: string;
|
|
100
|
+
/** Override the public Markdown representation URL when it differs from `${url}.md`. */
|
|
101
|
+
markdownUrl?: string;
|
|
102
|
+
title: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
related?: ResolvedDocsRelatedLink[];
|
|
105
|
+
sourcePath?: string;
|
|
106
|
+
lastmod?: string;
|
|
107
|
+
lastModified?: string;
|
|
108
|
+
}
|
|
109
|
+
interface DocsSitemapManifestPage {
|
|
110
|
+
url: string;
|
|
111
|
+
absoluteUrl?: string;
|
|
112
|
+
markdownUrl: string;
|
|
113
|
+
title: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
sourcePath?: string;
|
|
116
|
+
lastmod?: string;
|
|
117
|
+
lastmodSource?: "git" | "filesystem" | "frontmatter" | "manifest" | "unknown";
|
|
118
|
+
related?: string[];
|
|
119
|
+
}
|
|
120
|
+
interface DocsSitemapManifest {
|
|
121
|
+
version: 1;
|
|
122
|
+
generatedAt: string;
|
|
123
|
+
baseUrl?: string;
|
|
124
|
+
entry: string;
|
|
125
|
+
siteTitle?: string;
|
|
126
|
+
pages: DocsSitemapManifestPage[];
|
|
127
|
+
}
|
|
128
|
+
interface DocsSitemapResolvedConfig {
|
|
129
|
+
enabled: boolean;
|
|
130
|
+
routePrefix: string;
|
|
131
|
+
baseUrl?: string;
|
|
132
|
+
manifestPath: string;
|
|
133
|
+
xml: {
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
includeLastmod: boolean;
|
|
136
|
+
route: string;
|
|
137
|
+
};
|
|
138
|
+
markdown: {
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
includeDescriptions: boolean;
|
|
141
|
+
includeLastmod: boolean;
|
|
142
|
+
linkTarget: "html" | "markdown" | "both";
|
|
143
|
+
route: string;
|
|
144
|
+
docsRoute?: string;
|
|
145
|
+
wellKnownRoute: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
interface CreateDocsSitemapResponseOptions extends DocsDiscoveryApiRouteOptions {
|
|
149
|
+
request: Request;
|
|
150
|
+
sitemap?: boolean | DocsSitemapConfig;
|
|
151
|
+
entry?: string;
|
|
152
|
+
siteTitle?: string;
|
|
153
|
+
baseUrl?: string;
|
|
154
|
+
pages: DocsSitemapPageInput[];
|
|
155
|
+
manifest?: DocsSitemapManifest | null;
|
|
156
|
+
}
|
|
157
|
+
declare function resolveDocsSitemapConfig(sitemap?: boolean | DocsSitemapConfig, defaults?: {
|
|
158
|
+
baseUrl?: string;
|
|
159
|
+
}): DocsSitemapResolvedConfig;
|
|
160
|
+
declare function resolveDocsSitemapRequest(url: URL, sitemap?: boolean | DocsSitemapConfig, options?: DocsDiscoveryApiRouteOptions): DocsSitemapFormat | null;
|
|
161
|
+
declare function toDocsSitemapMarkdownUrl(url: string): string;
|
|
162
|
+
declare function buildDocsSitemapManifest(options: {
|
|
163
|
+
pages: DocsSitemapPageInput[];
|
|
164
|
+
entry?: string;
|
|
165
|
+
siteTitle?: string;
|
|
166
|
+
baseUrl?: string;
|
|
167
|
+
generatedAt?: string;
|
|
168
|
+
resolveLastmod?: (page: DocsSitemapPageInput) => {
|
|
169
|
+
lastmod?: string;
|
|
170
|
+
lastmodSource?: DocsSitemapManifestPage["lastmodSource"];
|
|
171
|
+
} | undefined;
|
|
172
|
+
}): DocsSitemapManifest;
|
|
173
|
+
declare function renderDocsSitemapXml(manifest: DocsSitemapManifest, options?: {
|
|
174
|
+
baseUrl?: string;
|
|
175
|
+
includeLastmod?: boolean;
|
|
176
|
+
}): string;
|
|
177
|
+
declare function renderDocsSitemapMarkdown(manifest: DocsSitemapManifest, options?: {
|
|
178
|
+
baseUrl?: string;
|
|
179
|
+
includeDescriptions?: boolean;
|
|
180
|
+
includeLastmod?: boolean;
|
|
181
|
+
linkTarget?: "html" | "markdown" | "both";
|
|
182
|
+
}): string;
|
|
183
|
+
declare function readDocsSitemapManifestFromContentMap(contentMap?: Record<string, string> | null): DocsSitemapManifest | null;
|
|
184
|
+
declare function resolveDocsSitemapPageLastmod(manifest: DocsSitemapManifest | null | undefined, url: string): string | undefined;
|
|
185
|
+
declare function createDocsSitemapResponse({
|
|
186
|
+
request,
|
|
187
|
+
apiRoute,
|
|
188
|
+
sitemap,
|
|
189
|
+
entry,
|
|
190
|
+
siteTitle,
|
|
191
|
+
baseUrl,
|
|
192
|
+
pages,
|
|
193
|
+
manifest
|
|
194
|
+
}: CreateDocsSitemapResponseOptions): Response | null;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/search.d.ts
|
|
197
|
+
interface DocsAskAIContextResult extends DocsSearchResult {
|
|
198
|
+
title: string;
|
|
199
|
+
contextContent: string;
|
|
200
|
+
}
|
|
201
|
+
interface DocsAskAIContext {
|
|
202
|
+
context: string;
|
|
203
|
+
/** Structured production context blocks; avoids reparsing markdown horizontal rules. */
|
|
204
|
+
blocks: Array<{
|
|
205
|
+
text: string;
|
|
206
|
+
result: DocsAskAIContextResult;
|
|
207
|
+
}>;
|
|
208
|
+
results: DocsAskAIContextResult[];
|
|
209
|
+
searchResults: DocsSearchResult[];
|
|
210
|
+
packageHints: DocsAskAIPackageHints;
|
|
211
|
+
}
|
|
212
|
+
interface DocsAskAIPackageHints {
|
|
213
|
+
packages: string[];
|
|
214
|
+
imports: string[];
|
|
215
|
+
installCommands: string[];
|
|
216
|
+
}
|
|
217
|
+
declare function inferDocsAskAIPackageHints(content: string): DocsAskAIPackageHints;
|
|
218
|
+
declare function formatDocsAskAIPackageHints(hints: DocsAskAIPackageHints, packageName?: string): string | undefined;
|
|
219
|
+
declare function buildDocsSearchDocuments(pages: DocsSearchSourcePage[], chunking?: DocsSearchChunkingConfig, audience?: DocsContentAudience): DocsSearchDocument[];
|
|
220
|
+
declare function createSimpleSearchAdapter(): DocsSearchAdapter;
|
|
221
|
+
declare function createTypesenseSearchAdapter(config: TypesenseDocsSearchConfig): DocsSearchAdapter;
|
|
222
|
+
declare function resolveSearchRequestConfig(search: boolean | DocsSearchConfig | undefined, requestUrl?: string): boolean | DocsSearchConfig | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Resolve the public search audience without allowing malformed values to opt into agent content.
|
|
225
|
+
* Human search remains the default for omitted, legacy, and unknown query values.
|
|
226
|
+
*/
|
|
227
|
+
declare function resolveDocsSearchAudience(value: string | null | undefined): DocsContentAudience;
|
|
228
|
+
declare function resolveAskAISearchRequestConfig(options: {
|
|
229
|
+
search: boolean | DocsSearchConfig | undefined;
|
|
230
|
+
useMcp?: boolean | DocsAskAIMcpConfig;
|
|
231
|
+
mcpEndpoint?: string;
|
|
232
|
+
mcpEnabled?: boolean;
|
|
233
|
+
mcpSearchEnabled?: boolean;
|
|
234
|
+
requestUrl?: string;
|
|
235
|
+
}): boolean | DocsSearchConfig | undefined;
|
|
236
|
+
declare function createMcpSearchAdapter(config: McpDocsSearchConfig): DocsSearchAdapter;
|
|
237
|
+
declare function createAlgoliaSearchAdapter(config: AlgoliaDocsSearchConfig): DocsSearchAdapter;
|
|
238
|
+
declare function performDocsSearch(options: {
|
|
239
|
+
pages: DocsSearchSourcePage[];
|
|
240
|
+
query: string;
|
|
241
|
+
search?: boolean | DocsSearchConfig; /** Selects which audience projection is searchable. Public site search defaults to human. */
|
|
242
|
+
audience?: DocsContentAudience;
|
|
243
|
+
locale?: string;
|
|
244
|
+
pathname?: string;
|
|
245
|
+
siteTitle?: string; /** Canonical docs URL used to distinguish same-site absolute hits from foreign MCP results. */
|
|
246
|
+
baseUrl?: string;
|
|
247
|
+
limit?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Controls provider failures. Runtime search keeps the resilient `fallback` default;
|
|
250
|
+
* diagnostics can request `throw` so a broken configured provider cannot be scored as
|
|
251
|
+
* successful simple search.
|
|
252
|
+
*/
|
|
253
|
+
failureMode?: "fallback" | "throw";
|
|
254
|
+
/**
|
|
255
|
+
* Whether non-simple provider hits are supplemented with exact/local simple results.
|
|
256
|
+
* Runtime search defaults to true; provider diagnostics can disable supplementation.
|
|
257
|
+
*/
|
|
258
|
+
supplementExternalResults?: boolean; /** Fail closed on absolute provider hits when no canonical docs origin is available. */
|
|
259
|
+
strictExternalOrigins?: boolean; /** Optional cancellation signal forwarded to adapters and their managed requests. */
|
|
260
|
+
signal?: AbortSignal;
|
|
261
|
+
}): Promise<DocsSearchResult[]>;
|
|
262
|
+
declare function buildDocsAskAIContext(options: {
|
|
263
|
+
pages: DocsSearchSourcePage[];
|
|
264
|
+
query: string;
|
|
265
|
+
search?: boolean | DocsSearchConfig;
|
|
266
|
+
locale?: string;
|
|
267
|
+
pathname?: string;
|
|
268
|
+
siteTitle?: string;
|
|
269
|
+
baseUrl?: string;
|
|
270
|
+
limit?: number;
|
|
271
|
+
maxContextChars?: number;
|
|
272
|
+
maxResultChars?: number; /** See `performDocsSearch.failureMode`. Defaults to resilient runtime fallback. */
|
|
273
|
+
searchFailureMode?: "fallback" | "throw"; /** See `performDocsSearch.strictExternalOrigins`. */
|
|
274
|
+
strictExternalOrigins?: boolean; /** Optional cancellation signal forwarded to the configured search provider. */
|
|
275
|
+
signal?: AbortSignal;
|
|
276
|
+
}): Promise<DocsAskAIContext>;
|
|
277
|
+
declare function createCustomSearchAdapter(adapter: DocsSearchAdapter | DocsSearchAdapterFactory): CustomDocsSearchConfig;
|
|
278
|
+
//#endregion
|
|
279
|
+
export { resolveDocsAudienceExposure as $, resolveDocsSitemapPageLastmod as A, SerializedOpenDocsProvider as B, DocsSitemapResolvedConfig as C, renderDocsSitemapMarkdown as D, readDocsSitemapManifestFromContentMap as E, DEFAULT_OPEN_DOCS_TARGET as F, serializeDocsIcon as G, parsePromptStringArray as H, DEFAULT_PROMPT_PROVIDER_TEMPLATES as I, serializeOpenDocsProviders as J, serializeDocsIconRegistry as K, PromptAction as L, toDocsSitemapMarkdownUrl as M, DEFAULT_OPEN_DOCS_PROMPT as N, renderDocsSitemapXml as O, DEFAULT_OPEN_DOCS_PROVIDER_IDS as P, resolveDocsAgentMdxContent as Q, PromptProviderChoice as R, DocsSitemapPageInput as S, createDocsSitemapResponse as T, resolvePromptProviderChoices as U, normalizePromptProviderName as V, sanitizePromptText as W, DocsContentAudience as X, DocsAudienceMdxIssue as Y, findDocsAudienceMdxIssues as Z, DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE as _, createMcpSearchAdapter as a, createDocsAgentTraceContext as at, DocsSitemapManifest as b, formatDocsAskAIPackageHints as c, emitDocsAnalyticsEvent as ct, resolveAskAISearchRequestConfig as d, resolveDocsAnalyticsConfig as dt, resolveDocsAudienceMdxContent as et, resolveDocsSearchAudience as f, resolveDocsObservabilityConfig as ft, DEFAULT_SITEMAP_MD_ROUTE as g, DEFAULT_SITEMAP_MD_DOCS_ROUTE as h, createCustomSearchAdapter as i, ResolvedDocsObservabilityConfig as it, resolveDocsSitemapRequest as j, resolveDocsSitemapConfig as k, inferDocsAskAIPackageHints as l, emitDocsObservabilityEvent as lt, DEFAULT_SITEMAP_MANIFEST_PATH as m, buildDocsSearchDocuments as n, DocsAgentTraceContext as nt, createSimpleSearchAdapter as o, createDocsAgentTraceId as ot, resolveSearchRequestConfig as p, serializeOpenDocsProvider as q, createAlgoliaSearchAdapter as r, ResolvedDocsAnalyticsConfig as rt, createTypesenseSearchAdapter as s, emitDocsAgentTraceEvent as st, buildDocsAskAIContext as t, DOCS_AGENT_TRACE_EVENT_TYPES as tt, performDocsSearch as u, getDocsRequestAnalyticsProperties as ut, DEFAULT_SITEMAP_XML_ROUTE as v, buildDocsSitemapManifest as w, DocsSitemapManifestPage as x, DocsSitemapFormat as y, SerializeOpenDocsProviderOptions as z };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import "./agent-DKKptIgy.mjs";
|
|
2
|
+
import "./standards-discovery-jkykaXq1.mjs";
|
|
3
|
+
import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as createTypesenseSearchAdapter } from "./search-B6V6qtiI.mjs";
|
|
4
|
+
import "./sitemap-server-C_6Wes83.mjs";
|
|
5
|
+
import "./agent-evals-B7MIxuEX.mjs";
|
|
6
|
+
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
|
7
|
+
import "./code-blocks-DnNVNK2M.mjs";
|
|
8
|
+
import "./agent-skills-server-DraIb6FV.mjs";
|
|
9
|
+
import "./server.mjs";
|
|
10
|
+
import { _ as resolveDocsContentDir, c as loadProjectEnv, g as resolveDocsConfigPath, h as readTopLevelStringProperty } from "./config-Wcdj-D0a.mjs";
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import pc from "picocolors";
|
|
13
|
+
|
|
14
|
+
//#region src/cli/search.ts
|
|
15
|
+
function getEnvValue(loadedEnv, key) {
|
|
16
|
+
return process.env[key] ?? loadedEnv[key];
|
|
17
|
+
}
|
|
18
|
+
function resolveSearchSyncProvider(options, loadedEnv) {
|
|
19
|
+
if (options.typesense && options.algolia) throw new Error("Use only one provider flag: --typesense or --algolia.");
|
|
20
|
+
if (options.typesense) return "typesense";
|
|
21
|
+
if (options.algolia) return "algolia";
|
|
22
|
+
if (options.provider === "typesense" || options.provider === "algolia") return options.provider;
|
|
23
|
+
if (options.provider) throw new Error(`Unsupported search provider: ${options.provider}.`);
|
|
24
|
+
if (options.baseUrl || getEnvValue(loadedEnv, "TYPESENSE_URL")) return "typesense";
|
|
25
|
+
if (options.appId || getEnvValue(loadedEnv, "ALGOLIA_APP_ID")) return "algolia";
|
|
26
|
+
throw new Error("Could not determine a search provider. Use --typesense, --algolia, or --provider <name>.");
|
|
27
|
+
}
|
|
28
|
+
function resolveTypesenseSyncConfig(options, loadedEnv) {
|
|
29
|
+
const baseUrl = options.baseUrl ?? getEnvValue(loadedEnv, "TYPESENSE_URL") ?? getEnvValue(loadedEnv, "TYPESENSE_BASE_URL");
|
|
30
|
+
const collection = options.collection ?? getEnvValue(loadedEnv, "TYPESENSE_COLLECTION") ?? "docs";
|
|
31
|
+
const apiKey = options.apiKey ?? getEnvValue(loadedEnv, "TYPESENSE_SEARCH_API_KEY") ?? getEnvValue(loadedEnv, "TYPESENSE_API_KEY");
|
|
32
|
+
const adminApiKey = options.adminApiKey ?? getEnvValue(loadedEnv, "TYPESENSE_ADMIN_API_KEY") ?? getEnvValue(loadedEnv, "TYPESENSE_API_KEY");
|
|
33
|
+
const mode = options.mode === "hybrid" ? "hybrid" : "keyword";
|
|
34
|
+
const ollamaModel = options.ollamaModel ?? getEnvValue(loadedEnv, "TYPESENSE_OLLAMA_MODEL");
|
|
35
|
+
const ollamaBaseUrl = options.ollamaBaseUrl ?? getEnvValue(loadedEnv, "TYPESENSE_OLLAMA_BASE_URL");
|
|
36
|
+
if (!baseUrl) throw new Error("Missing Typesense base URL. Set TYPESENSE_URL or pass --base-url.");
|
|
37
|
+
if (!apiKey) throw new Error("Missing Typesense API key. Set TYPESENSE_API_KEY or pass --api-key.");
|
|
38
|
+
if (!adminApiKey) throw new Error("Missing Typesense admin-capable key for sync. Set TYPESENSE_ADMIN_API_KEY or pass --admin-api-key.");
|
|
39
|
+
return {
|
|
40
|
+
provider: "typesense",
|
|
41
|
+
baseUrl,
|
|
42
|
+
collection,
|
|
43
|
+
apiKey,
|
|
44
|
+
adminApiKey,
|
|
45
|
+
mode,
|
|
46
|
+
...mode === "hybrid" ? ollamaModel ? { embeddings: {
|
|
47
|
+
provider: "ollama",
|
|
48
|
+
model: ollamaModel,
|
|
49
|
+
baseUrl: ollamaBaseUrl
|
|
50
|
+
} } : (() => {
|
|
51
|
+
throw new Error("Typesense hybrid sync needs an embeddings model. Set TYPESENSE_OLLAMA_MODEL or pass --ollama-model.");
|
|
52
|
+
})() : {}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function resolveAlgoliaSyncConfig(options, loadedEnv) {
|
|
56
|
+
const appId = options.appId ?? getEnvValue(loadedEnv, "ALGOLIA_APP_ID");
|
|
57
|
+
const indexName = options.indexName ?? getEnvValue(loadedEnv, "ALGOLIA_INDEX_NAME") ?? "docs";
|
|
58
|
+
const adminApiKey = options.adminApiKey ?? getEnvValue(loadedEnv, "ALGOLIA_ADMIN_API_KEY");
|
|
59
|
+
const searchApiKey = options.searchApiKey ?? getEnvValue(loadedEnv, "ALGOLIA_SEARCH_API_KEY") ?? adminApiKey;
|
|
60
|
+
if (!appId) throw new Error("Missing Algolia app id. Set ALGOLIA_APP_ID or pass --app-id.");
|
|
61
|
+
if (!adminApiKey) throw new Error("Missing Algolia admin API key for sync. Set ALGOLIA_ADMIN_API_KEY or pass --admin-api-key.");
|
|
62
|
+
if (!searchApiKey) throw new Error("Missing Algolia search API key. Set ALGOLIA_SEARCH_API_KEY or pass --search-api-key.");
|
|
63
|
+
return {
|
|
64
|
+
provider: "algolia",
|
|
65
|
+
appId,
|
|
66
|
+
indexName,
|
|
67
|
+
searchApiKey,
|
|
68
|
+
adminApiKey
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async function syncSearch(options = {}) {
|
|
72
|
+
const rootDir = process.cwd();
|
|
73
|
+
const configContent = readFileSync(resolveDocsConfigPath(rootDir, options.configPath), "utf-8");
|
|
74
|
+
const loadedEnv = loadProjectEnv(rootDir);
|
|
75
|
+
const provider = resolveSearchSyncProvider(options, loadedEnv);
|
|
76
|
+
const entry = readTopLevelStringProperty(configContent, "entry") ?? "docs";
|
|
77
|
+
const contentDir = resolveDocsContentDir(rootDir, configContent, entry);
|
|
78
|
+
const source = createFilesystemDocsMcpSource({
|
|
79
|
+
rootDir,
|
|
80
|
+
entry,
|
|
81
|
+
contentDir,
|
|
82
|
+
siteTitle: "Documentation"
|
|
83
|
+
});
|
|
84
|
+
const pages = await source.getPages();
|
|
85
|
+
const documents = buildDocsSearchDocuments(pages);
|
|
86
|
+
const context = {
|
|
87
|
+
pages,
|
|
88
|
+
documents,
|
|
89
|
+
siteTitle: source.siteTitle
|
|
90
|
+
};
|
|
91
|
+
if (documents.length === 0) throw new Error(`No docs content was found under ${contentDir}.`);
|
|
92
|
+
if (provider === "typesense") {
|
|
93
|
+
const config = resolveTypesenseSyncConfig(options, loadedEnv);
|
|
94
|
+
await createTypesenseSearchAdapter(config).index?.(context);
|
|
95
|
+
console.log(pc.green(`Synced ${documents.length} docs search documents to Typesense collection "${config.collection}".`));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const config = resolveAlgoliaSyncConfig(options, loadedEnv);
|
|
99
|
+
await createAlgoliaSearchAdapter(config).index?.(context);
|
|
100
|
+
console.log(pc.green(`Synced ${documents.length} docs search documents to Algolia index "${config.indexName}".`));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { syncSearch };
|