MCPcopy Index your code
hub / github.com/AI45Lab/Code / edit_file

Method edit_file

sdk/node/src/lib.rs:3758–3781  ·  view source on GitHub ↗
(
        &self,
        path: String,
        old_string: String,
        new_string: String,
        replace_all: Option<bool>,
    )

Source from the content-addressed store, hash-verified

3756 /// Edit a file by replacing text in the workspace.
3757 #[napi]
3758 pub async fn edit_file(
3759 &self,
3760 path: String,
3761 old_string: String,
3762 new_string: String,
3763 replace_all: Option<bool>,
3764 ) -> napi::Result<ToolResult> {
3765 let session = self.inner.clone();
3766 let result = get_runtime()
3767 .spawn(async move {
3768 session
3769 .edit_file(
3770 &path,
3771 &old_string,
3772 &new_string,
3773 replace_all.unwrap_or(false),
3774 )
3775 .await
3776 })
3777 .await
3778 .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))?
3779 .map_err(|e| napi::Error::from_reason(format!("{e}")))?;
3780 Ok(tool_result_from_core(result))
3781 }
3782
3783 /// Apply a unified diff patch to a workspace file.
3784 #[napi]

Callers

nothing calls this directly

Calls 4

tool_result_from_coreFunction · 0.85
get_runtimeFunction · 0.70
cloneMethod · 0.45
spawnMethod · 0.45

Tested by

no test coverage detected