@farming-labs/docs 0.2.28 → 0.2.30
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/cli/index.mjs
CHANGED
|
@@ -31,7 +31,8 @@ function parseFlags(argv) {
|
|
|
31
31
|
"network",
|
|
32
32
|
"analytics",
|
|
33
33
|
"ask-ai",
|
|
34
|
-
"deploy"
|
|
34
|
+
"deploy",
|
|
35
|
+
"dry-run"
|
|
35
36
|
]);
|
|
36
37
|
for (let i = 0; i < argv.length; i++) {
|
|
37
38
|
const arg = argv[i];
|
|
@@ -162,7 +163,7 @@ async function main() {
|
|
|
162
163
|
printAgentsGenerateHelp();
|
|
163
164
|
process.exit(1);
|
|
164
165
|
} else if (parsedCommand.command === "doctor") {
|
|
165
|
-
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-
|
|
166
|
+
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-C_djsk99.mjs");
|
|
166
167
|
const doctorOptions = parseDoctorArgs(args.slice(1));
|
|
167
168
|
if (doctorOptions.help) {
|
|
168
169
|
printDoctorHelp();
|
|
@@ -228,22 +229,24 @@ async function main() {
|
|
|
228
229
|
printRobotsGenerateHelp();
|
|
229
230
|
process.exit(1);
|
|
230
231
|
} else if (parsedCommand.command === "downgrade") {
|
|
231
|
-
const { downgrade } = await import("../downgrade-
|
|
232
|
+
const { downgrade } = await import("../downgrade-ghVFFHKi.mjs");
|
|
232
233
|
const framework = (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0);
|
|
233
234
|
const hasVersionFlag = args.includes("--version") || args.some((arg) => arg.startsWith("--version="));
|
|
234
235
|
await downgrade({
|
|
235
236
|
framework,
|
|
236
|
-
version: typeof flags.version === "string" ? flags.version : hasVersionFlag ? "" : void 0
|
|
237
|
+
version: typeof flags.version === "string" ? flags.version : hasVersionFlag ? "" : void 0,
|
|
238
|
+
dryRun: flags["dry-run"] === true
|
|
237
239
|
});
|
|
238
240
|
} else if (parsedCommand.command === "upgrade") {
|
|
239
|
-
const { upgrade } = await import("../upgrade-
|
|
241
|
+
const { upgrade } = await import("../upgrade-aexO-zom.mjs");
|
|
240
242
|
const framework = (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0);
|
|
241
243
|
const hasVersionFlag = args.includes("--version") || args.some((arg) => arg.startsWith("--version="));
|
|
242
244
|
const version = typeof flags.version === "string" ? flags.version : hasVersionFlag ? "" : void 0;
|
|
243
245
|
await upgrade({
|
|
244
246
|
framework,
|
|
245
247
|
tag: version !== void 0 ? void 0 : args.includes("--beta") ? "beta" : args.includes("--latest") ? "latest" : parsedCommand.tag ?? "latest",
|
|
246
|
-
version
|
|
248
|
+
version,
|
|
249
|
+
dryRun: flags["dry-run"] === true
|
|
247
250
|
});
|
|
248
251
|
} else if (parsedCommand.command === "--help" || parsedCommand.command === "-h") printHelp();
|
|
249
252
|
else if (parsedCommand.command === "--version" || parsedCommand.command === "-v") printVersion();
|
|
@@ -341,6 +344,8 @@ ${pc.dim("Options for doctor:")}
|
|
|
341
344
|
${pc.cyan("doctor --human")} Alias for ${pc.cyan("doctor --site")}
|
|
342
345
|
${pc.cyan("doctor --json")} Print the report as JSON for CI, scripts, and automation
|
|
343
346
|
${pc.cyan("doctor --strict")} Exit with failure when any doctor check warns or fails
|
|
347
|
+
${pc.cyan("doctor --agent --fix")} Refresh stale generated ${pc.dim("agent.md")} files and token-budget missing outputs
|
|
348
|
+
${pc.cyan("doctor --agent --fix --dry-run")} Report the fix command without writing generated ${pc.dim("agent.md")} files
|
|
344
349
|
${pc.cyan("doctor --fail-on warn|fail")} Choose whether warnings or only failures fail CI
|
|
345
350
|
${pc.cyan("doctor agent")} Subcommand alias for agent scoring
|
|
346
351
|
${pc.cyan("doctor site")} Subcommand alias for reader-facing scoring
|
|
@@ -394,6 +399,7 @@ ${pc.dim("Options for upgrade:")}
|
|
|
394
399
|
${pc.cyan("--version <version>")} Install an exact version (e.g. ${pc.dim("0.1.104")})
|
|
395
400
|
${pc.cyan("--latest")} Install latest stable (default)
|
|
396
401
|
${pc.cyan("--beta")} Install beta versions
|
|
402
|
+
${pc.cyan("--dry-run")} Print the install command without changing dependencies
|
|
397
403
|
${pc.cyan("upgrade@beta")} Shortcut for ${pc.cyan("upgrade --beta")}
|
|
398
404
|
${pc.cyan("upgrade@latest")} Shortcut for ${pc.cyan("upgrade --latest")}
|
|
399
405
|
|
|
@@ -401,6 +407,7 @@ ${pc.dim("Options for downgrade:")}
|
|
|
401
407
|
${pc.cyan("downgrade")} Install the published version immediately below the current installed version
|
|
402
408
|
${pc.cyan("--framework <name>")} Explicit framework (${pc.dim("next")}, ${pc.dim("tanstack-start")}, ${pc.dim("nuxt")}, ${pc.dim("sveltekit")}, ${pc.dim("astro")}); omit to auto-detect
|
|
403
409
|
${pc.cyan("--version <version>")} Install an exact lower version (e.g. ${pc.dim("0.1.103")})
|
|
410
|
+
${pc.cyan("--dry-run")} Print the install command without changing dependencies
|
|
404
411
|
|
|
405
412
|
${pc.cyan("-h, --help")} Show this help message
|
|
406
413
|
${pc.cyan("-v, --version")} Show version
|
|
@@ -7,7 +7,7 @@ import { createFilesystemDocsMcpSource, resolveDocsMcpConfig } from "./mcp.mjs";
|
|
|
7
7
|
import "./server.mjs";
|
|
8
8
|
import { a as loadProjectEnv, c as readNavTitle, f as readTopLevelStringProperty, i as loadDocsConfigModule, m as resolveDocsContentDir, o as readBooleanProperty, p as resolveDocsConfigPath, r as extractTopLevelConfigObject, t as extractNestedObjectLiteral } from "./config-De5z-2LK.mjs";
|
|
9
9
|
import { t as detectFramework } from "./utils-CoHZJ1i4.mjs";
|
|
10
|
-
import { n as inspectAgentCompactionState, o as scanDocsPageTargets } from "./codeblocks-Dcn5tRbB.mjs";
|
|
10
|
+
import { n as inspectAgentCompactionState, o as scanDocsPageTargets, t as compactAgentDocs } from "./codeblocks-Dcn5tRbB.mjs";
|
|
11
11
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { LATEST_PROTOCOL_VERSION } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -66,6 +66,14 @@ function parseDoctorArgs(argv) {
|
|
|
66
66
|
parsed.strict = true;
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
|
+
if (arg === "--fix") {
|
|
70
|
+
parsed.fix = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (arg === "--dry-run") {
|
|
74
|
+
parsed.dryRun = true;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
69
77
|
if (arg.startsWith("--fail-on=")) {
|
|
70
78
|
const value = parseInlineFlag(arg).value;
|
|
71
79
|
if (!value) throw new Error("Missing value for --fail-on.");
|
|
@@ -137,6 +145,8 @@ ${pc.dim("Usage:")}
|
|
|
137
145
|
pnpm exec docs doctor --site
|
|
138
146
|
pnpm exec docs doctor --agent --json
|
|
139
147
|
pnpm exec docs doctor --agent --strict
|
|
148
|
+
pnpm exec docs doctor --agent --fix
|
|
149
|
+
pnpm exec docs doctor --agent --fix --dry-run
|
|
140
150
|
pnpm exec docs doctor --agent --fail-on fail
|
|
141
151
|
pnpm exec docs doctor --only agent
|
|
142
152
|
pnpm exec docs doctor --only site
|
|
@@ -150,6 +160,8 @@ ${pc.dim("Options:")}
|
|
|
150
160
|
${pc.cyan("--only <mode>")} Run only one doctor suite: ${pc.cyan("agent")} or ${pc.cyan("site")}
|
|
151
161
|
${pc.cyan("--json")} Print the report as JSON for CI, scripts, and other agents
|
|
152
162
|
${pc.cyan("--strict")} Exit with failure when any check warns or fails
|
|
163
|
+
${pc.cyan("--fix")} Refresh stale generated agent.md files and token-budget missing outputs
|
|
164
|
+
${pc.cyan("--dry-run")} With ${pc.cyan("--fix")}, report the compaction command without writing files
|
|
153
165
|
${pc.cyan("--fail-on <level>")} Exit with failure on ${pc.cyan("warn")} or only on ${pc.cyan("fail")}
|
|
154
166
|
${pc.cyan("--url <url>")} Probe hosted agent surfaces, e.g. ${pc.dim("https://docs.example.com")}
|
|
155
167
|
${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
|
|
@@ -1462,6 +1474,7 @@ function printAgentDoctorReport(report) {
|
|
|
1462
1474
|
if (report.url) console.log(`${pc.bold("Hosted URL:")} ${report.url}`);
|
|
1463
1475
|
console.log(`${pc.bold("Explicit agent-friendly pages:")} ${report.coverage.explicitPages}/${report.coverage.totalPages} pages ${pc.dim(`(${report.coverage.explicitCoverage}%)`)}`);
|
|
1464
1476
|
console.log(`${pc.bold("Generated agent.md freshness:")} ${report.coverage.compaction.freshGeneratedPages} fresh ${pc.dim("•")} ${report.coverage.compaction.staleGeneratedPages} stale ${pc.dim("•")} ${report.coverage.compaction.modifiedGeneratedPages} modified ${pc.dim("•")} ${report.coverage.compaction.tokenBudgetMissingPages} token-budget missing`);
|
|
1477
|
+
if (report.fixes && report.fixes.length > 0) console.log(`${pc.bold("Fixes:")} ${report.fixes.map((fix) => `${fix.status === "applied" ? "applied" : "skipped"} ${fix.title}`).join(pc.dim(" • "))}`);
|
|
1465
1478
|
console.log();
|
|
1466
1479
|
for (const check of report.checks) {
|
|
1467
1480
|
console.log(`${formatStatus(check.status)} ${check.title} ${pc.dim(`(${check.score}/${check.maxScore})`)}`);
|
|
@@ -1513,8 +1526,58 @@ function applyDoctorExitCode(report, options) {
|
|
|
1513
1526
|
if (!failOn) return;
|
|
1514
1527
|
if (failOn === "warn" ? hasNonPassingDoctorCheck(report) : hasFailingDoctorCheck(report)) process.exitCode = 1;
|
|
1515
1528
|
}
|
|
1529
|
+
async function runAgentDoctorFixes(report, options) {
|
|
1530
|
+
const fixes = [];
|
|
1531
|
+
const compaction = report.coverage.compaction;
|
|
1532
|
+
if (!(compaction.staleGeneratedPages > 0 || compaction.tokenBudgetMissingPages > 0)) {
|
|
1533
|
+
if (compaction.modifiedGeneratedPages > 0 || compaction.unknownGeneratedPages > 0) fixes.push({
|
|
1534
|
+
id: "agent-compact",
|
|
1535
|
+
title: "agent compact",
|
|
1536
|
+
status: "skipped",
|
|
1537
|
+
detail: "Only modified or unknown generated agent.md files need attention; doctor --fix leaves those for manual review."
|
|
1538
|
+
});
|
|
1539
|
+
return fixes;
|
|
1540
|
+
}
|
|
1541
|
+
const runCompaction = () => compactAgentDocs({
|
|
1542
|
+
configPath: options.configPath,
|
|
1543
|
+
stale: true,
|
|
1544
|
+
includeMissing: compaction.tokenBudgetMissingPages > 0
|
|
1545
|
+
});
|
|
1546
|
+
const command = `docs agent compact --stale${compaction.tokenBudgetMissingPages > 0 ? " --include-missing" : ""}`;
|
|
1547
|
+
if (options.dryRun) {
|
|
1548
|
+
const missingOutputDetail = compaction.tokenBudgetMissingPages > 0 ? " and create token-budget missing outputs" : "";
|
|
1549
|
+
fixes.push({
|
|
1550
|
+
id: "agent-compact",
|
|
1551
|
+
title: "agent compact",
|
|
1552
|
+
status: "skipped",
|
|
1553
|
+
detail: `Dry run: would run ${command} to refresh stale generated agent.md files${missingOutputDetail}.`
|
|
1554
|
+
});
|
|
1555
|
+
return fixes;
|
|
1556
|
+
}
|
|
1557
|
+
if (options.json) {
|
|
1558
|
+
const originalLog = console.log;
|
|
1559
|
+
console.log = () => void 0;
|
|
1560
|
+
try {
|
|
1561
|
+
await runCompaction();
|
|
1562
|
+
} finally {
|
|
1563
|
+
console.log = originalLog;
|
|
1564
|
+
}
|
|
1565
|
+
} else {
|
|
1566
|
+
console.log();
|
|
1567
|
+
console.log(pc.bold("Applying doctor --fix"));
|
|
1568
|
+
await runCompaction();
|
|
1569
|
+
}
|
|
1570
|
+
fixes.push({
|
|
1571
|
+
id: "agent-compact",
|
|
1572
|
+
title: "agent compact",
|
|
1573
|
+
status: "applied",
|
|
1574
|
+
detail: compaction.tokenBudgetMissingPages > 0 ? "Ran docs agent compact --stale --include-missing to refresh stale generated agent.md files and create token-budget missing outputs." : "Ran docs agent compact --stale to refresh stale generated agent.md files."
|
|
1575
|
+
});
|
|
1576
|
+
return fixes;
|
|
1577
|
+
}
|
|
1516
1578
|
async function runDoctor(options = {}) {
|
|
1517
1579
|
if (options.mode === "human") {
|
|
1580
|
+
if (options.fix) throw new Error("doctor --fix is currently only supported with --agent.");
|
|
1518
1581
|
const report = await inspectHumanReadiness(options);
|
|
1519
1582
|
applyDoctorExitCode(report, options);
|
|
1520
1583
|
if (options.json) {
|
|
@@ -1524,7 +1587,15 @@ async function runDoctor(options = {}) {
|
|
|
1524
1587
|
printHumanDoctorReport(report);
|
|
1525
1588
|
return report;
|
|
1526
1589
|
}
|
|
1527
|
-
|
|
1590
|
+
let report = await inspectAgentReadiness(options);
|
|
1591
|
+
let fixes;
|
|
1592
|
+
if (options.fix) {
|
|
1593
|
+
fixes = await runAgentDoctorFixes(report, options);
|
|
1594
|
+
report = {
|
|
1595
|
+
...await inspectAgentReadiness(options),
|
|
1596
|
+
fixes
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1528
1599
|
applyDoctorExitCode(report, options);
|
|
1529
1600
|
if (options.json) {
|
|
1530
1601
|
printDoctorJsonReport(report);
|
|
@@ -165,6 +165,11 @@ async function downgrade(options = {}) {
|
|
|
165
165
|
const cmd = buildDowngradeCommand(framework, targetVersion, pm);
|
|
166
166
|
p.log.step(`Downgrading ${preset} docs packages from ${currentVersion} to ${targetVersion}...`);
|
|
167
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
|
+
}
|
|
168
173
|
try {
|
|
169
174
|
exec(cmd, cwd);
|
|
170
175
|
p.log.success(`Packages downgraded to ${targetVersion}.`);
|
|
@@ -37,6 +37,11 @@ async function upgrade(options = {}) {
|
|
|
37
37
|
const packages = getPackagesForFramework(framework);
|
|
38
38
|
p.log.step(`Upgrading ${preset} docs packages to ${target}...`);
|
|
39
39
|
p.log.message(pc.dim(packages.join(", ")));
|
|
40
|
+
if (options.dryRun) {
|
|
41
|
+
p.log.info("Dry run. Would run:\n " + pc.cyan(cmd));
|
|
42
|
+
p.outro(pc.green("Dry run complete. No changes made."));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
40
45
|
try {
|
|
41
46
|
exec(cmd, cwd);
|
|
42
47
|
p.log.success(`Packages upgraded to ${target}.`);
|