@sanity/ailf 0.1.34 → 0.3.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/LICENSE +21 -0
- package/config/airbyte/ai_literacy_framework.connector.yaml +6 -0
- package/config/bigquery/views/reports.sql +1 -0
- package/dist/_vendor/ailf-core/examples/index.d.ts +10 -20
- package/dist/_vendor/ailf-core/examples/index.js +10 -20
- package/dist/_vendor/ailf-core/ports/task-source.d.ts +2 -0
- package/dist/_vendor/ailf-core/types/index.d.ts +65 -0
- package/dist/_vendor/ailf-tasks/schemas.d.ts +12 -0
- package/dist/_vendor/ailf-tasks/schemas.js +4 -0
- package/dist/adapters/task-sources/content-lake-task-source.js +9 -1
- package/dist/adapters/task-sources/repo-task-source.js +19 -4
- package/dist/commands/calculate-scores.js +5 -1
- package/dist/commands/publish.js +3 -0
- package/dist/composition-root.js +7 -2
- package/dist/orchestration/pipeline-orchestrator.js +27 -2
- package/dist/orchestration/step-runner.js +8 -0
- package/dist/orchestration/steps/calculate-scores-step.js +22 -19
- package/dist/orchestration/steps/generate-configs-step.js +1 -0
- package/dist/orchestration/steps/grader-consistency-step.js +1 -0
- package/dist/orchestration/steps/mirror-repo-tasks-step.js +2 -1
- package/dist/orchestration/steps/publish-report-step.js +3 -0
- package/dist/pipeline/calculate-scores.d.ts +11 -1
- package/dist/pipeline/calculate-scores.js +222 -157
- package/dist/pipeline/coverage-audit.d.ts +2 -1
- package/dist/pipeline/coverage-audit.js +5 -3
- package/dist/pipeline/expand-tasks.d.ts +2 -1
- package/dist/pipeline/expand-tasks.js +33 -2
- package/dist/pipeline/generate-configs.d.ts +3 -1
- package/dist/pipeline/generate-configs.js +51 -37
- package/dist/pipeline/grader-api.d.ts +2 -1
- package/dist/pipeline/grader-api.js +11 -9
- package/dist/pipeline/grader-compare-runner.d.ts +3 -0
- package/dist/pipeline/grader-compare-runner.js +21 -19
- package/dist/pipeline/grader-consistency-runner.d.ts +3 -0
- package/dist/pipeline/grader-consistency-runner.js +16 -14
- package/dist/pipeline/grader-sensitivity-runner.d.ts +3 -0
- package/dist/pipeline/grader-sensitivity-runner.js +18 -16
- package/dist/pipeline/grader-validate-runner.d.ts +3 -0
- package/dist/pipeline/grader-validate-runner.js +16 -14
- package/dist/pipeline/mirror-repo-tasks.d.ts +80 -1
- package/dist/pipeline/mirror-repo-tasks.js +148 -32
- package/dist/pipeline/provenance.d.ts +3 -0
- package/dist/pipeline/provenance.js +25 -3
- package/dist/pipeline/report-title.d.ts +66 -0
- package/dist/pipeline/report-title.js +118 -0
- package/dist/report-store.js +2 -0
- package/dist/sinks/bigquery/index.d.ts +1 -0
- package/dist/sinks/bigquery/index.js +1 -0
- package/dist/sources.d.ts +2 -1
- package/dist/sources.js +28 -1
- package/package.json +23 -23
package/dist/sources.js
CHANGED
|
@@ -16,6 +16,7 @@ import { readFileSync } from "fs";
|
|
|
16
16
|
import { dirname, resolve } from "path";
|
|
17
17
|
import { fileURLToPath } from "url";
|
|
18
18
|
import { load } from "js-yaml";
|
|
19
|
+
import { ConsoleLogger } from "./adapters/loggers/index.js";
|
|
19
20
|
import { interpolate } from "./interpolate.js";
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
21
22
|
// Paths
|
|
@@ -72,11 +73,17 @@ export function isAllowedOrigin(url, origins) {
|
|
|
72
73
|
* @param name - Source name from config/sources.yaml. If omitted, uses DOC_SOURCE
|
|
73
74
|
* env var or the first source defined in config/sources.yaml.
|
|
74
75
|
*/
|
|
75
|
-
export function loadSource(name, overrides) {
|
|
76
|
+
export function loadSource(name, overrides, logger) {
|
|
77
|
+
const log = logger ?? new ConsoleLogger();
|
|
76
78
|
// Priority 1: DOC_BASE_URL env var creates an ad-hoc source
|
|
77
79
|
const envBaseUrl = overrides?.baseUrl ?? process.env.DOC_BASE_URL;
|
|
78
80
|
if (envBaseUrl) {
|
|
79
81
|
const domain = extractHostname(envBaseUrl);
|
|
82
|
+
log.debug("Source resolved from DOC_BASE_URL env override", {
|
|
83
|
+
baseUrl: envBaseUrl,
|
|
84
|
+
domain,
|
|
85
|
+
hasOverrides: Boolean(overrides),
|
|
86
|
+
});
|
|
80
87
|
return {
|
|
81
88
|
allowedOrigins: overrides?.allowedOrigins ?? parseAllowedOriginsEnv(),
|
|
82
89
|
baseUrl: envBaseUrl,
|
|
@@ -106,10 +113,16 @@ export function loadSource(name, overrides) {
|
|
|
106
113
|
}
|
|
107
114
|
catch {
|
|
108
115
|
// No config/sources.yaml — use built-in default
|
|
116
|
+
log.debug("No config/sources.yaml found, falling back to built-in default", {
|
|
117
|
+
path: SOURCES_PATH,
|
|
118
|
+
defaultName: DEFAULT_SOURCE.name,
|
|
119
|
+
defaultBaseUrl: DEFAULT_SOURCE.baseUrl,
|
|
120
|
+
});
|
|
109
121
|
console.log(" No config/sources.yaml found, using built-in default (sanity.io production)");
|
|
110
122
|
return DEFAULT_SOURCE;
|
|
111
123
|
}
|
|
112
124
|
if (!rawFile?.sources || Object.keys(rawFile.sources).length === 0) {
|
|
125
|
+
log.debug("config/sources.yaml is empty, falling back to built-in default");
|
|
113
126
|
console.log(" config/sources.yaml is empty, using built-in default");
|
|
114
127
|
return DEFAULT_SOURCE;
|
|
115
128
|
}
|
|
@@ -117,6 +130,11 @@ export function loadSource(name, overrides) {
|
|
|
117
130
|
const sourceName =
|
|
118
131
|
// oxlint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- empty strings should fall through to next candidate
|
|
119
132
|
name || process.env.DOC_SOURCE || Object.keys(rawFile.sources)[0];
|
|
133
|
+
log.debug("Resolving source from config/sources.yaml", {
|
|
134
|
+
requestedName: name,
|
|
135
|
+
resolvedName: sourceName,
|
|
136
|
+
availableSources: Object.keys(rawFile.sources),
|
|
137
|
+
});
|
|
120
138
|
const rawEntry = rawFile.sources[sourceName];
|
|
121
139
|
if (!rawEntry) {
|
|
122
140
|
const available = Object.keys(rawFile.sources).join(", ");
|
|
@@ -133,6 +151,15 @@ export function loadSource(name, overrides) {
|
|
|
133
151
|
// An interpolation like ${{ DOC_ALLOWED_ORIGIN | }} resolves to "",
|
|
134
152
|
// Which would produce [""] — matching nothing and silently blocking all origins.
|
|
135
153
|
const filteredOrigins = resolved.allowedOrigins?.filter(Boolean);
|
|
154
|
+
log.debug("Source resolved from config/sources.yaml", {
|
|
155
|
+
name: sourceName,
|
|
156
|
+
baseUrl: resolved.baseUrl,
|
|
157
|
+
dataset: resolved.dataset,
|
|
158
|
+
projectId: resolved.projectId,
|
|
159
|
+
hasOverrides: Boolean(overrides),
|
|
160
|
+
hasAllowedOrigins: Boolean(filteredOrigins?.length),
|
|
161
|
+
hasPerspective: Boolean(overrides?.perspective ?? process.env.SANITY_PERSPECTIVE),
|
|
162
|
+
});
|
|
136
163
|
return {
|
|
137
164
|
allowedOrigins: filteredOrigins && filteredOrigins.length > 0
|
|
138
165
|
? filteredOrigins
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ailf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "restricted"
|
|
@@ -23,6 +23,27 @@
|
|
|
23
23
|
"canonical",
|
|
24
24
|
"tasks"
|
|
25
25
|
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@google-cloud/bigquery": "^8.1.1",
|
|
28
|
+
"@inquirer/prompts": "^8.3.0",
|
|
29
|
+
"@portabletext/markdown": "^1.0.0",
|
|
30
|
+
"@sanity/client": "^7.3.0",
|
|
31
|
+
"commander": "^14.0.3",
|
|
32
|
+
"dotenv": "^16.4.7",
|
|
33
|
+
"dotenv-cli": "^11.0.0",
|
|
34
|
+
"js-yaml": "^4.1.0",
|
|
35
|
+
"promptfoo": "^0.120.24",
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"@types/node": "^22.13.1",
|
|
41
|
+
"tsx": "^4.19.2",
|
|
42
|
+
"typescript": "^5.7.3",
|
|
43
|
+
"@sanity/ailf-shared": "0.1.0",
|
|
44
|
+
"@sanity/ailf-tasks": "0.1.4",
|
|
45
|
+
"@sanity/ailf-core": "0.1.0"
|
|
46
|
+
},
|
|
26
47
|
"scripts": {
|
|
27
48
|
"build": "tsc && tsx scripts/bundle-workspace-deps.ts",
|
|
28
49
|
"generate-configs": "tsx src/cli.ts generate-configs",
|
|
@@ -48,26 +69,5 @@
|
|
|
48
69
|
"discovery-report": "tsx src/cli.ts discovery-report",
|
|
49
70
|
"webhook-server": "tsx src/cli.ts webhook-server",
|
|
50
71
|
"weekly-digest": "tsx src/cli.ts weekly-digest"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@google-cloud/bigquery": "^8.1.1",
|
|
54
|
-
"@inquirer/prompts": "^8.3.0",
|
|
55
|
-
"@portabletext/markdown": "^1.0.0",
|
|
56
|
-
"@sanity/client": "^7.3.0",
|
|
57
|
-
"commander": "^14.0.3",
|
|
58
|
-
"dotenv": "^16.4.7",
|
|
59
|
-
"dotenv-cli": "^11.0.0",
|
|
60
|
-
"js-yaml": "^4.1.0",
|
|
61
|
-
"promptfoo": "^0.120.24",
|
|
62
|
-
"zod": "^4.3.6"
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@sanity/ailf-core": "workspace:*",
|
|
66
|
-
"@sanity/ailf-shared": "workspace:*",
|
|
67
|
-
"@sanity/ailf-tasks": "workspace:*",
|
|
68
|
-
"@types/js-yaml": "^4.0.9",
|
|
69
|
-
"@types/node": "^22.13.1",
|
|
70
|
-
"tsx": "^4.19.2",
|
|
71
|
-
"typescript": "^5.7.3"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|