@farming-labs/docs 0.2.120 → 0.2.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.
Files changed (188) hide show
  1. package/README.md +8 -0
  2. package/dist/access.d.mts +13 -0
  3. package/dist/access.mjs +56 -0
  4. package/dist/agent-conformance.d.mts +60 -0
  5. package/dist/agent-conformance.mjs +538 -0
  6. package/dist/agent-contract.d.mts +47 -0
  7. package/dist/agent-contract.mjs +645 -0
  8. package/dist/agent-detection.d.mts +6 -0
  9. package/dist/agent-detection.mjs +83 -0
  10. package/dist/agent-evals.d.mts +224 -0
  11. package/dist/{agent-evals-BLNLvXbG.mjs → agent-evals.mjs} +7 -565
  12. package/dist/agent-feedback-evaluations-node.mjs +38 -0
  13. package/dist/agent-feedback-evaluations.d.mts +91 -0
  14. package/dist/{agent-feedback-evaluations-CcMGlgsO.mjs → agent-feedback-evaluations.mjs} +2 -2
  15. package/dist/agent-feedback-loop.d.mts +45 -0
  16. package/dist/{agent-feedback-loop-CcZL_sb1.mjs → agent-feedback-loop.mjs} +1 -1
  17. package/dist/agent-maintenance.d.mts +71 -0
  18. package/dist/{agent-maintenance-CuZ7iAKq.mjs → agent-maintenance.mjs} +1 -1
  19. package/dist/agent-provenance.d.mts +23 -0
  20. package/dist/agent-provenance.mjs +77 -0
  21. package/dist/agent-scope.mjs +321 -0
  22. package/dist/agent-skills-archive.mjs +86 -0
  23. package/dist/agent-skills-bundle.d.mts +1 -1
  24. package/dist/{agent-skills-progressive-disclosure-PjPtTYL-.mjs → agent-skills-progressive-disclosure.mjs} +2 -2
  25. package/dist/{agent-skills-server-D5IuvwM7.d.mts → agent-skills-server.d.mts} +3 -3
  26. package/dist/{agent-skills-server-BC7md56k.mjs → agent-skills-server.mjs} +2 -2
  27. package/dist/agent-skills-vite.d.mts +3 -3
  28. package/dist/agent-skills-vite.mjs +1 -2
  29. package/dist/agent-surface-drift.mjs +236 -0
  30. package/dist/{golden-evaluations-CLUViycJ.mjs → agent-usefulness.mjs} +5 -290
  31. package/dist/{content-change-hydration-wqXIZHp6.d.mts → agent.d.mts} +10 -411
  32. package/dist/agent.mjs +2729 -0
  33. package/dist/{analytics-w3FDOksr.d.mts → analytics.d.mts} +2 -2
  34. package/dist/{analytics-p8Vhhu2P.mjs → analytics.mjs} +2 -2
  35. package/dist/{sitemap-server-BUdPBcGs.d.mts → api-reference.d.mts} +2 -6
  36. package/dist/api-reference.mjs +1481 -0
  37. package/dist/{audience-exposure-DBrFWULA.d.mts → audience-exposure.d.mts} +1 -1
  38. package/dist/audience-exposure.mjs +8 -0
  39. package/dist/audience.d.mts +44 -0
  40. package/dist/audience.mjs +1654 -0
  41. package/dist/authoring-mcp.d.mts +44 -0
  42. package/dist/{authoring-mcp-CiCUQe3o.mjs → authoring-mcp.mjs} +3 -3
  43. package/dist/browser.d.mts +6 -4
  44. package/dist/browser.mjs +6 -7
  45. package/dist/build.d.mts +8 -0
  46. package/dist/build.mjs +8 -0
  47. package/dist/changelog.d.mts +20 -0
  48. package/dist/changelog.mjs +39 -0
  49. package/dist/{agent-export-CA6IUQ7T.mjs → cli/agent-export.mjs} +19 -45
  50. package/dist/{agent-CYk2DxY7.mjs → cli/agent.mjs} +6 -35
  51. package/dist/{agents-BUiVmj8i.mjs → cli/agents.mjs} +5 -18
  52. package/dist/cli/api-doctor.mjs +206 -0
  53. package/dist/{authoring-C2ymvYWl.mjs → cli/authoring.mjs} +2 -8
  54. package/dist/{cloud-6eKrlmKd.mjs → cli/cloud.mjs} +3 -3
  55. package/dist/{codeblocks-CHpgAwY-.mjs → cli/codeblocks.mjs} +2 -2
  56. package/dist/cli/config.d.mts +11 -0
  57. package/dist/{config-BZnKAj_Y.mjs → cli/config.mjs} +1 -1
  58. package/dist/cli/dev-banner.mjs +58 -0
  59. package/dist/{dev-Bnn-NUNa.mjs → cli/dev.mjs} +3 -57
  60. package/dist/{doctor-Bfkrkzad.mjs → cli/doctor.mjs} +41 -226
  61. package/dist/{downgrade-CHMta85e.mjs → cli/downgrade.mjs} +2 -2
  62. package/dist/cli/errors.d.mts +4 -0
  63. package/dist/{errors-BtnVLhNF.mjs → cli/errors.mjs} +1 -1
  64. package/dist/{feedback-evals-DMilg9pY.mjs → cli/feedback-evals.mjs} +3 -36
  65. package/dist/{feedback-DL4T5oIO.mjs → cli/feedback.mjs} +1 -1
  66. package/dist/cli/git-dates.mjs +35 -0
  67. package/dist/cli/golden-evaluations.mjs +52 -0
  68. package/dist/cli/index.d.mts +2 -3
  69. package/dist/cli/index.mjs +38 -38
  70. package/dist/{init-K0LmXDZ5.mjs → cli/init.mjs} +3 -3
  71. package/dist/{mcp-iLCmnPJI.mjs → cli/mcp.mjs} +7 -19
  72. package/dist/{openapi-diff-HcpUNjA-.mjs → cli/openapi-diff.mjs} +2 -7
  73. package/dist/{openapi-sdk-BQKC6H-_.mjs → cli/openapi-sdk.mjs} +2 -7
  74. package/dist/{openapi-source-DK6ts_Bk.mjs → cli/openapi-source.mjs} +2 -2
  75. package/dist/{package-version-HJhYeq4M.mjs → cli/package-version.mjs} +2 -2
  76. package/dist/{propose-JmUv_BTt.mjs → cli/propose.mjs} +1 -1
  77. package/dist/{review-C6EmbV0l.mjs → cli/review.mjs} +16 -15
  78. package/dist/{robots-DteZB8vl.mjs → cli/robots.mjs} +3 -7
  79. package/dist/{search-Bhuv_YsL.mjs → cli/search.mjs} +7 -20
  80. package/dist/{sitemap-DW5LDKDa.mjs → cli/sitemap.mjs} +7 -42
  81. package/dist/{skills-BAPQLSCm.mjs → cli/skills.mjs} +5 -19
  82. package/dist/{templates-BuQ8YsGv.mjs → cli/templates.mjs} +1 -1
  83. package/dist/{upgrade-DlQMOFV1.mjs → cli/upgrade.mjs} +2 -2
  84. package/dist/{utils-C7KDrPpA.mjs → cli/utils.mjs} +1 -1
  85. package/dist/client/react.d.mts +2 -18
  86. package/dist/client/react.mjs +1 -157
  87. package/dist/{cloud-analytics-D14HplI7.mjs → cloud-analytics.mjs} +1 -1
  88. package/dist/{cloud-ask-ai-BrsTXQf6.d.mts → cloud-ask-ai.d.mts} +2 -2
  89. package/dist/{cloud-ask-ai-BqKhjpS5.mjs → cloud-ask-ai.mjs} +3 -3
  90. package/dist/code-blocks.d.mts +51 -0
  91. package/dist/{code-blocks-GYdvS3BH.mjs → code-blocks.mjs} +2 -2
  92. package/dist/code-group-mdx.d.mts +11 -0
  93. package/dist/code-group-mdx.mjs +57 -0
  94. package/dist/content-change-hydration.d.mts +87 -0
  95. package/dist/{openapi-mcp-BIOTLiA7.mjs → content-change-hydration.mjs} +5 -210
  96. package/dist/content-changes.d.mts +47 -0
  97. package/dist/content-changes.mjs +216 -0
  98. package/dist/create-theme.d.mts +48 -0
  99. package/dist/create-theme.mjs +57 -0
  100. package/dist/date.d.mts +5 -0
  101. package/dist/date.mjs +17 -0
  102. package/dist/define-docs.d.mts +9 -0
  103. package/dist/define-docs.mjs +46 -0
  104. package/dist/docs-cloud-client.d.mts +18 -0
  105. package/dist/docs-cloud-client.mjs +161 -0
  106. package/dist/docs-cloud-server.d.mts +2 -2
  107. package/dist/docs-cloud-server.mjs +2 -3
  108. package/dist/heading-toc.d.mts +10 -0
  109. package/dist/heading-toc.mjs +23 -0
  110. package/dist/http-body.d.mts +14 -0
  111. package/dist/{http-body-DkAPk6D5.mjs → http-body.mjs} +1 -1
  112. package/dist/http-cache.d.mts +25 -0
  113. package/dist/http-cache.mjs +140 -0
  114. package/dist/http-link.mjs +81 -0
  115. package/dist/i18n.d.mts +18 -0
  116. package/dist/{i18n-B1gJ9EW0.mjs → i18n.mjs} +1 -1
  117. package/dist/index.d.mts +42 -674
  118. package/dist/index.mjs +40 -14
  119. package/dist/markdown-rendering.mjs +1 -1
  120. package/dist/markdown-section-cache.mjs +49 -0
  121. package/dist/markdown-sections.d.mts +47 -0
  122. package/dist/{markdown-sections-9Oxr33b-.mjs → markdown-sections.mjs} +29 -703
  123. package/dist/mcp-auth.d.mts +14 -0
  124. package/dist/mcp-auth.mjs +99 -0
  125. package/dist/mcp.d.mts +5 -3
  126. package/dist/mcp.mjs +21 -9
  127. package/dist/mdx.d.mts +6 -0
  128. package/dist/mdx.mjs +7 -0
  129. package/dist/metadata.d.mts +60 -0
  130. package/dist/{metadata-BOHn0Y5K.mjs → metadata.mjs} +2 -2
  131. package/dist/native-api-reference.mjs +968 -0
  132. package/dist/okf.d.mts +42 -0
  133. package/dist/okf.mjs +145 -0
  134. package/dist/openapi-contract.mjs +154 -0
  135. package/dist/{openapi-mcp-node-C4jUpZG6.mjs → openapi-mcp-node.mjs} +1 -1
  136. package/dist/openapi-mcp.d.mts +26 -0
  137. package/dist/openapi-mcp.mjs +132 -0
  138. package/dist/openapi-operations.d.mts +71 -0
  139. package/dist/{openapi-operations-DFpaqOqA.mjs → openapi-operations.mjs} +1 -1
  140. package/dist/openapi-overlays.mjs +221 -0
  141. package/dist/openapi-references.mjs +233 -0
  142. package/dist/pagination.d.mts +7 -0
  143. package/dist/pagination.mjs +100 -0
  144. package/dist/prompt-references.d.mts +12 -0
  145. package/dist/prompt-references.mjs +132 -0
  146. package/dist/prompt-utils.d.mts +36 -0
  147. package/dist/{prompt-utils-B5g-bv7o.mjs → prompt-utils.mjs} +1 -57
  148. package/dist/reading-time.d.mts +23 -0
  149. package/dist/reading-time.mjs +58 -0
  150. package/dist/related.d.mts +7 -0
  151. package/dist/related.mjs +50 -0
  152. package/dist/retrieval-digest.d.mts +16 -0
  153. package/dist/{retrieval-digest-CT-eIEcp.mjs → retrieval-digest.mjs} +1 -1
  154. package/dist/review.d.mts +69 -0
  155. package/dist/review.mjs +562 -0
  156. package/dist/robots.d.mts +54 -0
  157. package/dist/{robots-BYJAVeI6.mjs → robots.mjs} +5 -3
  158. package/dist/runtime.d.mts +3 -3
  159. package/dist/runtime.mjs +3 -9
  160. package/dist/search.d.mts +210 -0
  161. package/dist/search.mjs +3401 -0
  162. package/dist/server.d.mts +22 -198
  163. package/dist/server.mjs +21 -19
  164. package/dist/sidebar.d.mts +15 -0
  165. package/dist/sidebar.mjs +73 -0
  166. package/dist/sitemap-server.d.mts +7 -0
  167. package/dist/{sitemap-server-Lg3YhUx4.mjs → sitemap-server.mjs} +2 -2
  168. package/dist/{sitemap-Cl8vrixd.d.mts → sitemap.d.mts} +3 -3
  169. package/dist/sitemap.mjs +254 -0
  170. package/dist/{standards-discovery-BHPc7YIX.d.mts → standards-discovery.d.mts} +2 -2
  171. package/dist/{standards-discovery-sSEojU80.mjs → standards-discovery.mjs} +3 -139
  172. package/dist/telemetry-runtime.d.mts +42 -0
  173. package/dist/telemetry-runtime.mjs +238 -0
  174. package/dist/telemetry.d.mts +15 -0
  175. package/dist/telemetry.mjs +117 -0
  176. package/dist/{types-BJFeMXWZ.d.mts → types.d.mts} +3 -2
  177. package/dist/urls.d.mts +7 -0
  178. package/dist/urls.mjs +21 -0
  179. package/dist/utils.d.mts +8 -0
  180. package/dist/utils.mjs +22 -0
  181. package/package.json +21 -3
  182. package/dist/agent-DkAidqtV.mjs +0 -9026
  183. package/dist/api-reference-BYee4zMo.mjs +0 -3046
  184. package/dist/prompt-references-DMgbu_dz.mjs +0 -1082
  185. package/dist/retrieval-digest-AOx2-LbC.d.mts +0 -367
  186. package/dist/sidebar-CFHBj29f.mjs +0 -421
  187. package/dist/sidebar-CMPbVfGP.d.mts +0 -63
  188. /package/dist/{openapi-CfCzX_a1.mjs → cli/openapi.mjs} +0 -0
