patchloom 0.37.2

Structured file editing library and CLI for AI agents: parser-backed JSON/YAML/TOML edits, AST-aware code operations, multi-file batching, markdown operations, and MCP server
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! `notebook.edit` for the tx engine.
use super::{TxState, read_file_content};

pub(super) fn execute(
    path: &str,
    cell_id: &str,
    source: &str,
    tx: &mut TxState<'_>,
) -> anyhow::Result<usize> {
    let file_path = tx.cwd.join(path);
    let existing = read_file_content(tx.pending, tx.existed_before, &file_path)?;
    let updated = crate::ops::notebook::replace_cell_source(existing, cell_id, source)?;
    if updated == existing {
        return Ok(0);
    }
    tx.write_file(&file_path, updated);
    Ok(1)
}