pub struct ApplyPatchTool { /* private fields */ }Expand description
Applies a *** Begin Patch envelope to several files at once (spec 3.1 §7.26).
The whole patch is parsed and every hunk located before anything is written. Each
file then goes to a temporary sibling, opened without following a symlink, and is
renamed into place; on any failure the files already written are restored from their
in-memory originals, so the call writes every file or none (§9.2 I67). A file’s
precondition is its expect_sha256 entry when the call gives one, else this session and
agent’s read record when one exists, and a file that differs is answered
devtools.stale. Each file keeps its line endings. The report and its errors name each
file as the patch does, relative to the workspace with / separators on every platform.
The report lists every file with its digests before and after:
{ "files": [{ "path": "src/lib.rs", "op": "update", "beforeSha256": "…", "afterSha256": "…" }] }§Example
use adk_core::{Tool, ToolEffect};
use adk_devtools::{ApplyPatchTool, Workspace};
let tool = ApplyPatchTool::new(Workspace::new("./my-repo"));
assert_eq!(tool.name(), "apply_patch");
assert_eq!(tool.effect(), ToolEffect::NonIdempotent);Implementations§
Trait Implementations§
Source§impl Tool for ApplyPatchTool
impl Tool for ApplyPatchTool
Source§fn egress(&self, _args: &Value) -> ToolEgress
fn egress(&self, _args: &Value) -> ToolEgress
Patches workspace files on disk.
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn effect(&self) -> ToolEffect
fn effect(&self) -> ToolEffect
Source§fn parameters_schema(&self) -> Option<Value>
fn parameters_schema(&self) -> Option<Value>
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<dyn ToolContext>,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn declaration(&self) -> Value
fn declaration(&self) -> Value
Source§fn enhanced_description(&self) -> String
fn enhanced_description(&self) -> String
Source§fn is_long_running(&self) -> bool
fn is_long_running(&self) -> bool
Source§fn is_builtin(&self) -> bool
fn is_builtin(&self) -> bool
google_search, url_context). Read more