# repo2string
[![PyPI - Version](https://img.shields.io/pypi/v/repo2string)](https://pypi.org/project/repo2string)
[![Python Versions](https://img.shields.io/pypi/pyversions/repo2string)](https://pypi.org/project/repo2string/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://static.pepy.tech/badge/repo2string)](https://pepy.tech/project/repo2string)
[![CI](https://github.com/szulcmaciej/repo2string/actions/workflows/ci.yml/badge.svg)](https://github.com/szulcmaciej/repo2string/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/szulcmaciej/repo2string/branch/master/graph/badge.svg)](https://codecov.io/gh/szulcmaciej/repo2string)
## TLDR: "Help! ChatGPT needs to see my code!"
Yeet your entire codebase into clipboard:
```bash
pip install repo2string
cd your/project/path
r2s # Yoink! Your entire codebase is now in your clipboard 📋
```
Token limit got you down? Cherry-pick your files:
```bash
r2s -s # Opens a nice UI for file selection 🎯
```
---
**repo2string** is a tool that helps you prepare your codebase for large language models (LLMs) like ChatGPT. In CLI mode, it automatically processes all relevant files in your project, excluding common build artifacts and respecting `.gitignore`. For more control, the file selection UI lets you interactively select specific files and folders while tracking token counts. Either way, the result is copied to your clipboard, ready to be pasted into your favorite LLM.
Features:
- Recursively traverse directories.
- Skip files listed in `.gitignore` (if present) or skip only `.git` if no `.gitignore` exists.
- Skip common directories like build outputs, dependencies, and IDE files ([see default exclusions](#default-exclusions)).
- Generate and include a file tree, making it easy to understand the codebase structure.
- 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 (uses the **gpt-4o**/**o1** tokenizer)
- **Verbose mode** (`-v` or `--verbose`): Also prints the token counts per file,
sorted from highest to lowest.
- **File selection UI** (`-s` or `--select`): Opens a lightweight web interface to select exactly
which files and folders to include.
## Installation
You can install `repo2string` directly from PyPI:
```bash
pip install repo2string
```
Or install from source:
```bash
git clone https://github.com/szulcmaciej/repo2string.git
cd repo2string
pip install .
```
## Usage
You can use either the full command `repo2string` or its shorter alias `r2s`.
### CLI Mode
The CLI mode processes all relevant files in the directory, excluding those matched by `.gitignore` and [default exclusions](#default-exclusions). Use this when you want to quickly copy the entire codebase.
```bash
r2s [PATH] [--verbose]
```
- `PATH` is optional; defaults to current directory
- `--verbose` or `-v` shows token counts per file
Example:
```bash
r2s # Copy current directory
r2s /path/to/project # Copy specific directory
r2s -v # Show token counts per file
```
### File Selection UI
Need more control? The file selection UI lets you choose specific files and folders while tracking token counts.
```bash
r2s [PATH] --select # or -s
```
This opens a local web interface where you can:
1. Browse the file tree
2. Select/deselect files and folders
3. Search for specific files
4. Monitor token counts
5. Copy only what you need
![Selection Mode Screenshot](https://raw.githubusercontent.com/szulcmaciej/repo2string/master/.github/images/selection-mode.png)
The UI runs locally - no data leaves your machine, and the server shuts down automatically when you're done.
### Default Exclusions
The tool automatically excludes common directories and files that typically don't need to be included in the LLM context:
- Version control: `.git/`
- Cache directories: `**/.*cache/`, `**/__pycache__/`
- Build outputs: `**/build/`, `**/dist/`, `**/target/`, `**/bin/`, `**/obj/`, `**/out/`
- Dependencies: `**/node_modules/`, `**/vendor/`, `**/package-lock.json`
- IDE files: `**/.idea/`, `**/.vscode/`, `**/.vs/`
- Environment: `**/.env*/`, `**/venv/`
These are in addition to any patterns specified in your `.gitignore` file.
## Development Setup
To set up the development environment:
1. Clone the repository:
```bash
git clone https://github.com/szulcmaciej/repo2string.git
cd repo2string
```
2. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
To run tests manually:
```bash
pytest
```
### Release Process
The release process is fully automated through a chain of GitHub Actions:
1. When you push to `master`, the CI workflow runs tests and linting
2. If CI passes and the version in `pyproject.toml` was bumped:
- A new GitHub release is created automatically
- Release notes are generated from commit messages
3. When the release is published:
- The package is automatically built and published to PyPI
- Using trusted publishing for enhanced security
No manual intervention is needed beyond pushing your changes with a version bump.
## License
[MIT](https://opensource.org/licenses/MIT)
Raw data
{
"_id": null,
"home_page": null,
"name": "repo2string",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "llm, chatgpt, repository, context, tokens, clipboard",
"author": null,
"author_email": "Maciej Szulc <szulcmaciej1@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/1b/9d/7fd8a7d4f11253bd2e253fb7599a7a1ee2b1e799a94ae1c302f4d144eba2/repo2string-0.4.2.tar.gz",
"platform": null,
"description": "# repo2string\n\n[![PyPI - Version](https://img.shields.io/pypi/v/repo2string)](https://pypi.org/project/repo2string)\n[![Python Versions](https://img.shields.io/pypi/pyversions/repo2string)](https://pypi.org/project/repo2string/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://static.pepy.tech/badge/repo2string)](https://pepy.tech/project/repo2string)\n[![CI](https://github.com/szulcmaciej/repo2string/actions/workflows/ci.yml/badge.svg)](https://github.com/szulcmaciej/repo2string/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/szulcmaciej/repo2string/branch/master/graph/badge.svg)](https://codecov.io/gh/szulcmaciej/repo2string)\n\n## TLDR: \"Help! ChatGPT needs to see my code!\"\nYeet your entire codebase into clipboard:\n```bash\npip install repo2string\ncd your/project/path\nr2s # Yoink! Your entire codebase is now in your clipboard \ud83d\udccb\n```\n\nToken limit got you down? Cherry-pick your files:\n```bash\nr2s -s # Opens a nice UI for file selection \ud83c\udfaf\n```\n\n---\n\n**repo2string** is a tool that helps you prepare your codebase for large language models (LLMs) like ChatGPT. In CLI mode, it automatically processes all relevant files in your project, excluding common build artifacts and respecting `.gitignore`. For more control, the file selection UI lets you interactively select specific files and folders while tracking token counts. Either way, the result is copied to your clipboard, ready to be pasted into your favorite LLM.\n\nFeatures:\n\n- Recursively traverse directories.\n- Skip files listed in `.gitignore` (if present) or skip only `.git` if no `.gitignore` exists.\n- Skip common directories like build outputs, dependencies, and IDE files ([see default exclusions](#default-exclusions)).\n- Generate and include a file tree, making it easy to understand the codebase structure.\n- Include the contents of all non-ignored files.\n- Copy all text to your clipboard automatically.\n- **Token counting**: Displays the token count of the \nentire prompt (uses the **gpt-4o**/**o1** tokenizer)\n- **Verbose mode** (`-v` or `--verbose`): Also prints the token counts per file, \n sorted from highest to lowest.\n- **File selection UI** (`-s` or `--select`): Opens a lightweight web interface to select exactly \n which files and folders to include.\n\n## Installation\n\nYou can install `repo2string` directly from PyPI:\n\n```bash\npip install repo2string\n```\n\nOr install from source:\n\n```bash\ngit clone https://github.com/szulcmaciej/repo2string.git\ncd repo2string\npip install .\n```\n\n## Usage\n\nYou can use either the full command `repo2string` or its shorter alias `r2s`.\n\n### CLI Mode\n\nThe CLI mode processes all relevant files in the directory, excluding those matched by `.gitignore` and [default exclusions](#default-exclusions). Use this when you want to quickly copy the entire codebase.\n\n```bash\nr2s [PATH] [--verbose]\n```\n\n- `PATH` is optional; defaults to current directory\n- `--verbose` or `-v` shows token counts per file\n\nExample:\n```bash\nr2s # Copy current directory\nr2s /path/to/project # Copy specific directory\nr2s -v # Show token counts per file\n```\n\n### File Selection UI\n\nNeed more control? The file selection UI lets you choose specific files and folders while tracking token counts.\n\n```bash\nr2s [PATH] --select # or -s\n```\n\nThis opens a local web interface where you can:\n1. Browse the file tree\n2. Select/deselect files and folders\n3. Search for specific files\n4. Monitor token counts\n5. Copy only what you need\n\n![Selection Mode Screenshot](https://raw.githubusercontent.com/szulcmaciej/repo2string/master/.github/images/selection-mode.png)\n\nThe UI runs locally - no data leaves your machine, and the server shuts down automatically when you're done.\n\n### Default Exclusions\n\nThe tool automatically excludes common directories and files that typically don't need to be included in the LLM context:\n\n- Version control: `.git/`\n- Cache directories: `**/.*cache/`, `**/__pycache__/`\n- Build outputs: `**/build/`, `**/dist/`, `**/target/`, `**/bin/`, `**/obj/`, `**/out/`\n- Dependencies: `**/node_modules/`, `**/vendor/`, `**/package-lock.json`\n- IDE files: `**/.idea/`, `**/.vscode/`, `**/.vs/`\n- Environment: `**/.env*/`, `**/venv/`\n\nThese are in addition to any patterns specified in your `.gitignore` file.\n\n\n\n## Development Setup\n\nTo set up the development environment:\n\n1. Clone the repository:\n ```bash\n git clone https://github.com/szulcmaciej/repo2string.git\n cd repo2string\n ```\n\n2. Create and activate a virtual environment:\n ```bash\n python -m venv venv\n source venv/bin/activate # On Windows: venv\\Scripts\\activate\n ```\n\nTo run tests manually:\n```bash\npytest\n```\n\n### Release Process\n\nThe release process is fully automated through a chain of GitHub Actions:\n\n1. When you push to `master`, the CI workflow runs tests and linting\n2. If CI passes and the version in `pyproject.toml` was bumped:\n - A new GitHub release is created automatically\n - Release notes are generated from commit messages\n3. When the release is published:\n - The package is automatically built and published to PyPI\n - Using trusted publishing for enhanced security\n\nNo manual intervention is needed beyond pushing your changes with a version bump.\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Copy any repository into the clipboard. And get the token count.",
"version": "0.4.2",
"project_urls": {
"Bug Tracker": "https://github.com/szulcmaciej/repo2string/issues",
"Homepage": "https://github.com/szulcmaciej/repo2string"
},
"split_keywords": [
"llm",
" chatgpt",
" repository",
" context",
" tokens",
" clipboard"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "24ecc8c26a3927a116babf7b6032d55fab8c19c32eab62a19d2fea142e49264b",
"md5": "3b64e7a485cc327b3f2f6f8e18891805",
"sha256": "126fdd96acf1d3687f056f329707790e2a22d03e2f224022cf82eac3bd601b6b"
},
"downloads": -1,
"filename": "repo2string-0.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3b64e7a485cc327b3f2f6f8e18891805",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13501,
"upload_time": "2025-01-26T17:45:18",
"upload_time_iso_8601": "2025-01-26T17:45:18.994837Z",
"url": "https://files.pythonhosted.org/packages/24/ec/c8c26a3927a116babf7b6032d55fab8c19c32eab62a19d2fea142e49264b/repo2string-0.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1b9d7fd8a7d4f11253bd2e253fb7599a7a1ee2b1e799a94ae1c302f4d144eba2",
"md5": "3e9bac0419475e55cbe9d268d892ac85",
"sha256": "3e47135ff35908253349e564d8c9d23fa62527e6af2e8ad271ece4df09ebb8d7"
},
"downloads": -1,
"filename": "repo2string-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "3e9bac0419475e55cbe9d268d892ac85",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 17292,
"upload_time": "2025-01-26T17:45:20",
"upload_time_iso_8601": "2025-01-26T17:45:20.693243Z",
"url": "https://files.pythonhosted.org/packages/1b/9d/7fd8a7d4f11253bd2e253fb7599a7a1ee2b1e799a94ae1c302f4d144eba2/repo2string-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-26 17:45:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "szulcmaciej",
"github_project": "repo2string",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "repo2string"
}