-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (40 loc) · 1.67 KB
/
conftest.py
File metadata and controls
52 lines (40 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Conftest for plugin tests.
Loads plugin scripts by absolute path since they don't have package structure.
Each module is loaded once and cached by importlib.
"""
import importlib.util
from pathlib import Path
# Root of the plugin scripts
PLUGINS_ROOT = (
Path(__file__).resolve().parent.parent
/ ".devcontainer"
/ "plugins"
/ "devs-marketplace"
/ "plugins"
)
def _load_script(plugin_name: str, script_name: str):
"""Load a plugin script as a Python module.
Args:
plugin_name: Plugin directory name (e.g. "dangerous-command-blocker")
script_name: Script filename (e.g. "block-dangerous.py")
Returns:
The loaded module.
"""
script_path = PLUGINS_ROOT / plugin_name / "scripts" / script_name
if not script_path.exists():
raise FileNotFoundError(f"Plugin script not found: {script_path}")
# Convert filename to valid module name
module_name = script_name.replace("-", "_").replace(".py", "")
spec = importlib.util.spec_from_file_location(module_name, script_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
# Pre-load all tested plugin modules
block_dangerous = _load_script("dangerous-command-blocker", "block-dangerous.py")
guard_workspace_scope = _load_script(
"workspace-scope-guard", "guard-workspace-scope.py"
)
guard_protected = _load_script("protected-files-guard", "guard-protected.py")
guard_protected_bash = _load_script("protected-files-guard", "guard-protected-bash.py")
guard_readonly_bash = _load_script("agent-system", "guard-readonly-bash.py")
redirect_builtin_agents = _load_script("agent-system", "redirect-builtin-agents.py")