janito 1.12.1__py3-none-any.whl → 1.12.2__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/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.11.0"
1
+ __version__ = "1.12.2"
@@ -93,7 +93,7 @@ class ConversationHandler:
93
93
 
94
94
  def _handle_no_tool_support(self, messages, max_tokens, spinner):
95
95
  print(
96
- "\u26a0\ufe0f Endpoint does not support tool use. Proceeding in vanilla mode (tools disabled)."
96
+ "⚠️ Endpoint does not support tool use. Proceeding in vanilla mode (tools disabled)."
97
97
  )
98
98
  runtime_config.set("vanilla_mode", True)
99
99
  resolved_max_tokens = 8000
@@ -45,7 +45,9 @@ class FindFilesTool(ToolBase):
45
45
  dir_output.add(os.path.join(root, d))
46
46
  return dir_output
47
47
 
48
- def run(self, paths: str, pattern: str, max_depth: int = None) -> str:
48
+ def run(
49
+ self, paths: str, pattern: str, max_depth: int = None, max_results: int = 0
50
+ ) -> str:
49
51
  if not pattern:
50
52
  self.report_warning(tr("ℹ️ Empty file pattern provided."))
51
53
  return tr("Warning: Empty file pattern provided. Operation skipped.")
@@ -61,13 +63,15 @@ class FindFilesTool(ToolBase):
61
63
  self.report_info(
62
64
  ActionType.READ,
63
65
  tr(
64
- "🔍 Search for files '{pattern}' in '{disp_path}'{depth_msg} ...",
66
+ "🔍 Search files '{pattern}' in '{disp_path}'{depth_msg} ...",
65
67
  pattern=pattern,
66
68
  disp_path=disp_path,
67
69
  depth_msg=depth_msg,
68
70
  ),
69
71
  )
70
72
  dir_output = set()
73
+ count_scanned = 0
74
+ limit_reached = False
71
75
  for root, dirs, files in walk_dir_with_gitignore(
72
76
  directory, max_depth=max_depth
73
77
  ):
@@ -79,11 +83,17 @@ class FindFilesTool(ToolBase):
79
83
  dir_output.update(
80
84
  self._match_dirs_without_slash(root, dirs, pat)
81
85
  )
86
+ if max_results > 0 and len(dir_output) >= max_results:
87
+ limit_reached = True
88
+ # Truncate to max_results
89
+ dir_output = set(list(dir_output)[:max_results])
90
+ break
82
91
  self.report_success(
83
92
  tr(
84
- " ✅ {count} {file_word}",
93
+ " ✅ {count} {file_word}{max_flag}",
85
94
  count=len(dir_output),
86
95
  file_word=pluralize("file", len(dir_output)),
96
+ max_flag=" (max)" if limit_reached else "",
87
97
  )
88
98
  )
89
99
  if directory.strip() == ".":
@@ -22,7 +22,7 @@ class GetLinesTool(ToolBase):
22
22
  - "---\nFile: /path/to/file.py | Lines: 1-10 (of 100)\n---\n<lines...>"
23
23
  - "---\nFile: /path/to/file.py | All lines (total: 100 (all))\n---\n<all lines...>"
24
24
  - "Error reading file: <error message>"
