@farming-labs/docs 0.2.60 → 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 (51) hide show
  1. package/README.md +1 -1
  2. package/package.json +11 -1
  3. package/dist/agent-BFqyqEnC.mjs +0 -4547
  4. package/dist/agent-DlxriaTs.mjs +0 -624
  5. package/dist/agent-evals-kJs2Y9xR.mjs +0 -2144
  6. package/dist/agent-export-BgUaiW8f.mjs +0 -869
  7. package/dist/agent-scope-CCaIY1aK.mjs +0 -283
  8. package/dist/agents-Djh-HXih.mjs +0 -219
  9. package/dist/analytics-Bx44lg6d.mjs +0 -177
  10. package/dist/cli/index.d.mts +0 -15
  11. package/dist/cli/index.mjs +0 -452
  12. package/dist/client/react.d.mts +0 -45
  13. package/dist/client/react.mjs +0 -223
  14. package/dist/cloud-BH_sHX64.mjs +0 -1615
  15. package/dist/cloud-analytics-CSyFE6SS.mjs +0 -132
  16. package/dist/cloud-ask-ai-B2WnG4fF.d.mts +0 -23
  17. package/dist/cloud-ask-ai-hnJfj8-X.mjs +0 -382
  18. package/dist/code-blocks-qe0T8-xe.mjs +0 -871
  19. package/dist/codeblocks-Bq67u32v.mjs +0 -250
  20. package/dist/config-DASewQ0x.mjs +0 -363
  21. package/dist/dev-DgY5xGl9.mjs +0 -1333
  22. package/dist/docs-cloud-server.d.mts +0 -70
  23. package/dist/docs-cloud-server.mjs +0 -310
  24. package/dist/doctor-CO1VMcF_.mjs +0 -1906
  25. package/dist/downgrade-BZs86NVr.mjs +0 -184
  26. package/dist/errors-CVqZ3kOO.mjs +0 -20
  27. package/dist/golden-evaluations-BN9u2wxw.mjs +0 -1483
  28. package/dist/i18n-CAlj1ADU.mjs +0 -40
  29. package/dist/index.d.mts +0 -1099
  30. package/dist/index.mjs +0 -9
  31. package/dist/init-Bd_k06bR.mjs +0 -1233
  32. package/dist/mcp-B_yXL5G5.mjs +0 -137
  33. package/dist/mcp.d.mts +0 -287
  34. package/dist/mcp.mjs +0 -4135
  35. package/dist/metadata-BDuewuzq.mjs +0 -237
  36. package/dist/package-version-qik_4J6C.mjs +0 -128
  37. package/dist/reading-time-BkEft6SD.mjs +0 -741
  38. package/dist/review-NC-sOdXn.mjs +0 -665
  39. package/dist/robots-DskPvGPw.mjs +0 -178
  40. package/dist/robots-ltltiLJF.mjs +0 -197
  41. package/dist/search-C1JitPwi.d.mts +0 -397
  42. package/dist/search-D57JXQLj.mjs +0 -1758
  43. package/dist/search-o4Ud6OXv.mjs +0 -102
  44. package/dist/server.d.mts +0 -341
  45. package/dist/server.mjs +0 -11
  46. package/dist/sitemap-Cq-Yj_iA.mjs +0 -247
  47. package/dist/sitemap-server-C1ibVKOy.mjs +0 -1137
  48. package/dist/templates-DNw15P-x.mjs +0 -2373
  49. package/dist/types-XHABMh_f.d.mts +0 -3248
  50. package/dist/upgrade-BCJTCW3O.mjs +0 -56
  51. package/dist/utils-6UCLxv4B.mjs +0 -225
