MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / GetEditTextFileToolDefinition

Function GetEditTextFileToolDefinition

pkg/aiusechat/tools_writefile.go:348–410  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

346}
347
348func GetEditTextFileToolDefinition() uctypes.ToolDefinition {
349 return uctypes.ToolDefinition{
350 Name: "edit_text_file",
351 DisplayName: "Edit Text File",
352 Description: "Edit a text file using precise search and replace. " +
353 "Each old_str must appear EXACTLY ONCE in the file or the edit will fail. " +
354 "All edits are applied atomically - if any single edit fails, the entire operation fails and no changes are made. " +
355 "Maximum file size: 100KB.",
356 ToolLogName: "gen:editfile",
357 Strict: true,
358 InputSchema: map[string]any{
359 "type": "object",
360 "properties": map[string]any{
361 "filename": map[string]any{
362 "type": "string",
363 "description": "Absolute path to the file to edit. Supports '~' for the user's home directory. Relative paths are not supported.",
364 },
365 "edits": map[string]any{
366 "type": "array",
367 "description": "Array of edit specifications. All edits are applied atomically - if any edit fails, none are applied.",
368 "items": map[string]any{
369 "type": "object",
370 "properties": map[string]any{
371 "old_str": map[string]any{
372 "type": "string",
373 "description": "The exact string to find and replace. MUST appear exactly once in the file - if it appears zero times or multiple times, the entire edit operation will fail.",
374 },
375 "new_str": map[string]any{
376 "type": "string",
377 "description": "The string to replace with",
378 },
379 "desc": map[string]any{
380 "type": "string",
381 "description": "Description of what this edit does (keep it VERY short, one sentence max)",
382 },
383 },
384 "required": []string{"old_str", "new_str", "desc"},
385 "additionalProperties": false,
386 },
387 },
388 },
389 "required": []string{"filename", "edits"},
390 "additionalProperties": false,
391 },
392 ToolCallDesc: func(input any, output any, toolUseData *uctypes.UIMessageDataToolUse) string {
393 params, err := parseEditTextFileInput(input)
394 if err != nil {
395 return fmt.Sprintf("error parsing input: %v", err)
396 }
397 editCount := len(params.Edits)
398 editWord := "edits"
399 if editCount == 1 {
400 editWord = "edit"
401 }
402 return fmt.Sprintf("editing %q (%d %s)", params.Filename, editCount, editWord)
403 },
404 ToolAnyCallback: editTextFileCallback,
405 ToolApproval: func(input any) string {

Callers 1

GenerateTabStateAndToolsFunction · 0.85

Calls 1

parseEditTextFileInputFunction · 0.85

Tested by

no test coverage detected