winx_code_agent/tools/
file_write_or_edit.rs1mod commit;
7mod matcher;
8mod parser;
9mod report;
10
11#[cfg(test)]
12mod tests;
13
14use std::sync::Arc;
15
16use tokio::sync::Mutex;
17use tracing::instrument;
18
19use crate::errors::Result;
20use crate::state::bash_state::BashState;
21use crate::types::FileWriteOrEdit;
22pub(crate) use commit::{
23 commit_edit, ensure_parent_dirs, hash_content, invalidate_edit_read_permit_at_target,
24 plan_explicit_text_edit_at_target, plan_revision_edit_at_target, resolve_edit_path,
25 write_no_follow_if_unchanged, PlannedEdit,
26};
27pub(crate) use parser::uses_search_replace;
28
29#[cfg(feature = "fuzzing")]
30pub(crate) fn fuzz_apply_blocks(original: &str, blocks: &str) {
31 let _ = matcher::apply_blocks_with_unescape_retry(original, blocks);
32}
33
34#[instrument(level = "info", skip(bash_state_arc, file_write_or_edit))]
35pub async fn handle_tool_call(
36 bash_state_arc: &Arc<Mutex<Option<BashState>>>,
37 file_write_or_edit: FileWriteOrEdit,
38) -> Result<String> {
39 crate::tools::edit_files::handle_legacy_tool(
40 bash_state_arc,
41 crate::tools::edit_files::EditSurface::FileWriteOrEdit,
42 file_write_or_edit,
43 )
44 .await
45 .map(|outcome| outcome.text)
46}