Allow `eca_shell_command` run in dirs outside workspace safely
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
We should allow some safe commands to run outside workspace root, this will enhance LLM capabilities, but we should block destructive commands somehow
@zikajk wondering if your suggestion of plan improvements would help here:
(def ^:private plan-safe-commands-default
#{"git" "ls" "find" "grep" "rg" "ag" "cat" "head" "tail"
"pwd" "which" "file" "stat" "tree" "date" "whoami"
"env" "echo" "wc" "du" "df"})
(def ^:private plan-forbidden-patterns-default
[#">" ; output redirection
#"\|\s*(tee|dd|xargs)" ; dangerous pipes
#"\b(sed|awk|perl)\s+.*-i" ; in-place editing
#"\b(rm|mv|cp|touch|mkdir)\b" ; file operations
#"git\s+(add|commit|push)" ; git mutations
#"npm\s+install" ; package installs
#"-c\s+[\"'].*open.*[\"']w[\"']" ; programmatic writes
#"bash.*-c.*>"]) ; nested shell redirects
Also, we already have working_directory arg in the tool call that LLM can pass, we just currently block it.
I believe we could have some kind of approval-fn in the tool which we decise if we should require manual approve if not in the settings? this would allow us to require manual approve if the working_directory is outside workspace.
c/c @r0man
I don't think this exact code will be needed. My idea is that if none of us has the experience that it has tried to edit something in plan mode, we will delete it / refactor it to allowed patterns.
The user would define in their own behavior which patterns the bash tool can run. But so far, I have no idea what the universal ones for plan mode should be, and as I said, the prompt might be enough.
But as for this topic, sometimes I want bash to edit something in another folder, so I definitely wouldn't prohibit it. I would start by making sure such calls always require confirmation. Later, we can also offer something like auto-approval for the directory (which would be remembered for a project).
Makes sense. I believe requiring manual approval for outside workspace folder calls is enough for now too