Skip to main content

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

Project description

repo2string

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

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

(Make sure pyperclip and tiktoken are installed; they’re declared as dependencies in pyproject.toml.)

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.1.tar.gz (4.4 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.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for repo2string-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4db134f4a50ac5fd5b2dceb08563059cb528228e0d8008279ff0635843c13560
MD5 cbc1c90a168570e2b20a013947e9c2de
BLAKE2b-256 c5d3e35efa82f64072d2995c7c4baac12ce1c7fcdbe8527752476eb8e0ddb07e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for repo2string-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d17f6d6d294b18e19140b4002d8ae6b22fe74d4102815a20db378087bcd3094
MD5 e8b8b9aeccc66579a69a6af58de9b31a
BLAKE2b-256 c2c5710dc40e37c2e5f35c2f726677c49e57021dbd04a76845735f04ff2c91a6

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