@@ -1,237 +0,0 @@
1
- import { _n as hasStructuredPageAgentContract, vn as normalizePageAgentFrontmatter } from "./agent-BFqyqEnC.mjs";
2
-
3
- //#region src/metadata.ts
4
- /**
5
- * Resolve page title using metadata titleTemplate.
6
- * %s is replaced with page title.
7
- */
8
- function resolveTitle(pageTitle, metadata) {
9
- return (metadata?.titleTemplate ?? "%s").replace("%s", pageTitle);
10
- }
11
- /**
12
- * Resolve OG image URL for a page.
13
- * Prefers page.openGraph.images[0], then page.ogImage, then config endpoint/default.
14
- */
15
- function resolveOGImage(page, ogConfig, baseUrl) {
16
- if (page.openGraph?.images?.length) return resolveImageUrl(page.openGraph.images[0].url, baseUrl);
17
- if (!ogConfig?.enabled) return void 0;
18
- if (page.ogImage) return resolveImageUrl(page.ogImage, baseUrl);
19
- if (ogConfig.type === "dynamic" && ogConfig.endpoint) return `${baseUrl ?? ""}${ogConfig.endpoint}`;
20
- return ogConfig.defaultImage;
21
- }
22
- function resolveImageUrl(url, baseUrl) {
23
- if (url.startsWith("/") || url.startsWith("http")) return url;
24
- const base = baseUrl ?? "";
25
- return `${base}${base.length > 0 && !base.endsWith("/") ? "/" : ""}${url}`;
26
- }
27
- /**
28
- * Build the Open Graph metadata object for a page.
29
- * When the page has openGraph in frontmatter, uses it (with title/description filled from page if omitted).
30
- * Otherwise uses ogImage or config (dynamic endpoint / defaultImage).
31
- */
32
- function buildPageOpenGraph(page, ogConfig, baseUrl) {
33
- if (page.openGraph) {
34
- const images = page.openGraph.images?.length ? page.openGraph.images.map((img) => ({
35
- url: resolveImageUrl(img.url, baseUrl),
36
- width: img.width ?? 1200,
37
- height: img.height ?? 630
38
- })) : void 0;
39
- return {
40
- title: page.openGraph.title ?? page.title,
41
- description: page.openGraph.description ?? page.description,
42
- ...images && { images }
43
- };
44
- }
45
- const url = resolveOGImage(page, ogConfig, baseUrl);
46
- if (!url) return void 0;
47
- return {
48
- title: page.title,
49
- ...page.description && { description: page.description },
50
- images: [{
51
- url,
52
- width: 1200,
53
- height: 630
54
- }]
55
- };
56
- }
57
- /**
58
- * Build the Twitter card metadata object for a page.
59
- * When the page has twitter in frontmatter, uses it.
60
- * Otherwise builds from ogImage or config (dynamic endpoint).
61
- */
62
- function buildPageTwitter(page, ogConfig, baseUrl) {
63
- if (page.twitter) {
64
- const images = page.twitter.images?.length ? page.twitter.images.map((url) => resolveImageUrl(url, baseUrl)) : void 0;
65
- return {
66
- ...page.twitter.card && { card: page.twitter.card },
67
- ...page.twitter.title !== void 0 && { title: page.twitter.title },
68
- ...page.twitter.description !== void 0 && { description: page.twitter.description },
69
- ...images && { images }
70
- };
71
- }
72
- const url = resolveOGImage(page, ogConfig, baseUrl);
73
- if (!url) return void 0;
74
- return {
75
- card: "summary_large_image",
76
- title: page.title,
77
- ...page.description && { description: page.description },
78
- images: [url]
79
- };
80
- }
81
- function normalizeBaseUrl(value) {
82
- if (!value) return void 0;
83
- try {
84
- const url = new URL(value);
85
- if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
86
- return url.toString().replace(/\/+$/, "");
87
- } catch {
88
- return;
89
- }
90
- }
91
- function absolutizeUrl(url, baseUrl) {
92
- const base = normalizeBaseUrl(baseUrl);
93
- if (!base) return url;
94
- try {
95
- return new URL(url, `${base}/`).toString();
96
- } catch {
97
- return url;
98
- }
99
- }
100
- function titleFromSegment(segment) {
101
- return segment.replace(/\.[a-z0-9]+$/i, "").replace(/[-_]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
102
- }
103
- function normalizeRoutePath(url) {
104
- try {
105
- return new URL(url, "https://farming-labs.local").pathname.replace(/\/+$/, "") || "/";
106
- } catch {
107
- return `/${url.replace(/^\/+/, "")}`.replace(/\/+$/, "") || "/";
108
- }
109
- }
110
- function buildDefaultBreadcrumbs(input) {
111
- const routePath = normalizeRoutePath(input.url);
112
- const entry = (input.entry ?? "docs").replace(/^\/+|\/+$/g, "") || "docs";
113
- const segments = routePath.split("/").filter(Boolean);
114
- const entryParts = entry.split("/").filter(Boolean);
115
- const contentSegments = segments.slice(0, entryParts.length).join("/") === entryParts.join("/") ? segments.slice(entryParts.length) : segments;
116
- const breadcrumbs = [{
117
- name: titleFromSegment(entryParts[entryParts.length - 1] ?? "Docs"),
118
- url: `/${entry}`
119
- }];
120
- let current = `/${entry}`;
121
- contentSegments.forEach((segment, index) => {
122
- current = `${current}/${segment}`.replace(/\/+/g, "/");
123
- breadcrumbs.push({
124
- name: index === contentSegments.length - 1 ? input.title : titleFromSegment(segment),
125
- url: current
126
- });
127
- });
128
- return breadcrumbs;
129
- }
130
- function normalizeDateModified(value) {
131
- if (!value) return void 0;
132
- const date = new Date(value);
133
- return Number.isNaN(date.getTime()) ? value : date.toISOString();
134
- }
135
- function buildAgentContractHowTo(value, fallback) {
136
- const agent = normalizePageAgentFrontmatter(value);
137
- if (!agent || !hasStructuredPageAgentContract(agent)) return void 0;
138
- const steps = [];
139
- for (const command of agent.commands ?? []) {
140
- const run = typeof command === "string" ? command : command.run;
141
- const description = typeof command === "string" ? void 0 : command.description;
142
- const cwd = typeof command === "string" ? void 0 : command.cwd;
143
- steps.push({
144
- "@type": "HowToStep",
145
- position: steps.length + 1,
146
- name: description ?? "Run command",
147
- text: cwd ? `${run} (from ${cwd})` : run
148
- });
149
- }
150
- for (const verification of agent.verification ?? []) {
151
- const description = typeof verification === "string" ? verification : verification.description ?? "Verify the result";
152
- const details = typeof verification === "string" ? verification : [verification.run, verification.expect ? `Expected: ${verification.expect}` : void 0].filter(Boolean).join(". ");
153
- steps.push({
154
- "@type": "HowToStep",
155
- position: steps.length + 1,
156
- name: description,
157
- text: details || description
158
- });
159
- }
160
- const supplies = [...(agent.prerequisites ?? []).map((name) => ({
161
- "@type": "HowToSupply",
162
- name
163
- })), ...(agent.files ?? []).map((name) => ({
164
- "@type": "HowToSupply",
165
- name
166
- }))];
167
- const about = Object.entries(agent.appliesTo ?? {}).flatMap(([kind, values]) => (typeof values === "string" ? [values] : values ?? []).map((name) => ({
168
- "@type": "Thing",
169
- name: `${kind}: ${name}`
170
- })));
171
- return {
172
- "@type": "HowTo",
173
- name: agent.task ?? fallback.title,
174
- ...agent.outcome ?? fallback.description ? { description: agent.outcome ?? fallback.description } : {},
175
- ...about.length > 0 ? { about } : {},
176
- ...supplies.length > 0 ? { supply: supplies } : {},
177
- ...steps.length > 0 ? { step: steps } : {}
178
- };
179
- }
180
- /**
181
- * Resolve the public docs site URL from existing agent-facing config.
182
- *
183
- * The framework intentionally reuses `sitemap.baseUrl`, `llmsTxt.baseUrl`,
184
- * `robots.baseUrl`, or `ai.docsUrl` instead of requiring another setting.
185
- */
186
- function resolveDocsMetadataBaseUrl(config) {
187
- return [
188
- typeof config.sitemap === "object" ? config.sitemap.baseUrl : void 0,
189
- typeof config.llmsTxt === "object" ? config.llmsTxt.baseUrl : void 0,
190
- typeof config.robots === "object" ? config.robots.baseUrl : void 0,
191
- config.ai?.docsUrl
192
- ].map((value) => normalizeBaseUrl(value)).find((value) => Boolean(value));
193
- }
194
- /**
195
- * Build Schema.org JSON-LD for a docs page.
196
- *
197
- * The shape follows Vercel's agent readability guidance: a `TechArticle`
198
- * with title, description, canonical URL, freshness, and breadcrumbs.
199
- */
200
- function buildDocsPageStructuredData(input) {
201
- const breadcrumbs = input.breadcrumbs?.length ? input.breadcrumbs : buildDefaultBreadcrumbs(input);
202
- const result = {
203
- "@context": "https://schema.org",
204
- "@type": "TechArticle",
205
- headline: input.title,
206
- name: input.title,
207
- url: absolutizeUrl(input.url, input.baseUrl),
208
- mainEntityOfPage: {
209
- "@type": "WebPage",
210
- "@id": absolutizeUrl(input.url, input.baseUrl)
211
- },
212
- breadcrumb: {
213
- "@type": "BreadcrumbList",
214
- itemListElement: breadcrumbs.map((item, index) => ({
215
- "@type": "ListItem",
216
- position: index + 1,
217
- name: item.name,
218
- item: absolutizeUrl(item.url, input.baseUrl)
219
- }))
220
- }
221
- };
222
- if (input.description) result.description = input.description;
223
- const agentContract = buildAgentContractHowTo(input.agent, input);
224
- if (agentContract) result.mainEntity = agentContract;
225
- const dateModified = normalizeDateModified(input.dateModified);
226
- if (dateModified) result.dateModified = dateModified;
227
- return result;
228
- }
229
- /**
230
- * Serialize Schema.org JSON-LD for safe insertion into a `<script>` tag.
231
- */
232
- function renderDocsPageStructuredDataJson(input) {
233
- return JSON.stringify(buildDocsPageStructuredData(input)).replace(/</g, "\\u003c");
234
- }
235
-
236
- //#endregion
237
- export { resolveDocsMetadataBaseUrl as a, renderDocsPageStructuredDataJson as i, buildPageOpenGraph as n, resolveOGImage as o, buildPageTwitter as r, resolveTitle as s, buildDocsPageStructuredData as t };
@@ -1,128 +0,0 @@
1
- import { i as detectPackageManagerFromProject, l as formatPackageManagerDetection, t as detectFramework, u as installCommand } from "./utils-6UCLxv4B.mjs";
2
- import pc from "picocolors";
3
- import * as p from "@clack/prompts";
4
-
5
- //#region src/cli/package-version.ts
6
- const PRESETS = [
7
- "next",
8
- "tanstack-start",
9
- "nuxt",
10
- "sveltekit",
11
- "astro"
12
- ];
13
- const PACKAGES_BY_FRAMEWORK = {
14
- nextjs: [
15
- "@farming-labs/docs",
16
- "@farming-labs/theme",
17
- "@farming-labs/next"
18
- ],
19
- "tanstack-start": [
20
- "@farming-labs/docs",
21
- "@farming-labs/theme",
22
- "@farming-labs/tanstack-start"
23
- ],
24
- nuxt: [
25
- "@farming-labs/docs",
26
- "@farming-labs/nuxt",
27
- "@farming-labs/nuxt-theme",
28
- "@farming-labs/theme"
29
- ],
30
- sveltekit: [
31
- "@farming-labs/docs",
32
- "@farming-labs/svelte",
33
- "@farming-labs/svelte-theme",
34
- "@farming-labs/theme"
35
- ],
36
- astro: [
37
- "@farming-labs/docs",
38
- "@farming-labs/astro",
39
- "@farming-labs/astro-theme",
40
- "@farming-labs/theme"
41
- ]
42
- };
43
- function presetFromFramework(fw) {
44
- return fw === "nextjs" ? "next" : fw;
45
- }
46
- function frameworkFromPreset(preset) {
47
- return preset === "next" ? "nextjs" : preset;
48
- }
49
- function getPackagesForFramework(framework) {
50
- return PACKAGES_BY_FRAMEWORK[framework];
51
- }
52
- const exactSemverPattern = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
53
- function validateUpgradeVersion(version) {
54
- const normalized = version.trim();
55
- if (!exactSemverPattern.test(normalized)) throw new Error(`Invalid version "${version}". Use an exact semver version like 0.1.104.`);
56
- return normalized;
57
- }
58
- function buildDocsPackageInstallCommand(framework, target, pm) {
59
- const packagesWithTarget = getPackagesForFramework(framework).map((name) => `${name}@${target}`);
60
- return `${installCommand(pm)} ${packagesWithTarget.join(" ")}`;
61
- }
62
- function resolveDocsPackageFramework(cwd, rawFramework) {
63
- if (rawFramework) {
64
- const raw = rawFramework.toLowerCase().trim();
65
- const normalized = raw === "nextjs" ? "next" : raw;
66
- if (!PRESETS.includes(normalized)) {
67
- p.log.error(`Invalid framework ${pc.cyan(rawFramework)}. Use one of: ${PRESETS.map((t) => pc.cyan(t)).join(", ")}`);
68
- process.exit(1);
69
- }
70
- const preset = normalized;
71
- return {
72
- framework: frameworkFromPreset(preset),
73
- preset
74
- };
75
- }
76
- const detected = detectFramework(cwd);
77
- if (!detected) {
78
- p.log.error("Could not detect a supported framework (Next.js, TanStack Start, Nuxt, SvelteKit, Astro). Use " + pc.cyan("--framework <next|tanstack-start|nuxt|sveltekit|astro>") + " to specify.");
79
- process.exit(1);
80
- }
81
- return {
82
- framework: detected,
83
- preset: presetFromFramework(detected)
84
- };
85
- }
86
- async function resolveDocsPackageManager(cwd, command) {
87
- const detected = detectPackageManagerFromProject(cwd);
88
- if (detected) {
89
- p.log.info(`Detected ${pc.cyan(detected.packageManager)} from ${formatPackageManagerDetection(cwd, detected)}`);
90
- return detected.packageManager;
91
- }
92
- const pmAnswer = await p.select({
93
- message: `Which package manager do you want to use for this ${command}?`,
94
- options: [
95
- {
96
- value: "pnpm",
97
- label: "pnpm",
98
- hint: "Use pnpm add"
99
- },
100
- {
101
- value: "npm",
102
- label: "npm",
103
- hint: "Use npm add"
104
- },
105
- {
106
- value: "yarn",
107
- label: "yarn",
108
- hint: "Use yarn add"
109
- },
110
- {
111
- value: "bun",
112
- label: "bun",
113
- hint: "Use bun add"
114
- }
115
- ]
116
- });
117
- if (p.isCancel(pmAnswer)) {
118
- const label = command === "upgrade" ? "Upgrade" : "Downgrade";
119
- p.outro(pc.red(`${label} cancelled.`));
120
- process.exit(0);
121
- }
122
- const pm = pmAnswer;
123
- p.log.info(`Using ${pc.cyan(pm)} as package manager`);
124
- return pm;
125
- }
126
-
127
- //#endregion
128
- export { getPackagesForFramework as a, resolveDocsPackageManager as c, frameworkFromPreset as i, validateUpgradeVersion as l, PRESETS as n, presetFromFramework as o, buildDocsPackageInstallCommand as r, resolveDocsPackageFramework as s, PACKAGES_BY_FRAMEWORK as t };