/** * Projection Engine for Lex Instructions * * Transforms canonical instruction content into host-specific files. * Pure transformation - no file I/O operations. */ import { CanonicalResult } from "./canonical-loader.js"; import { HostDetectionResult } from "./host-detection.js"; import { LexYaml } from "../config/lex-yaml-schema.js"; /** * Supported host types for projection */ export type HostType = "copilot" | "cursor"; /** * Configuration input for the projection engine */ export interface ProjectionConfig { /** Loaded canonical instruction content */ canonical: CanonicalResult; /** Detected host targets in the repository */ hosts: HostDetectionResult; /** Lex configuration with projection settings */ config: LexYaml; /** Function to read existing file content (for determining action). If not provided, assumes files don't exist. */ readFile?: (path: string) => string | null; } /** * Action to take for a projection * - create: File doesn't exist, will be created * - update: File exists, will be updated with new content * - skip: No action needed (content unchanged or host disabled) */ export type ProjectionAction = "create" | "update" | "skip"; /** * Result of projecting to a specific host */ export interface ProjectionResult { /** Target host type */ host: HostType; /** Absolute path to the target file */ path: string; /** Generated content for the file */ content: string; /** Action to take */ action: ProjectionAction; } /** * Generate projections for all enabled and available hosts * * This is a pure transformation function - it does not perform file I/O. * The caller is responsible for writing the generated content to files. * * @param config - Projection configuration with canonical content, hosts, and settings * @returns Array of projection results for each applicable host * * @example * ```ts * const projections = generateProjections({ * canonical: loadCanonicalInstructions(repoRoot), * hosts: detectAvailableHosts(repoRoot), * config: { version: 1 }, * readFile: (path) => fs.existsSync(path) ? fs.readFileSync(path, 'utf-8') : null * }); * * for (const proj of projections) { * if (proj.action !== 'skip') { * fs.writeFileSync(proj.path, proj.content); * } * } * ``` */ export declare function generateProjections(config: ProjectionConfig): ProjectionResult[]; /** * Default file reader implementation using Node.js fs * * @param path - Path to read * @returns File content or null if file doesn't exist or can't be read */ export declare function defaultFileReader(path: string): string | null;