janito 2.32.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. janito/agent/setup_agent.py +26 -0
  2. janito/agent/templates/profiles/system_prompt_template_Developer_with_Python_Tools.txt.j2 +2 -0
  3. janito/agent/templates/profiles/system_prompt_template_developer.txt.j2 +2 -0
  4. janito/agent/templates/profiles/system_prompt_template_market_analyst.txt.j2 +2 -0
  5. janito/agent/templates/profiles/system_prompt_template_model_conversation_without_tools_or_context.txt.j2 +2 -0
  6. janito/cli/cli_commands/check_tools.py +212 -0
  7. janito/cli/cli_commands/list_plugins.py +52 -43
  8. janito/cli/core/getters.py +3 -0
  9. janito/cli/main_cli.py +9 -12
  10. janito/drivers/openai/driver.py +1 -0
  11. janito/drivers/zai/driver.py +1 -0
  12. janito/llm/auth_utils.py +14 -5
  13. janito/plugin_system/__init__.py +10 -0
  14. janito/{plugins → plugin_system}/base.py +5 -2
  15. janito/{plugins/core_loader_fixed.py → plugin_system/core_loader.py} +45 -26
  16. janito/plugin_system/core_loader_fixed.py +149 -0
  17. janito/plugins/__init__.py +31 -12
  18. janito/plugins/auto_loader_fixed.py +12 -11
  19. janito/plugins/builtin.py +15 -1
  20. janito/plugins/core/__init__.py +7 -0
  21. janito/plugins/core/codeanalyzer/__init__.py +43 -0
  22. janito/plugins/core/filemanager/__init__.py +124 -0
  23. janito/plugins/core/filemanager/tools/create_file.py +87 -0
  24. janito/plugins/core/filemanager/tools/replace_text_in_file.py +270 -0
  25. janito/plugins/core/imagedisplay/__init__.py +14 -0
  26. janito/plugins/core/imagedisplay/plugin.py +51 -0
  27. janito/plugins/core/imagedisplay/tools/__init__.py +1 -0
  28. janito/plugins/core/imagedisplay/tools/show_image.py +83 -0
  29. janito/{tools/adapters/local → plugins/core/imagedisplay/tools}/show_image_grid.py +13 -5
  30. janito/plugins/core/system/__init__.py +23 -0
  31. janito/plugins/core_adapter.py +11 -9
  32. janito/plugins/dev/__init__.py +7 -0
  33. janito/plugins/dev/pythondev/__init__.py +37 -0
  34. janito/plugins/dev/visualization/__init__.py +23 -0
  35. janito/plugins/discovery.py +5 -5
  36. janito/plugins/example_plugin.py +108 -0
  37. janito/plugins/manager.py +1 -1
  38. janito/plugins/tools/__init__.py +10 -0
  39. janito/{tools/adapters/local → plugins/tools}/ask_user.py +3 -3
  40. janito/plugins/tools/copy_file.py +87 -0
  41. janito/plugins/tools/core_tools_plugin.py +88 -0
  42. janito/plugins/tools/create_directory.py +70 -0
  43. janito/{tools/adapters/local → plugins/tools}/create_file.py +4 -4
  44. janito/plugins/tools/decorators.py +19 -0
  45. janito/plugins/tools/delete_text_in_file.py +134 -0
  46. janito/plugins/tools/fetch_url.py +466 -0
  47. janito/plugins/tools/find_files.py +143 -0
  48. janito/plugins/tools/get_file_outline/__init__.py +7 -0
  49. janito/plugins/tools/get_file_outline/core.py +122 -0
  50. janito/plugins/tools/get_file_outline/java_outline.py +47 -0
  51. janito/plugins/tools/get_file_outline/markdown_outline.py +14 -0
  52. janito/plugins/tools/get_file_outline/python_outline.py +303 -0
  53. janito/plugins/tools/get_file_outline/search_outline.py +36 -0
  54. janito/plugins/tools/move_file.py +131 -0
  55. janito/plugins/tools/open_html_in_browser.py +51 -0
  56. janito/plugins/tools/open_url.py +37 -0
  57. janito/plugins/tools/python_code_run.py +172 -0
  58. janito/plugins/tools/python_command_run.py +171 -0
  59. janito/plugins/tools/python_file_run.py +172 -0
  60. janito/plugins/tools/read_chart.py +259 -0
  61. janito/plugins/tools/read_files.py +58 -0
  62. janito/plugins/tools/remove_directory.py +55 -0
  63. janito/plugins/tools/remove_file.py +58 -0
  64. janito/{tools/adapters/local → plugins/tools}/replace_text_in_file.py +4 -4
  65. janito/plugins/tools/run_bash_command.py +183 -0
  66. janito/plugins/tools/run_powershell_command.py +218 -0
  67. janito/plugins/tools/search_text/__init__.py +7 -0
  68. janito/plugins/tools/search_text/core.py +205 -0
  69. janito/plugins/tools/search_text/match_lines.py +67 -0
  70. janito/plugins/tools/search_text/pattern_utils.py +73 -0
  71. janito/plugins/tools/search_text/traverse_directory.py +145 -0
  72. janito/{tools/adapters/local → plugins/tools}/show_image.py +15 -6
  73. janito/plugins/tools/show_image_grid.py +85 -0
  74. janito/plugins/tools/validate_file_syntax/__init__.py +7 -0
  75. janito/plugins/tools/validate_file_syntax/core.py +114 -0
  76. janito/plugins/tools/validate_file_syntax/css_validator.py +35 -0
  77. janito/plugins/tools/validate_file_syntax/html_validator.py +100 -0
  78. janito/plugins/tools/validate_file_syntax/jinja2_validator.py +50 -0
  79. janito/plugins/tools/validate_file_syntax/js_validator.py +27 -0
  80. janito/plugins/tools/validate_file_syntax/json_validator.py +6 -0
  81. janito/plugins/tools/validate_file_syntax/markdown_validator.py +109 -0
  82. janito/plugins/tools/validate_file_syntax/ps1_validator.py +32 -0
  83. janito/plugins/tools/validate_file_syntax/python_validator.py +5 -0
  84. janito/plugins/tools/validate_file_syntax/xml_validator.py +11 -0
  85. janito/plugins/tools/validate_file_syntax/yaml_validator.py +6 -0
  86. janito/plugins/tools/view_file.py +172 -0
  87. janito/plugins/ui/__init__.py +7 -0
  88. janito/plugins/ui/userinterface/__init__.py +16 -0
  89. janito/plugins/ui/userinterface/tools/ask_user.py +110 -0
  90. janito/plugins/web/__init__.py +7 -0
  91. janito/plugins/web/webtools/__init__.py +33 -0
  92. janito/{tools/adapters/local → plugins/web/webtools/tools}/fetch_url.py +37 -27
  93. janito/tools/__init__.py +31 -7
  94. janito/tools/adapters/__init__.py +6 -1
  95. janito/tools/adapters/local/__init__.py +7 -70
  96. janito/tools/cli_initializer.py +88 -0
  97. janito/tools/function_adapter.py +93 -16
  98. janito/tools/initialize.py +70 -0
  99. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/METADATA +1 -2
  100. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/RECORD +144 -76
  101. janito/plugins/core_loader.py +0 -120
  102. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/__init__.py +0 -0
  103. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/core.py +0 -0
  104. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/java_outline.py +0 -0
  105. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/markdown_outline.py +0 -0
  106. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/python_outline.py +0 -0
  107. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/get_file_outline/search_outline.py +0 -0
  108. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/__init__.py +0 -0
  109. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/core.py +0 -0
  110. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/match_lines.py +0 -0
  111. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/pattern_utils.py +0 -0
  112. /janito/{tools/adapters/local → plugins/core/codeanalyzer/tools}/search_text/traverse_directory.py +0 -0
  113. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/copy_file.py +0 -0
  114. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/create_directory.py +0 -0
  115. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/delete_text_in_file.py +0 -0
  116. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/find_files.py +0 -0
  117. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/move_file.py +0 -0
  118. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/read_files.py +0 -0
  119. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_directory.py +0 -0
  120. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/remove_file.py +0 -0
  121. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/__init__.py +0 -0
  122. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/core.py +0 -0
  123. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/css_validator.py +0 -0
  124. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/html_validator.py +0 -0
  125. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/jinja2_validator.py +0 -0
  126. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/js_validator.py +0 -0
  127. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/json_validator.py +0 -0
  128. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/markdown_validator.py +0 -0
  129. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/ps1_validator.py +0 -0
  130. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/python_validator.py +0 -0
  131. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/xml_validator.py +0 -0
  132. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/validate_file_syntax/yaml_validator.py +0 -0
  133. /janito/{tools/adapters/local → plugins/core/filemanager/tools}/view_file.py +0 -0
  134. /janito/{tools/adapters/local → plugins/core/system/tools}/run_bash_command.py +0 -0
  135. /janito/{tools/adapters/local → plugins/core/system/tools}/run_powershell_command.py +0 -0
  136. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_code_run.py +0 -0
  137. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_command_run.py +0 -0
  138. /janito/{tools/adapters/local → plugins/dev/pythondev/tools}/python_file_run.py +0 -0
  139. /janito/{tools/adapters/local → plugins/dev/visualization/tools}/read_chart.py +0 -0
  140. /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_html_in_browser.py +0 -0
  141. /janito/{tools/adapters/local → plugins/web/webtools/tools}/open_url.py +0 -0
  142. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/WHEEL +0 -0
  143. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/entry_points.txt +0 -0
  144. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/licenses/LICENSE +0 -0
  145. {janito-2.32.0.dist-info → janito-3.0.0.dist-info}/top_level.txt +0 -0
