core/tools: rename grep_files to regex_files (regex pattern)

This commit is contained in:
2026-09-22 23:22:13 +08:00
parent 76933b044c
commit de03e5932b
11 changed files with 35 additions and 35 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ def test_read_only_classification() -> None:
"read_file",
"get_truncated",
"glob_paths",
"grep_files",
"regex_files",
"listdir",
"tree",
"todo_list",
@@ -2,46 +2,46 @@ from __future__ import annotations
from pathlib import Path
from plyngent.tools.file.grep_files import grep_files
from plyngent.tools.file.regex_files import regex_files
from tests.test_tools.helpers import call_sync
def test_grep_files_basic(workspace: object) -> None:
def test_regex_files_basic(workspace: object) -> None:
assert isinstance(workspace, Path)
_ = (workspace / "a.py").write_text("hello world\nfoo\n", encoding="utf-8")
_ = (workspace / "b.py").write_text("nope\n", encoding="utf-8")
out = call_sync(grep_files, "hello")
out = call_sync(regex_files, "hello")
assert "a.py:1:" in out
assert "hello world" in out
assert "b.py" not in out
def test_grep_files_case_insensitive(workspace: object) -> None:
def test_regex_files_case_insensitive(workspace: object) -> None:
assert isinstance(workspace, Path)
_ = (workspace / "t.txt").write_text("Hello\n", encoding="utf-8")
assert "no matches" in call_sync(grep_files, "hello")
out = call_sync(grep_files, "hello", case_insensitive=True)
assert "no matches" in call_sync(regex_files, "hello")
out = call_sync(regex_files, "hello", case_insensitive=True)
assert "t.txt:1:" in out
def test_grep_files_invalid_regex(workspace: object) -> None:
def test_regex_files_invalid_regex(workspace: object) -> None:
del workspace
assert "invalid regex" in call_sync(grep_files, "[")
assert "invalid regex" in call_sync(regex_files, "[")
def test_grep_files_skip_git(workspace: object) -> None:
def test_regex_files_skip_git(workspace: object) -> None:
assert isinstance(workspace, Path)
(workspace / ".git").mkdir()
_ = (workspace / ".git" / "x").write_text("secret\n", encoding="utf-8")
_ = (workspace / "ok.txt").write_text("secret\n", encoding="utf-8")
out = call_sync(grep_files, "secret")
out = call_sync(regex_files, "secret")
assert "ok.txt" in out
assert ".git" not in out
def test_grep_files_max_matches(workspace: object) -> None:
def test_regex_files_max_matches(workspace: object) -> None:
assert isinstance(workspace, Path)
lines = "\n".join(f"match {i}" for i in range(10))
_ = (workspace / "m.txt").write_text(lines + "\n", encoding="utf-8")
out = call_sync(grep_files, "match", max_matches=3)
out = call_sync(regex_files, "match", max_matches=3)
assert "truncated" in out
+1 -1
View File
@@ -198,7 +198,7 @@ async def test_skill_search_single_skill_and_errors(tmp_path: Path) -> None:
async def test_skill_search_inside_the_workspace_rebases_the_hit(tmp_path: Path) -> None:
"""A project-scope skill root lives inside the workspace: one path, once.
Grep reports in-workspace files relative to the workspace root and outside
The search reports in-workspace files relative to the workspace root and outside
ones absolutely, so the skill name must never be glued onto a path that
already carries the root.
"""