1
0

feat: add EditTools.cs to implement file manipulation functions like replace_lines, delete_range, and batch_edit, updating README.md to reflect new tools and command descriptions.

This commit is contained in:
2026-03-06 03:20:48 +01:00
parent 8f2c72b3c5
commit 4fbbde32e3
3 changed files with 8 additions and 173 deletions

View File

@@ -1,105 +0,0 @@
# Tool Consolidation Ideas
This document outlines opportunities to merge similar tools to simplify the API.
## 1. File Write Operations
**Current tools:** `CreateFile`, `InsertAfter`, `AppendToFile`
**Proposed merge:** `WriteToFile`
```csharp
public static string WriteToFile(
string path,
string[] content,
string? mode = "create",
string? anchor = null)
```
**Behavior:**
- `mode="create"` - Creates new file (error if exists)
- `mode="append"` - Appends to EOF (creates if missing)
- `mode="insert"` - Inserts after anchor (requires existing file)
**Benefits:**
- Reduces 3 tools to 1
- Cleaner API for LLM
- Unified error handling
## 2. File Move Operations
**Current tools:** `RenameFile`, `CopyFile`
**Proposed merge:** `MoveFile`
```csharp
public static string MoveFile(
string sourcePath,
string destinationPath,
bool copy = false)
```
**Behavior:**
- `copy=false` - Moves file (current RenameFile behavior)
- `copy=true` - Copies file (current CopyFile behavior)
**Benefits:**
- 90% identical logic
- Only difference is File.Move vs File.Copy
- Both create parent directories
- Similar error handling patterns
## 4. Grep Operations ✅ DONE
**Current tools:** `GrepFile`, `GrepRecursive`
**Proposed merge:** `Grep`
```csharp
public static string Grep(
string path,
string pattern,
string mode = "recursive",
string? filePattern = null)
```
**Behavior:**
- `mode="file"` - Searches single file (current GrepFile)
- `mode="recursive"` - Searches directory recursively (current GrepRecursive)
- `filePattern` - Optional glob to filter files when recursive
**Benefits:**
- Very similar logic
- Reduces 2 tools to 1
- Cleaner API for LLM
## 5. Delete Operations ✅ DONE
**Current tools:** `DeleteFile`, `DeleteDir`
**Proposed merge:** `Delete`
```csharp
public static string Delete(
string path,
string mode = "file")
```
**Behavior:**
- `mode="file"` - Deletes a file
- `mode="dir"` - Deletes a directory (recursive)
**Benefits:**
- Unified interface for all deletion
- Similar error handling patterns
- Reduces 2 tools to 1
These consolidations reduced the tool count from 17 to 13 tools (4 completed), making the API simpler and easier for the LLM to use effectively.
**Completed merges**:
1. ✅ File Move Operations (2 → 1) - **DONE**
2. ✅ File Write Operations (3 → 1) - **DONE**
3. ✅ Delete Operations (2 → 1) - **DONE**
4. ✅ Grep Operations (2 → 1) - **DONE**
**All high priority merges completed!**