import { defineHandler } from '@kb-labs/sdk';
import { loadLastRun, createBaselineFromResults, saveBaseline } from '@kb-labs/qa-core';

// src/rest/handlers/baseline-update-handler.ts
var baseline_update_handler_default = defineHandler({
  async execute(ctx, _input) {
    const rootDir = ctx.cwd;
    const lastRun = loadLastRun(rootDir);
    if (!lastRun) {
      throw new Error("No last run data available. Run QA first (POST /run).");
    }
    const baseline = createBaselineFromResults(lastRun.results, rootDir);
    saveBaseline(rootDir, baseline);
    return {
      success: true,
      baseline
    };
  }
});

export { baseline_update_handler_default as default };
//# sourceMappingURL=baseline-update-handler.js.map
//# sourceMappingURL=baseline-update-handler.js.map