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.0.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.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: repo_to_text_ai-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 122c6b2a03df0d96b4669d00e9718caae30129ed195ff2fc3aaa626f695f6c69
MD5 32cd7932b3d3b272dbf5a923567f94d4
BLAKE2b-256 ef80c653edee75cf5b96d1903d2e07e057914197842f0b649343ad4fd2323622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for repo_to_text_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 761d21d5fb0b8a5e597ee5f7bd29b970b7dc551d2b4e7081176c162e96ab1de8
MD5 2ae70fcee38aa1129f7d8885e67bd672
BLAKE2b-256 a530bcade98b7fce88d79a827b2a74fecba581501e30d04143f66a8aedefedc4

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