Skip to main content

Simple Python CLI tool for turning directories into a single text file for input to LLMs.

Project description

grabit

grabit is a command-line tool for recursively scanning a directory, extracting file contents, and saving or copying them to the clipboard while respecting .grabit ignore rules. The tool helps turn complex projects into LLM input for big context questions.

Features

  • Recursively extracts file contents from a directory.
  • Respects .grabit ignore files (similar to .gitignore).
  • Saves extracted content to a file or copies it to the clipboard.
  • Works on Windows, macOS, and Linux.

Installation

Install grabit using pip:

pip install grabit

Usage

Basic Usage

grabit /path/to/directory

Save Output to a File

grabit /path/to/directory -o output.txt

Copy Output to Clipboard

grabit /path/to/directory -c

Ignore Files

To ignore specific files or patterns, create a .grabit file in the root of your project. This works similarly to .gitignore.

Example .grabit:

*.log
__pycache__/
secrets.txt

Example Output

When run, grabit will generate a structured output:

## `src/main.py`:
``
print("Hello, World!")
``

## `README.md`:
``
# Project Readme
``

Versioning

Major.Minor.Patch

  • Major: Breaking changes.
  • Minor: New feature has been added, but backwards compatible.
  • Patch: Backwards compatible bug fixes.

Future Features

  • include and exclude sections in .grabit.
  • different titled configurations in the .grabit file. i.e. you could have a configuration for getting section A of your app, and another for section B of your app to make it easier to set the configs once and not worry afterwards.
  • add a command line argument option for adding an include or an exclude regex, something like grabit -e "some-regex" or grabit -i "some-regex".
  • include a directory tree in the output as well as the code.
  • tell the user the rough number of tokens that have been found across all the files.
  • predict the number of tokens in a file based on the number of characters in each file.
  • if the number of tokens is high, intelligently group files by suffix and prefix and ask the user if they'd like to include or exclude them.
  • ask the user if they'd like to include only a snippet of parts of long files, i.e. first 50 lines or so. Allow them to set this on a per file basis.
  • add sensible defaults to the .grabit file produced by grabit init.
  • automatically generate or update the .grabit file to reflect the user's choices in the above two features.
  • ask the user if they want to include large directories as well, not just by prefix.
  • add an option for setting up a query on the cli that helps grabit decide how simliar files are to that query and suggest including or discluding based on that. Cursor do something like this, a vector database.
  • store the query inside of the .grabit file for faster query re-runs.
  • if the files have git history, find the git history of every collected file and add when it was last changed.
  • taking the above further, optionally add the entire git log of commits for each file, or the last N commits or what have you. This could add extra context for an LLM.
  • add an option to include the git diff of each file, or the last N diffs or what have you. This could add even more context for an LLM, an optional argument could be add that switches this on.
  • add the ablity to collect the whole git history of the repo, all the logs.
  • get a log timeline, so you can see how much activity each file has in git. This extra information could be used to help decide which files to include or exclude. It could also help the user decide how important a particular file is. Especially if data on recent history is provided.
  • add tests to the package to avoid changes causing failure.
  • decide on versioning strategy and add to README.md
  • add standard configuration setting for .grabit files. This will run through their directory and make decisions for them, outputting choices to the terminal for the user to review. e.g. skipping extra large files, or skipping known auto-genned file types like .dll.
  • add a terminal based configuration building process that guides users through the various .grabit options and lets them build their .grabit file via the terminal
  • add an option to set the target number of tokens that grabit should not go over. Then when grabit does go over it will make suggestions underneath the table on what you could do to lower the amount of tokens. If there are embeddings as well, this could be very helpful for figuring out how important different directory paths etc. are.
  • build directory path trees whilst collecting so that more than just the path name can be used to group the directories and find similarities that could be exploited for removing tokens.
  • colour the output that's given to the user depending on size so it's easier to see patterns and make decisions on what to include or disclude.
  • potentially colour the file endings of different file types to also add a visual cue to the user.
  • add an option to order table output by token sizes, last modified by, by order scanned, by file path, and by date last modified.
  • add an option for quickly scanning through a directory and getting sizes in bytes very quickly to make choice on inclusion faster.
  • improve the option for fast search to include colour coding and ordering by column.

License

MIT License

Connor Skelland

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grabit-1.3.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grabit-1.3.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file grabit-1.3.0.tar.gz.

File metadata

  • Download URL: grabit-1.3.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/10

File hashes

Hashes for grabit-1.3.0.tar.gz
Algorithm Hash digest
SHA256 dc58aaa043c008536041d49706afebcb855302145a007dce7f154befe9241b56
MD5 ce181078e1d01b6b629d47cf67d7916f
BLAKE2b-256 ff35ccbaa1af036ea18e24d0744a3fa4d86620ed94cbcbb14bfb057e2e31531f

See more details on using hashes here.

File details

Details for the file grabit-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: grabit-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/10

File hashes

Hashes for grabit-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11a57089cd725fc904b0bf9fbe98c8d0cd591223fedb48d471ae94dff0119317
MD5 7b1b121741479ae26bb60f4d1fea0a33
BLAKE2b-256 e6a5f4dc2fe21809e3fb5685ea170f781017ac5ce253257e622d84b3aa32758f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page