| 58 | } |
| 59 | |
| 60 | QJsonObject EditFileTool::parametersSchema() const |
| 61 | { |
| 62 | QJsonObject properties; |
| 63 | |
| 64 | QJsonObject filenameProperty; |
| 65 | filenameProperty["type"] = "string"; |
| 66 | filenameProperty["description"] |
| 67 | = "The path of the file to edit. Can be an absolute path (e.g., /path/to/file.cpp) " |
| 68 | "or a relative path from the project root (e.g., src/main.cpp)"; |
| 69 | properties["filename"] = filenameProperty; |
| 70 | |
| 71 | QJsonObject oldContentProperty; |
| 72 | oldContentProperty["type"] = "string"; |
| 73 | oldContentProperty["description"] |
| 74 | = "The content to find and replace. For exact matches, provide precise text " |
| 75 | "(including whitespace). For changed files, the system uses fuzzy matching with " |
| 76 | "85% similarity threshold for first-time edits. If empty, new_content will be " |
| 77 | "appended to the end of the file"; |
| 78 | properties["old_content"] = oldContentProperty; |
| 79 | |
| 80 | QJsonObject newContentProperty; |
| 81 | newContentProperty["type"] = "string"; |
| 82 | newContentProperty["description"] = "The new content to replace the old content with"; |
| 83 | properties["new_content"] = newContentProperty; |
| 84 | |
| 85 | QJsonObject definition; |
| 86 | definition["type"] = "object"; |
| 87 | definition["properties"] = properties; |
| 88 | QJsonArray required; |
| 89 | required.append("filename"); |
| 90 | required.append("new_content"); |
| 91 | definition["required"] = required; |
| 92 | |
| 93 | return definition; |
| 94 | } |
| 95 | |
| 96 | QFuture<LLMQore::ToolResult> EditFileTool::executeAsync(const QJsonObject &input) |
| 97 | { |