Metadata-Version: 2.4
Name: repo2xml
Version: 2026.4.12.1
Summary: Bundle a repository into a single XML file for LLMs.
Author: rbroderi
Author-email: rbroderi <rbroderi@gmail.com>
License-Expression: Apache-2.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: beartype>=0.22.9
Requires-Dist: identify>=2.6.18
Requires-Dist: magika>=0.6.3
Requires-Dist: markitdown[all]>=0.1.5
Requires-Dist: pathspec>=0.12.1
Requires-Dist: puremagic>=2.2.0
Requires-Dist: prek>=0.3.8 ; extra == 'dev'
Requires-Dist: pyinstaller>=6.19.0 ; extra == 'dev'
Requires-Dist: pytest>=9.0.3 ; extra == 'dev'
Requires-Dist: pytest-cov>=7.1.0 ; extra == 'dev'
Requires-Dist: pytest-sugar>=1.1.1 ; extra == 'dev'
Requires-Dist: rust-just>=1.49.0 ; extra == 'dev'
Requires-Python: >=3.13
Provides-Extra: dev
Description-Content-Type: text/markdown

# repo2xml

Bundle a complete repository into a single XML file that ChatGPT
or other LLMs can read, inspired by [repomix](https://github.com/yamadashy/repomix).

## Features

- Walks any directory tree and bundles readable files into XML
- Respects `.gitignore` rules (via [pathspec](https://github.com/cpburnz/python-pathspec))
- Uses layered file detection: Magika, then `puremagic` MIME, then `identify`
- Converts supported non-text files to Markdown via `markitdown`
- Skips zero-byte files, oversized files, and common build/cache directories automatically
- Outputs a well-formed XML document with a directory tree and full file contents
- CLI tool (`repo2xml`) and importable Python API

## Installation

```bash
pip install repo2xml
```

Or with [uv](https://github.com/astral-sh/uv):

```bash
uv tool install repo2xml
```

## Usage

### CLI

```bash
# Bundle current directory to stdout
repo2xml --repo-path .

# Bundle a specific directory and save to a file
repo2xml --repo-path /path/to/repo -o repo.xml

# Skip .gitignore and add extra exclusions
repo2xml --repo-path /path/to/repo --no-gitignore --ignore "*.log" --ignore "tests/"
```

### Python API

```python
from repo2xml import bundle_repo, RepoBundler

# Simple one-liner
xml = bundle_repo("/path/to/repo")

# More control
bundler = RepoBundler(
    "/path/to/repo",
    respect_gitignore=True,
    max_file_size=500_000,
    extra_ignore_patterns=["*.csv", "data/"],
)
xml = bundler.bundle()
```

## Output Format

```xml
<?xml version="1.0" encoding="UTF-8"?>
<repository>
  <file_summary>
    <purpose>...</purpose>
    <usage_guidelines>...</usage_guidelines>
  </file_summary>
  <repository_info>
    <name>my-repo</name>
    <path>/home/user/my-repo</path>
    <file_count>42</file_count>
  </repository_info>
  <directory_structure>
    my-repo/
    ├── README.md
    └── src/
        └── main.py
  </directory_structure>
  <files>
    <file path="README.md">
      <content>...</content>
    </file>
  </files>
</repository>
```

## Development

Requires [uv](https://github.com/astral-sh/uv).

```bash
# Install dependencies
uv sync --extra dev

# Run tests
uv run pytest --doctest-modules
just test-cov

# Lint and format
uvx ruff check src
uvx ruff format src

# Build one-file executable via PyInstaller
just build
```
