/**
 * Fast detection of whether PLERI is configured for this olam install.
 *
 * Used by `olam --help` to decide whether to show or hide the `crystallize`
 * command (Phase A's A3 task — hide enterprise-flavoured commands from the
 * fresh-install discovery surface).
 *
 * Detection is intentionally cheap (no full config load):
 *   - env var: `PLERI_BASE_URL` set → configured.
 *   - config file: `.olam/config.yaml` (or `OLAM_CONFIG_DIR/config.yaml`)
 *     contains a top-level `pleri:` line → configured.
 *
 * Cost: O(1) env lookup + at most one stat + one small file read. Stays
 * well within the ≤200ms CLI startup budget (P3).
 *
 * The detection is "false negatives are fine" (worst case: an operator
 * with a misconfigured pleri block sees crystallize hidden from help —
 * the command itself still works, since the runtime gate in crystallize.ts
 * does the real check).
 */
import * as fs from 'node:fs';
import * as path from 'node:path';
export function isPleriConfigured(configDir = process.env.OLAM_CONFIG_DIR ?? '.olam') {
    if (process.env.PLERI_BASE_URL) {
        return true;
    }
    const configPath = path.join(configDir, 'config.yaml');
    if (!fs.existsSync(configPath)) {
        return false;
    }
    try {
        const contents = fs.readFileSync(configPath, 'utf8');
        // Match a top-level `pleri:` line (not commented out). YAML allows leading
        // whitespace at top-level (zero indent), but `pleri` could be commented
        // (`# pleri: ...`) — check for an uncommented match.
        return /^[^#\n]*\bpleri:/m.test(contents);
    }
    catch {
        return false;
    }
}
//# sourceMappingURL=pleri-config.js.map