@farming-labs/docs 0.2.62 → 0.2.63

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/dist/agent-CQTH7NFu.mjs +624 -0
  2. package/dist/agent-DKKptIgy.mjs +4365 -0
  3. package/dist/agent-evals-B7MIxuEX.mjs +2144 -0
  4. package/dist/agent-export-CBgWgPvH.mjs +910 -0
  5. package/dist/agent-scope-C_U--OZ7.mjs +283 -0
  6. package/dist/agent-skills-bundle.d.mts +13 -0
  7. package/dist/agent-skills-bundle.mjs +12 -0
  8. package/dist/agent-skills-server-CPja6Syt.d.mts +14 -0
  9. package/dist/agent-skills-server-DraIb6FV.mjs +415 -0
  10. package/dist/agent-skills-vite.d.mts +31 -0
  11. package/dist/agent-skills-vite.mjs +70 -0
  12. package/dist/agents-XWZBub6f.mjs +221 -0
  13. package/dist/analytics-Bx44lg6d.mjs +177 -0
  14. package/dist/cli/index.d.mts +15 -0
  15. package/dist/cli/index.mjs +452 -0
  16. package/dist/client/react.d.mts +45 -0
  17. package/dist/client/react.mjs +223 -0
  18. package/dist/cloud-analytics-CSyFE6SS.mjs +132 -0
  19. package/dist/cloud-ask-ai-sbpjOR2K.mjs +382 -0
  20. package/dist/cloud-ask-ai-zpwkdwnF.d.mts +23 -0
  21. package/dist/cloud-pdNC-tyj.mjs +1615 -0
  22. package/dist/code-blocks-DnNVNK2M.mjs +871 -0
  23. package/dist/codeblocks-CFuurVIH.mjs +250 -0
  24. package/dist/config-Wcdj-D0a.mjs +369 -0
  25. package/dist/dev-Cmy6DtdF.mjs +1333 -0
  26. package/dist/docs-cloud-server.d.mts +70 -0
  27. package/dist/docs-cloud-server.mjs +310 -0
  28. package/dist/doctor-CJqtzKZT.mjs +2036 -0
  29. package/dist/downgrade-w7e6Se0L.mjs +184 -0
  30. package/dist/errors-DbOhkE1h.mjs +20 -0
  31. package/dist/golden-evaluations-Dsvh0etV.mjs +1503 -0
  32. package/dist/i18n-CCaFUnAN.mjs +40 -0
  33. package/dist/index.d.mts +1150 -0
  34. package/dist/index.mjs +10 -0
  35. package/dist/init-CQY0Woe3.mjs +1264 -0
  36. package/dist/mcp-B9dcsivk.mjs +156 -0
  37. package/dist/mcp.d.mts +298 -0
  38. package/dist/mcp.mjs +4430 -0
  39. package/dist/metadata-DWExHQnx.mjs +237 -0
  40. package/dist/package-version-n5AFur8a.mjs +128 -0
  41. package/dist/reading-time-CYZ5VvKU.mjs +742 -0
  42. package/dist/review-Fndl5brR.mjs +673 -0
  43. package/dist/robots-BIpC4j4P.mjs +201 -0
  44. package/dist/robots-CUTahhoY.mjs +179 -0
  45. package/dist/search-B6V6qtiI.mjs +1826 -0
  46. package/dist/search-CaSyi6H6.d.mts +279 -0
  47. package/dist/search-DSjCeOk7.mjs +104 -0
  48. package/dist/server.d.mts +343 -0
  49. package/dist/server.mjs +14 -0
  50. package/dist/sitemap-Cykpe3Tz.mjs +249 -0
  51. package/dist/sitemap-server-C_6Wes83.mjs +1137 -0
  52. package/dist/standards-discovery-C4HUqMd2.d.mts +227 -0
  53. package/dist/standards-discovery-jkykaXq1.mjs +519 -0
  54. package/dist/templates-Bq_P7ctv.mjs +2465 -0
  55. package/dist/types-lMBIdZg0.d.mts +3315 -0
  56. package/dist/upgrade-oz-GChgt.mjs +56 -0
  57. package/dist/utils-DpiIioYb.mjs +225 -0
  58. package/package.json +1 -1
