import { emitAutopilotEvent } from '../../autopilot/event-bus.js';
// eslint-disable-next-line @typescript-eslint/require-await
async function handler(ctx) {
    const { projectPath, specId, projectId, spec, newStatus } = ctx;
    if (!projectPath) {
        return;
    }
    const autopilotEventName = newStatus === 'approved'
        ? 'spec:status:approved'
        : newStatus === 'implementing'
            ? 'spec:status:implementing'
            : newStatus === 'review'
                ? 'spec:status:review'
                : newStatus === 'done'
                    ? 'spec:status:done'
                    : null;
    if (autopilotEventName) {
        emitAutopilotEvent({
            name: autopilotEventName,
            specId,
            projectPath,
            projectId,
            payload: { estimatedHours: spec.estimation.devHours, risk: spec.risk },
        });
    }
}
export const autopilotEventsHook = {
    id: 'autopilot-events',
    triggers: ['approved', 'implementing', 'review', 'done'],
    requiresProjectPath: true,
    label: 'Emit autopilot lifecycle events (SPEC-413)',
    handler,
};
//# sourceMappingURL=autopilot-events.hook.js.map