MCPcopy
hub / github.com/wavetermdev/waveterm / verifyEditTextFileInput

Function verifyEditTextFileInput

pkg/aiusechat/tools_writefile.go:247–269  ·  view source on GitHub ↗
(input any, toolUseData *uctypes.UIMessageDataToolUse)

Source from the content-addressed store, hash-verified

245}
246
247func verifyEditTextFileInput(input any, toolUseData *uctypes.UIMessageDataToolUse) error {
248 params, err := parseEditTextFileInput(input)
249 if err != nil {
250 return err
251 }
252
253 expandedPath, err := wavebase.ExpandHomeDir(params.Filename)
254 if err != nil {
255 return fmt.Errorf("failed to expand path: %w", err)
256 }
257
258 if !filepath.IsAbs(expandedPath) {
259 return fmt.Errorf("path must be absolute, got relative path: %s", params.Filename)
260 }
261
262 _, err = validateTextFile(expandedPath, "edit", true)
263 if err != nil {
264 return err
265 }
266
267 toolUseData.InputFileName = params.Filename
268 return nil
269}
270
271// EditTextFileDryRun applies edits to a file and returns the original and modified content
272// without writing to disk. Takes the same input format as editTextFileCallback.

Callers

nothing calls this directly

Calls 3

ExpandHomeDirFunction · 0.92
parseEditTextFileInputFunction · 0.85
validateTextFileFunction · 0.85

Tested by

no test coverage detected