tooling and docs

This commit is contained in:
2025-09-18 22:54:40 +02:00
parent d07eb7dfd4
commit ca3ebcf02a
13 changed files with 1522 additions and 411 deletions

36
src/tools/__init__.py Normal file
View File

@@ -0,0 +1,36 @@
import os
import importlib
from typing import List, Dict
from .base_tool import BaseTool
def discover_tools() -> Dict[str, BaseTool]:
"""Auto-discover and load all tools"""
tools = {}
tools_dir = os.path.dirname(__file__)
for item in os.listdir(tools_dir):
tool_path = os.path.join(tools_dir, item)
if os.path.isdir(tool_path) and not item.startswith('_'):
try:
# Import the tool module
module = importlib.import_module(f'tools.{item}.tool')
# Find Tool class (should be named like CensorTool, etc.)
for attr_name in dir(module):
attr = getattr(module, attr_name)
if (isinstance(attr, type) and
issubclass(attr, BaseTool) and
attr != BaseTool):
tool_instance = attr()
# Only register enabled tools
if tool_instance.enabled:
tools[tool_instance.baseroute] = tool_instance
break
except ImportError as e:
print(f"Failed to load tool {item}: {e}")
return tools
TOOLS = discover_tools()