janito 3.3.0__py3-none-any.whl → 3.4.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.
- janito/cli/cli_commands/list_plugins.py +48 -52
- janito/cli/core/getters.py +0 -3
- janito/cli/main_cli.py +12 -9
- janito/drivers/openai/driver.py +0 -1
- janito/drivers/zai/driver.py +0 -1
- janito/hello.txt +0 -0
- janito/llm/auth_utils.py +5 -14
- janito/plugins/__init__.py +7 -18
- janito/{plugins_backup_20250825_070018 → plugins}/auto_loader_fixed.py +11 -12
- janito/plugins/base.py +152 -57
- janito/plugins/builtin.py +1 -15
- janito/{plugins_backup_20250825_070018 → plugins}/core_adapter.py +9 -11
- janito/plugins/core_loader.py +34 -58
- janito/{plugin_system_backup_20250825_070018/core_loader.py → plugins/core_loader_fixed.py} +26 -45
- janito/plugins/discovery.py +3 -3
- janito/tools/__init__.py +7 -31
- janito/tools/adapters/__init__.py +1 -6
- janito/tools/adapters/local/__init__.py +70 -7
- janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/ask_user.py +3 -3
- janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/create_file.py +4 -4
- janito/{plugins/core/filemanager/tools → tools/adapters/local}/delete_text_in_file.py +0 -1
- janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/fetch_url.py +3 -3
- janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/replace_text_in_file.py +4 -4
- janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/show_image.py +6 -15
- janito/{plugins/core/imagedisplay/tools → tools/adapters/local}/show_image_grid.py +5 -13
- janito/tools/base.py +1 -31
- janito/tools/function_adapter.py +16 -127
- janito/tools/tool_base.py +114 -142
- janito/tools/tools_schema.py +6 -12
- {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/METADATA +2 -1
- janito-3.4.0.dist-info/RECORD +264 -0
- janito/cli/cli_commands/check_tools.py +0 -212
- janito/plugin_system_backup_20250825_070018/__init__.py +0 -10
- janito/plugin_system_backup_20250825_070018/base.py +0 -155
- janito/plugin_system_backup_20250825_070018/core_loader_fixed.py +0 -149
- janito/plugins/__main__.py +0 -85
- janito/plugins/core/__init__.py +0 -7
- janito/plugins/core/codeanalyzer/__init__.py +0 -43
- janito/plugins/core/filemanager/__init__.py +0 -124
- janito/plugins/core/filemanager/tools/copy_file.py +0 -111
- janito/plugins/core/filemanager/tools/create_directory.py +0 -97
- janito/plugins/core/filemanager/tools/create_file.py +0 -111
- janito/plugins/core/filemanager/tools/replace_text_in_file.py +0 -270
- janito/plugins/core/imagedisplay/__init__.py +0 -14
- janito/plugins/core/imagedisplay/plugin.py +0 -51
- janito/plugins/core/imagedisplay/tools/__init__.py +0 -1
- janito/plugins/core/imagedisplay/tools/show_image.py +0 -83
- janito/plugins/core/system/__init__.py +0 -23
- janito/plugins/dev/__init__.py +0 -7
- janito/plugins/dev/pythondev/__init__.py +0 -37
- janito/plugins/dev/visualization/__init__.py +0 -23
- janito/plugins/example_plugin.py +0 -108
- janito/plugins/ui/__init__.py +0 -7
- janito/plugins/ui/userinterface/__init__.py +0 -16
- janito/plugins/ui/userinterface/tools/ask_user.py +0 -110
- janito/plugins/web/__init__.py +0 -7
- janito/plugins/web/webtools/__init__.py +0 -33
- janito/plugins/web/webtools/tools/fetch_url.py +0 -458
- janito/plugins_backup_20250825_070018/__init__.py +0 -36
- janito/plugins_backup_20250825_070018/builtin.py +0 -102
- janito/plugins_backup_20250825_070018/config.py +0 -84
- janito/plugins_backup_20250825_070018/core/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/core/codeanalyzer/__init__.py +0 -43
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/__init__.py +0 -1
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/core.py +0 -122
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/java_outline.py +0 -47
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/markdown_outline.py +0 -14
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/python_outline.py +0 -303
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/search_outline.py +0 -36
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/__init__.py +0 -1
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/core.py +0 -205
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/match_lines.py +0 -67
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/pattern_utils.py +0 -73
- janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/traverse_directory.py +0 -145
- janito/plugins_backup_20250825_070018/core/filemanager/__init__.py +0 -124
- janito/plugins_backup_20250825_070018/core/filemanager/tools/create_file.py +0 -87
- janito/plugins_backup_20250825_070018/core/filemanager/tools/delete_text_in_file.py +0 -135
- janito/plugins_backup_20250825_070018/core/filemanager/tools/find_files.py +0 -143
- janito/plugins_backup_20250825_070018/core/filemanager/tools/move_file.py +0 -131
- janito/plugins_backup_20250825_070018/core/filemanager/tools/read_files.py +0 -58
- janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_directory.py +0 -55
- janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_file.py +0 -58
- janito/plugins_backup_20250825_070018/core/filemanager/tools/replace_text_in_file.py +0 -270
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/__init__.py +0 -1
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/core.py +0 -114
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/css_validator.py +0 -35
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/html_validator.py +0 -100
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/jinja2_validator.py +0 -50
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/js_validator.py +0 -27
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/json_validator.py +0 -6
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/markdown_validator.py +0 -109
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/ps1_validator.py +0 -32
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/python_validator.py +0 -5
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/xml_validator.py +0 -11
- janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/yaml_validator.py +0 -6
- janito/plugins_backup_20250825_070018/core/filemanager/tools/view_file.py +0 -172
- janito/plugins_backup_20250825_070018/core/imagedisplay/__init__.py +0 -14
- janito/plugins_backup_20250825_070018/core/imagedisplay/plugin.py +0 -51
- janito/plugins_backup_20250825_070018/core/imagedisplay/tools/__init__.py +0 -1
- janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image.py +0 -83
- janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image_grid.py +0 -84
- janito/plugins_backup_20250825_070018/core/system/__init__.py +0 -23
- janito/plugins_backup_20250825_070018/core/system/tools/run_bash_command.py +0 -183
- janito/plugins_backup_20250825_070018/core/system/tools/run_powershell_command.py +0 -218
- janito/plugins_backup_20250825_070018/dev/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/dev/pythondev/__init__.py +0 -37
- janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_code_run.py +0 -172
- janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_command_run.py +0 -171
- janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_file_run.py +0 -172
- janito/plugins_backup_20250825_070018/dev/visualization/__init__.py +0 -23
- janito/plugins_backup_20250825_070018/dev/visualization/tools/read_chart.py +0 -259
- janito/plugins_backup_20250825_070018/discovery.py +0 -289
- janito/plugins_backup_20250825_070018/example_plugin.py +0 -108
- janito/plugins_backup_20250825_070018/manager.py +0 -243
- janito/plugins_backup_20250825_070018/tools/__init__.py +0 -10
- janito/plugins_backup_20250825_070018/tools/copy_file.py +0 -87
- janito/plugins_backup_20250825_070018/tools/core_tools_plugin.py +0 -88
- janito/plugins_backup_20250825_070018/tools/create_directory.py +0 -70
- janito/plugins_backup_20250825_070018/tools/decorators.py +0 -19
- janito/plugins_backup_20250825_070018/tools/delete_text_in_file.py +0 -135
- janito/plugins_backup_20250825_070018/tools/find_files.py +0 -143
- janito/plugins_backup_20250825_070018/tools/get_file_outline/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/tools/get_file_outline/core.py +0 -122
- janito/plugins_backup_20250825_070018/tools/get_file_outline/java_outline.py +0 -47
- janito/plugins_backup_20250825_070018/tools/get_file_outline/markdown_outline.py +0 -14
- janito/plugins_backup_20250825_070018/tools/get_file_outline/python_outline.py +0 -303
- janito/plugins_backup_20250825_070018/tools/get_file_outline/search_outline.py +0 -36
- janito/plugins_backup_20250825_070018/tools/move_file.py +0 -131
- janito/plugins_backup_20250825_070018/tools/open_html_in_browser.py +0 -51
- janito/plugins_backup_20250825_070018/tools/open_url.py +0 -37
- janito/plugins_backup_20250825_070018/tools/python_code_run.py +0 -172
- janito/plugins_backup_20250825_070018/tools/python_command_run.py +0 -171
- janito/plugins_backup_20250825_070018/tools/python_file_run.py +0 -172
- janito/plugins_backup_20250825_070018/tools/read_chart.py +0 -259
- janito/plugins_backup_20250825_070018/tools/read_files.py +0 -58
- janito/plugins_backup_20250825_070018/tools/remove_directory.py +0 -55
- janito/plugins_backup_20250825_070018/tools/remove_file.py +0 -58
- janito/plugins_backup_20250825_070018/tools/run_bash_command.py +0 -183
- janito/plugins_backup_20250825_070018/tools/run_powershell_command.py +0 -218
- janito/plugins_backup_20250825_070018/tools/search_text/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/tools/search_text/core.py +0 -205
- janito/plugins_backup_20250825_070018/tools/search_text/match_lines.py +0 -67
- janito/plugins_backup_20250825_070018/tools/search_text/pattern_utils.py +0 -73
- janito/plugins_backup_20250825_070018/tools/search_text/traverse_directory.py +0 -145
- janito/plugins_backup_20250825_070018/tools/show_image_grid.py +0 -85
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/core.py +0 -114
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/css_validator.py +0 -35
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/html_validator.py +0 -100
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/jinja2_validator.py +0 -50
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/js_validator.py +0 -27
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/json_validator.py +0 -6
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/markdown_validator.py +0 -109
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/ps1_validator.py +0 -32
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/python_validator.py +0 -5
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/xml_validator.py +0 -11
- janito/plugins_backup_20250825_070018/tools/validate_file_syntax/yaml_validator.py +0 -6
- janito/plugins_backup_20250825_070018/tools/view_file.py +0 -172
- janito/plugins_backup_20250825_070018/ui/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/ui/userinterface/__init__.py +0 -16
- janito/plugins_backup_20250825_070018/ui/userinterface/tools/ask_user.py +0 -110
- janito/plugins_backup_20250825_070018/web/__init__.py +0 -7
- janito/plugins_backup_20250825_070018/web/webtools/__init__.py +0 -33
- janito/plugins_backup_20250825_070018/web/webtools/tools/fetch_url.py +0 -458
- janito/plugins_backup_20250825_070018/web/webtools/tools/open_html_in_browser.py +0 -51
- janito/plugins_backup_20250825_070018/web/webtools/tools/open_url.py +0 -37
- janito/tools/cli_initializer.py +0 -88
- janito/tools/initialize.py +0 -70
- janito-3.3.0.dist-info/RECORD +0 -400
- /janito/{plugins_backup_20250825_070018 → plugins}/auto_loader.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/discovery_core.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager/tools → tools/adapters/local}/copy_file.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager/tools → tools/adapters/local}/create_directory.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/find_files.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/__init__.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/core.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/java_outline.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/markdown_outline.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/python_outline.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/search_outline.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/move_file.py +0 -0
- /janito/{plugins/web/webtools/tools → tools/adapters/local}/open_html_in_browser.py +0 -0
- /janito/{plugins/web/webtools/tools → tools/adapters/local}/open_url.py +0 -0
- /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_code_run.py +0 -0
- /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_command_run.py +0 -0
- /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_file_run.py +0 -0
- /janito/{plugins/dev/visualization/tools → tools/adapters/local}/read_chart.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/read_files.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/remove_directory.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/remove_file.py +0 -0
- /janito/{plugins/core/system/tools → tools/adapters/local}/run_bash_command.py +0 -0
- /janito/{plugins/core/system/tools → tools/adapters/local}/run_powershell_command.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/__init__.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/core.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/match_lines.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/pattern_utils.py +0 -0
- /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/traverse_directory.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/__init__.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/core.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/css_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/html_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/jinja2_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/js_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/json_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/markdown_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/ps1_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/python_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/xml_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/yaml_validator.py +0 -0
- /janito/{plugins/core/filemanager/tools → tools/adapters/local}/view_file.py +0 -0
- {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/WHEEL +0 -0
- {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/entry_points.txt +0 -0
- {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/licenses/LICENSE +0 -0
- {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/top_level.txt +0 -0
@@ -5,7 +5,7 @@ This module provides proper Plugin class implementations for core plugins
|
|
5
5
|
that use the function-based approach instead of class-based.
|
6
6
|
"""
|
7
7
|
|
8
|
-
from janito.
|
8
|
+
from janito.plugins.base import Plugin, PluginMetadata
|
9
9
|
from typing import List, Type
|
10
10
|
from janito.tools.tool_base import ToolBase
|
11
11
|
from janito.tools.function_adapter import create_function_tool
|
@@ -13,17 +13,17 @@ from janito.tools.function_adapter import create_function_tool
|
|
13
13
|
|
14
14
|
class CorePluginAdapter(Plugin):
|
15
15
|
"""Adapter for core plugins using function-based tools."""
|
16
|
-
|
16
|
+
|
17
17
|
def __init__(self, plugin_name: str, description: str, tools_module):
|
18
18
|
super().__init__()
|
19
19
|
self._plugin_name = plugin_name
|
20
20
|
self._description = description
|
21
21
|
self._tools_module = tools_module
|
22
22
|
self._tool_classes = []
|
23
|
-
|
23
|
+
|
24
24
|
# Set the metadata attribute that Plugin expects
|
25
25
|
self.metadata = self.get_metadata()
|
26
|
-
|
26
|
+
|
27
27
|
def get_metadata(self) -> PluginMetadata:
|
28
28
|
return PluginMetadata(
|
29
29
|
name=self._plugin_name,
|
@@ -32,15 +32,15 @@ class CorePluginAdapter(Plugin):
|
|
32
32
|
author="Janito",
|
33
33
|
license="MIT",
|
34
34
|
)
|
35
|
-
|
35
|
+
|
36
36
|
def get_tools(self) -> List[Type[ToolBase]]:
|
37
37
|
return self._tool_classes
|
38
|
-
|
38
|
+
|
39
39
|
def initialize(self):
|
40
40
|
"""Initialize the plugin by creating tool classes."""
|
41
41
|
# Get tools from the module
|
42
42
|
tools = getattr(self._tools_module, "__plugin_tools__", [])
|
43
|
-
|
43
|
+
|
44
44
|
self._tool_classes = []
|
45
45
|
for tool_func in tools:
|
46
46
|
if callable(tool_func):
|
@@ -48,8 +48,6 @@ class CorePluginAdapter(Plugin):
|
|
48
48
|
self._tool_classes.append(tool_class)
|
49
49
|
|
50
50
|
|
51
|
-
def create_core_plugin(
|
52
|
-
plugin_name: str, description: str, tools_module
|
53
|
-
) -> CorePluginAdapter:
|
51
|
+
def create_core_plugin(plugin_name: str, description: str, tools_module) -> CorePluginAdapter:
|
54
52
|
"""Create a core plugin adapter."""
|
55
|
-
return CorePluginAdapter(plugin_name, description, tools_module)
|
53
|
+
return CorePluginAdapter(plugin_name, description, tools_module)
|
janito/plugins/core_loader.py
CHANGED
@@ -1,31 +1,30 @@
|
|
1
1
|
"""
|
2
|
-
|
2
|
+
Core plugin loader that properly handles function-based plugins.
|
3
3
|
|
4
|
-
This module provides a
|
5
|
-
|
4
|
+
This module provides a simplified approach to load core plugins
|
5
|
+
without the complex discovery mechanism.
|
6
6
|
"""
|
7
7
|
|
8
|
-
import importlib
|
9
8
|
import importlib.util
|
10
9
|
import sys
|
11
10
|
from pathlib import Path
|
12
|
-
from typing import Optional
|
11
|
+
from typing import Optional
|
13
12
|
|
14
|
-
from .base import Plugin, PluginMetadata
|
13
|
+
from janito.plugins.base import Plugin, PluginMetadata
|
15
14
|
from janito.tools.function_adapter import create_function_tool
|
16
15
|
from janito.tools.tool_base import ToolBase
|
17
16
|
|
18
17
|
|
19
18
|
class CorePlugin(Plugin):
|
20
|
-
"""
|
21
|
-
|
19
|
+
"""Simple core plugin implementation."""
|
20
|
+
|
22
21
|
def __init__(self, name: str, description: str, tools: list):
|
22
|
+
super().__init__()
|
23
23
|
self._plugin_name = name
|
24
24
|
self._description = description
|
25
25
|
self._tools = tools
|
26
26
|
self._tool_classes = []
|
27
|
-
|
28
|
-
|
27
|
+
|
29
28
|
def get_metadata(self) -> PluginMetadata:
|
30
29
|
return PluginMetadata(
|
31
30
|
name=self._plugin_name,
|
@@ -34,10 +33,10 @@ class CorePlugin(Plugin):
|
|
34
33
|
author="Janito",
|
35
34
|
license="MIT",
|
36
35
|
)
|
37
|
-
|
38
|
-
def get_tools(self) ->
|
36
|
+
|
37
|
+
def get_tools(self) -> list:
|
39
38
|
return self._tool_classes
|
40
|
-
|
39
|
+
|
41
40
|
def initialize(self):
|
42
41
|
"""Initialize by creating tool classes."""
|
43
42
|
self._tool_classes = []
|
@@ -50,10 +49,10 @@ class CorePlugin(Plugin):
|
|
50
49
|
def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
|
51
50
|
"""
|
52
51
|
Load a core plugin by name.
|
53
|
-
|
52
|
+
|
54
53
|
Args:
|
55
54
|
plugin_name: Name of the plugin (e.g., 'core.filemanager')
|
56
|
-
|
55
|
+
|
57
56
|
Returns:
|
58
57
|
Plugin instance if loaded successfully
|
59
58
|
"""
|
@@ -61,67 +60,39 @@ def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
|
|
61
60
|
# Parse plugin name
|
62
61
|
if "." not in plugin_name:
|
63
62
|
return None
|
64
|
-
|
63
|
+
|
65
64
|
parts = plugin_name.split(".")
|
66
65
|
if len(parts) != 2:
|
67
66
|
return None
|
68
|
-
|
67
|
+
|
69
68
|
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
|
-
|
69
|
+
|
84
70
|
# Build path to plugin
|
85
|
-
plugin_path = (
|
86
|
-
Path("janito/plugins") / package_name / submodule_name / "__init__.py"
|
87
|
-
)
|
71
|
+
plugin_path = Path("plugins") / package_name / submodule_name / "__init__.py"
|
88
72
|
if not plugin_path.exists():
|
89
73
|
return None
|
90
|
-
|
74
|
+
|
91
75
|
# Load the module
|
92
76
|
spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
|
93
77
|
if spec is None or spec.loader is None:
|
94
78
|
return None
|
95
|
-
|
79
|
+
|
96
80
|
module = importlib.util.module_from_spec(spec)
|
97
81
|
spec.loader.exec_module(module)
|
98
|
-
|
82
|
+
|
99
83
|
# Get plugin info
|
100
84
|
name = getattr(module, "__plugin_name__", plugin_name)
|
101
|
-
description = getattr(
|
102
|
-
module, "__plugin_description__", f"Core plugin: {plugin_name}"
|
103
|
-
)
|
85
|
+
description = getattr(module, "__plugin_description__", f"Core plugin: {plugin_name}")
|
104
86
|
tools = getattr(module, "__plugin_tools__", [])
|
105
|
-
|
87
|
+
|
106
88
|
if not tools:
|
107
89
|
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
|
-
|
90
|
+
|
120
91
|
# Create plugin
|
121
|
-
plugin = CorePlugin(name, description,
|
92
|
+
plugin = CorePlugin(name, description, tools)
|
122
93
|
plugin.initialize()
|
123
94
|
return plugin
|
124
|
-
|
95
|
+
|
125
96
|
except Exception as e:
|
126
97
|
print(f"Error loading core plugin {plugin_name}: {e}")
|
127
98
|
return None
|
@@ -139,6 +110,11 @@ def get_core_plugins() -> list:
|
|
139
110
|
"ui.userinterface",
|
140
111
|
"web.webtools",
|
141
112
|
]
|
142
|
-
|
143
|
-
|
144
|
-
|
113
|
+
|
114
|
+
available = []
|
115
|
+
for plugin_name in core_plugins:
|
116
|
+
plugin = load_core_plugin(plugin_name)
|
117
|
+
if plugin:
|
118
|
+
available.append(plugin_name)
|
119
|
+
|
120
|
+
return available
|
@@ -5,27 +5,26 @@ This module provides a working implementation to load core plugins
|
|
5
5
|
by directly using the Plugin base class properly.
|
6
6
|
"""
|
7
7
|
|
8
|
-
import importlib
|
9
8
|
import importlib.util
|
10
9
|
import sys
|
11
10
|
from pathlib import Path
|
12
11
|
from typing import Optional, List, Type
|
13
12
|
|
14
|
-
from janito.
|
13
|
+
from janito.plugins.base import Plugin, PluginMetadata
|
15
14
|
from janito.tools.function_adapter import create_function_tool
|
16
15
|
from janito.tools.tool_base import ToolBase
|
17
16
|
|
18
17
|
|
19
18
|
class CorePlugin(Plugin):
|
20
19
|
"""Working core plugin implementation."""
|
21
|
-
|
20
|
+
|
22
21
|
def __init__(self, name: str, description: str, tools: list):
|
23
22
|
self._plugin_name = name
|
24
23
|
self._description = description
|
25
24
|
self._tools = tools
|
26
25
|
self._tool_classes = []
|
27
26
|
super().__init__() # Call super after setting attributes
|
28
|
-
|
27
|
+
|
29
28
|
def get_metadata(self) -> PluginMetadata:
|
30
29
|
return PluginMetadata(
|
31
30
|
name=self._plugin_name,
|
@@ -34,10 +33,10 @@ class CorePlugin(Plugin):
|
|
34
33
|
author="Janito",
|
35
34
|
license="MIT",
|
36
35
|
)
|
37
|
-
|
36
|
+
|
38
37
|
def get_tools(self) -> List[Type[ToolBase]]:
|
39
38
|
return self._tool_classes
|
40
|
-
|
39
|
+
|
41
40
|
def initialize(self):
|
42
41
|
"""Initialize by creating tool classes."""
|
43
42
|
self._tool_classes = []
|
@@ -50,10 +49,10 @@ class CorePlugin(Plugin):
|
|
50
49
|
def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
|
51
50
|
"""
|
52
51
|
Load a core plugin by name.
|
53
|
-
|
52
|
+
|
54
53
|
Args:
|
55
54
|
plugin_name: Name of the plugin (e.g., 'core.filemanager')
|
56
|
-
|
55
|
+
|
57
56
|
Returns:
|
58
57
|
Plugin instance if loaded successfully
|
59
58
|
"""
|
@@ -61,67 +60,49 @@ def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
|
|
61
60
|
# Parse plugin name
|
62
61
|
if "." not in plugin_name:
|
63
62
|
return None
|
64
|
-
|
63
|
+
|
65
64
|
parts = plugin_name.split(".")
|
66
65
|
if len(parts) != 2:
|
67
66
|
return None
|
68
|
-
|
67
|
+
|
69
68
|
package_name, submodule_name = parts
|
70
|
-
|
69
|
+
|
71
70
|
# Handle imagedisplay specially
|
72
71
|
if plugin_name == "core.imagedisplay":
|
73
72
|
# Import the actual plugin class
|
74
73
|
try:
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
return plugin_module.ImageDisplayPlugin()
|
80
|
-
except ImportError as e:
|
81
|
-
print(f"Failed to load imagedisplay: {e}")
|
74
|
+
from plugins.core.imagedisplay.plugin import ImageDisplayPlugin
|
75
|
+
return ImageDisplayPlugin()
|
76
|
+
except ImportError:
|
77
|
+
# If import fails, return None - don't return True
|
82
78
|
return None
|
83
|
-
|
79
|
+
|
84
80
|
# Build path to plugin
|
85
|
-
plugin_path = (
|
86
|
-
Path("janito/plugins") / package_name / submodule_name / "__init__.py"
|
87
|
-
)
|
81
|
+
plugin_path = Path("plugins") / package_name / submodule_name / "__init__.py"
|
88
82
|
if not plugin_path.exists():
|
89
83
|
return None
|
90
|
-
|
84
|
+
|
91
85
|
# Load the module
|
92
86
|
spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
|
93
87
|
if spec is None or spec.loader is None:
|
94
88
|
return None
|
95
|
-
|
89
|
+
|
96
90
|
module = importlib.util.module_from_spec(spec)
|
97
91
|
spec.loader.exec_module(module)
|
98
|
-
|
92
|
+
|
99
93
|
# Get plugin info
|
100
94
|
name = getattr(module, "__plugin_name__", plugin_name)
|
101
|
-
description = getattr(
|
102
|
-
module, "__plugin_description__", f"Core plugin: {plugin_name}"
|
103
|
-
)
|
95
|
+
description = getattr(module, "__plugin_description__", f"Core plugin: {plugin_name}")
|
104
96
|
tools = getattr(module, "__plugin_tools__", [])
|
105
|
-
|
97
|
+
|
106
98
|
if not tools:
|
107
99
|
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
|
-
|
100
|
+
|
120
101
|
# Create plugin
|
121
|
-
plugin = CorePlugin(name, description,
|
102
|
+
plugin = CorePlugin(name, description, tools)
|
122
103
|
plugin.initialize()
|
123
104
|
return plugin
|
124
|
-
|
105
|
+
|
125
106
|
except Exception as e:
|
126
107
|
print(f"Error loading core plugin {plugin_name}: {e}")
|
127
108
|
return None
|
@@ -139,6 +120,6 @@ def get_core_plugins() -> list:
|
|
139
120
|
"ui.userinterface",
|
140
121
|
"web.webtools",
|
141
122
|
]
|
142
|
-
|
123
|
+
|
143
124
|
# All core plugins are always available
|
144
|
-
return core_plugins
|
125
|
+
return core_plugins
|
janito/plugins/discovery.py
CHANGED
@@ -75,13 +75,13 @@ def discover_plugins(
|
|
75
75
|
parts = plugin_name.split(".")
|
76
76
|
if len(parts) == 2:
|
77
77
|
package_name, submodule_name = parts
|
78
|
-
|
78
|
+
|
79
79
|
# Handle core plugins with dedicated loader
|
80
80
|
if plugin_name.startswith(("core.", "dev.", "ui.", "web.")):
|
81
81
|
plugin = load_core_plugin(plugin_name)
|
82
82
|
if plugin:
|
83
83
|
return plugin
|
84
|
-
|
84
|
+
|
85
85
|
for base_path in all_paths:
|
86
86
|
package_path = base_path / package_name / submodule_name / "__init__.py"
|
87
87
|
if package_path.exists():
|
@@ -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 .base import PluginMetadata
|
160
|
+
from janito.plugins.base import PluginMetadata
|
161
161
|
|
162
162
|
# Create a dynamic plugin class
|
163
163
|
class PackagePlugin(Plugin):
|
janito/tools/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
from janito.tools.adapters.local import
|
2
|
-
|
3
|
-
LocalToolsAdapter
|
1
|
+
from janito.tools.adapters.local import (
|
2
|
+
local_tools_adapter as _internal_local_tools_adapter,
|
3
|
+
LocalToolsAdapter,
|
4
4
|
)
|
5
5
|
|
6
6
|
|
@@ -11,10 +11,8 @@ def get_local_tools_adapter(workdir=None, allowed_permissions=None):
|
|
11
11
|
if workdir is not None and not os.path.exists(workdir):
|
12
12
|
os.makedirs(workdir, exist_ok=True)
|
13
13
|
# Permissions are now managed globally; ignore allowed_permissions argument except for backward compatibility
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
registry = initialize_tools(LocalToolsAdapter(workdir=workdir))
|
14
|
+
# Reuse the singleton adapter defined in janito.tools.adapters.local to maintain tool registrations
|
15
|
+
registry = _internal_local_tools_adapter
|
18
16
|
# Change workdir if requested
|
19
17
|
if workdir is not None:
|
20
18
|
try:
|
@@ -29,32 +27,10 @@ def get_local_tools_adapter(workdir=None, allowed_permissions=None):
|
|
29
27
|
return registry
|
30
28
|
|
31
29
|
|
32
|
-
|
33
|
-
local_tools_adapter = None
|
34
|
-
|
35
|
-
|
36
|
-
def get_local_tools_adapter(workdir=None, allowed_permissions=None):
|
37
|
-
"""Get the global tools adapter, initializing on first use."""
|
38
|
-
global local_tools_adapter
|
39
|
-
if local_tools_adapter is None:
|
40
|
-
from janito.tools.initialize import initialize_tools
|
41
|
-
|
42
|
-
adapter = LocalToolsAdapter(workdir=workdir)
|
43
|
-
local_tools_adapter = initialize_tools(adapter)
|
44
|
-
|
45
|
-
# Handle workdir if provided
|
46
|
-
if workdir is not None and local_tools_adapter is not None:
|
47
|
-
import os
|
48
|
-
|
49
|
-
if not os.path.exists(workdir):
|
50
|
-
os.makedirs(workdir, exist_ok=True)
|
51
|
-
os.chdir(workdir)
|
52
|
-
local_tools_adapter.workdir = workdir
|
53
|
-
|
54
|
-
return local_tools_adapter
|
55
|
-
|
30
|
+
local_tools_adapter = _internal_local_tools_adapter
|
56
31
|
|
57
32
|
__all__ = [
|
58
33
|
"LocalToolsAdapter",
|
59
34
|
"get_local_tools_adapter",
|
35
|
+
"local_tools_adapter",
|
60
36
|
]
|
@@ -1,6 +1 @@
|
|
1
|
-
|
2
|
-
Tools providers package: for plug-and-play tool collections, integrations, and adapters.
|
3
|
-
|
4
|
-
This package contains the core adapter infrastructure for managing tools,
|
5
|
-
while the actual tool implementations have been moved to the plugins system.
|
6
|
-
"""
|
1
|
+
# Tools providers package: for plug-and-play tool collections, integrations, and adapters.
|
@@ -1,10 +1,73 @@
|
|
1
|
-
|
2
|
-
Local tools adapter for janito.
|
1
|
+
from .adapter import LocalToolsAdapter
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
from .ask_user import AskUserTool
|
4
|
+
from .copy_file import CopyFileTool
|
5
|
+
from .create_directory import CreateDirectoryTool
|
6
|
+
from .create_file import CreateFileTool
|
7
|
+
from .fetch_url import FetchUrlTool
|
8
|
+
from .find_files import FindFilesTool
|
9
|
+
from .view_file import ViewFileTool
|
10
|
+
from .read_files import ReadFilesTool
|
11
|
+
from .move_file import MoveFileTool
|
12
|
+
from .open_url import OpenUrlTool
|
13
|
+
from .open_html_in_browser import OpenHtmlInBrowserTool
|
14
|
+
from .python_code_run import PythonCodeRunTool
|
15
|
+
from .python_command_run import PythonCommandRunTool
|
16
|
+
from .python_file_run import PythonFileRunTool
|
17
|
+
from .remove_directory import RemoveDirectoryTool
|
18
|
+
from .remove_file import RemoveFileTool
|
19
|
+
from .replace_text_in_file import ReplaceTextInFileTool
|
20
|
+
from .run_bash_command import RunBashCommandTool
|
21
|
+
from .run_powershell_command import RunPowershellCommandTool
|
22
|
+
from .get_file_outline.core import GetFileOutlineTool
|
23
|
+
from .get_file_outline.search_outline import SearchOutlineTool
|
24
|
+
from .search_text.core import SearchTextTool
|
25
|
+
from .validate_file_syntax.core import ValidateFileSyntaxTool
|
26
|
+
from .read_chart import ReadChartTool
|
27
|
+
from .show_image import ShowImageTool
|
28
|
+
from .show_image_grid import ShowImageGridTool
|
7
29
|
|
8
|
-
from .
|
30
|
+
from janito.tools.tool_base import ToolPermissions
|
31
|
+
import os
|
32
|
+
from janito.tools.permissions import get_global_allowed_permissions
|
33
|
+
|
34
|
+
# Singleton tools adapter with all standard tools registered
|
35
|
+
local_tools_adapter = LocalToolsAdapter(workdir=os.getcwd())
|
36
|
+
|
37
|
+
|
38
|
+
def get_local_tools_adapter(workdir=None):
|
39
|
+
return LocalToolsAdapter(workdir=workdir or os.getcwd())
|
40
|
+
|
41
|
+
|
42
|
+
# Register tools
|
43
|
+
for tool_class in [
|
44
|
+
AskUserTool,
|
45
|
+
CopyFileTool,
|
46
|
+
CreateDirectoryTool,
|
47
|
+
CreateFileTool,
|
48
|
+
FetchUrlTool,
|
49
|
+
FindFilesTool,
|
50
|
+
ViewFileTool,
|
51
|
+
ReadFilesTool,
|
52
|
+
MoveFileTool,
|
53
|
+
OpenUrlTool,
|
54
|
+
OpenHtmlInBrowserTool,
|
55
|
+
PythonCodeRunTool,
|
56
|
+
PythonCommandRunTool,
|
57
|
+
PythonFileRunTool,
|
58
|
+
RemoveDirectoryTool,
|
59
|
+
RemoveFileTool,
|
60
|
+
ReplaceTextInFileTool,
|
61
|
+
RunBashCommandTool,
|
62
|
+
RunPowershellCommandTool,
|
63
|
+
GetFileOutlineTool,
|
64
|
+
SearchOutlineTool,
|
65
|
+
SearchTextTool,
|
66
|
+
ValidateFileSyntaxTool,
|
67
|
+
ReadChartTool,
|
68
|
+
ShowImageTool,
|
69
|
+
ShowImageGridTool,
|
70
|
+
]:
|
71
|
+
local_tools_adapter.register_tool(tool_class)
|
9
72
|
|
10
|
-
|
73
|
+
# DEBUG: Print registered tools at startup
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
|
-
from janito.
|
2
|
+
from janito.tools.adapters.local.adapter import register_local_tool
|
3
3
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
4
4
|
|
5
5
|
from rich import print as rich_print
|
@@ -16,8 +16,8 @@ from prompt_toolkit.styles import Style
|
|
16
16
|
toolbar_style = Style.from_dict({"bottom-toolbar": "fg:yellow bg:darkred"})
|
17
17
|
|
18
18
|
|
19
|
-
@
|
20
|
-
class
|
19
|
+
@register_local_tool
|
20
|
+
class AskUserTool(ToolBase):
|
21
21
|
"""
|
22
22
|
Prompts the user for clarification or input with a question.
|
23
23
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from janito.tools.path_utils import expand_path
|
3
|
-
from janito.
|
3
|
+
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
|
5
5
|
from janito.tools.tool_utils import display_path
|
6
6
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
@@ -8,11 +8,11 @@ from janito.report_events import ReportAction
|
|
8
8
|
from janito.i18n import tr
|
9
9
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
10
10
|
|
11
|
-
from janito.
|
11
|
+
from janito.tools.adapters.local.validate_file_syntax.core import validate_file_syntax
|
12
12
|
|
13
13
|
|
14
|
-
@
|
15
|
-
class
|
14
|
+
@register_local_tool
|
15
|
+
class CreateFileTool(ToolBase):
|
16
16
|
"""
|
17
17
|
Create a new file with specified content at the given path.
|
18
18
|
|
@@ -15,7 +15,6 @@ class DeleteTextInFileTool(ToolBase):
|
|
15
15
|
path (str): Path to the file to modify.
|
16
16
|
start_marker (str): The starting delimiter string.
|
17
17
|
end_marker (str): The ending delimiter string.
|
18
|
-
backup (bool, optional): Deprecated. No backups are created anymore and this flag is ignored. Defaults to False.
|
19
18
|
|
20
19
|
Returns:
|
21
20
|
str: Status message indicating the result.
|
@@ -5,7 +5,7 @@ import json
|
|
5
5
|
from pathlib import Path
|
6
6
|
from bs4 import BeautifulSoup
|
7
7
|
from typing import Dict, Any, Optional
|
8
|
-
from janito.
|
8
|
+
from janito.tools.adapters.local.adapter import register_local_tool
|
9
9
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
10
10
|
from janito.report_events import ReportAction
|
11
11
|
from janito.i18n import tr
|
@@ -13,8 +13,8 @@ from janito.tools.tool_utils import pluralize
|
|
13
13
|
from janito.tools.loop_protection_decorator import protect_against_loops
|
14
14
|
|
15
15
|
|
16
|
-
@
|
17
|
-
class
|
16
|
+
@register_local_tool
|
17
|
+
class FetchUrlTool(ToolBase):
|
18
18
|
"""
|
19
19
|
Fetch the content of a web page and extract its text.
|
20
20
|
|
janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/replace_text_in_file.py
RENAMED
@@ -1,14 +1,14 @@
|
|
1
1
|
from janito.tools.tool_base import ToolBase, ToolPermissions
|
2
2
|
from janito.report_events import ReportAction
|
3
|
-
from janito.
|
3
|
+
from janito.tools.adapters.local.adapter import register_local_tool
|
4
4
|
from janito.i18n import tr
|
5
5
|
import shutil
|
6
6
|
import re
|
7
|
-
from janito.
|
7
|
+
from janito.tools.adapters.local.validate_file_syntax.core import validate_file_syntax
|
8
8
|
|
9
9
|
|
10
|
-
@
|
11
|
-
class
|
10
|
+
@register_local_tool
|
11
|
+
class ReplaceTextInFileTool(ToolBase):
|
12
12
|
"""
|
13
13
|
Replace exact occurrences of a given text in a file.
|
14
14
|
|