janito 2.7.0__py3-none-any.whl → 2.8.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 (116) hide show
  1. janito/__init__.py +0 -1
  2. janito/__main__.py +0 -1
  3. janito/_version.py +0 -3
  4. janito/agent/setup_agent.py +77 -10
  5. janito/agent/templates/profiles/{system_prompt_template_plain_software_developer.txt.j2 → system_prompt_template_Developer_with_Python_Tools.txt.j2} +5 -1
  6. janito/agent/templates/profiles/system_prompt_template_developer.txt.j2 +3 -12
  7. janito/cli/__init__.py +0 -1
  8. janito/cli/chat_mode/bindings.py +1 -1
  9. janito/cli/chat_mode/chat_entry.py +0 -2
  10. janito/cli/chat_mode/prompt_style.py +0 -3
  11. janito/cli/chat_mode/script_runner.py +9 -5
  12. janito/cli/chat_mode/session.py +80 -35
  13. janito/cli/chat_mode/session_profile_select.py +61 -52
  14. janito/cli/chat_mode/shell/commands/__init__.py +1 -5
  15. janito/cli/chat_mode/shell/commands/_priv_check.py +1 -0
  16. janito/cli/chat_mode/shell/commands/bang.py +10 -3
  17. janito/cli/chat_mode/shell/commands/conversation_restart.py +24 -7
  18. janito/cli/chat_mode/shell/commands/execute.py +22 -7
  19. janito/cli/chat_mode/shell/commands/help.py +4 -1
  20. janito/cli/chat_mode/shell/commands/model.py +13 -5
  21. janito/cli/chat_mode/shell/commands/privileges.py +21 -0
  22. janito/cli/chat_mode/shell/commands/prompt.py +0 -2
  23. janito/cli/chat_mode/shell/commands/read.py +22 -5
  24. janito/cli/chat_mode/shell/commands/tools.py +15 -4
  25. janito/cli/chat_mode/shell/commands/write.py +22 -5
  26. janito/cli/chat_mode/shell/input_history.py +3 -1
  27. janito/cli/chat_mode/shell/session/manager.py +0 -2
  28. janito/cli/chat_mode/toolbar.py +25 -19
  29. janito/cli/cli_commands/list_models.py +1 -1
  30. janito/cli/cli_commands/list_providers.py +1 -0
  31. janito/cli/cli_commands/list_tools.py +35 -7
  32. janito/cli/cli_commands/model_utils.py +5 -3
  33. janito/cli/cli_commands/show_config.py +12 -0
  34. janito/cli/cli_commands/show_system_prompt.py +23 -9
  35. janito/cli/config.py +0 -13
  36. janito/cli/core/getters.py +2 -0
  37. janito/cli/core/runner.py +25 -8
  38. janito/cli/core/setters.py +13 -76
  39. janito/cli/main_cli.py +9 -25
  40. janito/cli/prompt_core.py +19 -18
  41. janito/cli/prompt_setup.py +6 -3
  42. janito/cli/rich_terminal_reporter.py +19 -5
  43. janito/cli/single_shot_mode/handler.py +14 -5
  44. janito/cli/verbose_output.py +5 -1
  45. janito/config_manager.py +4 -0
  46. janito/drivers/azure_openai/driver.py +27 -30
  47. janito/drivers/openai/driver.py +52 -36
  48. janito/formatting_token.py +12 -4
  49. janito/llm/agent.py +15 -6
  50. janito/llm/driver.py +1 -0
  51. janito/provider_registry.py +31 -70
  52. janito/providers/__init__.py +1 -0
  53. janito/providers/anthropic/model_info.py +0 -1
  54. janito/providers/anthropic/provider.py +9 -14
  55. janito/providers/azure_openai/provider.py +9 -4
  56. janito/providers/deepseek/provider.py +5 -4
  57. janito/providers/google/model_info.py +4 -2
  58. janito/providers/google/provider.py +11 -5
  59. janito/providers/groq/__init__.py +1 -0
  60. janito/providers/groq/model_info.py +46 -0
  61. janito/providers/groq/provider.py +76 -0
  62. janito/providers/moonshotai/provider.py +11 -4
  63. janito/providers/openai/model_info.py +0 -1
  64. janito/providers/openai/provider.py +6 -7
  65. janito/tools/__init__.py +2 -0
  66. janito/tools/adapters/local/__init__.py +2 -1
  67. janito/tools/adapters/local/adapter.py +21 -4
  68. janito/tools/adapters/local/ask_user.py +1 -0
  69. janito/tools/adapters/local/copy_file.py +1 -0
  70. janito/tools/adapters/local/create_directory.py +1 -0
  71. janito/tools/adapters/local/create_file.py +1 -0
  72. janito/tools/adapters/local/delete_text_in_file.py +2 -1
  73. janito/tools/adapters/local/fetch_url.py +1 -0
  74. janito/tools/adapters/local/find_files.py +7 -6
  75. janito/tools/adapters/local/get_file_outline/core.py +1 -0
  76. janito/tools/adapters/local/get_file_outline/java_outline.py +22 -15
  77. janito/tools/adapters/local/get_file_outline/search_outline.py +1 -0
  78. janito/tools/adapters/local/move_file.py +1 -0
  79. janito/tools/adapters/local/open_html_in_browser.py +15 -5
  80. janito/tools/adapters/local/open_url.py +1 -0
  81. janito/tools/adapters/local/python_code_run.py +1 -0
  82. janito/tools/adapters/local/python_command_run.py +1 -0
  83. janito/tools/adapters/local/python_file_run.py +1 -0
  84. janito/tools/adapters/local/read_files.py +19 -4
  85. janito/tools/adapters/local/remove_directory.py +1 -0
  86. janito/tools/adapters/local/remove_file.py +1 -0
  87. janito/tools/adapters/local/replace_text_in_file.py +4 -3
  88. janito/tools/adapters/local/run_bash_command.py +1 -0
  89. janito/tools/adapters/local/run_powershell_command.py +1 -0
  90. janito/tools/adapters/local/search_text/core.py +18 -17
  91. janito/tools/adapters/local/search_text/match_lines.py +5 -5
  92. janito/tools/adapters/local/search_text/pattern_utils.py +1 -1
  93. janito/tools/adapters/local/search_text/traverse_directory.py +7 -7
  94. janito/tools/adapters/local/validate_file_syntax/core.py +1 -1
  95. janito/tools/adapters/local/validate_file_syntax/html_validator.py +8 -1
  96. janito/tools/disabled_tools.py +68 -0
  97. janito/tools/path_security.py +18 -11
  98. janito/tools/permissions.py +6 -0
  99. janito/tools/permissions_parse.py +4 -3
  100. janito/tools/tool_base.py +11 -5
  101. janito/tools/tool_use_tracker.py +1 -4
  102. janito/tools/tool_utils.py +1 -1
  103. janito/tools/tools_adapter.py +57 -25
  104. {janito-2.7.0.dist-info → janito-2.8.0.dist-info}/METADATA +4 -12
  105. janito-2.8.0.dist-info/RECORD +202 -0
  106. janito/cli/chat_mode/shell/commands/livelogs.py +0 -49
  107. janito/drivers/mistralai/driver.py +0 -41
  108. janito/providers/mistralai/model_info.py +0 -37
  109. janito/providers/mistralai/provider.py +0 -72
  110. janito/providers/provider_static_info.py +0 -21
  111. janito-2.7.0.dist-info/RECORD +0 -202
  112. /janito/agent/templates/profiles/{system_prompt_template_assistant.txt.j2 → system_prompt_template_model_conversation_without_tools_or_context.txt.j2} +0 -0
  113. {janito-2.7.0.dist-info → janito-2.8.0.dist-info}/WHEEL +0 -0
  114. {janito-2.7.0.dist-info → janito-2.8.0.dist-info}/entry_points.txt +0 -0
  115. {janito-2.7.0.dist-info → janito-2.8.0.dist-info}/licenses/LICENSE +0 -0
  116. {janito-2.7.0.dist-info → janito-2.8.0.dist-info}/top_level.txt +0 -0
