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
@@ -1,149 +0,0 @@
|
|
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.util
|
9
|
-
import sys
|
10
|
-
from pathlib import Path
|
11
|
-
from typing import Optional, List, Type
|
12
|
-
|
13
|
-
from janito.plugin_system.base import Plugin, PluginMetadata
|
14
|
-
from janito.tools.function_adapter import create_function_tool
|
15
|
-
from janito.tools.tool_base import ToolBase
|
16
|
-
|
17
|
-
|
18
|
-
class CorePlugin(Plugin):
|
19
|
-
"""Working core plugin implementation."""
|
20
|
-
|
21
|
-
def __init__(self, name: str, description: str, tools: list):
|
22
|
-
self._plugin_name = name
|
23
|
-
self._description = description
|
24
|
-
self._tools = tools
|
25
|
-
self._tool_classes = []
|
26
|
-
super().__init__() # Call super after setting attributes
|
27
|
-
|
28
|
-
def get_metadata(self) -> PluginMetadata:
|
29
|
-
return PluginMetadata(
|
30
|
-
name=self._plugin_name,
|
31
|
-
version="1.0.0",
|
32
|
-
description=self._description,
|
33
|
-
author="Janito",
|
34
|
-
license="MIT",
|
35
|
-
)
|
36
|
-
|
37
|
-
def get_tools(self) -> List[Type[ToolBase]]:
|
38
|
-
return self._tool_classes
|
39
|
-
|
40
|
-
def initialize(self):
|
41
|
-
"""Initialize by creating tool classes."""
|
42
|
-
self._tool_classes = []
|
43
|
-
for tool_func in self._tools:
|
44
|
-
if callable(tool_func):
|
45
|
-
tool_class = create_function_tool(tool_func)
|
46
|
-
self._tool_classes.append(tool_class)
|
47
|
-
|
48
|
-
|
49
|
-
def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
|
50
|
-
"""
|
51
|
-
Load a core plugin by name.
|
52
|
-
|
53
|
-
Args:
|
54
|
-
plugin_name: Name of the plugin (e.g., 'core.filemanager')
|
55
|
-
|
56
|
-
Returns:
|
57
|
-
Plugin instance if loaded successfully
|
58
|
-
"""
|
59
|
-
try:
|
60
|
-
# Parse plugin name
|
61
|
-
if "." not in plugin_name:
|
62
|
-
return None
|
63
|
-
|
64
|
-
parts = plugin_name.split(".")
|
65
|
-
if len(parts) != 2:
|
66
|
-
return None
|
67
|
-
|
68
|
-
package_name, submodule_name = parts
|
69
|
-
|
70
|
-
# Handle imagedisplay specially
|
71
|
-
if plugin_name == "core.imagedisplay":
|
72
|
-
# Import the actual plugin class
|
73
|
-
try:
|
74
|
-
from janito.plugins.core.imagedisplay.plugin import ImageDisplayPlugin
|
75
|
-
|
76
|
-
return ImageDisplayPlugin()
|
77
|
-
except ImportError as e:
|
78
|
-
print(f"Failed to load imagedisplay: {e}")
|
79
|
-
return None
|
80
|
-
|
81
|
-
# Build path to plugin
|
82
|
-
plugin_path = (
|
83
|
-
Path("janito/plugins") / package_name / submodule_name / "__init__.py"
|
84
|
-
)
|
85
|
-
if not plugin_path.exists():
|
86
|
-
return None
|
87
|
-
|
88
|
-
# Load the module
|
89
|
-
spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
|
90
|
-
if spec is None or spec.loader is None:
|
91
|
-
return None
|
92
|
-
|
93
|
-
module = importlib.util.module_from_spec(spec)
|
94
|
-
|
95
|
-
# Add module to sys.modules to prevent circular imports
|
96
|
-
sys.modules[plugin_name] = module
|
97
|
-
|
98
|
-
try:
|
99
|
-
# Read and execute the module content
|
100
|
-
with open(plugin_path, "r", encoding="utf-8") as f:
|
101
|
-
code = f.read()
|
102
|
-
|
103
|
-
# Execute in module's namespace
|
104
|
-
exec(code, module.__dict__)
|
105
|
-
|
106
|
-
# Get plugin info
|
107
|
-
name = module.__dict__.get("__plugin_name__", plugin_name)
|
108
|
-
description = module.__dict__.get(
|
109
|
-
"__plugin_description__", f"Core plugin: {plugin_name}"
|
110
|
-
)
|
111
|
-
tools = module.__dict__.get("__plugin_tools__", [])
|
112
|
-
|
113
|
-
if not tools:
|
114
|
-
return None
|
115
|
-
|
116
|
-
# Ensure all tools have tool_name attribute
|
117
|
-
for tool in tools:
|
118
|
-
if tool is not None and not hasattr(tool, "tool_name"):
|
119
|
-
tool.tool_name = tool.__name__
|
120
|
-
|
121
|
-
# Create plugin
|
122
|
-
plugin = CorePlugin(name, description, tools)
|
123
|
-
plugin.initialize()
|
124
|
-
return plugin
|
125
|
-
finally:
|
126
|
-
# Clean up sys.modules
|
127
|
-
if plugin_name in sys.modules:
|
128
|
-
del sys.modules[plugin_name]
|
129
|
-
|
130
|
-
except Exception as e:
|
131
|
-
print(f"Error loading core plugin {plugin_name}: {e}")
|
132
|
-
return None
|
133
|
-
|
134
|
-
|
135
|
-
def get_core_plugins() -> list:
|
136
|
-
"""Get list of all available core plugins."""
|
137
|
-
core_plugins = [
|
138
|
-
"core.filemanager",
|
139
|
-
"core.codeanalyzer",
|
140
|
-
"core.system",
|
141
|
-
"core.imagedisplay",
|
142
|
-
"dev.pythondev",
|
143
|
-
"dev.visualization",
|
144
|
-
"ui.userinterface",
|
145
|
-
"web.webtools",
|
146
|
-
]
|
147
|
-
|
148
|
-
# All core plugins are always available
|
149
|
-
return core_plugins
|
janito/plugins/__main__.py
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
"""
|
3
|
-
Plugin system CLI entry point.
|
4
|
-
"""
|
5
|
-
|
6
|
-
import argparse
|
7
|
-
import sys
|
8
|
-
from pathlib import Path
|
9
|
-
|
10
|
-
from .manager import PluginManager
|
11
|
-
from .discovery import list_available_plugins
|
12
|
-
from .core_loader import get_core_plugins
|
13
|
-
|
14
|
-
|
15
|
-
def list_plugins():
|
16
|
-
"""List all available plugins."""
|
17
|
-
print("📋 Available Plugins:")
|
18
|
-
print("=" * 50)
|
19
|
-
|
20
|
-
# Get available plugins
|
21
|
-
available = list_available_plugins()
|
22
|
-
|
23
|
-
# Get core plugins
|
24
|
-
core_plugins = get_core_plugins()
|
25
|
-
|
26
|
-
if available:
|
27
|
-
print("\n🔌 Available Plugins:")
|
28
|
-
for plugin in sorted(available):
|
29
|
-
if plugin in core_plugins:
|
30
|
-
print(f" ✅ {plugin} (core)")
|
31
|
-
else:
|
32
|
-
print(f" 🔌 {plugin}")
|
33
|
-
else:
|
34
|
-
print(" No plugins found in search paths")
|
35
|
-
|
36
|
-
print(f"\n📊 Total: {len(available)} plugins")
|
37
|
-
|
38
|
-
|
39
|
-
def list_loaded():
|
40
|
-
"""List currently loaded plugins."""
|
41
|
-
print("🔧 Currently Loaded Plugins:")
|
42
|
-
print("=" * 50)
|
43
|
-
|
44
|
-
pm = PluginManager()
|
45
|
-
|
46
|
-
# Load core plugins
|
47
|
-
core_plugins = get_core_plugins()
|
48
|
-
for plugin in core_plugins:
|
49
|
-
pm.load_plugin(plugin)
|
50
|
-
|
51
|
-
loaded = pm.list_plugins()
|
52
|
-
|
53
|
-
if loaded:
|
54
|
-
for plugin in sorted(loaded):
|
55
|
-
metadata = pm.get_plugin_metadata(plugin)
|
56
|
-
if metadata:
|
57
|
-
print(f" 📦 {plugin} v{metadata.version}")
|
58
|
-
print(f" {metadata.description}")
|
59
|
-
else:
|
60
|
-
print(f" 📦 {plugin}")
|
61
|
-
else:
|
62
|
-
print(" No plugins currently loaded")
|
63
|
-
|
64
|
-
print(f"\n📊 Total: {len(loaded)} plugins loaded")
|
65
|
-
|
66
|
-
|
67
|
-
def main():
|
68
|
-
"""Main CLI entry point."""
|
69
|
-
parser = argparse.ArgumentParser(description="Janito Plugin System CLI")
|
70
|
-
parser.add_argument(
|
71
|
-
"--list-plugins",
|
72
|
-
action="store_true",
|
73
|
-
help="List all loaded plugins"
|
74
|
-
)
|
75
|
-
|
76
|
-
args = parser.parse_args()
|
77
|
-
|
78
|
-
if args.list_plugins:
|
79
|
-
list_loaded()
|
80
|
-
else:
|
81
|
-
list_loaded()
|
82
|
-
|
83
|
-
|
84
|
-
if __name__ == "__main__":
|
85
|
-
main()
|
janito/plugins/core/__init__.py
DELETED
@@ -1,43 +0,0 @@
|
|
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]
|
@@ -1,124 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
File Manager Plugin
|
3
|
-
|
4
|
-
Core file and directory operations for managing project files.
|
5
|
-
"""
|
6
|
-
|
7
|
-
from typing import List, Optional
|
8
|
-
import os
|
9
|
-
|
10
|
-
|
11
|
-
def create_file(path: str, content: str = "", overwrite: bool = False) -> str:
|
12
|
-
"""Create a new file with content"""
|
13
|
-
return f"create_file(path='{path}', content='{len(content)} chars', overwrite={overwrite})"
|
14
|
-
|
15
|
-
|
16
|
-
create_file.tool_name = "create_file"
|
17
|
-
|
18
|
-
|
19
|
-
def read_files(paths: List[str]) -> str:
|
20
|
-
"""Read multiple files at once"""
|
21
|
-
return f"read_files(paths={paths})"
|
22
|
-
|
23
|
-
|
24
|
-
read_files.tool_name = "read_files"
|
25
|
-
|
26
|
-
|
27
|
-
def view_file(
|
28
|
-
path: str, from_line: Optional[int] = None, to_line: Optional[int] = None
|
29
|
-
) -> str:
|
30
|
-
"""Read specific lines or entire files"""
|
31
|
-
range_str = f"{from_line}-{to_line}" if from_line or to_line else "all"
|
32
|
-
return f"view_file(path='{path}', range='{range_str}')"
|
33
|
-
|
34
|
-
|
35
|
-
view_file.tool_name = "view_file"
|
36
|
-
|
37
|
-
|
38
|
-
def replace_text_in_file(
|
39
|
-
path: str, search_text: str, replacement_text: str, replace_all: bool = True
|
40
|
-
) -> str:
|
41
|
-
"""Find and replace text in files"""
|
42
|
-
return f"replace_text_in_file(path='{path}', search='{search_text[:20]}...', replace='{replacement_text[:20]}...')"
|
43
|
-
|
44
|
-
|
45
|
-
replace_text_in_file.tool_name = "replace_text_in_file"
|
46
|
-
|
47
|
-
|
48
|
-
def validate_file_syntax(path: str) -> str:
|
49
|
-
"""Check file syntax (Python/Markdown)"""
|
50
|
-
return f"validate_file_syntax(path='{path}')"
|
51
|
-
|
52
|
-
|
53
|
-
validate_file_syntax.tool_name = "validate_file_syntax"
|
54
|
-
|
55
|
-
|
56
|
-
def create_directory(path: str) -> str:
|
57
|
-
"""Create new directories"""
|
58
|
-
return f"create_directory(path='{path}')"
|
59
|
-
|
60
|
-
|
61
|
-
create_directory.tool_name = "create_directory"
|
62
|
-
|
63
|
-
|
64
|
-
def remove_directory(path: str, recursive: bool = False) -> str:
|
65
|
-
"""Remove directories (recursive option)"""
|
66
|
-
return f"remove_directory(path='{path}', recursive={recursive})"
|
67
|
-
|
68
|
-
|
69
|
-
remove_directory.tool_name = "remove_directory"
|
70
|
-
|
71
|
-
|
72
|
-
def remove_file(path: str) -> str:
|
73
|
-
"""Delete single files"""
|
74
|
-
return f"remove_file(path='{path}')"
|
75
|
-
|
76
|
-
|
77
|
-
remove_file.tool_name = "remove_file"
|
78
|
-
|
79
|
-
|
80
|
-
def copy_file(sources: str, target: str, overwrite: bool = False) -> str:
|
81
|
-
"""Copy files or directories"""
|
82
|
-
return f"copy_file(sources='{sources}', target='{target}', overwrite={overwrite})"
|
83
|
-
|
84
|
-
|
85
|
-
copy_file.tool_name = "copy_file"
|
86
|
-
|
87
|
-
|
88
|
-
def move_file(src_path: str, dest_path: str, overwrite: bool = False) -> str:
|
89
|
-
"""Move/rename files or directories"""
|
90
|
-
return f"move_file(src='{src_path}', dest='{dest_path}', overwrite={overwrite})"
|
91
|
-
|
92
|
-
|
93
|
-
move_file.tool_name = "move_file"
|
94
|
-
|
95
|
-
|
96
|
-
def find_files(
|
97
|
-
paths: str,
|
98
|
-
pattern: str,
|
99
|
-
max_depth: Optional[int] = None,
|
100
|
-
include_gitignored: bool = False,
|
101
|
-
) -> str:
|
102
|
-
"""Search for files by pattern (respects .gitignore)"""
|
103
|
-
return f"find_files(paths='{paths}', pattern='{pattern}', max_depth={max_depth})"
|
104
|
-
|
105
|
-
|
106
|
-
find_files.tool_name = "find_files"
|
107
|
-
|
108
|
-
|
109
|
-
# Plugin metadata
|
110
|
-
__plugin_name__ = "core.filemanager"
|
111
|
-
__plugin_description__ = "Core file and directory operations"
|
112
|
-
__plugin_tools__ = [
|
113
|
-
create_file,
|
114
|
-
read_files,
|
115
|
-
view_file,
|
116
|
-
replace_text_in_file,
|
117
|
-
validate_file_syntax,
|
118
|
-
create_directory,
|
119
|
-
remove_directory,
|
120
|
-
remove_file,
|
121
|
-
copy_file,
|
122
|
-
move_file,
|
123
|
-
find_files,
|
124
|
-
]
|
@@ -1,111 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from janito.tools.path_utils import expand_path
|
3
|
-
import shutil
|
4
|
-
from typing import List, Union
|
5
|
-
from janito.tools.adapters.local.adapter import register_local_tool
|
6
|
-
from janito.tools.tool_base import ToolBase, ToolPermissions
|
7
|
-
from janito.tools.tool_utils import display_path
|
8
|
-
from janito.report_events import ReportAction
|
9
|
-
from janito.i18n import tr
|
10
|
-
|
11
|
-
|
12
|
-
@register_local_tool
|
13
|
-
class CopyFileTool(ToolBase):
|
14
|
-
"""
|
15
|
-
Copy one or more files to a target directory, or copy a single file to a new file.
|
16
|
-
|
17
|
-
Parameters:
|
18
|
-
sources (str): Space-separated path(s) to the file(s) to copy.
|
19
|
-
For multiple sources, provide a single string with paths separated by spaces.
|
20
|
-
target (str): Destination path. If copying multiple sources, this must be an existing directory.
|
21
|
-
overwrite (bool, optional): Overwrite existing files. Default: False.
|
22
|
-
Recommended only after reading the file to be overwritten.
|
23
|
-
content (str): File content to write or process
|
24
|
-
recursive (bool): Whether to process directories recursively
|
25
|
-
from_line (int): Starting line number for file reading
|
26
|
-
to_line (int): Ending line number for file reading
|
27
|
-
search_text (str): Text to search for in files
|
28
|
-
replacement_text (str): Text to replace search matches with
|
29
|
-
use_regex (bool): Whether to treat search as regex pattern
|
30
|
-
case_sensitive (bool): Whether search should be case sensitive
|
31
|
-
max_depth (int): Maximum directory depth to search
|
32
|
-
include_gitignored (bool): Whether to include .gitignored files
|
33
|
-
timeout (int): Timeout in seconds for operations
|
34
|
-
require_confirmation (bool): Whether to require user confirmation
|
35
|
-
data (dict): Chart data for visualization tools
|
36
|
-
title (str): Chart title
|
37
|
-
width (int): Chart width in pixels
|
38
|
-
height (int): Chart height in pixels
|
39
|
-
query (str): Search query for text search
|
40
|
-
paths (str): Directory or file paths to search in
|
41
|
-
src_path (str): Source path for move operations
|
42
|
-
dest_path (str): Destination path for move operations
|
43
|
-
code (str): Python code to execute
|
44
|
-
pattern (str): File pattern to match (e.g., '*.py')
|
45
|
-
|
46
|
-
Returns:
|
47
|
-
str: Status string for each copy operation.
|
48
|
-
"""
|
49
|
-
|
50
|
-
permissions = ToolPermissions(read=True, write=True)
|
51
|
-
tool_name = "copy_file"
|
52
|
-
|
53
|
-
def run(self, sources: str, target: str, overwrite: bool = False) -> str:
|
54
|
-
source_list = [expand_path(src) for src in sources.split() if src]
|
55
|
-
target = expand_path(target)
|
56
|
-
messages = []
|
57
|
-
if len(source_list) > 1:
|
58
|
-
if not os.path.isdir(target):
|
59
|
-
return tr(
|
60
|
-
"❗ Target must be an existing directory when copying multiple files: '{target}'",
|
61
|
-
target=display_path(target),
|
62
|
-
)
|
63
|
-
for src in source_list:
|
64
|
-
if not os.path.isfile(src):
|
65
|
-
messages.append(
|
66
|
-
tr(
|
67
|
-
"❗ Source file does not exist: '{src}'",
|
68
|
-
src=display_path(src),
|
69
|
-
)
|
70
|
-
)
|
71
|
-
continue
|
72
|
-
dst = os.path.join(target, os.path.basename(src))
|
73
|
-
messages.append(self._copy_one(src, dst, overwrite=overwrite))
|
74
|
-
else:
|
75
|
-
src = source_list[0]
|
76
|
-
if os.path.isdir(target):
|
77
|
-
dst = os.path.join(target, os.path.basename(src))
|
78
|
-
else:
|
79
|
-
dst = target
|
80
|
-
messages.append(self._copy_one(src, dst, overwrite=overwrite))
|
81
|
-
return "\n".join(messages)
|
82
|
-
|
83
|
-
def _copy_one(self, src, dst, overwrite=False) -> str:
|
84
|
-
disp_src = display_path(src)
|
85
|
-
disp_dst = display_path(dst)
|
86
|
-
if not os.path.isfile(src):
|
87
|
-
return tr("❗ Source file does not exist: '{src}'", src=disp_src)
|
88
|
-
if os.path.exists(dst) and not overwrite:
|
89
|
-
return tr(
|
90
|
-
"❗ Target already exists: '{dst}'. Set overwrite=True to replace.",
|
91
|
-
dst=disp_dst,
|
92
|
-
)
|
93
|
-
try:
|
94
|
-
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
95
|
-
shutil.copy2(src, dst)
|
96
|
-
note = (
|
97
|
-
"\n⚠️ Overwrote existing file. (recommended only after reading the file to be overwritten)"
|
98
|
-
if (os.path.exists(dst) and overwrite)
|
99
|
-
else ""
|
100
|
-
)
|
101
|
-
self.report_success(
|
102
|
-
tr("✅ Copied '{src}' to '{dst}'", src=disp_src, dst=disp_dst)
|
103
|
-
)
|
104
|
-
return tr("✅ Copied '{src}' to '{dst}'", src=disp_src, dst=disp_dst) + note
|
105
|
-
except Exception as e:
|
106
|
-
return tr(
|
107
|
-
"❗ Copy failed from '{src}' to '{dst}': {err}",
|
108
|
-
src=disp_src,
|
109
|
-
dst=disp_dst,
|
110
|
-
err=str(e),
|
111
|
-
)
|
@@ -1,97 +0,0 @@
|
|
1
|
-
from janito.tools.adapters.local.adapter import register_local_tool
|
2
|
-
|
3
|
-
from janito.tools.tool_utils import display_path
|
4
|
-
from janito.tools.tool_base import ToolBase, ToolPermissions
|
5
|
-
from janito.report_events import ReportAction
|
6
|
-
from janito.i18n import tr
|
7
|
-
import os
|
8
|
-
from janito.tools.path_utils import expand_path
|
9
|
-
|
10
|
-
|
11
|
-
@register_local_tool
|
12
|
-
class CreateDirectoryTool(ToolBase):
|
13
|
-
"""
|
14
|
-
Create a new directory at the specified path.
|
15
|
-
|
16
|
-
Parameters:
|
17
|
-
path (str): Path for the new directory.
|
18
|
-
content (str): File content to write or process
|
19
|
-
overwrite (bool): Whether to overwrite existing files (default: False)
|
20
|
-
sources (str): Source file(s) to copy from
|
21
|
-
target (str): Destination path for copy operations
|
22
|
-
recursive (bool): Whether to process directories recursively
|
23
|
-
from_line (int): Starting line number for file reading
|
24
|
-
to_line (int): Ending line number for file reading
|
25
|
-
search_text (str): Text to search for in files
|
26
|
-
replacement_text (str): Text to replace search matches with
|
27
|
-
use_regex (bool): Whether to treat search as regex pattern
|
28
|
-
case_sensitive (bool): Whether search should be case sensitive
|
29
|
-
max_depth (int): Maximum directory depth to search
|
30
|
-
include_gitignored (bool): Whether to include .gitignored files
|
31
|
-
timeout (int): Timeout in seconds for operations
|
32
|
-
require_confirmation (bool): Whether to require user confirmation
|
33
|
-
data (dict): Chart data for visualization tools
|
34
|
-
title (str): Chart title
|
35
|
-
width (int): Chart width in pixels
|
36
|
-
height (int): Chart height in pixels
|
37
|
-
query (str): Search query for text search
|
38
|
-
paths (str): Directory or file paths to search in
|
39
|
-
src_path (str): Source path for move operations
|
40
|
-
dest_path (str): Destination path for move operations
|
41
|
-
code (str): Python code to execute
|
42
|
-
pattern (str): File pattern to match (e.g., '*.py')
|
43
|
-
|
44
|
-
Returns:
|
45
|
-
str: Status message indicating the result. Example:
|
46
|
-
- "5c5 Successfully created the directory at ..."
|
47
|
-
- "5d7 Cannot create directory: ..."
|
48
|
-
"""
|
49
|
-
|
50
|
-
permissions = ToolPermissions(write=True)
|
51
|
-
tool_name = "create_directory"
|
52
|
-
|
53
|
-
def run(self, path: str) -> str:
|
54
|
-
path = expand_path(path)
|
55
|
-
disp_path = display_path(path)
|
56
|
-
self.report_action(
|
57
|
-
tr("📁 Create directory '{disp_path}' ...", disp_path=disp_path),
|
58
|
-
ReportAction.CREATE,
|
59
|
-
)
|
60
|
-
try:
|
61
|
-
if os.path.exists(path):
|
62
|
-
if not os.path.isdir(path):
|
63
|
-
self.report_error(
|
64
|
-
tr(
|
65
|
-
"❌ Path '{disp_path}' exists and is not a directory.",
|
66
|
-
disp_path=disp_path,
|
67
|
-
)
|
68
|
-
)
|
69
|
-
return tr(
|
70
|
-
"❌ Path '{disp_path}' exists and is not a directory.",
|
71
|
-
disp_path=disp_path,
|
72
|
-
)
|
73
|
-
self.report_error(
|
74
|
-
tr(
|
75
|
-
"❗ Directory '{disp_path}' already exists.",
|
76
|
-
disp_path=disp_path,
|
77
|
-
)
|
78
|
-
)
|
79
|
-
return tr(
|
80
|
-
"❗ Cannot create directory: '{disp_path}' already exists.",
|
81
|
-
disp_path=disp_path,
|
82
|
-
)
|
83
|
-
os.makedirs(path, exist_ok=True)
|
84
|
-
self.report_success(tr("✅ Directory created"))
|
85
|
-
return tr(
|
86
|
-
"✅ Successfully created the directory at '{disp_path}'.",
|
87
|
-
disp_path=disp_path,
|
88
|
-
)
|
89
|
-
except Exception as e:
|
90
|
-
self.report_error(
|
91
|
-
tr(
|
92
|
-
"❌ Error creating directory '{disp_path}': {error}",
|
93
|
-
disp_path=disp_path,
|
94
|
-
error=e,
|
95
|
-
)
|
96
|
-
)
|
97
|
-
return tr("❌ Cannot create directory: {error}", error=e)
|