Skip to main content

A tool to turn an entire Git repository into a single organized text file for AI context.

Project description

Repo-to-Text-AI

Turn an entire Git repository into a single, organized text file designed for providing context to Large Language Models (LLMs).

repo-to-text-ai is a command-line tool that intelligently traverses a local repository, respecting .gitignore rules, and consolidates the code into a clean text file. This is perfect for pasting complete project contexts into AI prompts for analysis, documentation, or feature development.


Features

  • Single File Output: Combines all relevant source files into one .txt file.
  • Project Tree Summary: Automatically generates a directory tree at the beginning of the output for a high-level overview.
  • Smart Exclusion:
    • Excludes the .git directory by default.
    • Automatically respects rules in .gitignore.
    • Allows for a user-defined .context_ignore file for additional, AI-specific exclusions.
    • Skips binary files to keep the output clean.
  • Progress Bar: Shows a progress bar for large repositories so you know it's working.
  • Easy to Use: A simple and intuitive command-line interface.

Installation

You can install repo-to-text-ai directly from PyPI:

pip install repo-to-text-ai

Usage

Navigate to the root directory of the Git repository you want to process and run the command:

repo-to-text-ai .

This will create a context_output.txt file in the current directory.

Options

  • Specify Output File: Use the --output or -o flag to specify a different name or location for the output file.

    repo-to-text-ai . -o my_project_context.txt
    
  • Specify Repository Path: You can run the command from anywhere by providing the path to the repository.

    repo-to-text-ai /path/to/your/project
    

Excluding Additional Files (.context_ignore)

Sometimes you want to exclude more files from the AI's context than you have in your standard .gitignore (e.g., test files, examples).

You can create a .context_ignore file in the root of your repository. It uses the exact same syntax as a .gitignore file.

Example .context_ignore:

# Exclude all test files from the AI context
tests/

# Exclude specific large data files
data/large_dataset.csv```

---

## Development

Interested in contributing? We use `pytest` for testing and `ruff`/`black` for formatting.

### Prerequisites

-   Python 3.8+
-   [Docker](https://www.docker.com/get-started') (Optional, for isolated environment)

### Local Setup

1.  **Clone the repository:**
    ```bash
    git clone https://github.com/zhu-weijie/repo-to-text-ai.git
    cd repo-to-text-ai
    ```

2.  **Create and activate a virtual environment:**
    ```bash
    python3 -m venv .venv
    source .venv/bin/activate
    ```

3.  **Install in editable mode with test dependencies:**
    ```bash
    pip install -e ".[test]"
    ```

4.  **Run the tests:**
    ```bash
    pytest
    ```

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

repo_to_text_ai-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

repo_to_text_ai-0.2.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file repo_to_text_ai-0.2.0.tar.gz.

File metadata

  • Download URL: repo_to_text_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for repo_to_text_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8fb8d1a5d7f1a026dcc1ac2c2d28f439438bb098def79ed4faa9e2ecb076b338
MD5 931c1ad3bf0c3f9f19c154e06a47b6eb
BLAKE2b-256 bdfc95b0e3d8a50a89f999af071db511e6368cc855647e01d4312f7ee3b5f460

See more details on using hashes here.

File details

Details for the file repo_to_text_ai-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for repo_to_text_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a199391c53cccf9a8eb7b3f795c6652c3fd11b24b035eeb33f4ff7c227a9520c
MD5 19af6cb142451c27c8617561fe9d052f
BLAKE2b-256 a762a68c1c27a273d9b09112ccd00acabd5736747d13caa779939ed305072ac2

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