aider icon indicating copy to clipboard operation
aider copied to clipboard

feat: add `/rg` command (ripgrep for `/add` files)

Open aleclarson opened this issue 1 year ago • 5 comments

NOTE: Using this command requires ripgrep installed on your machine.

How it works

It calls rg through a subprocess with the -l flag to return a list of filenames. These filenames are then fed into the /add command. Anything you pass after /rg is forwarded to the ripgrep tool.

aleclarson avatar Apr 09 '24 02:04 aleclarson

This is nice. Would it be possible to make the /rg command pop up an interactive window for selecting a file? Otherwise, it seems like it would be easy to add too many files by accident.

Also, one thing you might want to check out in the interim is fzf shell integration. This way, you can type aider **<tab> and it will pop open an interactive fzf window where you can search for a file using fuzzy matching. I have found this quite effective, and much easier/faster than using the /add command from within aider.

avi-cenna avatar May 06 '24 20:05 avi-cenna

This seems like a very valuable feature which I would want to take advantage of.

I am not the author, but my suggestion would be to follow the current implementation approach to tests.

Aider knows very little about tests:

  • if given the command /test , it will run the command and include it in chat if return code shows an error.
  • Alternatively, it is told what fixed command to run via --test-cmd (e.g., pytest)
  • Tests should be run after changes and block commits (I think)

So it is:

  • enabling workflows that help the user+LLM make progress
  • avoiding dependence on pre-installed tools that might be relevant to a subset of projects or users
  • allowing future improvements to the workflow (e.g., user or project level config so the command line argument isn't necessary).

So how about instead adding a /search command that only activates when --search-cmd is given? that way people get to choose their preferred among grep, ag, etc.

daniel-vainsencher avatar Jun 17 '24 16:06 daniel-vainsencher

More importantly: the user should be asked to review the grep result (the list of files that are going to be added) before actually adding them. So that it would be simple to cancel and try again with a better pattern.

Emasoft avatar Jun 22 '24 18:06 Emasoft

This is nice. Would it be possible to make the /rg command pop up an interactive window for selecting a file? Otherwise, it seems like it would be easy to add too many files by accident.

Also, one thing you might want to check out in the interim is fzf shell integration. This way, you can type aider **<tab> and it will pop open an interactive fzf window where you can search for a file using fuzzy matching. I have found this quite effective, and much easier/faster than using the /add command from within aider.

would you happen to know how to use fzf for aider file selection in Windows?

drhouse avatar Jul 18 '24 15:07 drhouse

+1 for fzf ;

However, -3 for hard dependence on external tools, which are often platform-specific.

Maybe this feature could be packaged as "optional plugin" ?

jerzydziewierz avatar Jul 28 '24 08:07 jerzydziewierz