more organization
This commit is contained in:
+8
-14
@@ -114,8 +114,8 @@ def configure(file_items: list[dict[str, Any]], extra_base_dirs: list[str] | Non
|
||||
[C: tests/conftest.py:reset_ai_client, tests/test_arch_boundary_phase1.py:TestArchBoundaryPhase1.test_mcp_client_whitelist_enforcement, tests/test_mcp_client_beads.py:test_bd_mcp_tools, tests/test_py_struct_tools.py:test_mcp_dispatch_errors, tests/test_py_struct_tools.py:test_mcp_dispatch_integration]
|
||||
"""
|
||||
global _allowed_paths, _base_dirs, _primary_base_dir
|
||||
_allowed_paths = set()
|
||||
_base_dirs = set()
|
||||
_allowed_paths = set()
|
||||
_base_dirs = set()
|
||||
_primary_base_dir = Path(extra_base_dirs[0]).resolve() if extra_base_dirs else Path.cwd()
|
||||
for item in file_items:
|
||||
p = item.get("path")
|
||||
@@ -154,10 +154,8 @@ def _is_allowed(path: Path) -> bool:
|
||||
rp = path.resolve()
|
||||
|
||||
# Blacklist check by resolved path
|
||||
if rp == get_config_path().resolve():
|
||||
return False
|
||||
if rp == get_credentials_path().resolve():
|
||||
return False
|
||||
if rp == get_config_path().resolve(): return False
|
||||
if rp == get_credentials_path().resolve(): return False
|
||||
|
||||
name = path.name.lower()
|
||||
if name == "history.toml" or name.endswith("_history.toml"):
|
||||
@@ -209,10 +207,8 @@ def read_file(path: str) -> str:
|
||||
p, err = _resolve_and_check(path)
|
||||
if err or p is None:
|
||||
return err
|
||||
if not p.exists():
|
||||
return f"ERROR: file not found: {path}"
|
||||
if not p.is_file():
|
||||
return f"ERROR: not a file: {path}"
|
||||
if not p.exists(): return f"ERROR: file not found: {path}"
|
||||
if not p.is_file(): return f"ERROR: not a file: {path}"
|
||||
try:
|
||||
return p.read_text(encoding="utf-8")
|
||||
except Exception as e:
|
||||
@@ -223,10 +219,8 @@ def list_directory(path: str) -> str:
|
||||
p, err = _resolve_and_check(path)
|
||||
if err or p is None:
|
||||
return err
|
||||
if not p.exists():
|
||||
return f"ERROR: path not found: {path}"
|
||||
if not p.is_dir():
|
||||
return f"ERROR: not a directory: {path}"
|
||||
if not p.exists(): return f"ERROR: path not found: {path}"
|
||||
if not p.is_dir(): return f"ERROR: not a directory: {path}"
|
||||
try:
|
||||
entries = sorted(p.iterdir(), key=lambda e: (e.is_file(), e.name.lower()))
|
||||
lines = [f"Directory: {p}", ""]
|
||||
|
||||
Reference in New Issue
Block a user