(
&self,
path: String,
old_string: String,
new_string: String,
replace_all: Option<bool>,
)
| 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] |
nothing calls this directly
no test coverage detected