@@ -0,0 +1,184 @@
1
+ import { c as fileExists, o as exec, s as execOutput } from "./utils-DpiIioYb.mjs";
2
+ import { a as getPackagesForFramework, c as resolveDocsPackageManager, l as validateUpgradeVersion, r as buildDocsPackageInstallCommand, s as resolveDocsPackageFramework } from "./package-version-n5AFur8a.mjs";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import pc from "picocolors";
6
+ import * as p from "@clack/prompts";
7
+
8
+ //#region src/cli/downgrade.ts
9
+ /**
10
+ * Downgrade @farming-labs/* packages to a lower exact version.
11
+ * Detects framework from package.json by default, or use --framework (next, tanstack-start, nuxt, sveltekit, astro).
12
+ */
13
+ function parseSemver(version) {
14
+ const normalized = validateUpgradeVersion(version).split("+", 1)[0] ?? version;
15
+ const prereleaseIndex = normalized.indexOf("-");
16
+ const core = prereleaseIndex === -1 ? normalized : normalized.slice(0, prereleaseIndex);
17
+ const prerelease = prereleaseIndex === -1 ? "" : normalized.slice(prereleaseIndex + 1);
18
+ const [major = "0", minor = "0", patch = "0"] = core.split(".");
19
+ return {
20
+ major: Number.parseInt(major, 10),
21
+ minor: Number.parseInt(minor, 10),
22
+ patch: Number.parseInt(patch, 10),
23
+ prerelease: prerelease ? prerelease.split(".") : []
24
+ };
25
+ }
26
+ function comparePrereleaseIdentifier(a, b) {
27
+ const aNumber = /^\d+$/.test(a) ? Number.parseInt(a, 10) : null;
28
+ const bNumber = /^\d+$/.test(b) ? Number.parseInt(b, 10) : null;
29
+ if (aNumber !== null && bNumber !== null) return Math.sign(aNumber - bNumber);
30
+ if (aNumber !== null) return -1;
31
+ if (bNumber !== null) return 1;
32
+ return a.localeCompare(b);
33
+ }
34
+ function compareSemver(a, b) {
35
+ const left = parseSemver(a);
36
+ const right = parseSemver(b);
37
+ for (const key of [
38
+ "major",
39
+ "minor",
40
+ "patch"
41
+ ]) if (left[key] !== right[key]) return Math.sign(left[key] - right[key]);
42
+ if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0;
43
+ if (left.prerelease.length === 0) return 1;
44
+ if (right.prerelease.length === 0) return -1;
45
+ const length = Math.max(left.prerelease.length, right.prerelease.length);
46
+ for (let index = 0; index < length; index++) {
47
+ const leftPart = left.prerelease[index];
48
+ const rightPart = right.prerelease[index];
49
+ if (leftPart === void 0) return -1;
50
+ if (rightPart === void 0) return 1;
51
+ const compared = comparePrereleaseIdentifier(leftPart, rightPart);
52
+ if (compared !== 0) return compared;
53
+ }
54
+ return 0;
55
+ }
56
+ function normalizeMaybeVersion(value) {
57
+ try {
58
+ return validateUpgradeVersion(value);
59
+ } catch {
60
+ return null;
61
+ }
62
+ }
63
+ function extractVersionFromSpec(spec) {
64
+ const exact = normalizeMaybeVersion(spec);
65
+ if (exact) return exact;
66
+ const rangeMatch = spec.match(/^[~^]([^~^<>=|\s]+)/);
67
+ if (!rangeMatch) return null;
68
+ return normalizeMaybeVersion(rangeMatch[1] ?? "");
69
+ }
70
+ function readJsonFile(filePath) {
71
+ try {
72
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
73
+ } catch {
74
+ return null;
75
+ }
76
+ }
77
+ function packageJsonPath(cwd, packageName) {
78
+ return path.join(cwd, "node_modules", ...packageName.split("/"), "package.json");
79
+ }
80
+ function readCurrentPackageVersion(cwd, packageNames) {
81
+ for (const packageName of packageNames) {
82
+ const installedPackageJson = readJsonFile(packageJsonPath(cwd, packageName));
83
+ const installedVersion = typeof installedPackageJson?.version === "string" ? normalizeMaybeVersion(installedPackageJson.version) : null;
84
+ if (installedVersion) return installedVersion;
85
+ }
86
+ const projectPackageJson = readJsonFile(path.join(cwd, "package.json"));
87
+ const dependencyGroups = [
88
+ projectPackageJson?.dependencies,
89
+ projectPackageJson?.devDependencies,
90
+ projectPackageJson?.peerDependencies
91
+ ];
92
+ for (const group of dependencyGroups) {
93
+ if (!group || typeof group !== "object") continue;
94
+ for (const packageName of packageNames) {
95
+ const spec = group[packageName];
96
+ if (typeof spec !== "string") continue;
97
+ const version = extractVersionFromSpec(spec);
98
+ if (version) return version;
99
+ }
100
+ }
101
+ return null;
102
+ }
103
+ function parsePublishedVersions(raw) {
104
+ const parsed = JSON.parse(raw);
105
+ return (Array.isArray(parsed) ? parsed : [parsed]).filter((version) => typeof version === "string").map((version) => normalizeMaybeVersion(version)).filter((version) => version !== null);
106
+ }
107
+ function getPreviousVersion(versions, currentVersion) {
108
+ const current = validateUpgradeVersion(currentVersion);
109
+ return versions.filter((version) => compareSemver(version, current) < 0).sort(compareSemver).at(-1) ?? null;
110
+ }
111
+ function fetchPublishedVersions(cwd) {
112
+ return parsePublishedVersions(execOutput("npm view @farming-labs/docs versions --json", cwd));
113
+ }
114
+ function buildDowngradeCommand(framework, version, pm) {
115
+ return buildDocsPackageInstallCommand(framework, validateUpgradeVersion(version), pm);
116
+ }
117
+ async function downgrade(options = {}) {
118
+ const cwd = process.cwd();
119
+ p.intro(pc.bgCyan(pc.black(" @farming-labs/docs downgrade ")));
120
+ if (!fileExists(path.join(cwd, "package.json"))) {
121
+ p.log.error("No package.json found in the current directory. Run this from your project root.");
122
+ process.exit(1);
123
+ }
124
+ const { framework, preset } = resolveDocsPackageFramework(cwd, options.framework);
125
+ const packages = getPackagesForFramework(framework);
126
+ const currentVersion = readCurrentPackageVersion(cwd, packages);
127
+ if (!currentVersion) {
128
+ p.log.error("Could not determine the current @farming-labs docs package version. Install dependencies first or use an exact package version in package.json.");
129
+ process.exit(1);
130
+ }
131
+ let targetVersion;
132
+ if (options.version !== void 0) {
133
+ try {
134
+ targetVersion = validateUpgradeVersion(options.version);
135
+ } catch (error) {
136
+ p.log.error(error instanceof Error ? error.message : "Invalid downgrade version.");
137
+ process.exit(1);
138
+ }
139
+ const comparison = compareSemver(targetVersion, currentVersion);
140
+ if (comparison > 0) {
141
+ p.log.error(`Version ${pc.cyan(targetVersion)} is newer than current ${pc.cyan(currentVersion)}.`);
142
+ p.log.info(`Use ${pc.cyan(`docs upgrade --version ${targetVersion}`)} instead.`);
143
+ process.exit(1);
144
+ }
145
+ if (comparison === 0) {
146
+ p.log.error(`Version ${pc.cyan(targetVersion)} is already installed. Choose a lower version to downgrade.`);
147
+ process.exit(1);
148
+ }
149
+ } else {
150
+ let publishedVersions;
151
+ try {
152
+ publishedVersions = fetchPublishedVersions(cwd);
153
+ } catch {
154
+ p.log.error("Could not fetch published @farming-labs/docs versions. Pass an exact version with " + pc.cyan("--version <version>") + ".");
155
+ process.exit(1);
156
+ }
157
+ const previousVersion = getPreviousVersion(publishedVersions, currentVersion);
158
+ if (!previousVersion) {
159
+ p.log.error(`No published version found below current ${pc.cyan(currentVersion)}.`);
160
+ process.exit(1);
161
+ }
162
+ targetVersion = previousVersion;
163
+ }
164
+ const pm = await resolveDocsPackageManager(cwd, "downgrade");
165
+ const cmd = buildDowngradeCommand(framework, targetVersion, pm);
166
+ p.log.step(`Downgrading ${preset} docs packages from ${currentVersion} to ${targetVersion}...`);
167
+ p.log.message(pc.dim(packages.join(", ")));
168
+ if (options.dryRun) {
169
+ p.log.info("Dry run. Would run:\n " + pc.cyan(cmd));
170
+ p.outro(pc.green("Dry run complete. No changes made."));
171
+ return;
172
+ }
173
+ try {
174
+ exec(cmd, cwd);
175
+ p.log.success(`Packages downgraded to ${targetVersion}.`);
176
+ p.outro(pc.green("Done. Run your dev server to confirm everything works."));
177
+ } catch {
178
+ p.log.error("Downgrade failed. Try running manually:\n " + pc.cyan(cmd));
179
+ process.exit(1);
180
+ }
181
+ }
182
+
183
+ //#endregion
184
+ export { downgrade };
@@ -0,0 +1,20 @@
1
+ //#region src/cli/errors.ts
2
+ const CLI_ERROR_REPORTED_KEY = "__farmingLabsDocsCliErrorReported";
3
+ function formatCliError(error) {
4
+ if (error instanceof Error && error.message.trim()) return error.message.trim();
5
+ if (typeof error === "string" && error.trim()) return error.trim();
6
+ return "An unexpected error occurred.";
7
+ }
8
+ function markCliErrorReported(error) {
9
+ if (error && typeof error === "object") error[CLI_ERROR_REPORTED_KEY] = true;
10
+ }
11
+ function wasCliErrorReported(error) {
12
+ return Boolean(error && typeof error === "object" && error[CLI_ERROR_REPORTED_KEY] === true);
13
+ }
14
+ function shouldPrintStackTrace(env = process.env) {
15
+ const debug = env.DOCS_DEBUG ?? env.DEBUG;
16
+ return debug === "1" || debug === "true" || debug === "@farming-labs/docs";
17
+ }
18
+
19
+ //#endregion
20
+ export { wasCliErrorReported as i, markCliErrorReported as n, shouldPrintStackTrace as r, formatCliError as t };