UNPKG

relaycode

Version:

A developer assistant that automates applying code changes from LLMs.

34 lines (31 loc) 1.79 kB
import { Config, ParsedLLMResponse, FileOperation, FileSnapshot } from 'relaycode-core'; type Prompter = (question: string) => Promise<boolean>; type ProcessPatchOptions = { prompter?: Prompter; cwd?: string; notifyOnStart?: boolean; yes?: boolean; }; declare const createSnapshot: (filePaths: string[], cwd?: string) => Promise<FileSnapshot>; /** * Applies a series of file operations to the filesystem and returns the new in-memory file states. * This function processes operations sequentially, applying patches (like diffs) against the evolving * state of files, and performing filesystem actions (write, delete, rename) along the way. * @param operations The file operations to apply. * @param originalFiles The initial state of the files. * @param cwd The working directory. * @returns A map representing the final state of all affected files. */ declare const applyOperations: (operations: FileOperation[], originalFiles: Map<string, string | null>, cwd?: string) => Promise<Map<string, string | null>>; declare const restoreSnapshot: (snapshot: FileSnapshot, cwd?: string) => Promise<void>; /** * Processes a patch transaction. This function acts as a locking wrapper around the core * patch processing logic (`_processPatch`) to ensure that only one transaction is * processed at a time for a given working directory. This prevents race conditions * with the file-based database. * @param config The application configuration. * @param parsedResponse The parsed response from the LLM. * @param options Options for processing the patch. */ declare const processPatch: (config: Config, parsedResponse: ParsedLLMResponse, options?: ProcessPatchOptions) => Promise<void>; export { applyOperations, createSnapshot, processPatch, restoreSnapshot };