import { defineHandler } from '@kb-labs/sdk';
import { calculateStats } from '@kb-labs/quality-core/stats';
import { calculateHealth } from '@kb-labs/quality-core/health';

// src/rest/handlers/stats-handler.ts
var stats_handler_default = defineHandler({
  async execute(ctx, input) {
    const includeHealth = input.query?.includeHealth ?? false;
    const stats = await calculateStats(ctx.cwd);
    let health;
    let grade;
    if (includeHealth) {
      const healthResult = await calculateHealth(ctx.cwd);
      health = healthResult.score;
      grade = healthResult.grade;
    }
    return {
      packages: stats.packages,
      loc: stats.loc,
      size: stats.sizeFormatted,
      health,
      grade
    };
  }
});

export { stats_handler_default as default };
//# sourceMappingURL=stats-handler.js.map
//# sourceMappingURL=stats-handler.js.map