@farming-labs/docs 0.2.103 → 0.2.105
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-BLHMoVId.mjs → agent-CaCWThBY.mjs} +4 -4
- package/dist/{agent-CFqECAG0.mjs → agent-DCTGj6J7.mjs} +212 -19
- package/dist/{agent-evals-GpcaCbRb.mjs → agent-evals-D-sPJfXz.mjs} +5 -5
- package/dist/{agent-export-oiWxB5aX.mjs → agent-export-GcTZPLfB.mjs} +30 -17
- package/dist/agent-feedback-evaluations-DQCTFegz.mjs +240 -0
- package/dist/agent-feedback-loop-vaC-M1sx.mjs +196 -0
- package/dist/agent-maintenance-CuZ7iAKq.mjs +289 -0
- package/dist/agent-skills-bundle.d.mts +1 -1
- package/dist/{agent-skills-progressive-disclosure-Da9LKEKv.mjs → agent-skills-progressive-disclosure-DL-q4JZo.mjs} +1 -1
- package/dist/{agent-skills-server-CICMh0zv.d.mts → agent-skills-server-D34054x5.d.mts} +2 -2
- package/dist/{agent-skills-server-DFqQyO_V.mjs → agent-skills-server-Ddbf15pY.mjs} +1 -1
- package/dist/agent-skills-vite.d.mts +3 -3
- package/dist/agent-skills-vite.mjs +2 -2
- package/dist/{agents-CtqIUW5I.mjs → agents-e1SYT64z.mjs} +11 -10
- package/dist/{analytics-Bx44lg6d.mjs → analytics-CqfcIBdg.mjs} +1 -1
- package/dist/{analytics-C75BnTEW.d.mts → analytics-aeXwEvQX.d.mts} +1 -1
- package/dist/authoring-Do87QzBd.mjs +41 -0
- package/dist/authoring-mcp-Be7quE5R.mjs +380 -0
- package/dist/browser.d.mts +3 -3
- package/dist/browser.mjs +2 -2
- package/dist/cli/index.mjs +103 -35
- package/dist/client/react.d.mts +1 -1
- package/dist/client/react.mjs +1 -1
- package/dist/{cloud-FNfcbfli.mjs → cloud-Bvof6mET.mjs} +3 -3
- package/dist/{cloud-ask-ai-BmbZVAT5.d.mts → cloud-ask-ai-BqfiQaNZ.d.mts} +1 -1
- package/dist/{cloud-ask-ai-CkCYjf2N.mjs → cloud-ask-ai-CK2qlNns.mjs} +1 -1
- package/dist/{code-blocks-Bel6vDqI.mjs → code-blocks-D90CCJFs.mjs} +1 -1
- package/dist/{codeblocks-jbWuvtJQ.mjs → codeblocks-C911CdyJ.mjs} +2 -2
- package/dist/{agent-lWTq6pgr.d.mts → content-change-hydration-CoYRs3pC.d.mts} +707 -675
- package/dist/{dev-BvbYmTLz.mjs → dev-Bx0JNglW.mjs} +3 -3
- package/dist/docs-cloud-server.d.mts +2 -2
- package/dist/docs-cloud-server.mjs +2 -2
- package/dist/{doctor-Bmm0uY98.mjs → doctor-CtK1CRPj.mjs} +20 -16
- package/dist/{downgrade-Dqm0rJMy.mjs → downgrade-BXmQMkMy.mjs} +2 -2
- package/dist/feedback-DWVUMrxy.mjs +72 -0
- package/dist/feedback-evals-k0sFDdms.mjs +146 -0
- package/dist/{golden-evaluations-K45fcWGW.mjs → golden-evaluations-De4KwoYr.mjs} +3 -3
- package/dist/index.d.mts +236 -9
- package/dist/index.mjs +14 -11
- package/dist/{init-jDQSo-Or.mjs → init-CCV2eRNB.mjs} +3 -3
- package/dist/markdown-rendering.mjs +1 -1
- package/dist/{markdown-sections-7OoA7ylx.mjs → markdown-sections-BKy4labo.mjs} +110 -2
- package/dist/{mcp-CwgKlbIz.mjs → mcp-DsjWxF7g.mjs} +11 -10
- package/dist/mcp.d.mts +20 -5
- package/dist/mcp.mjs +538 -56
- package/dist/{metadata-D4v_R1t5.mjs → metadata-7htr-Xj_.mjs} +1 -1
- package/dist/{content-change-hydration-BsbBXAUi.mjs → openapi-mcp-DQ3xptKo.mjs} +182 -4
- package/dist/openapi-mcp-node-vO3IXVGI.mjs +43 -0
- package/dist/{package-version--oQiHwZj.mjs → package-version-Ci99L0yo.mjs} +1 -1
- package/dist/{prompt-references-DW5vG5zs.mjs → prompt-references-1Wce71c7.mjs} +3 -3
- package/dist/propose-DJOiHu9Y.mjs +73 -0
- package/dist/retrieval-digest-B-SgtXKK.mjs +177 -0
- package/dist/retrieval-digest-DyNRD-mt.d.mts +467 -0
- package/dist/{review-C_5wB0rR.mjs → review-XI9FXeos.mjs} +12 -12
- package/dist/{robots-NQesPX5L.mjs → robots-BOjWB1ky.mjs} +2 -2
- package/dist/{robots-BQ42Y84a.mjs → robots-CzKesbdX.mjs} +6 -6
- package/dist/{search-B5etKU-v.mjs → search-DwAoC9X7.mjs} +12 -11
- package/dist/server.d.mts +47 -264
- package/dist/server.mjs +14 -11
- package/dist/{sidebar-CwZlgyAz.d.mts → sidebar-CJze8SBi.d.mts} +1 -1
- package/dist/{sitemap-DjhxvQP1.mjs → sitemap-DOaJIKJf.mjs} +11 -10
- package/dist/{sitemap-server-B0SiREN0.mjs → sitemap-server-NeVu8W38.mjs} +11 -1
- package/dist/{skills-BFang8vF.mjs → skills-BILSESek.mjs} +11 -10
- package/dist/{standards-discovery-Ckx0tN7B.mjs → standards-discovery-Bpz90VYq.mjs} +2 -177
- package/dist/{standards-discovery-D1Ys4J3h.d.mts → standards-discovery-Xm84bS4M.d.mts} +1 -1
- package/dist/{types-DLLefoU5.d.mts → types-QhYMnKvb.d.mts} +148 -2
- package/dist/{upgrade-kj2crJSk.mjs → upgrade-B92U83xo.mjs} +2 -2
- package/package.json +1 -1
- package/dist/retrieval-digest-DYEsIeCE.d.mts +0 -164
- /package/dist/{audience-exposure-Cw3SA4WE.d.mts → audience-exposure-CkNZNeVX.d.mts} +0 -0
- /package/dist/{cloud-analytics-CSyFE6SS.mjs → cloud-analytics-Ci1yiwD8.mjs} +0 -0
- /package/dist/{config-BaTmjDqD.mjs → config-DrZ3fXgf.mjs} +0 -0
- /package/dist/{errors-DZiNXv5c.mjs → errors-BDmra6mz.mjs} +0 -0
- /package/dist/{i18n-B3BIxShC.mjs → i18n-B1gJ9EW0.mjs} +0 -0
- /package/dist/{sidebar-IcpElOVH.mjs → sidebar-3W51s2sF.mjs} +0 -0
- /package/dist/{templates-kc7jxspR.mjs → templates-DdB4BBGq.mjs} +0 -0
- /package/dist/{utils-DOMeZW9V.mjs → utils-Cc1SrVza.mjs} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { i as detectPackageManagerFromProject } from "./utils-
|
|
2
|
-
import { $ as postcssConfigTemplate, C as globalCssTemplate, g as docsLayoutTemplate, kt as tsconfigTemplate, tt as rootLayoutTemplate } from "./templates-
|
|
1
|
+
import { i as detectPackageManagerFromProject } from "./utils-Cc1SrVza.mjs";
|
|
2
|
+
import { $ as postcssConfigTemplate, C as globalCssTemplate, g as docsLayoutTemplate, kt as tsconfigTemplate, tt as rootLayoutTemplate } from "./templates-DdB4BBGq.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
import os from "node:os";
|
|
7
8
|
import pc from "picocolors";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { z } from "zod";
|
|
10
10
|
|
|
11
11
|
//#region src/cli/dev-banner.ts
|
|
12
12
|
function createDevLogger() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as DocsCloudAskAIResponseOptions, t as DocsCloudAskAIConfig } from "./cloud-ask-ai-
|
|
1
|
+
import { gt as DocsAnalyticsEventInput, ht as DocsAnalyticsEvent, mt as DocsAnalyticsConfig } from "./types-QhYMnKvb.mjs";
|
|
2
|
+
import { n as DocsCloudAskAIResponseOptions, t as DocsCloudAskAIConfig } from "./cloud-ask-ai-BqfiQaNZ.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/docs-cloud-server.d.ts
|
|
5
5
|
type DocsCloudRuntimeValue<T = string> = T | undefined | null | (() => T | undefined | null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as sendDocsCloudAnalyticsEvent } from "./cloud-analytics-
|
|
2
|
-
import { t as createDocsCloudAskAIResponse } from "./cloud-ask-ai-
|
|
1
|
+
import { n as sendDocsCloudAnalyticsEvent } from "./cloud-analytics-Ci1yiwD8.mjs";
|
|
2
|
+
import { t as createDocsCloudAskAIResponse } from "./cloud-ask-ai-CK2qlNns.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/docs-cloud-server.ts
|
|
5
5
|
const DEFAULT_DOCS_CLOUD_API_BASE_URL = "https://api.farming-labs.dev";
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { i as scanDocsPageTargets, n as compactAgentDocs, r as inspectAgentCompactionState } from "./agent-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { I as resolveDocsDiscoveryApiRoute, _ as DEFAULT_API_CATALOG_FORMAT, d as DEFAULT_AGENT_SKILLS_ROUTE_PATTERN, f as DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, h as DEFAULT_AGENT_SKILL_FORMAT, l as DEFAULT_AGENT_SKILLS_INDEX_FORMAT, n as API_CATALOG_MEDIA_TYPE, r as API_CATALOG_PROFILE_URI, t as AGENT_SKILLS_DISCOVERY_SCHEMA_URI, u as DEFAULT_AGENT_SKILLS_INDEX_ROUTE, v as DEFAULT_API_CATALOG_ROUTE } from "./standards-discovery-
|
|
1
|
+
import { i as scanDocsPageTargets, n as compactAgentDocs, r as inspectAgentCompactionState } from "./agent-CaCWThBY.mjs";
|
|
2
|
+
import { f as PAGE_AGENT_CONTRACT_FIELDS } from "./markdown-sections-BKy4labo.mjs";
|
|
3
|
+
import { d as httpLinkHeaderHasTargetRelation, f as AGENT_SKILL_ARCHIVE_MAX_UNCOMPRESSED_BYTES, p as readAgentSkillDocumentFromTar } from "./prompt-references-1Wce71c7.mjs";
|
|
4
|
+
import { A as buildDocsAgentDiscoverySpec, At as DEFAULT_SITEMAP_MD_WELL_KNOWN_ROUTE, F as buildDocsMcpEndpointCandidates, Gn as getDocsMcpProtectedResourceMetadataRoutes, Jn as isDocsMcpOAuthScopeToken, Lt as resolveDocsSitemapConfig, M as buildDocsConfigMap, Qn as normalizeDocsMcpAuthorizationServerUrls, S as DEFAULT_SKILL_MD_WELL_KNOWN_ROUTE, T as DOCS_CONFIG_MAP_TOP_LEVEL_KEYS, Un as DEFAULT_MCP_WELL_KNOWN_ROUTE, Vn as DEFAULT_MCP_PUBLIC_ROUTE, c as DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE, cr as resolveDocsOkfTrustMetadata, h as DEFAULT_LLMS_FULL_TXT_ROUTE, i as DEFAULT_AGENT_FEEDBACK_ROUTE, jt as DEFAULT_SITEMAP_XML_ROUTE, kt as DEFAULT_SITEMAP_MD_ROUTE, l as DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE, mn as resolveAskAISearchRequestConfig, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, sr as resolveDocsOkfConfig, t as DEFAULT_AGENTS_MD_ROUTE, v as DEFAULT_LLMS_TXT_ROUTE, x as DEFAULT_SKILL_MD_ROUTE } from "./agent-DCTGj6J7.mjs";
|
|
5
|
+
import { I as resolveDocsDiscoveryApiRoute, _ as DEFAULT_API_CATALOG_FORMAT, d as DEFAULT_AGENT_SKILLS_ROUTE_PATTERN, f as DEFAULT_AGENT_SKILLS_ROUTE_PREFIX, h as DEFAULT_AGENT_SKILL_FORMAT, l as DEFAULT_AGENT_SKILLS_INDEX_FORMAT, n as API_CATALOG_MEDIA_TYPE, r as API_CATALOG_PROFILE_URI, t as AGENT_SKILLS_DISCOVERY_SCHEMA_URI, u as DEFAULT_AGENT_SKILLS_INDEX_ROUTE, v as DEFAULT_API_CATALOG_ROUTE } from "./standards-discovery-Bpz90VYq.mjs";
|
|
6
6
|
import { isDocsAgentSkillName, validateDocsAgentSkillFrontmatter } from "./agent-skills-spec.mjs";
|
|
7
|
-
import "./
|
|
8
|
-
import { a as analyzeDocsRobotsTxt, n as DEFAULT_ROBOTS_TXT_ROUTE, u as resolveDocsRobotsConfig } from "./robots-
|
|
9
|
-
import { a as resolveDocsMetadataBaseUrl } from "./metadata-
|
|
10
|
-
import "./sitemap-server-
|
|
11
|
-
import { r as resolveConfiguredAgentSkills } from "./agent-skills-server-
|
|
12
|
-
import { t as runDocsGoldenTasks } from "./agent-evals-
|
|
7
|
+
import "./openapi-mcp-DQ3xptKo.mjs";
|
|
8
|
+
import { a as analyzeDocsRobotsTxt, n as DEFAULT_ROBOTS_TXT_ROUTE, u as resolveDocsRobotsConfig } from "./robots-BOjWB1ky.mjs";
|
|
9
|
+
import { a as resolveDocsMetadataBaseUrl } from "./metadata-7htr-Xj_.mjs";
|
|
10
|
+
import "./sitemap-server-NeVu8W38.mjs";
|
|
11
|
+
import { r as resolveConfiguredAgentSkills } from "./agent-skills-server-Ddbf15pY.mjs";
|
|
12
|
+
import { t as runDocsGoldenTasks } from "./agent-evals-D-sPJfXz.mjs";
|
|
13
13
|
import { createFilesystemDocsMcpSource, getDocsConfigSchema, resolveDocsMcpConfig } from "./mcp.mjs";
|
|
14
|
-
import "./
|
|
14
|
+
import "./authoring-mcp-Be7quE5R.mjs";
|
|
15
|
+
import "./code-blocks-D90CCJFs.mjs";
|
|
15
16
|
import "./server.mjs";
|
|
16
|
-
import { _ as resolveDocsContentDir, d as readNavTitle, g as resolveDocsConfigPath, h as readTopLevelStringProperty, l as readBooleanProperty, r as extractTopLevelConfigObject, s as loadDocsConfigModuleResultWithProjectEnv, t as extractNestedObjectLiteral, v as resolveDocsProjectRoot } from "./config-
|
|
17
|
-
import { t as detectFramework } from "./utils-
|
|
18
|
-
import { i as createAgentUsefulnessPagesFromMcp, n as analyzeAgentSurfaceDrift, r as analyzeAgentUsefulness, t as resolveGoldenEvaluationInput } from "./golden-evaluations-
|
|
19
|
-
import { t as analyzeConfiguredAgentSkillsProgressiveDisclosure } from "./agent-skills-progressive-disclosure-
|
|
17
|
+
import { _ as resolveDocsContentDir, d as readNavTitle, g as resolveDocsConfigPath, h as readTopLevelStringProperty, l as readBooleanProperty, r as extractTopLevelConfigObject, s as loadDocsConfigModuleResultWithProjectEnv, t as extractNestedObjectLiteral, v as resolveDocsProjectRoot } from "./config-DrZ3fXgf.mjs";
|
|
18
|
+
import { t as detectFramework } from "./utils-Cc1SrVza.mjs";
|
|
19
|
+
import { i as createAgentUsefulnessPagesFromMcp, n as analyzeAgentSurfaceDrift, r as analyzeAgentUsefulness, t as resolveGoldenEvaluationInput } from "./golden-evaluations-De4KwoYr.mjs";
|
|
20
|
+
import { t as analyzeConfiguredAgentSkillsProgressiveDisclosure } from "./agent-skills-progressive-disclosure-DL-q4JZo.mjs";
|
|
20
21
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
21
22
|
import path from "node:path";
|
|
22
23
|
import { createHash } from "node:crypto";
|
|
@@ -1925,6 +1926,9 @@ async function inspectAgentReadiness(options = {}) {
|
|
|
1925
1926
|
const evaluationCoverage = evaluations.coverage;
|
|
1926
1927
|
const formatDimensionCoverage = (label, dimension) => `${label}: ${dimension.status} (${dimension.measuredTaskCount}/${dimension.totalTaskCount} tasks)`;
|
|
1927
1928
|
checks.push(makeCheck("golden-task-coverage", "Golden evaluation coverage", evaluationCoverage.status === "measured" ? "pass" : "warn", Math.round(evaluationCoverage.coveragePercent / 100 * 5), 5, `${evaluationCoverage.status} coverage across optional confidence dimensions (${evaluationCoverage.measuredTaskDimensions}/${evaluationCoverage.totalTaskDimensions} task-dimensions, ${evaluationCoverage.coveragePercent}%): ${formatDimensionCoverage("safety", evaluationCoverage.dimensions.safety)}; ${formatDimensionCoverage("answer quality", evaluationCoverage.dimensions.answerQuality)}; ${formatDimensionCoverage("executable examples", evaluationCoverage.dimensions.executableExamples)}.`, evaluationCoverage.status === "measured" ? void 0 : "Add golden-task safety expectations, actual-answer assertions, and execute-level example checks so each confidence dimension is measured explicitly."));
|
|
1929
|
+
const okfConfig = resolveDocsOkfConfig(config?.agent?.okf);
|
|
1930
|
+
const staleOkfPages = okfConfig.enabled ? pages.filter((page) => resolveDocsOkfTrustMetadata(page, okfConfig).stale) : [];
|
|
1931
|
+
checks.push(makeCheck("okf-trust", "OKF trust metadata", staleOkfPages.length > 0 ? "warn" : "pass", staleOkfPages.length > 0 ? 1 : 2, 2, !okfConfig.enabled ? "OKF export is optional and not configured." : staleOkfPages.length === 0 ? `OKF v0.2 trust metadata is enabled at ${okfConfig.route}; ${pages.length} page${pages.length === 1 ? "" : "s"} passed the configured staleness policy.` : `${staleOkfPages.length}/${pages.length} OKF document${staleOkfPages.length === 1 ? " is" : "s are"} beyond stale_after.`, staleOkfPages.length > 0 ? "Review or regenerate stale pages, then update okf.verified or stale_after with an auditable timestamp." : void 0));
|
|
1928
1932
|
const hosted = options.url ? await buildHostedAgentChecks(options.url, pages) : void 0;
|
|
1929
1933
|
if (hosted) checks.push(...hosted.checks);
|
|
1930
1934
|
const { score, maxScore } = normalizedDoctorScore(checks.reduce((total, check) => total + check.score, 0), checks.reduce((total, check) => total + check.maxScore, 0));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as fileExists, o as exec, s as execOutput } from "./utils-
|
|
2
|
-
import { a as getPackagesForFramework, c as resolveDocsPackageManager, l as validateUpgradeVersion, r as buildDocsPackageInstallCommand, s as resolveDocsPackageFramework } from "./package-version
|
|
1
|
+
import { c as fileExists, o as exec, s as execOutput } from "./utils-Cc1SrVza.mjs";
|
|
2
|
+
import { a as getPackagesForFramework, c as resolveDocsPackageManager, l as validateUpgradeVersion, r as buildDocsPackageInstallCommand, s as resolveDocsPackageFramework } from "./package-version-Ci99L0yo.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import pc from "picocolors";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { n as analyzeDocsAgentFeedback, r as readDocsAgentFeedbackFile } from "./agent-feedback-loop-vaC-M1sx.mjs";
|
|
2
|
+
import { mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/feedback.ts
|
|
7
|
+
function parseAgentFeedbackImproveArgs(argv) {
|
|
8
|
+
const options = {};
|
|
9
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
10
|
+
const argument = argv[index];
|
|
11
|
+
if (argument === "--write") options.write = true;
|
|
12
|
+
else if (argument === "--json") options.json = true;
|
|
13
|
+
else if (argument === "--help" || argument === "-h") options.help = true;
|
|
14
|
+
else if (argument === "--input" || argument === "--output" || argument === "--min-occurrences") {
|
|
15
|
+
const value = argv[index + 1];
|
|
16
|
+
if (!value || value.startsWith("--")) throw new Error(`${argument} requires a value.`);
|
|
17
|
+
index += 1;
|
|
18
|
+
if (argument === "--input") options.input = value;
|
|
19
|
+
else if (argument === "--output") options.output = value;
|
|
20
|
+
else {
|
|
21
|
+
const parsed = Number(value);
|
|
22
|
+
if (!Number.isInteger(parsed) || parsed < 2 || parsed > 100) throw new Error("--min-occurrences must be an integer from 2 through 100.");
|
|
23
|
+
options.minOccurrences = parsed;
|
|
24
|
+
}
|
|
25
|
+
} else throw new Error(`Unknown agent feedback flag: ${argument}`);
|
|
26
|
+
}
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
function resolveProjectPath(rootDir, value) {
|
|
30
|
+
if (path.isAbsolute(value)) throw new Error("Feedback paths must be project-relative.");
|
|
31
|
+
const candidate = path.resolve(rootDir, value);
|
|
32
|
+
const relative = path.relative(rootDir, candidate);
|
|
33
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) throw new Error("Feedback paths must stay inside the project root.");
|
|
34
|
+
return candidate;
|
|
35
|
+
}
|
|
36
|
+
function writeReport(outputPath, report) {
|
|
37
|
+
mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
38
|
+
const temporaryPath = `${outputPath}.${process.pid}.tmp`;
|
|
39
|
+
writeFileSync(temporaryPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
40
|
+
renameSync(temporaryPath, outputPath);
|
|
41
|
+
}
|
|
42
|
+
async function runAgentFeedbackImprove(options = {}) {
|
|
43
|
+
const rootDir = path.resolve(options.rootDir ?? process.cwd());
|
|
44
|
+
const input = options.input ?? ".farming-labs/agent-feedback.jsonl";
|
|
45
|
+
const output = options.output ?? ".farming-labs/agent-feedback-improvements.json";
|
|
46
|
+
const report = analyzeDocsAgentFeedback(readDocsAgentFeedbackFile(resolveProjectPath(rootDir, input)), { minOccurrences: options.minOccurrences });
|
|
47
|
+
if (options.write) {
|
|
48
|
+
const outputPath = resolveProjectPath(rootDir, output);
|
|
49
|
+
writeReport(outputPath, report);
|
|
50
|
+
if (!options.json) console.log(pc.green(`Wrote ${path.relative(rootDir, outputPath)} with ${report.recurringClusterCount} recurring cluster${report.recurringClusterCount === 1 ? "" : "s"}.`));
|
|
51
|
+
}
|
|
52
|
+
if (options.json || !options.write) console.log(JSON.stringify(report, null, 2));
|
|
53
|
+
return report;
|
|
54
|
+
}
|
|
55
|
+
function printAgentFeedbackImproveHelp() {
|
|
56
|
+
console.log(`${pc.bold("docs agent feedback")} — turn agent feedback into improvement drafts
|
|
57
|
+
|
|
58
|
+
${pc.dim("Usage:")}
|
|
59
|
+
docs agent feedback --input .farming-labs/agent-feedback.jsonl
|
|
60
|
+
docs agent feedback --input feedback.json --write
|
|
61
|
+
|
|
62
|
+
${pc.dim("Options:")}
|
|
63
|
+
${pc.cyan("--input <path>")} JSON array/object or JSON Lines feedback export
|
|
64
|
+
${pc.cyan("--min-occurrences <2-100>")} Recurrence threshold (default: 2)
|
|
65
|
+
${pc.cyan("--write")} Write the improvement report
|
|
66
|
+
${pc.cyan("--output <path>")} Output path (default: .farming-labs/agent-feedback-improvements.json)
|
|
67
|
+
${pc.cyan("--json")} Print JSON when writing
|
|
68
|
+
`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { parseAgentFeedbackImproveArgs, printAgentFeedbackImproveHelp, runAgentFeedbackImprove };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { a as compareDocsAgentFeedbackEvaluationBaseline, i as buildDocsAgentFeedbackEvaluationCandidates, o as createDocsAgentFeedbackEvaluationBaseline, t as DOCS_AGENT_FEEDBACK_EVALUATION_BASELINE_FORMAT } from "./agent-feedback-evaluations-DQCTFegz.mjs";
|
|
2
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
|
|
6
|
+
//#region src/agent-feedback-evaluations-node.ts
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function readJsonFile(filePath) {
|
|
11
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
12
|
+
}
|
|
13
|
+
function readDocsAgentFeedbackImprovementReport(filePath) {
|
|
14
|
+
const value = readJsonFile(filePath);
|
|
15
|
+
if (!isRecord(value) || value.format !== "farming-labs-agent-feedback-improvements.v1" || !Array.isArray(value.clusters) || typeof value.feedbackCount !== "number" || typeof value.recurringClusterCount !== "number") throw new Error("Input is not a supported agent feedback improvement report.");
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function readDocsAgentEvaluationTasksFile(filePath) {
|
|
19
|
+
const value = readJsonFile(filePath);
|
|
20
|
+
if (Array.isArray(value)) return value;
|
|
21
|
+
if (!isRecord(value)) throw new Error("Existing evaluation tasks must be a JSON object or array.");
|
|
22
|
+
if (Array.isArray(value.candidates)) return value.candidates.flatMap((candidate) => isRecord(candidate) && isRecord(candidate.task) ? [candidate.task] : []);
|
|
23
|
+
if (Array.isArray(value.tasks)) return value.tasks;
|
|
24
|
+
if (isRecord(value.agent) && isRecord(value.agent.evaluations) && Array.isArray(value.agent.evaluations.tasks)) return value.agent.evaluations.tasks;
|
|
25
|
+
throw new Error("Could not find evaluation tasks in the existing JSON file.");
|
|
26
|
+
}
|
|
27
|
+
function readDocsGoldenTasksReportFile(filePath) {
|
|
28
|
+
const value = readJsonFile(filePath);
|
|
29
|
+
const report = isRecord(value) && isRecord(value.evaluations) ? value.evaluations : value;
|
|
30
|
+
if (!isRecord(report) || !Array.isArray(report.tasks) || typeof report.taskCount !== "number" || !(typeof report.score === "number" || report.score === null)) throw new Error("Input does not contain a golden-task evaluation report.");
|
|
31
|
+
return report;
|
|
32
|
+
}
|
|
33
|
+
function readDocsAgentFeedbackEvaluationBaseline(filePath) {
|
|
34
|
+
const value = readJsonFile(filePath);
|
|
35
|
+
if (!isRecord(value) || value.format !== DOCS_AGENT_FEEDBACK_EVALUATION_BASELINE_FORMAT || typeof value.score !== "number" || !Array.isArray(value.tasks)) throw new Error("Evaluation baseline format is not supported.");
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/cli/feedback-evals.ts
|
|
41
|
+
function parseAgentFeedbackEvaluationsArgs(argv) {
|
|
42
|
+
const options = { existing: [] };
|
|
43
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
44
|
+
const argument = argv[index];
|
|
45
|
+
if (argument === "--write") options.write = true;
|
|
46
|
+
else if (argument === "--write-baseline") options.writeBaseline = true;
|
|
47
|
+
else if (argument === "--check") options.check = true;
|
|
48
|
+
else if (argument === "--allow-new-failures") options.allowNewFailures = true;
|
|
49
|
+
else if (argument === "--json") options.json = true;
|
|
50
|
+
else if (argument === "--help" || argument === "-h") options.help = true;
|
|
51
|
+
else if (argument === "--input" || argument === "--existing" || argument === "--output" || argument === "--results" || argument === "--baseline" || argument === "--max-score-drop") {
|
|
52
|
+
const value = argv[index + 1];
|
|
53
|
+
if (!value || value.startsWith("--")) throw new Error(`${argument} requires a value.`);
|
|
54
|
+
index += 1;
|
|
55
|
+
if (argument === "--input") options.input = value;
|
|
56
|
+
else if (argument === "--existing") options.existing.push(value);
|
|
57
|
+
else if (argument === "--output") options.output = value;
|
|
58
|
+
else if (argument === "--results") options.results = value;
|
|
59
|
+
else if (argument === "--baseline") options.baseline = value;
|
|
60
|
+
else {
|
|
61
|
+
const parsed = Number(value);
|
|
62
|
+
if (!Number.isFinite(parsed) || parsed < 0 || parsed > 100) throw new Error("--max-score-drop must be a number from 0 through 100.");
|
|
63
|
+
options.maxScoreDrop = parsed;
|
|
64
|
+
}
|
|
65
|
+
} else throw new Error(`Unknown agent feedback-evals flag: ${argument}`);
|
|
66
|
+
}
|
|
67
|
+
return options;
|
|
68
|
+
}
|
|
69
|
+
function resolveProjectPath(rootDir, value) {
|
|
70
|
+
if (path.isAbsolute(value)) throw new Error("Evaluation paths must be project-relative.");
|
|
71
|
+
const candidate = path.resolve(rootDir, value);
|
|
72
|
+
const relative = path.relative(rootDir, candidate);
|
|
73
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) throw new Error("Evaluation paths must stay inside the project root.");
|
|
74
|
+
return candidate;
|
|
75
|
+
}
|
|
76
|
+
function writeJson(outputPath, value) {
|
|
77
|
+
mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
78
|
+
const temporaryPath = `${outputPath}.${process.pid}.tmp`;
|
|
79
|
+
writeFileSync(temporaryPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
80
|
+
renameSync(temporaryPath, outputPath);
|
|
81
|
+
}
|
|
82
|
+
async function runCandidateMode(rootDir, options) {
|
|
83
|
+
const registry = buildDocsAgentFeedbackEvaluationCandidates(readDocsAgentFeedbackImprovementReport(resolveProjectPath(rootDir, options.input ?? ".farming-labs/agent-feedback-improvements.json")), { existingTasks: (options.existing ?? []).flatMap((filePath) => readDocsAgentEvaluationTasksFile(resolveProjectPath(rootDir, filePath))) });
|
|
84
|
+
if (options.write) {
|
|
85
|
+
const outputPath = resolveProjectPath(rootDir, options.output ?? ".farming-labs/agent-evaluation-candidates.json");
|
|
86
|
+
writeJson(outputPath, registry);
|
|
87
|
+
if (!options.json) console.log(pc.green(`Wrote ${path.relative(rootDir, outputPath)} with ${registry.candidateCount} review-required candidate${registry.candidateCount === 1 ? "" : "s"}.`));
|
|
88
|
+
}
|
|
89
|
+
if (options.json || !options.write) console.log(JSON.stringify(registry, null, 2));
|
|
90
|
+
return registry;
|
|
91
|
+
}
|
|
92
|
+
async function runRegressionMode(rootDir, options) {
|
|
93
|
+
if (!options.results || !options.baseline) throw new Error("--results and --baseline are required for baseline or regression mode.");
|
|
94
|
+
const results = readDocsGoldenTasksReportFile(resolveProjectPath(rootDir, options.results));
|
|
95
|
+
const baselinePath = resolveProjectPath(rootDir, options.baseline);
|
|
96
|
+
if (options.writeBaseline) {
|
|
97
|
+
const baseline = createDocsAgentFeedbackEvaluationBaseline(results);
|
|
98
|
+
writeJson(baselinePath, baseline);
|
|
99
|
+
if (!options.json) console.log(pc.green(`Wrote ${path.relative(rootDir, baselinePath)}.`));
|
|
100
|
+
if (options.json) console.log(JSON.stringify(baseline, null, 2));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const comparison = compareDocsAgentFeedbackEvaluationBaseline(results, readDocsAgentFeedbackEvaluationBaseline(baselinePath), {
|
|
104
|
+
maxScoreDrop: options.maxScoreDrop,
|
|
105
|
+
failOnNewFailures: options.allowNewFailures !== true
|
|
106
|
+
});
|
|
107
|
+
console.log(JSON.stringify(comparison, null, 2));
|
|
108
|
+
if (options.check && !comparison.passed) throw new Error(`Agent evaluation regression check failed with ${comparison.regressions.length} regression(s).`);
|
|
109
|
+
return comparison;
|
|
110
|
+
}
|
|
111
|
+
async function runAgentFeedbackEvaluations(options = {}) {
|
|
112
|
+
const rootDir = path.resolve(options.rootDir ?? process.cwd());
|
|
113
|
+
if (options.writeBaseline && options.check) throw new Error("--write-baseline and --check are separate operations.");
|
|
114
|
+
if (options.results !== void 0 || options.baseline !== void 0 || options.writeBaseline === true || options.check === true) return runRegressionMode(rootDir, options);
|
|
115
|
+
return runCandidateMode(rootDir, options);
|
|
116
|
+
}
|
|
117
|
+
function printAgentFeedbackEvaluationsHelp() {
|
|
118
|
+
console.log(`${pc.bold("docs agent feedback-evals")} — promote feedback into reviewed evaluations and guard regressions
|
|
119
|
+
|
|
120
|
+
${pc.dim("Candidate usage:")}
|
|
121
|
+
docs agent feedback-evals --input .farming-labs/agent-feedback-improvements.json
|
|
122
|
+
docs agent feedback-evals --existing docs-evaluations.json --write
|
|
123
|
+
|
|
124
|
+
${pc.dim("Regression usage:")}
|
|
125
|
+
docs agent feedback-evals --results doctor.json --baseline .farming-labs/agent-evaluation-baseline.json --write-baseline
|
|
126
|
+
docs agent feedback-evals --results doctor.json --baseline .farming-labs/agent-evaluation-baseline.json --check
|
|
127
|
+
|
|
128
|
+
${pc.dim("Options:")}
|
|
129
|
+
${pc.cyan("--input <path>")} Feedback improvement report
|
|
130
|
+
${pc.cyan("--existing <path>")} Repeatable registry/config/task JSON used for deduplication
|
|
131
|
+
${pc.cyan("--write")} Write sanitized candidates
|
|
132
|
+
${pc.cyan("--output <path>")} Candidate output (default: .farming-labs/agent-evaluation-candidates.json)
|
|
133
|
+
${pc.cyan("--results <path>")} Golden-task or doctor JSON evaluation results
|
|
134
|
+
${pc.cyan("--baseline <path>")} Baseline JSON path
|
|
135
|
+
${pc.cyan("--write-baseline")} Create or replace the baseline from --results
|
|
136
|
+
${pc.cyan("--check")} Fail when results regress from the baseline
|
|
137
|
+
${pc.cyan("--max-score-drop <0-100>")} Allowed suite/task score decrease (default: 0)
|
|
138
|
+
${pc.cyan("--allow-new-failures")} Do not fail only because a newly added task fails
|
|
139
|
+
${pc.cyan("--json")} Print written candidate/baseline JSON
|
|
140
|
+
|
|
141
|
+
Candidates are redacted, deduplicated, and never added to docs.config without human review.
|
|
142
|
+
`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
export { parseAgentFeedbackEvaluationsArgs, printAgentFeedbackEvaluationsHelp, runAgentFeedbackEvaluations };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as extractCodeBlocksFromMarkdown } from "./code-blocks-
|
|
1
|
+
import { _ as hasStructuredPageAgentContract, v as normalizePageAgentFrontmatter } from "./markdown-sections-BKy4labo.mjs";
|
|
2
|
+
import { An as normalizeAgentFramework, En as resolveDocsAudienceMdxContent, Nn as normalizeAgentVersion, kn as agentVersionConstraintsOverlap, wn as findDocsAudienceMdxTags } from "./agent-DCTGj6J7.mjs";
|
|
3
|
+
import { t as extractCodeBlocksFromMarkdown } from "./code-blocks-D90CCJFs.mjs";
|
|
4
4
|
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
5
5
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|