@evalgate/sdk 2.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/CHANGELOG.md +638 -0
- package/README.md +398 -0
- package/dist/assertions.d.ts +189 -0
- package/dist/assertions.js +662 -0
- package/dist/batch.d.ts +68 -0
- package/dist/batch.js +179 -0
- package/dist/cache.d.ts +65 -0
- package/dist/cache.js +131 -0
- package/dist/cli/api.d.ts +108 -0
- package/dist/cli/api.js +132 -0
- package/dist/cli/baseline.d.ts +10 -0
- package/dist/cli/baseline.js +172 -0
- package/dist/cli/check.d.ts +73 -0
- package/dist/cli/check.js +355 -0
- package/dist/cli/ci-context.d.ts +6 -0
- package/dist/cli/ci-context.js +112 -0
- package/dist/cli/ci.d.ts +45 -0
- package/dist/cli/ci.js +192 -0
- package/dist/cli/config.d.ts +30 -0
- package/dist/cli/config.js +230 -0
- package/dist/cli/constants.d.ts +15 -0
- package/dist/cli/constants.js +18 -0
- package/dist/cli/diff.d.ts +173 -0
- package/dist/cli/diff.js +685 -0
- package/dist/cli/discover.d.ts +84 -0
- package/dist/cli/discover.js +419 -0
- package/dist/cli/doctor.d.ts +88 -0
- package/dist/cli/doctor.js +675 -0
- package/dist/cli/env.d.ts +21 -0
- package/dist/cli/env.js +42 -0
- package/dist/cli/explain.d.ts +58 -0
- package/dist/cli/explain.js +561 -0
- package/dist/cli/formatters/github.d.ts +8 -0
- package/dist/cli/formatters/github.js +135 -0
- package/dist/cli/formatters/human.d.ts +6 -0
- package/dist/cli/formatters/human.js +110 -0
- package/dist/cli/formatters/json.d.ts +6 -0
- package/dist/cli/formatters/json.js +10 -0
- package/dist/cli/formatters/pr-comment.d.ts +12 -0
- package/dist/cli/formatters/pr-comment.js +103 -0
- package/dist/cli/formatters/types.d.ts +103 -0
- package/dist/cli/formatters/types.js +8 -0
- package/dist/cli/gate.d.ts +21 -0
- package/dist/cli/gate.js +179 -0
- package/dist/cli/impact-analysis.d.ts +63 -0
- package/dist/cli/impact-analysis.js +252 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +332 -0
- package/dist/cli/init.d.ts +16 -0
- package/dist/cli/init.js +292 -0
- package/dist/cli/manifest.d.ts +103 -0
- package/dist/cli/manifest.js +282 -0
- package/dist/cli/migrate.d.ts +41 -0
- package/dist/cli/migrate.js +349 -0
- package/dist/cli/policy-packs.d.ts +23 -0
- package/dist/cli/policy-packs.js +89 -0
- package/dist/cli/print-config.d.ts +29 -0
- package/dist/cli/print-config.js +270 -0
- package/dist/cli/profiles.d.ts +28 -0
- package/dist/cli/profiles.js +30 -0
- package/dist/cli/reason-codes.d.ts +17 -0
- package/dist/cli/reason-codes.js +19 -0
- package/dist/cli/regression-gate.d.ts +15 -0
- package/dist/cli/regression-gate.js +341 -0
- package/dist/cli/render/snippet.d.ts +5 -0
- package/dist/cli/render/snippet.js +15 -0
- package/dist/cli/render/sort.d.ts +10 -0
- package/dist/cli/render/sort.js +24 -0
- package/dist/cli/report/build-check-report.d.ts +19 -0
- package/dist/cli/report/build-check-report.js +132 -0
- package/dist/cli/run.d.ts +101 -0
- package/dist/cli/run.js +395 -0
- package/dist/cli/share.d.ts +17 -0
- package/dist/cli/share.js +91 -0
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +492 -0
- package/dist/cli/workspace.d.ts +31 -0
- package/dist/cli/workspace.js +68 -0
- package/dist/client.d.ts +368 -0
- package/dist/client.js +893 -0
- package/dist/client.request.test.d.ts +1 -0
- package/dist/client.request.test.js +232 -0
- package/dist/context.d.ts +134 -0
- package/dist/context.js +215 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.js +298 -0
- package/dist/export.d.ts +195 -0
- package/dist/export.js +344 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +153 -0
- package/dist/integrations/anthropic.d.ts +91 -0
- package/dist/integrations/anthropic.js +163 -0
- package/dist/integrations/openai-eval.d.ts +57 -0
- package/dist/integrations/openai-eval.js +232 -0
- package/dist/integrations/openai.d.ts +92 -0
- package/dist/integrations/openai.js +160 -0
- package/dist/local.d.ts +39 -0
- package/dist/local.js +148 -0
- package/dist/logger.d.ts +128 -0
- package/dist/logger.js +227 -0
- package/dist/matchers/index.d.ts +1 -0
- package/dist/matchers/index.js +6 -0
- package/dist/matchers/to-pass-gate.d.ts +29 -0
- package/dist/matchers/to-pass-gate.js +35 -0
- package/dist/pagination.d.ts +74 -0
- package/dist/pagination.js +139 -0
- package/dist/regression.d.ts +100 -0
- package/dist/regression.js +44 -0
- package/dist/runtime/adapters/config-to-dsl.d.ts +33 -0
- package/dist/runtime/adapters/config-to-dsl.js +400 -0
- package/dist/runtime/adapters/testsuite-to-dsl.d.ts +63 -0
- package/dist/runtime/adapters/testsuite-to-dsl.js +276 -0
- package/dist/runtime/context.d.ts +26 -0
- package/dist/runtime/context.js +74 -0
- package/dist/runtime/eval.d.ts +46 -0
- package/dist/runtime/eval.js +244 -0
- package/dist/runtime/execution-mode.d.ts +80 -0
- package/dist/runtime/execution-mode.js +357 -0
- package/dist/runtime/executor.d.ts +16 -0
- package/dist/runtime/executor.js +152 -0
- package/dist/runtime/registry.d.ts +78 -0
- package/dist/runtime/registry.js +403 -0
- package/dist/runtime/run-report.d.ts +200 -0
- package/dist/runtime/run-report.js +222 -0
- package/dist/runtime/types.d.ts +356 -0
- package/dist/runtime/types.js +76 -0
- package/dist/snapshot.d.ts +176 -0
- package/dist/snapshot.js +322 -0
- package/dist/streaming.d.ts +173 -0
- package/dist/streaming.js +268 -0
- package/dist/testing.d.ts +273 -0
- package/dist/testing.js +317 -0
- package/dist/types.d.ts +754 -0
- package/dist/types.js +54 -0
- package/dist/utils/input-hash.d.ts +8 -0
- package/dist/utils/input-hash.js +41 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +10 -0
- package/dist/workflows.d.ts +389 -0
- package/dist/workflows.js +671 -0
- package/package.json +117 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* COMPAT-203: Config → DSL migration generator (file-based)
|
|
4
|
+
*
|
|
5
|
+
* CLI command: evalgate migrate config --in evalgate.config.json --out eval/legacy.spec.ts
|
|
6
|
+
* Generates defineEval() calls with comments and TODOs for manual completion
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.migrateConfig = migrateConfig;
|
|
43
|
+
exports.createMigrateCommand = createMigrateCommand;
|
|
44
|
+
exports.validateConfigFile = validateConfigFile;
|
|
45
|
+
exports.previewMigration = previewMigration;
|
|
46
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const commander_1 = require("commander");
|
|
49
|
+
const testsuite_to_dsl_1 = require("../runtime/adapters/testsuite-to-dsl");
|
|
50
|
+
const testing_1 = require("../testing");
|
|
51
|
+
/**
|
|
52
|
+
* Read and parse evalgate.config.json (or evalai.config.json)
|
|
53
|
+
*/
|
|
54
|
+
async function readConfigFile(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
57
|
+
return JSON.parse(content);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new Error(`Failed to read config file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Extract TestSuite data from config
|
|
65
|
+
*/
|
|
66
|
+
function extractTestSuitesFromConfig(config) {
|
|
67
|
+
const suites = [];
|
|
68
|
+
// Handle different config structures
|
|
69
|
+
if (config.tests) {
|
|
70
|
+
// Direct tests array
|
|
71
|
+
const suite = (0, testing_1.createTestSuite)("config-tests", {
|
|
72
|
+
cases: config.tests,
|
|
73
|
+
executor: config.executor,
|
|
74
|
+
timeout: config.timeout,
|
|
75
|
+
parallel: config.parallel,
|
|
76
|
+
stopOnFailure: config.stopOnFailure,
|
|
77
|
+
retries: config.retries,
|
|
78
|
+
});
|
|
79
|
+
suites.push({ name: "config-tests", suite });
|
|
80
|
+
}
|
|
81
|
+
if (config.suites) {
|
|
82
|
+
// Multiple named suites
|
|
83
|
+
for (const [suiteName, suiteConfig] of Object.entries(config.suites)) {
|
|
84
|
+
const suite = (0, testing_1.createTestSuite)(suiteName, suiteConfig);
|
|
85
|
+
suites.push({ name: suiteName, suite });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (config.testSuites) {
|
|
89
|
+
// Alternative property name
|
|
90
|
+
for (const [suiteName, suiteConfig] of Object.entries(config.testSuites)) {
|
|
91
|
+
const suite = (0, testing_1.createTestSuite)(suiteName, suiteConfig);
|
|
92
|
+
suites.push({ name: suiteName, suite });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return suites;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate DSL file header
|
|
99
|
+
*/
|
|
100
|
+
function generateFileHeader(_config, options) {
|
|
101
|
+
const timestamp = new Date().toISOString();
|
|
102
|
+
const inputPath = path.resolve(options.input);
|
|
103
|
+
const outputPath = path.resolve(options.output);
|
|
104
|
+
return [
|
|
105
|
+
`/**`,
|
|
106
|
+
` * Auto-generated EvalGate DSL from configuration`,
|
|
107
|
+
` * `,
|
|
108
|
+
` * Generated at: ${timestamp}`,
|
|
109
|
+
` * Source config: ${inputPath}`,
|
|
110
|
+
` * Output file: ${outputPath}`,
|
|
111
|
+
` * `,
|
|
112
|
+
` * This file contains defineEval() specifications migrated from evalgate.config.json`,
|
|
113
|
+
` * `,
|
|
114
|
+
` * ⚠️ IMPORTANT: This is a best-effort migration. Manual review and completion required.`,
|
|
115
|
+
` * `,
|
|
116
|
+
` * Migration notes:`,
|
|
117
|
+
` * - Executors have been converted to async functions`,
|
|
118
|
+
` * - Assertions have been converted where possible`,
|
|
119
|
+
` * - Complex logic may need manual adaptation`,
|
|
120
|
+
` * - Review TODO comments for items requiring attention`,
|
|
121
|
+
` */`,
|
|
122
|
+
``,
|
|
123
|
+
`import { defineEval, createResult } from '@evalgate/sdk';`,
|
|
124
|
+
``,
|
|
125
|
+
].join("\n");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Generate helper functions for the entire file
|
|
129
|
+
*/
|
|
130
|
+
function generateGlobalHelpers(config, _options) {
|
|
131
|
+
const helpers = [];
|
|
132
|
+
// Add executor helper if config has executor
|
|
133
|
+
if (config.executor) {
|
|
134
|
+
helpers.push([
|
|
135
|
+
`/**`,
|
|
136
|
+
` * Legacy executor function from config`,
|
|
137
|
+
` * TODO: Replace with actual executor implementation`,
|
|
138
|
+
` */`,
|
|
139
|
+
`async function legacyExecutor(input: string): Promise<string> {`,
|
|
140
|
+
` // Original executor was: ${config.executor.toString()}`,
|
|
141
|
+
` // TODO: Implement actual executor logic here`,
|
|
142
|
+
` return input; // Placeholder`,
|
|
143
|
+
`}`,
|
|
144
|
+
``,
|
|
145
|
+
].join("\n"));
|
|
146
|
+
}
|
|
147
|
+
// Add assertion helpers
|
|
148
|
+
helpers.push([
|
|
149
|
+
`/**`,
|
|
150
|
+
` * Helper function for legacy assertion evaluation`,
|
|
151
|
+
` * TODO: Implement actual assertion logic based on original config`,
|
|
152
|
+
` */`,
|
|
153
|
+
`function evaluateAssertions(output: string, expected?: string): boolean {`,
|
|
154
|
+
` if (expected !== undefined) {`,
|
|
155
|
+
` return output === expected;`,
|
|
156
|
+
` }`,
|
|
157
|
+
` return output.length > 0;`,
|
|
158
|
+
`}`,
|
|
159
|
+
``,
|
|
160
|
+
].join("\n"));
|
|
161
|
+
// Add evaluation helper
|
|
162
|
+
helpers.push([
|
|
163
|
+
`/**`,
|
|
164
|
+
` * Legacy test evaluation function`,
|
|
165
|
+
` * TODO: Adapt based on your original test logic`,
|
|
166
|
+
` */`,
|
|
167
|
+
`async function evaluateLegacyTest(input: string, expected?: string): Promise<unknown> {`,
|
|
168
|
+
` const output = await legacyExecutor(input);`,
|
|
169
|
+
` const passed = evaluateAssertions(output, expected);`,
|
|
170
|
+
` `,
|
|
171
|
+
` return createResult({`,
|
|
172
|
+
` pass: passed,`,
|
|
173
|
+
` score: passed ? 100 : 0,`,
|
|
174
|
+
` metadata: { input, expected },`,
|
|
175
|
+
` });`,
|
|
176
|
+
`}`,
|
|
177
|
+
``,
|
|
178
|
+
].join("\n"));
|
|
179
|
+
return helpers.join("\n");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Generate DSL content for a single suite
|
|
183
|
+
*/
|
|
184
|
+
function generateSuiteDSL(suiteName, suite, options) {
|
|
185
|
+
const dslCode = (0, testsuite_to_dsl_1.generateDefineEvalCode)(suite, {
|
|
186
|
+
generateHelpers: options.helpers,
|
|
187
|
+
preserveIds: options.preserveIds,
|
|
188
|
+
includeProvenance: options.provenance,
|
|
189
|
+
});
|
|
190
|
+
// Add suite-specific comments
|
|
191
|
+
const header = [
|
|
192
|
+
`/**`,
|
|
193
|
+
` * Test suite: ${suiteName}`,
|
|
194
|
+
` * Migrated from evalgate.config.json`,
|
|
195
|
+
` * `,
|
|
196
|
+
` * TODO items for this suite:`,
|
|
197
|
+
` * - Review executor implementation`,
|
|
198
|
+
` * - Verify assertion logic`,
|
|
199
|
+
` * - Test with actual data`,
|
|
200
|
+
` */`,
|
|
201
|
+
``,
|
|
202
|
+
].join("\n");
|
|
203
|
+
return header + dslCode;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Generate migration summary
|
|
207
|
+
*/
|
|
208
|
+
function generateSummary(suites, options) {
|
|
209
|
+
const totalTests = suites.reduce((sum, { suite }) => sum + suite.getTests().length, 0);
|
|
210
|
+
const totalSuites = suites.length;
|
|
211
|
+
return [
|
|
212
|
+
`/**`,
|
|
213
|
+
` * Migration Summary`,
|
|
214
|
+
` * =================`,
|
|
215
|
+
` * `,
|
|
216
|
+
` * Total suites migrated: ${totalSuites}`,
|
|
217
|
+
` * Total tests migrated: ${totalTests}`,
|
|
218
|
+
` * `,
|
|
219
|
+
` * Migration options used:`,
|
|
220
|
+
` * - Include helpers: ${options.helpers}`,
|
|
221
|
+
` * - Preserve IDs: ${options.preserveIds}`,
|
|
222
|
+
` * - Include provenance: ${options.provenance}`,
|
|
223
|
+
` * `,
|
|
224
|
+
` * Next steps:`,
|
|
225
|
+
` * 1. Review all TODO comments in this file`,
|
|
226
|
+
` * 2. Implement actual executor logic`,
|
|
227
|
+
` * 3. Adapt complex assertions`,
|
|
228
|
+
` * 4. Test with real data`,
|
|
229
|
+
` * 5. Remove evalgate.config.json when satisfied`,
|
|
230
|
+
` * `,
|
|
231
|
+
` * For help with migration, see: https://github.com/pauly7610/ai-evaluation-platform/docs/MIGRATION.md`,
|
|
232
|
+
` */`,
|
|
233
|
+
``,
|
|
234
|
+
].join("\n");
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Main migration function
|
|
238
|
+
*/
|
|
239
|
+
async function migrateConfig(options) {
|
|
240
|
+
try {
|
|
241
|
+
// Read input config
|
|
242
|
+
const config = await readConfigFile(options.input);
|
|
243
|
+
// Extract test suites
|
|
244
|
+
const suites = extractTestSuitesFromConfig(config);
|
|
245
|
+
if (suites.length === 0) {
|
|
246
|
+
throw new Error("No test suites found in config file. Check config structure.");
|
|
247
|
+
}
|
|
248
|
+
// Generate DSL content
|
|
249
|
+
const content = [
|
|
250
|
+
generateFileHeader(config, options),
|
|
251
|
+
generateGlobalHelpers(config, options),
|
|
252
|
+
...suites.map(({ name, suite }) => generateSuiteDSL(name, suite, options)),
|
|
253
|
+
generateSummary(suites, options),
|
|
254
|
+
].join("\n");
|
|
255
|
+
// Ensure output directory exists
|
|
256
|
+
const outputDir = path.dirname(options.output);
|
|
257
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
258
|
+
// Write output file
|
|
259
|
+
await fs.writeFile(options.output, content, "utf-8");
|
|
260
|
+
console.log(`✅ Migration complete!`);
|
|
261
|
+
console.log(`📁 Output written to: ${path.resolve(options.output)}`);
|
|
262
|
+
console.log(`📊 Migrated ${suites.length} suites with ${suites.reduce((sum, { suite }) => sum + suite.getTests().length, 0)} tests`);
|
|
263
|
+
console.log(`\n⚠️ Remember to review TODO comments and test the migration!`);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error(`❌ Migration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* CLI command definition
|
|
272
|
+
*/
|
|
273
|
+
function createMigrateCommand() {
|
|
274
|
+
const command = new commander_1.Command("migrate")
|
|
275
|
+
.description("Migrate legacy configuration to new DSL format")
|
|
276
|
+
.command("config")
|
|
277
|
+
.description("Migrate evalgate.config.json to defineEval() specifications")
|
|
278
|
+
.requiredOption("-i, --in <path>", "Input config file path")
|
|
279
|
+
.requiredOption("-o, --out <path>", "Output DSL file path")
|
|
280
|
+
.option("-v, --verbose", "Include detailed comments and logging", false)
|
|
281
|
+
.option("--no-helpers", "Don't generate helper functions")
|
|
282
|
+
.option("--no-preserve-ids", "Don't preserve original test IDs")
|
|
283
|
+
.option("--no-provenance", "Don't include provenance metadata")
|
|
284
|
+
.action(async (options) => {
|
|
285
|
+
const migrateOptions = {
|
|
286
|
+
input: options.in,
|
|
287
|
+
output: options.out,
|
|
288
|
+
verbose: options.verbose,
|
|
289
|
+
helpers: options.helpers !== false,
|
|
290
|
+
preserveIds: options.preserveIds !== false,
|
|
291
|
+
provenance: options.provenance !== false,
|
|
292
|
+
};
|
|
293
|
+
await migrateConfig(migrateOptions);
|
|
294
|
+
});
|
|
295
|
+
return command;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Validate config file structure
|
|
299
|
+
*/
|
|
300
|
+
async function validateConfigFile(filePath) {
|
|
301
|
+
try {
|
|
302
|
+
const config = await readConfigFile(filePath);
|
|
303
|
+
// Basic validation
|
|
304
|
+
if (!config || typeof config !== "object") {
|
|
305
|
+
throw new Error("Config file must contain a valid JSON object");
|
|
306
|
+
}
|
|
307
|
+
// Check for test data
|
|
308
|
+
const hasTests = config.tests || config.suites || config.testSuites;
|
|
309
|
+
if (!hasTests) {
|
|
310
|
+
throw new Error("Config file must contain 'tests', 'suites', or 'testSuites' property");
|
|
311
|
+
}
|
|
312
|
+
console.log(`✅ Config file ${filePath} appears valid for migration`);
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
console.error(`❌ Config validation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Show migration preview without writing files
|
|
322
|
+
*/
|
|
323
|
+
async function previewMigration(filePath) {
|
|
324
|
+
try {
|
|
325
|
+
const config = await readConfigFile(filePath);
|
|
326
|
+
const suites = extractTestSuitesFromConfig(config);
|
|
327
|
+
console.log(`📋 Migration preview for: ${filePath}`);
|
|
328
|
+
console.log(``);
|
|
329
|
+
console.log(`Found ${suites.length} test suites:`);
|
|
330
|
+
console.log(``);
|
|
331
|
+
for (const { name, suite } of suites) {
|
|
332
|
+
const tests = suite.getTests();
|
|
333
|
+
console.log(` 📁 ${name}: ${tests.length} tests`);
|
|
334
|
+
if (tests.length > 0) {
|
|
335
|
+
console.log(` Tests: ${tests
|
|
336
|
+
.slice(0, 3)
|
|
337
|
+
.map((t) => t.id)
|
|
338
|
+
.join(", ")}${tests.length > 3 ? "..." : ""}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
console.log(``);
|
|
342
|
+
console.log(`Total tests to migrate: ${suites.reduce((sum, { suite }) => sum + suite.getTests().length, 0)}`);
|
|
343
|
+
console.log(``);
|
|
344
|
+
console.log(`To migrate, run: evalgate migrate config --in ${filePath} --out eval/migrated.spec.ts`);
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
console.error(`❌ Preview failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned policy packs for evalgate check --policy.
|
|
3
|
+
* Schema: policyId, version, thresholds, rationale, checks.
|
|
4
|
+
* Usage: --policy HIPAA@1
|
|
5
|
+
*/
|
|
6
|
+
export type PolicyPack = {
|
|
7
|
+
policyId: string;
|
|
8
|
+
version: number;
|
|
9
|
+
thresholds: {
|
|
10
|
+
requiredSafetyRate: number;
|
|
11
|
+
maxFlags: string[];
|
|
12
|
+
};
|
|
13
|
+
rationale: string;
|
|
14
|
+
checks: string[];
|
|
15
|
+
};
|
|
16
|
+
export declare const POLICY_PACKS: Record<string, Record<number, PolicyPack>>;
|
|
17
|
+
/**
|
|
18
|
+
* Parse --policy flag (e.g. "HIPAA@1" or "HIPAA") and resolve to PolicyPack.
|
|
19
|
+
* Default version is 1 when omitted.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolvePolicyPack(spec: string): PolicyPack | null;
|
|
22
|
+
/** List valid policy@version specs for error messages */
|
|
23
|
+
export declare function getValidPolicyVersions(): string[];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Versioned policy packs for evalgate check --policy.
|
|
4
|
+
* Schema: policyId, version, thresholds, rationale, checks.
|
|
5
|
+
* Usage: --policy HIPAA@1
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.POLICY_PACKS = void 0;
|
|
9
|
+
exports.resolvePolicyPack = resolvePolicyPack;
|
|
10
|
+
exports.getValidPolicyVersions = getValidPolicyVersions;
|
|
11
|
+
exports.POLICY_PACKS = {
|
|
12
|
+
HIPAA: {
|
|
13
|
+
1: {
|
|
14
|
+
policyId: "HIPAA",
|
|
15
|
+
version: 1,
|
|
16
|
+
thresholds: { requiredSafetyRate: 0.99, maxFlags: ["SAFETY_RISK"] },
|
|
17
|
+
rationale: "HIPAA requires high safety and no safety risks for PHI handling.",
|
|
18
|
+
checks: ["safety_rate", "no_safety_flags"],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
SOC2: {
|
|
22
|
+
1: {
|
|
23
|
+
policyId: "SOC2",
|
|
24
|
+
version: 1,
|
|
25
|
+
thresholds: {
|
|
26
|
+
requiredSafetyRate: 0.95,
|
|
27
|
+
maxFlags: ["SAFETY_RISK", "LOW_PASS_RATE"],
|
|
28
|
+
},
|
|
29
|
+
rationale: "SOC2 trust criteria for security and availability.",
|
|
30
|
+
checks: ["safety_rate", "flag_restrictions"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
GDPR: {
|
|
34
|
+
1: {
|
|
35
|
+
policyId: "GDPR",
|
|
36
|
+
version: 1,
|
|
37
|
+
thresholds: { requiredSafetyRate: 0.95, maxFlags: ["SAFETY_RISK"] },
|
|
38
|
+
rationale: "GDPR data protection and privacy requirements.",
|
|
39
|
+
checks: ["safety_rate", "no_safety_flags"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
PCI_DSS: {
|
|
43
|
+
1: {
|
|
44
|
+
policyId: "PCI_DSS",
|
|
45
|
+
version: 1,
|
|
46
|
+
thresholds: {
|
|
47
|
+
requiredSafetyRate: 0.99,
|
|
48
|
+
maxFlags: ["SAFETY_RISK", "LOW_PASS_RATE"],
|
|
49
|
+
},
|
|
50
|
+
rationale: "PCI DSS cardholder data security standards.",
|
|
51
|
+
checks: ["safety_rate", "flag_restrictions"],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
FINRA_4511: {
|
|
55
|
+
1: {
|
|
56
|
+
policyId: "FINRA_4511",
|
|
57
|
+
version: 1,
|
|
58
|
+
thresholds: { requiredSafetyRate: 0.95, maxFlags: ["SAFETY_RISK"] },
|
|
59
|
+
rationale: "FINRA 4511 supervisory control requirements.",
|
|
60
|
+
checks: ["safety_rate", "no_safety_flags"],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Parse --policy flag (e.g. "HIPAA@1" or "HIPAA") and resolve to PolicyPack.
|
|
66
|
+
* Default version is 1 when omitted.
|
|
67
|
+
*/
|
|
68
|
+
function resolvePolicyPack(spec) {
|
|
69
|
+
const at = spec.indexOf("@");
|
|
70
|
+
const policyId = (at >= 0 ? spec.slice(0, at) : spec).toUpperCase();
|
|
71
|
+
const version = at >= 0 ? parseInt(spec.slice(at + 1), 10) : 1;
|
|
72
|
+
if (Number.isNaN(version) || version < 1)
|
|
73
|
+
return null;
|
|
74
|
+
const versions = exports.POLICY_PACKS[policyId];
|
|
75
|
+
if (!versions)
|
|
76
|
+
return null;
|
|
77
|
+
const pack = versions[version];
|
|
78
|
+
return pack ?? null;
|
|
79
|
+
}
|
|
80
|
+
/** List valid policy@version specs for error messages */
|
|
81
|
+
function getValidPolicyVersions() {
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const [policyId, versions] of Object.entries(exports.POLICY_PACKS)) {
|
|
84
|
+
for (const v of Object.keys(versions)) {
|
|
85
|
+
out.push(`${policyId}@${v}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out.sort();
|
|
89
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evalgate print-config — Show resolved configuration with source-of-truth annotations.
|
|
3
|
+
*
|
|
4
|
+
* Prints every config field, where it came from (file, env, default, CLI arg),
|
|
5
|
+
* and redacts secrets. Useful for debugging "why is it using this baseUrl?"
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* evalgate print-config
|
|
9
|
+
* evalgate print-config --format json
|
|
10
|
+
*
|
|
11
|
+
* Exit codes:
|
|
12
|
+
* 0 — Always (informational only)
|
|
13
|
+
*/
|
|
14
|
+
type Source = "file" | "env" | "default" | "profile" | "arg";
|
|
15
|
+
interface ResolvedField {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string | number | boolean | null;
|
|
18
|
+
source: Source;
|
|
19
|
+
raw?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PrintConfigOutput {
|
|
22
|
+
cliVersion: string;
|
|
23
|
+
configFile: string | null;
|
|
24
|
+
cwd: string;
|
|
25
|
+
resolved: ResolvedField[];
|
|
26
|
+
env: Record<string, string | null>;
|
|
27
|
+
}
|
|
28
|
+
export declare function runPrintConfig(argv: string[]): number;
|
|
29
|
+
export {};
|