Update.
Tests / test (macos-latest, 3.10) (push) Waiting to run
Tests / test (macos-latest, 3.11) (push) Waiting to run
Tests / test (macos-latest, 3.12) (push) Waiting to run
Tests / test (macos-latest, 3.8) (push) Waiting to run
Tests / test (macos-latest, 3.9) (push) Waiting to run
Tests / test (ubuntu-latest, 3.8) (push) Waiting to run
Tests / test (ubuntu-latest, 3.9) (push) Waiting to run
Tests / test (windows-latest, 3.10) (push) Waiting to run
Tests / test (windows-latest, 3.11) (push) Waiting to run
Tests / test (windows-latest, 3.12) (push) Waiting to run
Tests / test (windows-latest, 3.8) (push) Waiting to run
Tests / test (windows-latest, 3.9) (push) Waiting to run
Lint / lint (push) Failing after 39s
Tests / test (ubuntu-latest, 3.10) (push) Successful in 55s
Tests / test (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / test (ubuntu-latest, 3.12) (push) Has been cancelled

This commit is contained in:
2025-11-04 08:09:12 +01:00
parent 5f04811dcc
commit 1a29ee4918
82 changed files with 4963 additions and 3094 deletions
+14 -9
View File
@@ -1,10 +1,11 @@
import importlib.util
import os
import sys
import importlib.util
from typing import List, Dict, Callable, Any
from typing import Callable, Dict, List
from pr.core.logging import get_logger
logger = get_logger('plugins')
logger = get_logger("plugins")
PLUGINS_DIR = os.path.expanduser("~/.pr/plugins")
@@ -21,7 +22,7 @@ class PluginLoader:
logger.info("No plugins directory found")
return []
plugin_files = [f for f in os.listdir(PLUGINS_DIR) if f.endswith('.py')]
plugin_files = [f for f in os.listdir(PLUGINS_DIR) if f.endswith(".py")]
for plugin_file in plugin_files:
try:
@@ -44,16 +45,20 @@ class PluginLoader:
sys.modules[plugin_name] = module
spec.loader.exec_module(module)
if hasattr(module, 'register_tools'):
if hasattr(module, "register_tools"):
tools = module.register_tools()
if isinstance(tools, list):
self.plugin_tools.extend(tools)
self.loaded_plugins[plugin_name] = module
logger.info(f"Loaded plugin: {plugin_name} ({len(tools)} tools)")
else:
logger.warning(f"Plugin {plugin_name} register_tools() did not return a list")
logger.warning(
f"Plugin {plugin_name} register_tools() did not return a list"
)
else:
logger.warning(f"Plugin {plugin_name} does not have register_tools() function")
logger.warning(
f"Plugin {plugin_name} does not have register_tools() function"
)
def get_plugin_function(self, tool_name: str) -> Callable:
for plugin_name, module in self.loaded_plugins.items():
@@ -67,7 +72,7 @@ class PluginLoader:
def create_example_plugin():
example_plugin = os.path.join(PLUGINS_DIR, 'example_plugin.py')
example_plugin = os.path.join(PLUGINS_DIR, "example_plugin.py")
if os.path.exists(example_plugin):
return
@@ -121,7 +126,7 @@ def register_tools():
try:
os.makedirs(PLUGINS_DIR, exist_ok=True)
with open(example_plugin, 'w') as f:
with open(example_plugin, "w") as f:
f.write(example_code)
logger.info(f"Created example plugin at {example_plugin}")
except Exception as e: