/**
 * Notify command — sends a notification event via configured webhooks.
 * Designed for bash script integration.
 */
import { basename } from 'path';
import { NOTIFICATION_EVENTS, loadConfig, sendNotifications } from '@night-watch/core';
export function notifyCommand(program) {
    program
        .command('notify <event> <projectDir>')
        .description('Send a notification event via configured webhooks')
        .option('--prd <name>', 'PRD name')
        .option('--branch <name>', 'Branch name')
        .option('--provider <name>', 'Provider name')
        .option('--exit-code <n>', 'Exit code', '0')
        .option('--pr-number <n>', 'PR number')
        .action(async (event, projectDir, options) => {
        if (!NOTIFICATION_EVENTS.includes(event)) {
            process.stderr.write(`Invalid event: ${event}. Must be one of: ${NOTIFICATION_EVENTS.join(', ')}\n`);
            process.exit(2);
        }
        const config = loadConfig(projectDir);
        await sendNotifications(config, {
            event: event,
            projectName: basename(projectDir),
            prdName: options.prd,
            branchName: options.branch,
            provider: options.provider ?? config.provider,
            exitCode: parseInt(options.exitCode, 10) || 0,
            prNumber: options.prNumber ? parseInt(options.prNumber, 10) : undefined,
        });
    });
}
//# sourceMappingURL=notify.js.map