ProgramDiffBlock
Models & Types · AiDotNet.Evolution.Programs
One parsed SEARCH/REPLACE edit: the text to find and the text that replaces it.
For Beginners
This is a single “find and replace” instruction. SearchText is the
snippet that must already exist in the program, and ReplaceText is what it becomes; an empty
replacement deletes the snippet. Because the instruction knows its own position in the model’s answer, an error
can say “your second edit failed” rather than just “something failed”.
How It Works
A block is the unit an LLM emits when it edits code without rewriting a whole file. Both halves are stored with
line endings normalized to line feeds and with trailing white space removed, matching the reference
OpenEvolve parser so an edit that works there works here. Ordinal and ResponseLine
record where the block came from in the response, which is what lets a failure message point the model at the
exact instruction that could not be applied.
Constructors
| Constructor | Summary |
|---|---|
ProgramDiffBlock(string searchText, string replaceText, int ordinal, int responseLine) |
Initializes an edit block. |
Properties
| Property | Summary |
|---|---|
bool IsDeletion { get; } |
Gets whether the block is a pure deletion. |
int Ordinal { get; } |
Gets the zero-based position of this block within its response. |
int ResponseLine { get; } |
Gets the one-based response line the search marker appeared on, or zero when unknown. |
string ReplaceText { get; } |
Gets the replacement text; an empty string deletes the matched lines. |
string SearchText { get; } |
Gets the text that must be found in the target program. |
Methods
| Method | Summary |
|---|---|
string ToString() |
Returns the block ordinal and its two text sizes without echoing any code. |