@farming-labs/docs 0.2.61 → 0.2.62

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 (58) hide show
  1. package/package.json +1 -1
  2. package/dist/agent-DFHlw_JC.mjs +0 -624
  3. package/dist/agent-Fl0pjVNF.mjs +0 -4352
  4. package/dist/agent-evals-f4_OL10T.mjs +0 -2144
  5. package/dist/agent-export-D0zQhasD.mjs +0 -910
  6. package/dist/agent-scope-C_U--OZ7.mjs +0 -283
  7. package/dist/agent-skills-bundle.d.mts +0 -13
  8. package/dist/agent-skills-bundle.mjs +0 -12
  9. package/dist/agent-skills-server-CIeBszxp.mjs +0 -263
  10. package/dist/agent-skills-server-CKq3_jMj.d.mts +0 -12
  11. package/dist/agent-skills-vite.d.mts +0 -31
  12. package/dist/agent-skills-vite.mjs +0 -70
  13. package/dist/agents-ibnXrWyp.mjs +0 -221
  14. package/dist/analytics-Bx44lg6d.mjs +0 -177
  15. package/dist/cli/index.d.mts +0 -15
  16. package/dist/cli/index.mjs +0 -452
  17. package/dist/client/react.d.mts +0 -45
  18. package/dist/client/react.mjs +0 -223
  19. package/dist/cloud-analytics-CSyFE6SS.mjs +0 -132
  20. package/dist/cloud-ask-ai-D7ZgF47y.d.mts +0 -23
  21. package/dist/cloud-ask-ai-sbpjOR2K.mjs +0 -382
  22. package/dist/cloud-pdNC-tyj.mjs +0 -1615
  23. package/dist/code-blocks-DnNVNK2M.mjs +0 -871
  24. package/dist/codeblocks-CFuurVIH.mjs +0 -250
  25. package/dist/config-Wcdj-D0a.mjs +0 -369
  26. package/dist/dev-Cmy6DtdF.mjs +0 -1333
  27. package/dist/docs-cloud-server.d.mts +0 -70
  28. package/dist/docs-cloud-server.mjs +0 -310
  29. package/dist/doctor-CXostbsI.mjs +0 -2036
  30. package/dist/downgrade-w7e6Se0L.mjs +0 -184
  31. package/dist/errors-DbOhkE1h.mjs +0 -20
  32. package/dist/golden-evaluations-CBZ_JZjf.mjs +0 -1498
  33. package/dist/i18n-CCaFUnAN.mjs +0 -40
  34. package/dist/index.d.mts +0 -1141
  35. package/dist/index.mjs +0 -10
  36. package/dist/init-CQY0Woe3.mjs +0 -1264
  37. package/dist/mcp-DyPcoLwm.mjs +0 -156
  38. package/dist/mcp.d.mts +0 -298
  39. package/dist/mcp.mjs +0 -4426
  40. package/dist/metadata-Dv1ah0Aj.mjs +0 -237
  41. package/dist/package-version-n5AFur8a.mjs +0 -128
  42. package/dist/reading-time-C-SAhQT9.mjs +0 -742
  43. package/dist/review-D2UBrxFq.mjs +0 -673
  44. package/dist/robots-5Yqz9mz7.mjs +0 -179
  45. package/dist/robots-C08kDLsz.mjs +0 -201
  46. package/dist/search-9OnMGMvt.mjs +0 -1758
  47. package/dist/search-C6heDO8h.d.mts +0 -274
  48. package/dist/search-CNsRpz90.mjs +0 -104
  49. package/dist/server.d.mts +0 -342
  50. package/dist/server.mjs +0 -13
  51. package/dist/sitemap-BpYnSsfJ.mjs +0 -249
  52. package/dist/sitemap-server-D_0Kzanj.mjs +0 -1137
  53. package/dist/standards-discovery-C4HUqMd2.d.mts +0 -227
  54. package/dist/standards-discovery-C54V_aJH.mjs +0 -510
  55. package/dist/templates-Bq_P7ctv.mjs +0 -2465
  56. package/dist/types-EhFhYGfr.d.mts +0 -3305
  57. package/dist/upgrade-oz-GChgt.mjs +0 -56
  58. package/dist/utils-DpiIioYb.mjs +0 -225
