Composes multiple edits against the same file into a single atomic write. Use this when a healer or AI agent wants to rewrite several things in one scenario file without parsing and writing three times.
const batch = Reflection.batch(filePath)The file is parsed and snapshotted at construction time.
Adds an Edit to the batch.
- Throws
ReflectionErrorifedit.filePathdoes not match the batch's file. - Throws
OverlappingEditErrorif the new edit's byte range overlaps a previously added one.magic-stringdetects overlaps for us.
Returns this for chaining.
Number of edits currently in the batch.
Full new source with all edits applied. Does not write.
Unified diff of the full batch.
| Option | Type | Default | Description |
|---|---|---|---|
ignoreStale |
boolean |
false |
When false, throws StaleEditError if the file's sha1 has changed since Reflection.batch(filePath) was called. |
Writes once. Atomicity is "all or nothing" — either every edit makes it to disk together, or none do.
Returns { filePath, applied }.