@@ -5,26 +5,27 @@ 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
8
9
  import importlib.util
9
10
  import sys
10
11
  from pathlib import Path
11
12
  from typing import Optional, List, Type
12
13
 
13
- from janito.plugins.base import Plugin, PluginMetadata
14
+ from janito.plugin_system.base import Plugin, PluginMetadata
14
15
  from janito.tools.function_adapter import create_function_tool
15
16
  from janito.tools.tool_base import ToolBase
16
17
 
17
18
 
18
19
  class CorePlugin(Plugin):
19
20
  """Working core plugin implementation."""
20
-
21
+
21
22
  def __init__(self, name: str, description: str, tools: list):
22
23
  self._plugin_name = name
23
24
  self._description = description
24
25
  self._tools = tools
25
26
  self._tool_classes = []
26
27
  super().__init__() # Call super after setting attributes
27
-
28
+
28
29
  def get_metadata(self) -> PluginMetadata:
29
30
  return PluginMetadata(
30
31
  name=self._plugin_name,
@@ -33,10 +34,10 @@ class CorePlugin(Plugin):
33
34
  author="Janito",
34
35
  license="MIT",
35
36
  )
36
-
37
+
37
38
  def get_tools(self) -> List[Type[ToolBase]]:
38
39
  return self._tool_classes