@@ -1,570 +1,12 @@
1
- import { S as upsertPageAgentContractMarkdown, l as stripDocsGeneratedAgentContractMarkers, o as findDocsMarkdownSection } from "./markdown-sections-9Oxr33b-.mjs";
2
- import { $t as buildDocsAskAIContext, An as agentVersionConstraintMatches, Fn as normalizeAgentVersion, Mn as normalizeAgentFramework, Nn as normalizeAgentLocale, Pn as normalizeAgentScopeValues, Sn as resolveSearchRequestConfig, fn as normalizeDocsSearchFilters, jn as agentVersionConstraintsOverlap, kn as agentVersionConstraintGroupsOverlap, pn as performDocsSearch, tn as buildDocsRetrievalDigestProjection } from "./agent-DkAidqtV.mjs";
3
- import { n as digestDocsRetrievalContent } from "./retrieval-digest-CT-eIEcp.mjs";
4
- import { t as getDocsAgentSkillsConfiguredPaths } from "./agent-skills-server-BC7md56k.mjs";
1
+ import { upsertPageAgentContractMarkdown } from "./agent-contract.mjs";
2
+ import { findDocsMarkdownSection, stripDocsGeneratedAgentContractMarkers } from "./markdown-sections.mjs";
3
+ import { digestDocsRetrievalContent } from "./retrieval-digest.mjs";
4
+ import { agentVersionConstraintGroupsOverlap, agentVersionConstraintMatches, agentVersionConstraintsOverlap, normalizeAgentFramework, normalizeAgentLocale, normalizeAgentScopeValues, normalizeAgentVersion } from "./agent-scope.mjs";
5
+ import { buildDocsAskAIContext, buildDocsRetrievalDigestProjection, normalizeDocsSearchFilters, performDocsSearch, resolveSearchRequestConfig } from "./search.mjs";
5
6
  import { buildDocsMcpContext } from "./mcp.mjs";
