import { fireCompleteLoopActions } from '../../autopilot/complete-loop.js';
import { loadAutopilotConfig } from '../../autopilot/action-executor.js';
async function handler(ctx) {
    const { projectPath, projectId, specId, newStatus, validateScore } = ctx;
    if (!projectPath) {
        return;
    }
    try {
        const config = await loadAutopilotConfig(projectPath);
        fireCompleteLoopActions({
            projectPath,
            projectId,
            specId,
            newStatus,
            validateScore,
            config,
        });
    }
    catch (err) {
        /* v8 ignore start */
        const msg = err instanceof Error ? err.message : String(err);
        console.error(`[planu] complete-loop autopilot failed: ${msg}`);
        /* v8 ignore stop */
    }
}
export const completeLoopHook = {
    id: 'complete-loop',
    triggers: ['approved', 'done'],
    requiresProjectPath: true,
    label: 'Complete-loop autopilot — auto-branch/auto-TDD on approved, auto-PR on done (SPEC-569)',
    handler,
};
//# sourceMappingURL=complete-loop.hook.js.map