39
-
40
+
40
41
  def initialize(self):
41
42
  """Initialize by creating tool classes."""
42
43
  self._tool_classes = []
@@ -49,10 +50,10 @@ class CorePlugin(Plugin):
49
50
  def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
50
51
  """
51
52
  Load a core plugin by name.
52
-
53
+
53
54
  Args:
54
55
  plugin_name: Name of the plugin (e.g., 'core.filemanager')
55
-
56
+
56
57
  Returns:
57
58
  Plugin instance if loaded successfully
58
59
  """
@@ -60,49 +61,67 @@ def load_core_plugin(plugin_name: str) -> Optional[Plugin]:
60
61
  # Parse plugin name
61
62
  if "." not in plugin_name:
62
63
  return None
63
-
64
+
64
65
  parts = plugin_name.split(".")
65
66
  if len(parts) != 2:
66
67
  return None
67
-
68
+
68
69
  package_name, submodule_name = parts
69
-
70
+
70
71
  # Handle imagedisplay specially
71
72
  if plugin_name == "core.imagedisplay":
72
73
  # Import the actual plugin class
73
74
  try:
74
- from plugins.core.imagedisplay.plugin import ImageDisplayPlugin
75
- return ImageDisplayPlugin()
76
- except ImportError:
77
- # If import fails, return None - don't return True
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}")
78
82
  return None
79
-
83
+
80
84
  # Build path to plugin
