Expand description
Shared edit engine: byte-offset conversion, content replacement, syntax validation, and auto-backup orchestration.
Used by write, edit_symbol, edit_match, and batch commands.
Structs§
- Write
Result - Result of the write → format → validate pipeline.
Functions§
- auto_
backup - Snapshot the file into the backup store before mutation, scoped to a session.
- compute_
diff_ counts - Compute compact diff counts (additions/deletions) without echoing any file content. This is the agent-facing default — the payload is constant-size regardless of how large the edited file is.
- compute_
diff_ for_ response - Pick the right diff shape for a response based on request flags.
- compute_
diff_ info - Compute diff info between before/after content for UI metadata. Returns a JSON value with before, after, additions, deletions. For files >512KB, omits full content and returns only counts.
- line_
col_ to_ byte - Convert 0-indexed line/col to a byte offset within
source. - replace_
byte_ range - Replace bytes in
[start..end)withreplacement. - validate_
syntax - Validate syntax of a file using a fresh FileParser (D023).
- validate_
syntax_ str - Validate syntax of an in-memory string without touching disk.
- wants_
diff - Check if the caller requested diff info in the response.
- wants_
diff_ content - Check if the caller requested the full before/after file contents in the
diff. This is for UI rendering only (e.g. the OpenCode/Pi plugins building a
diff view in tool metadata) and is deliberately NOT the default: full
content makes the response scale with file size, not edit size, which floods
agent context on large files. Agent-facing/raw consumers should pass
include_diff(counts only) instead. - write_
format_ validate - Write content to disk, auto-format, then validate syntax.