janito 3.12.0__py3-none-any.whl → 3.12.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
janito/plugins/builtin.py CHANGED
@@ -1,88 +1,64 @@
1
- """
2
- Builtin plugin system for janito-packaged plugins.
3
-
4
- This module provides the infrastructure for plugins that are bundled
5
- with janito and available by default without requiring external installation.
6
- """
7
-
8
- import importlib
9
- from typing import Dict, List, Optional, Type
10
- from janito.plugins.base import Plugin
11
-
12
-
13
- class BuiltinPluginRegistry:
14
- """Registry for builtin plugins that come packaged with janito."""
15
-
16
- _plugins: Dict[str, Type[Plugin]] = {}
17
-
18
- @classmethod
19
- def register(cls, name: str, plugin_class: Type[Plugin]) -> None:
20
- """Register a builtin plugin."""
21
- cls._plugins[name] = plugin_class
22
-
23
- @classmethod
24
- def get_plugin_class(cls, name: str) -> Optional[Type[Plugin]]:
25
- """Get the plugin class for a builtin plugin."""
26
- return cls._plugins.get(name)
27
-
28
- @classmethod
29
- def list_builtin_plugins(cls) -> List[str]:
30
- """List all registered builtin plugins."""
31
- return list(cls._plugins.keys())
32
-
33
- @classmethod
34
- def is_builtin(cls, name: str) -> bool:
35
- """Check if a plugin is builtin."""
36
- return name in cls._plugins
37
-
38
-
39
- def register_builtin_plugin(name: str):
40
- """Decorator to register a plugin as builtin."""
41
-
42
- def decorator(plugin_class: Type[Plugin]) -> Type[Plugin]:
43
- BuiltinPluginRegistry.register(name, plugin_class)
44
- return plugin_class
45
-
46
- return decorator
47
-
48
-
49
- def load_builtin_plugin(name: str) -> Optional[Plugin]:
50
- """Load a builtin plugin by name."""
51
- plugin_class = BuiltinPluginRegistry.get_plugin_class(name)
52
- if plugin_class:
53
- return plugin_class()
54
- return None
55
-
56
-
57
- # Auto-register janito-coder plugins as builtin
58
- try:
59
- from janito_coder.plugins import (
60
- GitAnalyzerPlugin,
61
- CodeNavigatorPlugin,
62
- DependencyAnalyzerPlugin,
63
- CodeFormatterPlugin,
64
- TestRunnerPlugin,
65
- LinterPlugin,
66
- DebuggerPlugin,
67
- PerformanceProfilerPlugin,
68
- SecurityScannerPlugin,
69
- DocumentationGeneratorPlugin,
70
- )
71
-
72
- # Register all janito-coder plugins as builtin
73
- BuiltinPluginRegistry.register("git_analyzer", GitAnalyzerPlugin)
74
- BuiltinPluginRegistry.register("code_navigator", CodeNavigatorPlugin)
75
- BuiltinPluginRegistry.register("dependency_analyzer", DependencyAnalyzerPlugin)
76
- BuiltinPluginRegistry.register("code_formatter", CodeFormatterPlugin)
77
- BuiltinPluginRegistry.register("test_runner", TestRunnerPlugin)
78
- BuiltinPluginRegistry.register("linter", LinterPlugin)
79
- BuiltinPluginRegistry.register("debugger", DebuggerPlugin)
80
- BuiltinPluginRegistry.register("performance_profiler", PerformanceProfilerPlugin)
81
- BuiltinPluginRegistry.register("security_scanner", SecurityScannerPlugin)
82
- BuiltinPluginRegistry.register(
83
- "documentation_generator", DocumentationGeneratorPlugin
84
- )
85
-
86
- except ImportError:
87
- # janito-coder not available, skip registration
88
- pass
1
+ """
2
+ Builtin plugin system for janito-packaged plugins.
3
+
4
+ This module provides the infrastructure for plugins that are bundled
5
+ with janito and available by default without requiring external installation.
6
+ """
7
+
8
+ import importlib
9
+ from typing import Dict, List, Optional, Type
10
+ from janito.plugins.base import Plugin
11
+
12
+
13
+ class BuiltinPluginRegistry:
14
+ """Registry for builtin plugins that come packaged with janito."""
15
+
16
+ _plugins: Dict[str, Type[Plugin]] = {}
17
+
18
+ @classmethod
19
+ def register(cls, name: str, plugin_class: Type[Plugin]) -> None:
20
+ """Register a builtin plugin."""
21
+ cls._plugins[name] = plugin_class
22
+
23
+ @classmethod
24
+ def get_plugin_class(cls, name: str) -> Optional[Type[Plugin]]:
25
+ """Get the plugin class for a builtin plugin."""
26
+ return cls._plugins.get(name)
27
+
28
+ @classmethod
29
+ def list_builtin_plugins(cls) -> List[str]:
30
+ """List all registered builtin plugins."""
31
+ return list(cls._plugins.keys())
32
+
33
+ @classmethod
34
+ def is_builtin(cls, name: str) -> bool:
35
+ """Check if a plugin is builtin."""
36
+ return name in cls._plugins
37
+
38
+
39
+ def register_builtin_plugin(name: str):
40
+ """Decorator to register a plugin as builtin."""
41
+
42
+ def decorator(plugin_class: Type[Plugin]) -> Type[Plugin]:
43
+ BuiltinPluginRegistry.register(name, plugin_class)
44
+ return plugin_class
45
+
46
+ return decorator
47
+
48
+
49
+ def load_builtin_plugin(name: str) -> Optional[Plugin]:
50
+ """Load a builtin plugin by name."""
51
+ plugin_class = BuiltinPluginRegistry.get_plugin_class(name)
52
+ if plugin_class:
53
+ return plugin_class()
54
+ return None
55
+
56
+
57
+ # Note: External plugin packages can be registered here if needed
58
+ # For example, to auto-register plugins from external packages:
59
+ # try:
60
+ # from external_package.plugins import SomePlugin
61
+ # BuiltinPluginRegistry.register("some_plugin", SomePlugin)
62
+ # except ImportError:
63
+ # # external_package not available, skip registration
64
+ # pass