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.1.1.tar.gz (6.3 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.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: repo_to_text_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 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.1.1.tar.gz
Algorithm Hash digest
SHA256 c709d337bc6fbbe8dab16bffac888bd9f05dac75703b2befbde56071cd8b05b3
MD5 6634b881b94f108c0a26faaaab507399
BLAKE2b-256 ee2af742b51b8e2625590794fcbf8cb37c71b242e624436308d15957a8036ae2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for repo_to_text_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef361187ac669442706739c63a5b470afc8f06fd61dbdc0c0ef21963004493a9
MD5 2508780c5fd9e49594b328a5c7ec698d
BLAKE2b-256 4b1ba97f6a4ed67647cd22be9504a14956c4746e5eac16c3f1e971b0281a099e

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