diff --git a/scripts/orchestrator/api_runner.py b/scripts/orchestrator/api_runner.py index b7d5d388..7b68370e 100644 --- a/scripts/orchestrator/api_runner.py +++ b/scripts/orchestrator/api_runner.py @@ -219,6 +219,8 @@ def _execute_grep(params: dict[str, Any]) -> str: except FileNotFoundError: # Fallback to grep if rg not available cmd_fallback = ["grep", "-rn"] + if glob_filter: + cmd_fallback.extend([f"--include={glob_filter}"]) if context: cmd_fallback.extend([f"-C{context}"]) cmd_fallback.extend([pattern, path]) @@ -259,8 +261,9 @@ def _execute_glob(params: dict[str, Any]) -> str: # Limit output if len(matches) > 500: + total = len(matches) matches = matches[:500] - matches.append(f"... ({len(matches)} total, truncated)") + matches.append(f"... ({total} total, truncated)") return "\n".join(matches) diff --git a/tests/test_api_runner.py b/tests/test_api_runner.py index eca3bd71..015a2af5 100644 --- a/tests/test_api_runner.py +++ b/tests/test_api_runner.py @@ -137,6 +137,12 @@ def test_glob_recursive(self, tmp_path): result = _execute_glob({"pattern": "**/*.go", "path": str(tmp_path)}) assert "deep.go" in result + def test_glob_truncation(self, tmp_path): + for i in range(505): + (tmp_path / f"file_{i:03d}.dat").touch() + result = _execute_glob({"pattern": "*.dat", "path": str(tmp_path)}) + assert "... (505 total, truncated)" in result + class TestWriteTool: """Tests for the Write tool executor."""