aider
aider copied to clipboard
Add files based on content
When refactoring a large codebase, it is hard to know exactly which files are needed and will be impacted by the refactoring. As a result, one generally has to spend time looking at the code and searching which files should be added to aider in a text editor before starting the refactoring.
For instance: if I want to ask aider to refactor the function exampleFunction (rename, change call parameters, etc.), I need to list all the files where that function appears and manually add them to aider.
One solution to make this workflow easier would be to allow the /add command (or a new command) to search for a specific string or pattern inside all the files in the current folder and all its sub-folders, and then automatically add the files where the string or patterns appear at least once.
Example: /add-pattern exampleFunction
I think even better would be a combo between /run and /add
Imagine you sloppily write a feature, and commit it to a branch.
Then, you want to clean it up the next work day, but it's now Monday, and you don't remember what files you changed.
You could do something like:
/run_and_add git diff-tree --no-commit-id --name-only -r HEAD (this just lists all files changed in the last commit)
To execute that bash, and interpret each line as a file argument to the /add command
Bash is VERY flexible, and fits your use-case as well. Your use-case can be solved with grep or ag or ls or many other tools easily if mixing bash code with the /add command is possible one way or another
related to this: one of my current workflows is to use cursor to write aider scripts: https://forum.cursor.sh/t/has-cursor-gotten-dumb/2884/14?u=raw.works
so cursor helps you with the part you are struggling with: "finding the right files to add to aider". then aider does what aider does for that script.
see also: https://aider.chat/docs/faq.html#can-i-script-aider
Aider should do a fine job on this now. At least well enough to score very high on SWE Bench. 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.