Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/orchestrator/api_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_api_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading