async function handler(ctx) {
    const { projectPath, allSpecs, specId } = ctx;
    if (!projectPath) {
        return;
    }
    const approvedCount = allSpecs.filter((s) => s.status === 'approved' || s.id === specId).length;
    if (approvedCount >= 2) {
        // Scenario 12: N≥2 approved → resolve orchestration plan
        try {
            const { resolveOrchestrationPlan } = await import('../../../engine/next-spec-resolver/orchestration-planner.js');
            const { writeOrchestrationPlan } = await import('../../../engine/next-spec-resolver/session-writer.js');
            const plan = await resolveOrchestrationPlan(projectPath, allSpecs);
            await writeOrchestrationPlan(projectPath, plan);
        }
        catch {
            /* best-effort — never throw */
        }
    }
    else {
        // Scenario 15: < 2 approved → clear orchestration plan
        try {
            const { writeOrchestrationPlan } = await import('../../../engine/next-spec-resolver/session-writer.js');
            await writeOrchestrationPlan(projectPath, null);
        }
        catch {
            /* best-effort — never throw */
        }
    }
}
export const orchestrationPlanHook = {
    id: 'orchestration-plan',
    triggers: ['approved'],
    requiresProjectPath: true,
    label: 'Auto-generate/clear orchestration plan on approved (SPEC-686, Scenarios 12 & 15)',
    handler,
};
//# sourceMappingURL=orchestration-plan.hook.js.map