25
- - "\u2757 not found"
25
+ - " not found"
26
26
  """
27
27
 
28
28
  def run(self, file_path: str, from_line: int = None, to_line: int = None) -> str:
@@ -83,7 +83,7 @@ class GetLinesTool(ToolBase):
83
83
  if at_end:
84
84
  self.report_success(
85
85
  tr(
86
- " \u2705 {selected_len} {line_word} (end)",
86
+ " {selected_len} {line_word} (end)",
87
87
  selected_len=selected_len,
88
88
  line_word=pluralize("line", selected_len),
89
89
  )
@@ -91,7 +91,7 @@ class GetLinesTool(ToolBase):
91
91
  elif to_line < total_lines:
92
92
  self.report_success(
93
93
  tr(
94
- " \u2705 {selected_len} {line_word} ({remaining} to end)",
94
+ " {selected_len} {line_word} ({remaining} to end)",
95
95
  selected_len=selected_len,
96
96
  line_word=pluralize("line", selected_len),
97
97
  remaining=total_lines - to_line,
@@ -100,7 +100,7 @@ class GetLinesTool(ToolBase):
100
100
  else:
101
101
  self.report_success(
102
102
  tr(
103
- " \u2705 {selected_len} {line_word} (all)",
103
+ " {selected_len} {line_word} (all)",
104
104
  selected_len=selected_len,
105
105
  line_word=pluralize("line", selected_len),
106
106
  )
@@ -143,7 +143,7 @@ class GetLinesTool(ToolBase):
143
143
  def _handle_read_error(self, e):
144
144
  """Handle file read errors and report appropriately."""
145
145
  if isinstance(e, FileNotFoundError):
146
- self.report_error(tr("\u2757 not found"))
147
- return tr("\u2757 not found")
148
- self.report_error(tr(" \u274c Error: {error}", error=e))
146
+ self.report_error(tr(" not found"))
147
+ return tr(" not found")
148
+ self.report_error(tr(" Error: {error}", error=e))
149
149
  return tr("Error reading file: {error}", error=e)
@@ -22,7 +22,7 @@ class PythonCommandRunnerTool(ToolBase):
22
22
 
23
23
  def run(self, code: str, timeout: int = 60) -> str:
24
24
  if not code.strip():
25
- self.report_warning(tr("\u2139\ufe0f Empty code provided."))
25
+ self.report_warning(tr("ℹ️ Empty code provided."))
26
26
  return tr("Warning: Empty code provided. Operation skipped.")
27
27
  self.report_info(
28
28
  ActionType.EXECUTE, tr("🐍 Running: python -c ...\n{code}\n", code=code)
@@ -63,13 +63,13 @@ class PythonCommandRunnerTool(ToolBase):
63
63
  stdout_file.flush()
64
64
  stderr_file.flush()
65
65
  self.report_success(
66
- tr("\u2705 Return code {return_code}", return_code=return_code)
66
+ tr(" Return code {return_code}", return_code=return_code)
67
67
  )
68
68
  return self._format_result(
69
69
  stdout_file.name, stderr_file.name, return_code
70
70
  )
71
71
  except Exception as e:
72
- self.report_error(tr("\u274c Error: {error}", error=e))
72
+ self.report_error(tr(" Error: {error}", error=e))
73
73
  return tr("Error running code: {error}", error=e)
74
74
 
75
75
  def _stream_process_output(self, process, stdout_file, stderr_file):
@@ -107,7 +107,7 @@ class PythonCommandRunnerTool(ToolBase):
107
107
  except subprocess.TimeoutExpired:
108
108
  process.kill()
109
109
  self.report_error(
110
- tr("\u274c Timed out after {timeout} seconds.", timeout=timeout)
110
+ tr(" Timed out after {timeout} seconds.", timeout=timeout)
111
111
  )
112
112
  return None
113
113
 
@@ -61,13 +61,13 @@ class PythonFileRunnerTool(ToolBase):
61
61
  stdout_file.flush()
62
62
  stderr_file.flush()
63
63
  self.report_success(
64
- tr("\u2705 Return code {return_code}", return_code=return_code)
64
+ tr(" Return code {return_code}", return_code=return_code)
65
65
  )
66
66
  return self._format_result(
67
67
  stdout_file.name, stderr_file.name, return_code
68
68
  )
69
69
  except Exception as e:
70
- self.report_error(tr("\u274c Error: {error}", error=e))
70
+ self.report_error(tr(" Error: {error}", error=e))
71
71
  return tr("Error running file: {error}", error=e)
72
72
 
73
73
  def _stream_process_output(self, process, stdout_file, stderr_file):
@@ -105,7 +105,7 @@ class PythonFileRunnerTool(ToolBase):
105
105
  except subprocess.TimeoutExpired:
106
106
  process.kill()
107
107
  self.report_error(
108
- tr("\u274c Timed out after {timeout} seconds.", timeout=timeout)
108
+ tr(" Timed out after {timeout} seconds.", timeout=timeout)
109
109
  )
110
110
  return None
111
111
 
@@ -5,6 +5,8 @@ from janito.i18n import tr
5
5
  import shutil
6
6
  import re
7
7
 
8
+ from janito.agent.tools.validate_file_syntax.core import validate_file_syntax
9
+
8
10
 
9
11
  @register_tool(name="replace_text_in_file")
10
12
  class ReplaceTextInFileTool(ToolBase):
@@ -82,9 +84,14 @@ class ReplaceTextInFileTool(ToolBase):
82
84
  line_delta_str,
83
85
  replace_all,
84
86
  )
85
- return self._format_final_msg(
87
+ final_msg = self._format_final_msg(
86
88
  file_path, warning, backup_path, match_info, details
87
89
  )
90
+ # Perform syntax validation and append result if file was changed
91
+ if file_changed:
92
+ validation_result = validate_file_syntax(file_path)
93
+ final_msg += f"\n{validation_result}"
94
+ return final_msg
88
95
  except Exception as e:
89
96
  self.report_error(tr(" \u274c Error"))
90
97
  return tr("Error replacing text: {error}", error=e)
@@ -124,7 +124,12 @@ class SearchTextTool(ToolBase):
124
124
  count = sum(count for _, count in per_file_counts)
125
125
  file_word = pluralize("match", count)
126
126
  self.report_success(
127
- tr(" \u2705 {count} {file_word}", count=count, file_word=file_word)
127
+ tr(
128
+ " \u2705 {count} {file_word}{max_flag}",
129
+ count=count,
130
+ file_word=file_word,
131
+ max_flag=" (max)" if dir_limit_reached else "",
132
+ )
128
133
  )
129
134
  return info_str, dir_output, dir_limit_reached, per_file_counts
130
135
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: janito
3
- Version: 1.12.1
3
+ Version: 1.12.2
4
4
  Summary: Natural Language Coding Agent,
5
5
  Author-email: João Pinto <joao.pinto@gmail.com>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- janito/__init__.py,sha256=K96Ieyj_pvPsWOfDSlFjBXqROLgyWEro-T06boxuOO8,24
1
+ janito/__init__.py,sha256=sShV3o03FCd1sOSP-USIgwsoW5l17OBSGUpFodS8-rQ,24
2
2
  janito/__main__.py,sha256=KKIoPBE9xPcb54PRYO2UOt0ti04iAwLeJlg8YY36vew,76
3
3
  janito/rich_utils.py,sha256=x7OsZdwtAOtUu_HYbrAMga0LElFMPbQL8GZ62vw5Jh8,1825
4
4
  janito/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -7,7 +7,7 @@ janito/agent/config.py,sha256=dO64nxiiHj-tLJLN8sfY10GUuIaOmWu-NX73n9zVHfg,4609
7
7
  janito/agent/config_defaults.py,sha256=22MxI84GF8YL5avIjAWxHlvARxu4A2wD0oou_lqNCeA,460
8
8
  janito/agent/config_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  janito/agent/content_handler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- janito/agent/conversation.py,sha256=jxt3DmvuWDQRNObvHwiWkj74qsfrNAjn4Syh-QBXuAA,9564
10
+ janito/agent/conversation.py,sha256=HqjZaXtnoQtKet7MRISDOqnWsjvAXlgKKf4E6LjjVNk,9558
11
11
  janito/agent/conversation_api.py,sha256=6iKlkLWnfgM4D_6ju-ReMprJSnMC1FdCHKqrSgOluhg,10706
12
12
  janito/agent/conversation_exceptions.py,sha256=Aw7PRLb3eUfyDOGynKds5F48dgjyiOrTCEcWSprYC58,381
13
13
  janito/agent/conversation_tool_calls.py,sha256=wz9FFtwNXgnyJQbcLzZfHfCPkiLfItE2vJ1JqjpKucA,1553
@@ -42,18 +42,18 @@ janito/agent/tools/create_directory.py,sha256=O-yCF-fRwI9m1IGuziqqHSl4-fiGeFwx4u
42
42
  janito/agent/tools/create_file.py,sha256=YLjyhCvcUOci87Tr4ejml9W75HiIvotLAgDWTbQT-98,2420
43
43
  janito/agent/tools/delete_text_in_file.py,sha256=WIUDPgaaPK2Dk1WzKTPdfyckcoA6p51cwAf0SMiJj8c,3494
44
44
  janito/agent/tools/fetch_url.py,sha256=GsSf5pdMEa_UYv_V5lJw7kClvypVDI96KOzt2k2cAeU,3863
45
- janito/agent/tools/find_files.py,sha256=kx1mgpKd03yf9Zp_7vlqrHAyO1xJoE0gdoCjc8xCWhc,4493
46
- janito/agent/tools/get_lines.py,sha256=5y5i1Y3CkKfudTSynFnR2w-xdSgUqJ3XSVwvOPsfoN0,6310
45
+ janito/agent/tools/find_files.py,sha256=ZzPB3Pk0JzqZjzeonY3OghfyBGJu5UuppduS2D178h8,4926
46
+ janito/agent/tools/get_lines.py,sha256=OO53g0tz1TnWXL8DqabQPEJhI_rYYp1VDjuSElhBPJI,6289
47
47
  janito/agent/tools/move_file.py,sha256=65ndePzYCR0TpI3LPmvL6qt1Tsz9nU6i-YRr3Y7dzCY,5113
48
48
  janito/agent/tools/open_url.py,sha256=xXGEonfvU3rCc8vOkdjeC1ibGfDnQEhHQ_qo0MIpPKk,1197
49
49
  janito/agent/tools/present_choices.py,sha256=XVO9jhWOUry7TedGPkOU4CG3COV_YdTUp3YiKyNKo2U,2422
50
- janito/agent/tools/python_command_runner.py,sha256=Lirx8VWY4A3uPQwkG6s3OT8de_rdSywbuW0aSj6VBX8,6102
51
- janito/agent/tools/python_file_runner.py,sha256=vD8OeRiagZpKXZiXXcOU7Hn2_RtZ1nOLQ2smZQ-wfiY,5929
50
+ janito/agent/tools/python_command_runner.py,sha256=RSBH8utsFjQ_HqVMN_F9XbrsWD8BqhiMAE8dlmWmrBo,6087
51
+ janito/agent/tools/python_file_runner.py,sha256=tHKScu_FA11EHXrxOc9ntLOGSOORdw7pX-7966i8qpc,5920
52
52
  janito/agent/tools/python_stdin_runner.py,sha256=fpLDCVyIo3viecmmwzprzn1OxrSWLtKrbRnh8C55Z_E,6265
53
53
  janito/agent/tools/remove_directory.py,sha256=9NmSqlSIGbm-uvundEQM89ZMGmcgPqygnnw-Cu9lQq8,2500
54
54
  janito/agent/tools/remove_file.py,sha256=v6NJdECofBxYB2YRt3DCqHr91kSPVfMQlgpuL0svVEs,2409
55
55
  janito/agent/tools/replace_file.py,sha256=SurwU_oR6HqZ2vsxNo8Ud-NT-gayg0XipoiCWlMESDI,3275
56
- janito/agent/tools/replace_text_in_file.py,sha256=RPlTIdi_Ib7Nhrq_oEML79DeEFD9essOFqxZauVacSY,10678
56
+ janito/agent/tools/replace_text_in_file.py,sha256=xLICg1l_kjJo3AwQisxL5oLcO_Gbg0ybFzn_2moN7Fo,11027
57
57
  janito/agent/tools/run_bash_command.py,sha256=XEyBGa5cSfjdi0sOklsaPNsEW_9oC9LZIir4FkxcO0M,5877
58
58
  janito/agent/tools/run_powershell_command.py,sha256=qA27uMsF6CqFd3A81Gn8TzEj99MHr0C_12QM74fIRNc,9022
59
59
  janito/agent/tools/get_file_outline/__init__.py,sha256=OKV_BHnoD9h-vkcVoW6AHmsuDjjauHPCKNK0nVFl4sU,37
@@ -62,7 +62,7 @@ janito/agent/tools/get_file_outline/markdown_outline.py,sha256=bXEBg0D93tEBDNy8t
62
62
  janito/agent/tools/get_file_outline/python_outline.py,sha256=d_DKQjo5fbzOvQadc2A_58kmavUTVqkzpWRdFRO4sbU,5768
63
63
  janito/agent/tools/get_file_outline/search_outline.py,sha256=_wPdylEFvl-iE3fuwY3MEUlaDKO5cbHxN1_DTJf5x8s,1079
64
64
  janito/agent/tools/search_text/__init__.py,sha256=FEYpF5tTtf0fiAyRGIGSn-kV-MJDkhdFIbus16mYW8Y,34
65
- janito/agent/tools/search_text/core.py,sha256=6B6ElILXKoupq29PTp9PIHD3-cySFDzRC4wLBxsvc-M,6740
65
+ janito/agent/tools/search_text/core.py,sha256=dpIknu-GHarl1kNo9V-x0zXfKg0bC1CXjIHmtCwrVoU,6882
66
66
  janito/agent/tools/search_text/match_lines.py,sha256=OjYgX9vFphambv0SfTLGZoR5Cdzf-Fp5Ytbj4sGEgnI,1999
67
67
  janito/agent/tools/search_text/pattern_utils.py,sha256=j_Svq_l-RT63VVAI9nj1ULm1qdU2JTsWKrVVaAgyRoo,2129
68
68
  janito/agent/tools/search_text/traverse_directory.py,sha256=Ln_GaJFQ0DQ4A2qBZ1Y4tX7YMFROhonFgTHf48DDXHQ,3864
@@ -155,9 +155,9 @@ janito/tests/test_rich_utils.py,sha256=S_mGVynekAP0DM4A_ZaY-SseJGtdlBJxOlzc-v8lJ
155
155
  janito/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
156
156
  janito/web/__main__.py,sha256=5Ck6okOZmxKYkQ-ir4mxXDH7XWMNR-9szgsm0UyQLE0,734
157
157
  janito/web/app.py,sha256=-zUBA1zlnrZdYbI421CSAgFZXOisLmIznNzUJrkSLQQ,4762
158
- janito-1.12.1.dist-info/licenses/LICENSE,sha256=sHBqv0bvtrb29H7WRR-Z603YHm9pLtJIo3nHU_9cmgE,1091
159
- janito-1.12.1.dist-info/METADATA,sha256=d4kM5viNhCUQ2SXPFhW7h5w0fEhtZpYoKwPlvLUJUFM,12879
160
- janito-1.12.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
161
- janito-1.12.1.dist-info/entry_points.txt,sha256=wIo5zZxbmu4fC-ZMrsKD0T0vq7IqkOOLYhrqRGypkx4,48
162
- janito-1.12.1.dist-info/top_level.txt,sha256=m0NaVCq0-ivxbazE2-ND0EA9Hmuijj_OGkmCbnBcCig,7
163
- janito-1.12.1.dist-info/RECORD,,
158
+ janito-1.12.2.dist-info/licenses/LICENSE,sha256=sHBqv0bvtrb29H7WRR-Z603YHm9pLtJIo3nHU_9cmgE,1091
159
+ janito-1.12.2.dist-info/METADATA,sha256=JithxB50yNFl6cZ4cUorEQj0xpNnpKGffurpijW4LPs,12879
160
+ janito-1.12.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
161
+ janito-1.12.2.dist-info/entry_points.txt,sha256=wIo5zZxbmu4fC-ZMrsKD0T0vq7IqkOOLYhrqRGypkx4,48
162
+ janito-1.12.2.dist-info/top_level.txt,sha256=m0NaVCq0-ivxbazE2-ND0EA9Hmuijj_OGkmCbnBcCig,7
163
+ janito-1.12.2.dist-info/RECORD,,