import {
parseContractFromYaml,
parseEvalFile,
evaluate,
formatDecision,
validateContract,
} from "@geval-labs/core";
import { readFileSync } from "fs";
// 1. Load and parse contract
const contractYaml = readFileSync("contract.yaml", "utf-8");
const contract = parseContractFromYaml(contractYaml);
// 2. Validate contract
const errors = validateContract(contract);
if (errors.length > 0) {
throw new Error(`Contract validation failed: ${errors.map(e => e.message).join(", ")}`);
}
// 3. Parse eval results
const csvContent = readFileSync("results.csv", "utf-8");
const evalResult = parseEvalFile(csvContent, "results.csv", contract);
// 4. Evaluate
const decision = evaluate({
contract,
evalResults: [evalResult],
baselines: {},
});
// 5. Format and display
console.log(formatDecision(decision, { colors: true, verbose: true }));
// 6. Use in CI
if (decision.status === "PASS") {
console.log("✅ Safe to deploy!");
process.exit(0);
} else {
console.log("❌ Deployment blocked");
process.exit(1);
}