import type { EditOp, RawEditOp } from "./types.ts"; /** * Normalize raw tool args to typed EditOp[]. * Defaults op to "replace". * Handles null/undefined/empty lines. */ export declare function normalizeEdits(rawEdits: RawEditOp[]): EditOp[]; /** * Apply a replace operation targeting a single line at the given anchor. * * D11: when `originalLines` (the batch-start snapshot) is provided, anchor * validation and the indent template come from it, not from the mutated * working `lines` — a prior same-line op (replace before append/prepend) * rewrites the anchor's content, so re-validating against `lines` would fail * on the already-replaced line. The splice always operates on `lines`. */ export declare function applyReplaceSingle(lines: string[], anchor: string, newText: string | string[], hashWidth: number, originalLines?: string[]): string[]; /** * Apply a replace operation targeting an inclusive range [startAnchor, endAnchor]. * * D11: validation/echo-strip/indent references use `originalLines` (the * batch-start snapshot) when provided; the splice operates on `lines`. * D3: `attached` inserts (append/prepend ops anchored strictly INSIDE this * range) ride along with the range splice as * [prepends..., rangeNewLines..., appends...]. */ export declare function applyReplaceRange(lines: string[], startAnchor: string, endAnchor: string, newText: string | string[], hashWidth: number, originalLines?: string[], attached?: AttachedInsert): string[]; /** * Insert new lines after the anchor line. * * D11: anchor validation and the echo-strip anchor line come from * `originalLines` (batch-start snapshot) when provided — a prior same-line * replace rewrites the working line, but the anchor references the ORIGINAL * content. */ export declare function applyInsertAfter(lines: string[], anchor: string, text: string | string[], hashWidth: number, originalLines?: string[]): string[]; /** * Insert new lines before the anchor line. * * D11: anchor validation and the echo-strip anchor line come from * `originalLines` (batch-start snapshot) when provided. */ export declare function applyInsertBefore(lines: string[], anchor: string, text: string | string[], hashWidth: number, originalLines?: string[]): string[]; /** * Append lines at EOF. * * Degenerate-file rule: a file whose only line is empty — canonical content * exactly "\n", the only content splitLines maps to [""] — has that newline as * its terminator, not a content line. An anchorless append therefore writes the * new lines as the file's first lines instead of stacking them below a blank * line (regression spec: "\n" + append "x" → "x\n", not "\nx\n"). */ export declare function applyAppend(lines: string[], text: string | string[], refLineCount?: number): string[]; /** * Prepend lines at BOF. */ export declare function applyPrepend(lines: string[], text: string | string[], refLineCount?: number): string[]; /** * D3: insert lines attached to a replace range. When the range is applied, * its splice becomes [prependLines..., rangeNewLines..., appendLines...]. * Lines are already normalized (echo-strip against the original anchor line, * then prefix strip). */ export interface AttachedInsert { prependLines: string[]; appendLines: string[]; } /** * Apply multiple edits to content and return the result with a report. * * Pipeline: * 1. Deduplicate edits * 2. Attach append/prepend ops anchored strictly inside a replace range (D3) * 3. Sort bottom-up (descending line number) * 4. Validate all line references * 5. Detect overlapping ranges * 6. Apply each edit in order * 7. Track noop edits */ export declare function applyEditsWithReport(content: string, edits: EditOp[], hashWidth: number): { content: string; noopEdits: number; deduplicatedEdits: number; }; //# sourceMappingURL=edit-primitives.d.ts.map