simonw / files-to-prompt

Concatenate a directory full of files into a single prompt for use with LLMs
Apache License 2.0
244 stars 17 forks source link

Take multiple arguments for files and directories to include #2

Closed simonw closed 3 months ago

simonw commented 3 months ago

That way you could send just specific files like this:

files-to-prompt app.py utils.py
dipam7 commented 3 months ago

Do you want to accept multiple args for path? or add a new option like --files?

simonw commented 3 months ago

cat files_to_prompt/cli.py | llm -m opus --system ' Modify this file. It should take multiple arguments in a variable called paths. Each of those argumets might be a path to a file or it might be a path to a directory - if any of the arguments do not correspoind to a file or directory it should raise a click error.

It should then do what it does already but for all files or files-recursively-contained-within-folders that are passed to it.

It should still obey the gitignore logic.'

https://gist.github.com/simonw/345f16a54f9e753852ea0af4bd7c2abc

simonw commented 3 months ago
files-to-prompt files_to_prompt tests | llm -m opus --system \
   'rewrite the tests to cover the ability to pass multiple files and folders to the tool'

https://gist.github.com/simonw/c3b021f7b4f8b1e30b79f95210cc5702

files-to-prompt files_to_prompt tests | llm -m opus --system \
  'add one last test which tests .gitignore and include_hidden against an example that mixes single files and directories of files together in one invocation'

https://gist.github.com/simonw/a578bae9fe409cb29533ae28a348cb27

simonw commented 3 months ago

I decided to make that last test a bit easier to read.

symbex test_mixed_paths_with_options | llm -m opus --system \
  'rewrite this test so the filenames are more obvious, thinks like ignored_in_gitignore.txt'

llm -c 'add a last bit to that test for ["test_dir", "single_file.txt", "--ignore-gitignore", "--include-hidden"]'

https://gist.github.com/simonw/a637f3e244ef1330e657221bfa84dfae

simonw commented 3 months ago

That test:

https://github.com/simonw/files-to-prompt/blob/ebd191f77dd1160710301633953b00884e0aa9fe/tests/test_files_to_prompt.py#L85-L141