@@ -1,221 +0,0 @@
1
- import { $ as renderDocsAgentsDocument, a as DEFAULT_AGENT_MD_ROUTE, at as resolveDocsAgentFeedbackConfig, b as DEFAULT_OPENAPI_SCHEMA_ROUTE, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE } from "./agent-Fl0pjVNF.mjs";
2
- import "./standards-discovery-C54V_aJH.mjs";
3
- import "./search-9OnMGMvt.mjs";
4
- import { S as resolveApiReferenceConfig } from "./sitemap-server-D_0Kzanj.mjs";
5
- import "./agent-evals-f4_OL10T.mjs";
6
- import { resolveDocsMcpConfig } from "./mcp.mjs";
7
- import "./code-blocks-DnNVNK2M.mjs";
8
- import "./agent-skills-server-CIeBszxp.mjs";
9
- import "./server.mjs";
10
- 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";
11
- import { t as detectFramework } from "./utils-DpiIioYb.mjs";
12
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
13
- import path from "node:path";
14
- import pc from "picocolors";
15
-
16
- //#region src/cli/agents.ts
17
- const AGENTS_GENERATED_MARKER = "<!-- Generated by @farming-labs/docs agents generate. -->";
18
- function parseInlineFlag(arg) {
19
- const [rawKey, value] = arg.slice(2).split("=", 2);
20
- return {
21
- key: rawKey.trim(),
22
- value
23
- };
24
- }
25
- function parseAgentsGenerateArgs(argv) {
26
- const parsed = {};
27
- for (let index = 0; index < argv.length; index += 1) {
28
- const arg = argv[index];
29
- if (arg === "--help" || arg === "-h") {
30
- parsed.help = true;
31
- continue;
32
- }
33
- if (arg === "--force") {
34
- parsed.force = true;
35
- continue;
36
- }
37
- if (arg === "--check") {
38
- parsed.check = true;
39
- continue;
40
- }
41
- if (arg.startsWith("--config=")) {
42
- const value = parseInlineFlag(arg).value;
43
- if (!value) throw new Error("Missing value for --config.");
44
- parsed.configPath = value;
45
- continue;
46
- }
47
- if (arg === "--config") {
48
- const value = argv[index + 1];
49
- if (!value || value.startsWith("--")) throw new Error("Missing value for --config.");
50
- parsed.configPath = value;
51
- index += 1;
52
- continue;
53
- }
54
- if (arg.startsWith("--path=")) {
55
- const value = parseInlineFlag(arg).value;
56
- if (!value) throw new Error("Missing value for --path.");
57
- parsed.path = value;
58
- continue;
59
- }
60
- if (arg === "--path") {
61
- const value = argv[index + 1];
62
- if (!value || value.startsWith("--")) throw new Error("Missing value for --path.");
63
- parsed.path = value;
64
- index += 1;
65
- continue;
66
- }
67
- if (!arg.startsWith("--") && !parsed.path) {
68
- parsed.path = arg;
69
- continue;
70
- }
71
- throw new Error(`Unknown agents generate flag: ${arg}.`);
72
- }
73
- return parsed;
74
- }
75
- function readTopLevelBooleanProperty(content, key) {
76
- const match = content.match(new RegExp(`\\b${key}\\b\\s*:\\s*(true|false)`));
77
- return match ? match[1] === "true" : void 0;
78
- }
79
- function readLlmsBaseUrlFromConfig(content, config) {
80
- if (config?.llmsTxt && typeof config.llmsTxt === "object") return config.llmsTxt.baseUrl;
81
- const block = extractNestedObjectLiteral(content, ["llmsTxt"]);
82
- return block ? readStringProperty(block, "baseUrl") : void 0;
83
- }
84
- function readSitemapBaseUrlFromConfig(content, config) {
85
- if (config?.sitemap && typeof config.sitemap === "object") return config.sitemap.baseUrl;
86
- const block = extractNestedObjectLiteral(content, ["sitemap"]);
87
- return block ? readStringProperty(block, "baseUrl") : void 0;
88
- }
89
- function readCloudApiRouteFromConfig(content, config) {
90
- if (typeof config?.cloud?.apiRoute === "string") return config.cloud.apiRoute;
91
- const block = extractNestedObjectLiteral(content, ["cloud"]);
92
- return block ? readStringProperty(block, "apiRoute") : void 0;
93
- }
94
- function readRobotsConfigFromStatic(content) {
95
- const topLevelBoolean = readTopLevelBooleanProperty(content, "robots");
96
- if (typeof topLevelBoolean === "boolean") return topLevelBoolean;
97
- const block = extractNestedObjectLiteral(content, ["robots"]);
98
- if (!block) return void 0;
99
- return { enabled: readBooleanProperty(block, "enabled") ?? true };
100
- }
101
- function resolvePublicDir(rootDir) {
102
- if (detectFramework(rootDir) === "sveltekit") return path.join(rootDir, "static");
103
- return path.join(rootDir, "public");
104
- }
105
- function resolveAgentsPath(rootDir, options) {
106
- if (options.path) return path.isAbsolute(options.path) ? options.path : path.resolve(rootDir, options.path);
107
- return path.join(rootDir, "AGENTS.md");
108
- }
109
- function publicFilePath(rootDir, route) {
110
- return path.join(resolvePublicDir(rootDir), route.replace(/^\/+/, ""));
111
- }
112
- function normalizeGeneratedContent(content) {
113
- return `${AGENTS_GENERATED_MARKER}\n${content.trimEnd()}\n`;
114
- }
115
- function normalizeCustomContent(content) {
116
- return content.endsWith("\n") ? content : `${content}\n`;
117
- }
118
- function isManagedAgentsFile(content) {
119
- return content.includes(AGENTS_GENERATED_MARKER);
120
- }
121
- function writeIfNeeded(filePath, content, options) {
122
- const current = existsSync(filePath) ? readFileSync(filePath, "utf-8") : void 0;
123
- if (current === content) return "current";
124
- if (current !== void 0 && !options.force && !isManagedAgentsFile(current)) return "kept";
125
- if (options.check) return "changed";
126
- mkdirSync(path.dirname(filePath), { recursive: true });
127
- writeFileSync(filePath, content, "utf-8");
128
- return "changed";
129
- }
130
- function resolveOpenApiDiscovery(config) {
131
- const apiReference = resolveApiReferenceConfig(config?.apiReference);
132
- if (!apiReference.enabled) return { enabled: false };
133
- return {
134
- enabled: true,
135
- url: DEFAULT_OPENAPI_SCHEMA_ROUTE,
136
- urlSource: "default",
137
- source: apiReference.specUrl ? "configured" : "generated",
138
- specUrl: apiReference.specUrl,
139
- apiReferencePath: `/${apiReference.path}`
140
- };
141
- }
142
- async function generateAgents(options = {}) {
143
- const rootDir = process.cwd();
144
- const loadedConfigModule = await loadDocsConfigModule(rootDir, options.configPath);
145
- const configContent = readFileSync(loadedConfigModule?.path ?? resolveDocsConfigPath(rootDir, options.configPath), "utf-8");
146
- const config = loadedConfigModule?.config;
147
- const entry = config?.entry ?? readTopLevelStringProperty(configContent, "entry") ?? "docs";
148
- const siteTitle = typeof config?.nav?.title === "string" ? config.nav.title : readNavTitle(configContent) ?? "Documentation";
149
- const siteDescription = typeof config?.metadata?.description === "string" ? config.metadata.description : void 0;
150
- const baseUrl = readLlmsBaseUrlFromConfig(configContent, config) ?? readSitemapBaseUrlFromConfig(configContent, config);
151
- const apiRoute = readCloudApiRouteFromConfig(configContent, config);
152
- const llmsTxt = config?.llmsTxt;
153
- const llmsEnabled = llmsTxt === false ? false : typeof llmsTxt === "object" ? llmsTxt.enabled ?? true : true;
154
- const llmsConfig = typeof llmsTxt === "object" ? llmsTxt : void 0;
155
- const robotsInput = config?.robots ?? readRobotsConfigFromStatic(configContent) ?? true;
156
- const rootAgentsPath = resolveAgentsPath(rootDir, options);
157
- const generatedContent = normalizeGeneratedContent(renderDocsAgentsDocument({
158
- origin: baseUrl ?? "http://localhost",
159
- entry,
160
- apiRoute,
161
- search: config?.search,
162
- mcp: resolveDocsMcpConfig(config?.mcp),
163
- feedback: resolveDocsAgentFeedbackConfig(config?.feedback),
164
- llms: {
165
- enabled: llmsEnabled,
166
- baseUrl,
167
- siteTitle,
168
- siteDescription,
169
- maxChars: llmsConfig?.maxChars,
170
- sections: llmsConfig?.sections
171
- },
172
- sitemap: config?.sitemap,
173
- robots: robotsInput,
174
- openapi: resolveOpenApiDiscovery(config),
175
- markdown: { acceptHeader: false }
176
- }));
177
- const existingRoot = existsSync(rootAgentsPath) ? readFileSync(rootAgentsPath, "utf-8") : null;
178
- const sourceContent = existingRoot !== null && !options.force && !isManagedAgentsFile(existingRoot) ? normalizeCustomContent(existingRoot) : generatedContent;
179
- const writes = [];
180
- const kept = [];
181
- const rootStatus = writeIfNeeded(rootAgentsPath, sourceContent, options);
182
- if (rootStatus === "changed") writes.push(rootAgentsPath);
183
- if (rootStatus === "kept") kept.push(rootAgentsPath);
184
- for (const route of [
185
- DEFAULT_AGENTS_MD_ROUTE,
186
- DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE,
187
- DEFAULT_AGENT_MD_ROUTE,
188
- DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE
189
- ]) {
190
- const filePath = publicFilePath(rootDir, route);
191
- const status = writeIfNeeded(filePath, sourceContent, options);
192
- if (status === "changed") writes.push(filePath);
193
- if (status === "kept") kept.push(filePath);
194
- }
195
- if (options.check && writes.length > 0) throw new Error("AGENTS.md output is stale. Run `docs agents generate` to update it.");
196
- const relativeRoot = path.relative(rootDir, rootAgentsPath).replace(/\\/g, "/");
197
- console.log(writes.length > 0 ? pc.green(`Generated agent instructions at ${relativeRoot}.`) : pc.green(`Agent instructions are current at ${relativeRoot}.`));
198
- for (const filePath of writes) {
199
- if (filePath === rootAgentsPath) continue;
200
- console.log(pc.dim(path.relative(rootDir, filePath).replace(/\\/g, "/")));
201
- }
202
- for (const filePath of kept) console.log(pc.yellow(`Kept user-owned ${path.relative(rootDir, filePath).replace(/\\/g, "/")}.`));
203
- }
204
- function printAgentsGenerateHelp() {
205
- console.log(`
206
- ${pc.bold("docs agents generate")} — Generate AGENTS.md instructions for coding agents.
207
-
208
- ${pc.dim("Usage:")}
209
- pnpm exec docs ${pc.cyan("agents generate")} ${pc.dim("[path]")}
210
-
211
- ${pc.dim("Options:")}
212
- ${pc.cyan("--path <path>")} Write the root instructions file; defaults to ${pc.dim("AGENTS.md")}
213
- ${pc.cyan("--force")} Replace existing AGENTS.md/static files
214
- ${pc.cyan("--check")} Fail if generated output would change
215
- ${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
216
- ${pc.cyan("-h, --help")} Show this help message
217
- `);
218
- }
219
-
220
- //#endregion
221
- export { generateAgents, parseAgentsGenerateArgs, printAgentsGenerateHelp };
@@ -1,177 +0,0 @@
1
- import { n as sendDocsCloudAnalyticsEvent, t as resolveDocsCloudAnalyticsOptions } from "./cloud-analytics-CSyFE6SS.mjs";
2
-
3
- //#region src/analytics.ts
4
- const ANALYTICS_LOG_PREFIX = "[@farming-labs/docs:analytics]";
5
- const OBSERVABILITY_LOG_PREFIX = "[@farming-labs/docs:observability]";
6
- const DOCS_AGENT_TRACE_EVENT_TYPES = [
7
- "run.start",
8
- "run.end",
9
- "run.error",
10
- "user.input",
11
- "prompt.build",
12
- "retrieval.query",
13
- "retrieval.result",
14
- "retrieval.error",
15
- "model.call",
16
- "model.response",
17
- "model.stream",
18
- "model.error",
19
- "tool.call",
20
- "tool.result",
21
- "tool.error",
22
- "retry",
23
- "timeout",
24
- "error",
25
- "agent.final"
26
- ];
27
- function composeAnalyticsHandlers(userOnEvent, cloudOnEvent) {
28
- if (typeof userOnEvent !== "function" && !cloudOnEvent) return;
29
- return async (event) => {
30
- let userError;
31
- if (typeof userOnEvent === "function") try {
32
- await userOnEvent(event);
33
- } catch (error) {
34
- userError = error;
35
- }
36
- if (cloudOnEvent) try {
37
- await cloudOnEvent(event);
38
- } catch {}
39
- if (typeof userError !== "undefined") throw userError;
40
- };
41
- }
42
- function resolveConsoleLevel(value, hasEventHandler) {
43
- if (value === false) return false;
44
- if (value === true) return "info";
45
- if (value === "log" || value === "info" || value === "debug") return value;
46
- return hasEventHandler ? false : "info";
47
- }
48
- function createDocsAgentTraceId(prefix = "trace") {
49
- return `${prefix.replace(/[^a-zA-Z0-9_-]/g, "_") || "trace"}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
50
- }
51
- function createDocsAgentTraceContext(name = "agent.run") {
52
- return {
53
- traceId: createDocsAgentTraceId("run"),
54
- name,
55
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
56
- startedMs: Date.now()
57
- };
58
- }
59
- function getDocsRequestAnalyticsProperties(request) {
60
- const userAgent = request.headers.get("user-agent")?.trim();
61
- return userAgent ? { userAgent } : {};
62
- }
63
- function resolveDocsAnalyticsConfig(analytics) {
64
- if (analytics === false) return {
65
- enabled: false,
66
- console: false,
67
- includeInputs: false
68
- };
69
- const cloudOptions = resolveDocsCloudAnalyticsOptions(analytics);
70
- const cloudOnEvent = cloudOptions ? async (event) => {
71
- await sendDocsCloudAnalyticsEvent(cloudOptions, event);
72
- } : void 0;
73
- if (!analytics) {
74
- if (!cloudOnEvent) return {
75
- enabled: false,
76
- console: false,
77
- includeInputs: false
78
- };
79
- return {
80
- enabled: true,
81
- console: false,
82
- includeInputs: false,
83
- onEvent: cloudOnEvent
84
- };
85
- }
86
- if (analytics === true) return {
87
- enabled: true,
88
- console: "info",
89
- includeInputs: false,
90
- onEvent: cloudOnEvent
91
- };
92
- const userOnEvent = analytics.onEvent;
93
- const hasEventHandler = typeof userOnEvent === "function" || Boolean(cloudOnEvent);
94
- const onEvent = composeAnalyticsHandlers(userOnEvent, cloudOnEvent);
95
- return {
96
- enabled: analytics.enabled !== false,
97
- console: resolveConsoleLevel(analytics.console, hasEventHandler),
98
- includeInputs: analytics.includeInputs === true,
99
- onEvent
100
- };
101
- }
102
- function resolveDocsObservabilityConfig(observability) {
103
- if (!observability) return {
104
- enabled: false,
105
- console: false,
106
- includeInputs: false
107
- };
108
- if (observability === true) return {
109
- enabled: true,
110
- console: "info",
111
- includeInputs: false
112
- };
113
- const hasEventHandler = typeof observability.onEvent === "function";
114
- return {
115
- enabled: observability.enabled !== false,
116
- console: resolveConsoleLevel(observability.console, hasEventHandler),
117
- includeInputs: observability.includeInputs === true,
118
- onEvent: observability.onEvent
119
- };
120
- }
121
- function normalizeAnalyticsEvent(event, config) {
122
- const normalized = {
123
- ...event,
124
- source: event.source ?? "server",
125
- timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
126
- };
127
- if (!config.includeInputs && normalized.input) delete normalized.input;
128
- return normalized;
129
- }
130
- function normalizeObservabilityEvent(event, config) {
131
- const normalized = {
132
- ...event,
133
- source: event.source ?? "server",
134
- timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
135
- };
136
- if (!config.includeInputs && normalized.input) delete normalized.input;
137
- return normalized;
138
- }
139
- async function emitDocsAnalyticsEvent(analytics, event) {
140
- const resolved = resolveDocsAnalyticsConfig(analytics);
141
- if (!resolved.enabled) return;
142
- const normalized = normalizeAnalyticsEvent(event, resolved);
143
- if (resolved.console) (console[resolved.console] ?? console.info).call(console, ANALYTICS_LOG_PREFIX, normalized);
144
- if (!resolved.onEvent) return;
145
- try {
146
- await resolved.onEvent(normalized);
147
- } catch (error) {
148
- if (resolved.console !== false) console.warn(`${ANALYTICS_LOG_PREFIX} onEvent failed`, error);
149
- }
150
- }
151
- async function emitDocsObservabilityEvent(observability, event) {
152
- const resolved = resolveDocsObservabilityConfig(observability);
153
- if (!resolved.enabled) return;
154
- const normalized = normalizeObservabilityEvent(event, resolved);
155
- if (resolved.console) (console[resolved.console] ?? console.info).call(console, OBSERVABILITY_LOG_PREFIX, normalized);
156
- if (!resolved.onEvent) return;
157
- try {
158
- await resolved.onEvent(normalized);
159
- } catch (error) {
160
- if (resolved.console !== false) console.warn(`${OBSERVABILITY_LOG_PREFIX} onEvent failed`, error);
161
- }
162
- }
163
- async function emitDocsAgentTraceEvent(observability, event) {
164
- const timestamp = event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
165
- await emitDocsObservabilityEvent(observability, {
166
- ...event,
167
- timestamp,
168
- source: event.source ?? "server",
169
- traceId: event.traceId ?? createDocsAgentTraceId("run"),
170
- spanId: event.spanId ?? createDocsAgentTraceId("span"),
171
- startedAt: event.startedAt ?? timestamp,
172
- status: event.status ?? "success"
173
- });
174
- }
175
-
176
- //#endregion
177
- export { emitDocsAnalyticsEvent as a, resolveDocsAnalyticsConfig as c, emitDocsAgentTraceEvent as i, resolveDocsObservabilityConfig as l, createDocsAgentTraceContext as n, emitDocsObservabilityEvent as o, createDocsAgentTraceId as r, getDocsRequestAnalyticsProperties as s, DOCS_AGENT_TRACE_EVENT_TYPES as t };
@@ -1,15 +0,0 @@
1
- //#region src/cli/errors.d.ts
2
- declare function formatCliError(error: unknown): string;
3
- //#endregion
4
- //#region src/cli/index.d.ts
5
- declare const UPGRADE_TAGS: readonly ["latest", "beta"];
6
- type UpgradeTag = (typeof UPGRADE_TAGS)[number];
7
- /** Normalize command aliases like `upgrade@beta` into the base command + dist-tag. */
8
- declare function parseCommandAlias(rawCommand?: string): {
9
- command?: string;
10
- tag?: UpgradeTag;
11
- };
12
- /** Parse flags like --template next, --name my-docs, --theme concrete, --entry docs, --framework astro (exported for tests). */
13
- declare function parseFlags(argv: string[]): Record<string, string | boolean | undefined>;
14
- //#endregion
15
- export { formatCliError, parseCommandAlias, parseFlags };