@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.
- package/README.md +1 -1
- package/package.json +11 -1
- package/dist/agent-BFqyqEnC.mjs +0 -4547
- package/dist/agent-DlxriaTs.mjs +0 -624
- package/dist/agent-evals-kJs2Y9xR.mjs +0 -2144
- package/dist/agent-export-BgUaiW8f.mjs +0 -869
- package/dist/agent-scope-CCaIY1aK.mjs +0 -283
- package/dist/agents-Djh-HXih.mjs +0 -219
- package/dist/analytics-Bx44lg6d.mjs +0 -177
- package/dist/cli/index.d.mts +0 -15
- package/dist/cli/index.mjs +0 -452
- package/dist/client/react.d.mts +0 -45
- package/dist/client/react.mjs +0 -223
- package/dist/cloud-BH_sHX64.mjs +0 -1615
- package/dist/cloud-analytics-CSyFE6SS.mjs +0 -132
- package/dist/cloud-ask-ai-B2WnG4fF.d.mts +0 -23
- package/dist/cloud-ask-ai-hnJfj8-X.mjs +0 -382
- package/dist/code-blocks-qe0T8-xe.mjs +0 -871
- package/dist/codeblocks-Bq67u32v.mjs +0 -250
- package/dist/config-DASewQ0x.mjs +0 -363
- package/dist/dev-DgY5xGl9.mjs +0 -1333
- package/dist/docs-cloud-server.d.mts +0 -70
- package/dist/docs-cloud-server.mjs +0 -310
- package/dist/doctor-CO1VMcF_.mjs +0 -1906
- package/dist/downgrade-BZs86NVr.mjs +0 -184
- package/dist/errors-CVqZ3kOO.mjs +0 -20
- package/dist/golden-evaluations-BN9u2wxw.mjs +0 -1483
- package/dist/i18n-CAlj1ADU.mjs +0 -40
- package/dist/index.d.mts +0 -1099
- package/dist/index.mjs +0 -9
- package/dist/init-Bd_k06bR.mjs +0 -1233
- package/dist/mcp-B_yXL5G5.mjs +0 -137
- package/dist/mcp.d.mts +0 -287
- package/dist/mcp.mjs +0 -4135
- package/dist/metadata-BDuewuzq.mjs +0 -237
- package/dist/package-version-qik_4J6C.mjs +0 -128
- package/dist/reading-time-BkEft6SD.mjs +0 -741
- package/dist/review-NC-sOdXn.mjs +0 -665
- package/dist/robots-DskPvGPw.mjs +0 -178
- package/dist/robots-ltltiLJF.mjs +0 -197
- package/dist/search-C1JitPwi.d.mts +0 -397
- package/dist/search-D57JXQLj.mjs +0 -1758
- package/dist/search-o4Ud6OXv.mjs +0 -102
- package/dist/server.d.mts +0 -341
- package/dist/server.mjs +0 -11
- package/dist/sitemap-Cq-Yj_iA.mjs +0 -247
- package/dist/sitemap-server-C1ibVKOy.mjs +0 -1137
- package/dist/templates-DNw15P-x.mjs +0 -2373
- package/dist/types-XHABMh_f.d.mts +0 -3248
- package/dist/upgrade-BCJTCW3O.mjs +0 -56
- package/dist/utils-6UCLxv4B.mjs +0 -225
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
//#region src/agent-scope.ts
|
|
2
|
-
/** Normalize framework aliases used by page metadata, agent contracts, MCP, and evaluations. */
|
|
3
|
-
function normalizeAgentFramework(value) {
|
|
4
|
-
const normalized = value.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
5
|
-
if ([
|
|
6
|
-
"next",
|
|
7
|
-
"nextjs",
|
|
8
|
-
"nextjsapp",
|
|
9
|
-
"reactnext"
|
|
10
|
-
].includes(normalized)) return "nextjs";
|
|
11
|
-
if ([
|
|
12
|
-
"tanstack",
|
|
13
|
-
"tanstackstart",
|
|
14
|
-
"start"
|
|
15
|
-
].includes(normalized)) return "tanstackstart";
|
|
16
|
-
if (["svelte", "sveltekit"].includes(normalized)) return "sveltekit";
|
|
17
|
-
if (["nuxt", "nuxtjs"].includes(normalized)) return "nuxt";
|
|
18
|
-
return normalized;
|
|
19
|
-
}
|
|
20
|
-
function normalizeAgentLocale(value) {
|
|
21
|
-
return value.trim().toLowerCase().replace(/_/gu, "-");
|
|
22
|
-
}
|
|
23
|
-
function normalizeAgentVersion(value) {
|
|
24
|
-
return value.trim().toLowerCase().replace(/^v(?=\d)/u, "");
|
|
25
|
-
}
|
|
26
|
-
function normalizeAgentScopeValues(value) {
|
|
27
|
-
const values = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
|
|
28
|
-
return Array.from(new Set(values.map((item) => item.trim()).filter(Boolean)));
|
|
29
|
-
}
|
|
30
|
-
function compareVersions(left, right) {
|
|
31
|
-
for (let index = 0; index < 3; index += 1) if (left[index] !== right[index]) return left[index] > right[index] ? 1 : -1;
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
function parseExactVersion(value) {
|
|
35
|
-
const match = normalizeAgentVersion(value).match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-[0-9a-z.-]+)?(?:\+[0-9a-z.-]+)?$/iu);
|
|
36
|
-
if (!match) return void 0;
|
|
37
|
-
return [
|
|
38
|
-
Number(match[1]),
|
|
39
|
-
Number(match[2] ?? 0),
|
|
40
|
-
Number(match[3] ?? 0)
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
function parseVersionOperand(value) {
|
|
44
|
-
const normalized = normalizeAgentVersion(value);
|
|
45
|
-
if (normalized === "*" || normalized === "x") return {
|
|
46
|
-
version: [
|
|
47
|
-
0,
|
|
48
|
-
0,
|
|
49
|
-
0
|
|
50
|
-
],
|
|
51
|
-
components: 0,
|
|
52
|
-
wildcard: true
|
|
53
|
-
};
|
|
54
|
-
const match = normalized.match(/^(\d+)(?:\.(\d+|x|\*))?(?:\.(\d+|x|\*))?$/iu);
|
|
55
|
-
if (!match) return void 0;
|
|
56
|
-
const raw = [
|
|
57
|
-
match[1],
|
|
58
|
-
match[2],
|
|
59
|
-
match[3]
|
|
60
|
-
];
|
|
61
|
-
const wildcardIndex = raw.findIndex((part, index) => index > 0 && (part?.toLowerCase() === "x" || part === "*"));
|
|
62
|
-
if (wildcardIndex >= 0 && raw.slice(wildcardIndex + 1).some((part) => part && part.toLowerCase() !== "x" && part !== "*")) return;
|
|
63
|
-
const components = wildcardIndex >= 0 ? wildcardIndex : raw.filter(Boolean).length;
|
|
64
|
-
return {
|
|
65
|
-
version: [
|
|
66
|
-
Number(raw[0]),
|
|
67
|
-
Number(raw[1] ?? 0) || 0,
|
|
68
|
-
Number(raw[2] ?? 0) || 0
|
|
69
|
-
],
|
|
70
|
-
components,
|
|
71
|
-
wildcard: wildcardIndex >= 0
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function nextVersionBoundary(operand) {
|
|
75
|
-
const [major, minor] = operand.version;
|
|
76
|
-
if (operand.components <= 0) return void 0;
|
|
77
|
-
if (operand.components === 1) return [
|
|
78
|
-
major + 1,
|
|
79
|
-
0,
|
|
80
|
-
0
|
|
81
|
-
];
|
|
82
|
-
return [
|
|
83
|
-
major,
|
|
84
|
-
minor + 1,
|
|
85
|
-
0
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
function operandRange(operand) {
|
|
89
|
-
if (operand.components === 0) return {
|
|
90
|
-
minimumInclusive: true,
|
|
91
|
-
maximumInclusive: false
|
|
92
|
-
};
|
|
93
|
-
if (operand.components < 3 || operand.wildcard) return {
|
|
94
|
-
minimum: operand.version,
|
|
95
|
-
minimumInclusive: true,
|
|
96
|
-
maximum: nextVersionBoundary(operand),
|
|
97
|
-
maximumInclusive: false
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
minimum: operand.version,
|
|
101
|
-
minimumInclusive: true,
|
|
102
|
-
maximum: operand.version,
|
|
103
|
-
maximumInclusive: true
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function caretRange(operand) {
|
|
107
|
-
const [major, minor, patch] = operand.version;
|
|
108
|
-
let maximum;
|
|
109
|
-
if (major > 0) maximum = [
|
|
110
|
-
major + 1,
|
|
111
|
-
0,
|
|
112
|
-
0
|
|
113
|
-
];
|
|
114
|
-
else if (operand.components <= 1) maximum = [
|
|
115
|
-
1,
|
|
116
|
-
0,
|
|
117
|
-
0
|
|
118
|
-
];
|
|
119
|
-
else if (minor > 0 || operand.components === 2) maximum = [
|
|
120
|
-
0,
|
|
121
|
-
minor + 1,
|
|
122
|
-
0
|
|
123
|
-
];
|
|
124
|
-
else maximum = [
|
|
125
|
-
0,
|
|
126
|
-
0,
|
|
127
|
-
patch + 1
|
|
128
|
-
];
|
|
129
|
-
return {
|
|
130
|
-
minimum: operand.version,
|
|
131
|
-
minimumInclusive: true,
|
|
132
|
-
maximum,
|
|
133
|
-
maximumInclusive: false
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function tildeRange(operand) {
|
|
137
|
-
const [major, minor] = operand.version;
|
|
138
|
-
const maximum = operand.components <= 1 ? [
|
|
139
|
-
major + 1,
|
|
140
|
-
0,
|
|
141
|
-
0
|
|
142
|
-
] : [
|
|
143
|
-
major,
|
|
144
|
-
minor + 1,
|
|
145
|
-
0
|
|
146
|
-
];
|
|
147
|
-
return {
|
|
148
|
-
minimum: operand.version,
|
|
149
|
-
minimumInclusive: true,
|
|
150
|
-
maximum,
|
|
151
|
-
maximumInclusive: false
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function intersectRanges(left, right) {
|
|
155
|
-
let minimum = left.minimum;
|
|
156
|
-
let minimumInclusive = left.minimumInclusive;
|
|
157
|
-
if (!minimum || right.minimum && compareVersions(right.minimum, minimum) > 0) {
|
|
158
|
-
minimum = right.minimum;
|
|
159
|
-
minimumInclusive = right.minimumInclusive;
|
|
160
|
-
} else if (right.minimum && compareVersions(right.minimum, minimum) === 0) minimumInclusive = minimumInclusive && right.minimumInclusive;
|
|
161
|
-
let maximum = left.maximum;
|
|
162
|
-
let maximumInclusive = left.maximumInclusive;
|
|
163
|
-
if (!maximum || right.maximum && compareVersions(right.maximum, maximum) < 0) {
|
|
164
|
-
maximum = right.maximum;
|
|
165
|
-
maximumInclusive = right.maximumInclusive;
|
|
166
|
-
} else if (right.maximum && compareVersions(right.maximum, maximum) === 0) maximumInclusive = maximumInclusive && right.maximumInclusive;
|
|
167
|
-
if (minimum && maximum) {
|
|
168
|
-
const compared = compareVersions(minimum, maximum);
|
|
169
|
-
if (compared > 0 || compared === 0 && !(minimumInclusive && maximumInclusive)) return void 0;
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
minimum,
|
|
173
|
-
minimumInclusive,
|
|
174
|
-
maximum,
|
|
175
|
-
maximumInclusive
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function comparatorRange(operator, operand) {
|
|
179
|
-
if (!operator || operator === "=") return operandRange(operand);
|
|
180
|
-
if (operator === ">=") return {
|
|
181
|
-
minimum: operand.version,
|
|
182
|
-
minimumInclusive: true,
|
|
183
|
-
maximumInclusive: false
|
|
184
|
-
};
|
|
185
|
-
if (operator === ">") {
|
|
186
|
-
const partialBoundary = operand.components < 3 ? nextVersionBoundary(operand) : void 0;
|
|
187
|
-
return {
|
|
188
|
-
minimum: partialBoundary ?? operand.version,
|
|
189
|
-
minimumInclusive: Boolean(partialBoundary),
|
|
190
|
-
maximumInclusive: false
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (operator === "<") return {
|
|
194
|
-
minimumInclusive: true,
|
|
195
|
-
maximum: operand.version,
|
|
196
|
-
maximumInclusive: false
|
|
197
|
-
};
|
|
198
|
-
const partialBoundary = operand.components < 3 ? nextVersionBoundary(operand) : void 0;
|
|
199
|
-
return {
|
|
200
|
-
minimumInclusive: true,
|
|
201
|
-
maximum: partialBoundary ?? operand.version,
|
|
202
|
-
maximumInclusive: !partialBoundary
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function parseVersionRangeBranch(value) {
|
|
206
|
-
const branch = normalizeAgentVersion(value).trim();
|
|
207
|
-
if (!branch) return void 0;
|
|
208
|
-
const hyphen = branch.match(/^(.+?)\s+-\s+(.+)$/u);
|
|
209
|
-
if (hyphen) {
|
|
210
|
-
const minimumOperand = parseVersionOperand(hyphen[1]);
|
|
211
|
-
const maximumOperand = parseVersionOperand(hyphen[2]);
|
|
212
|
-
if (!minimumOperand || !maximumOperand) return void 0;
|
|
213
|
-
const maximumBoundary = maximumOperand.components < 3 ? nextVersionBoundary(maximumOperand) : maximumOperand.version;
|
|
214
|
-
return intersectRanges({
|
|
215
|
-
minimum: minimumOperand.version,
|
|
216
|
-
minimumInclusive: true,
|
|
217
|
-
maximumInclusive: false
|
|
218
|
-
}, {
|
|
219
|
-
minimumInclusive: true,
|
|
220
|
-
maximum: maximumBoundary,
|
|
221
|
-
maximumInclusive: maximumOperand.components === 3
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
const special = branch.match(/^(\^|~)\s*(.+)$/u);
|
|
225
|
-
if (special) {
|
|
226
|
-
const operand = parseVersionOperand(special[2]);
|
|
227
|
-
if (!operand || operand.components === 0) return void 0;
|
|
228
|
-
return special[1] === "^" ? caretRange(operand) : tildeRange(operand);
|
|
229
|
-
}
|
|
230
|
-
const comparators = Array.from(branch.matchAll(/(>=|<=|>|<|=)\s*([^\s]+)/gu));
|
|
231
|
-
if (comparators.length > 0) {
|
|
232
|
-
if (comparators.map((match) => match[0]).join(" ").replace(/\s+/gu, " ") !== branch.replace(/\s+/gu, " ")) return void 0;
|
|
233
|
-
let range = {
|
|
234
|
-
minimumInclusive: true,
|
|
235
|
-
maximumInclusive: false
|
|
236
|
-
};
|
|
237
|
-
for (const comparator of comparators) {
|
|
238
|
-
const operand = parseVersionOperand(comparator[2]);
|
|
239
|
-
if (!operand) return void 0;
|
|
240
|
-
const next = intersectRanges(range, comparatorRange(comparator[1], operand));
|
|
241
|
-
if (!next) return void 0;
|
|
242
|
-
range = next;
|
|
243
|
-
}
|
|
244
|
-
return range;
|
|
245
|
-
}
|
|
246
|
-
const operand = parseVersionOperand(branch);
|
|
247
|
-
return operand ? operandRange(operand) : void 0;
|
|
248
|
-
}
|
|
249
|
-
function parseVersionRanges(value) {
|
|
250
|
-
return normalizeAgentVersion(value).split("||").map((branch) => parseVersionRangeBranch(branch)).filter((range) => Boolean(range));
|
|
251
|
-
}
|
|
252
|
-
function rangeContains(range, version) {
|
|
253
|
-
if (range.minimum) {
|
|
254
|
-
const compared = compareVersions(version, range.minimum);
|
|
255
|
-
if (compared < 0 || compared === 0 && !range.minimumInclusive) return false;
|
|
256
|
-
}
|
|
257
|
-
if (range.maximum) {
|
|
258
|
-
const compared = compareVersions(version, range.maximum);
|
|
259
|
-
if (compared > 0 || compared === 0 && !range.maximumInclusive) return false;
|
|
260
|
-
}
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
function rangesOverlap(left, right) {
|
|
264
|
-
return Boolean(intersectRanges(left, right));
|
|
265
|
-
}
|
|
266
|
-
/** Match an exact requested version against an exact or range-like documented constraint. */
|
|
267
|
-
function agentVersionConstraintMatches(requested, constraint) {
|
|
268
|
-
if (normalizeAgentVersion(requested) === normalizeAgentVersion(constraint)) return Boolean(normalizeAgentVersion(requested));
|
|
269
|
-
const wanted = parseExactVersion(requested);
|
|
270
|
-
if (!wanted) return false;
|
|
271
|
-
return parseVersionRanges(constraint).some((range) => rangeContains(range, wanted));
|
|
272
|
-
}
|
|
273
|
-
/** Return true when two exact or range-like documented version constraints can select one version. */
|
|
274
|
-
function agentVersionConstraintsOverlap(left, right) {
|
|
275
|
-
const normalizedLeft = normalizeAgentVersion(left);
|
|
276
|
-
if (normalizedLeft === normalizeAgentVersion(right)) return Boolean(normalizedLeft);
|
|
277
|
-
const leftRanges = parseVersionRanges(left);
|
|
278
|
-
const rightRanges = parseVersionRanges(right);
|
|
279
|
-
return leftRanges.some((leftRange) => rightRanges.some((rightRange) => rangesOverlap(leftRange, rightRange)));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
//#endregion
|
|
283
|
-
export { normalizeAgentScopeValues as a, normalizeAgentLocale as i, agentVersionConstraintsOverlap as n, normalizeAgentVersion as o, normalizeAgentFramework as r, agentVersionConstraintMatches as t };
|
package/dist/agents-Djh-HXih.mjs
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { C as DEFAULT_OPENAPI_SCHEMA_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, lt as resolveDocsAgentFeedbackConfig, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, rt as renderDocsAgentsDocument, t as DEFAULT_AGENTS_MD_ROUTE } from "./agent-BFqyqEnC.mjs";
|
|
2
|
-
import "./search-D57JXQLj.mjs";
|
|
3
|
-
import { S as resolveApiReferenceConfig } from "./sitemap-server-C1ibVKOy.mjs";
|
|
4
|
-
import "./agent-evals-kJs2Y9xR.mjs";
|
|
5
|
-
import { resolveDocsMcpConfig } from "./mcp.mjs";
|
|
6
|
-
import "./code-blocks-qe0T8-xe.mjs";
|
|
7
|
-
import "./server.mjs";
|
|
8
|
-
import { d as readStringProperty, i as loadDocsConfigModule, l as readNavTitle, m as resolveDocsConfigPath, p as readTopLevelStringProperty, s as readBooleanProperty, t as extractNestedObjectLiteral } from "./config-DASewQ0x.mjs";
|
|
9
|
-
import { t as detectFramework } from "./utils-6UCLxv4B.mjs";
|
|
10
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import pc from "picocolors";
|
|
13
|
-
|
|
14
|
-
//#region src/cli/agents.ts
|
|
15
|
-
const AGENTS_GENERATED_MARKER = "<!-- Generated by @farming-labs/docs agents generate. -->";
|
|
16
|
-
function parseInlineFlag(arg) {
|
|
17
|
-
const [rawKey, value] = arg.slice(2).split("=", 2);
|
|
18
|
-
return {
|
|
19
|
-
key: rawKey.trim(),
|
|
20
|
-
value
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function parseAgentsGenerateArgs(argv) {
|
|
24
|
-
const parsed = {};
|
|
25
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
26
|
-
const arg = argv[index];
|
|
27
|
-
if (arg === "--help" || arg === "-h") {
|
|
28
|
-
parsed.help = true;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (arg === "--force") {
|
|
32
|
-
parsed.force = true;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (arg === "--check") {
|
|
36
|
-
parsed.check = true;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (arg.startsWith("--config=")) {
|
|
40
|
-
const value = parseInlineFlag(arg).value;
|
|
41
|
-
if (!value) throw new Error("Missing value for --config.");
|
|
42
|
-
parsed.configPath = value;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (arg === "--config") {
|
|
46
|
-
const value = argv[index + 1];
|
|
47
|
-
if (!value || value.startsWith("--")) throw new Error("Missing value for --config.");
|
|
48
|
-
parsed.configPath = value;
|
|
49
|
-
index += 1;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (arg.startsWith("--path=")) {
|
|
53
|
-
const value = parseInlineFlag(arg).value;
|
|
54
|
-
if (!value) throw new Error("Missing value for --path.");
|
|
55
|
-
parsed.path = value;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (arg === "--path") {
|
|
59
|
-
const value = argv[index + 1];
|
|
60
|
-
if (!value || value.startsWith("--")) throw new Error("Missing value for --path.");
|
|
61
|
-
parsed.path = value;
|
|
62
|
-
index += 1;
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (!arg.startsWith("--") && !parsed.path) {
|
|
66
|
-
parsed.path = arg;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
throw new Error(`Unknown agents generate flag: ${arg}.`);
|
|
70
|
-
}
|
|
71
|
-
return parsed;
|
|
72
|
-
}
|
|
73
|
-
function readTopLevelBooleanProperty(content, key) {
|
|
74
|
-
const match = content.match(new RegExp(`\\b${key}\\b\\s*:\\s*(true|false)`));
|
|
75
|
-
return match ? match[1] === "true" : void 0;
|
|
76
|
-
}
|
|
77
|
-
function readLlmsBaseUrlFromConfig(content, config) {
|
|
78
|
-
if (config?.llmsTxt && typeof config.llmsTxt === "object") return config.llmsTxt.baseUrl;
|
|
79
|
-
const block = extractNestedObjectLiteral(content, ["llmsTxt"]);
|
|
80
|
-
return block ? readStringProperty(block, "baseUrl") : void 0;
|
|
81
|
-
}
|
|
82
|
-
function readSitemapBaseUrlFromConfig(content, config) {
|
|
83
|
-
if (config?.sitemap && typeof config.sitemap === "object") return config.sitemap.baseUrl;
|
|
84
|
-
const block = extractNestedObjectLiteral(content, ["sitemap"]);
|
|
85
|
-
return block ? readStringProperty(block, "baseUrl") : void 0;
|
|
86
|
-
}
|
|
87
|
-
function readCloudApiRouteFromConfig(content, config) {
|
|
88
|
-
if (typeof config?.cloud?.apiRoute === "string") return config.cloud.apiRoute;
|
|
89
|
-
const block = extractNestedObjectLiteral(content, ["cloud"]);
|
|
90
|
-
return block ? readStringProperty(block, "apiRoute") : void 0;
|
|
91
|
-
}
|
|
92
|
-
function readRobotsConfigFromStatic(content) {
|
|
93
|
-
const topLevelBoolean = readTopLevelBooleanProperty(content, "robots");
|
|
94
|
-
if (typeof topLevelBoolean === "boolean") return topLevelBoolean;
|
|
95
|
-
const block = extractNestedObjectLiteral(content, ["robots"]);
|
|
96
|
-
if (!block) return void 0;
|
|
97
|
-
return { enabled: readBooleanProperty(block, "enabled") ?? true };
|
|
98
|
-
}
|
|
99
|
-
function resolvePublicDir(rootDir) {
|
|
100
|
-
if (detectFramework(rootDir) === "sveltekit") return path.join(rootDir, "static");
|
|
101
|
-
return path.join(rootDir, "public");
|
|
102
|
-
}
|
|
103
|
-
function resolveAgentsPath(rootDir, options) {
|
|
104
|
-
if (options.path) return path.isAbsolute(options.path) ? options.path : path.resolve(rootDir, options.path);
|
|
105
|
-
return path.join(rootDir, "AGENTS.md");
|
|
106
|
-
}
|
|
107
|
-
function publicFilePath(rootDir, route) {
|
|
108
|
-
return path.join(resolvePublicDir(rootDir), route.replace(/^\/+/, ""));
|
|
109
|
-
}
|
|
110
|
-
function normalizeGeneratedContent(content) {
|
|
111
|
-
return `${AGENTS_GENERATED_MARKER}\n${content.trimEnd()}\n`;
|
|
112
|
-
}
|
|
113
|
-
function normalizeCustomContent(content) {
|
|
114
|
-
return content.endsWith("\n") ? content : `${content}\n`;
|
|
115
|
-
}
|
|
116
|
-
function isManagedAgentsFile(content) {
|
|
117
|
-
return content.includes(AGENTS_GENERATED_MARKER);
|
|
118
|
-
}
|
|
119
|
-
function writeIfNeeded(filePath, content, options) {
|
|
120
|
-
const current = existsSync(filePath) ? readFileSync(filePath, "utf-8") : void 0;
|
|
121
|
-
if (current === content) return "current";
|
|
122
|
-
if (current !== void 0 && !options.force && !isManagedAgentsFile(current)) return "kept";
|
|
123
|
-
if (options.check) return "changed";
|
|
124
|
-
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
125
|
-
writeFileSync(filePath, content, "utf-8");
|
|
126
|
-
return "changed";
|
|
127
|
-
}
|
|
128
|
-
function resolveOpenApiDiscovery(config) {
|
|
129
|
-
const apiReference = resolveApiReferenceConfig(config?.apiReference);
|
|
130
|
-
if (!apiReference.enabled) return { enabled: false };
|
|
131
|
-
return {
|
|
132
|
-
enabled: true,
|
|
133
|
-
url: DEFAULT_OPENAPI_SCHEMA_ROUTE,
|
|
134
|
-
urlSource: "default",
|
|
135
|
-
source: apiReference.specUrl ? "configured" : "generated",
|
|
136
|
-
specUrl: apiReference.specUrl,
|
|
137
|
-
apiReferencePath: `/${apiReference.path}`
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
async function generateAgents(options = {}) {
|
|
141
|
-
const rootDir = process.cwd();
|
|
142
|
-
const loadedConfigModule = await loadDocsConfigModule(rootDir, options.configPath);
|
|
143
|
-
const configContent = readFileSync(loadedConfigModule?.path ?? resolveDocsConfigPath(rootDir, options.configPath), "utf-8");
|
|
144
|
-
const config = loadedConfigModule?.config;
|
|
145
|
-
const entry = config?.entry ?? readTopLevelStringProperty(configContent, "entry") ?? "docs";
|
|
146
|
-
const siteTitle = typeof config?.nav?.title === "string" ? config.nav.title : readNavTitle(configContent) ?? "Documentation";
|
|
147
|
-
const siteDescription = typeof config?.metadata?.description === "string" ? config.metadata.description : void 0;
|
|
148
|
-
const baseUrl = readLlmsBaseUrlFromConfig(configContent, config) ?? readSitemapBaseUrlFromConfig(configContent, config);
|
|
149
|
-
const apiRoute = readCloudApiRouteFromConfig(configContent, config);
|
|
150
|
-
const llmsTxt = config?.llmsTxt;
|
|
151
|
-
const llmsEnabled = llmsTxt === false ? false : typeof llmsTxt === "object" ? llmsTxt.enabled ?? true : true;
|
|
152
|
-
const llmsConfig = typeof llmsTxt === "object" ? llmsTxt : void 0;
|
|
153
|
-
const robotsInput = config?.robots ?? readRobotsConfigFromStatic(configContent) ?? true;
|
|
154
|
-
const rootAgentsPath = resolveAgentsPath(rootDir, options);
|
|
155
|
-
const generatedContent = normalizeGeneratedContent(renderDocsAgentsDocument({
|
|
156
|
-
origin: baseUrl ?? "http://localhost",
|
|
157
|
-
entry,
|
|
158
|
-
apiRoute,
|
|
159
|
-
search: config?.search,
|
|
160
|
-
mcp: resolveDocsMcpConfig(config?.mcp),
|
|
161
|
-
feedback: resolveDocsAgentFeedbackConfig(config?.feedback),
|
|
162
|
-
llms: {
|
|
163
|
-
enabled: llmsEnabled,
|
|
164
|
-
baseUrl,
|
|
165
|
-
siteTitle,
|
|
166
|
-
siteDescription,
|
|
167
|
-
maxChars: llmsConfig?.maxChars,
|
|
168
|
-
sections: llmsConfig?.sections
|
|
169
|
-
},
|
|
170
|
-
sitemap: config?.sitemap,
|
|
171
|
-
robots: robotsInput,
|
|
172
|
-
openapi: resolveOpenApiDiscovery(config),
|
|
173
|
-
markdown: { acceptHeader: false }
|
|
174
|
-
}));
|
|
175
|
-
const existingRoot = existsSync(rootAgentsPath) ? readFileSync(rootAgentsPath, "utf-8") : null;
|
|
176
|
-
const sourceContent = existingRoot !== null && !options.force && !isManagedAgentsFile(existingRoot) ? normalizeCustomContent(existingRoot) : generatedContent;
|
|
177
|
-
const writes = [];
|
|
178
|
-
const kept = [];
|
|
179
|
-
const rootStatus = writeIfNeeded(rootAgentsPath, sourceContent, options);
|
|
180
|
-
if (rootStatus === "changed") writes.push(rootAgentsPath);
|
|
181
|
-
if (rootStatus === "kept") kept.push(rootAgentsPath);
|
|
182
|
-
for (const route of [
|
|
183
|
-
DEFAULT_AGENTS_MD_ROUTE,
|
|
184
|
-
DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE,
|
|
185
|
-
DEFAULT_AGENT_MD_ROUTE,
|
|
186
|
-
DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE
|
|
187
|
-
]) {
|
|
188
|
-
const filePath = publicFilePath(rootDir, route);
|
|
189
|
-
const status = writeIfNeeded(filePath, sourceContent, options);
|
|
190
|
-
if (status === "changed") writes.push(filePath);
|
|
191
|
-
if (status === "kept") kept.push(filePath);
|
|
192
|
-
}
|
|
193
|
-
if (options.check && writes.length > 0) throw new Error("AGENTS.md output is stale. Run `docs agents generate` to update it.");
|
|
194
|
-
const relativeRoot = path.relative(rootDir, rootAgentsPath).replace(/\\/g, "/");
|
|
195
|
-
console.log(writes.length > 0 ? pc.green(`Generated agent instructions at ${relativeRoot}.`) : pc.green(`Agent instructions are current at ${relativeRoot}.`));
|
|
196
|
-
for (const filePath of writes) {
|
|
197
|
-
if (filePath === rootAgentsPath) continue;
|
|
198
|
-
console.log(pc.dim(path.relative(rootDir, filePath).replace(/\\/g, "/")));
|
|
199
|
-
}
|
|
200
|
-
for (const filePath of kept) console.log(pc.yellow(`Kept user-owned ${path.relative(rootDir, filePath).replace(/\\/g, "/")}.`));
|
|
201
|
-
}
|
|
202
|
-
function printAgentsGenerateHelp() {
|
|
203
|
-
console.log(`
|
|
204
|
-
${pc.bold("docs agents generate")} — Generate AGENTS.md instructions for coding agents.
|
|
205
|
-
|
|
206
|
-
${pc.dim("Usage:")}
|
|
207
|
-
pnpm exec docs ${pc.cyan("agents generate")} ${pc.dim("[path]")}
|
|
208
|
-
|
|
209
|
-
${pc.dim("Options:")}
|
|
210
|
-
${pc.cyan("--path <path>")} Write the root instructions file; defaults to ${pc.dim("AGENTS.md")}
|
|
211
|
-
${pc.cyan("--force")} Replace existing AGENTS.md/static files
|
|
212
|
-
${pc.cyan("--check")} Fail if generated output would change
|
|
213
|
-
${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
|
|
214
|
-
${pc.cyan("-h, --help")} Show this help message
|
|
215
|
-
`);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
//#endregion
|
|
219
|
-
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 };
|
package/dist/cli/index.d.mts
DELETED
|
@@ -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 };
|