aider icon indicating copy to clipboard operation
aider copied to clipboard

Adding directories doesn't ignore __pycache__ etc.

Open dokterbob opened this issue 1 year ago • 5 comments

Issue

When adding directories of Python code, things like pycache should be ignored rather than added to context. They are not, creating confusion for the model and adding extraneous tokens.

Version and model info

Aider: 0.57.1

dokterbob avatar Sep 27 '24 09:09 dokterbob

Thank you for filing this issue.

aider's source of truth is the git repository. If those directories do not get ignored via .gitignore they might get added. That is outside of the control of aider.

This repository might be helpful -> https://github.com/github/gitignore

fry69 avatar Sep 27 '24 09:09 fry69

Thanks for the quick follow-up @fry69.

They are most definitely not in the GIT repo. Is aider using home dir/system GIT ignores, like GIT does?

dokterbob avatar Sep 27 '24 09:09 dokterbob

aider uses GitPython, which respects everything what git does too (except for some arcane features which do not matter for this discussion). Most certainly GitPython respects git ignore files everywhere where git expects those/is configured to look for.

It may be possible that aider cannot see those configuration files e.g. if it runs in a separate environment like Docker.

fry69 avatar Sep 27 '24 09:09 fry69

🤔 I did add a directory outside the GIT root (to make aider aware of types there), could that be the cause?

dokterbob avatar Sep 27 '24 09:09 dokterbob

Yes. That is outside of the control of git and its ignore files. If you add a directory with e.g. /read it will recursively add the whole contents (that was a requested feature).

If that is a problem you have to add single files manually via /read not whole directories.

Adding a huge amount of files is discouraged anyway, as this often will confuse the LLM, see here:

https://aider.chat/docs/faq.html#how-can-i-add-all-the-files-to-the-chat

fry69 avatar Sep 27 '24 09:09 fry69

I'm closing this issue for now.

If any new related concerns arise, please feel free to comment, and I'll reopen the issue.

fry69 avatar Oct 05 '24 12:10 fry69

This is a very normal scenario to add a folder of source files at once, in fact that must be why this functionality even exists. And basically every time there will be a __pycache__ folder there. There's clear room for improvement here, as it is passing a folder to /read will be useless a for a lot of users.

swarmer avatar Oct 07 '24 14:10 swarmer

You can also use a glob like foo/**/*.py.

paul-gauthier avatar Oct 07 '24 17:10 paul-gauthier

Please also do read the FAQ about why it's not advisable to "add a folder of source files at once".

paul-gauthier avatar Oct 07 '24 17:10 paul-gauthier