// engine/telemetry/stance.ts — Telemetry opt-in stance reader (SPEC-741)
import { readFileSync, existsSync } from 'node:fs';
import { join } from 'node:path';
/**
 * Returns true if telemetry is enabled for the given project root.
 * Reads conventions.json synchronously.
 * Default stance: DISABLED (opt-in per SPEC-741).
 */
export function isTelemetryEnabled(projectRoot) {
    if (process.env.PLANU_TELEMETRY === 'off') {
        return false;
    }
    if (process.env.PLANU_TELEMETRY === 'on') {
        return true;
    }
    try {
        const conventionsPath = join(projectRoot, 'planu', 'conventions.json');
        if (!existsSync(conventionsPath)) {
            return false;
        }
        const raw = readFileSync(conventionsPath, 'utf-8');
        const parsed = JSON.parse(raw);
        const telemetry = parsed.telemetry;
        return telemetry?.enabled === true;
    }
    catch {
        return false;
    }
}
//# sourceMappingURL=stance.js.map