Iterate on tools some more (#26663)

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2025-03-13 13:42:02 +01:00 committed by GitHub
parent d9590f3f0e
commit e80df25386
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 5 deletions

View file

@ -1,5 +1,7 @@
Executes a bash one-liner and returns the combined output. Executes a bash one-liner and returns the combined output.
This tool spawns a bash process, combines stdout and stderr into one interleaved stream as they are produced (preserving the order of writes), and captures that stream into a string which is returned. This tool spawns a bash process IN THE SPECIFIED WORKING DIRECTORY, combines stdout and stderr into one interleaved stream as they are produced (preserving the order of writes), and captures that stream into a string which is returned.
WARNING: **NEVER** use 'cd' commands to navigate to the working directory - this is automatically handled by the 'working_directory' parameter. Only use 'cd' to navigate to subdirectories within the specified working directory.
Remember that each invocation of this tool will spawn a new bash process, so you can't rely on any state from previous invocations. Remember that each invocation of this tool will spawn a new bash process, so you can't rely on any state from previous invocations.

View file

@ -204,15 +204,27 @@ impl EditFilesTool {
let diff = buffer let diff = buffer
.read_with(&cx, |buffer, cx| { .read_with(&cx, |buffer, cx| {
let new_text = match action { let new_text = match action {
EditAction::Replace { old, new, .. } => { EditAction::Replace {
file_path,
old,
new,
} => {
// TODO: Replace in background? // TODO: Replace in background?
buffer.text().replace(&old, &new) let text = buffer.text();
if text.contains(&old) {
text.replace(&old, &new)
} else {
return Err(anyhow!(
"Could not find search text in {}",
file_path.display()
));
}
} }
EditAction::Write { content, .. } => content, EditAction::Write { content, .. } => content,
}; };
buffer.diff(new_text, cx) anyhow::Ok(buffer.diff(new_text, cx))
})? })??
.await; .await;
let _clock = let _clock =