import { defineHandler } from '@kb-labs/sdk';
import { loadPlan } from '@kb-labs/commit-core/storage';

// src/rest/handlers/plan-handler.ts
var plan_handler_default = defineHandler({
  async execute(ctx, input) {
    const scope = input.query?.scope || "root";
    try {
      const plan = await loadPlan(ctx.cwd, scope);
      if (!plan || plan.commits.length === 0) {
        return {
          hasPlan: false,
          scope
        };
      }
      return {
        hasPlan: true,
        plan,
        scope
      };
    } catch (error) {
      return {
        hasPlan: false,
        scope
      };
    }
  }
});

export { plan_handler_default as default };
//# sourceMappingURL=plan-handler.js.map
//# sourceMappingURL=plan-handler.js.map