aider icon indicating copy to clipboard operation
aider copied to clipboard

Allow filename autocomplete to match against files that aren't part of git repo

Open Morriz opened this issue 1 year ago • 7 comments

Hi, I just created some new files and aider does not "see" them. Autocompletion finally works but maybe it only shows files from git? That would be undesirable since we are developing...

Aider v0.23.0
Model: gpt-4-1106-preview using udiff edit format
Git repo: .git with 35 files
Repo-map: using 1024 tokens

Morriz avatar Feb 09 '24 11:02 Morriz

Yeah, it only sees stuff in github, which defeats the point of being in dev mode and creating new files and tests for those ;(

Morriz avatar Feb 10 '24 17:02 Morriz

Thanks for trying aider and filing this issue.

Sorry, can you be more clear about the problem you are having with new files? Aider certainly allows you or GPT to create new files.

See the transcript below for examples, which does the following:

  1. Makes a new dir with a new git repo, all empty.
  2. Launches aider with a new file called hello.py on the cmd line. Asks aider to make it print hello world.
  3. Uses /add goodbye.py to add another new file to the chat, and then make it print goodbye.
  4. Asks GPT to create another new file bonjour.py and make it print hello world in French.
$ mkdir newfiles
(aider) macbook:~/tmp$ cd newfiles/

(aider) macbook:tmp/newfiles$ git init
Initialized empty Git repository in /Users/gauthier/tmp/newfiles/.git/

(aider) macbook:tmp/newfiles$ aider hello.py
Aider v0.24.1-dev
Model: gpt-4-0613 using diff edit format
Creating empty file /Users/gauthier/tmp/newfiles/hello.py
Git repo: .git with 0 files
Repo-map: using 1024 tokens
Added hello.py to the chat.
Use /help to see in-chat commands, run with --help to see cmd line args
──────────────────────────────────────────────────────────────────────────────────────────
hello.py> print hello world

To print "Hello, World!" in Python, we need to modify hello.py:

 1 Add a print statement to hello.py.

Here is the SEARCH/REPLACE block:

hello.py


 <<<<<<< SEARCH
 =======
 print("Hello, World!")
 >>>>>>> REPLACE



Applied edit to hello.py
Commit 7372f99 aider: Added print statement to hello.py.
──────────────────────────────────────────────────────────────────────────────────────────
hello.py> /add goodbye.py

No files matched 'goodbye.py'. Do you want to create /Users/gauthier/tmp/newfiles/goodbye.py? y
Added /Users/gauthier/tmp/newfiles/goodbye.py to the chat
────────────────────────────────────
goodbye.py hello.py
> print goodbye

To print "Goodbye" in Python, we need to modify goodbye.py:

 1 Add a print statement to goodbye.py.

Here is the SEARCH/REPLACE block:

goodbye.py


 <<<<<<< SEARCH
 =======
 print("Goodbye")
 >>>>>>> REPLACE



Applied edit to goodbye.py
Commit bae2185 aider: Added print statement to `goodbye.py`.
────────────────────────────────────
goodbye.py hello.py
> make a new file call bonjour.py that says hello world in french

To create a new file bonjour.py that prints "Hello, World!" in French, we need to:

 1 Create a new file bonjour.py.
 2 Add a print statement to bonjour.py that prints "Bonjour, le monde!".

Here is the SEARCH/REPLACE block:

bonjour.py


 <<<<<<< SEARCH
 =======
 print("Bonjour, le monde!")
 >>>>>>> REPLACE



Allow creation of new file bonjour.py? y
Applied edit to bonjour.py
Commit 1c59cf7 aider: Create a new file `bonjour.py` that prints "Bonjour, le monde!".
────────────────────────────────────

paul-gauthier avatar Feb 10 '24 18:02 paul-gauthier

I think I can clarify a little bit. @Morriz, let me know if I've got the wrong idea.

I use tmux, but this also happens when I use two terminals. I keep aider running in one window and use a second window to edit and create files.

$ aider testfile1.txt 
Aider v0.24.1
Model: gpt-4-0613 using diff edit format
Git repo: .git with 0 files
Repo-map: using 1024 tokens
Added testfile1.txt to the chat.
Use /help to see in-chat commands, run with --help to see cmd line args
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
testfile1.txt                                                                                                                                                                         
>  

In a second window, I create a new file.

$ echo "second testfile" > testfile2.txt

Go back to aider and try to add it.

> /add test<TAB>

No file shows up in tab completion, but if I type out the fqfn /add testfile2.txt, the file is added to the context.

The problem I have is that when I create a new file in subdirectories. It's kind of a pain to have to type out the whole path. Especially when short-term memory sucks mud. :)

harleypig avatar Feb 11 '24 16:02 harleypig

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.

paul-gauthier avatar Feb 24 '24 15:02 paul-gauthier

why did you close this? it is like @harleypig also describes...can you reopen this or at least tell us why you would close it?

Morriz avatar Mar 09 '24 14:03 Morriz

It's a minor issue. It's not that file won't load, it's just that the autocomplete won't see it. You could use aider to try and fix it and submit a pr. :)

harleypig avatar Mar 09 '24 16:03 harleypig

Ok, it sounds like you want autocomplete to match against files that are not part of the git repo.

Currently, autocomplete intentionally only matches against the git repo files. There are good reasons for that, as well as a reasonable argument for the change you are requesting.

I'll leave this issue open as an enhancement request.

paul-gauthier avatar Mar 09 '24 16:03 paul-gauthier