janito 1.14.2__py3-none-any.whl → 2.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 (282) hide show
  1. janito/__init__.py +6 -1
  2. janito/__main__.py +1 -1
  3. janito/agent/setup_agent.py +139 -0
  4. janito/agent/templates/profiles/{system_prompt_template_base.txt.j2 → system_prompt_template_main.txt.j2} +1 -1
  5. janito/cli/__init__.py +9 -0
  6. janito/cli/chat_mode/bindings.py +37 -0
  7. janito/cli/chat_mode/chat_entry.py +23 -0
  8. janito/cli/chat_mode/prompt_style.py +19 -0
  9. janito/cli/chat_mode/session.py +272 -0
  10. janito/{shell/prompt/completer.py → cli/chat_mode/shell/autocomplete.py} +7 -6
  11. janito/cli/chat_mode/shell/commands/__init__.py +55 -0
  12. janito/cli/chat_mode/shell/commands/base.py +9 -0
  13. janito/cli/chat_mode/shell/commands/clear.py +12 -0
  14. janito/{shell → cli/chat_mode/shell}/commands/conversation_restart.py +34 -30
  15. janito/cli/chat_mode/shell/commands/edit.py +25 -0
  16. janito/cli/chat_mode/shell/commands/help.py +16 -0
  17. janito/cli/chat_mode/shell/commands/history_view.py +93 -0
  18. janito/cli/chat_mode/shell/commands/lang.py +25 -0
  19. janito/cli/chat_mode/shell/commands/last.py +137 -0
  20. janito/cli/chat_mode/shell/commands/livelogs.py +49 -0
  21. janito/cli/chat_mode/shell/commands/multi.py +51 -0
  22. janito/cli/chat_mode/shell/commands/prompt.py +64 -0
  23. janito/cli/chat_mode/shell/commands/role.py +36 -0
  24. janito/cli/chat_mode/shell/commands/session.py +40 -0
  25. janito/{shell → cli/chat_mode/shell}/commands/session_control.py +2 -2
  26. janito/cli/chat_mode/shell/commands/termweb_log.py +92 -0
  27. janito/cli/chat_mode/shell/commands/tools.py +32 -0
  28. janito/{shell → cli/chat_mode/shell}/commands/utility.py +4 -7
  29. janito/{shell → cli/chat_mode/shell}/commands/verbose.py +5 -5
  30. janito/cli/chat_mode/shell/session/__init__.py +1 -0
  31. janito/{shell → cli/chat_mode/shell}/session/manager.py +9 -1
  32. janito/cli/chat_mode/toolbar.py +90 -0
  33. janito/cli/cli_commands/list_models.py +35 -0
  34. janito/cli/cli_commands/list_providers.py +9 -0
  35. janito/cli/cli_commands/list_tools.py +53 -0
  36. janito/cli/cli_commands/model_selection.py +50 -0
  37. janito/cli/cli_commands/model_utils.py +84 -0
  38. janito/cli/cli_commands/set_api_key.py +19 -0
  39. janito/cli/cli_commands/show_config.py +51 -0
  40. janito/cli/cli_commands/show_system_prompt.py +62 -0
  41. janito/cli/config.py +28 -0
  42. janito/cli/console.py +3 -0
  43. janito/cli/core/__init__.py +4 -0
  44. janito/cli/core/event_logger.py +59 -0
  45. janito/cli/core/getters.py +31 -0
  46. janito/cli/core/runner.py +141 -0
  47. janito/cli/core/setters.py +174 -0
  48. janito/cli/core/unsetters.py +54 -0
  49. janito/cli/main.py +8 -196
  50. janito/cli/main_cli.py +312 -0
  51. janito/cli/prompt_core.py +230 -0
  52. janito/cli/prompt_handler.py +6 -0
  53. janito/cli/rich_terminal_reporter.py +101 -0
  54. janito/cli/single_shot_mode/__init__.py +6 -0
  55. janito/cli/single_shot_mode/handler.py +137 -0
  56. janito/cli/termweb_starter.py +73 -24
  57. janito/cli/utils.py +25 -0
  58. janito/cli/verbose_output.py +196 -0
  59. janito/config.py +5 -0
  60. janito/config_manager.py +110 -0
  61. janito/conversation_history.py +30 -0
  62. janito/{agent/tools_utils/dir_walk_utils.py → dir_walk_utils.py} +3 -2
  63. janito/driver_events.py +98 -0
  64. janito/drivers/anthropic/driver.py +113 -0
  65. janito/drivers/azure_openai/driver.py +36 -0
  66. janito/drivers/driver_registry.py +33 -0
  67. janito/drivers/google_genai/driver.py +54 -0
  68. janito/drivers/google_genai/schema_generator.py +67 -0
  69. janito/drivers/mistralai/driver.py +41 -0
  70. janito/drivers/openai/driver.py +334 -0
  71. janito/event_bus/__init__.py +2 -0
  72. janito/event_bus/bus.py +68 -0
  73. janito/event_bus/event.py +15 -0
  74. janito/event_bus/handler.py +31 -0
  75. janito/event_bus/queue_bus.py +57 -0
  76. janito/exceptions.py +23 -0
  77. janito/formatting_token.py +54 -0
  78. janito/i18n/pt.py +1 -0
  79. janito/llm/__init__.py +5 -0
  80. janito/llm/agent.py +443 -0
  81. janito/llm/auth.py +62 -0
  82. janito/llm/driver.py +239 -0
  83. janito/llm/driver_config.py +34 -0
  84. janito/llm/driver_config_builder.py +34 -0
  85. janito/llm/driver_input.py +12 -0
  86. janito/llm/message_parts.py +60 -0
  87. janito/llm/model.py +38 -0
  88. janito/llm/provider.py +187 -0
  89. janito/perf_singleton.py +3 -0
  90. janito/performance_collector.py +167 -0
  91. janito/provider_config.py +98 -0
  92. janito/provider_registry.py +152 -0
  93. janito/providers/__init__.py +7 -0
  94. janito/providers/anthropic/model_info.py +22 -0
  95. janito/providers/anthropic/provider.py +65 -0
  96. janito/providers/azure_openai/model_info.py +15 -0
  97. janito/providers/azure_openai/provider.py +72 -0
  98. janito/providers/deepseek/__init__.py +1 -0
  99. janito/providers/deepseek/model_info.py +16 -0
  100. janito/providers/deepseek/provider.py +91 -0
  101. janito/providers/google/__init__.py +1 -0
  102. janito/providers/google/model_info.py +40 -0
  103. janito/providers/google/provider.py +69 -0
  104. janito/providers/mistralai/model_info.py +37 -0
  105. janito/providers/mistralai/provider.py +69 -0
  106. janito/providers/openai/__init__.py +1 -0
  107. janito/providers/openai/model_info.py +137 -0
  108. janito/providers/openai/provider.py +107 -0
  109. janito/providers/openai/schema_generator.py +63 -0
  110. janito/providers/provider_static_info.py +21 -0
  111. janito/providers/registry.py +26 -0
  112. janito/report_events.py +38 -0
  113. janito/termweb/app.py +1 -1
  114. janito/tools/__init__.py +16 -0
  115. janito/tools/adapters/__init__.py +1 -0
  116. janito/tools/adapters/local/__init__.py +54 -0
  117. janito/tools/adapters/local/adapter.py +92 -0
  118. janito/{agent/tools → tools/adapters/local}/ask_user.py +30 -13
  119. janito/tools/adapters/local/copy_file.py +84 -0
  120. janito/{agent/tools → tools/adapters/local}/create_directory.py +11 -10
  121. janito/tools/adapters/local/create_file.py +82 -0
  122. janito/tools/adapters/local/delete_text_in_file.py +136 -0
  123. janito/{agent/tools → tools/adapters/local}/fetch_url.py +18 -19
  124. janito/tools/adapters/local/find_files.py +140 -0
  125. janito/tools/adapters/local/get_file_outline/core.py +151 -0
  126. janito/{agent/tools → tools/adapters/local}/get_file_outline/python_outline.py +125 -0
  127. janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -0
  128. janito/{agent/tools → tools/adapters/local}/get_file_outline/search_outline.py +12 -7
  129. janito/{agent/tools → tools/adapters/local}/move_file.py +13 -9
  130. janito/{agent/tools → tools/adapters/local}/open_url.py +7 -5
  131. janito/tools/adapters/local/python_code_run.py +165 -0
  132. janito/tools/adapters/local/python_command_run.py +163 -0
  133. janito/tools/adapters/local/python_file_run.py +162 -0
  134. janito/{agent/tools → tools/adapters/local}/remove_directory.py +15 -9
  135. janito/{agent/tools → tools/adapters/local}/remove_file.py +17 -14
  136. janito/{agent/tools → tools/adapters/local}/replace_text_in_file.py +27 -22
  137. janito/tools/adapters/local/run_bash_command.py +176 -0
  138. janito/tools/adapters/local/run_powershell_command.py +219 -0
  139. janito/{agent/tools → tools/adapters/local}/search_text/core.py +32 -12
  140. janito/{agent/tools → tools/adapters/local}/search_text/match_lines.py +13 -4
  141. janito/{agent/tools → tools/adapters/local}/search_text/pattern_utils.py +12 -4
  142. janito/{agent/tools → tools/adapters/local}/search_text/traverse_directory.py +15 -2
  143. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/core.py +12 -11
  144. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/css_validator.py +1 -1
  145. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/html_validator.py +1 -1
  146. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/js_validator.py +1 -1
  147. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/json_validator.py +1 -1
  148. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/markdown_validator.py +1 -1
  149. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/ps1_validator.py +1 -1
  150. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/python_validator.py +1 -1
  151. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/xml_validator.py +1 -1
  152. janito/{agent/tools → tools/adapters/local}/validate_file_syntax/yaml_validator.py +1 -1
  153. janito/{agent/tools/get_lines.py → tools/adapters/local/view_file.py} +45 -27
  154. janito/tools/inspect_registry.py +17 -0
  155. janito/tools/tool_base.py +105 -0
  156. janito/tools/tool_events.py +58 -0
  157. janito/tools/tool_run_exception.py +12 -0
  158. janito/{agent → tools}/tool_use_tracker.py +2 -4
  159. janito/{agent/tools_utils/utils.py → tools/tool_utils.py} +18 -9
  160. janito/tools/tools_adapter.py +207 -0
  161. janito/tools/tools_schema.py +104 -0
  162. janito/utils.py +11 -0
  163. janito/version.py +4 -0
  164. janito-2.0.0.dist-info/METADATA +232 -0
  165. janito-2.0.0.dist-info/RECORD +180 -0
  166. janito/agent/__init__.py +0 -0
  167. janito/agent/api_exceptions.py +0 -4
  168. janito/agent/config.py +0 -147
  169. janito/agent/config_defaults.py +0 -12
  170. janito/agent/config_utils.py +0 -0
  171. janito/agent/content_handler.py +0 -0
  172. janito/agent/conversation.py +0 -238
  173. janito/agent/conversation_api.py +0 -306
  174. janito/agent/conversation_exceptions.py +0 -18
  175. janito/agent/conversation_tool_calls.py +0 -39
  176. janito/agent/conversation_ui.py +0 -17
  177. janito/agent/event.py +0 -24
  178. janito/agent/event_dispatcher.py +0 -24
  179. janito/agent/event_handler_protocol.py +0 -5
  180. janito/agent/event_system.py +0 -15
  181. janito/agent/llm_conversation_history.py +0 -82
  182. janito/agent/message_handler.py +0 -20
  183. janito/agent/message_handler_protocol.py +0 -5
  184. janito/agent/openai_client.py +0 -149
  185. janito/agent/openai_schema_generator.py +0 -187
  186. janito/agent/profile_manager.py +0 -96
  187. janito/agent/queued_message_handler.py +0 -50
  188. janito/agent/rich_live.py +0 -32
  189. janito/agent/rich_message_handler.py +0 -115
  190. janito/agent/runtime_config.py +0 -36
  191. janito/agent/test_handler_protocols.py +0 -47
  192. janito/agent/test_openai_schema_generator.py +0 -93
  193. janito/agent/tests/__init__.py +0 -1
  194. janito/agent/tool_base.py +0 -63
  195. janito/agent/tool_executor.py +0 -122
  196. janito/agent/tool_registry.py +0 -49
  197. janito/agent/tools/__init__.py +0 -47
  198. janito/agent/tools/create_file.py +0 -59
  199. janito/agent/tools/delete_text_in_file.py +0 -97
  200. janito/agent/tools/find_files.py +0 -106
  201. janito/agent/tools/get_file_outline/core.py +0 -81
  202. janito/agent/tools/present_choices.py +0 -64
  203. janito/agent/tools/python_command_runner.py +0 -201
  204. janito/agent/tools/python_file_runner.py +0 -199
  205. janito/agent/tools/python_stdin_runner.py +0 -208
  206. janito/agent/tools/replace_file.py +0 -72
  207. janito/agent/tools/run_bash_command.py +0 -218
  208. janito/agent/tools/run_powershell_command.py +0 -251
  209. janito/agent/tools_utils/__init__.py +0 -1
  210. janito/agent/tools_utils/action_type.py +0 -7
  211. janito/agent/tools_utils/test_gitignore_utils.py +0 -46
  212. janito/cli/_livereload_log_utils.py +0 -13
  213. janito/cli/_print_config.py +0 -96
  214. janito/cli/_termweb_log_utils.py +0 -17
  215. janito/cli/_utils.py +0 -9
  216. janito/cli/arg_parser.py +0 -272
  217. janito/cli/cli_main.py +0 -281
  218. janito/cli/config_commands.py +0 -211
  219. janito/cli/config_runner.py +0 -35
  220. janito/cli/formatting_runner.py +0 -12
  221. janito/cli/livereload_starter.py +0 -60
  222. janito/cli/logging_setup.py +0 -38
  223. janito/cli/one_shot.py +0 -80
  224. janito/livereload/app.py +0 -25
  225. janito/rich_utils.py +0 -59
  226. janito/shell/__init__.py +0 -0
  227. janito/shell/commands/__init__.py +0 -61
  228. janito/shell/commands/config.py +0 -22
  229. janito/shell/commands/edit.py +0 -24
  230. janito/shell/commands/history_view.py +0 -18
  231. janito/shell/commands/lang.py +0 -19
  232. janito/shell/commands/livelogs.py +0 -42
  233. janito/shell/commands/prompt.py +0 -62
  234. janito/shell/commands/termweb_log.py +0 -94
  235. janito/shell/commands/tools.py +0 -26
  236. janito/shell/commands/track.py +0 -36
  237. janito/shell/main.py +0 -326
  238. janito/shell/prompt/load_prompt.py +0 -57
  239. janito/shell/prompt/session_setup.py +0 -57
  240. janito/shell/session/config.py +0 -109
  241. janito/shell/session/history.py +0 -0
  242. janito/shell/ui/interactive.py +0 -226
  243. janito/termweb/static/editor.css +0 -158
  244. janito/termweb/static/editor.css.bak +0 -145
  245. janito/termweb/static/editor.html +0 -46
  246. janito/termweb/static/editor.html.bak +0 -46
  247. janito/termweb/static/editor.js +0 -265
  248. janito/termweb/static/editor.js.bak +0 -259
  249. janito/termweb/static/explorer.html.bak +0 -59
  250. janito/termweb/static/favicon.ico +0 -0
  251. janito/termweb/static/favicon.ico.bak +0 -0
  252. janito/termweb/static/index.html +0 -53
  253. janito/termweb/static/index.html.bak +0 -54
  254. janito/termweb/static/index.html.bak.bak +0 -175
  255. janito/termweb/static/landing.html.bak +0 -36
  256. janito/termweb/static/termicon.svg +0 -1
  257. janito/termweb/static/termweb.css +0 -214
  258. janito/termweb/static/termweb.css.bak +0 -237
  259. janito/termweb/static/termweb.js +0 -162
  260. janito/termweb/static/termweb.js.bak +0 -168
  261. janito/termweb/static/termweb.js.bak.bak +0 -157
  262. janito/termweb/static/termweb_quickopen.js +0 -135
  263. janito/termweb/static/termweb_quickopen.js.bak +0 -125
  264. janito/tests/test_rich_utils.py +0 -44
  265. janito/web/__init__.py +0 -0
  266. janito/web/__main__.py +0 -25
  267. janito/web/app.py +0 -145
  268. janito-1.14.2.dist-info/METADATA +0 -306
  269. janito-1.14.2.dist-info/RECORD +0 -162
  270. janito-1.14.2.dist-info/licenses/LICENSE +0 -21
  271. /janito/{shell → cli/chat_mode/shell}/input_history.py +0 -0
  272. /janito/{shell/commands/session.py → cli/chat_mode/shell/session/history.py} +0 -0
  273. /janito/{agent/tools_utils/formatting.py → formatting.py} +0 -0
  274. /janito/{agent/tools_utils/gitignore_utils.py → gitignore_utils.py} +0 -0
  275. /janito/{agent/platform_discovery.py → platform_discovery.py} +0 -0
  276. /janito/{agent/tools → tools/adapters/local}/get_file_outline/__init__.py +0 -0
  277. /janito/{agent/tools → tools/adapters/local}/get_file_outline/markdown_outline.py +0 -0
  278. /janito/{agent/tools → tools/adapters/local}/search_text/__init__.py +0 -0
  279. /janito/{agent/tools → tools/adapters/local}/validate_file_syntax/__init__.py +0 -0
  280. {janito-1.14.2.dist-info → janito-2.0.0.dist-info}/WHEEL +0 -0
  281. {janito-1.14.2.dist-info → janito-2.0.0.dist-info}/entry_points.txt +0 -0
  282. {janito-1.14.2.dist-info → janito-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,237 +0,0 @@
1
- /* --- Layout and Theme --- */
2
- html, body {
3
- height: 100%;
4
- margin: 0;
5
- padding: 0;
6
- }
7
- body {
8
- display: flex;
9
- flex-direction: column;
10
- min-height: 100vh;
11
- background: #181a1b;
12
- color: #f1f1f1;
13
- transition: background 0.2s, color 0.2s;
14
- }
15
- body.light-theme {
16
- background: #f5f5f5;
17
- color: #181a1b;
18
- }
19
-
20
- .header {
21
- background: #23272b;
22
- color: #f1f1f1;
23
- padding: 0.2em 2em 1em 2em;
24
- font-size: 1.5em;
25
- font-weight: bold;
26
- letter-spacing: 0.04em;
27
- border-bottom: 2px solid #1a73e8;
28
- position: relative;
29
- transition: background 0.2s, color 0.2s;
30
- }
31
- body.dark-theme .header {
32
- background: #181a1b;
33
- color: #f1f1f1;
34
- border-bottom: 2px solid #1976d2;
35
- }
36
- body.light-theme .header {
37
- background: #eaeaea;
38
- color: #181a1b;
39
- border-bottom: 2px solid #1565c0;
40
- }
41
-
42
- /* --- Enhanced Header --- */
43
- .header-logo {
44
- width: 2.4em;
45
- height: 2.4em;
46
- margin-right: 0.5em;
47
- vertical-align: middle;
48
- }
49
- .header-title {
50
- font-size: 1.7em;
51
- font-weight: bold;
52
- letter-spacing: 0.04em;
53
- color: #8be9fd;
54
- text-shadow: 0 2px 8px #222a, 0 1px 0 #222a;
55
- }
56
- .header-subtitle {
57
- font-size: 1.1em;
58
- font-weight: 400;
59
- opacity: 0.7;
60
- margin-left: 0.5em;
61
- color: #90caf9;
62
- }
63
-
64
- /* --- Explorer Entry Flex Alignment --- */
65
- .explorer-entry {
66
- display: flex;
67
- align-items: center;
68
- gap: 0.7em;
69
- }
70
- .explorer-icon {
71
- font-size: 1.2em;
72
- min-width: 1.6em;
73
- text-align: center;
74
- margin-right: 0.2em;
75
- }
76
- .explorer-name {
77
- font-size: 1em;
78
- word-break: break-all;
79
- }
80
-
81
- .main {
82
- flex: 1 1 auto;
83
- display: flex;
84
- flex-direction: row;
85
- gap: 2em;
86
- padding: 2em;
87
- min-height: 60vh;
88
- background: transparent;
89
- }
90
- #explorer-main, #explorer-preview {
91
- background: #22262b;
92
- border-radius: 1.1em;
93
- box-shadow: 0 4px 24px #0004;
94
- border: 1px solid #1a73e8;
95
- padding: 1.5em 1.2em;
96
- min-height: 40vh;
97
- overflow: auto;
98
- }
99
- #explorer-main {
100
- margin-right: 0.5em;
101
- }
102
- #explorer-preview {
103
- margin-left: 0.5em;
104
- display: flex;
105
- flex-direction: column;
106
- flex: 1 1 0;
107
- min-width: 0;
108
- }
109
-
110
- /* --- CodeMirror Integration for Preview --- */
111
- #explorer-codemirror-preview {
112
- flex: 1 1 auto;
113
- min-height: 0;
114
- min-width: 0;
115
- display: flex;
116
- flex-direction: column;
117
- }
118
- .CodeMirror {
119
- flex: 1 1 auto;
120
- height: 60vh !important;
121
- min-height: 0;
122
- font-size: 1.1em;
123
- background: #23272b;
124
- color: #f8f8f2;
125
- border-radius: 0.5em;
126
- border: none;
127
- transition: background 0.2s, color 0.2s;
128
- }
129
- body.light-theme .CodeMirror {
130
- background: #fff;
131
- color: #181a1b;
132
- }
133
-
134
- .footer {
135
- flex-shrink: 0;
136
- background: #23272b;
137
- color: #f1f1f1;
138
- padding: 1.2em 2em 1em 2em;
139
- font-size: 1em;
140
- border-top: 2px solid #1a73e8;
141
- text-align: center;
142
- display: flex;
143
- flex-direction: column;
144
- align-items: center;
145
- justify-content: center;
146
- position: fixed;
147
- left: 0;
148
- bottom: 0;
149
- width: 100%;
150
- z-index: 100;
151
- transition: background 0.2s, color 0.2s;
152
- }
153
- body.dark-theme .footer {
154
- background: #181a1b;
155
- color: #f1f1f1;
156
- border-top: 2px solid #1976d2;
157
- }
158
- body.light-theme .footer {
159
- background: #eaeaea;
160
- color: #181a1b;
161
- border-top: 2px solid #1565c0;
162
- }
163
- .footer a {
164
- color: #90caf9;
165
- text-decoration: underline;
166
- }
167
- body.light-theme .footer a {
168
- color: #1976d2;
169
- }
170
- .footer ul {
171
- list-style: none;
172
- padding: 0;
173
- margin: 0.5em 0 0 0;
174
- display: flex;
175
- gap: 1.5em;
176
- justify-content: center;
177
- align-items: center;
178
- }
179
- .footer li {
180
- display: inline;
181
- }
182
-
183
- .theme-switcher {
184
- position: absolute;
185
- right: 20px;
186
- top: 2px;
187
- background: #444;
188
- color: #f1f1f1;
189
- border: none;
190
- border-radius: 4px;
191
- padding: 0px 6px;
192
- margin-top: -0.2em;
193
- margin-bottom: 2px;
194
- cursor: pointer;
195
- font-size: 0.85em;
196
- transition: background 0.2s, color 0.2s;
197
- }
198
- body.light-theme .theme-switcher {
199
- background: #ddd;
200
- color: #181a1b;
201
- }
202
- body.dark-theme .theme-switcher {
203
- background: #23272b;
204
- color: #f1f1f1;
205
- }
206
-
207
- /* Explorer file/dir links */
208
- .explorer-link, .explorer-link:visited {
209
- color: #90caf9;
210
- text-decoration: none;
211
- font-weight: 500;
212
- }
213
- body.light-theme .explorer-link, body.light-theme .explorer-link:visited {
214
- color: #1976d2;
215
- }
216
- .explorer-link:hover {
217
- text-decoration: underline;
218
- color: #42a5f5;
219
- }
220
- body.light-theme .explorer-link:hover {
221
- color: #1565c0;
222
- }
223
-
224
- @media (max-width: 900px) {
225
- .main {
226
- flex-direction: column;
227
- gap: 1em;
228
- padding: 1em;
229
- }
230
- #explorer-main, #explorer-preview {
231
- min-height: 20vh;
232
- padding: 1em 0.7em;
233
- }
234
- #explorer-preview {
235
- margin-left: 0;
236
- }
237
- }
@@ -1,162 +0,0 @@
1
- // Directory/File browser logic for explorer with right-side preview and URL sync (using /path)
2
- let explorerView = localStorage.getItem('explorerView') || 'list';
3
- let currentExplorerPath = '.';
4
-
5
- function getPaiPath(path) {
6
- // Normalize slashes
7
- path = (path || '').replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
8
- if (!path || path === '.' || path === '') return '.';
9
- const parts = path.split('/');
10
- if (parts.length <= 1) return '.';
11
- parts.pop();
12
- const parent = parts.join('/');
13
- return parent === '' ? '.' : parent;
14
- }
15
-
16
- function setExplorerView(view) {
17
- explorerView = view;
18
- localStorage.setItem('explorerView', view);
19
- }
20
-
21
- function normalizeExplorerPath(path) {
22
- if (!path || path === '/' || path === '' || path === '.') return '.';
23
- return path.replace(/^\/+|\/+$/g, '');
24
- }
25
-
26
- function updateExplorerUrl(path, push=true) {
27
- let url = '/';
28
- if (path && path !== '.' && path !== '/') {
29
- url = '/' + path.replace(/^\/+|\/+$/g, '');
30
- }
31
- if (push) {
32
- window.history.pushState({ explorerPath: path }, '', url);
33
- }
34
- }
35
-
36
- function renderExplorer(path, pushUrl=true) {
37
- currentExplorerPath = normalizeExplorerPath(path);
38
- fetch(`/api/explorer/${encodeURIComponent(currentExplorerPath)}`)
39
- .then(resp => resp.json())
40
- .then(data => {
41
- const main = document.getElementById('explorer-main');
42
- if (!main) return;
43
- if (data.error) {
44
- main.innerHTML = `<div class='error'>${data.error}</div>`;
45
- return;
46
- }
47
- if (data.type === 'dir') {
48
- let html = `<h3>Diretório: ${data.path}</h3>`;
49
- if (explorerView === 'list') {
50
- html += `<ul class='explorer-list'>`;
51
- if (data.path !== '.') {
52
- const parent = getPaiPath(data.path);
53
- html += `<li><a href='#' data-path='${parent}' class='explorer-link'><span class='explorer-entry'><span class='explorer-icon'>⬆️</span><span class='explorer-name'>(.. parent)</span></span></a></li>`;
54
- }
55
- for (const entry of data.entries) {
56
- const entryPath = data.path === '.' ? entry.name : data.path + '/' + entry.name;
57
- if (entry.is_dir) {
58
- html += `<li><a href='#' data-path='${entryPath}' class='explorer-link'><span class='explorer-entry'><span class='explorer-icon'>📁</span><span class='explorer-name'>${entry.name}</span></span></a></li>`;
59
- } else {
60
- html += `<li><a href='#' data-path='${entryPath}' class='explorer-link file-link'><span class='explorer-entry'><span class='explorer-icon'>📄</span><span class='explorer-name'>${entry.name}</span></span></a></li>`;
61
- }
62
- }
63
- html += '</ul>';
64
- }
65
-
66
- main.innerHTML = html;
67
- // Clear preview panel when changing directories
68
- const preview = document.getElementById('explorer-preview');
69
- if (preview) preview.innerHTML = '';
70
- if (pushUrl) updateExplorerUrl(currentExplorerPath, true);
71
- }
72
- // Attach click handlers
73
- document.querySelectorAll('.explorer-link').forEach(link => {
74
- link.onclick = function(e) {
75
- e.preventDefault();
76
- const p = this.getAttribute('data-path');
77
- // If file, show preview; if dir, update explorer
78
- if (this.classList.contains('file-link')) {
79
- const preview = document.getElementById('explorer-preview');
80
- if (preview) {
81
- preview.innerHTML = `<div class='spinner' style='display:inline-block;vertical-align:middle;'></div> <span style='vertical-align:middle;'>Carregando arquivo...</span>`;
82
- }
83
- fetch(`/api/explorer/${encodeURIComponent(p)}`)
84
- .then(resp => resp.json())
85
- .then(fileData => {
86
- if (preview && fileData.type === 'file') {
87
- if (window.renderCodePreview) {
88
- preview.innerHTML = `<h3>Arquivo: ${fileData.path}</h3><div id='explorer-codemirror-preview'></div>`;
89
- window.renderCodePreview(document.getElementById('explorer-codemirror-preview'), fileData.content, 'python');
90
- } else {
91
- preview.innerHTML = `<h3>Arquivo: ${fileData.path}</h3><pre class='explorer-file'>${escapeHtml(fileData.content)}</pre>`;
92
- }
93
- }
94
- });
95
- } else {
96
- renderExplorer(p, true);
97
- }
98
- };
99
- });
100
- });
101
- }
102
-
103
- function escapeHtml(text) {
104
- if (!text) return '';
105
- return text.replace(/[&<>"']/g, function (c) {
106
- return {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'}[c];
107
- });
108
- }
109
-
110
- // Patch: Use CodeMirror for explorer preview in read-only mode
111
- window.renderCodePreview = function(container, content, mode) {
112
- if (!container) return;
113
- container.innerHTML = '';
114
- try {
115
- var textarea = document.createElement('textarea');
116
- textarea.value = (typeof content === 'string') ? content : '';
117
- container.appendChild(textarea);
118
- if (window.CodeMirror) {
119
- var editor = CodeMirror.fromTextArea(textarea, {
120
- lineNumbers: true,
121
- mode: mode || 'python',
122
- theme: (document.body.classList.contains('light-theme') ? 'default' : 'dracula'),
123
- readOnly: true,
124
- indentUnit: 4,
125
- tabSize: 4,
126
- });
127
- editor.setSize('100%', '60vh');
128
- return editor;
129
- } else {
130
- container.innerHTML = '<pre>' + (content ? String(content) : '') + '</pre>';
131
- }
132
- } catch (e) {
133
- container.innerHTML = '<pre>' + (content ? String(content) : '') + '</pre>';
134
- }
135
- };
136
-
137
- // Theme switcher logic
138
- function setTheme(dark) {
139
- if (dark) {
140
- document.body.classList.add('dark-theme');
141
- document.body.classList.remove('light-theme');
142
- localStorage.setItem('theme', 'dark');
143
- var themeIcon = document.getElementById('theme-icon');
144
- if (themeIcon) themeIcon.textContent = '🌙'; // Moon for dark theme
145
- } else {
146
- document.body.classList.remove('dark-theme');
147
- document.body.classList.add('light-theme');
148
- localStorage.setItem('theme', 'light');
149
- var themeIcon = document.getElementById('theme-icon');
150
- if (themeIcon) themeIcon.textContent = '☀️'; // Sun for light theme
151
- }
152
- }
153
- document.addEventListener('DOMContentLoaded', function() {
154
- // Initial theme
155
- var theme = localStorage.getItem('theme') || 'dark';
156
- setTheme(theme === 'dark');
157
- setExplorerView('list'); // Always use list view
158
- renderExplorer('.')
159
- });
160
-
161
- window.renderExplorer = renderExplorer;
162
- window.setExplorerView = setExplorerView;
@@ -1,168 +0,0 @@
1
- // Directory/File browser logic for explorer with right-side preview and URL sync (using /path)
2
- let explorerView = localStorage.getItem('explorerView') || 'list';
3
- let currentExplorerPath = '.';
4
-
5
- function getPaiPath(path) {
6
- // Normalize slashes
7
- path = (path || '').replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
8
- if (!path || path === '.' || path === '') return '.';
9
- const parts = path.split('/');
10
- if (parts.length <= 1) return '.';
11
- parts.pop();
12
- const parent = parts.join('/');
13
- return parent === '' ? '.' : parent;
14
- }
15
-
16
- function setExplorerView(view) {
17
- explorerView = view;
18
- localStorage.setItem('explorerView', view);
19
- }
20
-
21
- function normalizeExplorerPath(path) {
22
- if (!path || path === '/' || path === '' || path === '.') return '.';
23
- return path.replace(/^\/+|\/+$/g, '');
24
- }
25
-
26
- function updateExplorerUrl(path, push=true) {
27
- let url = '/';
28
- if (path && path !== '.' && path !== '/') {
29
- url = '/' + path.replace(/^\/+|\/+$/g, '');
30
- }
31
- if (push) {
32
- window.history.pushState({ explorerPath: path }, '', url);
33
- }
34
- }
35
-
36
- function renderExplorer(path, pushUrl=true) {
37
- currentExplorerPath = normalizeExplorerPath(path);
38
- fetch(`/api/explorer/${encodeURIComponent(currentExplorerPath)}`)
39
- .then(resp => resp.json())
40
- .then(data => {
41
- const main = document.getElementById('explorer-main');
42
- if (!main) return;
43
- if (data.error) {
44
- main.innerHTML = `<div class='error'>${data.error}</div>`;
45
- return;
46
- }
47
- if (data.type === 'dir') {
48
- let html = `<h3>Diretório: ${data.path}</h3>`;
49
- if (explorerView === 'list') {
50
- html += `<ul class='explorer-list'>`;
51
- if (data.path !== '.') {
52
- const parent = getPaiPath(data.path);
53
- html += `<li><a href='#' data-path='${parent}' class='explorer-link'><span class='explorer-entry'><span class='explorer-icon'>⬆️</span><span class='explorer-name'>(.. parent)</span></span></a></li>`;
54
- }
55
- for (const entry of data.entries) {
56
- const entryPath = data.path === '.' ? entry.name : data.path + '/' + entry.name;
57
- if (entry.is_dir) {
58
- html += `<li><a href='#' data-path='${entryPath}' class='explorer-link'><span class='explorer-entry'><span class='explorer-icon'>📁</span><span class='explorer-name'>${entry.name}</span></span></a></li>`;
59
- } else {
60
- html += `<li><a href='#' data-path='${entryPath}' class='explorer-link file-link'><span class='explorer-entry'><span class='explorer-icon'>📄</span><span class='explorer-name'>${entry.name}</span></span></a></li>`;
61
- }
62
- }
63
- html += '</ul>';
64
- }
65
-
66
- main.innerHTML = html;
67
- // Clear preview panel when changing directories
68
- const preview = document.getElementById('explorer-preview');
69
- if (preview) preview.innerHTML = '';
70
- if (pushUrl) updateExplorerUrl(currentExplorerPath, true);
71
- }
72
- // Attach click handlers
73
- document.querySelectorAll('.explorer-link').forEach(link => {
74
- link.onclick = function(e) {
75
- e.preventDefault();
76
- const p = this.getAttribute('data-path');
77
- // If file, show preview; if dir, update explorer
78
- if (this.classList.contains('file-link')) {
79
- const preview = document.getElementById('explorer-preview');
80
- if (preview) {
81
- preview.innerHTML = `<div class='spinner' style='display:inline-block;vertical-align:middle;'></div> <span style='vertical-align:middle;'>Carregando arquivo...</span>`;
82
- }
83
- fetch(`/api/explorer/${encodeURIComponent(p)}`)
84
- .then(resp => resp.json())
85
- .then(fileData => {
86
- if (preview && fileData.type === 'file') {
87
- if (window.renderCodePreview) {
88
- preview.innerHTML = `<h3>Arquivo: ${fileData.path}</h3><div id='explorer-codemirror-preview'></div>`;
89
- window.renderCodePreview(document.getElementById('explorer-codemirror-preview'), fileData.content, 'python');
90
- } else {
91
- preview.innerHTML = `<h3>Arquivo: ${fileData.path}</h3><pre class='explorer-file'>${escapeHtml(fileData.content)}</pre>`;
92
- }
93
- }
94
- });
95
- } else {
96
- renderExplorer(p, true);
97
- }
98
- };
99
- });
100
- });
101
- }
102
-
103
- function escapeHtml(text) {
104
- if (!text) return '';
105
- return text.replace(/[&<>"']/g, function (c) {
106
- return {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'}[c];
107
- });
108
- }
109
-
110
- // Patch: Use CodeMirror for explorer preview in read-only mode
111
- window.renderCodePreview = function(container, content, mode) {
112
- if (!container) return;
113
- container.innerHTML = '';
114
- try {
115
- var textarea = document.createElement('textarea');
116
- textarea.value = (typeof content === 'string') ? content : '';
117
- container.appendChild(textarea);
118
- if (window.CodeMirror) {
119
- var editor = CodeMirror.fromTextArea(textarea, {
120
- lineNumbers: true,
121
- mode: mode || 'python',
122
- theme: (document.body.classList.contains('light-theme') ? 'default' : 'dracula'),
123
- readOnly: true,
124
- indentUnit: 4,
125
- tabSize: 4,
126
- });
127
- editor.setSize('100%', '60vh');
128
- return editor;
129
- } else {
130
- container.innerHTML = '<pre>' + (content ? String(content) : '') + '</pre>';
131
- }
132
- } catch (e) {
133
- container.innerHTML = '<pre>' + (content ? String(content) : '') + '</pre>';
134
- }
135
- };
136
-
137
- // Theme switcher logic
138
- function setTheme(dark) {
139
- if (dark) {
140
- document.body.classList.add('dark-theme');
141
- document.body.classList.remove('light-theme');
142
- localStorage.setItem('theme', 'dark');
143
- var themeIcon = document.getElementById('theme-icon');
144
- if (themeIcon) themeIcon.textContent = '🌙'; // Moon for dark theme
145
- } else {
146
- document.body.classList.remove('dark-theme');
147
- document.body.classList.add('light-theme');
148
- localStorage.setItem('theme', 'light');
149
- var themeIcon = document.getElementById('theme-icon');
150
- if (themeIcon) themeIcon.textContent = '☀️'; // Sun for light theme
151
- }
152
- }
153
- document.addEventListener('DOMContentLoaded', function() {
154
- // Initial theme
155
- var theme = localStorage.getItem('theme') || 'dark';
156
- setTheme(theme === 'dark');
157
- var themeSwitcher = document.getElementById('theme-switcher');
158
- if (themeSwitcher) {
159
- themeSwitcher.onclick = function() {
160
- setTheme(document.body.classList.contains('light-theme'));
161
- };
162
- }
163
- setExplorerView('list'); // Always use list view
164
- renderExplorer('.')
165
- });
166
-
167
- window.renderExplorer = renderExplorer;
168
- window.setExplorerView = setExplorerView;