()
| 29 | } |
| 30 | |
| 31 | func (t *EditTool) InputSchema() map[string]any { |
| 32 | return map[string]any{ |
| 33 | "type": "object", |
| 34 | "properties": map[string]any{ |
| 35 | "file_path": map[string]any{ |
| 36 | "type": "string", |
| 37 | "description": "要编辑的文件路径,必须是绝对路径", |
| 38 | }, |
| 39 | "old_string": map[string]any{ |
| 40 | "type": "string", |
| 41 | "description": "要被替换的原始字符串,必须精确匹配", |
| 42 | }, |
| 43 | "new_string": map[string]any{ |
| 44 | "type": "string", |
| 45 | "description": "替换后的新字符串", |
| 46 | }, |
| 47 | "replace_all": map[string]any{ |
| 48 | "type": "boolean", |
| 49 | "description": "是否替换所有匹配的实例,默认为false(只替换第一个匹配项)", |
| 50 | }, |
| 51 | "preserve_indentation": map[string]any{ |
| 52 | "type": "boolean", |
| 53 | "description": "是否保持原始缩进格式,默认为true", |
| 54 | }, |
| 55 | "backup": map[string]any{ |
| 56 | "type": "boolean", |
| 57 | "description": "在编辑前是否创建备份,默认为true", |
| 58 | }, |
| 59 | }, |
| 60 | "required": []string{"file_path", "old_string", "new_string"}, |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (t *EditTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error) { |
| 65 | // 验证必需参数 |
no outgoing calls