Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion trae_agent/tools/edit_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
# This modified file is released under the same license.

import shlex
from pathlib import Path
from typing import override

Expand Down Expand Up @@ -159,7 +160,9 @@ async def _view(self, path: Path, view_range: list[int] | None = None) -> ToolEx
"The `view_range` parameter is not allowed when `path` points to a directory."
)

return_code, stdout, stderr = await run(rf"find {path} -maxdepth 2 -not -path '*/\.*'")
return_code, stdout, stderr = await run(
rf"find {shlex.quote(str(path))} -maxdepth 2 -not -path '*/\.*'"
)
if not stderr:
stdout = f"Here's the files and directories up to 2 levels deep in {path}, excluding hidden items:\n{stdout}\n"
return ToolExecResult(error_code=return_code, output=stdout, error=stderr)
Expand Down