Skip to main content

Turn a repository's tracked files into a single text for LLM context (with token counts).

Project description

repo2string

PyPI version Python Versions License: MIT Downloads

repo2string is a Python package and CLI tool that gathers all files in a repository (or any folder), excluding ignored files as specified by a .gitignore (if present), and concatenates them into a single string. This is useful for copying the entire codebase as a context to large language models (LLMs) like ChatGPT.

Features:

  • Recursively traverse directories.
  • Skip files listed in .gitignore (if present) or skip only .git if no .gitignore exists.
  • Generate a file tree (with absolute paths).
  • Include the contents of all non-ignored files.
  • Copy all text to your clipboard automatically.
  • Token counting: Displays the token count of the entire prompt.
  • Verbose mode (-v or --verbose): Also prints the token counts per file, sorted from highest to lowest.

Installation

You can install repo2string directly from PyPI:

pip install repo2string

Or install from source:

git clone https://github.com/szulcmaciej/repo2string.git
cd repo2string
pip install .

Usage

repo2string [PATH] [--verbose]
  • PATH is optional; defaults to . (current directory).
  • --verbose or -v prints a token-count summary per file (descending).

Example:

repo2string /path/to/myproject --verbose

You will see console output summarizing the total token count, plus a per-file token breakdown if in verbose mode. The entire text is copied to your clipboard.

Now you can paste the combined repo data into ChatGPT or another LLM interface to work on your code with maximum context.

License

MIT

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

repo2string-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

repo2string-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file repo2string-0.1.2.tar.gz.

File metadata

  • Download URL: repo2string-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for repo2string-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1459c274089559f3183e9ed4076e80aa4b76fb6628e39a7efb58aa6f3611f667
MD5 0943b67b3d3b00b9c7126f7541ba5606
BLAKE2b-256 443aab6e1e9685272e88f2cb3744554ef3b7c45f42f922b9f93261d82dab7b6a

See more details on using hashes here.

File details

Details for the file repo2string-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: repo2string-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for repo2string-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 90b4199b03c507f619b7fdb648242b480975507e6659168413c797c8607e17c6
MD5 ce5090804c1b6fcc651aa47d939602fc
BLAKE2b-256 11e3f2827677b9c84edc701f5b43d523dae158f38bd7da7faf109b2d2597b8c4

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