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.
- janito/__init__.py +6 -1
- janito/__main__.py +1 -1
- janito/agent/setup_agent.py +139 -0
- janito/agent/templates/profiles/{system_prompt_template_base.txt.j2 → system_prompt_template_main.txt.j2} +1 -1
- janito/cli/__init__.py +9 -0
- janito/cli/chat_mode/bindings.py +37 -0
- janito/cli/chat_mode/chat_entry.py +23 -0
- janito/cli/chat_mode/prompt_style.py +19 -0
- janito/cli/chat_mode/session.py +272 -0
- janito/{shell/prompt/completer.py → cli/chat_mode/shell/autocomplete.py} +7 -6
- janito/cli/chat_mode/shell/commands/__init__.py +55 -0
- janito/cli/chat_mode/shell/commands/base.py +9 -0
- janito/cli/chat_mode/shell/commands/clear.py +12 -0
- janito/{shell → cli/chat_mode/shell}/commands/conversation_restart.py +34 -30
- janito/cli/chat_mode/shell/commands/edit.py +25 -0
- janito/cli/chat_mode/shell/commands/help.py +16 -0
- janito/cli/chat_mode/shell/commands/history_view.py +93 -0
- janito/cli/chat_mode/shell/commands/lang.py +25 -0
- janito/cli/chat_mode/shell/commands/last.py +137 -0
- janito/cli/chat_mode/shell/commands/livelogs.py +49 -0
- janito/cli/chat_mode/shell/commands/multi.py +51 -0
- janito/cli/chat_mode/shell/commands/prompt.py +64 -0
- janito/cli/chat_mode/shell/commands/role.py +36 -0
- janito/cli/chat_mode/shell/commands/session.py +40 -0
- janito/{shell → cli/chat_mode/shell}/commands/session_control.py +2 -2
- janito/cli/chat_mode/shell/commands/termweb_log.py +92 -0
- janito/cli/chat_mode/shell/commands/tools.py +32 -0
- janito/{shell → cli/chat_mode/shell}/commands/utility.py +4 -7
- janito/{shell → cli/chat_mode/shell}/commands/verbose.py +5 -5
- janito/cli/chat_mode/shell/session/__init__.py +1 -0
- janito/{shell → cli/chat_mode/shell}/session/manager.py +9 -1
- janito/cli/chat_mode/toolbar.py +90 -0
- janito/cli/cli_commands/list_models.py +35 -0
- janito/cli/cli_commands/list_providers.py +9 -0
- janito/cli/cli_commands/list_tools.py +53 -0
- janito/cli/cli_commands/model_selection.py +50 -0
- janito/cli/cli_commands/model_utils.py +84 -0
- janito/cli/cli_commands/set_api_key.py +19 -0
- janito/cli/cli_commands/show_config.py +51 -0
- janito/cli/cli_commands/show_system_prompt.py +62 -0
- janito/cli/config.py +28 -0
- janito/cli/console.py +3 -0
- janito/cli/core/__init__.py +4 -0
- janito/cli/core/event_logger.py +59 -0
- janito/cli/core/getters.py +31 -0
- janito/cli/core/runner.py +141 -0
- janito/cli/core/setters.py +174 -0
- janito/cli/core/unsetters.py +54 -0
- janito/cli/main.py +8 -196
- janito/cli/main_cli.py +312 -0
- janito/cli/prompt_core.py +230 -0
- janito/cli/prompt_handler.py +6 -0
- janito/cli/rich_terminal_reporter.py +101 -0
- janito/cli/single_shot_mode/__init__.py +6 -0
- janito/cli/single_shot_mode/handler.py +137 -0
- janito/cli/termweb_starter.py +73 -24
- janito/cli/utils.py +25 -0
- janito/cli/verbose_output.py +196 -0
- janito/config.py +5 -0
- janito/config_manager.py +110 -0
- janito/conversation_history.py +30 -0
- janito/{agent/tools_utils/dir_walk_utils.py → dir_walk_utils.py} +3 -2
- janito/driver_events.py +98 -0
- janito/drivers/anthropic/driver.py +113 -0
- janito/drivers/azure_openai/driver.py +36 -0
- janito/drivers/driver_registry.py +33 -0
- janito/drivers/google_genai/driver.py +54 -0
- janito/drivers/google_genai/schema_generator.py +67 -0
- janito/drivers/mistralai/driver.py +41 -0
- janito/drivers/openai/driver.py +334 -0
- janito/event_bus/__init__.py +2 -0
- janito/event_bus/bus.py +68 -0
- janito/event_bus/event.py +15 -0
- janito/event_bus/handler.py +31 -0
- janito/event_bus/queue_bus.py +57 -0
- janito/exceptions.py +23 -0
- janito/formatting_token.py +54 -0
- janito/i18n/pt.py +1 -0
- janito/llm/__init__.py +5 -0
- janito/llm/agent.py +443 -0
- janito/llm/auth.py +62 -0
- janito/llm/driver.py +239 -0
- janito/llm/driver_config.py +34 -0
- janito/llm/driver_config_builder.py +34 -0
- janito/llm/driver_input.py +12 -0
- janito/llm/message_parts.py +60 -0
- janito/llm/model.py +38 -0
- janito/llm/provider.py +187 -0
- janito/perf_singleton.py +3 -0
- janito/performance_collector.py +167 -0
- janito/provider_config.py +98 -0
- janito/provider_registry.py +152 -0
- janito/providers/__init__.py +7 -0
- janito/providers/anthropic/model_info.py +22 -0
- janito/providers/anthropic/provider.py +65 -0
- janito/providers/azure_openai/model_info.py +15 -0
- janito/providers/azure_openai/provider.py +72 -0
- janito/providers/deepseek/__init__.py +1 -0
- janito/providers/deepseek/model_info.py +16 -0
- janito/providers/deepseek/provider.py +91 -0
- janito/providers/google/__init__.py +1 -0
- janito/providers/google/model_info.py +40 -0
- janito/providers/google/provider.py +69 -0
- janito/providers/mistralai/model_info.py +37 -0
- janito/providers/mistralai/provider.py +69 -0
- janito/providers/openai/__init__.py +1 -0
- janito/providers/openai/model_info.py +137 -0
- janito/providers/openai/provider.py +107 -0
- janito/providers/openai/schema_generator.py +63 -0
- janito/providers/provider_static_info.py +21 -0
- janito/providers/registry.py +26 -0
- janito/report_events.py +38 -0
- janito/termweb/app.py +1 -1
- janito/tools/__init__.py +16 -0
- janito/tools/adapters/__init__.py +1 -0
- janito/tools/adapters/local/__init__.py +54 -0
- janito/tools/adapters/local/adapter.py +92 -0
- janito/{agent/tools → tools/adapters/local}/ask_user.py +30 -13
- janito/tools/adapters/local/copy_file.py +84 -0
- janito/{agent/tools → tools/adapters/local}/create_directory.py +11 -10
- janito/tools/adapters/local/create_file.py +82 -0
- janito/tools/adapters/local/delete_text_in_file.py +136 -0
- janito/{agent/tools → tools/adapters/local}/fetch_url.py +18 -19
- janito/tools/adapters/local/find_files.py +140 -0
- janito/tools/adapters/local/get_file_outline/core.py +151 -0
- janito/{agent/tools → tools/adapters/local}/get_file_outline/python_outline.py +125 -0
- janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -0
- janito/{agent/tools → tools/adapters/local}/get_file_outline/search_outline.py +12 -7
- janito/{agent/tools → tools/adapters/local}/move_file.py +13 -9
- janito/{agent/tools → tools/adapters/local}/open_url.py +7 -5
- janito/tools/adapters/local/python_code_run.py +165 -0
- janito/tools/adapters/local/python_command_run.py +163 -0
- janito/tools/adapters/local/python_file_run.py +162 -0
- janito/{agent/tools → tools/adapters/local}/remove_directory.py +15 -9
- janito/{agent/tools → tools/adapters/local}/remove_file.py +17 -14
- janito/{agent/tools → tools/adapters/local}/replace_text_in_file.py +27 -22
- janito/tools/adapters/local/run_bash_command.py +176 -0
- janito/tools/adapters/local/run_powershell_command.py +219 -0
- janito/{agent/tools → tools/adapters/local}/search_text/core.py +32 -12
- janito/{agent/tools → tools/adapters/local}/search_text/match_lines.py +13 -4
- janito/{agent/tools → tools/adapters/local}/search_text/pattern_utils.py +12 -4
- janito/{agent/tools → tools/adapters/local}/search_text/traverse_directory.py +15 -2
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/core.py +12 -11
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/css_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/html_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/js_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/json_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/markdown_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/ps1_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/python_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/xml_validator.py +1 -1
- janito/{agent/tools → tools/adapters/local}/validate_file_syntax/yaml_validator.py +1 -1
- janito/{agent/tools/get_lines.py → tools/adapters/local/view_file.py} +45 -27
- janito/tools/inspect_registry.py +17 -0
- janito/tools/tool_base.py +105 -0
- janito/tools/tool_events.py +58 -0
- janito/tools/tool_run_exception.py +12 -0
- janito/{agent → tools}/tool_use_tracker.py +2 -4
- janito/{agent/tools_utils/utils.py → tools/tool_utils.py} +18 -9
- janito/tools/tools_adapter.py +207 -0
- janito/tools/tools_schema.py +104 -0
- janito/utils.py +11 -0
- janito/version.py +4 -0
- janito-2.0.0.dist-info/METADATA +232 -0
- janito-2.0.0.dist-info/RECORD +180 -0
- janito/agent/__init__.py +0 -0
- janito/agent/api_exceptions.py +0 -4
- janito/agent/config.py +0 -147
- janito/agent/config_defaults.py +0 -12
- janito/agent/config_utils.py +0 -0
- janito/agent/content_handler.py +0 -0
- janito/agent/conversation.py +0 -238
- janito/agent/conversation_api.py +0 -306
- janito/agent/conversation_exceptions.py +0 -18
- janito/agent/conversation_tool_calls.py +0 -39
- janito/agent/conversation_ui.py +0 -17
- janito/agent/event.py +0 -24
- janito/agent/event_dispatcher.py +0 -24
- janito/agent/event_handler_protocol.py +0 -5
- janito/agent/event_system.py +0 -15
- janito/agent/llm_conversation_history.py +0 -82
- janito/agent/message_handler.py +0 -20
- janito/agent/message_handler_protocol.py +0 -5
- janito/agent/openai_client.py +0 -149
- janito/agent/openai_schema_generator.py +0 -187
- janito/agent/profile_manager.py +0 -96
- janito/agent/queued_message_handler.py +0 -50
- janito/agent/rich_live.py +0 -32
- janito/agent/rich_message_handler.py +0 -115
- janito/agent/runtime_config.py +0 -36
- janito/agent/test_handler_protocols.py +0 -47
- janito/agent/test_openai_schema_generator.py +0 -93
- janito/agent/tests/__init__.py +0 -1
- janito/agent/tool_base.py +0 -63
- janito/agent/tool_executor.py +0 -122
- janito/agent/tool_registry.py +0 -49
- janito/agent/tools/__init__.py +0 -47
- janito/agent/tools/create_file.py +0 -59
- janito/agent/tools/delete_text_in_file.py +0 -97
- janito/agent/tools/find_files.py +0 -106
- janito/agent/tools/get_file_outline/core.py +0 -81
- janito/agent/tools/present_choices.py +0 -64
- janito/agent/tools/python_command_runner.py +0 -201
- janito/agent/tools/python_file_runner.py +0 -199
- janito/agent/tools/python_stdin_runner.py +0 -208
- janito/agent/tools/replace_file.py +0 -72
- janito/agent/tools/run_bash_command.py +0 -218
- janito/agent/tools/run_powershell_command.py +0 -251
- janito/agent/tools_utils/__init__.py +0 -1
- janito/agent/tools_utils/action_type.py +0 -7
- janito/agent/tools_utils/test_gitignore_utils.py +0 -46
- janito/cli/_livereload_log_utils.py +0 -13
- janito/cli/_print_config.py +0 -96
- janito/cli/_termweb_log_utils.py +0 -17
- janito/cli/_utils.py +0 -9
- janito/cli/arg_parser.py +0 -272
- janito/cli/cli_main.py +0 -281
- janito/cli/config_commands.py +0 -211
- janito/cli/config_runner.py +0 -35
- janito/cli/formatting_runner.py +0 -12
- janito/cli/livereload_starter.py +0 -60
- janito/cli/logging_setup.py +0 -38
- janito/cli/one_shot.py +0 -80
- janito/livereload/app.py +0 -25
- janito/rich_utils.py +0 -59
- janito/shell/__init__.py +0 -0
- janito/shell/commands/__init__.py +0 -61
- janito/shell/commands/config.py +0 -22
- janito/shell/commands/edit.py +0 -24
- janito/shell/commands/history_view.py +0 -18
- janito/shell/commands/lang.py +0 -19
- janito/shell/commands/livelogs.py +0 -42
- janito/shell/commands/prompt.py +0 -62
- janito/shell/commands/termweb_log.py +0 -94
- janito/shell/commands/tools.py +0 -26
- janito/shell/commands/track.py +0 -36
- janito/shell/main.py +0 -326
- janito/shell/prompt/load_prompt.py +0 -57
- janito/shell/prompt/session_setup.py +0 -57
- janito/shell/session/config.py +0 -109
- janito/shell/session/history.py +0 -0
- janito/shell/ui/interactive.py +0 -226
- janito/termweb/static/editor.css +0 -158
- janito/termweb/static/editor.css.bak +0 -145
- janito/termweb/static/editor.html +0 -46
- janito/termweb/static/editor.html.bak +0 -46
- janito/termweb/static/editor.js +0 -265
- janito/termweb/static/editor.js.bak +0 -259
- janito/termweb/static/explorer.html.bak +0 -59
- janito/termweb/static/favicon.ico +0 -0
- janito/termweb/static/favicon.ico.bak +0 -0
- janito/termweb/static/index.html +0 -53
- janito/termweb/static/index.html.bak +0 -54
- janito/termweb/static/index.html.bak.bak +0 -175
- janito/termweb/static/landing.html.bak +0 -36
- janito/termweb/static/termicon.svg +0 -1
- janito/termweb/static/termweb.css +0 -214
- janito/termweb/static/termweb.css.bak +0 -237
- janito/termweb/static/termweb.js +0 -162
- janito/termweb/static/termweb.js.bak +0 -168
- janito/termweb/static/termweb.js.bak.bak +0 -157
- janito/termweb/static/termweb_quickopen.js +0 -135
- janito/termweb/static/termweb_quickopen.js.bak +0 -125
- janito/tests/test_rich_utils.py +0 -44
- janito/web/__init__.py +0 -0
- janito/web/__main__.py +0 -25
- janito/web/app.py +0 -145
- janito-1.14.2.dist-info/METADATA +0 -306
- janito-1.14.2.dist-info/RECORD +0 -162
- janito-1.14.2.dist-info/licenses/LICENSE +0 -21
- /janito/{shell → cli/chat_mode/shell}/input_history.py +0 -0
- /janito/{shell/commands/session.py → cli/chat_mode/shell/session/history.py} +0 -0
- /janito/{agent/tools_utils/formatting.py → formatting.py} +0 -0
- /janito/{agent/tools_utils/gitignore_utils.py → gitignore_utils.py} +0 -0
- /janito/{agent/platform_discovery.py → platform_discovery.py} +0 -0
- /janito/{agent/tools → tools/adapters/local}/get_file_outline/__init__.py +0 -0
- /janito/{agent/tools → tools/adapters/local}/get_file_outline/markdown_outline.py +0 -0
- /janito/{agent/tools → tools/adapters/local}/search_text/__init__.py +0 -0
- /janito/{agent/tools → tools/adapters/local}/validate_file_syntax/__init__.py +0 -0
- {janito-1.14.2.dist-info → janito-2.0.0.dist-info}/WHEEL +0 -0
- {janito-1.14.2.dist-info → janito-2.0.0.dist-info}/entry_points.txt +0 -0
- {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
|
-
}
|
janito/termweb/static/termweb.js
DELETED
@@ -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 {'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[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 {'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[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;
|