@sanity/ailf 0.4.1 → 1.0.0

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 (290) hide show
  1. package/config/features.ts +23 -0
  2. package/config/models.ts +83 -0
  3. package/config/prompts.ts +16 -0
  4. package/config/rubrics.ts +225 -0
  5. package/config/schedules.ts +47 -0
  6. package/config/sinks.ts +37 -0
  7. package/config/sources.ts +21 -0
  8. package/config/thresholds.ts +61 -0
  9. package/dist/_vendor/ailf-core/config-helpers.d.ts +174 -0
  10. package/dist/_vendor/ailf-core/config-helpers.js +150 -0
  11. package/dist/_vendor/ailf-core/env-helper.d.ts +35 -0
  12. package/dist/_vendor/ailf-core/env-helper.js +45 -0
  13. package/dist/_vendor/ailf-core/examples/index.d.ts +10 -10
  14. package/dist/_vendor/ailf-core/examples/index.js +10 -10
  15. package/dist/_vendor/ailf-core/index.d.ts +3 -0
  16. package/dist/_vendor/ailf-core/index.js +5 -0
  17. package/dist/_vendor/ailf-core/ports/context.d.ts +15 -2
  18. package/dist/_vendor/ailf-core/ports/doc-fetcher.d.ts +2 -2
  19. package/dist/_vendor/ailf-core/ports/index.d.ts +2 -1
  20. package/dist/_vendor/ailf-core/ports/mode-handler.d.ts +129 -0
  21. package/dist/_vendor/ailf-core/ports/mode-handler.js +19 -0
  22. package/dist/_vendor/ailf-core/ports/task-source.d.ts +16 -122
  23. package/dist/_vendor/ailf-core/ports/task-source.js +7 -7
  24. package/dist/_vendor/ailf-core/schemas/eval-config.d.ts +7 -2
  25. package/dist/_vendor/ailf-core/schemas/eval-config.js +7 -2
  26. package/dist/_vendor/ailf-core/schemas/pipeline-request.d.ts +8 -3
  27. package/dist/_vendor/ailf-core/schemas/pipeline-request.js +6 -1
  28. package/dist/_vendor/ailf-core/schemas/pipeline.d.ts +32 -31
  29. package/dist/_vendor/ailf-core/schemas/pipeline.js +52 -12
  30. package/dist/_vendor/ailf-core/schemas/schedules.d.ts +14 -4
  31. package/dist/_vendor/ailf-core/schemas/schedules.js +6 -2
  32. package/dist/_vendor/ailf-core/schemas/sinks.d.ts +1 -1
  33. package/dist/_vendor/ailf-core/services/comparison-formatters.js +57 -19
  34. package/dist/_vendor/ailf-core/services/index.d.ts +2 -1
  35. package/dist/_vendor/ailf-core/services/index.js +2 -1
  36. package/dist/_vendor/ailf-core/services/scoring-engine.d.ts +153 -0
  37. package/dist/_vendor/ailf-core/services/scoring-engine.js +237 -0
  38. package/dist/_vendor/ailf-core/services/scoring.d.ts +15 -2
  39. package/dist/_vendor/ailf-core/services/scoring.js +25 -15
  40. package/dist/_vendor/ailf-core/types/branded-ids.d.ts +137 -0
  41. package/dist/_vendor/ailf-core/types/branded-ids.js +136 -0
  42. package/dist/_vendor/ailf-core/types/eval-mode-config.d.ts +150 -0
  43. package/dist/_vendor/ailf-core/types/eval-mode-config.js +24 -0
  44. package/dist/_vendor/ailf-core/types/generalized-task.d.ts +319 -0
  45. package/dist/_vendor/ailf-core/types/generalized-task.js +13 -0
  46. package/dist/_vendor/ailf-core/types/index.d.ts +45 -81
  47. package/dist/_vendor/ailf-core/types/index.js +8 -1
  48. package/dist/_vendor/ailf-core/types/plugin-registry.d.ts +202 -0
  49. package/dist/_vendor/ailf-core/types/plugin-registry.js +132 -0
  50. package/dist/_vendor/ailf-core/types/storage-schema.d.ts +199 -0
  51. package/dist/_vendor/ailf-core/types/storage-schema.js +39 -0
  52. package/dist/_vendor/ailf-core/types/task-graph.d.ts +86 -0
  53. package/dist/_vendor/ailf-core/types/task-graph.js +20 -0
  54. package/dist/_vendor/ailf-core/types/trace.d.ts +118 -0
  55. package/dist/_vendor/ailf-core/types/trace.js +18 -0
  56. package/dist/_vendor/ailf-core/types/variable-envelope.d.ts +80 -0
  57. package/dist/_vendor/ailf-core/types/variable-envelope.js +16 -0
  58. package/dist/_vendor/ailf-shared/dimension-names.d.ts +5 -18
  59. package/dist/_vendor/ailf-shared/dimension-names.js +6 -24
  60. package/dist/_vendor/ailf-shared/eval-modes.d.ts +38 -6
  61. package/dist/_vendor/ailf-shared/eval-modes.js +26 -2
  62. package/dist/_vendor/ailf-shared/index.d.ts +0 -1
  63. package/dist/_vendor/ailf-shared/index.js +0 -1
  64. package/dist/adapters/api-client/build-request.js +14 -13
  65. package/dist/adapters/config-sources/file-config-adapter.d.ts +20 -11
  66. package/dist/adapters/config-sources/file-config-adapter.js +38 -12
  67. package/dist/adapters/config-sources/index.d.ts +2 -0
  68. package/dist/adapters/config-sources/index.js +1 -0
  69. package/dist/adapters/config-sources/ts-config-loader.d.ts +59 -0
  70. package/dist/adapters/config-sources/ts-config-loader.js +133 -0
  71. package/dist/adapters/doc-fetchers/sanity-doc-fetcher.d.ts +3 -2
  72. package/dist/adapters/doc-fetchers/sanity-doc-fetcher.js +7 -2
  73. package/dist/adapters/task-sources/composite-task-source.d.ts +3 -3
  74. package/dist/adapters/task-sources/composite-task-source.js +1 -1
  75. package/dist/adapters/task-sources/content-lake-task-source.d.ts +7 -6
  76. package/dist/adapters/task-sources/content-lake-task-source.js +22 -23
  77. package/dist/adapters/task-sources/index.d.ts +1 -0
  78. package/dist/adapters/task-sources/index.js +1 -0
  79. package/dist/adapters/task-sources/repo-task-source.d.ts +4 -4
  80. package/dist/adapters/task-sources/repo-task-source.js +69 -16
  81. package/dist/adapters/task-sources/task-file-loader.d.ts +64 -0
  82. package/dist/adapters/task-sources/task-file-loader.js +83 -0
  83. package/dist/adapters/task-sources/yaml-task-source.d.ts +6 -6
  84. package/dist/adapters/task-sources/yaml-task-source.js +19 -16
  85. package/dist/cli.js +0 -2
  86. package/dist/commands/baseline.js +4 -1
  87. package/dist/commands/calculate-scores.js +1 -1
  88. package/dist/commands/coverage-audit.js +7 -1
  89. package/dist/commands/explain-handler.js +25 -23
  90. package/dist/commands/fetch-docs.js +3 -2
  91. package/dist/commands/generate-configs.js +1 -1
  92. package/dist/commands/interactive.js +11 -7
  93. package/dist/commands/pipeline-action.d.ts +2 -0
  94. package/dist/commands/pipeline-action.js +16 -6
  95. package/dist/commands/pipeline.d.ts +1 -0
  96. package/dist/commands/pipeline.js +4 -2
  97. package/dist/commands/pr-comment.js +1 -1
  98. package/dist/commands/publish.js +2 -2
  99. package/dist/commands/readiness-report.js +13 -6
  100. package/dist/composition-root.d.ts +1 -1
  101. package/dist/composition-root.js +67 -4
  102. package/dist/orchestration/build-app-context.js +1 -0
  103. package/dist/orchestration/build-step-sequence.js +24 -6
  104. package/dist/orchestration/steps/calculate-scores-step.js +24 -11
  105. package/dist/orchestration/steps/fetch-docs-step.js +6 -4
  106. package/dist/orchestration/steps/gap-analysis-step.js +8 -7
  107. package/dist/orchestration/steps/generate-configs-step.d.ts +16 -3
  108. package/dist/orchestration/steps/generate-configs-step.js +245 -51
  109. package/dist/orchestration/steps/grader-consistency-step.js +7 -4
  110. package/dist/orchestration/steps/mirror-repo-tasks-step.js +1 -1
  111. package/dist/orchestration/steps/readiness-step.js +5 -6
  112. package/dist/orchestration/steps/run-eval-step.d.ts +1 -2
  113. package/dist/orchestration/steps/run-eval-step.js +8 -7
  114. package/dist/pipeline/cache.d.ts +1 -1
  115. package/dist/pipeline/cache.js +36 -8
  116. package/dist/pipeline/calculate-scores.d.ts +5 -7
  117. package/dist/pipeline/calculate-scores.js +74 -153
  118. package/dist/pipeline/checks.js +2 -2
  119. package/dist/pipeline/compare.js +8 -8
  120. package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.d.ts +10 -0
  121. package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.js +288 -0
  122. package/dist/pipeline/compiler/__tests__/assertion-mapper.test.d.ts +9 -0
  123. package/dist/pipeline/compiler/__tests__/assertion-mapper.test.js +145 -0
  124. package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.d.ts +10 -0
  125. package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.js +314 -0
  126. package/dist/pipeline/compiler/__tests__/literacy-handler.test.d.ts +10 -0
  127. package/dist/pipeline/compiler/__tests__/literacy-handler.test.js +486 -0
  128. package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.d.ts +10 -0
  129. package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.js +355 -0
  130. package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.d.ts +9 -0
  131. package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.js +333 -0
  132. package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.d.ts +12 -0
  133. package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.js +210 -0
  134. package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.d.ts +7 -0
  135. package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.js +471 -0
  136. package/dist/pipeline/compiler/__tests__/scoring-bridge.test.d.ts +10 -0
  137. package/dist/pipeline/compiler/__tests__/scoring-bridge.test.js +184 -0
  138. package/dist/pipeline/compiler/__tests__/task-graph-builder.test.d.ts +8 -0
  139. package/dist/pipeline/compiler/__tests__/task-graph-builder.test.js +301 -0
  140. package/dist/pipeline/compiler/__tests__/telemetry.test.d.ts +9 -0
  141. package/dist/pipeline/compiler/__tests__/telemetry.test.js +503 -0
  142. package/dist/pipeline/compiler/assertion-mapper.d.ts +58 -0
  143. package/dist/pipeline/compiler/assertion-mapper.js +175 -0
  144. package/dist/pipeline/compiler/compiler-to-yaml.d.ts +51 -0
  145. package/dist/pipeline/compiler/compiler-to-yaml.js +222 -0
  146. package/dist/pipeline/compiler/config-loader.d.ts +56 -0
  147. package/dist/pipeline/compiler/config-loader.js +111 -0
  148. package/dist/pipeline/compiler/fixture-resolver.d.ts +41 -0
  149. package/dist/pipeline/compiler/fixture-resolver.js +113 -0
  150. package/dist/pipeline/compiler/hash.d.ts +11 -0
  151. package/dist/pipeline/compiler/hash.js +18 -0
  152. package/dist/pipeline/compiler/ignore-fields.d.ts +53 -0
  153. package/dist/pipeline/compiler/ignore-fields.js +113 -0
  154. package/dist/pipeline/compiler/index.d.ts +29 -0
  155. package/dist/pipeline/compiler/index.js +45 -0
  156. package/dist/pipeline/compiler/literacy-bridge.d.ts +102 -0
  157. package/dist/pipeline/compiler/literacy-bridge.js +172 -0
  158. package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.d.ts +14 -0
  159. package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.js +152 -0
  160. package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.d.ts +32 -0
  161. package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.js +176 -0
  162. package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.d.ts +49 -0
  163. package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.js +259 -0
  164. package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.d.ts +70 -0
  165. package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.js +485 -0
  166. package/dist/pipeline/compiler/mode-handlers/index.d.ts +16 -0
  167. package/dist/pipeline/compiler/mode-handlers/index.js +21 -0
  168. package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.d.ts +76 -0
  169. package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.js +245 -0
  170. package/dist/pipeline/compiler/mode-handlers/literacy-handler.d.ts +89 -0
  171. package/dist/pipeline/compiler/mode-handlers/literacy-handler.js +379 -0
  172. package/dist/pipeline/compiler/mode-handlers/mcp-assertions.d.ts +50 -0
  173. package/dist/pipeline/compiler/mode-handlers/mcp-assertions.js +277 -0
  174. package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.d.ts +67 -0
  175. package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.js +309 -0
  176. package/dist/pipeline/compiler/presets/index.d.ts +9 -0
  177. package/dist/pipeline/compiler/presets/index.js +8 -0
  178. package/dist/pipeline/compiler/presets/sanity-literacy.d.ts +45 -0
  179. package/dist/pipeline/compiler/presets/sanity-literacy.js +354 -0
  180. package/dist/pipeline/compiler/promptfoo-compiler.d.ts +96 -0
  181. package/dist/pipeline/compiler/promptfoo-compiler.js +230 -0
  182. package/dist/pipeline/compiler/provider-assembler.d.ts +39 -0
  183. package/dist/pipeline/compiler/provider-assembler.js +137 -0
  184. package/dist/pipeline/compiler/sandbox/docker-sandbox.d.ts +21 -0
  185. package/dist/pipeline/compiler/sandbox/docker-sandbox.js +136 -0
  186. package/dist/pipeline/compiler/sandbox/fixture-provisioner.d.ts +69 -0
  187. package/dist/pipeline/compiler/sandbox/fixture-provisioner.js +189 -0
  188. package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.d.ts +20 -0
  189. package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.js +114 -0
  190. package/dist/pipeline/compiler/sandbox/index.d.ts +10 -0
  191. package/dist/pipeline/compiler/sandbox/index.js +11 -0
  192. package/dist/pipeline/compiler/sandbox/sandbox-selector.d.ts +35 -0
  193. package/dist/pipeline/compiler/sandbox/sandbox-selector.js +86 -0
  194. package/dist/pipeline/compiler/sandbox/sandbox-strategy.d.ts +81 -0
  195. package/dist/pipeline/compiler/sandbox/sandbox-strategy.js +15 -0
  196. package/dist/pipeline/compiler/sandbox/tempdir-sandbox.d.ts +20 -0
  197. package/dist/pipeline/compiler/sandbox/tempdir-sandbox.js +74 -0
  198. package/dist/pipeline/compiler/scoring-bridge.d.ts +49 -0
  199. package/dist/pipeline/compiler/scoring-bridge.js +114 -0
  200. package/dist/pipeline/compiler/task-graph-builder.d.ts +54 -0
  201. package/dist/pipeline/compiler/task-graph-builder.js +291 -0
  202. package/dist/pipeline/compiler/telemetry/cost-tracker.d.ts +90 -0
  203. package/dist/pipeline/compiler/telemetry/cost-tracker.js +146 -0
  204. package/dist/pipeline/compiler/telemetry/index.d.ts +14 -0
  205. package/dist/pipeline/compiler/telemetry/index.js +19 -0
  206. package/dist/pipeline/compiler/telemetry/redactor.d.ts +58 -0
  207. package/dist/pipeline/compiler/telemetry/redactor.js +222 -0
  208. package/dist/pipeline/compiler/telemetry/tool-classifier.d.ts +32 -0
  209. package/dist/pipeline/compiler/telemetry/tool-classifier.js +120 -0
  210. package/dist/pipeline/compiler/telemetry/trace-collector.d.ts +75 -0
  211. package/dist/pipeline/compiler/telemetry/trace-collector.js +297 -0
  212. package/dist/pipeline/compiler/telemetry/trace-store.d.ts +78 -0
  213. package/dist/pipeline/compiler/telemetry/trace-store.js +85 -0
  214. package/dist/pipeline/compiler/variable-resolver.d.ts +46 -0
  215. package/dist/pipeline/compiler/variable-resolver.js +115 -0
  216. package/dist/pipeline/coverage-audit.d.ts +15 -5
  217. package/dist/pipeline/coverage-audit.js +41 -22
  218. package/dist/pipeline/eval-constants.d.ts +16 -6
  219. package/dist/pipeline/eval-constants.js +25 -4
  220. package/dist/pipeline/eval-fingerprint.d.ts +2 -2
  221. package/dist/pipeline/eval-fingerprint.js +8 -9
  222. package/dist/pipeline/expand-tasks.d.ts +23 -14
  223. package/dist/pipeline/expand-tasks.js +37 -31
  224. package/dist/pipeline/gap-analysis.d.ts +1 -1
  225. package/dist/pipeline/gap-analysis.js +2 -2
  226. package/dist/pipeline/generate-configs.d.ts +22 -4
  227. package/dist/pipeline/generate-configs.js +53 -24
  228. package/dist/pipeline/grader-api.d.ts +3 -3
  229. package/dist/pipeline/grader-api.js +5 -12
  230. package/dist/pipeline/grader-compare-runner.js +20 -27
  231. package/dist/pipeline/grader-comparison.d.ts +4 -8
  232. package/dist/pipeline/grader-comparison.js +11 -17
  233. package/dist/pipeline/grader-consistency-runner.d.ts +2 -3
  234. package/dist/pipeline/grader-consistency-runner.js +18 -21
  235. package/dist/pipeline/grader-consistency.d.ts +6 -10
  236. package/dist/pipeline/grader-consistency.js +13 -32
  237. package/dist/pipeline/grader-sensitivity-runner.js +7 -5
  238. package/dist/pipeline/grader-sensitivity.d.ts +2 -6
  239. package/dist/pipeline/grader-sensitivity.js +10 -10
  240. package/dist/pipeline/grader-validate-runner.js +7 -5
  241. package/dist/pipeline/grader-validation.d.ts +2 -6
  242. package/dist/pipeline/grader-validation.js +14 -22
  243. package/dist/pipeline/map-request-to-config.js +6 -1
  244. package/dist/pipeline/mirror-repo-tasks.d.ts +6 -6
  245. package/dist/pipeline/mirror-repo-tasks.js +16 -15
  246. package/dist/pipeline/normalize-mode.d.ts +49 -0
  247. package/dist/pipeline/normalize-mode.js +64 -0
  248. package/dist/pipeline/plan.d.ts +5 -2
  249. package/dist/pipeline/plan.js +134 -78
  250. package/dist/pipeline/pr-comment.js +2 -0
  251. package/dist/pipeline/profile-resolution.d.ts +47 -0
  252. package/dist/pipeline/profile-resolution.js +91 -0
  253. package/dist/pipeline/provenance.d.ts +2 -2
  254. package/dist/pipeline/provenance.js +12 -17
  255. package/dist/pipeline/release-report.js +4 -4
  256. package/dist/pipeline/repo-threshold-evaluator.d.ts +1 -1
  257. package/dist/pipeline/repo-threshold-evaluator.js +1 -1
  258. package/dist/pipeline/rubric-loader.d.ts +20 -0
  259. package/dist/pipeline/rubric-loader.js +37 -0
  260. package/dist/pipeline/validate.d.ts +4 -4
  261. package/dist/pipeline/validate.js +64 -53
  262. package/dist/schedules/loader.js +18 -8
  263. package/dist/scripts/migrate-task-mode.d.ts +24 -0
  264. package/dist/scripts/migrate-task-mode.js +85 -0
  265. package/dist/scripts/migrate-tasks-to-content-lake.js +11 -10
  266. package/dist/scripts/validate-task-sources.d.ts +1 -1
  267. package/dist/scripts/validate-task-sources.js +15 -15
  268. package/dist/sinks/loader.js +5 -7
  269. package/dist/sources.d.ts +7 -7
  270. package/dist/sources.js +22 -24
  271. package/dist/webhook/dispatch.js +2 -1
  272. package/package.json +6 -3
  273. package/tasks/knowledge-probe/define-type-api.task.ts +55 -0
  274. package/tasks/knowledge-probe/groq-projections.task.ts +59 -0
  275. package/tasks/literacy/frameworks.task.ts +128 -0
  276. package/tasks/literacy/functions.task.ts +69 -0
  277. package/tasks/literacy/groq.task.ts +258 -0
  278. package/tasks/literacy/nextjs-live.task.ts +75 -0
  279. package/tasks/literacy/studio-setup.task.ts +131 -0
  280. package/tasks/literacy/visual-editing.task.ts +146 -0
  281. package/config/features.yaml +0 -116
  282. package/config/models.yaml +0 -116
  283. package/config/prompts.yaml +0 -75
  284. package/config/rubrics.yaml +0 -62
  285. package/config/schedules.yaml +0 -43
  286. package/config/sinks.yaml +0 -54
  287. package/config/sources.yaml +0 -51
  288. package/config/thresholds.yaml +0 -49
  289. package/dist/agent-observer/test-imports.d.ts +0 -7
  290. package/dist/agent-observer/test-imports.js +0 -185
