refactor: короче методы, чище тесты, README разгружен
- ShellTool::handle 108 → 52 строк: tempFiles() и run() отдельно - CsvQueryTool::handle 103 → 80: readRows() и pickRows() отдельно - в кейсах тестов оставлены только используемые use (было 26 в каждом) - README 653 → 261 строк: инструменты, примеры, провайдеры и справочник вынесены в docs/ - 100 тестов
This commit is contained in:
1 parent
76b3be7115
commit
27c0fc2477
13 files changed
+546
-616
No files matched your search
@@ -5,31 +5,10 @@ declare(strict_types=1);
|
||||
// Тесты: agent. Запускаются из tests/run.php.
|
||||
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Агент
|
||||
@@ -166,7 +145,6 @@ test('агент: tool_choice не навязывается на повторн
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Настройки агента
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -310,7 +288,6 @@ test('агент: reset очищает историю и трассировку'
|
||||
assertSame([], $agent->trace());
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Завершение через finish
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -4,32 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
// Тесты: files. Запускаются из tests/run.php.
|
||||
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Файлы
|
||||
@@ -101,7 +83,6 @@ test('list_dir: выход за корень запрещён', function (): voi
|
||||
assertContains('не должен содержать', $result);
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CSV
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -152,7 +133,6 @@ test('csv_query: неизвестная колонка — понятная ош
|
||||
assertContains('name, city', $result);
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Запись и правка файлов
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -260,7 +240,6 @@ test('replace_in_file: не найдено — понятная ошибка', f
|
||||
assertContains('не найден', $result);
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Поиск по файлам
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -321,7 +300,6 @@ test('find_files: поиск по маске', function (): void {
|
||||
assertTrue(!str_contains($result, 'b.txt'), 'лишний файл в выдаче');
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Песочница: ограниченный и свободный режимы
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -4,32 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
// Тесты: http. Запускаются из tests/run.php.
|
||||
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// http_request: сборка запроса (без сети)
|
||||
@@ -110,7 +88,6 @@ test('http: заголовки превращаются в строки cURL', f
|
||||
assertSame(['Accept: */*'], HttpTransport::headerLines(['Accept: */*']));
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// http_request: защита от SSRF (без сети)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -7,29 +7,10 @@ declare(strict_types=1);
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Логирование
|
||||
|
||||
@@ -4,32 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
// Тесты: shell. Запускаются из tests/run.php.
|
||||
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// run_command: оболочка
|
||||
|
||||
@@ -4,31 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
// Тесты: tools. Запускаются из tests/run.php.
|
||||
|
||||
use AiSdk\Agent;
|
||||
use AiSdk\ChatClient;
|
||||
use AiSdk\ChatResult;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\HttpRequest;
|
||||
use AiSdk\LoggingClient;
|
||||
use AiSdk\Tool;
|
||||
use AiSdk\ToolRegistry;
|
||||
use AiSdk\Tools\CalculatorTool;
|
||||
use AiSdk\Tools\ConvertUnitsTool;
|
||||
use AiSdk\Tools\CsvQueryTool;
|
||||
use AiSdk\Tools\DateCalcTool;
|
||||
use AiSdk\Tools\FileSandbox;
|
||||
use AiSdk\Tools\FindFilesTool;
|
||||
use AiSdk\Tools\JsonQueryTool;
|
||||
use AiSdk\Tools\FinishTool;
|
||||
use AiSdk\Tools\HashTool;
|
||||
use AiSdk\Tools\HttpRequestTool;
|
||||
use AiSdk\Tools\ListDirTool;
|
||||
use AiSdk\Tools\ReadFileTool;
|
||||
use AiSdk\Tools\ReplaceInFileTool;
|
||||
use AiSdk\Tools\SearchFilesTool;
|
||||
use AiSdk\Tools\ShellTool;
|
||||
use AiSdk\Tools\TimeTool;
|
||||
use AiSdk\Tools\WriteFileTool;
|
||||
use AiSdk\Tools\UuidTool;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -68,7 +51,6 @@ test('time: неизвестный пояс — понятная ошибка',
|
||||
assertContains('Неизвестный часовой пояс', (new TimeTool())->handle(['timezone' => 'Mars/Olympus']));
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Реестр инструментов
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -145,7 +127,6 @@ test('реестр: длинный результат обрезается', fun
|
||||
assertSame(11, mb_strlen($result), 'ожидалось 10 символов и многоточие');
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Единицы и даты
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -210,7 +191,6 @@ test('date_calc: плохой часовой пояс', function (): void {
|
||||
]));
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UUID и хеши
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -235,7 +215,6 @@ test('hash_text: известные значения', function (): void {
|
||||
assertContains('Неизвестный алгоритм', $tool->handle(['text' => 'x', 'algo' => 'crc32']));
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// JSON
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user