@farming-labs/docs 0.1.119 → 0.1.121
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-D8DpCgt_.mjs → agent-ByXnegrS.mjs} +3 -3
- package/dist/{agents-XyolXdXp.mjs → agents-CpTNRbsh.mjs} +2 -2
- package/dist/cli/index.mjs +33 -15
- package/dist/{dev-FC6Fh7nT.mjs → dev-C03tUSTz.mjs} +2 -2
- package/dist/{doctor-CU4knIej.mjs → doctor-DMs3Q0wj.mjs} +4 -4
- package/dist/{downgrade-Bt4yrVyy.mjs → downgrade-Bv7E5LV2.mjs} +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/{init-BgzyLAay.mjs → init-_HAuo5Dv.mjs} +2 -2
- package/dist/{mcp-BMgH1Q33.mjs → mcp-DojNlB8t.mjs} +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/{package-version-DQgrHnSb.mjs → package-version-L4GZowaF.mjs} +1 -1
- package/dist/{reading-time-DNLXwuqA.mjs → reading-time-Io7iRZ7S.mjs} +2 -1
- package/dist/review-BouPBEHv.mjs +475 -0
- package/dist/review-SngQ_dxy.mjs +563 -0
- package/dist/{robots-Byj0knC3.mjs → robots-BxZaiGH3.mjs} +2 -2
- package/dist/{search-BQ1cY913.mjs → search-DKpKe0rf.mjs} +1 -1
- package/dist/{search-Dqu1Q27e.d.mts → search-DSgDbYBT.d.mts} +1 -1
- package/dist/server.d.mts +67 -3
- package/dist/server.mjs +2 -1
- package/dist/{sitemap-mqWvYODL.mjs → sitemap-CXwYOIIb.mjs} +2 -2
- package/dist/{types-Dts3a32G.d.mts → types-CHD7M60f.d.mts} +105 -1
- package/dist/{upgrade-B1EMfRQJ.mjs → upgrade-DrOWQIKI.mjs} +2 -2
- package/package.json +1 -1
- /package/dist/{config-Cio3byUJ.mjs → config-BHRL4R2v.mjs} +0 -0
- /package/dist/{templates-CkL3bEE5.mjs → templates-CakZBXK8.mjs} +0 -0
- /package/dist/{utils-TPe8H1P-.mjs → utils-x5EtYWjC.mjs} +0 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/review.ts
|
|
5
|
+
const DEFAULT_DOCS_REVIEW_WORKFLOW_PATH = ".github/workflows/docs-review.yml";
|
|
6
|
+
const DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD = 80;
|
|
7
|
+
const DEFAULT_DOCS_REVIEW_CI_NAME = "docs-review";
|
|
8
|
+
const DEFAULT_REVIEW_RULES = {
|
|
9
|
+
brokenLinks: "error",
|
|
10
|
+
frontmatter: "error",
|
|
11
|
+
duplicateSlugs: "error",
|
|
12
|
+
invalidMdx: "error",
|
|
13
|
+
configExamples: "warn",
|
|
14
|
+
codeFenceMetadata: "warn",
|
|
15
|
+
runnableMetadata: "warn",
|
|
16
|
+
agentContext: "suggestion"
|
|
17
|
+
};
|
|
18
|
+
const DEFAULT_REVIEW_WEIGHTS = {
|
|
19
|
+
error: 20,
|
|
20
|
+
warn: 8,
|
|
21
|
+
suggestion: 2
|
|
22
|
+
};
|
|
23
|
+
const REVIEW_SEVERITIES = new Set([
|
|
24
|
+
"off",
|
|
25
|
+
"suggestion",
|
|
26
|
+
"warn",
|
|
27
|
+
"error"
|
|
28
|
+
]);
|
|
29
|
+
const REVIEW_CI_MODES = new Set([
|
|
30
|
+
"off",
|
|
31
|
+
"warn",
|
|
32
|
+
"block"
|
|
33
|
+
]);
|
|
34
|
+
const FILE_EXTS = [
|
|
35
|
+
"tsx",
|
|
36
|
+
"ts",
|
|
37
|
+
"jsx",
|
|
38
|
+
"js"
|
|
39
|
+
];
|
|
40
|
+
function resolveDocsReviewConfig(review) {
|
|
41
|
+
if (review === false) return {
|
|
42
|
+
enabled: false,
|
|
43
|
+
ci: {
|
|
44
|
+
enabled: false,
|
|
45
|
+
name: DEFAULT_DOCS_REVIEW_CI_NAME,
|
|
46
|
+
mode: "off",
|
|
47
|
+
annotations: false,
|
|
48
|
+
comment: false
|
|
49
|
+
},
|
|
50
|
+
score: {
|
|
51
|
+
threshold: DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD,
|
|
52
|
+
weights: DEFAULT_REVIEW_WEIGHTS
|
|
53
|
+
},
|
|
54
|
+
rules: DEFAULT_REVIEW_RULES
|
|
55
|
+
};
|
|
56
|
+
const objectConfig = review && typeof review === "object" ? review : {};
|
|
57
|
+
const ciConfig = objectConfig.ci;
|
|
58
|
+
const ciObject = ciConfig && typeof ciConfig === "object" ? ciConfig : {};
|
|
59
|
+
const configuredMode = ciObject.mode;
|
|
60
|
+
const mode = configuredMode && REVIEW_CI_MODES.has(configuredMode) ? configuredMode : "warn";
|
|
61
|
+
const enabled = objectConfig.enabled !== false;
|
|
62
|
+
const ciEnabled = enabled && ciConfig !== false && ciObject.enabled !== false && mode !== "off";
|
|
63
|
+
return {
|
|
64
|
+
enabled,
|
|
65
|
+
ci: {
|
|
66
|
+
enabled: ciEnabled,
|
|
67
|
+
name: normalizeCiName(ciObject.name),
|
|
68
|
+
mode: ciEnabled ? mode : "off",
|
|
69
|
+
annotations: ciObject.annotations !== false,
|
|
70
|
+
comment: ciObject.comment !== false
|
|
71
|
+
},
|
|
72
|
+
score: {
|
|
73
|
+
threshold: clampScoreThreshold(objectConfig.score?.threshold),
|
|
74
|
+
weights: {
|
|
75
|
+
error: normalizeWeight(objectConfig.score?.weights?.error, DEFAULT_REVIEW_WEIGHTS.error),
|
|
76
|
+
warn: normalizeWeight(objectConfig.score?.weights?.warn, DEFAULT_REVIEW_WEIGHTS.warn),
|
|
77
|
+
suggestion: normalizeWeight(objectConfig.score?.weights?.suggestion, DEFAULT_REVIEW_WEIGHTS.suggestion)
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
rules: {
|
|
81
|
+
...DEFAULT_REVIEW_RULES,
|
|
82
|
+
...normalizeRules(objectConfig.rules)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function buildDocsReviewWorkflow(options = {}) {
|
|
87
|
+
const packageManager = options.packageManager ?? "npm";
|
|
88
|
+
const ciName = normalizeCiName(options.ciName);
|
|
89
|
+
const projectDir = normalizeProjectDir(options.projectDir);
|
|
90
|
+
const configArg = options.configPath ? ` --config ${shellQuote(options.configPath)}` : "";
|
|
91
|
+
const reviewCommand = `${options.reviewCommand ?? reviewCommandForPackageManager(packageManager)} review --ci${configArg}`;
|
|
92
|
+
const filters = normalizePathFilters(options.pathFilters);
|
|
93
|
+
const installSteps = buildInstallSteps(packageManager);
|
|
94
|
+
const buildStep = options.buildCommand ? `\n - name: Build docs CLI\n run: ${options.buildCommand}\n` : "";
|
|
95
|
+
const workingDirectoryLine = projectDir === "." ? "" : `\n working-directory: ${projectDir}`;
|
|
96
|
+
return `# Generated by @farming-labs/docs. You can edit this file.
|
|
97
|
+
name: Docs Review
|
|
98
|
+
|
|
99
|
+
on:
|
|
100
|
+
pull_request:
|
|
101
|
+
paths:
|
|
102
|
+
${filters.map((filter) => ` - ${JSON.stringify(filter)}`).join("\n")}
|
|
103
|
+
|
|
104
|
+
permissions:
|
|
105
|
+
contents: read
|
|
106
|
+
checks: write
|
|
107
|
+
pull-requests: write
|
|
108
|
+
|
|
109
|
+
jobs:
|
|
110
|
+
docs-review:
|
|
111
|
+
name: ${JSON.stringify(ciName)}
|
|
112
|
+
runs-on: ubuntu-latest
|
|
113
|
+
steps:
|
|
114
|
+
- uses: actions/checkout@v4
|
|
115
|
+
with:
|
|
116
|
+
fetch-depth: 0
|
|
117
|
+
|
|
118
|
+
${installSteps}
|
|
119
|
+
${buildStep}
|
|
120
|
+
|
|
121
|
+
- name: Review docs
|
|
122
|
+
run: ${reviewCommand}${workingDirectoryLine}
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
function ensureDocsReviewWorkflow(options) {
|
|
126
|
+
const rootDir = options.rootDir;
|
|
127
|
+
const repoRoot = findGitRoot(rootDir) ?? rootDir;
|
|
128
|
+
const workflowRelativePath = options.workflowPath ?? DEFAULT_DOCS_REVIEW_WORKFLOW_PATH;
|
|
129
|
+
const workflowPath = isAbsolute(workflowRelativePath) ? workflowRelativePath : join(repoRoot, workflowRelativePath);
|
|
130
|
+
const resultRelativePath = toPosixPath(relative(repoRoot, workflowPath));
|
|
131
|
+
const review = resolveDocsReviewConfig(options.config?.review ?? readDocsReviewConfigFromSource(options.configContent ?? readConfig(rootDir)));
|
|
132
|
+
if (!review.enabled || !review.ci.enabled) return {
|
|
133
|
+
status: "disabled",
|
|
134
|
+
path: workflowPath,
|
|
135
|
+
relativePath: resultRelativePath
|
|
136
|
+
};
|
|
137
|
+
if (existsSync(workflowPath)) return {
|
|
138
|
+
status: "exists",
|
|
139
|
+
path: workflowPath,
|
|
140
|
+
relativePath: resultRelativePath
|
|
141
|
+
};
|
|
142
|
+
const configPath = options.configPath ?? findDocsConfigPath(rootDir);
|
|
143
|
+
const configContent = options.configContent ?? readConfig(rootDir, configPath);
|
|
144
|
+
const projectDir = toPosixPath(relative(repoRoot, rootDir)) || ".";
|
|
145
|
+
const packageManager = detectPackageManager(repoRoot);
|
|
146
|
+
const workflow = buildDocsReviewWorkflow({
|
|
147
|
+
packageManager,
|
|
148
|
+
ciName: review.ci.name,
|
|
149
|
+
projectDir,
|
|
150
|
+
configPath,
|
|
151
|
+
buildCommand: detectLocalDocsCliBuildCommand(repoRoot, packageManager),
|
|
152
|
+
reviewCommand: detectLocalDocsCliReviewCommand(repoRoot, rootDir),
|
|
153
|
+
pathFilters: buildDocsReviewWorkflowPathFilters({
|
|
154
|
+
rootDir,
|
|
155
|
+
repoRoot,
|
|
156
|
+
config: options.config,
|
|
157
|
+
configPath,
|
|
158
|
+
configContent
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
mkdirSync(dirname(workflowPath), { recursive: true });
|
|
162
|
+
writeFileSync(workflowPath, workflow, "utf-8");
|
|
163
|
+
options.log?.(`[docs] Created ${resultRelativePath} for Docs Review CI.`);
|
|
164
|
+
return {
|
|
165
|
+
status: "created",
|
|
166
|
+
path: workflowPath,
|
|
167
|
+
relativePath: resultRelativePath
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function readDocsReviewConfigFromSource(content) {
|
|
171
|
+
if (!content) return void 0;
|
|
172
|
+
const rootObject = extractRootObjectLiteral(content) ?? content;
|
|
173
|
+
const reviewCursor = findTopLevelPropertyValueIndex(rootObject, "review");
|
|
174
|
+
if (reviewCursor === void 0) return void 0;
|
|
175
|
+
if (rootObject.startsWith("true", reviewCursor)) return true;
|
|
176
|
+
if (rootObject.startsWith("false", reviewCursor)) return false;
|
|
177
|
+
if (rootObject[reviewCursor] !== "{") return void 0;
|
|
178
|
+
const reviewEnd = findMatchingObjectEnd(rootObject, reviewCursor);
|
|
179
|
+
if (reviewEnd === void 0) return void 0;
|
|
180
|
+
const reviewBlock = rootObject.slice(reviewCursor + 1, reviewEnd);
|
|
181
|
+
const scoreBlock = extractTopLevelObjectLiteral(reviewBlock, "score");
|
|
182
|
+
const ciCursor = findTopLevelPropertyValueIndex(reviewBlock, "ci");
|
|
183
|
+
const rulesBlock = extractTopLevelObjectLiteral(reviewBlock, "rules");
|
|
184
|
+
const ci = ciCursor === void 0 ? void 0 : reviewBlock.startsWith("true", ciCursor) ? true : reviewBlock.startsWith("false", ciCursor) ? false : reviewBlock[ciCursor] === "{" ? readReviewCiObject(reviewBlock, ciCursor) : void 0;
|
|
185
|
+
return {
|
|
186
|
+
enabled: readTopLevelBoolean(reviewBlock, "enabled"),
|
|
187
|
+
score: scoreBlock ? {
|
|
188
|
+
threshold: readTopLevelNumber(scoreBlock, "threshold"),
|
|
189
|
+
weights: readReviewWeights(scoreBlock)
|
|
190
|
+
} : void 0,
|
|
191
|
+
ci,
|
|
192
|
+
rules: rulesBlock ? readReviewRules(rulesBlock) : void 0
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function buildDocsReviewWorkflowPathFilters(options) {
|
|
196
|
+
const repoRoot = options.repoRoot ?? findGitRoot(options.rootDir) ?? options.rootDir;
|
|
197
|
+
const configPath = options.configPath ?? findDocsConfigPath(options.rootDir);
|
|
198
|
+
const configContent = options.configContent ?? readConfig(options.rootDir, configPath);
|
|
199
|
+
const entry = options.config?.entry ?? readTopLevelString(configContent, "entry") ?? "docs";
|
|
200
|
+
const contentDir = options.config?.contentDir ?? readTopLevelString(configContent, "contentDir");
|
|
201
|
+
const projectDir = toPosixPath(relative(repoRoot, options.rootDir));
|
|
202
|
+
const projectPrefix = projectDir && projectDir !== "." ? `${projectDir}/` : "";
|
|
203
|
+
const candidates = [
|
|
204
|
+
prefixPath(projectPrefix, configPath),
|
|
205
|
+
prefixPath(projectPrefix, `${entry}/**`),
|
|
206
|
+
prefixPath(projectPrefix, `app/${entry}/**`),
|
|
207
|
+
prefixPath(projectPrefix, `src/app/${entry}/**`),
|
|
208
|
+
contentDir ? prefixPath(projectPrefix, `${trimSlashes(contentDir)}/**`) : void 0,
|
|
209
|
+
prefixPath(projectPrefix, "content/docs/**"),
|
|
210
|
+
prefixPath(projectPrefix, "src/content/docs/**"),
|
|
211
|
+
prefixPath(projectPrefix, "src/lib/docs.config.*"),
|
|
212
|
+
DEFAULT_DOCS_REVIEW_WORKFLOW_PATH
|
|
213
|
+
];
|
|
214
|
+
return Array.from(new Set(candidates.filter((candidate) => Boolean(candidate))));
|
|
215
|
+
}
|
|
216
|
+
function normalizeRules(rules) {
|
|
217
|
+
if (!rules) return {};
|
|
218
|
+
return Object.fromEntries(Object.entries(rules).filter((entry) => REVIEW_SEVERITIES.has(entry[1])));
|
|
219
|
+
}
|
|
220
|
+
function normalizeWeight(value, fallback) {
|
|
221
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
222
|
+
}
|
|
223
|
+
function normalizeCiName(value) {
|
|
224
|
+
return value?.trim() || DEFAULT_DOCS_REVIEW_CI_NAME;
|
|
225
|
+
}
|
|
226
|
+
function clampScoreThreshold(value) {
|
|
227
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD;
|
|
228
|
+
return Math.min(100, Math.max(0, Math.round(value)));
|
|
229
|
+
}
|
|
230
|
+
function readReviewCiObject(source, cursor) {
|
|
231
|
+
const end = findMatchingObjectEnd(source, cursor);
|
|
232
|
+
if (end === void 0) return void 0;
|
|
233
|
+
const block = source.slice(cursor + 1, end);
|
|
234
|
+
const mode = readTopLevelString(block, "mode");
|
|
235
|
+
return {
|
|
236
|
+
enabled: readTopLevelBoolean(block, "enabled"),
|
|
237
|
+
name: readTopLevelString(block, "name"),
|
|
238
|
+
mode: mode && REVIEW_CI_MODES.has(mode) ? mode : void 0,
|
|
239
|
+
annotations: readTopLevelBoolean(block, "annotations"),
|
|
240
|
+
comment: readTopLevelBoolean(block, "comment")
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function readReviewRules(block) {
|
|
244
|
+
const rules = {};
|
|
245
|
+
for (const key of Object.keys(DEFAULT_REVIEW_RULES)) {
|
|
246
|
+
const value = readTopLevelString(block, key);
|
|
247
|
+
if (value && REVIEW_SEVERITIES.has(value)) rules[key] = value;
|
|
248
|
+
}
|
|
249
|
+
return rules;
|
|
250
|
+
}
|
|
251
|
+
function readReviewWeights(block) {
|
|
252
|
+
const weightsBlock = extractTopLevelObjectLiteral(block, "weights");
|
|
253
|
+
if (!weightsBlock) return void 0;
|
|
254
|
+
return {
|
|
255
|
+
error: readTopLevelNumber(weightsBlock, "error"),
|
|
256
|
+
warn: readTopLevelNumber(weightsBlock, "warn"),
|
|
257
|
+
suggestion: readTopLevelNumber(weightsBlock, "suggestion")
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function detectPackageManager(rootDir) {
|
|
261
|
+
if (existsSync(join(rootDir, "pnpm-lock.yaml"))) return "pnpm";
|
|
262
|
+
if (existsSync(join(rootDir, "yarn.lock"))) return "yarn";
|
|
263
|
+
if (existsSync(join(rootDir, "bun.lock")) || existsSync(join(rootDir, "bun.lockb"))) return "bun";
|
|
264
|
+
return "npm";
|
|
265
|
+
}
|
|
266
|
+
function detectLocalDocsCliBuildCommand(repoRoot, packageManager) {
|
|
267
|
+
if (!hasLocalDocsWorkspacePackage(repoRoot)) return void 0;
|
|
268
|
+
if (packageManager === "pnpm") return "pnpm --filter @farming-labs/docs run build";
|
|
269
|
+
if (packageManager === "yarn") return "yarn workspace @farming-labs/docs build";
|
|
270
|
+
if (packageManager === "bun") return "bun run --filter @farming-labs/docs build";
|
|
271
|
+
return "npm run build --workspace=@farming-labs/docs";
|
|
272
|
+
}
|
|
273
|
+
function detectLocalDocsCliReviewCommand(repoRoot, rootDir) {
|
|
274
|
+
if (!hasLocalDocsWorkspacePackage(repoRoot)) return void 0;
|
|
275
|
+
return `node ${shellQuote(toPosixPath(relative(rootDir, join(repoRoot, "packages", "docs", "dist", "cli", "index.mjs"))) || "./packages/docs/dist/cli/index.mjs")}`;
|
|
276
|
+
}
|
|
277
|
+
function hasLocalDocsWorkspacePackage(repoRoot) {
|
|
278
|
+
const packageJsonPath = join(repoRoot, "packages", "docs", "package.json");
|
|
279
|
+
if (!existsSync(packageJsonPath)) return false;
|
|
280
|
+
try {
|
|
281
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
282
|
+
return packageJson.name === "@farming-labs/docs" && Boolean(packageJson.scripts?.build);
|
|
283
|
+
} catch {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function buildInstallSteps(packageManager) {
|
|
288
|
+
if (packageManager === "pnpm") return ` - uses: pnpm/action-setup@v4
|
|
289
|
+
|
|
290
|
+
- uses: actions/setup-node@v4
|
|
291
|
+
with:
|
|
292
|
+
node-version: 20
|
|
293
|
+
cache: pnpm
|
|
294
|
+
|
|
295
|
+
- name: Install dependencies
|
|
296
|
+
run: pnpm install --frozen-lockfile`;
|
|
297
|
+
if (packageManager === "yarn") return ` - uses: actions/setup-node@v4
|
|
298
|
+
with:
|
|
299
|
+
node-version: 20
|
|
300
|
+
cache: yarn
|
|
301
|
+
|
|
302
|
+
- name: Enable Corepack
|
|
303
|
+
run: corepack enable
|
|
304
|
+
|
|
305
|
+
- name: Install dependencies
|
|
306
|
+
run: yarn install --immutable || yarn install --frozen-lockfile`;
|
|
307
|
+
if (packageManager === "bun") return ` - uses: oven-sh/setup-bun@v2
|
|
308
|
+
|
|
309
|
+
- name: Install dependencies
|
|
310
|
+
run: bun install --frozen-lockfile`;
|
|
311
|
+
return ` - uses: actions/setup-node@v4
|
|
312
|
+
with:
|
|
313
|
+
node-version: 20
|
|
314
|
+
cache: npm
|
|
315
|
+
|
|
316
|
+
- name: Install dependencies
|
|
317
|
+
run: npm ci`;
|
|
318
|
+
}
|
|
319
|
+
function reviewCommandForPackageManager(packageManager) {
|
|
320
|
+
if (packageManager === "pnpm") return "pnpm exec docs";
|
|
321
|
+
if (packageManager === "yarn") return "yarn exec docs";
|
|
322
|
+
if (packageManager === "bun") return "bunx docs";
|
|
323
|
+
return "npx --no-install docs";
|
|
324
|
+
}
|
|
325
|
+
function shellQuote(value) {
|
|
326
|
+
if (/^[A-Za-z0-9_./:-]+$/.test(value)) return value;
|
|
327
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
328
|
+
}
|
|
329
|
+
function normalizeProjectDir(value) {
|
|
330
|
+
if (!value || value === "") return ".";
|
|
331
|
+
return toPosixPath(value).replace(/\/+$/, "") || ".";
|
|
332
|
+
}
|
|
333
|
+
function normalizePathFilters(filters) {
|
|
334
|
+
const normalized = (filters && filters.length > 0 ? filters : ["docs.config.*", "app/docs/**"]).map((filter) => toPosixPath(filter).replace(/^\.\/+/, "")).filter(Boolean);
|
|
335
|
+
return Array.from(new Set(normalized));
|
|
336
|
+
}
|
|
337
|
+
function findGitRoot(start) {
|
|
338
|
+
let current = start;
|
|
339
|
+
while (true) {
|
|
340
|
+
if (existsSync(join(current, ".git"))) return current;
|
|
341
|
+
const parent = dirname(current);
|
|
342
|
+
if (parent === current) return void 0;
|
|
343
|
+
current = parent;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function findDocsConfigPath(rootDir) {
|
|
347
|
+
for (const ext of FILE_EXTS) {
|
|
348
|
+
const path = `docs.config.${ext}`;
|
|
349
|
+
if (existsSync(join(rootDir, path))) return path;
|
|
350
|
+
}
|
|
351
|
+
return "docs.config.ts";
|
|
352
|
+
}
|
|
353
|
+
function readConfig(rootDir, configPath = findDocsConfigPath(rootDir)) {
|
|
354
|
+
const fullPath = join(rootDir, configPath);
|
|
355
|
+
if (!existsSync(fullPath)) return void 0;
|
|
356
|
+
try {
|
|
357
|
+
return readFileSync(fullPath, "utf-8");
|
|
358
|
+
} catch {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function prefixPath(prefix, value) {
|
|
363
|
+
return `${prefix}${toPosixPath(value).replace(/^\.\/+/, "")}`;
|
|
364
|
+
}
|
|
365
|
+
function trimSlashes(value) {
|
|
366
|
+
return toPosixPath(value).replace(/^\/+|\/+$/g, "");
|
|
367
|
+
}
|
|
368
|
+
function toPosixPath(value) {
|
|
369
|
+
return value.replaceAll("\\", "/");
|
|
370
|
+
}
|
|
371
|
+
function extractRootObjectLiteral(content) {
|
|
372
|
+
const candidateIndexes = [content.search(/\bdefineDocs\s*\(/), content.search(/\bexport\s+default\b/)].filter((value) => value !== -1);
|
|
373
|
+
for (const startIndex of candidateIndexes) {
|
|
374
|
+
const braceStart = content.indexOf("{", startIndex);
|
|
375
|
+
if (braceStart === -1) continue;
|
|
376
|
+
const braceEnd = findMatchingObjectEnd(content, braceStart);
|
|
377
|
+
if (braceEnd !== void 0) return content.slice(braceStart + 1, braceEnd);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function extractTopLevelObjectLiteral(content, key) {
|
|
381
|
+
const cursor = findTopLevelPropertyValueIndex(content, key);
|
|
382
|
+
if (cursor === void 0 || content[cursor] !== "{") return void 0;
|
|
383
|
+
const end = findMatchingObjectEnd(content, cursor);
|
|
384
|
+
return end === void 0 ? void 0 : content.slice(cursor + 1, end);
|
|
385
|
+
}
|
|
386
|
+
function readTopLevelBoolean(content, key) {
|
|
387
|
+
const cursor = findTopLevelPropertyValueIndex(content, key);
|
|
388
|
+
if (cursor === void 0) return void 0;
|
|
389
|
+
if (content.startsWith("true", cursor)) return true;
|
|
390
|
+
if (content.startsWith("false", cursor)) return false;
|
|
391
|
+
}
|
|
392
|
+
function readTopLevelNumber(content, key) {
|
|
393
|
+
const cursor = findTopLevelPropertyValueIndex(content, key);
|
|
394
|
+
if (cursor === void 0) return void 0;
|
|
395
|
+
const match = content.slice(cursor).match(/^-?\d+(?:\.\d+)?/);
|
|
396
|
+
if (!match) return void 0;
|
|
397
|
+
const value = Number(match[0]);
|
|
398
|
+
return Number.isFinite(value) ? value : void 0;
|
|
399
|
+
}
|
|
400
|
+
function readTopLevelString(content, key) {
|
|
401
|
+
if (!content) return void 0;
|
|
402
|
+
const cursor = findTopLevelPropertyValueIndex(content, key);
|
|
403
|
+
if (cursor === void 0) return void 0;
|
|
404
|
+
const quote = content[cursor];
|
|
405
|
+
if (quote !== "\"" && quote !== "'") return void 0;
|
|
406
|
+
let value = "";
|
|
407
|
+
for (let index = cursor + 1; index < content.length; index += 1) {
|
|
408
|
+
const char = content[index];
|
|
409
|
+
if (char === "\\") {
|
|
410
|
+
const escaped = content[index + 1];
|
|
411
|
+
if (escaped) {
|
|
412
|
+
value += escaped;
|
|
413
|
+
index += 1;
|
|
414
|
+
}
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (char === quote) return value;
|
|
418
|
+
value += char;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function findTopLevelPropertyValueIndex(block, key) {
|
|
422
|
+
let objectDepth = 0;
|
|
423
|
+
let arrayDepth = 0;
|
|
424
|
+
let parenDepth = 0;
|
|
425
|
+
let inString = null;
|
|
426
|
+
let inLineComment = false;
|
|
427
|
+
let inBlockComment = false;
|
|
428
|
+
let escaped = false;
|
|
429
|
+
for (let index = 0; index < block.length; index += 1) {
|
|
430
|
+
const char = block[index];
|
|
431
|
+
const next = block[index + 1];
|
|
432
|
+
if (inLineComment) {
|
|
433
|
+
if (char === "\n") inLineComment = false;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (inBlockComment) {
|
|
437
|
+
if (char === "*" && next === "/") {
|
|
438
|
+
inBlockComment = false;
|
|
439
|
+
index += 1;
|
|
440
|
+
}
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (inString) {
|
|
444
|
+
if (escaped) {
|
|
445
|
+
escaped = false;
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (char === "\\") {
|
|
449
|
+
escaped = true;
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (char === inString) inString = null;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (char === "/" && next === "/") {
|
|
456
|
+
inLineComment = true;
|
|
457
|
+
index += 1;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (char === "/" && next === "*") {
|
|
461
|
+
inBlockComment = true;
|
|
462
|
+
index += 1;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
466
|
+
inString = char;
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (char === "{") {
|
|
470
|
+
objectDepth += 1;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (char === "}") {
|
|
474
|
+
objectDepth = Math.max(0, objectDepth - 1);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (char === "[") {
|
|
478
|
+
arrayDepth += 1;
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (char === "]") {
|
|
482
|
+
arrayDepth = Math.max(0, arrayDepth - 1);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (char === "(") {
|
|
486
|
+
parenDepth += 1;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (char === ")") {
|
|
490
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (objectDepth !== 0 || arrayDepth !== 0 || parenDepth !== 0) continue;
|
|
494
|
+
if (!block.startsWith(key, index)) continue;
|
|
495
|
+
const before = block[index - 1] ?? "";
|
|
496
|
+
const after = block[index + key.length] ?? "";
|
|
497
|
+
if (/[A-Za-z0-9_$]/.test(before) || /[A-Za-z0-9_$]/.test(after)) continue;
|
|
498
|
+
let cursor = index + key.length;
|
|
499
|
+
while (/\s/.test(block[cursor] ?? "")) cursor += 1;
|
|
500
|
+
if (block[cursor] !== ":") continue;
|
|
501
|
+
cursor += 1;
|
|
502
|
+
while (/\s/.test(block[cursor] ?? "")) cursor += 1;
|
|
503
|
+
return cursor;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function findMatchingObjectEnd(block, start) {
|
|
507
|
+
let depth = 0;
|
|
508
|
+
let inString = null;
|
|
509
|
+
let inLineComment = false;
|
|
510
|
+
let inBlockComment = false;
|
|
511
|
+
let escaped = false;
|
|
512
|
+
for (let index = start; index < block.length; index += 1) {
|
|
513
|
+
const char = block[index];
|
|
514
|
+
const next = block[index + 1];
|
|
515
|
+
if (inLineComment) {
|
|
516
|
+
if (char === "\n") inLineComment = false;
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (inBlockComment) {
|
|
520
|
+
if (char === "*" && next === "/") {
|
|
521
|
+
inBlockComment = false;
|
|
522
|
+
index += 1;
|
|
523
|
+
}
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
if (inString) {
|
|
527
|
+
if (escaped) {
|
|
528
|
+
escaped = false;
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
if (char === "\\") {
|
|
532
|
+
escaped = true;
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
if (char === inString) inString = null;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (char === "/" && next === "/") {
|
|
539
|
+
inLineComment = true;
|
|
540
|
+
index += 1;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
if (char === "/" && next === "*") {
|
|
544
|
+
inBlockComment = true;
|
|
545
|
+
index += 1;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
if (char === "\"" || char === "'" || char === "`") {
|
|
549
|
+
inString = char;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (char === "{") {
|
|
553
|
+
depth += 1;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (char !== "}") continue;
|
|
557
|
+
depth -= 1;
|
|
558
|
+
if (depth === 0) return index;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
//#endregion
|
|
563
|
+
export { ensureDocsReviewWorkflow as a, buildDocsReviewWorkflowPathFilters as i, DEFAULT_DOCS_REVIEW_WORKFLOW_PATH as n, readDocsReviewConfigFromSource as o, buildDocsReviewWorkflow as r, resolveDocsReviewConfig as s, DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./agent-Dt6kdGqw.mjs";
|
|
2
2
|
import { c as renderDocsRobotsGeneratedBlock, f as upsertDocsRobotsGeneratedBlock, i as DOCS_ROBOTS_GENERATED_BLOCK_START, r as DOCS_ROBOTS_GENERATED_BLOCK_END, u as resolveDocsRobotsConfig } from "./robots-tohhTNbU.mjs";
|
|
3
|
-
import { d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, o as readBooleanProperty, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-
|
|
4
|
-
import { t as detectFramework } from "./utils-
|
|
3
|
+
import { d as readTopLevelStringProperty, f as resolveDocsConfigPath, i as loadDocsConfigModule, o as readBooleanProperty, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-BHRL4R2v.mjs";
|
|
4
|
+
import { t as detectFramework } from "./utils-x5EtYWjC.mjs";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import pc from "picocolors";
|
|
@@ -2,7 +2,7 @@ import { n as buildDocsSearchDocuments, r as createAlgoliaSearchAdapter, s as cr
|
|
|
2
2
|
import "./sitemap-server-DdHzJorR.mjs";
|
|
3
3
|
import { createFilesystemDocsMcpSource } from "./mcp.mjs";
|
|
4
4
|
import "./server.mjs";
|
|
5
|
-
import { a as loadProjectEnv, d as readTopLevelStringProperty, f as resolveDocsConfigPath, p as resolveDocsContentDir } from "./config-
|
|
5
|
+
import { a as loadProjectEnv, d as readTopLevelStringProperty, f as resolveDocsConfigPath, p as resolveDocsContentDir } from "./config-BHRL4R2v.mjs";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import pc from "picocolors";
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as DocsSearchChunkingConfig, B as DocsObservabilityEventInput, Ct as OpenDocsTarget, Ht as TypesenseDocsSearchConfig, Mt as ResolvedDocsRelatedLink, Q as DocsSearchAdapterFactory, R as DocsObservabilityConfig, X as DocsSearchAdapter, _ as DocsAnalyticsConfig, _t as McpDocsSearchConfig, bt as OpenDocsProvider, d as CustomDocsSearchConfig, et as DocsSearchConfig, it as DocsSearchResult, k as DocsAskAIMcpConfig, m as DocsAgentTraceEventInput, ot as DocsSearchSourcePage, r as AlgoliaDocsSearchConfig, st as DocsSitemapConfig, tt as DocsSearchDocument, v as DocsAnalyticsEvent, y as DocsAnalyticsEventInput, z as DocsObservabilityEvent } from "./types-CHD7M60f.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/cloud-analytics.d.ts
|
|
4
4
|
interface DocsCloudAnalyticsOptions {
|