@sanity/ailf 0.5.0 → 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.
- package/config/features.ts +23 -0
- package/config/models.ts +83 -0
- package/config/prompts.ts +16 -0
- package/config/rubrics.ts +225 -0
- package/config/schedules.ts +47 -0
- package/config/sinks.ts +37 -0
- package/config/sources.ts +21 -0
- package/config/thresholds.ts +61 -0
- package/dist/_vendor/ailf-core/config-helpers.d.ts +174 -0
- package/dist/_vendor/ailf-core/config-helpers.js +150 -0
- package/dist/_vendor/ailf-core/env-helper.d.ts +35 -0
- package/dist/_vendor/ailf-core/env-helper.js +45 -0
- package/dist/_vendor/ailf-core/index.d.ts +3 -0
- package/dist/_vendor/ailf-core/index.js +5 -0
- package/dist/_vendor/ailf-core/ports/context.d.ts +15 -2
- package/dist/_vendor/ailf-core/ports/doc-fetcher.d.ts +2 -2
- package/dist/_vendor/ailf-core/ports/index.d.ts +2 -1
- package/dist/_vendor/ailf-core/ports/mode-handler.d.ts +129 -0
- package/dist/_vendor/ailf-core/ports/mode-handler.js +19 -0
- package/dist/_vendor/ailf-core/ports/task-source.d.ts +16 -122
- package/dist/_vendor/ailf-core/ports/task-source.js +7 -7
- package/dist/_vendor/ailf-core/schemas/eval-config.d.ts +7 -2
- package/dist/_vendor/ailf-core/schemas/eval-config.js +7 -2
- package/dist/_vendor/ailf-core/schemas/pipeline-request.d.ts +8 -3
- package/dist/_vendor/ailf-core/schemas/pipeline-request.js +6 -1
- package/dist/_vendor/ailf-core/schemas/pipeline.d.ts +14 -29
- package/dist/_vendor/ailf-core/schemas/pipeline.js +17 -8
- package/dist/_vendor/ailf-core/schemas/schedules.d.ts +14 -4
- package/dist/_vendor/ailf-core/schemas/schedules.js +6 -2
- package/dist/_vendor/ailf-core/schemas/sinks.d.ts +1 -1
- package/dist/_vendor/ailf-core/services/comparison-formatters.js +57 -19
- package/dist/_vendor/ailf-core/services/index.d.ts +2 -1
- package/dist/_vendor/ailf-core/services/index.js +2 -1
- package/dist/_vendor/ailf-core/services/scoring-engine.d.ts +153 -0
- package/dist/_vendor/ailf-core/services/scoring-engine.js +237 -0
- package/dist/_vendor/ailf-core/services/scoring.d.ts +15 -2
- package/dist/_vendor/ailf-core/services/scoring.js +25 -15
- package/dist/_vendor/ailf-core/types/branded-ids.d.ts +137 -0
- package/dist/_vendor/ailf-core/types/branded-ids.js +136 -0
- package/dist/_vendor/ailf-core/types/eval-mode-config.d.ts +150 -0
- package/dist/_vendor/ailf-core/types/eval-mode-config.js +24 -0
- package/dist/_vendor/ailf-core/types/generalized-task.d.ts +319 -0
- package/dist/_vendor/ailf-core/types/generalized-task.js +13 -0
- package/dist/_vendor/ailf-core/types/index.d.ts +45 -81
- package/dist/_vendor/ailf-core/types/index.js +8 -1
- package/dist/_vendor/ailf-core/types/plugin-registry.d.ts +202 -0
- package/dist/_vendor/ailf-core/types/plugin-registry.js +132 -0
- package/dist/_vendor/ailf-core/types/storage-schema.d.ts +199 -0
- package/dist/_vendor/ailf-core/types/storage-schema.js +39 -0
- package/dist/_vendor/ailf-core/types/task-graph.d.ts +86 -0
- package/dist/_vendor/ailf-core/types/task-graph.js +20 -0
- package/dist/_vendor/ailf-core/types/trace.d.ts +118 -0
- package/dist/_vendor/ailf-core/types/trace.js +18 -0
- package/dist/_vendor/ailf-core/types/variable-envelope.d.ts +80 -0
- package/dist/_vendor/ailf-core/types/variable-envelope.js +16 -0
- package/dist/_vendor/ailf-shared/dimension-names.d.ts +5 -18
- package/dist/_vendor/ailf-shared/dimension-names.js +6 -24
- package/dist/_vendor/ailf-shared/eval-modes.d.ts +38 -6
- package/dist/_vendor/ailf-shared/eval-modes.js +26 -2
- package/dist/_vendor/ailf-shared/index.d.ts +0 -1
- package/dist/_vendor/ailf-shared/index.js +0 -1
- package/dist/adapters/api-client/build-request.js +14 -13
- package/dist/adapters/config-sources/file-config-adapter.d.ts +20 -11
- package/dist/adapters/config-sources/file-config-adapter.js +38 -12
- package/dist/adapters/config-sources/index.d.ts +2 -0
- package/dist/adapters/config-sources/index.js +1 -0
- package/dist/adapters/config-sources/ts-config-loader.d.ts +59 -0
- package/dist/adapters/config-sources/ts-config-loader.js +133 -0
- package/dist/adapters/doc-fetchers/sanity-doc-fetcher.d.ts +3 -2
- package/dist/adapters/doc-fetchers/sanity-doc-fetcher.js +7 -2
- package/dist/adapters/task-sources/composite-task-source.d.ts +3 -3
- package/dist/adapters/task-sources/composite-task-source.js +1 -1
- package/dist/adapters/task-sources/content-lake-task-source.d.ts +7 -6
- package/dist/adapters/task-sources/content-lake-task-source.js +22 -23
- package/dist/adapters/task-sources/index.d.ts +1 -0
- package/dist/adapters/task-sources/index.js +1 -0
- package/dist/adapters/task-sources/repo-task-source.d.ts +4 -4
- package/dist/adapters/task-sources/repo-task-source.js +69 -16
- package/dist/adapters/task-sources/task-file-loader.d.ts +64 -0
- package/dist/adapters/task-sources/task-file-loader.js +83 -0
- package/dist/adapters/task-sources/yaml-task-source.d.ts +6 -6
- package/dist/adapters/task-sources/yaml-task-source.js +19 -16
- package/dist/cli.js +0 -2
- package/dist/commands/baseline.js +4 -1
- package/dist/commands/calculate-scores.js +1 -1
- package/dist/commands/coverage-audit.js +7 -1
- package/dist/commands/explain-handler.js +25 -23
- package/dist/commands/fetch-docs.js +3 -2
- package/dist/commands/generate-configs.js +1 -1
- package/dist/commands/interactive.js +11 -7
- package/dist/commands/pipeline-action.d.ts +2 -0
- package/dist/commands/pipeline-action.js +16 -6
- package/dist/commands/pipeline.d.ts +1 -0
- package/dist/commands/pipeline.js +4 -2
- package/dist/commands/pr-comment.js +1 -1
- package/dist/commands/publish.js +2 -2
- package/dist/commands/readiness-report.js +13 -6
- package/dist/composition-root.d.ts +1 -1
- package/dist/composition-root.js +67 -4
- package/dist/orchestration/build-app-context.js +1 -0
- package/dist/orchestration/build-step-sequence.js +24 -6
- package/dist/orchestration/steps/calculate-scores-step.js +24 -11
- package/dist/orchestration/steps/fetch-docs-step.js +6 -4
- package/dist/orchestration/steps/gap-analysis-step.js +8 -7
- package/dist/orchestration/steps/generate-configs-step.d.ts +16 -3
- package/dist/orchestration/steps/generate-configs-step.js +245 -51
- package/dist/orchestration/steps/grader-consistency-step.js +7 -4
- package/dist/orchestration/steps/mirror-repo-tasks-step.js +1 -1
- package/dist/orchestration/steps/readiness-step.js +5 -6
- package/dist/orchestration/steps/run-eval-step.d.ts +1 -2
- package/dist/orchestration/steps/run-eval-step.js +8 -7
- package/dist/pipeline/cache.d.ts +1 -1
- package/dist/pipeline/cache.js +36 -8
- package/dist/pipeline/calculate-scores.d.ts +2 -4
- package/dist/pipeline/calculate-scores.js +43 -113
- package/dist/pipeline/checks.js +2 -2
- package/dist/pipeline/compare.js +8 -8
- package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.js +288 -0
- package/dist/pipeline/compiler/__tests__/assertion-mapper.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/assertion-mapper.test.js +145 -0
- package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.js +314 -0
- package/dist/pipeline/compiler/__tests__/literacy-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/literacy-handler.test.js +486 -0
- package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.js +355 -0
- package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.js +333 -0
- package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.d.ts +12 -0
- package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.js +210 -0
- package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.d.ts +7 -0
- package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.js +471 -0
- package/dist/pipeline/compiler/__tests__/scoring-bridge.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/scoring-bridge.test.js +184 -0
- package/dist/pipeline/compiler/__tests__/task-graph-builder.test.d.ts +8 -0
- package/dist/pipeline/compiler/__tests__/task-graph-builder.test.js +301 -0
- package/dist/pipeline/compiler/__tests__/telemetry.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/telemetry.test.js +503 -0
- package/dist/pipeline/compiler/assertion-mapper.d.ts +58 -0
- package/dist/pipeline/compiler/assertion-mapper.js +175 -0
- package/dist/pipeline/compiler/compiler-to-yaml.d.ts +51 -0
- package/dist/pipeline/compiler/compiler-to-yaml.js +222 -0
- package/dist/pipeline/compiler/config-loader.d.ts +56 -0
- package/dist/pipeline/compiler/config-loader.js +111 -0
- package/dist/pipeline/compiler/fixture-resolver.d.ts +41 -0
- package/dist/pipeline/compiler/fixture-resolver.js +113 -0
- package/dist/pipeline/compiler/hash.d.ts +11 -0
- package/dist/pipeline/compiler/hash.js +18 -0
- package/dist/pipeline/compiler/ignore-fields.d.ts +53 -0
- package/dist/pipeline/compiler/ignore-fields.js +113 -0
- package/dist/pipeline/compiler/index.d.ts +29 -0
- package/dist/pipeline/compiler/index.js +45 -0
- package/dist/pipeline/compiler/literacy-bridge.d.ts +102 -0
- package/dist/pipeline/compiler/literacy-bridge.js +172 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.d.ts +14 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.js +152 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.d.ts +32 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.js +176 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.d.ts +49 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.js +259 -0
- package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.d.ts +70 -0
- package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.js +485 -0
- package/dist/pipeline/compiler/mode-handlers/index.d.ts +16 -0
- package/dist/pipeline/compiler/mode-handlers/index.js +21 -0
- package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.d.ts +76 -0
- package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.js +245 -0
- package/dist/pipeline/compiler/mode-handlers/literacy-handler.d.ts +89 -0
- package/dist/pipeline/compiler/mode-handlers/literacy-handler.js +379 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-assertions.d.ts +50 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-assertions.js +277 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.d.ts +67 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.js +309 -0
- package/dist/pipeline/compiler/presets/index.d.ts +9 -0
- package/dist/pipeline/compiler/presets/index.js +8 -0
- package/dist/pipeline/compiler/presets/sanity-literacy.d.ts +45 -0
- package/dist/pipeline/compiler/presets/sanity-literacy.js +354 -0
- package/dist/pipeline/compiler/promptfoo-compiler.d.ts +96 -0
- package/dist/pipeline/compiler/promptfoo-compiler.js +230 -0
- package/dist/pipeline/compiler/provider-assembler.d.ts +39 -0
- package/dist/pipeline/compiler/provider-assembler.js +137 -0
- package/dist/pipeline/compiler/sandbox/docker-sandbox.d.ts +21 -0
- package/dist/pipeline/compiler/sandbox/docker-sandbox.js +136 -0
- package/dist/pipeline/compiler/sandbox/fixture-provisioner.d.ts +69 -0
- package/dist/pipeline/compiler/sandbox/fixture-provisioner.js +189 -0
- package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.d.ts +20 -0
- package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.js +114 -0
- package/dist/pipeline/compiler/sandbox/index.d.ts +10 -0
- package/dist/pipeline/compiler/sandbox/index.js +11 -0
- package/dist/pipeline/compiler/sandbox/sandbox-selector.d.ts +35 -0
- package/dist/pipeline/compiler/sandbox/sandbox-selector.js +86 -0
- package/dist/pipeline/compiler/sandbox/sandbox-strategy.d.ts +81 -0
- package/dist/pipeline/compiler/sandbox/sandbox-strategy.js +15 -0
- package/dist/pipeline/compiler/sandbox/tempdir-sandbox.d.ts +20 -0
- package/dist/pipeline/compiler/sandbox/tempdir-sandbox.js +74 -0
- package/dist/pipeline/compiler/scoring-bridge.d.ts +49 -0
- package/dist/pipeline/compiler/scoring-bridge.js +114 -0
- package/dist/pipeline/compiler/task-graph-builder.d.ts +54 -0
- package/dist/pipeline/compiler/task-graph-builder.js +291 -0
- package/dist/pipeline/compiler/telemetry/cost-tracker.d.ts +90 -0
- package/dist/pipeline/compiler/telemetry/cost-tracker.js +146 -0
- package/dist/pipeline/compiler/telemetry/index.d.ts +14 -0
- package/dist/pipeline/compiler/telemetry/index.js +19 -0
- package/dist/pipeline/compiler/telemetry/redactor.d.ts +58 -0
- package/dist/pipeline/compiler/telemetry/redactor.js +222 -0
- package/dist/pipeline/compiler/telemetry/tool-classifier.d.ts +32 -0
- package/dist/pipeline/compiler/telemetry/tool-classifier.js +120 -0
- package/dist/pipeline/compiler/telemetry/trace-collector.d.ts +75 -0
- package/dist/pipeline/compiler/telemetry/trace-collector.js +297 -0
- package/dist/pipeline/compiler/telemetry/trace-store.d.ts +78 -0
- package/dist/pipeline/compiler/telemetry/trace-store.js +85 -0
- package/dist/pipeline/compiler/variable-resolver.d.ts +46 -0
- package/dist/pipeline/compiler/variable-resolver.js +115 -0
- package/dist/pipeline/coverage-audit.d.ts +15 -5
- package/dist/pipeline/coverage-audit.js +41 -22
- package/dist/pipeline/eval-constants.d.ts +16 -6
- package/dist/pipeline/eval-constants.js +25 -4
- package/dist/pipeline/eval-fingerprint.d.ts +2 -2
- package/dist/pipeline/eval-fingerprint.js +8 -9
- package/dist/pipeline/expand-tasks.d.ts +19 -10
- package/dist/pipeline/expand-tasks.js +34 -28
- package/dist/pipeline/gap-analysis.d.ts +1 -1
- package/dist/pipeline/gap-analysis.js +2 -2
- package/dist/pipeline/generate-configs.d.ts +22 -4
- package/dist/pipeline/generate-configs.js +53 -24
- package/dist/pipeline/grader-api.d.ts +3 -3
- package/dist/pipeline/grader-api.js +5 -12
- package/dist/pipeline/grader-compare-runner.js +20 -27
- package/dist/pipeline/grader-comparison.d.ts +4 -8
- package/dist/pipeline/grader-comparison.js +11 -17
- package/dist/pipeline/grader-consistency-runner.d.ts +2 -3
- package/dist/pipeline/grader-consistency-runner.js +16 -20
- package/dist/pipeline/grader-consistency.d.ts +6 -10
- package/dist/pipeline/grader-consistency.js +13 -32
- package/dist/pipeline/grader-sensitivity-runner.js +7 -5
- package/dist/pipeline/grader-sensitivity.d.ts +2 -6
- package/dist/pipeline/grader-sensitivity.js +10 -10
- package/dist/pipeline/grader-validate-runner.js +7 -5
- package/dist/pipeline/grader-validation.d.ts +2 -6
- package/dist/pipeline/grader-validation.js +14 -22
- package/dist/pipeline/map-request-to-config.js +6 -1
- package/dist/pipeline/mirror-repo-tasks.d.ts +6 -6
- package/dist/pipeline/mirror-repo-tasks.js +16 -15
- package/dist/pipeline/normalize-mode.d.ts +49 -0
- package/dist/pipeline/normalize-mode.js +64 -0
- package/dist/pipeline/plan.d.ts +5 -2
- package/dist/pipeline/plan.js +134 -78
- package/dist/pipeline/pr-comment.js +2 -0
- package/dist/pipeline/profile-resolution.d.ts +22 -14
- package/dist/pipeline/profile-resolution.js +41 -19
- package/dist/pipeline/provenance.d.ts +2 -2
- package/dist/pipeline/provenance.js +12 -17
- package/dist/pipeline/release-report.js +4 -4
- package/dist/pipeline/repo-threshold-evaluator.d.ts +1 -1
- package/dist/pipeline/repo-threshold-evaluator.js +1 -1
- package/dist/pipeline/rubric-loader.d.ts +20 -0
- package/dist/pipeline/rubric-loader.js +37 -0
- package/dist/pipeline/validate.d.ts +4 -4
- package/dist/pipeline/validate.js +64 -53
- package/dist/schedules/loader.js +18 -8
- package/dist/scripts/migrate-task-mode.d.ts +24 -0
- package/dist/scripts/migrate-task-mode.js +85 -0
- package/dist/scripts/migrate-tasks-to-content-lake.js +11 -10
- package/dist/scripts/validate-task-sources.d.ts +1 -1
- package/dist/scripts/validate-task-sources.js +15 -15
- package/dist/sinks/loader.js +5 -7
- package/dist/sources.d.ts +7 -7
- package/dist/sources.js +22 -24
- package/dist/webhook/dispatch.js +2 -1
- package/package.json +6 -3
- package/tasks/knowledge-probe/define-type-api.task.ts +55 -0
- package/tasks/knowledge-probe/groq-projections.task.ts +59 -0
- package/tasks/literacy/frameworks.task.ts +128 -0
- package/tasks/literacy/functions.task.ts +69 -0
- package/tasks/literacy/groq.task.ts +258 -0
- package/tasks/literacy/nextjs-live.task.ts +75 -0
- package/tasks/literacy/studio-setup.task.ts +131 -0
- package/tasks/literacy/visual-editing.task.ts +146 -0
- package/config/features.yaml +0 -116
- package/config/models.yaml +0 -116
- package/config/prompts.yaml +0 -75
- package/config/rubrics.yaml +0 -81
- package/config/schedules.yaml +0 -43
- package/config/sinks.yaml +0 -54
- package/config/sources.yaml +0 -51
- package/config/thresholds.yaml +0 -49
- package/dist/agent-observer/test-imports.d.ts +0 -7
- package/dist/agent-observer/test-imports.js +0 -185
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KnowledgeProbeModeHandler — compilation rules for `knowledge-probe` mode.
|
|
3
|
+
*
|
|
4
|
+
* The simplest mode handler. Knowledge probes measure raw model knowledge
|
|
5
|
+
* without documentation context, tool calling, or sandboxed execution.
|
|
6
|
+
* They answer: "What does this model know about X without any help?"
|
|
7
|
+
*
|
|
8
|
+
* Key properties:
|
|
9
|
+
* - No doc vars injected (intentionally empty)
|
|
10
|
+
* - Uses the without-docs prompt template (or custom prompt)
|
|
11
|
+
* - Standard LLM providers only (no agent SDKs, no MCP)
|
|
12
|
+
* - No retrieval metrics (precision/recall/F1 not applicable)
|
|
13
|
+
* - Results feed into the standard cross-model comparison pipeline
|
|
14
|
+
*
|
|
15
|
+
* This handler is the reference implementation for the mode handler pattern.
|
|
16
|
+
*
|
|
17
|
+
* @see docs/exec-plans/architecture-overhaul/phase-5-knowledge-probe.md
|
|
18
|
+
* @see packages/core/src/types/generalized-task.ts — KnowledgeProbeTaskDefinition
|
|
19
|
+
*/
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Canonical knowledge probe prompt templates
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Handler-owned prompts for knowledge probe evaluations. These ask factual
|
|
24
|
+
// questions without injecting documentation context — measuring raw model
|
|
25
|
+
// knowledge about Sanity concepts.
|
|
26
|
+
export const KNOWLEDGE_PROBE_PROMPT_TEMPLATES = {
|
|
27
|
+
"knowledge-probe": {
|
|
28
|
+
id: "knowledge-probe",
|
|
29
|
+
label: "Knowledge Probe (No Docs)",
|
|
30
|
+
template: `Answer the following question about Sanity.io based on your existing knowledge. Do not search for or reference external documentation.
|
|
31
|
+
|
|
32
|
+
## Question
|
|
33
|
+
{{task}}
|
|
34
|
+
|
|
35
|
+
## Instructions
|
|
36
|
+
|
|
37
|
+
1. Answer based solely on what you already know
|
|
38
|
+
2. Be specific — include API names, function signatures, and code examples where relevant
|
|
39
|
+
3. If you are unsure about a detail, say so rather than guessing
|
|
40
|
+
4. Provide a complete, accurate answer
|
|
41
|
+
|
|
42
|
+
Your answer:
|
|
43
|
+
`,
|
|
44
|
+
variables: ["task"],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Validate that a knowledge probe task definition has all required fields.
|
|
49
|
+
*/
|
|
50
|
+
export function validateKnowledgeProbeTask(task) {
|
|
51
|
+
const errors = [];
|
|
52
|
+
if (!task.id) {
|
|
53
|
+
errors.push({ field: "id", message: "Task ID is required" });
|
|
54
|
+
}
|
|
55
|
+
if (!task.title) {
|
|
56
|
+
errors.push({ field: "title", message: "Task title is required" });
|
|
57
|
+
}
|
|
58
|
+
// Knowledge probes must have either a prompt or a description
|
|
59
|
+
if (!task.prompt?.text && !task.prompt?.vars?.task && !task.description) {
|
|
60
|
+
errors.push({
|
|
61
|
+
field: "prompt",
|
|
62
|
+
message: "Knowledge probe tasks require either prompt.text, prompt.vars.task, " +
|
|
63
|
+
"or description — the question to ask the model",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return errors;
|
|
67
|
+
}
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Compilation
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
/**
|
|
72
|
+
* Compile a knowledge probe task definition into Promptfoo configuration.
|
|
73
|
+
*
|
|
74
|
+
* This is intentionally minimal — knowledge probes map almost 1:1 to
|
|
75
|
+
* basic Promptfoo test cases. The AILF value-add is type-safe authoring,
|
|
76
|
+
* cross-model comparison, and score normalization.
|
|
77
|
+
*/
|
|
78
|
+
export function compileKnowledgeProbeTask(task, options) {
|
|
79
|
+
const warnings = [];
|
|
80
|
+
// Validate
|
|
81
|
+
const validationErrors = validateKnowledgeProbeTask(task);
|
|
82
|
+
for (const err of validationErrors) {
|
|
83
|
+
warnings.push(`Knowledge probe "${task.id}": ${err.field} — ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
// Build providers from model list (or use a default placeholder)
|
|
86
|
+
const providers = buildProviders(options);
|
|
87
|
+
// Build prompts — knowledge probes use a single no-docs prompt
|
|
88
|
+
const prompts = buildPrompts(task);
|
|
89
|
+
// Build test cases
|
|
90
|
+
const tests = buildTestCases(task, options, warnings);
|
|
91
|
+
// Build metadata
|
|
92
|
+
const metadata = {
|
|
93
|
+
mode: "knowledge-probe",
|
|
94
|
+
probeStrategy: task.probeStrategy ?? "breadth-first",
|
|
95
|
+
noDocContext: true,
|
|
96
|
+
retrievalMetrics: false,
|
|
97
|
+
};
|
|
98
|
+
return { providers, tests, prompts, metadata, warnings };
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Provider assembly
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
function buildProviders(options) {
|
|
104
|
+
if (options?.models && options.models.length > 0) {
|
|
105
|
+
return options.models.map((model) => ({
|
|
106
|
+
id: model.id,
|
|
107
|
+
label: model.label,
|
|
108
|
+
config: model.config,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
// No models specified — return empty (caller should provide models)
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Prompt assembly
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
function buildPrompts(task) {
|
|
118
|
+
// Knowledge probes use a single prompt — no with-docs/without-docs split.
|
|
119
|
+
// The prompt IS the probe question.
|
|
120
|
+
const promptText = task.prompt?.text ??
|
|
121
|
+
task.prompt?.vars?.task ??
|
|
122
|
+
task.description ??
|
|
123
|
+
`Knowledge probe: ${task.title}`;
|
|
124
|
+
const systemMessage = task.prompt?.systemMessage;
|
|
125
|
+
return [
|
|
126
|
+
{
|
|
127
|
+
id: "knowledge-probe",
|
|
128
|
+
label: `Probe: ${task.title}`,
|
|
129
|
+
raw: systemMessage
|
|
130
|
+
? `[system]\n${systemMessage}\n\n[user]\n${String(promptText)}`
|
|
131
|
+
: String(promptText),
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
// Test case assembly
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
function buildTestCases(task, options, warnings) {
|
|
139
|
+
// Build assertions
|
|
140
|
+
const assertions = [];
|
|
141
|
+
if (task.assertions) {
|
|
142
|
+
for (const assertion of task.assertions) {
|
|
143
|
+
const raw = assertion;
|
|
144
|
+
const mapped = mapKnowledgeProbeAssertion(raw, options, warnings);
|
|
145
|
+
if (mapped)
|
|
146
|
+
assertions.push(mapped);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Build vars — intentionally no docs
|
|
150
|
+
const vars = {
|
|
151
|
+
task: task.prompt?.vars?.task ??
|
|
152
|
+
task.description ??
|
|
153
|
+
`Knowledge probe: ${task.title}`,
|
|
154
|
+
...(task.prompt?.vars ?? {}),
|
|
155
|
+
// Metadata for scoring pipeline
|
|
156
|
+
__mode: "knowledge-probe",
|
|
157
|
+
__probeStrategy: task.probeStrategy ?? "breadth-first",
|
|
158
|
+
};
|
|
159
|
+
// Explicitly do NOT include docs
|
|
160
|
+
// This is the defining characteristic of knowledge-probe mode
|
|
161
|
+
delete vars.docs;
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
description: `${task.id} — ${task.title}`,
|
|
165
|
+
vars,
|
|
166
|
+
...(assertions.length > 0 ? { assert: assertions } : {}),
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
// Assertion mapping
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
function mapKnowledgeProbeAssertion(assertion, options, warnings) {
|
|
174
|
+
switch (assertion.type) {
|
|
175
|
+
// Standard assertions — pass through
|
|
176
|
+
case "contains":
|
|
177
|
+
case "contains-all":
|
|
178
|
+
case "contains-any":
|
|
179
|
+
case "equals":
|
|
180
|
+
case "is-json":
|
|
181
|
+
case "javascript":
|
|
182
|
+
case "python":
|
|
183
|
+
case "regex":
|
|
184
|
+
case "similar":
|
|
185
|
+
return {
|
|
186
|
+
type: assertion.type,
|
|
187
|
+
...("value" in assertion ? { value: assertion.value } : {}),
|
|
188
|
+
...(typeof assertion.weight === "number"
|
|
189
|
+
? { weight: assertion.weight }
|
|
190
|
+
: {}),
|
|
191
|
+
};
|
|
192
|
+
// LLM-graded assertions — add grader provider
|
|
193
|
+
case "g-eval":
|
|
194
|
+
case "llm-rubric":
|
|
195
|
+
case "model-graded-closedqa":
|
|
196
|
+
case "model-graded-factuality":
|
|
197
|
+
return {
|
|
198
|
+
type: assertion.type,
|
|
199
|
+
...("value" in assertion ? { value: assertion.value } : {}),
|
|
200
|
+
...(typeof assertion.weight === "number"
|
|
201
|
+
? { weight: assertion.weight }
|
|
202
|
+
: {}),
|
|
203
|
+
...(options?.graderProvider
|
|
204
|
+
? { provider: options.graderProvider }
|
|
205
|
+
: {}),
|
|
206
|
+
};
|
|
207
|
+
// Tool-use assertions are NOT valid for knowledge probes
|
|
208
|
+
case "skill-used":
|
|
209
|
+
case "tool-call-f1":
|
|
210
|
+
case "tool-called":
|
|
211
|
+
case "tool-input-matches":
|
|
212
|
+
case "tool-output-matches":
|
|
213
|
+
warnings.push(`Knowledge probe "${assertion.type}" assertion is not applicable — ` +
|
|
214
|
+
"knowledge probes don't use tools. Assertion skipped.");
|
|
215
|
+
return null;
|
|
216
|
+
default:
|
|
217
|
+
warnings.push(`Knowledge probe: unknown assertion type "${assertion.type}" — passed through`);
|
|
218
|
+
return {
|
|
219
|
+
type: assertion.type,
|
|
220
|
+
...("value" in assertion ? { value: assertion.value } : {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
// ModeHandler adapter
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
/** ModeHandler-conformant export for the knowledge-probe evaluation mode. */
|
|
228
|
+
export const handler = {
|
|
229
|
+
getPrompts() {
|
|
230
|
+
return KNOWLEDGE_PROBE_PROMPT_TEMPLATES;
|
|
231
|
+
},
|
|
232
|
+
compileTask(task, ctx) {
|
|
233
|
+
if (!("mode" in task) || task.mode !== "knowledge-probe") {
|
|
234
|
+
throw new Error(`Knowledge probe handler received task with mode "${task.mode ?? "undefined"}" — expected "knowledge-probe"`);
|
|
235
|
+
}
|
|
236
|
+
const result = compileKnowledgeProbeTask(task, { graderProvider: ctx.graderProvider, models: ctx.models });
|
|
237
|
+
return {
|
|
238
|
+
providers: result.providers,
|
|
239
|
+
tests: result.tests,
|
|
240
|
+
prompts: result.prompts,
|
|
241
|
+
warnings: result.warnings,
|
|
242
|
+
extras: { metadata: result.metadata },
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiteracyModeHandler — compilation rules for `literacy` mode.
|
|
3
|
+
*
|
|
4
|
+
* This handler replaces the existing `generate-configs.ts` + `expand-tasks.ts`
|
|
5
|
+
* code path for literacy (documentation) evaluation. It compiles
|
|
6
|
+
* LiteracyTaskDefinition objects into Promptfoo structure:
|
|
7
|
+
*
|
|
8
|
+
* - Gold entry (with-docs prompt, canonical docs injected)
|
|
9
|
+
* - Baseline entry (without-docs prompt, empty docs)
|
|
10
|
+
* - Rubric template resolution from config/rubrics
|
|
11
|
+
* - Doc-coverage auto-generation when opted in
|
|
12
|
+
* - Structured dimension metadata on rubric assertions
|
|
13
|
+
*
|
|
14
|
+
* The handler accepts GeneralizedTaskDefinition, narrows to
|
|
15
|
+
* LiteracyTaskDefinition, and produces Promptfoo output.
|
|
16
|
+
*
|
|
17
|
+
* @see docs/exec-plans/architecture-overhaul/phase-7-migrate-literacy.md
|
|
18
|
+
* @see packages/eval/src/pipeline/expand-tasks.ts — the legacy code path
|
|
19
|
+
*/
|
|
20
|
+
import type { LiteracyTaskDefinition, ModeHandler, PromptTemplate } from "../../../_vendor/ailf-core/index.d.ts";
|
|
21
|
+
import { type LiteracyEvalSubMode } from "../../normalize-mode.js";
|
|
22
|
+
import type { PromptfooPrompt, PromptfooProvider, PromptfooTestCase } from "../promptfoo-compiler.js";
|
|
23
|
+
export declare const LITERACY_PROMPT_TEMPLATES: Record<string, PromptTemplate>;
|
|
24
|
+
/** Options for compiling a literacy task */
|
|
25
|
+
export interface LiteracyCompileOptions {
|
|
26
|
+
/** Grader provider for LLM-graded assertions */
|
|
27
|
+
graderProvider?: string;
|
|
28
|
+
/** Root directory (for resolving file:// doc paths) */
|
|
29
|
+
rootDir?: string;
|
|
30
|
+
/** Evaluation sub-mode — controls which entries are generated */
|
|
31
|
+
evalMode?: LiteracyEvalSubMode;
|
|
32
|
+
/** Model providers to include */
|
|
33
|
+
models?: {
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
config?: Record<string, unknown>;
|
|
37
|
+
}[];
|
|
38
|
+
/** Rubric config (templates, weights, profiles) — loaded from rubrics config */
|
|
39
|
+
rubricConfig?: RubricConfig;
|
|
40
|
+
}
|
|
41
|
+
/** Minimal rubric config needed by the handler */
|
|
42
|
+
export interface RubricConfig {
|
|
43
|
+
templates: Record<string, {
|
|
44
|
+
dimension?: string;
|
|
45
|
+
header: string;
|
|
46
|
+
scale: string[];
|
|
47
|
+
criteria_label?: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/** Result of compiling a single literacy task */
|
|
51
|
+
export interface LiteracyCompileResult {
|
|
52
|
+
/** Promptfoo provider configs */
|
|
53
|
+
providers: PromptfooProvider[];
|
|
54
|
+
/** Compiled test cases (gold + optional baseline) */
|
|
55
|
+
tests: PromptfooTestCase[];
|
|
56
|
+
/** Prompts for evaluation */
|
|
57
|
+
prompts: PromptfooPrompt[];
|
|
58
|
+
/** Warnings generated during compilation */
|
|
59
|
+
warnings: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface LiteracyValidationError {
|
|
62
|
+
field: string;
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validate a literacy task definition.
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateLiteracyTask(task: LiteracyTaskDefinition): LiteracyValidationError[];
|
|
69
|
+
/**
|
|
70
|
+
* Compile a literacy task into Promptfoo configuration.
|
|
71
|
+
*
|
|
72
|
+
* Produces the same structure as the legacy expand-tasks.ts path:
|
|
73
|
+
* - Gold entry with with-docs prompt and canonical doc context
|
|
74
|
+
* - Baseline entry with without-docs prompt and empty docs
|
|
75
|
+
* - Rubric assertions with structured dimension metadata
|
|
76
|
+
*/
|
|
77
|
+
export declare function compileLiteracyTask(task: LiteracyTaskDefinition, options?: LiteracyCompileOptions): LiteracyCompileResult;
|
|
78
|
+
/**
|
|
79
|
+
* ModeHandler-conformant export for the literacy evaluation mode.
|
|
80
|
+
*
|
|
81
|
+
* The pipeline looks up this handler via `registry.getMode("literacy")`
|
|
82
|
+
* and calls `handler.compileTask()`. The handler narrows the union to
|
|
83
|
+
* LiteracyTaskDefinition and delegates to `compileLiteracyTask()`.
|
|
84
|
+
*
|
|
85
|
+
* Note: The literacy handler's `evalMode` variant ("baseline" vs "agentic")
|
|
86
|
+
* is passed via `ctx.evalMode` — a literacy-specific extension of
|
|
87
|
+
* CompilationContext. The pipeline sets this when compiling literacy tasks.
|
|
88
|
+
*/
|
|
89
|
+
export declare const handler: ModeHandler;
|