janito 3.3.0__py3-none-any.whl → 3.5.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/README.md +3 -0
- janito/cli/chat_mode/bindings.py +50 -0
- janito/cli/chat_mode/session.py +12 -1
- janito/cli/chat_mode/shell/commands/multi.py +5 -0
- janito/cli/chat_mode/shell/commands/security/allowed_sites.py +47 -33
- janito/cli/cli_commands/list_plugins.py +13 -8
- janito/cli/core/model_guesser.py +40 -24
- janito/cli/prompt_core.py +47 -9
- janito/cli/rich_terminal_reporter.py +2 -2
- janito/hello.txt +0 -0
- janito/i18n/it.py +46 -46
- janito/llm/agent.py +32 -16
- janito/llm/cancellation_manager.py +63 -0
- janito/llm/driver.py +8 -0
- janito/llm/enter_cancellation.py +107 -0
- janito/{plugin_system_backup_20250825_070018 → plugin_system}/core_loader.py +76 -3
- janito/{plugin_system_backup_20250825_070018 → plugin_system}/core_loader_fixed.py +79 -3
- janito/plugins/__init__.py +29 -21
- janito/{plugins_backup_20250825_070018 → plugins}/auto_loader.py +12 -11
- janito/plugins/builtin.py +1 -1
- janito/plugins/core/filemanager/tools/copy_file.py +1 -25
- janito/plugins/core/filemanager/tools/create_directory.py +1 -28
- janito/plugins/core/filemanager/tools/create_file.py +3 -27
- janito/plugins/core/filemanager/tools/delete_text_in_file.py +0 -1
- janito/plugins/core/imagedisplay/plugin.py +1 -1
- janito/plugins/core_adapter.py +131 -0
- janito/plugins/discovery.py +3 -3
- janito/{plugins_backup_20250825_070018 → plugins}/discovery_core.py +14 -9
- janito/plugins/example_plugin.py +1 -1
- janito/plugins/manager.py +1 -1
- janito/{plugins_backup_20250825_070018 → plugins}/tools/core_tools_plugin.py +9 -10
- janito/{plugins_backup_20250825_070018 → plugins}/tools/create_file.py +2 -2
- janito/{plugins_backup_20250825_070018 → plugins}/tools/delete_text_in_file.py +0 -1
- janito/providers/__init__.py +1 -0
- janito/providers/together/__init__.py +1 -0
- janito/providers/together/model_info.py +69 -0
- janito/providers/together/provider.py +108 -0
- janito/tools/base.py +1 -31
- janito/tools/cli_initializer.py +1 -1
- janito/tools/initialize.py +1 -1
- janito/tools/loop_protection_decorator.py +114 -117
- janito/tools/tool_base.py +114 -142
- janito/tools/tools_schema.py +6 -12
- janito-3.5.0.dist-info/METADATA +229 -0
- {janito-3.3.0.dist-info → janito-3.5.0.dist-info}/RECORD +98 -162
- janito/plugins/__main__.py +0 -85
- janito/plugins/base.py +0 -57
- janito/plugins/core_loader.py +0 -144
- 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/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/filemanager/__init__.py +0 -124
- janito/plugins_backup_20250825_070018/core/filemanager/tools/copy_file.py +0 -87
- janito/plugins_backup_20250825_070018/core/filemanager/tools/create_directory.py +0 -70
- 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/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/core_adapter.py +0 -55
- 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/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/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/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/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/function_adapter.py +0 -176
- janito-3.3.0.dist-info/METADATA +0 -83
- /janito/{plugin_system_backup_20250825_070018 → plugin_system}/__init__.py +0 -0
- /janito/{plugin_system_backup_20250825_070018 → plugin_system}/base.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/auto_loader_fixed.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/__init__.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/ask_user.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/copy_file.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/create_directory.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/decorators.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/fetch_url.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/find_files.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/get_file_outline/__init__.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/get_file_outline/core.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/get_file_outline/java_outline.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/get_file_outline/markdown_outline.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/get_file_outline/python_outline.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/get_file_outline/search_outline.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/move_file.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/open_html_in_browser.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/open_url.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/python_code_run.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/python_command_run.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/python_file_run.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/read_chart.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/read_files.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/remove_directory.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/remove_file.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/replace_text_in_file.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/run_bash_command.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/run_powershell_command.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/search_text/__init__.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/search_text/core.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/search_text/match_lines.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/search_text/pattern_utils.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/codeanalyzer → plugins}/tools/search_text/traverse_directory.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/show_image.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/show_image_grid.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/validate_file_syntax/__init__.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/validate_file_syntax/core.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/css_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/html_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/jinja2_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/js_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/json_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/markdown_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/ps1_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/python_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/xml_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018/core/filemanager → plugins}/tools/validate_file_syntax/yaml_validator.py +0 -0
- /janito/{plugins_backup_20250825_070018 → plugins}/tools/view_file.py +0 -0
- {janito-3.3.0.dist-info → janito-3.5.0.dist-info}/WHEEL +0 -0
- {janito-3.3.0.dist-info → janito-3.5.0.dist-info}/entry_points.txt +0 -0
- {janito-3.3.0.dist-info → janito-3.5.0.dist-info}/licenses/LICENSE +0 -0
- {janito-3.3.0.dist-info → janito-3.5.0.dist-info}/top_level.txt +0 -0
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/base.py
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Base classes for janito plugins.
|
3
|
-
"""
|
4
|
-
|
5
|
-
from abc import ABC, abstractmethod
|
6
|
-
from dataclasses import dataclass
|
7
|
-
from typing import Dict, Any, List, Optional, Type
|
8
|
-
|
9
|
-
@dataclass
|
10
|
-
class PluginMetadata:
|
11
|
-
name: str
|
12
|
-
version: str
|
13
|
-
description: str
|
14
|
-
author: str
|
15
|
-
license: str = "MIT"
|
16
|
-
homepage: Optional[str] = None
|
17
|
-
dependencies: List[str] = None
|
18
|
-
|
19
|
-
def __post_init__(self):
|
20
|
-
if self.dependencies is None:
|
21
|
-
self.dependencies = []
|
22
|
-
|
23
|
-
@dataclass
|
24
|
-
class PluginResource:
|
25
|
-
name: str
|
26
|
-
type: str
|
27
|
-
description: str
|
28
|
-
schema: Optional[Dict[str, Any]] = None
|
29
|
-
|
30
|
-
class Plugin(ABC):
|
31
|
-
def __init__(self):
|
32
|
-
self.metadata: PluginMetadata = self.get_metadata()
|
33
|
-
|
34
|
-
@abstractmethod
|
35
|
-
def get_metadata(self) -> PluginMetadata:
|
36
|
-
pass
|
37
|
-
|
38
|
-
def get_tools(self):
|
39
|
-
return []
|
40
|
-
|
41
|
-
def get_commands(self):
|
42
|
-
return {}
|
43
|
-
|
44
|
-
def initialize(self):
|
45
|
-
pass
|
46
|
-
|
47
|
-
def cleanup(self):
|
48
|
-
pass
|
49
|
-
|
50
|
-
def get_config_schema(self):
|
51
|
-
return {}
|
52
|
-
|
53
|
-
def validate_config(self, config):
|
54
|
-
return True
|
55
|
-
|
56
|
-
def get_resources(self):
|
57
|
-
return []
|
janito/plugins/core_loader.py
DELETED
@@ -1,144 +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
|
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
|
@@ -1,36 +0,0 @@
|
|
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)
|
@@ -1,102 +0,0 @@
|
|
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
|
@@ -1,84 +0,0 @@
|
|
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
|
@@ -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 +0,0 @@
|
|
1
|
-
# Outline tools and parsers package
|
@@ -1,122 +0,0 @@
|
|
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
|
-
)
|
@@ -1 +0,0 @@
|
|
1
|
-
from .core import SearchTextTool
|