81
- plugin_path = Path("plugins") / package_name / submodule_name / "__init__.py"
85
+ plugin_path = (
86
+ Path("janito/plugins") / package_name / submodule_name / "__init__.py"
87
+ )
82
88
  if not plugin_path.exists():
83
89
  return None
84
-
90
+
85
91
  # Load the module
86
92
  spec = importlib.util.spec_from_file_location(plugin_name, plugin_path)
87
93
  if spec is None or spec.loader is None:
88
94
  return None
89
-
95
+
90
96
  module = importlib.util.module_from_spec(spec)
91
97
  spec.loader.exec_module(module)
92
-
98
+
93
99
  # Get plugin info
94
100
  name = getattr(module, "__plugin_name__", plugin_name)
95
- description = getattr(module, "__plugin_description__", f"Core plugin: {plugin_name}")
101
+ description = getattr(
102
+ module, "__plugin_description__", f"Core plugin: {plugin_name}"
103
+ )
96
104
  tools = getattr(module, "__plugin_tools__", [])
97
-
105
+
98
106
  if not tools:
99
107
  return None
100
-
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
+
101
120
  # Create plugin
102
- plugin = CorePlugin(name, description, tools)
121
+ plugin = CorePlugin(name, description, valid_tools)
103
122
  plugin.initialize()
104
123
  return plugin
105
-
124
+
106
125
  except Exception as e:
107
126
  print(f"Error loading core plugin {plugin_name}: {e}")
108
127
  return None
@@ -120,6 +139,6 @@ def get_core_plugins() -> list:
120
139
  "ui.userinterface",
121
140
  "web.webtools",
122
141
  ]
123
-
142
+
124
143
  # All core plugins are always available
125
- return core_plugins
144
+ return core_plugins
@@ -0,0 +1,149 @@
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
@@ -1,17 +1,36 @@
1
1
  """
2
- Plugin system for janito.
2
+ Plugin System for Development Tools
3
3
 
4
- This package provides a flexible plugin system that allows extending
5
- janito's functionality with custom tools, commands, and features.
4
+ This package organizes all available tools into logical plugin groups
5
+ for easier discovery and usage.
6
6
  """
7
7
 
8
- from .manager import PluginManager
9
- from .base import Plugin, PluginMetadata
10
- from .discovery import discover_plugins
8
+ __version__ = "1.0.0"
9
+ __author__ = "Development Assistant"
11
10
 
12
- __all__ = [
13
- "PluginManager",
14
- "Plugin",
15
- "PluginMetadata",
16
- "discover_plugins",
17
- ]
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)
@@ -9,12 +9,12 @@ import os
9
9
  from pathlib import Path
10
10
  from typing import List
11
11
  from janito.plugins.manager import PluginManager
12
- from janito.plugins.core_loader_fixed import load_core_plugin, get_core_plugins
12
+ from janito.plugin_system.core_loader_fixed import load_core_plugin, get_core_plugins
13
13
 
14
14
  # List of core plugins that should be enabled by default