@@ -0,0 +1,45 @@
1
+ /**
2
+ * sanity-literacy preset — the built-in documentation literacy evaluation.
3
+ *
4
+ * Packages ALL Sanity-specific configuration into a single preset:
5
+ * - Literacy mode handler registration
6
+ * - Prompt templates (with-docs, without-docs, agentic)
7
+ * - Rubric templates (task-completion, code-correctness, doc-coverage)
8
+ * - Scoring profiles (default, output-only)
9
+ * - Sanity doc source definitions (production, branch, local)
10
+ * - Product feature registry for coverage auditing
11
+ * - DocFetcher factory (SanityDocFetcher)
12
+ * - Standard assertions and fixture resolvers
13
+ *
14
+ * Use `createSanityLiteracyPreset()` to get a fully configured preset
15
+ * with a docFetcher factory bound to a specific rootDir.
16
+ *
17
+ * @see docs/exec-plans/architecture-overhaul/phase-8-scoring-storage-presets.md
18
+ */
19
+ import { type PresetDefinition } from "../../../_vendor/ailf-core/index.d.ts";
20
+ export interface SanityLiteracyPresetOptions {
21
+ /** Root directory for SanityDocFetcher file path resolution (defaults to cwd) */
22
+ rootDir?: string;
23
+ }
24
+ /**
25
+ * Create the sanity-literacy preset with all Sanity-specific configuration.
26
+ *
27
+ * The `rootDir` option controls where the SanityDocFetcher resolves file
28
+ * paths. When omitted it defaults to `process.cwd()`, which matches the
29
+ * composition root's existing behavior.
30
+ */
31
+ export declare function createSanityLiteracyPreset(options?: SanityLiteracyPresetOptions): PresetDefinition;
32
+ /**
33
+ * Pre-built preset instance using default options (cwd for rootDir).
34
+ *
35
+ * Prefer `createSanityLiteracyPreset()` when you need to control rootDir
36
+ * or other options. This constant exists for backward compatibility with
37
+ * code that imports `sanityLiteracyPreset` directly.
38
+ */
39
+ export declare const sanityLiteracyPreset: PresetDefinition;
40
+ /**
41
+ * Register the sanity-literacy preset in a plugin registry.
42
+ */
43
+ export declare function registerSanityLiteracyPreset(registry: {
44
+ registerPreset(preset: PresetDefinition): void;
45
+ }): void;
@@ -0,0 +1,354 @@
1
+ /**
2
+ * sanity-literacy preset — the built-in documentation literacy evaluation.
3
+ *
4
+ * Packages ALL Sanity-specific configuration into a single preset:
5
+ * - Literacy mode handler registration
6
+ * - Prompt templates (with-docs, without-docs, agentic)
7
+ * - Rubric templates (task-completion, code-correctness, doc-coverage)
8
+ * - Scoring profiles (default, output-only)
9
+ * - Sanity doc source definitions (production, branch, local)
10
+ * - Product feature registry for coverage auditing
11
+ * - DocFetcher factory (SanityDocFetcher)
12
+ * - Standard assertions and fixture resolvers
13
+ *
14
+ * Use `createSanityLiteracyPreset()` to get a fully configured preset
15
+ * with a docFetcher factory bound to a specific rootDir.
16
+ *
17
+ * @see docs/exec-plans/architecture-overhaul/phase-8-scoring-storage-presets.md
18
+ */
19
+ import { env } from "../../../_vendor/ailf-core/index.js";
20
+ import { SanityDocFetcher } from "../../../adapters/doc-fetchers/index.js";
21
+ import { LITERACY_PROMPT_TEMPLATES } from "../mode-handlers/literacy-handler.js";
22
+ // ---------------------------------------------------------------------------
23
+ // Factory
24
+ // ---------------------------------------------------------------------------
25
+ /**
26
+ * Create the sanity-literacy preset with all Sanity-specific configuration.
27
+ *
28
+ * The `rootDir` option controls where the SanityDocFetcher resolves file
29
+ * paths. When omitted it defaults to `process.cwd()`, which matches the
30
+ * composition root's existing behavior.
31
+ */
32
+ export function createSanityLiteracyPreset(options) {
33
+ const rootDir = options?.rootDir ?? process.cwd();
34
+ return {
35
+ name: "sanity-literacy",
36
+ manifest: {
37
+ name: "sanity-literacy",
38
+ version: "1.0.0",
39
+ description: "Documentation literacy evaluation for Sanity.io — measures how " +
40
+ "effectively documentation enables AI coding tools to implement " +
41
+ "features correctly.",
42
+ pluginApiVersion: 1,
43
+ },
44
+ // ── Mode handler ─────────────────────────────────────────
45
+ modes: [
46
+ {
47
+ id: "literacy",
48
+ label: "Documentation Literacy",
49
+ validProviderPatterns: ["^openai:", "^anthropic:", "^file://"],
50
+ rubricTemplateIds: [
51
+ "task-completion",
52
+ "code-correctness",
53
+ "doc-coverage",
54
+ ],
55
+ handlerModule: "./mode-handlers/literacy-handler.js",
56
+ },
57
+ ],
58
+ // ── Assertions ───────────────────────────────────────────
59
+ assertions: [
60
+ {
61
+ type: "contains",
62
+ label: "Contains text",
63
+ compatibleModes: ["literacy", "knowledge-probe", "mcp-server"],
64
+ handlerModule: "promptfoo:builtin",
65
+ },
66
+ {
67
+ type: "contains-all",
68
+ label: "Contains all texts",
69
+ compatibleModes: ["literacy", "knowledge-probe", "mcp-server"],
70
+ handlerModule: "promptfoo:builtin",
71
+ },
72
+ {
73
+ type: "contains-any",
74
+ label: "Contains any text",
75
+ compatibleModes: ["literacy", "knowledge-probe", "mcp-server"],
76
+ handlerModule: "promptfoo:builtin",
77
+ },
78
+ {
79
+ type: "equals",
80
+ label: "Exact match",
81
+ compatibleModes: ["literacy"],
82
+ handlerModule: "promptfoo:builtin",
83
+ },
84
+ {
85
+ type: "regex",
86
+ label: "Regex match",
87
+ compatibleModes: ["literacy", "knowledge-probe"],
88
+ handlerModule: "promptfoo:builtin",
89
+ },
90
+ {
91
+ type: "is-json",
92
+ label: "Valid JSON",
93
+ compatibleModes: ["literacy", "mcp-server"],
94
+ handlerModule: "promptfoo:builtin",
95
+ },
96
+ {
97
+ type: "javascript",
98
+ label: "JavaScript assertion",
99
+ compatibleModes: [
100
+ "literacy",
101
+ "mcp-server",
102
+ "agent-harness",
103
+ "knowledge-probe",
104
+ "custom",
105
+ ],
106
+ handlerModule: "promptfoo:builtin",
107
+ },
108
+ {
109
+ type: "llm-rubric",
110
+ label: "LLM-graded rubric",
111
+ compatibleModes: [
112
+ "literacy",
113
+ "mcp-server",
114
+ "agent-harness",
115
+ "knowledge-probe",
116
+ "custom",
117
+ ],
118
+ handlerModule: "promptfoo:builtin",
119
+ },
120
+ {
121
+ type: "similar",
122
+ label: "Semantic similarity",
123
+ compatibleModes: ["literacy", "knowledge-probe"],
124
+ handlerModule: "promptfoo:builtin",
125
+ },
126
+ ],
127
+ // ── Rubric templates ─────────────────────────────────────
128
+ rubricTemplates: [
129
+ {
130
+ id: "task-completion",
131
+ dimension: "task-completion",
132
+ header: "Score task completion from 0 to 100:",
133
+ scale: [
134
+ "0: Couldn't attempt — missing critical information",
135
+ "20: Attempted but fundamentally wrong approach",
136
+ "50: Partial implementation — major functional gaps",
137
+ "80: Mostly complete — minor issues or missing edge cases",
138
+ "100: Fully functional code — works as expected",
139
+ ],
140
+ criteriaLabel: "Must demonstrate:",
141
+ },
142
+ {
143
+ id: "code-correctness",
144
+ dimension: "code-correctness",
145
+ header: "Score code correctness from 0 to 100:",
146
+ scale: [
147
+ "0: Broken code, syntax errors, or deprecated APIs",
148
+ "30: Works but uses anti-patterns or inefficient approaches",
149
+ "50: Works but not idiomatic",
150
+ "80: Follows most best practices",
151
+ "100: Follows all best practices, idiomatic implementation",
152
+ ],
153
+ criteriaLabel: "Check for:",
154
+ },
155
+ {
156
+ id: "doc-coverage",
157
+ dimension: "doc-coverage",
158
+ header: "Score documentation coverage from 0 to 100:",
159
+ scale: [
160
+ "0: Had to hallucinate/guess most implementation details",
161
+ "30: Significant gaps — filled with assumptions",
162
+ "50: Some gaps — inferred from partial information",
163
+ "80: Minor gaps — almost everything was documented",
164
+ "100: Complete coverage — all necessary info was in docs",
165
+ ],
166
+ },
167
+ ],
168
+ // ── Fixture resolvers ────────────────────────────────────
169
+ fixtureResolvers: [
170
+ {
171
+ scheme: "sanity://",
172
+ handlerModule: "./fixture-resolver.js",
173
+ },
174
+ ],
175
+ // ── Prompt templates (from literacy handler) ─────────────
176
+ promptTemplates: LITERACY_PROMPT_TEMPLATES,
177
+ // ── Scoring profiles ─────────────────────────────────────
178
+ // Literacy-relevant profiles only; mode-specific profiles for
179
+ // mcp-server, knowledge-probe, etc. belong in their own presets.
180
+ scoringProfiles: {
181
+ default: {
182
+ "task-completion": 0.5,
183
+ "code-correctness": 0.25,
184
+ "doc-coverage": 0.25,
185
+ },
186
+ "output-only": {
187
+ "task-completion": 0.6,
188
+ "code-correctness": 0.4,
189
+ },
190
+ },
191
+ // ── Doc fetcher factory ──────────────────────────────────
192
+ // Closure captures rootDir so the registry can instantiate
193
+ // the fetcher without knowing about Sanity internals.
194
+ docFetcher: () => new SanityDocFetcher(rootDir),
195
+ // ── Source definitions ────────────────────────────────────
196
+ // Mirrors config/sources.ts — env() calls are evaluated at
197
+ // preset creation time, matching the existing runtime behavior.
198
+ sourceDefs: [
199
+ {
200
+ name: "production",
201
+ baseUrl: "https://www.sanity.io/docs",
202
+ projectId: env("SANITY_PROJECT_ID", "3do82whm"),
203
+ dataset: env("SANITY_DATASET", "next"),
204
+ },
205
+ {
206
+ name: "branch",
207
+ baseUrl: env("DOC_BASE_URL", ""),
208
+ projectId: env("SANITY_PROJECT_ID", "3do82whm"),
209
+ dataset: env("SANITY_DATASET", "next"),
210
+ },
211
+ {
212
+ name: "local",
213
+ baseUrl: `http://localhost:${env("DOC_LOCAL_PORT", "3001")}/docs`,
214
+ projectId: env("SANITY_PROJECT_ID", "3do82whm"),
215
+ dataset: env("SANITY_DATASET", "next"),
216
+ },
217
+ ],
218
+ // ── Feature registry ─────────────────────────────────────
219
+ // Complete product feature set for coverage auditing.
220
+ featureDefs: {
221
+ features: [
222
+ // Currently covered (have evaluation tasks)
223
+ {
224
+ id: "groq",
225
+ name: "GROQ Query Language",
226
+ sections: ["content-lake"],
227
+ status: "covered",
228
+ area: "groq",
229
+ priority: "critical",
230
+ taskCount: 3,
231
+ },
232
+ {
233
+ id: "visual-editing",
234
+ name: "Visual Editing",
235
+ sections: ["visual-editing"],
236
+ status: "covered",
237
+ area: "visual-editing",
238
+ priority: "critical",
239
+ taskCount: 1,
240
+ },
241
+ {
242
+ id: "nextjs-live",
243
+ name: "Next.js Live Preview",
244
+ sections: ["visual-editing"],
245
+ status: "covered",
246
+ area: "nextjs-live",
247
+ priority: "high",
248
+ taskCount: 2,
249
+ },
250
+ {
251
+ id: "functions",
252
+ name: "Sanity Functions",
253
+ sections: ["compute-and-ai"],
254
+ status: "covered",
255
+ area: "functions",
256
+ priority: "high",
257
+ taskCount: 2,
258
+ },
259
+ {
260
+ id: "studio-setup",
261
+ name: "Studio Configuration",
262
+ sections: ["studio"],
263
+ status: "covered",
264
+ area: "studio-setup",
265
+ priority: "high",
266
+ taskCount: 1,
267
+ },
268
+ {
269
+ id: "frameworks",
270
+ name: "Framework Integration",
271
+ sections: ["developer-guides"],
272
+ status: "covered",
273
+ area: "frameworks",
274
+ priority: "high",
275
+ taskCount: 2,
276
+ },
277
+ // Uncovered (no evaluation tasks yet)
278
+ {
279
+ id: "portable-text",
280
+ name: "Portable Text",
281
+ sections: ["content-lake", "studio"],
282
+ status: "uncovered",
283
+ priority: "high",
284
+ },
285
+ {
286
+ id: "image-assets",
287
+ name: "Image & Asset Handling",
288
+ sections: ["content-lake", "apis-and-sdks"],
289
+ status: "uncovered",
290
+ priority: "high",
291
+ },
292
+ {
293
+ id: "mutations",
294
+ name: "Mutations & Transactions",
295
+ sections: ["content-lake", "apis-and-sdks"],
296
+ status: "uncovered",
297
+ priority: "high",
298
+ },
299
+ {
300
+ id: "schemas",
301
+ name: "Schema Types & Validation",
302
+ sections: ["studio", "content-lake"],
303
+ status: "uncovered",
304
+ priority: "medium",
305
+ },
306
+ {
307
+ id: "authentication",
308
+ name: "Authentication & Access Control",
309
+ sections: ["apis-and-sdks"],
310
+ status: "uncovered",
311
+ priority: "medium",
312
+ },
313
+ {
314
+ id: "webhooks",
315
+ name: "Webhooks",
316
+ sections: ["content-lake"],
317
+ status: "uncovered",
318
+ priority: "medium",
319
+ },
320
+ {
321
+ id: "realtime",
322
+ name: "Real-time Listeners",
323
+ sections: ["apis-and-sdks"],
324
+ status: "uncovered",
325
+ priority: "low",
326
+ },
327
+ {
328
+ id: "ai-assist",
329
+ name: "AI Assist",
330
+ sections: ["compute-and-ai", "studio"],
331
+ status: "uncovered",
332
+ priority: "medium",
333
+ },
334
+ ],
335
+ },
336
+ };
337
+ }
338
+ // ---------------------------------------------------------------------------
339
+ // Convenience constant — preset with default options for backward compat
340
+ // ---------------------------------------------------------------------------
341
+ /**
342
+ * Pre-built preset instance using default options (cwd for rootDir).
343
+ *
344
+ * Prefer `createSanityLiteracyPreset()` when you need to control rootDir
345
+ * or other options. This constant exists for backward compatibility with
346
+ * code that imports `sanityLiteracyPreset` directly.
347
+ */
348
+ export const sanityLiteracyPreset = createSanityLiteracyPreset();
349
+ /**
350
+ * Register the sanity-literacy preset in a plugin registry.
351
+ */
352
+ export function registerSanityLiteracyPreset(registry) {
353
+ registry.registerPreset(sanityLiteracyPreset);
354
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * PromptfooCompiler — compiles a TaskGraph into Promptfoo YAML configuration.
3
+ *
4
+ * The compiler is the core of the new architecture. It takes a validated
5
+ * TaskGraph and produces a Promptfoo config that can be executed via
6
+ * `promptfoo eval`.
7
+ *
8
+ * Compilation pipeline:
9
+ * TaskGraph → resolve fixtures → resolve variables → map assertions
10
+ * → assemble prompts → assemble providers → emit YAML
11
+ *
12
+ * This module exists alongside `generate-configs.ts` — it does NOT replace
13
+ * the existing codegen path. Phase 7 will swap callers over to the compiler.
14
+ *
15
+ * @see docs/exec-plans/architecture-overhaul/phase-2-config-compiler.md
16
+ */
17
+ import type { ModeHandler, ModelsConfig, TaskGraph } from "../../_vendor/ailf-core/index.d.ts";
18
+ import type { EvalMode } from "../../_vendor/ailf-shared/index.d.ts";
19
+ import { type PromptfooAssertion } from "./assertion-mapper.js";
20
+ /** A single Promptfoo test case */
21
+ export interface PromptfooTestCase {
22
+ assert?: PromptfooAssertion[];
23
+ description: string;
24
+ vars: Record<string, unknown>;
25
+ /** Prompt filter — which prompts this test case runs against */
26
+ prompts?: string[];
27
+ }
28
+ /** A compiled Promptfoo configuration */
29
+ export interface CompiledPromptfooConfig {
30
+ /** Description header */
31
+ description: string;
32
+ /** Prompt entries (id, label, raw template) */
33
+ prompts: PromptfooPrompt[];
34
+ /** Provider entries */
35
+ providers: PromptfooProvider[];
36
+ /** Test cases */
37
+ tests: PromptfooTestCase[];
38
+ /** Default test configuration */
39
+ defaultTest?: {
40
+ options?: Record<string, unknown>;
41
+ };
42
+ /** Output path for results */
43
+ outputPath?: string;
44
+ }
45
+ /** A Promptfoo prompt entry */
46
+ export interface PromptfooPrompt {
47
+ id: string;
48
+ label: string;
49
+ raw: string;
50
+ }
51
+ /** A Promptfoo provider entry */
52
+ export interface PromptfooProvider {
53
+ id: string;
54
+ label?: string;
55
+ config?: Record<string, unknown>;
56
+ }
57
+ /** Options for the Promptfoo compiler */
58
+ export interface PromptfooCompilerOptions {
59
+ /** The evaluation mode */
60
+ mode: EvalMode;
61
+ /** Model registry */
62
+ models: ModelsConfig;
63
+ /** Root directory for fixture resolution */
64
+ rootDir: string;
65
+ /** Output path for the generated config */
66
+ outputPath?: string;
67
+ /** Grader model provider ID */
68
+ graderProvider?: string;
69
+ /** Prompt templates to use (explicit override) */
70
+ prompts?: PromptfooPrompt[];
71
+ /**
72
+ * Mode handler — when provided, the compiler calls handler.getPrompts()
73
+ * and uses those templates before falling back to explicit prompts or
74
+ * built-in defaults.
75
+ */
76
+ handler?: ModeHandler;
77
+ }
78
+ /** Result of compilation */
79
+ export interface CompilationResult {
80
+ /** The compiled Promptfoo config */
81
+ config: CompiledPromptfooConfig;
82
+ /** Warnings generated during compilation */
83
+ warnings: string[];
84
+ /** Number of tasks compiled */
85
+ taskCount: number;
86
+ /** Number of test cases generated */
87
+ testCaseCount: number;
88
+ }
89
+ /**
90
+ * Compile a TaskGraph into a Promptfoo configuration.
91
+ *
92
+ * Traverses the graph in topological order, resolves fixtures and
93
+ * variables for each node, maps assertions, and assembles the final
94
+ * Promptfoo config.
95
+ */
96
+ export declare function compileToPromptfoo(graph: TaskGraph, options: PromptfooCompilerOptions): CompilationResult;