janito 1.14.3__py3-none-any.whl → 2.0.1__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/tools/adapters/local/open_html_in_browser.py +34 -0
- 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.1.dist-info/METADATA +232 -0
- janito-2.0.1.dist-info/RECORD +181 -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.3.dist-info/METADATA +0 -313
- janito-1.14.3.dist-info/RECORD +0 -162
- janito-1.14.3.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.3.dist-info → janito-2.0.1.dist-info}/WHEEL +0 -0
- {janito-1.14.3.dist-info → janito-2.0.1.dist-info}/entry_points.txt +0 -0
- {janito-1.14.3.dist-info → janito-2.0.1.dist-info}/top_level.txt +0 -0
@@ -1,218 +0,0 @@
|
|
1
|
-
from janito.agent.tool_base import ToolBase
|
2
|
-
from janito.agent.tools_utils.action_type import ActionType
|
3
|
-
from janito.agent.tool_registry import register_tool
|
4
|
-
from janito.i18n import tr
|
5
|
-
import subprocess
|
6
|
-
import tempfile
|
7
|
-
import sys
|
8
|
-
import os
|
9
|
-
import threading
|
10
|
-
from janito.agent.runtime_config import runtime_config
|
11
|
-
|
12
|
-
|
13
|
-
@register_tool(name="run_bash_command")
|
14
|
-
class RunBashCommandTool(ToolBase):
|
15
|
-
"""
|
16
|
-
Execute a non-interactive command using the bash shell and capture live output.
|
17
|
-
This tool explicitly invokes the 'bash' shell (not just the system default shell), so it requires bash to be installed and available in the system PATH. On Windows, this will only work if bash is available (e.g., via WSL, Git Bash, or similar).
|
18
|
-
Args:
|
19
|
-
command (str): The bash command to execute.
|
20
|
-
timeout (int, optional): Timeout in seconds for the command. Defaults to 60.
|
21
|
-
require_confirmation (bool, optional): If True, require user confirmation before running. Defaults to False.
|
22
|
-
requires_user_input (bool, optional): If True, warns that the command may require user input and might hang. Defaults to False. Non-interactive commands are preferred for automation and reliability.
|
23
|
-
Returns:
|
24
|
-
str: File paths and line counts for stdout and stderr.
|
25
|
-
"""
|
26
|
-
|
27
|
-
def _stream_output(
|
28
|
-
self,
|
29
|
-
stream,
|
30
|
-
report_func,
|
31
|
-
accum=None,
|
32
|
-
file_obj=None,
|
33
|
-
count_func=None,
|
34
|
-
counter=None,
|
35
|
-
):
|
36
|
-
for line in stream:
|
37
|
-
if accum is not None:
|
38
|
-
accum.append(line)
|
39
|
-
if file_obj is not None:
|
40
|
-
file_obj.write(line)
|
41
|
-
file_obj.flush()
|
42
|
-
report_func(line)
|
43
|
-
if counter is not None and count_func is not None:
|
44
|
-
counter[count_func] += 1
|
45
|
-
|
46
|
-
def _handle_all_out(self, process, timeout):
|
47
|
-
stdout_accum = []
|
48
|
-
stderr_accum = []
|
49
|
-
stdout_thread = threading.Thread(
|
50
|
-
target=self._stream_output,
|
51
|
-
args=(process.stdout, self.report_stdout, stdout_accum),
|
52
|
-
)
|
53
|
-
stderr_thread = threading.Thread(
|
54
|
-
target=self._stream_output,
|
55
|
-
args=(process.stderr, self.report_stderr, stderr_accum),
|
56
|
-
)
|
57
|
-
stdout_thread.start()
|
58
|
-
stderr_thread.start()
|
59
|
-
try:
|
60
|
-
return_code = process.wait(timeout=timeout)
|
61
|
-
except subprocess.TimeoutExpired:
|
62
|
-
process.kill()
|
63
|
-
self.report_error(
|
64
|
-
tr(" ❌ Timed out after {timeout} seconds.", timeout=timeout)
|
65
|
-
)
|
66
|
-
return tr("Command timed out after {timeout} seconds.", timeout=timeout)
|
67
|
-
stdout_thread.join()
|
68
|
-
stderr_thread.join()
|
69
|
-
self.report_success(
|
70
|
-
tr(" ✅ return code {return_code}", return_code=return_code)
|
71
|
-
)
|
72
|
-
stdout_content = "".join(stdout_accum)
|
73
|
-
stderr_content = "".join(stderr_accum)
|
74
|
-
result = tr(
|
75
|
-
"Return code: {return_code}\n--- STDOUT ---\n{stdout_content}",
|
76
|
-
return_code=return_code,
|
77
|
-
stdout_content=stdout_content,
|
78
|
-
)
|
79
|
-
if stderr_content.strip():
|
80
|
-
result += tr(
|
81
|
-
"\n--- STDERR ---\n{stderr_content}", stderr_content=stderr_content
|
82
|
-
)
|
83
|
-
return result
|
84
|
-
|
85
|
-
def _handle_file_out(self, process, timeout):
|
86
|
-
max_lines = 100
|
87
|
-
with (
|
88
|
-
tempfile.NamedTemporaryFile(
|
89
|
-
mode="w+",
|
90
|
-
prefix="run_bash_stdout_",
|
91
|
-
delete=False,
|
92
|
-
encoding="utf-8",
|
93
|
-
) as stdout_file,
|
94
|
-
tempfile.NamedTemporaryFile(
|
95
|
-
mode="w+",
|
96
|
-
prefix="run_bash_stderr_",
|
97
|
-
delete=False,
|
98
|
-
encoding="utf-8",
|
99
|
-
) as stderr_file,
|
100
|
-
):
|
101
|
-
counter = {"stdout": 0, "stderr": 0}
|
102
|
-
stdout_thread = threading.Thread(
|
103
|
-
target=self._stream_output,
|
104
|
-
args=(
|
105
|
-
process.stdout,
|
106
|
-
self.report_stdout,
|
107
|
-
None,
|
108
|
-
stdout_file,
|
109
|
-
"stdout",
|
110
|
-
counter,
|
111
|
-
),
|
112
|
-
)
|
113
|
-
stderr_thread = threading.Thread(
|
114
|
-
target=self._stream_output,
|
115
|
-
args=(
|
116
|
-
process.stderr,
|
117
|
-
self.report_stderr,
|
118
|
-
None,
|
119
|
-
stderr_file,
|
120
|
-
"stderr",
|
121
|
-
counter,
|
122
|
-
),
|
123
|
-
)
|
124
|
-
stdout_thread.start()
|
125
|
-
stderr_thread.start()
|
126
|
-
try:
|
127
|
-
return_code = process.wait(timeout=timeout)
|
128
|
-
except subprocess.TimeoutExpired:
|
129
|
-
process.kill()
|
130
|
-
self.report_error(
|
131
|
-
tr(" ❌ Timed out after {timeout} seconds.", timeout=timeout)
|
132
|
-
)
|
133
|
-
return tr("Command timed out after {timeout} seconds.", timeout=timeout)
|
134
|
-
stdout_thread.join()
|
135
|
-
stderr_thread.join()
|
136
|
-
stdout_file.flush()
|
137
|
-
stderr_file.flush()
|
138
|
-
self.report_success(
|
139
|
-
tr(" ✅ return code {return_code}", return_code=return_code)
|
140
|
-
)
|
141
|
-
stdout_file.seek(0)
|
142
|
-
stderr_file.seek(0)
|
143
|
-
stdout_content = stdout_file.read()
|
144
|
-
stderr_content = stderr_file.read()
|
145
|
-
stdout_lines = stdout_content.count("\n")
|
146
|
-
stderr_lines = stderr_content.count("\n")
|
147
|
-
if stdout_lines <= max_lines and stderr_lines <= max_lines:
|
148
|
-
result = tr(
|
149
|
-
"Return code: {return_code}\n--- STDOUT ---\n{stdout_content}",
|
150
|
-
return_code=return_code,
|
151
|
-
stdout_content=stdout_content,
|
152
|
-
)
|
153
|
-
if stderr_content.strip():
|
154
|
-
result += tr(
|
155
|
-
"\n--- STDERR ---\n{stderr_content}",
|
156
|
-
stderr_content=stderr_content,
|
157
|
-
)
|
158
|
-
return result
|
159
|
-
else:
|
160
|
-
result = tr(
|
161
|
-
"[LARGE OUTPUT]\nstdout_file: {stdout_file} (lines: {stdout_lines})\n",
|
162
|
-
stdout_file=stdout_file.name,
|
163
|
-
stdout_lines=stdout_lines,
|
164
|
-
)
|
165
|
-
if stderr_lines > 0:
|
166
|
-
result += tr(
|
167
|
-
"stderr_file: {stderr_file} (lines: {stderr_lines})\n",
|
168
|
-
stderr_file=stderr_file.name,
|
169
|
-
stderr_lines=stderr_lines,
|
170
|
-
)
|
171
|
-
result += tr(
|
172
|
-
"returncode: {return_code}\nUse the get_lines tool to inspect the contents of these files when needed.",
|
173
|
-
return_code=return_code,
|
174
|
-
)
|
175
|
-
return result
|
176
|
-
|
177
|
-
def run(
|
178
|
-
self,
|
179
|
-
command: str,
|
180
|
-
timeout: int = 60,
|
181
|
-
require_confirmation: bool = False,
|
182
|
-
requires_user_input: bool = False,
|
183
|
-
) -> str:
|
184
|
-
if not command.strip():
|
185
|
-
self.report_warning(tr("ℹ️ Empty command provided."))
|
186
|
-
return tr("Warning: Empty command provided. Operation skipped.")
|
187
|
-
self.report_info(
|
188
|
-
ActionType.EXECUTE,
|
189
|
-
tr("🖥️ Run bash command: {command} ...\n", command=command),
|
190
|
-
)
|
191
|
-
if requires_user_input:
|
192
|
-
self.report_warning(
|
193
|
-
tr(
|
194
|
-
"⚠️ Warning: This command might be interactive, require user input, and might hang."
|
195
|
-
)
|
196
|
-
)
|
197
|
-
sys.stdout.flush()
|
198
|
-
try:
|
199
|
-
env = os.environ.copy()
|
200
|
-
env["PYTHONIOENCODING"] = "utf-8"
|
201
|
-
env["LC_ALL"] = "C.UTF-8"
|
202
|
-
env["LANG"] = "C.UTF-8"
|
203
|
-
process = subprocess.Popen(
|
204
|
-
["bash", "-c", command],
|
205
|
-
stdout=subprocess.PIPE,
|
206
|
-
stderr=subprocess.PIPE,
|
207
|
-
text=True,
|
208
|
-
encoding="utf-8",
|
209
|
-
bufsize=1,
|
210
|
-
env=env,
|
211
|
-
)
|
212
|
-
if runtime_config.get("all_out"):
|
213
|
-
return self._handle_all_out(process, timeout)
|
214
|
-
else:
|
215
|
-
return self._handle_file_out(process, timeout)
|
216
|
-
except Exception as e:
|
217
|
-
self.report_error(tr(" ❌ Error: {error}", error=e))
|
218
|
-
return tr("Error running command: {error}", error=e)
|
@@ -1,251 +0,0 @@
|
|
1
|
-
from janito.agent.tool_base import ToolBase
|
2
|
-
from janito.agent.tools_utils.action_type import ActionType
|
3
|
-
from janito.agent.tool_registry import register_tool
|
4
|
-
from janito.i18n import tr
|
5
|
-
import subprocess
|
6
|
-
import os
|
7
|
-
import tempfile
|
8
|
-
import threading
|
9
|
-
from janito.agent.runtime_config import runtime_config
|
10
|
-
|
11
|
-
|
12
|
-
@register_tool(name="run_powershell_command")
|
13
|
-
class RunPowerShellCommandTool(ToolBase):
|
14
|
-
"""
|
15
|
-
Execute a non-interactive command using the PowerShell shell and capture live output.
|
16
|
-
This tool explicitly invokes 'powershell.exe' (on Windows) or 'pwsh' (on other platforms if available).
|
17
|
-
All commands are automatically prepended with UTF-8 output encoding:
|
18
|
-
$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
|
19
|
-
For file output, it is recommended to use -Encoding utf8 in your PowerShell commands (e.g., Out-File -Encoding utf8) to ensure correct file encoding.
|
20
|
-
Args:
|
21
|
-
command (str): The PowerShell command to execute. This string is passed directly to PowerShell using the --Command argument (not as a script file).
|
22
|
-
timeout (int, optional): Timeout in seconds for the command. Defaults to 60.
|
23
|
-
require_confirmation (bool, optional): If True, require user confirmation before running. Defaults to False.
|
24
|
-
requires_user_input (bool, optional): If True, warns that the command may require user input and might hang. Defaults to False. Non-interactive commands are preferred for automation and reliability.
|
25
|
-
Returns:
|
26
|
-
str: Output and status message, or file paths/line counts if output is large.
|
27
|
-
"""
|
28
|
-
|
29
|
-
def _confirm_and_warn(self, command, require_confirmation, requires_user_input):
|
30
|
-
if requires_user_input:
|
31
|
-
self.report_warning(
|
32
|
-
tr(
|
33
|
-
"⚠️ Warning: This command might be interactive, require user input, and might hang."
|
34
|
-
)
|
35
|
-
)
|
36
|
-
if require_confirmation:
|
37
|
-
confirmed = self.ask_user_confirmation(
|
38
|
-
tr(
|
39
|
-
"About to run PowerShell command: {command}\nContinue?",
|
40
|
-
command=command,
|
41
|
-
)
|
42
|
-
)
|
43
|
-
if not confirmed:
|
44
|
-
self.report_warning(tr("⚠️ Execution cancelled by user."))
|
45
|
-
return False
|
46
|
-
return True
|
47
|
-
|
48
|
-
def _launch_process(self, shell_exe, command_with_encoding):
|
49
|
-
env = os.environ.copy()
|
50
|
-
env["PYTHONIOENCODING"] = "utf-8"
|
51
|
-
return subprocess.Popen(
|
52
|
-
[
|
53
|
-
shell_exe,
|
54
|
-
"-NoProfile",
|
55
|
-
"-ExecutionPolicy",
|
56
|
-
"Bypass",
|
57
|
-
"-Command",
|
58
|
-
command_with_encoding,
|
59
|
-
],
|
60
|
-
stdout=subprocess.PIPE,
|
61
|
-
stderr=subprocess.PIPE,
|
62
|
-
text=True,
|
63
|
-
bufsize=1,
|
64
|
-
universal_newlines=True,
|
65
|
-
encoding="utf-8",
|
66
|
-
env=env,
|
67
|
-
)
|
68
|
-
|
69
|
-
def _stream_output(
|
70
|
-
self,
|
71
|
-
stream,
|
72
|
-
report_func,
|
73
|
-
accum=None,
|
74
|
-
file_obj=None,
|
75
|
-
count_func=None,
|
76
|
-
counter=None,
|
77
|
-
):
|
78
|
-
for line in stream:
|
79
|
-
if accum is not None:
|
80
|
-
accum.append(line)
|
81
|
-
if file_obj is not None:
|
82
|
-
file_obj.write(line)
|
83
|
-
file_obj.flush()
|
84
|
-
report_func(line)
|
85
|
-
if counter is not None and count_func is not None:
|
86
|
-
counter[count_func] += 1
|
87
|
-
|
88
|
-
def _handle_all_out(self, process, timeout):
|
89
|
-
stdout_accum = []
|
90
|
-
stderr_accum = []
|
91
|
-
stdout_thread = threading.Thread(
|
92
|
-
target=self._stream_output,
|
93
|
-
args=(process.stdout, self.report_stdout, stdout_accum),
|
94
|
-
)
|
95
|
-
stderr_thread = threading.Thread(
|
96
|
-
target=self._stream_output,
|
97
|
-
args=(process.stderr, self.report_stderr, stderr_accum),
|
98
|
-
)
|
99
|
-
stdout_thread.start()
|
100
|
-
stderr_thread.start()
|
101
|
-
try:
|
102
|
-
return_code = process.wait(timeout=timeout)
|
103
|
-
except subprocess.TimeoutExpired:
|
104
|
-
process.kill()
|
105
|
-
self.report_error(
|
106
|
-
tr(" ❌ Timed out after {timeout} seconds.", timeout=timeout)
|
107
|
-
)
|
108
|
-
return tr("Command timed out after {timeout} seconds.", timeout=timeout)
|
109
|
-
stdout_thread.join()
|
110
|
-
stderr_thread.join()
|
111
|
-
self.report_success(
|
112
|
-
tr(" ✅ return code {return_code}", return_code=return_code)
|
113
|
-
)
|
114
|
-
stdout = "".join(stdout_accum)
|
115
|
-
stderr = "".join(stderr_accum)
|
116
|
-
result = f"Return code: {return_code}\n--- STDOUT ---\n{stdout}"
|
117
|
-
if stderr and stderr.strip():
|
118
|
-
result += f"\n--- STDERR ---\n{stderr}"
|
119
|
-
return result
|
120
|
-
|
121
|
-
def _handle_file_out(self, process, timeout):
|
122
|
-
with (
|
123
|
-
tempfile.NamedTemporaryFile(
|
124
|
-
mode="w+",
|
125
|
-
prefix="run_powershell_stdout_",
|
126
|
-
delete=False,
|
127
|
-
encoding="utf-8",
|
128
|
-
) as stdout_file,
|
129
|
-
tempfile.NamedTemporaryFile(
|
130
|
-
mode="w+",
|
131
|
-
prefix="run_powershell_stderr_",
|
132
|
-
delete=False,
|
133
|
-
encoding="utf-8",
|
134
|
-
) as stderr_file,
|
135
|
-
):
|
136
|
-
counter = {"stdout": 0, "stderr": 0}
|
137
|
-
stdout_thread = threading.Thread(
|
138
|
-
target=self._stream_output,
|
139
|
-
args=(
|
140
|
-
process.stdout,
|
141
|
-
self.report_stdout,
|
142
|
-
None,
|
143
|
-
stdout_file,
|
144
|
-
"stdout",
|
145
|
-
counter,
|
146
|
-
),
|
147
|
-
)
|
148
|
-
stderr_thread = threading.Thread(
|
149
|
-
target=self._stream_output,
|
150
|
-
args=(
|
151
|
-
process.stderr,
|
152
|
-
self.report_stderr,
|
153
|
-
None,
|
154
|
-
stderr_file,
|
155
|
-
"stderr",
|
156
|
-
counter,
|
157
|
-
),
|
158
|
-
)
|
159
|
-
stdout_thread.start()
|
160
|
-
stderr_thread.start()
|
161
|
-
try:
|
162
|
-
return_code = process.wait(timeout=timeout)
|
163
|
-
except subprocess.TimeoutExpired:
|
164
|
-
process.kill()
|
165
|
-
self.report_error(
|
166
|
-
tr(" ❌ Timed out after {timeout} seconds.", timeout=timeout)
|
167
|
-
)
|
168
|
-
return tr("Command timed out after {timeout} seconds.", timeout=timeout)
|
169
|
-
stdout_thread.join()
|
170
|
-
stderr_thread.join()
|
171
|
-
stdout_file.flush()
|
172
|
-
stderr_file.flush()
|
173
|
-
self.report_success(
|
174
|
-
tr(" ✅ return code {return_code}", return_code=return_code)
|
175
|
-
)
|
176
|
-
return self._format_result(stdout_file.name, stderr_file.name, return_code)
|
177
|
-
|
178
|
-
def run(
|
179
|
-
self,
|
180
|
-
command: str,
|
181
|
-
timeout: int = 60,
|
182
|
-
require_confirmation: bool = False,
|
183
|
-
requires_user_input: bool = False,
|
184
|
-
) -> str:
|
185
|
-
if not command.strip():
|
186
|
-
self.report_warning(tr("ℹ️ Empty command provided."))
|
187
|
-
return tr("Warning: Empty command provided. Operation skipped.")
|
188
|
-
encoding_prefix = "$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; "
|
189
|
-
command_with_encoding = encoding_prefix + command
|
190
|
-
self.report_info(
|
191
|
-
ActionType.EXECUTE,
|
192
|
-
tr(
|
193
|
-
"🖥️ Running PowerShell command: {command} ...\n",
|
194
|
-
command=command,
|
195
|
-
),
|
196
|
-
)
|
197
|
-
if not self._confirm_and_warn(
|
198
|
-
command, require_confirmation, requires_user_input
|
199
|
-
):
|
200
|
-
return tr("❌ Command execution cancelled by user.")
|
201
|
-
from janito.agent.platform_discovery import PlatformDiscovery
|
202
|
-
|
203
|
-
pd = PlatformDiscovery()
|
204
|
-
shell_exe = "powershell.exe" if pd.is_windows() else "pwsh"
|
205
|
-
try:
|
206
|
-
if runtime_config.get("all_out"):
|
207
|
-
process = self._launch_process(shell_exe, command_with_encoding)
|
208
|
-
return self._handle_all_out(process, timeout)
|
209
|
-
else:
|
210
|
-
process = self._launch_process(shell_exe, command_with_encoding)
|
211
|
-
return self._handle_file_out(process, timeout)
|
212
|
-
except Exception as e:
|
213
|
-
self.report_error(tr(" ❌ Error: {error}", error=e))
|
214
|
-
return tr("Error running command: {error}", error=e)
|
215
|
-
|
216
|
-
def _format_result(self, stdout_file_name, stderr_file_name, return_code):
|
217
|
-
with open(stdout_file_name, "r", encoding="utf-8", errors="replace") as out_f:
|
218
|
-
stdout_content = out_f.read()
|
219
|
-
with open(stderr_file_name, "r", encoding="utf-8", errors="replace") as err_f:
|
220
|
-
stderr_content = err_f.read()
|
221
|
-
max_lines = 100
|
222
|
-
stdout_lines = stdout_content.count("\n")
|
223
|
-
stderr_lines = stderr_content.count("\n")
|
224
|
-
|
225
|
-
def head_tail(text, n=10):
|
226
|
-
lines = text.splitlines()
|
227
|
-
if len(lines) <= 2 * n:
|
228
|
-
return "\n".join(lines)
|
229
|
-
return "\n".join(
|
230
|
-
lines[:n]
|
231
|
-
+ ["... ({} lines omitted) ...".format(len(lines) - 2 * n)]
|
232
|
-
+ lines[-n:]
|
233
|
-
)
|
234
|
-
|
235
|
-
if stdout_lines <= max_lines and stderr_lines <= max_lines:
|
236
|
-
result = f"Return code: {return_code}\n--- STDOUT ---\n{stdout_content}"
|
237
|
-
if stderr_content.strip():
|
238
|
-
result += f"\n--- STDERR ---\n{stderr_content}"
|
239
|
-
return result
|
240
|
-
else:
|
241
|
-
result = f"stdout_file: {stdout_file_name} (lines: {stdout_lines})\n"
|
242
|
-
if stderr_lines > 0 and stderr_content.strip():
|
243
|
-
result += f"stderr_file: {stderr_file_name} (lines: {stderr_lines})\n"
|
244
|
-
result += f"returncode: {return_code}\n"
|
245
|
-
result += "--- STDOUT (head/tail) ---\n" + head_tail(stdout_content) + "\n"
|
246
|
-
if stderr_content.strip():
|
247
|
-
result += (
|
248
|
-
"--- STDERR (head/tail) ---\n" + head_tail(stderr_content) + "\n"
|
249
|
-
)
|
250
|
-
result += "Use the get_lines tool to inspect the contents of these files when needed."
|
251
|
-
return result
|
@@ -1 +0,0 @@
|
|
1
|
-
# tools_utils package init
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import tempfile
|
3
|
-
import shutil
|
4
|
-
import pytest
|
5
|
-
from janito.agent.tools_utils.gitignore_utils import GitignoreFilter
|
6
|
-
|
7
|
-
|
8
|
-
def test_gitignore_filter_basic(tmp_path):
|
9
|
-
# Create a .gitignore file
|
10
|
-
gitignore_content = """
|
11
|
-
ignored_file.txt
|
12
|
-
ignored_dir/
|
13
|
-
*.log
|
14
|
-
"""
|
15
|
-
gitignore_path = tmp_path / ".gitignore"
|
16
|
-
gitignore_path.write_text(gitignore_content)
|
17
|
-
|
18
|
-
# Create files and directories
|
19
|
-
(tmp_path / "ignored_file.txt").write_text("should be ignored")
|
20
|
-
(tmp_path / "not_ignored.txt").write_text("should not be ignored")
|
21
|
-
(tmp_path / "ignored_dir").mkdir()
|
22
|
-
(tmp_path / "ignored_dir" / "file.txt").write_text("should be ignored")
|
23
|
-
(tmp_path / "not_ignored_dir").mkdir()
|
24
|
-
(tmp_path / "not_ignored_dir" / "file.txt").write_text("should not be ignored")
|
25
|
-
(tmp_path / "file.log").write_text("should be ignored")
|
26
|
-
|
27
|
-
gi = GitignoreFilter(str(gitignore_path))
|
28
|
-
|
29
|
-
assert gi.is_ignored(str(tmp_path / "ignored_file.txt"))
|
30
|
-
assert not gi.is_ignored(str(tmp_path / "not_ignored.txt"))
|
31
|
-
# Directory itself is not ignored, only its contents
|
32
|
-
assert not gi.is_ignored(str(tmp_path / "ignored_dir"))
|
33
|
-
assert gi.is_ignored(str(tmp_path / "ignored_dir" / "file.txt"))
|
34
|
-
assert not gi.is_ignored(str(tmp_path / "not_ignored_dir"))
|
35
|
-
assert not gi.is_ignored(str(tmp_path / "not_ignored_dir" / "file.txt"))
|
36
|
-
assert gi.is_ignored(str(tmp_path / "file.log"))
|
37
|
-
|
38
|
-
# Test filter_ignored
|
39
|
-
dirs = ["ignored_dir", "not_ignored_dir"]
|
40
|
-
files = ["ignored_file.txt", "not_ignored.txt", "file.log"]
|
41
|
-
filtered_dirs, filtered_files = gi.filter_ignored(str(tmp_path), dirs, files)
|
42
|
-
assert "ignored_dir" not in filtered_dirs
|
43
|
-
assert "not_ignored_dir" in filtered_dirs
|
44
|
-
assert "ignored_file.txt" not in filtered_files
|
45
|
-
assert "file.log" not in filtered_files
|
46
|
-
assert "not_ignored.txt" in filtered_files
|
@@ -1,13 +0,0 @@
|
|
1
|
-
def print_livereload_logs(stdout_path, stderr_path):
|
2
|
-
print("\n[LiveReload stdout log]")
|
3
|
-
try:
|
4
|
-
with open(stdout_path, encoding="utf-8") as f:
|
5
|
-
print(f.read())
|
6
|
-
except Exception as e:
|
7
|
-
print(f"[Error reading stdout log: {e}]")
|
8
|
-
print("\n[LiveReload stderr log]")
|
9
|
-
try:
|
10
|
-
with open(stderr_path, encoding="utf-8") as f:
|
11
|
-
print(f.read())
|
12
|
-
except Exception as e:
|
13
|
-
print(f"[Error reading stderr log: {e}]")
|
janito/cli/_print_config.py
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from janito.rich_utils import RichPrinter
|
3
|
-
|
4
|
-
_rich_printer = RichPrinter()
|
5
|
-
from ._utils import home_shorten
|
6
|
-
|
7
|
-
|
8
|
-
def print_config_items(items, color_label=None):
|
9
|
-
if not items:
|
10
|
-
return
|
11
|
-
if color_label:
|
12
|
-
_rich_printer.print_info(color_label)
|
13
|
-
home = os.path.expanduser("~")
|
14
|
-
for key, value in items.items():
|
15
|
-
if key == "system_prompt_template" and isinstance(value, str):
|
16
|
-
if value.startswith(home):
|
17
|
-
print(f"{key} = {home_shorten(value)}")
|
18
|
-
else:
|
19
|
-
_rich_printer.print_info(f"{key} = {value}")
|
20
|
-
else:
|
21
|
-
_rich_printer.print_info(f"{key} = {value}")
|
22
|
-
_rich_printer.print_info("")
|
23
|
-
|
24
|
-
|
25
|
-
def _mask_api_key(value):
|
26
|
-
if value and len(value) > 8:
|
27
|
-
return value[:4] + "..." + value[-4:]
|
28
|
-
elif value:
|
29
|
-
return "***"
|
30
|
-
return None
|
31
|
-
|
32
|
-
|
33
|
-
def _collect_config_items(config, unified_config, keys):
|
34
|
-
items = {}
|
35
|
-
for key in sorted(keys):
|
36
|
-
if key == "api_key":
|
37
|
-
value = config.get("api_key")
|
38
|
-
value = _mask_api_key(value)
|
39
|
-
else:
|
40
|
-
value = unified_config.get(key)
|
41
|
-
items[key] = value
|
42
|
-
return items
|
43
|
-
|
44
|
-
|
45
|
-
def _print_defaults(config_defaults, shown_keys):
|
46
|
-
default_items = {
|
47
|
-
k: v
|
48
|
-
for k, v in config_defaults.items()
|
49
|
-
if k not in shown_keys and k != "api_key"
|
50
|
-
}
|
51
|
-
if default_items:
|
52
|
-
_rich_printer.print_magenta(
|
53
|
-
"[green]\U0001f7e2 Defaults (not set in config files)[/green]"
|
54
|
-
)
|
55
|
-
from pathlib import Path
|
56
|
-
|
57
|
-
template_path = (
|
58
|
-
Path(__file__).parent
|
59
|
-
/ "agent"
|
60
|
-
/ "templates"
|
61
|
-
/ "system_prompt_template_default.j2"
|
62
|
-
)
|
63
|
-
for key, value in default_items.items():
|
64
|
-
if key == "system_prompt_template" and value is None:
|
65
|
-
_rich_printer.print_info(
|
66
|
-
f"{key} = (default template path: {home_shorten(str(template_path))})"
|
67
|
-
)
|
68
|
-
else:
|
69
|
-
_rich_printer.print_info(f"{key} = {value}")
|
70
|
-
_rich_printer.print_info("")
|
71
|
-
|
72
|
-
|
73
|
-
def print_full_config(
|
74
|
-
local_config, global_config, unified_config, config_defaults, console=None
|
75
|
-
):
|
76
|
-
"""
|
77
|
-
Print local, global, and default config values in a unified way.
|
78
|
-
Handles masking API keys and showing the template file for system_prompt_template if not set.
|
79
|
-
"""
|
80
|
-
local_keys = set(local_config.all().keys())
|
81
|
-
global_keys = set(global_config.all().keys())
|
82
|
-
if not (local_keys or global_keys):
|
83
|
-
_rich_printer.print_warning("No configuration found.")
|
84
|
-
else:
|
85
|
-
local_items = _collect_config_items(local_config, unified_config, local_keys)
|
86
|
-
global_items = _collect_config_items(
|
87
|
-
global_config, unified_config, global_keys - local_keys
|
88
|
-
)
|
89
|
-
print_config_items(
|
90
|
-
local_items, color_label="[cyan]\U0001f3e0 Local Configuration[/cyan]"
|
91
|
-
)
|
92
|
-
print_config_items(
|
93
|
-
global_items, color_label="[yellow]\U0001f310 Global Configuration[/yellow]"
|
94
|
-
)
|
95
|
-
shown_keys = set(local_items.keys()) | set(global_items.keys())
|
96
|
-
_print_defaults(config_defaults, shown_keys)
|
janito/cli/_termweb_log_utils.py
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
def print_termweb_logs(stdout_path, stderr_path, console):
|
2
|
-
try:
|
3
|
-
with open(stdout_path, encoding="utf-8") as f:
|
4
|
-
stdout_content = f.read().strip()
|
5
|
-
except Exception:
|
6
|
-
stdout_content = None
|
7
|
-
try:
|
8
|
-
with open(stderr_path, encoding="utf-8") as f:
|
9
|
-
stderr_content = f.read().strip()
|
10
|
-
except Exception:
|
11
|
-
stderr_content = None
|
12
|
-
if stdout_content:
|
13
|
-
console.print("[yellow][termweb][stdout] Output:\n" + stdout_content)
|
14
|
-
if stderr_content:
|
15
|
-
console.print("[red][termweb][stderr] Errors:\n" + stderr_content)
|
16
|
-
if not stdout_content and not stderr_content:
|
17
|
-
console.print("[termweb] No output or errors captured in logs.")
|
janito/cli/_utils.py
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
|
3
|
-
|
4
|
-
def home_shorten(path: str) -> str:
|
5
|
-
"""If path starts with the user's home directory, replace it with ~."""
|
6
|
-
home = os.path.expanduser("~")
|
7
|
-
if path and isinstance(path, str) and path.startswith(home):
|
8
|
-
return path.replace(home, "~", 1)
|
9
|
-
return path
|