janito 3.1.0__py3-none-any.whl → 3.3.0__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.
Files changed (156) hide show
  1. janito/cli/chat_mode/bindings.py +0 -26
  2. janito/cli/chat_mode/session.py +1 -7
  3. janito/cli/cli_commands/list_plugins.py +8 -13
  4. janito/cli/prompt_core.py +9 -19
  5. janito/llm/agent.py +17 -30
  6. janito/llm/driver.py +0 -7
  7. janito/plugins/__init__.py +21 -29
  8. janito/plugins/__main__.py +85 -0
  9. janito/plugins/base.py +57 -0
  10. janito/plugins/builtin.py +1 -1
  11. janito/plugins/core/filemanager/tools/copy_file.py +25 -1
  12. janito/plugins/core/filemanager/tools/create_directory.py +28 -1
  13. janito/plugins/core/filemanager/tools/create_file.py +25 -1
  14. janito/plugins/core/filemanager/tools/delete_text_in_file.py +1 -0
  15. janito/plugins/core/imagedisplay/plugin.py +1 -1
  16. janito/plugins/core_loader.py +144 -0
  17. janito/plugins/discovery.py +3 -3
  18. janito/plugins/example_plugin.py +1 -1
  19. janito/plugins/manager.py +1 -1
  20. janito/plugins_backup_20250825_070018/__init__.py +36 -0
  21. janito/plugins_backup_20250825_070018/builtin.py +102 -0
  22. janito/plugins_backup_20250825_070018/config.py +84 -0
  23. janito/plugins_backup_20250825_070018/core/__init__.py +7 -0
  24. janito/plugins_backup_20250825_070018/core/codeanalyzer/__init__.py +43 -0
  25. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/__init__.py +1 -0
  26. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/core.py +122 -0
  27. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/__init__.py +1 -0
  28. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/core.py +205 -0
  29. janito/plugins_backup_20250825_070018/core/filemanager/__init__.py +124 -0
  30. janito/plugins_backup_20250825_070018/core/filemanager/tools/copy_file.py +87 -0
  31. janito/plugins_backup_20250825_070018/core/filemanager/tools/create_directory.py +70 -0
  32. janito/plugins_backup_20250825_070018/core/filemanager/tools/create_file.py +87 -0
  33. janito/plugins_backup_20250825_070018/core/filemanager/tools/delete_text_in_file.py +135 -0
  34. janito/plugins_backup_20250825_070018/core/filemanager/tools/find_files.py +143 -0
  35. janito/plugins_backup_20250825_070018/core/filemanager/tools/move_file.py +131 -0
  36. janito/plugins_backup_20250825_070018/core/filemanager/tools/read_files.py +58 -0
  37. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_directory.py +55 -0
  38. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_file.py +58 -0
  39. janito/plugins_backup_20250825_070018/core/filemanager/tools/replace_text_in_file.py +270 -0
  40. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/__init__.py +1 -0
  41. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/core.py +114 -0
  42. janito/plugins_backup_20250825_070018/core/filemanager/tools/view_file.py +172 -0
  43. janito/plugins_backup_20250825_070018/core/imagedisplay/__init__.py +14 -0
  44. janito/plugins_backup_20250825_070018/core/imagedisplay/plugin.py +51 -0
  45. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/__init__.py +1 -0
  46. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image.py +83 -0
  47. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image_grid.py +84 -0
  48. janito/plugins_backup_20250825_070018/core/system/__init__.py +23 -0
  49. janito/plugins_backup_20250825_070018/core/system/tools/run_bash_command.py +183 -0
  50. janito/plugins_backup_20250825_070018/core/system/tools/run_powershell_command.py +218 -0
  51. janito/plugins_backup_20250825_070018/dev/__init__.py +7 -0
  52. janito/plugins_backup_20250825_070018/dev/pythondev/__init__.py +37 -0
  53. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_code_run.py +172 -0
  54. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_command_run.py +171 -0
  55. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_file_run.py +172 -0
  56. janito/plugins_backup_20250825_070018/dev/visualization/__init__.py +23 -0
  57. janito/plugins_backup_20250825_070018/dev/visualization/tools/read_chart.py +259 -0
  58. janito/plugins_backup_20250825_070018/discovery.py +289 -0
  59. janito/plugins_backup_20250825_070018/example_plugin.py +108 -0
  60. janito/plugins_backup_20250825_070018/manager.py +243 -0
  61. janito/{plugins → plugins_backup_20250825_070018}/tools/delete_text_in_file.py +1 -0
  62. janito/plugins_backup_20250825_070018/tools/get_file_outline/java_outline.py +47 -0
  63. janito/plugins_backup_20250825_070018/tools/get_file_outline/markdown_outline.py +14 -0
  64. janito/plugins_backup_20250825_070018/tools/get_file_outline/python_outline.py +303 -0
  65. janito/plugins_backup_20250825_070018/tools/get_file_outline/search_outline.py +36 -0
  66. janito/plugins_backup_20250825_070018/tools/search_text/match_lines.py +67 -0
  67. janito/plugins_backup_20250825_070018/tools/search_text/pattern_utils.py +73 -0
  68. janito/plugins_backup_20250825_070018/tools/search_text/traverse_directory.py +145 -0
  69. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/css_validator.py +35 -0
  70. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/html_validator.py +100 -0
  71. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/jinja2_validator.py +50 -0
  72. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/js_validator.py +27 -0
  73. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/json_validator.py +6 -0
  74. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/markdown_validator.py +109 -0
  75. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/ps1_validator.py +32 -0
  76. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/python_validator.py +5 -0
  77. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/xml_validator.py +11 -0
  78. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/yaml_validator.py +6 -0
  79. janito/plugins_backup_20250825_070018/ui/__init__.py +7 -0
  80. janito/plugins_backup_20250825_070018/ui/userinterface/__init__.py +16 -0
  81. janito/plugins_backup_20250825_070018/ui/userinterface/tools/ask_user.py +110 -0
  82. janito/plugins_backup_20250825_070018/web/__init__.py +7 -0
  83. janito/plugins_backup_20250825_070018/web/webtools/__init__.py +33 -0
  84. janito/plugins_backup_20250825_070018/web/webtools/tools/fetch_url.py +458 -0
  85. janito/plugins_backup_20250825_070018/web/webtools/tools/open_html_in_browser.py +51 -0
  86. janito/plugins_backup_20250825_070018/web/webtools/tools/open_url.py +37 -0
  87. janito/tools/base.py +31 -1
  88. janito/tools/cli_initializer.py +1 -1
  89. janito/tools/function_adapter.py +35 -1
  90. janito/tools/initialize.py +1 -1
  91. janito/tools/tool_base.py +142 -114
  92. janito/tools/tools_schema.py +12 -6
  93. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/METADATA +1 -1
  94. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/RECORD +154 -87
  95. janito/llm/cancellation_manager.py +0 -62
  96. janito/llm/enter_cancellation.py +0 -93
  97. /janito/{plugin_system → plugin_system_backup_20250825_070018}/__init__.py +0 -0
  98. /janito/{plugin_system → plugin_system_backup_20250825_070018}/base.py +0 -0
  99. /janito/{plugin_system → plugin_system_backup_20250825_070018}/core_loader.py +0 -0
  100. /janito/{plugin_system → plugin_system_backup_20250825_070018}/core_loader_fixed.py +0 -0
  101. /janito/{plugins → plugins_backup_20250825_070018}/auto_loader.py +0 -0
  102. /janito/{plugins → plugins_backup_20250825_070018}/auto_loader_fixed.py +0 -0
  103. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/java_outline.py +0 -0
  104. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/markdown_outline.py +0 -0
  105. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/python_outline.py +0 -0
  106. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/get_file_outline/search_outline.py +0 -0
  107. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/match_lines.py +0 -0
  108. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/pattern_utils.py +0 -0
  109. /janito/{plugins → plugins_backup_20250825_070018/core/codeanalyzer}/tools/search_text/traverse_directory.py +0 -0
  110. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/css_validator.py +0 -0
  111. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/html_validator.py +0 -0
  112. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/jinja2_validator.py +0 -0
  113. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/js_validator.py +0 -0
  114. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/json_validator.py +0 -0
  115. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/markdown_validator.py +0 -0
  116. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/ps1_validator.py +0 -0
  117. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/python_validator.py +0 -0
  118. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/xml_validator.py +0 -0
  119. /janito/{plugins → plugins_backup_20250825_070018/core/filemanager}/tools/validate_file_syntax/yaml_validator.py +0 -0
  120. /janito/{plugins → plugins_backup_20250825_070018}/core_adapter.py +0 -0
  121. /janito/{plugins → plugins_backup_20250825_070018}/discovery_core.py +0 -0
  122. /janito/{plugins → plugins_backup_20250825_070018}/tools/__init__.py +0 -0
  123. /janito/{plugins → plugins_backup_20250825_070018}/tools/ask_user.py +0 -0
  124. /janito/{plugins → plugins_backup_20250825_070018}/tools/copy_file.py +0 -0
  125. /janito/{plugins → plugins_backup_20250825_070018}/tools/core_tools_plugin.py +0 -0
  126. /janito/{plugins → plugins_backup_20250825_070018}/tools/create_directory.py +0 -0
  127. /janito/{plugins → plugins_backup_20250825_070018}/tools/create_file.py +0 -0
  128. /janito/{plugins → plugins_backup_20250825_070018}/tools/decorators.py +0 -0
  129. /janito/{plugins → plugins_backup_20250825_070018}/tools/fetch_url.py +0 -0
  130. /janito/{plugins → plugins_backup_20250825_070018}/tools/find_files.py +0 -0
  131. /janito/{plugins → plugins_backup_20250825_070018}/tools/get_file_outline/__init__.py +0 -0
  132. /janito/{plugins → plugins_backup_20250825_070018}/tools/get_file_outline/core.py +0 -0
  133. /janito/{plugins → plugins_backup_20250825_070018}/tools/move_file.py +0 -0
  134. /janito/{plugins → plugins_backup_20250825_070018}/tools/open_html_in_browser.py +0 -0
  135. /janito/{plugins → plugins_backup_20250825_070018}/tools/open_url.py +0 -0
  136. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_code_run.py +0 -0
  137. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_command_run.py +0 -0
  138. /janito/{plugins → plugins_backup_20250825_070018}/tools/python_file_run.py +0 -0
  139. /janito/{plugins → plugins_backup_20250825_070018}/tools/read_chart.py +0 -0
  140. /janito/{plugins → plugins_backup_20250825_070018}/tools/read_files.py +0 -0
  141. /janito/{plugins → plugins_backup_20250825_070018}/tools/remove_directory.py +0 -0
  142. /janito/{plugins → plugins_backup_20250825_070018}/tools/remove_file.py +0 -0
  143. /janito/{plugins → plugins_backup_20250825_070018}/tools/replace_text_in_file.py +0 -0
  144. /janito/{plugins → plugins_backup_20250825_070018}/tools/run_bash_command.py +0 -0
  145. /janito/{plugins → plugins_backup_20250825_070018}/tools/run_powershell_command.py +0 -0
  146. /janito/{plugins → plugins_backup_20250825_070018}/tools/search_text/__init__.py +0 -0
  147. /janito/{plugins → plugins_backup_20250825_070018}/tools/search_text/core.py +0 -0
  148. /janito/{plugins → plugins_backup_20250825_070018}/tools/show_image.py +0 -0
  149. /janito/{plugins → plugins_backup_20250825_070018}/tools/show_image_grid.py +0 -0
  150. /janito/{plugins → plugins_backup_20250825_070018}/tools/validate_file_syntax/__init__.py +0 -0
  151. /janito/{plugins → plugins_backup_20250825_070018}/tools/validate_file_syntax/core.py +0 -0
  152. /janito/{plugins → plugins_backup_20250825_070018}/tools/view_file.py +0 -0
  153. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/WHEEL +0 -0
  154. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/entry_points.txt +0 -0
  155. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/licenses/LICENSE +0 -0
  156. {janito-3.1.0.dist-info → janito-3.3.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,144 @@
1
+ """
2
+ Fixed core plugin loader.
3
+
4
+ This module provides a working implementation to load core plugins
5
+ by directly using the Plugin base class properly.
6
+ """
7
+
8
+ import importlib
9
+ import importlib.util
10
+ import sys
11
+ from pathlib import Path
12
+ from typing import Optional, List, Type
13
+
14
+ from .base import Plugin, PluginMetadata
15
+ from janito.tools.function_adapter import create_function_tool
16
+ from janito.tools.tool_base import ToolBase
17
+
18
+
19
+ class CorePlugin(Plugin):
20
+ """Working core plugin implementation."""
21
+
22
+ def __init__(self, name: str, description: str, tools: list):
23
+ self._plugin_name = name
24
+ self._description = description
25
+ self._tools = tools
26
+ self._tool_classes = []
27
+ super().__init__() # Call super after setting attributes
28
+
29
+ def get_metadata(self) -> PluginMetadata:
30
+ return PluginMetadata(
31
+ name=self._plugin_name,
32
+ version="1.0.0",
33
+ description=self._description,
34
+ author="Janito",
35
+ license="MIT",
36
+ )
37
+
38
+ def get_tools(self) -> List[Type[ToolBase]]:
39
+ return self._tool_classes
40
+
41
+ def initialize(self):
42
+ """Initialize by creating tool classes."""
43
+ self._tool_classes = []
44
+ for tool_func in self._tools:
45
+ if callable(tool_func):
46
+ tool_class = create_function_tool(tool_func)
47
+ self._tool_classes.append(tool_class)
48
+
49
+
50
+ def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
51
+ """
52
+ Load a core plugin by name.
53
+
54
+ Args:
55
+ plugin_name: Name of the plugin (e.g., 'core.filemanager')
56
+
57
+ Returns:
58
+ Plugin instance if loaded successfully
59
+ """
60
+ try:
61
+ # Parse plugin name
62
+ if "." not in plugin_name:
63
+ return None
64
+
65
+ parts = plugin_name.split(".")
66
+ if len(parts) != 2:
67
+ return None
68
+
69
+ package_name, submodule_name = parts
70
+
71
+ # Handle imagedisplay specially
72
+ if plugin_name == "core.imagedisplay":
73
+ # Import the actual plugin class
74
+ try:
75
+ # Use dynamic import to avoid circular dependency
76
+ plugin_module = importlib.import_module(
77
+ "janito.plugins.core.imagedisplay.plugin"
78
+ )
79
+ return plugin_module.ImageDisplayPlugin()
80
+ except ImportError as e:
81
+ print(f"Failed to load imagedisplay: {e}")
82
+ return None
83
+
84
+ # Build path to plugin
85
+ plugin_path = (
86
+ Path("janito/plugins") / package_name / submodule_name / "__init__.py"
87
+ )
88
+ if not plugin_path.exists():
89
+ return None
90
+
91
+ # Load the module
92
+ spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
93
+ if spec is None or spec.loader is None:
94
+ return None
95
+
96
+ module = importlib.util.module_from_spec(spec)
97
+ spec.loader.exec_module(module)
98
+
99
+ # Get plugin info
100
+ name = getattr(module, "__plugin_name__", plugin_name)
101
+ description = getattr(
102
+ module, "__plugin_description__", f"Core plugin: {plugin_name}"
103
+ )
104
+ tools = getattr(module, "__plugin_tools__", [])
105
+
106
+ if not tools:
107
+ return None
108
+
109
+ # Filter out None values and ensure all tools have tool_name
110
+ valid_tools = []
111
+ for tool in tools:
112
+ if tool is not None:
113
+ if not hasattr(tool, "tool_name"):
114
+ tool.tool_name = tool.__name__
115
+ valid_tools.append(tool)
116
+
117
+ if not valid_tools:
118
+ return None
119
+
120
+ # Create plugin
121
+ plugin = CorePlugin(name, description, valid_tools)
122
+ plugin.initialize()
123
+ return plugin
124
+
125
+ except Exception as e:
126
+ print(f"Error loading core plugin {plugin_name}: {e}")
127
+ return None
128
+
129
+
130
+ def get_core_plugins() -> list:
131
+ """Get list of all available core plugins."""
132
+ core_plugins = [
133
+ "core.filemanager",
134
+ "core.codeanalyzer",
135
+ "core.system",
136
+ "core.imagedisplay",
137
+ "dev.pythondev",
138
+ "dev.visualization",
139
+ "ui.userinterface",
140
+ "web.webtools",
141
+ ]
142
+
143
+ # All core plugins are always available
144
+ return core_plugins
@@ -31,9 +31,9 @@ from pathlib import Path
31
31
  from typing import Optional, List
32
32
  import logging
33
33
 
34
- from janito.plugin_system.base import Plugin
34
+ from .base import Plugin
35
35
  from .builtin import load_builtin_plugin, BuiltinPluginRegistry
36
- from janito.plugin_system.core_loader import load_core_plugin
36
+ from .core_loader import load_core_plugin
37
37
 
38
38
  logger = logging.getLogger(__name__)
39
39
 
@@ -157,7 +157,7 @@ def _load_plugin_from_file(
157
157
 
158
158
  # Check for package-based plugin with __plugin_name__ metadata
159
159
  if hasattr(module, "__plugin_name__"):
160
- from janito.plugin_system.base import PluginMetadata
160
+ from .base import PluginMetadata
161
161
 
162
162
  # Create a dynamic plugin class
163
163
  class PackagePlugin(Plugin):
@@ -2,7 +2,7 @@
2
2
  Example plugin demonstrating the plugin system.
3
3
  """
4
4
 
5
- from janito.plugin_system.base import Plugin, PluginMetadata, PluginResource
5
+ from .base import Plugin, PluginMetadata, PluginResource
6
6
  from janito.tools.tool_base import ToolBase, ToolPermissions
7
7
  from typing import Dict, Any
8
8
 
janito/plugins/manager.py CHANGED
@@ -10,7 +10,7 @@ from pathlib import Path
10
10
  from typing import Dict, List, Optional, Any
11
11
  import logging
12
12
 
13
- from janito.plugin_system.base import Plugin, PluginMetadata
13
+ from .base import Plugin, PluginMetadata
14
14
  from .discovery import discover_plugins
15
15
  from .config import load_plugins_config, get_user_plugins_dir
16
16
  from .builtin import BuiltinPluginRegistry, load_builtin_plugin
@@ -0,0 +1,36 @@
1
+ """
2
+ Plugin System for Development Tools
3
+
4
+ This package organizes all available tools into logical plugin groups
5
+ for easier discovery and usage.
6
+ """
7
+
8
+ __version__ = "1.0.0"
9
+ __author__ = "Development Assistant"
10
+
11
+ from .core import filemanager, codeanalyzer, system, imagedisplay
12
+ from .web import webtools
13
+ from .dev import pythondev, visualization
14
+ from .ui import userinterface
15
+
16
+ # Plugin registry
17
+ PLUGINS = {
18
+ "core.filemanager": filemanager,
19
+ "core.codeanalyzer": codeanalyzer,
20
+ "core.system": system,
21
+ "core.imagedisplay": imagedisplay,
22
+ "web.webtools": webtools,
23
+ "dev.pythondev": pythondev,
24
+ "dev.visualization": visualization,
25
+ "ui.userinterface": userinterface,
26
+ }
27
+
28
+
29
+ def list_plugins():
30
+ """Return all available plugins"""
31
+ return list(PLUGINS.keys())
32
+
33
+
34
+ def get_plugin(name):
35
+ """Get a specific plugin by name"""
36
+ return PLUGINS.get(name)
@@ -0,0 +1,102 @@
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.plugin_system.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
+ # Register core tools plugin
87
+ from janito.plugins.tools import CoreToolsPlugin
88
+
89
+ BuiltinPluginRegistry.register("core_tools", CoreToolsPlugin)
90
+
91
+ except ImportError:
92
+ # janito-coder not available, skip registration
93
+ pass
94
+
95
+ # Register core tools plugin (always available)
96
+ try:
97
+ from janito.plugins.tools import CoreToolsPlugin
98
+
99
+ BuiltinPluginRegistry.register("core_tools", CoreToolsPlugin)
100
+ except ImportError:
101
+ # Should not happen, but handle gracefully
102
+ pass
@@ -0,0 +1,84 @@
1
+ """
2
+ Configuration management for plugins using user directory.
3
+ """
4
+
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ from typing import Dict, Any, Optional
9
+
10
+
11
+ def get_user_config_dir() -> Path:
12
+ """Get the user configuration directory."""
13
+ return Path.home() / ".janito"
14
+
15
+
16
+ def get_plugins_config_path() -> Path:
17
+ """Get the path to the plugins configuration file."""
18
+ return get_user_config_dir() / "plugins.json"
19
+
20
+
21
+ def load_plugins_config() -> Dict[str, Any]:
22
+ """
23
+ Load plugins configuration from user directory.
24
+
25
+ Returns:
26
+ Dict containing plugins configuration
27
+ """
28
+ config_path = get_plugins_config_path()
29
+
30
+ if not config_path.exists():
31
+ # Create default config if it doesn't exist
32
+ default_config = {
33
+ "plugins": {
34
+ "paths": [str(Path.home() / ".janito" / "plugins"), "./plugins"],
35
+ "load": {},
36
+ }
37
+ }
38
+
39
+ # Ensure directory exists
40
+ config_path.parent.mkdir(parents=True, exist_ok=True)
41
+
42
+ # Save default config
43
+ with open(config_path, "w") as f:
44
+ json.dump(default_config, f, indent=2)
45
+
46
+ return default_config
47
+
48
+ try:
49
+ with open(config_path, "r") as f:
50
+ return json.load(f)
51
+ except (json.JSONDecodeError, IOError) as e:
52
+ print(f"Warning: Failed to load plugins config from {config_path}: {e}")
53
+ return {"plugins": {"paths": [], "load": {}}}
54
+
55
+
56
+ def save_plugins_config(config: Dict[str, Any]) -> bool:
57
+ """
58
+ Save plugins configuration to user directory.
59
+
60
+ Args:
61
+ config: Configuration dict to save
62
+
63
+ Returns:
64
+ True if saved successfully
65
+ """
66
+ config_path = get_plugins_config_path()
67
+
68
+ try:
69
+ # Ensure directory exists
70
+ config_path.parent.mkdir(parents=True, exist_ok=True)
71
+
72
+ with open(config_path, "w") as f:
73
+ json.dump(config, f, indent=2)
74
+ return True
75
+ except IOError as e:
76
+ print(f"Error: Failed to save plugins config to {config_path}: {e}")
77
+ return False
78
+
79
+
80
+ def get_user_plugins_dir() -> Path:
81
+ """Get the user plugins directory."""
82
+ plugins_dir = get_user_config_dir() / "plugins"
83
+ plugins_dir.mkdir(parents=True, exist_ok=True)
84
+ return plugins_dir
@@ -0,0 +1,7 @@
1
+ """
2
+ Core Plugin Package
3
+
4
+ Contains essential system and file management plugins.
5
+ """
6
+
7
+ __all__ = ["filemanager", "codeanalyzer", "system"]
@@ -0,0 +1,43 @@
1
+ """
2
+ Code Analyzer Plugin
3
+
4
+ Tools for understanding and searching code structure.
5
+ """
6
+
7
+ from typing import List, Optional
8
+
9
+
10
+ def get_file_outline(path: str) -> str:
11
+ """Get file structure (classes, functions, etc.)"""
12
+ return f"get_file_outline(path='{path}')"
13
+
14
+
15
+ get_file_outline.tool_name = "get_file_outline"
16
+
17
+
18
+ def search_outline(path: str) -> str:
19
+ """Search within file outlines"""
20
+ return f"search_outline(path='{path}')"
21
+
22
+
23
+ search_outline.tool_name = "search_outline"
24
+
25
+
26
+ def search_text(
27
+ paths: str,
28
+ query: str,
29
+ use_regex: bool = False,
30
+ case_sensitive: bool = True,
31
+ max_depth: Optional[int] = None,
32
+ ) -> str:
33
+ """Full-text search across files with regex support"""
34
+ return f"search_text(paths='{paths}', query='{query}', regex={use_regex})"
35
+
36
+
37
+ search_text.tool_name = "search_text"
38
+
39
+
40
+ # Plugin metadata
41
+ __plugin_name__ = "core.codeanalyzer"
42
+ __plugin_description__ = "Code analysis and structure understanding"
43
+ __plugin_tools__ = [get_file_outline, search_outline, search_text]
@@ -0,0 +1 @@
1
+ # Outline tools and parsers package
@@ -0,0 +1,122 @@
1
+ from janito.tools.adapters.local.adapter import register_local_tool
2
+ from .python_outline import parse_python_outline
3
+ from .markdown_outline import parse_markdown_outline
4
+ from janito.formatting import OutlineFormatter
5
+ from .java_outline import parse_java_outline
6
+ import os
7
+ from janito.tools.path_utils import expand_path
8
+ from janito.tools.tool_base import ToolBase, ToolPermissions
9
+ from janito.report_events import ReportAction
10
+ from janito.tools.tool_utils import display_path, pluralize
11
+ from janito.i18n import tr
12
+
13
+ from janito.tools.adapters.local.adapter import register_local_tool as register_tool
14
+ from janito.tools.loop_protection_decorator import protect_against_loops
15
+
16
+
17
+ @register_tool
18
+ class GetFileOutlineTool(ToolBase):
19
+ """
20
+ Get an outline of a file's structure. Supports Python and Markdown files.
21
+
22
+ Args:
23
+ path (str): Path to the file to outline.
24
+ """
25
+
26
+ permissions = ToolPermissions(read=True)
27
+ tool_name = "get_file_outline"
28
+
29
+ @protect_against_loops(max_calls=5, time_window=10.0, key_field="path")
30
+ def run(self, path: str) -> str:
31
+ try:
32
+ path = expand_path(path)
33
+ self.report_action(
34
+ tr(
35
+ "📄 Outline file '{disp_path}' ...",
36
+ disp_path=display_path(path),
37
+ ),
38
+ ReportAction.READ,
39
+ )
40
+ ext = os.path.splitext(path)[1].lower()
41
+ with open(path, "r", encoding="utf-8", errors="replace") as f:
42
+ lines = f.readlines()
43
+ return self._outline_by_extension(ext, lines)
44
+ except Exception as e:
45
+ self.report_error(
46
+ tr("❌ Error reading file: {error}", error=e),
47
+ ReportAction.READ,
48
+ )
49
+ return tr("Error reading file: {error}", error=e)
50
+
51
+ def _outline_by_extension(self, ext, lines):
52
+ if ext == ".py":
53
+ outline_items = parse_python_outline(lines)
54
+ outline_type = "python"
55
+ table = OutlineFormatter.format_outline_table(outline_items)
56
+ self.report_success(
57
+ tr(
58
+ "✅ Outlined {count} {item_word}",
59
+ count=len(outline_items),
60
+ item_word=pluralize("item", len(outline_items)),
61
+ ),
62
+ ReportAction.READ,
63
+ )
64
+ return (
65
+ tr(
66
+ "Outline: {count} items ({outline_type})\n",
67
+ count=len(outline_items),
68
+ outline_type=outline_type,
69
+ )
70
+ + table
71
+ )
72
+ elif ext == ".md":
73
+ outline_items = parse_markdown_outline(lines)
74
+ outline_type = "markdown"
75
+ table = OutlineFormatter.format_markdown_outline_table(outline_items)
76
+ self.report_success(
77
+ tr(
78
+ "✅ Outlined {count} {item_word}",
79
+ count=len(outline_items),
80
+ item_word=pluralize("item", len(outline_items)),
81
+ ),
82
+ ReportAction.READ,
83
+ )
84
+ return (
85
+ tr(
86
+ "Outline: {count} items ({outline_type})\n",
87
+ count=len(outline_items),
88
+ outline_type=outline_type,
89
+ )
90
+ + table
91
+ )
92
+ elif ext == ".java":
93
+ outline_items = parse_java_outline(lines)
94
+ outline_type = "java"
95
+ table = OutlineFormatter.format_outline_table(outline_items)
96
+ self.report_success(
97
+ tr(
98
+ "✅ Outlined {count} {item_word}",
99
+ count=len(outline_items),
100
+ item_word=pluralize("item", len(outline_items)),
101
+ ),
102
+ ReportAction.READ,
103
+ )
104
+ return (
105
+ tr(
106
+ "Outline: {count} items ({outline_type})\n",
107
+ count=len(outline_items),
108
+ outline_type=outline_type,
109
+ )
110
+ + table
111
+ )
112
+ else:
113
+ outline_type = "default"
114
+ self.report_success(
115
+ tr("✅ Outlined {count} items", count=len(lines)),
116
+ ReportAction.READ,
117
+ )
118
+ return tr(
119
+ "Outline: {count} lines ({outline_type})\nFile has {count} lines.",
120
+ count=len(lines),
121
+ outline_type=outline_type,
122
+ )
@@ -0,0 +1 @@
1
+ from .core import SearchTextTool