mufeedvh / code2prompt

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.
MIT License
1.45k stars 77 forks source link

feat: relative directories to files #13

Closed jpshackelford closed 4 months ago

jpshackelford commented 4 months ago

@mufeedvh This is an awesome tool!

Feature request:

A --relative-paths flag truncates paths to the directory passed as an argument so that parent directories are not included in the file paths of the output.

Today if I run code2prompt projectdir when files are listed in the prompt payload the paths are displayed as $HOME/code/projectdir/somefile.txt instead of /projectdir/somefile.txt. Stripping the parent path saves tokens and keep details of my filesystem and username private.

mufeedvh commented 4 months ago

Hey @jpshackelford, thank you for opening a feature request! This is indeed useful, just implemented it right away using code2prompt itself! :)

You can update code2prompt by building the latest commits from source or simply with the following command if you've cargo installed:

cargo install --git https://github.com/mufeedvh/code2prompt

Use relative paths instead of absolute paths:

code2prompt path/to/codebase --relative-paths

Thanks again! 🙌

jpshackelford commented 4 months ago

Amazing. Verified. Thanks again!