/** * A prompt loop's prompt on disk: the file is the source of truth, the record's * `prompt` is the seed and the rebuild source (ADR-0024). * * The address is derived from the loop id alone, so nothing here takes a path * from a caller. The plugin writes at three moments: creating the loop, an * explicit rewrite through pretty_task_loop_update, and a rebuild of a file that * is missing, unreadable or holds only whitespace. Every fire reads. * * @author mystery4f <40482524+mystery4f@users.noreply.github.com> */ import type { PromptLoopTask } from "../base/task.js"; /** What one fire sends, and what the record should say about how it was obtained. */ export interface PromptRead { /** Text the wake carries; never empty, because an unreadable file still fires. */ readonly text: string; /** * One line for the record when the creation prompt had to stand in. Absent on * a clean read, so the warning disappears once the file is healthy again. */ readonly warning?: string; } /** * A prompt file as the panel shows it: where it is, the first few lines, when it * last changed, and what went wrong with the read if anything did, so a reader * can tell whether the version they edited is the one that fired. Never the * whole text. */ export interface PromptPreview { /** The file's address, derived from the loop id; present even when it cannot be read. */ readonly path: string; /** The first `PROMPT_PREVIEW_LINES` non-empty lines, trimmed; empty when there are none. */ readonly lines: readonly string[]; /** The file's modification time, epoch ms; absent when it could not be stat'ed. */ readonly changedAt?: number; /** * Why there is no text — "is missing", "is empty", "could not be read (…)" — the * same words the fire's warning uses. Absent when the file read cleanly, so a * failed stat of a readable file still shows the lines it did read. */ readonly problem?: string; } /** Write the loop's prompt file, replacing whatever is there. */ export declare function writePromptText(directory: string, loopId: string, text: string): Promise; /** * Delete the loop's prompt file with the loop. Best effort: a loop the user * asked to delete is gone even when a file handle or a scanner keeps the entry * alive for a moment (ADR-0024 lifecycle). */ export declare function removePromptText(directory: string, loopId: string): Promise; /** * The text one fire sends. A readable, non-empty file wins outright — that is * what makes editing the file refine the prompt without recreating the loop. * Anything else rebuilds the file from the record and still fires: a loop that * silently stopped is the failure this whole design is against (ADR-0024). */ export declare function readPromptText(directory: string, task: PromptLoopTask): Promise; /** * A loop's prompt file as its panel page shows it. Reads through this layer, so * the panel never joins a path or opens a file itself, and never throws: a file * that is gone yields the address and no preview, which the page pairs with the * record's own warning (ADR-0024, ticket #48). */ export declare function readPromptPreview(directory: string, loopId: string): Promise;