/** * Policy Loading Utility * * Loads and caches policy from lexmap.policy.json * Supports custom policy path via environment variable */ import type { Policy } from "../../types/policy.js"; /** * Load policy from lexmap.policy.json * * @param path - Optional custom policy path (defaults to working file with fallback to example) * @returns Policy object * @throws Error if policy file cannot be read or parsed * * Policy loading precedence: * 1. LEX_POLICY_PATH environment variable (explicit override) * 2. Custom path parameter (if provided) * 3. .smartergpt/lex/lexmap.policy.json (working file) * 4. canon/policy/lexmap.policy.json (canonical policy - checked in git) * 5. src/policy/policy_spec/lexmap.policy.json.example (example template) * * @example * ```typescript * const policy = loadPolicy(); * console.log(Object.keys(policy.modules)); // ['indexer', 'ts', 'php', 'mcp'] * ``` * * @example With custom path * ```typescript * const policy = loadPolicy('/custom/path/policy.json'); * ``` * * @example With environment variable * ```typescript * process.env.LEX_POLICY_PATH = '/custom/path/policy.json'; * const policy = loadPolicy(); * ``` */ export declare function loadPolicy(path?: string): Policy; /** * Load policy if available, return null if not found (graceful mode) * * @param path - Optional custom policy path * @returns Policy object or null if not found * * This is used by CLI commands that should work without a policy file, * emitting a warning instead of failing. * * @example * ```typescript * const policy = loadPolicyIfAvailable(); * if (!policy) { * console.warn('No policy file found, skipping validation'); * } * ``` */ export declare function loadPolicyIfAvailable(path?: string): Policy | null; /** * Clear cached policy (useful for testing) */ export declare function clearPolicyCache(): void;