1
0

feat: consolidate file write, move, grep, and delete operations into unified tools and update context compaction heuristics

This commit is contained in:
2026-03-06 01:14:56 +01:00
parent 7a6e9785d6
commit 003345edc0
6 changed files with 230 additions and 261 deletions

View File

@@ -49,7 +49,7 @@ public static string MoveFile(
- Both create parent directories
- Similar error handling patterns
## 3. Grep Operations
## 4. Grep Operations ✅ DONE
**Current tools:** `GrepFile`, `GrepRecursive`
@@ -59,13 +59,13 @@ public static string MoveFile(
public static string Grep(
string path,
string pattern,
bool recursive = false,
string mode = "recursive",
string? filePattern = null)
```
**Behavior:**
- `recursive=false` - Searches single file (current GrepFile)
- `recursive=true` - Searches directory recursively (current GrepRecursive)
- `mode="file"` - Searches single file (current GrepFile)
- `mode="recursive"` - Searches directory recursively (current GrepRecursive)
- `filePattern` - Optional glob to filter files when recursive
**Benefits:**
@@ -73,7 +73,7 @@ public static string Grep(
- Reduces 2 tools to 1
- Cleaner API for LLM
## 4. Delete Operations
## 5. Delete Operations ✅ DONE
**Current tools:** `DeleteFile`, `DeleteDir`
@@ -82,31 +82,24 @@ public static string Grep(
```csharp
public static string Delete(
string path,
bool recursive = true)
string mode = "file")
```
**Behavior:**
- Auto-detects if path is file or directory
- `recursive=true` - Delete directory and all contents
- `recursive=false` - Only matters for directories (error if not empty)
- `mode="file"` - Deletes a file
- `mode="dir"` - Deletes a directory (recursive)
**Benefits:**
- Auto-detects file vs directory
- Unified interface for all deletion
- Similar error handling patterns
- Reduces 2 tools to 1
## Summary
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.
These consolidations would reduce the tool count from 17 to 13 tools, 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**
**High priority merges:**
1. ✅ File Write Operations (3 → 1)
2. ✅ File Move Operations (2 → 1)
3. ✅ Grep Operations (2 → 1)
4. ✅ Delete Operations (2 → 1)
**Kept separate:**
- `ReadFile` - distinct read-only operation
- `ListDir`, `FindFiles`, `GetFileInfo` - different purposes
- `CreateDir` - simple enough to keep standalone
- `ReplaceLines`, `InsertAfter`, `DeleteRange` - too complex to merge without confusing LLM
**All high priority merges completed!**