import { defineCommand } from '@kb-labs/sdk';
import { loadHistory, detectRegressions, buildRegressionsReport } from '@kb-labs/qa-core';

// src/cli/commands/qa-regressions.ts
var qa_regressions_default = defineCommand({
  id: "qa:regressions",
  description: "Detect regressions since last QA save",
  handler: {
    async execute(ctx, input) {
      const { ui } = ctx;
      const flags = input.flags ?? input;
      const rootDir = ctx.cwd;
      const history = loadHistory(rootDir);
      const result = detectRegressions(history);
      if (flags.json) {
        ui?.json?.(result);
        return { exitCode: result.hasRegressions ? 1 : 0 };
      }
      const sections = buildRegressionsReport(result, history);
      for (const section of sections) {
        ui?.success?.(section.header, {
          title: section.header,
          sections: [{ header: "", items: section.lines }]
        });
      }
      return { exitCode: result.hasRegressions ? 1 : 0 };
    }
  }
});

export { qa_regressions_default as default };
//# sourceMappingURL=qa-regressions.js.map
//# sourceMappingURL=qa-regressions.js.map