paul-gauthier / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
18.04k stars 1.69k forks source link

Allow the LLM to rename/move files/directories and run other shell commands #528

Closed VictorBargains closed 2 weeks ago

VictorBargains commented 5 months ago

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.

$ aider DESIGN.md
Aider v0.27.0
Model: gpt-4-1106-preview using udiff edit format
Git repo: ..\..\..\.git with 32 files
Repo-map: using 1024 tokens
Added filesystem\find\up\DESIGN.md to the chat.
Use /help to see in-chat commands, run with --help to see cmd line args
Note: in-chat filenames are always relative to the git working dir, not the current working dir.
Cur working dir: C:\Users\victorb\code\ai-sdlc\filesystem\find\up
Git working dir: C:\Users\victorb\code\ai-sdlc
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
filesystem\find\up\DESIGN.md
> Please write a find-up.sh file in the versions\0.2 folder, according to the features in DESIGN.md

This diff represents the creation of a new file `find-up.sh` in the `versions/0.2` directory. The script is a basic implementation of the `find-up` tool as described in the DESIGN.md document. It includes parsing of the new upward search flags, a function to perform the upward search, and the main logic to start the search from the current directory or a provided path.

Allow creation of new file versions/0.2/find-up.sh? y
Applied edit to versions/0.2/find-up.sh
Commit 24a88f8 aider: Create find-up.sh script for upward search functionality in versions/0.2 folder.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
versions\0.2\find-up.sh filesystem\find\up\DESIGN.md
> Can you move the versions tree from the root to `filesystem\find\up\

To move the `versions` tree from the root to `filesystem/find/up/`, you would typically use file system commands like `mv` in a Unix-like environment. However, since you're asking for a diff, I will provide you with a representation of what the changes would look like in a diff format. Please note that actual moving of directories and files is not something that can be represented in a diff because diffs show changes to file contents, not file system operations.

If you were to apply this change in a real environment, you would execute a command like this:
mv versions filesystem/find/up/
However, for the sake of this exercise, here's a representation of what the diff might look like if we were to "move" the contents of the `find-up.sh` script:
--- versions/0.2/find-up.sh
+++ filesystem/find/up/versions/0.2/find-up.sh
@@ ... @@
 # The contents of the file would remain unchanged, but the file's path is updated.
 # No actual content diff is provided since the file itself is not being modified, only moved.
Please execute the appropriate file system command to move the directory as diffs cannot perform such operations.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
versions\0.2\find-up.sh filesystem\find\up\DESIGN.md
>
amacsmith commented 5 months ago

I think this makes a lot of sense to ask and is probably something aider can and/or should handle.

paul-gauthier commented 5 months ago

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.

tremayne-stewart commented 4 months ago

What are your ideas on how to implement it? I may have done cycles to create a PR.

paul-gauthier commented 4 months ago

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.

VictorBargains commented 4 months ago

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:


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

paul-gauthier commented 4 months ago

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,

jerzydziewierz commented 1 month ago

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.

paul-gauthier commented 3 weeks ago

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.

Kreijstal commented 3 weeks ago

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

paul-gauthier commented 2 weeks ago

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.

andrewsgeller commented 2 weeks ago

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: @.***>