Add new features and update configurations for improved functionality

This commit is contained in:
ImBenji
2026-04-11 12:34:00 +01:00
parent fa4415553d
commit 0b6b604c56
125 changed files with 14119 additions and 1664 deletions
+51
View File
@@ -0,0 +1,51 @@
import "dart:io";
import "package:clawd_code/src/tools/grep_tool.dart";
import "package:test/test.dart";
void main() {
late Directory tempDir;
late GrepTool tool;
setUp(() async {
tempDir = await Directory.systemTemp.createTemp("grep_tool_test_");
tool = GrepTool();
});
tearDown(() async {
if (await tempDir.exists()) {
await tempDir.delete(recursive: true);
}
});
group("GrepTool", () {
test("searches a direct file path", () async {
final file = File("${tempDir.path}/sample.txt");
await file.writeAsString("alpha\nbeta\nalpha again\n");
final result = await tool.execute({
"pattern": "alpha",
"path": file.path,
"output_mode": "content",
});
expect(result, contains("sample.txt:1:alpha"));
expect(result, contains("sample.txt:3:alpha again"));
});
test("searches a directory path", () async {
final nested = Directory("${tempDir.path}/nested");
await nested.create(recursive: true);
final file = File("${nested.path}/sample.txt");
await file.writeAsString("needle\n");
final result = await tool.execute({
"pattern": "needle",
"path": tempDir.path,
"output_mode": "files_with_matches",
});
expect(result, contains("nested/sample.txt"));
});
});
}