janito 3.3.0__py3-none-any.whl → 3.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. janito/cli/cli_commands/list_plugins.py +48 -52
  2. janito/cli/core/getters.py +0 -3
  3. janito/cli/main_cli.py +12 -9
  4. janito/drivers/openai/driver.py +0 -1
  5. janito/drivers/zai/driver.py +0 -1
  6. janito/hello.txt +0 -0
  7. janito/llm/auth_utils.py +5 -14
  8. janito/plugins/__init__.py +7 -18
  9. janito/{plugins_backup_20250825_070018 → plugins}/auto_loader_fixed.py +11 -12
  10. janito/plugins/base.py +152 -57
  11. janito/plugins/builtin.py +1 -15
  12. janito/{plugins_backup_20250825_070018 → plugins}/core_adapter.py +9 -11
  13. janito/plugins/core_loader.py +34 -58
  14. janito/{plugin_system_backup_20250825_070018/core_loader.py → plugins/core_loader_fixed.py} +26 -45
  15. janito/plugins/discovery.py +3 -3
  16. janito/tools/__init__.py +7 -31
  17. janito/tools/adapters/__init__.py +1 -6
  18. janito/tools/adapters/local/__init__.py +70 -7
  19. janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/ask_user.py +3 -3
  20. janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/create_file.py +4 -4
  21. janito/{plugins/core/filemanager/tools → tools/adapters/local}/delete_text_in_file.py +0 -1
  22. janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/fetch_url.py +3 -3
  23. janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/replace_text_in_file.py +4 -4
  24. janito/{plugins_backup_20250825_070018/tools → tools/adapters/local}/show_image.py +6 -15
  25. janito/{plugins/core/imagedisplay/tools → tools/adapters/local}/show_image_grid.py +5 -13
  26. janito/tools/base.py +1 -31
  27. janito/tools/function_adapter.py +16 -127
  28. janito/tools/tool_base.py +114 -142
  29. janito/tools/tools_schema.py +6 -12
  30. {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/METADATA +2 -1
  31. janito-3.4.0.dist-info/RECORD +264 -0
  32. janito/cli/cli_commands/check_tools.py +0 -212
  33. janito/plugin_system_backup_20250825_070018/__init__.py +0 -10
  34. janito/plugin_system_backup_20250825_070018/base.py +0 -155
  35. janito/plugin_system_backup_20250825_070018/core_loader_fixed.py +0 -149
  36. janito/plugins/__main__.py +0 -85
  37. janito/plugins/core/__init__.py +0 -7
  38. janito/plugins/core/codeanalyzer/__init__.py +0 -43
  39. janito/plugins/core/filemanager/__init__.py +0 -124
  40. janito/plugins/core/filemanager/tools/copy_file.py +0 -111
  41. janito/plugins/core/filemanager/tools/create_directory.py +0 -97
  42. janito/plugins/core/filemanager/tools/create_file.py +0 -111
  43. janito/plugins/core/filemanager/tools/replace_text_in_file.py +0 -270
  44. janito/plugins/core/imagedisplay/__init__.py +0 -14
  45. janito/plugins/core/imagedisplay/plugin.py +0 -51
  46. janito/plugins/core/imagedisplay/tools/__init__.py +0 -1
  47. janito/plugins/core/imagedisplay/tools/show_image.py +0 -83
  48. janito/plugins/core/system/__init__.py +0 -23
  49. janito/plugins/dev/__init__.py +0 -7
  50. janito/plugins/dev/pythondev/__init__.py +0 -37
  51. janito/plugins/dev/visualization/__init__.py +0 -23
  52. janito/plugins/example_plugin.py +0 -108
  53. janito/plugins/ui/__init__.py +0 -7
  54. janito/plugins/ui/userinterface/__init__.py +0 -16
  55. janito/plugins/ui/userinterface/tools/ask_user.py +0 -110
  56. janito/plugins/web/__init__.py +0 -7
  57. janito/plugins/web/webtools/__init__.py +0 -33
  58. janito/plugins/web/webtools/tools/fetch_url.py +0 -458
  59. janito/plugins_backup_20250825_070018/__init__.py +0 -36
  60. janito/plugins_backup_20250825_070018/builtin.py +0 -102
  61. janito/plugins_backup_20250825_070018/config.py +0 -84
  62. janito/plugins_backup_20250825_070018/core/__init__.py +0 -7
  63. janito/plugins_backup_20250825_070018/core/codeanalyzer/__init__.py +0 -43
  64. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/__init__.py +0 -1
  65. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/core.py +0 -122
  66. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/java_outline.py +0 -47
  67. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/markdown_outline.py +0 -14
  68. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/python_outline.py +0 -303
  69. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/get_file_outline/search_outline.py +0 -36
  70. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/__init__.py +0 -1
  71. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/core.py +0 -205
  72. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/match_lines.py +0 -67
  73. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/pattern_utils.py +0 -73
  74. janito/plugins_backup_20250825_070018/core/codeanalyzer/tools/search_text/traverse_directory.py +0 -145
  75. janito/plugins_backup_20250825_070018/core/filemanager/__init__.py +0 -124
  76. janito/plugins_backup_20250825_070018/core/filemanager/tools/create_file.py +0 -87
  77. janito/plugins_backup_20250825_070018/core/filemanager/tools/delete_text_in_file.py +0 -135
  78. janito/plugins_backup_20250825_070018/core/filemanager/tools/find_files.py +0 -143
  79. janito/plugins_backup_20250825_070018/core/filemanager/tools/move_file.py +0 -131
  80. janito/plugins_backup_20250825_070018/core/filemanager/tools/read_files.py +0 -58
  81. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_directory.py +0 -55
  82. janito/plugins_backup_20250825_070018/core/filemanager/tools/remove_file.py +0 -58
  83. janito/plugins_backup_20250825_070018/core/filemanager/tools/replace_text_in_file.py +0 -270
  84. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/__init__.py +0 -1
  85. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/core.py +0 -114
  86. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/css_validator.py +0 -35
  87. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/html_validator.py +0 -100
  88. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/jinja2_validator.py +0 -50
  89. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/js_validator.py +0 -27
  90. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/json_validator.py +0 -6
  91. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/markdown_validator.py +0 -109
  92. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/ps1_validator.py +0 -32
  93. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/python_validator.py +0 -5
  94. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/xml_validator.py +0 -11
  95. janito/plugins_backup_20250825_070018/core/filemanager/tools/validate_file_syntax/yaml_validator.py +0 -6
  96. janito/plugins_backup_20250825_070018/core/filemanager/tools/view_file.py +0 -172
  97. janito/plugins_backup_20250825_070018/core/imagedisplay/__init__.py +0 -14
  98. janito/plugins_backup_20250825_070018/core/imagedisplay/plugin.py +0 -51
  99. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/__init__.py +0 -1
  100. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image.py +0 -83
  101. janito/plugins_backup_20250825_070018/core/imagedisplay/tools/show_image_grid.py +0 -84
  102. janito/plugins_backup_20250825_070018/core/system/__init__.py +0 -23
  103. janito/plugins_backup_20250825_070018/core/system/tools/run_bash_command.py +0 -183
  104. janito/plugins_backup_20250825_070018/core/system/tools/run_powershell_command.py +0 -218
  105. janito/plugins_backup_20250825_070018/dev/__init__.py +0 -7
  106. janito/plugins_backup_20250825_070018/dev/pythondev/__init__.py +0 -37
  107. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_code_run.py +0 -172
  108. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_command_run.py +0 -171
  109. janito/plugins_backup_20250825_070018/dev/pythondev/tools/python_file_run.py +0 -172
  110. janito/plugins_backup_20250825_070018/dev/visualization/__init__.py +0 -23
  111. janito/plugins_backup_20250825_070018/dev/visualization/tools/read_chart.py +0 -259
  112. janito/plugins_backup_20250825_070018/discovery.py +0 -289
  113. janito/plugins_backup_20250825_070018/example_plugin.py +0 -108
  114. janito/plugins_backup_20250825_070018/manager.py +0 -243
  115. janito/plugins_backup_20250825_070018/tools/__init__.py +0 -10
  116. janito/plugins_backup_20250825_070018/tools/copy_file.py +0 -87
  117. janito/plugins_backup_20250825_070018/tools/core_tools_plugin.py +0 -88
  118. janito/plugins_backup_20250825_070018/tools/create_directory.py +0 -70
  119. janito/plugins_backup_20250825_070018/tools/decorators.py +0 -19
  120. janito/plugins_backup_20250825_070018/tools/delete_text_in_file.py +0 -135
  121. janito/plugins_backup_20250825_070018/tools/find_files.py +0 -143
  122. janito/plugins_backup_20250825_070018/tools/get_file_outline/__init__.py +0 -7
  123. janito/plugins_backup_20250825_070018/tools/get_file_outline/core.py +0 -122
  124. janito/plugins_backup_20250825_070018/tools/get_file_outline/java_outline.py +0 -47
  125. janito/plugins_backup_20250825_070018/tools/get_file_outline/markdown_outline.py +0 -14
  126. janito/plugins_backup_20250825_070018/tools/get_file_outline/python_outline.py +0 -303
  127. janito/plugins_backup_20250825_070018/tools/get_file_outline/search_outline.py +0 -36
  128. janito/plugins_backup_20250825_070018/tools/move_file.py +0 -131
  129. janito/plugins_backup_20250825_070018/tools/open_html_in_browser.py +0 -51
  130. janito/plugins_backup_20250825_070018/tools/open_url.py +0 -37
  131. janito/plugins_backup_20250825_070018/tools/python_code_run.py +0 -172
  132. janito/plugins_backup_20250825_070018/tools/python_command_run.py +0 -171
  133. janito/plugins_backup_20250825_070018/tools/python_file_run.py +0 -172
  134. janito/plugins_backup_20250825_070018/tools/read_chart.py +0 -259
  135. janito/plugins_backup_20250825_070018/tools/read_files.py +0 -58
  136. janito/plugins_backup_20250825_070018/tools/remove_directory.py +0 -55
  137. janito/plugins_backup_20250825_070018/tools/remove_file.py +0 -58
  138. janito/plugins_backup_20250825_070018/tools/run_bash_command.py +0 -183
  139. janito/plugins_backup_20250825_070018/tools/run_powershell_command.py +0 -218
  140. janito/plugins_backup_20250825_070018/tools/search_text/__init__.py +0 -7
  141. janito/plugins_backup_20250825_070018/tools/search_text/core.py +0 -205
  142. janito/plugins_backup_20250825_070018/tools/search_text/match_lines.py +0 -67
  143. janito/plugins_backup_20250825_070018/tools/search_text/pattern_utils.py +0 -73
  144. janito/plugins_backup_20250825_070018/tools/search_text/traverse_directory.py +0 -145
  145. janito/plugins_backup_20250825_070018/tools/show_image_grid.py +0 -85
  146. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/__init__.py +0 -7
  147. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/core.py +0 -114
  148. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/css_validator.py +0 -35
  149. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/html_validator.py +0 -100
  150. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/jinja2_validator.py +0 -50
  151. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/js_validator.py +0 -27
  152. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/json_validator.py +0 -6
  153. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/markdown_validator.py +0 -109
  154. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/ps1_validator.py +0 -32
  155. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/python_validator.py +0 -5
  156. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/xml_validator.py +0 -11
  157. janito/plugins_backup_20250825_070018/tools/validate_file_syntax/yaml_validator.py +0 -6
  158. janito/plugins_backup_20250825_070018/tools/view_file.py +0 -172
  159. janito/plugins_backup_20250825_070018/ui/__init__.py +0 -7
  160. janito/plugins_backup_20250825_070018/ui/userinterface/__init__.py +0 -16
  161. janito/plugins_backup_20250825_070018/ui/userinterface/tools/ask_user.py +0 -110
  162. janito/plugins_backup_20250825_070018/web/__init__.py +0 -7
  163. janito/plugins_backup_20250825_070018/web/webtools/__init__.py +0 -33
  164. janito/plugins_backup_20250825_070018/web/webtools/tools/fetch_url.py +0 -458
  165. janito/plugins_backup_20250825_070018/web/webtools/tools/open_html_in_browser.py +0 -51
  166. janito/plugins_backup_20250825_070018/web/webtools/tools/open_url.py +0 -37
  167. janito/tools/cli_initializer.py +0 -88
  168. janito/tools/initialize.py +0 -70
  169. janito-3.3.0.dist-info/RECORD +0 -400
  170. /janito/{plugins_backup_20250825_070018 → plugins}/auto_loader.py +0 -0
  171. /janito/{plugins_backup_20250825_070018 → plugins}/discovery_core.py +0 -0
  172. /janito/{plugins_backup_20250825_070018/core/filemanager/tools → tools/adapters/local}/copy_file.py +0 -0
  173. /janito/{plugins_backup_20250825_070018/core/filemanager/tools → tools/adapters/local}/create_directory.py +0 -0
  174. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/find_files.py +0 -0
  175. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/__init__.py +0 -0
  176. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/core.py +0 -0
  177. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/java_outline.py +0 -0
  178. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/markdown_outline.py +0 -0
  179. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/python_outline.py +0 -0
  180. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/get_file_outline/search_outline.py +0 -0
  181. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/move_file.py +0 -0
  182. /janito/{plugins/web/webtools/tools → tools/adapters/local}/open_html_in_browser.py +0 -0
  183. /janito/{plugins/web/webtools/tools → tools/adapters/local}/open_url.py +0 -0
  184. /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_code_run.py +0 -0
  185. /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_command_run.py +0 -0
  186. /janito/{plugins/dev/pythondev/tools → tools/adapters/local}/python_file_run.py +0 -0
  187. /janito/{plugins/dev/visualization/tools → tools/adapters/local}/read_chart.py +0 -0
  188. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/read_files.py +0 -0
  189. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/remove_directory.py +0 -0
  190. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/remove_file.py +0 -0
  191. /janito/{plugins/core/system/tools → tools/adapters/local}/run_bash_command.py +0 -0
  192. /janito/{plugins/core/system/tools → tools/adapters/local}/run_powershell_command.py +0 -0
  193. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/__init__.py +0 -0
  194. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/core.py +0 -0
  195. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/match_lines.py +0 -0
  196. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/pattern_utils.py +0 -0
  197. /janito/{plugins/core/codeanalyzer/tools → tools/adapters/local}/search_text/traverse_directory.py +0 -0
  198. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/__init__.py +0 -0
  199. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/core.py +0 -0
  200. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/css_validator.py +0 -0
  201. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/html_validator.py +0 -0
  202. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/jinja2_validator.py +0 -0
  203. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/js_validator.py +0 -0
  204. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/json_validator.py +0 -0
  205. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/markdown_validator.py +0 -0
  206. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/ps1_validator.py +0 -0
  207. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/python_validator.py +0 -0
  208. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/xml_validator.py +0 -0
  209. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/validate_file_syntax/yaml_validator.py +0 -0
  210. /janito/{plugins/core/filemanager/tools → tools/adapters/local}/view_file.py +0 -0
  211. {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/WHEEL +0 -0
  212. {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/entry_points.txt +0 -0
  213. {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/licenses/LICENSE +0 -0
  214. {janito-3.3.0.dist-info → janito-3.4.0.dist-info}/top_level.txt +0 -0
@@ -1,109 +0,0 @@
1
- from janito.i18n import tr
2
- import re
3
-
4
-
5
- def validate_markdown(path: str) -> str:
6
- with open(path, "r", encoding="utf-8") as f:
7
- content = f.read()
8
- lines = content.splitlines()
9
- errors = []
10
- errors.extend(_check_header_space(lines))
11
- errors.extend(_check_unclosed_code_block(content))
12
- errors.extend(_check_unclosed_links_images(lines))
13
- errors.extend(_check_list_formatting(lines))
14
- errors.extend(_check_unclosed_inline_code(content))
15
- return _build_markdown_result(errors)
16
-
17
-
18
- def _check_header_space(lines):
19
- errors = []
20
- for i, line in enumerate(lines, 1):
21
- if re.match(r"^#+[^ #]", line):
22
- errors.append(f"Line {i}: Header missing space after # | {line.strip()}")
23
- return errors
24
-
25
-
26
- def _check_unclosed_code_block(content):
27
- errors = []
28
- if content.count("```") % 2 != 0:
29
- errors.append("Unclosed code block (```) detected")
30
- return errors
31
-
32
-
33
- def _check_unclosed_links_images(lines):
34
- errors = []
35
- for i, line in enumerate(lines, 1):
36
- if re.search(r"\[[^\]]*\]\([^)]+$", line):
37
- errors.append(
38
- f"Line {i}: Unclosed link or image (missing closing parenthesis) | {line.strip()}"
39
- )
40
- return errors
41
-
42
-
43
- def _is_table_line(line):
44
- return line.lstrip().startswith("|")
45
-
46
-
47
- def _list_item_missing_space(line):
48
- return re.match(r"^[-*+][^ \n]", line)
49
-
50
-
51
- def _should_skip_list_item(line):
52
- stripped = line.strip()
53
- return stripped.startswith("*") and stripped.endswith("*") and len(stripped) > 2
54
-
55
-
56
- def _needs_blank_line_before_bullet(lines, i):
57
- if i <= 1:
58
- return False
59
- prev_line = lines[i - 2]
60
- prev_is_list = bool(re.match(r"^\s*[-*+] ", prev_line))
61
- return not prev_is_list and prev_line.strip() != ""
62
-
63
-
64
- def _needs_blank_line_before_numbered(lines, i):
65
- if i <= 1:
66
- return False
67
- prev_line = lines[i - 2]
68
- prev_is_numbered_list = bool(re.match(r"^\s*\d+\. ", prev_line))
69
- return not prev_is_numbered_list and prev_line.strip() != ""
70
-
71
-
72
- def _check_list_formatting(lines):
73
- errors = []
74
- for i, line in enumerate(lines, 1):
75
- if _is_table_line(line):
76
- continue
77
- if _list_item_missing_space(line):
78
- if not _should_skip_list_item(line):
79
- errors.append(
80
- f"Line {i}: List item missing space after bullet | {line.strip()}"
81
- )
82
- if re.match(r"^\s*[-*+] ", line):
83
- if _needs_blank_line_before_bullet(lines, i):
84
- errors.append(
85
- f"Line {i}: List should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
86
- )
87
- if re.match(r"^\s*\d+\. ", line):
88
- if _needs_blank_line_before_numbered(lines, i):
89
- errors.append(
90
- f"Line {i}: Numbered list should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
91
- )
92
- return errors
93
-
94
-
95
- def _check_unclosed_inline_code(content):
96
- errors = []
97
- if content.count("`") % 2 != 0:
98
- errors.append("Unclosed inline code (`) detected")
99
- return errors
100
-
101
-
102
- def _build_markdown_result(errors):
103
- if errors:
104
- msg = tr(
105
- "⚠️ Warning: Markdown syntax issues found:\n{errors}",
106
- errors="\n".join(errors),
107
- )
108
- return msg
109
- return "✅ OK"
@@ -1,32 +0,0 @@
1
- from janito.i18n import tr
2
- import re
3
-
4
-
5
- def validate_ps1(path: str) -> str:
6
- with open(path, "r", encoding="utf-8") as f:
7
- content = f.read()
8
- errors = []
9
- # Unmatched curly braces
10
- if content.count("{") != content.count("}"):
11
- errors.append("Unmatched curly braces { }")
12
- # Unmatched parentheses
13
- if content.count("(") != content.count(")"):
14
- errors.append("Unmatched parentheses ( )")
15
- # Unmatched brackets
16
- if content.count("[") != content.count("]"):
17
- errors.append("Unmatched brackets [ ]")
18
- # Unclosed string literals
19
- for quote in ["'", '"']:
20
- unescaped = re.findall(rf"(?<!\\){quote}", content)
21
- if len(unescaped) % 2 != 0:
22
- errors.append(f"Unclosed string literal ({quote}) detected")
23
- # Unclosed block comments <# ... #>
24
- if content.count("<#") != content.count("#>"):
25
- errors.append("Unclosed block comment (<# ... #>)")
26
- if errors:
27
- msg = tr(
28
- "⚠️ Warning: PowerShell syntax issues found:\n{errors}",
29
- errors="\n".join(errors),
30
- )
31
- return msg
32
- return "✅ OK"
@@ -1,5 +0,0 @@
1
- def validate_python(path: str) -> str:
2
- import py_compile
3
-
4
- py_compile.compile(path, doraise=True)
5
- return "✅ OK"
@@ -1,11 +0,0 @@
1
- from janito.i18n import tr
2
-
3
-
4
- def validate_xml(path: str) -> str:
5
- try:
6
- from lxml import etree
7
- except ImportError:
8
- return tr("⚠️ lxml not installed. Cannot validate XML.")
9
- with open(path, "rb") as f:
10
- etree.parse(f)
11
- return "✅ OK"
@@ -1,6 +0,0 @@
1
- def validate_yaml(path: str) -> str:
2
- import yaml
3
-
4
- with open(path, "r", encoding="utf-8") as f:
5
- yaml.safe_load(f)
6
- return "✅ OK"
@@ -1,172 +0,0 @@
1
- from janito.tools.tool_base import ToolBase, ToolPermissions
2
- from janito.report_events import ReportAction
3
- from janito.tools.adapters.local.adapter import register_local_tool
4
- from janito.tools.tool_utils import pluralize
5
- from janito.i18n import tr
6
- from janito.tools.loop_protection_decorator import protect_against_loops
7
-
8
-
9
- @register_local_tool
10
- class ViewFileTool(ToolBase):
11
- """
12
- Read lines from a file. You can specify a line range, or read the entire file by simply omitting the from_line and to_line parameters.
13
-
14
- Args:
15
- path (str): Path to the file to read lines from.
16
- from_line (int, optional): Starting line number (1-based). Omit to start from the first line.
17
- to_line (int, optional): Ending line number (1-based). Omit to read to the end of the file.
18
-
19
- To read the full file, just provide path and leave from_line and to_line unset.
20
-
21
- Returns:
22
- str: File content with a header indicating the file name and line range. Example:
23
- - "---\nFile: /path/to/file.py | Lines: 1-10 (of 100)\n---\n<lines...>"
24
- - "---\nFile: /path/to/file.py | All lines (total: 100 (all))\n---\n<all lines...>"
25
- - "Error reading file: <error message>"
26
- - "❗ not found"
27
- """
28
-
29
- permissions = ToolPermissions(read=True)
30
- tool_name = "view_file"
31
-
32
- @protect_against_loops(max_calls=5, time_window=10.0, key_field="path")
33
- def run(self, path: str, from_line: int = None, to_line: int = None) -> str:
34
- import os
35
- from janito.tools.tool_utils import display_path
36
- from janito.tools.path_utils import expand_path
37
-
38
- path = expand_path(path)
39
- disp_path = display_path(path)
40
- self.report_action(
41
- tr("📖 View '{disp_path}'", disp_path=disp_path),
42
- ReportAction.READ,
43
- )
44
- try:
45
- if os.path.isdir(path):
46
- return self._list_directory(path, disp_path)
47
- lines = self._read_file_lines(path)
48
- selected, selected_len, total_lines = self._select_lines(
49
- lines, from_line, to_line
50
- )
51
- self._report_success(selected_len, from_line, to_line, total_lines)
52
- header = self._format_header(
53
- disp_path, from_line, to_line, selected_len, total_lines
54
- )
55
- return header + "".join(selected)
56
- except FileNotFoundError as e:
57
- self.report_warning(tr("❗ not found"))
58
- return f"Error reading file: {e}"
59
- except Exception as e:
60
- self.report_error(tr(" ❌ Error: {error}", error=e))
61
- return tr("Error reading file: {error}", error=e)
62
-
63
- def _list_directory(self, path, disp_path):
64
- import os
65
-
66
- try:
67
- entries = os.listdir(path)
68
- entries.sort()
69
- # Suffix subdirectories with '/'
70
- formatted_entries = []
71
- for entry in entries:
72
- full_path = os.path.join(path, entry)
73
- if os.path.isdir(full_path):
74
- formatted_entries.append(entry + "/")
75
- else:
76
- formatted_entries.append(entry)
77
- header = (
78
- f"--- view_file: {disp_path} [directory, {len(entries)} entries] ---\n"
79
- )
80
- listing = "\n".join(formatted_entries)
81
- self.report_success(tr("📁 Directory ({count} items)", count=len(entries)))
82
- return header + listing + "\n"
83
- except Exception as e:
84
- self.report_error(tr(" ❌ Error listing directory: {error}", error=e))
85
- return tr("Error listing directory: {error}", error=e)
86
-
87
- def _read_file_lines(self, path):
88
- """Read all lines from the file."""
89
- with open(path, "r", encoding="utf-8", errors="replace") as f:
90
- return f.readlines()
91
-
92
- def _select_lines(self, lines, from_line, to_line):
93
- """Select the requested lines and return them with their count and total lines."""
94
- selected = lines[
95
- (from_line - 1 if from_line else 0) : (to_line if to_line else None)
96
- ]
97
- selected_len = len(selected)
98
- total_lines = len(lines)
99
- return selected, selected_len, total_lines
100
-
101
- def _report_success(self, selected_len, from_line, to_line, total_lines):
102
- """Report the success message after reading lines."""
103
- if from_line and to_line:
104
- requested = to_line - from_line + 1
105
- at_end = to_line >= total_lines or selected_len < requested
106
- if at_end:
107
- self.report_success(
108
- tr(
109
- " ✅ {selected_len} {line_word} (end)",
110
- selected_len=selected_len,
111
- line_word=pluralize("line", selected_len),
112
- )
113
- )
114
- elif to_line < total_lines:
115
- self.report_success(
116
- tr(
117
- " ✅ {selected_len} {line_word} ({remaining} to end)",
118
- selected_len=selected_len,
119
- line_word=pluralize("line", selected_len),
120
- remaining=total_lines - to_line,
121
- )
122
- )
123
- else:
124
- self.report_success(
125
- tr(
126
- " ✅ {selected_len} {line_word} (all)",
127
- selected_len=selected_len,
128
- line_word=pluralize("line", selected_len),
129
- )
130
- )
131
-
132
- def _format_header(self, disp_path, from_line, to_line, selected_len, total_lines):
133
- """Format the header for the output."""
134
- if from_line and to_line:
135
- requested = to_line - from_line + 1
136
- at_end = selected_len < requested or to_line >= total_lines
137
- if at_end:
138
- return tr(
139
- "---\n{disp_path} {from_line}-{to_line} (end)\n---\n",
140
- disp_path=disp_path,
141
- from_line=from_line,
142
- to_line=to_line,
143
- )
144
- else:
145
- return tr(
146
- "---\n{disp_path} {from_line}-{to_line} (of {total_lines})\n---\n",
147
- disp_path=disp_path,
148
- from_line=from_line,
149
- to_line=to_line,
150
- total_lines=total_lines,
151
- )
152
- elif from_line:
153
- return tr(
154
- "---\n{disp_path} {from_line}-END (of {total_lines})\n---\n",
155
- disp_path=disp_path,
156
- from_line=from_line,
157
- total_lines=total_lines,
158
- )
159
- else:
160
- return tr(
161
- "---\n{disp_path} All lines (total: {total_lines} (all))\n---\n",
162
- disp_path=disp_path,
163
- total_lines=total_lines,
164
- )
165
-
166
- def _handle_read_error(self, e):
167
- """Handle file read errors and report appropriately."""
168
- if isinstance(e, FileNotFoundError):
169
- self.report_error(tr("❗ not found"), ReportAction.READ)
170
- return tr("❗ not found")
171
- self.report_error(tr(" ❌ Error: {error}", error=e), ReportAction.READ)
172
- return tr("Error reading file: {error}", error=e)
@@ -1,14 +0,0 @@
1
- """
2
- Image Display Plugin - Core plugin for displaying images inline in the terminal.
3
-
4
- This plugin provides tools for displaying images directly in the terminal using
5
- rich library's image rendering capabilities.
6
- """
7
-
8
- from .plugin import ImageDisplayPlugin
9
-
10
- # Plugin metadata for discovery/listing
11
- __plugin_name__ = "core.imagedisplay"
12
- __plugin_description__ = "Display images inline in the terminal using rich"
13
-
14
- __all__ = ["ImageDisplayPlugin"]
@@ -1,51 +0,0 @@
1
- """
2
- Image Display Plugin implementation.
3
- """
4
-
5
- from typing import Dict, Any, List, Type
6
-
7
- from janito.plugin_system.base import Plugin, PluginMetadata
8
- from janito.tools.tool_base import ToolBase
9
- from .tools.show_image import ShowImageTool
10
- from .tools.show_image_grid import ShowImageGridTool
11
-
12
-
13
- class ImageDisplayPlugin(Plugin):
14
- """Plugin for displaying images inline in the terminal using rich."""
15
-
16
- def get_metadata(self) -> PluginMetadata:
17
- return PluginMetadata(
18
- name="core.imagedisplay",
19
- version="1.0.0",
20
- description="Display images inline in the terminal using rich",
21
- author="Janito",
22
- dependencies=["rich", "pillow"],
23
- )
24
-
25
- def get_tools(self) -> List[Type[ToolBase]]:
26
- # Return tool classes so the PluginManager can register them
27
- return [ShowImageTool, ShowImageGridTool]
28
-
29
- def get_config_schema(self) -> Dict[str, Any]:
30
- return {
31
- "type": "object",
32
- "properties": {
33
- "default_width": {
34
- "type": "integer",
35
- "description": "Default width for image display",
36
- "minimum": 1,
37
- "maximum": 200,
38
- },
39
- "default_height": {
40
- "type": "integer",
41
- "description": "Default height for image display",
42
- "minimum": 1,
43
- "maximum": 100,
44
- },
45
- "preserve_aspect": {
46
- "type": "boolean",
47
- "description": "Preserve aspect ratio by default",
48
- "default": True,
49
- },
50
- },
51
- }
@@ -1 +0,0 @@
1
- """Tools for image display plugin."""
@@ -1,83 +0,0 @@
1
- from janito.tools.tool_base import ToolBase, ToolPermissions
2
- from janito.report_events import ReportAction
3
- from janito.i18n import tr
4
- from janito.tools.loop_protection_decorator import protect_against_loops
5
-
6
-
7
- class ShowImageTool(ToolBase):
8
- """Display an image inline in the terminal using the rich library.
9
-
10
- Args:
11
- path (str): Path to the image file.
12
- width (int, optional): Target width in terminal cells. If unset, auto-fit.
13
- height (int, optional): Target height in terminal rows. If unset, auto-fit.
14
- preserve_aspect (bool, optional): Preserve aspect ratio. Default: True.
15
-
16
- Returns:
17
- str: Status message indicating display result or error details.
18
- """
19
-
20
- permissions = ToolPermissions(read=True)
21
- tool_name = "show_image"
22
-
23
- @protect_against_loops(max_calls=5, time_window=10.0, key_field="path")
24
- def run(
25
- self,
26
- path: str,
27
- width: int | None = None,
28
- height: int | None = None,
29
- preserve_aspect: bool = True,
30
- ) -> str:
31
- from janito.tools.tool_utils import display_path
32
- from janito.tools.path_utils import expand_path
33
- import os
34
-
35
- # Defer heavy imports to runtime
36
- try:
37
- from rich.console import Console
38
- from PIL import Image as PILImage
39
- except Exception as e:
40
- msg = tr("⚠️ Missing dependency: PIL/Pillow ({error})", error=e)
41
- self.report_error(msg)
42
- return msg
43
-
44
- path = expand_path(path)
45
- disp_path = display_path(path)
46
- self.report_action(
47
- tr("🖼️ Show image '{disp_path}'", disp_path=disp_path), ReportAction.READ
48
- )
49
-
50
- if not os.path.exists(path):
51
- msg = tr("❗ not found")
52
- self.report_warning(msg)
53
- return tr("Error: file not found: {path}", path=disp_path)
54
-
55
- try:
56
- console = Console()
57
- # rich.image.Image handles inline terminal display of common formats
58
- from rich.console import Console
59
- from rich.text import Text
60
-
61
- console = Console()
62
- img = PILImage.open(path)
63
- console.print(
64
- Text(
65
- f"Image: {disp_path} ({img.width}x{img.height})", style="bold green"
66
- )
67
- )
68
- console.print(img)
69
- self.report_success(tr("✅ Displayed"))
70
- details = []
71
- if width:
72
- details.append(f"width={width}")
73
- if height:
74
- details.append(f"height={height}")
75
- if not preserve_aspect:
76
- details.append("preserve_aspect=False")
77
- info = ("; ".join(details)) if details else "auto-fit"
78
- return tr(
79
- "Image displayed: {disp_path} ({info})", disp_path=disp_path, info=info
80
- )
81
- except Exception as e:
82
- self.report_error(tr(" ❌ Error: {error}", error=e))
83
- return tr("Error displaying image: {error}", error=e)
@@ -1,84 +0,0 @@
1
- from janito.tools.tool_base import ToolBase, ToolPermissions
2
- from janito.report_events import ReportAction
3
- from janito.i18n import tr
4
- from janito.tools.loop_protection_decorator import protect_against_loops
5
- from typing import Sequence
6
-
7
-
8
- class ShowImageGridTool(ToolBase):
9
- """Display multiple images in a grid inline in the terminal using rich.
10
-
11
- Args:
12
- paths (list[str]): List of image file paths.
13
- columns (int, optional): Number of columns in the grid. Default: 2.
14
- width (int, optional): Max width for each image cell. Default: None (auto).
15
- height (int, optional): Max height for each image cell. Default: None (auto).
16
- preserve_aspect (bool, optional): Preserve aspect ratio. Default: True.
17
-
18
- Returns:
19
- str: Status string summarizing the grid display.
20
- """
21
-
22
- permissions = ToolPermissions(read=True)
23
- tool_name = "show_image_grid"
24
-
25
- @protect_against_loops(max_calls=5, time_window=10.0, key_field="paths")
26
- def run(
27
- self,
28
- paths: Sequence[str],
29
- columns: int = 2,
30
- width: int | None = None,
31
- height: int | None = None,
32
- preserve_aspect: bool = True,
33
- ) -> str:
34
- from janito.tools.path_utils import expand_path
35
- from janito.tools.tool_utils import display_path
36
- import os
37
-
38
- try:
39
- from rich.console import Console
40
- from rich.columns import Columns
41
- from PIL import Image as PILImage
42
- from rich.panel import Panel
43
- except Exception as e:
44
- msg = tr("⚠️ Missing dependency: PIL/Pillow ({error})", error=e)
45
- self.report_error(msg)
46
- return msg
47
-
48
- if not paths:
49
- return tr("No images provided")
50
-
51
- self.report_action(
52
- tr("🖼️ Show image grid ({n} images)", n=len(paths)), ReportAction.READ
53
- )
54
-
55
- console = Console()
56
- images = []
57
- shown = 0
58
- for p in paths:
59
- fp = expand_path(p)
60
- if not os.path.exists(fp):
61
- self.report_warning(tr("❗ not found: {p}", p=display_path(fp)))
62
- continue
63
- try:
64
- img = PILImage.open(fp)
65
- title = f"{display_path(fp)} ({img.width}x{img.height})"
66
- images.append(
67
- Panel.fit(title, title=display_path(fp), border_style="dim")
68
- )
69
- shown += 1
70
- except Exception as e:
71
- self.report_warning(tr("⚠️ Skipped {p}: {e}", p=display_path(fp), e=e))
72
-
73
- if not images:
74
- return tr("No images could be displayed")
75
-
76
- # Render in columns (grid-like)
77
- console.print(Columns(images, equal=True, expand=True, columns=columns))
78
- self.report_success(tr("✅ Displayed {n} images", n=shown))
79
- return tr(
80
- "Displayed {shown}/{total} images in a {cols}x? grid",
81
- shown=shown,
82
- total=len(paths),
83
- cols=columns,
84
- )
@@ -1,23 +0,0 @@
1
- """
2
- System Tools Plugin
3
-
4
- System-level operations and shell access.
5
- """
6
-
7
- from typing import Optional
8
-
9
-
10
- def run_powershell_command(
11
- command: str, timeout: int = 60, require_confirmation: bool = False
12
- ) -> str:
13
- """Execute PowerShell commands"""
14
- return f"run_powershell_command(command='{command[:50]}...', timeout={timeout})"
15
-
16
-
17
- run_powershell_command.tool_name = "run_powershell_command"
18
-
19
-
20
- # Plugin metadata
21
- __plugin_name__ = "core.system"
22
- __plugin_description__ = "System-level operations and shell access"
23
- __plugin_tools__ = [run_powershell_command]