/** * OutputDelta — re-send only what changed, never the whole thing again. * * The problem: a debug loop reads the same file (or runs the same command) six times. * Between two of those calls maybe three lines moved, but the model pays for the entire * file or the entire 400-line `tsc` dump each time — and because tool results stay in the * transcript, it keeps paying for every copy on every subsequent turn. * * `ReadWorkspaceCache` already suppresses the *identical* case. This module covers the far * more common one: it changed, but barely. * * Two rules this module is built around: * * 1. The diff is computed against the exact text the model received. Not the file on * disk, not the pre-squeeze source — the final emitted string. A diff against * anything else describes a document the model never had, which is worse than * re-sending the whole file. * 2. A delta is only emitted when it is decisively smaller than the full text. Below * that margin, reconstructing from a diff is cognitive work with no token payoff, so * the full text wins. See `shouldEmitDelta`. */ export interface Hunk { /** 1-indexed start line in the previous text. */ oldStart: number; oldLines: number; /** 1-indexed start line in the new text. */ newStart: number; newLines: number; /** Rendered lines, each prefixed with ' ', '-' or '+'. */ lines: string[]; } export interface DiffResult { hunks: Hunk[]; added: number; removed: number; /** True when the two texts are byte-identical. */ identical: boolean; } /** Line-level diff between the text the model already has and the text we would send now. */ export declare function computeDiff(previous: string, next: string): DiffResult | null; /** Render hunks as a unified diff body (no ---/+++ file headers; the caller supplies context). */ export declare function renderDiff(diff: DiffResult): string; export interface DeltaDecision { emit: boolean; /** The rendered diff body, present only when `emit` is true. */ body?: string; added: number; removed: number; hunkCount: number; /** Why a delta was declined — surfaced in logs and receipts, never guessed at. */ reason?: string; } /** * Decide whether to hand the model a delta instead of the full text. * * Declining is the safe direction: the caller falls back to sending everything, which is * always correct. So every uncertain case here resolves to `emit: false`. */ export declare function shouldEmitDelta(previous: string, next: string): DeltaDecision; //# sourceMappingURL=OutputDelta.d.ts.map