6
- import { i as validateCodeBlockPlans, n as planCodeBlockTargets, r as resolveDocsCodeBlocksValidateConfig, t as extractCodeBlocksFromMarkdown } from "./code-blocks-GYdvS3BH.mjs";
7
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
8
- import { dirname, isAbsolute, join, relative } from "node:path";
7
+ import { extractCodeBlocksFromMarkdown, planCodeBlockTargets, resolveDocsCodeBlocksValidateConfig, validateCodeBlockPlans } from "./code-blocks.mjs";
9
8
  import { createJiti } from "jiti";
10
9
 
11
- //#region src/review.ts
12
- const DEFAULT_DOCS_REVIEW_WORKFLOW_PATH = ".github/workflows/docs-review.yml";
13
- const DEFAULT_DOCS_REVIEW_REUSABLE_WORKFLOW_PATH = ".github/workflows/docs-review-reusable.yml";
14
- const DEFAULT_DOCS_REVIEW_REUSABLE_WORKFLOW = "farming-labs/docs/.github/workflows/docs-review-reusable.yml@main";
15
- const LOCAL_DOCS_REVIEW_REUSABLE_WORKFLOW = "./.github/workflows/docs-review-reusable.yml";
16
- const DEFAULT_DOCS_REVIEW_PNPM_VERSION = "10";
17
- const DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD = 80;
18
- const DEFAULT_DOCS_REVIEW_CI_NAME = "docs-review";
19
- const DEFAULT_REVIEW_RULES = {
20
- brokenLinks: "error",
21
- frontmatter: "error",
22
- duplicateSlugs: "error",
23
- invalidMdx: "error",
24
- configExamples: "warn",
25
- codeFenceMetadata: "warn",
26
- runnableMetadata: "warn",
27
- agentContext: "warn",
28
- commandHealth: "warn",
29
- relatedCoverage: "suggestion",
30
- configConfidence: "warn",
31
- agentSurfaceDrift: "error",
32
- goldenTasks: "warn",
33
- agentSkills: "warn"
34
- };
35
- const DEFAULT_REVIEW_WEIGHTS = {
36
- error: 20,
37
- warn: 8,
38
- suggestion: 2
39
- };
40
- const REVIEW_SEVERITIES = new Set([
41
- "off",
42
- "suggestion",
43
- "warn",
44
- "error"
45
- ]);
46
- const REVIEW_CI_MODES = new Set([
47
- "off",
48
- "warn",
49
- "block"
50
- ]);
51
- const FILE_EXTS = [
52
- "tsx",
53
- "ts",
54
- "jsx",
55
- "js"
56
- ];
57
- function resolveDocsReviewConfig(review) {
58
- if (review === false) return {
59
- enabled: false,
60
- ci: {
61
- enabled: false,
62
- name: DEFAULT_DOCS_REVIEW_CI_NAME,
63
- mode: "off",
64
- annotations: false,
65
- comment: false
66
- },
67
- score: {
68
- threshold: DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD,
69
- weights: DEFAULT_REVIEW_WEIGHTS
70
- },
71
- rules: DEFAULT_REVIEW_RULES
72
- };
73
- const objectConfig = review && typeof review === "object" ? review : {};
74
- const ciConfig = objectConfig.ci;
75
- const ciObject = ciConfig && typeof ciConfig === "object" ? ciConfig : {};
76
- const configuredMode = ciObject.mode;
77
- const mode = configuredMode && REVIEW_CI_MODES.has(configuredMode) ? configuredMode : "warn";
78
- const enabled = objectConfig.enabled !== false;
79
- const ciEnabled = enabled && ciConfig !== false && ciObject.enabled !== false && mode !== "off";
80
- return {
81
- enabled,
82
- ci: {
83
- enabled: ciEnabled,
84
- name: normalizeCiName(ciObject.name),
85
- mode: ciEnabled ? mode : "off",
86
- annotations: ciObject.annotations !== false,
87
- comment: ciObject.comment !== false
88
- },
89
- score: {
90
- threshold: clampScoreThreshold(objectConfig.score?.threshold),
91
- weights: {
92
- error: normalizeWeight(objectConfig.score?.weights?.error, DEFAULT_REVIEW_WEIGHTS.error),
93
- warn: normalizeWeight(objectConfig.score?.weights?.warn, DEFAULT_REVIEW_WEIGHTS.warn),
94
- suggestion: normalizeWeight(objectConfig.score?.weights?.suggestion, DEFAULT_REVIEW_WEIGHTS.suggestion)
95
- }
96
- },
97
- rules: {
98
- ...DEFAULT_REVIEW_RULES,
99
- ...normalizeRules(objectConfig.rules)
100
- }
101
- };
102
- }
103
- function buildDocsReviewWorkflow(options = {}) {
104
- const packageManager = options.packageManager ?? "npm";
105
- const ciName = normalizeCiName(options.ciName);
106
- const projectDir = normalizeProjectDir(options.projectDir);
107
- const configPath = options.configPath ?? "docs.config.ts";
108
- const reusableWorkflow = options.reusableWorkflow ?? DEFAULT_DOCS_REVIEW_REUSABLE_WORKFLOW;
109
- const filters = normalizePathFilters(options.pathFilters);
110
- const workflowInputs = [
111
- ["check-name", ciName],
112
- ["config", configPath],
113
- ["working-directory", projectDir],
114
- ["package-manager", packageManager],
115
- options.pnpmVersion ? ["pnpm-version", options.pnpmVersion] : void 0,
116
- options.buildCommand ? ["build-command", options.buildCommand] : void 0,
117
- options.reviewCommand ? ["review-command", options.reviewCommand] : void 0
118
- ].filter((input) => Boolean(input)).map(([key, value]) => ` ${key}: ${JSON.stringify(value)}`).join("\n");
119
- return `# Generated by @farming-labs/docs. You can edit this file.
120
- name: Docs Review
121
-
122
- on:
123
- pull_request:
124
- paths:
125
- ${filters.map((filter) => ` - ${JSON.stringify(filter)}`).join("\n")}
126
-
127
- permissions:
128
- contents: read
129
- checks: write
130
- pull-requests: write
131
-
132
- jobs:
133
- docs-review:
134
- name: ${JSON.stringify(ciName)}
135
- uses: ${reusableWorkflow}
136
- with:
137
- ${workflowInputs}
138
- permissions:
139
- contents: read
140
- checks: write
141
- pull-requests: write
142
- `;
143
- }
144
- function ensureDocsReviewWorkflow(options) {
145
- const rootDir = options.rootDir;
146
- const repoRoot = findGitRoot(rootDir) ?? rootDir;
147
- const workflowRelativePath = options.workflowPath ?? DEFAULT_DOCS_REVIEW_WORKFLOW_PATH;
148
- const workflowPath = isAbsolute(workflowRelativePath) ? workflowRelativePath : join(repoRoot, workflowRelativePath);
149
- const resultRelativePath = toPosixPath(relative(repoRoot, workflowPath));
150
- const review = resolveDocsReviewConfig(options.config?.review ?? readDocsReviewConfigFromSource(options.configContent ?? readConfig(rootDir)));
151
- if (!review.enabled || !review.ci.enabled) return {
152
- status: "disabled",
153
- path: workflowPath,
154
- relativePath: resultRelativePath
155
- };
156
- if (existsSync(workflowPath)) return {
157
- status: "exists",
158
- path: workflowPath,
159
- relativePath: resultRelativePath
160
- };
161
- const configPath = options.configPath ?? findDocsConfigPath(rootDir);
162
- const configContent = options.configContent ?? readConfig(rootDir, configPath);
163
- const projectDir = toPosixPath(relative(repoRoot, rootDir)) || ".";
164
- const packageManager = detectPackageManager(repoRoot);
165
- const workflow = buildDocsReviewWorkflow({
166
- packageManager,
167
- ciName: review.ci.name,
168
- reusableWorkflow: hasLocalDocsWorkspacePackage(repoRoot) ? LOCAL_DOCS_REVIEW_REUSABLE_WORKFLOW : DEFAULT_DOCS_REVIEW_REUSABLE_WORKFLOW,
169
- pnpmVersion: detectPnpmVersionFallback(repoRoot, packageManager),
170
- projectDir,
171
- configPath,
172
- buildCommand: detectLocalDocsCliBuildCommand(repoRoot, packageManager),
173
- reviewCommand: detectLocalDocsCliReviewCommand(repoRoot, rootDir),
174
- pathFilters: buildDocsReviewWorkflowPathFilters({
175
- rootDir,
176
- repoRoot,
177
- config: options.config,
178
- configPath,
179
- configContent
180
- })
181
- });
182
- mkdirSync(dirname(workflowPath), { recursive: true });
183
- writeFileSync(workflowPath, workflow, "utf-8");
184
- options.log?.(`[docs] Created ${resultRelativePath} for Docs Review CI.`);
185
- return {
186
- status: "created",
187
- path: workflowPath,
188
- relativePath: resultRelativePath
189
- };
190
- }
191
- function readDocsReviewConfigFromSource(content) {
192
- if (!content) return void 0;
193
- const rootObject = extractRootObjectLiteral(content) ?? content;
194
- const reviewCursor = findTopLevelPropertyValueIndex(rootObject, "review");
195
- if (reviewCursor === void 0) return void 0;
196
- if (rootObject.startsWith("true", reviewCursor)) return true;
197
- if (rootObject.startsWith("false", reviewCursor)) return false;
198
- if (rootObject[reviewCursor] !== "{") return void 0;
199
- const reviewEnd = findMatchingObjectEnd(rootObject, reviewCursor);
200
- if (reviewEnd === void 0) return void 0;
201
- const reviewBlock = rootObject.slice(reviewCursor + 1, reviewEnd);
202
- const scoreBlock = extractTopLevelObjectLiteral(reviewBlock, "score");
203
- const ciCursor = findTopLevelPropertyValueIndex(reviewBlock, "ci");
204
- const rulesBlock = extractTopLevelObjectLiteral(reviewBlock, "rules");
205
- const ci = ciCursor === void 0 ? void 0 : reviewBlock.startsWith("true", ciCursor) ? true : reviewBlock.startsWith("false", ciCursor) ? false : reviewBlock[ciCursor] === "{" ? readReviewCiObject(reviewBlock, ciCursor) : void 0;
206
- return {
207
- enabled: readTopLevelBoolean(reviewBlock, "enabled"),
208
- score: scoreBlock ? {
209
- threshold: readTopLevelNumber(scoreBlock, "threshold"),
210
- weights: readReviewWeights(scoreBlock)
211
- } : void 0,
212
- ci,
213
- rules: rulesBlock ? readReviewRules(rulesBlock) : void 0
214
- };
215
- }
216
- function buildDocsReviewWorkflowPathFilters(options) {
217
- const repoRoot = options.repoRoot ?? findGitRoot(options.rootDir) ?? options.rootDir;
218
- const configPath = options.configPath ?? findDocsConfigPath(options.rootDir);
219
- const configContent = options.configContent ?? readConfig(options.rootDir, configPath);
220
- const entry = options.config?.entry ?? readTopLevelString(configContent, "entry") ?? "docs";
221
- const contentDir = options.config?.contentDir ?? readTopLevelString(configContent, "contentDir");
222
- const projectDir = toPosixPath(relative(repoRoot, options.rootDir));
223
- const projectPrefix = projectDir && projectDir !== "." ? `${projectDir}/` : "";
224
- const candidates = [
225
- prefixPath(projectPrefix, configPath),
226
- prefixPath(projectPrefix, `${entry}/**`),
227
- prefixPath(projectPrefix, `app/${entry}/**`),
228
- prefixPath(projectPrefix, `src/app/${entry}/**`),
229
- contentDir ? prefixPath(projectPrefix, `${trimSlashes(contentDir)}/**`) : void 0,
230
- prefixPath(projectPrefix, "content/docs/**"),
231
- prefixPath(projectPrefix, "src/content/docs/**"),
232
- prefixPath(projectPrefix, "src/lib/docs.config.*"),
233
- DEFAULT_DOCS_REVIEW_WORKFLOW_PATH,
234
- DEFAULT_DOCS_REVIEW_REUSABLE_WORKFLOW_PATH,
235
- ...buildAgentSkillPathFilters({
236
- rootDir: options.rootDir,
237
- repoRoot,
238
- skills: options.config?.agent?.skills
239
- })
240
- ];
241
- return Array.from(new Set(candidates.filter((candidate) => Boolean(candidate))));
242
- }
243
- function buildAgentSkillPathFilters(options) {
244
- return getDocsAgentSkillsConfiguredPaths(options.skills).map((configuredPath) => {
245
- const absolutePath = isAbsolute(configuredPath) ? configuredPath : join(options.rootDir, configuredPath);
246
- const repoRelative = toPosixPath(relative(options.repoRoot, absolutePath));
247
- if (!repoRelative || repoRelative.startsWith("../")) return void 0;
248
- return repoRelative.endsWith("/SKILL.md") || repoRelative === "SKILL.md" ? repoRelative : `${repoRelative.replace(/\/+$/u, "")}/**`;
249
- }).filter((candidate) => Boolean(candidate));
250
- }
251
- function normalizeRules(rules) {
252
- if (!rules) return {};
253
- const knownRules = new Set(Object.keys(DEFAULT_REVIEW_RULES));
254
- return Object.fromEntries(Object.entries(rules).filter((entry) => knownRules.has(entry[0]) && REVIEW_SEVERITIES.has(entry[1])));
255
- }
256
- function normalizeWeight(value, fallback) {
257
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
258
- }
259
- function normalizeCiName(value) {
260
- return value?.trim() || DEFAULT_DOCS_REVIEW_CI_NAME;
261
- }
262
- function clampScoreThreshold(value) {
263
- if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD;
264
- return Math.min(100, Math.max(0, Math.round(value)));
265
- }
266
- function readReviewCiObject(source, cursor) {
267
- const end = findMatchingObjectEnd(source, cursor);
268
- if (end === void 0) return void 0;
269
- const block = source.slice(cursor + 1, end);
270
- const mode = readTopLevelString(block, "mode");
271
- return {
272
- enabled: readTopLevelBoolean(block, "enabled"),
273
- name: readTopLevelString(block, "name"),
274
- mode: mode && REVIEW_CI_MODES.has(mode) ? mode : void 0,
275
- annotations: readTopLevelBoolean(block, "annotations"),
276
- comment: readTopLevelBoolean(block, "comment")
277
- };
278
- }
279
- function readReviewRules(block) {
280
- const rules = {};
281
- for (const key of Object.keys(DEFAULT_REVIEW_RULES)) {
282
- const value = readTopLevelString(block, key);
283
- if (value && REVIEW_SEVERITIES.has(value)) rules[key] = value;
284
- }
285
- return rules;
286
- }
287
- function readReviewWeights(block) {
288
- const weightsBlock = extractTopLevelObjectLiteral(block, "weights");
289
- if (!weightsBlock) return void 0;
290
- return {
291
- error: readTopLevelNumber(weightsBlock, "error"),
292
- warn: readTopLevelNumber(weightsBlock, "warn"),
293
- suggestion: readTopLevelNumber(weightsBlock, "suggestion")
294
- };
295
- }
296
- function detectPackageManager(rootDir) {
297
- if (existsSync(join(rootDir, "pnpm-lock.yaml"))) return "pnpm";
298
- if (existsSync(join(rootDir, "yarn.lock"))) return "yarn";
299
- if (existsSync(join(rootDir, "bun.lock")) || existsSync(join(rootDir, "bun.lockb"))) return "bun";
300
- return "npm";
301
- }
302
- function detectLocalDocsCliBuildCommand(repoRoot, packageManager) {
303
- if (!hasLocalDocsWorkspacePackage(repoRoot)) return void 0;
304
- if (packageManager === "pnpm") return "pnpm --filter @farming-labs/docs run build";
305
- if (packageManager === "yarn") return "yarn workspace @farming-labs/docs build";
306
- if (packageManager === "bun") return "bun run --filter @farming-labs/docs build";
307
- return "npm run build --workspace=@farming-labs/docs";
308
- }
309
- function detectPnpmVersionFallback(repoRoot, packageManager) {
310
- if (packageManager !== "pnpm") return void 0;
311
- try {
312
- if (JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf-8")).packageManager?.startsWith("pnpm@")) return void 0;
313
- } catch {}
314
- return DEFAULT_DOCS_REVIEW_PNPM_VERSION;
315
- }
316
- function detectLocalDocsCliReviewCommand(repoRoot, rootDir) {
317
- if (!hasLocalDocsWorkspacePackage(repoRoot)) return void 0;
318
- return `node ${shellQuote(toPosixPath(relative(rootDir, join(repoRoot, "packages", "docs", "dist", "cli", "index.mjs"))) || "./packages/docs/dist/cli/index.mjs")}`;
319
- }
320
- function hasLocalDocsWorkspacePackage(repoRoot) {
321
- const packageJsonPath = join(repoRoot, "packages", "docs", "package.json");
322
- if (!existsSync(packageJsonPath)) return false;
323
- try {
324
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
325
- return packageJson.name === "@farming-labs/docs" && Boolean(packageJson.scripts?.build);
326
- } catch {
327
- return false;
328
- }
329
- }
330
- function shellQuote(value) {
331
- if (/^[A-Za-z0-9_./:-]+$/.test(value)) return value;
332
- return `'${value.replaceAll("'", "'\\''")}'`;
333
- }
334
- function normalizeProjectDir(value) {
335
- if (!value || value === "") return ".";
336
- return toPosixPath(value).replace(/\/+$/, "") || ".";
337
- }
338
- function normalizePathFilters(filters) {
339
- const normalized = (filters && filters.length > 0 ? filters : ["docs.config.*", "app/docs/**"]).map((filter) => toPosixPath(filter).replace(/^\.\/+/, "")).filter(Boolean);
340
- return Array.from(new Set(normalized));
341
- }
342
- function findGitRoot(start) {
343
- let current = start;
344
- while (true) {
345
- if (existsSync(join(current, ".git"))) return current;
346
- const parent = dirname(current);
347
- if (parent === current) return void 0;
348
- current = parent;
349
- }
350
- }
351
- function findDocsConfigPath(rootDir) {
352
- for (const ext of FILE_EXTS) {
353
- const path = `docs.config.${ext}`;
354
- if (existsSync(join(rootDir, path))) return path;
355
- }
356
- return "docs.config.ts";
357
- }
358
- function readConfig(rootDir, configPath = findDocsConfigPath(rootDir)) {
359
- const fullPath = join(rootDir, configPath);
360
- if (!existsSync(fullPath)) return void 0;
361
- try {
362
- return readFileSync(fullPath, "utf-8");
363
- } catch {
364
- return;
365
- }
366
- }
367
- function prefixPath(prefix, value) {
368
- return `${prefix}${toPosixPath(value).replace(/^\.\/+/, "")}`;
369
- }
370
- function trimSlashes(value) {
371
- return toPosixPath(value).replace(/^\/+|\/+$/g, "");
372
- }
373
- function toPosixPath(value) {
374
- return value.replaceAll("\\", "/");
375
- }
376
- function extractRootObjectLiteral(content) {
377
- const candidateIndexes = [content.search(/\bdefineDocs\s*\(/), content.search(/\bexport\s+default\b/)].filter((value) => value !== -1);
378
- for (const startIndex of candidateIndexes) {
379
- const braceStart = content.indexOf("{", startIndex);
380
- if (braceStart === -1) continue;
381
- const braceEnd = findMatchingObjectEnd(content, braceStart);
382
- if (braceEnd !== void 0) return content.slice(braceStart + 1, braceEnd);
383
- }
384
- }
385
- function extractTopLevelObjectLiteral(content, key) {
386
- const cursor = findTopLevelPropertyValueIndex(content, key);
387
- if (cursor === void 0 || content[cursor] !== "{") return void 0;
388
- const end = findMatchingObjectEnd(content, cursor);
389
- return end === void 0 ? void 0 : content.slice(cursor + 1, end);
390
- }
391
- function readTopLevelBoolean(content, key) {
392
- const cursor = findTopLevelPropertyValueIndex(content, key);
393
- if (cursor === void 0) return void 0;
394
- if (content.startsWith("true", cursor)) return true;
395
- if (content.startsWith("false", cursor)) return false;
396
- }
397
- function readTopLevelNumber(content, key) {
398
- const cursor = findTopLevelPropertyValueIndex(content, key);
399
- if (cursor === void 0) return void 0;
400
- const match = content.slice(cursor).match(/^-?\d+(?:\.\d+)?/);
401
- if (!match) return void 0;
402
- const value = Number(match[0]);
403
- return Number.isFinite(value) ? value : void 0;
404
- }
405
- function readTopLevelString(content, key) {
406
- if (!content) return void 0;
407
- const cursor = findTopLevelPropertyValueIndex(content, key);
408
- if (cursor === void 0) return void 0;
409
- const quote = content[cursor];
410
- if (quote !== "\"" && quote !== "'") return void 0;
411
- let value = "";
412
- for (let index = cursor + 1; index < content.length; index += 1) {
413
- const char = content[index];
414
- if (char === "\\") {
415
- const escaped = content[index + 1];
416
- if (escaped) {
417
- value += escaped;
418
- index += 1;
419
- }
420
- continue;
421
- }
422
- if (char === quote) return value;
423
- value += char;
424
- }
425
- }
426
- function findTopLevelPropertyValueIndex(block, key) {
427
- let objectDepth = 0;
428
- let arrayDepth = 0;
429
- let parenDepth = 0;
430
- let inString = null;
431
- let inLineComment = false;
432
- let inBlockComment = false;
433
- let escaped = false;
434
- for (let index = 0; index < block.length; index += 1) {
435
- const char = block[index];
436
- const next = block[index + 1];
437
- if (inLineComment) {
438
- if (char === "\n") inLineComment = false;
439
- continue;
440
- }
441
- if (inBlockComment) {
442
- if (char === "*" && next === "/") {
443
- inBlockComment = false;
444
- index += 1;
445
- }
446
- continue;
447
- }
448
- if (inString) {
449
- if (escaped) {
450
- escaped = false;
451
- continue;
452
- }
453
- if (char === "\\") {
454
- escaped = true;
455
- continue;
456
- }
457
- if (char === inString) inString = null;
458
- continue;
459
- }
460
- if (char === "/" && next === "/") {
461
- inLineComment = true;
462
- index += 1;
463
- continue;
464
- }
465
- if (char === "/" && next === "*") {
466
- inBlockComment = true;
467
- index += 1;
468
- continue;
469
- }
470
- if (char === "\"" || char === "'" || char === "`") {
471
- inString = char;
472
- continue;
473
- }
474
- if (char === "{") {
475
- objectDepth += 1;
476
- continue;
477
- }
478
- if (char === "}") {
479
- objectDepth = Math.max(0, objectDepth - 1);
480
- continue;
481
- }
482
- if (char === "[") {
483
- arrayDepth += 1;
484
- continue;
485
- }
486
- if (char === "]") {
487
- arrayDepth = Math.max(0, arrayDepth - 1);
488
- continue;
489
- }
490
- if (char === "(") {
491
- parenDepth += 1;
492
- continue;
493
- }
494
- if (char === ")") {
495
- parenDepth = Math.max(0, parenDepth - 1);
496
- continue;
497
- }
498
- if (objectDepth !== 0 || arrayDepth !== 0 || parenDepth !== 0) continue;
499
- if (!block.startsWith(key, index)) continue;
500
- const before = block[index - 1] ?? "";
501
- const after = block[index + key.length] ?? "";
502
- if (/[A-Za-z0-9_$]/.test(before) || /[A-Za-z0-9_$]/.test(after)) continue;
503
- let cursor = index + key.length;
504
- while (/\s/.test(block[cursor] ?? "")) cursor += 1;
505
- if (block[cursor] !== ":") continue;
506
- cursor += 1;
507
- while (/\s/.test(block[cursor] ?? "")) cursor += 1;
508
- return cursor;
509
- }
510
- }
511
- function findMatchingObjectEnd(block, start) {
512
- let depth = 0;
513
- let inString = null;
514
- let inLineComment = false;
515
- let inBlockComment = false;
516
- let escaped = false;
517
- for (let index = start; index < block.length; index += 1) {
518
- const char = block[index];
519
- const next = block[index + 1];
520
- if (inLineComment) {
521
- if (char === "\n") inLineComment = false;
522
- continue;
523
- }
524
- if (inBlockComment) {
525
- if (char === "*" && next === "/") {
526
- inBlockComment = false;
527
- index += 1;
528
- }
529
- continue;
530
- }
531
- if (inString) {
532
- if (escaped) {
533
- escaped = false;
534
- continue;
535
- }
536
- if (char === "\\") {
537
- escaped = true;
538
- continue;
539
- }
540
- if (char === inString) inString = null;
541
- continue;
542
- }
543
- if (char === "/" && next === "/") {
544
- inLineComment = true;
545
- index += 1;
546
- continue;
547
- }
548
- if (char === "/" && next === "*") {
549
- inBlockComment = true;
550
- index += 1;
551
- continue;
552
- }
553
- if (char === "\"" || char === "'" || char === "`") {
554
- inString = char;
555
- continue;
556
- }
557
- if (char === "{") {
558
- depth += 1;
559
- continue;
560
- }
561
- if (char !== "}") continue;
562
- depth -= 1;
563
- if (depth === 0) return index;
564
- }
565
- }
566
-
567
- //#endregion
568
10
  //#region src/agent-evals.ts
569
11
  const DEFAULT_TOP_K = 5;
570
12
  const DEFAULT_TOKEN_BUDGET = 4e3;
@@ -2655,4 +2097,4 @@ async function runDocsGoldenTasks(pages, tasks, options = {}) {
2655
2097
  }
2656
2098
 
2657
2099
  //#endregion
2658
- export { buildDocsReviewWorkflowPathFilters as a, resolveDocsReviewConfig as c, buildDocsReviewWorkflow as i, DEFAULT_DOCS_REVIEW_SCORE_THRESHOLD as n, ensureDocsReviewWorkflow as o, DEFAULT_DOCS_REVIEW_WORKFLOW_PATH as r, readDocsReviewConfigFromSource as s, runDocsGoldenTasks as t };
2100
+ export { runDocsGoldenTasks };
@@ -0,0 +1,38 @@
1
+ import { DOCS_AGENT_FEEDBACK_EVALUATION_BASELINE_FORMAT } from "./agent-feedback-evaluations.mjs";
2
+ import { readFileSync } from "node:fs";
3
+
4
+ //#region src/agent-feedback-evaluations-node.ts
5
+ function isRecord(value) {
6
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7
+ }
8
+ function readJsonFile(filePath) {
9
+ return JSON.parse(readFileSync(filePath, "utf8"));
10
+ }
11
+ function readDocsAgentFeedbackImprovementReport(filePath) {
12
+ const value = readJsonFile(filePath);
13
+ 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.");
14
+ return value;
15
+ }
16
+ function readDocsAgentEvaluationTasksFile(filePath) {
17
+ const value = readJsonFile(filePath);
18
+ if (Array.isArray(value)) return value;
19
+ if (!isRecord(value)) throw new Error("Existing evaluation tasks must be a JSON object or array.");
20
+ if (Array.isArray(value.candidates)) return value.candidates.flatMap((candidate) => isRecord(candidate) && isRecord(candidate.task) ? [candidate.task] : []);
21
+ if (Array.isArray(value.tasks)) return value.tasks;
22
+ if (isRecord(value.agent) && isRecord(value.agent.evaluations) && Array.isArray(value.agent.evaluations.tasks)) return value.agent.evaluations.tasks;
23
+ throw new Error("Could not find evaluation tasks in the existing JSON file.");
24
+ }
25
+ function readDocsGoldenTasksReportFile(filePath) {
26
+ const value = readJsonFile(filePath);
27
+ const report = isRecord(value) && isRecord(value.evaluations) ? value.evaluations : value;
28
+ 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.");
29
+ return report;
30
+ }
31
+ function readDocsAgentFeedbackEvaluationBaseline(filePath) {
32
+ const value = readJsonFile(filePath);
33
+ 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.");
34
+ return value;
35
+ }
36
+
37
+ //#endregion
38
+ export { readDocsAgentEvaluationTasksFile, readDocsAgentFeedbackEvaluationBaseline, readDocsAgentFeedbackImprovementReport, readDocsGoldenTasksReportFile };