15
15
  CORE_PLUGINS = [
16
16
  "core.filemanager",
17
- "core.codeanalyzer",
17
+ "core.codeanalyzer",
18
18
  "core.system",
19
19
  "core.imagedisplay",
20
20
  "dev.pythondev",
@@ -27,18 +27,18 @@ CORE_PLUGINS = [
27
27
  def load_core_plugins(pm: PluginManager = None) -> List[str]:
28
28
  """
29
29
  Load all core plugins.
30
-
30
+
31
31
  Args:
32
32
  pm: PluginManager instance. If None, creates a new one.
33
-
33
+
34
34
  Returns:
35
35
  List of successfully loaded plugin names
36
36
  """
37
37
  if pm is None:
38
38
  pm = PluginManager()
39
-
39
+
40
40
  loaded = []
41
-
41
+
42
42
  # Load core plugins
43
43
  for plugin_name in CORE_PLUGINS:
44
44
  try:
@@ -49,14 +49,14 @@ def load_core_plugins(pm: PluginManager = None) -> List[str]:
49
49
  loaded.append(plugin_name)
50
50
  except Exception as e:
51
51
  print(f"Warning: Failed to load core plugin {plugin_name}: {e}")
52
-
52
+
53
53
  return loaded
54
54
 
55
55
 
56
56
  def get_loaded_core_plugins() -> List[str]:
57
57
  """
58
58
  Get list of currently loaded core plugins.
59
-
59
+
60
60
  Returns:
61
61
  List of loaded core plugin names
62
62
  """
@@ -68,10 +68,10 @@ def get_loaded_core_plugins() -> List[str]:
68
68
  def is_core_plugin(plugin_name: str) -> bool:
69
69
  """
70
70
  Check if a plugin is a core plugin.
71
-
71
+
72
72
  Args:
73
73
  plugin_name: Name of the plugin to check
74
-
74
+
75
75
  Returns:
76
76
  True if it's a core plugin
77
77
  """
@@ -81,10 +81,11 @@ def is_core_plugin(plugin_name: str) -> bool:
81
81
  # Auto-load core plugins when module is imported
82
82
  _plugin_manager = None
83
83
 
84
+
84
85
  def get_plugin_manager() -> PluginManager:
85
86
  """Get the global plugin manager with core plugins loaded."""
86
87
  global _plugin_manager
87
88
  if _plugin_manager is None:
88
89
  _plugin_manager = PluginManager()
89
90
  load_core_plugins(_plugin_manager)
90
- return _plugin_manager
91
+ return _plugin_manager
janito/plugins/builtin.py CHANGED
@@ -7,7 +7,7 @@ with janito and available by default without requiring external installation.
7
7
 
8
8
  import importlib
9
9
  from typing import Dict, List, Optional, Type
10
- from janito.plugins.base import Plugin
10
+ from janito.plugin_system.base import Plugin
11
11
 
12
12
 
13
13
  class BuiltinPluginRegistry:
@@ -83,6 +83,20 @@ try:
83
83
  "documentation_generator", DocumentationGeneratorPlugin
84
84
  )
85
85
 
86
+ # Register core tools plugin
87
+ from janito.plugins.tools import CoreToolsPlugin
88
+
89
+ BuiltinPluginRegistry.register("core_tools", CoreToolsPlugin)
90
+
86
91
  except ImportError:
87
92
  # janito-coder not available, skip registration
88
93
  pass
94
+
95
+ # Register core tools plugin (always available)
96
+ try:
97
+ from janito.plugins.tools import CoreToolsPlugin
98
+
99
+ BuiltinPluginRegistry.register("core_tools", CoreToolsPlugin)
100
+ except ImportError:
101
+ # Should not happen, but handle gracefully
102
+ pass
@@ -0,0 +1,7 @@
1
+ """
2
+ Core Plugin Package
3
+
4
+ Contains essential system and file management plugins.
5
+ """
6
+
7
+ __all__ = ["filemanager", "codeanalyzer", "system"]
@@ -0,0 +1,43 @@
1
+ """
2
+ Code Analyzer Plugin
3
+
4
+ Tools for understanding and searching code structure.
5
+ """
6
+
7
+ from typing import List, Optional
8
+
9
+
10
+ def get_file_outline(path: str) -> str:
11
+ """Get file structure (classes, functions, etc.)"""
12
+ return f"get_file_outline(path='{path}')"
13
+
14
+
15
+ get_file_outline.tool_name = "get_file_outline"
16
+
17
+
18
+ def search_outline(path: str) -> str:
19
+ """Search within file outlines"""
20
+ return f"search_outline(path='{path}')"
21
+
22
+
23
+ search_outline.tool_name = "search_outline"
24
+
25
+
26
+ def search_text(
27
+ paths: str,
28
+ query: str,
29
+ use_regex: bool = False,
30
+ case_sensitive: bool = True,
31
+ max_depth: Optional[int] = None,
32
+ ) -> str:
33
+ """Full-text search across files with regex support"""
34
+ return f"search_text(paths='{paths}', query='{query}', regex={use_regex})"
35
+
36
+
37
+ search_text.tool_name = "search_text"
38
+
39
+
40
+ # Plugin metadata
41
+ __plugin_name__ = "core.codeanalyzer"
42
+ __plugin_description__ = "Code analysis and structure understanding"
43
+ __plugin_tools__ = [get_file_outline, search_outline, search_text]
@@ -0,0 +1,124 @@
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
+ ]