repo2xml.bundler.RepoBundler

class RepoBundler(repo_path: Path, *, respect_gitignore: bool = True, max_file_size: Annotated[int, beartype.vale.Is[_is_positive_int]] = 1048576, extra_ignore_patterns: list[str] | None = None, include_patterns: list[str] | None = None)[source]

Bundle a repository directory into a single XML representation for LLMs.

>>> import tempfile, pathlib
>>> with tempfile.TemporaryDirectory() as d:
...     p = pathlib.Path(d)
...     _ = (p / "hello.py").write_text("x = 1\n")
...     xml = RepoBundler(p).bundle()
...     "hello.py" in xml
True
__init__(repo_path: Path, *, respect_gitignore: bool = True, max_file_size: Annotated[int, beartype.vale.Is[_is_positive_int]] = 1048576, extra_ignore_patterns: list[str] | None = None, include_patterns: list[str] | None = None) None[source]

Initialize the repository bundler.

Parameters:
  • repo_path – Path to the repository root.

  • respect_gitignore – Whether to respect patterns in .gitignore.

  • max_file_size – Maximum file size in bytes to include in output.

  • extra_ignore_patterns – Additional gitignore-style patterns to exclude.

  • include_patterns – Patterns that override default and extra excludes.

Methods

__init__(repo_path, *[, respect_gitignore, ...])

Initialize the repository bundler.

build_file_tree(files)

Return a text tree diagram for files.

bundle(*[, show_progress])

Bundle the repository and return a well-formed XML string.

collect_files()

Return a sorted list of text files to include in the bundle.

Attributes

DEFAULT_MAX_FILE_SIZE