import { defineCommand } from '@kb-labs/sdk';
import { loadHistory, analyzeTrends, analyzeEnrichedTrends, buildTrendsReport } from '@kb-labs/qa-core';

// src/cli/commands/qa-trends.ts
var qa_trends_default = defineCommand({
  id: "qa:trends",
  description: "Show QA quality trends over time",
  handler: {
    async execute(ctx, input) {
      const { ui } = ctx;
      const flags = input.flags ?? input;
      const rootDir = ctx.cwd;
      const history = loadHistory(rootDir);
      const window = typeof flags.window === "number" ? flags.window : 10;
      const trends = analyzeTrends(history, window);
      if (flags.json) {
        const enrichedTrends = analyzeEnrichedTrends(history, window);
        ui?.json?.({ trends: enrichedTrends, historyCount: history.length, window });
        return { exitCode: 0 };
      }
      const sections = buildTrendsReport(trends, history);
      for (const section of sections) {
        ui?.success?.(section.header, {
          title: section.header,
          sections: [{ header: "", items: section.lines }]
        });
      }
      return { exitCode: 0 };
    }
  }
});

export { qa_trends_default as default };
//# sourceMappingURL=qa-trends.js.map
//# sourceMappingURL=qa-trends.js.map