Closed VictorBargains closed 2 weeks ago
I think this makes a lot of sense to ask and is probably something aider can and/or should handle.
Thanks for trying aider and filing this issue. I agree, this is a nice to have capability and I have ideas for how to implement it.
What are your ideas on how to implement it? I may have done cycles to create a PR.
I'd like to allow the model to return arbitrary shell commands, which aider will recognize and ask the user if they'd like to run them. This is a pretty general capability, which would solve the move/rename issue here but also serve a host of other purposes, like allowing the LLM to offer to install dependencies, run linters, etc. LLMs are quite good at shell.
I'd like to allow the model to return arbitrary shell commands, which aider will recognize and ask the user if they'd like to run them. This is a pretty general capability, which would solve the move/rename issue here but also serve a host of other purposes, like allowing the LLM to offer to install dependencies, run linters, etc. LLMs are quite good at shell.
Yes, LLMs are great at shell. When developing on *Nix or OSX the experience is wonderful. Developing on a windows system, unless you are using WSL, can lead to some tricky situations. I've always used Git Bash on windows and it's my preferred terminal in VSCode, and there are a few very particular cases that come up almost every time I have an LLM write a shell script for me:
bash ./script.sh
instead of ./script.sh
if you know it's a bash fileWindows paths beginning with C:\ will be under /c/ within the gitbash filesystem, so any shell commands run that reference paths from the output of a program (like python -m site -user-base
) or an env variable (like PYTHONUSERBASE
) will be working with windows paths, not unix paths, so an if [[ -x $PYTHONUSERBASE ]]
will always return false unless you translate the path:
convert_windows_path_to_unix() {
local path="$1"
if [[ -n "$MINGW_PREFIX" ]]; then
path=$(echo "$path" | sed 's/\\/\//g')
path=$(echo "$path" | sed 's/^\([A-Za-z]\):/\/\L\1/')
fi
echo "$path"
}
# windows C:\backslash to unix /c/forward slash path conversion
echo "Checking $directory..."
if [[ "$directory" =~ ^[A-Za-z]: ]]; then
directory=$(convert_windows_path_to_unix "$directory")
fi
The LLM does not understand this layer, and will 99% of the time write broken shell code under git bash and then flail and die changing the wrong code 100 times until you finally step in and say "this is running under git bash in windows, so you need to convert the file paths" and it still might get half of it wrong because it's really not trained on this layer of platform compatibility.
I would strongly advise, similar to how you detect the vscode terminal and adjust output appropriately, that you detect the git bash environment (or more generally any env like MINGW where this may be a *nix system on top of windows -- is cygwin still a thing?) and make sure this is a thing you handle at the prompt engineering layer.
$ env|grep MINGW MINGW_PREFIX=C:/Program Files/Git/mingw64 MSYSTEM=MINGW64 MINGW_CHOST=x86_64-w64-mingw32 MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
Yes, I was planning to sniff the OS/shell environment and prompt accordingly. I'll see if I can make this general enough to handle git bash too. I was also planning to provide a manual config, where you can explicitly specify what shell environment the LLM should target,
may I suggest reviewing https://github.com/OpenInterpreter/open-interpreter -- it is actually somewhat similar to Aider, but aimed specifically at shell command generation and execution.
The change is available in the main branch. You can get it by installing the latest version from github:
python -m pip install --upgrade git+https://github.com/paul-gauthier/aider.git
If you have a chance to try it, let me know if it works better for you.
The change is available in the main branch. You can get it by installing the latest version from github:
python -m pip install --upgrade git+https://github.com/paul-gauthier/aider.git
If you have a chance to try it, let me know if it works better for you.
Works perfectly thank you
I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.
Amazing work!
Sent from my iPhone
From: paul-gauthier @.> Sent: Monday, August 26, 2024 6:04 PM To: paul-gauthier/aider @.> Cc: Subscribed @.***> Subject: Re: [paul-gauthier/aider] Allow the LLM to rename/move files/directories and run other shell commands (Issue #528)
Closed #528https://github.com/paul-gauthier/aider/issues/528 as completed.
— Reply to this email directly, view it on GitHubhttps://github.com/paul-gauthier/aider/issues/528#event-14019580591, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJ65MRUEODV7MD42DXDKHATZTOQ6JAVCNFSM6AAAAABFPZFE4CVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGAYTSNJYGA2TSMI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Is there any plan to make aider capable of performing more of the local file maintenance tasks required during development, of moving and renaming files and folders?
Or is this the kind of thing best left to a layer like langgraph or autogen with tools that wrap around aider?
RIght now my experiences go something like this, and sometimes crash when I ask it to move a file.