import { execSync } from 'child_process';
import { existsSync, unlinkSync } from 'fs';
import { homedir } from 'os';
import { join } from 'path';
const LABEL = 'com.cursorconnect.service';
const LAUNCH_AGENT = join(homedir(), 'Library', 'LaunchAgents', `${LABEL}.plist`);
/** Снять launchd автозапуск (устарел; вызывается при cursorconnect start). */
export function uninstallLegacyAutostart() {
    if (!existsSync(LAUNCH_AGENT))
        return;
    try {
        execSync(`launchctl bootout gui/$(id -u) "${LAUNCH_AGENT}" 2>/dev/null || true`, {
            stdio: 'ignore',
            shell: '/bin/bash',
        });
    }
    catch {
        /* ignore */
    }
    try {
        unlinkSync(LAUNCH_AGENT);
        console.log('[cursorconnect] Removed legacy login autostart (launchd).');
    }
    catch {
        /* ignore */
    }
}
