8cb0531959
* fix(lint): organize imports in queen_orchestrator.create_queen Ruff I001 blocks CI on every PR against main. The deferred imports inside create_queen were not in alphabetical order between the queen package and the framework package; ruff auto-fix moves framework.config below the framework.agents.queen.nodes block. No behavior change. * fix(ci): install Playwright Chromium before Test Tools job The new chart_tools smoke tests added infeabf327require a Chromium build for ECharts/Mermaid rendering, but the test-tools workflow only ran `uv sync` and went straight to pytest. Three tests (test_render_echarts_bar_chart, test_render_echarts_accepts_string_spec, test_render_mermaid_flowchart) crash on every PR with: BrowserType.launch: Executable doesn't exist at /home/runner/.cache/ms-playwright/chromium_headless_shell-1208/... Split the install/run into separate steps and add `playwright install chromium` before pytest. Use `--with-deps` on Linux to pull system libraries; Windows runners only need the browser binary. * fix(tests): adapt test_file_state_cache to new file_ops API The file_ops rewrite infeabf327dropped the standalone hashline_edit tool (the file_system_toolkits/hashline_edit/ directory was removed) and switched edit_file to a mode-first signature (mode, path, old_string, new_string, ...). The test fixture still tried to look up "hashline_edit" via the MCP tool manager and crashed with KeyError before any test could run, and the edit_file calls were positional in the old order so they hit "unknown mode 'e.py'" once the fixture was fixed. Drop the stale hashline_edit lookup and pass mode="replace" explicitly to every edit_file call. All 11 tests pass locally. * fix(tests): skip terminal_tools tests on Windows (POSIX-only) The new terminal_tools package added infeabf327imports the Unix-only `resource` module in tools/src/terminal_tools/common/limits.py to set RLIMIT_CPU / RLIMIT_AS / RLIMIT_FSIZE on subprocesses. Five of the six terminal_tools test files therefore crash on windows-latest with `ModuleNotFoundError: No module named 'resource'` once their fixtures trigger the import chain. test_terminal_tools_pty.py already has the right module-level skip (PTY is POSIX-only). Apply the same `pytestmark = skipif(win32)` to the other five so the whole suite skips cleanly on Windows. The terminal-tools package is bash-only by design (zsh refused at the shell-resolver level), so a Windows port is out of scope.
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
"""terminal_rg + terminal_find — basic functionality, structured output."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="terminal_tools is POSIX-only (uses resource module)")
|
|
|
|
|
|
@pytest.fixture
|
|
def search_tools(mcp):
|
|
from terminal_tools.search.tools import register_search_tools
|
|
|
|
register_search_tools(mcp)
|
|
return {
|
|
"rg": mcp._tool_manager._tools["terminal_rg"].fn,
|
|
"find": mcp._tool_manager._tools["terminal_find"].fn,
|
|
}
|
|
|
|
|
|
@pytest.mark.skipif(not shutil.which("rg"), reason="ripgrep not installed")
|
|
def test_rg_finds_pattern(search_tools, tmp_path):
|
|
(tmp_path / "a.txt").write_text("hello\nworld\nfoo\n")
|
|
(tmp_path / "b.txt").write_text("bar\nworld\n")
|
|
|
|
result = search_tools["rg"](pattern="world", path=str(tmp_path))
|
|
assert result["total"] >= 2
|
|
paths = {m["path"] for m in result["matches"]}
|
|
assert any("a.txt" in p for p in paths)
|
|
|
|
|
|
@pytest.mark.skipif(not shutil.which("rg"), reason="ripgrep not installed")
|
|
def test_rg_no_matches(search_tools, tmp_path):
|
|
(tmp_path / "a.txt").write_text("hello\n")
|
|
result = search_tools["rg"](pattern="zzz_no_match_zzz", path=str(tmp_path))
|
|
assert result["total"] == 0
|
|
assert result["matches"] == []
|
|
|
|
|
|
def test_find_by_name(search_tools, tmp_path):
|
|
(tmp_path / "alpha.log").write_text("a")
|
|
(tmp_path / "beta.log").write_text("b")
|
|
(tmp_path / "ignore.txt").write_text("c")
|
|
|
|
result = search_tools["find"](path=str(tmp_path), name="*.log")
|
|
assert result["count"] == 2
|
|
assert all(p.endswith(".log") for p in result["paths"])
|
|
|
|
|
|
def test_find_by_type_dir(search_tools, tmp_path):
|
|
(tmp_path / "sub").mkdir()
|
|
(tmp_path / "file.txt").write_text("x")
|
|
|
|
result = search_tools["find"](path=str(tmp_path), type_filter="d")
|
|
paths = result["paths"]
|
|
# tmp_path itself + sub
|
|
assert any(p.endswith("sub") for p in paths)
|
|
assert not any(p.endswith("file.txt") for p in paths)
|