@@ -14,11 +14,10 @@ unavailable_reason = OpenAIModelDriver.unavailable_reason
14
14
 
15
15
  class OpenAIProvider(LLMProvider):
16
16
  name = "openai"
17
- maintainer = "João Pinto <lamego.pinto@gmail.com>"
17
+ NAME = "openai"
18
+ MAINTAINER = "João Pinto <lamego.pinto@gmail.com>"
18
19
  MODEL_SPECS = MODEL_SPECS
19
- DEFAULT_MODEL = (
20
- "gpt-4.1" # Options: gpt-4.1, gpt-4o, o3-mini, o4-mini,
21
- )
20
+ DEFAULT_MODEL = "gpt-4.1" # Options: gpt-4.1, gpt-4o, o3-mini, o4-mini,
22
21
 
23
22
  def __init__(
24
23
  self, auth_manager: LLMAuthManager = None, config: LLMDriverConfig = None
@@ -31,7 +30,7 @@ class OpenAIProvider(LLMProvider):
31
30
  self._driver = None
32
31
  else:
33
32
  self.auth_manager = auth_manager or LLMAuthManager()
34
- self._api_key = self.auth_manager.get_credentials(type(self).name)
33
+ self._api_key = self.auth_manager.get_credentials(type(self).NAME)
35
34
  self._tools_adapter = get_local_tools_adapter()
36
35
  self._driver_config = config or LLMDriverConfig(model=None)
37
36
  if not self._driver_config.model:
@@ -77,7 +76,7 @@ class OpenAIProvider(LLMProvider):
77
76
  Creates and returns a new OpenAIModelDriver instance with input/output queues.
78
77
  """
79
78
  driver = OpenAIModelDriver(
80
- tools_adapter=self._tools_adapter, provider_name=self.name
79
+ tools_adapter=self._tools_adapter, provider_name=self.NAME
81
80
  )
82
81
  driver.config = self._driver_config
83
82
  # NOTE: The caller is responsible for calling driver.start() if background processing is needed.
@@ -108,4 +107,4 @@ class OpenAIProvider(LLMProvider):
108
107
  return self._tools_adapter.execute_by_name(tool_name, *args, **kwargs)
109
108
 
110
109
 
111
- LLMProviderRegistry.register(OpenAIProvider.name, OpenAIProvider)
110
+ LLMProviderRegistry.register(OpenAIProvider.NAME, OpenAIProvider)
janito/tools/__init__.py CHANGED
@@ -7,6 +7,7 @@ from janito.tools.adapters.local import (
7
7
  def get_local_tools_adapter(workdir=None, allowed_permissions=None):
8
8
  # Use set_verbose_tools on the returned adapter to set verbosity as needed
9
9
  import os
10
+
10
11
  if workdir is not None and not os.path.exists(workdir):
11
12
  os.makedirs(workdir, exist_ok=True)
12
13
  # Permissions are now managed globally; ignore allowed_permissions argument except for backward compatibility
@@ -16,6 +17,7 @@ def get_local_tools_adapter(workdir=None, allowed_permissions=None):
16
17
  if workdir is not None:
17
18
  try:
18
19
  import os
20
+
19
21
  if not os.path.exists(workdir):
20
22
  os.makedirs(workdir, exist_ok=True)
21
23
  os.chdir(workdir)
@@ -31,9 +31,11 @@ from janito.tools.permissions import get_global_allowed_permissions
31
31
  # Singleton tools adapter with all standard tools registered
32
32
  local_tools_adapter = LocalToolsAdapter(workdir=os.getcwd())
33
33
 
34
+
34
35
  def get_local_tools_adapter(workdir=None):
35
36
  return LocalToolsAdapter(workdir=workdir or os.getcwd())
36
37
 
38
+
37
39
  # Register tools
38
40
  for tool_class in [
39
41
  AskUserTool,
@@ -63,4 +65,3 @@ for tool_class in [
63
65
  local_tools_adapter.register_tool(tool_class)
64
66
 
65
67
  # DEBUG: Print registered tools at startup
66
-
@@ -40,6 +40,7 @@ class LocalToolsAdapter(ToolsAdapter):
40
40
  # to UI components even if the caller did not supply a custom bus.
41
41
  if event_bus is None:
42
42
  from janito.event_bus.bus import event_bus as global_event_bus
43
+
43
44
  event_bus = global_event_bus
44
45
 
45
46
  super().__init__(tools=tools, event_bus=event_bus)
@@ -48,6 +49,7 @@ class LocalToolsAdapter(ToolsAdapter):
48
49
  self._tools: Dict[str, Dict[str, Any]] = {}
49
50
 
50
51
  import os
52
+
51
53
  self.workdir = workdir or os.getcwd()
52
54
  # Ensure *some* workdir is set – fallback to CWD.
53
55
  if not self.workdir:
@@ -93,27 +95,39 @@ class LocalToolsAdapter(ToolsAdapter):
93
95
  # Lookup helpers used by ToolsAdapterBase
94
96
  # ------------------------------------------------------------------
95
97
  def get_tool(self, name: str):
96
- return self._tools[name]["instance"] if name in self._tools else None
98
+ from janito.tools.disabled_tools import is_tool_disabled
99
+
100
+ if name in self._tools and not is_tool_disabled(name):
101
+ return self._tools[name]["instance"]
102
+ return None
97
103
 
98
104
  def list_tools(self):
105
+ from janito.tools.disabled_tools import is_tool_disabled
106
+
99
107
  return [
100
108
  name
101
109
  for name, entry in self._tools.items()
102
- if self.is_tool_allowed(entry["instance"])
110
+ if self.is_tool_allowed(entry["instance"]) and not is_tool_disabled(name)
103
111
  ]
104
112
 
105
113
  def get_tool_classes(self):
114
+ from janito.tools.disabled_tools import is_tool_disabled
115
+
106
116
  return [
107
117
  entry["class"]
108
118
  for entry in self._tools.values()
109
119
  if self.is_tool_allowed(entry["instance"])
120
+ and not is_tool_disabled(entry["instance"].tool_name)
110
121
  ]
111
122
 
112
123
  def get_tools(self):
124
+ from janito.tools.disabled_tools import is_tool_disabled
125
+
113
126
  return [
114
127
  entry["instance"]
115
128
  for entry in self._tools.values()
116
129
  if self.is_tool_allowed(entry["instance"])
130
+ and not is_tool_disabled(entry["instance"].tool_name)
117
131
  ]
118
132
 
119
133
  # ------------------------------------------------------------------
@@ -125,7 +139,9 @@ class LocalToolsAdapter(ToolsAdapter):
125
139
  raise TypeError(f"Tool '{tool}' must implement a callable 'run' method.")
126
140
  tool_name = getattr(tool, "tool_name", None)
127
141
  if not tool_name or not isinstance(tool_name, str):
128
- raise ValueError(f"Tool '{tool}' must provide a 'tool_name' (str) attribute.")
142
+ raise ValueError(
143
+ f"Tool '{tool}' must provide a 'tool_name' (str) attribute."
144
+ )
129
145
  if tool_name in self._tools:
130
146
  raise ValueError(f"Tool '{tool_name}' is already registered.")
131
147
  self._tools[tool_name] = {
@@ -139,6 +155,7 @@ class LocalToolsAdapter(ToolsAdapter):
139
155
  # Decorator helper for quick registration of local tools
140
156
  # -------------------------------------------------------------------------
141
157
 
158
+
142
159
  def register_local_tool(tool=None):
143
160
  """Class decorator that registers the tool on the *singleton* adapter.
144
161
 
@@ -150,7 +167,7 @@ def register_local_tool(tool=None):
150
167
  """
151
168
 
152
169
  def decorator(cls):
153
- # Register the tool on a *fresh* adapter instance to avoid circular
170
+ # Register the tool on a *fresh* adapter instance to avoid circular
154
171
  # import issues during package initialisation. This keeps behaviour
155
172
  # identical to the original implementation while still allowing
156
173
  # immediate use via the singleton in janito.tools.adapters.local.
@@ -27,6 +27,7 @@ class AskUserTool(ToolBase):
27
27
  - "No"
28
28
  - "Some detailed answer..."
29
29
  """
30
+
30
31
  permissions = ToolPermissions(read=True)
31
32
  tool_name = "ask_user"
32
33
 
@@ -21,6 +21,7 @@ class CopyFileTool(ToolBase):
21
21
  Returns:
22
22
  str: Status string for each copy operation.
23
23
  """
24
+
24
25
  permissions = ToolPermissions(read=True, write=True)
25
26
  tool_name = "copy_file"
26
27
 
@@ -18,6 +18,7 @@ class CreateDirectoryTool(ToolBase):
18
18
  - "5c5 Successfully created the directory at ..."
19
19
  - "5d7 Cannot create directory: ..."
20
20
  """
21
+
21
22
  permissions = ToolPermissions(write=True)
22
23
  tool_name = "create_directory"
23
24
 
@@ -25,6 +25,7 @@ class CreateFileTool(ToolBase):
25
25
 
26
26
  Note: Syntax validation is automatically performed after this operation.
27
27
  """
28
+
28
29
  permissions = ToolPermissions(write=True)
29
30
  tool_name = "create_file"
30
31
 
@@ -19,6 +19,7 @@ class DeleteTextInFileTool(ToolBase):
19
19
  Returns:
20
20
  str: Status message indicating the result.
21
21
  """
22
+
22
23
  permissions = ToolPermissions(read=True, write=True)
23
24
  tool_name = "delete_text_in_file"
24
25
 
@@ -62,7 +63,7 @@ class DeleteTextInFileTool(ToolBase):
62
63
  return tr(
63
64
  "Deleted {count} block(s) between markers in {path}. ",
64
65
  count=deleted_blocks,
65
- path=path
66
+ path=path,
66
67
  ) + (f"\n{validation_result}" if validation_result else "")
67
68
  except Exception as e:
68
69
  self.report_error(tr(" ❌ Error: {error}", error=e), ReportAction.REPLACE)
@@ -21,6 +21,7 @@ class FetchUrlTool(ToolBase):
21
21
  - "No lines found for the provided search strings."
22
22
  - "Warning: Empty URL provided. Operation skipped."
23
23
  """
24
+
24
25
  permissions = ToolPermissions(read=True)
25
26
  tool_name = "fetch_url"
26
27
 
@@ -61,7 +61,9 @@ class FindFilesTool(ToolBase):
61
61
  break
62
62
  return dir_output
63
63
 
64
- def _handle_directory_path(self, directory, patterns, max_depth, include_gitignored):
64
+ def _handle_directory_path(
65
+ self, directory, patterns, max_depth, include_gitignored
66
+ ):
65
67
  dir_output = set()
66
68
  for root, dirs, files in walk_dir_with_gitignore(
67
69
  directory,
@@ -73,9 +75,7 @@ class FindFilesTool(ToolBase):
73
75
  dir_output.update(self._match_directories(root, dirs, pat))
74
76
  else:
75
77
  dir_output.update(self._match_files(root, files, pat))
76
- dir_output.update(
77
- self._match_dirs_without_slash(root, dirs, pat)
78
- )
78
+ dir_output.update(self._match_dirs_without_slash(root, dirs, pat))
79
79
  return dir_output
80
80
 
81
81
  def _report_search(self, pattern, disp_path, depth_msg):
@@ -131,9 +131,10 @@ class FindFilesTool(ToolBase):
131
131
  if os.path.isfile(directory):
132
132
  dir_output = self._handle_path(directory, patterns)
133
133
  elif os.path.isdir(directory):
134
- dir_output = self._handle_directory_path(directory, patterns, max_depth, include_gitignored)
134
+ dir_output = self._handle_directory_path(
135
+ directory, patterns, max_depth, include_gitignored
136
+ )
135
137
  self._report_success(len(dir_output))
136
138
  results.extend(self._format_output(directory, dir_output))
137
139
  result = "\n".join(results)
138
140
  return result
139
-
@@ -20,6 +20,7 @@ class GetFileOutlineTool(ToolBase):
20
20
  Args:
21
21
  path (str): Path to the file to outline.
22
22
  """
23
+
23
24
  permissions = ToolPermissions(read=True)
24
25
  tool_name = "get_file_outline"
25
26
 
@@ -1,6 +1,7 @@
1
1
  import re
2
2
  from typing import List, Dict
3
3
 
4
+
4
5
  def parse_java_outline(lines: List[str]) -> List[Dict]:
5
6
  """
6
7
  Parses Java source code lines and extracts classes and methods with their signatures.
@@ -9,19 +10,23 @@ def parse_java_outline(lines: List[str]) -> List[Dict]:
9
10
  outline = []
10
11
  class_pattern = re.compile(r"\bclass\s+(\w+)(\s*<[^>]+>)?")
11
12
  # Match methods with or without visibility modifiers (including package-private)
12
- method_pattern = re.compile(r"^(?:\s*(public|protected|private)\s+)?(?:static\s+)?([\w<>\[\]]+)\s+(\w+)\s*\(([^)]*)\)")
13
+ method_pattern = re.compile(
14
+ r"^(?:\s*(public|protected|private)\s+)?(?:static\s+)?([\w<>\[\]]+)\s+(\w+)\s*\(([^)]*)\)"
15
+ )
13
16
  current_class = None
14
17
  for idx, line in enumerate(lines, 1):
15
18
  class_match = class_pattern.search(line)
16
19
  if class_match:
17
20
  class_name = class_match.group(1)
18
21
  generics = class_match.group(2) or ""
19
- outline.append({
20
- "type": "class",
21
- "name": class_name,
22
- "generics": generics.strip("<>") if generics else None,
23
- "line": idx
24
- })
22
+ outline.append(
23
+ {
24
+ "type": "class",
25
+ "name": class_name,
26
+ "generics": generics.strip("<>") if generics else None,
27
+ "line": idx,
28
+ }
29
+ )
25
30
  current_class = class_name
26
31
  else:
27
32
  method_match = method_pattern.search(line)
@@ -29,12 +34,14 @@ def parse_java_outline(lines: List[str]) -> List[Dict]:
29
34
  return_type = method_match.group(2)
30
35
  method_name = method_match.group(3)
31
36
  params = method_match.group(4)
32
- outline.append({
33
- "type": "method",
34
- "class": current_class,
35
- "name": method_name,
36
- "return_type": return_type,
37
- "parameters": params.strip(),
38
- "line": idx
39
- })
37
+ outline.append(
38
+ {
39
+ "type": "method",
40
+ "class": current_class,
41
+ "name": method_name,
42
+ "return_type": return_type,
43
+ "parameters": params.strip(),
44
+ "line": idx,
45
+ }
46
+ )
40
47
  return outline
@@ -11,6 +11,7 @@ class SearchOutlineTool(ToolBase):
11
11
  Returns:
12
12
  str: Outline search result or status message.
13
13
  """
14
+
14
15
  permissions = ToolPermissions(read=True)
15
16
  tool_name = "search_outline"
16
17
 
@@ -20,6 +20,7 @@ class MoveFileTool(ToolBase):
20
20
  Returns:
21
21
  str: Status message indicating the result.
22
22
  """
23
+
23
24
  permissions = ToolPermissions(read=True, write=True)
24
25
  tool_name = "move_file"
25
26
 
@@ -5,6 +5,7 @@ from janito.tools.tool_base import ToolBase, ToolPermissions
5
5
  from janito.report_events import ReportAction
6
6
  from janito.i18n import tr
7
7
 
8
+
8
9
  @register_local_tool
9
10
  class OpenHtmlInBrowserTool(ToolBase):
10
11
  """
@@ -15,6 +16,7 @@ class OpenHtmlInBrowserTool(ToolBase):
15
16
  Returns:
16
17
  str: Status message indicating the result.
17
18
  """
19
+
18
20
  permissions = ToolPermissions(read=True)
19
21
  tool_name = "open_html_in_browser"
20
22
 
@@ -25,15 +27,23 @@ class OpenHtmlInBrowserTool(ToolBase):
25
27
  if not os.path.isfile(path):
26
28
  self.report_error(tr("❗ File does not exist: {path}", path=path))
27
29
  return tr("Warning: File does not exist: {path}", path=path)
28
- if not path.lower().endswith(('.html', '.htm')):
30
+ if not path.lower().endswith((".html", ".htm")):
29
31
  self.report_warning(tr("⚠️ Not an HTML file: {path}", path=path))
30
32
  return tr("Warning: Not an HTML file: {path}", path=path)
31
- url = 'file://' + os.path.abspath(path)
32
- self.report_action(tr("📖 Opening HTML file in browser: {path}", path=path), ReportAction.READ)
33
+ url = "file://" + os.path.abspath(path)
34
+ self.report_action(
35
+ tr("📖 Opening HTML file in browser: {path}", path=path), ReportAction.READ
36
+ )
33
37
  try:
34
38
  webbrowser.open(url)
35
39
  except Exception as err:
36
- self.report_error(tr("❗ Error opening HTML file: {path}: {err}", path=path, err=str(err)))
37
- return tr("Warning: Error opening HTML file: {path}: {err}", path=path, err=str(err))
40
+ self.report_error(
41
+ tr(" Error opening HTML file: {path}: {err}", path=path, err=str(err))
42
+ )
43
+ return tr(
44
+ "Warning: Error opening HTML file: {path}: {err}",
45
+ path=path,
46
+ err=str(err),
47
+ )
38
48
  self.report_success(tr("✅ HTML file opened in browser: {path}", path=path))
39
49
  return tr("HTML file opened in browser: {path}", path=path)
@@ -15,6 +15,7 @@ class OpenUrlTool(ToolBase):
15
15
  Returns:
16
16
  str: Status message indicating the result.
17
17
  """
18
+
18
19
  permissions = ToolPermissions(read=True)
19
20
  tool_name = "open_url"
20
21
 
@@ -21,6 +21,7 @@ class PythonCodeRunTool(ToolBase):
21
21
  Returns:
22
22
  str: Output and status message, or file paths/line counts if output is large.
23
23
  """
24
+
24
25
  permissions = ToolPermissions(execute=True)
25
26
  tool_name = "python_code_run"
26
27
 
@@ -21,6 +21,7 @@ class PythonCommandRunTool(ToolBase):
21
21
  Returns:
22
22
  str: Output and status message, or file paths/line counts if output is large.
23
23
  """
24
+
24
25
  permissions = ToolPermissions(execute=True)
25
26
  tool_name = "python_command_run"
26
27
 
@@ -21,6 +21,7 @@ class PythonFileRunTool(ToolBase):
21
21
  Returns:
22
22
  str: Output and status message, or file paths/line counts if output is large.
23
23
  """
24
+
24
25
  permissions = ToolPermissions(execute=True)
25
26
  tool_name = "python_file_run"
26
27
 
@@ -4,6 +4,7 @@ from janito.tools.adapters.local.adapter import register_local_tool
4
4
  from janito.tools.tool_utils import pluralize
5
5
  from janito.i18n import tr
6
6
 
7
+
7
8
  @register_local_tool
8
9
  class ReadFilesTool(ToolBase):
9
10
  """
@@ -15,18 +16,24 @@ class ReadFilesTool(ToolBase):
15
16
  Returns:
16
17
  str: Concatenated content of all files, each prefixed by a header with the file name. If a file cannot be read, an error message is included for that file.
17
18
  """
19
+
18
20
  permissions = ToolPermissions(read=True)
19
21
  tool_name = "read_files"
20
22
 
21
23
  def run(self, paths: list[str]) -> str:
22
24
  from janito.tools.tool_utils import display_path
23
25
  import os
26
+
24
27
  results = []
25
28
  for path in paths:
26
29
  disp_path = display_path(path)
27
- self.report_action(tr("📖 Read '{disp_path}'", disp_path=disp_path), ReportAction.READ)
30
+ self.report_action(
31
+ tr("📖 Read '{disp_path}'", disp_path=disp_path), ReportAction.READ
32
+ )
28
33
  if not os.path.isfile(path):
29
- self.report_warning(tr("❗ not found: {disp_path}", disp_path=disp_path))
34
+ self.report_warning(
35
+ tr("❗ not found: {disp_path}", disp_path=disp_path)
36
+ )
30
37
  results.append(f"--- File: {disp_path} (not found) ---\n")
31
38
  continue
32
39
  try:
@@ -35,6 +42,14 @@ class ReadFilesTool(ToolBase):
35
42
  results.append(f"--- File: {disp_path} ---\n{content}\n")
36
43
  self.report_success(tr("✅ Read {disp_path}", disp_path=disp_path))
37
44
  except Exception as e:
38
- self.report_error(tr(" ❌ Error reading {disp_path}: {error}", disp_path=disp_path, error=e))
39
- results.append(f"--- File: {disp_path} (error) ---\nError reading file: {e}\n")
45
+ self.report_error(
46
+ tr(
47
+ " ❌ Error reading {disp_path}: {error}",
48
+ disp_path=disp_path,
49
+ error=e,
50
+ )
51
+ )
52
+ results.append(
53
+ f"--- File: {disp_path} (error) ---\nError reading file: {e}\n"
54
+ )
40
55
  return "\n".join(results)
@@ -21,6 +21,7 @@ class RemoveDirectoryTool(ToolBase):
21
21
  - "Directory removed: /path/to/dir"
22
22
  - "Error removing directory: <error message>"
23
23
  """
24
+
24
25
  permissions = ToolPermissions(write=True)
25
26
  tool_name = "remove_directory"
26
27
 
@@ -21,6 +21,7 @@ class RemoveFileTool(ToolBase):
21
21
  - " Successfully removed the file at ..."
22
22
  - " Cannot remove file: ..."
23
23
  """
24
+
24
25
  permissions = ToolPermissions(write=True)
25
26
  tool_name = "remove_file"
26
27
 
@@ -28,6 +28,7 @@ class ReplaceTextInFileTool(ToolBase):
28
28
  - "No changes made. [Warning: Search text not found in file] Please review the original file."
29
29
  - "Error replacing text: <error message>"
30
30
  """
31
+
31
32
  permissions = ToolPermissions(read=True, write=True)
32
33
  tool_name = "replace_text_in_file"
33
34
 
@@ -85,9 +86,9 @@ class ReplaceTextInFileTool(ToolBase):
85
86
  line_delta_str,
86
87
  replace_all,
87
88
  )
88
- return self._format_final_msg(
89
- path, warning, match_info, details
90
- ) + (f"\n{validation_result}" if validation_result else "")
89
+ return self._format_final_msg(path, warning, match_info, details) + (
90
+ f"\n{validation_result}" if validation_result else ""
91
+ )
91
92
  except Exception as e:
92
93
  self.report_error(tr(" ❌ Error"), ReportAction.REPLACE)
93
94
  return tr("Error replacing text: {error}", error=e)
@@ -24,6 +24,7 @@ class RunBashCommandTool(ToolBase):
24
24
  Returns:
25
25
  str: File paths and line counts for stdout and stderr.
26
26
  """
27
+
27
28
  permissions = ToolPermissions(execute=True)
28
29
  tool_name = "run_bash_command"
29
30
 
@@ -26,6 +26,7 @@ class RunPowershellCommandTool(ToolBase):
26
26
  Returns:
27
27
  str: Output and status message, or file paths/line counts if output is large.
28
28
  """
29
+
29
30
  permissions = ToolPermissions(execute=True)
30
31
  tool_name = "run_powershell_command"
31
32