@farming-labs/docs 0.2.29 → 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.
@@ -163,7 +163,7 @@ async function main() {
163
163
  printAgentsGenerateHelp();
164
164
  process.exit(1);
165
165
  } else if (parsedCommand.command === "doctor") {
166
- const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-Qe_2T86D.mjs");
166
+ const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-C_djsk99.mjs");
167
167
  const doctorOptions = parseDoctorArgs(args.slice(1));
168
168
  if (doctorOptions.help) {
169
169
  printDoctorHelp();
@@ -344,6 +344,8 @@ ${pc.dim("Options for doctor:")}
344
344
  ${pc.cyan("doctor --human")} Alias for ${pc.cyan("doctor --site")}
345
345
  ${pc.cyan("doctor --json")} Print the report as JSON for CI, scripts, and automation
346
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
347
349
  ${pc.cyan("doctor --fail-on warn|fail")} Choose whether warnings or only failures fail CI
348
350
  ${pc.cyan("doctor agent")} Subcommand alias for agent scoring
349
351
  ${pc.cyan("doctor site")} Subcommand alias for reader-facing scoring
@@ -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
- const report = await inspectAgentReadiness(options);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/docs",
3
- "version": "0.2.29",
3
+ "version": "0.2.30",
4
4
  "description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
5
5
  "keywords": [
6
6
  "docs",